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