OSDN Git Service

* expmed.c (extract_fixed_bit_field): Remove unused code.
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / mips.h
1 /* Definitions of target machine for GNU compiler.  MIPS version.
2    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
3    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4    Contributed by A. Lichnewsky (lich@inria.inria.fr).
5    Changed by Michael Meissner  (meissner@osf.org).
6    64 bit r4000 support by Ian Lance Taylor (ian@cygnus.com) and
7    Brendan Eich (brendan@microunity.com).
8
9 This file is part of GNU CC.
10
11 GNU CC is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
14 any later version.
15
16 GNU CC is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with GNU CC; see the file COPYING.  If not, write to
23 the Free Software Foundation, 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.  */
25
26
27 /* Standard GCC variables that we reference.  */
28
29 extern char    *asm_file_name;
30 extern char     call_used_regs[];
31 extern int      may_call_alloca;
32 extern char   **save_argv;
33 extern int      target_flags;
34
35 /* MIPS external variables defined in mips.c.  */
36
37 /* comparison type */
38 enum cmp_type {
39   CMP_SI,                               /* compare four byte integers */
40   CMP_DI,                               /* compare eight byte integers */
41   CMP_SF,                               /* compare single precision floats */
42   CMP_DF,                               /* compare double precision floats */
43   CMP_MAX                               /* max comparison type */
44 };
45
46 /* types of delay slot */
47 enum delay_type {
48   DELAY_NONE,                           /* no delay slot */
49   DELAY_LOAD,                           /* load from memory delay */
50   DELAY_HILO,                           /* move from/to hi/lo registers */
51   DELAY_FCMP                            /* delay after doing c.<xx>.{d,s} */
52 };
53
54 /* Which processor to schedule for.  Since there is no difference between
55    a R2000 and R3000 in terms of the scheduler, we collapse them into
56    just an R3000.  The elements of the enumeration must match exactly
57    the cpu attribute in the mips.md machine description.  */
58
59 enum processor_type {
60   PROCESSOR_DEFAULT,
61   PROCESSOR_R3000,
62   PROCESSOR_R3900,
63   PROCESSOR_R6000,
64   PROCESSOR_R4000,
65   PROCESSOR_R4100,
66   PROCESSOR_R4300,
67   PROCESSOR_R4600,
68   PROCESSOR_R4650,
69   PROCESSOR_R5000,
70   PROCESSOR_R8000,
71   PROCESSOR_R4KC,
72   PROCESSOR_R5KC,
73   PROCESSOR_R20KC
74 };
75
76 /* Recast the cpu class to be the cpu attribute.  */
77 #define mips_cpu_attr ((enum attr_cpu)mips_tune)
78
79 /* Which ABI to use.  These are constants because abi64.h must check their
80    value at preprocessing time.
81
82    ABI_32 (original 32, or o32), ABI_N32 (n32), ABI_64 (n64) are all
83    defined by SGI.  ABI_O64 is o32 extended to work on a 64 bit machine.  */
84
85 #define ABI_32  0
86 #define ABI_N32 1
87 #define ABI_64  2
88 #define ABI_EABI 3
89 #define ABI_O64  4
90 /* MEABI is gcc's internal name for MIPS' new EABI (defined by MIPS)
91    which is not the same as the above EABI (defined by Cygnus,
92    Greenhills, and Toshiba?).  MEABI is not yet complete or published,
93    but at this point it looks like N32 as far as calling conventions go,
94    but allows for either 32 or 64 bit registers.
95
96    Currently MIPS is calling their EABI "the" MIPS EABI, and Cygnus'
97    EABI the legacy EABI.  In the end we may end up calling both ABI's
98    EABI but give them different version numbers, but for now I'm going
99    with different names.  */
100 #define ABI_MEABI 5
101
102 /* Whether to emit abicalls code sequences or not.  */
103
104 enum mips_abicalls_type {
105   MIPS_ABICALLS_NO,
106   MIPS_ABICALLS_YES
107 };
108
109 /* Recast the abicalls class to be the abicalls attribute.  */
110 #define mips_abicalls_attr ((enum attr_abicalls)mips_abicalls)
111
112 /* Which type of block move to do (whether or not the last store is
113    split out so it can fill a branch delay slot).  */
114
115 enum block_move_type {
116   BLOCK_MOVE_NORMAL,                    /* generate complete block move */
117   BLOCK_MOVE_NOT_LAST,                  /* generate all but last store */
118   BLOCK_MOVE_LAST                       /* generate just the last store */
119 };
120
121 extern char mips_reg_names[][8];        /* register names (a0 vs. $4).  */
122 extern char mips_print_operand_punct[256]; /* print_operand punctuation chars */
123 extern const char *current_function_file; /* filename current function is in */
124 extern int num_source_filenames;        /* current .file # */
125 extern int inside_function;             /* != 0 if inside of a function */
126 extern int ignore_line_number;          /* != 0 if we are to ignore next .loc */
127 extern int file_in_function_warning;    /* warning given about .file in func */
128 extern int sdb_label_count;             /* block start/end next label # */
129 extern int sdb_begin_function_line;     /* Starting Line of current function */
130 extern int mips_section_threshold;      /* # bytes of data/sdata cutoff */
131 extern int g_switch_value;              /* value of the -G xx switch */
132 extern int g_switch_set;                /* whether -G xx was passed.  */
133 extern int sym_lineno;                  /* sgi next label # for each stmt */
134 extern int set_noreorder;               /* # of nested .set noreorder's  */
135 extern int set_nomacro;                 /* # of nested .set nomacro's  */
136 extern int set_noat;                    /* # of nested .set noat's  */
137 extern int set_volatile;                /* # of nested .set volatile's  */
138 extern int mips_branch_likely;          /* emit 'l' after br (branch likely) */
139 extern int mips_dbx_regno[];            /* Map register # to debug register # */
140 extern struct rtx_def *branch_cmp[2];   /* operands for compare */
141 extern enum cmp_type branch_type;       /* what type of branch to use */
142 extern enum processor_type mips_arch;   /* which cpu to codegen for */
143 extern enum processor_type mips_tune;   /* which cpu to schedule for */
144 extern enum mips_abicalls_type mips_abicalls;/* for svr4 abi pic calls */
145 extern int mips_isa;                    /* architectural level */
146 extern int mips16;                      /* whether generating mips16 code */
147 extern int mips16_hard_float;           /* mips16 without -msoft-float */
148 extern int mips_entry;                  /* generate entry/exit for mips16 */
149 extern const char *mips_cpu_string;     /* for -mcpu=<xxx> */
150 extern const char *mips_arch_string;    /* for -march=<xxx> */
151 extern const char *mips_tune_string;    /* for -mtune=<xxx> */
152 extern const char *mips_isa_string;     /* for -mips{1,2,3,4} */
153 extern const char *mips_abi_string;     /* for -mabi={32,n32,64} */
154 extern const char *mips_entry_string;   /* for -mentry */
155 extern const char *mips_no_mips16_string;/* for -mno-mips16 */
156 extern const char *mips_explicit_type_size_string;/* for -mexplicit-type-size */
157 extern const char *mips_cache_flush_func;/* for -mflush-func= and -mno-flush-func */
158 extern int mips_split_addresses;        /* perform high/lo_sum support */
159 extern int dslots_load_total;           /* total # load related delay slots */
160 extern int dslots_load_filled;          /* # filled load delay slots */
161 extern int dslots_jump_total;           /* total # jump related delay slots */
162 extern int dslots_jump_filled;          /* # filled jump delay slots */
163 extern int dslots_number_nops;          /* # of nops needed by previous insn */
164 extern int num_refs[3];                 /* # 1/2/3 word references */
165 extern struct rtx_def *mips_load_reg;   /* register to check for load delay */
166 extern struct rtx_def *mips_load_reg2;  /* 2nd reg to check for load delay */
167 extern struct rtx_def *mips_load_reg3;  /* 3rd reg to check for load delay */
168 extern struct rtx_def *mips_load_reg4;  /* 4th reg to check for load delay */
169 extern struct rtx_def *embedded_pic_fnaddr_rtx; /* function address */
170 extern int mips_string_length;          /* length of strings for mips16 */
171 extern struct rtx_def *mips16_gp_pseudo_rtx; /* psuedo reg holding $gp */
172
173 /* Functions to change what output section we are using.  */
174 extern void             rdata_section PARAMS ((void));
175 extern void             sdata_section PARAMS ((void));
176 extern void             sbss_section PARAMS ((void));
177
178 /* Stubs for half-pic support if not OSF/1 reference platform.  */
179
180 #ifndef HALF_PIC_P
181 #define HALF_PIC_P() 0
182 #define HALF_PIC_NUMBER_PTRS 0
183 #define HALF_PIC_NUMBER_REFS 0
184 #define HALF_PIC_ENCODE(DECL)
185 #define HALF_PIC_DECLARE(NAME)
186 #define HALF_PIC_INIT() error ("half-pic init called on systems that don't support it")
187 #define HALF_PIC_ADDRESS_P(X) 0
188 #define HALF_PIC_PTR(X) X
189 #define HALF_PIC_FINISH(STREAM)
190 #endif
191
192 /* Macros to silence warnings about numbers being signed in traditional
193    C and unsigned in ISO C when compiled on 32-bit hosts.  */
194
195 #define BITMASK_HIGH    (((unsigned long)1) << 31)      /* 0x80000000 */
196 #define BITMASK_UPPER16 ((unsigned long)0xffff << 16)   /* 0xffff0000 */
197 #define BITMASK_LOWER16 ((unsigned long)0xffff)         /* 0x0000ffff */
198
199 \f
200 /* Run-time compilation parameters selecting different hardware subsets.  */
201
202 /* Macros used in the machine description to test the flags.  */
203
204                                         /* Bits for real switches */
205 #define MASK_INT64         0x00000001   /* ints are 64 bits */
206 #define MASK_LONG64        0x00000002   /* longs are 64 bits */
207 #define MASK_SPLIT_ADDR    0x00000004   /* Address splitting is enabled.  */
208 #define MASK_GPOPT         0x00000008   /* Optimize for global pointer */
209 #define MASK_GAS           0x00000010   /* Gas used instead of MIPS as */
210 #define MASK_NAME_REGS     0x00000020   /* Use MIPS s/w reg name convention */
211 #define MASK_STATS         0x00000040   /* print statistics to stderr */
212 #define MASK_MEMCPY        0x00000080   /* call memcpy instead of inline code*/
213 #define MASK_SOFT_FLOAT    0x00000100   /* software floating point */
214 #define MASK_FLOAT64       0x00000200   /* fp registers are 64 bits */
215 #define MASK_ABICALLS      0x00000400   /* emit .abicalls/.cprestore/.cpload */
216 #define MASK_HALF_PIC      0x00000800   /* Emit OSF-style pic refs to externs*/
217 #define MASK_LONG_CALLS    0x00001000   /* Always call through a register */
218 #define MASK_64BIT         0x00002000   /* Use 64 bit GP registers and insns */
219 #define MASK_EMBEDDED_PIC  0x00004000   /* Generate embedded PIC code */
220 #define MASK_EMBEDDED_DATA 0x00008000   /* Reduce RAM usage, not fast code */
221 #define MASK_BIG_ENDIAN    0x00010000   /* Generate big endian code */
222 #define MASK_SINGLE_FLOAT  0x00020000   /* Only single precision FPU.  */
223 #define MASK_MAD           0x00040000   /* Generate mad/madu as on 4650.  */
224 #define MASK_4300_MUL_FIX  0x00080000   /* Work-around early Vr4300 CPU bug */
225 #define MASK_MIPS16        0x00100000   /* Generate mips16 code */
226 #define MASK_NO_CHECK_ZERO_DIV \
227                            0x00200000   /* divide by zero checking */
228 #define MASK_CHECK_RANGE_DIV \
229                            0x00400000   /* divide result range checking */
230 #define MASK_UNINIT_CONST_IN_RODATA \
231                            0x00800000   /* Store uninitialized
232                                            consts in rodata */
233 #define MASK_NO_FUSED_MADD 0x01000000   /* Don't generate floating point
234                                            multiply-add operations.  */
235
236                                         /* Debug switches, not documented */
237 #define MASK_DEBUG      0               /* unused */
238 #define MASK_DEBUG_A    0               /* don't allow <label>($reg) addrs */
239 #define MASK_DEBUG_B    0               /* GO_IF_LEGITIMATE_ADDRESS debug */
240 #define MASK_DEBUG_C    0               /* don't expand seq, etc.  */
241 #define MASK_DEBUG_D    0               /* don't do define_split's */
242 #define MASK_DEBUG_E    0               /* function_arg debug */
243 #define MASK_DEBUG_F    0               /* ??? */
244 #define MASK_DEBUG_G    0               /* don't support 64 bit arithmetic */
245 #define MASK_DEBUG_H    0               /* allow ints in FP registers */
246 #define MASK_DEBUG_I    0               /* unused */
247
248                                         /* Dummy switches used only in specs */
249 #define MASK_MIPS_TFILE 0               /* flag for mips-tfile usage */
250
251                                         /* r4000 64 bit sizes */
252 #define TARGET_INT64            (target_flags & MASK_INT64)
253 #define TARGET_LONG64           (target_flags & MASK_LONG64)
254 #define TARGET_FLOAT64          (target_flags & MASK_FLOAT64)
255 #define TARGET_64BIT            (target_flags & MASK_64BIT)
256
257                                         /* Mips vs. GNU linker */
258 #define TARGET_SPLIT_ADDRESSES  (target_flags & MASK_SPLIT_ADDR)
259
260                                         /* Mips vs. GNU assembler */
261 #define TARGET_GAS              (target_flags & MASK_GAS)
262 #define TARGET_MIPS_AS          (!TARGET_GAS)
263
264                                         /* Debug Modes */
265 #define TARGET_DEBUG_MODE       (target_flags & MASK_DEBUG)
266 #define TARGET_DEBUG_A_MODE     (target_flags & MASK_DEBUG_A)
267 #define TARGET_DEBUG_B_MODE     (target_flags & MASK_DEBUG_B)
268 #define TARGET_DEBUG_C_MODE     (target_flags & MASK_DEBUG_C)
269 #define TARGET_DEBUG_D_MODE     (target_flags & MASK_DEBUG_D)
270 #define TARGET_DEBUG_E_MODE     (target_flags & MASK_DEBUG_E)
271 #define TARGET_DEBUG_F_MODE     (target_flags & MASK_DEBUG_F)
272 #define TARGET_DEBUG_G_MODE     (target_flags & MASK_DEBUG_G)
273 #define TARGET_DEBUG_H_MODE     (target_flags & MASK_DEBUG_H)
274 #define TARGET_DEBUG_I_MODE     (target_flags & MASK_DEBUG_I)
275
276                                         /* Reg. Naming in .s ($21 vs. $a0) */
277 #define TARGET_NAME_REGS        (target_flags & MASK_NAME_REGS)
278
279                                         /* Optimize for Sdata/Sbss */
280 #define TARGET_GP_OPT           (target_flags & MASK_GPOPT)
281
282                                         /* print program statistics */
283 #define TARGET_STATS            (target_flags & MASK_STATS)
284
285                                         /* call memcpy instead of inline code */
286 #define TARGET_MEMCPY           (target_flags & MASK_MEMCPY)
287
288                                         /* .abicalls, etc from Pyramid V.4 */
289 #define TARGET_ABICALLS         (target_flags & MASK_ABICALLS)
290
291                                         /* OSF pic references to externs */
292 #define TARGET_HALF_PIC         (target_flags & MASK_HALF_PIC)
293
294                                         /* software floating point */
295 #define TARGET_SOFT_FLOAT       (target_flags & MASK_SOFT_FLOAT)
296 #define TARGET_HARD_FLOAT       (! TARGET_SOFT_FLOAT)
297
298                                         /* always call through a register */
299 #define TARGET_LONG_CALLS       (target_flags & MASK_LONG_CALLS)
300
301                                         /* generate embedded PIC code;
302                                            requires gas.  */
303 #define TARGET_EMBEDDED_PIC     (target_flags & MASK_EMBEDDED_PIC)
304
305                                         /* for embedded systems, optimize for
306                                            reduced RAM space instead of for
307                                            fastest code.  */
308 #define TARGET_EMBEDDED_DATA    (target_flags & MASK_EMBEDDED_DATA)
309
310                                         /* always store uninitialized const
311                                            variables in rodata, requires
312                                            TARGET_EMBEDDED_DATA.  */
313 #define TARGET_UNINIT_CONST_IN_RODATA   (target_flags & MASK_UNINIT_CONST_IN_RODATA)
314
315                                         /* generate big endian code.  */
316 #define TARGET_BIG_ENDIAN       (target_flags & MASK_BIG_ENDIAN)
317
318 #define TARGET_SINGLE_FLOAT     (target_flags & MASK_SINGLE_FLOAT)
319 #define TARGET_DOUBLE_FLOAT     (! TARGET_SINGLE_FLOAT)
320
321 #define TARGET_MAD              (target_flags & MASK_MAD)
322
323 #define TARGET_FUSED_MADD       (! (target_flags & MASK_NO_FUSED_MADD))
324
325 #define TARGET_4300_MUL_FIX     (target_flags & MASK_4300_MUL_FIX)
326
327 #define TARGET_NO_CHECK_ZERO_DIV (target_flags & MASK_NO_CHECK_ZERO_DIV)
328 #define TARGET_CHECK_RANGE_DIV  (target_flags & MASK_CHECK_RANGE_DIV)
329
330 /* This is true if we must enable the assembly language file switching
331    code.  */
332
333 #define TARGET_FILE_SWITCHING \
334   (TARGET_GP_OPT && ! TARGET_GAS && ! TARGET_MIPS16)
335
336 /* We must disable the function end stabs when doing the file switching trick,
337    because the Lscope stabs end up in the wrong place, making it impossible
338    to debug the resulting code.  */
339 #define NO_DBX_FUNCTION_END TARGET_FILE_SWITCHING
340
341                                         /* Generate mips16 code */
342 #define TARGET_MIPS16           (target_flags & MASK_MIPS16)
343
344 /* Architecture target defines.  */
345 #define TARGET_MIPS3900             (mips_arch == PROCESSOR_R3900)
346 #define TARGET_MIPS4000             (mips_arch == PROCESSOR_R4000)
347 #define TARGET_MIPS4100             (mips_arch == PROCESSOR_R4100)
348 #define TARGET_MIPS4300             (mips_arch == PROCESSOR_R4300)
349 #define TARGET_MIPS4KC              (mips_arch == PROCESSOR_R4KC)
350 #define TARGET_MIPS5KC              (mips_arch == PROCESSOR_R5KC)
351
352 /* Scheduling target defines.  */
353 #define TUNE_MIPS3000               (mips_tune == PROCESSOR_R3000)
354 #define TUNE_MIPS3900               (mips_tune == PROCESSOR_R3900)
355 #define TUNE_MIPS4000               (mips_tune == PROCESSOR_R4000)
356 #define TUNE_MIPS5000               (mips_tune == PROCESSOR_R5000)
357 #define TUNE_MIPS6000               (mips_tune == PROCESSOR_R6000)
358
359 /* Macro to define tables used to set the flags.
360    This is a list in braces of pairs in braces,
361    each pair being { "NAME", VALUE }
362    where VALUE is the bits to set or minus the bits to clear.
363    An empty string NAME is used to identify the default VALUE.  */
364
365 #define TARGET_SWITCHES                                                 \
366 {                                                                       \
367   {"no-crt0",          0,                                               \
368      N_("No default crt0.o") },                                         \
369   {"int64",               MASK_INT64 | MASK_LONG64,                     \
370      N_("Use 64-bit int type")},                                        \
371   {"long64",              MASK_LONG64,                                  \
372      N_("Use 64-bit long type")},                                       \
373   {"long32",             -(MASK_LONG64 | MASK_INT64),                   \
374      N_("Use 32-bit long type")},                                       \
375   {"split-addresses",     MASK_SPLIT_ADDR,                              \
376      N_("Optimize lui/addiu address loads")},                           \
377   {"no-split-addresses", -MASK_SPLIT_ADDR,                              \
378      N_("Don't optimize lui/addiu address loads")},                     \
379   {"mips-as",            -MASK_GAS,                                     \
380      N_("Use MIPS as")},                                                \
381   {"gas",                 MASK_GAS,                                     \
382      N_("Use GNU as")},                                                 \
383   {"rnames",              MASK_NAME_REGS,                               \
384      N_("Use symbolic register names")},                                \
385   {"no-rnames",          -MASK_NAME_REGS,                               \
386      N_("Don't use symbolic register names")},                          \
387   {"gpOPT",               MASK_GPOPT,                                   \
388      N_("Use GP relative sdata/sbss sections")},                        \
389   {"gpopt",               MASK_GPOPT,                                   \
390      N_("Use GP relative sdata/sbss sections")},                        \
391   {"no-gpOPT",           -MASK_GPOPT,                                   \
392      N_("Don't use GP relative sdata/sbss sections")},                  \
393   {"no-gpopt",           -MASK_GPOPT,                                   \
394      N_("Don't use GP relative sdata/sbss sections")},                  \
395   {"stats",               MASK_STATS,                                   \
396      N_("Output compiler statistics")},                                 \
397   {"no-stats",           -MASK_STATS,                                   \
398      N_("Don't output compiler statistics")},                           \
399   {"memcpy",              MASK_MEMCPY,                                  \
400      N_("Don't optimize block moves")},                                 \
401   {"no-memcpy",          -MASK_MEMCPY,                                  \
402      N_("Optimize block moves")},                                       \
403   {"mips-tfile",          MASK_MIPS_TFILE,                              \
404      N_("Use mips-tfile asm postpass")},                                \
405   {"no-mips-tfile",      -MASK_MIPS_TFILE,                              \
406      N_("Don't use mips-tfile asm postpass")},                          \
407   {"soft-float",          MASK_SOFT_FLOAT,                              \
408      N_("Use software floating point")},                                \
409   {"hard-float",         -MASK_SOFT_FLOAT,                              \
410      N_("Use hardware floating point")},                                \
411   {"fp64",                MASK_FLOAT64,                                 \
412      N_("Use 64-bit FP registers")},                                    \
413   {"fp32",               -MASK_FLOAT64,                                 \
414      N_("Use 32-bit FP registers")},                                    \
415   {"gp64",                MASK_64BIT,                                   \
416      N_("Use 64-bit general registers")},                               \
417   {"gp32",               -MASK_64BIT,                                   \
418      N_("Use 32-bit general registers")},                               \
419   {"abicalls",            MASK_ABICALLS,                                \
420      N_("Use Irix PIC")},                                               \
421   {"no-abicalls",        -MASK_ABICALLS,                                \
422      N_("Don't use Irix PIC")},                                         \
423   {"half-pic",            MASK_HALF_PIC,                                \
424      N_("Use OSF PIC")},                                                \
425   {"no-half-pic",        -MASK_HALF_PIC,                                \
426      N_("Don't use OSF PIC")},                                          \
427   {"long-calls",          MASK_LONG_CALLS,                              \
428      N_("Use indirect calls")},                                         \
429   {"no-long-calls",      -MASK_LONG_CALLS,                              \
430      N_("Don't use indirect calls")},                                   \
431   {"embedded-pic",        MASK_EMBEDDED_PIC,                            \
432      N_("Use embedded PIC")},                                           \
433   {"no-embedded-pic",    -MASK_EMBEDDED_PIC,                            \
434      N_("Don't use embedded PIC")},                                     \
435   {"embedded-data",       MASK_EMBEDDED_DATA,                           \
436      N_("Use ROM instead of RAM")},                                     \
437   {"no-embedded-data",   -MASK_EMBEDDED_DATA,                           \
438      N_("Don't use ROM instead of RAM")},                               \
439   {"uninit-const-in-rodata", MASK_UNINIT_CONST_IN_RODATA,               \
440      N_("Put uninitialized constants in ROM (needs -membedded-data)")}, \
441   {"no-uninit-const-in-rodata", -MASK_UNINIT_CONST_IN_RODATA,           \
442      N_("Don't put uninitialized constants in ROM")},                   \
443   {"eb",                  MASK_BIG_ENDIAN,                              \
444      N_("Use big-endian byte order")},                                  \
445   {"el",                 -MASK_BIG_ENDIAN,                              \
446      N_("Use little-endian byte order")},                               \
447   {"single-float",        MASK_SINGLE_FLOAT,                            \
448      N_("Use single (32-bit) FP only")},                                \
449   {"double-float",       -MASK_SINGLE_FLOAT,                            \
450      N_("Don't use single (32-bit) FP only")},                          \
451   {"mad",                 MASK_MAD,                                     \
452      N_("Use multiply accumulate")},                                    \
453   {"no-mad",             -MASK_MAD,                                     \
454      N_("Don't use multiply accumulate")},                              \
455   {"no-fused-madd",       MASK_NO_FUSED_MADD,                           \
456      N_("Don't generate fused multiply/add instructions")},             \
457   {"fused-madd",         -MASK_NO_FUSED_MADD,                           \
458      N_("Generate fused multiply/add instructions")},                   \
459   {"fix4300",             MASK_4300_MUL_FIX,                            \
460      N_("Work around early 4300 hardware bug")},                        \
461   {"no-fix4300",         -MASK_4300_MUL_FIX,                            \
462      N_("Don't work around early 4300 hardware bug")},                  \
463   {"3900",                0,                                            \
464      N_("Optimize for 3900")},                                          \
465   {"4650",                0,                                            \
466      N_("Optimize for 4650")},                                          \
467   {"check-zero-division",-MASK_NO_CHECK_ZERO_DIV,                       \
468      N_("Trap on integer divide by zero")},                             \
469   {"no-check-zero-division", MASK_NO_CHECK_ZERO_DIV,                    \
470      N_("Don't trap on integer divide by zero")},                       \
471   {"check-range-division",MASK_CHECK_RANGE_DIV,                         \
472      N_("Trap on integer divide overflow")},                            \
473   {"no-check-range-division",-MASK_CHECK_RANGE_DIV,                     \
474      N_("Don't trap on integer divide overflow")},                      \
475   {"debug",               MASK_DEBUG,                                   \
476      NULL},                                                             \
477   {"debuga",              MASK_DEBUG_A,                                 \
478      NULL},                                                             \
479   {"debugb",              MASK_DEBUG_B,                                 \
480      NULL},                                                             \
481   {"debugc",              MASK_DEBUG_C,                                 \
482      NULL},                                                             \
483   {"debugd",              MASK_DEBUG_D,                                 \
484      NULL},                                                             \
485   {"debuge",              MASK_DEBUG_E,                                 \
486      NULL},                                                             \
487   {"debugf",              MASK_DEBUG_F,                                 \
488      NULL},                                                             \
489   {"debugg",              MASK_DEBUG_G,                                 \
490      NULL},                                                             \
491   {"debugh",              MASK_DEBUG_H,                                 \
492      NULL},                                                             \
493   {"debugi",              MASK_DEBUG_I,                                 \
494      NULL},                                                             \
495   {"",                    (TARGET_DEFAULT                               \
496                            | TARGET_CPU_DEFAULT                         \
497                            | TARGET_ENDIAN_DEFAULT),                    \
498      NULL},                                                             \
499 }
500
501 /* Default target_flags if no switches are specified  */
502
503 #ifndef TARGET_DEFAULT
504 #define TARGET_DEFAULT 0
505 #endif
506
507 #ifndef TARGET_CPU_DEFAULT
508 #define TARGET_CPU_DEFAULT 0
509 #endif
510
511 #ifndef TARGET_ENDIAN_DEFAULT
512 #ifndef DECSTATION
513 #define TARGET_ENDIAN_DEFAULT MASK_BIG_ENDIAN
514 #else
515 #define TARGET_ENDIAN_DEFAULT 0
516 #endif
517 #endif
518
519 #ifndef MIPS_ISA_DEFAULT
520 #define MIPS_ISA_DEFAULT 1
521 #endif
522
523 #ifdef IN_LIBGCC2
524 #undef TARGET_64BIT
525 /* Make this compile time constant for libgcc2 */
526 #ifdef __mips64
527 #define TARGET_64BIT            1
528 #else
529 #define TARGET_64BIT            0
530 #endif
531 #endif /* IN_LIBGCC2 */
532
533 #ifndef MULTILIB_ENDIAN_DEFAULT
534 #if TARGET_ENDIAN_DEFAULT == 0
535 #define MULTILIB_ENDIAN_DEFAULT "EL"
536 #else
537 #define MULTILIB_ENDIAN_DEFAULT "EB"
538 #endif
539 #endif
540
541 #ifndef MULTILIB_ISA_DEFAULT
542 #  if MIPS_ISA_DEFAULT == 1
543 #    define MULTILIB_ISA_DEFAULT "mips1"
544 #  else
545 #    if MIPS_ISA_DEFAULT == 2
546 #      define MULTILIB_ISA_DEFAULT "mips2"
547 #    else
548 #      if MIPS_ISA_DEFAULT == 3
549 #        define MULTILIB_ISA_DEFAULT "mips3"
550 #      else
551 #        if MIPS_ISA_DEFAULT == 4
552 #          define MULTILIB_ISA_DEFAULT "mips4"
553 #        else
554 #          if MIPS_ISA_DEFAULT == 32
555 #            define MULTILIB_ISA_DEFAULT "mips32"
556 #          else
557 #            if MIPS_ISA_DEFAULT == 64
558 #              define MULTILIB_ISA_DEFAULT "mips64"
559 #            else
560 #          define MULTILIB_ISA_DEFAULT "mips1"
561 #         endif
562 #        endif
563 #       endif
564 #      endif
565 #    endif
566 #  endif
567 #endif
568
569 #ifndef MULTILIB_DEFAULTS
570 #define MULTILIB_DEFAULTS { MULTILIB_ENDIAN_DEFAULT, MULTILIB_ISA_DEFAULT }
571 #endif
572
573 /* We must pass -EL to the linker by default for little endian embedded
574    targets using linker scripts with a OUTPUT_FORMAT line.  Otherwise, the
575    linker will default to using big-endian output files.  The OUTPUT_FORMAT
576    line must be in the linker script, otherwise -EB/-EL will not work.  */
577
578 #ifndef ENDIAN_SPEC
579 #if TARGET_ENDIAN_DEFAULT == 0
580 #define ENDIAN_SPEC "%{!EB:%{!meb:-EL}} %{EL} %{EB}"
581 #else
582 #define ENDIAN_SPEC "%{!EL:%{!mel:-EB}} %{EB} %{EL}"
583 #endif
584 #endif
585
586 /* This macro is similar to `TARGET_SWITCHES' but defines names of
587    command options that have values.  Its definition is an
588    initializer with a subgrouping for each command option.
589
590    Each subgrouping contains a string constant, that defines the
591    fixed part of the option name, and the address of a variable.
592    The variable, type `char *', is set to the variable part of the
593    given option if the fixed part matches.  The actual option name
594    is made by appending `-m' to the specified name.
595
596    Here is an example which defines `-mshort-data-NUMBER'.  If the
597    given option is `-mshort-data-512', the variable `m88k_short_data'
598    will be set to the string `"512"'.
599
600         extern char *m88k_short_data;
601         #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } }  */
602
603 #define TARGET_OPTIONS                                                  \
604 {                                                                       \
605   SUBTARGET_TARGET_OPTIONS                                              \
606   { "cpu=",     &mips_cpu_string,                                       \
607       N_("Specify CPU for scheduling purposes")},                       \
608   { "tune=",    &mips_tune_string,                                   \
609       N_("Specify CPU for scheduling purposes")},                       \
610   { "arch=",    &mips_arch_string,                                      \
611       N_("Specify CPU for code generation purposes")},                  \
612   { "ips",      &mips_isa_string,                                       \
613       N_("Specify a Standard MIPS ISA")},                               \
614   { "entry",    &mips_entry_string,                                     \
615       N_("Use mips16 entry/exit psuedo ops")},                          \
616   { "no-mips16", &mips_no_mips16_string,                                \
617       N_("Don't use MIPS16 instructions")},                             \
618   { "explicit-type-size", &mips_explicit_type_size_string,              \
619       NULL},                                                            \
620   { "no-flush-func", &mips_cache_flush_func,                            \
621       N_("Don't call any cache flush functions")},                      \
622   { "flush-func=", &mips_cache_flush_func,                              \
623       N_("Specify cache flush function")},                              \
624 }
625
626 /* This is meant to be redefined in the host dependent files.  */
627 #define SUBTARGET_TARGET_OPTIONS
628
629 #define GENERATE_BRANCHLIKELY  (!TARGET_MIPS16 && ISA_HAS_BRANCHLIKELY)
630
631 /* Generate three-operand multiply instructions for SImode.  */
632 #define GENERATE_MULT3_SI       ((TARGET_MIPS3900                       \
633                                   || mips_isa == 32                     \
634                                   || mips_isa == 64)                    \
635                                  && !TARGET_MIPS16)
636
637 /* Generate three-operand multiply instructions for DImode.  */
638 #define GENERATE_MULT3_DI       ((TARGET_MIPS3900)                      \
639                                  && !TARGET_MIPS16)
640
641 /* Macros to decide whether certain features are available or not,
642    depending on the instruction set architecture level.  */
643
644 #define BRANCH_LIKELY_P()       GENERATE_BRANCHLIKELY
645 #define HAVE_SQRT_P()           (mips_isa != 1)
646
647 /* ISA has instructions for managing 64 bit fp and gp regs (eg. mips3).  */
648 #define ISA_HAS_64BIT_REGS      (mips_isa == 3          \
649                                  || mips_isa == 4       \
650                                  || mips_isa == 64)
651
652 /* ISA has branch likely instructions (eg. mips2).  */
653 /* Disable branchlikely for tx39 until compare rewrite.  They haven't
654    been generated up to this point.  */
655 #define ISA_HAS_BRANCHLIKELY    (mips_isa != 1                          \
656                                  /* || TARGET_MIPS3900 */)
657
658 /* ISA has the conditional move instructions introduced in mips4.  */
659 #define ISA_HAS_CONDMOVE        (mips_isa == 4                          \
660                                  || mips_isa == 32                      \
661                                  || mips_isa == 64)
662
663 /* ISA has just the integer condition move instructions (movn,movz) */
664 #define ISA_HAS_INT_CONDMOVE     0
665
666
667
668 /* ISA has the mips4 FP condition code instructions: FP-compare to CC,
669    branch on CC, and move (both FP and non-FP) on CC.  */
670 #define ISA_HAS_8CC             (mips_isa == 4                          \
671                                  || mips_isa == 32                      \
672                                  || mips_isa == 64)
673
674
675 /* This is a catch all for the other new mips4 instructions: indexed load and
676    indexed prefetch instructions, the FP madd,msub,nmadd, and nmsub instructions,
677    and the FP recip and recip sqrt instructions */
678 #define ISA_HAS_FP4             (mips_isa == 4                          \
679                                 )
680
681 /* ISA has conditional trap instructions.  */
682 #define ISA_HAS_COND_TRAP       (mips_isa >= 2)
683
684 /* ISA has multiply-accumulate instructions, madd and msub.  */
685 #define ISA_HAS_MADD_MSUB       (mips_isa == 32                         \
686                                 || mips_isa == 64                       \
687                                 )
688
689 /* ISA has nmadd and nmsub instructions.  */
690 #define ISA_HAS_NMADD_NMSUB     (mips_isa == 4                          \
691                                 )
692
693 /* ISA has count leading zeroes/ones instruction (not implemented).  */
694 #define ISA_HAS_CLZ_CLO         (mips_isa == 32                         \
695                                 || mips_isa == 64                       \
696                                 )
697
698 /* ISA has double-word count leading zeroes/ones instruction (not
699    implemented).  */
700 #define ISA_HAS_DCLZ_DCLO       (mips_isa == 64)
701
702
703 /* CC1_SPEC causes -mips3 and -mips4 to set -mfp64 and -mgp64; -mips1 or
704    -mips2 sets -mfp32 and -mgp32.  This can be overridden by an explicit
705    -mfp32, -mfp64, -mgp32 or -mgp64.  -mfp64 sets MASK_FLOAT64 in
706    target_flags, and -mgp64 sets MASK_64BIT.
707
708    Setting MASK_64BIT in target_flags will cause gcc to assume that
709    registers are 64 bits wide.  int, long and void * will be 32 bit;
710    this may be changed with -mint64 or -mlong64.
711
712    The gen* programs link code that refers to MASK_64BIT.  They don't
713    actually use the information in target_flags; they just refer to
714    it.  */
715 \f
716 /* Switch  Recognition by gcc.c.  Add -G xx support */
717
718 #undef  SWITCH_TAKES_ARG
719 #define SWITCH_TAKES_ARG(CHAR)                                          \
720   (DEFAULT_SWITCH_TAKES_ARG (CHAR) || (CHAR) == 'G')
721
722 /* Sometimes certain combinations of command options do not make sense
723    on a particular target machine.  You can define a macro
724    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
725    defined, is executed once just after all the command options have
726    been parsed.
727
728    On the MIPS, it is used to handle -G.  We also use it to set up all
729    of the tables referenced in the other macros.  */
730
731 #define OVERRIDE_OPTIONS override_options ()
732
733 /* Zero or more C statements that may conditionally modify two
734    variables `fixed_regs' and `call_used_regs' (both of type `char
735    []') after they have been initialized from the two preceding
736    macros.
737
738    This is necessary in case the fixed or call-clobbered registers
739    depend on target flags.
740
741    You need not define this macro if it has no work to do.
742
743    If the usage of an entire class of registers depends on the target
744    flags, you may indicate this to GCC by using this macro to modify
745    `fixed_regs' and `call_used_regs' to 1 for each of the registers in
746    the classes which should not be used by GCC.  Also define the macro
747    `REG_CLASS_FROM_LETTER' to return `NO_REGS' if it is called with a
748    letter for a class that shouldn't be used.
749
750    (However, if this class is not included in `GENERAL_REGS' and all
751    of the insn patterns whose constraints permit this class are
752    controlled by target switches, then GCC will automatically avoid
753    using these registers when the target switches are opposed to
754    them.)  */
755
756 #define CONDITIONAL_REGISTER_USAGE                                      \
757 do                                                                      \
758   {                                                                     \
759     if (!TARGET_HARD_FLOAT)                                             \
760       {                                                                 \
761         int regno;                                                      \
762                                                                         \
763         for (regno = FP_REG_FIRST; regno <= FP_REG_LAST; regno++)       \
764           fixed_regs[regno] = call_used_regs[regno] = 1;                \
765         for (regno = ST_REG_FIRST; regno <= ST_REG_LAST; regno++)       \
766           fixed_regs[regno] = call_used_regs[regno] = 1;                \
767       }                                                                 \
768     else if (! ISA_HAS_8CC)                                             \
769       {                                                                 \
770         int regno;                                                      \
771                                                                         \
772         /* We only have a single condition code register.  We           \
773            implement this by hiding all the condition code registers,   \
774            and generating RTL that refers directly to ST_REG_FIRST.  */ \
775         for (regno = ST_REG_FIRST; regno <= ST_REG_LAST; regno++)       \
776           fixed_regs[regno] = call_used_regs[regno] = 1;                \
777       }                                                                 \
778     /* In mips16 mode, we permit the $t temporary registers to be used  \
779        for reload.  We prohibit the unused $s registers, since they     \
780        are caller saved, and saving them via a mips16 register would    \
781        probably waste more time than just reloading the value.  */      \
782     if (TARGET_MIPS16)                                                  \
783       {                                                                 \
784         fixed_regs[18] = call_used_regs[18] = 1;                        \
785         fixed_regs[19] = call_used_regs[19] = 1;                        \
786         fixed_regs[20] = call_used_regs[20] = 1;                        \
787         fixed_regs[21] = call_used_regs[21] = 1;                        \
788         fixed_regs[22] = call_used_regs[22] = 1;                        \
789         fixed_regs[23] = call_used_regs[23] = 1;                        \
790         fixed_regs[26] = call_used_regs[26] = 1;                        \
791         fixed_regs[27] = call_used_regs[27] = 1;                        \
792         fixed_regs[30] = call_used_regs[30] = 1;                        \
793       }                                                                 \
794     SUBTARGET_CONDITIONAL_REGISTER_USAGE                                \
795   }                                                                     \
796 while (0)
797
798 /* This is meant to be redefined in the host dependent files.  */
799 #define SUBTARGET_CONDITIONAL_REGISTER_USAGE
800
801 /* Show we can debug even without a frame pointer.  */
802 #define CAN_DEBUG_WITHOUT_FP
803 \f
804 /* Complain about missing specs and predefines that should be defined in each
805    of the target tm files to override the defaults.  This is mostly a place-
806    holder until I can get each of the files updated [mm].  */
807
808 #if defined(OSF_OS) \
809     || defined(DECSTATION) \
810     || defined(SGI_TARGET) \
811     || defined(MIPS_NEWS) \
812     || defined(MIPS_SYSV) \
813     || defined(MIPS_SVR4) \
814     || defined(MIPS_BSD43)
815
816 #ifndef CPP_PREDEFINES
817         #error "Define CPP_PREDEFINES in the appropriate tm.h file"
818 #endif
819
820 #ifndef LIB_SPEC
821         #error "Define LIB_SPEC in the appropriate tm.h file"
822 #endif
823
824 #ifndef STARTFILE_SPEC
825         #error "Define STARTFILE_SPEC in the appropriate tm.h file"
826 #endif
827
828 #ifndef MACHINE_TYPE
829         #error "Define MACHINE_TYPE in the appropriate tm.h file"
830 #endif
831 #endif
832
833 /* Tell collect what flags to pass to nm.  */
834 #ifndef NM_FLAGS
835 #define NM_FLAGS "-Bn"
836 #endif
837
838 \f
839 /* Names to predefine in the preprocessor for this target machine.  */
840
841 #ifndef CPP_PREDEFINES
842 #define CPP_PREDEFINES "-Dmips -Dunix -Dhost_mips -DMIPSEB -DR3000 -DSYSTYPE_BSD43 \
843 -D_mips -D_unix -D_host_mips -D_MIPSEB -D_R3000 -D_SYSTYPE_BSD43 \
844 -Asystem=unix -Asystem=bsd -Acpu=mips -Amachine=mips"
845 #endif
846
847 /* Assembler specs.  */
848
849 /* MIPS_AS_ASM_SPEC is passed when using the MIPS assembler rather
850    than gas.  */
851
852 #define MIPS_AS_ASM_SPEC "\
853 %{!.s:-nocpp} %{.s: %{cpp} %{nocpp}} \
854 %{pipe: %e-pipe is not supported} \
855 %{K} %(subtarget_mips_as_asm_spec)"
856
857 /* SUBTARGET_MIPS_AS_ASM_SPEC is passed when using the MIPS assembler
858    rather than gas.  It may be overridden by subtargets.  */
859
860 #ifndef SUBTARGET_MIPS_AS_ASM_SPEC
861 #define SUBTARGET_MIPS_AS_ASM_SPEC "%{v}"
862 #endif
863
864 /* GAS_ASM_SPEC is passed when using gas, rather than the MIPS
865    assembler.  */
866
867 #define GAS_ASM_SPEC "%{march=*} %{mtune=*} %{mcpu=*} %{m4650} %{mmad:-m4650} %{m3900} %{v} %{mgp32} %{mgp64} %(abi_gas_asm_spec) %{mabi=32:%{!mips*:-mips1}}"
868
869
870 /* We use the o32 abi as default for mips1 and mips2.  SGI uses n32/n64 for
871    mips3 and mips4 by default, however, this is unsupported at this point in
872    binutils so we use o64. This should change when n32/n64 is supported.  */
873
874 extern int mips_abi;
875
876 #ifndef MIPS_ABI_DEFAULT
877 #define MIPS_ABI_DEFAULT ABI_32
878 #endif
879
880 #if MIPS_ABI_DEFAULT == ABI_32
881 #define ABI_GAS_ASM_SPEC "%{mabi=*} \
882 %{!mabi=*:%{mips3|mips4|mips5|mips64:-mabi=o64} %{!mips3:%{!mips4:%{!mips5:%{!mips64:-mabi=32}}}}}"
883 #endif
884
885 #if MIPS_ABI_DEFAULT == ABI_N32
886 #define ABI_GAS_ASM_SPEC "%{mabi=*} %{!mabi=*:-mabi=n32}"
887 #endif
888
889 #if MIPS_ABI_DEFAULT == ABI_64
890 #define ABI_GAS_ASM_SPEC "%{mabi=*} %{!mabi=*:-mabi=64}"
891 #endif
892
893 #if MIPS_ABI_DEFAULT == ABI_EABI
894 #define ABI_GAS_ASM_SPEC "%{mabi=*} %{!mabi=*:-mabi=eabi}"
895 #endif
896
897 #if MIPS_ABI_DEFAULT == ABI_O64
898 #define ABI_GAS_ASM_SPEC "\
899 %{mabi=*} \
900 %{!mabi=*:%{mips1|mips2|mips32:-mabi=32} %{!mips1:%{!mips2:%{!mips3:%{!mips32:-mabi=o64}}}}}"
901 #endif
902
903 #if MIPS_ABI_DEFAULT == ABI_MEABI
904 #define ABI_GAS_ASM_SPEC "\
905 %{mabi=*} \
906 %{!mabi=*:-mabi=meabi }"
907 #endif
908
909 #ifndef ABI_GAS_ASM_SPEC
910  #error "Unhandled MIPS_ABI_DEFAULT"
911 #endif
912
913 /* TARGET_ASM_SPEC is used to select either MIPS_AS_ASM_SPEC or
914    GAS_ASM_SPEC as the default, depending upon the value of
915    TARGET_DEFAULT.  */
916
917 #if ((TARGET_CPU_DEFAULT | TARGET_DEFAULT) & MASK_GAS) != 0
918 /* GAS */
919
920 #define TARGET_ASM_SPEC "\
921 %{mmips-as: %(mips_as_asm_spec)} \
922 %{!mmips-as: %(gas_asm_spec)}"
923
924 #else /* not GAS */
925
926 #define TARGET_ASM_SPEC "\
927 %{!mgas: %(mips_as_asm_spec)} \
928 %{mgas: %(gas_asm_spec)}"
929
930 #endif /* not GAS */
931
932 /* SUBTARGET_ASM_OPTIMIZING_SPEC handles passing optimization options
933    to the assembler.  It may be overridden by subtargets.  */
934 #ifndef SUBTARGET_ASM_OPTIMIZING_SPEC
935 #define SUBTARGET_ASM_OPTIMIZING_SPEC "\
936 %{noasmopt:-O0} \
937 %{!noasmopt:%{O:-O2} %{O1:-O2} %{O2:-O2} %{O3:-O3}}"
938 #endif
939
940 /* SUBTARGET_ASM_DEBUGGING_SPEC handles passing debugging options to
941    the assembler.  It may be overridden by subtargets.  */
942 #ifndef SUBTARGET_ASM_DEBUGGING_SPEC
943 #define SUBTARGET_ASM_DEBUGGING_SPEC "\
944 %{g} %{g0} %{g1} %{g2} %{g3} \
945 %{ggdb:-g} %{ggdb0:-g0} %{ggdb1:-g1} %{ggdb2:-g2} %{ggdb3:-g3} \
946 %{gstabs:-g} %{gstabs0:-g0} %{gstabs1:-g1} %{gstabs2:-g2} %{gstabs3:-g3} \
947 %{gstabs+:-g} %{gstabs+0:-g0} %{gstabs+1:-g1} %{gstabs+2:-g2} %{gstabs+3:-g3} \
948 %{gcoff:-g} %{gcoff0:-g0} %{gcoff1:-g1} %{gcoff2:-g2} %{gcoff3:-g3}"
949 #endif
950
951 /* SUBTARGET_ASM_SPEC is always passed to the assembler.  It may be
952    overridden by subtargets.  */
953
954 #ifndef SUBTARGET_ASM_SPEC
955 #define SUBTARGET_ASM_SPEC ""
956 #endif
957
958 /* ASM_SPEC is the set of arguments to pass to the assembler.  */
959
960 #undef ASM_SPEC
961 #define ASM_SPEC "\
962 %{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips64}\
963 %{mips16:%{!mno-mips16:-mips16}} %{mno-mips16:-no-mips16} \
964 %(subtarget_asm_optimizing_spec) \
965 %(subtarget_asm_debugging_spec) \
966 %{membedded-pic} \
967 %{mabi=32:-32}%{mabi=o32:-32}%{mabi=n32:-n32}%{mabi=64:-64}%{mabi=n64:-64} \
968 %(target_asm_spec) \
969 %(subtarget_asm_spec)"
970
971 /* Specify to run a post-processor, mips-tfile after the assembler
972    has run to stuff the mips debug information into the object file.
973    This is needed because the $#!%^ MIPS assembler provides no way
974    of specifying such information in the assembly file.  If we are
975    cross compiling, disable mips-tfile unless the user specifies
976    -mmips-tfile.  */
977
978 #ifndef ASM_FINAL_SPEC
979 #if ((TARGET_CPU_DEFAULT | TARGET_DEFAULT) & MASK_GAS) != 0
980 /* GAS */
981 #define ASM_FINAL_SPEC "\
982 %{mmips-as: %{!mno-mips-tfile: \
983         \n mips-tfile %{v*: -v} \
984                 %{K: -I %b.o~} \
985                 %{!K: %{save-temps: -I %b.o~}} \
986                 %{c:%W{o*}%{!o*:-o %b.o}}%{!c:-o %U.o} \
987                 %{.s:%i} %{!.s:%g.s}}}"
988
989 #else
990 /* not GAS */
991 #define ASM_FINAL_SPEC "\
992 %{!mgas: %{!mno-mips-tfile: \
993         \n mips-tfile %{v*: -v} \
994                 %{K: -I %b.o~} \
995                 %{!K: %{save-temps: -I %b.o~}} \
996                 %{c:%W{o*}%{!o*:-o %b.o}}%{!c:-o %U.o} \
997                 %{.s:%i} %{!.s:%g.s}}}"
998
999 #endif
1000 #endif  /* ASM_FINAL_SPEC */
1001
1002 /* Redefinition of libraries used.  Mips doesn't support normal
1003    UNIX style profiling via calling _mcount.  It does offer
1004    profiling that samples the PC, so do what we can...  */
1005
1006 #ifndef LIB_SPEC
1007 #define LIB_SPEC "%{pg:-lprof1} %{p:-lprof1} -lc"
1008 #endif
1009
1010 /* Extra switches sometimes passed to the linker.  */
1011 /* ??? The bestGnum will never be passed to the linker, because the gcc driver
1012   will interpret it as a -b option.  */
1013
1014 #ifndef LINK_SPEC
1015 #define LINK_SPEC "\
1016 %(endian_spec) \
1017 %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips64} \
1018 %{bestGnum} %{shared} %{non_shared}"
1019 #endif  /* LINK_SPEC defined */
1020
1021
1022 /* Specs for the compiler proper */
1023
1024 /* SUBTARGET_CC1_SPEC is passed to the compiler proper.  It may be
1025    overridden by subtargets.  */
1026 #ifndef SUBTARGET_CC1_SPEC
1027 #define SUBTARGET_CC1_SPEC ""
1028 #endif
1029
1030 /* Deal with historic options.  */
1031 #ifndef CC1_CPU_SPEC
1032 #define CC1_CPU_SPEC "\
1033 %{!mcpu*: \
1034 %{m3900:-march=r3900 -mips1 -mfp32 -mgp32 \
1035 %n`-m3900' is deprecated. Use `-march=r3900' instead.\n} \
1036 %{m4650:-march=r4650 -mmad -msingle-float \
1037 %n`-m4650' is deprecated. Use `-march=r4650' instead.\n}}"
1038 #endif
1039
1040 /* CC1_SPEC is the set of arguments to pass to the compiler proper.  */
1041 /* Note, we will need to adjust the following if we ever find a MIPS variant
1042    that has 32-bit GPRs and 64-bit FPRs as well as fix all of the reload bugs
1043    that show up in this case.  */
1044
1045 #ifndef CC1_SPEC
1046 #define CC1_SPEC "\
1047 %{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \
1048 %{mips1:-mfp32 -mgp32} %{mips2:-mfp32 -mgp32}\
1049 %{mips3:%{!msingle-float:%{!m4650:-mfp64}} -mgp64} \
1050 %{mips4:%{!msingle-float:%{!m4650:-mfp64}} -mgp64} \
1051 %{mips32:-mfp32 -mgp32} \
1052 %{mips64:%{!msingle-float:%{!m4650:-mfp64}} -mgp64} \
1053 %{mfp64:%{msingle-float:%emay not use both -mfp64 and -msingle-float}} \
1054 %{mfp64:%{m4650:%emay not use both -mfp64 and -m4650}} \
1055 %{mint64|mlong64|mlong32:-mexplicit-type-size }\
1056 %{mgp32: %{mfp64:%emay not use both -mgp32 and -mfp64} %{!mfp32: -mfp32}} \
1057 %{G*} %{EB:-meb} %{EL:-mel} %{EB:%{EL:%emay not use both -EB and -EL}} \
1058 %{pic-none:   -mno-half-pic} \
1059 %{pic-lib:    -mhalf-pic} \
1060 %{pic-extern: -mhalf-pic} \
1061 %{pic-calls:  -mhalf-pic} \
1062 %{save-temps: } \
1063 %(subtarget_cc1_spec) \
1064 %(cc1_cpu_spec)"
1065 #endif
1066
1067 /* Preprocessor specs.  */
1068
1069 /* SUBTARGET_CPP_SIZE_SPEC defines SIZE_TYPE and PTRDIFF_TYPE.  It may
1070    be overridden by subtargets.  */
1071
1072 #ifndef SUBTARGET_CPP_SIZE_SPEC
1073 #define SUBTARGET_CPP_SIZE_SPEC "\
1074 %{mlong64:%{!mips1:%{!mips2:%{!mips32:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int}}}} \
1075 %{!mlong64:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}"
1076 #endif
1077
1078 /* SUBTARGET_CPP_SPEC is passed to the preprocessor.  It may be
1079    overridden by subtargets.  */
1080 #ifndef SUBTARGET_CPP_SPEC
1081 #define SUBTARGET_CPP_SPEC ""
1082 #endif
1083
1084 /* If we're using 64bit longs, then we have to define __LONG_MAX__
1085    correctly.  Similarly for 64bit ints and __INT_MAX__.  */
1086 #ifndef LONG_MAX_SPEC
1087 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_LONG64)
1088 #define LONG_MAX_SPEC "%{!mlong32:-D__LONG_MAX__=9223372036854775807L}"
1089 #else
1090 #define LONG_MAX_SPEC "%{mlong64:-D__LONG_MAX__=9223372036854775807L}"
1091 #endif
1092 #endif
1093
1094 /* Define appropriate macros for fpr register size.  */
1095 #ifndef CPP_FPR_SPEC
1096 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_FLOAT64)
1097 #define CPP_FPR_SPEC "-D__mips_fpr=64"
1098 #else
1099 #define CPP_FPR_SPEC "-D__mips_fpr=32"
1100 #endif
1101 #endif
1102
1103 /* For C++ we need to ensure that _LANGUAGE_C_PLUS_PLUS is defined independent
1104    of the source file extension.  */
1105 #undef CPLUSPLUS_CPP_SPEC
1106 #define CPLUSPLUS_CPP_SPEC "\
1107 -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
1108 %(cpp) \
1109 "
1110 /* CPP_SPEC is the set of arguments to pass to the preprocessor.  */
1111
1112 #ifndef CPP_SPEC
1113 #define CPP_SPEC "\
1114 %{.m:   -D__LANGUAGE_OBJECTIVE_C -D_LANGUAGE_OBJECTIVE_C -D__LANGUAGE_C -D_LANGUAGE_C} \
1115 %{.S|.s: -D__LANGUAGE_ASSEMBLY -D_LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
1116 %{!.S: %{!.s: %{!.cc: %{!.cxx: %{!.cpp: %{!.cp: %{!.c++: %{!.C: %{!.m: -D__LANGUAGE_C -D_LANGUAGE_C %{!ansi:-DLANGUAGE_C}}}}}}}}}} \
1117 %(subtarget_cpp_size_spec) \
1118 %{mips3:-U__mips -D__mips=3 -D__mips64} \
1119 %{mips4:-U__mips -D__mips=4 -D__mips64} \
1120 %{mips32:-U__mips -D__mips=32} \
1121 %{mips64:-U__mips -D__mips=64 -D__mips64} \
1122 %{mgp32:-U__mips64} %{mgp64:-D__mips64} \
1123 %{mfp32:-D__mips_fpr=32} %{mfp64:-D__mips_fpr=64} %{!mfp32: %{!mfp64: %{mgp32:-D__mips_fpr=32} %{!mgp32: %(cpp_fpr_spec)}}} \
1124 %{msingle-float:%{!msoft-float:-D__mips_single_float}} \
1125 %{m4650:%{!msoft-float:-D__mips_single_float}} \
1126 %{msoft-float:-D__mips_soft_float} \
1127 %{mabi=eabi:-D__mips_eabi} \
1128 %{mips16:%{!mno-mips16:-D__mips16}} \
1129 %{EB:-UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__ -D_MIPSEB -D__MIPSEB -D__MIPSEB__ %{!ansi:-DMIPSEB}} \
1130 %{EL:-UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__ -D_MIPSEL -D__MIPSEL -D__MIPSEL__ %{!ansi:-DMIPSEL}} \
1131 %(long_max_spec) \
1132 %(subtarget_cpp_spec) "
1133 #endif
1134
1135 /* This macro defines names of additional specifications to put in the specs
1136    that can be used in various specifications like CC1_SPEC.  Its definition
1137    is an initializer with a subgrouping for each command option.
1138
1139    Each subgrouping contains a string constant, that defines the
1140    specification name, and a string constant that used by the GNU CC driver
1141    program.
1142
1143    Do not define this macro if it does not need to do anything.  */
1144
1145 #define EXTRA_SPECS                                                     \
1146   { "subtarget_cc1_spec", SUBTARGET_CC1_SPEC },                         \
1147   { "cc1_cpu_spec", CC1_CPU_SPEC},                                      \
1148   { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC },                         \
1149   { "subtarget_cpp_size_spec", SUBTARGET_CPP_SIZE_SPEC },               \
1150   { "long_max_spec", LONG_MAX_SPEC },                                   \
1151   { "cpp_fpr_spec", CPP_FPR_SPEC },                                     \
1152   { "mips_as_asm_spec", MIPS_AS_ASM_SPEC },                             \
1153   { "gas_asm_spec", GAS_ASM_SPEC },                                     \
1154   { "abi_gas_asm_spec", ABI_GAS_ASM_SPEC },                             \
1155   { "target_asm_spec", TARGET_ASM_SPEC },                               \
1156   { "subtarget_mips_as_asm_spec", SUBTARGET_MIPS_AS_ASM_SPEC },         \
1157   { "subtarget_asm_optimizing_spec", SUBTARGET_ASM_OPTIMIZING_SPEC },   \
1158   { "subtarget_asm_debugging_spec", SUBTARGET_ASM_DEBUGGING_SPEC },     \
1159   { "subtarget_asm_spec", SUBTARGET_ASM_SPEC },                         \
1160   { "endian_spec", ENDIAN_SPEC },                                       \
1161   SUBTARGET_EXTRA_SPECS
1162
1163 #ifndef SUBTARGET_EXTRA_SPECS
1164 #define SUBTARGET_EXTRA_SPECS
1165 #endif
1166
1167 /* If defined, this macro is an additional prefix to try after
1168    `STANDARD_EXEC_PREFIX'.  */
1169
1170 #ifndef MD_EXEC_PREFIX
1171 #define MD_EXEC_PREFIX "/usr/lib/cmplrs/cc/"
1172 #endif
1173
1174 #ifndef MD_STARTFILE_PREFIX
1175 #define MD_STARTFILE_PREFIX "/usr/lib/cmplrs/cc/"
1176 #endif
1177
1178 \f
1179 /* Print subsidiary information on the compiler version in use.  */
1180
1181 #define MIPS_VERSION "[AL 1.1, MM 40]"
1182
1183 #ifndef MACHINE_TYPE
1184 #define MACHINE_TYPE "BSD Mips"
1185 #endif
1186
1187 #ifndef TARGET_VERSION_INTERNAL
1188 #define TARGET_VERSION_INTERNAL(STREAM)                                 \
1189   fprintf (STREAM, " %s %s", MIPS_VERSION, MACHINE_TYPE)
1190 #endif
1191
1192 #ifndef TARGET_VERSION
1193 #define TARGET_VERSION TARGET_VERSION_INTERNAL (stderr)
1194 #endif
1195
1196 \f
1197 #define SDB_DEBUGGING_INFO              /* generate info for mips-tfile */
1198 #define DBX_DEBUGGING_INFO              /* generate stabs (OSF/rose) */
1199 #define MIPS_DEBUGGING_INFO             /* MIPS specific debugging info */
1200
1201 #ifndef PREFERRED_DEBUGGING_TYPE        /* assume SDB_DEBUGGING_INFO */
1202 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
1203 #endif
1204
1205 /* By default, turn on GDB extensions.  */
1206 #define DEFAULT_GDB_EXTENSIONS 1
1207
1208 /* If we are passing smuggling stabs through the MIPS ECOFF object
1209    format, put a comment in front of the .stab<x> operation so
1210    that the MIPS assembler does not choke.  The mips-tfile program
1211    will correctly put the stab into the object file.  */
1212
1213 #define ASM_STABS_OP    ((TARGET_GAS) ? "\t.stabs\t" : " #.stabs\t")
1214 #define ASM_STABN_OP    ((TARGET_GAS) ? "\t.stabn\t" : " #.stabn\t")
1215 #define ASM_STABD_OP    ((TARGET_GAS) ? "\t.stabd\t" : " #.stabd\t")
1216
1217 /* Local compiler-generated symbols must have a prefix that the assembler
1218    understands.   By default, this is $, although some targets (e.g.,
1219    NetBSD-ELF) need to override this.  */
1220
1221 #ifndef LOCAL_LABEL_PREFIX
1222 #define LOCAL_LABEL_PREFIX      "$"
1223 #endif
1224
1225 /* By default on the mips, external symbols do not have an underscore
1226    prepended, but some targets (e.g., NetBSD) require this.  */
1227
1228 #ifndef USER_LABEL_PREFIX
1229 #define USER_LABEL_PREFIX       ""
1230 #endif
1231
1232 /* Forward references to tags are allowed.  */
1233 #define SDB_ALLOW_FORWARD_REFERENCES
1234
1235 /* Unknown tags are also allowed.  */
1236 #define SDB_ALLOW_UNKNOWN_REFERENCES
1237
1238 /* On Sun 4, this limit is 2048.  We use 1500 to be safe,
1239    since the length can run past this up to a continuation point.  */
1240 #undef DBX_CONTIN_LENGTH
1241 #define DBX_CONTIN_LENGTH 1500
1242
1243 /* How to renumber registers for dbx and gdb.  */
1244 #define DBX_REGISTER_NUMBER(REGNO) mips_dbx_regno[ (REGNO) ]
1245
1246 /* The mapping from gcc register number to DWARF 2 CFA column number.
1247    This mapping does not allow for tracking register 0, since SGI's broken
1248    dwarf reader thinks column 0 is used for the frame address, but since
1249    register 0 is fixed this is not a problem.  */
1250 #define DWARF_FRAME_REGNUM(REG)                         \
1251   (REG == GP_REG_FIRST + 31 ? DWARF_FRAME_RETURN_COLUMN : REG)
1252
1253 /* The DWARF 2 CFA column which tracks the return address.  */
1254 #define DWARF_FRAME_RETURN_COLUMN (FP_REG_LAST + 1)
1255
1256 /* Before the prologue, RA lives in r31.  */
1257 #define INCOMING_RETURN_ADDR_RTX  gen_rtx_REG (VOIDmode, GP_REG_FIRST + 31)
1258
1259 /* Describe how we implement __builtin_eh_return.  */
1260 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + GP_ARG_FIRST : INVALID_REGNUM)
1261 #define EH_RETURN_STACKADJ_RTX  gen_rtx_REG (Pmode, GP_REG_FIRST + 3)
1262
1263 /* Offsets recorded in opcodes are a multiple of this alignment factor.
1264    The default for this in 64-bit mode is 8, which causes problems with
1265    SFmode register saves.  */
1266 #define DWARF_CIE_DATA_ALIGNMENT 4
1267
1268 /* Overrides for the COFF debug format.  */
1269 #define PUT_SDB_SCL(a)                                  \
1270 do {                                                    \
1271   extern FILE *asm_out_text_file;                       \
1272   fprintf (asm_out_text_file, "\t.scl\t%d;", (a));      \
1273 } while (0)
1274
1275 #define PUT_SDB_INT_VAL(a)                              \
1276 do {                                                    \
1277   extern FILE *asm_out_text_file;                       \
1278   fprintf (asm_out_text_file, "\t.val\t");              \
1279   fprintf (asm_out_text_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
1280   fprintf (asm_out_text_file, ";");                     \
1281 } while (0)
1282
1283 #define PUT_SDB_VAL(a)                                  \
1284 do {                                                    \
1285   extern FILE *asm_out_text_file;                       \
1286   fputs ("\t.val\t", asm_out_text_file);                \
1287   output_addr_const (asm_out_text_file, (a));           \
1288   fputc (';', asm_out_text_file);                       \
1289 } while (0)
1290
1291 #define PUT_SDB_DEF(a)                                  \
1292 do {                                                    \
1293   extern FILE *asm_out_text_file;                       \
1294   fprintf (asm_out_text_file, "\t%s.def\t",             \
1295            (TARGET_GAS) ? "" : "#");                    \
1296   ASM_OUTPUT_LABELREF (asm_out_text_file, a);           \
1297   fputc (';', asm_out_text_file);                       \
1298 } while (0)
1299
1300 #define PUT_SDB_PLAIN_DEF(a)                            \
1301 do {                                                    \
1302   extern FILE *asm_out_text_file;                       \
1303   fprintf (asm_out_text_file, "\t%s.def\t.%s;",         \
1304            (TARGET_GAS) ? "" : "#", (a));               \
1305 } while (0)
1306
1307 #define PUT_SDB_ENDEF                                   \
1308 do {                                                    \
1309   extern FILE *asm_out_text_file;                       \
1310   fprintf (asm_out_text_file, "\t.endef\n");            \
1311 } while (0)
1312
1313 #define PUT_SDB_TYPE(a)                                 \
1314 do {                                                    \
1315   extern FILE *asm_out_text_file;                       \
1316   fprintf (asm_out_text_file, "\t.type\t0x%x;", (a));   \
1317 } while (0)
1318
1319 #define PUT_SDB_SIZE(a)                                 \
1320 do {                                                    \
1321   extern FILE *asm_out_text_file;                       \
1322   fprintf (asm_out_text_file, "\t.size\t");             \
1323   fprintf (asm_out_text_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
1324   fprintf (asm_out_text_file, ";");                     \
1325 } while (0)
1326
1327 #define PUT_SDB_DIM(a)                                  \
1328 do {                                                    \
1329   extern FILE *asm_out_text_file;                       \
1330   fprintf (asm_out_text_file, "\t.dim\t%d;", (a));      \
1331 } while (0)
1332
1333 #ifndef PUT_SDB_START_DIM
1334 #define PUT_SDB_START_DIM                               \
1335 do {                                                    \
1336   extern FILE *asm_out_text_file;                       \
1337   fprintf (asm_out_text_file, "\t.dim\t");              \
1338 } while (0)
1339 #endif
1340
1341 #ifndef PUT_SDB_NEXT_DIM
1342 #define PUT_SDB_NEXT_DIM(a)                             \
1343 do {                                                    \
1344   extern FILE *asm_out_text_file;                       \
1345   fprintf (asm_out_text_file, "%d,", a);                \
1346 } while (0)
1347 #endif
1348
1349 #ifndef PUT_SDB_LAST_DIM
1350 #define PUT_SDB_LAST_DIM(a)                             \
1351 do {                                                    \
1352   extern FILE *asm_out_text_file;                       \
1353   fprintf (asm_out_text_file, "%d;", a);                \
1354 } while (0)
1355 #endif
1356
1357 #define PUT_SDB_TAG(a)                                  \
1358 do {                                                    \
1359   extern FILE *asm_out_text_file;                       \
1360   fprintf (asm_out_text_file, "\t.tag\t");              \
1361   ASM_OUTPUT_LABELREF (asm_out_text_file, a);           \
1362   fputc (';', asm_out_text_file);                       \
1363 } while (0)
1364
1365 /* For block start and end, we create labels, so that
1366    later we can figure out where the correct offset is.
1367    The normal .ent/.end serve well enough for functions,
1368    so those are just commented out.  */
1369
1370 #define PUT_SDB_BLOCK_START(LINE)                       \
1371 do {                                                    \
1372   extern FILE *asm_out_text_file;                       \
1373   fprintf (asm_out_text_file,                           \
1374            "%sLb%d:\n\t%s.begin\t%sLb%d\t%d\n",         \
1375            LOCAL_LABEL_PREFIX,                          \
1376            sdb_label_count,                             \
1377            (TARGET_GAS) ? "" : "#",                     \
1378            LOCAL_LABEL_PREFIX,                          \
1379            sdb_label_count,                             \
1380            (LINE));                                     \
1381   sdb_label_count++;                                    \
1382 } while (0)
1383
1384 #define PUT_SDB_BLOCK_END(LINE)                         \
1385 do {                                                    \
1386   extern FILE *asm_out_text_file;                       \
1387   fprintf (asm_out_text_file,                           \
1388            "%sLe%d:\n\t%s.bend\t%sLe%d\t%d\n",          \
1389            LOCAL_LABEL_PREFIX,                          \
1390            sdb_label_count,                             \
1391            (TARGET_GAS) ? "" : "#",                     \
1392            LOCAL_LABEL_PREFIX,                          \
1393            sdb_label_count,                             \
1394            (LINE));                                     \
1395   sdb_label_count++;                                    \
1396 } while (0)
1397
1398 #define PUT_SDB_FUNCTION_START(LINE)
1399
1400 #define PUT_SDB_FUNCTION_END(LINE)            \
1401 do {                                                  \
1402   extern FILE *asm_out_text_file;             \
1403   ASM_OUTPUT_SOURCE_LINE (asm_out_text_file, LINE + sdb_begin_function_line); \
1404 } while (0)
1405
1406 #define PUT_SDB_EPILOGUE_END(NAME)
1407
1408 #define PUT_SDB_SRC_FILE(FILENAME) \
1409 do {                                                    \
1410   extern FILE *asm_out_text_file;                       \
1411   output_file_directive (asm_out_text_file, (FILENAME)); \
1412 } while (0)
1413
1414 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
1415   sprintf ((BUFFER), ".%dfake", (NUMBER));
1416
1417 /* Correct the offset of automatic variables and arguments.  Note that
1418    the MIPS debug format wants all automatic variables and arguments
1419    to be in terms of the virtual frame pointer (stack pointer before
1420    any adjustment in the function), while the MIPS 3.0 linker wants
1421    the frame pointer to be the stack pointer after the initial
1422    adjustment.  */
1423
1424 #define DEBUGGER_AUTO_OFFSET(X)  \
1425   mips_debugger_offset (X, (HOST_WIDE_INT) 0)
1426 #define DEBUGGER_ARG_OFFSET(OFFSET, X)  \
1427   mips_debugger_offset (X, (HOST_WIDE_INT) OFFSET)
1428
1429 /* Tell collect that the object format is ECOFF */
1430 #ifndef OBJECT_FORMAT_ROSE
1431 #define OBJECT_FORMAT_COFF      /* Object file looks like COFF */
1432 #define EXTENDED_COFF           /* ECOFF, not normal coff */
1433 #endif
1434 \f
1435 /* Target machine storage layout */
1436
1437 /* Define in order to support both big and little endian float formats
1438    in the same gcc binary.  */
1439 #define REAL_ARITHMETIC
1440
1441 /* Define this if most significant bit is lowest numbered
1442    in instructions that operate on numbered bit-fields.
1443 */
1444 #define BITS_BIG_ENDIAN 0
1445
1446 /* Define this if most significant byte of a word is the lowest numbered.  */
1447 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
1448
1449 /* Define this if most significant word of a multiword number is the lowest.  */
1450 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
1451
1452 /* Define this to set the endianness to use in libgcc2.c, which can
1453    not depend on target_flags.  */
1454 #if !defined(MIPSEL) && !defined(__MIPSEL__)
1455 #define LIBGCC2_WORDS_BIG_ENDIAN 1
1456 #else
1457 #define LIBGCC2_WORDS_BIG_ENDIAN 0
1458 #endif
1459
1460 /* Number of bits in an addressable storage unit */
1461 #define BITS_PER_UNIT 8
1462
1463 /* Width in bits of a "word", which is the contents of a machine register.
1464    Note that this is not necessarily the width of data type `int';
1465    if using 16-bit ints on a 68000, this would still be 32.
1466    But on a machine with 16-bit registers, this would be 16.  */
1467 #define BITS_PER_WORD (TARGET_64BIT ? 64 : 32)
1468 #define MAX_BITS_PER_WORD 64
1469
1470 /* Width of a word, in units (bytes).  */
1471 #define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4)
1472 #define MIN_UNITS_PER_WORD 4
1473
1474 /* For MIPS, width of a floating point register.  */
1475 #define UNITS_PER_FPREG (TARGET_FLOAT64 ? 8 : 4)
1476
1477 /* A C expression for the size in bits of the type `int' on the
1478    target machine.  If you don't define this, the default is one
1479    word.  */
1480 #define INT_TYPE_SIZE (TARGET_INT64 ? 64 : 32)
1481
1482 /* Tell the preprocessor the maximum size of wchar_t.  */
1483 #ifndef MAX_WCHAR_TYPE_SIZE
1484 #ifndef WCHAR_TYPE_SIZE
1485 #define MAX_WCHAR_TYPE_SIZE 64
1486 #endif
1487 #endif
1488
1489 /* A C expression for the size in bits of the type `short' on the
1490    target machine.  If you don't define this, the default is half a
1491    word.  (If this would be less than one storage unit, it is
1492    rounded up to one unit.)  */
1493 #define SHORT_TYPE_SIZE 16
1494
1495 /* A C expression for the size in bits of the type `long' on the
1496    target machine.  If you don't define this, the default is one
1497    word.  */
1498 #define LONG_TYPE_SIZE (TARGET_LONG64 ? 64 : 32)
1499 #define MAX_LONG_TYPE_SIZE 64
1500
1501 /* A C expression for the size in bits of the type `long long' on the
1502    target machine.  If you don't define this, the default is two
1503    words.  */
1504 #define LONG_LONG_TYPE_SIZE 64
1505
1506 /* A C expression for the size in bits of the type `char' on the
1507    target machine.  If you don't define this, the default is one
1508    quarter of a word.  (If this would be less than one storage unit,
1509    it is rounded up to one unit.)  */
1510 #define CHAR_TYPE_SIZE BITS_PER_UNIT
1511
1512 /* A C expression for the size in bits of the type `float' on the
1513    target machine.  If you don't define this, the default is one
1514    word.  */
1515 #define FLOAT_TYPE_SIZE 32
1516
1517 /* A C expression for the size in bits of the type `double' on the
1518    target machine.  If you don't define this, the default is two
1519    words.  */
1520 #define DOUBLE_TYPE_SIZE 64
1521
1522 /* A C expression for the size in bits of the type `long double' on
1523    the target machine.  If you don't define this, the default is two
1524    words.  */
1525 #define LONG_DOUBLE_TYPE_SIZE 64
1526
1527 /* Width in bits of a pointer.
1528    See also the macro `Pmode' defined below.  */
1529 #ifndef POINTER_SIZE
1530 #define POINTER_SIZE (Pmode == DImode ? 64 : 32)
1531 #endif
1532
1533 /* Allocation boundary (in *bits*) for storing pointers in memory.  */
1534 #define POINTER_BOUNDARY (Pmode == DImode ? 64 : 32)
1535
1536 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
1537 #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
1538
1539 /* Allocation boundary (in *bits*) for the code of a function.  */
1540 #define FUNCTION_BOUNDARY 32
1541
1542 /* Alignment of field after `int : 0' in a structure.  */
1543 #define EMPTY_FIELD_BOUNDARY 32
1544
1545 /* Every structure's size must be a multiple of this.  */
1546 /* 8 is observed right on a DECstation and on riscos 4.02.  */
1547 #define STRUCTURE_SIZE_BOUNDARY 8
1548
1549 /* There is no point aligning anything to a rounder boundary than this.  */
1550 #define BIGGEST_ALIGNMENT 64
1551
1552 /* Set this nonzero if move instructions will actually fail to work
1553    when given unaligned data.  */
1554 #define STRICT_ALIGNMENT 1
1555
1556 /* Define this if you wish to imitate the way many other C compilers
1557    handle alignment of bitfields and the structures that contain
1558    them.
1559
1560    The behavior is that the type written for a bitfield (`int',
1561    `short', or other integer type) imposes an alignment for the
1562    entire structure, as if the structure really did contain an
1563    ordinary field of that type.  In addition, the bitfield is placed
1564    within the structure so that it would fit within such a field,
1565    not crossing a boundary for it.
1566
1567    Thus, on most machines, a bitfield whose type is written as `int'
1568    would not cross a four-byte boundary, and would force four-byte
1569    alignment for the whole structure.  (The alignment used may not
1570    be four bytes; it is controlled by the other alignment
1571    parameters.)
1572
1573    If the macro is defined, its definition should be a C expression;
1574    a nonzero value for the expression enables this behavior.  */
1575
1576 #define PCC_BITFIELD_TYPE_MATTERS 1
1577
1578 /* If defined, a C expression to compute the alignment given to a
1579    constant that is being placed in memory.  CONSTANT is the constant
1580    and ALIGN is the alignment that the object would ordinarily have.
1581    The value of this macro is used instead of that alignment to align
1582    the object.
1583
1584    If this macro is not defined, then ALIGN is used.
1585
1586    The typical use of this macro is to increase alignment for string
1587    constants to be word aligned so that `strcpy' calls that copy
1588    constants can be done inline.  */
1589
1590 #define CONSTANT_ALIGNMENT(EXP, ALIGN)                                  \
1591   ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)   \
1592    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
1593
1594 /* If defined, a C expression to compute the alignment for a static
1595    variable.  TYPE is the data type, and ALIGN is the alignment that
1596    the object would ordinarily have.  The value of this macro is used
1597    instead of that alignment to align the object.
1598
1599    If this macro is not defined, then ALIGN is used.
1600
1601    One use of this macro is to increase alignment of medium-size
1602    data to make it all fit in fewer cache lines.  Another is to
1603    cause character arrays to be word-aligned so that `strcpy' calls
1604    that copy constants to character arrays can be done inline.  */
1605
1606 #undef DATA_ALIGNMENT
1607 #define DATA_ALIGNMENT(TYPE, ALIGN)                                     \
1608   ((((ALIGN) < BITS_PER_WORD)                                           \
1609     && (TREE_CODE (TYPE) == ARRAY_TYPE                                  \
1610         || TREE_CODE (TYPE) == UNION_TYPE                               \
1611         || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
1612
1613
1614 /* Force right-alignment for small varargs in 32 bit little_endian mode */
1615
1616 #define PAD_VARARGS_DOWN (TARGET_64BIT                                  \
1617                           || mips_abi == ABI_MEABI                      \
1618                              ? BYTES_BIG_ENDIAN : !BYTES_BIG_ENDIAN)
1619
1620 /* Define this macro if an argument declared as `char' or `short' in a
1621    prototype should actually be passed as an `int'.  In addition to
1622    avoiding errors in certain cases of mismatch, it also makes for
1623    better code on certain machines.  */
1624
1625 #define PROMOTE_PROTOTYPES 1
1626
1627 /* Define if operations between registers always perform the operation
1628    on the full register even if a narrower mode is specified.  */
1629 #define WORD_REGISTER_OPERATIONS
1630
1631 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1632    will either zero-extend or sign-extend.  The value of this macro should
1633    be the code that says which one of the two operations is implicitly
1634    done, NIL if none.
1635
1636    When in 64 bit mode, mips_move_1word will sign extend SImode and CCmode
1637    moves.  All other referces are zero extended.  */
1638 #define LOAD_EXTEND_OP(MODE) \
1639   (TARGET_64BIT && ((MODE) == SImode || (MODE) == CCmode) \
1640    ? SIGN_EXTEND : ZERO_EXTEND)
1641
1642 /* Define this macro if it is advisable to hold scalars in registers
1643    in a wider mode than that declared by the program.  In such cases,
1644    the value is constrained to be within the bounds of the declared
1645    type, but kept valid in the wider mode.  The signedness of the
1646    extension may differ from that of the type.
1647
1648    We promote any value smaller than SImode up to SImode.  We don't
1649    want to promote to DImode when in 64 bit mode, because that would
1650    prevent us from using the faster SImode multiply and divide
1651    instructions.  */
1652
1653 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE)     \
1654   if (GET_MODE_CLASS (MODE) == MODE_INT         \
1655       && GET_MODE_SIZE (MODE) < 4)              \
1656     (MODE) = SImode;
1657
1658 /* Define this if function arguments should also be promoted using the above
1659    procedure.  */
1660
1661 #define PROMOTE_FUNCTION_ARGS
1662
1663 /* Likewise, if the function return value is promoted.  */
1664
1665 #define PROMOTE_FUNCTION_RETURN
1666 \f
1667 /* Standard register usage.  */
1668
1669 /* Number of actual hardware registers.
1670    The hardware registers are assigned numbers for the compiler
1671    from 0 to just below FIRST_PSEUDO_REGISTER.
1672    All registers that the compiler knows about must be given numbers,
1673    even those that are not normally considered general registers.
1674
1675    On the Mips, we have 32 integer registers, 32 floating point
1676    registers, 8 condition code registers, and the special registers
1677    hi, lo, hilo, and rap.  The 8 condition code registers are only
1678    used if mips_isa >= 4.  The hilo register is only used in 64 bit
1679    mode.  It represents a 64 bit value stored as two 32 bit values in
1680    the hi and lo registers; this is the result of the mult
1681    instruction.  rap is a pointer to the stack where the return
1682    address reg ($31) was stored.  This is needed for C++ exception
1683    handling.  */
1684
1685 #define FIRST_PSEUDO_REGISTER 76
1686
1687 /* 1 for registers that have pervasive standard uses
1688    and are not available for the register allocator.
1689
1690    On the MIPS, see conventions, page D-2  */
1691
1692 #define FIXED_REGISTERS                                                 \
1693 {                                                                       \
1694   1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       \
1695   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1,                       \
1696   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       \
1697   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       \
1698   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1                                    \
1699 }
1700
1701
1702 /* 1 for registers not available across function calls.
1703    These must include the FIXED_REGISTERS and also any
1704    registers that can be used without being saved.
1705    The latter must include the registers where values are returned
1706    and the register where structure-value addresses are passed.
1707    Aside from that, you can include as many other registers as you like.  */
1708
1709 #define CALL_USED_REGISTERS                                             \
1710 {                                                                       \
1711   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,                       \
1712   0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1,                       \
1713   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,                       \
1714   1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       \
1715   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1                                    \
1716 }
1717
1718 /* Like `CALL_USED_REGISTERS' but used to overcome a historical
1719    problem which makes CALL_USED_REGISTERS *always* include
1720    all the FIXED_REGISTERS.  Until this problem has been
1721    resolved this macro can be used to overcome this situation.
1722    In particular, block_propagate() requires this list
1723    be acurate, or we can remove registers which should be live.
1724    This macro is used in regs_invalidated_by_call.  */
1725
1726
1727 #define CALL_REALLY_USED_REGISTERS                                      \
1728 { /* General registers.  */                                             \
1729   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,                       \
1730   0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1,                       \
1731   /* Floating-point registers.  */                                      \
1732   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,                       \
1733   1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                       \
1734   /* Others.  */                                                        \
1735   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1                                    \
1736 }
1737
1738 /* Internal macros to classify a register number as to whether it's a
1739    general purpose register, a floating point register, a
1740    multiply/divide register, or a status register.  */
1741
1742 #define GP_REG_FIRST 0
1743 #define GP_REG_LAST  31
1744 #define GP_REG_NUM   (GP_REG_LAST - GP_REG_FIRST + 1)
1745 #define GP_DBX_FIRST 0
1746
1747 #define FP_REG_FIRST 32
1748 #define FP_REG_LAST  63
1749 #define FP_REG_NUM   (FP_REG_LAST - FP_REG_FIRST + 1)
1750 #define FP_DBX_FIRST ((write_symbols == DBX_DEBUG) ? 38 : 32)
1751
1752 #define MD_REG_FIRST 64
1753 #define MD_REG_LAST  66
1754 #define MD_REG_NUM   (MD_REG_LAST - MD_REG_FIRST + 1)
1755
1756 #define ST_REG_FIRST 67
1757 #define ST_REG_LAST  74
1758 #define ST_REG_NUM   (ST_REG_LAST - ST_REG_FIRST + 1)
1759
1760 #define RAP_REG_NUM   75
1761
1762 #define AT_REGNUM       (GP_REG_FIRST + 1)
1763 #define HI_REGNUM       (MD_REG_FIRST + 0)
1764 #define LO_REGNUM       (MD_REG_FIRST + 1)
1765 #define HILO_REGNUM     (MD_REG_FIRST + 2)
1766
1767 /* FPSW_REGNUM is the single condition code used if mips_isa < 4.  If
1768    mips_isa >= 4, it should not be used, and an arbitrary ST_REG
1769    should be used instead.  */
1770 #define FPSW_REGNUM     ST_REG_FIRST
1771
1772 #define GP_REG_P(REGNO) \
1773   ((unsigned int) ((int) (REGNO) - GP_REG_FIRST) < GP_REG_NUM)
1774 #define M16_REG_P(REGNO) \
1775   (((REGNO) >= 2 && (REGNO) <= 7) || (REGNO) == 16 || (REGNO) == 17)
1776 #define FP_REG_P(REGNO)  \
1777   ((unsigned int) ((int) (REGNO) - FP_REG_FIRST) < FP_REG_NUM)
1778 #define MD_REG_P(REGNO) \
1779   ((unsigned int) ((int) (REGNO) - MD_REG_FIRST) < MD_REG_NUM)
1780 #define ST_REG_P(REGNO) \
1781   ((unsigned int) ((int) (REGNO) - ST_REG_FIRST) < ST_REG_NUM)
1782
1783 /* Return number of consecutive hard regs needed starting at reg REGNO
1784    to hold something of mode MODE.
1785    This is ordinarily the length in words of a value of mode MODE
1786    but can be less for certain modes in special long registers.
1787
1788    On the MIPS, all general registers are one word long.  Except on
1789    the R4000 with the FR bit set, the floating point uses register
1790    pairs, with the second register not being allocable.  */
1791
1792 #define HARD_REGNO_NREGS(REGNO, MODE) mips_hard_regno_nregs (REGNO, MODE)
1793
1794 /* Value is 1 if hard register REGNO can hold a value of machine-mode
1795    MODE.  In 32 bit mode, require that DImode and DFmode be in even
1796    registers.  For DImode, this makes some of the insns easier to
1797    write, since you don't have to worry about a DImode value in
1798    registers 3 & 4, producing a result in 4 & 5.
1799
1800    To make the code simpler HARD_REGNO_MODE_OK now just references an
1801    array built in override_options.  Because machmodes.h is not yet
1802    included before this file is processed, the MODE bound can't be
1803    expressed here.  */
1804
1805 extern char mips_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
1806
1807 #define HARD_REGNO_MODE_OK(REGNO, MODE)                                 \
1808   mips_hard_regno_mode_ok[ (int)(MODE) ][ (REGNO) ]
1809
1810 /* Value is 1 if it is a good idea to tie two pseudo registers
1811    when one has mode MODE1 and one has mode MODE2.
1812    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
1813    for any hard reg, then this must be 0 for correct output.  */
1814 #define MODES_TIEABLE_P(MODE1, MODE2)                                   \
1815   ((GET_MODE_CLASS (MODE1) == MODE_FLOAT ||                             \
1816     GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT)                       \
1817    == (GET_MODE_CLASS (MODE2) == MODE_FLOAT ||                          \
1818        GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT))
1819
1820 /* MIPS pc is not overloaded on a register.     */
1821 /* #define PC_REGNUM xx                         */
1822
1823 /* Register to use for pushing function arguments.  */
1824 #define STACK_POINTER_REGNUM (GP_REG_FIRST + 29)
1825
1826 /* Offset from the stack pointer to the first available location.  Use
1827    the default value zero.  */
1828 /* #define STACK_POINTER_OFFSET 0 */
1829
1830 /* Base register for access to local variables of the function.  We
1831    pretend that the frame pointer is $1, and then eliminate it to
1832    HARD_FRAME_POINTER_REGNUM.  We can get away with this because $1 is
1833    a fixed register, and will not be used for anything else.  */
1834 #define FRAME_POINTER_REGNUM (GP_REG_FIRST + 1)
1835
1836 /* Temporary scratch register for use by the assembler.  */
1837 #define ASSEMBLER_SCRATCH_REGNUM (GP_REG_FIRST + 1)
1838
1839 /* $30 is not available on the mips16, so we use $17 as the frame
1840    pointer.  */
1841 #define HARD_FRAME_POINTER_REGNUM \
1842   (TARGET_MIPS16 ? GP_REG_FIRST + 17 : GP_REG_FIRST + 30)
1843
1844 /* Value should be nonzero if functions must have frame pointers.
1845    Zero means the frame pointer need not be set up (and parms
1846    may be accessed via the stack pointer) in functions that seem suitable.
1847    This is computed in `reload', in reload1.c.  */
1848 #define FRAME_POINTER_REQUIRED (current_function_calls_alloca)
1849
1850 /* Base register for access to arguments of the function.  */
1851 #define ARG_POINTER_REGNUM GP_REG_FIRST
1852
1853 /* Fake register that holds the address on the stack of the
1854    current function's return address.  */
1855 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG_NUM
1856
1857 /* Register in which static-chain is passed to a function.  */
1858 #define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 2)
1859
1860 /* If the structure value address is passed in a register, then
1861    `STRUCT_VALUE_REGNUM' should be the number of that register.  */
1862 /* #define STRUCT_VALUE_REGNUM (GP_REG_FIRST + 4) */
1863
1864 /* If the structure value address is not passed in a register, define
1865    `STRUCT_VALUE' as an expression returning an RTX for the place
1866    where the address is passed.  If it returns 0, the address is
1867    passed as an "invisible" first argument.  */
1868 #define STRUCT_VALUE 0
1869
1870 /* Mips registers used in prologue/epilogue code when the stack frame
1871    is larger than 32K bytes.  These registers must come from the
1872    scratch register set, and not used for passing and returning
1873    arguments and any other information used in the calling sequence
1874    (such as pic).  Must start at 12, since t0/t3 are parameter passing
1875    registers in the 64 bit ABI.  */
1876
1877 #define MIPS_TEMP1_REGNUM (GP_REG_FIRST + 12)
1878 #define MIPS_TEMP2_REGNUM (GP_REG_FIRST + 13)
1879
1880 /* Define this macro if it is as good or better to call a constant
1881    function address than to call an address kept in a register.  */
1882 #define NO_FUNCTION_CSE 1
1883
1884 /* Define this macro if it is as good or better for a function to
1885    call itself with an explicit address than to call an address
1886    kept in a register.  */
1887 #define NO_RECURSIVE_FUNCTION_CSE 1
1888
1889 /* The register number of the register used to address a table of
1890    static data addresses in memory.  In some cases this register is
1891    defined by a processor's "application binary interface" (ABI).
1892    When this macro is defined, RTL is generated for this register
1893    once, as with the stack pointer and frame pointer registers.  If
1894    this macro is not defined, it is up to the machine-dependent
1895    files to allocate such a register (if necessary).  */
1896 #define PIC_OFFSET_TABLE_REGNUM (GP_REG_FIRST + 28)
1897
1898 #define PIC_FUNCTION_ADDR_REGNUM (GP_REG_FIRST + 25)
1899
1900 /* Initialize embedded_pic_fnaddr_rtx before RTL generation for
1901    each function.  We used to do this in FINALIZE_PIC, but FINALIZE_PIC
1902    isn't always called for static inline functions.  */
1903 #define INIT_EXPANDERS                  \
1904 do {                                    \
1905   embedded_pic_fnaddr_rtx = NULL;       \
1906   mips16_gp_pseudo_rtx = NULL;          \
1907 } while (0)
1908 \f
1909 /* Define the classes of registers for register constraints in the
1910    machine description.  Also define ranges of constants.
1911
1912    One of the classes must always be named ALL_REGS and include all hard regs.
1913    If there is more than one class, another class must be named NO_REGS
1914    and contain no registers.
1915
1916    The name GENERAL_REGS must be the name of a class (or an alias for
1917    another name such as ALL_REGS).  This is the class of registers
1918    that is allowed by "g" or "r" in a register constraint.
1919    Also, registers outside this class are allocated only when
1920    instructions express preferences for them.
1921
1922    The classes must be numbered in nondecreasing order; that is,
1923    a larger-numbered class must never be contained completely
1924    in a smaller-numbered class.
1925
1926    For any two classes, it is very desirable that there be another
1927    class that represents their union.  */
1928
1929 enum reg_class
1930 {
1931   NO_REGS,                      /* no registers in set */
1932   M16_NA_REGS,                  /* mips16 regs not used to pass args */
1933   M16_REGS,                     /* mips16 directly accessible registers */
1934   T_REG,                        /* mips16 T register ($24) */
1935   M16_T_REGS,                   /* mips16 registers plus T register */
1936   GR_REGS,                      /* integer registers */
1937   FP_REGS,                      /* floating point registers */
1938   HI_REG,                       /* hi register */
1939   LO_REG,                       /* lo register */
1940   HILO_REG,                     /* hilo register pair for 64 bit mode mult */
1941   MD_REGS,                      /* multiply/divide registers (hi/lo) */
1942   HI_AND_GR_REGS,               /* union classes */
1943   LO_AND_GR_REGS,
1944   HILO_AND_GR_REGS,
1945   HI_AND_FP_REGS,
1946   ST_REGS,                      /* status registers (fp status) */
1947   ALL_REGS,                     /* all registers */
1948   LIM_REG_CLASSES               /* max value + 1 */
1949 };
1950
1951 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1952
1953 #define GENERAL_REGS GR_REGS
1954
1955 /* An initializer containing the names of the register classes as C
1956    string constants.  These names are used in writing some of the
1957    debugging dumps.  */
1958
1959 #define REG_CLASS_NAMES                                                 \
1960 {                                                                       \
1961   "NO_REGS",                                                            \
1962   "M16_NA_REGS",                                                        \
1963   "M16_REGS",                                                           \
1964   "T_REG",                                                              \
1965   "M16_T_REGS",                                                         \
1966   "GR_REGS",                                                            \
1967   "FP_REGS",                                                            \
1968   "HI_REG",                                                             \
1969   "LO_REG",                                                             \
1970   "HILO_REG",                                                           \
1971   "MD_REGS",                                                            \
1972   "HI_AND_GR_REGS",                                                     \
1973   "LO_AND_GR_REGS",                                                     \
1974   "HILO_AND_GR_REGS",                                                   \
1975   "HI_AND_FP_REGS",                                                     \
1976   "ST_REGS",                                                            \
1977   "ALL_REGS"                                                            \
1978 }
1979
1980 /* An initializer containing the contents of the register classes,
1981    as integers which are bit masks.  The Nth integer specifies the
1982    contents of class N.  The way the integer MASK is interpreted is
1983    that register R is in the class if `MASK & (1 << R)' is 1.
1984
1985    When the machine has more than 32 registers, an integer does not
1986    suffice.  Then the integers are replaced by sub-initializers,
1987    braced groupings containing several integers.  Each
1988    sub-initializer must be suitable as an initializer for the type
1989    `HARD_REG_SET' which is defined in `hard-reg-set.h'.  */
1990
1991 #define REG_CLASS_CONTENTS                                              \
1992 {                                                                       \
1993   { 0x00000000, 0x00000000, 0x00000000 },       /* no registers */      \
1994   { 0x0003000c, 0x00000000, 0x00000000 },       /* mips16 nonarg regs */\
1995   { 0x000300fc, 0x00000000, 0x00000000 },       /* mips16 registers */  \
1996   { 0x01000000, 0x00000000, 0x00000000 },       /* mips16 T register */ \
1997   { 0x010300fc, 0x00000000, 0x00000000 },       /* mips16 and T regs */ \
1998   { 0xffffffff, 0x00000000, 0x00000000 },       /* integer registers */ \
1999   { 0x00000000, 0xffffffff, 0x00000000 },       /* floating registers*/ \
2000   { 0x00000000, 0x00000000, 0x00000001 },       /* hi register */       \
2001   { 0x00000000, 0x00000000, 0x00000002 },       /* lo register */       \
2002   { 0x00000000, 0x00000000, 0x00000004 },       /* hilo register */     \
2003   { 0x00000000, 0x00000000, 0x00000003 },       /* mul/div registers */ \
2004   { 0xffffffff, 0x00000000, 0x00000001 },       /* union classes */     \
2005   { 0xffffffff, 0x00000000, 0x00000002 },                               \
2006   { 0xffffffff, 0x00000000, 0x00000004 },                               \
2007   { 0x00000000, 0xffffffff, 0x00000001 },                               \
2008   { 0x00000000, 0x00000000, 0x000007f8 },       /* status registers */  \
2009   { 0xffffffff, 0xffffffff, 0x000007ff }        /* all registers */     \
2010 }
2011
2012
2013 /* A C expression whose value is a register class containing hard
2014    register REGNO.  In general there is more that one such class;
2015    choose a class which is "minimal", meaning that no smaller class
2016    also contains the register.  */
2017
2018 extern const enum reg_class mips_regno_to_class[];
2019
2020 #define REGNO_REG_CLASS(REGNO) mips_regno_to_class[ (REGNO) ]
2021
2022 /* A macro whose definition is the name of the class to which a
2023    valid base register must belong.  A base register is one used in
2024    an address which is the register value plus a displacement.  */
2025
2026 #define BASE_REG_CLASS  (TARGET_MIPS16 ? M16_REGS : GR_REGS)
2027
2028 /* A macro whose definition is the name of the class to which a
2029    valid index register must belong.  An index register is one used
2030    in an address where its value is either multiplied by a scale
2031    factor or added to another register (as well as added to a
2032    displacement).  */
2033
2034 #define INDEX_REG_CLASS NO_REGS
2035
2036 /* When SMALL_REGISTER_CLASSES is nonzero, the compiler allows
2037    registers explicitly used in the rtl to be used as spill registers
2038    but prevents the compiler from extending the lifetime of these
2039    registers.  */
2040
2041 #define SMALL_REGISTER_CLASSES (TARGET_MIPS16)
2042
2043 /* This macro is used later on in the file.  */
2044 #define GR_REG_CLASS_P(CLASS)                                           \
2045   ((CLASS) == GR_REGS || (CLASS) == M16_REGS || (CLASS) == T_REG        \
2046    || (CLASS) == M16_T_REGS || (CLASS) == M16_NA_REGS)
2047
2048 /* REG_ALLOC_ORDER is to order in which to allocate registers.  This
2049    is the default value (allocate the registers in numeric order).  We
2050    define it just so that we can override it for the mips16 target in
2051    ORDER_REGS_FOR_LOCAL_ALLOC.  */
2052
2053 #define REG_ALLOC_ORDER                                                 \
2054 {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,       \
2055   16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,       \
2056   32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,       \
2057   48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,       \
2058   64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75                        \
2059 }
2060
2061 /* ORDER_REGS_FOR_LOCAL_ALLOC is a macro which permits reg_alloc_order
2062    to be rearranged based on a particular function.  On the mips16, we
2063    want to allocate $24 (T_REG) before other registers for
2064    instructions for which it is possible.  */
2065
2066 #define ORDER_REGS_FOR_LOCAL_ALLOC mips_order_regs_for_local_alloc ()
2067
2068 /* REGISTER AND CONSTANT CLASSES */
2069
2070 /* Get reg_class from a letter such as appears in the machine
2071    description.
2072
2073    DEFINED REGISTER CLASSES:
2074
2075    'd'  General (aka integer) registers
2076         Normally this is GR_REGS, but in mips16 mode this is M16_REGS
2077    'y'  General registers (in both mips16 and non mips16 mode)
2078    'e'  mips16 non argument registers (M16_NA_REGS)
2079    't'  mips16 temporary register ($24)
2080    'f'  Floating point registers
2081    'h'  Hi register
2082    'l'  Lo register
2083    'x'  Multiply/divide registers
2084    'a'  HILO_REG
2085    'z'  FP Status register
2086    'b'  All registers */
2087
2088 extern enum reg_class mips_char_to_class[256];
2089
2090 #define REG_CLASS_FROM_LETTER(C) mips_char_to_class[(unsigned char)(C)]
2091
2092 /* The letters I, J, K, L, M, N, O, and P in a register constraint
2093    string can be used to stand for particular ranges of immediate
2094    operands.  This macro defines what the ranges are.  C is the
2095    letter, and VALUE is a constant value.  Return 1 if VALUE is
2096    in the range specified by C.  */
2097
2098 /* For MIPS:
2099
2100    `I'  is used for the range of constants an arithmetic insn can
2101         actually contain (16 bits signed integers).
2102
2103    `J'  is used for the range which is just zero (ie, $r0).
2104
2105    `K'  is used for the range of constants a logical insn can actually
2106         contain (16 bit zero-extended integers).
2107
2108    `L'  is used for the range of constants that be loaded with lui
2109         (ie, the bottom 16 bits are zero).
2110
2111    `M'  is used for the range of constants that take two words to load
2112         (ie, not matched by `I', `K', and `L').
2113
2114    `N'  is used for negative 16 bit constants other than -65536.
2115
2116    `O'  is a 15 bit signed integer.
2117
2118    `P'  is used for positive 16 bit constants.  */
2119
2120 #define SMALL_INT(X) ((unsigned HOST_WIDE_INT) (INTVAL (X) + 0x8000) < 0x10000)
2121 #define SMALL_INT_UNSIGNED(X) ((unsigned HOST_WIDE_INT) (INTVAL (X)) < 0x10000)
2122
2123 #define CONST_OK_FOR_LETTER_P(VALUE, C)                                 \
2124   ((C) == 'I' ? ((unsigned HOST_WIDE_INT) ((VALUE) + 0x8000) < 0x10000) \
2125    : (C) == 'J' ? ((VALUE) == 0)                                        \
2126    : (C) == 'K' ? ((unsigned HOST_WIDE_INT) (VALUE) < 0x10000)          \
2127    : (C) == 'L' ? (((VALUE) & 0x0000ffff) == 0                          \
2128                    && (((VALUE) & ~2147483647) == 0                     \
2129                        || ((VALUE) & ~2147483647) == ~2147483647))      \
2130    : (C) == 'M' ? ((((VALUE) & ~0x0000ffff) != 0)                       \
2131                    && (((VALUE) & ~0x0000ffff) != ~0x0000ffff)          \
2132                    && (((VALUE) & 0x0000ffff) != 0                      \
2133                        || (((VALUE) & ~2147483647) != 0                 \
2134                            && ((VALUE) & ~2147483647) != ~2147483647))) \
2135    : (C) == 'N' ? ((unsigned HOST_WIDE_INT) ((VALUE) + 0xffff) < 0xffff) \
2136    : (C) == 'O' ? ((unsigned HOST_WIDE_INT) ((VALUE) + 0x4000) < 0x8000) \
2137    : (C) == 'P' ? ((VALUE) != 0 && (((VALUE) & ~0x0000ffff) == 0))      \
2138    : 0)
2139
2140 /* Similar, but for floating constants, and defining letters G and H.
2141    Here VALUE is the CONST_DOUBLE rtx itself.  */
2142
2143 /* For Mips
2144
2145   'G'   : Floating point 0 */
2146
2147 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)                          \
2148   ((C) == 'G'                                                           \
2149    && (VALUE) == CONST0_RTX (GET_MODE (VALUE)))
2150
2151 /* Letters in the range `Q' through `U' may be defined in a
2152    machine-dependent fashion to stand for arbitrary operand types.
2153    The machine description macro `EXTRA_CONSTRAINT' is passed the
2154    operand as its first argument and the constraint letter as its
2155    second operand.
2156
2157    `Q'  is for mips16 GP relative constants
2158    `R'  is for memory references which take 1 word for the instruction.
2159    `S'  is for references to extern items which are PIC for OSF/rose.
2160    `T'  is for memory addresses that can be used to load two words.  */
2161
2162 #define EXTRA_CONSTRAINT(OP,CODE)                                       \
2163   (((CODE) == 'T')        ? double_memory_operand (OP, GET_MODE (OP))   \
2164    : ((CODE) == 'Q')      ? (GET_CODE (OP) == CONST                     \
2165                              && mips16_gp_offset_p (OP))                \
2166    : (GET_CODE (OP) != MEM) ? FALSE                                     \
2167    : ((CODE) == 'R')      ? simple_memory_operand (OP, GET_MODE (OP))   \
2168    : ((CODE) == 'S')      ? (HALF_PIC_P () && CONSTANT_P (OP)           \
2169                              && HALF_PIC_ADDRESS_P (OP))                \
2170    : FALSE)
2171
2172 /* Given an rtx X being reloaded into a reg required to be
2173    in class CLASS, return the class of reg to actually use.
2174    In general this is just CLASS; but on some machines
2175    in some cases it is preferable to use a more restrictive class.  */
2176
2177 #define PREFERRED_RELOAD_CLASS(X,CLASS)                                 \
2178   ((CLASS) != ALL_REGS                                                  \
2179    ? (! TARGET_MIPS16                                                   \
2180       ? (CLASS)                                                         \
2181       : ((CLASS) != GR_REGS                                             \
2182          ? (CLASS)                                                      \
2183          : M16_REGS))                                                   \
2184    : ((GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT                      \
2185        || GET_MODE_CLASS (GET_MODE (X)) == MODE_COMPLEX_FLOAT)          \
2186       ? (TARGET_SOFT_FLOAT                                              \
2187          ? (TARGET_MIPS16 ? M16_REGS : GR_REGS)                         \
2188          : FP_REGS)                                                     \
2189       : ((GET_MODE_CLASS (GET_MODE (X)) == MODE_INT                     \
2190           || GET_MODE (X) == VOIDmode)                                  \
2191          ? (TARGET_MIPS16 ? M16_REGS : GR_REGS)                         \
2192          : (CLASS))))
2193
2194 /* Certain machines have the property that some registers cannot be
2195    copied to some other registers without using memory.  Define this
2196    macro on those machines to be a C expression that is non-zero if
2197    objects of mode MODE in registers of CLASS1 can only be copied to
2198    registers of class CLASS2 by storing a register of CLASS1 into
2199    memory and loading that memory location into a register of CLASS2.
2200
2201    Do not define this macro if its value would always be zero.  */
2202
2203 #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE)                   \
2204   ((!TARGET_DEBUG_H_MODE                                                \
2205     && GET_MODE_CLASS (MODE) == MODE_INT                                \
2206     && ((CLASS1 == FP_REGS && GR_REG_CLASS_P (CLASS2))                  \
2207         || (GR_REG_CLASS_P (CLASS1) && CLASS2 == FP_REGS)))             \
2208    || (TARGET_FLOAT64 && !TARGET_64BIT && (MODE) == DFmode              \
2209        && ((GR_REG_CLASS_P (CLASS1) && CLASS2 == FP_REGS)               \
2210            || (GR_REG_CLASS_P (CLASS2) && CLASS1 == FP_REGS))))
2211
2212 /* The HI and LO registers can only be reloaded via the general
2213    registers.  Condition code registers can only be loaded to the
2214    general registers, and from the floating point registers.  */
2215
2216 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X)                    \
2217   mips_secondary_reload_class (CLASS, MODE, X, 1)
2218 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X)                   \
2219   mips_secondary_reload_class (CLASS, MODE, X, 0)
2220
2221 /* Return the maximum number of consecutive registers
2222    needed to represent mode MODE in a register of class CLASS.  */
2223
2224 #define CLASS_UNITS(mode, size)                                         \
2225   ((GET_MODE_SIZE (mode) + (size) - 1) / (size))
2226
2227 #define CLASS_MAX_NREGS(CLASS, MODE)                                    \
2228   ((CLASS) == FP_REGS                                                   \
2229    ? (TARGET_FLOAT64                                                    \
2230       ? CLASS_UNITS (MODE, 8)                                           \
2231       : 2 * CLASS_UNITS (MODE, 8))                                      \
2232    : CLASS_UNITS (MODE, UNITS_PER_WORD))
2233
2234 /* If defined, gives a class of registers that cannot be used as the
2235    operand of a SUBREG that changes the mode of the object illegally.
2236
2237    When FP regs are larger than integer regs... Er, anyone remember what
2238    goes wrong?
2239
2240    In little-endian mode, the hi-lo registers are numbered backwards,
2241    so (subreg:SI (reg:DI hi) 0) gets the high word instead of the low
2242    word as intended.  */
2243
2244 #define CLASS_CANNOT_CHANGE_MODE                                        \
2245   (TARGET_BIG_ENDIAN                                                    \
2246    ? (TARGET_FLOAT64 && ! TARGET_64BIT ? FP_REGS : NO_REGS)             \
2247    : (TARGET_FLOAT64 && ! TARGET_64BIT ? HI_AND_FP_REGS : HI_REG))
2248
2249 /* Defines illegal mode changes for CLASS_CANNOT_CHANGE_MODE.  */
2250
2251 #define CLASS_CANNOT_CHANGE_MODE_P(FROM,TO) \
2252   (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO))
2253 \f
2254 /* Stack layout; function entry, exit and calling.  */
2255
2256 /* Define this if pushing a word on the stack
2257    makes the stack pointer a smaller address.  */
2258 #define STACK_GROWS_DOWNWARD
2259
2260 /* Define this if the nominal address of the stack frame
2261    is at the high-address end of the local variables;
2262    that is, each additional local variable allocated
2263    goes at a more negative offset in the frame.  */
2264 /* #define FRAME_GROWS_DOWNWARD */
2265
2266 /* Offset within stack frame to start allocating local variables at.
2267    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
2268    first local allocated.  Otherwise, it is the offset to the BEGINNING
2269    of the first local allocated.  */
2270 #define STARTING_FRAME_OFFSET                                           \
2271   (current_function_outgoing_args_size                                  \
2272    + (TARGET_ABICALLS ? MIPS_STACK_ALIGN (UNITS_PER_WORD) : 0))
2273
2274 /* Offset from the stack pointer register to an item dynamically
2275    allocated on the stack, e.g., by `alloca'.
2276
2277    The default value for this macro is `STACK_POINTER_OFFSET' plus the
2278    length of the outgoing arguments.  The default is correct for most
2279    machines.  See `function.c' for details.
2280
2281    The MIPS ABI states that functions which dynamically allocate the
2282    stack must not have 0 for STACK_DYNAMIC_OFFSET, since it looks like
2283    we are trying to create a second frame pointer to the function, so
2284    allocate some stack space to make it happy.
2285
2286    However, the linker currently complains about linking any code that
2287    dynamically allocates stack space, and there seems to be a bug in
2288    STACK_DYNAMIC_OFFSET, so don't define this right now.  */
2289
2290 #if 0
2291 #define STACK_DYNAMIC_OFFSET(FUNDECL)                                   \
2292   ((current_function_outgoing_args_size == 0 && current_function_calls_alloca) \
2293         ? 4*UNITS_PER_WORD                                              \
2294         : current_function_outgoing_args_size)
2295 #endif
2296
2297 /* The return address for the current frame is in r31 is this is a leaf
2298    function.  Otherwise, it is on the stack.  It is at a variable offset
2299    from sp/fp/ap, so we define a fake hard register rap which is a
2300    poiner to the return address on the stack.  This always gets eliminated
2301    during reload to be either the frame pointer or the stack pointer plus
2302    an offset.  */
2303
2304 /* ??? This definition fails for leaf functions.  There is currently no
2305    general solution for this problem.  */
2306
2307 /* ??? There appears to be no way to get the return address of any previous
2308    frame except by disassembling instructions in the prologue/epilogue.
2309    So currently we support only the current frame.  */
2310
2311 #define RETURN_ADDR_RTX(count, frame)                   \
2312   ((count == 0)                                         \
2313    ? gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM))\
2314    : (rtx) 0)
2315
2316 /* Structure to be filled in by compute_frame_size with register
2317    save masks, and offsets for the current function.  */
2318
2319 struct mips_frame_info
2320 {
2321   long total_size;              /* # bytes that the entire frame takes up */
2322   long var_size;                /* # bytes that variables take up */
2323   long args_size;               /* # bytes that outgoing arguments take up */
2324   long extra_size;              /* # bytes of extra gunk */
2325   int  gp_reg_size;             /* # bytes needed to store gp regs */
2326   int  fp_reg_size;             /* # bytes needed to store fp regs */
2327   long mask;                    /* mask of saved gp registers */
2328   long fmask;                   /* mask of saved fp registers */
2329   long gp_save_offset;          /* offset from vfp to store gp registers */
2330   long fp_save_offset;          /* offset from vfp to store fp registers */
2331   long gp_sp_offset;            /* offset from new sp to store gp registers */
2332   long fp_sp_offset;            /* offset from new sp to store fp registers */
2333   int  initialized;             /* != 0 if frame size already calculated */
2334   int  num_gp;                  /* number of gp registers saved */
2335   int  num_fp;                  /* number of fp registers saved */
2336   long insns_len;               /* length of insns; mips16 only */
2337 };
2338
2339 extern struct mips_frame_info current_frame_info;
2340
2341 /* If defined, this macro specifies a table of register pairs used to
2342    eliminate unneeded registers that point into the stack frame.  If
2343    it is not defined, the only elimination attempted by the compiler
2344    is to replace references to the frame pointer with references to
2345    the stack pointer.
2346
2347    The definition of this macro is a list of structure
2348    initializations, each of which specifies an original and
2349    replacement register.
2350
2351    On some machines, the position of the argument pointer is not
2352    known until the compilation is completed.  In such a case, a
2353    separate hard register must be used for the argument pointer.
2354    This register can be eliminated by replacing it with either the
2355    frame pointer or the argument pointer, depending on whether or not
2356    the frame pointer has been eliminated.
2357
2358    In this case, you might specify:
2359         #define ELIMINABLE_REGS  \
2360         {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
2361          {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
2362          {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
2363
2364    Note that the elimination of the argument pointer with the stack
2365    pointer is specified first since that is the preferred elimination.
2366
2367    The eliminations to $17 are only used on the mips16.  See the
2368    definition of HARD_FRAME_POINTER_REGNUM.  */
2369
2370 #define ELIMINABLE_REGS                                                 \
2371 {{ ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM},                         \
2372  { ARG_POINTER_REGNUM,   GP_REG_FIRST + 30},                            \
2373  { ARG_POINTER_REGNUM,   GP_REG_FIRST + 17},                            \
2374  { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM},                \
2375  { RETURN_ADDRESS_POINTER_REGNUM, GP_REG_FIRST + 30},                   \
2376  { RETURN_ADDRESS_POINTER_REGNUM, GP_REG_FIRST + 17},                   \
2377  { RETURN_ADDRESS_POINTER_REGNUM, GP_REG_FIRST + 31},                   \
2378  { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},                         \
2379  { FRAME_POINTER_REGNUM, GP_REG_FIRST + 30},                            \
2380  { FRAME_POINTER_REGNUM, GP_REG_FIRST + 17}}
2381
2382 /* A C expression that returns non-zero if the compiler is allowed to
2383    try to replace register number FROM-REG with register number
2384    TO-REG.  This macro need only be defined if `ELIMINABLE_REGS' is
2385    defined, and will usually be the constant 1, since most of the
2386    cases preventing register elimination are things that the compiler
2387    already knows about.
2388
2389    When not in mips16 and mips64, we can always eliminate to the
2390    frame pointer.  We can eliminate to the stack pointer unless
2391    a frame pointer is needed.  In mips16 mode, we need a frame
2392    pointer for a large frame; otherwise, reload may be unable
2393    to compute the address of a local variable, since there is
2394    no way to add a large constant to the stack pointer
2395    without using a temporary register.
2396
2397    In mips16, for some instructions (eg lwu), we can't eliminate the
2398    frame pointer for the stack pointer.  These instructions are
2399    only generated in TARGET_64BIT mode.
2400    */
2401
2402 #define CAN_ELIMINATE(FROM, TO)                                         \
2403   (((FROM) == RETURN_ADDRESS_POINTER_REGNUM && (! leaf_function_p ()    \
2404    || (TO == GP_REG_FIRST + 31 && leaf_function_p)))                    \
2405   || ((FROM) != RETURN_ADDRESS_POINTER_REGNUM                           \
2406    && ((TO) == HARD_FRAME_POINTER_REGNUM                                \
2407    || ((TO) == STACK_POINTER_REGNUM && ! frame_pointer_needed           \
2408        && ! (TARGET_MIPS16 && TARGET_64BIT)                             \
2409        && (! TARGET_MIPS16                                              \
2410            || compute_frame_size (get_frame_size ()) < 32768)))))
2411
2412 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It
2413    specifies the initial difference between the specified pair of
2414    registers.  This macro must be defined if `ELIMINABLE_REGS' is
2415    defined.  */
2416
2417 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                     \
2418 {  compute_frame_size (get_frame_size ());                               \
2419   if (TARGET_MIPS16 && (FROM) == FRAME_POINTER_REGNUM                    \
2420       && (TO) == HARD_FRAME_POINTER_REGNUM)                              \
2421     (OFFSET) = - current_function_outgoing_args_size;                    \
2422   else if ((FROM) == FRAME_POINTER_REGNUM)                               \
2423     (OFFSET) = 0;                                                        \
2424   else if (TARGET_MIPS16 && (FROM) == ARG_POINTER_REGNUM                 \
2425            && (TO) == HARD_FRAME_POINTER_REGNUM)                         \
2426     (OFFSET) = (current_frame_info.total_size                            \
2427                 - current_function_outgoing_args_size                    \
2428                 - ((mips_abi != ABI_32                                   \
2429                     && mips_abi != ABI_O64                               \
2430                     && mips_abi != ABI_EABI)                             \
2431                    ? current_function_pretend_args_size                  \
2432                    : 0));                                                \
2433   else if ((FROM) == ARG_POINTER_REGNUM)                                 \
2434     (OFFSET) = (current_frame_info.total_size                            \
2435                 - ((mips_abi != ABI_32                                   \
2436                     && mips_abi != ABI_O64                               \
2437                     && mips_abi != ABI_EABI)                             \
2438                    ? current_function_pretend_args_size                  \
2439                    : 0));                                                \
2440   /* Some ABIs store 64 bits to the stack, but Pmode is 32 bits,         \
2441      so we must add 4 bytes to the offset to get the right value.  */    \
2442   else if ((FROM) == RETURN_ADDRESS_POINTER_REGNUM)                      \
2443   {                                                                      \
2444    if (leaf_function_p ())                                               \
2445       (OFFSET) = 0;                                                      \
2446    else (OFFSET) = current_frame_info.gp_sp_offset                       \
2447                + ((UNITS_PER_WORD - (POINTER_SIZE / BITS_PER_UNIT))      \
2448                   * (BYTES_BIG_ENDIAN != 0));                            \
2449   }                                                                      \
2450   else                                                                   \
2451     abort();                                                             \
2452 }
2453
2454 /* If we generate an insn to push BYTES bytes,
2455    this says how many the stack pointer really advances by.
2456    On the VAX, sp@- in a byte insn really pushes a word.  */
2457
2458 /* #define PUSH_ROUNDING(BYTES) 0 */
2459
2460 /* If defined, the maximum amount of space required for outgoing
2461    arguments will be computed and placed into the variable
2462    `current_function_outgoing_args_size'.  No space will be pushed
2463    onto the stack for each call; instead, the function prologue
2464    should increase the stack frame size by this amount.
2465
2466    It is not proper to define both `PUSH_ROUNDING' and
2467    `ACCUMULATE_OUTGOING_ARGS'.  */
2468 #define ACCUMULATE_OUTGOING_ARGS 1
2469
2470 /* Offset from the argument pointer register to the first argument's
2471    address.  On some machines it may depend on the data type of the
2472    function.
2473
2474    If `ARGS_GROW_DOWNWARD', this is the offset to the location above
2475    the first argument's address.
2476
2477    On the MIPS, we must skip the first argument position if we are
2478    returning a structure or a union, to account for its address being
2479    passed in $4.  However, at the current time, this produces a compiler
2480    that can't bootstrap, so comment it out for now.  */
2481
2482 #if 0
2483 #define FIRST_PARM_OFFSET(FNDECL)                                       \
2484   (FNDECL != 0                                                          \
2485    && TREE_TYPE (FNDECL) != 0                                           \
2486    && TREE_TYPE (TREE_TYPE (FNDECL)) != 0                               \
2487    && (TREE_CODE (TREE_TYPE (TREE_TYPE (FNDECL))) == RECORD_TYPE        \
2488        || TREE_CODE (TREE_TYPE (TREE_TYPE (FNDECL))) == UNION_TYPE)     \
2489                 ? UNITS_PER_WORD                                        \
2490                 : 0)
2491 #else
2492 #define FIRST_PARM_OFFSET(FNDECL) 0
2493 #endif
2494
2495 /* When a parameter is passed in a register, stack space is still
2496    allocated for it.  For the MIPS, stack space must be allocated, cf
2497    Asm Lang Prog Guide page 7-8.
2498
2499    BEWARE that some space is also allocated for non existing arguments
2500    in register. In case an argument list is of form GF used registers
2501    are a0 (a2,a3), but we should push over a1...  */
2502
2503 #define REG_PARM_STACK_SPACE(FNDECL)    \
2504   ((MAX_ARGS_IN_REGISTERS*UNITS_PER_WORD) - FIRST_PARM_OFFSET (FNDECL))
2505
2506 /* Define this if it is the responsibility of the caller to
2507    allocate the area reserved for arguments passed in registers.
2508    If `ACCUMULATE_OUTGOING_ARGS' is also defined, the only effect
2509    of this macro is to determine whether the space is included in
2510    `current_function_outgoing_args_size'.  */
2511 #define OUTGOING_REG_PARM_STACK_SPACE
2512
2513 /* Align stack frames on 64 bits (Double Word ).  */
2514 #ifndef STACK_BOUNDARY
2515 #define STACK_BOUNDARY 64
2516 #endif
2517
2518 /* Make sure 4 words are always allocated on the stack.  */
2519
2520 #ifndef STACK_ARGS_ADJUST
2521 #define STACK_ARGS_ADJUST(SIZE)                                         \
2522 {                                                                       \
2523   if (SIZE.constant < 4 * UNITS_PER_WORD)                               \
2524     SIZE.constant = 4 * UNITS_PER_WORD;                                 \
2525 }
2526 #endif
2527
2528 \f
2529 /* A C expression that should indicate the number of bytes of its
2530    own arguments that a function pops on returning, or 0
2531    if the function pops no arguments and the caller must therefore
2532    pop them all after the function returns.
2533
2534    FUNDECL is the declaration node of the function (as a tree).
2535
2536    FUNTYPE is a C variable whose value is a tree node that
2537    describes the function in question.  Normally it is a node of
2538    type `FUNCTION_TYPE' that describes the data type of the function.
2539    From this it is possible to obtain the data types of the value
2540    and arguments (if known).
2541
2542    When a call to a library function is being considered, FUNTYPE
2543    will contain an identifier node for the library function.  Thus,
2544    if you need to distinguish among various library functions, you
2545    can do so by their names.  Note that "library function" in this
2546    context means a function used to perform arithmetic, whose name
2547    is known specially in the compiler and was not mentioned in the
2548    C code being compiled.
2549
2550    STACK-SIZE is the number of bytes of arguments passed on the
2551    stack.  If a variable number of bytes is passed, it is zero, and
2552    argument popping will always be the responsibility of the
2553    calling function.  */
2554
2555 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
2556
2557
2558 /* Symbolic macros for the registers used to return integer and floating
2559    point values.  */
2560
2561 #define GP_RETURN (GP_REG_FIRST + 2)
2562 #define FP_RETURN ((TARGET_SOFT_FLOAT) ? GP_RETURN : (FP_REG_FIRST + 0))
2563
2564 /* Symbolic macros for the first/last argument registers.  */
2565
2566 #define GP_ARG_FIRST (GP_REG_FIRST + 4)
2567 #define GP_ARG_LAST  (GP_REG_FIRST + 7)
2568 #define FP_ARG_FIRST (FP_REG_FIRST + 12)
2569 #define FP_ARG_LAST  (FP_REG_FIRST + 15)
2570
2571 #define MAX_ARGS_IN_REGISTERS   4
2572
2573 /* Define how to find the value returned by a library function
2574    assuming the value has mode MODE.  Because we define
2575    PROMOTE_FUNCTION_RETURN, we must promote the mode just as
2576    PROMOTE_MODE does.  */
2577
2578 #define LIBCALL_VALUE(MODE)                                             \
2579   gen_rtx (REG,                                                         \
2580            ((GET_MODE_CLASS (MODE) != MODE_INT                          \
2581              || GET_MODE_SIZE (MODE) >= 4)                              \
2582             ? (MODE)                                                    \
2583             : SImode),                                                  \
2584            ((GET_MODE_CLASS (MODE) == MODE_FLOAT                        \
2585              && (! TARGET_SINGLE_FLOAT                                  \
2586                  || GET_MODE_SIZE (MODE) <= 4))                         \
2587             ? FP_RETURN                                                 \
2588             : GP_RETURN))
2589
2590 /* Define how to find the value returned by a function.
2591    VALTYPE is the data type of the value (as a tree).
2592    If the precise function being called is known, FUNC is its FUNCTION_DECL;
2593    otherwise, FUNC is 0.  */
2594
2595 #define FUNCTION_VALUE(VALTYPE, FUNC) LIBCALL_VALUE (TYPE_MODE (VALTYPE))
2596
2597
2598 /* 1 if N is a possible register number for a function value.
2599    On the MIPS, R2 R3 and F0 F2 are the only register thus used.
2600    Currently, R2 and F0 are only implemented  here (C has no complex type)  */
2601
2602 #define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN)
2603
2604 /* 1 if N is a possible register number for function argument passing.
2605    We have no FP argument registers when soft-float.  When FP registers
2606    are 32 bits, we can't directly reference the odd numbered ones.  */
2607
2608 #define FUNCTION_ARG_REGNO_P(N)                                 \
2609   (((N) >= GP_ARG_FIRST && (N) <= GP_ARG_LAST)                  \
2610    || ((! TARGET_SOFT_FLOAT                                     \
2611        && ((N) >= FP_ARG_FIRST && (N) <= FP_ARG_LAST)           \
2612        && (TARGET_FLOAT64 || (0 == (N) % 2)))                   \
2613        && ! fixed_regs[N]))
2614
2615 /* A C expression which can inhibit the returning of certain function
2616    values in registers, based on the type of value.  A nonzero value says
2617    to return the function value in memory, just as large structures are
2618    always returned.  Here TYPE will be a C expression of type
2619    `tree', representing the data type of the value.
2620
2621    Note that values of mode `BLKmode' must be explicitly
2622    handled by this macro.  Also, the option `-fpcc-struct-return'
2623    takes effect regardless of this macro.  On most systems, it is
2624    possible to leave the macro undefined; this causes a default
2625    definition to be used, whose value is the constant 1 for BLKmode
2626    values, and 0 otherwise.
2627
2628    GCC normally converts 1 byte structures into chars, 2 byte
2629    structs into shorts, and 4 byte structs into ints, and returns
2630    them this way.  Defining the following macro overrides this,
2631    to give us MIPS cc compatibility.  */
2632
2633 #define RETURN_IN_MEMORY(TYPE)  \
2634   (TYPE_MODE (TYPE) == BLKmode)
2635 \f
2636 /* A code distinguishing the floating point format of the target
2637    machine.  There are three defined values: IEEE_FLOAT_FORMAT,
2638    VAX_FLOAT_FORMAT, and UNKNOWN_FLOAT_FORMAT.  */
2639
2640 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
2641
2642 \f
2643 /* Define a data type for recording info about an argument list
2644    during the scan of that argument list.  This data type should
2645    hold all necessary information about the function itself
2646    and about the args processed so far, enough to enable macros
2647    such as FUNCTION_ARG to determine where the next arg should go.
2648
2649    On the mips16, we need to keep track of which floating point
2650    arguments were passed in general registers, but would have been
2651    passed in the FP regs if this were a 32 bit function, so that we
2652    can move them to the FP regs if we wind up calling a 32 bit
2653    function.  We record this information in fp_code, encoded in base
2654    four.  A zero digit means no floating point argument, a one digit
2655    means an SFmode argument, and a two digit means a DFmode argument,
2656    and a three digit is not used.  The low order digit is the first
2657    argument.  Thus 6 == 1 * 4 + 2 means a DFmode argument followed by
2658    an SFmode argument.  ??? A more sophisticated approach will be
2659    needed if MIPS_ABI != ABI_32.  */
2660
2661 typedef struct mips_args {
2662   int gp_reg_found;             /* whether a gp register was found yet */
2663   unsigned int arg_number;      /* argument number */
2664   unsigned int arg_words;       /* # total words the arguments take */
2665   unsigned int fp_arg_words;    /* # words for FP args (MIPS_EABI only) */
2666   int last_arg_fp;              /* nonzero if last arg was FP (EABI only) */
2667   int fp_code;                  /* Mode of FP arguments (mips16) */
2668   unsigned int num_adjusts;     /* number of adjustments made */
2669                                 /* Adjustments made to args pass in regs.  */
2670                                 /* ??? The size is doubled to work around a
2671                                    bug in the code that sets the adjustments
2672                                    in function_arg.  */
2673   int prototype;                /* True if the function has a prototype.  */
2674   struct rtx_def *adjust[MAX_ARGS_IN_REGISTERS*2];
2675 } CUMULATIVE_ARGS;
2676
2677 /* Initialize a variable CUM of type CUMULATIVE_ARGS
2678    for a call to a function whose data type is FNTYPE.
2679    For a library call, FNTYPE is 0.
2680
2681 */
2682
2683 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT)               \
2684   init_cumulative_args (&CUM, FNTYPE, LIBNAME)                          \
2685
2686 /* Update the data in CUM to advance over an argument
2687    of mode MODE and data type TYPE.
2688    (TYPE is null for libcalls where that information may not be available.)  */
2689
2690 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                    \
2691   function_arg_advance (&CUM, MODE, TYPE, NAMED)
2692
2693 /* Determine where to put an argument to a function.
2694    Value is zero to push the argument on the stack,
2695    or a hard register in which to store the argument.
2696
2697    MODE is the argument's machine mode.
2698    TYPE is the data type of the argument (as a tree).
2699     This is null for libcalls where that information may
2700     not be available.
2701    CUM is a variable of type CUMULATIVE_ARGS which gives info about
2702     the preceding args and about the function being called.
2703    NAMED is nonzero if this argument is a named parameter
2704     (otherwise it is an extra parameter matching an ellipsis).  */
2705
2706 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
2707   function_arg( &CUM, MODE, TYPE, NAMED)
2708
2709 /* For an arg passed partly in registers and partly in memory,
2710    this is the number of registers used.
2711    For args passed entirely in registers or entirely in memory, zero.  */
2712
2713 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
2714   function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
2715
2716 /* If defined, a C expression that gives the alignment boundary, in
2717    bits, of an argument with the specified mode and type.  If it is
2718    not defined,  `PARM_BOUNDARY' is used for all arguments.  */
2719
2720 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE)                               \
2721   (((TYPE) != 0)                                                        \
2722         ? ((TYPE_ALIGN(TYPE) <= PARM_BOUNDARY)                          \
2723                 ? PARM_BOUNDARY                                         \
2724                 : TYPE_ALIGN(TYPE))                                     \
2725         : ((GET_MODE_ALIGNMENT(MODE) <= PARM_BOUNDARY)                  \
2726                 ? PARM_BOUNDARY                                         \
2727                 : GET_MODE_ALIGNMENT(MODE)))
2728
2729 \f
2730 /* Tell prologue and epilogue if register REGNO should be saved / restored.  */
2731
2732 #define MUST_SAVE_REGISTER(regno) \
2733  ((regs_ever_live[regno] && !call_used_regs[regno])                     \
2734   || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed)       \
2735   || (regno == (GP_REG_FIRST + 31) && regs_ever_live[GP_REG_FIRST + 31]))
2736
2737 /* ALIGN FRAMES on double word boundaries */
2738 #ifndef MIPS_STACK_ALIGN
2739 #define MIPS_STACK_ALIGN(LOC) (((LOC) + 7) & ~7)
2740 #endif
2741
2742 \f
2743 /* Define the `__builtin_va_list' type for the ABI.  */
2744 #define BUILD_VA_LIST_TYPE(VALIST) \
2745   (VALIST) = mips_build_va_list ()
2746
2747 /* Implement `va_start' for varargs and stdarg.  */
2748 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
2749   mips_va_start (stdarg, valist, nextarg)
2750
2751 /* Implement `va_arg'.  */
2752 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
2753   mips_va_arg (valist, type)
2754 \f
2755 /* Output assembler code to FILE to increment profiler label # LABELNO
2756    for profiling a function entry.  */
2757
2758 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
2759 {                                                                       \
2760   if (TARGET_MIPS16)                                                    \
2761     sorry ("mips16 function profiling");                                \
2762   fprintf (FILE, "\t.set\tnoreorder\n");                                \
2763   fprintf (FILE, "\t.set\tnoat\n");                                     \
2764   fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n",    \
2765            reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]);  \
2766   fprintf (FILE, "\tjal\t_mcount\n");                                   \
2767   fprintf (FILE,                                                        \
2768            "\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from  stack\n",    \
2769            TARGET_64BIT ? "dsubu" : "subu",                             \
2770            reg_names[STACK_POINTER_REGNUM],                             \
2771            reg_names[STACK_POINTER_REGNUM],                             \
2772            Pmode == DImode ? 16 : 8);                                   \
2773   fprintf (FILE, "\t.set\treorder\n");                                  \
2774   fprintf (FILE, "\t.set\tat\n");                                       \
2775 }
2776
2777 /* Define this macro if the code for function profiling should come
2778    before the function prologue.  Normally, the profiling code comes
2779    after.  */
2780
2781 /* #define PROFILE_BEFORE_PROLOGUE */
2782
2783 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
2784    the stack pointer does not matter.  The value is tested only in
2785    functions that have frame pointers.
2786    No definition is equivalent to always zero.  */
2787
2788 #define EXIT_IGNORE_STACK 1
2789
2790 \f
2791 /* A C statement to output, on the stream FILE, assembler code for a
2792    block of data that contains the constant parts of a trampoline.
2793    This code should not include a label--the label is taken care of
2794    automatically.  */
2795
2796 #define TRAMPOLINE_TEMPLATE(STREAM)                                      \
2797 {                                                                        \
2798   fprintf (STREAM, "\t.word\t0x03e00821\t\t# move   $1,$31\n");         \
2799   fprintf (STREAM, "\t.word\t0x04110001\t\t# bgezal $0,.+8\n");         \
2800   fprintf (STREAM, "\t.word\t0x00000000\t\t# nop\n");                   \
2801   if (Pmode == DImode)                                                  \
2802     {                                                                   \
2803       fprintf (STREAM, "\t.word\t0xdfe30014\t\t# ld     $3,20($31)\n"); \
2804       fprintf (STREAM, "\t.word\t0xdfe2001c\t\t# ld     $2,28($31)\n"); \
2805     }                                                                   \
2806   else                                                                  \
2807     {                                                                   \
2808       fprintf (STREAM, "\t.word\t0x8fe30014\t\t# lw     $3,20($31)\n"); \
2809       fprintf (STREAM, "\t.word\t0x8fe20018\t\t# lw     $2,24($31)\n"); \
2810     }                                                                   \
2811   fprintf (STREAM, "\t.word\t0x0060c821\t\t# move   $25,$3 (abicalls)\n"); \
2812   fprintf (STREAM, "\t.word\t0x00600008\t\t# jr     $3\n");             \
2813   fprintf (STREAM, "\t.word\t0x0020f821\t\t# move   $31,$1\n");         \
2814   if (Pmode == DImode)                                                  \
2815     {                                                                   \
2816       fprintf (STREAM, "\t.dword\t0x00000000\t\t# <function address>\n"); \
2817       fprintf (STREAM, "\t.dword\t0x00000000\t\t# <static chain value>\n"); \
2818     }                                                                   \
2819   else                                                                  \
2820     {                                                                   \
2821       fprintf (STREAM, "\t.word\t0x00000000\t\t# <function address>\n"); \
2822       fprintf (STREAM, "\t.word\t0x00000000\t\t# <static chain value>\n"); \
2823     }                                                                   \
2824 }
2825
2826 /* A C expression for the size in bytes of the trampoline, as an
2827    integer.  */
2828
2829 #define TRAMPOLINE_SIZE (32 + (Pmode == DImode ? 16 : 8))
2830
2831 /* Alignment required for trampolines, in bits.  */
2832
2833 #define TRAMPOLINE_ALIGNMENT (Pmode == DImode ? 64 : 32)
2834
2835 /* INITIALIZE_TRAMPOLINE calls this library function to flush
2836    program and data caches.  */
2837
2838 #ifndef CACHE_FLUSH_FUNC
2839 #define CACHE_FLUSH_FUNC "_flush_cache"
2840 #endif
2841
2842 /* A C statement to initialize the variable parts of a trampoline.
2843    ADDR is an RTX for the address of the trampoline; FNADDR is an
2844    RTX for the address of the nested function; STATIC_CHAIN is an
2845    RTX for the static chain value that should be passed to the
2846    function when it is called.  */
2847
2848 #define INITIALIZE_TRAMPOLINE(ADDR, FUNC, CHAIN)                            \
2849 {                                                                           \
2850   rtx addr = ADDR;                                                          \
2851   if (Pmode == DImode)                                                      \
2852     {                                                                       \
2853       emit_move_insn (gen_rtx_MEM (DImode, plus_constant (addr, 32)), FUNC); \
2854       emit_move_insn (gen_rtx_MEM (DImode, plus_constant (addr, 40)), CHAIN);\
2855     }                                                                       \
2856   else                                                                      \
2857     {                                                                       \
2858       emit_move_insn (gen_rtx_MEM (SImode, plus_constant (addr, 32)), FUNC); \
2859       emit_move_insn (gen_rtx_MEM (SImode, plus_constant (addr, 36)), CHAIN);\
2860     }                                                                       \
2861                                                                             \
2862   /* Flush both caches.  We need to flush the data cache in case            \
2863      the system has a write-back cache.  */                                 \
2864   /* ??? Should check the return value for errors.  */                      \
2865   if (mips_cache_flush_func && mips_cache_flush_func[0])                    \
2866     emit_library_call (gen_rtx_SYMBOL_REF (Pmode, mips_cache_flush_func),   \
2867                        0, VOIDmode, 3, addr, Pmode,                         \
2868                        GEN_INT (TRAMPOLINE_SIZE), TYPE_MODE (integer_type_node),\
2869                        GEN_INT (3), TYPE_MODE (integer_type_node));         \
2870 }
2871 \f
2872 /* Addressing modes, and classification of registers for them.  */
2873
2874 /* #define HAVE_POST_INCREMENT 0 */
2875 /* #define HAVE_POST_DECREMENT 0 */
2876
2877 /* #define HAVE_PRE_DECREMENT 0 */
2878 /* #define HAVE_PRE_INCREMENT 0 */
2879
2880 /* These assume that REGNO is a hard or pseudo reg number.
2881    They give nonzero only if REGNO is a hard reg of the suitable class
2882    or a pseudo reg currently allocated to a suitable hard reg.
2883    These definitions are NOT overridden anywhere.  */
2884
2885 #define BASE_REG_P(regno, mode)                                 \
2886   (TARGET_MIPS16                                                \
2887    ? (M16_REG_P (regno)                                         \
2888       || (regno) == FRAME_POINTER_REGNUM                        \
2889       || (regno) == ARG_POINTER_REGNUM                          \
2890       || ((regno) == STACK_POINTER_REGNUM                       \
2891           && (GET_MODE_SIZE (mode) == 4                         \
2892               || GET_MODE_SIZE (mode) == 8)))                   \
2893    : GP_REG_P (regno))
2894
2895 #define GP_REG_OR_PSEUDO_STRICT_P(regno, mode)                              \
2896   BASE_REG_P((regno < FIRST_PSEUDO_REGISTER) ? (int) regno : reg_renumber[regno], \
2897              (mode))
2898
2899 #define GP_REG_OR_PSEUDO_NONSTRICT_P(regno, mode) \
2900   (((regno) >= FIRST_PSEUDO_REGISTER) || (BASE_REG_P ((regno), (mode))))
2901
2902 #define REGNO_OK_FOR_INDEX_P(regno)     0
2903 #define REGNO_MODE_OK_FOR_BASE_P(regno, mode) \
2904   GP_REG_OR_PSEUDO_STRICT_P ((regno), (mode))
2905
2906 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2907    and check its validity for a certain class.
2908    We have two alternate definitions for each of them.
2909    The usual definition accepts all pseudo regs; the other rejects them all.
2910    The symbol REG_OK_STRICT causes the latter definition to be used.
2911
2912    Most source files want to accept pseudo regs in the hope that
2913    they will get allocated to the class that the insn wants them to be in.
2914    Some source files that are used after register allocation
2915    need to be strict.  */
2916
2917 #ifndef REG_OK_STRICT
2918 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
2919   mips_reg_mode_ok_for_base_p (X, MODE, 0)
2920 #else
2921 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
2922   mips_reg_mode_ok_for_base_p (X, MODE, 1)
2923 #endif
2924
2925 #define REG_OK_FOR_INDEX_P(X) 0
2926
2927 \f
2928 /* Maximum number of registers that can appear in a valid memory address.  */
2929
2930 #define MAX_REGS_PER_ADDRESS 1
2931
2932 /* A C compound statement with a conditional `goto LABEL;' executed
2933    if X (an RTX) is a legitimate memory address on the target
2934    machine for a memory operand of mode MODE.
2935
2936    It usually pays to define several simpler macros to serve as
2937    subroutines for this one.  Otherwise it may be too complicated
2938    to understand.
2939
2940    This macro must exist in two variants: a strict variant and a
2941    non-strict one.  The strict variant is used in the reload pass.
2942    It must be defined so that any pseudo-register that has not been
2943    allocated a hard register is considered a memory reference.  In
2944    contexts where some kind of register is required, a
2945    pseudo-register with no hard register must be rejected.
2946
2947    The non-strict variant is used in other passes.  It must be
2948    defined to accept all pseudo-registers in every context where
2949    some kind of register is required.
2950
2951    Compiler source files that want to use the strict variant of
2952    this macro define the macro `REG_OK_STRICT'.  You should use an
2953    `#ifdef REG_OK_STRICT' conditional to define the strict variant
2954    in that case and the non-strict variant otherwise.
2955
2956    Typically among the subroutines used to define
2957    `GO_IF_LEGITIMATE_ADDRESS' are subroutines to check for
2958    acceptable registers for various purposes (one for base
2959    registers, one for index registers, and so on).  Then only these
2960    subroutine macros need have two variants; the higher levels of
2961    macros may be the same whether strict or not.
2962
2963    Normally, constant addresses which are the sum of a `symbol_ref'
2964    and an integer are stored inside a `const' RTX to mark them as
2965    constant.  Therefore, there is no need to recognize such sums
2966    specifically as legitimate addresses.  Normally you would simply
2967    recognize any `const' as legitimate.
2968
2969    Usually `PRINT_OPERAND_ADDRESS' is not prepared to handle
2970    constant sums that are not marked with  `const'.  It assumes
2971    that a naked `plus' indicates indexing.  If so, then you *must*
2972    reject such naked constant sums as illegitimate addresses, so
2973    that none of them will be given to `PRINT_OPERAND_ADDRESS'.
2974
2975    On some machines, whether a symbolic address is legitimate
2976    depends on the section that the address refers to.  On these
2977    machines, define the macro `ENCODE_SECTION_INFO' to store the
2978    information into the `symbol_ref', and then check for it here.
2979    When you see a `const', you will have to look inside it to find
2980    the `symbol_ref' in order to determine the section.  */
2981
2982 #if 1
2983 #define GO_PRINTF(x)    fprintf(stderr, (x))
2984 #define GO_PRINTF2(x,y) fprintf(stderr, (x), (y))
2985 #define GO_DEBUG_RTX(x) debug_rtx(x)
2986
2987 #else
2988 #define GO_PRINTF(x)
2989 #define GO_PRINTF2(x,y)
2990 #define GO_DEBUG_RTX(x)
2991 #endif
2992
2993 #ifdef REG_OK_STRICT
2994 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
2995 {                                               \
2996   if (mips_legitimate_address_p (MODE, X, 1))   \
2997     goto ADDR;                                  \
2998 }
2999 #else
3000 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
3001 {                                               \
3002   if (mips_legitimate_address_p (MODE, X, 0))   \
3003     goto ADDR;                                  \
3004 }
3005 #endif
3006
3007 /* A C expression that is 1 if the RTX X is a constant which is a
3008    valid address.  This is defined to be the same as `CONSTANT_P (X)',
3009    but rejecting CONST_DOUBLE.  */
3010 /* When pic, we must reject addresses of the form symbol+large int.
3011    This is because an instruction `sw $4,s+70000' needs to be converted
3012    by the assembler to `lw $at,s($gp);sw $4,70000($at)'.  Normally the
3013    assembler would use $at as a temp to load in the large offset.  In this
3014    case $at is already in use.  We convert such problem addresses to
3015    `la $5,s;sw $4,70000($5)' via LEGITIMIZE_ADDRESS.  */
3016 /* ??? SGI Irix 6 assembler fails for CONST address, so reject them.  */
3017 #define CONSTANT_ADDRESS_P(X)                                           \
3018   ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF             \
3019     || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH                \
3020     || (GET_CODE (X) == CONST                                           \
3021         && ! (flag_pic && pic_address_needs_scratch (X))                \
3022         && (mips_abi == ABI_32                                          \
3023             || mips_abi == ABI_O64                                      \
3024             || mips_abi == ABI_EABI)))                                  \
3025    && (!HALF_PIC_P () || !HALF_PIC_ADDRESS_P (X)))
3026
3027 /* Define this, so that when PIC, reload won't try to reload invalid
3028    addresses which require two reload registers.  */
3029
3030 #define LEGITIMATE_PIC_OPERAND_P(X)  (! pic_address_needs_scratch (X))
3031
3032 /* Nonzero if the constant value X is a legitimate general operand.
3033    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
3034
3035    At present, GAS doesn't understand li.[sd], so don't allow it
3036    to be generated at present.  Also, the MIPS assembler does not
3037    grok li.d Infinity.  */
3038
3039 /* ??? SGI Irix 6 assembler fails for CONST address, so reject them.
3040    Note that the Irix 6 assembler problem may already be fixed.
3041    Note also that the GET_CODE (X) == CONST test catches the mips16
3042    gp pseudo reg (see mips16_gp_pseudo_reg) deciding it is not
3043    a LEGITIMATE_CONSTANT.  If we ever want mips16 and ABI_N32 or
3044    ABI_64 to work together, we'll need to fix this.  */
3045 #define LEGITIMATE_CONSTANT_P(X)                                        \
3046   ((GET_CODE (X) != CONST_DOUBLE                                        \
3047     || mips_const_double_ok (X, GET_MODE (X)))                          \
3048    && ! (GET_CODE (X) == CONST                                          \
3049          && ! TARGET_GAS                                                \
3050          && (mips_abi == ABI_N32                                        \
3051              || mips_abi == ABI_64))                                    \
3052    && (! TARGET_MIPS16 || mips16_constant (X, GET_MODE (X), 0, 0)))
3053
3054 /* A C compound statement that attempts to replace X with a valid
3055    memory address for an operand of mode MODE.  WIN will be a C
3056    statement label elsewhere in the code; the macro definition may
3057    use
3058
3059           GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN);
3060
3061    to avoid further processing if the address has become legitimate.
3062
3063    X will always be the result of a call to `break_out_memory_refs',
3064    and OLDX will be the operand that was given to that function to
3065    produce X.
3066
3067    The code generated by this macro should not alter the
3068    substructure of X.  If it transforms X into a more legitimate
3069    form, it should assign X (which will always be a C variable) a
3070    new value.
3071
3072    It is not necessary for this macro to come up with a legitimate
3073    address.  The compiler has standard ways of doing so in all
3074    cases.  In fact, it is safe for this macro to do nothing.  But
3075    often a machine-dependent strategy can generate better code.
3076
3077    For the MIPS, transform:
3078
3079         memory(X + <large int>)
3080
3081    into:
3082
3083         Y = <large int> & ~0x7fff;
3084         Z = X + Y
3085         memory (Z + (<large int> & 0x7fff));
3086
3087    This is for CSE to find several similar references, and only use one Z.
3088
3089    When PIC, convert addresses of the form memory (symbol+large int) to
3090    memory (reg+large int).  */
3091
3092
3093 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                             \
3094 {                                                                       \
3095   register rtx xinsn = (X);                                             \
3096                                                                         \
3097   if (TARGET_DEBUG_B_MODE)                                              \
3098     {                                                                   \
3099       GO_PRINTF ("\n========== LEGITIMIZE_ADDRESS\n");                  \
3100       GO_DEBUG_RTX (xinsn);                                             \
3101     }                                                                   \
3102                                                                         \
3103   if (mips_split_addresses && mips_check_split (X, MODE))               \
3104     {                                                                   \
3105       /* ??? Is this ever executed?  */                                 \
3106       X = gen_rtx_LO_SUM (Pmode,                                        \
3107                           copy_to_mode_reg (Pmode,                      \
3108                                             gen_rtx (HIGH, Pmode, X)),  \
3109                           X);                                           \
3110       goto WIN;                                                         \
3111     }                                                                   \
3112                                                                         \
3113   if (GET_CODE (xinsn) == CONST                                         \
3114       && ((flag_pic && pic_address_needs_scratch (xinsn))               \
3115           /* ??? SGI's Irix 6 assembler can't handle CONST.  */         \
3116           || (mips_abi != ABI_32                                        \
3117               && mips_abi != ABI_O64                                    \
3118               && mips_abi != ABI_EABI)))                                \
3119     {                                                                   \
3120       rtx ptr_reg = gen_reg_rtx (Pmode);                                \
3121       rtx constant = XEXP (XEXP (xinsn, 0), 1);                         \
3122                                                                         \
3123       emit_move_insn (ptr_reg, XEXP (XEXP (xinsn, 0), 0));              \
3124                                                                         \
3125       X = gen_rtx_PLUS (Pmode, ptr_reg, constant);                      \
3126       if (SMALL_INT (constant))                                         \
3127         goto WIN;                                                       \
3128       /* Otherwise we fall through so the code below will fix the       \
3129          constant.  */                                                  \
3130       xinsn = X;                                                        \
3131     }                                                                   \
3132                                                                         \
3133   if (GET_CODE (xinsn) == PLUS)                                         \
3134     {                                                                   \
3135       register rtx xplus0 = XEXP (xinsn, 0);                            \
3136       register rtx xplus1 = XEXP (xinsn, 1);                            \
3137       register enum rtx_code code0 = GET_CODE (xplus0);                 \
3138       register enum rtx_code code1 = GET_CODE (xplus1);                 \
3139                                                                         \
3140       if (code0 != REG && code1 == REG)                                 \
3141         {                                                               \
3142           xplus0 = XEXP (xinsn, 1);                                     \
3143           xplus1 = XEXP (xinsn, 0);                                     \
3144           code0 = GET_CODE (xplus0);                                    \
3145           code1 = GET_CODE (xplus1);                                    \
3146         }                                                               \
3147                                                                         \
3148       if (code0 == REG && REG_MODE_OK_FOR_BASE_P (xplus0, MODE)         \
3149           && code1 == CONST_INT && !SMALL_INT (xplus1))                 \
3150         {                                                               \
3151           rtx int_reg = gen_reg_rtx (Pmode);                            \
3152           rtx ptr_reg = gen_reg_rtx (Pmode);                            \
3153                                                                         \
3154           emit_move_insn (int_reg,                                      \
3155                           GEN_INT (INTVAL (xplus1) & ~ 0x7fff));        \
3156                                                                         \
3157           emit_insn (gen_rtx_SET (VOIDmode,                             \
3158                                   ptr_reg,                              \
3159                                   gen_rtx_PLUS (Pmode, xplus0, int_reg))); \
3160                                                                         \
3161           X = plus_constant (ptr_reg, INTVAL (xplus1) & 0x7fff);        \
3162           goto WIN;                                                     \
3163         }                                                               \
3164     }                                                                   \
3165                                                                         \
3166   if (TARGET_DEBUG_B_MODE)                                              \
3167     GO_PRINTF ("LEGITIMIZE_ADDRESS could not fix.\n");                  \
3168 }
3169
3170
3171 /* A C statement or compound statement with a conditional `goto
3172    LABEL;' executed if memory address X (an RTX) can have different
3173    meanings depending on the machine mode of the memory reference it
3174    is used for.
3175
3176    Autoincrement and autodecrement addresses typically have
3177    mode-dependent effects because the amount of the increment or
3178    decrement is the size of the operand being addressed.  Some
3179    machines have other mode-dependent addresses.  Many RISC machines
3180    have no mode-dependent addresses.
3181
3182    You may assume that ADDR is a valid address for the machine.  */
3183
3184 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) {}
3185
3186
3187 /* Define this macro if references to a symbol must be treated
3188    differently depending on something about the variable or
3189    function named by the symbol (such as what section it is in).
3190
3191    The macro definition, if any, is executed immediately after the
3192    rtl for DECL has been created and stored in `DECL_RTL (DECL)'.
3193    The value of the rtl will be a `mem' whose address is a
3194    `symbol_ref'.
3195
3196    The usual thing for this macro to do is to a flag in the
3197    `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
3198    name string in the `symbol_ref' (if one bit is not enough
3199    information).
3200
3201    The best way to modify the name string is by adding text to the
3202    beginning, with suitable punctuation to prevent any ambiguity.
3203    Allocate the new name in `saveable_obstack'.  You will have to
3204    modify `ASM_OUTPUT_LABELREF' to remove and decode the added text
3205    and output the name accordingly.
3206
3207    You can also check the information stored in the `symbol_ref' in
3208    the definition of `GO_IF_LEGITIMATE_ADDRESS' or
3209    `PRINT_OPERAND_ADDRESS'.
3210
3211    When optimizing for the $gp pointer, SYMBOL_REF_FLAG is set for all
3212    small objects.
3213
3214    When generating embedded PIC code, SYMBOL_REF_FLAG is set for
3215    symbols which are not in the .text section.
3216
3217    When generating mips16 code, SYMBOL_REF_FLAG is set for string
3218    constants which are put in the .text section.  We also record the
3219    total length of all such strings; this total is used to decide
3220    whether we need to split the constant table, and need not be
3221    precisely correct.
3222
3223    When not mips16 code nor embedded PIC, if a symbol is in a
3224    gp addresable section, SYMBOL_REF_FLAG is set prevent gcc from
3225    splitting the reference so that gas can generate a gp relative
3226    reference.
3227
3228    When TARGET_EMBEDDED_DATA is set, we assume that all const
3229    variables will be stored in ROM, which is too far from %gp to use
3230    %gprel addressing.  Note that (1) we include "extern const"
3231    variables in this, which mips_select_section doesn't, and (2) we
3232    can't always tell if they're really const (they might be const C++
3233    objects with non-const constructors), so we err on the side of
3234    caution and won't use %gprel anyway (otherwise we'd have to defer
3235    this decision to the linker/loader).  The handling of extern consts
3236    is why the DECL_INITIAL macros differ from mips_select_section.
3237
3238    If you are changing this macro, you should look at
3239    mips_select_section and see if it needs a similar change.  */
3240
3241 #define ENCODE_SECTION_INFO(DECL)                                       \
3242 do                                                                      \
3243   {                                                                     \
3244     if (TARGET_MIPS16)                                                  \
3245       {                                                                 \
3246         if (TREE_CODE (DECL) == STRING_CST                              \
3247             && ! flag_writable_strings                                  \
3248             /* If this string is from a function, and the function will \
3249                go in a gnu linkonce section, then we can't directly     \
3250                access the string.  This gets an assembler error         \
3251                "unsupported PC relative reference to different section".\
3252                If we modify SELECT_SECTION to put it in function_section\
3253                instead of text_section, it still fails because          \
3254                DECL_SECTION_NAME isn't set until assemble_start_function.\
3255                If we fix that, it still fails because strings are shared\
3256                among multiple functions, and we have cross section      \
3257                references again.  We force it to work by putting string \
3258                addresses in the constant pool and indirecting.  */      \
3259             && (! current_function_decl                                 \
3260                 || ! DECL_ONE_ONLY (current_function_decl)))            \
3261           {                                                             \
3262             SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 1;        \
3263             mips_string_length += TREE_STRING_LENGTH (DECL);            \
3264           }                                                             \
3265       }                                                                 \
3266                                                                         \
3267     if (TARGET_EMBEDDED_DATA                                            \
3268         && (TREE_CODE (DECL) == VAR_DECL                                \
3269             && TREE_READONLY (DECL) && !TREE_SIDE_EFFECTS (DECL))       \
3270             && (!DECL_INITIAL (DECL)                                    \
3271                 || TREE_CONSTANT (DECL_INITIAL (DECL))))                \
3272       {                                                                 \
3273         SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 0;                \
3274       }                                                                 \
3275                                                                         \
3276     else if (TARGET_EMBEDDED_PIC)                                       \
3277       {                                                                 \
3278         if (TREE_CODE (DECL) == VAR_DECL)                               \
3279           SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;              \
3280         else if (TREE_CODE (DECL) == FUNCTION_DECL)                     \
3281           SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 0;              \
3282         else if (TREE_CODE (DECL) == STRING_CST                         \
3283                  && ! flag_writable_strings)                            \
3284           SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 0;          \
3285         else                                                            \
3286           SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 1;          \
3287       }                                                                 \
3288                                                                         \
3289     else if (TREE_CODE (DECL) == VAR_DECL                               \
3290              && DECL_SECTION_NAME (DECL) != NULL_TREE                   \
3291              && (0 == strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (DECL)), \
3292                               ".sdata")                                 \
3293                 || 0 == strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (DECL)),\
3294                               ".sbss")))                                \
3295       {                                                                 \
3296         SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;                \
3297       }                                                                 \
3298                                                                         \
3299     /* We can not perform GP optimizations on variables which are in    \
3300        specific sections, except for .sdata and .sbss which are         \
3301        handled above.  */                                               \
3302     else if (TARGET_GP_OPT && TREE_CODE (DECL) == VAR_DECL              \
3303              && DECL_SECTION_NAME (DECL) == NULL_TREE)                  \
3304       {                                                                 \
3305         int size = int_size_in_bytes (TREE_TYPE (DECL));                \
3306                                                                         \
3307         if (size > 0 && size <= mips_section_threshold)                 \
3308           SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;              \
3309       }                                                                 \
3310                                                                         \
3311     else if (HALF_PIC_P ())                                             \
3312       {                                                                 \
3313         HALF_PIC_ENCODE (DECL);                                         \
3314       }                                                                 \
3315   }                                                                     \
3316 while (0)
3317
3318 /* This handles the magic '..CURRENT_FUNCTION' symbol, which means
3319    'the start of the function that this code is output in'.  */
3320
3321 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
3322   if (strcmp (NAME, "..CURRENT_FUNCTION") == 0)                         \
3323     asm_fprintf ((FILE), "%U%s",                                        \
3324                  XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
3325   else                                                                  \
3326     asm_fprintf ((FILE), "%U%s", (NAME))
3327
3328 /* The mips16 wants the constant pool to be after the function,
3329    because the PC relative load instructions use unsigned offsets.  */
3330
3331 #define CONSTANT_POOL_BEFORE_FUNCTION (! TARGET_MIPS16)
3332
3333 #define ASM_OUTPUT_POOL_EPILOGUE(FILE, FNNAME, FNDECL, SIZE)    \
3334   mips_string_length = 0;
3335
3336 #if 0
3337 /* In mips16 mode, put most string constants after the function.  */
3338 #define CONSTANT_AFTER_FUNCTION_P(tree)                         \
3339   (TARGET_MIPS16 && mips16_constant_after_function_p (tree))
3340 #endif
3341 \f
3342 /* Specify the machine mode that this machine uses
3343    for the index in the tablejump instruction.
3344    ??? Using HImode in mips16 mode can cause overflow.  However, the
3345    overflow is no more likely than the overflow in a branch
3346    instruction.  Large functions can currently break in both ways.  */
3347 #define CASE_VECTOR_MODE \
3348   (TARGET_MIPS16 ? HImode : Pmode == DImode ? DImode : SImode)
3349
3350 /* Define as C expression which evaluates to nonzero if the tablejump
3351    instruction expects the table to contain offsets from the address of the
3352    table.
3353    Do not define this if the table should contain absolute addresses.  */
3354 #define CASE_VECTOR_PC_RELATIVE (TARGET_MIPS16)
3355
3356 /* Define this as 1 if `char' should by default be signed; else as 0.  */
3357 #ifndef DEFAULT_SIGNED_CHAR
3358 #define DEFAULT_SIGNED_CHAR 1
3359 #endif
3360
3361 /* Max number of bytes we can move from memory to memory
3362    in one reasonably fast instruction.  */
3363 #define MOVE_MAX (TARGET_64BIT ? 8 : 4)
3364 #define MAX_MOVE_MAX 8
3365
3366 /* Define this macro as a C expression which is nonzero if
3367    accessing less than a word of memory (i.e. a `char' or a
3368    `short') is no faster than accessing a word of memory, i.e., if
3369    such access require more than one instruction or if there is no
3370    difference in cost between byte and (aligned) word loads.
3371
3372    On RISC machines, it tends to generate better code to define
3373    this as 1, since it avoids making a QI or HI mode register.  */
3374 #define SLOW_BYTE_ACCESS 1
3375
3376 /* We assume that the store-condition-codes instructions store 0 for false
3377    and some other value for true.  This is the value stored for true.  */
3378
3379 #define STORE_FLAG_VALUE 1
3380
3381 /* Define this to be nonzero if shift instructions ignore all but the low-order
3382    few bits.  */
3383 #define SHIFT_COUNT_TRUNCATED 1
3384
3385 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
3386    is done just by pretending it is already truncated.  */
3387 /* In 64 bit mode, 32 bit instructions require that register values be properly
3388    sign-extended to 64 bits.  As a result, a truncate is not a no-op if it
3389    converts a value >32 bits to a value <32 bits.  */
3390 /* ??? This results in inefficient code for 64 bit to 32 conversions.
3391    Something needs to be done about this.  Perhaps not use any 32 bit
3392    instructions?  Perhaps use PROMOTE_MODE?  */
3393 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) \
3394   (TARGET_64BIT ? ((INPREC) <= 32 || (OUTPREC) > 32) : 1)
3395
3396 /* Specify the machine mode that pointers have.
3397    After generation of rtl, the compiler makes no further distinction
3398    between pointers and any other objects of this machine mode.
3399
3400    For MIPS we make pointers are the smaller of longs and gp-registers.  */
3401
3402 #ifndef Pmode
3403 #define Pmode ((TARGET_LONG64 && TARGET_64BIT) ? DImode : SImode)
3404 #endif
3405
3406 /* A function address in a call instruction
3407    is a word address (for indexing purposes)
3408    so give the MEM rtx a words's mode.  */
3409
3410 #define FUNCTION_MODE (Pmode == DImode ? DImode : SImode)
3411
3412 /* Define TARGET_MEM_FUNCTIONS if we want to use calls to memcpy and
3413    memset, instead of the BSD functions bcopy and bzero.  */
3414
3415 #if defined(MIPS_SYSV) || defined(OSF_OS)
3416 #define TARGET_MEM_FUNCTIONS
3417 #endif
3418
3419 \f
3420 /* A part of a C `switch' statement that describes the relative
3421    costs of constant RTL expressions.  It must contain `case'
3422    labels for expression codes `const_int', `const', `symbol_ref',
3423    `label_ref' and `const_double'.  Each case must ultimately reach
3424    a `return' statement to return the relative cost of the use of
3425    that kind of constant value in an expression.  The cost may
3426    depend on the precise value of the constant, which is available
3427    for examination in X.
3428
3429    CODE is the expression code--redundant, since it can be obtained
3430    with `GET_CODE (X)'.  */
3431
3432 #define CONST_COSTS(X,CODE,OUTER_CODE)                                  \
3433   case CONST_INT:                                                       \
3434     if (! TARGET_MIPS16)                                                \
3435       {                                                                 \
3436         /* Always return 0, since we don't have different sized         \
3437            instructions, hence different costs according to Richard     \
3438            Kenner */                                                    \
3439         return 0;                                                       \
3440       }                                                                 \
3441     if ((OUTER_CODE) == SET)                                            \
3442       {                                                                 \
3443         if (INTVAL (X) >= 0 && INTVAL (X) < 0x100)                      \
3444           return 0;                                                     \
3445         else if ((INTVAL (X) >= 0 && INTVAL (X) < 0x10000)              \
3446                  || (INTVAL (X) < 0 && INTVAL (X) > -0x100))            \
3447           return COSTS_N_INSNS (1);                                     \
3448         else                                                            \
3449           return COSTS_N_INSNS (2);                                     \
3450       }                                                                 \
3451     /* A PLUS could be an address.  We don't want to force an address   \
3452        to use a register, so accept any signed 16 bit value without     \
3453        complaint.  */                                                   \
3454     if ((OUTER_CODE) == PLUS                                            \
3455         && INTVAL (X) >= -0x8000 && INTVAL (X) < 0x8000)                \
3456       return 0;                                                         \
3457     /* A number between 1 and 8 inclusive is efficient for a shift.     \
3458        Otherwise, we will need an extended instruction.  */             \
3459     if ((OUTER_CODE) == ASHIFT || (OUTER_CODE) == ASHIFTRT              \
3460         || (OUTER_CODE) == LSHIFTRT)                                    \
3461       {                                                                 \
3462         if (INTVAL (X) >= 1 && INTVAL (X) <= 8)                         \
3463           return 0;                                                     \
3464         return COSTS_N_INSNS (1);                                       \
3465       }                                                                 \
3466     /* We can use cmpi for an xor with an unsigned 16 bit value.  */    \
3467     if ((OUTER_CODE) == XOR                                             \
3468         && INTVAL (X) >= 0 && INTVAL (X) < 0x10000)                     \
3469       return 0;                                                         \
3470     /* We may be able to use slt or sltu for a comparison with a        \
3471        signed 16 bit value.  (The boundary conditions aren't quite      \
3472        right, but this is just a heuristic anyhow.)  */                 \
3473     if (((OUTER_CODE) == LT || (OUTER_CODE) == LE                       \
3474          || (OUTER_CODE) == GE || (OUTER_CODE) == GT                    \
3475          || (OUTER_CODE) == LTU || (OUTER_CODE) == LEU                  \
3476          || (OUTER_CODE) == GEU || (OUTER_CODE) == GTU)                 \
3477         && INTVAL (X) >= -0x8000 && INTVAL (X) < 0x8000)                \
3478       return 0;                                                         \
3479     /* Equality comparisons with 0 are cheap.  */                       \
3480     if (((OUTER_CODE) == EQ || (OUTER_CODE) == NE)                      \
3481         && INTVAL (X) == 0)                                             \
3482       return 0;                                                         \
3483                                                                         \
3484     /* Otherwise, work out the cost to load the value into a            \
3485        register.  */                                                    \
3486     if (INTVAL (X) >= 0 && INTVAL (X) < 0x100)                          \
3487       return COSTS_N_INSNS (1);                                         \
3488     else if ((INTVAL (X) >= 0 && INTVAL (X) < 0x10000)                  \
3489              || (INTVAL (X) < 0 && INTVAL (X) > -0x100))                \
3490       return COSTS_N_INSNS (2);                                         \
3491     else                                                                \
3492       return COSTS_N_INSNS (3);                                         \
3493                                                                         \
3494   case LABEL_REF:                                                       \
3495     return COSTS_N_INSNS (2);                                           \
3496                                                                         \
3497   case CONST:                                                           \
3498     {                                                                   \
3499       rtx offset = const0_rtx;                                          \
3500       rtx symref = eliminate_constant_term (XEXP (X, 0), &offset);      \
3501                                                                         \
3502       if (TARGET_MIPS16 && mips16_gp_offset_p (X))                      \
3503         {                                                               \
3504           /* Treat this like a signed 16 bit CONST_INT.  */             \
3505           if ((OUTER_CODE) == PLUS)                                     \
3506             return 0;                                                   \
3507           else if ((OUTER_CODE) == SET)                                 \
3508             return COSTS_N_INSNS (1);                                   \
3509           else                                                          \
3510             return COSTS_N_INSNS (2);                                   \
3511         }                                                               \
3512                                                                         \
3513       if (GET_CODE (symref) == LABEL_REF)                               \
3514         return COSTS_N_INSNS (2);                                       \
3515                                                                         \
3516       if (GET_CODE (symref) != SYMBOL_REF)                              \
3517         return COSTS_N_INSNS (4);                                       \
3518                                                                         \
3519       /* let's be paranoid....  */                                      \
3520       if (INTVAL (offset) < -32768 || INTVAL (offset) > 32767)          \
3521         return COSTS_N_INSNS (2);                                       \
3522                                                                         \
3523       return COSTS_N_INSNS (SYMBOL_REF_FLAG (symref) ? 1 : 2);          \
3524     }                                                                   \
3525                                                                         \
3526   case SYMBOL_REF:                                                      \
3527     return COSTS_N_INSNS (SYMBOL_REF_FLAG (X) ? 1 : 2);                 \
3528                                                                         \
3529   case CONST_DOUBLE:                                                    \
3530     {                                                                   \
3531       rtx high, low;                                                    \
3532       if (TARGET_MIPS16)                                                \
3533         return COSTS_N_INSNS (4);                                       \
3534       split_double (X, &high, &low);                                    \
3535       return COSTS_N_INSNS ((high == CONST0_RTX (GET_MODE (high))       \
3536                              || low == CONST0_RTX (GET_MODE (low)))     \
3537                             ? 2 : 4);                                   \
3538     }
3539
3540 /* Like `CONST_COSTS' but applies to nonconstant RTL expressions.
3541    This can be used, for example, to indicate how costly a multiply
3542    instruction is.  In writing this macro, you can use the construct
3543    `COSTS_N_INSNS (N)' to specify a cost equal to N fast instructions.
3544
3545    This macro is optional; do not define it if the default cost
3546    assumptions are adequate for the target machine.
3547
3548    If -mdebugd is used, change the multiply cost to 2, so multiply by
3549    a constant isn't converted to a series of shifts.  This helps
3550    strength reduction, and also makes it easier to identify what the
3551    compiler is doing.  */
3552
3553 /* ??? Fix this to be right for the R8000.  */
3554 #define RTX_COSTS(X,CODE,OUTER_CODE)                                    \
3555   case MEM:                                                             \
3556     {                                                                   \
3557       int num_words = (GET_MODE_SIZE (GET_MODE (X)) > UNITS_PER_WORD) ? 2 : 1; \
3558       if (simple_memory_operand (X, GET_MODE (X)))                      \
3559         return COSTS_N_INSNS (num_words);                               \
3560                                                                         \
3561       return COSTS_N_INSNS (2*num_words);                               \
3562     }                                                                   \
3563                                                                         \
3564   case FFS:                                                             \
3565     return COSTS_N_INSNS (6);                                           \
3566                                                                         \
3567   case NOT:                                                             \
3568     return COSTS_N_INSNS ((GET_MODE (X) == DImode && !TARGET_64BIT) ? 2 : 1); \
3569                                                                         \
3570   case AND:                                                             \
3571   case IOR:                                                             \
3572   case XOR:                                                             \
3573     if (GET_MODE (X) == DImode && !TARGET_64BIT)                        \
3574       return COSTS_N_INSNS (2);                                         \
3575                                                                         \
3576     break;                                                              \
3577                                                                         \
3578   case ASHIFT:                                                          \
3579   case ASHIFTRT:                                                        \
3580   case LSHIFTRT:                                                        \
3581     if (GET_MODE (X) == DImode && !TARGET_64BIT)                        \
3582       return COSTS_N_INSNS ((GET_CODE (XEXP (X, 1)) == CONST_INT) ? 4 : 12); \
3583                                                                         \
3584     break;                                                              \
3585                                                                         \
3586   case ABS:                                                             \
3587     {                                                                   \
3588       enum machine_mode xmode = GET_MODE (X);                           \
3589       if (xmode == SFmode || xmode == DFmode)                           \
3590         return COSTS_N_INSNS (1);                                       \
3591                                                                         \
3592       return COSTS_N_INSNS (4);                                         \
3593     }                                                                   \
3594                                                                         \
3595   case PLUS:                                                            \
3596   case MINUS:                                                           \
3597     {                                                                   \
3598       enum machine_mode xmode = GET_MODE (X);                           \
3599       if (xmode == SFmode || xmode == DFmode)                           \
3600         {                                                               \
3601           if (TUNE_MIPS3000                                             \
3602               || TUNE_MIPS3900)                                         \
3603             return COSTS_N_INSNS (2);                                   \
3604           else if (TUNE_MIPS6000)                                       \
3605             return COSTS_N_INSNS (3);                                   \
3606           else                                                          \
3607             return COSTS_N_INSNS (6);                                   \
3608         }                                                               \
3609                                                                         \
3610       if (xmode == DImode && !TARGET_64BIT)                             \
3611         return COSTS_N_INSNS (4);                                       \
3612                                                                         \
3613       break;                                                            \
3614     }                                                                   \
3615                                                                         \
3616   case NEG:                                                             \
3617     if (GET_MODE (X) == DImode && !TARGET_64BIT)                        \
3618       return 4;                                                         \
3619                                                                         \
3620     break;                                                              \
3621                                                                         \
3622   case MULT:                                                            \
3623     {                                                                   \
3624       enum machine_mode xmode = GET_MODE (X);                           \
3625       if (xmode == SFmode)                                              \
3626         {                                                               \
3627           if (TUNE_MIPS3000                             \
3628               || TUNE_MIPS3900                          \
3629               || TUNE_MIPS5000)                         \
3630             return COSTS_N_INSNS (4);                                   \
3631           else if (TUNE_MIPS6000)                               \
3632             return COSTS_N_INSNS (5);                                   \
3633           else                                                          \
3634             return COSTS_N_INSNS (7);                                   \
3635         }                                                               \
3636                                                                         \
3637       if (xmode == DFmode)                                              \
3638         {                                                               \
3639           if (TUNE_MIPS3000                             \
3640               || TUNE_MIPS3900                          \
3641               || TUNE_MIPS5000)                         \
3642             return COSTS_N_INSNS (5);                                   \
3643           else if (TUNE_MIPS6000)                               \
3644             return COSTS_N_INSNS (6);                                   \
3645           else                                                          \
3646             return COSTS_N_INSNS (8);                                   \
3647         }                                                               \
3648                                                                         \
3649       if (TUNE_MIPS3000)                                        \
3650         return COSTS_N_INSNS (12);                                      \
3651       else if (TUNE_MIPS3900)                           \
3652         return COSTS_N_INSNS (2);                                       \
3653       else if (TUNE_MIPS6000)                           \
3654         return COSTS_N_INSNS (17);                                      \
3655       else if (TUNE_MIPS5000)                           \
3656         return COSTS_N_INSNS (5);                                       \
3657       else                                                              \
3658         return COSTS_N_INSNS (10);                                      \
3659     }                                                                   \
3660                                                                         \
3661   case DIV:                                                             \
3662   case MOD:                                                             \
3663     {                                                                   \
3664       enum machine_mode xmode = GET_MODE (X);                           \
3665       if (xmode == SFmode)                                              \
3666         {                                                               \
3667           if (TUNE_MIPS3000                             \
3668               || TUNE_MIPS3900)                         \
3669             return COSTS_N_INSNS (12);                                  \
3670           else if (TUNE_MIPS6000)                               \
3671             return COSTS_N_INSNS (15);                                  \
3672           else                                                          \
3673             return COSTS_N_INSNS (23);                                  \
3674         }                                                               \
3675                                                                         \
3676       if (xmode == DFmode)                                              \
3677         {                                                               \
3678           if (TUNE_MIPS3000                             \
3679               || TUNE_MIPS3900)                         \
3680             return COSTS_N_INSNS (19);                                  \
3681           else if (TUNE_MIPS6000)                               \
3682             return COSTS_N_INSNS (16);                                  \
3683           else                                                          \
3684             return COSTS_N_INSNS (36);                                  \
3685         }                                                               \
3686     }                                                                   \
3687     /* fall through */                                                  \
3688                                                                         \
3689   case UDIV:                                                            \
3690   case UMOD:                                                            \
3691     if (TUNE_MIPS3000                                   \
3692         || TUNE_MIPS3900)                                       \
3693       return COSTS_N_INSNS (35);                                        \
3694     else if (TUNE_MIPS6000)                             \
3695       return COSTS_N_INSNS (38);                                        \
3696     else if (TUNE_MIPS5000)                             \
3697       return COSTS_N_INSNS (36);                                        \
3698     else                                                                \
3699       return COSTS_N_INSNS (69);                                        \
3700                                                                         \
3701   case SIGN_EXTEND:                                                     \
3702     /* A sign extend from SImode to DImode in 64 bit mode is often      \
3703        zero instructions, because the result can often be used          \
3704        directly by another instruction; we'll call it one.  */          \
3705     if (TARGET_64BIT && GET_MODE (X) == DImode                          \
3706         && GET_MODE (XEXP (X, 0)) == SImode)                            \
3707       return COSTS_N_INSNS (1);                                         \
3708     else                                                                \
3709       return COSTS_N_INSNS (2);                                         \
3710                                                                         \
3711   case ZERO_EXTEND:                                                     \
3712     if (TARGET_64BIT && GET_MODE (X) == DImode                          \
3713         && GET_MODE (XEXP (X, 0)) == SImode)                            \
3714       return COSTS_N_INSNS (2);                                         \
3715     else                                                                \
3716       return COSTS_N_INSNS (1);
3717
3718 /* An expression giving the cost of an addressing mode that
3719    contains ADDRESS.  If not defined, the cost is computed from the
3720    form of the ADDRESS expression and the `CONST_COSTS' values.
3721
3722    For most CISC machines, the default cost is a good approximation
3723    of the true cost of the addressing mode.  However, on RISC
3724    machines, all instructions normally have the same length and
3725    execution time.  Hence all addresses will have equal costs.
3726
3727    In cases where more than one form of an address is known, the
3728    form with the lowest cost will be used.  If multiple forms have
3729    the same, lowest, cost, the one that is the most complex will be
3730    used.
3731
3732    For example, suppose an address that is equal to the sum of a
3733    register and a constant is used twice in the same basic block.
3734    When this macro is not defined, the address will be computed in
3735    a register and memory references will be indirect through that
3736    register.  On machines where the cost of the addressing mode
3737    containing the sum is no higher than that of a simple indirect
3738    reference, this will produce an additional instruction and
3739    possibly require an additional register.  Proper specification
3740    of this macro eliminates this overhead for such machines.
3741
3742    Similar use of this macro is made in strength reduction of loops.
3743
3744    ADDRESS need not be valid as an address.  In such a case, the
3745    cost is not relevant and can be any value; invalid addresses
3746    need not be assigned a different cost.
3747
3748    On machines where an address involving more than one register is
3749    as cheap as an address computation involving only one register,
3750    defining `ADDRESS_COST' to reflect this can cause two registers
3751    to be live over a region of code where only one would have been
3752    if `ADDRESS_COST' were not defined in that manner.  This effect
3753    should be considered in the definition of this macro.
3754    Equivalent costs should probably only be given to addresses with
3755    different numbers of registers on machines with lots of registers.
3756
3757    This macro will normally either not be defined or be defined as
3758    a constant.  */
3759
3760 #define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : mips_address_cost (ADDR))
3761
3762 /* A C expression for the cost of moving data from a register in
3763    class FROM to one in class TO.  The classes are expressed using
3764    the enumeration values such as `GENERAL_REGS'.  A value of 2 is
3765    the default; other values are interpreted relative to that.
3766
3767    It is not required that the cost always equal 2 when FROM is the
3768    same as TO; on some machines it is expensive to move between
3769    registers if they are not general registers.
3770
3771    If reload sees an insn consisting of a single `set' between two
3772    hard registers, and if `REGISTER_MOVE_COST' applied to their
3773    classes returns a value of 2, reload does not check to ensure
3774    that the constraints of the insn are met.  Setting a cost of
3775    other than 2 will allow reload to verify that the constraints are
3776    met.  You should do this if the `movM' pattern's constraints do
3777    not allow such copying.
3778
3779    ??? We make make the cost of moving from HI/LO/HILO/MD into general
3780    registers the same as for one of moving general registers to
3781    HI/LO/HILO/MD for TARGET_MIPS16 in order to prevent allocating a
3782    pseudo to HI/LO/HILO/MD.  This might hurt optimizations though, it
3783    isn't clear if it is wise.  And it might not work in all cases.  We
3784    could solve the DImode LO reg problem by using a multiply, just like
3785    reload_{in,out}si.  We could solve the SImode/HImode HI reg problem
3786    by using divide instructions.  divu puts the remainder in the HI
3787    reg, so doing a divide by -1 will move the value in the HI reg for
3788    all values except -1.  We could handle that case by using a signed
3789    divide, e.g.  -1 / 2 (or maybe 1 / -2?).  We'd have to emit a
3790    compare/branch to test the input value to see which instruction we
3791    need to use.  This gets pretty messy, but it is feasible.  */
3792
3793 #define REGISTER_MOVE_COST(MODE, FROM, TO)      \
3794   ((FROM) == M16_REGS && GR_REG_CLASS_P (TO) ? 2                        \
3795    : (FROM) == M16_NA_REGS && GR_REG_CLASS_P (TO) ? 2                   \
3796    : GR_REG_CLASS_P (FROM) && (TO) == M16_REGS ? 2                      \
3797    : GR_REG_CLASS_P (FROM) && (TO) == M16_NA_REGS ? 2                   \
3798    : GR_REG_CLASS_P (FROM) && GR_REG_CLASS_P (TO) ? (TARGET_MIPS16 ? 4 : 2) \
3799    : (FROM) == FP_REGS && (TO) == FP_REGS ? 2                           \
3800    : GR_REG_CLASS_P (FROM) && (TO) == FP_REGS ? 4                       \
3801    : (FROM) == FP_REGS && GR_REG_CLASS_P (TO) ? 4                       \
3802    : (((FROM) == HI_REG || (FROM) == LO_REG                             \
3803        || (FROM) == MD_REGS || (FROM) == HILO_REG)                      \
3804       && GR_REG_CLASS_P (TO)) ? (TARGET_MIPS16 ? 12 : 6)                \
3805    : (((TO) == HI_REG || (TO) == LO_REG                                 \
3806        || (TO) == MD_REGS || (TO) == HILO_REG)                          \
3807       && GR_REG_CLASS_P (FROM)) ? (TARGET_MIPS16 ? 12 : 6)              \
3808    : (FROM) == ST_REGS && GR_REG_CLASS_P (TO) ? 4                       \
3809    : (FROM) == FP_REGS && (TO) == ST_REGS ? 8                           \
3810    : 12)
3811
3812 /* ??? Fix this to be right for the R8000.  */
3813 #define MEMORY_MOVE_COST(MODE,CLASS,TO_P) \
3814   (((TUNE_MIPS4000 || TUNE_MIPS6000) ? 6 : 4) \
3815    + memory_move_secondary_cost ((MODE), (CLASS), (TO_P)))
3816
3817 /* Define if copies to/from condition code registers should be avoided.
3818
3819    This is needed for the MIPS because reload_outcc is not complete;
3820    it needs to handle cases where the source is a general or another
3821    condition code register.  */
3822 #define AVOID_CCMODE_COPIES
3823
3824 /* A C expression for the cost of a branch instruction.  A value of
3825    1 is the default; other values are interpreted relative to that.  */
3826
3827 /* ??? Fix this to be right for the R8000.  */
3828 #define BRANCH_COST                                                     \
3829   ((! TARGET_MIPS16                                                     \
3830     && (TUNE_MIPS4000 || TUNE_MIPS6000))        \
3831    ? 2 : 1)
3832
3833 /* If defined, modifies the length assigned to instruction INSN as a
3834    function of the context in which it is used.  LENGTH is an lvalue
3835    that contains the initially computed length of the insn and should
3836    be updated with the correct length of the insn.  */
3837 #define ADJUST_INSN_LENGTH(INSN, LENGTH) \
3838   ((LENGTH) = mips_adjust_insn_length ((INSN), (LENGTH)))
3839
3840 \f
3841 /* Optionally define this if you have added predicates to
3842    `MACHINE.c'.  This macro is called within an initializer of an
3843    array of structures.  The first field in the structure is the
3844    name of a predicate and the second field is an array of rtl
3845    codes.  For each predicate, list all rtl codes that can be in
3846    expressions matched by the predicate.  The list should have a
3847    trailing comma.  Here is an example of two entries in the list
3848    for a typical RISC machine:
3849
3850    #define PREDICATE_CODES \
3851      {"gen_reg_rtx_operand", {SUBREG, REG}},  \
3852      {"reg_or_short_cint_operand", {SUBREG, REG, CONST_INT}},
3853
3854    Defining this macro does not affect the generated code (however,
3855    incorrect definitions that omit an rtl code that may be matched
3856    by the predicate can cause the compiler to malfunction).
3857    Instead, it allows the table built by `genrecog' to be more
3858    compact and efficient, thus speeding up the compiler.  The most
3859    important predicates to include in the list specified by this
3860    macro are thoses used in the most insn patterns.  */
3861
3862 #define PREDICATE_CODES                                                 \
3863   {"uns_arith_operand",         { REG, CONST_INT, SUBREG }},            \
3864   {"arith_operand",             { REG, CONST_INT, SUBREG }},            \
3865   {"arith32_operand",           { REG, CONST_INT, SUBREG }},            \
3866   {"reg_or_0_operand",          { REG, CONST_INT, CONST_DOUBLE, SUBREG }}, \
3867   {"true_reg_or_0_operand",     { REG, CONST_INT, CONST_DOUBLE, SUBREG }}, \
3868   {"small_int",                 { CONST_INT }},                         \
3869   {"large_int",                 { CONST_INT }},                         \
3870   {"mips_const_double_ok",      { CONST_DOUBLE }},                      \
3871   {"const_float_1_operand",     { CONST_DOUBLE }},                      \
3872   {"simple_memory_operand",     { MEM, SUBREG }},                       \
3873   {"equality_op",               { EQ, NE }},                            \
3874   {"cmp_op",                    { EQ, NE, GT, GE, GTU, GEU, LT, LE,     \
3875                                   LTU, LEU }},                          \
3876   {"trap_cmp_op",               { EQ, NE, GE, GEU, LT, LTU }},          \
3877   {"pc_or_label_operand",       { PC, LABEL_REF }},                     \
3878   {"call_insn_operand",         { CONST_INT, CONST, SYMBOL_REF, REG}},  \
3879   {"move_operand",              { CONST_INT, CONST_DOUBLE, CONST,       \
3880                                   SYMBOL_REF, LABEL_REF, SUBREG,        \
3881                                   REG, MEM}},                           \
3882   {"movdi_operand",             { CONST_INT, CONST_DOUBLE, CONST,       \
3883                                   SYMBOL_REF, LABEL_REF, SUBREG, REG,   \
3884                                   MEM, SIGN_EXTEND }},                  \
3885   {"se_register_operand",       { SUBREG, REG, SIGN_EXTEND }},          \
3886   {"se_reg_or_0_operand",       { REG, CONST_INT, CONST_DOUBLE, SUBREG, \
3887                                   SIGN_EXTEND }},                       \
3888   {"se_uns_arith_operand",      { REG, CONST_INT, SUBREG,               \
3889                                   SIGN_EXTEND }},                       \
3890   {"se_arith_operand",          { REG, CONST_INT, SUBREG,               \
3891                                   SIGN_EXTEND }},                       \
3892   {"se_nonmemory_operand",      { CONST_INT, CONST_DOUBLE, CONST,       \
3893                                   SYMBOL_REF, LABEL_REF, SUBREG,        \
3894                                   REG, SIGN_EXTEND }},                  \
3895   {"se_nonimmediate_operand",   { SUBREG, REG, MEM, SIGN_EXTEND }},     \
3896   {"consttable_operand",        { LABEL_REF, SYMBOL_REF, CONST_INT,     \
3897                                   CONST_DOUBLE, CONST }},               \
3898   {"extend_operator",           { SIGN_EXTEND, ZERO_EXTEND }},          \
3899   {"highpart_shift_operator",   { ASHIFTRT, LSHIFTRT, ROTATERT, ROTATE }},
3900
3901 /* A list of predicates that do special things with modes, and so
3902    should not elicit warnings for VOIDmode match_operand.  */
3903
3904 #define SPECIAL_MODE_PREDICATES \
3905   "pc_or_label_operand",
3906
3907 \f
3908 /* If defined, a C statement to be executed just prior to the
3909    output of assembler code for INSN, to modify the extracted
3910    operands so they will be output differently.
3911
3912    Here the argument OPVEC is the vector containing the operands
3913    extracted from INSN, and NOPERANDS is the number of elements of
3914    the vector which contain meaningful data for this insn.  The
3915    contents of this vector are what will be used to convert the
3916    insn template into assembler code, so you can change the
3917    assembler output by changing the contents of the vector.
3918
3919    We use it to check if the current insn needs a nop in front of it
3920    because of load delays, and also to update the delay slot
3921    statistics.  */
3922
3923 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS)                      \
3924   final_prescan_insn (INSN, OPVEC, NOPERANDS)
3925
3926 \f
3927 /* Control the assembler format that we output.  */
3928
3929 /* Output at beginning of assembler file.
3930    If we are optimizing to use the global pointer, create a temporary
3931    file to hold all of the text stuff, and write it out to the end.
3932    This is needed because the MIPS assembler is evidently one pass,
3933    and if it hasn't seen the relevant .comm/.lcomm/.extern/.sdata
3934    declaration when the code is processed, it generates a two
3935    instruction sequence.  */
3936
3937 #undef ASM_FILE_START
3938 #define ASM_FILE_START(STREAM) mips_asm_file_start (STREAM)
3939
3940 /* Output to assembler file text saying following lines
3941    may contain character constants, extra white space, comments, etc.  */
3942
3943 #ifndef ASM_APP_ON
3944 #define ASM_APP_ON " #APP\n"
3945 #endif
3946
3947 /* Output to assembler file text saying following lines
3948    no longer contain unusual constructs.  */
3949
3950 #ifndef ASM_APP_OFF
3951 #define ASM_APP_OFF " #NO_APP\n"
3952 #endif
3953
3954 /* How to refer to registers in assembler output.
3955    This sequence is indexed by compiler's hard-register-number (see above).
3956
3957    In order to support the two different conventions for register names,
3958    we use the name of a table set up in mips.c, which is overwritten
3959    if -mrnames is used.  */
3960
3961 #define REGISTER_NAMES                                                  \
3962 {                                                                       \
3963   &mips_reg_names[ 0][0],                                               \
3964   &mips_reg_names[ 1][0],                                               \
3965   &mips_reg_names[ 2][0],                                               \
3966   &mips_reg_names[ 3][0],                                               \
3967   &mips_reg_names[ 4][0],                                               \
3968   &mips_reg_names[ 5][0],                                               \
3969   &mips_reg_names[ 6][0],                                               \
3970   &mips_reg_names[ 7][0],                                               \
3971   &mips_reg_names[ 8][0],                                               \
3972   &mips_reg_names[ 9][0],                                               \
3973   &mips_reg_names[10][0],                                               \
3974   &mips_reg_names[11][0],                                               \
3975   &mips_reg_names[12][0],                                               \
3976   &mips_reg_names[13][0],                                               \
3977   &mips_reg_names[14][0],                                               \
3978   &mips_reg_names[15][0],                                               \
3979   &mips_reg_names[16][0],                                               \
3980   &mips_reg_names[17][0],                                               \
3981   &mips_reg_names[18][0],                                               \
3982   &mips_reg_names[19][0],                                               \
3983   &mips_reg_names[20][0],                                               \
3984   &mips_reg_names[21][0],                                               \
3985   &mips_reg_names[22][0],                                               \
3986   &mips_reg_names[23][0],                                               \
3987   &mips_reg_names[24][0],                                               \
3988   &mips_reg_names[25][0],                                               \
3989   &mips_reg_names[26][0],                                               \
3990   &mips_reg_names[27][0],                                               \
3991   &mips_reg_names[28][0],                                               \
3992   &mips_reg_names[29][0],                                               \
3993   &mips_reg_names[30][0],                                               \
3994   &mips_reg_names[31][0],                                               \
3995   &mips_reg_names[32][0],                                               \
3996   &mips_reg_names[33][0],                                               \
3997   &mips_reg_names[34][0],                                               \
3998   &mips_reg_names[35][0],                                               \
3999   &mips_reg_names[36][0],                                               \
4000   &mips_reg_names[37][0],                                               \
4001   &mips_reg_names[38][0],                                               \
4002   &mips_reg_names[39][0],                                               \
4003   &mips_reg_names[40][0],                                               \
4004   &mips_reg_names[41][0],                                               \
4005   &mips_reg_names[42][0],                                               \
4006   &mips_reg_names[43][0],                                               \
4007   &mips_reg_names[44][0],                                               \
4008   &mips_reg_names[45][0],                                               \
4009   &mips_reg_names[46][0],                                               \
4010   &mips_reg_names[47][0],                                               \
4011   &mips_reg_names[48][0],                                               \
4012   &mips_reg_names[49][0],                                               \
4013   &mips_reg_names[50][0],                                               \
4014   &mips_reg_names[51][0],                                               \
4015   &mips_reg_names[52][0],                                               \
4016   &mips_reg_names[53][0],                                               \
4017   &mips_reg_names[54][0],                                               \
4018   &mips_reg_names[55][0],                                               \
4019   &mips_reg_names[56][0],                                               \
4020   &mips_reg_names[57][0],                                               \
4021   &mips_reg_names[58][0],                                               \
4022   &mips_reg_names[59][0],                                               \
4023   &mips_reg_names[60][0],                                               \
4024   &mips_reg_names[61][0],                                               \
4025   &mips_reg_names[62][0],                                               \
4026   &mips_reg_names[63][0],                                               \
4027   &mips_reg_names[64][0],                                               \
4028   &mips_reg_names[65][0],                                               \
4029   &mips_reg_names[66][0],                                               \
4030   &mips_reg_names[67][0],                                               \
4031   &mips_reg_names[68][0],                                               \
4032   &mips_reg_names[69][0],                                               \
4033   &mips_reg_names[70][0],                                               \
4034   &mips_reg_names[71][0],                                               \
4035   &mips_reg_names[72][0],                                               \
4036   &mips_reg_names[73][0],                                               \
4037   &mips_reg_names[74][0],                                               \
4038   &mips_reg_names[75][0],                                               \
4039 }
4040
4041 /* print-rtl.c can't use REGISTER_NAMES, since it depends on mips.c.
4042    So define this for it.  */
4043 #define DEBUG_REGISTER_NAMES                                            \
4044 {                                                                       \
4045   "$0",   "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",         \
4046   "t0",   "t1",   "t2",   "t3",   "t4",   "t5",   "t6",   "t7",         \
4047   "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",         \
4048   "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "$fp",   "ra",        \
4049   "$f0",  "$f1",  "$f2",  "$f3",  "$f4",  "$f5",  "$f6",  "$f7",        \
4050   "$f8",  "$f9",  "$f10", "$f11", "$f12", "$f13", "$f14", "$f15",       \
4051   "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",       \
4052   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",       \
4053   "hi",   "lo",   "accum","$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",      \
4054   "$fcc5","$fcc6","$fcc7","$rap"                                        \
4055 }
4056
4057 /* If defined, a C initializer for an array of structures
4058    containing a name and a register number.  This macro defines
4059    additional names for hard registers, thus allowing the `asm'
4060    option in declarations to refer to registers using alternate
4061    names.
4062
4063    We define both names for the integer registers here.  */
4064
4065 #define ADDITIONAL_REGISTER_NAMES                                       \
4066 {                                                                       \
4067   { "$0",        0 + GP_REG_FIRST },                                    \
4068   { "$1",        1 + GP_REG_FIRST },                                    \
4069   { "$2",        2 + GP_REG_FIRST },                                    \
4070   { "$3",        3 + GP_REG_FIRST },                                    \
4071   { "$4",        4 + GP_REG_FIRST },                                    \
4072   { "$5",        5 + GP_REG_FIRST },                                    \
4073   { "$6",        6 + GP_REG_FIRST },                                    \
4074   { "$7",        7 + GP_REG_FIRST },                                    \
4075   { "$8",        8 + GP_REG_FIRST },                                    \
4076   { "$9",        9 + GP_REG_FIRST },                                    \
4077   { "$10",      10 + GP_REG_FIRST },                                    \
4078   { "$11",      11 + GP_REG_FIRST },                                    \
4079   { "$12",      12 + GP_REG_FIRST },                                    \
4080   { "$13",      13 + GP_REG_FIRST },                                    \
4081   { "$14",      14 + GP_REG_FIRST },                                    \
4082   { "$15",      15 + GP_REG_FIRST },                                    \
4083   { "$16",      16 + GP_REG_FIRST },                                    \
4084   { "$17",      17 + GP_REG_FIRST },                                    \
4085   { "$18",      18 + GP_REG_FIRST },                                    \
4086   { "$19",      19 + GP_REG_FIRST },                                    \
4087   { "$20",      20 + GP_REG_FIRST },                                    \
4088   { "$21",      21 + GP_REG_FIRST },                                    \
4089   { "$22",      22 + GP_REG_FIRST },                                    \
4090   { "$23",      23 + GP_REG_FIRST },                                    \
4091   { "$24",      24 + GP_REG_FIRST },                                    \
4092   { "$25",      25 + GP_REG_FIRST },                                    \
4093   { "$26",      26 + GP_REG_FIRST },                                    \
4094   { "$27",      27 + GP_REG_FIRST },                                    \
4095   { "$28",      28 + GP_REG_FIRST },                                    \
4096   { "$29",      29 + GP_REG_FIRST },                                    \
4097   { "$30",      30 + GP_REG_FIRST },                                    \
4098   { "$31",      31 + GP_REG_FIRST },                                    \
4099   { "$sp",      29 + GP_REG_FIRST },                                    \
4100   { "$fp",      30 + GP_REG_FIRST },                                    \
4101   { "at",        1 + GP_REG_FIRST },                                    \
4102   { "v0",        2 + GP_REG_FIRST },                                    \
4103   { "v1",        3 + GP_REG_FIRST },                                    \
4104   { "a0",        4 + GP_REG_FIRST },                                    \
4105   { "a1",        5 + GP_REG_FIRST },                                    \
4106   { "a2",        6 + GP_REG_FIRST },                                    \
4107   { "a3",        7 + GP_REG_FIRST },                                    \
4108   { "t0",        8 + GP_REG_FIRST },                                    \
4109   { "t1",        9 + GP_REG_FIRST },                                    \
4110   { "t2",       10 + GP_REG_FIRST },                                    \
4111   { "t3",       11 + GP_REG_FIRST },                                    \
4112   { "t4",       12 + GP_REG_FIRST },                                    \
4113   { "t5",       13 + GP_REG_FIRST },                                    \
4114   { "t6",       14 + GP_REG_FIRST },                                    \
4115   { "t7",       15 + GP_REG_FIRST },                                    \
4116   { "s0",       16 + GP_REG_FIRST },                                    \
4117   { "s1",       17 + GP_REG_FIRST },                                    \
4118   { "s2",       18 + GP_REG_FIRST },                                    \
4119   { "s3",       19 + GP_REG_FIRST },                                    \
4120   { "s4",       20 + GP_REG_FIRST },                                    \
4121   { "s5",       21 + GP_REG_FIRST },                                    \
4122   { "s6",       22 + GP_REG_FIRST },                                    \
4123   { "s7",       23 + GP_REG_FIRST },                                    \
4124   { "t8",       24 + GP_REG_FIRST },                                    \
4125   { "t9",       25 + GP_REG_FIRST },                                    \
4126   { "k0",       26 + GP_REG_FIRST },                                    \
4127   { "k1",       27 + GP_REG_FIRST },                                    \
4128   { "gp",       28 + GP_REG_FIRST },                                    \
4129   { "sp",       29 + GP_REG_FIRST },                                    \
4130   { "fp",       30 + GP_REG_FIRST },                                    \
4131   { "ra",       31 + GP_REG_FIRST },                                    \
4132   { "$sp",      29 + GP_REG_FIRST },                                    \
4133   { "$fp",      30 + GP_REG_FIRST }                                     \
4134 }
4135
4136 /* A C compound statement to output to stdio stream STREAM the
4137    assembler syntax for an instruction operand X.  X is an RTL
4138    expression.
4139
4140    CODE is a value that can be used to specify one of several ways
4141    of printing the operand.  It is used when identical operands
4142    must be printed differently depending on the context.  CODE
4143    comes from the `%' specification that was used to request
4144    printing of the operand.  If the specification was just `%DIGIT'
4145    then CODE is 0; if the specification was `%LTR DIGIT' then CODE
4146    is the ASCII code for LTR.
4147
4148    If X is a register, this macro should print the register's name.
4149    The names can be found in an array `reg_names' whose type is
4150    `char *[]'.  `reg_names' is initialized from `REGISTER_NAMES'.
4151
4152    When the machine description has a specification `%PUNCT' (a `%'
4153    followed by a punctuation character), this macro is called with
4154    a null pointer for X and the punctuation character for CODE.
4155
4156    See mips.c for the MIPS specific codes.  */
4157
4158 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
4159
4160 /* A C expression which evaluates to true if CODE is a valid
4161    punctuation character for use in the `PRINT_OPERAND' macro.  If
4162    `PRINT_OPERAND_PUNCT_VALID_P' is not defined, it means that no
4163    punctuation characters (except for the standard one, `%') are
4164    used in this way.  */
4165
4166 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) mips_print_operand_punct[CODE]
4167
4168 /* A C compound statement to output to stdio stream STREAM the
4169    assembler syntax for an instruction operand that is a memory
4170    reference whose address is ADDR.  ADDR is an RTL expression.
4171
4172    On some machines, the syntax for a symbolic address depends on
4173    the section that the address refers to.  On these machines,
4174    define the macro `ENCODE_SECTION_INFO' to store the information
4175    into the `symbol_ref', and then check for it here.  */
4176
4177 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
4178
4179
4180 /* A C statement, to be executed after all slot-filler instructions
4181    have been output.  If necessary, call `dbr_sequence_length' to
4182    determine the number of slots filled in a sequence (zero if not
4183    currently outputting a sequence), to decide how many no-ops to
4184    output, or whatever.
4185
4186    Don't define this macro if it has nothing to do, but it is
4187    helpful in reading assembly output if the extent of the delay
4188    sequence is made explicit (e.g. with white space).
4189
4190    Note that output routines for instructions with delay slots must
4191    be prepared to deal with not being output as part of a sequence
4192    (i.e.  when the scheduling pass is not run, or when no slot
4193    fillers could be found.)  The variable `final_sequence' is null
4194    when not processing a sequence, otherwise it contains the
4195    `sequence' rtx being output.  */
4196
4197 #define DBR_OUTPUT_SEQEND(STREAM)                                       \
4198 do                                                                      \
4199   {                                                                     \
4200     if (set_nomacro > 0 && --set_nomacro == 0)                          \
4201       fputs ("\t.set\tmacro\n", STREAM);                                \
4202                                                                         \
4203     if (set_noreorder > 0 && --set_noreorder == 0)                      \
4204       fputs ("\t.set\treorder\n", STREAM);                              \
4205                                                                         \
4206     dslots_jump_filled++;                                               \
4207     fputs ("\n", STREAM);                                               \
4208   }                                                                     \
4209 while (0)
4210
4211
4212 /* How to tell the debugger about changes of source files.  Note, the
4213    mips ECOFF format cannot deal with changes of files inside of
4214    functions, which means the output of parser generators like bison
4215    is generally not debuggable without using the -l switch.  Lose,
4216    lose, lose.  Silicon graphics seems to want all .file's hardwired
4217    to 1.  */
4218
4219 #ifndef SET_FILE_NUMBER
4220 #define SET_FILE_NUMBER() ++num_source_filenames
4221 #endif
4222
4223 #define ASM_OUTPUT_SOURCE_FILENAME(STREAM, NAME)                        \
4224   mips_output_filename (STREAM, NAME)
4225
4226 /* This is defined so that it can be overridden in iris6.h.  */
4227 #define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
4228 do                                                              \
4229   {                                                             \
4230     fprintf (STREAM, "\t.file\t%d ", NUM_SOURCE_FILENAMES);     \
4231     output_quoted_string (STREAM, NAME);                        \
4232     fputs ("\n", STREAM);                                       \
4233   }                                                             \
4234 while (0)
4235
4236 /* This is how to output a note the debugger telling it the line number
4237    to which the following sequence of instructions corresponds.
4238    Silicon graphics puts a label after each .loc.  */
4239
4240 #ifndef LABEL_AFTER_LOC
4241 #define LABEL_AFTER_LOC(STREAM)
4242 #endif
4243
4244 #ifndef ASM_OUTPUT_SOURCE_LINE
4245 #define ASM_OUTPUT_SOURCE_LINE(STREAM, LINE)                            \
4246   mips_output_lineno (STREAM, LINE)
4247 #endif
4248
4249 /* The MIPS implementation uses some labels for its own purpose.  The
4250    following lists what labels are created, and are all formed by the
4251    pattern $L[a-z].*.  The machine independent portion of GCC creates
4252    labels matching:  $L[A-Z][0-9]+ and $L[0-9]+.
4253
4254         LM[0-9]+        Silicon Graphics/ECOFF stabs label before each stmt.
4255         $Lb[0-9]+       Begin blocks for MIPS debug support
4256         $Lc[0-9]+       Label for use in s<xx> operation.
4257         $Le[0-9]+       End blocks for MIPS debug support
4258         $Lp\..+         Half-pic labels.  */
4259
4260 /* This is how to output the definition of a user-level label named NAME,
4261    such as the label on a static function or variable NAME.
4262
4263    If we are optimizing the gp, remember that this label has been put
4264    out, so we know not to emit an .extern for it in mips_asm_file_end.
4265    We use one of the common bits in the IDENTIFIER tree node for this,
4266    since those bits seem to be unused, and we don't have any method
4267    of getting the decl nodes from the name.  */
4268
4269 #define ASM_OUTPUT_LABEL(STREAM,NAME)                                   \
4270 do {                                                                    \
4271   assemble_name (STREAM, NAME);                                         \
4272   fputs (":\n", STREAM);                                                \
4273 } while (0)
4274
4275
4276 /* A C statement (sans semicolon) to output to the stdio stream
4277    STREAM any text necessary for declaring the name NAME of an
4278    initialized variable which is being defined.  This macro must
4279    output the label definition (perhaps using `ASM_OUTPUT_LABEL').
4280    The argument DECL is the `VAR_DECL' tree node representing the
4281    variable.
4282
4283    If this macro is not defined, then the variable name is defined
4284    in the usual manner as a label (by means of `ASM_OUTPUT_LABEL').  */
4285
4286 #undef ASM_DECLARE_OBJECT_NAME
4287 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)                     \
4288 do                                                                      \
4289  {                                                                      \
4290    mips_declare_object (STREAM, NAME, "", ":\n", 0);                    \
4291    HALF_PIC_DECLARE (NAME);                                             \
4292  }                                                                      \
4293 while (0)
4294
4295
4296 /* This is how to output a command to make the user-level label named NAME
4297    defined for reference from other files.  */
4298
4299 #define ASM_GLOBALIZE_LABEL(STREAM,NAME)                                \
4300   do {                                                                  \
4301     fputs ("\t.globl\t", STREAM);                                       \
4302     assemble_name (STREAM, NAME);                                       \
4303     fputs ("\n", STREAM);                                               \
4304   } while (0)
4305
4306 /* This says how to define a global common symbol.  */
4307
4308 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGN) \
4309   do {                                                                  \
4310     /* If the target wants uninitialized const declarations in          \
4311        .rdata then don't put them in .comm */                           \
4312     if (TARGET_EMBEDDED_DATA && TARGET_UNINIT_CONST_IN_RODATA           \
4313         && TREE_CODE (DECL) == VAR_DECL && TREE_READONLY (DECL)         \
4314         && (DECL_INITIAL (DECL) == 0                                    \
4315             || DECL_INITIAL (DECL) == error_mark_node))                 \
4316       {                                                                 \
4317         if (TREE_PUBLIC (DECL) && DECL_NAME (DECL))                     \
4318           ASM_GLOBALIZE_LABEL (STREAM, NAME);                           \
4319                                                                         \
4320         READONLY_DATA_SECTION ();                                       \
4321         ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT));  \
4322         mips_declare_object (STREAM, NAME, "", ":\n\t.space\t%u\n",     \
4323             (SIZE));                                                    \
4324       }                                                                 \
4325     else                                                                \
4326       mips_declare_object (STREAM, NAME, "\n\t.comm\t", ",%u\n",        \
4327           (SIZE));                                                      \
4328   } while (0)
4329
4330
4331 /* This says how to define a local common symbol (ie, not visible to
4332    linker).  */
4333
4334 #define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)                   \
4335   mips_declare_object (STREAM, NAME, "\n\t.lcomm\t", ",%u\n", (SIZE))
4336
4337
4338 /* This says how to output an external.  It would be possible not to
4339    output anything and let undefined symbol become external. However
4340    the assembler uses length information on externals to allocate in
4341    data/sdata bss/sbss, thereby saving exec time.  */
4342
4343 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
4344   mips_output_external(STREAM,DECL,NAME)
4345
4346 /* This says what to print at the end of the assembly file */
4347 #undef ASM_FILE_END
4348 #define ASM_FILE_END(STREAM) mips_asm_file_end(STREAM)
4349
4350
4351 /* Play switch file games if we're optimizing the global pointer.  */
4352
4353 #undef TEXT_SECTION
4354 #define TEXT_SECTION()                                  \
4355 do {                                                    \
4356   extern FILE *asm_out_text_file;                       \
4357   if (TARGET_FILE_SWITCHING)                            \
4358     asm_out_file = asm_out_text_file;                   \
4359   fputs (TEXT_SECTION_ASM_OP, asm_out_file);            \
4360   fputc ('\n', asm_out_file);                           \
4361 } while (0)
4362
4363
4364 /* This is how to declare a function name.  The actual work of
4365    emitting the label is moved to function_prologue, so that we can
4366    get the line number correctly emitted before the .ent directive,
4367    and after any .file directives.  */
4368
4369 #undef ASM_DECLARE_FUNCTION_NAME
4370 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)     \
4371   HALF_PIC_DECLARE (NAME)
4372
4373 /* This is how to output an internal numbered label where
4374    PREFIX is the class of label and NUM is the number within the class.  */
4375
4376 #undef ASM_OUTPUT_INTERNAL_LABEL
4377 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM,PREFIX,NUM)                    \
4378   fprintf (STREAM, "%s%s%d:\n", LOCAL_LABEL_PREFIX, PREFIX, NUM)
4379
4380 /* This is how to store into the string LABEL
4381    the symbol_ref name of an internal numbered label where
4382    PREFIX is the class of label and NUM is the number within the class.
4383    This is suitable for output with `assemble_name'.  */
4384
4385 #undef ASM_GENERATE_INTERNAL_LABEL
4386 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)                   \
4387   sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long)(NUM))
4388
4389 /* This is how to output an element of a case-vector that is absolute.  */
4390
4391 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)                          \
4392   fprintf (STREAM, "\t%s\t%sL%d\n",                                     \
4393            Pmode == DImode ? ".dword" : ".word",                        \
4394            LOCAL_LABEL_PREFIX,                                          \
4395            VALUE)
4396
4397 /* This is how to output an element of a case-vector that is relative.
4398    This is used for pc-relative code (e.g. when TARGET_ABICALLS or
4399    TARGET_EMBEDDED_PIC).  */
4400
4401 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL)              \
4402 do {                                                                    \
4403   if (TARGET_MIPS16)                                                    \
4404     fprintf (STREAM, "\t.half\t%sL%d-%sL%d\n",                          \
4405              LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL);       \
4406   else if (TARGET_EMBEDDED_PIC)                                         \
4407     fprintf (STREAM, "\t%s\t%sL%d-%sLS%d\n",                            \
4408              Pmode == DImode ? ".dword" : ".word",                      \
4409              LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL);       \
4410   else if (mips_abi == ABI_32 || mips_abi == ABI_O64)                   \
4411     fprintf (STREAM, "\t%s\t%sL%d\n",                                   \
4412              Pmode == DImode ? ".gpdword" : ".gpword",                  \
4413              LOCAL_LABEL_PREFIX, VALUE);                                \
4414   else                                                                  \
4415     fprintf (STREAM, "\t%s\t%sL%d\n",                                   \
4416              Pmode == DImode ? ".dword" : ".word",                      \
4417              LOCAL_LABEL_PREFIX, VALUE);                                \
4418 } while (0)
4419
4420 /* When generating embedded PIC or mips16 code we want to put the jump
4421    table in the .text section.  In all other cases, we want to put the
4422    jump table in the .rdata section.  Unfortunately, we can't use
4423    JUMP_TABLES_IN_TEXT_SECTION, because it is not conditional.
4424    Instead, we use ASM_OUTPUT_CASE_LABEL to switch back to the .text
4425    section if appropriate.  */
4426 #undef ASM_OUTPUT_CASE_LABEL
4427 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, INSN)                  \
4428 do {                                                                    \
4429   if (TARGET_EMBEDDED_PIC || TARGET_MIPS16)                             \
4430     function_section (current_function_decl);                           \
4431   ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM);                        \
4432 } while (0)
4433
4434 /* This is how to output an assembler line
4435    that says to advance the location counter
4436    to a multiple of 2**LOG bytes.  */
4437
4438 #define ASM_OUTPUT_ALIGN(STREAM,LOG)                                    \
4439   fprintf (STREAM, "\t.align\t%d\n", (LOG))
4440
4441 /* This is how to output an assembler line to advance the location
4442    counter by SIZE bytes.  */
4443
4444 #undef ASM_OUTPUT_SKIP
4445 #define ASM_OUTPUT_SKIP(STREAM,SIZE)                                    \
4446   fprintf (STREAM, "\t.space\t%u\n", (SIZE))
4447
4448 /* This is how to output a string.  */
4449 #undef ASM_OUTPUT_ASCII
4450 #define ASM_OUTPUT_ASCII(STREAM, STRING, LEN)                           \
4451   mips_output_ascii (STREAM, STRING, LEN)
4452
4453 /* Handle certain cpp directives used in header files on sysV.  */
4454 #define SCCS_DIRECTIVE
4455
4456 /* Output #ident as a in the read-only data section.  */
4457 #undef  ASM_OUTPUT_IDENT
4458 #define ASM_OUTPUT_IDENT(FILE, STRING)                                  \
4459 {                                                                       \
4460   const char *p = STRING;                                               \
4461   int size = strlen (p) + 1;                                            \
4462   rdata_section ();                                                     \
4463   assemble_string (p, size);                                            \
4464 }
4465 \f
4466 /* Default to -G 8 */
4467 #ifndef MIPS_DEFAULT_GVALUE
4468 #define MIPS_DEFAULT_GVALUE 8
4469 #endif
4470
4471 /* Define the strings to put out for each section in the object file.  */
4472 #define TEXT_SECTION_ASM_OP     "\t.text"       /* instructions */
4473 #define DATA_SECTION_ASM_OP     "\t.data"       /* large data */
4474 #define SDATA_SECTION_ASM_OP    "\t.sdata"      /* small data */
4475 #define RDATA_SECTION_ASM_OP    "\t.rdata"      /* read-only data */
4476 #undef READONLY_DATA_SECTION
4477 #define READONLY_DATA_SECTION   rdata_section
4478 #define SMALL_DATA_SECTION      sdata_section
4479
4480 /* What other sections we support other than the normal .data/.text.  */
4481
4482 #undef EXTRA_SECTIONS
4483 #define EXTRA_SECTIONS in_sdata, in_rdata
4484
4485 /* Define the additional functions to select our additional sections.  */
4486
4487 /* on the MIPS it is not a good idea to put constants in the text
4488    section, since this defeats the sdata/data mechanism. This is
4489    especially true when -O is used. In this case an effort is made to
4490    address with faster (gp) register relative addressing, which can
4491    only get at sdata and sbss items (there is no stext !!)  However,
4492    if the constant is too large for sdata, and it's readonly, it
4493    will go into the .rdata section.  */
4494
4495 #undef EXTRA_SECTION_FUNCTIONS
4496 #define EXTRA_SECTION_FUNCTIONS                                         \
4497 void                                                                    \
4498 sdata_section ()                                                        \
4499 {                                                                       \
4500   if (in_section != in_sdata)                                           \
4501     {                                                                   \
4502       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
4503       in_section = in_sdata;                                            \
4504     }                                                                   \
4505 }                                                                       \
4506                                                                         \
4507 void                                                                    \
4508 rdata_section ()                                                        \
4509 {                                                                       \
4510   if (in_section != in_rdata)                                           \
4511     {                                                                   \
4512       fprintf (asm_out_file, "%s\n", RDATA_SECTION_ASM_OP);             \
4513       in_section = in_rdata;                                            \
4514     }                                                                   \
4515 }
4516
4517 /* Given a decl node or constant node, choose the section to output it in
4518    and select that section.  */
4519
4520 #undef SELECT_RTX_SECTION
4521 #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \
4522   mips_select_rtx_section (MODE, RTX)
4523
4524 #undef SELECT_SECTION
4525 #define SELECT_SECTION(DECL, RELOC, ALIGN) \
4526   mips_select_section (DECL, RELOC)
4527
4528 \f
4529 /* Store in OUTPUT a string (made with alloca) containing
4530    an assembler-name for a local static variable named NAME.
4531    LABELNO is an integer which is different for each call.  */
4532
4533 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)                  \
4534 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),                    \
4535   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
4536
4537 #define ASM_OUTPUT_REG_PUSH(STREAM,REGNO)                               \
4538 do                                                                      \
4539   {                                                                     \
4540     fprintf (STREAM, "\t%s\t%s,%s,8\n\t%s\t%s,0(%s)\n",                 \
4541              TARGET_64BIT ? "dsubu" : "subu",                           \
4542              reg_names[STACK_POINTER_REGNUM],                           \
4543              reg_names[STACK_POINTER_REGNUM],                           \
4544              TARGET_64BIT ? "sd" : "sw",                                \
4545              reg_names[REGNO],                                          \
4546              reg_names[STACK_POINTER_REGNUM]);                          \
4547   }                                                                     \
4548 while (0)
4549
4550 #define ASM_OUTPUT_REG_POP(STREAM,REGNO)                                \
4551 do                                                                      \
4552   {                                                                     \
4553     if (! set_noreorder)                                                \
4554       fprintf (STREAM, "\t.set\tnoreorder\n");                          \
4555                                                                         \
4556     dslots_load_total++;                                                \
4557     dslots_load_filled++;                                               \
4558     fprintf (STREAM, "\t%s\t%s,0(%s)\n\t%s\t%s,%s,8\n",                 \
4559              TARGET_64BIT ? "ld" : "lw",                                \
4560              reg_names[REGNO],                                          \
4561              reg_names[STACK_POINTER_REGNUM],                           \
4562              TARGET_64BIT ? "daddu" : "addu",                           \
4563              reg_names[STACK_POINTER_REGNUM],                           \
4564              reg_names[STACK_POINTER_REGNUM]);                          \
4565                                                                         \
4566     if (! set_noreorder)                                                \
4567       fprintf (STREAM, "\t.set\treorder\n");                            \
4568   }                                                                     \
4569 while (0)
4570
4571 /* How to start an assembler comment.
4572    The leading space is important (the mips native assembler requires it).  */
4573 #ifndef ASM_COMMENT_START
4574 #define ASM_COMMENT_START " #"
4575 #endif
4576 \f
4577
4578 /* Macros for mips-tfile.c to encapsulate stabs in ECOFF, and for
4579    and mips-tdump.c to print them out.
4580
4581    These must match the corresponding definitions in gdb/mipsread.c.
4582    Unfortunately, gcc and gdb do not currently share any directories.  */
4583
4584 #define CODE_MASK 0x8F300
4585 #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
4586 #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
4587 #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
4588
4589 \f
4590 /* Default definitions for size_t and ptrdiff_t.  */
4591
4592 #ifndef SIZE_TYPE
4593 #define NO_BUILTIN_SIZE_TYPE
4594 #define SIZE_TYPE (Pmode == DImode ? "long unsigned int" : "unsigned int")
4595 #endif
4596
4597 #ifndef PTRDIFF_TYPE
4598 #define NO_BUILTIN_PTRDIFF_TYPE
4599 #define PTRDIFF_TYPE (Pmode == DImode ? "long int" : "int")
4600 #endif
4601
4602 /* See mips_expand_prologue's use of loadgp for when this should be
4603    true.  */
4604
4605 #define DONT_ACCESS_GBLS_AFTER_EPILOGUE (TARGET_ABICALLS                \
4606                                          && mips_abi != ABI_32          \
4607                                          && mips_abi != ABI_O64)
4608 \f
4609 /* In mips16 mode, we need to look through the function to check for
4610    PC relative loads that are out of range.  */
4611 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg (X)
4612
4613 /* We need to use a special set of functions to handle hard floating
4614    point code in mips16 mode.  */
4615
4616 #ifndef INIT_SUBTARGET_OPTABS
4617 #define INIT_SUBTARGET_OPTABS
4618 #endif
4619
4620 #define INIT_TARGET_OPTABS                                              \
4621 do                                                                      \
4622   {                                                                     \
4623     if (! TARGET_MIPS16 || ! mips16_hard_float)                         \
4624       INIT_SUBTARGET_OPTABS;                                            \
4625     else                                                                \
4626       {                                                                 \
4627         add_optab->handlers[(int) SFmode].libfunc =                     \
4628           init_one_libfunc ("__mips16_addsf3");                         \
4629         sub_optab->handlers[(int) SFmode].libfunc =                     \
4630           init_one_libfunc ("__mips16_subsf3");                         \
4631         smul_optab->handlers[(int) SFmode].libfunc =                    \
4632           init_one_libfunc ("__mips16_mulsf3");                         \
4633         sdiv_optab->handlers[(int) SFmode].libfunc =                    \
4634           init_one_libfunc ("__mips16_divsf3");                         \
4635                                                                         \
4636         eqsf2_libfunc = init_one_libfunc ("__mips16_eqsf2");            \
4637         nesf2_libfunc = init_one_libfunc ("__mips16_nesf2");            \
4638         gtsf2_libfunc = init_one_libfunc ("__mips16_gtsf2");            \
4639         gesf2_libfunc = init_one_libfunc ("__mips16_gesf2");            \
4640         ltsf2_libfunc = init_one_libfunc ("__mips16_ltsf2");            \
4641         lesf2_libfunc = init_one_libfunc ("__mips16_lesf2");            \
4642                                                                         \
4643         floatsisf_libfunc =                                             \
4644           init_one_libfunc ("__mips16_floatsisf");                      \
4645         fixsfsi_libfunc =                                               \
4646           init_one_libfunc ("__mips16_fixsfsi");                        \
4647                                                                         \
4648         if (TARGET_DOUBLE_FLOAT)                                        \
4649           {                                                             \
4650             add_optab->handlers[(int) DFmode].libfunc =                 \
4651               init_one_libfunc ("__mips16_adddf3");                     \
4652             sub_optab->handlers[(int) DFmode].libfunc =                 \
4653               init_one_libfunc ("__mips16_subdf3");                     \
4654             smul_optab->handlers[(int) DFmode].libfunc =                \
4655               init_one_libfunc ("__mips16_muldf3");                     \
4656             sdiv_optab->handlers[(int) DFmode].libfunc =                \
4657               init_one_libfunc ("__mips16_divdf3");                     \
4658                                                                         \
4659             extendsfdf2_libfunc =                                       \
4660               init_one_libfunc ("__mips16_extendsfdf2");                \
4661             truncdfsf2_libfunc =                                        \
4662               init_one_libfunc ("__mips16_truncdfsf2");                 \
4663                                                                         \
4664             eqdf2_libfunc =                                             \
4665               init_one_libfunc ("__mips16_eqdf2");                      \
4666             nedf2_libfunc =                                             \
4667               init_one_libfunc ("__mips16_nedf2");                      \
4668             gtdf2_libfunc =                                             \
4669               init_one_libfunc ("__mips16_gtdf2");                      \
4670             gedf2_libfunc =                                             \
4671               init_one_libfunc ("__mips16_gedf2");                      \
4672             ltdf2_libfunc =                                             \
4673               init_one_libfunc ("__mips16_ltdf2");                      \
4674             ledf2_libfunc =                                             \
4675               init_one_libfunc ("__mips16_ledf2");                      \
4676                                                                         \
4677             floatsidf_libfunc =                                         \
4678               init_one_libfunc ("__mips16_floatsidf");                  \
4679             fixdfsi_libfunc =                                           \
4680               init_one_libfunc ("__mips16_fixdfsi");                    \
4681           }                                                             \
4682       }                                                                 \
4683   }                                                                     \
4684 while (0)