]> gcc.gnu.org Git - gcc.git/blame - gcc/config/sparc/sparc.h
(SECONDARY_MEMORY_NEEDED_RTX): Use STARTING_FRAME_OFFSET.
[gcc.git] / gcc / config / sparc / sparc.h
CommitLineData
1bb87f28
JW
1/* Definitions of target machine for GNU compiler, for Sun SPARC.
2 Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
3 Contributed by Michael Tiemann (tiemann@cygnus.com).
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21/* Note that some other tm.h files include this one and then override
22 many of the definitions that relate to assembler syntax. */
23
d95c3733
JW
24#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} %{g:-lg} \
25 %{a:/usr/lib/bb_link.o}"
1bb87f28 26
98ccf8fe 27/* Provide required defaults for linker -e and -d switches. */
1bb87f28 28
d6f04508 29#define LINK_SPEC \
197a1140 30 "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*}"
1bb87f28
JW
31
32/* Special flags to the Sun-4 assembler when using pipe for input. */
33
cf8a904b 34#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}"
1bb87f28 35
885d8175 36/* Define macros to distinguish architectures. */
9a1c7cd7 37#define CPP_SPEC "%{msparclite:-D__sparclite__} %{mv8:-D__sparc_v8__}"
885d8175 38
b1fc14e5
RS
39/* Prevent error on `-sun4' and `-target sun4' options. */
40/* This used to translate -dalign to -malign, but that is no good
41 because it can't turn off the usual meaning of making debugging dumps. */
1bb87f28 42
b1fc14e5 43#define CC1_SPEC "%{sun4:} %{target:}"
1bb87f28 44
317417a2
JW
45#if 0
46/* ??? This fails because REAL_VALUE_TYPE is `double' making it impossible to
47 represent and output `long double' constants. This causes problems during
48 a bootstrap with enquire/float.h, and hence must be disabled for now.
49 To fix, we need to implement code for TFmode just like the existing XFmode
50 support in real.[ch]. */
95dea81f
JW
51/* Sparc ABI says that long double is 4 words. */
52
d9ca49d5 53#define LONG_DOUBLE_TYPE_SIZE 128
317417a2 54#endif
d9ca49d5 55
1bb87f28 56#define PTRDIFF_TYPE "int"
1ede52a6
RS
57/* In 2.4 it should work to delete this.
58 #define SIZE_TYPE "int" */
1bb87f28
JW
59#define WCHAR_TYPE "short unsigned int"
60#define WCHAR_TYPE_SIZE 16
61
98ccf8fe
RK
62/* Omit frame pointer at high optimization levels. */
63
1bb87f28
JW
64#define OPTIMIZATION_OPTIONS(OPTIMIZE) \
65{ \
66 if (OPTIMIZE >= 2) \
67 { \
68 flag_omit_frame_pointer = 1; \
1bb87f28
JW
69 } \
70}
71
5b485d2c
JW
72/* To make profiling work with -f{pic,PIC}, we need to emit the profiling
73 code into the rtl. Also, if we are profiling, we cannot eliminate
74 the frame pointer (because the return address will get smashed). */
75
76#define OVERRIDE_OPTIONS \
77 do { if (profile_flag || profile_block_flag) \
78 flag_omit_frame_pointer = 0, flag_pic = 0; } while (0)
79
1bb87f28
JW
80/* These compiler options take an argument. We ignore -target for now. */
81
82#define WORD_SWITCH_TAKES_ARG(STR) \
3b39b94f
ILT
83 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \
84 || !strcmp (STR, "target") || !strcmp (STR, "assert"))
1bb87f28
JW
85
86/* Names to predefine in the preprocessor for this target machine. */
87
f19c1a78
JW
88/* The GCC_NEW_VARARGS macro is so that old versions of gcc can compile
89 new versions, which have an incompatible va-sparc.h file. This matters
90 because gcc does "gvarargs.h" instead of <varargs.h>, and thus gets the
91 wrong varargs file when it is compiled with a different version of gcc. */
92
93#define CPP_PREDEFINES "-Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__"
1bb87f28
JW
94
95/* Print subsidiary information on the compiler version in use. */
96
97#define TARGET_VERSION fprintf (stderr, " (sparc)");
98
99/* Generate DBX debugging information. */
100
101#define DBX_DEBUGGING_INFO
102
103/* Run-time compilation parameters selecting different hardware subsets. */
104
105extern int target_flags;
106
107/* Nonzero if we should generate code to use the fpu. */
108#define TARGET_FPU (target_flags & 1)
109
110/* Nonzero if we should use FUNCTION_EPILOGUE. Otherwise, we
111 use fast return insns, but lose some generality. */
112#define TARGET_EPILOGUE (target_flags & 2)
113
95dea81f
JW
114/* Nonzero if we should assume that double pointers might be unaligned.
115 This can happen when linking gcc compiled code with other compilers,
116 because the ABI only guarantees 4 byte alignment. */
117#define TARGET_UNALIGNED_DOUBLES (target_flags & 4)
1bb87f28 118
885d8175
JW
119/* Nonzero means that we should generate code for a v8 sparc. */
120#define TARGET_V8 (target_flags & 64)
121
122/* Nonzero means that we should generate code for a sparclite. */
123#define TARGET_SPARCLITE (target_flags & 128)
124
5b485d2c 125/* Nonzero means that we should generate code using a flat register window
9a1c7cd7
JW
126 model, i.e. no save/restore instructions are generated, in the most
127 efficient manner. This code is not compatible with normal sparc code. */
128/* This is not a user selectable option yet, because it requires changes
129 that are not yet switchable via command line arguments. */
5b485d2c
JW
130#define TARGET_FRW (target_flags & 256)
131
9a1c7cd7
JW
132/* Nonzero means that we should generate code using a flat register window
133 model, i.e. no save/restore instructions are generated, but which is
134 compatible with normal sparc code. This is the same as above, except
135 that the frame pointer is %l6 instead of %fp. This code is not as efficient
136 as TARGET_FRW, because it has one less allocatable register. */
137/* This is not a user selectable option yet, because it requires changes
138 that are not yet switchable via command line arguments. */
139#define TARGET_FRW_COMPAT (target_flags & 512)
140
1bb87f28
JW
141/* Macro to define tables used to set the flags.
142 This is a list in braces of pairs in braces,
143 each pair being { "NAME", VALUE }
144 where VALUE is the bits to set or minus the bits to clear.
145 An empty string NAME is used to identify the default VALUE. */
146
147#define TARGET_SWITCHES \
148 { {"fpu", 1}, \
26c5587d
JW
149 {"no-fpu", -1}, \
150 {"hard-float", 1}, \
1bb87f28
JW
151 {"soft-float", -1}, \
152 {"epilogue", 2}, \
153 {"no-epilogue", -2}, \
95dea81f
JW
154 {"unaligned-doubles", 4}, \
155 {"no-unaligned-doubles", -4},\
885d8175
JW
156 {"v8", 64}, \
157 {"no-v8", -64}, \
158 {"sparclite", 128}, \
a66279da 159 {"sparclite", -1}, \
885d8175 160 {"no-sparclite", -128}, \
a66279da 161 {"no-sparclite", 1}, \
9a1c7cd7
JW
162/* {"frw", 256}, */ \
163/* {"no-frw", -256}, */ \
164/* {"frw-compat", 256+512}, */ \
165/* {"no-frw-compat", -(256+512)}, */ \
b1fc14e5 166 { "", TARGET_DEFAULT}}
1bb87f28
JW
167
168#define TARGET_DEFAULT 3
169\f
170/* target machine storage layout */
171
172/* Define this if most significant bit is lowest numbered
173 in instructions that operate on numbered bit-fields. */
174#define BITS_BIG_ENDIAN 1
175
176/* Define this if most significant byte of a word is the lowest numbered. */
177/* This is true on the SPARC. */
178#define BYTES_BIG_ENDIAN 1
179
180/* Define this if most significant word of a multiword number is the lowest
181 numbered. */
182/* Doubles are stored in memory with the high order word first. This
183 matters when cross-compiling. */
184#define WORDS_BIG_ENDIAN 1
185
b4ac57ab 186/* number of bits in an addressable storage unit */
1bb87f28
JW
187#define BITS_PER_UNIT 8
188
189/* Width in bits of a "word", which is the contents of a machine register.
190 Note that this is not necessarily the width of data type `int';
191 if using 16-bit ints on a 68000, this would still be 32.
192 But on a machine with 16-bit registers, this would be 16. */
193#define BITS_PER_WORD 32
194#define MAX_BITS_PER_WORD 32
195
196/* Width of a word, in units (bytes). */
197#define UNITS_PER_WORD 4
198
199/* Width in bits of a pointer.
200 See also the macro `Pmode' defined below. */
201#define POINTER_SIZE 32
202
203/* Allocation boundary (in *bits*) for storing arguments in argument list. */
204#define PARM_BOUNDARY 32
205
206/* Boundary (in *bits*) on which stack pointer should be aligned. */
207#define STACK_BOUNDARY 64
208
10d1b70f
JW
209/* ALIGN FRAMES on double word boundaries */
210
211#define SPARC_STACK_ALIGN(LOC) (((LOC)+7) & 0xfffffff8)
212
1bb87f28
JW
213/* Allocation boundary (in *bits*) for the code of a function. */
214#define FUNCTION_BOUNDARY 32
215
216/* Alignment of field after `int : 0' in a structure. */
217#define EMPTY_FIELD_BOUNDARY 32
218
219/* Every structure's size must be a multiple of this. */
220#define STRUCTURE_SIZE_BOUNDARY 8
221
222/* A bitfield declared as `int' forces `int' alignment for the struct. */
223#define PCC_BITFIELD_TYPE_MATTERS 1
224
225/* No data type wants to be aligned rounder than this. */
226#define BIGGEST_ALIGNMENT 64
227
77a02b01
JW
228/* The best alignment to use in cases where we have a choice. */
229#define FASTEST_ALIGNMENT 64
230
1bb87f28
JW
231/* Make strings word-aligned so strcpy from constants will be faster. */
232#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
d2a8e680
RS
233 ((TREE_CODE (EXP) == STRING_CST \
234 && (ALIGN) < FASTEST_ALIGNMENT) \
235 ? FASTEST_ALIGNMENT : (ALIGN))
1bb87f28
JW
236
237/* Make arrays of chars word-aligned for the same reasons. */
238#define DATA_ALIGNMENT(TYPE, ALIGN) \
239 (TREE_CODE (TYPE) == ARRAY_TYPE \
240 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
77a02b01 241 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
1bb87f28 242
b4ac57ab 243/* Set this nonzero if move instructions will actually fail to work
1bb87f28 244 when given unaligned data. */
b4ac57ab 245#define STRICT_ALIGNMENT 1
1bb87f28
JW
246
247/* Things that must be doubleword aligned cannot go in the text section,
248 because the linker fails to align the text section enough!
249 Put them in the data section. */
250#define MAX_TEXT_ALIGN 32
251
252#define SELECT_SECTION(T,RELOC) \
253{ \
254 if (TREE_CODE (T) == VAR_DECL) \
255 { \
256 if (TREE_READONLY (T) && ! TREE_SIDE_EFFECTS (T) \
257 && DECL_ALIGN (T) <= MAX_TEXT_ALIGN \
258 && ! (flag_pic && (RELOC))) \
259 text_section (); \
260 else \
261 data_section (); \
262 } \
263 else if (TREE_CODE (T) == CONSTRUCTOR) \
264 { \
265 if (flag_pic != 0 && (RELOC) != 0) \
266 data_section (); \
267 } \
268 else if (*tree_code_type[(int) TREE_CODE (T)] == 'c') \
269 { \
270 if ((TREE_CODE (T) == STRING_CST && flag_writable_strings) \
271 || TYPE_ALIGN (TREE_TYPE (T)) > MAX_TEXT_ALIGN) \
272 data_section (); \
273 else \
274 text_section (); \
275 } \
276}
277
278/* Use text section for a constant
279 unless we need more alignment than that offers. */
280#define SELECT_RTX_SECTION(MODE, X) \
281{ \
282 if (GET_MODE_BITSIZE (MODE) <= MAX_TEXT_ALIGN \
283 && ! (flag_pic && symbolic_operand (X))) \
284 text_section (); \
285 else \
286 data_section (); \
287}
288\f
289/* Standard register usage. */
290
291/* Number of actual hardware registers.
292 The hardware registers are assigned numbers for the compiler
293 from 0 to just below FIRST_PSEUDO_REGISTER.
294 All registers that the compiler knows about must be given numbers,
295 even those that are not normally considered general registers.
296
297 SPARC has 32 integer registers and 32 floating point registers. */
298
299#define FIRST_PSEUDO_REGISTER 64
300
301/* 1 for registers that have pervasive standard uses
302 and are not available for the register allocator.
5b485d2c 303 g0 is used for the condition code and not to represent %g0, which is
1bb87f28 304 hardwired to 0, so reg 0 is *not* fixed.
d9ca49d5
JW
305 g1 through g4 are free to use as temporaries.
306 g5 through g7 are reserved for the operating system. */
1bb87f28 307#define FIXED_REGISTERS \
d9ca49d5 308 {0, 0, 0, 0, 0, 1, 1, 1, \
1bb87f28
JW
309 0, 0, 0, 0, 0, 0, 1, 0, \
310 0, 0, 0, 0, 0, 0, 0, 0, \
311 0, 0, 0, 0, 0, 0, 1, 1, \
312 \
313 0, 0, 0, 0, 0, 0, 0, 0, \
314 0, 0, 0, 0, 0, 0, 0, 0, \
315 0, 0, 0, 0, 0, 0, 0, 0, \
316 0, 0, 0, 0, 0, 0, 0, 0}
317
318/* 1 for registers not available across function calls.
319 These must include the FIXED_REGISTERS and also any
320 registers that can be used without being saved.
321 The latter must include the registers where values are returned
322 and the register where structure-value addresses are passed.
323 Aside from that, you can include as many other registers as you like. */
324#define CALL_USED_REGISTERS \
325 {1, 1, 1, 1, 1, 1, 1, 1, \
326 1, 1, 1, 1, 1, 1, 1, 1, \
327 0, 0, 0, 0, 0, 0, 0, 0, \
328 0, 0, 0, 0, 0, 0, 1, 1, \
329 \
330 1, 1, 1, 1, 1, 1, 1, 1, \
331 1, 1, 1, 1, 1, 1, 1, 1, \
332 1, 1, 1, 1, 1, 1, 1, 1, \
333 1, 1, 1, 1, 1, 1, 1, 1}
334
26c5587d
JW
335/* If !TARGET_FPU, then make the fp registers fixed so that they won't
336 be allocated. */
337
338#define CONDITIONAL_REGISTER_USAGE \
339do \
340 { \
341 if (! TARGET_FPU) \
342 { \
343 int regno; \
344 for (regno = 32; regno < 64; regno++) \
345 fixed_regs[regno] = 1; \
346 } \
347 } \
348while (0)
349
1bb87f28
JW
350/* Return number of consecutive hard regs needed starting at reg REGNO
351 to hold something of mode MODE.
352 This is ordinarily the length in words of a value of mode MODE
353 but can be less for certain modes in special long registers.
354
355 On SPARC, ordinary registers hold 32 bits worth;
356 this means both integer and floating point registers.
357
358 We use vectors to keep this information about registers. */
359
360/* How many hard registers it takes to make a register of this mode. */
361extern int hard_regno_nregs[];
362
363#define HARD_REGNO_NREGS(REGNO, MODE) \
364 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
365
366/* Value is 1 if register/mode pair is acceptable on sparc. */
367extern int hard_regno_mode_ok[FIRST_PSEUDO_REGISTER];
368
369/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
370 On SPARC, the cpu registers can hold any mode but the float registers
371 can only hold SFmode or DFmode. See sparc.c for how we
372 initialize this. */
373#define HARD_REGNO_MODE_OK(REGNO, MODE) \
374 ((hard_regno_mode_ok[REGNO] & (1<<(int)(MODE))) != 0)
375
376/* Value is 1 if it is a good idea to tie two pseudo registers
377 when one has mode MODE1 and one has mode MODE2.
378 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
379 for any hard reg, then this must be 0 for correct output. */
380#define MODES_TIEABLE_P(MODE1, MODE2) \
381 ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
382
383/* Specify the registers used for certain standard purposes.
384 The values of these macros are register numbers. */
385
386/* SPARC pc isn't overloaded on a register that the compiler knows about. */
387/* #define PC_REGNUM */
388
389/* Register to use for pushing function arguments. */
390#define STACK_POINTER_REGNUM 14
391
392/* Actual top-of-stack address is 92 greater than the contents
393 of the stack pointer register. 92 = 68 + 24. 64 bytes reserving space
394 for the ins and local registers, 4 byte for structure return address, and
395 24 bytes for the 6 register parameters. */
396#define STACK_POINTER_OFFSET FIRST_PARM_OFFSET(0)
397
398/* Base register for access to local variables of the function. */
399#define FRAME_POINTER_REGNUM 30
400
401#if 0
402/* Register that is used for the return address. */
403#define RETURN_ADDR_REGNUM 15
404#endif
405
406/* Value should be nonzero if functions must have frame pointers.
407 Zero means the frame pointer need not be set up (and parms
408 may be accessed via the stack pointer) in functions that seem suitable.
409 This is computed in `reload', in reload1.c.
410
c0524a34 411 Used in flow.c, global.c, and reload1.c. */
1bb87f28
JW
412extern int leaf_function;
413
414#define FRAME_POINTER_REQUIRED \
a72cb8ec 415 (! (leaf_function_p () && only_leaf_regs_used ()))
1bb87f28
JW
416
417/* C statement to store the difference between the frame pointer
418 and the stack pointer values immediately after the function prologue.
419
420 Note, we always pretend that this is a leaf function because if
421 it's not, there's no point in trying to eliminate the
422 frame pointer. If it is a leaf function, we guessed right! */
423#define INITIAL_FRAME_POINTER_OFFSET(VAR) \
5b485d2c
JW
424 ((VAR) = (TARGET_FRW ? sparc_frw_compute_frame_size (get_frame_size ()) \
425 : compute_frame_size (get_frame_size (), 1)))
1bb87f28
JW
426
427/* Base register for access to arguments of the function. */
428#define ARG_POINTER_REGNUM 30
429
430/* Register in which static-chain is passed to a function. */
431/* ??? */
432#define STATIC_CHAIN_REGNUM 1
433
434/* Register which holds offset table for position-independent
435 data references. */
436
437#define PIC_OFFSET_TABLE_REGNUM 23
438
439#define INITIALIZE_PIC initialize_pic ()
440#define FINALIZE_PIC finalize_pic ()
441
d9ca49d5 442/* Sparc ABI says that quad-precision floats and all structures are returned
59d7764f 443 in memory. */
d9ca49d5 444#define RETURN_IN_MEMORY(TYPE) \
e14fa9c4 445 (TYPE_MODE (TYPE) == BLKmode || TYPE_MODE (TYPE) == TFmode)
d9ca49d5 446
1bb87f28
JW
447/* Functions which return large structures get the address
448 to place the wanted value at offset 64 from the frame.
449 Must reserve 64 bytes for the in and local registers. */
450/* Used only in other #defines in this file. */
451#define STRUCT_VALUE_OFFSET 64
452
453#define STRUCT_VALUE \
454 gen_rtx (MEM, Pmode, \
455 gen_rtx (PLUS, Pmode, stack_pointer_rtx, \
456 gen_rtx (CONST_INT, VOIDmode, STRUCT_VALUE_OFFSET)))
457#define STRUCT_VALUE_INCOMING \
458 gen_rtx (MEM, Pmode, \
459 gen_rtx (PLUS, Pmode, frame_pointer_rtx, \
460 gen_rtx (CONST_INT, VOIDmode, STRUCT_VALUE_OFFSET)))
461\f
462/* Define the classes of registers for register constraints in the
463 machine description. Also define ranges of constants.
464
465 One of the classes must always be named ALL_REGS and include all hard regs.
466 If there is more than one class, another class must be named NO_REGS
467 and contain no registers.
468
469 The name GENERAL_REGS must be the name of a class (or an alias for
470 another name such as ALL_REGS). This is the class of registers
471 that is allowed by "g" or "r" in a register constraint.
472 Also, registers outside this class are allocated only when
473 instructions express preferences for them.
474
475 The classes must be numbered in nondecreasing order; that is,
476 a larger-numbered class must never be contained completely
477 in a smaller-numbered class.
478
479 For any two classes, it is very desirable that there be another
480 class that represents their union. */
481
482/* The SPARC has two kinds of registers, general and floating point. */
483
484enum reg_class { NO_REGS, GENERAL_REGS, FP_REGS, ALL_REGS, LIM_REG_CLASSES };
485
486#define N_REG_CLASSES (int) LIM_REG_CLASSES
487
488/* Give names of register classes as strings for dump file. */
489
490#define REG_CLASS_NAMES \
491 {"NO_REGS", "GENERAL_REGS", "FP_REGS", "ALL_REGS" }
492
493/* Define which registers fit in which classes.
494 This is an initializer for a vector of HARD_REG_SET
495 of length N_REG_CLASSES. */
496
497#if 0 && defined (__GNUC__)
498#define REG_CLASS_CONTENTS {0LL, 0xfffffffeLL, 0xffffffff00000000LL, 0xfffffffffffffffeLL}
499#else
500#define REG_CLASS_CONTENTS {{0, 0}, {-2, 0}, {0, -1}, {-2, -1}}
501#endif
502
503/* The same information, inverted:
504 Return the class number of the smallest class containing
505 reg number REGNO. This could be a conditional expression
506 or could index an array. */
507
508#define REGNO_REG_CLASS(REGNO) \
509 ((REGNO) >= 32 ? FP_REGS : (REGNO) == 0 ? NO_REGS : GENERAL_REGS)
510
511/* This is the order in which to allocate registers
51f0e748
JW
512 normally.
513
514 We put %f0/%f1 last among the float registers, so as to make it more
515 likely that a pseduo-register which dies in the float return register
516 will get allocated to the float return register, thus saving a move
517 instruction at the end of the function. */
1bb87f28 518#define REG_ALLOC_ORDER \
b4ac57ab
RS
519{ 8, 9, 10, 11, 12, 13, 2, 3, \
520 15, 16, 17, 18, 19, 20, 21, 22, \
521 23, 24, 25, 26, 27, 28, 29, 31, \
51f0e748 522 34, 35, 36, 37, 38, 39, \
1bb87f28
JW
523 40, 41, 42, 43, 44, 45, 46, 47, \
524 48, 49, 50, 51, 52, 53, 54, 55, \
525 56, 57, 58, 59, 60, 61, 62, 63, \
51f0e748 526 32, 33, \
4b69d2a3 527 1, 4, 5, 6, 7, 0, 14, 30}
1bb87f28
JW
528
529/* This is the order in which to allocate registers for
530 leaf functions. If all registers can fit in the "i" registers,
531 then we have the possibility of having a leaf function. */
532#define REG_LEAF_ALLOC_ORDER \
533{ 2, 3, 24, 25, 26, 27, 28, 29, \
534 15, 8, 9, 10, 11, 12, 13, \
535 16, 17, 18, 19, 20, 21, 22, 23, \
51f0e748 536 34, 35, 36, 37, 38, 39, \
1bb87f28
JW
537 40, 41, 42, 43, 44, 45, 46, 47, \
538 48, 49, 50, 51, 52, 53, 54, 55, \
539 56, 57, 58, 59, 60, 61, 62, 63, \
51f0e748 540 32, 33, \
4b69d2a3 541 1, 4, 5, 6, 7, 0, 14, 30, 31}
1bb87f28
JW
542
543#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()
544
545#define LEAF_REGISTERS \
546{ 1, 1, 1, 1, 1, 1, 1, 1, \
547 0, 0, 0, 0, 0, 0, 1, 0, \
548 0, 0, 0, 0, 0, 0, 0, 0, \
549 1, 1, 1, 1, 1, 1, 0, 1, \
550 1, 1, 1, 1, 1, 1, 1, 1, \
551 1, 1, 1, 1, 1, 1, 1, 1, \
552 1, 1, 1, 1, 1, 1, 1, 1, \
4b69d2a3 553 1, 1, 1, 1, 1, 1, 1, 1}
1bb87f28
JW
554
555extern char leaf_reg_remap[];
556#define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO])
557extern char leaf_reg_backmap[];
558#define LEAF_REG_BACKMAP(REGNO) (leaf_reg_backmap[REGNO])
559
1bb87f28
JW
560/* The class value for index registers, and the one for base regs. */
561#define INDEX_REG_CLASS GENERAL_REGS
562#define BASE_REG_CLASS GENERAL_REGS
563
564/* Get reg_class from a letter such as appears in the machine description. */
565
566#define REG_CLASS_FROM_LETTER(C) \
567 ((C) == 'f' ? FP_REGS : (C) == 'r' ? GENERAL_REGS : NO_REGS)
568
569/* The letters I, J, K, L and M in a register constraint string
570 can be used to stand for particular ranges of immediate operands.
571 This macro defines what the ranges are.
572 C is the letter, and VALUE is a constant value.
573 Return 1 if VALUE is in the range specified by C.
574
575 For SPARC, `I' is used for the range of constants an insn
576 can actually contain.
577 `J' is used for the range which is just zero (since that is R0).
9ad2c692 578 `K' is used for constants which can be loaded with a single sethi insn. */
1bb87f28
JW
579
580#define SMALL_INT(X) ((unsigned) (INTVAL (X) + 0x1000) < 0x2000)
581
582#define CONST_OK_FOR_LETTER_P(VALUE, C) \
583 ((C) == 'I' ? (unsigned) ((VALUE) + 0x1000) < 0x2000 \
584 : (C) == 'J' ? (VALUE) == 0 \
585 : (C) == 'K' ? ((VALUE) & 0x3ff) == 0 \
586 : 0)
587
588/* Similar, but for floating constants, and defining letters G and H.
589 Here VALUE is the CONST_DOUBLE rtx itself. */
590
591#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
592 ((C) == 'G' ? CONST_DOUBLE_HIGH (VALUE) == 0 \
593 && CONST_DOUBLE_LOW (VALUE) == 0 \
594 : (C) == 'H' ? arith_double_operand (VALUE, DImode) \
595 : 0)
596
597/* Given an rtx X being reloaded into a reg required to be
598 in class CLASS, return the class of reg to actually use.
599 In general this is just CLASS; but on some machines
600 in some cases it is preferable to use a more restrictive class. */
2b9a9aea
JW
601/* We can't load constants into FP registers. We can't load any FP constant
602 if an 'E' constraint fails to match it. */
603#define PREFERRED_RELOAD_CLASS(X,CLASS) \
604 (CONSTANT_P (X) \
605 && ((CLASS) == FP_REGS \
606 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
607 && (HOST_FLOAT_FORMAT != IEEE_FLOAT_FORMAT \
608 || HOST_BITS_PER_INT != BITS_PER_WORD))) \
609 ? NO_REGS : (CLASS))
1bb87f28
JW
610
611/* Return the register class of a scratch register needed to load IN into
612 a register of class CLASS in MODE.
613
614 On the SPARC, when PIC, we need a temporary when loading some addresses
ae51bd97 615 into a register.
1bb87f28 616
ae51bd97
JW
617 Also, we need a temporary when loading/storing a HImode/QImode value
618 between memory and the FPU registers. This can happen when combine puts
619 a paradoxical subreg in a float/fix conversion insn. */
620
621#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, IN) \
622 (flag_pic && pic_address_needs_scratch (IN) ? GENERAL_REGS \
623 : ((CLASS) == FP_REGS && ((MODE) == HImode || (MODE) == QImode)\
624 && (GET_CODE (IN) == MEM \
625 || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
626 && true_regnum (IN) == -1))) ? GENERAL_REGS : NO_REGS)
627
628#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, IN) \
629 ((CLASS) == FP_REGS && ((MODE) == HImode || (MODE) == QImode) \
630 && (GET_CODE (IN) == MEM \
631 || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
632 && true_regnum (IN) == -1)) ? GENERAL_REGS : NO_REGS)
1bb87f28 633
b924cef0
JW
634/* On SPARC it is not possible to directly move data between
635 GENERAL_REGS and FP_REGS. */
636#define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
ae51bd97
JW
637 (((CLASS1) == FP_REGS && (CLASS2) == GENERAL_REGS) \
638 || ((CLASS1) == GENERAL_REGS && (CLASS2) == FP_REGS))
b924cef0 639
fe1f7f24
JW
640/* Return the stack location to use for secondary memory needed reloads. */
641#define SECONDARY_MEMORY_NEEDED_RTX(MODE) \
15f67e06
JW
642 gen_rtx (MEM, MODE, gen_rtx (PLUS, Pmode, frame_pointer_rtx, \
643 GEN_INT (STARTING_FRAME_OFFSET)))
fe1f7f24 644
1bb87f28
JW
645/* Return the maximum number of consecutive registers
646 needed to represent mode MODE in a register of class CLASS. */
647/* On SPARC, this is the size of MODE in words. */
648#define CLASS_MAX_NREGS(CLASS, MODE) \
649 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
650\f
651/* Stack layout; function entry, exit and calling. */
652
653/* Define the number of register that can hold parameters.
654 These two macros are used only in other macro definitions below. */
655#define NPARM_REGS 6
656
657/* Define this if pushing a word on the stack
658 makes the stack pointer a smaller address. */
659#define STACK_GROWS_DOWNWARD
660
661/* Define this if the nominal address of the stack frame
662 is at the high-address end of the local variables;
663 that is, each additional local variable allocated
664 goes at a more negative offset in the frame. */
665#define FRAME_GROWS_DOWNWARD
666
667/* Offset within stack frame to start allocating local variables at.
668 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
669 first local allocated. Otherwise, it is the offset to the BEGINNING
670 of the first local allocated. */
15f67e06
JW
671/* This is 16 to allow space for one TFmode floating point value. */
672#define STARTING_FRAME_OFFSET (-16)
1bb87f28
JW
673
674/* If we generate an insn to push BYTES bytes,
675 this says how many the stack pointer really advances by.
676 On SPARC, don't define this because there are no push insns. */
677/* #define PUSH_ROUNDING(BYTES) */
678
679/* Offset of first parameter from the argument pointer register value.
680 This is 64 for the ins and locals, plus 4 for the struct-return reg
95dea81f
JW
681 even if this function isn't going to use it. */
682#define FIRST_PARM_OFFSET(FNDECL) (STRUCT_VALUE_OFFSET + UNITS_PER_WORD)
1bb87f28
JW
683
684/* When a parameter is passed in a register, stack space is still
685 allocated for it. */
686#define REG_PARM_STACK_SPACE(DECL) (NPARM_REGS * UNITS_PER_WORD)
687
688/* Keep the stack pointer constant throughout the function.
b4ac57ab 689 This is both an optimization and a necessity: longjmp
1bb87f28
JW
690 doesn't behave itself when the stack pointer moves within
691 the function! */
692#define ACCUMULATE_OUTGOING_ARGS
693
694/* Value is the number of bytes of arguments automatically
695 popped when returning from a subroutine call.
696 FUNTYPE is the data type of the function (as a tree),
697 or for a library call it is an identifier node for the subroutine name.
698 SIZE is the number of bytes of arguments passed on the stack. */
699
700#define RETURN_POPS_ARGS(FUNTYPE,SIZE) 0
701
5b485d2c
JW
702/* Some subroutine macros specific to this machine.
703 When !TARGET_FPU, put float return values in the general registers,
704 since we don't have any fp registers. */
1bb87f28 705#define BASE_RETURN_VALUE_REG(MODE) \
26c5587d 706 (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 : 8)
1bb87f28 707#define BASE_OUTGOING_VALUE_REG(MODE) \
5b485d2c
JW
708 (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 \
709 : (TARGET_FRW ? 8 : 24))
1bb87f28 710#define BASE_PASSING_ARG_REG(MODE) (8)
5b485d2c 711#define BASE_INCOMING_ARG_REG(MODE) (TARGET_FRW ? 8 : 24)
1bb87f28 712
92ea370b
TW
713/* Define this macro if the target machine has "register windows". This
714 C expression returns the register number as seen by the called function
715 corresponding to register number OUT as seen by the calling function.
716 Return OUT if register number OUT is not an outbound register. */
717
718#define INCOMING_REGNO(OUT) \
719 ((TARGET_FRW || (OUT) < 8 || (OUT) > 15) ? (OUT) : (OUT) + 16)
720
721/* Define this macro if the target machine has "register windows". This
722 C expression returns the register number as seen by the calling function
723 corresponding to register number IN as seen by the called function.
724 Return IN if register number IN is not an inbound register. */
725
726#define OUTGOING_REGNO(IN) \
727 ((TARGET_FRW || (IN) < 24 || (IN) > 31) ? (IN) : (IN) - 16)
728
1bb87f28
JW
729/* Define how to find the value returned by a function.
730 VALTYPE is the data type of the value (as a tree).
731 If the precise function being called is known, FUNC is its FUNCTION_DECL;
732 otherwise, FUNC is 0. */
733
734/* On SPARC the value is found in the first "output" register. */
735
736#define FUNCTION_VALUE(VALTYPE, FUNC) \
737 gen_rtx (REG, TYPE_MODE (VALTYPE), BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
738
739/* But the called function leaves it in the first "input" register. */
740
741#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
742 gen_rtx (REG, TYPE_MODE (VALTYPE), BASE_OUTGOING_VALUE_REG (TYPE_MODE (VALTYPE)))
743
744/* Define how to find the value returned by a library function
745 assuming the value has mode MODE. */
746
747#define LIBCALL_VALUE(MODE) \
748 gen_rtx (REG, MODE, BASE_RETURN_VALUE_REG (MODE))
749
750/* 1 if N is a possible register number for a function value
751 as seen by the caller.
752 On SPARC, the first "output" reg is used for integer values,
753 and the first floating point register is used for floating point values. */
754
755#define FUNCTION_VALUE_REGNO_P(N) ((N) == 8 || (N) == 32)
756
757/* 1 if N is a possible register number for function argument passing.
758 On SPARC, these are the "output" registers. */
759
760#define FUNCTION_ARG_REGNO_P(N) ((N) < 14 && (N) > 7)
761\f
762/* Define a data type for recording info about an argument list
763 during the scan of that argument list. This data type should
764 hold all necessary information about the function itself
765 and about the args processed so far, enough to enable macros
766 such as FUNCTION_ARG to determine where the next arg should go.
767
768 On SPARC, this is a single integer, which is a number of words
769 of arguments scanned so far (including the invisible argument,
770 if any, which holds the structure-value-address).
771 Thus 7 or more means all following args should go on the stack. */
772
773#define CUMULATIVE_ARGS int
774
775#define ROUND_ADVANCE(SIZE) \
b1fc14e5
RS
776 ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
777
1bb87f28
JW
778/* Initialize a variable CUM of type CUMULATIVE_ARGS
779 for a call to a function whose data type is FNTYPE.
780 For a library call, FNTYPE is 0.
781
782 On SPARC, the offset always starts at 0: the first parm reg is always
783 the same reg. */
784
785#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) ((CUM) = 0)
786
787/* Update the data in CUM to advance over an argument
788 of mode MODE and data type TYPE.
789 (TYPE is null for libcalls where that information may not be available.) */
790
791#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
95dea81f
JW
792 ((CUM) += ((MODE) != BLKmode \
793 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
794 : ROUND_ADVANCE (int_size_in_bytes (TYPE))))
1bb87f28
JW
795
796/* Determine where to put an argument to a function.
797 Value is zero to push the argument on the stack,
798 or a hard register in which to store the argument.
799
800 MODE is the argument's machine mode.
801 TYPE is the data type of the argument (as a tree).
802 This is null for libcalls where that information may
803 not be available.
804 CUM is a variable of type CUMULATIVE_ARGS which gives info about
805 the preceding args and about the function being called.
806 NAMED is nonzero if this argument is a named parameter
807 (otherwise it is an extra parameter matching an ellipsis). */
808
809/* On SPARC the first six args are normally in registers
810 and the rest are pushed. Any arg that starts within the first 6 words
811 is at least partially passed in a register unless its data type forbids. */
812
813#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
95dea81f 814((CUM) < NPARM_REGS \
1bb87f28 815 && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
b1fc14e5
RS
816 && ((TYPE)==0 || (MODE) != BLKmode \
817 || (TYPE_ALIGN ((TYPE)) % PARM_BOUNDARY == 0)) \
95dea81f 818 ? gen_rtx (REG, (MODE), (BASE_PASSING_ARG_REG (MODE) + (CUM))) \
b1fc14e5 819 : 0)
1bb87f28
JW
820
821/* Define where a function finds its arguments.
822 This is different from FUNCTION_ARG because of register windows. */
823
824#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
95dea81f 825((CUM) < NPARM_REGS \
1bb87f28 826 && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
b1fc14e5
RS
827 && ((TYPE)==0 || (MODE) != BLKmode \
828 || (TYPE_ALIGN ((TYPE)) % PARM_BOUNDARY == 0)) \
95dea81f 829 ? gen_rtx (REG, (MODE), (BASE_INCOMING_ARG_REG (MODE) + (CUM))) \
b1fc14e5 830 : 0)
1bb87f28
JW
831
832/* For an arg passed partly in registers and partly in memory,
833 this is the number of registers used.
834 For args passed entirely in registers or entirely in memory, zero.
835 Any arg that starts in the first 6 regs but won't entirely fit in them
836 needs partial registers on the Sparc. */
837
838#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
95dea81f 839 ((CUM) < NPARM_REGS \
1bb87f28 840 && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
b1fc14e5
RS
841 && ((TYPE)==0 || (MODE) != BLKmode \
842 || (TYPE_ALIGN ((TYPE)) % PARM_BOUNDARY == 0)) \
95dea81f
JW
843 && ((CUM) + ((MODE) == BLKmode \
844 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
845 : ROUND_ADVANCE (GET_MODE_SIZE (MODE))) - NPARM_REGS > 0)\
846 ? (NPARM_REGS - (CUM)) \
1bb87f28
JW
847 : 0)
848
d9ca49d5
JW
849/* The SPARC ABI stipulates passing struct arguments (of any size) and
850 quad-precision floats by invisible reference. */
1bb87f28 851#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
d9ca49d5
JW
852 ((TYPE && (TREE_CODE (TYPE) == RECORD_TYPE \
853 || TREE_CODE (TYPE) == UNION_TYPE)) \
854 || (MODE == TFmode))
1bb87f28
JW
855
856/* Define the information needed to generate branch and scc insns. This is
857 stored from the compare operation. Note that we can't use "rtx" here
858 since it hasn't been defined! */
859
860extern struct rtx_def *sparc_compare_op0, *sparc_compare_op1;
861
862/* Define the function that build the compare insn for scc and bcc. */
863
864extern struct rtx_def *gen_compare_reg ();
865\f
4b69d2a3
RS
866/* Generate the special assembly code needed to tell the assembler whatever
867 it might need to know about the return value of a function.
868
869 For Sparc assemblers, we need to output a .proc pseudo-op which conveys
870 information to the assembler relating to peephole optimization (done in
871 the assembler). */
872
873#define ASM_DECLARE_RESULT(FILE, RESULT) \
874 fprintf ((FILE), "\t.proc\t0%o\n", sparc_type_code (TREE_TYPE (RESULT)))
875
1bb87f28
JW
876/* Output the label for a function definition. */
877
4b69d2a3
RS
878#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
879do { \
880 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
881 ASM_OUTPUT_LABEL (FILE, NAME); \
882} while (0)
1bb87f28
JW
883
884/* Two views of the size of the current frame. */
885extern int actual_fsize;
886extern int apparent_fsize;
887
888/* This macro generates the assembly code for function entry.
889 FILE is a stdio stream to output the code to.
890 SIZE is an int: how many units of temporary storage to allocate.
891 Refer to the array `regs_ever_live' to determine which registers
892 to save; `regs_ever_live[I]' is nonzero if register number I
893 is ever used in the function. This macro is responsible for
894 knowing which registers should not be saved even if used. */
895
896/* On SPARC, move-double insns between fpu and cpu need an 8-byte block
897 of memory. If any fpu reg is used in the function, we allocate
898 such a block here, at the bottom of the frame, just in case it's needed.
899
900 If this function is a leaf procedure, then we may choose not
901 to do a "save" insn. The decision about whether or not
902 to do this is made in regclass.c. */
903
904#define FUNCTION_PROLOGUE(FILE, SIZE) \
5b485d2c
JW
905 (TARGET_FRW ? sparc_frw_output_function_prologue (FILE, SIZE, leaf_function)\
906 : output_function_prologue (FILE, SIZE, leaf_function))
1bb87f28
JW
907
908/* Output assembler code to FILE to increment profiler label # LABELNO
909 for profiling a function entry. */
910
d2a8e680
RS
911#define FUNCTION_PROFILER(FILE, LABELNO) \
912 do { \
913 fputs ("\tsethi %hi(", (FILE)); \
914 ASM_OUTPUT_INTERNAL_LABELREF (FILE, "LP", LABELNO); \
915 fputs ("),%o0\n\tcall mcount\n\tor %lo(", (FILE)); \
916 ASM_OUTPUT_INTERNAL_LABELREF (FILE, "LP", LABELNO); \
917 fputs ("),%o0,%o0\n", (FILE)); \
918 } while (0)
1bb87f28
JW
919
920/* Output assembler code to FILE to initialize this source file's
921 basic block profiling info, if that has not already been done. */
d2a8e680
RS
922/* FIXME -- this does not parameterize how it generates labels (like the
923 above FUNCTION_PROFILER). Broken on Solaris-2. --gnu@cygnus.com */
1bb87f28
JW
924
925#define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \
926 fprintf (FILE, "\tsethi %%hi(LPBX0),%%o0\n\tld [%%lo(LPBX0)+%%o0],%%o1\n\ttst %%o1\n\tbne LPY%d\n\tadd %%o0,%%lo(LPBX0),%%o0\n\tcall ___bb_init_func\n\tnop\nLPY%d:\n", \
927 (LABELNO), (LABELNO))
928
929/* Output assembler code to FILE to increment the entry-count for
930 the BLOCKNO'th basic block in this source file. */
931
932#define BLOCK_PROFILER(FILE, BLOCKNO) \
933{ \
934 int blockn = (BLOCKNO); \
935 fprintf (FILE, "\tsethi %%hi(LPBX2+%d),%%g1\n\tld [%%lo(LPBX2+%d)+%%g1],%%g2\n\
936\tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(LPBX2+%d)+%%g1]\n", \
937 4 * blockn, 4 * blockn, 4 * blockn); \
938}
939
1bb87f28
JW
940/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
941 the stack pointer does not matter. The value is tested only in
942 functions that have frame pointers.
943 No definition is equivalent to always zero. */
944
945extern int current_function_calls_alloca;
946extern int current_function_outgoing_args_size;
947
948#define EXIT_IGNORE_STACK \
949 (get_frame_size () != 0 \
950 || current_function_calls_alloca || current_function_outgoing_args_size)
951
952/* This macro generates the assembly code for function exit,
953 on machines that need it. If FUNCTION_EPILOGUE is not defined
954 then individual return instructions are generated for each
955 return statement. Args are same as for FUNCTION_PROLOGUE.
956
957 The function epilogue should not depend on the current stack pointer!
958 It should use the frame pointer only. This is mandatory because
959 of alloca; we also take advantage of it to omit stack adjustments
960 before returning. */
961
962/* This declaration is needed due to traditional/ANSI
963 incompatibilities which cannot be #ifdefed away
964 because they occur inside of macros. Sigh. */
965extern union tree_node *current_function_decl;
966
967#define FUNCTION_EPILOGUE(FILE, SIZE) \
5b485d2c
JW
968 (TARGET_FRW ? sparc_frw_output_function_epilogue (FILE, SIZE, leaf_function)\
969 : output_function_epilogue (FILE, SIZE, leaf_function))
1bb87f28 970
5b485d2c
JW
971#define DELAY_SLOTS_FOR_EPILOGUE \
972 (TARGET_FRW ? sparc_frw_epilogue_delay_slots () : 1)
1bb87f28 973#define ELIGIBLE_FOR_EPILOGUE_DELAY(trial, slots_filled) \
5b485d2c
JW
974 (TARGET_FRW ? sparc_frw_eligible_for_epilogue_delay (trial, slots_filled) \
975 : eligible_for_epilogue_delay (trial, slots_filled))
1bb87f28
JW
976
977/* Output assembler code for a block containing the constant parts
978 of a trampoline, leaving space for the variable parts. */
979
980/* On the sparc, the trampoline contains five instructions:
981 sethi #TOP_OF_FUNCTION,%g2
982 or #BOTTOM_OF_FUNCTION,%g2,%g2
983 sethi #TOP_OF_STATIC,%g1
984 jmp g2
985 or #BOTTOM_OF_STATIC,%g1,%g1 */
986#define TRAMPOLINE_TEMPLATE(FILE) \
987{ \
988 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
989 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
990 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
991 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x81C08000)); \
992 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
993}
994
995/* Length in units of the trampoline for entering a nested function. */
996
997#define TRAMPOLINE_SIZE 20
998
999/* Emit RTL insns to initialize the variable parts of a trampoline.
1000 FNADDR is an RTX for the address of the function's pure code.
1001 CXT is an RTX for the static chain value for the function.
1002
1003 This takes 16 insns: 2 shifts & 2 ands (to split up addresses), 4 sethi
1004 (to load in opcodes), 4 iors (to merge address and opcodes), and 4 writes
1005 (to store insns). This is a bit excessive. Perhaps a different
1006 mechanism would be better here. */
1007
1008#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1009{ \
1010 rtx high_cxt = expand_shift (RSHIFT_EXPR, SImode, CXT, \
1011 size_int (10), 0, 1); \
1012 rtx high_fn = expand_shift (RSHIFT_EXPR, SImode, FNADDR, \
1013 size_int (10), 0, 1); \
1014 rtx low_cxt = expand_and (CXT, gen_rtx (CONST_INT, VOIDmode, 0x3ff), 0); \
1015 rtx low_fn = expand_and (FNADDR, gen_rtx (CONST_INT, VOIDmode, 0x3ff), 0); \
1016 rtx g1_sethi = gen_rtx (HIGH, SImode, \
1017 gen_rtx (CONST_INT, VOIDmode, 0x03000000)); \
1018 rtx g2_sethi = gen_rtx (HIGH, SImode, \
1019 gen_rtx (CONST_INT, VOIDmode, 0x05000000)); \
1020 rtx g1_ori = gen_rtx (HIGH, SImode, \
1021 gen_rtx (CONST_INT, VOIDmode, 0x82106000)); \
1022 rtx g2_ori = gen_rtx (HIGH, SImode, \
1023 gen_rtx (CONST_INT, VOIDmode, 0x8410A000)); \
1024 rtx tem = gen_reg_rtx (SImode); \
1025 emit_move_insn (tem, g2_sethi); \
1026 emit_insn (gen_iorsi3 (high_fn, high_fn, tem)); \
1027 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 0)), high_fn);\
1028 emit_move_insn (tem, g2_ori); \
1029 emit_insn (gen_iorsi3 (low_fn, low_fn, tem)); \
1030 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 4)), low_fn);\
1031 emit_move_insn (tem, g1_sethi); \
1032 emit_insn (gen_iorsi3 (high_cxt, high_cxt, tem)); \
1033 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 8)), high_cxt);\
1034 emit_move_insn (tem, g1_ori); \
1035 emit_insn (gen_iorsi3 (low_cxt, low_cxt, tem)); \
1036 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 16)), low_cxt);\
1037}
1038
9a1c7cd7
JW
1039/* Generate necessary RTL for __builtin_saveregs().
1040 ARGLIST is the argument list; see expr.c. */
1041extern struct rtx_def *sparc_builtin_saveregs ();
1042#define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sparc_builtin_saveregs (ARGLIST)
953fe179
JW
1043
1044/* Generate RTL to flush the register windows so as to make arbitrary frames
1045 available. */
1046#define SETUP_FRAME_ADDRESSES() \
1047 emit_insn (gen_flush_register_windows ())
1048
1049/* Given an rtx for the address of a frame,
1050 return an rtx for the address of the word in the frame
1051 that holds the dynamic chain--the previous frame's address. */
1052#define DYNAMIC_CHAIN_ADDRESS(frame) \
1053 gen_rtx (PLUS, Pmode, frame, gen_rtx (CONST_INT, VOIDmode, 56))
1054
1055/* The return address isn't on the stack, it is in a register, so we can't
1056 access it from the current frame pointer. We can access it from the
1057 previous frame pointer though by reading a value from the register window
1058 save area. */
1059#define RETURN_ADDR_IN_PREVIOUS_FRAME
1060
1061/* The current return address is in %i7. The return address of anything
1062 farther back is in the register window save area at [%fp+60]. */
1063/* ??? This ignores the fact that the actual return address is +8 for normal
1064 returns, and +12 for structure returns. */
1065#define RETURN_ADDR_RTX(count, frame) \
1066 ((count == -1) \
1067 ? gen_rtx (REG, Pmode, 31) \
1068 : copy_to_reg (gen_rtx (MEM, Pmode, \
1069 memory_address (Pmode, plus_constant (frame, 60)))))
1bb87f28
JW
1070\f
1071/* Addressing modes, and classification of registers for them. */
1072
1073/* #define HAVE_POST_INCREMENT */
1074/* #define HAVE_POST_DECREMENT */
1075
1076/* #define HAVE_PRE_DECREMENT */
1077/* #define HAVE_PRE_INCREMENT */
1078
1079/* Macros to check register numbers against specific register classes. */
1080
1081/* These assume that REGNO is a hard or pseudo reg number.
1082 They give nonzero only if REGNO is a hard reg of the suitable class
1083 or a pseudo reg currently allocated to a suitable hard reg.
1084 Since they use reg_renumber, they are safe only once reg_renumber
1085 has been allocated, which happens in local-alloc.c. */
1086
1087#define REGNO_OK_FOR_INDEX_P(REGNO) \
1088(((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32) && (REGNO) != 0)
1089#define REGNO_OK_FOR_BASE_P(REGNO) \
1090(((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32) && (REGNO) != 0)
1091#define REGNO_OK_FOR_FP_P(REGNO) \
1092(((REGNO) ^ 0x20) < 32 \
1093 || (((REGNO) != 0) && (unsigned) (reg_renumber[REGNO] ^ 0x20) < 32))
1094
1095/* Now macros that check whether X is a register and also,
1096 strictly, whether it is in a specified class.
1097
1098 These macros are specific to the SPARC, and may be used only
1099 in code for printing assembler insns and in conditions for
1100 define_optimization. */
1101
1102/* 1 if X is an fp register. */
1103
1104#define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
1105\f
1106/* Maximum number of registers that can appear in a valid memory address. */
1107
1108#define MAX_REGS_PER_ADDRESS 2
1109
1110/* Recognize any constant value that is a valid address. */
1111
6eff269e
BK
1112#define CONSTANT_ADDRESS_P(X) \
1113 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
1114 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \
1115 || GET_CODE (X) == HIGH)
1bb87f28
JW
1116
1117/* Nonzero if the constant value X is a legitimate general operand.
1118 Anything can be made to work except floating point constants. */
1119
1120#define LEGITIMATE_CONSTANT_P(X) \
1121 (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode)
1122
1123/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1124 and check its validity for a certain class.
1125 We have two alternate definitions for each of them.
1126 The usual definition accepts all pseudo regs; the other rejects
1127 them unless they have been allocated suitable hard regs.
1128 The symbol REG_OK_STRICT causes the latter definition to be used.
1129
1130 Most source files want to accept pseudo regs in the hope that
1131 they will get allocated to the class that the insn wants them to be in.
1132 Source files for reload pass need to be strict.
1133 After reload, it makes no difference, since pseudo regs have
1134 been eliminated by then. */
1135
1136/* Optional extra constraints for this machine. Borrowed from romp.h.
1137
1138 For the SPARC, `Q' means that this is a memory operand but not a
1139 symbolic memory operand. Note that an unassigned pseudo register
1140 is such a memory operand. Needed because reload will generate
1141 these things in insns and then not re-recognize the insns, causing
1142 constrain_operands to fail.
1143
1bb87f28
JW
1144 `S' handles constraints for calls. */
1145
1146#ifndef REG_OK_STRICT
1147
1148/* Nonzero if X is a hard reg that can be used as an index
1149 or if it is a pseudo reg. */
1150#define REG_OK_FOR_INDEX_P(X) (((unsigned) REGNO (X)) - 32 >= 32 && REGNO (X) != 0)
1151/* Nonzero if X is a hard reg that can be used as a base reg
1152 or if it is a pseudo reg. */
1153#define REG_OK_FOR_BASE_P(X) (((unsigned) REGNO (X)) - 32 >= 32 && REGNO (X) != 0)
1154
1155#define EXTRA_CONSTRAINT(OP, C) \
db5e449c
RS
1156 ((C) == 'Q' \
1157 ? ((GET_CODE (OP) == MEM \
1158 && memory_address_p (GET_MODE (OP), XEXP (OP, 0)) \
1159 && ! symbolic_memory_operand (OP, VOIDmode)) \
1160 || (reload_in_progress && GET_CODE (OP) == REG \
1161 && REGNO (OP) >= FIRST_PSEUDO_REGISTER)) \
db5e449c
RS
1162 : (C) == 'S' \
1163 ? (CONSTANT_P (OP) || memory_address_p (Pmode, OP)) \
19858600
JL
1164 : (C) == 'T' \
1165 ? (mem_aligned_8 (OP)) \
1166 : (C) == 'U' \
1167 ? (register_ok_for_ldd (OP)) \
db5e449c 1168 : 0)
19858600 1169
1bb87f28
JW
1170#else
1171
1172/* Nonzero if X is a hard reg that can be used as an index. */
1173#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1174/* Nonzero if X is a hard reg that can be used as a base reg. */
1175#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1176
1177#define EXTRA_CONSTRAINT(OP, C) \
9ad2c692
JW
1178 ((C) == 'Q' \
1179 ? (GET_CODE (OP) == REG \
1180 ? (REGNO (OP) >= FIRST_PSEUDO_REGISTER \
1181 && reg_renumber[REGNO (OP)] < 0) \
1182 : GET_CODE (OP) == MEM) \
1183 : (C) == 'S' \
1184 ? (CONSTANT_P (OP) \
1185 || (GET_CODE (OP) == REG && reg_renumber[REGNO (OP)] > 0) \
1186 || strict_memory_address_p (Pmode, OP)) \
1187 : (C) == 'T' \
b165d471 1188 ? mem_aligned_8 (OP) && strict_memory_address_p (Pmode, XEXP (OP, 0)) \
9ad2c692 1189 : (C) == 'U' \
b165d471
JW
1190 ? (GET_CODE (OP) == REG \
1191 && (REGNO (OP) < FIRST_PSEUDO_REGISTER \
1192 || reg_renumber[REGNO (OP)] > 0) \
1193 && register_ok_for_ldd (OP)) : 0)
1bb87f28
JW
1194#endif
1195\f
1196/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1197 that is a valid memory address for an instruction.
1198 The MODE argument is the machine mode for the MEM expression
1199 that wants to use this address.
1200
1201 On SPARC, the actual legitimate addresses must be REG+REG or REG+SMALLINT
1202 ordinarily. This changes a bit when generating PIC.
1203
1204 If you change this, execute "rm explow.o recog.o reload.o". */
1205
bec2e359
JW
1206#define RTX_OK_FOR_BASE_P(X) \
1207 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
1208 || (GET_CODE (X) == SUBREG \
1209 && GET_CODE (SUBREG_REG (X)) == REG \
1210 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
1211
1212#define RTX_OK_FOR_INDEX_P(X) \
1213 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
1214 || (GET_CODE (X) == SUBREG \
1215 && GET_CODE (SUBREG_REG (X)) == REG \
1216 && REG_OK_FOR_INDEX_P (SUBREG_REG (X))))
1217
1218#define RTX_OK_FOR_OFFSET_P(X) \
1219 (GET_CODE (X) == CONST_INT && INTVAL (X) >= -0x1000 && INTVAL (X) < 0x1000)
1220
1bb87f28 1221#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
bec2e359
JW
1222{ if (RTX_OK_FOR_BASE_P (X)) \
1223 goto ADDR; \
1bb87f28
JW
1224 else if (GET_CODE (X) == PLUS) \
1225 { \
bec2e359
JW
1226 register rtx op0 = XEXP (X, 0); \
1227 register rtx op1 = XEXP (X, 1); \
1228 if (flag_pic && op0 == pic_offset_table_rtx) \
1bb87f28 1229 { \
bec2e359 1230 if (RTX_OK_FOR_BASE_P (op1)) \
1bb87f28
JW
1231 goto ADDR; \
1232 else if (flag_pic == 1 \
bec2e359
JW
1233 && GET_CODE (op1) != REG \
1234 && GET_CODE (op1) != LO_SUM \
1235 && GET_CODE (op1) != MEM) \
1bb87f28
JW
1236 goto ADDR; \
1237 } \
bec2e359 1238 else if (RTX_OK_FOR_BASE_P (op0)) \
1bb87f28 1239 { \
bec2e359
JW
1240 if (RTX_OK_FOR_INDEX_P (op1) \
1241 || RTX_OK_FOR_OFFSET_P (op1)) \
1bb87f28
JW
1242 goto ADDR; \
1243 } \
bec2e359 1244 else if (RTX_OK_FOR_BASE_P (op1)) \
1bb87f28 1245 { \
bec2e359
JW
1246 if (RTX_OK_FOR_INDEX_P (op0) \
1247 || RTX_OK_FOR_OFFSET_P (op0)) \
1bb87f28
JW
1248 goto ADDR; \
1249 } \
1250 } \
bec2e359
JW
1251 else if (GET_CODE (X) == LO_SUM) \
1252 { \
1253 register rtx op0 = XEXP (X, 0); \
1254 register rtx op1 = XEXP (X, 1); \
1255 if (RTX_OK_FOR_BASE_P (op0) \
1256 && CONSTANT_P (op1)) \
1257 goto ADDR; \
1258 } \
1bb87f28
JW
1259 else if (GET_CODE (X) == CONST_INT && SMALL_INT (X)) \
1260 goto ADDR; \
1261}
1262\f
1263/* Try machine-dependent ways of modifying an illegitimate address
1264 to be legitimate. If we find one, return the new, valid address.
1265 This macro is used in only one place: `memory_address' in explow.c.
1266
1267 OLDX is the address as it was before break_out_memory_refs was called.
1268 In some cases it is useful to look at this to decide what needs to be done.
1269
1270 MODE and WIN are passed so that this macro can use
1271 GO_IF_LEGITIMATE_ADDRESS.
1272
1273 It is always safe for this macro to do nothing. It exists to recognize
1274 opportunities to optimize the output. */
1275
1276/* On SPARC, change REG+N into REG+REG, and REG+(X*Y) into REG+REG. */
1277extern struct rtx_def *legitimize_pic_address ();
1278#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1279{ rtx sparc_x = (X); \
1280 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
1281 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 1), \
a015279e 1282 force_operand (XEXP (X, 0), NULL_RTX)); \
1bb87f28
JW
1283 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
1284 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
a015279e 1285 force_operand (XEXP (X, 1), NULL_RTX)); \
1bb87f28 1286 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
a015279e 1287 (X) = gen_rtx (PLUS, Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
1bb87f28
JW
1288 XEXP (X, 1)); \
1289 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
1290 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
a015279e 1291 force_operand (XEXP (X, 1), NULL_RTX)); \
1bb87f28
JW
1292 if (sparc_x != (X) && memory_address_p (MODE, X)) \
1293 goto WIN; \
1294 if (flag_pic) (X) = legitimize_pic_address (X, MODE, 0, 0); \
1295 else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
1296 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
1297 copy_to_mode_reg (Pmode, XEXP (X, 1))); \
1298 else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
1299 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 1), \
1300 copy_to_mode_reg (Pmode, XEXP (X, 0))); \
1301 else if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
1302 || GET_CODE (X) == LABEL_REF) \
1303 (X) = gen_rtx (LO_SUM, Pmode, \
1304 copy_to_mode_reg (Pmode, gen_rtx (HIGH, Pmode, X)), X); \
1305 if (memory_address_p (MODE, X)) \
1306 goto WIN; }
1307
1308/* Go to LABEL if ADDR (a legitimate address expression)
1309 has an effect that depends on the machine mode it is used for.
1310 On the SPARC this is never true. */
1311
1312#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
1313\f
1314/* Specify the machine mode that this machine uses
1315 for the index in the tablejump instruction. */
1316#define CASE_VECTOR_MODE SImode
1317
1318/* Define this if the tablejump instruction expects the table
1319 to contain offsets from the address of the table.
1320 Do not define this if the table should contain absolute addresses. */
1321/* #define CASE_VECTOR_PC_RELATIVE */
1322
1323/* Specify the tree operation to be used to convert reals to integers. */
1324#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1325
1326/* This is the kind of divide that is easiest to do in the general case. */
1327#define EASY_DIV_EXPR TRUNC_DIV_EXPR
1328
1329/* Define this as 1 if `char' should by default be signed; else as 0. */
1330#define DEFAULT_SIGNED_CHAR 1
1331
1332/* Max number of bytes we can move from memory to memory
1333 in one reasonably fast instruction. */
2eef2ef1 1334#define MOVE_MAX 8
1bb87f28 1335
0fb5a69e 1336#if 0 /* Sun 4 has matherr, so this is no good. */
24e2a2bf
RS
1337/* This is the value of the error code EDOM for this machine,
1338 used by the sqrt instruction. */
1339#define TARGET_EDOM 33
1340
1341/* This is how to refer to the variable errno. */
1342#define GEN_ERRNO_RTX \
1343 gen_rtx (MEM, SImode, gen_rtx (SYMBOL_REF, Pmode, "errno"))
0fb5a69e 1344#endif /* 0 */
24e2a2bf 1345
1bb87f28
JW
1346/* Define if normal loads of shorter-than-word items from memory clears
1347 the rest of the bigs in the register. */
1348#define BYTE_LOADS_ZERO_EXTEND
1349
1350/* Nonzero if access to memory by bytes is slow and undesirable.
1351 For RISC chips, it means that access to memory by bytes is no
1352 better than access by words when possible, so grab a whole word
1353 and maybe make use of that. */
1354#define SLOW_BYTE_ACCESS 1
1355
1356/* We assume that the store-condition-codes instructions store 0 for false
1357 and some other value for true. This is the value stored for true. */
1358
1359#define STORE_FLAG_VALUE 1
1360
1361/* When a prototype says `char' or `short', really pass an `int'. */
1362#define PROMOTE_PROTOTYPES
1363
1364/* Define if shifts truncate the shift count
1365 which implies one can omit a sign-extension or zero-extension
1366 of a shift count. */
1367#define SHIFT_COUNT_TRUNCATED
1368
1369/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1370 is done just by pretending it is already truncated. */
1371#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1372
1373/* Specify the machine mode that pointers have.
1374 After generation of rtl, the compiler makes no further distinction
1375 between pointers and any other objects of this machine mode. */
1376#define Pmode SImode
1377
b4ac57ab
RS
1378/* Generate calls to memcpy, memcmp and memset. */
1379#define TARGET_MEM_FUNCTIONS
1380
1bb87f28
JW
1381/* Add any extra modes needed to represent the condition code.
1382
1383 On the Sparc, we have a "no-overflow" mode which is used when an add or
1384 subtract insn is used to set the condition code. Different branches are
1385 used in this case for some operations.
1386
4d449554
JW
1387 We also have two modes to indicate that the relevant condition code is
1388 in the floating-point condition code register. One for comparisons which
1389 will generate an exception if the result is unordered (CCFPEmode) and
1390 one for comparisons which will never trap (CCFPmode). This really should
1391 be a separate register, but we don't want to go to 65 registers. */
1392#define EXTRA_CC_MODES CC_NOOVmode, CCFPmode, CCFPEmode
1bb87f28
JW
1393
1394/* Define the names for the modes specified above. */
4d449554 1395#define EXTRA_CC_NAMES "CC_NOOV", "CCFP", "CCFPE"
1bb87f28
JW
1396
1397/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
4d449554
JW
1398 return the mode to be used for the comparison. For floating-point,
1399 CCFP[E]mode is used. CC_NOOVmode should be used when the first operand is a
1bb87f28
JW
1400 PLUS, MINUS, or NEG. CCmode should be used when no special processing is
1401 needed. */
679655e6 1402#define SELECT_CC_MODE(OP,X,Y) \
4d449554
JW
1403 (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
1404 ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode) \
1405 : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS || GET_CODE (X) == NEG) \
1406 ? CC_NOOVmode : CCmode))
1bb87f28
JW
1407
1408/* A function address in a call instruction
1409 is a byte address (for indexing purposes)
1410 so give the MEM rtx a byte's mode. */
1411#define FUNCTION_MODE SImode
1412
1413/* Define this if addresses of constant functions
1414 shouldn't be put through pseudo regs where they can be cse'd.
1415 Desirable on machines where ordinary constants are expensive
1416 but a CALL with constant address is cheap. */
1417#define NO_FUNCTION_CSE
1418
1419/* alloca should avoid clobbering the old register save area. */
1420#define SETJMP_VIA_SAVE_AREA
1421
1422/* Define subroutines to call to handle multiply and divide.
1423 Use the subroutines that Sun's library provides.
1424 The `*' prevents an underscore from being prepended by the compiler. */
1425
1426#define DIVSI3_LIBCALL "*.div"
1427#define UDIVSI3_LIBCALL "*.udiv"
1428#define MODSI3_LIBCALL "*.rem"
1429#define UMODSI3_LIBCALL "*.urem"
1430/* .umul is a little faster than .mul. */
1431#define MULSI3_LIBCALL "*.umul"
1432
1433/* Compute the cost of computing a constant rtl expression RTX
1434 whose rtx-code is CODE. The body of this macro is a portion
1435 of a switch statement. If the code is computed here,
1436 return it with a return statement. Otherwise, break from the switch. */
1437
3bb22aee 1438#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1bb87f28 1439 case CONST_INT: \
1bb87f28 1440 if (INTVAL (RTX) < 0x1000 && INTVAL (RTX) >= -0x1000) \
5b485d2c 1441 return 0; \
1bb87f28
JW
1442 case HIGH: \
1443 return 2; \
1444 case CONST: \
1445 case LABEL_REF: \
1446 case SYMBOL_REF: \
1447 return 4; \
1448 case CONST_DOUBLE: \
1449 if (GET_MODE (RTX) == DImode) \
1450 if ((XINT (RTX, 3) == 0 \
1451 && (unsigned) XINT (RTX, 2) < 0x1000) \
1452 || (XINT (RTX, 3) == -1 \
1453 && XINT (RTX, 2) < 0 \
1454 && XINT (RTX, 2) >= -0x1000)) \
5b485d2c 1455 return 0; \
1bb87f28
JW
1456 return 8;
1457
1458/* SPARC offers addressing modes which are "as cheap as a register".
1459 See sparc.c (or gcc.texinfo) for details. */
1460
1461#define ADDRESS_COST(RTX) \
1462 (GET_CODE (RTX) == REG ? 1 : sparc_address_cost (RTX))
1463
1464/* Compute extra cost of moving data between one register class
1465 and another. */
1466#define REGISTER_MOVE_COST(CLASS1, CLASS2) \
1467 (((CLASS1 == FP_REGS && CLASS2 == GENERAL_REGS) \
1468 || (CLASS1 == GENERAL_REGS && CLASS2 == FP_REGS)) ? 6 : 2)
1469
1470/* Provide the costs of a rtl expression. This is in the body of a
1471 switch on CODE. The purpose for the cost of MULT is to encourage
1472 `synth_mult' to find a synthetic multiply when reasonable.
1473
1474 If we need more than 12 insns to do a multiply, then go out-of-line,
1475 since the call overhead will be < 10% of the cost of the multiply. */
1476
3bb22aee 1477#define RTX_COSTS(X,CODE,OUTER_CODE) \
1bb87f28 1478 case MULT: \
6ffeae97 1479 return TARGET_V8 ? COSTS_N_INSNS (5) : COSTS_N_INSNS (25); \
1bb87f28
JW
1480 case DIV: \
1481 case UDIV: \
1482 case MOD: \
1483 case UMOD: \
5b485d2c
JW
1484 return COSTS_N_INSNS (25); \
1485 /* Make FLOAT and FIX more expensive than CONST_DOUBLE,\
1bb87f28
JW
1486 so that cse will favor the latter. */ \
1487 case FLOAT: \
5b485d2c 1488 case FIX: \
1bb87f28
JW
1489 return 19;
1490
1491/* Conditional branches with empty delay slots have a length of two. */
1492#define ADJUST_INSN_LENGTH(INSN, LENGTH) \
1493 if (GET_CODE (INSN) == CALL_INSN \
1494 || (GET_CODE (INSN) == JUMP_INSN && ! simplejump_p (insn))) \
1495 LENGTH += 1;
1496\f
1497/* Control the assembler format that we output. */
1498
1499/* Output at beginning of assembler file. */
1500
1501#define ASM_FILE_START(file)
1502
1503/* Output to assembler file text saying following lines
1504 may contain character constants, extra white space, comments, etc. */
1505
1506#define ASM_APP_ON ""
1507
1508/* Output to assembler file text saying following lines
1509 no longer contain unusual constructs. */
1510
1511#define ASM_APP_OFF ""
1512
303d524a
JW
1513#define ASM_LONG ".word"
1514#define ASM_SHORT ".half"
1515#define ASM_BYTE_OP ".byte"
1516
1bb87f28
JW
1517/* Output before read-only data. */
1518
1519#define TEXT_SECTION_ASM_OP ".text"
1520
1521/* Output before writable data. */
1522
1523#define DATA_SECTION_ASM_OP ".data"
1524
1525/* How to refer to registers in assembler output.
1526 This sequence is indexed by compiler's hard-register-number (see above). */
1527
1528#define REGISTER_NAMES \
1529{"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", \
1530 "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", \
1531 "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
1532 "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", \
1533 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", \
1534 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", \
1535 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", \
1536 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31"}
1537
ea3fa5f7
JW
1538/* Define additional names for use in asm clobbers and asm declarations.
1539
1540 We define the fake Condition Code register as an alias for reg 0 (which
1541 is our `condition code' register), so that condition codes can easily
1542 be clobbered by an asm. No such register actually exists. Condition
1543 codes are partly stored in the PSR and partly in the FSR. */
1544
0eb9f40e 1545#define ADDITIONAL_REGISTER_NAMES {"ccr", 0, "cc", 0}
ea3fa5f7 1546
1bb87f28
JW
1547/* How to renumber registers for dbx and gdb. */
1548
1549#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1550
1551/* On Sun 4, this limit is 2048. We use 1500 to be safe,
1552 since the length can run past this up to a continuation point. */
1553#define DBX_CONTIN_LENGTH 1500
1554
1555/* This is how to output a note to DBX telling it the line number
1556 to which the following sequence of instructions corresponds.
1557
1558 This is needed for SunOS 4.0, and should not hurt for 3.2
1559 versions either. */
1560#define ASM_OUTPUT_SOURCE_LINE(file, line) \
1561 { static int sym_lineno = 1; \
1562 fprintf (file, ".stabn 68,0,%d,LM%d\nLM%d:\n", \
1563 line, sym_lineno, sym_lineno); \
1564 sym_lineno += 1; }
1565
1566/* This is how to output the definition of a user-level label named NAME,
1567 such as the label on a static function or variable NAME. */
1568
1569#define ASM_OUTPUT_LABEL(FILE,NAME) \
1570 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1571
1572/* This is how to output a command to make the user-level label named NAME
1573 defined for reference from other files. */
1574
1575#define ASM_GLOBALIZE_LABEL(FILE,NAME) \
1576 do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
1577
1578/* This is how to output a reference to a user-level label named NAME.
1579 `assemble_name' uses this. */
1580
1581#define ASM_OUTPUT_LABELREF(FILE,NAME) \
1582 fprintf (FILE, "_%s", NAME)
1583
d2a8e680 1584/* This is how to output a definition of an internal numbered label where
1bb87f28
JW
1585 PREFIX is the class of label and NUM is the number within the class. */
1586
1587#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1588 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
1589
d2a8e680
RS
1590/* This is how to output a reference to an internal numbered label where
1591 PREFIX is the class of label and NUM is the number within the class. */
1592/* FIXME: This should be used throughout gcc, and documented in the texinfo
1593 files. There is no reason you should have to allocate a buffer and
1594 `sprintf' to reference an internal label (as opposed to defining it). */
1595
1596#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
1597 fprintf (FILE, "%s%d", PREFIX, NUM)
1598
1bb87f28
JW
1599/* This is how to store into the string LABEL
1600 the symbol_ref name of an internal numbered label where
1601 PREFIX is the class of label and NUM is the number within the class.
1602 This is suitable for output with `assemble_name'. */
1603
1604#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
1605 sprintf (LABEL, "*%s%d", PREFIX, NUM)
1606
1607/* This is how to output an assembler line defining a `double' constant. */
1608
b1fc14e5
RS
1609/* Assemblers (both gas 1.35 and as in 4.0.3)
1610 seem to treat -0.0 as if it were 0.0.
1611 They reject 99e9999, but accept inf. */
1bb87f28
JW
1612#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1613 { \
303d524a
JW
1614 if (REAL_VALUE_ISINF (VALUE) \
1615 || REAL_VALUE_ISNAN (VALUE) \
1616 || REAL_VALUE_MINUS_ZERO (VALUE)) \
1bb87f28 1617 { \
303d524a
JW
1618 long t[2]; \
1619 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \
1620 fprintf (FILE, "\t%s\t0x%lx\n\t%s\t0x%lx\n", \
1621 ASM_LONG, t[0], ASM_LONG, t[1]); \
1bb87f28
JW
1622 } \
1623 else \
1624 fprintf (FILE, "\t.double 0r%.17g\n", VALUE); \
1625 }
1626
1627/* This is how to output an assembler line defining a `float' constant. */
1628
1629#define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1630 { \
303d524a
JW
1631 if (REAL_VALUE_ISINF (VALUE) \
1632 || REAL_VALUE_ISNAN (VALUE) \
1633 || REAL_VALUE_MINUS_ZERO (VALUE)) \
1bb87f28 1634 { \
303d524a
JW
1635 long t; \
1636 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
1637 fprintf (FILE, "\t%s\t0x%lx\n", ASM_LONG, t); \
1bb87f28
JW
1638 } \
1639 else \
1640 fprintf (FILE, "\t.single 0r%.9g\n", VALUE); \
1641 }
1642
0cd02cbb
DE
1643/* This is how to output an assembler line defining a `long double'
1644 constant. */
1645
1646#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
1647 { \
1648 long t[4]; \
1649 REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), t); \
1650 fprintf (FILE, "\t%s\t0x%lx\n\t%s\t0x%lx\n\t%s\t0x%lx\n\t%s\t0x%lx\n", \
1651 ASM_LONG, t[0], ASM_LONG, t[1], ASM_LONG, t[2], ASM_LONG, t[3]); \
1652 }
1653
1bb87f28
JW
1654/* This is how to output an assembler line defining an `int' constant. */
1655
1656#define ASM_OUTPUT_INT(FILE,VALUE) \
303d524a 1657( fprintf (FILE, "\t%s\t", ASM_LONG), \
1bb87f28
JW
1658 output_addr_const (FILE, (VALUE)), \
1659 fprintf (FILE, "\n"))
1660
1661/* This is how to output an assembler line defining a DImode constant. */
1662#define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE) \
1663 output_double_int (FILE, VALUE)
1664
1665/* Likewise for `char' and `short' constants. */
1666
1667#define ASM_OUTPUT_SHORT(FILE,VALUE) \
303d524a 1668( fprintf (FILE, "\t%s\t", ASM_SHORT), \
1bb87f28
JW
1669 output_addr_const (FILE, (VALUE)), \
1670 fprintf (FILE, "\n"))
1671
1672#define ASM_OUTPUT_CHAR(FILE,VALUE) \
303d524a 1673( fprintf (FILE, "\t%s\t", ASM_BYTE_OP), \
1bb87f28
JW
1674 output_addr_const (FILE, (VALUE)), \
1675 fprintf (FILE, "\n"))
1676
1677/* This is how to output an assembler line for a numeric constant byte. */
1678
1679#define ASM_OUTPUT_BYTE(FILE,VALUE) \
303d524a 1680 fprintf (FILE, "\t%s\t0x%x\n", ASM_BYTE_OP, (VALUE))
1bb87f28
JW
1681
1682/* This is how to output an element of a case-vector that is absolute. */
1683
1684#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
4b69d2a3
RS
1685do { \
1686 char label[30]; \
1687 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
1688 fprintf (FILE, "\t.word\t"); \
1689 assemble_name (FILE, label); \
1690 fprintf (FILE, "\n"); \
1691} while (0)
1bb87f28
JW
1692
1693/* This is how to output an element of a case-vector that is relative.
1694 (SPARC uses such vectors only when generating PIC.) */
1695
4b69d2a3
RS
1696#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
1697do { \
1698 char label[30]; \
1699 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
1700 fprintf (FILE, "\t.word\t"); \
1701 assemble_name (FILE, label); \
1702 fprintf (FILE, "-1b\n"); \
1703} while (0)
1bb87f28
JW
1704
1705/* This is how to output an assembler line
1706 that says to advance the location counter
1707 to a multiple of 2**LOG bytes. */
1708
1709#define ASM_OUTPUT_ALIGN(FILE,LOG) \
1710 if ((LOG) != 0) \
1711 fprintf (FILE, "\t.align %d\n", (1<<(LOG)))
1712
1713#define ASM_OUTPUT_SKIP(FILE,SIZE) \
1714 fprintf (FILE, "\t.skip %u\n", (SIZE))
1715
1716/* This says how to output an assembler line
1717 to define a global common symbol. */
1718
1719#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1720( fputs ("\t.global ", (FILE)), \
1721 assemble_name ((FILE), (NAME)), \
1722 fputs ("\n\t.common ", (FILE)), \
1723 assemble_name ((FILE), (NAME)), \
1724 fprintf ((FILE), ",%u,\"bss\"\n", (ROUNDED)))
1725
1726/* This says how to output an assembler line
1727 to define a local common symbol. */
1728
1729#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1730( fputs ("\n\t.reserve ", (FILE)), \
1731 assemble_name ((FILE), (NAME)), \
1732 fprintf ((FILE), ",%u,\"bss\"\n", (ROUNDED)))
1733
1734/* Store in OUTPUT a string (made with alloca) containing
1735 an assembler-name for a local static variable named NAME.
1736 LABELNO is an integer which is different for each call. */
1737
1738#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1739( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1740 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1741
c14f2655
RS
1742#define IDENT_ASM_OP ".ident"
1743
1744/* Output #ident as a .ident. */
1745
1746#define ASM_OUTPUT_IDENT(FILE, NAME) \
1747 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
1748
1bb87f28
JW
1749/* Define the parentheses used to group arithmetic operations
1750 in assembler code. */
1751
1752#define ASM_OPEN_PAREN "("
1753#define ASM_CLOSE_PAREN ")"
1754
1755/* Define results of standard character escape sequences. */
1756#define TARGET_BELL 007
1757#define TARGET_BS 010
1758#define TARGET_TAB 011
1759#define TARGET_NEWLINE 012
1760#define TARGET_VT 013
1761#define TARGET_FF 014
1762#define TARGET_CR 015
1763
1764#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
2ccdef65 1765 ((CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' || (CHAR) == '(')
1bb87f28
JW
1766
1767/* Print operand X (an rtx) in assembler syntax to file FILE.
1768 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1769 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1770
1771#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
1772
1773/* Print a memory address as an operand to reference that memory location. */
1774
1775#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1776{ register rtx base, index = 0; \
1777 int offset = 0; \
1778 register rtx addr = ADDR; \
1779 if (GET_CODE (addr) == REG) \
1780 fputs (reg_names[REGNO (addr)], FILE); \
1781 else if (GET_CODE (addr) == PLUS) \
1782 { \
1783 if (GET_CODE (XEXP (addr, 0)) == CONST_INT) \
1784 offset = INTVAL (XEXP (addr, 0)), base = XEXP (addr, 1);\
1785 else if (GET_CODE (XEXP (addr, 1)) == CONST_INT) \
1786 offset = INTVAL (XEXP (addr, 1)), base = XEXP (addr, 0);\
1787 else \
1788 base = XEXP (addr, 0), index = XEXP (addr, 1); \
1789 fputs (reg_names[REGNO (base)], FILE); \
1790 if (index == 0) \
1791 fprintf (FILE, "%+d", offset); \
1792 else if (GET_CODE (index) == REG) \
1793 fprintf (FILE, "+%s", reg_names[REGNO (index)]); \
1794 else if (GET_CODE (index) == SYMBOL_REF) \
1795 fputc ('+', FILE), output_addr_const (FILE, index); \
1796 else abort (); \
1797 } \
1798 else if (GET_CODE (addr) == MINUS \
1799 && GET_CODE (XEXP (addr, 1)) == LABEL_REF) \
1800 { \
1801 output_addr_const (FILE, XEXP (addr, 0)); \
1802 fputs ("-(", FILE); \
1803 output_addr_const (FILE, XEXP (addr, 1)); \
1804 fputs ("-.)", FILE); \
1805 } \
1806 else if (GET_CODE (addr) == LO_SUM) \
1807 { \
1808 output_operand (XEXP (addr, 0), 0); \
1809 fputs ("+%lo(", FILE); \
1810 output_address (XEXP (addr, 1)); \
1811 fputc (')', FILE); \
1812 } \
1813 else if (flag_pic && GET_CODE (addr) == CONST \
1814 && GET_CODE (XEXP (addr, 0)) == MINUS \
1815 && GET_CODE (XEXP (XEXP (addr, 0), 1)) == CONST \
1816 && GET_CODE (XEXP (XEXP (XEXP (addr, 0), 1), 0)) == MINUS \
1817 && XEXP (XEXP (XEXP (XEXP (addr, 0), 1), 0), 1) == pc_rtx) \
1818 { \
1819 addr = XEXP (addr, 0); \
1820 output_addr_const (FILE, XEXP (addr, 0)); \
1821 /* Group the args of the second CONST in parenthesis. */ \
1822 fputs ("-(", FILE); \
1823 /* Skip past the second CONST--it does nothing for us. */\
1824 output_addr_const (FILE, XEXP (XEXP (addr, 1), 0)); \
1825 /* Close the parenthesis. */ \
1826 fputc (')', FILE); \
1827 } \
1828 else \
1829 { \
1830 output_addr_const (FILE, addr); \
1831 } \
1832}
1833
1834/* Declare functions defined in sparc.c and used in templates. */
1835
1836extern char *singlemove_string ();
1837extern char *output_move_double ();
795068a4 1838extern char *output_move_quad ();
1bb87f28 1839extern char *output_fp_move_double ();
795068a4 1840extern char *output_fp_move_quad ();
1bb87f28
JW
1841extern char *output_block_move ();
1842extern char *output_scc_insn ();
1843extern char *output_cbranch ();
1844extern char *output_return ();
1bb87f28
JW
1845
1846/* Defined in flags.h, but insn-emit.c does not include flags.h. */
1847
1848extern int flag_pic;
This page took 0.301698 seconds and 5 git commands to generate.