`constrain_operands' is called. If either of these cases of a reference to
an operand is found, `extract_insn' is called.
- The special attribute `length' is also recognized. For this operand,
+ The special attribute `length' is also recognized. For this operand,
expressions involving the address of an operand or the current insn,
(address (pc)), are valid. In this case, an initial pass is made to
set all lengths that do not depend on address. Those that do are set to
parameters as it does not depend on any particular insn. Constant
attributes are typically used to specify which variety of processor is
used.
-
+
Internal attributes are defined to handle DEFINE_DELAY and
DEFINE_FUNCTION_UNIT. Special routines are output for these cases.
`volatil' (MEM_VOLATILE_P): During simplify_by_exploding the value of an
EQ_ATTR rtx is true if !volatil and false if volatil. */
-
#include "hconfig.h"
#include "system.h"
#include "rtl.h"
struct insn_def
{
- int insn_code; /* Instruction number. */
- int insn_index; /* Expression numer in file, for errors. */
struct insn_def *next; /* Next insn in chain. */
rtx def; /* The DEFINE_... */
+ int insn_code; /* Instruction number. */
+ int insn_index; /* Expression numer in file, for errors. */
+ int lineno; /* Line number. */
int num_alternatives; /* Number of alternatives. */
int vec_idx; /* Index of attribute vector in `def'. */
};
struct insn_ent
{
+ struct insn_ent *next; /* Next in chain. */
int insn_code; /* Instruction number. */
int insn_index; /* Index of definition in file */
- struct insn_ent *next; /* Next in chain. */
+ int lineno; /* Line number. */
};
/* Each value of an attribute (either constant or computed) is assigned a
unsigned blockage_p : 1; /* this is the blockage range function */
struct attr_value *first_value; /* First value of this attribute. */
struct attr_value *default_val; /* Default value for this attribute. */
+ int lineno; /* Line number. */
};
#define NULL_ATTR (struct attr_desc *) NULL
rtx def; /* DEFINE_DELAY expression. */
struct delay_desc *next; /* Next DEFINE_DELAY. */
int num; /* Number of DEFINE_DELAY, starting at 1. */
+ int lineno; /* Line number. */
};
/* Record information about each DEFINE_FUNCTION_UNIT. */
int issue_delay; /* Cost until unit can accept another insn. */
rtx conflict_exp; /* Expression TRUE for insns incurring issue delay. */
rtx issue_exp; /* Expression computing issue delay. */
+ int lineno; /* Line number. */
};
/* Record information about each function unit mentioned in a
rtx default_cost; /* Conflict cost, if constant. */
struct range issue_delay; /* Range of issue delay values. */
int max_blockage; /* Maximum time an insn blocks the unit. */
+ int first_lineno; /* First seen line number. */
};
/* Listheads of above structures. */
computed and becomes the corresponding value. To do this, we must be
able to enumerate all values for each attribute used in the expression
(currently, we give up if we find a numeric attribute).
-
+
If the set of EQ_ATTR tests used in an expression tests the value of N
different attributes, the list of all possible combinations can be made
by walking the N-dimensional attribute space defined by those
Once the dimensions are created, the algorithm enumerates all possible
values and computes the current value of the given expression. */
-struct dimension
+struct dimension
{
struct attr_desc *attr; /* Attribute for this dimension. */
rtx values; /* List of attribute values used. */
#define SIMPLIFY_TEST_EXP(EXP,INSN_CODE,INSN_INDEX) \
(RTX_UNCHANGING_P (EXP) || MEM_IN_STRUCT_P (EXP) ? (EXP) \
: simplify_test_exp (EXP, INSN_CODE, INSN_INDEX))
-
+
/* Simplify (eq_attr ("alternative") ...)
when we are working with a particular alternative. */
#define SIMPLIFY_ALTERNATIVE(EXP) \
static char *attr_printf PARAMS ((int, const char *, ...))
ATTRIBUTE_PRINTF_2;
static char *attr_string PARAMS ((const char *, int));
-static rtx check_attr_test PARAMS ((rtx, int));
+static rtx check_attr_test PARAMS ((rtx, int, int));
static rtx check_attr_value PARAMS ((rtx, struct attr_desc *));
-static rtx convert_set_attr_alternative PARAMS ((rtx, int, int));
-static rtx convert_set_attr PARAMS ((rtx, int, int));
+static rtx convert_set_attr_alternative PARAMS ((rtx, struct insn_def *));
+static rtx convert_set_attr PARAMS ((rtx, struct insn_def *));
static void check_defs PARAMS ((void));
#if 0
static rtx convert_const_symbol_ref PARAMS ((rtx, struct attr_desc *));
static rtx simplify_or_tree PARAMS ((rtx, rtx *, int, int));
static rtx simplify_test_exp PARAMS ((rtx, int, int));
static void optimize_attrs PARAMS ((void));
-static void gen_attr PARAMS ((rtx));
+static void gen_attr PARAMS ((rtx, int));
static int count_alternatives PARAMS ((rtx));
static int compares_alternatives_p PARAMS ((rtx));
static int contained_in_p PARAMS ((rtx, rtx));
-static void gen_insn PARAMS ((rtx));
-static void gen_delay PARAMS ((rtx));
-static void gen_unit PARAMS ((rtx));
+static void gen_insn PARAMS ((rtx, int));
+static void gen_delay PARAMS ((rtx, int));
+static void gen_unit PARAMS ((rtx, int));
static void write_test_expr PARAMS ((rtx, int));
static int max_attr_value PARAMS ((rtx, int*));
static int or_attr_value PARAMS ((rtx, int*));
static const char *attr_numeral PARAMS ((int));
static int attr_equal_p PARAMS ((rtx, rtx));
static rtx attr_copy_rtx PARAMS ((rtx));
+static int attr_rtx_cost PARAMS ((rtx));
#define oballoc(size) obstack_alloc (hash_obstack, size)
-
\f
/* Hash table for sharing RTL and strings. */
rtx attr_rtx (code, [element1, ..., elementn]) */
-/*VARARGS1*/
static rtx
attr_rtx VPARAMS ((enum rtx_code code, ...))
{
{
nohash:
rt_val = rtx_alloc (code); /* Allocate the storage space. */
-
+
fmt = GET_RTX_FORMAT (code); /* Find the right format... */
for (i = 0; i < GET_RTX_LENGTH (code); i++)
{
break;
default:
- abort();
+ abort ();
}
}
va_end (p);
rtx attr_printf (len, format, [arg1, ..., argn]) */
-/*VARARGS2*/
static char *
attr_printf VPARAMS ((register int len, const char *fmt, ...))
{
register char *new_str;
/* Compute the hash code. */
- hashcode = (len + 1) * 613 + (unsigned)str[0];
+ hashcode = (len + 1) * 613 + (unsigned) str[0];
for (i = 1; i <= len; i += 2)
- hashcode = ((hashcode * 613) + (unsigned)str[i]);
+ hashcode = ((hashcode * 613) + (unsigned) str[i]);
if (hashcode < 0)
hashcode = -hashcode;
/* Not found; create a permanent copy and add it to the hash table. */
new_str = (char *) obstack_alloc (hash_obstack, len + 1);
- bcopy (str, new_str, len);
+ memcpy (new_str, str, len);
new_str[len] = '\0';
attr_hash_add_string (hashcode, new_str);
copy->volatil = orig->volatil;
copy->unchanging = orig->unchanging;
copy->integrated = orig->integrated;
-
+
format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
Return the new expression, if any. */
static rtx
-check_attr_test (exp, is_const)
+check_attr_test (exp, is_const, lineno)
rtx exp;
int is_const;
+ int lineno;
{
struct attr_desc *attr;
struct attr_value *av;
return check_attr_test (attr_rtx (NOT,
attr_eq (XSTR (exp, 0),
&XSTR (exp, 1)[1])),
- is_const);
+ is_const, lineno);
else if (n_comma_elts (XSTR (exp, 1)) == 1)
{
/* It shouldn't be possible to simplify the value given to a
constant attribute, so don't expand this until it's time to
- write the test expression. */
+ write the test expression. */
if (attr->is_const)
RTX_UNCHANGING_P (exp) = 1;
{
for (p = XSTR (exp, 1); *p; p++)
if (*p < '0' || *p > '9')
- fatal ("Attribute `%s' takes only numeric values",
- XSTR (exp, 0));
+ fatal ("Attribute `%s' takes only numeric values",
+ XSTR (exp, 0));
}
else
{
orexp = insert_right_side (IOR, orexp, newexp, -2, -2);
}
- return check_attr_test (orexp, is_const);
+ return check_attr_test (orexp, is_const, lineno);
}
break;
case IOR:
case AND:
- XEXP (exp, 0) = check_attr_test (XEXP (exp, 0), is_const);
- XEXP (exp, 1) = check_attr_test (XEXP (exp, 1), is_const);
+ XEXP (exp, 0) = check_attr_test (XEXP (exp, 0), is_const, lineno);
+ XEXP (exp, 1) = check_attr_test (XEXP (exp, 1), is_const, lineno);
break;
case NOT:
- XEXP (exp, 0) = check_attr_test (XEXP (exp, 0), is_const);
+ XEXP (exp, 0) = check_attr_test (XEXP (exp, 0), is_const, lineno);
break;
case MATCH_INSN:
/* These cases can't be simplified. */
RTX_UNCHANGING_P (exp) = 1;
break;
-
+
case LE: case LT: case GT: case GE:
case LEU: case LTU: case GTU: case GEU:
case NE: case EQ:
{
case CONST_INT:
if (attr && ! attr->is_numeric)
- fatal ("CONST_INT not valid for non-numeric `%s' attribute",
- attr->name);
+ {
+ message_with_line (attr->lineno,
+ "CONST_INT not valid for non-numeric attribute %s",
+ attr->name);
+ have_error = 1;
+ break;
+ }
if (INTVAL (exp) < 0 && ! attr->negative_ok)
- fatal ("Negative numeric value specified for `%s' attribute",
- attr->name);
-
+ {
+ message_with_line (attr->lineno,
+ "negative numeric value specified for attribute %s",
+ attr->name);
+ have_error = 1;
+ break;
+ }
break;
case CONST_STRING:
p++;
for (; *p; p++)
if (*p > '9' || *p < '0')
- fatal ("Non-numeric value for numeric `%s' attribute",
- attr ? attr->name : "internal");
+ {
+ message_with_line (attr ? attr->lineno : 0,
+ "non-numeric value for numeric attribute %s",
+ attr ? attr->name : "internal");
+ have_error = 1;
+ break;
+ }
break;
}
break;
if (av == NULL)
- fatal ("Unknown value `%s' for `%s' attribute",
- XSTR (exp, 0), attr ? attr->name : "internal");
-
+ {
+ message_with_line (attr->lineno,
+ "unknown value `%s' for `%s' attribute",
+ XSTR (exp, 0), attr ? attr->name : "internal");
+ have_error = 1;
+ }
break;
case IF_THEN_ELSE:
XEXP (exp, 0) = check_attr_test (XEXP (exp, 0),
- attr ? attr->is_const : 0);
+ attr ? attr->is_const : 0,
+ attr ? attr->lineno : 0);
XEXP (exp, 1) = check_attr_value (XEXP (exp, 1), attr);
XEXP (exp, 2) = check_attr_value (XEXP (exp, 2), attr);
break;
case DIV:
case MOD:
if (attr && !attr->is_numeric)
- fatal ("Invalid operation `%s' for non-numeric attribute value",
- GET_RTX_NAME (GET_CODE (exp)));
+ {
+ message_with_line (attr->lineno,
+ "invalid operation `%s' for non-numeric attribute value",
+ GET_RTX_NAME (GET_CODE (exp)));
+ have_error = 1;
+ break;
+ }
/* FALLTHRU */
case IOR:
case COND:
if (XVECLEN (exp, 0) % 2 != 0)
- fatal ("First operand of COND must have even length");
+ {
+ message_with_line (attr->lineno,
+ "first operand of COND must have even length");
+ have_error = 1;
+ break;
+ }
for (i = 0; i < XVECLEN (exp, 0); i += 2)
{
XVECEXP (exp, 0, i) = check_attr_test (XVECEXP (exp, 0, i),
- attr ? attr->is_const : 0);
+ attr ? attr->is_const : 0,
+ attr ? attr->lineno : 0);
XVECEXP (exp, 0, i + 1)
= check_attr_value (XVECEXP (exp, 0, i + 1), attr);
}
{
struct attr_desc *attr2 = find_attr (XSTR (exp, 0), 0);
if (attr2 == NULL)
- fatal ("Unknown attribute `%s' in ATTR", XSTR (exp, 0));
- else if ((attr && attr->is_const) && ! attr2->is_const)
- fatal ("Non-constant attribute `%s' referenced from `%s'",
- XSTR (exp, 0), attr->name);
- else if (attr
+ {
+ message_with_line (attr ? attr->lineno : 0,
+ "unknown attribute `%s' in ATTR",
+ XSTR (exp, 0));
+ have_error = 1;
+ }
+ else if (attr && attr->is_const && ! attr2->is_const)
+ {
+ message_with_line (attr->lineno,
+ "non-constant attribute `%s' referenced from `%s'",
+ XSTR (exp, 0), attr->name);
+ have_error = 1;
+ }
+ else if (attr
&& (attr->is_numeric != attr2->is_numeric
|| (! attr->negative_ok && attr2->negative_ok)))
- fatal ("Numeric attribute mismatch calling `%s' from `%s'",
- XSTR (exp, 0), attr->name);
+ {
+ message_with_line (attr->lineno,
+ "numeric attribute mismatch calling `%s' from `%s'",
+ XSTR (exp, 0), attr->name);
+ have_error = 1;
+ }
}
break;
return attr_rtx (SYMBOL_REF, XSTR (exp, 0));
default:
- fatal ("Invalid operation `%s' for attribute value",
- GET_RTX_NAME (GET_CODE (exp)));
+ message_with_line (attr ? attr->lineno : 0,
+ "invalid operation `%s' for attribute value",
+ GET_RTX_NAME (GET_CODE (exp)));
+ have_error = 1;
+ break;
}
return exp;
It becomes a COND with each test being (eq_attr "alternative "n") */
static rtx
-convert_set_attr_alternative (exp, num_alt, insn_index)
+convert_set_attr_alternative (exp, id)
rtx exp;
- int num_alt;
- int insn_index;
+ struct insn_def *id;
{
+ int num_alt = id->num_alternatives;
rtx condexp;
int i;
if (XVECLEN (exp, 1) != num_alt)
- fatal ("Bad number of entries in SET_ATTR_ALTERNATIVE for insn %d",
- insn_index);
+ {
+ message_with_line (id->lineno,
+ "bad number of entries in SET_ATTR_ALTERNATIVE");
+ have_error = 1;
+ return NULL_RTX;
+ }
/* Make a COND with all tests but the last. Select the last value via the
default. */
p = attr_numeral (i);
XVECEXP (condexp, 0, 2 * i) = attr_eq (alternative_name, p);
-#if 0
- /* Sharing this EQ_ATTR rtl causes trouble. */
- XVECEXP (condexp, 0, 2 * i) = rtx_alloc (EQ_ATTR);
- XSTR (XVECEXP (condexp, 0, 2 * i), 0) = alternative_name;
- XSTR (XVECEXP (condexp, 0, 2 * i), 1) = p;
-#endif
XVECEXP (condexp, 0, 2 * i + 1) = XVECEXP (exp, 1, i);
}
list of values is given, convert to SET_ATTR_ALTERNATIVE first. */
static rtx
-convert_set_attr (exp, num_alt, insn_index)
+convert_set_attr (exp, id)
rtx exp;
- int num_alt;
- int insn_index;
+ struct insn_def *id;
{
rtx newexp;
const char *name_ptr;
while ((p = next_comma_elt (&name_ptr)) != NULL)
XVECEXP (newexp, 1, n++) = attr_rtx (CONST_STRING, p);
- return convert_set_attr_alternative (newexp, num_alt, insn_index);
+ return convert_set_attr_alternative (newexp, id);
}
\f
/* Scan all definitions, checking for validity. Also, convert any SET_ATTR
{
case SET:
if (GET_CODE (XEXP (value, 0)) != ATTR)
- fatal ("Bad attribute set in pattern %d", id->insn_index);
+ {
+ message_with_line (id->lineno, "bad attribute set");
+ have_error = 1;
+ value = NULL_RTX;
+ }
break;
case SET_ATTR_ALTERNATIVE:
- value = convert_set_attr_alternative (value,
- id->num_alternatives,
- id->insn_index);
+ value = convert_set_attr_alternative (value, id);
break;
case SET_ATTR:
- value = convert_set_attr (value, id->num_alternatives,
- id->insn_index);
+ value = convert_set_attr (value, id);
break;
default:
- fatal ("Invalid attribute code `%s' for pattern %d",
- GET_RTX_NAME (GET_CODE (value)), id->insn_index);
+ message_with_line (id->lineno, "invalid attribute code %s",
+ GET_RTX_NAME (GET_CODE (value)));
+ have_error = 1;
+ value = NULL_RTX;
}
+ if (value == NULL_RTX)
+ continue;
if ((attr = find_attr (XSTR (XEXP (value, 0), 0), 0)) == NULL)
- fatal ("Unknown attribute `%s' for pattern number %d",
- XSTR (XEXP (value, 0), 0), id->insn_index);
+ {
+ message_with_line (id->lineno, "unknown attribute %s",
+ XSTR (XEXP (value, 0), 0));
+ have_error = 1;
+ continue;
+ }
XVECEXP (id->def, id->vec_idx, i) = value;
XEXP (value, 1) = check_attr_value (XEXP (value, 1), attr);
value = attr_rtx (SYMBOL_REF, string);
RTX_UNCHANGING_P (value) = 1;
-
+
XVECEXP (condexp, 0, 2 * i) = attr_rtx (EQ, exp, value);
XVECEXP (condexp, 0, 2 * i + 1) = av->value;
#if 0
/* ??? Why do we do this? With attribute values { A B C D E }, this
tends to generate (!(x==A) && !(x==B) && !(x==C) && !(x==D)) rather
- than (x==E). */
+ than (x==E). */
exp = convert_const_symbol_ref (exp, attr);
RTX_UNCHANGING_P (exp) = 1;
exp = check_attr_value (exp, attr);
/* For each delay possibility and delay slot, compute an eligibility
attribute for non-annulled insns and for each type of annulled (annul
if true and annul if false). */
- for (delay = delays; delay; delay = delay->next)
- {
- for (i = 0; i < XVECLEN (delay->def, 1); i += 3)
- {
- condexp = XVECEXP (delay->def, 1, i);
- if (condexp == 0) condexp = false_rtx;
- newexp = attr_rtx (IF_THEN_ELSE, condexp,
- make_numeric_value (1), make_numeric_value (0));
-
- p = attr_printf (sizeof ("*delay__") + MAX_DIGITS*2, "*delay_%d_%d",
- delay->num, i / 3);
- make_internal_attr (p, newexp, 1);
-
- if (have_annul_true)
- {
- condexp = XVECEXP (delay->def, 1, i + 1);
- if (condexp == 0) condexp = false_rtx;
- newexp = attr_rtx (IF_THEN_ELSE, condexp,
- make_numeric_value (1),
- make_numeric_value (0));
- p = attr_printf (sizeof ("*annul_true__") + MAX_DIGITS*2,
- "*annul_true_%d_%d", delay->num, i / 3);
- make_internal_attr (p, newexp, 1);
- }
-
- if (have_annul_false)
- {
- condexp = XVECEXP (delay->def, 1, i + 2);
- if (condexp == 0) condexp = false_rtx;
- newexp = attr_rtx (IF_THEN_ELSE, condexp,
- make_numeric_value (1),
- make_numeric_value (0));
- p = attr_printf (sizeof ("*annul_false__") + MAX_DIGITS*2,
- "*annul_false_%d_%d", delay->num, i / 3);
- make_internal_attr (p, newexp, 1);
- }
- }
- }
+ for (delay = delays; delay; delay = delay->next)
+ {
+ for (i = 0; i < XVECLEN (delay->def, 1); i += 3)
+ {
+ condexp = XVECEXP (delay->def, 1, i);
+ if (condexp == 0)
+ condexp = false_rtx;
+ newexp = attr_rtx (IF_THEN_ELSE, condexp,
+ make_numeric_value (1), make_numeric_value (0));
+
+ p = attr_printf (sizeof ("*delay__") + MAX_DIGITS * 2,
+ "*delay_%d_%d",
+ delay->num, i / 3);
+ make_internal_attr (p, newexp, 1);
+
+ if (have_annul_true)
+ {
+ condexp = XVECEXP (delay->def, 1, i + 1);
+ if (condexp == 0) condexp = false_rtx;
+ newexp = attr_rtx (IF_THEN_ELSE, condexp,
+ make_numeric_value (1),
+ make_numeric_value (0));
+ p = attr_printf (sizeof ("*annul_true__") + MAX_DIGITS * 2,
+ "*annul_true_%d_%d", delay->num, i / 3);
+ make_internal_attr (p, newexp, 1);
+ }
+
+ if (have_annul_false)
+ {
+ condexp = XVECEXP (delay->def, 1, i + 2);
+ if (condexp == 0) condexp = false_rtx;
+ newexp = attr_rtx (IF_THEN_ELSE, condexp,
+ make_numeric_value (1),
+ make_numeric_value (0));
+ p = attr_printf (sizeof ("*annul_false__") + MAX_DIGITS * 2,
+ "*annul_false_%d_%d", delay->num, i / 3);
+ make_internal_attr (p, newexp, 1);
+ }
+ }
+ }
}
\f
/* This function is given a left and right side expression and an operator.
XVECEXP (newexp, 0, i + 1)
= operate_exp (op, left, XVECEXP (right, 0, i + 1));
if (! rtx_equal_p (XVECEXP (newexp, 0, i + 1),
- defval))
+ defval))
allsame = 0;
}
/* If the resulting cond is trivial (all alternatives
give the same value), optimize it away. */
if (allsame)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, newexp);
- return operate_exp (op, left, XEXP (right, 1));
- }
-
- /* If the result is the same as the RIGHT operand,
- just use that. */
- if (rtx_equal_p (newexp, right))
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, newexp);
- return right;
- }
+ return operate_exp (op, left, XEXP (right, 1));
return newexp;
}
XVECEXP (newexp, 0, i + 1)
= operate_exp (op, XVECEXP (left, 0, i + 1), right);
if (! rtx_equal_p (XVECEXP (newexp, 0, i + 1),
- defval))
+ defval))
allsame = 0;
}
/* If the cond is trivial (all alternatives give the same value),
optimize it away. */
if (allsame)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, newexp);
- return operate_exp (op, XEXP (left, 1), right);
- }
+ return operate_exp (op, XEXP (left, 1), right);
/* If the result is the same as the LEFT operand,
just use that. */
if (rtx_equal_p (newexp, left))
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, newexp);
- return left;
- }
+ return left;
return newexp;
}
for (unit = units; unit; unit = unit->next)
{
- unit->condexp = check_attr_test (unit->condexp, 0);
+ unit->condexp = check_attr_test (unit->condexp, 0, unit->first_lineno);
for (op = unit->ops; op; op = op->next)
{
}
/* Validate the condition. */
- op->condexp = check_attr_test (op->condexp, 0);
+ op->condexp = check_attr_test (op->condexp, 0, op->lineno);
}
}
{
/* Merge each function unit into the unit mask attributes. */
for (unit = units; unit; unit = unit->next)
- {
- XEXP (newexp, 0) = unit->condexp;
- XEXP (newexp, 1) = make_numeric_value (1 << unit->num);
- unitsmask = operate_exp (OR_OP, unitsmask, newexp);
- }
+ {
+ XEXP (newexp, 0) = unit->condexp;
+ XEXP (newexp, 1) = make_numeric_value (1 << unit->num);
+ unitsmask = operate_exp (OR_OP, unitsmask, newexp);
+ }
}
else
{
/* Merge each function unit into the unit mask attributes. */
for (unit = units; unit; unit = unit->next)
- {
- XEXP (newexp, 0) = unit->condexp;
- XEXP (newexp, 1) = make_numeric_value (1 << unit->num);
- unitsmask = operate_exp (ORX_OP, unitsmask, attr_copy_rtx (newexp));
- }
+ {
+ XEXP (newexp, 0) = unit->condexp;
+ XEXP (newexp, 1) = make_numeric_value (1 << unit->num);
+ unitsmask = operate_exp (ORX_OP, unitsmask, attr_copy_rtx (newexp));
+ }
}
/* Simplify the unit mask expression, encode it, and make an attribute
/* Sort the array of ops into increasing ready cost order. */
for (i = 0; i < num; i++)
for (j = num - 1; j > i; j--)
- if (op_array[j-1]->ready < op_array[j]->ready)
+ if (op_array[j - 1]->ready < op_array[j]->ready)
{
op = op_array[j];
- op_array[j] = op_array[j-1];
- op_array[j-1] = op;
+ op_array[j] = op_array[j - 1];
+ op_array[j - 1] = op;
}
/* Determine how many distinct non-default ready cost values there
XVEC (readycost, 0) = rtvec_alloc (nvalues * 2);
XEXP (readycost, 1) = make_numeric_value (1);
- nvalues = 0; orexp = false_rtx; value = op_array[0]->ready;
+ nvalues = 0;
+ orexp = false_rtx;
+ value = op_array[0]->ready;
for (i = 0; i < num; i++)
{
op = op_array[i];
|| atoi (XSTR (newexp, 0)) != 1);
/* If the all values of BLOCKAGE (E,C) have the same value,
- neither blockage function is written. */
+ neither blockage function is written. */
unit->needs_range_function
= (unit->needs_blockage_function
|| GET_CODE (max_blockage) != CONST_STRING);
if (! unknown)
{
exp = attr_rtx (IF_THEN_ELSE, known_true, exp,
- make_numeric_value (max));
- exp = simplify_by_exploding (exp);
+ make_numeric_value (max));
+ exp = simplify_by_exploding (exp);
}
}
return exp;
case CONST_STRING:
i = atoi (XSTR (x, 0));
if (i < 0)
- abort (); /* The sign bit encodes a one's compliment mask. */
+ /* The sign bit encodes a one's compliment mask. */
+ abort ();
else if (i != 0 && i == (i & -i))
/* Only one bit is set, so yield that unit number. */
for (j = 0; (i >>= 1) != 0; j++)
case CC0:
case EQ_ATTR:
return x;
-
+
default:
break;
}
value = NULL;
if (XVEC (id->def, id->vec_idx))
for (i = 0; i < XVECLEN (id->def, id->vec_idx); i++)
- if (! strcmp (XSTR (XEXP (XVECEXP (id->def, id->vec_idx, i), 0), 0),
+ if (! strcmp (XSTR (XEXP (XVECEXP (id->def, id->vec_idx, i), 0), 0),
attr->name))
value = XEXP (XVECEXP (id->def, id->vec_idx, i), 1);
length_attr->is_special = 1;
/* Make each new attribute, in turn. */
- for (i = 0; i < sizeof new_names / sizeof new_names[0]; i++)
+ for (i = 0; i < ARRAY_SIZE (new_names); i++)
{
make_internal_attr (new_names[i],
substitute_address (length_attr->default_val->value,
{
length_or = ~length_or;
for (length_unit_log = 0; length_or & 1; length_or >>= 1)
- length_unit_log++;
+ length_unit_log++;
}
printf ("int length_unit_log = %u;\n", length_unit_log);
}
/* This lets us free all storage allocated below, if appropriate. */
first_spacer = (char *) obstack_finish (rtl_obstack);
- bcopy ((char *) XVEC (exp, 0)->elem, (char *) tests, len * sizeof (rtx));
+ memcpy (tests, XVEC (exp, 0)->elem, len * sizeof (rtx));
/* See if default value needs simplification. */
if (GET_CODE (defval) == COND)
if (len == 0)
{
- if (!ggc_p)
- obstack_free (rtl_obstack, first_spacer);
if (GET_CODE (defval) == COND)
return simplify_cond (defval, insn_code, insn_index);
return defval;
}
else if (allsame)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, first_spacer);
- return exp;
- }
+ return exp;
else
{
rtx newexp = rtx_alloc (COND);
XVEC (newexp, 0) = rtvec_alloc (len);
- bcopy ((char *) tests, (char *) XVEC (newexp, 0)->elem,
- len * sizeof (rtx));
+ memcpy (XVEC (newexp, 0)->elem, tests, len * sizeof (rtx));
XEXP (newexp, 1) = new_defval;
return newexp;
}
of "attr" for this insn code. From that value, we can compute a test
showing when the EQ_ATTR will be true. This routine performs that
computation. If a test condition involves an address, we leave the EQ_ATTR
- intact because addresses are only valid for the `length' attribute.
+ intact because addresses are only valid for the `length' attribute.
EXP is the EQ_ATTR expression and VALUE is the value of that attribute
for the insn corresponding to INSN_CODE and INSN_INDEX. */
char *p, *string;
if (GET_CODE (exp) != EQ_ATTR)
- abort();
+ abort ();
string = (char *) alloca (2 + strlen (XSTR (exp, 0))
+ strlen (XSTR (exp, 1)));
strcpy (string, XSTR (exp, 0));
strcat (string, "_");
strcat (string, XSTR (exp, 1));
- for (p = string; *p ; p++)
+ for (p = string; *p; p++)
*p = TOUPPER (*p);
-
+
newexp = attr_rtx (EQ, value,
attr_rtx (SYMBOL_REF,
- attr_string(string, strlen(string))));
+ attr_string (string, strlen (string))));
}
else if (GET_CODE (value) == COND)
{
FALSE will be returned.
Each case is the AND of the NOT's of the previous conditions with the
- current condition; in the default case the current condition is TRUE.
+ current condition; in the default case the current condition is TRUE.
For each possible COND value, call ourselves recursively.
can be replaced with TRUE or FALSE, respectively.
Note that (eq_attr "att" "v1") and (eq_attr "att" "v2") cannot both
- be true and hence are complementary.
+ be true and hence are complementary.
There is one special case: If we see
(and (not (eq_attr "att" "v1"))
if (GET_CODE (exp) == AND)
{
- left = simplify_and_tree (XEXP (exp, 0), pterm, insn_code, insn_index);
+ left = simplify_and_tree (XEXP (exp, 0), pterm, insn_code, insn_index);
right = simplify_and_tree (XEXP (exp, 1), pterm, insn_code, insn_index);
if (left != XEXP (exp, 0) || right != XEXP (exp, 1))
{
/* For the IOR case, we do the same as above, except that we can
only eliminate `term' if both sides of the IOR would do so. */
temp = *pterm;
- left = simplify_and_tree (XEXP (exp, 0), &temp, insn_code, insn_index);
+ left = simplify_and_tree (XEXP (exp, 0), &temp, insn_code, insn_index);
left_eliminates_term = (temp == true_rtx);
temp = *pterm;
if (GET_CODE (exp) == IOR)
{
- left = simplify_or_tree (XEXP (exp, 0), pterm, insn_code, insn_index);
+ left = simplify_or_tree (XEXP (exp, 0), pterm, insn_code, insn_index);
right = simplify_or_tree (XEXP (exp, 1), pterm, insn_code, insn_index);
if (left != XEXP (exp, 0) || right != XEXP (exp, 1))
{
/* For the AND case, we do the same as above, except that we can
only eliminate `term' if both sides of the AND would do so. */
temp = *pterm;
- left = simplify_or_tree (XEXP (exp, 0), &temp, insn_code, insn_index);
+ left = simplify_or_tree (XEXP (exp, 0), &temp, insn_code, insn_index);
left_eliminates_term = (temp == false_rtx);
temp = *pterm;
return exp;
}
+/* Compute approximate cost of the expression. Used to decide whether
+ expression is cheap enought for inline. */
+static int
+attr_rtx_cost (x)
+ rtx x;
+{
+ int cost = 0;
+ enum rtx_code code;
+ if (!x)
+ return 0;
+ code = GET_CODE (x);
+ switch (code)
+ {
+ case MATCH_OPERAND:
+ if (XSTR (x, 1)[0])
+ return 10;
+ else
+ return 0;
+ case EQ_ATTR:
+ /* Alternatives don't result into function call. */
+ if (!strcmp (XSTR (x, 0), "alternative"))
+ return 0;
+ else
+ return 5;
+ default:
+ {
+ int i, j;
+ const char *fmt = GET_RTX_FORMAT (code);
+ for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+ {
+ switch (fmt[i])
+ {
+ case 'V':
+ case 'E':
+ for (j = 0; j < XVECLEN (x, i); j++)
+ cost += attr_rtx_cost (XVECEXP (x, i, j));
+ break;
+ case 'e':
+ cost += attr_rtx_cost (XEXP (x, i));
+ break;
+ }
+ }
+ }
+ break;
+ }
+ return cost;
+}
\f
/* Given an expression, see if it can be simplified for a particular insn
code based on the values of other attributes being tested. This can
eliminate nested get_attr_... calls.
- Note that if an endless recursion is specified in the patterns, the
+ Note that if an endless recursion is specified in the patterns, the
optimization will loop. However, it will do so in precisely the cases where
an infinite recursion loop could occur during compilation. It's better that
it occurs here! */
struct insn_ent *ie;
int i;
rtx newexp = exp;
- char *spacer = (char *) obstack_finish (rtl_obstack);
/* Don't re-simplify something we already simplified. */
if (RTX_UNCHANGING_P (exp) || MEM_IN_STRUCT_P (exp))
left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
SIMPLIFY_ALTERNATIVE (left);
if (left == false_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return false_rtx;
- }
+ return false_rtx;
right = SIMPLIFY_TEST_EXP (XEXP (exp, 1), insn_code, insn_index);
SIMPLIFY_ALTERNATIVE (right);
if (left == false_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return false_rtx;
- }
+ return false_rtx;
/* If either side is an IOR and we have (eq_attr "alternative" ..")
present on both sides, apply the distributive law since this will
left = simplify_and_tree (left, &right, insn_code, insn_index);
if (left == false_rtx || right == false_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return false_rtx;
- }
+ return false_rtx;
else if (left == true_rtx)
{
return right;
left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
SIMPLIFY_ALTERNATIVE (left);
if (left == true_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return true_rtx;
- }
+ return true_rtx;
right = SIMPLIFY_TEST_EXP (XEXP (exp, 1), insn_code, insn_index);
SIMPLIFY_ALTERNATIVE (right);
if (right == true_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return true_rtx;
- }
+ return true_rtx;
right = simplify_or_tree (right, &left, insn_code, insn_index);
if (left == XEXP (exp, 0) && right == XEXP (exp, 1))
left = simplify_or_tree (left, &right, insn_code, insn_index);
if (right == true_rtx || left == true_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return true_rtx;
- }
+ return true_rtx;
else if (left == false_rtx)
{
return right;
*/
else if (GET_CODE (left) == AND && GET_CODE (right) == AND
- && attr_equal_p (XEXP (left, 0), XEXP (right, 0)))
+ && attr_equal_p (XEXP (left, 0), XEXP (right, 0)))
{
newexp = attr_rtx (IOR, XEXP (left, 1), XEXP (right, 1));
in this tree. Optimize if so. */
else if (insn_code >= 0
- && (GET_CODE (left) == IOR
- || (GET_CODE (left) == EQ_ATTR
- && XSTR (left, 0) == alternative_name)
- || GET_CODE (right) == IOR
- || (GET_CODE (right) == EQ_ATTR
- && XSTR (right, 0) == alternative_name)))
+ && (GET_CODE (left) == IOR
+ || (GET_CODE (left) == EQ_ATTR
+ && XSTR (left, 0) == alternative_name)
+ || GET_CODE (right) == IOR
+ || (GET_CODE (right) == EQ_ATTR
+ && XSTR (right, 0) == alternative_name)))
{
i = compute_alternative_mask (exp, IOR);
if (i & ~insn_alternatives[insn_code])
return XEXP (left, 0);
if (left == false_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return true_rtx;
- }
+ return true_rtx;
else if (left == true_rtx)
- {
- if (!ggc_p)
- obstack_free (rtl_obstack, spacer);
- return false_rtx;
- }
+ return false_rtx;
/* Try to apply De`Morgan's laws. */
else if (GET_CODE (left) == IOR)
if (current_alternative_string && XSTR (exp, 0) == alternative_name)
return (XSTR (exp, 1) == current_alternative_string
? true_rtx : false_rtx);
-
+
/* Look at the value for this insn code in the specified attribute.
We normally can replace this comparison with the condition that
would give this insn the values being tested for. */
for (av = attr->first_value; av; av = av->next)
for (ie = av->first_insn; ie; ie = ie->next)
if (ie->insn_code == insn_code)
- return evaluate_eq_attr (exp, av->value, insn_code, insn_index);
+ {
+ rtx x;
+ struct obstack *old = rtl_obstack;
+ rtl_obstack = temp_obstack;
+ x = evaluate_eq_attr (exp, av->value, insn_code, insn_index);
+ x = SIMPLIFY_TEST_EXP (x, insn_code, insn_index);
+ rtl_obstack = old;
+ if (attr_rtx_cost(x) < 20)
+ return attr_copy_rtx (x);
+ }
break;
-
+
default:
break;
}
rtx newexp;
int something_changed = 1;
int i;
- struct attr_value_list { struct attr_value *av;
- struct insn_ent *ie;
- struct attr_desc * attr;
- struct attr_value_list *next; };
+ struct attr_value_list
+ {
+ struct attr_value *av;
+ struct insn_ent *ie;
+ struct attr_desc *attr;
+ struct attr_value_list *next;
+ };
struct attr_value_list **insn_code_values;
struct attr_value_list *ivbuf;
struct attr_value_list *iv;
insn_code_values
= (struct attr_value_list **) alloca ((insn_code_number + 2)
* sizeof (struct attr_value_list *));
- bzero ((char *) insn_code_values,
+ memset ((char *) insn_code_values, 0,
(insn_code_number + 2) * sizeof (struct attr_value_list *));
/* Offset the table address so we can index by -2 or -1. */
for (iv = insn_code_values[i]; iv; iv = iv->next)
{
struct obstack *old = rtl_obstack;
- char *spacer = (char *) obstack_finish (temp_obstack);
attr = iv->attr;
av = iv->av;
insert_insn_ent (av, ie);
something_changed = 1;
}
- if (!ggc_p)
- obstack_free (temp_obstack, spacer);
}
}
}
rtx newexp = rtx_alloc (COND);
rtx ultimate;
-
XVEC (newexp, 0) = rtvec_alloc (len * 2);
/* It will not matter what value we use as the default value
{
struct dimension tmp;
tmp = space[j];
- space[j] = space[j-1];
- space[j-1] = tmp;
+ space[j] = space[j - 1];
+ space[j - 1] = tmp;
}
/* Establish the initial current value. */
if (nalt < dim->num_values)
abort ();
else if (nalt == dim->num_values)
- ; /* Ok. */
+ /* OK. */
+ ;
else if (nalt * 2 < dim->num_values * 3)
{
/* Most all the values of the attribute are used, so add all the unused
case EQ_ATTR:
case ATTR_FLAG:
return;
-
+
default:
break;
}
case EQ_ATTR:
case ATTR_FLAG:
return 1;
-
+
default:
break;
}
/* Create table entries for DEFINE_ATTR. */
static void
-gen_attr (exp)
+gen_attr (exp, lineno)
rtx exp;
+ int lineno;
{
struct attr_desc *attr;
struct attr_value *av;
attr->default_val, since it is initialized by this routine. */
attr = find_attr (XSTR (exp, 0), 1);
if (attr->default_val)
- fatal ("Duplicate definition for `%s' attribute", attr->name);
+ {
+ message_with_line (lineno, "duplicate definition for attribute %s",
+ attr->name);
+ message_with_line (attr->lineno, "previous definition");
+ have_error = 1;
+ return;
+ }
+ attr->lineno = lineno;
if (*XSTR (exp, 1) == '\0')
attr->is_numeric = 1;
{
attr->is_const = 1;
if (attr->is_numeric)
- fatal ("Constant attributes may not take numeric values");
+ {
+ message_with_line (lineno,
+ "constant attributes may not take numeric values");
+ have_error = 1;
+ }
+
/* Get rid of the CONST node. It is allowed only at top-level. */
XEXP (exp, 2) = XEXP (XEXP (exp, 2), 0);
}
if (! strcmp (attr->name, "length") && ! attr->is_numeric)
- fatal ("`length' attribute must take numeric values");
+ {
+ message_with_line (lineno,
+ "`length' attribute must take numeric values");
+ have_error = 1;
+ }
/* Set up the default value. */
XEXP (exp, 2) = check_attr_value (XEXP (exp, 2), attr);
{
int i, j, n;
const char *fmt;
-
+
if (GET_CODE (exp) == MATCH_OPERAND)
return n_comma_elts (XSTR (exp, 2));
return 0;
}
-\f
+\f
/* Process DEFINE_PEEPHOLE, DEFINE_INSN, and DEFINE_ASM_ATTRIBUTES. */
static void
-gen_insn (exp)
+gen_insn (exp, lineno)
rtx exp;
+ int lineno;
{
struct insn_def *id;
id->next = defs;
defs = id;
id->def = exp;
+ id->lineno = lineno;
switch (GET_CODE (exp))
{
id->vec_idx = 0;
got_define_asm_attributes = 1;
break;
-
+
default:
abort ();
}
true or annul false is specified, and make a `struct delay_desc'. */
static void
-gen_delay (def)
+gen_delay (def, lineno)
rtx def;
+ int lineno;
{
struct delay_desc *delay;
int i;
if (XVECLEN (def, 1) % 3 != 0)
- fatal ("Number of elements in DEFINE_DELAY must be multiple of three.");
+ {
+ message_with_line (lineno,
+ "number of elements in DEFINE_DELAY must be multiple of three");
+ have_error = 1;
+ return;
+ }
for (i = 0; i < XVECLEN (def, 1); i += 3)
{
if (XVECEXP (def, 1, i + 2))
have_annul_false = 1;
}
-
+
delay = (struct delay_desc *) oballoc (sizeof (struct delay_desc));
delay->def = def;
delay->num = ++num_delays;
delay->next = delays;
+ delay->lineno = lineno;
delays = delay;
}
\f
-/* Process a DEFINE_FUNCTION_UNIT.
+/* Process a DEFINE_FUNCTION_UNIT.
This gives information about a function unit contained in the CPU.
We fill in a `struct function_unit_op' and a `struct function_unit'
with information used later by `expand_unit'. */
static void
-gen_unit (def)
+gen_unit (def, lineno)
rtx def;
+ int lineno;
{
struct function_unit *unit;
struct function_unit_op *op;
{
if (unit->multiplicity != multiplicity
|| unit->simultaneity != simultaneity)
- fatal ("Differing specifications given for `%s' function unit.",
- unit->name);
+ {
+ message_with_line (lineno,
+ "differing specifications given for function unit %s",
+ unit->name);
+ message_with_line (unit->first_lineno, "previous definition");
+ have_error = 1;
+ return;
+ }
break;
}
unit->condexp = false_rtx;
unit->ops = 0;
unit->next = units;
+ unit->first_lineno = lineno;
units = unit;
}
op->ready = ready_cost;
op->issue_delay = issue_delay;
op->next = unit->ops;
+ op->lineno = lineno;
unit->ops = op;
num_unit_opclasses++;
}
\f
/* Given a piece of RTX, print a C expression to test its truth value.
- We use AND and IOR both for logical and bit-wise operations, so
+ We use AND and IOR both for logical and bit-wise operations, so
interpret them as logical unless they are inside a comparison expression.
The first bit of FLAGS will be non-zero in that case.
case ASHIFT: case LSHIFTRT: case ASHIFTRT:
write_test_expr (XEXP (exp, 0), flags | comparison_operator);
switch (code)
- {
+ {
case EQ:
printf (" == ");
break;
break;
default:
abort ();
- }
+ }
write_test_expr (XEXP (exp, 1), flags | comparison_operator);
break;
/* Otherwise, fall through to normal unary operator. */
- /* Unary operators. */
+ /* Unary operators. */
case ABS: case NEG:
switch (code)
{
}
attr = find_attr (XSTR (exp, 0), 0);
- if (! attr) abort ();
+ if (! attr)
+ abort ();
/* Now is the time to expand the value of a constant attribute. */
if (attr->is_const)
case MATCH_OPERAND:
/* If only a mode is given, just ensure the mode matches the operand.
If neither a mode nor predicate is given, error. */
- if (XSTR (exp, 1) == NULL || *XSTR (exp, 1) == '\0')
+ if (XSTR (exp, 1) == NULL || *XSTR (exp, 1) == '\0')
{
if (GET_MODE (exp) == VOIDmode)
fatal ("Null MATCH_OPERAND specified as test");
/* The address of the branch target. */
case MATCH_DUP:
- printf ("insn_addresses[INSN_UID (GET_CODE (operands[%d]) == LABEL_REF ? XEXP (operands[%d], 0) : operands[%d])]",
+ printf ("INSN_ADDRESSES_SET_P () ? INSN_ADDRESSES (INSN_UID (GET_CODE (operands[%d]) == LABEL_REF ? XEXP (operands[%d], 0) : operands[%d])) : 0",
XINT (exp, 0), XINT (exp, 0), XINT (exp, 0));
break;
address of the next insn for forward branches, and both with
adjustments that account for the worst-case possible stretching of
intervening alignments between this insn and its destination. */
- printf("insn_current_reference_address (insn)");
+ printf ("insn_current_reference_address (insn)");
break;
case CONST_STRING:
switch we will generate. */
common_av = find_most_used (attr);
- /* Write out prototype of function. */
+ /* Write out prototype of function. */
if (!attr->is_numeric)
printf ("extern enum attr_%s ", attr->name);
else if (attr->unsigned_p)
{
rtx p = XEXP (common_av->value, 0);
- /* No need to emit code to abort if the insn is unrecognized; the
+ /* No need to emit code to abort if the insn is unrecognized; the
other get_attr_foo functions will do that when we call them. */
write_toplevel_expr (p);
XVECEXP (value, 0, i),
insn_code, insn_index);
newexp = attr_rtx (NOT, testexp);
- newexp = insert_right_side (AND, our_known_true, newexp,
- insn_code, insn_index);
+ newexp = insert_right_side (AND, our_known_true, newexp,
+ insn_code, insn_index);
/* If the test expression is always true or if the next `known_true'
expression is always false, this is the last case, so break
write_indent (indent + 2);
printf ("{\n");
- write_attr_set (attr, indent + 4,
+ write_attr_set (attr, indent + 4,
XVECEXP (value, 0, i + 1), prefix, suffix,
inner_true, insn_code, insn_index);
write_indent (indent + 2);
must_extract = must_constrain = address_used = 0;
walk_attr_value (av->value);
- if (must_extract)
+ if (must_constrain)
{
write_indent (indent + 2);
- printf ("extract_insn (insn);\n");
+ printf ("extract_constrain_insn_cached (insn);\n");
}
-
- if (must_constrain)
+ else if (must_extract)
{
write_indent (indent + 2);
- printf ("if (! constrain_operands (reload_completed))\n");
- write_indent (indent + 2);
- printf (" fatal_insn_not_found (insn);\n");
+ printf ("extract_insn_cached (insn);\n");
}
write_attr_set (attr, indent + 2, av->value, prefix, suffix,
int i;
for (i = 0; i < MAX_ATTRS_INDEX; ++i)
- for (attr = attrs[i]; attr ; attr = attr->next)
+ for (attr = attrs[i]; attr; attr = attr->next)
if (!attr->is_const)
write_expr_attr_cache (p, attr);
- printf(" register unsigned long accum = 0;\n\n");
+ printf (" register unsigned long accum = 0;\n\n");
while (GET_CODE (p) == IOR)
{
case ATTR:
{
struct attr_desc *attr2 = find_attr (XSTR (value, 0), 0);
- printf ("get_attr_%s (%s)", attr2->name,
+ printf ("get_attr_%s (%s)", attr2->name,
(attr2->is_const ? "" : "insn"));
}
break;
const char *str;
{
while (*str)
- {
- /* The argument of TOUPPER should not have side effects. */
- putchar (TOUPPER(*str));
- str++;
- }
+ {
+ /* The argument of TOUPPER should not have side effects. */
+ putchar (TOUPPER(*str));
+ str++;
+ }
}
static void
static void
write_eligible_delay (kind)
- const char *kind;
+ const char *kind;
{
struct delay_desc *delay;
int max_slots;
/* Write function prelude. */
printf ("int\n");
- printf ("eligible_for_%s (delay_insn, slot, candidate_insn, flags)\n",
- kind);
+ printf ("eligible_for_%s (delay_insn, slot, candidate_insn, flags)\n",
+ kind);
printf (" rtx delay_insn;\n");
printf (" int slot;\n");
printf (" rtx candidate_insn;\n");
if (num_delays > 1)
{
attr = find_attr ("*delay_type", 0);
- if (! attr) abort ();
+ if (! attr)
+ abort ();
common_av = find_most_used (attr);
printf (" insn = delay_insn;\n");
printf (" {\n");
attr = find_attr ("*delay_1_0", 0);
- if (! attr) abort ();
+ if (! attr)
+ abort ();
common_av = find_most_used (attr);
for (av = attr->first_value; av; av = av->next)
sprintf (str, "*%s_%d_%d", kind, delay->num, i / 3);
attr = find_attr (str, 0);
- if (! attr) abort ();
+ if (! attr)
+ abort ();
common_av = find_most_used (attr);
for (av = attr->first_value; av; av = av->next)
}
printf (" default:\n");
- printf (" abort ();\n");
+ printf (" abort ();\n");
printf (" }\n");
}
printf ("static int %s_unit_%s PARAMS ((rtx, rtx));\n", unit->name, name);
printf ("static int\n");
- printf ("%s_unit_%s (executing_insn, candidate_insn)\n",
- unit->name, name);
+ printf ("%s_unit_%s (executing_insn, candidate_insn)\n", unit->name, name);
printf (" rtx executing_insn;\n");
printf (" rtx candidate_insn;\n");
printf ("{\n");
str = (char *) alloca (strlen (unit->name) + strlen (name) + strlen (connection) + 10);
sprintf (str, "*%s_cases", unit->name);
case_attr = find_attr (str, 0);
- if (! case_attr) abort ();
+ if (! case_attr)
+ abort ();
common_av = find_most_used (case_attr);
for (av = case_attr->first_value; av; av = av->next)
printf (" case %d:\n", i);
sprintf (str, "*%s_%s_%d", unit->name, connection, i);
attr = find_attr (str, 0);
- if (! attr) abort ();
+ if (! attr)
+ abort ();
/* If single value, just write it. */
value = find_single_value (attr);
int min;
int max;
{
- if (range->min > min) range->min = min;
- if (range->max < max) range->max = max;
+ if (range->min > min)
+ range->min = min;
+ if (range->max < max)
+ range->max = max;
}
static rtx
case SYMBOL_REF:
case CODE_LABEL:
return orig;
-
+
default:
break;
}
copy = rtx_alloc (code);
PUT_MODE (copy, GET_MODE (orig));
RTX_UNCHANGING_P (copy) = 1;
-
- bcopy ((char *) &XEXP (orig, 0), (char *) &XEXP (copy, 0),
- GET_RTX_LENGTH (GET_CODE (copy)) * sizeof (rtx));
+
+ memcpy (&XEXP (copy, 0), &XEXP (orig, 0),
+ GET_RTX_LENGTH (GET_CODE (copy)) * sizeof (rtx));
return copy;
#endif
}
if (length_used)
{
for (ie = av->first_insn; ie; ie = ie->next)
- if (ie->insn_code != -1)
- printf (" case %d:\n", ie->insn_code);
+ if (ie->insn_code != -1)
+ printf (" case %d:\n", ie->insn_code);
printf (" return 0;\n");
}
}
printf (" }\n}\n\n");
}
}
-
\f
extern int main PARAMS ((int, char **));
while (1)
{
- int line_no;
+ int lineno;
- desc = read_md_rtx (&line_no, &insn_code_number);
+ desc = read_md_rtx (&lineno, &insn_code_number);
if (desc == NULL)
break;
switch (GET_CODE (desc))
{
- case DEFINE_INSN:
- case DEFINE_PEEPHOLE:
- case DEFINE_ASM_ATTRIBUTES:
- gen_insn(desc);
- break;
-
- case DEFINE_ATTR:
- gen_attr (desc);
- break;
+ case DEFINE_INSN:
+ case DEFINE_PEEPHOLE:
+ case DEFINE_ASM_ATTRIBUTES:
+ gen_insn (desc, lineno);
+ break;
- case DEFINE_DELAY:
- gen_delay (desc);
- break;
+ case DEFINE_ATTR:
+ gen_attr (desc, lineno);
+ break;
- case DEFINE_FUNCTION_UNIT:
- gen_unit (desc);
- break;
-
- default:
- break;
+ case DEFINE_DELAY:
+ gen_delay (desc, lineno);
+ break;
+
+ case DEFINE_FUNCTION_UNIT:
+ gen_unit (desc, lineno);
+ break;
+
+ default:
+ break;
}
if (GET_CODE (desc) != DEFINE_ASM_ATTRIBUTES)
- insn_index_number++;
+ insn_index_number++;
}
+ if (have_error)
+ return FATAL_EXIT_CODE;
+
insn_code_number++;
/* If we didn't have a DEFINE_ASM_ATTRIBUTES, make a null one. */
{
tem = rtx_alloc (DEFINE_ASM_ATTRIBUTES);
XVEC (tem, 0) = rtvec_alloc (0);
- gen_insn (tem);
+ gen_insn (tem, 0);
}
/* Expand DEFINE_DELAY information into new attribute. */
printf ("#include \"output.h\"\n");
printf ("#include \"insn-attr.h\"\n");
printf ("#include \"toplev.h\"\n");
- printf ("\n");
+ printf ("\n");
printf ("#define operands recog_data.operand\n\n");
/* Make `insn_alternatives'. */
away and building the attribute cases. */
check_defs ();
+
for (i = 0; i < MAX_ATTRS_INDEX; i++)
for (attr = attrs[i]; attr; attr = attr->next)
- {
- attr->default_val->value
- = check_attr_value (attr->default_val->value, attr);
- fill_attr (attr);
- }
+ attr->default_val->value
+ = check_attr_value (attr->default_val->value, attr);
+
+ if (have_error)
+ return FATAL_EXIT_CODE;
+
+ for (i = 0; i < MAX_ATTRS_INDEX; i++)
+ for (attr = attrs[i]; attr; attr = attr->next)
+ fill_attr (attr);
/* Construct extra attributes for `length'. */
make_length_attrs ();