OSDN Git Service

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