]>
Commit | Line | Data |
---|---|---|
672a6f42 | 1 | /* Data structure definitions for a generic GCC target. |
c7ec5472 MK |
2 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 |
3 | Free Software Foundation, Inc. | |
672a6f42 NB |
4 | |
5 | This program is free software; you can redistribute it and/or modify it | |
6 | under the terms of the GNU General Public License as published by the | |
7 | Free Software Foundation; either version 2, or (at your option) any | |
8 | later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
366ccddb | 17 | Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
672a6f42 NB |
18 | |
19 | In other words, you are welcome to use, share and improve this program. | |
20 | You are forbidden to forbid anyone else to use, share and improve | |
21 | what you give them. Help stamp out software-hoarding! */ | |
22 | ||
23 | /* This file contains a data structure that describes a GCC target. | |
17b53c33 | 24 | At present it is incomplete, but in future it should grow to |
672a6f42 NB |
25 | contain most or all target machine and target O/S specific |
26 | information. | |
27 | ||
28 | This structure has its initializer declared in target-def.h in the | |
29 | form of large macro TARGET_INITIALIZER that expands to many smaller | |
30 | macros. | |
31 | ||
32 | The smaller macros each initialize one component of the structure, | |
33 | and each has a default. Each target should have a file that | |
34 | includes target.h and target-def.h, and overrides any inappropriate | |
35 | defaults by undefining the relevant macro and defining a suitable | |
36 | replacement. That file should then contain the definition of | |
f6897b10 | 37 | "targetm" like so: |
672a6f42 | 38 | |
f6897b10 | 39 | struct gcc_target targetm = TARGET_INITIALIZER; |
672a6f42 NB |
40 | |
41 | Doing things this way allows us to bring together everything that | |
17b53c33 NB |
42 | defines a GCC target. By supplying a default that is appropriate |
43 | to most targets, we can easily add new items without needing to | |
44 | edit dozens of target configuration files. It should also allow us | |
45 | to gradually reduce the amount of conditional compilation that is | |
46 | scattered throughout GCC. */ | |
672a6f42 | 47 | |
59587b18 JQ |
48 | #ifndef GCC_TARGET_H |
49 | #define GCC_TARGET_H | |
50 | ||
7bb1ad93 | 51 | #include "tm.h" |
59587b18 | 52 | #include "insn-modes.h" |
7bb1ad93 | 53 | |
9d30f3c1 | 54 | struct stdarg_info; |
496d7bb0 | 55 | struct spec_info_def; |
9d30f3c1 | 56 | |
8a99f6f9 R |
57 | /* The struct used by the secondary_reload target hook. */ |
58 | typedef struct secondary_reload_info | |
59 | { | |
60 | /* icode is actually an enum insn_code, but we don't want to force every | |
61 | file that includes target.h to include optabs.h . */ | |
62 | int icode; | |
63 | int extra_cost; /* Cost for using (a) scratch register(s) to be taken | |
64 | into account by copy_cost. */ | |
65 | /* The next two members are for the use of the backward | |
66 | compatibility hook. */ | |
67 | struct secondary_reload_info *prev_sri; | |
68 | int t_icode; /* Actually an enum insn_code - see above. */ | |
69 | } secondary_reload_info; | |
70 | ||
71 | ||
672a6f42 NB |
72 | struct gcc_target |
73 | { | |
08c148a8 NB |
74 | /* Functions that output assembler for the target. */ |
75 | struct asm_out | |
76 | { | |
17b53c33 NB |
77 | /* Opening and closing parentheses for asm expression grouping. */ |
78 | const char *open_paren, *close_paren; | |
79 | ||
301d03af RS |
80 | /* Assembler instructions for creating various kinds of integer object. */ |
81 | const char *byte_op; | |
82 | struct asm_int_op | |
83 | { | |
84 | const char *hi; | |
85 | const char *si; | |
86 | const char *di; | |
87 | const char *ti; | |
88 | } aligned_op, unaligned_op; | |
89 | ||
90 | /* Try to output the assembler code for an integer object whose | |
91 | value is given by X. SIZE is the size of the object in bytes and | |
92 | ALIGNED_P indicates whether it is aligned. Return true if | |
93 | successful. Only handles cases for which BYTE_OP, ALIGNED_OP | |
94 | and UNALIGNED_OP are NULL. */ | |
46c5ad27 | 95 | bool (* integer) (rtx x, unsigned int size, int aligned_p); |
301d03af | 96 | |
5eb99654 | 97 | /* Output code that will globalize a label. */ |
46c5ad27 | 98 | void (* globalize_label) (FILE *, const char *); |
5eb99654 | 99 | |
4746cf84 MA |
100 | /* Output code that will emit a label for unwind info, if this |
101 | target requires such labels. Second argument is the decl the | |
eeab4d81 MS |
102 | unwind info is associated with, third is a boolean: true if |
103 | this is for exception handling, fourth is a boolean: true if | |
9cf737f8 | 104 | this is only a placeholder for an omitted FDE. */ |
eeab4d81 | 105 | void (* unwind_label) (FILE *, tree, int, int); |
4746cf84 | 106 | |
083cad55 EC |
107 | /* Output code that will emit a label to divide up the exception |
108 | table. */ | |
109 | void (* except_table_label) (FILE *); | |
110 | ||
951120ea PB |
111 | /* Emit any directives required to unwind this instruction. */ |
112 | void (* unwind_emit) (FILE *, rtx); | |
113 | ||
4977bab6 | 114 | /* Output an internal label. */ |
46c5ad27 | 115 | void (* internal_label) (FILE *, const char *, unsigned long); |
4977bab6 | 116 | |
617a1b71 PB |
117 | /* Emit a ttype table reference to a typeinfo object. */ |
118 | bool (* ttype) (rtx); | |
119 | ||
93638d7a AM |
120 | /* Emit an assembler directive to set visibility for the symbol |
121 | associated with the tree decl. */ | |
46c5ad27 | 122 | void (* visibility) (tree, int); |
93638d7a | 123 | |
08c148a8 | 124 | /* Output the assembler code for entry to a function. */ |
46c5ad27 | 125 | void (* function_prologue) (FILE *, HOST_WIDE_INT); |
08c148a8 | 126 | |
b4c25db2 | 127 | /* Output the assembler code for end of prologue. */ |
46c5ad27 | 128 | void (* function_end_prologue) (FILE *); |
b4c25db2 NB |
129 | |
130 | /* Output the assembler code for start of epilogue. */ | |
46c5ad27 | 131 | void (* function_begin_epilogue) (FILE *); |
b4c25db2 | 132 | |
08c148a8 | 133 | /* Output the assembler code for function exit. */ |
46c5ad27 | 134 | void (* function_epilogue) (FILE *, HOST_WIDE_INT); |
7c262518 | 135 | |
d6b5193b RS |
136 | /* Initialize target-specific sections. */ |
137 | void (* init_sections) (void); | |
138 | ||
c18a5b6c MM |
139 | /* Tell assembler to change to section NAME with attributes FLAGS. |
140 | If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with | |
141 | which this section is associated. */ | |
142 | void (* named_section) (const char *name, unsigned int flags, tree decl); | |
2cc07db4 | 143 | |
d6b5193b RS |
144 | /* Return a section for EXP. It may be a DECL or a constant. RELOC |
145 | is nonzero if runtime relocations must be applied; bit 1 will be | |
146 | set if the runtime relocations require non-local name resolution. | |
147 | ALIGN is the required alignment of the data. */ | |
148 | section *(* select_section) (tree, int, unsigned HOST_WIDE_INT); | |
ae46c4e0 | 149 | |
d6b5193b RS |
150 | /* Return a section for X. MODE is X's mode and ALIGN is its |
151 | alignment in bits. */ | |
152 | section *(* select_rtx_section) (enum machine_mode, rtx, | |
153 | unsigned HOST_WIDE_INT); | |
b64a1b53 | 154 | |
ae46c4e0 RH |
155 | /* Select a unique section name for DECL. RELOC is the same as |
156 | for SELECT_SECTION. */ | |
46c5ad27 | 157 | void (* unique_section) (tree, int); |
ae46c4e0 | 158 | |
d6b5193b RS |
159 | /* Return the readonly data section associated with function DECL. */ |
160 | section *(* function_rodata_section) (tree); | |
ab5c8549 | 161 | |
2cc07db4 | 162 | /* Output a constructor for a symbol with a given priority. */ |
46c5ad27 | 163 | void (* constructor) (rtx, int); |
2cc07db4 RH |
164 | |
165 | /* Output a destructor for a symbol with a given priority. */ | |
46c5ad27 | 166 | void (* destructor) (rtx, int); |
483ab821 | 167 | |
3961e8fe RH |
168 | /* Output the assembler code for a thunk function. THUNK_DECL is the |
169 | declaration for the thunk function itself, FUNCTION is the decl for | |
170 | the target function. DELTA is an immediate constant offset to be | |
476c5eb6 | 171 | added to THIS. If VCALL_OFFSET is nonzero, the word at |
3961e8fe | 172 | *(*this + vcall_offset) should be added to THIS. */ |
46c5ad27 AJ |
173 | void (* output_mi_thunk) (FILE *file, tree thunk_decl, |
174 | HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, | |
175 | tree function_decl); | |
3961e8fe RH |
176 | |
177 | /* Determine whether output_mi_thunk would succeed. */ | |
178 | /* ??? Ideally, this hook would not exist, and success or failure | |
179 | would be returned from output_mi_thunk directly. But there's | |
180 | too much undo-able setup involved in invoking output_mi_thunk. | |
181 | Could be fixed by making output_mi_thunk emit rtl instead of | |
182 | text to the output file. */ | |
46c5ad27 AJ |
183 | bool (* can_output_mi_thunk) (tree thunk_decl, HOST_WIDE_INT delta, |
184 | HOST_WIDE_INT vcall_offset, | |
185 | tree function_decl); | |
a5fe455b | 186 | |
1bc7c5b6 ZW |
187 | /* Output any boilerplate text needed at the beginning of a |
188 | translation unit. */ | |
46c5ad27 | 189 | void (*file_start) (void); |
1bc7c5b6 ZW |
190 | |
191 | /* Output any boilerplate text needed at the end of a | |
192 | translation unit. */ | |
46c5ad27 | 193 | void (*file_end) (void); |
6773a41c RO |
194 | |
195 | /* Output an assembler pseudo-op to declare a library function name | |
196 | external. */ | |
197 | void (*external_libcall) (rtx); | |
8e3e233b DP |
198 | |
199 | /* Output an assembler directive to mark decl live. This instructs | |
200 | linker to not dead code strip this symbol. */ | |
201 | void (*mark_decl_preserved) (const char *); | |
202 | ||
aacd3885 RS |
203 | /* Output the definition of a section anchor. */ |
204 | void (*output_anchor) (rtx); | |
205 | ||
fdbe66f2 EB |
206 | /* Output a DTP-relative reference to a TLS symbol. */ |
207 | void (*output_dwarf_dtprel) (FILE *file, int size, rtx x); | |
208 | ||
08c148a8 NB |
209 | } asm_out; |
210 | ||
c237e94a ZW |
211 | /* Functions relating to instruction scheduling. */ |
212 | struct sched | |
213 | { | |
214 | /* Given the current cost, COST, of an insn, INSN, calculate and | |
215 | return a new cost based on its relationship to DEP_INSN through | |
216 | the dependence LINK. The default is to make no adjustment. */ | |
46c5ad27 | 217 | int (* adjust_cost) (rtx insn, rtx link, rtx def_insn, int cost); |
c237e94a ZW |
218 | |
219 | /* Adjust the priority of an insn as you see fit. Returns the new | |
220 | priority. */ | |
46c5ad27 | 221 | int (* adjust_priority) (rtx, int); |
c237e94a ZW |
222 | |
223 | /* Function which returns the maximum number of insns that can be | |
224 | scheduled in the same machine cycle. This must be constant | |
225 | over an entire compilation. The default is 1. */ | |
46c5ad27 | 226 | int (* issue_rate) (void); |
c237e94a ZW |
227 | |
228 | /* Calculate how much this insn affects how many more insns we | |
229 | can emit this cycle. Default is they all cost the same. */ | |
46c5ad27 | 230 | int (* variable_issue) (FILE *, int, rtx, int); |
41077ce4 | 231 | |
c237e94a | 232 | /* Initialize machine-dependent scheduling code. */ |
46c5ad27 | 233 | void (* md_init) (FILE *, int, int); |
c237e94a ZW |
234 | |
235 | /* Finalize machine-dependent scheduling code. */ | |
46c5ad27 | 236 | void (* md_finish) (FILE *, int); |
c237e94a | 237 | |
58565a33 SKG |
238 | /* Initialize machine-dependent function while scheduling code. */ |
239 | void (* md_init_global) (FILE *, int, int); | |
240 | ||
241 | /* Finalize machine-dependent function wide scheduling code. */ | |
242 | void (* md_finish_global) (FILE *, int); | |
243 | ||
c237e94a ZW |
244 | /* Reorder insns in a machine-dependent fashion, in two different |
245 | places. Default does nothing. */ | |
46c5ad27 AJ |
246 | int (* reorder) (FILE *, int, rtx *, int *, int); |
247 | int (* reorder2) (FILE *, int, rtx *, int *, int); | |
c237e94a | 248 | |
30028c85 VM |
249 | /* The following member value is a pointer to a function called |
250 | after evaluation forward dependencies of insns in chain given | |
251 | by two parameter values (head and tail correspondingly). */ | |
46c5ad27 | 252 | void (* dependencies_evaluation_hook) (rtx, rtx); |
30028c85 | 253 | |
fae15c93 VM |
254 | /* The values of the following four members are pointers to |
255 | functions used to simplify the automaton descriptions. | |
256 | dfa_pre_cycle_insn and dfa_post_cycle_insn give functions | |
257 | returning insns which are used to change the pipeline hazard | |
258 | recognizer state when the new simulated processor cycle | |
259 | correspondingly starts and finishes. The function defined by | |
260 | init_dfa_pre_cycle_insn and init_dfa_post_cycle_insn are used | |
261 | to initialize the corresponding insns. The default values of | |
d91edf86 | 262 | the members result in not changing the automaton state when |
fae15c93 VM |
263 | the new simulated processor cycle correspondingly starts and |
264 | finishes. */ | |
46c5ad27 AJ |
265 | void (* init_dfa_pre_cycle_insn) (void); |
266 | rtx (* dfa_pre_cycle_insn) (void); | |
267 | void (* init_dfa_post_cycle_insn) (void); | |
268 | rtx (* dfa_post_cycle_insn) (void); | |
fa0aee89 | 269 | |
fae15c93 VM |
270 | /* The following member value is a pointer to a function returning value |
271 | which defines how many insns in queue `ready' will we try for | |
5ad6fca5 | 272 | multi-pass scheduling. If the member value is nonzero and the |
fae15c93 VM |
273 | function returns positive value, the DFA based scheduler will make |
274 | multi-pass scheduling for the first cycle. In other words, we will | |
275 | try to choose ready insn which permits to start maximum number of | |
276 | insns on the same cycle. */ | |
46c5ad27 | 277 | int (* first_cycle_multipass_dfa_lookahead) (void); |
fa0aee89 | 278 | |
30028c85 VM |
279 | /* The following member value is pointer to a function controlling |
280 | what insns from the ready insn queue will be considered for the | |
281 | multipass insn scheduling. If the hook returns zero for insn | |
282 | passed as the parameter, the insn will be not chosen to be | |
283 | issued. */ | |
46c5ad27 | 284 | int (* first_cycle_multipass_dfa_lookahead_guard) (rtx); |
fa0aee89 | 285 | |
30028c85 VM |
286 | /* The following member value is pointer to a function called by |
287 | the insn scheduler before issuing insn passed as the third | |
288 | parameter on given cycle. If the hook returns nonzero, the | |
289 | insn is not issued on given processors cycle. Instead of that, | |
290 | the processor cycle is advanced. If the value passed through | |
291 | the last parameter is zero, the insn ready queue is not sorted | |
292 | on the new cycle start as usually. The first parameter passes | |
293 | file for debugging output. The second one passes the scheduler | |
294 | verbose level of the debugging output. The forth and the fifth | |
295 | parameter values are correspondingly processor cycle on which | |
296 | the previous insn has been issued and the current processor | |
297 | cycle. */ | |
46c5ad27 | 298 | int (* dfa_new_cycle) (FILE *, int, rtx, int, int, int *); |
fa0aee89 | 299 | |
569fa502 DN |
300 | /* The following member value is a pointer to a function called |
301 | by the insn scheduler. It should return true if there exists a | |
f676971a EC |
302 | dependence which is considered costly by the target, between |
303 | the insn passed as the first parameter, and the insn passed as | |
304 | the second parameter. The third parameter is the INSN_DEPEND | |
569fa502 DN |
305 | link that represents the dependence between the two insns. The |
306 | fourth argument is the cost of the dependence as estimated by | |
f676971a | 307 | the scheduler. The last argument is the distance in cycles |
569fa502 | 308 | between the already scheduled insn (first parameter) and the |
80fcc7bc SB |
309 | the second insn (second parameter). */ |
310 | bool (* is_costly_dependence) (rtx, rtx, rtx, int, int); | |
496d7bb0 MK |
311 | |
312 | /* Given the current cost, COST, of an insn, INSN, calculate and | |
313 | return a new cost based on its relationship to DEP_INSN through the | |
314 | dependence of type DEP_TYPE. The default is to make no adjustment. */ | |
315 | int (* adjust_cost_2) (rtx insn, int, rtx def_insn, int cost); | |
316 | ||
317 | /* The following member value is a pointer to a function called | |
318 | by the insn scheduler. This hook is called to notify the backend | |
319 | that new instructions were emitted. */ | |
320 | void (* h_i_d_extended) (void); | |
321 | ||
322 | /* The following member value is a pointer to a function called | |
323 | by the insn scheduler. | |
324 | The first parameter is an instruction, the second parameter is the type | |
325 | of the requested speculation, and the third parameter is a pointer to the | |
326 | speculative pattern of the corresponding type (set if return value == 1). | |
327 | It should return | |
328 | -1, if there is no pattern, that will satisfy the requested speculation | |
329 | type, | |
330 | 0, if current pattern satisfies the requested speculation type, | |
331 | 1, if pattern of the instruction should be changed to the newly | |
332 | generated one. */ | |
c7ec5472 | 333 | int (* speculate_insn) (rtx, int, rtx *); |
496d7bb0 MK |
334 | |
335 | /* The following member value is a pointer to a function called | |
336 | by the insn scheduler. It should return true if the check instruction | |
337 | corresponding to the instruction passed as the parameter needs a | |
338 | recovery block. */ | |
339 | bool (* needs_block_p) (rtx); | |
340 | ||
341 | /* The following member value is a pointer to a function called | |
342 | by the insn scheduler. It should return a pattern for the check | |
343 | instruction. | |
344 | The first parameter is a speculative instruction, the second parameter | |
345 | is the label of the corresponding recovery block (or null, if it is a | |
346 | simple check). If the mutation of the check is requested (e.g. from | |
347 | ld.c to chk.a), the third parameter is true - in this case the first | |
348 | parameter is the previous check. */ | |
349 | rtx (* gen_check) (rtx, rtx, bool); | |
350 | ||
351 | /* The following member value is a pointer to a function controlling | |
352 | what insns from the ready insn queue will be considered for the | |
353 | multipass insn scheduling. If the hook returns zero for the insn | |
354 | passed as the parameter, the insn will not be chosen to be | |
355 | issued. This hook is used to discard speculative instructions, | |
356 | that stand at the first position of the ready list. */ | |
357 | bool (* first_cycle_multipass_dfa_lookahead_guard_spec) (rtx); | |
358 | ||
359 | /* The following member value is a pointer to a function that provides | |
360 | information about the speculation capabilities of the target. | |
361 | The parameter is a pointer to spec_info variable. */ | |
362 | void (* set_sched_flags) (struct spec_info_def *); | |
c237e94a ZW |
363 | } sched; |
364 | ||
7ccf35ed DN |
365 | /* Functions relating to vectorization. */ |
366 | struct vectorize | |
367 | { | |
d16b59fa | 368 | /* The following member value is a pointer to a function called |
7ccf35ed DN |
369 | by the vectorizer, and return the decl of the target builtin |
370 | function. */ | |
371 | tree (* builtin_mask_for_load) (void); | |
7ccf35ed DN |
372 | } vectorize; |
373 | ||
75685792 RS |
374 | /* The initial value of target_flags. */ |
375 | int default_target_flags; | |
376 | ||
377 | /* Handle target switch CODE (an OPT_* value). ARG is the argument | |
378 | passed to the switch; it is NULL if no argument was. VALUE is the | |
379 | value of ARG if CODE specifies a UInteger option, otherwise it is | |
380 | 1 if the positive form of the switch was used and 0 if the negative | |
381 | form was. Return true if the switch was valid. */ | |
382 | bool (* handle_option) (size_t code, const char *arg, int value); | |
383 | ||
8c27b7d4 | 384 | /* Return machine mode for filter value. */ |
93f90be6 FJ |
385 | enum machine_mode (* eh_return_filter_mode) (void); |
386 | ||
672a6f42 | 387 | /* Given two decls, merge their attributes and return the result. */ |
46c5ad27 | 388 | tree (* merge_decl_attributes) (tree, tree); |
672a6f42 NB |
389 | |
390 | /* Given two types, merge their attributes and return the result. */ | |
46c5ad27 | 391 | tree (* merge_type_attributes) (tree, tree); |
672a6f42 | 392 | |
349ae713 NB |
393 | /* Table of machine attributes and functions to handle them. |
394 | Ignored if NULL. */ | |
91d231cb | 395 | const struct attribute_spec *attribute_table; |
8d8e52be JM |
396 | |
397 | /* Return zero if the attributes on TYPE1 and TYPE2 are incompatible, | |
398 | one if they are compatible and two if they are nearly compatible | |
399 | (which causes a warning to be generated). */ | |
46c5ad27 | 400 | int (* comp_type_attributes) (tree type1, tree type2); |
8d8e52be JM |
401 | |
402 | /* Assign default attributes to the newly defined TYPE. */ | |
46c5ad27 | 403 | void (* set_default_type_attributes) (tree type); |
12a68f1f JM |
404 | |
405 | /* Insert attributes on the newly created DECL. */ | |
46c5ad27 | 406 | void (* insert_attributes) (tree decl, tree *attributes); |
f6155fda | 407 | |
91d231cb JM |
408 | /* Return true if FNDECL (which has at least one machine attribute) |
409 | can be inlined despite its machine attributes, false otherwise. */ | |
46c5ad27 | 410 | bool (* function_attribute_inlinable_p) (tree fndecl); |
91d231cb | 411 | |
f913c102 AO |
412 | /* Return true if bitfields in RECORD_TYPE should follow the |
413 | Microsoft Visual C++ bitfield layout rules. */ | |
46c5ad27 | 414 | bool (* ms_bitfield_layout_p) (tree record_type); |
f913c102 | 415 | |
9a8ce21f JG |
416 | /* True if the target supports decimal floating point. */ |
417 | bool (* decimal_float_supported_p) (void); | |
418 | ||
13c1cd82 PB |
419 | /* Return true if anonymous bitfields affect structure alignment. */ |
420 | bool (* align_anon_bitfield) (void); | |
421 | ||
c2a64439 PB |
422 | /* Return true if volatile bitfields should use the narrowest type possible. |
423 | Return false if they should use the container type. */ | |
424 | bool (* narrow_volatile_bitfield) (void); | |
425 | ||
f6155fda | 426 | /* Set up target-specific built-in functions. */ |
46c5ad27 | 427 | void (* init_builtins) (void); |
f6155fda SS |
428 | |
429 | /* Expand a target-specific builtin. */ | |
46c5ad27 AJ |
430 | rtx (* expand_builtin) (tree exp, rtx target, rtx subtarget, |
431 | enum machine_mode mode, int ignore); | |
7c262518 | 432 | |
ee963181 RG |
433 | /* Expand a target-specific library builtin. */ |
434 | rtx (* expand_library_builtin) (tree exp, rtx target, rtx subtarget, | |
435 | enum machine_mode mode, int ignore); | |
436 | ||
58646b77 PB |
437 | /* Select a replacement for a target-specific builtin. This is done |
438 | *before* regular type checking, and so allows the target to implement | |
439 | a crude form of function overloading. The result is a complete | |
440 | expression that implements the operation. */ | |
441 | tree (*resolve_overloaded_builtin) (tree decl, tree params); | |
442 | ||
c2dda19b | 443 | /* Fold a target-specific builtin. */ |
a05a80fc | 444 | tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore); |
083cad55 | 445 | |
f18eca82 ZL |
446 | /* For a vendor-specific fundamental TYPE, return a pointer to |
447 | a statically-allocated string containing the C++ mangling for | |
448 | TYPE. In all other cases, return NULL. */ | |
449 | const char * (* mangle_fundamental_type) (tree type); | |
450 | ||
c15c90bb ZW |
451 | /* Make any adjustments to libfunc names needed for this target. */ |
452 | void (* init_libfuncs) (void); | |
453 | ||
7c262518 RH |
454 | /* Given a decl, a section name, and whether the decl initializer |
455 | has relocs, choose attributes for the section. */ | |
456 | /* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */ | |
46c5ad27 | 457 | unsigned int (* section_type_flags) (tree, const char *, int); |
7c262518 | 458 | |
e4ec2cac AO |
459 | /* True if new jumps cannot be created, to replace existing ones or |
460 | not, at the current point in the compilation. */ | |
46c5ad27 | 461 | bool (* cannot_modify_jumps_p) (void); |
ae46c4e0 | 462 | |
a3424f5c RH |
463 | /* Return a register class for which branch target register |
464 | optimizations should be applied. */ | |
46c5ad27 | 465 | int (* branch_target_register_class) (void); |
a3424f5c RH |
466 | |
467 | /* Return true if branch target register optimizations should include | |
468 | callee-saved registers that are not already live during the current | |
469 | function. AFTER_PE_GEN is true if prologues and epilogues have | |
470 | already been generated. */ | |
46c5ad27 | 471 | bool (* branch_target_register_callee_saved) (bool after_pe_gen); |
fe3ad572 | 472 | |
3a04ff64 | 473 | /* True if the constant X cannot be placed in the constant pool. */ |
46c5ad27 | 474 | bool (* cannot_force_const_mem) (rtx); |
3a04ff64 | 475 | |
0b077eac | 476 | /* True if the insn X cannot be duplicated. */ |
46c5ad27 | 477 | bool (* cannot_copy_insn_p) (rtx); |
0b077eac | 478 | |
8ddf681a R |
479 | /* True if X is considered to be commutative. */ |
480 | bool (* commutative_p) (rtx, int); | |
481 | ||
7daebb7a | 482 | /* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */ |
46c5ad27 | 483 | rtx (* delegitimize_address) (rtx); |
7daebb7a | 484 | |
aacd3885 RS |
485 | /* True if the given constant can be put into an object_block. */ |
486 | bool (* use_blocks_for_constant_p) (enum machine_mode, rtx); | |
487 | ||
488 | /* The minimum and maximum byte offsets for anchored addresses. */ | |
489 | HOST_WIDE_INT min_anchor_offset; | |
490 | HOST_WIDE_INT max_anchor_offset; | |
491 | ||
492 | /* True if section anchors can be used to access the given symbol. */ | |
493 | bool (* use_anchors_for_symbol_p) (rtx); | |
494 | ||
4977bab6 ZW |
495 | /* True if it is OK to do sibling call optimization for the specified |
496 | call expression EXP. DECL will be the called function, or NULL if | |
497 | this is an indirect call. */ | |
46c5ad27 AJ |
498 | bool (*function_ok_for_sibcall) (tree decl, tree exp); |
499 | ||
ae46c4e0 | 500 | /* True if EXP should be placed in a "small data" section. */ |
46c5ad27 | 501 | bool (* in_small_data_p) (tree); |
fb49053f | 502 | |
47754fd5 RH |
503 | /* True if EXP names an object for which name resolution must resolve |
504 | to the current module. */ | |
46c5ad27 | 505 | bool (* binds_local_p) (tree); |
47754fd5 | 506 | |
fb49053f RH |
507 | /* Do something target-specific to record properties of the DECL into |
508 | the associated SYMBOL_REF. */ | |
46c5ad27 | 509 | void (* encode_section_info) (tree, rtx, int); |
772c5265 RH |
510 | |
511 | /* Undo the effects of encode_section_info on the symbol string. */ | |
46c5ad27 | 512 | const char * (* strip_name_encoding) (const char *); |
47754fd5 | 513 | |
273a2526 RS |
514 | /* If shift optabs for MODE are known to always truncate the shift count, |
515 | return the mask that they apply. Return 0 otherwise. */ | |
516 | unsigned HOST_WIDE_INT (* shift_truncation_mask) (enum machine_mode mode); | |
517 | ||
bc23502b PB |
518 | /* Return the number of divisions in the given MODE that should be present, |
519 | so that it is profitable to turn the division into a multiplication by | |
520 | the reciprocal. */ | |
521 | unsigned int (* min_divisions_for_recip_mul) (enum machine_mode mode); | |
522 | ||
b12cbf2c AN |
523 | /* If the representation of integral MODE is such that values are |
524 | always sign-extended to a wider mode MODE_REP then return | |
525 | SIGN_EXTEND. Return UNKNOWN otherwise. */ | |
526 | /* Note that the return type ought to be RTX_CODE, but that's not | |
527 | necessarily defined at this point. */ | |
528 | int (* mode_rep_extended) (enum machine_mode mode, | |
529 | enum machine_mode mode_rep); | |
530 | ||
3c50106f | 531 | /* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */ |
46c5ad27 | 532 | bool (* valid_pointer_mode) (enum machine_mode mode); |
3c50106f | 533 | |
6dd53648 RH |
534 | /* True if MODE is valid for the target. By "valid", we mean able to |
535 | be manipulated in non-trivial ways. In particular, this means all | |
536 | the arithmetic is supported. */ | |
537 | bool (* scalar_mode_supported_p) (enum machine_mode mode); | |
538 | ||
539 | /* Similarly for vector modes. "Supported" here is less strict. At | |
540 | least some operations are supported; need to check optabs or builtins | |
541 | for further details. */ | |
f676971a EC |
542 | bool (* vector_mode_supported_p) (enum machine_mode mode); |
543 | ||
c8e4f0e9 | 544 | /* True if a vector is opaque. */ |
46c5ad27 | 545 | bool (* vector_opaque_p) (tree); |
62e1dfcf | 546 | |
3c50106f RH |
547 | /* Compute a (partial) cost for rtx X. Return true if the complete |
548 | cost has been computed, and false if subexpressions should be | |
549 | scanned. In either case, *TOTAL contains the cost result. */ | |
550 | /* Note that CODE and OUTER_CODE ought to be RTX_CODE, but that's | |
551 | not necessarily defined at this point. */ | |
46c5ad27 | 552 | bool (* rtx_costs) (rtx x, int code, int outer_code, int *total); |
3c50106f | 553 | |
dcefdf67 RH |
554 | /* Compute the cost of X, used as an address. Never called with |
555 | invalid addresses. */ | |
46c5ad27 | 556 | int (* address_cost) (rtx x); |
dcefdf67 | 557 | |
b48f503c KK |
558 | /* Return where to allocate pseudo for a given hard register initial |
559 | value. */ | |
560 | rtx (* allocate_initial_value) (rtx x); | |
561 | ||
96714395 AH |
562 | /* Given a register, this hook should return a parallel of registers |
563 | to represent where to find the register pieces. Define this hook | |
564 | if the register and its mode are represented in Dwarf in | |
565 | non-contiguous locations, or if the register should be | |
566 | represented in more than one register in Dwarf. Otherwise, this | |
567 | hook should return NULL_RTX. */ | |
46c5ad27 | 568 | rtx (* dwarf_register_span) (rtx); |
96714395 | 569 | |
e129d93a ILT |
570 | /* Fetch the fixed register(s) which hold condition codes, for |
571 | targets where it makes sense to look for duplicate assignments to | |
572 | the condition codes. This should return true if there is such a | |
573 | register, false otherwise. The arguments should be set to the | |
574 | fixed register numbers. Up to two condition code registers are | |
575 | supported. If there is only one for this target, the int pointed | |
576 | at by the second argument should be set to -1. */ | |
577 | bool (* fixed_condition_code_regs) (unsigned int *, unsigned int *); | |
578 | ||
579 | /* If two condition code modes are compatible, return a condition | |
580 | code mode which is compatible with both, such that a comparison | |
581 | done in the returned mode will work for both of the original | |
582 | modes. If the condition code modes are not compatible, return | |
583 | VOIDmode. */ | |
584 | enum machine_mode (* cc_modes_compatible) (enum machine_mode, | |
585 | enum machine_mode); | |
586 | ||
18dbd950 RS |
587 | /* Do machine-dependent code transformations. Called just before |
588 | delayed-branch scheduling. */ | |
46c5ad27 | 589 | void (* machine_dependent_reorg) (void); |
18dbd950 | 590 | |
c35d187f RH |
591 | /* Create the __builtin_va_list type. */ |
592 | tree (* build_builtin_va_list) (void); | |
593 | ||
cdc3ddb8 RH |
594 | /* Gimplifies a VA_ARG_EXPR. */ |
595 | tree (* gimplify_va_arg_expr) (tree valist, tree type, tree *pre_p, | |
596 | tree *post_p); | |
597 | ||
7bb1ad93 GK |
598 | /* Validity-checking routines for PCH files, target-specific. |
599 | get_pch_validity returns a pointer to the data to be stored, | |
600 | and stores the size in its argument. pch_valid_p gets the same | |
601 | information back and returns NULL if the PCH is valid, | |
602 | or an error message if not. | |
603 | */ | |
604 | void * (* get_pch_validity) (size_t *); | |
605 | const char * (* pch_valid_p) (const void *, size_t); | |
606 | ||
8d932be3 RS |
607 | /* If nonnull, this function checks whether a PCH file with the |
608 | given set of target flags can be used. It returns NULL if so, | |
609 | otherwise it returns an error message. */ | |
610 | const char *(*check_pch_target_flags) (int); | |
611 | ||
a841ab8b | 612 | /* True if the compiler should give an enum type only as many |
221ee7c9 KH |
613 | bytes as it takes to represent the range of possible values of |
614 | that type. */ | |
615 | bool (* default_short_enums) (void); | |
616 | ||
d6da68b9 | 617 | /* This target hook returns an rtx that is used to store the address |
a841ab8b | 618 | of the current frame into the built-in setjmp buffer. */ |
d6da68b9 KH |
619 | rtx (* builtin_setjmp_frame_value) (void); |
620 | ||
67dfe110 | 621 | /* This target hook should add STRING_CST trees for any hard regs |
61158923 HPN |
622 | the port wishes to automatically clobber for an asm. */ |
623 | tree (* md_asm_clobbers) (tree, tree, tree); | |
67dfe110 | 624 | |
a1c496cb EC |
625 | /* This target hook allows the backend to specify a calling convention |
626 | in the debug information. This function actually returns an | |
627 | enum dwarf_calling_convention, but because of forward declarations | |
628 | and not wanting to include dwarf2.h everywhere target.h is included | |
629 | the function is being declared as an int. */ | |
630 | int (* dwarf_calling_convention) (tree); | |
631 | ||
e54c7471 EB |
632 | /* This target hook allows the backend to emit frame-related insns that |
633 | contain UNSPECs or UNSPEC_VOLATILEs. The call frame debugging info | |
634 | engine will invoke it on insns of the form | |
635 | (set (reg) (unspec [...] UNSPEC_INDEX)) | |
636 | and | |
637 | (set (reg) (unspec_volatile [...] UNSPECV_INDEX)) | |
638 | to let the backend emit the call frame instructions. */ | |
639 | void (* dwarf_handle_frame_unspec) (const char *, rtx, int); | |
640 | ||
9d30f3c1 JJ |
641 | /* Perform architecture specific checking of statements gimplified |
642 | from VA_ARG_EXPR. LHS is left hand side of MODIFY_EXPR, RHS | |
643 | is right hand side. Returns true if the statements doesn't need | |
644 | to be checked for va_list references. */ | |
7d69de61 RH |
645 | bool (* stdarg_optimize_hook) (struct stdarg_info *ai, tree lhs, tree rhs); |
646 | ||
647 | /* This target hook allows the operating system to override the DECL | |
648 | that represents the external variable that contains the stack | |
649 | protection guard variable. The type of this DECL is ptr_type_node. */ | |
650 | tree (* stack_protect_guard) (void); | |
651 | ||
652 | /* This target hook allows the operating system to override the CALL_EXPR | |
653 | that is invoked when a check vs the guard variable fails. */ | |
654 | tree (* stack_protect_fail) (void); | |
9d30f3c1 | 655 | |
e7e64a25 AS |
656 | /* Returns NULL if target supports the insn within a doloop block, |
657 | otherwise it returns an error message. */ | |
658 | const char * (*invalid_within_doloop) (rtx); | |
43d9ad1d DS |
659 | |
660 | /* DECL is a variable or function with __attribute__((dllimport)) | |
661 | specified. Use this hook if the target needs to add extra validation | |
662 | checks to handle_dll_attribute (). */ | |
663 | bool (* valid_dllimport_attribute_p) (tree decl); | |
083cad55 | 664 | |
42ba5130 RH |
665 | /* Functions relating to calls - argument passing, returns, etc. */ |
666 | struct calls { | |
667 | bool (*promote_function_args) (tree fntype); | |
668 | bool (*promote_function_return) (tree fntype); | |
669 | bool (*promote_prototypes) (tree fntype); | |
670 | rtx (*struct_value_rtx) (tree fndecl, int incoming); | |
671 | bool (*return_in_memory) (tree type, tree fndecl); | |
672 | bool (*return_in_msb) (tree type); | |
8cd5a4e0 RH |
673 | |
674 | /* Return true if a parameter must be passed by reference. TYPE may | |
675 | be null if this is a libcall. CA may be null if this query is | |
676 | from __builtin_va_arg. */ | |
677 | bool (*pass_by_reference) (CUMULATIVE_ARGS *ca, enum machine_mode mode, | |
678 | tree type, bool named_arg); | |
679 | ||
42ba5130 RH |
680 | rtx (*expand_builtin_saveregs) (void); |
681 | /* Returns pretend_argument_size. */ | |
682 | void (*setup_incoming_varargs) (CUMULATIVE_ARGS *ca, enum machine_mode mode, | |
683 | tree type, int *pretend_arg_size, | |
684 | int second_time); | |
685 | bool (*strict_argument_naming) (CUMULATIVE_ARGS *ca); | |
686 | /* Returns true if we should use | |
687 | targetm.calls.setup_incoming_varargs() and/or | |
688 | targetm.calls.strict_argument_naming(). */ | |
689 | bool (*pretend_outgoing_varargs_named) (CUMULATIVE_ARGS *ca); | |
690 | ||
691 | /* Given a complex type T, return true if a parameter of type T | |
692 | should be passed as two scalars. */ | |
693 | bool (* split_complex_arg) (tree type); | |
fe984136 RH |
694 | |
695 | /* Return true if type T, mode MODE, may not be passed in registers, | |
696 | but must be passed on the stack. */ | |
697 | /* ??? This predicate should be applied strictly after pass-by-reference. | |
698 | Need audit to verify that this is the case. */ | |
699 | bool (* must_pass_in_stack) (enum machine_mode mode, tree t); | |
6cdd5672 RH |
700 | |
701 | /* Return true if type TYPE, mode MODE, which is passed by reference, | |
702 | should have the object copy generated by the callee rather than | |
703 | the caller. It is never called for TYPE requiring constructors. */ | |
704 | bool (* callee_copies) (CUMULATIVE_ARGS *ca, enum machine_mode mode, | |
705 | tree type, bool named); | |
78a52f11 RH |
706 | |
707 | /* Return zero for arguments passed entirely on the stack or entirely | |
708 | in registers. If passed in both, return the number of bytes passed | |
709 | in registers; the balance is therefore passed on the stack. */ | |
710 | int (* arg_partial_bytes) (CUMULATIVE_ARGS *ca, enum machine_mode mode, | |
711 | tree type, bool named); | |
4d3e6fae FJ |
712 | |
713 | /* Return the diagnostic message string if function without a prototype | |
714 | is not allowed for this 'val' argument; NULL otherwise. */ | |
083cad55 | 715 | const char *(*invalid_arg_for_unprototyped_fn) (tree typelist, |
4d3e6fae | 716 | tree funcdecl, tree val); |
1d636cc6 RG |
717 | |
718 | /* Return an rtx for the return value location of the function | |
719 | specified by FN_DECL_OR_TYPE with a return type of RET_TYPE. */ | |
720 | rtx (*function_value) (tree ret_type, tree fn_decl_or_type, | |
721 | bool outgoing); | |
150cdc9e RH |
722 | |
723 | /* Return an rtx for the argument pointer incoming to the | |
724 | current function. */ | |
725 | rtx (*internal_arg_pointer) (void); | |
42ba5130 RH |
726 | } calls; |
727 | ||
4de67c26 JM |
728 | /* Return the diagnostic message string if conversion from FROMTYPE |
729 | to TOTYPE is not allowed, NULL otherwise. */ | |
730 | const char *(*invalid_conversion) (tree fromtype, tree totype); | |
731 | ||
732 | /* Return the diagnostic message string if the unary operation OP is | |
733 | not permitted on TYPE, NULL otherwise. */ | |
734 | const char *(*invalid_unary_op) (int op, tree type); | |
735 | ||
736 | /* Return the diagnostic message string if the binary operation OP | |
737 | is not permitted on TYPE1 and TYPE2, NULL otherwise. */ | |
738 | const char *(*invalid_binary_op) (int op, tree type1, tree type2); | |
739 | ||
8a99f6f9 R |
740 | /* Return the class for a secondary reload, and fill in extra information. */ |
741 | enum reg_class (*secondary_reload) (bool, rtx, enum reg_class, | |
742 | enum machine_mode, | |
743 | struct secondary_reload_info *); | |
744 | ||
4185ae53 PB |
745 | /* Functions specific to the C++ frontend. */ |
746 | struct cxx { | |
747 | /* Return the integer type used for guard variables. */ | |
748 | tree (*guard_type) (void); | |
749 | /* Return true if only the low bit of the guard should be tested. */ | |
750 | bool (*guard_mask_bit) (void); | |
46e995e0 PB |
751 | /* Returns the size of the array cookie for an array of type. */ |
752 | tree (*get_cookie_size) (tree); | |
753 | /* Returns true if the element size should be stored in the | |
754 | array cookie. */ | |
755 | bool (*cookie_has_size) (void); | |
d59c7b4b NC |
756 | /* Allows backends to perform additional processing when |
757 | deciding if a class should be exported or imported. */ | |
758 | int (*import_export_class) (tree, int); | |
44d10c10 PB |
759 | /* Returns true if constructors and destructors return "this". */ |
760 | bool (*cdtor_returns_this) (void); | |
af287697 MM |
761 | /* Returns true if the key method for a class can be an inline |
762 | function, so long as it is not declared inline in the class | |
763 | itself. Returning true is the behavior required by the Itanium | |
764 | C++ ABI. */ | |
765 | bool (*key_method_may_be_inline) (void); | |
1e731102 MM |
766 | /* DECL is a virtual table, virtual table table, typeinfo object, |
767 | or other similar implicit class data object that will be | |
768 | emitted with external linkage in this translation unit. No ELF | |
769 | visibility has been explicitly specified. If the target needs | |
770 | to specify a visibility other than that of the containing class, | |
771 | use this hook to set DECL_VISIBILITY and | |
083cad55 | 772 | DECL_VISIBILITY_SPECIFIED. */ |
1e731102 MM |
773 | void (*determine_class_data_visibility) (tree decl); |
774 | /* Returns true (the default) if virtual tables and other | |
775 | similar implicit class data objects are always COMDAT if they | |
776 | have external linkage. If this hook returns false, then | |
777 | class data for classes whose virtual table will be emitted in | |
778 | only one translation unit will not be COMDAT. */ | |
779 | bool (*class_data_always_comdat) (void); | |
9f62c3e3 PB |
780 | /* Returns true if __aeabi_atexit should be used to register static |
781 | destructors. */ | |
782 | bool (*use_aeabi_atexit) (void); | |
43d9ad1d DS |
783 | /* TYPE is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that |
784 | has just been defined. Use this hook to make adjustments to the | |
785 | class (eg, tweak visibility or perform any other required | |
083cad55 | 786 | target modifications). */ |
43d9ad1d | 787 | void (*adjust_class_at_definition) (tree type); |
4185ae53 | 788 | } cxx; |
912f2dac DB |
789 | |
790 | /* For targets that need to mark extra registers as live on entry to | |
791 | the function, they should define this target hook and set their | |
792 | bits in the bitmap passed in. */ | |
793 | void (*live_on_entry) (bitmap); | |
4185ae53 | 794 | |
617a1b71 PB |
795 | /* True if unwinding tables should be generated by default. */ |
796 | bool unwind_tables_default; | |
797 | ||
47754fd5 RH |
798 | /* Leave the boolean fields at the end. */ |
799 | ||
800 | /* True if arbitrary sections are supported. */ | |
801 | bool have_named_sections; | |
802 | ||
434aeebb RS |
803 | /* True if we can create zeroed data by switching to a BSS section |
804 | and then using ASM_OUTPUT_SKIP to allocate the space. */ | |
805 | bool have_switchable_bss_sections; | |
806 | ||
47754fd5 RH |
807 | /* True if "native" constructors and destructors are supported, |
808 | false if we're using collect2 for the job. */ | |
809 | bool have_ctors_dtors; | |
3d78f2e9 RH |
810 | |
811 | /* True if thread-local storage is supported. */ | |
812 | bool have_tls; | |
275b6d80 DE |
813 | |
814 | /* True if a small readonly data section is supported. */ | |
815 | bool have_srodata_section; | |
7606e68f SS |
816 | |
817 | /* True if EH frame info sections should be zero-terminated. */ | |
818 | bool terminate_dw2_eh_frame_info; | |
1bc7c5b6 ZW |
819 | |
820 | /* True if #NO_APP should be emitted at the beginning of | |
821 | assembly output. */ | |
822 | bool file_start_app_off; | |
823 | ||
824 | /* True if output_file_directive should be called for main_input_filename | |
825 | at the beginning of assembly output. */ | |
826 | bool file_start_file_directive; | |
61f71b34 | 827 | |
84b8b0e0 ZW |
828 | /* True if #pragma redefine_extname is to be supported. */ |
829 | bool handle_pragma_redefine_extname; | |
830 | ||
831 | /* True if #pragma extern_prefix is to be supported. */ | |
832 | bool handle_pragma_extern_prefix; | |
833 | ||
445cf5eb JM |
834 | /* True if the target is allowed to reorder memory accesses unless |
835 | synchronization is explicitly requested. */ | |
836 | bool relaxed_ordering; | |
837 | ||
617a1b71 PB |
838 | /* Returns true if we should generate exception tables for use with the |
839 | ARM EABI. The effects the encoding of function exception specifications. | |
840 | */ | |
841 | bool arm_eabi_unwinder; | |
842 | ||
42ba5130 | 843 | /* Leave the boolean fields at the end. */ |
672a6f42 NB |
844 | }; |
845 | ||
f6897b10 | 846 | extern struct gcc_target targetm; |
59587b18 JQ |
847 | |
848 | #endif /* GCC_TARGET_H */ |