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