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