]>
Commit | Line | Data |
---|---|---|
f045b2c9 | 1 | /* Definitions of target machine for GNU compiler, for IBM RS/6000. |
cf27b467 | 2 | Copyright (C) 1992, 1993, 1994, 1995, 1996 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 | |
c15c9075 RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
f045b2c9 RS |
21 | |
22 | ||
23 | /* Note that some other tm.h files include this one and then override | |
24 | many of the definitions that relate to assembler syntax. */ | |
25 | ||
26 | ||
27 | /* Names to predefine in the preprocessor for this target machine. */ | |
28 | ||
84b49fa7 RK |
29 | #define CPP_PREDEFINES "-D_IBMR2 -D_POWER -D_AIX -D_AIX32 \ |
30 | -Asystem(unix) -Asystem(aix) -Acpu(rs6000) -Amachine(rs6000)" | |
f045b2c9 RS |
31 | |
32 | /* Print subsidiary information on the compiler version in use. */ | |
33 | #define TARGET_VERSION ; | |
34 | ||
8e3f41e7 MM |
35 | /* Default string to use for cpu if not specified. */ |
36 | #ifndef TARGET_CPU_DEFAULT | |
37 | #define TARGET_CPU_DEFAULT ((char *)0) | |
38 | #endif | |
39 | ||
fdaff8ba RS |
40 | /* Tell the assembler to assume that all undefined names are external. |
41 | ||
42 | Don't do this until the fixed IBM assembler is more generally available. | |
43 | When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL, | |
44 | ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no | |
b4d6689b RK |
45 | longer be needed. Also, the extern declaration of mcount in ASM_FILE_START |
46 | will no longer be needed. */ | |
f045b2c9 | 47 | |
841faeed | 48 | /* #define ASM_SPEC "-u %(asm_cpu)" */ |
f045b2c9 | 49 | |
84b49fa7 RK |
50 | /* Define appropriate architecture macros for preprocessor depending on |
51 | target switches. */ | |
52 | ||
841faeed MM |
53 | #define CPP_SPEC "%{posix: -D_POSIX_SOURCE} %(cpp_cpu)" |
54 | ||
55 | /* Common CPP definitions used by CPP_SPEC amonst the various targets | |
56 | for handling -mcpu=xxx switches. */ | |
57 | #define CPP_CPU_SPEC \ | |
58 | "%{!mcpu*: \ | |
84b49fa7 RK |
59 | %{mpower: %{!mpower2: -D_ARCH_PWR}} \ |
60 | %{mpower2: -D_ARCH_PWR2} \ | |
61 | %{mpowerpc*: -D_ARCH_PPC} \ | |
62 | %{mno-power: %{!mpowerpc*: -D_ARCH_COM}} \ | |
841faeed | 63 | %{!mno-power: %{!mpower2: %(cpp_default)}}} \ |
84b49fa7 RK |
64 | %{mcpu=common: -D_ARCH_COM} \ |
65 | %{mcpu=power: -D_ARCH_PWR} \ | |
8e3f41e7 | 66 | %{mcpu=power2: -D_ARCH_PWR2} \ |
84b49fa7 RK |
67 | %{mcpu=powerpc: -D_ARCH_PPC} \ |
68 | %{mcpu=rios: -D_ARCH_PWR} \ | |
69 | %{mcpu=rios1: -D_ARCH_PWR} \ | |
70 | %{mcpu=rios2: -D_ARCH_PWR2} \ | |
71 | %{mcpu=rsc: -D_ARCH_PWR} \ | |
72 | %{mcpu=rsc1: -D_ARCH_PWR} \ | |
49a0b204 | 73 | %{mcpu=403: -D_ARCH_PPC} \ |
cf27b467 | 74 | %{mcpu=505: -D_ARCH_PPC} \ |
84b49fa7 | 75 | %{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \ |
841faeed | 76 | %{mcpu=602: -D_ARCH_PPC} \ |
fada905b MM |
77 | %{mcpu=603: -D_ARCH_PPC} \ |
78 | %{mcpu=603e: -D_ARCH_PPC} \ | |
79 | %{mcpu=604: -D_ARCH_PPC} \ | |
cf27b467 MM |
80 | %{mcpu=620: -D_ARCH_PPC} \ |
81 | %{mcpu=821: -D_ARCH_PPC} \ | |
82 | %{mcpu=860: -D_ARCH_PPC}" | |
84b49fa7 | 83 | |
841faeed MM |
84 | #ifndef CPP_DEFAULT_SPEC |
85 | #define CPP_DEFAULT_SPEC "-D_ARCH_PWR" | |
86 | #endif | |
87 | ||
88 | #ifndef CPP_SYSV_SPEC | |
89 | #define CPP_SYSV_SPEC "" | |
90 | #endif | |
91 | ||
92 | #ifndef CPP_ENDIAN_SPEC | |
93 | #define CPP_ENDIAN_SPEC "" | |
94 | #endif | |
95 | ||
c81bebd7 MM |
96 | #ifndef CPP_ENDIAN_DEFAULT_SPEC |
97 | #define CPP_ENDIAN_DEFAULT_SPEC "" | |
98 | #endif | |
99 | ||
841faeed MM |
100 | #ifndef CPP_SYSV_DEFAULT_SPEC |
101 | #define CPP_SYSV_DEFAULT_SPEC "" | |
102 | #endif | |
103 | ||
104 | /* Common ASM definitions used by ASM_SPEC amonst the various targets | |
105 | for handling -mcpu=xxx switches. */ | |
106 | #define ASM_CPU_SPEC \ | |
107 | "%{!mcpu*: \ | |
108 | %{mpower: %{!mpower2: -mpwr}} \ | |
109 | %{mpower2: -mpwrx} \ | |
110 | %{mpowerpc*: -mppc} \ | |
111 | %{mno-power: %{!mpowerpc*: -mcom}} \ | |
112 | %{!mno-power: %{!mpower2: %(asm_default)}}} \ | |
113 | %{mcpu=common: -mcom} \ | |
114 | %{mcpu=power: -mpwr} \ | |
115 | %{mcpu=power2: -mpwrx} \ | |
116 | %{mcpu=powerpc: -mppc} \ | |
117 | %{mcpu=rios: -mpwr} \ | |
118 | %{mcpu=rios1: -mpwr} \ | |
119 | %{mcpu=rios2: -mpwrx} \ | |
120 | %{mcpu=rsc: -mpwr} \ | |
121 | %{mcpu=rsc1: -mpwr} \ | |
122 | %{mcpu=403: -mppc} \ | |
123 | %{mcpu=505: -mppc} \ | |
124 | %{mcpu=601: -m601} \ | |
125 | %{mcpu=602: -mppc} \ | |
126 | %{mcpu=603: -mppc} \ | |
127 | %{mcpu=603e: -mppc} \ | |
128 | %{mcpu=604: -mppc} \ | |
129 | %{mcpu=620: -mppc} \ | |
130 | %{mcpu=821: -mppc} \ | |
131 | %{mcpu=860: -mppc}" | |
132 | ||
133 | #ifndef ASM_DEFAULT_SPEC | |
fba29a8c | 134 | #define ASM_DEFAULT_SPEC "" |
841faeed MM |
135 | #endif |
136 | ||
137 | /* This macro defines names of additional specifications to put in the specs | |
138 | that can be used in various specifications like CC1_SPEC. Its definition | |
139 | is an initializer with a subgrouping for each command option. | |
140 | ||
141 | Each subgrouping contains a string constant, that defines the | |
142 | specification name, and a string constant that used by the GNU CC driver | |
143 | program. | |
144 | ||
145 | Do not define this macro if it does not need to do anything. */ | |
146 | ||
7509c759 MM |
147 | #ifndef SUBTARGET_EXTRA_SPECS |
148 | #define SUBTARGET_EXTRA_SPECS | |
149 | #endif | |
150 | ||
c81bebd7 MM |
151 | #define EXTRA_SPECS \ |
152 | { "cpp_cpu", CPP_CPU_SPEC }, \ | |
153 | { "cpp_default", CPP_DEFAULT_SPEC }, \ | |
154 | { "cpp_sysv", CPP_SYSV_SPEC }, \ | |
155 | { "cpp_sysv_default", CPP_SYSV_DEFAULT_SPEC }, \ | |
156 | { "cpp_endian_default", CPP_ENDIAN_DEFAULT_SPEC }, \ | |
157 | { "cpp_endian", CPP_ENDIAN_SPEC }, \ | |
158 | { "asm_cpu", ASM_CPU_SPEC }, \ | |
159 | { "asm_default", ASM_DEFAULT_SPEC }, \ | |
160 | { "link_syscalls", LINK_SYSCALLS_SPEC }, \ | |
161 | { "link_libg", LINK_LIBG_SPEC }, \ | |
7509c759 MM |
162 | SUBTARGET_EXTRA_SPECS |
163 | ||
7509c759 MM |
164 | /* Default location of syscalls.exp under AIX */ |
165 | #ifndef CROSS_COMPILE | |
166 | #define LINK_SYSCALLS_SPEC "-bI:/lib/syscalls.exp" | |
167 | #else | |
168 | #define LINK_SYSCALLS_SPEC "" | |
169 | #endif | |
170 | ||
171 | /* Default location of libg.exp under AIX */ | |
172 | #ifndef CROSS_COMPILE | |
173 | #define LINK_LIBG_SPEC "-bexport:/usr/lib/libg.exp" | |
174 | #else | |
175 | #define LINK_LIBG_SPEC "" | |
176 | #endif | |
177 | ||
f045b2c9 RS |
178 | /* Define the options for the binder: Start text at 512, align all segments |
179 | to 512 bytes, and warn if there is text relocation. | |
180 | ||
181 | The -bhalt:4 option supposedly changes the level at which ld will abort, | |
182 | but it also suppresses warnings about multiply defined symbols and is | |
183 | used by the AIX cc command. So we use it here. | |
184 | ||
185 | -bnodelcsect undoes a poor choice of default relating to multiply-defined | |
52c0eaf8 JM |
186 | csects. See AIX documentation for more information about this. |
187 | ||
188 | -bM:SRE tells the linker that the output file is Shared REusable. Note | |
189 | that to actually build a shared library you will also need to specify an | |
190 | export list with the -Wl,-bE option. */ | |
f045b2c9 | 191 | |
c1950f1c | 192 | #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\ |
7509c759 MM |
193 | %{static:-bnso %(link_syscalls) } \ |
194 | %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}" | |
f045b2c9 | 195 | |
58a39e45 RS |
196 | /* Profiled library versions are used by linking with special directories. */ |
197 | #define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\ | |
788d9012 | 198 | %{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc" |
f045b2c9 RS |
199 | |
200 | /* gcc must do the search itself to find libgcc.a, not use -l. */ | |
046b1537 | 201 | #define LIBGCC_SPEC "libgcc.a%s" |
f045b2c9 RS |
202 | |
203 | /* Don't turn -B into -L if the argument specifies a relative file name. */ | |
204 | #define RELATIVE_PREFIX_NOT_LINKDIR | |
205 | ||
fb623df5 | 206 | /* Architecture type. */ |
f045b2c9 | 207 | |
fb623df5 RK |
208 | extern int target_flags; |
209 | ||
210 | /* Use POWER architecture instructions and MQ register. */ | |
211 | #define MASK_POWER 0x01 | |
212 | ||
6febd581 RK |
213 | /* Use POWER2 extensions to POWER architecture. */ |
214 | #define MASK_POWER2 0x02 | |
215 | ||
fb623df5 | 216 | /* Use PowerPC architecture instructions. */ |
6febd581 RK |
217 | #define MASK_POWERPC 0x04 |
218 | ||
583cf4db RK |
219 | /* Use PowerPC General Purpose group optional instructions, e.g. fsqrt. */ |
220 | #define MASK_PPC_GPOPT 0x08 | |
221 | ||
222 | /* Use PowerPC Graphics group optional instructions, e.g. fsel. */ | |
223 | #define MASK_PPC_GFXOPT 0x10 | |
f045b2c9 | 224 | |
fb623df5 | 225 | /* Use PowerPC-64 architecture instructions. */ |
583cf4db | 226 | #define MASK_POWERPC64 0x20 |
f045b2c9 | 227 | |
fb623df5 | 228 | /* Use revised mnemonic names defined for PowerPC architecture. */ |
583cf4db | 229 | #define MASK_NEW_MNEMONICS 0x40 |
fb623df5 RK |
230 | |
231 | /* Disable placing fp constants in the TOC; can be turned on when the | |
232 | TOC overflows. */ | |
583cf4db | 233 | #define MASK_NO_FP_IN_TOC 0x80 |
fb623df5 | 234 | |
0b9ccabc RK |
235 | /* Disable placing symbol+offset constants in the TOC; can be turned on when |
236 | the TOC overflows. */ | |
583cf4db | 237 | #define MASK_NO_SUM_IN_TOC 0x100 |
0b9ccabc | 238 | |
fb623df5 | 239 | /* Output only one TOC entry per module. Normally linking fails if |
642a35f1 JW |
240 | there are more than 16K unique variables/constants in an executable. With |
241 | this option, linking fails only if there are more than 16K modules, or | |
242 | if there are more than 16K unique variables/constant in a single module. | |
243 | ||
244 | This is at the cost of having 2 extra loads and one extra store per | |
245 | function, and one less allocatable register. */ | |
583cf4db | 246 | #define MASK_MINIMAL_TOC 0x200 |
642a35f1 | 247 | |
9e654916 RK |
248 | /* Nonzero for the 64bit model: ints, longs, and pointers are 64 bits. */ |
249 | #define MASK_64BIT 0x400 | |
250 | ||
f85f4585 | 251 | /* Disable use of FPRs. */ |
d14a6d05 | 252 | #define MASK_SOFT_FLOAT 0x800 |
f85f4585 | 253 | |
4d30c363 MM |
254 | /* Enable load/store multiple, even on powerpc */ |
255 | #define MASK_MULTIPLE 0x1000 | |
8a61d227 | 256 | #define MASK_MULTIPLE_SET 0x2000 |
4d30c363 | 257 | |
7e69e155 MM |
258 | /* Use string instructions for block moves */ |
259 | #define MASK_STRING 0x4000 | |
938937d8 | 260 | #define MASK_STRING_SET 0x8000 |
7e69e155 | 261 | |
4697a36c MM |
262 | /* Temporary debug switches */ |
263 | #define MASK_DEBUG_STACK 0x10000 | |
264 | #define MASK_DEBUG_ARG 0x20000 | |
265 | ||
7e69e155 MM |
266 | #define TARGET_POWER (target_flags & MASK_POWER) |
267 | #define TARGET_POWER2 (target_flags & MASK_POWER2) | |
268 | #define TARGET_POWERPC (target_flags & MASK_POWERPC) | |
269 | #define TARGET_PPC_GPOPT (target_flags & MASK_PPC_GPOPT) | |
270 | #define TARGET_PPC_GFXOPT (target_flags & MASK_PPC_GFXOPT) | |
271 | #define TARGET_POWERPC64 (target_flags & MASK_POWERPC64) | |
272 | #define TARGET_NEW_MNEMONICS (target_flags & MASK_NEW_MNEMONICS) | |
273 | #define TARGET_NO_FP_IN_TOC (target_flags & MASK_NO_FP_IN_TOC) | |
274 | #define TARGET_NO_SUM_IN_TOC (target_flags & MASK_NO_SUM_IN_TOC) | |
275 | #define TARGET_MINIMAL_TOC (target_flags & MASK_MINIMAL_TOC) | |
276 | #define TARGET_64BIT (target_flags & MASK_64BIT) | |
277 | #define TARGET_SOFT_FLOAT (target_flags & MASK_SOFT_FLOAT) | |
278 | #define TARGET_MULTIPLE (target_flags & MASK_MULTIPLE) | |
279 | #define TARGET_MULTIPLE_SET (target_flags & MASK_MULTIPLE_SET) | |
280 | #define TARGET_STRING (target_flags & MASK_STRING) | |
938937d8 | 281 | #define TARGET_STRING_SET (target_flags & MASK_STRING_SET) |
4697a36c MM |
282 | #define TARGET_DEBUG_STACK (target_flags & MASK_DEBUG_STACK) |
283 | #define TARGET_DEBUG_ARG (target_flags & MASK_DEBUG_ARG) | |
7e69e155 | 284 | |
2f3e5814 | 285 | #define TARGET_32BIT (! TARGET_64BIT) |
7e69e155 | 286 | #define TARGET_HARD_FLOAT (! TARGET_SOFT_FLOAT) |
d14a6d05 | 287 | |
4697a36c MM |
288 | /* Pseudo target to indicate whether the object format is ELF |
289 | (to get around not having conditional compilation in the md file) */ | |
290 | #ifndef TARGET_ELF | |
291 | #define TARGET_ELF 0 | |
292 | #endif | |
293 | ||
294 | /* If this isn't V.4, don't support -mno-toc. */ | |
295 | #ifndef TARGET_NO_TOC | |
296 | #define TARGET_NO_TOC 0 | |
297 | #define TARGET_TOC 1 | |
298 | #endif | |
299 | ||
b6c9286a MM |
300 | /* Pseudo target to say whether this is Windows NT */ |
301 | #ifndef TARGET_WINDOWS_NT | |
302 | #define TARGET_WINDOWS_NT 0 | |
303 | #endif | |
304 | ||
305 | /* Pseudo target to say whether this is MAC */ | |
306 | #ifndef TARGET_MACOS | |
307 | #define TARGET_MACOS 0 | |
308 | #endif | |
309 | ||
310 | /* Pseudo target to say whether this is AIX */ | |
311 | #ifndef TARGET_AIX | |
312 | #if (TARGET_ELF || TARGET_WINDOWS_NT || TARGET_MACOS) | |
313 | #define TARGET_AIX 0 | |
314 | #else | |
315 | #define TARGET_AIX 1 | |
316 | #endif | |
317 | #endif | |
318 | ||
a3950905 MM |
319 | #ifndef TARGET_XL_CALL |
320 | #define TARGET_XL_CALL 0 | |
321 | #endif | |
322 | ||
fb623df5 | 323 | /* Run-time compilation parameters selecting different hardware subsets. |
f045b2c9 | 324 | |
fb623df5 | 325 | Macro to define tables used to set the flags. |
f045b2c9 RS |
326 | This is a list in braces of pairs in braces, |
327 | each pair being { "NAME", VALUE } | |
328 | where VALUE is the bits to set or minus the bits to clear. | |
329 | An empty string NAME is used to identify the default VALUE. */ | |
330 | ||
4d30c363 MM |
331 | /* This is meant to be redefined in the host dependent files */ |
332 | #ifndef SUBTARGET_SWITCHES | |
333 | #define SUBTARGET_SWITCHES | |
334 | #endif | |
335 | ||
938937d8 MM |
336 | #define TARGET_SWITCHES \ |
337 | {{"power", MASK_POWER | MASK_MULTIPLE | MASK_STRING}, \ | |
338 | {"power2", (MASK_POWER | MASK_MULTIPLE | MASK_STRING \ | |
339 | | MASK_POWER2)}, \ | |
340 | {"no-power2", - MASK_POWER2}, \ | |
341 | {"no-power", - (MASK_POWER | MASK_POWER2 | MASK_MULTIPLE \ | |
342 | | MASK_STRING)}, \ | |
343 | {"powerpc", MASK_POWERPC}, \ | |
344 | {"no-powerpc", - (MASK_POWERPC | MASK_PPC_GPOPT \ | |
345 | | MASK_PPC_GFXOPT | MASK_POWERPC64)}, \ | |
346 | {"powerpc-gpopt", MASK_POWERPC | MASK_PPC_GPOPT}, \ | |
347 | {"no-powerpc-gpopt", - MASK_PPC_GPOPT}, \ | |
348 | {"powerpc-gfxopt", MASK_POWERPC | MASK_PPC_GFXOPT}, \ | |
349 | {"no-powerpc-gfxopt", - MASK_PPC_GFXOPT}, \ | |
350 | {"new-mnemonics", MASK_NEW_MNEMONICS}, \ | |
351 | {"old-mnemonics", -MASK_NEW_MNEMONICS}, \ | |
352 | {"full-toc", - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC \ | |
353 | | MASK_MINIMAL_TOC)}, \ | |
354 | {"fp-in-toc", - MASK_NO_FP_IN_TOC}, \ | |
355 | {"no-fp-in-toc", MASK_NO_FP_IN_TOC}, \ | |
356 | {"sum-in-toc", - MASK_NO_SUM_IN_TOC}, \ | |
357 | {"no-sum-in-toc", MASK_NO_SUM_IN_TOC}, \ | |
358 | {"minimal-toc", MASK_MINIMAL_TOC}, \ | |
359 | {"minimal-toc", - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC)}, \ | |
360 | {"no-minimal-toc", - MASK_MINIMAL_TOC}, \ | |
361 | {"hard-float", - MASK_SOFT_FLOAT}, \ | |
362 | {"soft-float", MASK_SOFT_FLOAT}, \ | |
363 | {"multiple", MASK_MULTIPLE | MASK_MULTIPLE_SET}, \ | |
364 | {"no-multiple", - MASK_MULTIPLE}, \ | |
365 | {"no-multiple", MASK_MULTIPLE_SET}, \ | |
366 | {"string", MASK_STRING | MASK_STRING_SET}, \ | |
367 | {"no-string", - MASK_STRING}, \ | |
bbdd88df | 368 | {"no-string", MASK_STRING_SET}, \ |
4697a36c MM |
369 | {"debug-stack", MASK_DEBUG_STACK}, \ |
370 | {"debug-arg", MASK_DEBUG_ARG}, \ | |
938937d8 | 371 | SUBTARGET_SWITCHES \ |
fb623df5 RK |
372 | {"", TARGET_DEFAULT}} |
373 | ||
938937d8 | 374 | #define TARGET_DEFAULT (MASK_POWER | MASK_MULTIPLE | MASK_STRING) |
fb623df5 RK |
375 | |
376 | /* Processor type. */ | |
377 | enum processor_type | |
f86fe1fb | 378 | {PROCESSOR_RIOS1, |
fb623df5 | 379 | PROCESSOR_RIOS2, |
cf27b467 | 380 | PROCESSOR_MPCCORE, |
49a0b204 | 381 | PROCESSOR_PPC403, |
fb623df5 RK |
382 | PROCESSOR_PPC601, |
383 | PROCESSOR_PPC603, | |
384 | PROCESSOR_PPC604, | |
385 | PROCESSOR_PPC620}; | |
386 | ||
387 | extern enum processor_type rs6000_cpu; | |
388 | ||
389 | /* Recast the processor type to the cpu attribute. */ | |
390 | #define rs6000_cpu_attr ((enum attr_cpu)rs6000_cpu) | |
391 | ||
8482e358 | 392 | /* Define generic processor types based upon current deployment. */ |
8e3f41e7 | 393 | #define PROCESSOR_COMMON PROCESSOR_PPC601 |
8482e358 | 394 | #define PROCESSOR_POWER PROCESSOR_RIOS1 |
8e3f41e7 | 395 | #define PROCESSOR_POWERPC PROCESSOR_PPC604 |
6e151478 | 396 | |
fb623df5 | 397 | /* Define the default processor. This is overridden by other tm.h files. */ |
f86fe1fb | 398 | #define PROCESSOR_DEFAULT PROCESSOR_RIOS1 |
fb623df5 | 399 | |
6febd581 RK |
400 | /* Specify the dialect of assembler to use. New mnemonics is dialect one |
401 | and the old mnemonics are dialect zero. */ | |
402 | #define ASSEMBLER_DIALECT TARGET_NEW_MNEMONICS ? 1 : 0 | |
403 | ||
fb623df5 RK |
404 | /* This macro is similar to `TARGET_SWITCHES' but defines names of |
405 | command options that have values. Its definition is an | |
406 | initializer with a subgrouping for each command option. | |
407 | ||
408 | Each subgrouping contains a string constant, that defines the | |
409 | fixed part of the option name, and the address of a variable. | |
410 | The variable, type `char *', is set to the variable part of the | |
411 | given option if the fixed part matches. The actual option name | |
412 | is made by appending `-m' to the specified name. | |
413 | ||
414 | Here is an example which defines `-mshort-data-NUMBER'. If the | |
415 | given option is `-mshort-data-512', the variable `m88k_short_data' | |
416 | will be set to the string `"512"'. | |
417 | ||
418 | extern char *m88k_short_data; | |
419 | #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } } */ | |
420 | ||
b6c9286a MM |
421 | /* This is meant to be overriden in target specific files. */ |
422 | #ifndef SUBTARGET_OPTIONS | |
423 | #define SUBTARGET_OPTIONS | |
424 | #endif | |
425 | ||
8e3f41e7 MM |
426 | #define TARGET_OPTIONS \ |
427 | { \ | |
428 | {"cpu=", &rs6000_select[1].string}, \ | |
429 | {"tune=", &rs6000_select[2].string}, \ | |
430 | SUBTARGET_OPTIONS \ | |
b6c9286a | 431 | } |
fb623df5 | 432 | |
ff222560 | 433 | /* rs6000_select[0] is reserved for the default cpu defined via --with-cpu */ |
8e3f41e7 MM |
434 | struct rs6000_cpu_select |
435 | { | |
436 | char *string; | |
437 | char *name; | |
438 | int set_tune_p; | |
439 | int set_arch_p; | |
440 | }; | |
441 | ||
442 | extern struct rs6000_cpu_select rs6000_select[]; | |
fb623df5 | 443 | |
a3950905 | 444 | |
fb623df5 RK |
445 | /* Sometimes certain combinations of command options do not make sense |
446 | on a particular target machine. You can define a macro | |
447 | `OVERRIDE_OPTIONS' to take account of this. This macro, if | |
448 | defined, is executed once just after all the command options have | |
449 | been parsed. | |
450 | ||
451 | On the RS/6000 this is used to define the target cpu type. */ | |
452 | ||
8e3f41e7 | 453 | #define OVERRIDE_OPTIONS rs6000_override_options (TARGET_CPU_DEFAULT) |
f045b2c9 | 454 | |
4f074454 RK |
455 | /* Show we can debug even without a frame pointer. */ |
456 | #define CAN_DEBUG_WITHOUT_FP | |
f045b2c9 RS |
457 | \f |
458 | /* target machine storage layout */ | |
459 | ||
df44fa77 RK |
460 | /* Define to support cross compilation to an RS6000 target. */ |
461 | #define REAL_ARITHMETIC | |
462 | ||
13d39dbc | 463 | /* Define this macro if it is advisable to hold scalars in registers |
c81bebd7 | 464 | in a wider mode than that declared by the program. In such cases, |
ef457bda RK |
465 | the value is constrained to be within the bounds of the declared |
466 | type, but kept valid in the wider mode. The signedness of the | |
467 | extension may differ from that of the type. */ | |
468 | ||
469 | #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ | |
470 | if (GET_MODE_CLASS (MODE) == MODE_INT \ | |
471 | && GET_MODE_SIZE (MODE) < 4) \ | |
dac29d65 | 472 | (MODE) = SImode; |
ef457bda | 473 | |
f045b2c9 RS |
474 | /* Define this if most significant bit is lowest numbered |
475 | in instructions that operate on numbered bit-fields. */ | |
476 | /* That is true on RS/6000. */ | |
477 | #define BITS_BIG_ENDIAN 1 | |
478 | ||
479 | /* Define this if most significant byte of a word is the lowest numbered. */ | |
480 | /* That is true on RS/6000. */ | |
481 | #define BYTES_BIG_ENDIAN 1 | |
482 | ||
483 | /* Define this if most significant word of a multiword number is lowest | |
c81bebd7 | 484 | numbered. |
f045b2c9 RS |
485 | |
486 | For RS/6000 we can decide arbitrarily since there are no machine | |
487 | instructions for them. Might as well be consistent with bits and bytes. */ | |
488 | #define WORDS_BIG_ENDIAN 1 | |
489 | ||
fdaff8ba | 490 | /* number of bits in an addressable storage unit */ |
f045b2c9 RS |
491 | #define BITS_PER_UNIT 8 |
492 | ||
493 | /* Width in bits of a "word", which is the contents of a machine register. | |
494 | Note that this is not necessarily the width of data type `int'; | |
495 | if using 16-bit ints on a 68000, this would still be 32. | |
496 | But on a machine with 16-bit registers, this would be 16. */ | |
2f3e5814 | 497 | #define BITS_PER_WORD (! TARGET_POWERPC64 ? 32 : 64) |
2e360ab3 | 498 | #define MAX_BITS_PER_WORD 64 |
f045b2c9 RS |
499 | |
500 | /* Width of a word, in units (bytes). */ | |
2f3e5814 | 501 | #define UNITS_PER_WORD (! TARGET_POWERPC64 ? 4 : 8) |
ef0e53ce | 502 | #define MIN_UNITS_PER_WORD 4 |
2e360ab3 | 503 | #define UNITS_PER_FP_WORD 8 |
f045b2c9 | 504 | |
915f619f JW |
505 | /* Type used for ptrdiff_t, as a string used in a declaration. */ |
506 | #define PTRDIFF_TYPE "int" | |
507 | ||
f045b2c9 RS |
508 | /* Type used for wchar_t, as a string used in a declaration. */ |
509 | #define WCHAR_TYPE "short unsigned int" | |
510 | ||
511 | /* Width of wchar_t in bits. */ | |
512 | #define WCHAR_TYPE_SIZE 16 | |
513 | ||
9e654916 RK |
514 | /* A C expression for the size in bits of the type `short' on the |
515 | target machine. If you don't define this, the default is half a | |
516 | word. (If this would be less than one storage unit, it is | |
517 | rounded up to one unit.) */ | |
518 | #define SHORT_TYPE_SIZE 16 | |
519 | ||
520 | /* A C expression for the size in bits of the type `int' on the | |
521 | target machine. If you don't define this, the default is one | |
522 | word. */ | |
19d2d16f | 523 | #define INT_TYPE_SIZE 32 |
9e654916 RK |
524 | |
525 | /* A C expression for the size in bits of the type `long' on the | |
526 | target machine. If you don't define this, the default is one | |
527 | word. */ | |
2f3e5814 | 528 | #define LONG_TYPE_SIZE (TARGET_32BIT ? 32 : 64) |
9e654916 RK |
529 | #define MAX_LONG_TYPE_SIZE 64 |
530 | ||
531 | /* A C expression for the size in bits of the type `long long' on the | |
532 | target machine. If you don't define this, the default is two | |
533 | words. */ | |
534 | #define LONG_LONG_TYPE_SIZE 64 | |
535 | ||
536 | /* A C expression for the size in bits of the type `char' on the | |
537 | target machine. If you don't define this, the default is one | |
538 | quarter of a word. (If this would be less than one storage unit, | |
539 | it is rounded up to one unit.) */ | |
540 | #define CHAR_TYPE_SIZE BITS_PER_UNIT | |
541 | ||
542 | /* A C expression for the size in bits of the type `float' on the | |
543 | target machine. If you don't define this, the default is one | |
544 | word. */ | |
545 | #define FLOAT_TYPE_SIZE 32 | |
546 | ||
547 | /* A C expression for the size in bits of the type `double' on the | |
548 | target machine. If you don't define this, the default is two | |
549 | words. */ | |
550 | #define DOUBLE_TYPE_SIZE 64 | |
551 | ||
552 | /* A C expression for the size in bits of the type `long double' on | |
553 | the target machine. If you don't define this, the default is two | |
554 | words. */ | |
555 | #define LONG_DOUBLE_TYPE_SIZE 64 | |
556 | ||
f045b2c9 RS |
557 | /* Width in bits of a pointer. |
558 | See also the macro `Pmode' defined below. */ | |
2f3e5814 | 559 | #define POINTER_SIZE (TARGET_32BIT ? 32 : 64) |
f045b2c9 RS |
560 | |
561 | /* Allocation boundary (in *bits*) for storing arguments in argument list. */ | |
2f3e5814 | 562 | #define PARM_BOUNDARY (TARGET_32BIT ? 32 : 64) |
f045b2c9 RS |
563 | |
564 | /* Boundary (in *bits*) on which stack pointer should be aligned. */ | |
565 | #define STACK_BOUNDARY 64 | |
566 | ||
567 | /* Allocation boundary (in *bits*) for the code of a function. */ | |
568 | #define FUNCTION_BOUNDARY 32 | |
569 | ||
570 | /* No data type wants to be aligned rounder than this. */ | |
b73fd26c DE |
571 | #define BIGGEST_ALIGNMENT 64 |
572 | ||
6bc3403c DE |
573 | /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ |
574 | #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ | |
575 | (DECL_MODE (FIELD) != DFmode ? (COMPUTED) : MIN ((COMPUTED), 32)) | |
f045b2c9 RS |
576 | |
577 | /* Alignment of field after `int : 0' in a structure. */ | |
578 | #define EMPTY_FIELD_BOUNDARY 32 | |
579 | ||
580 | /* Every structure's size must be a multiple of this. */ | |
581 | #define STRUCTURE_SIZE_BOUNDARY 8 | |
582 | ||
583 | /* A bitfield declared as `int' forces `int' alignment for the struct. */ | |
584 | #define PCC_BITFIELD_TYPE_MATTERS 1 | |
585 | ||
6bc3403c DE |
586 | /* AIX increases natural record alignment to doubleword if the first |
587 | field is an FP double while the FP fields remain word aligned. */ | |
588 | #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ | |
589 | ((TREE_CODE (STRUCT) == RECORD_TYPE \ | |
590 | || TREE_CODE (STRUCT) == UNION_TYPE \ | |
591 | || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ | |
592 | && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \ | |
593 | ? MAX (MAX ((COMPUTED), (SPECIFIED)), BIGGEST_ALIGNMENT) \ | |
594 | : MAX ((COMPUTED), (SPECIFIED))) | |
595 | ||
f045b2c9 RS |
596 | /* Make strings word-aligned so strcpy from constants will be faster. */ |
597 | #define CONSTANT_ALIGNMENT(EXP, ALIGN) \ | |
598 | (TREE_CODE (EXP) == STRING_CST \ | |
599 | && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) | |
600 | ||
601 | /* Make arrays of chars word-aligned for the same reasons. */ | |
602 | #define DATA_ALIGNMENT(TYPE, ALIGN) \ | |
603 | (TREE_CODE (TYPE) == ARRAY_TYPE \ | |
604 | && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \ | |
605 | && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) | |
606 | ||
fdaff8ba | 607 | /* Non-zero if move instructions will actually fail to work |
f045b2c9 | 608 | when given unaligned data. */ |
fdaff8ba | 609 | #define STRICT_ALIGNMENT 0 |
f045b2c9 RS |
610 | \f |
611 | /* Standard register usage. */ | |
612 | ||
613 | /* Number of actual hardware registers. | |
614 | The hardware registers are assigned numbers for the compiler | |
615 | from 0 to just below FIRST_PSEUDO_REGISTER. | |
616 | All registers that the compiler knows about must be given numbers, | |
617 | even those that are not normally considered general registers. | |
618 | ||
619 | RS/6000 has 32 fixed-point registers, 32 floating-point registers, | |
620 | an MQ register, a count register, a link register, and 8 condition | |
621 | register fields, which we view here as separate registers. | |
622 | ||
623 | In addition, the difference between the frame and argument pointers is | |
624 | a function of the number of registers saved, so we need to have a | |
625 | register for AP that will later be eliminated in favor of SP or FP. | |
802a0058 | 626 | This is a normal register, but it is fixed. |
f045b2c9 | 627 | |
802a0058 MM |
628 | We also create a pseudo register for float/int conversions, that will |
629 | really represent the memory location used. It is represented here as | |
630 | a register, in order to work around problems in allocating stack storage | |
631 | in inline functions. */ | |
632 | ||
633 | #define FIRST_PSEUDO_REGISTER 77 | |
f045b2c9 RS |
634 | |
635 | /* 1 for registers that have pervasive standard uses | |
636 | and are not available for the register allocator. | |
637 | ||
c81bebd7 | 638 | On RS/6000, r1 is used for the stack and r2 is used as the TOC pointer. |
f045b2c9 | 639 | |
a127c4e5 RK |
640 | cr5 is not supposed to be used. |
641 | ||
642 | On System V implementations, r13 is fixed and not available for use. */ | |
643 | ||
644 | #ifndef FIXED_R13 | |
645 | #define FIXED_R13 0 | |
646 | #endif | |
f045b2c9 RS |
647 | |
648 | #define FIXED_REGISTERS \ | |
a127c4e5 | 649 | {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_R13, 0, 0, \ |
f045b2c9 RS |
650 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
651 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
652 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
802a0058 | 653 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1} |
f045b2c9 RS |
654 | |
655 | /* 1 for registers not available across function calls. | |
656 | These must include the FIXED_REGISTERS and also any | |
657 | registers that can be used without being saved. | |
658 | The latter must include the registers where values are returned | |
659 | and the register where structure-value addresses are passed. | |
660 | Aside from that, you can include as many other registers as you like. */ | |
661 | ||
662 | #define CALL_USED_REGISTERS \ | |
a127c4e5 | 663 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, FIXED_R13, 0, 0, \ |
f045b2c9 RS |
664 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
665 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \ | |
666 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
802a0058 | 667 | 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1} |
f045b2c9 RS |
668 | |
669 | /* List the order in which to allocate registers. Each register must be | |
670 | listed once, even those in FIXED_REGISTERS. | |
671 | ||
672 | We allocate in the following order: | |
673 | fp0 (not saved or used for anything) | |
674 | fp13 - fp2 (not saved; incoming fp arg registers) | |
675 | fp1 (not saved; return value) | |
676 | fp31 - fp14 (saved; order given to save least number) | |
677 | cr1, cr6, cr7 (not saved or special) | |
678 | cr0 (not saved, but used for arithmetic operations) | |
679 | cr2, cr3, cr4 (saved) | |
680 | r0 (not saved; cannot be base reg) | |
681 | r9 (not saved; best for TImode) | |
682 | r11, r10, r8-r4 (not saved; highest used first to make less conflict) | |
683 | r3 (not saved; return value register) | |
684 | r31 - r13 (saved; order given to save least number) | |
685 | r12 (not saved; if used for DImode or DFmode would use r13) | |
686 | mq (not saved; best to use it if we can) | |
687 | ctr (not saved; when we have the choice ctr is better) | |
688 | lr (saved) | |
689 | cr5, r1, r2, ap (fixed) */ | |
690 | ||
691 | #define REG_ALLOC_ORDER \ | |
692 | {32, \ | |
693 | 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, \ | |
694 | 33, \ | |
695 | 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, \ | |
696 | 50, 49, 48, 47, 46, \ | |
697 | 69, 74, 75, 68, 70, 71, 72, \ | |
698 | 0, \ | |
699 | 9, 11, 10, 8, 7, 6, 5, 4, \ | |
700 | 3, \ | |
701 | 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \ | |
702 | 18, 17, 16, 15, 14, 13, 12, \ | |
703 | 64, 66, 65, \ | |
802a0058 | 704 | 73, 1, 2, 67, 76} |
f045b2c9 RS |
705 | |
706 | /* True if register is floating-point. */ | |
707 | #define FP_REGNO_P(N) ((N) >= 32 && (N) <= 63) | |
708 | ||
709 | /* True if register is a condition register. */ | |
710 | #define CR_REGNO_P(N) ((N) >= 68 && (N) <= 75) | |
711 | ||
712 | /* True if register is an integer register. */ | |
713 | #define INT_REGNO_P(N) ((N) <= 31 || (N) == 67) | |
714 | ||
802a0058 MM |
715 | /* True if register is the temporary memory location used for int/float |
716 | conversion. */ | |
717 | #define FPMEM_REGNO_P(N) ((N) == FPMEM_REGNUM) | |
718 | ||
f045b2c9 RS |
719 | /* Return number of consecutive hard regs needed starting at reg REGNO |
720 | to hold something of mode MODE. | |
721 | This is ordinarily the length in words of a value of mode MODE | |
722 | but can be less for certain modes in special long registers. | |
723 | ||
724 | On RS/6000, ordinary registers hold 32 bits worth; | |
725 | a single floating point register holds 64 bits worth. */ | |
726 | ||
802a0058 MM |
727 | #define HARD_REGNO_NREGS(REGNO, MODE) \ |
728 | (FP_REGNO_P (REGNO) || FPMEM_REGNO_P (REGNO) \ | |
2e360ab3 | 729 | ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \ |
f045b2c9 RS |
730 | : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) |
731 | ||
732 | /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. | |
bdfd4e31 RK |
733 | For POWER and PowerPC, the GPRs can hold any mode, but the float |
734 | registers only can hold floating modes and DImode, and CR register only | |
735 | can hold CC modes. We cannot put TImode anywhere except general | |
736 | register and it must be able to fit within the register set. */ | |
f045b2c9 | 737 | |
802a0058 MM |
738 | #define HARD_REGNO_MODE_OK(REGNO, MODE) \ |
739 | (FP_REGNO_P (REGNO) ? \ | |
740 | (GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
741 | || (GET_MODE_CLASS (MODE) == MODE_INT \ | |
742 | && GET_MODE_SIZE (MODE) == UNITS_PER_FP_WORD)) \ | |
743 | : CR_REGNO_P (REGNO) ? GET_MODE_CLASS (MODE) == MODE_CC \ | |
744 | : FPMEM_REGNO_P (REGNO) ? ((MODE) == DImode || (MODE) == DFmode) \ | |
745 | : ! INT_REGNO_P (REGNO) ? (GET_MODE_CLASS (MODE) == MODE_INT \ | |
bdfd4e31 | 746 | && GET_MODE_SIZE (MODE) <= UNITS_PER_WORD) \ |
f045b2c9 RS |
747 | : 1) |
748 | ||
749 | /* Value is 1 if it is a good idea to tie two pseudo registers | |
750 | when one has mode MODE1 and one has mode MODE2. | |
751 | If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, | |
752 | for any hard reg, then this must be 0 for correct output. */ | |
753 | #define MODES_TIEABLE_P(MODE1, MODE2) \ | |
754 | (GET_MODE_CLASS (MODE1) == MODE_FLOAT \ | |
755 | ? GET_MODE_CLASS (MODE2) == MODE_FLOAT \ | |
756 | : GET_MODE_CLASS (MODE2) == MODE_FLOAT \ | |
757 | ? GET_MODE_CLASS (MODE1) == MODE_FLOAT \ | |
758 | : GET_MODE_CLASS (MODE1) == MODE_CC \ | |
759 | ? GET_MODE_CLASS (MODE2) == MODE_CC \ | |
760 | : GET_MODE_CLASS (MODE2) == MODE_CC \ | |
761 | ? GET_MODE_CLASS (MODE1) == MODE_CC \ | |
762 | : 1) | |
763 | ||
764 | /* A C expression returning the cost of moving data from a register of class | |
765 | CLASS1 to one of CLASS2. | |
766 | ||
767 | On the RS/6000, copying between floating-point and fixed-point | |
768 | registers is expensive. */ | |
769 | ||
770 | #define REGISTER_MOVE_COST(CLASS1, CLASS2) \ | |
771 | ((CLASS1) == FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 2 \ | |
772 | : (CLASS1) == FLOAT_REGS && (CLASS2) != FLOAT_REGS ? 10 \ | |
773 | : (CLASS1) != FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 10 \ | |
a4b970a0 | 774 | : (((CLASS1) == SPECIAL_REGS || (CLASS1) == MQ_REGS \ |
5119dc13 RK |
775 | || (CLASS1) == LINK_REGS || (CLASS1) == CTR_REGS \ |
776 | || (CLASS1) == LINK_OR_CTR_REGS) \ | |
a4b970a0 | 777 | && ((CLASS2) == SPECIAL_REGS || (CLASS2) == MQ_REGS \ |
5119dc13 | 778 | || (CLASS2) == LINK_REGS || (CLASS2) == CTR_REGS \ |
802a0058 | 779 | || (CLASS2) == LINK_OR_CTR_REGS)) ? 10 \ |
f045b2c9 RS |
780 | : 2) |
781 | ||
782 | /* A C expressions returning the cost of moving data of MODE from a register to | |
783 | or from memory. | |
784 | ||
785 | On the RS/6000, bump this up a bit. */ | |
786 | ||
ab4a5fc9 RK |
787 | #define MEMORY_MOVE_COST(MODE) \ |
788 | ((GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
789 | && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \ | |
790 | ? 3 : 2) \ | |
791 | + 4) | |
f045b2c9 RS |
792 | |
793 | /* Specify the cost of a branch insn; roughly the number of extra insns that | |
794 | should be added to avoid a branch. | |
795 | ||
ef457bda | 796 | Set this to 3 on the RS/6000 since that is roughly the average cost of an |
f045b2c9 RS |
797 | unscheduled conditional branch. */ |
798 | ||
ef457bda | 799 | #define BRANCH_COST 3 |
f045b2c9 | 800 | |
5a5e4c2c RK |
801 | /* A C statement (sans semicolon) to update the integer variable COST |
802 | based on the relationship between INSN that is dependent on | |
803 | DEP_INSN through the dependence LINK. The default is to make no | |
804 | adjustment to COST. On the RS/6000, ignore the cost of anti- and | |
805 | output-dependencies. In fact, output dependencies on the CR do have | |
806 | a cost, but it is probably not worthwhile to track it. */ | |
807 | ||
808 | #define ADJUST_COST(INSN,LINK,DEP_INSN,COST) \ | |
b0634e74 | 809 | (COST) = rs6000_adjust_cost (INSN,LINK,DEP_INSN,COST) |
5a5e4c2c | 810 | |
6febd581 RK |
811 | /* Define this macro to change register usage conditional on target flags. |
812 | Set MQ register fixed (already call_used) if not POWER architecture | |
f85f4585 RK |
813 | (RIOS1, RIOS2, RSC, and PPC601) so that it will not be allocated. |
814 | Conditionally disable FPRs. */ | |
815 | ||
816 | #define CONDITIONAL_REGISTER_USAGE \ | |
817 | { \ | |
818 | if (! TARGET_POWER) \ | |
819 | fixed_regs[64] = 1; \ | |
d14a6d05 MM |
820 | if (TARGET_SOFT_FLOAT) \ |
821 | for (i = 32; i < 64; i++) \ | |
f85f4585 RK |
822 | fixed_regs[i] = call_used_regs[i] = 1; \ |
823 | } | |
6febd581 | 824 | |
f045b2c9 RS |
825 | /* Specify the registers used for certain standard purposes. |
826 | The values of these macros are register numbers. */ | |
827 | ||
828 | /* RS/6000 pc isn't overloaded on a register that the compiler knows about. */ | |
829 | /* #define PC_REGNUM */ | |
830 | ||
831 | /* Register to use for pushing function arguments. */ | |
832 | #define STACK_POINTER_REGNUM 1 | |
833 | ||
834 | /* Base register for access to local variables of the function. */ | |
835 | #define FRAME_POINTER_REGNUM 31 | |
836 | ||
837 | /* Value should be nonzero if functions must have frame pointers. | |
838 | Zero means the frame pointer need not be set up (and parms | |
839 | may be accessed via the stack pointer) in functions that seem suitable. | |
840 | This is computed in `reload', in reload1.c. */ | |
841 | #define FRAME_POINTER_REQUIRED 0 | |
842 | ||
843 | /* Base register for access to arguments of the function. */ | |
844 | #define ARG_POINTER_REGNUM 67 | |
845 | ||
846 | /* Place to put static chain when calling a function that requires it. */ | |
847 | #define STATIC_CHAIN_REGNUM 11 | |
848 | ||
b6c9286a MM |
849 | /* count register number for special purposes */ |
850 | #define COUNT_REGISTER_REGNUM 66 | |
851 | ||
802a0058 MM |
852 | /* Special register that represents memory, used for float/int conversions. */ |
853 | #define FPMEM_REGNUM 76 | |
854 | ||
1ff7789b MM |
855 | /* Register to use as a placeholder for the GOT/allocated TOC register. |
856 | FINALIZE_PIC will change all uses of this register to a an appropriate | |
857 | pseudo register when it adds the code to setup the GOT. We use r2 | |
858 | because it is a reserved register in all of the ABI's. */ | |
859 | #define GOT_TOC_REGNUM 2 | |
860 | ||
f045b2c9 RS |
861 | /* Place that structure value return address is placed. |
862 | ||
863 | On the RS/6000, it is passed as an extra parameter. */ | |
1ff7789b | 864 | #define STRUCT_VALUE 0 |
f045b2c9 RS |
865 | \f |
866 | /* Define the classes of registers for register constraints in the | |
867 | machine description. Also define ranges of constants. | |
868 | ||
869 | One of the classes must always be named ALL_REGS and include all hard regs. | |
870 | If there is more than one class, another class must be named NO_REGS | |
871 | and contain no registers. | |
872 | ||
873 | The name GENERAL_REGS must be the name of a class (or an alias for | |
874 | another name such as ALL_REGS). This is the class of registers | |
875 | that is allowed by "g" or "r" in a register constraint. | |
876 | Also, registers outside this class are allocated only when | |
877 | instructions express preferences for them. | |
878 | ||
879 | The classes must be numbered in nondecreasing order; that is, | |
880 | a larger-numbered class must never be contained completely | |
881 | in a smaller-numbered class. | |
882 | ||
883 | For any two classes, it is very desirable that there be another | |
884 | class that represents their union. */ | |
c81bebd7 | 885 | |
f045b2c9 RS |
886 | /* The RS/6000 has three types of registers, fixed-point, floating-point, |
887 | and condition registers, plus three special registers, MQ, CTR, and the | |
888 | link register. | |
889 | ||
890 | However, r0 is special in that it cannot be used as a base register. | |
891 | So make a class for registers valid as base registers. | |
892 | ||
893 | Also, cr0 is the only condition code register that can be used in | |
802a0058 MM |
894 | arithmetic insns, so make a separate class for it. |
895 | ||
896 | There is a special 'registrer' (76), which is not a register, but a | |
897 | placeholder for memory allocated to convert between floating point and | |
898 | integral types. This works around a problem where if we allocate memory | |
899 | with allocate_stack_{local,temp} and the function is an inline function, the | |
900 | memory allocated will clobber memory in the caller. So we use a special | |
901 | register, and if that is used, we allocate stack space for it. */ | |
f045b2c9 | 902 | |
ebedb4dd MM |
903 | enum reg_class |
904 | { | |
905 | NO_REGS, | |
ebedb4dd MM |
906 | BASE_REGS, |
907 | GENERAL_REGS, | |
908 | FLOAT_REGS, | |
909 | NON_SPECIAL_REGS, | |
910 | MQ_REGS, | |
911 | LINK_REGS, | |
912 | CTR_REGS, | |
913 | LINK_OR_CTR_REGS, | |
914 | SPECIAL_REGS, | |
915 | SPEC_OR_GEN_REGS, | |
916 | CR0_REGS, | |
ebedb4dd MM |
917 | CR_REGS, |
918 | NON_FLOAT_REGS, | |
802a0058 MM |
919 | FPMEM_REGS, |
920 | FLOAT_OR_FPMEM_REGS, | |
ebedb4dd MM |
921 | ALL_REGS, |
922 | LIM_REG_CLASSES | |
923 | }; | |
f045b2c9 RS |
924 | |
925 | #define N_REG_CLASSES (int) LIM_REG_CLASSES | |
926 | ||
927 | /* Give names of register classes as strings for dump file. */ | |
928 | ||
ebedb4dd MM |
929 | #define REG_CLASS_NAMES \ |
930 | { \ | |
931 | "NO_REGS", \ | |
ebedb4dd MM |
932 | "BASE_REGS", \ |
933 | "GENERAL_REGS", \ | |
934 | "FLOAT_REGS", \ | |
935 | "NON_SPECIAL_REGS", \ | |
936 | "MQ_REGS", \ | |
937 | "LINK_REGS", \ | |
938 | "CTR_REGS", \ | |
939 | "LINK_OR_CTR_REGS", \ | |
940 | "SPECIAL_REGS", \ | |
941 | "SPEC_OR_GEN_REGS", \ | |
942 | "CR0_REGS", \ | |
ebedb4dd MM |
943 | "CR_REGS", \ |
944 | "NON_FLOAT_REGS", \ | |
802a0058 MM |
945 | "FPMEM_REGS", \ |
946 | "FLOAT_OR_FPMEM_REGS", \ | |
ebedb4dd MM |
947 | "ALL_REGS" \ |
948 | } | |
f045b2c9 RS |
949 | |
950 | /* Define which registers fit in which classes. | |
951 | This is an initializer for a vector of HARD_REG_SET | |
952 | of length N_REG_CLASSES. */ | |
953 | ||
ebedb4dd MM |
954 | #define REG_CLASS_CONTENTS \ |
955 | { \ | |
956 | { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ | |
ebedb4dd MM |
957 | { 0xfffffffe, 0x00000000, 0x00000008 }, /* BASE_REGS */ \ |
958 | { 0xffffffff, 0x00000000, 0x00000008 }, /* GENERAL_REGS */ \ | |
959 | { 0x00000000, 0xffffffff, 0x00000000 }, /* FLOAT_REGS */ \ | |
960 | { 0xffffffff, 0xffffffff, 0x00000008 }, /* NON_SPECIAL_REGS */ \ | |
961 | { 0x00000000, 0x00000000, 0x00000001 }, /* MQ_REGS */ \ | |
962 | { 0x00000000, 0x00000000, 0x00000002 }, /* LINK_REGS */ \ | |
963 | { 0x00000000, 0x00000000, 0x00000004 }, /* CTR_REGS */ \ | |
964 | { 0x00000000, 0x00000000, 0x00000006 }, /* LINK_OR_CTR_REGS */ \ | |
965 | { 0x00000000, 0x00000000, 0x00000007 }, /* SPECIAL_REGS */ \ | |
966 | { 0xffffffff, 0x00000000, 0x0000000f }, /* SPEC_OR_GEN_REGS */ \ | |
967 | { 0x00000000, 0x00000000, 0x00000010 }, /* CR0_REGS */ \ | |
ebedb4dd MM |
968 | { 0x00000000, 0x00000000, 0x00000ff0 }, /* CR_REGS */ \ |
969 | { 0xffffffff, 0x00000000, 0x0000ffff }, /* NON_FLOAT_REGS */ \ | |
802a0058 MM |
970 | { 0x00000000, 0x00000000, 0x00010000 }, /* FPMEM_REGS */ \ |
971 | { 0x00000000, 0xffffffff, 0x00010000 }, /* FLOAT_OR_FPMEM_REGS */ \ | |
972 | { 0xffffffff, 0xffffffff, 0x0001ffff } /* ALL_REGS */ \ | |
ebedb4dd | 973 | } |
f045b2c9 RS |
974 | |
975 | /* The same information, inverted: | |
976 | Return the class number of the smallest class containing | |
977 | reg number REGNO. This could be a conditional expression | |
978 | or could index an array. */ | |
979 | ||
802a0058 MM |
980 | #define REGNO_REG_CLASS(REGNO) \ |
981 | ((REGNO) == 0 ? GENERAL_REGS \ | |
982 | : (REGNO) < 32 ? BASE_REGS \ | |
983 | : FP_REGNO_P (REGNO) ? FLOAT_REGS \ | |
984 | : (REGNO) == 68 ? CR0_REGS \ | |
985 | : CR_REGNO_P (REGNO) ? CR_REGS \ | |
986 | : (REGNO) == 64 ? MQ_REGS \ | |
987 | : (REGNO) == 65 ? LINK_REGS \ | |
988 | : (REGNO) == 66 ? CTR_REGS \ | |
989 | : (REGNO) == 67 ? BASE_REGS \ | |
990 | : (REGNO) == 76 ? FPMEM_REGS \ | |
f045b2c9 RS |
991 | : NO_REGS) |
992 | ||
993 | /* The class value for index registers, and the one for base regs. */ | |
994 | #define INDEX_REG_CLASS GENERAL_REGS | |
995 | #define BASE_REG_CLASS BASE_REGS | |
996 | ||
997 | /* Get reg_class from a letter such as appears in the machine description. */ | |
998 | ||
999 | #define REG_CLASS_FROM_LETTER(C) \ | |
1000 | ((C) == 'f' ? FLOAT_REGS \ | |
1001 | : (C) == 'b' ? BASE_REGS \ | |
1002 | : (C) == 'h' ? SPECIAL_REGS \ | |
1003 | : (C) == 'q' ? MQ_REGS \ | |
1004 | : (C) == 'c' ? CTR_REGS \ | |
1005 | : (C) == 'l' ? LINK_REGS \ | |
1006 | : (C) == 'x' ? CR0_REGS \ | |
1007 | : (C) == 'y' ? CR_REGS \ | |
802a0058 | 1008 | : (C) == 'z' ? FPMEM_REGS \ |
f045b2c9 RS |
1009 | : NO_REGS) |
1010 | ||
1011 | /* The letters I, J, K, L, M, N, and P in a register constraint string | |
1012 | can be used to stand for particular ranges of immediate operands. | |
1013 | This macro defines what the ranges are. | |
1014 | C is the letter, and VALUE is a constant value. | |
1015 | Return 1 if VALUE is in the range specified by C. | |
1016 | ||
c81bebd7 | 1017 | `I' is signed 16-bit constants |
f045b2c9 RS |
1018 | `J' is a constant with only the high-order 16 bits non-zero |
1019 | `K' is a constant with only the low-order 16 bits non-zero | |
1020 | `L' is a constant that can be placed into a mask operand | |
1021 | `M' is a constant that is greater than 31 | |
1022 | `N' is a constant that is an exact power of two | |
1023 | `O' is the constant zero | |
1024 | `P' is a constant whose negation is a signed 16-bit constant */ | |
1025 | ||
1026 | #define CONST_OK_FOR_LETTER_P(VALUE, C) \ | |
1027 | ( (C) == 'I' ? (unsigned) ((VALUE) + 0x8000) < 0x10000 \ | |
1028 | : (C) == 'J' ? ((VALUE) & 0xffff) == 0 \ | |
1029 | : (C) == 'K' ? ((VALUE) & 0xffff0000) == 0 \ | |
1030 | : (C) == 'L' ? mask_constant (VALUE) \ | |
1031 | : (C) == 'M' ? (VALUE) > 31 \ | |
1032 | : (C) == 'N' ? exact_log2 (VALUE) >= 0 \ | |
1033 | : (C) == 'O' ? (VALUE) == 0 \ | |
1034 | : (C) == 'P' ? (unsigned) ((- (VALUE)) + 0x8000) < 0x1000 \ | |
1035 | : 0) | |
1036 | ||
1037 | /* Similar, but for floating constants, and defining letters G and H. | |
1038 | Here VALUE is the CONST_DOUBLE rtx itself. | |
1039 | ||
1040 | We flag for special constants when we can copy the constant into | |
4e74d8ec | 1041 | a general register in two insns for DF/DI and one insn for SF. |
f045b2c9 | 1042 | |
c4c40373 | 1043 | 'H' is used for DI/DF constants that take 3 insns. */ |
4e74d8ec MM |
1044 | |
1045 | #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ | |
c4c40373 MM |
1046 | ( (C) == 'G' ? (num_insns_constant (VALUE, GET_MODE (VALUE)) \ |
1047 | == ((GET_MODE (VALUE) == SFmode) ? 1 : 2)) \ | |
1048 | : (C) == 'H' ? (num_insns_constant (VALUE, GET_MODE (VALUE)) == 3) \ | |
1049 | : 0) | |
f045b2c9 RS |
1050 | |
1051 | /* Optional extra constraints for this machine. | |
1052 | ||
b6c9286a MM |
1053 | 'Q' means that is a memory operand that is just an offset from a reg. |
1054 | 'R' is for AIX TOC entries. | |
1055 | 'S' is for Windows NT SYMBOL_REFs | |
88228c4b MM |
1056 | 'T' is for Windows NT LABEL_REFs. |
1057 | 'U' is for V.4 small data references. */ | |
f045b2c9 | 1058 | |
e8a8bc24 RK |
1059 | #define EXTRA_CONSTRAINT(OP, C) \ |
1060 | ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \ | |
d537c24d | 1061 | : (C) == 'R' ? LEGITIMATE_CONSTANT_POOL_ADDRESS_P (OP) \ |
b6c9286a MM |
1062 | : (C) == 'S' ? (TARGET_WINDOWS_NT && DEFAULT_ABI == ABI_NT && GET_CODE (OP) == SYMBOL_REF)\ |
1063 | : (C) == 'T' ? (TARGET_WINDOWS_NT && DEFAULT_ABI == ABI_NT && GET_CODE (OP) == LABEL_REF) \ | |
c81bebd7 MM |
1064 | : (C) == 'U' ? ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) \ |
1065 | && small_data_operand (OP, GET_MODE (OP))) \ | |
e8a8bc24 | 1066 | : 0) |
f045b2c9 RS |
1067 | |
1068 | /* Given an rtx X being reloaded into a reg required to be | |
1069 | in class CLASS, return the class of reg to actually use. | |
1070 | In general this is just CLASS; but on some machines | |
c81bebd7 | 1071 | in some cases it is preferable to use a more restrictive class. |
f045b2c9 RS |
1072 | |
1073 | On the RS/6000, we have to return NO_REGS when we want to reload a | |
1074 | floating-point CONST_DOUBLE to force it to be copied to memory. */ | |
1075 | ||
802a0058 | 1076 | #define PREFERRED_RELOAD_CLASS(X,CLASS) \ |
f045b2c9 RS |
1077 | ((GET_CODE (X) == CONST_DOUBLE \ |
1078 | && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ | |
1079 | ? NO_REGS : (CLASS)) | |
c81bebd7 | 1080 | |
f045b2c9 RS |
1081 | /* Return the register class of a scratch register needed to copy IN into |
1082 | or out of a register in CLASS in MODE. If it can be done directly, | |
1083 | NO_REGS is returned. */ | |
1084 | ||
1085 | #define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \ | |
1086 | secondary_reload_class (CLASS, MODE, IN) | |
1087 | ||
7ea555a4 RK |
1088 | /* If we are copying between FP registers and anything else, we need a memory |
1089 | location. */ | |
1090 | ||
1091 | #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \ | |
1092 | ((CLASS1) != (CLASS2) && ((CLASS1) == FLOAT_REGS || (CLASS2) == FLOAT_REGS)) | |
1093 | ||
f045b2c9 RS |
1094 | /* Return the maximum number of consecutive registers |
1095 | needed to represent mode MODE in a register of class CLASS. | |
1096 | ||
1097 | On RS/6000, this is the size of MODE in words, | |
1098 | except in the FP regs, where a single reg is enough for two words. */ | |
802a0058 MM |
1099 | #define CLASS_MAX_NREGS(CLASS, MODE) \ |
1100 | (((CLASS) == FLOAT_REGS || (CLASS) == FPMEM_REGS \ | |
1101 | || (CLASS) == FLOAT_OR_FPMEM_REGS) \ | |
2e360ab3 | 1102 | ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \ |
f045b2c9 | 1103 | : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) |
580d3230 RK |
1104 | |
1105 | /* If defined, gives a class of registers that cannot be used as the | |
1106 | operand of a SUBREG that changes the size of the object. */ | |
1107 | ||
802a0058 | 1108 | #define CLASS_CANNOT_CHANGE_SIZE FLOAT_OR_FPMEM_REGS |
f045b2c9 RS |
1109 | \f |
1110 | /* Stack layout; function entry, exit and calling. */ | |
1111 | ||
6b67933e RK |
1112 | /* Enumeration to give which calling sequence to use. */ |
1113 | enum rs6000_abi { | |
1114 | ABI_NONE, | |
1115 | ABI_AIX, /* IBM's AIX */ | |
b6c9286a MM |
1116 | ABI_AIX_NODESC, /* AIX calling sequence minus function descriptors */ |
1117 | ABI_V4, /* System V.4/eabi */ | |
c81bebd7 MM |
1118 | ABI_NT, /* Windows/NT */ |
1119 | ABI_SOLARIS /* Solaris */ | |
6b67933e RK |
1120 | }; |
1121 | ||
b6c9286a MM |
1122 | extern enum rs6000_abi rs6000_current_abi; /* available for use by subtarget */ |
1123 | ||
1124 | /* Default ABI to compile code for */ | |
1125 | #ifndef DEFAULT_ABI | |
1126 | #define DEFAULT_ABI ABI_AIX | |
1127 | #endif | |
1128 | ||
4697a36c MM |
1129 | /* Structure used to define the rs6000 stack */ |
1130 | typedef struct rs6000_stack { | |
1131 | int first_gp_reg_save; /* first callee saved GP register used */ | |
1132 | int first_fp_reg_save; /* first callee saved FP register used */ | |
1133 | int lr_save_p; /* true if the link reg needs to be saved */ | |
1134 | int cr_save_p; /* true if the CR reg needs to be saved */ | |
b6c9286a | 1135 | int toc_save_p; /* true if the TOC needs to be saved */ |
4697a36c MM |
1136 | int push_p; /* true if we need to allocate stack space */ |
1137 | int calls_p; /* true if the function makes any calls */ | |
b6c9286a MM |
1138 | int main_p; /* true if this is main */ |
1139 | int main_save_p; /* true if this is main and we need to save args */ | |
802a0058 | 1140 | int fpmem_p; /* true if float/int conversion temp needed */ |
6b67933e | 1141 | enum rs6000_abi abi; /* which ABI to use */ |
abc95ed3 RK |
1142 | int gp_save_offset; /* offset to save GP regs from initial SP */ |
1143 | int fp_save_offset; /* offset to save FP regs from initial SP */ | |
4697a36c MM |
1144 | int lr_save_offset; /* offset to save LR from initial SP */ |
1145 | int cr_save_offset; /* offset to save CR from initial SP */ | |
b6c9286a | 1146 | int toc_save_offset; /* offset to save the TOC pointer */ |
4697a36c | 1147 | int varargs_save_offset; /* offset to save the varargs registers */ |
b6c9286a | 1148 | int main_save_offset; /* offset to save main's args */ |
802a0058 | 1149 | int fpmem_offset; /* offset for float/int conversion temp */ |
4697a36c MM |
1150 | int reg_size; /* register size (4 or 8) */ |
1151 | int varargs_size; /* size to hold V.4 args passed in regs */ | |
1152 | int vars_size; /* variable save area size */ | |
1153 | int parm_size; /* outgoing parameter size */ | |
b6c9286a | 1154 | int main_size; /* size to hold saving main's args */ |
4697a36c MM |
1155 | int save_size; /* save area size */ |
1156 | int fixed_size; /* fixed size of stack frame */ | |
1157 | int gp_size; /* size of saved GP registers */ | |
1158 | int fp_size; /* size of saved FP registers */ | |
1159 | int cr_size; /* size to hold CR if not in save_size */ | |
b6c9286a | 1160 | int lr_size; /* size to hold LR if not in save_size */ |
802a0058 | 1161 | int fpmem_size; /* size to hold float/int conversion */ |
b6c9286a | 1162 | int toc_size; /* size to hold TOC if not in save_size */ |
4697a36c MM |
1163 | int total_size; /* total bytes allocated for stack */ |
1164 | } rs6000_stack_t; | |
1165 | ||
f045b2c9 RS |
1166 | /* Define this if pushing a word on the stack |
1167 | makes the stack pointer a smaller address. */ | |
1168 | #define STACK_GROWS_DOWNWARD | |
1169 | ||
1170 | /* Define this if the nominal address of the stack frame | |
1171 | is at the high-address end of the local variables; | |
1172 | that is, each additional local variable allocated | |
1173 | goes at a more negative offset in the frame. | |
1174 | ||
1175 | On the RS/6000, we grow upwards, from the area after the outgoing | |
1176 | arguments. */ | |
1177 | /* #define FRAME_GROWS_DOWNWARD */ | |
1178 | ||
4697a36c | 1179 | /* Size of the outgoing register save area */ |
2f3e5814 | 1180 | #define RS6000_REG_SAVE (TARGET_32BIT ? 32 : 64) |
4697a36c MM |
1181 | |
1182 | /* Size of the fixed area on the stack */ | |
2f3e5814 | 1183 | #define RS6000_SAVE_AREA (TARGET_32BIT ? 24 : 48) |
4697a36c | 1184 | |
b6c9286a MM |
1185 | /* Address to save the TOC register */ |
1186 | #define RS6000_SAVE_TOC plus_constant (stack_pointer_rtx, 20) | |
1187 | ||
1188 | /* Whether a separate TOC save area is needed */ | |
1189 | extern int rs6000_save_toc_p; | |
1190 | ||
802a0058 MM |
1191 | /* Offset & size for fpmem stack locations used for converting between |
1192 | float and integral types. */ | |
1193 | extern int rs6000_fpmem_offset; | |
1194 | extern int rs6000_fpmem_size; | |
1195 | ||
4697a36c MM |
1196 | /* Size of the V.4 varargs area if needed */ |
1197 | #define RS6000_VARARGS_AREA 0 | |
1198 | ||
1199 | /* Whether a V.4 varargs area is needed */ | |
1200 | extern int rs6000_sysv_varargs_p; | |
1201 | ||
1202 | /* Align an address */ | |
1203 | #define ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1)) | |
1204 | ||
a7df97e6 MM |
1205 | /* Initialize data used by insn expanders. This is called from |
1206 | init_emit, once for each function, before code is generated. */ | |
1207 | #define INIT_EXPANDERS rs6000_init_expanders () | |
1208 | ||
4697a36c MM |
1209 | /* Size of V.4 varargs area in bytes */ |
1210 | #define RS6000_VARARGS_SIZE \ | |
2f3e5814 | 1211 | ((GP_ARG_NUM_REG * (TARGET_32BIT ? 4 : 8)) + (FP_ARG_NUM_REG * 8) + 8) |
4697a36c MM |
1212 | |
1213 | /* Offset of V.4 varargs area */ | |
802a0058 MM |
1214 | #define RS6000_VARARGS_OFFSET \ |
1215 | (ALIGN (current_function_outgoing_args_size, 8) \ | |
802a0058 | 1216 | + RS6000_SAVE_AREA) |
4697a36c | 1217 | |
f045b2c9 RS |
1218 | /* Offset within stack frame to start allocating local variables at. |
1219 | If FRAME_GROWS_DOWNWARD, this is the offset to the END of the | |
1220 | first local allocated. Otherwise, it is the offset to the BEGINNING | |
c81bebd7 | 1221 | of the first local allocated. |
f045b2c9 RS |
1222 | |
1223 | On the RS/6000, the frame pointer is the same as the stack pointer, | |
1224 | except for dynamic allocations. So we start after the fixed area and | |
1225 | outgoing parameter area. */ | |
1226 | ||
802a0058 MM |
1227 | #define STARTING_FRAME_OFFSET \ |
1228 | (ALIGN (current_function_outgoing_args_size, 8) \ | |
802a0058 MM |
1229 | + RS6000_VARARGS_AREA \ |
1230 | + RS6000_SAVE_AREA) | |
1231 | ||
1232 | /* Offset from the stack pointer register to an item dynamically | |
1233 | allocated on the stack, e.g., by `alloca'. | |
1234 | ||
1235 | The default value for this macro is `STACK_POINTER_OFFSET' plus the | |
1236 | length of the outgoing arguments. The default is correct for most | |
1237 | machines. See `function.c' for details. */ | |
1238 | #define STACK_DYNAMIC_OFFSET(FUNDECL) \ | |
1239 | (ALIGN (current_function_outgoing_args_size, 8) \ | |
802a0058 | 1240 | + (STACK_POINTER_OFFSET)) |
f045b2c9 RS |
1241 | |
1242 | /* If we generate an insn to push BYTES bytes, | |
1243 | this says how many the stack pointer really advances by. | |
1244 | On RS/6000, don't define this because there are no push insns. */ | |
1245 | /* #define PUSH_ROUNDING(BYTES) */ | |
1246 | ||
1247 | /* Offset of first parameter from the argument pointer register value. | |
1248 | On the RS/6000, we define the argument pointer to the start of the fixed | |
1249 | area. */ | |
4697a36c | 1250 | #define FIRST_PARM_OFFSET(FNDECL) RS6000_SAVE_AREA |
f045b2c9 RS |
1251 | |
1252 | /* Define this if stack space is still allocated for a parameter passed | |
1253 | in a register. The value is the number of bytes allocated to this | |
1254 | area. */ | |
4697a36c | 1255 | #define REG_PARM_STACK_SPACE(FNDECL) RS6000_REG_SAVE |
f045b2c9 RS |
1256 | |
1257 | /* Define this if the above stack space is to be considered part of the | |
1258 | space allocated by the caller. */ | |
1259 | #define OUTGOING_REG_PARM_STACK_SPACE | |
1260 | ||
1261 | /* This is the difference between the logical top of stack and the actual sp. | |
1262 | ||
1263 | For the RS/6000, sp points past the fixed area. */ | |
4697a36c | 1264 | #define STACK_POINTER_OFFSET RS6000_SAVE_AREA |
f045b2c9 RS |
1265 | |
1266 | /* Define this if the maximum size of all the outgoing args is to be | |
1267 | accumulated and pushed during the prologue. The amount can be | |
1268 | found in the variable current_function_outgoing_args_size. */ | |
1269 | #define ACCUMULATE_OUTGOING_ARGS | |
1270 | ||
1271 | /* Value is the number of bytes of arguments automatically | |
1272 | popped when returning from a subroutine call. | |
8b109b37 | 1273 | FUNDECL is the declaration node of the function (as a tree), |
f045b2c9 RS |
1274 | FUNTYPE is the data type of the function (as a tree), |
1275 | or for a library call it is an identifier node for the subroutine name. | |
1276 | SIZE is the number of bytes of arguments passed on the stack. */ | |
1277 | ||
8b109b37 | 1278 | #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0 |
f045b2c9 RS |
1279 | |
1280 | /* Define how to find the value returned by a function. | |
1281 | VALTYPE is the data type of the value (as a tree). | |
1282 | If the precise function being called is known, FUNC is its FUNCTION_DECL; | |
1283 | otherwise, FUNC is 0. | |
1284 | ||
c81bebd7 | 1285 | On RS/6000 an integer value is in r3 and a floating-point value is in |
d14a6d05 | 1286 | fp1, unless -msoft-float. */ |
f045b2c9 RS |
1287 | |
1288 | #define FUNCTION_VALUE(VALTYPE, FUNC) \ | |
1289 | gen_rtx (REG, TYPE_MODE (VALTYPE), \ | |
d14a6d05 | 1290 | TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_HARD_FLOAT ? 33 : 3) |
f045b2c9 RS |
1291 | |
1292 | /* Define how to find the value returned by a library function | |
1293 | assuming the value has mode MODE. */ | |
1294 | ||
1295 | #define LIBCALL_VALUE(MODE) \ | |
d14a6d05 | 1296 | gen_rtx (REG, MODE, GET_MODE_CLASS (MODE) == MODE_FLOAT && TARGET_HARD_FLOAT ? 33 : 3) |
f045b2c9 RS |
1297 | |
1298 | /* The definition of this macro implies that there are cases where | |
1299 | a scalar value cannot be returned in registers. | |
1300 | ||
c81bebd7 MM |
1301 | For the RS/6000, any structure or union type is returned in memory, except for |
1302 | Solaris, which returns structures <= 8 bytes in registers. */ | |
f045b2c9 | 1303 | |
c81bebd7 MM |
1304 | #define RETURN_IN_MEMORY(TYPE) \ |
1305 | (TYPE_MODE (TYPE) == BLKmode \ | |
1306 | && (DEFAULT_ABI != ABI_SOLARIS || int_size_in_bytes (TYPE) > 8)) | |
f045b2c9 | 1307 | |
4697a36c MM |
1308 | /* Minimum and maximum general purpose registers used to hold arguments. */ |
1309 | #define GP_ARG_MIN_REG 3 | |
1310 | #define GP_ARG_MAX_REG 10 | |
1311 | #define GP_ARG_NUM_REG (GP_ARG_MAX_REG - GP_ARG_MIN_REG + 1) | |
1312 | ||
1313 | /* Minimum and maximum floating point registers used to hold arguments. */ | |
1314 | #define FP_ARG_MIN_REG 33 | |
7509c759 MM |
1315 | #define FP_ARG_AIX_MAX_REG 45 |
1316 | #define FP_ARG_V4_MAX_REG 40 | |
1317 | #define FP_ARG_MAX_REG FP_ARG_AIX_MAX_REG | |
4697a36c MM |
1318 | #define FP_ARG_NUM_REG (FP_ARG_MAX_REG - FP_ARG_MIN_REG + 1) |
1319 | ||
1320 | /* Return registers */ | |
1321 | #define GP_ARG_RETURN GP_ARG_MIN_REG | |
1322 | #define FP_ARG_RETURN FP_ARG_MIN_REG | |
1323 | ||
7509c759 | 1324 | /* Flags for the call/call_value rtl operations set up by function_arg */ |
6a4cee5f MM |
1325 | #define CALL_NORMAL 0x00000000 /* no special processing */ |
1326 | #define CALL_NT_DLLIMPORT 0x00000001 /* NT, this is a DLL import call */ | |
1327 | #define CALL_V4_CLEAR_FP_ARGS 0x00000002 /* V.4, no FP args passed */ | |
1328 | #define CALL_V4_SET_FP_ARGS 0x00000004 /* V.4, FP args were passed */ | |
1329 | #define CALL_LONG 0x00000008 /* always call indirect */ | |
7509c759 | 1330 | |
4697a36c MM |
1331 | /* Define cutoff for using external functions to save floating point */ |
1332 | #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63) | |
1333 | ||
f045b2c9 RS |
1334 | /* 1 if N is a possible register number for a function value |
1335 | as seen by the caller. | |
1336 | ||
1337 | On RS/6000, this is r3 and fp1. */ | |
4697a36c | 1338 | #define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_ARG_RETURN || ((N) == FP_ARG_RETURN)) |
f045b2c9 RS |
1339 | |
1340 | /* 1 if N is a possible register number for function argument passing. | |
1341 | On RS/6000, these are r3-r10 and fp1-fp13. */ | |
4697a36c MM |
1342 | #define FUNCTION_ARG_REGNO_P(N) \ |
1343 | (((unsigned)((N) - GP_ARG_MIN_REG) < (unsigned)(GP_ARG_NUM_REG)) \ | |
1344 | || ((unsigned)((N) - FP_ARG_MIN_REG) < (unsigned)(FP_ARG_NUM_REG))) | |
f045b2c9 | 1345 | |
f045b2c9 RS |
1346 | \f |
1347 | /* Define a data type for recording info about an argument list | |
1348 | during the scan of that argument list. This data type should | |
1349 | hold all necessary information about the function itself | |
1350 | and about the args processed so far, enough to enable macros | |
1351 | such as FUNCTION_ARG to determine where the next arg should go. | |
1352 | ||
1353 | On the RS/6000, this is a structure. The first element is the number of | |
1354 | total argument words, the second is used to store the next | |
1355 | floating-point register number, and the third says how many more args we | |
4697a36c MM |
1356 | have prototype types for. |
1357 | ||
1358 | The System V.4 varargs/stdarg support requires that this structure's size | |
1359 | be a multiple of sizeof(int), and that WORDS, FREGNO, NARGS_PROTOTYPE, | |
1360 | ORIG_NARGS, and VARARGS_OFFSET be the first five ints. */ | |
1361 | ||
1362 | typedef struct rs6000_args | |
1363 | { | |
6a4cee5f MM |
1364 | int words; /* # words uses for passing GP registers */ |
1365 | int fregno; /* next available FP register */ | |
1366 | int nargs_prototype; /* # args left in the current prototype */ | |
1367 | int orig_nargs; /* Original value of nargs_prototype */ | |
1368 | int varargs_offset; /* offset of the varargs save area */ | |
1369 | int prototype; /* Whether a prototype was defined */ | |
1370 | int call_cookie; /* Do special things for this call */ | |
4697a36c | 1371 | } CUMULATIVE_ARGS; |
f045b2c9 RS |
1372 | |
1373 | /* Define intermediate macro to compute the size (in registers) of an argument | |
1374 | for the RS/6000. */ | |
1375 | ||
1376 | #define RS6000_ARG_SIZE(MODE, TYPE, NAMED) \ | |
1377 | (! (NAMED) ? 0 \ | |
1378 | : (MODE) != BLKmode \ | |
1379 | ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD \ | |
1380 | : (int_size_in_bytes (TYPE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD) | |
1381 | ||
1382 | /* Initialize a variable CUM of type CUMULATIVE_ARGS | |
1383 | for a call to a function whose data type is FNTYPE. | |
1384 | For a library call, FNTYPE is 0. */ | |
1385 | ||
2c7ee1a6 | 1386 | #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \ |
4697a36c | 1387 | init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE) |
f045b2c9 RS |
1388 | |
1389 | /* Similar, but when scanning the definition of a procedure. We always | |
1390 | set NARGS_PROTOTYPE large so we never return an EXPR_LIST. */ | |
1391 | ||
4697a36c MM |
1392 | #define INIT_CUMULATIVE_INCOMING_ARGS(CUM,FNTYPE,LIBNAME) \ |
1393 | init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE) | |
f045b2c9 RS |
1394 | |
1395 | /* Update the data in CUM to advance over an argument | |
1396 | of mode MODE and data type TYPE. | |
1397 | (TYPE is null for libcalls where that information may not be available.) */ | |
1398 | ||
1399 | #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ | |
4697a36c | 1400 | function_arg_advance (&CUM, MODE, TYPE, NAMED) |
f045b2c9 RS |
1401 | |
1402 | /* Non-zero if we can use a floating-point register to pass this arg. */ | |
4697a36c MM |
1403 | #define USE_FP_FOR_ARG_P(CUM,MODE,TYPE) \ |
1404 | (GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
1405 | && (CUM).fregno <= FP_ARG_MAX_REG \ | |
1406 | && TARGET_HARD_FLOAT) | |
f045b2c9 RS |
1407 | |
1408 | /* Determine where to put an argument to a function. | |
1409 | Value is zero to push the argument on the stack, | |
1410 | or a hard register in which to store the argument. | |
1411 | ||
1412 | MODE is the argument's machine mode. | |
1413 | TYPE is the data type of the argument (as a tree). | |
1414 | This is null for libcalls where that information may | |
1415 | not be available. | |
1416 | CUM is a variable of type CUMULATIVE_ARGS which gives info about | |
1417 | the preceding args and about the function being called. | |
1418 | NAMED is nonzero if this argument is a named parameter | |
1419 | (otherwise it is an extra parameter matching an ellipsis). | |
1420 | ||
1421 | On RS/6000 the first eight words of non-FP are normally in registers | |
1422 | and the rest are pushed. The first 13 FP args are in registers. | |
1423 | ||
1424 | If this is floating-point and no prototype is specified, we use | |
4d6697ca RK |
1425 | both an FP and integer register (or possibly FP reg and stack). Library |
1426 | functions (when TYPE is zero) always have the proper types for args, | |
1427 | so we can pass the FP value just in one register. emit_library_function | |
1428 | doesn't support EXPR_LIST anyway. */ | |
f045b2c9 | 1429 | |
4697a36c MM |
1430 | #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ |
1431 | function_arg (&CUM, MODE, TYPE, NAMED) | |
f045b2c9 RS |
1432 | |
1433 | /* For an arg passed partly in registers and partly in memory, | |
1434 | this is the number of registers used. | |
1435 | For args passed entirely in registers or entirely in memory, zero. */ | |
1436 | ||
4697a36c MM |
1437 | #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ |
1438 | function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED) | |
1439 | ||
1440 | /* A C expression that indicates when an argument must be passed by | |
1441 | reference. If nonzero for an argument, a copy of that argument is | |
1442 | made in memory and a pointer to the argument is passed instead of | |
1443 | the argument itself. The pointer is passed in whatever way is | |
1444 | appropriate for passing a pointer to that type. */ | |
1445 | ||
1446 | #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \ | |
1447 | function_arg_pass_by_reference(&CUM, MODE, TYPE, NAMED) | |
f045b2c9 | 1448 | |
b6c9286a | 1449 | /* If defined, a C expression that gives the alignment boundary, in bits, |
c81bebd7 | 1450 | of an argument with the specified mode and type. If it is not defined, |
b6c9286a MM |
1451 | PARM_BOUNDARY is used for all arguments. */ |
1452 | ||
1453 | #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \ | |
1454 | function_arg_boundary (MODE, TYPE) | |
1455 | ||
f045b2c9 | 1456 | /* Perform any needed actions needed for a function that is receiving a |
c81bebd7 | 1457 | variable number of arguments. |
f045b2c9 RS |
1458 | |
1459 | CUM is as above. | |
1460 | ||
1461 | MODE and TYPE are the mode and type of the current parameter. | |
1462 | ||
1463 | PRETEND_SIZE is a variable that should be set to the amount of stack | |
1464 | that must be pushed by the prolog to pretend that our caller pushed | |
1465 | it. | |
1466 | ||
1467 | Normally, this macro will push all remaining incoming registers on the | |
1468 | stack and set PRETEND_SIZE to the length of the registers pushed. */ | |
1469 | ||
4697a36c MM |
1470 | #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \ |
1471 | setup_incoming_varargs (&CUM, MODE, TYPE, &PRETEND_SIZE, NO_RTL) | |
1472 | ||
1473 | /* If defined, is a C expression that produces the machine-specific | |
1474 | code for a call to `__builtin_saveregs'. This code will be moved | |
1475 | to the very beginning of the function, before any parameter access | |
1476 | are made. The return value of this function should be an RTX that | |
1477 | contains the value to use as the return of `__builtin_saveregs'. | |
1478 | ||
1479 | The argument ARGS is a `tree_list' containing the arguments that | |
1480 | were passed to `__builtin_saveregs'. | |
1481 | ||
1482 | If this macro is not defined, the compiler will output an ordinary | |
1483 | call to the library function `__builtin_saveregs'. */ | |
1484 | ||
1485 | #define EXPAND_BUILTIN_SAVEREGS(ARGS) \ | |
1486 | expand_builtin_saveregs (ARGS) | |
f045b2c9 RS |
1487 | |
1488 | /* This macro generates the assembly code for function entry. | |
1489 | FILE is a stdio stream to output the code to. | |
1490 | SIZE is an int: how many units of temporary storage to allocate. | |
1491 | Refer to the array `regs_ever_live' to determine which registers | |
1492 | to save; `regs_ever_live[I]' is nonzero if register number I | |
1493 | is ever used in the function. This macro is responsible for | |
1494 | knowing which registers should not be saved even if used. */ | |
1495 | ||
1496 | #define FUNCTION_PROLOGUE(FILE, SIZE) output_prolog (FILE, SIZE) | |
1497 | ||
1498 | /* Output assembler code to FILE to increment profiler label # LABELNO | |
58a39e45 | 1499 | for profiling a function entry. */ |
f045b2c9 RS |
1500 | |
1501 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
58a39e45 | 1502 | output_function_profiler ((FILE), (LABELNO)); |
f045b2c9 RS |
1503 | |
1504 | /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, | |
1505 | the stack pointer does not matter. No definition is equivalent to | |
1506 | always zero. | |
1507 | ||
1508 | On the RS/6000, this is non-zero because we can restore the stack from | |
1509 | its backpointer, which we maintain. */ | |
1510 | #define EXIT_IGNORE_STACK 1 | |
1511 | ||
1512 | /* This macro generates the assembly code for function exit, | |
1513 | on machines that need it. If FUNCTION_EPILOGUE is not defined | |
1514 | then individual return instructions are generated for each | |
1515 | return statement. Args are same as for FUNCTION_PROLOGUE. | |
1516 | ||
1517 | The function epilogue should not depend on the current stack pointer! | |
1518 | It should use the frame pointer only. This is mandatory because | |
1519 | of alloca; we also take advantage of it to omit stack adjustments | |
1520 | before returning. */ | |
1521 | ||
1522 | #define FUNCTION_EPILOGUE(FILE, SIZE) output_epilog (FILE, SIZE) | |
1523 | \f | |
1524 | /* Output assembler code for a block containing the constant parts | |
1525 | of a trampoline, leaving space for the variable parts. | |
1526 | ||
1527 | The trampoline should set the static chain pointer to value placed | |
b6c9286a MM |
1528 | into the trampoline and should branch to the specified routine. */ |
1529 | #define TRAMPOLINE_TEMPLATE(FILE) rs6000_trampoline_template (FILE) | |
f045b2c9 RS |
1530 | |
1531 | /* Length in units of the trampoline for entering a nested function. */ | |
1532 | ||
b6c9286a | 1533 | #define TRAMPOLINE_SIZE rs6000_trampoline_size () |
f045b2c9 RS |
1534 | |
1535 | /* Emit RTL insns to initialize the variable parts of a trampoline. | |
1536 | FNADDR is an RTX for the address of the function's pure code. | |
1537 | CXT is an RTX for the static chain value for the function. */ | |
1538 | ||
1539 | #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \ | |
b6c9286a | 1540 | rs6000_initialize_trampoline (ADDR, FNADDR, CXT) |
f045b2c9 | 1541 | \f |
7509c759 MM |
1542 | /* If defined, a C expression whose value is nonzero if IDENTIFIER |
1543 | with arguments ARGS is a valid machine specific attribute for DECL. | |
1544 | The attributes in ATTRIBUTES have previously been assigned to DECL. */ | |
1545 | ||
1546 | #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, NAME, ARGS) \ | |
1547 | (rs6000_valid_decl_attribute_p (DECL, ATTRIBUTES, NAME, ARGS)) | |
1548 | ||
1549 | /* If defined, a C expression whose value is nonzero if IDENTIFIER | |
1550 | with arguments ARGS is a valid machine specific attribute for TYPE. | |
1551 | The attributes in ATTRIBUTES have previously been assigned to TYPE. */ | |
1552 | ||
1553 | #define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, NAME, ARGS) \ | |
1554 | (rs6000_valid_type_attribute_p (TYPE, ATTRIBUTES, NAME, ARGS)) | |
1555 | ||
1556 | /* If defined, a C expression whose value is zero if the attributes on | |
1557 | TYPE1 and TYPE2 are incompatible, one if they are compatible, and | |
1558 | two if they are nearly compatible (which causes a warning to be | |
1559 | generated). */ | |
1560 | ||
1561 | #define COMP_TYPE_ATTRIBUTES(TYPE1, TYPE2) \ | |
1562 | (rs6000_comp_type_attributes (TYPE1, TYPE2)) | |
1563 | ||
1564 | /* If defined, a C statement that assigns default attributes to newly | |
1565 | defined TYPE. */ | |
1566 | ||
1567 | #define SET_DEFAULT_TYPE_ATTRIBUTES(TYPE) \ | |
1568 | (rs6000_set_default_type_attributes (TYPE)) | |
1569 | ||
1570 | \f | |
f33985c6 MS |
1571 | /* Definitions for __builtin_return_address and __builtin_frame_address. |
1572 | __builtin_return_address (0) should give link register (65), enable | |
1573 | this. */ | |
1574 | /* This should be uncommented, so that the link register is used, but | |
1575 | currently this would result in unmatched insns and spilling fixed | |
1576 | registers so we'll leave it for another day. When these problems are | |
1577 | taken care of one additional fetch will be necessary in RETURN_ADDR_RTX. | |
1578 | (mrs) */ | |
1579 | /* #define RETURN_ADDR_IN_PREVIOUS_FRAME */ | |
f09d4c33 | 1580 | |
b6c9286a MM |
1581 | /* Number of bytes into the frame return addresses can be found. See |
1582 | rs6000_stack_info in rs6000.c for more information on how the different | |
1583 | abi's store the return address. */ | |
1584 | #define RETURN_ADDRESS_OFFSET \ | |
1585 | ((DEFAULT_ABI == ABI_AIX \ | |
1586 | || DEFAULT_ABI == ABI_AIX_NODESC) ? 8 : \ | |
c81bebd7 MM |
1587 | (DEFAULT_ABI == ABI_V4 \ |
1588 | || DEFAULT_ABI == ABI_SOLARIS) ? (TARGET_32BIT ? 4 : 8) : \ | |
b6c9286a MM |
1589 | (DEFAULT_ABI == ABI_NT) ? -4 : \ |
1590 | (fatal ("RETURN_ADDRESS_OFFSET not supported"), 0)) | |
f09d4c33 | 1591 | |
f33985c6 MS |
1592 | /* The current return address is in link register (65). The return address |
1593 | of anything farther back is accessed normally at an offset of 8 from the | |
1594 | frame pointer. */ | |
1595 | #define RETURN_ADDR_RTX(count, frame) \ | |
1596 | ((count == -1) \ | |
1597 | ? gen_rtx (REG, Pmode, 65) \ | |
f09d4c33 RK |
1598 | : gen_rtx (MEM, Pmode, \ |
1599 | memory_address (Pmode, \ | |
1600 | plus_constant (copy_to_reg (gen_rtx (MEM, Pmode, \ | |
1601 | memory_address (Pmode, frame))), \ | |
1602 | RETURN_ADDRESS_OFFSET)))) | |
f33985c6 | 1603 | \f |
f045b2c9 RS |
1604 | /* Definitions for register eliminations. |
1605 | ||
1606 | We have two registers that can be eliminated on the RS/6000. First, the | |
1607 | frame pointer register can often be eliminated in favor of the stack | |
1608 | pointer register. Secondly, the argument pointer register can always be | |
642a35f1 JW |
1609 | eliminated; it is replaced with either the stack or frame pointer. |
1610 | ||
1611 | In addition, we use the elimination mechanism to see if r30 is needed | |
1612 | Initially we assume that it isn't. If it is, we spill it. This is done | |
1613 | by making it an eliminable register. We replace it with itself so that | |
1614 | if it isn't needed, then existing uses won't be modified. */ | |
f045b2c9 RS |
1615 | |
1616 | /* This is an array of structures. Each structure initializes one pair | |
1617 | of eliminable registers. The "from" register number is given first, | |
1618 | followed by "to". Eliminations of the same "from" register are listed | |
1619 | in order of preference. */ | |
1620 | #define ELIMINABLE_REGS \ | |
1621 | {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
1622 | { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
642a35f1 JW |
1623 | { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ |
1624 | { 30, 30} } | |
f045b2c9 RS |
1625 | |
1626 | /* Given FROM and TO register numbers, say whether this elimination is allowed. | |
1627 | Frame pointer elimination is automatically handled. | |
1628 | ||
1629 | For the RS/6000, if frame pointer elimination is being done, we would like | |
642a35f1 JW |
1630 | to convert ap into fp, not sp. |
1631 | ||
abc95ed3 | 1632 | We need r30 if -mminimal-toc was specified, and there are constant pool |
642a35f1 | 1633 | references. */ |
f045b2c9 RS |
1634 | |
1635 | #define CAN_ELIMINATE(FROM, TO) \ | |
1636 | ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \ | |
1637 | ? ! frame_pointer_needed \ | |
4697a36c | 1638 | : (FROM) == 30 ? ! TARGET_MINIMAL_TOC || TARGET_NO_TOC || get_pool_size () == 0 \ |
f045b2c9 RS |
1639 | : 1) |
1640 | ||
1641 | /* Define the offset between two registers, one to be eliminated, and the other | |
1642 | its replacement, at the start of a routine. */ | |
1643 | #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ | |
1644 | { \ | |
4697a36c | 1645 | rs6000_stack_t *info = rs6000_stack_info (); \ |
f045b2c9 RS |
1646 | \ |
1647 | if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \ | |
4697a36c MM |
1648 | (OFFSET) = (info->push_p) ? 0 : - info->total_size; \ |
1649 | else if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \ | |
1650 | (OFFSET) = info->total_size; \ | |
1651 | else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \ | |
1652 | (OFFSET) = (info->push_p) ? info->total_size : 0; \ | |
642a35f1 JW |
1653 | else if ((FROM) == 30) \ |
1654 | (OFFSET) = 0; \ | |
f045b2c9 RS |
1655 | else \ |
1656 | abort (); \ | |
1657 | } | |
1658 | \f | |
1659 | /* Addressing modes, and classification of registers for them. */ | |
1660 | ||
1661 | /* #define HAVE_POST_INCREMENT */ | |
1662 | /* #define HAVE_POST_DECREMENT */ | |
1663 | ||
1664 | #define HAVE_PRE_DECREMENT | |
1665 | #define HAVE_PRE_INCREMENT | |
1666 | ||
1667 | /* Macros to check register numbers against specific register classes. */ | |
1668 | ||
1669 | /* These assume that REGNO is a hard or pseudo reg number. | |
1670 | They give nonzero only if REGNO is a hard reg of the suitable class | |
1671 | or a pseudo reg currently allocated to a suitable hard reg. | |
1672 | Since they use reg_renumber, they are safe only once reg_renumber | |
1673 | has been allocated, which happens in local-alloc.c. */ | |
1674 | ||
1675 | #define REGNO_OK_FOR_INDEX_P(REGNO) \ | |
1676 | ((REGNO) < FIRST_PSEUDO_REGISTER \ | |
1677 | ? (REGNO) <= 31 || (REGNO) == 67 \ | |
1678 | : (reg_renumber[REGNO] >= 0 \ | |
1679 | && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67))) | |
1680 | ||
1681 | #define REGNO_OK_FOR_BASE_P(REGNO) \ | |
1682 | ((REGNO) < FIRST_PSEUDO_REGISTER \ | |
1683 | ? ((REGNO) > 0 && (REGNO) <= 31) || (REGNO) == 67 \ | |
1684 | : (reg_renumber[REGNO] > 0 \ | |
1685 | && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67))) | |
1686 | \f | |
1687 | /* Maximum number of registers that can appear in a valid memory address. */ | |
1688 | ||
1689 | #define MAX_REGS_PER_ADDRESS 2 | |
1690 | ||
1691 | /* Recognize any constant value that is a valid address. */ | |
1692 | ||
6eff269e BK |
1693 | #define CONSTANT_ADDRESS_P(X) \ |
1694 | (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ | |
1695 | || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ | |
1696 | || GET_CODE (X) == HIGH) | |
f045b2c9 RS |
1697 | |
1698 | /* Nonzero if the constant value X is a legitimate general operand. | |
1699 | It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. | |
1700 | ||
1701 | On the RS/6000, all integer constants are acceptable, most won't be valid | |
1702 | for particular insns, though. Only easy FP constants are | |
1703 | acceptable. */ | |
1704 | ||
1705 | #define LEGITIMATE_CONSTANT_P(X) \ | |
1706 | (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode \ | |
1707 | || easy_fp_constant (X, GET_MODE (X))) | |
1708 | ||
1709 | /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx | |
1710 | and check its validity for a certain class. | |
1711 | We have two alternate definitions for each of them. | |
1712 | The usual definition accepts all pseudo regs; the other rejects | |
1713 | them unless they have been allocated suitable hard regs. | |
1714 | The symbol REG_OK_STRICT causes the latter definition to be used. | |
1715 | ||
1716 | Most source files want to accept pseudo regs in the hope that | |
1717 | they will get allocated to the class that the insn wants them to be in. | |
1718 | Source files for reload pass need to be strict. | |
1719 | After reload, it makes no difference, since pseudo regs have | |
1720 | been eliminated by then. */ | |
1721 | ||
1722 | #ifndef REG_OK_STRICT | |
1723 | ||
1724 | /* Nonzero if X is a hard reg that can be used as an index | |
1725 | or if it is a pseudo reg. */ | |
1726 | #define REG_OK_FOR_INDEX_P(X) \ | |
1727 | (REGNO (X) <= 31 || REGNO (X) == 67 || REGNO (X) >= FIRST_PSEUDO_REGISTER) | |
1728 | ||
1729 | /* Nonzero if X is a hard reg that can be used as a base reg | |
1730 | or if it is a pseudo reg. */ | |
1731 | #define REG_OK_FOR_BASE_P(X) \ | |
1732 | (REGNO (X) > 0 && REG_OK_FOR_INDEX_P (X)) | |
1733 | ||
1734 | #else | |
1735 | ||
1736 | /* Nonzero if X is a hard reg that can be used as an index. */ | |
1737 | #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) | |
1738 | /* Nonzero if X is a hard reg that can be used as a base reg. */ | |
1739 | #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) | |
1740 | ||
1741 | #endif | |
1742 | \f | |
1743 | /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression | |
1744 | that is a valid memory address for an instruction. | |
1745 | The MODE argument is the machine mode for the MEM expression | |
1746 | that wants to use this address. | |
1747 | ||
1748 | On the RS/6000, there are four valid address: a SYMBOL_REF that | |
1749 | refers to a constant pool entry of an address (or the sum of it | |
1750 | plus a constant), a short (16-bit signed) constant plus a register, | |
1751 | the sum of two registers, or a register indirect, possibly with an | |
1752 | auto-increment. For DFmode and DImode with an constant plus register, | |
2f3e5814 DE |
1753 | we must ensure that both words are addressable or PowerPC64 with offset |
1754 | word aligned. */ | |
f045b2c9 RS |
1755 | |
1756 | #define LEGITIMATE_CONSTANT_POOL_BASE_P(X) \ | |
4697a36c MM |
1757 | (TARGET_TOC && GET_CODE (X) == SYMBOL_REF \ |
1758 | && CONSTANT_POOL_ADDRESS_P (X) \ | |
f045b2c9 RS |
1759 | && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (X))) |
1760 | ||
2f3e5814 | 1761 | /* TARGET_64BIT TOC64 guaranteed to have 64 bit alignment. */ |
f045b2c9 RS |
1762 | #define LEGITIMATE_CONSTANT_POOL_ADDRESS_P(X) \ |
1763 | (LEGITIMATE_CONSTANT_POOL_BASE_P (X) \ | |
4697a36c MM |
1764 | || (TARGET_TOC \ |
1765 | && GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ | |
f045b2c9 RS |
1766 | && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \ |
1767 | && LEGITIMATE_CONSTANT_POOL_BASE_P (XEXP (XEXP (X, 0), 0)))) | |
1768 | ||
7509c759 | 1769 | #define LEGITIMATE_SMALL_DATA_P(MODE, X) \ |
c81bebd7 | 1770 | ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) \ |
88228c4b MM |
1771 | && (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST) \ |
1772 | && small_data_operand (X, MODE)) | |
7509c759 | 1773 | |
f045b2c9 RS |
1774 | #define LEGITIMATE_ADDRESS_INTEGER_P(X,OFFSET) \ |
1775 | (GET_CODE (X) == CONST_INT \ | |
1776 | && (unsigned) (INTVAL (X) + (OFFSET) + 0x8000) < 0x10000) | |
1777 | ||
1778 | #define LEGITIMATE_OFFSET_ADDRESS_P(MODE,X) \ | |
1779 | (GET_CODE (X) == PLUS \ | |
1780 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1781 | && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1782 | && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 0) \ | |
1783 | && (((MODE) != DFmode && (MODE) != DImode) \ | |
2f3e5814 | 1784 | || (TARGET_32BIT \ |
1465faec DE |
1785 | ? LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 4) \ |
1786 | : ! (INTVAL (XEXP (X, 1)) & 3))) \ | |
2f3e5814 | 1787 | && ((MODE) != TImode \ |
644d82dd | 1788 | || (TARGET_32BIT \ |
1465faec DE |
1789 | ? LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 12) \ |
1790 | : (LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 8) \ | |
1791 | && ! (INTVAL (XEXP (X, 1)) & 3))))) | |
f045b2c9 RS |
1792 | |
1793 | #define LEGITIMATE_INDEXED_ADDRESS_P(X) \ | |
1794 | (GET_CODE (X) == PLUS \ | |
1795 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1796 | && GET_CODE (XEXP (X, 1)) == REG \ | |
1797 | && ((REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1798 | && REG_OK_FOR_INDEX_P (XEXP (X, 1))) \ | |
1799 | || (REG_OK_FOR_BASE_P (XEXP (X, 1)) \ | |
1800 | && REG_OK_FOR_INDEX_P (XEXP (X, 0))))) | |
1801 | ||
1802 | #define LEGITIMATE_INDIRECT_ADDRESS_P(X) \ | |
1803 | (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) | |
1804 | ||
4697a36c MM |
1805 | #define LEGITIMATE_LO_SUM_ADDRESS_P(MODE, X) \ |
1806 | (TARGET_ELF \ | |
1807 | && (MODE) != DImode \ | |
1808 | && (MODE) != TImode \ | |
1809 | && (TARGET_HARD_FLOAT || (MODE) != DFmode) \ | |
1810 | && GET_CODE (X) == LO_SUM \ | |
1811 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1812 | && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1813 | && CONSTANT_P (XEXP (X, 1))) | |
1814 | ||
f045b2c9 RS |
1815 | #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ |
1816 | { if (LEGITIMATE_INDIRECT_ADDRESS_P (X)) \ | |
1817 | goto ADDR; \ | |
0a90c336 | 1818 | if ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC) \ |
f045b2c9 RS |
1819 | && LEGITIMATE_INDIRECT_ADDRESS_P (XEXP (X, 0))) \ |
1820 | goto ADDR; \ | |
7509c759 MM |
1821 | if (LEGITIMATE_SMALL_DATA_P (MODE, X)) \ |
1822 | goto ADDR; \ | |
f045b2c9 RS |
1823 | if (LEGITIMATE_CONSTANT_POOL_ADDRESS_P (X)) \ |
1824 | goto ADDR; \ | |
1825 | if (LEGITIMATE_OFFSET_ADDRESS_P (MODE, X)) \ | |
1826 | goto ADDR; \ | |
2f3e5814 DE |
1827 | if ((MODE) != TImode \ |
1828 | && (TARGET_HARD_FLOAT || TARGET_64BIT || (MODE) != DFmode) \ | |
1829 | && (TARGET_64BIT || (MODE) != DImode) \ | |
f045b2c9 RS |
1830 | && LEGITIMATE_INDEXED_ADDRESS_P (X)) \ |
1831 | goto ADDR; \ | |
4697a36c MM |
1832 | if (LEGITIMATE_LO_SUM_ADDRESS_P (MODE, X)) \ |
1833 | goto ADDR; \ | |
f045b2c9 RS |
1834 | } |
1835 | \f | |
1836 | /* Try machine-dependent ways of modifying an illegitimate address | |
1837 | to be legitimate. If we find one, return the new, valid address. | |
1838 | This macro is used in only one place: `memory_address' in explow.c. | |
1839 | ||
1840 | OLDX is the address as it was before break_out_memory_refs was called. | |
1841 | In some cases it is useful to look at this to decide what needs to be done. | |
1842 | ||
1843 | MODE and WIN are passed so that this macro can use | |
1844 | GO_IF_LEGITIMATE_ADDRESS. | |
1845 | ||
1846 | It is always safe for this macro to do nothing. It exists to recognize | |
1847 | opportunities to optimize the output. | |
1848 | ||
1849 | On RS/6000, first check for the sum of a register with a constant | |
1850 | integer that is out of range. If so, generate code to add the | |
1851 | constant with the low-order 16 bits masked to the register and force | |
1852 | this result into another register (this can be done with `cau'). | |
c81bebd7 | 1853 | Then generate an address of REG+(CONST&0xffff), allowing for the |
f045b2c9 RS |
1854 | possibility of bit 16 being a one. |
1855 | ||
1856 | Then check for the sum of a register and something not constant, try to | |
1857 | load the other things into a register and return the sum. */ | |
1858 | ||
4697a36c MM |
1859 | #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \ |
1860 | { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \ | |
1861 | && GET_CODE (XEXP (X, 1)) == CONST_INT \ | |
1862 | && (unsigned) (INTVAL (XEXP (X, 1)) + 0x8000) >= 0x10000) \ | |
354b734b MM |
1863 | { HOST_WIDE_INT high_int, low_int; \ |
1864 | rtx sum; \ | |
1865 | high_int = INTVAL (XEXP (X, 1)) & (~ (HOST_WIDE_INT) 0xffff); \ | |
4697a36c MM |
1866 | low_int = INTVAL (XEXP (X, 1)) & 0xffff; \ |
1867 | if (low_int & 0x8000) \ | |
354b734b MM |
1868 | high_int += 0x10000, low_int |= ((HOST_WIDE_INT) -1) << 16; \ |
1869 | sum = force_operand (gen_rtx (PLUS, Pmode, XEXP (X, 0), \ | |
1870 | GEN_INT (high_int)), 0); \ | |
1871 | (X) = gen_rtx (PLUS, Pmode, sum, GEN_INT (low_int)); \ | |
4697a36c MM |
1872 | goto WIN; \ |
1873 | } \ | |
1874 | else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \ | |
1875 | && GET_CODE (XEXP (X, 1)) != CONST_INT \ | |
2f3e5814 DE |
1876 | && (TARGET_HARD_FLOAT || TARGET_64BIT || (MODE) != DFmode) \ |
1877 | && (TARGET_64BIT || (MODE) != DImode) \ | |
1878 | && (MODE) != TImode) \ | |
4697a36c | 1879 | { \ |
0a90c336 DE |
1880 | (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \ |
1881 | force_reg (Pmode, force_operand (XEXP (X, 1), 0))); \ | |
4697a36c MM |
1882 | goto WIN; \ |
1883 | } \ | |
2f3e5814 | 1884 | else if (TARGET_ELF && TARGET_32BIT && TARGET_NO_TOC \ |
4697a36c MM |
1885 | && GET_CODE (X) != CONST_INT \ |
1886 | && GET_CODE (X) != CONST_DOUBLE && CONSTANT_P (X) \ | |
1887 | && (TARGET_HARD_FLOAT || (MODE) != DFmode) \ | |
1888 | && (MODE) != DImode && (MODE) != TImode) \ | |
1889 | { \ | |
1890 | rtx reg = gen_reg_rtx (Pmode); \ | |
1891 | emit_insn (gen_elf_high (reg, (X))); \ | |
1892 | (X) = gen_rtx (LO_SUM, Pmode, reg, (X)); \ | |
1893 | } \ | |
f045b2c9 RS |
1894 | } |
1895 | ||
1896 | /* Go to LABEL if ADDR (a legitimate address expression) | |
1897 | has an effect that depends on the machine mode it is used for. | |
1898 | ||
1899 | On the RS/6000 this is true if the address is valid with a zero offset | |
1900 | but not with an offset of four (this means it cannot be used as an | |
1901 | address for DImode or DFmode) or is a pre-increment or decrement. Since | |
1902 | we know it is valid, we just check for an address that is not valid with | |
1903 | an offset of four. */ | |
1904 | ||
1905 | #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ | |
1906 | { if (GET_CODE (ADDR) == PLUS \ | |
1907 | && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), 0) \ | |
2f3e5814 DE |
1908 | && ! LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), \ |
1909 | (TARGET_32BIT ? 4 : 8))) \ | |
f045b2c9 RS |
1910 | goto LABEL; \ |
1911 | if (GET_CODE (ADDR) == PRE_INC) \ | |
1912 | goto LABEL; \ | |
1913 | if (GET_CODE (ADDR) == PRE_DEC) \ | |
1914 | goto LABEL; \ | |
4697a36c MM |
1915 | if (GET_CODE (ADDR) == LO_SUM) \ |
1916 | goto LABEL; \ | |
f045b2c9 | 1917 | } |
766a866c MM |
1918 | \f |
1919 | /* The register number of the register used to address a table of | |
1920 | static data addresses in memory. In some cases this register is | |
1921 | defined by a processor's "application binary interface" (ABI). | |
1922 | When this macro is defined, RTL is generated for this register | |
1923 | once, as with the stack pointer and frame pointer registers. If | |
1924 | this macro is not defined, it is up to the machine-dependent files | |
1925 | to allocate such a register (if necessary). */ | |
1926 | ||
1927 | /* #define PIC_OFFSET_TABLE_REGNUM */ | |
1928 | ||
1929 | /* Define this macro if the register defined by | |
1930 | `PIC_OFFSET_TABLE_REGNUM' is clobbered by calls. Do not define | |
1931 | this macro if `PPIC_OFFSET_TABLE_REGNUM' is not defined. */ | |
1932 | ||
1933 | /* #define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED */ | |
1934 | ||
1935 | /* By generating position-independent code, when two different | |
1936 | programs (A and B) share a common library (libC.a), the text of | |
1937 | the library can be shared whether or not the library is linked at | |
1938 | the same address for both programs. In some of these | |
1939 | environments, position-independent code requires not only the use | |
1940 | of different addressing modes, but also special code to enable the | |
1941 | use of these addressing modes. | |
1942 | ||
1943 | The `FINALIZE_PIC' macro serves as a hook to emit these special | |
1944 | codes once the function is being compiled into assembly code, but | |
1945 | not before. (It is not done before, because in the case of | |
1946 | compiling an inline function, it would lead to multiple PIC | |
1947 | prologues being included in functions which used inline functions | |
1948 | and were compiled to assembly language.) */ | |
1949 | ||
d266da75 | 1950 | #define FINALIZE_PIC rs6000_finalize_pic () |
766a866c | 1951 | |
766a866c MM |
1952 | /* A C expression that is nonzero if X is a legitimate immediate |
1953 | operand on the target machine when generating position independent | |
1954 | code. You can assume that X satisfies `CONSTANT_P', so you need | |
1955 | not check this. You can also assume FLAG_PIC is true, so you need | |
1956 | not check it either. You need not define this macro if all | |
1957 | constants (including `SYMBOL_REF') can be immediate operands when | |
1958 | generating position independent code. */ | |
1959 | ||
1960 | /* #define LEGITIMATE_PIC_OPERAND_P (X) */ | |
1961 | ||
30ea98f1 MM |
1962 | /* In rare cases, correct code generation requires extra machine |
1963 | dependent processing between the second jump optimization pass and | |
1964 | delayed branch scheduling. On those machines, define this macro | |
1965 | as a C statement to act on the code starting at INSN. | |
1966 | ||
1967 | On the RS/6000, we use it to make sure the GOT_TOC register marker | |
1968 | that FINALIZE_PIC is supposed to remove actually got removed. */ | |
1969 | ||
1970 | #define MACHINE_DEPENDENT_REORG(INSN) rs6000_reorg (INSN) | |
1971 | ||
f045b2c9 RS |
1972 | \f |
1973 | /* Define this if some processing needs to be done immediately before | |
4255474b | 1974 | emitting code for an insn. */ |
f045b2c9 | 1975 | |
4255474b | 1976 | /* #define FINAL_PRESCAN_INSN(INSN,OPERANDS,NOPERANDS) */ |
f045b2c9 RS |
1977 | |
1978 | /* Specify the machine mode that this machine uses | |
1979 | for the index in the tablejump instruction. */ | |
2f3e5814 | 1980 | #define CASE_VECTOR_MODE (TARGET_32BIT ? SImode : DImode) |
f045b2c9 RS |
1981 | |
1982 | /* Define this if the tablejump instruction expects the table | |
1983 | to contain offsets from the address of the table. | |
1984 | Do not define this if the table should contain absolute addresses. */ | |
1985 | #define CASE_VECTOR_PC_RELATIVE | |
1986 | ||
1987 | /* Specify the tree operation to be used to convert reals to integers. */ | |
1988 | #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR | |
1989 | ||
1990 | /* This is the kind of divide that is easiest to do in the general case. */ | |
1991 | #define EASY_DIV_EXPR TRUNC_DIV_EXPR | |
1992 | ||
1993 | /* Define this as 1 if `char' should by default be signed; else as 0. */ | |
1994 | #define DEFAULT_SIGNED_CHAR 0 | |
1995 | ||
1996 | /* This flag, if defined, says the same insns that convert to a signed fixnum | |
1997 | also convert validly to an unsigned one. */ | |
1998 | ||
1999 | /* #define FIXUNS_TRUNC_LIKE_FIX_TRUNC */ | |
2000 | ||
2001 | /* Max number of bytes we can move from memory to memory | |
2002 | in one reasonably fast instruction. */ | |
2f3e5814 | 2003 | #define MOVE_MAX (! TARGET_POWERPC64 ? 4 : 8) |
7e69e155 | 2004 | #define MAX_MOVE_MAX 8 |
f045b2c9 RS |
2005 | |
2006 | /* Nonzero if access to memory by bytes is no faster than for words. | |
2007 | Also non-zero if doing byte operations (specifically shifts) in registers | |
2008 | is undesirable. */ | |
2009 | #define SLOW_BYTE_ACCESS 1 | |
2010 | ||
9a63901f RK |
2011 | /* Define if operations between registers always perform the operation |
2012 | on the full register even if a narrower mode is specified. */ | |
2013 | #define WORD_REGISTER_OPERATIONS | |
2014 | ||
2015 | /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD | |
2016 | will either zero-extend or sign-extend. The value of this macro should | |
2017 | be the code that says which one of the two operations is implicitly | |
2018 | done, NIL if none. */ | |
2019 | #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND | |
225211e2 RK |
2020 | |
2021 | /* Define if loading short immediate values into registers sign extends. */ | |
2022 | #define SHORT_IMMEDIATES_SIGN_EXTEND | |
fdaff8ba RS |
2023 | \f |
2024 | /* The RS/6000 uses the XCOFF format. */ | |
f045b2c9 | 2025 | |
fdaff8ba | 2026 | #define XCOFF_DEBUGGING_INFO |
f045b2c9 | 2027 | |
c5abcf1d CH |
2028 | /* Define if the object format being used is COFF or a superset. */ |
2029 | #define OBJECT_FORMAT_COFF | |
2030 | ||
2c440f06 RK |
2031 | /* Define the magic numbers that we recognize as COFF. */ |
2032 | ||
2033 | #define MY_ISCOFF(magic) \ | |
2034 | ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC || (magic) == U802TOCMAGIC) | |
2035 | ||
115e69a9 RK |
2036 | /* This is the only version of nm that collect2 can work with. */ |
2037 | #define REAL_NM_FILE_NAME "/usr/ucb/nm" | |
2038 | ||
f045b2c9 RS |
2039 | /* We don't have GAS for the RS/6000 yet, so don't write out special |
2040 | .stabs in cc1plus. */ | |
c81bebd7 | 2041 | |
f045b2c9 | 2042 | #define FASCIST_ASSEMBLER |
b6c9286a MM |
2043 | |
2044 | #ifndef ASM_OUTPUT_CONSTRUCTOR | |
a6cf191b | 2045 | #define ASM_OUTPUT_CONSTRUCTOR(file, name) |
b6c9286a MM |
2046 | #endif |
2047 | #ifndef ASM_OUTPUT_DESTRUCTOR | |
a6cf191b | 2048 | #define ASM_OUTPUT_DESTRUCTOR(file, name) |
b6c9286a | 2049 | #endif |
f045b2c9 | 2050 | |
f045b2c9 RS |
2051 | /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits |
2052 | is done just by pretending it is already truncated. */ | |
2053 | #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 | |
2054 | ||
2055 | /* Specify the machine mode that pointers have. | |
2056 | After generation of rtl, the compiler makes no further distinction | |
2057 | between pointers and any other objects of this machine mode. */ | |
2f3e5814 | 2058 | #define Pmode (TARGET_32BIT ? SImode : DImode) |
f045b2c9 RS |
2059 | |
2060 | /* Mode of a function address in a call instruction (for indexing purposes). | |
2061 | ||
2062 | Doesn't matter on RS/6000. */ | |
2f3e5814 | 2063 | #define FUNCTION_MODE (TARGET_32BIT ? SImode : DImode) |
f045b2c9 RS |
2064 | |
2065 | /* Define this if addresses of constant functions | |
2066 | shouldn't be put through pseudo regs where they can be cse'd. | |
2067 | Desirable on machines where ordinary constants are expensive | |
2068 | but a CALL with constant address is cheap. */ | |
2069 | #define NO_FUNCTION_CSE | |
2070 | ||
d969caf8 | 2071 | /* Define this to be nonzero if shift instructions ignore all but the low-order |
6febd581 RK |
2072 | few bits. |
2073 | ||
2074 | The sle and sre instructions which allow SHIFT_COUNT_TRUNCATED | |
2075 | have been dropped from the PowerPC architecture. */ | |
2076 | ||
4697a36c | 2077 | #define SHIFT_COUNT_TRUNCATED (TARGET_POWER ? 1 : 0) |
f045b2c9 RS |
2078 | |
2079 | /* Use atexit for static constructors/destructors, instead of defining | |
2080 | our own exit function. */ | |
2081 | #define HAVE_ATEXIT | |
2082 | ||
2083 | /* Compute the cost of computing a constant rtl expression RTX | |
2084 | whose rtx-code is CODE. The body of this macro is a portion | |
2085 | of a switch statement. If the code is computed here, | |
2086 | return it with a return statement. Otherwise, break from the switch. | |
2087 | ||
01554f00 | 2088 | On the RS/6000, if it is valid in the insn, it is free. So this |
f045b2c9 RS |
2089 | always returns 0. */ |
2090 | ||
4697a36c | 2091 | #define CONST_COSTS(RTX,CODE,OUTER_CODE) \ |
f045b2c9 RS |
2092 | case CONST_INT: \ |
2093 | case CONST: \ | |
2094 | case LABEL_REF: \ | |
2095 | case SYMBOL_REF: \ | |
2096 | case CONST_DOUBLE: \ | |
4697a36c | 2097 | case HIGH: \ |
f045b2c9 RS |
2098 | return 0; |
2099 | ||
2100 | /* Provide the costs of a rtl expression. This is in the body of a | |
2101 | switch on CODE. */ | |
2102 | ||
3bb22aee | 2103 | #define RTX_COSTS(X,CODE,OUTER_CODE) \ |
f045b2c9 | 2104 | case MULT: \ |
bdfd4e31 RK |
2105 | switch (rs6000_cpu) \ |
2106 | { \ | |
2107 | case PROCESSOR_RIOS1: \ | |
2108 | return (GET_CODE (XEXP (X, 1)) != CONST_INT \ | |
2109 | ? COSTS_N_INSNS (5) \ | |
2110 | : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \ | |
2111 | ? COSTS_N_INSNS (3) : COSTS_N_INSNS (4)); \ | |
2112 | case PROCESSOR_RIOS2: \ | |
cf27b467 | 2113 | case PROCESSOR_MPCCORE: \ |
bdfd4e31 RK |
2114 | return COSTS_N_INSNS (2); \ |
2115 | case PROCESSOR_PPC601: \ | |
869c489d | 2116 | return COSTS_N_INSNS (5); \ |
1ec26da6 DE |
2117 | case PROCESSOR_PPC603: \ |
2118 | return (GET_CODE (XEXP (X, 1)) != CONST_INT \ | |
2119 | ? COSTS_N_INSNS (5) \ | |
2120 | : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \ | |
2121 | ? COSTS_N_INSNS (2) : COSTS_N_INSNS (3)); \ | |
49a0b204 | 2122 | case PROCESSOR_PPC403: \ |
bdfd4e31 RK |
2123 | case PROCESSOR_PPC604: \ |
2124 | case PROCESSOR_PPC620: \ | |
869c489d | 2125 | return COSTS_N_INSNS (4); \ |
bdfd4e31 | 2126 | } \ |
f045b2c9 RS |
2127 | case DIV: \ |
2128 | case MOD: \ | |
2129 | if (GET_CODE (XEXP (X, 1)) == CONST_INT \ | |
2130 | && exact_log2 (INTVAL (XEXP (X, 1))) >= 0) \ | |
2131 | return COSTS_N_INSNS (2); \ | |
2132 | /* otherwise fall through to normal divide. */ \ | |
2133 | case UDIV: \ | |
2134 | case UMOD: \ | |
bdfd4e31 RK |
2135 | switch (rs6000_cpu) \ |
2136 | { \ | |
2137 | case PROCESSOR_RIOS1: \ | |
2138 | return COSTS_N_INSNS (19); \ | |
2139 | case PROCESSOR_RIOS2: \ | |
2140 | return COSTS_N_INSNS (13); \ | |
cf27b467 MM |
2141 | case PROCESSOR_MPCCORE: \ |
2142 | return COSTS_N_INSNS (6); \ | |
49a0b204 MM |
2143 | case PROCESSOR_PPC403: \ |
2144 | return COSTS_N_INSNS (33); \ | |
bdfd4e31 | 2145 | case PROCESSOR_PPC601: \ |
869c489d | 2146 | return COSTS_N_INSNS (36); \ |
bdfd4e31 | 2147 | case PROCESSOR_PPC603: \ |
869c489d | 2148 | return COSTS_N_INSNS (37); \ |
bdfd4e31 RK |
2149 | case PROCESSOR_PPC604: \ |
2150 | case PROCESSOR_PPC620: \ | |
869c489d | 2151 | return COSTS_N_INSNS (20); \ |
bdfd4e31 | 2152 | } \ |
3a942930 RK |
2153 | case FFS: \ |
2154 | return COSTS_N_INSNS (4); \ | |
f045b2c9 RS |
2155 | case MEM: \ |
2156 | /* MEM should be slightly more expensive than (plus (reg) (const)) */ \ | |
2157 | return 5; | |
2158 | ||
2159 | /* Compute the cost of an address. This is meant to approximate the size | |
2160 | and/or execution delay of an insn using that address. If the cost is | |
2161 | approximated by the RTL complexity, including CONST_COSTS above, as | |
2162 | is usually the case for CISC machines, this macro should not be defined. | |
2163 | For aggressively RISCy machines, only one insn format is allowed, so | |
2164 | this macro should be a constant. The value of this macro only matters | |
2165 | for valid addresses. | |
2166 | ||
2167 | For the RS/6000, everything is cost 0. */ | |
2168 | ||
2169 | #define ADDRESS_COST(RTX) 0 | |
2170 | ||
2171 | /* Adjust the length of an INSN. LENGTH is the currently-computed length and | |
2172 | should be adjusted to reflect any required changes. This macro is used when | |
2173 | there is some systematic length adjustment required that would be difficult | |
2174 | to express in the length attribute. */ | |
2175 | ||
2176 | /* #define ADJUST_INSN_LENGTH(X,LENGTH) */ | |
2177 | ||
2178 | /* Add any extra modes needed to represent the condition code. | |
2179 | ||
2180 | For the RS/6000, we need separate modes when unsigned (logical) comparisons | |
c5defebb RK |
2181 | are being done and we need a separate mode for floating-point. We also |
2182 | use a mode for the case when we are comparing the results of two | |
2183 | comparisons. */ | |
f045b2c9 | 2184 | |
c5defebb | 2185 | #define EXTRA_CC_MODES CCUNSmode, CCFPmode, CCEQmode |
f045b2c9 RS |
2186 | |
2187 | /* Define the names for the modes specified above. */ | |
c5defebb | 2188 | #define EXTRA_CC_NAMES "CCUNS", "CCFP", "CCEQ" |
f045b2c9 RS |
2189 | |
2190 | /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, | |
2191 | return the mode to be used for the comparison. For floating-point, CCFPmode | |
c5defebb RK |
2192 | should be used. CCUNSmode should be used for unsigned comparisons. |
2193 | CCEQmode should be used when we are doing an inequality comparison on | |
2194 | the result of a comparison. CCmode should be used in all other cases. */ | |
2195 | ||
b565a316 | 2196 | #define SELECT_CC_MODE(OP,X,Y) \ |
f045b2c9 | 2197 | (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CCFPmode \ |
c5defebb RK |
2198 | : (OP) == GTU || (OP) == LTU || (OP) == GEU || (OP) == LEU ? CCUNSmode \ |
2199 | : (((OP) == EQ || (OP) == NE) && GET_RTX_CLASS (GET_CODE (X)) == '<' \ | |
2200 | ? CCEQmode : CCmode)) | |
f045b2c9 RS |
2201 | |
2202 | /* Define the information needed to generate branch and scc insns. This is | |
2203 | stored from the compare operation. Note that we can't use "rtx" here | |
2204 | since it hasn't been defined! */ | |
2205 | ||
2206 | extern struct rtx_def *rs6000_compare_op0, *rs6000_compare_op1; | |
2207 | extern int rs6000_compare_fp_p; | |
2208 | ||
2209 | /* Set to non-zero by "fix" operation to indicate that itrunc and | |
2210 | uitrunc must be defined. */ | |
2211 | ||
2212 | extern int rs6000_trunc_used; | |
9929b575 ILT |
2213 | |
2214 | /* Function names to call to do floating point truncation. */ | |
2215 | ||
2216 | #define RS6000_ITRUNC "itrunc" | |
2217 | #define RS6000_UITRUNC "uitrunc" | |
4d30c363 MM |
2218 | |
2219 | /* Prefix and suffix to use to saving floating point */ | |
2220 | #ifndef SAVE_FP_PREFIX | |
2221 | #define SAVE_FP_PREFIX "._savef" | |
2222 | #define SAVE_FP_SUFFIX "" | |
2223 | #endif | |
2224 | ||
2225 | /* Prefix and suffix to use to restoring floating point */ | |
2226 | #ifndef RESTORE_FP_PREFIX | |
2227 | #define RESTORE_FP_PREFIX "._restf" | |
2228 | #define RESTORE_FP_SUFFIX "" | |
2229 | #endif | |
2230 | ||
f045b2c9 RS |
2231 | \f |
2232 | /* Control the assembler format that we output. */ | |
2233 | ||
1b279f39 DE |
2234 | /* A C string constant describing how to begin a comment in the target |
2235 | assembler language. The compiler assumes that the comment will end at | |
2236 | the end of the line. */ | |
2237 | #define ASM_COMMENT_START " #" | |
6b67933e | 2238 | |
f045b2c9 RS |
2239 | /* Output at beginning of assembler file. |
2240 | ||
b4d6689b | 2241 | Initialize the section names for the RS/6000 at this point. |
fdaff8ba | 2242 | |
6355b140 | 2243 | Specify filename to assembler. |
3fc2151d | 2244 | |
b4d6689b | 2245 | We want to go into the TOC section so at least one .toc will be emitted. |
fdaff8ba | 2246 | Also, in order to output proper .bs/.es pairs, we need at least one static |
b4d6689b RK |
2247 | [RW] section emitted. |
2248 | ||
2249 | We then switch back to text to force the gcc2_compiled. label and the space | |
c81bebd7 | 2250 | allocated after it (when profiling) into the text section. |
b4d6689b RK |
2251 | |
2252 | Finally, declare mcount when profiling to make the assembler happy. */ | |
f045b2c9 RS |
2253 | |
2254 | #define ASM_FILE_START(FILE) \ | |
2255 | { \ | |
fdaff8ba | 2256 | rs6000_gen_section_name (&xcoff_bss_section_name, \ |
f045b2c9 | 2257 | main_input_filename, ".bss_"); \ |
fdaff8ba | 2258 | rs6000_gen_section_name (&xcoff_private_data_section_name, \ |
f045b2c9 | 2259 | main_input_filename, ".rw_"); \ |
fdaff8ba | 2260 | rs6000_gen_section_name (&xcoff_read_only_section_name, \ |
f045b2c9 RS |
2261 | main_input_filename, ".ro_"); \ |
2262 | \ | |
6355b140 | 2263 | output_file_directive (FILE, main_input_filename); \ |
f045b2c9 | 2264 | toc_section (); \ |
fdaff8ba RS |
2265 | if (write_symbols != NO_DEBUG) \ |
2266 | private_data_section (); \ | |
b4d6689b RK |
2267 | text_section (); \ |
2268 | if (profile_flag) \ | |
19d2d16f | 2269 | fputs ("\t.extern .mcount\n", FILE); \ |
3cfa4909 | 2270 | rs6000_file_start (FILE, TARGET_CPU_DEFAULT); \ |
f045b2c9 RS |
2271 | } |
2272 | ||
2273 | /* Output at end of assembler file. | |
2274 | ||
2275 | On the RS/6000, referencing data should automatically pull in text. */ | |
2276 | ||
2277 | #define ASM_FILE_END(FILE) \ | |
2278 | { \ | |
2279 | text_section (); \ | |
19d2d16f | 2280 | fputs ("_section_.text:\n", FILE); \ |
f045b2c9 | 2281 | data_section (); \ |
19d2d16f | 2282 | fputs ("\t.long _section_.text\n", FILE); \ |
f045b2c9 RS |
2283 | } |
2284 | ||
f045b2c9 RS |
2285 | /* We define this to prevent the name mangler from putting dollar signs into |
2286 | function names. */ | |
2287 | ||
2288 | #define NO_DOLLAR_IN_LABEL | |
2289 | ||
2290 | /* We define this to 0 so that gcc will never accept a dollar sign in a | |
2291 | variable name. This is needed because the AIX assembler will not accept | |
2292 | dollar signs. */ | |
2293 | ||
2294 | #define DOLLARS_IN_IDENTIFIERS 0 | |
2295 | ||
fdaff8ba RS |
2296 | /* Implicit library calls should use memcpy, not bcopy, etc. */ |
2297 | ||
2298 | #define TARGET_MEM_FUNCTIONS | |
2299 | ||
f045b2c9 RS |
2300 | /* Define the extra sections we need. We define three: one is the read-only |
2301 | data section which is used for constants. This is a csect whose name is | |
2302 | derived from the name of the input file. The second is for initialized | |
2303 | global variables. This is a csect whose name is that of the variable. | |
2304 | The third is the TOC. */ | |
2305 | ||
2306 | #define EXTRA_SECTIONS \ | |
2307 | read_only_data, private_data, read_only_private_data, toc, bss | |
2308 | ||
2309 | /* Define the name of our readonly data section. */ | |
2310 | ||
2311 | #define READONLY_DATA_SECTION read_only_data_section | |
2312 | ||
b4f892eb RK |
2313 | /* If we are referencing a function that is static or is known to be |
2314 | in this file, make the SYMBOL_REF special. We can use this to indicate | |
2315 | that we can branch to this function without emitting a no-op after the | |
2316 | call. */ | |
2317 | ||
2318 | #define ENCODE_SECTION_INFO(DECL) \ | |
2319 | if (TREE_CODE (DECL) == FUNCTION_DECL \ | |
2320 | && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))) \ | |
2321 | SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; | |
2322 | ||
f045b2c9 RS |
2323 | /* Indicate that jump tables go in the text section. */ |
2324 | ||
2325 | #define JUMP_TABLES_IN_TEXT_SECTION | |
2326 | ||
2327 | /* Define the routines to implement these extra sections. */ | |
2328 | ||
2329 | #define EXTRA_SECTION_FUNCTIONS \ | |
2330 | \ | |
2331 | void \ | |
2332 | read_only_data_section () \ | |
2333 | { \ | |
2334 | if (in_section != read_only_data) \ | |
2335 | { \ | |
469adec3 | 2336 | fprintf (asm_out_file, ".csect %s[RO]\n", \ |
fdaff8ba | 2337 | xcoff_read_only_section_name); \ |
f045b2c9 RS |
2338 | in_section = read_only_data; \ |
2339 | } \ | |
2340 | } \ | |
2341 | \ | |
2342 | void \ | |
2343 | private_data_section () \ | |
2344 | { \ | |
2345 | if (in_section != private_data) \ | |
2346 | { \ | |
469adec3 | 2347 | fprintf (asm_out_file, ".csect %s[RW]\n", \ |
fdaff8ba | 2348 | xcoff_private_data_section_name); \ |
f045b2c9 RS |
2349 | \ |
2350 | in_section = private_data; \ | |
2351 | } \ | |
2352 | } \ | |
2353 | \ | |
2354 | void \ | |
2355 | read_only_private_data_section () \ | |
2356 | { \ | |
2357 | if (in_section != read_only_private_data) \ | |
2358 | { \ | |
f25359b5 | 2359 | fprintf (asm_out_file, ".csect %s[RO]\n", \ |
fdaff8ba | 2360 | xcoff_private_data_section_name); \ |
f045b2c9 RS |
2361 | in_section = read_only_private_data; \ |
2362 | } \ | |
2363 | } \ | |
2364 | \ | |
2365 | void \ | |
2366 | toc_section () \ | |
2367 | { \ | |
642a35f1 JW |
2368 | if (TARGET_MINIMAL_TOC) \ |
2369 | { \ | |
2370 | static int toc_initialized = 0; \ | |
2371 | \ | |
2372 | /* toc_section is always called at least once from ASM_FILE_START, \ | |
2373 | so this is guaranteed to always be defined once and only once \ | |
2374 | in each file. */ \ | |
2375 | if (! toc_initialized) \ | |
2376 | { \ | |
19d2d16f MM |
2377 | fputs (".toc\nLCTOC..0:\n", asm_out_file); \ |
2378 | fputs ("\t.tc toc_table[TC],toc_table[RW]\n", asm_out_file); \ | |
642a35f1 JW |
2379 | toc_initialized = 1; \ |
2380 | } \ | |
f045b2c9 | 2381 | \ |
642a35f1 | 2382 | if (in_section != toc) \ |
19d2d16f | 2383 | fputs (".csect toc_table[RW]\n", asm_out_file); \ |
642a35f1 JW |
2384 | } \ |
2385 | else \ | |
2386 | { \ | |
2387 | if (in_section != toc) \ | |
19d2d16f | 2388 | fputs (".toc\n", asm_out_file); \ |
642a35f1 | 2389 | } \ |
f045b2c9 | 2390 | in_section = toc; \ |
fc3ffe83 | 2391 | } |
f045b2c9 RS |
2392 | |
2393 | /* This macro produces the initial definition of a function name. | |
2394 | On the RS/6000, we need to place an extra '.' in the function name and | |
c81bebd7 | 2395 | output the function descriptor. |
f045b2c9 RS |
2396 | |
2397 | The csect for the function will have already been created by the | |
2398 | `text_section' call previously done. We do have to go back to that | |
2399 | csect, however. */ | |
2400 | ||
fdaff8ba RS |
2401 | /* ??? What do the 16 and 044 in the .function line really mean? */ |
2402 | ||
f045b2c9 RS |
2403 | #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \ |
2404 | { if (TREE_PUBLIC (DECL)) \ | |
2405 | { \ | |
19d2d16f | 2406 | fputs ("\t.globl .", FILE); \ |
f045b2c9 | 2407 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
19d2d16f | 2408 | putc ('\n', FILE); \ |
fdaff8ba | 2409 | } \ |
3ce428da | 2410 | else \ |
fdaff8ba | 2411 | { \ |
19d2d16f | 2412 | fputs ("\t.lglobl .", FILE); \ |
fdaff8ba | 2413 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
19d2d16f | 2414 | putc ('\n', FILE); \ |
f045b2c9 | 2415 | } \ |
19d2d16f | 2416 | fputs (".csect ", FILE); \ |
f045b2c9 | 2417 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
19d2d16f | 2418 | fputs ("[DS]\n", FILE); \ |
f045b2c9 | 2419 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
19d2d16f | 2420 | fputs (":\n", FILE); \ |
5854b0d0 | 2421 | fputs ((TARGET_32BIT) ? "\t.long ." : "\t.llong .", FILE); \ |
f045b2c9 | 2422 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
19d2d16f MM |
2423 | fputs (", TOC[tc0], 0\n", FILE); \ |
2424 | fputs (".csect .text[PR]\n.", FILE); \ | |
f045b2c9 | 2425 | RS6000_OUTPUT_BASENAME (FILE, NAME); \ |
19d2d16f | 2426 | fputs (":\n", FILE); \ |
fdaff8ba | 2427 | if (write_symbols == XCOFF_DEBUG) \ |
c2a47e48 | 2428 | xcoffout_declare_function (FILE, DECL, NAME); \ |
f045b2c9 RS |
2429 | } |
2430 | ||
2431 | /* Return non-zero if this entry is to be written into the constant pool | |
2432 | in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST | |
2433 | containing one of them. If -mfp-in-toc (the default), we also do | |
2434 | this for floating-point constants. We actually can only do this | |
2435 | if the FP formats of the target and host machines are the same, but | |
2436 | we can't check that since not every file that uses | |
2437 | GO_IF_LEGITIMATE_ADDRESS_P includes real.h. */ | |
2438 | ||
4697a36c MM |
2439 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X) \ |
2440 | (TARGET_TOC \ | |
2441 | && (GET_CODE (X) == SYMBOL_REF \ | |
2442 | || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ | |
2443 | && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ | |
2444 | || GET_CODE (X) == LABEL_REF \ | |
2445 | || (! (TARGET_NO_FP_IN_TOC && ! TARGET_MINIMAL_TOC) \ | |
2446 | && GET_CODE (X) == CONST_DOUBLE \ | |
2447 | && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ | |
2448 | && BITS_PER_WORD == HOST_BITS_PER_INT))) | |
f045b2c9 RS |
2449 | |
2450 | /* Select section for constant in constant pool. | |
2451 | ||
2452 | On RS/6000, all constants are in the private read-only data area. | |
2453 | However, if this is being placed in the TOC it must be output as a | |
2454 | toc entry. */ | |
2455 | ||
2456 | #define SELECT_RTX_SECTION(MODE, X) \ | |
2457 | { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X)) \ | |
2458 | toc_section (); \ | |
2459 | else \ | |
2460 | read_only_private_data_section (); \ | |
2461 | } | |
2462 | ||
2463 | /* Macro to output a special constant pool entry. Go to WIN if we output | |
2464 | it. Otherwise, it is written the usual way. | |
2465 | ||
2466 | On the RS/6000, toc entries are handled this way. */ | |
2467 | ||
2468 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY(FILE, X, MODE, ALIGN, LABELNO, WIN) \ | |
2469 | { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X)) \ | |
2470 | { \ | |
2471 | output_toc (FILE, X, LABELNO); \ | |
2472 | goto WIN; \ | |
2473 | } \ | |
2474 | } | |
2475 | ||
2476 | /* Select the section for an initialized data object. | |
2477 | ||
2478 | On the RS/6000, we have a special section for all variables except those | |
2479 | that are static. */ | |
2480 | ||
2481 | #define SELECT_SECTION(EXP,RELOC) \ | |
2482 | { \ | |
ed8969fa JW |
2483 | if ((TREE_CODE (EXP) == STRING_CST \ |
2484 | && !flag_writable_strings) \ | |
128e5769 | 2485 | || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd' \ |
1ff5cbcd | 2486 | && TREE_READONLY (EXP) && ! TREE_THIS_VOLATILE (EXP) \ |
ed8969fa JW |
2487 | && DECL_INITIAL (EXP) \ |
2488 | && (DECL_INITIAL (EXP) == error_mark_node \ | |
2489 | || TREE_CONSTANT (DECL_INITIAL (EXP))) \ | |
2490 | && ! (RELOC))) \ | |
f045b2c9 RS |
2491 | { \ |
2492 | if (TREE_PUBLIC (EXP)) \ | |
2493 | read_only_data_section (); \ | |
2494 | else \ | |
2495 | read_only_private_data_section (); \ | |
2496 | } \ | |
2497 | else \ | |
2498 | { \ | |
2499 | if (TREE_PUBLIC (EXP)) \ | |
2500 | data_section (); \ | |
2501 | else \ | |
2502 | private_data_section (); \ | |
2503 | } \ | |
2504 | } | |
2505 | ||
2506 | /* This outputs NAME to FILE up to the first null or '['. */ | |
2507 | ||
2508 | #define RS6000_OUTPUT_BASENAME(FILE, NAME) \ | |
c23a9d0e JM |
2509 | { \ |
2510 | char *_p; \ | |
99d3d26e | 2511 | \ |
c23a9d0e JM |
2512 | STRIP_NAME_ENCODING (_p, (NAME)); \ |
2513 | assemble_name ((FILE), _p); \ | |
2514 | } | |
2515 | ||
2516 | /* Remove any trailing [DS] or the like from the symbol name. */ | |
2517 | ||
28c57785 MM |
2518 | #define STRIP_NAME_ENCODING(VAR,NAME) \ |
2519 | do \ | |
2520 | { \ | |
2521 | char *_name = (NAME); \ | |
b6c9286a | 2522 | int _len; \ |
28c57785 | 2523 | if (_name[0] == '*') \ |
b6c9286a MM |
2524 | _name++; \ |
2525 | _len = strlen (_name); \ | |
2526 | if (_name[_len - 1] != ']') \ | |
2527 | (VAR) = _name; \ | |
28c57785 MM |
2528 | else \ |
2529 | { \ | |
b6c9286a MM |
2530 | (VAR) = (char *) alloca (_len + 1); \ |
2531 | strcpy ((VAR), _name); \ | |
2532 | (VAR)[_len - 4] = '\0'; \ | |
28c57785 MM |
2533 | } \ |
2534 | } \ | |
c23a9d0e | 2535 | while (0) |
f045b2c9 RS |
2536 | |
2537 | /* Output something to declare an external symbol to the assembler. Most | |
c81bebd7 | 2538 | assemblers don't need this. |
f045b2c9 RS |
2539 | |
2540 | If we haven't already, add "[RW]" (or "[DS]" for a function) to the | |
2541 | name. Normally we write this out along with the name. In the few cases | |
2542 | where we can't, it gets stripped off. */ | |
2543 | ||
2544 | #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ | |
2545 | { rtx _symref = XEXP (DECL_RTL (DECL), 0); \ | |
2546 | if ((TREE_CODE (DECL) == VAR_DECL \ | |
2547 | || TREE_CODE (DECL) == FUNCTION_DECL) \ | |
f045b2c9 RS |
2548 | && (NAME)[strlen (NAME) - 1] != ']') \ |
2549 | { \ | |
2550 | char *_name = (char *) permalloc (strlen (XSTR (_symref, 0)) + 5); \ | |
2551 | strcpy (_name, XSTR (_symref, 0)); \ | |
2552 | strcat (_name, TREE_CODE (DECL) == FUNCTION_DECL ? "[DS]" : "[RW]"); \ | |
2553 | XSTR (_symref, 0) = _name; \ | |
2554 | } \ | |
19d2d16f | 2555 | fputs ("\t.extern ", FILE); \ |
f045b2c9 RS |
2556 | assemble_name (FILE, XSTR (_symref, 0)); \ |
2557 | if (TREE_CODE (DECL) == FUNCTION_DECL) \ | |
2558 | { \ | |
19d2d16f | 2559 | fputs ("\n\t.extern .", FILE); \ |
f045b2c9 RS |
2560 | RS6000_OUTPUT_BASENAME (FILE, XSTR (_symref, 0)); \ |
2561 | } \ | |
19d2d16f | 2562 | putc ('\n', FILE); \ |
f045b2c9 RS |
2563 | } |
2564 | ||
2565 | /* Similar, but for libcall. We only have to worry about the function name, | |
2566 | not that of the descriptor. */ | |
2567 | ||
2568 | #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ | |
19d2d16f | 2569 | { fputs ("\t.extern .", FILE); \ |
f045b2c9 | 2570 | assemble_name (FILE, XSTR (FUN, 0)); \ |
19d2d16f | 2571 | putc ('\n', FILE); \ |
f045b2c9 RS |
2572 | } |
2573 | ||
2574 | /* Output to assembler file text saying following lines | |
2575 | may contain character constants, extra white space, comments, etc. */ | |
2576 | ||
2577 | #define ASM_APP_ON "" | |
2578 | ||
2579 | /* Output to assembler file text saying following lines | |
2580 | no longer contain unusual constructs. */ | |
2581 | ||
2582 | #define ASM_APP_OFF "" | |
2583 | ||
2584 | /* Output before instructions. */ | |
2585 | ||
11117bb9 | 2586 | #define TEXT_SECTION_ASM_OP ".csect .text[PR]" |
f045b2c9 RS |
2587 | |
2588 | /* Output before writable data. */ | |
2589 | ||
fdaff8ba | 2590 | #define DATA_SECTION_ASM_OP ".csect .data[RW]" |
f045b2c9 RS |
2591 | |
2592 | /* How to refer to registers in assembler output. | |
2593 | This sequence is indexed by compiler's hard-register-number (see above). */ | |
2594 | ||
802a0058 | 2595 | extern char rs6000_reg_names[][8]; /* register names (0 vs. %r0). */ |
c81bebd7 MM |
2596 | |
2597 | #define REGISTER_NAMES \ | |
2598 | { \ | |
2599 | &rs6000_reg_names[ 0][0], /* r0 */ \ | |
2600 | &rs6000_reg_names[ 1][0], /* r1 */ \ | |
2601 | &rs6000_reg_names[ 2][0], /* r2 */ \ | |
2602 | &rs6000_reg_names[ 3][0], /* r3 */ \ | |
2603 | &rs6000_reg_names[ 4][0], /* r4 */ \ | |
2604 | &rs6000_reg_names[ 5][0], /* r5 */ \ | |
2605 | &rs6000_reg_names[ 6][0], /* r6 */ \ | |
2606 | &rs6000_reg_names[ 7][0], /* r7 */ \ | |
2607 | &rs6000_reg_names[ 8][0], /* r8 */ \ | |
2608 | &rs6000_reg_names[ 9][0], /* r9 */ \ | |
2609 | &rs6000_reg_names[10][0], /* r10 */ \ | |
2610 | &rs6000_reg_names[11][0], /* r11 */ \ | |
2611 | &rs6000_reg_names[12][0], /* r12 */ \ | |
2612 | &rs6000_reg_names[13][0], /* r13 */ \ | |
2613 | &rs6000_reg_names[14][0], /* r14 */ \ | |
2614 | &rs6000_reg_names[15][0], /* r15 */ \ | |
2615 | &rs6000_reg_names[16][0], /* r16 */ \ | |
2616 | &rs6000_reg_names[17][0], /* r17 */ \ | |
2617 | &rs6000_reg_names[18][0], /* r18 */ \ | |
2618 | &rs6000_reg_names[19][0], /* r19 */ \ | |
2619 | &rs6000_reg_names[20][0], /* r20 */ \ | |
2620 | &rs6000_reg_names[21][0], /* r21 */ \ | |
2621 | &rs6000_reg_names[22][0], /* r22 */ \ | |
2622 | &rs6000_reg_names[23][0], /* r23 */ \ | |
2623 | &rs6000_reg_names[24][0], /* r24 */ \ | |
2624 | &rs6000_reg_names[25][0], /* r25 */ \ | |
2625 | &rs6000_reg_names[26][0], /* r26 */ \ | |
2626 | &rs6000_reg_names[27][0], /* r27 */ \ | |
2627 | &rs6000_reg_names[28][0], /* r28 */ \ | |
2628 | &rs6000_reg_names[29][0], /* r29 */ \ | |
2629 | &rs6000_reg_names[30][0], /* r30 */ \ | |
2630 | &rs6000_reg_names[31][0], /* r31 */ \ | |
2631 | \ | |
2632 | &rs6000_reg_names[32][0], /* fr0 */ \ | |
2633 | &rs6000_reg_names[33][0], /* fr1 */ \ | |
2634 | &rs6000_reg_names[34][0], /* fr2 */ \ | |
2635 | &rs6000_reg_names[35][0], /* fr3 */ \ | |
2636 | &rs6000_reg_names[36][0], /* fr4 */ \ | |
2637 | &rs6000_reg_names[37][0], /* fr5 */ \ | |
2638 | &rs6000_reg_names[38][0], /* fr6 */ \ | |
2639 | &rs6000_reg_names[39][0], /* fr7 */ \ | |
2640 | &rs6000_reg_names[40][0], /* fr8 */ \ | |
2641 | &rs6000_reg_names[41][0], /* fr9 */ \ | |
2642 | &rs6000_reg_names[42][0], /* fr10 */ \ | |
2643 | &rs6000_reg_names[43][0], /* fr11 */ \ | |
2644 | &rs6000_reg_names[44][0], /* fr12 */ \ | |
2645 | &rs6000_reg_names[45][0], /* fr13 */ \ | |
2646 | &rs6000_reg_names[46][0], /* fr14 */ \ | |
2647 | &rs6000_reg_names[47][0], /* fr15 */ \ | |
2648 | &rs6000_reg_names[48][0], /* fr16 */ \ | |
2649 | &rs6000_reg_names[49][0], /* fr17 */ \ | |
2650 | &rs6000_reg_names[50][0], /* fr18 */ \ | |
2651 | &rs6000_reg_names[51][0], /* fr19 */ \ | |
2652 | &rs6000_reg_names[52][0], /* fr20 */ \ | |
2653 | &rs6000_reg_names[53][0], /* fr21 */ \ | |
2654 | &rs6000_reg_names[54][0], /* fr22 */ \ | |
2655 | &rs6000_reg_names[55][0], /* fr23 */ \ | |
2656 | &rs6000_reg_names[56][0], /* fr24 */ \ | |
2657 | &rs6000_reg_names[57][0], /* fr25 */ \ | |
2658 | &rs6000_reg_names[58][0], /* fr26 */ \ | |
2659 | &rs6000_reg_names[59][0], /* fr27 */ \ | |
2660 | &rs6000_reg_names[60][0], /* fr28 */ \ | |
2661 | &rs6000_reg_names[61][0], /* fr29 */ \ | |
2662 | &rs6000_reg_names[62][0], /* fr30 */ \ | |
2663 | &rs6000_reg_names[63][0], /* fr31 */ \ | |
2664 | \ | |
2665 | &rs6000_reg_names[64][0], /* mq */ \ | |
2666 | &rs6000_reg_names[65][0], /* lr */ \ | |
2667 | &rs6000_reg_names[66][0], /* ctr */ \ | |
2668 | &rs6000_reg_names[67][0], /* ap */ \ | |
2669 | \ | |
2670 | &rs6000_reg_names[68][0], /* cr0 */ \ | |
2671 | &rs6000_reg_names[69][0], /* cr1 */ \ | |
2672 | &rs6000_reg_names[70][0], /* cr2 */ \ | |
2673 | &rs6000_reg_names[71][0], /* cr3 */ \ | |
2674 | &rs6000_reg_names[72][0], /* cr4 */ \ | |
2675 | &rs6000_reg_names[73][0], /* cr5 */ \ | |
2676 | &rs6000_reg_names[74][0], /* cr6 */ \ | |
2677 | &rs6000_reg_names[75][0], /* cr7 */ \ | |
802a0058 MM |
2678 | \ |
2679 | &rs6000_reg_names[76][0], /* fpmem */ \ | |
c81bebd7 MM |
2680 | } |
2681 | ||
2682 | /* print-rtl can't handle the above REGISTER_NAMES, so define the | |
2683 | following for it. Switch to use the alternate names since | |
2684 | they are more mnemonic. */ | |
2685 | ||
2686 | #define DEBUG_REGISTER_NAMES \ | |
2687 | { \ | |
802a0058 MM |
2688 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ |
2689 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \ | |
2690 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \ | |
2691 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \ | |
2692 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ | |
2693 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ | |
2694 | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ | |
2695 | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ | |
2696 | "mq", "lr", "ctr", "ap", \ | |
2697 | "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ | |
2698 | "fpmem" \ | |
c81bebd7 | 2699 | } |
f045b2c9 RS |
2700 | |
2701 | /* Table of additional register names to use in user input. */ | |
2702 | ||
2703 | #define ADDITIONAL_REGISTER_NAMES \ | |
2704 | {"r0", 0, "r1", 1, "r2", 2, "r3", 3, \ | |
2705 | "r4", 4, "r5", 5, "r6", 6, "r7", 7, \ | |
2706 | "r8", 8, "r9", 9, "r10", 10, "r11", 11, \ | |
2707 | "r12", 12, "r13", 13, "r14", 14, "r15", 15, \ | |
2708 | "r16", 16, "r17", 17, "r18", 18, "r19", 19, \ | |
2709 | "r20", 20, "r21", 21, "r22", 22, "r23", 23, \ | |
2710 | "r24", 24, "r25", 25, "r26", 26, "r27", 27, \ | |
2711 | "r28", 28, "r29", 29, "r30", 30, "r31", 31, \ | |
2712 | "fr0", 32, "fr1", 33, "fr2", 34, "fr3", 35, \ | |
2713 | "fr4", 36, "fr5", 37, "fr6", 38, "fr7", 39, \ | |
2714 | "fr8", 40, "fr9", 41, "fr10", 42, "fr11", 43, \ | |
2715 | "fr12", 44, "fr13", 45, "fr14", 46, "fr15", 47, \ | |
2716 | "fr16", 48, "fr17", 49, "fr18", 50, "fr19", 51, \ | |
2717 | "fr20", 52, "fr21", 53, "fr22", 54, "fr23", 55, \ | |
2718 | "fr24", 56, "fr25", 57, "fr26", 58, "fr27", 59, \ | |
2719 | "fr28", 60, "fr29", 61, "fr30", 62, "fr31", 63, \ | |
2720 | /* no additional names for: mq, lr, ctr, ap */ \ | |
2721 | "cr0", 68, "cr1", 69, "cr2", 70, "cr3", 71, \ | |
fc3ffe83 | 2722 | "cr4", 72, "cr5", 73, "cr6", 74, "cr7", 75, \ |
c81bebd7 | 2723 | "cc", 68, "sp", 1, "toc", 2 } |
f045b2c9 RS |
2724 | |
2725 | /* How to renumber registers for dbx and gdb. */ | |
2726 | ||
2727 | #define DBX_REGISTER_NUMBER(REGNO) (REGNO) | |
2728 | ||
0da40b09 RK |
2729 | /* Text to write out after a CALL that may be replaced by glue code by |
2730 | the loader. This depends on the AIX version. */ | |
2731 | #define RS6000_CALL_GLUE "cror 31,31,31" | |
11117bb9 | 2732 | |
f045b2c9 RS |
2733 | /* This is how to output the definition of a user-level label named NAME, |
2734 | such as the label on a static function or variable NAME. */ | |
2735 | ||
2736 | #define ASM_OUTPUT_LABEL(FILE,NAME) \ | |
2737 | do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0) | |
2738 | ||
2739 | /* This is how to output a command to make the user-level label named NAME | |
2740 | defined for reference from other files. */ | |
2741 | ||
2742 | #define ASM_GLOBALIZE_LABEL(FILE,NAME) \ | |
2743 | do { fputs ("\t.globl ", FILE); \ | |
2744 | RS6000_OUTPUT_BASENAME (FILE, NAME); fputs ("\n", FILE);} while (0) | |
2745 | ||
2746 | /* This is how to output a reference to a user-level label named NAME. | |
2747 | `assemble_name' uses this. */ | |
2748 | ||
2749 | #define ASM_OUTPUT_LABELREF(FILE,NAME) \ | |
7509c759 | 2750 | fputs (NAME, FILE) |
f045b2c9 RS |
2751 | |
2752 | /* This is how to output an internal numbered label where | |
2753 | PREFIX is the class of label and NUM is the number within the class. */ | |
2754 | ||
2755 | #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ | |
2756 | fprintf (FILE, "%s..%d:\n", PREFIX, NUM) | |
2757 | ||
3daf36a4 ILT |
2758 | /* This is how to output an internal label prefix. rs6000.c uses this |
2759 | when generating traceback tables. */ | |
2760 | ||
2761 | #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \ | |
2762 | fprintf (FILE, "%s..", PREFIX) | |
2763 | ||
f045b2c9 RS |
2764 | /* This is how to output a label for a jump table. Arguments are the same as |
2765 | for ASM_OUTPUT_INTERNAL_LABEL, except the insn for the jump table is | |
2766 | passed. */ | |
2767 | ||
2768 | #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \ | |
2769 | { ASM_OUTPUT_ALIGN (FILE, 2); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); } | |
2770 | ||
2771 | /* This is how to store into the string LABEL | |
2772 | the symbol_ref name of an internal numbered label where | |
2773 | PREFIX is the class of label and NUM is the number within the class. | |
2774 | This is suitable for output with `assemble_name'. */ | |
2775 | ||
2776 | #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ | |
3d199f7a | 2777 | sprintf (LABEL, "*%s..%d", PREFIX, NUM) |
f045b2c9 RS |
2778 | |
2779 | /* This is how to output an assembler line defining a `double' constant. */ | |
2780 | ||
a5b1eb34 RS |
2781 | #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \ |
2782 | { \ | |
2783 | if (REAL_VALUE_ISINF (VALUE) \ | |
2784 | || REAL_VALUE_ISNAN (VALUE) \ | |
2785 | || REAL_VALUE_MINUS_ZERO (VALUE)) \ | |
2786 | { \ | |
2787 | long t[2]; \ | |
2788 | REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \ | |
2789 | fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", \ | |
2790 | t[0] & 0xffffffff, t[1] & 0xffffffff); \ | |
2791 | } \ | |
2792 | else \ | |
2793 | { \ | |
2794 | char str[30]; \ | |
2795 | REAL_VALUE_TO_DECIMAL (VALUE, "%.20e", str); \ | |
2796 | fprintf (FILE, "\t.double 0d%s\n", str); \ | |
2797 | } \ | |
2798 | } | |
f045b2c9 RS |
2799 | |
2800 | /* This is how to output an assembler line defining a `float' constant. */ | |
2801 | ||
a5b1eb34 RS |
2802 | #define ASM_OUTPUT_FLOAT(FILE, VALUE) \ |
2803 | { \ | |
2804 | if (REAL_VALUE_ISINF (VALUE) \ | |
2805 | || REAL_VALUE_ISNAN (VALUE) \ | |
2806 | || REAL_VALUE_MINUS_ZERO (VALUE)) \ | |
2807 | { \ | |
2808 | long t; \ | |
2809 | REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \ | |
2810 | fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff); \ | |
2811 | } \ | |
2812 | else \ | |
2813 | { \ | |
2814 | char str[30]; \ | |
2815 | REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \ | |
2816 | fprintf (FILE, "\t.float 0d%s\n", str); \ | |
2817 | } \ | |
2818 | } | |
f045b2c9 RS |
2819 | |
2820 | /* This is how to output an assembler line defining an `int' constant. */ | |
2821 | ||
5854b0d0 DE |
2822 | #define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE) \ |
2823 | do { \ | |
2824 | if (TARGET_32BIT) \ | |
2825 | { \ | |
2826 | assemble_integer (operand_subword ((VALUE), 0, 0, DImode), \ | |
2827 | UNITS_PER_WORD, 1); \ | |
2828 | assemble_integer (operand_subword ((VALUE), 1, 0, DImode), \ | |
2829 | UNITS_PER_WORD, 1); \ | |
2830 | } \ | |
2831 | else \ | |
2832 | { \ | |
2833 | fputs ("\t.llong ", FILE); \ | |
2834 | output_addr_const (FILE, (VALUE)); \ | |
2835 | putc ('\n', FILE); \ | |
2836 | } \ | |
2837 | } while (0) | |
2838 | ||
f045b2c9 | 2839 | #define ASM_OUTPUT_INT(FILE,VALUE) \ |
19d2d16f | 2840 | ( fputs ("\t.long ", FILE), \ |
f045b2c9 | 2841 | output_addr_const (FILE, (VALUE)), \ |
19d2d16f | 2842 | putc ('\n', FILE)) |
f045b2c9 RS |
2843 | |
2844 | /* Likewise for `char' and `short' constants. */ | |
2845 | ||
2846 | #define ASM_OUTPUT_SHORT(FILE,VALUE) \ | |
19d2d16f | 2847 | ( fputs ("\t.short ", FILE), \ |
f045b2c9 | 2848 | output_addr_const (FILE, (VALUE)), \ |
19d2d16f | 2849 | putc ('\n', FILE)) |
f045b2c9 RS |
2850 | |
2851 | #define ASM_OUTPUT_CHAR(FILE,VALUE) \ | |
19d2d16f | 2852 | ( fputs ("\t.byte ", FILE), \ |
f045b2c9 | 2853 | output_addr_const (FILE, (VALUE)), \ |
19d2d16f | 2854 | putc ('\n', FILE)) |
f045b2c9 RS |
2855 | |
2856 | /* This is how to output an assembler line for a numeric constant byte. */ | |
2857 | ||
2858 | #define ASM_OUTPUT_BYTE(FILE,VALUE) \ | |
2859 | fprintf (FILE, "\t.byte 0x%x\n", (VALUE)) | |
2860 | ||
2861 | /* This is how to output an assembler line to define N characters starting | |
2862 | at P to FILE. */ | |
2863 | ||
2864 | #define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) | |
2865 | ||
2866 | /* This is how to output code to push a register on the stack. | |
2867 | It need not be very fast code. */ | |
2868 | ||
4697a36c MM |
2869 | #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ |
2870 | do { \ | |
2871 | extern char *reg_names[]; \ | |
2872 | asm_fprintf (FILE, "\{tstu|stwu} %s,-4(%s)\n", reg_names[REGNO], \ | |
2873 | reg_names[1]); \ | |
2874 | } while (0) | |
f045b2c9 RS |
2875 | |
2876 | /* This is how to output an insn to pop a register from the stack. | |
2877 | It need not be very fast code. */ | |
2878 | ||
4697a36c MM |
2879 | #define ASM_OUTPUT_REG_POP(FILE,REGNO) \ |
2880 | do { \ | |
2881 | extern char *reg_names[]; \ | |
2882 | asm_fprintf (FILE, "\t{l|lwz} %s,0(%s)\n\t{ai|addic} %s,%s,4\n", \ | |
2883 | reg_names[REGNO], reg_names[1], reg_names[1], \ | |
2884 | reg_names[1]); \ | |
2885 | } while (0) | |
f045b2c9 | 2886 | |
c81bebd7 | 2887 | /* This is how to output an element of a case-vector that is absolute. |
f045b2c9 RS |
2888 | (RS/6000 does not use such vectors, but we must define this macro |
2889 | anyway.) */ | |
2890 | ||
3daf36a4 ILT |
2891 | #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ |
2892 | do { char buf[100]; \ | |
5854b0d0 | 2893 | fputs ((TARGET_32BIT) ? "\t.long " : "\t.llong ", FILE); \ |
3daf36a4 ILT |
2894 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE); \ |
2895 | assemble_name (FILE, buf); \ | |
19d2d16f | 2896 | putc ('\n', FILE); \ |
3daf36a4 | 2897 | } while (0) |
f045b2c9 RS |
2898 | |
2899 | /* This is how to output an element of a case-vector that is relative. */ | |
2900 | ||
2901 | #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ | |
3daf36a4 | 2902 | do { char buf[100]; \ |
5854b0d0 | 2903 | fputs ((TARGET_32BIT) ? "\t.long " : "\t.llong ", FILE); \ |
3daf36a4 ILT |
2904 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE); \ |
2905 | assemble_name (FILE, buf); \ | |
19d2d16f | 2906 | putc ('-', FILE); \ |
3daf36a4 ILT |
2907 | ASM_GENERATE_INTERNAL_LABEL (buf, "L", REL); \ |
2908 | assemble_name (FILE, buf); \ | |
19d2d16f | 2909 | putc ('\n', FILE); \ |
3daf36a4 | 2910 | } while (0) |
f045b2c9 RS |
2911 | |
2912 | /* This is how to output an assembler line | |
2913 | that says to advance the location counter | |
2914 | to a multiple of 2**LOG bytes. */ | |
2915 | ||
2916 | #define ASM_OUTPUT_ALIGN(FILE,LOG) \ | |
2917 | if ((LOG) != 0) \ | |
2918 | fprintf (FILE, "\t.align %d\n", (LOG)) | |
2919 | ||
2920 | #define ASM_OUTPUT_SKIP(FILE,SIZE) \ | |
2921 | fprintf (FILE, "\t.space %d\n", (SIZE)) | |
2922 | ||
2923 | /* This says how to output an assembler line | |
2924 | to define a global common symbol. */ | |
2925 | ||
b73fd26c | 2926 | #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGNMENT) \ |
fc3ffe83 | 2927 | do { fputs (".comm ", (FILE)); \ |
f045b2c9 | 2928 | RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ |
b73fd26c DE |
2929 | if ( (SIZE) > 4) \ |
2930 | fprintf ((FILE), ",%d,3\n", (SIZE)); \ | |
2931 | else \ | |
2932 | fprintf( (FILE), ",%d\n", (SIZE)); \ | |
2933 | } while (0) | |
f045b2c9 RS |
2934 | |
2935 | /* This says how to output an assembler line | |
2936 | to define a local common symbol. */ | |
2937 | ||
2938 | #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \ | |
fc3ffe83 | 2939 | do { fputs (".lcomm ", (FILE)); \ |
f045b2c9 | 2940 | RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ |
fdaff8ba | 2941 | fprintf ((FILE), ",%d,%s\n", (SIZE), xcoff_bss_section_name); \ |
f045b2c9 RS |
2942 | } while (0) |
2943 | ||
2944 | /* Store in OUTPUT a string (made with alloca) containing | |
2945 | an assembler-name for a local static variable named NAME. | |
2946 | LABELNO is an integer which is different for each call. */ | |
2947 | ||
2948 | #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ | |
2949 | ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ | |
2950 | sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) | |
2951 | ||
2952 | /* Define the parentheses used to group arithmetic operations | |
2953 | in assembler code. */ | |
2954 | ||
2955 | #define ASM_OPEN_PAREN "(" | |
2956 | #define ASM_CLOSE_PAREN ")" | |
2957 | ||
2958 | /* Define results of standard character escape sequences. */ | |
2959 | #define TARGET_BELL 007 | |
2960 | #define TARGET_BS 010 | |
2961 | #define TARGET_TAB 011 | |
2962 | #define TARGET_NEWLINE 012 | |
2963 | #define TARGET_VT 013 | |
2964 | #define TARGET_FF 014 | |
2965 | #define TARGET_CR 015 | |
2966 | ||
2967 | /* Print operand X (an rtx) in assembler syntax to file FILE. | |
2968 | CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. | |
2969 | For `%' followed by punctuation, CODE is the punctuation and X is null. */ | |
2970 | ||
2971 | #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE) | |
2972 | ||
2973 | /* Define which CODE values are valid. */ | |
2974 | ||
c81bebd7 MM |
2975 | #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ |
2976 | ((CODE) == '.' || (CODE) == '*' || (CODE) == '$') | |
f045b2c9 RS |
2977 | |
2978 | /* Print a memory address as an operand to reference that memory location. */ | |
2979 | ||
2980 | #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR) | |
2981 | ||
2982 | /* Define the codes that are matched by predicates in rs6000.c. */ | |
2983 | ||
802a0058 | 2984 | #define PREDICATE_CODES \ |
f045b2c9 RS |
2985 | {"short_cint_operand", {CONST_INT}}, \ |
2986 | {"u_short_cint_operand", {CONST_INT}}, \ | |
f357808b | 2987 | {"non_short_cint_operand", {CONST_INT}}, \ |
cd2b37d9 | 2988 | {"gpc_reg_operand", {SUBREG, REG}}, \ |
f045b2c9 RS |
2989 | {"cc_reg_operand", {SUBREG, REG}}, \ |
2990 | {"reg_or_short_operand", {SUBREG, REG, CONST_INT}}, \ | |
2991 | {"reg_or_neg_short_operand", {SUBREG, REG, CONST_INT}}, \ | |
2992 | {"reg_or_u_short_operand", {SUBREG, REG, CONST_INT}}, \ | |
2993 | {"reg_or_cint_operand", {SUBREG, REG, CONST_INT}}, \ | |
766a866c | 2994 | {"got_operand", {SYMBOL_REF, CONST, LABEL_REF}}, \ |
f045b2c9 RS |
2995 | {"easy_fp_constant", {CONST_DOUBLE}}, \ |
2996 | {"reg_or_mem_operand", {SUBREG, MEM, REG}}, \ | |
414d3ee4 | 2997 | {"lwa_operand", {SUBREG, MEM, REG}}, \ |
b6c9286a | 2998 | {"volatile_mem_operand", {MEM}}, \ |
b7676b46 | 2999 | {"offsettable_addr_operand", {REG, SUBREG, PLUS}}, \ |
f045b2c9 RS |
3000 | {"fp_reg_or_mem_operand", {SUBREG, MEM, REG}}, \ |
3001 | {"mem_or_easy_const_operand", {SUBREG, MEM, CONST_DOUBLE}}, \ | |
3002 | {"add_operand", {SUBREG, REG, CONST_INT}}, \ | |
f357808b | 3003 | {"non_add_cint_operand", {CONST_INT}}, \ |
f045b2c9 | 3004 | {"and_operand", {SUBREG, REG, CONST_INT}}, \ |
f357808b | 3005 | {"non_and_cint_operand", {CONST_INT}}, \ |
f045b2c9 | 3006 | {"logical_operand", {SUBREG, REG, CONST_INT}}, \ |
f357808b | 3007 | {"non_logical_cint_operand", {CONST_INT}}, \ |
f045b2c9 | 3008 | {"mask_operand", {CONST_INT}}, \ |
b6c9286a | 3009 | {"count_register_operand", {REG}}, \ |
802a0058 | 3010 | {"fpmem_operand", {REG}}, \ |
f045b2c9 | 3011 | {"call_operand", {SYMBOL_REF, REG}}, \ |
f8634644 | 3012 | {"current_file_function_operand", {SYMBOL_REF}}, \ |
38250554 | 3013 | {"input_operand", {SUBREG, MEM, REG, CONST_INT, SYMBOL_REF}}, \ |
f8634644 RK |
3014 | {"load_multiple_operation", {PARALLEL}}, \ |
3015 | {"store_multiple_operation", {PARALLEL}}, \ | |
3016 | {"branch_comparison_operator", {EQ, NE, LE, LT, GE, \ | |
e477bbc7 | 3017 | GT, LEU, LTU, GEU, GTU}}, \ |
f8634644 | 3018 | {"scc_comparison_operator", {EQ, NE, LE, LT, GE, \ |
e477bbc7 | 3019 | GT, LEU, LTU, GEU, GTU}}, |
75814ad4 | 3020 | |
b6c9286a MM |
3021 | |
3022 | /* uncomment for disabling the corresponding default options */ | |
3023 | /* #define MACHINE_no_sched_interblock */ | |
3024 | /* #define MACHINE_no_sched_speculative */ | |
3025 | /* #define MACHINE_no_sched_speculative_load */ | |
3026 | ||
3027 | /* indicate that issue rate is defined for this machine | |
3028 | (no need to use the default) */ | |
3029 | #define MACHINE_issue_rate | |
3030 | ||
766a866c MM |
3031 | /* General flags. */ |
3032 | extern int flag_pic; | |
354b734b MM |
3033 | extern int optimize; |
3034 | extern int flag_expensive_optimizations; | |
a7df97e6 | 3035 | extern int frame_pointer_needed; |
354b734b | 3036 | |
75814ad4 | 3037 | /* Declare functions in rs6000.c */ |
6b67933e | 3038 | extern void output_options (); |
75814ad4 | 3039 | extern void rs6000_override_options (); |
3cfa4909 | 3040 | extern void rs6000_file_start (); |
6b67933e | 3041 | extern struct rtx_def *rs6000_float_const (); |
75814ad4 | 3042 | extern struct rtx_def *rs6000_immed_double_const (); |
c4c40373 | 3043 | extern struct rtx_def *rs6000_got_register (); |
75814ad4 MM |
3044 | extern int direct_return (); |
3045 | extern int any_operand (); | |
3046 | extern int short_cint_operand (); | |
3047 | extern int u_short_cint_operand (); | |
3048 | extern int non_short_cint_operand (); | |
3049 | extern int gpc_reg_operand (); | |
3050 | extern int cc_reg_operand (); | |
3051 | extern int reg_or_short_operand (); | |
3052 | extern int reg_or_neg_short_operand (); | |
3053 | extern int reg_or_u_short_operand (); | |
3054 | extern int reg_or_cint_operand (); | |
766a866c | 3055 | extern int got_operand (); |
4e74d8ec | 3056 | extern int num_insns_constant (); |
75814ad4 | 3057 | extern int easy_fp_constant (); |
b7676b46 RK |
3058 | extern int volatile_mem_operand (); |
3059 | extern int offsettable_addr_operand (); | |
75814ad4 MM |
3060 | extern int fp_reg_or_mem_operand (); |
3061 | extern int mem_or_easy_const_operand (); | |
3062 | extern int add_operand (); | |
3063 | extern int non_add_cint_operand (); | |
3064 | extern int logical_operand (); | |
3065 | extern int non_logical_operand (); | |
3066 | extern int mask_constant (); | |
3067 | extern int mask_operand (); | |
3068 | extern int and_operand (); | |
802a0058 MM |
3069 | extern int count_register_operand (); |
3070 | extern int fpmem_operand (); | |
75814ad4 MM |
3071 | extern int non_and_cint_operand (); |
3072 | extern int reg_or_mem_operand (); | |
3073 | extern int lwa_operand (); | |
3074 | extern int call_operand (); | |
3075 | extern int current_file_function_operand (); | |
3076 | extern int input_operand (); | |
7509c759 | 3077 | extern int small_data_operand (); |
4697a36c MM |
3078 | extern void init_cumulative_args (); |
3079 | extern void function_arg_advance (); | |
b6c9286a | 3080 | extern int function_arg_boundary (); |
4697a36c MM |
3081 | extern struct rtx_def *function_arg (); |
3082 | extern int function_arg_partial_nregs (); | |
3083 | extern int function_arg_pass_by_reference (); | |
3084 | extern void setup_incoming_varargs (); | |
3085 | extern struct rtx_def *expand_builtin_saveregs (); | |
b7676b46 | 3086 | extern struct rtx_def *rs6000_stack_temp (); |
7e69e155 | 3087 | extern int expand_block_move (); |
75814ad4 MM |
3088 | extern int load_multiple_operation (); |
3089 | extern int store_multiple_operation (); | |
3090 | extern int branch_comparison_operator (); | |
3091 | extern int scc_comparison_operator (); | |
3092 | extern int includes_lshift_p (); | |
3093 | extern int includes_rshift_p (); | |
3094 | extern int registers_ok_for_quad_peep (); | |
3095 | extern int addrs_ok_for_quad_peep (); | |
3096 | extern enum reg_class secondary_reload_class (); | |
3097 | extern int ccr_bit (); | |
d266da75 | 3098 | extern void rs6000_finalize_pic (); |
30ea98f1 | 3099 | extern void rs6000_reorg (); |
a7df97e6 MM |
3100 | extern void rs6000_save_machine_status (); |
3101 | extern void rs6000_restore_machine_status (); | |
3102 | extern void rs6000_init_expanders (); | |
75814ad4 MM |
3103 | extern void print_operand (); |
3104 | extern void print_operand_address (); | |
3105 | extern int first_reg_to_save (); | |
3106 | extern int first_fp_reg_to_save (); | |
75814ad4 | 3107 | extern int rs6000_makes_calls (); |
4697a36c | 3108 | extern rs6000_stack_t *rs6000_stack_info (); |
75814ad4 MM |
3109 | extern void output_prolog (); |
3110 | extern void output_epilog (); | |
3111 | extern void output_toc (); | |
3112 | extern void output_ascii (); | |
3113 | extern void rs6000_gen_section_name (); | |
3114 | extern void output_function_profiler (); | |
3115 | extern int rs6000_adjust_cost (); | |
b6c9286a MM |
3116 | extern void rs6000_trampoline_template (); |
3117 | extern int rs6000_trampoline_size (); | |
3118 | extern void rs6000_initialize_trampoline (); | |
7509c759 MM |
3119 | extern int rs6000_comp_type_attributes (); |
3120 | extern int rs6000_valid_decl_attribute_p (); | |
3121 | extern int rs6000_valid_type_attribute_p (); | |
3122 | extern void rs6000_set_default_type_attributes (); | |
3123 | extern struct rtx_def *rs6000_dll_import_ref (); | |
6a4cee5f | 3124 | extern struct rtx_def *rs6000_longcall_ref (); |