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