|
|
1.1 root 1: /* Convert tree expression to rtl instructions, for GNU compiler.
1.1.1.2 root 2: Copyright (C) 1988 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
1.1.1.15 root 6: GNU CC is free software; you can redistribute it and/or modify
7: it under the terms of the GNU General Public License as published by
8: the Free Software Foundation; either version 1, or (at your option)
9: any later version.
10:
1.1 root 11: GNU CC is distributed in the hope that it will be useful,
1.1.1.15 root 12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with GNU CC; see the file COPYING. If not, write to
18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
1.1 root 19:
20:
21: #include "config.h"
22: #include "rtl.h"
23: #include "tree.h"
1.1.1.2 root 24: #include "flags.h"
1.1 root 25: #include "insn-flags.h"
26: #include "insn-codes.h"
27: #include "expr.h"
1.1.1.2 root 28: #include "insn-config.h"
29: #include "recog.h"
1.1.1.17! root 30: #include "gvarargs.h"
! 31: #include "typeclass.h"
1.1.1.2 root 32:
33: /* Decide whether a function's arguments should be processed
34: from first to last or from last to first. */
35:
36: #ifdef STACK_GROWS_DOWNWARD
37: #ifdef PUSH_ROUNDING
38: #define PUSH_ARGS_REVERSED /* If it's last to first */
39: #endif
40: #endif
41:
42: /* Like STACK_BOUNDARY but in units of bytes, not bits. */
43: #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
1.1 root 44:
45: /* If this is nonzero, we do not bother generating VOLATILE
46: around volatile memory references, and we are willing to
47: output indirect addresses. If cse is to follow, we reject
48: indirect addresses so a useful potential cse is generated;
49: if it is used only once, instruction combination will produce
50: the same indirect address eventually. */
51: int cse_not_expected;
52:
53: /* Nonzero to generate code for all the subroutines within an
54: expression before generating the upper levels of the expression.
55: Nowadays this is never zero. */
56: int do_preexpand_calls = 1;
57:
58: /* Number of units that we should eventually pop off the stack.
59: These are the arguments to function calls that have already returned. */
60: int pending_stack_adjust;
61:
1.1.1.17! root 62: /* Nonzero means stack pops must not be deferred, and deferred stack
! 63: pops must not be output. It is nonzero inside a function call,
! 64: inside a conditional expression, inside a statement expression,
! 65: and in other cases as well. */
! 66: int inhibit_defer_pop;
1.1.1.6 root 67:
1.1.1.13 root 68: /* A list of all cleanups which belong to the arguments of
1.1.1.8 root 69: function calls being expanded by expand_call. */
70: static tree cleanups_of_this_call;
71:
1.1.1.17! root 72: /* Nonzero means current function may call alloca
! 73: as a subroutine. (__builtin_alloca does not count.) */
1.1.1.2 root 74: int may_call_alloca;
75:
76: rtx store_expr ();
77: static void store_constructor ();
78: static rtx store_field ();
1.1 root 79: static rtx expand_call ();
1.1.1.2 root 80: static void emit_call_1 ();
81: static rtx prepare_call_address ();
82: static rtx expand_builtin ();
1.1 root 83: static rtx compare ();
1.1.1.2 root 84: static rtx compare_constants ();
1.1 root 85: static rtx compare1 ();
86: static rtx do_store_flag ();
87: static void preexpand_calls ();
1.1.1.2 root 88: static rtx expand_increment ();
89: static void init_queue ();
90:
91: void do_pending_stack_adjust ();
1.1 root 92:
93: /* MOVE_RATIO is the number of move instructions that is better than
94: a block move. */
95:
1.1.1.10 root 96: #ifndef MOVE_RATIO
97: #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi)
1.1 root 98: #define MOVE_RATIO 2
99: #else
1.1.1.10 root 100: /* A value of around 6 would minimize code size; infinity would minimize
101: execution time. */
102: #define MOVE_RATIO 15
103: #endif
1.1 root 104: #endif
105:
106: /* Table indexed by tree code giving 1 if the code is for a
107: comparison operation, or anything that is most easily
108: computed with a conditional branch.
109:
110: We include tree.def to give it the proper length.
111: The contents thus created are irrelevant.
112: The real contents are initialized in init_comparisons. */
113:
1.1.1.2 root 114: #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) 0,
1.1 root 115:
116: static char comparison_code[] = {
117: #include "tree.def"
118: };
119: #undef DEFTREECODE
120:
1.1.1.2 root 121: /* This is run once per compilation. */
122:
123: void
1.1 root 124: init_comparisons ()
125: {
126: comparison_code[(int) EQ_EXPR] = 1;
127: comparison_code[(int) NE_EXPR] = 1;
128: comparison_code[(int) LT_EXPR] = 1;
129: comparison_code[(int) GT_EXPR] = 1;
130: comparison_code[(int) LE_EXPR] = 1;
131: comparison_code[(int) GE_EXPR] = 1;
132: }
1.1.1.2 root 133:
134: /* This is run at the start of compiling a function. */
135:
136: void
137: init_expr ()
138: {
139: init_queue ();
140: may_call_alloca = 0;
141: }
1.1 root 142:
143: /* Manage the queue of increment instructions to be output
144: for POSTINCREMENT_EXPR expressions, etc. */
145:
146: static rtx pending_chain;
147:
148: /* Queue up to increment (or change) VAR later. BODY says how:
149: BODY should be the same thing you would pass to emit_insn
150: to increment right away. It will go to emit_insn later on.
151:
152: The value is a QUEUED expression to be used in place of VAR
1.1.1.2 root 153: where you want to guarantee the pre-incrementation value of VAR. */
1.1 root 154:
155: static rtx
156: enqueue_insn (var, body)
157: rtx var, body;
158: {
159: pending_chain = gen_rtx (QUEUED, GET_MODE (var),
160: var, 0, 0, body, pending_chain);
161: return pending_chain;
162: }
163:
164: /* Use protect_from_queue to convert a QUEUED expression
165: into something that you can put immediately into an instruction.
166: If the queued incrementation has not happened yet,
167: protect_from_queue returns the variable itself.
168: If the incrementation has happened, protect_from_queue returns a temp
169: that contains a copy of the old value of the variable.
170:
171: Any time an rtx which might possibly be a QUEUED is to be put
172: into an instruction, it must be passed through protect_from_queue first.
173: QUEUED expressions are not meaningful in instructions.
174:
175: Do not pass a value through protect_from_queue and then hold
176: on to it for a while before putting it in an instruction!
177: If the queue is flushed in between, incorrect code will result. */
178:
179: rtx
180: protect_from_queue (x, modify)
181: register rtx x;
182: int modify;
183: {
184: register RTX_CODE code = GET_CODE (x);
185: if (code != QUEUED)
186: {
187: /* A special hack for read access to (MEM (QUEUED ...))
188: to facilitate use of autoincrement.
189: Make a copy of the contents of the memory location
190: rather than a copy of the address. */
191: if (code == MEM && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
192: {
193: register rtx y = XEXP (x, 0);
194: XEXP (x, 0) = QUEUED_VAR (y);
195: if (QUEUED_INSN (y))
196: {
197: register rtx temp = gen_reg_rtx (GET_MODE (x));
198: emit_insn_before (gen_move_insn (temp, x),
199: QUEUED_INSN (y));
200: return temp;
201: }
202: return x;
203: }
204: /* Otherwise, recursively protect the subexpressions of all
205: the kinds of rtx's that can contain a QUEUED. */
206: if (code == MEM)
207: XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
208: else if (code == PLUS || code == MULT)
209: {
210: XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
211: XEXP (x, 1) = protect_from_queue (XEXP (x, 1), 0);
212: }
213: return x;
214: }
215: /* If the increment has not happened, use the variable itself. */
216: if (QUEUED_INSN (x) == 0)
217: return QUEUED_VAR (x);
218: /* If the increment has happened and a pre-increment copy exists,
219: use that copy. */
220: if (QUEUED_COPY (x) != 0)
221: return QUEUED_COPY (x);
222: /* The increment has happened but we haven't set up a pre-increment copy.
223: Set one up now, and use it. */
224: QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
225: emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
226: QUEUED_INSN (x));
227: return QUEUED_COPY (x);
228: }
229:
1.1.1.2 root 230: /* Return nonzero if X contains a QUEUED expression:
1.1.1.15 root 231: if it contains anything that will be altered by a queued increment.
232: We handle only combinations of MEM, PLUS, MINUS and MULT operators
233: since memory addresses generally contain only those. */
1.1.1.2 root 234:
235: static int
236: queued_subexp_p (x)
237: rtx x;
238: {
239: register enum rtx_code code = GET_CODE (x);
240: switch (code)
241: {
242: case QUEUED:
243: return 1;
244: case MEM:
245: return queued_subexp_p (XEXP (x, 0));
246: case MULT:
247: case PLUS:
248: case MINUS:
249: return queued_subexp_p (XEXP (x, 0))
250: || queued_subexp_p (XEXP (x, 1));
251: }
252: return 0;
253: }
254:
255: /* Perform all the pending incrementations. */
1.1 root 256:
257: void
258: emit_queue ()
259: {
260: register rtx p;
261: while (p = pending_chain)
262: {
263: QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
264: pending_chain = QUEUED_NEXT (p);
265: }
266: }
267:
1.1.1.2 root 268: static void
1.1 root 269: init_queue ()
270: {
271: if (pending_chain)
272: abort ();
273: }
274:
275: /* Copy data from FROM to TO, where the machine modes are not the same.
276: Both modes may be integer, or both may be floating.
277: UNSIGNEDP should be nonzero if FROM is an unsigned type.
278: This causes zero-extension instead of sign-extension. */
279:
280: void
281: convert_move (to, from, unsignedp)
282: register rtx to, from;
283: int unsignedp;
284: {
285: enum machine_mode to_mode = GET_MODE (to);
286: enum machine_mode from_mode = GET_MODE (from);
1.1.1.16 root 287: int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
288: int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
1.1 root 289: int extending = (int) to_mode > (int) from_mode;
290:
291: to = protect_from_queue (to, 1);
292: from = protect_from_queue (from, 0);
293:
294: if (to_real != from_real)
295: abort ();
296:
1.1.1.2 root 297: if (to_mode == from_mode
298: || (from_mode == VOIDmode && CONSTANT_P (from)))
1.1 root 299: {
300: emit_move_insn (to, from);
301: return;
302: }
303:
304: if (to_real)
305: {
306: #ifdef HAVE_extendsfdf2
307: if (HAVE_extendsfdf2 && extending)
308: {
1.1.1.2 root 309: emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
1.1 root 310: return;
311: }
312: #endif
313: #ifdef HAVE_truncdfsf2
314: if (HAVE_truncdfsf2 && ! extending)
315: {
1.1.1.2 root 316: emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
1.1 root 317: return;
318: }
319: #endif
320: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, (extending
1.1.1.13 root 321: ? "__extendsfdf2"
1.1.1.17! root 322: : "__truncdfsf2")), 0,
1.1.1.2 root 323: GET_MODE (to), 1,
324: from, (extending ? SFmode : DFmode));
325: emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
1.1 root 326: return;
327: }
328:
1.1.1.2 root 329: /* Now both modes are integers. */
330:
1.1 root 331: if (to_mode == DImode)
332: {
333: if (unsignedp)
334: {
1.1.1.14 root 335: #ifdef HAVE_zero_extendsidi2
336: if (HAVE_zero_extendsidi2 && from_mode == SImode)
337: emit_unop_insn (CODE_FOR_zero_extendsidi2, to, from, ZERO_EXTEND);
338: else
339: #endif
340: #ifdef HAVE_zero_extendhidi2
341: if (HAVE_zero_extendhidi2 && from_mode == HImode)
342: emit_unop_insn (CODE_FOR_zero_extendhidi2, to, from, ZERO_EXTEND);
343: else
344: #endif
345: #ifdef HAVE_zero_extendqidi2
346: if (HAVE_zero_extendqidi2 && from_mode == QImode)
347: emit_unop_insn (CODE_FOR_zero_extendqidi2, to, from, ZERO_EXTEND);
348: else
349: #endif
350: #ifdef HAVE_zero_extendsidi2
351: if (HAVE_zero_extendsidi2)
352: {
353: convert_move (gen_lowpart (SImode, to), from, unsignedp);
1.1.1.15 root 354: emit_unop_insn (CODE_FOR_zero_extendsidi2, to,
355: gen_lowpart (SImode, to), ZERO_EXTEND);
1.1.1.14 root 356: }
357: else
358: #endif
359: {
360: emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
361: convert_move (gen_lowpart (SImode, to), from, unsignedp);
362: emit_clr_insn (gen_highpart (SImode, to));
363: }
1.1 root 364: }
1.1.1.5 root 365: #ifdef HAVE_extendsidi2
1.1.1.14 root 366: else if (HAVE_extendsidi2 && from_mode == SImode)
367: emit_unop_insn (CODE_FOR_extendsidi2, to, from, SIGN_EXTEND);
368: #endif
369: #ifdef HAVE_extendhidi2
370: else if (HAVE_extendhidi2 && from_mode == HImode)
371: emit_unop_insn (CODE_FOR_extendhidi2, to, from, SIGN_EXTEND);
372: #endif
373: #ifdef HAVE_extendqidi2
374: else if (HAVE_extendqidi2 && from_mode == QImode)
375: emit_unop_insn (CODE_FOR_extendqidi2, to, from, SIGN_EXTEND);
376: #endif
377: #ifdef HAVE_extendsidi2
1.1.1.5 root 378: else if (HAVE_extendsidi2)
1.1.1.14 root 379: {
380: convert_move (gen_lowpart (SImode, to), from, unsignedp);
1.1.1.16 root 381: emit_unop_insn (CODE_FOR_extendsidi2, to,
382: gen_lowpart (SImode, to), SIGN_EXTEND);
1.1.1.14 root 383: }
1.1.1.5 root 384: #endif
1.1.1.2 root 385: #ifdef HAVE_slt
386: else if (HAVE_slt && insn_operand_mode[(int) CODE_FOR_slt][0] == SImode)
1.1 root 387: {
1.1.1.5 root 388: emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
1.1 root 389: convert_move (gen_lowpart (SImode, to), from, unsignedp);
1.1.1.2 root 390: emit_insn (gen_slt (gen_highpart (SImode, to)));
1.1 root 391: }
392: #endif
393: else
394: {
395: register rtx label = gen_label_rtx ();
396:
1.1.1.5 root 397: emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
1.1 root 398: emit_clr_insn (gen_highpart (SImode, to));
399: convert_move (gen_lowpart (SImode, to), from, unsignedp);
400: emit_cmp_insn (gen_lowpart (SImode, to),
401: gen_rtx (CONST_INT, VOIDmode, 0),
1.1.1.14 root 402: 0, 0, 0);
1.1.1.6 root 403: NO_DEFER_POP;
1.1 root 404: emit_jump_insn (gen_bge (label));
405: expand_unop (SImode, one_cmpl_optab,
406: gen_highpart (SImode, to), gen_highpart (SImode, to),
407: 1);
408: emit_label (label);
1.1.1.6 root 409: OK_DEFER_POP;
1.1 root 410: }
411: return;
412: }
413:
414: if (from_mode == DImode)
415: {
416: convert_move (to, gen_lowpart (SImode, from), 0);
417: return;
418: }
419:
420: /* Now follow all the conversions between integers
421: no more than a word long. */
422:
1.1.1.2 root 423: /* For truncation, usually we can just refer to FROM in a narrower mode. */
424: if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
425: && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
426: GET_MODE_BITSIZE (from_mode))
427: && ((GET_CODE (from) == MEM
1.1.1.16 root 428: && ! MEM_VOLATILE_P (from)
1.1.1.2 root 429: && ! mode_dependent_address_p (XEXP (from, 0)))
1.1.1.16 root 430: || GET_CODE (from) == REG
431: || GET_CODE (from) == SUBREG))
1.1.1.2 root 432: {
433: emit_move_insn (to, gen_lowpart (to_mode, from));
434: return;
435: }
436:
1.1 root 437: if (to_mode == SImode && from_mode == HImode)
438: {
439: if (unsignedp)
440: {
441: #ifdef HAVE_zero_extendhisi2
442: if (HAVE_zero_extendhisi2)
1.1.1.2 root 443: emit_unop_insn (CODE_FOR_zero_extendhisi2, to, from, ZERO_EXTEND);
1.1 root 444: else
445: #endif
446: abort ();
447: }
448: else
449: {
450: #ifdef HAVE_extendhisi2
451: if (HAVE_extendhisi2)
1.1.1.2 root 452: emit_unop_insn (CODE_FOR_extendhisi2, to, from, SIGN_EXTEND);
1.1 root 453: else
454: #endif
455: abort ();
456: }
457: return;
458: }
459:
460: if (to_mode == SImode && from_mode == QImode)
461: {
462: if (unsignedp)
463: {
464: #ifdef HAVE_zero_extendqisi2
465: if (HAVE_zero_extendqisi2)
466: {
1.1.1.2 root 467: emit_unop_insn (CODE_FOR_zero_extendqisi2, to, from, ZERO_EXTEND);
1.1 root 468: return;
469: }
470: #endif
471: #if defined (HAVE_zero_extendqihi2) && defined (HAVE_extendhisi2)
472: if (HAVE_zero_extendqihi2 && HAVE_extendhisi2)
473: {
474: register rtx temp = gen_reg_rtx (HImode);
1.1.1.2 root 475: emit_unop_insn (CODE_FOR_zero_extendqihi2, temp, from, ZERO_EXTEND);
476: emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
1.1 root 477: return;
478: }
479: #endif
480: }
481: else
482: {
483: #ifdef HAVE_extendqisi2
484: if (HAVE_extendqisi2)
485: {
1.1.1.2 root 486: emit_unop_insn (CODE_FOR_extendqisi2, to, from, SIGN_EXTEND);
1.1 root 487: return;
488: }
489: #endif
490: #if defined (HAVE_extendqihi2) && defined (HAVE_extendhisi2)
491: if (HAVE_extendqihi2 && HAVE_extendhisi2)
492: {
493: register rtx temp = gen_reg_rtx (HImode);
1.1.1.2 root 494: emit_unop_insn (CODE_FOR_extendqihi2, temp, from, SIGN_EXTEND);
495: emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
1.1 root 496: return;
497: }
498: #endif
499: }
500: abort ();
501: }
502:
503: if (to_mode == HImode && from_mode == QImode)
504: {
505: if (unsignedp)
506: {
507: #ifdef HAVE_zero_extendqihi2
508: if (HAVE_zero_extendqihi2)
509: {
1.1.1.2 root 510: emit_unop_insn (CODE_FOR_zero_extendqihi2, to, from, ZERO_EXTEND);
1.1 root 511: return;
512: }
513: #endif
514: }
515: else
516: {
517: #ifdef HAVE_extendqihi2
518: if (HAVE_extendqihi2)
519: {
1.1.1.2 root 520: emit_unop_insn (CODE_FOR_extendqihi2, to, from, SIGN_EXTEND);
1.1 root 521: return;
522: }
523: #endif
524: }
525: abort ();
526: }
527:
1.1.1.16 root 528: #if 0 /* This seems to be redundant with code 100 lines up. */
529:
1.1 root 530: /* Now we are truncating an integer to a smaller one.
531: If the result is a temporary, we might as well just copy it,
532: since only the low-order part of the result needs to be valid
533: and it is valid with no change. */
534:
535: if (GET_CODE (to) == REG)
536: {
537: if (GET_CODE (from) == REG)
538: {
539: emit_move_insn (to, gen_lowpart (GET_MODE (to), from));
540: return;
541: }
1.1.1.2 root 542: else if (GET_CODE (from) == SUBREG)
543: {
544: from = copy_rtx (from);
545: /* This is safe since FROM is not more than one word. */
546: PUT_MODE (from, GET_MODE (to));
547: emit_move_insn (to, from);
548: return;
549: }
1.1 root 550: #ifndef BYTES_BIG_ENDIAN
551: else if (GET_CODE (from) == MEM)
552: {
553: register rtx addr = XEXP (from, 0);
1.1.1.2 root 554: if (memory_address_p (GET_MODE (to), addr))
1.1 root 555: {
556: emit_move_insn (to, gen_rtx (MEM, GET_MODE (to), addr));
557: return;
558: }
559: }
560: #endif /* not BYTES_BIG_ENDIAN */
561: }
1.1.1.16 root 562: #endif /* 0 */
1.1 root 563:
564: if (from_mode == SImode && to_mode == HImode)
565: {
566: #ifdef HAVE_truncsihi2
567: if (HAVE_truncsihi2)
568: {
1.1.1.2 root 569: emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
1.1 root 570: return;
571: }
572: #endif
573: abort ();
574: }
575:
576: if (from_mode == SImode && to_mode == QImode)
577: {
578: #ifdef HAVE_truncsiqi2
579: if (HAVE_truncsiqi2)
580: {
1.1.1.2 root 581: emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
1.1 root 582: return;
583: }
584: #endif
585: abort ();
586: }
587:
588: if (from_mode == HImode && to_mode == QImode)
589: {
590: #ifdef HAVE_trunchiqi2
591: if (HAVE_trunchiqi2)
592: {
1.1.1.2 root 593: emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
1.1 root 594: return;
595: }
596: #endif
597: abort ();
598: }
1.1.1.2 root 599:
600: /* Mode combination is not recognized. */
601: abort ();
1.1 root 602: }
603:
604: /* Return an rtx for a value that would result
605: from converting X to mode MODE.
606: Both X and MODE may be floating, or both integer.
607: UNSIGNEDP is nonzero if X is an unsigned value.
608: This can be done by referring to a part of X in place
609: or by copying to a new temporary with conversion. */
610:
611: rtx
612: convert_to_mode (mode, x, unsignedp)
613: enum machine_mode mode;
614: rtx x;
615: int unsignedp;
616: {
617: register rtx temp;
618: if (mode == GET_MODE (x))
619: return x;
1.1.1.2 root 620: if (integer_mode_p (mode)
1.1.1.16 root 621: && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (x))
622: && ! (GET_CODE (x) == MEM && MEM_VOLATILE_P (x)))
1.1 root 623: return gen_lowpart (mode, x);
624: temp = gen_reg_rtx (mode);
625: convert_move (temp, x, unsignedp);
626: return temp;
627: }
1.1.1.2 root 628:
629: int
630: integer_mode_p (mode)
631: enum machine_mode mode;
632: {
633: return (int) mode > (int) VOIDmode && (int) mode <= (int) TImode;
634: }
1.1 root 635:
636: /* Generate several move instructions to copy LEN bytes
1.1.1.2 root 637: from block FROM to block TO. (These are MEM rtx's with BLKmode).
638: The caller must pass FROM and TO
1.1 root 639: through protect_from_queue before calling.
640: ALIGN (in bytes) is maximum alignment we can assume. */
641:
642: struct move_by_pieces
643: {
644: rtx to;
1.1.1.2 root 645: rtx to_addr;
1.1 root 646: int autinc_to;
647: int explicit_inc_to;
648: rtx from;
1.1.1.2 root 649: rtx from_addr;
1.1 root 650: int autinc_from;
651: int explicit_inc_from;
652: int len;
653: int offset;
654: int reverse;
655: };
656:
1.1.1.17! root 657: static void move_by_pieces_1 ();
! 658: static int move_by_pieces_ninsns ();
! 659:
1.1 root 660: static void
1.1.1.2 root 661: move_by_pieces (to, from, len, align)
1.1 root 662: rtx to, from;
663: int len, align;
664: {
665: struct move_by_pieces data;
1.1.1.2 root 666: rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
1.1 root 667:
668: data.offset = 0;
1.1.1.2 root 669: data.to_addr = to_addr;
670: data.from_addr = from_addr;
1.1 root 671: data.to = to;
672: data.from = from;
1.1.1.2 root 673: data.autinc_to
674: = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
675: || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
676: data.autinc_from
677: = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
678: || GET_CODE (from_addr) == POST_INC
679: || GET_CODE (from_addr) == POST_DEC);
1.1 root 680:
681: data.explicit_inc_from = 0;
682: data.explicit_inc_to = 0;
1.1.1.2 root 683: data.reverse
684: = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
1.1 root 685: if (data.reverse) data.offset = len;
686: data.len = len;
687:
688: /* If copying requires more than two move insns,
689: copy addresses to registers (to make displacements shorter)
690: and use post-increment if available. */
691: if (!(data.autinc_from && data.autinc_to)
692: && move_by_pieces_ninsns (len, align) > 2)
693: {
694: #ifdef HAVE_PRE_DECREMENT
695: if (data.reverse && ! data.autinc_from)
696: {
1.1.1.2 root 697: data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
1.1 root 698: data.autinc_from = 1;
699: data.explicit_inc_from = -1;
700: }
701: #endif
702: #ifdef HAVE_POST_INCREMENT
703: if (! data.autinc_from)
704: {
1.1.1.2 root 705: data.from_addr = copy_addr_to_reg (from_addr);
1.1 root 706: data.autinc_from = 1;
707: data.explicit_inc_from = 1;
708: }
709: #endif
1.1.1.2 root 710: if (!data.autinc_from && CONSTANT_P (from_addr))
711: data.from_addr = copy_addr_to_reg (from_addr);
1.1 root 712: #ifdef HAVE_PRE_DECREMENT
713: if (data.reverse && ! data.autinc_to)
714: {
1.1.1.2 root 715: data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
1.1 root 716: data.autinc_to = 1;
717: data.explicit_inc_to = -1;
718: }
719: #endif
720: #ifdef HAVE_POST_INCREMENT
721: if (! data.reverse && ! data.autinc_to)
722: {
1.1.1.2 root 723: data.to_addr = copy_addr_to_reg (to_addr);
1.1 root 724: data.autinc_to = 1;
725: data.explicit_inc_to = 1;
726: }
727: #endif
1.1.1.2 root 728: if (!data.autinc_to && CONSTANT_P (to_addr))
729: data.to_addr = copy_addr_to_reg (to_addr);
1.1 root 730: }
731:
732: #ifdef STRICT_ALIGNMENT
1.1.1.2 root 733: if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1.1 root 734: align = MOVE_MAX;
735: #else
736: align = MOVE_MAX;
737: #endif
738:
739: #ifdef HAVE_movti
740: if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
741: move_by_pieces_1 (gen_movti, TImode, &data);
742: #endif
743: #ifdef HAVE_movdi
744: if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
745: move_by_pieces_1 (gen_movdi, DImode, &data);
746: #endif
1.1.1.2 root 747: #ifdef HAVE_movsi
1.1 root 748: if (align >= GET_MODE_SIZE (SImode))
749: move_by_pieces_1 (gen_movsi, SImode, &data);
1.1.1.2 root 750: #endif
751: #ifdef HAVE_movhi
752: if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
1.1 root 753: move_by_pieces_1 (gen_movhi, HImode, &data);
1.1.1.2 root 754: #endif
755: #ifdef HAVE_movqi
1.1 root 756: move_by_pieces_1 (gen_movqi, QImode, &data);
1.1.1.2 root 757: #else
758: movqi instruction required in machine description
759: #endif
1.1 root 760: }
761:
762: /* Return number of insns required to move L bytes by pieces.
763: ALIGN (in bytes) is maximum alignment we can assume. */
764:
1.1.1.2 root 765: static int
1.1 root 766: move_by_pieces_ninsns (l, align)
767: unsigned int l;
768: int align;
769: {
770: register int n_insns = 0;
771:
772: #ifdef STRICT_ALIGNMENT
1.1.1.2 root 773: if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1.1 root 774: align = MOVE_MAX;
775: #else
776: align = MOVE_MAX;
777: #endif
778:
779: #ifdef HAVE_movti
780: if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
781: n_insns += l / GET_MODE_SIZE (TImode), l %= GET_MODE_SIZE (TImode);
782: #endif
783: #ifdef HAVE_movdi
784: if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
785: n_insns += l / GET_MODE_SIZE (DImode), l %= GET_MODE_SIZE (DImode);
786: #endif
1.1.1.2 root 787: #ifdef HAVE_movsi
1.1 root 788: if (HAVE_movsi && align >= GET_MODE_SIZE (SImode))
789: n_insns += l / GET_MODE_SIZE (SImode), l %= GET_MODE_SIZE (SImode);
1.1.1.2 root 790: #endif
791: #ifdef HAVE_movhi
1.1 root 792: if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
793: n_insns += l / GET_MODE_SIZE (HImode), l %= GET_MODE_SIZE (HImode);
1.1.1.2 root 794: #endif
1.1 root 795: n_insns += l;
796:
797: return n_insns;
798: }
799:
800: /* Subroutine of move_by_pieces. Move as many bytes as appropriate
801: with move instructions for mode MODE. GENFUN is the gen_... function
802: to make a move insn for that mode. DATA has all the other info. */
803:
1.1.1.2 root 804: static void
1.1 root 805: move_by_pieces_1 (genfun, mode, data)
806: rtx (*genfun) ();
807: enum machine_mode mode;
808: struct move_by_pieces *data;
809: {
810: register int size = GET_MODE_SIZE (mode);
811: register rtx to1, from1;
812:
813: while (data->len >= size)
814: {
1.1.1.2 root 815: if (data->reverse) data->offset -= size;
1.1 root 816:
1.1.1.13 root 817: to1 = (data->autinc_to
818: ? gen_rtx (MEM, mode, data->to_addr)
819: : change_address (data->to, mode,
820: plus_constant (data->to_addr, data->offset)));
821: from1 =
822: (data->autinc_from
823: ? gen_rtx (MEM, mode, data->from_addr)
824: : change_address (data->from, mode,
825: plus_constant (data->from_addr, data->offset)));
1.1 root 826:
827: #ifdef HAVE_PRE_DECREMENT
828: if (data->explicit_inc_to < 0)
1.1.1.2 root 829: emit_insn (gen_sub2_insn (data->to_addr,
1.1 root 830: gen_rtx (CONST_INT, VOIDmode, size)));
831: if (data->explicit_inc_from < 0)
1.1.1.2 root 832: emit_insn (gen_sub2_insn (data->from_addr,
1.1 root 833: gen_rtx (CONST_INT, VOIDmode, size)));
834: #endif
835:
1.1.1.5 root 836: emit_insn ((*genfun) (to1, from1));
1.1 root 837: #ifdef HAVE_POST_INCREMENT
838: if (data->explicit_inc_to > 0)
1.1.1.2 root 839: emit_insn (gen_add2_insn (data->to_addr,
1.1 root 840: gen_rtx (CONST_INT, VOIDmode, size)));
841: if (data->explicit_inc_from > 0)
1.1.1.2 root 842: emit_insn (gen_add2_insn (data->from_addr,
1.1 root 843: gen_rtx (CONST_INT, VOIDmode, size)));
844: #endif
845:
846: if (! data->reverse) data->offset += size;
1.1.1.2 root 847:
1.1 root 848: data->len -= size;
849: }
850: }
851:
852: /* Emit code to move a block Y to a block X.
853: This may be done with string-move instructions,
854: with multiple scalar move instructions, or with a library call.
855:
856: Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
857: with mode BLKmode.
858: SIZE is an rtx that says how long they are.
859: ALIGN is the maximum alignment we can assume they have,
860: measured in bytes. */
861:
862: static void
863: emit_block_move (x, y, size, align)
864: rtx x, y;
865: rtx size;
866: int align;
867: {
868: if (GET_MODE (x) != BLKmode)
869: abort ();
870:
871: if (GET_MODE (y) != BLKmode)
872: abort ();
873:
874: x = protect_from_queue (x, 1);
875: y = protect_from_queue (y, 0);
876:
1.1.1.2 root 877: if (GET_CODE (x) != MEM)
1.1 root 878: abort ();
1.1.1.2 root 879: if (GET_CODE (y) != MEM)
1.1 root 880: abort ();
881: if (size == 0)
882: abort ();
883:
884: if (GET_CODE (size) == CONST_INT
885: && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
886: < MOVE_RATIO))
1.1.1.2 root 887: move_by_pieces (x, y, INTVAL (size), align);
1.1 root 888: else
889: {
1.1.1.9 root 890: /* Try the most limited insn first, because there's no point
891: including more than one in the machine description unless
892: the more limited one has some advantage. */
893: #ifdef HAVE_movstrqi
894: if (HAVE_movstrqi
895: && GET_CODE (size) == CONST_INT
896: && ((unsigned) INTVAL (size)
897: < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
1.1 root 898: {
1.1.1.14 root 899: emit_insn (gen_movstrqi (x, y, size,
900: gen_rtx (CONST_INT, VOIDmode, align)));
1.1 root 901: return;
902: }
903: #endif
904: #ifdef HAVE_movstrhi
905: if (HAVE_movstrhi
906: && GET_CODE (size) == CONST_INT
907: && ((unsigned) INTVAL (size)
1.1.1.5 root 908: < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
1.1 root 909: {
1.1.1.14 root 910: emit_insn (gen_movstrhi (x, y, size,
911: gen_rtx (CONST_INT, VOIDmode, align)));
1.1 root 912: return;
913: }
914: #endif
1.1.1.9 root 915: #ifdef HAVE_movstrsi
916: if (HAVE_movstrsi)
1.1.1.5 root 917: {
1.1.1.14 root 918: emit_insn (gen_movstrsi (x, y, size,
919: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.5 root 920: return;
921: }
922: #endif
1.1.1.2 root 923:
924: #ifdef TARGET_MEM_FUNCTIONS
1.1.1.17! root 925: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0,
1.1.1.2 root 926: VOIDmode, 3, XEXP (x, 0), Pmode,
927: XEXP (y, 0), Pmode,
928: size, Pmode);
929: #else
1.1.1.17! root 930: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0,
1.1.1.2 root 931: VOIDmode, 3, XEXP (y, 0), Pmode,
932: XEXP (x, 0), Pmode,
1.1 root 933: size, Pmode);
1.1.1.2 root 934: #endif
935: }
936: }
937:
938: /* Copy all or part of a BLKmode value X into registers starting at REGNO.
939: The number of registers to be filled is NREGS. */
940:
941: static void
942: move_block_to_reg (regno, x, nregs)
943: int regno;
944: rtx x;
945: int nregs;
946: {
947: int i;
948: if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
949: x = force_const_double_mem (x);
950: for (i = 0; i < nregs; i++)
951: {
952: if (GET_CODE (x) == REG)
953: emit_move_insn (gen_rtx (REG, SImode, regno + i),
954: gen_rtx (SUBREG, SImode, x, i));
955: else if (x == dconst0_rtx)
956: emit_move_insn (gen_rtx (REG, SImode, regno + i),
957: const0_rtx);
958: else
959: emit_move_insn (gen_rtx (REG, SImode, regno + i),
960: gen_rtx (MEM, SImode,
1.1.1.10 root 961: memory_address (SImode,
962: plus_constant (XEXP (x, 0),
963: i * GET_MODE_SIZE (SImode)))));
1.1.1.2 root 964: }
965: }
966:
967: /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
968: The number of registers to be filled is NREGS. */
969:
970: void
971: move_block_from_reg (regno, x, nregs)
972: int regno;
973: rtx x;
974: int nregs;
975: {
976: int i;
977: for (i = 0; i < nregs; i++)
978: {
979: if (GET_CODE (x) == REG)
980: emit_move_insn (gen_rtx (SUBREG, SImode, x, i),
981: gen_rtx (REG, SImode, regno + i));
982: else
983: emit_move_insn (gen_rtx (MEM, SImode,
1.1.1.10 root 984: memory_address (SImode,
985: plus_constant (XEXP (x, 0),
986: i * GET_MODE_SIZE (SImode)))),
1.1.1.2 root 987: gen_rtx (REG, SImode, regno + i));
1.1 root 988: }
989: }
1.1.1.2 root 990:
991: /* Mark NREGS consecutive regs, starting at REGNO, as being live now. */
992:
993: static void
994: use_regs (regno, nregs)
995: int regno;
996: int nregs;
997: {
998: int i;
999: for (i = 0; i < nregs; i++)
1000: emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, regno + i)));
1001: }
1.1 root 1002:
1.1.1.2 root 1003: /* Write zeros through the storage of OBJECT.
1004: If OBJECT has BLKmode, SIZE is its length in bytes. */
1005:
1006: void
1007: clear_storage (object, size)
1008: rtx object;
1009: int size;
1010: {
1011: if (GET_MODE (object) == BLKmode)
1012: {
1013: #ifdef TARGET_MEM_FUNCTIONS
1.1.1.17! root 1014: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memset"), 0,
1.1.1.2 root 1015: VOIDmode, 3,
1016: XEXP (object, 0), Pmode, const0_rtx, Pmode,
1017: gen_rtx (CONST_INT, VOIDmode, size), Pmode);
1018: #else
1.1.1.17! root 1019: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bzero"), 0,
1.1.1.2 root 1020: VOIDmode, 2,
1021: XEXP (object, 0), Pmode,
1022: gen_rtx (CONST_INT, VOIDmode, size), Pmode);
1023: #endif
1024: }
1025: else
1.1.1.13 root 1026: emit_move_insn (object, const0_rtx);
1.1.1.2 root 1027: }
1028:
1.1 root 1029: /* Generate code to copy Y into X.
1030: Both Y and X must have the same mode, except that
1031: Y can be a constant with VOIDmode.
1.1.1.2 root 1032: This mode cannot be BLKmode; use emit_block_move for that.
1.1 root 1033:
1.1.1.2 root 1034: Return the last instruction emitted. */
1035:
1036: rtx
1.1 root 1037: emit_move_insn (x, y)
1038: rtx x, y;
1039: {
1040: enum machine_mode mode = GET_MODE (x);
1041: x = protect_from_queue (x, 1);
1042: y = protect_from_queue (y, 0);
1043:
1.1.1.3 root 1044: if ((CONSTANT_P (y) || GET_CODE (y) == CONST_DOUBLE)
1045: && ! LEGITIMATE_CONSTANT_P (y))
1.1.1.10 root 1046: {
1047: y = force_const_mem (mode, y);
1048: if (! memory_address_p (mode, y))
1049: y = gen_rtx (MEM, mode, memory_address (mode, XEXP (y, 0)));
1050: }
1.1.1.2 root 1051:
1.1 root 1052: if (mode == BLKmode)
1053: abort ();
1.1.1.2 root 1054: if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
1.1.1.6 root 1055: return
1.1.1.2 root 1056: emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
1057: #if 0
1058: /* It turns out you get much better optimization (in cse and flow)
1059: if you define movdi and movdf instruction patterns
1060: even if they must turn into multiple assembler instructions. */
1.1 root 1061: else if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (SImode))
1062: {
1063: register int count = GET_MODE_SIZE (mode) / GET_MODE_SIZE (SImode);
1064: register int i;
1.1.1.2 root 1065: if (GET_CODE (y) == CONST_DOUBLE && y != dconst0_rtx)
1066: y = force_const_double_mem (y);
1.1 root 1067: for (i = 0; i < count; i++)
1068: {
1069: rtx x1, y1;
1070: if (GET_CODE (x) == REG)
1071: x1 = gen_rtx (SUBREG, SImode, x, i);
1072: else
1073: x1 = gen_rtx (MEM, SImode,
1074: memory_address (SImode,
1075: plus_constant (XEXP (x, 0),
1076: i * GET_MODE_SIZE (SImode))));
1077: if (GET_CODE (y) == REG)
1078: y1 = gen_rtx (SUBREG, SImode, y, i);
1.1.1.2 root 1079: else if (y == dconst0_rtx)
1080: y1 = const0_rtx;
1.1 root 1081: else
1082: y1 = gen_rtx (MEM, SImode,
1083: memory_address (SImode,
1084: plus_constant (XEXP (y, 0),
1085: i * GET_MODE_SIZE (SImode))));
1086: emit_insn (gen_movsi (protect_from_queue (x1, 1), protect_from_queue (y1, 0)));
1087: }
1088: }
1.1.1.2 root 1089: #endif
1.1 root 1090: else
1091: abort ();
1092: }
1093:
1094: /* Pushing data onto the stack. */
1095:
1096: /* Push a block of length SIZE (perhaps variable)
1097: and return an rtx to address the beginning of the block.
1.1.1.4 root 1098: Note that it is not possible for the value returned to be a QUEUED.
1099: The value may be stack_pointer_rtx.
1100:
1.1.1.7 root 1101: The value we return does take account of STACK_POINTER_OFFSET. */
1.1 root 1102:
1.1.1.7 root 1103: rtx
1.1 root 1104: push_block (size)
1105: rtx size;
1106: {
1107: register rtx temp;
1.1.1.2 root 1108: if (CONSTANT_P (size) || GET_CODE (size) == REG)
1109: anti_adjust_stack (size);
1110: else
1111: anti_adjust_stack (copy_to_mode_reg (Pmode, size));
1.1.1.6 root 1112:
1.1 root 1113: #ifdef STACK_GROWS_DOWNWARD
1.1.1.2 root 1114: temp = stack_pointer_rtx;
1.1 root 1115: #else
1116: temp = gen_rtx (PLUS, Pmode,
1.1.1.2 root 1117: stack_pointer_rtx,
1.1.1.11 root 1118: negate_rtx (Pmode, size));
1.1 root 1119: if (GET_CODE (size) != CONST_INT)
1120: temp = force_operand (temp, 0);
1121: #endif
1.1.1.7 root 1122:
1123: #ifdef STACK_POINTER_OFFSET
1124: temp = plus_constant (temp, STACK_POINTER_OFFSET);
1125: #endif /* STACK_POINTER_OFFSET */
1126:
1.1 root 1127: return memory_address (QImode, temp);
1128: }
1129:
1130: static rtx
1131: gen_push_operand ()
1132: {
1133: return gen_rtx (
1134: #ifdef STACK_GROWS_DOWNWARD
1135: PRE_DEC,
1136: #else
1137: PRE_INC,
1138: #endif
1139: Pmode,
1.1.1.2 root 1140: stack_pointer_rtx);
1.1 root 1141: }
1142:
1143: /* Generate code to push X onto the stack, assuming it has mode MODE.
1144: MODE is redundant except when X is a CONST_INT (since they don't
1145: carry mode info).
1146: SIZE is an rtx for the size of data to be copied (in bytes),
1147: needed only if X is BLKmode.
1.1.1.13 root 1148:
1149:
1150:
1151:
1152:
1.1.1.2 root 1153: ALIGN (in bytes) is maximum alignment we can assume.
1154:
1155: If PARTIAL is nonzero, then copy that many of the first words
1156: of X into registers starting with REG, and push the rest of X.
1157: The amount of space pushed is decreased by PARTIAL words,
1158: rounded *down* to a multiple of PARM_BOUNDARY.
1159: REG must be a hard register in this case.
1160:
1161: EXTRA is the amount in bytes of extra space to leave next to this arg.
1162:
1163: On a machine that lacks real push insns, ARGS_ADDR is the address of
1164: the bottom of the argument block for this call. We use indexing off there
1165: to store the arg. On machines with push insns, ARGS_ADDR is 0.
1166:
1167: ARGS_SO_FAR is the size of args previously pushed for this call. */
1.1 root 1168:
1169: static void
1.1.1.2 root 1170: emit_push_insn (x, mode, size, align, partial, reg, extra, args_addr, args_so_far)
1.1 root 1171: register rtx x;
1172: enum machine_mode mode;
1173: rtx size;
1174: int align;
1.1.1.2 root 1175: int partial;
1176: rtx reg;
1177: int extra;
1178: rtx args_addr;
1179: rtx args_so_far;
1.1 root 1180: {
1181: rtx xinner;
1.1.1.6 root 1182: enum direction stack_direction
1183: #ifdef STACK_GROWS_DOWNWARD
1184: = downward;
1185: #else
1186: = upward;
1187: #endif
1188:
1189: /* Decide where to pad the argument: `downward' for below,
1190: `upward' for above, or `none' for don't pad it.
1191: Default is below for small data on big-endian machines; else above. */
1192: enum direction where_pad = FUNCTION_ARG_PADDING (mode, size);
1.1 root 1193:
1194: xinner = x = protect_from_queue (x, 0);
1195:
1.1.1.6 root 1196: if (extra)
1197: {
1198: if (args_addr == 0)
1199: {
1200: /* Push padding now if padding above and stack grows down,
1201: or if padding below and stack grows up. */
1202: if (where_pad != none && where_pad != stack_direction)
1203: anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
1204: }
1205: else
1206: {
1207: /* If space already allocated, just adjust the address we use. */
1208: if (where_pad == downward)
1209: args_so_far = plus_constant (args_so_far, extra);
1210: }
1211: }
1.1 root 1212:
1213: if (mode == BLKmode)
1214: {
1.1.1.17! root 1215: /* Copy a block into the stack, entirely or partially. */
! 1216:
1.1 root 1217: register rtx temp;
1.1.1.2 root 1218: int used = partial * UNITS_PER_WORD;
1219: int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
1.1.1.17! root 1220: int skip;
! 1221:
! 1222: if (size == 0)
! 1223: abort ();
1.1.1.2 root 1224:
1.1.1.13 root 1225: used -= offset;
1.1.1.2 root 1226:
1.1.1.17! root 1227: /* USED is now the # of bytes we need not copy to the stack
! 1228: because registers will take care of them. */
1.1 root 1229:
1.1.1.2 root 1230: if (partial != 0)
1231: xinner = change_address (xinner, BLKmode,
1232: plus_constant (XEXP (xinner, 0), used));
1233:
1.1.1.17! root 1234: /* If the partial register-part of the arg counts in its stack size,
! 1235: skip the part of stack space corresponding to the registers.
! 1236: Otherwise, start copying to the beginning of the stack space,
! 1237: by setting SKIP to 0. */
! 1238: #ifndef FIRST_PARM_CALLER_OFFSET
! 1239: skip = 0;
! 1240: #else
! 1241: skip = used;
! 1242: #endif
! 1243:
1.1.1.2 root 1244: #ifdef PUSH_ROUNDING
1245: /* Do it with several push insns if that doesn't take lots of insns
1246: and if there is no difficulty with push insns that skip bytes
1247: on the stack for alignment purposes. */
1248: if (args_addr == 0
1249: && GET_CODE (size) == CONST_INT
1250: && args_addr == 0
1.1.1.17! root 1251: && skip == 0
1.1.1.2 root 1252: && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
1253: < MOVE_RATIO)
1254: && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
1255: move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
1256: INTVAL (size) - used, align);
1.1 root 1257: else
1.1.1.2 root 1258: #endif /* PUSH_ROUNDING */
1.1 root 1259: {
1.1.1.2 root 1260: /* Otherwise make space on the stack and copy the data
1261: to the address of that space. */
1262:
1.1.1.17! root 1263: /* Deduct words put into registers from the size we must copy. */
1.1.1.2 root 1264: if (partial != 0)
1265: {
1266: if (GET_CODE (size) == CONST_INT)
1267: size = gen_rtx (CONST_INT, VOIDmode, INTVAL (size) - used);
1268: else
1269: size = expand_binop (GET_MODE (size), sub_optab, size,
1270: gen_rtx (CONST_INT, VOIDmode, used),
1271: 0, 0, OPTAB_LIB_WIDEN);
1272: }
1273:
1274: /* Get the address of the stack space. */
1275: if (! args_addr)
1276: temp = push_block (size);
1277: else if (GET_CODE (args_so_far) == CONST_INT)
1278: temp = memory_address (BLKmode,
1279: plus_constant (args_addr,
1.1.1.17! root 1280: skip + INTVAL (args_so_far)));
1.1.1.2 root 1281: else
1282: temp = memory_address (BLKmode,
1283: plus_constant (gen_rtx (PLUS, Pmode,
1284: args_addr, args_so_far),
1.1.1.17! root 1285: skip));
1.1.1.2 root 1286:
1287: /* TEMP is the address of the block. Copy the data there. */
1288: if (GET_CODE (size) == CONST_INT
1289: && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
1290: < MOVE_RATIO))
1291: {
1292: move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
1293: INTVAL (size), align);
1.1.1.16 root 1294: goto ret;
1.1.1.2 root 1295: }
1.1.1.13 root 1296: /* Try the most limited insn first, because there's no point
1297: including more than one in the machine description unless
1298: the more limited one has some advantage. */
1.1.1.9 root 1299: #ifdef HAVE_movstrqi
1300: if (HAVE_movstrqi
1301: && GET_CODE (size) == CONST_INT
1302: && ((unsigned) INTVAL (size)
1303: < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
1.1 root 1304: {
1.1.1.9 root 1305: emit_insn (gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
1.1.1.14 root 1306: xinner, size,
1307: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.16 root 1308: goto ret;
1.1 root 1309: }
1310: #endif
1311: #ifdef HAVE_movstrhi
1312: if (HAVE_movstrhi
1313: && GET_CODE (size) == CONST_INT
1314: && ((unsigned) INTVAL (size)
1.1.1.5 root 1315: < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
1.1 root 1316: {
1317: emit_insn (gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
1.1.1.14 root 1318: xinner, size,
1319: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.16 root 1320: goto ret;
1.1 root 1321: }
1322: #endif
1.1.1.9 root 1323: #ifdef HAVE_movstrsi
1324: if (HAVE_movstrsi)
1.1.1.5 root 1325: {
1.1.1.14 root 1326: emit_insn (gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
1327: xinner, size,
1328: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.16 root 1329: goto ret;
1.1.1.5 root 1330: }
1331: #endif
1.1.1.2 root 1332:
1333: if (reg_mentioned_p (stack_pointer_rtx, temp))
1334: {
1.1.1.15 root 1335: /* Now that emit_library_call does force_operand
1336: before pushing anything, preadjustment does not work. */
1337: temp = copy_to_reg (temp);
1338: #if 0
1.1.1.2 root 1339: /* Correct TEMP so it holds what will be a description of
1340: the address to copy to, valid after one arg is pushed. */
1.1.1.5 root 1341: int xsize = GET_MODE_SIZE (Pmode);
1342: #ifdef PUSH_ROUNDING
1343: xsize = PUSH_ROUNDING (xsize);
1344: #endif
1345: xsize = ((xsize + PARM_BOUNDARY / BITS_PER_UNIT - 1)
1346: / (PARM_BOUNDARY / BITS_PER_UNIT)
1347: * (PARM_BOUNDARY / BITS_PER_UNIT));
1.1.1.8 root 1348: #ifdef TARGET_MEM_FUNCTIONS
1349: /* If we are calling bcopy, we push one arg before TEMP.
1350: If calling memcpy, we push two. */
1351: xsize *= 2;
1352: #endif
1.1 root 1353: #ifdef STACK_GROWS_DOWNWARD
1.1.1.4 root 1354: temp = plus_constant (temp, xsize);
1.1 root 1355: #else
1.1.1.6 root 1356: temp = plus_constant (temp, -xsize);
1.1.1.15 root 1357: #endif /* not STACK_GROWS_DOWNWARD */
1358: #endif /* 0 */
1.1.1.2 root 1359: }
1360:
1.1.1.17! root 1361: /* Make inhibit_defer_pop nonzero around the library call
1.1.1.2 root 1362: to force it to pop the bcopy-arguments right away. */
1.1.1.9 root 1363: NO_DEFER_POP;
1.1.1.2 root 1364: #ifdef TARGET_MEM_FUNCTIONS
1.1.1.17! root 1365: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0,
1.1.1.2 root 1366: VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
1367: size, Pmode);
1368: #else
1.1.1.17! root 1369: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0,
1.1.1.2 root 1370: VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
1.1 root 1371: size, Pmode);
1.1.1.2 root 1372: #endif
1.1.1.9 root 1373: OK_DEFER_POP;
1.1 root 1374: }
1375: }
1.1.1.2 root 1376: else if (partial > 0)
1.1 root 1377: {
1.1.1.14 root 1378: /* Scalar partly in registers. */
1379:
1.1.1.2 root 1380: int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
1381: int i;
1.1.1.13 root 1382: int not_stack;
1.1.1.6 root 1383: /* # words of start of argument
1.1.1.2 root 1384: that we must make space for but need not store. */
1.1.1.17! root 1385: int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
1.1.1.2 root 1386: int args_offset = INTVAL (args_so_far);
1.1.1.17! root 1387: int skip;
1.1.1.2 root 1388:
1389: /* If we make space by pushing it, we might as well push
1.1.1.17! root 1390: the real data. Otherwise, we can leave OFFSET nonzero
1.1.1.2 root 1391: and leave the space uninitialized. */
1392: if (args_addr == 0)
1.1.1.17! root 1393: offset = 0;
1.1.1.2 root 1394:
1.1.1.17! root 1395: /* Now NOT_STACK gets the number of words that we don't need to
1.1.1.13 root 1396: allocate on the stack. */
1.1.1.17! root 1397: not_stack = partial - offset;
! 1398:
! 1399: /* If the partial register-part of the arg counts in its stack size,
! 1400: skip the part of stack space corresponding to the registers.
! 1401: Otherwise, start copying to the beginning of the stack space,
! 1402: by setting SKIP to 0. */
! 1403: #ifndef FIRST_PARM_CALLER_OFFSET
! 1404: skip = 0;
! 1405: #else
! 1406: skip = not_stack;
! 1407: #endif
1.1.1.2 root 1408:
1409: if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
1410: x = force_const_double_mem (x);
1411:
1.1.1.13 root 1412: /* Loop over all the words allocated on the stack for this arg. */
1.1.1.14 root 1413: /* We can do it by words, because any scalar bigger than a word
1414: has a size a multiple of a word. */
1.1.1.2 root 1415: #ifndef PUSH_ARGS_REVERSED
1.1.1.13 root 1416: for (i = not_stack; i < size; i++)
1.1.1.2 root 1417: #else
1.1.1.13 root 1418: for (i = size - 1; i >= not_stack; i--)
1.1.1.2 root 1419: #endif
1.1.1.17! root 1420: if (i >= not_stack + offset)
1.1.1.13 root 1421: {
1.1.1.14 root 1422: rtx wd;
1423: rtx addr;
1424: /* Get the next word of the value in WD. */
1.1.1.13 root 1425: if (GET_CODE (x) == MEM)
1.1.1.14 root 1426: {
1427: rtx addr = memory_address (SImode,
1428: plus_constant (XEXP (x, 0),
1429: i * UNITS_PER_WORD));
1430: /* Copy to a reg, since machine may lack
1431: memory-to-memory move insns. */
1432: wd = copy_to_reg (gen_rtx (MEM, SImode, addr));
1433: }
1.1.1.13 root 1434: else if (GET_CODE (x) == REG)
1.1.1.14 root 1435: wd = gen_rtx (SUBREG, SImode, x, i);
1.1.1.13 root 1436: else if (x == dconst0_rtx)
1.1.1.14 root 1437: wd = const0_rtx;
1.1.1.13 root 1438: else
1439: abort ();
1.1.1.14 root 1440:
1441: emit_push_insn (wd,
1442: SImode, 0, align, 0, 0, 0, args_addr,
1443: gen_rtx (CONST_INT, VOIDmode,
1.1.1.17! root 1444: args_offset + (i - not_stack + skip) * UNITS_PER_WORD));
1.1.1.13 root 1445: }
1.1 root 1446: }
1447: else
1.1.1.2 root 1448: {
1449: rtx addr;
1450: #ifdef PUSH_ROUNDING
1451: if (args_addr == 0)
1452: addr = gen_push_operand ();
1453: else
1454: #endif
1455: if (GET_CODE (args_so_far) == CONST_INT)
1456: addr
1457: = memory_address (mode,
1458: plus_constant (args_addr, INTVAL (args_so_far)));
1459: else
1460: addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
1461: args_so_far));
1462:
1463: emit_move_insn (gen_rtx (MEM, mode, addr), x);
1464: }
1465:
1.1.1.16 root 1466: ret:
1.1.1.17! root 1467: /* If part should go in registers, copy that part
! 1468: into the appropriate registers. Do this now, at the end,
! 1469: since mem-to-mem copies above may do function calls. */
! 1470: if (partial > 0)
! 1471: move_block_to_reg (REGNO (reg), x, partial);
! 1472:
1.1.1.6 root 1473: if (extra && args_addr == 0 && where_pad == stack_direction)
1.1.1.2 root 1474: anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
1.1 root 1475: }
1476:
1477: /* Output a library call to function FUN (a SYMBOL_REF rtx)
1.1.1.17! root 1478: (emitting the queue unless NO_QUEUE is nonzero),
! 1479: for a value of mode OUTMODE,
1.1 root 1480: with NARGS different arguments, passed as alternating rtx values
1481: and machine_modes to convert them to.
1482: The rtx values should have been passed through protect_from_queue already. */
1483:
1484: void
1.1.1.2 root 1485: emit_library_call (va_alist)
1486: va_dcl
1.1 root 1487: {
1.1.1.2 root 1488: register va_list p;
1.1 root 1489: register int args_size = 0;
1490: register int argnum;
1.1.1.2 root 1491: enum machine_mode outmode;
1492: int nargs;
1493: rtx fun;
1494: rtx orgfun;
1495: int inc;
1496: int count;
1497: rtx *regvec;
1498: rtx argblock = 0;
1499: CUMULATIVE_ARGS args_so_far;
1500: struct arg { rtx value; enum machine_mode mode; };
1501: struct arg *argvec;
1.1.1.17! root 1502: int old_inhibit_defer_pop = inhibit_defer_pop;
1.1.1.15 root 1503: int stack_padding = 0;
1.1.1.17! root 1504: int no_queue = 0;
1.1.1.2 root 1505:
1506: va_start (p);
1507: orgfun = fun = va_arg (p, rtx);
1.1.1.17! root 1508: no_queue = va_arg (p, int);
1.1.1.2 root 1509: outmode = va_arg (p, enum machine_mode);
1510: nargs = va_arg (p, int);
1511:
1512: regvec = (rtx *) alloca (nargs * sizeof (rtx));
1513:
1514: /* Copy all the libcall-arguments out of the varargs data
1515: and into a vector ARGVEC. */
1516: argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
1517: for (count = 0; count < nargs; count++)
1518: {
1.1.1.14 root 1519: rtx val = va_arg (p, rtx);
1520: enum machine_mode mode = va_arg (p, enum machine_mode);
1521:
1522: argvec[count].value = val;
1523:
1524: /* Convert the arg value to the mode the library wants.
1525: Also make sure it is a reasonable operand
1526: for a move or push insn. */
1527: /* ??? It is wrong to do it here; must do it earlier
1528: where we know the signedness of the arg. */
1529: if (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode)
1530: {
1531: val = gen_reg_rtx (mode);
1.1.1.16 root 1532: convert_move (val, argvec[count].value, 0);
1.1.1.14 root 1533: }
1534: else if (GET_CODE (val) != REG && GET_CODE (val) != MEM
1535:
1536: && ! ((CONSTANT_P (val) || GET_CODE (val) == CONST_DOUBLE)
1537: && LEGITIMATE_CONSTANT_P (val)))
1538: val = force_operand (val, 0);
1539:
1540: argvec[count].value = val;
1541: argvec[count].mode = mode;
1.1.1.2 root 1542: }
1543: va_end (p);
1544:
1545: /* If we have no actual push instructions, make space for all the args
1546: right now. */
1547: #ifndef PUSH_ROUNDING
1548: INIT_CUMULATIVE_ARGS (args_so_far, (tree)0);
1549: for (count = 0; count < nargs; count++)
1550: {
1551: register enum machine_mode mode = argvec[count].mode;
1552: register rtx reg;
1553: register int partial;
1554:
1.1.1.17! root 1555: reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1556: #ifdef FUNCTION_ARG_PARTIAL_NREGS
1.1.1.17! root 1557: partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1558: #else
1559: partial = 0;
1560: #endif
1561: if (reg == 0 || partial != 0)
1562: args_size += GET_MODE_SIZE (mode);
1563: if (partial != 0)
1564: args_size -= partial * GET_MODE_SIZE (SImode);
1.1.1.17! root 1565: FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1566: }
1567:
1568: if (args_size != 0)
1.1.1.15 root 1569: {
1570: #ifdef STACK_ARGS_ADJUST
1.1.1.16 root 1571: struct args_size size;
1572: size.constant = args_size;
1573: size.var = 0;
1574: STACK_ARGS_ADJUST (size);
1575: args_size = size.constant;
1.1.1.2 root 1576: #endif
1.1.1.15 root 1577: argblock
1578: = push_block (round_push (gen_rtx (CONST_INT, VOIDmode, args_size)));
1579: }
1580: #endif /* no PUSH_ROUNDING */
1.1.1.2 root 1581:
1582: INIT_CUMULATIVE_ARGS (args_so_far, (tree)0);
1583:
1584: #ifdef PUSH_ARGS_REVERSED
1585: inc = -1;
1586: argnum = nargs - 1;
1.1 root 1587: #else
1.1.1.2 root 1588: inc = 1;
1589: argnum = 0;
1.1 root 1590: #endif
1.1.1.15 root 1591: args_size = stack_padding;
1.1.1.2 root 1592:
1593: for (count = 0; count < nargs; count++, argnum += inc)
1.1 root 1594: {
1.1.1.2 root 1595: register enum machine_mode mode = argvec[argnum].mode;
1596: register rtx val = argvec[argnum].value;
1597: rtx reg;
1598: int partial;
1599: int arg_size;
1600:
1.1.1.17! root 1601: reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1602: regvec[argnum] = reg;
1603: #ifdef FUNCTION_ARG_PARTIAL_NREGS
1.1.1.17! root 1604: partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1605: #else
1606: partial = 0;
1607: #endif
1608:
1609: if (reg != 0 && partial == 0)
1610: emit_move_insn (reg, val);
1611: else
1612: emit_push_insn (val, mode, 0, 0, partial, reg, 0, argblock,
1613: gen_rtx (CONST_INT, VOIDmode, args_size));
1614:
1615: /* Compute size of stack space used by this argument. */
1616: if (reg == 0 || partial != 0)
1617: arg_size = GET_MODE_SIZE (mode);
1618: else
1619: arg_size = 0;
1620: if (partial != 0)
1621: arg_size
1622: -= ((partial * UNITS_PER_WORD)
1623: / (PARM_BOUNDARY / BITS_PER_UNIT)
1624: * (PARM_BOUNDARY / BITS_PER_UNIT));
1625:
1626: args_size += arg_size;
1.1.1.9 root 1627: NO_DEFER_POP;
1.1.1.17! root 1628: FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
1.1 root 1629: }
1630:
1.1.1.17! root 1631: /* For version 1.37, try deleting this entirely. */
! 1632: if (! no_queue)
! 1633: emit_queue ();
1.1.1.2 root 1634:
1635: fun = prepare_call_address (fun, 0);
1636:
1637: /* Any regs containing parms remain in use through the call.
1638: ??? This is not quite correct, since it doesn't indicate
1639: that they are in use immediately before the call insn.
1640: Currently that doesn't matter since explicitly-used regs
1641: won't be used for reloading. But if the reloader becomes smarter,
1642: this will have to change somehow. */
1643: for (count = 0; count < nargs; count++)
1644: if (regvec[count] != 0)
1645: emit_insn (gen_rtx (USE, VOIDmode, regvec[count]));
1646:
1647: #ifdef STACK_BOUNDARY
1648: args_size = (args_size + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
1649: #endif
1650:
1.1.1.3 root 1651: /* Don't allow popping to be deferred, since then
1652: cse'ing of library calls could delete a call and leave the pop. */
1.1.1.9 root 1653: NO_DEFER_POP;
1.1.1.2 root 1654: emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size,
1655: FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1656: outmode != VOIDmode ? hard_libcall_value (outmode) : 0,
1.1.1.17! root 1657: old_inhibit_defer_pop + 1);
1.1.1.9 root 1658: OK_DEFER_POP;
1.1 root 1659: }
1660:
1661: /* Expand an assignment that stores the value of FROM into TO.
1.1.1.2 root 1662: If WANT_VALUE is nonzero, return an rtx for the value of TO.
1663: (This may contain a QUEUED rtx.)
1664: Otherwise, the returned value is not meaningful.
1665:
1666: SUGGEST_REG is no longer actually used.
1667: It used to mean, copy the value through a register
1668: and return that register, if that is possible.
1669: But now we do this if WANT_VALUE.
1670:
1671: If the value stored is a constant, we return the constant. */
1.1 root 1672:
1673: rtx
1.1.1.2 root 1674: expand_assignment (to, from, want_value, suggest_reg)
1.1 root 1675: tree to, from;
1.1.1.2 root 1676: int want_value;
1677: int suggest_reg;
1.1 root 1678: {
1679: register rtx to_rtx = 0;
1680:
1681: /* Don't crash if the lhs of the assignment was erroneous. */
1682:
1683: if (TREE_CODE (to) == ERROR_MARK)
1684: return expand_expr (from, 0, VOIDmode, 0);
1685:
1686: /* Assignment of a structure component needs special treatment
1.1.1.2 root 1687: if the structure component's rtx is not simply a MEM.
1688: Assignment of an array element at a constant index
1689: has the same problem. */
1690:
1691: if (TREE_CODE (to) == COMPONENT_REF
1692: || (TREE_CODE (to) == ARRAY_REF
1693: && TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
1694: && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST))
1.1 root 1695: {
1.1.1.2 root 1696: register enum machine_mode mode1;
1697: int bitsize;
1.1 root 1698: int volstruct = 0;
1.1.1.2 root 1699: tree tem = to;
1700: int bitpos = 0;
1701: int unsignedp;
1.1 root 1702:
1.1.1.2 root 1703: if (TREE_CODE (to) == COMPONENT_REF)
1.1 root 1704: {
1705: tree field = TREE_OPERAND (to, 1);
1.1.1.2 root 1706: bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
1707: mode1 = DECL_MODE (TREE_OPERAND (to, 1));
1708: unsignedp = TREE_UNSIGNED (field);
1.1 root 1709: }
1.1.1.2 root 1710: else
1.1 root 1711: {
1.1.1.2 root 1712: mode1 = TYPE_MODE (TREE_TYPE (to));
1713: bitsize = GET_MODE_BITSIZE (mode1);
1714: unsignedp = TREE_UNSIGNED (TREE_TYPE (to));
1.1 root 1715: }
1716:
1.1.1.2 root 1717: /* Compute cumulative bit-offset for nested component-refs
1718: and array-refs, and find the ultimate containing object. */
1.1 root 1719:
1.1.1.2 root 1720: while (1)
1.1 root 1721: {
1.1.1.2 root 1722: if (TREE_CODE (tem) == COMPONENT_REF)
1723: {
1724: bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
1725: if (TREE_THIS_VOLATILE (tem))
1726: volstruct = 1;
1727: }
1728: else if (TREE_CODE (tem) == ARRAY_REF
1729: && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
1730: && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
1731: {
1732: bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
1733: * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
1734: * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
1735: }
1736: else
1737: break;
1738: tem = TREE_OPERAND (tem, 0);
1.1 root 1739: }
1.1.1.17! root 1740: /* TEM is now the containing data object. */
1.1 root 1741:
1.1.1.2 root 1742: /* If we are going to use store_bit_field and extract_bit_field,
1743: make sure to_rtx will be safe for multiple use. */
1744: if (mode1 == BImode && want_value)
1745: tem = stabilize_reference (tem);
1.1 root 1746:
1.1.1.2 root 1747: to_rtx = expand_expr (tem, 0, VOIDmode, 0);
1748:
1749: return store_field (to_rtx, bitsize, bitpos, mode1, from,
1.1.1.10 root 1750: (want_value
1751: /* Spurious cast makes HPUX compiler happy. */
1752: ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
1753: : VOIDmode),
1.1.1.14 root 1754: unsignedp,
1.1.1.17! root 1755: /* Required alignment of containing datum. */
! 1756: TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT);
1.1 root 1757: }
1758:
1759: /* Ordinary treatment. Expand TO to get a REG or MEM rtx.
1760: Don't re-expand if it was expanded already (in COMPONENT_REF case). */
1761:
1762: if (to_rtx == 0)
1763: to_rtx = expand_expr (to, 0, VOIDmode, 0);
1764:
1765: /* Compute FROM and store the value in the rtx we got. */
1766:
1.1.1.2 root 1767: return store_expr (from, to_rtx, want_value);
1.1 root 1768: }
1769:
1770: /* Generate code for computing expression EXP,
1.1.1.2 root 1771: and storing the value into TARGET.
1772: Returns TARGET or an equivalent value.
1773: TARGET may contain a QUEUED rtx.
1.1 root 1774:
1.1.1.2 root 1775: If SUGGEST_REG is nonzero, copy the value through a register
1776: and return that register, if that is possible.
1777:
1778: If the value stored is a constant, we return the constant. */
1779:
1780: rtx
1781: store_expr (exp, target, suggest_reg)
1.1 root 1782: register tree exp;
1783: register rtx target;
1.1.1.2 root 1784: int suggest_reg;
1.1 root 1785: {
1.1.1.2 root 1786: register rtx temp;
1787: int dont_return_target = 0;
1788:
1789: /* Copying a non-constant CONSTRUCTOR needs special treatment. */
1790:
1791: if (TREE_CODE (exp) == CONSTRUCTOR && ! TREE_LITERAL (exp))
1792: {
1793: store_constructor (exp, target);
1794: return target;
1795: }
1796:
1797: if (suggest_reg && GET_CODE (target) == MEM && GET_MODE (target) != BLKmode)
1798: /* If target is in memory and caller wants value in a register instead,
1799: arrange that. Pass TARGET as target for expand_expr so that,
1800: if EXP is another assignment, SUGGEST_REG will be nonzero for it.
1801: We know expand_expr will not use the target in that case. */
1802: {
1803: temp = expand_expr (exp, cse_not_expected ? 0 : target,
1804: GET_MODE (target), 0);
1805: if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
1806: temp = copy_to_reg (temp);
1807: dont_return_target = 1;
1808: }
1809: else if (queued_subexp_p (target))
1810: /* If target contains a postincrement, it is not safe
1811: to use as the returned value. It would access the wrong
1812: place by the time the queued increment gets output.
1813: So copy the value through a temporary and use that temp
1814: as the result. */
1815: {
1816: temp = expand_expr (exp, 0, GET_MODE (target), 0);
1817: if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
1818: temp = copy_to_reg (temp);
1819: dont_return_target = 1;
1820: }
1821: else
1822: {
1823: temp = expand_expr (exp, target, GET_MODE (target), 0);
1824: /* DO return TARGET if it's a specified hardware register.
1825: expand_return relies on this. */
1826: if (!(target && GET_CODE (target) == REG
1827: && REGNO (target) < FIRST_PSEUDO_REGISTER)
1828: && (CONSTANT_P (temp) || GET_CODE (temp) == CONST_DOUBLE))
1829: dont_return_target = 1;
1830: }
1831:
1.1.1.12 root 1832: /* If value was not generated in the target, store it there.
1833: Convert the value to TARGET's type first if nec. */
1.1.1.2 root 1834:
1.1 root 1835: if (temp != target && TREE_CODE (exp) != ERROR_MARK)
1836: {
1837: target = protect_from_queue (target, 1);
1838: if (GET_MODE (temp) != GET_MODE (target)
1839: && GET_MODE (temp) != VOIDmode)
1.1.1.2 root 1840: {
1841: int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
1842: if (dont_return_target)
1.1.1.12 root 1843: {
1844: /* In this case, we will return TEMP,
1845: so make sure it has the proper mode.
1846: But don't forget to store the value into TARGET. */
1847: temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
1848: emit_move_insn (target, temp);
1849: }
1.1.1.2 root 1850: else
1851: convert_move (target, temp, unsignedp);
1852: }
1853:
1.1 root 1854: else if (GET_MODE (temp) == BLKmode)
1855: emit_block_move (target, temp, expr_size (exp),
1856: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1857: else
1858: emit_move_insn (target, temp);
1859: }
1.1.1.2 root 1860: if (dont_return_target)
1861: return temp;
1.1 root 1862: return target;
1863: }
1864:
1.1.1.2 root 1865: /* Store the value of constructor EXP into the rtx TARGET.
1866: TARGET is either a REG or a MEM. */
1.1 root 1867:
1.1.1.2 root 1868: static void
1869: store_constructor (exp, target)
1870: tree exp;
1871: rtx target;
1.1 root 1872: {
1.1.1.7 root 1873: /* Don't try copying piece by piece into a hard register
1874: since that is vulnerable to being clobbered by EXP.
1875: Instead, construct in a pseudo register and then copy it all. */
1876: if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
1877: {
1878: rtx temp = gen_reg_rtx (GET_MODE (target));
1879: store_constructor (exp, temp);
1880: emit_move_insn (target, temp);
1881: return;
1882: }
1883:
1.1.1.2 root 1884: if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1.1 root 1885: {
1.1.1.2 root 1886: register tree elt;
1.1 root 1887:
1.1.1.2 root 1888: /* If the constructor has fewer fields than the structure,
1889: clear the whole structure first. */
1.1 root 1890:
1.1.1.2 root 1891: if (list_length (CONSTRUCTOR_ELTS (exp))
1892: != list_length (TYPE_FIELDS (TREE_TYPE (exp))))
1893: clear_storage (target, int_size_in_bytes (TREE_TYPE (exp)));
1894: else
1895: /* Inform later passes that the old value is dead. */
1896: emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
1897:
1898: /* Store each element of the constructor into
1899: the corresponding field of TARGET. */
1900:
1901: for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
1902: {
1903: register tree field = TREE_PURPOSE (elt);
1904: register enum machine_mode mode;
1905: int bitsize;
1906: int bitpos;
1907: int unsignedp;
1908:
1909: bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
1910: mode = DECL_MODE (field);
1911: unsignedp = TREE_UNSIGNED (field);
1912:
1913: bitpos = DECL_OFFSET (field);
1914:
1915: store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
1.1.1.15 root 1916: /* The alignment of TARGET is
1917: at least what its type requires. */
1.1.1.17! root 1918: VOIDmode, 0,
! 1919: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1.1.1.2 root 1920: }
1921: }
1922: else if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
1923: {
1924: register tree elt;
1925: register int i;
1926: tree domain = TYPE_DOMAIN (TREE_TYPE (exp));
1927: int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
1928: int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
1929: tree elttype = TREE_TYPE (TREE_TYPE (exp));
1930:
1931: /* If the constructor has fewer fields than the structure,
1932: clear the whole structure first. */
1933:
1934: if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1)
1935: clear_storage (target, maxelt - minelt + 1);
1936: else
1937: /* Inform later passes that the old value is dead. */
1938: emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
1939:
1940: /* Store each element of the constructor into
1941: the corresponding element of TARGET, determined
1942: by counting the elements. */
1943: for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
1944: elt;
1945: elt = TREE_CHAIN (elt), i++)
1946: {
1947: register enum machine_mode mode;
1948: int bitsize;
1949: int bitpos;
1950: int unsignedp;
1951:
1952: mode = TYPE_MODE (elttype);
1953: bitsize = GET_MODE_BITSIZE (mode);
1954: unsignedp = TREE_UNSIGNED (elttype);
1955:
1956: bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
1957: * TYPE_SIZE_UNIT (elttype));
1958:
1959: store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
1.1.1.15 root 1960: /* The alignment of TARGET is
1961: at least what its type requires. */
1.1.1.17! root 1962: VOIDmode, 0,
! 1963: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1.1.1.2 root 1964: }
1965: }
1966: }
1967:
1968: /* Store the value of EXP (an expression tree)
1969: into a subfield of TARGET which has mode MODE and occupies
1970: BITSIZE bits, starting BITPOS bits from the start of TARGET.
1971:
1972: If VALUE_MODE is VOIDmode, return nothing in particular.
1973: UNSIGNEDP is not used in this case.
1974:
1975: Otherwise, return an rtx for the value stored. This rtx
1976: has mode VALUE_MODE if that is convenient to do.
1.1.1.14 root 1977: In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
1978:
1979: ALIGN is the alignment that TARGET is known to have, measured in bytes. */
1.1.1.2 root 1980:
1981: static rtx
1.1.1.14 root 1982: store_field (target, bitsize, bitpos, mode, exp, value_mode, unsignedp, align)
1.1.1.2 root 1983: rtx target;
1984: int bitsize, bitpos;
1985: enum machine_mode mode;
1986: tree exp;
1987: enum machine_mode value_mode;
1988: int unsignedp;
1.1.1.14 root 1989: int align;
1.1.1.2 root 1990: {
1991: /* If the structure is in a register or if the component
1992: is a bit field, we cannot use addressing to access it.
1993: Use bit-field techniques or SUBREG to store in it. */
1994:
1995: if (mode == BImode || GET_CODE (target) == REG
1996: || GET_CODE (target) == SUBREG)
1997: {
1998: store_bit_field (target, bitsize, bitpos,
1999: mode,
1.1.1.14 root 2000: expand_expr (exp, 0, VOIDmode, 0),
2001: align);
1.1.1.2 root 2002: if (value_mode != VOIDmode)
2003: return extract_bit_field (target, bitsize, bitpos, unsignedp,
1.1.1.14 root 2004: 0, value_mode, 0, align);
1.1.1.2 root 2005: return const0_rtx;
2006: }
2007: else
2008: {
2009: rtx addr = XEXP (target, 0);
2010: rtx to_rtx;
2011:
2012: /* If a value is wanted, it must be the lhs;
2013: so make the address stable for multiple use. */
2014:
2015: if (value_mode != VOIDmode && GET_CODE (addr) != REG
2016: && ! CONSTANT_ADDRESS_P (addr))
2017: addr = copy_to_reg (addr);
2018:
2019: /* Now build a reference to just the desired component. */
2020:
2021: to_rtx = change_address (target, mode,
2022: plus_constant (addr,
2023: (bitpos / BITS_PER_UNIT)));
1.1.1.10 root 2024: MEM_IN_STRUCT_P (to_rtx) = 1;
1.1.1.2 root 2025:
2026: return store_expr (exp, to_rtx, value_mode != VOIDmode);
2027: }
2028: }
2029:
2030: /* Given an rtx VALUE that may contain additions and multiplications,
2031: return an equivalent value that just refers to a register or memory.
2032: This is done by generating instructions to perform the arithmetic
2033: and returning a pseudo-register containing the value. */
2034:
2035: rtx
2036: force_operand (value, target)
2037: rtx value, target;
2038: {
2039: register optab binoptab = 0;
2040: register rtx op2;
2041: /* Use subtarget as the target for operand 0 of a binary operation. */
2042: register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
2043:
2044: if (GET_CODE (value) == PLUS)
2045: binoptab = add_optab;
2046: else if (GET_CODE (value) == MINUS)
2047: binoptab = sub_optab;
2048: else if (GET_CODE (value) == MULT)
2049: {
2050: op2 = XEXP (value, 1);
2051: if (!CONSTANT_P (op2)
2052: && !(GET_CODE (op2) == REG && op2 != subtarget))
2053: subtarget = 0;
2054: return expand_mult (GET_MODE (value),
2055: force_operand (XEXP (value, 0), subtarget),
2056: force_operand (op2, 0),
2057: target, 0);
2058: }
2059:
2060: if (binoptab)
2061: {
2062: op2 = XEXP (value, 1);
2063: if (!CONSTANT_P (op2)
2064: && !(GET_CODE (op2) == REG && op2 != subtarget))
2065: subtarget = 0;
2066: if (binoptab == sub_optab
2067: && GET_CODE (op2) == CONST_INT && INTVAL (op2) < 0)
2068: {
2069: binoptab = add_optab;
2070: op2 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op2));
2071: }
2072: return expand_binop (GET_MODE (value), binoptab,
2073: force_operand (XEXP (value, 0), subtarget),
2074: force_operand (op2, 0),
2075: target, 0, OPTAB_LIB_WIDEN);
2076: /* We give UNSIGNEP = 0 to expand_binop
2077: because the only operations we are expanding here are signed ones. */
2078: }
2079: return value;
2080: }
2081:
2082: /* expand_expr: generate code for computing expression EXP.
1.1.1.14 root 2083: An rtx for the computed value is returned. The value is never null.
2084: In the case of a void EXP, const0_rtx is returned.
1.1.1.2 root 2085:
2086: The value may be stored in TARGET if TARGET is nonzero.
1.1 root 2087: TARGET is just a suggestion; callers must assume that
2088: the rtx returned may not be the same as TARGET.
2089:
1.1.1.2 root 2090: If TARGET is CONST0_RTX, it means that the value will be ignored.
2091:
1.1 root 2092: If TMODE is not VOIDmode, it suggests generating the
2093: result in mode TMODE. But this is done only when convenient.
2094: Otherwise, TMODE is ignored and the value generated in its natural mode.
2095: TMODE is just a suggestion; callers must assume that
2096: the rtx returned may not have mode TMODE.
2097:
1.1.1.2 root 2098: If MODIFIER is EXPAND_SUM then when EXP is an addition
1.1 root 2099: we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
2100: or a nest of (PLUS ...) and (MINUS ...) where the terms are
2101: products as above, or REG or MEM, or constant.
1.1.1.2 root 2102: Ordinarily in such cases we would output mul or add instructions
2103: and then return a pseudo reg containing the sum.
2104:
2105: If MODIFIER is EXPAND_CONST_ADDRESS then it is ok to return
2106: a MEM rtx whose address is a constant that isn't a legitimate address. */
1.1 root 2107:
2108: /* Subroutine of expand_expr:
1.1.1.13 root 2109: save the non-copied parts (LIST) of an expr (LHS), and return a list
2110: which can restore these values to their previous values,
2111: should something modify their storage. */
2112: static tree
2113: save_noncopied_parts (lhs, list)
2114: tree lhs;
2115: tree list;
2116: {
2117: tree tail;
2118: tree parts = 0;
2119:
2120: for (tail = list; tail; tail = TREE_CHAIN (tail))
2121: if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
2122: parts = chainon (parts, save_noncopied_parts (TREE_VALUE (tail)));
2123: else
2124: {
2125: tree part = TREE_VALUE (tail);
2126: tree part_type = TREE_TYPE (part);
2127: parts = tree_cons (save_expr (build_component_ref (lhs, part, parts, 0)),
2128: build_nt (RTL_EXPR, 0, (tree) assign_stack_local (TYPE_MODE (part_type), int_size_in_bytes (part_type))),
2129: parts);
2130: store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
2131: }
2132: return parts;
2133: }
2134:
2135: /* Subroutine of expand_expr:
1.1 root 2136: return the target to use when recursively expanding
2137: the first operand of an arithmetic operation. */
2138:
2139: static rtx
2140: validate_subtarget (subtarget, otherop)
2141: rtx subtarget;
2142: tree otherop;
2143: {
2144: if (TREE_LITERAL (otherop))
2145: return subtarget;
2146: if (TREE_CODE (otherop) == VAR_DECL
2147: && DECL_RTL (otherop) != subtarget)
2148: return subtarget;
2149: return 0;
2150: }
2151:
2152: rtx
1.1.1.2 root 2153: expand_expr (exp, target, tmode, modifier)
1.1 root 2154: register tree exp;
2155: rtx target;
2156: enum machine_mode tmode;
1.1.1.2 root 2157: enum expand_modifier modifier;
1.1 root 2158: {
2159: register rtx op0, op1, temp;
2160: tree type = TREE_TYPE (exp);
2161: register enum machine_mode mode = TYPE_MODE (type);
2162: register enum tree_code code = TREE_CODE (exp);
1.1.1.2 root 2163: optab this_optab;
1.1 root 2164: int negate_1;
2165: /* Use subtarget as the target for operand 0 of a binary operation. */
2166: rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
1.1.1.2 root 2167: rtx original_target = target;
2168: int ignore = target == const0_rtx;
2169:
1.1.1.7 root 2170: /* Don't use hard regs as subtargets, because the combiner
2171: can only handle pseudo regs. */
2172: if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
2173: subtarget = 0;
1.1.1.17! root 2174: /* Avoid subtargets inside loops,
! 2175: since they hide some invariant expressions. */
! 2176: if (optimize && inside_loop ())
! 2177: subtarget = 0;
1.1.1.7 root 2178:
1.1.1.2 root 2179: if (ignore) target = 0, original_target = 0;
1.1 root 2180:
2181: /* If will do cse, generate all results into registers
2182: since 1) that allows cse to find more things
2183: and 2) otherwise cse could produce an insn the machine
2184: cannot support. */
2185:
2186: if (! cse_not_expected && mode != BLKmode)
2187: target = subtarget;
2188:
1.1.1.2 root 2189: /* No sense saving up arithmetic to be done
2190: if it's all in the wrong mode to form part of an address.
2191: And force_operand won't know whether to sign-extend or zero-extend. */
2192:
2193: if (mode != Pmode && modifier == EXPAND_SUM)
1.1.1.6 root 2194: modifier = EXPAND_NORMAL;
1.1.1.2 root 2195:
1.1 root 2196: switch (code)
2197: {
1.1.1.4 root 2198: case PARM_DECL:
2199: if (DECL_RTL (exp) == 0)
2200: {
2201: error_with_decl (exp, "prior parameter's size depends on `%s'");
2202: return const0_rtx;
2203: }
2204:
1.1 root 2205: case FUNCTION_DECL:
2206: case VAR_DECL:
2207: case RESULT_DECL:
2208: if (DECL_RTL (exp) == 0)
2209: abort ();
1.1.1.14 root 2210: /* This is the case of an array whose size is to be determined
2211: from its initializer, while the initializer is still being parsed.
2212: See expand_decl. */
2213: if (GET_CODE (DECL_RTL (exp)) == MEM
2214: && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
1.1.1.16 root 2215: return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
1.1.1.14 root 2216: XEXP (DECL_RTL (exp), 0));
1.1.1.2 root 2217: if (GET_CODE (DECL_RTL (exp)) == MEM
2218: && modifier != EXPAND_CONST_ADDRESS)
2219: {
2220: /* DECL_RTL probably contains a constant address.
2221: On RISC machines where a constant address isn't valid,
2222: make some insns to get that address into a register. */
1.1.1.7 root 2223: if (!memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
2224: || (flag_force_addr
2225: && CONSTANT_ADDRESS_P (XEXP (DECL_RTL (exp), 0))))
1.1.1.2 root 2226: return change_address (DECL_RTL (exp), VOIDmode,
2227: copy_rtx (XEXP (DECL_RTL (exp), 0)));
2228: }
1.1 root 2229: return DECL_RTL (exp);
2230:
2231: case INTEGER_CST:
1.1.1.7 root 2232: if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT)
2233: return gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (exp));
1.1.1.8 root 2234: /* Generate immediate CONST_DOUBLE
1.1.1.7 root 2235: which will be turned into memory by reload if necessary. */
1.1.1.8 root 2236: return immed_double_const (TREE_INT_CST_LOW (exp),
2237: TREE_INT_CST_HIGH (exp),
2238: mode);
1.1 root 2239:
2240: case CONST_DECL:
2241: return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
2242:
2243: case REAL_CST:
1.1.1.7 root 2244: /* If optimized, generate immediate CONST_DOUBLE
2245: which will be turned into memory by reload if necessary. */
1.1 root 2246: if (!cse_not_expected)
2247: return immed_real_const (exp);
2248: case COMPLEX_CST:
2249: case STRING_CST:
1.1.1.8 root 2250: if (! TREE_CST_RTL (exp))
2251: output_constant_def (exp);
2252:
2253: /* TREE_CST_RTL probably contains a constant address.
2254: On RISC machines where a constant address isn't valid,
2255: make some insns to get that address into a register. */
2256: if (GET_CODE (TREE_CST_RTL (exp)) == MEM
2257: && modifier != EXPAND_CONST_ADDRESS
2258: && !memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0)))
2259: return change_address (TREE_CST_RTL (exp), VOIDmode,
2260: copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
1.1 root 2261: return TREE_CST_RTL (exp);
2262:
2263: case SAVE_EXPR:
2264: if (SAVE_EXPR_RTL (exp) == 0)
2265: {
1.1.1.5 root 2266: rtx reg = gen_reg_rtx (mode);
2267: SAVE_EXPR_RTL (exp) = reg;
2268: store_expr (TREE_OPERAND (exp, 0), reg, 0);
2269: if (!optimize)
2270: save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg,
2271: save_expr_regs);
1.1 root 2272: }
1.1.1.2 root 2273: /* Don't let the same rtl node appear in two places. */
1.1 root 2274: return SAVE_EXPR_RTL (exp);
2275:
1.1.1.17! root 2276: case LET_STMT:
! 2277: TREE_USED (exp) = 1;
! 2278: temp = expand_expr (STMT_BODY (exp), target, tmode, modifier);
! 2279: return temp;
! 2280:
1.1.1.2 root 2281: case RTL_EXPR:
1.1.1.10 root 2282: if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
2283: abort ();
2284: emit_insns (RTL_EXPR_SEQUENCE (exp));
2285: RTL_EXPR_SEQUENCE (exp) = const0_rtx;
1.1.1.2 root 2286: return RTL_EXPR_RTL (exp);
2287:
2288: case CONSTRUCTOR:
2289: /* All elts simple constants => refer to a constant in memory. */
2290: if (TREE_STATIC (exp))
2291: /* For aggregate types with non-BLKmode modes,
2292: this should ideally construct a CONST_INT. */
1.1.1.14 root 2293: {
2294: rtx constructor = output_constant_def (exp);
2295: if (! memory_address_p (GET_MODE (constructor),
2296: XEXP (constructor, 0)))
2297: constructor = change_address (constructor, VOIDmode,
2298: XEXP (constructor, 0));
2299: return constructor;
2300: }
1.1.1.2 root 2301:
2302: if (ignore)
2303: {
2304: tree elt;
2305: for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
2306: expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
2307: return const0_rtx;
2308: }
2309: else
2310: {
2311: if (target == 0)
2312: target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
2313: get_structure_value_addr (expr_size (exp)));
2314: store_expr (exp, target, 0);
2315: return target;
2316: }
2317:
1.1 root 2318: case INDIRECT_REF:
2319: {
2320: tree exp1 = TREE_OPERAND (exp, 0);
2321: tree exp2;
2322:
2323: /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
2324: for *PTR += ANYTHING where PTR is put inside the SAVE_EXPR.
2325: This code has the same general effect as simply doing
2326: expand_expr on the save expr, except that the expression PTR
2327: is computed for use as a memory address. This means different
2328: code, suitable for indexing, may be generated. */
2329: if (TREE_CODE (exp1) == SAVE_EXPR
2330: && SAVE_EXPR_RTL (exp1) == 0
2331: && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK
2332: && TYPE_MODE (TREE_TYPE (exp1)) == Pmode
2333: && TYPE_MODE (TREE_TYPE (exp2)) == Pmode)
2334: {
1.1.1.2 root 2335: temp = expand_expr (TREE_OPERAND (exp1, 0), 0, VOIDmode, EXPAND_SUM);
1.1 root 2336: op0 = memory_address (mode, temp);
2337: op0 = copy_all_regs (op0);
2338: SAVE_EXPR_RTL (exp1) = op0;
2339: }
2340: else
2341: {
1.1.1.2 root 2342: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, EXPAND_SUM);
1.1 root 2343: op0 = memory_address (mode, op0);
2344: }
2345: }
2346: temp = gen_rtx (MEM, mode, op0);
1.1.1.2 root 2347: /* If address was computed by addition,
2348: mark this as an element of an aggregate. */
2349: if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
2350: || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
2351: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR))
1.1.1.10 root 2352: MEM_IN_STRUCT_P (temp) = 1;
1.1.1.13 root 2353: MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) || flag_volatile;
1.1.1.10 root 2354: RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
1.1.1.2 root 2355: return temp;
2356:
2357: case ARRAY_REF:
2358: if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST
2359: || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
2360: {
2361: /* Nonconstant array index or nonconstant element size.
2362: Generate the tree for *(&array+index) and expand that,
2363: except do it in a language-independent way
2364: and don't complain about non-lvalue arrays.
2365: `mark_addressable' should already have been called
2366: for any array for which this case will be reached. */
2367:
2368: tree array_adr = build (ADDR_EXPR, TYPE_POINTER_TO (type),
2369: TREE_OPERAND (exp, 0));
2370: tree index = TREE_OPERAND (exp, 1);
2371: tree elt;
2372:
2373: /* Convert the integer argument to a type the same size as a pointer
2374: so the multiply won't overflow spuriously. */
2375: if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
2376: index = convert (type_for_size (POINTER_SIZE, 0), index);
2377:
2378: /* The array address isn't volatile even if the array is. */
2379: TREE_VOLATILE (array_adr) = 0;
2380:
2381: elt = build (INDIRECT_REF, type,
2382: fold (build (PLUS_EXPR, TYPE_POINTER_TO (type),
2383: array_adr,
2384: fold (build (MULT_EXPR,
2385: TYPE_POINTER_TO (type),
2386: index, size_in_bytes (type))))));
2387:
2388: return expand_expr (elt, target, tmode, modifier);
2389: }
1.1.1.13 root 2390:
1.1.1.17! root 2391: /* Fold an expression like: "foo"[2].
! 2392: This is not done in fold so it won't happen inside &. */
! 2393: {
! 2394: int i;
! 2395: tree arg0 = TREE_OPERAND (exp, 0);
! 2396: tree arg1 = TREE_OPERAND (exp, 1);
! 2397:
! 2398: if (TREE_CODE (arg0) == STRING_CST
! 2399: && TREE_CODE (arg1) == INTEGER_CST
! 2400: && !TREE_INT_CST_HIGH (arg1)
! 2401: && (i = TREE_INT_CST_LOW (arg1)) < TREE_STRING_LENGTH (arg0))
! 2402: {
! 2403: if (TREE_TYPE (TREE_TYPE (arg0)) == integer_type_node)
! 2404: {
! 2405: exp = build_int_2 (((int *)TREE_STRING_POINTER (arg0))[i], 0);
! 2406: TREE_TYPE (exp) = integer_type_node;
! 2407: return expand_expr (exp, target, tmode, modifier);
! 2408: }
! 2409: if (TREE_TYPE (TREE_TYPE (arg0)) == char_type_node)
! 2410: {
! 2411: exp = build_int_2 (TREE_STRING_POINTER (arg0)[i], 0);
! 2412: TREE_TYPE (exp) = integer_type_node;
! 2413: return expand_expr (convert (TREE_TYPE (TREE_TYPE (arg0)), exp), target, tmode, modifier);
! 2414: }
! 2415: }
! 2416: }
! 2417:
1.1.1.13 root 2418: /* If this is a constant index into a constant array,
2419: just get the value from the array. */
2420: if (TREE_READONLY (TREE_OPERAND (exp, 0))
2421: && ! TREE_VOLATILE (TREE_OPERAND (exp, 0))
2422: && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == ARRAY_TYPE
2423: && TREE_LITERAL (TREE_OPERAND (exp, 1))
2424: && TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL
1.1.1.15 root 2425: && DECL_INITIAL (TREE_OPERAND (exp, 0))
2426: && TREE_CODE (DECL_INITIAL (TREE_OPERAND (exp, 0))) != ERROR_MARK)
1.1.1.13 root 2427: {
2428: tree index = fold (TREE_OPERAND (exp, 1));
2429: if (TREE_CODE (index) == INTEGER_CST)
2430: {
2431: int i = TREE_INT_CST_LOW (index);
2432: tree init = CONSTRUCTOR_ELTS (DECL_INITIAL (TREE_OPERAND (exp, 0)));
2433:
2434: while (init && i--)
2435: init = TREE_CHAIN (init);
2436: if (init)
2437: return expand_expr (fold (TREE_VALUE (init)), target, tmode, modifier);
2438: }
2439: }
1.1.1.2 root 2440: /* Treat array-ref with constant index as a component-ref. */
1.1 root 2441:
2442: case COMPONENT_REF:
2443: {
1.1.1.2 root 2444: register enum machine_mode mode1;
1.1 root 2445: int volstruct = 0;
1.1.1.2 root 2446: int bitsize;
2447: tree tem = exp;
2448: int bitpos = 0;
2449: int unsignedp;
1.1 root 2450:
1.1.1.2 root 2451: if (TREE_CODE (exp) == COMPONENT_REF)
1.1 root 2452: {
2453: tree field = TREE_OPERAND (exp, 1);
1.1.1.2 root 2454: bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
2455: mode1 = DECL_MODE (TREE_OPERAND (exp, 1));
2456: unsignedp = TREE_UNSIGNED (field);
1.1 root 2457: }
1.1.1.2 root 2458: else
1.1 root 2459: {
1.1.1.2 root 2460: mode1 = TYPE_MODE (TREE_TYPE (exp));
2461: bitsize = GET_MODE_BITSIZE (mode1);
2462: unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
1.1 root 2463: }
2464:
1.1.1.2 root 2465: /* Compute cumulative bit-offset for nested component-refs
2466: and array-refs, and find the ultimate containing object. */
2467:
2468: while (1)
1.1 root 2469: {
1.1.1.2 root 2470: if (TREE_CODE (tem) == COMPONENT_REF)
2471: {
2472: bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
2473: if (TREE_THIS_VOLATILE (tem))
2474: volstruct = 1;
2475: }
2476: else if (TREE_CODE (tem) == ARRAY_REF
2477: && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
2478: && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
2479: {
2480: bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
2481: * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
2482: * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
2483: }
2484: else
2485: break;
2486: tem = TREE_OPERAND (tem, 0);
1.1 root 2487: }
2488:
1.1.1.2 root 2489: op0 = expand_expr (tem, 0, VOIDmode,
2490: (modifier == EXPAND_CONST_ADDRESS
2491: ? modifier : EXPAND_NORMAL));
1.1 root 2492:
1.1.1.2 root 2493: if (mode1 == BImode || GET_CODE (op0) == REG
2494: || GET_CODE (op0) == SUBREG)
1.1.1.17! root 2495: return extract_bit_field (op0, bitsize, bitpos, unsignedp,
! 2496: target, mode, tmode,
! 2497: TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT);
1.1.1.2 root 2498: /* Get a reference to just this component. */
2499: if (modifier == EXPAND_CONST_ADDRESS)
2500: op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
2501: (bitpos / BITS_PER_UNIT)));
2502: else
2503: op0 = change_address (op0, mode1,
2504: plus_constant (XEXP (op0, 0),
2505: (bitpos / BITS_PER_UNIT)));
1.1.1.10 root 2506: MEM_IN_STRUCT_P (op0) = 1;
1.1.1.15 root 2507: MEM_VOLATILE_P (op0) |= volstruct;
1.1.1.2 root 2508: /* If OP0 is in the shared structure-value stack slot,
2509: and it is not BLKmode, copy it into a register.
2510: The shared slot may be clobbered at any time by another call.
2511: BLKmode is safe because our caller will either copy the value away
2512: or take another component and come back here. */
2513: if (mode != BLKmode
2514: && TREE_CODE (TREE_OPERAND (exp, 0)) == CALL_EXPR
2515: && TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == BLKmode)
2516: op0 = copy_to_reg (op0);
2517: if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
2518: return op0;
2519: if (target == 0)
2520: target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
2521: convert_move (target, op0, unsignedp);
2522: return target;
1.1 root 2523: }
2524:
2525: /* Intended for a reference to a buffer of a file-object in Pascal.
2526: But it's not certain that a special tree code will really be
2527: necessary for these. INDIRECT_REF might work for them. */
2528: case BUFFER_REF:
2529: abort ();
2530:
1.1.1.13 root 2531: case WITH_CLEANUP_EXPR:
2532: RTL_EXPR_RTL (TREE_OPERAND (exp, 1))
2533: = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
2534: cleanups_of_this_call = tree_cons (0, TREE_OPERAND (exp, 2), cleanups_of_this_call);
2535: return RTL_EXPR_RTL (TREE_OPERAND (exp, 1));
2536:
1.1 root 2537: case CALL_EXPR:
1.1.1.2 root 2538: /* Check for a built-in function. */
2539: if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
2540: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
1.1.1.5 root 2541: && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
2542: != NOT_BUILT_IN))
1.1.1.17! root 2543: return expand_builtin (exp, target, subtarget, tmode, ignore);
1.1 root 2544: /* If this call was expanded already by preexpand_calls,
2545: just return the result we got. */
2546: if (CALL_EXPR_RTL (exp) != 0)
2547: return CALL_EXPR_RTL (exp);
1.1.1.2 root 2548: return expand_call (exp, target, ignore);
1.1 root 2549:
2550: case NOP_EXPR:
2551: case CONVERT_EXPR:
1.1.1.7 root 2552: case REFERENCE_EXPR:
1.1.1.2 root 2553: if (TREE_CODE (type) == VOID_TYPE || ignore)
1.1 root 2554: {
1.1.1.2 root 2555: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
1.1 root 2556: return const0_rtx;
2557: }
2558: if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
1.1.1.2 root 2559: return expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier);
1.1 root 2560: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, mode, 0);
1.1.1.2 root 2561: if (GET_MODE (op0) == mode || GET_MODE (op0) == VOIDmode)
1.1 root 2562: return op0;
1.1.1.2 root 2563: if (flag_force_mem && GET_CODE (op0) == MEM)
2564: op0 = copy_to_reg (op0);
1.1 root 2565: if (target == 0)
2566: target = gen_reg_rtx (mode);
1.1.1.2 root 2567: convert_move (target, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
1.1 root 2568: return target;
2569:
2570: case PLUS_EXPR:
2571: preexpand_calls (exp);
1.1.1.2 root 2572: if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
2573: && modifier == EXPAND_SUM)
1.1 root 2574: {
1.1.1.2 root 2575: op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode, EXPAND_SUM);
1.1 root 2576: op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
1.1.1.2 root 2577: return op1;
1.1 root 2578: }
2579: negate_1 = 1;
2580: plus_minus:
1.1.1.2 root 2581: if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
2582: && modifier == EXPAND_SUM)
1.1 root 2583: {
1.1.1.2 root 2584: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
1.1 root 2585: op0 = plus_constant (op0,
2586: negate_1 * TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
1.1.1.2 root 2587: return op0;
1.1 root 2588: }
2589: this_optab = add_optab;
1.1.1.2 root 2590: if (modifier != EXPAND_SUM) goto binop;
1.1 root 2591: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
1.1.1.2 root 2592: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
2593: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, EXPAND_SUM);
1.1 root 2594: /* Put a sum last, to simplify what follows. */
2595: #ifdef OLD_INDEXING
2596: if (GET_CODE (op1) == MULT)
2597: {
2598: temp = op0;
2599: op0 = op1;
2600: op1 = temp;
2601: }
2602: #endif
2603: #ifndef OLD_INDEXING
2604: /* Make sure any term that's a sum with a constant comes last. */
2605: if (GET_CODE (op0) == PLUS
1.1.1.2 root 2606: && CONSTANT_P (XEXP (op0, 1)))
1.1 root 2607: {
2608: temp = op0;
2609: op0 = op1;
2610: op1 = temp;
2611: }
2612: /* If adding to a sum including a constant,
2613: associate it to put the constant outside. */
2614: if (GET_CODE (op1) == PLUS
1.1.1.2 root 2615: && CONSTANT_P (XEXP (op1, 1)))
1.1 root 2616: {
1.1.1.16 root 2617: rtx tem;
2618: int constant_term = 0;
2619:
1.1 root 2620: op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
1.1.1.16 root 2621: /* Let's also eliminate constants from op0 if possible. */
2622: tem = eliminate_constant_term (op0, &constant_term);
1.1 root 2623: if (GET_CODE (XEXP (op1, 1)) == CONST_INT)
1.1.1.16 root 2624: {
2625: if (constant_term != 0)
2626: return plus_constant (tem, INTVAL (XEXP (op1, 1)) + constant_term);
2627: else
2628: return plus_constant (op0, INTVAL (XEXP (op1, 1)));
2629: }
1.1 root 2630: else
2631: return gen_rtx (PLUS, mode, op0, XEXP (op1, 1));
2632: }
2633: #endif
2634: return gen_rtx (PLUS, mode, op0, op1);
2635:
2636: case MINUS_EXPR:
2637: preexpand_calls (exp);
2638: if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
2639: {
1.1.1.10 root 2640: int negated;
1.1.1.2 root 2641: if (modifier == EXPAND_SUM)
2642: {
2643: negate_1 = -1;
2644: goto plus_minus;
2645: }
2646: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2647: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
1.1.1.10 root 2648: negated = - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1));
2649: if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_INT)
2650: negated &= (1 << GET_MODE_BITSIZE (mode)) - 1;
2651: op1 = gen_rtx (CONST_INT, VOIDmode, negated);
1.1.1.2 root 2652: this_optab = add_optab;
2653: goto binop2;
1.1 root 2654: }
2655: this_optab = sub_optab;
2656: goto binop;
2657:
2658: case MULT_EXPR:
2659: preexpand_calls (exp);
2660: /* If first operand is constant, swap them.
2661: Thus the following special case checks need only
2662: check the second operand. */
2663: if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
2664: {
2665: register tree t1 = TREE_OPERAND (exp, 0);
2666: TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
2667: TREE_OPERAND (exp, 1) = t1;
2668: }
2669:
2670: /* Attempt to return something suitable for generating an
2671: indexed address, for machines that support that. */
2672:
1.1.1.2 root 2673: if (modifier == EXPAND_SUM
1.1.1.6 root 2674: && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
1.1 root 2675: {
1.1.1.2 root 2676: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
2677:
2678: /* Apply distributive law if OP0 is x+c. */
2679: if (GET_CODE (op0) == PLUS
2680: && GET_CODE (XEXP (op0, 1)) == CONST_INT)
2681: return gen_rtx (PLUS, mode,
2682: gen_rtx (MULT, mode, XEXP (op0, 0),
2683: gen_rtx (CONST_INT, VOIDmode,
2684: TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
2685: gen_rtx (CONST_INT, VOIDmode,
2686: (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
2687: * INTVAL (XEXP (op0, 1)))));
2688:
1.1 root 2689: if (GET_CODE (op0) != REG)
1.1.1.2 root 2690: op0 = force_operand (op0, 0);
2691: if (GET_CODE (op0) != REG)
2692: op0 = copy_to_mode_reg (mode, op0);
2693:
1.1.1.6 root 2694: return gen_rtx (MULT, mode, op0,
1.1 root 2695: gen_rtx (CONST_INT, VOIDmode,
2696: TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
2697: }
2698: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2699: /* Check for multiplying things that have been extended
2700: from a narrower type. If this machine supports multiplying
2701: in that narrower type with a result in the desired type,
2702: do it that way, and avoid the explicit type-conversion. */
2703: if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
2704: && TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE
2705: && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
2706: < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
2707: && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
2708: && int_fits_type_p (TREE_OPERAND (exp, 1),
1.1.1.2 root 2709: TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
2710: /* Don't use a widening multiply if a shift will do. */
2711: && exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0)
1.1 root 2712: ||
2713: (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
2714: && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
2715: ==
1.1.1.2 root 2716: TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
2717: /* If both operands are extended, they must either both
2718: be zero-extended or both be sign-extended. */
2719: && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
2720: ==
2721: TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
1.1 root 2722: {
2723: enum machine_mode innermode
2724: = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
1.1.1.2 root 2725: this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
1.1 root 2726: ? umul_widen_optab : smul_widen_optab);
1.1.1.17! root 2727: if (mode == GET_MODE_WIDER_MODE (innermode)
1.1.1.2 root 2728: && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
1.1 root 2729: {
2730: op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
2731: 0, VOIDmode, 0);
2732: if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
2733: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2734: else
2735: op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
2736: 0, VOIDmode, 0);
2737: goto binop2;
2738: }
2739: }
2740: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2741: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
1.1.1.2 root 2742: return expand_mult (mode, op0, op1, target, TREE_UNSIGNED (type));
1.1 root 2743:
2744: case TRUNC_DIV_EXPR:
2745: case FLOOR_DIV_EXPR:
2746: case CEIL_DIV_EXPR:
2747: case ROUND_DIV_EXPR:
1.1.1.17! root 2748: case EXACT_DIV_EXPR:
1.1 root 2749: preexpand_calls (exp);
2750: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
1.1.1.2 root 2751: /* Possible optimization: compute the dividend with EXPAND_SUM
1.1 root 2752: then if the divisor is constant can optimize the case
2753: where some terms of the dividend have coeffs divisible by it. */
2754: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2755: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2756: return expand_divmod (0, code, mode, op0, op1, target,
1.1.1.2 root 2757: TREE_UNSIGNED (type));
1.1 root 2758:
2759: case RDIV_EXPR:
2760: preexpand_calls (exp);
2761: this_optab = flodiv_optab;
2762: goto binop;
2763:
2764: case TRUNC_MOD_EXPR:
2765: case FLOOR_MOD_EXPR:
2766: case CEIL_MOD_EXPR:
2767: case ROUND_MOD_EXPR:
2768: preexpand_calls (exp);
2769: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2770: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2771: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2772: return expand_divmod (1, code, mode, op0, op1, target,
1.1.1.2 root 2773: TREE_UNSIGNED (type));
1.1 root 2774: #if 0
2775: #ifdef HAVE_divmoddisi4
2776: if (GET_MODE (op0) != DImode)
2777: {
2778: temp = gen_reg_rtx (DImode);
2779: convert_move (temp, op0, 0);
2780: op0 = temp;
2781: if (GET_MODE (op1) != SImode && GET_CODE (op1) != CONST_INT)
2782: {
2783: temp = gen_reg_rtx (SImode);
2784: convert_move (temp, op1, 0);
2785: op1 = temp;
2786: }
2787: temp = gen_reg_rtx (SImode);
2788: if (target == 0)
2789: target = gen_reg_rtx (SImode);
2790: emit_insn (gen_divmoddisi4 (temp, protect_from_queue (op0, 0),
2791: protect_from_queue (op1, 0),
2792: protect_from_queue (target, 1)));
2793: return target;
2794: }
2795: #endif
2796: #endif
2797:
2798: case FIX_ROUND_EXPR:
2799: case FIX_FLOOR_EXPR:
2800: case FIX_CEIL_EXPR:
2801: abort (); /* Not used for C. */
2802:
2803: case FIX_TRUNC_EXPR:
2804: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
2805: if (target == 0)
2806: target = gen_reg_rtx (mode);
1.1.1.2 root 2807: {
2808: int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
2809: if (mode == HImode || mode == QImode)
2810: {
2811: register rtx temp = gen_reg_rtx (SImode);
1.1.1.6 root 2812: expand_fix (temp, op0, 0);
2813: convert_move (target, temp, 0);
1.1.1.2 root 2814: }
2815: else
2816: expand_fix (target, op0, unsignedp);
2817: }
1.1 root 2818: return target;
2819:
2820: case FLOAT_EXPR:
2821: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
2822: if (target == 0)
2823: target = gen_reg_rtx (mode);
1.1.1.2 root 2824: {
2825: int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
2826: if (GET_MODE (op0) == HImode
2827: || GET_MODE (op0) == QImode)
2828: {
2829: register rtx temp = gen_reg_rtx (SImode);
2830: convert_move (temp, op0, unsignedp);
2831: expand_float (target, temp, 0);
2832: }
2833: else
2834: expand_float (target, op0, unsignedp);
2835: }
1.1 root 2836: return target;
2837:
2838: case NEGATE_EXPR:
2839: op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
2840: temp = expand_unop (mode, neg_optab, op0, target, 0);
2841: if (temp == 0)
2842: abort ();
2843: return temp;
2844:
2845: case ABS_EXPR:
2846: /* First try to do it with a special abs instruction.
2847: If that does not win, use conditional jump and negate. */
1.1.1.2 root 2848: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
1.1 root 2849: temp = expand_unop (mode, abs_optab, op0, target, 0);
2850: if (temp != 0)
2851: return temp;
2852: temp = gen_label_rtx ();
2853: if (target == 0 || GET_CODE (target) != REG)
1.1.1.2 root 2854: target = gen_reg_rtx (mode);
1.1 root 2855: emit_move_insn (target, op0);
1.1.1.2 root 2856: emit_cmp_insn (target,
2857: expand_expr (convert (TREE_TYPE (exp), integer_zero_node),
2858: 0, VOIDmode, 0),
1.1.1.14 root 2859: 0, 0, 0);
1.1.1.6 root 2860: NO_DEFER_POP;
1.1 root 2861: emit_jump_insn (gen_bge (temp));
2862: op0 = expand_unop (mode, neg_optab, target, target, 0);
2863: if (op0 != target)
2864: emit_move_insn (target, op0);
2865: emit_label (temp);
1.1.1.6 root 2866: OK_DEFER_POP;
1.1 root 2867: return target;
2868:
2869: case MAX_EXPR:
2870: case MIN_EXPR:
1.1.1.8 root 2871: mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1)));
1.1 root 2872: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2873: if (target == 0 || GET_CODE (target) != REG || target == op1)
1.1.1.2 root 2874: target = gen_reg_rtx (mode);
1.1 root 2875: op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
2876: if (target != op0)
2877: emit_move_insn (target, op0);
2878: op0 = gen_label_rtx ();
2879: if (code == MAX_EXPR)
1.1.1.2 root 2880: temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
2881: ? compare1 (target, op1, GEU, LEU, 1, mode)
2882: : compare1 (target, op1, GE, LE, 0, mode));
2883: else
2884: temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
2885: ? compare1 (target, op1, LEU, GEU, 1, mode)
2886: : compare1 (target, op1, LE, GE, 0, mode));
2887: if (temp == const0_rtx)
2888: emit_move_insn (target, op1);
2889: else if (temp != const1_rtx)
2890: {
1.1.1.13 root 2891: if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
2892: emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
2893: else
2894: abort ();
1.1.1.2 root 2895: emit_move_insn (target, op1);
2896: }
2897: emit_label (op0);
1.1 root 2898: return target;
2899:
2900: /* ??? Can optimize when the operand of this is a bitwise operation,
2901: by using a different bitwise operation. */
2902: case BIT_NOT_EXPR:
2903: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2904: temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
2905: if (temp == 0)
2906: abort ();
2907: return temp;
2908:
1.1.1.2 root 2909: case FFS_EXPR:
2910: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2911: temp = expand_unop (mode, ffs_optab, op0, target, 1);
2912: if (temp == 0)
2913: abort ();
2914: return temp;
2915:
1.1 root 2916: /* ??? Can optimize bitwise operations with one arg constant.
2917: Pastel optimizes (a bitwise1 n) bitwise2 (a bitwise3 b)
2918: and (a bitwise1 b) bitwise2 b (etc)
2919: but that is probably not worth while. */
2920:
1.1.1.2 root 2921: /* BIT_AND_EXPR is for bitwise anding.
1.1 root 2922: TRUTH_AND_EXPR is for anding two boolean values
2923: when we want in all cases to compute both of them.
2924: In general it is fastest to do TRUTH_AND_EXPR by
2925: computing both operands as actual zero-or-1 values
2926: and then bitwise anding. In cases where there cannot
2927: be any side effects, better code would be made by
2928: treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR;
2929: but the question is how to recognize those cases. */
2930:
2931: case TRUTH_AND_EXPR:
2932: case BIT_AND_EXPR:
2933: preexpand_calls (exp);
2934: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2935: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2936: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2937: return expand_bit_and (mode, op0, op1, target);
2938:
2939: /* See comment above about TRUTH_AND_EXPR; it applies here too. */
2940: case TRUTH_OR_EXPR:
2941: case BIT_IOR_EXPR:
2942: preexpand_calls (exp);
2943: this_optab = ior_optab;
2944: goto binop;
2945:
2946: case BIT_XOR_EXPR:
2947: preexpand_calls (exp);
2948: this_optab = xor_optab;
2949: goto binop;
2950:
2951: case LSHIFT_EXPR:
2952: case RSHIFT_EXPR:
2953: case LROTATE_EXPR:
2954: case RROTATE_EXPR:
2955: preexpand_calls (exp);
2956: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2957: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2958: return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
1.1.1.2 root 2959: TREE_UNSIGNED (type));
1.1 root 2960:
2961: /* ??? cv's were used to effect here to combine additive constants
2962: and to determine the answer when only additive constants differ.
2963: Also, the addition of one can be handled by changing the condition. */
2964: case LT_EXPR:
2965: case LE_EXPR:
2966: case GT_EXPR:
2967: case GE_EXPR:
2968: case EQ_EXPR:
2969: case NE_EXPR:
2970: preexpand_calls (exp);
1.1.1.2 root 2971: temp = do_store_flag (exp, target, mode);
1.1 root 2972: if (temp != 0)
2973: return temp;
1.1.1.2 root 2974: /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
2975: if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
2976: && subtarget
2977: && (GET_MODE (subtarget)
2978: == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
1.1 root 2979: {
2980: temp = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2981: if (temp != subtarget)
2982: temp = copy_to_reg (temp);
2983: op1 = gen_label_rtx ();
1.1.1.14 root 2984: emit_cmp_insn (temp, const0_rtx, 0, TREE_UNSIGNED (type), 0);
1.1 root 2985: emit_jump_insn (gen_beq (op1));
2986: emit_move_insn (temp, const1_rtx);
2987: emit_label (op1);
2988: return temp;
2989: }
2990: /* If no set-flag instruction, must generate a conditional
2991: store into a temporary variable. Drop through
2992: and handle this like && and ||. */
2993:
2994: case TRUTH_ANDIF_EXPR:
2995: case TRUTH_ORIF_EXPR:
2996: temp = gen_reg_rtx (mode);
2997: emit_clr_insn (temp);
2998: op1 = gen_label_rtx ();
2999: jumpifnot (exp, op1);
3000: emit_0_to_1_insn (temp);
3001: emit_label (op1);
3002: return temp;
3003:
3004: case TRUTH_NOT_EXPR:
3005: op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
3006: /* The parser is careful to generate TRUTH_NOT_EXPR
3007: only with operands that are always zero or one. */
3008: temp = expand_binop (mode, xor_optab, op0,
3009: gen_rtx (CONST_INT, mode, 1),
3010: target, 1, OPTAB_LIB_WIDEN);
3011: if (temp == 0)
3012: abort ();
3013: return temp;
3014:
3015: case COMPOUND_EXPR:
1.1.1.2 root 3016: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
1.1 root 3017: emit_queue ();
3018: return expand_expr (TREE_OPERAND (exp, 1), target, VOIDmode, 0);
3019:
3020: case COND_EXPR:
3021: /* Note that COND_EXPRs whose type is a structure or union
3022: are required to be constructed to contain assignments of
3023: a temporary variable, so that we can evaluate them here
3024: for side effect only. If type is void, we must do likewise. */
3025: op0 = gen_label_rtx ();
3026: op1 = gen_label_rtx ();
3027:
1.1.1.2 root 3028: if (mode == VOIDmode || ignore)
1.1 root 3029: temp = 0;
3030: else if (target)
3031: temp = target;
1.1.1.2 root 3032: else if (mode == BLKmode)
3033: {
3034: if (TYPE_SIZE (type) == 0 || ! TREE_LITERAL (TYPE_SIZE (type)))
3035: abort ();
3036: temp = assign_stack_local (BLKmode,
3037: (TREE_INT_CST_LOW (TYPE_SIZE (type))
3038: * TYPE_SIZE_UNIT (type)
3039: + BITS_PER_UNIT - 1)
3040: / BITS_PER_UNIT);
3041: }
1.1 root 3042: else
3043: temp = gen_reg_rtx (mode);
3044:
3045: jumpifnot (TREE_OPERAND (exp, 0), op0);
1.1.1.6 root 3046: NO_DEFER_POP;
1.1 root 3047: if (temp != 0)
1.1.1.2 root 3048: store_expr (TREE_OPERAND (exp, 1), temp, 0);
1.1 root 3049: else
1.1.1.2 root 3050: expand_expr (TREE_OPERAND (exp, 1), ignore ? const0_rtx : 0,
3051: VOIDmode, 0);
1.1 root 3052: emit_queue ();
3053: emit_jump_insn (gen_jump (op1));
3054: emit_barrier ();
3055: emit_label (op0);
3056: if (temp != 0)
1.1.1.2 root 3057: store_expr (TREE_OPERAND (exp, 2), temp, 0);
1.1 root 3058: else
1.1.1.2 root 3059: expand_expr (TREE_OPERAND (exp, 2), ignore ? const0_rtx : 0,
3060: VOIDmode, 0);
1.1 root 3061: emit_queue ();
3062: emit_label (op1);
1.1.1.6 root 3063: OK_DEFER_POP;
1.1 root 3064: return temp;
3065:
3066: case MODIFY_EXPR:
1.1.1.7 root 3067: {
3068: /* If lhs is complex, expand calls in rhs before computing it.
3069: That's so we don't compute a pointer and save it over a call.
3070: If lhs is simple, compute it first so we can give it as a
3071: target if the rhs is just a call. This avoids an extra temp and copy
3072: and that prevents a partial-subsumption which makes bad code.
3073: Actually we could treat component_ref's of vars like vars. */
3074:
3075: tree lhs = TREE_OPERAND (exp, 0);
3076: tree rhs = TREE_OPERAND (exp, 1);
1.1.1.13 root 3077: tree noncopied_parts;
1.1.1.7 root 3078:
3079: if (TREE_CODE (lhs) != VAR_DECL
3080: && TREE_CODE (lhs) != RESULT_DECL
3081: && TREE_CODE (lhs) != PARM_DECL)
3082: preexpand_calls (exp);
3083:
1.1.1.13 root 3084: noncopied_parts = save_noncopied_parts (lhs, TYPE_NONCOPIED_PARTS (TREE_TYPE (lhs)));
3085: temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
3086: while (noncopied_parts != 0)
1.1.1.7 root 3087: {
1.1.1.13 root 3088: store_expr (TREE_VALUE (noncopied_parts),
3089: SAVE_EXPR_RTL (TREE_PURPOSE (noncopied_parts)), 0);
3090: noncopied_parts = TREE_CHAIN (noncopied_parts);
1.1.1.7 root 3091: }
1.1.1.13 root 3092: return temp;
3093: }
1.1 root 3094:
3095: case PREINCREMENT_EXPR:
3096: case PREDECREMENT_EXPR:
1.1.1.2 root 3097: return expand_increment (exp, 0);
1.1 root 3098:
3099: case POSTINCREMENT_EXPR:
3100: case POSTDECREMENT_EXPR:
1.1.1.2 root 3101: return expand_increment (exp, 1);
1.1 root 3102:
3103: case ADDR_EXPR:
1.1.1.2 root 3104: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode,
3105: EXPAND_CONST_ADDRESS);
1.1 root 3106: if (GET_CODE (op0) != MEM)
3107: abort ();
1.1.1.2 root 3108: if (modifier == EXPAND_SUM)
1.1 root 3109: return XEXP (op0, 0);
1.1.1.2 root 3110: op0 = force_operand (XEXP (op0, 0), target);
3111: if (flag_force_addr && GET_CODE (op0) != REG)
3112: return force_reg (Pmode, op0);
3113: return op0;
1.1 root 3114:
3115: case ENTRY_VALUE_EXPR:
3116: abort ();
3117:
3118: case ERROR_MARK:
1.1.1.2 root 3119: return const0_rtx;
1.1 root 3120:
3121: default:
3122: abort ();
3123: }
3124:
3125: /* Here to do an ordinary binary operator, generating an instruction
3126: from the optab already placed in `this_optab'. */
3127: binop:
3128: /* Detect things like x = y | (a == b)
3129: and do them as (x = y), (a == b ? x |= 1 : 0), x. */
3130: /* First, get the comparison or conditional into the second arg. */
3131: if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 0))]
3132: || (TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR
3133: && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
3134: || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 2)))))
3135: {
3136: if (this_optab == ior_optab || this_optab == add_optab
3137: || this_optab == xor_optab)
3138: {
3139: tree exch = TREE_OPERAND (exp, 1);
3140: TREE_OPERAND (exp, 1) = TREE_OPERAND (exp, 0);
3141: TREE_OPERAND (exp, 0) = exch;
3142: }
3143: }
1.1.1.3 root 3144: /* Optimize X + (Y ? Z : 0) by computing X and maybe adding Z. */
1.1 root 3145: if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 1))]
3146: || (TREE_CODE (TREE_OPERAND (exp, 1)) == COND_EXPR
3147: && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 1))
3148: || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))))
3149: {
3150: if (this_optab == ior_optab || this_optab == add_optab
3151: || this_optab == xor_optab || this_optab == sub_optab
3152: || this_optab == lshl_optab || this_optab == ashl_optab
3153: || this_optab == lshr_optab || this_optab == ashr_optab
3154: || this_optab == rotl_optab || this_optab == rotr_optab)
3155: {
1.1.1.2 root 3156: tree thenexp;
1.1 root 3157: rtx thenv = 0;
3158:
1.1.1.8 root 3159: /* TARGET gets a reg in which we can perform the computation.
3160: Use the specified target if it's a pseudo reg and safe. */
3161: target = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
1.1 root 3162: if (target == 0) target = gen_reg_rtx (mode);
1.1.1.3 root 3163:
3164: /* Compute X into the target. */
1.1.1.2 root 3165: store_expr (TREE_OPERAND (exp, 0), target, 0);
1.1 root 3166: op0 = gen_label_rtx ();
3167:
1.1.1.3 root 3168: /* If other operand is a comparison COMP, treat it as COMP ? 1 : 0 */
1.1 root 3169: if (TREE_CODE (TREE_OPERAND (exp, 1)) != COND_EXPR)
3170: {
3171: do_jump (TREE_OPERAND (exp, 1), op0, 0);
3172: thenv = const1_rtx;
3173: }
3174: else if (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))
3175: {
3176: do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), op0, 0);
3177: thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 1);
3178: }
3179: else
3180: {
3181: do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0, op0);
3182: thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 2);
3183: }
3184:
3185: if (thenv == 0)
3186: thenv = expand_expr (thenexp, 0, VOIDmode, 0);
3187:
1.1.1.3 root 3188: /* THENV is now Z, the value to operate on, as an rtx.
3189: We have already tested that Y isn't zero, so do the operation. */
3190:
1.1 root 3191: if (this_optab == rotl_optab || this_optab == rotr_optab)
3192: temp = expand_binop (mode, this_optab, target, thenv, target,
3193: -1, OPTAB_LIB);
3194: else if (this_optab == lshl_optab || this_optab == lshr_optab)
3195: temp = expand_binop (mode, this_optab, target, thenv, target,
3196: 1, OPTAB_LIB_WIDEN);
3197: else
3198: temp = expand_binop (mode, this_optab, target, thenv, target,
3199: 0, OPTAB_LIB_WIDEN);
3200: if (target != temp)
3201: emit_move_insn (target, temp);
3202:
1.1.1.17! root 3203: emit_queue ();
1.1.1.6 root 3204: do_pending_stack_adjust ();
1.1 root 3205: emit_label (op0);
3206: return target;
3207: }
3208: }
3209: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
3210: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
3211: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
3212: binop2:
3213: temp = expand_binop (mode, this_optab, op0, op1, target,
1.1.1.2 root 3214: TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
1.1 root 3215: if (temp == 0)
3216: abort ();
3217: return temp;
3218: }
3219:
1.1.1.2 root 3220: /* Expand an expression EXP that calls a built-in function,
3221: with result going to TARGET if that's convenient
3222: (and in mode MODE if that's convenient).
1.1.1.17! root 3223: SUBTARGET may be used as the target for computing one of EXP's operands.
! 3224: IGNORE is nonzero if the value is to be ignored. */
1.1.1.2 root 3225:
3226: static rtx
1.1.1.17! root 3227: expand_builtin (exp, target, subtarget, mode, ignore)
1.1.1.2 root 3228: tree exp;
3229: rtx target;
3230: rtx subtarget;
3231: enum machine_mode mode;
1.1.1.17! root 3232: int ignore;
1.1.1.2 root 3233: {
3234: tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
3235: tree arglist = TREE_OPERAND (exp, 1);
3236: rtx op0;
3237:
3238: switch (DECL_FUNCTION_CODE (fndecl))
3239: {
3240: case BUILT_IN_ABS:
3241: case BUILT_IN_LABS:
3242: case BUILT_IN_FABS:
3243: /* build_function_call changes these into ABS_EXPR. */
3244: abort ();
3245:
1.1.1.14 root 3246: case BUILT_IN_SAVEREGS:
3247: {
3248: /* When this function is called, it means that registers must be
3249: saved on entry to this function. So we migrate the
3250: call to the first insn of this function. */
3251: rtx last = get_last_insn ();
3252: /* Now really call the function. `expand_call' does not call
3253: expand_builtin, so there is no danger of infinite recursion here. */
1.1.1.17! root 3254: rtx temp = expand_call (exp, target, ignore);
! 3255: reorder_insns (NEXT_INSN (last), get_last_insn (), get_insns ());
! 3256: return temp;
1.1.1.14 root 3257: }
1.1.1.17! root 3258:
! 3259: case BUILT_IN_CLASSIFY_TYPE:
! 3260: if (arglist != 0)
! 3261: {
! 3262: tree type = TREE_TYPE (TREE_VALUE (arglist));
! 3263: enum tree_code code = TREE_CODE (type);
! 3264: if (code == VOID_TYPE)
! 3265: return gen_rtx (CONST_INT, VOIDmode, void_type_class);
! 3266: if (code == INTEGER_TYPE)
! 3267: return gen_rtx (CONST_INT, VOIDmode, integer_type_class);
! 3268: if (code == CHAR_TYPE)
! 3269: return gen_rtx (CONST_INT, VOIDmode, char_type_class);
! 3270: if (code == ENUMERAL_TYPE)
! 3271: return gen_rtx (CONST_INT, VOIDmode, enumeral_type_class);
! 3272: if (code == BOOLEAN_TYPE)
! 3273: return gen_rtx (CONST_INT, VOIDmode, boolean_type_class);
! 3274: if (code == POINTER_TYPE)
! 3275: return gen_rtx (CONST_INT, VOIDmode, pointer_type_class);
! 3276: if (code == REFERENCE_TYPE)
! 3277: return gen_rtx (CONST_INT, VOIDmode, reference_type_class);
! 3278: if (code == OFFSET_TYPE)
! 3279: return gen_rtx (CONST_INT, VOIDmode, offset_type_class);
! 3280: if (code == REAL_TYPE)
! 3281: return gen_rtx (CONST_INT, VOIDmode, real_type_class);
! 3282: if (code == COMPLEX_TYPE)
! 3283: return gen_rtx (CONST_INT, VOIDmode, complex_type_class);
! 3284: if (code == FUNCTION_TYPE)
! 3285: return gen_rtx (CONST_INT, VOIDmode, function_type_class);
! 3286: if (code == METHOD_TYPE)
! 3287: return gen_rtx (CONST_INT, VOIDmode, method_type_class);
! 3288: if (code == RECORD_TYPE)
! 3289: return gen_rtx (CONST_INT, VOIDmode, record_type_class);
! 3290: if (code == UNION_TYPE)
! 3291: return gen_rtx (CONST_INT, VOIDmode, union_type_class);
! 3292: if (code == ARRAY_TYPE)
! 3293: return gen_rtx (CONST_INT, VOIDmode, array_type_class);
! 3294: if (code == STRING_TYPE)
! 3295: return gen_rtx (CONST_INT, VOIDmode, string_type_class);
! 3296: if (code == SET_TYPE)
! 3297: return gen_rtx (CONST_INT, VOIDmode, set_type_class);
! 3298: if (code == FILE_TYPE)
! 3299: return gen_rtx (CONST_INT, VOIDmode, file_type_class);
! 3300: if (code == LANG_TYPE)
! 3301: return gen_rtx (CONST_INT, VOIDmode, lang_type_class);
! 3302: }
! 3303: return gen_rtx (CONST_INT, VOIDmode, no_type_class);
! 3304:
1.1.1.2 root 3305: case BUILT_IN_ALLOCA:
1.1.1.10 root 3306: if (arglist == 0
3307: /* Arg could be non-integer if user redeclared this fcn wrong. */
3308: || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
1.1.1.2 root 3309: return const0_rtx;
3310: frame_pointer_needed = 1;
1.1.1.17! root 3311: current_function_calls_alloca = 1;
1.1.1.2 root 3312: /* Compute the argument. */
3313: op0 = expand_expr (TREE_VALUE (arglist), 0, VOIDmode, 0);
3314: if (! CONSTANT_P (op0))
3315: {
3316: op0 = force_reg (GET_MODE (op0), op0);
3317: if (GET_MODE (op0) != Pmode)
1.1.1.12 root 3318: op0 = convert_to_mode (Pmode, op0, 1);
1.1.1.2 root 3319: }
3320: /* Push that much space (rounding it up). */
1.1.1.3 root 3321: do_pending_stack_adjust ();
1.1.1.8 root 3322:
3323: #ifdef STACK_POINTER_OFFSET
1.1.1.9 root 3324: /* If we will have to round the result down (which is up
3325: if stack grows down), make sure we have extra space so the
3326: user still gets at least as much space as he asked for. */
1.1.1.8 root 3327: if ((STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES
3328: != STACK_POINTER_OFFSET / STACK_BYTES)
3329: op0 = plus_constant (op0, STACK_BYTES);
3330: #endif
3331:
1.1.1.4 root 3332: #ifdef STACK_GROWS_DOWNWARD
1.1.1.2 root 3333: anti_adjust_stack (round_push (op0));
1.1.1.4 root 3334: #endif
1.1.1.2 root 3335: /* Return a copy of current stack ptr, in TARGET if possible. */
3336: if (target)
3337: emit_move_insn (target, stack_pointer_rtx);
3338: else
3339: target = copy_to_reg (stack_pointer_rtx);
1.1.1.4 root 3340: #ifdef STACK_POINTER_OFFSET
3341: /* If the contents of the stack pointer reg are offset from the
3342: actual top-of-stack address, add the offset here. */
1.1.1.6 root 3343: if (GET_CODE (target) == REG)
1.1.1.8 root 3344: emit_insn (gen_add2_insn (target,
3345: gen_rtx (CONST_INT, VOIDmode,
3346: (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES)));
1.1.1.6 root 3347: else
3348: {
3349: rtx temp =
3350: expand_binop (GET_MODE (target), add_optab, target,
1.1.1.8 root 3351: gen_rtx (CONST_INT, VOIDmode,
3352: (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES),
1.1.1.6 root 3353: target,
3354: 1, OPTAB_DIRECT);
3355: if (temp == 0) abort ();
3356: if (temp != target)
3357: emit_move_insn (target, temp);
3358: }
1.1.1.4 root 3359: #endif
3360: #ifndef STACK_GROWS_DOWNWARD
3361: anti_adjust_stack (round_push (op0));
3362: #endif
1.1.1.17! root 3363: /* Some systems require a particular insn to refer to the stack
! 3364: to make the pages exist. */
! 3365: #ifdef HAVE_probe
! 3366: if (HAVE_probe)
! 3367: emit_insn (gen_probe ());
! 3368: #endif
1.1.1.2 root 3369: return target;
3370:
3371: case BUILT_IN_FFS:
1.1.1.10 root 3372: if (arglist == 0
3373: /* Arg could be non-integer if user redeclared this fcn wrong. */
3374: || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
1.1.1.2 root 3375: return const0_rtx;
3376:
3377: /* Compute the argument. */
3378: op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
3379: /* Compute ffs, into TARGET if possible.
3380: Set TARGET to wherever the result comes back. */
3381: target = expand_unop (mode, ffs_optab, op0, target, 1);
3382: if (target == 0)
3383: abort ();
3384: return target;
3385:
3386: default:
3387: abort ();
3388: }
3389: }
3390:
3391: /* Expand code for a post- or pre- increment or decrement
3392: and return the RTX for the result.
3393: POST is 1 for postinc/decrements and 0 for preinc/decrements. */
3394:
3395: static rtx
3396: expand_increment (exp, post)
3397: register tree exp;
3398: int post;
3399: {
3400: register rtx op0, op1;
3401: register rtx temp;
3402: register tree incremented = TREE_OPERAND (exp, 0);
3403: optab this_optab = add_optab;
3404: int icode;
3405: enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
3406: int op0_is_copy = 0;
3407:
3408: /* Stabilize any component ref that might need to be
3409: evaluated more than once below. */
3410: if (TREE_CODE (incremented) == COMPONENT_REF
3411: && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
1.1.1.17! root 3412: || DECL_MODE (TREE_OPERAND (incremented, 1)) == BImode))
1.1.1.2 root 3413: incremented = stabilize_reference (incremented);
3414:
3415: /* Compute the operands as RTX.
3416: Note whether OP0 is the actual lvalue or a copy of it:
3417: I believe it is a copy iff it is a register and insns were
3418: generated in computing it. */
3419: temp = get_last_insn ();
3420: op0 = expand_expr (incremented, 0, VOIDmode, 0);
3421: if (temp != get_last_insn ())
3422: op0_is_copy = (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG);
3423: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
3424:
3425: /* Decide whether incrementing or decrementing. */
3426: if (TREE_CODE (exp) == POSTDECREMENT_EXPR
3427: || TREE_CODE (exp) == PREDECREMENT_EXPR)
3428: this_optab = sub_optab;
3429:
3430: /* If OP0 is not the actual lvalue, but rather a copy in a register,
3431: then we cannot just increment OP0. We must
3432: therefore contrive to increment the original value.
3433: Then we can return OP0 since it is a copy of the old value. */
3434: if (op0_is_copy)
3435: {
3436: /* This is the easiest way to increment the value wherever it is.
3437: Problems with multiple evaluation of INCREMENTED
3438: are prevented because either (1) it is a component_ref,
3439: in which case it was stabilized above, or (2) it is an array_ref
3440: with constant index in an array in a register, which is
3441: safe to reevaluate. */
3442: tree newexp = build ((this_optab == add_optab
3443: ? PLUS_EXPR : MINUS_EXPR),
3444: TREE_TYPE (exp),
3445: incremented,
3446: TREE_OPERAND (exp, 1));
3447: temp = expand_assignment (incremented, newexp, ! post, 0);
3448: return post ? op0 : temp;
3449: }
3450:
3451: /* Convert decrement by a constant into a negative increment. */
3452: if (this_optab == sub_optab
3453: && GET_CODE (op1) == CONST_INT)
3454: {
3455: op1 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op1));
3456: this_optab = add_optab;
3457: }
3458:
3459: if (post)
3460: {
3461: /* We have a true reference to the value in OP0.
3462: If there is an insn to add or subtract in this mode, queue it. */
3463:
3464: /* I'm not sure this is still necessary. */
3465: op0 = stabilize (op0);
3466:
3467: icode = (int) this_optab->handlers[(int) mode].insn_code;
3468: if (icode != (int) CODE_FOR_nothing
3469: /* Make sure that OP0 is valid for operands 0 and 1
3470: of the insn we want to queue. */
3471: && (*insn_operand_predicate[icode][0]) (op0, mode)
3472: && (*insn_operand_predicate[icode][1]) (op0, mode))
3473: {
3474: if (! (*insn_operand_predicate[icode][2]) (op1, mode))
3475: op1 = force_reg (mode, op1);
3476:
3477: return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
3478: }
3479: }
3480:
3481: /* Preincrement, or we can't increment with one simple insn. */
3482: if (post)
3483: /* Save a copy of the value before inc or dec, to return it later. */
3484: temp = copy_to_reg (op0);
3485: else
3486: /* Arrange to return the incremented value. */
3487: temp = op0;
3488:
3489: /* Increment however we can. */
3490: op1 = expand_binop (mode, this_optab, op0, op1, op0,
1.1.1.17! root 3491: TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
1.1.1.2 root 3492: /* Make sure the value is stored into OP0. */
3493: if (op1 != op0)
3494: emit_move_insn (op0, op1);
3495:
3496: return temp;
3497: }
3498:
1.1 root 3499: /* Expand all function calls contained within EXP, innermost ones first.
3500: But don't look within expressions that have sequence points.
3501: For each CALL_EXPR, record the rtx for its value
1.1.1.2 root 3502: in the CALL_EXPR_RTL field.
3503:
3504: Calls that return large structures for which a structure return
3505: stack slot is needed are not preexpanded. Preexpanding them loses
3506: because if more than one were preexpanded they would try to use the
3507: same stack slot. */
1.1 root 3508:
3509: static void
3510: preexpand_calls (exp)
3511: tree exp;
3512: {
3513: register int nops, i;
3514:
3515: if (! do_preexpand_calls)
3516: return;
3517:
1.1.1.2 root 3518: /* Only expressions and references can contain calls. */
3519:
3520: if (tree_code_type[(int) TREE_CODE (exp)][0] != 'e'
3521: && tree_code_type[(int) TREE_CODE (exp)][0] != 'r')
3522: return;
3523:
1.1 root 3524: switch (TREE_CODE (exp))
3525: {
3526: case CALL_EXPR:
1.1.1.2 root 3527: /* Do nothing to built-in functions. */
3528: if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
3529: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
1.1.1.5 root 3530: && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
3531: != NOT_BUILT_IN))
1.1.1.2 root 3532: return;
1.1.1.16 root 3533: /* Precompute calls that don't return values in memory. */
1.1.1.2 root 3534: if (CALL_EXPR_RTL (exp) == 0
1.1.1.16 root 3535: && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
3536: && ! RETURN_IN_MEMORY (TREE_TYPE (exp)))
1.1.1.2 root 3537: CALL_EXPR_RTL (exp) = expand_call (exp, 0, 0);
1.1 root 3538: return;
3539:
3540: case COMPOUND_EXPR:
3541: case COND_EXPR:
3542: case TRUTH_ANDIF_EXPR:
3543: case TRUTH_ORIF_EXPR:
3544: /* If we find one of these, then we can be sure
3545: the adjust will be done for it (since it makes jumps).
3546: Do it now, so that if this is inside an argument
3547: of a function, we don't get the stack adjustment
3548: after some other args have already been pushed. */
3549: do_pending_stack_adjust ();
3550: return;
3551:
1.1.1.2 root 3552: case RTL_EXPR:
3553: return;
3554:
1.1 root 3555: case SAVE_EXPR:
3556: if (SAVE_EXPR_RTL (exp) != 0)
3557: return;
3558: }
3559:
3560: nops = tree_code_length[(int) TREE_CODE (exp)];
3561: for (i = 0; i < nops; i++)
3562: if (TREE_OPERAND (exp, i) != 0)
3563: {
3564: register int type = *tree_code_type[(int) TREE_CODE (TREE_OPERAND (exp, i))];
3565: if (type == 'e' || type == 'r')
3566: preexpand_calls (TREE_OPERAND (exp, i));
3567: }
3568: }
3569:
1.1.1.2 root 3570: /* Force FUNEXP into a form suitable for the address of a CALL,
3571: and return that as an rtx. Also load the static chain register
3572: from either FUNEXP or CONTEXT. */
1.1 root 3573:
1.1.1.2 root 3574: static rtx
3575: prepare_call_address (funexp, context)
1.1 root 3576: rtx funexp;
3577: rtx context;
3578: {
3579: funexp = protect_from_queue (funexp, 0);
1.1.1.2 root 3580: if (context != 0)
1.1 root 3581: context = protect_from_queue (context, 0);
3582:
3583: /* Function variable in language with nested functions. */
3584: if (GET_MODE (funexp) == EPmode)
3585: {
1.1.1.2 root 3586: emit_move_insn (static_chain_rtx, gen_highpart (Pmode, funexp));
3587: funexp = memory_address (FUNCTION_MODE, gen_lowpart (Pmode, funexp));
3588: emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
1.1 root 3589: }
3590: else
3591: {
3592: if (context != 0)
1.1.1.2 root 3593: /* Unless function variable in C, or top level function constant */
3594: emit_move_insn (static_chain_rtx, lookup_static_chain (context));
3595:
3596: /* Make a valid memory address and copy constants thru pseudo-regs,
3597: but not for a constant address if -fno-function-cse. */
3598: if (GET_CODE (funexp) != SYMBOL_REF)
3599: funexp = memory_address (FUNCTION_MODE, funexp);
3600: else
1.1 root 3601: {
1.1.1.2 root 3602: #ifndef NO_FUNCTION_CSE
1.1.1.6 root 3603: if (optimize && ! flag_no_function_cse)
3604: funexp = force_reg (Pmode, funexp);
1.1.1.2 root 3605: #endif
3606: }
3607:
3608: if (context != 0)
3609: emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
1.1 root 3610: }
1.1.1.2 root 3611: return funexp;
3612: }
3613:
3614: /* Generate instructions to call function FUNEXP,
3615: and optionally pop the results.
3616: The CALL_INSN is the first insn generated.
3617:
3618: FUNTYPE is the data type of the function, or, for a library call,
3619: the identifier for the name of the call. This is given to the
3620: macro RETURN_POPS_ARGS to determine whether this function pops its own args.
3621:
1.1.1.6 root 3622: STACK_SIZE is the number of bytes of arguments on the stack,
1.1.1.2 root 3623: rounded up to STACK_BOUNDARY; zero if the size is variable.
3624: This is both to put into the call insn and
3625: to generate explicit popping code if necessary.
3626:
3627: NEXT_ARG_REG is the rtx that results from executing
3628: FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
3629: just after all the args have had their registers assigned.
3630: This could be whatever you like, but normally it is the first
3631: arg-register beyond those used for args in this call,
3632: or 0 if all the arg-registers are used in this call.
3633: It is passed on to `gen_call' so you can put this info in the call insn.
3634:
3635: VALREG is a hard register in which a value is returned,
3636: or 0 if the call does not return a value.
3637:
1.1.1.17! root 3638: OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
1.1.1.2 root 3639: the args to this call were processed.
1.1.1.17! root 3640: We restore `inhibit_defer_pop' to that value. */
1.1.1.2 root 3641:
3642: static void
1.1.1.17! root 3643: emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_inhibit_defer_pop)
1.1.1.2 root 3644: rtx funexp;
3645: tree funtype;
3646: int stack_size;
3647: rtx next_arg_reg;
3648: rtx valreg;
1.1.1.17! root 3649: int old_inhibit_defer_pop;
1.1.1.2 root 3650: {
3651: rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
3652:
3653: if (valreg)
3654: emit_call_insn (gen_call_value (valreg,
3655: gen_rtx (MEM, FUNCTION_MODE, funexp),
3656: stack_size_rtx, next_arg_reg));
3657: else
3658: emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
3659: stack_size_rtx, next_arg_reg));
3660:
1.1.1.17! root 3661: inhibit_defer_pop = old_inhibit_defer_pop;
1.1.1.2 root 3662:
1.1 root 3663: /* If returning from the subroutine does not automatically pop the args,
3664: we need an instruction to pop them sooner or later.
3665: Perhaps do it now; perhaps just record how much space to pop later. */
1.1.1.2 root 3666:
3667: if (! RETURN_POPS_ARGS (TREE_TYPE (funtype))
3668: && stack_size != 0)
1.1 root 3669: {
1.1.1.17! root 3670: if (flag_defer_pop && inhibit_defer_pop == 0)
1.1.1.2 root 3671: pending_stack_adjust += stack_size;
1.1 root 3672: else
1.1.1.3 root 3673: adjust_stack (stack_size_rtx);
1.1 root 3674: }
3675: }
3676:
3677: /* At the start of a function, record that we have no previously-pushed
3678: arguments waiting to be popped. */
3679:
1.1.1.2 root 3680: void
3681: init_pending_stack_adjust ()
1.1 root 3682: {
3683: pending_stack_adjust = 0;
3684: }
3685:
1.1.1.2 root 3686: /* When exiting from function, if safe, clear out any pending stack adjust
3687: so the adjustment won't get done. */
3688:
3689: void
3690: clear_pending_stack_adjust ()
3691: {
3692: #ifdef EXIT_IGNORE_STACK
1.1.1.4 root 3693: if (!flag_omit_frame_pointer && EXIT_IGNORE_STACK
1.1.1.10 root 3694: && ! TREE_INLINE (current_function_decl)
3695: && ! flag_inline_functions)
1.1.1.2 root 3696: pending_stack_adjust = 0;
3697: #endif
3698: }
3699:
1.1 root 3700: /* Pop any previously-pushed arguments that have not been popped yet. */
3701:
1.1.1.2 root 3702: void
1.1 root 3703: do_pending_stack_adjust ()
3704: {
1.1.1.17! root 3705: if (inhibit_defer_pop == 0)
1.1 root 3706: {
3707: if (pending_stack_adjust != 0)
3708: adjust_stack (gen_rtx (CONST_INT, VOIDmode, pending_stack_adjust));
3709: pending_stack_adjust = 0;
3710: }
3711: }
3712:
1.1.1.17! root 3713: /* Data structure and subroutines used within expand_call. */
1.1 root 3714:
1.1.1.9 root 3715: struct arg_data
3716: {
3717: /* Tree node for this argument. */
3718: tree tree_value;
3719: /* Precomputed RTL value, or 0 if it isn't precomputed. */
3720: rtx value;
3721: /* Register to pass this argument in, or 0 if passed on stack. */
3722: rtx reg;
3723: /* Number of registers to use. 0 means put the whole arg in registers.
3724: Also 0 if not passed in registers. */
3725: int partial;
3726: /* Offset of this argument from beginning of stack-args. */
3727: struct args_size offset;
3728: /* Size of this argument on the stack, rounded up for any padding it gets,
3729: parts of the argument passed in registers do not count.
3730: If the FIRST_PARM_CALLER_OFFSET is negative, then register parms
3731: are counted here as well. */
3732: struct args_size size;
3733: /* Nonzero if this arg has already been stored. */
3734: int stored;
3735: /* const0_rtx means should preallocate stack space for this arg.
3736: Other non0 value is the stack slot, preallocated.
3737: Used only for BLKmode. */
3738: rtx stack;
3739: };
3740:
1.1.1.17! root 3741: static void store_one_arg ();
! 3742: static rtx target_for_arg ();
! 3743:
! 3744: /* Generate all the code for a function call
! 3745: and return an rtx for its value.
! 3746: Store the value in TARGET (specified as an rtx) if convenient.
! 3747: If the value is stored in TARGET then TARGET is returned.
! 3748: If IGNORE is nonzero, then we ignore the value of the function call. */
! 3749:
1.1 root 3750: static rtx
1.1.1.2 root 3751: expand_call (exp, target, ignore)
1.1 root 3752: tree exp;
3753: rtx target;
1.1.1.2 root 3754: int ignore;
1.1 root 3755: {
1.1.1.8 root 3756: /* List of actual parameters. */
1.1 root 3757: tree actparms = TREE_OPERAND (exp, 1);
1.1.1.8 root 3758: /* RTX for the function to be called. */
1.1.1.2 root 3759: rtx funexp;
1.1.1.8 root 3760: /* Data type of the function. */
3761: tree funtype;
3762: /* Declaration of the function being called,
3763: or 0 if the function is computed (not known by name). */
3764: tree fndecl = 0;
3765:
3766: /* Register in which non-BLKmode value will be returned,
3767: or 0 if no value or if value is BLKmode. */
3768: rtx valreg;
3769: /* Address where we should return a BLKmode value;
3770: 0 if value not BLKmode. */
3771: rtx structure_value_addr = 0;
3772: /* Nonzero if that address is being passed by treating it as
3773: an extra, implicit first parameter. Otherwise,
3774: it is passed by being copied directly into struct_value_rtx. */
3775: int structure_value_addr_parm = 0;
1.1.1.15 root 3776: /* Nonzero if called function returns an aggregate in memory PCC style,
3777: by returning the address of where to find it. */
3778: int pcc_struct_value = 0;
1.1.1.8 root 3779:
3780: /* Number of actual parameters in this call, including struct value addr. */
3781: int num_actuals;
3782: /* Number of named args. Args after this are anonymous ones
3783: and they must all go on the stack. */
3784: int n_named_args;
3785:
1.1.1.9 root 3786: /* Vector of information about each argument.
3787: Arguments are numbered in the order they will be pushed,
1.1.1.8 root 3788: not the order they are written. */
1.1.1.9 root 3789: struct arg_data *args;
1.1.1.8 root 3790:
3791: /* Total size in bytes of all the stack-parms scanned so far. */
3792: struct args_size args_size;
1.1.1.9 root 3793: /* Remember initial value of args_size.constant. */
3794: int starting_args_size;
3795: /* Nonzero means count reg-parms' size in ARGS_SIZE. */
3796: int stack_count_regparms = 0;
1.1.1.8 root 3797: /* Data on reg parms scanned so far. */
3798: CUMULATIVE_ARGS args_so_far;
3799: /* Nonzero if a reg parm has been scanned. */
1.1.1.9 root 3800: int reg_parm_seen;
3801: /* Nonzero if we must avoid push-insns in the args for this call. */
3802: int must_preallocate;
1.1.1.8 root 3803: /* 1 if scanning parms front to back, -1 if scanning back to front. */
1.1.1.2 root 3804: int inc;
1.1.1.8 root 3805: /* Address of space preallocated for stack parms
3806: (on machines that lack push insns), or 0 if space not preallocated. */
3807: rtx argblock = 0;
3808:
3809: /* Nonzero if it is plausible that this is a call to alloca. */
3810: int may_be_alloca;
3811: /* Nonzero if this is a call to setjmp or a related function. */
1.1.1.2 root 3812: int is_setjmp;
1.1.1.8 root 3813: /* Nonzero if this is a call to an inline function. */
1.1.1.2 root 3814: int is_integrable = 0;
1.1.1.8 root 3815: /* Nonzero if this is a call to __builtin_new. */
3816: int is_builtin_new;
1.1.1.14 root 3817: /* Nonzero if this is a call to a `const' function. */
3818: int is_const = 0;
1.1.1.8 root 3819:
1.1.1.9 root 3820: /* Nonzero if there are BLKmode args whose data types require them
3821: to be passed in memory, not (even partially) in registers. */
3822: int BLKmode_parms_forced = 0;
3823: /* The offset of the first BLKmode parameter which
3824: *must* be passed in memory. */
3825: int BLKmode_parms_first_offset = 0;
3826: /* Total size of BLKmode parms which could usefully be preallocated. */
3827: int BLKmode_parms_sizes = 0;
3828:
3829: /* Amount stack was adjusted to protect BLKmode parameters
3830: which are below the nominal "stack address" value. */
3831: rtx protected_stack = 0;
3832:
1.1.1.14 root 3833: /* The last insn before the things that are intrinsically part of the call.
3834: The beginning reg-note goes on the insn after this one. */
3835: rtx insn_before;
3836:
1.1.1.9 root 3837: rtx old_stack_level = 0;
1.1.1.2 root 3838: int old_pending_adj;
1.1.1.17! root 3839: int old_inhibit_defer_pop = inhibit_defer_pop;
1.1.1.8 root 3840: tree old_cleanups = cleanups_of_this_call;
1.1.1.2 root 3841:
1.1.1.8 root 3842: register tree p;
3843: register int i;
1.1.1.2 root 3844:
3845: /* See if we can find a DECL-node for the actual function.
3846: As a result, decide whether this is a call to an integrable function. */
3847:
1.1.1.8 root 3848: p = TREE_OPERAND (exp, 0);
1.1.1.2 root 3849: if (TREE_CODE (p) == ADDR_EXPR)
3850: {
3851: fndecl = TREE_OPERAND (p, 0);
3852: if (TREE_CODE (fndecl) != FUNCTION_DECL)
3853: fndecl = 0;
3854: else
3855: {
3856: extern tree current_function_decl;
1.1 root 3857:
1.1.1.2 root 3858: if (fndecl != current_function_decl
3859: && DECL_SAVED_INSNS (fndecl))
3860: is_integrable = 1;
3861: else
1.1.1.4 root 3862: {
3863: /* In case this function later becomes inlineable,
3864: record that there was already a non-inline call to it. */
1.1.1.17! root 3865: mark_addressable (fndecl);
1.1.1.4 root 3866: }
1.1.1.14 root 3867:
3868: if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl))
3869: is_const = 1;
1.1.1.2 root 3870: }
3871: }
1.1 root 3872:
1.1.1.17! root 3873: /* When calling a const function, we must pop the stack args right away,
! 3874: so that the pop is deleted or moved with the call. */
! 3875: if (is_const)
! 3876: NO_DEFER_POP;
! 3877:
1.1.1.2 root 3878: /* Set up a place to return a structure. */
1.1 root 3879:
1.1.1.17! root 3880: /* Cater to broken compilers. */
! 3881: if (aggregate_value_p (exp))
1.1 root 3882: {
3883: /* This call returns a big structure. */
1.1.1.15 root 3884: #ifdef PCC_STATIC_STRUCT_RETURN
3885: if (flag_pcc_struct_return)
1.1.1.9 root 3886: {
1.1.1.15 root 3887: pcc_struct_value = 1;
3888: is_integrable = 0; /* Easier than making that case work right. */
1.1.1.9 root 3889: }
1.1 root 3890: else
1.1.1.15 root 3891: #endif
3892: {
1.1.1.16 root 3893: if (target && GET_CODE (target) == MEM)
1.1.1.15 root 3894: {
3895: structure_value_addr = XEXP (target, 0);
3896: if (reg_mentioned_p (stack_pointer_rtx, structure_value_addr))
3897: structure_value_addr = copy_to_reg (structure_value_addr);
3898: }
3899: else
1.1.1.17! root 3900: {
! 3901: /* Make room on the stack to hold the value. */
! 3902: structure_value_addr
! 3903: = get_structure_value_addr (expr_size (exp));
! 3904: target = 0;
! 3905: }
1.1.1.15 root 3906: }
1.1 root 3907: }
3908:
1.1.1.15 root 3909: /* If called function is inline, try to integrate it. */
3910:
1.1.1.2 root 3911: if (is_integrable)
3912: {
3913: extern rtx expand_inline_function ();
3914: rtx temp;
3915:
3916: temp = expand_inline_function (fndecl, actparms, target,
3917: ignore, TREE_TYPE (exp),
3918: structure_value_addr);
3919:
1.1.1.8 root 3920: /* If inlining succeeded, return. */
3921: if ((int) temp != -1)
1.1.1.2 root 3922: return temp;
1.1.1.8 root 3923:
3924: /* If inlining failed, mark FNDECL as needing to be compiled
3925: separately after all. */
3926: TREE_ADDRESSABLE (fndecl) = 1;
3927: TREE_ADDRESSABLE (DECL_NAME (fndecl)) = 1;
1.1.1.2 root 3928: }
3929:
3930: #if 0
3931: /* Unless it's a call to a specific function that isn't alloca,
3932: if it has one argument, we must assume it might be alloca. */
3933:
3934: may_be_alloca =
3935: (!(fndecl != 0
3936: && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
3937: "alloca"))
3938: && actparms != 0
3939: && TREE_CHAIN (actparms) == 0);
3940: #else
3941: /* We assume that alloca will always be called by name. It
3942: makes no sense to pass it as a pointer-to-function to
3943: anything that does not understand its behavior. */
3944: may_be_alloca =
1.1.1.9 root 3945: (fndecl && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "alloca")
3946: || ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
3947: "__builtin_alloca")));
1.1.1.2 root 3948: #endif
3949:
3950: /* See if this is a call to a function that can return more than once. */
3951:
3952: is_setjmp
3953: = (fndecl != 0
3954: && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "setjmp")
3955: || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "_setjmp")));
3956:
1.1.1.8 root 3957: is_builtin_new
3958: = (fndecl != 0
3959: && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "__builtin_new")));
3960:
1.1.1.2 root 3961: if (may_be_alloca)
3962: {
3963: frame_pointer_needed = 1;
3964: may_call_alloca = 1;
1.1.1.17! root 3965: current_function_calls_alloca = 1;
1.1.1.2 root 3966: }
3967:
3968: /* Don't let pending stack adjusts add up to too much.
3969: Also, do all pending adjustments now
3970: if there is any chance this might be a call to alloca. */
3971:
3972: if (pending_stack_adjust >= 32
3973: || (pending_stack_adjust > 0 && may_be_alloca))
3974: do_pending_stack_adjust ();
3975:
3976: /* Operand 0 is a pointer-to-function; get the type of the function. */
3977: funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
3978: if (TREE_CODE (funtype) != POINTER_TYPE)
3979: abort ();
3980: funtype = TREE_TYPE (funtype);
3981:
1.1.1.17! root 3982: /* If struct_value_rtx is 0, it means pass the address
! 3983: as if it were an extra parameter. */
! 3984: if (structure_value_addr && struct_value_rtx == 0)
1.1.1.8 root 3985: {
3986: rtx tem;
3987:
3988: INIT_CUMULATIVE_ARGS (args_so_far, funtype);
3989: tem = FUNCTION_ARG (args_so_far, Pmode,
3990: build_pointer_type (TREE_TYPE (funtype)), 1);
1.1.1.16 root 3991: if (tem == 0)
1.1.1.8 root 3992: {
3993: actparms = tree_cons (error_mark_node,
3994: build (SAVE_EXPR,
3995: type_for_size (GET_MODE_BITSIZE (Pmode), 0),
3996: 0,
3997: force_reg (Pmode, structure_value_addr)),
3998: actparms);
3999: structure_value_addr_parm = 1;
4000: }
4001: }
1.1.1.6 root 4002:
1.1.1.2 root 4003: /* Count the arguments and set NUM_ACTUALS. */
1.1 root 4004: for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
4005: num_actuals = i;
1.1.1.2 root 4006:
4007: /* Compute number of named args.
1.1.1.17! root 4008: Don't include the last named arg if anonymous args follow.
! 4009: (If no anonymous args follow, the result of list_length
! 4010: is actually one too large.) */
1.1.1.2 root 4011: if (TYPE_ARG_TYPES (funtype) != 0)
1.1.1.17! root 4012: n_named_args = list_length (TYPE_ARG_TYPES (funtype)) - 1;
1.1.1.2 root 4013: else
4014: /* If we know nothing, treat all args as named. */
4015: n_named_args = num_actuals;
4016:
1.1.1.9 root 4017: /* Make a vector to hold all the information about each arg. */
4018: args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
4019: bzero (args, num_actuals * sizeof (struct arg_data));
4020:
4021: args_size.constant = 0;
4022: args_size.var = 0;
4023: #ifdef FIRST_PARM_CALLER_OFFSET
1.1.1.17! root 4024: args_size.constant = FIRST_PARM_CALLER_OFFSET (funtype);
1.1.1.9 root 4025: stack_count_regparms = 1;
4026: #endif
4027: starting_args_size = args_size.constant;
1.1.1.2 root 4028:
4029: /* In this loop, we consider args in the order they are written.
1.1.1.9 root 4030: We fill up ARGS from the front of from the back if necessary
4031: so that in any case the first arg to be pushed ends up at the front. */
1.1 root 4032:
1.1.1.2 root 4033: #ifdef PUSH_ARGS_REVERSED
4034: i = num_actuals - 1, inc = -1;
1.1 root 4035: /* In this case, must reverse order of args
1.1.1.2 root 4036: so that we compute and push the last arg first. */
1.1 root 4037: #else
1.1.1.2 root 4038: i = 0, inc = 1;
4039: #endif
4040:
4041: INIT_CUMULATIVE_ARGS (args_so_far, funtype);
4042:
4043: for (p = actparms; p; p = TREE_CHAIN (p), i += inc)
4044: {
4045: tree type = TREE_TYPE (TREE_VALUE (p));
1.1.1.9 root 4046: args[i].tree_value = TREE_VALUE (p);
4047: args[i].offset = args_size;
1.1.1.2 root 4048:
1.1.1.15 root 4049: if (type == error_mark_node
4050: || TYPE_SIZE (type) == 0)
1.1.1.2 root 4051: continue;
4052:
4053: /* Decide where to pass this arg. */
1.1.1.9 root 4054: /* args[i].reg is nonzero if all or part is passed in registers.
4055: args[i].partial is nonzero if part but not all is passed in registers,
1.1.1.2 root 4056: and the exact value says how many words are passed in registers. */
4057:
4058: if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
1.1.1.6 root 4059: && args_size.var == 0
4060: /* error_mark_node here is a flag for the fake argument
4061: for a structure value address. */
4062: && TREE_PURPOSE (p) != error_mark_node)
1.1.1.2 root 4063: {
1.1.1.9 root 4064: args[i].reg = FUNCTION_ARG (args_so_far, TYPE_MODE (type), type,
4065: i < n_named_args);
1.1.1.16 root 4066: /* If this argument needs more than the usual parm alignment, do
4067: extrinsic padding to reach that alignment. */
4068:
4069: #ifdef MAX_PARM_BOUNDARY
4070: /* If MAX_PARM_BOUNDARY is not defined, it means that the usual
4071: alignment requirements are relaxed for parms, and that no parm
4072: needs more than PARM_BOUNDARY, regardless of data type. */
4073:
4074: if (PARM_BOUNDARY < TYPE_ALIGN (type))
4075: {
4076: int boundary = PARM_BOUNDARY;
4077:
4078: /* Determine the boundary to pad up to. */
4079: if (TYPE_ALIGN (type) > boundary)
4080: boundary = TYPE_ALIGN (type);
4081: if (boundary > MAX_PARM_BOUNDARY)
4082: boundary = MAX_PARM_BOUNDARY;
4083:
4084: /* If the previous args don't reach such a boundary,
4085: advance to the next one. */
1.1.1.17! root 4086: boundary /= BITS_PER_UNIT;
1.1.1.16 root 4087: args[i].offset.constant += boundary - 1;
1.1.1.17! root 4088: args[i].offset.constant &= ~(boundary - 1);
1.1.1.16 root 4089: args_size.constant += boundary - 1;
1.1.1.17! root 4090: args_size.constant &= ~(boundary - 1);
1.1.1.16 root 4091:
4092: if (args_size.var != 0)
4093: abort (); /* This case not implemented yet */
4094: }
4095: #endif /* MAX_PARM_BOUNDARY */
4096:
1.1.1.2 root 4097: #ifdef FUNCTION_ARG_PARTIAL_NREGS
1.1.1.9 root 4098: args[i].partial
4099: = FUNCTION_ARG_PARTIAL_NREGS (args_so_far,
4100: TYPE_MODE (type), type,
4101: i < n_named_args);
1.1.1.2 root 4102: #endif
4103: }
4104:
1.1.1.9 root 4105: /* Compute the stack-size of this argument. */
1.1.1.2 root 4106:
1.1.1.9 root 4107: if (args[i].reg != 0 && args[i].partial == 0
4108: && ! stack_count_regparms)
4109: /* On most machines, don't count stack space for a register arg. */
1.1.1.2 root 4110: ;
4111: else if (TYPE_MODE (type) != BLKmode)
4112: {
4113: register int size;
4114:
4115: size = GET_MODE_SIZE (TYPE_MODE (type));
4116: /* Compute how much space the push instruction will push.
4117: On many machines, pushing a byte will advance the stack
4118: pointer by a halfword. */
4119: #ifdef PUSH_ROUNDING
4120: size = PUSH_ROUNDING (size);
1.1 root 4121: #endif
1.1.1.2 root 4122: /* Compute how much space the argument should get:
1.1.1.6 root 4123: maybe pad to a multiple of the alignment for arguments. */
1.1.1.16 root 4124: if (none == FUNCTION_ARG_PADDING (TYPE_MODE (type), const0_rtx))
1.1.1.9 root 4125: args[i].size.constant = size;
1.1.1.6 root 4126: else
1.1.1.9 root 4127: args[i].size.constant
1.1.1.6 root 4128: = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
4129: / (PARM_BOUNDARY / BITS_PER_UNIT))
4130: * (PARM_BOUNDARY / BITS_PER_UNIT));
1.1.1.2 root 4131: }
4132: else
4133: {
4134: register tree size = size_in_bytes (type);
4135:
4136: /* A nonscalar. Round its size up to a multiple
1.1.1.9 root 4137: of PARM_BOUNDARY bits, unless it is not supposed to be padded. */
1.1.1.6 root 4138: if (none
4139: != FUNCTION_ARG_PADDING (TYPE_MODE (type),
4140: expand_expr (size, 0, VOIDmode, 0)))
4141: size = convert_units (convert_units (size, BITS_PER_UNIT,
4142: PARM_BOUNDARY),
4143: PARM_BOUNDARY, BITS_PER_UNIT);
1.1.1.9 root 4144: ADD_PARM_SIZE (args[i].size, size);
4145:
4146: /* Certain data types may not be passed in registers
4147: (eg C++ classes with constructors).
4148: Also, BLKmode parameters initialized from CALL_EXPRs
4149: are treated specially, if it is a win to do so. */
4150: if (TREE_CODE (TREE_VALUE (p)) == CALL_EXPR
1.1.1.13 root 4151: || TREE_ADDRESSABLE (type))
1.1.1.9 root 4152: {
1.1.1.13 root 4153: if (TREE_ADDRESSABLE (type))
1.1.1.9 root 4154: BLKmode_parms_forced = 1;
4155: /* This is a marker for such a parameter. */
4156: args[i].stack = const0_rtx;
4157: BLKmode_parms_sizes += TREE_INT_CST_LOW (size);
4158:
4159: /* If this parm's location is "below" the nominal stack pointer,
4160: note to decrement the stack pointer while it is computed. */
4161: #ifdef FIRST_PARM_CALLER_OFFSET
4162: if (BLKmode_parms_first_offset == 0)
4163: BLKmode_parms_first_offset
4164: /* If parameter's offset is variable, assume the worst. */
4165: = (args[i].offset.var
1.1.1.17! root 4166: ? FIRST_PARM_CALLER_OFFSET (funtype)
1.1.1.9 root 4167: : args[i].offset.constant);
4168: #endif
4169: }
1.1.1.2 root 4170: }
1.1.1.9 root 4171:
1.1.1.2 root 4172: /* If a part of the arg was put into registers,
4173: don't include that part in the amount pushed. */
1.1.1.9 root 4174: if (! stack_count_regparms)
4175: args[i].size.constant
4176: -= ((args[i].partial * UNITS_PER_WORD)
4177: / (PARM_BOUNDARY / BITS_PER_UNIT)
4178: * (PARM_BOUNDARY / BITS_PER_UNIT));
1.1.1.2 root 4179:
1.1.1.9 root 4180: /* Update ARGS_SIZE, the total stack space for args so far. */
1.1.1.2 root 4181:
1.1.1.9 root 4182: args_size.constant += args[i].size.constant;
4183: if (args[i].size.var)
1.1.1.2 root 4184: {
1.1.1.9 root 4185: ADD_PARM_SIZE (args_size, args[i].size.var);
1.1.1.2 root 4186: }
1.1.1.9 root 4187:
4188: /* Increment ARGS_SO_FAR, which has info about which arg-registers
4189: have been used, etc. */
4190:
4191: FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
4192: i < n_named_args);
1.1.1.2 root 4193: }
4194:
1.1.1.9 root 4195: /* If we would have to push a partially-in-regs parm
4196: before other stack parms, preallocate stack space instead. */
4197: must_preallocate = 0;
4198: {
4199: int partial_seen = 0;
4200: for (i = 0; i < num_actuals; i++)
4201: {
4202: if (args[i].partial > 0)
4203: partial_seen = 1;
4204: else if (partial_seen && args[i].reg == 0)
4205: must_preallocate = 1;
4206: }
4207: }
4208:
1.1.1.14 root 4209: /* Precompute all register parameters. It isn't safe to compute anything
4210: once we have started filling any specific hard regs.
4211: If this function call is cse'able, precompute all the parameters. */
4212:
4213: reg_parm_seen = 0;
4214: for (i = 0; i < num_actuals; i++)
4215: if (args[i].reg != 0 || is_const)
4216: {
1.1.1.15 root 4217: int j;
4218: int struct_value_lossage = 0;
4219:
4220: /* First, see if this is a precomputed struct-returning function call
4221: and other subsequent parms are also such. */
1.1.1.16 root 4222: if ((TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
4223: || RETURN_IN_MEMORY (TREE_TYPE (args[i].tree_value)))
1.1.1.15 root 4224: && TREE_CODE (args[i].tree_value) == CALL_EXPR)
4225: for (j = i + 1; j < num_actuals; j++)
1.1.1.16 root 4226: if ((TYPE_MODE (TREE_TYPE (args[j].tree_value)) == BLKmode
4227: || RETURN_IN_MEMORY (TREE_TYPE (args[j].tree_value)))
1.1.1.15 root 4228: && TREE_CODE (args[j].tree_value) == CALL_EXPR
4229: && args[j].reg != 0 || is_const)
4230: {
4231: /* We have two precomputed structure-values call expressions
4232: in our parm list. Both of them would normally use
4233: the structure-value block. To avoid the conflict,
4234: compute this parm with a different temporary block. */
4235: int size = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
4236: rtx structval = assign_stack_local (BLKmode, size);
4237: args[i].value = expand_expr (args[i].tree_value, structval,
4238: VOIDmode, 0);
4239: struct_value_lossage = 1;
4240: break;
4241: }
4242: if (!struct_value_lossage)
4243: args[i].value = expand_expr (args[i].tree_value, 0, VOIDmode, 0);
4244:
1.1.1.14 root 4245: if (args[i].reg != 0)
4246: reg_parm_seen = 1;
1.1.1.15 root 4247:
1.1.1.14 root 4248: if (GET_CODE (args[i].value) != MEM
4249: && ! CONSTANT_P (args[i].value)
4250: && GET_CODE (args[i].value) != CONST_DOUBLE)
4251: args[i].value
4252: = force_reg (TYPE_MODE (TREE_TYPE (args[i].tree_value)),
4253: args[i].value);
4254: /* ANSI doesn't require a sequence point here,
4255: but PCC has one, so this will avoid some problems. */
4256: emit_queue ();
4257: }
4258:
4259: /* Get the function to call, in the form of RTL, if it is a constant. */
4260: if (fndecl && is_const)
4261: {
4262: /* Get a SYMBOL_REF rtx for the function address. */
4263: funexp = XEXP (DECL_RTL (fndecl), 0);
4264:
4265: #ifndef NO_FUNCTION_CSE
4266: /* Pass the address through a pseudoreg, if desired,
4267: before the "beginning" of the library call.
4268: So this insn isn't "part of" the library call, in case that
4269: is deleted, or cse'd. */
4270: if (! flag_no_function_cse)
4271: funexp = copy_to_mode_reg (Pmode, funexp);
4272: #endif
4273: }
4274:
4275: /* Now we are about to start emitting insns that can be deleted
4276: if the libcall is deleted. */
4277: insn_before = get_last_insn ();
4278:
1.1.1.16 root 4279: /* Maybe do additional rounding on the size of the arguments. */
4280: #ifdef STACK_ARGS_ADJUST
4281: STACK_ARGS_ADJUST (args_size);
4282: #endif
4283:
1.1.1.9 root 4284: /* If we have no actual push instructions, or shouldn't use them,
4285: or we need a variable amount of space, make space for all args right now.
4286: Round the needed size up to multiple of STACK_BOUNDARY. */
1.1.1.2 root 4287:
4288: if (args_size.var != 0)
4289: {
4290: old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx);
4291: old_pending_adj = pending_stack_adjust;
4292: argblock = push_block (round_push (ARGS_SIZE_RTX (args_size)));
4293: }
1.1.1.9 root 4294: else if (args_size.constant > 0)
1.1.1.2 root 4295: {
4296: int needed = args_size.constant;
4297:
4298: #ifdef STACK_BOUNDARY
4299: needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
4300: #endif
1.1.1.15 root 4301: args_size.constant = needed;
1.1.1.2 root 4302:
1.1.1.9 root 4303: if (
1.1.1.2 root 4304: #ifndef PUSH_ROUNDING
1.1.1.9 root 4305: 1 /* Always preallocate if no push insns. */
4306: #else
4307: must_preallocate || BLKmode_parms_forced
4308: || BLKmode_parms_sizes > (args_size.constant >> 1)
4309: #endif
4310: )
1.1.1.2 root 4311: {
1.1.1.9 root 4312: /* Try to reuse some or all of the pending_stack_adjust
4313: to get this space. Maybe we can avoid any pushing. */
4314: if (needed > pending_stack_adjust)
4315: {
4316: needed -= pending_stack_adjust;
4317: pending_stack_adjust = 0;
4318: }
4319: else
4320: {
4321: pending_stack_adjust -= needed;
4322: needed = 0;
4323: }
4324: argblock = push_block (gen_rtx (CONST_INT, VOIDmode, needed));
1.1.1.2 root 4325: }
4326: }
1.1.1.13 root 4327: #ifndef PUSH_ROUNDING
4328: else if (BLKmode_parms_forced)
4329: {
4330: /* If we have reg-parms that need to be temporarily on the stack,
4331: set up an arg block address even though there is no space
4332: to be allocated for it. */
4333: argblock = push_block (const0_rtx);
4334: }
4335: #endif
1.1.1.2 root 4336:
1.1.1.16 root 4337: #if 0
1.1.1.15 root 4338: /* If stack needs padding below the args, increase all arg offsets
4339: so the args are stored above the padding. */
4340: if (stack_padding)
4341: for (i = 0; i < num_actuals; i++)
4342: args[i].offset.constant += stack_padding;
4343: #endif
4344:
1.1.1.9 root 4345: /* Don't try to defer pops if preallocating, not even from the first arg,
4346: since ARGBLOCK probably refers to the SP. */
4347: if (argblock)
4348: NO_DEFER_POP;
4349:
4350: #ifdef STACK_GROWS_DOWNWARD
4351: /* If any BLKmode parms need to be preallocated in space
4352: below the nominal stack-pointer address, we need to adjust the
4353: stack pointer so that this location is temporarily above it.
4354: This ensures that computation won't clobber that space. */
4355: if (BLKmode_parms_first_offset < 0 && argblock != 0)
4356: {
4357: int needed = -BLKmode_parms_first_offset;
4358: argblock = copy_to_reg (argblock);
4359:
4360: #ifdef STACK_BOUNDARY
4361: needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
4362: #endif
4363: protected_stack = gen_rtx (CONST_INT, VOIDmode, needed);
4364: anti_adjust_stack (protected_stack);
4365: }
4366: #endif /* STACK_GROWS_DOWNWARD */
4367:
1.1.1.2 root 4368: /* Get the function to call, in the form of RTL. */
4369: if (fndecl)
4370: /* Get a SYMBOL_REF rtx for the function address. */
4371: funexp = XEXP (DECL_RTL (fndecl), 0);
4372: else
4373: /* Generate an rtx (probably a pseudo-register) for the address. */
1.1.1.4 root 4374: {
4375: funexp = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
4376: emit_queue ();
4377: }
1.1.1.2 root 4378:
1.1.1.9 root 4379: /* Now compute and store all non-register parms.
4380: These come before register parms, since they can require block-moves,
4381: which could clobber the registers used for register parms.
4382: Parms which have partial registers are not stored here,
4383: but we do preallocate space here if they want that. */
1.1.1.2 root 4384:
1.1 root 4385: for (i = 0; i < num_actuals; i++)
4386: {
1.1.1.9 root 4387: /* Preallocate the stack space for a parm if appropriate
4388: so it can be computed directly in the stack space. */
4389: if (args[i].stack != 0 && argblock != 0)
4390: args[i].stack = target_for_arg (TREE_TYPE (args[i].tree_value),
4391: ARGS_SIZE_RTX (args[i].size),
4392: argblock, args[i].offset);
1.1 root 4393: else
1.1.1.9 root 4394: args[i].stack = 0;
1.1 root 4395:
1.1.1.15 root 4396: if (args[i].reg == 0
4397: && TYPE_SIZE (TREE_TYPE (args[i].tree_value)) != 0)
1.1.1.9 root 4398: store_one_arg (&args[i], argblock, may_be_alloca);
4399: }
1.1 root 4400:
1.1.1.9 root 4401: /* Now store any partially-in-registers parm.
4402: This is the last place a block-move can happen. */
4403: if (reg_parm_seen)
4404: for (i = 0; i < num_actuals; i++)
4405: if (args[i].partial != 0)
4406: store_one_arg (&args[i], argblock, may_be_alloca);
1.1 root 4407:
1.1.1.9 root 4408: if (protected_stack != 0)
4409: adjust_stack (protected_stack);
1.1 root 4410:
1.1.1.9 root 4411: /* Pass the function the address in which to return a structure value. */
4412: if (structure_value_addr && ! structure_value_addr_parm)
1.1.1.17! root 4413: emit_move_insn (struct_value_rtx,
! 4414: force_reg (Pmode, force_operand (structure_value_addr, 0)));
1.1 root 4415:
1.1.1.9 root 4416: /* Now set up any wholly-register parms. They were computed already. */
4417: if (reg_parm_seen)
4418: for (i = 0; i < num_actuals; i++)
4419: if (args[i].reg != 0 && args[i].partial == 0)
4420: store_one_arg (&args[i], argblock, may_be_alloca);
1.1 root 4421:
4422: /* Perform postincrements before actually calling the function. */
4423: emit_queue ();
4424:
1.1.1.2 root 4425: /* All arguments and registers used for the call must be set up by now! */
1.1 root 4426:
1.1.1.2 root 4427: /* ??? Other languages need a nontrivial second argument (static chain). */
4428: funexp = prepare_call_address (funexp, 0);
4429:
4430: /* Mark all register-parms as living through the call.
4431: ??? This is not quite correct, since it doesn't indicate
4432: that they are in use immediately before the call insn.
4433: Currently that doesn't matter since explicitly-used regs
4434: won't be used for reloading. But if the reloader becomes smarter,
4435: this will have to change somehow. */
4436: for (i = 0; i < num_actuals; i++)
1.1.1.9 root 4437: if (args[i].reg != 0)
1.1.1.2 root 4438: {
1.1.1.9 root 4439: if (args[i].partial > 0)
4440: use_regs (REGNO (args[i].reg), args[i].partial);
4441: else if (GET_MODE (args[i].reg) == BLKmode)
4442: use_regs (REGNO (args[i].reg),
1.1.1.10 root 4443: (int_size_in_bytes (TREE_TYPE (args[i].tree_value))
1.1.1.2 root 4444: / UNITS_PER_WORD));
4445: else
1.1.1.9 root 4446: emit_insn (gen_rtx (USE, VOIDmode, args[i].reg));
1.1.1.2 root 4447: }
4448:
1.1.1.17! root 4449: if (structure_value_addr && ! structure_value_addr_parm
! 4450: && GET_CODE (struct_value_rtx) == REG)
1.1.1.2 root 4451: emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx));
4452:
4453: /* Figure out the register where the value, if any, will come back. */
4454: valreg = 0;
4455: if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
4456: && TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
4457: valreg = hard_function_value (TREE_TYPE (exp), fndecl);
4458:
4459: /* Generate the actual call instruction. */
1.1.1.9 root 4460: if (args_size.constant < 0)
4461: args_size.constant = 0;
1.1.1.2 root 4462: emit_call_1 (funexp, funtype, args_size.constant,
4463: FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1.1.1.17! root 4464: valreg, old_inhibit_defer_pop);
1.1 root 4465:
4466: /* ??? Nothing has been done here to record control flow
4467: when contained functions can do nonlocal gotos. */
4468:
1.1.1.2 root 4469: /* For calls to `setjmp', etc., inform flow.c it should complain
4470: if nonvolatile values are live. */
4471:
4472: if (is_setjmp)
1.1.1.11 root 4473: {
4474: emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_SETJMP);
4475: current_function_calls_setjmp = 1;
4476: }
1.1.1.2 root 4477:
1.1.1.14 root 4478: /* Notice functions that cannot return.
4479: If optimizing, insns emitted below will be dead.
4480: If not optimizing, they will exist, which is useful
4481: if the user uses the `return' command in the debugger. */
4482:
4483: if (fndecl && TREE_THIS_VOLATILE (fndecl))
4484: emit_barrier ();
4485:
1.1.1.8 root 4486: /* For calls to __builtin_new, note that it can never return 0.
4487: This is because a new handler will be called, and 0 it not
4488: among the numbers it is supposed to return. */
4489: #if 0
4490: if (is_builtin_new)
4491: emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_BUILTIN_NEW);
4492: #endif
1.1.1.2 root 4493:
1.1 root 4494: /* If value type not void, return an rtx for the value. */
4495:
1.1.1.13 root 4496: /* If there are cleanups to be called, don't use a hard reg as target. */
4497: if (cleanups_of_this_call != old_cleanups
4498: && target && REG_P (target)
4499: && REGNO (target) < FIRST_PSEUDO_REGISTER)
4500: target = 0;
4501:
1.1.1.2 root 4502: if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
4503: || ignore)
1.1 root 4504: {
1.1.1.14 root 4505: target = const0_rtx;
1.1 root 4506: }
1.1.1.8 root 4507: else if (structure_value_addr)
4508: {
1.1.1.16 root 4509: if (target == 0 || GET_CODE (target) != MEM)
4510: target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1.1.1.8 root 4511: memory_address (BLKmode, structure_value_addr));
4512: }
1.1.1.15 root 4513: else if (pcc_struct_value)
4514: {
1.1.1.16 root 4515: valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
4516: fndecl);
4517: if (target == 0)
4518: target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
4519: copy_to_reg (valreg));
1.1.1.15 root 4520: else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
4521: emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
4522: copy_to_reg (valreg)));
4523: else
4524: emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
4525: expr_size (exp),
4526: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
4527: }
1.1.1.8 root 4528: else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp)))
1.1 root 4529: {
1.1.1.2 root 4530: if (!rtx_equal_p (target, valreg))
4531: emit_move_insn (target, valreg);
4532: else
4533: /* This tells expand_inline_function to copy valreg to its target. */
4534: emit_insn (gen_rtx (USE, VOIDmode, valreg));
1.1 root 4535: }
1.1.1.8 root 4536: else
4537: target = copy_to_reg (valreg);
4538:
1.1.1.9 root 4539: /* Perform all cleanups needed for the arguments of this call
4540: (i.e. destructors in C++). */
4541: while (cleanups_of_this_call != old_cleanups)
4542: {
4543: expand_expr (TREE_VALUE (cleanups_of_this_call), 0, VOIDmode, 0);
4544: cleanups_of_this_call = TREE_CHAIN (cleanups_of_this_call);
4545: }
4546:
1.1.1.8 root 4547: /* If size of args is variable, restore saved stack-pointer value. */
4548:
1.1.1.9 root 4549: if (old_stack_level)
1.1.1.8 root 4550: {
4551: emit_move_insn (stack_pointer_rtx, old_stack_level);
4552: pending_stack_adjust = old_pending_adj;
4553: }
4554:
1.1.1.14 root 4555: /* If call is cse'able, make appropriate pair of reg-notes around it. */
4556: if (is_const)
4557: {
4558: rtx insn_first = NEXT_INSN (insn_before);
4559: rtx insn_last = get_last_insn ();
4560: rtx note = 0;
4561:
1.1.1.17! root 4562: /* Cancel the NO_DEFER_POP done at start of expand_call. */
! 4563: OK_DEFER_POP;
! 4564:
1.1.1.14 root 4565: /* Construct an "equal form" for the value
4566: which mentions all the arguments in order
4567: as well as the function name. */
4568: for (i = 0; i < num_actuals; i++)
4569: if (args[i].reg != 0 || is_const)
4570: note = gen_rtx (EXPR_LIST, VOIDmode, args[i].value, note);
4571: note = gen_rtx (EXPR_LIST, VOIDmode, XEXP (DECL_RTL (fndecl), 0), note);
4572:
4573: REG_NOTES (insn_last)
4574: = gen_rtx (EXPR_LIST, REG_EQUAL, note,
4575: gen_rtx (INSN_LIST, REG_RETVAL, insn_first,
4576: REG_NOTES (insn_last)));
4577: REG_NOTES (insn_first)
4578: = gen_rtx (INSN_LIST, REG_LIBCALL, insn_last,
4579: REG_NOTES (insn_first));
4580: }
4581:
1.1.1.9 root 4582: return target;
4583: }
4584:
4585: /* Return an rtx which represents a suitable home on the stack
4586: given TYPE, the type of the argument looking for a home.
4587: This is called only for BLKmode arguments.
4588:
4589: SIZE is the size needed for this target.
4590: ARGS_ADDR is the address of the bottom of the argument block for this call.
4591: OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless
4592: if this machine uses push insns. */
4593:
4594: static rtx
4595: target_for_arg (type, size, args_addr, offset)
4596: tree type;
4597: rtx size;
4598: rtx args_addr;
4599: struct args_size offset;
4600: {
4601: rtx target;
4602: rtx offset_rtx = ARGS_SIZE_RTX (offset);
4603:
4604: /* We do not call memory_address if possible,
4605: because we want to address as close to the stack
4606: as possible. For non-variable sized arguments,
4607: this will be stack-pointer relative addressing. */
4608: if (GET_CODE (offset_rtx) == CONST_INT)
4609: target = plus_constant (args_addr, INTVAL (offset_rtx));
4610: else
1.1.1.8 root 4611: {
1.1.1.9 root 4612: /* I have no idea how to guarantee that this
4613: will work in the presence of register parameters. */
4614: target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
4615: target = memory_address (QImode, target);
1.1.1.8 root 4616: }
1.1.1.9 root 4617:
4618: return gen_rtx (MEM, BLKmode, target);
4619: }
4620:
4621: /* Store a single argument for a function call
4622: into the register or memory area where it must be passed.
4623: *ARG describes the argument value and where to pass it.
4624: ARGBLOCK is the address of the stack-block for all the arguments,
4625: or 0 on a machine where arguemnts are pushed individually.
4626: MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
4627: so must be careful about how the stack is used. */
4628:
4629: static void
4630: store_one_arg (arg, argblock, may_be_alloca)
4631: struct arg_data *arg;
4632: rtx argblock;
4633: int may_be_alloca;
4634: {
4635: register tree pval = arg->tree_value;
4636: int used = 0;
4637:
4638: if (TREE_CODE (pval) == ERROR_MARK)
4639: return;
4640:
4641: if (arg->reg != 0 && arg->partial == 0)
4642: {
4643: /* Being passed entirely in a register. */
4644: if (arg->value != 0)
4645: {
4646: if (GET_MODE (arg->value) == BLKmode)
4647: move_block_to_reg (REGNO (arg->reg), arg->value,
4648: (int_size_in_bytes (TREE_TYPE (pval))
4649: / UNITS_PER_WORD));
4650: else
4651: emit_move_insn (arg->reg, arg->value);
4652: }
4653: else
4654: store_expr (pval, arg->reg, 0);
4655:
4656: /* Don't allow anything left on stack from computation
4657: of argument to alloca. */
4658: if (may_be_alloca)
4659: do_pending_stack_adjust ();
4660: }
4661: else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode)
4662: {
4663: register int size;
4664: rtx tem;
4665:
4666: /* Argument is a scalar, not entirely passed in registers.
4667: (If part is passed in registers, arg->partial says how much
4668: and emit_push_insn will take care of putting it there.)
4669:
4670: Push it, and if its size is less than the
4671: amount of space allocated to it,
4672: also bump stack pointer by the additional space.
4673: Note that in C the default argument promotions
4674: will prevent such mismatches. */
4675:
4676: used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval)));
4677: /* Compute how much space the push instruction will push.
4678: On many machines, pushing a byte will advance the stack
4679: pointer by a halfword. */
4680: #ifdef PUSH_ROUNDING
4681: size = PUSH_ROUNDING (size);
4682: #endif
4683: /* Compute how much space the argument should get:
4684: round up to a multiple of the alignment for arguments. */
1.1.1.16 root 4685: if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), const0_rtx))
1.1.1.9 root 4686: used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
4687: / (PARM_BOUNDARY / BITS_PER_UNIT))
4688: * (PARM_BOUNDARY / BITS_PER_UNIT));
4689:
4690: tem = arg->value;
4691: if (tem == 0)
4692: {
4693: tem = expand_expr (pval, 0, VOIDmode, 0);
4694: /* ANSI doesn't require a sequence point here,
4695: but PCC has one, so this will avoid some problems. */
4696: emit_queue ();
4697: }
4698:
4699: /* Don't allow anything left on stack from computation
4700: of argument to alloca. */
4701: if (may_be_alloca)
4702: do_pending_stack_adjust ();
4703:
4704: emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), 0, 0,
4705: arg->partial, arg->reg, used - size,
4706: argblock, ARGS_SIZE_RTX (arg->offset));
4707: }
4708: else if (arg->stack != 0)
4709: {
1.1.1.14 root 4710: /* BLKmode parm, not entirely passed in registers,
4711: and with space already allocated. */
4712:
4713: tree sizetree = size_in_bytes (TREE_TYPE (pval));
4714: /* Round the size up to multiple of PARM_BOUNDARY bits. */
4715: tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
4716: tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
4717:
4718: /* Find out if the parm needs padding, and whether above or below. */
4719: enum direction where_pad
4720: = FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)),
4721: expand_expr (sizetree, 0, VOIDmode, 0));
4722:
4723: /* If it is padded below, adjust the stack address
4724: upward over the padding. */
4725:
4726: if (where_pad == downward)
4727: {
4728: rtx offset_rtx;
4729: rtx address = XEXP (arg->stack, 0);
4730: struct args_size stack_offset;
4731:
4732: stack_offset.constant = 0;
4733: stack_offset.var = 0;
4734:
4735: /* Compute amount of padding. */
4736: ADD_PARM_SIZE (stack_offset, s2);
4737: SUB_PARM_SIZE (stack_offset, sizetree);
4738: offset_rtx = ARGS_SIZE_RTX (stack_offset);
4739:
4740: /* Adjust the address to store at. */
4741: if (GET_CODE (offset_rtx) == CONST_INT)
4742: address = plus_constant (address, INTVAL (offset_rtx));
4743: else
4744: {
4745: address = gen_rtx (PLUS, Pmode, address, offset_rtx);
4746: address = memory_address (QImode, address);
4747: }
4748: arg->stack = change_address (arg->stack, VOIDmode, address);
4749: }
4750:
1.1.1.12 root 4751: /* ARG->stack probably refers to the stack-pointer. If so,
4752: stabilize it, in case stack-pointer changes during evaluation. */
4753: if (reg_mentioned_p (stack_pointer_rtx, arg->stack))
4754: arg->stack = change_address (arg->stack, VOIDmode,
4755: copy_to_reg (XEXP (arg->stack, 0)));
1.1.1.9 root 4756: /* BLKmode argument that should go in a prespecified stack location. */
4757: if (arg->value == 0)
4758: /* Not yet computed => compute it there. */
4759: /* ??? This should be changed to tell expand_expr
4760: that it can store directly in the target. */
4761: arg->value = store_expr (arg->tree_value, arg->stack, 0);
4762: else if (arg->value != arg->stack)
4763: /* It was computed somewhere, but not where we wanted.
4764: For example, the value may have come from an official
4765: local variable or parameter. In that case, expand_expr
4766: does not fill our suggested target. */
4767: emit_block_move (arg->stack, arg->value, ARGS_SIZE_RTX (arg->size),
1.1.1.10 root 4768: TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT);
1.1.1.9 root 4769:
4770: /* Now, if this value wanted to be partly in registers,
4771: move the value from the stack to the registers
4772: that are supposed to hold the values. */
4773: if (arg->partial > 0)
4774: move_block_to_reg (REGNO (arg->reg), arg->stack, arg->partial);
4775: }
4776: else
4777: {
1.1.1.14 root 4778: /* BLKmode, at least partly to be pushed. */
4779:
1.1.1.9 root 4780: register rtx tem
4781: = arg->value ? arg->value : expand_expr (pval, 0, VOIDmode, 0);
4782: register int excess;
4783: rtx size_rtx;
4784:
4785: /* Pushing a nonscalar.
4786: If part is passed in registers, arg->partial says how much
4787: and emit_push_insn will take care of putting it there. */
4788:
4789: /* Round its size up to a multiple
4790: of the allocation unit for arguments. */
4791:
4792: if (arg->size.var != 0)
4793: {
4794: excess = 0;
4795: size_rtx = ARGS_SIZE_RTX (arg->size);
4796: }
4797: else
4798: {
4799: register tree size = size_in_bytes (TREE_TYPE (pval));
4800: /* PUSH_ROUNDING has no effect on us, because
4801: emit_push_insn for BLKmode is careful to avoid it. */
1.1.1.17! root 4802: excess = (arg->size.constant - TREE_INT_CST_LOW (size)
! 4803: + arg->partial * UNITS_PER_WORD);
1.1.1.9 root 4804: size_rtx = expand_expr (size, 0, VOIDmode, 0);
4805: }
4806:
4807: if (arg->stack)
4808: abort ();
4809:
4810: emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), size_rtx,
4811: TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT,
4812: arg->partial, arg->reg, excess, argblock,
4813: ARGS_SIZE_RTX (arg->offset));
4814: }
4815:
4816: /* Once we have pushed something, pops can't safely
4817: be deferred during the rest of the arguments. */
4818: NO_DEFER_POP;
1.1 root 4819: }
4820:
4821: /* Expand conditional expressions. */
4822:
4823: /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
4824: LABEL is an rtx of code CODE_LABEL, in this function and all the
4825: functions here. */
4826:
1.1.1.2 root 4827: void
1.1 root 4828: jumpifnot (exp, label)
4829: tree exp;
4830: rtx label;
4831: {
4832: do_jump (exp, label, 0);
4833: }
4834:
4835: /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero. */
4836:
1.1.1.2 root 4837: void
1.1 root 4838: jumpif (exp, label)
4839: tree exp;
4840: rtx label;
4841: {
4842: do_jump (exp, 0, label);
4843: }
4844:
4845: /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
4846: the result is zero, or IF_TRUE_LABEL if the result is one.
4847: Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
4848: meaning fall through in that case.
4849:
4850: This function is responsible for optimizing cases such as
4851: &&, || and comparison operators in EXP. */
4852:
1.1.1.2 root 4853: void
1.1 root 4854: do_jump (exp, if_false_label, if_true_label)
4855: tree exp;
4856: rtx if_false_label, if_true_label;
4857: {
4858: register enum tree_code code = TREE_CODE (exp);
4859: /* Some cases need to create a label to jump to
4860: in order to properly fall through.
4861: These cases set DROP_THROUGH_LABEL nonzero. */
4862: rtx drop_through_label = 0;
4863: rtx temp;
4864: rtx comparison = 0;
4865:
4866: emit_queue ();
4867:
4868: switch (code)
4869: {
4870: case ERROR_MARK:
4871: break;
4872:
4873: case INTEGER_CST:
4874: temp = integer_zerop (exp) ? if_false_label : if_true_label;
4875: if (temp)
4876: emit_jump (temp);
4877: break;
4878:
4879: case ADDR_EXPR:
4880: /* The address of something can never be zero. */
4881: if (if_true_label)
4882: emit_jump (if_true_label);
4883: break;
1.1.1.6 root 4884:
1.1 root 4885: case NOP_EXPR:
4886: do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
4887: break;
4888:
4889: case TRUTH_NOT_EXPR:
4890: do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
4891: break;
4892:
4893: case TRUTH_ANDIF_EXPR:
4894: if (if_false_label == 0)
4895: if_false_label = drop_through_label = gen_label_rtx ();
4896: do_jump (TREE_OPERAND (exp, 0), if_false_label, 0);
4897: do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
4898: break;
4899:
4900: case TRUTH_ORIF_EXPR:
4901: if (if_true_label == 0)
4902: if_true_label = drop_through_label = gen_label_rtx ();
4903: do_jump (TREE_OPERAND (exp, 0), 0, if_true_label);
4904: do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
4905: break;
4906:
4907: case COMPOUND_EXPR:
1.1.1.2 root 4908: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
1.1 root 4909: emit_queue ();
4910: do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
4911: break;
4912:
4913: case COND_EXPR:
4914: {
4915: register rtx label1 = gen_label_rtx ();
4916: drop_through_label = gen_label_rtx ();
4917: do_jump (TREE_OPERAND (exp, 0), label1, 0);
4918: /* Now the THEN-expression. */
4919: do_jump (TREE_OPERAND (exp, 1),
4920: if_false_label ? if_false_label : drop_through_label,
4921: if_true_label ? if_true_label : drop_through_label);
4922: emit_label (label1);
4923: /* Now the ELSE-expression. */
4924: do_jump (TREE_OPERAND (exp, 2),
4925: if_false_label ? if_false_label : drop_through_label,
4926: if_true_label ? if_true_label : drop_through_label);
4927: }
4928: break;
4929:
4930: case EQ_EXPR:
4931: comparison = compare (exp, EQ, EQ, EQ, EQ);
4932: break;
4933:
4934: case NE_EXPR:
4935: comparison = compare (exp, NE, NE, NE, NE);
4936: break;
4937:
4938: case LT_EXPR:
4939: comparison = compare (exp, LT, LTU, GT, GTU);
4940: break;
4941:
4942: case LE_EXPR:
4943: comparison = compare (exp, LE, LEU, GE, GEU);
4944: break;
4945:
4946: case GT_EXPR:
4947: comparison = compare (exp, GT, GTU, LT, LTU);
4948: break;
4949:
4950: case GE_EXPR:
4951: comparison = compare (exp, GE, GEU, LE, LEU);
4952: break;
4953:
4954: default:
4955: temp = expand_expr (exp, 0, VOIDmode, 0);
1.1.1.2 root 4956: /* Copy to register to avoid generating bad insns by cse
4957: from (set (mem ...) (arithop)) (set (cc0) (mem ...)). */
4958: if (!cse_not_expected && GET_CODE (temp) == MEM)
4959: temp = copy_to_reg (temp);
1.1 root 4960: do_pending_stack_adjust ();
1.1.1.2 root 4961: {
1.1.1.16 root 4962: rtx zero = CONST0_RTX (GET_MODE (temp));
1.1 root 4963:
1.1.1.2 root 4964: if (GET_CODE (temp) == CONST_INT)
4965: comparison = compare_constants (NE, 0,
4966: INTVAL (temp), 0, BITS_PER_WORD);
4967: else if (GET_MODE (temp) != VOIDmode)
4968: comparison = compare1 (temp, zero, NE, NE, 0, GET_MODE (temp));
4969: else
4970: abort ();
4971: }
1.1 root 4972: }
4973:
1.1.1.2 root 4974: /* Do any postincrements in the expression that was tested. */
4975: emit_queue ();
4976:
1.1 root 4977: /* If COMPARISON is nonzero here, it is an rtx that can be substituted
4978: straight into a conditional jump instruction as the jump condition.
4979: Otherwise, all the work has been done already. */
4980:
1.1.1.2 root 4981: if (comparison == const1_rtx)
4982: {
4983: if (if_true_label)
4984: emit_jump (if_true_label);
4985: }
4986: else if (comparison == const0_rtx)
4987: {
4988: if (if_false_label)
4989: emit_jump (if_false_label);
4990: }
4991: else if (comparison)
4992: {
4993: if (if_true_label)
4994: {
1.1.1.13 root 4995: if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
4996: emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
4997: else
4998: abort ();
4999:
1.1.1.2 root 5000: if (if_false_label)
5001: emit_jump (if_false_label);
5002: }
5003: else if (if_false_label)
5004: {
1.1.1.13 root 5005: rtx pat;
5006:
5007: if (bcc_gen_fctn[(int) GET_CODE (comparison)] == 0)
5008: abort ();
5009:
5010: pat = (*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_false_label);
5011: /* Now invert the sense of the jump by exchanging the two arms
5012: of each IF_THEN_ELSE. Note that inverting the condition
5013: would be incorrect for IEEE floating point with nans! */
1.1.1.14 root 5014: if (GET_CODE (pat) == SEQUENCE)
5015: {
5016: int i;
5017: /* We can invert a sequence if the only jump is at the end. */
5018: for (i = 0; i < XVECLEN (pat, 0) - 1; i++)
5019: if (GET_CODE (XVECEXP (pat, 0, i)) == JUMP_INSN)
5020: abort ();
1.1.1.16 root 5021: invert_exp (PATTERN (XVECEXP (pat, 0, XVECLEN (pat, 0) - 1)),
5022: 0, 0);
1.1.1.14 root 5023: }
5024: else
5025: invert_exp (pat, 0, 0);
5026:
1.1.1.13 root 5027: emit_jump_insn (pat);
1.1.1.2 root 5028: }
5029: }
1.1 root 5030:
5031: if (drop_through_label)
5032: emit_label (drop_through_label);
5033: }
5034:
1.1.1.2 root 5035: /* Compare two integer constant rtx's, OP0 and OP1.
5036: The comparison operation is OPERATION.
5037: Return an rtx representing the value 1 or 0.
5038: WIDTH is the width in bits that is significant. */
5039:
5040: static rtx
5041: compare_constants (operation, unsignedp, op0, op1, width)
5042: enum rtx_code operation;
5043: int unsignedp;
5044: int op0, op1;
5045: int width;
5046: {
5047: int val;
5048:
5049: /* Sign-extend or zero-extend the operands to a full word
5050: from an initial width of WIDTH bits. */
5051: if (width < HOST_BITS_PER_INT)
5052: {
5053: op0 &= (1 << width) - 1;
5054: op1 &= (1 << width) - 1;
5055:
5056: if (! unsignedp)
5057: {
5058: if (op0 & (1 << (width - 1)))
5059: op0 |= ((-1) << width);
5060: if (op1 & (1 << (width - 1)))
5061: op1 |= ((-1) << width);
5062: }
5063: }
5064:
5065: switch (operation)
5066: {
5067: case EQ:
5068: val = op0 == op1;
5069: break;
5070:
5071: case NE:
5072: val = op0 != op1;
5073: break;
5074:
5075: case GT:
5076: case GTU:
5077: val = op0 > op1;
5078: break;
5079:
5080: case LT:
5081: case LTU:
5082: val = op0 < op1;
5083: break;
5084:
5085: case GE:
5086: case GEU:
5087: val = op0 >= op1;
5088: break;
5089:
5090: case LE:
5091: case LEU:
5092: val = op0 <= op1;
5093: }
5094:
5095: return val ? const1_rtx : const0_rtx;
5096: }
5097:
1.1 root 5098: /* Generate code for a comparison expression EXP
5099: (including code to compute the values to be compared)
5100: and set (CC0) according to the result.
5101: SIGNED_FORWARD should be the rtx operation for this comparison for
5102: signed data; UNSIGNED_FORWARD, likewise for use if data is unsigned.
5103: SIGNED_REVERSE and UNSIGNED_REVERSE are used if it is desirable
5104: to interchange the operands for the compare instruction.
5105:
5106: We force a stack adjustment unless there are currently
5107: things pushed on the stack that aren't yet used. */
5108:
5109: static rtx
5110: compare (exp, signed_forward, unsigned_forward,
5111: signed_reverse, unsigned_reverse)
5112: register tree exp;
5113: enum rtx_code signed_forward, unsigned_forward;
5114: enum rtx_code signed_reverse, unsigned_reverse;
5115: {
1.1.1.2 root 5116:
1.1 root 5117: register rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
5118: register rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
5119: register enum machine_mode mode = GET_MODE (op0);
5120: int unsignedp;
5121:
5122: /* If one operand is 0, make it the second one. */
5123:
1.1.1.16 root 5124: if (op0 == const0_rtx
5125: || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode)))
1.1 root 5126: {
5127: rtx tem = op0;
5128: op0 = op1;
5129: op1 = tem;
5130: signed_forward = signed_reverse;
5131: unsigned_forward = unsigned_reverse;
5132: }
5133:
1.1.1.2 root 5134: if (flag_force_mem)
1.1 root 5135: {
5136: op0 = force_not_mem (op0);
5137: op1 = force_not_mem (op1);
5138: }
5139:
5140: do_pending_stack_adjust ();
5141:
1.1.1.2 root 5142: unsignedp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)))
5143: || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))));
5144:
5145: if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
5146: return compare_constants (signed_forward, unsignedp,
5147: INTVAL (op0), INTVAL (op1),
5148: GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))));
1.1 root 5149:
5150: emit_cmp_insn (op0, op1,
5151: (mode == BLKmode) ? expr_size (TREE_OPERAND (exp, 0)) : 0,
1.1.1.14 root 5152: unsignedp,
5153: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1.1 root 5154:
5155: return gen_rtx ((unsignedp ? unsigned_forward : signed_forward),
5156: VOIDmode, cc0_rtx, const0_rtx);
5157: }
5158:
5159: /* Like compare but expects the values to compare as two rtx's.
5160: The decision as to signed or unsigned comparison must be made by the caller.
5161: BLKmode is not allowed. */
5162:
5163: static rtx
1.1.1.2 root 5164: compare1 (op0, op1, forward_op, reverse_op, unsignedp, mode)
1.1 root 5165: register rtx op0, op1;
5166: enum rtx_code forward_op, reverse_op;
5167: int unsignedp;
1.1.1.2 root 5168: enum machine_mode mode;
1.1 root 5169: {
5170: /* If one operand is 0, make it the second one. */
5171:
1.1.1.16 root 5172: if (op0 == const0_rtx
5173: || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode)))
1.1 root 5174: {
5175: rtx tem = op0;
5176: op0 = op1;
5177: op1 = tem;
5178: forward_op = reverse_op;
5179: }
5180:
1.1.1.2 root 5181: if (flag_force_mem)
1.1 root 5182: {
5183: op0 = force_not_mem (op0);
5184: op1 = force_not_mem (op1);
5185: }
5186:
5187: do_pending_stack_adjust ();
5188:
1.1.1.2 root 5189: if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
5190: return compare_constants (forward_op, unsignedp,
5191: INTVAL (op0), INTVAL (op1),
5192: GET_MODE_BITSIZE (mode));
5193:
1.1.1.14 root 5194: emit_cmp_insn (op0, op1, 0, unsignedp, 0);
1.1 root 5195:
5196: return gen_rtx (forward_op, VOIDmode, cc0_rtx, const0_rtx);
5197: }
5198:
5199: /* Generate code to calculate EXP using a store-flag instruction
5200: and return an rtx for the result.
5201: If TARGET is nonzero, store the result there if convenient.
5202:
5203: Return zero if there is no suitable set-flag instruction
5204: available on this machine. */
5205:
5206: static rtx
1.1.1.2 root 5207: do_store_flag (exp, target, mode)
1.1 root 5208: tree exp;
5209: rtx target;
1.1.1.2 root 5210: enum machine_mode mode;
1.1 root 5211: {
5212: register enum tree_code code = TREE_CODE (exp);
5213: register rtx comparison = 0;
1.1.1.2 root 5214: enum machine_mode compare_mode;
1.1.1.17! root 5215: rtx prev_insn = get_last_insn ();
! 5216: enum insn_code icode;
1.1 root 5217:
5218: switch (code)
5219: {
1.1.1.2 root 5220: #ifdef HAVE_seq
1.1 root 5221: case EQ_EXPR:
1.1.1.2 root 5222: if (HAVE_seq)
5223: {
5224: comparison = compare (exp, EQ, EQ, EQ, EQ);
1.1.1.17! root 5225: icode = CODE_FOR_seq;
1.1.1.2 root 5226: compare_mode = insn_operand_mode[(int) CODE_FOR_seq][0];
5227: }
1.1 root 5228: break;
5229: #endif
5230:
1.1.1.2 root 5231: #ifdef HAVE_sne
1.1 root 5232: case NE_EXPR:
1.1.1.2 root 5233: if (HAVE_sne)
5234: {
5235: comparison = compare (exp, NE, NE, NE, NE);
1.1.1.17! root 5236: icode = CODE_FOR_sne;
1.1.1.2 root 5237: compare_mode = insn_operand_mode[(int) CODE_FOR_sne][0];
5238: }
1.1 root 5239: break;
5240: #endif
5241:
1.1.1.2 root 5242: #if defined (HAVE_slt) && defined (HAVE_sltu) && defined (HAVE_sgt) && defined (HAVE_sgtu)
1.1 root 5243: case LT_EXPR:
1.1.1.2 root 5244: if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
5245: {
5246: comparison = compare (exp, LT, LTU, GT, GTU);
1.1.1.17! root 5247: icode = CODE_FOR_slt;
1.1.1.2 root 5248: compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
5249: }
1.1 root 5250: break;
5251:
5252: case GT_EXPR:
1.1.1.2 root 5253: if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
5254: {
5255: comparison = compare (exp, GT, GTU, LT, LTU);
1.1.1.17! root 5256: icode = CODE_FOR_slt;
1.1.1.2 root 5257: compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
5258: }
1.1 root 5259: break;
5260: #endif
5261:
1.1.1.2 root 5262: #if defined (HAVE_sle) && defined (HAVE_sleu) && defined (HAVE_sge) && defined (HAVE_sgeu)
1.1 root 5263: case LE_EXPR:
1.1.1.2 root 5264: if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
5265: {
5266: comparison = compare (exp, LE, LEU, GE, GEU);
1.1.1.17! root 5267: icode = CODE_FOR_sle;
1.1.1.2 root 5268: compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
5269: }
1.1 root 5270: break;
5271:
5272: case GE_EXPR:
1.1.1.2 root 5273: if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
5274: {
5275: comparison = compare (exp, GE, GEU, LE, LEU);
1.1.1.17! root 5276: icode = CODE_FOR_sle;
1.1.1.2 root 5277: compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
5278: }
1.1 root 5279: break;
5280: #endif
5281: }
5282: if (comparison == 0)
5283: return 0;
5284:
1.1.1.2 root 5285: if (target == 0 || GET_MODE (target) != mode
1.1.1.17! root 5286: /* Don't use specified target unless the insn can handle it. */
! 5287: || ! (*insn_operand_predicate[(int) icode][0]) (target, mode)
! 5288: /* When modes don't match, don't use specified target,
! 5289: because it might be the same as an operand,
! 5290: and then the CLOBBER output below would screw up. */
! 5291: || (mode != compare_mode && GET_CODE (comparison) != CONST_INT))
1.1.1.2 root 5292: target = gen_reg_rtx (mode);
5293:
5294: /* Store the comparison in its proper mode. */
1.1.1.13 root 5295: if (GET_CODE (comparison) == CONST_INT)
5296: emit_move_insn (target, comparison);
5297: else if (GET_MODE (target) != compare_mode)
1.1.1.17! root 5298: {
! 5299: /* We want a different mode: store result in its natural mode.
! 5300: Combine the mode conversion with the truncation we must do anyway. */
! 5301: /* Put a CLOBBER before the compare, so we don't come between
! 5302: the compare and the insn that uses the result. */
! 5303: emit_insn_after (gen_rtx (CLOBBER, VOIDmode, target), prev_insn);
! 5304: emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)])
! 5305: (gen_rtx (SUBREG, compare_mode, target, 0)));
! 5306: /* If the desired mode is wider than what we got,
! 5307: use an AND to convert it, but not if we will do one anyway. */
! 5308: #if STORE_FLAG_VALUE == 1
! 5309: if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (compare_mode))
! 5310: expand_bit_and (mode, target, const1_rtx, target);
! 5311: #endif
! 5312: }
1.1.1.2 root 5313: else
1.1.1.13 root 5314: emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)]) (target));
1.1.1.2 root 5315:
5316: #if STORE_FLAG_VALUE != 1
1.1.1.17! root 5317: #if STORE_FLAG_VALUE & 1
1.1.1.2 root 5318: expand_bit_and (mode, target, const1_rtx, target);
1.1.1.17! root 5319: #else
! 5320: expand_shift (RSHIFT_EXPR, mode, target,
! 5321: build_int_2 (GET_MODE_BITSIZE (mode) - 1, 0),
! 5322: target, TRUE);
! 5323: #endif
1.1.1.2 root 5324: #endif
1.1 root 5325: return target;
5326: }
5327:
5328: /* Generate a tablejump instruction (used for switch statements). */
5329:
5330: #ifdef HAVE_tablejump
5331:
5332: /* INDEX is the value being switched on, with the lowest value
5333: in the table already subtracted.
5334: RANGE is the length of the jump table.
5335: TABLE_LABEL is a CODE_LABEL rtx for the table itself.
1.1.1.2 root 5336:
1.1 root 5337: DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
5338: index value is out of range. */
5339:
5340: void
5341: do_tablejump (index, range, table_label, default_label)
5342: rtx index, range, table_label, default_label;
5343: {
5344: register rtx temp;
5345:
1.1.1.14 root 5346: emit_cmp_insn (range, index, 0, 0, 0);
1.1.1.2 root 5347: emit_jump_insn (gen_bltu (default_label));
1.1.1.4 root 5348: /* If flag_force_addr were to affect this address
5349: it could interfere with the tricky assumptions made
5350: about addresses that contain label-refs,
5351: which may be valid only very near the tablejump itself. */
5352: index = memory_address_noforce
5353: (CASE_VECTOR_MODE,
5354: gen_rtx (PLUS, Pmode,
5355: gen_rtx (MULT, Pmode, index,
5356: gen_rtx (CONST_INT, VOIDmode,
5357: GET_MODE_SIZE (CASE_VECTOR_MODE))),
5358: gen_rtx (LABEL_REF, VOIDmode, table_label)));
1.1 root 5359: temp = gen_reg_rtx (CASE_VECTOR_MODE);
5360: convert_move (temp, gen_rtx (MEM, CASE_VECTOR_MODE, index), 0);
5361:
1.1.1.2 root 5362: emit_jump_insn (gen_tablejump (temp, table_label));
1.1 root 5363: }
5364:
1.1.1.2 root 5365: #endif /* HAVE_tablejump */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.