OSDN Git Service

2002-06-19 Eric Christopher <echristo@redhat.com>
[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,msub,nmadd, and nmsub
755    instructions, 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   ((((N) >= GP_ARG_FIRST && (N) <= GP_ARG_LAST)                 \
2577     || ((N) >= FP_ARG_FIRST && (N) <= FP_ARG_LAST               \
2578         && (((N) % FP_INC) == 0                                 \
2579             && (! mips_abi == ABI_O64)))                        \
2580    && !fixed_regs[N]))
2581
2582 /* A C expression which can inhibit the returning of certain function
2583    values in registers, based on the type of value.  A nonzero value says
2584    to return the function value in memory, just as large structures are
2585    always returned.  Here TYPE will be a C expression of type
2586    `tree', representing the data type of the value.
2587
2588    Note that values of mode `BLKmode' must be explicitly
2589    handled by this macro.  Also, the option `-fpcc-struct-return'
2590    takes effect regardless of this macro.  On most systems, it is
2591    possible to leave the macro undefined; this causes a default
2592    definition to be used, whose value is the constant 1 for BLKmode
2593    values, and 0 otherwise.
2594
2595    GCC normally converts 1 byte structures into chars, 2 byte
2596    structs into shorts, and 4 byte structs into ints, and returns
2597    them this way.  Defining the following macro overrides this,
2598    to give us MIPS cc compatibility.  */
2599
2600 #define RETURN_IN_MEMORY(TYPE)  \
2601         mips_return_in_memory (TYPE)
2602
2603 #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)       \
2604         (PRETEND_SIZE) = mips_setup_incoming_varargs (&(CUM), (MODE),   \
2605                                                       (TYPE), (NO_RTL))
2606 \f
2607
2608 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
2609
2610 \f
2611 /* Define a data type for recording info about an argument list
2612    during the scan of that argument list.  This data type should
2613    hold all necessary information about the function itself
2614    and about the args processed so far, enough to enable macros
2615    such as FUNCTION_ARG to determine where the next arg should go.
2616
2617    This structure has to cope with two different argument allocation
2618    schemes.  Most MIPS ABIs view the arguments as a struct, of which the
2619    first N words go in registers and the rest go on the stack.  If I < N,
2620    the Ith word might go in Ith integer argument register or the
2621    Ith floating-point one.  In some cases, it has to go in both (see
2622    function_arg).  For these ABIs, we only need to remember the number
2623    of words passed so far.
2624
2625    The EABI instead allocates the integer and floating-point arguments
2626    separately.  The first N words of FP arguments go in FP registers,
2627    the rest go on the stack.  Likewise, the first N words of the other
2628    arguments go in integer registers, and the rest go on the stack.  We
2629    need to maintain three counts: the number of integer registers used,
2630    the number of floating-point registers used, and the number of words
2631    passed on the stack.
2632
2633    We could keep separate information for the two ABIs (a word count for
2634    the standard ABIs, and three separate counts for the EABI).  But it
2635    seems simpler to view the standard ABIs as forms of EABI that do not
2636    allocate floating-point registers.
2637
2638    So for the standard ABIs, the first N words are allocated to integer
2639    registers, and function_arg decides on an argument-by-argument basis
2640    whether that argument should really go in an integer register, or in
2641    a floating-point one.  */
2642
2643 typedef struct mips_args {
2644   /* Always true for varargs functions.  Otherwise true if at least
2645      one argument has been passed in an integer register.  */
2646   int gp_reg_found;
2647
2648   /* The number of arguments seen so far.  */
2649   unsigned int arg_number;
2650
2651   /* For EABI, the number of integer registers used so far.  For other
2652      ABIs, the number of words passed in registers (whether integer
2653      or floating-point).  */
2654   unsigned int num_gprs;
2655
2656   /* For EABI, the number of floating-point registers used so far.  */
2657   unsigned int num_fprs;
2658
2659   /* The number of words passed on the stack.  */
2660   unsigned int stack_words;
2661
2662   /* On the mips16, we need to keep track of which floating point
2663      arguments were passed in general registers, but would have been
2664      passed in the FP regs if this were a 32 bit function, so that we
2665      can move them to the FP regs if we wind up calling a 32 bit
2666      function.  We record this information in fp_code, encoded in base
2667      four.  A zero digit means no floating point argument, a one digit
2668      means an SFmode argument, and a two digit means a DFmode argument,
2669      and a three digit is not used.  The low order digit is the first
2670      argument.  Thus 6 == 1 * 4 + 2 means a DFmode argument followed by
2671      an SFmode argument.  ??? A more sophisticated approach will be
2672      needed if MIPS_ABI != ABI_32.  */
2673   int fp_code;
2674
2675   /* True if the function has a prototype.  */
2676   int prototype;
2677
2678   /* When a structure does not take up a full register, the argument
2679      should sometimes be shifted left so that it occupies the high part
2680      of the register.  These two fields describe an array of ashl
2681      patterns for doing this.  See function_arg_advance, which creates
2682      the shift patterns, and function_arg, which returns them when given
2683      a VOIDmode argument.  */
2684   unsigned int num_adjusts;
2685   rtx adjust[MAX_ARGS_IN_REGISTERS];
2686 } CUMULATIVE_ARGS;
2687
2688 /* Initialize a variable CUM of type CUMULATIVE_ARGS
2689    for a call to a function whose data type is FNTYPE.
2690    For a library call, FNTYPE is 0.
2691
2692 */
2693
2694 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT)               \
2695   init_cumulative_args (&CUM, FNTYPE, LIBNAME)                          \
2696
2697 /* Update the data in CUM to advance over an argument
2698    of mode MODE and data type TYPE.
2699    (TYPE is null for libcalls where that information may not be available.)  */
2700
2701 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                    \
2702   function_arg_advance (&CUM, MODE, TYPE, NAMED)
2703
2704 /* Determine where to put an argument to a function.
2705    Value is zero to push the argument on the stack,
2706    or a hard register in which to store the argument.
2707
2708    MODE is the argument's machine mode.
2709    TYPE is the data type of the argument (as a tree).
2710     This is null for libcalls where that information may
2711     not be available.
2712    CUM is a variable of type CUMULATIVE_ARGS which gives info about
2713     the preceding args and about the function being called.
2714    NAMED is nonzero if this argument is a named parameter
2715     (otherwise it is an extra parameter matching an ellipsis).  */
2716
2717 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
2718   function_arg( &CUM, MODE, TYPE, NAMED)
2719
2720 /* For an arg passed partly in registers and partly in memory,
2721    this is the number of registers used.
2722    For args passed entirely in registers or entirely in memory, zero.  */
2723
2724 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
2725   function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
2726
2727 /* If defined, a C expression that gives the alignment boundary, in
2728    bits, of an argument with the specified mode and type.  If it is
2729    not defined,  `PARM_BOUNDARY' is used for all arguments.  */
2730
2731 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE)                               \
2732   (((TYPE) != 0)                                                        \
2733         ? ((TYPE_ALIGN(TYPE) <= PARM_BOUNDARY)                          \
2734                 ? PARM_BOUNDARY                                         \
2735                 : TYPE_ALIGN(TYPE))                                     \
2736         : ((GET_MODE_ALIGNMENT(MODE) <= PARM_BOUNDARY)                  \
2737                 ? PARM_BOUNDARY                                         \
2738                 : GET_MODE_ALIGNMENT(MODE)))
2739
2740 /* True if using EABI and varargs can be passed in floating-point
2741    registers.  Under these conditions, we need a more complex form
2742    of va_list, which tracks GPR, FPR and stack arguments separately.  */
2743 #define EABI_FLOAT_VARARGS_P \
2744         (mips_abi == ABI_EABI && UNITS_PER_FPVALUE >= UNITS_PER_DOUBLE)
2745
2746 \f
2747 /* Tell prologue and epilogue if register REGNO should be saved / restored.  */
2748
2749 #define MUST_SAVE_REGISTER(regno) \
2750  ((regs_ever_live[regno] && !call_used_regs[regno])                     \
2751   || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed)       \
2752   || (regno == (GP_REG_FIRST + 31) && regs_ever_live[GP_REG_FIRST + 31]))
2753
2754 /* ALIGN FRAMES on double word boundaries */
2755 #ifndef MIPS_STACK_ALIGN
2756 #define MIPS_STACK_ALIGN(LOC) (((LOC) + 7) & ~7)
2757 #endif
2758
2759 \f
2760 /* Define the `__builtin_va_list' type for the ABI.  */
2761 #define BUILD_VA_LIST_TYPE(VALIST) \
2762   (VALIST) = mips_build_va_list ()
2763
2764 /* Implement `va_start' for varargs and stdarg.  */
2765 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
2766   mips_va_start (stdarg, valist, nextarg)
2767
2768 /* Implement `va_arg'.  */
2769 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
2770   mips_va_arg (valist, type)
2771 \f
2772 /* Output assembler code to FILE to increment profiler label # LABELNO
2773    for profiling a function entry.  */
2774
2775 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
2776 {                                                                       \
2777   if (TARGET_MIPS16)                                                    \
2778     sorry ("mips16 function profiling");                                \
2779   fprintf (FILE, "\t.set\tnoat\n");                                     \
2780   fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n",    \
2781            reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]);  \
2782   fprintf (FILE,                                                        \
2783            "\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from  stack\n",    \
2784            TARGET_64BIT ? "dsubu" : "subu",                             \
2785            reg_names[STACK_POINTER_REGNUM],                             \
2786            reg_names[STACK_POINTER_REGNUM],                             \
2787            Pmode == DImode ? 16 : 8);                                   \
2788   fprintf (FILE, "\tjal\t_mcount\n");                                   \
2789   fprintf (FILE, "\t.set\tat\n");                                       \
2790 }
2791
2792 /* Define this macro if the code for function profiling should come
2793    before the function prologue.  Normally, the profiling code comes
2794    after.  */
2795
2796 /* #define PROFILE_BEFORE_PROLOGUE */
2797
2798 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
2799    the stack pointer does not matter.  The value is tested only in
2800    functions that have frame pointers.
2801    No definition is equivalent to always zero.  */
2802
2803 #define EXIT_IGNORE_STACK 1
2804
2805 \f
2806 /* A C statement to output, on the stream FILE, assembler code for a
2807    block of data that contains the constant parts of a trampoline.
2808    This code should not include a label--the label is taken care of
2809    automatically.  */
2810
2811 #define TRAMPOLINE_TEMPLATE(STREAM)                                      \
2812 {                                                                        \
2813   fprintf (STREAM, "\t.word\t0x03e00821\t\t# move   $1,$31\n");         \
2814   fprintf (STREAM, "\t.word\t0x04110001\t\t# bgezal $0,.+8\n");         \
2815   fprintf (STREAM, "\t.word\t0x00000000\t\t# nop\n");                   \
2816   if (Pmode == DImode)                                                  \
2817     {                                                                   \
2818       fprintf (STREAM, "\t.word\t0xdfe30014\t\t# ld     $3,20($31)\n"); \
2819       fprintf (STREAM, "\t.word\t0xdfe2001c\t\t# ld     $2,28($31)\n"); \
2820     }                                                                   \
2821   else                                                                  \
2822     {                                                                   \
2823       fprintf (STREAM, "\t.word\t0x8fe30014\t\t# lw     $3,20($31)\n"); \
2824       fprintf (STREAM, "\t.word\t0x8fe20018\t\t# lw     $2,24($31)\n"); \
2825     }                                                                   \
2826   fprintf (STREAM, "\t.word\t0x0060c821\t\t# move   $25,$3 (abicalls)\n"); \
2827   fprintf (STREAM, "\t.word\t0x00600008\t\t# jr     $3\n");             \
2828   fprintf (STREAM, "\t.word\t0x0020f821\t\t# move   $31,$1\n");         \
2829   if (Pmode == DImode)                                                  \
2830     {                                                                   \
2831       fprintf (STREAM, "\t.dword\t0x00000000\t\t# <function address>\n"); \
2832       fprintf (STREAM, "\t.dword\t0x00000000\t\t# <static chain value>\n"); \
2833     }                                                                   \
2834   else                                                                  \
2835     {                                                                   \
2836       fprintf (STREAM, "\t.word\t0x00000000\t\t# <function address>\n"); \
2837       fprintf (STREAM, "\t.word\t0x00000000\t\t# <static chain value>\n"); \
2838     }                                                                   \
2839 }
2840
2841 /* A C expression for the size in bytes of the trampoline, as an
2842    integer.  */
2843
2844 #define TRAMPOLINE_SIZE (32 + (Pmode == DImode ? 16 : 8))
2845
2846 /* Alignment required for trampolines, in bits.  */
2847
2848 #define TRAMPOLINE_ALIGNMENT (Pmode == DImode ? 64 : 32)
2849
2850 /* INITIALIZE_TRAMPOLINE calls this library function to flush
2851    program and data caches.  */
2852
2853 #ifndef CACHE_FLUSH_FUNC
2854 #define CACHE_FLUSH_FUNC "_flush_cache"
2855 #endif
2856
2857 /* A C statement to initialize the variable parts of a trampoline.
2858    ADDR is an RTX for the address of the trampoline; FNADDR is an
2859    RTX for the address of the nested function; STATIC_CHAIN is an
2860    RTX for the static chain value that should be passed to the
2861    function when it is called.  */
2862
2863 #define INITIALIZE_TRAMPOLINE(ADDR, FUNC, CHAIN)                            \
2864 {                                                                           \
2865   rtx addr = ADDR;                                                          \
2866   if (Pmode == DImode)                                                      \
2867     {                                                                       \
2868       emit_move_insn (gen_rtx_MEM (DImode, plus_constant (addr, 32)), FUNC); \
2869       emit_move_insn (gen_rtx_MEM (DImode, plus_constant (addr, 40)), CHAIN);\
2870     }                                                                       \
2871   else                                                                      \
2872     {                                                                       \
2873       emit_move_insn (gen_rtx_MEM (SImode, plus_constant (addr, 32)), FUNC); \
2874       emit_move_insn (gen_rtx_MEM (SImode, plus_constant (addr, 36)), CHAIN);\
2875     }                                                                       \
2876                                                                             \
2877   /* Flush both caches.  We need to flush the data cache in case            \
2878      the system has a write-back cache.  */                                 \
2879   /* ??? Should check the return value for errors.  */                      \
2880   if (mips_cache_flush_func && mips_cache_flush_func[0])                    \
2881     emit_library_call (gen_rtx_SYMBOL_REF (Pmode, mips_cache_flush_func),   \
2882                        0, VOIDmode, 3, addr, Pmode,                         \
2883                        GEN_INT (TRAMPOLINE_SIZE), TYPE_MODE (integer_type_node),\
2884                        GEN_INT (3), TYPE_MODE (integer_type_node));         \
2885 }
2886 \f
2887 /* Addressing modes, and classification of registers for them.  */
2888
2889 /* #define HAVE_POST_INCREMENT 0 */
2890 /* #define HAVE_POST_DECREMENT 0 */
2891
2892 /* #define HAVE_PRE_DECREMENT 0 */
2893 /* #define HAVE_PRE_INCREMENT 0 */
2894
2895 /* These assume that REGNO is a hard or pseudo reg number.
2896    They give nonzero only if REGNO is a hard reg of the suitable class
2897    or a pseudo reg currently allocated to a suitable hard reg.
2898    These definitions are NOT overridden anywhere.  */
2899
2900 #define BASE_REG_P(regno, mode)                                 \
2901   (TARGET_MIPS16                                                \
2902    ? (M16_REG_P (regno)                                         \
2903       || (regno) == FRAME_POINTER_REGNUM                        \
2904       || (regno) == ARG_POINTER_REGNUM                          \
2905       || ((regno) == STACK_POINTER_REGNUM                       \
2906           && (GET_MODE_SIZE (mode) == 4                         \
2907               || GET_MODE_SIZE (mode) == 8)))                   \
2908    : GP_REG_P (regno))
2909
2910 #define GP_REG_OR_PSEUDO_STRICT_P(regno, mode)                              \
2911   BASE_REG_P((regno < FIRST_PSEUDO_REGISTER) ? (int) regno : reg_renumber[regno], \
2912              (mode))
2913
2914 #define GP_REG_OR_PSEUDO_NONSTRICT_P(regno, mode) \
2915   (((regno) >= FIRST_PSEUDO_REGISTER) || (BASE_REG_P ((regno), (mode))))
2916
2917 #define REGNO_OK_FOR_INDEX_P(regno)     0
2918 #define REGNO_MODE_OK_FOR_BASE_P(regno, mode) \
2919   GP_REG_OR_PSEUDO_STRICT_P ((regno), (mode))
2920
2921 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2922    and check its validity for a certain class.
2923    We have two alternate definitions for each of them.
2924    The usual definition accepts all pseudo regs; the other rejects them all.
2925    The symbol REG_OK_STRICT causes the latter definition to be used.
2926
2927    Most source files want to accept pseudo regs in the hope that
2928    they will get allocated to the class that the insn wants them to be in.
2929    Some source files that are used after register allocation
2930    need to be strict.  */
2931
2932 #ifndef REG_OK_STRICT
2933 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
2934   mips_reg_mode_ok_for_base_p (X, MODE, 0)
2935 #else
2936 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
2937   mips_reg_mode_ok_for_base_p (X, MODE, 1)
2938 #endif
2939
2940 #define REG_OK_FOR_INDEX_P(X) 0
2941
2942 \f
2943 /* Maximum number of registers that can appear in a valid memory address.  */
2944
2945 #define MAX_REGS_PER_ADDRESS 1
2946
2947 /* A C compound statement with a conditional `goto LABEL;' executed
2948    if X (an RTX) is a legitimate memory address on the target
2949    machine for a memory operand of mode MODE.  */
2950
2951 #if 1
2952 #define GO_PRINTF(x)    fprintf(stderr, (x))
2953 #define GO_PRINTF2(x,y) fprintf(stderr, (x), (y))
2954 #define GO_DEBUG_RTX(x) debug_rtx(x)
2955
2956 #else
2957 #define GO_PRINTF(x)
2958 #define GO_PRINTF2(x,y)
2959 #define GO_DEBUG_RTX(x)
2960 #endif
2961
2962 #ifdef REG_OK_STRICT
2963 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
2964 {                                               \
2965   if (mips_legitimate_address_p (MODE, X, 1))   \
2966     goto ADDR;                                  \
2967 }
2968 #else
2969 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
2970 {                                               \
2971   if (mips_legitimate_address_p (MODE, X, 0))   \
2972     goto ADDR;                                  \
2973 }
2974 #endif
2975
2976 /* A C expression that is 1 if the RTX X is a constant which is a
2977    valid address.  This is defined to be the same as `CONSTANT_P (X)',
2978    but rejecting CONST_DOUBLE.  */
2979 /* When pic, we must reject addresses of the form symbol+large int.
2980    This is because an instruction `sw $4,s+70000' needs to be converted
2981    by the assembler to `lw $at,s($gp);sw $4,70000($at)'.  Normally the
2982    assembler would use $at as a temp to load in the large offset.  In this
2983    case $at is already in use.  We convert such problem addresses to
2984    `la $5,s;sw $4,70000($5)' via LEGITIMIZE_ADDRESS.  */
2985 /* ??? SGI Irix 6 assembler fails for CONST address, so reject them
2986    when !TARGET_GAS.  */
2987 /* We should be rejecting everything but const addresses.  */
2988 #define CONSTANT_ADDRESS_P(X)                                           \
2989   (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF              \
2990     || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH                \
2991     || (GET_CODE (X) == CONST                                           \
2992         && ! (flag_pic && pic_address_needs_scratch (X))                \
2993         && (!TARGET_GAS)                                                \
2994         && (mips_abi == ABI_N32                                         \
2995             || mips_abi == ABI_64)))
2996
2997 /* Define this, so that when PIC, reload won't try to reload invalid
2998    addresses which require two reload registers.  */
2999
3000 #define LEGITIMATE_PIC_OPERAND_P(X)  (! pic_address_needs_scratch (X))
3001
3002 /* Nonzero if the constant value X is a legitimate general operand.
3003    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
3004
3005    At present, GAS doesn't understand li.[sd], so don't allow it
3006    to be generated at present.  Also, the MIPS assembler does not
3007    grok li.d Infinity.  */
3008
3009 /* ??? SGI Irix 6 assembler fails for CONST address, so reject them.
3010    Note that the Irix 6 assembler problem may already be fixed.
3011    Note also that the GET_CODE (X) == CONST test catches the mips16
3012    gp pseudo reg (see mips16_gp_pseudo_reg) deciding it is not
3013    a LEGITIMATE_CONSTANT.  If we ever want mips16 and ABI_N32 or
3014    ABI_64 to work together, we'll need to fix this.  */
3015 #define LEGITIMATE_CONSTANT_P(X)                                        \
3016   ((GET_CODE (X) != CONST_DOUBLE                                        \
3017     || mips_const_double_ok (X, GET_MODE (X)))                          \
3018    && ! (GET_CODE (X) == CONST                                          \
3019          && ! TARGET_GAS                                                \
3020          && (mips_abi == ABI_N32                                        \
3021              || mips_abi == ABI_64))                                    \
3022    && (! TARGET_MIPS16 || mips16_constant (X, GET_MODE (X), 0, 0)))
3023
3024 /* A C compound statement that attempts to replace X with a valid
3025    memory address for an operand of mode MODE.  WIN will be a C
3026    statement label elsewhere in the code; the macro definition may
3027    use
3028
3029           GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN);
3030
3031    to avoid further processing if the address has become legitimate.
3032
3033    X will always be the result of a call to `break_out_memory_refs',
3034    and OLDX will be the operand that was given to that function to
3035    produce X.
3036
3037    The code generated by this macro should not alter the
3038    substructure of X.  If it transforms X into a more legitimate
3039    form, it should assign X (which will always be a C variable) a
3040    new value.
3041
3042    It is not necessary for this macro to come up with a legitimate
3043    address.  The compiler has standard ways of doing so in all
3044    cases.  In fact, it is safe for this macro to do nothing.  But
3045    often a machine-dependent strategy can generate better code.
3046
3047    For the MIPS, transform:
3048
3049         memory(X + <large int>)
3050
3051    into:
3052
3053         Y = <large int> & ~0x7fff;
3054         Z = X + Y
3055         memory (Z + (<large int> & 0x7fff));
3056
3057    This is for CSE to find several similar references, and only use one Z.
3058
3059    When PIC, convert addresses of the form memory (symbol+large int) to
3060    memory (reg+large int).  */
3061
3062
3063 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                             \
3064 {                                                                       \
3065   register rtx xinsn = (X);                                             \
3066                                                                         \
3067   if (TARGET_DEBUG_B_MODE)                                              \
3068     {                                                                   \
3069       GO_PRINTF ("\n========== LEGITIMIZE_ADDRESS\n");                  \
3070       GO_DEBUG_RTX (xinsn);                                             \
3071     }                                                                   \
3072                                                                         \
3073   if (mips_split_addresses && mips_check_split (X, MODE))               \
3074     {                                                                   \
3075       /* ??? Is this ever executed?  */                                 \
3076       X = gen_rtx_LO_SUM (Pmode,                                        \
3077                           copy_to_mode_reg (Pmode,                      \
3078                                             gen_rtx (HIGH, Pmode, X)),  \
3079                           X);                                           \
3080       goto WIN;                                                         \
3081     }                                                                   \
3082                                                                         \
3083   if (GET_CODE (xinsn) == CONST                                         \
3084       && ((flag_pic && pic_address_needs_scratch (xinsn))               \
3085           /* ??? SGI's Irix 6 assembler can't handle CONST.  */         \
3086           || (!TARGET_GAS                                               \
3087               && (mips_abi == ABI_N32                                   \
3088                   || mips_abi == ABI_64))))                             \
3089     {                                                                   \
3090       rtx ptr_reg = gen_reg_rtx (Pmode);                                \
3091       rtx constant = XEXP (XEXP (xinsn, 0), 1);                         \
3092                                                                         \
3093       emit_move_insn (ptr_reg, XEXP (XEXP (xinsn, 0), 0));              \
3094                                                                         \
3095       X = gen_rtx_PLUS (Pmode, ptr_reg, constant);                      \
3096       if (SMALL_INT (constant))                                         \
3097         goto WIN;                                                       \
3098       /* Otherwise we fall through so the code below will fix the       \
3099          constant.  */                                                  \
3100       xinsn = X;                                                        \
3101     }                                                                   \
3102                                                                         \
3103   if (GET_CODE (xinsn) == PLUS)                                         \
3104     {                                                                   \
3105       register rtx xplus0 = XEXP (xinsn, 0);                            \
3106       register rtx xplus1 = XEXP (xinsn, 1);                            \
3107       register enum rtx_code code0 = GET_CODE (xplus0);                 \
3108       register enum rtx_code code1 = GET_CODE (xplus1);                 \
3109                                                                         \
3110       if (code0 != REG && code1 == REG)                                 \
3111         {                                                               \
3112           xplus0 = XEXP (xinsn, 1);                                     \
3113           xplus1 = XEXP (xinsn, 0);                                     \
3114           code0 = GET_CODE (xplus0);                                    \
3115           code1 = GET_CODE (xplus1);                                    \
3116         }                                                               \
3117                                                                         \
3118       if (code0 == REG && REG_MODE_OK_FOR_BASE_P (xplus0, MODE)         \
3119           && code1 == CONST_INT && !SMALL_INT (xplus1))                 \
3120         {                                                               \
3121           rtx int_reg = gen_reg_rtx (Pmode);                            \
3122           rtx ptr_reg = gen_reg_rtx (Pmode);                            \
3123                                                                         \
3124           emit_move_insn (int_reg,                                      \
3125                           GEN_INT (INTVAL (xplus1) & ~ 0x7fff));        \
3126                                                                         \
3127           emit_insn (gen_rtx_SET (VOIDmode,                             \
3128                                   ptr_reg,                              \
3129                                   gen_rtx_PLUS (Pmode, xplus0, int_reg))); \
3130                                                                         \
3131           X = plus_constant (ptr_reg, INTVAL (xplus1) & 0x7fff);        \
3132           goto WIN;                                                     \
3133         }                                                               \
3134     }                                                                   \
3135                                                                         \
3136   if (TARGET_DEBUG_B_MODE)                                              \
3137     GO_PRINTF ("LEGITIMIZE_ADDRESS could not fix.\n");                  \
3138 }
3139
3140
3141 /* A C statement or compound statement with a conditional `goto
3142    LABEL;' executed if memory address X (an RTX) can have different
3143    meanings depending on the machine mode of the memory reference it
3144    is used for.
3145
3146    Autoincrement and autodecrement addresses typically have
3147    mode-dependent effects because the amount of the increment or
3148    decrement is the size of the operand being addressed.  Some
3149    machines have other mode-dependent addresses.  Many RISC machines
3150    have no mode-dependent addresses.
3151
3152    You may assume that ADDR is a valid address for the machine.  */
3153
3154 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) {}
3155
3156 /* This handles the magic '..CURRENT_FUNCTION' symbol, which means
3157    'the start of the function that this code is output in'.  */
3158
3159 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
3160   if (strcmp (NAME, "..CURRENT_FUNCTION") == 0)                         \
3161     asm_fprintf ((FILE), "%U%s",                                        \
3162                  XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
3163   else                                                                  \
3164     asm_fprintf ((FILE), "%U%s", (NAME))
3165
3166 /* The mips16 wants the constant pool to be after the function,
3167    because the PC relative load instructions use unsigned offsets.  */
3168
3169 #define CONSTANT_POOL_BEFORE_FUNCTION (! TARGET_MIPS16)
3170
3171 #define ASM_OUTPUT_POOL_EPILOGUE(FILE, FNNAME, FNDECL, SIZE)    \
3172   mips_string_length = 0;
3173
3174 #if 0
3175 /* In mips16 mode, put most string constants after the function.  */
3176 #define CONSTANT_AFTER_FUNCTION_P(tree)                         \
3177   (TARGET_MIPS16 && mips16_constant_after_function_p (tree))
3178 #endif
3179 \f
3180 /* Specify the machine mode that this machine uses
3181    for the index in the tablejump instruction.
3182    ??? Using HImode in mips16 mode can cause overflow.  However, the
3183    overflow is no more likely than the overflow in a branch
3184    instruction.  Large functions can currently break in both ways.  */
3185 #define CASE_VECTOR_MODE \
3186   (TARGET_MIPS16 ? HImode : Pmode == DImode ? DImode : SImode)
3187
3188 /* Define as C expression which evaluates to nonzero if the tablejump
3189    instruction expects the table to contain offsets from the address of the
3190    table.
3191    Do not define this if the table should contain absolute addresses.  */
3192 #define CASE_VECTOR_PC_RELATIVE (TARGET_MIPS16)
3193
3194 /* Define this as 1 if `char' should by default be signed; else as 0.  */
3195 #ifndef DEFAULT_SIGNED_CHAR
3196 #define DEFAULT_SIGNED_CHAR 1
3197 #endif
3198
3199 /* Max number of bytes we can move from memory to memory
3200    in one reasonably fast instruction.  */
3201 #define MOVE_MAX (TARGET_64BIT ? 8 : 4)
3202 #define MAX_MOVE_MAX 8
3203
3204 /* Define this macro as a C expression which is nonzero if
3205    accessing less than a word of memory (i.e. a `char' or a
3206    `short') is no faster than accessing a word of memory, i.e., if
3207    such access require more than one instruction or if there is no
3208    difference in cost between byte and (aligned) word loads.
3209
3210    On RISC machines, it tends to generate better code to define
3211    this as 1, since it avoids making a QI or HI mode register.  */
3212 #define SLOW_BYTE_ACCESS 1
3213
3214 /* We assume that the store-condition-codes instructions store 0 for false
3215    and some other value for true.  This is the value stored for true.  */
3216
3217 #define STORE_FLAG_VALUE 1
3218
3219 /* Define this to be nonzero if shift instructions ignore all but the low-order
3220    few bits.  */
3221 #define SHIFT_COUNT_TRUNCATED 1
3222
3223 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
3224    is done just by pretending it is already truncated.  */
3225 /* In 64 bit mode, 32 bit instructions require that register values be properly
3226    sign-extended to 64 bits.  As a result, a truncate is not a no-op if it
3227    converts a value >32 bits to a value <32 bits.  */
3228 /* ??? This results in inefficient code for 64 bit to 32 conversions.
3229    Something needs to be done about this.  Perhaps not use any 32 bit
3230    instructions?  Perhaps use PROMOTE_MODE?  */
3231 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) \
3232   (TARGET_64BIT ? ((INPREC) <= 32 || (OUTPREC) > 32) : 1)
3233
3234 /* Specify the machine mode that pointers have.
3235    After generation of rtl, the compiler makes no further distinction
3236    between pointers and any other objects of this machine mode.
3237
3238    For MIPS we make pointers are the smaller of longs and gp-registers.  */
3239
3240 #ifndef Pmode
3241 #define Pmode ((TARGET_LONG64 && TARGET_64BIT) ? DImode : SImode)
3242 #endif
3243
3244 /* A function address in a call instruction
3245    is a word address (for indexing purposes)
3246    so give the MEM rtx a words's mode.  */
3247
3248 #define FUNCTION_MODE (Pmode == DImode ? DImode : SImode)
3249
3250 \f
3251 /* A part of a C `switch' statement that describes the relative
3252    costs of constant RTL expressions.  It must contain `case'
3253    labels for expression codes `const_int', `const', `symbol_ref',
3254    `label_ref' and `const_double'.  Each case must ultimately reach
3255    a `return' statement to return the relative cost of the use of
3256    that kind of constant value in an expression.  The cost may
3257    depend on the precise value of the constant, which is available
3258    for examination in X.
3259
3260    CODE is the expression code--redundant, since it can be obtained
3261    with `GET_CODE (X)'.  */
3262
3263 #define CONST_COSTS(X,CODE,OUTER_CODE)                                  \
3264   case CONST_INT:                                                       \
3265     if (! TARGET_MIPS16)                                                \
3266       {                                                                 \
3267         /* Always return 0, since we don't have different sized         \
3268            instructions, hence different costs according to Richard     \
3269            Kenner */                                                    \
3270         return 0;                                                       \
3271       }                                                                 \
3272     if ((OUTER_CODE) == SET)                                            \
3273       {                                                                 \
3274         if (INTVAL (X) >= 0 && INTVAL (X) < 0x100)                      \
3275           return 0;                                                     \
3276         else if ((INTVAL (X) >= 0 && INTVAL (X) < 0x10000)              \
3277                  || (INTVAL (X) < 0 && INTVAL (X) > -0x100))            \
3278           return COSTS_N_INSNS (1);                                     \
3279         else                                                            \
3280           return COSTS_N_INSNS (2);                                     \
3281       }                                                                 \
3282     /* A PLUS could be an address.  We don't want to force an address   \
3283        to use a register, so accept any signed 16 bit value without     \
3284        complaint.  */                                                   \
3285     if ((OUTER_CODE) == PLUS                                            \
3286         && INTVAL (X) >= -0x8000 && INTVAL (X) < 0x8000)                \
3287       return 0;                                                         \
3288     /* A number between 1 and 8 inclusive is efficient for a shift.     \
3289        Otherwise, we will need an extended instruction.  */             \
3290     if ((OUTER_CODE) == ASHIFT || (OUTER_CODE) == ASHIFTRT              \
3291         || (OUTER_CODE) == LSHIFTRT)                                    \
3292       {                                                                 \
3293         if (INTVAL (X) >= 1 && INTVAL (X) <= 8)                         \
3294           return 0;                                                     \
3295         return COSTS_N_INSNS (1);                                       \
3296       }                                                                 \
3297     /* We can use cmpi for an xor with an unsigned 16 bit value.  */    \
3298     if ((OUTER_CODE) == XOR                                             \
3299         && INTVAL (X) >= 0 && INTVAL (X) < 0x10000)                     \
3300       return 0;                                                         \
3301     /* We may be able to use slt or sltu for a comparison with a        \
3302        signed 16 bit value.  (The boundary conditions aren't quite      \
3303        right, but this is just a heuristic anyhow.)  */                 \
3304     if (((OUTER_CODE) == LT || (OUTER_CODE) == LE                       \
3305          || (OUTER_CODE) == GE || (OUTER_CODE) == GT                    \
3306          || (OUTER_CODE) == LTU || (OUTER_CODE) == LEU                  \
3307          || (OUTER_CODE) == GEU || (OUTER_CODE) == GTU)                 \
3308         && INTVAL (X) >= -0x8000 && INTVAL (X) < 0x8000)                \
3309       return 0;                                                         \
3310     /* Equality comparisons with 0 are cheap.  */                       \
3311     if (((OUTER_CODE) == EQ || (OUTER_CODE) == NE)                      \
3312         && INTVAL (X) == 0)                                             \
3313       return 0;                                                         \
3314                                                                         \
3315     /* Otherwise, work out the cost to load the value into a            \
3316        register.  */                                                    \
3317     if (INTVAL (X) >= 0 && INTVAL (X) < 0x100)                          \
3318       return COSTS_N_INSNS (1);                                         \
3319     else if ((INTVAL (X) >= 0 && INTVAL (X) < 0x10000)                  \
3320              || (INTVAL (X) < 0 && INTVAL (X) > -0x100))                \
3321       return COSTS_N_INSNS (2);                                         \
3322     else                                                                \
3323       return COSTS_N_INSNS (3);                                         \
3324                                                                         \
3325   case LABEL_REF:                                                       \
3326     return COSTS_N_INSNS (2);                                           \
3327                                                                         \
3328   case CONST:                                                           \
3329     {                                                                   \
3330       rtx offset = const0_rtx;                                          \
3331       rtx symref = eliminate_constant_term (XEXP (X, 0), &offset);      \
3332                                                                         \
3333       if (TARGET_MIPS16 && mips16_gp_offset_p (X))                      \
3334         {                                                               \
3335           /* Treat this like a signed 16 bit CONST_INT.  */             \
3336           if ((OUTER_CODE) == PLUS)                                     \
3337             return 0;                                                   \
3338           else if ((OUTER_CODE) == SET)                                 \
3339             return COSTS_N_INSNS (1);                                   \
3340           else                                                          \
3341             return COSTS_N_INSNS (2);                                   \
3342         }                                                               \
3343                                                                         \
3344       if (GET_CODE (symref) == LABEL_REF)                               \
3345         return COSTS_N_INSNS (2);                                       \
3346                                                                         \
3347       if (GET_CODE (symref) != SYMBOL_REF)                              \
3348         return COSTS_N_INSNS (4);                                       \
3349                                                                         \
3350       /* let's be paranoid....  */                                      \
3351       if (INTVAL (offset) < -32768 || INTVAL (offset) > 32767)          \
3352         return COSTS_N_INSNS (2);                                       \
3353                                                                         \
3354       return COSTS_N_INSNS (SYMBOL_REF_FLAG (symref) ? 1 : 2);          \
3355     }                                                                   \
3356                                                                         \
3357   case SYMBOL_REF:                                                      \
3358     return COSTS_N_INSNS (SYMBOL_REF_FLAG (X) ? 1 : 2);                 \
3359                                                                         \
3360   case CONST_DOUBLE:                                                    \
3361     {                                                                   \
3362       rtx high, low;                                                    \
3363       if (TARGET_MIPS16)                                                \
3364         return COSTS_N_INSNS (4);                                       \
3365       split_double (X, &high, &low);                                    \
3366       return COSTS_N_INSNS ((high == CONST0_RTX (GET_MODE (high))       \
3367                              || low == CONST0_RTX (GET_MODE (low)))     \
3368                             ? 2 : 4);                                   \
3369     }
3370
3371 /* Like `CONST_COSTS' but applies to nonconstant RTL expressions.
3372    This can be used, for example, to indicate how costly a multiply
3373    instruction is.  In writing this macro, you can use the construct
3374    `COSTS_N_INSNS (N)' to specify a cost equal to N fast instructions.
3375
3376    This macro is optional; do not define it if the default cost
3377    assumptions are adequate for the target machine.
3378
3379    If -mdebugd is used, change the multiply cost to 2, so multiply by
3380    a constant isn't converted to a series of shifts.  This helps
3381    strength reduction, and also makes it easier to identify what the
3382    compiler is doing.  */
3383
3384 /* ??? Fix this to be right for the R8000.  */
3385 #define RTX_COSTS(X,CODE,OUTER_CODE)                                    \
3386   case MEM:                                                             \
3387     {                                                                   \
3388       int num_words = (GET_MODE_SIZE (GET_MODE (X)) > UNITS_PER_WORD) ? 2 : 1; \
3389       if (simple_memory_operand (X, GET_MODE (X)))                      \
3390         return COSTS_N_INSNS (num_words);                               \
3391                                                                         \
3392       return COSTS_N_INSNS (2*num_words);                               \
3393     }                                                                   \
3394                                                                         \
3395   case FFS:                                                             \
3396     return COSTS_N_INSNS (6);                                           \
3397                                                                         \
3398   case NOT:                                                             \
3399     return COSTS_N_INSNS ((GET_MODE (X) == DImode && !TARGET_64BIT) ? 2 : 1); \
3400                                                                         \
3401   case AND:                                                             \
3402   case IOR:                                                             \
3403   case XOR:                                                             \
3404     if (GET_MODE (X) == DImode && !TARGET_64BIT)                        \
3405       return COSTS_N_INSNS (2);                                         \
3406                                                                         \
3407     break;                                                              \
3408                                                                         \
3409   case ASHIFT:                                                          \
3410   case ASHIFTRT:                                                        \
3411   case LSHIFTRT:                                                        \
3412     if (GET_MODE (X) == DImode && !TARGET_64BIT)                        \
3413       return COSTS_N_INSNS ((GET_CODE (XEXP (X, 1)) == CONST_INT) ? 4 : 12); \
3414                                                                         \
3415     break;                                                              \
3416                                                                         \
3417   case ABS:                                                             \
3418     {                                                                   \
3419       enum machine_mode xmode = GET_MODE (X);                           \
3420       if (xmode == SFmode || xmode == DFmode)                           \
3421         return COSTS_N_INSNS (1);                                       \
3422                                                                         \
3423       return COSTS_N_INSNS (4);                                         \
3424     }                                                                   \
3425                                                                         \
3426   case PLUS:                                                            \
3427   case MINUS:                                                           \
3428     {                                                                   \
3429       enum machine_mode xmode = GET_MODE (X);                           \
3430       if (xmode == SFmode || xmode == DFmode)                           \
3431         {                                                               \
3432           if (TUNE_MIPS3000                                             \
3433               || TUNE_MIPS3900)                                         \
3434             return COSTS_N_INSNS (2);                                   \
3435           else if (TUNE_MIPS6000)                                       \
3436             return COSTS_N_INSNS (3);                                   \
3437           else                                                          \
3438             return COSTS_N_INSNS (6);                                   \
3439         }                                                               \
3440                                                                         \
3441       if (xmode == DImode && !TARGET_64BIT)                             \
3442         return COSTS_N_INSNS (4);                                       \
3443                                                                         \
3444       break;                                                            \
3445     }                                                                   \
3446                                                                         \
3447   case NEG:                                                             \
3448     if (GET_MODE (X) == DImode && !TARGET_64BIT)                        \
3449       return 4;                                                         \
3450                                                                         \
3451     break;                                                              \
3452                                                                         \
3453   case MULT:                                                            \
3454     {                                                                   \
3455       enum machine_mode xmode = GET_MODE (X);                           \
3456       if (xmode == SFmode)                                              \
3457         {                                                               \
3458           if (TUNE_MIPS3000                                             \
3459               || TUNE_MIPS3900                                          \
3460               || TUNE_MIPS5000)                                         \
3461             return COSTS_N_INSNS (4);                                   \
3462           else if (TUNE_MIPS6000)                                       \
3463             return COSTS_N_INSNS (5);                                   \
3464           else                                                          \
3465             return COSTS_N_INSNS (7);                                   \
3466         }                                                               \
3467                                                                         \
3468       if (xmode == DFmode)                                              \
3469         {                                                               \
3470           if (TUNE_MIPS3000                                             \
3471               || TUNE_MIPS3900                                          \
3472               || TUNE_MIPS5000)                                         \
3473             return COSTS_N_INSNS (5);                                   \
3474           else if (TUNE_MIPS6000)                                       \
3475             return COSTS_N_INSNS (6);                                   \
3476           else                                                          \
3477             return COSTS_N_INSNS (8);                                   \
3478         }                                                               \
3479                                                                         \
3480       if (TUNE_MIPS3000)                                                \
3481         return COSTS_N_INSNS (12);                                      \
3482       else if (TUNE_MIPS3900)                                           \
3483         return COSTS_N_INSNS (2);                                       \
3484       else if (TUNE_MIPS6000)                                           \
3485         return COSTS_N_INSNS (17);                                      \
3486       else if (TUNE_MIPS5000)                                           \
3487         return COSTS_N_INSNS (5);                                       \
3488       else                                                              \
3489         return COSTS_N_INSNS (10);                                      \
3490     }                                                                   \
3491                                                                         \
3492   case DIV:                                                             \
3493   case MOD:                                                             \
3494     {                                                                   \
3495       enum machine_mode xmode = GET_MODE (X);                           \
3496       if (xmode == SFmode)                                              \
3497         {                                                               \
3498           if (TUNE_MIPS3000                                             \
3499               || TUNE_MIPS3900)                                         \
3500             return COSTS_N_INSNS (12);                                  \
3501           else if (TUNE_MIPS6000)                                       \
3502             return COSTS_N_INSNS (15);                                  \
3503           else                                                          \
3504             return COSTS_N_INSNS (23);                                  \
3505         }                                                               \
3506                                                                         \
3507       if (xmode == DFmode)                                              \
3508         {                                                               \
3509           if (TUNE_MIPS3000                                             \
3510               || TUNE_MIPS3900)                                         \
3511             return COSTS_N_INSNS (19);                                  \
3512           else if (TUNE_MIPS6000)                                       \
3513             return COSTS_N_INSNS (16);                                  \
3514           else                                                          \
3515             return COSTS_N_INSNS (36);                                  \
3516         }                                                               \
3517     }                                                                   \
3518     /* fall through */                                                  \
3519                                                                         \
3520   case UDIV:                                                            \
3521   case UMOD:                                                            \
3522     if (TUNE_MIPS3000                                                   \
3523         || TUNE_MIPS3900)                                               \
3524       return COSTS_N_INSNS (35);                                        \
3525     else if (TUNE_MIPS6000)                                             \
3526       return COSTS_N_INSNS (38);                                        \
3527     else if (TUNE_MIPS5000)                                             \
3528       return COSTS_N_INSNS (36);                                        \
3529     else                                                                \
3530       return COSTS_N_INSNS (69);                                        \
3531                                                                         \
3532   case SIGN_EXTEND:                                                     \
3533     /* A sign extend from SImode to DImode in 64 bit mode is often      \
3534        zero instructions, because the result can often be used          \
3535        directly by another instruction; we'll call it one.  */          \
3536     if (TARGET_64BIT && GET_MODE (X) == DImode                          \
3537         && GET_MODE (XEXP (X, 0)) == SImode)                            \
3538       return COSTS_N_INSNS (1);                                         \
3539     else                                                                \
3540       return COSTS_N_INSNS (2);                                         \
3541                                                                         \
3542   case ZERO_EXTEND:                                                     \
3543     if (TARGET_64BIT && GET_MODE (X) == DImode                          \
3544         && GET_MODE (XEXP (X, 0)) == SImode)                            \
3545       return COSTS_N_INSNS (2);                                         \
3546     else                                                                \
3547       return COSTS_N_INSNS (1);
3548
3549 /* An expression giving the cost of an addressing mode that
3550    contains ADDRESS.  If not defined, the cost is computed from the
3551    form of the ADDRESS expression and the `CONST_COSTS' values.
3552
3553    For most CISC machines, the default cost is a good approximation
3554    of the true cost of the addressing mode.  However, on RISC
3555    machines, all instructions normally have the same length and
3556    execution time.  Hence all addresses will have equal costs.
3557
3558    In cases where more than one form of an address is known, the
3559    form with the lowest cost will be used.  If multiple forms have
3560    the same, lowest, cost, the one that is the most complex will be
3561    used.
3562
3563    For example, suppose an address that is equal to the sum of a
3564    register and a constant is used twice in the same basic block.
3565    When this macro is not defined, the address will be computed in
3566    a register and memory references will be indirect through that
3567    register.  On machines where the cost of the addressing mode
3568    containing the sum is no higher than that of a simple indirect
3569    reference, this will produce an additional instruction and
3570    possibly require an additional register.  Proper specification
3571    of this macro eliminates this overhead for such machines.
3572
3573    Similar use of this macro is made in strength reduction of loops.
3574
3575    ADDRESS need not be valid as an address.  In such a case, the
3576    cost is not relevant and can be any value; invalid addresses
3577    need not be assigned a different cost.
3578
3579    On machines where an address involving more than one register is
3580    as cheap as an address computation involving only one register,
3581    defining `ADDRESS_COST' to reflect this can cause two registers
3582    to be live over a region of code where only one would have been
3583    if `ADDRESS_COST' were not defined in that manner.  This effect
3584    should be considered in the definition of this macro.
3585    Equivalent costs should probably only be given to addresses with
3586    different numbers of registers on machines with lots of registers.
3587
3588    This macro will normally either not be defined or be defined as
3589    a constant.  */
3590
3591 #define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : mips_address_cost (ADDR))
3592
3593 /* A C expression for the cost of moving data from a register in
3594    class FROM to one in class TO.  The classes are expressed using
3595    the enumeration values such as `GENERAL_REGS'.  A value of 2 is
3596    the default; other values are interpreted relative to that.
3597
3598    It is not required that the cost always equal 2 when FROM is the
3599    same as TO; on some machines it is expensive to move between
3600    registers if they are not general registers.
3601
3602    If reload sees an insn consisting of a single `set' between two
3603    hard registers, and if `REGISTER_MOVE_COST' applied to their
3604    classes returns a value of 2, reload does not check to ensure
3605    that the constraints of the insn are met.  Setting a cost of
3606    other than 2 will allow reload to verify that the constraints are
3607    met.  You should do this if the `movM' pattern's constraints do
3608    not allow such copying. */
3609
3610 #define REGISTER_MOVE_COST(MODE, FROM, TO)                              \
3611   mips_register_move_cost (MODE, FROM, TO)
3612
3613 /* ??? Fix this to be right for the R8000.  */
3614 #define MEMORY_MOVE_COST(MODE,CLASS,TO_P) \
3615   (((TUNE_MIPS4000 || TUNE_MIPS6000) ? 6 : 4) \
3616    + memory_move_secondary_cost ((MODE), (CLASS), (TO_P)))
3617
3618 /* Define if copies to/from condition code registers should be avoided.
3619
3620    This is needed for the MIPS because reload_outcc is not complete;
3621    it needs to handle cases where the source is a general or another
3622    condition code register.  */
3623 #define AVOID_CCMODE_COPIES
3624
3625 /* A C expression for the cost of a branch instruction.  A value of
3626    1 is the default; other values are interpreted relative to that.  */
3627
3628 /* ??? Fix this to be right for the R8000.  */
3629 #define BRANCH_COST                                                     \
3630   ((! TARGET_MIPS16                                                     \
3631     && (TUNE_MIPS4000 || TUNE_MIPS6000))        \
3632    ? 2 : 1)
3633
3634 /* If defined, modifies the length assigned to instruction INSN as a
3635    function of the context in which it is used.  LENGTH is an lvalue
3636    that contains the initially computed length of the insn and should
3637    be updated with the correct length of the insn.  */
3638 #define ADJUST_INSN_LENGTH(INSN, LENGTH) \
3639   ((LENGTH) = mips_adjust_insn_length ((INSN), (LENGTH)))
3640
3641 \f
3642 /* Optionally define this if you have added predicates to
3643    `MACHINE.c'.  This macro is called within an initializer of an
3644    array of structures.  The first field in the structure is the
3645    name of a predicate and the second field is an array of rtl
3646    codes.  For each predicate, list all rtl codes that can be in
3647    expressions matched by the predicate.  The list should have a
3648    trailing comma.  Here is an example of two entries in the list
3649    for a typical RISC machine:
3650
3651    #define PREDICATE_CODES \
3652      {"gen_reg_rtx_operand", {SUBREG, REG}},  \
3653      {"reg_or_short_cint_operand", {SUBREG, REG, CONST_INT}},
3654
3655    Defining this macro does not affect the generated code (however,
3656    incorrect definitions that omit an rtl code that may be matched
3657    by the predicate can cause the compiler to malfunction).
3658    Instead, it allows the table built by `genrecog' to be more
3659    compact and efficient, thus speeding up the compiler.  The most
3660    important predicates to include in the list specified by this
3661    macro are thoses used in the most insn patterns.  */
3662
3663 #define PREDICATE_CODES                                                 \
3664   {"uns_arith_operand",         { REG, CONST_INT, SUBREG }},            \
3665   {"arith_operand",             { REG, CONST_INT, SUBREG }},            \
3666   {"arith32_operand",           { REG, CONST_INT, SUBREG }},            \
3667   {"reg_or_0_operand",          { REG, CONST_INT, CONST_DOUBLE, SUBREG }}, \
3668   {"true_reg_or_0_operand",     { REG, CONST_INT, CONST_DOUBLE, SUBREG }}, \
3669   {"small_int",                 { CONST_INT }},                         \
3670   {"large_int",                 { CONST_INT }},                         \
3671   {"mips_const_double_ok",      { CONST_DOUBLE }},                      \
3672   {"const_float_1_operand",     { CONST_DOUBLE }},                      \
3673   {"simple_memory_operand",     { MEM, SUBREG }},                       \
3674   {"equality_op",               { EQ, NE }},                            \
3675   {"cmp_op",                    { EQ, NE, GT, GE, GTU, GEU, LT, LE,     \
3676                                   LTU, LEU }},                          \
3677   {"trap_cmp_op",               { EQ, NE, GE, GEU, LT, LTU }},          \
3678   {"pc_or_label_operand",       { PC, LABEL_REF }},                     \
3679   {"call_insn_operand",         { CONST_INT, CONST, SYMBOL_REF, REG}},  \
3680   {"move_operand",              { CONST_INT, CONST_DOUBLE, CONST,       \
3681                                   SYMBOL_REF, LABEL_REF, SUBREG,        \
3682                                   REG, MEM}},                           \
3683   {"movdi_operand",             { CONST_INT, CONST_DOUBLE, CONST,       \
3684                                   SYMBOL_REF, LABEL_REF, SUBREG, REG,   \
3685                                   MEM, SIGN_EXTEND }},                  \
3686   {"se_register_operand",       { SUBREG, REG, SIGN_EXTEND }},          \
3687   {"se_reg_or_0_operand",       { REG, CONST_INT, CONST_DOUBLE, SUBREG, \
3688                                   SIGN_EXTEND }},                       \
3689   {"se_uns_arith_operand",      { REG, CONST_INT, SUBREG,               \
3690                                   SIGN_EXTEND }},                       \
3691   {"se_arith_operand",          { REG, CONST_INT, SUBREG,               \
3692                                   SIGN_EXTEND }},                       \
3693   {"se_nonmemory_operand",      { CONST_INT, CONST_DOUBLE, CONST,       \
3694                                   SYMBOL_REF, LABEL_REF, SUBREG,        \
3695                                   REG, SIGN_EXTEND }},                  \
3696   {"se_nonimmediate_operand",   { SUBREG, REG, MEM, SIGN_EXTEND }},     \
3697   {"consttable_operand",        { LABEL_REF, SYMBOL_REF, CONST_INT,     \
3698                                   CONST_DOUBLE, CONST }},               \
3699   {"extend_operator",           { SIGN_EXTEND, ZERO_EXTEND }},          \
3700   {"highpart_shift_operator",   { ASHIFTRT, LSHIFTRT, ROTATERT, ROTATE }},
3701
3702 /* A list of predicates that do special things with modes, and so
3703    should not elicit warnings for VOIDmode match_operand.  */
3704
3705 #define SPECIAL_MODE_PREDICATES \
3706   "pc_or_label_operand",
3707
3708 \f
3709 /* If defined, a C statement to be executed just prior to the
3710    output of assembler code for INSN, to modify the extracted
3711    operands so they will be output differently.
3712
3713    Here the argument OPVEC is the vector containing the operands
3714    extracted from INSN, and NOPERANDS is the number of elements of
3715    the vector which contain meaningful data for this insn.  The
3716    contents of this vector are what will be used to convert the
3717    insn template into assembler code, so you can change the
3718    assembler output by changing the contents of the vector.
3719
3720    We use it to check if the current insn needs a nop in front of it
3721    because of load delays, and also to update the delay slot
3722    statistics.  */
3723
3724 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS)                      \
3725   final_prescan_insn (INSN, OPVEC, NOPERANDS)
3726
3727 \f
3728 /* Control the assembler format that we output.  */
3729
3730 /* Output at beginning of assembler file.
3731    If we are optimizing to use the global pointer, create a temporary
3732    file to hold all of the text stuff, and write it out to the end.
3733    This is needed because the MIPS assembler is evidently one pass,
3734    and if it hasn't seen the relevant .comm/.lcomm/.extern/.sdata
3735    declaration when the code is processed, it generates a two
3736    instruction sequence.  */
3737
3738 #undef ASM_FILE_START
3739 #define ASM_FILE_START(STREAM) mips_asm_file_start (STREAM)
3740
3741 /* Output to assembler file text saying following lines
3742    may contain character constants, extra white space, comments, etc.  */
3743
3744 #ifndef ASM_APP_ON
3745 #define ASM_APP_ON " #APP\n"
3746 #endif
3747
3748 /* Output to assembler file text saying following lines
3749    no longer contain unusual constructs.  */
3750
3751 #ifndef ASM_APP_OFF
3752 #define ASM_APP_OFF " #NO_APP\n"
3753 #endif
3754
3755 /* How to refer to registers in assembler output.
3756    This sequence is indexed by compiler's hard-register-number (see above).
3757
3758    In order to support the two different conventions for register names,
3759    we use the name of a table set up in mips.c, which is overwritten
3760    if -mrnames is used.  */
3761
3762 #define REGISTER_NAMES                                                  \
3763 {                                                                       \
3764   &mips_reg_names[ 0][0],                                               \
3765   &mips_reg_names[ 1][0],                                               \
3766   &mips_reg_names[ 2][0],                                               \
3767   &mips_reg_names[ 3][0],                                               \
3768   &mips_reg_names[ 4][0],                                               \
3769   &mips_reg_names[ 5][0],                                               \
3770   &mips_reg_names[ 6][0],                                               \
3771   &mips_reg_names[ 7][0],                                               \
3772   &mips_reg_names[ 8][0],                                               \
3773   &mips_reg_names[ 9][0],                                               \
3774   &mips_reg_names[10][0],                                               \
3775   &mips_reg_names[11][0],                                               \
3776   &mips_reg_names[12][0],                                               \
3777   &mips_reg_names[13][0],                                               \
3778   &mips_reg_names[14][0],                                               \
3779   &mips_reg_names[15][0],                                               \
3780   &mips_reg_names[16][0],                                               \
3781   &mips_reg_names[17][0],                                               \
3782   &mips_reg_names[18][0],                                               \
3783   &mips_reg_names[19][0],                                               \
3784   &mips_reg_names[20][0],                                               \
3785   &mips_reg_names[21][0],                                               \
3786   &mips_reg_names[22][0],                                               \
3787   &mips_reg_names[23][0],                                               \
3788   &mips_reg_names[24][0],                                               \
3789   &mips_reg_names[25][0],                                               \
3790   &mips_reg_names[26][0],                                               \
3791   &mips_reg_names[27][0],                                               \
3792   &mips_reg_names[28][0],                                               \
3793   &mips_reg_names[29][0],                                               \
3794   &mips_reg_names[30][0],                                               \
3795   &mips_reg_names[31][0],                                               \
3796   &mips_reg_names[32][0],                                               \
3797   &mips_reg_names[33][0],                                               \
3798   &mips_reg_names[34][0],                                               \
3799   &mips_reg_names[35][0],                                               \
3800   &mips_reg_names[36][0],                                               \
3801   &mips_reg_names[37][0],                                               \
3802   &mips_reg_names[38][0],                                               \
3803   &mips_reg_names[39][0],                                               \
3804   &mips_reg_names[40][0],                                               \
3805   &mips_reg_names[41][0],                                               \
3806   &mips_reg_names[42][0],                                               \
3807   &mips_reg_names[43][0],                                               \
3808   &mips_reg_names[44][0],                                               \
3809   &mips_reg_names[45][0],                                               \
3810   &mips_reg_names[46][0],                                               \
3811   &mips_reg_names[47][0],                                               \
3812   &mips_reg_names[48][0],                                               \
3813   &mips_reg_names[49][0],                                               \
3814   &mips_reg_names[50][0],                                               \
3815   &mips_reg_names[51][0],                                               \
3816   &mips_reg_names[52][0],                                               \
3817   &mips_reg_names[53][0],                                               \
3818   &mips_reg_names[54][0],                                               \
3819   &mips_reg_names[55][0],                                               \
3820   &mips_reg_names[56][0],                                               \
3821   &mips_reg_names[57][0],                                               \
3822   &mips_reg_names[58][0],                                               \
3823   &mips_reg_names[59][0],                                               \
3824   &mips_reg_names[60][0],                                               \
3825   &mips_reg_names[61][0],                                               \
3826   &mips_reg_names[62][0],                                               \
3827   &mips_reg_names[63][0],                                               \
3828   &mips_reg_names[64][0],                                               \
3829   &mips_reg_names[65][0],                                               \
3830   &mips_reg_names[66][0],                                               \
3831   &mips_reg_names[67][0],                                               \
3832   &mips_reg_names[68][0],                                               \
3833   &mips_reg_names[69][0],                                               \
3834   &mips_reg_names[70][0],                                               \
3835   &mips_reg_names[71][0],                                               \
3836   &mips_reg_names[72][0],                                               \
3837   &mips_reg_names[73][0],                                               \
3838   &mips_reg_names[74][0],                                               \
3839   &mips_reg_names[75][0],                                               \
3840   &mips_reg_names[76][0],                                               \
3841   &mips_reg_names[77][0],                                               \
3842   &mips_reg_names[78][0],                                               \
3843   &mips_reg_names[79][0],                                               \
3844   &mips_reg_names[80][0],                                               \
3845   &mips_reg_names[81][0],                                               \
3846   &mips_reg_names[82][0],                                               \
3847   &mips_reg_names[83][0],                                               \
3848   &mips_reg_names[84][0],                                               \
3849   &mips_reg_names[85][0],                                               \
3850   &mips_reg_names[86][0],                                               \
3851   &mips_reg_names[87][0],                                               \
3852   &mips_reg_names[88][0],                                               \
3853   &mips_reg_names[89][0],                                               \
3854   &mips_reg_names[90][0],                                               \
3855   &mips_reg_names[91][0],                                               \
3856   &mips_reg_names[92][0],                                               \
3857   &mips_reg_names[93][0],                                               \
3858   &mips_reg_names[94][0],                                               \
3859   &mips_reg_names[95][0],                                               \
3860   &mips_reg_names[96][0],                                               \
3861   &mips_reg_names[97][0],                                               \
3862   &mips_reg_names[98][0],                                               \
3863   &mips_reg_names[99][0],                                               \
3864   &mips_reg_names[100][0],                                              \
3865   &mips_reg_names[101][0],                                              \
3866   &mips_reg_names[102][0],                                              \
3867   &mips_reg_names[103][0],                                              \
3868   &mips_reg_names[104][0],                                              \
3869   &mips_reg_names[105][0],                                              \
3870   &mips_reg_names[106][0],                                              \
3871   &mips_reg_names[107][0],                                              \
3872   &mips_reg_names[108][0],                                              \
3873   &mips_reg_names[109][0],                                              \
3874   &mips_reg_names[110][0],                                              \
3875   &mips_reg_names[111][0],                                              \
3876   &mips_reg_names[112][0],                                              \
3877   &mips_reg_names[113][0],                                              \
3878   &mips_reg_names[114][0],                                              \
3879   &mips_reg_names[115][0],                                              \
3880   &mips_reg_names[116][0],                                              \
3881   &mips_reg_names[117][0],                                              \
3882   &mips_reg_names[118][0],                                              \
3883   &mips_reg_names[119][0],                                              \
3884   &mips_reg_names[120][0],                                              \
3885   &mips_reg_names[121][0],                                              \
3886   &mips_reg_names[122][0],                                              \
3887   &mips_reg_names[123][0],                                              \
3888   &mips_reg_names[124][0],                                              \
3889   &mips_reg_names[125][0],                                              \
3890   &mips_reg_names[126][0],                                              \
3891   &mips_reg_names[127][0],                                              \
3892   &mips_reg_names[128][0],                                              \
3893   &mips_reg_names[129][0],                                              \
3894   &mips_reg_names[130][0],                                              \
3895   &mips_reg_names[131][0],                                              \
3896   &mips_reg_names[132][0],                                              \
3897   &mips_reg_names[133][0],                                              \
3898   &mips_reg_names[134][0],                                              \
3899   &mips_reg_names[135][0],                                              \
3900   &mips_reg_names[136][0],                                              \
3901   &mips_reg_names[137][0],                                              \
3902   &mips_reg_names[138][0],                                              \
3903   &mips_reg_names[139][0],                                              \
3904   &mips_reg_names[140][0],                                              \
3905   &mips_reg_names[141][0],                                              \
3906   &mips_reg_names[142][0],                                              \
3907   &mips_reg_names[143][0],                                              \
3908   &mips_reg_names[144][0],                                              \
3909   &mips_reg_names[145][0],                                              \
3910   &mips_reg_names[146][0],                                              \
3911   &mips_reg_names[147][0],                                              \
3912   &mips_reg_names[148][0],                                              \
3913   &mips_reg_names[149][0],                                              \
3914   &mips_reg_names[150][0],                                              \
3915   &mips_reg_names[151][0],                                              \
3916   &mips_reg_names[152][0],                                              \
3917   &mips_reg_names[153][0],                                              \
3918   &mips_reg_names[154][0],                                              \
3919   &mips_reg_names[155][0],                                              \
3920   &mips_reg_names[156][0],                                              \
3921   &mips_reg_names[157][0],                                              \
3922   &mips_reg_names[158][0],                                              \
3923   &mips_reg_names[159][0],                                              \
3924   &mips_reg_names[160][0],                                              \
3925   &mips_reg_names[161][0],                                              \
3926   &mips_reg_names[162][0],                                              \
3927   &mips_reg_names[163][0],                                              \
3928   &mips_reg_names[164][0],                                              \
3929   &mips_reg_names[165][0],                                              \
3930   &mips_reg_names[166][0],                                              \
3931   &mips_reg_names[167][0],                                              \
3932   &mips_reg_names[168][0],                                              \
3933   &mips_reg_names[169][0],                                              \
3934   &mips_reg_names[170][0],                                              \
3935   &mips_reg_names[171][0],                                              \
3936   &mips_reg_names[172][0],                                              \
3937   &mips_reg_names[173][0],                                              \
3938   &mips_reg_names[174][0],                                              \
3939   &mips_reg_names[175][0]                                               \
3940 }
3941
3942 /* print-rtl.c can't use REGISTER_NAMES, since it depends on mips.c.
3943    So define this for it.  */
3944 #define DEBUG_REGISTER_NAMES                                            \
3945 {                                                                       \
3946   "$0",   "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",         \
3947   "t0",   "t1",   "t2",   "t3",   "t4",   "t5",   "t6",   "t7",         \
3948   "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",         \
3949   "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "$fp",  "ra",         \
3950   "$f0",  "$f1",  "$f2",  "$f3",  "$f4",  "$f5",  "$f6",  "$f7",        \
3951   "$f8",  "$f9",  "$f10", "$f11", "$f12", "$f13", "$f14", "$f15",       \
3952   "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",       \
3953   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",       \
3954   "hi",   "lo",   "accum","$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",      \
3955   "$fcc5","$fcc6","$fcc7","$rap", "",     "",     "",     "",           \
3956   "$c0r0", "$c0r1", "$c0r2", "$c0r3", "$c0r4", "$c0r5", "$c0r6", "$c0r7",\
3957   "$c0r8", "$c0r9", "$c0r10","$c0r11","$c0r12","$c0r13","$c0r14","$c0r15",\
3958   "$c0r16","$c0r17","$c0r18","$c0r19","$c0r20","$c0r21","$c0r22","$c0r23",\
3959   "$c0r24","$c0r25","$c0r26","$c0r27","$c0r28","$c0r29","$c0r30","$c0r31",\
3960   "$c2r0", "$c2r1", "$c2r2", "$c2r3", "$c2r4", "$c2r5", "$c2r6", "$c2r7",\
3961   "$c2r8", "$c2r9", "$c2r10","$c2r11","$c2r12","$c2r13","$c2r14","$c2r15",\
3962   "$c2r16","$c2r17","$c2r18","$c2r19","$c2r20","$c2r21","$c2r22","$c2r23",\
3963   "$c2r24","$c2r25","$c2r26","$c2r27","$c2r28","$c2r29","$c2r30","$c2r31",\
3964   "$c3r0", "$c3r1", "$c3r2", "$c3r3", "$c3r4", "$c3r5", "$c3r6", "$c3r7",\
3965   "$c3r8", "$c3r9", "$c3r10","$c3r11","$c3r12","$c3r13","$c3r14","$c3r15",\
3966   "$c3r16","$c3r17","$c3r18","$c3r19","$c3r20","$c3r21","$c3r22","$c3r23",\
3967   "$c3r24","$c3r25","$c3r26","$c3r27","$c3r28","$c3r29","$c3r30","$c3r31"\
3968 }
3969
3970 /* If defined, a C initializer for an array of structures
3971    containing a name and a register number.  This macro defines
3972    additional names for hard registers, thus allowing the `asm'
3973    option in declarations to refer to registers using alternate
3974    names.
3975
3976    We define both names for the integer registers here.  */
3977
3978 #define ADDITIONAL_REGISTER_NAMES                                       \
3979 {                                                                       \
3980   { "$0",        0 + GP_REG_FIRST },                                    \
3981   { "$1",        1 + GP_REG_FIRST },                                    \
3982   { "$2",        2 + GP_REG_FIRST },                                    \
3983   { "$3",        3 + GP_REG_FIRST },                                    \
3984   { "$4",        4 + GP_REG_FIRST },                                    \
3985   { "$5",        5 + GP_REG_FIRST },                                    \
3986   { "$6",        6 + GP_REG_FIRST },                                    \
3987   { "$7",        7 + GP_REG_FIRST },                                    \
3988   { "$8",        8 + GP_REG_FIRST },                                    \
3989   { "$9",        9 + GP_REG_FIRST },                                    \
3990   { "$10",      10 + GP_REG_FIRST },                                    \
3991   { "$11",      11 + GP_REG_FIRST },                                    \
3992   { "$12",      12 + GP_REG_FIRST },                                    \
3993   { "$13",      13 + GP_REG_FIRST },                                    \
3994   { "$14",      14 + GP_REG_FIRST },                                    \
3995   { "$15",      15 + GP_REG_FIRST },                                    \
3996   { "$16",      16 + GP_REG_FIRST },                                    \
3997   { "$17",      17 + GP_REG_FIRST },                                    \
3998   { "$18",      18 + GP_REG_FIRST },                                    \
3999   { "$19",      19 + GP_REG_FIRST },                                    \
4000   { "$20",      20 + GP_REG_FIRST },                                    \
4001   { "$21",      21 + GP_REG_FIRST },                                    \
4002   { "$22",      22 + GP_REG_FIRST },                                    \
4003   { "$23",      23 + GP_REG_FIRST },                                    \
4004   { "$24",      24 + GP_REG_FIRST },                                    \
4005   { "$25",      25 + GP_REG_FIRST },                                    \
4006   { "$26",      26 + GP_REG_FIRST },                                    \
4007   { "$27",      27 + GP_REG_FIRST },                                    \
4008   { "$28",      28 + GP_REG_FIRST },                                    \
4009   { "$29",      29 + GP_REG_FIRST },                                    \
4010   { "$30",      30 + GP_REG_FIRST },                                    \
4011   { "$31",      31 + GP_REG_FIRST },                                    \
4012   { "$sp",      29 + GP_REG_FIRST },                                    \
4013   { "$fp",      30 + GP_REG_FIRST },                                    \
4014   { "at",        1 + GP_REG_FIRST },                                    \
4015   { "v0",        2 + GP_REG_FIRST },                                    \
4016   { "v1",        3 + GP_REG_FIRST },                                    \
4017   { "a0",        4 + GP_REG_FIRST },                                    \
4018   { "a1",        5 + GP_REG_FIRST },                                    \
4019   { "a2",        6 + GP_REG_FIRST },                                    \
4020   { "a3",        7 + GP_REG_FIRST },                                    \
4021   { "t0",        8 + GP_REG_FIRST },                                    \
4022   { "t1",        9 + GP_REG_FIRST },                                    \
4023   { "t2",       10 + GP_REG_FIRST },                                    \
4024   { "t3",       11 + GP_REG_FIRST },                                    \
4025   { "t4",       12 + GP_REG_FIRST },                                    \
4026   { "t5",       13 + GP_REG_FIRST },                                    \
4027   { "t6",       14 + GP_REG_FIRST },                                    \
4028   { "t7",       15 + GP_REG_FIRST },                                    \
4029   { "s0",       16 + GP_REG_FIRST },                                    \
4030   { "s1",       17 + GP_REG_FIRST },                                    \
4031   { "s2",       18 + GP_REG_FIRST },                                    \
4032   { "s3",       19 + GP_REG_FIRST },                                    \
4033   { "s4",       20 + GP_REG_FIRST },                                    \
4034   { "s5",       21 + GP_REG_FIRST },                                    \
4035   { "s6",       22 + GP_REG_FIRST },                                    \
4036   { "s7",       23 + GP_REG_FIRST },                                    \
4037   { "t8",       24 + GP_REG_FIRST },                                    \
4038   { "t9",       25 + GP_REG_FIRST },                                    \
4039   { "k0",       26 + GP_REG_FIRST },                                    \
4040   { "k1",       27 + GP_REG_FIRST },                                    \
4041   { "gp",       28 + GP_REG_FIRST },                                    \
4042   { "sp",       29 + GP_REG_FIRST },                                    \
4043   { "fp",       30 + GP_REG_FIRST },                                    \
4044   { "ra",       31 + GP_REG_FIRST },                                    \
4045   { "$sp",      29 + GP_REG_FIRST },                                    \
4046   { "$fp",      30 + GP_REG_FIRST }                                     \
4047   ALL_COP_ADDITIONAL_REGISTER_NAMES                                     \
4048 }
4049
4050 /* This is meant to be redefined in the host dependent files.  It is a
4051    set of alternative names and regnums for mips coprocessors.  */
4052
4053 #define ALL_COP_ADDITIONAL_REGISTER_NAMES
4054
4055 /* A C compound statement to output to stdio stream STREAM the
4056    assembler syntax for an instruction operand X.  X is an RTL
4057    expression.
4058
4059    CODE is a value that can be used to specify one of several ways
4060    of printing the operand.  It is used when identical operands
4061    must be printed differently depending on the context.  CODE
4062    comes from the `%' specification that was used to request
4063    printing of the operand.  If the specification was just `%DIGIT'
4064    then CODE is 0; if the specification was `%LTR DIGIT' then CODE
4065    is the ASCII code for LTR.
4066
4067    If X is a register, this macro should print the register's name.
4068    The names can be found in an array `reg_names' whose type is
4069    `char *[]'.  `reg_names' is initialized from `REGISTER_NAMES'.
4070
4071    When the machine description has a specification `%PUNCT' (a `%'
4072    followed by a punctuation character), this macro is called with
4073    a null pointer for X and the punctuation character for CODE.
4074
4075    See mips.c for the MIPS specific codes.  */
4076
4077 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
4078
4079 /* A C expression which evaluates to true if CODE is a valid
4080    punctuation character for use in the `PRINT_OPERAND' macro.  If
4081    `PRINT_OPERAND_PUNCT_VALID_P' is not defined, it means that no
4082    punctuation characters (except for the standard one, `%') are
4083    used in this way.  */
4084
4085 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) mips_print_operand_punct[CODE]
4086
4087 /* A C compound statement to output to stdio stream STREAM the
4088    assembler syntax for an instruction operand that is a memory
4089    reference whose address is ADDR.  ADDR is an RTL expression.  */
4090
4091 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
4092
4093
4094 /* A C statement, to be executed after all slot-filler instructions
4095    have been output.  If necessary, call `dbr_sequence_length' to
4096    determine the number of slots filled in a sequence (zero if not
4097    currently outputting a sequence), to decide how many no-ops to
4098    output, or whatever.
4099
4100    Don't define this macro if it has nothing to do, but it is
4101    helpful in reading assembly output if the extent of the delay
4102    sequence is made explicit (e.g. with white space).
4103
4104    Note that output routines for instructions with delay slots must
4105    be prepared to deal with not being output as part of a sequence
4106    (i.e.  when the scheduling pass is not run, or when no slot
4107    fillers could be found.)  The variable `final_sequence' is null
4108    when not processing a sequence, otherwise it contains the
4109    `sequence' rtx being output.  */
4110
4111 #define DBR_OUTPUT_SEQEND(STREAM)                                       \
4112 do                                                                      \
4113   {                                                                     \
4114     if (set_nomacro > 0 && --set_nomacro == 0)                          \
4115       fputs ("\t.set\tmacro\n", STREAM);                                \
4116                                                                         \
4117     if (set_noreorder > 0 && --set_noreorder == 0)                      \
4118       fputs ("\t.set\treorder\n", STREAM);                              \
4119                                                                         \
4120     dslots_jump_filled++;                                               \
4121     fputs ("\n", STREAM);                                               \
4122   }                                                                     \
4123 while (0)
4124
4125
4126 /* How to tell the debugger about changes of source files.  Note, the
4127    mips ECOFF format cannot deal with changes of files inside of
4128    functions, which means the output of parser generators like bison
4129    is generally not debuggable without using the -l switch.  Lose,
4130    lose, lose.  Silicon graphics seems to want all .file's hardwired
4131    to 1.  */
4132
4133 #ifndef SET_FILE_NUMBER
4134 #define SET_FILE_NUMBER() ++num_source_filenames
4135 #endif
4136
4137 #define ASM_OUTPUT_SOURCE_FILENAME(STREAM, NAME)                        \
4138   mips_output_filename (STREAM, NAME)
4139
4140 /* This is defined so that it can be overridden in iris6.h.  */
4141 #define ASM_OUTPUT_FILENAME(STREAM, NUM_SOURCE_FILENAMES, NAME) \
4142 do                                                              \
4143   {                                                             \
4144     fprintf (STREAM, "\t.file\t%d ", NUM_SOURCE_FILENAMES);     \
4145     output_quoted_string (STREAM, NAME);                        \
4146     fputs ("\n", STREAM);                                       \
4147   }                                                             \
4148 while (0)
4149
4150 /* This is how to output a note the debugger telling it the line number
4151    to which the following sequence of instructions corresponds.
4152    Silicon graphics puts a label after each .loc.  */
4153
4154 #ifndef LABEL_AFTER_LOC
4155 #define LABEL_AFTER_LOC(STREAM)
4156 #endif
4157
4158 #ifndef ASM_OUTPUT_SOURCE_LINE
4159 #define ASM_OUTPUT_SOURCE_LINE(STREAM, LINE)                            \
4160   mips_output_lineno (STREAM, LINE)
4161 #endif
4162
4163 /* The MIPS implementation uses some labels for its own purpose.  The
4164    following lists what labels are created, and are all formed by the
4165    pattern $L[a-z].*.  The machine independent portion of GCC creates
4166    labels matching:  $L[A-Z][0-9]+ and $L[0-9]+.
4167
4168         LM[0-9]+        Silicon Graphics/ECOFF stabs label before each stmt.
4169         $Lb[0-9]+       Begin blocks for MIPS debug support
4170         $Lc[0-9]+       Label for use in s<xx> operation.
4171         $Le[0-9]+       End blocks for MIPS debug support  */
4172
4173 /* This is how to output the definition of a user-level label named NAME,
4174    such as the label on a static function or variable NAME.
4175
4176    If we are optimizing the gp, remember that this label has been put
4177    out, so we know not to emit an .extern for it in mips_asm_file_end.
4178    We use one of the common bits in the IDENTIFIER tree node for this,
4179    since those bits seem to be unused, and we don't have any method
4180    of getting the decl nodes from the name.  */
4181
4182 #define ASM_OUTPUT_LABEL(STREAM,NAME)                                   \
4183 do {                                                                    \
4184   assemble_name (STREAM, NAME);                                         \
4185   fputs (":\n", STREAM);                                                \
4186 } while (0)
4187
4188
4189 /* A C statement (sans semicolon) to output to the stdio stream
4190    STREAM any text necessary for declaring the name NAME of an
4191    initialized variable which is being defined.  This macro must
4192    output the label definition (perhaps using `ASM_OUTPUT_LABEL').
4193    The argument DECL is the `VAR_DECL' tree node representing the
4194    variable.
4195
4196    If this macro is not defined, then the variable name is defined
4197    in the usual manner as a label (by means of `ASM_OUTPUT_LABEL').  */
4198
4199 #undef ASM_DECLARE_OBJECT_NAME
4200 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)                     \
4201 do                                                                      \
4202  {                                                                      \
4203    mips_declare_object (STREAM, NAME, "", ":\n", 0);                    \
4204  }                                                                      \
4205 while (0)
4206
4207
4208 /* This is how to output a command to make the user-level label named NAME
4209    defined for reference from other files.  */
4210
4211 #define ASM_GLOBALIZE_LABEL(STREAM,NAME)                                \
4212   do {                                                                  \
4213     fputs ("\t.globl\t", STREAM);                                       \
4214     assemble_name (STREAM, NAME);                                       \
4215     fputs ("\n", STREAM);                                               \
4216   } while (0)
4217
4218 /* This says how to define a global common symbol.  */
4219
4220 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGN) \
4221   do {                                                                  \
4222     /* If the target wants uninitialized const declarations in          \
4223        .rdata then don't put them in .comm */                           \
4224     if (TARGET_EMBEDDED_DATA && TARGET_UNINIT_CONST_IN_RODATA           \
4225         && TREE_CODE (DECL) == VAR_DECL && TREE_READONLY (DECL)         \
4226         && (DECL_INITIAL (DECL) == 0                                    \
4227             || DECL_INITIAL (DECL) == error_mark_node))                 \
4228       {                                                                 \
4229         if (TREE_PUBLIC (DECL) && DECL_NAME (DECL))                     \
4230           ASM_GLOBALIZE_LABEL (STREAM, NAME);                           \
4231                                                                         \
4232         readonly_data_section ();                                       \
4233         ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT));  \
4234         mips_declare_object (STREAM, NAME, "", ":\n\t.space\t%u\n",     \
4235             (SIZE));                                                    \
4236       }                                                                 \
4237     else                                                                \
4238         mips_declare_object (STREAM, NAME, "\n\t.comm\t", ",%u\n",      \
4239           (SIZE));                                                      \
4240   } while (0)
4241
4242
4243 /* This says how to define a local common symbol (ie, not visible to
4244    linker).  */
4245
4246 #define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)                   \
4247   mips_declare_object (STREAM, NAME, "\n\t.lcomm\t", ",%u\n", (SIZE))
4248
4249
4250 /* This says how to output an external.  It would be possible not to
4251    output anything and let undefined symbol become external. However
4252    the assembler uses length information on externals to allocate in
4253    data/sdata bss/sbss, thereby saving exec time.  */
4254
4255 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
4256   mips_output_external(STREAM,DECL,NAME)
4257
4258 /* This says what to print at the end of the assembly file */
4259 #undef ASM_FILE_END
4260 #define ASM_FILE_END(STREAM) mips_asm_file_end(STREAM)
4261
4262
4263 /* Play switch file games if we're optimizing the global pointer.  */
4264
4265 #undef TEXT_SECTION
4266 #define TEXT_SECTION()                                  \
4267 do {                                                    \
4268   extern FILE *asm_out_text_file;                       \
4269   if (TARGET_FILE_SWITCHING)                            \
4270     asm_out_file = asm_out_text_file;                   \
4271   fputs (TEXT_SECTION_ASM_OP, asm_out_file);            \
4272   fputc ('\n', asm_out_file);                           \
4273 } while (0)
4274
4275
4276 /* This is how to declare a function name.  The actual work of
4277    emitting the label is moved to function_prologue, so that we can
4278    get the line number correctly emitted before the .ent directive,
4279    and after any .file directives.  */
4280 /*
4281 #undef ASM_DECLARE_FUNCTION_NAME
4282 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)
4283 */
4284
4285 /* This is how to output an internal numbered label where
4286    PREFIX is the class of label and NUM is the number within the class.  */
4287
4288 #undef ASM_OUTPUT_INTERNAL_LABEL
4289 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM,PREFIX,NUM)                    \
4290   fprintf (STREAM, "%s%s%d:\n", LOCAL_LABEL_PREFIX, PREFIX, NUM)
4291
4292 /* This is how to store into the string LABEL
4293    the symbol_ref name of an internal numbered label where
4294    PREFIX is the class of label and NUM is the number within the class.
4295    This is suitable for output with `assemble_name'.  */
4296
4297 #undef ASM_GENERATE_INTERNAL_LABEL
4298 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)                   \
4299   sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long)(NUM))
4300
4301 /* This is how to output an element of a case-vector that is absolute.  */
4302
4303 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)                          \
4304   fprintf (STREAM, "\t%s\t%sL%d\n",                                     \
4305            Pmode == DImode ? ".dword" : ".word",                        \
4306            LOCAL_LABEL_PREFIX,                                          \
4307            VALUE)
4308
4309 /* This is how to output an element of a case-vector that is relative.
4310    This is used for pc-relative code (e.g. when TARGET_ABICALLS or
4311    TARGET_EMBEDDED_PIC).  */
4312
4313 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL)              \
4314 do {                                                                    \
4315   if (TARGET_MIPS16)                                                    \
4316     fprintf (STREAM, "\t.half\t%sL%d-%sL%d\n",                          \
4317              LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL);       \
4318   else if (TARGET_EMBEDDED_PIC)                                         \
4319     fprintf (STREAM, "\t%s\t%sL%d-%sLS%d\n",                            \
4320              Pmode == DImode ? ".dword" : ".word",                      \
4321              LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL);       \
4322   else if (mips_abi == ABI_32 || mips_abi == ABI_O64)                   \
4323     fprintf (STREAM, "\t%s\t%sL%d\n",                                   \
4324              Pmode == DImode ? ".gpdword" : ".gpword",                  \
4325              LOCAL_LABEL_PREFIX, VALUE);                                \
4326   else                                                                  \
4327     fprintf (STREAM, "\t%s\t%sL%d\n",                                   \
4328              Pmode == DImode ? ".dword" : ".word",                      \
4329              LOCAL_LABEL_PREFIX, VALUE);                                \
4330 } while (0)
4331
4332 /* When generating embedded PIC or mips16 code we want to put the jump
4333    table in the .text section.  In all other cases, we want to put the
4334    jump table in the .rdata section.  Unfortunately, we can't use
4335    JUMP_TABLES_IN_TEXT_SECTION, because it is not conditional.
4336    Instead, we use ASM_OUTPUT_CASE_LABEL to switch back to the .text
4337    section if appropriate.  */
4338 #undef ASM_OUTPUT_CASE_LABEL
4339 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, INSN)                  \
4340 do {                                                                    \
4341   if (TARGET_EMBEDDED_PIC || TARGET_MIPS16)                             \
4342     function_section (current_function_decl);                           \
4343   ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM);                        \
4344 } while (0)
4345
4346 /* This is how to output an assembler line
4347    that says to advance the location counter
4348    to a multiple of 2**LOG bytes.  */
4349
4350 #define ASM_OUTPUT_ALIGN(STREAM,LOG)                                    \
4351   fprintf (STREAM, "\t.align\t%d\n", (LOG))
4352
4353 /* This is how to output an assembler line to advance the location
4354    counter by SIZE bytes.  */
4355
4356 #undef ASM_OUTPUT_SKIP
4357 #define ASM_OUTPUT_SKIP(STREAM,SIZE)                                    \
4358   fprintf (STREAM, "\t.space\t%u\n", (SIZE))
4359
4360 /* This is how to output a string.  */
4361 #undef ASM_OUTPUT_ASCII
4362 #define ASM_OUTPUT_ASCII(STREAM, STRING, LEN)                           \
4363   mips_output_ascii (STREAM, STRING, LEN)
4364
4365 /* Handle certain cpp directives used in header files on sysV.  */
4366 #define SCCS_DIRECTIVE
4367
4368 /* Output #ident as a in the read-only data section.  */
4369 #undef  ASM_OUTPUT_IDENT
4370 #define ASM_OUTPUT_IDENT(FILE, STRING)                                  \
4371 {                                                                       \
4372   const char *p = STRING;                                               \
4373   int size = strlen (p) + 1;                                            \
4374   readonly_data_section ();                                             \
4375   assemble_string (p, size);                                            \
4376 }
4377 \f
4378 /* Default to -G 8 */
4379 #ifndef MIPS_DEFAULT_GVALUE
4380 #define MIPS_DEFAULT_GVALUE 8
4381 #endif
4382
4383 /* Define the strings to put out for each section in the object file.  */
4384 #define TEXT_SECTION_ASM_OP     "\t.text"       /* instructions */
4385 #define DATA_SECTION_ASM_OP     "\t.data"       /* large data */
4386 #define SDATA_SECTION_ASM_OP    "\t.sdata"      /* small data */
4387 #ifndef READONLY_DATA_SECTION_ASM_OP
4388 #define READONLY_DATA_SECTION_ASM_OP    "\t.rdata"      /* read-only data */
4389 #endif
4390 #define SMALL_DATA_SECTION      sdata_section
4391
4392 /* What other sections we support other than the normal .data/.text.  */
4393
4394 #undef EXTRA_SECTIONS
4395 #define EXTRA_SECTIONS in_sdata
4396
4397 /* Define the additional functions to select our additional sections.  */
4398
4399 /* on the MIPS it is not a good idea to put constants in the text
4400    section, since this defeats the sdata/data mechanism. This is
4401    especially true when -O is used. In this case an effort is made to
4402    address with faster (gp) register relative addressing, which can
4403    only get at sdata and sbss items (there is no stext !!)  However,
4404    if the constant is too large for sdata, and it's readonly, it
4405    will go into the .rdata section.  */
4406
4407 #undef EXTRA_SECTION_FUNCTIONS
4408 #define EXTRA_SECTION_FUNCTIONS                                         \
4409 void                                                                    \
4410 sdata_section ()                                                        \
4411 {                                                                       \
4412   if (in_section != in_sdata)                                           \
4413     {                                                                   \
4414       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
4415       in_section = in_sdata;                                            \
4416     }                                                                   \
4417 }
4418
4419 /* Given a decl node or constant node, choose the section to output it in
4420    and select that section.  */
4421
4422 #undef  TARGET_ASM_SELECT_SECTION
4423 #define TARGET_ASM_SELECT_SECTION  mips_select_section
4424 \f
4425 /* Store in OUTPUT a string (made with alloca) containing
4426    an assembler-name for a local static variable named NAME.
4427    LABELNO is an integer which is different for each call.  */
4428
4429 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)                  \
4430 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),                    \
4431   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
4432
4433 #define ASM_OUTPUT_REG_PUSH(STREAM,REGNO)                               \
4434 do                                                                      \
4435   {                                                                     \
4436     fprintf (STREAM, "\t%s\t%s,%s,8\n\t%s\t%s,0(%s)\n",                 \
4437              TARGET_64BIT ? "dsubu" : "subu",                           \
4438              reg_names[STACK_POINTER_REGNUM],                           \
4439              reg_names[STACK_POINTER_REGNUM],                           \
4440              TARGET_64BIT ? "sd" : "sw",                                \
4441              reg_names[REGNO],                                          \
4442              reg_names[STACK_POINTER_REGNUM]);                          \
4443   }                                                                     \
4444 while (0)
4445
4446 #define ASM_OUTPUT_REG_POP(STREAM,REGNO)                                \
4447 do                                                                      \
4448   {                                                                     \
4449     if (! set_noreorder)                                                \
4450       fprintf (STREAM, "\t.set\tnoreorder\n");                          \
4451                                                                         \
4452     dslots_load_total++;                                                \
4453     dslots_load_filled++;                                               \
4454     fprintf (STREAM, "\t%s\t%s,0(%s)\n\t%s\t%s,%s,8\n",                 \
4455              TARGET_64BIT ? "ld" : "lw",                                \
4456              reg_names[REGNO],                                          \
4457              reg_names[STACK_POINTER_REGNUM],                           \
4458              TARGET_64BIT ? "daddu" : "addu",                           \
4459              reg_names[STACK_POINTER_REGNUM],                           \
4460              reg_names[STACK_POINTER_REGNUM]);                          \
4461                                                                         \
4462     if (! set_noreorder)                                                \
4463       fprintf (STREAM, "\t.set\treorder\n");                            \
4464   }                                                                     \
4465 while (0)
4466
4467 /* How to start an assembler comment.
4468    The leading space is important (the mips native assembler requires it).  */
4469 #ifndef ASM_COMMENT_START
4470 #define ASM_COMMENT_START " #"
4471 #endif
4472 \f
4473
4474 /* Macros for mips-tfile.c to encapsulate stabs in ECOFF, and for
4475    and mips-tdump.c to print them out.
4476
4477    These must match the corresponding definitions in gdb/mipsread.c.
4478    Unfortunately, gcc and gdb do not currently share any directories.  */
4479
4480 #define CODE_MASK 0x8F300
4481 #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
4482 #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
4483 #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
4484
4485 \f
4486 /* Default definitions for size_t and ptrdiff_t.  */
4487
4488 #ifndef SIZE_TYPE
4489 #define SIZE_TYPE (Pmode == DImode ? "long unsigned int" : "unsigned int")
4490 #endif
4491
4492 #ifndef PTRDIFF_TYPE
4493 #define PTRDIFF_TYPE (Pmode == DImode ? "long int" : "int")
4494 #endif
4495
4496 /* See mips_expand_prologue's use of loadgp for when this should be
4497    true.  */
4498
4499 #define DONT_ACCESS_GBLS_AFTER_EPILOGUE (TARGET_ABICALLS                \
4500                                          && mips_abi != ABI_32          \
4501                                          && mips_abi != ABI_O64)
4502 \f
4503 /* In mips16 mode, we need to look through the function to check for
4504    PC relative loads that are out of range.  */
4505 #define MACHINE_DEPENDENT_REORG(X) machine_dependent_reorg (X)
4506
4507 /* We need to use a special set of functions to handle hard floating
4508    point code in mips16 mode.  */
4509
4510 #ifndef INIT_SUBTARGET_OPTABS
4511 #define INIT_SUBTARGET_OPTABS
4512 #endif
4513
4514 #define INIT_TARGET_OPTABS                                              \
4515 do                                                                      \
4516   {                                                                     \
4517     if (! TARGET_MIPS16 || ! mips16_hard_float)                         \
4518       INIT_SUBTARGET_OPTABS;                                            \
4519     else                                                                \
4520       {                                                                 \
4521         add_optab->handlers[(int) SFmode].libfunc =                     \
4522           init_one_libfunc ("__mips16_addsf3");                         \
4523         sub_optab->handlers[(int) SFmode].libfunc =                     \
4524           init_one_libfunc ("__mips16_subsf3");                         \
4525         smul_optab->handlers[(int) SFmode].libfunc =                    \
4526           init_one_libfunc ("__mips16_mulsf3");                         \
4527         sdiv_optab->handlers[(int) SFmode].libfunc =                    \
4528           init_one_libfunc ("__mips16_divsf3");                         \
4529                                                                         \
4530         eqsf2_libfunc = init_one_libfunc ("__mips16_eqsf2");            \
4531         nesf2_libfunc = init_one_libfunc ("__mips16_nesf2");            \
4532         gtsf2_libfunc = init_one_libfunc ("__mips16_gtsf2");            \
4533         gesf2_libfunc = init_one_libfunc ("__mips16_gesf2");            \
4534         ltsf2_libfunc = init_one_libfunc ("__mips16_ltsf2");            \
4535         lesf2_libfunc = init_one_libfunc ("__mips16_lesf2");            \
4536                                                                         \
4537         floatsisf_libfunc =                                             \
4538           init_one_libfunc ("__mips16_floatsisf");                      \
4539         fixsfsi_libfunc =                                               \
4540           init_one_libfunc ("__mips16_fixsfsi");                        \
4541                                                                         \
4542         if (TARGET_DOUBLE_FLOAT)                                        \
4543           {                                                             \
4544             add_optab->handlers[(int) DFmode].libfunc =                 \
4545               init_one_libfunc ("__mips16_adddf3");                     \
4546             sub_optab->handlers[(int) DFmode].libfunc =                 \
4547               init_one_libfunc ("__mips16_subdf3");                     \
4548             smul_optab->handlers[(int) DFmode].libfunc =                \
4549               init_one_libfunc ("__mips16_muldf3");                     \
4550             sdiv_optab->handlers[(int) DFmode].libfunc =                \
4551               init_one_libfunc ("__mips16_divdf3");                     \
4552                                                                         \
4553             extendsfdf2_libfunc =                                       \
4554               init_one_libfunc ("__mips16_extendsfdf2");                \
4555             truncdfsf2_libfunc =                                        \
4556               init_one_libfunc ("__mips16_truncdfsf2");                 \
4557                                                                         \
4558             eqdf2_libfunc =                                             \
4559               init_one_libfunc ("__mips16_eqdf2");                      \
4560             nedf2_libfunc =                                             \
4561               init_one_libfunc ("__mips16_nedf2");                      \
4562             gtdf2_libfunc =                                             \
4563               init_one_libfunc ("__mips16_gtdf2");                      \
4564             gedf2_libfunc =                                             \
4565               init_one_libfunc ("__mips16_gedf2");                      \
4566             ltdf2_libfunc =                                             \
4567               init_one_libfunc ("__mips16_ltdf2");                      \
4568             ledf2_libfunc =                                             \
4569               init_one_libfunc ("__mips16_ledf2");                      \
4570                                                                         \
4571             floatsidf_libfunc =                                         \
4572               init_one_libfunc ("__mips16_floatsidf");                  \
4573             fixdfsi_libfunc =                                           \
4574               init_one_libfunc ("__mips16_fixdfsi");                    \
4575           }                                                             \
4576       }                                                                 \
4577   }                                                                     \
4578 while (0)
4579
4580 #define DFMODE_NAN \
4581         unsigned short DFbignan[4] = {0x7ff7, 0xffff, 0xffff, 0xffff}; \
4582         unsigned short DFlittlenan[4] = {0xffff, 0xffff, 0xffff, 0xfff7}
4583 #define SFMODE_NAN \
4584         unsigned short SFbignan[2] = {0x7fbf, 0xffff}; \
4585         unsigned short SFlittlenan[2] = {0xffff, 0xffbf}