1 /* Subroutines for insn-output.c for GNU compiler. Elxsi version.
2 Copyright (C) 1987, 1992, 1998, 1999, 2000 Free Software Foundation, Inc
3 Contributrd by Mike Stump <mrs@cygnus.com> in 1988 and is the first
5 Based upon the VAX port.
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
35 #include "target-def.h"
37 extern const char *reg_names
[];
38 rtx cmp_op0
=0, cmp_op1
=0;
40 /* table of relations for compares and branches */
41 static const char *const cmp_tab
[] = {
42 "gt", "gt", "eq", "eq", "ge", "ge", "lt", "lt", "ne", "ne",
45 static bool elxsi_assemble_integer
PARAMS ((rtx
, unsigned int, int));
46 static void elxsi_output_function_prologue
PARAMS ((FILE *, HOST_WIDE_INT
));
47 static void elxsi_output_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
));
49 /* Initialize the GCC target structure. */
50 #undef TARGET_ASM_BYTE_OP
51 #define TARGET_ASM_BYTE_OP NULL
52 #undef TARGET_ASM_ALIGNED_HI_OP
53 #define TARGET_ASM_ALIGNED_HI_OP NULL
54 #undef TARGET_ASM_ALIGNED_SI_OP
55 #define TARGET_ASM_ALIGNED_SI_OP NULL
56 #undef TARGET_ASM_INTEGER
57 #define TARGET_ASM_INTEGER elxsi_assemble_integer
59 #undef TARGET_ASM_FUNCTION_PROLOGUE
60 #define TARGET_ASM_FUNCTION_PROLOGUE elxsi_output_function_prologue
61 #undef TARGET_ASM_FUNCTION_EPILOGUE
62 #define TARGET_ASM_FUNCTION_EPILOGUE elxsi_output_function_epilogue
64 struct gcc_target targetm
= TARGET_INITIALIZER
;
66 /* Target hook for assembling integer objects. The ELXSI assembler
67 syntax uses a suffix to indicate the size of data, so we can't use
68 the usual string hooks. */
71 elxsi_assemble_integer (x
, size
, aligned_p
)
82 fputs ("\t.data\t", asm_out_file
);
83 output_addr_const (asm_out_file
, x
);
84 fprintf (asm_out_file
, "{%d}\n", size
* BITS_PER_UNIT
);
87 return default_assemble_integer (x
, size
, aligned_p
);
90 /* Generate the assembly code for function entry. FILE is a stdio
91 stream to output the code to. SIZE is an int: how many units of
92 temporary storage to allocate.
94 Refer to the array `regs_ever_live' to determine which registers to
95 save; `regs_ever_live[I]' is nonzero if register number I is ever
96 used in the function. This function is responsible for knowing
97 which registers should not be saved even if used. */
100 elxsi_output_function_prologue (file
, size
)
105 register int cnt
= 0;
106 extern char call_used_regs
[];
108 /* the below two lines are a HACK, and should be deleted, but
109 for now are very much needed (1.35) */
110 if (frame_pointer_needed
)
111 regs_ever_live
[14] = 1, call_used_regs
[14] = 0;
113 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
114 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
118 fprintf (file
, "\tadd.64\t.sp,=%d\n", -size
- cnt
);
121 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
122 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
123 fprintf (file
, "\tst.64\t.r%d,[.sp]%d\n", regno
, (cnt
+= 8) - 12);
125 if (frame_pointer_needed
)
126 fprintf (file
, "\tadd.64\t.r14,.sp,=%d\n", size
+ cnt
);
129 /* This function generates the assembly code for function exit.
130 Args are as for output_function_prologue ().
132 The function epilogue should not depend on the current stack
133 pointer! It should use the frame pointer only. This is mandatory
134 because of alloca; we also take advantage of it to omit stack
135 adjustments before returning. */
138 elxsi_output_function_epilogue (file
, size
)
143 register int cnt
= 0;
144 extern char call_used_regs
[];
146 /* this conditional is ONLY here because there is a BUG;
147 EXIT_IGNORE_STACK is ignored itself when the first part of
148 the condition is true! (at least in version 1.35) */
149 /* the 8*10 is for 64 bits of .r5 - .r14 */
150 if (current_function_calls_alloca
|| size
>= (256 - 8 * 10))
152 /* use .r4 as a temporary! Ok for now.... */
153 fprintf (file
, "\tld.64\t.r4,.r14\n");
155 for (regno
= FIRST_PSEUDO_REGISTER
-1; regno
>= 0; --regno
)
156 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
159 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; ++regno
)
160 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
161 fprintf (file
, "\tld.64\t.r%d,[.r14]%d\n", regno
,
162 -((cnt
-= 8) + 8) - 4 - size
);
164 fprintf (file
, "\tld.64\t.sp,.r4\n\texit\t0\n");
168 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; ++regno
)
169 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
170 fprintf (file
, "\tld.64\t.r%d,[.sp]%d\n", regno
, (cnt
+= 8) - 12);
172 fprintf (file
, "\texit\t%d\n", size
+ cnt
);
176 /* type is the index into the above table */
177 /* s is "" for signed, or "u" for unsigned */
179 cmp_jmp (s
, type
, where
)
187 const char *bits
= "64";
188 if (GET_MODE (cmp_op0
) == SFmode
) f
= "f", bits
= "32";
189 if (GET_MODE (cmp_op0
) == DFmode
) f
= "f";
194 sprintf(template, "%scmp%s.br.%s\t%%1,%%2:j%s\t%%l0",
195 f
, s
, bits
, cmp_tab
[type
]);
197 sprintf(template, "fcmp.br.%s\t%%1,=0:j%s\t%%l0",
198 bits
, cmp_tab
[type
]);
199 else if (*s
) /* can turn the below in to a jmp ... */
200 sprintf(template, "cmpu.br.64\t%%1,=0:j%s\t%%l0", s
);
202 sprintf(template, "jmp.%s\t%%1,%%l0", cmp_tab
[type
+1]);
203 output_asm_insn(template, br_ops
);
208 cmp_set (s
, type
, reg
)
209 const char *s
, *type
;
215 const char *bits
= "64";
216 if (GET_MODE (cmp_op0
) == SFmode
) f
= "f", bits
= "32";
217 else if (GET_MODE (cmp_op0
) == DFmode
) f
= "f";
218 else if (GET_MODE (cmp_op0
) == SImode
) bits
= "32";
219 else if (GET_MODE (cmp_op0
) == HImode
) bits
= "16";
220 else if (GET_MODE (cmp_op0
) == QImode
) bits
= "8";
225 sprintf(template, "%scmp%s.%s\t%%0,%%1,%%2:%s",
228 sprintf(template, "%scmp%s.%s\t%%0,%%1,=0:%s",
230 output_asm_insn(template, br_ops
);
235 print_operand_address (file
, addr
)
239 register rtx reg1
, reg2
, breg
, ireg
;
242 switch (GET_CODE (addr
))
246 if (GET_CODE (XEXP (addr
, 0)) == REG
)
247 fprintf (file
, "%s", reg_names
[REGNO (addr
)]);
252 fprintf (file
, "[%s]", reg_names
[REGNO (addr
)]);
259 if (GET_CODE (XEXP (addr
, 0)) == REG
)
261 offset
= XEXP (addr
, 1);
262 addr
= XEXP (addr
, 0);
264 else if (GET_CODE (XEXP (addr
, 1)) == REG
)
266 offset
= XEXP (addr
, 0);
267 addr
= XEXP (addr
, 1);
269 fprintf (file
, "[%s]", reg_names
[REGNO (addr
)]);
270 output_address (offset
);
274 output_addr_const (file
, addr
);