1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 1987 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
27 /* Macros to access the slots of a QUEUED rtx.
28 Here rather than in rtl.h because only the expansion pass
29 should ever encounter a QUEUED. */
31 /* The variable for which an increment is queued. */
32 #define QUEUED_VAR(P) XEXP (P, 0)
33 /* If the increment has been emitted, this is the insn
34 that does the increment. It is zero before the increment is emitted. */
35 #define QUEUED_INSN(P) XEXP (P, 1)
36 /* If a pre-increment copy has been generated, this is the copy
37 (it is a temporary reg). Zero if no copy made yet. */
38 #define QUEUED_COPY(P) XEXP (P, 2)
39 /* This is the body to use for the insn to do the increment.
40 It is used to emit the increment. */
41 #define QUEUED_BODY(P) XEXP (P, 3)
42 /* Next QUEUED in the queue. */
43 #define QUEUED_NEXT(P) XEXP (P, 4)
45 /* This is the 4th arg to `expand_expr'.
46 EXPAND_SUM means it is ok to return a PLUS rtx or MULT rtx.
47 EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address
48 is a constant that is not a legitimate address.
49 EXPAND_INTO_STACK means that if a temporary value needs to be
50 created, it should be done so that it lasts the life of
51 the call. This can be implemented either by returning
52 a pointer to a slot which is actually allocated on the stack,
53 or by returning a temporary in the callers frame. */
54 enum expand_modifier
{EXPAND_NORMAL
, EXPAND_SUM
, EXPAND_CONST_ADDRESS
,
57 /* If this is nonzero, we do not bother generating VOLATILE
58 around volatile memory references, and we are willing to
59 output indirect addresses. If cse is to follow, we reject
60 indirect addresses so a useful potential cse is generated;
61 if it is used only once, instruction combination will produce
62 the same indirect address eventually. */
63 extern int cse_not_expected
;
65 /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
66 So we can mark them all live at the end of the function, if stupid. */
67 extern rtx save_expr_regs
;
69 extern int current_function_calls_alloca
;
71 /* Nonzero means stack pops must not be deferred, and deferred stack
72 pops must not be output. It is nonzero inside a function call,
73 inside a conditional expression, inside a statement expression,
74 and in other cases as well. */
75 extern int inhibit_defer_pop
;
77 /* Number of function calls seen so far in current function. */
79 extern int function_call_count
;
81 /* RTX for stack slot that holds the current handler for nonlocal gotos.
82 Zero when function does not have nonlocal labels. */
84 extern rtx nonlocal_goto_handler_slot
;
86 /* RTX for stack slot that holds the stack pointer value to restore
88 Zero when function does not have nonlocal labels. */
90 extern rtx nonlocal_goto_stack_level
;
92 /* List (chain of TREE_LIST) of LABEL_DECLs for all nonlocal labels
93 (labels to which there can be nonlocal gotos from nested functions)
96 #ifdef TREE_CODE /* Don't lose if tree.h not included. */
97 extern tree nonlocal_labels
;
100 #define NO_DEFER_POP (inhibit_defer_pop += 1)
101 #define OK_DEFER_POP (inhibit_defer_pop -= 1)
103 /* Number of units that we should eventually pop off the stack.
104 These are the arguments to function calls that have already returned. */
105 extern int pending_stack_adjust
;
107 /* A list of all cleanups which belong to the arguments of
108 function calls being expanded by expand_call. */
109 #ifdef TREE_CODE /* Don't lose if tree.h not included. */
110 extern tree cleanups_this_call
;
113 /* Sequence of insns which must be emitted *prior* to calling
114 __builtin_saveregs. */
115 rtx save_from_saveregs
;
117 #ifdef TREE_CODE /* Don't lose if tree.h not included. */
118 /* Structure to record the size of a sequence of arguments
119 as the sum of a tree-expression and a constant. */
128 /* Add the value of the tree INC to the `struct args_size' TO. */
130 #define ADD_PARM_SIZE(TO, INC) \
131 { tree inc = (INC); \
132 if (TREE_CODE (inc) == INTEGER_CST) \
133 (TO).constant += TREE_INT_CST_LOW (inc); \
134 else if ((TO).var == 0) \
137 (TO).var = genop (PLUS_EXPR, (TO).var, inc); }
139 #define SUB_PARM_SIZE(TO, DEC) \
140 { tree dec = (DEC); \
141 if (TREE_CODE (dec) == INTEGER_CST) \
142 (TO).constant -= TREE_INT_CST_LOW (dec); \
143 else if ((TO).var == 0) \
144 (TO).var = genop (MINUS_EXPR, integer_zero_node, dec); \
146 (TO).var = genop (MINUS_EXPR, (TO).var, dec); }
148 /* Convert the implicit sum in a `struct args_size' into an rtx. */
149 #define ARGS_SIZE_RTX(SIZE) \
150 ((SIZE).var == 0 ? gen_rtx (CONST_INT, VOIDmode, (SIZE).constant) \
151 : plus_constant (expand_expr ((SIZE).var, 0, VOIDmode, 0), \
154 /* Supply a default definition for FUNCTION_ARG_PADDING:
155 usually pad upward, but pad short args downward on big-endian machines. */
157 enum direction
{none
, upward
, downward
}; /* Value has this type. */
159 #ifndef FUNCTION_ARG_PADDING
160 #ifdef BYTES_BIG_ENDIAN
161 #define FUNCTION_ARG_PADDING(mode, size) \
162 (((mode) == BLKmode \
163 ? (GET_CODE (size) == CONST_INT \
164 && INTVAL (size) < PARM_BOUNDARY / BITS_PER_UNIT) \
165 : GET_MODE_BITSIZE (mode) < PARM_BOUNDARY) \
168 #define FUNCTION_ARG_PADDING(mode, size) upward
172 /* Nonzero if type TYPE should be returned in memory
173 (even though its mode is not BLKmode).
174 Most machines can use the following default definition. */
176 #ifndef RETURN_IN_MEMORY
177 #define RETURN_IN_MEMORY(type) 0
180 /* Optabs are tables saying how to generate insn bodies
181 for various machine modes and numbers of operands.
182 Each optab applies to one operation.
183 For example, add_optab applies to addition.
185 The insn_code slot is the enum insn_code that says how to
186 generate an insn for this operation on a particular machine mode.
187 It is CODE_FOR_nothing if there is no such insn on the target machine.
189 The `lib_call' slot is the name of the library function that
190 can be used to perform the operation.
192 A few optabs, such as move_optab and cmp_optab, are used
195 /* Everything that uses expr.h needs to define enum insn_code
196 but we don't list it in the Makefile dependencies just for that. */
197 #include "insn-codes.h"
203 enum insn_code insn_code
;
205 } handlers
[NUM_MACHINE_MODES
];
208 /* Given an enum insn_code, access the function to construct
209 the body of that kind of insn. */
210 #define GEN_FCN(CODE) (*insn_gen_function[(int) (CODE)])
211 extern rtx (*const insn_gen_function
[]) ();
213 extern optab add_optab
;
214 extern optab sub_optab
;
215 extern optab smul_optab
; /* Signed multiply */
216 extern optab smul_widen_optab
; /* Signed multiply with result
217 one machine mode wider than args */
218 extern optab umul_widen_optab
;
219 extern optab sdiv_optab
; /* Signed divide */
220 extern optab sdivmod_optab
; /* Signed divide-and-remainder in one */
221 extern optab udiv_optab
;
222 extern optab udivmod_optab
;
223 extern optab smod_optab
; /* Signed remainder */
224 extern optab umod_optab
;
225 extern optab flodiv_optab
; /* Optab for floating divide. */
226 extern optab ftrunc_optab
; /* Convert float to integer in float fmt */
227 extern optab and_optab
; /* Logical and */
228 extern optab ior_optab
; /* Logical or */
229 extern optab xor_optab
; /* Logical xor */
230 extern optab ashl_optab
; /* Arithmetic shift left */
231 extern optab ashr_optab
; /* Arithmetic shift right */
232 extern optab lshl_optab
; /* Logical shift left */
233 extern optab lshr_optab
; /* Logical shift right */
234 extern optab rotl_optab
; /* Rotate left */
235 extern optab rotr_optab
; /* Rotate right */
237 extern optab mov_optab
; /* Move instruction. */
238 extern optab movstrict_optab
; /* Move, preserving high part of register. */
240 extern optab cmp_optab
; /* Compare insn; two operands. */
241 extern optab tst_optab
; /* tst insn; compare one operand against 0 */
243 /* Unary operations */
244 extern optab neg_optab
; /* Negation */
245 extern optab abs_optab
; /* Abs value */
246 extern optab one_cmpl_optab
; /* Bitwise not */
247 extern optab ffs_optab
; /* Find first bit set */
249 /* Passed to expand_binop and expand_unop to say which options to try to use
250 if the requested operation can't be open-coded on the requisite mode.
251 Either OPTAB_LIB or OPTAB_LIB_WIDEN says try using a library call.
252 Either OPTAB_WIDEN or OPTAB_LIB_WIDEN says try using a wider mode.
253 OPTAB_MUST_WIDEN says try widening and don't try anything else. */
264 typedef rtx (*rtxfun
) ();
266 /* Indexed by the rtx-code for a conditional (eg. EQ, LT,...)
267 gives the gen_function to make a branch to test that condition. */
269 extern rtxfun bcc_gen_fctn
[NUM_RTX_CODE
];
271 /* Indexed by the rtx-code for a conditional (eg. EQ, LT,...)
272 gives the gen_function to make a store-condition insn
273 to test that condition. */
275 extern rtxfun setcc_gen_fctn
[NUM_RTX_CODE
];
277 /* Expand a binary operation given optab and rtx operands. */
280 /* Expand a binary operation with both signed and unsigned forms. */
281 rtx
sign_expand_binop ();
283 /* Expand a unary arithmetic operation given optab rtx operand. */
286 /* Arguments MODE, RTX: return an rtx for the negation of that value.
290 /* Initialize the tables that control conversion between fixed and
293 void init_floattab ();
295 /* Generate code for a FIX_EXPR. */
298 /* Generate code for a FLOAT_EXPR. */
299 void expand_float ();
301 /* Create but don't emit one rtl instruction to add one rtx into another.
303 Likewise for subtraction and for just copying.
304 These do not call protect_from_queue; caller must do so. */
305 rtx
gen_add2_insn ();
306 rtx
gen_sub2_insn ();
307 rtx
gen_move_insn ();
309 /* Emit one rtl instruction to store zero in specified rtx. */
310 void emit_clr_insn ();
312 /* Emit one rtl insn to store 1 in specified rtx assuming it contains 0. */
313 void emit_0_to_1_insn ();
315 /* Emit one rtl insn to compare two rtx's. */
316 void emit_cmp_insn ();
318 /* Emit some rtl insns to move data between rtx's, converting machine modes.
319 Both modes must be floating or both fixed. */
320 void convert_move ();
322 /* Convert an rtx to specified machine mode and return the result. */
323 rtx
convert_to_mode ();
325 /* Emit code to push some arguments and call a library routine,
326 storing the value in a specified place. Calling sequence is
328 void emit_library_call ();
330 /* Given an rtx that may include add and multiply operations,
331 generate them as insns and return a pseudo-reg containing the value.
332 Useful after calling expand_expr with 1 as sum_ok. */
333 rtx
force_operand ();
335 /* Return an rtx for the size in bytes of the value of an expr. */
338 /* Return an rtx for the sum of an rtx and an integer. */
339 rtx
plus_constant ();
341 rtx
lookup_static_chain ();
343 /* Return an rtx like arg but sans any constant terms.
344 Returns the original rtx if it has no constant terms.
345 The constant terms are added and stored via a second arg. */
346 rtx
eliminate_constant_term ();
348 /* Convert arg to a valid memory address for specified machine mode,
349 by emitting insns to perform arithmetic if nec. */
350 rtx
memory_address ();
352 /* Like `memory_address' but pretent `flag_force_addr' is 0. */
353 rtx
memory_address_noforce ();
355 /* Return a memory reference like MEMREF, but with its mode changed
356 to MODE and its address changed to ADDR.
357 (VOIDmode means don't change the mode.
358 NULL for ADDR means don't change the address.) */
359 rtx
change_address ();
362 /* Convert a stack slot address ADDR valid in function FNDECL
363 into an address valid in this function (using a static chain). */
364 rtx
fix_lexical_addr ();
366 /* Return the address of the trampoline for entering nested fn FUNCTION. */
367 rtx
trampoline_address ();
369 /* Assemble the static constant template for function entry trampolines. */
370 rtx
assemble_trampoline_template ();
373 /* Return 1 if two rtx's are equivalent in structure and elements. */
376 /* Given rtx, return new rtx whose address won't be affected by
377 any side effects. It has been copied to a new temporary reg. */
380 /* Given an rtx, copy all regs it refers to into new temps
381 and return a modified copy that refers to the new temps. */
382 rtx
copy_all_regs ();
384 /* Copy given rtx to a new temp reg and return that. */
387 /* Like copy_to_reg but always make the reg Pmode. */
388 rtx
copy_addr_to_reg ();
390 /* Like copy_to_reg but always make the reg the specified mode MODE. */
391 rtx
copy_to_mode_reg ();
393 /* Copy given rtx to given temp reg and return that. */
394 rtx
copy_to_suggested_reg ();
396 /* Copy a value to a register if it isn't already a register.
397 Args are mode (in case value is a constant) and the value. */
400 /* Return given rtx, copied into a new temp reg if it was in memory. */
401 rtx
force_not_mem ();
403 /* Remove some bytes from the stack. An rtx says how many. */
404 void adjust_stack ();
406 /* Add some bytes to the stack. An rtx says how many. */
407 void anti_adjust_stack ();
409 /* Emit code to copy function value to a new temp reg and return that reg. */
410 rtx
function_value ();
412 /* Return an rtx that refers to the value returned by a function
413 in its original home. This becomes invalid if any more code is emitted. */
414 rtx
hard_function_value ();
416 /* Return an rtx that refers to the value returned by a library call
417 in its original home. This becomes invalid if any more code is emitted. */
418 rtx
hard_libcall_value ();
420 /* Emit code to copy function value to a specified place. */
421 void copy_function_value ();
423 /* Given an rtx, return an rtx for a value rounded up to a multiple
424 of STACK_BOUNDARY / BITS_PER_UNIT. */
427 /* Push a block of length SIZE (perhaps variable)
428 and return an rtx to address the beginning of the block. */
431 /* Generate code for computing expression EXP,
432 and storing the value into TARGET.
433 If SUGGEST_REG is nonzero, copy the value through a register
434 and return that register, if that is possible. */
437 rtx
prepare_call_address ();
441 void emit_block_move ();
442 void emit_push_insn ();
444 void move_block_to_reg ();
446 rtx
store_bit_field ();
447 rtx
extract_bit_field ();
450 rtx
expand_divmod ();
451 rtx
expand_mult_add ();
452 rtx
get_structure_value_addr ();
453 rtx
expand_stmt_expr ();
454 rtx
emit_no_conflict_block ();
460 rtx
assemble_static_space ();
462 /* Needed for old compiler. */
463 rtx
expand_bit_and ();