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