/* Generate code from machine description to compute values of attributes.
- Copyright (C) 1991-2019 Free Software Foundation, Inc.
+ Copyright (C) 1991-2020 Free Software Foundation, Inc.
Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
This file is part of GCC.
class insn_def
{
public:
- struct insn_def *next; /* Next insn in chain. */
+ class insn_def *next; /* Next insn in chain. */
rtx def; /* The DEFINE_... */
int insn_code; /* Instruction number. */
int insn_index; /* Expression number in file, for errors. */
struct insn_ent
{
struct insn_ent *next; /* Next in chain. */
- struct insn_def *def; /* Instruction definition. */
+ class insn_def *def; /* Instruction definition. */
};
/* Each value of an attribute (either constant or computed) is assigned a
public:
char *name; /* Name of attribute. */
const char *enum_name; /* Enum name for DEFINE_ENUM_NAME. */
- struct attr_desc *next; /* Next attribute. */
+ class attr_desc *next; /* Next attribute. */
struct attr_value *first_value; /* First value of this attribute. */
struct attr_value *default_val; /* Default value for this attribute. */
file_location loc; /* Where in the .md files it occurs. */
{
public:
rtx def; /* DEFINE_DELAY expression. */
- struct delay_desc *next; /* Next DEFINE_DELAY. */
+ class delay_desc *next; /* Next DEFINE_DELAY. */
file_location loc; /* Where in the .md files it occurs. */
int num; /* Number of DEFINE_DELAY, starting at 1. */
};
{
struct attr_value *av;
struct insn_ent *ie;
- struct attr_desc *attr;
+ class attr_desc *attr;
struct attr_value_list *next;
};
/* This one is indexed by the first character of the attribute name. */
#define MAX_ATTRS_INDEX 256
-static struct attr_desc *attrs[MAX_ATTRS_INDEX];
-static struct insn_def *defs;
-static struct delay_desc *delays;
+static class attr_desc *attrs[MAX_ATTRS_INDEX];
+static class insn_def *defs;
+static class delay_desc *delays;
struct attr_value_list **insn_code_values;
/* Other variables. */
static char *attr_printf (unsigned int, const char *, ...)
ATTRIBUTE_PRINTF_2;
static rtx make_numeric_value (int);
-static struct attr_desc *find_attr (const char **, int);
+static class attr_desc *find_attr (const char **, int);
static rtx mk_attr_alt (alternative_mask);
static char *next_comma_elt (const char **);
static rtx insert_right_side (enum rtx_code, rtx, rtx, int, int);
static bool attr_alt_subset_p (rtx, rtx);
static bool attr_alt_subset_of_compl_p (rtx, rtx);
static void clear_struct_flag (rtx);
-static void write_attr_valueq (FILE *, struct attr_desc *, const char *);
-static struct attr_value *find_most_used (struct attr_desc *);
-static void write_attr_set (FILE *, struct attr_desc *, int, rtx,
+static void write_attr_valueq (FILE *, class attr_desc *, const char *);
+static struct attr_value *find_most_used (class attr_desc *);
+static void write_attr_set (FILE *, class attr_desc *, int, rtx,
const char *, const char *, rtx,
int, int, unsigned int);
-static void write_attr_case (FILE *, struct attr_desc *,
+static void write_attr_case (FILE *, class attr_desc *,
struct attr_value *,
int, const char *, const char *, int, rtx);
-static void write_attr_value (FILE *, struct attr_desc *, rtx);
+static void write_attr_value (FILE *, class attr_desc *, rtx);
static void write_upcase (FILE *, const char *);
static void write_indent (FILE *, int);
static rtx identity_fn (rtx);
Return a perhaps modified replacement expression for the value. */
static rtx
-check_attr_value (file_location loc, rtx exp, struct attr_desc *attr)
+check_attr_value (file_location loc, rtx exp, class attr_desc *attr)
{
struct attr_value *av;
const char *p;
case ATTR:
{
- struct attr_desc *attr2 = find_attr (&XSTR (exp, 0), 0);
+ class attr_desc *attr2 = find_attr (&XSTR (exp, 0), 0);
if (attr2 == NULL)
error_at (loc, "unknown attribute `%s' in ATTR",
XSTR (exp, 0));
It becomes a COND with each test being (eq_attr "alternative" "n") */
static rtx
-convert_set_attr_alternative (rtx exp, struct insn_def *id)
+convert_set_attr_alternative (rtx exp, class insn_def *id)
{
int num_alt = id->num_alternatives;
rtx condexp;
list of values is given, convert to SET_ATTR_ALTERNATIVE first. */
static rtx
-convert_set_attr (rtx exp, struct insn_def *id)
+convert_set_attr (rtx exp, class insn_def *id)
{
rtx newexp;
const char *name_ptr;
static void
check_defs (void)
{
- struct insn_def *id;
- struct attr_desc *attr;
+ class insn_def *id;
+ class attr_desc *attr;
int i;
rtx value;
value. LOC is the location to use for error reporting. */
static rtx
-make_canonical (file_location loc, struct attr_desc *attr, rtx exp)
+make_canonical (file_location loc, class attr_desc *attr, rtx exp)
{
int i;
rtx newexp;
alternatives. LOC is the location to use for error reporting. */
static struct attr_value *
-get_attr_value (file_location loc, rtx value, struct attr_desc *attr,
+get_attr_value (file_location loc, rtx value, class attr_desc *attr,
int insn_code)
{
struct attr_value *av;
static void
expand_delays (void)
{
- struct delay_desc *delay;
+ class delay_desc *delay;
rtx condexp;
rtx newexp;
int i;
the attribute. */
static void
-fill_attr (struct attr_desc *attr)
+fill_attr (class attr_desc *attr)
{
struct attr_value *av;
struct insn_ent *ie;
- struct insn_def *id;
+ class insn_def *id;
int i;
rtx value;
static rtx (*const address_fn[]) (rtx)
= {max_fn, min_fn, one_fn, identity_fn};
size_t i;
- struct attr_desc *length_attr, *new_attr;
+ class attr_desc *length_attr, *new_attr;
struct attr_value *av, *new_av;
struct insn_ent *ie, *new_ie;
static void
write_length_unit_log (FILE *outf)
{
- struct attr_desc *length_attr = find_attr (&length_str, 0);
+ class attr_desc *length_attr = find_attr (&length_str, 0);
struct attr_value *av;
struct insn_ent *ie;
unsigned int length_unit_log, length_or;
corresponding to INSN_CODE and INSN_INDEX. */
static rtx
-evaluate_eq_attr (rtx exp, struct attr_desc *attr, rtx value,
+evaluate_eq_attr (rtx exp, class attr_desc *attr, rtx value,
int insn_code, int insn_index)
{
rtx orexp, andexp;
simplify_test_exp (rtx exp, int insn_code, int insn_index)
{
rtx left, right;
- struct attr_desc *attr;
+ class attr_desc *attr;
struct attr_value *av;
struct insn_ent *ie;
struct attr_value_list *iv;
otherwise return 0. */
static int
-tests_attr_p (rtx p, struct attr_desc *attr)
+tests_attr_p (rtx p, class attr_desc *attr)
{
const char *fmt;
int i, ie, j, je;
attr_desc pointers), and return the size of that array. */
static int
-get_attr_order (struct attr_desc ***ret)
+get_attr_order (class attr_desc ***ret)
{
int i, j;
int num = 0;
- struct attr_desc *attr;
- struct attr_desc **all, **sorted;
+ class attr_desc *attr;
+ class attr_desc **all, **sorted;
char *handled;
for (i = 0; i < MAX_ATTRS_INDEX; i++)
for (attr = attrs[i]; attr; attr = attr->next)
num++;
- all = XNEWVEC (struct attr_desc *, num);
- sorted = XNEWVEC (struct attr_desc *, num);
+ all = XNEWVEC (class attr_desc *, num);
+ sorted = XNEWVEC (class attr_desc *, num);
handled = XCNEWVEC (char, num);
num = 0;
for (i = 0; i < MAX_ATTRS_INDEX; i++)
if (DEBUG)
for (j = 0; j < num; j++)
{
- struct attr_desc *attr2;
+ class attr_desc *attr2;
struct attr_value *av;
attr = sorted[j];
static void
optimize_attrs (int num_insn_codes)
{
- struct attr_desc *attr;
+ class attr_desc *attr;
struct attr_value *av;
struct insn_ent *ie;
rtx newexp;
int i;
struct attr_value_list *ivbuf;
struct attr_value_list *iv;
- struct attr_desc **topsort;
+ class attr_desc **topsort;
int topnum;
/* For each insn code, make a list of all the insn_ent's for it,
/* Add attribute value NAME to the beginning of ATTR's list. */
static void
-add_attr_value (struct attr_desc *attr, const char *name)
+add_attr_value (class attr_desc *attr, const char *name)
{
struct attr_value *av;
{
struct enum_type *et;
struct enum_value *ev;
- struct attr_desc *attr;
+ class attr_desc *attr;
const char *name_ptr;
char *p;
rtx def = info->def;
static void
gen_insn (md_rtx_info *info)
{
- struct insn_def *id;
+ class insn_def *id;
rtx def = info->def;
- id = oballoc (struct insn_def);
+ id = oballoc (class insn_def);
id->next = defs;
defs = id;
id->def = def;
static void
gen_delay (md_rtx_info *info)
{
- struct delay_desc *delay;
+ class delay_desc *delay;
int i;
rtx def = info->def;
have_annul_false = 1;
}
- delay = oballoc (struct delay_desc);
+ delay = oballoc (class delay_desc);
delay->def = def;
delay->num = ++num_delays;
delay->next = delays;
{
int i;
const char *name;
- struct attr_desc *attr;
+ class attr_desc *attr;
if (exp == NULL)
return;
{
int comparison_operator = 0;
RTX_CODE code;
- struct attr_desc *attr;
+ class attr_desc *attr;
if (emit_parens)
fprintf (outf, "(");
/* Write out a function to obtain the attribute for a given INSN. */
static void
-write_attr_get (FILE *outf, struct attr_desc *attr)
+write_attr_get (FILE *outf, class attr_desc *attr)
{
struct attr_value *av, *common_av;
int i, j;
if ((attrs_seen_more_than_once & (1U << i)) != 0)
{
const char *name = cached_attrs[i];
- struct attr_desc *cached_attr;
+ class attr_desc *cached_attr;
if (i != j)
cached_attrs[j] = name;
cached_attr = find_attr (&name, 0);
and ";"). */
static void
-write_attr_set (FILE *outf, struct attr_desc *attr, int indent, rtx value,
+write_attr_set (FILE *outf, class attr_desc *attr, int indent, rtx value,
const char *prefix, const char *suffix, rtx known_true,
int insn_code, int insn_index, unsigned int attrs_cached)
{
/* Write out the computation for one attribute value. */
static void
-write_attr_case (FILE *outf, struct attr_desc *attr, struct attr_value *av,
+write_attr_case (FILE *outf, class attr_desc *attr, struct attr_value *av,
int write_case_lines, const char *prefix, const char *suffix,
int indent, rtx known_true)
{
/* Utilities to write in various forms. */
static void
-write_attr_valueq (FILE *outf, struct attr_desc *attr, const char *s)
+write_attr_valueq (FILE *outf, class attr_desc *attr, const char *s)
{
if (attr->is_numeric)
{
}
static void
-write_attr_value (FILE *outf, struct attr_desc *attr, rtx value)
+write_attr_value (FILE *outf, class attr_desc *attr, rtx value)
{
int op;
case ATTR:
{
- struct attr_desc *attr2 = find_attr (&XSTR (value, 0), 0);
+ class attr_desc *attr2 = find_attr (&XSTR (value, 0), 0);
if (attr->enum_name)
fprintf (outf, "(enum %s)", attr->enum_name);
else if (!attr->is_numeric)
goto do_operator;
do_operator:
+ fprintf (outf, "(");
write_attr_value (outf, attr, XEXP (value, 0));
- fputc (' ', outf);
- fputc (op, outf);
- fputc (' ', outf);
+ fprintf (outf, " %c ", op);
write_attr_value (outf, attr, XEXP (value, 1));
+ fprintf (outf, ")");
break;
case IF_THEN_ELSE:
static void
write_eligible_delay (FILE *outf, const char *kind)
{
- struct delay_desc *delay;
+ class delay_desc *delay;
int max_slots;
char str[50];
const char *pstr;
- struct attr_desc *attr;
+ class attr_desc *attr;
struct attr_value *av, *common_av;
int i;
return attr_string (start, *pstr - start);
}
-/* Return a `struct attr_desc' pointer for a given named attribute. If CREATE
+/* Return a `class attr_desc' pointer for a given named attribute. If CREATE
is nonzero, build a new attribute, if one does not exist. *NAME_P is
replaced by a pointer to a canonical copy of the string. */
-static struct attr_desc *
+static class attr_desc *
find_attr (const char **name_p, int create)
{
- struct attr_desc *attr;
+ class attr_desc *attr;
int index;
const char *name = *name_p;
if (! create)
return NULL;
- attr = oballoc (struct attr_desc);
+ attr = oballoc (class attr_desc);
attr->name = DEF_ATTR_STRING (name);
attr->enum_name = 0;
attr->first_value = attr->default_val = NULL;
static void
make_internal_attr (const char *name, rtx value, int special)
{
- struct attr_desc *attr;
+ class attr_desc *attr;
attr = find_attr (&name, 1);
gcc_assert (!attr->default_val);
/* Find the most used value of an attribute. */
static struct attr_value *
-find_most_used (struct attr_desc *attr)
+find_most_used (class attr_desc *attr)
{
struct attr_value *av;
struct attr_value *most_used;
static void
write_const_num_delay_slots (FILE *outf)
{
- struct attr_desc *attr = find_attr (&num_delay_slots_str, 0);
+ class attr_desc *attr = find_attr (&num_delay_slots_str, 0);
struct attr_value *av;
if (attr)
struct insn_reserv *decl = oballoc (struct insn_reserv);
rtx def = info->def;
- struct attr_desc attr = { };
+ class attr_desc attr = { };
attr.name = DEF_ATTR_STRING (XSTR (def, 0));
attr.loc = info->loc;
/* Try to find a const attribute (usually cpu or tune) that is used
in all define_insn_reservation conditions. */
-static struct attr_desc *
+static class attr_desc *
find_tune_attr (rtx exp)
{
- struct attr_desc *attr;
+ class attr_desc *attr;
switch (GET_CODE (exp))
{
int i;
struct insn_reserv *decl;
rtx code_exp, lats_exp, byps_exp;
- struct attr_desc *tune_attr;
+ class attr_desc *tune_attr;
if (n_insn_reservs == 0)
return;
int
main (int argc, const char **argv)
{
- struct attr_desc *attr;
- struct insn_def *id;
+ class attr_desc *attr;
+ class insn_def *id;
int i;
progname = "genattrtab";