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