]>
gcc.gnu.org Git - gcc.git/blob - gcc/config/mips/abi64.h
a3e768cdc2d276efb412395b2d90c815d5f65397
1 /* Definitions of target machine for GNU compiler. 64 bit ABI support.
2 Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Macros to implement the 64 bit ABI. This file is meant to be included
24 #undef SUBTARGET_TARGET_OPTIONS
25 #define SUBTARGET_TARGET_OPTIONS\
26 { "abi=", &mips_abi_string },
29 #define STACK_BOUNDARY \
30 ((mips_abi == ABI_32 || mips_abi == ABI_EABI) ? 64 : 128)
32 #undef MIPS_STACK_ALIGN
33 #define MIPS_STACK_ALIGN(LOC) \
34 ((mips_abi == ABI_32 || mips_abi == ABI_EABI) \
39 #define GP_ARG_LAST (mips_abi == ABI_32 ? GP_REG_FIRST + 7 : GP_REG_FIRST + 11)
41 #define FP_ARG_LAST (mips_abi == ABI_32 ? FP_REG_FIRST + 15 : FP_REG_FIRST + 19)
43 #undef SUBTARGET_CONDITIONAL_REGISTER_USAGE
44 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE \
46 /* fp20-23 are now caller saved. */ \
47 if (mips_abi == ABI_64) \
50 for (regno = FP_REG_FIRST + 20; regno < FP_REG_FIRST + 24; regno++) \
51 call_used_regs[regno] = 1; \
53 /* odd registers from fp21 to fp31 are now caller saved. */ \
54 if (mips_abi == ABI_N32) \
57 for (regno = FP_REG_FIRST + 21; regno <= FP_REG_FIRST + 31; regno+=2) \
58 call_used_regs[regno] = 1; \
62 #undef MAX_ARGS_IN_REGISTERS
63 #define MAX_ARGS_IN_REGISTERS (mips_abi == ABI_32 ? 4 : 8)
65 #undef REG_PARM_STACK_SPACE
67 /* ??? This is necessary in order for the ABI_32 support to work. However,
68 expr.c (emit_push_insn) has no support for a REG_PARM_STACK_SPACE
69 definition that returns zero. That would have to be fixed before this
71 #define REG_PARM_STACK_SPACE(FNDECL) \
73 ? (MAX_ARGS_IN_REGISTERS*UNITS_PER_WORD) - FIRST_PARM_OFFSET (FNDECL) \
77 #define FUNCTION_ARG_PADDING(MODE, TYPE) \
80 : (((MODE) == BLKmode \
81 ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \
82 && int_size_in_bytes (TYPE) < (PARM_BOUNDARY / BITS_PER_UNIT))\
83 : (GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY \
84 && (mips_abi == ABI_32 || mips_abi == ABI_EABI \
85 || GET_MODE_CLASS (MODE) == MODE_INT))) \
88 #undef RETURN_IN_MEMORY
89 #define RETURN_IN_MEMORY(TYPE) \
91 ? TYPE_MODE (TYPE) == BLKmode \
92 : (int_size_in_bytes (TYPE) \
93 > (mips_abi == ABI_EABI ? 2 * UNITS_PER_WORD : 16)))
95 extern struct rtx_def
*mips_function_value ();
97 #define FUNCTION_VALUE(VALTYPE, FUNC) mips_function_value (VALTYPE, FUNC)
99 /* For varargs, we must save the current argument, because it is the fake
100 argument va_alist, and will need to be converted to the real argument.
101 For stdarg, we do not need to save the current argument, because it
102 is a real argument. */
103 #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
104 { int mips_off = (! current_function_varargs) && (! (CUM).last_arg_fp); \
105 int mips_fp_off = (! current_function_varargs) && ((CUM).last_arg_fp); \
106 if ((mips_abi != ABI_32 \
107 && (CUM).arg_words < MAX_ARGS_IN_REGISTERS - mips_off) \
108 || (mips_abi == ABI_EABI \
109 && ! TARGET_SOFT_FLOAT \
110 && (CUM).fp_arg_words < MAX_ARGS_IN_REGISTERS - mips_fp_off)) \
112 int mips_save_gp_regs = \
113 MAX_ARGS_IN_REGISTERS - (CUM).arg_words - mips_off; \
114 int mips_save_fp_regs = \
115 (mips_abi != ABI_EABI ? 0 \
116 : MAX_ARGS_IN_REGISTERS - (CUM).fp_arg_words - mips_fp_off); \
118 if (mips_save_gp_regs < 0) \
119 mips_save_gp_regs = 0; \
120 if (mips_save_fp_regs < 0) \
121 mips_save_fp_regs = 0; \
122 PRETEND_SIZE = ((mips_save_gp_regs * UNITS_PER_WORD) \
123 + (mips_save_fp_regs * UNITS_PER_FPREG)); \
127 if ((CUM).arg_words < MAX_ARGS_IN_REGISTERS - mips_off) \
130 if (mips_abi != ABI_EABI) \
131 ptr = virtual_incoming_args_rtx; \
133 ptr = plus_constant (virtual_incoming_args_rtx, \
134 - (mips_save_gp_regs \
135 * UNITS_PER_WORD)); \
136 mem = gen_rtx (MEM, BLKmode, ptr); \
137 /* va_arg is an array access in this case, which causes \
138 it to get MEM_IN_STRUCT_P set. We must set it here \
139 so that the insn scheduler won't assume that these \
140 stores can't possibly overlap with the va_arg loads. */ \
141 if (mips_abi != ABI_EABI && BYTES_BIG_ENDIAN) \
142 MEM_IN_STRUCT_P (mem) = 1; \
143 move_block_from_reg \
144 ((CUM).arg_words + GP_ARG_FIRST + mips_off, \
147 mips_save_gp_regs * UNITS_PER_WORD); \
149 if (mips_abi == ABI_EABI \
150 && ! TARGET_SOFT_FLOAT \
151 && (CUM).fp_arg_words < MAX_ARGS_IN_REGISTERS - mips_fp_off) \
153 enum machine_mode mode = TARGET_SINGLE_FLOAT ? SFmode : DFmode; \
154 int size = GET_MODE_SIZE (mode); \
157 /* We can't use move_block_from_reg, because it will use \
159 off = - (mips_save_gp_regs * UNITS_PER_WORD); \
160 if (! TARGET_SINGLE_FLOAT) \
162 if (! TARGET_FLOAT64 || TARGET_SINGLE_FLOAT) \
163 off -= (mips_save_fp_regs / 2) * size; \
165 off -= mips_save_fp_regs * size; \
166 for (i = 0; i < mips_save_fp_regs; i++) \
169 gen_rtx (MEM, mode, \
170 plus_constant (virtual_incoming_args_rtx, \
172 emit_move_insn (tem, \
173 gen_rtx (REG, mode, \
174 ((CUM).fp_arg_words \
179 if (! TARGET_FLOAT64 || TARGET_SINGLE_FLOAT) \
187 /* ??? Should disable for mips_abi == ABI32. */
188 #define STRICT_ARGUMENT_NAMING
190 /* A C expression that indicates when an argument must be passed by
191 reference. If nonzero for an argument, a copy of that argument is
192 made in memory and a pointer to the argument is passed instead of the
193 argument itself. The pointer is passed in whatever way is appropriate
194 for passing a pointer to that type. */
195 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
196 (mips_abi == ABI_EABI \
197 && function_arg_pass_by_reference (&CUM, MODE, TYPE, NAMED))
199 /* A C expression that indicates when it is the called function's
200 responsibility to make a copy of arguments passed by invisible
201 reference. Normally, the caller makes a copy and passes the
202 address of the copy to the routine being called. When
203 FUNCTION_ARG_CALLEE_COPIES is defined and is nonzero, the caller
204 does not make a copy. Instead, it passes a pointer to the "live"
205 value. The called function must not modify this value. If it can
206 be determined that the value won't be modified, it need not make a
207 copy; otherwise a copy must be made.
209 ??? The MIPS EABI says that the caller should copy in ``K&R mode.''
210 I don't know how to detect that here, since flag_traditional is not
212 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
213 (mips_abi == ABI_EABI && (NAMED) \
214 && FUNCTION_ARG_PASS_BY_REFERENCE (CUM, MODE, TYPE, NAMED))
217 #define LONG_MAX_SPEC "%{!mno-long64:-D__LONG_MAX__=9223372036854775807LL}"
219 /* ??? Unimplemented stuff follows. */
221 /* ??? Add support for 16 byte/128 bit long doubles here when
222 mips_abi != ABI32. */
224 /* ??? Make main return zero if user did not specify return value. */
226 /* ??? Add support for .interfaces section, so as to get linker warnings
227 when stdarg functions called without prototype in scope? */
229 /* ??? Could optimize structure passing by putting the right register rtx
230 into the field decl, so that if we use the field, we can take the value from
231 a register instead of from memory. */
This page took 0.050109 seconds and 4 git commands to generate.