expr.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /* Definitions for code generation pass of GNU compiler.
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* Macros to access the slots of a QUEUED rtx.
  18. Here rather than in rtl.h because only the expansion pass
  19. should ever encounter a QUEUED. */
  20. /* The variable for which an increment is queued. */
  21. #define QUEUED_VAR(P) FORMAT_e (P, 0)
  22. /* If the increment has been emitted, this is the insn
  23. that does the increment. It is zero before the increment is emitted. */
  24. #define QUEUED_INSN(P) FORMAT_e (P, 1)
  25. /* If a pre-increment copy has been generated, this is the copy
  26. (it is a temporary reg). Zero if no copy made yet. */
  27. #define QUEUED_COPY(P) FORMAT_e (P, 2)
  28. /* This is the body to use for the insn to do the increment.
  29. It is used to emit the increment. */
  30. #define QUEUED_BODY(P) FORMAT_e (P, 3)
  31. /* Next QUEUED in the queue. */
  32. #define QUEUED_NEXT(P) FORMAT_e (P, 4)
  33. /* If this is nonzero, we do not bother generating VOLATILE
  34. around volatile memory references, and we are willing to
  35. output indirect addresses. If cse is to follow, we reject
  36. indirect addresses so a useful potential cse is generated;
  37. if it is used only once, instruction combination will produce
  38. the same indirect address eventually. */
  39. extern int cse_not_expected;
  40. /* Optabs are tables saying how to generate insn bodies
  41. for various machine modes and numbers of operands.
  42. Each optab applies to one operation.
  43. For example, add_optab applies to addition.
  44. The insn_code slot is the enum insn_code that says how to
  45. generate an insn for this operation on a particular machine mode.
  46. It is CODE_FOR_nothing if there is no such insn on the target machine.
  47. The `lib_call' slot is the name of the library function that
  48. can be used to perform the operation.
  49. A few optabs, such as move_optab and cmp_optab, are used
  50. by special code. */
  51. /* Everything that uses expr.h needs to define enum insn_code
  52. but we don't list it in the Makefile dependencies just for that. */
  53. #include "insn-codes.h"
  54. typedef struct optab
  55. {
  56. enum insn_code insn_code;
  57. char *lib_call;
  58. } optab [NUM_MACHINE_MODES];
  59. /* Given an enum insn_code, access the function to construct
  60. the body of that kind of insn. */
  61. #define GEN_FCN(CODE) (*insn_gen_function[(int) (CODE)])
  62. extern rtx (*insn_gen_function[]) ();
  63. extern optab add_optab;
  64. extern optab sub_optab;
  65. extern optab smul_optab; /* Signed multiply */
  66. extern optab umul_optab; /* Unsigned multiply */
  67. extern optab smul_widen_optab; /* Signed multiply with result
  68. one machine mode wider than args */
  69. extern optab umul_widen_optab;
  70. extern optab sdiv_optab; /* Signed divide */
  71. extern optab sdivmod_optab; /* Signed divide-and-remainder in one */
  72. extern optab udiv_optab;
  73. extern optab udivmod_optab;
  74. extern optab smod_optab; /* Signed remainder */
  75. extern optab umod_optab;
  76. extern optab flodiv_optab; /* Optab for floating divide. */
  77. extern optab and_optab; /* Logical and */
  78. extern optab andcb_optab; /* Logical and with complement of 2nd arg */
  79. extern optab ior_optab; /* Logical or */
  80. extern optab xor_optab; /* Logical xor */
  81. extern optab ashl_optab; /* Arithmetic shift left */
  82. extern optab ashr_optab; /* Arithmetic shift right */
  83. extern optab lshl_optab; /* Logical shift left */
  84. extern optab lshr_optab; /* Logical shift right */
  85. extern optab rotl_optab; /* Rotate left */
  86. extern optab rotr_optab; /* Rotate right */
  87. extern optab mov_optab; /* Move instruction. */
  88. extern optab movstrict_optab; /* Move, preserving high part of register. */
  89. extern optab cmp_optab; /* Compare insn; two operands. */
  90. extern optab tst_optab; /* tst insn; compare one operand against 0 */
  91. /* Unary operations */
  92. extern optab neg_optab; /* Negation */
  93. extern optab abs_optab; /* Abs value */
  94. extern optab one_cmpl_optab; /* Bitwise not */
  95. /* Passed to expand_binop and expand_unop to say which options to try to use
  96. if the requested operation can't be open-coded on the requisite mode.
  97. Either OPTAB_LIB or OPTAB_LIB_WIDEN says try using a library call.
  98. Either OPTAB_WIDEN or OPTAB_LIB_WIDEN says try using a wider mode. */
  99. enum optab_methods
  100. {
  101. OPTAB_DIRECT,
  102. OPTAB_LIB,
  103. OPTAB_WIDEN,
  104. OPTAB_LIB_WIDEN,
  105. };
  106. /* Nonzero means load memory operands into registers before doing
  107. arithmetic on them. Gives better cse but slower compilation. */
  108. extern int force_mem;
  109. /* Nonzero for -optforceaddr: load memory address into a register
  110. before reference to it. This makes better cse but slower compilation. */
  111. extern int force_addr;
  112. typedef rtx (*rtxfun) ();
  113. /* Expand a binary operation given optab and rtx operands. */
  114. rtx expand_binop ();
  115. /* Expand a unary arithmetic operation given optab rtx operand. */
  116. rtx expand_unop ();
  117. /* Initialize the tables that control conversion between fixed and
  118. floating values. */
  119. void init_fixtab ();
  120. void init_floattab ();
  121. /* Say whether a certain floating machine mode can be converted to a certain
  122. fixed machine mode. */
  123. rtxfun can_fix_p ();
  124. /* Similar for converting a fixed machine mode to a floating one. */
  125. rtxfun can_float_p ();
  126. /* Generate code for a FIX_EXPR. */
  127. void expand_fix ();
  128. /* Generate code for a FLOAT_EXPR. */
  129. void expand_float ();
  130. /* Create but don't emit one rtl instruction to add one rtx into another.
  131. Modes must match.
  132. Likewise for subtraction and for just copying.
  133. These do not call protect_from_queue; caller must do so. */
  134. rtx gen_add2_insn ();
  135. rtx gen_sub2_insn ();
  136. rtx gen_move_insn ();
  137. /* Emit one rtl instruction to store zero in specified rtx. */
  138. void emit_clr_insn ();
  139. /* Emit one rtl insn to store 1 in specified rtx assuming it contains 0. */
  140. void emit_0_to_1_insn ();
  141. /* Emit one rtl insn to compare two rtx's. */
  142. void emit_cmp_insn ();
  143. /* Emit some rtl insns to move data between rtx's, converting machine modes.
  144. Both modes must be floating or both fixed. */
  145. void convert_move ();
  146. /* Convert an rtx to specified machine mode and return the result. */
  147. rtx convert_to_mode ();
  148. /* Emit code to push some arguments and call a library routine,
  149. storing the value in a specified place. Calling sequence is
  150. complicated. */
  151. void emit_library_call ();
  152. /* Given an rtx that may include add and multiply operations,
  153. generate them as insns and return a pseudo-reg containing the value.
  154. Useful after calling expand_expr with 1 as sum_ok. */
  155. rtx force_operand ();
  156. /* Return an rtx for the size in bytes of the value of an expr. */
  157. rtx expr_size ();
  158. /* Return an rtx for the sum of an rtx and an integer. */
  159. rtx plus_constant ();
  160. rtx lookup_static_chain ();
  161. /* Return an rtx like arg but sans any constant terms.
  162. Returns the original rtx if it has no constant terms.
  163. The constant terms are added and stored via a second arg. */
  164. rtx eliminate_constant_term ();
  165. /* Convert arg to a valid memory address for specified machine mode,
  166. by emitting insns to perform arithmetic if nec. */
  167. rtx memory_address ();
  168. rtx low_half ();
  169. rtx high_half ();
  170. /* Return 1 if two rtx's are equivalent in structure and elements. */
  171. int rtx_equal_p ();
  172. /* Given rtx, return new rtx whose address won't be affected by
  173. any side effects. It has been copied to a new temporary reg. */
  174. rtx stabilize ();
  175. /* Given an rtx, copy all regs it refers to into new temps
  176. and return a modified copy that refers to the new temps. */
  177. rtx copy_all_regs ();
  178. /* Copy given rtx to a new temp reg and return that. */
  179. rtx copy_to_reg ();
  180. /* Copy given rtx to given temp reg and return that. */
  181. rtx copy_to_suggested_reg ();
  182. /* Return given rtx, copied into a new temp reg if it was in memory. */
  183. rtx force_not_mem ();
  184. /* Remove some bytes from the stack. An rtx says how many. */
  185. void adjust_stack ();
  186. /* Add some bytes to the stack. An rtx says how many. */
  187. void anti_adjust_stack ();
  188. /* Emit code to copy function value to a new temp reg and return that reg. */
  189. rtx function_value ();
  190. /* Return an rtx that refers to the value returned by a function
  191. in its original home. This becomes invalid if any more code is emitted. */
  192. rtx hard_function_value ();
  193. /* Emit code to copy function value to a specified place. */
  194. void copy_function_value ();
  195. rtx store_bit_field ();
  196. rtx store_fixed_bit_field ();
  197. rtx extract_bit_field ();
  198. rtx extract_fixed_bit_field ();
  199. rtx expand_shift ();
  200. rtx expand_bit_and ();
  201. rtx expand_mult ();
  202. rtx expand_divmod ();
  203. rtx get_structure_value_addr ();