internal-fn.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* Internal functions.
  2. Copyright (C) 2011-2019 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_INTERNAL_FN_H
  16. #define GCC_INTERNAL_FN_H
  17. /* INTEGER_CST values for IFN_UNIQUE function arg-0.
  18. UNSPEC: Undifferentiated UNIQUE.
  19. FORK and JOIN mark the points at which OpenACC partitioned
  20. execution is entered or exited.
  21. DEP_VAR = UNIQUE ({FORK,JOIN}, DEP_VAR, AXIS)
  22. HEAD_MARK and TAIL_MARK are used to demark the sequence entering
  23. or leaving partitioned execution.
  24. DEP_VAR = UNIQUE ({HEAD,TAIL}_MARK, REMAINING_MARKS, ...PRIMARY_FLAGS)
  25. The PRIMARY_FLAGS only occur on the first HEAD_MARK of a sequence. */
  26. #define IFN_UNIQUE_CODES \
  27. DEF(UNSPEC), \
  28. DEF(OACC_FORK), DEF(OACC_JOIN), \
  29. DEF(OACC_HEAD_MARK), DEF(OACC_TAIL_MARK)
  30. enum ifn_unique_kind {
  31. #define DEF(X) IFN_UNIQUE_##X
  32. IFN_UNIQUE_CODES
  33. #undef DEF
  34. };
  35. /* INTEGER_CST values for IFN_GOACC_LOOP arg-0. Allows the precise
  36. stepping of the compute geometry over the loop iterations to be
  37. deferred until it is known which compiler is generating the code.
  38. The action is encoded in a constant first argument.
  39. CHUNK_MAX = LOOP (CODE_CHUNKS, DIR, RANGE, STEP, CHUNK_SIZE, MASK)
  40. STEP = LOOP (CODE_STEP, DIR, RANGE, STEP, CHUNK_SIZE, MASK)
  41. OFFSET = LOOP (CODE_OFFSET, DIR, RANGE, STEP, CHUNK_SIZE, MASK, CHUNK_NO)
  42. BOUND = LOOP (CODE_BOUND, DIR, RANGE, STEP, CHUNK_SIZE, MASK, OFFSET)
  43. DIR - +1 for up loop, -1 for down loop
  44. RANGE - Range of loop (END - BASE)
  45. STEP - iteration step size
  46. CHUNKING - size of chunking, (constant zero for no chunking)
  47. CHUNK_NO - chunk number
  48. MASK - partitioning mask. */
  49. #define IFN_GOACC_LOOP_CODES \
  50. DEF(CHUNKS), DEF(STEP), DEF(OFFSET), DEF(BOUND)
  51. enum ifn_goacc_loop_kind {
  52. #define DEF(X) IFN_GOACC_LOOP_##X
  53. IFN_GOACC_LOOP_CODES
  54. #undef DEF
  55. };
  56. /* The GOACC_REDUCTION function defines a generic interface to support
  57. gang, worker and vector reductions. All calls are of the following
  58. form:
  59. V = REDUCTION (CODE, REF_TO_RES, LOCAL_VAR, LEVEL, OP, OFFSET)
  60. REF_TO_RES - is a reference to the original reduction varl, may be NULL
  61. LOCAL_VAR is the intermediate reduction variable
  62. LEVEL corresponds to the GOMP_DIM of the reduction
  63. OP is the tree code of the reduction operation
  64. OFFSET may be used as an offset into a reduction array for the
  65. reductions occuring at this level.
  66. In general the return value is LOCAL_VAR, which creates a data
  67. dependency between calls operating on the same reduction. */
  68. #define IFN_GOACC_REDUCTION_CODES \
  69. DEF(SETUP), DEF(INIT), DEF(FINI), DEF(TEARDOWN)
  70. enum ifn_goacc_reduction_kind {
  71. #define DEF(X) IFN_GOACC_REDUCTION_##X
  72. IFN_GOACC_REDUCTION_CODES
  73. #undef DEF
  74. };
  75. /* Initialize internal function tables. */
  76. extern void init_internal_fns ();
  77. /* Return the name of internal function FN. The name is only meaningful
  78. for dumps; it has no linkage. */
  79. extern const char *const internal_fn_name_array[];
  80. static inline const char *
  81. internal_fn_name (enum internal_fn fn)
  82. {
  83. return internal_fn_name_array[(int) fn];
  84. }
  85. extern internal_fn lookup_internal_fn (const char *);
  86. /* Return the ECF_* flags for function FN. */
  87. extern const int internal_fn_flags_array[];
  88. static inline int
  89. internal_fn_flags (enum internal_fn fn)
  90. {
  91. return internal_fn_flags_array[(int) fn];
  92. }
  93. /* Return fnspec for function FN. */
  94. extern GTY(()) const_tree internal_fn_fnspec_array[IFN_LAST + 1];
  95. static inline const_tree
  96. internal_fn_fnspec (enum internal_fn fn)
  97. {
  98. return internal_fn_fnspec_array[(int) fn];
  99. }
  100. /* Describes an internal function that maps directly to an optab. */
  101. struct direct_internal_fn_info
  102. {
  103. /* optabs can be parameterized by one or two modes. These fields describe
  104. how to select those modes from the types of the return value and
  105. arguments. A value of -1 says that the mode is determined by the
  106. return type while a value N >= 0 says that the mode is determined by
  107. the type of argument N. A value of -2 says that this internal
  108. function isn't directly mapped to an optab. */
  109. signed int type0 : 8;
  110. signed int type1 : 8;
  111. /* True if the function is pointwise, so that it can be vectorized by
  112. converting the return type and all argument types to vectors of the
  113. same number of elements. E.g. we can vectorize an IFN_SQRT on
  114. floats as an IFN_SQRT on vectors of N floats.
  115. This only needs 1 bit, but occupies the full 16 to ensure a nice
  116. layout. */
  117. unsigned int vectorizable : 16;
  118. };
  119. extern const direct_internal_fn_info direct_internal_fn_array[IFN_LAST + 1];
  120. /* Return true if FN is mapped directly to an optab. */
  121. inline bool
  122. direct_internal_fn_p (internal_fn fn)
  123. {
  124. return direct_internal_fn_array[fn].type0 >= -1;
  125. }
  126. /* Return true if FN is a direct internal function that can be vectorized by
  127. converting the return type and all argument types to vectors of the same
  128. number of elements. E.g. we can vectorize an IFN_SQRT on floats as an
  129. IFN_SQRT on vectors of N floats. */
  130. inline bool
  131. vectorizable_internal_fn_p (internal_fn fn)
  132. {
  133. return direct_internal_fn_array[fn].vectorizable;
  134. }
  135. /* Return optab information about internal function FN. Only meaningful
  136. if direct_internal_fn_p (FN). */
  137. inline const direct_internal_fn_info &
  138. direct_internal_fn (internal_fn fn)
  139. {
  140. gcc_checking_assert (direct_internal_fn_p (fn));
  141. return direct_internal_fn_array[fn];
  142. }
  143. extern tree_pair direct_internal_fn_types (internal_fn, tree, tree *);
  144. extern tree_pair direct_internal_fn_types (internal_fn, gcall *);
  145. extern bool direct_internal_fn_supported_p (internal_fn, tree_pair,
  146. optimization_type);
  147. extern bool direct_internal_fn_supported_p (internal_fn, tree,
  148. optimization_type);
  149. extern bool direct_internal_fn_supported_p (gcall *, optimization_type);
  150. /* Return true if FN is supported for types TYPE0 and TYPE1 when the
  151. optimization type is OPT_TYPE. The types are those associated with
  152. the "type0" and "type1" fields of FN's direct_internal_fn_info
  153. structure. */
  154. inline bool
  155. direct_internal_fn_supported_p (internal_fn fn, tree type0, tree type1,
  156. optimization_type opt_type)
  157. {
  158. return direct_internal_fn_supported_p (fn, tree_pair (type0, type1),
  159. opt_type);
  160. }
  161. extern int first_commutative_argument (internal_fn);
  162. extern bool set_edom_supported_p (void);
  163. extern internal_fn get_conditional_internal_fn (tree_code);
  164. extern internal_fn get_conditional_internal_fn (internal_fn);
  165. extern tree_code conditional_internal_fn_code (internal_fn);
  166. extern internal_fn get_unconditional_internal_fn (internal_fn);
  167. extern bool can_interpret_as_conditional_op_p (gimple *, tree *,
  168. tree_code *, tree (&)[3],
  169. tree *);
  170. extern bool internal_load_fn_p (internal_fn);
  171. extern bool internal_store_fn_p (internal_fn);
  172. extern bool internal_gather_scatter_fn_p (internal_fn);
  173. extern int internal_fn_mask_index (internal_fn);
  174. extern int internal_fn_stored_value_index (internal_fn);
  175. extern bool internal_gather_scatter_fn_supported_p (internal_fn, tree,
  176. tree, signop, int);
  177. extern void expand_internal_call (gcall *);
  178. extern void expand_internal_call (internal_fn, gcall *);
  179. extern void expand_PHI (internal_fn, gcall *);
  180. extern bool vectorized_internal_fn_supported_p (internal_fn, tree);
  181. #endif