]>
Commit | Line | Data |
---|---|---|
f045b2c9 | 1 | /* Definitions of target machine for GNU compiler, for IBM RS/6000. |
5119dc13 | 2 | Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
6a7ec0a7 | 3 | Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) |
f045b2c9 RS |
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 | ||
22 | /* Note that some other tm.h files include this one and then override | |
23 | many of the definitions that relate to assembler syntax. */ | |
24 | ||
25 | ||
26 | /* Names to predefine in the preprocessor for this target machine. */ | |
27 | ||
84b49fa7 RK |
28 | #define CPP_PREDEFINES "-D_IBMR2 -D_POWER -D_AIX -D_AIX32 \ |
29 | -Asystem(unix) -Asystem(aix) -Acpu(rs6000) -Amachine(rs6000)" | |
f045b2c9 RS |
30 | |
31 | /* Print subsidiary information on the compiler version in use. */ | |
32 | #define TARGET_VERSION ; | |
33 | ||
fdaff8ba RS |
34 | /* Tell the assembler to assume that all undefined names are external. |
35 | ||
36 | Don't do this until the fixed IBM assembler is more generally available. | |
37 | When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL, | |
38 | ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no | |
b4d6689b RK |
39 | longer be needed. Also, the extern declaration of mcount in ASM_FILE_START |
40 | will no longer be needed. */ | |
f045b2c9 RS |
41 | |
42 | /* #define ASM_SPEC "-u" */ | |
43 | ||
84b49fa7 RK |
44 | /* Define appropriate architecture macros for preprocessor depending on |
45 | target switches. */ | |
46 | ||
47 | #define CPP_SPEC "\ | |
50124474 | 48 | %{posix: -D_POSIX_SOURCE} \ |
84b49fa7 RK |
49 | %{!mcpu*: \ |
50 | %{mpower: %{!mpower2: -D_ARCH_PWR}} \ | |
51 | %{mpower2: -D_ARCH_PWR2} \ | |
52 | %{mpowerpc*: -D_ARCH_PPC} \ | |
53 | %{mno-power: %{!mpowerpc*: -D_ARCH_COM}} \ | |
54 | %{!mno-power: %{!mpower2: -D_ARCH_PWR}}} \ | |
55 | %{mcpu=common: -D_ARCH_COM} \ | |
56 | %{mcpu=power: -D_ARCH_PWR} \ | |
57 | %{mcpu=powerpc: -D_ARCH_PPC} \ | |
58 | %{mcpu=rios: -D_ARCH_PWR} \ | |
59 | %{mcpu=rios1: -D_ARCH_PWR} \ | |
60 | %{mcpu=rios2: -D_ARCH_PWR2} \ | |
61 | %{mcpu=rsc: -D_ARCH_PWR} \ | |
62 | %{mcpu=rsc1: -D_ARCH_PWR} \ | |
49a0b204 MM |
63 | %{mcpu=403: -D_ARCH_PPC} \ |
64 | %{mcpu=mpc403: -D_ARCH_PPC} \ | |
65 | %{mcpu=ppc403: -D_ARCH_PPC} \ | |
84b49fa7 RK |
66 | %{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \ |
67 | %{mcpu=mpc601: -D_ARCH_PPC -D_ARCH_PWR} \ | |
68 | %{mcpu=ppc601: -D_ARCH_PPC -D_ARCH_PWR} \ | |
69 | %{mcpu=603: -D_ARCH_PPC} \ | |
70 | %{mcpu=mpc603: -D_ARCH_PPC} \ | |
71 | %{mcpu=ppc603: -D_ARCH_PPC} \ | |
72 | %{mcpu=604: -D_ARCH_PPC} \ | |
73 | %{mcpu=mpc604: -D_ARCH_PPC} \ | |
74 | %{mcpu=ppc604: -D_ARCH_PPC}" | |
75 | ||
f045b2c9 RS |
76 | /* Define the options for the binder: Start text at 512, align all segments |
77 | to 512 bytes, and warn if there is text relocation. | |
78 | ||
79 | The -bhalt:4 option supposedly changes the level at which ld will abort, | |
80 | but it also suppresses warnings about multiply defined symbols and is | |
81 | used by the AIX cc command. So we use it here. | |
82 | ||
83 | -bnodelcsect undoes a poor choice of default relating to multiply-defined | |
52c0eaf8 JM |
84 | csects. See AIX documentation for more information about this. |
85 | ||
86 | -bM:SRE tells the linker that the output file is Shared REusable. Note | |
87 | that to actually build a shared library you will also need to specify an | |
88 | export list with the -Wl,-bE option. */ | |
f045b2c9 | 89 | |
c1950f1c | 90 | #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\ |
788d9012 JM |
91 | %{static:-bnso -bI:/lib/syscalls.exp} \ |
92 | %{!shared:%{g*:-bexport:/usr/lib/libg.exp}} %{shared:-bM:SRE}" | |
f045b2c9 | 93 | |
58a39e45 RS |
94 | /* Profiled library versions are used by linking with special directories. */ |
95 | #define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\ | |
788d9012 | 96 | %{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc" |
f045b2c9 RS |
97 | |
98 | /* gcc must do the search itself to find libgcc.a, not use -l. */ | |
046b1537 | 99 | #define LIBGCC_SPEC "libgcc.a%s" |
f045b2c9 RS |
100 | |
101 | /* Don't turn -B into -L if the argument specifies a relative file name. */ | |
102 | #define RELATIVE_PREFIX_NOT_LINKDIR | |
103 | ||
fb623df5 | 104 | /* Architecture type. */ |
f045b2c9 | 105 | |
fb623df5 RK |
106 | extern int target_flags; |
107 | ||
108 | /* Use POWER architecture instructions and MQ register. */ | |
109 | #define MASK_POWER 0x01 | |
110 | ||
6febd581 RK |
111 | /* Use POWER2 extensions to POWER architecture. */ |
112 | #define MASK_POWER2 0x02 | |
113 | ||
fb623df5 | 114 | /* Use PowerPC architecture instructions. */ |
6febd581 RK |
115 | #define MASK_POWERPC 0x04 |
116 | ||
583cf4db RK |
117 | /* Use PowerPC General Purpose group optional instructions, e.g. fsqrt. */ |
118 | #define MASK_PPC_GPOPT 0x08 | |
119 | ||
120 | /* Use PowerPC Graphics group optional instructions, e.g. fsel. */ | |
121 | #define MASK_PPC_GFXOPT 0x10 | |
f045b2c9 | 122 | |
fb623df5 | 123 | /* Use PowerPC-64 architecture instructions. */ |
583cf4db | 124 | #define MASK_POWERPC64 0x20 |
f045b2c9 | 125 | |
fb623df5 | 126 | /* Use revised mnemonic names defined for PowerPC architecture. */ |
583cf4db | 127 | #define MASK_NEW_MNEMONICS 0x40 |
fb623df5 RK |
128 | |
129 | /* Disable placing fp constants in the TOC; can be turned on when the | |
130 | TOC overflows. */ | |
583cf4db | 131 | #define MASK_NO_FP_IN_TOC 0x80 |
fb623df5 | 132 | |
0b9ccabc RK |
133 | /* Disable placing symbol+offset constants in the TOC; can be turned on when |
134 | the TOC overflows. */ | |
583cf4db | 135 | #define MASK_NO_SUM_IN_TOC 0x100 |
0b9ccabc | 136 | |
fb623df5 | 137 | /* Output only one TOC entry per module. Normally linking fails if |
642a35f1 JW |
138 | there are more than 16K unique variables/constants in an executable. With |
139 | this option, linking fails only if there are more than 16K modules, or | |
140 | if there are more than 16K unique variables/constant in a single module. | |
141 | ||
142 | This is at the cost of having 2 extra loads and one extra store per | |
143 | function, and one less allocatable register. */ | |
583cf4db | 144 | #define MASK_MINIMAL_TOC 0x200 |
642a35f1 | 145 | |
9e654916 RK |
146 | /* Nonzero for the 64bit model: ints, longs, and pointers are 64 bits. */ |
147 | #define MASK_64BIT 0x400 | |
148 | ||
f85f4585 | 149 | /* Disable use of FPRs. */ |
d14a6d05 | 150 | #define MASK_SOFT_FLOAT 0x800 |
f85f4585 | 151 | |
4d30c363 MM |
152 | /* Enable load/store multiple, even on powerpc */ |
153 | #define MASK_MULTIPLE 0x1000 | |
8a61d227 | 154 | #define MASK_MULTIPLE_SET 0x2000 |
4d30c363 | 155 | |
7e69e155 MM |
156 | /* Use string instructions for block moves */ |
157 | #define MASK_STRING 0x4000 | |
158 | ||
159 | #define TARGET_POWER (target_flags & MASK_POWER) | |
160 | #define TARGET_POWER2 (target_flags & MASK_POWER2) | |
161 | #define TARGET_POWERPC (target_flags & MASK_POWERPC) | |
162 | #define TARGET_PPC_GPOPT (target_flags & MASK_PPC_GPOPT) | |
163 | #define TARGET_PPC_GFXOPT (target_flags & MASK_PPC_GFXOPT) | |
164 | #define TARGET_POWERPC64 (target_flags & MASK_POWERPC64) | |
165 | #define TARGET_NEW_MNEMONICS (target_flags & MASK_NEW_MNEMONICS) | |
166 | #define TARGET_NO_FP_IN_TOC (target_flags & MASK_NO_FP_IN_TOC) | |
167 | #define TARGET_NO_SUM_IN_TOC (target_flags & MASK_NO_SUM_IN_TOC) | |
168 | #define TARGET_MINIMAL_TOC (target_flags & MASK_MINIMAL_TOC) | |
169 | #define TARGET_64BIT (target_flags & MASK_64BIT) | |
170 | #define TARGET_SOFT_FLOAT (target_flags & MASK_SOFT_FLOAT) | |
171 | #define TARGET_MULTIPLE (target_flags & MASK_MULTIPLE) | |
172 | #define TARGET_MULTIPLE_SET (target_flags & MASK_MULTIPLE_SET) | |
173 | #define TARGET_STRING (target_flags & MASK_STRING) | |
174 | ||
175 | #define TARGET_HARD_FLOAT (! TARGET_SOFT_FLOAT) | |
d14a6d05 | 176 | |
fb623df5 | 177 | /* Run-time compilation parameters selecting different hardware subsets. |
f045b2c9 | 178 | |
fb623df5 | 179 | Macro to define tables used to set the flags. |
f045b2c9 RS |
180 | This is a list in braces of pairs in braces, |
181 | each pair being { "NAME", VALUE } | |
182 | where VALUE is the bits to set or minus the bits to clear. | |
183 | An empty string NAME is used to identify the default VALUE. */ | |
184 | ||
4d30c363 MM |
185 | /* This is meant to be redefined in the host dependent files */ |
186 | #ifndef SUBTARGET_SWITCHES | |
187 | #define SUBTARGET_SWITCHES | |
188 | #endif | |
189 | ||
fb623df5 | 190 | #define TARGET_SWITCHES \ |
d14a6d05 MM |
191 | {{"power", MASK_POWER | MASK_MULTIPLE}, \ |
192 | {"power2", MASK_POWER | MASK_MULTIPLE | MASK_POWER2}, \ | |
6febd581 | 193 | {"no-power2", - MASK_POWER2}, \ |
d14a6d05 | 194 | {"no-power", - (MASK_POWER | MASK_POWER2 | MASK_MULTIPLE)}, \ |
fb623df5 | 195 | {"powerpc", MASK_POWERPC}, \ |
583cf4db RK |
196 | {"no-powerpc", - (MASK_POWERPC | MASK_PPC_GPOPT \ |
197 | | MASK_PPC_GFXOPT | MASK_POWERPC64)}, \ | |
198 | {"powerpc-gpopt", MASK_POWERPC | MASK_PPC_GPOPT}, \ | |
199 | {"no-powerpc-gpopt", - MASK_PPC_GPOPT}, \ | |
200 | {"powerpc-gfxopt", MASK_POWERPC | MASK_PPC_GFXOPT}, \ | |
201 | {"no-powerpc-gfxopt", - MASK_PPC_GFXOPT}, \ | |
fb623df5 RK |
202 | {"new-mnemonics", MASK_NEW_MNEMONICS}, \ |
203 | {"old-mnemonics", -MASK_NEW_MNEMONICS}, \ | |
0b9ccabc RK |
204 | {"full-toc", - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC \ |
205 | | MASK_MINIMAL_TOC)}, \ | |
fb623df5 RK |
206 | {"fp-in-toc", - MASK_NO_FP_IN_TOC}, \ |
207 | {"no-fp-in-toc", MASK_NO_FP_IN_TOC}, \ | |
0b9ccabc RK |
208 | {"sum-in-toc", - MASK_NO_SUM_IN_TOC}, \ |
209 | {"no-sum-in-toc", MASK_NO_SUM_IN_TOC}, \ | |
fb623df5 | 210 | {"minimal-toc", MASK_MINIMAL_TOC}, \ |
0b9ccabc | 211 | {"minimal-toc", - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC)}, \ |
fb623df5 | 212 | {"no-minimal-toc", - MASK_MINIMAL_TOC}, \ |
d14a6d05 MM |
213 | {"hard-float", - MASK_SOFT_FLOAT}, \ |
214 | {"soft-float", MASK_SOFT_FLOAT}, \ | |
8a61d227 | 215 | {"multiple", MASK_MULTIPLE | MASK_MULTIPLE_SET}, \ |
4d30c363 | 216 | {"no-multiple", - MASK_MULTIPLE}, \ |
8a61d227 | 217 | {"no-multiple", MASK_MULTIPLE_SET}, \ |
7e69e155 MM |
218 | {"string", MASK_STRING}, \ |
219 | {"no-string", - MASK_STRING}, \ | |
4d30c363 | 220 | SUBTARGET_SWITCHES \ |
fb623df5 RK |
221 | {"", TARGET_DEFAULT}} |
222 | ||
4d30c363 | 223 | #define TARGET_DEFAULT (MASK_POWER | MASK_MULTIPLE) |
fb623df5 RK |
224 | |
225 | /* Processor type. */ | |
226 | enum processor_type | |
f86fe1fb | 227 | {PROCESSOR_RIOS1, |
fb623df5 | 228 | PROCESSOR_RIOS2, |
49a0b204 | 229 | PROCESSOR_PPC403, |
fb623df5 RK |
230 | PROCESSOR_PPC601, |
231 | PROCESSOR_PPC603, | |
232 | PROCESSOR_PPC604, | |
233 | PROCESSOR_PPC620}; | |
234 | ||
235 | extern enum processor_type rs6000_cpu; | |
236 | ||
237 | /* Recast the processor type to the cpu attribute. */ | |
238 | #define rs6000_cpu_attr ((enum attr_cpu)rs6000_cpu) | |
239 | ||
8482e358 RK |
240 | /* Define generic processor types based upon current deployment. */ |
241 | #define PROCESSOR_COMMON PROCESSOR_PPC601 | |
242 | #define PROCESSOR_POWER PROCESSOR_RIOS1 | |
243 | #define PROCESSOR_POWERPC PROCESSOR_PPC601 | |
6e151478 | 244 | |
fb623df5 | 245 | /* Define the default processor. This is overridden by other tm.h files. */ |
f86fe1fb | 246 | #define PROCESSOR_DEFAULT PROCESSOR_RIOS1 |
fb623df5 | 247 | |
6febd581 RK |
248 | /* Specify the dialect of assembler to use. New mnemonics is dialect one |
249 | and the old mnemonics are dialect zero. */ | |
250 | #define ASSEMBLER_DIALECT TARGET_NEW_MNEMONICS ? 1 : 0 | |
251 | ||
fb623df5 RK |
252 | /* This macro is similar to `TARGET_SWITCHES' but defines names of |
253 | command options that have values. Its definition is an | |
254 | initializer with a subgrouping for each command option. | |
255 | ||
256 | Each subgrouping contains a string constant, that defines the | |
257 | fixed part of the option name, and the address of a variable. | |
258 | The variable, type `char *', is set to the variable part of the | |
259 | given option if the fixed part matches. The actual option name | |
260 | is made by appending `-m' to the specified name. | |
261 | ||
262 | Here is an example which defines `-mshort-data-NUMBER'. If the | |
263 | given option is `-mshort-data-512', the variable `m88k_short_data' | |
264 | will be set to the string `"512"'. | |
265 | ||
266 | extern char *m88k_short_data; | |
267 | #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } } */ | |
268 | ||
269 | #define TARGET_OPTIONS \ | |
270 | { {"cpu=", &rs6000_cpu_string}} | |
271 | ||
272 | extern char *rs6000_cpu_string; | |
273 | ||
274 | /* Sometimes certain combinations of command options do not make sense | |
275 | on a particular target machine. You can define a macro | |
276 | `OVERRIDE_OPTIONS' to take account of this. This macro, if | |
277 | defined, is executed once just after all the command options have | |
278 | been parsed. | |
279 | ||
280 | On the RS/6000 this is used to define the target cpu type. */ | |
281 | ||
3933e0e1 | 282 | #define OVERRIDE_OPTIONS rs6000_override_options () |
f045b2c9 | 283 | |
4f074454 RK |
284 | /* Show we can debug even without a frame pointer. */ |
285 | #define CAN_DEBUG_WITHOUT_FP | |
f045b2c9 RS |
286 | \f |
287 | /* target machine storage layout */ | |
288 | ||
df44fa77 RK |
289 | /* Define to support cross compilation to an RS6000 target. */ |
290 | #define REAL_ARITHMETIC | |
291 | ||
13d39dbc | 292 | /* Define this macro if it is advisable to hold scalars in registers |
ef457bda RK |
293 | in a wider mode than that declared by the program. In such cases, |
294 | the value is constrained to be within the bounds of the declared | |
295 | type, but kept valid in the wider mode. The signedness of the | |
296 | extension may differ from that of the type. */ | |
297 | ||
298 | #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ | |
299 | if (GET_MODE_CLASS (MODE) == MODE_INT \ | |
300 | && GET_MODE_SIZE (MODE) < 4) \ | |
dac29d65 | 301 | (MODE) = SImode; |
ef457bda | 302 | |
f045b2c9 RS |
303 | /* Define this if most significant bit is lowest numbered |
304 | in instructions that operate on numbered bit-fields. */ | |
305 | /* That is true on RS/6000. */ | |
306 | #define BITS_BIG_ENDIAN 1 | |
307 | ||
308 | /* Define this if most significant byte of a word is the lowest numbered. */ | |
309 | /* That is true on RS/6000. */ | |
310 | #define BYTES_BIG_ENDIAN 1 | |
311 | ||
312 | /* Define this if most significant word of a multiword number is lowest | |
313 | numbered. | |
314 | ||
315 | For RS/6000 we can decide arbitrarily since there are no machine | |
316 | instructions for them. Might as well be consistent with bits and bytes. */ | |
317 | #define WORDS_BIG_ENDIAN 1 | |
318 | ||
fdaff8ba | 319 | /* number of bits in an addressable storage unit */ |
f045b2c9 RS |
320 | #define BITS_PER_UNIT 8 |
321 | ||
322 | /* Width in bits of a "word", which is the contents of a machine register. | |
323 | Note that this is not necessarily the width of data type `int'; | |
324 | if using 16-bit ints on a 68000, this would still be 32. | |
325 | But on a machine with 16-bit registers, this would be 16. */ | |
2e360ab3 RK |
326 | #define BITS_PER_WORD (TARGET_POWERPC64 ? 64 : 32) |
327 | #define MAX_BITS_PER_WORD 64 | |
f045b2c9 RS |
328 | |
329 | /* Width of a word, in units (bytes). */ | |
2e360ab3 | 330 | #define UNITS_PER_WORD (TARGET_POWERPC64 ? 8 : 4) |
ef0e53ce | 331 | #define MIN_UNITS_PER_WORD 4 |
2e360ab3 | 332 | #define UNITS_PER_FP_WORD 8 |
f045b2c9 | 333 | |
915f619f JW |
334 | /* Type used for ptrdiff_t, as a string used in a declaration. */ |
335 | #define PTRDIFF_TYPE "int" | |
336 | ||
f045b2c9 RS |
337 | /* Type used for wchar_t, as a string used in a declaration. */ |
338 | #define WCHAR_TYPE "short unsigned int" | |
339 | ||
340 | /* Width of wchar_t in bits. */ | |
341 | #define WCHAR_TYPE_SIZE 16 | |
342 | ||
9e654916 RK |
343 | /* A C expression for the size in bits of the type `short' on the |
344 | target machine. If you don't define this, the default is half a | |
345 | word. (If this would be less than one storage unit, it is | |
346 | rounded up to one unit.) */ | |
347 | #define SHORT_TYPE_SIZE 16 | |
348 | ||
349 | /* A C expression for the size in bits of the type `int' on the | |
350 | target machine. If you don't define this, the default is one | |
351 | word. */ | |
352 | #define INT_TYPE_SIZE (TARGET_64BIT ? 64 : 32) | |
353 | #define MAX_INT_TYPE_SIZE 64 | |
354 | ||
355 | /* A C expression for the size in bits of the type `long' on the | |
356 | target machine. If you don't define this, the default is one | |
357 | word. */ | |
358 | #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) | |
359 | #define MAX_LONG_TYPE_SIZE 64 | |
360 | ||
361 | /* A C expression for the size in bits of the type `long long' on the | |
362 | target machine. If you don't define this, the default is two | |
363 | words. */ | |
364 | #define LONG_LONG_TYPE_SIZE 64 | |
365 | ||
366 | /* A C expression for the size in bits of the type `char' on the | |
367 | target machine. If you don't define this, the default is one | |
368 | quarter of a word. (If this would be less than one storage unit, | |
369 | it is rounded up to one unit.) */ | |
370 | #define CHAR_TYPE_SIZE BITS_PER_UNIT | |
371 | ||
372 | /* A C expression for the size in bits of the type `float' on the | |
373 | target machine. If you don't define this, the default is one | |
374 | word. */ | |
375 | #define FLOAT_TYPE_SIZE 32 | |
376 | ||
377 | /* A C expression for the size in bits of the type `double' on the | |
378 | target machine. If you don't define this, the default is two | |
379 | words. */ | |
380 | #define DOUBLE_TYPE_SIZE 64 | |
381 | ||
382 | /* A C expression for the size in bits of the type `long double' on | |
383 | the target machine. If you don't define this, the default is two | |
384 | words. */ | |
385 | #define LONG_DOUBLE_TYPE_SIZE 64 | |
386 | ||
f045b2c9 RS |
387 | /* Width in bits of a pointer. |
388 | See also the macro `Pmode' defined below. */ | |
9e654916 | 389 | #define POINTER_SIZE (TARGET_64BIT ? 64 : 32) |
f045b2c9 RS |
390 | |
391 | /* Allocation boundary (in *bits*) for storing arguments in argument list. */ | |
9e654916 | 392 | #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32) |
f045b2c9 RS |
393 | |
394 | /* Boundary (in *bits*) on which stack pointer should be aligned. */ | |
395 | #define STACK_BOUNDARY 64 | |
396 | ||
397 | /* Allocation boundary (in *bits*) for the code of a function. */ | |
398 | #define FUNCTION_BOUNDARY 32 | |
399 | ||
400 | /* No data type wants to be aligned rounder than this. */ | |
9e654916 | 401 | #define BIGGEST_ALIGNMENT (TARGET_64BIT ? 64 : 32) |
f045b2c9 RS |
402 | |
403 | /* Alignment of field after `int : 0' in a structure. */ | |
404 | #define EMPTY_FIELD_BOUNDARY 32 | |
405 | ||
406 | /* Every structure's size must be a multiple of this. */ | |
407 | #define STRUCTURE_SIZE_BOUNDARY 8 | |
408 | ||
409 | /* A bitfield declared as `int' forces `int' alignment for the struct. */ | |
410 | #define PCC_BITFIELD_TYPE_MATTERS 1 | |
411 | ||
412 | /* Make strings word-aligned so strcpy from constants will be faster. */ | |
413 | #define CONSTANT_ALIGNMENT(EXP, ALIGN) \ | |
414 | (TREE_CODE (EXP) == STRING_CST \ | |
415 | && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) | |
416 | ||
417 | /* Make arrays of chars word-aligned for the same reasons. */ | |
418 | #define DATA_ALIGNMENT(TYPE, ALIGN) \ | |
419 | (TREE_CODE (TYPE) == ARRAY_TYPE \ | |
420 | && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \ | |
421 | && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) | |
422 | ||
fdaff8ba | 423 | /* Non-zero if move instructions will actually fail to work |
f045b2c9 | 424 | when given unaligned data. */ |
fdaff8ba | 425 | #define STRICT_ALIGNMENT 0 |
f045b2c9 RS |
426 | \f |
427 | /* Standard register usage. */ | |
428 | ||
429 | /* Number of actual hardware registers. | |
430 | The hardware registers are assigned numbers for the compiler | |
431 | from 0 to just below FIRST_PSEUDO_REGISTER. | |
432 | All registers that the compiler knows about must be given numbers, | |
433 | even those that are not normally considered general registers. | |
434 | ||
435 | RS/6000 has 32 fixed-point registers, 32 floating-point registers, | |
436 | an MQ register, a count register, a link register, and 8 condition | |
437 | register fields, which we view here as separate registers. | |
438 | ||
439 | In addition, the difference between the frame and argument pointers is | |
440 | a function of the number of registers saved, so we need to have a | |
441 | register for AP that will later be eliminated in favor of SP or FP. | |
442 | This is a normal register, but it is fixed. */ | |
443 | ||
444 | #define FIRST_PSEUDO_REGISTER 76 | |
445 | ||
446 | /* 1 for registers that have pervasive standard uses | |
447 | and are not available for the register allocator. | |
448 | ||
449 | On RS/6000, r1 is used for the stack and r2 is used as the TOC pointer. | |
450 | ||
451 | cr5 is not supposed to be used. */ | |
452 | ||
453 | #define FIXED_REGISTERS \ | |
454 | {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
455 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
456 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
457 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
458 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0} | |
459 | ||
460 | /* 1 for registers not available across function calls. | |
461 | These must include the FIXED_REGISTERS and also any | |
462 | registers that can be used without being saved. | |
463 | The latter must include the registers where values are returned | |
464 | and the register where structure-value addresses are passed. | |
465 | Aside from that, you can include as many other registers as you like. */ | |
466 | ||
467 | #define CALL_USED_REGISTERS \ | |
468 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, \ | |
469 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
470 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \ | |
471 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
472 | 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1} | |
473 | ||
474 | /* List the order in which to allocate registers. Each register must be | |
475 | listed once, even those in FIXED_REGISTERS. | |
476 | ||
477 | We allocate in the following order: | |
478 | fp0 (not saved or used for anything) | |
479 | fp13 - fp2 (not saved; incoming fp arg registers) | |
480 | fp1 (not saved; return value) | |
481 | fp31 - fp14 (saved; order given to save least number) | |
482 | cr1, cr6, cr7 (not saved or special) | |
483 | cr0 (not saved, but used for arithmetic operations) | |
484 | cr2, cr3, cr4 (saved) | |
485 | r0 (not saved; cannot be base reg) | |
486 | r9 (not saved; best for TImode) | |
487 | r11, r10, r8-r4 (not saved; highest used first to make less conflict) | |
488 | r3 (not saved; return value register) | |
489 | r31 - r13 (saved; order given to save least number) | |
490 | r12 (not saved; if used for DImode or DFmode would use r13) | |
491 | mq (not saved; best to use it if we can) | |
492 | ctr (not saved; when we have the choice ctr is better) | |
493 | lr (saved) | |
494 | cr5, r1, r2, ap (fixed) */ | |
495 | ||
496 | #define REG_ALLOC_ORDER \ | |
497 | {32, \ | |
498 | 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, \ | |
499 | 33, \ | |
500 | 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, \ | |
501 | 50, 49, 48, 47, 46, \ | |
502 | 69, 74, 75, 68, 70, 71, 72, \ | |
503 | 0, \ | |
504 | 9, 11, 10, 8, 7, 6, 5, 4, \ | |
505 | 3, \ | |
506 | 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \ | |
507 | 18, 17, 16, 15, 14, 13, 12, \ | |
508 | 64, 66, 65, \ | |
509 | 73, 1, 2, 67} | |
510 | ||
511 | /* True if register is floating-point. */ | |
512 | #define FP_REGNO_P(N) ((N) >= 32 && (N) <= 63) | |
513 | ||
514 | /* True if register is a condition register. */ | |
515 | #define CR_REGNO_P(N) ((N) >= 68 && (N) <= 75) | |
516 | ||
517 | /* True if register is an integer register. */ | |
518 | #define INT_REGNO_P(N) ((N) <= 31 || (N) == 67) | |
519 | ||
520 | /* Return number of consecutive hard regs needed starting at reg REGNO | |
521 | to hold something of mode MODE. | |
522 | This is ordinarily the length in words of a value of mode MODE | |
523 | but can be less for certain modes in special long registers. | |
524 | ||
525 | On RS/6000, ordinary registers hold 32 bits worth; | |
526 | a single floating point register holds 64 bits worth. */ | |
527 | ||
528 | #define HARD_REGNO_NREGS(REGNO, MODE) \ | |
529 | (FP_REGNO_P (REGNO) \ | |
2e360ab3 | 530 | ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \ |
f045b2c9 RS |
531 | : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) |
532 | ||
533 | /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. | |
bdfd4e31 RK |
534 | For POWER and PowerPC, the GPRs can hold any mode, but the float |
535 | registers only can hold floating modes and DImode, and CR register only | |
536 | can hold CC modes. We cannot put TImode anywhere except general | |
537 | register and it must be able to fit within the register set. */ | |
f045b2c9 RS |
538 | |
539 | #define HARD_REGNO_MODE_OK(REGNO, MODE) \ | |
bdfd4e31 RK |
540 | (FP_REGNO_P (REGNO) ? \ |
541 | (GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
542 | || (GET_MODE_CLASS (MODE) == MODE_INT \ | |
2e360ab3 | 543 | && GET_MODE_SIZE (MODE) == UNITS_PER_FP_WORD)) \ |
f045b2c9 | 544 | : CR_REGNO_P (REGNO) ? GET_MODE_CLASS (MODE) == MODE_CC \ |
bdfd4e31 RK |
545 | : ! INT_REGNO_P (REGNO) ? (GET_MODE_CLASS (MODE) == MODE_INT \ |
546 | && GET_MODE_SIZE (MODE) <= UNITS_PER_WORD) \ | |
f045b2c9 RS |
547 | : 1) |
548 | ||
549 | /* Value is 1 if it is a good idea to tie two pseudo registers | |
550 | when one has mode MODE1 and one has mode MODE2. | |
551 | If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, | |
552 | for any hard reg, then this must be 0 for correct output. */ | |
553 | #define MODES_TIEABLE_P(MODE1, MODE2) \ | |
554 | (GET_MODE_CLASS (MODE1) == MODE_FLOAT \ | |
555 | ? GET_MODE_CLASS (MODE2) == MODE_FLOAT \ | |
556 | : GET_MODE_CLASS (MODE2) == MODE_FLOAT \ | |
557 | ? GET_MODE_CLASS (MODE1) == MODE_FLOAT \ | |
558 | : GET_MODE_CLASS (MODE1) == MODE_CC \ | |
559 | ? GET_MODE_CLASS (MODE2) == MODE_CC \ | |
560 | : GET_MODE_CLASS (MODE2) == MODE_CC \ | |
561 | ? GET_MODE_CLASS (MODE1) == MODE_CC \ | |
562 | : 1) | |
563 | ||
564 | /* A C expression returning the cost of moving data from a register of class | |
565 | CLASS1 to one of CLASS2. | |
566 | ||
567 | On the RS/6000, copying between floating-point and fixed-point | |
568 | registers is expensive. */ | |
569 | ||
570 | #define REGISTER_MOVE_COST(CLASS1, CLASS2) \ | |
571 | ((CLASS1) == FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 2 \ | |
572 | : (CLASS1) == FLOAT_REGS && (CLASS2) != FLOAT_REGS ? 10 \ | |
573 | : (CLASS1) != FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 10 \ | |
a4b970a0 | 574 | : (((CLASS1) == SPECIAL_REGS || (CLASS1) == MQ_REGS \ |
5119dc13 RK |
575 | || (CLASS1) == LINK_REGS || (CLASS1) == CTR_REGS \ |
576 | || (CLASS1) == LINK_OR_CTR_REGS) \ | |
a4b970a0 | 577 | && ((CLASS2) == SPECIAL_REGS || (CLASS2) == MQ_REGS \ |
5119dc13 RK |
578 | || (CLASS2) == LINK_REGS || (CLASS2) == CTR_REGS \ |
579 | || (CLASS2) == LINK_OR_CTR_REGS)) ? 10 \ | |
f045b2c9 RS |
580 | : 2) |
581 | ||
582 | /* A C expressions returning the cost of moving data of MODE from a register to | |
583 | or from memory. | |
584 | ||
585 | On the RS/6000, bump this up a bit. */ | |
586 | ||
ab4a5fc9 RK |
587 | #define MEMORY_MOVE_COST(MODE) \ |
588 | ((GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
589 | && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \ | |
590 | ? 3 : 2) \ | |
591 | + 4) | |
f045b2c9 RS |
592 | |
593 | /* Specify the cost of a branch insn; roughly the number of extra insns that | |
594 | should be added to avoid a branch. | |
595 | ||
ef457bda | 596 | Set this to 3 on the RS/6000 since that is roughly the average cost of an |
f045b2c9 RS |
597 | unscheduled conditional branch. */ |
598 | ||
ef457bda | 599 | #define BRANCH_COST 3 |
f045b2c9 | 600 | |
5a5e4c2c RK |
601 | /* A C statement (sans semicolon) to update the integer variable COST |
602 | based on the relationship between INSN that is dependent on | |
603 | DEP_INSN through the dependence LINK. The default is to make no | |
604 | adjustment to COST. On the RS/6000, ignore the cost of anti- and | |
605 | output-dependencies. In fact, output dependencies on the CR do have | |
606 | a cost, but it is probably not worthwhile to track it. */ | |
607 | ||
608 | #define ADJUST_COST(INSN,LINK,DEP_INSN,COST) \ | |
b0634e74 | 609 | (COST) = rs6000_adjust_cost (INSN,LINK,DEP_INSN,COST) |
5a5e4c2c | 610 | |
6febd581 RK |
611 | /* Define this macro to change register usage conditional on target flags. |
612 | Set MQ register fixed (already call_used) if not POWER architecture | |
f85f4585 RK |
613 | (RIOS1, RIOS2, RSC, and PPC601) so that it will not be allocated. |
614 | Conditionally disable FPRs. */ | |
615 | ||
616 | #define CONDITIONAL_REGISTER_USAGE \ | |
617 | { \ | |
618 | if (! TARGET_POWER) \ | |
619 | fixed_regs[64] = 1; \ | |
d14a6d05 MM |
620 | if (TARGET_SOFT_FLOAT) \ |
621 | for (i = 32; i < 64; i++) \ | |
f85f4585 RK |
622 | fixed_regs[i] = call_used_regs[i] = 1; \ |
623 | } | |
6febd581 | 624 | |
f045b2c9 RS |
625 | /* Specify the registers used for certain standard purposes. |
626 | The values of these macros are register numbers. */ | |
627 | ||
628 | /* RS/6000 pc isn't overloaded on a register that the compiler knows about. */ | |
629 | /* #define PC_REGNUM */ | |
630 | ||
631 | /* Register to use for pushing function arguments. */ | |
632 | #define STACK_POINTER_REGNUM 1 | |
633 | ||
634 | /* Base register for access to local variables of the function. */ | |
635 | #define FRAME_POINTER_REGNUM 31 | |
636 | ||
637 | /* Value should be nonzero if functions must have frame pointers. | |
638 | Zero means the frame pointer need not be set up (and parms | |
639 | may be accessed via the stack pointer) in functions that seem suitable. | |
640 | This is computed in `reload', in reload1.c. */ | |
641 | #define FRAME_POINTER_REQUIRED 0 | |
642 | ||
643 | /* Base register for access to arguments of the function. */ | |
644 | #define ARG_POINTER_REGNUM 67 | |
645 | ||
646 | /* Place to put static chain when calling a function that requires it. */ | |
647 | #define STATIC_CHAIN_REGNUM 11 | |
648 | ||
649 | /* Place that structure value return address is placed. | |
650 | ||
651 | On the RS/6000, it is passed as an extra parameter. */ | |
652 | #define STRUCT_VALUE 0 | |
653 | \f | |
654 | /* Define the classes of registers for register constraints in the | |
655 | machine description. Also define ranges of constants. | |
656 | ||
657 | One of the classes must always be named ALL_REGS and include all hard regs. | |
658 | If there is more than one class, another class must be named NO_REGS | |
659 | and contain no registers. | |
660 | ||
661 | The name GENERAL_REGS must be the name of a class (or an alias for | |
662 | another name such as ALL_REGS). This is the class of registers | |
663 | that is allowed by "g" or "r" in a register constraint. | |
664 | Also, registers outside this class are allocated only when | |
665 | instructions express preferences for them. | |
666 | ||
667 | The classes must be numbered in nondecreasing order; that is, | |
668 | a larger-numbered class must never be contained completely | |
669 | in a smaller-numbered class. | |
670 | ||
671 | For any two classes, it is very desirable that there be another | |
672 | class that represents their union. */ | |
673 | ||
674 | /* The RS/6000 has three types of registers, fixed-point, floating-point, | |
675 | and condition registers, plus three special registers, MQ, CTR, and the | |
676 | link register. | |
677 | ||
678 | However, r0 is special in that it cannot be used as a base register. | |
679 | So make a class for registers valid as base registers. | |
680 | ||
681 | Also, cr0 is the only condition code register that can be used in | |
682 | arithmetic insns, so make a separate class for it. */ | |
683 | ||
684 | enum reg_class { NO_REGS, BASE_REGS, GENERAL_REGS, FLOAT_REGS, | |
685 | NON_SPECIAL_REGS, MQ_REGS, LINK_REGS, CTR_REGS, LINK_OR_CTR_REGS, | |
e8a8bc24 RK |
686 | SPECIAL_REGS, SPEC_OR_GEN_REGS, CR0_REGS, CR_REGS, NON_FLOAT_REGS, |
687 | ALL_REGS, LIM_REG_CLASSES }; | |
f045b2c9 RS |
688 | |
689 | #define N_REG_CLASSES (int) LIM_REG_CLASSES | |
690 | ||
691 | /* Give names of register classes as strings for dump file. */ | |
692 | ||
693 | #define REG_CLASS_NAMES \ | |
694 | { "NO_REGS", "BASE_REGS", "GENERAL_REGS", "FLOAT_REGS", \ | |
695 | "NON_SPECIAL_REGS", "MQ_REGS", "LINK_REGS", "CTR_REGS", \ | |
e8a8bc24 RK |
696 | "LINK_OR_CTR_REGS", "SPECIAL_REGS", "SPEC_OR_GEN_REGS", \ |
697 | "CR0_REGS", "CR_REGS", "NON_FLOAT_REGS", "ALL_REGS" } | |
f045b2c9 RS |
698 | |
699 | /* Define which registers fit in which classes. | |
700 | This is an initializer for a vector of HARD_REG_SET | |
701 | of length N_REG_CLASSES. */ | |
702 | ||
703 | #define REG_CLASS_CONTENTS \ | |
704 | { {0, 0, 0}, {0xfffffffe, 0, 8}, {~0, 0, 8}, \ | |
e8a8bc24 RK |
705 | {0, ~0, 0}, {~0, ~0, 8}, {0, 0, 1}, {0, 0, 2}, \ |
706 | {0, 0, 4}, {0, 0, 6}, {0, 0, 7}, {~0, 0, 15}, \ | |
707 | {0, 0, 16}, {0, 0, 0xff0}, {~0, 0, 0xffff}, \ | |
708 | {~0, ~0, 0xffff} } | |
f045b2c9 RS |
709 | |
710 | /* The same information, inverted: | |
711 | Return the class number of the smallest class containing | |
712 | reg number REGNO. This could be a conditional expression | |
713 | or could index an array. */ | |
714 | ||
715 | #define REGNO_REG_CLASS(REGNO) \ | |
716 | ((REGNO) == 0 ? GENERAL_REGS \ | |
717 | : (REGNO) < 32 ? BASE_REGS \ | |
718 | : FP_REGNO_P (REGNO) ? FLOAT_REGS \ | |
719 | : (REGNO) == 68 ? CR0_REGS \ | |
720 | : CR_REGNO_P (REGNO) ? CR_REGS \ | |
721 | : (REGNO) == 64 ? MQ_REGS \ | |
722 | : (REGNO) == 65 ? LINK_REGS \ | |
723 | : (REGNO) == 66 ? CTR_REGS \ | |
724 | : (REGNO) == 67 ? BASE_REGS \ | |
725 | : NO_REGS) | |
726 | ||
727 | /* The class value for index registers, and the one for base regs. */ | |
728 | #define INDEX_REG_CLASS GENERAL_REGS | |
729 | #define BASE_REG_CLASS BASE_REGS | |
730 | ||
731 | /* Get reg_class from a letter such as appears in the machine description. */ | |
732 | ||
733 | #define REG_CLASS_FROM_LETTER(C) \ | |
734 | ((C) == 'f' ? FLOAT_REGS \ | |
735 | : (C) == 'b' ? BASE_REGS \ | |
736 | : (C) == 'h' ? SPECIAL_REGS \ | |
737 | : (C) == 'q' ? MQ_REGS \ | |
738 | : (C) == 'c' ? CTR_REGS \ | |
739 | : (C) == 'l' ? LINK_REGS \ | |
740 | : (C) == 'x' ? CR0_REGS \ | |
741 | : (C) == 'y' ? CR_REGS \ | |
742 | : NO_REGS) | |
743 | ||
744 | /* The letters I, J, K, L, M, N, and P in a register constraint string | |
745 | can be used to stand for particular ranges of immediate operands. | |
746 | This macro defines what the ranges are. | |
747 | C is the letter, and VALUE is a constant value. | |
748 | Return 1 if VALUE is in the range specified by C. | |
749 | ||
750 | `I' is signed 16-bit constants | |
751 | `J' is a constant with only the high-order 16 bits non-zero | |
752 | `K' is a constant with only the low-order 16 bits non-zero | |
753 | `L' is a constant that can be placed into a mask operand | |
754 | `M' is a constant that is greater than 31 | |
755 | `N' is a constant that is an exact power of two | |
756 | `O' is the constant zero | |
757 | `P' is a constant whose negation is a signed 16-bit constant */ | |
758 | ||
759 | #define CONST_OK_FOR_LETTER_P(VALUE, C) \ | |
760 | ( (C) == 'I' ? (unsigned) ((VALUE) + 0x8000) < 0x10000 \ | |
761 | : (C) == 'J' ? ((VALUE) & 0xffff) == 0 \ | |
762 | : (C) == 'K' ? ((VALUE) & 0xffff0000) == 0 \ | |
763 | : (C) == 'L' ? mask_constant (VALUE) \ | |
764 | : (C) == 'M' ? (VALUE) > 31 \ | |
765 | : (C) == 'N' ? exact_log2 (VALUE) >= 0 \ | |
766 | : (C) == 'O' ? (VALUE) == 0 \ | |
767 | : (C) == 'P' ? (unsigned) ((- (VALUE)) + 0x8000) < 0x1000 \ | |
768 | : 0) | |
769 | ||
770 | /* Similar, but for floating constants, and defining letters G and H. | |
771 | Here VALUE is the CONST_DOUBLE rtx itself. | |
772 | ||
773 | We flag for special constants when we can copy the constant into | |
774 | a general register in two insns for DF and one insn for SF. */ | |
775 | ||
776 | #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ | |
777 | ((C) == 'G' ? easy_fp_constant (VALUE, GET_MODE (VALUE)) : 0) | |
778 | ||
779 | /* Optional extra constraints for this machine. | |
780 | ||
781 | For the RS/6000, `Q' means that this is a memory operand that is just | |
782 | an offset from a register. */ | |
783 | ||
e8a8bc24 RK |
784 | #define EXTRA_CONSTRAINT(OP, C) \ |
785 | ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \ | |
d537c24d | 786 | : (C) == 'R' ? LEGITIMATE_CONSTANT_POOL_ADDRESS_P (OP) \ |
e8a8bc24 | 787 | : 0) |
f045b2c9 RS |
788 | |
789 | /* Given an rtx X being reloaded into a reg required to be | |
790 | in class CLASS, return the class of reg to actually use. | |
791 | In general this is just CLASS; but on some machines | |
792 | in some cases it is preferable to use a more restrictive class. | |
793 | ||
794 | On the RS/6000, we have to return NO_REGS when we want to reload a | |
795 | floating-point CONST_DOUBLE to force it to be copied to memory. */ | |
796 | ||
797 | #define PREFERRED_RELOAD_CLASS(X,CLASS) \ | |
798 | ((GET_CODE (X) == CONST_DOUBLE \ | |
799 | && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ | |
800 | ? NO_REGS : (CLASS)) | |
801 | ||
802 | /* Return the register class of a scratch register needed to copy IN into | |
803 | or out of a register in CLASS in MODE. If it can be done directly, | |
804 | NO_REGS is returned. */ | |
805 | ||
806 | #define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \ | |
807 | secondary_reload_class (CLASS, MODE, IN) | |
808 | ||
7ea555a4 RK |
809 | /* If we are copying between FP registers and anything else, we need a memory |
810 | location. */ | |
811 | ||
812 | #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \ | |
813 | ((CLASS1) != (CLASS2) && ((CLASS1) == FLOAT_REGS || (CLASS2) == FLOAT_REGS)) | |
814 | ||
f045b2c9 RS |
815 | /* Return the maximum number of consecutive registers |
816 | needed to represent mode MODE in a register of class CLASS. | |
817 | ||
818 | On RS/6000, this is the size of MODE in words, | |
819 | except in the FP regs, where a single reg is enough for two words. */ | |
820 | #define CLASS_MAX_NREGS(CLASS, MODE) \ | |
821 | ((CLASS) == FLOAT_REGS \ | |
2e360ab3 | 822 | ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \ |
f045b2c9 | 823 | : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) |
580d3230 RK |
824 | |
825 | /* If defined, gives a class of registers that cannot be used as the | |
826 | operand of a SUBREG that changes the size of the object. */ | |
827 | ||
828 | #define CLASS_CANNOT_CHANGE_SIZE FLOAT_REGS | |
f045b2c9 RS |
829 | \f |
830 | /* Stack layout; function entry, exit and calling. */ | |
831 | ||
832 | /* Define this if pushing a word on the stack | |
833 | makes the stack pointer a smaller address. */ | |
834 | #define STACK_GROWS_DOWNWARD | |
835 | ||
836 | /* Define this if the nominal address of the stack frame | |
837 | is at the high-address end of the local variables; | |
838 | that is, each additional local variable allocated | |
839 | goes at a more negative offset in the frame. | |
840 | ||
841 | On the RS/6000, we grow upwards, from the area after the outgoing | |
842 | arguments. */ | |
843 | /* #define FRAME_GROWS_DOWNWARD */ | |
844 | ||
845 | /* Offset within stack frame to start allocating local variables at. | |
846 | If FRAME_GROWS_DOWNWARD, this is the offset to the END of the | |
847 | first local allocated. Otherwise, it is the offset to the BEGINNING | |
848 | of the first local allocated. | |
849 | ||
850 | On the RS/6000, the frame pointer is the same as the stack pointer, | |
851 | except for dynamic allocations. So we start after the fixed area and | |
852 | outgoing parameter area. */ | |
853 | ||
9e654916 RK |
854 | #define STARTING_FRAME_OFFSET (current_function_outgoing_args_size \ |
855 | + (TARGET_64BIT ? 48 : 24)) | |
f045b2c9 RS |
856 | |
857 | /* If we generate an insn to push BYTES bytes, | |
858 | this says how many the stack pointer really advances by. | |
859 | On RS/6000, don't define this because there are no push insns. */ | |
860 | /* #define PUSH_ROUNDING(BYTES) */ | |
861 | ||
862 | /* Offset of first parameter from the argument pointer register value. | |
863 | On the RS/6000, we define the argument pointer to the start of the fixed | |
864 | area. */ | |
9e654916 | 865 | #define FIRST_PARM_OFFSET(FNDECL) (TARGET_64BIT ? 48 : 24) |
f045b2c9 RS |
866 | |
867 | /* Define this if stack space is still allocated for a parameter passed | |
868 | in a register. The value is the number of bytes allocated to this | |
869 | area. */ | |
9e654916 | 870 | #define REG_PARM_STACK_SPACE(FNDECL) (TARGET_64BIT ? 64 : 32) |
f045b2c9 RS |
871 | |
872 | /* Define this if the above stack space is to be considered part of the | |
873 | space allocated by the caller. */ | |
874 | #define OUTGOING_REG_PARM_STACK_SPACE | |
875 | ||
876 | /* This is the difference between the logical top of stack and the actual sp. | |
877 | ||
878 | For the RS/6000, sp points past the fixed area. */ | |
9e654916 | 879 | #define STACK_POINTER_OFFSET (TARGET_64BIT ? 48 : 24) |
f045b2c9 RS |
880 | |
881 | /* Define this if the maximum size of all the outgoing args is to be | |
882 | accumulated and pushed during the prologue. The amount can be | |
883 | found in the variable current_function_outgoing_args_size. */ | |
884 | #define ACCUMULATE_OUTGOING_ARGS | |
885 | ||
886 | /* Value is the number of bytes of arguments automatically | |
887 | popped when returning from a subroutine call. | |
8b109b37 | 888 | FUNDECL is the declaration node of the function (as a tree), |
f045b2c9 RS |
889 | FUNTYPE is the data type of the function (as a tree), |
890 | or for a library call it is an identifier node for the subroutine name. | |
891 | SIZE is the number of bytes of arguments passed on the stack. */ | |
892 | ||
8b109b37 | 893 | #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0 |
f045b2c9 RS |
894 | |
895 | /* Define how to find the value returned by a function. | |
896 | VALTYPE is the data type of the value (as a tree). | |
897 | If the precise function being called is known, FUNC is its FUNCTION_DECL; | |
898 | otherwise, FUNC is 0. | |
899 | ||
900 | On RS/6000 an integer value is in r3 and a floating-point value is in | |
d14a6d05 | 901 | fp1, unless -msoft-float. */ |
f045b2c9 RS |
902 | |
903 | #define FUNCTION_VALUE(VALTYPE, FUNC) \ | |
904 | gen_rtx (REG, TYPE_MODE (VALTYPE), \ | |
d14a6d05 | 905 | TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_HARD_FLOAT ? 33 : 3) |
f045b2c9 RS |
906 | |
907 | /* Define how to find the value returned by a library function | |
908 | assuming the value has mode MODE. */ | |
909 | ||
910 | #define LIBCALL_VALUE(MODE) \ | |
d14a6d05 | 911 | gen_rtx (REG, MODE, GET_MODE_CLASS (MODE) == MODE_FLOAT && TARGET_HARD_FLOAT ? 33 : 3) |
f045b2c9 RS |
912 | |
913 | /* The definition of this macro implies that there are cases where | |
914 | a scalar value cannot be returned in registers. | |
915 | ||
916 | For the RS/6000, any structure or union type is returned in memory. */ | |
917 | ||
918 | #define RETURN_IN_MEMORY(TYPE) \ | |
e419152d | 919 | (TYPE_MODE (TYPE) == BLKmode) |
f045b2c9 RS |
920 | |
921 | /* 1 if N is a possible register number for a function value | |
922 | as seen by the caller. | |
923 | ||
924 | On RS/6000, this is r3 and fp1. */ | |
925 | ||
926 | #define FUNCTION_VALUE_REGNO_P(N) ((N) == 3 || ((N) == 33)) | |
927 | ||
928 | /* 1 if N is a possible register number for function argument passing. | |
929 | On RS/6000, these are r3-r10 and fp1-fp13. */ | |
930 | ||
931 | #define FUNCTION_ARG_REGNO_P(N) \ | |
932 | (((N) <= 10 && (N) >= 3) || ((N) >= 33 && (N) <= 45)) | |
933 | \f | |
934 | /* Define a data type for recording info about an argument list | |
935 | during the scan of that argument list. This data type should | |
936 | hold all necessary information about the function itself | |
937 | and about the args processed so far, enough to enable macros | |
938 | such as FUNCTION_ARG to determine where the next arg should go. | |
939 | ||
940 | On the RS/6000, this is a structure. The first element is the number of | |
941 | total argument words, the second is used to store the next | |
942 | floating-point register number, and the third says how many more args we | |
943 | have prototype types for. */ | |
944 | ||
945 | struct rs6000_args {int words, fregno, nargs_prototype; }; | |
946 | #define CUMULATIVE_ARGS struct rs6000_args | |
947 | ||
948 | /* Define intermediate macro to compute the size (in registers) of an argument | |
949 | for the RS/6000. */ | |
950 | ||
951 | #define RS6000_ARG_SIZE(MODE, TYPE, NAMED) \ | |
952 | (! (NAMED) ? 0 \ | |
953 | : (MODE) != BLKmode \ | |
954 | ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD \ | |
955 | : (int_size_in_bytes (TYPE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD) | |
956 | ||
957 | /* Initialize a variable CUM of type CUMULATIVE_ARGS | |
958 | for a call to a function whose data type is FNTYPE. | |
959 | For a library call, FNTYPE is 0. */ | |
960 | ||
961 | #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \ | |
962 | (CUM).words = 0, \ | |
963 | (CUM).fregno = 33, \ | |
964 | (CUM).nargs_prototype = (FNTYPE && TYPE_ARG_TYPES (FNTYPE) \ | |
965 | ? (list_length (TYPE_ARG_TYPES (FNTYPE)) - 1 \ | |
966 | + (TYPE_MODE (TREE_TYPE (FNTYPE)) == BLKmode \ | |
967 | || RETURN_IN_MEMORY (TREE_TYPE (FNTYPE)))) \ | |
968 | : 0) | |
969 | ||
970 | /* Similar, but when scanning the definition of a procedure. We always | |
971 | set NARGS_PROTOTYPE large so we never return an EXPR_LIST. */ | |
972 | ||
973 | #define INIT_CUMULATIVE_INCOMING_ARGS(CUM,FNTYPE,IGNORE) \ | |
974 | (CUM).words = 0, \ | |
975 | (CUM).fregno = 33, \ | |
976 | (CUM).nargs_prototype = 1000 | |
977 | ||
978 | /* Update the data in CUM to advance over an argument | |
979 | of mode MODE and data type TYPE. | |
980 | (TYPE is null for libcalls where that information may not be available.) */ | |
981 | ||
982 | #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ | |
983 | { (CUM).nargs_prototype--; \ | |
984 | if (NAMED) \ | |
985 | { \ | |
986 | (CUM).words += RS6000_ARG_SIZE (MODE, TYPE, NAMED); \ | |
987 | if (GET_MODE_CLASS (MODE) == MODE_FLOAT) \ | |
988 | (CUM).fregno++; \ | |
989 | } \ | |
990 | } | |
991 | ||
992 | /* Non-zero if we can use a floating-point register to pass this arg. */ | |
993 | #define USE_FP_FOR_ARG_P(CUM,MODE,TYPE) \ | |
d14a6d05 | 994 | (GET_MODE_CLASS (MODE) == MODE_FLOAT && (CUM).fregno < 46 && TARGET_HARD_FLOAT) |
f045b2c9 RS |
995 | |
996 | /* Determine where to put an argument to a function. | |
997 | Value is zero to push the argument on the stack, | |
998 | or a hard register in which to store the argument. | |
999 | ||
1000 | MODE is the argument's machine mode. | |
1001 | TYPE is the data type of the argument (as a tree). | |
1002 | This is null for libcalls where that information may | |
1003 | not be available. | |
1004 | CUM is a variable of type CUMULATIVE_ARGS which gives info about | |
1005 | the preceding args and about the function being called. | |
1006 | NAMED is nonzero if this argument is a named parameter | |
1007 | (otherwise it is an extra parameter matching an ellipsis). | |
1008 | ||
1009 | On RS/6000 the first eight words of non-FP are normally in registers | |
1010 | and the rest are pushed. The first 13 FP args are in registers. | |
1011 | ||
1012 | If this is floating-point and no prototype is specified, we use | |
4d6697ca RK |
1013 | both an FP and integer register (or possibly FP reg and stack). Library |
1014 | functions (when TYPE is zero) always have the proper types for args, | |
1015 | so we can pass the FP value just in one register. emit_library_function | |
1016 | doesn't support EXPR_LIST anyway. */ | |
f045b2c9 RS |
1017 | |
1018 | #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ | |
1019 | (! (NAMED) ? 0 \ | |
38bd31fc | 1020 | : ((TYPE) != 0 && TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST) ? 0 \ |
d072107f | 1021 | : USE_FP_FOR_ARG_P (CUM, MODE, TYPE) \ |
4d6697ca | 1022 | ? ((CUM).nargs_prototype > 0 || (TYPE) == 0 \ |
f045b2c9 RS |
1023 | ? gen_rtx (REG, MODE, (CUM).fregno) \ |
1024 | : ((CUM).words < 8 \ | |
1025 | ? gen_rtx (EXPR_LIST, VOIDmode, \ | |
1026 | gen_rtx (REG, (MODE), 3 + (CUM).words), \ | |
1027 | gen_rtx (REG, (MODE), (CUM).fregno)) \ | |
1028 | : gen_rtx (EXPR_LIST, VOIDmode, 0, \ | |
1029 | gen_rtx (REG, (MODE), (CUM).fregno)))) \ | |
1030 | : (CUM).words < 8 ? gen_rtx(REG, (MODE), 3 + (CUM).words) : 0) | |
1031 | ||
1032 | /* For an arg passed partly in registers and partly in memory, | |
1033 | this is the number of registers used. | |
1034 | For args passed entirely in registers or entirely in memory, zero. */ | |
1035 | ||
1036 | #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ | |
1037 | (! (NAMED) ? 0 \ | |
1038 | : USE_FP_FOR_ARG_P (CUM, MODE, TYPE) && (CUM).nargs_prototype >= 0 ? 0 \ | |
1039 | : (((CUM).words < 8 \ | |
1040 | && 8 < ((CUM).words + RS6000_ARG_SIZE (MODE, TYPE, NAMED))) \ | |
1041 | ? 8 - (CUM).words : 0)) | |
1042 | ||
1043 | /* Perform any needed actions needed for a function that is receiving a | |
1044 | variable number of arguments. | |
1045 | ||
1046 | CUM is as above. | |
1047 | ||
1048 | MODE and TYPE are the mode and type of the current parameter. | |
1049 | ||
1050 | PRETEND_SIZE is a variable that should be set to the amount of stack | |
1051 | that must be pushed by the prolog to pretend that our caller pushed | |
1052 | it. | |
1053 | ||
1054 | Normally, this macro will push all remaining incoming registers on the | |
1055 | stack and set PRETEND_SIZE to the length of the registers pushed. */ | |
1056 | ||
1057 | #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \ | |
1058 | { if ((CUM).words < 8) \ | |
1059 | { \ | |
1060 | int first_reg_offset = (CUM).words; \ | |
1061 | \ | |
1062 | if (MUST_PASS_IN_STACK (MODE, TYPE)) \ | |
1063 | first_reg_offset += RS6000_ARG_SIZE (TYPE_MODE (TYPE), TYPE, 1); \ | |
1064 | \ | |
1065 | if (first_reg_offset > 8) \ | |
1066 | first_reg_offset = 8; \ | |
1067 | \ | |
1068 | if (! (NO_RTL) && first_reg_offset != 8) \ | |
1069 | move_block_from_reg \ | |
1070 | (3 + first_reg_offset, \ | |
1071 | gen_rtx (MEM, BLKmode, \ | |
1072 | plus_constant (virtual_incoming_args_rtx, \ | |
1073 | first_reg_offset * 4)), \ | |
02892e06 | 1074 | 8 - first_reg_offset, (8 - first_reg_offset) * UNITS_PER_WORD); \ |
f045b2c9 RS |
1075 | PRETEND_SIZE = (8 - first_reg_offset) * UNITS_PER_WORD; \ |
1076 | } \ | |
1077 | } | |
1078 | ||
1079 | /* This macro generates the assembly code for function entry. | |
1080 | FILE is a stdio stream to output the code to. | |
1081 | SIZE is an int: how many units of temporary storage to allocate. | |
1082 | Refer to the array `regs_ever_live' to determine which registers | |
1083 | to save; `regs_ever_live[I]' is nonzero if register number I | |
1084 | is ever used in the function. This macro is responsible for | |
1085 | knowing which registers should not be saved even if used. */ | |
1086 | ||
1087 | #define FUNCTION_PROLOGUE(FILE, SIZE) output_prolog (FILE, SIZE) | |
1088 | ||
1089 | /* Output assembler code to FILE to increment profiler label # LABELNO | |
58a39e45 | 1090 | for profiling a function entry. */ |
f045b2c9 RS |
1091 | |
1092 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
58a39e45 | 1093 | output_function_profiler ((FILE), (LABELNO)); |
f045b2c9 RS |
1094 | |
1095 | /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, | |
1096 | the stack pointer does not matter. No definition is equivalent to | |
1097 | always zero. | |
1098 | ||
1099 | On the RS/6000, this is non-zero because we can restore the stack from | |
1100 | its backpointer, which we maintain. */ | |
1101 | #define EXIT_IGNORE_STACK 1 | |
1102 | ||
1103 | /* This macro generates the assembly code for function exit, | |
1104 | on machines that need it. If FUNCTION_EPILOGUE is not defined | |
1105 | then individual return instructions are generated for each | |
1106 | return statement. Args are same as for FUNCTION_PROLOGUE. | |
1107 | ||
1108 | The function epilogue should not depend on the current stack pointer! | |
1109 | It should use the frame pointer only. This is mandatory because | |
1110 | of alloca; we also take advantage of it to omit stack adjustments | |
1111 | before returning. */ | |
1112 | ||
1113 | #define FUNCTION_EPILOGUE(FILE, SIZE) output_epilog (FILE, SIZE) | |
1114 | \f | |
1115 | /* Output assembler code for a block containing the constant parts | |
1116 | of a trampoline, leaving space for the variable parts. | |
1117 | ||
1118 | The trampoline should set the static chain pointer to value placed | |
1119 | into the trampoline and should branch to the specified routine. | |
1120 | ||
1121 | On the RS/6000, this is not code at all, but merely a data area, | |
1122 | since that is the way all functions are called. The first word is | |
1123 | the address of the function, the second word is the TOC pointer (r2), | |
1124 | and the third word is the static chain value. */ | |
1125 | ||
1126 | #define TRAMPOLINE_TEMPLATE(FILE) { fprintf (FILE, "\t.long 0, 0, 0\n"); } | |
1127 | ||
1128 | /* Length in units of the trampoline for entering a nested function. */ | |
1129 | ||
1130 | #define TRAMPOLINE_SIZE 12 | |
1131 | ||
1132 | /* Emit RTL insns to initialize the variable parts of a trampoline. | |
1133 | FNADDR is an RTX for the address of the function's pure code. | |
1134 | CXT is an RTX for the static chain value for the function. */ | |
1135 | ||
1136 | #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \ | |
1137 | { \ | |
f045b2c9 | 1138 | emit_move_insn (gen_rtx (MEM, SImode, \ |
858b728c RK |
1139 | memory_address (SImode, (ADDR))), \ |
1140 | gen_rtx (MEM, SImode, \ | |
1141 | memory_address (SImode, (FNADDR)))); \ | |
f045b2c9 | 1142 | emit_move_insn (gen_rtx (MEM, SImode, \ |
858b728c RK |
1143 | memory_address (SImode, \ |
1144 | plus_constant ((ADDR), 4))), \ | |
1145 | gen_rtx (MEM, SImode, \ | |
1146 | memory_address (SImode, \ | |
1147 | plus_constant ((FNADDR), 4)))); \ | |
1148 | emit_move_insn (gen_rtx (MEM, SImode, \ | |
1149 | memory_address (SImode, \ | |
1150 | plus_constant ((ADDR), 8))), \ | |
1151 | force_reg (SImode, (CXT))); \ | |
f045b2c9 RS |
1152 | } |
1153 | \f | |
f33985c6 MS |
1154 | /* Definitions for __builtin_return_address and __builtin_frame_address. |
1155 | __builtin_return_address (0) should give link register (65), enable | |
1156 | this. */ | |
1157 | /* This should be uncommented, so that the link register is used, but | |
1158 | currently this would result in unmatched insns and spilling fixed | |
1159 | registers so we'll leave it for another day. When these problems are | |
1160 | taken care of one additional fetch will be necessary in RETURN_ADDR_RTX. | |
1161 | (mrs) */ | |
1162 | /* #define RETURN_ADDR_IN_PREVIOUS_FRAME */ | |
1163 | /* The current return address is in link register (65). The return address | |
1164 | of anything farther back is accessed normally at an offset of 8 from the | |
1165 | frame pointer. */ | |
1166 | #define RETURN_ADDR_RTX(count, frame) \ | |
1167 | ((count == -1) \ | |
1168 | ? gen_rtx (REG, Pmode, 65) \ | |
1169 | : copy_to_reg (gen_rtx (MEM, Pmode, \ | |
1170 | memory_address (Pmode, \ | |
1171 | plus_constant (copy_to_reg (gen_rtx (MEM, Pmode, \ | |
1172 | memory_address (Pmode, frame))), \ | |
1173 | 8))))) | |
1174 | \f | |
f045b2c9 RS |
1175 | /* Definitions for register eliminations. |
1176 | ||
1177 | We have two registers that can be eliminated on the RS/6000. First, the | |
1178 | frame pointer register can often be eliminated in favor of the stack | |
1179 | pointer register. Secondly, the argument pointer register can always be | |
642a35f1 JW |
1180 | eliminated; it is replaced with either the stack or frame pointer. |
1181 | ||
1182 | In addition, we use the elimination mechanism to see if r30 is needed | |
1183 | Initially we assume that it isn't. If it is, we spill it. This is done | |
1184 | by making it an eliminable register. We replace it with itself so that | |
1185 | if it isn't needed, then existing uses won't be modified. */ | |
f045b2c9 RS |
1186 | |
1187 | /* This is an array of structures. Each structure initializes one pair | |
1188 | of eliminable registers. The "from" register number is given first, | |
1189 | followed by "to". Eliminations of the same "from" register are listed | |
1190 | in order of preference. */ | |
1191 | #define ELIMINABLE_REGS \ | |
1192 | {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
1193 | { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
642a35f1 JW |
1194 | { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ |
1195 | { 30, 30} } | |
f045b2c9 RS |
1196 | |
1197 | /* Given FROM and TO register numbers, say whether this elimination is allowed. | |
1198 | Frame pointer elimination is automatically handled. | |
1199 | ||
1200 | For the RS/6000, if frame pointer elimination is being done, we would like | |
642a35f1 JW |
1201 | to convert ap into fp, not sp. |
1202 | ||
1203 | We need r30 if -mmininal-toc was specified, and there are constant pool | |
1204 | references. */ | |
f045b2c9 RS |
1205 | |
1206 | #define CAN_ELIMINATE(FROM, TO) \ | |
1207 | ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \ | |
1208 | ? ! frame_pointer_needed \ | |
642a35f1 | 1209 | : (FROM) == 30 ? ! TARGET_MINIMAL_TOC || get_pool_size () == 0 \ |
f045b2c9 RS |
1210 | : 1) |
1211 | ||
1212 | /* Define the offset between two registers, one to be eliminated, and the other | |
1213 | its replacement, at the start of a routine. */ | |
1214 | #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ | |
1215 | { \ | |
1216 | int total_stack_size = (rs6000_sa_size () + get_frame_size () \ | |
1217 | + current_function_outgoing_args_size); \ | |
1218 | \ | |
1219 | total_stack_size = (total_stack_size + 7) & ~7; \ | |
1220 | \ | |
1221 | if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \ | |
1222 | { \ | |
1223 | if (rs6000_pushes_stack ()) \ | |
1224 | (OFFSET) = 0; \ | |
1225 | else \ | |
1226 | (OFFSET) = - total_stack_size; \ | |
1227 | } \ | |
1228 | else if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \ | |
1229 | (OFFSET) = total_stack_size; \ | |
1230 | else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \ | |
1231 | { \ | |
1232 | if (rs6000_pushes_stack ()) \ | |
1233 | (OFFSET) = total_stack_size; \ | |
1234 | else \ | |
1235 | (OFFSET) = 0; \ | |
1236 | } \ | |
642a35f1 JW |
1237 | else if ((FROM) == 30) \ |
1238 | (OFFSET) = 0; \ | |
f045b2c9 RS |
1239 | else \ |
1240 | abort (); \ | |
1241 | } | |
1242 | \f | |
1243 | /* Addressing modes, and classification of registers for them. */ | |
1244 | ||
1245 | /* #define HAVE_POST_INCREMENT */ | |
1246 | /* #define HAVE_POST_DECREMENT */ | |
1247 | ||
1248 | #define HAVE_PRE_DECREMENT | |
1249 | #define HAVE_PRE_INCREMENT | |
1250 | ||
1251 | /* Macros to check register numbers against specific register classes. */ | |
1252 | ||
1253 | /* These assume that REGNO is a hard or pseudo reg number. | |
1254 | They give nonzero only if REGNO is a hard reg of the suitable class | |
1255 | or a pseudo reg currently allocated to a suitable hard reg. | |
1256 | Since they use reg_renumber, they are safe only once reg_renumber | |
1257 | has been allocated, which happens in local-alloc.c. */ | |
1258 | ||
1259 | #define REGNO_OK_FOR_INDEX_P(REGNO) \ | |
1260 | ((REGNO) < FIRST_PSEUDO_REGISTER \ | |
1261 | ? (REGNO) <= 31 || (REGNO) == 67 \ | |
1262 | : (reg_renumber[REGNO] >= 0 \ | |
1263 | && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67))) | |
1264 | ||
1265 | #define REGNO_OK_FOR_BASE_P(REGNO) \ | |
1266 | ((REGNO) < FIRST_PSEUDO_REGISTER \ | |
1267 | ? ((REGNO) > 0 && (REGNO) <= 31) || (REGNO) == 67 \ | |
1268 | : (reg_renumber[REGNO] > 0 \ | |
1269 | && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67))) | |
1270 | \f | |
1271 | /* Maximum number of registers that can appear in a valid memory address. */ | |
1272 | ||
1273 | #define MAX_REGS_PER_ADDRESS 2 | |
1274 | ||
1275 | /* Recognize any constant value that is a valid address. */ | |
1276 | ||
6eff269e BK |
1277 | #define CONSTANT_ADDRESS_P(X) \ |
1278 | (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ | |
1279 | || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ | |
1280 | || GET_CODE (X) == HIGH) | |
f045b2c9 RS |
1281 | |
1282 | /* Nonzero if the constant value X is a legitimate general operand. | |
1283 | It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. | |
1284 | ||
1285 | On the RS/6000, all integer constants are acceptable, most won't be valid | |
1286 | for particular insns, though. Only easy FP constants are | |
1287 | acceptable. */ | |
1288 | ||
1289 | #define LEGITIMATE_CONSTANT_P(X) \ | |
1290 | (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode \ | |
1291 | || easy_fp_constant (X, GET_MODE (X))) | |
1292 | ||
1293 | /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx | |
1294 | and check its validity for a certain class. | |
1295 | We have two alternate definitions for each of them. | |
1296 | The usual definition accepts all pseudo regs; the other rejects | |
1297 | them unless they have been allocated suitable hard regs. | |
1298 | The symbol REG_OK_STRICT causes the latter definition to be used. | |
1299 | ||
1300 | Most source files want to accept pseudo regs in the hope that | |
1301 | they will get allocated to the class that the insn wants them to be in. | |
1302 | Source files for reload pass need to be strict. | |
1303 | After reload, it makes no difference, since pseudo regs have | |
1304 | been eliminated by then. */ | |
1305 | ||
1306 | #ifndef REG_OK_STRICT | |
1307 | ||
1308 | /* Nonzero if X is a hard reg that can be used as an index | |
1309 | or if it is a pseudo reg. */ | |
1310 | #define REG_OK_FOR_INDEX_P(X) \ | |
1311 | (REGNO (X) <= 31 || REGNO (X) == 67 || REGNO (X) >= FIRST_PSEUDO_REGISTER) | |
1312 | ||
1313 | /* Nonzero if X is a hard reg that can be used as a base reg | |
1314 | or if it is a pseudo reg. */ | |
1315 | #define REG_OK_FOR_BASE_P(X) \ | |
1316 | (REGNO (X) > 0 && REG_OK_FOR_INDEX_P (X)) | |
1317 | ||
1318 | #else | |
1319 | ||
1320 | /* Nonzero if X is a hard reg that can be used as an index. */ | |
1321 | #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) | |
1322 | /* Nonzero if X is a hard reg that can be used as a base reg. */ | |
1323 | #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) | |
1324 | ||
1325 | #endif | |
1326 | \f | |
1327 | /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression | |
1328 | that is a valid memory address for an instruction. | |
1329 | The MODE argument is the machine mode for the MEM expression | |
1330 | that wants to use this address. | |
1331 | ||
1332 | On the RS/6000, there are four valid address: a SYMBOL_REF that | |
1333 | refers to a constant pool entry of an address (or the sum of it | |
1334 | plus a constant), a short (16-bit signed) constant plus a register, | |
1335 | the sum of two registers, or a register indirect, possibly with an | |
1336 | auto-increment. For DFmode and DImode with an constant plus register, | |
1337 | we must ensure that both words are addressable. */ | |
1338 | ||
1339 | #define LEGITIMATE_CONSTANT_POOL_BASE_P(X) \ | |
1340 | (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X) \ | |
1341 | && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (X))) | |
1342 | ||
1343 | #define LEGITIMATE_CONSTANT_POOL_ADDRESS_P(X) \ | |
1344 | (LEGITIMATE_CONSTANT_POOL_BASE_P (X) \ | |
1345 | || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ | |
1346 | && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \ | |
1347 | && LEGITIMATE_CONSTANT_POOL_BASE_P (XEXP (XEXP (X, 0), 0)))) | |
1348 | ||
1349 | #define LEGITIMATE_ADDRESS_INTEGER_P(X,OFFSET) \ | |
1350 | (GET_CODE (X) == CONST_INT \ | |
1351 | && (unsigned) (INTVAL (X) + (OFFSET) + 0x8000) < 0x10000) | |
1352 | ||
1353 | #define LEGITIMATE_OFFSET_ADDRESS_P(MODE,X) \ | |
1354 | (GET_CODE (X) == PLUS \ | |
1355 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1356 | && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1357 | && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 0) \ | |
1358 | && (((MODE) != DFmode && (MODE) != DImode) \ | |
1359 | || LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 4))) | |
1360 | ||
1361 | #define LEGITIMATE_INDEXED_ADDRESS_P(X) \ | |
1362 | (GET_CODE (X) == PLUS \ | |
1363 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1364 | && GET_CODE (XEXP (X, 1)) == REG \ | |
1365 | && ((REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1366 | && REG_OK_FOR_INDEX_P (XEXP (X, 1))) \ | |
1367 | || (REG_OK_FOR_BASE_P (XEXP (X, 1)) \ | |
1368 | && REG_OK_FOR_INDEX_P (XEXP (X, 0))))) | |
1369 | ||
1370 | #define LEGITIMATE_INDIRECT_ADDRESS_P(X) \ | |
1371 | (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) | |
1372 | ||
1373 | #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ | |
1374 | { if (LEGITIMATE_INDIRECT_ADDRESS_P (X)) \ | |
1375 | goto ADDR; \ | |
1376 | if (GET_CODE (X) == PRE_INC \ | |
1377 | && LEGITIMATE_INDIRECT_ADDRESS_P (XEXP (X, 0))) \ | |
1378 | goto ADDR; \ | |
1379 | if (GET_CODE (X) == PRE_DEC \ | |
1380 | && LEGITIMATE_INDIRECT_ADDRESS_P (XEXP (X, 0))) \ | |
1381 | goto ADDR; \ | |
1382 | if (LEGITIMATE_CONSTANT_POOL_ADDRESS_P (X)) \ | |
1383 | goto ADDR; \ | |
1384 | if (LEGITIMATE_OFFSET_ADDRESS_P (MODE, X)) \ | |
1385 | goto ADDR; \ | |
1386 | if ((MODE) != DImode && (MODE) != TImode \ | |
d14a6d05 | 1387 | && (TARGET_HARD_FLOAT || (MODE) != DFmode) \ |
f045b2c9 RS |
1388 | && LEGITIMATE_INDEXED_ADDRESS_P (X)) \ |
1389 | goto ADDR; \ | |
1390 | } | |
1391 | \f | |
1392 | /* Try machine-dependent ways of modifying an illegitimate address | |
1393 | to be legitimate. If we find one, return the new, valid address. | |
1394 | This macro is used in only one place: `memory_address' in explow.c. | |
1395 | ||
1396 | OLDX is the address as it was before break_out_memory_refs was called. | |
1397 | In some cases it is useful to look at this to decide what needs to be done. | |
1398 | ||
1399 | MODE and WIN are passed so that this macro can use | |
1400 | GO_IF_LEGITIMATE_ADDRESS. | |
1401 | ||
1402 | It is always safe for this macro to do nothing. It exists to recognize | |
1403 | opportunities to optimize the output. | |
1404 | ||
1405 | On RS/6000, first check for the sum of a register with a constant | |
1406 | integer that is out of range. If so, generate code to add the | |
1407 | constant with the low-order 16 bits masked to the register and force | |
1408 | this result into another register (this can be done with `cau'). | |
1409 | Then generate an address of REG+(CONST&0xffff), allowing for the | |
1410 | possibility of bit 16 being a one. | |
1411 | ||
1412 | Then check for the sum of a register and something not constant, try to | |
1413 | load the other things into a register and return the sum. */ | |
1414 | ||
1415 | #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \ | |
1416 | { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \ | |
1417 | && GET_CODE (XEXP (X, 1)) == CONST_INT \ | |
1418 | && (unsigned) (INTVAL (XEXP (X, 1)) + 0x8000) >= 0x10000) \ | |
1419 | { int high_int, low_int; \ | |
1420 | high_int = INTVAL (XEXP (X, 1)) >> 16; \ | |
1421 | low_int = INTVAL (XEXP (X, 1)) & 0xffff; \ | |
1422 | if (low_int & 0x8000) \ | |
1423 | high_int += 1, low_int |= 0xffff0000; \ | |
1424 | (X) = gen_rtx (PLUS, SImode, \ | |
1425 | force_operand \ | |
1426 | (gen_rtx (PLUS, SImode, XEXP (X, 0), \ | |
1427 | gen_rtx (CONST_INT, VOIDmode, \ | |
1428 | high_int << 16)), 0),\ | |
1429 | gen_rtx (CONST_INT, VOIDmode, low_int)); \ | |
f357808b | 1430 | goto WIN; \ |
f045b2c9 RS |
1431 | } \ |
1432 | else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \ | |
27a2a2f1 | 1433 | && GET_CODE (XEXP (X, 1)) != CONST_INT \ |
17ea6633 | 1434 | && (TARGET_HARD_FLOAT || (MODE) != DFmode) \ |
27a2a2f1 | 1435 | && (MODE) != DImode && (MODE) != TImode) \ |
f357808b RK |
1436 | { \ |
1437 | (X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \ | |
1438 | force_reg (SImode, force_operand (XEXP (X, 1), 0))); \ | |
1439 | goto WIN; \ | |
1440 | } \ | |
f045b2c9 RS |
1441 | } |
1442 | ||
1443 | /* Go to LABEL if ADDR (a legitimate address expression) | |
1444 | has an effect that depends on the machine mode it is used for. | |
1445 | ||
1446 | On the RS/6000 this is true if the address is valid with a zero offset | |
1447 | but not with an offset of four (this means it cannot be used as an | |
1448 | address for DImode or DFmode) or is a pre-increment or decrement. Since | |
1449 | we know it is valid, we just check for an address that is not valid with | |
1450 | an offset of four. */ | |
1451 | ||
1452 | #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ | |
1453 | { if (GET_CODE (ADDR) == PLUS \ | |
1454 | && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), 0) \ | |
1455 | && ! LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), 4)) \ | |
1456 | goto LABEL; \ | |
1457 | if (GET_CODE (ADDR) == PRE_INC) \ | |
1458 | goto LABEL; \ | |
1459 | if (GET_CODE (ADDR) == PRE_DEC) \ | |
1460 | goto LABEL; \ | |
1461 | } | |
1462 | \f | |
1463 | /* Define this if some processing needs to be done immediately before | |
4255474b | 1464 | emitting code for an insn. */ |
f045b2c9 | 1465 | |
4255474b | 1466 | /* #define FINAL_PRESCAN_INSN(INSN,OPERANDS,NOPERANDS) */ |
f045b2c9 RS |
1467 | |
1468 | /* Specify the machine mode that this machine uses | |
1469 | for the index in the tablejump instruction. */ | |
1470 | #define CASE_VECTOR_MODE SImode | |
1471 | ||
1472 | /* Define this if the tablejump instruction expects the table | |
1473 | to contain offsets from the address of the table. | |
1474 | Do not define this if the table should contain absolute addresses. */ | |
1475 | #define CASE_VECTOR_PC_RELATIVE | |
1476 | ||
1477 | /* Specify the tree operation to be used to convert reals to integers. */ | |
1478 | #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR | |
1479 | ||
1480 | /* This is the kind of divide that is easiest to do in the general case. */ | |
1481 | #define EASY_DIV_EXPR TRUNC_DIV_EXPR | |
1482 | ||
1483 | /* Define this as 1 if `char' should by default be signed; else as 0. */ | |
1484 | #define DEFAULT_SIGNED_CHAR 0 | |
1485 | ||
1486 | /* This flag, if defined, says the same insns that convert to a signed fixnum | |
1487 | also convert validly to an unsigned one. */ | |
1488 | ||
1489 | /* #define FIXUNS_TRUNC_LIKE_FIX_TRUNC */ | |
1490 | ||
1491 | /* Max number of bytes we can move from memory to memory | |
1492 | in one reasonably fast instruction. */ | |
7e69e155 MM |
1493 | #define MOVE_MAX (TARGET_POWERPC64 ? 8 : 4) |
1494 | #define MAX_MOVE_MAX 8 | |
f045b2c9 RS |
1495 | |
1496 | /* Nonzero if access to memory by bytes is no faster than for words. | |
1497 | Also non-zero if doing byte operations (specifically shifts) in registers | |
1498 | is undesirable. */ | |
1499 | #define SLOW_BYTE_ACCESS 1 | |
1500 | ||
9a63901f RK |
1501 | /* Define if operations between registers always perform the operation |
1502 | on the full register even if a narrower mode is specified. */ | |
1503 | #define WORD_REGISTER_OPERATIONS | |
1504 | ||
1505 | /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD | |
1506 | will either zero-extend or sign-extend. The value of this macro should | |
1507 | be the code that says which one of the two operations is implicitly | |
1508 | done, NIL if none. */ | |
1509 | #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND | |
225211e2 RK |
1510 | |
1511 | /* Define if loading short immediate values into registers sign extends. */ | |
1512 | #define SHORT_IMMEDIATES_SIGN_EXTEND | |
fdaff8ba RS |
1513 | \f |
1514 | /* The RS/6000 uses the XCOFF format. */ | |
f045b2c9 | 1515 | |
fdaff8ba | 1516 | #define XCOFF_DEBUGGING_INFO |
f045b2c9 | 1517 | |
c5abcf1d CH |
1518 | /* Define if the object format being used is COFF or a superset. */ |
1519 | #define OBJECT_FORMAT_COFF | |
1520 | ||
2c440f06 RK |
1521 | /* Define the magic numbers that we recognize as COFF. */ |
1522 | ||
1523 | #define MY_ISCOFF(magic) \ | |
1524 | ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC || (magic) == U802TOCMAGIC) | |
1525 | ||
115e69a9 RK |
1526 | /* This is the only version of nm that collect2 can work with. */ |
1527 | #define REAL_NM_FILE_NAME "/usr/ucb/nm" | |
1528 | ||
f045b2c9 RS |
1529 | /* We don't have GAS for the RS/6000 yet, so don't write out special |
1530 | .stabs in cc1plus. */ | |
1531 | ||
1532 | #define FASCIST_ASSEMBLER | |
1533 | ||
f045b2c9 RS |
1534 | /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits |
1535 | is done just by pretending it is already truncated. */ | |
1536 | #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 | |
1537 | ||
1538 | /* Specify the machine mode that pointers have. | |
1539 | After generation of rtl, the compiler makes no further distinction | |
1540 | between pointers and any other objects of this machine mode. */ | |
9e654916 | 1541 | #define Pmode (TARGET_64BIT ? DImode : SImode) |
f045b2c9 RS |
1542 | |
1543 | /* Mode of a function address in a call instruction (for indexing purposes). | |
1544 | ||
1545 | Doesn't matter on RS/6000. */ | |
9e654916 | 1546 | #define FUNCTION_MODE (TARGET_64BIT ? DImode : SImode) |
f045b2c9 RS |
1547 | |
1548 | /* Define this if addresses of constant functions | |
1549 | shouldn't be put through pseudo regs where they can be cse'd. | |
1550 | Desirable on machines where ordinary constants are expensive | |
1551 | but a CALL with constant address is cheap. */ | |
1552 | #define NO_FUNCTION_CSE | |
1553 | ||
d969caf8 | 1554 | /* Define this to be nonzero if shift instructions ignore all but the low-order |
6febd581 RK |
1555 | few bits. |
1556 | ||
1557 | The sle and sre instructions which allow SHIFT_COUNT_TRUNCATED | |
1558 | have been dropped from the PowerPC architecture. */ | |
1559 | ||
1560 | #define SHIFT_COUNT_TRUNCATED TARGET_POWER ? 1 : 0 | |
f045b2c9 RS |
1561 | |
1562 | /* Use atexit for static constructors/destructors, instead of defining | |
1563 | our own exit function. */ | |
1564 | #define HAVE_ATEXIT | |
1565 | ||
1566 | /* Compute the cost of computing a constant rtl expression RTX | |
1567 | whose rtx-code is CODE. The body of this macro is a portion | |
1568 | of a switch statement. If the code is computed here, | |
1569 | return it with a return statement. Otherwise, break from the switch. | |
1570 | ||
01554f00 | 1571 | On the RS/6000, if it is valid in the insn, it is free. So this |
f045b2c9 RS |
1572 | always returns 0. */ |
1573 | ||
3bb22aee | 1574 | #define CONST_COSTS(RTX,CODE,OUTER_CODE) \ |
f045b2c9 RS |
1575 | case CONST_INT: \ |
1576 | case CONST: \ | |
1577 | case LABEL_REF: \ | |
1578 | case SYMBOL_REF: \ | |
1579 | case CONST_DOUBLE: \ | |
1580 | return 0; | |
1581 | ||
1582 | /* Provide the costs of a rtl expression. This is in the body of a | |
1583 | switch on CODE. */ | |
1584 | ||
3bb22aee | 1585 | #define RTX_COSTS(X,CODE,OUTER_CODE) \ |
f045b2c9 | 1586 | case MULT: \ |
bdfd4e31 RK |
1587 | switch (rs6000_cpu) \ |
1588 | { \ | |
1589 | case PROCESSOR_RIOS1: \ | |
1590 | return (GET_CODE (XEXP (X, 1)) != CONST_INT \ | |
1591 | ? COSTS_N_INSNS (5) \ | |
1592 | : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \ | |
1593 | ? COSTS_N_INSNS (3) : COSTS_N_INSNS (4)); \ | |
1594 | case PROCESSOR_RIOS2: \ | |
1595 | return COSTS_N_INSNS (2); \ | |
1596 | case PROCESSOR_PPC601: \ | |
1597 | case PROCESSOR_PPC603: \ | |
869c489d | 1598 | return COSTS_N_INSNS (5); \ |
49a0b204 | 1599 | case PROCESSOR_PPC403: \ |
bdfd4e31 RK |
1600 | case PROCESSOR_PPC604: \ |
1601 | case PROCESSOR_PPC620: \ | |
869c489d | 1602 | return COSTS_N_INSNS (4); \ |
bdfd4e31 | 1603 | } \ |
f045b2c9 RS |
1604 | case DIV: \ |
1605 | case MOD: \ | |
1606 | if (GET_CODE (XEXP (X, 1)) == CONST_INT \ | |
1607 | && exact_log2 (INTVAL (XEXP (X, 1))) >= 0) \ | |
1608 | return COSTS_N_INSNS (2); \ | |
1609 | /* otherwise fall through to normal divide. */ \ | |
1610 | case UDIV: \ | |
1611 | case UMOD: \ | |
bdfd4e31 RK |
1612 | switch (rs6000_cpu) \ |
1613 | { \ | |
1614 | case PROCESSOR_RIOS1: \ | |
1615 | return COSTS_N_INSNS (19); \ | |
1616 | case PROCESSOR_RIOS2: \ | |
1617 | return COSTS_N_INSNS (13); \ | |
49a0b204 MM |
1618 | case PROCESSOR_PPC403: \ |
1619 | return COSTS_N_INSNS (33); \ | |
bdfd4e31 | 1620 | case PROCESSOR_PPC601: \ |
869c489d | 1621 | return COSTS_N_INSNS (36); \ |
bdfd4e31 | 1622 | case PROCESSOR_PPC603: \ |
869c489d | 1623 | return COSTS_N_INSNS (37); \ |
bdfd4e31 RK |
1624 | case PROCESSOR_PPC604: \ |
1625 | case PROCESSOR_PPC620: \ | |
869c489d | 1626 | return COSTS_N_INSNS (20); \ |
bdfd4e31 | 1627 | } \ |
3a942930 RK |
1628 | case FFS: \ |
1629 | return COSTS_N_INSNS (4); \ | |
f045b2c9 RS |
1630 | case MEM: \ |
1631 | /* MEM should be slightly more expensive than (plus (reg) (const)) */ \ | |
1632 | return 5; | |
1633 | ||
1634 | /* Compute the cost of an address. This is meant to approximate the size | |
1635 | and/or execution delay of an insn using that address. If the cost is | |
1636 | approximated by the RTL complexity, including CONST_COSTS above, as | |
1637 | is usually the case for CISC machines, this macro should not be defined. | |
1638 | For aggressively RISCy machines, only one insn format is allowed, so | |
1639 | this macro should be a constant. The value of this macro only matters | |
1640 | for valid addresses. | |
1641 | ||
1642 | For the RS/6000, everything is cost 0. */ | |
1643 | ||
1644 | #define ADDRESS_COST(RTX) 0 | |
1645 | ||
1646 | /* Adjust the length of an INSN. LENGTH is the currently-computed length and | |
1647 | should be adjusted to reflect any required changes. This macro is used when | |
1648 | there is some systematic length adjustment required that would be difficult | |
1649 | to express in the length attribute. */ | |
1650 | ||
1651 | /* #define ADJUST_INSN_LENGTH(X,LENGTH) */ | |
1652 | ||
1653 | /* Add any extra modes needed to represent the condition code. | |
1654 | ||
1655 | For the RS/6000, we need separate modes when unsigned (logical) comparisons | |
c5defebb RK |
1656 | are being done and we need a separate mode for floating-point. We also |
1657 | use a mode for the case when we are comparing the results of two | |
1658 | comparisons. */ | |
f045b2c9 | 1659 | |
c5defebb | 1660 | #define EXTRA_CC_MODES CCUNSmode, CCFPmode, CCEQmode |
f045b2c9 RS |
1661 | |
1662 | /* Define the names for the modes specified above. */ | |
c5defebb | 1663 | #define EXTRA_CC_NAMES "CCUNS", "CCFP", "CCEQ" |
f045b2c9 RS |
1664 | |
1665 | /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, | |
1666 | return the mode to be used for the comparison. For floating-point, CCFPmode | |
c5defebb RK |
1667 | should be used. CCUNSmode should be used for unsigned comparisons. |
1668 | CCEQmode should be used when we are doing an inequality comparison on | |
1669 | the result of a comparison. CCmode should be used in all other cases. */ | |
1670 | ||
b565a316 | 1671 | #define SELECT_CC_MODE(OP,X,Y) \ |
f045b2c9 | 1672 | (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CCFPmode \ |
c5defebb RK |
1673 | : (OP) == GTU || (OP) == LTU || (OP) == GEU || (OP) == LEU ? CCUNSmode \ |
1674 | : (((OP) == EQ || (OP) == NE) && GET_RTX_CLASS (GET_CODE (X)) == '<' \ | |
1675 | ? CCEQmode : CCmode)) | |
f045b2c9 RS |
1676 | |
1677 | /* Define the information needed to generate branch and scc insns. This is | |
1678 | stored from the compare operation. Note that we can't use "rtx" here | |
1679 | since it hasn't been defined! */ | |
1680 | ||
1681 | extern struct rtx_def *rs6000_compare_op0, *rs6000_compare_op1; | |
1682 | extern int rs6000_compare_fp_p; | |
1683 | ||
1684 | /* Set to non-zero by "fix" operation to indicate that itrunc and | |
1685 | uitrunc must be defined. */ | |
1686 | ||
1687 | extern int rs6000_trunc_used; | |
9929b575 ILT |
1688 | |
1689 | /* Function names to call to do floating point truncation. */ | |
1690 | ||
1691 | #define RS6000_ITRUNC "itrunc" | |
1692 | #define RS6000_UITRUNC "uitrunc" | |
4d30c363 MM |
1693 | |
1694 | /* Prefix and suffix to use to saving floating point */ | |
1695 | #ifndef SAVE_FP_PREFIX | |
1696 | #define SAVE_FP_PREFIX "._savef" | |
1697 | #define SAVE_FP_SUFFIX "" | |
1698 | #endif | |
1699 | ||
1700 | /* Prefix and suffix to use to restoring floating point */ | |
1701 | #ifndef RESTORE_FP_PREFIX | |
1702 | #define RESTORE_FP_PREFIX "._restf" | |
1703 | #define RESTORE_FP_SUFFIX "" | |
1704 | #endif | |
1705 | ||
f045b2c9 RS |
1706 | \f |
1707 | /* Control the assembler format that we output. */ | |
1708 | ||
1709 | /* Output at beginning of assembler file. | |
1710 | ||
b4d6689b | 1711 | Initialize the section names for the RS/6000 at this point. |
fdaff8ba | 1712 | |
6355b140 | 1713 | Specify filename to assembler. |
3fc2151d | 1714 | |
b4d6689b | 1715 | We want to go into the TOC section so at least one .toc will be emitted. |
fdaff8ba | 1716 | Also, in order to output proper .bs/.es pairs, we need at least one static |
b4d6689b RK |
1717 | [RW] section emitted. |
1718 | ||
1719 | We then switch back to text to force the gcc2_compiled. label and the space | |
1720 | allocated after it (when profiling) into the text section. | |
1721 | ||
1722 | Finally, declare mcount when profiling to make the assembler happy. */ | |
f045b2c9 RS |
1723 | |
1724 | #define ASM_FILE_START(FILE) \ | |
1725 | { \ | |
fdaff8ba | 1726 | rs6000_gen_section_name (&xcoff_bss_section_name, \ |
f045b2c9 | 1727 | main_input_filename, ".bss_"); \ |
fdaff8ba | 1728 | rs6000_gen_section_name (&xcoff_private_data_section_name, \ |
f045b2c9 | 1729 | main_input_filename, ".rw_"); \ |
fdaff8ba | 1730 | rs6000_gen_section_name (&xcoff_read_only_section_name, \ |
f045b2c9 RS |
1731 | main_input_filename, ".ro_"); \ |
1732 | \ | |
6355b140 | 1733 | output_file_directive (FILE, main_input_filename); \ |
f045b2c9 | 1734 | toc_section (); \ |
fdaff8ba RS |
1735 | if (write_symbols != NO_DEBUG) \ |
1736 | private_data_section (); \ | |
b4d6689b RK |
1737 | text_section (); \ |
1738 | if (profile_flag) \ | |
1739 | fprintf (FILE, "\t.extern .mcount\n"); \ | |
f045b2c9 RS |
1740 | } |
1741 | ||
1742 | /* Output at end of assembler file. | |
1743 | ||
1744 | On the RS/6000, referencing data should automatically pull in text. */ | |
1745 | ||
1746 | #define ASM_FILE_END(FILE) \ | |
1747 | { \ | |
1748 | text_section (); \ | |
1749 | fprintf (FILE, "_section_.text:\n"); \ | |
1750 | data_section (); \ | |
1751 | fprintf (FILE, "\t.long _section_.text\n"); \ | |
1752 | } | |
1753 | ||
f045b2c9 RS |
1754 | /* We define this to prevent the name mangler from putting dollar signs into |
1755 | function names. */ | |
1756 | ||
1757 | #define NO_DOLLAR_IN_LABEL | |
1758 | ||
1759 | /* We define this to 0 so that gcc will never accept a dollar sign in a | |
1760 | variable name. This is needed because the AIX assembler will not accept | |
1761 | dollar signs. */ | |
1762 | ||
1763 | #define DOLLARS_IN_IDENTIFIERS 0 | |
1764 | ||
fdaff8ba RS |
1765 | /* Implicit library calls should use memcpy, not bcopy, etc. */ |
1766 | ||
1767 | #define TARGET_MEM_FUNCTIONS | |
1768 | ||
f045b2c9 RS |
1769 | /* Define the extra sections we need. We define three: one is the read-only |
1770 | data section which is used for constants. This is a csect whose name is | |
1771 | derived from the name of the input file. The second is for initialized | |
1772 | global variables. This is a csect whose name is that of the variable. | |
1773 | The third is the TOC. */ | |
1774 | ||
1775 | #define EXTRA_SECTIONS \ | |
1776 | read_only_data, private_data, read_only_private_data, toc, bss | |
1777 | ||
1778 | /* Define the name of our readonly data section. */ | |
1779 | ||
1780 | #define READONLY_DATA_SECTION read_only_data_section | |
1781 | ||
b4f892eb RK |
1782 | /* If we are referencing a function that is static or is known to be |
1783 | in this file, make the SYMBOL_REF special. We can use this to indicate | |
1784 | that we can branch to this function without emitting a no-op after the | |
1785 | call. */ | |
1786 | ||
1787 | #define ENCODE_SECTION_INFO(DECL) \ | |
1788 | if (TREE_CODE (DECL) == FUNCTION_DECL \ | |
1789 | && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))) \ | |
1790 | SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; | |
1791 | ||
f045b2c9 RS |
1792 | /* Indicate that jump tables go in the text section. */ |
1793 | ||
1794 | #define JUMP_TABLES_IN_TEXT_SECTION | |
1795 | ||
1796 | /* Define the routines to implement these extra sections. */ | |
1797 | ||
1798 | #define EXTRA_SECTION_FUNCTIONS \ | |
1799 | \ | |
1800 | void \ | |
1801 | read_only_data_section () \ | |
1802 | { \ | |
1803 | if (in_section != read_only_data) \ | |
1804 | { \ | |
469adec3 | 1805 | fprintf (asm_out_file, ".csect %s[RO]\n", \ |
fdaff8ba | 1806 | xcoff_read_only_section_name); \ |
f045b2c9 RS |
1807 | in_section = read_only_data; \ |
1808 | } \ | |
1809 | } \ | |
1810 | \ | |
1811 | void \ | |
1812 | private_data_section () \ | |
1813 | { \ | |
1814 | if (in_section != private_data) \ | |
1815 | { \ | |
469adec3 | 1816 | fprintf (asm_out_file, ".csect %s[RW]\n", \ |
fdaff8ba | 1817 | xcoff_private_data_section_name); \ |
f045b2c9 RS |
1818 | \ |
1819 | in_section = private_data; \ | |
1820 | } \ | |
1821 | } \ | |
1822 | \ | |
1823 | void \ | |
1824 | read_only_private_data_section () \ | |
1825 | { \ | |
1826 | if (in_section != read_only_private_data) \ | |
1827 | { \ | |
f25359b5 | 1828 | fprintf (asm_out_file, ".csect %s[RO]\n", \ |
fdaff8ba | 1829 | xcoff_private_data_section_name); \ |
f045b2c9 RS |
1830 | in_section = read_only_private_data; \ |
1831 | } \ | |
1832 | } \ | |
1833 | \ | |
1834 | void \ | |
1835 | toc_section () \ | |
1836 | { \ | |
642a35f1 JW |
1837 | if (TARGET_MINIMAL_TOC) \ |
1838 | { \ | |
1839 | static int toc_initialized = 0; \ | |
1840 | \ | |
1841 | /* toc_section is always called at least once from ASM_FILE_START, \ | |
1842 | so this is guaranteed to always be defined once and only once \ | |
1843 | in each file. */ \ | |
1844 | if (! toc_initialized) \ | |
1845 | { \ | |
1846 | fprintf (asm_out_file, ".toc\nLCTOC..0:\n"); \ | |
1847 | fprintf (asm_out_file, "\t.tc toc_table[TC],toc_table[RW]\n"); \ | |
1848 | toc_initialized = 1; \ | |
1849 | } \ | |
f045b2c9 | 1850 | \ |
642a35f1 JW |
1851 | if (in_section != toc) \ |
1852 | fprintf (asm_out_file, ".csect toc_table[RW]\n"); \ | |
1853 | } \ | |
1854 | else \ | |
1855 | { \ | |
1856 | if (in_section != toc) \ | |
1857 | fprintf (asm_out_file, ".toc\n"); \ | |
1858 | } \ | |
f045b2c9 | 1859 | in_section = toc; \ |
fc3ffe83 | 1860 | } |
f045b2c9 RS |
1861 | |
1862 | /* This macro produces the initial definition of a function name. | |
1863 | On the RS/6000, we need to place an extra '.' in the function name and | |
1864 | output the function descriptor. | |
1865 | ||
1866 | The csect for the function will have already been created by the | |
1867 | `text_section' call previously done. We do have to go back to that | |
1868 | csect, however. */ | |
1869 | ||
fdaff8ba RS |
1870 | /* ??? What do the 16 and 044 in the .function line really mean? */ |
1871 | ||
f045b2c9 RS |
1872 | #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \ |
1873 | { if (TREE_PUBLIC (DECL)) \ | |
1874 | { \ | |
1875 | fprintf (FILE, "\t.globl ."); \ | |
1876 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ | |
fdaff8ba RS |
1877 | fprintf (FILE, "\n"); \ |
1878 | } \ | |
3ce428da | 1879 | else \ |
fdaff8ba RS |
1880 | { \ |
1881 | fprintf (FILE, "\t.lglobl ."); \ | |
1882 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ | |
1883 | fprintf (FILE, "\n"); \ | |
f045b2c9 | 1884 | } \ |
f25359b5 | 1885 | fprintf (FILE, ".csect "); \ |
f045b2c9 RS |
1886 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
1887 | fprintf (FILE, "[DS]\n"); \ | |
1888 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ | |
1889 | fprintf (FILE, ":\n"); \ | |
1890 | fprintf (FILE, "\t.long ."); \ | |
1891 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ | |
fdaff8ba | 1892 | fprintf (FILE, ", TOC[tc0], 0\n"); \ |
11117bb9 | 1893 | fprintf (FILE, ".csect .text[PR]\n."); \ |
f045b2c9 RS |
1894 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
1895 | fprintf (FILE, ":\n"); \ | |
fdaff8ba | 1896 | if (write_symbols == XCOFF_DEBUG) \ |
c2a47e48 | 1897 | xcoffout_declare_function (FILE, DECL, NAME); \ |
f045b2c9 RS |
1898 | } |
1899 | ||
1900 | /* Return non-zero if this entry is to be written into the constant pool | |
1901 | in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST | |
1902 | containing one of them. If -mfp-in-toc (the default), we also do | |
1903 | this for floating-point constants. We actually can only do this | |
1904 | if the FP formats of the target and host machines are the same, but | |
1905 | we can't check that since not every file that uses | |
1906 | GO_IF_LEGITIMATE_ADDRESS_P includes real.h. */ | |
1907 | ||
1908 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X) \ | |
1909 | (GET_CODE (X) == SYMBOL_REF \ | |
1910 | || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ | |
1911 | && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ | |
1912 | || GET_CODE (X) == LABEL_REF \ | |
72847b95 RK |
1913 | || (! (TARGET_NO_FP_IN_TOC && ! TARGET_MINIMAL_TOC) \ |
1914 | && GET_CODE (X) == CONST_DOUBLE \ | |
f045b2c9 RS |
1915 | && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ |
1916 | && BITS_PER_WORD == HOST_BITS_PER_INT)) | |
1917 | ||
1918 | /* Select section for constant in constant pool. | |
1919 | ||
1920 | On RS/6000, all constants are in the private read-only data area. | |
1921 | However, if this is being placed in the TOC it must be output as a | |
1922 | toc entry. */ | |
1923 | ||
1924 | #define SELECT_RTX_SECTION(MODE, X) \ | |
1925 | { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X)) \ | |
1926 | toc_section (); \ | |
1927 | else \ | |
1928 | read_only_private_data_section (); \ | |
1929 | } | |
1930 | ||
1931 | /* Macro to output a special constant pool entry. Go to WIN if we output | |
1932 | it. Otherwise, it is written the usual way. | |
1933 | ||
1934 | On the RS/6000, toc entries are handled this way. */ | |
1935 | ||
1936 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY(FILE, X, MODE, ALIGN, LABELNO, WIN) \ | |
1937 | { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X)) \ | |
1938 | { \ | |
1939 | output_toc (FILE, X, LABELNO); \ | |
1940 | goto WIN; \ | |
1941 | } \ | |
1942 | } | |
1943 | ||
1944 | /* Select the section for an initialized data object. | |
1945 | ||
1946 | On the RS/6000, we have a special section for all variables except those | |
1947 | that are static. */ | |
1948 | ||
1949 | #define SELECT_SECTION(EXP,RELOC) \ | |
1950 | { \ | |
ed8969fa JW |
1951 | if ((TREE_CODE (EXP) == STRING_CST \ |
1952 | && !flag_writable_strings) \ | |
128e5769 | 1953 | || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd' \ |
1ff5cbcd | 1954 | && TREE_READONLY (EXP) && ! TREE_THIS_VOLATILE (EXP) \ |
ed8969fa JW |
1955 | && DECL_INITIAL (EXP) \ |
1956 | && (DECL_INITIAL (EXP) == error_mark_node \ | |
1957 | || TREE_CONSTANT (DECL_INITIAL (EXP))) \ | |
1958 | && ! (RELOC))) \ | |
f045b2c9 RS |
1959 | { \ |
1960 | if (TREE_PUBLIC (EXP)) \ | |
1961 | read_only_data_section (); \ | |
1962 | else \ | |
1963 | read_only_private_data_section (); \ | |
1964 | } \ | |
1965 | else \ | |
1966 | { \ | |
1967 | if (TREE_PUBLIC (EXP)) \ | |
1968 | data_section (); \ | |
1969 | else \ | |
1970 | private_data_section (); \ | |
1971 | } \ | |
1972 | } | |
1973 | ||
1974 | /* This outputs NAME to FILE up to the first null or '['. */ | |
1975 | ||
1976 | #define RS6000_OUTPUT_BASENAME(FILE, NAME) \ | |
99d3d26e | 1977 | if ((NAME)[0] == '*' || (NAME)[strlen (NAME) - 1] != ']') \ |
f045b2c9 RS |
1978 | assemble_name (FILE, NAME); \ |
1979 | else \ | |
1980 | { \ | |
99d3d26e RK |
1981 | int _len = strlen (NAME); \ |
1982 | char *_p = alloca (_len + 1); \ | |
1983 | \ | |
1984 | strcpy (_p, NAME); \ | |
1985 | _p[_len - 4] = '\0'; \ | |
1986 | assemble_name (FILE, _p); \ | |
f045b2c9 RS |
1987 | } |
1988 | ||
1989 | /* Output something to declare an external symbol to the assembler. Most | |
1990 | assemblers don't need this. | |
1991 | ||
1992 | If we haven't already, add "[RW]" (or "[DS]" for a function) to the | |
1993 | name. Normally we write this out along with the name. In the few cases | |
1994 | where we can't, it gets stripped off. */ | |
1995 | ||
1996 | #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ | |
1997 | { rtx _symref = XEXP (DECL_RTL (DECL), 0); \ | |
1998 | if ((TREE_CODE (DECL) == VAR_DECL \ | |
1999 | || TREE_CODE (DECL) == FUNCTION_DECL) \ | |
2000 | && (NAME)[0] != '*' \ | |
2001 | && (NAME)[strlen (NAME) - 1] != ']') \ | |
2002 | { \ | |
2003 | char *_name = (char *) permalloc (strlen (XSTR (_symref, 0)) + 5); \ | |
2004 | strcpy (_name, XSTR (_symref, 0)); \ | |
2005 | strcat (_name, TREE_CODE (DECL) == FUNCTION_DECL ? "[DS]" : "[RW]"); \ | |
2006 | XSTR (_symref, 0) = _name; \ | |
2007 | } \ | |
2008 | fprintf (FILE, "\t.extern "); \ | |
2009 | assemble_name (FILE, XSTR (_symref, 0)); \ | |
2010 | if (TREE_CODE (DECL) == FUNCTION_DECL) \ | |
2011 | { \ | |
2012 | fprintf (FILE, "\n\t.extern ."); \ | |
2013 | RS6000_OUTPUT_BASENAME (FILE, XSTR (_symref, 0)); \ | |
2014 | } \ | |
2015 | fprintf (FILE, "\n"); \ | |
2016 | } | |
2017 | ||
2018 | /* Similar, but for libcall. We only have to worry about the function name, | |
2019 | not that of the descriptor. */ | |
2020 | ||
2021 | #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ | |
2022 | { fprintf (FILE, "\t.extern ."); \ | |
2023 | assemble_name (FILE, XSTR (FUN, 0)); \ | |
2024 | fprintf (FILE, "\n"); \ | |
2025 | } | |
2026 | ||
2027 | /* Output to assembler file text saying following lines | |
2028 | may contain character constants, extra white space, comments, etc. */ | |
2029 | ||
2030 | #define ASM_APP_ON "" | |
2031 | ||
2032 | /* Output to assembler file text saying following lines | |
2033 | no longer contain unusual constructs. */ | |
2034 | ||
2035 | #define ASM_APP_OFF "" | |
2036 | ||
2037 | /* Output before instructions. */ | |
2038 | ||
11117bb9 | 2039 | #define TEXT_SECTION_ASM_OP ".csect .text[PR]" |
f045b2c9 RS |
2040 | |
2041 | /* Output before writable data. */ | |
2042 | ||
fdaff8ba | 2043 | #define DATA_SECTION_ASM_OP ".csect .data[RW]" |
f045b2c9 RS |
2044 | |
2045 | /* How to refer to registers in assembler output. | |
2046 | This sequence is indexed by compiler's hard-register-number (see above). */ | |
2047 | ||
2048 | #define REGISTER_NAMES \ | |
2049 | {"0", "1", "2", "3", "4", "5", "6", "7", \ | |
2050 | "8", "9", "10", "11", "12", "13", "14", "15", \ | |
2051 | "16", "17", "18", "19", "20", "21", "22", "23", \ | |
2052 | "24", "25", "26", "27", "28", "29", "30", "31", \ | |
2053 | "0", "1", "2", "3", "4", "5", "6", "7", \ | |
2054 | "8", "9", "10", "11", "12", "13", "14", "15", \ | |
2055 | "16", "17", "18", "19", "20", "21", "22", "23", \ | |
2056 | "24", "25", "26", "27", "28", "29", "30", "31", \ | |
2057 | "mq", "lr", "ctr", "ap", \ | |
2058 | "0", "1", "2", "3", "4", "5", "6", "7" } | |
2059 | ||
2060 | /* Table of additional register names to use in user input. */ | |
2061 | ||
2062 | #define ADDITIONAL_REGISTER_NAMES \ | |
2063 | {"r0", 0, "r1", 1, "r2", 2, "r3", 3, \ | |
2064 | "r4", 4, "r5", 5, "r6", 6, "r7", 7, \ | |
2065 | "r8", 8, "r9", 9, "r10", 10, "r11", 11, \ | |
2066 | "r12", 12, "r13", 13, "r14", 14, "r15", 15, \ | |
2067 | "r16", 16, "r17", 17, "r18", 18, "r19", 19, \ | |
2068 | "r20", 20, "r21", 21, "r22", 22, "r23", 23, \ | |
2069 | "r24", 24, "r25", 25, "r26", 26, "r27", 27, \ | |
2070 | "r28", 28, "r29", 29, "r30", 30, "r31", 31, \ | |
2071 | "fr0", 32, "fr1", 33, "fr2", 34, "fr3", 35, \ | |
2072 | "fr4", 36, "fr5", 37, "fr6", 38, "fr7", 39, \ | |
2073 | "fr8", 40, "fr9", 41, "fr10", 42, "fr11", 43, \ | |
2074 | "fr12", 44, "fr13", 45, "fr14", 46, "fr15", 47, \ | |
2075 | "fr16", 48, "fr17", 49, "fr18", 50, "fr19", 51, \ | |
2076 | "fr20", 52, "fr21", 53, "fr22", 54, "fr23", 55, \ | |
2077 | "fr24", 56, "fr25", 57, "fr26", 58, "fr27", 59, \ | |
2078 | "fr28", 60, "fr29", 61, "fr30", 62, "fr31", 63, \ | |
2079 | /* no additional names for: mq, lr, ctr, ap */ \ | |
2080 | "cr0", 68, "cr1", 69, "cr2", 70, "cr3", 71, \ | |
fc3ffe83 RK |
2081 | "cr4", 72, "cr5", 73, "cr6", 74, "cr7", 75, \ |
2082 | "cc", 68 } | |
f045b2c9 RS |
2083 | |
2084 | /* How to renumber registers for dbx and gdb. */ | |
2085 | ||
2086 | #define DBX_REGISTER_NUMBER(REGNO) (REGNO) | |
2087 | ||
0da40b09 RK |
2088 | /* Text to write out after a CALL that may be replaced by glue code by |
2089 | the loader. This depends on the AIX version. */ | |
2090 | #define RS6000_CALL_GLUE "cror 31,31,31" | |
11117bb9 | 2091 | |
f045b2c9 RS |
2092 | /* This is how to output the definition of a user-level label named NAME, |
2093 | such as the label on a static function or variable NAME. */ | |
2094 | ||
2095 | #define ASM_OUTPUT_LABEL(FILE,NAME) \ | |
2096 | do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0) | |
2097 | ||
2098 | /* This is how to output a command to make the user-level label named NAME | |
2099 | defined for reference from other files. */ | |
2100 | ||
2101 | #define ASM_GLOBALIZE_LABEL(FILE,NAME) \ | |
2102 | do { fputs ("\t.globl ", FILE); \ | |
2103 | RS6000_OUTPUT_BASENAME (FILE, NAME); fputs ("\n", FILE);} while (0) | |
2104 | ||
2105 | /* This is how to output a reference to a user-level label named NAME. | |
2106 | `assemble_name' uses this. */ | |
2107 | ||
2108 | #define ASM_OUTPUT_LABELREF(FILE,NAME) \ | |
2109 | fprintf (FILE, NAME) | |
2110 | ||
2111 | /* This is how to output an internal numbered label where | |
2112 | PREFIX is the class of label and NUM is the number within the class. */ | |
2113 | ||
2114 | #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ | |
2115 | fprintf (FILE, "%s..%d:\n", PREFIX, NUM) | |
2116 | ||
3daf36a4 ILT |
2117 | /* This is how to output an internal label prefix. rs6000.c uses this |
2118 | when generating traceback tables. */ | |
2119 | ||
2120 | #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \ | |
2121 | fprintf (FILE, "%s..", PREFIX) | |
2122 | ||
f045b2c9 RS |
2123 | /* This is how to output a label for a jump table. Arguments are the same as |
2124 | for ASM_OUTPUT_INTERNAL_LABEL, except the insn for the jump table is | |
2125 | passed. */ | |
2126 | ||
2127 | #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \ | |
2128 | { ASM_OUTPUT_ALIGN (FILE, 2); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); } | |
2129 | ||
2130 | /* This is how to store into the string LABEL | |
2131 | the symbol_ref name of an internal numbered label where | |
2132 | PREFIX is the class of label and NUM is the number within the class. | |
2133 | This is suitable for output with `assemble_name'. */ | |
2134 | ||
2135 | #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ | |
2136 | sprintf (LABEL, "%s..%d", PREFIX, NUM) | |
2137 | ||
2138 | /* This is how to output an assembler line defining a `double' constant. */ | |
2139 | ||
a5b1eb34 RS |
2140 | #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \ |
2141 | { \ | |
2142 | if (REAL_VALUE_ISINF (VALUE) \ | |
2143 | || REAL_VALUE_ISNAN (VALUE) \ | |
2144 | || REAL_VALUE_MINUS_ZERO (VALUE)) \ | |
2145 | { \ | |
2146 | long t[2]; \ | |
2147 | REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \ | |
2148 | fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", \ | |
2149 | t[0] & 0xffffffff, t[1] & 0xffffffff); \ | |
2150 | } \ | |
2151 | else \ | |
2152 | { \ | |
2153 | char str[30]; \ | |
2154 | REAL_VALUE_TO_DECIMAL (VALUE, "%.20e", str); \ | |
2155 | fprintf (FILE, "\t.double 0d%s\n", str); \ | |
2156 | } \ | |
2157 | } | |
f045b2c9 RS |
2158 | |
2159 | /* This is how to output an assembler line defining a `float' constant. */ | |
2160 | ||
a5b1eb34 RS |
2161 | #define ASM_OUTPUT_FLOAT(FILE, VALUE) \ |
2162 | { \ | |
2163 | if (REAL_VALUE_ISINF (VALUE) \ | |
2164 | || REAL_VALUE_ISNAN (VALUE) \ | |
2165 | || REAL_VALUE_MINUS_ZERO (VALUE)) \ | |
2166 | { \ | |
2167 | long t; \ | |
2168 | REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \ | |
2169 | fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff); \ | |
2170 | } \ | |
2171 | else \ | |
2172 | { \ | |
2173 | char str[30]; \ | |
2174 | REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \ | |
2175 | fprintf (FILE, "\t.float 0d%s\n", str); \ | |
2176 | } \ | |
2177 | } | |
f045b2c9 RS |
2178 | |
2179 | /* This is how to output an assembler line defining an `int' constant. */ | |
2180 | ||
2181 | #define ASM_OUTPUT_INT(FILE,VALUE) \ | |
2182 | ( fprintf (FILE, "\t.long "), \ | |
2183 | output_addr_const (FILE, (VALUE)), \ | |
2184 | fprintf (FILE, "\n")) | |
2185 | ||
2186 | /* Likewise for `char' and `short' constants. */ | |
2187 | ||
2188 | #define ASM_OUTPUT_SHORT(FILE,VALUE) \ | |
2189 | ( fprintf (FILE, "\t.short "), \ | |
2190 | output_addr_const (FILE, (VALUE)), \ | |
2191 | fprintf (FILE, "\n")) | |
2192 | ||
2193 | #define ASM_OUTPUT_CHAR(FILE,VALUE) \ | |
2194 | ( fprintf (FILE, "\t.byte "), \ | |
2195 | output_addr_const (FILE, (VALUE)), \ | |
2196 | fprintf (FILE, "\n")) | |
2197 | ||
2198 | /* This is how to output an assembler line for a numeric constant byte. */ | |
2199 | ||
2200 | #define ASM_OUTPUT_BYTE(FILE,VALUE) \ | |
2201 | fprintf (FILE, "\t.byte 0x%x\n", (VALUE)) | |
2202 | ||
2203 | /* This is how to output an assembler line to define N characters starting | |
2204 | at P to FILE. */ | |
2205 | ||
2206 | #define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) | |
2207 | ||
2208 | /* This is how to output code to push a register on the stack. | |
2209 | It need not be very fast code. */ | |
2210 | ||
2211 | #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ | |
6febd581 | 2212 | asm_fprintf (FILE, "\{tstu|stwu} %s,-4(r1)\n", reg_names[REGNO]); |
f045b2c9 RS |
2213 | |
2214 | /* This is how to output an insn to pop a register from the stack. | |
2215 | It need not be very fast code. */ | |
2216 | ||
2217 | #define ASM_OUTPUT_REG_POP(FILE,REGNO) \ | |
6febd581 RK |
2218 | asm_fprintf (FILE, "\t{l|lwz} %s,0(r1)\n\t{ai|addic} r1,r1,4\n", \ |
2219 | reg_names[REGNO]) | |
f045b2c9 RS |
2220 | |
2221 | /* This is how to output an element of a case-vector that is absolute. | |
2222 | (RS/6000 does not use such vectors, but we must define this macro | |
2223 | anyway.) */ | |
2224 | ||
3daf36a4 ILT |
2225 | #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ |
2226 | do { char buf[100]; \ | |
2227 | fprintf (FILE, "\t.long "); \ | |
2228 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE); \ | |
2229 | assemble_name (FILE, buf); \ | |
2230 | fprintf (FILE, "\n"); \ | |
2231 | } while (0) | |
f045b2c9 RS |
2232 | |
2233 | /* This is how to output an element of a case-vector that is relative. */ | |
2234 | ||
2235 | #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ | |
3daf36a4 ILT |
2236 | do { char buf[100]; \ |
2237 | fprintf (FILE, "\t.long "); \ | |
2238 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE); \ | |
2239 | assemble_name (FILE, buf); \ | |
2240 | fprintf (FILE, "-"); \ | |
2241 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", REL); \ | |
2242 | assemble_name (FILE, buf); \ | |
2243 | fprintf (FILE, "\n"); \ | |
2244 | } while (0) | |
f045b2c9 RS |
2245 | |
2246 | /* This is how to output an assembler line | |
2247 | that says to advance the location counter | |
2248 | to a multiple of 2**LOG bytes. */ | |
2249 | ||
2250 | #define ASM_OUTPUT_ALIGN(FILE,LOG) \ | |
2251 | if ((LOG) != 0) \ | |
2252 | fprintf (FILE, "\t.align %d\n", (LOG)) | |
2253 | ||
2254 | #define ASM_OUTPUT_SKIP(FILE,SIZE) \ | |
2255 | fprintf (FILE, "\t.space %d\n", (SIZE)) | |
2256 | ||
2257 | /* This says how to output an assembler line | |
2258 | to define a global common symbol. */ | |
2259 | ||
2260 | #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ | |
fc3ffe83 | 2261 | do { fputs (".comm ", (FILE)); \ |
f045b2c9 RS |
2262 | RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ |
2263 | fprintf ((FILE), ",%d\n", (SIZE)); } while (0) | |
2264 | ||
2265 | /* This says how to output an assembler line | |
2266 | to define a local common symbol. */ | |
2267 | ||
2268 | #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \ | |
fc3ffe83 | 2269 | do { fputs (".lcomm ", (FILE)); \ |
f045b2c9 | 2270 | RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ |
fdaff8ba | 2271 | fprintf ((FILE), ",%d,%s\n", (SIZE), xcoff_bss_section_name); \ |
f045b2c9 RS |
2272 | } while (0) |
2273 | ||
2274 | /* Store in OUTPUT a string (made with alloca) containing | |
2275 | an assembler-name for a local static variable named NAME. | |
2276 | LABELNO is an integer which is different for each call. */ | |
2277 | ||
2278 | #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ | |
2279 | ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ | |
2280 | sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) | |
2281 | ||
2282 | /* Define the parentheses used to group arithmetic operations | |
2283 | in assembler code. */ | |
2284 | ||
2285 | #define ASM_OPEN_PAREN "(" | |
2286 | #define ASM_CLOSE_PAREN ")" | |
2287 | ||
2288 | /* Define results of standard character escape sequences. */ | |
2289 | #define TARGET_BELL 007 | |
2290 | #define TARGET_BS 010 | |
2291 | #define TARGET_TAB 011 | |
2292 | #define TARGET_NEWLINE 012 | |
2293 | #define TARGET_VT 013 | |
2294 | #define TARGET_FF 014 | |
2295 | #define TARGET_CR 015 | |
2296 | ||
2297 | /* Print operand X (an rtx) in assembler syntax to file FILE. | |
2298 | CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. | |
2299 | For `%' followed by punctuation, CODE is the punctuation and X is null. */ | |
2300 | ||
2301 | #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE) | |
2302 | ||
2303 | /* Define which CODE values are valid. */ | |
2304 | ||
38250554 | 2305 | #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '.' || (CODE) == '*') |
f045b2c9 RS |
2306 | |
2307 | /* Print a memory address as an operand to reference that memory location. */ | |
2308 | ||
2309 | #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR) | |
2310 | ||
2311 | /* Define the codes that are matched by predicates in rs6000.c. */ | |
2312 | ||
2313 | #define PREDICATE_CODES \ | |
2314 | {"short_cint_operand", {CONST_INT}}, \ | |
2315 | {"u_short_cint_operand", {CONST_INT}}, \ | |
f357808b | 2316 | {"non_short_cint_operand", {CONST_INT}}, \ |
cd2b37d9 | 2317 | {"gpc_reg_operand", {SUBREG, REG}}, \ |
f045b2c9 RS |
2318 | {"cc_reg_operand", {SUBREG, REG}}, \ |
2319 | {"reg_or_short_operand", {SUBREG, REG, CONST_INT}}, \ | |
2320 | {"reg_or_neg_short_operand", {SUBREG, REG, CONST_INT}}, \ | |
2321 | {"reg_or_u_short_operand", {SUBREG, REG, CONST_INT}}, \ | |
2322 | {"reg_or_cint_operand", {SUBREG, REG, CONST_INT}}, \ | |
2323 | {"easy_fp_constant", {CONST_DOUBLE}}, \ | |
2324 | {"reg_or_mem_operand", {SUBREG, MEM, REG}}, \ | |
414d3ee4 | 2325 | {"lwa_operand", {SUBREG, MEM, REG}}, \ |
1c71b69d | 2326 | {"low_32_bit_operand", {CONST_DOUBLE, CONST_INT}}, \ |
f045b2c9 RS |
2327 | {"fp_reg_or_mem_operand", {SUBREG, MEM, REG}}, \ |
2328 | {"mem_or_easy_const_operand", {SUBREG, MEM, CONST_DOUBLE}}, \ | |
2329 | {"add_operand", {SUBREG, REG, CONST_INT}}, \ | |
f357808b | 2330 | {"non_add_cint_operand", {CONST_INT}}, \ |
f045b2c9 | 2331 | {"and_operand", {SUBREG, REG, CONST_INT}}, \ |
f357808b | 2332 | {"non_and_cint_operand", {CONST_INT}}, \ |
f045b2c9 | 2333 | {"logical_operand", {SUBREG, REG, CONST_INT}}, \ |
f357808b | 2334 | {"non_logical_cint_operand", {CONST_INT}}, \ |
f045b2c9 RS |
2335 | {"mask_operand", {CONST_INT}}, \ |
2336 | {"call_operand", {SYMBOL_REF, REG}}, \ | |
f8634644 | 2337 | {"current_file_function_operand", {SYMBOL_REF}}, \ |
38250554 | 2338 | {"input_operand", {SUBREG, MEM, REG, CONST_INT, SYMBOL_REF}}, \ |
f8634644 RK |
2339 | {"load_multiple_operation", {PARALLEL}}, \ |
2340 | {"store_multiple_operation", {PARALLEL}}, \ | |
2341 | {"branch_comparison_operator", {EQ, NE, LE, LT, GE, \ | |
e477bbc7 | 2342 | GT, LEU, LTU, GEU, GTU}}, \ |
f8634644 | 2343 | {"scc_comparison_operator", {EQ, NE, LE, LT, GE, \ |
e477bbc7 | 2344 | GT, LEU, LTU, GEU, GTU}}, |
75814ad4 MM |
2345 | |
2346 | /* Declare functions in rs6000.c */ | |
2347 | extern void rs6000_override_options (); | |
2348 | extern struct rtx_def *rs6000_immed_double_const (); | |
2349 | extern int direct_return (); | |
2350 | extern int any_operand (); | |
2351 | extern int short_cint_operand (); | |
2352 | extern int u_short_cint_operand (); | |
2353 | extern int non_short_cint_operand (); | |
2354 | extern int gpc_reg_operand (); | |
2355 | extern int cc_reg_operand (); | |
2356 | extern int reg_or_short_operand (); | |
2357 | extern int reg_or_neg_short_operand (); | |
2358 | extern int reg_or_u_short_operand (); | |
2359 | extern int reg_or_cint_operand (); | |
2360 | extern int easy_fp_constant (); | |
2361 | extern int low_32_bit_operand (); | |
2362 | extern int fp_reg_or_mem_operand (); | |
2363 | extern int mem_or_easy_const_operand (); | |
2364 | extern int add_operand (); | |
2365 | extern int non_add_cint_operand (); | |
2366 | extern int logical_operand (); | |
2367 | extern int non_logical_operand (); | |
2368 | extern int mask_constant (); | |
2369 | extern int mask_operand (); | |
2370 | extern int and_operand (); | |
2371 | extern int non_and_cint_operand (); | |
2372 | extern int reg_or_mem_operand (); | |
2373 | extern int lwa_operand (); | |
2374 | extern int call_operand (); | |
2375 | extern int current_file_function_operand (); | |
2376 | extern int input_operand (); | |
7e69e155 | 2377 | extern int expand_block_move (); |
75814ad4 MM |
2378 | extern int load_multiple_operation (); |
2379 | extern int store_multiple_operation (); | |
2380 | extern int branch_comparison_operator (); | |
2381 | extern int scc_comparison_operator (); | |
2382 | extern int includes_lshift_p (); | |
2383 | extern int includes_rshift_p (); | |
2384 | extern int registers_ok_for_quad_peep (); | |
2385 | extern int addrs_ok_for_quad_peep (); | |
2386 | extern enum reg_class secondary_reload_class (); | |
2387 | extern int ccr_bit (); | |
2388 | extern void print_operand (); | |
2389 | extern void print_operand_address (); | |
2390 | extern int first_reg_to_save (); | |
2391 | extern int first_fp_reg_to_save (); | |
2392 | extern int must_save_cr (); | |
2393 | extern int rs6000_sa_size (); | |
2394 | extern int rs6000_makes_calls (); | |
2395 | extern int rs6000_pushes_stack (); | |
2396 | extern void svr4_traceback (); | |
2397 | extern void output_prolog (); | |
2398 | extern void output_epilog (); | |
2399 | extern void output_toc (); | |
2400 | extern void output_ascii (); | |
2401 | extern void rs6000_gen_section_name (); | |
2402 | extern void output_function_profiler (); | |
2403 | extern int rs6000_adjust_cost (); |