]> gcc.gnu.org Git - gcc.git/blame - gcc/config/sparc/sparc.h
Added arg to RETURN_POPS_ARGS.
[gcc.git] / gcc / config / sparc / sparc.h
CommitLineData
1bb87f28 1/* Definitions of target machine for GNU compiler, for Sun SPARC.
ef0e53ce 2 Copyright (C) 1987, 88, 89, 92, 94, 1995 Free Software Foundation, Inc.
1bb87f28 3 Contributed by Michael Tiemann (tiemann@cygnus.com).
7a6cf439
DE
4 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
5 at Cygnus Support.
1bb87f28
JW
6
7This file is part of GNU CC.
8
9GNU CC is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GNU CC is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU CC; see the file COPYING. If not, write to
21the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23/* Note that some other tm.h files include this one and then override
24 many of the definitions that relate to assembler syntax. */
25
7a6cf439
DE
26/* Sparc64 support has been added by trying to allow for a day when one
27 compiler can handle both v8 and v9. There are a few cases where this
28 isn't doable, but keep them to a minimum! Two macros are used to help out:
29 TARGET_V9 is used to select (at runtime) !v9-ness or v9-ness.
30 SPARCV9 is defined when compiling for sparc64 only.
31 In places where it is possible to choose between the two at runtime, use
32 TARGET_V9. In places where it is currently not possible to select
33 between the two at runtime use SPARCV9. Again, keep uses of SPARCV9 to a
34 minimum. No attempt is made to support both v8 and v9 in the v9 compiler.
35
36 If a combination v8/v9 compiler is too slow, it should always be possible
37 to #define TARGET_V9 as 0 (and potentially other v9-only options), and
38 #undef SPARCV9. */
39
bef8d8c7
JW
40/* What architecture we're compiling for. This must coincide with the
41 `arch_type' attribute in the .md file. The names were chosen to avoid
42 potential misunderstandings with the various 32 bit flavors (v7, v8, etc.):
43 if we used ARCH_V9 then we'd want to use something like ARCH_V8 but that
44 could be misleading and ARCH_NOTV9 sounds klunky. */
45enum arch_type { ARCH_32BIT, ARCH_64BIT };
46extern enum arch_type sparc_arch_type;
7a6cf439
DE
47
48/* Names to predefine in the preprocessor for this target machine. */
49
50/* ??? The GCC_NEW_VARARGS macro is now obsolete, because gcc always uses
51 the right varags.h file when bootstrapping. */
52
53#ifdef SPARCV9
54#define CPP_PREDEFINES \
55 "-Dsparc -Dsun -Dunix -D__sparc_v9__ \
56 -Asystem(unix) -Asystem(bsd) -Acpu(sparc64) -Amachine(sparc64)"
57#else
58#define CPP_PREDEFINES \
59 "-Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__ \
857458c4 60 -Asystem(unix) -Asystem(bsd) -Acpu(sparc) -Amachine(sparc)"
7a6cf439
DE
61#endif
62
68d69835 63#define LIB_SPEC "%{!shared:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} %{g:-lg}}"
1bb87f28 64
98ccf8fe 65/* Provide required defaults for linker -e and -d switches. */
1bb87f28 66
d6f04508 67#define LINK_SPEC \
68d69835
JM
68 "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp} %{static:-Bstatic} \
69 %{assert*} %{shared:-assert pure-text}"
1bb87f28
JW
70
71/* Special flags to the Sun-4 assembler when using pipe for input. */
72
b877b5ab 73#define ASM_SPEC " %| %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}}"
1bb87f28 74
885d8175 75/* Define macros to distinguish architectures. */
857458c4
DE
76
77#ifdef SPARCV9
78#define CPP_SPEC "\
79%{mint64:-D__INT_MAX__=9223372036854775807LL -D__LONG_MAX__=9223372036854775807LL} \
80%{mlong64:-D__LONG_MAX__=9223372036854775807LL} \
81"
82#else
7a6cf439
DE
83#define CPP_SPEC "\
84%{msparclite:-D__sparclite__} \
85%{mf930:-D__sparclite__} %{mf934:-D__sparclite__} \
86%{mv8:-D__sparc_v8__} \
bef8d8c7 87%{msupersparc:-D__supersparc__ -D__sparc_v8__} \
7a6cf439 88"
857458c4 89#endif
885d8175 90
b1fc14e5
RS
91/* Prevent error on `-sun4' and `-target sun4' options. */
92/* This used to translate -dalign to -malign, but that is no good
93 because it can't turn off the usual meaning of making debugging dumps. */
1bb87f28 94
b1fc14e5 95#define CC1_SPEC "%{sun4:} %{target:}"
1bb87f28 96
857458c4
DE
97#ifdef SPARCV9
98#define PTRDIFF_TYPE "long long int"
99#define SIZE_TYPE "long long unsigned int"
100#else
101#define PTRDIFF_TYPE "int"
102/* In 2.4 it should work to delete this.
103 #define SIZE_TYPE "int" */
104#endif
7a6cf439
DE
105
106/* ??? This should be 32 bits for v9 but what can we do? */
1bb87f28
JW
107#define WCHAR_TYPE "short unsigned int"
108#define WCHAR_TYPE_SIZE 16
7a6cf439 109#define MAX_WCHAR_TYPE_SIZE 16
1bb87f28 110
4f074454
RK
111/* Show we can debug even without a frame pointer. */
112#define CAN_DEBUG_WITHOUT_FP
1bb87f28 113
5b485d2c
JW
114/* To make profiling work with -f{pic,PIC}, we need to emit the profiling
115 code into the rtl. Also, if we are profiling, we cannot eliminate
116 the frame pointer (because the return address will get smashed). */
117
7a6cf439
DE
118void sparc_override_options ();
119
5b485d2c 120#define OVERRIDE_OPTIONS \
7a6cf439
DE
121 do { \
122 if (profile_flag || profile_block_flag) \
123 { \
124 if (flag_pic) \
125 { \
126 char *pic_string = (flag_pic == 1) ? "-fpic" : "-fPIC"; \
127 warning ("%s and profiling conflict: disabling %s", \
128 pic_string, pic_string); \
129 flag_pic = 0; \
130 } \
131 flag_omit_frame_pointer = 0; \
132 } \
cf9be6f0 133 SUBTARGET_OVERRIDE_OPTIONS; \
7a6cf439
DE
134 sparc_override_options (); \
135 } while (0)
84ab3bfb 136
cf9be6f0 137/* This is meant to be redefined in the host dependent files. */
84ab3bfb 138#define SUBTARGET_OVERRIDE_OPTIONS
5b485d2c 139
1bb87f28
JW
140/* These compiler options take an argument. We ignore -target for now. */
141
142#define WORD_SWITCH_TAKES_ARG(STR) \
3b39b94f
ILT
143 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \
144 || !strcmp (STR, "target") || !strcmp (STR, "assert"))
1bb87f28 145
1bb87f28
JW
146/* Print subsidiary information on the compiler version in use. */
147
148#define TARGET_VERSION fprintf (stderr, " (sparc)");
149
150/* Generate DBX debugging information. */
151
152#define DBX_DEBUGGING_INFO
7a6cf439 153\f
1bb87f28
JW
154/* Run-time compilation parameters selecting different hardware subsets. */
155
156extern int target_flags;
157
158/* Nonzero if we should generate code to use the fpu. */
7a6cf439
DE
159#define MASK_FPU 1
160#define TARGET_FPU (target_flags & MASK_FPU)
1bb87f28
JW
161
162/* Nonzero if we should use FUNCTION_EPILOGUE. Otherwise, we
163 use fast return insns, but lose some generality. */
7a6cf439
DE
164#define MASK_EPILOGUE 2
165#define TARGET_EPILOGUE (target_flags & MASK_EPILOGUE)
1bb87f28 166
95dea81f
JW
167/* Nonzero if we should assume that double pointers might be unaligned.
168 This can happen when linking gcc compiled code with other compilers,
169 because the ABI only guarantees 4 byte alignment. */
7a6cf439
DE
170#define MASK_UNALIGNED_DOUBLES 4
171#define TARGET_UNALIGNED_DOUBLES (target_flags & MASK_UNALIGNED_DOUBLES)
172
bef8d8c7
JW
173/* ??? Bits 0x18 are currently unused. */
174
175/* Nonzero means we should schedule code for the TMS390Z55 SuperSparc chip. */
176#define MASK_SUPERSPARC 0x20
177#define TARGET_SUPERSPARC (target_flags & MASK_SUPERSPARC)
1bb87f28 178
885d8175 179/* Nonzero means that we should generate code for a v8 sparc. */
7a6cf439
DE
180#define MASK_V8 0x40
181#define TARGET_V8 (target_flags & MASK_V8)
885d8175 182
bc9e02ae
JW
183/* Nonzero means that we should generate code for a sparclite.
184 This enables the sparclite specific instructions, but does not affect
185 whether FPU instructions are emitted. */
7a6cf439
DE
186#define MASK_SPARCLITE 0x80
187#define TARGET_SPARCLITE (target_flags & MASK_SPARCLITE)
885d8175 188
5b485d2c 189/* Nonzero means that we should generate code using a flat register window
9a1c7cd7
JW
190 model, i.e. no save/restore instructions are generated, in the most
191 efficient manner. This code is not compatible with normal sparc code. */
192/* This is not a user selectable option yet, because it requires changes
193 that are not yet switchable via command line arguments. */
5c56efde 194/* ??? This flag is deprecated and may disappear at some point. */
7a6cf439
DE
195#define MASK_FRW 0x100
196#define TARGET_FRW (target_flags & MASK_FRW)
5b485d2c 197
9a1c7cd7
JW
198/* Nonzero means that we should generate code using a flat register window
199 model, i.e. no save/restore instructions are generated, but which is
200 compatible with normal sparc code. This is the same as above, except
5c56efde
DE
201 that the frame pointer is %i7 instead of %fp. */
202/* ??? This use to be named TARGET_FRW_COMPAT. At some point TARGET_FRW will
203 go away, but until that time only use this one when necessary.
204 -mflat sets both. */
7a6cf439
DE
205#define MASK_FLAT 0x200
206#define TARGET_FLAT (target_flags & MASK_FLAT)
9a1c7cd7 207
34ad7aaf 208/* Nonzero means use the registers that the Sparc ABI reserves for
7a6cf439
DE
209 application software. This is the default for v8, but not v9. */
210#define MASK_APP_REGS 0x400
211#define TARGET_APP_REGS (target_flags & MASK_APP_REGS)
34ad7aaf 212
8248e2bc
JW
213/* Option to select how quad word floating point is implemented.
214 When TARGET_HARD_QUAD is true, we use the hardware quad instructions.
215 Otherwise, we use the SPARC ABI quad library functions. */
7a6cf439
DE
216#define MASK_HARD_QUAD 0x800
217#define TARGET_HARD_QUAD (target_flags & MASK_HARD_QUAD)
218
219/* Nonzero if we're compiling for 64 bit sparc. */
220#define MASK_V9 0x1000
221#define TARGET_V9 (target_flags & MASK_V9)
222
223/* Nonzero if ints are 64 bits.
224 This automatically implies longs are 64 bits too.
225 This option is for v9 only. */
226#define MASK_INT64 0x2000
227#define TARGET_INT64 (target_flags & MASK_INT64)
228
229/* Nonzero if longs are 64 bits.
230 This option is for v9 only. */
231#define MASK_LONG64 0x4000
232#define TARGET_LONG64 (target_flags & MASK_LONG64)
233
234/* Nonzero if pointers are 64 bits.
857458c4
DE
235 This is not a user selectable option, though it may be one day -
236 so it is used to determine pointer size instead of an architecture flag. */
7a6cf439
DE
237#define MASK_PTR64 0x8000
238#define TARGET_PTR64 (target_flags & MASK_PTR64)
239
240/* Nonzero if we are generating code to be tested in a 32 bit environment.
241 Hence, we assume the upper 32 bits of symbolic addresses are zero, and
242 avoid generating %uhi and %ulo terms.
243 Pointers are still 64 bits though! This option is for v9 only. */
2454c8d4 244/* ??? This option is deprecated. Try to use -mmedlow. */
7a6cf439
DE
245#define MASK_ENV32 0x10000
246#define TARGET_ENV32 (target_flags & MASK_ENV32)
247
248/* Memory models.
249 Two memory models are supported:
250 TARGET_MEDLOW: 32 bit address space, top 32 bits = 0
857458c4 251 (pointers still 64 bits)
7a6cf439
DE
252 TARGET_MEDANY: 32 bit address space, data segment loaded anywhere
253 (use %g4 as offset).
254 TARGET_FULLANY: not supported yet.
255 These options are for v9 only. All mask values are nonzero so the v8
256 compiler can assume this stuff won't interfere. */
257#define MASK_MEDLOW 0x20000
258#define MASK_MEDANY 0x40000
259#define MASK_FULLANY 0x60000
260#define MASK_CODE_MODEL (MASK_MEDLOW + MASK_MEDANY)
261#define TARGET_MEDLOW ((target_flags & MASK_CODE_MODEL) == MASK_MEDLOW)
262#define TARGET_MEDANY ((target_flags & MASK_CODE_MODEL) == MASK_MEDANY)
263#define TARGET_FULLANY ((target_flags & MASK_CODE_MODEL) == MASK_FULLANY)
264
265/* ??? There are hardcoded references to this reg in the .md file. */
266#define MEDANY_BASE_REG "%g4"
267
268/* Non-zero means use a stack bias of 2047. Stack offsets are obtained by
269 adding 2047 to %sp. This option is for v9 only and is the default. */
270#define MASK_STACK_BIAS 0x80000
271#define TARGET_STACK_BIAS (target_flags & MASK_STACK_BIAS)
8248e2bc 272
1bb87f28
JW
273/* Macro to define tables used to set the flags.
274 This is a list in braces of pairs in braces,
275 each pair being { "NAME", VALUE }
276 where VALUE is the bits to set or minus the bits to clear.
277 An empty string NAME is used to identify the default VALUE. */
278
bc9e02ae 279/* The Fujitsu MB86930 is the original sparclite chip, with no fpu.
7a6cf439 280 The Fujitsu MB86934 is the recent sparclite chip, with an fpu.
bc9e02ae
JW
281 We use -mf930 and -mf934 options to choose which.
282 ??? These should perhaps be -mcpu= options. */
283
1bb87f28 284#define TARGET_SWITCHES \
7a6cf439
DE
285 { {"fpu", MASK_FPU}, \
286 {"no-fpu", -MASK_FPU}, \
287 {"hard-float", MASK_FPU}, \
288 {"soft-float", -MASK_FPU}, \
289 {"epilogue", MASK_EPILOGUE}, \
290 {"no-epilogue", -MASK_EPILOGUE}, \
291 {"unaligned-doubles", MASK_UNALIGNED_DOUBLES}, \
292 {"no-unaligned-doubles", -MASK_UNALIGNED_DOUBLES}, \
bef8d8c7
JW
293 {"supersparc", MASK_SUPERSPARC+MASK_V8}, \
294 {"cypress", -MASK_SUPERSPARC-MASK_V8}, \
7a6cf439
DE
295 {"v8", MASK_V8}, \
296 {"no-v8", -MASK_V8}, \
297 {"sparclite", MASK_SPARCLITE}, \
298 {"no-sparclite", -MASK_SPARCLITE}, \
299 {"f930", MASK_SPARCLITE}, \
300 {"f930", -MASK_FPU}, \
301 {"f934", MASK_SPARCLITE}, \
302 {"flat", MASK_FRW+MASK_FLAT}, \
303 {"no-flat", -(MASK_FRW+MASK_FLAT)}, \
304 {"app-regs", MASK_APP_REGS}, \
305 {"no-app-regs", -MASK_APP_REGS}, \
306 {"hard-quad-float", MASK_HARD_QUAD}, \
307 {"soft-quad-float", -MASK_HARD_QUAD}, \
308 SUBTARGET_SWITCHES \
309 V9_SWITCHES \
b1fc14e5 310 { "", TARGET_DEFAULT}}
1bb87f28 311
7a6cf439 312#define TARGET_DEFAULT (MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU)
84ab3bfb
JW
313
314/* This is meant to be redefined in the host dependent files */
315#define SUBTARGET_SWITCHES
1bb87f28 316
7a6cf439
DE
317/* ??? Until we support a combination v8/v9 compiler, the v9 specific options
318 are only defined for the v9 compiler. */
7a6cf439
DE
319#ifdef SPARCV9
320#define V9_SWITCHES \
fa653e40 321/* {"v9", MASK_V9}, */ \
7a6cf439
DE
322 {"int64", MASK_INT64+MASK_LONG64}, \
323 {"int32", -MASK_INT64}, \
fa653e40
DE
324 {"int32", MASK_LONG64}, \
325 {"long64", -MASK_INT64}, \
7a6cf439 326 {"long64", MASK_LONG64}, \
fa653e40
DE
327 {"long32", -(MASK_INT64+MASK_LONG64)}, \
328/* {"ptr64", MASK_PTR64}, */ \
329/* {"ptr32", -MASK_PTR64}, */ \
7a6cf439 330 {"stack-bias", MASK_STACK_BIAS}, \
2454c8d4
JW
331 {"no-stack-bias", -MASK_STACK_BIAS}, \
332 {"medlow", -MASK_CODE_MODEL}, \
333 {"medlow", MASK_MEDLOW}, \
334 {"medany", -MASK_CODE_MODEL}, \
335 {"medany", MASK_MEDANY},
7a6cf439
DE
336#else
337#define V9_SWITCHES
360b1451 338#endif
7a6cf439
DE
339\f
340/* target machine storage layout */
341
d667538b
JW
342/* Define for cross-compilation to a sparc target with no TFmode from a host
343 with a different float format (e.g. VAX). */
344#define REAL_ARITHMETIC
345
1bb87f28
JW
346/* Define this if most significant bit is lowest numbered
347 in instructions that operate on numbered bit-fields. */
348#define BITS_BIG_ENDIAN 1
349
350/* Define this if most significant byte of a word is the lowest numbered. */
351/* This is true on the SPARC. */
352#define BYTES_BIG_ENDIAN 1
353
354/* Define this if most significant word of a multiword number is the lowest
355 numbered. */
356/* Doubles are stored in memory with the high order word first. This
357 matters when cross-compiling. */
358#define WORDS_BIG_ENDIAN 1
359
b4ac57ab 360/* number of bits in an addressable storage unit */
1bb87f28
JW
361#define BITS_PER_UNIT 8
362
363/* Width in bits of a "word", which is the contents of a machine register.
364 Note that this is not necessarily the width of data type `int';
365 if using 16-bit ints on a 68000, this would still be 32.
366 But on a machine with 16-bit registers, this would be 16. */
7a6cf439
DE
367#define BITS_PER_WORD (TARGET_V9 ? 64 : 32)
368#define MAX_BITS_PER_WORD 64
1bb87f28
JW
369
370/* Width of a word, in units (bytes). */
7a6cf439 371#define UNITS_PER_WORD (TARGET_V9 ? 8 : 4)
ef0e53ce 372#define MIN_UNITS_PER_WORD 4
7a6cf439
DE
373
374/* Now define the sizes of the C data types. */
375
376#define SHORT_TYPE_SIZE 16
377#define INT_TYPE_SIZE (TARGET_INT64 ? 64 : 32)
378#define LONG_TYPE_SIZE (TARGET_LONG64 ? 64 : 32)
379#define LONG_LONG_TYPE_SIZE 64
380#define FLOAT_TYPE_SIZE 32
381#define DOUBLE_TYPE_SIZE 64
382
383#define MAX_INT_TYPE_SIZE 64
384#define MAX_LONG_TYPE_SIZE 64
385
386#ifdef SPARCV9
387/* ??? This does not work in SunOS 4.x, so it is not enabled here.
388 Instead, it is enabled in sol2.h, because it does work under Solaris. */
389/* Define for support of TFmode long double and REAL_ARITHMETIC.
390 Sparc ABI says that long double is 4 words. */
391#define LONG_DOUBLE_TYPE_SIZE 128
392#endif
1bb87f28
JW
393
394/* Width in bits of a pointer.
395 See also the macro `Pmode' defined below. */
7a6cf439 396#define POINTER_SIZE (TARGET_PTR64 ? 64 : 32)
1bb87f28
JW
397
398/* Allocation boundary (in *bits*) for storing arguments in argument list. */
7a6cf439 399#define PARM_BOUNDARY (TARGET_V9 ? 64 : 32)
1bb87f28
JW
400
401/* Boundary (in *bits*) on which stack pointer should be aligned. */
7a6cf439 402#define STACK_BOUNDARY (TARGET_V9 ? 128 : 64)
1bb87f28 403
10d1b70f
JW
404/* ALIGN FRAMES on double word boundaries */
405
7a6cf439
DE
406#define SPARC_STACK_ALIGN(LOC) \
407 (TARGET_V9 ? (((LOC)+15) & ~15) : (((LOC)+7) & ~7))
10d1b70f 408
1bb87f28
JW
409/* Allocation boundary (in *bits*) for the code of a function. */
410#define FUNCTION_BOUNDARY 32
411
412/* Alignment of field after `int : 0' in a structure. */
7a6cf439
DE
413/* ??? Should this be based on TARGET_INT64? */
414#define EMPTY_FIELD_BOUNDARY (TARGET_V9 ? 64 : 32)
1bb87f28
JW
415
416/* Every structure's size must be a multiple of this. */
417#define STRUCTURE_SIZE_BOUNDARY 8
418
419/* A bitfield declared as `int' forces `int' alignment for the struct. */
420#define PCC_BITFIELD_TYPE_MATTERS 1
421
422/* No data type wants to be aligned rounder than this. */
7a6cf439 423#define BIGGEST_ALIGNMENT (TARGET_V9 ? 128 : 64)
1bb87f28 424
77a02b01
JW
425/* The best alignment to use in cases where we have a choice. */
426#define FASTEST_ALIGNMENT 64
427
1bb87f28
JW
428/* Make strings word-aligned so strcpy from constants will be faster. */
429#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
d2a8e680
RS
430 ((TREE_CODE (EXP) == STRING_CST \
431 && (ALIGN) < FASTEST_ALIGNMENT) \
432 ? FASTEST_ALIGNMENT : (ALIGN))
1bb87f28
JW
433
434/* Make arrays of chars word-aligned for the same reasons. */
435#define DATA_ALIGNMENT(TYPE, ALIGN) \
436 (TREE_CODE (TYPE) == ARRAY_TYPE \
437 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
77a02b01 438 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
1bb87f28 439
b4ac57ab 440/* Set this nonzero if move instructions will actually fail to work
1bb87f28 441 when given unaligned data. */
b4ac57ab 442#define STRICT_ALIGNMENT 1
1bb87f28
JW
443
444/* Things that must be doubleword aligned cannot go in the text section,
445 because the linker fails to align the text section enough!
7a6cf439 446 Put them in the data section. This macro is only used in this file. */
1bb87f28
JW
447#define MAX_TEXT_ALIGN 32
448
68d69835
JM
449/* This forces all variables and constants to the data section when PIC.
450 This is because the SunOS 4 shared library scheme thinks everything in
451 text is a function, and patches the address to point to a loader stub. */
452/* This is defined to zero for every system which doesn't use the a.out object
453 file format. */
454#ifndef SUNOS4_SHARED_LIBRARIES
455#define SUNOS4_SHARED_LIBRARIES 0
456#endif
457
7a6cf439 458/* This is defined differently for v9 in a cover file. */
1bb87f28
JW
459#define SELECT_SECTION(T,RELOC) \
460{ \
461 if (TREE_CODE (T) == VAR_DECL) \
462 { \
463 if (TREE_READONLY (T) && ! TREE_SIDE_EFFECTS (T) \
ed8969fa
JW
464 && DECL_INITIAL (T) \
465 && (DECL_INITIAL (T) == error_mark_node \
466 || TREE_CONSTANT (DECL_INITIAL (T))) \
1bb87f28 467 && DECL_ALIGN (T) <= MAX_TEXT_ALIGN \
68d69835 468 && ! (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))) \
1bb87f28
JW
469 text_section (); \
470 else \
471 data_section (); \
472 } \
473 else if (TREE_CODE (T) == CONSTRUCTOR) \
474 { \
68d69835 475 if (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES)) \
1bb87f28
JW
476 data_section (); \
477 } \
478 else if (*tree_code_type[(int) TREE_CODE (T)] == 'c') \
479 { \
480 if ((TREE_CODE (T) == STRING_CST && flag_writable_strings) \
68d69835
JM
481 || TYPE_ALIGN (TREE_TYPE (T)) > MAX_TEXT_ALIGN \
482 || (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))) \
1bb87f28
JW
483 data_section (); \
484 else \
485 text_section (); \
486 } \
487}
488
489/* Use text section for a constant
490 unless we need more alignment than that offers. */
7a6cf439 491/* This is defined differently for v9 in a cover file. */
1bb87f28
JW
492#define SELECT_RTX_SECTION(MODE, X) \
493{ \
494 if (GET_MODE_BITSIZE (MODE) <= MAX_TEXT_ALIGN \
68d69835 495 && ! (flag_pic && (symbolic_operand (X) || SUNOS4_SHARED_LIBRARIES))) \
1bb87f28
JW
496 text_section (); \
497 else \
498 data_section (); \
499}
500\f
501/* Standard register usage. */
502
503/* Number of actual hardware registers.
504 The hardware registers are assigned numbers for the compiler
505 from 0 to just below FIRST_PSEUDO_REGISTER.
506 All registers that the compiler knows about must be given numbers,
507 even those that are not normally considered general registers.
508
7a6cf439
DE
509 SPARC has 32 integer registers and 32 floating point registers.
510 64 bit SPARC has 32 additional fp regs, but the odd numbered ones are not
511 accessible. We still account for them to simplify register computations
512 (eg: in CLASS_MAX_NREGS). There are also 4 fp condition code registers, so
513 32+32+32+4 == 100.
514 Register 0 is used as the integer condition code register. */
1bb87f28 515
7a6cf439
DE
516#ifdef SPARCV9
517#define FIRST_PSEUDO_REGISTER 100
518#else
1bb87f28 519#define FIRST_PSEUDO_REGISTER 64
7a6cf439 520#endif
1bb87f28
JW
521
522/* 1 for registers that have pervasive standard uses
523 and are not available for the register allocator.
5b485d2c 524 g0 is used for the condition code and not to represent %g0, which is
1bb87f28 525 hardwired to 0, so reg 0 is *not* fixed.
7a6cf439 526 On non-v9 systems:
34ad7aaf
JW
527 g1 is free to use as temporary.
528 g2-g4 are reserved for applications. Gcc normally uses them as
529 temporaries, but this can be disabled via the -mno-app-regs option.
7a6cf439
DE
530 g5 through g7 are reserved for the operating system.
531 On v9 systems:
532 g1 and g5 are free to use as temporaries.
533 g2-g4 are reserved for applications (the compiler will not normally use
534 them, but they can be used as temporaries with -mapp-regs).
535 g6-g7 are reserved for the operating system.
536 ??? Register 1 is used as a temporary by the 64 bit sethi pattern, so must
537 currently be a fixed register until this pattern is rewritten.
538 Register 1 is also used when restoring call-preserved registers in large
539 stack frames. */
540
541#ifdef SPARCV9
542#define FIXED_REGISTERS \
543 {0, 1, 1, 1, 1, 0, 1, 1, \
544 0, 0, 0, 0, 0, 0, 1, 0, \
545 0, 0, 0, 0, 0, 0, 0, 0, \
546 0, 0, 0, 0, 0, 0, 1, 1, \
547 \
548 0, 0, 0, 0, 0, 0, 0, 0, \
549 0, 0, 0, 0, 0, 0, 0, 0, \
550 0, 0, 0, 0, 0, 0, 0, 0, \
551 0, 0, 0, 0, 0, 0, 0, 0, \
552 \
553 0, 0, 0, 0, 0, 0, 0, 0, \
554 0, 0, 0, 0, 0, 0, 0, 0, \
555 0, 0, 0, 0, 0, 0, 0, 0, \
556 0, 0, 0, 0, 0, 0, 0, 0, \
557 \
558 0, 0, 0, 0}
559#else
1bb87f28 560#define FIXED_REGISTERS \
d9ca49d5 561 {0, 0, 0, 0, 0, 1, 1, 1, \
1bb87f28
JW
562 0, 0, 0, 0, 0, 0, 1, 0, \
563 0, 0, 0, 0, 0, 0, 0, 0, \
564 0, 0, 0, 0, 0, 0, 1, 1, \
565 \
566 0, 0, 0, 0, 0, 0, 0, 0, \
567 0, 0, 0, 0, 0, 0, 0, 0, \
568 0, 0, 0, 0, 0, 0, 0, 0, \
569 0, 0, 0, 0, 0, 0, 0, 0}
7a6cf439 570#endif
1bb87f28
JW
571
572/* 1 for registers not available across function calls.
573 These must include the FIXED_REGISTERS and also any
574 registers that can be used without being saved.
575 The latter must include the registers where values are returned
576 and the register where structure-value addresses are passed.
577 Aside from that, you can include as many other registers as you like. */
7a6cf439
DE
578
579#ifdef SPARCV9
580#define CALL_USED_REGISTERS \
581 {1, 1, 1, 1, 1, 1, 1, 1, \
582 1, 1, 1, 1, 1, 1, 1, 1, \
583 0, 0, 0, 0, 0, 0, 0, 0, \
584 0, 0, 0, 0, 0, 0, 1, 1, \
585 \
586 1, 1, 1, 1, 1, 1, 1, 1, \
587 1, 1, 1, 1, 1, 1, 1, 1, \
588 0, 0, 0, 0, 0, 0, 0, 0, \
589 0, 0, 0, 0, 0, 0, 0, 0, \
590 \
591 0, 0, 0, 0, 0, 0, 0, 0, \
592 0, 0, 0, 0, 0, 0, 0, 0, \
593 1, 1, 1, 1, 1, 1, 1, 1, \
594 1, 1, 1, 1, 1, 1, 1, 1, \
595 \
596 1, 1, 1, 1}
597#else
1bb87f28
JW
598#define CALL_USED_REGISTERS \
599 {1, 1, 1, 1, 1, 1, 1, 1, \
600 1, 1, 1, 1, 1, 1, 1, 1, \
601 0, 0, 0, 0, 0, 0, 0, 0, \
602 0, 0, 0, 0, 0, 0, 1, 1, \
603 \
604 1, 1, 1, 1, 1, 1, 1, 1, \
605 1, 1, 1, 1, 1, 1, 1, 1, \
606 1, 1, 1, 1, 1, 1, 1, 1, \
607 1, 1, 1, 1, 1, 1, 1, 1}
7a6cf439 608#endif
1bb87f28 609
26c5587d 610/* If !TARGET_FPU, then make the fp registers fixed so that they won't
7a6cf439 611 be allocated. On v9, also make the fp cc regs fixed. */
26c5587d
JW
612
613#define CONDITIONAL_REGISTER_USAGE \
614do \
615 { \
616 if (! TARGET_FPU) \
617 { \
618 int regno; \
7a6cf439 619 for (regno = 32; regno < FIRST_PSEUDO_REGISTER; regno++) \
26c5587d
JW
620 fixed_regs[regno] = 1; \
621 } \
34ad7aaf
JW
622 if (! TARGET_APP_REGS) \
623 { \
624 fixed_regs[2] = 1; \
625 fixed_regs[3] = 1; \
626 fixed_regs[4] = 1; \
627 } \
7a6cf439
DE
628 else \
629 { \
630 fixed_regs[2] = 0; \
631 fixed_regs[3] = 0; \
2454c8d4 632 fixed_regs[4] = TARGET_MEDANY != 0; \
7a6cf439 633 } \
5c56efde
DE
634 if (TARGET_FLAT) \
635 { \
636 /* Let the compiler believe the frame pointer is still \
637 %fp, but output it as %i7. */ \
638 fixed_regs[31] = 1; \
639 reg_names[FRAME_POINTER_REGNUM] = "%i7"; \
640 /* ??? This is a hack to disable leaf functions. */ \
641 global_regs[7] = 1; \
642 } \
9ee6230c
JW
643 if (profile_block_flag) \
644 { \
645 /* %g1 and %g2 must be fixed, because BLOCK_PROFILER \
646 uses them. */ \
647 fixed_regs[1] = 1; \
648 fixed_regs[2] = 1; \
649 } \
26c5587d
JW
650 } \
651while (0)
652
1bb87f28
JW
653/* Return number of consecutive hard regs needed starting at reg REGNO
654 to hold something of mode MODE.
655 This is ordinarily the length in words of a value of mode MODE
656 but can be less for certain modes in special long registers.
657
658 On SPARC, ordinary registers hold 32 bits worth;
659 this means both integer and floating point registers.
7a6cf439
DE
660 On v9, integer regs hold 64 bits worth; floating point regs hold
661 32 bits worth (this includes the new fp regs as even the odd ones are
662 included in the hard register count). */
1bb87f28 663
7a6cf439
DE
664#define HARD_REGNO_NREGS(REGNO, MODE) \
665 (TARGET_V9 \
666 ? ((REGNO) < 32 \
667 ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD \
668 : (GET_MODE_SIZE (MODE) + 3) / 4) \
669 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
1bb87f28
JW
670
671/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
923a8d06 672 See sparc.c for how we initialize this. */
7a6cf439
DE
673extern int *hard_regno_mode_classes;
674extern int sparc_mode_class[];
1bb87f28 675#define HARD_REGNO_MODE_OK(REGNO, MODE) \
7a6cf439 676 ((hard_regno_mode_classes[REGNO] & sparc_mode_class[MODE]) != 0)
1bb87f28
JW
677
678/* Value is 1 if it is a good idea to tie two pseudo registers
679 when one has mode MODE1 and one has mode MODE2.
680 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
7a6cf439
DE
681 for any hard reg, then this must be 0 for correct output.
682
683 For V9: SFmode can't be combined with other float modes, because they can't
684 be allocated to the %d registers. Also, DFmode won't fit in odd %f
685 registers, but SFmode will. */
1bb87f28 686#define MODES_TIEABLE_P(MODE1, MODE2) \
7a6cf439
DE
687 ((MODE1) == (MODE2) \
688 || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
689 && (! TARGET_V9 \
690 || (GET_MODE_CLASS (MODE1) != MODE_FLOAT \
691 || (MODE1 != SFmode && MODE2 != SFmode)))))
1bb87f28
JW
692
693/* Specify the registers used for certain standard purposes.
694 The values of these macros are register numbers. */
695
696/* SPARC pc isn't overloaded on a register that the compiler knows about. */
697/* #define PC_REGNUM */
698
699/* Register to use for pushing function arguments. */
700#define STACK_POINTER_REGNUM 14
701
7a6cf439
DE
702/* Actual top-of-stack address is 92/136 greater than the contents of the
703 stack pointer register for !v9/v9. That is:
704 - !v9: 64 bytes for the in and local registers, 4 bytes for structure return
705 address, and 24 bytes for the 6 register parameters.
706 - v9: 128 bytes for the in and local registers + 8 bytes reserved. */
1bb87f28
JW
707#define STACK_POINTER_OFFSET FIRST_PARM_OFFSET(0)
708
7a6cf439
DE
709/* The stack bias (amount by which the hardware register is offset by). */
710#define SPARC_STACK_BIAS (TARGET_STACK_BIAS ? 2047 : 0)
711
1bb87f28
JW
712/* Base register for access to local variables of the function. */
713#define FRAME_POINTER_REGNUM 30
714
715#if 0
716/* Register that is used for the return address. */
717#define RETURN_ADDR_REGNUM 15
718#endif
719
720/* Value should be nonzero if functions must have frame pointers.
721 Zero means the frame pointer need not be set up (and parms
722 may be accessed via the stack pointer) in functions that seem suitable.
723 This is computed in `reload', in reload1.c.
a061b9fa 724 Used in flow.c, global.c, and reload1.c.
1bb87f28 725
a061b9fa
DE
726 Being a non-leaf function does not mean a frame pointer is needed in the
727 flat window model. However, the debugger won't be able to backtrace through
728 us with out it. */
1bb87f28 729#define FRAME_POINTER_REQUIRED \
a061b9fa
DE
730 (TARGET_FRW ? (current_function_calls_alloca || current_function_varargs \
731 || !leaf_function_p ()) \
5c56efde 732 : ! (leaf_function_p () && only_leaf_regs_used ()))
1bb87f28
JW
733
734/* C statement to store the difference between the frame pointer
735 and the stack pointer values immediately after the function prologue.
736
737 Note, we always pretend that this is a leaf function because if
738 it's not, there's no point in trying to eliminate the
739 frame pointer. If it is a leaf function, we guessed right! */
740#define INITIAL_FRAME_POINTER_OFFSET(VAR) \
5c56efde 741 ((VAR) = (TARGET_FRW ? sparc_flat_compute_frame_size (get_frame_size ()) \
5b485d2c 742 : compute_frame_size (get_frame_size (), 1)))
1bb87f28
JW
743
744/* Base register for access to arguments of the function. */
5c56efde 745#define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
1bb87f28 746
6098b63e 747/* Register in which static-chain is passed to a function. This must
7a6cf439
DE
748 not be a register used by the prologue.
749 ??? v9: Since %g2 is reserved but %g5 is available, perhaps use %g5. */
6098b63e 750#define STATIC_CHAIN_REGNUM 2
1bb87f28
JW
751
752/* Register which holds offset table for position-independent
753 data references. */
754
755#define PIC_OFFSET_TABLE_REGNUM 23
756
757#define INITIALIZE_PIC initialize_pic ()
758#define FINALIZE_PIC finalize_pic ()
759
d9ca49d5 760/* Sparc ABI says that quad-precision floats and all structures are returned
7a6cf439
DE
761 in memory.
762 For v9, all aggregates are returned in memory. */
686667bf
JW
763#define RETURN_IN_MEMORY(TYPE) \
764 (TYPE_MODE (TYPE) == BLKmode \
765 || (! TARGET_V9 && (TYPE_MODE (TYPE) == TFmode \
766 || TYPE_MODE (TYPE) == TCmode)))
d9ca49d5 767
1bb87f28
JW
768/* Functions which return large structures get the address
769 to place the wanted value at offset 64 from the frame.
7a6cf439
DE
770 Must reserve 64 bytes for the in and local registers.
771 v9: Functions which return large structures get the address to place the
772 wanted value from an invisible first argument. */
1bb87f28
JW
773/* Used only in other #defines in this file. */
774#define STRUCT_VALUE_OFFSET 64
775
776#define STRUCT_VALUE \
7a6cf439
DE
777 (TARGET_V9 \
778 ? 0 \
779 : gen_rtx (MEM, Pmode, \
780 gen_rtx (PLUS, Pmode, stack_pointer_rtx, \
781 gen_rtx (CONST_INT, VOIDmode, STRUCT_VALUE_OFFSET))))
1bb87f28 782#define STRUCT_VALUE_INCOMING \
7a6cf439
DE
783 (TARGET_V9 \
784 ? 0 \
785 : gen_rtx (MEM, Pmode, \
786 gen_rtx (PLUS, Pmode, frame_pointer_rtx, \
787 gen_rtx (CONST_INT, VOIDmode, STRUCT_VALUE_OFFSET))))
1bb87f28
JW
788\f
789/* Define the classes of registers for register constraints in the
790 machine description. Also define ranges of constants.
791
792 One of the classes must always be named ALL_REGS and include all hard regs.
793 If there is more than one class, another class must be named NO_REGS
794 and contain no registers.
795
796 The name GENERAL_REGS must be the name of a class (or an alias for
797 another name such as ALL_REGS). This is the class of registers
798 that is allowed by "g" or "r" in a register constraint.
799 Also, registers outside this class are allocated only when
800 instructions express preferences for them.
801
802 The classes must be numbered in nondecreasing order; that is,
803 a larger-numbered class must never be contained completely
804 in a smaller-numbered class.
805
806 For any two classes, it is very desirable that there be another
807 class that represents their union. */
808
7a6cf439 809/* The SPARC has two kinds of registers, general and floating point.
24b63396
JW
810
811 For v9 we must distinguish between the upper and lower floating point
812 registers because the upper ones can't hold SFmode values.
813 HARD_REGNO_MODE_OK won't help here because reload assumes that register(s)
814 satisfying a group need for a class will also satisfy a single need for
815 that class. EXTRA_FP_REGS is a bit of a misnomer as it covers all 64 fp
816 regs.
817
818 It is important that one class contains all the general and all the standard
819 fp regs. Otherwise find_reg() won't properly allocate int regs for moves,
820 because reg_class_record() will bias the selection in favor of fp regs,
821 because reg_class_subunion[GENERAL_REGS][FP_REGS] will yield FP_REGS,
822 because FP_REGS > GENERAL_REGS.
823
824 It is also important that one class contain all the general and all the
825 fp regs. Otherwise when spilling a DFmode reg, it may be from EXTRA_FP_REGS
826 but find_reloads() may use class GENERAL_OR_FP_REGS. This will cause
827 allocate_reload_reg() to bypass it causing an abort because the compiler
828 thinks it doesn't have a spill reg when in fact it does.
829
7a6cf439
DE
830 v9 also has 4 floating point condition code registers. Since we don't
831 have a class that is the union of FPCC_REGS with either of the others,
832 it is important that it appear first. Otherwise the compiler will die
833 trying to compile _fixunsdfsi because fix_truncdfsi2 won't match its
834 constraints. */
7a6cf439
DE
835
836#ifdef SPARCV9
24b63396
JW
837enum reg_class { NO_REGS, FPCC_REGS, GENERAL_REGS, FP_REGS, EXTRA_FP_REGS,
838 GENERAL_OR_FP_REGS, GENERAL_OR_EXTRA_FP_REGS,
7a6cf439
DE
839 ALL_REGS, LIM_REG_CLASSES };
840#else
1bb87f28 841enum reg_class { NO_REGS, GENERAL_REGS, FP_REGS, ALL_REGS, LIM_REG_CLASSES };
7a6cf439 842#endif
1bb87f28
JW
843
844#define N_REG_CLASSES (int) LIM_REG_CLASSES
845
846/* Give names of register classes as strings for dump file. */
847
7a6cf439 848#ifdef SPARCV9
1bb87f28 849#define REG_CLASS_NAMES \
24b63396
JW
850 { "NO_REGS", "FPCC_REGS", "GENERAL_REGS", "FP_REGS", "EXTRA_FP_REGS", \
851 "GENERAL_OR_FP_REGS", "GENERAL_OR_EXTRA_FP_REGS", "ALL_REGS" }
7a6cf439
DE
852#else
853#define REG_CLASS_NAMES \
24b63396 854 { "NO_REGS", "GENERAL_REGS", "FP_REGS", "ALL_REGS" }
7a6cf439 855#endif
1bb87f28
JW
856
857/* Define which registers fit in which classes.
858 This is an initializer for a vector of HARD_REG_SET
859 of length N_REG_CLASSES. */
860
7a6cf439
DE
861#ifdef SPARCV9
862#define REG_CLASS_CONTENTS \
24b63396
JW
863 {{0, 0, 0, 0}, {0, 0, 0, 0xf}, {-2, 0, 0, 0}, \
864 {0, -1, 0, 0}, {0, -1, -1, 0}, {-2, -1, 0, 0}, {-2, -1, -1, 0}, \
865 {-2, -1, -1, 0xf}}
7a6cf439 866#else
1bb87f28
JW
867#if 0 && defined (__GNUC__)
868#define REG_CLASS_CONTENTS {0LL, 0xfffffffeLL, 0xffffffff00000000LL, 0xfffffffffffffffeLL}
869#else
870#define REG_CLASS_CONTENTS {{0, 0}, {-2, 0}, {0, -1}, {-2, -1}}
871#endif
7a6cf439 872#endif
1bb87f28
JW
873
874/* The same information, inverted:
875 Return the class number of the smallest class containing
876 reg number REGNO. This could be a conditional expression
877 or could index an array. */
878
7a6cf439 879#ifdef SPARCV9
24b63396
JW
880#define REGNO_REG_CLASS(REGNO) \
881 ((REGNO) == 0 ? NO_REGS \
882 : (REGNO) < 32 ? GENERAL_REGS \
883 : (REGNO) < 64 ? FP_REGS \
884 : (REGNO) < 96 ? EXTRA_FP_REGS \
885 : FPCC_REGS)
7a6cf439 886#else
1bb87f28
JW
887#define REGNO_REG_CLASS(REGNO) \
888 ((REGNO) >= 32 ? FP_REGS : (REGNO) == 0 ? NO_REGS : GENERAL_REGS)
7a6cf439 889#endif
1bb87f28 890
7a6cf439 891/* This is the order in which to allocate registers normally.
51f0e748
JW
892
893 We put %f0/%f1 last among the float registers, so as to make it more
6a4bb1fa 894 likely that a pseudo-register which dies in the float return register
51f0e748 895 will get allocated to the float return register, thus saving a move
7a6cf439
DE
896 instruction at the end of the function.
897
898 On v9, the float registers are ordered a little "funny" because some
899 of them (%f16-%f47) are call-preserved. */
900#ifdef SPARCV9
901#define REG_ALLOC_ORDER \
902{ 8, 9, 10, 11, 12, 13, \
903 15, 16, 17, 18, 19, 20, 21, 22, \
904 23, 24, 25, 26, 27, 28, 29, 31, \
905 34, 35, 36, 37, 38, 39, /* %f2-%f7 */ \
906 40, 41, 42, 43, 44, 45, 46, 47, /* %f8-%f15 */ \
907 80, 81, 82, 83, 84, 85, 86, 87, /* %f48-%f55 */ \
908 88, 89, 90, 91, 92, 93, 94, 95, /* %f56-%f63 */ \
909 48, 49, 50, 51, 52, 53, 54, 55, /* %f16-%f23 */ \
910 56, 57, 58, 59, 60, 61, 62, 63, /* %f24-%f31 */ \
911 64, 65, 66, 67, 68, 69, 70, 71, /* %f32-%f39 */ \
912 72, 73, 74, 75, 76, 77, 78, 79, /* %f40-%f47 */ \
913 32, 33, /* %f0,%f1 */ \
914 96, 97, 98, 99, /* %fcc0-3 */ \
915 1, 5, 2, 3, 4, 6, 7, 0, 14, 30}
916#else
1bb87f28 917#define REG_ALLOC_ORDER \
b4ac57ab
RS
918{ 8, 9, 10, 11, 12, 13, 2, 3, \
919 15, 16, 17, 18, 19, 20, 21, 22, \
920 23, 24, 25, 26, 27, 28, 29, 31, \
51f0e748 921 34, 35, 36, 37, 38, 39, \
1bb87f28
JW
922 40, 41, 42, 43, 44, 45, 46, 47, \
923 48, 49, 50, 51, 52, 53, 54, 55, \
924 56, 57, 58, 59, 60, 61, 62, 63, \
51f0e748 925 32, 33, \
4b69d2a3 926 1, 4, 5, 6, 7, 0, 14, 30}
7a6cf439 927#endif
1bb87f28
JW
928
929/* This is the order in which to allocate registers for
930 leaf functions. If all registers can fit in the "i" registers,
7a6cf439
DE
931 then we have the possibility of having a leaf function.
932 v9: The floating point registers are ordered a little "funny" because some
933 of them (%f16-%f47) are call-preserved. */
934#ifdef SPARCV9
935#define REG_LEAF_ALLOC_ORDER \
936{ 24, 25, 26, 27, 28, 29, \
937 15, 8, 9, 10, 11, 12, 13, \
938 16, 17, 18, 19, 20, 21, 22, 23, \
939 34, 35, 36, 37, 38, 39, \
940 40, 41, 42, 43, 44, 45, 46, 47, \
941 80, 81, 82, 83, 84, 85, 86, 87, \
942 88, 89, 90, 91, 92, 93, 94, 95, \
943 48, 49, 50, 51, 52, 53, 54, 55, \
944 56, 57, 58, 59, 60, 61, 62, 63, \
945 64, 65, 66, 67, 68, 69, 70, 71, \
946 72, 73, 74, 75, 76, 77, 78, 79, \
947 32, 33, \
948 96, 97, 98, 99, \
949 1, 5, 2, 3, 4, 6, 7, 0, 14, 30, 31}
950#else
1bb87f28
JW
951#define REG_LEAF_ALLOC_ORDER \
952{ 2, 3, 24, 25, 26, 27, 28, 29, \
953 15, 8, 9, 10, 11, 12, 13, \
954 16, 17, 18, 19, 20, 21, 22, 23, \
51f0e748 955 34, 35, 36, 37, 38, 39, \
1bb87f28
JW
956 40, 41, 42, 43, 44, 45, 46, 47, \
957 48, 49, 50, 51, 52, 53, 54, 55, \
958 56, 57, 58, 59, 60, 61, 62, 63, \
51f0e748 959 32, 33, \
4b69d2a3 960 1, 4, 5, 6, 7, 0, 14, 30, 31}
7a6cf439 961#endif
1bb87f28
JW
962
963#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()
964
5c56efde
DE
965/* ??? %g7 is not a leaf register to effectively #undef LEAF_REGISTERS when
966 -mflat is used. Function only_leaf_regs_used will return 0 if a global
967 register is used and is not permitted in a leaf function. We make %g7
968 a global reg if -mflat and voila. Since %g7 is a system register and is
969 fixed it won't be used by gcc anyway. */
7a6cf439
DE
970#ifdef SPARCV9
971#define LEAF_REGISTERS \
972{ 1, 1, 1, 1, 1, 1, 1, 0, \
973 0, 0, 0, 0, 0, 0, 1, 0, \
974 0, 0, 0, 0, 0, 0, 0, 0, \
975 1, 1, 1, 1, 1, 1, 0, 1, \
976 1, 1, 1, 1, 1, 1, 1, 1, \
977 1, 1, 1, 1, 1, 1, 1, 1, \
978 1, 1, 1, 1, 1, 1, 1, 1, \
979 1, 1, 1, 1, 1, 1, 1, 1, \
980 1, 1, 1, 1, 1, 1, 1, 1, \
981 1, 1, 1, 1, 1, 1, 1, 1, \
982 1, 1, 1, 1, 1, 1, 1, 1, \
983 1, 1, 1, 1, 1, 1, 1, 1, \
984 1, 1, 1, 1}
985#else
1bb87f28 986#define LEAF_REGISTERS \
5c56efde 987{ 1, 1, 1, 1, 1, 1, 1, 0, \
1bb87f28
JW
988 0, 0, 0, 0, 0, 0, 1, 0, \
989 0, 0, 0, 0, 0, 0, 0, 0, \
990 1, 1, 1, 1, 1, 1, 0, 1, \
991 1, 1, 1, 1, 1, 1, 1, 1, \
992 1, 1, 1, 1, 1, 1, 1, 1, \
993 1, 1, 1, 1, 1, 1, 1, 1, \
4b69d2a3 994 1, 1, 1, 1, 1, 1, 1, 1}
7a6cf439 995#endif
1bb87f28
JW
996
997extern char leaf_reg_remap[];
998#define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO])
1bb87f28 999
1bb87f28
JW
1000/* The class value for index registers, and the one for base regs. */
1001#define INDEX_REG_CLASS GENERAL_REGS
1002#define BASE_REG_CLASS GENERAL_REGS
1003
24b63396
JW
1004/* Local macro to handle the two v9 classes of FP regs. */
1005#ifdef SPARCV9
1006#define FP_REG_CLASS_P(CLASS) ((CLASS) == FP_REGS || (CLASS) == EXTRA_FP_REGS)
1007#else
1008#define FP_REG_CLASS_P(CLASS) ((CLASS) == FP_REGS)
1009#endif
1010
1bb87f28
JW
1011/* Get reg_class from a letter such as appears in the machine description. */
1012
7a6cf439
DE
1013#ifdef SPARCV9
1014#define REG_CLASS_FROM_LETTER(C) \
24b63396
JW
1015 ((C) == 'f' ? FP_REGS \
1016 : (C) == 'e' ? EXTRA_FP_REGS \
1017 : (C) == 'c' ? FPCC_REGS \
1018 : NO_REGS)
7a6cf439 1019#else
24b63396
JW
1020/* Coerce v9's 'e' class to 'f', so we can use 'e' in the .md file for
1021 v8 and v9. */
1bb87f28 1022#define REG_CLASS_FROM_LETTER(C) \
24b63396 1023 ((C) == 'f' ? FP_REGS : (C) == 'e' ? FP_REGS : NO_REGS)
7a6cf439 1024#endif
1bb87f28
JW
1025
1026/* The letters I, J, K, L and M in a register constraint string
1027 can be used to stand for particular ranges of immediate operands.
1028 This macro defines what the ranges are.
1029 C is the letter, and VALUE is a constant value.
1030 Return 1 if VALUE is in the range specified by C.
1031
1032 For SPARC, `I' is used for the range of constants an insn
1033 can actually contain.
1034 `J' is used for the range which is just zero (since that is R0).
9ad2c692 1035 `K' is used for constants which can be loaded with a single sethi insn. */
1bb87f28
JW
1036
1037#define SMALL_INT(X) ((unsigned) (INTVAL (X) + 0x1000) < 0x2000)
1038
1039#define CONST_OK_FOR_LETTER_P(VALUE, C) \
1040 ((C) == 'I' ? (unsigned) ((VALUE) + 0x1000) < 0x2000 \
1041 : (C) == 'J' ? (VALUE) == 0 \
1042 : (C) == 'K' ? ((VALUE) & 0x3ff) == 0 \
1043 : 0)
1044
1045/* Similar, but for floating constants, and defining letters G and H.
1046 Here VALUE is the CONST_DOUBLE rtx itself. */
1047
1048#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
96f69de5 1049 ((C) == 'G' ? fp_zero_operand (VALUE) \
1bb87f28
JW
1050 : (C) == 'H' ? arith_double_operand (VALUE, DImode) \
1051 : 0)
1052
1053/* Given an rtx X being reloaded into a reg required to be
1054 in class CLASS, return the class of reg to actually use.
1055 In general this is just CLASS; but on some machines
1056 in some cases it is preferable to use a more restrictive class. */
2b9a9aea
JW
1057/* We can't load constants into FP registers. We can't load any FP constant
1058 if an 'E' constraint fails to match it. */
1059#define PREFERRED_RELOAD_CLASS(X,CLASS) \
1060 (CONSTANT_P (X) \
24b63396 1061 && (FP_REG_CLASS_P (CLASS) \
2b9a9aea
JW
1062 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
1063 && (HOST_FLOAT_FORMAT != IEEE_FLOAT_FORMAT \
1064 || HOST_BITS_PER_INT != BITS_PER_WORD))) \
1065 ? NO_REGS : (CLASS))
1bb87f28
JW
1066
1067/* Return the register class of a scratch register needed to load IN into
1068 a register of class CLASS in MODE.
1069
1070 On the SPARC, when PIC, we need a temporary when loading some addresses
ae51bd97 1071 into a register.
1bb87f28 1072
ae51bd97
JW
1073 Also, we need a temporary when loading/storing a HImode/QImode value
1074 between memory and the FPU registers. This can happen when combine puts
1075 a paradoxical subreg in a float/fix conversion insn. */
1076
1077#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, IN) \
24b63396
JW
1078 ((FP_REG_CLASS_P (CLASS) && ((MODE) == HImode || (MODE) == QImode) \
1079 && (GET_CODE (IN) == MEM \
1080 || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
1081 && true_regnum (IN) == -1))) ? GENERAL_REGS : NO_REGS)
ae51bd97
JW
1082
1083#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, IN) \
24b63396
JW
1084 ((FP_REG_CLASS_P (CLASS) && ((MODE) == HImode || (MODE) == QImode) \
1085 && (GET_CODE (IN) == MEM \
1086 || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
1087 && true_regnum (IN) == -1))) ? GENERAL_REGS : NO_REGS)
1bb87f28 1088
b924cef0
JW
1089/* On SPARC it is not possible to directly move data between
1090 GENERAL_REGS and FP_REGS. */
24b63396
JW
1091#define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
1092 (FP_REG_CLASS_P (CLASS1) != FP_REG_CLASS_P (CLASS2))
b924cef0 1093
55be783d
JW
1094/* Return the stack location to use for secondary memory needed reloads.
1095 We want to use the reserved location just below the frame pointer.
1096 However, we must ensure that there is a frame, so use assign_stack_local
1097 if the frame size is zero. */
fe1f7f24 1098#define SECONDARY_MEMORY_NEEDED_RTX(MODE) \
55be783d 1099 (get_frame_size () == 0 \
fb3eb6f6 1100 ? assign_stack_local (MODE, GET_MODE_SIZE (MODE), 0) \
55be783d
JW
1101 : gen_rtx (MEM, MODE, gen_rtx (PLUS, Pmode, frame_pointer_rtx, \
1102 GEN_INT (STARTING_FRAME_OFFSET))))
fe1f7f24 1103
7a6cf439
DE
1104/* Get_secondary_mem widens it's argument to BITS_PER_WORD which loses on v9
1105 because the movsi and movsf patterns don't handle r/f moves.
1106 For v8 we copy the default definition. */
1107#define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
1108 (TARGET_V9 \
fb3eb6f6
JW
1109 ? (GET_MODE_BITSIZE (MODE) < 32 \
1110 ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \
7a6cf439 1111 : MODE) \
fb3eb6f6
JW
1112 : (GET_MODE_BITSIZE (MODE) < BITS_PER_WORD \
1113 ? mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (MODE), 0) \
7a6cf439
DE
1114 : MODE))
1115
1bb87f28
JW
1116/* Return the maximum number of consecutive registers
1117 needed to represent mode MODE in a register of class CLASS. */
1118/* On SPARC, this is the size of MODE in words. */
1119#define CLASS_MAX_NREGS(CLASS, MODE) \
24b63396 1120 (FP_REG_CLASS_P (CLASS) ? (GET_MODE_SIZE (MODE) + 3) / 4 \
7a6cf439 1121 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1bb87f28
JW
1122\f
1123/* Stack layout; function entry, exit and calling. */
1124
1125/* Define the number of register that can hold parameters.
7a6cf439
DE
1126 These two macros are used only in other macro definitions below.
1127 MODE is the mode of the argument.
1128 !v9: All args are passed in %o0-%o5.
1129 v9: Non-float args are passed in %o0-5 and float args are passed in
1130 %f0-%f15. */
1131#define NPARM_REGS(MODE) \
1132 (TARGET_V9 ? (GET_MODE_CLASS (MODE) == MODE_FLOAT ? 16 : 6) : 6)
1bb87f28
JW
1133
1134/* Define this if pushing a word on the stack
1135 makes the stack pointer a smaller address. */
1136#define STACK_GROWS_DOWNWARD
1137
1138/* Define this if the nominal address of the stack frame
1139 is at the high-address end of the local variables;
1140 that is, each additional local variable allocated
1141 goes at a more negative offset in the frame. */
1142#define FRAME_GROWS_DOWNWARD
1143
1144/* Offset within stack frame to start allocating local variables at.
1145 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1146 first local allocated. Otherwise, it is the offset to the BEGINNING
1147 of the first local allocated. */
7238ce3a
JW
1148/* This allows space for one TFmode floating point value. */
1149#define STARTING_FRAME_OFFSET \
7a6cf439
DE
1150 (TARGET_V9 ? (SPARC_STACK_BIAS - 16) \
1151 : (-SPARC_STACK_ALIGN (LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)))
1bb87f28
JW
1152
1153/* If we generate an insn to push BYTES bytes,
1154 this says how many the stack pointer really advances by.
1155 On SPARC, don't define this because there are no push insns. */
1156/* #define PUSH_ROUNDING(BYTES) */
1157
1158/* Offset of first parameter from the argument pointer register value.
7a6cf439
DE
1159 !v9: This is 64 for the ins and locals, plus 4 for the struct-return reg
1160 even if this function isn't going to use it.
1161 v9: This is 128 for the ins and locals, plus a reserved space of 8. */
1162#define FIRST_PARM_OFFSET(FNDECL) \
1163 (TARGET_V9 ? (SPARC_STACK_BIAS + 136) \
1164 : (STRUCT_VALUE_OFFSET + UNITS_PER_WORD))
1bb87f28
JW
1165
1166/* When a parameter is passed in a register, stack space is still
1167 allocated for it. */
7a6cf439
DE
1168#ifndef SPARCV9
1169#define REG_PARM_STACK_SPACE(DECL) (NPARM_REGS (SImode) * UNITS_PER_WORD)
1170#endif
1bb87f28
JW
1171
1172/* Keep the stack pointer constant throughout the function.
b4ac57ab 1173 This is both an optimization and a necessity: longjmp
1bb87f28
JW
1174 doesn't behave itself when the stack pointer moves within
1175 the function! */
1176#define ACCUMULATE_OUTGOING_ARGS
1177
1178/* Value is the number of bytes of arguments automatically
1179 popped when returning from a subroutine call.
8b109b37 1180 FUNDECL is the declaration node of the function (as a tree),
1bb87f28
JW
1181 FUNTYPE is the data type of the function (as a tree),
1182 or for a library call it is an identifier node for the subroutine name.
1183 SIZE is the number of bytes of arguments passed on the stack. */
1184
8b109b37 1185#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1bb87f28 1186
5b485d2c
JW
1187/* Some subroutine macros specific to this machine.
1188 When !TARGET_FPU, put float return values in the general registers,
1189 since we don't have any fp registers. */
1bb87f28 1190#define BASE_RETURN_VALUE_REG(MODE) \
7a6cf439
DE
1191 (TARGET_V9 ? (TARGET_FPU && GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 : 8) \
1192 : (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 : 8))
1bb87f28 1193#define BASE_OUTGOING_VALUE_REG(MODE) \
7a6cf439
DE
1194 (TARGET_V9 ? (TARGET_FPU && GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 \
1195 : TARGET_FRW ? 8 : 24) \
1196 : (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 \
1197 : (TARGET_FRW ? 8 : 24)))
1198#define BASE_PASSING_ARG_REG(MODE) \
1199 (TARGET_V9 ? (TARGET_FPU && GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 : 8) \
1200 : (8))
1201#define BASE_INCOMING_ARG_REG(MODE) \
1202 (TARGET_V9 ? (TARGET_FPU && GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 \
1203 : TARGET_FRW ? 8 : 24) \
1204 : (TARGET_FRW ? 8 : 24))
1bb87f28 1205
92ea370b
TW
1206/* Define this macro if the target machine has "register windows". This
1207 C expression returns the register number as seen by the called function
1208 corresponding to register number OUT as seen by the calling function.
1209 Return OUT if register number OUT is not an outbound register. */
1210
1211#define INCOMING_REGNO(OUT) \
1212 ((TARGET_FRW || (OUT) < 8 || (OUT) > 15) ? (OUT) : (OUT) + 16)
1213
1214/* Define this macro if the target machine has "register windows". This
1215 C expression returns the register number as seen by the calling function
1216 corresponding to register number IN as seen by the called function.
1217 Return IN if register number IN is not an inbound register. */
1218
1219#define OUTGOING_REGNO(IN) \
1220 ((TARGET_FRW || (IN) < 24 || (IN) > 31) ? (IN) : (IN) - 16)
1221
1bb87f28
JW
1222/* Define how to find the value returned by a function.
1223 VALTYPE is the data type of the value (as a tree).
1224 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1225 otherwise, FUNC is 0. */
1226
1227/* On SPARC the value is found in the first "output" register. */
1228
1229#define FUNCTION_VALUE(VALTYPE, FUNC) \
1230 gen_rtx (REG, TYPE_MODE (VALTYPE), BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
1231
1232/* But the called function leaves it in the first "input" register. */
1233
1234#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
1235 gen_rtx (REG, TYPE_MODE (VALTYPE), BASE_OUTGOING_VALUE_REG (TYPE_MODE (VALTYPE)))
1236
1237/* Define how to find the value returned by a library function
1238 assuming the value has mode MODE. */
1239
1240#define LIBCALL_VALUE(MODE) \
1241 gen_rtx (REG, MODE, BASE_RETURN_VALUE_REG (MODE))
1242
1243/* 1 if N is a possible register number for a function value
1244 as seen by the caller.
1245 On SPARC, the first "output" reg is used for integer values,
1246 and the first floating point register is used for floating point values. */
1247
1248#define FUNCTION_VALUE_REGNO_P(N) ((N) == 8 || (N) == 32)
1249
34aaacec
JW
1250/* Define the size of space to allocate for the return value of an
1251 untyped_call. */
1252
1253#define APPLY_RESULT_SIZE 16
1254
1bb87f28 1255/* 1 if N is a possible register number for function argument passing.
7a6cf439 1256 On SPARC, these are the "output" registers. v9 also uses %f0-%f15. */
1bb87f28 1257
7a6cf439
DE
1258#define FUNCTION_ARG_REGNO_P(N) \
1259 (TARGET_V9 ? (((N) < 14 && (N) > 7) || (N) > 31 && (N) < 48) \
1260 : ((N) < 14 && (N) > 7))
1bb87f28
JW
1261\f
1262/* Define a data type for recording info about an argument list
1263 during the scan of that argument list. This data type should
1264 hold all necessary information about the function itself
1265 and about the args processed so far, enough to enable macros
1266 such as FUNCTION_ARG to determine where the next arg should go.
1267
7a6cf439 1268 On SPARC (!v9), this is a single integer, which is a number of words
1bb87f28
JW
1269 of arguments scanned so far (including the invisible argument,
1270 if any, which holds the structure-value-address).
7a6cf439
DE
1271 Thus 7 or more means all following args should go on the stack.
1272
1273 For v9, we record how many of each type has been passed. Different
1274 types get passed differently.
1275
1276 - Float args are passed in %f0-15, after which they go to the stack
1277 where floats and doubles are passed 8 byte aligned and long doubles
1278 are passed 16 byte aligned.
1279 - All aggregates are passed by reference. The callee copies
1280 the structure if necessary, except if stdarg/varargs and the struct
1281 matches the ellipse in which case the caller makes a copy.
1282 - Any non-float argument might be split between memory and reg %o5.
1283 ??? I don't think this can ever happen now that structs are no
1284 longer passed in regs.
1285
1286 For v9 return values:
1287
1288 - For all aggregates, the caller allocates space for the return value,
1289 and passes the pointer as an implicit first argument, which is
1290 allocated like all other arguments.
1291 - The unimp instruction stuff for structure returns is gone. */
1292
1293#ifdef SPARCV9
1294enum sparc_arg_class { SPARC_ARG_INT = 0, SPARC_ARG_FLOAT = 1 };
1295struct sparc_args {
1296 int arg_count[2]; /* must be int! (for __builtin_args_info) */
1297};
1298#define CUMULATIVE_ARGS struct sparc_args
1299
1300/* Return index into CUMULATIVE_ARGS. */
1301
1302#define GET_SPARC_ARG_CLASS(MODE) \
1303 (GET_MODE_CLASS (MODE) == MODE_FLOAT ? SPARC_ARG_FLOAT : SPARC_ARG_INT)
1bb87f28 1304
7a6cf439
DE
1305/* Round a register number up to a proper boundary for an arg of mode MODE.
1306 This macro is only used in this file.
1307
1308 The "& (0x10000 - ...)" is used to round up to the next appropriate reg. */
1309
1310#define ROUND_REG(CUM, MODE) \
1311 (GET_MODE_CLASS (MODE) != MODE_FLOAT \
1312 ? (CUM).arg_count[(int) GET_SPARC_ARG_CLASS (MODE)] \
1313 : ((CUM).arg_count[(int) GET_SPARC_ARG_CLASS (MODE)] \
1314 + GET_MODE_UNIT_SIZE (MODE) / 4 - 1) \
1315 & (0x10000 - GET_MODE_UNIT_SIZE (MODE) / 4))
1316
1317#define ROUND_ADVANCE(SIZE) \
1318 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1319
1320#else /* ! SPARCV9 */
1bb87f28
JW
1321#define CUMULATIVE_ARGS int
1322
7a6cf439
DE
1323#define ROUND_REG(CUM, MODE) (CUM)
1324
1bb87f28 1325#define ROUND_ADVANCE(SIZE) \
b1fc14e5 1326 ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
7a6cf439 1327#endif /* ! SPARCV9 */
b1fc14e5 1328
1bb87f28
JW
1329/* Initialize a variable CUM of type CUMULATIVE_ARGS
1330 for a call to a function whose data type is FNTYPE.
1331 For a library call, FNTYPE is 0.
1332
1333 On SPARC, the offset always starts at 0: the first parm reg is always
1334 the same reg. */
1335
7a6cf439
DE
1336#ifdef SPARCV9
1337extern int sparc_arg_count,sparc_n_named_args;
1338#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \
1339 do { \
1340 (CUM).arg_count[(int) SPARC_ARG_INT] = 0; \
1341 (CUM).arg_count[(int) SPARC_ARG_FLOAT] = 0; \
1342 sparc_arg_count = 0; \
1343 sparc_n_named_args = \
1344 ((FNTYPE) && TYPE_ARG_TYPES (FNTYPE) \
1345 ? (list_length (TYPE_ARG_TYPES (FNTYPE)) \
1346 + (TREE_CODE (TREE_TYPE (FNTYPE)) == RECORD_TYPE \
1347 || TREE_CODE (TREE_TYPE (FNTYPE)) == UNION_TYPE)) \
1348 /* Can't tell, treat 'em all as named. */ \
1349 : 10000); \
1350 } while (0)
1351#else
1bb87f28 1352#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) ((CUM) = 0)
7a6cf439 1353#endif
1bb87f28
JW
1354
1355/* Update the data in CUM to advance over an argument
1356 of mode MODE and data type TYPE.
1357 (TYPE is null for libcalls where that information may not be available.) */
1358
7a6cf439
DE
1359#ifdef SPARCV9
1360#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1361 do { \
1362 (CUM).arg_count[(int) GET_SPARC_ARG_CLASS (MODE)] = \
1363 ROUND_REG ((CUM), (MODE)) \
1364 + (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1365 ? GET_MODE_SIZE (MODE) / 4 \
1366 : ROUND_ADVANCE ((MODE) == BLKmode \
1367 ? GET_MODE_SIZE (Pmode) \
1368 : GET_MODE_SIZE (MODE))); \
1369 sparc_arg_count++; \
1370 } while (0)
1371#else
1bb87f28 1372#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
95dea81f
JW
1373 ((CUM) += ((MODE) != BLKmode \
1374 ? ROUND_ADVANCE (GET_MODE_SIZE (MODE)) \
1375 : ROUND_ADVANCE (int_size_in_bytes (TYPE))))
7a6cf439
DE
1376#endif
1377
1378/* Return boolean indicating arg of mode MODE will be passed in a reg.
1379 This macro is only used in this file. */
1380
1381#ifdef SPARCV9
1382#define PASS_IN_REG_P(CUM, MODE, TYPE) \
1383 (ROUND_REG ((CUM), (MODE)) < NPARM_REGS (MODE) \
1384 && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
1385 && ((TYPE)==0 || (MODE) != BLKmode))
1386#else
1387#define PASS_IN_REG_P(CUM, MODE, TYPE) \
1388 ((CUM) < NPARM_REGS (SImode) \
1389 && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \
1390 && ((TYPE)==0 || (MODE) != BLKmode \
1391 || (TYPE_ALIGN (TYPE) % PARM_BOUNDARY == 0)))
1392#endif
1bb87f28
JW
1393
1394/* Determine where to put an argument to a function.
1395 Value is zero to push the argument on the stack,
1396 or a hard register in which to store the argument.
1397
1398 MODE is the argument's machine mode.
1399 TYPE is the data type of the argument (as a tree).
1400 This is null for libcalls where that information may
1401 not be available.
1402 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1403 the preceding args and about the function being called.
1404 NAMED is nonzero if this argument is a named parameter
1405 (otherwise it is an extra parameter matching an ellipsis). */
1406
1407/* On SPARC the first six args are normally in registers
1408 and the rest are pushed. Any arg that starts within the first 6 words
7a6cf439
DE
1409 is at least partially passed in a register unless its data type forbids.
1410 For v9, the first 6 int args are passed in regs and the first N
1411 float args are passed in regs (where N is such that %f0-15 are filled).
1412 The rest are pushed. Any arg that starts within the first 6 words
1bb87f28
JW
1413 is at least partially passed in a register unless its data type forbids. */
1414
1415#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
7a6cf439
DE
1416 (PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1417 ? gen_rtx (REG, (MODE), \
1418 (BASE_PASSING_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))))\
1419 : 0)
1bb87f28
JW
1420
1421/* Define where a function finds its arguments.
1422 This is different from FUNCTION_ARG because of register windows. */
1423
1424#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
7a6cf439
DE
1425 (PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1426 ? gen_rtx (REG, (MODE), \
1427 (BASE_INCOMING_ARG_REG (MODE) + ROUND_REG ((CUM), (MODE))))\
1428 : 0)
1bb87f28
JW
1429
1430/* For an arg passed partly in registers and partly in memory,
1431 this is the number of registers used.
1432 For args passed entirely in registers or entirely in memory, zero.
1433 Any arg that starts in the first 6 regs but won't entirely fit in them
7a6cf439
DE
1434 needs partial registers on the Sparc (!v9). On v9, there are no arguments
1435 that are passed partially in registers (??? complex values?). */
1bb87f28 1436
7a6cf439 1437#ifndef SPARCV9
1bb87f28 1438#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
7a6cf439
DE
1439 (PASS_IN_REG_P ((CUM), (MODE), (TYPE)) \
1440 && ((CUM) + ((MODE) == BLKmode \
1441 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
1442 : ROUND_ADVANCE (GET_MODE_SIZE (MODE))) - NPARM_REGS (SImode) > 0)\
1443 ? (NPARM_REGS (SImode) - (CUM)) \
1bb87f28 1444 : 0)
7a6cf439 1445#endif
1bb87f28 1446
d9ca49d5 1447/* The SPARC ABI stipulates passing struct arguments (of any size) and
7a6cf439 1448 (!v9) quad-precision floats by invisible reference.
87ac3809 1449 For Pascal, also pass arrays by reference. */
1bb87f28 1450#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
d9ca49d5 1451 ((TYPE && (TREE_CODE (TYPE) == RECORD_TYPE \
87ac3809
JW
1452 || TREE_CODE (TYPE) == UNION_TYPE \
1453 || TREE_CODE (TYPE) == ARRAY_TYPE)) \
7a6cf439
DE
1454 || (!TARGET_V9 && MODE == TFmode))
1455
1456/* A C expression that indicates when it is the called function's
1457 responsibility to make copies of arguments passed by reference.
1458 If the callee can determine that the argument won't be modified, it can
1459 avoid the copy. */
1460/* ??? We'd love to be able to use NAMED here. Unfortunately, it doesn't
1461 include the last named argument so we keep track of the args ourselves. */
1462
1463#ifdef SPARCV9
1464#define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
1465 (sparc_arg_count < sparc_n_named_args)
1466#endif
1467\f
1468/* Initialize data used by insn expanders. This is called from
1469 init_emit, once for each function, before code is generated.
1470 For v9, clear the temp slot used by float/int DImode conversions.
1471 ??? There is the 16 bytes at [%fp-16], however we'd like to delete this
1472 space at some point.
1473 ??? Use assign_stack_temp? */
1474
1475extern void sparc64_init_expanders ();
1476extern struct rtx_def *sparc64_fpconv_stack_temp ();
1477#ifdef SPARCV9
1478#define INIT_EXPANDERS sparc64_init_expanders ()
1479#endif
1bb87f28
JW
1480
1481/* Define the information needed to generate branch and scc insns. This is
1482 stored from the compare operation. Note that we can't use "rtx" here
1483 since it hasn't been defined! */
1484
1485extern struct rtx_def *sparc_compare_op0, *sparc_compare_op1;
1486
1487/* Define the function that build the compare insn for scc and bcc. */
1488
1489extern struct rtx_def *gen_compare_reg ();
7a6cf439
DE
1490
1491/* This function handles all v9 scc insns */
1492
1493extern int gen_v9_scc ();
1bb87f28 1494\f
4b69d2a3
RS
1495/* Generate the special assembly code needed to tell the assembler whatever
1496 it might need to know about the return value of a function.
1497
1498 For Sparc assemblers, we need to output a .proc pseudo-op which conveys
1499 information to the assembler relating to peephole optimization (done in
1500 the assembler). */
1501
1502#define ASM_DECLARE_RESULT(FILE, RESULT) \
1503 fprintf ((FILE), "\t.proc\t0%o\n", sparc_type_code (TREE_TYPE (RESULT)))
1504
1bb87f28
JW
1505/* Output the label for a function definition. */
1506
4b69d2a3
RS
1507#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
1508do { \
1509 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
1510 ASM_OUTPUT_LABEL (FILE, NAME); \
1511} while (0)
1bb87f28 1512
1bb87f28
JW
1513/* This macro generates the assembly code for function entry.
1514 FILE is a stdio stream to output the code to.
1515 SIZE is an int: how many units of temporary storage to allocate.
1516 Refer to the array `regs_ever_live' to determine which registers
1517 to save; `regs_ever_live[I]' is nonzero if register number I
1518 is ever used in the function. This macro is responsible for
1519 knowing which registers should not be saved even if used. */
1520
1521/* On SPARC, move-double insns between fpu and cpu need an 8-byte block
1522 of memory. If any fpu reg is used in the function, we allocate
1523 such a block here, at the bottom of the frame, just in case it's needed.
1524
1525 If this function is a leaf procedure, then we may choose not
1526 to do a "save" insn. The decision about whether or not
1527 to do this is made in regclass.c. */
1528
a061b9fa 1529extern int leaf_function;
1bb87f28 1530#define FUNCTION_PROLOGUE(FILE, SIZE) \
5c56efde 1531 (TARGET_FRW ? sparc_flat_output_function_prologue (FILE, SIZE) \
5b485d2c 1532 : output_function_prologue (FILE, SIZE, leaf_function))
1bb87f28
JW
1533
1534/* Output assembler code to FILE to increment profiler label # LABELNO
1535 for profiling a function entry. */
1536
d2a8e680
RS
1537#define FUNCTION_PROFILER(FILE, LABELNO) \
1538 do { \
1539 fputs ("\tsethi %hi(", (FILE)); \
1540 ASM_OUTPUT_INTERNAL_LABELREF (FILE, "LP", LABELNO); \
7a6cf439
DE
1541 fputs ("),%o0\n", (FILE)); \
1542 if (TARGET_MEDANY) \
1543 fprintf (FILE, "\tadd %%o0,%s,%%o0\n", \
1544 MEDANY_BASE_REG); \
1545 fputs ("\tcall mcount\n\tadd %lo(", (FILE)); \
d2a8e680
RS
1546 ASM_OUTPUT_INTERNAL_LABELREF (FILE, "LP", LABELNO); \
1547 fputs ("),%o0,%o0\n", (FILE)); \
1548 } while (0)
1bb87f28
JW
1549
1550/* Output assembler code to FILE to initialize this source file's
1551 basic block profiling info, if that has not already been done. */
1552
1553#define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \
7a6cf439
DE
1554 do { \
1555 if (TARGET_MEDANY) \
1556 fprintf (FILE, "\tsethi %%hi(LPBX0),%%o0\n\tor %%0,%%lo(LPBX0),%%o0\n\tld [%s+%%o0],%%o1\n\ttst %%o1\n\tbne LPY%d\n\tadd %%o0,%s,%%o0\n\tcall ___bb_init_func\n\tnop\nLPY%d:\n", \
1557 MEDANY_BASE_REG, (LABELNO), MEDANY_BASE_REG, (LABELNO)); \
1558 else \
1559 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", \
1560 (LABELNO), (LABELNO)); \
1561 } while (0)
1bb87f28
JW
1562
1563/* Output assembler code to FILE to increment the entry-count for
1564 the BLOCKNO'th basic block in this source file. */
1565
1566#define BLOCK_PROFILER(FILE, BLOCKNO) \
7a6cf439
DE
1567{ \
1568 int blockn = (BLOCKNO); \
1569 if (TARGET_MEDANY) \
1570 fprintf (FILE, "\tsethi %%hi(LPBX2+%d),%%g1\n\tor %%g1,%%lo(LPBX2+%d),%%g1\n\tld [%%g1+%s],%%g2\n\tadd %%g2,1,%%g2\n\tst %%g2,[%%g1+%s]\n", \
1571 4 * blockn, 4 * blockn, MEDANY_BASE_REG, MEDANY_BASE_REG); \
1572 else \
1573 fprintf (FILE, "\tsethi %%hi(LPBX2+%d),%%g1\n\tld [%%lo(LPBX2+%d)+%%g1],%%g2\n\
1574\tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(LPBX2+%d)+%%g1]\n", \
1575 4 * blockn, 4 * blockn, 4 * blockn); \
1bb87f28
JW
1576}
1577
1bb87f28
JW
1578/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1579 the stack pointer does not matter. The value is tested only in
1580 functions that have frame pointers.
1581 No definition is equivalent to always zero. */
1582
1583extern int current_function_calls_alloca;
1584extern int current_function_outgoing_args_size;
1585
1586#define EXIT_IGNORE_STACK \
1587 (get_frame_size () != 0 \
1588 || current_function_calls_alloca || current_function_outgoing_args_size)
1589
1590/* This macro generates the assembly code for function exit,
1591 on machines that need it. If FUNCTION_EPILOGUE is not defined
1592 then individual return instructions are generated for each
1593 return statement. Args are same as for FUNCTION_PROLOGUE.
1594
1595 The function epilogue should not depend on the current stack pointer!
1596 It should use the frame pointer only. This is mandatory because
1597 of alloca; we also take advantage of it to omit stack adjustments
1598 before returning. */
1599
1600/* This declaration is needed due to traditional/ANSI
1601 incompatibilities which cannot be #ifdefed away
1602 because they occur inside of macros. Sigh. */
1603extern union tree_node *current_function_decl;
1604
1605#define FUNCTION_EPILOGUE(FILE, SIZE) \
5c56efde 1606 (TARGET_FRW ? sparc_flat_output_function_epilogue (FILE, SIZE) \
5b485d2c 1607 : output_function_epilogue (FILE, SIZE, leaf_function))
1bb87f28 1608
5b485d2c 1609#define DELAY_SLOTS_FOR_EPILOGUE \
5c56efde 1610 (TARGET_FRW ? sparc_flat_epilogue_delay_slots () : 1)
1bb87f28 1611#define ELIGIBLE_FOR_EPILOGUE_DELAY(trial, slots_filled) \
5c56efde 1612 (TARGET_FRW ? sparc_flat_eligible_for_epilogue_delay (trial, slots_filled) \
5b485d2c 1613 : eligible_for_epilogue_delay (trial, slots_filled))
6a4bb1fa 1614\f
1bb87f28
JW
1615/* Output assembler code for a block containing the constant parts
1616 of a trampoline, leaving space for the variable parts. */
1617
1618/* On the sparc, the trampoline contains five instructions:
6098b63e
RK
1619 sethi #TOP_OF_FUNCTION,%g1
1620 or #BOTTOM_OF_FUNCTION,%g1,%g1
1621 sethi #TOP_OF_STATIC,%g2
1622 jmp g1
1623 or #BOTTOM_OF_STATIC,%g2,%g2 */
1bb87f28
JW
1624#define TRAMPOLINE_TEMPLATE(FILE) \
1625{ \
1626 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
1627 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
1628 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
6098b63e 1629 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x81C04000)); \
1bb87f28
JW
1630 ASM_OUTPUT_INT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x00000000)); \
1631}
1632
1633/* Length in units of the trampoline for entering a nested function. */
1634
1635#define TRAMPOLINE_SIZE 20
1636
1637/* Emit RTL insns to initialize the variable parts of a trampoline.
1638 FNADDR is an RTX for the address of the function's pure code.
7a6cf439 1639 CXT is an RTX for the static chain value for the function. */
1bb87f28 1640
7a6cf439
DE
1641void sparc_initialize_trampoline ();
1642void sparc64_initialize_trampoline ();
1643#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1644 do { \
1645 if (TARGET_V9) \
1646 sparc64_initialize_trampoline (TRAMP, FNADDR, CXT); \
1647 else \
1648 sparc_initialize_trampoline (TRAMP, FNADDR, CXT); \
1649 } while (0)
6a4bb1fa 1650\f
9a1c7cd7
JW
1651/* Generate necessary RTL for __builtin_saveregs().
1652 ARGLIST is the argument list; see expr.c. */
1653extern struct rtx_def *sparc_builtin_saveregs ();
1654#define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sparc_builtin_saveregs (ARGLIST)
953fe179
JW
1655
1656/* Generate RTL to flush the register windows so as to make arbitrary frames
1657 available. */
1658#define SETUP_FRAME_ADDRESSES() \
1659 emit_insn (gen_flush_register_windows ())
1660
1661/* Given an rtx for the address of a frame,
1662 return an rtx for the address of the word in the frame
7a6cf439
DE
1663 that holds the dynamic chain--the previous frame's address.
1664 ??? -mflat support? */
953fe179 1665#define DYNAMIC_CHAIN_ADDRESS(frame) \
7a6cf439 1666 gen_rtx (PLUS, Pmode, frame, gen_rtx (CONST_INT, VOIDmode, 14 * UNITS_PER_WORD))
953fe179
JW
1667
1668/* The return address isn't on the stack, it is in a register, so we can't
1669 access it from the current frame pointer. We can access it from the
1670 previous frame pointer though by reading a value from the register window
1671 save area. */
1672#define RETURN_ADDR_IN_PREVIOUS_FRAME
1673
1674/* The current return address is in %i7. The return address of anything
1675 farther back is in the register window save area at [%fp+60]. */
1676/* ??? This ignores the fact that the actual return address is +8 for normal
1677 returns, and +12 for structure returns. */
1678#define RETURN_ADDR_RTX(count, frame) \
1679 ((count == -1) \
1680 ? gen_rtx (REG, Pmode, 31) \
1681 : copy_to_reg (gen_rtx (MEM, Pmode, \
7a6cf439 1682 memory_address (Pmode, plus_constant (frame, 15 * UNITS_PER_WORD)))))
1bb87f28
JW
1683\f
1684/* Addressing modes, and classification of registers for them. */
1685
1686/* #define HAVE_POST_INCREMENT */
1687/* #define HAVE_POST_DECREMENT */
1688
1689/* #define HAVE_PRE_DECREMENT */
1690/* #define HAVE_PRE_INCREMENT */
1691
1692/* Macros to check register numbers against specific register classes. */
1693
1694/* These assume that REGNO is a hard or pseudo reg number.
1695 They give nonzero only if REGNO is a hard reg of the suitable class
1696 or a pseudo reg currently allocated to a suitable hard reg.
1697 Since they use reg_renumber, they are safe only once reg_renumber
1698 has been allocated, which happens in local-alloc.c. */
1699
1700#define REGNO_OK_FOR_INDEX_P(REGNO) \
1701(((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32) && (REGNO) != 0)
1702#define REGNO_OK_FOR_BASE_P(REGNO) \
1703(((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32) && (REGNO) != 0)
1704#define REGNO_OK_FOR_FP_P(REGNO) \
7a6cf439
DE
1705 (((unsigned) (REGNO) - 32 < (TARGET_V9 ? 64 : 32)) \
1706 || ((unsigned) reg_renumber[REGNO] - 32 < (TARGET_V9 ? 64 : 32)))
1707#define REGNO_OK_FOR_CCFP_P(REGNO) \
1708 (TARGET_V9 \
1709 && ((unsigned) (REGNO) - 96 < 4) || ((unsigned) reg_renumber[REGNO] - 96 < 4))
1bb87f28
JW
1710
1711/* Now macros that check whether X is a register and also,
1712 strictly, whether it is in a specified class.
1713
1714 These macros are specific to the SPARC, and may be used only
1715 in code for printing assembler insns and in conditions for
1716 define_optimization. */
1717
1718/* 1 if X is an fp register. */
1719
1720#define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
1721\f
1722/* Maximum number of registers that can appear in a valid memory address. */
1723
1724#define MAX_REGS_PER_ADDRESS 2
1725
7aca9b9c
JW
1726/* Recognize any constant value that is a valid address.
1727 When PIC, we do not accept an address that would require a scratch reg
1728 to load into a register. */
1bb87f28 1729
6eff269e
BK
1730#define CONSTANT_ADDRESS_P(X) \
1731 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
7aca9b9c
JW
1732 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
1733 || (GET_CODE (X) == CONST \
1734 && ! (flag_pic && pic_address_needs_scratch (X))))
1735
1736/* Define this, so that when PIC, reload won't try to reload invalid
1737 addresses which require two reload registers. */
1738
1739#define LEGITIMATE_PIC_OPERAND_P(X) (! pic_address_needs_scratch (X))
1bb87f28
JW
1740
1741/* Nonzero if the constant value X is a legitimate general operand.
1742 Anything can be made to work except floating point constants. */
1743
1744#define LEGITIMATE_CONSTANT_P(X) \
1745 (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode)
1746
1747/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1748 and check its validity for a certain class.
1749 We have two alternate definitions for each of them.
1750 The usual definition accepts all pseudo regs; the other rejects
1751 them unless they have been allocated suitable hard regs.
1752 The symbol REG_OK_STRICT causes the latter definition to be used.
1753
1754 Most source files want to accept pseudo regs in the hope that
1755 they will get allocated to the class that the insn wants them to be in.
1756 Source files for reload pass need to be strict.
1757 After reload, it makes no difference, since pseudo regs have
1758 been eliminated by then. */
1759
1760/* Optional extra constraints for this machine. Borrowed from romp.h.
1761
1762 For the SPARC, `Q' means that this is a memory operand but not a
1763 symbolic memory operand. Note that an unassigned pseudo register
1764 is such a memory operand. Needed because reload will generate
1765 these things in insns and then not re-recognize the insns, causing
1766 constrain_operands to fail.
1767
7a6cf439 1768 `S' handles constraints for calls. ??? So where is it? */
1bb87f28
JW
1769
1770#ifndef REG_OK_STRICT
1771
1772/* Nonzero if X is a hard reg that can be used as an index
1773 or if it is a pseudo reg. */
7a6cf439
DE
1774#define REG_OK_FOR_INDEX_P(X) \
1775 (((unsigned) REGNO (X)) - 32 >= (FIRST_PSEUDO_REGISTER - 32) && REGNO (X) != 0)
1bb87f28
JW
1776/* Nonzero if X is a hard reg that can be used as a base reg
1777 or if it is a pseudo reg. */
7a6cf439
DE
1778#define REG_OK_FOR_BASE_P(X) \
1779 (((unsigned) REGNO (X)) - 32 >= (FIRST_PSEUDO_REGISTER - 32) && REGNO (X) != 0)
1780
1781/* 'T', 'U' are for aligned memory loads which aren't needed for v9. */
1bb87f28
JW
1782
1783#define EXTRA_CONSTRAINT(OP, C) \
db5e449c
RS
1784 ((C) == 'Q' \
1785 ? ((GET_CODE (OP) == MEM \
7a6cf439 1786 && memory_address_p (GET_MODE (OP), XEXP (OP, 0)) \
db5e449c
RS
1787 && ! symbolic_memory_operand (OP, VOIDmode)) \
1788 || (reload_in_progress && GET_CODE (OP) == REG \
1789 && REGNO (OP) >= FIRST_PSEUDO_REGISTER)) \
7a6cf439 1790 : ! TARGET_V9 && (C) == 'T' \
19858600 1791 ? (mem_aligned_8 (OP)) \
7a6cf439 1792 : ! TARGET_V9 && (C) == 'U' \
19858600 1793 ? (register_ok_for_ldd (OP)) \
db5e449c 1794 : 0)
19858600 1795
1bb87f28
JW
1796#else
1797
1798/* Nonzero if X is a hard reg that can be used as an index. */
1799#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1800/* Nonzero if X is a hard reg that can be used as a base reg. */
1801#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1802
1803#define EXTRA_CONSTRAINT(OP, C) \
9ad2c692
JW
1804 ((C) == 'Q' \
1805 ? (GET_CODE (OP) == REG \
1806 ? (REGNO (OP) >= FIRST_PSEUDO_REGISTER \
1807 && reg_renumber[REGNO (OP)] < 0) \
1808 : GET_CODE (OP) == MEM) \
7a6cf439 1809 : ! TARGET_V9 && (C) == 'T' \
b165d471 1810 ? mem_aligned_8 (OP) && strict_memory_address_p (Pmode, XEXP (OP, 0)) \
7a6cf439 1811 : ! TARGET_V9 && (C) == 'U' \
b165d471
JW
1812 ? (GET_CODE (OP) == REG \
1813 && (REGNO (OP) < FIRST_PSEUDO_REGISTER \
1814 || reg_renumber[REGNO (OP)] > 0) \
1815 && register_ok_for_ldd (OP)) : 0)
1bb87f28
JW
1816#endif
1817\f
1818/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1819 that is a valid memory address for an instruction.
1820 The MODE argument is the machine mode for the MEM expression
1821 that wants to use this address.
1822
1823 On SPARC, the actual legitimate addresses must be REG+REG or REG+SMALLINT
1824 ordinarily. This changes a bit when generating PIC.
1825
1826 If you change this, execute "rm explow.o recog.o reload.o". */
1827
bec2e359
JW
1828#define RTX_OK_FOR_BASE_P(X) \
1829 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
1830 || (GET_CODE (X) == SUBREG \
1831 && GET_CODE (SUBREG_REG (X)) == REG \
1832 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
1833
1834#define RTX_OK_FOR_INDEX_P(X) \
1835 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
1836 || (GET_CODE (X) == SUBREG \
1837 && GET_CODE (SUBREG_REG (X)) == REG \
1838 && REG_OK_FOR_INDEX_P (SUBREG_REG (X))))
1839
1840#define RTX_OK_FOR_OFFSET_P(X) \
1841 (GET_CODE (X) == CONST_INT && INTVAL (X) >= -0x1000 && INTVAL (X) < 0x1000)
1842
1bb87f28 1843#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
bec2e359
JW
1844{ if (RTX_OK_FOR_BASE_P (X)) \
1845 goto ADDR; \
1bb87f28
JW
1846 else if (GET_CODE (X) == PLUS) \
1847 { \
bec2e359
JW
1848 register rtx op0 = XEXP (X, 0); \
1849 register rtx op1 = XEXP (X, 1); \
1850 if (flag_pic && op0 == pic_offset_table_rtx) \
1bb87f28 1851 { \
bec2e359 1852 if (RTX_OK_FOR_BASE_P (op1)) \
1bb87f28
JW
1853 goto ADDR; \
1854 else if (flag_pic == 1 \
bec2e359
JW
1855 && GET_CODE (op1) != REG \
1856 && GET_CODE (op1) != LO_SUM \
7aca9b9c
JW
1857 && GET_CODE (op1) != MEM \
1858 && (GET_CODE (op1) != CONST_INT \
1859 || SMALL_INT (op1))) \
1bb87f28
JW
1860 goto ADDR; \
1861 } \
bec2e359 1862 else if (RTX_OK_FOR_BASE_P (op0)) \
1bb87f28 1863 { \
bec2e359
JW
1864 if (RTX_OK_FOR_INDEX_P (op1) \
1865 || RTX_OK_FOR_OFFSET_P (op1)) \
1bb87f28
JW
1866 goto ADDR; \
1867 } \
bec2e359 1868 else if (RTX_OK_FOR_BASE_P (op1)) \
1bb87f28 1869 { \
bec2e359
JW
1870 if (RTX_OK_FOR_INDEX_P (op0) \
1871 || RTX_OK_FOR_OFFSET_P (op0)) \
1bb87f28
JW
1872 goto ADDR; \
1873 } \
1874 } \
bec2e359
JW
1875 else if (GET_CODE (X) == LO_SUM) \
1876 { \
1877 register rtx op0 = XEXP (X, 0); \
1878 register rtx op1 = XEXP (X, 1); \
1879 if (RTX_OK_FOR_BASE_P (op0) \
2f0da906
JW
1880 && CONSTANT_P (op1) \
1881 /* We can't allow TFmode, because an offset \
1882 greater than or equal to the alignment (8) \
1883 may cause the LO_SUM to overflow. */ \
1884 && MODE != TFmode) \
bec2e359
JW
1885 goto ADDR; \
1886 } \
1bb87f28
JW
1887 else if (GET_CODE (X) == CONST_INT && SMALL_INT (X)) \
1888 goto ADDR; \
1889}
1890\f
1891/* Try machine-dependent ways of modifying an illegitimate address
1892 to be legitimate. If we find one, return the new, valid address.
1893 This macro is used in only one place: `memory_address' in explow.c.
1894
1895 OLDX is the address as it was before break_out_memory_refs was called.
1896 In some cases it is useful to look at this to decide what needs to be done.
1897
1898 MODE and WIN are passed so that this macro can use
1899 GO_IF_LEGITIMATE_ADDRESS.
1900
1901 It is always safe for this macro to do nothing. It exists to recognize
1902 opportunities to optimize the output. */
1903
1904/* On SPARC, change REG+N into REG+REG, and REG+(X*Y) into REG+REG. */
1905extern struct rtx_def *legitimize_pic_address ();
1906#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1907{ rtx sparc_x = (X); \
1908 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
1909 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 1), \
a015279e 1910 force_operand (XEXP (X, 0), NULL_RTX)); \
1bb87f28
JW
1911 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
1912 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
a015279e 1913 force_operand (XEXP (X, 1), NULL_RTX)); \
1bb87f28 1914 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
a015279e 1915 (X) = gen_rtx (PLUS, Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
1bb87f28
JW
1916 XEXP (X, 1)); \
1917 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
1918 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
a015279e 1919 force_operand (XEXP (X, 1), NULL_RTX)); \
1bb87f28
JW
1920 if (sparc_x != (X) && memory_address_p (MODE, X)) \
1921 goto WIN; \
7aca9b9c 1922 if (flag_pic) (X) = legitimize_pic_address (X, MODE, 0); \
1bb87f28
JW
1923 else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
1924 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
1925 copy_to_mode_reg (Pmode, XEXP (X, 1))); \
1926 else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
1927 (X) = gen_rtx (PLUS, Pmode, XEXP (X, 1), \
1928 copy_to_mode_reg (Pmode, XEXP (X, 0))); \
1929 else if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
1930 || GET_CODE (X) == LABEL_REF) \
1931 (X) = gen_rtx (LO_SUM, Pmode, \
1932 copy_to_mode_reg (Pmode, gen_rtx (HIGH, Pmode, X)), X); \
1933 if (memory_address_p (MODE, X)) \
1934 goto WIN; }
1935
1936/* Go to LABEL if ADDR (a legitimate address expression)
1937 has an effect that depends on the machine mode it is used for.
1938 On the SPARC this is never true. */
1939
1940#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
7a6cf439
DE
1941
1942/* If we are referencing a function make the SYMBOL_REF special.
1943 In the Medium/Anywhere code model, %g4 points to the data segment so we
1944 must not add it to function addresses. */
1945
1946#define ENCODE_SECTION_INFO(DECL) \
1947 do { \
1948 if (TARGET_MEDANY && TREE_CODE (DECL) == FUNCTION_DECL) \
1949 SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; \
1950 } while (0)
1bb87f28
JW
1951\f
1952/* Specify the machine mode that this machine uses
1953 for the index in the tablejump instruction. */
7a6cf439 1954#define CASE_VECTOR_MODE Pmode
1bb87f28
JW
1955
1956/* Define this if the tablejump instruction expects the table
1957 to contain offsets from the address of the table.
1958 Do not define this if the table should contain absolute addresses. */
1959/* #define CASE_VECTOR_PC_RELATIVE */
1960
1961/* Specify the tree operation to be used to convert reals to integers. */
1962#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1963
1964/* This is the kind of divide that is easiest to do in the general case. */
1965#define EASY_DIV_EXPR TRUNC_DIV_EXPR
1966
1967/* Define this as 1 if `char' should by default be signed; else as 0. */
1968#define DEFAULT_SIGNED_CHAR 1
1969
1970/* Max number of bytes we can move from memory to memory
1971 in one reasonably fast instruction. */
2eef2ef1 1972#define MOVE_MAX 8
1bb87f28 1973
0fb5a69e 1974#if 0 /* Sun 4 has matherr, so this is no good. */
24e2a2bf
RS
1975/* This is the value of the error code EDOM for this machine,
1976 used by the sqrt instruction. */
1977#define TARGET_EDOM 33
1978
1979/* This is how to refer to the variable errno. */
1980#define GEN_ERRNO_RTX \
1981 gen_rtx (MEM, SImode, gen_rtx (SYMBOL_REF, Pmode, "errno"))
0fb5a69e 1982#endif /* 0 */
24e2a2bf 1983
9a63901f
RK
1984/* Define if operations between registers always perform the operation
1985 on the full register even if a narrower mode is specified. */
1986#define WORD_REGISTER_OPERATIONS
1987
1988/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1989 will either zero-extend or sign-extend. The value of this macro should
1990 be the code that says which one of the two operations is implicitly
1991 done, NIL if none. */
1992#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1bb87f28
JW
1993
1994/* Nonzero if access to memory by bytes is slow and undesirable.
1995 For RISC chips, it means that access to memory by bytes is no
1996 better than access by words when possible, so grab a whole word
1997 and maybe make use of that. */
1998#define SLOW_BYTE_ACCESS 1
1999
2000/* We assume that the store-condition-codes instructions store 0 for false
2001 and some other value for true. This is the value stored for true. */
2002
2003#define STORE_FLAG_VALUE 1
2004
2005/* When a prototype says `char' or `short', really pass an `int'. */
2006#define PROMOTE_PROTOTYPES
2007
d969caf8
RK
2008/* Define this to be nonzero if shift instructions ignore all but the low-order
2009 few bits. */
2010#define SHIFT_COUNT_TRUNCATED 1
1bb87f28
JW
2011
2012/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
2013 is done just by pretending it is already truncated. */
2014#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2015
2016/* Specify the machine mode that pointers have.
2017 After generation of rtl, the compiler makes no further distinction
2018 between pointers and any other objects of this machine mode. */
7a6cf439 2019#define Pmode (TARGET_PTR64 ? DImode : SImode)
1bb87f28 2020
b4ac57ab
RS
2021/* Generate calls to memcpy, memcmp and memset. */
2022#define TARGET_MEM_FUNCTIONS
2023
1bb87f28
JW
2024/* Add any extra modes needed to represent the condition code.
2025
2026 On the Sparc, we have a "no-overflow" mode which is used when an add or
2027 subtract insn is used to set the condition code. Different branches are
2028 used in this case for some operations.
2029
4d449554
JW
2030 We also have two modes to indicate that the relevant condition code is
2031 in the floating-point condition code register. One for comparisons which
2032 will generate an exception if the result is unordered (CCFPEmode) and
2033 one for comparisons which will never trap (CCFPmode). This really should
7a6cf439
DE
2034 be a separate register, but we don't want to go to 65 registers.
2035
2036 CCXmode and CCX_NOOVmode are only used by v9. */
2037
2038#define EXTRA_CC_MODES CCXmode, CC_NOOVmode, CCX_NOOVmode, CCFPmode, CCFPEmode
1bb87f28
JW
2039
2040/* Define the names for the modes specified above. */
7a6cf439
DE
2041
2042#define EXTRA_CC_NAMES "CCX", "CC_NOOV", "CCX_NOOV", "CCFP", "CCFPE"
1bb87f28
JW
2043
2044/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
4d449554
JW
2045 return the mode to be used for the comparison. For floating-point,
2046 CCFP[E]mode is used. CC_NOOVmode should be used when the first operand is a
922bd191
JW
2047 PLUS, MINUS, NEG, or ASHIFT. CCmode should be used when no special
2048 processing is needed. */
679655e6 2049#define SELECT_CC_MODE(OP,X,Y) \
4d449554 2050 (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
922bd191
JW
2051 ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode) \
2052 : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \
2053 || GET_CODE (X) == NEG || GET_CODE (X) == ASHIFT) \
7a6cf439
DE
2054 ? (TARGET_V9 && GET_MODE (X) == DImode ? CCX_NOOVmode : CC_NOOVmode) \
2055 : (TARGET_V9 && GET_MODE (X) == DImode ? CCXmode : CCmode)))
1bb87f28 2056
b331b745
RK
2057/* Return non-zero if SELECT_CC_MODE will never return MODE for a
2058 floating point inequality comparison. */
2059
2060#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
2061
1bb87f28
JW
2062/* A function address in a call instruction
2063 is a byte address (for indexing purposes)
2064 so give the MEM rtx a byte's mode. */
2065#define FUNCTION_MODE SImode
2066
2067/* Define this if addresses of constant functions
2068 shouldn't be put through pseudo regs where they can be cse'd.
2069 Desirable on machines where ordinary constants are expensive
2070 but a CALL with constant address is cheap. */
2071#define NO_FUNCTION_CSE
2072
2073/* alloca should avoid clobbering the old register save area. */
2074#define SETJMP_VIA_SAVE_AREA
2075
2076/* Define subroutines to call to handle multiply and divide.
2077 Use the subroutines that Sun's library provides.
2078 The `*' prevents an underscore from being prepended by the compiler. */
2079
2080#define DIVSI3_LIBCALL "*.div"
2081#define UDIVSI3_LIBCALL "*.udiv"
2082#define MODSI3_LIBCALL "*.rem"
2083#define UMODSI3_LIBCALL "*.urem"
2084/* .umul is a little faster than .mul. */
2085#define MULSI3_LIBCALL "*.umul"
2086
8248e2bc
JW
2087/* Define library calls for quad FP operations. These are all part of the
2088 SPARC ABI. */
b3f741ed
JW
2089#define ADDTF3_LIBCALL "_Q_add"
2090#define SUBTF3_LIBCALL "_Q_sub"
2091#define MULTF3_LIBCALL "_Q_mul"
2092#define DIVTF3_LIBCALL "_Q_div"
b3f741ed
JW
2093#define FLOATSITF2_LIBCALL "_Q_itoq"
2094#define FIX_TRUNCTFSI2_LIBCALL "_Q_qtoi"
2095#define FIXUNS_TRUNCTFSI2_LIBCALL "_Q_qtou"
2096#define EXTENDSFTF2_LIBCALL "_Q_stoq"
2097#define TRUNCTFSF2_LIBCALL "_Q_qtos"
2098#define EXTENDDFTF2_LIBCALL "_Q_dtoq"
2099#define TRUNCTFDF2_LIBCALL "_Q_qtod"
2100#define EQTF2_LIBCALL "_Q_feq"
2101#define NETF2_LIBCALL "_Q_fne"
2102#define GTTF2_LIBCALL "_Q_fgt"
2103#define GETF2_LIBCALL "_Q_fge"
2104#define LTTF2_LIBCALL "_Q_flt"
2105#define LETF2_LIBCALL "_Q_fle"
8248e2bc 2106
78e9b5df
JW
2107/* We can define the TFmode sqrt optab only if TARGET_FPU. This is because
2108 with soft-float, the SFmode and DFmode sqrt instructions will be absent,
2109 and the compiler will notice and try to use the TFmode sqrt instruction
2110 for calls to the builtin function sqrt, but this fails. */
2111#define INIT_TARGET_OPTABS \
2112 do { \
2113 INIT_SUBTARGET_OPTABS; \
2114 if (TARGET_FPU) \
2115 sqrt_optab->handlers[(int) TFmode].libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Q_sqrt"); \
2116 } while (0)
2117
2118/* This is meant to be redefined in the host dependent files */
2119#define INIT_SUBTARGET_OPTABS
2120
1bb87f28
JW
2121/* Compute the cost of computing a constant rtl expression RTX
2122 whose rtx-code is CODE. The body of this macro is a portion
2123 of a switch statement. If the code is computed here,
2124 return it with a return statement. Otherwise, break from the switch. */
2125
3bb22aee 2126#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1bb87f28 2127 case CONST_INT: \
1bb87f28 2128 if (INTVAL (RTX) < 0x1000 && INTVAL (RTX) >= -0x1000) \
5b485d2c 2129 return 0; \
1bb87f28
JW
2130 case HIGH: \
2131 return 2; \
2132 case CONST: \
2133 case LABEL_REF: \
2134 case SYMBOL_REF: \
2135 return 4; \
2136 case CONST_DOUBLE: \
2137 if (GET_MODE (RTX) == DImode) \
2138 if ((XINT (RTX, 3) == 0 \
2139 && (unsigned) XINT (RTX, 2) < 0x1000) \
2140 || (XINT (RTX, 3) == -1 \
2141 && XINT (RTX, 2) < 0 \
2142 && XINT (RTX, 2) >= -0x1000)) \
5b485d2c 2143 return 0; \
1bb87f28
JW
2144 return 8;
2145
a0a74fda 2146/* Compute the cost of an address. For the sparc, all valid addresses are
7a6cf439
DE
2147 the same cost.
2148 ??? Is this true for v9? */
1bb87f28 2149
a0a74fda 2150#define ADDRESS_COST(RTX) 1
1bb87f28
JW
2151
2152/* Compute extra cost of moving data between one register class
7a6cf439
DE
2153 and another.
2154 ??? v9: We ignore FPCC_REGS on the assumption they'll never be seen. */
1bb87f28 2155#define REGISTER_MOVE_COST(CLASS1, CLASS2) \
24b63396
JW
2156 (((FP_REG_CLASS_P (CLASS1) && (CLASS2) == GENERAL_REGS) \
2157 || ((CLASS1) == GENERAL_REGS && FP_REG_CLASS_P (CLASS2))) ? 6 : 2)
1bb87f28
JW
2158
2159/* Provide the costs of a rtl expression. This is in the body of a
2160 switch on CODE. The purpose for the cost of MULT is to encourage
2161 `synth_mult' to find a synthetic multiply when reasonable.
2162
2163 If we need more than 12 insns to do a multiply, then go out-of-line,
2164 since the call overhead will be < 10% of the cost of the multiply. */
2165
3bb22aee 2166#define RTX_COSTS(X,CODE,OUTER_CODE) \
1bb87f28 2167 case MULT: \
7a6cf439 2168 return (TARGET_V8 || TARGET_V9) ? COSTS_N_INSNS (5) : COSTS_N_INSNS (25); \
1bb87f28
JW
2169 case DIV: \
2170 case UDIV: \
2171 case MOD: \
2172 case UMOD: \
5b485d2c
JW
2173 return COSTS_N_INSNS (25); \
2174 /* Make FLOAT and FIX more expensive than CONST_DOUBLE,\
1bb87f28
JW
2175 so that cse will favor the latter. */ \
2176 case FLOAT: \
5b485d2c 2177 case FIX: \
1bb87f28
JW
2178 return 19;
2179
bef8d8c7
JW
2180/* Adjust the cost of dependencies. */
2181#define ADJUST_COST(INSN,LINK,DEP,COST) \
2182 if (TARGET_SUPERSPARC) \
2183 (COST) = supersparc_adjust_cost (INSN, LINK, DEP, COST)
2184
1bb87f28
JW
2185/* Conditional branches with empty delay slots have a length of two. */
2186#define ADJUST_INSN_LENGTH(INSN, LENGTH) \
2187 if (GET_CODE (INSN) == CALL_INSN \
2188 || (GET_CODE (INSN) == JUMP_INSN && ! simplejump_p (insn))) \
2189 LENGTH += 1;
2190\f
2191/* Control the assembler format that we output. */
2192
2193/* Output at beginning of assembler file. */
2194
2195#define ASM_FILE_START(file)
2196
2197/* Output to assembler file text saying following lines
2198 may contain character constants, extra white space, comments, etc. */
2199
2200#define ASM_APP_ON ""
2201
2202/* Output to assembler file text saying following lines
2203 no longer contain unusual constructs. */
2204
2205#define ASM_APP_OFF ""
2206
7a6cf439
DE
2207/* ??? Try to make the style consistent here (_OP?). */
2208
2209#define ASM_LONGLONG ".xword"
303d524a
JW
2210#define ASM_LONG ".word"
2211#define ASM_SHORT ".half"
2212#define ASM_BYTE_OP ".byte"
7a6cf439
DE
2213#define ASM_FLOAT ".single"
2214#define ASM_DOUBLE ".double"
2215#define ASM_LONGDOUBLE ".xxx" /* ??? Not known (or used yet). */
303d524a 2216
1bb87f28
JW
2217/* Output before read-only data. */
2218
2219#define TEXT_SECTION_ASM_OP ".text"
2220
2221/* Output before writable data. */
2222
2223#define DATA_SECTION_ASM_OP ".data"
2224
2225/* How to refer to registers in assembler output.
2226 This sequence is indexed by compiler's hard-register-number (see above). */
2227
7a6cf439
DE
2228#ifdef SPARCV9
2229#define REGISTER_NAMES \
2230{"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", \
2231 "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", \
2232 "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
2233 "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", \
2234 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", \
2235 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", \
2236 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", \
2237 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", \
2238 "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", \
2239 "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", \
2240 "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", \
2241 "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", \
2242 "%fcc0", "%fcc1", "%fcc2", "%fcc3"}
2243#else
1bb87f28
JW
2244#define REGISTER_NAMES \
2245{"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", \
2246 "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", \
2247 "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
2248 "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", \
2249 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", \
2250 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", \
2251 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", \
2252 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31"}
7a6cf439 2253#endif
1bb87f28 2254
ea3fa5f7
JW
2255/* Define additional names for use in asm clobbers and asm declarations.
2256
2257 We define the fake Condition Code register as an alias for reg 0 (which
2258 is our `condition code' register), so that condition codes can easily
2259 be clobbered by an asm. No such register actually exists. Condition
2260 codes are partly stored in the PSR and partly in the FSR. */
2261
0eb9f40e 2262#define ADDITIONAL_REGISTER_NAMES {"ccr", 0, "cc", 0}
ea3fa5f7 2263
1bb87f28
JW
2264/* How to renumber registers for dbx and gdb. */
2265
2266#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
2267
2268/* On Sun 4, this limit is 2048. We use 1500 to be safe,
2269 since the length can run past this up to a continuation point. */
2270#define DBX_CONTIN_LENGTH 1500
2271
2272/* This is how to output a note to DBX telling it the line number
2273 to which the following sequence of instructions corresponds.
2274
2275 This is needed for SunOS 4.0, and should not hurt for 3.2
2276 versions either. */
2277#define ASM_OUTPUT_SOURCE_LINE(file, line) \
2278 { static int sym_lineno = 1; \
2279 fprintf (file, ".stabn 68,0,%d,LM%d\nLM%d:\n", \
2280 line, sym_lineno, sym_lineno); \
2281 sym_lineno += 1; }
2282
2283/* This is how to output the definition of a user-level label named NAME,
2284 such as the label on a static function or variable NAME. */
2285
2286#define ASM_OUTPUT_LABEL(FILE,NAME) \
2287 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
2288
2289/* This is how to output a command to make the user-level label named NAME
2290 defined for reference from other files. */
2291
2292#define ASM_GLOBALIZE_LABEL(FILE,NAME) \
2293 do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
2294
2295/* This is how to output a reference to a user-level label named NAME.
2296 `assemble_name' uses this. */
2297
2298#define ASM_OUTPUT_LABELREF(FILE,NAME) \
2299 fprintf (FILE, "_%s", NAME)
2300
d2a8e680 2301/* This is how to output a definition of an internal numbered label where
1bb87f28
JW
2302 PREFIX is the class of label and NUM is the number within the class. */
2303
2304#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
2305 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
2306
d2a8e680
RS
2307/* This is how to output a reference to an internal numbered label where
2308 PREFIX is the class of label and NUM is the number within the class. */
2309/* FIXME: This should be used throughout gcc, and documented in the texinfo
2310 files. There is no reason you should have to allocate a buffer and
2311 `sprintf' to reference an internal label (as opposed to defining it). */
2312
2313#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
2314 fprintf (FILE, "%s%d", PREFIX, NUM)
2315
1bb87f28
JW
2316/* This is how to store into the string LABEL
2317 the symbol_ref name of an internal numbered label where
2318 PREFIX is the class of label and NUM is the number within the class.
2319 This is suitable for output with `assemble_name'. */
2320
2321#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
2322 sprintf (LABEL, "*%s%d", PREFIX, NUM)
2323
2324/* This is how to output an assembler line defining a `double' constant. */
2325
2326#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
2327 { \
2e7ac77c
JW
2328 long t[2]; \
2329 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \
2330 fprintf (FILE, "\t%s\t0x%lx\n\t%s\t0x%lx\n", \
2331 ASM_LONG, t[0], ASM_LONG, t[1]); \
1bb87f28
JW
2332 }
2333
2334/* This is how to output an assembler line defining a `float' constant. */
2335
2336#define ASM_OUTPUT_FLOAT(FILE,VALUE) \
2337 { \
2e7ac77c
JW
2338 long t; \
2339 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
2340 fprintf (FILE, "\t%s\t0x%lx\n", ASM_LONG, t); \
2341 } \
1bb87f28 2342
0cd02cbb
DE
2343/* This is how to output an assembler line defining a `long double'
2344 constant. */
2345
2346#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
2347 { \
2348 long t[4]; \
2349 REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), t); \
2350 fprintf (FILE, "\t%s\t0x%lx\n\t%s\t0x%lx\n\t%s\t0x%lx\n\t%s\t0x%lx\n", \
2351 ASM_LONG, t[0], ASM_LONG, t[1], ASM_LONG, t[2], ASM_LONG, t[3]); \
2352 }
2353
1bb87f28
JW
2354/* This is how to output an assembler line defining an `int' constant. */
2355
2356#define ASM_OUTPUT_INT(FILE,VALUE) \
303d524a 2357( fprintf (FILE, "\t%s\t", ASM_LONG), \
1bb87f28
JW
2358 output_addr_const (FILE, (VALUE)), \
2359 fprintf (FILE, "\n"))
2360
2361/* This is how to output an assembler line defining a DImode constant. */
2362#define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE) \
2363 output_double_int (FILE, VALUE)
2364
2365/* Likewise for `char' and `short' constants. */
2366
2367#define ASM_OUTPUT_SHORT(FILE,VALUE) \
303d524a 2368( fprintf (FILE, "\t%s\t", ASM_SHORT), \
1bb87f28
JW
2369 output_addr_const (FILE, (VALUE)), \
2370 fprintf (FILE, "\n"))
2371
2372#define ASM_OUTPUT_CHAR(FILE,VALUE) \
303d524a 2373( fprintf (FILE, "\t%s\t", ASM_BYTE_OP), \
1bb87f28
JW
2374 output_addr_const (FILE, (VALUE)), \
2375 fprintf (FILE, "\n"))
2376
2377/* This is how to output an assembler line for a numeric constant byte. */
2378
2379#define ASM_OUTPUT_BYTE(FILE,VALUE) \
303d524a 2380 fprintf (FILE, "\t%s\t0x%x\n", ASM_BYTE_OP, (VALUE))
1bb87f28
JW
2381
2382/* This is how to output an element of a case-vector that is absolute. */
2383
2384#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
4b69d2a3
RS
2385do { \
2386 char label[30]; \
2387 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
7a6cf439
DE
2388 if (Pmode == SImode) \
2389 fprintf (FILE, "\t.word\t"); \
2390 else if (TARGET_ENV32) \
2391 fprintf (FILE, "\t.word\t0\n\t.word\t"); \
2392 else \
2393 fprintf (FILE, "\t.xword\t"); \
4b69d2a3
RS
2394 assemble_name (FILE, label); \
2395 fprintf (FILE, "\n"); \
2396} while (0)
1bb87f28
JW
2397
2398/* This is how to output an element of a case-vector that is relative.
2399 (SPARC uses such vectors only when generating PIC.) */
2400
4b69d2a3
RS
2401#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
2402do { \
2403 char label[30]; \
2404 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
7a6cf439
DE
2405 if (Pmode == SImode) \
2406 fprintf (FILE, "\t.word\t"); \
2407 else if (TARGET_ENV32) \
2408 fprintf (FILE, "\t.word\t0\n\t.word\t"); \
2409 else \
2410 fprintf (FILE, "\t.xword\t"); \
4b69d2a3
RS
2411 assemble_name (FILE, label); \
2412 fprintf (FILE, "-1b\n"); \
2413} while (0)
1bb87f28
JW
2414
2415/* This is how to output an assembler line
2416 that says to advance the location counter
2417 to a multiple of 2**LOG bytes. */
2418
2419#define ASM_OUTPUT_ALIGN(FILE,LOG) \
2420 if ((LOG) != 0) \
2421 fprintf (FILE, "\t.align %d\n", (1<<(LOG)))
2422
2423#define ASM_OUTPUT_SKIP(FILE,SIZE) \
2424 fprintf (FILE, "\t.skip %u\n", (SIZE))
2425
2426/* This says how to output an assembler line
2427 to define a global common symbol. */
2428
2429#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
b277ceaf 2430( fputs ("\t.common ", (FILE)), \
1bb87f28 2431 assemble_name ((FILE), (NAME)), \
b277ceaf 2432 fprintf ((FILE), ",%u,\"bss\"\n", (SIZE)))
1bb87f28 2433
b277ceaf
JW
2434/* This says how to output an assembler line to define a local common
2435 symbol. */
1bb87f28 2436
b277ceaf
JW
2437#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGNED) \
2438( fputs ("\t.reserve ", (FILE)), \
2439 assemble_name ((FILE), (NAME)), \
2440 fprintf ((FILE), ",%u,\"bss\",%u\n", \
2441 (SIZE), ((ALIGNED) / BITS_PER_UNIT)))
1bb87f28
JW
2442
2443/* Store in OUTPUT a string (made with alloca) containing
2444 an assembler-name for a local static variable named NAME.
2445 LABELNO is an integer which is different for each call. */
2446
2447#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2448( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2449 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2450
c14f2655
RS
2451#define IDENT_ASM_OP ".ident"
2452
2453/* Output #ident as a .ident. */
2454
2455#define ASM_OUTPUT_IDENT(FILE, NAME) \
2456 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
2457
1bb87f28
JW
2458/* Define the parentheses used to group arithmetic operations
2459 in assembler code. */
2460
2461#define ASM_OPEN_PAREN "("
2462#define ASM_CLOSE_PAREN ")"
2463
2464/* Define results of standard character escape sequences. */
2465#define TARGET_BELL 007
2466#define TARGET_BS 010
2467#define TARGET_TAB 011
2468#define TARGET_NEWLINE 012
2469#define TARGET_VT 013
2470#define TARGET_FF 014
2471#define TARGET_CR 015
2472
2473#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
2ccdef65 2474 ((CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' || (CHAR) == '(')
1bb87f28
JW
2475
2476/* Print operand X (an rtx) in assembler syntax to file FILE.
2477 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2478 For `%' followed by punctuation, CODE is the punctuation and X is null. */
2479
2480#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
2481
2482/* Print a memory address as an operand to reference that memory location. */
2483
2484#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
2485{ register rtx base, index = 0; \
2486 int offset = 0; \
2487 register rtx addr = ADDR; \
2488 if (GET_CODE (addr) == REG) \
2489 fputs (reg_names[REGNO (addr)], FILE); \
2490 else if (GET_CODE (addr) == PLUS) \
2491 { \
2492 if (GET_CODE (XEXP (addr, 0)) == CONST_INT) \
2493 offset = INTVAL (XEXP (addr, 0)), base = XEXP (addr, 1);\
2494 else if (GET_CODE (XEXP (addr, 1)) == CONST_INT) \
2495 offset = INTVAL (XEXP (addr, 1)), base = XEXP (addr, 0);\
2496 else \
2497 base = XEXP (addr, 0), index = XEXP (addr, 1); \
2498 fputs (reg_names[REGNO (base)], FILE); \
2499 if (index == 0) \
2500 fprintf (FILE, "%+d", offset); \
2501 else if (GET_CODE (index) == REG) \
2502 fprintf (FILE, "+%s", reg_names[REGNO (index)]); \
2503 else if (GET_CODE (index) == SYMBOL_REF) \
2504 fputc ('+', FILE), output_addr_const (FILE, index); \
2505 else abort (); \
2506 } \
2507 else if (GET_CODE (addr) == MINUS \
2508 && GET_CODE (XEXP (addr, 1)) == LABEL_REF) \
2509 { \
2510 output_addr_const (FILE, XEXP (addr, 0)); \
2511 fputs ("-(", FILE); \
2512 output_addr_const (FILE, XEXP (addr, 1)); \
2513 fputs ("-.)", FILE); \
2514 } \
2515 else if (GET_CODE (addr) == LO_SUM) \
2516 { \
2517 output_operand (XEXP (addr, 0), 0); \
2518 fputs ("+%lo(", FILE); \
2519 output_address (XEXP (addr, 1)); \
2520 fputc (')', FILE); \
2521 } \
2522 else if (flag_pic && GET_CODE (addr) == CONST \
2523 && GET_CODE (XEXP (addr, 0)) == MINUS \
2524 && GET_CODE (XEXP (XEXP (addr, 0), 1)) == CONST \
2525 && GET_CODE (XEXP (XEXP (XEXP (addr, 0), 1), 0)) == MINUS \
2526 && XEXP (XEXP (XEXP (XEXP (addr, 0), 1), 0), 1) == pc_rtx) \
2527 { \
2528 addr = XEXP (addr, 0); \
2529 output_addr_const (FILE, XEXP (addr, 0)); \
2530 /* Group the args of the second CONST in parenthesis. */ \
2531 fputs ("-(", FILE); \
2532 /* Skip past the second CONST--it does nothing for us. */\
2533 output_addr_const (FILE, XEXP (XEXP (addr, 1), 0)); \
2534 /* Close the parenthesis. */ \
2535 fputc (')', FILE); \
2536 } \
2537 else \
2538 { \
2539 output_addr_const (FILE, addr); \
2540 } \
2541}
2542
2543/* Declare functions defined in sparc.c and used in templates. */
2544
2545extern char *singlemove_string ();
2546extern char *output_move_double ();
795068a4 2547extern char *output_move_quad ();
1bb87f28 2548extern char *output_fp_move_double ();
795068a4 2549extern char *output_fp_move_quad ();
1bb87f28
JW
2550extern char *output_block_move ();
2551extern char *output_scc_insn ();
2552extern char *output_cbranch ();
7a6cf439 2553extern char *output_v9branch ();
1bb87f28 2554extern char *output_return ();
1bb87f28
JW
2555
2556/* Defined in flags.h, but insn-emit.c does not include flags.h. */
2557
2558extern int flag_pic;
This page took 0.554906 seconds and 5 git commands to generate.