1*38fd1498Szrj /* Data structure definitions for a generic GCC target.
2*38fd1498Szrj Copyright (C) 2001-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This program is free software; you can redistribute it and/or modify it
5*38fd1498Szrj under the terms of the GNU General Public License as published by the
6*38fd1498Szrj Free Software Foundation; either version 3, or (at your option) any
7*38fd1498Szrj later version.
8*38fd1498Szrj
9*38fd1498Szrj This program is distributed in the hope that it will be useful,
10*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of
11*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12*38fd1498Szrj GNU General Public License for more details.
13*38fd1498Szrj
14*38fd1498Szrj You should have received a copy of the GNU General Public License
15*38fd1498Szrj along with this program; see the file COPYING3. If not see
16*38fd1498Szrj <http://www.gnu.org/licenses/>.
17*38fd1498Szrj
18*38fd1498Szrj In other words, you are welcome to use, share and improve this program.
19*38fd1498Szrj You are forbidden to forbid anyone else to use, share and improve
20*38fd1498Szrj what you give them. Help stamp out software-hoarding! */
21*38fd1498Szrj
22*38fd1498Szrj
23*38fd1498Szrj /* This file contains a data structure that describes a GCC target.
24*38fd1498Szrj At present it is incomplete, but in future it should grow to
25*38fd1498Szrj contain most or all target machine and target O/S specific
26*38fd1498Szrj information.
27*38fd1498Szrj
28*38fd1498Szrj This structure has its initializer declared in target-def.h in the
29*38fd1498Szrj form of large macro TARGET_INITIALIZER that expands to many smaller
30*38fd1498Szrj macros.
31*38fd1498Szrj
32*38fd1498Szrj The smaller macros each initialize one component of the structure,
33*38fd1498Szrj and each has a default. Each target should have a file that
34*38fd1498Szrj includes target.h and target-def.h, and overrides any inappropriate
35*38fd1498Szrj defaults by undefining the relevant macro and defining a suitable
36*38fd1498Szrj replacement. That file should then contain the definition of
37*38fd1498Szrj "targetm" like so:
38*38fd1498Szrj
39*38fd1498Szrj struct gcc_target targetm = TARGET_INITIALIZER;
40*38fd1498Szrj
41*38fd1498Szrj Doing things this way allows us to bring together everything that
42*38fd1498Szrj defines a GCC target. By supplying a default that is appropriate
43*38fd1498Szrj to most targets, we can easily add new items without needing to
44*38fd1498Szrj edit dozens of target configuration files. It should also allow us
45*38fd1498Szrj to gradually reduce the amount of conditional compilation that is
46*38fd1498Szrj scattered throughout GCC. */
47*38fd1498Szrj
48*38fd1498Szrj #ifndef GCC_TARGET_H
49*38fd1498Szrj #define GCC_TARGET_H
50*38fd1498Szrj
51*38fd1498Szrj #include "insn-codes.h"
52*38fd1498Szrj #include "tm.h"
53*38fd1498Szrj #include "hard-reg-set.h"
54*38fd1498Szrj
55*38fd1498Szrj #if CHECKING_P
56*38fd1498Szrj
57*38fd1498Szrj struct cumulative_args_t { void *magic; void *p; };
58*38fd1498Szrj
59*38fd1498Szrj #else /* !CHECKING_P */
60*38fd1498Szrj
61*38fd1498Szrj /* When using a GCC build compiler, we could use
62*38fd1498Szrj __attribute__((transparent_union)) to get cumulative_args_t function
63*38fd1498Szrj arguments passed like scalars where the ABI would mandate a less
64*38fd1498Szrj efficient way of argument passing otherwise. However, that would come
65*38fd1498Szrj at the cost of less type-safe !CHECKING_P compilation. */
66*38fd1498Szrj
67*38fd1498Szrj union cumulative_args_t { void *p; };
68*38fd1498Szrj
69*38fd1498Szrj #endif /* !CHECKING_P */
70*38fd1498Szrj
71*38fd1498Szrj /* Types used by the record_gcc_switches() target function. */
72*38fd1498Szrj enum print_switch_type
73*38fd1498Szrj {
74*38fd1498Szrj SWITCH_TYPE_PASSED, /* A switch passed on the command line. */
75*38fd1498Szrj SWITCH_TYPE_ENABLED, /* An option that is currently enabled. */
76*38fd1498Szrj SWITCH_TYPE_DESCRIPTIVE, /* Descriptive text, not a switch or option. */
77*38fd1498Szrj SWITCH_TYPE_LINE_START, /* Please emit any necessary text at the start of a line. */
78*38fd1498Szrj SWITCH_TYPE_LINE_END /* Please emit a line terminator. */
79*38fd1498Szrj };
80*38fd1498Szrj
81*38fd1498Szrj /* Types of memory operation understood by the "by_pieces" infrastructure.
82*38fd1498Szrj Used by the TARGET_USE_BY_PIECES_INFRASTRUCTURE_P target hook and
83*38fd1498Szrj internally by the functions in expr.c. */
84*38fd1498Szrj
85*38fd1498Szrj enum by_pieces_operation
86*38fd1498Szrj {
87*38fd1498Szrj CLEAR_BY_PIECES,
88*38fd1498Szrj MOVE_BY_PIECES,
89*38fd1498Szrj SET_BY_PIECES,
90*38fd1498Szrj STORE_BY_PIECES,
91*38fd1498Szrj COMPARE_BY_PIECES
92*38fd1498Szrj };
93*38fd1498Szrj
94*38fd1498Szrj extern unsigned HOST_WIDE_INT by_pieces_ninsns (unsigned HOST_WIDE_INT,
95*38fd1498Szrj unsigned int,
96*38fd1498Szrj unsigned int,
97*38fd1498Szrj by_pieces_operation);
98*38fd1498Szrj
99*38fd1498Szrj typedef int (* print_switch_fn_type) (print_switch_type, const char *);
100*38fd1498Szrj
101*38fd1498Szrj /* An example implementation for ELF targets. Defined in varasm.c */
102*38fd1498Szrj extern int elf_record_gcc_switches (print_switch_type type, const char *);
103*38fd1498Szrj
104*38fd1498Szrj /* Some places still assume that all pointer or address modes are the
105*38fd1498Szrj standard Pmode and ptr_mode. These optimizations become invalid if
106*38fd1498Szrj the target actually supports multiple different modes. For now,
107*38fd1498Szrj we disable such optimizations on such targets, using this function. */
108*38fd1498Szrj extern bool target_default_pointer_address_modes_p (void);
109*38fd1498Szrj
110*38fd1498Szrj /* For hooks which use the MOVE_RATIO macro, this gives the legacy default
111*38fd1498Szrj behavior. */
112*38fd1498Szrj extern unsigned int get_move_ratio (bool);
113*38fd1498Szrj
114*38fd1498Szrj struct stdarg_info;
115*38fd1498Szrj struct spec_info_def;
116*38fd1498Szrj struct hard_reg_set_container;
117*38fd1498Szrj struct cgraph_node;
118*38fd1498Szrj struct cgraph_simd_clone;
119*38fd1498Szrj
120*38fd1498Szrj /* The struct used by the secondary_reload target hook. */
121*38fd1498Szrj struct secondary_reload_info
122*38fd1498Szrj {
123*38fd1498Szrj /* icode is actually an enum insn_code, but we don't want to force every
124*38fd1498Szrj file that includes target.h to include optabs.h . */
125*38fd1498Szrj int icode;
126*38fd1498Szrj int extra_cost; /* Cost for using (a) scratch register(s) to be taken
127*38fd1498Szrj into account by copy_cost. */
128*38fd1498Szrj /* The next two members are for the use of the backward
129*38fd1498Szrj compatibility hook. */
130*38fd1498Szrj struct secondary_reload_info *prev_sri;
131*38fd1498Szrj int t_icode; /* Actually an enum insn_code - see above. */
132*38fd1498Szrj };
133*38fd1498Szrj
134*38fd1498Szrj /* This is defined in sched-int.h . */
135*38fd1498Szrj struct _dep;
136*38fd1498Szrj
137*38fd1498Szrj /* This is defined in ddg.h . */
138*38fd1498Szrj struct ddg;
139*38fd1498Szrj
140*38fd1498Szrj /* This is defined in cfgloop.h . */
141*38fd1498Szrj struct loop;
142*38fd1498Szrj
143*38fd1498Szrj /* This is defined in ifcvt.h. */
144*38fd1498Szrj struct noce_if_info;
145*38fd1498Szrj
146*38fd1498Szrj /* This is defined in tree-ssa-alias.h. */
147*38fd1498Szrj struct ao_ref;
148*38fd1498Szrj
149*38fd1498Szrj /* This is defined in tree-vectorizer.h. */
150*38fd1498Szrj struct _stmt_vec_info;
151*38fd1498Szrj
152*38fd1498Szrj /* These are defined in tree-vect-stmts.c. */
153*38fd1498Szrj extern tree stmt_vectype (struct _stmt_vec_info *);
154*38fd1498Szrj extern bool stmt_in_inner_loop_p (struct _stmt_vec_info *);
155*38fd1498Szrj
156*38fd1498Szrj /* Assembler instructions for creating various kinds of integer object. */
157*38fd1498Szrj
158*38fd1498Szrj struct asm_int_op
159*38fd1498Szrj {
160*38fd1498Szrj const char *hi;
161*38fd1498Szrj const char *si;
162*38fd1498Szrj const char *di;
163*38fd1498Szrj const char *ti;
164*38fd1498Szrj };
165*38fd1498Szrj
166*38fd1498Szrj /* Types of costs for vectorizer cost model. */
167*38fd1498Szrj enum vect_cost_for_stmt
168*38fd1498Szrj {
169*38fd1498Szrj scalar_stmt,
170*38fd1498Szrj scalar_load,
171*38fd1498Szrj scalar_store,
172*38fd1498Szrj vector_stmt,
173*38fd1498Szrj vector_load,
174*38fd1498Szrj vector_gather_load,
175*38fd1498Szrj unaligned_load,
176*38fd1498Szrj unaligned_store,
177*38fd1498Szrj vector_store,
178*38fd1498Szrj vector_scatter_store,
179*38fd1498Szrj vec_to_scalar,
180*38fd1498Szrj scalar_to_vec,
181*38fd1498Szrj cond_branch_not_taken,
182*38fd1498Szrj cond_branch_taken,
183*38fd1498Szrj vec_perm,
184*38fd1498Szrj vec_promote_demote,
185*38fd1498Szrj vec_construct
186*38fd1498Szrj };
187*38fd1498Szrj
188*38fd1498Szrj /* Separate locations for which the vectorizer cost model should
189*38fd1498Szrj track costs. */
190*38fd1498Szrj enum vect_cost_model_location {
191*38fd1498Szrj vect_prologue = 0,
192*38fd1498Szrj vect_body = 1,
193*38fd1498Szrj vect_epilogue = 2
194*38fd1498Szrj };
195*38fd1498Szrj
196*38fd1498Szrj class vec_perm_indices;
197*38fd1498Szrj
198*38fd1498Szrj /* The type to use for lists of vector sizes. */
199*38fd1498Szrj typedef vec<poly_uint64> vector_sizes;
200*38fd1498Szrj
201*38fd1498Szrj /* Same, but can be used to construct local lists that are
202*38fd1498Szrj automatically freed. */
203*38fd1498Szrj typedef auto_vec<poly_uint64, 8> auto_vector_sizes;
204*38fd1498Szrj
205*38fd1498Szrj /* The target structure. This holds all the backend hooks. */
206*38fd1498Szrj #define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
207*38fd1498Szrj #define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
208*38fd1498Szrj #define DEFHOOK_UNDOC DEFHOOK
209*38fd1498Szrj #define HOOKSTRUCT(FRAGMENT) FRAGMENT
210*38fd1498Szrj
211*38fd1498Szrj #include "target.def"
212*38fd1498Szrj
213*38fd1498Szrj extern struct gcc_target targetm;
214*38fd1498Szrj
215*38fd1498Szrj /* Return an estimate of the runtime value of X, for use in things
216*38fd1498Szrj like cost calculations or profiling frequencies. Note that this
217*38fd1498Szrj function should never be used in situations where the actual
218*38fd1498Szrj runtime value is needed for correctness, since the function only
219*38fd1498Szrj provides a rough guess. */
220*38fd1498Szrj
221*38fd1498Szrj static inline HOST_WIDE_INT
estimated_poly_value(poly_int64 x)222*38fd1498Szrj estimated_poly_value (poly_int64 x)
223*38fd1498Szrj {
224*38fd1498Szrj if (NUM_POLY_INT_COEFFS == 1)
225*38fd1498Szrj return x.coeffs[0];
226*38fd1498Szrj else
227*38fd1498Szrj return targetm.estimated_poly_value (x);
228*38fd1498Szrj }
229*38fd1498Szrj
230*38fd1498Szrj #ifdef GCC_TM_H
231*38fd1498Szrj
232*38fd1498Szrj #ifndef CUMULATIVE_ARGS_MAGIC
233*38fd1498Szrj #define CUMULATIVE_ARGS_MAGIC ((void *) &targetm.calls)
234*38fd1498Szrj #endif
235*38fd1498Szrj
236*38fd1498Szrj static inline CUMULATIVE_ARGS *
get_cumulative_args(cumulative_args_t arg)237*38fd1498Szrj get_cumulative_args (cumulative_args_t arg)
238*38fd1498Szrj {
239*38fd1498Szrj #if CHECKING_P
240*38fd1498Szrj gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
241*38fd1498Szrj #endif /* CHECKING_P */
242*38fd1498Szrj return (CUMULATIVE_ARGS *) arg.p;
243*38fd1498Szrj }
244*38fd1498Szrj
245*38fd1498Szrj static inline cumulative_args_t
pack_cumulative_args(CUMULATIVE_ARGS * arg)246*38fd1498Szrj pack_cumulative_args (CUMULATIVE_ARGS *arg)
247*38fd1498Szrj {
248*38fd1498Szrj cumulative_args_t ret;
249*38fd1498Szrj
250*38fd1498Szrj #if CHECKING_P
251*38fd1498Szrj ret.magic = CUMULATIVE_ARGS_MAGIC;
252*38fd1498Szrj #endif /* CHECKING_P */
253*38fd1498Szrj ret.p = (void *) arg;
254*38fd1498Szrj return ret;
255*38fd1498Szrj }
256*38fd1498Szrj #endif /* GCC_TM_H */
257*38fd1498Szrj
258*38fd1498Szrj #endif /* GCC_TARGET_H */
259