target.h 6.8 KB

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