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