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