1 /* Subroutines for insn-output.c for VAX.
2 Copyright (C) 1987, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002,
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
25 #include "coretypes.h"
30 #include "hard-reg-set.h"
32 #include "insn-config.h"
33 #include "conditions.h"
36 #include "insn-attr.h"
45 #include "target-def.h"
47 static void vax_output_function_prologue (FILE *, HOST_WIDE_INT
);
48 static void vax_file_start (void);
49 static void vax_init_libfuncs (void);
50 static void vax_output_mi_thunk (FILE *, tree
, HOST_WIDE_INT
,
52 static int vax_address_cost_1 (rtx
);
53 static int vax_address_cost (rtx
);
54 static bool vax_rtx_costs (rtx
, int, int, int *);
55 static rtx
vax_struct_value_rtx (tree
, int);
57 /* Initialize the GCC target structure. */
58 #undef TARGET_ASM_ALIGNED_HI_OP
59 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
61 #undef TARGET_ASM_FUNCTION_PROLOGUE
62 #define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue
64 #undef TARGET_ASM_FILE_START
65 #define TARGET_ASM_FILE_START vax_file_start
66 #undef TARGET_ASM_FILE_START_APP_OFF
67 #define TARGET_ASM_FILE_START_APP_OFF true
69 #undef TARGET_INIT_LIBFUNCS
70 #define TARGET_INIT_LIBFUNCS vax_init_libfuncs
72 #undef TARGET_ASM_OUTPUT_MI_THUNK
73 #define TARGET_ASM_OUTPUT_MI_THUNK vax_output_mi_thunk
74 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
75 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
77 #undef TARGET_DEFAULT_TARGET_FLAGS
78 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
80 #undef TARGET_RTX_COSTS
81 #define TARGET_RTX_COSTS vax_rtx_costs
82 #undef TARGET_ADDRESS_COST
83 #define TARGET_ADDRESS_COST vax_address_cost
85 #undef TARGET_PROMOTE_PROTOTYPES
86 #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
88 #undef TARGET_STRUCT_VALUE_RTX
89 #define TARGET_STRUCT_VALUE_RTX vax_struct_value_rtx
91 struct gcc_target targetm
= TARGET_INITIALIZER
;
93 /* Set global variables as needed for the options enabled. */
96 override_options (void)
98 /* We're VAX floating point, not IEEE floating point. */
100 REAL_MODE_FORMAT (DFmode
) = &vax_g_format
;
103 /* Generate the assembly code for function entry. FILE is a stdio
104 stream to output the code to. SIZE is an int: how many units of
105 temporary storage to allocate.
107 Refer to the array `regs_ever_live' to determine which registers to
108 save; `regs_ever_live[I]' is nonzero if register number I is ever
109 used in the function. This function is responsible for knowing
110 which registers should not be saved even if used. */
113 vax_output_function_prologue (FILE * file
, HOST_WIDE_INT size
)
118 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
119 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
122 fprintf (file
, "\t.word 0x%x\n", mask
);
124 if (dwarf2out_do_frame ())
126 const char *label
= dwarf2out_cfi_label ();
129 for (regno
= FIRST_PSEUDO_REGISTER
-1; regno
>= 0; --regno
)
130 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
131 dwarf2out_reg_save (label
, regno
, offset
-= 4);
133 dwarf2out_reg_save (label
, PC_REGNUM
, offset
-= 4);
134 dwarf2out_reg_save (label
, FRAME_POINTER_REGNUM
, offset
-= 4);
135 dwarf2out_reg_save (label
, ARG_POINTER_REGNUM
, offset
-= 4);
136 dwarf2out_def_cfa (label
, FRAME_POINTER_REGNUM
, -(offset
- 4));
139 size
-= STARTING_FRAME_OFFSET
;
141 asm_fprintf (file
, "\tmovab %wd(%Rsp),%Rsp\n", -size
);
143 asm_fprintf (file
, "\tsubl2 $%wd,%Rsp\n", size
);
146 /* When debugging with stabs, we want to output an extra dummy label
147 so that gas can distinguish between D_float and G_float prior to
148 processing the .stabs directive identifying type double. */
150 vax_file_start (void)
152 default_file_start ();
154 if (write_symbols
== DBX_DEBUG
)
155 fprintf (asm_out_file
, "___vax_%c_doubles:\n", ASM_DOUBLE_CHAR
);
158 /* We can use the BSD C library routines for the libgcc calls that are
159 still generated, since that's what they boil down to anyways. When
160 ELF, avoid the user's namespace. */
163 vax_init_libfuncs (void)
165 set_optab_libfunc (udiv_optab
, SImode
, TARGET_ELF
? "*__udiv" : "*udiv");
166 set_optab_libfunc (umod_optab
, SImode
, TARGET_ELF
? "*__urem" : "*urem");
169 /* This is like nonimmediate_operand with a restriction on the type of MEM. */
172 split_quadword_operands (rtx
* operands
, rtx
* low
, int n ATTRIBUTE_UNUSED
)
175 /* Split operands. */
177 low
[0] = low
[1] = low
[2] = 0;
178 for (i
= 0; i
< 3; i
++)
181 /* it's already been figured out */;
182 else if (GET_CODE (operands
[i
]) == MEM
183 && (GET_CODE (XEXP (operands
[i
], 0)) == POST_INC
))
185 rtx addr
= XEXP (operands
[i
], 0);
186 operands
[i
] = low
[i
] = gen_rtx_MEM (SImode
, addr
);
187 if (which_alternative
== 0 && i
== 0)
189 addr
= XEXP (operands
[i
], 0);
190 operands
[i
+1] = low
[i
+1] = gen_rtx_MEM (SImode
, addr
);
195 low
[i
] = operand_subword (operands
[i
], 0, 0, DImode
);
196 operands
[i
] = operand_subword (operands
[i
], 1, 0, DImode
);
202 print_operand_address (FILE * file
, rtx addr
)
204 rtx reg1
, breg
, ireg
;
208 switch (GET_CODE (addr
))
212 addr
= XEXP (addr
, 0);
216 fprintf (file
, "(%s)", reg_names
[REGNO (addr
)]);
220 fprintf (file
, "-(%s)", reg_names
[REGNO (XEXP (addr
, 0))]);
224 fprintf (file
, "(%s)+", reg_names
[REGNO (XEXP (addr
, 0))]);
228 /* There can be either two or three things added here. One must be a
229 REG. One can be either a REG or a MULT of a REG and an appropriate
230 constant, and the third can only be a constant or a MEM.
232 We get these two or three things and put the constant or MEM in
233 OFFSET, the MULT or REG in IREG, and the REG in BREG. If we have
234 a register and can't tell yet if it is a base or index register,
237 reg1
= 0; ireg
= 0; breg
= 0; offset
= 0;
239 if (CONSTANT_ADDRESS_P (XEXP (addr
, 0))
240 || GET_CODE (XEXP (addr
, 0)) == MEM
)
242 offset
= XEXP (addr
, 0);
243 addr
= XEXP (addr
, 1);
245 else if (CONSTANT_ADDRESS_P (XEXP (addr
, 1))
246 || GET_CODE (XEXP (addr
, 1)) == MEM
)
248 offset
= XEXP (addr
, 1);
249 addr
= XEXP (addr
, 0);
251 else if (GET_CODE (XEXP (addr
, 1)) == MULT
)
253 ireg
= XEXP (addr
, 1);
254 addr
= XEXP (addr
, 0);
256 else if (GET_CODE (XEXP (addr
, 0)) == MULT
)
258 ireg
= XEXP (addr
, 0);
259 addr
= XEXP (addr
, 1);
261 else if (GET_CODE (XEXP (addr
, 1)) == REG
)
263 reg1
= XEXP (addr
, 1);
264 addr
= XEXP (addr
, 0);
266 else if (GET_CODE (XEXP (addr
, 0)) == REG
)
268 reg1
= XEXP (addr
, 0);
269 addr
= XEXP (addr
, 1);
274 if (GET_CODE (addr
) == REG
)
281 else if (GET_CODE (addr
) == MULT
)
285 gcc_assert (GET_CODE (addr
) == PLUS
);
286 if (CONSTANT_ADDRESS_P (XEXP (addr
, 0))
287 || GET_CODE (XEXP (addr
, 0)) == MEM
)
291 if (GET_CODE (offset
) == CONST_INT
)
292 offset
= plus_constant (XEXP (addr
, 0), INTVAL (offset
));
295 gcc_assert (GET_CODE (XEXP (addr
, 0)) == CONST_INT
);
296 offset
= plus_constant (offset
, INTVAL (XEXP (addr
, 0)));
299 offset
= XEXP (addr
, 0);
301 else if (GET_CODE (XEXP (addr
, 0)) == REG
)
304 ireg
= reg1
, breg
= XEXP (addr
, 0), reg1
= 0;
306 reg1
= XEXP (addr
, 0);
310 gcc_assert (GET_CODE (XEXP (addr
, 0)) == MULT
);
312 ireg
= XEXP (addr
, 0);
315 if (CONSTANT_ADDRESS_P (XEXP (addr
, 1))
316 || GET_CODE (XEXP (addr
, 1)) == MEM
)
320 if (GET_CODE (offset
) == CONST_INT
)
321 offset
= plus_constant (XEXP (addr
, 1), INTVAL (offset
));
324 gcc_assert (GET_CODE (XEXP (addr
, 1)) == CONST_INT
);
325 offset
= plus_constant (offset
, INTVAL (XEXP (addr
, 1)));
328 offset
= XEXP (addr
, 1);
330 else if (GET_CODE (XEXP (addr
, 1)) == REG
)
333 ireg
= reg1
, breg
= XEXP (addr
, 1), reg1
= 0;
335 reg1
= XEXP (addr
, 1);
339 gcc_assert (GET_CODE (XEXP (addr
, 1)) == MULT
);
341 ireg
= XEXP (addr
, 1);
345 /* If REG1 is nonzero, figure out if it is a base or index register. */
348 if (breg
!= 0 || (offset
&& GET_CODE (offset
) == MEM
))
358 output_address (offset
);
361 fprintf (file
, "(%s)", reg_names
[REGNO (breg
)]);
365 if (GET_CODE (ireg
) == MULT
)
366 ireg
= XEXP (ireg
, 0);
367 gcc_assert (GET_CODE (ireg
) == REG
);
368 fprintf (file
, "[%s]", reg_names
[REGNO (ireg
)]);
373 output_addr_const (file
, addr
);
378 rev_cond_name (rtx op
)
380 switch (GET_CODE (op
))
409 vax_float_literal(rtx c
)
411 enum machine_mode mode
;
412 REAL_VALUE_TYPE r
, s
;
415 if (GET_CODE (c
) != CONST_DOUBLE
)
420 if (c
== const_tiny_rtx
[(int) mode
][0]
421 || c
== const_tiny_rtx
[(int) mode
][1]
422 || c
== const_tiny_rtx
[(int) mode
][2])
425 REAL_VALUE_FROM_CONST_DOUBLE (r
, c
);
427 for (i
= 0; i
< 7; i
++)
431 REAL_VALUE_FROM_INT (s
, x
, 0, mode
);
433 if (REAL_VALUES_EQUAL (r
, s
))
435 ok
= exact_real_inverse (mode
, &s
);
437 if (REAL_VALUES_EQUAL (r
, s
))
444 /* Return the cost in cycles of a memory address, relative to register
447 Each of the following adds the indicated number of cycles:
451 1 - indexing and/or offset(register)
456 vax_address_cost_1 (rtx addr
)
458 int reg
= 0, indexed
= 0, indir
= 0, offset
= 0, predec
= 0;
459 rtx plus_op0
= 0, plus_op1
= 0;
461 switch (GET_CODE (addr
))
471 indexed
= 1; /* 2 on VAX 2 */
474 /* byte offsets cost nothing (on a VAX 2, they cost 1 cycle) */
476 offset
= (unsigned HOST_WIDE_INT
)(INTVAL(addr
)+128) > 256;
480 offset
= 1; /* 2 on VAX 2 */
482 case LABEL_REF
: /* this is probably a byte offset from the pc */
488 plus_op1
= XEXP (addr
, 0);
490 plus_op0
= XEXP (addr
, 0);
491 addr
= XEXP (addr
, 1);
494 indir
= 2; /* 3 on VAX 2 */
495 addr
= XEXP (addr
, 0);
501 /* Up to 3 things can be added in an address. They are stored in
502 plus_op0, plus_op1, and addr. */
516 /* Indexing and register+offset can both be used (except on a VAX 2)
517 without increasing execution time over either one alone. */
518 if (reg
&& indexed
&& offset
)
519 return reg
+ indir
+ offset
+ predec
;
520 return reg
+ indexed
+ indir
+ offset
+ predec
;
524 vax_address_cost (rtx x
)
526 return (1 + (GET_CODE (x
) == REG
? 0 : vax_address_cost_1 (x
)));
529 /* Cost of an expression on a VAX. This version has costs tuned for the
530 CVAX chip (found in the VAX 3 series) with comments for variations on
533 FIXME: The costs need review, particularly for TRUNCATE, FLOAT_EXTEND
534 and FLOAT_TRUNCATE. We need a -mcpu option to allow provision of
535 costs on a per cpu basis. */
538 vax_rtx_costs (rtx x
, int code
, int outer_code
, int *total
)
540 enum machine_mode mode
= GET_MODE (x
);
541 int i
= 0; /* may be modified in switch */
542 const char *fmt
= GET_RTX_FORMAT (code
); /* may be modified in switch */
546 /* On a VAX, constants from 0..63 are cheap because they can use the
547 1 byte literal constant format. Compare to -1 should be made cheap
548 so that decrement-and-branch insns can be formed more easily (if
549 the value -1 is copied to a register some decrement-and-branch
550 patterns will not match). */
554 if (outer_code
== AND
)
556 *total
= ((unsigned HOST_WIDE_INT
) ~INTVAL (x
) <= 077) ? 1 : 2;
559 if ((unsigned HOST_WIDE_INT
) INTVAL (x
) <= 077
560 || (outer_code
== COMPARE
562 || ((outer_code
== PLUS
|| outer_code
== MINUS
)
563 && (unsigned HOST_WIDE_INT
) -INTVAL (x
) <= 077))
577 if (GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
)
578 *total
= vax_float_literal (x
) ? 5 : 8;
580 *total
= ((CONST_DOUBLE_HIGH (x
) == 0
581 && (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (x
) < 64)
582 || (outer_code
== PLUS
583 && CONST_DOUBLE_HIGH (x
) == -1
584 && (unsigned HOST_WIDE_INT
)-CONST_DOUBLE_LOW (x
) < 64))
590 return true; /* Implies register operand. */
594 return true; /* Implies register operand. */
600 *total
= 16; /* 4 on VAX 9000 */
603 *total
= 9; /* 4 on VAX 9000, 12 on VAX 2 */
606 *total
= 16; /* 6 on VAX 9000, 28 on VAX 2 */
611 *total
= 10; /* 3-4 on VAX 9000, 20-28 on VAX 2 */
614 *total
= MAX_COST
; /* Mode is not supported. */
622 *total
= MAX_COST
; /* Mode is not supported. */
630 *total
= 30; /* Highly variable. */
631 else if (mode
== DFmode
)
632 /* divide takes 28 cycles if the result is not zero, 13 otherwise */
635 *total
= 11; /* 25 on VAX 2 */
645 *total
= MAX_COST
; /* Mode is not supported. */
652 *total
= (6 /* 4 on VAX 9000 */
653 + (mode
== DFmode
) + (GET_MODE (XEXP (x
, 0)) != SImode
));
657 *total
= 7; /* 17 on VAX 2 */
666 *total
= 10; /* 6 on VAX 9000 */
671 *total
= 6; /* 5 on VAX 2, 4 on VAX 9000 */
672 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
)
673 fmt
= "e"; /* all constant rotate counts are short */
678 *total
= (mode
== DFmode
) ? 13 : 8; /* 6/8 on VAX 9000, 16/15 on VAX 2 */
679 /* Small integer operands can use subl2 and addl2. */
680 if ((GET_CODE (XEXP (x
, 1)) == CONST_INT
)
681 && (unsigned HOST_WIDE_INT
)(INTVAL (XEXP (x
, 1)) + 63) < 127)
691 /* AND is special because the first operand is complemented. */
693 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
695 if ((unsigned HOST_WIDE_INT
)~INTVAL (XEXP (x
, 0)) > 63)
705 else if (mode
== SFmode
)
707 else if (mode
== DImode
)
723 if (mode
== DImode
|| mode
== DFmode
)
724 *total
= 5; /* 7 on VAX 2 */
726 *total
= 3; /* 4 on VAX 2 */
728 if (GET_CODE (x
) != REG
&& GET_CODE (x
) != POST_INC
)
729 *total
+= vax_address_cost_1 (x
);
735 *total
= 3; /* FIXME: Costs need to be checked */
742 /* Now look inside the expression. Operands which are not registers or
743 short constants add to the cost.
745 FMT and I may have been adjusted in the switch above for instructions
746 which require special handling. */
748 while (*fmt
++ == 'e')
750 rtx op
= XEXP (x
, i
);
753 code
= GET_CODE (op
);
755 /* A NOT is likely to be found as the first operand of an AND
756 (in which case the relevant cost is of the operand inside
757 the not) and not likely to be found anywhere else. */
759 op
= XEXP (op
, 0), code
= GET_CODE (op
);
764 if ((unsigned HOST_WIDE_INT
)INTVAL (op
) > 63
765 && GET_MODE (x
) != QImode
)
766 *total
+= 1; /* 2 on VAX 2 */
771 *total
+= 1; /* 2 on VAX 2 */
774 if (GET_MODE_CLASS (GET_MODE (op
)) == MODE_FLOAT
)
776 /* Registers are faster than floating point constants -- even
777 those constants which can be encoded in a single byte. */
778 if (vax_float_literal (op
))
781 *total
+= (GET_MODE (x
) == DFmode
) ? 3 : 2;
785 if (CONST_DOUBLE_HIGH (op
) != 0
786 || (unsigned)CONST_DOUBLE_LOW (op
) > 63)
791 *total
+= 1; /* 2 on VAX 2 */
792 if (GET_CODE (XEXP (op
, 0)) != REG
)
793 *total
+= vax_address_cost_1 (XEXP (op
, 0));
806 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
807 Used for C++ multiple inheritance.
808 .mask ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11> #conservative entry mask
809 addl2 $DELTA, 4(ap) #adjust first argument
810 jmp FUNCTION+2 #jump beyond FUNCTION's entry mask
814 vax_output_mi_thunk (FILE * file
,
815 tree thunk ATTRIBUTE_UNUSED
,
817 HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED
,
820 fprintf (file
, "\t.word 0x0ffc\n\taddl2 $" HOST_WIDE_INT_PRINT_DEC
, delta
);
821 asm_fprintf (file
, ",4(%Rap)\n");
822 fprintf (file
, "\tjmp ");
823 assemble_name (file
, XSTR (XEXP (DECL_RTL (function
), 0), 0));
824 fprintf (file
, "+2\n");
828 vax_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED
,
829 int incoming ATTRIBUTE_UNUSED
)
831 return gen_rtx_REG (Pmode
, VAX_STRUCT_VALUE_REGNUM
);
834 /* Worker function for NOTICE_UPDATE_CC. */
837 vax_notice_update_cc (rtx exp
, rtx insn ATTRIBUTE_UNUSED
)
839 if (GET_CODE (exp
) == SET
)
841 if (GET_CODE (SET_SRC (exp
)) == CALL
)
843 else if (GET_CODE (SET_DEST (exp
)) != ZERO_EXTRACT
844 && GET_CODE (SET_DEST (exp
)) != PC
)
847 /* The integer operations below don't set carry or
848 set it in an incompatible way. That's ok though
849 as the Z bit is all we need when doing unsigned
850 comparisons on the result of these insns (since
851 they're always with 0). Set CC_NO_OVERFLOW to
852 generate the correct unsigned branches. */
853 switch (GET_CODE (SET_SRC (exp
)))
856 if (GET_MODE_CLASS (GET_MODE (exp
)) == MODE_FLOAT
)
864 cc_status
.flags
= CC_NO_OVERFLOW
;
869 cc_status
.value1
= SET_DEST (exp
);
870 cc_status
.value2
= SET_SRC (exp
);
873 else if (GET_CODE (exp
) == PARALLEL
874 && GET_CODE (XVECEXP (exp
, 0, 0)) == SET
)
876 if (GET_CODE (SET_SRC (XVECEXP (exp
, 0, 0))) == CALL
)
878 else if (GET_CODE (SET_DEST (XVECEXP (exp
, 0, 0))) != PC
)
881 cc_status
.value1
= SET_DEST (XVECEXP (exp
, 0, 0));
882 cc_status
.value2
= SET_SRC (XVECEXP (exp
, 0, 0));
885 /* PARALLELs whose first element sets the PC are aob,
886 sob insns. They do change the cc's. */
891 if (cc_status
.value1
&& GET_CODE (cc_status
.value1
) == REG
893 && reg_overlap_mentioned_p (cc_status
.value1
, cc_status
.value2
))
894 cc_status
.value2
= 0;
895 if (cc_status
.value1
&& GET_CODE (cc_status
.value1
) == MEM
897 && GET_CODE (cc_status
.value2
) == MEM
)
898 cc_status
.value2
= 0;
899 /* Actual condition, one line up, should be that value2's address
900 depends on value1, but that is too much of a pain. */
903 /* Output integer move instructions. */
906 vax_output_int_move (rtx insn ATTRIBUTE_UNUSED
, rtx
*operands
,
907 enum machine_mode mode
)
912 if (GET_CODE (operands
[1]) == SYMBOL_REF
|| GET_CODE (operands
[1]) == CONST
)
914 if (push_operand (operands
[0], SImode
))
916 return "movab %a1,%0";
918 if (operands
[1] == const0_rtx
)
920 if (GET_CODE (operands
[1]) == CONST_INT
921 && (unsigned) INTVAL (operands
[1]) >= 64)
923 int i
= INTVAL (operands
[1]);
924 if ((unsigned)(~i
) < 64)
925 return "mcoml %N1,%0";
926 if ((unsigned)i
< 0x100)
927 return "movzbl %1,%0";
928 if (i
>= -0x80 && i
< 0)
929 return "cvtbl %1,%0";
930 if ((unsigned)i
< 0x10000)
931 return "movzwl %1,%0";
932 if (i
>= -0x8000 && i
< 0)
933 return "cvtwl %1,%0";
935 if (push_operand (operands
[0], SImode
))
940 if (GET_CODE (operands
[1]) == CONST_INT
)
942 int i
= INTVAL (operands
[1]);
945 else if ((unsigned int)i
< 64)
947 else if ((unsigned int)~i
< 64)
948 return "mcomw %H1,%0";
949 else if ((unsigned int)i
< 256)
950 return "movzbw %1,%0";
955 if (GET_CODE (operands
[1]) == CONST_INT
)
957 int i
= INTVAL (operands
[1]);
960 else if ((unsigned int)~i
< 64)
961 return "mcomb %B1,%0";
970 /* Output integer add instructions.
972 The space-time-opcode tradeoffs for addition vary by model of VAX.
974 On a VAX 3 "movab (r1)[r2],r3" is faster than "addl3 r1,r2,r3",
975 but it not faster on other models.
977 "movab #(r1),r2" is usually shorter than "addl3 #,r1,r2", and is
978 faster on a VAX 3, but some VAXen (e.g. VAX 9000) will stall if
979 a register is used in an address too soon after it is set.
980 Compromise by using movab only when it is shorter than the add
981 or the base register in the address is one of sp, ap, and fp,
982 which are not modified very often. */
985 vax_output_int_add (rtx insn ATTRIBUTE_UNUSED
, rtx
*operands
,
986 enum machine_mode mode
)
991 if (rtx_equal_p (operands
[0], operands
[1]))
993 if (operands
[2] == const1_rtx
)
995 if (operands
[2] == constm1_rtx
)
997 if (GET_CODE (operands
[2]) == CONST_INT
998 && (unsigned) (- INTVAL (operands
[2])) < 64)
999 return "subl2 $%n2,%0";
1000 if (GET_CODE (operands
[2]) == CONST_INT
1001 && (unsigned) INTVAL (operands
[2]) >= 64
1002 && GET_CODE (operands
[1]) == REG
1003 && ((INTVAL (operands
[2]) < 32767 && INTVAL (operands
[2]) > -32768)
1004 || REGNO (operands
[1]) > 11))
1005 return "movab %c2(%1),%0";
1006 return "addl2 %2,%0";
1009 if (rtx_equal_p (operands
[0], operands
[2]))
1010 return "addl2 %1,%0";
1012 if (GET_CODE (operands
[2]) == CONST_INT
1013 && INTVAL (operands
[2]) < 32767
1014 && INTVAL (operands
[2]) > -32768
1015 && GET_CODE (operands
[1]) == REG
1016 && push_operand (operands
[0], SImode
))
1017 return "pushab %c2(%1)";
1019 if (GET_CODE (operands
[2]) == CONST_INT
1020 && (unsigned) (- INTVAL (operands
[2])) < 64)
1021 return "subl3 $%n2,%1,%0";
1023 if (GET_CODE (operands
[2]) == CONST_INT
1024 && (unsigned) INTVAL (operands
[2]) >= 64
1025 && GET_CODE (operands
[1]) == REG
1026 && ((INTVAL (operands
[2]) < 32767 && INTVAL (operands
[2]) > -32768)
1027 || REGNO (operands
[1]) > 11))
1028 return "movab %c2(%1),%0";
1030 /* Add this if using gcc on a VAX 3xxx:
1031 if (REG_P (operands[1]) && REG_P (operands[2]))
1032 return "movab (%1)[%2],%0";
1034 return "addl3 %1,%2,%0";
1037 if (rtx_equal_p (operands
[0], operands
[1]))
1039 if (operands
[2] == const1_rtx
)
1041 if (operands
[2] == constm1_rtx
)
1043 if (GET_CODE (operands
[2]) == CONST_INT
1044 && (unsigned) (- INTVAL (operands
[2])) < 64)
1045 return "subw2 $%n2,%0";
1046 return "addw2 %2,%0";
1048 if (rtx_equal_p (operands
[0], operands
[2]))
1049 return "addw2 %1,%0";
1050 if (GET_CODE (operands
[2]) == CONST_INT
1051 && (unsigned) (- INTVAL (operands
[2])) < 64)
1052 return "subw3 $%n2,%1,%0";
1053 return "addw3 %1,%2,%0";
1056 if (rtx_equal_p (operands
[0], operands
[1]))
1058 if (operands
[2] == const1_rtx
)
1060 if (operands
[2] == constm1_rtx
)
1062 if (GET_CODE (operands
[2]) == CONST_INT
1063 && (unsigned) (- INTVAL (operands
[2])) < 64)
1064 return "subb2 $%n2,%0";
1065 return "addb2 %2,%0";
1067 if (rtx_equal_p (operands
[0], operands
[2]))
1068 return "addb2 %1,%0";
1069 if (GET_CODE (operands
[2]) == CONST_INT
1070 && (unsigned) (- INTVAL (operands
[2])) < 64)
1071 return "subb3 $%n2,%1,%0";
1072 return "addb3 %1,%2,%0";
1079 /* Output a conditional branch. */
1081 vax_output_conditional_branch (enum rtx_code code
)
1085 case EQ
: return "jeql %l0";
1086 case NE
: return "jneq %l0";
1087 case GT
: return "jgtr %l0";
1088 case LT
: return "jlss %l0";
1089 case GTU
: return "jgtru %l0";
1090 case LTU
: return "jlssu %l0";
1091 case GE
: return "jgeq %l0";
1092 case LE
: return "jleq %l0";
1093 case GEU
: return "jgequ %l0";
1094 case LEU
: return "jlequ %l0";
1100 /* 1 if X is an rtx for a constant that is a valid address. */
1103 legitimate_constant_address_p (rtx x
)
1105 return (GET_CODE (x
) == LABEL_REF
|| GET_CODE (x
) == SYMBOL_REF
1106 || GET_CODE (x
) == CONST_INT
|| GET_CODE (x
) == CONST
1107 || GET_CODE (x
) == HIGH
);
1110 /* Nonzero if the constant value X is a legitimate general operand.
1111 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1114 legitimate_constant_p (rtx x ATTRIBUTE_UNUSED
)
1119 /* The other macros defined here are used only in legitimate_address_p (). */
1121 /* Nonzero if X is a hard reg that can be used as an index
1122 or, if not strict, if it is a pseudo reg. */
1123 #define INDEX_REGISTER_P(X, STRICT) \
1124 (GET_CODE (X) == REG && (!(STRICT) || REGNO_OK_FOR_INDEX_P (REGNO (X))))
1126 /* Nonzero if X is a hard reg that can be used as a base reg
1127 or, if not strict, if it is a pseudo reg. */
1128 #define BASE_REGISTER_P(X, STRICT) \
1129 (GET_CODE (X) == REG && (!(STRICT) || REGNO_OK_FOR_BASE_P (REGNO (X))))
1131 #ifdef NO_EXTERNAL_INDIRECT_ADDRESS
1133 /* Re-definition of CONSTANT_ADDRESS_P, which is true only when there
1134 are no SYMBOL_REFs for external symbols present. */
1137 indirectable_constant_address_p (rtx x
)
1139 if (!CONSTANT_ADDRESS_P (x
))
1141 if (GET_CODE (x
) == CONST
&& GET_CODE (XEXP ((x
), 0)) == PLUS
)
1142 x
= XEXP (XEXP (x
, 0), 0);
1143 if (GET_CODE (x
) == SYMBOL_REF
&& !SYMBOL_REF_LOCAL_P (x
))
1149 #else /* not NO_EXTERNAL_INDIRECT_ADDRESS */
1152 indirectable_constant_address_p (rtx x
)
1154 return CONSTANT_ADDRESS_P (x
);
1157 #endif /* not NO_EXTERNAL_INDIRECT_ADDRESS */
1159 /* Nonzero if X is an address which can be indirected. External symbols
1160 could be in a sharable image library, so we disallow those. */
1163 indirectable_address_p(rtx x
, int strict
)
1165 if (indirectable_constant_address_p (x
))
1167 if (BASE_REGISTER_P (x
, strict
))
1169 if (GET_CODE (x
) == PLUS
1170 && BASE_REGISTER_P (XEXP (x
, 0), strict
)
1171 && indirectable_constant_address_p (XEXP (x
, 1)))
1176 /* Return 1 if x is a valid address not using indexing.
1177 (This much is the easy part.) */
1179 nonindexed_address_p (rtx x
, int strict
)
1182 if (GET_CODE (x
) == REG
)
1184 extern rtx
*reg_equiv_mem
;
1185 if (! reload_in_progress
1186 || reg_equiv_mem
[REGNO (x
)] == 0
1187 || indirectable_address_p (reg_equiv_mem
[REGNO (x
)], strict
))
1190 if (indirectable_constant_address_p (x
))
1192 if (indirectable_address_p (x
, strict
))
1194 xfoo0
= XEXP (x
, 0);
1195 if (GET_CODE (x
) == MEM
&& indirectable_address_p (xfoo0
, strict
))
1197 if ((GET_CODE (x
) == PRE_DEC
|| GET_CODE (x
) == POST_INC
)
1198 && BASE_REGISTER_P (xfoo0
, strict
))
1203 /* 1 if PROD is either a reg times size of mode MODE and MODE is less
1204 than or equal 8 bytes, or just a reg if MODE is one byte. */
1207 index_term_p (rtx prod
, enum machine_mode mode
, int strict
)
1211 if (GET_MODE_SIZE (mode
) == 1)
1212 return BASE_REGISTER_P (prod
, strict
);
1214 if (GET_CODE (prod
) != MULT
|| GET_MODE_SIZE (mode
) > 8)
1217 xfoo0
= XEXP (prod
, 0);
1218 xfoo1
= XEXP (prod
, 1);
1220 if (GET_CODE (xfoo0
) == CONST_INT
1221 && INTVAL (xfoo0
) == (int)GET_MODE_SIZE (mode
)
1222 && INDEX_REGISTER_P (xfoo1
, strict
))
1225 if (GET_CODE (xfoo1
) == CONST_INT
1226 && INTVAL (xfoo1
) == (int)GET_MODE_SIZE (mode
)
1227 && INDEX_REGISTER_P (xfoo0
, strict
))
1233 /* Return 1 if X is the sum of a register
1234 and a valid index term for mode MODE. */
1236 reg_plus_index_p (rtx x
, enum machine_mode mode
, int strict
)
1240 if (GET_CODE (x
) != PLUS
)
1243 xfoo0
= XEXP (x
, 0);
1244 xfoo1
= XEXP (x
, 1);
1246 if (BASE_REGISTER_P (xfoo0
, strict
) && index_term_p (xfoo1
, mode
, strict
))
1249 if (BASE_REGISTER_P (xfoo1
, strict
) && index_term_p (xfoo0
, mode
, strict
))
1255 /* legitimate_address_p returns 1 if it recognizes an RTL expression "x"
1256 that is a valid memory address for an instruction.
1257 The MODE argument is the machine mode for the MEM expression
1258 that wants to use this address. */
1260 legitimate_address_p (enum machine_mode mode
, rtx x
, int strict
)
1264 if (nonindexed_address_p (x
, strict
))
1267 if (GET_CODE (x
) != PLUS
)
1270 /* Handle <address>[index] represented with index-sum outermost */
1272 xfoo0
= XEXP (x
, 0);
1273 xfoo1
= XEXP (x
, 1);
1275 if (index_term_p (xfoo0
, mode
, strict
)
1276 && nonindexed_address_p (xfoo1
, strict
))
1279 if (index_term_p (xfoo1
, mode
, strict
)
1280 && nonindexed_address_p (xfoo0
, strict
))
1283 /* Handle offset(reg)[index] with offset added outermost */
1285 if (indirectable_constant_address_p (xfoo0
)
1286 && (BASE_REGISTER_P (xfoo1
, strict
)
1287 || reg_plus_index_p (xfoo1
, mode
, strict
)))
1290 if (indirectable_constant_address_p (xfoo1
)
1291 && (BASE_REGISTER_P (xfoo0
, strict
)
1292 || reg_plus_index_p (xfoo0
, mode
, strict
)))
1298 /* Return 1 if x (a legitimate address expression) has an effect that
1299 depends on the machine mode it is used for. On the VAX, the predecrement
1300 and postincrement address depend thus (the amount of decrement or
1301 increment being the length of the operand) and all indexed address depend
1302 thus (because the index scale factor is the length of the operand). */
1305 vax_mode_dependent_address_p (rtx x
)
1309 if (GET_CODE (x
) == POST_INC
|| GET_CODE (x
) == PRE_DEC
)
1311 if (GET_CODE (x
) != PLUS
)
1314 xfoo0
= XEXP (x
, 0);
1315 xfoo1
= XEXP (x
, 1);
1317 if (CONSTANT_ADDRESS_P (xfoo0
) && GET_CODE (xfoo1
) == REG
)
1319 if (CONSTANT_ADDRESS_P (xfoo1
) && GET_CODE (xfoo0
) == REG
)