386BSD 0.0 development
[unix-history] / usr / src / usr.bin / gcc / cc1 / rtl.h
CommitLineData
f149655f
WJ
1/* Register Transfer Language (RTL) definitions for GNU C-Compiler
2 Copyright (C) 1987 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21#undef FFS /* Some systems predefine this symbol; don't let it interfere. */
22
23/* Register Transfer Language EXPRESSIONS CODES */
24
25#define RTX_CODE enum rtx_code
26enum rtx_code {
27
28#define DEF_RTL_EXPR(ENUM, NAME, FORMAT) ENUM ,
29#include "rtl.def" /* rtl expressions are documented here */
30#undef DEF_RTL_EXPR
31
32 LAST_AND_UNUSED_RTX_CODE}; /* A convienent way to get a value for
33 NUM_RTX_CODE.
34 Assumes default enum value assignement. */
35
36#define NUM_RTX_CODE ((int)LAST_AND_UNUSED_RTX_CODE)
37 /* The cast here, saves many elsewhere. */
38
39extern int rtx_length[];
40#define GET_RTX_LENGTH(CODE) (rtx_length[(int)(CODE)])
41
42extern char *rtx_name[];
43#define GET_RTX_NAME(CODE) (rtx_name[(int)(CODE)])
44
45extern char *rtx_format[];
46#define GET_RTX_FORMAT(CODE) (rtx_format[(int)(CODE)])
47
48
49/* Get the definition of `enum machine_mode' */
50
51#ifndef HAVE_MACHINE_MODES
52
53#define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT, WIDER) SYM,
54
55enum machine_mode {
56#include "machmode.def"
57MAX_MACHINE_MODE };
58
59#undef DEF_MACHMODE
60
61#define HAVE_MACHINE_MODES
62
63#endif /* not HAVE_MACHINE_MODES */
64
65#ifndef NUM_MACHINE_MODES
66#define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE
67#endif
68
69/* Get the name of mode MODE as a string. */
70
71extern char *mode_name[];
72#define GET_MODE_NAME(MODE) (mode_name[(int)(MODE)])
73
74enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT,
75 MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MODE_FUNCTION };
76
77/* Get the general kind of object that mode MODE represents
78 (integer, floating, complex, etc.) */
79
80extern enum mode_class mode_class[];
81#define GET_MODE_CLASS(MODE) (mode_class[(int)(MODE)])
82
83/* Get the size in bytes of an object of mode MODE. */
84
85extern int mode_size[];
86#define GET_MODE_SIZE(MODE) (mode_size[(int)(MODE)])
87
88/* Get the size in bytes of the basic parts of an object of mode MODE. */
89
90extern int mode_unit_size[];
91#define GET_MODE_UNIT_SIZE(MODE) (mode_unit_size[(int)(MODE)])
92
93/* Get the size in bits of an object of mode MODE. */
94
95#define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int)(MODE)])
96
97/* Get a bitmask containing 1 for all bits in a word
98 that fit within mode MODE. */
99
100#define GET_MODE_MASK(MODE) \
101 ((GET_MODE_BITSIZE (MODE) >= HOST_BITS_PER_INT) \
102 ? -1 : ((1 << GET_MODE_BITSIZE (MODE)) - 1))
103
104/* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
105
106extern enum machine_mode mode_wider_mode[];
107#define GET_MODE_WIDER_MODE(MODE) (mode_wider_mode[(int)(MODE)])
108\f
109/* Common union for an element of an rtx. */
110
111typedef union rtunion_def
112{
113 int rtint;
114 char *rtstr;
115 struct rtx_def *rtx;
116 struct rtvec_def *rtvec;
117 enum machine_mode rttype;
118} rtunion;
119
120/* RTL expression ("rtx"). */
121
122typedef struct rtx_def
123{
124#ifdef SHORT_ENUM_BUG
125 unsigned short code;
126#else
127 /* The kind of expression this is. */
128 enum rtx_code code : 16;
129#endif
130 /* The kind of value the expression has. */
131 enum machine_mode mode : 8;
132 /* 1 in an INSN if it can alter flow of control
133 within this function. Not yet used! */
134 unsigned int jump : 1;
135 /* 1 in an INSN if it can call another function. Not yet used! */
136 unsigned int call : 1;
137 /* 1 in a MEM or REG if value of this expression will never change
138 during the current function, even though it is not
139 manifestly constant.
140 1 in a SYMBOL_REF if it addresses something in the per-function
141 constants pool. */
142 unsigned int unchanging : 1;
143 /* 1 in a MEM expression if contents of memory are volatile. */
144 /* 1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL or BARRIER
145 if it is deleted. */
146 /* 1 in a REG expression if corresponds to a variable declared by the user.
147 0 for an internally generated temporary. */
148 unsigned int volatil : 1;
149 /* 1 in a MEM referring to a field of a structure (not a union!).
150 0 if the MEM was a variable or the result of a * operator in C;
151 1 if it was the result of a . or -> operator (on a struct) in C. */
152 unsigned int in_struct : 1;
153 /* 1 if this rtx is used. This is used for copying shared structure.
154 See `unshare_all_rtl'.
155 This bit is used to detect that event. */
156 unsigned int used : 1;
157 /* Nonzero if this rtx came from procedure integration.
158 In a REG, nonzero means this reg refers to the return value
159 of the current function. */
160 unsigned integrated : 1;
161 /* The first element of the operands of this rtx.
162 The number of operands and their types are controlled
163 by the `code' field, according to rtl.def. */
164 rtunion fld[1];
165} *rtx;
166
167#define NULL_RTX (rtx) 0
168
169/* Define macros to access the `code' field of the rtx. */
170
171#ifdef SHORT_ENUM_BUG
172#define GET_CODE(RTX) ((enum rtx_code) ((RTX)->code))
173#define PUT_CODE(RTX, CODE) ((RTX)->code = ((short) (CODE)))
174#else
175#define GET_CODE(RTX) ((RTX)->code)
176#define PUT_CODE(RTX, CODE) ((RTX)->code = (CODE))
177#endif
178
179#define GET_MODE(RTX) ((RTX)->mode)
180#define PUT_MODE(RTX, MODE) ((RTX)->mode = (MODE))
181
182#define RTX_INTEGRATED_P(RTX) ((RTX)->integrated)
183#define RTX_UNCHANGING_P(RTX) ((RTX)->unchanging)
184
185/* RTL vector. These appear inside RTX's when there is a need
186 for a variable number of things. The principle use is inside
187 PARALLEL expressions. */
188
189typedef struct rtvec_def{
190 unsigned num_elem; /* number of elements */
191 rtunion elem[1];
192} *rtvec;
193
194#define NULL_RTVEC (rtvec) 0
195
196#define GET_NUM_ELEM(RTVEC) ((RTVEC)->num_elem)
197#define PUT_NUM_ELEM(RTVEC, NUM) ((RTVEC)->num_elem = (unsigned) NUM)
198
199/* 1 if X is a REG. */
200
201#define REG_P(X) (GET_CODE (X) == REG)
202
203/* 1 if X is a constant value that is an integer. */
204
205#define CONSTANT_P(X) \
206 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
207 || GET_CODE (X) == CONST_INT \
208 || GET_CODE (X) == CONST)
209
210/* General accessor macros for accessing the fields of an rtx. */
211
212#define XEXP(RTX, N) ((RTX)->fld[N].rtx)
213#define XINT(RTX, N) ((RTX)->fld[N].rtint)
214#define XSTR(RTX, N) ((RTX)->fld[N].rtstr)
215#define XVEC(RTX, N) ((RTX)->fld[N].rtvec)
216#define XVECLEN(RTX, N) ((RTX)->fld[N].rtvec->num_elem)
217#define XVECEXP(RTX,N,M)((RTX)->fld[N].rtvec->elem[M].rtx)
218\f
219/* ACCESS MACROS for particular fields of insns. */
220
221/* Holds a unique number for each insn.
222 These are not necessarily sequentially increasing. */
223#define INSN_UID(INSN) ((INSN)->fld[0].rtint)
224
225/* Chain insns together in sequence. */
226#define PREV_INSN(INSN) ((INSN)->fld[1].rtx)
227#define NEXT_INSN(INSN) ((INSN)->fld[2].rtx)
228
229/* The body of an insn. */
230#define PATTERN(INSN) ((INSN)->fld[3].rtx)
231
232/* Code number of instruction, from when it was recognized.
233 -1 means this instruction has not been recognized yet. */
234#define INSN_CODE(INSN) ((INSN)->fld[4].rtint)
235
236/* Set up in flow.c; empty before then.
237 Holds a chain of INSN_LIST rtx's whose first operands point at
238 previous insns with direct data-flow connections to this one.
239 That means that those insns set variables whose next use is in this insn.
240 They are always in the same basic block as this insn. */
241#define LOG_LINKS(INSN) ((INSN)->fld[5].rtx)
242
243/* 1 if insn has been deleted. */
244#define INSN_DELETED_P(INSN) ((INSN)->volatil)
245
246/* Holds a list of notes on what this insn does to various REGs.
247 It is a chain of EXPR_LIST rtx's, where the second operand
248 is the chain pointer and the first operand is the REG being described.
249 The mode field of the EXPR_LIST contains not a real machine mode
250 but a value that says what this note says about the REG:
251 REG_DEAD means that the REG dies in this insn.
252 REG_INC means that the REG is autoincremented or autodecremented.
253 Note that one insn can have both REG_DEAD and REG_INC for the same register
254 if the register is preincremented or predecremented in the insn
255 and not needed afterward. This can probably happen.
256 REG_EQUIV describes the insn as a whole; it says that the
257 insn sets a register to a constant value or to be equivalent to
258 a memory address. If the
259 register is spilled to the stack then the constant value
260 should be substituted for it. The contents of the REG_EQUIV
261 is the constant value or memory address, which may be different
262 from the source of the SET although it has the same value.
263 REG_EQUAL is like REG_EQUIV except that the destination
264 is only momentarily equal to the specified rtx. Therefore, it
265 cannot be used for substitution; but it can be used for cse.
266 REG_RETVAL means that this insn copies the return-value of
267 a library call out of the hard reg for return values. This note
268 is actually an INSN_LIST and it points to the first insn involved
269 in setting up arguments for the call. flow.c uses this to delete
270 the entire library call when its result is dead.
271 REG_LIBCALL is the inverse of REG_RETVAL: it goes on the first insn
272 of the library call and points at the one that has the REG_RETVAL.
273 REG_WAS_0 says that the register set in this insn held 0 before the insn.
274 The contents of the note is the insn that stored the 0.
275 If that insn is deleted or patched to a NOTE, the REG_WAS_0 is inoperative.
276 The REG_WAS_0 note is actually an INSN_LIST, not an EXPR_LIST.
277 REG_NONNEG means that the register is always nonnegative during
278 the containing loop. This is used in branches so that decrement and
279 branch instructions terminating on zero can be matched.
280 REG_UNSET identifies a pseudo-reg used in this insn and never set. */
281
282#define REG_NOTES(INSN) ((INSN)->fld[6].rtx)
283
284/* Don't forget to change reg_note_name in rtl.c. */
285enum reg_note { REG_DEAD = 1, REG_INC = 2, REG_EQUIV = 3, REG_WAS_0 = 4,
286 REG_EQUAL = 5, REG_RETVAL = 6, REG_LIBCALL = 7,
287 REG_NONNEG = 8, REG_UNSET = 9 };
288
289/* Extract the reg-note kind from an EXPR_LIST. */
290#define REG_NOTE_KIND(LINK) ((enum reg_note) GET_MODE (LINK))
291
292/* Names for REG_NOTE's in EXPR_LIST insn's. */
293
294extern char *reg_note_name[];
295#define GET_REG_NOTE_NAME(MODE) (reg_note_name[(int)(MODE)])
296
297/* The label-number of a code-label. The assembler label
298 is made from `L' and the label-number printed in decimal.
299 Label numbers are unique in a compilation. */
300#define CODE_LABEL_NUMBER(INSN) ((INSN)->fld[3].rtint)
301
302#define LINE_NUMBER NOTE
303
304/* In a NOTE that is a line number, this is a string for the file name
305 that the line is in. */
306
307#define NOTE_SOURCE_FILE(INSN) ((INSN)->fld[3].rtstr)
308
309/* In a NOTE that is a line number, this is the line number.
310 Other kinds of NOTEs are identified by negative numbers here. */
311#define NOTE_LINE_NUMBER(INSN) ((INSN)->fld[4].rtint)
312
313/* Codes that appear in the NOTE_LINE_NUMBER field
314 for kinds of notes that are not line numbers. */
315
316/* This note indicates the end of the real body of the function,
317 after moving the parms into their homes, etc. */
318#define NOTE_INSN_FUNCTION_BEG 0
319
320/* This note is used to get rid of an insn
321 when it isn't safe to patch the insn out of the chain. */
322#define NOTE_INSN_DELETED -1
323#define NOTE_INSN_BLOCK_BEG -2
324#define NOTE_INSN_BLOCK_END -3
325#define NOTE_INSN_LOOP_BEG -4
326#define NOTE_INSN_LOOP_END -5
327/* This kind of note is generated at the end of the function body,
328 just before the return insn or return label.
329 In an optimizing compilation it is deleted by the first jump optimization,
330 after enabling that optimizer to determine whether control can fall
331 off the end of the function body without a return statement. */
332#define NOTE_INSN_FUNCTION_END -6
333/* This kind of note is generated just after each call to `setjmp', et al. */
334#define NOTE_INSN_SETJMP -7
335/* Generated at the place in a loop that `continue' jumps to. */
336#define NOTE_INSN_LOOP_CONT -8
337/* Don't forget to change note_insn_name in rtl.c. */
338
339#define NOTE_DECL_NAME(INSN) ((INSN)->fld[3].rtstr)
340#define NOTE_DECL_CODE(INSN) ((INSN)->fld[4].rtint)
341#define NOTE_DECL_RTL(INSN) ((INSN)->fld[5].rtx)
342#define NOTE_DECL_IDENTIFIER(INSN) ((INSN)->fld[6].rtint)
343#define NOTE_DECL_TYPE(INSN) ((INSN)->fld[7].rtint)
344
345/* Names for NOTE insn's other than line numbers. */
346
347extern char *note_insn_name[];
348#define GET_NOTE_INSN_NAME(NOTE_CODE) (note_insn_name[-(NOTE_CODE)])
349
350/* In jump.c, each label contains a count of the number
351 of LABEL_REFs that point at it, so unused labels can be deleted. */
352#define LABEL_NUSES(LABEL) ((LABEL)->fld[4].rtint)
353
354/* In jump.c, each JUMP_INSN can point to a label that it can jump to,
355 so that if the JUMP_INSN is deleted, the label's LABEL_NUSES can
356 be decremented and possibly the label can be deleted. */
357#define JUMP_LABEL(INSN) ((INSN)->fld[7].rtx)
358
359/* Once basic blocks are found in flow.c,
360 each CODE_LABEL starts a chain that goes through
361 all the LABEL_REFs that jump to that label.
362 The chain eventually winds up at the CODE_LABEL; it is circular. */
363#define LABEL_REFS(LABEL) ((LABEL)->fld[4].rtx)
364\f
365/* This is the field in the LABEL_REF through which the circular chain
366 of references to a particular label is linked.
367 This chain is set up in flow.c. */
368
369#define LABEL_NEXTREF(REF) ((REF)->fld[1].rtx)
370
371/* Once basic blocks are found in flow.c,
372 Each LABEL_REF points to its containing instruction with this field. */
373
374#define CONTAINING_INSN(RTX) ((RTX)->fld[2].rtx)
375
376/* For a REG rtx, REGNO extracts the register number. */
377
378#define REGNO(RTX) ((RTX)->fld[0].rtint)
379
380/* For a REG rtx, REG_FUNCTION_VALUE_P is nonzero if the reg
381 is the current function's return value. */
382
383#define REG_FUNCTION_VALUE_P(RTX) ((RTX)->integrated)
384
385/* 1 in a REG rtx if it corresponds to a variable declared by the user. */
386#define REG_USERVAR_P(RTX) ((RTX)->volatil)
387
388/* For a CONST_INT rtx, INTVAL extracts the integer. */
389
390#define INTVAL(RTX) ((RTX)->fld[0].rtint)
391
392/* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of.
393 SUBREG_WORD extracts the word-number. */
394
395#define SUBREG_REG(RTX) ((RTX)->fld[0].rtx)
396#define SUBREG_WORD(RTX) ((RTX)->fld[1].rtint)
397
398/* Access various components of an ASM_OPERANDS rtx. */
399
400#define ASM_OPERANDS_TEMPLATE(RTX) XSTR ((RTX), 0)
401#define ASM_OPERANDS_OUTPUT_CONSTRAINT(RTX) XSTR ((RTX), 1)
402#define ASM_OPERANDS_OUTPUT_IDX(RTX) XINT ((RTX), 2)
403#define ASM_OPERANDS_INPUT_VEC(RTX) XVEC ((RTX), 3)
404#define ASM_OPERANDS_INPUT_CONSTRAINT_VEC(RTX) XVEC ((RTX), 4)
405#define ASM_OPERANDS_INPUT(RTX, N) XVECEXP ((RTX), 3, (N))
406#define ASM_OPERANDS_INPUT_CONSTRAINT(RTX, N) XSTR (XVECEXP ((RTX), 4, (N)), 0)
407#define ASM_OPERANDS_INPUT_MODE(RTX, N) GET_MODE (XVECEXP ((RTX), 4, (N)))
408#define ASM_OPERANDS_SOURCE_FILE(RTX) XSTR ((RTX), 5)
409#define ASM_OPERANDS_SOURCE_LINE(RTX) XINT ((RTX), 6)
410
411/* For a MEM rtx, 1 if it's a volatile reference.
412 Also in an ASM_OPERANDS rtx. */
413#define MEM_VOLATILE_P(RTX) ((RTX)->volatil)
414
415/* For a MEM rtx, 1 if it refers to a structure or union component. */
416#define MEM_IN_STRUCT_P(RTX) ((RTX)->in_struct)
417
418/* For a SET rtx, SET_DEST is the place that is set
419 and SET_SRC is the value it is set to. */
420#define SET_DEST(RTX) ((RTX)->fld[0].rtx)
421#define SET_SRC(RTX) ((RTX)->fld[1].rtx)
422
423/* 1 in a SYMBOL_REF if it addresses this function's constants pool. */
424#define CONSTANT_POOL_ADDRESS_P(RTX) ((RTX)->unchanging)
425/* 1 in a SYMBOL_REF if it is the name of an external symbol. */
426#define EXTERNAL_SYMBOL_P(RTX) ((RTX)->volatil)
427
428/* For an INLINE_HEADER rtx, FIRST_FUNCTION_INSN is the first insn
429 of the function that is not involved in copying parameters to
430 pseudo-registers. FIRST_PARM_INSN is the very first insn of
431 the function, including the parameter copying.
432 We keep this around in case we must splice
433 this function into the assembly code at the end of the file.
434 FIRST_LABELNO is the first label number used by the function (inclusive).
435 LAST_LABELNO is the last label used by the function (exclusive).
436 MAX_REGNUM is the largest pseudo-register used by that function.
437
438 We want this to lay down like an INSN. The PREV_INSN field
439 is always NULL. The NEXT_INSN field always points to the
440 first function insn of the function being squirreled away. */
441
442#define FIRST_FUNCTION_INSN(RTX) ((RTX)->fld[2].rtx)
443#define FIRST_PARM_INSN(RTX) ((RTX)->fld[3].rtx)
444#define FIRST_LABELNO(RTX) ((RTX)->fld[4].rtint)
445#define LAST_LABELNO(RTX) ((RTX)->fld[5].rtint)
446#define MAX_PARMREG(RTX) ((RTX)->fld[6].rtint)
447#define MAX_REGNUM(RTX) ((RTX)->fld[7].rtint)
448#define FUNCTION_ARGS_SIZE(RTX) ((RTX)->fld[8].rtint)
449\f
450/* Generally useful functions. */
451
452extern rtx rtx_alloc ();
453extern rtvec rtvec_alloc ();
454extern rtx find_reg_note ();
455extern rtx gen_rtx ();
456extern rtx copy_rtx ();
457extern rtvec gen_rtvec ();
458extern rtvec gen_rtvec_v ();
459extern rtx gen_reg_rtx ();
460extern rtx gen_label_rtx ();
461extern rtx gen_inline_header_rtx ();
462extern rtx gen_lowpart ();
463extern rtx gen_highpart ();
464extern int subreg_lowpart_p ();
465extern rtx make_safe_from ();
466extern rtx memory_address ();
467extern rtx get_insns ();
468extern rtx get_last_insn ();
469extern rtx start_sequence ();
470extern rtx gen_sequence ();
471extern rtx expand_expr ();
472extern rtx output_constant_def ();
473extern rtx immed_real_const ();
474extern rtx immed_real_const_1 ();
475extern rtx immed_double_const ();
476extern rtx force_const_double_mem ();
477extern rtx force_const_mem ();
478extern rtx get_parm_real_loc ();
479extern rtx assign_stack_local ();
480extern rtx protect_from_queue ();
481extern void emit_queue ();
482extern rtx emit_move_insn ();
483extern rtx emit_insn ();
484extern rtx emit_jump_insn ();
485extern rtx emit_call_insn ();
486extern rtx emit_call_insn_before ();
487extern rtx emit_insn_before ();
488extern rtx emit_insn_after ();
489extern rtx emit_label ();
490extern rtx emit_barrier ();
491extern rtx emit_barrier_after ();
492extern rtx emit_note ();
493extern rtx emit_line_note ();
494extern rtx emit_line_note_force ();
495extern rtx prev_real_insn ();
496extern rtx next_real_insn ();
497extern rtx next_nondeleted_insn ();
498extern rtx plus_constant ();
499extern rtx find_equiv_reg ();
500extern rtx delete_insn ();
501extern rtx adj_offsettable_operand ();
502
503/* Maximum number of parallel sets and clobbers in any insn in this fn.
504 Always at least 3, since the combiner could put that many togetherm
505 and we want this to remain correct for all the remaining passes. */
506
507extern int max_parallel;
508
509extern int asm_noperands ();
510extern char *decode_asm_operands ();
511
512#ifdef BITS_PER_WORD
513/* Conditional is to detect when config.h has been included. */
514extern enum reg_class reg_preferred_class ();
515#endif
516
517extern rtx get_first_nonparm_insn ();
518
519/* Standard pieces of rtx, to be substituted directly into things. */
520extern rtx pc_rtx;
521extern rtx cc0_rtx;
522extern rtx const0_rtx;
523extern rtx const1_rtx;
524extern rtx fconst0_rtx;
525extern rtx dconst0_rtx;
526
527/* Returns a constant 0 rtx in mode MODE. */
528
529#define CONST0_RTX(MODE) \
530 ((MODE == SFmode) ? fconst0_rtx \
531 : ((MODE == DFmode) ? dconst0_rtx \
532 : ((GET_MODE_CLASS (MODE) == MODE_INT) ? const0_rtx \
533 : (abort (), NULL_RTX))))
534
535/* All references to certain hard regs, except those created
536 by allocating pseudo regs into them (when that's possible),
537 go through these unique rtx objects. */
538extern rtx stack_pointer_rtx;
539extern rtx frame_pointer_rtx;
540extern rtx arg_pointer_rtx;
541extern rtx struct_value_rtx;
542extern rtx struct_value_incoming_rtx;
543extern rtx static_chain_rtx;
544extern rtx static_chain_incoming_rtx;