|
|
1.1 root 1: /* Expands front end tree to back end RTL for GNU C-Compiler
1.1.1.2 root 2: Copyright (C) 1987,1988 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
6: GNU CC is distributed in the hope that it will be useful,
7: but WITHOUT ANY WARRANTY. No author or distributor
8: accepts responsibility to anyone for the consequences of using it
9: or for whether it serves any particular purpose or works at all,
10: unless he says so in writing. Refer to the GNU CC General Public
11: License for full details.
12:
13: Everyone is granted permission to copy, modify and redistribute
14: GNU CC, but only under the conditions described in the
15: GNU CC General Public License. A copy of this license is
16: supposed to have been given to you along with GNU CC so you
17: can know your rights and responsibilities. It should be in a
18: file named COPYING. Among other things, the copyright notice
19: and this notice must be preserved on all copies. */
20:
21:
22: /* This file handles the generation of rtl code from tree structure
1.1.1.2 root 23: above the level of expressions, using subroutines in exp*.c and emit-rtl.c.
1.1 root 24: It also creates the rtl expressions for parameters and auto variables
25: and has full responsibility for allocating stack slots.
26:
1.1.1.2 root 27: The functions whose names start with `expand_' are called by the
28: parser to generate RTL instructions for various kinds of constructs.
29:
30: Some control and binding constructs require calling several such
31: functions at different times. For example, a simple if-then
32: is expanded by calling `expand_start_cond' (with the condition-expression
33: as argument) before parsing the then-clause and calling `expand_end_cond'
34: after parsing the then-clause.
35:
36: `expand_start_function' is called at the beginning of a function,
37: before the function body is parsed, and `expand_end_function' is
38: called after parsing the body.
39:
40: Call `assign_stack_local' to allocate a stack slot for a local variable.
41: This is usually done during the RTL generation for the function body,
42: but it can also be done in the reload pass when a pseudo-register does
43: not get a hard register.
44:
45: Call `put_var_into_stack' when you learn, belatedly, that a variable
46: previously given a pseudo-register must in fact go in the stack.
47: This function changes the DECL_RTL to be a stack slot instead of a reg
48: then scans all the RTL instructions so far generated to correct them. */
1.1 root 49:
50: #include "config.h"
51:
52: #include <stdio.h>
53:
54: #include "rtl.h"
55: #include "tree.h"
1.1.1.2 root 56: #include "flags.h"
1.1 root 57: #include "insn-flags.h"
1.1.1.2 root 58: #include "insn-config.h"
1.1 root 59: #include "expr.h"
1.1.1.2 root 60: #include "regs.h"
1.1 root 61:
62: #define MAX(x,y) (((x) > (y)) ? (x) : (y))
63: #define MIN(x,y) (((x) < (y)) ? (x) : (y))
64:
1.1.1.2 root 65: /* Nonzero if function being compiled pops its args on return.
66: May affect compilation of return insn or of function epilogue. */
67:
68: int current_function_pops_args;
69:
70: /* If function's args have a fixed size, this is that size, in bytes.
71: Otherwise, it is -1.
72: May affect compilation of return insn or of function epilogue. */
73:
74: int current_function_args_size;
75:
76: /* # bytes the prologue should push and pretend that the caller pushed them.
77: The prologue must do this, but only if parms can be passed in registers. */
78:
79: int current_function_pretend_args_size;
80:
81: /* Name of function now being compiled. */
82:
83: char *current_function_name;
84:
1.1 root 85: /* Label that will go on function epilogue.
86: Jumping to this label serves as a "return" instruction
87: on machines which require execution of the epilogue on all returns. */
88:
1.1.1.2 root 89: rtx return_label;
1.1 root 90:
1.1.1.5 root 91: /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
92: So we can mark them all live at the end of the function, if nonopt. */
93: rtx save_expr_regs;
94:
95: /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
96: static rtx parm_birth_insn;
97:
1.1 root 98: /* The FUNCTION_DECL node for the function being compiled. */
99:
100: static tree this_function;
101:
102: /* Offset to end of allocated area of stack frame.
103: If stack grows down, this is the address of the last stack slot allocated.
104: If stack grows up, this is the address for the next slot. */
105: static int frame_offset;
106:
1.1.1.2 root 107: /* Nonzero if a stack slot has been generated whose address is not
108: actually valid. It means that the generated rtl must all be scanned
109: to detect and correct the invalid addresses where they occur. */
110: static int invalid_stack_slot;
1.1 root 111:
112: /* Label to jump back to for tail recursion, or 0 if we have
113: not yet needed one for this function. */
114: static rtx tail_recursion_label;
115:
116: /* Place after which to insert the tail_recursion_label if we need one. */
117: static rtx tail_recursion_reentry;
118:
1.1.1.2 root 119: /* Each time we expand an expression-statement,
120: record the expr's type and its RTL value here. */
121:
122: static tree last_expr_type;
123: static rtx last_expr_value;
124:
1.1.1.6 ! root 125: static void expand_goto_internal ();
! 126: static int expand_fixup ();
1.1.1.2 root 127: static void fixup_gotos ();
1.1 root 128: static int tail_recursion_args ();
1.1.1.2 root 129: void fixup_stack_slots ();
130: static rtx fixup_stack_1 ();
131: static rtx fixup_memory_subreg ();
132: static void fixup_var_refs ();
133: static rtx fixup_var_refs_1 ();
134: static rtx parm_stack_loc ();
135: static void optimize_bit_field ();
136: void do_jump_if_equal ();
1.1 root 137:
1.1.1.2 root 138: /* Stack of control and binding constructs we are currently inside.
1.1 root 139:
1.1.1.2 root 140: These constructs begin when you call `expand_start_WHATEVER'
141: and end when you call `expand_end_WHATEVER'. This stack records
142: info about how the construct began that tells the end-function
143: what to do. It also may provide information about the construct
144: to alter the behavior of other constructs within the body.
145: For example, they may affect the behavior of C `break' and `continue'.
146:
147: Each construct gets one `struct nesting' object.
148: All of these objects are chained through the `all' field.
149: `nesting_stack' points to the first object (innermost construct).
150: The position of an entry on `nesting_stack' is in its `depth' field.
151:
152: Each type of construct has its own individual stack.
153: For example, loops have `loop_stack'. Each object points to the
154: next object of the same type through the `next' field.
155:
156: Some constructs are visible to `break' exit-statements and others
157: are not. Which constructs are visible depends on the language.
158: Therefore, the data structure allows each construct to be visible
159: or not, according to the args given when the construct is started.
160: The construct is visible if the `exit_label' field is non-null.
161: In that case, the value should be a CODE_LABEL rtx. */
162:
163: struct nesting
1.1 root 164: {
1.1.1.2 root 165: struct nesting *all;
166: struct nesting *next;
167: int depth;
168: rtx exit_label;
169: union
170: {
171: /* For conds (if-then and if-then-else statements). */
172: struct
173: {
174: /* Label on the else-part, if any, else 0. */
175: rtx else_label;
176: /* Label at the end of the whole construct. */
177: rtx after_label;
178: } cond;
179: /* For loops. */
180: struct
181: {
182: /* Label at the top of the loop; place to loop back to. */
183: rtx start_label;
184: /* Label at the end of the whole construct. */
185: rtx end_label;
186: /* Label for `continue' statement to jump to;
187: this is in front of the stepper of the loop. */
188: rtx continue_label;
189: } loop;
190: /* For variable binding contours. */
191: struct
192: {
193: /* Nonzero => value to restore stack to on exit. */
194: rtx stack_level;
195: /* The NOTE that starts this contour.
196: Used by expand_goto to check whether the destination
197: is within each contour or not. */
198: rtx first_insn;
199: /* Innermost containing binding contour that has a stack level. */
200: struct nesting *innermost_stack_block;
201: /* Chain of labels defined inside this binding contour.
202: Only for contours that have stack levels. */
203: struct label_chain *label_chain;
204: } block;
205: /* For switch (C) or case (Pascal) statements,
206: and also for dummies (see `expand_start_case_dummy'). */
207: struct
208: {
209: /* The insn after which the case dispatch should finally
210: be emitted. Zero for a dummy. */
211: rtx start;
212: /* A list of the case-values and their labels.
213: A chain of TREE_LIST nodes with the value to test for
214: (a constant node) in the TREE_PURPOSE and the
215: label (a LABEL_DECL) in the TREE_VALUE. */
216: tree case_list;
217: /* The expression to be dispatched on. */
218: tree index_expr;
219: /* Type that INDEX_EXPR should be converted to. */
220: tree nominal_type;
221: } case_stmt;
222: } data;
223: };
1.1 root 224:
1.1.1.2 root 225: /* Chain of all pending binding contours. */
226: struct nesting *block_stack;
1.1 root 227:
1.1.1.2 root 228: /* Chain of all pending binding contours that restore stack levels. */
229: struct nesting *stack_block_stack;
1.1 root 230:
1.1.1.2 root 231: /* Chain of all pending conditional statements. */
232: struct nesting *cond_stack;
1.1 root 233:
1.1.1.2 root 234: /* Chain of all pending loops. */
235: struct nesting *loop_stack;
236:
237: /* Chain of all pending case or switch statements. */
238: struct nesting *case_stack;
239:
240: /* Separate chain including all of the above,
241: chained through the `all' field. */
242: struct nesting *nesting_stack;
243:
244: /* Number of entries on nesting_stack now. */
245: int nesting_depth;
246:
247: /* Pop one of the sub-stacks, such as `loop_stack' or `cond_stack';
248: and pop off `nesting_stack' down to the same level. */
249:
250: #define POPSTACK(STACK) \
251: do { int initial_depth = nesting_stack->depth; \
252: do { struct nesting *this = STACK; \
253: STACK = this->next; \
254: nesting_stack = this->all; \
255: nesting_depth = this->depth; \
256: free (this); } \
257: while (nesting_depth > initial_depth); } while (0)
258:
1.1 root 259: /* Return the rtx-label that corresponds to a LABEL_DECL,
260: creating it if necessary. */
261:
262: static rtx
263: label_rtx (label)
264: tree label;
265: {
1.1.1.2 root 266: if (TREE_CODE (label) != LABEL_DECL)
267: abort ();
268:
1.1 root 269: if (DECL_RTL (label))
270: return DECL_RTL (label);
271:
272: return DECL_RTL (label) = gen_label_rtx ();
273: }
274:
275: /* Add an unconditional jump to LABEL as the next sequential instruction. */
276:
277: void
278: emit_jump (label)
279: rtx label;
280: {
281: do_pending_stack_adjust ();
282: emit_jump_insn (gen_jump (label));
283: emit_barrier ();
284: }
1.1.1.2 root 285:
286: /* Handle goto statements and the labels that they can go to. */
1.1 root 287:
1.1.1.2 root 288: /* In some cases it is impossible to generate code for a forward goto
289: until the label definition is seen. This happens when it may be necessary
290: for the goto to reset the stack pointer: we don't yet know how to do that.
291: So expand_goto puts an entry on this fixup list.
292: Each time a binding contour that resets the stack is exited,
293: we check each fixup.
294: If the target label has now been defined, we can insert the proper code. */
1.1 root 295:
1.1.1.2 root 296: struct goto_fixup
1.1 root 297: {
1.1.1.2 root 298: /* Points to following fixup. */
299: struct goto_fixup *next;
300: /* Points to the insn before the jump insn.
301: If more code must be inserted, it goes after this insn. */
302: rtx before_jump;
1.1.1.6 ! root 303: /* The LABEL_DECL that this jump is jumping to, or 0
! 304: for break, continue or return. */
1.1.1.2 root 305: tree target;
1.1.1.6 ! root 306: /* The CODE_LABEL rtx that this is jumping to. */
! 307: rtx target_rtl;
1.1.1.2 root 308: /* The outermost stack level that should be restored for this jump.
309: Each time a binding contour that resets the stack is exited,
310: if the target label is *not* yet defined, this slot is updated. */
311: rtx stack_level;
312: };
313:
314: static struct goto_fixup *goto_fixup_chain;
315:
316: /* Within any binding contour that must restore a stack level,
317: all labels are recorded with a chain of these structures. */
318:
319: struct label_chain
320: {
321: /* Points to following fixup. */
322: struct label_chain *next;
323: tree label;
324: };
325:
326: /* Specify the location in the RTL code of a label BODY,
327: which is a LABEL_DECL tree node.
328:
329: This is used for the kind of label that the user can jump to with a
330: goto statement, and for alternatives of a switch or case statement.
331: RTL labels generated for loops and conditionals don't go through here;
332: they are generated directly at the RTL level, by other functions below.
333:
334: Note that this has nothing to do with defining label *names*.
335: Languages vary in how they do that and what that even means. */
336:
337: void
338: expand_label (body)
339: tree body;
340: {
341: struct label_chain *p;
342:
343: do_pending_stack_adjust ();
344: emit_label (label_rtx (body));
345:
346: if (stack_block_stack)
347: {
348: p = (struct label_chain *) oballoc (sizeof (struct label_chain));
349: p->next = stack_block_stack->data.block.label_chain;
350: stack_block_stack->data.block.label_chain = p;
351: p->label = body;
352: }
1.1 root 353: }
354:
1.1.1.2 root 355: /* Generate RTL code for a `goto' statement with target label BODY.
356: BODY should be a LABEL_DECL tree node that was or will later be
357: defined with `expand_label'. */
358:
359: void
360: expand_goto (body)
361: tree body;
1.1 root 362: {
1.1.1.6 ! root 363: expand_goto_internal (body, label_rtx (body));
! 364: }
! 365:
! 366: static void
! 367: expand_goto_internal (body, label)
! 368: tree body;
! 369: rtx label;
! 370: {
1.1.1.2 root 371: struct nesting *block;
372: rtx stack_level = 0;
373:
374: if (GET_CODE (label) != CODE_LABEL)
375: abort ();
376:
377: /* If label has already been defined, we can tell now
378: whether and how we must alter the stack level. */
379:
1.1.1.6 ! root 380: if (PREV_INSN (label) != 0)
1.1.1.2 root 381: {
382: /* Find the outermost pending block that contains the label.
383: (Check containment by comparing insn-uids.)
384: Then restore the outermost stack level within that block. */
385: for (block = block_stack; block; block = block->next)
386: {
387: if (INSN_UID (block->data.block.first_insn) < INSN_UID (label))
388: break;
389: if (block->data.block.stack_level != 0)
390: stack_level = block->data.block.stack_level;
391: }
392:
393: if (stack_level)
394: emit_move_insn (stack_pointer_rtx, stack_level);
395:
1.1.1.6 ! root 396: if (body != 0 && TREE_PACKED (body))
1.1.1.2 root 397: error ("goto \"%s\" invalidly jumps into binding contour",
398: IDENTIFIER_POINTER (DECL_NAME (body)));
399: }
400: /* Label not yet defined: may need to put this goto
401: on the fixup list. */
1.1.1.6 ! root 402: else if (! expand_fixup (body, label))
! 403: /* No fixup needed. Record that the label is the target
! 404: of at least one goto that has no fixup. */
! 405: if (body != 0)
! 406: TREE_ADDRESSABLE (body) = 1;
1.1.1.2 root 407:
1.1.1.6 ! root 408: emit_jump (label);
! 409: }
! 410:
! 411: /* Generate if necessary a fixup for a goto
! 412: whose target label in tree structure (if any) is TREE_LABEL
! 413: and whose target in rtl is RTL_LABEL.
! 414:
! 415: The fixup will be used later to insert insns at this point
! 416: to restore the stack level as appropriate for the target label.
! 417:
! 418: Value is nonzero if a fixup is made. */
! 419:
! 420: static int
! 421: expand_fixup (tree_label, rtl_label)
! 422: tree tree_label;
! 423: rtx rtl_label;
! 424: {
! 425: struct nesting *block;
! 426: /* Does any containing block have a stack level?
! 427: If not, no fixup is needed, and that is the normal case
! 428: (the only case, for standard C). */
! 429: for (block = block_stack; block; block = block->next)
! 430: if (block->data.block.stack_level != 0)
! 431: break;
! 432:
! 433: if (block)
! 434: {
! 435: /* Ok, a fixup is needed. Add a fixup to the list of such. */
! 436: struct goto_fixup *fixup
! 437: = (struct goto_fixup *) oballoc (sizeof (struct goto_fixup));
! 438: /* In case an old stack level is restored, make sure that comes
! 439: after any pending stack adjust. */
! 440: do_pending_stack_adjust ();
! 441: fixup->before_jump = get_last_insn ();
! 442: fixup->target = tree_label;
! 443: fixup->target_rtl = rtl_label;
! 444: fixup->stack_level = 0;
! 445: fixup->next = goto_fixup_chain;
! 446: goto_fixup_chain = fixup;
1.1.1.2 root 447: }
448:
1.1.1.6 ! root 449: return block != 0;
1.1 root 450: }
451:
1.1.1.2 root 452: /* When exiting a binding contour, process all pending gotos requiring fixups.
453: STACK_LEVEL is the rtx for the stack level to restore on exit from
454: this contour. FIRST_INSN is the insn that begain this contour.
455: Gotos that jump out of this contour must restore the
456: stack level before actually jumping.
1.1 root 457:
1.1.1.2 root 458: Also print an error message if any fixup describes a jump into this
459: contour from before the beginning of the contour. */
1.1 root 460:
1.1.1.2 root 461: static void
462: fixup_gotos (stack_level, first_insn)
463: rtx stack_level;
464: rtx first_insn;
1.1 root 465: {
1.1.1.2 root 466: register struct goto_fixup *f;
1.1 root 467:
1.1.1.2 root 468: for (f = goto_fixup_chain; f; f = f->next)
469: {
470: /* Test for a fixup that is inactive because it is already handled. */
471: if (f->before_jump == 0)
472: ;
473: /* Has this fixup's target label been defined?
474: If so, we can finalize it. */
1.1.1.6 ! root 475: else if (PREV_INSN (f->target_rtl) != 0)
1.1.1.2 root 476: {
477: /* If this fixup jumped into this contour from before the beginning
478: of this contour, report an error. */
1.1.1.6 ! root 479: if (f->target != 0
! 480: && INSN_UID (first_insn) > INSN_UID (f->before_jump)
1.1.1.2 root 481: && ! TREE_ADDRESSABLE (f->target))
482: {
483: error_with_file_and_line (DECL_SOURCE_FILE (f->target),
484: DECL_SOURCE_LINE (f->target),
485: "label \"%s\" was used \
486: before containing binding contour",
487: IDENTIFIER_POINTER (DECL_NAME (f->target)));
488: /* Prevent multiple errors for one label. */
489: TREE_ADDRESSABLE (f->target) = 1;
490: }
1.1 root 491:
1.1.1.2 root 492: /* Restore stack level for the biggest contour that this
493: jump jumps out of. */
494: if (f->stack_level)
495: emit_insn_after (gen_move_insn (stack_pointer_rtx, f->stack_level),
496: f->before_jump);
497: f->before_jump = 0;
498: }
499: /* Label has still not appeared. If we are exiting a block with
500: a stack level to restore, mark this stack level as needing
501: restoration when the fixup is later finalized. */
502: else if (stack_level)
503: f->stack_level = stack_level;
504: }
505: }
506:
507: /* Generate RTL for an asm statement (explicit assembler code).
508: BODY is a STRING_CST node containing the assembler code text. */
509:
510: void
511: expand_asm (body)
512: tree body;
1.1 root 513: {
1.1.1.2 root 514: emit_insn (gen_rtx (ASM_INPUT, VOIDmode,
515: TREE_STRING_POINTER (body)));
516: last_expr_type = 0;
517: }
518:
519: /* Generate RTL for an asm statement with arguments.
520: STRING is the instruction template.
521: OUTPUTS is a list of output arguments (lvalues); INPUTS a list of inputs.
522: Each output or input has an expression in the TREE_VALUE and
523: a constraint-string in the TREE_PURPOSE.
524:
525: Not all kinds of lvalue that may appear in OUTPUTS can be stored directly.
526: Some elements of OUTPUTS may be replaced with trees representing temporary
527: values. The caller should copy those temporary values to the originally
528: specified lvalues.
1.1 root 529:
1.1.1.2 root 530: VOL nonzero means the insn is volatile; don't optimize it. */
1.1 root 531:
1.1.1.2 root 532: void
533: expand_asm_operands (string, outputs, inputs, vol)
534: tree string, outputs, inputs;
535: int vol;
536: {
537: rtvec argvec, constraints;
538: rtx body;
539: int ninputs = list_length (inputs);
540: int noutputs = list_length (outputs);
541: int numargs = 0;
542: tree tail;
543: int i;
544:
1.1.1.4 root 545: last_expr_type = 0;
546:
1.1.1.2 root 547: if (ninputs + noutputs > MAX_RECOG_OPERANDS)
1.1 root 548: {
1.1.1.2 root 549: error ("more than %d operands in `asm'", MAX_RECOG_OPERANDS);
550: return;
551: }
1.1 root 552:
1.1.1.2 root 553: for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
554: {
555: tree val = TREE_VALUE (tail);
1.1 root 556:
1.1.1.4 root 557: /* If there's an erroneous arg, emit no insn. */
558: if (TREE_TYPE (val) == error_mark_node)
559: return;
560:
1.1.1.2 root 561: /* If an output operand is not a variable or indirect ref,
562: create a SAVE_EXPR which is a pseudo-reg
563: to act as an intermediate temporary.
564: Make the asm insn write into that, then copy it to
565: the real output operand. */
566:
567: if (TREE_CODE (val) != VAR_DECL
568: && TREE_CODE (val) != PARM_DECL
569: && TREE_CODE (val) != INDIRECT_REF)
570: TREE_VALUE (tail) = build (SAVE_EXPR, TREE_TYPE (val), val,
571: gen_reg_rtx (TYPE_MODE (TREE_TYPE (val))));
572: }
1.1 root 573:
1.1.1.2 root 574: /* Make vectors for the expression-rtx and constraint strings. */
1.1 root 575:
1.1.1.4 root 576: argvec = rtvec_alloc (ninputs);
577: constraints = rtvec_alloc (ninputs);
1.1 root 578:
1.1.1.2 root 579: body = gen_rtx (ASM_OPERANDS, VOIDmode,
580: TREE_STRING_POINTER (string), "", 0, argvec, constraints);
581: body->volatil = vol;
1.1 root 582:
1.1.1.2 root 583: /* Eval the inputs and put them into ARGVEC.
584: Put their constraints into ASM_INPUTs and store in CONSTRAINTS. */
1.1 root 585:
1.1.1.2 root 586: i = 0;
587: for (tail = inputs; tail; tail = TREE_CHAIN (tail))
588: {
1.1.1.4 root 589: /* If there's an erroneous arg, emit no insn,
590: because the ASM_INPUT would get VOIDmode
591: and that could cause a crash in reload. */
592: if (TREE_TYPE (TREE_VALUE (tail)) == error_mark_node)
593: return;
594:
1.1.1.2 root 595: XVECEXP (body, 3, i) /* argvec */
596: = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0);
597: XVECEXP (body, 4, i) /* constraints */
598: = gen_rtx (ASM_INPUT, TYPE_MODE (TREE_TYPE (TREE_VALUE (tail))),
599: TREE_STRING_POINTER (TREE_PURPOSE (tail)));
600: i++;
601: }
1.1 root 602:
1.1.1.2 root 603: /* Now, for each output, construct an rtx
604: (set OUTPUT (asm_operands INSN OUTPUTNUMBER OUTPUTCONSTRAINT
605: ARGVEC CONSTRAINTS))
606: If there is more than one, put them inside a PARALLEL. */
1.1 root 607:
1.1.1.2 root 608: if (noutputs == 1)
609: {
610: tree val = TREE_VALUE (outputs);
1.1 root 611:
1.1.1.2 root 612: XSTR (body, 1) = TREE_STRING_POINTER (TREE_PURPOSE (outputs));
613: emit_insn (gen_rtx (SET, VOIDmode,
614: expand_expr (val, 0, VOIDmode, 0),
615: body));
616: }
1.1.1.5 root 617: else if (noutputs == 0)
618: {
619: /* No output operands: put in a raw ASM_OPERANDS rtx. */
620: emit_insn (body);
621: }
1.1.1.2 root 622: else
623: {
624: body = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (noutputs));
625:
626: for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
1.1 root 627: {
1.1.1.2 root 628: tree val = TREE_VALUE (tail);
629:
630: XVECEXP (body, 0, i)
631: = gen_rtx (SET, VOIDmode,
632: expand_expr (val, 0, VOIDmode, 0),
633: gen_rtx (ASM_OPERANDS, VOIDmode,
634: TREE_STRING_POINTER (string),
635: TREE_STRING_POINTER (TREE_PURPOSE (tail)),
636: i, argvec, constraints));
637: SET_SRC (XVECEXP (body, 0, i))->volatil = vol;
1.1 root 638: }
639:
1.1.1.2 root 640: emit_insn (body);
641: }
642: last_expr_type = 0;
643: }
1.1 root 644:
1.1.1.2 root 645: /* Nonzero if within a ({...}) grouping, in which case we must
646: always compute a value for each expr-stmt in case it is the last one. */
1.1 root 647:
1.1.1.2 root 648: int expr_stmts_for_value;
1.1 root 649:
1.1.1.2 root 650: /* Generate RTL to evaluate the expression EXP
651: and remember it in case this is the VALUE in a ({... VALUE; }) constr. */
1.1 root 652:
1.1.1.2 root 653: void
654: expand_expr_stmt (exp)
655: tree exp;
656: {
657: last_expr_type = TREE_TYPE (exp);
658: last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx,
659: VOIDmode, 0);
660: emit_queue ();
661: }
1.1 root 662:
1.1.1.2 root 663: /* Clear out the memory of the last expression evaluated. */
1.1 root 664:
1.1.1.2 root 665: void
666: clear_last_expr ()
667: {
668: last_expr_type = 0;
669: }
1.1 root 670:
1.1.1.2 root 671: /* Return a tree node that refers to the last expression evaluated.
672: The nodes of that expression have been freed by now, so we cannot use them.
673: But we don't want to do that anyway; the expression has already been
674: evaluated and now we just want to use the value. So generate a SAVE_EXPR
675: with the proper type and RTL value.
1.1 root 676:
1.1.1.2 root 677: If the last statement was not an expression,
678: return something with type `void'. */
1.1 root 679:
1.1.1.2 root 680: tree
681: get_last_expr ()
682: {
683: tree t;
1.1 root 684:
1.1.1.2 root 685: if (last_expr_type == 0)
686: {
687: last_expr_type = void_type_node;
688: last_expr_value = const0_rtx;
689: }
690: t = build (RTL_EXPR, last_expr_type, NULL, NULL);
691: RTL_EXPR_RTL (t) = last_expr_value;
692: RTL_EXPR_SEQUENCE (t) = gen_sequence ();
693: return t;
694: }
1.1 root 695:
1.1.1.2 root 696: void
697: expand_start_stmt_expr ()
698: {
699: extern int emit_to_sequence;
700: expr_stmts_for_value++;
701: emit_to_sequence++;
702: }
1.1 root 703:
1.1.1.2 root 704: void
705: expand_end_stmt_expr ()
706: {
707: extern int emit_to_sequence;
708: expr_stmts_for_value--;
709: emit_to_sequence--;
710: }
711:
712: /* Generate RTL for the start of an if-then. COND is the expression
713: whose truth should be tested.
1.1 root 714:
1.1.1.2 root 715: If EXITFLAG is nonzero, this conditional is visible to
716: `exit_something'. */
1.1 root 717:
1.1.1.2 root 718: void
719: expand_start_cond (cond, exitflag)
720: tree cond;
721: int exitflag;
722: {
723: struct nesting *thiscond
724: = (struct nesting *) xmalloc (sizeof (struct nesting));
1.1 root 725:
1.1.1.2 root 726: /* Make an entry on cond_stack for the cond we are entering. */
1.1 root 727:
1.1.1.2 root 728: thiscond->next = cond_stack;
729: thiscond->all = nesting_stack;
730: thiscond->depth = ++nesting_depth;
731: thiscond->data.cond.after_label = 0;
732: thiscond->data.cond.else_label = gen_label_rtx ();
733: thiscond->exit_label = exitflag ? thiscond->data.cond.else_label : 0;
734: cond_stack = thiscond;
735: nesting_stack = thiscond;
1.1 root 736:
1.1.1.2 root 737: do_jump (cond, thiscond->data.cond.else_label, NULL);
738: }
1.1 root 739:
1.1.1.2 root 740: /* Generate RTL for the end of an if-then with no else-clause.
741: Pop the record for it off of cond_stack. */
1.1 root 742:
1.1.1.2 root 743: void
744: expand_end_cond ()
745: {
746: struct nesting *thiscond = cond_stack;
1.1 root 747:
1.1.1.2 root 748: do_pending_stack_adjust ();
749: emit_label (thiscond->data.cond.else_label);
1.1 root 750:
1.1.1.2 root 751: POPSTACK (cond_stack);
752: last_expr_type = 0;
753: }
1.1 root 754:
1.1.1.2 root 755: /* Generate RTL between the then-clause and the else-clause
756: of an if-then-else. */
1.1 root 757:
1.1.1.2 root 758: void
759: expand_start_else ()
760: {
761: cond_stack->data.cond.after_label = gen_label_rtx ();
762: if (cond_stack->exit_label != 0)
763: cond_stack->exit_label = cond_stack->data.cond.after_label;
764: emit_jump (cond_stack->data.cond.after_label);
765: if (cond_stack->data.cond.else_label)
766: emit_label (cond_stack->data.cond.else_label);
767: }
1.1 root 768:
1.1.1.2 root 769: /* Generate RTL for the end of an if-then-else.
770: Pop the record for it off of cond_stack. */
771:
772: void
773: expand_end_else ()
774: {
775: struct nesting *thiscond = cond_stack;
776:
777: do_pending_stack_adjust ();
778: /* Note: a syntax error can cause this to be called
779: without first calling `expand_start_else'. */
780: if (thiscond->data.cond.after_label)
781: emit_label (thiscond->data.cond.after_label);
782:
783: POPSTACK (cond_stack);
784: last_expr_type = 0;
785: }
786:
787: /* Generate RTL for the start of a loop. EXIT_FLAG is nonzero if this
788: loop should be exited by `exit_something'. This is a loop for which
789: `expand_continue' will jump to the top of the loop.
790:
791: Make an entry on loop_stack to record the labels associated with
792: this loop. */
793:
794: void
795: expand_start_loop (exit_flag)
796: int exit_flag;
797: {
798: register struct nesting *thisloop
799: = (struct nesting *) xmalloc (sizeof (struct nesting));
800:
801: /* Make an entry on loop_stack for the loop we are entering. */
802:
803: thisloop->next = loop_stack;
804: thisloop->all = nesting_stack;
805: thisloop->depth = ++nesting_depth;
806: thisloop->data.loop.start_label = gen_label_rtx ();
807: thisloop->data.loop.end_label = gen_label_rtx ();
808: thisloop->data.loop.continue_label = thisloop->data.loop.start_label;
809: thisloop->exit_label = exit_flag ? thisloop->data.loop.end_label : 0;
810: loop_stack = thisloop;
811: nesting_stack = thisloop;
812:
813: do_pending_stack_adjust ();
814: emit_queue ();
815: emit_note (0, NOTE_INSN_LOOP_BEG);
816: emit_label (thisloop->data.loop.start_label);
817: }
818:
819: /* Like expand_start_loop but for a loop where the continuation point
820: (for expand_continue_loop) will be specified explicitly. */
1.1 root 821:
1.1.1.2 root 822: void
823: expand_start_loop_continue_elsewhere (exit_flag)
824: int exit_flag;
825: {
826: expand_start_loop (exit_flag);
827: loop_stack->data.loop.continue_label = gen_label_rtx ();
828: }
829:
830: /* Specify the continuation point for a loop started with
831: expand_start_loop_continue_elsewhere.
832: Use this at the point in the code to which a continue statement
833: should jump. */
834:
835: void
836: expand_loop_continue_here ()
837: {
838: do_pending_stack_adjust ();
839: emit_label (loop_stack->data.loop.continue_label);
840: }
841:
842: /* Finish a loop. Generate a jump back to the top and the loop-exit label.
843: Pop the block off of loop_stack. */
844:
845: void
846: expand_end_loop ()
847: {
848: register struct nesting *thisloop = loop_stack;
849: register rtx insn = get_last_insn ();
850: register rtx start_label = loop_stack->data.loop.start_label;
851:
852: do_pending_stack_adjust ();
853:
854: /* If optimizing, perhaps reorder the loop. If the loop
855: starts with a conditional exit, roll that to the end
856: where it will optimize together with the jump back. */
857: if (optimize
858: &&
859: ! (GET_CODE (insn) == JUMP_INSN
860: && GET_CODE (PATTERN (insn)) == SET
861: && SET_DEST (PATTERN (insn)) == pc_rtx
862: && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE))
863: {
864: /* Scan insns from the top of the loop looking for a qualified
865: conditional exit. */
866: for (insn = loop_stack->data.loop.start_label; insn; insn= NEXT_INSN (insn))
867: if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET
868: && SET_DEST (PATTERN (insn)) == pc_rtx
869: && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE
870: &&
871: ((GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == LABEL_REF
872: && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0)
873: == loop_stack->data.loop.end_label))
874: ||
875: (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 2)) == LABEL_REF
876: && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0)
877: == loop_stack->data.loop.end_label))))
878: break;
879: if (insn != 0)
880: {
881: /* We found one. Move everything from there up
882: to the end of the loop, and add a jump into the loop
883: to jump to there. */
884: register rtx newstart_label = gen_label_rtx ();
885:
886: emit_label_after (newstart_label, PREV_INSN (start_label));
887: reorder_insns (start_label, insn, get_last_insn ());
888: emit_jump_insn_after (gen_jump (start_label), PREV_INSN (newstart_label));
889: emit_barrier_after (PREV_INSN (newstart_label));
890: start_label = newstart_label;
891: }
892: }
893:
894: emit_jump (start_label);
895: emit_note (0, NOTE_INSN_LOOP_END);
896: emit_label (loop_stack->data.loop.end_label);
897:
898: POPSTACK (loop_stack);
899:
900: last_expr_type = 0;
901: }
902:
903: /* Generate a jump to the current loop's continue-point.
904: This is usually the top of the loop, but may be specified
905: explicitly elsewhere. If not currently inside a loop,
906: return 0 and do nothing; caller will print an error message. */
907:
908: int
909: expand_continue_loop ()
910: {
911: last_expr_type = 0;
912: if (loop_stack == 0)
913: return 0;
1.1.1.6 ! root 914: expand_goto_internal (0, loop_stack->data.loop.continue_label);
1.1.1.2 root 915: return 1;
916: }
917:
918: /* Generate a jump to exit the current loop. If not currently inside a loop,
919: return 0 and do nothing; caller will print an error message. */
920:
921: int
922: expand_exit_loop ()
923: {
924: last_expr_type = 0;
925: if (loop_stack == 0)
926: return 0;
1.1.1.6 ! root 927: expand_goto_internal (0, loop_stack->data.loop.end_label);
1.1.1.2 root 928: return 1;
929: }
930:
931: /* Generate a conditional jump to exit the current loop if COND
932: evaluates to zero. If not currently inside a loop,
933: return 0 and do nothing; caller will print an error message. */
934:
935: int
936: expand_exit_loop_if_false (cond)
937: tree cond;
938: {
939: last_expr_type = 0;
940: if (loop_stack == 0)
941: return 0;
942: do_jump (cond, loop_stack->data.loop.end_label, NULL);
943: return 1;
944: }
945:
946: /* Generate a jump to exit the current loop, conditional, binding contour
947: or case statement. Not all such constructs are visible to this function,
948: only those started with EXIT_FLAG nonzero. Individual languages use
949: the EXIT_FLAG parameter to control which kinds of constructs you can
950: exit this way.
951:
952: If not currently inside anything that can be exited,
953: return 0 and do nothing; caller will print an error message. */
954:
955: int
956: expand_exit_something ()
957: {
958: struct nesting *n;
959: last_expr_type = 0;
960: for (n = nesting_stack; n; n = n->all)
961: {
962: if (n->exit_label != 0)
963: {
1.1.1.6 ! root 964: expand_goto_internal (0, n->exit_label);
1.1.1.2 root 965: return 1;
966: }
1.1 root 967: }
1.1.1.2 root 968: return 0;
969: }
970:
971: /* Generate RTL to return from the current function, with no value.
972: (That is, we do not do anything about returning any value.) */
973:
974: void
975: expand_null_return ()
976: {
977: clear_pending_stack_adjust ();
978: #ifdef FUNCTION_EPILOGUE
1.1.1.6 ! root 979: expand_goto_internal (0, return_label);
1.1.1.2 root 980: #else
981: emit_jump_insn (gen_return ());
982: emit_barrier ();
983: #endif
984: last_expr_type = 0;
985: }
1.1 root 986:
1.1.1.2 root 987: /* Generate RTL to evaluate the expression RETVAL and return it
988: from the current function. */
1.1 root 989:
1.1.1.2 root 990: void
991: expand_return (retval)
992: tree retval;
993: {
994: register rtx val = 0;
995: register rtx op0;
996: int really_for_value =
997: (TREE_CODE (retval) == MODIFY_EXPR
998: && TREE_CODE (TREE_OPERAND (retval, 0)) == RESULT_DECL);
999:
1000: /* For tail-recursive call to current function,
1001: just jump back to the beginning.
1002: It's unsafe if any auto variable in this function
1003: has its address taken; for simplicity,
1004: require stack frame to be empty. */
1005: if (optimize && really_for_value
1.1.1.3 root 1006: && frame_offset == STARTING_FRAME_OFFSET
1.1.1.2 root 1007: && TREE_CODE (TREE_OPERAND (retval, 1)) == CALL_EXPR
1008: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (retval, 1), 0)) == ADDR_EXPR
1009: && TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (retval, 1), 0), 0) == this_function
1010: /* Finish checking validity, and if valid emit code
1011: to set the argument variables for the new call. */
1012: && tail_recursion_args (TREE_OPERAND (TREE_OPERAND (retval, 1), 1),
1013: DECL_ARGUMENTS (this_function)))
1014: {
1015: ;
1016: if (tail_recursion_label == 0)
1017: {
1018: tail_recursion_label = gen_label_rtx ();
1019: emit_label_after (tail_recursion_label,
1020: tail_recursion_reentry);
1021: }
1.1.1.6 ! root 1022: expand_goto_internal (0, tail_recursion_label);
1.1.1.2 root 1023: emit_barrier ();
1024: return;
1025: }
1026: #ifndef FUNCTION_EPILOGUE
1027: /* If this is return x == y; then generate
1028: if (x == y) return 1; else return 0;
1029: if we can do it with explicit return insns. */
1030: if (really_for_value)
1031: switch (TREE_CODE (TREE_OPERAND (retval, 1)))
1032: {
1033: case EQ_EXPR:
1034: case NE_EXPR:
1035: case GT_EXPR:
1036: case GE_EXPR:
1037: case LT_EXPR:
1038: case LE_EXPR:
1039: case TRUTH_ANDIF_EXPR:
1040: case TRUTH_ORIF_EXPR:
1041: case TRUTH_NOT_EXPR:
1042: op0 = gen_label_rtx ();
1043: val = DECL_RTL (DECL_RESULT (this_function));
1044: jumpifnot (TREE_OPERAND (retval, 1), op0);
1045: emit_move_insn (val, const1_rtx);
1046: emit_insn (gen_rtx (USE, VOIDmode, val));
1047: expand_null_return ();
1048: emit_label (op0);
1049: emit_move_insn (val, const0_rtx);
1050: emit_insn (gen_rtx (USE, VOIDmode, val));
1051: expand_null_return ();
1052: return;
1053: }
1054: #endif
1055: val = expand_expr (retval, 0, VOIDmode, 0);
1.1 root 1056: emit_queue ();
1.1.1.2 root 1057:
1058: if (really_for_value && GET_CODE (val) == REG)
1059: emit_insn (gen_rtx (USE, VOIDmode, val));
1060:
1061: expand_null_return ();
1062: }
1063:
1064: /* Return 1 if the end of the generated RTX is not a barrier.
1065: This means code already compiled can drop through. */
1066:
1067: int
1068: drop_through_at_end_p ()
1069: {
1070: rtx insn = get_last_insn ();
1071: while (insn && GET_CODE (insn) == NOTE)
1072: insn = PREV_INSN (insn);
1073: return insn && GET_CODE (insn) != BARRIER;
1.1 root 1074: }
1075:
1076: /* Emit code to alter this function's formal parms for a tail-recursive call.
1077: ACTUALS is a list of actual parameter expressions (chain of TREE_LISTs).
1078: FORMALS is the chain of decls of formals.
1079: Return 1 if this can be done;
1080: otherwise return 0 and do not emit any code. */
1081:
1082: static int
1083: tail_recursion_args (actuals, formals)
1084: tree actuals, formals;
1085: {
1086: register tree a = actuals, f = formals;
1087: register int i;
1088: register rtx *argvec;
1089:
1090: /* Check that number and types of actuals are compatible
1091: with the formals. This is not always true in valid C code.
1092: Also check that no formal needs to be addressable
1093: and that all formals are scalars. */
1094:
1095: /* Also count the args. */
1096:
1097: for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++)
1098: {
1099: if (TREE_TYPE (TREE_VALUE (a)) != TREE_TYPE (f))
1100: return 0;
1101: if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode)
1102: return 0;
1103: }
1104: if (a != 0 || f != 0)
1105: return 0;
1106:
1107: /* Compute all the actuals. */
1108:
1109: argvec = (rtx *) alloca (i * sizeof (rtx));
1110:
1111: for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
1112: argvec[i] = expand_expr (TREE_VALUE (a), 0, VOIDmode, 0);
1113:
1114: /* Find which actual values refer to current values of previous formals.
1115: Copy each of them now, before any formal is changed. */
1116:
1117: for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
1118: {
1119: int copy = 0;
1120: register int j;
1121: for (f = formals, j = 0; j < i; f = TREE_CHAIN (f), j++)
1122: if (reg_mentioned_p (DECL_RTL (f), argvec[i]))
1123: { copy = 1; break; }
1124: if (copy)
1125: argvec[i] = copy_to_reg (argvec[i]);
1126: }
1127:
1128: /* Store the values of the actuals into the formals. */
1129:
1.1.1.2 root 1130: for (f = formals, a = actuals, i = 0; f;
1131: f = TREE_CHAIN (f), a = TREE_CHAIN (a), i++)
1.1 root 1132: {
1133: if (DECL_MODE (f) == GET_MODE (argvec[i]))
1134: emit_move_insn (DECL_RTL (f), argvec[i]);
1135: else
1.1.1.2 root 1136: convert_move (DECL_RTL (f), argvec[i],
1137: TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (a))));
1.1 root 1138: }
1139:
1140: return 1;
1141: }
1142:
1.1.1.2 root 1143: /* Generate the RTL code for entering a binding contour.
1144: The variables are declared one by one, by calls to `expand_decl'.
1.1 root 1145:
1.1.1.2 root 1146: EXIT_FLAG is nonzero if this construct should be visible to
1147: `exit_something'. */
1148:
1149: void
1150: expand_start_bindings (exit_flag)
1151: int exit_flag;
1.1 root 1152: {
1.1.1.2 root 1153: struct nesting *thisblock
1154: = (struct nesting *) xmalloc (sizeof (struct nesting));
1155:
1156: rtx note = emit_note (0, NOTE_INSN_BLOCK_BEG);
1157:
1158: /* Make an entry on block_stack for the block we are entering. */
1159:
1160: thisblock->next = block_stack;
1161: thisblock->all = nesting_stack;
1162: thisblock->depth = ++nesting_depth;
1163: thisblock->data.block.stack_level = 0;
1164: thisblock->data.block.label_chain = 0;
1165: thisblock->data.block.innermost_stack_block = stack_block_stack;
1166: thisblock->data.block.first_insn = note;
1167: thisblock->exit_label = exit_flag ? gen_label_rtx () : 0;
1168: block_stack = thisblock;
1169: nesting_stack = thisblock;
1170: }
1171:
1.1.1.3 root 1172: /* Output a USE for any register use in RTL.
1173: This is used with -noreg to mark the extent of lifespan
1174: of any registers used in a user-visible variable's DECL_RTL. */
1175:
1176: static void
1177: use_variable (rtl)
1178: rtx rtl;
1179: {
1180: if (GET_CODE (rtl) == REG)
1181: /* This is a register variable. */
1182: emit_insn (gen_rtx (USE, VOIDmode, rtl));
1183: else if (GET_CODE (rtl) == MEM
1184: && GET_CODE (XEXP (rtl, 0)) == REG
1185: && XEXP (rtl, 0) != frame_pointer_rtx
1186: && XEXP (rtl, 0) != arg_pointer_rtx)
1187: /* This is a variable-sized structure. */
1188: emit_insn (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)));
1189: }
1190:
1.1.1.2 root 1191: /* Generate RTL code to terminate a binding contour.
1192: VARS is the chain of VAR_DECL nodes
1193: for the variables bound in this contour.
1194: MARK_ENDs is nonzero if we should put a note at the beginning
1195: and end of this binding contour. */
1196:
1197: void
1198: expand_end_bindings (vars, mark_ends)
1199: tree vars;
1200: int mark_ends;
1201: {
1202: register struct nesting *thisblock = block_stack;
1203: register tree decl;
1204:
1205: /* Mark the beginning and end of the scope if requested. */
1206:
1207: if (mark_ends)
1208: emit_note (0, NOTE_INSN_BLOCK_END);
1209: else
1210: /* Get rid of the beginning-mark if we don't make an end-mark. */
1211: NOTE_LINE_NUMBER (thisblock->data.block.first_insn) = NOTE_INSN_DELETED;
1212:
1213: if (thisblock->exit_label)
1214: {
1215: do_pending_stack_adjust ();
1216: emit_label (thisblock->exit_label);
1217: }
1218:
1219: /* Restore stack level in effect before the block
1220: (only if variable-size objects allocated). */
1221:
1222: if (thisblock->data.block.stack_level != 0)
1223: {
1224: struct label_chain *chain;
1225:
1226: do_pending_stack_adjust ();
1227: emit_move_insn (stack_pointer_rtx,
1228: thisblock->data.block.stack_level);
1229:
1230: /* Any labels in this block are no longer valid to go to.
1231: Mark them to cause an error message. */
1232: for (chain = thisblock->data.block.label_chain; chain; chain = chain->next)
1233: {
1234: TREE_PACKED (chain->label) = 1;
1235: /* If any goto without a fixup came to this label,
1236: that must be an error, because gotos without fixups
1237: come from outside all saved stack-levels. */
1238: if (TREE_ADDRESSABLE (chain->label))
1239: error_with_file_and_line (DECL_SOURCE_FILE (chain->label),
1240: DECL_SOURCE_LINE (chain->label),
1241: "label \"%s\" was used \
1242: before containing binding contour",
1243: IDENTIFIER_POINTER (DECL_NAME (chain->label)));
1244: }
1245:
1246: /* Any gotos out of this block must also restore the stack level.
1247: Also report any gotos with fixups that came to labels in this level. */
1248: fixup_gotos (thisblock->data.block.stack_level,
1249: thisblock->data.block.first_insn);
1250: }
1251:
1252: /* If doing stupid register allocation, make sure lives of all
1253: register variables declared here extend thru end of scope. */
1254:
1255: if (obey_regdecls)
1256: for (decl = vars; decl; decl = TREE_CHAIN (decl))
1257: {
1.1.1.3 root 1258: rtx rtl = DECL_RTL (decl);
1259: if (TREE_CODE (decl) == VAR_DECL && rtl != 0)
1260: use_variable (rtl);
1.1.1.2 root 1261: }
1262:
1263: /* Restore block_stack level for containing block. */
1264:
1265: stack_block_stack = thisblock->data.block.innermost_stack_block;
1266: POPSTACK (block_stack);
1267: }
1268:
1269: /* Generate RTL for the automatic variable declaration DECL.
1270: (Other kinds of declarations are simply ignored.) */
1271:
1272: void
1273: expand_decl (decl)
1274: register tree decl;
1275: {
1276: struct nesting *thisblock = block_stack;
1277: tree type = TREE_TYPE (decl);
1278:
1279: /* External function declarations are supposed to have been
1280: handled in assemble_variable. Verify this. */
1281: if (TREE_CODE (decl) == FUNCTION_DECL)
1282: {
1283: if (DECL_RTL (decl) == 0)
1284: abort ();
1285: return;
1286: }
1287:
1288: /* Aside from that, only automatic variables need any expansion done.
1289: Static and external variables were handled by `assemble_variable'
1290: (called from finish_decl). TYPE_DECL and CONST_DECL require nothing;
1291: PARM_DECLs are handled in `assign_parms'. */
1292:
1293: if (TREE_CODE (decl) != VAR_DECL)
1294: return;
1295: if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
1296: return;
1297:
1298: /* Create the RTL representation for the variable. */
1299:
1300: if (type == error_mark_node)
1301: DECL_RTL (decl) = gen_rtx (MEM, BLKmode, const0_rtx);
1302: else if (DECL_MODE (decl) != BLKmode
1303: /* If -ffloat-store, don't put explicit float vars
1304: into regs. */
1305: && !(flag_float_store
1306: && TREE_CODE (type) == REAL_TYPE)
1307: && ! TREE_VOLATILE (decl)
1308: && ! TREE_ADDRESSABLE (decl)
1309: && (TREE_REGDECL (decl) || ! obey_regdecls))
1310: {
1311: /* Automatic variable that can go in a register. */
1312: DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
1313: if (TREE_CODE (type) == POINTER_TYPE)
1314: mark_reg_pointer (DECL_RTL (decl));
1315: DECL_RTL (decl)->volatil = 1;
1316: }
1317: else if (DECL_SIZE (decl) == 0)
1318: /* Variable with incomplete type. */
1319: /* Error message was already done; now avoid a crash. */
1320: DECL_RTL (decl) = assign_stack_local (DECL_MODE (decl), 0);
1321: else if (TREE_LITERAL (DECL_SIZE (decl)))
1322: {
1323: /* Variable of fixed size that goes on the stack. */
1324: DECL_RTL (decl)
1325: = assign_stack_local (DECL_MODE (decl),
1326: (TREE_INT_CST_LOW (DECL_SIZE (decl))
1327: * DECL_SIZE_UNIT (decl)
1328: + BITS_PER_UNIT - 1)
1329: / BITS_PER_UNIT);
1330: /* If this is a memory ref that contains aggregate components,
1331: mark it as such for cse and loop optimize. */
1332: DECL_RTL (decl)->in_struct
1333: = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
1334: || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
1335: || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
1336: }
1337: else
1338: /* Dynamic-size object: must push space on the stack. */
1339: {
1340: rtx address, size;
1341:
1342: frame_pointer_needed = 1;
1343:
1344: /* Record the stack pointer on entry to block, if have
1345: not already done so. */
1346: if (thisblock->data.block.stack_level == 0)
1347: {
1348: do_pending_stack_adjust ();
1349: thisblock->data.block.stack_level
1350: = copy_to_reg (stack_pointer_rtx);
1351: stack_block_stack = thisblock;
1352: }
1353:
1354: /* Compute the variable's size, in bytes. */
1355: size = expand_expr (convert_units (DECL_SIZE (decl),
1356: DECL_SIZE_UNIT (decl),
1357: BITS_PER_UNIT),
1358: 0, VOIDmode, 0);
1359:
1360: /* Round it up to this machine's required stack boundary. */
1361: #ifdef STACK_BOUNDARY
1362: /* Avoid extra code if we can prove it's a multiple already. */
1363: if (DECL_SIZE_UNIT (decl) % STACK_BOUNDARY)
1364: size = round_push (size);
1365: #endif
1366:
1367: /* Make space on the stack, and get an rtx for the address of it. */
1368: #ifdef STACK_GROWS_DOWNWARD
1369: anti_adjust_stack (size);
1370: #endif
1371: address = copy_to_reg (stack_pointer_rtx);
1.1.1.4 root 1372: #ifdef STACK_POINTER_OFFSET
1373: /* If the contents of the stack pointer reg are offset from the
1374: actual top-of-stack address, add the offset here. */
1375: emit_insn (gen_add2_insn (address, gen_rtx (CONST_INT, VOIDmode,
1376: STACK_POINTER_OFFSET)));
1377: #endif
1.1.1.2 root 1378: #ifndef STACK_GROWS_DOWNWARD
1379: anti_adjust_stack (size);
1380: #endif
1381:
1382: /* Reference the variable indirect through that rtx. */
1383: DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), address);
1384: }
1385:
1386: if (TREE_VOLATILE (decl))
1387: DECL_RTL (decl)->volatil = 1;
1388: if (TREE_READONLY (decl))
1389: DECL_RTL (decl)->unchanging = 1;
1390:
1391: /* If doing stupid register allocation, make sure life of any
1392: register variable starts here, at the start of its scope. */
1393:
1394: if (obey_regdecls
1395: && TREE_CODE (decl) == VAR_DECL
1.1.1.3 root 1396: && DECL_RTL (decl) != 0)
1397: use_variable (DECL_RTL (decl));
1.1.1.2 root 1398:
1399: /* Compute and store the initial value now. */
1400:
1.1.1.3 root 1401: if (DECL_INITIAL (decl) == error_mark_node)
1402: {
1403: enum tree_code code = TREE_CODE (TREE_TYPE (decl));
1404: if (code == INTEGER_TYPE || code == REAL_TYPE || code == ENUMERAL_TYPE
1405: || code == POINTER_TYPE)
1406: expand_assignment (decl, convert (TREE_TYPE (decl), integer_zero_node),
1407: 0, 0);
1408: emit_queue ();
1409: }
1410: else if (DECL_INITIAL (decl))
1.1.1.2 root 1411: {
1412: emit_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1413: expand_assignment (decl, DECL_INITIAL (decl), 0, 0);
1414: emit_queue ();
1415: }
1416: }
1417:
1418: /* Enter a case (Pascal) or switch (C) statement.
1419: Push a block onto case_stack and nesting_stack
1420: to accumulate the case-labels that are seen
1421: and to record the labels generated for the statement.
1422:
1423: EXIT_FLAG is nonzero if `exit_something' should exit this case stmt.
1424: Otherwise, this construct is transparent for `exit_something'.
1425:
1426: EXPR is the index-expression to be dispatched on.
1427: TYPE is its nominal type. We could simply convert EXPR to this type,
1428: but instead we take short cuts. */
1429:
1430: void
1431: expand_start_case (exit_flag, expr, type)
1432: int exit_flag;
1433: tree expr;
1434: tree type;
1435: {
1436: register struct nesting *thiscase
1437: = (struct nesting *) xmalloc (sizeof (struct nesting));
1438:
1439: /* Make an entry on case_stack for the case we are entering. */
1440:
1441: thiscase->next = case_stack;
1442: thiscase->all = nesting_stack;
1443: thiscase->depth = ++nesting_depth;
1444: thiscase->exit_label = exit_flag ? gen_label_rtx () : 0;
1445: thiscase->data.case_stmt.case_list = 0;
1446: thiscase->data.case_stmt.index_expr = expr;
1447: thiscase->data.case_stmt.nominal_type = type;
1448: case_stack = thiscase;
1449: nesting_stack = thiscase;
1450:
1451: do_pending_stack_adjust ();
1452:
1.1.1.6 ! root 1453: /* Make sure case_stmt.start points to something that won't
! 1454: need any transformation before expand_end_case. */
! 1455: if (GET_CODE (get_last_insn ()) != NOTE)
! 1456: emit_note (0, NOTE_INSN_DELETED);
! 1457:
1.1.1.2 root 1458: thiscase->data.case_stmt.start = get_last_insn ();
1459: }
1460:
1461: /* Start a "dummy case statement" within which case labels are invalid
1462: and are not connected to any larger real case statement.
1463: This can be used if you don't want to let a case statement jump
1464: into the middle of certain kinds of constructs. */
1465:
1466: void
1467: expand_start_case_dummy ()
1468: {
1469: register struct nesting *thiscase
1470: = (struct nesting *) xmalloc (sizeof (struct nesting));
1471:
1472: /* Make an entry on case_stack for the dummy. */
1473:
1474: thiscase->next = case_stack;
1475: thiscase->all = nesting_stack;
1476: thiscase->depth = ++nesting_depth;
1477: thiscase->exit_label = 0;
1478: thiscase->data.case_stmt.case_list = 0;
1479: thiscase->data.case_stmt.start = 0;
1480: thiscase->data.case_stmt.nominal_type = 0;
1481: case_stack = thiscase;
1482: nesting_stack = thiscase;
1483: }
1484:
1485: /* End a dummy case statement. */
1486:
1487: void
1488: expand_end_case_dummy ()
1489: {
1490: POPSTACK (case_stack);
1491: }
1492:
1493: /* Accumulate one case or default label inside a case or switch statement.
1494: VALUE is the value of the case (a null pointer, for a default label).
1495:
1496: If not currently inside a case or switch statement, return 1 and do
1497: nothing. The caller will print a language-specific error message.
1498: If VALUE is a duplicate, return 2 and do nothing.
1499: If VALUE is out of range, return 3 and do nothing.
1500: Return 0 on success. */
1501:
1502: int
1503: pushcase (value, label)
1504: register tree value;
1505: register tree label;
1506: {
1507: register tree l;
1508: tree index_type;
1509: tree nominal_type;
1510:
1511: /* Fail if not inside a real case statement. */
1512: if (! (case_stack && case_stack->data.case_stmt.start))
1513: return 1;
1514:
1515: index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
1516: nominal_type = case_stack->data.case_stmt.nominal_type;
1517:
1518: /* If the index is erroneous, avoid more problems: pretend to succeed. */
1519: if (index_type == error_mark_node)
1520: return 0;
1521:
1522: /* Convert VALUE to the type in which the comparisons are nominally done. */
1523: if (value != 0)
1524: value = convert (nominal_type, value);
1525:
1526: /* Fail if this is a duplicate entry. */
1527: for (l = case_stack->data.case_stmt.case_list; l; l = TREE_CHAIN (l))
1528: {
1529: if (value == 0 && TREE_PURPOSE (l) == 0)
1530: return 2;
1531: if (value != 0 && TREE_PURPOSE (l)
1532: && (TREE_INT_CST_LOW (value)
1533: == TREE_INT_CST_LOW (TREE_PURPOSE (l)))
1534: && (TREE_INT_CST_HIGH (value)
1535: == TREE_INT_CST_HIGH (TREE_PURPOSE (l))))
1536: return 2;
1537: }
1538:
1539: /* Fail if this value is out of range for the actual type of the index
1540: (which may be narrower than NOMINAL_TYPE). */
1541: if (value != 0 && ! int_fits_type_p (value, index_type))
1542: return 3;
1543:
1544: /* Add this label to the list, and succeed.
1545: Copy VALUE so it is temporary rather than momentary. */
1546: case_stack->data.case_stmt.case_list
1547: = tree_cons (value ? copy_node (value) : 0, label,
1548: case_stack->data.case_stmt.case_list);
1549: expand_label (label);
1550: return 0;
1551: }
1552:
1553: /* Terminate a case (Pascal) or switch (C) statement
1554: in which CASE_INDEX is the expression to be tested.
1555: Generate the code to test it and jump to the right place. */
1556:
1557: void
1558: expand_end_case ()
1559: {
1560: tree minval, maxval, range;
1561: rtx default_label = 0;
1562: register tree elt;
1563: register tree c;
1564: int count;
1565: rtx index;
1566: rtx table_label = gen_label_rtx ();
1567: int ncases;
1568: rtx *labelvec;
1569: register int i;
1570: rtx before_case;
1571: register struct nesting *thiscase = case_stack;
1572: tree index_expr = thiscase->data.case_stmt.index_expr;
1573:
1574: do_pending_stack_adjust ();
1575:
1.1.1.6 ! root 1576: /* An ERROR_MARK occurs for various reasons including invalid data type. */
! 1577: if (TREE_TYPE (index_expr) != error_mark_node)
1.1.1.2 root 1578: {
1579: /* If we don't have a default-label, create one here,
1580: after the body of the switch. */
1581: for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
1582: if (TREE_PURPOSE (c) == 0)
1583: break;
1584: if (c == 0)
1585: pushcase (0, build_decl (LABEL_DECL, NULL_TREE, NULL_TREE));
1586:
1587: before_case = get_last_insn ();
1588:
1589: /* Get upper and lower bounds of case values.
1590: Also convert all the case values to the index expr's data type. */
1591: count = 0;
1592: for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
1593: if (elt = TREE_PURPOSE (c))
1594: {
1595: /* Note that in Pascal it will be possible
1596: to have a RANGE_EXPR here as long as both
1597: ends of the range are constant.
1598: It will be necessary to extend this function
1599: to handle them. */
1600: if (TREE_CODE (elt) != INTEGER_CST)
1601: abort ();
1602:
1603: TREE_PURPOSE (c) = elt = convert (TREE_TYPE (index_expr), elt);
1604:
1605: /* Count the elements and track the largest and
1606: smallest of them
1607: (treating them as signed even if they are not). */
1608: if (count++ == 0)
1609: {
1610: minval = maxval = elt;
1611: }
1612: else
1613: {
1614: if (INT_CST_LT (elt, minval))
1615: minval = elt;
1616: if (INT_CST_LT (maxval, elt))
1617: maxval = elt;
1618: }
1619: }
1620: else
1621: default_label = label_rtx (TREE_VALUE (c));
1622:
1623: if (default_label == 0)
1624: abort ();
1625:
1626: /* Compute span of values. */
1627: if (count != 0)
1628: range = combine (MINUS_EXPR, maxval, minval);
1629:
1630: if (count == 0 || TREE_CODE (TREE_TYPE (index_expr)) == ERROR_MARK)
1631: {
1632: expand_expr (index_expr, const0_rtx, VOIDmode, 0);
1633: emit_queue ();
1634: emit_jump (default_label);
1635: }
1636: /* If range of values is much bigger than number of values,
1637: make a sequence of conditional branches instead of a dispatch.
1638: If the switch-index is a constant, do it this way
1639: because we can optimize it. */
1640: else if (TREE_INT_CST_HIGH (range) != 0
1.1 root 1641: #ifdef HAVE_casesi
1.1.1.2 root 1642: || count < 4
1.1 root 1643: #else
1.1.1.2 root 1644: /* If machine does not have a case insn that compares the
1645: bounds, this means extra overhead for dispatch tables
1646: which raises the threshold for using them. */
1647: || count < 5
1.1 root 1648: #endif
1.1.1.2 root 1649: || (unsigned) (TREE_INT_CST_LOW (range)) > 10 * count
1650: || TREE_CODE (index_expr) == INTEGER_CST)
1651: {
1652: index = expand_expr (index_expr, 0, VOIDmode, 0);
1653: emit_queue ();
1.1 root 1654:
1.1.1.2 root 1655: index = protect_from_queue (index, 0);
1656: if (GET_CODE (index) == MEM)
1657: index = copy_to_reg (index);
1658: do_pending_stack_adjust ();
1.1 root 1659:
1.1.1.2 root 1660: for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
1661: {
1662: elt = TREE_PURPOSE (c);
1663: if (elt && TREE_VALUE (c))
1.1.1.6 ! root 1664: do_jump_if_equal (index, expand_expr (elt, 0, VOIDmode, 0),
1.1.1.2 root 1665: label_rtx (TREE_VALUE (c)));
1666: }
1667:
1668: emit_jump (default_label);
1669: }
1670: else
1671: {
1.1 root 1672: #ifdef HAVE_casesi
1.1.1.3 root 1673: /* Convert the index to SImode. */
1.1.1.2 root 1674: if (TYPE_MODE (TREE_TYPE (index_expr)) == DImode)
1675: {
1.1.1.3 root 1676: index_expr = build (MINUS_EXPR, TREE_TYPE (index_expr),
1677: index_expr, minval);
1.1.1.2 root 1678: minval = integer_zero_node;
1679: }
1.1.1.3 root 1680: if (TYPE_MODE (TREE_TYPE (index_expr)) != SImode)
1681: index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
1682: index_expr);
1.1.1.2 root 1683: index = expand_expr (index_expr, 0, VOIDmode, 0);
1684: emit_queue ();
1685: index = protect_from_queue (index, 0);
1686: do_pending_stack_adjust ();
1687:
1688: emit_jump_insn (gen_casesi (index, expand_expr (minval, 0, VOIDmode, 0),
1689: expand_expr (range, 0, VOIDmode, 0),
1690: table_label, default_label));
1.1 root 1691: #else
1692: #ifdef HAVE_tablejump
1.1.1.3 root 1693: index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
1.1.1.2 root 1694: build (MINUS_EXPR, TREE_TYPE (index_expr),
1695: index_expr, minval));
1696: index = expand_expr (index_expr, 0, VOIDmode, 0);
1697: emit_queue ();
1698: index = protect_from_queue (index, 0);
1699: do_pending_stack_adjust ();
1700:
1701: do_tablejump (index,
1702: gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (range)),
1703: table_label, default_label);
1.1 root 1704: #else
1.1.1.2 root 1705: lossage;
1706: #endif /* not HAVE_tablejump */
1707: #endif /* not HAVE_casesi */
1708:
1709: /* Get table of labels to jump to, in order of case index. */
1710:
1711: ncases = TREE_INT_CST_LOW (range) + 1;
1712: labelvec = (rtx *) alloca (ncases * sizeof (rtx));
1713: bzero (labelvec, ncases * sizeof (rtx));
1.1 root 1714:
1.1.1.2 root 1715: for (c = thiscase->data.case_stmt.case_list; c; c = TREE_CHAIN (c))
1716: if (TREE_VALUE (c) && (elt = TREE_PURPOSE (c)))
1717: {
1718: register int i
1719: = TREE_INT_CST_LOW (elt) - TREE_INT_CST_LOW (minval);
1720: labelvec[i]
1721: = gen_rtx (LABEL_REF, Pmode, label_rtx (TREE_VALUE (c)));
1722: }
1723:
1724: /* Fill in the gaps with the default. */
1725: for (i = 0; i < ncases; i++)
1726: if (labelvec[i] == 0)
1727: labelvec[i] = gen_rtx (LABEL_REF, Pmode, default_label);
1728:
1729: /* Output the table */
1730: emit_label (table_label);
1.1 root 1731:
1732: #ifdef CASE_VECTOR_PC_RELATIVE
1.1.1.2 root 1733: emit_jump_insn (gen_rtx (ADDR_DIFF_VEC, CASE_VECTOR_MODE,
1734: gen_rtx (LABEL_REF, Pmode, table_label),
1735: gen_rtvec_v (ncases, labelvec)));
1.1 root 1736: #else
1.1.1.2 root 1737: emit_jump_insn (gen_rtx (ADDR_VEC, CASE_VECTOR_MODE,
1738: gen_rtvec_v (ncases, labelvec)));
1.1 root 1739: #endif
1.1.1.2 root 1740: /* If the case insn drops through the table,
1741: after the table we must jump to the default-label.
1742: Otherwise record no drop-through after the table. */
1743: #ifdef CASE_DROPS_THROUGH
1744: emit_jump (default_label);
1745: #else
1746: emit_barrier ();
1747: #endif
1748: }
1749:
1750: reorder_insns (NEXT_INSN (before_case), get_last_insn (),
1751: thiscase->data.case_stmt.start);
1752: }
1753: if (thiscase->exit_label)
1754: emit_label (thiscase->exit_label);
1755:
1756: POPSTACK (case_stack);
1757: }
1758:
1759: /* Generate code to jump to LABEL if OP1 and OP2 are equal. */
1760: /* ??? This may need an UNSIGNEDP argument to work properly ??? */
1761:
1762: void
1763: do_jump_if_equal (op1, op2, label)
1764: rtx op1, op2, label;
1765: {
1766: if (GET_CODE (op1) == CONST_INT
1767: && GET_CODE (op2) == CONST_INT)
1768: {
1769: if (INTVAL (op1) == INTVAL (op2))
1770: emit_jump (label);
1771: }
1772: else
1773: {
1774: emit_cmp_insn (op1, op2, 0, 0);
1775: emit_jump_insn (gen_beq (label));
1776: }
1.1 root 1777: }
1778:
1.1.1.2 root 1779: /* Allocate fixed slots in the stack frame of the current function. */
1.1 root 1780:
1781: /* Return size needed for stack frame based on slots so far allocated. */
1782:
1783: int
1784: get_frame_size ()
1785: {
1.1.1.2 root 1786: #ifdef FRAME_GROWS_DOWNWARD
1787: return -frame_offset;
1788: #else
1.1 root 1789: return frame_offset;
1.1.1.2 root 1790: #endif
1.1 root 1791: }
1792:
1793: /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
1794: with machine mode MODE. */
1795:
1796: rtx
1797: assign_stack_local (mode, size)
1798: enum machine_mode mode;
1799: int size;
1800: {
1.1.1.2 root 1801: register rtx x, addr;
1.1.1.4 root 1802: int bigend_correction = 0;
1.1 root 1803:
1.1.1.2 root 1804: frame_pointer_needed = 1;
1.1 root 1805:
1806: /* Make each stack slot a multiple of the main allocation unit. */
1807: size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
1808: / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
1809: * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
1810:
1.1.1.4 root 1811: /* On a big-endian machine, if we are allocating more space than we will use,
1812: use the least significant bytes of those that are allocated. */
1813: #ifdef BYTES_BIG_ENDIAN
1814: if (mode != BLKmode)
1815: bigend_correction = size - GET_MODE_SIZE (mode);
1816: #endif
1817:
1.1 root 1818: #ifdef FRAME_GROWS_DOWNWARD
1819: frame_offset -= size;
1820: #endif
1.1.1.2 root 1821: addr = gen_rtx (PLUS, Pmode, frame_pointer_rtx,
1.1.1.4 root 1822: gen_rtx (CONST_INT, VOIDmode,
1823: (frame_offset + bigend_correction)));
1.1 root 1824: #ifndef FRAME_GROWS_DOWNWARD
1825: frame_offset += size;
1826: #endif
1827:
1.1.1.2 root 1828: if (! memory_address_p (mode, addr))
1829: invalid_stack_slot = 1;
1830:
1831: x = gen_rtx (MEM, mode, addr);
1832:
1833: return x;
1.1 root 1834: }
1835:
1.1.1.2 root 1836: /* Retroactively move an auto variable from a register to a stack slot.
1837: This is done when an address-reference to the variable is seen. */
1.1 root 1838:
1.1.1.2 root 1839: void
1840: put_var_into_stack (decl)
1841: tree decl;
1842: {
1843: register rtx reg = DECL_RTL (decl);
1844: register rtx new;
1.1 root 1845:
1.1.1.2 root 1846: /* No need to do anything if decl has no rtx yet
1847: since in that case caller is setting TREE_ADDRESSABLE
1848: and a stack slot will be assigned when the rtl is made. */
1849: if (reg == 0)
1850: return;
1851: if (GET_CODE (reg) != REG)
1852: return;
1853:
1854: new = parm_stack_loc (reg);
1855: if (new == 0)
1856: new = assign_stack_local (GET_MODE (reg), GET_MODE_SIZE (GET_MODE (reg)));
1857:
1858: /* If this is a memory ref that contains aggregate components,
1859: mark it as such for cse and loop optimize. */
1860: reg->in_struct
1861: = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
1862: || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
1863: || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
1864:
1865: XEXP (reg, 0) = XEXP (new, 0);
1866: PUT_CODE (reg, MEM);
1867: /* `volatil' bit means one thing for MEMs, another entirely for REGs. */
1868: reg->volatil = 0;
1.1 root 1869:
1.1.1.2 root 1870: fixup_var_refs (reg);
1871: }
1872:
1.1 root 1873: static void
1.1.1.2 root 1874: fixup_var_refs (var)
1875: rtx var;
1.1 root 1876: {
1.1.1.2 root 1877: register rtx insn;
1878:
1879: /* Yes. Must scan all insns for stack-refs that exceed the limit. */
1880: for (insn = get_insns (); insn; )
1881: {
1882: rtx next = NEXT_INSN (insn);
1883: if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
1884: || GET_CODE (insn) == JUMP_INSN)
1885: {
1886: /* The insn to load VAR from a home in the arglist
1887: is now a no-op. When we see it, just delete it. */
1888: if (GET_CODE (PATTERN (insn)) == SET
1889: && SET_DEST (PATTERN (insn)) == var
1890: && rtx_equal_p (SET_SRC (PATTERN (insn)), var))
1891: next = delete_insn (insn);
1892: else
1893: fixup_var_refs_1 (var, PATTERN (insn), insn);
1894: }
1895: insn = next;
1896: }
1897: }
1898:
1899: static rtx
1900: fixup_var_refs_1 (var, x, insn)
1901: register rtx var;
1902: register rtx x;
1903: rtx insn;
1904: {
1905: register int i;
1906: RTX_CODE code = GET_CODE (x);
1907: register char *fmt;
1908: register rtx tem;
1909:
1910: switch (code)
1911: {
1912: case MEM:
1913: if (var == x)
1914: {
1915: x = fixup_stack_1 (x, insn);
1916: tem = gen_reg_rtx (GET_MODE (x));
1917: emit_insn_before (gen_move_insn (tem, x), insn);
1918: return tem;
1919: }
1920: break;
1921:
1922: case REG:
1923: case CC0:
1924: case PC:
1925: case CONST_INT:
1926: case CONST:
1927: case SYMBOL_REF:
1928: case LABEL_REF:
1929: case CONST_DOUBLE:
1930: return x;
1931:
1932: case SIGN_EXTRACT:
1933: case ZERO_EXTRACT:
1934: /* Note that in some cases those types of expressions are altered
1935: by optimize_bit_field, and do not survive to get here. */
1936: case SUBREG:
1937: tem = x;
1938: while (GET_CODE (tem) == SUBREG || GET_CODE (tem) == SIGN_EXTRACT
1939: || GET_CODE (tem) == ZERO_EXTRACT)
1940: tem = XEXP (tem, 0);
1941: if (tem == var)
1942: {
1943: x = fixup_stack_1 (x, insn);
1944: tem = gen_reg_rtx (GET_MODE (x));
1945: emit_insn_before (gen_move_insn (tem, x), insn);
1946: return tem;
1947: }
1948: break;
1949:
1950: case SET:
1951: /* First do special simplification of bit-field references. */
1952: if (GET_CODE (SET_DEST (x)) == SIGN_EXTRACT
1953: || GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
1954: optimize_bit_field (x, insn, 0);
1955: if (GET_CODE (SET_SRC (x)) == SIGN_EXTRACT
1956: || GET_CODE (SET_SRC (x)) == ZERO_EXTRACT)
1957: optimize_bit_field (x, insn, 0);
1958:
1959: {
1960: rtx dest = SET_DEST (x);
1961: rtx src = SET_SRC (x);
1962: rtx outerdest = dest;
1963: rtx outersrc = src;
1964: int strictflag = GET_CODE (dest) == STRICT_LOW_PART;
1965:
1966: while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART
1967: || GET_CODE (dest) == SIGN_EXTRACT
1968: || GET_CODE (dest) == ZERO_EXTRACT)
1969: dest = XEXP (dest, 0);
1970: while (GET_CODE (src) == SUBREG
1971: || GET_CODE (src) == SIGN_EXTRACT
1972: || GET_CODE (src) == ZERO_EXTRACT)
1973: src = XEXP (src, 0);
1974:
1975: /* If VAR does not appear at the top level of the SET
1976: just scan the lower levels of the tree. */
1977:
1978: if (src != var && dest != var)
1979: break;
1980:
1981: /* Clean up (SUBREG:SI (MEM:mode ...) 0)
1982: that may appear inside a SIGN_EXTRACT or ZERO_EXTRACT.
1983: This was legitimate when the MEM was a REG. */
1984:
1985: if ((GET_CODE (outerdest) == SIGN_EXTRACT
1986: || GET_CODE (outerdest) == ZERO_EXTRACT)
1987: && GET_CODE (XEXP (outerdest, 0)) == SUBREG
1988: && SUBREG_REG (XEXP (outerdest, 0)) == var)
1989: XEXP (outerdest, 0) = fixup_memory_subreg (XEXP (outerdest, 0));
1990:
1991: if ((GET_CODE (outersrc) == SIGN_EXTRACT
1992: || GET_CODE (outersrc) == ZERO_EXTRACT)
1993: && GET_CODE (XEXP (outersrc, 0)) == SUBREG
1994: && SUBREG_REG (XEXP (outersrc, 0)) == var)
1995: XEXP (outersrc, 0) = fixup_memory_subreg (XEXP (outersrc, 0));
1996:
1997: /* Make sure a MEM inside a SIGN_EXTRACT has QImode
1998: since that's what bit-field insns want. */
1999:
2000: if ((GET_CODE (outerdest) == SIGN_EXTRACT
2001: || GET_CODE (outerdest) == ZERO_EXTRACT)
2002: && GET_CODE (XEXP (outerdest, 0)) == MEM
2003: && GET_MODE (XEXP (outerdest, 0)) != QImode)
2004: {
2005: XEXP (outerdest, 0) = copy_rtx (XEXP (outerdest, 0));
2006: PUT_MODE (XEXP (outerdest, 0), QImode);
2007: }
2008:
2009: if ((GET_CODE (outersrc) == SIGN_EXTRACT
2010: || GET_CODE (outersrc) == ZERO_EXTRACT)
2011: && GET_CODE (XEXP (outersrc, 0)) == MEM
2012: && GET_MODE (XEXP (outersrc, 0)) != QImode)
2013: {
2014: XEXP (outersrc, 0) = copy_rtx (XEXP (outersrc, 0));
2015: PUT_MODE (XEXP (outersrc, 0), QImode);
2016: }
2017:
2018: /* STRICT_LOW_PART is a no-op on memory references
2019: and it can cause combinations to be unrecognizable,
2020: so eliminate it. */
2021:
2022: if (dest == var && GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
2023: SET_DEST (x) = XEXP (SET_DEST (x), 0);
2024:
2025: /* An insn to copy VAR into or out of a register
2026: must be left alone, to avoid an infinite loop here.
2027: But do fix up the address of VAR's stack slot if nec. */
2028:
2029: if (GET_CODE (SET_SRC (x)) == REG || GET_CODE (SET_DEST (x)) == REG)
2030: return fixup_stack_1 (x, insn);
2031:
2032: if ((GET_CODE (SET_SRC (x)) == SUBREG
2033: && GET_CODE (SUBREG_REG (SET_SRC (x))) == REG)
2034: || (GET_CODE (SET_DEST (x)) == SUBREG
2035: && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
2036: return fixup_stack_1 (x, insn);
2037:
2038: /* Otherwise, storing into VAR must be handled specially
2039: by storing into a temporary and copying that into VAR
2040: with a new insn after this one. */
2041:
2042: if (dest == var)
2043: {
2044: rtx temp;
2045: rtx fixeddest;
2046: tem = SET_DEST (x);
2047: if (GET_CODE (tem) == STRICT_LOW_PART)
2048: tem = XEXP (tem, 0);
2049: temp = gen_reg_rtx (GET_MODE (tem));
2050: fixeddest = fixup_stack_1 (SET_DEST (x), insn);
2051: emit_insn_after (gen_move_insn (fixeddest, temp), insn);
2052: SET_DEST (x) = temp;
2053: }
2054: }
2055: }
2056:
2057: /* Nothing special about this RTX; fix its operands. */
2058:
2059: fmt = GET_RTX_FORMAT (code);
2060: for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2061: {
2062: if (fmt[i] == 'e')
2063: XEXP (x, i) = fixup_var_refs_1 (var, XEXP (x, i), insn);
2064: if (fmt[i] == 'E')
2065: {
2066: register int j;
2067: for (j = 0; j < XVECLEN (x, i); j++)
2068: XVECEXP (x, i, j)
2069: = fixup_var_refs_1 (var, XVECEXP (x, i, j), insn);
2070: }
2071: }
2072: return x;
2073: }
2074:
2075: /* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)),
2076: return an rtx (MEM:m1 newaddr) which is equivalent. */
2077:
2078: static rtx
2079: fixup_memory_subreg (x)
2080: rtx x;
2081: {
2082: int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
2083: rtx addr = XEXP (SUBREG_REG (x), 0);
2084: enum machine_mode mode = GET_MODE (SUBREG_REG (x));
2085:
2086: #ifdef BYTES_BIG_ENDIAN
2087: offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
2088: - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
2089: #endif
2090: return change_address (SUBREG_REG (x), mode,
2091: plus_constant (addr, offset));
2092: }
2093:
2094: #if 0
2095: /* Fix up any references to stack slots that are invalid memory addresses
2096: because they exceed the maximum range of a displacement. */
2097:
2098: void
2099: fixup_stack_slots ()
2100: {
2101: register rtx insn;
2102:
2103: /* Did we generate a stack slot that is out of range
2104: or otherwise has an invalid address? */
2105: if (invalid_stack_slot)
2106: {
2107: /* Yes. Must scan all insns for stack-refs that exceed the limit. */
2108: for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2109: if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
2110: || GET_CODE (insn) == JUMP_INSN)
2111: fixup_stack_1 (PATTERN (insn), insn);
2112: }
2113: }
2114: #endif
2115:
2116: /* For each memory ref within X, if it refers to a stack slot
2117: with an out of range displacement, put the address in a temp register
2118: (emitting new insns before INSN to load these registers)
2119: and alter the memory ref to use that register.
2120: Replace each such MEM rtx with a copy, to avoid clobberage. */
2121:
2122: static rtx
2123: fixup_stack_1 (x, insn)
2124: rtx x;
2125: rtx insn;
2126: {
2127: register int i;
2128: register RTX_CODE code = GET_CODE (x);
2129: register char *fmt;
2130:
2131: if (code == MEM)
2132: {
2133: register rtx ad = XEXP (x, 0);
2134: /* If we have address of a stack slot but it's not valid
2135: (displacement is too large), compute the sum in a register. */
2136: if (GET_CODE (ad) == PLUS
2137: && XEXP (ad, 0) == frame_pointer_rtx
2138: && GET_CODE (XEXP (ad, 1)) == CONST_INT)
2139: {
2140: rtx temp;
2141: if (memory_address_p (GET_MODE (x), ad))
2142: return x;
2143: temp = gen_reg_rtx (GET_MODE (ad));
2144: emit_insn_before (gen_move_insn (temp, ad), insn);
2145: return change_address (x, VOIDmode, temp);
2146: }
2147: return x;
2148: }
2149:
2150: fmt = GET_RTX_FORMAT (code);
2151: for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2152: {
2153: if (fmt[i] == 'e')
2154: XEXP (x, i) = fixup_stack_1 (XEXP (x, i), insn);
2155: if (fmt[i] == 'E')
2156: {
2157: register int j;
2158: for (j = 0; j < XVECLEN (x, i); j++)
2159: XVECEXP (x, i, j) = fixup_stack_1 (XVECEXP (x, i, j), insn);
2160: }
2161: }
2162: return x;
1.1 root 2163: }
1.1.1.2 root 2164:
2165: /* Optimization: a bit-field instruction whose field
2166: happens to be a byte or halfword in memory
2167: can be changed to a move instruction.
1.1 root 2168:
1.1.1.2 root 2169: We call here when INSN is an insn to examine or store into a bit-field.
2170: BODY is the SET-rtx to be altered.
2171:
2172: EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0.
2173: (Currently this is called only from stmt.c, and EQUIV_MEM is always 0.) */
1.1 root 2174:
2175: static void
1.1.1.2 root 2176: optimize_bit_field (body, insn, equiv_mem)
2177: rtx body;
2178: rtx insn;
2179: rtx *equiv_mem;
1.1 root 2180: {
1.1.1.2 root 2181: register rtx bitfield;
2182: int destflag;
1.1 root 2183:
1.1.1.2 root 2184: if (GET_CODE (SET_DEST (body)) == SIGN_EXTRACT
2185: || GET_CODE (SET_DEST (body)) == ZERO_EXTRACT)
2186: bitfield = SET_DEST (body), destflag = 1;
2187: else
2188: bitfield = SET_SRC (body), destflag = 0;
2189:
2190: /* First check that the field being stored has constant size and position
2191: and is in fact a byte or halfword suitably aligned. */
2192:
2193: if (GET_CODE (XEXP (bitfield, 1)) == CONST_INT
2194: && GET_CODE (XEXP (bitfield, 2)) == CONST_INT
2195: && (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
2196: || INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (HImode))
2197: && INTVAL (XEXP (bitfield, 2)) % INTVAL (XEXP (bitfield, 1)) == 0)
1.1 root 2198: {
1.1.1.2 root 2199: register rtx memref = 0;
2200:
2201: /* Now check that the contanting word is memory, not a register,
2202: and that it is safe to change the machine mode and to
2203: add something to the address. */
2204:
2205: if (GET_CODE (XEXP (bitfield, 0)) == MEM)
2206: memref = XEXP (bitfield, 0);
2207: else if (GET_CODE (XEXP (bitfield, 0)) == REG
2208: && equiv_mem != 0
2209: && (memref = equiv_mem[REGNO (XEXP (bitfield, 0))]) != 0)
2210: ;
2211: else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
2212: && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == MEM)
2213: memref = SUBREG_REG (XEXP (bitfield, 0));
2214: else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
2215: && equiv_mem != 0
2216: && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == REG
2217: && (memref = equiv_mem[REGNO (SUBREG_REG (XEXP (bitfield, 0)))]) != 0)
2218: ;
2219:
2220: if (memref
2221: && ! mode_dependent_address_p (XEXP (memref, 0))
2222: && offsetable_address_p (GET_MODE (bitfield), XEXP (memref, 0)))
1.1 root 2223: {
1.1.1.2 root 2224: /* Now adjust the address, first for any subreg'ing
2225: that we are now getting rid of,
2226: and then for which byte of the word is wanted. */
2227:
2228: register int offset
2229: = INTVAL (XEXP (bitfield, 2)) / GET_MODE_BITSIZE (QImode);
2230: if (GET_CODE (XEXP (bitfield, 0)) == SUBREG)
2231: {
2232: offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD;
2233: #ifdef BYTES_BIG_ENDIAN
2234: offset -= (MIN (UNITS_PER_WORD,
2235: GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0))))
2236: - MIN (UNITS_PER_WORD,
2237: GET_MODE_SIZE (GET_MODE (memref))));
2238: #endif
2239: }
2240: memref = gen_rtx (MEM,
2241: (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
2242: ? QImode : HImode),
2243: XEXP (memref, 0));
1.1 root 2244:
1.1.1.2 root 2245: /* Store this memory reference where
2246: we found the bit field reference. */
1.1 root 2247:
1.1.1.2 root 2248: if (destflag)
1.1 root 2249: {
1.1.1.2 root 2250: SET_DEST (body)
2251: = adj_offsetable_operand (memref, offset);
2252: if (! CONSTANT_ADDRESS_P (SET_SRC (body)))
1.1 root 2253: {
1.1.1.2 root 2254: rtx src = SET_SRC (body);
2255: while (GET_CODE (src) == SUBREG
2256: && SUBREG_WORD (src) == 0)
2257: src = SUBREG_REG (src);
2258: if (GET_MODE (src) != GET_MODE (memref))
2259: src = gen_rtx (SUBREG, GET_MODE (memref),
2260: SET_SRC (body), 0);
2261: SET_SRC (body) = src;
1.1 root 2262: }
1.1.1.2 root 2263: else if (GET_MODE (SET_SRC (body)) != VOIDmode
2264: && GET_MODE (SET_SRC (body)) != GET_MODE (memref))
2265: /* This shouldn't happen because anything that didn't have
2266: one of these modes should have got converted explicitly
2267: and then referenced through a subreg.
2268: This is so because the original bit-field was
2269: handled by agg_mode and so its tree structure had
2270: the same mode that memref now has. */
2271: abort ();
2272: }
2273: else
2274: {
2275: rtx newreg = gen_reg_rtx (GET_MODE (SET_DEST (body)));
2276: emit_insn_before (gen_extend_insn (newreg, adj_offsetable_operand (memref, offset),
2277: GET_MODE (SET_DEST (body)),
2278: GET_MODE (memref),
2279: GET_CODE (SET_SRC (body)) == ZERO_EXTRACT),
2280: insn);
2281: SET_SRC (body) = newreg;
1.1 root 2282: }
1.1.1.2 root 2283:
2284: /* Cause the insn to be re-recognized. */
2285:
2286: INSN_CODE (insn) = -1;
1.1 root 2287: }
2288: }
2289: }
2290:
2291: /* 1 + last pseudo register number used for loading a copy
2292: of a parameter of this function. */
2293:
2294: static int max_parm_reg;
2295:
1.1.1.2 root 2296: /* Vector indexed by REGNO, containing location on stack in which
2297: to put the parm which is nominally in pseudo register REGNO,
2298: if we discover that that parm must go in the stack. */
2299: static rtx *parm_reg_stack_loc;
2300:
2301: /* Last insn of those whose job was to put parms into their nominal homes. */
2302: static rtx last_parm_insn;
2303:
2304: int
2305: max_parm_reg_num ()
2306: {
2307: return max_parm_reg;
2308: }
2309:
2310: /* Return the first insn following those generated by `assign_parms'. */
2311:
2312: rtx
2313: get_first_nonparm_insn ()
2314: {
2315: if (last_parm_insn)
2316: return NEXT_INSN (last_parm_insn);
2317: return get_insns ();
2318: }
2319:
2320: /* Get the stack home of a REG rtx that is one of this function's parameters.
2321: This is called rather than assign a new stack slot as a local.
2322: Return 0 if there is no existing stack home suitable for such use. */
2323:
2324: static rtx
2325: parm_stack_loc (reg)
2326: rtx reg;
2327: {
2328: if (REGNO (reg) < max_parm_reg)
2329: return parm_reg_stack_loc[REGNO (reg)];
2330: return 0;
2331: }
2332:
1.1 root 2333: /* Assign RTL expressions to the function's parameters.
2334: This may involve copying them into registers and using
2335: those registers as the RTL for them. */
2336:
2337: static void
2338: assign_parms (fndecl)
2339: tree fndecl;
2340: {
2341: register tree parm;
1.1.1.2 root 2342: register rtx entry_parm;
2343: register rtx stack_parm;
2344: register CUMULATIVE_ARGS args_so_far;
2345: enum machine_mode passed_mode, nominal_mode;
2346: /* Total space needed so far for args on the stack,
2347: given as a constant and a tree-expression. */
2348: struct args_size stack_args_size;
2349:
2350: int nparmregs
2351: = list_length (DECL_ARGUMENTS (fndecl)) + FIRST_PSEUDO_REGISTER;
2352:
2353: /* Nonzero if function takes extra anonymous args.
2354: This means the last named arg must be on the stack
1.1.1.4 root 2355: right before the anonymous ones.
2356: Also nonzero if the first arg is named `__builtin_va_alist',
2357: which is used on some machines for old-fashioned non-ANSI varargs.h;
2358: this too should be stuck onto the stack as if it had arrived there. */
1.1.1.2 root 2359: int vararg
1.1.1.4 root 2360: = ((DECL_ARGUMENTS (fndecl) != 0
2361: && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))),
2362: "__builtin_va_alist")))
2363: ||
2364: (TYPE_ARG_TYPES (TREE_TYPE (fndecl)) != 0
2365: && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))))
2366: != void_type_node)));
1.1.1.2 root 2367:
2368: stack_args_size.constant = 0;
2369: stack_args_size.var = 0;
2370:
1.1.1.6 ! root 2371: /* If struct value address comes on the stack, count it in size of args. */
! 2372: if (DECL_MODE (DECL_RESULT (fndecl)) == BLKmode
! 2373: && GET_CODE (struct_value_incoming_rtx) == MEM)
! 2374: stack_args_size.constant += GET_MODE_SIZE (Pmode);
! 2375:
1.1.1.2 root 2376: parm_reg_stack_loc = (rtx *) oballoc (nparmregs * sizeof (rtx));
2377: bzero (parm_reg_stack_loc, nparmregs * sizeof (rtx));
2378:
2379: INIT_CUMULATIVE_ARGS (args_so_far, TREE_TYPE (fndecl));
1.1 root 2380:
1.1.1.2 root 2381: for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
1.1 root 2382: {
1.1.1.2 root 2383: int aggregate
2384: = (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE
2385: || TREE_CODE (TREE_TYPE (parm)) == RECORD_TYPE
2386: || TREE_CODE (TREE_TYPE (parm)) == UNION_TYPE);
2387: struct args_size stack_offset;
2388: rtx stack_offset_rtx;
1.1.1.6 ! root 2389: enum direction where_pad;
1.1.1.2 root 2390:
2391: DECL_OFFSET (parm) = -1;
2392:
1.1 root 2393: if (TREE_TYPE (parm) == error_mark_node)
1.1.1.2 root 2394: {
2395: DECL_RTL (parm) = gen_rtx (MEM, BLKmode, const0_rtx);
2396: continue;
2397: }
2398:
2399: /* Find mode of arg as it is passed, and mode of arg
2400: as it should be during execution of this function. */
2401: passed_mode = TYPE_MODE (DECL_ARG_TYPE (parm));
2402: nominal_mode = TYPE_MODE (TREE_TYPE (parm));
2403:
1.1.1.6 ! root 2404: /* Get this parm's offset as an rtx. */
! 2405: stack_offset = stack_args_size;
! 2406: stack_offset.constant += FIRST_PARM_OFFSET;
! 2407:
! 2408: /* Find out if the parm needs padding, and whether above or below. */
! 2409: where_pad
! 2410: = FUNCTION_ARG_PADDING (passed_mode,
! 2411: expand_expr (size_in_bytes (DECL_ARG_TYPE (parm)),
! 2412: 0, VOIDmode, 0));
! 2413:
! 2414: /* If it is padded below, adjust the stack address
! 2415: upward over the padding. */
! 2416: if (where_pad == downward)
! 2417: {
! 2418: if (passed_mode != BLKmode)
! 2419: {
! 2420: if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY)
! 2421: stack_offset.constant
! 2422: += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1)
! 2423: / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT)
! 2424: - GET_MODE_SIZE (passed_mode));
! 2425: }
! 2426: else
! 2427: {
! 2428: tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
! 2429: /* Round the size up to multiple of PARM_BOUNDARY bits. */
! 2430: tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
! 2431: tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
! 2432: /* Add it in. */
! 2433: ADD_PARM_SIZE (stack_offset, s2);
! 2434: SUB_PARM_SIZE (stack_offset, sizetree);
! 2435: }
! 2436: }
! 2437:
! 2438: stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
! 2439:
1.1.1.2 root 2440: /* Determine parm's home in the stack,
2441: in case it arrives in the stack or we should pretend it did. */
2442: stack_parm
2443: = gen_rtx (MEM, passed_mode,
2444: memory_address (passed_mode,
2445: gen_rtx (PLUS, Pmode,
2446: arg_pointer_rtx, stack_offset_rtx)));
2447:
2448: /* If this is a memory ref that contains aggregate components,
2449: mark it as such for cse and loop optimize. */
2450: stack_parm->in_struct = aggregate;
2451:
2452: /* Let machine desc say which reg (if any) the parm arrives in.
2453: 0 means it arrives on the stack. */
2454: entry_parm = 0;
2455: /* Variable-size args, and args following such, are never in regs. */
2456: if (TREE_CODE (TYPE_SIZE (TREE_TYPE (parm))) == INTEGER_CST
2457: || stack_offset.var != 0)
2458: {
2459: #ifdef FUNCTION_INCOMING_ARG
2460: entry_parm
2461: = FUNCTION_INCOMING_ARG (args_so_far, passed_mode,
2462: DECL_ARG_TYPE (parm), 1);
2463: #else
2464: entry_parm
2465: = FUNCTION_ARG (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1);
2466: #endif
2467: }
2468: /* If this parm was passed part in regs and part in memory,
2469: pretend it arrived entirely in memory
2470: by pushing the register-part onto the stack.
2471:
2472: In the special case of a DImode or DFmode that is split,
2473: we could put it together in a pseudoreg directly,
2474: but for now that's not worth bothering with. */
2475:
2476: /* If this is the last named arg and anonymous args follow,
2477: likewise pretend this arg arrived on the stack
2478: so varargs can find the anonymous args following it. */
2479: {
2480: int nregs = 0;
2481: int i;
2482: #ifdef FUNCTION_ARG_PARTIAL_NREGS
2483: nregs = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, passed_mode,
2484: DECL_ARG_TYPE (parm), 1);
2485: #endif
2486: if (TREE_CHAIN (parm) == 0 && vararg && entry_parm != 0)
1.1.1.4 root 2487: {
2488: if (GET_MODE (entry_parm) == BLKmode)
2489: nregs = GET_MODE_SIZE (GET_MODE (entry_parm)) / UNITS_PER_WORD;
2490: else
2491: nregs = (int_size_in_bytes (DECL_ARG_TYPE (parm))
2492: / UNITS_PER_WORD);
2493: }
1.1.1.2 root 2494:
2495: if (nregs > 0)
1.1.1.4 root 2496: {
2497: current_function_pretend_args_size
2498: = (((nregs * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1)
2499: / (PARM_BOUNDARY / BITS_PER_UNIT)
2500: * (PARM_BOUNDARY / BITS_PER_UNIT));
2501:
2502: i = nregs;
2503: while (--i >= 0)
2504: emit_move_insn (gen_rtx (MEM, SImode,
2505: plus_constant (XEXP (stack_parm, 0),
2506: i * GET_MODE_SIZE (SImode))),
2507: gen_rtx (REG, SImode, REGNO (entry_parm) + i));
2508: entry_parm = stack_parm;
2509: }
1.1.1.2 root 2510: }
2511:
1.1.1.4 root 2512: /* If we didn't decide this parm came in a register,
2513: by default it came on the stack. */
1.1.1.2 root 2514: if (entry_parm == 0)
2515: entry_parm = stack_parm;
2516:
1.1.1.4 root 2517: /* For a stack parm, record in DECL_OFFSET the arglist offset
2518: of the parm at the time it is passed (before conversion). */
1.1.1.2 root 2519: if (entry_parm == stack_parm)
1.1.1.4 root 2520: DECL_OFFSET (parm) = stack_offset.constant * BITS_PER_UNIT;
2521:
2522: /* If there is actually space on the stack for this parm,
2523: count it in stack_args_size; otherwise set stack_parm to 0
2524: to indicate there is no preallocated stack slot for the parm. */
2525:
2526: if (entry_parm == stack_parm
2527: #ifdef REG_PARM_STACK_SPACE
2528: /* On some machines, even if a parm value arrives in a register
2529: there is still an (uninitialized) stack slot allocated for it. */
2530: || 1
2531: #endif
2532: )
1.1.1.2 root 2533: {
2534: tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
1.1.1.6 ! root 2535: if (where_pad != none)
! 2536: {
! 2537: /* Round the size up to multiple of PARM_BOUNDARY bits. */
! 2538: tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
! 2539: sizetree = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
! 2540: }
1.1.1.2 root 2541: /* Add it in. */
1.1.1.6 ! root 2542: ADD_PARM_SIZE (stack_args_size, sizetree);
1.1.1.2 root 2543: }
1.1.1.4 root 2544: else
2545: /* No stack slot was pushed for this parm. */
2546: stack_parm = 0;
1.1.1.2 root 2547:
1.1.1.4 root 2548: /* Now adjust STACK_PARM to the mode and precise location
1.1.1.2 root 2549: where this parameter should live during execution,
2550: if we discover that it must live in the stack during execution.
2551: To make debuggers happier on big-endian machines, we store
2552: the value in the last bytes of the space available. */
2553:
1.1.1.4 root 2554: if (nominal_mode != BLKmode && nominal_mode != passed_mode
2555: && stack_parm != 0)
1.1.1.2 root 2556: {
2557: #ifdef BYTES_BIG_ENDIAN
1.1.1.6 ! root 2558: if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD)
! 2559: {
! 2560: stack_offset.constant
! 2561: += GET_MODE_SIZE (passed_mode)
! 2562: - GET_MODE_SIZE (nominal_mode);
! 2563: stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
! 2564: }
1.1.1.2 root 2565: #endif
2566:
2567: stack_parm
2568: = gen_rtx (MEM, nominal_mode,
2569: memory_address (nominal_mode,
2570: gen_rtx (PLUS, Pmode,
2571: arg_pointer_rtx,
2572: stack_offset_rtx)));
2573:
2574: /* If this is a memory ref that contains aggregate components,
2575: mark it as such for cse and loop optimize. */
2576: stack_parm->in_struct = aggregate;
2577: }
2578:
2579: /* ENTRY_PARM is an RTX for the parameter as it arrives,
2580: in the mode in which it arrives.
1.1.1.4 root 2581: STACK_PARM is an RTX for a stack slot where the parameter can live
2582: during the function (in case we want to put it there).
2583: STACK_PARM is 0 if no stack slot was pushed for it.
1.1 root 2584:
1.1.1.4 root 2585: Now output code if necessary to convert ENTRY_PARM to
1.1 root 2586: the type in which this function declares it,
1.1.1.4 root 2587: and store that result in an appropriate place,
2588: which may be a pseudo reg, may be STACK_PARM,
2589: or may be a local stack slot if STACK_PARM is 0.
2590:
2591: Set DECL_RTL to that place. */
1.1.1.2 root 2592:
2593: if (nominal_mode == BLKmode)
2594: {
2595: /* If a BLKmode arrives in registers, copy it to a stack slot. */
1.1.1.4 root 2596: if (GET_CODE (entry_parm) == REG)
1.1.1.2 root 2597: {
1.1.1.4 root 2598: if (stack_parm == 0)
2599: stack_parm
2600: = assign_stack_local (GET_MODE (entry_parm),
2601: int_size_in_bytes (TREE_TYPE (parm)));
1.1.1.2 root 2602:
2603: move_block_from_reg (REGNO (entry_parm), stack_parm,
2604: int_size_in_bytes (TREE_TYPE (parm))
2605: / UNITS_PER_WORD);
2606: }
2607: DECL_RTL (parm) = stack_parm;
2608: }
2609: else if (! ((obey_regdecls && ! TREE_REGDECL (parm))
2610: /* If -ffloat-store specified, don't put explicit
2611: float variables into registers. */
2612: || (flag_float_store
2613: && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE)))
1.1 root 2614: {
1.1.1.2 root 2615: /* Store the parm in a pseudoregister during the function. */
2616: register rtx parmreg = gen_reg_rtx (nominal_mode);
1.1 root 2617:
1.1.1.2 root 2618: parmreg->volatil = 1;
1.1 root 2619: DECL_RTL (parm) = parmreg;
2620:
2621: /* Copy the value into the register. */
1.1.1.2 root 2622: if (GET_MODE (parmreg) != GET_MODE (entry_parm))
2623: convert_move (parmreg, entry_parm, 0);
1.1 root 2624: else
1.1.1.2 root 2625: emit_move_insn (parmreg, entry_parm);
2626:
2627: /* In any case, record the parm's desired stack location
2628: in case we later discover it must live in the stack. */
2629: if (REGNO (parmreg) >= nparmregs)
2630: {
2631: rtx *new;
2632: nparmregs = REGNO (parmreg) + 5;
2633: new = (rtx *) oballoc (nparmregs * sizeof (rtx));
2634: bcopy (parm_reg_stack_loc, new, nparmregs * sizeof (rtx));
2635: parm_reg_stack_loc = new;
2636: }
2637: parm_reg_stack_loc[REGNO (parmreg)] = stack_parm;
1.1 root 2638:
1.1.1.2 root 2639: /* Mark the register as eliminable if we did no conversion
2640: and it was copied from memory at a fixed offset. */
2641: if (nominal_mode == passed_mode
2642: && GET_CODE (entry_parm) == MEM
2643: && stack_offset.var == 0)
2644: REG_NOTES (get_last_insn ()) = gen_rtx (EXPR_LIST, REG_EQUIV,
2645: entry_parm, 0);
1.1 root 2646:
2647: /* For pointer data type, suggest pointer register. */
2648: if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE)
2649: mark_reg_pointer (parmreg);
2650: }
1.1.1.2 root 2651: else
1.1 root 2652: {
1.1.1.2 root 2653: /* Value must be stored in the stack slot STACK_PARM
2654: during function execution. */
2655:
2656: if (passed_mode != nominal_mode)
2657: /* Conversion is required. */
2658: entry_parm = convert_to_mode (nominal_mode, entry_parm, 0);
2659:
2660: if (entry_parm != stack_parm)
2661: {
2662: if (stack_parm == 0)
2663: stack_parm = assign_stack_local (GET_MODE (entry_parm),
2664: GET_MODE_SIZE (GET_MODE (entry_parm)));
2665: emit_move_insn (stack_parm, entry_parm);
2666: }
2667:
2668: DECL_RTL (parm) = stack_parm;
2669: frame_pointer_needed = 1;
1.1 root 2670: }
1.1.1.2 root 2671:
2672: if (TREE_VOLATILE (parm))
2673: DECL_RTL (parm)->volatil = 1;
2674: if (TREE_READONLY (parm))
2675: DECL_RTL (parm)->unchanging = 1;
2676:
2677: /* Update info on where next arg arrives in registers. */
2678:
2679: FUNCTION_ARG_ADVANCE (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1);
1.1 root 2680: }
1.1.1.4 root 2681:
1.1 root 2682: max_parm_reg = max_reg_num ();
1.1.1.2 root 2683: last_parm_insn = get_last_insn ();
2684:
2685: current_function_args_size = stack_args_size.constant;
1.1 root 2686: }
2687:
2688: /* Allocation of space for returned structure values.
2689: During the rtl generation pass, `get_structure_value_addr'
2690: is called from time to time to request the address of a block in our
2691: stack frame in which called functions will store the structures
2692: they are returning. The same space is used for all of these blocks.
2693:
1.1.1.2 root 2694: We allocate these blocks like stack locals. We keep reusing
2695: the same block until a bigger one is needed. */
2696:
2697: /* Length in bytes of largest structure value returned by
2698: any function called so far in this function. */
2699: static int max_structure_value_size;
1.1 root 2700:
1.1.1.2 root 2701: /* An rtx for the addr we are currently using for structure values.
2702: This is typically (PLUS (REG:SI stackptr) (CONST_INT...)). */
2703: static rtx structure_value;
1.1 root 2704:
2705: rtx
2706: get_structure_value_addr (sizex)
2707: rtx sizex;
2708: {
2709: register int size;
2710: if (GET_CODE (sizex) != CONST_INT)
2711: abort ();
2712: size = INTVAL (sizex);
2713:
2714: /* Round up to a multiple of the main allocation unit. */
2715: size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
2716: / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
2717: * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
2718:
1.1.1.2 root 2719: /* If this size is bigger than space we know to use,
2720: get a bigger piece of space. */
1.1 root 2721: if (size > max_structure_value_size)
2722: {
2723: max_structure_value_size = size;
1.1.1.2 root 2724: structure_value = assign_stack_local (BLKmode, size);
2725: if (GET_CODE (structure_value) == MEM)
2726: structure_value = XEXP (structure_value, 0);
1.1 root 2727: }
1.1.1.2 root 2728:
2729: return structure_value;
1.1 root 2730: }
1.1.1.2 root 2731:
2732: /* Walk the tree of LET_STMTs describing the binding levels within a function
2733: and warn about uninitialized variables.
2734: This is done after calling flow_analysis and before global_alloc
2735: clobbers the pseudo-regs to hard regs. */
1.1 root 2736:
1.1.1.2 root 2737: void
2738: uninitialized_vars_warning (block)
2739: tree block;
1.1 root 2740: {
1.1.1.2 root 2741: register tree decl, sub;
2742: for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
2743: {
2744: if (TREE_CODE (decl) == VAR_DECL
2745: /* These warnings are unreliable for and aggregates
2746: because assigning the fields one by one can fail to convince
2747: flow.c that the entire aggregate was initialized.
2748: Unions are troublesome because members may be shorter. */
2749: && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
2750: && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE
2751: && TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE
2752: && GET_CODE (DECL_RTL (decl)) == REG
2753: && regno_uninitialized (REGNO (DECL_RTL (decl))))
2754: warning_with_decl (decl,
2755: "variable `%s' used uninitialized in this function");
2756: if (TREE_CODE (decl) == VAR_DECL
2757: && GET_CODE (DECL_RTL (decl)) == REG
2758: && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
2759: warning_with_decl (decl,
2760: "variable `%s' may be clobbered by `longjmp'");
2761: }
2762: for (sub = STMT_BODY (block); sub; sub = TREE_CHAIN (sub))
2763: uninitialized_vars_warning (sub);
1.1 root 2764: }
2765:
1.1.1.2 root 2766: /* Generate RTL for the start of the function FUNC (a FUNCTION_DECL tree node)
2767: and initialize static variables for generating RTL for the statements
2768: of the function. */
1.1 root 2769:
1.1.1.2 root 2770: void
2771: expand_function_start (subr)
1.1 root 2772: tree subr;
2773: {
2774: register int i;
1.1.1.2 root 2775: tree tem;
1.1 root 2776:
2777: this_function = subr;
1.1.1.2 root 2778: cse_not_expected = ! optimize;
2779:
2780: /* We have not yet found a reason why a frame pointer cannot
2781: be omitted for this function in particular, but maybe we know
2782: a priori that it is required.
2783: `flag_omit_frame_pointer' has its main effect here. */
2784: frame_pointer_needed = FRAME_POINTER_REQUIRED || ! flag_omit_frame_pointer;
1.1 root 2785:
1.1.1.2 root 2786: /* No gotos have been expanded yet. */
2787: goto_fixup_chain = 0;
1.1 root 2788:
1.1.1.2 root 2789: /* No invalid stack slots have been made yet. */
2790: invalid_stack_slot = 0;
2791:
2792: /* Initialize the RTL mechanism. */
2793: init_emit (write_symbols);
2794:
2795: /* Initialize the queue of pending postincrement and postdecrements,
2796: and some other info in expr.c. */
2797: init_expr ();
2798:
2799: init_const_rtx_hash_table ();
2800:
2801: /* Decide whether function should try to pop its args on return. */
2802:
2803: current_function_pops_args = RETURN_POPS_ARGS (TREE_TYPE (subr));
2804:
2805: current_function_name = IDENTIFIER_POINTER (DECL_NAME (subr));
2806:
2807: /* Make the label for return statements to jump to, if this machine
2808: does not have a one-instruction return. */
1.1 root 2809: #ifdef FUNCTION_EPILOGUE
2810: return_label = gen_label_rtx ();
1.1.1.2 root 2811: #else
2812: return_label = 0;
1.1 root 2813: #endif
2814:
1.1.1.2 root 2815: /* No space assigned yet for structure values. */
1.1 root 2816: max_structure_value_size = 0;
1.1.1.2 root 2817: structure_value = 0;
1.1 root 2818:
1.1.1.2 root 2819: /* We are not currently within any block, conditional, loop or case. */
1.1 root 2820: block_stack = 0;
1.1.1.2 root 2821: loop_stack = 0;
2822: case_stack = 0;
2823: cond_stack = 0;
2824: nesting_stack = 0;
2825: nesting_depth = 0;
2826:
2827: /* We have not yet needed to make a label to jump to for tail-recursion. */
1.1 root 2828: tail_recursion_label = 0;
2829:
1.1.1.2 root 2830: /* No stack slots allocated yet. */
2831: frame_offset = STARTING_FRAME_OFFSET;
2832:
1.1.1.5 root 2833: /* No SAVE_EXPRs in this function yet. */
2834: save_expr_regs = 0;
2835:
1.1.1.4 root 2836: /* Within function body, compute a type's size as soon it is laid out. */
2837: immediate_size_expand++;
2838:
1.1.1.2 root 2839: init_pending_stack_adjust ();
1.1 root 2840: clear_current_args_size ();
2841:
2842: /* Prevent ever trying to delete the first instruction of a function.
2843: Also tell final how to output a linenum before the function prologue. */
2844: emit_note (DECL_SOURCE_FILE (subr), DECL_SOURCE_LINE (subr));
2845: /* Make sure first insn is a note even if we don't want linenums.
2846: This makes sure the first insn will never be deleted.
2847: Also, final expects a note to appear there. */
2848: emit_note (0, NOTE_INSN_DELETED);
2849:
2850: /* Initialize rtx for parameters and local variables.
2851: In some cases this requires emitting insns. */
2852:
2853: assign_parms (subr);
1.1.1.2 root 2854:
2855: /* If doing stupid allocation, mark parms as born here. */
2856:
2857: if (obey_regdecls)
1.1.1.5 root 2858: {
2859: parm_birth_insn = get_last_insn ();
2860: for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
2861: use_variable (regno_reg_rtx[i]);
2862: }
1.1.1.2 root 2863:
1.1 root 2864: /* After the parm initializations is where the tail-recursion label
2865: should go, if we end up needing one. */
2866: tail_recursion_reentry = get_last_insn ();
2867:
1.1.1.4 root 2868: /* Evaluate now the sizes of any types declared among the arguments. */
2869: for (tem = get_pending_sizes (); tem; tem = TREE_CHAIN (tem))
2870: expand_expr (TREE_VALUE (tem), 0, VOIDmode, 0);
2871:
1.1 root 2872: /* Initialize rtx used to return the value. */
2873:
2874: if (DECL_MODE (DECL_RESULT (subr)) == BLKmode)
2875: {
2876: /* Returning something that won't go in a register. */
2877: register rtx value_address;
2878:
1.1.1.2 root 2879: /* Expect to be passed the address of a place to store the value. */
1.1 root 2880: value_address = gen_reg_rtx (Pmode);
1.1.1.2 root 2881: emit_move_insn (value_address, struct_value_incoming_rtx);
1.1 root 2882: DECL_RTL (DECL_RESULT (subr))
2883: = gen_rtx (MEM, DECL_MODE (DECL_RESULT (subr)),
2884: value_address);
2885: }
2886: else
1.1.1.2 root 2887: #ifdef FUNCTION_OUTGOING_VALUE
1.1 root 2888: DECL_RTL (DECL_RESULT (subr))
1.1.1.2 root 2889: = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
2890: #else
2891: DECL_RTL (DECL_RESULT (subr))
2892: = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
2893: #endif
1.1.1.6 ! root 2894:
! 2895: /* Mark this reg as the function's return value. */
! 2896: if (GET_CODE (DECL_RTL (DECL_RESULT (subr))) == REG)
! 2897: REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr))) = 1;
1.1.1.2 root 2898: }
1.1 root 2899:
1.1.1.6 ! root 2900: /* Generate RTL for the end of the current function.
! 2901: LINE is the line number. */
1.1 root 2902:
1.1.1.2 root 2903: void
1.1.1.6 ! root 2904: expand_function_end (filename, line)
! 2905: char *filename;
! 2906: int line;
1.1.1.2 root 2907: {
2908: register int i;
1.1 root 2909:
1.1.1.4 root 2910: /* Outside function body, can't compute type's actual size
2911: until next function's body starts. */
2912: immediate_size_expand--;
2913:
1.1 root 2914: /* If doing stupid register allocation,
1.1.1.2 root 2915: mark register parms as dying here. */
2916:
1.1 root 2917: if (obey_regdecls)
1.1.1.5 root 2918: {
2919: rtx tem;
2920: for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
2921: use_variable (regno_reg_rtx[i]);
2922:
2923: /* Likewise for the regs of all the SAVE_EXPRs in the function. */
2924:
2925: for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
2926: emit_insn (gen_rtx (USE, VOIDmode, XEXP (tem, 0)));
2927:
2928: /* Also mark those as borm at the beginning of the function.
2929: (This was done in expand_function_start for parms). */
2930: for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
2931: emit_insn_after (gen_rtx (USE, VOIDmode, XEXP (tem, 0)),
2932: parm_birth_insn);
2933: }
1.1 root 2934:
2935: clear_pending_stack_adjust ();
1.1.1.2 root 2936: do_pending_stack_adjust ();
1.1 root 2937:
1.1.1.2 root 2938: /* Mark the end of the function body.
2939: If control reaches this insn, the function can drop through
2940: without returning a value. */
2941: emit_note (0, NOTE_INSN_FUNCTION_END);
2942:
1.1.1.6 ! root 2943: /* Output a linenumber for the end of the function.
! 2944: SDB depends on this. */
! 2945: emit_note (input_filename, line);
! 2946:
1.1.1.2 root 2947: /* If we require a true epilogue,
2948: put here the label that return statements jump to.
2949: If there will be no epilogue, write a return instruction. */
1.1 root 2950: #ifdef FUNCTION_EPILOGUE
2951: emit_label (return_label);
2952: #else
2953: emit_jump_insn (gen_return ());
2954: #endif
1.1.1.6 ! root 2955:
! 2956: /* Fix up any gotos that jumped out to the outermost
! 2957: binding level of the function.
! 2958: Must follow emitting RETURN_LABEL. */
! 2959: fixup_gotos (0, get_insns ());
1.1 root 2960: }
1.1.1.6 ! root 2961:
! 2962:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.