190075Sobrien/* Data structure definitions for a generic GCC target. 2169689Skan Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 3169689Skan Free Software Foundation, Inc. 490075Sobrien 590075SobrienThis program is free software; you can redistribute it and/or modify it 690075Sobrienunder the terms of the GNU General Public License as published by the 790075SobrienFree Software Foundation; either version 2, or (at your option) any 890075Sobrienlater version. 990075Sobrien 1090075SobrienThis program is distributed in the hope that it will be useful, 1190075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1290075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390075SobrienGNU General Public License for more details. 1490075Sobrien 1590075SobrienYou should have received a copy of the GNU General Public License 1690075Sobrienalong with this program; if not, write to the Free Software 17169689SkanFoundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 1890075Sobrien 1990075Sobrien In other words, you are welcome to use, share and improve this program. 2090075Sobrien You are forbidden to forbid anyone else to use, share and improve 2190075Sobrien what you give them. Help stamp out software-hoarding! */ 2290075Sobrien 2390075Sobrien/* This file contains a data structure that describes a GCC target. 2490075Sobrien At present it is incomplete, but in future it should grow to 2590075Sobrien contain most or all target machine and target O/S specific 2690075Sobrien information. 2790075Sobrien 2890075Sobrien This structure has its initializer declared in target-def.h in the 2990075Sobrien form of large macro TARGET_INITIALIZER that expands to many smaller 3090075Sobrien macros. 3190075Sobrien 3290075Sobrien The smaller macros each initialize one component of the structure, 3390075Sobrien and each has a default. Each target should have a file that 3490075Sobrien includes target.h and target-def.h, and overrides any inappropriate 3590075Sobrien defaults by undefining the relevant macro and defining a suitable 3690075Sobrien replacement. That file should then contain the definition of 3790075Sobrien "targetm" like so: 3890075Sobrien 3990075Sobrien struct gcc_target targetm = TARGET_INITIALIZER; 4090075Sobrien 4190075Sobrien Doing things this way allows us to bring together everything that 4290075Sobrien defines a GCC target. By supplying a default that is appropriate 4390075Sobrien to most targets, we can easily add new items without needing to 4490075Sobrien edit dozens of target configuration files. It should also allow us 4590075Sobrien to gradually reduce the amount of conditional compilation that is 4690075Sobrien scattered throughout GCC. */ 4790075Sobrien 48169689Skan#ifndef GCC_TARGET_H 49169689Skan#define GCC_TARGET_H 50169689Skan 51132718Skan#include "tm.h" 52169689Skan#include "insn-modes.h" 53132718Skan 54169689Skanstruct stdarg_info; 55169689Skanstruct spec_info_def; 56169689Skan 57169689Skan/* The struct used by the secondary_reload target hook. */ 58169689Skantypedef struct secondary_reload_info 59169689Skan{ 60169689Skan /* icode is actually an enum insn_code, but we don't want to force every 61169689Skan file that includes target.h to include optabs.h . */ 62169689Skan int icode; 63169689Skan int extra_cost; /* Cost for using (a) scratch register(s) to be taken 64169689Skan into account by copy_cost. */ 65169689Skan /* The next two members are for the use of the backward 66169689Skan compatibility hook. */ 67169689Skan struct secondary_reload_info *prev_sri; 68169689Skan int t_icode; /* Actually an enum insn_code - see above. */ 69169689Skan} secondary_reload_info; 70169689Skan 71169689Skan 7290075Sobrienstruct gcc_target 7390075Sobrien{ 7490075Sobrien /* Functions that output assembler for the target. */ 7590075Sobrien struct asm_out 7690075Sobrien { 7790075Sobrien /* Opening and closing parentheses for asm expression grouping. */ 7890075Sobrien const char *open_paren, *close_paren; 7990075Sobrien 8090075Sobrien /* Assembler instructions for creating various kinds of integer object. */ 8190075Sobrien const char *byte_op; 8290075Sobrien struct asm_int_op 8390075Sobrien { 8490075Sobrien const char *hi; 8590075Sobrien const char *si; 8690075Sobrien const char *di; 8790075Sobrien const char *ti; 8890075Sobrien } aligned_op, unaligned_op; 8990075Sobrien 9090075Sobrien /* Try to output the assembler code for an integer object whose 9190075Sobrien value is given by X. SIZE is the size of the object in bytes and 9290075Sobrien ALIGNED_P indicates whether it is aligned. Return true if 9390075Sobrien successful. Only handles cases for which BYTE_OP, ALIGNED_OP 9490075Sobrien and UNALIGNED_OP are NULL. */ 95132718Skan bool (* integer) (rtx x, unsigned int size, int aligned_p); 9690075Sobrien 97117395Skan /* Output code that will globalize a label. */ 98132718Skan void (* globalize_label) (FILE *, const char *); 99117395Skan 100169689Skan /* Output code that will emit a label for unwind info, if this 101169689Skan target requires such labels. Second argument is the decl the 102169689Skan unwind info is associated with, third is a boolean: true if 103169689Skan this is for exception handling, fourth is a boolean: true if 104169689Skan this is only a placeholder for an omitted FDE. */ 105169689Skan void (* unwind_label) (FILE *, tree, int, int); 106169689Skan 107169689Skan /* Output code that will emit a label to divide up the exception 108169689Skan table. */ 109169689Skan void (* except_table_label) (FILE *); 110169689Skan 111169689Skan /* Emit any directives required to unwind this instruction. */ 112169689Skan void (* unwind_emit) (FILE *, rtx); 113169689Skan 114132718Skan /* Output an internal label. */ 115132718Skan void (* internal_label) (FILE *, const char *, unsigned long); 116132718Skan 117169689Skan /* Emit a ttype table reference to a typeinfo object. */ 118169689Skan bool (* ttype) (rtx); 119169689Skan 120117395Skan /* Emit an assembler directive to set visibility for the symbol 121117395Skan associated with the tree decl. */ 122132718Skan void (* visibility) (tree, int); 123117395Skan 12490075Sobrien /* Output the assembler code for entry to a function. */ 125132718Skan void (* function_prologue) (FILE *, HOST_WIDE_INT); 12690075Sobrien 12790075Sobrien /* Output the assembler code for end of prologue. */ 128132718Skan void (* function_end_prologue) (FILE *); 12990075Sobrien 13090075Sobrien /* Output the assembler code for start of epilogue. */ 131132718Skan void (* function_begin_epilogue) (FILE *); 13290075Sobrien 13390075Sobrien /* Output the assembler code for function exit. */ 134132718Skan void (* function_epilogue) (FILE *, HOST_WIDE_INT); 13590075Sobrien 136169689Skan /* Initialize target-specific sections. */ 137169689Skan void (* init_sections) (void); 13890075Sobrien 139169689Skan /* Tell assembler to change to section NAME with attributes FLAGS. 140169689Skan If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with 141169689Skan which this section is associated. */ 142169689Skan void (* named_section) (const char *name, unsigned int flags, tree decl); 14390075Sobrien 144169689Skan /* Return a mask describing how relocations should be treated when 145169689Skan selecting sections. Bit 1 should be set if global relocations 146169689Skan should be placed in a read-write section; bit 0 should be set if 147169689Skan local relocations should be placed in a read-write section. */ 148169689Skan int (*reloc_rw_mask) (void); 14990075Sobrien 150169689Skan /* Return a section for EXP. It may be a DECL or a constant. RELOC 151169689Skan is nonzero if runtime relocations must be applied; bit 1 will be 152169689Skan set if the runtime relocations require non-local name resolution. 153169689Skan ALIGN is the required alignment of the data. */ 154169689Skan section *(* select_section) (tree, int, unsigned HOST_WIDE_INT); 155117395Skan 156169689Skan /* Return a section for X. MODE is X's mode and ALIGN is its 157169689Skan alignment in bits. */ 158169689Skan section *(* select_rtx_section) (enum machine_mode, rtx, 159169689Skan unsigned HOST_WIDE_INT); 160117395Skan 161117395Skan /* Select a unique section name for DECL. RELOC is the same as 162117395Skan for SELECT_SECTION. */ 163132718Skan void (* unique_section) (tree, int); 164117395Skan 165169689Skan /* Return the readonly data section associated with function DECL. */ 166169689Skan section *(* function_rodata_section) (tree); 167169689Skan 16890075Sobrien /* Output a constructor for a symbol with a given priority. */ 169132718Skan void (* constructor) (rtx, int); 17090075Sobrien 17190075Sobrien /* Output a destructor for a symbol with a given priority. */ 172132718Skan void (* destructor) (rtx, int); 173117395Skan 174117395Skan /* Output the assembler code for a thunk function. THUNK_DECL is the 175117395Skan declaration for the thunk function itself, FUNCTION is the decl for 176117395Skan the target function. DELTA is an immediate constant offset to be 177117395Skan added to THIS. If VCALL_OFFSET is nonzero, the word at 178117395Skan *(*this + vcall_offset) should be added to THIS. */ 179132718Skan void (* output_mi_thunk) (FILE *file, tree thunk_decl, 180132718Skan HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, 181132718Skan tree function_decl); 182117395Skan 183117395Skan /* Determine whether output_mi_thunk would succeed. */ 184117395Skan /* ??? Ideally, this hook would not exist, and success or failure 185117395Skan would be returned from output_mi_thunk directly. But there's 186117395Skan too much undo-able setup involved in invoking output_mi_thunk. 187117395Skan Could be fixed by making output_mi_thunk emit rtl instead of 188117395Skan text to the output file. */ 189132718Skan bool (* can_output_mi_thunk) (tree thunk_decl, HOST_WIDE_INT delta, 190132718Skan HOST_WIDE_INT vcall_offset, 191132718Skan tree function_decl); 192132718Skan 193132718Skan /* Output any boilerplate text needed at the beginning of a 194132718Skan translation unit. */ 195132718Skan void (*file_start) (void); 196132718Skan 197132718Skan /* Output any boilerplate text needed at the end of a 198132718Skan translation unit. */ 199132718Skan void (*file_end) (void); 200132718Skan 201132718Skan /* Output an assembler pseudo-op to declare a library function name 202132718Skan external. */ 203132718Skan void (*external_libcall) (rtx); 204169689Skan 205169689Skan /* Output an assembler directive to mark decl live. This instructs 206169689Skan linker to not dead code strip this symbol. */ 207169689Skan void (*mark_decl_preserved) (const char *); 208169689Skan 209169689Skan /* Output the definition of a section anchor. */ 210169689Skan void (*output_anchor) (rtx); 211169689Skan 212169689Skan /* Output a DTP-relative reference to a TLS symbol. */ 213169689Skan void (*output_dwarf_dtprel) (FILE *file, int size, rtx x); 214169689Skan 21590075Sobrien } asm_out; 21690075Sobrien 21790075Sobrien /* Functions relating to instruction scheduling. */ 21890075Sobrien struct sched 21990075Sobrien { 22090075Sobrien /* Given the current cost, COST, of an insn, INSN, calculate and 22190075Sobrien return a new cost based on its relationship to DEP_INSN through 22290075Sobrien the dependence LINK. The default is to make no adjustment. */ 223132718Skan int (* adjust_cost) (rtx insn, rtx link, rtx def_insn, int cost); 22490075Sobrien 22590075Sobrien /* Adjust the priority of an insn as you see fit. Returns the new 22690075Sobrien priority. */ 227132718Skan int (* adjust_priority) (rtx, int); 22890075Sobrien 22990075Sobrien /* Function which returns the maximum number of insns that can be 23090075Sobrien scheduled in the same machine cycle. This must be constant 23190075Sobrien over an entire compilation. The default is 1. */ 232132718Skan int (* issue_rate) (void); 23390075Sobrien 23490075Sobrien /* Calculate how much this insn affects how many more insns we 23590075Sobrien can emit this cycle. Default is they all cost the same. */ 236132718Skan int (* variable_issue) (FILE *, int, rtx, int); 237117395Skan 23890075Sobrien /* Initialize machine-dependent scheduling code. */ 239132718Skan void (* md_init) (FILE *, int, int); 24090075Sobrien 24190075Sobrien /* Finalize machine-dependent scheduling code. */ 242132718Skan void (* md_finish) (FILE *, int); 24390075Sobrien 244169689Skan /* Initialize machine-dependent function while scheduling code. */ 245169689Skan void (* md_init_global) (FILE *, int, int); 246169689Skan 247169689Skan /* Finalize machine-dependent function wide scheduling code. */ 248169689Skan void (* md_finish_global) (FILE *, int); 249169689Skan 25090075Sobrien /* Reorder insns in a machine-dependent fashion, in two different 25190075Sobrien places. Default does nothing. */ 252132718Skan int (* reorder) (FILE *, int, rtx *, int *, int); 253132718Skan int (* reorder2) (FILE *, int, rtx *, int *, int); 25490075Sobrien 255132718Skan /* The following member value is a pointer to a function called 256132718Skan after evaluation forward dependencies of insns in chain given 257132718Skan by two parameter values (head and tail correspondingly). */ 258132718Skan void (* dependencies_evaluation_hook) (rtx, rtx); 259132718Skan 260117395Skan /* The values of the following four members are pointers to 261117395Skan functions used to simplify the automaton descriptions. 262117395Skan dfa_pre_cycle_insn and dfa_post_cycle_insn give functions 263117395Skan returning insns which are used to change the pipeline hazard 264117395Skan recognizer state when the new simulated processor cycle 265117395Skan correspondingly starts and finishes. The function defined by 266117395Skan init_dfa_pre_cycle_insn and init_dfa_post_cycle_insn are used 267117395Skan to initialize the corresponding insns. The default values of 268132718Skan the members result in not changing the automaton state when 269117395Skan the new simulated processor cycle correspondingly starts and 270117395Skan finishes. */ 271132718Skan void (* init_dfa_pre_cycle_insn) (void); 272132718Skan rtx (* dfa_pre_cycle_insn) (void); 273132718Skan void (* init_dfa_post_cycle_insn) (void); 274132718Skan rtx (* dfa_post_cycle_insn) (void); 275169689Skan 276117395Skan /* The following member value is a pointer to a function returning value 277117395Skan which defines how many insns in queue `ready' will we try for 278169689Skan multi-pass scheduling. If the member value is nonzero and the 279117395Skan function returns positive value, the DFA based scheduler will make 280117395Skan multi-pass scheduling for the first cycle. In other words, we will 281117395Skan try to choose ready insn which permits to start maximum number of 282117395Skan insns on the same cycle. */ 283132718Skan int (* first_cycle_multipass_dfa_lookahead) (void); 284169689Skan 285132718Skan /* The following member value is pointer to a function controlling 286132718Skan what insns from the ready insn queue will be considered for the 287132718Skan multipass insn scheduling. If the hook returns zero for insn 288132718Skan passed as the parameter, the insn will be not chosen to be 289132718Skan issued. */ 290132718Skan int (* first_cycle_multipass_dfa_lookahead_guard) (rtx); 291169689Skan 292132718Skan /* The following member value is pointer to a function called by 293132718Skan the insn scheduler before issuing insn passed as the third 294132718Skan parameter on given cycle. If the hook returns nonzero, the 295132718Skan insn is not issued on given processors cycle. Instead of that, 296132718Skan the processor cycle is advanced. If the value passed through 297132718Skan the last parameter is zero, the insn ready queue is not sorted 298132718Skan on the new cycle start as usually. The first parameter passes 299132718Skan file for debugging output. The second one passes the scheduler 300132718Skan verbose level of the debugging output. The forth and the fifth 301132718Skan parameter values are correspondingly processor cycle on which 302132718Skan the previous insn has been issued and the current processor 303132718Skan cycle. */ 304132718Skan int (* dfa_new_cycle) (FILE *, int, rtx, int, int, int *); 305169689Skan 306132718Skan /* The following member value is a pointer to a function called 307132718Skan by the insn scheduler. It should return true if there exists a 308169689Skan dependence which is considered costly by the target, between 309169689Skan the insn passed as the first parameter, and the insn passed as 310169689Skan the second parameter. The third parameter is the INSN_DEPEND 311132718Skan link that represents the dependence between the two insns. The 312132718Skan fourth argument is the cost of the dependence as estimated by 313169689Skan the scheduler. The last argument is the distance in cycles 314132718Skan between the already scheduled insn (first parameter) and the 315132718Skan the second insn (second parameter). */ 316132718Skan bool (* is_costly_dependence) (rtx, rtx, rtx, int, int); 317169689Skan 318169689Skan /* Given the current cost, COST, of an insn, INSN, calculate and 319169689Skan return a new cost based on its relationship to DEP_INSN through the 320169689Skan dependence of type DEP_TYPE. The default is to make no adjustment. */ 321169689Skan int (* adjust_cost_2) (rtx insn, int, rtx def_insn, int cost); 322169689Skan 323169689Skan /* The following member value is a pointer to a function called 324169689Skan by the insn scheduler. This hook is called to notify the backend 325169689Skan that new instructions were emitted. */ 326169689Skan void (* h_i_d_extended) (void); 327169689Skan 328169689Skan /* The following member value is a pointer to a function called 329169689Skan by the insn scheduler. 330169689Skan The first parameter is an instruction, the second parameter is the type 331169689Skan of the requested speculation, and the third parameter is a pointer to the 332169689Skan speculative pattern of the corresponding type (set if return value == 1). 333169689Skan It should return 334169689Skan -1, if there is no pattern, that will satisfy the requested speculation 335169689Skan type, 336169689Skan 0, if current pattern satisfies the requested speculation type, 337169689Skan 1, if pattern of the instruction should be changed to the newly 338169689Skan generated one. */ 339169689Skan int (* speculate_insn) (rtx, int, rtx *); 340169689Skan 341169689Skan /* The following member value is a pointer to a function called 342169689Skan by the insn scheduler. It should return true if the check instruction 343169689Skan corresponding to the instruction passed as the parameter needs a 344169689Skan recovery block. */ 345169689Skan bool (* needs_block_p) (rtx); 346169689Skan 347169689Skan /* The following member value is a pointer to a function called 348169689Skan by the insn scheduler. It should return a pattern for the check 349169689Skan instruction. 350169689Skan The first parameter is a speculative instruction, the second parameter 351169689Skan is the label of the corresponding recovery block (or null, if it is a 352169689Skan simple check). If the mutation of the check is requested (e.g. from 353169689Skan ld.c to chk.a), the third parameter is true - in this case the first 354169689Skan parameter is the previous check. */ 355169689Skan rtx (* gen_check) (rtx, rtx, bool); 356169689Skan 357169689Skan /* The following member value is a pointer to a function controlling 358169689Skan what insns from the ready insn queue will be considered for the 359169689Skan multipass insn scheduling. If the hook returns zero for the insn 360169689Skan passed as the parameter, the insn will not be chosen to be 361169689Skan issued. This hook is used to discard speculative instructions, 362169689Skan that stand at the first position of the ready list. */ 363169689Skan bool (* first_cycle_multipass_dfa_lookahead_guard_spec) (rtx); 364169689Skan 365169689Skan /* The following member value is a pointer to a function that provides 366169689Skan information about the speculation capabilities of the target. 367169689Skan The parameter is a pointer to spec_info variable. */ 368169689Skan void (* set_sched_flags) (struct spec_info_def *); 36990075Sobrien } sched; 37090075Sobrien 371169689Skan /* Functions relating to vectorization. */ 372169689Skan struct vectorize 373169689Skan { 374169689Skan /* The following member value is a pointer to a function called 375169689Skan by the vectorizer, and return the decl of the target builtin 376169689Skan function. */ 377169689Skan tree (* builtin_mask_for_load) (void); 378220150Smm 379220150Smm /* Return true if vector alignment is reachable (by peeling N 380220150Smm interations) for the given type. */ 381220150Smm bool (* vector_alignment_reachable) (tree, bool); 382169689Skan } vectorize; 383169689Skan 384169689Skan /* The initial value of target_flags. */ 385169689Skan int default_target_flags; 386169689Skan 387169689Skan /* Handle target switch CODE (an OPT_* value). ARG is the argument 388169689Skan passed to the switch; it is NULL if no argument was. VALUE is the 389169689Skan value of ARG if CODE specifies a UInteger option, otherwise it is 390169689Skan 1 if the positive form of the switch was used and 0 if the negative 391169689Skan form was. Return true if the switch was valid. */ 392169689Skan bool (* handle_option) (size_t code, const char *arg, int value); 393169689Skan 394169689Skan /* Return machine mode for filter value. */ 395169689Skan enum machine_mode (* eh_return_filter_mode) (void); 396169689Skan 39790075Sobrien /* Given two decls, merge their attributes and return the result. */ 398132718Skan tree (* merge_decl_attributes) (tree, tree); 39990075Sobrien 40090075Sobrien /* Given two types, merge their attributes and return the result. */ 401132718Skan tree (* merge_type_attributes) (tree, tree); 40290075Sobrien 403117395Skan /* Table of machine attributes and functions to handle them. 404117395Skan Ignored if NULL. */ 40590075Sobrien const struct attribute_spec *attribute_table; 40690075Sobrien 40790075Sobrien /* Return zero if the attributes on TYPE1 and TYPE2 are incompatible, 40890075Sobrien one if they are compatible and two if they are nearly compatible 40990075Sobrien (which causes a warning to be generated). */ 410132718Skan int (* comp_type_attributes) (tree type1, tree type2); 41190075Sobrien 41290075Sobrien /* Assign default attributes to the newly defined TYPE. */ 413132718Skan void (* set_default_type_attributes) (tree type); 41490075Sobrien 41590075Sobrien /* Insert attributes on the newly created DECL. */ 416132718Skan void (* insert_attributes) (tree decl, tree *attributes); 41790075Sobrien 41890075Sobrien /* Return true if FNDECL (which has at least one machine attribute) 41990075Sobrien can be inlined despite its machine attributes, false otherwise. */ 420132718Skan bool (* function_attribute_inlinable_p) (tree fndecl); 42190075Sobrien 42296263Sobrien /* Return true if bitfields in RECORD_TYPE should follow the 42396263Sobrien Microsoft Visual C++ bitfield layout rules. */ 424132718Skan bool (* ms_bitfield_layout_p) (tree record_type); 42596263Sobrien 426169689Skan /* True if the target supports decimal floating point. */ 427169689Skan bool (* decimal_float_supported_p) (void); 428169689Skan 429169689Skan /* Return true if anonymous bitfields affect structure alignment. */ 430169689Skan bool (* align_anon_bitfield) (void); 431169689Skan 432169689Skan /* Return true if volatile bitfields should use the narrowest type possible. 433169689Skan Return false if they should use the container type. */ 434169689Skan bool (* narrow_volatile_bitfield) (void); 435169689Skan 43690075Sobrien /* Set up target-specific built-in functions. */ 437132718Skan void (* init_builtins) (void); 43890075Sobrien 43990075Sobrien /* Expand a target-specific builtin. */ 440132718Skan rtx (* expand_builtin) (tree exp, rtx target, rtx subtarget, 441132718Skan enum machine_mode mode, int ignore); 44290075Sobrien 443169689Skan /* Select a replacement for a target-specific builtin. This is done 444169689Skan *before* regular type checking, and so allows the target to implement 445169689Skan a crude form of function overloading. The result is a complete 446169689Skan expression that implements the operation. */ 447169689Skan tree (*resolve_overloaded_builtin) (tree decl, tree params); 448169689Skan 449169689Skan /* Fold a target-specific builtin. */ 450169689Skan tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore); 451169689Skan 452146895Skan /* For a vendor-specific fundamental TYPE, return a pointer to 453146895Skan a statically-allocated string containing the C++ mangling for 454146895Skan TYPE. In all other cases, return NULL. */ 455146895Skan const char * (* mangle_fundamental_type) (tree type); 456146895Skan 457132718Skan /* Make any adjustments to libfunc names needed for this target. */ 458132718Skan void (* init_libfuncs) (void); 459132718Skan 46090075Sobrien /* Given a decl, a section name, and whether the decl initializer 46190075Sobrien has relocs, choose attributes for the section. */ 46290075Sobrien /* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */ 463132718Skan unsigned int (* section_type_flags) (tree, const char *, int); 46490075Sobrien 465117395Skan /* True if new jumps cannot be created, to replace existing ones or 466117395Skan not, at the current point in the compilation. */ 467132718Skan bool (* cannot_modify_jumps_p) (void); 468117395Skan 469132718Skan /* Return a register class for which branch target register 470132718Skan optimizations should be applied. */ 471132718Skan int (* branch_target_register_class) (void); 472132718Skan 473132718Skan /* Return true if branch target register optimizations should include 474132718Skan callee-saved registers that are not already live during the current 475132718Skan function. AFTER_PE_GEN is true if prologues and epilogues have 476132718Skan already been generated. */ 477132718Skan bool (* branch_target_register_callee_saved) (bool after_pe_gen); 478132718Skan 479117395Skan /* True if the constant X cannot be placed in the constant pool. */ 480132718Skan bool (* cannot_force_const_mem) (rtx); 481117395Skan 482132718Skan /* True if the insn X cannot be duplicated. */ 483132718Skan bool (* cannot_copy_insn_p) (rtx); 484132718Skan 485169689Skan /* True if X is considered to be commutative. */ 486169689Skan bool (* commutative_p) (rtx, int); 487169689Skan 488132718Skan /* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */ 489132718Skan rtx (* delegitimize_address) (rtx); 490132718Skan 491169689Skan /* True if the given constant can be put into an object_block. */ 492169689Skan bool (* use_blocks_for_constant_p) (enum machine_mode, rtx); 493169689Skan 494169689Skan /* The minimum and maximum byte offsets for anchored addresses. */ 495169689Skan HOST_WIDE_INT min_anchor_offset; 496169689Skan HOST_WIDE_INT max_anchor_offset; 497169689Skan 498169689Skan /* True if section anchors can be used to access the given symbol. */ 499169689Skan bool (* use_anchors_for_symbol_p) (rtx); 500169689Skan 501132718Skan /* True if it is OK to do sibling call optimization for the specified 502132718Skan call expression EXP. DECL will be the called function, or NULL if 503132718Skan this is an indirect call. */ 504132718Skan bool (*function_ok_for_sibcall) (tree decl, tree exp); 505132718Skan 506117395Skan /* True if EXP should be placed in a "small data" section. */ 507132718Skan bool (* in_small_data_p) (tree); 508117395Skan 509117395Skan /* True if EXP names an object for which name resolution must resolve 510117395Skan to the current module. */ 511132718Skan bool (* binds_local_p) (tree); 512117395Skan 513117395Skan /* Do something target-specific to record properties of the DECL into 514117395Skan the associated SYMBOL_REF. */ 515132718Skan void (* encode_section_info) (tree, rtx, int); 516117395Skan 517117395Skan /* Undo the effects of encode_section_info on the symbol string. */ 518132718Skan const char * (* strip_name_encoding) (const char *); 519117395Skan 520169689Skan /* If shift optabs for MODE are known to always truncate the shift count, 521169689Skan return the mask that they apply. Return 0 otherwise. */ 522169689Skan unsigned HOST_WIDE_INT (* shift_truncation_mask) (enum machine_mode mode); 523169689Skan 524169689Skan /* Return the number of divisions in the given MODE that should be present, 525169689Skan so that it is profitable to turn the division into a multiplication by 526169689Skan the reciprocal. */ 527169689Skan unsigned int (* min_divisions_for_recip_mul) (enum machine_mode mode); 528169689Skan 529169689Skan /* If the representation of integral MODE is such that values are 530169689Skan always sign-extended to a wider mode MODE_REP then return 531169689Skan SIGN_EXTEND. Return UNKNOWN otherwise. */ 532169689Skan /* Note that the return type ought to be RTX_CODE, but that's not 533169689Skan necessarily defined at this point. */ 534169689Skan int (* mode_rep_extended) (enum machine_mode mode, 535169689Skan enum machine_mode mode_rep); 536169689Skan 537132718Skan /* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */ 538132718Skan bool (* valid_pointer_mode) (enum machine_mode mode); 539132718Skan 540169689Skan /* True if MODE is valid for the target. By "valid", we mean able to 541169689Skan be manipulated in non-trivial ways. In particular, this means all 542169689Skan the arithmetic is supported. */ 543169689Skan bool (* scalar_mode_supported_p) (enum machine_mode mode); 544169689Skan 545169689Skan /* Similarly for vector modes. "Supported" here is less strict. At 546169689Skan least some operations are supported; need to check optabs or builtins 547169689Skan for further details. */ 548169689Skan bool (* vector_mode_supported_p) (enum machine_mode mode); 549169689Skan 550132718Skan /* True if a vector is opaque. */ 551132718Skan bool (* vector_opaque_p) (tree); 552132718Skan 553132718Skan /* Compute a (partial) cost for rtx X. Return true if the complete 554132718Skan cost has been computed, and false if subexpressions should be 555132718Skan scanned. In either case, *TOTAL contains the cost result. */ 556132718Skan /* Note that CODE and OUTER_CODE ought to be RTX_CODE, but that's 557132718Skan not necessarily defined at this point. */ 558132718Skan bool (* rtx_costs) (rtx x, int code, int outer_code, int *total); 559132718Skan 560132718Skan /* Compute the cost of X, used as an address. Never called with 561132718Skan invalid addresses. */ 562132718Skan int (* address_cost) (rtx x); 563132718Skan 564169689Skan /* Return where to allocate pseudo for a given hard register initial 565169689Skan value. */ 566169689Skan rtx (* allocate_initial_value) (rtx x); 567169689Skan 568132718Skan /* Given a register, this hook should return a parallel of registers 569132718Skan to represent where to find the register pieces. Define this hook 570132718Skan if the register and its mode are represented in Dwarf in 571132718Skan non-contiguous locations, or if the register should be 572132718Skan represented in more than one register in Dwarf. Otherwise, this 573132718Skan hook should return NULL_RTX. */ 574132718Skan rtx (* dwarf_register_span) (rtx); 575132718Skan 576132718Skan /* Fetch the fixed register(s) which hold condition codes, for 577132718Skan targets where it makes sense to look for duplicate assignments to 578132718Skan the condition codes. This should return true if there is such a 579132718Skan register, false otherwise. The arguments should be set to the 580132718Skan fixed register numbers. Up to two condition code registers are 581132718Skan supported. If there is only one for this target, the int pointed 582132718Skan at by the second argument should be set to -1. */ 583132718Skan bool (* fixed_condition_code_regs) (unsigned int *, unsigned int *); 584132718Skan 585132718Skan /* If two condition code modes are compatible, return a condition 586132718Skan code mode which is compatible with both, such that a comparison 587132718Skan done in the returned mode will work for both of the original 588132718Skan modes. If the condition code modes are not compatible, return 589132718Skan VOIDmode. */ 590132718Skan enum machine_mode (* cc_modes_compatible) (enum machine_mode, 591132718Skan enum machine_mode); 592132718Skan 593132718Skan /* Do machine-dependent code transformations. Called just before 594132718Skan delayed-branch scheduling. */ 595132718Skan void (* machine_dependent_reorg) (void); 596132718Skan 597132718Skan /* Create the __builtin_va_list type. */ 598132718Skan tree (* build_builtin_va_list) (void); 599132718Skan 600169689Skan /* Gimplifies a VA_ARG_EXPR. */ 601169689Skan tree (* gimplify_va_arg_expr) (tree valist, tree type, tree *pre_p, 602169689Skan tree *post_p); 603169689Skan 604132718Skan /* Validity-checking routines for PCH files, target-specific. 605132718Skan get_pch_validity returns a pointer to the data to be stored, 606132718Skan and stores the size in its argument. pch_valid_p gets the same 607132718Skan information back and returns NULL if the PCH is valid, 608132718Skan or an error message if not. 609132718Skan */ 610132718Skan void * (* get_pch_validity) (size_t *); 611132718Skan const char * (* pch_valid_p) (const void *, size_t); 612132718Skan 613169689Skan /* If nonnull, this function checks whether a PCH file with the 614169689Skan given set of target flags can be used. It returns NULL if so, 615169689Skan otherwise it returns an error message. */ 616169689Skan const char *(*check_pch_target_flags) (int); 617169689Skan 618169689Skan /* True if the compiler should give an enum type only as many 619169689Skan bytes as it takes to represent the range of possible values of 620169689Skan that type. */ 621169689Skan bool (* default_short_enums) (void); 622169689Skan 623169689Skan /* This target hook returns an rtx that is used to store the address 624169689Skan of the current frame into the built-in setjmp buffer. */ 625169689Skan rtx (* builtin_setjmp_frame_value) (void); 626169689Skan 627169689Skan /* This target hook should add STRING_CST trees for any hard regs 628169689Skan the port wishes to automatically clobber for an asm. */ 629169689Skan tree (* md_asm_clobbers) (tree, tree, tree); 630169689Skan 631169689Skan /* This target hook allows the backend to specify a calling convention 632169689Skan in the debug information. This function actually returns an 633169689Skan enum dwarf_calling_convention, but because of forward declarations 634169689Skan and not wanting to include dwarf2.h everywhere target.h is included 635169689Skan the function is being declared as an int. */ 636169689Skan int (* dwarf_calling_convention) (tree); 637169689Skan 638169689Skan /* This target hook allows the backend to emit frame-related insns that 639169689Skan contain UNSPECs or UNSPEC_VOLATILEs. The call frame debugging info 640169689Skan engine will invoke it on insns of the form 641169689Skan (set (reg) (unspec [...] UNSPEC_INDEX)) 642169689Skan and 643169689Skan (set (reg) (unspec_volatile [...] UNSPECV_INDEX)) 644169689Skan to let the backend emit the call frame instructions. */ 645169689Skan void (* dwarf_handle_frame_unspec) (const char *, rtx, int); 646169689Skan 647169689Skan /* Perform architecture specific checking of statements gimplified 648169689Skan from VA_ARG_EXPR. LHS is left hand side of MODIFY_EXPR, RHS 649169689Skan is right hand side. Returns true if the statements doesn't need 650169689Skan to be checked for va_list references. */ 651169689Skan bool (* stdarg_optimize_hook) (struct stdarg_info *ai, tree lhs, tree rhs); 652169689Skan 653169689Skan /* This target hook allows the operating system to override the DECL 654169689Skan that represents the external variable that contains the stack 655169689Skan protection guard variable. The type of this DECL is ptr_type_node. */ 656169689Skan tree (* stack_protect_guard) (void); 657169689Skan 658169689Skan /* This target hook allows the operating system to override the CALL_EXPR 659169689Skan that is invoked when a check vs the guard variable fails. */ 660169689Skan tree (* stack_protect_fail) (void); 661169689Skan 662169689Skan /* Returns NULL if target supports the insn within a doloop block, 663169689Skan otherwise it returns an error message. */ 664169689Skan const char * (*invalid_within_doloop) (rtx); 665169689Skan 666169689Skan /* DECL is a variable or function with __attribute__((dllimport)) 667169689Skan specified. Use this hook if the target needs to add extra validation 668169689Skan checks to handle_dll_attribute (). */ 669169689Skan bool (* valid_dllimport_attribute_p) (tree decl); 670169689Skan 671132718Skan /* Functions relating to calls - argument passing, returns, etc. */ 672132718Skan struct calls { 673132718Skan bool (*promote_function_args) (tree fntype); 674132718Skan bool (*promote_function_return) (tree fntype); 675132718Skan bool (*promote_prototypes) (tree fntype); 676132718Skan rtx (*struct_value_rtx) (tree fndecl, int incoming); 677132718Skan bool (*return_in_memory) (tree type, tree fndecl); 678132718Skan bool (*return_in_msb) (tree type); 679169689Skan 680169689Skan /* Return true if a parameter must be passed by reference. TYPE may 681169689Skan be null if this is a libcall. CA may be null if this query is 682169689Skan from __builtin_va_arg. */ 683169689Skan bool (*pass_by_reference) (CUMULATIVE_ARGS *ca, enum machine_mode mode, 684169689Skan tree type, bool named_arg); 685169689Skan 686132718Skan rtx (*expand_builtin_saveregs) (void); 687132718Skan /* Returns pretend_argument_size. */ 688132718Skan void (*setup_incoming_varargs) (CUMULATIVE_ARGS *ca, enum machine_mode mode, 689132718Skan tree type, int *pretend_arg_size, 690132718Skan int second_time); 691132718Skan bool (*strict_argument_naming) (CUMULATIVE_ARGS *ca); 692169689Skan /* Returns true if we should use 693169689Skan targetm.calls.setup_incoming_varargs() and/or 694132718Skan targetm.calls.strict_argument_naming(). */ 695132718Skan bool (*pretend_outgoing_varargs_named) (CUMULATIVE_ARGS *ca); 696132718Skan 697132718Skan /* Given a complex type T, return true if a parameter of type T 698132718Skan should be passed as two scalars. */ 699132718Skan bool (* split_complex_arg) (tree type); 700169689Skan 701169689Skan /* Return true if type T, mode MODE, may not be passed in registers, 702169689Skan but must be passed on the stack. */ 703169689Skan /* ??? This predicate should be applied strictly after pass-by-reference. 704169689Skan Need audit to verify that this is the case. */ 705169689Skan bool (* must_pass_in_stack) (enum machine_mode mode, tree t); 706169689Skan 707169689Skan /* Return true if type TYPE, mode MODE, which is passed by reference, 708169689Skan should have the object copy generated by the callee rather than 709169689Skan the caller. It is never called for TYPE requiring constructors. */ 710169689Skan bool (* callee_copies) (CUMULATIVE_ARGS *ca, enum machine_mode mode, 711169689Skan tree type, bool named); 712169689Skan 713169689Skan /* Return zero for arguments passed entirely on the stack or entirely 714169689Skan in registers. If passed in both, return the number of bytes passed 715169689Skan in registers; the balance is therefore passed on the stack. */ 716169689Skan int (* arg_partial_bytes) (CUMULATIVE_ARGS *ca, enum machine_mode mode, 717169689Skan tree type, bool named); 718169689Skan 719169689Skan /* Return the diagnostic message string if function without a prototype 720169689Skan is not allowed for this 'val' argument; NULL otherwise. */ 721169689Skan const char *(*invalid_arg_for_unprototyped_fn) (tree typelist, 722169689Skan tree funcdecl, tree val); 723169689Skan 724169689Skan /* Return an rtx for the return value location of the function 725169689Skan specified by FN_DECL_OR_TYPE with a return type of RET_TYPE. */ 726169689Skan rtx (*function_value) (tree ret_type, tree fn_decl_or_type, 727169689Skan bool outgoing); 728169689Skan 729169689Skan /* Return an rtx for the argument pointer incoming to the 730169689Skan current function. */ 731169689Skan rtx (*internal_arg_pointer) (void); 732132718Skan } calls; 733132718Skan 734169689Skan /* Return the diagnostic message string if conversion from FROMTYPE 735169689Skan to TOTYPE is not allowed, NULL otherwise. */ 736169689Skan const char *(*invalid_conversion) (tree fromtype, tree totype); 737169689Skan 738169689Skan /* Return the diagnostic message string if the unary operation OP is 739169689Skan not permitted on TYPE, NULL otherwise. */ 740169689Skan const char *(*invalid_unary_op) (int op, tree type); 741169689Skan 742169689Skan /* Return the diagnostic message string if the binary operation OP 743169689Skan is not permitted on TYPE1 and TYPE2, NULL otherwise. */ 744169689Skan const char *(*invalid_binary_op) (int op, tree type1, tree type2); 745169689Skan 746169689Skan /* Return the class for a secondary reload, and fill in extra information. */ 747169689Skan enum reg_class (*secondary_reload) (bool, rtx, enum reg_class, 748169689Skan enum machine_mode, 749169689Skan struct secondary_reload_info *); 750169689Skan 751169689Skan /* Functions specific to the C++ frontend. */ 752169689Skan struct cxx { 753169689Skan /* Return the integer type used for guard variables. */ 754169689Skan tree (*guard_type) (void); 755169689Skan /* Return true if only the low bit of the guard should be tested. */ 756169689Skan bool (*guard_mask_bit) (void); 757169689Skan /* Returns the size of the array cookie for an array of type. */ 758169689Skan tree (*get_cookie_size) (tree); 759169689Skan /* Returns true if the element size should be stored in the 760169689Skan array cookie. */ 761169689Skan bool (*cookie_has_size) (void); 762169689Skan /* Allows backends to perform additional processing when 763169689Skan deciding if a class should be exported or imported. */ 764169689Skan int (*import_export_class) (tree, int); 765169689Skan /* Returns true if constructors and destructors return "this". */ 766169689Skan bool (*cdtor_returns_this) (void); 767169689Skan /* Returns true if the key method for a class can be an inline 768169689Skan function, so long as it is not declared inline in the class 769169689Skan itself. Returning true is the behavior required by the Itanium 770169689Skan C++ ABI. */ 771169689Skan bool (*key_method_may_be_inline) (void); 772169689Skan /* DECL is a virtual table, virtual table table, typeinfo object, 773169689Skan or other similar implicit class data object that will be 774169689Skan emitted with external linkage in this translation unit. No ELF 775169689Skan visibility has been explicitly specified. If the target needs 776169689Skan to specify a visibility other than that of the containing class, 777169689Skan use this hook to set DECL_VISIBILITY and 778169689Skan DECL_VISIBILITY_SPECIFIED. */ 779169689Skan void (*determine_class_data_visibility) (tree decl); 780169689Skan /* Returns true (the default) if virtual tables and other 781169689Skan similar implicit class data objects are always COMDAT if they 782169689Skan have external linkage. If this hook returns false, then 783169689Skan class data for classes whose virtual table will be emitted in 784169689Skan only one translation unit will not be COMDAT. */ 785169689Skan bool (*class_data_always_comdat) (void); 786259947Spfg /* Returns true (the default) if the RTTI for the basic types, 787259947Spfg which is always defined in the C++ runtime, should be COMDAT; 788259947Spfg false if it should not be COMDAT. */ 789259947Spfg bool (*library_rtti_comdat) (void); 790169689Skan /* Returns true if __aeabi_atexit should be used to register static 791169689Skan destructors. */ 792169689Skan bool (*use_aeabi_atexit) (void); 793169689Skan /* TYPE is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that 794169689Skan has just been defined. Use this hook to make adjustments to the 795169689Skan class (eg, tweak visibility or perform any other required 796169689Skan target modifications). */ 797169689Skan void (*adjust_class_at_definition) (tree type); 798169689Skan } cxx; 799169689Skan 800169689Skan /* For targets that need to mark extra registers as live on entry to 801169689Skan the function, they should define this target hook and set their 802169689Skan bits in the bitmap passed in. */ 803169689Skan void (*live_on_entry) (bitmap); 804169689Skan 805169689Skan /* True if unwinding tables should be generated by default. */ 806169689Skan bool unwind_tables_default; 807169689Skan 808117395Skan /* Leave the boolean fields at the end. */ 809117395Skan 81090075Sobrien /* True if arbitrary sections are supported. */ 81190075Sobrien bool have_named_sections; 81290075Sobrien 813169689Skan /* True if we can create zeroed data by switching to a BSS section 814169689Skan and then using ASM_OUTPUT_SKIP to allocate the space. */ 815169689Skan bool have_switchable_bss_sections; 816169689Skan 81790075Sobrien /* True if "native" constructors and destructors are supported, 81890075Sobrien false if we're using collect2 for the job. */ 81990075Sobrien bool have_ctors_dtors; 82096263Sobrien 821117395Skan /* True if thread-local storage is supported. */ 822117395Skan bool have_tls; 823117395Skan 824117395Skan /* True if a small readonly data section is supported. */ 825117395Skan bool have_srodata_section; 826117395Skan 827117395Skan /* True if EH frame info sections should be zero-terminated. */ 828117395Skan bool terminate_dw2_eh_frame_info; 829132718Skan 830132718Skan /* True if #NO_APP should be emitted at the beginning of 831132718Skan assembly output. */ 832132718Skan bool file_start_app_off; 833132718Skan 834132718Skan /* True if output_file_directive should be called for main_input_filename 835132718Skan at the beginning of assembly output. */ 836132718Skan bool file_start_file_directive; 837132718Skan 838169689Skan /* True if #pragma redefine_extname is to be supported. */ 839169689Skan bool handle_pragma_redefine_extname; 840169689Skan 841169689Skan /* True if #pragma extern_prefix is to be supported. */ 842169689Skan bool handle_pragma_extern_prefix; 843169689Skan 844169689Skan /* True if the target is allowed to reorder memory accesses unless 845169689Skan synchronization is explicitly requested. */ 846169689Skan bool relaxed_ordering; 847169689Skan 848169689Skan /* Returns true if we should generate exception tables for use with the 849169689Skan ARM EABI. The effects the encoding of function exception specifications. 850169689Skan */ 851169689Skan bool arm_eabi_unwinder; 852169689Skan 853132718Skan /* Leave the boolean fields at the end. */ 85490075Sobrien}; 85590075Sobrien 85690075Sobrienextern struct gcc_target targetm; 857169689Skan 858169689Skan#endif /* GCC_TARGET_H */ 859