From patchwork Thu Jul 16 13:47:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 496697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 75BBB140295 for ; Thu, 16 Jul 2015 23:48:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=vKnYL9Kw; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=d9m2ZGVK9NVbsC3U r1aBAwSxMw6Eb6svMKfcQ1lmKDK0HSrLQEhtWTPaCS5d+LS/32XPpAK5vuqhQDYj Q1Yj7OoVZJ/kxwsNt+AMaQKRnhj6YXn4/2PFcfekcjWRK3h8g0NV3t6IsBVTBiwT 7wDlU1ubYIB6nO3d2ZOkCPK2dgU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=wicOlDHxmStqIRe9+O1Lqs gFXVA=; b=vKnYL9KwXURai29ERssTZR8lGNcaT94XX2VjJMI0eYDBOXUwpOoQa1 u1gI7c8iD4enh5bNeBwfouq4SXhnIA1nCv2zi9I+bdueY6FcjNoFUDSb92EIrcOr 40j48433ny3gCDCFqeVq47kUuS/nRbfB2lM1mfDLi+BPfKMYzhwHI= Received: (qmail 59961 invoked by alias); 16 Jul 2015 13:48:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 59838 invoked by uid 89); 16 Jul 2015 13:48:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_50, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jul 2015 13:47:59 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-8-RX-KDl2jT2uThOhyCj94PA-1; Thu, 16 Jul 2015 14:47:55 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Jul 2015 14:47:54 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Use file_location to record positions in genoutput.c Date: Thu, 16 Jul 2015 14:47:54 +0100 Message-ID: <87pp3si585.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: RX-KDl2jT2uThOhyCj94PA-1 Use file_location to replace separate filename and line number in genoutput.c. Series bootstrapped & regression-tested on x86_64-linux-gnu. I built gcc before and after the series for one target per CPU directory and checked that the output was the same (except for some filename fixes later in the series.) Applied. Thanks, Richard gcc/ * genoutput.c (data): Use a file_location to record the source position. (nothing): Delete. (idata, idata_end): Remove initialization. (constraint_data): Replace lineno with a file_location. (output_insn_data): Update after changes to data. (gen_insn, gen_peephole, gen_expand, gen_split): Likewise. (scan_operands): Likewise, using *_at rather than *_with_line functions. (process_template): Likewise. (validate_insn_alternatives): Likewise. (validate_insn_operands): Likewise. (validate_optab_operands): Likewise. (init_insn_for_nothing): Initialize idata and idata_end. (note_constraint): Update after changes to constraint_data, using at rather than with_line functions. (mdep_constraint_len): Take a file_location rather than a line number. Use at rather than with_line functions. Index: gcc/genoutput.c =================================================================== --- gcc/genoutput.c 2015-07-12 14:18:26.631114404 +0100 +++ gcc/genoutput.c 2015-07-12 20:53:11.543868618 +0100 @@ -154,9 +154,8 @@ struct data struct data *next; const char *name; const char *template_code; + file_location loc; int code_number; - const char *filename; - int lineno; int n_generator_args; /* Number of arguments passed to generator */ int n_operands; /* Number of operands this insn recognizes */ int n_dups; /* Number times match_dup appears in pattern */ @@ -166,15 +165,12 @@ struct data struct operand_data operand[MAX_MAX_OPERANDS]; }; -/* A dummy insn, for CODE_FOR_nothing. */ -static struct data nothing; - /* This variable points to the first link in the insn chain. */ -static struct data *idata = ¬hing; +static struct data *idata; /* This variable points to the end of the insn chain. This is where everything relevant from the machien description is appended to. */ -static struct data **idata_end = ¬hing.next; +static struct data **idata_end; static void output_prologue (void); @@ -196,9 +192,9 @@ static void gen_split (rtx, int); struct constraint_data { struct constraint_data *next_this_letter; - int lineno; + file_location loc; unsigned int namelen; - const char name[1]; + char name[1]; }; /* All machine-independent constraint characters (except digits) that @@ -208,7 +204,7 @@ static const char indep_constraints[] = static struct constraint_data * constraints_by_letter_table[1 << CHAR_BIT]; -static int mdep_constraint_len (const char *, int, int); +static int mdep_constraint_len (const char *, file_location, int); static void note_constraint (rtx, int); static void @@ -306,7 +302,7 @@ output_insn_data (void) for (d = idata; d; d = d->next) { - printf (" /* %s:%d */\n", d->filename, d->lineno); + printf (" /* %s:%d */\n", d->loc.filename, d->loc.lineno); printf (" {\n"); if (d->name) @@ -449,11 +445,11 @@ scan_operands (struct data *d, rtx part, opno = XINT (part, 0); if (opno >= MAX_MAX_OPERANDS) { - error_with_line (d->lineno, "maximum number of operands exceeded"); + error_at (d->loc, "maximum number of operands exceeded"); return; } if (d->operand[opno].seen) - error_with_line (d->lineno, "repeated operand number %d\n", opno); + error_at (d->loc, "repeated operand number %d\n", opno); d->operand[opno].seen = 1; d->operand[opno].mode = GET_MODE (part); @@ -470,11 +466,11 @@ scan_operands (struct data *d, rtx part, opno = XINT (part, 0); if (opno >= MAX_MAX_OPERANDS) { - error_with_line (d->lineno, "maximum number of operands exceeded"); + error_at (d->loc, "maximum number of operands exceeded"); return; } if (d->operand[opno].seen) - error_with_line (d->lineno, "repeated operand number %d\n", opno); + error_at (d->loc, "repeated operand number %d\n", opno); d->operand[opno].seen = 1; d->operand[opno].mode = GET_MODE (part); @@ -492,11 +488,11 @@ scan_operands (struct data *d, rtx part, opno = XINT (part, 0); if (opno >= MAX_MAX_OPERANDS) { - error_with_line (d->lineno, "maximum number of operands exceeded"); + error_at (d->loc, "maximum number of operands exceeded"); return; } if (d->operand[opno].seen) - error_with_line (d->lineno, "repeated operand number %d\n", opno); + error_at (d->loc, "repeated operand number %d\n", opno); d->operand[opno].seen = 1; d->operand[opno].mode = GET_MODE (part); @@ -708,8 +704,7 @@ process_template (struct data *d, const sp = ep + 1; if (sp != ep) - message_with_line (d->lineno, - "trailing whitespace in output template"); + message_at (d->loc, "trailing whitespace in output template"); while (cp < sp) { @@ -732,11 +727,11 @@ process_template (struct data *d, const i++; } if (i == 1) - message_with_line (d->lineno, - "'@' is redundant for output template with single alternative"); + message_at (d->loc, "'@' is redundant for output template with" + " single alternative"); if (i != d->n_alternatives) - error_with_line (d->lineno, - "wrong number of alternatives in the output template"); + error_at (d->loc, "wrong number of alternatives in the output" + " template"); if (found_star) puts (" default: gcc_unreachable ();\n }\n}"); @@ -773,9 +768,8 @@ validate_insn_alternatives (struct data { if ((c == '%' || c == '=' || c == '+') && p != d->operand[start].constraint) - error_with_line (d->lineno, - "character '%c' can only be used at the" - " beginning of a constraint string", c); + error_at (d->loc, "character '%c' can only be used at the" + " beginning of a constraint string", c); if (c == '=' || c == '+') seen_write = true; @@ -783,10 +777,8 @@ validate_insn_alternatives (struct data /* Earlyclobber operands must always be marked write-only or read/write. */ if (!seen_write && c == '&') - error_with_line (d->lineno, - "earlyclobber operands may not be" - " read-only in alternative %d", - which_alternative); + error_at (d->loc, "earlyclobber operands may not be" + " read-only in alternative %d", which_alternative); if (ISSPACE (c) || strchr (indep_constraints, c)) len = 1; @@ -799,7 +791,7 @@ validate_insn_alternatives (struct data len = q - p; } else - len = mdep_constraint_len (p, d->lineno, start); + len = mdep_constraint_len (p, d->loc, start); if (c == ',') { @@ -810,17 +802,15 @@ validate_insn_alternatives (struct data for (i = 1; i < len; i++) if (p[i] == '\0') { - error_with_line (d->lineno, - "NUL in alternative %d of operand %d", - which_alternative, start); + error_at (d->loc, "NUL in alternative %d of operand %d", + which_alternative, start); alternative_count_unsure = 1; break; } else if (strchr (",#*", p[i])) { - error_with_line (d->lineno, - "'%c' in alternative %d of operand %d", - p[i], which_alternative, start); + error_at (d->loc, "'%c' in alternative %d of operand %d", + p[i], which_alternative, start); alternative_count_unsure = 1; } } @@ -829,9 +819,8 @@ validate_insn_alternatives (struct data if (n == 0) n = d->operand[start].n_alternatives; else if (n != d->operand[start].n_alternatives) - error_with_line (d->lineno, - "wrong number of alternatives in operand %d", - start); + error_at (d->loc, "wrong number of alternatives in operand %d", + start); } } @@ -848,7 +837,7 @@ validate_insn_operands (struct data *d) for (i = 0; i < d->n_operands; ++i) if (d->operand[i].seen == 0) - error_with_line (d->lineno, "missing operand %d", i); + error_at (d->loc, "missing operand %d", i); } static void @@ -862,7 +851,7 @@ validate_optab_operands (struct data *d) && d->name[strlen (d->name) - 1] == '4' && d->operand[0].mode == VOIDmode) { - message_with_line (d->lineno, "missing mode for operand 0 of cstore"); + message_at (d->loc, "missing mode for operand 0 of cstore"); have_error = 1; } } @@ -875,12 +864,11 @@ validate_optab_operands (struct data *d) gen_insn (rtx insn, int lineno) { struct pattern_stats stats; - struct data *d = XNEW (struct data); + data *d = new data; int i; d->code_number = next_code_number; - d->filename = read_md_filename; - d->lineno = lineno; + d->loc = file_location (read_md_filename, lineno); if (XSTR (insn, 0)[0]) d->name = XSTR (insn, 0); else @@ -917,12 +905,11 @@ gen_insn (rtx insn, int lineno) gen_peephole (rtx peep, int lineno) { struct pattern_stats stats; - struct data *d = XNEW (struct data); + data *d = new data; int i; d->code_number = next_code_number; - d->filename = read_md_filename; - d->lineno = lineno; + d->loc = file_location (read_md_filename, lineno); d->name = 0; /* Build up the list in the same order as the insns are seen @@ -956,12 +943,11 @@ gen_peephole (rtx peep, int lineno) gen_expand (rtx insn, int lineno) { struct pattern_stats stats; - struct data *d = XNEW (struct data); + data *d = new data; int i; d->code_number = next_code_number; - d->filename = read_md_filename; - d->lineno = lineno; + d->loc = file_location (read_md_filename, lineno); if (XSTR (insn, 0)[0]) d->name = XSTR (insn, 0); else @@ -1001,12 +987,11 @@ gen_expand (rtx insn, int lineno) gen_split (rtx split, int lineno) { struct pattern_stats stats; - struct data *d = XNEW (struct data); + data *d = new data; int i; d->code_number = next_code_number; - d->filename = read_md_filename; - d->lineno = lineno; + d->loc = file_location (read_md_filename, lineno); d->name = 0; /* Build up the list in the same order as the insns are seen @@ -1037,9 +1022,11 @@ gen_split (rtx split, int lineno) static void init_insn_for_nothing (void) { - memset (¬hing, 0, sizeof (nothing)); - nothing.name = "*placeholder_for_nothing"; - nothing.filename = ""; + idata = XCNEW (struct data); + new (idata) data (); + idata->name = "*placeholder_for_nothing"; + idata->loc = file_location ("", 0); + idata_end = &idata->next; } extern int main (int, char **); @@ -1189,28 +1176,30 @@ note_constraint (rtx exp, int lineno) if (!strcmp ((*iter)->name, name)) { error_with_line (lineno, "redefinition of constraint '%s'", name); - message_with_line ((*iter)->lineno, "previous definition is here"); + message_at ((*iter)->loc, "previous definition is here"); return; } else if (!strncmp ((*iter)->name, name, (*iter)->namelen)) { error_with_line (lineno, "defining constraint '%s' here", name); - message_with_line ((*iter)->lineno, "renders constraint '%s' " - "(defined here) a prefix", (*iter)->name); + message_at ((*iter)->loc, "renders constraint '%s' " + "(defined here) a prefix", (*iter)->name); return; } else if (!strncmp ((*iter)->name, name, namelen)) { error_with_line (lineno, "constraint '%s' is a prefix", name); - message_with_line ((*iter)->lineno, "of constraint '%s' " - "(defined here)", (*iter)->name); + message_at ((*iter)->loc, "of constraint '%s' " + "(defined here)", (*iter)->name); return; } } - new_cdata = XNEWVAR (struct constraint_data, sizeof (struct constraint_data) + namelen); + new_cdata = XNEWVAR (struct constraint_data, + sizeof (struct constraint_data) + namelen); + new (new_cdata) constraint_data (); strcpy (CONST_CAST (char *, new_cdata->name), name); new_cdata->namelen = namelen; - new_cdata->lineno = lineno; + new_cdata->loc = file_location (read_md_filename, lineno); new_cdata->next_this_letter = *slot; *slot = new_cdata; } @@ -1220,7 +1209,7 @@ note_constraint (rtx exp, int lineno) is no such constraint. Does not expect to be called for generic constraints. */ static int -mdep_constraint_len (const char *s, int lineno, int opno) +mdep_constraint_len (const char *s, file_location loc, int opno) { struct constraint_data *p; @@ -1231,9 +1220,8 @@ mdep_constraint_len (const char *s, int if (!strncmp (s, p->name, p->namelen)) return p->namelen; - error_with_line (lineno, - "error: undefined machine-specific constraint " - "at this point: \"%s\"", s); - message_with_line (lineno, "note: in operand %d", opno); + error_at (loc, "error: undefined machine-specific constraint " + "at this point: \"%s\"", s); + message_at (loc, "note: in operand %d", opno); return 1; /* safe */ }