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