summaryrefslogtreecommitdiff
path: root/gcc/genopinit.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-27 10:13:12 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-27 10:13:12 +0000
commite0e4357b88efe5dc53e50d341a09de4d02331200 (patch)
treecafff2748190357bac05d69d344e79b0e38d1e27 /gcc/genopinit.c
parent7b48bf2011b4020c4a5a2d5d4149b03983f72cc2 (diff)
downloadgcc-tarball-e0e4357b88efe5dc53e50d341a09de4d02331200.tar.gz
gcc-6.1.0gcc-6.1.0
Diffstat (limited to 'gcc/genopinit.c')
-rw-r--r--gcc/genopinit.c290
1 files changed, 31 insertions, 259 deletions
diff --git a/gcc/genopinit.c b/gcc/genopinit.c
index 7fa59eb89a..6d7ad4ffc3 100644
--- a/gcc/genopinit.c
+++ b/gcc/genopinit.c
@@ -1,5 +1,5 @@
/* Generate code to initialize optabs from machine description.
- Copyright (C) 1993-2015 Free Software Foundation, Inc.
+ Copyright (C) 1993-2016 Free Software Foundation, Inc.
This file is part of GCC.
@@ -35,245 +35,22 @@ static const char * const rtx_upname[] = {
#undef DEF_RTL_EXPR
-
-/* The entries in optabs.def are categorized:
- C: A "conversion" optab, which uses two modes; has libcall data.
- N: A "normal" optab, which uses one mode; has libcall data.
- D: A "direct" optab, which uses one mode; does not have libcall data.
- V: An "oVerflow" optab. Like N, but does not record its code in
- code_to_optab.
-
- CX, NX, VX: An extra pattern entry for a conversion or normal optab.
-
- These patterns may be present in the MD file with names that contain
- the mode(s) used and the name of the operation. This array contains
- a list of optabs that need to be initialized. Within each name,
- $a and $b are used to match a short mode name (the part of the mode
- name not including `mode' and converted to lower-case).
-
- $I means that only full integer modes should be considered for the
- next mode, and $F means that only float modes should be considered.
- $P means that both full and partial integer modes should be considered.
- $Q means that only fixed-point modes should be considered.
-
- The pattern may be NULL if the optab exists only for the libcalls
- that we plan to attach to it, and there are no named patterns in
- the md files. */
-
-#define OPTAB_CL(name, pat, c, b, l) name,
-#define OPTAB_CX(name, pat)
-#define OPTAB_CD(name, pat) name,
-#define OPTAB_NL(name, pat, c, b, s, l) name,
-#define OPTAB_NC(name, pat, c) name,
-#define OPTAB_NX(name, pat)
-#define OPTAB_VL(name, pat, c, b, s, l) name,
-#define OPTAB_VC(name, pat, c) name,
-#define OPTAB_VX(name, pat)
-#define OPTAB_DC(name, pat, c) name,
-#define OPTAB_D(name, pat) name,
-
-typedef enum optab_tag {
- unknown_optab,
-#include "optabs.def"
- NUM_OPTABS
-} optab;
-
-#undef OPTAB_CL
-#undef OPTAB_CX
-#undef OPTAB_CD
-#undef OPTAB_NL
-#undef OPTAB_NC
-#undef OPTAB_NX
-#undef OPTAB_VL
-#undef OPTAB_VC
-#undef OPTAB_VX
-#undef OPTAB_DC
-#undef OPTAB_D
-
-#define NS "NULL"
-#define ZS "'\\0'"
-#define OPTAB_CL(o, p, c, b, l) { #o, p, #b, ZS, #l, o, c, UNKNOWN, 1 },
-#define OPTAB_CX(o, p) { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 1 },
-#define OPTAB_CD(o, p) { #o, p, NS, ZS, NS, o, UNKNOWN, UNKNOWN, 2 },
-#define OPTAB_NL(o, p, c, b, s, l) { #o, p, #b, #s, #l, o, c, c, 3 },
-#define OPTAB_NC(o, p, c) { #o, p, NS, ZS, NS, o, c, c, 3 },
-#define OPTAB_NX(o, p) { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 3 },
-#define OPTAB_VL(o, p, c, b, s, l) { #o, p, #b, #s, #l, o, c, UNKNOWN, 3 },
-#define OPTAB_VC(o, p, c) { #o, p, NS, ZS, NS, o, c, UNKNOWN, 3 },
-#define OPTAB_VX(o, p) { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 3 },
-#define OPTAB_DC(o, p, c) { #o, p, NS, ZS, NS, o, c, c, 4 },
-#define OPTAB_D(o, p) { #o, p, NS, ZS, NS, o, UNKNOWN, UNKNOWN, 4 },
-
-typedef struct optab_def_d
-{
- const char *name;
- const char *pattern;
- const char *base;
- const char *suffix;
- const char *libcall;
- unsigned int op;
- enum rtx_code fcode;
- enum rtx_code rcode;
- unsigned int kind;
-} optab_def;
-
-static optab_def optabs[] = {
- { "unknown_optab", NULL, NS, ZS, NS, unknown_optab, UNKNOWN, UNKNOWN, 0 },
-#include "optabs.def"
-};
-
-#undef OPTAB_CL
-#undef OPTAB_CX
-#undef OPTAB_CD
-#undef OPTAB_NL
-#undef OPTAB_NC
-#undef OPTAB_NX
-#undef OPTAB_VL
-#undef OPTAB_VC
-#undef OPTAB_VX
-#undef OPTAB_DC
-#undef OPTAB_D
-
/* Vector in which to collect insns that match. */
-
-typedef struct pattern_d
-{
- const char *name;
- unsigned int op;
- unsigned int m1, m2;
- unsigned int sort_num;
-} pattern;
-
-
-static vec<pattern> patterns;
-
-static bool
-match_pattern (pattern *p, const char *name, const char *pat)
-{
- bool force_float = false;
- bool force_int = false;
- bool force_partial_int = false;
- bool force_fixed = false;
-
- if (pat == NULL)
- return false;
- for (; ; ++pat)
- {
- if (*pat != '$')
- {
- if (*pat != *name++)
- return false;
- if (*pat == '\0')
- return true;
- continue;
- }
- switch (*++pat)
- {
- case 'I':
- force_int = 1;
- break;
- case 'P':
- force_partial_int = 1;
- break;
- case 'F':
- force_float = 1;
- break;
- case 'Q':
- force_fixed = 1;
- break;
-
- case 'a':
- case 'b':
- {
- int i;
-
- /* This loop will stop at the first prefix match, so
- look through the modes in reverse order, in case
- there are extra CC modes and CC is a prefix of the
- CC modes (as it should be). */
- for (i = (MAX_MACHINE_MODE) - 1; i >= 0; i--)
- {
- const char *p, *q;
- for (p = GET_MODE_NAME (i), q = name; *p; p++, q++)
- if (TOLOWER (*p) != *q)
- break;
- if (*p == 0
- && (! force_int || mode_class[i] == MODE_INT
- || mode_class[i] == MODE_VECTOR_INT)
- && (! force_partial_int
- || mode_class[i] == MODE_INT
- || mode_class[i] == MODE_PARTIAL_INT
- || mode_class[i] == MODE_VECTOR_INT)
- && (! force_float
- || mode_class[i] == MODE_FLOAT
- || mode_class[i] == MODE_DECIMAL_FLOAT
- || mode_class[i] == MODE_COMPLEX_FLOAT
- || mode_class[i] == MODE_VECTOR_FLOAT)
- && (! force_fixed
- || mode_class[i] == MODE_FRACT
- || mode_class[i] == MODE_UFRACT
- || mode_class[i] == MODE_ACCUM
- || mode_class[i] == MODE_UACCUM
- || mode_class[i] == MODE_VECTOR_FRACT
- || mode_class[i] == MODE_VECTOR_UFRACT
- || mode_class[i] == MODE_VECTOR_ACCUM
- || mode_class[i] == MODE_VECTOR_UACCUM))
- break;
- }
-
- if (i < 0)
- return false;
- name += strlen (GET_MODE_NAME (i));
- if (*pat == 'a')
- p->m1 = i;
- else
- p->m2 = i;
-
- force_int = false;
- force_partial_int = false;
- force_float = false;
- force_fixed = false;
- }
- break;
-
- default:
- gcc_unreachable ();
- }
- }
-}
+static vec<optab_pattern> patterns;
static void
-gen_insn (rtx insn)
+gen_insn (md_rtx_info *info)
{
- const char *name = XSTR (insn, 0);
- pattern p;
- unsigned pindex;
-
- /* Don't mention "unnamed" instructions. */
- if (*name == 0 || *name == '*')
- return;
- p.name = name;
-
- /* See if NAME matches one of the patterns we have for the optabs
- we know about. */
- for (pindex = 0; pindex < ARRAY_SIZE (optabs); pindex++)
- {
- p.m1 = p.m2 = 0;
- if (match_pattern (&p, name, optabs[pindex].pattern))
- {
- p.op = optabs[pindex].op;
- p.sort_num = (p.op << 16) | (p.m2 << 8) | p.m1;
- patterns.safe_push (p);
- return;
- }
- }
+ optab_pattern p;
+ if (find_optab (&p, XSTR (info->def, 0)))
+ patterns.safe_push (p);
}
static int
pattern_cmp (const void *va, const void *vb)
{
- const pattern *a = (const pattern *)va;
- const pattern *b = (const pattern *)vb;
+ const optab_pattern *a = (const optab_pattern *)va;
+ const optab_pattern *b = (const optab_pattern *)vb;
return a->sort_num - b->sort_num;
}
@@ -332,7 +109,7 @@ main (int argc, char **argv)
{
FILE *h_file, *s_file;
unsigned int i, j, n, last_kind[5];
- pattern *p;
+ optab_pattern *p;
progname = "genopinit";
@@ -346,22 +123,25 @@ main (int argc, char **argv)
s_file = open_outfile (source_file_name);
/* Read the machine description. */
- while (1)
- {
- int line_no, insn_code_number = 0;
- rtx desc = read_md_rtx (&line_no, &insn_code_number);
- if (desc == NULL)
+ md_rtx_info info;
+ while (read_md_rtx (&info))
+ switch (GET_CODE (info.def))
+ {
+ case DEFINE_INSN:
+ case DEFINE_EXPAND:
+ gen_insn (&info);
break;
- if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND)
- gen_insn (desc);
- }
+
+ default:
+ break;
+ }
/* Sort the collected patterns. */
patterns.qsort (pattern_cmp);
/* Now that we've handled the "extra" patterns, eliminate them from
the optabs array. That way they don't get in the way below. */
- n = ARRAY_SIZE (optabs);
+ n = num_optabs;
for (i = 0; i < n; )
if (optabs[i].base == NULL)
optabs[i] = optabs[--n];
@@ -373,6 +153,9 @@ main (int argc, char **argv)
purging of the X patterns above. */
qsort (optabs, n, sizeof (optab_def), optab_kind_cmp);
+ fprintf (h_file, "#ifndef GCC_INSN_OPINIT_H\n");
+ fprintf (h_file, "#define GCC_INSN_OPINIT_H 1\n");
+
/* Emit the optab enumeration for the header file. */
fprintf (h_file, "enum optab_tag {\n");
for (i = j = 0; i < n; ++i)
@@ -422,6 +205,7 @@ main (int argc, char **argv)
" the body of that kind of insn. */\n"
"#define GEN_FCN(CODE) (insn_data[CODE].genfun)\n"
"\n"
+ "#ifdef NUM_RTX_CODE\n"
"/* Contains the optab used for each rtx code, and vice-versa. */\n"
"extern const optab code_to_optab_[NUM_RTX_CODE];\n"
"extern const enum rtx_code optab_to_code_[NUM_OPTABS];\n"
@@ -437,6 +221,7 @@ main (int argc, char **argv)
"{\n"
" return optab_to_code_[op];\n"
"}\n"
+ "#endif\n"
"\n"
"extern const struct convert_optab_libcall_d convlib_def[NUM_CONVLIB_OPTABS];\n"
"extern const struct optab_libcall_d normlib_def[NUM_NORMLIB_OPTABS];\n"
@@ -464,31 +249,17 @@ main (int argc, char **argv)
"#include \"config.h\"\n"
"#include \"system.h\"\n"
"#include \"coretypes.h\"\n"
- "#include \"tm.h\"\n"
- "#include \"hash-set.h\"\n"
- "#include \"machmode.h\"\n"
- "#include \"vec.h\"\n"
- "#include \"double-int.h\"\n"
- "#include \"input.h\"\n"
- "#include \"alias.h\"\n"
- "#include \"symtab.h\"\n"
- "#include \"wide-int.h\"\n"
- "#include \"inchash.h\"\n"
+ "#include \"backend.h\"\n"
+ "#include \"predict.h\"\n"
"#include \"tree.h\"\n"
+ "#include \"rtl.h\"\n"
+ "#include \"alias.h\"\n"
"#include \"varasm.h\"\n"
"#include \"stor-layout.h\"\n"
"#include \"calls.h\"\n"
- "#include \"rtl.h\"\n"
- "#include \"predict.h\"\n"
"#include \"tm_p.h\"\n"
"#include \"flags.h\"\n"
"#include \"insn-config.h\"\n"
- "#include \"hashtab.h\"\n"
- "#include \"hard-reg-set.h\"\n"
- "#include \"function.h\"\n"
- "#include \"statistics.h\"\n"
- "#include \"real.h\"\n"
- "#include \"fixed-value.h\"\n"
"#include \"expmed.h\"\n"
"#include \"dojump.h\"\n"
"#include \"explow.h\"\n"
@@ -604,6 +375,7 @@ main (int argc, char **argv)
}
fprintf (s_file, "};\n\n");
+ fprintf (h_file, "#endif\n");
return (fclose (h_file) == 0 && fclose (s_file) == 0
? SUCCESS_EXIT_CODE : FATAL_EXIT_CODE);
}