OSDN Git Service

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