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