2002-05-09 Hassan Aurag <aurag@cae.com>
[official-gcc.git] / gcc / config / mips / abi64.h
blobc5125d794413ace57300fd11fb5f0157863a3820
1 /* Definitions of target machine for GNU compiler. 64 bit ABI support.
2 Copyright (C) 1994, 1995, 1996, 1998, 1999, 2001, 2002 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)
9 any later version.
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
22 after mips.h. */
24 #undef SUBTARGET_TARGET_OPTIONS
25 #define SUBTARGET_TARGET_OPTIONS \
26 { "abi=", &mips_abi_string, \
27 "Specify ABI to use"},
29 #undef STACK_BOUNDARY
30 #define STACK_BOUNDARY \
31 ((mips_abi == ABI_32 || mips_abi == ABI_O64 || mips_abi == ABI_EABI) \
32 ? 64 : 128)
34 #undef MIPS_STACK_ALIGN
35 #define MIPS_STACK_ALIGN(LOC) \
36 ((mips_abi == ABI_32 || mips_abi == ABI_O64 || mips_abi == ABI_EABI) \
37 ? ((LOC) + 7) & ~7 \
38 : ((LOC) + 15) & ~15)
40 #undef GP_ARG_LAST
41 #define GP_ARG_LAST ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
42 ? GP_REG_FIRST + 7 : GP_REG_FIRST + 11)
43 #undef FP_ARG_LAST
44 #define FP_ARG_LAST ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
45 ? FP_REG_FIRST + 15 : FP_REG_FIRST + 19)
47 #undef SUBTARGET_CONDITIONAL_REGISTER_USAGE
48 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE \
49 { \
50 /* fp20-23 are now caller saved. */ \
51 if (mips_abi == ABI_64) \
52 { \
53 int regno; \
54 for (regno = FP_REG_FIRST + 20; regno < FP_REG_FIRST + 24; regno++) \
55 call_really_used_regs[regno] = call_used_regs[regno] = 1; \
56 } \
57 /* odd registers from fp21 to fp31 are now caller saved. */ \
58 if (mips_abi == ABI_N32 || mips_abi == ABI_MEABI) \
59 { \
60 int regno; \
61 for (regno = FP_REG_FIRST + 21; regno <= FP_REG_FIRST + 31; regno+=2) \
62 call_really_used_regs[regno] = call_used_regs[regno] = 1; \
63 } \
66 #undef MAX_ARGS_IN_REGISTERS
67 #define MAX_ARGS_IN_REGISTERS ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
68 ? 4 : 8)
70 #undef REG_PARM_STACK_SPACE
71 #define REG_PARM_STACK_SPACE(FNDECL) \
72 ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
73 ? (MAX_ARGS_IN_REGISTERS*UNITS_PER_WORD) - FIRST_PARM_OFFSET (FNDECL) \
74 : 0)
76 #define FUNCTION_ARG_PADDING(MODE, TYPE) \
77 (! BYTES_BIG_ENDIAN \
78 ? upward \
79 : (((MODE) == BLKmode \
80 ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \
81 && int_size_in_bytes (TYPE) < (PARM_BOUNDARY / BITS_PER_UNIT))\
82 : (GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY \
83 && (mips_abi == ABI_32 \
84 || mips_abi == ABI_O64 \
85 || mips_abi == ABI_EABI \
86 || GET_MODE_CLASS (MODE) == MODE_INT))) \
87 ? downward : upward))
89 /* Modified version of the macro in expr.h. */
90 #define MUST_PASS_IN_STACK(MODE,TYPE) \
91 ((TYPE) != 0 \
92 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
93 || TREE_ADDRESSABLE (TYPE) \
94 || ((MODE) == BLKmode \
95 && mips_abi != ABI_32 && mips_abi != ABI_O64 \
96 && ! ((TYPE) != 0 && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \
97 && 0 == (int_size_in_bytes (TYPE) \
98 % (PARM_BOUNDARY / BITS_PER_UNIT))) \
99 && (FUNCTION_ARG_PADDING (MODE, TYPE) \
100 == (BYTES_BIG_ENDIAN ? upward : downward)))))
102 #define STRICT_ARGUMENT_NAMING (mips_abi != ABI_32 && mips_abi != ABI_O64)
104 /* A C expression that indicates when an argument must be passed by
105 reference. If nonzero for an argument, a copy of that argument is
106 made in memory and a pointer to the argument is passed instead of the
107 argument itself. The pointer is passed in whatever way is appropriate
108 for passing a pointer to that type. */
109 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
110 function_arg_pass_by_reference (&CUM, MODE, TYPE, NAMED)
112 /* A C expression that indicates when it is the called function's
113 responsibility to make a copy of arguments passed by invisible
114 reference. Normally, the caller makes a copy and passes the
115 address of the copy to the routine being called. When
116 FUNCTION_ARG_CALLEE_COPIES is defined and is nonzero, the caller
117 does not make a copy. Instead, it passes a pointer to the "live"
118 value. The called function must not modify this value. If it can
119 be determined that the value won't be modified, it need not make a
120 copy; otherwise a copy must be made. */
121 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
122 (mips_abi == ABI_EABI && (NAMED) \
123 && FUNCTION_ARG_PASS_BY_REFERENCE (CUM, MODE, TYPE, NAMED))
125 /* ??? Unimplemented stuff follows. */
127 /* ??? Add support for 16 byte/128 bit long doubles here when
128 mips_abi != ABI32. */
130 /* ??? Make main return zero if user did not specify return value. */
132 /* ??? Add support for .interfaces section, so as to get linker warnings
133 when stdarg functions called without prototype in scope? */
135 /* ??? Could optimize structure passing by putting the right register rtx
136 into the field decl, so that if we use the field, we can take the value from
137 a register instead of from memory. */