1 /* Subroutines for insn-output.c for AT&T we32000 Family.
2 Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Contributed by John Wehle (john@feith1.uucp)
6 This file is part of GNU CC.
8 GNU CC 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 GNU CC 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 GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 #include "insn-config.h"
37 #include "target-def.h"
39 static void we32k_output_function_prologue
PARAMS ((FILE *, HOST_WIDE_INT
));
40 static void we32k_output_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
));
42 /* Initialize the GCC target structure. */
43 #undef TARGET_ASM_ALIGNED_HI_OP
44 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
45 #undef TARGET_ASM_ALIGNED_SI_OP
46 #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
48 #undef TARGET_ASM_FUNCTION_PROLOGUE
49 #define TARGET_ASM_FUNCTION_PROLOGUE we32k_output_function_prologue
50 #undef TARGET_ASM_FUNCTION_EPILOGUE
51 #define TARGET_ASM_FUNCTION_EPILOGUE we32k_output_function_epilogue
53 struct gcc_target targetm
= TARGET_INITIALIZER
;
55 /* Generate the assembly code for function entry. FILE is a stdio
56 stream to output the code to. SIZE is an int: how many units of
57 temporary storage to allocate.
59 Refer to the array `regs_ever_live' to determine which registers to
60 save; `regs_ever_live[I]' is nonzero if register number I is ever
61 used in the function. This function is responsible for knowing
62 which registers should not be saved even if used. */
65 we32k_output_function_prologue (file
, size
)
69 register int nregs_to_save
;
71 extern char call_used_regs
[];
74 for (regno
= 8; regno
> 2; regno
--)
75 if (regs_ever_live
[regno
] && ! call_used_regs
[regno
])
76 nregs_to_save
= (9 - regno
);
78 fprintf (file
, "\tsave &%d\n", nregs_to_save
);
80 fprintf (file
, "\taddw2 &%d,%%sp\n", (size
+ 3) & ~3);
83 /* This function generates the assembly code for function exit.
84 Args are as for output_function_prologue ().
86 The function epilogue should not depend on the current stack
87 pointer! It should use the frame pointer only. This is mandatory
88 because of alloca; we also take advantage of it to omit stack
89 adjustments before returning. */
92 we32k_output_function_epilogue (file
, size
)
94 HOST_WIDE_INT size ATTRIBUTE_UNUSED
;
96 register int nregs_to_restore
;
98 extern char call_used_regs
[];
100 nregs_to_restore
= 0;
101 for (regno
= 8; regno
> 2; regno
--)
102 if (regs_ever_live
[regno
] && ! call_used_regs
[regno
])
103 nregs_to_restore
= (9 - regno
);
105 fprintf (file
, "\tret &%d\n", nregs_to_restore
);
109 output_move_double (operands
)
116 if (GET_CODE (operands
[0]) == REG
)
118 lsw_operands
[0] = gen_rtx_REG (SImode
, REGNO (operands
[0]) + 1);
119 msw_dreg
= operands
[0];
121 else if (GET_CODE (operands
[0]) == MEM
&& offsettable_memref_p (operands
[0]))
122 lsw_operands
[0] = adjust_address (operands
[0], SImode
, 4);
126 if (GET_CODE (operands
[1]) == REG
)
128 lsw_operands
[1] = gen_rtx_REG (SImode
, REGNO (operands
[1]) + 1);
129 lsw_sreg
= lsw_operands
[1];
131 else if (GET_CODE (operands
[1]) == MEM
&& offsettable_memref_p (operands
[1]))
133 lsw_operands
[1] = adjust_address (operands
[1], SImode
, 4);
134 lsw_sreg
= operands
[1];
137 if (REG_P (lsw_sreg
))
139 if (CONSTANT_ADDRESS_P (lsw_sreg
))
144 if (GET_CODE (lsw_sreg
) == MEM
)
146 lsw_sreg
= XEXP (lsw_sreg
, 0);
149 if (GET_CODE (lsw_sreg
) == PLUS
)
151 if (CONSTANT_ADDRESS_P (XEXP (lsw_sreg
, 1)))
153 lsw_sreg
= XEXP (lsw_sreg
, 0);
156 else if (CONSTANT_ADDRESS_P (XEXP (lsw_sreg
, 0)))
158 lsw_sreg
= XEXP (lsw_sreg
, 1);
165 else if (GET_CODE (operands
[1]) == CONST_DOUBLE
)
167 lsw_operands
[1] = GEN_INT (CONST_DOUBLE_HIGH (operands
[1]));
168 operands
[1] = GEN_INT (CONST_DOUBLE_LOW (operands
[1]));
170 else if (GET_CODE (operands
[1]) == CONST_INT
)
172 lsw_operands
[1] = operands
[1];
173 operands
[1] = const0_rtx
;
178 if (!msw_dreg
|| !lsw_sreg
|| REGNO (msw_dreg
) != REGNO (lsw_sreg
))
180 output_asm_insn ("movw %1, %0", operands
);
181 output_asm_insn ("movw %1, %0", lsw_operands
);
185 output_asm_insn ("movw %1, %0", lsw_operands
);
186 output_asm_insn ("movw %1, %0", operands
);
191 output_push_double (operands
)
196 if (GET_CODE (operands
[0]) == REG
)
197 lsw_operands
[0] = gen_rtx_REG (SImode
, REGNO (operands
[0]) + 1);
198 else if (GET_CODE (operands
[0]) == MEM
&& offsettable_memref_p (operands
[0]))
199 lsw_operands
[0] = adjust_address (operands
[0], SImode
, 4);
200 else if (GET_CODE (operands
[0]) == CONST_DOUBLE
)
202 lsw_operands
[0] = GEN_INT (CONST_DOUBLE_HIGH (operands
[0]));
203 operands
[0] = GEN_INT (CONST_DOUBLE_LOW (operands
[0]));
205 else if (GET_CODE (operands
[0]) == CONST_INT
)
207 lsw_operands
[0] = operands
[0];
208 operands
[0] = const0_rtx
;
213 output_asm_insn ("pushw %0", operands
);
214 output_asm_insn ("pushw %0", lsw_operands
);