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 void elxsi_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
46 static void elxsi_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
48 /* Initialize the GCC target structure. */
49 #undef TARGET_ASM_FUNCTION_PROLOGUE
50 #define TARGET_ASM_FUNCTION_PROLOGUE elxsi_output_function_prologue
51 #undef TARGET_ASM_FUNCTION_EPILOGUE
52 #define TARGET_ASM_FUNCTION_EPILOGUE elxsi_output_function_epilogue
54 struct gcc_target targetm = TARGET_INITIALIZER;
56 /* Generate the assembly code for function entry. FILE is a stdio
57 stream to output the code to. SIZE is an int: how many units of
58 temporary storage to allocate.
60 Refer to the array `regs_ever_live' to determine which registers to
61 save; `regs_ever_live[I]' is nonzero if register number I is ever
62 used in the function. This function is responsible for knowing
63 which registers should not be saved even if used. */
66 elxsi_output_function_prologue (file, size)
72 extern char call_used_regs[];
74 /* the below two lines are a HACK, and should be deleted, but
75 for now are very much needed (1.35) */
76 if (frame_pointer_needed)
77 regs_ever_live[14] = 1, call_used_regs[14] = 0;
79 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
80 if (regs_ever_live[regno] && !call_used_regs[regno])
84 fprintf (file, "\tadd.64\t.sp,=%d\n", -size - cnt);
87 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
88 if (regs_ever_live[regno] && !call_used_regs[regno])
89 fprintf (file, "\tst.64\t.r%d,[.sp]%d\n", regno, (cnt += 8) - 12);
91 if (frame_pointer_needed)
92 fprintf (file, "\tadd.64\t.r14,.sp,=%d\n", size + cnt);
95 /* This function generates the assembly code for function exit.
96 Args are as for output_function_prologue ().
98 The function epilogue should not depend on the current stack
99 pointer! It should use the frame pointer only. This is mandatory
100 because of alloca; we also take advantage of it to omit stack
101 adjustments before returning. */
104 elxsi_output_function_epilogue (file, size)
109 register int cnt = 0;
110 extern char call_used_regs[];
112 /* this conditional is ONLY here because there is a BUG;
113 EXIT_IGNORE_STACK is ignored itself when the first part of
114 the condition is true! (at least in version 1.35) */
115 /* the 8*10 is for 64 bits of .r5 - .r14 */
116 if (current_function_calls_alloca || size >= (256 - 8 * 10))
118 /* use .r4 as a temporary! Ok for now.... */
119 fprintf (file, "\tld.64\t.r4,.r14\n");
121 for (regno = FIRST_PSEUDO_REGISTER-1; regno >= 0; --regno)
122 if (regs_ever_live[regno] && !call_used_regs[regno])
125 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
126 if (regs_ever_live[regno] && !call_used_regs[regno])
127 fprintf (file, "\tld.64\t.r%d,[.r14]%d\n", regno,
128 -((cnt -= 8) + 8) - 4 - size);
130 fprintf (file, "\tld.64\t.sp,.r4\n\texit\t0\n");
134 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
135 if (regs_ever_live[regno] && !call_used_regs[regno])
136 fprintf (file, "\tld.64\t.r%d,[.sp]%d\n", regno, (cnt += 8) - 12);
138 fprintf (file, "\texit\t%d\n", size + cnt);
142 /* type is the index into the above table */
143 /* s is "" for signed, or "u" for unsigned */
145 cmp_jmp (s, type, where)
153 const char *bits = "64";
154 if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
155 if (GET_MODE (cmp_op0) == DFmode) f = "f";
160 sprintf(template, "%scmp%s.br.%s\t%%1,%%2:j%s\t%%l0",
161 f, s, bits, cmp_tab[type]);
163 sprintf(template, "fcmp.br.%s\t%%1,=0:j%s\t%%l0",
164 bits, cmp_tab[type]);
165 else if (*s) /* can turn the below in to a jmp ... */
166 sprintf(template, "cmpu.br.64\t%%1,=0:j%s\t%%l0", s);
168 sprintf(template, "jmp.%s\t%%1,%%l0", cmp_tab[type+1]);
169 output_asm_insn(template, br_ops);
174 cmp_set (s, type, reg)
175 const char *s, *type;
181 const char *bits = "64";
182 if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
183 else if (GET_MODE (cmp_op0) == DFmode) f = "f";
184 else if (GET_MODE (cmp_op0) == SImode) bits = "32";
185 else if (GET_MODE (cmp_op0) == HImode) bits = "16";
186 else if (GET_MODE (cmp_op0) == QImode) bits = "8";
191 sprintf(template, "%scmp%s.%s\t%%0,%%1,%%2:%s",
194 sprintf(template, "%scmp%s.%s\t%%0,%%1,=0:%s",
196 output_asm_insn(template, br_ops);
201 print_operand_address (file, addr)
205 register rtx reg1, reg2, breg, ireg;
208 switch (GET_CODE (addr))
212 if (GET_CODE (XEXP (addr, 0)) == REG)
213 fprintf (file, "%s", reg_names[REGNO (addr)]);
218 fprintf (file, "[%s]", reg_names[REGNO (addr)]);
225 if (GET_CODE (XEXP (addr, 0)) == REG)
227 offset = XEXP (addr, 1);
228 addr = XEXP (addr, 0);
230 else if (GET_CODE (XEXP (addr, 1)) == REG)
232 offset = XEXP (addr, 0);
233 addr = XEXP (addr, 1);
235 fprintf (file, "[%s]", reg_names[REGNO (addr)]);
236 output_address (offset);
240 output_addr_const (file, addr);