OSDN Git Service

663539b9ecc5b9fff00ff2f4b4be2777656c8594
[pf3gnuchains/gcc-fork.git] / gcc / config / i960 / i960.c
1 /* Subroutines used for code generation on intel 80960.
2    Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3    Free Software Foundation, Inc.
4    Contributed by Steven McGeady, Intel Corp.
5    Additional Work by Glenn Colon-Bonet, Jonathan Shapiro, Andy Wilson
6    Converted to GCC 2.0 by Jim Wilson and Michael Tiemann, Cygnus Support.
7
8 This file is part of GNU CC.
9
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING.  If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA.  */
24
25 #include "config.h"
26 #include "system.h"
27 #include <math.h>
28 #include "rtl.h"
29 #include "regs.h"
30 #include "hard-reg-set.h"
31 #include "real.h"
32 #include "insn-config.h"
33 #include "conditions.h"
34 #include "output.h"
35 #include "insn-attr.h"
36 #include "flags.h"
37 #include "tree.h"
38 #include "expr.h"
39 #include "except.h"
40 #include "function.h"
41 #include "recog.h"
42 #include "toplev.h"
43 #include "cpplib.h"
44 #include "c-pragma.h"
45 #include "c-lex.h"
46 #include "tm_p.h"
47 #include "target.h"
48 #include "target-def.h"
49
50 /* Save the operands last given to a compare for use when we
51    generate a scc or bcc insn.  */
52
53 rtx i960_compare_op0, i960_compare_op1;
54
55 /* Used to implement #pragma align/noalign.  Initialized by OVERRIDE_OPTIONS
56    macro in i960.h.  */
57
58 int i960_maxbitalignment;
59 int i960_last_maxbitalignment;
60
61 /* Used to implement switching between MEM and ALU insn types, for better
62    C series performance.  */
63
64 enum insn_types i960_last_insn_type;
65
66 /* The leaf-procedure return register.  Set only if this is a leaf routine.  */
67
68 static int i960_leaf_ret_reg;
69
70 /* True if replacing tail calls with jumps is OK.  */
71
72 static int tail_call_ok;
73
74 /* A string containing a list of insns to emit in the epilogue so as to
75    restore all registers saved by the prologue.  Created by the prologue
76    code as it saves registers away.  */
77
78 char epilogue_string[1000];
79
80 /* A unique number (per function) for return labels.  */
81
82 static int ret_label = 0;
83
84 /* This is true if FNDECL is either a varargs or a stdarg function.
85    This is used to help identify functions that use an argument block.  */
86
87 #define VARARGS_STDARG_FUNCTION(FNDECL) \
88 ((TYPE_ARG_TYPES (TREE_TYPE (FNDECL)) != 0                                                    \
89   && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (FNDECL)))) != void_type_node))    \
90  || current_function_varargs)
91 \f
92 /* Initialize the GCC target structure.  */
93
94 struct gcc_target target = TARGET_INITIALIZER;
95 \f
96 /* Initialize variables before compiling any files.  */
97
98 void
99 i960_initialize ()
100 {
101   if (TARGET_IC_COMPAT2_0)
102     {
103       i960_maxbitalignment = 8;
104       i960_last_maxbitalignment = 128;
105     }
106   else
107     {
108       i960_maxbitalignment = 128;
109       i960_last_maxbitalignment = 8;
110     }
111 }
112 \f
113 /* Return true if OP can be used as the source of an fp move insn.  */
114
115 int
116 fpmove_src_operand (op, mode)
117      rtx op;
118      enum machine_mode mode;
119 {
120   return (GET_CODE (op) == CONST_DOUBLE || general_operand (op, mode));
121 }
122
123 #if 0
124 /* Return true if OP is a register or zero.  */
125
126 int
127 reg_or_zero_operand (op, mode)
128      rtx op;
129      enum machine_mode mode;
130 {
131   return register_operand (op, mode) || op == const0_rtx;
132 }
133 #endif
134
135 /* Return truth value of whether OP can be used as an operands in a three
136    address arithmetic insn (such as add %o1,7,%l2) of mode MODE.  */
137
138 int
139 arith_operand (op, mode)
140      rtx op;
141      enum machine_mode mode;
142 {
143   return (register_operand (op, mode) || literal (op, mode));
144 }
145
146 /* Return truth value of whether OP can be used as an operands in a three
147    address logic insn, possibly complementing OP, of mode MODE.  */
148
149 int
150 logic_operand (op, mode)
151      rtx op;
152      enum machine_mode mode;
153 {
154   return (register_operand (op, mode)
155           || (GET_CODE (op) == CONST_INT
156               && INTVAL(op) >= -32 && INTVAL(op) < 32));
157 }
158
159 /* Return true if OP is a register or a valid floating point literal.  */
160
161 int
162 fp_arith_operand (op, mode)
163      rtx op;
164      enum machine_mode mode;
165 {
166   return (register_operand (op, mode) || fp_literal (op, mode));
167 }
168
169 /* Return true if OP is a register or a valid signed integer literal.  */
170
171 int
172 signed_arith_operand (op, mode)
173      rtx op;
174      enum machine_mode mode;
175 {
176   return (register_operand (op, mode) || signed_literal (op, mode));
177 }
178
179 /* Return truth value of whether OP is a integer which fits the
180    range constraining immediate operands in three-address insns.  */
181
182 int
183 literal (op, mode)
184      rtx op;
185      enum machine_mode mode ATTRIBUTE_UNUSED;
186 {
187   return ((GET_CODE (op) == CONST_INT) && INTVAL(op) >= 0 && INTVAL(op) < 32);
188 }
189
190 /* Return true if OP is a float constant of 1.  */
191
192 int
193 fp_literal_one (op, mode)
194      rtx op;
195      enum machine_mode mode;
196 {
197   return (TARGET_NUMERICS && mode == GET_MODE (op) && op == CONST1_RTX (mode));
198 }
199
200 /* Return true if OP is a float constant of 0.  */
201
202 int
203 fp_literal_zero (op, mode)
204      rtx op;
205      enum machine_mode mode;
206 {
207   return (TARGET_NUMERICS && mode == GET_MODE (op) && op == CONST0_RTX (mode));
208 }
209
210 /* Return true if OP is a valid floating point literal.  */
211
212 int
213 fp_literal(op, mode)
214      rtx op;
215      enum machine_mode mode;
216 {
217   return fp_literal_zero (op, mode) || fp_literal_one (op, mode);
218 }
219
220 /* Return true if OP is a valid signed immediate constant.  */
221
222 int
223 signed_literal(op, mode)
224      rtx op;
225      enum machine_mode mode ATTRIBUTE_UNUSED;
226 {
227   return ((GET_CODE (op) == CONST_INT) && INTVAL(op) > -32 && INTVAL(op) < 32);
228 }
229
230 /* Return truth value of statement that OP is a symbolic memory
231    operand of mode MODE.  */
232
233 int
234 symbolic_memory_operand (op, mode)
235      rtx op;
236      enum machine_mode mode ATTRIBUTE_UNUSED;
237 {
238   if (GET_CODE (op) == SUBREG)
239     op = SUBREG_REG (op);
240   if (GET_CODE (op) != MEM)
241     return 0;
242   op = XEXP (op, 0);
243   return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST
244           || GET_CODE (op) == HIGH || GET_CODE (op) == LABEL_REF);
245 }
246
247 /* Return truth value of whether OP is EQ or NE.  */
248
249 int
250 eq_or_neq (op, mode)
251      rtx op;
252      enum machine_mode mode ATTRIBUTE_UNUSED;
253 {
254   return (GET_CODE (op) == EQ || GET_CODE (op) == NE);
255 }
256
257 /* OP is an integer register or a constant.  */
258
259 int
260 arith32_operand (op, mode)
261      rtx op;
262      enum machine_mode mode;
263 {
264   if (register_operand (op, mode))
265     return 1;
266   return (CONSTANT_P (op));
267 }
268
269 /* Return true if OP is an integer constant which is a power of 2.  */
270
271 int
272 power2_operand (op,mode)
273      rtx op;
274      enum machine_mode mode ATTRIBUTE_UNUSED;
275 {
276   if (GET_CODE (op) != CONST_INT)
277     return 0;
278
279   return exact_log2 (INTVAL (op)) >= 0;
280 }
281
282 /* Return true if OP is an integer constant which is the complement of a
283    power of 2.  */
284
285 int
286 cmplpower2_operand (op, mode)
287      rtx op;
288      enum machine_mode mode ATTRIBUTE_UNUSED;
289 {
290   if (GET_CODE (op) != CONST_INT)
291     return 0;
292
293   return exact_log2 (~ INTVAL (op)) >= 0;
294 }
295
296 /* If VAL has only one bit set, return the index of that bit.  Otherwise
297    return -1.  */
298
299 int
300 bitpos (val)
301      unsigned int val;
302 {
303   register int i;
304
305   for (i = 0; val != 0; i++, val >>= 1)
306     {
307       if (val & 1)
308         {
309           if (val != 1)
310             return -1;
311           return i;
312         }
313     }
314   return -1;
315 }
316
317 /* Return non-zero if OP is a mask, i.e. all one bits are consecutive.
318    The return value indicates how many consecutive non-zero bits exist
319    if this is a mask.  This is the same as the next function, except that
320    it does not indicate what the start and stop bit positions are.  */
321
322 int
323 is_mask (val)
324      unsigned int val;
325 {
326   register int start, end, i;
327
328   start = -1;
329   for (i = 0; val != 0; val >>= 1, i++)
330     {
331       if (val & 1)
332         {
333           if (start < 0)
334             start = i;
335
336           end = i;
337           continue;
338         }
339       /* Still looking for the first bit.  */
340       if (start < 0)
341         continue;
342
343       /* We've seen the start of a bit sequence, and now a zero.  There
344          must be more one bits, otherwise we would have exited the loop.
345          Therefore, it is not a mask.  */
346       if (val)
347         return 0;
348     }
349
350   /* The bit string has ones from START to END bit positions only.  */
351   return end - start + 1;
352 }
353
354 /* If VAL is a mask, then return nonzero, with S set to the starting bit
355    position and E set to the ending bit position of the mask.  The return
356    value indicates how many consecutive bits exist in the mask.  This is
357    the same as the previous function, except that it also indicates the
358    start and end bit positions of the mask.  */
359
360 int
361 bitstr (val, s, e)
362      unsigned int val;
363      int *s, *e;
364 {
365   register int start, end, i;
366
367   start = -1;
368   end = -1;
369   for (i = 0; val != 0; val >>= 1, i++)
370     {
371       if (val & 1)
372         {
373           if (start < 0)
374             start = i;
375
376           end = i;
377           continue;
378         }
379
380       /* Still looking for the first bit.  */
381       if (start < 0)
382         continue;
383
384       /* We've seen the start of a bit sequence, and now a zero.  There
385          must be more one bits, otherwise we would have exited the loop.
386          Therefor, it is not a mask.  */
387       if (val)
388         {
389           start = -1;
390           end = -1;
391           break;
392         }
393     }
394
395   /* The bit string has ones from START to END bit positions only.  */
396   *s = start;
397   *e = end;
398   return ((start < 0) ? 0 : end - start + 1);
399 }
400 \f
401 /* Return the machine mode to use for a comparison.  */
402
403 enum machine_mode
404 select_cc_mode (op, x)
405      RTX_CODE op;
406      rtx x ATTRIBUTE_UNUSED;
407 {
408   if (op == GTU || op == LTU || op == GEU || op == LEU)
409     return CC_UNSmode;
410   return CCmode;
411 }
412
413 /* X and Y are two things to compare using CODE.  Emit the compare insn and
414    return the rtx for register 36 in the proper mode.  */
415
416 rtx
417 gen_compare_reg (code, x, y)
418      enum rtx_code code;
419      rtx x, y;
420 {
421   rtx cc_reg;
422   enum machine_mode ccmode = SELECT_CC_MODE (code, x, y);
423   enum machine_mode mode
424     = GET_MODE (x) == VOIDmode ? GET_MODE (y) : GET_MODE (x);
425
426   if (mode == SImode)
427     {
428       if (! arith_operand (x, mode))
429         x = force_reg (SImode, x);
430       if (! arith_operand (y, mode))
431         y = force_reg (SImode, y);
432     }
433
434   cc_reg = gen_rtx_REG (ccmode, 36);
435   emit_insn (gen_rtx_SET (VOIDmode, cc_reg,
436                           gen_rtx_COMPARE (ccmode, x, y)));
437
438   return cc_reg;
439 }
440
441 /* For the i960, REG is cost 1, REG+immed CONST is cost 2, REG+REG is cost 2,
442    REG+nonimmed CONST is cost 4.  REG+SYMBOL_REF, SYMBOL_REF, and similar
443    are 4.  Indexed addresses are cost 6.  */
444
445 /* ??? Try using just RTX_COST, i.e. not defining ADDRESS_COST.  */
446
447 int
448 i960_address_cost (x)
449      rtx x;
450 {
451 #if 0
452   /* Handled before calling here.  */
453   if (GET_CODE (x) == REG)
454     return 1;
455 #endif
456   /* This is a MEMA operand -- it's free.  */
457   if (GET_CODE (x) == CONST_INT
458       && INTVAL (x) >= 0
459       && INTVAL (x) < 4096)
460     return 0;
461
462   if (GET_CODE (x) == PLUS)
463     {
464       rtx base = XEXP (x, 0);
465       rtx offset = XEXP (x, 1);
466
467       if (GET_CODE (base) == SUBREG)
468         base = SUBREG_REG (base);
469       if (GET_CODE (offset) == SUBREG)
470         offset = SUBREG_REG (offset);
471
472       if (GET_CODE (base) == REG)
473         {
474           if (GET_CODE (offset) == REG)
475             return 2;
476           if (GET_CODE (offset) == CONST_INT)
477             {
478               if ((unsigned)INTVAL (offset) < 2047)
479                 return 2;
480               return 4;
481             }
482           if (CONSTANT_P (offset))
483             return 4;
484         }
485       if (GET_CODE (base) == PLUS || GET_CODE (base) == MULT)
486         return 6;
487
488       /* This is an invalid address.  The return value doesn't matter, but
489          for convenience we make this more expensive than anything else.  */
490       return 12;
491     }
492   if (GET_CODE (x) == MULT)
493     return 6;
494
495   /* Symbol_refs and other unrecognized addresses are cost 4.  */
496   return 4;
497 }
498 \f
499 /* Emit insns to move operands[1] into operands[0].
500
501    Return 1 if we have written out everything that needs to be done to
502    do the move.  Otherwise, return 0 and the caller will emit the move
503    normally. */
504
505 int
506 emit_move_sequence (operands, mode)
507      rtx *operands;
508      enum machine_mode mode;
509 {
510   /* We can only store registers to memory.  */
511   
512   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) != REG
513       && (operands[1] != const0_rtx || current_function_args_size
514           || current_function_varargs || current_function_stdarg
515           || rtx_equal_function_value_matters))
516     /* Here we use the same test as movsi+1 pattern -- see i960.md. */
517     operands[1] = force_reg (mode, operands[1]);
518
519   /* Storing multi-word values in unaligned hard registers to memory may
520      require a scratch since we have to store them a register at a time and
521      adding 4 to the memory address may not yield a valid insn.  */
522   /* ??? We don't always need the scratch, but that would complicate things.
523      Maybe later.  */
524   /* ??? We must also handle stores to pseudos here, because the pseudo may be
525      replaced with a MEM later.  This would be cleaner if we didn't have
526      a separate pattern for unaligned DImode/TImode stores.  */
527   if (GET_MODE_SIZE (mode) > UNITS_PER_WORD
528       && (GET_CODE (operands[0]) == MEM
529           || (GET_CODE (operands[0]) == REG
530               && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
531       && GET_CODE (operands[1]) == REG
532       && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
533       && ! HARD_REGNO_MODE_OK (REGNO (operands[1]), mode))
534     {
535       emit_insn (gen_rtx_PARALLEL
536                  (VOIDmode,
537                   gen_rtvec (2,
538                              gen_rtx_SET (VOIDmode, operands[0], operands[1]),
539                              gen_rtx_CLOBBER (VOIDmode,
540                                               gen_rtx_SCRATCH (Pmode)))));
541       return 1;
542     }
543
544   return 0;
545 }
546
547 /* Output assembler to move a double word value.  */
548
549 const char *
550 i960_output_move_double (dst, src)
551      rtx dst, src;
552 {
553   rtx operands[5];
554
555   if (GET_CODE (dst) == REG
556       && GET_CODE (src) == REG)
557     {
558       if ((REGNO (src) & 1)
559           || (REGNO (dst) & 1))
560         {
561           /* We normally copy the low-numbered register first.  However, if
562              the second source register is the same as the first destination
563              register, we must copy in the opposite order.  */
564           if (REGNO (src) + 1 == REGNO (dst))
565             return "mov %D1,%D0\n\tmov  %1,%0";
566           else
567             return "mov %1,%0\n\tmov    %D1,%D0";
568         }
569       else
570         return "movl    %1,%0";
571     }
572   else if (GET_CODE (dst) == REG
573            && GET_CODE (src) == CONST_INT
574            && CONST_OK_FOR_LETTER_P (INTVAL (src), 'I'))
575     {
576       if (REGNO (dst) & 1)
577         return "mov     %1,%0\n\tmov    0,%D0";
578       else
579         return "movl    %1,%0";
580     }
581   else if (GET_CODE (dst) == REG
582            && GET_CODE (src) == MEM)
583     {
584       if (REGNO (dst) & 1)
585         {
586           /* One can optimize a few cases here, but you have to be
587              careful of clobbering registers used in the address and
588              edge conditions.  */
589           operands[0] = dst;
590           operands[1] = src;
591           operands[2] = gen_rtx_REG (Pmode, REGNO (dst) + 1);
592           operands[3] = gen_rtx_MEM (word_mode, operands[2]);
593           operands[4] = adjust_address (operands[3], word_mode,
594                                         UNITS_PER_WORD);
595           output_asm_insn
596             ("lda       %1,%2\n\tld     %3,%0\n\tld     %4,%D0", operands);
597           return "";
598         }
599       else
600         return "ldl     %1,%0";
601     }
602   else if (GET_CODE (dst) == MEM
603            && GET_CODE (src) == REG)
604     {
605       if (REGNO (src) & 1)
606         {
607           operands[0] = dst;
608           operands[1] = adjust_address (dst, word_mode, UNITS_PER_WORD);
609           if (! memory_address_p (word_mode, XEXP (operands[1], 0)))
610             abort ();
611           operands[2] = src;
612           output_asm_insn ("st  %2,%0\n\tst     %D2,%1", operands);
613           return "";
614         }
615       return "stl       %1,%0";
616     }
617   else
618     abort ();
619 }
620
621 /* Output assembler to move a double word zero.  */
622
623 const char *
624 i960_output_move_double_zero (dst)
625      rtx dst;
626 {
627   rtx operands[2];
628
629   operands[0] = dst;
630     {
631       operands[1] = adjust_address (dst, word_mode, 4);
632       output_asm_insn ("st      g14,%0\n\tst    g14,%1", operands);
633     }
634   return "";
635 }
636
637 /* Output assembler to move a quad word value.  */
638
639 const char *
640 i960_output_move_quad (dst, src)
641      rtx dst, src;
642 {
643   rtx operands[7];
644
645   if (GET_CODE (dst) == REG
646       && GET_CODE (src) == REG)
647     {
648       if ((REGNO (src) & 3)
649           || (REGNO (dst) & 3))
650         {
651           /* We normally copy starting with the low numbered register.
652              However, if there is an overlap such that the first dest reg
653              is <= the last source reg but not < the first source reg, we
654              must copy in the opposite order.  */
655           if (REGNO (dst) <= REGNO (src) + 3
656               && REGNO (dst) >= REGNO (src))
657             return "mov %F1,%F0\n\tmov  %E1,%E0\n\tmov  %D1,%D0\n\tmov  %1,%0";
658           else
659             return "mov %1,%0\n\tmov    %D1,%D0\n\tmov  %E1,%E0\n\tmov  %F1,%F0";
660         }
661       else
662         return "movq    %1,%0";
663     }
664   else if (GET_CODE (dst) == REG
665            && GET_CODE (src) == CONST_INT
666            && CONST_OK_FOR_LETTER_P (INTVAL (src), 'I'))
667     {
668       if (REGNO (dst) & 3)
669         return "mov     %1,%0\n\tmov    0,%D0\n\tmov    0,%E0\n\tmov    0,%F0";
670       else
671         return "movq    %1,%0";
672     }
673   else if (GET_CODE (dst) == REG
674            && GET_CODE (src) == MEM)
675     {
676       if (REGNO (dst) & 3)
677         {
678           /* One can optimize a few cases here, but you have to be
679              careful of clobbering registers used in the address and
680              edge conditions.  */
681           operands[0] = dst;
682           operands[1] = src;
683           operands[2] = gen_rtx_REG (Pmode, REGNO (dst) + 3);
684           operands[3] = gen_rtx_MEM (word_mode, operands[2]);
685           operands[4]
686             = adjust_address (operands[3], word_mode, UNITS_PER_WORD);
687           operands[5]
688             = adjust_address (operands[4], word_mode, UNITS_PER_WORD);
689           operands[6]
690             = adjust_address (operands[5], word_mode, UNITS_PER_WORD);
691           output_asm_insn ("lda %1,%2\n\tld     %3,%0\n\tld     %4,%D0\n\tld    %5,%E0\n\tld    %6,%F0", operands);
692           return "";
693         }
694       else
695         return "ldq     %1,%0";
696     }
697   else if (GET_CODE (dst) == MEM
698            && GET_CODE (src) == REG)
699     {
700       if (REGNO (src) & 3)
701         {
702           operands[0] = dst;
703           operands[1] = adjust_address (dst, word_mode, UNITS_PER_WORD);
704           operands[2] = adjust_address (dst, word_mode, 2 * UNITS_PER_WORD);
705           operands[3] = adjust_address (dst, word_mode, 3 * UNITS_PER_WORD);
706           if (! memory_address_p (word_mode, XEXP (operands[3], 0)))
707             abort ();
708           operands[4] = src;
709           output_asm_insn ("st  %4,%0\n\tst     %D4,%1\n\tst    %E4,%2\n\tst    %F4,%3", operands);
710           return "";
711         }
712       return "stq       %1,%0";
713     }
714   else
715     abort ();
716 }
717
718 /* Output assembler to move a quad word zero.  */
719
720 const char *
721 i960_output_move_quad_zero (dst)
722      rtx dst;
723 {
724   rtx operands[4];
725
726   operands[0] = dst;
727     {
728       operands[1] = adjust_address (dst, word_mode, 4);
729       operands[2] = adjust_address (dst, word_mode, 8);
730       operands[3] = adjust_address (dst, word_mode, 12);
731       output_asm_insn ("st      g14,%0\n\tst    g14,%1\n\tst    g14,%2\n\tst    g14,%3", operands);
732     }
733   return "";
734 }
735
736 \f
737 /* Emit insns to load a constant to non-floating point registers.
738    Uses several strategies to try to use as few insns as possible.  */
739
740 const char *
741 i960_output_ldconst (dst, src)
742      register rtx dst, src;
743 {
744   register int rsrc1;
745   register unsigned rsrc2;
746   enum machine_mode mode = GET_MODE (dst);
747   rtx operands[4];
748
749   operands[0] = operands[2] = dst;
750   operands[1] = operands[3] = src;
751
752   /* Anything that isn't a compile time constant, such as a SYMBOL_REF,
753      must be a ldconst insn.  */
754
755   if (GET_CODE (src) != CONST_INT && GET_CODE (src) != CONST_DOUBLE)
756     {
757       output_asm_insn ("ldconst %1,%0", operands);
758       return "";
759     }
760   else if (mode == XFmode)
761     {
762       REAL_VALUE_TYPE d;
763       long value_long[3];
764       int i;
765
766       if (fp_literal_zero (src, XFmode))
767         return "movt    0,%0";
768
769       REAL_VALUE_FROM_CONST_DOUBLE (d, src);
770       REAL_VALUE_TO_TARGET_LONG_DOUBLE (d, value_long);
771
772       output_asm_insn ("# ldconst       %1,%0",operands);
773
774       for (i = 0; i < 3; i++)
775         {
776           operands[0] = gen_rtx_REG (SImode, REGNO (dst) + i);
777           operands[1] = GEN_INT (value_long[i]);
778           output_asm_insn (i960_output_ldconst (operands[0], operands[1]),
779                            operands);
780         }
781
782       return ""; 
783    }
784   else if (mode == DFmode)
785     {
786       rtx first, second;
787
788       if (fp_literal_zero (src, DFmode))
789         return "movl    0,%0";
790
791       split_double (src, &first, &second);
792
793       output_asm_insn ("# ldconst       %1,%0",operands);
794
795       operands[0] = gen_rtx_REG (SImode, REGNO (dst));
796       operands[1] = first;
797       output_asm_insn (i960_output_ldconst (operands[0], operands[1]),
798                       operands);
799       operands[0] = gen_rtx_REG (SImode, REGNO (dst) + 1);
800       operands[1] = second;
801       output_asm_insn (i960_output_ldconst (operands[0], operands[1]),
802                       operands);
803       return "";
804     }
805   else if (mode == SFmode)
806     {
807       REAL_VALUE_TYPE d;
808       long value;
809
810       REAL_VALUE_FROM_CONST_DOUBLE (d, src);
811       REAL_VALUE_TO_TARGET_SINGLE (d, value);
812
813       output_asm_insn ("# ldconst       %1,%0",operands);
814       operands[0] = gen_rtx_REG (SImode, REGNO (dst));
815       operands[1] = GEN_INT (value);
816       output_asm_insn (i960_output_ldconst (operands[0], operands[1]),
817                       operands);
818       return "";
819     }
820   else if (mode == TImode)
821     {
822       /* ??? This is currently not handled at all.  */
823       abort ();
824
825       /* Note: lowest order word goes in lowest numbered reg.  */
826       rsrc1 = INTVAL (src);
827       if (rsrc1 >= 0 && rsrc1 < 32)
828         return "movq    %1,%0";
829       else
830         output_asm_insn ("movq\t0,%0\t# ldconstq %1,%0",operands);
831       /* Go pick up the low-order word.  */
832     }
833   else if (mode == DImode)
834     {
835       rtx upperhalf, lowerhalf, xoperands[2];
836
837       if (GET_CODE (src) == CONST_DOUBLE || GET_CODE (src) == CONST_INT)
838         split_double (src, &lowerhalf, &upperhalf);
839
840       else
841         abort ();
842
843       /* Note: lowest order word goes in lowest numbered reg.  */
844       /* Numbers from 0 to 31 can be handled with a single insn.  */
845       rsrc1 = INTVAL (lowerhalf);
846       if (upperhalf == const0_rtx && rsrc1 >= 0 && rsrc1 < 32)
847         return "movl    %1,%0";
848
849       /* Output the upper half with a recursive call.  */
850       xoperands[0] = gen_rtx_REG (SImode, REGNO (dst) + 1);
851       xoperands[1] = upperhalf;
852       output_asm_insn (i960_output_ldconst (xoperands[0], xoperands[1]),
853                        xoperands);
854       /* The lower word is emitted as normally.  */
855     }
856   else
857     {
858       rsrc1 = INTVAL (src);
859       if (mode == QImode)
860         {
861           if (rsrc1 > 0xff)
862             rsrc1 &= 0xff;
863         }
864       else if (mode == HImode)
865         {
866           if (rsrc1 > 0xffff)
867             rsrc1 &= 0xffff;
868         }
869     }
870
871   if (rsrc1 >= 0)
872     {
873       /* ldconst        0..31,X         ->      mov     0..31,X  */
874       if (rsrc1 < 32)
875         {
876           if (i960_last_insn_type == I_TYPE_REG && TARGET_C_SERIES)
877             return "lda %1,%0";
878           return "mov   %1,%0";
879         }
880
881       /* ldconst        32..63,X        ->      add     31,nn,X  */
882       if (rsrc1 < 63)
883         {
884           if (i960_last_insn_type == I_TYPE_REG && TARGET_C_SERIES)
885             return "lda %1,%0";
886           operands[1] = GEN_INT (rsrc1 - 31);
887           output_asm_insn ("addo\t31,%1,%0\t# ldconst %3,%0", operands);
888           return "";
889         }
890     }
891   else if (rsrc1 < 0)
892     {
893       /* ldconst        -1..-31         ->      sub     0,0..31,X  */
894       if (rsrc1 >= -31)
895         {
896           /* return 'sub -(%1),0,%0' */
897           operands[1] = GEN_INT (- rsrc1);
898           output_asm_insn ("subo\t%1,0,%0\t# ldconst %3,%0", operands);
899           return "";
900         }
901       
902       /* ldconst        -32             ->      not     31,X  */
903       if (rsrc1 == -32)
904         {
905           operands[1] = GEN_INT (~rsrc1);
906           output_asm_insn ("not\t%1,%0  # ldconst %3,%0", operands);
907           return "";
908         }
909     }
910
911   /* If const is a single bit.  */
912   if (bitpos (rsrc1) >= 0)
913     {
914       operands[1] = GEN_INT (bitpos (rsrc1));
915       output_asm_insn ("setbit\t%1,0,%0\t# ldconst %3,%0", operands);
916       return "";
917     }
918
919   /* If const is a bit string of less than 6 bits (1..31 shifted).  */
920   if (is_mask (rsrc1))
921     {
922       int s, e;
923
924       if (bitstr (rsrc1, &s, &e) < 6)
925         {
926           rsrc2 = ((unsigned int) rsrc1) >> s;
927           operands[1] = GEN_INT (rsrc2);
928           operands[2] = GEN_INT (s);
929           output_asm_insn ("shlo\t%2,%1,%0\t# ldconst %3,%0", operands);
930           return "";
931         }
932     }
933
934   /* Unimplemented cases:
935      const is in range 0..31 but rotated around end of word:
936      ror        31,3,g0 -> ldconst 0xe0000003,g0
937    
938      and any 2 instruction cases that might be worthwhile  */
939   
940   output_asm_insn ("ldconst     %1,%0", operands);
941   return "";
942 }
943
944 /* Determine if there is an opportunity for a bypass optimization.
945    Bypass succeeds on the 960K* if the destination of the previous
946    instruction is the second operand of the current instruction.
947    Bypass always succeeds on the C*.
948  
949    Return 1 if the pattern should interchange the operands.
950
951    CMPBR_FLAG is true if this is for a compare-and-branch insn.
952    OP1 and OP2 are the two source operands of a 3 operand insn.  */
953
954 int
955 i960_bypass (insn, op1, op2, cmpbr_flag)
956      register rtx insn, op1, op2;
957      int cmpbr_flag;
958 {
959   register rtx prev_insn, prev_dest;
960
961   if (TARGET_C_SERIES)
962     return 0;
963
964   /* Can't do this if op1 isn't a register.  */
965   if (! REG_P (op1))
966     return 0;
967
968   /* Can't do this for a compare-and-branch if both ops aren't regs.  */
969   if (cmpbr_flag && ! REG_P (op2))
970     return 0;
971
972   prev_insn = prev_real_insn (insn);
973
974   if (prev_insn && GET_CODE (prev_insn) == INSN
975       && GET_CODE (PATTERN (prev_insn)) == SET)
976     {
977       prev_dest = SET_DEST (PATTERN (prev_insn));
978       if ((GET_CODE (prev_dest) == REG && REGNO (prev_dest) == REGNO (op1))
979           || (GET_CODE (prev_dest) == SUBREG
980               && GET_CODE (SUBREG_REG (prev_dest)) == REG
981               && REGNO (SUBREG_REG (prev_dest)) == REGNO (op1)))
982         return 1;
983     }
984   return 0;
985 }
986 \f
987 /* Output the code which declares the function name.  This also handles
988    leaf routines, which have special requirements, and initializes some
989    global variables.  */
990
991 void
992 i960_function_name_declare (file, name, fndecl)
993      FILE *file;
994      const char *name;
995      tree fndecl;
996 {
997   register int i, j;
998   int leaf_proc_ok;
999   rtx insn;
1000
1001   /* Increment global return label.  */
1002
1003   ret_label++;
1004
1005   /* Compute whether tail calls and leaf routine optimizations can be performed
1006      for this function.  */
1007
1008   if (TARGET_TAILCALL)
1009     tail_call_ok = 1;
1010   else
1011     tail_call_ok = 0;
1012
1013   if (TARGET_LEAFPROC)
1014     leaf_proc_ok = 1;
1015   else
1016     leaf_proc_ok = 0;
1017
1018   /* Even if nobody uses extra parms, can't have leafproc or tail calls if
1019      argblock, because argblock uses g14 implicitly.  */
1020
1021   if (current_function_args_size != 0 || VARARGS_STDARG_FUNCTION (fndecl))
1022     {
1023       tail_call_ok = 0;
1024       leaf_proc_ok = 0;
1025     }
1026       
1027   /* See if caller passes in an address to return value. */
1028
1029   if (aggregate_value_p (DECL_RESULT (fndecl)))
1030     {
1031       tail_call_ok = 0;
1032       leaf_proc_ok = 0;
1033     }
1034
1035   /* Can not use tail calls or make this a leaf routine if there is a non
1036      zero frame size.  */
1037
1038   if (get_frame_size () != 0)
1039     leaf_proc_ok = 0;
1040
1041   /* I don't understand this condition, and do not think that it is correct.
1042      Apparently this is just checking whether the frame pointer is used, and
1043      we can't trust regs_ever_live[fp] since it is (almost?) always set.  */
1044
1045   if (tail_call_ok)
1046     for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
1047       if (GET_CODE (insn) == INSN
1048           && reg_mentioned_p (frame_pointer_rtx, insn))
1049         {
1050           tail_call_ok = 0;
1051           break;
1052         }
1053
1054   /* Check for CALL insns.  Can not be a leaf routine if there are any.  */
1055
1056   if (leaf_proc_ok)
1057     for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
1058       if (GET_CODE (insn) == CALL_INSN)
1059         {
1060           leaf_proc_ok = 0;
1061           break;
1062         }
1063
1064   /* Can not be a leaf routine if any non-call clobbered registers are
1065      used in this function.  */
1066
1067   if (leaf_proc_ok)
1068     for (i = 0, j = 0; i < FIRST_PSEUDO_REGISTER; i++)
1069       if (regs_ever_live[i]
1070           && ((! call_used_regs[i]) || (i > 7 && i < 12)))
1071         {
1072           /* Global registers.  */
1073           if (i < 16 && i > 7 && i != 13)
1074             leaf_proc_ok = 0;
1075           /* Local registers.  */
1076           else if (i < 32)
1077             leaf_proc_ok = 0;
1078         }
1079
1080   /* Now choose a leaf return register, if we can find one, and if it is
1081      OK for this to be a leaf routine.  */
1082
1083   i960_leaf_ret_reg = -1;
1084
1085   if (optimize && leaf_proc_ok)
1086     {
1087       for (i960_leaf_ret_reg = -1, i = 0; i < 8; i++)
1088         if (regs_ever_live[i] == 0)
1089           {
1090             i960_leaf_ret_reg = i;
1091             regs_ever_live[i] = 1;
1092             break;
1093           }
1094     }
1095
1096   /* Do this after choosing the leaf return register, so it will be listed
1097      if one was chosen.  */
1098
1099   fprintf (file, "\t#  Function '%s'\n", (name[0] == '*' ? &name[1] : name));
1100   fprintf (file, "\t#  Registers used: ");
1101
1102   for (i = 0, j = 0; i < FIRST_PSEUDO_REGISTER; i++)
1103     {
1104       if (regs_ever_live[i])
1105         {
1106           fprintf (file, "%s%s ", reg_names[i], call_used_regs[i] ? "" : "*");
1107
1108           if (i > 15 && j == 0)
1109             {
1110               fprintf (file,"\n\t#\t\t   ");
1111               j++;
1112             }
1113         }
1114     }
1115
1116   fprintf (file, "\n");
1117
1118   if (i960_leaf_ret_reg >= 0)
1119     {
1120       /* Make it a leaf procedure.  */
1121
1122       if (TREE_PUBLIC (fndecl))
1123         fprintf (file,"\t.globl\t%s.lf\n", (name[0] == '*' ? &name[1] : name));
1124
1125       fprintf (file, "\t.leafproc\t");
1126       assemble_name (file, name);
1127       fprintf (file, ",%s.lf\n", (name[0] == '*' ? &name[1] : name));
1128       ASM_OUTPUT_LABEL (file, name);
1129       fprintf (file, "\tlda    Li960R%d,g14\n", ret_label);
1130       fprintf (file, "%s.lf:\n", (name[0] == '*' ? &name[1] : name));
1131       fprintf (file, "\tmov    g14,g%d\n", i960_leaf_ret_reg);
1132
1133       if (TARGET_C_SERIES)
1134         {
1135           fprintf (file, "\tlda    0,g14\n");
1136           i960_last_insn_type = I_TYPE_MEM;
1137         }
1138       else
1139         {
1140           fprintf (file, "\tmov    0,g14\n");
1141           i960_last_insn_type = I_TYPE_REG;
1142         }
1143     }
1144   else
1145     {
1146       ASM_OUTPUT_LABEL (file, name);
1147       i960_last_insn_type = I_TYPE_CTRL; 
1148     }
1149 }
1150 \f
1151 /* Compute and return the frame size.  */
1152
1153 int
1154 compute_frame_size (size)
1155      int size;
1156 {
1157   int actual_fsize;
1158   int outgoing_args_size = current_function_outgoing_args_size;
1159
1160   /* The STARTING_FRAME_OFFSET is totally hidden to us as far
1161      as size is concerned.  */
1162   actual_fsize = (size + 15) & -16;
1163   actual_fsize += (outgoing_args_size + 15) & -16;
1164
1165   return actual_fsize;
1166 }
1167
1168 /* Here register group is range of registers which can be moved by
1169    one i960 instruction. */
1170
1171 struct reg_group
1172 {
1173   char start_reg;
1174   char length;
1175 };
1176
1177 static int i960_form_reg_groups PARAMS ((int, int, int *, int, struct reg_group *));
1178 static int i960_reg_group_compare PARAMS ((const void *, const void *));
1179 static int i960_split_reg_group PARAMS ((struct reg_group *, int, int));
1180 static void i960_arg_size_and_align PARAMS ((enum machine_mode, tree, int *, int *));
1181
1182 /* The following functions forms the biggest as possible register
1183    groups with registers in STATE.  REGS contain states of the
1184    registers in range [start, finish_reg).  The function returns the
1185    number of groups formed. */
1186 static int
1187 i960_form_reg_groups (start_reg, finish_reg, regs, state, reg_groups)
1188      int start_reg;
1189      int finish_reg;
1190      int *regs;
1191      int state;
1192      struct reg_group *reg_groups;
1193 {
1194   int i;
1195   int nw = 0;
1196
1197   for (i = start_reg; i < finish_reg; )
1198     {
1199       if (regs [i] != state)
1200         {
1201           i++;
1202           continue;
1203         }
1204       else if (i % 2 != 0 || regs [i + 1] != state)
1205         reg_groups [nw].length = 1;
1206       else if (i % 4 != 0 || regs [i + 2] != state)
1207         reg_groups [nw].length = 2;
1208       else if (regs [i + 3] != state)
1209         reg_groups [nw].length = 3;
1210       else
1211         reg_groups [nw].length = 4;
1212       reg_groups [nw].start_reg = i;
1213       i += reg_groups [nw].length;
1214       nw++;
1215     }
1216   return nw;
1217 }
1218
1219 /* We sort register winodws in descending order by length. */
1220 static int
1221 i960_reg_group_compare (group1, group2)
1222      const void *group1;
1223      const void *group2;
1224 {
1225   const struct reg_group *w1 = group1;
1226   const struct reg_group *w2 = group2;
1227
1228   if (w1->length > w2->length)
1229     return -1;
1230   else if (w1->length < w2->length)
1231     return 1;
1232   else
1233     return 0;
1234 }
1235
1236 /* Split the first register group in REG_GROUPS on subgroups one of
1237    which will contain SUBGROUP_LENGTH registers.  The function
1238    returns new number of winodws. */
1239 static int
1240 i960_split_reg_group (reg_groups, nw, subgroup_length)
1241      struct reg_group *reg_groups;
1242      int nw;
1243      int subgroup_length;
1244 {
1245   if (subgroup_length < reg_groups->length - subgroup_length)
1246     /* This guarantees correct alignments of the two subgroups for
1247        i960 (see spliting for the group length 2, 3, 4).  More
1248        generalized algorithm would require splitting the group more
1249        two subgroups. */
1250     subgroup_length = reg_groups->length - subgroup_length;
1251   /* More generalized algorithm would require to try merging
1252      subgroups here.  But in case i960 it always results in failure
1253      because of register group alignment. */
1254   reg_groups[nw].length = reg_groups->length - subgroup_length;
1255   reg_groups[nw].start_reg = reg_groups->start_reg + subgroup_length;
1256   nw++;
1257   reg_groups->length = subgroup_length;
1258   qsort (reg_groups, nw, sizeof (struct reg_group), i960_reg_group_compare);
1259   return nw;
1260 }
1261
1262 /* Output code for the function prologue.  */
1263
1264 void
1265 i960_function_prologue (file, size)
1266      FILE *file;
1267      unsigned int size;
1268 {
1269   register int i, j, nr;
1270   int n_saved_regs = 0;
1271   int n_remaining_saved_regs;
1272   int lvar_size;
1273   int actual_fsize, offset;
1274   int gnw, lnw;
1275   struct reg_group *g, *l;
1276   char tmpstr[1000];
1277   /* -1 if reg must be saved on proc entry, 0 if available, 1 if saved
1278      somewhere.  */
1279   int regs[FIRST_PSEUDO_REGISTER];
1280   /* All global registers (which must be saved) divided by groups. */
1281   struct reg_group global_reg_groups [16];
1282   /* All local registers (which are available) divided by groups. */
1283   struct reg_group local_reg_groups [16];
1284
1285
1286   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1287     if (regs_ever_live[i]
1288         && ((! call_used_regs[i]) || (i > 7 && i < 12))
1289         /* No need to save the static chain pointer.  */
1290         && ! (i == STATIC_CHAIN_REGNUM && current_function_needs_context))
1291       {
1292         regs[i] = -1;
1293         /* Count global registers that need saving.  */
1294         if (i < 16)
1295           n_saved_regs++;
1296       }
1297     else
1298       regs[i] = 0;
1299
1300   n_remaining_saved_regs = n_saved_regs;
1301
1302   epilogue_string[0] = '\0';
1303
1304   if (profile_flag || profile_block_flag)
1305     {
1306       /* When profiling, we may use registers 20 to 27 to save arguments, so
1307          they can't be used here for saving globals.  J is the number of
1308          argument registers the mcount call will save.  */
1309       for (j = 7; j >= 0 && ! regs_ever_live[j]; j--)
1310         ;
1311
1312       for (i = 20; i <= j + 20; i++)
1313         regs[i] = -1;
1314     }
1315
1316   gnw = i960_form_reg_groups (0, 16, regs, -1, global_reg_groups);
1317   lnw = i960_form_reg_groups (19, 32, regs, 0, local_reg_groups);
1318   qsort (global_reg_groups, gnw, sizeof (struct reg_group),
1319          i960_reg_group_compare);
1320   qsort (local_reg_groups, lnw, sizeof (struct reg_group),
1321          i960_reg_group_compare);
1322   for (g = global_reg_groups, l = local_reg_groups; lnw != 0 && gnw != 0;)
1323     {
1324       if (g->length == l->length)
1325         {
1326           fprintf (file, "\tmov%s       %s,%s\n",
1327                    ((g->length == 4) ? "q" :
1328                     (g->length == 3) ? "t" :
1329                     (g->length == 2) ? "l" : ""),
1330                    reg_names[(unsigned char) g->start_reg],
1331                    reg_names[(unsigned char) l->start_reg]);
1332           sprintf (tmpstr, "\tmov%s     %s,%s\n",
1333                    ((g->length == 4) ? "q" :
1334                     (g->length == 3) ? "t" :
1335                     (g->length == 2) ? "l" : ""),
1336                    reg_names[(unsigned char) l->start_reg],
1337                    reg_names[(unsigned char) g->start_reg]);
1338           strcat (epilogue_string, tmpstr);
1339           n_remaining_saved_regs -= g->length;
1340           for (i = 0; i < g->length; i++)
1341             {
1342               regs [i + g->start_reg] = 1;
1343               regs [i + l->start_reg] = -1;
1344               regs_ever_live [i + l->start_reg] = 1;
1345             }
1346           g++;
1347           l++;
1348           gnw--;
1349           lnw--;
1350         }
1351       else if (g->length > l->length)
1352         gnw = i960_split_reg_group (g, gnw, l->length);
1353       else
1354         lnw = i960_split_reg_group (l, lnw, g->length);
1355     }
1356
1357   actual_fsize = compute_frame_size (size) + 4 * n_remaining_saved_regs;
1358 #if 0
1359   /* ??? The 1.2.1 compiler does this also.  This is meant to round the frame
1360      size up to the nearest multiple of 16.  I don't know whether this is
1361      necessary, or even desirable.
1362
1363      The frame pointer must be aligned, but the call instruction takes care of
1364      that.  If we leave the stack pointer unaligned, we may save a little on
1365      dynamic stack allocation.  And we don't lose, at least according to the
1366      i960CA manual.  */
1367   actual_fsize = (actual_fsize + 15) & ~0xF;
1368 #endif
1369
1370   /* Check stack limit if necessary.  */
1371   if (current_function_limit_stack)
1372     {
1373       rtx min_stack = stack_limit_rtx;
1374       if (actual_fsize != 0)
1375         min_stack = plus_constant (stack_limit_rtx, -actual_fsize);
1376
1377       /* Now, emulate a little bit of reload.  We want to turn 'min_stack'
1378          into an arith_operand.  Use register 20 as the temporary.  */
1379       if (legitimate_address_p (Pmode, min_stack, 1) 
1380           && !arith_operand (min_stack, Pmode))
1381         {
1382           rtx tmp = gen_rtx_MEM (Pmode, min_stack);
1383           fputs ("\tlda\t", file);
1384           i960_print_operand (file, tmp, 0);
1385           fputs (",r4\n", file);
1386           min_stack = gen_rtx_REG (Pmode, 20);
1387         }
1388       if (arith_operand (min_stack, Pmode))
1389         {
1390           fputs ("\tcmpo\tsp,", file);
1391           i960_print_operand (file, min_stack, 0);
1392           fputs ("\n\tfaultge.f\n", file);
1393         }
1394       else
1395         warning ("stack limit expression is not supported");
1396     }
1397
1398   /* Allocate space for register save and locals.  */
1399   if (actual_fsize > 0)
1400     {
1401       if (actual_fsize < 32)
1402         fprintf (file, "\taddo  %d,sp,sp\n", actual_fsize);
1403       else
1404         fprintf (file, "\tlda\t%d(sp),sp\n", actual_fsize);
1405     }
1406
1407   /* Take hardware register save area created by the call instruction
1408      into account, but store them before the argument block area.  */
1409   lvar_size = actual_fsize - compute_frame_size (0) - n_remaining_saved_regs * 4;
1410   offset = STARTING_FRAME_OFFSET + lvar_size;
1411   /* Save registers on stack if needed.  */
1412   /* ??? Is it worth to use the same algorithm as one for saving
1413      global registers in local registers? */
1414   for (i = 0, j = n_remaining_saved_regs; j > 0 && i < 16; i++)
1415     {
1416       if (regs[i] != -1)
1417         continue;
1418
1419       nr = 1;
1420
1421       if (i <= 14 && i % 2 == 0 && regs[i+1] == -1 && offset % 2 == 0)
1422         nr = 2;
1423
1424       if (nr == 2 && i <= 12 && i % 4 == 0 && regs[i+2] == -1
1425           && offset % 4 == 0)
1426         nr = 3;
1427
1428       if (nr == 3 && regs[i+3] == -1)
1429         nr = 4;
1430
1431       fprintf (file,"\tst%s     %s,%d(fp)\n",
1432                ((nr == 4) ? "q" :
1433                 (nr == 3) ? "t" :
1434                 (nr == 2) ? "l" : ""),
1435                reg_names[i], offset);
1436       sprintf (tmpstr,"\tld%s   %d(fp),%s\n",
1437                ((nr == 4) ? "q" :
1438                 (nr == 3) ? "t" :
1439                 (nr == 2) ? "l" : ""),
1440                offset, reg_names[i]);
1441       strcat (epilogue_string, tmpstr);
1442       i += nr-1;
1443       j -= nr;
1444       offset += nr * 4;
1445     }
1446
1447   if (actual_fsize == 0)
1448     return;
1449
1450   fprintf (file, "\t#Prologue stats:\n");
1451   fprintf (file, "\t#  Total Frame Size: %d bytes\n", actual_fsize);
1452
1453   if (lvar_size)
1454     fprintf (file, "\t#  Local Variable Size: %d bytes\n", lvar_size);
1455   if (n_saved_regs)
1456     fprintf (file, "\t#  Register Save Size: %d regs, %d bytes\n",
1457              n_saved_regs, n_saved_regs * 4);
1458   fprintf (file, "\t#End Prologue#\n");
1459 }
1460
1461 /* Output code for the function profiler.  */
1462
1463 void
1464 output_function_profiler (file, labelno)
1465      FILE *file;
1466      int labelno;
1467 {
1468   /* The last used parameter register.  */
1469   int last_parm_reg;
1470   int i, j, increment;
1471   int varargs_stdarg_function
1472     = VARARGS_STDARG_FUNCTION (current_function_decl);
1473
1474   /* Figure out the last used parameter register.  The proper thing to do
1475      is to walk incoming args of the function.  A function might have live
1476      parameter registers even if it has no incoming args.  Note that we
1477      don't have to save parameter registers g8 to g11 because they are
1478      call preserved.  */
1479
1480   /* See also output_function_prologue, which tries to use local registers
1481      for preserved call-saved global registers.  */
1482
1483   for (last_parm_reg = 7;
1484        last_parm_reg >= 0 && ! regs_ever_live[last_parm_reg];
1485        last_parm_reg--)
1486     ;
1487
1488   /* Save parameter registers in regs r4 (20) to r11 (27).  */
1489
1490   for (i = 0, j = 4; i <= last_parm_reg; i += increment, j += increment)
1491     {
1492       if (i % 4 == 0 && (last_parm_reg - i) >= 3)
1493         increment = 4;
1494       else if (i % 4 == 0 && (last_parm_reg - i) >= 2)
1495         increment = 3;
1496       else if (i % 2 == 0 && (last_parm_reg - i) >= 1)
1497         increment = 2;
1498       else
1499         increment = 1;
1500
1501       fprintf (file, "\tmov%s   g%d,r%d\n",
1502                (increment == 4 ? "q" : increment == 3 ? "t"
1503                 : increment == 2 ? "l": ""), i, j);
1504       }
1505
1506   /* If this function uses the arg pointer, then save it in r3 and then
1507      set it to zero.  */
1508
1509   if (current_function_args_size != 0 || varargs_stdarg_function)
1510     fprintf (file, "\tmov       g14,r3\n\tmov   0,g14\n");
1511
1512   /* Load location address into g0 and call mcount.  */
1513
1514   fprintf (file, "\tlda\tLP%d,g0\n\tcallx\tmcount\n", labelno);
1515
1516   /* If this function uses the arg pointer, restore it.  */
1517
1518   if (current_function_args_size != 0 || varargs_stdarg_function)
1519     fprintf (file, "\tmov       r3,g14\n");
1520
1521   /* Restore parameter registers.  */
1522
1523   for (i = 0, j = 4; i <= last_parm_reg; i += increment, j += increment)
1524     {
1525       if (i % 4 == 0 && (last_parm_reg - i) >= 3)
1526         increment = 4;
1527       else if (i % 4 == 0 && (last_parm_reg - i) >= 2)
1528         increment = 3;
1529       else if (i % 2 == 0 && (last_parm_reg - i) >= 1)
1530         increment = 2;
1531       else
1532         increment = 1;
1533
1534       fprintf (file, "\tmov%s   r%d,g%d\n",
1535                (increment == 4 ? "q" : increment == 3 ? "t"
1536                 : increment == 2 ? "l": ""), j, i);
1537     }
1538 }
1539
1540 /* Output code for the function epilogue.  */
1541
1542 void
1543 i960_function_epilogue (file, size)
1544      FILE *file;
1545      unsigned int size ATTRIBUTE_UNUSED;
1546 {
1547   if (i960_leaf_ret_reg >= 0)
1548     {
1549       fprintf (file, "Li960R%d: ret\n", ret_label);
1550       return;
1551     }
1552
1553   if (*epilogue_string == 0)
1554     {
1555       register rtx tmp;
1556         
1557       /* Emit a return insn, but only if control can fall through to here.  */
1558
1559       tmp = get_last_insn ();
1560       while (tmp)
1561         {
1562           if (GET_CODE (tmp) == BARRIER)
1563             return;
1564           if (GET_CODE (tmp) == CODE_LABEL)
1565             break;
1566           if (GET_CODE (tmp) == JUMP_INSN)
1567             {
1568               if (GET_CODE (PATTERN (tmp)) == RETURN)
1569                 return;
1570               break;
1571             }
1572           if (GET_CODE (tmp) == NOTE)
1573             {
1574               tmp = PREV_INSN (tmp);
1575               continue;
1576             }
1577           break;
1578         }
1579       fprintf (file, "Li960R%d: ret\n", ret_label);
1580       return;
1581     }
1582
1583   fprintf (file, "Li960R%d:\n", ret_label);
1584
1585   fprintf (file, "\t#EPILOGUE#\n");
1586
1587   /* Output the string created by the prologue which will restore all
1588      registers saved by the prologue.  */
1589
1590   if (epilogue_string[0] != '\0')
1591     fprintf (file, "%s", epilogue_string);
1592
1593   /* Must clear g14 on return if this function set it.
1594      Only varargs/stdarg functions modify g14.  */
1595
1596   if (VARARGS_STDARG_FUNCTION (current_function_decl))
1597     fprintf (file, "\tmov       0,g14\n");
1598
1599   fprintf (file, "\tret\n");
1600   fprintf (file, "\t#End Epilogue#\n");
1601 }
1602
1603 /* Output code for a call insn.  */
1604
1605 const char *
1606 i960_output_call_insn (target, argsize_rtx, arg_pointer, insn)
1607      register rtx target, argsize_rtx, arg_pointer, insn;
1608 {
1609   int argsize = INTVAL (argsize_rtx);
1610   rtx nexti = next_real_insn (insn);
1611   rtx operands[2];
1612   int varargs_stdarg_function
1613     = VARARGS_STDARG_FUNCTION (current_function_decl);
1614
1615   operands[0] = target;
1616   operands[1] = arg_pointer;
1617
1618   if (current_function_args_size != 0 || varargs_stdarg_function)
1619     output_asm_insn ("mov       g14,r3", operands);
1620
1621   if (argsize > 48)
1622     output_asm_insn ("lda       %a1,g14", operands);
1623   else if (current_function_args_size != 0 || varargs_stdarg_function)
1624     output_asm_insn ("mov       0,g14", operands);
1625
1626   /* The code used to assume that calls to SYMBOL_REFs could not be more
1627      than 24 bits away (b vs bx, callj vs callx).  This is not true.  This
1628      feature is now implemented by relaxing in the GNU linker.  It can convert
1629      bx to b if in range, and callx to calls/call/balx/bal as appropriate.  */
1630
1631   /* Nexti could be zero if the called routine is volatile.  */
1632   if (optimize && (*epilogue_string == 0) && argsize == 0 && tail_call_ok 
1633       && (nexti == 0 || GET_CODE (PATTERN (nexti)) == RETURN))
1634     {
1635       /* Delete following return insn.  */
1636       if (nexti && no_labels_between_p (insn, nexti))
1637         delete_insn (nexti);
1638       output_asm_insn ("bx      %0", operands);
1639       return "# notreached";
1640     }
1641
1642   output_asm_insn ("callx       %0", operands);
1643
1644   /* If the caller sets g14 to the address of the argblock, then the caller
1645      must clear it after the return.  */
1646
1647   if (current_function_args_size != 0 || varargs_stdarg_function)
1648     output_asm_insn ("mov       r3,g14", operands);
1649   else if (argsize > 48)
1650     output_asm_insn ("mov       0,g14", operands);
1651
1652   return "";
1653 }
1654
1655 /* Output code for a return insn.  */
1656
1657 const char *
1658 i960_output_ret_insn (insn)
1659      register rtx insn;
1660 {
1661   static char lbuf[20];
1662   
1663   if (*epilogue_string != 0)
1664     {
1665       if (! TARGET_CODE_ALIGN && next_real_insn (insn) == 0)
1666         return "";
1667
1668       sprintf (lbuf, "b Li960R%d", ret_label);
1669       return lbuf;
1670     }
1671
1672   /* Must clear g14 on return if this function set it.
1673      Only varargs/stdarg functions modify g14.  */
1674
1675   if (VARARGS_STDARG_FUNCTION (current_function_decl))
1676     output_asm_insn ("mov       0,g14", 0);
1677
1678   if (i960_leaf_ret_reg >= 0)
1679     {
1680       sprintf (lbuf, "bx        (%s)", reg_names[i960_leaf_ret_reg]);
1681       return lbuf;
1682     }
1683   return "ret";
1684 }
1685 \f
1686 /* Print the operand represented by rtx X formatted by code CODE.  */
1687
1688 void
1689 i960_print_operand (file, x, code)
1690      FILE *file;
1691      rtx x;
1692      int code;
1693 {
1694   enum rtx_code rtxcode = x ? GET_CODE (x) : NIL;
1695
1696   if (rtxcode == REG)
1697     {
1698       switch (code)
1699         {
1700         case 'D':
1701           /* Second reg of a double or quad.  */
1702           fprintf (file, "%s", reg_names[REGNO (x)+1]);
1703           break;
1704
1705         case 'E':
1706           /* Third reg of a quad.  */
1707           fprintf (file, "%s", reg_names[REGNO (x)+2]);
1708           break;
1709
1710         case 'F':
1711           /* Fourth reg of a quad.  */
1712           fprintf (file, "%s", reg_names[REGNO (x)+3]);
1713           break;
1714
1715         case 0:
1716           fprintf (file, "%s", reg_names[REGNO (x)]);
1717           break;
1718
1719         default:
1720           abort ();
1721         }
1722       return;
1723     }
1724   else if (rtxcode == MEM)
1725     {
1726       output_address (XEXP (x, 0));
1727       return;
1728     }
1729   else if (rtxcode == CONST_INT)
1730     {
1731       HOST_WIDE_INT val = INTVAL (x);
1732       if (code == 'C')
1733         val = ~val;
1734       if (val > 9999 || val < -999)
1735         fprintf (file, "0x%x", val);
1736       else
1737         fprintf (file, "%d", val);
1738       return;
1739     }
1740   else if (rtxcode == CONST_DOUBLE)
1741     {
1742       REAL_VALUE_TYPE d;
1743       char dstr[30];
1744
1745       if (x == CONST0_RTX (GET_MODE (x)))
1746         {
1747           fprintf (file, "0f0.0");
1748           return;
1749         }
1750       else if (x == CONST1_RTX (GET_MODE (x)))
1751         {
1752           fprintf (file, "0f1.0");
1753           return;
1754         }
1755
1756       REAL_VALUE_FROM_CONST_DOUBLE (d, x);
1757       REAL_VALUE_TO_DECIMAL (d, "%#g", dstr);
1758       fprintf (file, "0f%s", dstr);
1759       return;
1760     }
1761
1762   switch(code)
1763     {
1764     case 'B':
1765       /* Branch or jump, depending on assembler.  */
1766       if (TARGET_ASM_COMPAT)
1767         fputs ("j", file);
1768       else
1769         fputs ("b", file);
1770       break;
1771
1772     case 'S':
1773       /* Sign of condition.  */
1774       if ((rtxcode == EQ) || (rtxcode == NE) || (rtxcode == GTU)
1775           || (rtxcode == LTU) || (rtxcode == GEU) || (rtxcode == LEU))
1776         fputs ("o", file);
1777       else if ((rtxcode == GT) || (rtxcode == LT)
1778           || (rtxcode == GE) || (rtxcode == LE))
1779         fputs ("i", file);
1780       else
1781         abort();
1782       break;
1783
1784     case 'I':
1785       /* Inverted condition.  */
1786       rtxcode = reverse_condition (rtxcode);
1787       goto normal;
1788
1789     case 'X':
1790       /* Inverted condition w/ reversed operands.  */
1791       rtxcode = reverse_condition (rtxcode);
1792       /* Fallthrough.  */
1793
1794     case 'R':
1795       /* Reversed operand condition.  */
1796       rtxcode = swap_condition (rtxcode);
1797       /* Fallthrough.  */
1798
1799     case 'C':
1800       /* Normal condition.  */
1801     normal:
1802       if (rtxcode == EQ)  { fputs ("e", file); return; }
1803       else if (rtxcode == NE)  { fputs ("ne", file); return; }
1804       else if (rtxcode == GT)  { fputs ("g", file); return; }
1805       else if (rtxcode == GTU) { fputs ("g", file); return; }
1806       else if (rtxcode == LT)  { fputs ("l", file); return; }
1807       else if (rtxcode == LTU) { fputs ("l", file); return; }
1808       else if (rtxcode == GE)  { fputs ("ge", file); return; }
1809       else if (rtxcode == GEU) { fputs ("ge", file); return; }
1810       else if (rtxcode == LE)  { fputs ("le", file); return; }
1811       else if (rtxcode == LEU) { fputs ("le", file); return; }
1812       else abort ();
1813       break;
1814
1815     case '+':
1816       /* For conditional branches, substitute ".t" or ".f".  */
1817       if (TARGET_BRANCH_PREDICT)
1818         {
1819           x = find_reg_note (current_output_insn, REG_BR_PROB, 0);
1820           if (x)
1821             {
1822               int pred_val = INTVAL (XEXP (x, 0));
1823               fputs ((pred_val < REG_BR_PROB_BASE / 2 ? ".f" : ".t"), file);
1824             }
1825         }
1826       break;
1827
1828     case 0:
1829       output_addr_const (file, x);
1830       break;
1831
1832     default:
1833       abort ();
1834     }
1835
1836   return;
1837 }
1838 \f
1839 /* Print a memory address as an operand to reference that memory location.
1840
1841    This is exactly the same as legitimate_address_p, except that it the prints
1842    addresses instead of recognizing them.  */
1843
1844 void
1845 i960_print_operand_addr (file, addr)
1846      FILE *file;
1847      register rtx addr;
1848 {
1849   rtx breg, ireg;
1850   rtx scale, offset;
1851
1852   ireg = 0;
1853   breg = 0;
1854   offset = 0;
1855   scale = const1_rtx;
1856
1857   if (GET_CODE (addr) == REG)
1858     breg = addr;
1859   else if (CONSTANT_P (addr))
1860     offset = addr;
1861   else if (GET_CODE (addr) == PLUS)
1862     {
1863       rtx op0, op1;
1864
1865       op0 = XEXP (addr, 0);
1866       op1 = XEXP (addr, 1);
1867
1868       if (GET_CODE (op0) == REG)
1869         {
1870           breg = op0;
1871           if (GET_CODE (op1) == REG)
1872             ireg = op1;
1873           else if (CONSTANT_P (op1))
1874             offset = op1;
1875           else
1876             abort ();
1877         }
1878       else if (GET_CODE (op0) == PLUS)
1879         {
1880           if (GET_CODE (XEXP (op0, 0)) == MULT)
1881             {
1882               ireg = XEXP (XEXP (op0, 0), 0);
1883               scale = XEXP (XEXP (op0, 0), 1);
1884               if (GET_CODE (XEXP (op0, 1)) == REG)
1885                 {
1886                   breg = XEXP (op0, 1);
1887                   offset = op1;
1888                 }
1889               else
1890                 abort ();
1891             }
1892           else if (GET_CODE (XEXP (op0, 0)) == REG)
1893             {
1894               breg = XEXP (op0, 0);
1895               if (GET_CODE (XEXP (op0, 1)) == REG)
1896                 {
1897                   ireg = XEXP (op0, 1);
1898                   offset = op1;
1899                 }
1900               else
1901                 abort ();
1902             }
1903           else
1904             abort ();
1905         }
1906       else if (GET_CODE (op0) == MULT)
1907         {
1908           ireg = XEXP (op0, 0);
1909           scale = XEXP (op0, 1);
1910           if (GET_CODE (op1) == REG)
1911             breg = op1;
1912           else if (CONSTANT_P (op1))
1913             offset = op1;
1914           else
1915             abort ();
1916         }
1917       else
1918         abort ();
1919     }
1920   else if (GET_CODE (addr) == MULT)
1921     {
1922       ireg = XEXP (addr, 0);
1923       scale = XEXP (addr, 1);
1924     }
1925   else
1926     abort ();
1927
1928   if (offset)
1929     output_addr_const (file, offset);
1930   if (breg)
1931     fprintf (file, "(%s)", reg_names[REGNO (breg)]);
1932   if (ireg)
1933     fprintf (file, "[%s*%d]", reg_names[REGNO (ireg)], INTVAL (scale));
1934 }
1935 \f
1936 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1937    that is a valid memory address for an instruction.
1938    The MODE argument is the machine mode for the MEM expression
1939    that wants to use this address.
1940
1941         On 80960, legitimate addresses are:
1942                 base                            ld      (g0),r0
1943                 disp    (12 or 32 bit)          ld      foo,r0
1944                 base + index                    ld      (g0)[g1*1],r0
1945                 base + displ                    ld      0xf00(g0),r0
1946                 base + index*scale + displ      ld      0xf00(g0)[g1*4],r0
1947                 index*scale + base              ld      (g0)[g1*4],r0
1948                 index*scale + displ             ld      0xf00[g1*4],r0
1949                 index*scale                     ld      [g1*4],r0
1950                 index + base + displ            ld      0xf00(g0)[g1*1],r0
1951
1952         In each case, scale can be 1, 2, 4, 8, or 16.  */
1953
1954 /* This is exactly the same as i960_print_operand_addr, except that
1955    it recognizes addresses instead of printing them.
1956
1957    It only recognizes address in canonical form.  LEGITIMIZE_ADDRESS should
1958    convert common non-canonical forms to canonical form so that they will
1959    be recognized.  */
1960
1961 /* These two macros allow us to accept either a REG or a SUBREG anyplace
1962    where a register is valid.  */
1963
1964 #define RTX_OK_FOR_BASE_P(X, STRICT)                                    \
1965   ((GET_CODE (X) == REG                                                 \
1966     && (STRICT ? REG_OK_FOR_BASE_P_STRICT (X) : REG_OK_FOR_BASE_P (X))) \
1967    || (GET_CODE (X) == SUBREG                                           \
1968        && GET_CODE (SUBREG_REG (X)) == REG                              \
1969        && (STRICT ? REG_OK_FOR_BASE_P_STRICT (SUBREG_REG (X))           \
1970            : REG_OK_FOR_BASE_P (SUBREG_REG (X)))))
1971
1972 #define RTX_OK_FOR_INDEX_P(X, STRICT)                                   \
1973   ((GET_CODE (X) == REG                                                 \
1974     && (STRICT ? REG_OK_FOR_INDEX_P_STRICT (X) : REG_OK_FOR_INDEX_P (X)))\
1975    || (GET_CODE (X) == SUBREG                                           \
1976        && GET_CODE (SUBREG_REG (X)) == REG                              \
1977        && (STRICT ? REG_OK_FOR_INDEX_P_STRICT (SUBREG_REG (X))          \
1978            : REG_OK_FOR_INDEX_P (SUBREG_REG (X)))))
1979
1980 int
1981 legitimate_address_p (mode, addr, strict)
1982      enum machine_mode mode ATTRIBUTE_UNUSED;
1983      register rtx addr;
1984      int strict;
1985 {
1986   if (RTX_OK_FOR_BASE_P (addr, strict))
1987     return 1;
1988   else if (CONSTANT_P (addr))
1989     return 1;
1990   else if (GET_CODE (addr) == PLUS)
1991     {
1992       rtx op0, op1;
1993
1994       if (! TARGET_COMPLEX_ADDR && ! reload_completed)
1995         return 0;
1996
1997       op0 = XEXP (addr, 0);
1998       op1 = XEXP (addr, 1);
1999
2000       if (RTX_OK_FOR_BASE_P (op0, strict))
2001         {
2002           if (RTX_OK_FOR_INDEX_P (op1, strict))
2003             return 1;
2004           else if (CONSTANT_P (op1))
2005             return 1;
2006           else
2007             return 0;
2008         }
2009       else if (GET_CODE (op0) == PLUS)
2010         {
2011           if (GET_CODE (XEXP (op0, 0)) == MULT)
2012             {
2013               if (! (RTX_OK_FOR_INDEX_P (XEXP (XEXP (op0, 0), 0), strict)
2014                      && SCALE_TERM_P (XEXP (XEXP (op0, 0), 1))))
2015                 return 0;
2016
2017               if (RTX_OK_FOR_BASE_P (XEXP (op0, 1), strict)
2018                   && CONSTANT_P (op1))
2019                 return 1;
2020               else
2021                 return 0;
2022             }
2023           else if (RTX_OK_FOR_BASE_P (XEXP (op0, 0), strict))
2024             {
2025               if (RTX_OK_FOR_INDEX_P (XEXP (op0, 1), strict)
2026                   && CONSTANT_P (op1))
2027                 return 1;
2028               else
2029                 return 0;
2030             }
2031           else
2032             return 0;
2033         }
2034       else if (GET_CODE (op0) == MULT)
2035         {
2036           if (! (RTX_OK_FOR_INDEX_P (XEXP (op0, 0), strict)
2037                  && SCALE_TERM_P (XEXP (op0, 1))))
2038             return 0;
2039
2040           if (RTX_OK_FOR_BASE_P (op1, strict))
2041             return 1;
2042           else if (CONSTANT_P (op1))
2043             return 1;
2044           else
2045             return 0;
2046         }
2047       else
2048         return 0;
2049     }
2050   else if (GET_CODE (addr) == MULT)
2051     {
2052       if (! TARGET_COMPLEX_ADDR && ! reload_completed)
2053         return 0;
2054
2055       return (RTX_OK_FOR_INDEX_P (XEXP (addr, 0), strict)
2056               && SCALE_TERM_P (XEXP (addr, 1)));
2057     }
2058   else
2059     return 0;
2060 }
2061
2062 /* Try machine-dependent ways of modifying an illegitimate address
2063    to be legitimate.  If we find one, return the new, valid address.
2064    This macro is used in only one place: `memory_address' in explow.c.
2065
2066    This converts some non-canonical addresses to canonical form so they
2067    can be recognized.  */
2068
2069 rtx
2070 legitimize_address (x, oldx, mode)
2071      register rtx x;
2072      register rtx oldx ATTRIBUTE_UNUSED;
2073      enum machine_mode mode ATTRIBUTE_UNUSED;
2074
2075   if (GET_CODE (x) == SYMBOL_REF)
2076     {
2077       abort ();
2078       x = copy_to_reg (x);
2079     }
2080
2081   if (! TARGET_COMPLEX_ADDR && ! reload_completed)
2082     return x;
2083
2084   /* Canonicalize (plus (mult (reg) (const)) (plus (reg) (const)))
2085      into (plus (plus (mult (reg) (const)) (reg)) (const)).  This can be
2086      created by virtual register instantiation, register elimination, and
2087      similar optimizations.  */
2088   if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 0)) == MULT
2089       && GET_CODE (XEXP (x, 1)) == PLUS)
2090     x = gen_rtx_PLUS (Pmode,
2091                       gen_rtx_PLUS (Pmode, XEXP (x, 0), XEXP (XEXP (x, 1), 0)),
2092                       XEXP (XEXP (x, 1), 1));
2093
2094   /* Canonicalize (plus (plus (mult (reg) (const)) (plus (reg) (const))) const)
2095      into (plus (plus (mult (reg) (const)) (reg)) (const)).  */
2096   else if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 0)) == PLUS
2097            && GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT
2098            && GET_CODE (XEXP (XEXP (x, 0), 1)) == PLUS
2099            && CONSTANT_P (XEXP (x, 1)))
2100     {
2101       rtx constant, other;
2102
2103       if (GET_CODE (XEXP (x, 1)) == CONST_INT)
2104         {
2105           constant = XEXP (x, 1);
2106           other = XEXP (XEXP (XEXP (x, 0), 1), 1);
2107         }
2108       else if (GET_CODE (XEXP (XEXP (XEXP (x, 0), 1), 1)) == CONST_INT)
2109         {
2110           constant = XEXP (XEXP (XEXP (x, 0), 1), 1);
2111           other = XEXP (x, 1);
2112         }
2113       else
2114         constant = 0;
2115
2116       if (constant)
2117         x = gen_rtx_PLUS (Pmode,
2118                           gen_rtx_PLUS (Pmode, XEXP (XEXP (x, 0), 0),
2119                                         XEXP (XEXP (XEXP (x, 0), 1), 0)),
2120                           plus_constant (other, INTVAL (constant)));
2121     }
2122
2123   return x;
2124 }
2125 \f
2126 #if 0
2127 /* Return the most stringent alignment that we are willing to consider
2128    objects of size SIZE and known alignment ALIGN as having. */
2129    
2130 int
2131 i960_alignment (size, align)
2132      int size;
2133      int align;
2134 {
2135   int i;
2136
2137   if (! TARGET_STRICT_ALIGN)
2138     if (TARGET_IC_COMPAT2_0 || align >= 4)
2139       {
2140         i = i960_object_bytes_bitalign (size) / BITS_PER_UNIT;
2141         if (i > align)
2142           align = i;
2143       }
2144
2145   return align;
2146 }
2147 #endif
2148 \f
2149
2150 int
2151 hard_regno_mode_ok (regno, mode)
2152      int regno;
2153      enum machine_mode mode;
2154 {
2155   if (regno < 32)
2156     {
2157       switch (mode)
2158         {
2159         case CCmode: case CC_UNSmode: case CC_CHKmode:
2160           return 0;
2161
2162         case DImode: case DFmode:
2163           return (regno & 1) == 0;
2164
2165         case TImode: case XFmode:
2166           return (regno & 3) == 0;
2167
2168         default:
2169           return 1;
2170         }
2171     }
2172   else if (regno >= 32 && regno < 36)
2173     {
2174       switch (mode)
2175         {
2176         case SFmode: case DFmode: case XFmode:
2177         case SCmode: case DCmode:
2178           return 1;
2179
2180         default:
2181           return 0;
2182         }
2183     }
2184   else if (regno == 36)
2185     {
2186       switch (mode)
2187         {
2188         case CCmode: case CC_UNSmode: case CC_CHKmode:
2189           return 1;
2190
2191         default:
2192           return 0;
2193         }
2194     }
2195   else if (regno == 37)
2196     return 0;
2197
2198   abort ();
2199 }
2200
2201 \f
2202 /* Return the minimum alignment of an expression rtx X in bytes.  This takes
2203    advantage of machine specific facts, such as knowing that the frame pointer
2204    is always 16 byte aligned.  */
2205
2206 int
2207 i960_expr_alignment (x, size)
2208      rtx x;
2209      int size;
2210 {
2211   int align = 1;
2212
2213   if (x == 0)
2214     return 1;
2215
2216   switch (GET_CODE(x))
2217     {
2218     case CONST_INT:
2219       align = INTVAL(x);
2220
2221       if ((align & 0xf) == 0)
2222         align = 16;
2223       else if ((align & 0x7) == 0)
2224         align = 8;
2225       else if ((align & 0x3) == 0)
2226         align = 4;
2227       else if ((align & 0x1) == 0)
2228         align = 2;
2229       else
2230         align = 1;
2231       break;
2232
2233     case PLUS:
2234       align = MIN (i960_expr_alignment (XEXP (x, 0), size),
2235                    i960_expr_alignment (XEXP (x, 1), size));
2236       break;
2237
2238     case SYMBOL_REF:
2239       /* If this is a valid program, objects are guaranteed to be
2240          correctly aligned for whatever size the reference actually is. */
2241       align = i960_object_bytes_bitalign (size) / BITS_PER_UNIT;
2242       break;
2243
2244     case REG:
2245       if (REGNO (x) == FRAME_POINTER_REGNUM)
2246         align = 16;
2247       break;
2248
2249     case ASHIFT:
2250       align = i960_expr_alignment (XEXP (x, 0), size);
2251
2252       if (GET_CODE (XEXP (x, 1)) == CONST_INT)
2253         {
2254           align = align << INTVAL (XEXP (x, 1));
2255           align = MIN (align, 16);
2256         }
2257       break;
2258
2259     case MULT:
2260       align = (i960_expr_alignment (XEXP (x, 0), size) *
2261                i960_expr_alignment (XEXP (x, 1), size));
2262
2263       align = MIN (align, 16);
2264       break;
2265     default:
2266       break;
2267     }
2268
2269   return align;
2270 }
2271
2272 /* Return true if it is possible to reference both BASE and OFFSET, which
2273    have alignment at least as great as 4 byte, as if they had alignment valid
2274    for an object of size SIZE.  */
2275
2276 int
2277 i960_improve_align (base, offset, size)
2278      rtx base;
2279      rtx offset;
2280      int size;
2281 {
2282   int i, j;
2283
2284   /* We have at least a word reference to the object, so we know it has to
2285      be aligned at least to 4 bytes.  */
2286
2287   i = MIN (i960_expr_alignment (base, 4),
2288            i960_expr_alignment (offset, 4));
2289
2290   i = MAX (i, 4);
2291
2292   /* We know the size of the request.  If strict align is not enabled, we
2293      can guess that the alignment is OK for the requested size.  */
2294
2295   if (! TARGET_STRICT_ALIGN)
2296     if ((j = (i960_object_bytes_bitalign (size) / BITS_PER_UNIT)) > i)
2297       i = j;
2298
2299   return (i >= size);
2300 }
2301
2302 /* Return true if it is possible to access BASE and OFFSET, which have 4 byte
2303    (SImode) alignment as if they had 16 byte (TImode) alignment.  */
2304
2305 int
2306 i960_si_ti (base, offset)
2307      rtx base;
2308      rtx offset;
2309 {
2310   return i960_improve_align (base, offset, 16);
2311 }
2312
2313 /* Return true if it is possible to access BASE and OFFSET, which have 4 byte
2314    (SImode) alignment as if they had 8 byte (DImode) alignment.  */
2315
2316 int
2317 i960_si_di (base, offset)
2318      rtx base;
2319      rtx offset;
2320 {
2321   return i960_improve_align (base, offset, 8);
2322 }
2323 \f
2324 /* Return raw values of size and alignment (in words) for the data
2325    type being accessed.  These values will be rounded by the caller.  */
2326
2327 static void 
2328 i960_arg_size_and_align (mode, type, size_out, align_out)
2329      enum machine_mode mode;
2330      tree type;
2331      int *size_out;
2332      int *align_out;
2333 {
2334   int size, align;
2335
2336   /* Use formal alignment requirements of type being passed, except make
2337      it at least a word.  If we don't have a type, this is a library call,
2338      and the parm has to be of scalar type.  In this case, consider its
2339      formal alignment requirement to be its size in words.  */
2340
2341   if (mode == BLKmode)
2342     size = (int_size_in_bytes (type) + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
2343   else if (mode == VOIDmode)
2344     {
2345       /* End of parm list.  */
2346       if (type == 0 || TYPE_MODE (type) != VOIDmode)
2347         abort ();
2348       size = 1;
2349     }
2350   else
2351     size = (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
2352
2353   if (type == 0)
2354     {
2355       /* ??? This is a hack to properly correct the alignment of XFmode
2356          values without affecting anything else.  */
2357       if (size == 3)
2358         align = 4;
2359       else
2360         align = size;
2361     }
2362   else if (TYPE_ALIGN (type) >= BITS_PER_WORD)
2363     align = TYPE_ALIGN (type) / BITS_PER_WORD;
2364   else
2365     align = 1;
2366
2367   *size_out  = size;
2368   *align_out = align;
2369 }
2370
2371 /* On the 80960 the first 12 args are in registers and the rest are pushed.
2372    Any arg that is bigger than 4 words is placed on the stack and all
2373    subsequent arguments are placed on the stack.
2374
2375    Additionally, parameters with an alignment requirement stronger than
2376    a word must be aligned appropriately.  Note that this means that a
2377    64 bit object with a 32 bit alignment is not 64 bit aligned and may be
2378    passed in an odd/even register pair.  */
2379
2380 /* Update CUM to advance past an argument described by MODE and TYPE.  */
2381
2382 void
2383 i960_function_arg_advance (cum, mode, type, named)
2384      CUMULATIVE_ARGS *cum;
2385      enum machine_mode mode;
2386      tree type;
2387      int named ATTRIBUTE_UNUSED;
2388 {
2389   int size, align;
2390
2391   i960_arg_size_and_align (mode, type, &size, &align);
2392
2393   if (size > 4 || cum->ca_nstackparms != 0
2394       || (size + ROUND_PARM (cum->ca_nregparms, align)) > NPARM_REGS
2395       || MUST_PASS_IN_STACK (mode, type))
2396     {
2397       /* Indicate that all the registers are in use, even if all are not,
2398          so va_start will compute the right value.  */
2399       cum->ca_nregparms = NPARM_REGS;
2400       cum->ca_nstackparms = ROUND_PARM (cum->ca_nstackparms, align) + size;
2401     }
2402   else
2403     cum->ca_nregparms = ROUND_PARM (cum->ca_nregparms, align) + size;
2404 }
2405
2406 /* Return the register that the argument described by MODE and TYPE is
2407    passed in, or else return 0 if it is passed on the stack.  */
2408
2409 rtx
2410 i960_function_arg (cum, mode, type, named)
2411      CUMULATIVE_ARGS *cum;
2412      enum machine_mode mode;
2413      tree type;
2414      int named ATTRIBUTE_UNUSED;
2415 {
2416   rtx ret;
2417   int size, align;
2418
2419   if (mode == VOIDmode)
2420     return 0;
2421
2422   i960_arg_size_and_align (mode, type, &size, &align);
2423
2424   if (size > 4 || cum->ca_nstackparms != 0
2425       || (size + ROUND_PARM (cum->ca_nregparms, align)) > NPARM_REGS
2426       || MUST_PASS_IN_STACK (mode, type))
2427     {
2428       cum->ca_nstackparms = ROUND_PARM (cum->ca_nstackparms, align);
2429       ret = 0;
2430     }
2431   else
2432     {
2433       cum->ca_nregparms = ROUND_PARM (cum->ca_nregparms, align);
2434       ret = gen_rtx_REG (mode, cum->ca_nregparms);
2435     }
2436
2437   return ret;
2438 }
2439 \f
2440 /* Floating-point support.  */
2441
2442 void
2443 i960_output_long_double (file, value)
2444      FILE *file;
2445      REAL_VALUE_TYPE value;
2446 {
2447   long value_long[3];
2448   char dstr[30];
2449
2450   REAL_VALUE_TO_TARGET_LONG_DOUBLE (value, value_long);
2451   REAL_VALUE_TO_DECIMAL (value, "%.20g", dstr);
2452
2453   fprintf (file,
2454            "\t.word\t0x%08lx\t\t# %s\n\t.word\t0x%08lx\n\t.word\t0x%08lx\n",
2455            value_long[0], dstr, value_long[1], value_long[2]);
2456   fprintf (file, "\t.word\t0x0\n");
2457 }
2458
2459 void
2460 i960_output_double (file, value)
2461      FILE *file;
2462      REAL_VALUE_TYPE value;
2463 {
2464   long value_long[2];
2465   char dstr[30];
2466
2467   REAL_VALUE_TO_TARGET_DOUBLE (value, value_long);
2468   REAL_VALUE_TO_DECIMAL (value, "%.20g", dstr);
2469
2470   fprintf (file, "\t.word\t0x%08lx\t\t# %s\n\t.word\t0x%08lx\n",
2471            value_long[0], dstr, value_long[1]);
2472 }
2473   
2474 void
2475 i960_output_float (file, value)
2476      FILE *file;
2477      REAL_VALUE_TYPE value;
2478 {
2479   long value_long;
2480   char dstr[30];
2481
2482   REAL_VALUE_TO_TARGET_SINGLE (value, value_long);
2483   REAL_VALUE_TO_DECIMAL (value, "%.12g", dstr);
2484
2485   fprintf (file, "\t.word\t0x%08lx\t\t# %s (float)\n", value_long, dstr);
2486 }
2487 \f
2488 /* Return the number of bits that an object of size N bytes is aligned to.  */
2489
2490 int
2491 i960_object_bytes_bitalign (n)
2492      int n;
2493 {
2494   if (n > 8)      n = 128;
2495   else if (n > 4) n = 64;
2496   else if (n > 2) n = 32;
2497   else if (n > 1) n = 16;
2498   else            n = 8;
2499
2500   return n;
2501 }
2502
2503 /* Compute the alignment for an aggregate type TSIZE.
2504    Alignment is MAX (greatest member alignment,
2505                      MIN (pragma align, structure size alignment)).  */
2506
2507 int
2508 i960_round_align (align, tsize)
2509      int align;
2510      tree tsize;
2511 {
2512   int new_align;
2513
2514   if (! tsize || TREE_CODE (tsize) != INTEGER_CST)
2515     return align;
2516
2517   new_align = i960_object_bytes_bitalign (TREE_INT_CST_LOW (tsize)
2518                                           / BITS_PER_UNIT);
2519   /* Handle #pragma align.  */
2520   if (new_align > i960_maxbitalignment)
2521     new_align = i960_maxbitalignment;
2522
2523   if (align < new_align)
2524     align = new_align;
2525
2526   return align;
2527 }
2528 \f
2529 /* Do any needed setup for a varargs function.  For the i960, we must
2530    create a register parameter block if one doesn't exist, and then copy
2531    all register parameters to memory.  */
2532
2533 void
2534 i960_setup_incoming_varargs (cum, mode, type, pretend_size, no_rtl)
2535      CUMULATIVE_ARGS *cum;
2536      enum machine_mode mode ATTRIBUTE_UNUSED;
2537      tree type ATTRIBUTE_UNUSED;
2538      int *pretend_size ATTRIBUTE_UNUSED;
2539      int no_rtl;
2540 {
2541   /* Note: for a varargs fn with only a va_alist argument, this is 0.  */
2542   int first_reg = cum->ca_nregparms;
2543
2544   /* Copy only unnamed register arguments to memory.  If there are
2545      any stack parms, there are no unnamed arguments in registers, and
2546      an argument block was already allocated by the caller.
2547      Remember that any arg bigger than 4 words is passed on the stack as
2548      are all subsequent args.
2549
2550      If there are no stack arguments but there are exactly NPARM_REGS
2551      registers, either there were no extra arguments or the caller
2552      allocated an argument block. */
2553
2554   if (cum->ca_nstackparms == 0 && first_reg < NPARM_REGS && !no_rtl)
2555     {
2556       rtx label = gen_label_rtx ();
2557       rtx regblock;
2558
2559       /* If arg_pointer_rtx == 0, no arguments were passed on the stack
2560          and we need to allocate a chunk to save the registers (if any
2561          arguments were passed on the stack the caller would allocate the
2562          48 bytes as well).  We must allocate all 48 bytes (12*4) because
2563          va_start assumes it.  */
2564       emit_insn (gen_cmpsi (arg_pointer_rtx, const0_rtx));
2565       emit_jump_insn (gen_bne (label));
2566       emit_insn (gen_rtx_SET (VOIDmode, arg_pointer_rtx,
2567                               stack_pointer_rtx));
2568       emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
2569                               memory_address (SImode,
2570                                               plus_constant (stack_pointer_rtx,
2571                                                              48))));
2572       emit_label (label);
2573
2574       /* ??? Note that we unnecessarily store one extra register for stdarg
2575          fns.  We could optimize this, but it's kept as for now.  */
2576       regblock = gen_rtx_MEM (BLKmode,
2577                           plus_constant (arg_pointer_rtx,
2578                                          first_reg * 4));
2579       MEM_ALIAS_SET (regblock) = get_varargs_alias_set ();
2580       move_block_from_reg (first_reg, regblock,
2581                            NPARM_REGS - first_reg,
2582                            (NPARM_REGS - first_reg) * UNITS_PER_WORD);
2583     }
2584 }
2585
2586 /* Define the `__builtin_va_list' type for the ABI.  */
2587
2588 tree
2589 i960_build_va_list ()
2590 {
2591   return build_array_type (unsigned_type_node,
2592                            build_index_type (size_one_node));
2593 }
2594
2595 /* Implement `va_start' for varargs and stdarg.  */
2596
2597 void
2598 i960_va_start (stdarg_p, valist, nextarg)
2599      int stdarg_p ATTRIBUTE_UNUSED;
2600      tree valist;
2601      rtx nextarg ATTRIBUTE_UNUSED;
2602 {
2603   tree s, t, base, num;
2604
2605   /* The array type always decays to a pointer before we get here, so we
2606      can't use ARRAY_REF.  */
2607   base = build1 (INDIRECT_REF, unsigned_type_node, valist);
2608   num = build1 (INDIRECT_REF, unsigned_type_node,
2609                 build (PLUS_EXPR, unsigned_type_node, valist,
2610                        TYPE_SIZE_UNIT (TREE_TYPE (valist))));
2611
2612   s = make_tree (unsigned_type_node, arg_pointer_rtx);
2613   t = build (MODIFY_EXPR, unsigned_type_node, base, s);
2614   TREE_SIDE_EFFECTS (t) = 1;
2615   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
2616
2617   s = build_int_2 ((current_function_args_info.ca_nregparms
2618                     + current_function_args_info.ca_nstackparms) * 4, 0);
2619   t = build (MODIFY_EXPR, unsigned_type_node, num, s);
2620   TREE_SIDE_EFFECTS (t) = 1;
2621   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
2622 }
2623
2624 /* Implement `va_arg'.  */
2625
2626 rtx
2627 i960_va_arg (valist, type)
2628      tree valist, type;
2629 {
2630   HOST_WIDE_INT siz, ali;
2631   tree base, num, pad, next, this, t1, t2, int48;
2632   rtx addr_rtx;
2633
2634   /* The array type always decays to a pointer before we get here, so we
2635      can't use ARRAY_REF.  */
2636   base = build1 (INDIRECT_REF, unsigned_type_node, valist);
2637   num = build1 (INDIRECT_REF, unsigned_type_node,
2638                 build (PLUS_EXPR, unsigned_type_node, valist,
2639                        TYPE_SIZE_UNIT (TREE_TYPE (valist))));
2640
2641   /* Round up sizeof(type) to a word.  */
2642   siz = (int_size_in_bytes (type) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD;
2643
2644   /* Round up alignment to a word.  */
2645   ali = TYPE_ALIGN (type);
2646   if (ali < BITS_PER_WORD)
2647     ali = BITS_PER_WORD;
2648   ali /= BITS_PER_UNIT;
2649
2650   /* Align NUM appropriate for the argument.  */
2651   pad = fold (build (PLUS_EXPR, unsigned_type_node, num, 
2652                       build_int_2 (ali - 1, 0)));
2653   pad = fold (build (BIT_AND_EXPR, unsigned_type_node, pad,
2654                       build_int_2 (-ali, -1)));
2655   pad = save_expr (pad);
2656
2657   /* Increment VPAD past this argument.  */
2658   next = fold (build (PLUS_EXPR, unsigned_type_node, pad,
2659                       build_int_2 (siz, 0)));
2660   next = save_expr (next);
2661
2662   /* Find the offset for the current argument.  Mind peculiar overflow
2663      from registers to stack.  */
2664   int48 = build_int_2 (48, 0);
2665   if (siz > 16)
2666     t2 = integer_one_node;
2667   else
2668     t2 = fold (build (GT_EXPR, integer_type_node, next, int48));
2669   t1 = fold (build (LE_EXPR, integer_type_node, num, int48));
2670   t1 = fold (build (TRUTH_AND_EXPR, integer_type_node, t1, t2));
2671   this = fold (build (COND_EXPR, unsigned_type_node, t1, int48, pad));
2672
2673   /* Find the address for the current argument.  */
2674   t1 = fold (build (PLUS_EXPR, unsigned_type_node, base, this));
2675   t1 = build1 (NOP_EXPR, ptr_type_node, t1);
2676   addr_rtx = expand_expr (t1, NULL_RTX, Pmode, EXPAND_NORMAL);
2677
2678   /* Increment NUM.  */
2679   t1 = build (MODIFY_EXPR, unsigned_type_node, num, next);
2680   TREE_SIDE_EFFECTS (t1) = 1;
2681   expand_expr (t1, const0_rtx, VOIDmode, EXPAND_NORMAL);
2682   
2683   return addr_rtx;
2684 }
2685
2686 /* Calculate the final size of the reg parm stack space for the current
2687    function, based on how many bytes would be allocated on the stack.  */
2688
2689 int
2690 i960_final_reg_parm_stack_space (const_size, var_size)
2691      int const_size;
2692      tree var_size;
2693 {
2694   if (var_size || const_size > 48)
2695     return 48;
2696   else
2697     return 0;
2698 }
2699
2700 /* Calculate the size of the reg parm stack space.  This is a bit complicated
2701    on the i960.  */
2702
2703 int
2704 i960_reg_parm_stack_space (fndecl)
2705      tree fndecl;
2706 {
2707   /* In this case, we are called from emit_library_call, and we don't need
2708      to pretend we have more space for parameters than what's apparent.  */
2709   if (fndecl == 0)
2710     return 0;
2711
2712   /* In this case, we are called from locate_and_pad_parms when we're
2713      not IN_REGS, so we have an arg block.  */
2714   if (fndecl != current_function_decl)
2715     return 48;
2716
2717   /* Otherwise, we have an arg block if the current function has more than
2718      48 bytes of parameters.  */
2719   if (current_function_args_size != 0 || VARARGS_STDARG_FUNCTION (fndecl))
2720     return 48;
2721   else
2722     return 0;
2723 }
2724 \f
2725 /* Return the register class of a scratch register needed to copy IN into
2726    or out of a register in CLASS in MODE.  If it can be done directly,
2727    NO_REGS is returned.  */
2728
2729 enum reg_class
2730 secondary_reload_class (class, mode, in)
2731      enum reg_class class;
2732      enum machine_mode mode;
2733      rtx in;
2734 {
2735   int regno = -1;
2736
2737   if (GET_CODE (in) == REG || GET_CODE (in) == SUBREG)
2738     regno = true_regnum (in);
2739
2740   /* We can place anything into LOCAL_OR_GLOBAL_REGS and can put
2741      LOCAL_OR_GLOBAL_REGS into anything.  */
2742   if (class == LOCAL_OR_GLOBAL_REGS || class == LOCAL_REGS
2743       || class == GLOBAL_REGS || (regno >= 0 && regno < 32))
2744     return NO_REGS;
2745
2746   /* We can place any hard register, 0.0, and 1.0 into FP_REGS.  */
2747   if (class == FP_REGS
2748       && ((regno >= 0 && regno < FIRST_PSEUDO_REGISTER)
2749           || in == CONST0_RTX (mode) || in == CONST1_RTX (mode)))
2750     return NO_REGS;
2751
2752   return LOCAL_OR_GLOBAL_REGS;
2753 }
2754 \f
2755 /* Look at the opcode P, and set i96_last_insn_type to indicate which
2756    function unit it executed on.  */
2757
2758 /* ??? This would make more sense as an attribute.  */
2759
2760 void
2761 i960_scan_opcode (p)
2762      const char *p;
2763 {
2764   switch (*p)
2765     {
2766     case 'a':
2767     case 'd':
2768     case 'e':
2769     case 'm':
2770     case 'n':
2771     case 'o':
2772     case 'r':
2773       /* Ret is not actually of type REG, but it won't matter, because no
2774          insn will ever follow it.  */
2775     case 'u':
2776     case 'x':
2777       i960_last_insn_type = I_TYPE_REG;
2778       break;
2779
2780     case 'b':
2781       if (p[1] == 'x' || p[3] == 'x')
2782         i960_last_insn_type = I_TYPE_MEM;
2783       i960_last_insn_type = I_TYPE_CTRL;
2784       break;
2785
2786     case 'f':
2787     case 't':
2788       i960_last_insn_type = I_TYPE_CTRL;
2789       break;
2790
2791     case 'c':
2792       if (p[1] == 'a')
2793         {
2794           if (p[4] == 'x')
2795             i960_last_insn_type = I_TYPE_MEM;
2796           else
2797             i960_last_insn_type = I_TYPE_CTRL;
2798         }
2799       else if (p[1] == 'm')
2800         {
2801           if (p[3] == 'd')
2802             i960_last_insn_type = I_TYPE_REG;
2803           else if (p[4] == 'b' || p[4] == 'j')
2804             i960_last_insn_type = I_TYPE_CTRL;
2805           else
2806             i960_last_insn_type = I_TYPE_REG;
2807         }
2808       else
2809         i960_last_insn_type = I_TYPE_REG;
2810       break;
2811
2812     case 'l':
2813       i960_last_insn_type = I_TYPE_MEM;
2814       break;
2815
2816     case 's':
2817       if (p[1] == 't')
2818         i960_last_insn_type = I_TYPE_MEM;
2819       else
2820         i960_last_insn_type = I_TYPE_REG;
2821       break;
2822     }
2823 }