1 /* Declarations for rtx-reader support for gen* routines.
2 Copyright (C) 2000-2023 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_GENSUPPORT_H
21 #define GCC_GENSUPPORT_H
27 extern struct obstack
*rtl_obstack
;
29 /* Information about an .md define_* rtx. */
35 /* The location of the first line of the rtx. */
38 /* The unique number attached to the rtx. Currently all define_insns,
39 define_expands, define_splits, define_peepholes and define_peephole2s
40 share the same insn_code index space. */
44 #define OPTAB_CL(name, pat, c, b, l) name,
45 #define OPTAB_CX(name, pat)
46 #define OPTAB_CD(name, pat) name,
47 #define OPTAB_NL(name, pat, c, b, s, l) name,
48 #define OPTAB_NC(name, pat, c) name,
49 #define OPTAB_NX(name, pat)
50 #define OPTAB_VL(name, pat, c, b, s, l) name,
51 #define OPTAB_VC(name, pat, c) name,
52 #define OPTAB_VX(name, pat)
53 #define OPTAB_DC(name, pat, c) name,
54 #define OPTAB_D(name, pat) name,
56 /* Enumerates all optabs. */
57 typedef enum optab_tag
{
75 /* Describes one entry in optabs.def. */
78 /* The name of the optab (e.g. "add_optab"). */
81 /* The pattern that matching define_expands and define_insns have.
82 See the comment at the head of optabs.def for details. */
85 /* The initializers (in the form of C code) for the libcall_basename,
86 libcall_suffix and libcall_gen fields of (convert_)optab_libcall_d. */
91 /* The optab's enum value. */
94 /* The value returned by optab_to_code (OP). */
97 /* CODE if code_to_optab (CODE) should return OP, otherwise UNKNOWN. */
100 /* 1: conversion optabs with libcall data,
101 2: conversion optabs without libcall data,
102 3: non-conversion optabs with libcall data ("normal" and "overflow"
103 optabs in the optabs.def comment)
104 4: non-conversion optabs without libcall data ("direct" optabs). */
108 extern optab_def optabs
[];
109 extern unsigned int num_optabs
;
111 /* Information about an instruction name that matches an optab pattern. */
114 /* The name of the instruction. */
117 /* The matching optab. */
120 /* The optab modes. M2 is only significant for conversion optabs;
121 it is zero otherwise. */
124 /* An index that provides a lexicographical sort of (OP, M2, M1).
125 Used by genopinit.cc. */
126 unsigned int sort_num
;
129 extern rtx
add_implicit_parallel (rtvec
);
130 extern rtx_reader
*init_rtx_reader_args_cb (int, const char **,
131 bool (*)(const char *));
132 extern rtx_reader
*init_rtx_reader_args (int, const char **);
133 extern bool read_md_rtx (md_rtx_info
*);
134 extern unsigned int get_num_insn_codes ();
136 /* Set this to 0 to disable automatic elision of insn patterns which
137 can never be used in this configuration. See genconditions.cc.
138 Must be set before calling init_md_reader. */
139 extern int insn_elision
;
141 /* Return the C test that says whether a definition rtx can be used,
142 or "" if it can be used unconditionally. */
143 extern const char *get_c_test (rtx
);
145 /* If the C test passed as the argument can be evaluated at compile
146 time, return its truth value; else return -1. The test must have
147 appeared somewhere in the machine description when genconditions
149 extern int maybe_eval_c_test (const char *);
151 /* Add an entry to the table of conditions. Used by genconditions and
153 extern void add_c_test (const char *, int);
155 /* This structure is used internally by gensupport.cc and genconditions.cc. */
163 extern hashval_t
hash_c_test (const void *);
164 extern int cmp_c_test (const void *, const void *);
165 extern void traverse_c_tests (htab_trav
, void *);
168 /* Predicate handling: helper functions and data structures. */
172 struct pred_data
*next
; /* for iterating over the set of all preds */
173 const char *name
; /* predicate name */
174 bool special
; /* special handling of modes? */
176 /* data used primarily by genpreds.cc */
177 const char *c_block
; /* C test block */
178 rtx exp
; /* RTL test expression */
180 /* data used primarily by genrecog.cc */
181 enum rtx_code singleton
; /* if pred takes only one code, that code */
182 int num_codes
; /* number of codes accepted */
183 bool allows_non_lvalue
; /* if pred allows non-lvalue expressions */
184 bool allows_non_const
; /* if pred allows non-const expressions */
185 bool codes
[NUM_RTX_CODE
]; /* set of codes accepted */
188 extern struct pred_data
*first_predicate
;
189 extern struct pred_data
*lookup_predicate (const char *);
190 extern void add_predicate_code (struct pred_data
*, enum rtx_code
);
191 extern void add_predicate (struct pred_data
*);
193 #define FOR_ALL_PREDICATES(p) for (p = first_predicate; p; p = p->next)
197 /* The largest match_operand, match_operator or match_parallel
201 /* The largest match_dup, match_op_dup or match_par_dup number found. */
204 /* The smallest and largest match_scratch number found. */
205 int min_scratch_opno
;
206 int max_scratch_opno
;
208 /* The number of times match_dup, match_op_dup or match_par_dup appears
212 /* The number of rtx arguments to the generator function. */
213 int num_generator_args
;
215 /* The number of rtx operands in an insn. */
216 int num_insn_operands
;
218 /* The number of operand variables that are needed. */
219 int num_operand_vars
;
222 extern hash_set
<rtx
> compact_syntax
;
224 extern void get_pattern_stats (struct pattern_stats
*ranges
, rtvec vec
);
225 extern void compute_test_codes (rtx
, file_location
, char *);
226 extern file_location
get_file_location (rtx
);
227 extern const char *get_emit_function (rtx
);
228 extern bool needs_barrier_p (rtx
);
229 extern bool find_optab (optab_pattern
*, const char *);
231 #endif /* GCC_GENSUPPORT_H */