]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sparc/sparc.h
Arrays.java (qsort): Fix off-by-one errors and use of incorrect "hi" value when count...
[thirdparty/gcc.git] / gcc / config / sparc / sparc.h
CommitLineData
1bb87f28 1/* Definitions of target machine for GNU compiler, for Sun SPARC.
4592bdcb 2 Copyright (C) 1987, 1988, 1989, 1992, 1994, 1995, 1996, 1997, 1998, 1999
16c484c7 3 2000, 2001, 2002 Free Software Foundation, Inc.
1bb87f28 4 Contributed by Michael Tiemann (tiemann@cygnus.com).
7a6cf439
DE
5 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
6 at Cygnus Support.
1bb87f28
JW
7
8This file is part of GNU CC.
9
10GNU CC is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 2, or (at your option)
13any later version.
14
15GNU CC is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with GNU CC; see the file COPYING. If not, write to
c15c9075
RK
22the Free Software Foundation, 59 Temple Place - Suite 330,
23Boston, MA 02111-1307, USA. */
1bb87f28
JW
24
25/* Note that some other tm.h files include this one and then override
a0a301fc
DE
26 whatever definitions are necessary. */
27
28/* Specify this in a cover file to provide bi-architecture (32/64) support. */
29/* #define SPARC_BI_ARCH */
30
31/* Macro used later in this file to determine default architecture. */
32#define DEFAULT_ARCH32_P ((TARGET_DEFAULT & MASK_64BIT) == 0)
7a6cf439 33
a0a301fc
DE
34/* TARGET_ARCH{32,64} are the main macros to decide which of the two
35 architectures to compile for. We allow targets to choose compile time or
36 runtime selection. */
959eb758 37#ifdef IN_LIBGCC2
afdac905 38#if defined(__sparcv9) || defined(__arch64__)
959eb758
DM
39#define TARGET_ARCH32 0
40#else
41#define TARGET_ARCH32 1
afdac905 42#endif /* sparc64 */
959eb758 43#else
53f4a9f6 44#ifdef SPARC_BI_ARCH
a0a301fc
DE
45#define TARGET_ARCH32 (! TARGET_64BIT)
46#else
47#define TARGET_ARCH32 (DEFAULT_ARCH32_P)
959eb758 48#endif /* SPARC_BI_ARCH */
53f4a9f6 49#endif /* IN_LIBGCC2 */
a0a301fc
DE
50#define TARGET_ARCH64 (! TARGET_ARCH32)
51
52/* Code model selection.
53 -mcmodel is used to select the v9 code model.
5cb01b65 54 Different code models aren't supported for v7/8 code.
a0a301fc
DE
55
56 TARGET_CM_32: 32 bit address space, top 32 bits = 0,
57 pointers are 32 bits. Note that this isn't intended
5cb01b65 58 to imply a v7/8 abi.
a0a301fc
DE
59
60 TARGET_CM_MEDLOW: 32 bit address space, top 32 bits = 0,
61 avoid generating %uhi and %ulo terms,
62 pointers are 64 bits.
63
64 TARGET_CM_MEDMID: 64 bit address space.
65 The executable must be in the low 16 TB of memory.
66 This corresponds to the low 44 bits, and the %[hml]44
67cb8900
JJ
67 relocs are used. The text segment has a maximum size
68 of 31 bits.
a0a301fc
DE
69
70 TARGET_CM_MEDANY: 64 bit address space.
71 The text and data segments have a maximum size of 31
72 bits and may be located anywhere. The maximum offset
73 from any instruction to the label _GLOBAL_OFFSET_TABLE_
74 is 31 bits.
75
76 TARGET_CM_EMBMEDANY: 64 bit address space.
77 The text and data segments have a maximum size of 31 bits
78 and may be located anywhere. Register %g4 contains
79 the start address of the data segment.
80*/
81
82enum cmodel {
83 CM_32,
84 CM_MEDLOW,
85 CM_MEDMID,
86 CM_MEDANY,
87 CM_EMBMEDANY
88};
89
90/* Value of -mcmodel specified by user. */
3bb5de61 91extern const char *sparc_cmodel_string;
a0a301fc
DE
92/* One of CM_FOO. */
93extern enum cmodel sparc_cmodel;
94
95/* V9 code model selection. */
96#define TARGET_CM_MEDLOW (sparc_cmodel == CM_MEDLOW)
97#define TARGET_CM_MEDMID (sparc_cmodel == CM_MEDMID)
98#define TARGET_CM_MEDANY (sparc_cmodel == CM_MEDANY)
99#define TARGET_CM_EMBMEDANY (sparc_cmodel == CM_EMBMEDANY)
100
a330e73b 101#define SPARC_DEFAULT_CMODEL CM_32
6f64bf5f 102
a0a301fc
DE
103/* This is call-clobbered in the normal ABI, but is reserved in the
104 home grown (aka upward compatible) embedded ABI. */
105#define EMBMEDANY_BASE_REG "%g4"
106\f
107/* Values of TARGET_CPU_DEFAULT, set via -D in the Makefile,
108 and specified by the user via --with-cpu=foo.
109 This specifies the cpu implementation, not the architecture size. */
8947065c
RH
110/* Note that TARGET_CPU_v9 is assumed to start the list of 64-bit
111 capable cpu's. */
2163f11b
RK
112#define TARGET_CPU_sparc 0
113#define TARGET_CPU_v7 0 /* alias for previous */
114#define TARGET_CPU_sparclet 1
115#define TARGET_CPU_sparclite 2
a0a301fc 116#define TARGET_CPU_v8 3 /* generic v8 implementation */
2163f11b 117#define TARGET_CPU_supersparc 4
8947065c 118#define TARGET_CPU_hypersparc 5
809934df 119#define TARGET_CPU_sparc86x 6
8947065c
RH
120#define TARGET_CPU_sparclite86x 6
121#define TARGET_CPU_v9 7 /* generic v9 implementation */
122#define TARGET_CPU_sparcv9 7 /* alias */
123#define TARGET_CPU_sparc64 7 /* alias */
124#define TARGET_CPU_ultrasparc 8
bafb031b 125
8947065c
RH
126#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
127 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
345a6161
DM
128
129#define CPP_CPU32_DEFAULT_SPEC ""
130#define ASM_CPU32_DEFAULT_SPEC ""
131
a0a301fc 132#if TARGET_CPU_DEFAULT == TARGET_CPU_v9
bafb031b 133/* ??? What does Sun's CC pass? */
345a6161 134#define CPP_CPU64_DEFAULT_SPEC "-D__sparc_v9__"
bafb031b
DE
135/* ??? It's not clear how other assemblers will handle this, so by default
136 use GAS. Sun's Solaris assembler recognizes -xarch=v8plus, but this case
137 is handled in sol2.h. */
345a6161 138#define ASM_CPU64_DEFAULT_SPEC "-Av9"
bafb031b 139#endif
a0a301fc 140#if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
345a6161
DM
141#define CPP_CPU64_DEFAULT_SPEC "-D__sparc_v9__"
142#define ASM_CPU64_DEFAULT_SPEC "-Av9a"
143#endif
144
145#else
146
147#define CPP_CPU64_DEFAULT_SPEC ""
148#define ASM_CPU64_DEFAULT_SPEC ""
149
8947065c
RH
150#if TARGET_CPU_DEFAULT == TARGET_CPU_sparc \
151 || TARGET_CPU_DEFAULT == TARGET_CPU_v8
345a6161
DM
152#define CPP_CPU32_DEFAULT_SPEC ""
153#define ASM_CPU32_DEFAULT_SPEC ""
154#endif
8947065c 155
345a6161
DM
156#if TARGET_CPU_DEFAULT == TARGET_CPU_sparclet
157#define CPP_CPU32_DEFAULT_SPEC "-D__sparclet__"
158#define ASM_CPU32_DEFAULT_SPEC "-Asparclet"
bafb031b 159#endif
8947065c 160
345a6161
DM
161#if TARGET_CPU_DEFAULT == TARGET_CPU_sparclite
162#define CPP_CPU32_DEFAULT_SPEC "-D__sparclite__"
163#define ASM_CPU32_DEFAULT_SPEC "-Asparclite"
164#endif
165
8947065c
RH
166#if TARGET_CPU_DEFAULT == TARGET_CPU_supersparc
167#define CPP_CPU32_DEFAULT_SPEC "-D__supersparc__ -D__sparc_v8__"
168#define ASM_CPU32_DEFAULT_SPEC ""
169#endif
170
171#if TARGET_CPU_DEFAULT == TARGET_CPU_hypersparc
172#define CPP_CPU32_DEFAULT_SPEC "-D__hypersparc__ -D__sparc_v8__"
173#define ASM_CPU32_DEFAULT_SPEC ""
174#endif
175
176#if TARGET_CPU_DEFAULT == TARGET_CPU_sparclite86x
8d72ec32
VM
177#define CPP_CPU32_DEFAULT_SPEC "-D__sparclite86x__"
178#define ASM_CPU32_DEFAULT_SPEC "-Asparclite"
8947065c
RH
179#endif
180
345a6161
DM
181#endif
182
183#if !defined(CPP_CPU32_DEFAULT_SPEC) || !defined(CPP_CPU64_DEFAULT_SPEC)
a0a301fc 184Unrecognized value in TARGET_CPU_DEFAULT.
bafb031b
DE
185#endif
186
345a6161
DM
187#ifdef SPARC_BI_ARCH
188
189#define CPP_CPU_DEFAULT_SPEC \
190(DEFAULT_ARCH32_P ? "\
191%{m64:" CPP_CPU64_DEFAULT_SPEC "} \
192%{!m64:" CPP_CPU32_DEFAULT_SPEC "} \
193" : "\
194%{m32:" CPP_CPU32_DEFAULT_SPEC "} \
195%{!m32:" CPP_CPU64_DEFAULT_SPEC "} \
196")
197#define ASM_CPU_DEFAULT_SPEC \
198(DEFAULT_ARCH32_P ? "\
199%{m64:" ASM_CPU64_DEFAULT_SPEC "} \
200%{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
201" : "\
202%{m32:" ASM_CPU32_DEFAULT_SPEC "} \
203%{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
204")
205
206#else /* !SPARC_BI_ARCH */
207
208#define CPP_CPU_DEFAULT_SPEC (DEFAULT_ARCH32_P ? CPP_CPU32_DEFAULT_SPEC : CPP_CPU64_DEFAULT_SPEC)
209#define ASM_CPU_DEFAULT_SPEC (DEFAULT_ARCH32_P ? ASM_CPU32_DEFAULT_SPEC : ASM_CPU64_DEFAULT_SPEC)
210
211#endif /* !SPARC_BI_ARCH */
212
885d8175 213/* Define macros to distinguish architectures. */
857458c4 214
bafb031b
DE
215/* Common CPP definitions used by CPP_SPEC amongst the various targets
216 for handling -mcpu=xxx switches. */
217#define CPP_CPU_SPEC "\
7adb4be8 218%{msoft-float:-D_SOFT_FLOAT} \
bafb031b 219%{mcypress:} \
7a6cf439
DE
220%{msparclite:-D__sparclite__} \
221%{mf930:-D__sparclite__} %{mf934:-D__sparclite__} \
222%{mv8:-D__sparc_v8__} \
bafb031b 223%{msupersparc:-D__supersparc__ -D__sparc_v8__} \
9b7c06d2 224%{mcpu=sparclet:-D__sparclet__} %{mcpu=tsc701:-D__sparclet__} \
bafb031b
DE
225%{mcpu=sparclite:-D__sparclite__} \
226%{mcpu=f930:-D__sparclite__} %{mcpu=f934:-D__sparclite__} \
227%{mcpu=v8:-D__sparc_v8__} \
228%{mcpu=supersparc:-D__supersparc__ -D__sparc_v8__} \
8947065c 229%{mcpu=hypersparc:-D__hypersparc__ -D__sparc_v8__} \
8d72ec32 230%{mcpu=sparclite86x:-D__sparclite86x__} \
bafb031b
DE
231%{mcpu=v9:-D__sparc_v9__} \
232%{mcpu=ultrasparc:-D__sparc_v9__} \
a0a301fc 233%{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(cpp_cpu_default)}}}}}}} \
7a6cf439 234"
885d8175 235
a0a301fc
DE
236/* ??? The GCC_NEW_VARARGS macro is now obsolete, because gcc always uses
237 the right varags.h file when bootstrapping. */
238/* ??? It's not clear what value we want to use for -Acpu/machine for
239 sparc64 in 32 bit environments, so for now we only use `sparc64' in
240 64 bit environments. */
241
345a6161
DM
242#ifdef SPARC_BI_ARCH
243
244#define CPP_ARCH32_SPEC "-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
2b57e919 245-D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
345a6161 246#define CPP_ARCH64_SPEC "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
2b57e919 247-D__arch64__ -Acpu=sparc64 -Amachine=sparc64"
345a6161
DM
248
249#else
250
2b57e919
NB
251#define CPP_ARCH32_SPEC "-D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
252#define CPP_ARCH64_SPEC "-D__arch64__ -Acpu=sparc64 -Amachine=sparc64"
345a6161
DM
253
254#endif
255
a0a301fc
DE
256#define CPP_ARCH_DEFAULT_SPEC \
257(DEFAULT_ARCH32_P ? CPP_ARCH32_SPEC : CPP_ARCH64_SPEC)
258
259#define CPP_ARCH_SPEC "\
260%{m32:%(cpp_arch32)} \
261%{m64:%(cpp_arch64)} \
262%{!m32:%{!m64:%(cpp_arch_default)}} \
263"
264
265/* Macros to distinguish endianness. */
8947065c
RH
266#define CPP_ENDIAN_SPEC "\
267%{mlittle-endian:-D__LITTLE_ENDIAN__} \
268%{mlittle-endian-data:-D__LITTLE_ENDIAN_DATA__}"
a0a301fc
DE
269
270/* Macros to distinguish the particular subtarget. */
271#define CPP_SUBTARGET_SPEC ""
272
273#define CPP_SPEC "%(cpp_cpu) %(cpp_arch) %(cpp_endian) %(cpp_subtarget)"
274
b1fc14e5
RS
275/* Prevent error on `-sun4' and `-target sun4' options. */
276/* This used to translate -dalign to -malign, but that is no good
277 because it can't turn off the usual meaning of making debugging dumps. */
bafb031b 278/* Translate old style -m<cpu> into new style -mcpu=<cpu>.
1cdbf242 279 ??? Delete support for -m<cpu> for 2.9. */
bafb031b
DE
280
281#define CC1_SPEC "\
282%{sun4:} %{target:} \
283%{mcypress:-mcpu=cypress} \
284%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
285%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
286"
287
bafb031b
DE
288/* Override in target specific files. */
289#define ASM_CPU_SPEC "\
9b7c06d2 290%{mcpu=sparclet:-Asparclet} %{mcpu=tsc701:-Asparclet} \
bafb031b
DE
291%{msparclite:-Asparclite} \
292%{mf930:-Asparclite} %{mf934:-Asparclite} \
293%{mcpu=sparclite:-Asparclite} \
8d72ec32 294%{mcpu=sparclite86x:-Asparclite} \
bafb031b 295%{mcpu=f930:-Asparclite} %{mcpu=f934:-Asparclite} \
284d86e9 296%{mv8plus:-Av8plus} \
bafb031b 297%{mcpu=v9:-Av9} \
284d86e9 298%{mcpu=ultrasparc:%{!mv8plus:-Av9a}} \
a0a301fc 299%{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(asm_cpu_default)}}}}}}} \
bafb031b
DE
300"
301
e632a26c
DE
302/* Word size selection, among other things.
303 This is what GAS uses. Add %(asm_arch) to ASM_SPEC to enable. */
304
a0a301fc 305#define ASM_ARCH32_SPEC "-32"
6149cebb
JJ
306#ifdef HAVE_AS_REGISTER_PSEUDO_OP
307#define ASM_ARCH64_SPEC "-64 -no-undeclared-regs"
308#else
a0a301fc 309#define ASM_ARCH64_SPEC "-64"
6149cebb 310#endif
a0a301fc 311#define ASM_ARCH_DEFAULT_SPEC \
e632a26c 312(DEFAULT_ARCH32_P ? ASM_ARCH32_SPEC : ASM_ARCH64_SPEC)
a0a301fc
DE
313
314#define ASM_ARCH_SPEC "\
315%{m32:%(asm_arch32)} \
316%{m64:%(asm_arch64)} \
317%{!m32:%{!m64:%(asm_arch_default)}} \
318"
319
e95b1e6a
JJ
320#ifdef HAVE_AS_RELAX_OPTION
321#define ASM_RELAX_SPEC "%{!mno-relax:-relax}"
322#else
323#define ASM_RELAX_SPEC ""
324#endif
325
a0a301fc
DE
326/* Special flags to the Sun-4 assembler when using pipe for input. */
327
328#define ASM_SPEC "\
329%| %{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \
e95b1e6a 330%(asm_cpu) %(asm_relax)"
a0a301fc 331
bafb031b
DE
332/* This macro defines names of additional specifications to put in the specs
333 that can be used in various specifications like CC1_SPEC. Its definition
334 is an initializer with a subgrouping for each command option.
335
336 Each subgrouping contains a string constant, that defines the
337 specification name, and a string constant that used by the GNU CC driver
338 program.
339
340 Do not define this macro if it does not need to do anything. */
1bb87f28 341
a0a301fc 342#define EXTRA_SPECS \
829245be
KG
343 { "cpp_cpu", CPP_CPU_SPEC }, \
344 { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC }, \
345 { "cpp_arch32", CPP_ARCH32_SPEC }, \
346 { "cpp_arch64", CPP_ARCH64_SPEC }, \
347 { "cpp_arch_default", CPP_ARCH_DEFAULT_SPEC },\
348 { "cpp_arch", CPP_ARCH_SPEC }, \
349 { "cpp_endian", CPP_ENDIAN_SPEC }, \
350 { "cpp_subtarget", CPP_SUBTARGET_SPEC }, \
351 { "asm_cpu", ASM_CPU_SPEC }, \
352 { "asm_cpu_default", ASM_CPU_DEFAULT_SPEC }, \
353 { "asm_arch32", ASM_ARCH32_SPEC }, \
354 { "asm_arch64", ASM_ARCH64_SPEC }, \
e95b1e6a 355 { "asm_relax", ASM_RELAX_SPEC }, \
829245be
KG
356 { "asm_arch_default", ASM_ARCH_DEFAULT_SPEC },\
357 { "asm_arch", ASM_ARCH_SPEC }, \
bafb031b 358 SUBTARGET_EXTRA_SPECS
1bb87f28 359
bafb031b 360#define SUBTARGET_EXTRA_SPECS
bbd7687d
DM
361
362/* Because libgcc can generate references back to libc (via .umul etc.) we have
363 to list libc again after the second libgcc. */
364#define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G %L"
365
bafb031b 366\f
a0a301fc
DE
367#ifdef SPARC_BI_ARCH
368#define NO_BUILTIN_PTRDIFF_TYPE
369#define NO_BUILTIN_SIZE_TYPE
857458c4 370#endif
82d6b402
RH
371#define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
372#define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
7a6cf439
DE
373
374/* ??? This should be 32 bits for v9 but what can we do? */
1bb87f28
JW
375#define WCHAR_TYPE "short unsigned int"
376#define WCHAR_TYPE_SIZE 16
377
4f074454
RK
378/* Show we can debug even without a frame pointer. */
379#define CAN_DEBUG_WITHOUT_FP
1bb87f28 380
89a8b315 381#define OVERRIDE_OPTIONS sparc_override_options ()
5b485d2c 382
1bb87f28
JW
383/* Generate DBX debugging information. */
384
385#define DBX_DEBUGGING_INFO
7a6cf439 386\f
1bb87f28
JW
387/* Run-time compilation parameters selecting different hardware subsets. */
388
389extern int target_flags;
390
391/* Nonzero if we should generate code to use the fpu. */
7a6cf439
DE
392#define MASK_FPU 1
393#define TARGET_FPU (target_flags & MASK_FPU)
1bb87f28 394
95dea81f
JW
395/* Nonzero if we should assume that double pointers might be unaligned.
396 This can happen when linking gcc compiled code with other compilers,
397 because the ABI only guarantees 4 byte alignment. */
7a6cf439
DE
398#define MASK_UNALIGNED_DOUBLES 4
399#define TARGET_UNALIGNED_DOUBLES (target_flags & MASK_UNALIGNED_DOUBLES)
400
885d8175 401/* Nonzero means that we should generate code for a v8 sparc. */
6f64bf5f 402#define MASK_V8 0x8
7a6cf439 403#define TARGET_V8 (target_flags & MASK_V8)
885d8175 404
bc9e02ae
JW
405/* Nonzero means that we should generate code for a sparclite.
406 This enables the sparclite specific instructions, but does not affect
407 whether FPU instructions are emitted. */
6f64bf5f 408#define MASK_SPARCLITE 0x10
7a6cf439 409#define TARGET_SPARCLITE (target_flags & MASK_SPARCLITE)
885d8175 410
bafb031b
DE
411/* Nonzero if we're compiling for the sparclet. */
412#define MASK_SPARCLET 0x20
413#define TARGET_SPARCLET (target_flags & MASK_SPARCLET)
6f64bf5f
DE
414
415/* Nonzero if we're compiling for v9 sparc.
416 Note that v9's can run in 32 bit mode so this doesn't necessarily mean
bafb031b 417 the word size is 64. */
6f64bf5f
DE
418#define MASK_V9 0x40
419#define TARGET_V9 (target_flags & MASK_V9)
420
bafb031b
DE
421/* Non-zero to generate code that uses the instructions deprecated in
422 the v9 architecture. This option only applies to v9 systems. */
423/* ??? This isn't user selectable yet. It's used to enable such insns
424 on 32 bit v9 systems and for the moment they're permanently disabled
425 on 64 bit v9 systems. */
426#define MASK_DEPRECATED_V8_INSNS 0x80
427#define TARGET_DEPRECATED_V8_INSNS (target_flags & MASK_DEPRECATED_V8_INSNS)
6f64bf5f 428
bafb031b
DE
429/* Mask of all CPU selection flags. */
430#define MASK_ISA \
431(MASK_V8 + MASK_SPARCLITE + MASK_SPARCLET + MASK_V9 + MASK_DEPRECATED_V8_INSNS)
6f64bf5f 432
bafb031b
DE
433/* Non-zero means don't pass `-assert pure-text' to the linker. */
434#define MASK_IMPURE_TEXT 0x100
435#define TARGET_IMPURE_TEXT (target_flags & MASK_IMPURE_TEXT)
5b485d2c 436
9a1c7cd7 437/* Nonzero means that we should generate code using a flat register window
bafb031b
DE
438 model, i.e. no save/restore instructions are generated, which is
439 compatible with normal sparc code.
440 The frame pointer is %i7 instead of %fp. */
7a6cf439
DE
441#define MASK_FLAT 0x200
442#define TARGET_FLAT (target_flags & MASK_FLAT)
9a1c7cd7 443
34ad7aaf 444/* Nonzero means use the registers that the Sparc ABI reserves for
bafb031b
DE
445 application software. This must be the default to coincide with the
446 setting in FIXED_REGISTERS. */
7a6cf439
DE
447#define MASK_APP_REGS 0x400
448#define TARGET_APP_REGS (target_flags & MASK_APP_REGS)
34ad7aaf 449
eb582c5d
DE
450/* Option to select how quad word floating point is implemented.
451 When TARGET_HARD_QUAD is true, we use the hardware quad instructions.
452 Otherwise, we use the SPARC ABI quad library functions. */
7a6cf439
DE
453#define MASK_HARD_QUAD 0x800
454#define TARGET_HARD_QUAD (target_flags & MASK_HARD_QUAD)
455
62f1c649
DE
456/* Non-zero on little-endian machines. */
457/* ??? Little endian support currently only exists for sparclet-aout and
458 sparc64-elf configurations. May eventually want to expand the support
459 to all targets, but for now it's kept local to only those two. */
460#define MASK_LITTLE_ENDIAN 0x1000
461#define TARGET_LITTLE_ENDIAN (target_flags & MASK_LITTLE_ENDIAN)
7a6cf439 462
a0a301fc 463/* 0x2000, 0x4000 are unused */
7a6cf439 464
7def3512 465/* Nonzero if pointers are 64 bits. */
7a6cf439
DE
466#define MASK_PTR64 0x8000
467#define TARGET_PTR64 (target_flags & MASK_PTR64)
468
a0a301fc
DE
469/* Nonzero if generating code to run in a 64 bit environment.
470 This is intended to only be used by TARGET_ARCH{32,64} as they are the
471 mechanism used to control compile time or run time selection. */
472#define MASK_64BIT 0x10000
473#define TARGET_64BIT (target_flags & MASK_64BIT)
474
475/* 0x20000,0x40000 unused */
7a6cf439
DE
476
477/* Non-zero means use a stack bias of 2047. Stack offsets are obtained by
478 adding 2047 to %sp. This option is for v9 only and is the default. */
479#define MASK_STACK_BIAS 0x80000
480#define TARGET_STACK_BIAS (target_flags & MASK_STACK_BIAS)
8248e2bc 481
e6c1be7e 482/* 0x100000,0x200000 unused */
9b7c06d2 483
1f1406b4
DE
484/* Non-zero means -m{,no-}fpu was passed on the command line. */
485#define MASK_FPU_SET 0x400000
486#define TARGET_FPU_SET (target_flags & MASK_FPU_SET)
487
bfd6bc60
JC
488/* Use the UltraSPARC Visual Instruction Set extensions. */
489#define MASK_VIS 0x1000000
490#define TARGET_VIS (target_flags & MASK_VIS)
491
284d86e9 492/* Compile for Solaris V8+. 32 bit Solaris preserves the high bits of
5cb01b65
JJ
493 the current out and global registers and Linux 2.2+ as well. */
494#define MASK_V8PLUS 0x2000000
bfd6bc60
JC
495#define TARGET_V8PLUS (target_flags & MASK_V8PLUS)
496
c219ddf7
BK
497/* Force a the fastest alignment on structures to take advantage of
498 faster copies. */
499#define MASK_FASTER_STRUCTS 0x4000000
500#define TARGET_FASTER_STRUCTS (target_flags & MASK_FASTER_STRUCTS)
501
4710d3eb
JJ
502/* Use IEEE quad long double. */
503#define MASK_LONG_DOUBLE_128 0x8000000
504#define TARGET_LONG_DOUBLE_128 (target_flags & MASK_LONG_DOUBLE_128)
505
284d86e9
JC
506/* TARGET_HARD_MUL: Use hardware multiply instructions but not %y.
507 TARGET_HARD_MUL32: Use hardware multiply instructions with rd %y
508 to get high 32 bits. False in V8+ or V9 because multiply stores
509 a 64 bit result in a register. */
510
bfd6bc60
JC
511#define TARGET_HARD_MUL32 \
512 ((TARGET_V8 || TARGET_SPARCLITE \
513 || TARGET_SPARCLET || TARGET_DEPRECATED_V8_INSNS) \
5cb01b65 514 && ! TARGET_V8PLUS && TARGET_ARCH32)
bfd6bc60
JC
515
516#define TARGET_HARD_MUL \
517 (TARGET_V8 || TARGET_SPARCLITE || TARGET_SPARCLET \
518 || TARGET_DEPRECATED_V8_INSNS || TARGET_V8PLUS)
519
520
1bb87f28
JW
521/* Macro to define tables used to set the flags.
522 This is a list in braces of pairs in braces,
523 each pair being { "NAME", VALUE }
524 where VALUE is the bits to set or minus the bits to clear.
525 An empty string NAME is used to identify the default VALUE. */
526
527#define TARGET_SWITCHES \
047142d3
PT
528 { {"fpu", MASK_FPU | MASK_FPU_SET, \
529 N_("Use hardware fp") }, \
530 {"no-fpu", -MASK_FPU, \
531 N_("Do not use hardware fp") }, \
46cc13b3 532 {"no-fpu", MASK_FPU_SET, NULL, }, \
047142d3
PT
533 {"hard-float", MASK_FPU | MASK_FPU_SET, \
534 N_("Use hardware fp") }, \
535 {"soft-float", -MASK_FPU, \
536 N_("Do not use hardware fp") }, \
537 {"soft-float", MASK_FPU_SET, NULL }, \
047142d3
PT
538 {"unaligned-doubles", MASK_UNALIGNED_DOUBLES, \
539 N_("Assume possible double misalignment") }, \
540 {"no-unaligned-doubles", -MASK_UNALIGNED_DOUBLES, \
541 N_("Assume all doubles are aligned") }, \
542 {"impure-text", MASK_IMPURE_TEXT, \
543 N_("Pass -assert pure-text to linker") }, \
544 {"no-impure-text", -MASK_IMPURE_TEXT, \
545 N_("Do not pass -assert pure-text to linker") }, \
546 {"flat", MASK_FLAT, \
547 N_("Use flat register window model") }, \
548 {"no-flat", -MASK_FLAT, \
549 N_("Do not use flat register window model") }, \
550 {"app-regs", MASK_APP_REGS, \
551 N_("Use ABI reserved registers") }, \
552 {"no-app-regs", -MASK_APP_REGS, \
553 N_("Do not use ABI reserved registers") }, \
554 {"hard-quad-float", MASK_HARD_QUAD, \
555 N_("Use hardware quad fp instructions") }, \
556 {"soft-quad-float", -MASK_HARD_QUAD, \
557 N_("Do not use hardware quad fp instructions") }, \
558 {"v8plus", MASK_V8PLUS, \
559 N_("Compile for v8plus ABI") }, \
560 {"no-v8plus", -MASK_V8PLUS, \
561 N_("Do not compile for v8plus ABI") }, \
562 {"vis", MASK_VIS, \
563 N_("Utilize Visual Instruction Set") }, \
564 {"no-vis", -MASK_VIS, \
565 N_("Do not utilize Visual Instruction Set") }, \
a0a301fc 566 /* ??? These are deprecated, coerced to -mcpu=. Delete in 2.9. */ \
047142d3
PT
567 {"cypress", 0, \
568 N_("Optimize for Cypress processors") }, \
569 {"sparclite", 0, \
570 N_("Optimize for SparcLite processors") }, \
571 {"f930", 0, \
572 N_("Optimize for F930 processors") }, \
573 {"f934", 0, \
574 N_("Optimize for F934 processors") }, \
575 {"v8", 0, \
576 N_("Use V8 Sparc ISA") }, \
577 {"supersparc", 0, \
578 N_("Optimize for SuperSparc processors") }, \
579 /* End of deprecated options. */ \
580 {"ptr64", MASK_PTR64, \
581 N_("Pointers are 64-bit") }, \
582 {"ptr32", -MASK_PTR64, \
583 N_("Pointers are 32-bit") }, \
584 {"32", -MASK_64BIT, \
585 N_("Use 32-bit ABI") }, \
586 {"64", MASK_64BIT, \
587 N_("Use 64-bit ABI") }, \
588 {"stack-bias", MASK_STACK_BIAS, \
589 N_("Use stack bias") }, \
590 {"no-stack-bias", -MASK_STACK_BIAS, \
591 N_("Do not use stack bias") }, \
592 {"faster-structs", MASK_FASTER_STRUCTS, \
593 N_("Use structs on stronger alignment for double-word copies") }, \
594 {"no-faster-structs", -MASK_FASTER_STRUCTS, \
595 N_("Do not use structs on stronger alignment for double-word copies") }, \
596 {"relax", 0, \
597 N_("Optimize tail call instructions in assembler and linker") }, \
598 {"no-relax", 0, \
599 N_("Do not optimize tail call instructions in assembler or linker") }, \
7a6cf439 600 SUBTARGET_SWITCHES \
ee76cf2a 601 { "", TARGET_DEFAULT, ""}}
1bb87f28 602
bafb031b
DE
603/* MASK_APP_REGS must always be the default because that's what
604 FIXED_REGISTERS is set to and -ffixed- is processed before
605 CONDITIONAL_REGISTER_USAGE is called (where we process -mno-app-regs). */
33074e5f 606#define TARGET_DEFAULT (MASK_APP_REGS + MASK_FPU)
84ab3bfb 607
bafb031b 608/* This is meant to be redefined in target specific files. */
84ab3bfb 609#define SUBTARGET_SWITCHES
1bb87f28 610
6afca97d
DE
611/* Processor type.
612 These must match the values for the cpu attribute in sparc.md. */
613enum processor_type {
614 PROCESSOR_V7,
615 PROCESSOR_CYPRESS,
616 PROCESSOR_V8,
617 PROCESSOR_SUPERSPARC,
618 PROCESSOR_SPARCLITE,
619 PROCESSOR_F930,
620 PROCESSOR_F934,
8947065c
RH
621 PROCESSOR_HYPERSPARC,
622 PROCESSOR_SPARCLITE86X,
6afca97d 623 PROCESSOR_SPARCLET,
9b7c06d2 624 PROCESSOR_TSC701,
6afca97d
DE
625 PROCESSOR_V9,
626 PROCESSOR_ULTRASPARC
627};
628
629/* This is set from -m{cpu,tune}=xxx. */
630extern enum processor_type sparc_cpu;
631
632/* Recast the cpu class to be the cpu attribute.
633 Every file includes us, but not every file includes insn-attr.h. */
634#define sparc_cpu_attr ((enum attr_cpu) sparc_cpu)
bafb031b 635
bafb031b 636#define TARGET_OPTIONS \
047142d3
PT
637{ \
638 { "cpu=", &sparc_select[1].string, \
639 N_("Use features of and schedule code for given CPU") }, \
640 { "tune=", &sparc_select[2].string, \
641 N_("Schedule code for given CPU") }, \
642 { "cmodel=", &sparc_cmodel_string, \
643 N_("Use given Sparc code model") }, \
644 SUBTARGET_OPTIONS \
bafb031b
DE
645}
646
647/* This is meant to be redefined in target specific files. */
648#define SUBTARGET_OPTIONS
6afca97d
DE
649
650/* sparc_select[0] is reserved for the default cpu. */
651struct sparc_cpu_select
652{
3bb5de61 653 const char *string;
8b60264b
KG
654 const char *const name;
655 const int set_tune_p;
656 const int set_arch_p;
6afca97d
DE
657};
658
659extern struct sparc_cpu_select sparc_select[];
7a6cf439
DE
660\f
661/* target machine storage layout */
662
1bb87f28
JW
663/* Define this if most significant bit is lowest numbered
664 in instructions that operate on numbered bit-fields. */
665#define BITS_BIG_ENDIAN 1
666
667/* Define this if most significant byte of a word is the lowest numbered. */
1bb87f28
JW
668#define BYTES_BIG_ENDIAN 1
669
670/* Define this if most significant word of a multiword number is the lowest
671 numbered. */
1bb87f28
JW
672#define WORDS_BIG_ENDIAN 1
673
62f1c649
DE
674/* Define this to set the endianness to use in libgcc2.c, which can
675 not depend on target_flags. */
8947065c 676#if defined (__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN_DATA__)
62f1c649
DE
677#define LIBGCC2_WORDS_BIG_ENDIAN 0
678#else
679#define LIBGCC2_WORDS_BIG_ENDIAN 1
680#endif
681
7a6cf439 682#define MAX_BITS_PER_WORD 64
1bb87f28
JW
683
684/* Width of a word, in units (bytes). */
6f64bf5f 685#define UNITS_PER_WORD (TARGET_ARCH64 ? 8 : 4)
ef0e53ce 686#define MIN_UNITS_PER_WORD 4
7a6cf439
DE
687
688/* Now define the sizes of the C data types. */
689
690#define SHORT_TYPE_SIZE 16
a0a301fc
DE
691#define INT_TYPE_SIZE 32
692#define LONG_TYPE_SIZE (TARGET_ARCH64 ? 64 : 32)
7a6cf439
DE
693#define LONG_LONG_TYPE_SIZE 64
694#define FLOAT_TYPE_SIZE 32
695#define DOUBLE_TYPE_SIZE 64
696
3276910d 697#ifdef SPARC_BI_ARCH
7a6cf439 698#define MAX_LONG_TYPE_SIZE 64
a0a301fc 699#endif
7a6cf439 700
a0a301fc 701#if 0
7a6cf439
DE
702/* ??? This does not work in SunOS 4.x, so it is not enabled here.
703 Instead, it is enabled in sol2.h, because it does work under Solaris. */
ba31d94e 704/* Define for support of TFmode long double.
7a6cf439
DE
705 Sparc ABI says that long double is 4 words. */
706#define LONG_DOUBLE_TYPE_SIZE 128
707#endif
1bb87f28
JW
708
709/* Width in bits of a pointer.
710 See also the macro `Pmode' defined below. */
7a6cf439 711#define POINTER_SIZE (TARGET_PTR64 ? 64 : 32)
1bb87f28 712
3276910d
RK
713/* If we have to extend pointers (only when TARGET_ARCH64 and not
714 TARGET_PTR64), we want to do it unsigned. This macro does nothing
715 if ptr_mode and Pmode are the same. */
716#define POINTERS_EXTEND_UNSIGNED 1
717
4fb4e4b8
DE
718/* A macro to update MODE and UNSIGNEDP when an object whose type
719 is TYPE and which has the specified mode and signedness is to be
720 stored in a register. This macro is only called when TYPE is a
721 scalar type. */
722#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
723if (TARGET_ARCH64 \
724 && GET_MODE_CLASS (MODE) == MODE_INT \
725 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
3276910d 726 (MODE) = DImode;
4fb4e4b8
DE
727
728/* Define this macro if the promotion described by PROMOTE_MODE
729 should also be done for outgoing function arguments. */
730/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
731 for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime test
732 for this value. */
733#define PROMOTE_FUNCTION_ARGS
734
735/* Define this macro if the promotion described by PROMOTE_MODE
736 should also be done for the return value of functions.
737 If this macro is defined, FUNCTION_VALUE must perform the same
738 promotions done by PROMOTE_MODE. */
739/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
740 for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime test
741 for this value. */
742#define PROMOTE_FUNCTION_RETURN
743
47841d1b
JJ
744/* Define this macro if the promotion described by PROMOTE_MODE
745 should _only_ be performed for outgoing function arguments or
746 function return values, as specified by PROMOTE_FUNCTION_ARGS
747 and PROMOTE_FUNCTION_RETURN, respectively. */
748/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
749 for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime test
750 for this value. For TARGET_ARCH64 we need it, as we don't have instructions
751 for arithmetic operations which do zero/sign extension at the same time,
752 so without this we end up with a srl/sra after every assignment to an
753 user variable, which means very very bad code. */
754#define PROMOTE_FOR_CALL_ONLY
755
1bb87f28 756/* Allocation boundary (in *bits*) for storing arguments in argument list. */
6f64bf5f 757#define PARM_BOUNDARY (TARGET_ARCH64 ? 64 : 32)
1bb87f28
JW
758
759/* Boundary (in *bits*) on which stack pointer should be aligned. */
6f64bf5f 760#define STACK_BOUNDARY (TARGET_ARCH64 ? 128 : 64)
1bb87f28 761
10d1b70f
JW
762/* ALIGN FRAMES on double word boundaries */
763
7a6cf439 764#define SPARC_STACK_ALIGN(LOC) \
6f64bf5f 765 (TARGET_ARCH64 ? (((LOC)+15) & ~15) : (((LOC)+7) & ~7))
10d1b70f 766
1bb87f28 767/* Allocation boundary (in *bits*) for the code of a function. */
efa3896a 768#define FUNCTION_BOUNDARY 32
1bb87f28
JW
769
770/* Alignment of field after `int : 0' in a structure. */
6f64bf5f 771#define EMPTY_FIELD_BOUNDARY (TARGET_ARCH64 ? 64 : 32)
1bb87f28
JW
772
773/* Every structure's size must be a multiple of this. */
774#define STRUCTURE_SIZE_BOUNDARY 8
775
776/* A bitfield declared as `int' forces `int' alignment for the struct. */
777#define PCC_BITFIELD_TYPE_MATTERS 1
778
779/* No data type wants to be aligned rounder than this. */
6f64bf5f 780#define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)
1bb87f28 781
77a02b01
JW
782/* The best alignment to use in cases where we have a choice. */
783#define FASTEST_ALIGNMENT 64
784
c219ddf7
BK
785/* Define this macro as an expression for the alignment of a structure
786 (given by STRUCT as a tree node) if the alignment computed in the
787 usual way is COMPUTED and the alignment explicitly specified was
788 SPECIFIED.
789
790 The default is to use SPECIFIED if it is larger; otherwise, use
791 the smaller of COMPUTED and `BIGGEST_ALIGNMENT' */
792#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
793 (TARGET_FASTER_STRUCTS ? \
794 ((TREE_CODE (STRUCT) == RECORD_TYPE \
795 || TREE_CODE (STRUCT) == UNION_TYPE \
796 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
797 && TYPE_FIELDS (STRUCT) != 0 \
798 ? MAX (MAX ((COMPUTED), (SPECIFIED)), BIGGEST_ALIGNMENT) \
799 : MAX ((COMPUTED), (SPECIFIED))) \
800 : MAX ((COMPUTED), (SPECIFIED)))
801
1bb87f28
JW
802/* Make strings word-aligned so strcpy from constants will be faster. */
803#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
d2a8e680
RS
804 ((TREE_CODE (EXP) == STRING_CST \
805 && (ALIGN) < FASTEST_ALIGNMENT) \
806 ? FASTEST_ALIGNMENT : (ALIGN))
1bb87f28
JW
807
808/* Make arrays of chars word-aligned for the same reasons. */
809#define DATA_ALIGNMENT(TYPE, ALIGN) \
810 (TREE_CODE (TYPE) == ARRAY_TYPE \
811 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
77a02b01 812 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
1bb87f28 813
b4ac57ab 814/* Set this nonzero if move instructions will actually fail to work
1bb87f28 815 when given unaligned data. */
b4ac57ab 816#define STRICT_ALIGNMENT 1
1bb87f28
JW
817
818/* Things that must be doubleword aligned cannot go in the text section,
819 because the linker fails to align the text section enough!
7a6cf439 820 Put them in the data section. This macro is only used in this file. */
1bb87f28
JW
821#define MAX_TEXT_ALIGN 32
822
68d69835
JM
823/* This forces all variables and constants to the data section when PIC.
824 This is because the SunOS 4 shared library scheme thinks everything in
825 text is a function, and patches the address to point to a loader stub. */
826/* This is defined to zero for every system which doesn't use the a.out object
827 file format. */
828#ifndef SUNOS4_SHARED_LIBRARIES
829#define SUNOS4_SHARED_LIBRARIES 0
830#endif
831
1bb87f28
JW
832
833/* Use text section for a constant
834 unless we need more alignment than that offers. */
7a6cf439 835/* This is defined differently for v9 in a cover file. */
201556f0 836#define SELECT_RTX_SECTION(MODE, X, ALIGN) \
1bb87f28
JW
837{ \
838 if (GET_MODE_BITSIZE (MODE) <= MAX_TEXT_ALIGN \
b1474bb7 839 && ! (flag_pic && (symbolic_operand ((X), (MODE)) || SUNOS4_SHARED_LIBRARIES))) \
1bb87f28
JW
840 text_section (); \
841 else \
842 data_section (); \
843}
844\f
845/* Standard register usage. */
846
847/* Number of actual hardware registers.
848 The hardware registers are assigned numbers for the compiler
849 from 0 to just below FIRST_PSEUDO_REGISTER.
850 All registers that the compiler knows about must be given numbers,
851 even those that are not normally considered general registers.
852
7a6cf439
DE
853 SPARC has 32 integer registers and 32 floating point registers.
854 64 bit SPARC has 32 additional fp regs, but the odd numbered ones are not
855 accessible. We still account for them to simplify register computations
856 (eg: in CLASS_MAX_NREGS). There are also 4 fp condition code registers, so
857 32+32+32+4 == 100.
563c12b0
RH
858 Register 100 is used as the integer condition code register.
859 Register 101 is used as the soft frame pointer register. */
1bb87f28 860
563c12b0 861#define FIRST_PSEUDO_REGISTER 102
6afca97d 862
4fb4e4b8 863#define SPARC_FIRST_FP_REG 32
6afca97d 864/* Additional V9 fp regs. */
4fb4e4b8
DE
865#define SPARC_FIRST_V9_FP_REG 64
866#define SPARC_LAST_V9_FP_REG 95
c4ce6853
DE
867/* V9 %fcc[0123]. V8 uses (figuratively) %fcc0. */
868#define SPARC_FIRST_V9_FCC_REG 96
869#define SPARC_LAST_V9_FCC_REG 99
870/* V8 fcc reg. */
871#define SPARC_FCC_REG 96
872/* Integer CC reg. We don't distinguish %icc from %xcc. */
873#define SPARC_ICC_REG 100
1bb87f28 874
4fb4e4b8
DE
875/* Nonzero if REGNO is an fp reg. */
876#define SPARC_FP_REG_P(REGNO) \
877((REGNO) >= SPARC_FIRST_FP_REG && (REGNO) <= SPARC_LAST_V9_FP_REG)
878
879/* Argument passing regs. */
880#define SPARC_OUTGOING_INT_ARG_FIRST 8
a9e95099 881#define SPARC_INCOMING_INT_ARG_FIRST (TARGET_FLAT ? 8 : 24)
4fb4e4b8
DE
882#define SPARC_FP_ARG_FIRST 32
883
1bb87f28
JW
884/* 1 for registers that have pervasive standard uses
885 and are not available for the register allocator.
4fb4e4b8 886
7a6cf439 887 On non-v9 systems:
34ad7aaf
JW
888 g1 is free to use as temporary.
889 g2-g4 are reserved for applications. Gcc normally uses them as
890 temporaries, but this can be disabled via the -mno-app-regs option.
7a6cf439 891 g5 through g7 are reserved for the operating system.
4fb4e4b8 892
7a6cf439 893 On v9 systems:
a0a301fc
DE
894 g1,g5 are free to use as temporaries, and are free to use between calls
895 if the call is to an external function via the PLT.
896 g4 is free to use as a temporary in the non-embedded case.
897 g4 is reserved in the embedded case.
4fb4e4b8 898 g2-g3 are reserved for applications. Gcc normally uses them as
bafb031b 899 temporaries, but this can be disabled via the -mno-app-regs option.
a0a301fc
DE
900 g6-g7 are reserved for the operating system (or application in
901 embedded case).
7a6cf439
DE
902 ??? Register 1 is used as a temporary by the 64 bit sethi pattern, so must
903 currently be a fixed register until this pattern is rewritten.
904 Register 1 is also used when restoring call-preserved registers in large
6afca97d
DE
905 stack frames.
906
907 Registers fixed in arch32 and not arch64 (or vice-versa) are marked in
908 CONDITIONAL_REGISTER_USAGE in order to properly handle -ffixed-.
909*/
7a6cf439 910
7a6cf439 911#define FIXED_REGISTERS \
e48addee 912 {1, 0, 2, 2, 2, 2, 1, 1, \
7a6cf439
DE
913 0, 0, 0, 0, 0, 0, 1, 0, \
914 0, 0, 0, 0, 0, 0, 0, 0, \
915 0, 0, 0, 0, 0, 0, 1, 1, \
916 \
917 0, 0, 0, 0, 0, 0, 0, 0, \
918 0, 0, 0, 0, 0, 0, 0, 0, \
919 0, 0, 0, 0, 0, 0, 0, 0, \
920 0, 0, 0, 0, 0, 0, 0, 0, \
921 \
922 0, 0, 0, 0, 0, 0, 0, 0, \
923 0, 0, 0, 0, 0, 0, 0, 0, \
924 0, 0, 0, 0, 0, 0, 0, 0, \
925 0, 0, 0, 0, 0, 0, 0, 0, \
926 \
563c12b0 927 0, 0, 0, 0, 0, 1}
1bb87f28
JW
928
929/* 1 for registers not available across function calls.
930 These must include the FIXED_REGISTERS and also any
931 registers that can be used without being saved.
932 The latter must include the registers where values are returned
933 and the register where structure-value addresses are passed.
934 Aside from that, you can include as many other registers as you like. */
7a6cf439 935
bafb031b
DE
936#define CALL_USED_REGISTERS \
937 {1, 1, 1, 1, 1, 1, 1, 1, \
938 1, 1, 1, 1, 1, 1, 1, 1, \
939 0, 0, 0, 0, 0, 0, 0, 0, \
940 0, 0, 0, 0, 0, 0, 1, 1, \
941 \
942 1, 1, 1, 1, 1, 1, 1, 1, \
943 1, 1, 1, 1, 1, 1, 1, 1, \
944 1, 1, 1, 1, 1, 1, 1, 1, \
945 1, 1, 1, 1, 1, 1, 1, 1, \
946 \
947 1, 1, 1, 1, 1, 1, 1, 1, \
948 1, 1, 1, 1, 1, 1, 1, 1, \
949 1, 1, 1, 1, 1, 1, 1, 1, \
950 1, 1, 1, 1, 1, 1, 1, 1, \
951 \
563c12b0 952 1, 1, 1, 1, 1, 1}
1bb87f28 953
c4ce6853
DE
954/* If !TARGET_FPU, then make the fp registers and fp cc regs fixed so that
955 they won't be allocated. */
26c5587d
JW
956
957#define CONDITIONAL_REGISTER_USAGE \
958do \
959 { \
5b43fed1 960 if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \
c7b2eb81
VM
961 { \
962 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
963 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
964 } \
e48addee
JJ
965 /* If the user has passed -f{fixed,call-{used,saved}}-g5 */ \
966 /* then honour it. */ \
967 if (TARGET_ARCH32 && fixed_regs[5]) \
968 fixed_regs[5] = 1; \
969 else if (TARGET_ARCH64 && fixed_regs[5] == 2) \
970 fixed_regs[5] = 0; \
6afca97d
DE
971 if (! TARGET_V9) \
972 { \
973 int regno; \
974 for (regno = SPARC_FIRST_V9_FP_REG; \
975 regno <= SPARC_LAST_V9_FP_REG; \
976 regno++) \
977 fixed_regs[regno] = 1; \
c4ce6853
DE
978 /* %fcc0 is used by v8 and v9. */ \
979 for (regno = SPARC_FIRST_V9_FCC_REG + 1; \
980 regno <= SPARC_LAST_V9_FCC_REG; \
981 regno++) \
982 fixed_regs[regno] = 1; \
6afca97d 983 } \
26c5587d
JW
984 if (! TARGET_FPU) \
985 { \
986 int regno; \
c4ce6853 987 for (regno = 32; regno < SPARC_LAST_V9_FCC_REG; regno++) \
26c5587d
JW
988 fixed_regs[regno] = 1; \
989 } \
e48addee
JJ
990 /* If the user has passed -f{fixed,call-{used,saved}}-g2 */ \
991 /* then honour it. Likewise with g3 and g4. */ \
992 if (fixed_regs[2] == 2) \
993 fixed_regs[2] = ! TARGET_APP_REGS; \
994 if (fixed_regs[3] == 2) \
995 fixed_regs[3] = ! TARGET_APP_REGS; \
996 if (TARGET_ARCH32 && fixed_regs[4] == 2) \
997 fixed_regs[4] = ! TARGET_APP_REGS; \
998 else if (TARGET_CM_EMBMEDANY) \
999 fixed_regs[4] = 1; \
1000 else if (fixed_regs[4] == 2) \
1001 fixed_regs[4] = 0; \
5c56efde
DE
1002 if (TARGET_FLAT) \
1003 { \
1004 /* Let the compiler believe the frame pointer is still \
1005 %fp, but output it as %i7. */ \
1006 fixed_regs[31] = 1; \
563c12b0 1007 reg_names[HARD_FRAME_POINTER_REGNUM] = "%i7"; \
7d167afd 1008 /* Disable leaf functions */ \
2e09e75a 1009 memset (sparc_leaf_regs, 0, FIRST_PSEUDO_REGISTER); \
5c56efde 1010 } \
26c5587d
JW
1011 } \
1012while (0)
1013
1bb87f28
JW
1014/* Return number of consecutive hard regs needed starting at reg REGNO
1015 to hold something of mode MODE.
1016 This is ordinarily the length in words of a value of mode MODE
1017 but can be less for certain modes in special long registers.
1018
1019 On SPARC, ordinary registers hold 32 bits worth;
1020 this means both integer and floating point registers.
7a6cf439
DE
1021 On v9, integer regs hold 64 bits worth; floating point regs hold
1022 32 bits worth (this includes the new fp regs as even the odd ones are
1023 included in the hard register count). */
1bb87f28 1024
7a6cf439 1025#define HARD_REGNO_NREGS(REGNO, MODE) \
6f64bf5f 1026 (TARGET_ARCH64 \
563c12b0
RH
1027 ? ((REGNO) < 32 || (REGNO) == FRAME_POINTER_REGNUM \
1028 ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD \
1029 : (GET_MODE_SIZE (MODE) + 3) / 4) \
7a6cf439 1030 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
1bb87f28 1031
ec8e621d
KG
1032/* Due to the ARCH64 descrepancy above we must override this next
1033 macro too. */
ddef6bc7
JJ
1034#define REGMODE_NATURAL_SIZE(MODE) \
1035 ((TARGET_ARCH64 && FLOAT_MODE_P (MODE)) ? 4 : UNITS_PER_WORD)
284d86e9 1036
1bb87f28 1037/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
923a8d06 1038 See sparc.c for how we initialize this. */
0b5826ac 1039extern const int *hard_regno_mode_classes;
7a6cf439 1040extern int sparc_mode_class[];
ddef6bc7
JJ
1041
1042/* ??? Because of the funny way we pass parameters we should allow certain
1043 ??? types of float/complex values to be in integer registers during
1044 ??? RTL generation. This only matters on arch32. */
1bb87f28 1045#define HARD_REGNO_MODE_OK(REGNO, MODE) \
7a6cf439 1046 ((hard_regno_mode_classes[REGNO] & sparc_mode_class[MODE]) != 0)
1bb87f28
JW
1047
1048/* Value is 1 if it is a good idea to tie two pseudo registers
1049 when one has mode MODE1 and one has mode MODE2.
1050 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
7a6cf439
DE
1051 for any hard reg, then this must be 0 for correct output.
1052
1053 For V9: SFmode can't be combined with other float modes, because they can't
1054 be allocated to the %d registers. Also, DFmode won't fit in odd %f
1055 registers, but SFmode will. */
1bb87f28 1056#define MODES_TIEABLE_P(MODE1, MODE2) \
7a6cf439
DE
1057 ((MODE1) == (MODE2) \
1058 || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
1059 && (! TARGET_V9 \
1060 || (GET_MODE_CLASS (MODE1) != MODE_FLOAT \
1061 || (MODE1 != SFmode && MODE2 != SFmode)))))
1bb87f28
JW
1062
1063/* Specify the registers used for certain standard purposes.
1064 The values of these macros are register numbers. */
1065
1066/* SPARC pc isn't overloaded on a register that the compiler knows about. */
1067/* #define PC_REGNUM */
1068
1069/* Register to use for pushing function arguments. */
1070#define STACK_POINTER_REGNUM 14
1071
563c12b0
RH
1072/* The stack bias (amount by which the hardware register is offset by). */
1073#define SPARC_STACK_BIAS ((TARGET_ARCH64 && TARGET_STACK_BIAS) ? 2047 : 0)
1074
4fb4e4b8 1075/* Actual top-of-stack address is 92/176 greater than the contents of the
7a6cf439
DE
1076 stack pointer register for !v9/v9. That is:
1077 - !v9: 64 bytes for the in and local registers, 4 bytes for structure return
4fb4e4b8
DE
1078 address, and 6*4 bytes for the 6 register parameters.
1079 - v9: 128 bytes for the in and local registers + 6*8 bytes for the integer
1080 parameter regs. */
563c12b0 1081#define STACK_POINTER_OFFSET (FIRST_PARM_OFFSET(0) + SPARC_STACK_BIAS)
1ccfa253 1082
1bb87f28 1083/* Base register for access to local variables of the function. */
563c12b0
RH
1084#define HARD_FRAME_POINTER_REGNUM 30
1085
1086/* The soft frame pointer does not have the stack bias applied. */
1087#define FRAME_POINTER_REGNUM 101
1088
1089/* Given the stack bias, the stack pointer isn't actually aligned. */
1090#define INIT_EXPANDERS \
1091 do { \
1092 if (cfun && cfun->emit->regno_pointer_align && SPARC_STACK_BIAS) \
1093 { \
1094 REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = BITS_PER_UNIT; \
1095 REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = BITS_PER_UNIT; \
1096 } \
1097 } while (0)
1bb87f28
JW
1098
1099/* Value should be nonzero if functions must have frame pointers.
1100 Zero means the frame pointer need not be set up (and parms
1101 may be accessed via the stack pointer) in functions that seem suitable.
1102 This is computed in `reload', in reload1.c.
a061b9fa 1103 Used in flow.c, global.c, and reload1.c.
1bb87f28 1104
a061b9fa
DE
1105 Being a non-leaf function does not mean a frame pointer is needed in the
1106 flat window model. However, the debugger won't be able to backtrace through
1107 us with out it. */
563c12b0
RH
1108#define FRAME_POINTER_REQUIRED \
1109 (TARGET_FLAT \
1110 ? (current_function_calls_alloca \
1111 || current_function_varargs \
1112 || !leaf_function_p ()) \
5c56efde 1113 : ! (leaf_function_p () && only_leaf_regs_used ()))
1bb87f28 1114
1bb87f28 1115/* Base register for access to arguments of the function. */
5c56efde 1116#define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
1bb87f28 1117
6098b63e 1118/* Register in which static-chain is passed to a function. This must
c8392688 1119 not be a register used by the prologue. */
6f64bf5f 1120#define STATIC_CHAIN_REGNUM (TARGET_ARCH64 ? 5 : 2)
1bb87f28
JW
1121
1122/* Register which holds offset table for position-independent
1123 data references. */
1124
5b43fed1 1125#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 23 : INVALID_REGNUM)
1bb87f28 1126
82d6b402
RH
1127/* Pick a default value we can notice from override_options:
1128 !v9: Default is on.
1129 v9: Default is off. */
1130
1131#define DEFAULT_PCC_STRUCT_RETURN -1
1132
d9ca49d5 1133/* Sparc ABI says that quad-precision floats and all structures are returned
7a6cf439 1134 in memory.
4fb4e4b8 1135 For v9: unions <= 32 bytes in size are returned in int regs,
82d6b402 1136 structures up to 32 bytes are returned in int and fp regs. */
4fb4e4b8 1137
686667bf 1138#define RETURN_IN_MEMORY(TYPE) \
4fb4e4b8
DE
1139(TARGET_ARCH32 \
1140 ? (TYPE_MODE (TYPE) == BLKmode \
1141 || TYPE_MODE (TYPE) == TFmode \
1142 || TYPE_MODE (TYPE) == TCmode) \
82d6b402 1143 : (TYPE_MODE (TYPE) == BLKmode \
f07d22aa 1144 && (unsigned HOST_WIDE_INT) int_size_in_bytes (TYPE) > 32))
d9ca49d5 1145
1bb87f28
JW
1146/* Functions which return large structures get the address
1147 to place the wanted value at offset 64 from the frame.
7a6cf439
DE
1148 Must reserve 64 bytes for the in and local registers.
1149 v9: Functions which return large structures get the address to place the
1150 wanted value from an invisible first argument. */
1bb87f28
JW
1151/* Used only in other #defines in this file. */
1152#define STRUCT_VALUE_OFFSET 64
1153
1154#define STRUCT_VALUE \
6f64bf5f 1155 (TARGET_ARCH64 \
7a6cf439 1156 ? 0 \
c5c76735
JL
1157 : gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, \
1158 STRUCT_VALUE_OFFSET)))
1159
1bb87f28 1160#define STRUCT_VALUE_INCOMING \
c5c76735
JL
1161 (TARGET_ARCH64 \
1162 ? 0 \
1163 : gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx, \
1164 STRUCT_VALUE_OFFSET)))
1bb87f28
JW
1165\f
1166/* Define the classes of registers for register constraints in the
1167 machine description. Also define ranges of constants.
1168
1169 One of the classes must always be named ALL_REGS and include all hard regs.
1170 If there is more than one class, another class must be named NO_REGS
1171 and contain no registers.
1172
1173 The name GENERAL_REGS must be the name of a class (or an alias for
1174 another name such as ALL_REGS). This is the class of registers
1175 that is allowed by "g" or "r" in a register constraint.
1176 Also, registers outside this class are allocated only when
1177 instructions express preferences for them.
1178
1179 The classes must be numbered in nondecreasing order; that is,
1180 a larger-numbered class must never be contained completely
1181 in a smaller-numbered class.
1182
1183 For any two classes, it is very desirable that there be another
1184 class that represents their union. */
1185
4fb4e4b8
DE
1186/* The SPARC has various kinds of registers: general, floating point,
1187 and condition codes [well, it has others as well, but none that we
1188 care directly about].
24b63396
JW
1189
1190 For v9 we must distinguish between the upper and lower floating point
1191 registers because the upper ones can't hold SFmode values.
1192 HARD_REGNO_MODE_OK won't help here because reload assumes that register(s)
1193 satisfying a group need for a class will also satisfy a single need for
1194 that class. EXTRA_FP_REGS is a bit of a misnomer as it covers all 64 fp
1195 regs.
1196
1197 It is important that one class contains all the general and all the standard
1198 fp regs. Otherwise find_reg() won't properly allocate int regs for moves,
1199 because reg_class_record() will bias the selection in favor of fp regs,
1200 because reg_class_subunion[GENERAL_REGS][FP_REGS] will yield FP_REGS,
1201 because FP_REGS > GENERAL_REGS.
1202
1203 It is also important that one class contain all the general and all the
1204 fp regs. Otherwise when spilling a DFmode reg, it may be from EXTRA_FP_REGS
1205 but find_reloads() may use class GENERAL_OR_FP_REGS. This will cause
1206 allocate_reload_reg() to bypass it causing an abort because the compiler
1207 thinks it doesn't have a spill reg when in fact it does.
1208
7a6cf439
DE
1209 v9 also has 4 floating point condition code registers. Since we don't
1210 have a class that is the union of FPCC_REGS with either of the others,
1211 it is important that it appear first. Otherwise the compiler will die
1212 trying to compile _fixunsdfsi because fix_truncdfsi2 won't match its
c4ce6853
DE
1213 constraints.
1214
1215 It is important that SPARC_ICC_REG have class NO_REGS. Otherwise combine
1216 may try to use it to hold an SImode value. See register_operand.
956d6950 1217 ??? Should %fcc[0123] be handled similarly?
c4ce6853 1218*/
7a6cf439 1219
284d86e9
JC
1220enum reg_class { NO_REGS, FPCC_REGS, I64_REGS, GENERAL_REGS, FP_REGS,
1221 EXTRA_FP_REGS, GENERAL_OR_FP_REGS, GENERAL_OR_EXTRA_FP_REGS,
7a6cf439 1222 ALL_REGS, LIM_REG_CLASSES };
1bb87f28
JW
1223
1224#define N_REG_CLASSES (int) LIM_REG_CLASSES
1225
80ffc95e 1226/* Give names of register classes as strings for dump file. */
1bb87f28
JW
1227
1228#define REG_CLASS_NAMES \
284d86e9
JC
1229 { "NO_REGS", "FPCC_REGS", "I64_REGS", "GENERAL_REGS", "FP_REGS", \
1230 "EXTRA_FP_REGS", "GENERAL_OR_FP_REGS", "GENERAL_OR_EXTRA_FP_REGS", \
1231 "ALL_REGS" }
1bb87f28
JW
1232
1233/* Define which registers fit in which classes.
1234 This is an initializer for a vector of HARD_REG_SET
1235 of length N_REG_CLASSES. */
1236
563c12b0
RH
1237#define REG_CLASS_CONTENTS \
1238 {{0, 0, 0, 0}, /* NO_REGS */ \
1239 {0, 0, 0, 0xf}, /* FPCC_REGS */ \
1240 {0xffff, 0, 0, 0}, /* I64_REGS */ \
1241 {-1, 0, 0, 0x20}, /* GENERAL_REGS */ \
1242 {0, -1, 0, 0}, /* FP_REGS */ \
1243 {0, -1, -1, 0}, /* EXTRA_FP_REGS */ \
1244 {-1, -1, 0, 0x20}, /* GENERAL_OR_FP_REGS */ \
1245 {-1, -1, -1, 0x20}, /* GENERAL_OR_EXTRA_FP_REGS */ \
1246 {-1, -1, -1, 0x3f}} /* ALL_REGS */
1bb87f28
JW
1247
1248/* The same information, inverted:
1249 Return the class number of the smallest class containing
1250 reg number REGNO. This could be a conditional expression
1251 or could index an array. */
1252
f540a7d3 1253extern enum reg_class sparc_regno_reg_class[FIRST_PSEUDO_REGISTER];
c4ce6853
DE
1254
1255#define REGNO_REG_CLASS(REGNO) sparc_regno_reg_class[(REGNO)]
1bb87f28 1256
7a6cf439 1257/* This is the order in which to allocate registers normally.
51f0e748
JW
1258
1259 We put %f0/%f1 last among the float registers, so as to make it more
6a4bb1fa 1260 likely that a pseudo-register which dies in the float return register
51f0e748 1261 will get allocated to the float return register, thus saving a move
4fb4e4b8 1262 instruction at the end of the function. */
6afca97d 1263
7a6cf439 1264#define REG_ALLOC_ORDER \
6afca97d 1265{ 8, 9, 10, 11, 12, 13, 2, 3, \
7a6cf439
DE
1266 15, 16, 17, 18, 19, 20, 21, 22, \
1267 23, 24, 25, 26, 27, 28, 29, 31, \
1268 34, 35, 36, 37, 38, 39, /* %f2-%f7 */ \
1269 40, 41, 42, 43, 44, 45, 46, 47, /* %f8-%f15 */ \
7a6cf439
DE
1270 48, 49, 50, 51, 52, 53, 54, 55, /* %f16-%f23 */ \
1271 56, 57, 58, 59, 60, 61, 62, 63, /* %f24-%f31 */ \
1272 64, 65, 66, 67, 68, 69, 70, 71, /* %f32-%f39 */ \
1273 72, 73, 74, 75, 76, 77, 78, 79, /* %f40-%f47 */ \
4fb4e4b8
DE
1274 80, 81, 82, 83, 84, 85, 86, 87, /* %f48-%f55 */ \
1275 88, 89, 90, 91, 92, 93, 94, 95, /* %f56-%f63 */ \
7a6cf439 1276 32, 33, /* %f0,%f1 */ \
c4ce6853 1277 96, 97, 98, 99, 100, /* %fcc0-3, %icc */ \
563c12b0 1278 1, 4, 5, 6, 7, 0, 14, 30, 101}
1bb87f28
JW
1279
1280/* This is the order in which to allocate registers for
e48addee 1281 leaf functions. If all registers can fit in the "gi" registers,
4fb4e4b8 1282 then we have the possibility of having a leaf function. */
6afca97d 1283
7a6cf439 1284#define REG_LEAF_ALLOC_ORDER \
6afca97d 1285{ 2, 3, 24, 25, 26, 27, 28, 29, \
e48addee 1286 4, 5, 6, 7, 1, \
7a6cf439
DE
1287 15, 8, 9, 10, 11, 12, 13, \
1288 16, 17, 18, 19, 20, 21, 22, 23, \
1289 34, 35, 36, 37, 38, 39, \
1290 40, 41, 42, 43, 44, 45, 46, 47, \
7a6cf439
DE
1291 48, 49, 50, 51, 52, 53, 54, 55, \
1292 56, 57, 58, 59, 60, 61, 62, 63, \
1293 64, 65, 66, 67, 68, 69, 70, 71, \
1294 72, 73, 74, 75, 76, 77, 78, 79, \
4fb4e4b8
DE
1295 80, 81, 82, 83, 84, 85, 86, 87, \
1296 88, 89, 90, 91, 92, 93, 94, 95, \
7a6cf439 1297 32, 33, \
c4ce6853 1298 96, 97, 98, 99, 100, \
563c12b0 1299 0, 14, 30, 31, 101}
e48addee 1300
1bb87f28
JW
1301#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()
1302
7d167afd
JJ
1303extern char sparc_leaf_regs[];
1304#define LEAF_REGISTERS sparc_leaf_regs
1bb87f28 1305
8b60264b 1306extern const char leaf_reg_remap[];
1bb87f28 1307#define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO])
1bb87f28 1308
1bb87f28
JW
1309/* The class value for index registers, and the one for base regs. */
1310#define INDEX_REG_CLASS GENERAL_REGS
1311#define BASE_REG_CLASS GENERAL_REGS
1312
24b63396 1313/* Local macro to handle the two v9 classes of FP regs. */
24b63396 1314#define FP_REG_CLASS_P(CLASS) ((CLASS) == FP_REGS || (CLASS) == EXTRA_FP_REGS)
24b63396 1315
6afca97d
DE
1316/* Get reg_class from a letter such as appears in the machine description.
1317 In the not-v9 case, coerce v9's 'e' class to 'f', so we can use 'e' in the
bfd6bc60 1318 .md file for v8 and v9.
284d86e9
JC
1319 'd' and 'b' are used for single and double precision VIS operations,
1320 if TARGET_VIS.
80ffc95e 1321 'h' is used for V8+ 64 bit global and out registers. */
bfd6bc60
JC
1322
1323#define REG_CLASS_FROM_LETTER(C) \
1324(TARGET_V9 \
1325 ? ((C) == 'f' ? FP_REGS \
1326 : (C) == 'e' ? EXTRA_FP_REGS \
1327 : (C) == 'c' ? FPCC_REGS \
284d86e9
JC
1328 : ((C) == 'd' && TARGET_VIS) ? FP_REGS\
1329 : ((C) == 'b' && TARGET_VIS) ? EXTRA_FP_REGS\
1330 : ((C) == 'h' && TARGET_V8PLUS) ? I64_REGS\
bfd6bc60
JC
1331 : NO_REGS) \
1332 : ((C) == 'f' ? FP_REGS \
1333 : (C) == 'e' ? FP_REGS \
1334 : (C) == 'c' ? FPCC_REGS \
6afca97d 1335 : NO_REGS))
1bb87f28
JW
1336
1337/* The letters I, J, K, L and M in a register constraint string
1338 can be used to stand for particular ranges of immediate operands.
1339 This macro defines what the ranges are.
1340 C is the letter, and VALUE is a constant value.
1341 Return 1 if VALUE is in the range specified by C.
1342
18c5947f 1343 `I' is used for the range of constants an insn can actually contain.
1bb87f28 1344 `J' is used for the range which is just zero (since that is R0).
18c5947f
DE
1345 `K' is used for constants which can be loaded with a single sethi insn.
1346 `L' is used for the range of constants supported by the movcc insns.
7d6040e8
AO
1347 `M' is used for the range of constants supported by the movrcc insns.
1348 `N' is like K, but for constants wider than 32 bits. */
1bb87f28 1349
1ccfa253
DE
1350#define SPARC_SIMM10_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x200 < 0x400)
1351#define SPARC_SIMM11_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x400 < 0x800)
1352#define SPARC_SIMM13_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x1000 < 0x2000)
18c5947f
DE
1353/* 10 and 11 bit immediates are only used for a few specific insns.
1354 SMALL_INT is used throughout the port so we continue to use it. */
1355#define SMALL_INT(X) (SPARC_SIMM13_P (INTVAL (X)))
284d86e9 1356/* 13 bit immediate, considering only the low 32 bits */
9e0625a3
AO
1357#define SMALL_INT32(X) (SPARC_SIMM13_P (trunc_int_for_mode \
1358 (INTVAL (X), SImode)))
1ccfa253 1359#define SPARC_SETHI_P(X) \
7d6040e8
AO
1360 (((unsigned HOST_WIDE_INT) (X) \
1361 & ((unsigned HOST_WIDE_INT) 0x3ff - GET_MODE_MASK (SImode) - 1)) == 0)
1362#define SPARC_SETHI32_P(X) \
1363 (SPARC_SETHI_P ((unsigned HOST_WIDE_INT) (X) & GET_MODE_MASK (SImode)))
1bb87f28
JW
1364
1365#define CONST_OK_FOR_LETTER_P(VALUE, C) \
18c5947f 1366 ((C) == 'I' ? SPARC_SIMM13_P (VALUE) \
1bb87f28 1367 : (C) == 'J' ? (VALUE) == 0 \
7d6040e8 1368 : (C) == 'K' ? SPARC_SETHI32_P (VALUE) \
18c5947f
DE
1369 : (C) == 'L' ? SPARC_SIMM11_P (VALUE) \
1370 : (C) == 'M' ? SPARC_SIMM10_P (VALUE) \
7d6040e8 1371 : (C) == 'N' ? SPARC_SETHI_P (VALUE) \
1bb87f28
JW
1372 : 0)
1373
1374/* Similar, but for floating constants, and defining letters G and H.
1375 Here VALUE is the CONST_DOUBLE rtx itself. */
1376
1377#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
7ce86678
RH
1378 ((C) == 'G' ? fp_zero_operand (VALUE, GET_MODE (VALUE)) \
1379 : (C) == 'H' ? arith_double_operand (VALUE, DImode) \
1bb87f28
JW
1380 : 0)
1381
1382/* Given an rtx X being reloaded into a reg required to be
1383 in class CLASS, return the class of reg to actually use.
1384 In general this is just CLASS; but on some machines
1385 in some cases it is preferable to use a more restrictive class. */
3e7cd49f
JW
1386/* - We can't load constants into FP registers.
1387 - We can't load FP constants into integer registers when soft-float,
1388 because there is no soft-float pattern with a r/F constraint.
1573b933
JJ
1389 - We can't load FP constants into integer registers for TFmode unless
1390 it is 0.0L, because there is no movtf pattern with a r/F constraint.
8947065c
RH
1391 - Try and reload integer constants (symbolic or otherwise) back into
1392 registers directly, rather than having them dumped to memory. */
1393
2b9a9aea
JW
1394#define PREFERRED_RELOAD_CLASS(X,CLASS) \
1395 (CONSTANT_P (X) \
8947065c 1396 ? ((FP_REG_CLASS_P (CLASS) \
2b9a9aea 1397 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
1573b933
JJ
1398 && ! TARGET_FPU) \
1399 || (GET_MODE (X) == TFmode \
1400 && ! fp_zero_operand (X, TFmode))) \
8947065c
RH
1401 ? NO_REGS \
1402 : (!FP_REG_CLASS_P (CLASS) \
1403 && GET_MODE_CLASS (GET_MODE (X)) == MODE_INT) \
1404 ? GENERAL_REGS \
1405 : (CLASS)) \
1406 : (CLASS))
1bb87f28
JW
1407
1408/* Return the register class of a scratch register needed to load IN into
1409 a register of class CLASS in MODE.
1410
e0d80184 1411 We need a temporary when loading/storing a HImode/QImode value
ae51bd97
JW
1412 between memory and the FPU registers. This can happen when combine puts
1413 a paradoxical subreg in a float/fix conversion insn. */
1414
1415#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, IN) \
e0d80184
DM
1416 ((FP_REG_CLASS_P (CLASS) \
1417 && ((MODE) == HImode || (MODE) == QImode) \
24b63396 1418 && (GET_CODE (IN) == MEM \
e0d80184
DM
1419 || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
1420 && true_regnum (IN) == -1))) \
1421 ? GENERAL_REGS \
1422 : (((TARGET_CM_MEDANY \
1423 && symbolic_operand ((IN), (MODE))) \
1424 || (TARGET_CM_EMBMEDANY \
1425 && text_segment_operand ((IN), (MODE)))) \
1426 && !flag_pic) \
1427 ? GENERAL_REGS \
1428 : NO_REGS)
ae51bd97
JW
1429
1430#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, IN) \
e0d80184
DM
1431 ((FP_REG_CLASS_P (CLASS) \
1432 && ((MODE) == HImode || (MODE) == QImode) \
1433 && (GET_CODE (IN) == MEM \
1434 || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
1435 && true_regnum (IN) == -1))) \
1436 ? GENERAL_REGS \
1437 : (((TARGET_CM_MEDANY \
1438 && symbolic_operand ((IN), (MODE))) \
1439 || (TARGET_CM_EMBMEDANY \
1440 && text_segment_operand ((IN), (MODE)))) \
1441 && !flag_pic) \
1442 ? GENERAL_REGS \
1443 : NO_REGS)
1bb87f28 1444
b924cef0
JW
1445/* On SPARC it is not possible to directly move data between
1446 GENERAL_REGS and FP_REGS. */
24b63396
JW
1447#define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
1448 (FP_REG_CLASS_P (CLASS1) != FP_REG_CLASS_P (CLASS2))
b924cef0 1449
55be783d
JW
1450/* Return the stack location to use for secondary memory needed reloads.
1451 We want to use the reserved location just below the frame pointer.
1452 However, we must ensure that there is a frame, so use assign_stack_local
1453 if the frame size is zero. */
fe1f7f24 1454#define SECONDARY_MEMORY_NEEDED_RTX(MODE) \
55be783d 1455 (get_frame_size () == 0 \
fb3eb6f6 1456 ? assign_stack_local (MODE, GET_MODE_SIZE (MODE), 0) \
c5c76735
JL
1457 : gen_rtx_MEM (MODE, plus_constant (frame_pointer_rtx, \
1458 STARTING_FRAME_OFFSET)))
fe1f7f24 1459
9ec36da5 1460/* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on v9
7a6cf439
DE
1461 because the movsi and movsf patterns don't handle r/f moves.
1462 For v8 we copy the default definition. */
1463#define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
6f64bf5f 1464 (TARGET_ARCH64 \
fb3eb6f6
JW
1465 ? (GET_MODE_BITSIZE (MODE) < 32 \
1466 ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \
7a6cf439 1467 : MODE) \
fb3eb6f6
JW
1468 : (GET_MODE_BITSIZE (MODE) < BITS_PER_WORD \
1469 ? mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (MODE), 0) \
7a6cf439
DE
1470 : MODE))
1471
1bb87f28
JW
1472/* Return the maximum number of consecutive registers
1473 needed to represent mode MODE in a register of class CLASS. */
1474/* On SPARC, this is the size of MODE in words. */
1475#define CLASS_MAX_NREGS(CLASS, MODE) \
24b63396 1476 (FP_REG_CLASS_P (CLASS) ? (GET_MODE_SIZE (MODE) + 3) / 4 \
7a6cf439 1477 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1bb87f28
JW
1478\f
1479/* Stack layout; function entry, exit and calling. */
1480
1481/* Define the number of register that can hold parameters.
4fb4e4b8 1482 This macro is only used in other macro definitions below and in sparc.c.
7a6cf439
DE
1483 MODE is the mode of the argument.
1484 !v9: All args are passed in %o0-%o5.
4fb4e4b8
DE
1485 v9: %o0-%o5 and %f0-%f31 are cumulatively used to pass values.
1486 See the description in sparc.c. */
7a6cf439 1487#define NPARM_REGS(MODE) \
4fb4e4b8
DE
1488(TARGET_ARCH64 \
1489 ? (GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 : 6) \
1490 : 6)
1bb87f28
JW
1491
1492/* Define this if pushing a word on the stack
1493 makes the stack pointer a smaller address. */
1494#define STACK_GROWS_DOWNWARD
1495
1496/* Define this if the nominal address of the stack frame
1497 is at the high-address end of the local variables;
1498 that is, each additional local variable allocated
1499 goes at a more negative offset in the frame. */
1500#define FRAME_GROWS_DOWNWARD
1501
1502/* Offset within stack frame to start allocating local variables at.
1503 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1504 first local allocated. Otherwise, it is the offset to the BEGINNING
1505 of the first local allocated. */
7238ce3a
JW
1506/* This allows space for one TFmode floating point value. */
1507#define STARTING_FRAME_OFFSET \
563c12b0 1508 (TARGET_ARCH64 ? -16 \
7a6cf439 1509 : (-SPARC_STACK_ALIGN (LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)))
1bb87f28
JW
1510
1511/* If we generate an insn to push BYTES bytes,
1512 this says how many the stack pointer really advances by.
1513 On SPARC, don't define this because there are no push insns. */
1514/* #define PUSH_ROUNDING(BYTES) */
1515
1516/* Offset of first parameter from the argument pointer register value.
7a6cf439
DE
1517 !v9: This is 64 for the ins and locals, plus 4 for the struct-return reg
1518 even if this function isn't going to use it.
4fb4e4b8 1519 v9: This is 128 for the ins and locals. */
7a6cf439 1520#define FIRST_PARM_OFFSET(FNDECL) \
563c12b0 1521 (TARGET_ARCH64 ? 16 * UNITS_PER_WORD : STRUCT_VALUE_OFFSET + UNITS_PER_WORD)
1bb87f28 1522
2c849145
JM
1523/* Offset from the argument pointer register value to the CFA.
1524 This is different from FIRST_PARM_OFFSET because the register window
1525 comes between the CFA and the arguments. */
c2c9f6c9 1526#define ARG_POINTER_CFA_OFFSET(FNDECL) 0
71038426 1527
1bb87f28 1528/* When a parameter is passed in a register, stack space is still
82d6b402
RH
1529 allocated for it.
1530 !v9: All 6 possible integer registers have backing store allocated.
80ffc95e 1531 v9: Only space for the arguments passed is allocated. */
82d6b402
RH
1532/* ??? Ideally, we'd use zero here (as the minimum), but zero has special
1533 meaning to the backend. Further, we need to be able to detect if a
1534 varargs/unprototyped function is called, as they may want to spill more
1535 registers than we've provided space. Ugly, ugly. So for now we retain
1536 all 6 slots even for v9. */
4fb4e4b8 1537#define REG_PARM_STACK_SPACE(DECL) (6 * UNITS_PER_WORD)
1bb87f28 1538
563c12b0
RH
1539/* Definitions for register elimination. */
1540/* ??? In TARGET_FLAT mode we needn't have a hard frame pointer. */
1541
1542#define ELIMINABLE_REGS \
e387e99b
JJ
1543 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1544 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM} }
563c12b0 1545
91d4b3fd
RK
1546/* The way this is structured, we can't eliminate SFP in favor of SP
1547 if the frame pointer is required: we want to use the SFP->HFP elimination
1548 in that case. But the test in update_eliminables doesn't know we are
1549 assuming below that we only do the former elimination. */
1550#define CAN_ELIMINATE(FROM, TO) \
1551 ((TO) == HARD_FRAME_POINTER_REGNUM || !FRAME_POINTER_REQUIRED)
563c12b0
RH
1552
1553#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
e387e99b
JJ
1554 do { \
1555 (OFFSET) = 0; \
1556 if ((TO) == STACK_POINTER_REGNUM) \
1557 { \
1558 /* Note, we always pretend that this is a leaf function \
1559 because if it's not, there's no point in trying to \
1560 eliminate the frame pointer. If it is a leaf \
1561 function, we guessed right! */ \
1562 if (TARGET_FLAT) \
1563 (OFFSET) = \
1564 sparc_flat_compute_frame_size (get_frame_size ()); \
1565 else \
1566 (OFFSET) = compute_frame_size (get_frame_size (), 1); \
1567 } \
1568 (OFFSET) += SPARC_STACK_BIAS; \
1569 } while (0)
563c12b0 1570
1bb87f28 1571/* Keep the stack pointer constant throughout the function.
b4ac57ab 1572 This is both an optimization and a necessity: longjmp
1bb87f28
JW
1573 doesn't behave itself when the stack pointer moves within
1574 the function! */
f73ad30e 1575#define ACCUMULATE_OUTGOING_ARGS 1
1bb87f28
JW
1576
1577/* Value is the number of bytes of arguments automatically
1578 popped when returning from a subroutine call.
8b109b37 1579 FUNDECL is the declaration node of the function (as a tree),
1bb87f28
JW
1580 FUNTYPE is the data type of the function (as a tree),
1581 or for a library call it is an identifier node for the subroutine name.
1582 SIZE is the number of bytes of arguments passed on the stack. */
1583
8b109b37 1584#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1bb87f28 1585
5b485d2c
JW
1586/* Some subroutine macros specific to this machine.
1587 When !TARGET_FPU, put float return values in the general registers,
1588 since we don't have any fp registers. */
82d6b402
RH
1589#define BASE_RETURN_VALUE_REG(MODE) \
1590 (TARGET_ARCH64 \
1591 ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 : 8) \
7a6cf439 1592 : (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 : 8))
82d6b402
RH
1593
1594#define BASE_OUTGOING_VALUE_REG(MODE) \
1595 (TARGET_ARCH64 \
1596 ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 \
1597 : TARGET_FLAT ? 8 : 24) \
7a6cf439 1598 : (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 \
bafb031b 1599 : (TARGET_FLAT ? 8 : 24)))
82d6b402
RH
1600
1601#define BASE_PASSING_ARG_REG(MODE) \
1602 (TARGET_ARCH64 \
1603 ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 : 8) \
6f64bf5f 1604 : 8)
82d6b402 1605
80ffc95e 1606/* ??? FIXME -- seems wrong for v9 structure passing... */
82d6b402
RH
1607#define BASE_INCOMING_ARG_REG(MODE) \
1608 (TARGET_ARCH64 \
1609 ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 \
1610 : TARGET_FLAT ? 8 : 24) \
bafb031b 1611 : (TARGET_FLAT ? 8 : 24))
1bb87f28 1612
92ea370b
TW
1613/* Define this macro if the target machine has "register windows". This
1614 C expression returns the register number as seen by the called function
1615 corresponding to register number OUT as seen by the calling function.
1616 Return OUT if register number OUT is not an outbound register. */
1617
1618#define INCOMING_REGNO(OUT) \
bafb031b 1619 ((TARGET_FLAT || (OUT) < 8 || (OUT) > 15) ? (OUT) : (OUT) + 16)
92ea370b
TW
1620
1621/* Define this macro if the target machine has "register windows". This
1622 C expression returns the register number as seen by the calling function
1623 corresponding to register number IN as seen by the called function.
1624 Return IN if register number IN is not an inbound register. */
1625
1626#define OUTGOING_REGNO(IN) \
bafb031b 1627 ((TARGET_FLAT || (IN) < 24 || (IN) > 31) ? (IN) : (IN) - 16)
92ea370b 1628
2a3e384f
RH
1629/* Define this macro if the target machine has register windows. This
1630 C expression returns true if the register is call-saved but is in the
1631 register window. */
1632
1633#define LOCAL_REGNO(REGNO) \
1634 (TARGET_FLAT ? 0 : (REGNO) >= 16 && (REGNO) <= 31)
1635
1bb87f28
JW
1636/* Define how to find the value returned by a function.
1637 VALTYPE is the data type of the value (as a tree).
1638 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1639 otherwise, FUNC is 0. */
1640
1641/* On SPARC the value is found in the first "output" register. */
1642
82d6b402
RH
1643#define FUNCTION_VALUE(VALTYPE, FUNC) \
1644 function_value ((VALTYPE), TYPE_MODE (VALTYPE), 1)
1bb87f28
JW
1645
1646/* But the called function leaves it in the first "input" register. */
1647
82d6b402
RH
1648#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
1649 function_value ((VALTYPE), TYPE_MODE (VALTYPE), 0)
1bb87f28
JW
1650
1651/* Define how to find the value returned by a library function
1652 assuming the value has mode MODE. */
1653
82d6b402
RH
1654#define LIBCALL_VALUE(MODE) \
1655 function_value (NULL_TREE, (MODE), 1)
1bb87f28
JW
1656
1657/* 1 if N is a possible register number for a function value
1658 as seen by the caller.
1659 On SPARC, the first "output" reg is used for integer values,
1660 and the first floating point register is used for floating point values. */
1661
1662#define FUNCTION_VALUE_REGNO_P(N) ((N) == 8 || (N) == 32)
1663
34aaacec
JW
1664/* Define the size of space to allocate for the return value of an
1665 untyped_call. */
1666
1667#define APPLY_RESULT_SIZE 16
1668
1bb87f28 1669/* 1 if N is a possible register number for function argument passing.
4fb4e4b8 1670 On SPARC, these are the "output" registers. v9 also uses %f0-%f31. */
1bb87f28 1671
7a6cf439 1672#define FUNCTION_ARG_REGNO_P(N) \
4fb4e4b8
DE
1673(TARGET_ARCH64 \
1674 ? (((N) >= 8 && (N) <= 13) || ((N) >= 32 && (N) <= 63)) \
1675 : ((N) >= 8 && (N) <= 13))
1bb87f28
JW
1676\f
1677/* Define a data type for recording info about an argument list
1678 during the scan of that argument list. This data type should
1679 hold all necessary information about the function itself
1680 and about the args processed so far, enough to enable macros
1681 such as FUNCTION_ARG to determine where the next arg should go.
1682
7a6cf439 1683 On SPARC (!v9), this is a single integer, which is a number of words
1bb87f28
JW
1684 of arguments scanned so far (including the invisible argument,
1685 if any, which holds the structure-value-address).
7a6cf439
DE
1686 Thus 7 or more means all following args should go on the stack.
1687
4fb4e4b8 1688 For v9, we also need to know whether a prototype is present. */
7a6cf439 1689
7a6cf439 1690struct sparc_args {
4fb4e4b8
DE
1691 int words; /* number of words passed so far */
1692 int prototype_p; /* non-zero if a prototype is present */
1693 int libcall_p; /* non-zero if a library call */
7a6cf439
DE
1694};
1695#define CUMULATIVE_ARGS struct sparc_args
1696
1bb87f28
JW
1697/* Initialize a variable CUM of type CUMULATIVE_ARGS
1698 for a call to a function whose data type is FNTYPE.
4fb4e4b8 1699 For a library call, FNTYPE is 0. */
1bb87f28 1700
4fb4e4b8
DE
1701#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
1702init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (INDIRECT));
1bb87f28
JW
1703
1704/* Update the data in CUM to advance over an argument
1705 of mode MODE and data type TYPE.
4fb4e4b8 1706 TYPE is null for libcalls where that information may not be available. */
7a6cf439 1707
4fb4e4b8
DE
1708#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1709function_arg_advance (& (CUM), (MODE), (TYPE), (NAMED))
1bb87f28 1710
7b0c7e62
JJ
1711/* Nonzero if we do not know how to pass TYPE solely in registers. */
1712
1713#define MUST_PASS_IN_STACK(MODE,TYPE) \
1714 ((TYPE) != 0 \
1715 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
1716 || TREE_ADDRESSABLE (TYPE)))
1717
1bb87f28
JW
1718/* Determine where to put an argument to a function.
1719 Value is zero to push the argument on the stack,
1720 or a hard register in which to store the argument.
1721
1722 MODE is the argument's machine mode.
1723 TYPE is the data type of the argument (as a tree).
1724 This is null for libcalls where that information may
1725 not be available.
1726 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1727 the preceding args and about the function being called.
1728 NAMED is nonzero if this argument is a named parameter
1729 (otherwise it is an extra parameter matching an ellipsis). */
1730
4fb4e4b8
DE
1731#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1732function_arg (& (CUM), (MODE), (TYPE), (NAMED), 0)
1bb87f28
JW
1733
1734/* Define where a function finds its arguments.
1735 This is different from FUNCTION_ARG because of register windows. */
1736
4fb4e4b8
DE
1737#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
1738function_arg (& (CUM), (MODE), (TYPE), (NAMED), 1)
1bb87f28
JW
1739
1740/* For an arg passed partly in registers and partly in memory,
1741 this is the number of registers used.
4fb4e4b8
DE
1742 For args passed entirely in registers or entirely in memory, zero. */
1743
4fb4e4b8
DE
1744#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1745function_arg_partial_nregs (& (CUM), (MODE), (TYPE), (NAMED))
1746
1747/* A C expression that indicates when an argument must be passed by reference.
1748 If nonzero for an argument, a copy of that argument is made in memory and a
1749 pointer to the argument is passed instead of the argument itself.
1750 The pointer is passed in whatever way is appropriate for passing a pointer
1751 to that type. */
1752
4fb4e4b8
DE
1753#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
1754function_arg_pass_by_reference (& (CUM), (MODE), (TYPE), (NAMED))
1755
1756/* If defined, a C expression which determines whether, and in which direction,
1757 to pad out an argument with extra space. The value should be of type
1758 `enum direction': either `upward' to pad above the argument,
1759 `downward' to pad below, or `none' to inhibit padding. */
284d86e9 1760
4fb4e4b8
DE
1761#define FUNCTION_ARG_PADDING(MODE, TYPE) \
1762function_arg_padding ((MODE), (TYPE))
1763
1764/* If defined, a C expression that gives the alignment boundary, in bits,
1765 of an argument with the specified mode and type. If it is not defined,
1766 PARM_BOUNDARY is used for all arguments.
1767 For sparc64, objects requiring 16 byte alignment are passed that way. */
1768
1769#define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
1770((TARGET_ARCH64 \
1771 && (GET_MODE_ALIGNMENT (MODE) == 128 \
1772 || ((TYPE) && TYPE_ALIGN (TYPE) == 128))) \
1773 ? 128 : PARM_BOUNDARY)
7a6cf439 1774\f
1bb87f28
JW
1775/* Define the information needed to generate branch and scc insns. This is
1776 stored from the compare operation. Note that we can't use "rtx" here
1777 since it hasn't been defined! */
1778
1779extern struct rtx_def *sparc_compare_op0, *sparc_compare_op1;
1780
1bb87f28 1781\f
4b69d2a3
RS
1782/* Generate the special assembly code needed to tell the assembler whatever
1783 it might need to know about the return value of a function.
1784
1785 For Sparc assemblers, we need to output a .proc pseudo-op which conveys
1786 information to the assembler relating to peephole optimization (done in
1787 the assembler). */
1788
1789#define ASM_DECLARE_RESULT(FILE, RESULT) \
4f70758f 1790 fprintf ((FILE), "\t.proc\t0%lo\n", sparc_type_code (TREE_TYPE (RESULT)))
4b69d2a3 1791
1cb36a98 1792/* Output the special assembly code needed to tell the assembler some
730f0207
JJ
1793 register is used as global register variable.
1794
1795 SPARC 64bit psABI declares registers %g2 and %g3 as application
1796 registers and %g6 and %g7 as OS registers. Any object using them
1797 should declare (for %g2/%g3 has to, for %g6/%g7 can) that it uses them
1798 and how they are used (scratch or some global variable).
1799 Linker will then refuse to link together objects which use those
1800 registers incompatibly.
1801
1802 Unless the registers are used for scratch, two different global
1803 registers cannot be declared to the same name, so in the unlikely
1804 case of a global register variable occupying more than one register
1805 we prefix the second and following registers with .gnu.part1. etc. */
1806
1807extern char sparc_hard_reg_printed[8];
1cb36a98
RH
1808
1809#ifdef HAVE_AS_REGISTER_PSEUDO_OP
1810#define ASM_DECLARE_REGISTER_GLOBAL(FILE, DECL, REGNO, NAME) \
1811do { \
1812 if (TARGET_ARCH64) \
1813 { \
730f0207
JJ
1814 int end = HARD_REGNO_NREGS ((REGNO), DECL_MODE (decl)) + (REGNO); \
1815 int reg; \
1816 for (reg = (REGNO); reg < 8 && reg < end; reg++) \
1817 if ((reg & ~1) == 2 || (reg & ~1) == 6) \
1cb36a98 1818 { \
730f0207
JJ
1819 if (reg == (REGNO)) \
1820 fprintf ((FILE), "\t.register\t%%g%d, %s\n", reg, (NAME)); \
1cb36a98
RH
1821 else \
1822 fprintf ((FILE), "\t.register\t%%g%d, .gnu.part%d.%s\n", \
730f0207
JJ
1823 reg, reg - (REGNO), (NAME)); \
1824 sparc_hard_reg_printed[reg] = 1; \
1cb36a98
RH
1825 } \
1826 } \
1827} while (0)
1828#endif
1829
c4ce6853 1830\f
89a8b315
RH
1831/* Emit rtl for profiling. */
1832#define PROFILE_HOOK(LABEL) sparc_profile_hook (LABEL)
6f334f44 1833
89a8b315
RH
1834/* All the work done in PROFILE_HOOK, but still required. */
1835#define FUNCTION_PROFILER(FILE, LABELNO) do { } while (0)
1bb87f28 1836
2be15d0f 1837/* Set the name of the mcount function for the system. */
2be15d0f 1838#define MCOUNT_FUNCTION "*mcount"
c4ce6853 1839\f
1bb87f28
JW
1840/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1841 the stack pointer does not matter. The value is tested only in
1842 functions that have frame pointers.
1843 No definition is equivalent to always zero. */
1844
1bb87f28
JW
1845#define EXIT_IGNORE_STACK \
1846 (get_frame_size () != 0 \
1847 || current_function_calls_alloca || current_function_outgoing_args_size)
1848
bafb031b
DE
1849#define DELAY_SLOTS_FOR_EPILOGUE \
1850 (TARGET_FLAT ? sparc_flat_epilogue_delay_slots () : 1)
1851#define ELIGIBLE_FOR_EPILOGUE_DELAY(trial, slots_filled) \
1852 (TARGET_FLAT ? sparc_flat_eligible_for_epilogue_delay (trial, slots_filled) \
5b485d2c 1853 : eligible_for_epilogue_delay (trial, slots_filled))
deeeee8c
MS
1854
1855/* Define registers used by the epilogue and return instruction. */
1856#define EPILOGUE_USES(REGNO) \
1857 (!TARGET_FLAT && REGNO == 31)
6a4bb1fa 1858\f
1bb87f28
JW
1859/* Length in units of the trampoline for entering a nested function. */
1860
c6b0465b
JC
1861#define TRAMPOLINE_SIZE (TARGET_ARCH64 ? 32 : 16)
1862
1863#define TRAMPOLINE_ALIGNMENT 128 /* 16 bytes */
1bb87f28
JW
1864
1865/* Emit RTL insns to initialize the variable parts of a trampoline.
1866 FNADDR is an RTX for the address of the function's pure code.
7a6cf439 1867 CXT is an RTX for the static chain value for the function. */
1bb87f28 1868
7a6cf439 1869#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
6f64bf5f 1870 if (TARGET_ARCH64) \
7a6cf439
DE
1871 sparc64_initialize_trampoline (TRAMP, FNADDR, CXT); \
1872 else \
c6b0465b 1873 sparc_initialize_trampoline (TRAMP, FNADDR, CXT)
6a4bb1fa 1874\f
648d2ffc 1875/* Generate necessary RTL for __builtin_saveregs(). */
4fb4e4b8 1876
648d2ffc 1877#define EXPAND_BUILTIN_SAVEREGS() sparc_builtin_saveregs ()
953fe179 1878
a8b2c8a1
RH
1879/* Implement `va_start' for varargs and stdarg. */
1880#define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1881 sparc_va_start (stdarg, valist, nextarg)
1882
1883/* Implement `va_arg'. */
1884#define EXPAND_BUILTIN_VA_ARG(valist, type) \
1885 sparc_va_arg (valist, type)
1886
4fb4e4b8
DE
1887/* Define this macro if the location where a function argument is passed
1888 depends on whether or not it is a named argument.
1889
1890 This macro controls how the NAMED argument to FUNCTION_ARG
1891 is set for varargs and stdarg functions. With this macro defined,
1892 the NAMED argument is always true for named arguments, and false for
1893 unnamed arguments. If this is not defined, but SETUP_INCOMING_VARARGS
1894 is defined, then all arguments are treated as named. Otherwise, all named
1895 arguments except the last are treated as named.
1896 For the v9 we want NAMED to mean what it says it means. */
e5e809f4
JL
1897
1898#define STRICT_ARGUMENT_NAMING TARGET_V9
4fb4e4b8 1899
7d167afd
JJ
1900/* We do not allow sibling calls if -mflat, nor
1901 we do not allow indirect calls to be optimized into sibling calls. */
1902#define FUNCTION_OK_FOR_SIBCALL(DECL) (DECL && ! TARGET_FLAT)
1903
953fe179
JW
1904/* Generate RTL to flush the register windows so as to make arbitrary frames
1905 available. */
1906#define SETUP_FRAME_ADDRESSES() \
1907 emit_insn (gen_flush_register_windows ())
1908
1909/* Given an rtx for the address of a frame,
1910 return an rtx for the address of the word in the frame
7a6cf439
DE
1911 that holds the dynamic chain--the previous frame's address.
1912 ??? -mflat support? */
c5c76735 1913#define DYNAMIC_CHAIN_ADDRESS(frame) plus_constant (frame, 14 * UNITS_PER_WORD)
953fe179
JW
1914
1915/* The return address isn't on the stack, it is in a register, so we can't
1916 access it from the current frame pointer. We can access it from the
1917 previous frame pointer though by reading a value from the register window
1918 save area. */
1919#define RETURN_ADDR_IN_PREVIOUS_FRAME
1920
5b6faa70 1921/* This is the offset of the return address to the true next instruction to be
80ffc95e 1922 executed for the current function. */
6f64bf5f
DE
1923#define RETURN_ADDR_OFFSET \
1924 (8 + 4 * (! TARGET_ARCH64 && current_function_returns_struct))
5b6faa70 1925
953fe179
JW
1926/* The current return address is in %i7. The return address of anything
1927 farther back is in the register window save area at [%fp+60]. */
1928/* ??? This ignores the fact that the actual return address is +8 for normal
1929 returns, and +12 for structure returns. */
1930#define RETURN_ADDR_RTX(count, frame) \
1931 ((count == -1) \
284d86e9
JC
1932 ? gen_rtx_REG (Pmode, 31) \
1933 : gen_rtx_MEM (Pmode, \
c5c76735 1934 memory_address (Pmode, plus_constant (frame, \
cd49f073
AM
1935 15 * UNITS_PER_WORD \
1936 + SPARC_STACK_BIAS))))
9704efe6 1937
d60bee3a
DE
1938/* Before the prologue, the return address is %o7 + 8. OK, sometimes it's
1939 +12, but always using +8 is close enough for frame unwind purposes.
1940 Actually, just using %o7 is close enough for unwinding, but %o7+8
1941 is something you can return to. */
1942#define INCOMING_RETURN_ADDR_RTX \
c5c76735 1943 plus_constant (gen_rtx_REG (word_mode, 15), 8)
8034da37 1944#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (15)
d60bee3a
DE
1945
1946/* The offset from the incoming value of %sp to the top of the stack frame
1947 for the current function. On sparc64, we have to account for the stack
1948 bias if present. */
1949#define INCOMING_FRAME_SP_OFFSET SPARC_STACK_BIAS
1950
1150a841
RH
1951/* Describe how we implement __builtin_eh_return. */
1952#define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 24 : INVALID_REGNUM)
1953#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 1) /* %g1 */
1954#define EH_RETURN_HANDLER_RTX gen_rtx_REG (Pmode, 31) /* %i7 */
17e9e88c
JJ
1955
1956/* Select a format to encode pointers in exception handling data. CODE
1957 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
1958 true if the symbol may be affected by dynamic relocations.
1959
1960 If assembler and linker properly support .uaword %r_disp32(foo),
1961 then use PC relative 32-bit relocations instead of absolute relocs
1962 for shared libraries. On sparc64, use pc relative 32-bit relocs even
cf7b8b0d
JJ
1963 for binaries, to save memory.
1964
1965 binutils 2.12 would emit a R_SPARC_DISP32 dynamic relocation if the
1966 symbol %r_disp32() is against was not local, but .hidden. In that
1967 case, we have to use DW_EH_PE_absptr for pic personality. */
17e9e88c 1968#ifdef HAVE_AS_SPARC_UA_PCREL
cf7b8b0d 1969#ifdef HAVE_AS_SPARC_UA_PCREL_HIDDEN
17e9e88c
JJ
1970#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
1971 (flag_pic \
1972 ? (GLOBAL ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
1973 : ((TARGET_ARCH64 && ! GLOBAL) \
1974 ? (DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
1975 : DW_EH_PE_absptr))
cf7b8b0d
JJ
1976#else
1977#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
1978 (flag_pic \
1979 ? (GLOBAL ? DW_EH_PE_absptr : (DW_EH_PE_pcrel | DW_EH_PE_sdata4)) \
1980 : ((TARGET_ARCH64 && ! GLOBAL) \
1981 ? (DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
1982 : DW_EH_PE_absptr))
1983#endif
17e9e88c
JJ
1984
1985/* Emit a PC-relative relocation. */
1986#define ASM_OUTPUT_DWARF_PCREL(FILE, SIZE, LABEL) \
1987 do { \
1988 fputs (integer_asm_op (SIZE, FALSE), FILE); \
1989 fprintf (FILE, "%%r_disp%d(", SIZE * 8); \
1990 assemble_name (FILE, LABEL); \
1991 fputc (')', FILE); \
1992 } while (0)
1993#endif
1bb87f28
JW
1994\f
1995/* Addressing modes, and classification of registers for them. */
1996
940da324
JL
1997/* #define HAVE_POST_INCREMENT 0 */
1998/* #define HAVE_POST_DECREMENT 0 */
1bb87f28 1999
940da324
JL
2000/* #define HAVE_PRE_DECREMENT 0 */
2001/* #define HAVE_PRE_INCREMENT 0 */
1bb87f28
JW
2002
2003/* Macros to check register numbers against specific register classes. */
2004
2005/* These assume that REGNO is a hard or pseudo reg number.
2006 They give nonzero only if REGNO is a hard reg of the suitable class
2007 or a pseudo reg currently allocated to a suitable hard reg.
2008 Since they use reg_renumber, they are safe only once reg_renumber
2009 has been allocated, which happens in local-alloc.c. */
2010
2011#define REGNO_OK_FOR_INDEX_P(REGNO) \
563c12b0
RH
2012((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < (unsigned)32 \
2013 || (REGNO) == FRAME_POINTER_REGNUM \
2014 || reg_renumber[REGNO] == FRAME_POINTER_REGNUM)
2015
2016#define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO)
2017
1bb87f28 2018#define REGNO_OK_FOR_FP_P(REGNO) \
4f70758f
KG
2019 (((unsigned) (REGNO) - 32 < (TARGET_V9 ? (unsigned)64 : (unsigned)32)) \
2020 || ((unsigned) reg_renumber[REGNO] - 32 < (TARGET_V9 ? (unsigned)64 : (unsigned)32)))
7a6cf439
DE
2021#define REGNO_OK_FOR_CCFP_P(REGNO) \
2022 (TARGET_V9 \
4f70758f
KG
2023 && (((unsigned) (REGNO) - 96 < (unsigned)4) \
2024 || ((unsigned) reg_renumber[REGNO] - 96 < (unsigned)4)))
1bb87f28
JW
2025
2026/* Now macros that check whether X is a register and also,
2027 strictly, whether it is in a specified class.
2028
2029 These macros are specific to the SPARC, and may be used only
2030 in code for printing assembler insns and in conditions for
2031 define_optimization. */
2032
2033/* 1 if X is an fp register. */
2034
2035#define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
284d86e9
JC
2036
2037/* Is X, a REG, an in or global register? i.e. is regno 0..7 or 24..31 */
2038#define IN_OR_GLOBAL_P(X) (REGNO (X) < 8 || (REGNO (X) >= 24 && REGNO (X) <= 31))
1bb87f28
JW
2039\f
2040/* Maximum number of registers that can appear in a valid memory address. */
2041
2042#define MAX_REGS_PER_ADDRESS 2
2043
7aca9b9c
JW
2044/* Recognize any constant value that is a valid address.
2045 When PIC, we do not accept an address that would require a scratch reg
2046 to load into a register. */
1bb87f28 2047
6eff269e
BK
2048#define CONSTANT_ADDRESS_P(X) \
2049 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
7aca9b9c
JW
2050 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
2051 || (GET_CODE (X) == CONST \
2052 && ! (flag_pic && pic_address_needs_scratch (X))))
2053
2054/* Define this, so that when PIC, reload won't try to reload invalid
2055 addresses which require two reload registers. */
2056
2057#define LEGITIMATE_PIC_OPERAND_P(X) (! pic_address_needs_scratch (X))
1bb87f28
JW
2058
2059/* Nonzero if the constant value X is a legitimate general operand.
f952a238
JJ
2060 Anything can be made to work except floating point constants.
2061 If TARGET_VIS, 0.0 can be made to work as well. */
1bb87f28 2062
f952a238
JJ
2063#define LEGITIMATE_CONSTANT_P(X) \
2064 (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode || \
0f63333c
JJ
2065 (TARGET_VIS && \
2066 (GET_MODE (X) == SFmode || GET_MODE (X) == DFmode || \
2067 GET_MODE (X) == TFmode) && \
7ce86678 2068 fp_zero_operand (X, GET_MODE (X))))
1bb87f28
JW
2069
2070/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
2071 and check its validity for a certain class.
2072 We have two alternate definitions for each of them.
2073 The usual definition accepts all pseudo regs; the other rejects
2074 them unless they have been allocated suitable hard regs.
2075 The symbol REG_OK_STRICT causes the latter definition to be used.
2076
2077 Most source files want to accept pseudo regs in the hope that
2078 they will get allocated to the class that the insn wants them to be in.
2079 Source files for reload pass need to be strict.
2080 After reload, it makes no difference, since pseudo regs have
2081 been eliminated by then. */
2082
e0d80184 2083/* Optional extra constraints for this machine.
1bb87f28 2084
62190128
DM
2085 'Q' handles floating point constants which can be moved into
2086 an integer register with a single sethi instruction.
2087
2088 'R' handles floating point constants which can be moved into
2089 an integer register with a single mov instruction.
2090
2091 'S' handles floating point constants which can be moved into
2092 an integer register using a high/lo_sum sequence.
2093
e0d80184
DM
2094 'T' handles memory addresses where the alignment is known to
2095 be at least 8 bytes.
1bb87f28 2096
e0d80184
DM
2097 `U' handles all pseudo registers or a hard even numbered
2098 integer register, needed for ldd/std instructions. */
1bb87f28 2099
62190128
DM
2100#define EXTRA_CONSTRAINT_BASE(OP, C) \
2101 ((C) == 'Q' ? fp_sethi_p(OP) \
2102 : (C) == 'R' ? fp_mov_p(OP) \
2103 : (C) == 'S' ? fp_high_losum_p(OP) \
2104 : 0)
2105
1bb87f28
JW
2106#ifndef REG_OK_STRICT
2107
2108/* Nonzero if X is a hard reg that can be used as an index
2109 or if it is a pseudo reg. */
7a6cf439 2110#define REG_OK_FOR_INDEX_P(X) \
563c12b0
RH
2111 (REGNO (X) < 32 \
2112 || REGNO (X) == FRAME_POINTER_REGNUM \
2113 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
2114
1bb87f28
JW
2115/* Nonzero if X is a hard reg that can be used as a base reg
2116 or if it is a pseudo reg. */
563c12b0 2117#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_INDEX_P (X)
7a6cf439 2118
a5774a7d 2119/* 'T', 'U' are for aligned memory loads which aren't needed for arch64. */
1bb87f28
JW
2120
2121#define EXTRA_CONSTRAINT(OP, C) \
62190128
DM
2122 (EXTRA_CONSTRAINT_BASE(OP, C) \
2123 || ((! TARGET_ARCH64 && (C) == 'T') \
2124 ? (mem_min_alignment (OP, 8)) \
2125 : ((! TARGET_ARCH64 && (C) == 'U') \
2126 ? (register_ok_for_ldd (OP)) \
2127 : 0)))
2128
1bb87f28
JW
2129#else
2130
2131/* Nonzero if X is a hard reg that can be used as an index. */
2132#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
2133/* Nonzero if X is a hard reg that can be used as a base reg. */
2134#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
2135
2136#define EXTRA_CONSTRAINT(OP, C) \
62190128
DM
2137 (EXTRA_CONSTRAINT_BASE(OP, C) \
2138 || ((! TARGET_ARCH64 && (C) == 'T') \
2139 ? mem_min_alignment (OP, 8) && strict_memory_address_p (Pmode, XEXP (OP, 0)) \
2140 : ((! TARGET_ARCH64 && (C) == 'U') \
2141 ? (GET_CODE (OP) == REG \
2142 && (REGNO (OP) < FIRST_PSEUDO_REGISTER \
2143 || reg_renumber[REGNO (OP)] >= 0) \
2144 && register_ok_for_ldd (OP)) \
2145 : 0)))
2146
1bb87f28
JW
2147#endif
2148\f
1cb36a98
RH
2149/* Should gcc use [%reg+%lo(xx)+offset] addresses? */
2150
2151#ifdef HAVE_AS_OFFSETABLE_LO10
2152#define USE_AS_OFFSETABLE_LO10 1
2153#else
2154#define USE_AS_OFFSETABLE_LO10 0
2155#endif
2156\f
1bb87f28
JW
2157/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
2158 that is a valid memory address for an instruction.
2159 The MODE argument is the machine mode for the MEM expression
2160 that wants to use this address.
2161
2162 On SPARC, the actual legitimate addresses must be REG+REG or REG+SMALLINT
2163 ordinarily. This changes a bit when generating PIC.
2164
2165 If you change this, execute "rm explow.o recog.o reload.o". */
2166
bec2e359
JW
2167#define RTX_OK_FOR_BASE_P(X) \
2168 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
2169 || (GET_CODE (X) == SUBREG \
2170 && GET_CODE (SUBREG_REG (X)) == REG \
2171 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
2172
2173#define RTX_OK_FOR_INDEX_P(X) \
2174 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
2175 || (GET_CODE (X) == SUBREG \
2176 && GET_CODE (SUBREG_REG (X)) == REG \
2177 && REG_OK_FOR_INDEX_P (SUBREG_REG (X))))
2178
2179#define RTX_OK_FOR_OFFSET_P(X) \
ce3e1311 2180 (GET_CODE (X) == CONST_INT && INTVAL (X) >= -0x1000 && INTVAL (X) < 0x1000 - 8)
1cb36a98
RH
2181
2182#define RTX_OK_FOR_OLO10_P(X) \
2183 (GET_CODE (X) == CONST_INT && INTVAL (X) >= -0x1000 && INTVAL (X) < 0xc00 - 8)
bec2e359 2184
1bb87f28 2185#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
bec2e359
JW
2186{ if (RTX_OK_FOR_BASE_P (X)) \
2187 goto ADDR; \
1bb87f28
JW
2188 else if (GET_CODE (X) == PLUS) \
2189 { \
bec2e359
JW
2190 register rtx op0 = XEXP (X, 0); \
2191 register rtx op1 = XEXP (X, 1); \
2192 if (flag_pic && op0 == pic_offset_table_rtx) \
1bb87f28 2193 { \
bec2e359 2194 if (RTX_OK_FOR_BASE_P (op1)) \
1bb87f28
JW
2195 goto ADDR; \
2196 else if (flag_pic == 1 \
bec2e359
JW
2197 && GET_CODE (op1) != REG \
2198 && GET_CODE (op1) != LO_SUM \
7aca9b9c
JW
2199 && GET_CODE (op1) != MEM \
2200 && (GET_CODE (op1) != CONST_INT \
2201 || SMALL_INT (op1))) \
1bb87f28
JW
2202 goto ADDR; \
2203 } \
bec2e359 2204 else if (RTX_OK_FOR_BASE_P (op0)) \
1bb87f28 2205 { \
54e7fb26 2206 if ((RTX_OK_FOR_INDEX_P (op1) \
d0ae1ce3
VM
2207 /* We prohibit REG + REG for TFmode when \
2208 there are no instructions which accept \
2209 REG+REG instructions. We do this \
2210 because REG+REG is not an offsetable \
2211 address. If we get the situation \
2212 in reload where source and destination \
2213 of a movtf pattern are both MEMs with \
2214 REG+REG address, then only one of them \
2215 gets converted to an offsetable \
80ffc95e 2216 address. */ \
ce3e1311
JJ
2217 && (MODE != TFmode \
2218 || (TARGET_FPU && TARGET_ARCH64 \
2219 && TARGET_V9 \
2220 && TARGET_HARD_QUAD)) \
2221 /* We prohibit REG + REG on ARCH32 if \
2222 not optimizing for DFmode/DImode \
2223 because then mem_min_alignment is \
2224 likely to be zero after reload and the \
2225 forced split would lack a matching \
80ffc95e 2226 splitter pattern. */ \
ce3e1311
JJ
2227 && (TARGET_ARCH64 || optimize \
2228 || (MODE != DFmode \
2229 && MODE != DImode))) \
bec2e359 2230 || RTX_OK_FOR_OFFSET_P (op1)) \
1bb87f28
JW
2231 goto ADDR; \
2232 } \
bec2e359 2233 else if (RTX_OK_FOR_BASE_P (op1)) \
1bb87f28 2234 { \
54e7fb26 2235 if ((RTX_OK_FOR_INDEX_P (op0) \
80ffc95e 2236 /* See the previous comment. */ \
ce3e1311 2237 && (MODE != TFmode \
d0ae1ce3 2238 || (TARGET_FPU && TARGET_ARCH64 \
54e7fb26 2239 && TARGET_V9 \
ce3e1311
JJ
2240 && TARGET_HARD_QUAD)) \
2241 && (TARGET_ARCH64 || optimize \
2242 || (MODE != DFmode \
2243 && MODE != DImode))) \
bec2e359 2244 || RTX_OK_FOR_OFFSET_P (op0)) \
1bb87f28
JW
2245 goto ADDR; \
2246 } \
1cb36a98
RH
2247 else if (USE_AS_OFFSETABLE_LO10 \
2248 && GET_CODE (op0) == LO_SUM \
2249 && TARGET_ARCH64 \
2250 && ! TARGET_CM_MEDMID \
2251 && RTX_OK_FOR_OLO10_P (op1)) \
2252 { \
2253 register rtx op00 = XEXP (op0, 0); \
2254 register rtx op01 = XEXP (op0, 1); \
2255 if (RTX_OK_FOR_BASE_P (op00) \
2256 && CONSTANT_P (op01)) \
2257 goto ADDR; \
2258 } \
2259 else if (USE_AS_OFFSETABLE_LO10 \
2260 && GET_CODE (op1) == LO_SUM \
2261 && TARGET_ARCH64 \
2262 && ! TARGET_CM_MEDMID \
2263 && RTX_OK_FOR_OLO10_P (op0)) \
2264 { \
2265 register rtx op10 = XEXP (op1, 0); \
2266 register rtx op11 = XEXP (op1, 1); \
2267 if (RTX_OK_FOR_BASE_P (op10) \
2268 && CONSTANT_P (op11)) \
2269 goto ADDR; \
2270 } \
1bb87f28 2271 } \
bec2e359
JW
2272 else if (GET_CODE (X) == LO_SUM) \
2273 { \
2274 register rtx op0 = XEXP (X, 0); \
2275 register rtx op1 = XEXP (X, 1); \
2276 if (RTX_OK_FOR_BASE_P (op0) \
2f0da906
JW
2277 && CONSTANT_P (op1) \
2278 /* We can't allow TFmode, because an offset \
2279 greater than or equal to the alignment (8) \
80ffc95e 2280 may cause the LO_SUM to overflow if !v9. */\
e0d80184 2281 && (MODE != TFmode || TARGET_V9)) \
bec2e359
JW
2282 goto ADDR; \
2283 } \
1bb87f28
JW
2284 else if (GET_CODE (X) == CONST_INT && SMALL_INT (X)) \
2285 goto ADDR; \
2286}
2287\f
2288/* Try machine-dependent ways of modifying an illegitimate address
2289 to be legitimate. If we find one, return the new, valid address.
2290 This macro is used in only one place: `memory_address' in explow.c.
2291
2292 OLDX is the address as it was before break_out_memory_refs was called.
2293 In some cases it is useful to look at this to decide what needs to be done.
2294
2295 MODE and WIN are passed so that this macro can use
2296 GO_IF_LEGITIMATE_ADDRESS.
2297
2298 It is always safe for this macro to do nothing. It exists to recognize
2299 opportunities to optimize the output. */
2300
2301/* On SPARC, change REG+N into REG+REG, and REG+(X*Y) into REG+REG. */
1bb87f28
JW
2302#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
2303{ rtx sparc_x = (X); \
2304 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
284d86e9 2305 (X) = gen_rtx_PLUS (Pmode, XEXP (X, 1), \
c5c76735 2306 force_operand (XEXP (X, 0), NULL_RTX)); \
1bb87f28 2307 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
284d86e9 2308 (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
c5c76735 2309 force_operand (XEXP (X, 1), NULL_RTX)); \
1bb87f28 2310 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
284d86e9 2311 (X) = gen_rtx_PLUS (Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
c5c76735 2312 XEXP (X, 1)); \
1bb87f28 2313 if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
284d86e9 2314 (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
c5c76735 2315 force_operand (XEXP (X, 1), NULL_RTX)); \
1bb87f28
JW
2316 if (sparc_x != (X) && memory_address_p (MODE, X)) \
2317 goto WIN; \
7aca9b9c 2318 if (flag_pic) (X) = legitimize_pic_address (X, MODE, 0); \
1bb87f28 2319 else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
284d86e9 2320 (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
c5c76735 2321 copy_to_mode_reg (Pmode, XEXP (X, 1))); \
1bb87f28 2322 else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
284d86e9 2323 (X) = gen_rtx_PLUS (Pmode, XEXP (X, 1), \
c5c76735 2324 copy_to_mode_reg (Pmode, XEXP (X, 0))); \
1bb87f28
JW
2325 else if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
2326 || GET_CODE (X) == LABEL_REF) \
e0d80184 2327 (X) = copy_to_suggested_reg (X, NULL_RTX, Pmode); \
1bb87f28
JW
2328 if (memory_address_p (MODE, X)) \
2329 goto WIN; }
2330
8947065c
RH
2331/* Try a machine-dependent way of reloading an illegitimate address
2332 operand. If we find one, push the reload and jump to WIN. This
2333 macro is used in only one place: `find_reloads_address' in reload.c.
2334
2335 For Sparc 32, we wish to handle addresses by splitting them into
2336 HIGH+LO_SUM pairs, retaining the LO_SUM in the memory reference.
1256ed02
JL
2337 This cuts the number of extra insns by one.
2338
2339 Do nothing when generating PIC code and the address is a
2340 symbolic operand or requires a scratch register. */
2341
8947065c
RH
2342#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
2343do { \
2344 /* Decompose SImode constants into hi+lo_sum. We do have to \
2345 rerecognize what we produce, so be careful. */ \
2346 if (CONSTANT_P (X) \
1e75bc34 2347 && (MODE != TFmode || TARGET_V9) \
8947065c 2348 && GET_MODE (X) == SImode \
1256ed02
JL
2349 && GET_CODE (X) != LO_SUM && GET_CODE (X) != HIGH \
2350 && ! (flag_pic \
78eca9f2
JL
2351 && (symbolic_operand (X, Pmode) \
2352 || pic_address_needs_scratch (X)))) \
8947065c
RH
2353 { \
2354 X = gen_rtx_LO_SUM (GET_MODE (X), \
2355 gen_rtx_HIGH (GET_MODE (X), X), X); \
df4ae160 2356 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \
8947065c
RH
2357 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
2358 OPNUM, TYPE); \
2359 goto WIN; \
2360 } \
2361 /* ??? 64-bit reloads. */ \
2362} while (0)
2363
1bb87f28
JW
2364/* Go to LABEL if ADDR (a legitimate address expression)
2365 has an effect that depends on the machine mode it is used for.
2366 On the SPARC this is never true. */
2367
2368#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
7a6cf439
DE
2369
2370/* If we are referencing a function make the SYMBOL_REF special.
a0a301fc
DE
2371 In the Embedded Medium/Anywhere code model, %g4 points to the data segment
2372 so we must not add it to function addresses. */
7a6cf439 2373
b2003250
RH
2374#define ENCODE_SECTION_INFO(DECL, FIRST) \
2375 do { \
2376 if (TARGET_CM_EMBMEDANY && TREE_CODE (DECL) == FUNCTION_DECL) \
2377 SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; \
7a6cf439 2378 } while (0)
1bb87f28
JW
2379\f
2380/* Specify the machine mode that this machine uses
2381 for the index in the tablejump instruction. */
67cb8900
JJ
2382/* If we ever implement any of the full models (such as CM_FULLANY),
2383 this has to be DImode in that case */
d1accaa3 2384#ifdef HAVE_GAS_SUBSECTION_ORDERING
67cb8900
JJ
2385#define CASE_VECTOR_MODE \
2386(! TARGET_PTR64 ? SImode : flag_pic ? SImode : TARGET_CM_MEDLOW ? SImode : DImode)
d1accaa3
JJ
2387#else
2388/* If assembler does not have working .subsection -1, we use DImode for pic, as otherwise
80ffc95e 2389 we have to sign extend which slows things down. */
d1accaa3
JJ
2390#define CASE_VECTOR_MODE \
2391(! TARGET_PTR64 ? SImode : flag_pic ? DImode : TARGET_CM_MEDLOW ? SImode : DImode)
2392#endif
1bb87f28 2393
18543a22
ILT
2394/* Define as C expression which evaluates to nonzero if the tablejump
2395 instruction expects the table to contain offsets from the address of the
2396 table.
80ffc95e 2397 Do not define this if the table should contain absolute addresses. */
18543a22 2398/* #define CASE_VECTOR_PC_RELATIVE 1 */
1bb87f28 2399
1bb87f28
JW
2400/* Define this as 1 if `char' should by default be signed; else as 0. */
2401#define DEFAULT_SIGNED_CHAR 1
2402
2403/* Max number of bytes we can move from memory to memory
2404 in one reasonably fast instruction. */
2eef2ef1 2405#define MOVE_MAX 8
1bb87f28 2406
0fb5a69e 2407#if 0 /* Sun 4 has matherr, so this is no good. */
24e2a2bf
RS
2408/* This is the value of the error code EDOM for this machine,
2409 used by the sqrt instruction. */
2410#define TARGET_EDOM 33
2411
2412/* This is how to refer to the variable errno. */
2413#define GEN_ERRNO_RTX \
284d86e9 2414 gen_rtx_MEM (SImode, gen_rtx_SYMBOL_REF (Pmode, "errno"))
0fb5a69e 2415#endif /* 0 */
24e2a2bf 2416
9a63901f
RK
2417/* Define if operations between registers always perform the operation
2418 on the full register even if a narrower mode is specified. */
2419#define WORD_REGISTER_OPERATIONS
2420
2421/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2422 will either zero-extend or sign-extend. The value of this macro should
2423 be the code that says which one of the two operations is implicitly
2424 done, NIL if none. */
2425#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1bb87f28
JW
2426
2427/* Nonzero if access to memory by bytes is slow and undesirable.
2428 For RISC chips, it means that access to memory by bytes is no
2429 better than access by words when possible, so grab a whole word
2430 and maybe make use of that. */
2431#define SLOW_BYTE_ACCESS 1
2432
2433/* We assume that the store-condition-codes instructions store 0 for false
2434 and some other value for true. This is the value stored for true. */
2435
2436#define STORE_FLAG_VALUE 1
2437
2438/* When a prototype says `char' or `short', really pass an `int'. */
cb560352 2439#define PROMOTE_PROTOTYPES (TARGET_ARCH32)
1bb87f28 2440
d969caf8 2441/* Define this to be nonzero if shift instructions ignore all but the low-order
80ffc95e 2442 few bits. */
d969caf8 2443#define SHIFT_COUNT_TRUNCATED 1
1bb87f28
JW
2444
2445/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
2446 is done just by pretending it is already truncated. */
2447#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2448
2449/* Specify the machine mode that pointers have.
2450 After generation of rtl, the compiler makes no further distinction
2451 between pointers and any other objects of this machine mode. */
3276910d 2452#define Pmode (TARGET_ARCH64 ? DImode : SImode)
1bb87f28 2453
b4ac57ab
RS
2454/* Generate calls to memcpy, memcmp and memset. */
2455#define TARGET_MEM_FUNCTIONS
2456
1bb87f28
JW
2457/* Add any extra modes needed to represent the condition code.
2458
2459 On the Sparc, we have a "no-overflow" mode which is used when an add or
2460 subtract insn is used to set the condition code. Different branches are
2461 used in this case for some operations.
2462
4d449554
JW
2463 We also have two modes to indicate that the relevant condition code is
2464 in the floating-point condition code register. One for comparisons which
2465 will generate an exception if the result is unordered (CCFPEmode) and
c4ce6853 2466 one for comparisons which will never trap (CCFPmode).
7a6cf439
DE
2467
2468 CCXmode and CCX_NOOVmode are only used by v9. */
2469
aa0b4465
ZW
2470#define EXTRA_CC_MODES \
2471 CC(CCXmode, "CCX") \
2472 CC(CC_NOOVmode, "CC_NOOV") \
2473 CC(CCX_NOOVmode, "CCX_NOOV") \
2474 CC(CCFPmode, "CCFP") \
2475 CC(CCFPEmode, "CCFPE")
1bb87f28
JW
2476
2477/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
4d449554 2478 return the mode to be used for the comparison. For floating-point,
7913f3d0
RH
2479 CCFP[E]mode is used. CC_NOOVmode should be used when the first operand
2480 is a PLUS, MINUS, NEG, or ASHIFT. CCmode should be used when no special
922bd191 2481 processing is needed. */
e267e177 2482#define SELECT_CC_MODE(OP,X,Y) select_cc_mode ((OP), (X), (Y))
1bb87f28 2483
7913f3d0
RH
2484/* Return non-zero if MODE implies a floating point inequality can be
2485 reversed. For Sparc this is always true because we have a full
46238b7d
JJ
2486 compliment of ordered and unordered comparisons, but until generic
2487 code knows how to reverse it correctly we keep the old definition. */
2488#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode && (MODE) != CCFPmode)
b331b745 2489
3276910d
RK
2490/* A function address in a call instruction for indexing purposes. */
2491#define FUNCTION_MODE Pmode
1bb87f28
JW
2492
2493/* Define this if addresses of constant functions
2494 shouldn't be put through pseudo regs where they can be cse'd.
2495 Desirable on machines where ordinary constants are expensive
2496 but a CALL with constant address is cheap. */
2497#define NO_FUNCTION_CSE
2498
2499/* alloca should avoid clobbering the old register save area. */
2500#define SETJMP_VIA_SAVE_AREA
2501
2502/* Define subroutines to call to handle multiply and divide.
2503 Use the subroutines that Sun's library provides.
2504 The `*' prevents an underscore from being prepended by the compiler. */
2505
2506#define DIVSI3_LIBCALL "*.div"
2507#define UDIVSI3_LIBCALL "*.udiv"
2508#define MODSI3_LIBCALL "*.rem"
2509#define UMODSI3_LIBCALL "*.urem"
2510/* .umul is a little faster than .mul. */
2511#define MULSI3_LIBCALL "*.umul"
2512
8248e2bc 2513/* Define library calls for quad FP operations. These are all part of the
47ac041c
JJ
2514 SPARC 32bit ABI. */
2515#define ADDTF3_LIBCALL "_Q_add"
2516#define SUBTF3_LIBCALL "_Q_sub"
2517#define NEGTF2_LIBCALL "_Q_neg"
2518#define MULTF3_LIBCALL "_Q_mul"
2519#define DIVTF3_LIBCALL "_Q_div"
2520#define FLOATSITF2_LIBCALL "_Q_itoq"
2521#define FIX_TRUNCTFSI2_LIBCALL "_Q_qtoi"
2522#define FIXUNS_TRUNCTFSI2_LIBCALL "_Q_qtou"
2523#define EXTENDSFTF2_LIBCALL "_Q_stoq"
2524#define TRUNCTFSF2_LIBCALL "_Q_qtos"
2525#define EXTENDDFTF2_LIBCALL "_Q_dtoq"
2526#define TRUNCTFDF2_LIBCALL "_Q_qtod"
2527#define EQTF2_LIBCALL "_Q_feq"
2528#define NETF2_LIBCALL "_Q_fne"
2529#define GTTF2_LIBCALL "_Q_fgt"
2530#define GETF2_LIBCALL "_Q_fge"
2531#define LTTF2_LIBCALL "_Q_flt"
2532#define LETF2_LIBCALL "_Q_fle"
8248e2bc 2533
78e9b5df
JW
2534/* We can define the TFmode sqrt optab only if TARGET_FPU. This is because
2535 with soft-float, the SFmode and DFmode sqrt instructions will be absent,
2536 and the compiler will notice and try to use the TFmode sqrt instruction
2537 for calls to the builtin function sqrt, but this fails. */
27da6752
JW
2538#define INIT_TARGET_OPTABS \
2539 do { \
47ac041c
JJ
2540 if (TARGET_ARCH32) \
2541 { \
2542 add_optab->handlers[(int) TFmode].libfunc \
2543 = init_one_libfunc (ADDTF3_LIBCALL); \
2544 sub_optab->handlers[(int) TFmode].libfunc \
2545 = init_one_libfunc (SUBTF3_LIBCALL); \
2546 neg_optab->handlers[(int) TFmode].libfunc \
2547 = init_one_libfunc (NEGTF2_LIBCALL); \
2548 smul_optab->handlers[(int) TFmode].libfunc \
2549 = init_one_libfunc (MULTF3_LIBCALL); \
ef89d648 2550 sdiv_optab->handlers[(int) TFmode].libfunc \
47ac041c
JJ
2551 = init_one_libfunc (DIVTF3_LIBCALL); \
2552 eqtf2_libfunc = init_one_libfunc (EQTF2_LIBCALL); \
2553 netf2_libfunc = init_one_libfunc (NETF2_LIBCALL); \
2554 gttf2_libfunc = init_one_libfunc (GTTF2_LIBCALL); \
2555 getf2_libfunc = init_one_libfunc (GETF2_LIBCALL); \
2556 lttf2_libfunc = init_one_libfunc (LTTF2_LIBCALL); \
2557 letf2_libfunc = init_one_libfunc (LETF2_LIBCALL); \
2558 trunctfsf2_libfunc = init_one_libfunc (TRUNCTFSF2_LIBCALL); \
2559 trunctfdf2_libfunc = init_one_libfunc (TRUNCTFDF2_LIBCALL); \
2560 extendsftf2_libfunc = init_one_libfunc (EXTENDSFTF2_LIBCALL); \
2561 extenddftf2_libfunc = init_one_libfunc (EXTENDDFTF2_LIBCALL); \
2562 floatsitf_libfunc = init_one_libfunc (FLOATSITF2_LIBCALL); \
2563 fixtfsi_libfunc = init_one_libfunc (FIX_TRUNCTFSI2_LIBCALL); \
2564 fixunstfsi_libfunc \
2565 = init_one_libfunc (FIXUNS_TRUNCTFSI2_LIBCALL); \
2566 if (TARGET_FPU) \
2567 sqrt_optab->handlers[(int) TFmode].libfunc \
2568 = init_one_libfunc ("_Q_sqrt"); \
2569 } \
47428190 2570 INIT_SUBTARGET_OPTABS; \
78e9b5df
JW
2571 } while (0)
2572
2573/* This is meant to be redefined in the host dependent files */
2574#define INIT_SUBTARGET_OPTABS
2575
c5c60e15
BS
2576/* Nonzero if a floating point comparison library call for
2577 mode MODE that will return a boolean value. Zero if one
2578 of the libgcc2 functions is used. */
2579#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
2580
1bb87f28
JW
2581/* Compute the cost of computing a constant rtl expression RTX
2582 whose rtx-code is CODE. The body of this macro is a portion
2583 of a switch statement. If the code is computed here,
2584 return it with a return statement. Otherwise, break from the switch. */
2585
3bb22aee 2586#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1bb87f28 2587 case CONST_INT: \
1bb87f28 2588 if (INTVAL (RTX) < 0x1000 && INTVAL (RTX) >= -0x1000) \
5b485d2c 2589 return 0; \
1bb87f28
JW
2590 case HIGH: \
2591 return 2; \
2592 case CONST: \
2593 case LABEL_REF: \
2594 case SYMBOL_REF: \
2595 return 4; \
2596 case CONST_DOUBLE: \
2597 if (GET_MODE (RTX) == DImode) \
2598 if ((XINT (RTX, 3) == 0 \
2599 && (unsigned) XINT (RTX, 2) < 0x1000) \
2600 || (XINT (RTX, 3) == -1 \
2601 && XINT (RTX, 2) < 0 \
2602 && XINT (RTX, 2) >= -0x1000)) \
5b485d2c 2603 return 0; \
1bb87f28
JW
2604 return 8;
2605
a0a74fda 2606#define ADDRESS_COST(RTX) 1
1bb87f28
JW
2607
2608/* Compute extra cost of moving data between one register class
bfd6bc60 2609 and another. */
284d86e9 2610#define GENERAL_OR_I64(C) ((C) == GENERAL_REGS || (C) == I64_REGS)
cf011243 2611#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
284d86e9
JC
2612 (((FP_REG_CLASS_P (CLASS1) && GENERAL_OR_I64 (CLASS2)) \
2613 || (GENERAL_OR_I64 (CLASS1) && FP_REG_CLASS_P (CLASS2)) \
bfd6bc60 2614 || (CLASS1) == FPCC_REGS || (CLASS2) == FPCC_REGS) \
284d86e9 2615 ? (sparc_cpu == PROCESSOR_ULTRASPARC ? 12 : 6) : 2)
1bb87f28
JW
2616
2617/* Provide the costs of a rtl expression. This is in the body of a
2618 switch on CODE. The purpose for the cost of MULT is to encourage
2619 `synth_mult' to find a synthetic multiply when reasonable.
2620
2621 If we need more than 12 insns to do a multiply, then go out-of-line,
2622 since the call overhead will be < 10% of the cost of the multiply. */
2623
3bb22aee 2624#define RTX_COSTS(X,CODE,OUTER_CODE) \
1bb87f28 2625 case MULT: \
3bc8b61e
DM
2626 if (sparc_cpu == PROCESSOR_ULTRASPARC) \
2627 return (GET_MODE (X) == DImode ? \
2628 COSTS_N_INSNS (34) : COSTS_N_INSNS (19)); \
bfd6bc60 2629 return TARGET_HARD_MUL ? COSTS_N_INSNS (5) : COSTS_N_INSNS (25); \
1bb87f28
JW
2630 case DIV: \
2631 case UDIV: \
2632 case MOD: \
2633 case UMOD: \
3bc8b61e
DM
2634 if (sparc_cpu == PROCESSOR_ULTRASPARC) \
2635 return (GET_MODE (X) == DImode ? \
2636 COSTS_N_INSNS (68) : COSTS_N_INSNS (37)); \
5b485d2c
JW
2637 return COSTS_N_INSNS (25); \
2638 /* Make FLOAT and FIX more expensive than CONST_DOUBLE,\
1bb87f28
JW
2639 so that cse will favor the latter. */ \
2640 case FLOAT: \
5b485d2c 2641 case FIX: \
1bb87f28 2642 return 19;
1bb87f28
JW
2643\f
2644/* Control the assembler format that we output. */
2645
2646/* Output at beginning of assembler file. */
2647
2648#define ASM_FILE_START(file)
2649
1ccfa253
DE
2650/* A C string constant describing how to begin a comment in the target
2651 assembler language. The compiler assumes that the comment will end at
2652 the end of the line. */
2653
2654#define ASM_COMMENT_START "!"
2655
1bb87f28
JW
2656/* Output to assembler file text saying following lines
2657 may contain character constants, extra white space, comments, etc. */
2658
2659#define ASM_APP_ON ""
2660
2661/* Output to assembler file text saying following lines
2662 no longer contain unusual constructs. */
2663
2664#define ASM_APP_OFF ""
2665
7a6cf439
DE
2666/* ??? Try to make the style consistent here (_OP?). */
2667
7a6cf439
DE
2668#define ASM_FLOAT ".single"
2669#define ASM_DOUBLE ".double"
80ffc95e 2670#define ASM_LONGDOUBLE ".xxx" /* ??? Not known (or used yet). */
303d524a 2671
1bb87f28
JW
2672/* How to refer to registers in assembler output.
2673 This sequence is indexed by compiler's hard-register-number (see above). */
2674
7a6cf439
DE
2675#define REGISTER_NAMES \
2676{"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", \
2677 "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", \
2678 "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
2679 "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", \
2680 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", \
2681 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", \
2682 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", \
2683 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", \
2684 "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", \
2685 "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", \
2686 "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", \
2687 "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", \
563c12b0 2688 "%fcc0", "%fcc1", "%fcc2", "%fcc3", "%icc", "%sfp" }
ea3fa5f7 2689
c4ce6853 2690/* Define additional names for use in asm clobbers and asm declarations. */
ea3fa5f7 2691
c4ce6853
DE
2692#define ADDITIONAL_REGISTER_NAMES \
2693{{"ccr", SPARC_ICC_REG}, {"cc", SPARC_ICC_REG}}
ea3fa5f7 2694
5bcb3f13
JM
2695/* On Sun 4, this limit is 2048. We use 1000 to be safe, since the length
2696 can run past this up to a continuation point. Once we used 1500, but
2697 a single entry in C++ can run more than 500 bytes, due to the length of
2698 mangled symbol names. dbxout.c should really be fixed to do
2699 continuations when they are actually needed instead of trying to
2700 guess... */
2701#define DBX_CONTIN_LENGTH 1000
1bb87f28 2702
1bb87f28
JW
2703/* This is how to output the definition of a user-level label named NAME,
2704 such as the label on a static function or variable NAME. */
2705
2706#define ASM_OUTPUT_LABEL(FILE,NAME) \
2707 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
2708
2709/* This is how to output a command to make the user-level label named NAME
2710 defined for reference from other files. */
2711
2712#define ASM_GLOBALIZE_LABEL(FILE,NAME) \
2713 do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
2714
80ffc95e 2715/* The prefix to add to user-visible assembler symbols. */
1bb87f28 2716
4e0c8ad2 2717#define USER_LABEL_PREFIX "_"
1bb87f28 2718
d2a8e680 2719/* This is how to output a definition of an internal numbered label where
1bb87f28
JW
2720 PREFIX is the class of label and NUM is the number within the class. */
2721
2722#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
2723 fprintf (FILE, "%s%d:\n", PREFIX, NUM)
2724
2725/* This is how to store into the string LABEL
2726 the symbol_ref name of an internal numbered label where
2727 PREFIX is the class of label and NUM is the number within the class.
2728 This is suitable for output with `assemble_name'. */
2729
2730#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
4f70758f 2731 sprintf ((LABEL), "*%s%ld", (PREFIX), (long)(NUM))
1bb87f28 2732
e0d80184
DM
2733/* This is how we hook in and defer the case-vector until the end of
2734 the function. */
e0d80184
DM
2735#define ASM_OUTPUT_ADDR_VEC(LAB,VEC) \
2736 sparc_defer_case_vector ((LAB),(VEC), 0)
2737
2738#define ASM_OUTPUT_ADDR_DIFF_VEC(LAB,VEC) \
2739 sparc_defer_case_vector ((LAB),(VEC), 1)
2740
1bb87f28
JW
2741/* This is how to output an element of a case-vector that is absolute. */
2742
2743#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
4b69d2a3
RS
2744do { \
2745 char label[30]; \
2746 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
67cb8900 2747 if (CASE_VECTOR_MODE == SImode) \
7a6cf439 2748 fprintf (FILE, "\t.word\t"); \
7a6cf439
DE
2749 else \
2750 fprintf (FILE, "\t.xword\t"); \
4b69d2a3 2751 assemble_name (FILE, label); \
e0d80184 2752 fputc ('\n', FILE); \
4b69d2a3 2753} while (0)
1bb87f28
JW
2754
2755/* This is how to output an element of a case-vector that is relative.
2756 (SPARC uses such vectors only when generating PIC.) */
2757
33f7f353 2758#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
4b69d2a3
RS
2759do { \
2760 char label[30]; \
e0d80184 2761 ASM_GENERATE_INTERNAL_LABEL (label, "L", (VALUE)); \
67cb8900 2762 if (CASE_VECTOR_MODE == SImode) \
7a6cf439 2763 fprintf (FILE, "\t.word\t"); \
7a6cf439
DE
2764 else \
2765 fprintf (FILE, "\t.xword\t"); \
4b69d2a3 2766 assemble_name (FILE, label); \
e0d80184
DM
2767 ASM_GENERATE_INTERNAL_LABEL (label, "L", (REL)); \
2768 fputc ('-', FILE); \
2769 assemble_name (FILE, label); \
2770 fputc ('\n', FILE); \
4b69d2a3 2771} while (0)
1bb87f28 2772
d1accaa3
JJ
2773/* This is what to output before and after case-vector (both
2774 relative and absolute). If .subsection -1 works, we put case-vectors
2775 at the beginning of the current section. */
2776
2777#ifdef HAVE_GAS_SUBSECTION_ORDERING
2778
2779#define ASM_OUTPUT_ADDR_VEC_START(FILE) \
2780 fprintf(FILE, "\t.subsection\t-1\n")
2781
2782#define ASM_OUTPUT_ADDR_VEC_END(FILE) \
2783 fprintf(FILE, "\t.previous\n")
2784
2785#endif
2786
1bb87f28
JW
2787/* This is how to output an assembler line
2788 that says to advance the location counter
2789 to a multiple of 2**LOG bytes. */
2790
2791#define ASM_OUTPUT_ALIGN(FILE,LOG) \
2792 if ((LOG) != 0) \
2793 fprintf (FILE, "\t.align %d\n", (1<<(LOG)))
2794
2795#define ASM_OUTPUT_SKIP(FILE,SIZE) \
2796 fprintf (FILE, "\t.skip %u\n", (SIZE))
2797
2798/* This says how to output an assembler line
2799 to define a global common symbol. */
2800
2801#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
b277ceaf 2802( fputs ("\t.common ", (FILE)), \
1bb87f28 2803 assemble_name ((FILE), (NAME)), \
b277ceaf 2804 fprintf ((FILE), ",%u,\"bss\"\n", (SIZE)))
1bb87f28 2805
b277ceaf
JW
2806/* This says how to output an assembler line to define a local common
2807 symbol. */
1bb87f28 2808
b277ceaf
JW
2809#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGNED) \
2810( fputs ("\t.reserve ", (FILE)), \
2811 assemble_name ((FILE), (NAME)), \
2812 fprintf ((FILE), ",%u,\"bss\",%u\n", \
2813 (SIZE), ((ALIGNED) / BITS_PER_UNIT)))
1bb87f28 2814
101d9529
JM
2815/* A C statement (sans semicolon) to output to the stdio stream
2816 FILE the assembler definition of uninitialized global DECL named
2817 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
2818 Try to use asm_output_aligned_bss to implement this macro. */
2819
2820#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
2821 do { \
2822 fputs (".globl ", (FILE)); \
2823 assemble_name ((FILE), (NAME)); \
2824 fputs ("\n", (FILE)); \
2825 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
2826 } while (0)
2827
1bb87f28
JW
2828/* Store in OUTPUT a string (made with alloca) containing
2829 an assembler-name for a local static variable named NAME.
2830 LABELNO is an integer which is different for each call. */
2831
2832#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2833( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2834 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2835
471b6f1b 2836#define IDENT_ASM_OP "\t.ident\t"
c14f2655
RS
2837
2838/* Output #ident as a .ident. */
2839
2840#define ASM_OUTPUT_IDENT(FILE, NAME) \
b9f7d63e 2841 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
c14f2655 2842
c94b3179
JM
2843/* Output code to add DELTA to the first argument, and then jump to FUNCTION.
2844 Used for C++ multiple inheritance. */
1df8f58f
JM
2845#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
2846do { \
a0115140
JJ
2847 int reg = 0; \
2848 \
2849 if (TARGET_ARCH64 \
2850 && aggregate_value_p (TREE_TYPE (TREE_TYPE (FUNCTION)))) \
2851 reg = 1; \
4c646291 2852 if ((DELTA) >= 4096 || (DELTA) < -4096) \
a0115140 2853 fprintf (FILE, "\tset\t%d, %%g1\n\tadd\t%%o%d, %%g1, %%o%d\n", \
6cada0cd 2854 (int)(DELTA), reg, reg); \
fd407cd2 2855 else \
6cada0cd 2856 fprintf (FILE, "\tadd\t%%o%d, %d, %%o%d\n", reg, (int)(DELTA), reg);\
4c646291
JJ
2857 fprintf (FILE, "\tor\t%%o7, %%g0, %%g1\n"); \
2858 fprintf (FILE, "\tcall\t"); \
2859 assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
2860 fprintf (FILE, ", 0\n"); \
2861 fprintf (FILE, "\t or\t%%g1, %%g0, %%o7\n"); \
c94b3179
JM
2862} while (0)
2863
1bb87f28 2864#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
a0a301fc 2865 ((CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' || (CHAR) == '(' || (CHAR) == '_')
1bb87f28
JW
2866
2867/* Print operand X (an rtx) in assembler syntax to file FILE.
2868 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2869 For `%' followed by punctuation, CODE is the punctuation and X is null. */
2870
2871#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
2872
2873/* Print a memory address as an operand to reference that memory location. */
2874
2875#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
2876{ register rtx base, index = 0; \
2877 int offset = 0; \
2878 register rtx addr = ADDR; \
2879 if (GET_CODE (addr) == REG) \
2880 fputs (reg_names[REGNO (addr)], FILE); \
2881 else if (GET_CODE (addr) == PLUS) \
2882 { \
2883 if (GET_CODE (XEXP (addr, 0)) == CONST_INT) \
2884 offset = INTVAL (XEXP (addr, 0)), base = XEXP (addr, 1);\
2885 else if (GET_CODE (XEXP (addr, 1)) == CONST_INT) \
2886 offset = INTVAL (XEXP (addr, 1)), base = XEXP (addr, 0);\
2887 else \
2888 base = XEXP (addr, 0), index = XEXP (addr, 1); \
1cb36a98
RH
2889 if (GET_CODE (base) == LO_SUM) \
2890 { \
2891 if (! USE_AS_OFFSETABLE_LO10 \
2892 || TARGET_ARCH32 \
2893 || TARGET_CM_MEDMID) \
2894 abort (); \
2895 output_operand (XEXP (base, 0), 0); \
2896 fputs ("+%lo(", FILE); \
2897 output_address (XEXP (base, 1)); \
2898 fprintf (FILE, ")+%d", offset); \
2899 } \
2900 else \
2901 { \
2902 fputs (reg_names[REGNO (base)], FILE); \
2903 if (index == 0) \
2904 fprintf (FILE, "%+d", offset); \
2905 else if (GET_CODE (index) == REG) \
2906 fprintf (FILE, "+%s", reg_names[REGNO (index)]); \
2907 else if (GET_CODE (index) == SYMBOL_REF \
2908 || GET_CODE (index) == CONST) \
2909 fputc ('+', FILE), output_addr_const (FILE, index); \
2910 else abort (); \
2911 } \
1bb87f28
JW
2912 } \
2913 else if (GET_CODE (addr) == MINUS \
2914 && GET_CODE (XEXP (addr, 1)) == LABEL_REF) \
2915 { \
2916 output_addr_const (FILE, XEXP (addr, 0)); \
2917 fputs ("-(", FILE); \
2918 output_addr_const (FILE, XEXP (addr, 1)); \
2919 fputs ("-.)", FILE); \
2920 } \
2921 else if (GET_CODE (addr) == LO_SUM) \
2922 { \
2923 output_operand (XEXP (addr, 0), 0); \
e0d80184
DM
2924 if (TARGET_CM_MEDMID) \
2925 fputs ("+%l44(", FILE); \
2926 else \
2927 fputs ("+%lo(", FILE); \
1bb87f28
JW
2928 output_address (XEXP (addr, 1)); \
2929 fputc (')', FILE); \
2930 } \
2931 else if (flag_pic && GET_CODE (addr) == CONST \
2932 && GET_CODE (XEXP (addr, 0)) == MINUS \
2933 && GET_CODE (XEXP (XEXP (addr, 0), 1)) == CONST \
2934 && GET_CODE (XEXP (XEXP (XEXP (addr, 0), 1), 0)) == MINUS \
2935 && XEXP (XEXP (XEXP (XEXP (addr, 0), 1), 0), 1) == pc_rtx) \
2936 { \
2937 addr = XEXP (addr, 0); \
2938 output_addr_const (FILE, XEXP (addr, 0)); \
2939 /* Group the args of the second CONST in parenthesis. */ \
2940 fputs ("-(", FILE); \
2941 /* Skip past the second CONST--it does nothing for us. */\
2942 output_addr_const (FILE, XEXP (XEXP (addr, 1), 0)); \
2943 /* Close the parenthesis. */ \
2944 fputc (')', FILE); \
2945 } \
2946 else \
2947 { \
2948 output_addr_const (FILE, addr); \
2949 } \
2950}
2951
f7e0e539
DM
2952/* Define the codes that are matched by predicates in sparc.c. */
2953
11301057
RH
2954#define PREDICATE_CODES \
2955{"reg_or_0_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2956{"fp_zero_operand", {CONST_DOUBLE}}, \
2957{"intreg_operand", {SUBREG, REG}}, \
2958{"fcc_reg_operand", {REG}}, \
0b82d204 2959{"fcc0_reg_operand", {REG}}, \
11301057
RH
2960{"icc_or_fcc_reg_operand", {REG}}, \
2961{"restore_operand", {REG}}, \
2962{"call_operand", {MEM}}, \
2963{"call_operand_address", {SYMBOL_REF, LABEL_REF, CONST, CONST_DOUBLE, \
2964 ADDRESSOF, SUBREG, REG, PLUS, LO_SUM, CONST_INT}}, \
6871dd65 2965{"symbolic_operand", {SYMBOL_REF, LABEL_REF, CONST}}, \
11301057
RH
2966{"symbolic_memory_operand", {SUBREG, MEM}}, \
2967{"label_ref_operand", {LABEL_REF}}, \
2968{"sp64_medium_pic_operand", {CONST}}, \
2969{"data_segment_operand", {SYMBOL_REF, PLUS, CONST}}, \
2970{"text_segment_operand", {LABEL_REF, SYMBOL_REF, PLUS, CONST}}, \
2971{"reg_or_nonsymb_mem_operand", {SUBREG, REG, MEM}}, \
2972{"splittable_symbolic_memory_operand", {MEM}}, \
2973{"splittable_immediate_memory_operand", {MEM}}, \
2974{"eq_or_neq", {EQ, NE}}, \
2975{"normal_comp_operator", {GE, GT, LE, LT, GTU, LEU}}, \
2976{"noov_compare_op", {NE, EQ, GE, GT, LE, LT, GEU, GTU, LEU, LTU}}, \
0b82d204 2977{"noov_compare64_op", {NE, EQ, GE, GT, LE, LT, GEU, GTU, LEU, LTU}}, \
11301057
RH
2978{"v9_regcmp_op", {EQ, NE, GE, LT, LE, GT}}, \
2979{"extend_op", {SIGN_EXTEND, ZERO_EXTEND}}, \
2980{"cc_arithop", {AND, IOR, XOR}}, \
2981{"cc_arithopn", {AND, IOR}}, \
2982{"arith_operand", {SUBREG, REG, CONST_INT}}, \
2983{"arith_add_operand", {SUBREG, REG, CONST_INT}}, \
2984{"arith11_operand", {SUBREG, REG, CONST_INT}}, \
2985{"arith10_operand", {SUBREG, REG, CONST_INT}}, \
2986{"arith_double_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2987{"arith_double_add_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2988{"arith11_double_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2989{"arith10_double_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2990{"small_int", {CONST_INT}}, \
2991{"small_int_or_double", {CONST_INT, CONST_DOUBLE}}, \
2992{"uns_small_int", {CONST_INT}}, \
2993{"uns_arith_operand", {SUBREG, REG, CONST_INT}}, \
2994{"clobbered_register", {REG}}, \
2995{"input_operand", {SUBREG, REG, CONST_INT, MEM, CONST}}, \
11301057
RH
2996{"const64_operand", {CONST_INT, CONST_DOUBLE}}, \
2997{"const64_high_operand", {CONST_INT, CONST_DOUBLE}},
f7e0e539 2998
27a36778
MS
2999/* The number of Pmode words for the setjmp buffer. */
3000#define JMP_BUF_SIZE 12
3001
59ba1a3a
MS
3002#define DONT_ACCESS_GBLS_AFTER_EPILOGUE (flag_pic)
3003