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