]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/rs6000.h
configopts.html: HTML to XHTML change.
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000.h
CommitLineData
f045b2c9 1/* Definitions of target machine for GNU compiler, for IBM RS/6000.
9ebbca7d 2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
cf011243 3 2000, 2001 Free Software Foundation, Inc.
6a7ec0a7 4 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
f045b2c9
RS
5
6This file is part of GNU CC.
7
8GNU CC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2, or (at your option)
11any later version.
12
13GNU CC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU CC; see the file COPYING. If not, write to
c15c9075
RK
20the Free Software Foundation, 59 Temple Place - Suite 330,
21Boston, MA 02111-1307, USA. */
f045b2c9
RS
22
23
24/* Note that some other tm.h files include this one and then override
9ebbca7d 25 many of the definitions. */
f045b2c9 26
9ebbca7d
GK
27/* Definitions for the object file format. These are set at
28 compile-time. */
f045b2c9 29
9ebbca7d
GK
30#define OBJECT_XCOFF 1
31#define OBJECT_ELF 2
32#define OBJECT_PEF 3
ee890fe2 33#define OBJECT_MACHO 4
f045b2c9 34
9ebbca7d 35#define TARGET_ELF (TARGET_OBJECT_FORMAT == OBJECT_ELF)
2bfcf297 36#define TARGET_XCOFF (TARGET_OBJECT_FORMAT == OBJECT_XCOFF)
9ebbca7d 37#define TARGET_MACOS (TARGET_OBJECT_FORMAT == OBJECT_PEF)
ee890fe2 38#define TARGET_MACHO (TARGET_OBJECT_FORMAT == OBJECT_MACHO)
f045b2c9 39
2bfcf297
DB
40#ifndef TARGET_AIX
41#define TARGET_AIX 0
42#endif
43
f045b2c9
RS
44/* Print subsidiary information on the compiler version in use. */
45#define TARGET_VERSION ;
46
8e3f41e7
MM
47/* Default string to use for cpu if not specified. */
48#ifndef TARGET_CPU_DEFAULT
49#define TARGET_CPU_DEFAULT ((char *)0)
50#endif
51
f984d8df
DB
52/* Common CPP definitions used by CPP_SPEC among the various targets
53 for handling -mcpu=xxx switches. */
54#define CPP_CPU_SPEC \
55"%{!mcpu*: \
56 %{mpower: %{!mpower2: -D_ARCH_PWR}} \
57 %{mpower2: -D_ARCH_PWR2} \
58 %{mpowerpc*: -D_ARCH_PPC} \
59 %{mno-power: %{!mpowerpc*: -D_ARCH_COM}} \
60 %{!mno-power: %{!mpower2: %(cpp_default)}}} \
61%{mcpu=common: -D_ARCH_COM} \
62%{mcpu=power: -D_ARCH_PWR} \
63%{mcpu=power2: -D_ARCH_PWR2} \
64%{mcpu=powerpc: -D_ARCH_PPC} \
65%{mcpu=rios: -D_ARCH_PWR} \
66%{mcpu=rios1: -D_ARCH_PWR} \
67%{mcpu=rios2: -D_ARCH_PWR2} \
68%{mcpu=rsc: -D_ARCH_PWR} \
69%{mcpu=rsc1: -D_ARCH_PWR} \
70%{mcpu=401: -D_ARCH_PPC} \
71%{mcpu=403: -D_ARCH_PPC} \
72%{mcpu=505: -D_ARCH_PPC} \
73%{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \
74%{mcpu=602: -D_ARCH_PPC} \
75%{mcpu=603: -D_ARCH_PPC} \
76%{mcpu=603e: -D_ARCH_PPC} \
77%{mcpu=ec603e: -D_ARCH_PPC} \
78%{mcpu=604: -D_ARCH_PPC} \
79%{mcpu=604e: -D_ARCH_PPC} \
80%{mcpu=620: -D_ARCH_PPC} \
81%{mcpu=740: -D_ARCH_PPC} \
82%{mcpu=750: -D_ARCH_PPC} \
83%{mcpu=801: -D_ARCH_PPC} \
84%{mcpu=821: -D_ARCH_PPC} \
85%{mcpu=823: -D_ARCH_PPC} \
86%{mcpu=860: -D_ARCH_PPC}"
87
88/* Common ASM definitions used by ASM_SPEC among the various targets
89 for handling -mcpu=xxx switches. */
90#define ASM_CPU_SPEC \
91"%{!mcpu*: \
92 %{mpower: %{!mpower2: -mpwr}} \
93 %{mpower2: -mpwrx} \
94 %{mpowerpc*: -mppc} \
95 %{mno-power: %{!mpowerpc*: -mcom}} \
96 %{!mno-power: %{!mpower2: %(asm_default)}}} \
97%{mcpu=common: -mcom} \
98%{mcpu=power: -mpwr} \
99%{mcpu=power2: -mpwrx} \
100%{mcpu=powerpc: -mppc} \
101%{mcpu=rios: -mpwr} \
102%{mcpu=rios1: -mpwr} \
103%{mcpu=rios2: -mpwrx} \
104%{mcpu=rsc: -mpwr} \
105%{mcpu=rsc1: -mpwr} \
106%{mcpu=401: -mppc} \
107%{mcpu=403: -mppc} \
108%{mcpu=505: -mppc} \
109%{mcpu=601: -m601} \
110%{mcpu=602: -mppc} \
111%{mcpu=603: -mppc} \
112%{mcpu=603e: -mppc} \
113%{mcpu=ec603e: -mppc} \
114%{mcpu=604: -mppc} \
115%{mcpu=604e: -mppc} \
116%{mcpu=620: -mppc} \
117%{mcpu=740: -mppc} \
118%{mcpu=750: -mppc} \
119%{mcpu=801: -mppc} \
120%{mcpu=821: -mppc} \
121%{mcpu=823: -mppc} \
122%{mcpu=860: -mppc}"
123
124#define CPP_DEFAULT_SPEC ""
125
126#define ASM_DEFAULT_SPEC ""
127
841faeed
MM
128/* This macro defines names of additional specifications to put in the specs
129 that can be used in various specifications like CC1_SPEC. Its definition
130 is an initializer with a subgrouping for each command option.
131
132 Each subgrouping contains a string constant, that defines the
133 specification name, and a string constant that used by the GNU CC driver
134 program.
135
136 Do not define this macro if it does not need to do anything. */
137
7509c759 138#define SUBTARGET_EXTRA_SPECS
7509c759 139
c81bebd7
MM
140#define EXTRA_SPECS \
141 { "cpp_cpu", CPP_CPU_SPEC }, \
142 { "cpp_default", CPP_DEFAULT_SPEC }, \
c81bebd7
MM
143 { "asm_cpu", ASM_CPU_SPEC }, \
144 { "asm_default", ASM_DEFAULT_SPEC }, \
7509c759
MM
145 SUBTARGET_EXTRA_SPECS
146
fb623df5 147/* Architecture type. */
f045b2c9 148
fb623df5
RK
149extern int target_flags;
150
151/* Use POWER architecture instructions and MQ register. */
38c1f2d7 152#define MASK_POWER 0x00000001
fb623df5 153
6febd581 154/* Use POWER2 extensions to POWER architecture. */
38c1f2d7 155#define MASK_POWER2 0x00000002
6febd581 156
fb623df5 157/* Use PowerPC architecture instructions. */
38c1f2d7 158#define MASK_POWERPC 0x00000004
6febd581 159
583cf4db 160/* Use PowerPC General Purpose group optional instructions, e.g. fsqrt. */
38c1f2d7 161#define MASK_PPC_GPOPT 0x00000008
583cf4db
RK
162
163/* Use PowerPC Graphics group optional instructions, e.g. fsel. */
38c1f2d7 164#define MASK_PPC_GFXOPT 0x00000010
f045b2c9 165
fb623df5 166/* Use PowerPC-64 architecture instructions. */
38c1f2d7 167#define MASK_POWERPC64 0x00000020
f045b2c9 168
fb623df5 169/* Use revised mnemonic names defined for PowerPC architecture. */
38c1f2d7 170#define MASK_NEW_MNEMONICS 0x00000040
fb623df5
RK
171
172/* Disable placing fp constants in the TOC; can be turned on when the
173 TOC overflows. */
38c1f2d7 174#define MASK_NO_FP_IN_TOC 0x00000080
fb623df5 175
0b9ccabc
RK
176/* Disable placing symbol+offset constants in the TOC; can be turned on when
177 the TOC overflows. */
38c1f2d7 178#define MASK_NO_SUM_IN_TOC 0x00000100
0b9ccabc 179
fb623df5 180/* Output only one TOC entry per module. Normally linking fails if
642a35f1
JW
181 there are more than 16K unique variables/constants in an executable. With
182 this option, linking fails only if there are more than 16K modules, or
183 if there are more than 16K unique variables/constant in a single module.
184
185 This is at the cost of having 2 extra loads and one extra store per
956d6950 186 function, and one less allocable register. */
38c1f2d7 187#define MASK_MINIMAL_TOC 0x00000200
642a35f1 188
9e654916 189/* Nonzero for the 64bit model: ints, longs, and pointers are 64 bits. */
38c1f2d7 190#define MASK_64BIT 0x00000400
9e654916 191
f85f4585 192/* Disable use of FPRs. */
38c1f2d7 193#define MASK_SOFT_FLOAT 0x00000800
f85f4585 194
4d30c363 195/* Enable load/store multiple, even on powerpc */
38c1f2d7
MM
196#define MASK_MULTIPLE 0x00001000
197#define MASK_MULTIPLE_SET 0x00002000
4d30c363 198
7e69e155 199/* Use string instructions for block moves */
38c1f2d7
MM
200#define MASK_STRING 0x00004000
201#define MASK_STRING_SET 0x00008000
7e69e155 202
38c1f2d7
MM
203/* Disable update form of load/store */
204#define MASK_NO_UPDATE 0x00010000
205
206/* Disable fused multiply/add operations */
207#define MASK_NO_FUSED_MADD 0x00020000
4697a36c 208
9ebbca7d
GK
209/* Nonzero if we need to schedule the prolog and epilog. */
210#define MASK_SCHED_PROLOG 0x00040000
211
7e69e155
MM
212#define TARGET_POWER (target_flags & MASK_POWER)
213#define TARGET_POWER2 (target_flags & MASK_POWER2)
214#define TARGET_POWERPC (target_flags & MASK_POWERPC)
215#define TARGET_PPC_GPOPT (target_flags & MASK_PPC_GPOPT)
216#define TARGET_PPC_GFXOPT (target_flags & MASK_PPC_GFXOPT)
7e69e155
MM
217#define TARGET_NEW_MNEMONICS (target_flags & MASK_NEW_MNEMONICS)
218#define TARGET_NO_FP_IN_TOC (target_flags & MASK_NO_FP_IN_TOC)
219#define TARGET_NO_SUM_IN_TOC (target_flags & MASK_NO_SUM_IN_TOC)
220#define TARGET_MINIMAL_TOC (target_flags & MASK_MINIMAL_TOC)
221#define TARGET_64BIT (target_flags & MASK_64BIT)
222#define TARGET_SOFT_FLOAT (target_flags & MASK_SOFT_FLOAT)
223#define TARGET_MULTIPLE (target_flags & MASK_MULTIPLE)
224#define TARGET_MULTIPLE_SET (target_flags & MASK_MULTIPLE_SET)
225#define TARGET_STRING (target_flags & MASK_STRING)
938937d8 226#define TARGET_STRING_SET (target_flags & MASK_STRING_SET)
38c1f2d7
MM
227#define TARGET_NO_UPDATE (target_flags & MASK_NO_UPDATE)
228#define TARGET_NO_FUSED_MADD (target_flags & MASK_NO_FUSED_MADD)
9ebbca7d 229#define TARGET_SCHED_PROLOG (target_flags & MASK_SCHED_PROLOG)
7e69e155 230
2f3e5814 231#define TARGET_32BIT (! TARGET_64BIT)
7e69e155 232#define TARGET_HARD_FLOAT (! TARGET_SOFT_FLOAT)
38c1f2d7
MM
233#define TARGET_UPDATE (! TARGET_NO_UPDATE)
234#define TARGET_FUSED_MADD (! TARGET_NO_FUSED_MADD)
d14a6d05 235
996ed075
JJ
236#ifdef IN_LIBGCC2
237/* For libgcc2 we make sure this is a compile time constant */
996ed075
JJ
238#ifdef __64BIT__
239#define TARGET_POWERPC64 1
240#else
241#define TARGET_POWERPC64 0
242#endif
b6c9286a 243#else
9ebbca7d 244#define TARGET_POWERPC64 (target_flags & MASK_POWERPC64)
b6c9286a
MM
245#endif
246
a3950905 247#define TARGET_XL_CALL 0
a3950905 248
fb623df5 249/* Run-time compilation parameters selecting different hardware subsets.
f045b2c9 250
fb623df5 251 Macro to define tables used to set the flags.
f045b2c9
RS
252 This is a list in braces of pairs in braces,
253 each pair being { "NAME", VALUE }
254 where VALUE is the bits to set or minus the bits to clear.
255 An empty string NAME is used to identify the default VALUE. */
256
938937d8 257#define TARGET_SWITCHES \
9ebbca7d 258 {{"power", MASK_POWER | MASK_MULTIPLE | MASK_STRING, \
047142d3 259 N_("Use POWER instruction set")}, \
938937d8 260 {"power2", (MASK_POWER | MASK_MULTIPLE | MASK_STRING \
9ebbca7d 261 | MASK_POWER2), \
047142d3 262 N_("Use POWER2 instruction set")}, \
9ebbca7d 263 {"no-power2", - MASK_POWER2, \
047142d3 264 N_("Do not use POWER2 instruction set")}, \
938937d8 265 {"no-power", - (MASK_POWER | MASK_POWER2 | MASK_MULTIPLE \
9ebbca7d 266 | MASK_STRING), \
047142d3 267 N_("Do not use POWER instruction set")}, \
9ebbca7d 268 {"powerpc", MASK_POWERPC, \
047142d3 269 N_("Use PowerPC instruction set")}, \
938937d8 270 {"no-powerpc", - (MASK_POWERPC | MASK_PPC_GPOPT \
9ebbca7d 271 | MASK_PPC_GFXOPT | MASK_POWERPC64), \
047142d3 272 N_("Do not use PowerPC instruction set")}, \
9ebbca7d 273 {"powerpc-gpopt", MASK_POWERPC | MASK_PPC_GPOPT, \
047142d3 274 N_("Use PowerPC General Purpose group optional instructions")},\
9ebbca7d 275 {"no-powerpc-gpopt", - MASK_PPC_GPOPT, \
047142d3 276 N_("Don't use PowerPC General Purpose group optional instructions")},\
9ebbca7d 277 {"powerpc-gfxopt", MASK_POWERPC | MASK_PPC_GFXOPT, \
047142d3 278 N_("Use PowerPC Graphics group optional instructions")},\
9ebbca7d 279 {"no-powerpc-gfxopt", - MASK_PPC_GFXOPT, \
047142d3 280 N_("Don't use PowerPC Graphics group optional instructions")},\
9ebbca7d 281 {"powerpc64", MASK_POWERPC64, \
047142d3 282 N_("Use PowerPC-64 instruction set")}, \
9ebbca7d 283 {"no-powerpc64", - MASK_POWERPC64, \
047142d3 284 N_("Don't use PowerPC-64 instruction set")}, \
9ebbca7d 285 {"new-mnemonics", MASK_NEW_MNEMONICS, \
047142d3 286 N_("Use new mnemonics for PowerPC architecture")},\
9ebbca7d 287 {"old-mnemonics", -MASK_NEW_MNEMONICS, \
047142d3 288 N_("Use old mnemonics for PowerPC architecture")},\
938937d8 289 {"full-toc", - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC \
9ebbca7d 290 | MASK_MINIMAL_TOC), \
047142d3 291 N_("Put everything in the regular TOC")}, \
9ebbca7d 292 {"fp-in-toc", - MASK_NO_FP_IN_TOC, \
047142d3 293 N_("Place floating point constants in TOC")}, \
9ebbca7d 294 {"no-fp-in-toc", MASK_NO_FP_IN_TOC, \
047142d3 295 N_("Don't place floating point constants in TOC")},\
9ebbca7d 296 {"sum-in-toc", - MASK_NO_SUM_IN_TOC, \
047142d3 297 N_("Place symbol+offset constants in TOC")}, \
9ebbca7d 298 {"no-sum-in-toc", MASK_NO_SUM_IN_TOC, \
047142d3 299 N_("Don't place symbol+offset constants in TOC")},\
9ebbca7d
GK
300 {"minimal-toc", MASK_MINIMAL_TOC, \
301 "Use only one TOC entry per procedure"}, \
302 {"minimal-toc", - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC), \
047142d3 303 ""}, \
9ebbca7d 304 {"no-minimal-toc", - MASK_MINIMAL_TOC, \
047142d3 305 N_("Place variable addresses in the regular TOC")},\
9ebbca7d 306 {"hard-float", - MASK_SOFT_FLOAT, \
047142d3 307 N_("Use hardware fp")}, \
9ebbca7d 308 {"soft-float", MASK_SOFT_FLOAT, \
047142d3 309 N_("Do not use hardware fp")}, \
9ebbca7d 310 {"multiple", MASK_MULTIPLE | MASK_MULTIPLE_SET, \
047142d3 311 N_("Generate load/store multiple instructions")}, \
9ebbca7d 312 {"no-multiple", - MASK_MULTIPLE, \
047142d3 313 N_("Do not generate load/store multiple instructions")},\
9ebbca7d 314 {"no-multiple", MASK_MULTIPLE_SET, \
047142d3 315 ""}, \
9ebbca7d 316 {"string", MASK_STRING | MASK_STRING_SET, \
047142d3 317 N_("Generate string instructions for block moves")},\
9ebbca7d 318 {"no-string", - MASK_STRING, \
047142d3 319 N_("Do not generate string instructions for block moves")},\
9ebbca7d 320 {"no-string", MASK_STRING_SET, \
047142d3 321 ""}, \
9ebbca7d 322 {"update", - MASK_NO_UPDATE, \
047142d3 323 N_("Generate load/store with update instructions")},\
9ebbca7d 324 {"no-update", MASK_NO_UPDATE, \
047142d3 325 N_("Do not generate load/store with update instructions")},\
9ebbca7d 326 {"fused-madd", - MASK_NO_FUSED_MADD, \
047142d3 327 N_("Generate fused multiply/add instructions")},\
9ebbca7d 328 {"no-fused-madd", MASK_NO_FUSED_MADD, \
047142d3 329 N_("Don't generate fused multiply/add instructions")},\
9ebbca7d
GK
330 {"sched-prolog", MASK_SCHED_PROLOG, \
331 ""}, \
332 {"no-sched-prolog", -MASK_SCHED_PROLOG, \
047142d3 333 N_("Don't schedule the start and end of the procedure")},\
9ebbca7d
GK
334 {"sched-epilog", MASK_SCHED_PROLOG, \
335 ""}, \
336 {"no-sched-epilog", -MASK_SCHED_PROLOG, \
337 ""}, \
938937d8 338 SUBTARGET_SWITCHES \
9ebbca7d
GK
339 {"", TARGET_DEFAULT | MASK_SCHED_PROLOG, \
340 ""}}
fb623df5 341
938937d8 342#define TARGET_DEFAULT (MASK_POWER | MASK_MULTIPLE | MASK_STRING)
9ebbca7d
GK
343
344/* This is meant to be redefined in the host dependent files */
345#define SUBTARGET_SWITCHES
fb623df5 346
cac8ce95 347/* Processor type. Order must match cpu attribute in MD file. */
fb623df5 348enum processor_type
bef84347
VM
349 {
350 PROCESSOR_RIOS1,
351 PROCESSOR_RIOS2,
3cb999d8 352 PROCESSOR_RS64A,
bef84347
VM
353 PROCESSOR_MPCCORE,
354 PROCESSOR_PPC403,
355 PROCESSOR_PPC601,
356 PROCESSOR_PPC603,
357 PROCESSOR_PPC604,
358 PROCESSOR_PPC604e,
359 PROCESSOR_PPC620,
3cb999d8 360 PROCESSOR_PPC630,
bef84347
VM
361 PROCESSOR_PPC750
362};
fb623df5
RK
363
364extern enum processor_type rs6000_cpu;
365
366/* Recast the processor type to the cpu attribute. */
367#define rs6000_cpu_attr ((enum attr_cpu)rs6000_cpu)
368
8482e358 369/* Define generic processor types based upon current deployment. */
3cb999d8
DE
370#define PROCESSOR_COMMON PROCESSOR_PPC601
371#define PROCESSOR_POWER PROCESSOR_RIOS1
372#define PROCESSOR_POWERPC PROCESSOR_PPC604
373#define PROCESSOR_POWERPC64 PROCESSOR_RS64A
6e151478 374
fb623df5 375/* Define the default processor. This is overridden by other tm.h files. */
3cb999d8
DE
376#define PROCESSOR_DEFAULT PROCESSOR_RIOS1
377#define PROCESSOR_DEFAULT64 PROCESSOR_RS64A
fb623df5 378
6febd581
RK
379/* Specify the dialect of assembler to use. New mnemonics is dialect one
380 and the old mnemonics are dialect zero. */
9ebbca7d 381#define ASSEMBLER_DIALECT (TARGET_NEW_MNEMONICS ? 1 : 0)
6febd581 382
fb623df5
RK
383/* This macro is similar to `TARGET_SWITCHES' but defines names of
384 command options that have values. Its definition is an
385 initializer with a subgrouping for each command option.
386
387 Each subgrouping contains a string constant, that defines the
388 fixed part of the option name, and the address of a variable.
389 The variable, type `char *', is set to the variable part of the
390 given option if the fixed part matches. The actual option name
391 is made by appending `-m' to the specified name.
392
393 Here is an example which defines `-mshort-data-NUMBER'. If the
394 given option is `-mshort-data-512', the variable `m88k_short_data'
395 will be set to the string `"512"'.
396
397 extern char *m88k_short_data;
398 #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } } */
399
956d6950 400/* This is meant to be overridden in target specific files. */
b6c9286a 401#define SUBTARGET_OPTIONS
b6c9286a 402
9ebbca7d
GK
403#define TARGET_OPTIONS \
404{ \
047142d3
PT
405 {"cpu=", &rs6000_select[1].string, \
406 N_("Use features of and schedule code for given CPU") }, \
407 {"tune=", &rs6000_select[2].string, \
408 N_("Schedule code for given CPU") }, \
409 {"debug=", &rs6000_debug_name, N_("Enable debug output") }, \
9ebbca7d 410 SUBTARGET_OPTIONS \
b6c9286a 411}
fb623df5 412
ff222560 413/* rs6000_select[0] is reserved for the default cpu defined via --with-cpu */
8e3f41e7
MM
414struct rs6000_cpu_select
415{
815cdc52
MM
416 const char *string;
417 const char *name;
8e3f41e7
MM
418 int set_tune_p;
419 int set_arch_p;
420};
421
422extern struct rs6000_cpu_select rs6000_select[];
fb623df5 423
38c1f2d7 424/* Debug support */
815cdc52 425extern const char *rs6000_debug_name; /* Name for -mdebug-xxxx option */
38c1f2d7
MM
426extern int rs6000_debug_stack; /* debug stack applications */
427extern int rs6000_debug_arg; /* debug argument handling */
428
429#define TARGET_DEBUG_STACK rs6000_debug_stack
430#define TARGET_DEBUG_ARG rs6000_debug_arg
431
fb623df5
RK
432/* Sometimes certain combinations of command options do not make sense
433 on a particular target machine. You can define a macro
434 `OVERRIDE_OPTIONS' to take account of this. This macro, if
435 defined, is executed once just after all the command options have
436 been parsed.
437
5accd822
DE
438 Don't use this macro to turn on various extra optimizations for
439 `-O'. That is what `OPTIMIZATION_OPTIONS' is for.
440
fb623df5
RK
441 On the RS/6000 this is used to define the target cpu type. */
442
8e3f41e7 443#define OVERRIDE_OPTIONS rs6000_override_options (TARGET_CPU_DEFAULT)
f045b2c9 444
5accd822
DE
445/* Define this to change the optimizations performed by default. */
446#define OPTIMIZATION_OPTIONS(LEVEL,SIZE) optimization_options(LEVEL,SIZE)
447
4f074454
RK
448/* Show we can debug even without a frame pointer. */
449#define CAN_DEBUG_WITHOUT_FP
f045b2c9
RS
450\f
451/* target machine storage layout */
452
df44fa77
RK
453/* Define to support cross compilation to an RS6000 target. */
454#define REAL_ARITHMETIC
455
13d39dbc 456/* Define this macro if it is advisable to hold scalars in registers
c81bebd7 457 in a wider mode than that declared by the program. In such cases,
ef457bda
RK
458 the value is constrained to be within the bounds of the declared
459 type, but kept valid in the wider mode. The signedness of the
460 extension may differ from that of the type. */
461
39403d82
DE
462#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
463 if (GET_MODE_CLASS (MODE) == MODE_INT \
464 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
3cb999d8 465 (MODE) = word_mode;
39403d82
DE
466
467/* Define this if function arguments should also be promoted using the above
468 procedure. */
469
470#define PROMOTE_FUNCTION_ARGS
471
472/* Likewise, if the function return value is promoted. */
473
474#define PROMOTE_FUNCTION_RETURN
ef457bda 475
f045b2c9
RS
476/* Define this if most significant bit is lowest numbered
477 in instructions that operate on numbered bit-fields. */
478/* That is true on RS/6000. */
479#define BITS_BIG_ENDIAN 1
480
481/* Define this if most significant byte of a word is the lowest numbered. */
482/* That is true on RS/6000. */
483#define BYTES_BIG_ENDIAN 1
484
485/* Define this if most significant word of a multiword number is lowest
c81bebd7 486 numbered.
f045b2c9
RS
487
488 For RS/6000 we can decide arbitrarily since there are no machine
489 instructions for them. Might as well be consistent with bits and bytes. */
490#define WORDS_BIG_ENDIAN 1
491
fdaff8ba 492/* number of bits in an addressable storage unit */
f045b2c9
RS
493#define BITS_PER_UNIT 8
494
495/* Width in bits of a "word", which is the contents of a machine register.
496 Note that this is not necessarily the width of data type `int';
497 if using 16-bit ints on a 68000, this would still be 32.
498 But on a machine with 16-bit registers, this would be 16. */
2f3e5814 499#define BITS_PER_WORD (! TARGET_POWERPC64 ? 32 : 64)
2e360ab3 500#define MAX_BITS_PER_WORD 64
f045b2c9
RS
501
502/* Width of a word, in units (bytes). */
2f3e5814 503#define UNITS_PER_WORD (! TARGET_POWERPC64 ? 4 : 8)
ef0e53ce 504#define MIN_UNITS_PER_WORD 4
2e360ab3 505#define UNITS_PER_FP_WORD 8
f045b2c9 506
915f619f
JW
507/* Type used for ptrdiff_t, as a string used in a declaration. */
508#define PTRDIFF_TYPE "int"
509
058ef853
DE
510/* Type used for size_t, as a string used in a declaration. */
511#define SIZE_TYPE "long unsigned int"
512
f045b2c9
RS
513/* Type used for wchar_t, as a string used in a declaration. */
514#define WCHAR_TYPE "short unsigned int"
515
516/* Width of wchar_t in bits. */
517#define WCHAR_TYPE_SIZE 16
518
9e654916
RK
519/* A C expression for the size in bits of the type `short' on the
520 target machine. If you don't define this, the default is half a
521 word. (If this would be less than one storage unit, it is
522 rounded up to one unit.) */
523#define SHORT_TYPE_SIZE 16
524
525/* A C expression for the size in bits of the type `int' on the
526 target machine. If you don't define this, the default is one
527 word. */
19d2d16f 528#define INT_TYPE_SIZE 32
9e654916
RK
529
530/* A C expression for the size in bits of the type `long' on the
531 target machine. If you don't define this, the default is one
532 word. */
2f3e5814 533#define LONG_TYPE_SIZE (TARGET_32BIT ? 32 : 64)
9e654916
RK
534#define MAX_LONG_TYPE_SIZE 64
535
536/* A C expression for the size in bits of the type `long long' on the
537 target machine. If you don't define this, the default is two
538 words. */
539#define LONG_LONG_TYPE_SIZE 64
540
541/* A C expression for the size in bits of the type `char' on the
542 target machine. If you don't define this, the default is one
543 quarter of a word. (If this would be less than one storage unit,
544 it is rounded up to one unit.) */
545#define CHAR_TYPE_SIZE BITS_PER_UNIT
546
547/* A C expression for the size in bits of the type `float' on the
548 target machine. If you don't define this, the default is one
549 word. */
550#define FLOAT_TYPE_SIZE 32
551
552/* A C expression for the size in bits of the type `double' on the
553 target machine. If you don't define this, the default is two
554 words. */
555#define DOUBLE_TYPE_SIZE 64
556
557/* A C expression for the size in bits of the type `long double' on
558 the target machine. If you don't define this, the default is two
559 words. */
560#define LONG_DOUBLE_TYPE_SIZE 64
561
f045b2c9
RS
562/* Width in bits of a pointer.
563 See also the macro `Pmode' defined below. */
2f3e5814 564#define POINTER_SIZE (TARGET_32BIT ? 32 : 64)
f045b2c9
RS
565
566/* Allocation boundary (in *bits*) for storing arguments in argument list. */
2f3e5814 567#define PARM_BOUNDARY (TARGET_32BIT ? 32 : 64)
f045b2c9
RS
568
569/* Boundary (in *bits*) on which stack pointer should be aligned. */
a260abc9 570#define STACK_BOUNDARY (TARGET_32BIT ? 64 : 128)
f045b2c9
RS
571
572/* Allocation boundary (in *bits*) for the code of a function. */
573#define FUNCTION_BOUNDARY 32
574
575/* No data type wants to be aligned rounder than this. */
b73fd26c
DE
576#define BIGGEST_ALIGNMENT 64
577
e1565e65
DE
578/* Handle #pragma pack. */
579#define HANDLE_PRAGMA_PACK 1
580
f045b2c9
RS
581/* Alignment of field after `int : 0' in a structure. */
582#define EMPTY_FIELD_BOUNDARY 32
583
584/* Every structure's size must be a multiple of this. */
585#define STRUCTURE_SIZE_BOUNDARY 8
586
587/* A bitfield declared as `int' forces `int' alignment for the struct. */
588#define PCC_BITFIELD_TYPE_MATTERS 1
589
590/* Make strings word-aligned so strcpy from constants will be faster. */
591#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
592 (TREE_CODE (EXP) == STRING_CST \
593 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
594
595/* Make arrays of chars word-aligned for the same reasons. */
596#define DATA_ALIGNMENT(TYPE, ALIGN) \
597 (TREE_CODE (TYPE) == ARRAY_TYPE \
598 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
599 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
600
fdaff8ba 601/* Non-zero if move instructions will actually fail to work
f045b2c9 602 when given unaligned data. */
fdaff8ba 603#define STRICT_ALIGNMENT 0
e1565e65
DE
604
605/* Define this macro to be the value 1 if unaligned accesses have a cost
606 many times greater than aligned accesses, for example if they are
607 emulated in a trap handler. */
608#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) \
9ebbca7d
GK
609 ((STRICT_ALIGNMENT \
610 || (((MODE) == SFmode || (MODE) == DFmode || (MODE) == DImode) \
19caa751 611 && (ALIGN) < 32)) ? 1 : 0)
f045b2c9
RS
612\f
613/* Standard register usage. */
614
615/* Number of actual hardware registers.
616 The hardware registers are assigned numbers for the compiler
617 from 0 to just below FIRST_PSEUDO_REGISTER.
618 All registers that the compiler knows about must be given numbers,
619 even those that are not normally considered general registers.
620
621 RS/6000 has 32 fixed-point registers, 32 floating-point registers,
622 an MQ register, a count register, a link register, and 8 condition
623 register fields, which we view here as separate registers.
624
625 In addition, the difference between the frame and argument pointers is
626 a function of the number of registers saved, so we need to have a
627 register for AP that will later be eliminated in favor of SP or FP.
802a0058 628 This is a normal register, but it is fixed.
f045b2c9 629
802a0058
MM
630 We also create a pseudo register for float/int conversions, that will
631 really represent the memory location used. It is represented here as
632 a register, in order to work around problems in allocating stack storage
633 in inline functions. */
634
635#define FIRST_PSEUDO_REGISTER 77
f045b2c9 636
62153b61
JM
637/* This must not decrease, for backwards compatibility. If
638 FIRST_PSEUDO_REGISTER increases, this should as well. */
639#define DWARF_FRAME_REGISTERS 77
640
f045b2c9
RS
641/* 1 for registers that have pervasive standard uses
642 and are not available for the register allocator.
643
c81bebd7 644 On RS/6000, r1 is used for the stack and r2 is used as the TOC pointer.
f045b2c9 645
a127c4e5
RK
646 cr5 is not supposed to be used.
647
648 On System V implementations, r13 is fixed and not available for use. */
649
f045b2c9 650#define FIXED_REGISTERS \
a127c4e5 651 {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_R13, 0, 0, \
f045b2c9
RS
652 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
653 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
802a0058 655 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1}
f045b2c9
RS
656
657/* 1 for registers not available across function calls.
658 These must include the FIXED_REGISTERS and also any
659 registers that can be used without being saved.
660 The latter must include the registers where values are returned
661 and the register where structure-value addresses are passed.
662 Aside from that, you can include as many other registers as you like. */
663
664#define CALL_USED_REGISTERS \
a127c4e5 665 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, FIXED_R13, 0, 0, \
f045b2c9
RS
666 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
667 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \
668 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
802a0058 669 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1}
f045b2c9 670
9ebbca7d
GK
671#define MQ_REGNO 64
672#define CR0_REGNO 68
673#define CR1_REGNO 69
674#define CR2_REGNO 70
675#define CR3_REGNO 71
676#define CR4_REGNO 72
677#define MAX_CR_REGNO 75
678#define XER_REGNO 76
679
f045b2c9
RS
680/* List the order in which to allocate registers. Each register must be
681 listed once, even those in FIXED_REGISTERS.
682
683 We allocate in the following order:
684 fp0 (not saved or used for anything)
685 fp13 - fp2 (not saved; incoming fp arg registers)
686 fp1 (not saved; return value)
687 fp31 - fp14 (saved; order given to save least number)
5accd822
DE
688 cr7, cr6 (not saved or special)
689 cr1 (not saved, but used for FP operations)
f045b2c9 690 cr0 (not saved, but used for arithmetic operations)
5accd822 691 cr4, cr3, cr2 (saved)
f045b2c9
RS
692 r0 (not saved; cannot be base reg)
693 r9 (not saved; best for TImode)
694 r11, r10, r8-r4 (not saved; highest used first to make less conflict)
695 r3 (not saved; return value register)
696 r31 - r13 (saved; order given to save least number)
697 r12 (not saved; if used for DImode or DFmode would use r13)
698 mq (not saved; best to use it if we can)
699 ctr (not saved; when we have the choice ctr is better)
700 lr (saved)
9ebbca7d 701 cr5, r1, r2, ap, xer (fixed) */
f045b2c9
RS
702
703#define REG_ALLOC_ORDER \
704 {32, \
705 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, \
706 33, \
707 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, \
708 50, 49, 48, 47, 46, \
5accd822 709 75, 74, 69, 68, 72, 71, 70, \
f045b2c9
RS
710 0, \
711 9, 11, 10, 8, 7, 6, 5, 4, \
712 3, \
713 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \
714 18, 17, 16, 15, 14, 13, 12, \
715 64, 66, 65, \
802a0058 716 73, 1, 2, 67, 76}
f045b2c9
RS
717
718/* True if register is floating-point. */
719#define FP_REGNO_P(N) ((N) >= 32 && (N) <= 63)
720
721/* True if register is a condition register. */
722#define CR_REGNO_P(N) ((N) >= 68 && (N) <= 75)
723
815cdc52
MM
724/* True if register is a condition register, but not cr0. */
725#define CR_REGNO_NOT_CR0_P(N) ((N) >= 69 && (N) <= 75)
726
f045b2c9 727/* True if register is an integer register. */
9ebbca7d 728#define INT_REGNO_P(N) ((N) <= 31 || (N) == ARG_POINTER_REGNUM)
f045b2c9 729
0d86f538 730/* True if register is the XER register. */
9ebbca7d 731#define XER_REGNO_P(N) ((N) == XER_REGNO)
802a0058 732
f045b2c9
RS
733/* Return number of consecutive hard regs needed starting at reg REGNO
734 to hold something of mode MODE.
735 This is ordinarily the length in words of a value of mode MODE
736 but can be less for certain modes in special long registers.
737
a260abc9
DE
738 POWER and PowerPC GPRs hold 32 bits worth;
739 PowerPC64 GPRs and FPRs point register holds 64 bits worth. */
f045b2c9 740
802a0058 741#define HARD_REGNO_NREGS(REGNO, MODE) \
9ebbca7d 742 (FP_REGNO_P (REGNO) \
2e360ab3 743 ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \
f045b2c9
RS
744 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
745
746/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
bdfd4e31
RK
747 For POWER and PowerPC, the GPRs can hold any mode, but the float
748 registers only can hold floating modes and DImode, and CR register only
749 can hold CC modes. We cannot put TImode anywhere except general
750 register and it must be able to fit within the register set. */
f045b2c9 751
802a0058
MM
752#define HARD_REGNO_MODE_OK(REGNO, MODE) \
753 (FP_REGNO_P (REGNO) ? \
754 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
755 || (GET_MODE_CLASS (MODE) == MODE_INT \
756 && GET_MODE_SIZE (MODE) == UNITS_PER_FP_WORD)) \
757 : CR_REGNO_P (REGNO) ? GET_MODE_CLASS (MODE) == MODE_CC \
9ebbca7d 758 : XER_REGNO_P (REGNO) ? (MODE) == PSImode \
802a0058 759 : ! INT_REGNO_P (REGNO) ? (GET_MODE_CLASS (MODE) == MODE_INT \
bdfd4e31 760 && GET_MODE_SIZE (MODE) <= UNITS_PER_WORD) \
f045b2c9
RS
761 : 1)
762
763/* Value is 1 if it is a good idea to tie two pseudo registers
764 when one has mode MODE1 and one has mode MODE2.
765 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
766 for any hard reg, then this must be 0 for correct output. */
767#define MODES_TIEABLE_P(MODE1, MODE2) \
768 (GET_MODE_CLASS (MODE1) == MODE_FLOAT \
769 ? GET_MODE_CLASS (MODE2) == MODE_FLOAT \
770 : GET_MODE_CLASS (MODE2) == MODE_FLOAT \
771 ? GET_MODE_CLASS (MODE1) == MODE_FLOAT \
772 : GET_MODE_CLASS (MODE1) == MODE_CC \
773 ? GET_MODE_CLASS (MODE2) == MODE_CC \
774 : GET_MODE_CLASS (MODE2) == MODE_CC \
775 ? GET_MODE_CLASS (MODE1) == MODE_CC \
776 : 1)
777
778/* A C expression returning the cost of moving data from a register of class
779 CLASS1 to one of CLASS2.
780
781 On the RS/6000, copying between floating-point and fixed-point
782 registers is expensive. */
783
cf011243 784#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
2bfcf297 785 ((CLASS1) == FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 2 \
f045b2c9
RS
786 : (CLASS1) == FLOAT_REGS && (CLASS2) != FLOAT_REGS ? 10 \
787 : (CLASS1) != FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 10 \
a4b970a0 788 : (((CLASS1) == SPECIAL_REGS || (CLASS1) == MQ_REGS \
5119dc13
RK
789 || (CLASS1) == LINK_REGS || (CLASS1) == CTR_REGS \
790 || (CLASS1) == LINK_OR_CTR_REGS) \
a4b970a0 791 && ((CLASS2) == SPECIAL_REGS || (CLASS2) == MQ_REGS \
5119dc13 792 || (CLASS2) == LINK_REGS || (CLASS2) == CTR_REGS \
802a0058 793 || (CLASS2) == LINK_OR_CTR_REGS)) ? 10 \
f045b2c9
RS
794 : 2)
795
796/* A C expressions returning the cost of moving data of MODE from a register to
797 or from memory.
798
799 On the RS/6000, bump this up a bit. */
800
e1565e65
DE
801#define MEMORY_MOVE_COST(MODE, CLASS, IN) \
802 ((GET_MODE_CLASS (MODE) == MODE_FLOAT \
ab4a5fc9
RK
803 && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \
804 ? 3 : 2) \
805 + 4)
f045b2c9
RS
806
807/* Specify the cost of a branch insn; roughly the number of extra insns that
808 should be added to avoid a branch.
809
ef457bda 810 Set this to 3 on the RS/6000 since that is roughly the average cost of an
f045b2c9
RS
811 unscheduled conditional branch. */
812
ef457bda 813#define BRANCH_COST 3
f045b2c9 814
6febd581
RK
815/* Define this macro to change register usage conditional on target flags.
816 Set MQ register fixed (already call_used) if not POWER architecture
f85f4585 817 (RIOS1, RIOS2, RSC, and PPC601) so that it will not be allocated.
a238cd8b 818 64-bit AIX reserves GPR13 for thread-private data.
f85f4585
RK
819 Conditionally disable FPRs. */
820
8d30c4ee
FS
821#define CONDITIONAL_REGISTER_USAGE \
822{ \
e9e4208a 823 int i; \
8d30c4ee
FS
824 if (! TARGET_POWER) \
825 fixed_regs[64] = 1; \
826 if (TARGET_64BIT) \
827 fixed_regs[13] = call_used_regs[13] = 1; \
828 if (TARGET_SOFT_FLOAT) \
829 for (i = 32; i < 64; i++) \
830 fixed_regs[i] = call_used_regs[i] = 1; \
831 if ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) \
832 && flag_pic == 1) \
833 fixed_regs[PIC_OFFSET_TABLE_REGNUM] \
834 = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
ee890fe2
SS
835 if (DEFAULT_ABI == ABI_DARWIN && flag_pic) \
836 global_regs[PIC_OFFSET_TABLE_REGNUM] \
837 = fixed_regs[PIC_OFFSET_TABLE_REGNUM] \
838 = call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
f85f4585 839}
6febd581 840
f045b2c9
RS
841/* Specify the registers used for certain standard purposes.
842 The values of these macros are register numbers. */
843
844/* RS/6000 pc isn't overloaded on a register that the compiler knows about. */
845/* #define PC_REGNUM */
846
847/* Register to use for pushing function arguments. */
848#define STACK_POINTER_REGNUM 1
849
850/* Base register for access to local variables of the function. */
851#define FRAME_POINTER_REGNUM 31
852
853/* Value should be nonzero if functions must have frame pointers.
854 Zero means the frame pointer need not be set up (and parms
855 may be accessed via the stack pointer) in functions that seem suitable.
856 This is computed in `reload', in reload1.c. */
857#define FRAME_POINTER_REQUIRED 0
858
859/* Base register for access to arguments of the function. */
860#define ARG_POINTER_REGNUM 67
861
862/* Place to put static chain when calling a function that requires it. */
863#define STATIC_CHAIN_REGNUM 11
864
9ebbca7d
GK
865/* Link register number. */
866#define LINK_REGISTER_REGNUM 65
b6c9286a 867
9ebbca7d
GK
868/* Count register number. */
869#define COUNT_REGISTER_REGNUM 66
802a0058 870
f045b2c9
RS
871/* Place that structure value return address is placed.
872
873 On the RS/6000, it is passed as an extra parameter. */
1ff7789b 874#define STRUCT_VALUE 0
f045b2c9
RS
875\f
876/* Define the classes of registers for register constraints in the
877 machine description. Also define ranges of constants.
878
879 One of the classes must always be named ALL_REGS and include all hard regs.
880 If there is more than one class, another class must be named NO_REGS
881 and contain no registers.
882
883 The name GENERAL_REGS must be the name of a class (or an alias for
884 another name such as ALL_REGS). This is the class of registers
885 that is allowed by "g" or "r" in a register constraint.
886 Also, registers outside this class are allocated only when
887 instructions express preferences for them.
888
889 The classes must be numbered in nondecreasing order; that is,
890 a larger-numbered class must never be contained completely
891 in a smaller-numbered class.
892
893 For any two classes, it is very desirable that there be another
894 class that represents their union. */
c81bebd7 895
f045b2c9
RS
896/* The RS/6000 has three types of registers, fixed-point, floating-point,
897 and condition registers, plus three special registers, MQ, CTR, and the
898 link register.
899
900 However, r0 is special in that it cannot be used as a base register.
901 So make a class for registers valid as base registers.
902
903 Also, cr0 is the only condition code register that can be used in
0d86f538 904 arithmetic insns, so make a separate class for it. */
f045b2c9 905
ebedb4dd
MM
906enum reg_class
907{
908 NO_REGS,
ebedb4dd
MM
909 BASE_REGS,
910 GENERAL_REGS,
911 FLOAT_REGS,
912 NON_SPECIAL_REGS,
913 MQ_REGS,
914 LINK_REGS,
915 CTR_REGS,
916 LINK_OR_CTR_REGS,
917 SPECIAL_REGS,
918 SPEC_OR_GEN_REGS,
919 CR0_REGS,
ebedb4dd
MM
920 CR_REGS,
921 NON_FLOAT_REGS,
9ebbca7d 922 XER_REGS,
ebedb4dd
MM
923 ALL_REGS,
924 LIM_REG_CLASSES
925};
f045b2c9
RS
926
927#define N_REG_CLASSES (int) LIM_REG_CLASSES
928
929/* Give names of register classes as strings for dump file. */
930
ebedb4dd
MM
931#define REG_CLASS_NAMES \
932{ \
933 "NO_REGS", \
ebedb4dd
MM
934 "BASE_REGS", \
935 "GENERAL_REGS", \
936 "FLOAT_REGS", \
937 "NON_SPECIAL_REGS", \
938 "MQ_REGS", \
939 "LINK_REGS", \
940 "CTR_REGS", \
941 "LINK_OR_CTR_REGS", \
942 "SPECIAL_REGS", \
943 "SPEC_OR_GEN_REGS", \
944 "CR0_REGS", \
ebedb4dd
MM
945 "CR_REGS", \
946 "NON_FLOAT_REGS", \
9ebbca7d 947 "XER_REGS", \
ebedb4dd
MM
948 "ALL_REGS" \
949}
f045b2c9
RS
950
951/* Define which registers fit in which classes.
952 This is an initializer for a vector of HARD_REG_SET
953 of length N_REG_CLASSES. */
954
ebedb4dd
MM
955#define REG_CLASS_CONTENTS \
956{ \
957 { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
ebedb4dd
MM
958 { 0xfffffffe, 0x00000000, 0x00000008 }, /* BASE_REGS */ \
959 { 0xffffffff, 0x00000000, 0x00000008 }, /* GENERAL_REGS */ \
960 { 0x00000000, 0xffffffff, 0x00000000 }, /* FLOAT_REGS */ \
961 { 0xffffffff, 0xffffffff, 0x00000008 }, /* NON_SPECIAL_REGS */ \
962 { 0x00000000, 0x00000000, 0x00000001 }, /* MQ_REGS */ \
963 { 0x00000000, 0x00000000, 0x00000002 }, /* LINK_REGS */ \
964 { 0x00000000, 0x00000000, 0x00000004 }, /* CTR_REGS */ \
965 { 0x00000000, 0x00000000, 0x00000006 }, /* LINK_OR_CTR_REGS */ \
966 { 0x00000000, 0x00000000, 0x00000007 }, /* SPECIAL_REGS */ \
967 { 0xffffffff, 0x00000000, 0x0000000f }, /* SPEC_OR_GEN_REGS */ \
968 { 0x00000000, 0x00000000, 0x00000010 }, /* CR0_REGS */ \
ebedb4dd
MM
969 { 0x00000000, 0x00000000, 0x00000ff0 }, /* CR_REGS */ \
970 { 0xffffffff, 0x00000000, 0x0000ffff }, /* NON_FLOAT_REGS */ \
9ebbca7d 971 { 0x00000000, 0x00000000, 0x00010000 }, /* XER_REGS */ \
802a0058 972 { 0xffffffff, 0xffffffff, 0x0001ffff } /* ALL_REGS */ \
ebedb4dd 973}
f045b2c9
RS
974
975/* The same information, inverted:
976 Return the class number of the smallest class containing
977 reg number REGNO. This could be a conditional expression
978 or could index an array. */
979
0d86f538
GK
980#define REGNO_REG_CLASS(REGNO) \
981 ((REGNO) == 0 ? GENERAL_REGS \
982 : (REGNO) < 32 ? BASE_REGS \
983 : FP_REGNO_P (REGNO) ? FLOAT_REGS \
984 : (REGNO) == CR0_REGNO ? CR0_REGS \
985 : CR_REGNO_P (REGNO) ? CR_REGS \
986 : (REGNO) == MQ_REGNO ? MQ_REGS \
987 : (REGNO) == LINK_REGISTER_REGNUM ? LINK_REGS \
988 : (REGNO) == COUNT_REGISTER_REGNUM ? CTR_REGS \
989 : (REGNO) == ARG_POINTER_REGNUM ? BASE_REGS \
990 : (REGNO) == XER_REGNO ? XER_REGS \
f045b2c9
RS
991 : NO_REGS)
992
993/* The class value for index registers, and the one for base regs. */
994#define INDEX_REG_CLASS GENERAL_REGS
995#define BASE_REG_CLASS BASE_REGS
996
997/* Get reg_class from a letter such as appears in the machine description. */
998
999#define REG_CLASS_FROM_LETTER(C) \
1000 ((C) == 'f' ? FLOAT_REGS \
1001 : (C) == 'b' ? BASE_REGS \
1002 : (C) == 'h' ? SPECIAL_REGS \
1003 : (C) == 'q' ? MQ_REGS \
1004 : (C) == 'c' ? CTR_REGS \
1005 : (C) == 'l' ? LINK_REGS \
1006 : (C) == 'x' ? CR0_REGS \
1007 : (C) == 'y' ? CR_REGS \
9ebbca7d 1008 : (C) == 'z' ? XER_REGS \
f045b2c9
RS
1009 : NO_REGS)
1010
1011/* The letters I, J, K, L, M, N, and P in a register constraint string
1012 can be used to stand for particular ranges of immediate operands.
1013 This macro defines what the ranges are.
1014 C is the letter, and VALUE is a constant value.
1015 Return 1 if VALUE is in the range specified by C.
1016
9615f239 1017 `I' is a signed 16-bit constant
f045b2c9
RS
1018 `J' is a constant with only the high-order 16 bits non-zero
1019 `K' is a constant with only the low-order 16 bits non-zero
9615f239 1020 `L' is a signed 16-bit constant shifted left 16 bits
f045b2c9 1021 `M' is a constant that is greater than 31
2bfcf297 1022 `N' is a positive constant that is an exact power of two
f045b2c9
RS
1023 `O' is the constant zero
1024 `P' is a constant whose negation is a signed 16-bit constant */
1025
5b6f7b96
RK
1026#define CONST_OK_FOR_LETTER_P(VALUE, C) \
1027 ( (C) == 'I' ? (unsigned HOST_WIDE_INT) ((VALUE) + 0x8000) < 0x10000 \
0858c623 1028 : (C) == 'J' ? ((VALUE) & (~ (unsigned HOST_WIDE_INT) 0xffff0000)) == 0 \
a260abc9 1029 : (C) == 'K' ? ((VALUE) & (~ (HOST_WIDE_INT) 0xffff)) == 0 \
9615f239
DE
1030 : (C) == 'L' ? (((VALUE) & 0xffff) == 0 \
1031 && ((VALUE) >> 31 == -1 || (VALUE) >> 31 == 0)) \
5b6f7b96 1032 : (C) == 'M' ? (VALUE) > 31 \
2bfcf297 1033 : (C) == 'N' ? (VALUE) > 0 && exact_log2 (VALUE) >= 0 \
5b6f7b96 1034 : (C) == 'O' ? (VALUE) == 0 \
9615f239 1035 : (C) == 'P' ? (unsigned HOST_WIDE_INT) ((- (VALUE)) + 0x8000) < 0x10000 \
f045b2c9
RS
1036 : 0)
1037
1038/* Similar, but for floating constants, and defining letters G and H.
1039 Here VALUE is the CONST_DOUBLE rtx itself.
1040
1041 We flag for special constants when we can copy the constant into
4e74d8ec 1042 a general register in two insns for DF/DI and one insn for SF.
f045b2c9 1043
c4c40373 1044 'H' is used for DI/DF constants that take 3 insns. */
4e74d8ec
MM
1045
1046#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
c4c40373
MM
1047 ( (C) == 'G' ? (num_insns_constant (VALUE, GET_MODE (VALUE)) \
1048 == ((GET_MODE (VALUE) == SFmode) ? 1 : 2)) \
1049 : (C) == 'H' ? (num_insns_constant (VALUE, GET_MODE (VALUE)) == 3) \
1050 : 0)
f045b2c9
RS
1051
1052/* Optional extra constraints for this machine.
1053
b6c9286a
MM
1054 'Q' means that is a memory operand that is just an offset from a reg.
1055 'R' is for AIX TOC entries.
a260abc9 1056 'S' is a constant that can be placed into a 64-bit mask operand
9615f239 1057 'T' is a consatnt that can be placed into a 32-bit mask operand
88228c4b 1058 'U' is for V.4 small data references. */
f045b2c9 1059
e8a8bc24
RK
1060#define EXTRA_CONSTRAINT(OP, C) \
1061 ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \
d537c24d 1062 : (C) == 'R' ? LEGITIMATE_CONSTANT_POOL_ADDRESS_P (OP) \
a260abc9 1063 : (C) == 'S' ? mask64_operand (OP, VOIDmode) \
9615f239 1064 : (C) == 'T' ? mask_operand (OP, VOIDmode) \
c81bebd7
MM
1065 : (C) == 'U' ? ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) \
1066 && small_data_operand (OP, GET_MODE (OP))) \
e8a8bc24 1067 : 0)
f045b2c9
RS
1068
1069/* Given an rtx X being reloaded into a reg required to be
1070 in class CLASS, return the class of reg to actually use.
1071 In general this is just CLASS; but on some machines
c81bebd7 1072 in some cases it is preferable to use a more restrictive class.
f045b2c9
RS
1073
1074 On the RS/6000, we have to return NO_REGS when we want to reload a
1e66d555
GK
1075 floating-point CONST_DOUBLE to force it to be copied to memory.
1076
1077 We also don't want to reload integer values into floating-point
1078 registers if we can at all help it. In fact, this can
1079 cause reload to abort, if it tries to generate a reload of CTR
1080 into a FP register and discovers it doesn't have the memory location
1081 required.
1082
1083 ??? Would it be a good idea to have reload do the converse, that is
1084 try to reload floating modes into FP registers if possible?
1085 */
f045b2c9 1086
802a0058 1087#define PREFERRED_RELOAD_CLASS(X,CLASS) \
1e66d555
GK
1088 (((GET_CODE (X) == CONST_DOUBLE \
1089 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
1090 ? NO_REGS \
1091 : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT \
1092 && (CLASS) == NON_SPECIAL_REGS) \
1093 ? GENERAL_REGS \
1094 : (CLASS)))
c81bebd7 1095
f045b2c9
RS
1096/* Return the register class of a scratch register needed to copy IN into
1097 or out of a register in CLASS in MODE. If it can be done directly,
1098 NO_REGS is returned. */
1099
1100#define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \
1101 secondary_reload_class (CLASS, MODE, IN)
1102
7ea555a4
RK
1103/* If we are copying between FP registers and anything else, we need a memory
1104 location. */
1105
1106#define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \
1107 ((CLASS1) != (CLASS2) && ((CLASS1) == FLOAT_REGS || (CLASS2) == FLOAT_REGS))
1108
f045b2c9
RS
1109/* Return the maximum number of consecutive registers
1110 needed to represent mode MODE in a register of class CLASS.
1111
1112 On RS/6000, this is the size of MODE in words,
1113 except in the FP regs, where a single reg is enough for two words. */
802a0058 1114#define CLASS_MAX_NREGS(CLASS, MODE) \
9ebbca7d 1115 (((CLASS) == FLOAT_REGS) \
2e360ab3 1116 ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \
f045b2c9 1117 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
580d3230
RK
1118
1119/* If defined, gives a class of registers that cannot be used as the
02188693 1120 operand of a SUBREG that changes the mode of the object illegally. */
580d3230 1121
02188693
RH
1122#define CLASS_CANNOT_CHANGE_MODE FLOAT_REGS
1123
1124/* Defines illegal mode changes for CLASS_CANNOT_CHANGE_MODE. */
1125
1126#define CLASS_CANNOT_CHANGE_MODE_P(FROM,TO) \
1127 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO))
f045b2c9
RS
1128\f
1129/* Stack layout; function entry, exit and calling. */
1130
6b67933e
RK
1131/* Enumeration to give which calling sequence to use. */
1132enum rs6000_abi {
1133 ABI_NONE,
1134 ABI_AIX, /* IBM's AIX */
b6c9286a
MM
1135 ABI_AIX_NODESC, /* AIX calling sequence minus function descriptors */
1136 ABI_V4, /* System V.4/eabi */
ee890fe2
SS
1137 ABI_SOLARIS, /* Solaris */
1138 ABI_DARWIN /* Apple's Darwin (OS X kernel) */
6b67933e
RK
1139};
1140
b6c9286a
MM
1141extern enum rs6000_abi rs6000_current_abi; /* available for use by subtarget */
1142
4697a36c
MM
1143/* Structure used to define the rs6000 stack */
1144typedef struct rs6000_stack {
1145 int first_gp_reg_save; /* first callee saved GP register used */
1146 int first_fp_reg_save; /* first callee saved FP register used */
1147 int lr_save_p; /* true if the link reg needs to be saved */
1148 int cr_save_p; /* true if the CR reg needs to be saved */
b6c9286a 1149 int toc_save_p; /* true if the TOC needs to be saved */
4697a36c
MM
1150 int push_p; /* true if we need to allocate stack space */
1151 int calls_p; /* true if the function makes any calls */
6b67933e 1152 enum rs6000_abi abi; /* which ABI to use */
abc95ed3
RK
1153 int gp_save_offset; /* offset to save GP regs from initial SP */
1154 int fp_save_offset; /* offset to save FP regs from initial SP */
4697a36c
MM
1155 int lr_save_offset; /* offset to save LR from initial SP */
1156 int cr_save_offset; /* offset to save CR from initial SP */
b6c9286a 1157 int toc_save_offset; /* offset to save the TOC pointer */
4697a36c 1158 int varargs_save_offset; /* offset to save the varargs registers */
83720594 1159 int ehrd_offset; /* offset to EH return data */
4697a36c
MM
1160 int reg_size; /* register size (4 or 8) */
1161 int varargs_size; /* size to hold V.4 args passed in regs */
1162 int vars_size; /* variable save area size */
1163 int parm_size; /* outgoing parameter size */
1164 int save_size; /* save area size */
1165 int fixed_size; /* fixed size of stack frame */
1166 int gp_size; /* size of saved GP registers */
1167 int fp_size; /* size of saved FP registers */
1168 int cr_size; /* size to hold CR if not in save_size */
b6c9286a
MM
1169 int lr_size; /* size to hold LR if not in save_size */
1170 int toc_size; /* size to hold TOC if not in save_size */
4697a36c
MM
1171 int total_size; /* total bytes allocated for stack */
1172} rs6000_stack_t;
1173
f045b2c9
RS
1174/* Define this if pushing a word on the stack
1175 makes the stack pointer a smaller address. */
1176#define STACK_GROWS_DOWNWARD
1177
1178/* Define this if the nominal address of the stack frame
1179 is at the high-address end of the local variables;
1180 that is, each additional local variable allocated
1181 goes at a more negative offset in the frame.
1182
1183 On the RS/6000, we grow upwards, from the area after the outgoing
1184 arguments. */
1185/* #define FRAME_GROWS_DOWNWARD */
1186
4697a36c 1187/* Size of the outgoing register save area */
9ebbca7d 1188#define RS6000_REG_SAVE ((DEFAULT_ABI == ABI_AIX \
ee890fe2
SS
1189 || DEFAULT_ABI == ABI_AIX_NODESC \
1190 || DEFAULT_ABI == ABI_DARWIN) \
9ebbca7d
GK
1191 ? (TARGET_64BIT ? 64 : 32) \
1192 : 0)
4697a36c
MM
1193
1194/* Size of the fixed area on the stack */
9ebbca7d 1195#define RS6000_SAVE_AREA \
ee890fe2 1196 (((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_DARWIN) ? 24 : 8) \
9ebbca7d 1197 << (TARGET_64BIT ? 1 : 0))
4697a36c 1198
97f6e72f
DE
1199/* MEM representing address to save the TOC register */
1200#define RS6000_SAVE_TOC gen_rtx_MEM (Pmode, \
1201 plus_constant (stack_pointer_rtx, \
1202 (TARGET_32BIT ? 20 : 40)))
b6c9286a 1203
4697a36c
MM
1204/* Size of the V.4 varargs area if needed */
1205#define RS6000_VARARGS_AREA 0
1206
4697a36c 1207/* Align an address */
ed33106f 1208#define RS6000_ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1))
4697a36c
MM
1209
1210/* Size of V.4 varargs area in bytes */
1211#define RS6000_VARARGS_SIZE \
2f3e5814 1212 ((GP_ARG_NUM_REG * (TARGET_32BIT ? 4 : 8)) + (FP_ARG_NUM_REG * 8) + 8)
4697a36c 1213
f045b2c9
RS
1214/* Offset within stack frame to start allocating local variables at.
1215 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1216 first local allocated. Otherwise, it is the offset to the BEGINNING
c81bebd7 1217 of the first local allocated.
f045b2c9
RS
1218
1219 On the RS/6000, the frame pointer is the same as the stack pointer,
1220 except for dynamic allocations. So we start after the fixed area and
1221 outgoing parameter area. */
1222
802a0058 1223#define STARTING_FRAME_OFFSET \
ed33106f 1224 (RS6000_ALIGN (current_function_outgoing_args_size, 8) \
802a0058
MM
1225 + RS6000_VARARGS_AREA \
1226 + RS6000_SAVE_AREA)
1227
1228/* Offset from the stack pointer register to an item dynamically
1229 allocated on the stack, e.g., by `alloca'.
1230
1231 The default value for this macro is `STACK_POINTER_OFFSET' plus the
1232 length of the outgoing arguments. The default is correct for most
1233 machines. See `function.c' for details. */
1234#define STACK_DYNAMIC_OFFSET(FUNDECL) \
ed33106f 1235 (RS6000_ALIGN (current_function_outgoing_args_size, 8) \
802a0058 1236 + (STACK_POINTER_OFFSET))
f045b2c9
RS
1237
1238/* If we generate an insn to push BYTES bytes,
1239 this says how many the stack pointer really advances by.
1240 On RS/6000, don't define this because there are no push insns. */
1241/* #define PUSH_ROUNDING(BYTES) */
1242
1243/* Offset of first parameter from the argument pointer register value.
1244 On the RS/6000, we define the argument pointer to the start of the fixed
1245 area. */
4697a36c 1246#define FIRST_PARM_OFFSET(FNDECL) RS6000_SAVE_AREA
f045b2c9 1247
62153b61
JM
1248/* Offset from the argument pointer register value to the top of
1249 stack. This is different from FIRST_PARM_OFFSET because of the
1250 register save area. */
1251#define ARG_POINTER_CFA_OFFSET(FNDECL) 0
1252
f045b2c9
RS
1253/* Define this if stack space is still allocated for a parameter passed
1254 in a register. The value is the number of bytes allocated to this
1255 area. */
4697a36c 1256#define REG_PARM_STACK_SPACE(FNDECL) RS6000_REG_SAVE
f045b2c9
RS
1257
1258/* Define this if the above stack space is to be considered part of the
1259 space allocated by the caller. */
1260#define OUTGOING_REG_PARM_STACK_SPACE
1261
1262/* This is the difference between the logical top of stack and the actual sp.
1263
1264 For the RS/6000, sp points past the fixed area. */
4697a36c 1265#define STACK_POINTER_OFFSET RS6000_SAVE_AREA
f045b2c9
RS
1266
1267/* Define this if the maximum size of all the outgoing args is to be
1268 accumulated and pushed during the prologue. The amount can be
1269 found in the variable current_function_outgoing_args_size. */
f73ad30e 1270#define ACCUMULATE_OUTGOING_ARGS 1
f045b2c9
RS
1271
1272/* Value is the number of bytes of arguments automatically
1273 popped when returning from a subroutine call.
8b109b37 1274 FUNDECL is the declaration node of the function (as a tree),
f045b2c9
RS
1275 FUNTYPE is the data type of the function (as a tree),
1276 or for a library call it is an identifier node for the subroutine name.
1277 SIZE is the number of bytes of arguments passed on the stack. */
1278
8b109b37 1279#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
f045b2c9
RS
1280
1281/* Define how to find the value returned by a function.
1282 VALTYPE is the data type of the value (as a tree).
1283 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1284 otherwise, FUNC is 0.
1285
c81bebd7 1286 On RS/6000 an integer value is in r3 and a floating-point value is in
d14a6d05 1287 fp1, unless -msoft-float. */
f045b2c9 1288
39403d82
DE
1289#define FUNCTION_VALUE(VALTYPE, FUNC) \
1290 gen_rtx_REG ((INTEGRAL_TYPE_P (VALTYPE) \
1291 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
1292 || POINTER_TYPE_P (VALTYPE) \
1293 ? word_mode : TYPE_MODE (VALTYPE), \
1294 TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_HARD_FLOAT ? 33 : 3)
f045b2c9
RS
1295
1296/* Define how to find the value returned by a library function
1297 assuming the value has mode MODE. */
1298
1299#define LIBCALL_VALUE(MODE) \
c5c76735
JL
1300 gen_rtx_REG (MODE, (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1301 && TARGET_HARD_FLOAT ? 33 : 3))
f045b2c9
RS
1302
1303/* The definition of this macro implies that there are cases where
1304 a scalar value cannot be returned in registers.
1305
c81bebd7
MM
1306 For the RS/6000, any structure or union type is returned in memory, except for
1307 Solaris, which returns structures <= 8 bytes in registers. */
f045b2c9 1308
c81bebd7
MM
1309#define RETURN_IN_MEMORY(TYPE) \
1310 (TYPE_MODE (TYPE) == BLKmode \
1311 && (DEFAULT_ABI != ABI_SOLARIS || int_size_in_bytes (TYPE) > 8))
f045b2c9 1312
a260abc9 1313/* Mode of stack savearea.
dfdfa60f
DE
1314 FUNCTION is VOIDmode because calling convention maintains SP.
1315 BLOCK needs Pmode for SP.
a260abc9
DE
1316 NONLOCAL needs twice Pmode to maintain both backchain and SP. */
1317#define STACK_SAVEAREA_MODE(LEVEL) \
dfdfa60f
DE
1318 (LEVEL == SAVE_FUNCTION ? VOIDmode \
1319 : LEVEL == SAVE_NONLOCAL ? (TARGET_32BIT ? DImode : TImode) : Pmode)
a260abc9 1320
4697a36c
MM
1321/* Minimum and maximum general purpose registers used to hold arguments. */
1322#define GP_ARG_MIN_REG 3
1323#define GP_ARG_MAX_REG 10
1324#define GP_ARG_NUM_REG (GP_ARG_MAX_REG - GP_ARG_MIN_REG + 1)
1325
1326/* Minimum and maximum floating point registers used to hold arguments. */
1327#define FP_ARG_MIN_REG 33
7509c759
MM
1328#define FP_ARG_AIX_MAX_REG 45
1329#define FP_ARG_V4_MAX_REG 40
9ebbca7d 1330#define FP_ARG_MAX_REG ((DEFAULT_ABI == ABI_AIX \
ee890fe2
SS
1331 || DEFAULT_ABI == ABI_AIX_NODESC \
1332 || DEFAULT_ABI == ABI_DARWIN) \
9ebbca7d 1333 ? FP_ARG_AIX_MAX_REG : FP_ARG_V4_MAX_REG)
4697a36c
MM
1334#define FP_ARG_NUM_REG (FP_ARG_MAX_REG - FP_ARG_MIN_REG + 1)
1335
1336/* Return registers */
1337#define GP_ARG_RETURN GP_ARG_MIN_REG
1338#define FP_ARG_RETURN FP_ARG_MIN_REG
1339
7509c759 1340/* Flags for the call/call_value rtl operations set up by function_arg */
6a4cee5f 1341#define CALL_NORMAL 0x00000000 /* no special processing */
9ebbca7d 1342/* Bits in 0x00000001 are unused. */
6a4cee5f
MM
1343#define CALL_V4_CLEAR_FP_ARGS 0x00000002 /* V.4, no FP args passed */
1344#define CALL_V4_SET_FP_ARGS 0x00000004 /* V.4, FP args were passed */
1345#define CALL_LONG 0x00000008 /* always call indirect */
7509c759 1346
f045b2c9
RS
1347/* 1 if N is a possible register number for a function value
1348 as seen by the caller.
1349
1350 On RS/6000, this is r3 and fp1. */
4697a36c 1351#define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_ARG_RETURN || ((N) == FP_ARG_RETURN))
f045b2c9
RS
1352
1353/* 1 if N is a possible register number for function argument passing.
1354 On RS/6000, these are r3-r10 and fp1-fp13. */
4697a36c 1355#define FUNCTION_ARG_REGNO_P(N) \
6d0f55e6
DB
1356 ((unsigned)(((N) - GP_ARG_MIN_REG) < (unsigned)(GP_ARG_NUM_REG)) \
1357 || ((unsigned)((N) - FP_ARG_MIN_REG) < (unsigned)(FP_ARG_NUM_REG)))
f045b2c9 1358
f045b2c9 1359\f
00dba523
NC
1360/* A C structure for machine-specific, per-function data.
1361 This is added to the cfun structure. */
1362typedef struct machine_function
1363{
1364 /* Whether a System V.4 varargs area was created. */
1365 int sysv_varargs_p;
71f123ca
FS
1366 /* Flags if __builtin_return_address (n) with n >= 1 was used. */
1367 int ra_needs_full_frame;
00dba523
NC
1368} machine_function;
1369
f045b2c9
RS
1370/* Define a data type for recording info about an argument list
1371 during the scan of that argument list. This data type should
1372 hold all necessary information about the function itself
1373 and about the args processed so far, enough to enable macros
1374 such as FUNCTION_ARG to determine where the next arg should go.
1375
1376 On the RS/6000, this is a structure. The first element is the number of
1377 total argument words, the second is used to store the next
1378 floating-point register number, and the third says how many more args we
4697a36c
MM
1379 have prototype types for.
1380
4cc833b7
RH
1381 For ABI_V4, we treat these slightly differently -- `sysv_gregno' is
1382 the next availible GP register, `fregno' is the next available FP
1383 register, and `words' is the number of words used on the stack.
1384
bd227acc 1385 The varargs/stdarg support requires that this structure's size
4cc833b7 1386 be a multiple of sizeof(int). */
4697a36c
MM
1387
1388typedef struct rs6000_args
1389{
4cc833b7 1390 int words; /* # words used for passing GP registers */
6a4cee5f
MM
1391 int fregno; /* next available FP register */
1392 int nargs_prototype; /* # args left in the current prototype */
1393 int orig_nargs; /* Original value of nargs_prototype */
6a4cee5f
MM
1394 int prototype; /* Whether a prototype was defined */
1395 int call_cookie; /* Do special things for this call */
4cc833b7 1396 int sysv_gregno; /* next available GP register */
4697a36c 1397} CUMULATIVE_ARGS;
f045b2c9
RS
1398
1399/* Define intermediate macro to compute the size (in registers) of an argument
1400 for the RS/6000. */
1401
d34c5b80
DE
1402#define RS6000_ARG_SIZE(MODE, TYPE) \
1403((MODE) != BLKmode \
c5d71f39
GK
1404 ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD \
1405 : ((unsigned HOST_WIDE_INT) int_size_in_bytes (TYPE) \
1406 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
f045b2c9
RS
1407
1408/* Initialize a variable CUM of type CUMULATIVE_ARGS
1409 for a call to a function whose data type is FNTYPE.
1410 For a library call, FNTYPE is 0. */
1411
2c7ee1a6 1412#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
4697a36c 1413 init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE)
f045b2c9
RS
1414
1415/* Similar, but when scanning the definition of a procedure. We always
1416 set NARGS_PROTOTYPE large so we never return an EXPR_LIST. */
1417
4697a36c
MM
1418#define INIT_CUMULATIVE_INCOMING_ARGS(CUM,FNTYPE,LIBNAME) \
1419 init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE)
f045b2c9
RS
1420
1421/* Update the data in CUM to advance over an argument
1422 of mode MODE and data type TYPE.
1423 (TYPE is null for libcalls where that information may not be available.) */
1424
1425#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
4697a36c 1426 function_arg_advance (&CUM, MODE, TYPE, NAMED)
f045b2c9
RS
1427
1428/* Non-zero if we can use a floating-point register to pass this arg. */
4697a36c
MM
1429#define USE_FP_FOR_ARG_P(CUM,MODE,TYPE) \
1430 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
1431 && (CUM).fregno <= FP_ARG_MAX_REG \
1432 && TARGET_HARD_FLOAT)
f045b2c9
RS
1433
1434/* Determine where to put an argument to a function.
1435 Value is zero to push the argument on the stack,
1436 or a hard register in which to store the argument.
1437
1438 MODE is the argument's machine mode.
1439 TYPE is the data type of the argument (as a tree).
1440 This is null for libcalls where that information may
1441 not be available.
1442 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1443 the preceding args and about the function being called.
1444 NAMED is nonzero if this argument is a named parameter
1445 (otherwise it is an extra parameter matching an ellipsis).
1446
1447 On RS/6000 the first eight words of non-FP are normally in registers
1448 and the rest are pushed. The first 13 FP args are in registers.
1449
1450 If this is floating-point and no prototype is specified, we use
4d6697ca
RK
1451 both an FP and integer register (or possibly FP reg and stack). Library
1452 functions (when TYPE is zero) always have the proper types for args,
1453 so we can pass the FP value just in one register. emit_library_function
1454 doesn't support EXPR_LIST anyway. */
f045b2c9 1455
4697a36c
MM
1456#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1457 function_arg (&CUM, MODE, TYPE, NAMED)
f045b2c9
RS
1458
1459/* For an arg passed partly in registers and partly in memory,
1460 this is the number of registers used.
1461 For args passed entirely in registers or entirely in memory, zero. */
1462
4697a36c
MM
1463#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
1464 function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
1465
1466/* A C expression that indicates when an argument must be passed by
1467 reference. If nonzero for an argument, a copy of that argument is
1468 made in memory and a pointer to the argument is passed instead of
1469 the argument itself. The pointer is passed in whatever way is
1470 appropriate for passing a pointer to that type. */
1471
1472#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
1473 function_arg_pass_by_reference(&CUM, MODE, TYPE, NAMED)
f045b2c9 1474
c229cba9
DE
1475/* If defined, a C expression which determines whether, and in which
1476 direction, to pad out an argument with extra space. The value
1477 should be of type `enum direction': either `upward' to pad above
1478 the argument, `downward' to pad below, or `none' to inhibit
1479 padding. */
1480
9ebbca7d 1481#define FUNCTION_ARG_PADDING(MODE, TYPE) function_arg_padding (MODE, TYPE)
c229cba9 1482
b6c9286a 1483/* If defined, a C expression that gives the alignment boundary, in bits,
c81bebd7 1484 of an argument with the specified mode and type. If it is not defined,
b6c9286a
MM
1485 PARM_BOUNDARY is used for all arguments. */
1486
1487#define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
1488 function_arg_boundary (MODE, TYPE)
1489
f045b2c9 1490/* Perform any needed actions needed for a function that is receiving a
c81bebd7 1491 variable number of arguments.
f045b2c9
RS
1492
1493 CUM is as above.
1494
1495 MODE and TYPE are the mode and type of the current parameter.
1496
1497 PRETEND_SIZE is a variable that should be set to the amount of stack
1498 that must be pushed by the prolog to pretend that our caller pushed
1499 it.
1500
1501 Normally, this macro will push all remaining incoming registers on the
1502 stack and set PRETEND_SIZE to the length of the registers pushed. */
1503
4697a36c
MM
1504#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
1505 setup_incoming_varargs (&CUM, MODE, TYPE, &PRETEND_SIZE, NO_RTL)
1506
dfafc897
FS
1507/* Define the `__builtin_va_list' type for the ABI. */
1508#define BUILD_VA_LIST_TYPE(VALIST) \
1509 (VALIST) = rs6000_build_va_list ()
4697a36c 1510
dfafc897
FS
1511/* Implement `va_start' for varargs and stdarg. */
1512#define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1513 rs6000_va_start (stdarg, valist, nextarg)
1514
1515/* Implement `va_arg'. */
1516#define EXPAND_BUILTIN_VA_ARG(valist, type) \
1517 rs6000_va_arg (valist, type)
f045b2c9 1518
d34c5b80
DE
1519/* Define this macro to be a nonzero value if the location where a function
1520 argument is passed depends on whether or not it is a named argument. */
1521#define STRICT_ARGUMENT_NAMING 1
1522
f045b2c9 1523/* Output assembler code to FILE to increment profiler label # LABELNO
58a39e45 1524 for profiling a function entry. */
f045b2c9
RS
1525
1526#define FUNCTION_PROFILER(FILE, LABELNO) \
58a39e45 1527 output_function_profiler ((FILE), (LABELNO));
f045b2c9
RS
1528
1529/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1530 the stack pointer does not matter. No definition is equivalent to
1531 always zero.
1532
1533 On the RS/6000, this is non-zero because we can restore the stack from
1534 its backpointer, which we maintain. */
1535#define EXIT_IGNORE_STACK 1
1536
a701949a
FS
1537/* Define this macro as a C expression that is nonzero for registers
1538 that are used by the epilogue or the return' pattern. The stack
1539 and frame pointer registers are already be assumed to be used as
1540 needed. */
1541
83720594
RH
1542#define EPILOGUE_USES(REGNO) \
1543 ((reload_completed && (REGNO) == LINK_REGISTER_REGNUM) \
1544 || (current_function_calls_eh_return \
3553b09d 1545 && TARGET_AIX \
83720594 1546 && (REGNO) == TOC_REGISTER))
2bfcf297 1547
f045b2c9 1548\f
eaf1bcf1 1549/* TRAMPOLINE_TEMPLATE deleted */
f045b2c9
RS
1550
1551/* Length in units of the trampoline for entering a nested function. */
1552
b6c9286a 1553#define TRAMPOLINE_SIZE rs6000_trampoline_size ()
f045b2c9
RS
1554
1555/* Emit RTL insns to initialize the variable parts of a trampoline.
1556 FNADDR is an RTX for the address of the function's pure code.
1557 CXT is an RTX for the static chain value for the function. */
1558
1559#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \
b6c9286a 1560 rs6000_initialize_trampoline (ADDR, FNADDR, CXT)
f045b2c9 1561\f
f33985c6
MS
1562/* Definitions for __builtin_return_address and __builtin_frame_address.
1563 __builtin_return_address (0) should give link register (65), enable
1564 this. */
1565/* This should be uncommented, so that the link register is used, but
1566 currently this would result in unmatched insns and spilling fixed
1567 registers so we'll leave it for another day. When these problems are
1568 taken care of one additional fetch will be necessary in RETURN_ADDR_RTX.
1569 (mrs) */
1570/* #define RETURN_ADDR_IN_PREVIOUS_FRAME */
f09d4c33 1571
b6c9286a
MM
1572/* Number of bytes into the frame return addresses can be found. See
1573 rs6000_stack_info in rs6000.c for more information on how the different
1574 abi's store the return address. */
1575#define RETURN_ADDRESS_OFFSET \
1576 ((DEFAULT_ABI == ABI_AIX \
ee890fe2 1577 || DEFAULT_ABI == ABI_DARWIN \
05ef2698 1578 || DEFAULT_ABI == ABI_AIX_NODESC) ? (TARGET_32BIT ? 8 : 16) : \
c81bebd7
MM
1579 (DEFAULT_ABI == ABI_V4 \
1580 || DEFAULT_ABI == ABI_SOLARIS) ? (TARGET_32BIT ? 4 : 8) : \
c4636dd1 1581 (internal_error ("RETURN_ADDRESS_OFFSET not supported"), 0))
f09d4c33 1582
f33985c6
MS
1583/* The current return address is in link register (65). The return address
1584 of anything farther back is accessed normally at an offset of 8 from the
1585 frame pointer. */
71f123ca
FS
1586#define RETURN_ADDR_RTX(COUNT, FRAME) \
1587 (rs6000_return_addr (COUNT, FRAME))
1588
f33985c6 1589\f
f045b2c9
RS
1590/* Definitions for register eliminations.
1591
1592 We have two registers that can be eliminated on the RS/6000. First, the
1593 frame pointer register can often be eliminated in favor of the stack
1594 pointer register. Secondly, the argument pointer register can always be
642a35f1
JW
1595 eliminated; it is replaced with either the stack or frame pointer.
1596
1597 In addition, we use the elimination mechanism to see if r30 is needed
1598 Initially we assume that it isn't. If it is, we spill it. This is done
1599 by making it an eliminable register. We replace it with itself so that
1600 if it isn't needed, then existing uses won't be modified. */
f045b2c9
RS
1601
1602/* This is an array of structures. Each structure initializes one pair
1603 of eliminable registers. The "from" register number is given first,
1604 followed by "to". Eliminations of the same "from" register are listed
1605 in order of preference. */
1606#define ELIMINABLE_REGS \
1607{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1608 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
642a35f1
JW
1609 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
1610 { 30, 30} }
f045b2c9
RS
1611
1612/* Given FROM and TO register numbers, say whether this elimination is allowed.
1613 Frame pointer elimination is automatically handled.
1614
1615 For the RS/6000, if frame pointer elimination is being done, we would like
642a35f1
JW
1616 to convert ap into fp, not sp.
1617
abc95ed3 1618 We need r30 if -mminimal-toc was specified, and there are constant pool
642a35f1 1619 references. */
f045b2c9
RS
1620
1621#define CAN_ELIMINATE(FROM, TO) \
1622 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \
1623 ? ! frame_pointer_needed \
4697a36c 1624 : (FROM) == 30 ? ! TARGET_MINIMAL_TOC || TARGET_NO_TOC || get_pool_size () == 0 \
f045b2c9
RS
1625 : 1)
1626
1627/* Define the offset between two registers, one to be eliminated, and the other
1628 its replacement, at the start of a routine. */
1629#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1630{ \
4697a36c 1631 rs6000_stack_t *info = rs6000_stack_info (); \
f045b2c9
RS
1632 \
1633 if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
4697a36c
MM
1634 (OFFSET) = (info->push_p) ? 0 : - info->total_size; \
1635 else if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \
1636 (OFFSET) = info->total_size; \
1637 else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
1638 (OFFSET) = (info->push_p) ? info->total_size : 0; \
642a35f1
JW
1639 else if ((FROM) == 30) \
1640 (OFFSET) = 0; \
f045b2c9
RS
1641 else \
1642 abort (); \
1643}
1644\f
1645/* Addressing modes, and classification of registers for them. */
1646
940da324
JL
1647/* #define HAVE_POST_INCREMENT 0 */
1648/* #define HAVE_POST_DECREMENT 0 */
f045b2c9 1649
940da324
JL
1650#define HAVE_PRE_DECREMENT 1
1651#define HAVE_PRE_INCREMENT 1
f045b2c9
RS
1652
1653/* Macros to check register numbers against specific register classes. */
1654
1655/* These assume that REGNO is a hard or pseudo reg number.
1656 They give nonzero only if REGNO is a hard reg of the suitable class
1657 or a pseudo reg currently allocated to a suitable hard reg.
1658 Since they use reg_renumber, they are safe only once reg_renumber
1659 has been allocated, which happens in local-alloc.c. */
1660
1661#define REGNO_OK_FOR_INDEX_P(REGNO) \
1662((REGNO) < FIRST_PSEUDO_REGISTER \
1663 ? (REGNO) <= 31 || (REGNO) == 67 \
1664 : (reg_renumber[REGNO] >= 0 \
1665 && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67)))
1666
1667#define REGNO_OK_FOR_BASE_P(REGNO) \
1668((REGNO) < FIRST_PSEUDO_REGISTER \
1669 ? ((REGNO) > 0 && (REGNO) <= 31) || (REGNO) == 67 \
1670 : (reg_renumber[REGNO] > 0 \
1671 && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67)))
1672\f
1673/* Maximum number of registers that can appear in a valid memory address. */
1674
1675#define MAX_REGS_PER_ADDRESS 2
1676
1677/* Recognize any constant value that is a valid address. */
1678
6eff269e
BK
1679#define CONSTANT_ADDRESS_P(X) \
1680 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
1681 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \
1682 || GET_CODE (X) == HIGH)
f045b2c9
RS
1683
1684/* Nonzero if the constant value X is a legitimate general operand.
1685 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
1686
1687 On the RS/6000, all integer constants are acceptable, most won't be valid
1688 for particular insns, though. Only easy FP constants are
1689 acceptable. */
1690
1691#define LEGITIMATE_CONSTANT_P(X) \
1692 (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode \
a260abc9 1693 || (TARGET_POWERPC64 && GET_MODE (X) == DImode) \
f045b2c9
RS
1694 || easy_fp_constant (X, GET_MODE (X)))
1695
1696/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1697 and check its validity for a certain class.
1698 We have two alternate definitions for each of them.
1699 The usual definition accepts all pseudo regs; the other rejects
1700 them unless they have been allocated suitable hard regs.
1701 The symbol REG_OK_STRICT causes the latter definition to be used.
1702
1703 Most source files want to accept pseudo regs in the hope that
1704 they will get allocated to the class that the insn wants them to be in.
1705 Source files for reload pass need to be strict.
1706 After reload, it makes no difference, since pseudo regs have
1707 been eliminated by then. */
1708
258bfae2
FS
1709#ifdef REG_OK_STRICT
1710# define REG_OK_STRICT_FLAG 1
1711#else
1712# define REG_OK_STRICT_FLAG 0
1713#endif
f045b2c9
RS
1714
1715/* Nonzero if X is a hard reg that can be used as an index
258bfae2
FS
1716 or if it is a pseudo reg in the non-strict case. */
1717#define INT_REG_OK_FOR_INDEX_P(X, STRICT) \
1718 ((! (STRICT) \
1719 && (REGNO (X) <= 31 \
1720 || REGNO (X) == ARG_POINTER_REGNUM \
1721 || REGNO (X) >= FIRST_PSEUDO_REGISTER)) \
1722 || ((STRICT) && REGNO_OK_FOR_INDEX_P (REGNO (X))))
f045b2c9
RS
1723
1724/* Nonzero if X is a hard reg that can be used as a base reg
258bfae2
FS
1725 or if it is a pseudo reg in the non-strict case. */
1726#define INT_REG_OK_FOR_BASE_P(X, STRICT) \
1727 (REGNO (X) > 0 && INT_REG_OK_FOR_INDEX_P (X, (STRICT)))
f045b2c9 1728
258bfae2
FS
1729#define REG_OK_FOR_INDEX_P(X) INT_REG_OK_FOR_INDEX_P (X, REG_OK_STRICT_FLAG)
1730#define REG_OK_FOR_BASE_P(X) INT_REG_OK_FOR_BASE_P (X, REG_OK_STRICT_FLAG)
f045b2c9
RS
1731\f
1732/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1733 that is a valid memory address for an instruction.
1734 The MODE argument is the machine mode for the MEM expression
1735 that wants to use this address.
1736
1737 On the RS/6000, there are four valid address: a SYMBOL_REF that
1738 refers to a constant pool entry of an address (or the sum of it
1739 plus a constant), a short (16-bit signed) constant plus a register,
1740 the sum of two registers, or a register indirect, possibly with an
1741 auto-increment. For DFmode and DImode with an constant plus register,
2f3e5814 1742 we must ensure that both words are addressable or PowerPC64 with offset
1427100a
DE
1743 word aligned.
1744
1745 For modes spanning multiple registers (DFmode in 32-bit GPRs,
1746 32-bit DImode, TImode), indexed addressing cannot be used because
1747 adjacent memory cells are accessed by adding word-sized offsets
1748 during assembly output. */
f045b2c9 1749
9ebbca7d
GK
1750#define CONSTANT_POOL_EXPR_P(X) (constant_pool_expr_p (X))
1751
1752#define TOC_RELATIVE_EXPR_P(X) (toc_relative_expr_p (X))
f045b2c9
RS
1753
1754#define LEGITIMATE_CONSTANT_POOL_ADDRESS_P(X) \
9ebbca7d
GK
1755 (TARGET_TOC \
1756 && GET_CODE (X) == PLUS \
1757 && GET_CODE (XEXP (X, 0)) == REG \
1758 && (TARGET_MINIMAL_TOC || REGNO (XEXP (X, 0)) == TOC_REGISTER) \
1759 && CONSTANT_POOL_EXPR_P (XEXP (X, 1)))
f045b2c9 1760
7509c759 1761#define LEGITIMATE_SMALL_DATA_P(MODE, X) \
c81bebd7 1762 ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) \
81795281 1763 && !flag_pic && !TARGET_TOC \
88228c4b
MM
1764 && (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST) \
1765 && small_data_operand (X, MODE))
7509c759 1766
258bfae2 1767#define LEGITIMATE_ADDRESS_INTEGER_P(X, OFFSET) \
f045b2c9 1768 (GET_CODE (X) == CONST_INT \
5b6f7b96 1769 && (unsigned HOST_WIDE_INT) (INTVAL (X) + (OFFSET) + 0x8000) < 0x10000)
f045b2c9 1770
258bfae2
FS
1771#define LEGITIMATE_OFFSET_ADDRESS_P(MODE, X, STRICT) \
1772 (GET_CODE (X) == PLUS \
1773 && GET_CODE (XEXP (X, 0)) == REG \
1774 && INT_REG_OK_FOR_BASE_P (XEXP (X, 0), (STRICT)) \
1775 && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 0) \
1776 && (((MODE) != DFmode && (MODE) != DImode) \
1777 || (TARGET_32BIT \
1778 ? LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 4) \
1779 : ! (INTVAL (XEXP (X, 1)) & 3))) \
1780 && ((MODE) != TImode \
1781 || (TARGET_32BIT \
1782 ? LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 12) \
1783 : (LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 8) \
1465faec 1784 && ! (INTVAL (XEXP (X, 1)) & 3)))))
f045b2c9 1785
258bfae2
FS
1786#define LEGITIMATE_INDEXED_ADDRESS_P(X, STRICT) \
1787 (GET_CODE (X) == PLUS \
1788 && GET_CODE (XEXP (X, 0)) == REG \
1789 && GET_CODE (XEXP (X, 1)) == REG \
1790 && ((INT_REG_OK_FOR_BASE_P (XEXP (X, 0), (STRICT)) \
1791 && INT_REG_OK_FOR_INDEX_P (XEXP (X, 1), (STRICT))) \
1792 || (INT_REG_OK_FOR_BASE_P (XEXP (X, 1), (STRICT)) \
1793 && INT_REG_OK_FOR_INDEX_P (XEXP (X, 0), (STRICT)))))
1794
1795#define LEGITIMATE_INDIRECT_ADDRESS_P(X, STRICT) \
1796 (GET_CODE (X) == REG && INT_REG_OK_FOR_BASE_P (X, (STRICT)))
1797
1798#define LEGITIMATE_LO_SUM_ADDRESS_P(MODE, X, STRICT) \
1799 (TARGET_ELF \
1800 && ! flag_pic && ! TARGET_TOC \
1801 && (MODE) != DImode \
1802 && (MODE) != TImode \
1803 && (TARGET_HARD_FLOAT || (MODE) != DFmode) \
1804 && GET_CODE (X) == LO_SUM \
1805 && GET_CODE (XEXP (X, 0)) == REG \
1806 && INT_REG_OK_FOR_BASE_P (XEXP (X, 0), (STRICT)) \
4697a36c
MM
1807 && CONSTANT_P (XEXP (X, 1)))
1808
258bfae2
FS
1809#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1810{ if (rs6000_legitimate_address (MODE, X, REG_OK_STRICT_FLAG)) \
1811 goto ADDR; \
f045b2c9
RS
1812}
1813\f
1814/* Try machine-dependent ways of modifying an illegitimate address
1815 to be legitimate. If we find one, return the new, valid address.
1816 This macro is used in only one place: `memory_address' in explow.c.
1817
1818 OLDX is the address as it was before break_out_memory_refs was called.
1819 In some cases it is useful to look at this to decide what needs to be done.
1820
1821 MODE and WIN are passed so that this macro can use
1822 GO_IF_LEGITIMATE_ADDRESS.
1823
1824 It is always safe for this macro to do nothing. It exists to recognize
1825 opportunities to optimize the output.
1826
1827 On RS/6000, first check for the sum of a register with a constant
1828 integer that is out of range. If so, generate code to add the
1829 constant with the low-order 16 bits masked to the register and force
1830 this result into another register (this can be done with `cau').
c81bebd7 1831 Then generate an address of REG+(CONST&0xffff), allowing for the
f045b2c9
RS
1832 possibility of bit 16 being a one.
1833
1834 Then check for the sum of a register and something not constant, try to
1835 load the other things into a register and return the sum. */
1836
9ebbca7d
GK
1837#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1838{ rtx result = rs6000_legitimize_address (X, OLDX, MODE); \
1839 if (result != NULL_RTX) \
1840 { \
1841 (X) = result; \
1842 goto WIN; \
1843 } \
f045b2c9
RS
1844}
1845
a260abc9
DE
1846/* Try a machine-dependent way of reloading an illegitimate address
1847 operand. If we find one, push the reload and jump to WIN. This
1848 macro is used in only one place: `find_reloads_address' in reload.c.
1849
1850 For RS/6000, we wish to handle large displacements off a base
1851 register by splitting the addend across an addiu/addis and the mem insn.
1852 This cuts number of extra insns needed from 3 to 1. */
1853
a9098fd0
GK
1854#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
1855do { \
1856 /* We must recognize output that we have already generated ourselves. */ \
1857 if (GET_CODE (X) == PLUS \
1858 && GET_CODE (XEXP (X, 0)) == PLUS \
1859 && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG \
1860 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
1861 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1862 { \
df4ae160 1863 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \
a9098fd0
GK
1864 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
1865 OPNUM, TYPE); \
1866 goto WIN; \
1867 } \
1868 if (GET_CODE (X) == PLUS \
1869 && GET_CODE (XEXP (X, 0)) == REG \
1870 && REGNO (XEXP (X, 0)) < FIRST_PSEUDO_REGISTER \
1871 && REG_MODE_OK_FOR_BASE_P (XEXP (X, 0), MODE) \
1872 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1873 { \
1874 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1875 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000; \
1876 HOST_WIDE_INT high \
0858c623 1877 = (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000; \
a9098fd0
GK
1878 \
1879 /* Check for 32-bit overflow. */ \
1880 if (high + low != val) \
1881 break; \
1882 \
1883 /* Reload the high part into a base reg; leave the low part \
1884 in the mem directly. */ \
1885 \
1886 X = gen_rtx_PLUS (GET_MODE (X), \
1887 gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0), \
1888 GEN_INT (high)), \
1889 GEN_INT (low)); \
1890 \
df4ae160 1891 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \
a9098fd0
GK
1892 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
1893 OPNUM, TYPE); \
1894 goto WIN; \
1895 } \
1896 else if (TARGET_TOC \
1897 && CONSTANT_POOL_EXPR_P (X) \
1898 && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (X), MODE)) \
1899 { \
1900 (X) = create_TOC_reference (X); \
1901 goto WIN; \
1902 } \
a260abc9
DE
1903} while (0)
1904
f045b2c9
RS
1905/* Go to LABEL if ADDR (a legitimate address expression)
1906 has an effect that depends on the machine mode it is used for.
1907
1908 On the RS/6000 this is true if the address is valid with a zero offset
1909 but not with an offset of four (this means it cannot be used as an
1910 address for DImode or DFmode) or is a pre-increment or decrement. Since
1911 we know it is valid, we just check for an address that is not valid with
1912 an offset of four. */
1913
1914#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1915{ if (GET_CODE (ADDR) == PLUS \
1916 && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), 0) \
2f3e5814
DE
1917 && ! LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), \
1918 (TARGET_32BIT ? 4 : 8))) \
f045b2c9 1919 goto LABEL; \
38c1f2d7 1920 if (TARGET_UPDATE && GET_CODE (ADDR) == PRE_INC) \
f045b2c9 1921 goto LABEL; \
38c1f2d7 1922 if (TARGET_UPDATE && GET_CODE (ADDR) == PRE_DEC) \
f045b2c9 1923 goto LABEL; \
4697a36c
MM
1924 if (GET_CODE (ADDR) == LO_SUM) \
1925 goto LABEL; \
f045b2c9 1926}
766a866c
MM
1927\f
1928/* The register number of the register used to address a table of
1929 static data addresses in memory. In some cases this register is
1930 defined by a processor's "application binary interface" (ABI).
1931 When this macro is defined, RTL is generated for this register
1932 once, as with the stack pointer and frame pointer registers. If
1933 this macro is not defined, it is up to the machine-dependent files
1934 to allocate such a register (if necessary). */
1935
8d30c4ee 1936#define PIC_OFFSET_TABLE_REGNUM 30
766a866c 1937
9ebbca7d
GK
1938#define TOC_REGISTER (TARGET_MINIMAL_TOC ? 30 : 2)
1939
766a866c
MM
1940/* Define this macro if the register defined by
1941 `PIC_OFFSET_TABLE_REGNUM' is clobbered by calls. Do not define
1942 this macro if `PPIC_OFFSET_TABLE_REGNUM' is not defined. */
1943
1944/* #define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED */
1945
1946/* By generating position-independent code, when two different
1947 programs (A and B) share a common library (libC.a), the text of
1948 the library can be shared whether or not the library is linked at
1949 the same address for both programs. In some of these
1950 environments, position-independent code requires not only the use
1951 of different addressing modes, but also special code to enable the
1952 use of these addressing modes.
1953
1954 The `FINALIZE_PIC' macro serves as a hook to emit these special
1955 codes once the function is being compiled into assembly code, but
1956 not before. (It is not done before, because in the case of
1957 compiling an inline function, it would lead to multiple PIC
1958 prologues being included in functions which used inline functions
1959 and were compiled to assembly language.) */
1960
8d30c4ee 1961/* #define FINALIZE_PIC */
766a866c 1962
766a866c
MM
1963/* A C expression that is nonzero if X is a legitimate immediate
1964 operand on the target machine when generating position independent
1965 code. You can assume that X satisfies `CONSTANT_P', so you need
1966 not check this. You can also assume FLAG_PIC is true, so you need
1967 not check it either. You need not define this macro if all
1968 constants (including `SYMBOL_REF') can be immediate operands when
1969 generating position independent code. */
1970
1971/* #define LEGITIMATE_PIC_OPERAND_P (X) */
1972
30ea98f1
MM
1973/* In rare cases, correct code generation requires extra machine
1974 dependent processing between the second jump optimization pass and
1975 delayed branch scheduling. On those machines, define this macro
9ebbca7d 1976 as a C statement to act on the code starting at INSN. */
30ea98f1 1977
9ebbca7d 1978/* #define MACHINE_DEPENDENT_REORG(INSN) */
30ea98f1 1979
f045b2c9
RS
1980\f
1981/* Define this if some processing needs to be done immediately before
4255474b 1982 emitting code for an insn. */
f045b2c9 1983
4255474b 1984/* #define FINAL_PRESCAN_INSN(INSN,OPERANDS,NOPERANDS) */
f045b2c9
RS
1985
1986/* Specify the machine mode that this machine uses
1987 for the index in the tablejump instruction. */
e1565e65 1988#define CASE_VECTOR_MODE SImode
f045b2c9 1989
18543a22
ILT
1990/* Define as C expression which evaluates to nonzero if the tablejump
1991 instruction expects the table to contain offsets from the address of the
1992 table.
1993 Do not define this if the table should contain absolute addresses. */
1994#define CASE_VECTOR_PC_RELATIVE 1
f045b2c9
RS
1995
1996/* Specify the tree operation to be used to convert reals to integers. */
1997#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1998
1999/* This is the kind of divide that is easiest to do in the general case. */
2000#define EASY_DIV_EXPR TRUNC_DIV_EXPR
2001
2002/* Define this as 1 if `char' should by default be signed; else as 0. */
2003#define DEFAULT_SIGNED_CHAR 0
2004
2005/* This flag, if defined, says the same insns that convert to a signed fixnum
2006 also convert validly to an unsigned one. */
2007
2008/* #define FIXUNS_TRUNC_LIKE_FIX_TRUNC */
2009
2010/* Max number of bytes we can move from memory to memory
2011 in one reasonably fast instruction. */
2f3e5814 2012#define MOVE_MAX (! TARGET_POWERPC64 ? 4 : 8)
7e69e155 2013#define MAX_MOVE_MAX 8
f045b2c9
RS
2014
2015/* Nonzero if access to memory by bytes is no faster than for words.
2016 Also non-zero if doing byte operations (specifically shifts) in registers
2017 is undesirable. */
2018#define SLOW_BYTE_ACCESS 1
2019
9a63901f
RK
2020/* Define if operations between registers always perform the operation
2021 on the full register even if a narrower mode is specified. */
2022#define WORD_REGISTER_OPERATIONS
2023
2024/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
2025 will either zero-extend or sign-extend. The value of this macro should
2026 be the code that says which one of the two operations is implicitly
2027 done, NIL if none. */
2028#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
225211e2
RK
2029
2030/* Define if loading short immediate values into registers sign extends. */
2031#define SHORT_IMMEDIATES_SIGN_EXTEND
fdaff8ba 2032\f
f045b2c9
RS
2033/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
2034 is done just by pretending it is already truncated. */
2035#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2036
2037/* Specify the machine mode that pointers have.
2038 After generation of rtl, the compiler makes no further distinction
2039 between pointers and any other objects of this machine mode. */
2f3e5814 2040#define Pmode (TARGET_32BIT ? SImode : DImode)
f045b2c9
RS
2041
2042/* Mode of a function address in a call instruction (for indexing purposes).
f045b2c9 2043 Doesn't matter on RS/6000. */
2f3e5814 2044#define FUNCTION_MODE (TARGET_32BIT ? SImode : DImode)
f045b2c9
RS
2045
2046/* Define this if addresses of constant functions
2047 shouldn't be put through pseudo regs where they can be cse'd.
2048 Desirable on machines where ordinary constants are expensive
2049 but a CALL with constant address is cheap. */
2050#define NO_FUNCTION_CSE
2051
d969caf8 2052/* Define this to be nonzero if shift instructions ignore all but the low-order
6febd581
RK
2053 few bits.
2054
2055 The sle and sre instructions which allow SHIFT_COUNT_TRUNCATED
2056 have been dropped from the PowerPC architecture. */
2057
4697a36c 2058#define SHIFT_COUNT_TRUNCATED (TARGET_POWER ? 1 : 0)
f045b2c9 2059
f045b2c9
RS
2060/* Compute the cost of computing a constant rtl expression RTX
2061 whose rtx-code is CODE. The body of this macro is a portion
2062 of a switch statement. If the code is computed here,
2063 return it with a return statement. Otherwise, break from the switch.
2064
01554f00 2065 On the RS/6000, if it is valid in the insn, it is free. So this
f045b2c9
RS
2066 always returns 0. */
2067
4697a36c 2068#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
f045b2c9
RS
2069 case CONST_INT: \
2070 case CONST: \
2071 case LABEL_REF: \
2072 case SYMBOL_REF: \
2073 case CONST_DOUBLE: \
4697a36c 2074 case HIGH: \
f045b2c9
RS
2075 return 0;
2076
2077/* Provide the costs of a rtl expression. This is in the body of a
2078 switch on CODE. */
2079
38c1f2d7
MM
2080#define RTX_COSTS(X,CODE,OUTER_CODE) \
2081 case PLUS: \
2082 return ((GET_CODE (XEXP (X, 1)) == CONST_INT \
a260abc9
DE
2083 && ((unsigned HOST_WIDE_INT) (INTVAL (XEXP (X, 1)) \
2084 + 0x8000) >= 0x10000) \
296b8152 2085 && ((INTVAL (XEXP (X, 1)) & 0xffff) != 0)) \
38c1f2d7
MM
2086 ? COSTS_N_INSNS (2) \
2087 : COSTS_N_INSNS (1)); \
2088 case AND: \
38c1f2d7
MM
2089 case IOR: \
2090 case XOR: \
a260abc9
DE
2091 return ((GET_CODE (XEXP (X, 1)) == CONST_INT \
2092 && (INTVAL (XEXP (X, 1)) & (~ (HOST_WIDE_INT) 0xffff)) != 0 \
296b8152 2093 && ((INTVAL (XEXP (X, 1)) & 0xffff) != 0)) \
38c1f2d7
MM
2094 ? COSTS_N_INSNS (2) \
2095 : COSTS_N_INSNS (1)); \
2096 case MULT: \
2097 switch (rs6000_cpu) \
2098 { \
2099 case PROCESSOR_RIOS1: \
2100 return (GET_CODE (XEXP (X, 1)) != CONST_INT \
2101 ? COSTS_N_INSNS (5) \
2102 : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \
2103 ? COSTS_N_INSNS (3) : COSTS_N_INSNS (4)); \
3cb999d8
DE
2104 case PROCESSOR_RS64A: \
2105 return (GET_CODE (XEXP (X, 1)) != CONST_INT \
2106 ? GET_MODE (XEXP (X, 1)) != DImode \
2107 ? COSTS_N_INSNS (20) : COSTS_N_INSNS (34) \
2108 : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \
2109 ? COSTS_N_INSNS (12) : COSTS_N_INSNS (14)); \
38c1f2d7
MM
2110 case PROCESSOR_RIOS2: \
2111 case PROCESSOR_MPCCORE: \
5a41b476 2112 case PROCESSOR_PPC604e: \
38c1f2d7
MM
2113 return COSTS_N_INSNS (2); \
2114 case PROCESSOR_PPC601: \
2115 return COSTS_N_INSNS (5); \
2116 case PROCESSOR_PPC603: \
bef84347 2117 case PROCESSOR_PPC750: \
38c1f2d7
MM
2118 return (GET_CODE (XEXP (X, 1)) != CONST_INT \
2119 ? COSTS_N_INSNS (5) \
2120 : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \
2121 ? COSTS_N_INSNS (2) : COSTS_N_INSNS (3)); \
2122 case PROCESSOR_PPC403: \
2123 case PROCESSOR_PPC604: \
38c1f2d7 2124 return COSTS_N_INSNS (4); \
3cb999d8
DE
2125 case PROCESSOR_PPC620: \
2126 case PROCESSOR_PPC630: \
2127 return (GET_CODE (XEXP (X, 1)) != CONST_INT \
2128 ? GET_MODE (XEXP (X, 1)) != DImode \
2129 ? COSTS_N_INSNS (4) : COSTS_N_INSNS (7) \
2130 : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \
2131 ? COSTS_N_INSNS (3) : COSTS_N_INSNS (4)); \
38c1f2d7
MM
2132 } \
2133 case DIV: \
2134 case MOD: \
2135 if (GET_CODE (XEXP (X, 1)) == CONST_INT \
2136 && exact_log2 (INTVAL (XEXP (X, 1))) >= 0) \
2137 return COSTS_N_INSNS (2); \
2138 /* otherwise fall through to normal divide. */ \
2139 case UDIV: \
2140 case UMOD: \
2141 switch (rs6000_cpu) \
2142 { \
2143 case PROCESSOR_RIOS1: \
2144 return COSTS_N_INSNS (19); \
2145 case PROCESSOR_RIOS2: \
2146 return COSTS_N_INSNS (13); \
3cb999d8
DE
2147 case PROCESSOR_RS64A: \
2148 return (GET_MODE (XEXP (X, 1)) != DImode \
2149 ? COSTS_N_INSNS (65) \
2150 : COSTS_N_INSNS (67)); \
38c1f2d7
MM
2151 case PROCESSOR_MPCCORE: \
2152 return COSTS_N_INSNS (6); \
2153 case PROCESSOR_PPC403: \
2154 return COSTS_N_INSNS (33); \
2155 case PROCESSOR_PPC601: \
2156 return COSTS_N_INSNS (36); \
2157 case PROCESSOR_PPC603: \
2158 return COSTS_N_INSNS (37); \
2159 case PROCESSOR_PPC604: \
5a41b476 2160 case PROCESSOR_PPC604e: \
38c1f2d7 2161 return COSTS_N_INSNS (20); \
3cb999d8
DE
2162 case PROCESSOR_PPC620: \
2163 case PROCESSOR_PPC630: \
2164 return (GET_MODE (XEXP (X, 1)) != DImode \
2165 ? COSTS_N_INSNS (21) \
2166 : COSTS_N_INSNS (37)); \
bef84347
VM
2167 case PROCESSOR_PPC750: \
2168 return COSTS_N_INSNS (19); \
38c1f2d7
MM
2169 } \
2170 case FFS: \
2171 return COSTS_N_INSNS (4); \
2172 case MEM: \
f045b2c9
RS
2173 /* MEM should be slightly more expensive than (plus (reg) (const)) */ \
2174 return 5;
2175
2176/* Compute the cost of an address. This is meant to approximate the size
2177 and/or execution delay of an insn using that address. If the cost is
2178 approximated by the RTL complexity, including CONST_COSTS above, as
2179 is usually the case for CISC machines, this macro should not be defined.
2180 For aggressively RISCy machines, only one insn format is allowed, so
2181 this macro should be a constant. The value of this macro only matters
2182 for valid addresses.
2183
2184 For the RS/6000, everything is cost 0. */
2185
2186#define ADDRESS_COST(RTX) 0
2187
2188/* Adjust the length of an INSN. LENGTH is the currently-computed length and
2189 should be adjusted to reflect any required changes. This macro is used when
2190 there is some systematic length adjustment required that would be difficult
2191 to express in the length attribute. */
2192
2193/* #define ADJUST_INSN_LENGTH(X,LENGTH) */
2194
2195/* Add any extra modes needed to represent the condition code.
2196
2197 For the RS/6000, we need separate modes when unsigned (logical) comparisons
c5defebb
RK
2198 are being done and we need a separate mode for floating-point. We also
2199 use a mode for the case when we are comparing the results of two
39a10a29 2200 comparisons, as then only the EQ bit is valid in the register. */
f045b2c9 2201
aa0b4465
ZW
2202#define EXTRA_CC_MODES \
2203 CC(CCUNSmode, "CCUNS") \
2204 CC(CCFPmode, "CCFP") \
2205 CC(CCEQmode, "CCEQ")
f045b2c9 2206
39a10a29
GK
2207/* Given a comparison code (EQ, NE, etc.) and the first operand of a
2208 COMPARE, return the mode to be used for the comparison. For
2209 floating-point, CCFPmode should be used. CCUNSmode should be used
2210 for unsigned comparisons. CCEQmode should be used when we are
2211 doing an inequality comparison on the result of a
2212 comparison. CCmode should be used in all other cases. */
c5defebb 2213
b565a316 2214#define SELECT_CC_MODE(OP,X,Y) \
f045b2c9 2215 (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CCFPmode \
c5defebb
RK
2216 : (OP) == GTU || (OP) == LTU || (OP) == GEU || (OP) == LEU ? CCUNSmode \
2217 : (((OP) == EQ || (OP) == NE) && GET_RTX_CLASS (GET_CODE (X)) == '<' \
2218 ? CCEQmode : CCmode))
f045b2c9
RS
2219
2220/* Define the information needed to generate branch and scc insns. This is
2221 stored from the compare operation. Note that we can't use "rtx" here
2222 since it hasn't been defined! */
2223
2224extern struct rtx_def *rs6000_compare_op0, *rs6000_compare_op1;
2225extern int rs6000_compare_fp_p;
f045b2c9
RS
2226\f
2227/* Control the assembler format that we output. */
2228
1b279f39
DE
2229/* A C string constant describing how to begin a comment in the target
2230 assembler language. The compiler assumes that the comment will end at
2231 the end of the line. */
2232#define ASM_COMMENT_START " #"
6b67933e 2233
fdaff8ba
RS
2234/* Implicit library calls should use memcpy, not bcopy, etc. */
2235
2236#define TARGET_MEM_FUNCTIONS
2237
38c1f2d7
MM
2238/* Flag to say the TOC is initialized */
2239extern int toc_initialized;
2240
f045b2c9
RS
2241/* Macro to output a special constant pool entry. Go to WIN if we output
2242 it. Otherwise, it is written the usual way.
2243
2244 On the RS/6000, toc entries are handled this way. */
2245
a9098fd0
GK
2246#define ASM_OUTPUT_SPECIAL_POOL_ENTRY(FILE, X, MODE, ALIGN, LABELNO, WIN) \
2247{ if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X, MODE)) \
2248 { \
2249 output_toc (FILE, X, LABELNO, MODE); \
2250 goto WIN; \
2251 } \
f045b2c9
RS
2252}
2253
9ebbca7d 2254/* This implementes the `alias' attribute. */
290ad355 2255
9ebbca7d
GK
2256#define ASM_OUTPUT_DEF_FROM_DECLS(FILE,decl,target) \
2257do { \
53cd5d6c 2258 const char * alias = XSTR (XEXP (DECL_RTL (decl), 0), 0); \
9ebbca7d
GK
2259 char * name = IDENTIFIER_POINTER (target); \
2260 if (TREE_CODE (decl) == FUNCTION_DECL \
2261 && DEFAULT_ABI == ABI_AIX) \
2262 { \
2263 if (TREE_PUBLIC (decl)) \
2264 { \
2265 fputs ("\t.globl .", FILE); \
2266 assemble_name (FILE, alias); \
2267 putc ('\n', FILE); \
2268 } \
2269 else \
2270 { \
2271 fputs ("\t.lglobl .", FILE); \
2272 assemble_name (FILE, alias); \
2273 putc ('\n', FILE); \
2274 } \
2275 fputs ("\t.set .", FILE); \
2276 assemble_name (FILE, alias); \
2277 fputs (",.", FILE); \
2278 assemble_name (FILE, name); \
2279 fputc ('\n', FILE); \
2280 } \
2281 ASM_OUTPUT_DEF (FILE, alias, name); \
290ad355
RH
2282} while (0)
2283
f045b2c9
RS
2284/* Output to assembler file text saying following lines
2285 may contain character constants, extra white space, comments, etc. */
2286
2287#define ASM_APP_ON ""
2288
2289/* Output to assembler file text saying following lines
2290 no longer contain unusual constructs. */
2291
2292#define ASM_APP_OFF ""
2293
f045b2c9
RS
2294/* How to refer to registers in assembler output.
2295 This sequence is indexed by compiler's hard-register-number (see above). */
2296
802a0058 2297extern char rs6000_reg_names[][8]; /* register names (0 vs. %r0). */
c81bebd7
MM
2298
2299#define REGISTER_NAMES \
2300{ \
2301 &rs6000_reg_names[ 0][0], /* r0 */ \
2302 &rs6000_reg_names[ 1][0], /* r1 */ \
2303 &rs6000_reg_names[ 2][0], /* r2 */ \
2304 &rs6000_reg_names[ 3][0], /* r3 */ \
2305 &rs6000_reg_names[ 4][0], /* r4 */ \
2306 &rs6000_reg_names[ 5][0], /* r5 */ \
2307 &rs6000_reg_names[ 6][0], /* r6 */ \
2308 &rs6000_reg_names[ 7][0], /* r7 */ \
2309 &rs6000_reg_names[ 8][0], /* r8 */ \
2310 &rs6000_reg_names[ 9][0], /* r9 */ \
2311 &rs6000_reg_names[10][0], /* r10 */ \
2312 &rs6000_reg_names[11][0], /* r11 */ \
2313 &rs6000_reg_names[12][0], /* r12 */ \
2314 &rs6000_reg_names[13][0], /* r13 */ \
2315 &rs6000_reg_names[14][0], /* r14 */ \
2316 &rs6000_reg_names[15][0], /* r15 */ \
2317 &rs6000_reg_names[16][0], /* r16 */ \
2318 &rs6000_reg_names[17][0], /* r17 */ \
2319 &rs6000_reg_names[18][0], /* r18 */ \
2320 &rs6000_reg_names[19][0], /* r19 */ \
2321 &rs6000_reg_names[20][0], /* r20 */ \
2322 &rs6000_reg_names[21][0], /* r21 */ \
2323 &rs6000_reg_names[22][0], /* r22 */ \
2324 &rs6000_reg_names[23][0], /* r23 */ \
2325 &rs6000_reg_names[24][0], /* r24 */ \
2326 &rs6000_reg_names[25][0], /* r25 */ \
2327 &rs6000_reg_names[26][0], /* r26 */ \
2328 &rs6000_reg_names[27][0], /* r27 */ \
2329 &rs6000_reg_names[28][0], /* r28 */ \
2330 &rs6000_reg_names[29][0], /* r29 */ \
2331 &rs6000_reg_names[30][0], /* r30 */ \
2332 &rs6000_reg_names[31][0], /* r31 */ \
2333 \
2334 &rs6000_reg_names[32][0], /* fr0 */ \
2335 &rs6000_reg_names[33][0], /* fr1 */ \
2336 &rs6000_reg_names[34][0], /* fr2 */ \
2337 &rs6000_reg_names[35][0], /* fr3 */ \
2338 &rs6000_reg_names[36][0], /* fr4 */ \
2339 &rs6000_reg_names[37][0], /* fr5 */ \
2340 &rs6000_reg_names[38][0], /* fr6 */ \
2341 &rs6000_reg_names[39][0], /* fr7 */ \
2342 &rs6000_reg_names[40][0], /* fr8 */ \
2343 &rs6000_reg_names[41][0], /* fr9 */ \
2344 &rs6000_reg_names[42][0], /* fr10 */ \
2345 &rs6000_reg_names[43][0], /* fr11 */ \
2346 &rs6000_reg_names[44][0], /* fr12 */ \
2347 &rs6000_reg_names[45][0], /* fr13 */ \
2348 &rs6000_reg_names[46][0], /* fr14 */ \
2349 &rs6000_reg_names[47][0], /* fr15 */ \
2350 &rs6000_reg_names[48][0], /* fr16 */ \
2351 &rs6000_reg_names[49][0], /* fr17 */ \
2352 &rs6000_reg_names[50][0], /* fr18 */ \
2353 &rs6000_reg_names[51][0], /* fr19 */ \
2354 &rs6000_reg_names[52][0], /* fr20 */ \
2355 &rs6000_reg_names[53][0], /* fr21 */ \
2356 &rs6000_reg_names[54][0], /* fr22 */ \
2357 &rs6000_reg_names[55][0], /* fr23 */ \
2358 &rs6000_reg_names[56][0], /* fr24 */ \
2359 &rs6000_reg_names[57][0], /* fr25 */ \
2360 &rs6000_reg_names[58][0], /* fr26 */ \
2361 &rs6000_reg_names[59][0], /* fr27 */ \
2362 &rs6000_reg_names[60][0], /* fr28 */ \
2363 &rs6000_reg_names[61][0], /* fr29 */ \
2364 &rs6000_reg_names[62][0], /* fr30 */ \
2365 &rs6000_reg_names[63][0], /* fr31 */ \
2366 \
2367 &rs6000_reg_names[64][0], /* mq */ \
2368 &rs6000_reg_names[65][0], /* lr */ \
2369 &rs6000_reg_names[66][0], /* ctr */ \
2370 &rs6000_reg_names[67][0], /* ap */ \
2371 \
2372 &rs6000_reg_names[68][0], /* cr0 */ \
2373 &rs6000_reg_names[69][0], /* cr1 */ \
2374 &rs6000_reg_names[70][0], /* cr2 */ \
2375 &rs6000_reg_names[71][0], /* cr3 */ \
2376 &rs6000_reg_names[72][0], /* cr4 */ \
2377 &rs6000_reg_names[73][0], /* cr5 */ \
2378 &rs6000_reg_names[74][0], /* cr6 */ \
2379 &rs6000_reg_names[75][0], /* cr7 */ \
802a0058 2380 \
9ebbca7d 2381 &rs6000_reg_names[76][0], /* xer */ \
c81bebd7
MM
2382}
2383
2384/* print-rtl can't handle the above REGISTER_NAMES, so define the
2385 following for it. Switch to use the alternate names since
2386 they are more mnemonic. */
2387
2388#define DEBUG_REGISTER_NAMES \
2389{ \
802a0058
MM
2390 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
2391 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
2392 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
2393 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
2394 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
2395 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
2396 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
2397 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
2398 "mq", "lr", "ctr", "ap", \
2399 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \
9ebbca7d 2400 "xer" \
c81bebd7 2401}
f045b2c9
RS
2402
2403/* Table of additional register names to use in user input. */
2404
2405#define ADDITIONAL_REGISTER_NAMES \
c4d38ccb
MM
2406 {{"r0", 0}, {"r1", 1}, {"r2", 2}, {"r3", 3}, \
2407 {"r4", 4}, {"r5", 5}, {"r6", 6}, {"r7", 7}, \
2408 {"r8", 8}, {"r9", 9}, {"r10", 10}, {"r11", 11}, \
2409 {"r12", 12}, {"r13", 13}, {"r14", 14}, {"r15", 15}, \
2410 {"r16", 16}, {"r17", 17}, {"r18", 18}, {"r19", 19}, \
2411 {"r20", 20}, {"r21", 21}, {"r22", 22}, {"r23", 23}, \
2412 {"r24", 24}, {"r25", 25}, {"r26", 26}, {"r27", 27}, \
2413 {"r28", 28}, {"r29", 29}, {"r30", 30}, {"r31", 31}, \
2414 {"fr0", 32}, {"fr1", 33}, {"fr2", 34}, {"fr3", 35}, \
2415 {"fr4", 36}, {"fr5", 37}, {"fr6", 38}, {"fr7", 39}, \
2416 {"fr8", 40}, {"fr9", 41}, {"fr10", 42}, {"fr11", 43}, \
2417 {"fr12", 44}, {"fr13", 45}, {"fr14", 46}, {"fr15", 47}, \
2418 {"fr16", 48}, {"fr17", 49}, {"fr18", 50}, {"fr19", 51}, \
2419 {"fr20", 52}, {"fr21", 53}, {"fr22", 54}, {"fr23", 55}, \
2420 {"fr24", 56}, {"fr25", 57}, {"fr26", 58}, {"fr27", 59}, \
2421 {"fr28", 60}, {"fr29", 61}, {"fr30", 62}, {"fr31", 63}, \
2422 /* no additional names for: mq, lr, ctr, ap */ \
2423 {"cr0", 68}, {"cr1", 69}, {"cr2", 70}, {"cr3", 71}, \
2424 {"cr4", 72}, {"cr5", 73}, {"cr6", 74}, {"cr7", 75}, \
2425 {"cc", 68}, {"sp", 1}, {"toc", 2} }
f045b2c9
RS
2426
2427/* How to renumber registers for dbx and gdb. */
2428
2429#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
2430
0da40b09
RK
2431/* Text to write out after a CALL that may be replaced by glue code by
2432 the loader. This depends on the AIX version. */
2433#define RS6000_CALL_GLUE "cror 31,31,31"
11117bb9 2434
f045b2c9
RS
2435/* This is how to output an assembler line defining a `double' constant. */
2436
b5253831
DE
2437#define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
2438 { \
2439 long t[2]; \
2440 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \
2441 fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", \
0858c623 2442 t[0] & 0xffffffff, t[1] & 0xffffffff); \
a5b1eb34 2443 }
f045b2c9
RS
2444
2445/* This is how to output an assembler line defining a `float' constant. */
2446
b5253831
DE
2447#define ASM_OUTPUT_FLOAT(FILE, VALUE) \
2448 { \
2449 long t; \
2450 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
0858c623 2451 fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff); \
a5b1eb34 2452 }
f045b2c9
RS
2453
2454/* This is how to output an assembler line defining an `int' constant. */
2455
5854b0d0
DE
2456#define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE) \
2457do { \
2458 if (TARGET_32BIT) \
2459 { \
2460 assemble_integer (operand_subword ((VALUE), 0, 0, DImode), \
c8af3574 2461 UNITS_PER_WORD, BITS_PER_WORD, 1); \
5854b0d0 2462 assemble_integer (operand_subword ((VALUE), 1, 0, DImode), \
c8af3574 2463 UNITS_PER_WORD, BITS_PER_WORD, 1); \
5854b0d0
DE
2464 } \
2465 else \
2466 { \
362b68a8 2467 fprintf (FILE, "%s", DOUBLE_INT_ASM_OP); \
5854b0d0
DE
2468 output_addr_const (FILE, (VALUE)); \
2469 putc ('\n', FILE); \
2470 } \
2471} while (0)
2472
f045b2c9 2473#define ASM_OUTPUT_INT(FILE,VALUE) \
19d2d16f 2474( fputs ("\t.long ", FILE), \
f045b2c9 2475 output_addr_const (FILE, (VALUE)), \
19d2d16f 2476 putc ('\n', FILE))
f045b2c9
RS
2477
2478/* Likewise for `char' and `short' constants. */
2479
2480#define ASM_OUTPUT_SHORT(FILE,VALUE) \
19d2d16f 2481( fputs ("\t.short ", FILE), \
f045b2c9 2482 output_addr_const (FILE, (VALUE)), \
19d2d16f 2483 putc ('\n', FILE))
f045b2c9
RS
2484
2485#define ASM_OUTPUT_CHAR(FILE,VALUE) \
19d2d16f 2486( fputs ("\t.byte ", FILE), \
f045b2c9 2487 output_addr_const (FILE, (VALUE)), \
19d2d16f 2488 putc ('\n', FILE))
f045b2c9
RS
2489
2490/* This is how to output an assembler line for a numeric constant byte. */
2491
2492#define ASM_OUTPUT_BYTE(FILE,VALUE) \
2493 fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
2494
9ebbca7d 2495/* This is used by the definition of ASM_OUTPUT_ADDR_ELT in defaults.h. */
2bfcf297 2496#define ASM_LONG (TARGET_32BIT ? ".long" : DOUBLE_INT_ASM_OP)
f045b2c9
RS
2497
2498/* This is how to output an element of a case-vector that is relative. */
2499
e1565e65 2500#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
3daf36a4 2501 do { char buf[100]; \
e1565e65 2502 fputs ("\t.long ", FILE); \
3daf36a4
ILT
2503 ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE); \
2504 assemble_name (FILE, buf); \
19d2d16f 2505 putc ('-', FILE); \
3daf36a4
ILT
2506 ASM_GENERATE_INTERNAL_LABEL (buf, "L", REL); \
2507 assemble_name (FILE, buf); \
19d2d16f 2508 putc ('\n', FILE); \
3daf36a4 2509 } while (0)
f045b2c9
RS
2510
2511/* This is how to output an assembler line
2512 that says to advance the location counter
2513 to a multiple of 2**LOG bytes. */
2514
2515#define ASM_OUTPUT_ALIGN(FILE,LOG) \
2516 if ((LOG) != 0) \
2517 fprintf (FILE, "\t.align %d\n", (LOG))
2518
f045b2c9
RS
2519/* Store in OUTPUT a string (made with alloca) containing
2520 an assembler-name for a local static variable named NAME.
2521 LABELNO is an integer which is different for each call. */
2522
2523#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2524( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2525 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2526
9ebbca7d
GK
2527/* Pick up the return address upon entry to a procedure. Used for
2528 dwarf2 unwind information. This also enables the table driven
2529 mechanism. */
2530
2531#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM)
8034da37 2532#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LINK_REGISTER_REGNUM)
9ebbca7d 2533
83720594
RH
2534/* Describe how we implement __builtin_eh_return. */
2535#define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 3 : INVALID_REGNUM)
2536#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 10)
2537
f045b2c9
RS
2538/* Print operand X (an rtx) in assembler syntax to file FILE.
2539 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2540 For `%' followed by punctuation, CODE is the punctuation and X is null. */
2541
2542#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
2543
2544/* Define which CODE values are valid. */
2545
c81bebd7
MM
2546#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
2547 ((CODE) == '.' || (CODE) == '*' || (CODE) == '$')
f045b2c9
RS
2548
2549/* Print a memory address as an operand to reference that memory location. */
2550
2551#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
2552
2553/* Define the codes that are matched by predicates in rs6000.c. */
2554
39a10a29
GK
2555#define PREDICATE_CODES \
2556 {"short_cint_operand", {CONST_INT}}, \
2557 {"u_short_cint_operand", {CONST_INT}}, \
2558 {"non_short_cint_operand", {CONST_INT}}, \
2bfcf297 2559 {"exact_log2_cint_operand", {CONST_INT}}, \
39a10a29
GK
2560 {"gpc_reg_operand", {SUBREG, REG}}, \
2561 {"cc_reg_operand", {SUBREG, REG}}, \
2562 {"cc_reg_not_cr0_operand", {SUBREG, REG}}, \
2563 {"reg_or_short_operand", {SUBREG, REG, CONST_INT}}, \
2564 {"reg_or_neg_short_operand", {SUBREG, REG, CONST_INT}}, \
2565 {"reg_or_u_short_operand", {SUBREG, REG, CONST_INT}}, \
2566 {"reg_or_cint_operand", {SUBREG, REG, CONST_INT}}, \
2567 {"reg_or_arith_cint_operand", {SUBREG, REG, CONST_INT}}, \
2bfcf297
DB
2568 {"reg_or_add_cint64_operand", {SUBREG, REG, CONST_INT}}, \
2569 {"reg_or_sub_cint64_operand", {SUBREG, REG, CONST_INT}}, \
1d328b19 2570 {"reg_or_logical_cint_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
39a10a29
GK
2571 {"got_operand", {SYMBOL_REF, CONST, LABEL_REF}}, \
2572 {"got_no_const_operand", {SYMBOL_REF, LABEL_REF}}, \
2573 {"easy_fp_constant", {CONST_DOUBLE}}, \
50a0b056 2574 {"zero_fp_constant", {CONST_DOUBLE}}, \
39a10a29
GK
2575 {"reg_or_mem_operand", {SUBREG, MEM, REG}}, \
2576 {"lwa_operand", {SUBREG, MEM, REG}}, \
2577 {"volatile_mem_operand", {MEM}}, \
2578 {"offsettable_mem_operand", {MEM}}, \
2579 {"mem_or_easy_const_operand", {SUBREG, MEM, CONST_DOUBLE}}, \
2580 {"add_operand", {SUBREG, REG, CONST_INT}}, \
2581 {"non_add_cint_operand", {CONST_INT}}, \
2582 {"and_operand", {SUBREG, REG, CONST_INT}}, \
2583 {"and64_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2584 {"logical_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
2585 {"non_logical_cint_operand", {CONST_INT, CONST_DOUBLE}}, \
2586 {"mask_operand", {CONST_INT}}, \
2587 {"mask64_operand", {CONST_INT, CONST_DOUBLE}}, \
39a10a29
GK
2588 {"count_register_operand", {REG}}, \
2589 {"xer_operand", {REG}}, \
2590 {"call_operand", {SYMBOL_REF, REG}}, \
2591 {"current_file_function_operand", {SYMBOL_REF}}, \
2592 {"input_operand", {SUBREG, MEM, REG, CONST_INT, \
2593 CONST_DOUBLE, SYMBOL_REF}}, \
2594 {"load_multiple_operation", {PARALLEL}}, \
2595 {"store_multiple_operation", {PARALLEL}}, \
2596 {"branch_comparison_operator", {EQ, NE, LE, LT, GE, \
2597 GT, LEU, LTU, GEU, GTU, \
2598 UNORDERED, ORDERED, \
2599 UNGE, UNLE }}, \
2600 {"branch_positive_comparison_operator", {EQ, LT, GT, LTU, GTU, \
2601 UNORDERED }}, \
2602 {"scc_comparison_operator", {EQ, NE, LE, LT, GE, \
2603 GT, LEU, LTU, GEU, GTU, \
2604 UNORDERED, ORDERED, \
2605 UNGE, UNLE }}, \
2606 {"trap_comparison_operator", {EQ, NE, LE, LT, GE, \
2607 GT, LEU, LTU, GEU, GTU}}, \
2608 {"boolean_operator", {AND, IOR, XOR}}, \
50a0b056
GK
2609 {"boolean_or_operator", {IOR, XOR}}, \
2610 {"min_max_operator", {SMIN, SMAX, UMIN, UMAX}},
75814ad4 2611
b6c9286a
MM
2612/* uncomment for disabling the corresponding default options */
2613/* #define MACHINE_no_sched_interblock */
2614/* #define MACHINE_no_sched_speculative */
2615/* #define MACHINE_no_sched_speculative_load */
2616
766a866c
MM
2617/* General flags. */
2618extern int flag_pic;
354b734b
MM
2619extern int optimize;
2620extern int flag_expensive_optimizations;
a7df97e6 2621extern int frame_pointer_needed;