summaryrefslogtreecommitdiff
path: root/gcc/gensupport.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-12-02 09:06:28 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-12-02 09:06:28 +0000
commit886456e210ef12d77f625ace8f312ab23d208aff (patch)
tree5b44d07d2d4f3d21be039ca6d049269722224bbf /gcc/gensupport.h
parente970b4b0002d0bc24cf4461fb0eadd7ee2241cab (diff)
Check for invalid FAILs
This patch makes it a compile-time error for an internal-fn optab to FAIL. There are certainly other optabs and patterns besides these that aren't allowed to fail, but this at least deals with the immediate point of controversy. Tested normally on x86_64-linux-gnu. Also tested by building one configuration per cpu directory. arc-elf and pdp11 didn't build for unrelated reasons, but I checked that insn-emit.o built for both without error. gcc/ * Makefile.in (GENSUPPORT_H): New macro. (build/gensupport.o, build/read-rtl.o, build/genattr.o) (build/genattr-common.o, build/genattrtab.o, build/genautomata.o) (build/gencodes.o, build/genconditions.o, build/genconfig.o) (build/genconstants.o, build/genextract.o, build/genflags.o) (build/gentarget-def.o): Use it. (build/genemit.o): Likewise. Depend on internal-fn.def. * genopinit.c: Move block comment to optabs.def. (optab_tag, optab_def): Move to gensupport.h (pattern): Likewise, renaming to optab_pattern. (match_pattern): Move to gensupport.c (gen_insn): Use find_optab. (patterns, pattern_cmp): Replace pattern with optab_pattern. (main): Likewise. Use num_optabs. * optabs.def: Add comment that was previously in genopinit.c. * gensupport.h (optab_tag): Moved from genopinit.c (optab_def): Likewise, expanding commentary. (optab_pattern): Likewise, after renaming from pattern. (optabs, num_optabs, find_optab): Declare. * gensupport.c (optabs): Moved from genopinit.c. (num_optabs): New variable. (match_pattern): Moved from genopinit.c. (find_optab): New function, extracted from genopinit.c:gen_insn. * genemit.c (nofail_optabs): New variable. (emit_c_code): New function. (gen_expand): Check whether the instruction is an optab that isn't allowed to fail. Call emit_c_code. (gen_split): Call emit_c_code here too. (main): Initialize nofail_optabs. Don't emit FAIL and DONE here. From-SVN: r231160
Diffstat (limited to 'gcc/gensupport.h')
-rw-r--r--gcc/gensupport.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/gcc/gensupport.h b/gcc/gensupport.h
index 0199e398034..456efa0c7d1 100644
--- a/gcc/gensupport.h
+++ b/gcc/gensupport.h
@@ -39,6 +39,91 @@ struct md_rtx_info {
int index;
};
+#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,
+
+/* Enumerates all optabs. */
+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
+
+/* Describes one entry in optabs.def. */
+struct optab_def
+{
+ /* The name of the optab (e.g. "add_optab"). */
+ const char *name;
+
+ /* The pattern that matching define_expands and define_insns have.
+ See the comment at the head of optabs.def for details. */
+ const char *pattern;
+
+ /* The initializers (in the form of C code) for the libcall_basename,
+ libcall_suffix and libcall_gen fields of (convert_)optab_libcall_d. */
+ const char *base;
+ const char *suffix;
+ const char *libcall;
+
+ /* The optab's enum value. */
+ unsigned int op;
+
+ /* The value returned by optab_to_code (OP). */
+ enum rtx_code fcode;
+
+ /* CODE if code_to_optab (CODE) should return OP, otherwise UNKNOWN. */
+ enum rtx_code rcode;
+
+ /* 1: conversion optabs with libcall data,
+ 2: conversion optabs without libcall data,
+ 3: non-conversion optabs with libcall data ("normal" and "overflow"
+ optabs in the optabs.def comment)
+ 4: non-conversion optabs without libcall data ("direct" optabs). */
+ unsigned int kind;
+};
+
+extern optab_def optabs[];
+extern unsigned int num_optabs;
+
+/* Information about an instruction name that matches an optab pattern. */
+struct optab_pattern
+{
+ /* The name of the instruction. */
+ const char *name;
+
+ /* The matching optab. */
+ unsigned int op;
+
+ /* The optab modes. M2 is only significant for conversion optabs;
+ it is zero otherwise. */
+ unsigned int m1, m2;
+
+ /* An index that provides a lexicographical sort of (OP, M2, M1).
+ Used by genopinit.c. */
+ unsigned int sort_num;
+};
+
extern rtx add_implicit_parallel (rtvec);
extern bool init_rtx_reader_args_cb (int, char **, bool (*)(const char *));
extern bool init_rtx_reader_args (int, char **);
@@ -135,5 +220,6 @@ extern void compute_test_codes (rtx, file_location, char *);
extern file_location get_file_location (rtx);
extern const char *get_emit_function (rtx);
extern bool needs_barrier_p (rtx);
+extern bool find_optab (optab_pattern *, const char *);
#endif /* GCC_GENSUPPORT_H */