/* Generate code from machine description to compute values of attributes.
Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
This file is part of GCC.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA. */
/* This program handles insn attributes and the DEFINE_DELAY and
DEFINE_INSN_RESERVATION definitions.
`in_struct' (ATTR_CURR_SIMPLIFIED_P): This rtx is fully simplified
for the insn code currently being processed (see optimize_attrs).
`return_val' (ATTR_PERMANENT_P): This rtx is permanent and unique
- (see attr_rtx).
- `volatil' (ATTR_EQ_ATTR_P): During simplify_by_exploding the value of an
- EQ_ATTR rtx is true if !volatil and false if volatil. */
+ (see attr_rtx). */
#define ATTR_IND_SIMPLIFIED_P(RTX) (RTX_FLAG((RTX), unchanging))
#define ATTR_CURR_SIMPLIFIED_P(RTX) (RTX_FLAG((RTX), in_struct))
#define ATTR_PERMANENT_P(RTX) (RTX_FLAG((RTX), return_val))
-#define ATTR_EQ_ATTR_P(RTX) (RTX_FLAG((RTX), volatil))
#if 0
#define strcmp_check(S1, S2) ((S1) == (S2) \
struct attr_value *default_val; /* Default value for this attribute. */
int lineno : 24; /* Line number. */
unsigned is_numeric : 1; /* Values of this attribute are numeric. */
- unsigned negative_ok : 1; /* Allow negative numeric values. */
- unsigned unsigned_p : 1; /* Make the output function unsigned int. */
unsigned is_const : 1; /* Attribute value constant for each run. */
unsigned is_special : 1; /* Don't call `write_attr_set'. */
unsigned static_p : 1; /* Make the output function static. */
};
-#define NULL_ATTR (struct attr_desc *) NULL
-
/* Structure for each DEFINE_DELAY. */
struct delay_desc
static void write_attr_set (struct attr_desc *, int, rtx,
const char *, const char *, rtx,
int, int);
+static void write_insn_cases (struct insn_ent *, int);
static void write_attr_case (struct attr_desc *, struct attr_value *,
int, const char *, const char *, int, rtx);
static void write_attr_valueq (struct attr_desc *, const char *);
ATTR_IND_SIMPLIFIED_P (copy) = ATTR_IND_SIMPLIFIED_P (orig);
ATTR_CURR_SIMPLIFIED_P (copy) = ATTR_CURR_SIMPLIFIED_P (orig);
ATTR_PERMANENT_P (copy) = ATTR_PERMANENT_P (orig);
- ATTR_EQ_ATTR_P (copy) = ATTR_EQ_ATTR_P (orig);
format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
break;
}
- if (INTVAL (exp) < 0 && ! attr->negative_ok)
+ if (INTVAL (exp) < 0)
{
message_with_line (attr->lineno,
"negative numeric value specified for attribute %s",
if (attr == 0 || attr->is_numeric)
{
p = XSTR (exp, 0);
- if (attr && attr->negative_ok && *p == '-')
- p++;
for (; *p; p++)
if (! ISDIGIT (*p))
{
have_error = 1;
}
else if (attr
- && (attr->is_numeric != attr2->is_numeric
- || (! attr->negative_ok && attr2->negative_ok)))
+ && attr->is_numeric != attr2->is_numeric)
{
message_with_line (attr->lineno,
"numeric attribute mismatch calling `%s' from `%s'",
/* A random C expression. */
case SYMBOL_REF:
- printf ("%s", XSTR (exp, 0));
+ print_c_condition (XSTR (exp, 0));
break;
/* The address of the branch target. */
printf ("static ");
if (!attr->is_numeric)
printf ("enum attr_%s\n", attr->name);
- else if (attr->unsigned_p)
- printf ("unsigned int\n");
else
printf ("int\n");
}
}
+/* Write a series of case statements for every instruction in list IE.
+ INDENT is the amount of indentation to write before each case. */
+
+static void
+write_insn_cases (struct insn_ent *ie, int indent)
+{
+ for (; ie != 0; ie = ie->next)
+ if (ie->def->insn_code != -1)
+ {
+ write_indent (indent);
+ if (GET_CODE (ie->def->def) == DEFINE_PEEPHOLE)
+ printf ("case %d: /* define_peephole, line %d */\n",
+ ie->def->insn_code, ie->def->lineno);
+ else
+ printf ("case %d: /* %s */\n",
+ ie->def->insn_code, XSTR (ie->def->def, 0));
+ }
+}
+
/* Write out the computation for one attribute value. */
static void
int write_case_lines, const char *prefix, const char *suffix,
int indent, rtx known_true)
{
- struct insn_ent *ie;
-
if (av->num_insns == 0)
return;
}
if (write_case_lines)
- {
- for (ie = av->first_insn; ie; ie = ie->next)
- if (ie->def->insn_code != -1)
- {
- write_indent (indent);
- printf ("case %d: /* %s */\n",
- ie->def->insn_code, XSTR (ie->def->def, 0));
- }
- }
+ write_insn_cases (av->first_insn, indent);
else
{
write_indent (indent);
if (!attr->is_numeric)
printf (" enum attr_%s ", attr->name);
- else if (attr->unsigned_p)
- printf (" unsigned int ");
else
printf (" int ");
break;
case SYMBOL_REF:
- fputs (XSTR (value, 0), stdout);
+ print_c_condition (XSTR (value, 0));
break;
case ATTR:
attr = oballoc (sizeof (struct attr_desc));
attr->name = DEF_ATTR_STRING (name);
attr->first_value = attr->default_val = NULL;
- attr->is_numeric = attr->negative_ok = attr->is_const = attr->is_special = 0;
- attr->unsigned_p = attr->static_p = 0;
+ attr->is_numeric = attr->is_const = attr->is_special = 0;
+ attr->static_p = 0;
attr->next = attrs[index];
attrs[index] = attr;
attr->is_numeric = 1;
attr->is_const = 0;
attr->is_special = (special & ATTR_SPECIAL) != 0;
- attr->negative_ok = (special & ATTR_NEGATIVE_OK) != 0;
- attr->unsigned_p = (special & ATTR_UNSIGNED) != 0;
attr->static_p = (special & ATTR_STATIC) != 0;
attr->default_val = get_attr_value (value, attr, -2);
}
{
struct attr_desc *attr = find_attr (&num_delay_slots_str, 0);
struct attr_value *av;
- struct insn_ent *ie;
if (attr)
{
length_used = 0;
walk_attr_value (av->value);
if (length_used)
- {
- for (ie = av->first_insn; ie; ie = ie->next)
- if (ie->def->insn_code != -1)
- printf (" case %d: /* %s */\n",
- ie->def->insn_code, XSTR (ie->def->def, 0));
- printf (" return 0;\n");
- }
+ write_insn_cases (av->first_insn, 4);
}
printf (" default:\n");