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