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
valid in predicate definitions. Returns true if EXP is
INvalid; issues error messages, caller need not. */
static bool
-validate_exp (rtx exp, const char *name, int lineno)
+validate_exp (rtx exp, const char *name, file_location loc)
{
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;
}
{
/* Ternary, binary, unary expressions: recurse into subexpressions. */
case IF_THEN_ELSE:
- if (validate_exp (XEXP (exp, 2), name, lineno))
+ if (validate_exp (XEXP (exp, 2), name, loc))
return true;
/* else fall through */
case AND:
case IOR:
- if (validate_exp (XEXP (exp, 1), name, lineno))
+ if (validate_exp (XEXP (exp, 1), name, loc))
return true;
/* else fall through */
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. */
case MATCH_CODE:
{
if (!ISDIGIT (*p) && !ISLOWER (*p))
{
- error_with_line (lineno, "%s: invalid character in path "
- "string '%s'", name, XSTR (exp, 1));
+ error_at (loc, "%s: invalid character in path "
+ "string '%s'", name, XSTR (exp, 1));
return true;
}
}
return false;
default:
- error_with_line (lineno,
- "%s: cannot use '%s' in a predicate expression",
- name, GET_RTX_NAME (GET_CODE (exp)));
+ error_at (loc, "%s: cannot use '%s' in a predicate expression",
+ name, GET_RTX_NAME (GET_CODE (exp)));
return true;
}
}
static void
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
struct constraint_data *next_textual;
const char *name;
const char *c_name; /* same as .name unless mangling is necessary */
+ file_location loc; /* location of definition */
size_t namelen;
const char *regclass; /* for register constraints */
rtx exp; /* for other constraints */
- unsigned int lineno; /* line of definition */
unsigned int is_register : 1;
unsigned int is_const_int : 1;
unsigned int is_const_dbl : 1;
/* 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
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
is mutually exclusive with EXP, and IS_MEMORY/IS_ADDRESS are only
meaningful for constraints with EXP.
static void
add_constraint (const char *name, const char *regclass,
rtx exp, bool is_memory, bool is_address,
- int lineno)
+ file_location loc)
{
struct constraint_data *c, **iter, **slot;
const char *p;
if (strcmp (name, "TARGET_MEM_CONSTRAINT") == 0)
name = general_mem;
- if (exp && validate_exp (exp, name, lineno))
+ if (exp && validate_exp (exp, name, loc))
return;
for (p = name; *p; p++)
need_mangled_name = true;
else
{
- error_with_line (lineno,
- "constraint name '%s' must be composed of "
- "letters, digits, underscores, and "
- "angle brackets", name);
+ error_at (loc, "constraint name '%s' must be composed of letters,"
+ " digits, underscores, and angle brackets", name);
return;
}
}
if (strchr (generic_constraint_letters, name[0]))
{
if (name[1] == '\0')
- error_with_line (lineno, "constraint letter '%s' cannot be "
- "redefined by the machine description", name);
+ error_at (loc, "constraint letter '%s' cannot be "
+ "redefined by the machine description", name);
else
- error_with_line (lineno, "constraint name '%s' cannot be defined by "
- "the machine description, as it begins with '%c'",
- name, name[0]);
+ error_at (loc, "constraint name '%s' cannot be defined by the machine"
+ " description, as it begins with '%c'", name, name[0]);
return;
}
if (!strcmp ((*iter)->name, name))
{
- error_with_line (lineno, "redefinition of constraint '%s'", name);
- message_with_line ((*iter)->lineno, "previous definition is here");
+ error_at (loc, "redefinition of constraint '%s'", name);
+ 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);
+ error_at (loc, "defining constraint '%s' here", 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);
+ error_at (loc, "constraint '%s' is a prefix", name);
+ message_at ((*iter)->loc, "of constraint '%s' (defined here)",
+ (*iter)->name);
return;
}
}
GET_RTX_NAME (appropriate_code)))
{
if (name[1] == '\0')
- error_with_line (lineno, "constraint letter '%c' is reserved "
- "for %s constraints",
- name[0], GET_RTX_NAME (appropriate_code));
+ error_at (loc, "constraint letter '%c' is reserved "
+ "for %s constraints", name[0],
+ GET_RTX_NAME (appropriate_code));
else
- error_with_line (lineno, "constraint names beginning with '%c' "
- "(%s) are reserved for %s constraints",
- name[0], name, GET_RTX_NAME (appropriate_code));
+ error_at (loc, "constraint names beginning with '%c' "
+ "(%s) are reserved for %s constraints",
+ name[0], name, GET_RTX_NAME (appropriate_code));
return;
}
if (is_memory)
{
if (name[1] == '\0')
- error_with_line (lineno, "constraint letter '%c' cannot be a "
- "memory constraint", name[0]);
+ error_at (loc, "constraint letter '%c' cannot be a "
+ "memory constraint", name[0]);
else
- error_with_line (lineno, "constraint name '%s' begins with '%c', "
- "and therefore cannot be a memory constraint",
- name, name[0]);
+ error_at (loc, "constraint name '%s' begins with '%c', "
+ "and therefore cannot be a memory constraint",
+ name, name[0]);
return;
}
else if (is_address)
{
if (name[1] == '\0')
- error_with_line (lineno, "constraint letter '%c' cannot be a "
- "memory constraint", name[0]);
+ error_at (loc, "constraint letter '%c' cannot be an "
+ "address constraint", name[0]);
else
- error_with_line (lineno, "constraint name '%s' begins with '%c', "
- "and therefore cannot be a memory constraint",
- name, name[0]);
+ error_at (loc, "constraint name '%s' begins with '%c', "
+ "and therefore cannot be an address constraint",
+ name, name[0]);
return;
}
}
c = XOBNEW (rtl_obstack, struct constraint_data);
c->name = name;
c->c_name = need_mangled_name ? mangle (name) : name;
- c->lineno = lineno;
+ c->loc = loc;
c->namelen = namelen;
c->regclass = regclass;
c->exp = exp;
if (exp)
{
char codes[NUM_RTX_CODE];
- compute_test_codes (exp, lineno, codes);
+ compute_test_codes (exp, loc, codes);
if (!codes[REG] && !codes[SUBREG])
c->maybe_allows_reg = false;
if (!codes[MEM])
add_constraint (XSTR (c, 0), 0, XEXP (c, 2),
GET_CODE (c) == DEFINE_MEMORY_CONSTRAINT,
GET_CODE (c) == DEFINE_ADDRESS_CONSTRAINT,
- lineno);
+ file_location (read_md_filename, lineno));
}
/* Process a DEFINE_REGISTER_CONSTRAINT expression, C. */
static void
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
static char did_you_mean_codes[NUM_RTX_CODE];
/* Recursively calculate the set of rtx codes accepted by the
- predicate expression EXP, writing the result to CODES. LINENO is
- the line number on which the directive containing EXP appeared. */
+ predicate expression EXP, writing the result to CODES. LOC is
+ the .md file location of the directive containing EXP. */
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 op1_codes[NUM_RTX_CODE];
switch (GET_CODE (exp))
{
case AND:
- compute_test_codes (XEXP (exp, 0), lineno, op0_codes);
- compute_test_codes (XEXP (exp, 1), lineno, op1_codes);
+ compute_test_codes (XEXP (exp, 0), loc, op0_codes);
+ compute_test_codes (XEXP (exp, 1), loc, op1_codes);
for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_AND (op0_codes[i], op1_codes[i]);
break;
case IOR:
- compute_test_codes (XEXP (exp, 0), lineno, op0_codes);
- compute_test_codes (XEXP (exp, 1), lineno, op1_codes);
+ compute_test_codes (XEXP (exp, 0), loc, op0_codes);
+ compute_test_codes (XEXP (exp, 1), loc, op1_codes);
for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_OR (op0_codes[i], op1_codes[i]);
break;
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++)
codes[i] = TRISTATE_NOT (op0_codes[i]);
break;
case IF_THEN_ELSE:
/* 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, 1), lineno, op1_codes);
- compute_test_codes (XEXP (exp, 2), lineno, op2_codes);
+ compute_test_codes (XEXP (exp, 0), loc, op0_codes);
+ compute_test_codes (XEXP (exp, 1), loc, op1_codes);
+ compute_test_codes (XEXP (exp, 2), loc, op2_codes);
for (i = 0; i < NUM_RTX_CODE; i++)
codes[i] = TRISTATE_OR (TRISTATE_AND (op0_codes[i], op1_codes[i]),
TRISTATE_AND (TRISTATE_NOT (op0_codes[i]),
if (*next_code == '\0')
{
- error_with_line (lineno, "empty match_code expression");
+ error_at (loc, "empty match_code expression");
break;
}
}
if (!found_it)
{
- error_with_line (lineno,
- "match_code \"%.*s\" matches nothing",
- (int) n, code);
+ error_at (loc, "match_code \"%.*s\" matches nothing",
+ (int) n, code);
for (i = 0; i < NUM_RTX_CODE; i++)
if (!strncasecmp (code, GET_RTX_NAME (i), n)
&& GET_RTX_NAME (i)[n] == '\0'
&& !did_you_mean_codes[i])
{
did_you_mean_codes[i] = 1;
- message_with_line (lineno, "(did you mean \"%s\"?)",
- GET_RTX_NAME (i));
+ message_at (loc, "(did you mean \"%s\"?)",
+ GET_RTX_NAME (i));
}
}
}
struct pred_data *p = lookup_predicate (XSTR (exp, 1));
if (!p)
{
- error_with_line (lineno, "reference to unknown predicate '%s'",
- XSTR (exp, 1));
+ error_at (loc, "reference to unknown predicate '%s'",
+ XSTR (exp, 1));
break;
}
for (i = 0; i < NUM_RTX_CODE; i++)
break;
default:
- error_with_line (lineno,
- "'%s' cannot be used in predicates or constraints",
- GET_RTX_NAME (GET_CODE (exp)));
+ error_at (loc, "'%s' cannot be used in predicates or constraints",
+ GET_RTX_NAME (GET_CODE (exp)));
memset (codes, I, NUM_RTX_CODE);
break;
}
if (GET_CODE (desc) == DEFINE_SPECIAL_PREDICATE)
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++)
if (codes[i] != N)