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