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