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