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