target.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /* Data structure definitions for a generic GCC target.
  2. Copyright (C) 2001-2019 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-codes.h"
  40. #include "tm.h"
  41. #include "hard-reg-set.h"
  42. #if CHECKING_P
  43. struct cumulative_args_t { void *magic; void *p; };
  44. #else /* !CHECKING_P */
  45. /* When using a GCC build compiler, we could use
  46. __attribute__((transparent_union)) to get cumulative_args_t function
  47. arguments passed like scalars where the ABI would mandate a less
  48. efficient way of argument passing otherwise. However, that would come
  49. at the cost of less type-safe !CHECKING_P compilation. */
  50. union cumulative_args_t { void *p; };
  51. #endif /* !CHECKING_P */
  52. /* Types used by the record_gcc_switches() target function. */
  53. enum print_switch_type
  54. {
  55. SWITCH_TYPE_PASSED, /* A switch passed on the command line. */
  56. SWITCH_TYPE_ENABLED, /* An option that is currently enabled. */
  57. SWITCH_TYPE_DESCRIPTIVE, /* Descriptive text, not a switch or option. */
  58. SWITCH_TYPE_LINE_START, /* Please emit any necessary text at the start of a line. */
  59. SWITCH_TYPE_LINE_END /* Please emit a line terminator. */
  60. };
  61. /* Types of memory operation understood by the "by_pieces" infrastructure.
  62. Used by the TARGET_USE_BY_PIECES_INFRASTRUCTURE_P target hook and
  63. internally by the functions in expr.c. */
  64. enum by_pieces_operation
  65. {
  66. CLEAR_BY_PIECES,
  67. MOVE_BY_PIECES,
  68. SET_BY_PIECES,
  69. STORE_BY_PIECES,
  70. COMPARE_BY_PIECES
  71. };
  72. extern unsigned HOST_WIDE_INT by_pieces_ninsns (unsigned HOST_WIDE_INT,
  73. unsigned int,
  74. unsigned int,
  75. by_pieces_operation);
  76. typedef int (* print_switch_fn_type) (print_switch_type, const char *);
  77. /* An example implementation for ELF targets. Defined in varasm.c */
  78. extern int elf_record_gcc_switches (print_switch_type type, const char *);
  79. /* Some places still assume that all pointer or address modes are the
  80. standard Pmode and ptr_mode. These optimizations become invalid if
  81. the target actually supports multiple different modes. For now,
  82. we disable such optimizations on such targets, using this function. */
  83. extern bool target_default_pointer_address_modes_p (void);
  84. /* For hooks which use the MOVE_RATIO macro, this gives the legacy default
  85. behavior. */
  86. extern unsigned int get_move_ratio (bool);
  87. struct stdarg_info;
  88. struct spec_info_def;
  89. struct hard_reg_set_container;
  90. struct cgraph_node;
  91. struct cgraph_simd_clone;
  92. /* The struct used by the secondary_reload target hook. */
  93. struct secondary_reload_info
  94. {
  95. /* icode is actually an enum insn_code, but we don't want to force every
  96. file that includes target.h to include optabs.h . */
  97. int icode;
  98. int extra_cost; /* Cost for using (a) scratch register(s) to be taken
  99. into account by copy_cost. */
  100. /* The next two members are for the use of the backward
  101. compatibility hook. */
  102. struct secondary_reload_info *prev_sri;
  103. int t_icode; /* Actually an enum insn_code - see above. */
  104. };
  105. /* This is defined in sched-int.h . */
  106. struct _dep;
  107. /* This is defined in ddg.h . */
  108. struct ddg;
  109. /* This is defined in cfgloop.h . */
  110. struct loop;
  111. /* This is defined in ifcvt.h. */
  112. struct noce_if_info;
  113. /* This is defined in tree-ssa-alias.h. */
  114. struct ao_ref;
  115. /* This is defined in tree-vectorizer.h. */
  116. struct _stmt_vec_info;
  117. /* These are defined in tree-vect-stmts.c. */
  118. extern tree stmt_vectype (struct _stmt_vec_info *);
  119. extern bool stmt_in_inner_loop_p (struct _stmt_vec_info *);
  120. /* Assembler instructions for creating various kinds of integer object. */
  121. struct asm_int_op
  122. {
  123. const char *hi;
  124. const char *psi;
  125. const char *si;
  126. const char *pdi;
  127. const char *di;
  128. const char *pti;
  129. const char *ti;
  130. };
  131. /* Types of costs for vectorizer cost model. */
  132. enum vect_cost_for_stmt
  133. {
  134. scalar_stmt,
  135. scalar_load,
  136. scalar_store,
  137. vector_stmt,
  138. vector_load,
  139. vector_gather_load,
  140. unaligned_load,
  141. unaligned_store,
  142. vector_store,
  143. vector_scatter_store,
  144. vec_to_scalar,
  145. scalar_to_vec,
  146. cond_branch_not_taken,
  147. cond_branch_taken,
  148. vec_perm,
  149. vec_promote_demote,
  150. vec_construct
  151. };
  152. /* Separate locations for which the vectorizer cost model should
  153. track costs. */
  154. enum vect_cost_model_location {
  155. vect_prologue = 0,
  156. vect_body = 1,
  157. vect_epilogue = 2
  158. };
  159. class vec_perm_indices;
  160. /* The type to use for lists of vector sizes. */
  161. typedef vec<poly_uint64> vector_sizes;
  162. /* Same, but can be used to construct local lists that are
  163. automatically freed. */
  164. typedef auto_vec<poly_uint64, 8> auto_vector_sizes;
  165. /* The target structure. This holds all the backend hooks. */
  166. #define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
  167. #define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
  168. #define DEFHOOK_UNDOC DEFHOOK
  169. #define HOOKSTRUCT(FRAGMENT) FRAGMENT
  170. #include "target.def"
  171. extern struct gcc_target targetm;
  172. /* Return an estimate of the runtime value of X, for use in things
  173. like cost calculations or profiling frequencies. Note that this
  174. function should never be used in situations where the actual
  175. runtime value is needed for correctness, since the function only
  176. provides a rough guess. */
  177. static inline HOST_WIDE_INT
  178. estimated_poly_value (poly_int64 x)
  179. {
  180. if (NUM_POLY_INT_COEFFS == 1)
  181. return x.coeffs[0];
  182. else
  183. return targetm.estimated_poly_value (x);
  184. }
  185. #ifdef GCC_TM_H
  186. #ifndef CUMULATIVE_ARGS_MAGIC
  187. #define CUMULATIVE_ARGS_MAGIC ((void *) &targetm.calls)
  188. #endif
  189. static inline CUMULATIVE_ARGS *
  190. get_cumulative_args (cumulative_args_t arg)
  191. {
  192. #if CHECKING_P
  193. gcc_assert (arg.magic == CUMULATIVE_ARGS_MAGIC);
  194. #endif /* CHECKING_P */
  195. return (CUMULATIVE_ARGS *) arg.p;
  196. }
  197. static inline cumulative_args_t
  198. pack_cumulative_args (CUMULATIVE_ARGS *arg)
  199. {
  200. cumulative_args_t ret;
  201. #if CHECKING_P
  202. ret.magic = CUMULATIVE_ARGS_MAGIC;
  203. #endif /* CHECKING_P */
  204. ret.p = (void *) arg;
  205. return ret;
  206. }
  207. #endif /* GCC_TM_H */
  208. #endif /* GCC_TARGET_H */