Commit c9f84f2e by Richard Sandiford Committed by Richard Sandiford

gensupport.h (compute_test_codes): Take a file_location rather than a line number.

gcc/
	* gensupport.h (compute_test_codes): Take a file_location rather
	than a line number.
	* gensupport.c (compute_test_codes): Likewise.  Use *_at functions
	rather than *_with_line functions.
	(process_define_predicate): Update call to compute_test_codes.
	* genpreds.c (validate_exp): Take a file_location rather than a
	line number.  Use *_at functions rather than *_with_line functions.
	(process_define_predicate): Update call to validate_exp.
	(constraint_data): Replace lineno field with a file_location.
	(add_constraint): Take a file_location rather than a line number.
	Use *_at functions rather than *_with_line functions.  Fix error
	message for address constraints.  Update after changes to
	validate_exp, constraint_data and compute_test_codes.
	(process_define_constraint): Update accordingly.
	(process_define_register_constraint): Likewise.

From-SVN: r225882
parent ca018d3c
2015-07-16 Richard Sandiford <richard.sandiford@arm.com> 2015-07-16 Richard Sandiford <richard.sandiford@arm.com>
* gensupport.h (compute_test_codes): Take a file_location rather
than a line number.
* gensupport.c (compute_test_codes): Likewise. Use *_at functions
rather than *_with_line functions.
(process_define_predicate): Update call to compute_test_codes.
* genpreds.c (validate_exp): Take a file_location rather than a
line number. Use *_at functions rather than *_with_line functions.
(process_define_predicate): Update call to validate_exp.
(constraint_data): Replace lineno field with a file_location.
(add_constraint): Take a file_location rather than a line number.
Use *_at functions rather than *_with_line functions. Fix error
message for address constraints. Update after changes to
validate_exp, constraint_data and compute_test_codes.
(process_define_constraint): Update accordingly.
(process_define_register_constraint): Likewise.
2015-07-16 Richard Sandiford <richard.sandiford@arm.com>
* genoutput.c (data): Use a file_location to record the source * genoutput.c (data): Use a file_location to record the source
position. position.
(nothing): Delete. (nothing): Delete.
......
...@@ -32,16 +32,16 @@ along with GCC; see the file COPYING3. If not see ...@@ -32,16 +32,16 @@ along with GCC; see the file COPYING3. If not see
static char general_mem[] = { TARGET_MEM_CONSTRAINT, 0 }; static char general_mem[] = { TARGET_MEM_CONSTRAINT, 0 };
/* Given a predicate expression EXP, from form NAME at line LINENO, /* Given a predicate expression EXP, from form NAME at location LOC,
verify that it does not contain any RTL constructs which are not verify that it does not contain any RTL constructs which are not
valid in predicate definitions. Returns true if EXP is valid in predicate definitions. Returns true if EXP is
INvalid; issues error messages, caller need not. */ INvalid; issues error messages, caller need not. */
static bool static bool
validate_exp (rtx exp, const char *name, int lineno) validate_exp (rtx exp, const char *name, file_location loc)
{ {
if (exp == 0) if (exp == 0)
{ {
message_with_line (lineno, "%s: must give a predicate expression", name); message_at (loc, "%s: must give a predicate expression", name);
return true; return true;
} }
...@@ -49,16 +49,16 @@ validate_exp (rtx exp, const char *name, int lineno) ...@@ -49,16 +49,16 @@ validate_exp (rtx exp, const char *name, int lineno)
{ {
/* Ternary, binary, unary expressions: recurse into subexpressions. */ /* Ternary, binary, unary expressions: recurse into subexpressions. */
case IF_THEN_ELSE: case IF_THEN_ELSE:
if (validate_exp (XEXP (exp, 2), name, lineno)) if (validate_exp (XEXP (exp, 2), name, loc))
return true; return true;
/* else fall through */ /* else fall through */
case AND: case AND:
case IOR: case IOR:
if (validate_exp (XEXP (exp, 1), name, lineno)) if (validate_exp (XEXP (exp, 1), name, loc))
return true; return true;
/* else fall through */ /* else fall through */
case NOT: case NOT:
return validate_exp (XEXP (exp, 0), name, lineno); return validate_exp (XEXP (exp, 0), name, loc);
/* MATCH_CODE might have a syntax error in its path expression. */ /* MATCH_CODE might have a syntax error in its path expression. */
case MATCH_CODE: case MATCH_CODE:
...@@ -68,8 +68,8 @@ validate_exp (rtx exp, const char *name, int lineno) ...@@ -68,8 +68,8 @@ validate_exp (rtx exp, const char *name, int lineno)
{ {
if (!ISDIGIT (*p) && !ISLOWER (*p)) if (!ISDIGIT (*p) && !ISLOWER (*p))
{ {
error_with_line (lineno, "%s: invalid character in path " error_at (loc, "%s: invalid character in path "
"string '%s'", name, XSTR (exp, 1)); "string '%s'", name, XSTR (exp, 1));
return true; return true;
} }
} }
...@@ -82,9 +82,8 @@ validate_exp (rtx exp, const char *name, int lineno) ...@@ -82,9 +82,8 @@ validate_exp (rtx exp, const char *name, int lineno)
return false; return false;
default: default:
error_with_line (lineno, error_at (loc, "%s: cannot use '%s' in a predicate expression",
"%s: cannot use '%s' in a predicate expression", name, GET_RTX_NAME (GET_CODE (exp)));
name, GET_RTX_NAME (GET_CODE (exp)));
return true; return true;
} }
} }
...@@ -94,7 +93,8 @@ validate_exp (rtx exp, const char *name, int lineno) ...@@ -94,7 +93,8 @@ validate_exp (rtx exp, const char *name, int lineno)
static void static void
process_define_predicate (rtx defn, int lineno) process_define_predicate (rtx defn, int lineno)
{ {
validate_exp (XEXP (defn, 1), XSTR (defn, 0), lineno); validate_exp (XEXP (defn, 1), XSTR (defn, 0),
file_location (read_md_filename, lineno));
} }
/* Given a predicate, if it has an embedded C block, write the block /* Given a predicate, if it has an embedded C block, write the block
...@@ -671,10 +671,10 @@ struct constraint_data ...@@ -671,10 +671,10 @@ struct constraint_data
struct constraint_data *next_textual; struct constraint_data *next_textual;
const char *name; const char *name;
const char *c_name; /* same as .name unless mangling is necessary */ const char *c_name; /* same as .name unless mangling is necessary */
file_location loc; /* location of definition */
size_t namelen; size_t namelen;
const char *regclass; /* for register constraints */ const char *regclass; /* for register constraints */
rtx exp; /* for other constraints */ rtx exp; /* for other constraints */
unsigned int lineno; /* line of definition */
unsigned int is_register : 1; unsigned int is_register : 1;
unsigned int is_const_int : 1; unsigned int is_const_int : 1;
unsigned int is_const_dbl : 1; unsigned int is_const_dbl : 1;
...@@ -754,7 +754,8 @@ mangle (const char *name) ...@@ -754,7 +754,8 @@ mangle (const char *name)
/* Add one constraint, of any sort, to the tables. NAME is its name; /* Add one constraint, of any sort, to the tables. NAME is its name;
REGCLASS is the register class, if any; EXP is the expression to REGCLASS is the register class, if any; EXP is the expression to
test, if any; IS_MEMORY and IS_ADDRESS indicate memory and address test, if any; IS_MEMORY and IS_ADDRESS indicate memory and address
constraints, respectively; LINENO is the line number from the MD reader. constraints, respectively; LOC is the .md file location.
Not all combinations of arguments are valid; most importantly, REGCLASS Not all combinations of arguments are valid; most importantly, REGCLASS
is mutually exclusive with EXP, and IS_MEMORY/IS_ADDRESS are only is mutually exclusive with EXP, and IS_MEMORY/IS_ADDRESS are only
meaningful for constraints with EXP. meaningful for constraints with EXP.
...@@ -765,7 +766,7 @@ mangle (const char *name) ...@@ -765,7 +766,7 @@ mangle (const char *name)
static void static void
add_constraint (const char *name, const char *regclass, add_constraint (const char *name, const char *regclass,
rtx exp, bool is_memory, bool is_address, rtx exp, bool is_memory, bool is_address,
int lineno) file_location loc)
{ {
struct constraint_data *c, **iter, **slot; struct constraint_data *c, **iter, **slot;
const char *p; const char *p;
...@@ -777,7 +778,7 @@ add_constraint (const char *name, const char *regclass, ...@@ -777,7 +778,7 @@ add_constraint (const char *name, const char *regclass,
if (strcmp (name, "TARGET_MEM_CONSTRAINT") == 0) if (strcmp (name, "TARGET_MEM_CONSTRAINT") == 0)
name = general_mem; name = general_mem;
if (exp && validate_exp (exp, name, lineno)) if (exp && validate_exp (exp, name, loc))
return; return;
for (p = name; *p; p++) for (p = name; *p; p++)
...@@ -787,10 +788,8 @@ add_constraint (const char *name, const char *regclass, ...@@ -787,10 +788,8 @@ add_constraint (const char *name, const char *regclass,
need_mangled_name = true; need_mangled_name = true;
else else
{ {
error_with_line (lineno, error_at (loc, "constraint name '%s' must be composed of letters,"
"constraint name '%s' must be composed of " " digits, underscores, and angle brackets", name);
"letters, digits, underscores, and "
"angle brackets", name);
return; return;
} }
} }
...@@ -798,12 +797,11 @@ add_constraint (const char *name, const char *regclass, ...@@ -798,12 +797,11 @@ add_constraint (const char *name, const char *regclass,
if (strchr (generic_constraint_letters, name[0])) if (strchr (generic_constraint_letters, name[0]))
{ {
if (name[1] == '\0') if (name[1] == '\0')
error_with_line (lineno, "constraint letter '%s' cannot be " error_at (loc, "constraint letter '%s' cannot be "
"redefined by the machine description", name); "redefined by the machine description", name);
else else
error_with_line (lineno, "constraint name '%s' cannot be defined by " error_at (loc, "constraint name '%s' cannot be defined by the machine"
"the machine description, as it begins with '%c'", " description, as it begins with '%c'", name, name[0]);
name, name[0]);
return; return;
} }
...@@ -822,22 +820,22 @@ add_constraint (const char *name, const char *regclass, ...@@ -822,22 +820,22 @@ add_constraint (const char *name, const char *regclass,
if (!strcmp ((*iter)->name, name)) if (!strcmp ((*iter)->name, name))
{ {
error_with_line (lineno, "redefinition of constraint '%s'", name); error_at (loc, "redefinition of constraint '%s'", name);
message_with_line ((*iter)->lineno, "previous definition is here"); message_at ((*iter)->loc, "previous definition is here");
return; return;
} }
else if (!strncmp ((*iter)->name, name, (*iter)->namelen)) else if (!strncmp ((*iter)->name, name, (*iter)->namelen))
{ {
error_with_line (lineno, "defining constraint '%s' here", name); error_at (loc, "defining constraint '%s' here", name);
message_with_line ((*iter)->lineno, "renders constraint '%s' " message_at ((*iter)->loc, "renders constraint '%s' "
"(defined here) a prefix", (*iter)->name); "(defined here) a prefix", (*iter)->name);
return; return;
} }
else if (!strncmp ((*iter)->name, name, namelen)) else if (!strncmp ((*iter)->name, name, namelen))
{ {
error_with_line (lineno, "constraint '%s' is a prefix", name); error_at (loc, "constraint '%s' is a prefix", name);
message_with_line ((*iter)->lineno, "of constraint '%s' " message_at ((*iter)->loc, "of constraint '%s' (defined here)",
"(defined here)", (*iter)->name); (*iter)->name);
return; return;
} }
} }
...@@ -858,36 +856,36 @@ add_constraint (const char *name, const char *regclass, ...@@ -858,36 +856,36 @@ add_constraint (const char *name, const char *regclass,
GET_RTX_NAME (appropriate_code))) GET_RTX_NAME (appropriate_code)))
{ {
if (name[1] == '\0') if (name[1] == '\0')
error_with_line (lineno, "constraint letter '%c' is reserved " error_at (loc, "constraint letter '%c' is reserved "
"for %s constraints", "for %s constraints", name[0],
name[0], GET_RTX_NAME (appropriate_code)); GET_RTX_NAME (appropriate_code));
else else
error_with_line (lineno, "constraint names beginning with '%c' " error_at (loc, "constraint names beginning with '%c' "
"(%s) are reserved for %s constraints", "(%s) are reserved for %s constraints",
name[0], name, GET_RTX_NAME (appropriate_code)); name[0], name, GET_RTX_NAME (appropriate_code));
return; return;
} }
if (is_memory) if (is_memory)
{ {
if (name[1] == '\0') if (name[1] == '\0')
error_with_line (lineno, "constraint letter '%c' cannot be a " error_at (loc, "constraint letter '%c' cannot be a "
"memory constraint", name[0]); "memory constraint", name[0]);
else else
error_with_line (lineno, "constraint name '%s' begins with '%c', " error_at (loc, "constraint name '%s' begins with '%c', "
"and therefore cannot be a memory constraint", "and therefore cannot be a memory constraint",
name, name[0]); name, name[0]);
return; return;
} }
else if (is_address) else if (is_address)
{ {
if (name[1] == '\0') if (name[1] == '\0')
error_with_line (lineno, "constraint letter '%c' cannot be a " error_at (loc, "constraint letter '%c' cannot be an "
"memory constraint", name[0]); "address constraint", name[0]);
else else
error_with_line (lineno, "constraint name '%s' begins with '%c', " error_at (loc, "constraint name '%s' begins with '%c', "
"and therefore cannot be a memory constraint", "and therefore cannot be an address constraint",
name, name[0]); name, name[0]);
return; return;
} }
} }
...@@ -896,7 +894,7 @@ add_constraint (const char *name, const char *regclass, ...@@ -896,7 +894,7 @@ add_constraint (const char *name, const char *regclass,
c = XOBNEW (rtl_obstack, struct constraint_data); c = XOBNEW (rtl_obstack, struct constraint_data);
c->name = name; c->name = name;
c->c_name = need_mangled_name ? mangle (name) : name; c->c_name = need_mangled_name ? mangle (name) : name;
c->lineno = lineno; c->loc = loc;
c->namelen = namelen; c->namelen = namelen;
c->regclass = regclass; c->regclass = regclass;
c->exp = exp; c->exp = exp;
...@@ -911,7 +909,7 @@ add_constraint (const char *name, const char *regclass, ...@@ -911,7 +909,7 @@ add_constraint (const char *name, const char *regclass,
if (exp) if (exp)
{ {
char codes[NUM_RTX_CODE]; char codes[NUM_RTX_CODE];
compute_test_codes (exp, lineno, codes); compute_test_codes (exp, loc, codes);
if (!codes[REG] && !codes[SUBREG]) if (!codes[REG] && !codes[SUBREG])
c->maybe_allows_reg = false; c->maybe_allows_reg = false;
if (!codes[MEM]) if (!codes[MEM])
...@@ -943,14 +941,15 @@ process_define_constraint (rtx c, int lineno) ...@@ -943,14 +941,15 @@ process_define_constraint (rtx c, int lineno)
add_constraint (XSTR (c, 0), 0, XEXP (c, 2), add_constraint (XSTR (c, 0), 0, XEXP (c, 2),
GET_CODE (c) == DEFINE_MEMORY_CONSTRAINT, GET_CODE (c) == DEFINE_MEMORY_CONSTRAINT,
GET_CODE (c) == DEFINE_ADDRESS_CONSTRAINT, GET_CODE (c) == DEFINE_ADDRESS_CONSTRAINT,
lineno); file_location (read_md_filename, lineno));
} }
/* Process a DEFINE_REGISTER_CONSTRAINT expression, C. */ /* Process a DEFINE_REGISTER_CONSTRAINT expression, C. */
static void static void
process_define_register_constraint (rtx c, int lineno) process_define_register_constraint (rtx c, int lineno)
{ {
add_constraint (XSTR (c, 0), XSTR (c, 1), 0, false, false, lineno); add_constraint (XSTR (c, 0), XSTR (c, 1), 0, false, false,
file_location (read_md_filename, lineno));
} }
/* Put the constraints into enum order. We want to keep constraints /* Put the constraints into enum order. We want to keep constraints
......
...@@ -209,11 +209,11 @@ add_implicit_parallel (rtvec vec) ...@@ -209,11 +209,11 @@ add_implicit_parallel (rtvec vec)
static char did_you_mean_codes[NUM_RTX_CODE]; static char did_you_mean_codes[NUM_RTX_CODE];
/* Recursively calculate the set of rtx codes accepted by the /* Recursively calculate the set of rtx codes accepted by the
predicate expression EXP, writing the result to CODES. LINENO is predicate expression EXP, writing the result to CODES. LOC is
the line number on which the directive containing EXP appeared. */ the .md file location of the directive containing EXP. */
void void
compute_test_codes (rtx exp, int lineno, char *codes) compute_test_codes (rtx exp, file_location loc, char *codes)
{ {
char op0_codes[NUM_RTX_CODE]; char op0_codes[NUM_RTX_CODE];
char op1_codes[NUM_RTX_CODE]; char op1_codes[NUM_RTX_CODE];
...@@ -223,29 +223,29 @@ compute_test_codes (rtx exp, int lineno, char *codes) ...@@ -223,29 +223,29 @@ compute_test_codes (rtx exp, int lineno, char *codes)
switch (GET_CODE (exp)) switch (GET_CODE (exp))
{ {
case AND: case AND:
compute_test_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), loc, op0_codes);
compute_test_codes (XEXP (exp, 1), lineno, op1_codes); compute_test_codes (XEXP (exp, 1), loc, op1_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_AND (op0_codes[i], op1_codes[i]); codes[i] = TRISTATE_AND (op0_codes[i], op1_codes[i]);
break; break;
case IOR: case IOR:
compute_test_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), loc, op0_codes);
compute_test_codes (XEXP (exp, 1), lineno, op1_codes); compute_test_codes (XEXP (exp, 1), loc, op1_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_OR (op0_codes[i], op1_codes[i]); codes[i] = TRISTATE_OR (op0_codes[i], op1_codes[i]);
break; break;
case NOT: case NOT:
compute_test_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), loc, op0_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_NOT (op0_codes[i]); codes[i] = TRISTATE_NOT (op0_codes[i]);
break; break;
case IF_THEN_ELSE: case IF_THEN_ELSE:
/* a ? b : c accepts the same codes as (a & b) | (!a & c). */ /* a ? b : c accepts the same codes as (a & b) | (!a & c). */
compute_test_codes (XEXP (exp, 0), lineno, op0_codes); compute_test_codes (XEXP (exp, 0), loc, op0_codes);
compute_test_codes (XEXP (exp, 1), lineno, op1_codes); compute_test_codes (XEXP (exp, 1), loc, op1_codes);
compute_test_codes (XEXP (exp, 2), lineno, op2_codes); compute_test_codes (XEXP (exp, 2), loc, op2_codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_OR (TRISTATE_AND (op0_codes[i], op1_codes[i]), codes[i] = TRISTATE_OR (TRISTATE_AND (op0_codes[i], op1_codes[i]),
TRISTATE_AND (TRISTATE_NOT (op0_codes[i]), TRISTATE_AND (TRISTATE_NOT (op0_codes[i]),
...@@ -269,7 +269,7 @@ compute_test_codes (rtx exp, int lineno, char *codes) ...@@ -269,7 +269,7 @@ compute_test_codes (rtx exp, int lineno, char *codes)
if (*next_code == '\0') if (*next_code == '\0')
{ {
error_with_line (lineno, "empty match_code expression"); error_at (loc, "empty match_code expression");
break; break;
} }
...@@ -288,17 +288,16 @@ compute_test_codes (rtx exp, int lineno, char *codes) ...@@ -288,17 +288,16 @@ compute_test_codes (rtx exp, int lineno, char *codes)
} }
if (!found_it) if (!found_it)
{ {
error_with_line (lineno, error_at (loc, "match_code \"%.*s\" matches nothing",
"match_code \"%.*s\" matches nothing", (int) n, code);
(int) n, code);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
if (!strncasecmp (code, GET_RTX_NAME (i), n) if (!strncasecmp (code, GET_RTX_NAME (i), n)
&& GET_RTX_NAME (i)[n] == '\0' && GET_RTX_NAME (i)[n] == '\0'
&& !did_you_mean_codes[i]) && !did_you_mean_codes[i])
{ {
did_you_mean_codes[i] = 1; did_you_mean_codes[i] = 1;
message_with_line (lineno, "(did you mean \"%s\"?)", message_at (loc, "(did you mean \"%s\"?)",
GET_RTX_NAME (i)); GET_RTX_NAME (i));
} }
} }
} }
...@@ -312,8 +311,8 @@ compute_test_codes (rtx exp, int lineno, char *codes) ...@@ -312,8 +311,8 @@ compute_test_codes (rtx exp, int lineno, char *codes)
struct pred_data *p = lookup_predicate (XSTR (exp, 1)); struct pred_data *p = lookup_predicate (XSTR (exp, 1));
if (!p) if (!p)
{ {
error_with_line (lineno, "reference to unknown predicate '%s'", error_at (loc, "reference to unknown predicate '%s'",
XSTR (exp, 1)); XSTR (exp, 1));
break; break;
} }
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
...@@ -328,9 +327,8 @@ compute_test_codes (rtx exp, int lineno, char *codes) ...@@ -328,9 +327,8 @@ compute_test_codes (rtx exp, int lineno, char *codes)
break; break;
default: default:
error_with_line (lineno, error_at (loc, "'%s' cannot be used in predicates or constraints",
"'%s' cannot be used in predicates or constraints", GET_RTX_NAME (GET_CODE (exp)));
GET_RTX_NAME (GET_CODE (exp)));
memset (codes, I, NUM_RTX_CODE); memset (codes, I, NUM_RTX_CODE);
break; break;
} }
...@@ -380,7 +378,7 @@ process_define_predicate (rtx desc, file_location loc) ...@@ -380,7 +378,7 @@ process_define_predicate (rtx desc, file_location loc)
if (GET_CODE (desc) == DEFINE_SPECIAL_PREDICATE) if (GET_CODE (desc) == DEFINE_SPECIAL_PREDICATE)
pred->special = true; pred->special = true;
compute_test_codes (XEXP (desc, 1), loc.lineno, codes); compute_test_codes (XEXP (desc, 1), loc, codes);
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
if (codes[i] != N) if (codes[i] != N)
......
...@@ -110,7 +110,7 @@ struct pattern_stats ...@@ -110,7 +110,7 @@ struct pattern_stats
}; };
extern void get_pattern_stats (struct pattern_stats *ranges, rtvec vec); extern void get_pattern_stats (struct pattern_stats *ranges, rtvec vec);
extern void compute_test_codes (rtx, int, char *); extern void compute_test_codes (rtx, file_location, char *);
extern const char *get_emit_function (rtx); extern const char *get_emit_function (rtx);
extern bool needs_barrier_p (rtx); extern bool needs_barrier_p (rtx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment