1*e4b17023SJohn Marino /* Data structure definitions for a generic GCC target.
2*e4b17023SJohn Marino Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3*e4b17023SJohn Marino 2011, 2012
4*e4b17023SJohn Marino Free Software Foundation, Inc.
5*e4b17023SJohn Marino
6*e4b17023SJohn Marino This program is free software; you can redistribute it and/or modify it
7*e4b17023SJohn Marino under the terms of the GNU General Public License as published by the
8*e4b17023SJohn Marino Free Software Foundation; either version 3, or (at your option) any
9*e4b17023SJohn Marino later version.
10*e4b17023SJohn Marino
11*e4b17023SJohn Marino This program is distributed in the hope that it will be useful,
12*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
13*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*e4b17023SJohn Marino GNU General Public License for more details.
15*e4b17023SJohn Marino
16*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
17*e4b17023SJohn Marino along with this program; see the file COPYING3. If not see
18*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.
19*e4b17023SJohn Marino
20*e4b17023SJohn Marino In other words, you are welcome to use, share and improve this program.
21*e4b17023SJohn Marino You are forbidden to forbid anyone else to use, share and improve
22*e4b17023SJohn Marino what you give them. Help stamp out software-hoarding! */
23*e4b17023SJohn Marino
24*e4b17023SJohn Marino
25*e4b17023SJohn Marino /* This file contains a data structure that describes a GCC target.
26*e4b17023SJohn Marino At present it is incomplete, but in future it should grow to
27*e4b17023SJohn Marino contain most or all target machine and target O/S specific
28*e4b17023SJohn Marino information.
29*e4b17023SJohn Marino
30*e4b17023SJohn Marino This structure has its initializer declared in target-def.h in the
31*e4b17023SJohn Marino form of large macro TARGET_INITIALIZER that expands to many smaller
32*e4b17023SJohn Marino macros.
33*e4b17023SJohn Marino
34*e4b17023SJohn Marino The smaller macros each initialize one component of the structure,
35*e4b17023SJohn Marino and each has a default. Each target should have a file that
36*e4b17023SJohn Marino includes target.h and target-def.h, and overrides any inappropriate
37*e4b17023SJohn Marino defaults by undefining the relevant macro and defining a suitable
38*e4b17023SJohn Marino replacement. That file should then contain the definition of
39*e4b17023SJohn Marino "targetm" like so:
40*e4b17023SJohn Marino
41*e4b17023SJohn Marino struct gcc_target targetm = TARGET_INITIALIZER;
42*e4b17023SJohn Marino
43*e4b17023SJohn Marino Doing things this way allows us to bring together everything that
44*e4b17023SJohn Marino defines a GCC target. By supplying a default that is appropriate
45*e4b17023SJohn Marino to most targets, we can easily add new items without needing to
46*e4b17023SJohn Marino edit dozens of target configuration files. It should also allow us
47*e4b17023SJohn Marino to gradually reduce the amount of conditional compilation that is
48*e4b17023SJohn Marino scattered throughout GCC. */
49*e4b17023SJohn Marino
50*e4b17023SJohn Marino #ifndef GCC_TARGET_H
51*e4b17023SJohn Marino #define GCC_TARGET_H
52*e4b17023SJohn Marino
53*e4b17023SJohn Marino #include "insn-modes.h"
54*e4b17023SJohn Marino
55*e4b17023SJohn Marino #ifdef ENABLE_CHECKING
56*e4b17023SJohn Marino
57*e4b17023SJohn Marino typedef struct { void *magic; void *p; } cumulative_args_t;
58*e4b17023SJohn Marino
59*e4b17023SJohn Marino #else /* !ENABLE_CHECKING */
60*e4b17023SJohn Marino
61*e4b17023SJohn Marino /* When using a GCC build compiler, we could use
62*e4b17023SJohn Marino __attribute__((transparent_union)) to get cumulative_args_t function
63*e4b17023SJohn Marino arguments passed like scalars where the ABI would mandate a less
64*e4b17023SJohn Marino efficient way of argument passing otherwise. However, that would come
65*e4b17023SJohn Marino at the cost of less type-safe !ENABLE_CHECKING compilation. */
66*e4b17023SJohn Marino
67*e4b17023SJohn Marino typedef union { void *p; } cumulative_args_t;
68*e4b17023SJohn Marino
69*e4b17023SJohn Marino #endif /* !ENABLE_CHECKING */
70*e4b17023SJohn Marino
71*e4b17023SJohn Marino /* Types used by the record_gcc_switches() target function. */
72*e4b17023SJohn Marino typedef enum
73*e4b17023SJohn Marino {
74*e4b17023SJohn Marino SWITCH_TYPE_PASSED, /* A switch passed on the command line. */
75*e4b17023SJohn Marino SWITCH_TYPE_ENABLED, /* An option that is currently enabled. */
76*e4b17023SJohn Marino SWITCH_TYPE_DESCRIPTIVE, /* Descriptive text, not a switch or option. */
77*e4b17023SJohn Marino SWITCH_TYPE_LINE_START, /* Please emit any necessary text at the start of a line. */
78*e4b17023SJohn Marino SWITCH_TYPE_LINE_END /* Please emit a line terminator. */
79*e4b17023SJohn Marino }
80*e4b17023SJohn Marino print_switch_type;
81*e4b17023SJohn Marino
82*e4b17023SJohn Marino typedef int (* print_switch_fn_type) (print_switch_type, const char *);
83*e4b17023SJohn Marino
84*e4b17023SJohn Marino /* An example implementation for ELF targets. Defined in varasm.c */
85*e4b17023SJohn Marino extern int elf_record_gcc_switches (print_switch_type type, const char *);
86*e4b17023SJohn Marino
87*e4b17023SJohn Marino /* Some places still assume that all pointer or address modes are the
88*e4b17023SJohn Marino standard Pmode and ptr_mode. These optimizations become invalid if
89*e4b17023SJohn Marino the target actually supports multiple different modes. For now,
90*e4b17023SJohn Marino we disable such optimizations on such targets, using this function. */
91*e4b17023SJohn Marino extern bool target_default_pointer_address_modes_p (void);
92*e4b17023SJohn Marino
93*e4b17023SJohn Marino struct stdarg_info;
94*e4b17023SJohn Marino struct spec_info_def;
95*e4b17023SJohn Marino struct hard_reg_set_container;
96*e4b17023SJohn Marino
97*e4b17023SJohn Marino /* The struct used by the secondary_reload target hook. */
98*e4b17023SJohn Marino typedef struct secondary_reload_info
99*e4b17023SJohn Marino {
100*e4b17023SJohn Marino /* icode is actually an enum insn_code, but we don't want to force every
101*e4b17023SJohn Marino file that includes target.h to include optabs.h . */
102*e4b17023SJohn Marino int icode;
103*e4b17023SJohn Marino int extra_cost; /* Cost for using (a) scratch register(s) to be taken
104*e4b17023SJohn Marino into account by copy_cost. */
105*e4b17023SJohn Marino /* The next two members are for the use of the backward
106*e4b17023SJohn Marino compatibility hook. */
107*e4b17023SJohn Marino struct secondary_reload_info *prev_sri;
108*e4b17023SJohn Marino int t_icode; /* Actually an enum insn_code - see above. */
109*e4b17023SJohn Marino } secondary_reload_info;
110*e4b17023SJohn Marino
111*e4b17023SJohn Marino /* This is defined in sched-int.h . */
112*e4b17023SJohn Marino struct _dep;
113*e4b17023SJohn Marino
114*e4b17023SJohn Marino /* This is defined in ddg.h . */
115*e4b17023SJohn Marino struct ddg;
116*e4b17023SJohn Marino
117*e4b17023SJohn Marino /* This is defined in cfgloop.h . */
118*e4b17023SJohn Marino struct loop;
119*e4b17023SJohn Marino
120*e4b17023SJohn Marino /* This is defined in tree-ssa-alias.h. */
121*e4b17023SJohn Marino struct ao_ref_s;
122*e4b17023SJohn Marino
123*e4b17023SJohn Marino /* Assembler instructions for creating various kinds of integer object. */
124*e4b17023SJohn Marino
125*e4b17023SJohn Marino struct asm_int_op
126*e4b17023SJohn Marino {
127*e4b17023SJohn Marino const char *hi;
128*e4b17023SJohn Marino const char *si;
129*e4b17023SJohn Marino const char *di;
130*e4b17023SJohn Marino const char *ti;
131*e4b17023SJohn Marino };
132*e4b17023SJohn Marino
133*e4b17023SJohn Marino /* Types of costs for vectorizer cost model. */
134*e4b17023SJohn Marino enum vect_cost_for_stmt
135*e4b17023SJohn Marino {
136*e4b17023SJohn Marino scalar_stmt,
137*e4b17023SJohn Marino scalar_load,
138*e4b17023SJohn Marino scalar_store,
139*e4b17023SJohn Marino vector_stmt,
140*e4b17023SJohn Marino vector_load,
141*e4b17023SJohn Marino unaligned_load,
142*e4b17023SJohn Marino unaligned_store,
143*e4b17023SJohn Marino vector_store,
144*e4b17023SJohn Marino vec_to_scalar,
145*e4b17023SJohn Marino scalar_to_vec,
146*e4b17023SJohn Marino cond_branch_not_taken,
147*e4b17023SJohn Marino cond_branch_taken,
148*e4b17023SJohn Marino vec_perm,
149*e4b17023SJohn Marino vec_promote_demote
150*e4b17023SJohn Marino };
151*e4b17023SJohn Marino
152*e4b17023SJohn Marino /* The target structure. This holds all the backend hooks. */
153*e4b17023SJohn Marino #define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
154*e4b17023SJohn Marino #define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
155*e4b17023SJohn Marino #define DEFHOOK_UNDOC DEFHOOK
156*e4b17023SJohn Marino #define HOOKSTRUCT(FRAGMENT) FRAGMENT
157*e4b17023SJohn Marino
158*e4b17023SJohn Marino #include "target.def"
159*e4b17023SJohn Marino
160*e4b17023SJohn Marino extern struct gcc_target targetm;
161*e4b17023SJohn Marino
162*e4b17023SJohn Marino #ifdef GCC_TM_H
163*e4b17023SJohn Marino
164*e4b17023SJohn Marino #ifndef CUMULATIVE_ARGS_MAGIC
165*e4b17023SJohn Marino #define CUMULATIVE_ARGS_MAGIC ((void *) &targetm.calls)
166*e4b17023SJohn Marino #endif
167*e4b17023SJohn Marino
168*e4b17023SJohn Marino static inline CUMULATIVE_ARGS *
get_cumulative_args(cumulative_args_t arg)169*e4b17023SJohn Marino get_cumulative_args (cumulative_args_t arg)
170*e4b17023SJohn Marino {
171*e4b17023SJohn Marino #ifdef ENABLE_CHECKING
172*e4b17023SJohn Marino gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
173*e4b17023SJohn Marino #endif /* ENABLE_CHECKING */
174*e4b17023SJohn Marino return (CUMULATIVE_ARGS *) arg.p;
175*e4b17023SJohn Marino }
176*e4b17023SJohn Marino
177*e4b17023SJohn Marino static inline cumulative_args_t
pack_cumulative_args(CUMULATIVE_ARGS * arg)178*e4b17023SJohn Marino pack_cumulative_args (CUMULATIVE_ARGS *arg)
179*e4b17023SJohn Marino {
180*e4b17023SJohn Marino cumulative_args_t ret;
181*e4b17023SJohn Marino
182*e4b17023SJohn Marino #ifdef ENABLE_CHECKING
183*e4b17023SJohn Marino ret.magic = CUMULATIVE_ARGS_MAGIC;
184*e4b17023SJohn Marino #endif /* ENABLE_CHECKING */
185*e4b17023SJohn Marino ret.p = (void *) arg;
186*e4b17023SJohn Marino return ret;
187*e4b17023SJohn Marino }
188*e4b17023SJohn Marino #endif /* GCC_TM_H */
189*e4b17023SJohn Marino
190*e4b17023SJohn Marino #endif /* GCC_TARGET_H */
191