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