rtl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /* Register Transfer Language (RTL) definitions for GNU C-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. /* Register Transfer Language EXPRESSIONS CODES */
  18. #define RTX_CODE enum rtx_code
  19. enum rtx_code {
  20. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT) ENUM ,
  21. #include "rtl.def" /* rtl expressions are documented here */
  22. #undef DEF_RTL_EXPR
  23. LAST_AND_UNUSED_RTX_CODE}; /* A convienent way to get a value for
  24. NUM_RTX_CODE.
  25. Assumes default enum value assignement. */
  26. #define NUM_RTX_CODE ((int)LAST_AND_UNUSED_RTX_CODE)
  27. /* The cast here, saves many elsewhere. */
  28. extern int rtx_length[];
  29. #define GET_RTX_LENGTH(CODE) (rtx_length[(int)(CODE)])
  30. extern char *rtx_name[];
  31. #define GET_RTX_NAME(CODE) (rtx_name[(int)(CODE)])
  32. extern char *rtx_format[];
  33. #define GET_RTX_FORMAT(CODE) (rtx_format[(int)(CODE)])
  34. /* Get the definition of `enum machine_mode' */
  35. #ifndef HAVE_MACHINE_MODES
  36. #define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT) SYM,
  37. enum machine_mode {
  38. #include "machmode.def"
  39. MAX_MACHINE_MODE };
  40. #undef DEF_MACHMODE
  41. #define HAVE_MACHINE_MODES
  42. #endif /* not HAVE_MACHINE_MODES */
  43. #define NUM_MACHINE_MODE ((int)MAX_MACHINE_MODE)
  44. extern char *mode_name[];
  45. #define GET_MODE_NAME(MODE) (mode_name[(int)(MODE)])
  46. extern int mode_size[];
  47. #define GET_MODE_SIZE(MODE) (mode_size[(int)(MODE)])
  48. extern int mode_unit_size[];
  49. #define GET_MODE_UNIT_SIZE(MODE) (mode_unit_size[(int)(MODE)])
  50. #define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int)(MODE)])
  51. #define GET_MODE_MASK(MODE) \
  52. ((1 << (BITS_PER_UNIT * mode_size[(int)(MODE)])) - 1)
  53. /* Common union for an element of an rtx. */
  54. typedef union rtunion_def
  55. {
  56. int rtint;
  57. char *rtstr;
  58. struct rtx_def *rtx;
  59. struct rtvec_def *rtvec;
  60. enum machine_mode rttype;
  61. } rtunion;
  62. /* RTL expression ("rtx"). */
  63. typedef struct rtx_def
  64. {
  65. /* The kind of expression this is. */
  66. enum rtx_code code : 16;
  67. /* The kind of value the expression has. */
  68. enum machine_mode mode : 8;
  69. /* 1 in an INSN if it can alter flow of control
  70. within this function. Not yet used! */
  71. unsigned int jump : 1;
  72. /* 1 in an INSN if it can call another function. Not yet used! */
  73. unsigned int call : 1;
  74. /* 1 if value of this expression will never change
  75. during the current function, even though it is not
  76. manifestly constant. Not yet used! */
  77. unsigned int unchanging : 1;
  78. /* 1 in a MEM expression if contents of memory are volatile.
  79. Not yet used! */
  80. unsigned int volatile : 1;
  81. /* 1 in a MEM referring to a field of a structure (not a union!).
  82. 0 if the MEM was a variable or the result of a * operator in C;
  83. 1 if it was the result of a . or -> operator in C.
  84. Not yet used! */
  85. unsigned int in_struct : 1;
  86. /* The first element of the operands of this rtx.
  87. The number of operands and their types are controlled
  88. by the `code' field, according to rtl.def. */
  89. rtunion fld[1];
  90. } *rtx;
  91. #define NULL_RTX (rtx) NULL
  92. #define GET_CODE(RTX) ((RTX)->code)
  93. #define PUT_CODE(RTX, CODE) ((RTX)->code = (CODE))
  94. #define GET_MODE(RTX) ((RTX)->mode)
  95. #define PUT_MODE(RTX, MODE) ((RTX)->mode = (MODE))
  96. /* RTL vector. These appear inside RTX's when there is a need
  97. for a variable number of things. The principle use is inside
  98. PARALLEL expressions. */
  99. typedef struct rtvec_def{
  100. unsigned num_elem; /* number of elements */
  101. rtunion elem[1];
  102. } *rtvec;
  103. #define NULL_RTVEC (rtvec) NULL
  104. #define GET_NUM_ELEM(RTVEC) ((RTVEC)->num_elem)
  105. #define PUT_NUM_ELEM(RTVEC, NUM) ((RTVEC)->num_elem = (unsigned) NUM)
  106. /* ----------------------------------------------------------------------
  107. FORMAT MACROS for access to rtx fields in specified data format.
  108. ---------------------------------------------------------------------- */
  109. #define XEXP(RTX, N) ((RTX)->fld[N].rtx)
  110. #define XINT(RTX, N) ((RTX)->fld[N].rtint)
  111. #define XSTR(RTX, N) ((RTX)->fld[N].rtstr)
  112. #define XVEC(RTX, N) ((RTX)->fld[N].rtvec)
  113. #define XVECLEN(RTX, N) ((RTX)->fld[N].rtvec->num_elem)
  114. #define XVECEXP(RTX,N,M)((RTX)->fld[N].rtvec->elem[M].rtx)
  115. /* name of expression */
  116. #define FORMAT_n(RTX) (*GET_RTX_NAME(GET_CODE(RTX)))
  117. /* string */
  118. #define FORMAT_s(RTX, N) ((RTX)->fld[N].rtstr)
  119. /* expression */
  120. #define FORMAT_e(RTX, N) ((RTX)->fld[N].rtx)
  121. /* elements of a vector of expressions */
  122. #define PT_FORMAT_E(RTX, N) ((RTX)->fld[N].rtvec)
  123. #define NUM_FORMAT_E(RTX, N) ((RTX)->fld[N].rtvec->num_elem)
  124. #define FORMAT_E(RTX, N, M) ((RTX)->fld[N].rtvec->elem[M].rtx)
  125. /* integer */
  126. #define FORMAT_i(RTX, N) ((RTX)->fld[N].rtint)
  127. /* pointed to insn uid */
  128. #define PT_FORMAT_u(RTX, N) ((RTX)->fld[N].rtx)
  129. #define FORMAT_u(RTX, N) ((RTX)->fld[N].rtx->fld[0].rtint)
  130. /* vector of pointed to insn uids */
  131. #define PT_FORMAT_U(RTX, N) ((RTX)->fld[N].rtvec)
  132. #define NUM_FORMAT_U(RTX, N) ((RTX)->fld[N].rtvec->num_elem)
  133. #define ELEM_FORMAT_U(RTX,N,M) ((RTX)->fld[N].rtvec->elem[M].rtx)
  134. #define FORMAT_U(RTX, N, M) ((RTX)->fld[N].rtvec->elem[M].rtx->fld[0].rtint)
  135. /* ----------------------------------------------------------------------
  136. ACCESS MACROS to particular fields of particular kinds of rtx's.
  137. ---------------------------------------------------------------------- */
  138. /* Holds a unique number for each insn.
  139. These are not necessarily sequentially increasing. */
  140. #define INSN_UID(INSN) ((INSN)->fld[0].rtint)
  141. #define PREV_INSN(INSN) ((INSN)->fld[1].rtx)
  142. #define NEXT_INSN(INSN) ((INSN)->fld[2].rtx)
  143. #define PATTERN(INSN) ((INSN)->fld[3].rtx)
  144. /* Code number of instruction, from when it was recognized.
  145. Zero means this instruction has not been recognized yet. */
  146. #define INSN_CODE(INSN) ((INSN)->fld[4].rtint)
  147. /* Set up in flow.c; empty before then.
  148. Holds a chain of INSN_LIST rtx's whose first operands point at
  149. previous insns with direct data-flow connections to this one.
  150. That means that those insns set variables whose next use is in this insn.
  151. They are always in the same basic block as this insn. */
  152. #define LOG_LINKS(INSN) ((INSN)->fld[5].rtx)
  153. /* Holds a list of notes on what this insn does to various REGs.
  154. This is set up by flow.c; it is empty until then.
  155. It is a chain of EXPR_LIST rtx's, where the second operand
  156. is the chain pointer and the first operand is the REG being described.
  157. The mode field of the EXPR_LIST contains not a real machine mode
  158. but a value that says what this note says about the REG:
  159. REG_DEAD means that the REG dies in this insn.
  160. REG_INC means that the REG is autoincremented or autodecremented.
  161. Note that one insn can have both REG_DEAD and REG_INC for the same register
  162. if the register is preincremented or predecremented in the insn
  163. and not needed afterward. This can probably happen.
  164. REG_CONST describes the insn as a whole; it says that the
  165. insn sets a register to a constant value and that if the
  166. register is spilled to the stack then the constant value
  167. should be substituted for it.
  168. REG_WAS_0 says that the specified register held 0 before this insn. */
  169. #define REG_NOTES(INSN) ((INSN)->fld[6].rtx)
  170. enum reg_note { REG_DEAD = 1, REG_INC = 2, REG_CONST = 3, REG_WAS_0 = 4 };
  171. #define CODE_LABEL_NUMBER(INSN) ((INSN)->fld[3].rtint)
  172. #define LINE_NUMBER NOTE
  173. #define NOTE_SOURCE_FILE(INSN) ((INSN)->fld[3].rtstr)
  174. #define NOTE_LINE_NUMBER(INSN) ((INSN)->fld[4].rtint)
  175. /* Codes that appear in the NOTE_LINE_NUMBER field
  176. for kinds of notes that are not line numbers. */
  177. #define NOTE_INSN_FUNCTION_BEG 0
  178. #define NOTE_INSN_DELETED -1
  179. #define NOTE_INSN_BLOCK_BEG -2
  180. #define NOTE_INSN_BLOCK_END -3
  181. #define NOTE_INSN_LOOP_BEG -4
  182. #define NOTE_INSN_LOOP_END -5
  183. /* In jump.c, each label contains a count of the number
  184. of LABEL_REFs that point at it, so unused labels can be deleted. */
  185. #define LABEL_NUSES(LABEL) ((LABEL)->fld[4].rtx)
  186. /* In jump.c, each JUMP_INSN can point to a label that it can jump to,
  187. so that if the JUMP_INSN is deleted, the label's LABEL_NUSES can
  188. be decremented and possibly the label can be deleted. */
  189. #define JUMP_LABEL(INSN) ((INSN)->fld[7].rtx)
  190. /* Once basic blocks are found in flow.c,
  191. each CODE_LABEL starts a chain that goes through
  192. all the LABEL_REFs that jump to that label.
  193. The chain eventually winds up at the CODE_LABEL; it is circular. */
  194. #define LABEL_REFS(LABEL) ((LABEL)->fld[4].rtx)
  195. /* This is the field in the LABEL_REF through which the chain is linked. */
  196. #define LABEL_NEXTREF(REF) ((REF)->fld[1].rtx)
  197. /* Once basic blocks are found in flow.c,
  198. Each LABEL_REF points to its containing instruction with this field. */
  199. #define CONTAINING_INSN(RTX) ((RTX)->fld[2].rtx)
  200. /* For a REG rtx, REGNO extracts the register number. */
  201. #define REGNO(RTX) ((RTX)->fld[0].rtint)
  202. /* For a CONST_INT rtx, INTVAL extracts the integer. */
  203. #define INTVAL(RTX) ((RTX)->fld[0].rtint)
  204. /* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of.
  205. SUBREG_WORD extracts the word-number. */
  206. #define SUBREG_REG(RTX) ((RTX)->fld[0].rtx)
  207. #define SUBREG_WORD(RTX) ((RTX)->fld[1].rtint)
  208. /* For a SET rtx, SET_DEST is the place that is set
  209. and SET_SRC is the value it is set to. */
  210. #define SET_DEST(RTX) ((RTX)->fld[0].rtx)
  211. #define SET_SRC(RTX) ((RTX)->fld[1].rtx)
  212. /* Generally useful functions. */
  213. extern rtx rtx_alloc ();
  214. extern rtvec rtvec_alloc ();
  215. extern rtx gen_rtx ();
  216. extern rtx copy_rtx ();
  217. extern rtvec gen_rtvec ();
  218. extern rtvec gen_rtvec_v ();
  219. extern rtx gen_reg_rtx ();
  220. extern rtx gen_label_rtx ();
  221. extern rtx gen_lowpart ();
  222. extern rtx gen_highpart ();
  223. extern int subreg_lowpart_p ();
  224. extern rtx memory_address ();
  225. extern rtx get_insns ();
  226. extern rtx get_last_insn ();
  227. extern rtx expand_expr ();
  228. extern rtx output_constant_def ();
  229. extern rtx immed_real_const ();
  230. extern rtx force_const_double_mem ();
  231. extern rtx get_parm_real_loc ();
  232. extern rtx assign_stack_local ();
  233. extern rtx protect_from_queue ();
  234. extern void emit_queue ();
  235. extern rtx emit_insn ();
  236. extern rtx emit_jump_insn ();
  237. extern rtx emit_call_insn ();
  238. extern rtx emit_insn_before ();
  239. extern rtx emit_insn_after ();
  240. extern void emit_label ();
  241. extern void emit_barrier ();
  242. extern void emit_note ();
  243. extern rtx prev_real_insn ();
  244. extern rtx next_real_insn ();
  245. extern rtx plus_constant ();
  246. extern rtx find_equiv_reg ();
  247. #ifdef BITS_PER_WORD
  248. /* Conditional is to detect when config.h has been included. */
  249. extern enum reg_class reg_preferred_class ();
  250. #endif
  251. /* Standard pieces of rtx, to be substituted directly into things. */
  252. extern rtx pc_rtx;
  253. extern rtx cc0_rtx;
  254. extern rtx const0_rtx;
  255. extern rtx const1_rtx;
  256. extern rtx fconst0_rtx;
  257. extern rtx dconst0_rtx;