]>
Commit | Line | Data |
---|---|---|
eabd3262 | 1 | /* Definitions of target machine for GNU compiler, for the HP Spectrum. |
4f72f5da | 2 | Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc. |
8b109b37 | 3 | Contributed by Michael Tiemann (tiemann@cygnus.com) of Cygnus Support |
eabd3262 RK |
4 | and Tim Moore (moore@defmacro.cs.utah.edu) of the Center for |
5 | Software Science at the University of Utah. | |
6 | ||
7 | This file is part of GNU CC. | |
8 | ||
9 | GNU CC is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 1, or (at your option) | |
12 | any later version. | |
13 | ||
14 | GNU CC is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GNU CC; see the file COPYING. If not, write to | |
0e29e3c9 RK |
21 | the Free Software Foundation, 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. */ | |
eabd3262 RK |
23 | |
24 | enum cmp_type /* comparison type */ | |
25 | { | |
26 | CMP_SI, /* compare integers */ | |
27 | CMP_SF, /* compare single precision floats */ | |
28 | CMP_DF, /* compare double precision floats */ | |
29 | CMP_MAX /* max comparison type */ | |
30 | }; | |
31 | ||
279c9bde JL |
32 | /* For long call handling. */ |
33 | extern unsigned int total_code_bytes; | |
34 | ||
c47decad JL |
35 | /* Which processor to schedule for. */ |
36 | ||
37 | enum processor_type | |
38 | { | |
39 | PROCESSOR_700, | |
40 | PROCESSOR_7100, | |
41 | PROCESSOR_7100LC, | |
e14b50ce JQ |
42 | PROCESSOR_7200, |
43 | PROCESSOR_8000 | |
c47decad JL |
44 | }; |
45 | ||
c47decad JL |
46 | /* For -mschedule= option. */ |
47 | extern char *pa_cpu_string; | |
48 | extern enum processor_type pa_cpu; | |
49 | ||
62d65906 JL |
50 | #define pa_cpu_attr ((enum attr_cpu)pa_cpu) |
51 | ||
52 | /* The 700 can only issue a single insn at a time. | |
e14b50ce JQ |
53 | The 7XXX processors can issue two insns at a time. |
54 | The 8000 can issue 4 insns at a time. */ | |
55 | #define ISSUE_RATE \ | |
56 | (pa_cpu == PROCESSOR_700 ? 1 \ | |
57 | : pa_cpu == PROCESSOR_7100 ? 2 \ | |
58 | : pa_cpu == PROCESSOR_7100LC ? 2 \ | |
59 | : pa_cpu == PROCESSOR_7200 ? 2 \ | |
60 | : pa_cpu == PROCESSOR_8000 ? 4 \ | |
61 | : 2) | |
62d65906 | 62 | |
ea3bfbfe JQ |
63 | /* Which architecture to generate code for. */ |
64 | ||
65 | enum architecture_type | |
66 | { | |
67 | ARCHITECTURE_10, | |
68 | ARCHITECTURE_11, | |
69 | ARCHITECTURE_20 | |
70 | }; | |
71 | ||
72 | /* For -march= option. */ | |
73 | extern char *pa_arch_string; | |
74 | extern enum architecture_type pa_arch; | |
75 | ||
eabd3262 RK |
76 | /* Print subsidiary information on the compiler version in use. */ |
77 | ||
e236a9ff | 78 | #define TARGET_VERSION fputs (" (hppa)", stderr); |
eabd3262 | 79 | |
3f8f5a3f | 80 | /* Run-time compilation parameters selecting different hardware subsets. */ |
eabd3262 RK |
81 | |
82 | extern int target_flags; | |
83 | ||
3f8f5a3f | 84 | /* compile code for HP-PA 1.1 ("Snake") */ |
eabd3262 | 85 | |
13ee407e JQ |
86 | #define MASK_PA_11 1 |
87 | #define TARGET_PA_11 (target_flags & MASK_PA_11) | |
eabd3262 | 88 | |
8c0a7019 JL |
89 | /* Disable all FP registers (they all become fixed). This may be necessary |
90 | for compiling kernels which perform lazy context switching of FP regs. | |
5a1c10de | 91 | Note if you use this option and try to perform floating point operations |
8c0a7019 JL |
92 | the compiler will abort! */ |
93 | ||
3723cad9 JL |
94 | #define MASK_DISABLE_FPREGS 2 |
95 | #define TARGET_DISABLE_FPREGS (target_flags & MASK_DISABLE_FPREGS) | |
8c0a7019 | 96 | |
105ce113 JL |
97 | /* Generate code which assumes that calls through function pointers will |
98 | never cross a space boundary. Such assumptions are generally safe for | |
99 | building kernels and statically linked executables. Code compiled with | |
100 | this option will fail miserably if the executable is dynamically linked | |
6a73009d JL |
101 | or uses nested functions! |
102 | ||
956d6950 | 103 | This is also used to trigger aggressive unscaled index addressing. */ |
3723cad9 JL |
104 | #define MASK_NO_SPACE_REGS 4 |
105 | #define TARGET_NO_SPACE_REGS (target_flags & MASK_NO_SPACE_REGS) | |
105ce113 | 106 | |
0a1daad4 | 107 | /* Allow unconditional jumps in the delay slots of call instructions. */ |
3723cad9 JL |
108 | #define MASK_JUMP_IN_DELAY 8 |
109 | #define TARGET_JUMP_IN_DELAY (target_flags & MASK_JUMP_IN_DELAY) | |
0a1daad4 | 110 | |
9e18f575 JL |
111 | /* Optimize for space. Currently this only turns on out of line |
112 | prologues and epilogues. */ | |
3723cad9 JL |
113 | #define MASK_SPACE 16 |
114 | #define TARGET_SPACE (target_flags & MASK_SPACE) | |
9e18f575 | 115 | |
24c6ab1c | 116 | /* Disable indexed addressing modes. */ |
3723cad9 JL |
117 | #define MASK_DISABLE_INDEXING 32 |
118 | #define TARGET_DISABLE_INDEXING (target_flags & MASK_DISABLE_INDEXING) | |
8c0a7019 | 119 | |
2822d96e JL |
120 | /* Emit code which follows the new portable runtime calling conventions |
121 | HP wants everyone to use for ELF objects. If at all possible you want | |
f726ea7d JL |
122 | to avoid this since it's a performance loss for non-prototyped code. |
123 | ||
279c9bde JL |
124 | Note TARGET_PORTABLE_RUNTIME also forces all calls to use inline |
125 | long-call stubs which is quite expensive. */ | |
3723cad9 JL |
126 | #define MASK_PORTABLE_RUNTIME 64 |
127 | #define TARGET_PORTABLE_RUNTIME (target_flags & MASK_PORTABLE_RUNTIME) | |
2822d96e | 128 | |
c87ba671 JL |
129 | /* Emit directives only understood by GAS. This allows parameter |
130 | relocations to work for static functions. There is no way | |
2822d96e | 131 | to make them work the HP assembler at this time. */ |
3723cad9 JL |
132 | #define MASK_GAS 128 |
133 | #define TARGET_GAS (target_flags & MASK_GAS) | |
c87ba671 | 134 | |
74356a72 | 135 | /* Emit code for processors which do not have an FPU. */ |
3723cad9 JL |
136 | #define MASK_SOFT_FLOAT 256 |
137 | #define TARGET_SOFT_FLOAT (target_flags & MASK_SOFT_FLOAT) | |
74356a72 | 138 | |
c3d4f633 JL |
139 | /* Use 3-insn load/store sequences for access to large data segments |
140 | in shared libraries on hpux10. */ | |
3723cad9 JL |
141 | #define MASK_LONG_LOAD_STORE 512 |
142 | #define TARGET_LONG_LOAD_STORE (target_flags & MASK_LONG_LOAD_STORE) | |
c3d4f633 | 143 | |
3aba034b | 144 | /* Use a faster sequence for indirect calls. */ |
3723cad9 JL |
145 | #define MASK_FAST_INDIRECT_CALLS 1024 |
146 | #define TARGET_FAST_INDIRECT_CALLS (target_flags & MASK_FAST_INDIRECT_CALLS) | |
3aba034b | 147 | |
3e056efc | 148 | /* Generate code with big switch statements to avoid out of range branches |
956d6950 | 149 | occurring within the switch table. */ |
3723cad9 JL |
150 | #define MASK_BIG_SWITCH 2048 |
151 | #define TARGET_BIG_SWITCH (target_flags & MASK_BIG_SWITCH) | |
3e056efc | 152 | |
ea3bfbfe JQ |
153 | |
154 | /* Generate code for the HPPA 2.0 architecture. TARGET_PA_11 should also be | |
155 | true when this is true. */ | |
156 | #define MASK_PA_20 4096 | |
157 | #define TARGET_PA_20 (target_flags & MASK_PA_20) | |
158 | ||
eabd3262 RK |
159 | /* Macro to define tables used to set the flags. |
160 | This is a list in braces of pairs in braces, | |
161 | each pair being { "NAME", VALUE } | |
162 | where VALUE is the bits to set or minus the bits to clear. | |
163 | An empty string NAME is used to identify the default VALUE. */ | |
164 | ||
165 | #define TARGET_SWITCHES \ | |
13ee407e | 166 | {{"snake", MASK_PA_11, "Generate PA1.1 code"}, \ |
ea3bfbfe JQ |
167 | {"nosnake", -(MASK_PA_11 | MASK_PA_20), "Generate PA1.0 code"}, \ |
168 | {"pa-risc-1-0", -(MASK_PA_11 | MASK_PA_20), "Generate PA1.0 code"}, \ | |
13ee407e | 169 | {"pa-risc-1-1", MASK_PA_11, "Generate PA1.1 code"}, \ |
ea3bfbfe | 170 | {"pa-risc-2-0", MASK_PA_20, "Generate PA2.0 code. This option requires gas snapshot 19990413 or later"}, \ |
e10dfab2 JL |
171 | {"disable-fpregs", MASK_DISABLE_FPREGS, "Disable FP regs"}, \ |
172 | {"no-disable-fpregs", -MASK_DISABLE_FPREGS, "Do not disable FP regs"},\ | |
173 | {"no-space-regs", MASK_NO_SPACE_REGS, "Disable space regs"}, \ | |
174 | {"space-regs", -MASK_NO_SPACE_REGS, "Do not disable space regs"}, \ | |
175 | {"jump-in-delay", MASK_JUMP_IN_DELAY, "Put jumps in call delay slots"},\ | |
176 | {"no-jump-in-delay", -MASK_JUMP_IN_DELAY, "Do not put jumps in call delay slots"}, \ | |
177 | {"space", MASK_SPACE, "Optimize for code space"}, \ | |
178 | {"no-space", -MASK_SPACE, "Do not optimize for code space"}, \ | |
179 | {"disable-indexing", MASK_DISABLE_INDEXING, "Disable indexed addressing"},\ | |
180 | {"no-disable-indexing", -MASK_DISABLE_INDEXING, "Do not disable indexed addressing"},\ | |
181 | {"portable-runtime", MASK_PORTABLE_RUNTIME, "Use portable calling conventions"}, \ | |
182 | {"no-portable-runtime", -MASK_PORTABLE_RUNTIME, "Do not use portable calling conventions"},\ | |
183 | {"gas", MASK_GAS, "Assume code will be assembled by GAS"}, \ | |
184 | {"no-gas", -MASK_GAS, "Do not assume code will be assembled by GAS"}, \ | |
185 | {"soft-float", MASK_SOFT_FLOAT, "Use software floating point"}, \ | |
186 | {"no-soft-float", -MASK_SOFT_FLOAT, "Do not use software floating point"}, \ | |
187 | {"long-load-store", MASK_LONG_LOAD_STORE, "Emit long load/store sequences"}, \ | |
188 | {"no-long-load-store", -MASK_LONG_LOAD_STORE, "Do not emit long load/store sequences"},\ | |
189 | {"fast-indirect-calls", MASK_FAST_INDIRECT_CALLS, "Generate fast indirect calls"},\ | |
190 | {"no-fast-indirect-calls", -MASK_FAST_INDIRECT_CALLS, "Do not generate fast indirect calls"},\ | |
191 | {"big-switch", MASK_BIG_SWITCH, "Generate code for huge switch statements"}, \ | |
192 | {"no-big-switch", -MASK_BIG_SWITCH, "Do not generate code for huge switch statements"}, \ | |
193 | {"linker-opt", 0, "Enable linker optimizations"}, \ | |
880b8fb8 | 194 | { "", TARGET_DEFAULT | TARGET_CPU_DEFAULT, NULL}} |
eabd3262 | 195 | |
233c0fef | 196 | #ifndef TARGET_DEFAULT |
3723cad9 | 197 | #define TARGET_DEFAULT (MASK_GAS | MASK_JUMP_IN_DELAY) |
233c0fef TG |
198 | #endif |
199 | ||
b34ec578 RK |
200 | #ifndef TARGET_CPU_DEFAULT |
201 | #define TARGET_CPU_DEFAULT 0 | |
202 | #endif | |
203 | ||
c47decad JL |
204 | #define TARGET_OPTIONS \ |
205 | { \ | |
ea3bfbfe JQ |
206 | { "schedule=", &pa_cpu_string, "Specify CPU for scheduling purposes" },\ |
207 | { "arch=", &pa_arch_string, "Specify architecture for code generation. Values are 1.0, 1.1, and 2.0. 2.0 requires gas snapshot 19990413 or later." }\ | |
c47decad JL |
208 | } |
209 | ||
210 | #define OVERRIDE_OPTIONS override_options () | |
211 | ||
233c0fef | 212 | #define DBX_DEBUGGING_INFO |
794b7f56 | 213 | #define DEFAULT_GDB_EXTENSIONS 1 |
233c0fef | 214 | |
75600ead | 215 | /* This is the way other stabs-in-XXX tools do things. We will be |
ddd5a7c1 | 216 | compatible. */ |
75600ead JL |
217 | #define DBX_BLOCKS_FUNCTION_RELATIVE 1 |
218 | ||
a40ed31b | 219 | /* Likewise for linenos. |
abb6b720 JL |
220 | |
221 | We make the first line stab special to avoid adding several | |
222 | gross hacks to GAS. */ | |
75600ead JL |
223 | #undef ASM_OUTPUT_SOURCE_LINE |
224 | #define ASM_OUTPUT_SOURCE_LINE(file, line) \ | |
225 | { static int sym_lineno = 1; \ | |
abb6b720 JL |
226 | static tree last_function_decl = NULL; \ |
227 | if (current_function_decl == last_function_decl) \ | |
228 | fprintf (file, "\t.stabn 68,0,%d,L$M%d-%s\nL$M%d:\n", \ | |
229 | line, sym_lineno, \ | |
230 | XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0) + 1, \ | |
231 | sym_lineno); \ | |
232 | else \ | |
233 | fprintf (file, "\t.stabn 68,0,%d,0\n", line); \ | |
234 | last_function_decl = current_function_decl; \ | |
75600ead JL |
235 | sym_lineno += 1; } |
236 | ||
237 | /* But, to make this work, we have to output the stabs for the function | |
238 | name *first*... */ | |
239 | #define DBX_FUNCTION_FIRST | |
240 | ||
ddd5a7c1 | 241 | /* Only labels should ever begin in column zero. */ |
bb2049d1 RK |
242 | #define ASM_STABS_OP "\t.stabs" |
243 | #define ASM_STABN_OP "\t.stabn" | |
244 | ||
2e7e7121 JL |
245 | /* GDB always assumes the current function's frame begins at the value |
246 | of the stack pointer upon entry to the current function. Accessing | |
6a5c0a8e JL |
247 | local variables and parameters passed on the stack is done using the |
248 | base of the frame + an offset provided by GCC. | |
2e7e7121 JL |
249 | |
250 | For functions which have frame pointers this method works fine; | |
251 | the (frame pointer) == (stack pointer at function entry) and GCC provides | |
252 | an offset relative to the frame pointer. | |
253 | ||
254 | This loses for functions without a frame pointer; GCC provides an offset | |
255 | which is relative to the stack pointer after adjusting for the function's | |
256 | frame size. GDB would prefer the offset to be relative to the value of | |
257 | the stack pointer at the function's entry. Yuk! */ | |
258 | #define DEBUGGER_AUTO_OFFSET(X) \ | |
259 | ((GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) \ | |
260 | + (frame_pointer_needed ? 0 : compute_frame_size (get_frame_size (), 0))) | |
261 | ||
6a5c0a8e JL |
262 | #define DEBUGGER_ARG_OFFSET(OFFSET, X) \ |
263 | ((GET_CODE (X) == PLUS ? OFFSET : 0) \ | |
264 | + (frame_pointer_needed ? 0 : compute_frame_size (get_frame_size (), 0))) | |
265 | ||
ba25ac36 JL |
266 | /* gdb needs a null N_SO at the end of each file for scattered loading. */ |
267 | ||
268 | #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END | |
ad238e4b | 269 | #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \ |
18a686c0 | 270 | text_section (); \ |
ad238e4b | 271 | if (!TARGET_PORTABLE_RUNTIME) \ |
2ac42d3a | 272 | fputs ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \ |
ad238e4b JL |
273 | else \ |
274 | fprintf (FILE, "%s\n", TEXT_SECTION_ASM_OP); \ | |
ba25ac36 | 275 | fprintf (FILE, \ |
ad238e4b | 276 | "\t.stabs \"\",%d,0,0,L$text_end0000\nL$text_end0000:\n", N_SO) |
ba25ac36 | 277 | |
13ee407e | 278 | #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_PA_11) == 0 |
233c0fef | 279 | #define CPP_SPEC "%{msnake:-D__hp9000s700 -D_PA_RISC1_1}\ |
ad238e4b | 280 | %{mpa-risc-1-1:-D__hp9000s700 -D_PA_RISC1_1}\ |
154bba13 TT |
281 | %{!ansi: -D_HPUX_SOURCE -D_HIUX_SOURCE}\ |
282 | %{threads:-D_REENTRANT -D_DCE_THREADS}" | |
233c0fef | 283 | #else |
154bba13 TT |
284 | #define CPP_SPEC "%{!mpa-risc-1-0:%{!mnosnake:%{!msoft-float:-D__hp9000s700 -D_PA_RISC1_1}}} \ |
285 | %{!ansi: -D_HPUX_SOURCE -D_HIUX_SOURCE}\ | |
286 | %{threads:-D_REENTRANT -D_DCE_THREADS}" | |
233c0fef TG |
287 | #endif |
288 | ||
289 | /* Defines for a K&R CC */ | |
290 | ||
233c0fef | 291 | #define CC1_SPEC "%{pg:} %{p:}" |
5a1c10de | 292 | |
ad238e4b | 293 | #define LINK_SPEC "%{mlinker-opt:-O} %{!shared:-u main} %{shared:-b}" |
233c0fef | 294 | |
0fffa5e1 RK |
295 | /* We don't want -lg. */ |
296 | #ifndef LIB_SPEC | |
297 | #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" | |
298 | #endif | |
299 | ||
233c0fef TG |
300 | /* Make gcc agree with <machine/ansi.h> */ |
301 | ||
302 | #define SIZE_TYPE "unsigned int" | |
303 | #define PTRDIFF_TYPE "int" | |
3c9a7b64 JL |
304 | #define WCHAR_TYPE "unsigned int" |
305 | #define WCHAR_TYPE_SIZE 32 | |
233c0fef | 306 | |
4f074454 RK |
307 | /* Show we can debug even without a frame pointer. */ |
308 | #define CAN_DEBUG_WITHOUT_FP | |
233c0fef | 309 | |
746a9efa JL |
310 | /* Machine dependent reorg pass. */ |
311 | #define MACHINE_DEPENDENT_REORG(X) pa_reorg(X) | |
312 | ||
51723711 KG |
313 | /* Prototype function used in MACHINE_DEPENDENT_REORG macro. */ |
314 | void pa_reorg (); | |
315 | ||
316 | /* Prototype function used in various macros. */ | |
317 | int symbolic_operand (); | |
318 | ||
319 | /* Used in insn-*.c. */ | |
320 | int following_call (); | |
321 | int function_label_operand (); | |
322 | int lhs_lshift_cint_operand (); | |
323 | ||
233c0fef TG |
324 | /* Names to predefine in the preprocessor for this target machine. */ |
325 | ||
ad238e4b | 326 | #define CPP_PREDEFINES "-Dhppa -Dhp9000s800 -D__hp9000s800 -Dhp9k8 -Dunix -Dhp9000 -Dhp800 -Dspectrum -DREVARGV -Asystem(unix) -Asystem(bsd) -Acpu(hppa) -Amachine(hppa)" |
68d69835 JM |
327 | |
328 | /* HPUX has a program 'chatr' to list the dependencies of dynamically | |
329 | linked executables and shared libraries. */ | |
330 | #define LDD_SUFFIX "chatr" | |
1b48da0d | 331 | /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl" |
2e91542a JL |
332 | or "static /usr/lib/X11R5/libX11.sl". |
333 | ||
334 | HPUX 10.20 also has lines like "static branch prediction ..." | |
956d6950 | 335 | so we filter that out explicitly. |
2e91542a JL |
336 | |
337 | We also try to bound our search for libraries with marker | |
338 | lines. What a pain. */ | |
68d69835 JM |
339 | #define PARSE_LDD_OUTPUT(PTR) \ |
340 | do { \ | |
2e91542a | 341 | static int in_shlib_list = 0; \ |
68d69835 | 342 | while (*PTR == ' ') PTR++; \ |
2e91542a JL |
343 | if (strncmp (PTR, "shared library list:", \ |
344 | sizeof ("shared library list:") - 1) == 0) \ | |
345 | { \ | |
346 | PTR = 0; \ | |
347 | in_shlib_list = 1; \ | |
348 | } \ | |
349 | else if (strncmp (PTR, "shared library binding:", \ | |
350 | sizeof ("shared library binding:") - 1) == 0)\ | |
351 | { \ | |
352 | PTR = 0; \ | |
353 | in_shlib_list = 0; \ | |
354 | } \ | |
355 | else if (strncmp (PTR, "static branch prediction disabled", \ | |
356 | sizeof ("static branch prediction disabled") - 1) == 0)\ | |
357 | { \ | |
358 | PTR = 0; \ | |
359 | in_shlib_list = 0; \ | |
360 | } \ | |
361 | else if (in_shlib_list \ | |
362 | && strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \ | |
68d69835 JM |
363 | { \ |
364 | PTR += sizeof ("dynamic") - 1; \ | |
365 | while (*p == ' ') PTR++; \ | |
366 | } \ | |
2e91542a JL |
367 | else if (in_shlib_list \ |
368 | && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \ | |
1b48da0d JL |
369 | { \ |
370 | PTR += sizeof ("static") - 1; \ | |
371 | while (*p == ' ') PTR++; \ | |
372 | } \ | |
68d69835 JM |
373 | else \ |
374 | PTR = 0; \ | |
375 | } while (0) | |
eabd3262 RK |
376 | \f |
377 | /* target machine storage layout */ | |
378 | ||
74356a72 | 379 | /* Define for cross-compilation from a host with a different float format |
ddd5a7c1 | 380 | or endianness (e.g. VAX, x86). */ |
74356a72 TG |
381 | #define REAL_ARITHMETIC |
382 | ||
9f9fba36 TG |
383 | /* Define this macro if it is advisable to hold scalars in registers |
384 | in a wider mode than that declared by the program. In such cases, | |
385 | the value is constrained to be within the bounds of the declared | |
386 | type, but kept valid in the wider mode. The signedness of the | |
387 | extension may differ from that of the type. */ | |
388 | ||
389 | #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ | |
390 | if (GET_MODE_CLASS (MODE) == MODE_INT \ | |
391 | && GET_MODE_SIZE (MODE) < 4) \ | |
392 | (MODE) = SImode; | |
393 | ||
eabd3262 RK |
394 | /* Define this if most significant bit is lowest numbered |
395 | in instructions that operate on numbered bit-fields. */ | |
396 | #define BITS_BIG_ENDIAN 1 | |
397 | ||
398 | /* Define this if most significant byte of a word is the lowest numbered. */ | |
23643037 | 399 | /* That is true on the HP-PA. */ |
eabd3262 RK |
400 | #define BYTES_BIG_ENDIAN 1 |
401 | ||
402 | /* Define this if most significant word of a multiword number is lowest | |
403 | numbered. */ | |
eabd3262 RK |
404 | #define WORDS_BIG_ENDIAN 1 |
405 | ||
406 | /* number of bits in an addressable storage unit */ | |
407 | #define BITS_PER_UNIT 8 | |
408 | ||
409 | /* Width in bits of a "word", which is the contents of a machine register. | |
410 | Note that this is not necessarily the width of data type `int'; | |
411 | if using 16-bit ints on a 68000, this would still be 32. | |
412 | But on a machine with 16-bit registers, this would be 16. */ | |
413 | #define BITS_PER_WORD 32 | |
414 | ||
415 | /* Width of a word, in units (bytes). */ | |
416 | #define UNITS_PER_WORD 4 | |
417 | ||
418 | /* Width in bits of a pointer. | |
419 | See also the macro `Pmode' defined below. */ | |
420 | #define POINTER_SIZE 32 | |
421 | ||
422 | /* Allocation boundary (in *bits*) for storing arguments in argument list. */ | |
423 | #define PARM_BOUNDARY 32 | |
424 | ||
425 | /* Largest alignment required for any stack parameter, in bits. | |
426 | Don't define this if it is equal to PARM_BOUNDARY */ | |
427 | #define MAX_PARM_BOUNDARY 64 | |
428 | ||
981e5cd9 JL |
429 | /* Boundary (in *bits*) on which stack pointer is always aligned; |
430 | certain optimizations in combine depend on this. | |
431 | ||
432 | GCC for the PA always rounds its stacks to a 512bit boundary, | |
433 | but that happens late in the compilation process. */ | |
434 | #define STACK_BOUNDARY 64 | |
eabd3262 RK |
435 | |
436 | /* Allocation boundary (in *bits*) for the code of a function. */ | |
437 | #define FUNCTION_BOUNDARY 32 | |
438 | ||
439 | /* Alignment of field after `int : 0' in a structure. */ | |
440 | #define EMPTY_FIELD_BOUNDARY 32 | |
441 | ||
442 | /* Every structure's size must be a multiple of this. */ | |
443 | #define STRUCTURE_SIZE_BOUNDARY 8 | |
444 | ||
445 | /* A bitfield declared as `int' forces `int' alignment for the struct. */ | |
446 | #define PCC_BITFIELD_TYPE_MATTERS 1 | |
447 | ||
448 | /* No data type wants to be aligned rounder than this. */ | |
449 | #define BIGGEST_ALIGNMENT 64 | |
450 | ||
a27d3fef JL |
451 | /* The .align directive in the HP assembler allows up to a 32 alignment. */ |
452 | #define MAX_OFILE_ALIGNMENT 32768 | |
453 | ||
eabd3262 RK |
454 | /* Get around hp-ux assembler bug, and make strcpy of constants fast. */ |
455 | #define CONSTANT_ALIGNMENT(CODE, TYPEALIGN) \ | |
456 | ((TYPEALIGN) < 32 ? 32 : (TYPEALIGN)) | |
457 | ||
458 | /* Make arrays of chars word-aligned for the same reasons. */ | |
459 | #define DATA_ALIGNMENT(TYPE, ALIGN) \ | |
460 | (TREE_CODE (TYPE) == ARRAY_TYPE \ | |
461 | && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \ | |
462 | && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) | |
463 | ||
464 | ||
465 | /* Set this nonzero if move instructions will actually fail to work | |
466 | when given unaligned data. */ | |
467 | #define STRICT_ALIGNMENT 1 | |
468 | ||
469 | /* Generate calls to memcpy, memcmp and memset. */ | |
470 | #define TARGET_MEM_FUNCTIONS | |
471 | \f | |
472 | /* Standard register usage. */ | |
473 | ||
474 | /* Number of actual hardware registers. | |
475 | The hardware registers are assigned numbers for the compiler | |
476 | from 0 to just below FIRST_PSEUDO_REGISTER. | |
477 | All registers that the compiler knows about must be given numbers, | |
478 | even those that are not normally considered general registers. | |
479 | ||
3f8f5a3f | 480 | HP-PA 1.0 has 32 fullword registers and 16 floating point |
eabd3262 RK |
481 | registers. The floating point registers hold either word or double |
482 | word values. | |
5a1c10de | 483 | |
eabd3262 | 484 | 16 additional registers are reserved. |
5a1c10de | 485 | |
3f8f5a3f | 486 | HP-PA 1.1 has 32 fullword registers and 32 floating point |
eabd3262 RK |
487 | registers. However, the floating point registers behave |
488 | differently: the left and right halves of registers are addressable | |
489 | as 32 bit registers. So, we will set things up like the 68k which | |
490 | has different fp units: define separate register sets for the 1.0 | |
491 | and 1.1 fp units. */ | |
492 | ||
a40ed31b TG |
493 | #define FIRST_PSEUDO_REGISTER 89 /* 32 general regs + 56 fp regs + |
494 | + 1 shift reg */ | |
eabd3262 RK |
495 | |
496 | /* 1 for registers that have pervasive standard uses | |
497 | and are not available for the register allocator. | |
498 | ||
3f8f5a3f | 499 | On the HP-PA, these are: |
eabd3262 RK |
500 | Reg 0 = 0 (hardware). However, 0 is used for condition code, |
501 | so is not fixed. | |
502 | Reg 1 = ADDIL target/Temporary (hardware). | |
503 | Reg 2 = Return Pointer | |
75600ead JL |
504 | Reg 3 = Frame Pointer |
505 | Reg 4 = Frame Pointer (>8k varying frame with HP compilers only) | |
506 | Reg 4-18 = Preserved Registers | |
d2a94ec0 TM |
507 | Reg 19 = Linkage Table Register in HPUX 8.0 shared library scheme. |
508 | Reg 20-22 = Temporary Registers | |
eabd3262 RK |
509 | Reg 23-26 = Temporary/Parameter Registers |
510 | Reg 27 = Global Data Pointer (hp) | |
511 | Reg 28 = Temporary/???/Return Value register | |
451d86c2 | 512 | Reg 29 = Temporary/Static Chain/Return Value register #2 |
eabd3262 RK |
513 | Reg 30 = stack pointer |
514 | Reg 31 = Temporary/Millicode Return Pointer (hp) | |
515 | ||
c2ae03cb | 516 | Freg 0-3 = Status Registers -- Not known to the compiler. |
eabd3262 RK |
517 | Freg 4-7 = Arguments/Return Value |
518 | Freg 8-11 = Temporary Registers | |
519 | Freg 12-15 = Preserved Registers | |
520 | ||
521 | Freg 16-31 = Reserved | |
522 | ||
523 | On the Snake, fp regs are | |
524 | ||
c2ae03cb | 525 | Freg 0-3 = Status Registers -- Not known to the compiler. |
eabd3262 RK |
526 | Freg 4L-7R = Arguments/Return Value |
527 | Freg 8L-11R = Temporary Registers | |
c2ae03cb JL |
528 | Freg 12L-21R = Preserved Registers |
529 | Freg 22L-31R = Temporary Registers | |
eabd3262 RK |
530 | |
531 | */ | |
532 | ||
533 | #define FIXED_REGISTERS \ | |
527986c9 | 534 | {0, 0, 0, 0, 0, 0, 0, 0, \ |
eabd3262 RK |
535 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
536 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
d39b6854 | 537 | 0, 0, 0, 1, 0, 0, 1, 0, \ |
a40ed31b | 538 | /* fp registers */ \ |
eabd3262 RK |
539 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
540 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
541 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
542 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
543 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
544 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
545 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
e061ef25 | 546 | 0} |
eabd3262 RK |
547 | |
548 | /* 1 for registers not available across function calls. | |
549 | These must include the FIXED_REGISTERS and also any | |
550 | registers that can be used without being saved. | |
551 | The latter must include the registers where values are returned | |
552 | and the register where structure-value addresses are passed. | |
553 | Aside from that, you can include as many other registers as you like. */ | |
554 | #define CALL_USED_REGISTERS \ | |
527986c9 | 555 | {1, 1, 1, 0, 0, 0, 0, 0, \ |
eabd3262 RK |
556 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
557 | 0, 0, 0, 1, 1, 1, 1, 1, \ | |
558 | 1, 1, 1, 1, 1, 1, 1, 1, \ | |
a40ed31b | 559 | /* fp registers */ \ |
eabd3262 RK |
560 | 1, 1, 1, 1, 1, 1, 1, 1, \ |
561 | 1, 1, 1, 1, 1, 1, 1, 1, \ | |
eabd3262 RK |
562 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
563 | 0, 0, 0, 0, 0, 0, 0, 0, \ | |
564 | 0, 0, 0, 0, 1, 1, 1, 1, \ | |
565 | 1, 1, 1, 1, 1, 1, 1, 1, \ | |
566 | 1, 1, 1, 1, 1, 1, 1, 1, \ | |
5a1c10de | 567 | 1} |
eabd3262 | 568 | |
eabd3262 RK |
569 | #define CONDITIONAL_REGISTER_USAGE \ |
570 | { \ | |
13ee407e | 571 | if (!TARGET_PA_11) \ |
5345f91a TG |
572 | { \ |
573 | for (i = 56; i < 88; i++) \ | |
574 | fixed_regs[i] = call_used_regs[i] = 1; \ | |
575 | for (i = 33; i < 88; i += 2) \ | |
576 | fixed_regs[i] = call_used_regs[i] = 1; \ | |
577 | } \ | |
859d9ce4 | 578 | if (TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)\ |
5345f91a TG |
579 | { \ |
580 | for (i = 32; i < 88; i++) \ | |
581 | fixed_regs[i] = call_used_regs[i] = 1; \ | |
582 | } \ | |
8381cd4c | 583 | if (flag_pic) \ |
71fce386 RK |
584 | { \ |
585 | fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ | |
586 | fixed_regs[PIC_OFFSET_TABLE_REGNUM_SAVED] = 1;\ | |
587 | } \ | |
eabd3262 RK |
588 | } |
589 | ||
a40ed31b | 590 | /* Allocate the call used registers first. This should minimize |
eabd3262 RK |
591 | the number of registers that need to be saved (as call used |
592 | registers will generally not be allocated across a call). | |
593 | ||
c2ae03cb | 594 | Experimentation has shown slightly better results by allocating |
2faa455b JQ |
595 | FP registers first. |
596 | ||
597 | FP registers are ordered so that all L registers are selected before | |
598 | R registers. This works around a false dependency interlock on the | |
599 | PA8000 when accessing the high and low parts of an FP register | |
600 | independently. */ | |
eabd3262 RK |
601 | |
602 | #define REG_ALLOC_ORDER \ | |
a40ed31b TG |
603 | { \ |
604 | /* caller-saved fp regs. */ \ | |
2faa455b JQ |
605 | 68, 70, 72, 74, 76, 78, 80, 82, \ |
606 | 84, 86, 40, 42, 44, 46, 32, 34, \ | |
607 | 36, 38, \ | |
608 | 69, 71, 73, 75, 77, 79, 81, 83, \ | |
609 | 85, 87, 41, 43, 45, 47, 33, 35, \ | |
610 | 37, 39, \ | |
c2ae03cb JL |
611 | /* caller-saved general regs. */ \ |
612 | 19, 20, 21, 22, 23, 24, 25, 26, \ | |
613 | 27, 28, 29, 31, 2, \ | |
a40ed31b | 614 | /* callee-saved fp regs. */ \ |
2faa455b JQ |
615 | 48, 50, 52, 54, 56, 58, 60, 62, \ |
616 | 64, 66, \ | |
617 | 49, 51, 53, 55, 57, 59, 61, 63, \ | |
618 | 65, 67, \ | |
c2ae03cb | 619 | /* callee-saved general regs. */ \ |
527986c9 JL |
620 | 3, 4, 5, 6, 7, 8, 9, 10, \ |
621 | 11, 12, 13, 14, 15, 16, 17, 18, \ | |
c2ae03cb | 622 | /* special registers. */ \ |
a40ed31b | 623 | 1, 30, 0, 88} |
eabd3262 RK |
624 | |
625 | ||
5345f91a TG |
626 | /* True if register is floating-point. */ |
627 | #define FP_REGNO_P(N) ((N) >= 32 && (N) <= 87) | |
628 | ||
eabd3262 RK |
629 | /* Return number of consecutive hard regs needed starting at reg REGNO |
630 | to hold something of mode MODE. | |
631 | This is ordinarily the length in words of a value of mode MODE | |
632 | but can be less for certain modes in special long registers. | |
633 | ||
3f8f5a3f | 634 | On the HP-PA, ordinary registers hold 32 bits worth; |
eabd3262 RK |
635 | The floating point registers are 64 bits wide. Snake fp regs are 32 |
636 | bits wide */ | |
5345f91a | 637 | #define HARD_REGNO_NREGS(REGNO, MODE) \ |
13ee407e | 638 | (!TARGET_PA_11 && FP_REGNO_P (REGNO) ? 1 \ |
5345f91a | 639 | : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) |
eabd3262 RK |
640 | |
641 | /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. | |
3f8f5a3f | 642 | On the HP-PA, the cpu registers can hold any mode. We |
eabd3262 | 643 | force this to be an even register is it cannot hold the full mode. */ |
d2a94ec0 TM |
644 | #define HARD_REGNO_MODE_OK(REGNO, MODE) \ |
645 | ((REGNO) == 0 ? (MODE) == CCmode || (MODE) == CCFPmode \ | |
5345f91a | 646 | /* On 1.0 machines, don't allow wide non-fp modes in fp regs. */ \ |
13ee407e | 647 | : !TARGET_PA_11 && FP_REGNO_P (REGNO) \ |
5345f91a TG |
648 | ? GET_MODE_SIZE (MODE) <= 4 || GET_MODE_CLASS (MODE) == MODE_FLOAT \ |
649 | /* Make wide modes be in aligned registers. */ \ | |
a40ed31b | 650 | : GET_MODE_SIZE (MODE) <= 4 || ((REGNO) & 1) == 0) |
eabd3262 RK |
651 | |
652 | /* Value is 1 if it is a good idea to tie two pseudo registers | |
653 | when one has mode MODE1 and one has mode MODE2. | |
654 | If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, | |
655 | for any hard reg, then this must be 0 for correct output. */ | |
656 | #define MODES_TIEABLE_P(MODE1, MODE2) \ | |
3518f904 | 657 | (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2)) |
eabd3262 RK |
658 | |
659 | /* Specify the registers used for certain standard purposes. | |
660 | The values of these macros are register numbers. */ | |
661 | ||
3f8f5a3f | 662 | /* The HP-PA pc isn't overloaded on a register that the compiler knows about. */ |
eabd3262 RK |
663 | /* #define PC_REGNUM */ |
664 | ||
665 | /* Register to use for pushing function arguments. */ | |
666 | #define STACK_POINTER_REGNUM 30 | |
667 | ||
668 | /* Base register for access to local variables of the function. */ | |
75600ead | 669 | #define FRAME_POINTER_REGNUM 3 |
eabd3262 | 670 | |
e63ffc38 | 671 | /* Value should be nonzero if functions must have frame pointers. */ |
9e18f575 | 672 | #define FRAME_POINTER_REQUIRED \ |
e63ffc38 | 673 | (current_function_calls_alloca) |
eabd3262 RK |
674 | |
675 | /* C statement to store the difference between the frame pointer | |
676 | and the stack pointer values immediately after the function prologue. | |
677 | ||
678 | Note, we always pretend that this is a leaf function because if | |
679 | it's not, there's no point in trying to eliminate the | |
680 | frame pointer. If it is a leaf function, we guessed right! */ | |
681 | #define INITIAL_FRAME_POINTER_OFFSET(VAR) \ | |
86daf4a6 | 682 | do {(VAR) = - compute_frame_size (get_frame_size (), 0);} while (0) |
eabd3262 RK |
683 | |
684 | /* Base register for access to arguments of the function. */ | |
75600ead | 685 | #define ARG_POINTER_REGNUM 3 |
eabd3262 RK |
686 | |
687 | /* Register in which static-chain is passed to a function. */ | |
688 | /* ??? */ | |
689 | #define STATIC_CHAIN_REGNUM 29 | |
690 | ||
691 | /* Register which holds offset table for position-independent | |
692 | data references. */ | |
693 | ||
d2a94ec0 | 694 | #define PIC_OFFSET_TABLE_REGNUM 19 |
6bb36601 | 695 | #define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 1 |
eabd3262 | 696 | |
71fce386 RK |
697 | /* Register into which we save the PIC_OFFEST_TABLE_REGNUM so that it |
698 | can be restore across function calls. */ | |
699 | #define PIC_OFFSET_TABLE_REGNUM_SAVED 4 | |
eabd3262 | 700 | |
11734ce8 | 701 | /* SOM ABI says that objects larger than 64 bits are returned in memory. */ |
451d86c2 | 702 | #define DEFAULT_PCC_STRUCT_RETURN 0 |
11734ce8 | 703 | #define RETURN_IN_MEMORY(TYPE) \ |
0821c881 | 704 | (int_size_in_bytes (TYPE) > 8) |
11734ce8 | 705 | |
eabd3262 RK |
706 | /* Register in which address to store a structure value |
707 | is passed to a function. */ | |
708 | #define STRUCT_VALUE_REGNUM 28 | |
709 | \f | |
710 | /* Define the classes of registers for register constraints in the | |
711 | machine description. Also define ranges of constants. | |
712 | ||
713 | One of the classes must always be named ALL_REGS and include all hard regs. | |
714 | If there is more than one class, another class must be named NO_REGS | |
715 | and contain no registers. | |
716 | ||
717 | The name GENERAL_REGS must be the name of a class (or an alias for | |
718 | another name such as ALL_REGS). This is the class of registers | |
719 | that is allowed by "g" or "r" in a register constraint. | |
720 | Also, registers outside this class are allocated only when | |
721 | instructions express preferences for them. | |
722 | ||
723 | The classes must be numbered in nondecreasing order; that is, | |
724 | a larger-numbered class must never be contained completely | |
725 | in a smaller-numbered class. | |
726 | ||
727 | For any two classes, it is very desirable that there be another | |
728 | class that represents their union. */ | |
729 | ||
3f8f5a3f | 730 | /* The HP-PA has four kinds of registers: general regs, 1.0 fp regs, |
eabd3262 | 731 | 1.1 fp regs, and the high 1.1 fp regs, to which the operands of |
a40ed31b | 732 | fmpyadd and fmpysub are restricted. */ |
eabd3262 | 733 | |
548e44b3 | 734 | enum reg_class { NO_REGS, R1_REGS, GENERAL_REGS, FPUPPER_REGS, FP_REGS, GENERAL_OR_FP_REGS, |
5345f91a | 735 | SHIFT_REGS, ALL_REGS, LIM_REG_CLASSES}; |
eabd3262 RK |
736 | |
737 | #define N_REG_CLASSES (int) LIM_REG_CLASSES | |
738 | ||
739 | /* Give names of register classes as strings for dump file. */ | |
740 | ||
741 | #define REG_CLASS_NAMES \ | |
548e44b3 | 742 | {"NO_REGS", "R1_REGS", "GENERAL_REGS", "FPUPPER_REGS", "FP_REGS", \ |
5345f91a | 743 | "GENERAL_OR_FP_REGS", "SHIFT_REGS", "ALL_REGS"} |
eabd3262 RK |
744 | |
745 | /* Define which registers fit in which classes. | |
746 | This is an initializer for a vector of HARD_REG_SET | |
747 | of length N_REG_CLASSES. Register 0, the "condition code" register, | |
748 | is in no class. */ | |
749 | ||
750 | #define REG_CLASS_CONTENTS \ | |
a40ed31b TG |
751 | {{0x00000000, 0x00000000, 0x00000000}, /* NO_REGS */ \ |
752 | {0x00000002, 0x00000000, 0x00000000}, /* R1_REGS */ \ | |
753 | {0xfffffffe, 0x00000000, 0x00000000}, /* GENERAL_REGS */ \ | |
548e44b3 | 754 | {0x00000000, 0xff000000, 0x00ffffff}, /* FPUPPER_REGS */ \ |
5345f91a TG |
755 | {0x00000000, 0xffffffff, 0x00ffffff}, /* FP_REGS */ \ |
756 | {0xfffffffe, 0xffffffff, 0x00ffffff}, /* GENERAL_OR_FP_REGS */ \ | |
a40ed31b TG |
757 | {0x00000000, 0x00000000, 0x01000000}, /* SHIFT_REGS */ \ |
758 | {0xfffffffe, 0xffffffff, 0x01ffffff}} /* ALL_REGS */ | |
eabd3262 RK |
759 | |
760 | /* The same information, inverted: | |
761 | Return the class number of the smallest class containing | |
762 | reg number REGNO. This could be a conditional expression | |
763 | or could index an array. */ | |
764 | ||
a40ed31b TG |
765 | #define REGNO_REG_CLASS(REGNO) \ |
766 | ((REGNO) == 0 ? NO_REGS \ | |
767 | : (REGNO) == 1 ? R1_REGS \ | |
768 | : (REGNO) < 32 ? GENERAL_REGS \ | |
548e44b3 LV |
769 | : (REGNO) < 56 ? FP_REGS \ |
770 | : (REGNO) < 88 ? FPUPPER_REGS \ | |
eabd3262 RK |
771 | : SHIFT_REGS) |
772 | ||
773 | /* The class value for index registers, and the one for base regs. */ | |
774 | #define INDEX_REG_CLASS GENERAL_REGS | |
775 | #define BASE_REG_CLASS GENERAL_REGS | |
776 | ||
5de7c240 | 777 | #define FP_REG_CLASS_P(CLASS) \ |
548e44b3 | 778 | ((CLASS) == FP_REGS || (CLASS) == FPUPPER_REGS) |
eabd3262 | 779 | |
5345f91a TG |
780 | /* Get reg_class from a letter such as appears in the machine description. */ |
781 | /* Keep 'x' for backward compatibility with user asm. */ | |
eabd3262 | 782 | #define REG_CLASS_FROM_LETTER(C) \ |
5345f91a | 783 | ((C) == 'f' ? FP_REGS : \ |
548e44b3 | 784 | (C) == 'y' ? FPUPPER_REGS : \ |
5345f91a | 785 | (C) == 'x' ? FP_REGS : \ |
a40ed31b TG |
786 | (C) == 'q' ? SHIFT_REGS : \ |
787 | (C) == 'a' ? R1_REGS : \ | |
a40ed31b | 788 | (C) == 'Z' ? ALL_REGS : NO_REGS) |
eabd3262 RK |
789 | |
790 | /* The letters I, J, K, L and M in a register constraint string | |
791 | can be used to stand for particular ranges of immediate operands. | |
792 | This macro defines what the ranges are. | |
793 | C is the letter, and VALUE is a constant value. | |
794 | Return 1 if VALUE is in the range specified by C. | |
795 | ||
eabd3262 RK |
796 | `I' is used for the 11 bit constants. |
797 | `J' is used for the 14 bit constants. | |
7e8b33d9 | 798 | `K' is used for values that can be moved with a zdepi insn. |
eabd3262 | 799 | `L' is used for the 5 bit constants. |
7e8b33d9 TG |
800 | `M' is used for 0. |
801 | `N' is used for values with the least significant 11 bits equal to zero. | |
802 | `O' is used for numbers n such that n+1 is a power of 2. | |
803 | */ | |
eabd3262 RK |
804 | |
805 | #define CONST_OK_FOR_LETTER_P(VALUE, C) \ | |
7e8b33d9 TG |
806 | ((C) == 'I' ? VAL_11_BITS_P (VALUE) \ |
807 | : (C) == 'J' ? VAL_14_BITS_P (VALUE) \ | |
808 | : (C) == 'K' ? zdepi_cint_p (VALUE) \ | |
809 | : (C) == 'L' ? VAL_5_BITS_P (VALUE) \ | |
eabd3262 | 810 | : (C) == 'M' ? (VALUE) == 0 \ |
7e8b33d9 | 811 | : (C) == 'N' ? ((VALUE) & 0x7ff) == 0 \ |
7254dbd4 | 812 | : (C) == 'O' ? (((VALUE) & ((VALUE) + 1)) == 0) \ |
7e8b33d9 | 813 | : (C) == 'P' ? and_mask_p (VALUE) \ |
eabd3262 RK |
814 | : 0) |
815 | ||
51723711 KG |
816 | /* Prototype function used in macro CONST_OK_FOR_LETTER_P. */ |
817 | int zdepi_cint_p (); | |
818 | ||
af69aabb JL |
819 | /* Similar, but for floating or large integer constants, and defining letters |
820 | G and H. Here VALUE is the CONST_DOUBLE rtx itself. | |
eabd3262 | 821 | |
af69aabb JL |
822 | For PA, `G' is the floating-point constant zero. `H' is undefined. */ |
823 | ||
824 | #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ | |
825 | ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT \ | |
826 | && (VALUE) == CONST0_RTX (GET_MODE (VALUE))) \ | |
827 | : 0) | |
eabd3262 RK |
828 | |
829 | /* Given an rtx X being reloaded into a reg required to be | |
830 | in class CLASS, return the class of reg to actually use. | |
831 | In general this is just CLASS; but on some machines | |
832 | in some cases it is preferable to use a more restrictive class. */ | |
833 | #define PREFERRED_RELOAD_CLASS(X,CLASS) (CLASS) | |
834 | ||
835 | /* Return the register class of a scratch register needed to copy IN into | |
e236a9ff JL |
836 | or out of a register in CLASS in MODE. If it can be done directly |
837 | NO_REGS is returned. | |
838 | ||
839 | Avoid doing any work for the common case calls. */ | |
eabd3262 RK |
840 | |
841 | #define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \ | |
e236a9ff JL |
842 | ((CLASS == BASE_REG_CLASS && GET_CODE (IN) == REG \ |
843 | && REGNO (IN) < FIRST_PSEUDO_REGISTER) \ | |
844 | ? NO_REGS : secondary_reload_class (CLASS, MODE, IN)) | |
eabd3262 | 845 | |
5a1c10de | 846 | /* On the PA it is not possible to directly move data between |
6b0ae684 JL |
847 | GENERAL_REGS and FP_REGS. */ |
848 | #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \ | |
a40ed31b | 849 | (FP_REG_CLASS_P (CLASS1) != FP_REG_CLASS_P (CLASS2)) |
6b0ae684 JL |
850 | |
851 | /* Return the stack location to use for secondary memory needed reloads. */ | |
852 | #define SECONDARY_MEMORY_NEEDED_RTX(MODE) \ | |
ad2c71b7 | 853 | gen_rtx_MEM (MODE, gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (-16))) |
6b0ae684 | 854 | |
eabd3262 RK |
855 | /* Return the maximum number of consecutive registers |
856 | needed to represent mode MODE in a register of class CLASS. */ | |
5345f91a | 857 | #define CLASS_MAX_NREGS(CLASS, MODE) \ |
13ee407e | 858 | (!TARGET_PA_11 && ((CLASS) == FP_REGS || (CLASS) == FPUPPER_REGS) ? 1 : \ |
5345f91a | 859 | ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) |
eabd3262 RK |
860 | \f |
861 | /* Stack layout; function entry, exit and calling. */ | |
862 | ||
863 | /* Define this if pushing a word on the stack | |
864 | makes the stack pointer a smaller address. */ | |
865 | /* #define STACK_GROWS_DOWNWARD */ | |
866 | ||
867 | /* Believe it or not. */ | |
868 | #define ARGS_GROW_DOWNWARD | |
869 | ||
870 | /* Define this if the nominal address of the stack frame | |
871 | is at the high-address end of the local variables; | |
872 | that is, each additional local variable allocated | |
873 | goes at a more negative offset in the frame. */ | |
874 | /* #define FRAME_GROWS_DOWNWARD */ | |
875 | ||
876 | /* Offset within stack frame to start allocating local variables at. | |
877 | If FRAME_GROWS_DOWNWARD, this is the offset to the END of the | |
878 | first local allocated. Otherwise, it is the offset to the BEGINNING | |
879 | of the first local allocated. */ | |
880 | #define STARTING_FRAME_OFFSET 8 | |
881 | ||
882 | /* If we generate an insn to push BYTES bytes, | |
883 | this says how many the stack pointer really advances by. | |
3f8f5a3f | 884 | On the HP-PA, don't define this because there are no push insns. */ |
eabd3262 RK |
885 | /* #define PUSH_ROUNDING(BYTES) */ |
886 | ||
887 | /* Offset of first parameter from the argument pointer register value. | |
888 | This value will be negated because the arguments grow down. | |
889 | Also note that on STACK_GROWS_UPWARD machines (such as this one) | |
890 | this is the distance from the frame pointer to the end of the first | |
891 | argument, not it's beginning. To get the real offset of the first | |
892 | argument, the size of the argument must be added. | |
893 | ||
894 | ??? Have to check on this.*/ | |
895 | ||
5a1c10de | 896 | #define FIRST_PARM_OFFSET(FNDECL) -32 |
eabd3262 RK |
897 | |
898 | /* Absolute value of offset from top-of-stack address to location to store the | |
899 | function parameter if it can't go in a register. | |
900 | Addresses for following parameters are computed relative to this one. */ | |
5a1c10de | 901 | #define FIRST_PARM_CALLER_OFFSET(FNDECL) -32 |
eabd3262 RK |
902 | |
903 | ||
904 | /* When a parameter is passed in a register, stack space is still | |
905 | allocated for it. */ | |
906 | #define REG_PARM_STACK_SPACE(DECL) 16 | |
907 | ||
908 | /* Define this if the above stack space is to be considered part of the | |
909 | space allocated by the caller. */ | |
910 | #define OUTGOING_REG_PARM_STACK_SPACE | |
911 | ||
912 | /* Keep the stack pointer constant throughout the function. | |
913 | This is both an optimization and a necessity: longjmp | |
914 | doesn't behave itself when the stack pointer moves within | |
915 | the function! */ | |
916 | #define ACCUMULATE_OUTGOING_ARGS | |
5a1c10de TG |
917 | |
918 | /* The weird HPPA calling conventions require a minimum of 48 bytes on | |
eabd3262 RK |
919 | the stack: 16 bytes for register saves, and 32 bytes for magic. |
920 | This is the difference between the logical top of stack and the | |
5a1c10de | 921 | actual sp. */ |
eabd3262 RK |
922 | #define STACK_POINTER_OFFSET -32 |
923 | ||
924 | #define STACK_DYNAMIC_OFFSET(FNDECL) \ | |
925 | ((STACK_POINTER_OFFSET) - current_function_outgoing_args_size) | |
926 | ||
927 | /* Value is 1 if returning from a function call automatically | |
928 | pops the arguments described by the number-of-args field in the call. | |
8b109b37 | 929 | FUNDECL is the declaration node of the function (as a tree), |
eabd3262 RK |
930 | FUNTYPE is the data type of the function (as a tree), |
931 | or for a library call it is an identifier node for the subroutine name. */ | |
932 | ||
8b109b37 | 933 | #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0 |
eabd3262 RK |
934 | |
935 | /* Define how to find the value returned by a function. | |
936 | VALTYPE is the data type of the value (as a tree). | |
937 | If the precise function being called is known, FUNC is its FUNCTION_DECL; | |
938 | otherwise, FUNC is 0. */ | |
939 | ||
3f8f5a3f | 940 | /* On the HP-PA the value is found in register(s) 28(-29), unless |
c2ae03cb | 941 | the mode is SF or DF. Then the value is returned in fr4 (32, ) */ |
eabd3262 RK |
942 | |
943 | ||
944 | #define FUNCTION_VALUE(VALTYPE, FUNC) \ | |
ad2c71b7 JL |
945 | gen_rtx_REG (TYPE_MODE (VALTYPE), ((! TARGET_SOFT_FLOAT \ |
946 | && (TYPE_MODE (VALTYPE) == SFmode || \ | |
947 | TYPE_MODE (VALTYPE) == DFmode)) ? \ | |
948 | 32 : 28)) | |
eabd3262 | 949 | |
eabd3262 RK |
950 | /* Define how to find the value returned by a library function |
951 | assuming the value has mode MODE. */ | |
952 | ||
74356a72 | 953 | #define LIBCALL_VALUE(MODE) \ |
ad2c71b7 JL |
954 | gen_rtx_REG (MODE, \ |
955 | (! TARGET_SOFT_FLOAT \ | |
956 | && ((MODE) == SFmode || (MODE) == DFmode) ? 32 : 28)) | |
eabd3262 RK |
957 | |
958 | /* 1 if N is a possible register number for a function value | |
959 | as seen by the caller. */ | |
960 | ||
a40ed31b | 961 | #define FUNCTION_VALUE_REGNO_P(N) \ |
74356a72 | 962 | ((N) == 28 || (! TARGET_SOFT_FLOAT && (N) == 32)) |
eabd3262 RK |
963 | |
964 | /* 1 if N is a possible register number for function argument passing. */ | |
965 | ||
a40ed31b | 966 | #define FUNCTION_ARG_REGNO_P(N) \ |
74356a72 | 967 | (((N) >= 23 && (N) <= 26) || (! TARGET_SOFT_FLOAT && (N) >= 32 && (N) <= 39)) |
eabd3262 RK |
968 | \f |
969 | /* Define a data type for recording info about an argument list | |
970 | during the scan of that argument list. This data type should | |
971 | hold all necessary information about the function itself | |
972 | and about the args processed so far, enough to enable macros | |
973 | such as FUNCTION_ARG to determine where the next arg should go. | |
974 | ||
3f8f5a3f | 975 | On the HP-PA, this is a single integer, which is a number of words |
eabd3262 RK |
976 | of arguments scanned so far (including the invisible argument, |
977 | if any, which holds the structure-value-address). | |
978 | Thus 4 or more means all following args should go on the stack. */ | |
979 | ||
2c7ee1a6 | 980 | struct hppa_args {int words, nargs_prototype, indirect; }; |
2822d96e JL |
981 | |
982 | #define CUMULATIVE_ARGS struct hppa_args | |
eabd3262 RK |
983 | |
984 | /* Initialize a variable CUM of type CUMULATIVE_ARGS | |
985 | for a call to a function whose data type is FNTYPE. | |
2822d96e | 986 | For a library call, FNTYPE is 0. */ |
eabd3262 | 987 | |
2c7ee1a6 | 988 | #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \ |
2822d96e | 989 | (CUM).words = 0, \ |
2c7ee1a6 | 990 | (CUM).indirect = INDIRECT, \ |
2822d96e JL |
991 | (CUM).nargs_prototype = (FNTYPE && TYPE_ARG_TYPES (FNTYPE) \ |
992 | ? (list_length (TYPE_ARG_TYPES (FNTYPE)) - 1 \ | |
993 | + (TYPE_MODE (TREE_TYPE (FNTYPE)) == BLKmode \ | |
994 | || RETURN_IN_MEMORY (TREE_TYPE (FNTYPE)))) \ | |
995 | : 0) | |
996 | ||
997 | ||
998 | ||
999 | /* Similar, but when scanning the definition of a procedure. We always | |
bd625e21 | 1000 | set NARGS_PROTOTYPE large so we never return a PARALLEL. */ |
2822d96e JL |
1001 | |
1002 | #define INIT_CUMULATIVE_INCOMING_ARGS(CUM,FNTYPE,IGNORE) \ | |
1003 | (CUM).words = 0, \ | |
a5bbd4b8 | 1004 | (CUM).indirect = 0, \ |
2822d96e | 1005 | (CUM).nargs_prototype = 1000 |
eabd3262 RK |
1006 | |
1007 | /* Figure out the size in words of the function argument. */ | |
1008 | ||
1009 | #define FUNCTION_ARG_SIZE(MODE, TYPE) \ | |
1010 | ((((MODE) != BLKmode ? GET_MODE_SIZE (MODE) : int_size_in_bytes (TYPE))+3)/4) | |
1011 | ||
1012 | /* Update the data in CUM to advance over an argument | |
1013 | of mode MODE and data type TYPE. | |
1014 | (TYPE is null for libcalls where that information may not be available.) */ | |
1015 | ||
1016 | #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ | |
2822d96e JL |
1017 | { (CUM).nargs_prototype--; \ |
1018 | ((((CUM).words & 01) && (TYPE) != 0 \ | |
1019 | && FUNCTION_ARG_SIZE(MODE, TYPE) > 1) \ | |
1020 | && (CUM).words++), \ | |
1021 | (CUM).words += FUNCTION_ARG_SIZE(MODE, TYPE); \ | |
1022 | } | |
eabd3262 RK |
1023 | |
1024 | /* Determine where to put an argument to a function. | |
1025 | Value is zero to push the argument on the stack, | |
1026 | or a hard register in which to store the argument. | |
1027 | ||
1028 | MODE is the argument's machine mode. | |
1029 | TYPE is the data type of the argument (as a tree). | |
1030 | This is null for libcalls where that information may | |
1031 | not be available. | |
1032 | CUM is a variable of type CUMULATIVE_ARGS which gives info about | |
1033 | the preceding args and about the function being called. | |
1034 | NAMED is nonzero if this argument is a named parameter | |
2822d96e | 1035 | (otherwise it is an extra parameter matching an ellipsis). |
eabd3262 | 1036 | |
2822d96e | 1037 | On the HP-PA the first four words of args are normally in registers |
eabd3262 | 1038 | and the rest are pushed. But any arg that won't entirely fit in regs |
3d247e85 TM |
1039 | is pushed. |
1040 | ||
99977c61 RS |
1041 | Arguments passed in registers are either 1 or 2 words long. |
1042 | ||
1043 | The caller must make a distinction between calls to explicitly named | |
1044 | functions and calls through pointers to functions -- the conventions | |
1045 | are different! Calls through pointers to functions only use general | |
279c9bde | 1046 | registers for the first four argument words. |
eabd3262 | 1047 | |
2822d96e JL |
1048 | Of course all this is different for the portable runtime model |
1049 | HP wants everyone to use for ELF. Ugh. Here's a quick description | |
1050 | of how it's supposed to work. | |
1051 | ||
1052 | 1) callee side remains unchanged. It expects integer args to be | |
1053 | in the integer registers, float args in the float registers and | |
1054 | unnamed args in integer registers. | |
1055 | ||
1056 | 2) caller side now depends on if the function being called has | |
1057 | a prototype in scope (rather than if it's being called indirectly). | |
1058 | ||
1059 | 2a) If there is a prototype in scope, then arguments are passed | |
1060 | according to their type (ints in integer registers, floats in float | |
1061 | registers, unnamed args in integer registers. | |
1062 | ||
1063 | 2b) If there is no prototype in scope, then floating point arguments | |
1064 | are passed in both integer and float registers. egad. | |
1065 | ||
1066 | FYI: The portable parameter passing conventions are almost exactly like | |
1067 | the standard parameter passing conventions on the RS6000. That's why | |
1068 | you'll see lots of similar code in rs6000.h. */ | |
a40ed31b | 1069 | |
eabd3262 RK |
1070 | #define FUNCTION_ARG_PADDING(MODE, TYPE) function_arg_padding ((MODE), (TYPE)) |
1071 | ||
2822d96e JL |
1072 | /* Do not expect to understand this without reading it several times. I'm |
1073 | tempted to try and simply it, but I worry about breaking something. */ | |
1074 | ||
eabd3262 | 1075 | #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ |
2822d96e JL |
1076 | (4 >= ((CUM).words + FUNCTION_ARG_SIZE ((MODE), (TYPE))) \ |
1077 | ? (!TARGET_PORTABLE_RUNTIME || (TYPE) == 0 \ | |
74356a72 TG |
1078 | || !FLOAT_MODE_P (MODE) || TARGET_SOFT_FLOAT \ |
1079 | || (CUM).nargs_prototype > 0) \ | |
ad2c71b7 | 1080 | ? gen_rtx_REG ((MODE), \ |
2822d96e | 1081 | (FUNCTION_ARG_SIZE ((MODE), (TYPE)) > 1 \ |
2c7ee1a6 | 1082 | ? (((!(CUM).indirect \ |
667f6759 | 1083 | || TARGET_PORTABLE_RUNTIME) \ |
74356a72 TG |
1084 | && (MODE) == DFmode \ |
1085 | && ! TARGET_SOFT_FLOAT) \ | |
a40ed31b | 1086 | ? ((CUM).words ? 38 : 34) \ |
2822d96e | 1087 | : ((CUM).words ? 23 : 25)) \ |
2c7ee1a6 | 1088 | : (((!(CUM).indirect \ |
667f6759 | 1089 | || TARGET_PORTABLE_RUNTIME) \ |
74356a72 TG |
1090 | && (MODE) == SFmode \ |
1091 | && ! TARGET_SOFT_FLOAT) \ | |
a40ed31b | 1092 | ? (32 + 2 * (CUM).words) \ |
2822d96e JL |
1093 | : (27 - (CUM).words - FUNCTION_ARG_SIZE ((MODE), \ |
1094 | (TYPE))))))\ | |
1095 | /* We are calling a non-prototyped function with floating point \ | |
1096 | arguments using the portable conventions. */ \ | |
ad2c71b7 | 1097 | : gen_rtx_PARALLEL ((MODE), \ |
bd625e21 JW |
1098 | gen_rtvec \ |
1099 | (2, \ | |
ad2c71b7 JL |
1100 | gen_rtx_EXPR_LIST (VOIDmode, \ |
1101 | gen_rtx_REG ((MODE), \ | |
bd625e21 JW |
1102 | (FUNCTION_ARG_SIZE ((MODE), (TYPE)) > 1 \ |
1103 | ? ((CUM).words ? 38 : 34) \ | |
1104 | : (32 + 2 * (CUM).words))), \ | |
1105 | const0_rtx), \ | |
ad2c71b7 JL |
1106 | gen_rtx_EXPR_LIST (VOIDmode, \ |
1107 | gen_rtx_REG ((MODE), \ | |
bd625e21 JW |
1108 | (FUNCTION_ARG_SIZE ((MODE), (TYPE)) > 1 \ |
1109 | ? ((CUM).words ? 23 : 25) \ | |
1110 | : (27 - (CUM).words - \ | |
1111 | FUNCTION_ARG_SIZE ((MODE), \ | |
1112 | (TYPE))))), \ | |
1113 | const0_rtx))) \ | |
2822d96e JL |
1114 | /* Pass this parameter in the stack. */ \ |
1115 | : 0) | |
eabd3262 | 1116 | |
eabd3262 RK |
1117 | /* For an arg passed partly in registers and partly in memory, |
1118 | this is the number of registers used. | |
1119 | For args passed entirely in registers or entirely in memory, zero. */ | |
1120 | ||
1121 | #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0 | |
1122 | ||
1123 | /* If defined, a C expression that gives the alignment boundary, in | |
1124 | bits, of an argument with the specified mode and type. If it is | |
1125 | not defined, `PARM_BOUNDARY' is used for all arguments. */ | |
1126 | ||
1127 | #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \ | |
1128 | (((TYPE) != 0) \ | |
e31f69f1 | 1129 | ? (((int_size_in_bytes (TYPE)) + 3) / 4) * BITS_PER_WORD \ |
eabd3262 RK |
1130 | : ((GET_MODE_ALIGNMENT(MODE) <= PARM_BOUNDARY) \ |
1131 | ? PARM_BOUNDARY \ | |
1132 | : GET_MODE_ALIGNMENT(MODE))) | |
1133 | ||
1134 | /* Arguments larger than eight bytes are passed by invisible reference */ | |
1135 | ||
1136 | #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \ | |
09a1d028 | 1137 | ((TYPE) && int_size_in_bytes (TYPE) > 8) |
32addcdf RK |
1138 | |
1139 | #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \ | |
1140 | ((TYPE) && int_size_in_bytes (TYPE) > 8) | |
1141 | ||
eabd3262 RK |
1142 | \f |
1143 | extern struct rtx_def *hppa_compare_op0, *hppa_compare_op1; | |
1144 | extern enum cmp_type hppa_branch_type; | |
1145 | ||
1146 | /* Output the label for a function definition. */ | |
22d6e660 | 1147 | #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED |
eabd3262 RK |
1148 | #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \ |
1149 | do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \ | |
1150 | fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0) | |
293100b5 JL |
1151 | #define DFMODE_RETURN_STRING ",RTNVAL=FU" |
1152 | #define SFMODE_RETURN_STRING ",RTNVAL=FR" | |
eabd3262 RK |
1153 | #else |
1154 | #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \ | |
1155 | do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \ | |
1156 | fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0) | |
293100b5 JL |
1157 | #define DFMODE_RETURN_STRING ",RTNVAL=FR" |
1158 | #define SFMODE_RETURN_STRING ",RTNVAL=FU" | |
eabd3262 | 1159 | #endif |
d2a94ec0 | 1160 | |
e38fd454 | 1161 | #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \ |
92d4501f | 1162 | { char *target_name = XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0); \ |
fbe83d7a | 1163 | STRIP_NAME_ENCODING (target_name, target_name); \ |
e38fd454 JL |
1164 | output_function_prologue (FILE, 0); \ |
1165 | if (VAL_14_BITS_P (DELTA)) \ | |
1166 | fprintf (FILE, "\tb %s\n\tldo %d(%%r26),%%r26\n", target_name, DELTA); \ | |
1167 | else \ | |
79873958 | 1168 | fprintf (FILE, "\taddil L%%%d,%%r26\n\tb %s\n\tldo R%%%d(%%r1),%%r26\n", \ |
e38fd454 JL |
1169 | DELTA, target_name, DELTA); \ |
1170 | fprintf (FILE, "\n\t.EXIT\n\t.PROCEND\n"); \ | |
1171 | } | |
1172 | ||
38488222 JL |
1173 | /* NAME refers to the function's name. If we are placing each function into |
1174 | its own section, we need to switch to the section for this function. Note | |
1175 | that the section name will have a "." prefix. */ | |
ad238e4b | 1176 | #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, NAME) \ |
435b1237 JL |
1177 | { \ |
1178 | char *name; \ | |
1179 | STRIP_NAME_ENCODING (name, NAME); \ | |
1180 | if (!TARGET_PORTABLE_RUNTIME && TARGET_GAS && in_section == in_text) \ | |
1181 | fputs ("\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \ | |
1182 | else if (! TARGET_PORTABLE_RUNTIME && TARGET_GAS) \ | |
1183 | fprintf (FILE, \ | |
38488222 | 1184 | "\t.SUBSPA .%s\n", name); \ |
435b1237 | 1185 | } |
ad238e4b | 1186 | |
eabd3262 | 1187 | #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ |
22a3ade0 | 1188 | do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \ |
eabd3262 RK |
1189 | tree tree_type = TREE_TYPE (DECL); \ |
1190 | tree parm; \ | |
1191 | int i; \ | |
c87ba671 | 1192 | if (TREE_PUBLIC (DECL) || TARGET_GAS) \ |
4fc473c1 | 1193 | { extern int current_function_varargs; \ |
c87ba671 JL |
1194 | if (TREE_PUBLIC (DECL)) \ |
1195 | { \ | |
1196 | fputs ("\t.EXPORT ", FILE); \ | |
1197 | assemble_name (FILE, NAME); \ | |
1198 | fputs (",ENTRY,PRIV_LEV=3", FILE); \ | |
1199 | } \ | |
1200 | else \ | |
1201 | { \ | |
1202 | fputs ("\t.PARAM ", FILE); \ | |
1203 | assemble_name (FILE, NAME); \ | |
1204 | } \ | |
2822d96e JL |
1205 | if (TARGET_PORTABLE_RUNTIME) \ |
1206 | { \ | |
b99e1ee9 | 1207 | fputs (",ARGW0=NO,ARGW1=NO,ARGW2=NO,ARGW3=NO,", FILE); \ |
2822d96e JL |
1208 | fputs ("RTNVAL=NO\n", FILE); \ |
1209 | break; \ | |
1210 | } \ | |
eabd3262 | 1211 | for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \ |
a9d91d6f | 1212 | parm = TREE_CHAIN (parm)) \ |
eabd3262 | 1213 | { \ |
74356a72 TG |
1214 | if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode \ |
1215 | && ! TARGET_SOFT_FLOAT) \ | |
a9d91d6f | 1216 | fprintf (FILE, ",ARGW%d=FR", i++); \ |
74356a72 TG |
1217 | else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode \ |
1218 | && ! TARGET_SOFT_FLOAT) \ | |
eabd3262 | 1219 | { \ |
3f8f5a3f TM |
1220 | if (i <= 2) \ |
1221 | { \ | |
1222 | if (i == 1) i++; \ | |
1223 | ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \ | |
1224 | } \ | |
1225 | else \ | |
1226 | break; \ | |
a9d91d6f RS |
1227 | } \ |
1228 | else \ | |
1229 | { \ | |
1230 | int arg_size = \ | |
1231 | FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\ | |
1232 | DECL_ARG_TYPE (parm)); \ | |
0ed5f250 JL |
1233 | /* Passing structs by invisible reference uses \ |
1234 | one general register. */ \ | |
c60a3c2f | 1235 | if (arg_size > 2 \ |
80363f0d | 1236 | || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm))) \ |
0ed5f250 | 1237 | arg_size = 1; \ |
a9d91d6f | 1238 | if (arg_size == 2 && i <= 2) \ |
eabd3262 | 1239 | { \ |
a9d91d6f RS |
1240 | if (i == 1) i++; \ |
1241 | fprintf (FILE, ",ARGW%d=GR", i++); \ | |
1242 | fprintf (FILE, ",ARGW%d=GR", i++); \ | |
eabd3262 | 1243 | } \ |
a9d91d6f RS |
1244 | else if (arg_size == 1) \ |
1245 | fprintf (FILE, ",ARGW%d=GR", i++); \ | |
1246 | else \ | |
1247 | i += arg_size; \ | |
eabd3262 | 1248 | } \ |
eabd3262 RK |
1249 | } \ |
1250 | /* anonymous args */ \ | |
4fc473c1 TM |
1251 | if ((TYPE_ARG_TYPES (tree_type) != 0 \ |
1252 | && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\ | |
1253 | != void_type_node)) \ | |
1254 | || current_function_varargs) \ | |
eabd3262 RK |
1255 | { \ |
1256 | for (; i < 4; i++) \ | |
1257 | fprintf (FILE, ",ARGW%d=GR", i); \ | |
1258 | } \ | |
74356a72 | 1259 | if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT) \ |
293100b5 | 1260 | fputs (DFMODE_RETURN_STRING, FILE); \ |
74356a72 | 1261 | else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \ |
293100b5 | 1262 | fputs (SFMODE_RETURN_STRING, FILE); \ |
eabd3262 | 1263 | else if (fntype != void_type_node) \ |
e236a9ff | 1264 | fputs (",RTNVAL=GR", FILE); \ |
eabd3262 | 1265 | fputs ("\n", FILE); \ |
ba0bfdac | 1266 | }} while (0) |
eabd3262 | 1267 | |
eabd3262 RK |
1268 | /* This macro generates the assembly code for function entry. |
1269 | FILE is a stdio stream to output the code to. | |
1270 | SIZE is an int: how many units of temporary storage to allocate. | |
1271 | Refer to the array `regs_ever_live' to determine which registers | |
1272 | to save; `regs_ever_live[I]' is nonzero if register number I | |
1273 | is ever used in the function. This macro is responsible for | |
1274 | knowing which registers should not be saved even if used. */ | |
1275 | ||
1276 | /* On HP-PA, move-double insns between fpu and cpu need an 8-byte block | |
1277 | of memory. If any fpu reg is used in the function, we allocate | |
1278 | such a block here, at the bottom of the frame, just in case it's needed. | |
1279 | ||
1280 | If this function is a leaf procedure, then we may choose not | |
1281 | to do a "save" insn. The decision about whether or not | |
1282 | to do this is made in regclass.c. */ | |
1283 | ||
1284 | #define FUNCTION_PROLOGUE(FILE, SIZE) \ | |
86daf4a6 | 1285 | output_function_prologue (FILE, SIZE) |
eabd3262 RK |
1286 | |
1287 | /* Output assembler code to FILE to increment profiler label # LABELNO | |
1288 | for profiling a function entry. | |
1289 | ||
1290 | Because HPUX _mcount is so different, we actually emit the | |
1291 | profiling code in function_prologue. This just stores LABELNO for | |
1292 | that. */ | |
1293 | ||
eabd3262 RK |
1294 | #define PROFILE_BEFORE_PROLOGUE |
1295 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
1296 | { extern int hp_profile_labelno; hp_profile_labelno = (LABELNO);} | |
eabd3262 RK |
1297 | |
1298 | /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, | |
1299 | the stack pointer does not matter. The value is tested only in | |
1300 | functions that have frame pointers. | |
1301 | No definition is equivalent to always zero. */ | |
1302 | ||
1303 | extern int may_call_alloca; | |
1304 | extern int current_function_pretend_args_size; | |
1305 | ||
1306 | #define EXIT_IGNORE_STACK \ | |
1307 | (get_frame_size () != 0 \ | |
1308 | || current_function_calls_alloca || current_function_outgoing_args_size) | |
1309 | ||
1310 | ||
1311 | /* This macro generates the assembly code for function exit, | |
1312 | on machines that need it. If FUNCTION_EPILOGUE is not defined | |
1313 | then individual return instructions are generated for each | |
1314 | return statement. Args are same as for FUNCTION_PROLOGUE. | |
1315 | ||
1316 | The function epilogue should not depend on the current stack pointer! | |
1317 | It should use the frame pointer only. This is mandatory because | |
1318 | of alloca; we also take advantage of it to omit stack adjustments | |
1319 | before returning. */ | |
1320 | ||
1321 | /* This declaration is needed due to traditional/ANSI | |
1322 | incompatibilities which cannot be #ifdefed away | |
1323 | because they occur inside of macros. Sigh. */ | |
1324 | extern union tree_node *current_function_decl; | |
1325 | ||
1326 | #define FUNCTION_EPILOGUE(FILE, SIZE) \ | |
86daf4a6 | 1327 | output_function_epilogue (FILE, SIZE) |
eabd3262 RK |
1328 | |
1329 | /* Output assembler code for a block containing the constant parts | |
f16fe394 | 1330 | of a trampoline, leaving space for the variable parts.\ |
eabd3262 | 1331 | |
f16fe394 JL |
1332 | The trampoline sets the static chain pointer to STATIC_CHAIN_REGNUM |
1333 | and then branches to the specified routine. | |
eabd3262 | 1334 | |
f16fe394 JL |
1335 | This code template is copied from text segment to stack location |
1336 | and then patched with INITIALIZE_TRAMPOLINE to contain | |
5a1c10de | 1337 | valid values, and then entered as a subroutine. |
eabd3262 | 1338 | |
5a1c10de | 1339 | It is best to keep this as small as possible to avoid having to |
f16fe394 JL |
1340 | flush multiple lines in the cache. */ |
1341 | ||
1342 | #define TRAMPOLINE_TEMPLATE(FILE) \ | |
77a2f698 | 1343 | { \ |
d2d28085 | 1344 | fputs ("\tldw 36(%r22),%r21\n", FILE); \ |
8b68935b JL |
1345 | fputs ("\tbb,>=,n %r21,30,.+16\n", FILE); \ |
1346 | fputs ("\tdepi 0,31,2,%r21\n", FILE); \ | |
d2d28085 JL |
1347 | fputs ("\tldw 4(%r21),%r19\n", FILE); \ |
1348 | fputs ("\tldw 0(%r21),%r21\n", FILE); \ | |
1349 | fputs ("\tldsid (%r21),%r1\n", FILE); \ | |
8b68935b JL |
1350 | fputs ("\tmtsp %r1,%sr0\n", FILE); \ |
1351 | fputs ("\tbe 0(%sr0,%r21)\n", FILE); \ | |
d2d28085 | 1352 | fputs ("\tldw 40(%r22),%r29\n", FILE); \ |
e236a9ff JL |
1353 | fputs ("\t.word 0\n", FILE); \ |
1354 | fputs ("\t.word 0\n", FILE); \ | |
77a2f698 | 1355 | } |
f16fe394 JL |
1356 | |
1357 | /* Length in units of the trampoline for entering a nested function. | |
afcc28b2 RS |
1358 | |
1359 | Flush the cache entries corresponding to the first and last addresses | |
1360 | of the trampoline. This is necessary as the trampoline may cross two | |
5a1c10de | 1361 | cache lines. |
afcc28b2 | 1362 | |
77a2f698 TG |
1363 | If the code part of the trampoline ever grows to > 32 bytes, then it |
1364 | will become necessary to hack on the cacheflush pattern in pa.md. */ | |
f16fe394 | 1365 | |
77a2f698 | 1366 | #define TRAMPOLINE_SIZE (11 * 4) |
eabd3262 RK |
1367 | |
1368 | /* Emit RTL insns to initialize the variable parts of a trampoline. | |
1369 | FNADDR is an RTX for the address of the function's pure code. | |
1370 | CXT is an RTX for the static chain value for the function. | |
1371 | ||
f16fe394 JL |
1372 | Move the function address to the trampoline template at offset 12. |
1373 | Move the static chain value to trampoline template at offset 16. */ | |
1374 | ||
1375 | #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ | |
77a2f698 | 1376 | { \ |
608f0dd2 | 1377 | rtx start_addr, end_addr; \ |
77a2f698 TG |
1378 | \ |
1379 | start_addr = memory_address (Pmode, plus_constant ((TRAMP), 36)); \ | |
ad2c71b7 | 1380 | emit_move_insn (gen_rtx_MEM (Pmode, start_addr), (FNADDR)); \ |
77a2f698 | 1381 | start_addr = memory_address (Pmode, plus_constant ((TRAMP), 40)); \ |
ad2c71b7 | 1382 | emit_move_insn (gen_rtx_MEM (Pmode, start_addr), (CXT)); \ |
77a2f698 TG |
1383 | /* fdc and fic only use registers for the address to flush, \ |
1384 | they do not accept integer displacements. */ \ | |
1385 | start_addr = force_reg (SImode, (TRAMP)); \ | |
1386 | end_addr = force_reg (SImode, plus_constant ((TRAMP), 32)); \ | |
1387 | emit_insn (gen_dcacheflush (start_addr, end_addr)); \ | |
608f0dd2 JL |
1388 | end_addr = force_reg (SImode, plus_constant (start_addr, 32)); \ |
1389 | emit_insn (gen_icacheflush (start_addr, end_addr, start_addr, \ | |
77a2f698 | 1390 | gen_reg_rtx (SImode), gen_reg_rtx (SImode)));\ |
f16fe394 | 1391 | } |
eabd3262 RK |
1392 | |
1393 | /* Emit code for a call to builtin_saveregs. We must emit USE insns which | |
1394 | reference the 4 integer arg registers and 4 fp arg registers. | |
1395 | Ordinarily they are not call used registers, but they are for | |
1396 | _builtin_saveregs, so we must make this explicit. */ | |
1397 | ||
107b5ee6 RK |
1398 | extern struct rtx_def *hppa_builtin_saveregs (); |
1399 | #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) hppa_builtin_saveregs (ARGLIST) | |
eabd3262 RK |
1400 | |
1401 | \f | |
51c2de46 | 1402 | /* Addressing modes, and classification of registers for them. |
eabd3262 | 1403 | |
51c2de46 JQ |
1404 | Using autoincrement addressing modes on PA8000 class machines is |
1405 | not profitable. */ | |
eabd3262 | 1406 | |
42a21f70 JQ |
1407 | #define HAVE_POST_INCREMENT (pa_cpu < PROCESSOR_8000) |
1408 | #define HAVE_POST_DECREMENT (pa_cpu < PROCESSOR_8000) | |
51c2de46 | 1409 | |
42a21f70 JQ |
1410 | #define HAVE_PRE_DECREMENT (pa_cpu < PROCESSOR_8000) |
1411 | #define HAVE_PRE_INCREMENT (pa_cpu < PROCESSOR_8000) | |
eabd3262 RK |
1412 | |
1413 | /* Macros to check register numbers against specific register classes. */ | |
1414 | ||
1415 | /* These assume that REGNO is a hard or pseudo reg number. | |
1416 | They give nonzero only if REGNO is a hard reg of the suitable class | |
1417 | or a pseudo reg currently allocated to a suitable hard reg. | |
1418 | Since they use reg_renumber, they are safe only once reg_renumber | |
1419 | has been allocated, which happens in local-alloc.c. */ | |
1420 | ||
1421 | #define REGNO_OK_FOR_INDEX_P(REGNO) \ | |
1422 | ((REGNO) && ((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32)) | |
1423 | #define REGNO_OK_FOR_BASE_P(REGNO) \ | |
1424 | ((REGNO) && ((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32)) | |
1425 | #define REGNO_OK_FOR_FP_P(REGNO) \ | |
5345f91a | 1426 | (FP_REGNO_P (REGNO) || FP_REGNO_P (reg_renumber[REGNO])) |
eabd3262 RK |
1427 | |
1428 | /* Now macros that check whether X is a register and also, | |
1429 | strictly, whether it is in a specified class. | |
1430 | ||
38e01259 | 1431 | These macros are specific to the HP-PA, and may be used only |
eabd3262 RK |
1432 | in code for printing assembler insns and in conditions for |
1433 | define_optimization. */ | |
1434 | ||
1435 | /* 1 if X is an fp register. */ | |
1436 | ||
1437 | #define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X))) | |
1438 | \f | |
1439 | /* Maximum number of registers that can appear in a valid memory address. */ | |
1440 | ||
1441 | #define MAX_REGS_PER_ADDRESS 2 | |
1442 | ||
901a8cea JL |
1443 | /* Recognize any constant value that is a valid address except |
1444 | for symbolic addresses. We get better CSE by rejecting them | |
6eff269e BK |
1445 | here and allowing hppa_legitimize_address to break them up. We |
1446 | use most of the constants accepted by CONSTANT_P, except CONST_DOUBLE. */ | |
eabd3262 | 1447 | |
901a8cea | 1448 | #define CONSTANT_ADDRESS_P(X) \ |
6eff269e BK |
1449 | ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ |
1450 | || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ | |
6e11a328 JL |
1451 | || GET_CODE (X) == HIGH) \ |
1452 | && (reload_in_progress || reload_completed || ! symbolic_expression_p (X))) | |
6eff269e | 1453 | |
af69aabb | 1454 | /* Include all constant integers and constant doubles, but not |
f45ebe47 | 1455 | floating-point, except for floating-point zero. |
af69aabb | 1456 | |
f45ebe47 JL |
1457 | Reject LABEL_REFs if we're not using gas or the new HP assembler. */ |
1458 | #ifdef NEW_HP_ASSEMBLER | |
af69aabb | 1459 | #define LEGITIMATE_CONSTANT_P(X) \ |
6bb36601 JL |
1460 | ((GET_MODE_CLASS (GET_MODE (X)) != MODE_FLOAT \ |
1461 | || (X) == CONST0_RTX (GET_MODE (X))) \ | |
359255a9 | 1462 | && !function_label_operand (X, VOIDmode)) |
f45ebe47 JL |
1463 | #else |
1464 | #define LEGITIMATE_CONSTANT_P(X) \ | |
1465 | ((GET_MODE_CLASS (GET_MODE (X)) != MODE_FLOAT \ | |
1466 | || (X) == CONST0_RTX (GET_MODE (X))) \ | |
1467 | && (GET_CODE (X) != LABEL_REF || TARGET_GAS)\ | |
1468 | && !function_label_operand (X, VOIDmode)) | |
1469 | #endif | |
eabd3262 | 1470 | |
5a1c10de | 1471 | /* Subroutine for EXTRA_CONSTRAINT. |
eabd3262 | 1472 | |
16594451 JL |
1473 | Return 1 iff OP is a pseudo which did not get a hard register and |
1474 | we are running the reload pass. */ | |
1475 | ||
1476 | #define IS_RELOADING_PSEUDO_P(OP) \ | |
1477 | ((reload_in_progress \ | |
1478 | && GET_CODE (OP) == REG \ | |
1479 | && REGNO (OP) >= FIRST_PSEUDO_REGISTER \ | |
1480 | && reg_renumber [REGNO (OP)] < 0)) | |
eabd3262 RK |
1481 | |
1482 | /* Optional extra constraints for this machine. Borrowed from sparc.h. | |
1483 | ||
1484 | For the HPPA, `Q' means that this is a memory operand but not a | |
1485 | symbolic memory operand. Note that an unassigned pseudo register | |
1486 | is such a memory operand. Needed because reload will generate | |
1487 | these things in insns and then not re-recognize the insns, causing | |
1488 | constrain_operands to fail. | |
1489 | ||
1c6c21c8 | 1490 | `R' is used for scaled indexed addresses. |
eabd3262 | 1491 | |
e30f390e | 1492 | `S' is unused. |
eabd3262 | 1493 | |
84721fbd | 1494 | `T' is for fp loads and stores. */ |
ec241c19 JL |
1495 | #define EXTRA_CONSTRAINT(OP, C) \ |
1496 | ((C) == 'Q' ? \ | |
16594451 | 1497 | (IS_RELOADING_PSEUDO_P (OP) \ |
16594451 | 1498 | || (GET_CODE (OP) == MEM \ |
78c0acfd JL |
1499 | && (memory_address_p (GET_MODE (OP), XEXP (OP, 0))\ |
1500 | || reload_in_progress) \ | |
2414e0e2 JL |
1501 | && ! symbolic_memory_operand (OP, VOIDmode) \ |
1502 | && !(GET_CODE (XEXP (OP, 0)) == PLUS \ | |
1503 | && (GET_CODE (XEXP (XEXP (OP, 0), 0)) == MULT\ | |
1504 | || GET_CODE (XEXP (XEXP (OP, 0), 1)) == MULT))))\ | |
1505 | : ((C) == 'R' ? \ | |
1506 | (GET_CODE (OP) == MEM \ | |
1507 | && GET_CODE (XEXP (OP, 0)) == PLUS \ | |
1508 | && (GET_CODE (XEXP (XEXP (OP, 0), 0)) == MULT \ | |
1509 | || GET_CODE (XEXP (XEXP (OP, 0), 1)) == MULT) \ | |
1510 | && (move_operand (OP, GET_MODE (OP)) \ | |
78c0acfd JL |
1511 | || memory_address_p (GET_MODE (OP), XEXP (OP, 0))\ |
1512 | || reload_in_progress)) \ | |
16594451 | 1513 | : ((C) == 'T' ? \ |
84721fbd JL |
1514 | (GET_CODE (OP) == MEM \ |
1515 | /* Using DFmode forces only short displacements \ | |
1516 | to be recognized as valid in reg+d addresses. */\ | |
2414e0e2 JL |
1517 | && memory_address_p (DFmode, XEXP (OP, 0)) \ |
1518 | && !(GET_CODE (XEXP (OP, 0)) == PLUS \ | |
1519 | && (GET_CODE (XEXP (XEXP (OP, 0), 0)) == MULT\ | |
1520 | || GET_CODE (XEXP (XEXP (OP, 0), 1)) == MULT))) : 0))) | |
16594451 JL |
1521 | |
1522 | /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx | |
1523 | and check its validity for a certain class. | |
1524 | We have two alternate definitions for each of them. | |
1525 | The usual definition accepts all pseudo regs; the other rejects | |
1526 | them unless they have been allocated suitable hard regs. | |
1527 | The symbol REG_OK_STRICT causes the latter definition to be used. | |
1528 | ||
1529 | Most source files want to accept pseudo regs in the hope that | |
1530 | they will get allocated to the class that the insn wants them to be in. | |
1531 | Source files for reload pass need to be strict. | |
1532 | After reload, it makes no difference, since pseudo regs have | |
1533 | been eliminated by then. */ | |
ec241c19 | 1534 | |
eabd3262 RK |
1535 | #ifndef REG_OK_STRICT |
1536 | ||
1537 | /* Nonzero if X is a hard reg that can be used as an index | |
1538 | or if it is a pseudo reg. */ | |
1539 | #define REG_OK_FOR_INDEX_P(X) \ | |
e515e507 | 1540 | (REGNO (X) && (REGNO (X) < 32 || REGNO (X) >= FIRST_PSEUDO_REGISTER)) |
eabd3262 RK |
1541 | /* Nonzero if X is a hard reg that can be used as a base reg |
1542 | or if it is a pseudo reg. */ | |
1543 | #define REG_OK_FOR_BASE_P(X) \ | |
e515e507 | 1544 | (REGNO (X) && (REGNO (X) < 32 || REGNO (X) >= FIRST_PSEUDO_REGISTER)) |
eabd3262 | 1545 | |
eabd3262 RK |
1546 | #else |
1547 | ||
1548 | /* Nonzero if X is a hard reg that can be used as an index. */ | |
1549 | #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) | |
1550 | /* Nonzero if X is a hard reg that can be used as a base reg. */ | |
1551 | #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) | |
1552 | ||
eabd3262 RK |
1553 | #endif |
1554 | \f | |
1555 | /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression | |
1556 | that is a valid memory address for an instruction. | |
1557 | The MODE argument is the machine mode for the MEM expression | |
1558 | that wants to use this address. | |
1559 | ||
3f8f5a3f | 1560 | On the HP-PA, the actual legitimate addresses must be |
eabd3262 RK |
1561 | REG+REG, REG+(REG*SCALE) or REG+SMALLINT. |
1562 | But we can treat a SYMBOL_REF as legitimate if it is part of this | |
1563 | function's constant-pool, because such addresses can actually | |
a08e7493 JL |
1564 | be output as REG+SMALLINT. |
1565 | ||
1566 | Note we only allow 5 bit immediates for access to a constant address; | |
1567 | doing so avoids losing for loading/storing a FP register at an address | |
1568 | which will not fit in 5 bits. */ | |
eabd3262 RK |
1569 | |
1570 | #define VAL_5_BITS_P(X) ((unsigned)(X) + 0x10 < 0x20) | |
1571 | #define INT_5_BITS(X) VAL_5_BITS_P (INTVAL (X)) | |
1572 | ||
1573 | #define VAL_U5_BITS_P(X) ((unsigned)(X) < 0x20) | |
1574 | #define INT_U5_BITS(X) VAL_U5_BITS_P (INTVAL (X)) | |
1575 | ||
1576 | #define VAL_11_BITS_P(X) ((unsigned)(X) + 0x400 < 0x800) | |
1577 | #define INT_11_BITS(X) VAL_11_BITS_P (INTVAL (X)) | |
1578 | ||
1579 | #define VAL_14_BITS_P(X) ((unsigned)(X) + 0x2000 < 0x4000) | |
1580 | #define INT_14_BITS(X) VAL_14_BITS_P (INTVAL (X)) | |
1581 | ||
eabd3262 RK |
1582 | #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ |
1583 | { \ | |
1584 | if ((REG_P (X) && REG_OK_FOR_BASE_P (X)) \ | |
1585 | || ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC \ | |
1586 | || GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC) \ | |
1587 | && REG_P (XEXP (X, 0)) \ | |
1588 | && REG_OK_FOR_BASE_P (XEXP (X, 0)))) \ | |
1589 | goto ADDR; \ | |
1590 | else if (GET_CODE (X) == PLUS) \ | |
1591 | { \ | |
516c2342 | 1592 | rtx base = 0, index = 0; \ |
eabd3262 RK |
1593 | if (flag_pic && XEXP (X, 0) == pic_offset_table_rtx)\ |
1594 | { \ | |
1595 | if (GET_CODE (XEXP (X, 1)) == REG \ | |
1596 | && REG_OK_FOR_BASE_P (XEXP (X, 1))) \ | |
1597 | goto ADDR; \ | |
1598 | else if (flag_pic == 1 \ | |
6bb36601 | 1599 | && GET_CODE (XEXP (X, 1)) == SYMBOL_REF)\ |
eabd3262 RK |
1600 | goto ADDR; \ |
1601 | } \ | |
1602 | else if (REG_P (XEXP (X, 0)) \ | |
1603 | && REG_OK_FOR_BASE_P (XEXP (X, 0))) \ | |
1604 | base = XEXP (X, 0), index = XEXP (X, 1); \ | |
1605 | else if (REG_P (XEXP (X, 1)) \ | |
1606 | && REG_OK_FOR_BASE_P (XEXP (X, 1))) \ | |
1607 | base = XEXP (X, 1), index = XEXP (X, 0); \ | |
1608 | if (base != 0) \ | |
1609 | if (GET_CODE (index) == CONST_INT \ | |
74356a72 TG |
1610 | && ((INT_14_BITS (index) \ |
1611 | && (TARGET_SOFT_FLOAT \ | |
1612 | || ((MODE) != SFmode && (MODE) != DFmode))) \ | |
eabd3262 RK |
1613 | || INT_5_BITS (index))) \ |
1614 | goto ADDR; \ | |
1e0e41d2 | 1615 | if (! TARGET_SOFT_FLOAT \ |
96b63cd7 | 1616 | && ! TARGET_DISABLE_INDEXING \ |
1e0e41d2 | 1617 | && base \ |
2414e0e2 JL |
1618 | && (mode == SFmode || mode == DFmode) \ |
1619 | && GET_CODE (index) == MULT \ | |
1620 | && GET_CODE (XEXP (index, 0)) == REG \ | |
1621 | && REG_OK_FOR_BASE_P (XEXP (index, 0)) \ | |
1622 | && GET_CODE (XEXP (index, 1)) == CONST_INT \ | |
1e0e41d2 | 1623 | && INTVAL (XEXP (index, 1)) == (mode == SFmode ? 4 : 8))\ |
2414e0e2 | 1624 | goto ADDR; \ |
eabd3262 RK |
1625 | } \ |
1626 | else if (GET_CODE (X) == LO_SUM \ | |
1627 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1628 | && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1629 | && CONSTANT_P (XEXP (X, 1)) \ | |
74356a72 TG |
1630 | && (TARGET_SOFT_FLOAT \ |
1631 | || ((MODE) != SFmode \ | |
1632 | && (MODE) != DFmode))) \ | |
eabd3262 RK |
1633 | goto ADDR; \ |
1634 | else if (GET_CODE (X) == LO_SUM \ | |
1635 | && GET_CODE (XEXP (X, 0)) == SUBREG \ | |
1636 | && GET_CODE (SUBREG_REG (XEXP (X, 0))) == REG\ | |
1637 | && REG_OK_FOR_BASE_P (SUBREG_REG (XEXP (X, 0)))\ | |
1638 | && CONSTANT_P (XEXP (X, 1)) \ | |
74356a72 TG |
1639 | && (TARGET_SOFT_FLOAT \ |
1640 | || ((MODE) != SFmode \ | |
1641 | && (MODE) != DFmode))) \ | |
eabd3262 RK |
1642 | goto ADDR; \ |
1643 | else if (GET_CODE (X) == LABEL_REF \ | |
1644 | || (GET_CODE (X) == CONST_INT \ | |
a08e7493 | 1645 | && INT_5_BITS (X))) \ |
eabd3262 | 1646 | goto ADDR; \ |
a205e34b JL |
1647 | /* Needed for -fPIC */ \ |
1648 | else if (GET_CODE (X) == LO_SUM \ | |
1649 | && GET_CODE (XEXP (X, 0)) == REG \ | |
1650 | && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ | |
1651 | && GET_CODE (XEXP (X, 1)) == UNSPEC) \ | |
1652 | goto ADDR; \ | |
eabd3262 | 1653 | } |
cc46ae8e JL |
1654 | |
1655 | /* Look for machine dependent ways to make the invalid address AD a | |
1656 | valid address. | |
1657 | ||
1658 | For the PA, transform: | |
1659 | ||
1660 | memory(X + <large int>) | |
1661 | ||
1662 | into: | |
1663 | ||
1664 | if (<large int> & mask) >= 16 | |
1665 | Y = (<large int> & ~mask) + mask + 1 Round up. | |
1666 | else | |
1667 | Y = (<large int> & ~mask) Round down. | |
1668 | Z = X + Y | |
1669 | memory (Z + (<large int> - Y)); | |
1670 | ||
1671 | This makes reload inheritance and reload_cse work better since Z | |
1672 | can be reused. | |
1673 | ||
1674 | There may be more opportunities to improve code with this hook. */ | |
1675 | #define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \ | |
1676 | do { \ | |
1677 | int offset, newoffset, mask; \ | |
5f0c590d | 1678 | rtx new, temp = NULL_RTX; \ |
cc46ae8e JL |
1679 | mask = GET_MODE_CLASS (MODE) == MODE_FLOAT ? 0x1f : 0x3fff; \ |
1680 | \ | |
2872409d | 1681 | if (optimize \ |
5f0c590d JL |
1682 | && GET_CODE (AD) == PLUS) \ |
1683 | temp = simplify_binary_operation (PLUS, Pmode, \ | |
1684 | XEXP (AD, 0), XEXP (AD, 1)); \ | |
1685 | \ | |
1686 | new = temp ? temp : AD; \ | |
1687 | \ | |
1688 | if (optimize \ | |
1689 | && GET_CODE (new) == PLUS \ | |
1690 | && GET_CODE (XEXP (new, 0)) == REG \ | |
1691 | && GET_CODE (XEXP (new, 1)) == CONST_INT) \ | |
cc46ae8e | 1692 | { \ |
5f0c590d | 1693 | offset = INTVAL (XEXP ((new), 1)); \ |
cc46ae8e JL |
1694 | \ |
1695 | /* Choose rounding direction. Round up if we are >= halfway. */ \ | |
1696 | if ((offset & mask) >= ((mask + 1) / 2)) \ | |
1697 | newoffset = (offset & ~mask) + mask + 1; \ | |
1698 | else \ | |
1699 | newoffset = offset & ~mask; \ | |
1700 | \ | |
1701 | if (newoffset != 0 \ | |
1702 | && VAL_14_BITS_P (newoffset)) \ | |
1703 | { \ | |
cc46ae8e | 1704 | \ |
5f0c590d | 1705 | temp = gen_rtx_PLUS (Pmode, XEXP (new, 0), \ |
cc46ae8e JL |
1706 | GEN_INT (newoffset)); \ |
1707 | AD = gen_rtx_PLUS (Pmode, temp, GEN_INT (offset - newoffset));\ | |
1708 | push_reload (XEXP (AD, 0), 0, &XEXP (AD, 0), 0, \ | |
1709 | BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, \ | |
1710 | (OPNUM), (TYPE)); \ | |
1711 | goto WIN; \ | |
1712 | } \ | |
1713 | } \ | |
1714 | } while (0) | |
1715 | ||
1716 | ||
1717 | ||
eabd3262 RK |
1718 | \f |
1719 | /* Try machine-dependent ways of modifying an illegitimate address | |
1720 | to be legitimate. If we find one, return the new, valid address. | |
1721 | This macro is used in only one place: `memory_address' in explow.c. | |
1722 | ||
1723 | OLDX is the address as it was before break_out_memory_refs was called. | |
1724 | In some cases it is useful to look at this to decide what needs to be done. | |
1725 | ||
1726 | MODE and WIN are passed so that this macro can use | |
1727 | GO_IF_LEGITIMATE_ADDRESS. | |
1728 | ||
1729 | It is always safe for this macro to do nothing. It exists to recognize | |
901a8cea JL |
1730 | opportunities to optimize the output. */ |
1731 | ||
1732 | extern struct rtx_def *hppa_legitimize_address (); | |
1733 | #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \ | |
1734 | { rtx orig_x = (X); \ | |
1735 | (X) = hppa_legitimize_address (X, OLDX, MODE); \ | |
1736 | if ((X) != orig_x && memory_address_p (MODE, X)) \ | |
1737 | goto WIN; } | |
eabd3262 RK |
1738 | |
1739 | /* Go to LABEL if ADDR (a legitimate address expression) | |
1740 | has an effect that depends on the machine mode it is used for. */ | |
1741 | ||
1742 | #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ | |
1743 | if (GET_CODE (ADDR) == PRE_DEC \ | |
1744 | || GET_CODE (ADDR) == POST_DEC \ | |
1745 | || GET_CODE (ADDR) == PRE_INC \ | |
1746 | || GET_CODE (ADDR) == POST_INC) \ | |
1747 | goto LABEL | |
1748 | \f | |
1749 | /* Define this macro if references to a symbol must be treated | |
1750 | differently depending on something about the variable or | |
1751 | function named by the symbol (such as what section it is in). | |
1752 | ||
1753 | The macro definition, if any, is executed immediately after the | |
1754 | rtl for DECL or other node is created. | |
1755 | The value of the rtl will be a `mem' whose address is a | |
1756 | `symbol_ref'. | |
1757 | ||
1758 | The usual thing for this macro to do is to a flag in the | |
1759 | `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified | |
1760 | name string in the `symbol_ref' (if one bit is not enough | |
1761 | information). | |
1762 | ||
3f8f5a3f | 1763 | On the HP-PA we use this to indicate if a symbol is in text or |
ff2b6252 TM |
1764 | data space. Also, function labels need special treatment. */ |
1765 | ||
1766 | #define TEXT_SPACE_P(DECL)\ | |
1767 | (TREE_CODE (DECL) == FUNCTION_DECL \ | |
1768 | || (TREE_CODE (DECL) == VAR_DECL \ | |
1769 | && TREE_READONLY (DECL) && ! TREE_SIDE_EFFECTS (DECL) \ | |
c77c286a | 1770 | && (! DECL_INITIAL (DECL) || ! reloc_needed (DECL_INITIAL (DECL))) \ |
ff2b6252 | 1771 | && !flag_pic) \ |
74c3447c | 1772 | || (TREE_CODE_CLASS (TREE_CODE (DECL)) == 'c' \ |
ff2b6252 TM |
1773 | && !(TREE_CODE (DECL) == STRING_CST && flag_writable_strings))) |
1774 | ||
1775 | #define FUNCTION_NAME_P(NAME) \ | |
1776 | (*(NAME) == '@' || (*(NAME) == '*' && *((NAME) + 1) == '@')) | |
eabd3262 RK |
1777 | |
1778 | #define ENCODE_SECTION_INFO(DECL)\ | |
ff2b6252 TM |
1779 | do \ |
1780 | { if (TEXT_SPACE_P (DECL)) \ | |
1781 | { rtx _rtl; \ | |
1782 | if (TREE_CODE (DECL) == FUNCTION_DECL \ | |
1783 | || TREE_CODE (DECL) == VAR_DECL) \ | |
1784 | _rtl = DECL_RTL (DECL); \ | |
1785 | else \ | |
1786 | _rtl = TREE_CST_RTL (DECL); \ | |
1787 | SYMBOL_REF_FLAG (XEXP (_rtl, 0)) = 1; \ | |
1788 | if (TREE_CODE (DECL) == FUNCTION_DECL) \ | |
4f6cd2e6 | 1789 | hppa_encode_label (XEXP (DECL_RTL (DECL), 0), 0);\ |
ff2b6252 TM |
1790 | } \ |
1791 | } \ | |
eabd3262 | 1792 | while (0) |
5a1c10de | 1793 | |
e42b4c96 RS |
1794 | /* Store the user-specified part of SYMBOL_NAME in VAR. |
1795 | This is sort of inverse to ENCODE_SECTION_INFO. */ | |
1796 | ||
1797 | #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ | |
ff2b6252 TM |
1798 | (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*' ? \ |
1799 | 1 + (SYMBOL_NAME)[1] == '@'\ | |
1800 | : (SYMBOL_NAME)[0] == '@')) | |
eabd3262 | 1801 | |
25ce77f4 JL |
1802 | /* On hpux10, the linker will give an error if we have a reference |
1803 | in the read-only data section to a symbol defined in a shared | |
1804 | library. Therefore, expressions that might require a reloc can | |
1805 | not be placed in the read-only data section. */ | |
1806 | #define SELECT_SECTION(EXP,RELOC) \ | |
1807 | if (TREE_CODE (EXP) == VAR_DECL \ | |
1808 | && TREE_READONLY (EXP) \ | |
1809 | && !TREE_THIS_VOLATILE (EXP) \ | |
1810 | && DECL_INITIAL (EXP) \ | |
1811 | && (DECL_INITIAL (EXP) == error_mark_node \ | |
1812 | || TREE_CONSTANT (DECL_INITIAL (EXP))) \ | |
ab2e3386 | 1813 | && !RELOC) \ |
25ce77f4 JL |
1814 | readonly_data_section (); \ |
1815 | else if (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'c' \ | |
1816 | && !(TREE_CODE (EXP) == STRING_CST && flag_writable_strings) \ | |
ab2e3386 | 1817 | && !RELOC) \ |
25ce77f4 JL |
1818 | readonly_data_section (); \ |
1819 | else \ | |
1820 | data_section (); | |
1821 | ||
8e64b41a JL |
1822 | /* Arghh. The hpux10 linker chokes if we have a reference to symbols |
1823 | in a readonly data section when the symbol is defined in a shared | |
1824 | library. Since we can't know at compile time if a symbol will be | |
1825 | satisfied by a shared library or main program we put any symbolic | |
1826 | constant into the normal data section. */ | |
1827 | #define SELECT_RTX_SECTION(MODE,RTX) \ | |
1828 | if (symbolic_operand (RTX, MODE)) \ | |
6bb36601 JL |
1829 | data_section (); \ |
1830 | else \ | |
1831 | readonly_data_section (); | |
1832 | ||
eabd3262 RK |
1833 | /* Specify the machine mode that this machine uses |
1834 | for the index in the tablejump instruction. */ | |
3e056efc | 1835 | #define CASE_VECTOR_MODE (TARGET_BIG_SWITCH ? TImode : DImode) |
eabd3262 RK |
1836 | |
1837 | /* Specify the tree operation to be used to convert reals to integers. */ | |
1838 | #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR | |
1839 | ||
1840 | /* This is the kind of divide that is easiest to do in the general case. */ | |
1841 | #define EASY_DIV_EXPR TRUNC_DIV_EXPR | |
1842 | ||
1843 | /* Define this as 1 if `char' should by default be signed; else as 0. */ | |
1844 | #define DEFAULT_SIGNED_CHAR 1 | |
1845 | ||
1846 | /* Max number of bytes we can move from memory to memory | |
1847 | in one reasonably fast instruction. */ | |
1848 | #define MOVE_MAX 8 | |
1849 | ||
68944452 JL |
1850 | /* Higher than the default as we prefer to use simple move insns |
1851 | (better scheduling and delay slot filling) and because our | |
1852 | built-in block move is really a 2X unrolled loop. */ | |
1853 | #define MOVE_RATIO 4 | |
1854 | ||
9a63901f RK |
1855 | /* Define if operations between registers always perform the operation |
1856 | on the full register even if a narrower mode is specified. */ | |
1857 | #define WORD_REGISTER_OPERATIONS | |
1858 | ||
1859 | /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD | |
1860 | will either zero-extend or sign-extend. The value of this macro should | |
1861 | be the code that says which one of the two operations is implicitly | |
1862 | done, NIL if none. */ | |
1863 | #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND | |
eabd3262 RK |
1864 | |
1865 | /* Nonzero if access to memory by bytes is slow and undesirable. */ | |
1866 | #define SLOW_BYTE_ACCESS 1 | |
1867 | ||
b10c8966 JL |
1868 | /* Do not break .stabs pseudos into continuations. |
1869 | ||
1870 | This used to be zero (no max length), but big enums and such can | |
1871 | cause huge strings which killed gas. | |
1872 | ||
1873 | We also have to avoid lossage in dbxout.c -- it does not compute the | |
1874 | string size accurately, so we are real conservative here. */ | |
1875 | #define DBX_CONTIN_LENGTH 3000 | |
eabd3262 RK |
1876 | |
1877 | /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits | |
1878 | is done just by pretending it is already truncated. */ | |
1879 | #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 | |
1880 | ||
1881 | /* We assume that the store-condition-codes instructions store 0 for false | |
1882 | and some other value for true. This is the value stored for true. */ | |
1883 | ||
1884 | #define STORE_FLAG_VALUE 1 | |
1885 | ||
1886 | /* When a prototype says `char' or `short', really pass an `int'. */ | |
1887 | #define PROMOTE_PROTOTYPES | |
1888 | ||
1889 | /* Specify the machine mode that pointers have. | |
1890 | After generation of rtl, the compiler makes no further distinction | |
1891 | between pointers and any other objects of this machine mode. */ | |
1892 | #define Pmode SImode | |
1893 | ||
1894 | /* Add any extra modes needed to represent the condition code. | |
1895 | ||
1896 | HPPA floating comparisons produce condition codes. */ | |
1897 | #define EXTRA_CC_MODES CCFPmode | |
1898 | ||
1899 | /* Define the names for the modes specified above. */ | |
1900 | #define EXTRA_CC_NAMES "CCFP" | |
1901 | ||
1902 | /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, | |
1903 | return the mode to be used for the comparison. For floating-point, CCFPmode | |
1904 | should be used. CC_NOOVmode should be used when the first operand is a | |
1905 | PLUS, MINUS, or NEG. CCmode should be used when no special processing is | |
1906 | needed. */ | |
b565a316 | 1907 | #define SELECT_CC_MODE(OP,X,Y) \ |
eabd3262 RK |
1908 | (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CCFPmode : CCmode) \ |
1909 | ||
1910 | /* A function address in a call instruction | |
1911 | is a byte address (for indexing purposes) | |
1912 | so give the MEM rtx a byte's mode. */ | |
1913 | #define FUNCTION_MODE SImode | |
5a1c10de | 1914 | |
eabd3262 RK |
1915 | /* Define this if addresses of constant functions |
1916 | shouldn't be put through pseudo regs where they can be cse'd. | |
1917 | Desirable on machines where ordinary constants are expensive | |
1918 | but a CALL with constant address is cheap. */ | |
1919 | #define NO_FUNCTION_CSE | |
1920 | ||
d969caf8 | 1921 | /* Define this to be nonzero if shift instructions ignore all but the low-order |
e061ef25 | 1922 | few bits. */ |
d969caf8 | 1923 | #define SHIFT_COUNT_TRUNCATED 1 |
e061ef25 | 1924 | |
81f433e4 JL |
1925 | /* Use atexit for static constructors/destructors, instead of defining |
1926 | our own exit function. */ | |
1927 | #define HAVE_ATEXIT | |
1928 | ||
eabd3262 RK |
1929 | /* Compute the cost of computing a constant rtl expression RTX |
1930 | whose rtx-code is CODE. The body of this macro is a portion | |
1931 | of a switch statement. If the code is computed here, | |
1932 | return it with a return statement. Otherwise, break from the switch. */ | |
1933 | ||
1934 | #define CONST_COSTS(RTX,CODE,OUTER_CODE) \ | |
5feca984 KG |
1935 | case CONST_INT: \ |
1936 | if (INTVAL (RTX) == 0) return 0; \ | |
1937 | if (INT_14_BITS (RTX)) return 1; \ | |
1938 | case HIGH: \ | |
1939 | return 2; \ | |
1940 | case CONST: \ | |
1941 | case LABEL_REF: \ | |
1942 | case SYMBOL_REF: \ | |
1943 | return 4; \ | |
1944 | case CONST_DOUBLE: \ | |
1945 | if ((RTX == CONST0_RTX (DFmode) || RTX == CONST0_RTX (SFmode)) \ | |
1946 | && OUTER_CODE != SET) \ | |
1947 | return 0; \ | |
1948 | else \ | |
af69aabb | 1949 | return 8; |
eabd3262 RK |
1950 | |
1951 | #define ADDRESS_COST(RTX) \ | |
1952 | (GET_CODE (RTX) == REG ? 1 : hppa_address_cost (RTX)) | |
1953 | ||
1954 | /* Compute extra cost of moving data between one register class | |
5de7c240 JL |
1955 | and another. |
1956 | ||
5ac6158d TG |
1957 | Make moves from SAR so expensive they should never happen. We used to |
1958 | have 0xffff here, but that generates overflow in rare cases. | |
5de7c240 | 1959 | |
5a1c10de | 1960 | Copies involving a FP register and a non-FP register are relatively |
5de7c240 JL |
1961 | expensive because they must go through memory. |
1962 | ||
1963 | Other copies are reasonably cheap. */ | |
eabd3262 | 1964 | #define REGISTER_MOVE_COST(CLASS1, CLASS2) \ |
5ac6158d | 1965 | (CLASS1 == SHIFT_REGS ? 0x100 \ |
5de7c240 JL |
1966 | : FP_REG_CLASS_P (CLASS1) && ! FP_REG_CLASS_P (CLASS2) ? 16 \ |
1967 | : FP_REG_CLASS_P (CLASS2) && ! FP_REG_CLASS_P (CLASS1) ? 16 \ | |
1968 | : 2) | |
1969 | ||
eabd3262 RK |
1970 | |
1971 | /* Provide the costs of a rtl expression. This is in the body of a | |
1972 | switch on CODE. The purpose for the cost of MULT is to encourage | |
1973 | `synth_mult' to find a synthetic multiply when reasonable. */ | |
1974 | ||
68944452 JL |
1975 | #define RTX_COSTS(X,CODE,OUTER_CODE) \ |
1976 | case MULT: \ | |
1977 | if (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ | |
1978 | return COSTS_N_INSNS (3); \ | |
13ee407e | 1979 | return (TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT) \ |
68944452 JL |
1980 | ? COSTS_N_INSNS (8) : COSTS_N_INSNS (20); \ |
1981 | case DIV: \ | |
1982 | if (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ | |
1983 | return COSTS_N_INSNS (14); \ | |
1984 | case UDIV: \ | |
1985 | case MOD: \ | |
1986 | case UMOD: \ | |
1987 | return COSTS_N_INSNS (60); \ | |
1988 | case PLUS: /* this includes shNadd insns */ \ | |
1989 | case MINUS: \ | |
1990 | if (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ | |
1991 | return COSTS_N_INSNS (3); \ | |
1992 | return COSTS_N_INSNS (1); \ | |
1993 | case ASHIFT: \ | |
1994 | case ASHIFTRT: \ | |
1995 | case LSHIFTRT: \ | |
1996 | return COSTS_N_INSNS (1); | |
eabd3262 | 1997 | |
1150aa70 TG |
1998 | /* Adjust the cost of dependencies. */ |
1999 | ||
2000 | #define ADJUST_COST(INSN,LINK,DEP,COST) \ | |
2001 | (COST) = pa_adjust_cost (INSN, LINK, DEP, COST) | |
2002 | ||
7c4a1f08 JL |
2003 | /* Adjust scheduling priorities. We use this to try and keep addil |
2004 | and the next use of %r1 close together. */ | |
2005 | #define ADJUST_PRIORITY(PREV) \ | |
2006 | { \ | |
2007 | rtx set = single_set (PREV); \ | |
2008 | rtx src, dest; \ | |
2009 | if (set) \ | |
2010 | { \ | |
2011 | src = SET_SRC (set); \ | |
2012 | dest = SET_DEST (set); \ | |
2013 | if (GET_CODE (src) == LO_SUM \ | |
2014 | && symbolic_operand (XEXP (src, 1), VOIDmode) \ | |
2015 | && ! read_only_operand (XEXP (src, 1), VOIDmode)) \ | |
2016 | INSN_PRIORITY (PREV) >>= 3; \ | |
2017 | else if (GET_CODE (src) == MEM \ | |
2018 | && GET_CODE (XEXP (src, 0)) == LO_SUM \ | |
2019 | && symbolic_operand (XEXP (XEXP (src, 0), 1), VOIDmode)\ | |
2020 | && ! read_only_operand (XEXP (XEXP (src, 0), 1), VOIDmode))\ | |
2021 | INSN_PRIORITY (PREV) >>= 1; \ | |
2022 | else if (GET_CODE (dest) == MEM \ | |
2023 | && GET_CODE (XEXP (dest, 0)) == LO_SUM \ | |
2024 | && symbolic_operand (XEXP (XEXP (dest, 0), 1), VOIDmode)\ | |
2025 | && ! read_only_operand (XEXP (XEXP (dest, 0), 1), VOIDmode))\ | |
2026 | INSN_PRIORITY (PREV) >>= 3; \ | |
2027 | } \ | |
2028 | } | |
2029 | ||
04664e24 RS |
2030 | /* Handling the special cases is going to get too complicated for a macro, |
2031 | just call `pa_adjust_insn_length' to do the real work. */ | |
eabd3262 | 2032 | #define ADJUST_INSN_LENGTH(INSN, LENGTH) \ |
04664e24 RS |
2033 | LENGTH += pa_adjust_insn_length (INSN, LENGTH); |
2034 | ||
72abf941 JL |
2035 | /* Millicode insns are actually function calls with some special |
2036 | constraints on arguments and register usage. | |
2037 | ||
2038 | Millicode calls always expect their arguments in the integer argument | |
2039 | registers, and always return their result in %r29 (ret1). They | |
2040 | are expected to clobber their arguments, %r1, %r29, and %r31 and | |
2041 | nothing else. | |
2042 | ||
5a1c10de TG |
2043 | These macros tell reorg that the references to arguments and |
2044 | register clobbers for millicode calls do not appear to happen | |
72abf941 JL |
2045 | until after the millicode call. This allows reorg to put insns |
2046 | which set the argument registers into the delay slot of the millicode | |
2047 | call -- thus they act more like traditional CALL_INSNs. | |
2048 | ||
2049 | get_attr_type will try to recognize the given insn, so make sure to | |
d0ca05ef RS |
2050 | filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns |
2051 | in particular. */ | |
b9cd54d2 JL |
2052 | #define INSN_SETS_ARE_DELAYED(X) (insn_sets_and_refs_are_delayed (X)) |
2053 | #define INSN_REFERENCES_ARE_DELAYED(X) (insn_sets_and_refs_are_delayed (X)) | |
72abf941 | 2054 | |
eabd3262 RK |
2055 | \f |
2056 | /* Control the assembler format that we output. */ | |
2057 | ||
2058 | /* Output at beginning of assembler file. */ | |
2059 | ||
2060 | #define ASM_FILE_START(FILE) \ | |
e236a9ff | 2061 | do { fputs ("\t.SPACE $PRIVATE$\n\ |
eabd3262 | 2062 | \t.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31\n\ |
a291e551 | 2063 | \t.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82\n\ |
eabd3262 | 2064 | \t.SPACE $TEXT$\n\ |
c83eb049 | 2065 | \t.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44\n\ |
eabd3262 RK |
2066 | \t.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n\ |
2067 | \t.IMPORT $global$,DATA\n\ | |
e236a9ff | 2068 | \t.IMPORT $$dyncall,MILLICODE\n", FILE);\ |
eabd3262 | 2069 | if (profile_flag)\ |
a291e551 | 2070 | fprintf (FILE, "\t.IMPORT _mcount, CODE\n");\ |
a7c1e13f JL |
2071 | if (write_symbols != NO_DEBUG) \ |
2072 | output_file_directive ((FILE), main_input_filename); \ | |
eabd3262 RK |
2073 | } while (0) |
2074 | ||
359255a9 JL |
2075 | #define ASM_FILE_END(FILE) output_deferred_plabels (FILE) |
2076 | ||
eabd3262 RK |
2077 | /* Output to assembler file text saying following lines |
2078 | may contain character constants, extra white space, comments, etc. */ | |
2079 | ||
2080 | #define ASM_APP_ON "" | |
2081 | ||
2082 | /* Output to assembler file text saying following lines | |
2083 | no longer contain unusual constructs. */ | |
2084 | ||
2085 | #define ASM_APP_OFF "" | |
2086 | ||
3f8f5a3f | 2087 | /* We don't yet know how to identify GCC to HP-PA machines. */ |
e236a9ff | 2088 | #define ASM_IDENTIFY_GCC(FILE) fputs ("; gcc_compiled.:\n", FILE) |
eabd3262 RK |
2089 | |
2090 | /* Output before code. */ | |
2091 | ||
2092 | /* Supposedly the assembler rejects the command if there is no tab! */ | |
2093 | #define TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$\n" | |
2094 | ||
41ded289 JL |
2095 | /* Output before read-only data. */ |
2096 | ||
2097 | /* Supposedly the assembler rejects the command if there is no tab! */ | |
2098 | #define READONLY_DATA_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n" | |
ee80d1cd | 2099 | |
41ded289 JL |
2100 | #define READONLY_DATA_SECTION readonly_data |
2101 | ||
eabd3262 RK |
2102 | /* Output before writable data. */ |
2103 | ||
2104 | /* Supposedly the assembler rejects the command if there is no tab! */ | |
2105 | #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n" | |
2106 | ||
a291e551 JL |
2107 | /* Output before uninitialized data. */ |
2108 | ||
2109 | #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n" | |
2110 | ||
2111 | /* Define the .bss section for ASM_OUTPUT_LOCAL to use. */ | |
2112 | ||
ad238e4b | 2113 | #ifndef CTORS_SECTION_FUNCTION |
f7093a42 | 2114 | #define EXTRA_SECTIONS in_readonly_data |
ad238e4b JL |
2115 | #define CTORS_SECTION_FUNCTION |
2116 | #define DTORS_SECTION_FUNCTION | |
2117 | #else | |
f7093a42 | 2118 | #define EXTRA_SECTIONS in_readonly_data, in_ctors, in_dtors |
ad238e4b | 2119 | #endif |
a291e551 | 2120 | |
a688adc7 JL |
2121 | /* Switch into a generic section. |
2122 | This is currently only used to support section attributes. | |
2123 | ||
2124 | We make the section read-only and executable for a function decl, | |
2125 | read-only for a const data decl, and writable for a non-const data decl. */ | |
ad4ff310 | 2126 | #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ |
a688adc7 JL |
2127 | if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ |
2128 | { \ | |
2129 | fputs ("\t.SPACE $TEXT$\n", FILE); \ | |
2130 | fprintf (FILE, \ | |
dd56b31f JL |
2131 | "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24\n",\ |
2132 | TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \ | |
a688adc7 | 2133 | } \ |
ad4ff310 | 2134 | else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ |
a688adc7 JL |
2135 | { \ |
2136 | fputs ("\t.SPACE $TEXT$\n", FILE); \ | |
2137 | fprintf (FILE, \ | |
dd56b31f JL |
2138 | "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,SORT=16\n", \ |
2139 | TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \ | |
a688adc7 JL |
2140 | } \ |
2141 | else \ | |
2142 | { \ | |
2143 | fputs ("\t.SPACE $PRIVATE$\n", FILE); \ | |
2144 | fprintf (FILE, \ | |
4f0875a9 | 2145 | "\t.SUBSPA %s%s%s,QUAD=1,ALIGN=8,ACCESS=31,SORT=16\n", \ |
dd56b31f | 2146 | TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \ |
a688adc7 JL |
2147 | } |
2148 | ||
5bff1750 JL |
2149 | /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups |
2150 | which reference data within the $TEXT$ space (for example constant | |
2151 | strings in the $LIT$ subspace). | |
2152 | ||
2153 | The assemblers (GAS and HP as) both have problems with handling | |
2154 | the difference of two symbols which is the other correct way to | |
2155 | reference constant data during PIC code generation. | |
2156 | ||
2157 | So, there's no way to reference constant data which is in the | |
2158 | $TEXT$ space during PIC generation. Instead place all constant | |
2159 | data into the $PRIVATE$ subspace (this reduces sharing, but it | |
2160 | works correctly). */ | |
2161 | ||
a291e551 JL |
2162 | #define EXTRA_SECTION_FUNCTIONS \ |
2163 | void \ | |
41ded289 JL |
2164 | readonly_data () \ |
2165 | { \ | |
2166 | if (in_section != in_readonly_data) \ | |
2167 | { \ | |
6bb36601 | 2168 | if (flag_pic) \ |
5bff1750 | 2169 | fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); \ |
6bb36601 JL |
2170 | else \ |
2171 | fprintf (asm_out_file, "%s\n", READONLY_DATA_ASM_OP); \ | |
41ded289 JL |
2172 | in_section = in_readonly_data; \ |
2173 | } \ | |
ad238e4b JL |
2174 | } \ |
2175 | CTORS_SECTION_FUNCTION \ | |
2176 | DTORS_SECTION_FUNCTION | |
a291e551 JL |
2177 | |
2178 | ||
eabd3262 RK |
2179 | /* How to refer to registers in assembler output. |
2180 | This sequence is indexed by compiler's hard-register-number (see above). */ | |
2181 | ||
2182 | #define REGISTER_NAMES \ | |
a40ed31b TG |
2183 | {"%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \ |
2184 | "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \ | |
2185 | "%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23", \ | |
2186 | "%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31", \ | |
2187 | "%fr4", "%fr4R", "%fr5", "%fr5R", "%fr6", "%fr6R", "%fr7", "%fr7R", \ | |
2188 | "%fr8", "%fr8R", "%fr9", "%fr9R", "%fr10", "%fr10R", "%fr11", "%fr11R", \ | |
2189 | "%fr12", "%fr12R", "%fr13", "%fr13R", "%fr14", "%fr14R", "%fr15", "%fr15R", \ | |
2190 | "%fr16", "%fr16R", "%fr17", "%fr17R", "%fr18", "%fr18R", "%fr19", "%fr19R", \ | |
2191 | "%fr20", "%fr20R", "%fr21", "%fr21R", "%fr22", "%fr22R", "%fr23", "%fr23R", \ | |
2192 | "%fr24", "%fr24R", "%fr25", "%fr25R", "%fr26", "%fr26R", "%fr27", "%fr27R", \ | |
2193 | "%fr28", "%fr28R", "%fr29", "%fr29R", "%fr30", "%fr30R", "%fr31", "%fr31R", \ | |
eabd3262 RK |
2194 | "SAR"} |
2195 | ||
a40ed31b TG |
2196 | #define ADDITIONAL_REGISTER_NAMES \ |
2197 | {{"%fr4L",32}, {"%fr5L",34}, {"%fr6L",36}, {"%fr7L",38}, \ | |
2198 | {"%fr8L",40}, {"%fr9L",42}, {"%fr10L",44}, {"%fr11L",46}, \ | |
2199 | {"%fr12L",48}, {"%fr13L",50}, {"%fr14L",52}, {"%fr15L",54}, \ | |
2200 | {"%fr16L",56}, {"%fr17L",58}, {"%fr18L",60}, {"%fr19L",62}, \ | |
2201 | {"%fr20L",64}, {"%fr21L",66}, {"%fr22L",68}, {"%fr23L",70}, \ | |
2202 | {"%fr24L",72}, {"%fr25L",74}, {"%fr26L",76}, {"%fr27L",78}, \ | |
2203 | {"%fr28L",80}, {"%fr29L",82}, {"%fr30L",84}, {"%fr31R",86}, \ | |
2204 | {"%cr11",88}} | |
2205 | ||
fa6bc669 | 2206 | /* How to renumber registers for dbx and gdb. |
eabd3262 | 2207 | |
fa6bc669 JL |
2208 | Registers 0 - 31 remain unchanged. |
2209 | ||
a40ed31b | 2210 | Registers 32 - 87 are mapped to 72 - 127 |
fa6bc669 | 2211 | |
a40ed31b | 2212 | Register 88 is mapped to 32. */ |
fa6bc669 JL |
2213 | |
2214 | #define DBX_REGISTER_NUMBER(REGNO) \ | |
a40ed31b TG |
2215 | ((REGNO) <= 31 ? (REGNO) : \ |
2216 | ((REGNO) > 31 && (REGNO) <= 87 ? (REGNO) + 40 : 32)) | |
eabd3262 RK |
2217 | |
2218 | /* This is how to output the definition of a user-level label named NAME, | |
2219 | such as the label on a static function or variable NAME. */ | |
2220 | ||
2221 | #define ASM_OUTPUT_LABEL(FILE, NAME) \ | |
37d7333e | 2222 | do { assemble_name (FILE, NAME); \ |
37d7333e | 2223 | fputc ('\n', FILE); } while (0) |
eabd3262 RK |
2224 | |
2225 | /* This is how to output a command to make the user-level label named NAME | |
ad238e4b JL |
2226 | defined for reference from other files. |
2227 | ||
2228 | We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED. This | |
2229 | macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid | |
2230 | placing useless function definitions in the output file. */ | |
eabd3262 RK |
2231 | |
2232 | #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ | |
ad238e4b JL |
2233 | do { int save_referenced; \ |
2234 | save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \ | |
2235 | fputs ("\t.IMPORT ", FILE); \ | |
eabd3262 | 2236 | assemble_name (FILE, NAME); \ |
ff2b6252 | 2237 | if (FUNCTION_NAME_P (NAME)) \ |
eabd3262 | 2238 | fputs (",CODE\n", FILE); \ |
ff2b6252 TM |
2239 | else \ |
2240 | fputs (",DATA\n", FILE); \ | |
ad238e4b | 2241 | TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \ |
eabd3262 RK |
2242 | } while (0) |
2243 | ||
5a1c10de | 2244 | /* The bogus HP assembler requires ALL external references to be |
eabd3262 | 2245 | "imported", even library calls. They look a bit different, so |
15ac8ba0 JL |
2246 | here's this macro. |
2247 | ||
2248 | Also note not all libcall names are passed to ENCODE_SECTION_INFO | |
2249 | (__main for example). To make sure all libcall names have section | |
2250 | info recorded in them, we do it here. */ | |
eabd3262 RK |
2251 | |
2252 | #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \ | |
2253 | do { fputs ("\t.IMPORT ", FILE); \ | |
15ac8ba0 | 2254 | if (!function_label_operand (RTL, VOIDmode)) \ |
4f6cd2e6 | 2255 | hppa_encode_label (RTL, 1); \ |
eabd3262 RK |
2256 | assemble_name (FILE, XSTR ((RTL), 0)); \ |
2257 | fputs (",CODE\n", FILE); \ | |
2258 | } while (0) | |
2259 | ||
2260 | #define ASM_GLOBALIZE_LABEL(FILE, NAME) \ | |
91535895 TG |
2261 | do { \ |
2262 | /* We only handle DATA objects here, functions are globalized in \ | |
2263 | ASM_DECLARE_FUNCTION_NAME. */ \ | |
2264 | if (! FUNCTION_NAME_P (NAME)) \ | |
2265 | { \ | |
2266 | fputs ("\t.EXPORT ", FILE); \ | |
2267 | assemble_name (FILE, NAME); \ | |
2268 | fputs (",DATA\n", FILE); \ | |
2269 | } \ | |
2270 | } while (0) | |
eabd3262 RK |
2271 | |
2272 | /* This is how to output a reference to a user-level label named NAME. | |
2273 | `assemble_name' uses this. */ | |
2274 | ||
2275 | #define ASM_OUTPUT_LABELREF(FILE,NAME) \ | |
ff2b6252 | 2276 | fprintf ((FILE), "%s", (NAME) + (FUNCTION_NAME_P (NAME) ? 1 : 0)) |
eabd3262 RK |
2277 | |
2278 | /* This is how to output an internal numbered label where | |
2279 | PREFIX is the class of label and NUM is the number within the class. */ | |
2280 | ||
2281 | #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ | |
2822d96e | 2282 | {fprintf (FILE, "%c$%s%04d\n", (PREFIX)[0], (PREFIX) + 1, NUM);} |
eabd3262 RK |
2283 | |
2284 | /* This is how to store into the string LABEL | |
2285 | the symbol_ref name of an internal numbered label where | |
2286 | PREFIX is the class of label and NUM is the number within the class. | |
2287 | This is suitable for output with `assemble_name'. */ | |
2288 | ||
2289 | #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ | |
77541d4e | 2290 | sprintf (LABEL, "*%c$%s%04d", (PREFIX)[0], (PREFIX) + 1, NUM) |
eabd3262 RK |
2291 | |
2292 | /* This is how to output an assembler line defining a `double' constant. */ | |
2293 | ||
2294 | #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ | |
74356a72 TG |
2295 | do { long l[2]; \ |
2296 | REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \ | |
2297 | fprintf (FILE, "\t.word 0x%lx\n\t.word 0x%lx\n", l[0], l[1]); \ | |
2298 | } while (0) | |
eabd3262 RK |
2299 | |
2300 | /* This is how to output an assembler line defining a `float' constant. */ | |
2301 | ||
2302 | #define ASM_OUTPUT_FLOAT(FILE,VALUE) \ | |
74356a72 TG |
2303 | do { long l; \ |
2304 | REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ | |
2305 | fprintf (FILE, "\t.word 0x%lx\n", l); \ | |
2306 | } while (0) | |
eabd3262 | 2307 | |
3ba1236f JL |
2308 | /* This is how to output an assembler line defining an `int' constant. |
2309 | ||
2310 | This is made more complicated by the fact that functions must be | |
2311 | prefixed by a P% as well as code label references for the exception | |
2312 | table -- otherwise the linker chokes. */ | |
eabd3262 RK |
2313 | |
2314 | #define ASM_OUTPUT_INT(FILE,VALUE) \ | |
e236a9ff | 2315 | { fputs ("\t.word ", FILE); \ |
2822d96e JL |
2316 | if (function_label_operand (VALUE, VOIDmode) \ |
2317 | && !TARGET_PORTABLE_RUNTIME) \ | |
a24d629d | 2318 | fputs ("P%", FILE); \ |
c2ae03cb | 2319 | output_addr_const (FILE, (VALUE)); \ |
e236a9ff | 2320 | fputs ("\n", FILE);} |
eabd3262 RK |
2321 | |
2322 | /* Likewise for `short' and `char' constants. */ | |
2323 | ||
2324 | #define ASM_OUTPUT_SHORT(FILE,VALUE) \ | |
e236a9ff | 2325 | ( fputs ("\t.half ", FILE), \ |
eabd3262 | 2326 | output_addr_const (FILE, (VALUE)), \ |
e236a9ff | 2327 | fputs ("\n", FILE)) |
eabd3262 RK |
2328 | |
2329 | #define ASM_OUTPUT_CHAR(FILE,VALUE) \ | |
e236a9ff | 2330 | ( fputs ("\t.byte ", FILE), \ |
eabd3262 | 2331 | output_addr_const (FILE, (VALUE)), \ |
e236a9ff | 2332 | fputs ("\n", FILE)) |
eabd3262 RK |
2333 | |
2334 | /* This is how to output an assembler line for a numeric constant byte. */ | |
2335 | ||
2336 | #define ASM_OUTPUT_BYTE(FILE,VALUE) \ | |
2337 | fprintf (FILE, "\t.byte 0x%x\n", (VALUE)) | |
2338 | ||
2339 | #define ASM_OUTPUT_ASCII(FILE, P, SIZE) \ | |
2340 | output_ascii ((FILE), (P), (SIZE)) | |
2341 | ||
d2a94ec0 | 2342 | #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) |
5a1c10de | 2343 | #define ASM_OUTPUT_REG_POP(FILE,REGNO) |
eabd3262 RK |
2344 | /* This is how to output an element of a case-vector that is absolute. |
2345 | Note that this method makes filling these branch delay slots | |
3518f904 | 2346 | impossible. */ |
eabd3262 RK |
2347 | |
2348 | #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ | |
3e056efc JL |
2349 | if (TARGET_BIG_SWITCH) \ |
2350 | fprintf (FILE, "\tstw %%r1,-16(%%r30)\n\tldil LR'L$%04d,%%r1\n\tbe RR'L$%04d(%%sr4,%%r1)\n\tldw -16(%%r30),%%r1\n", VALUE, VALUE); \ | |
2351 | else \ | |
2352 | fprintf (FILE, "\tb L$%04d\n\tnop\n", VALUE) | |
eabd3262 | 2353 | |
63671b34 | 2354 | /* Jump tables are executable code and live in the TEXT section on the PA. */ |
75197b37 | 2355 | #define JUMP_TABLES_IN_TEXT_SECTION 1 |
63671b34 | 2356 | |
eabd3262 | 2357 | /* This is how to output an element of a case-vector that is relative. |
cface026 JL |
2358 | This must be defined correctly as it is used when generating PIC code. |
2359 | ||
ddd5a7c1 | 2360 | I believe it safe to use the same definition as ASM_OUTPUT_ADDR_VEC_ELT |
cface026 JL |
2361 | on the PA since ASM_OUTPUT_ADDR_VEC_ELT uses pc-relative jump instructions |
2362 | rather than a table of absolute addresses. */ | |
eabd3262 | 2363 | |
33f7f353 | 2364 | #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ |
3e056efc | 2365 | if (TARGET_BIG_SWITCH) \ |
f24d52e1 | 2366 | fprintf (FILE, "\tstw %%r1,-16(%%r30)\n\tldw T'L$%04d(%%r19),%%r1\n\tbv %%r0(%%r1)\n\tldw -16(%%r30),%%r1\n", VALUE); \ |
3e056efc JL |
2367 | else \ |
2368 | fprintf (FILE, "\tb L$%04d\n\tnop\n", VALUE) | |
eabd3262 RK |
2369 | |
2370 | /* This is how to output an assembler line | |
2371 | that says to advance the location counter | |
2372 | to a multiple of 2**LOG bytes. */ | |
2373 | ||
2374 | #define ASM_OUTPUT_ALIGN(FILE,LOG) \ | |
2375 | fprintf (FILE, "\t.align %d\n", (1<<(LOG))) | |
2376 | ||
2377 | #define ASM_OUTPUT_SKIP(FILE,SIZE) \ | |
2378 | fprintf (FILE, "\t.blockz %d\n", (SIZE)) | |
2379 | ||
6b282118 JL |
2380 | /* This says how to output an assembler line to define a global common symbol |
2381 | with size SIZE (in bytes) and alignment ALIGN (in bits). */ | |
a291e551 | 2382 | |
6b282118 JL |
2383 | #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGNED) \ |
2384 | { bss_section (); \ | |
2385 | assemble_name ((FILE), (NAME)); \ | |
2386 | fputs ("\t.comm ", (FILE)); \ | |
2387 | fprintf ((FILE), "%d\n", MAX ((SIZE), ((ALIGNED) / BITS_PER_UNIT)));} | |
a291e551 | 2388 | |
6b282118 JL |
2389 | /* This says how to output an assembler line to define a local common symbol |
2390 | with size SIZE (in bytes) and alignment ALIGN (in bits). */ | |
eabd3262 | 2391 | |
6b282118 JL |
2392 | #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGNED) \ |
2393 | { bss_section (); \ | |
2394 | fprintf ((FILE), "\t.align %d\n", ((ALIGNED) / BITS_PER_UNIT)); \ | |
37d7333e | 2395 | assemble_name ((FILE), (NAME)); \ |
6b282118 JL |
2396 | fprintf ((FILE), "\n\t.block %d\n", (SIZE));} |
2397 | ||
eabd3262 RK |
2398 | /* Store in OUTPUT a string (made with alloca) containing |
2399 | an assembler-name for a local static variable named NAME. | |
2400 | LABELNO is an integer which is different for each call. */ | |
2401 | ||
2402 | #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ | |
2403 | ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 12), \ | |
2404 | sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO))) | |
2405 | ||
2406 | /* Define the parentheses used to group arithmetic operations | |
2407 | in assembler code. */ | |
2408 | ||
2409 | #define ASM_OPEN_PAREN "(" | |
2410 | #define ASM_CLOSE_PAREN ")" | |
2411 | ||
5921f26b JL |
2412 | /* All HP assemblers use "!" to separate logical lines. */ |
2413 | #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '!') | |
2414 | ||
eabd3262 RK |
2415 | /* Define results of standard character escape sequences. */ |
2416 | #define TARGET_BELL 007 | |
2417 | #define TARGET_BS 010 | |
2418 | #define TARGET_TAB 011 | |
2419 | #define TARGET_NEWLINE 012 | |
2420 | #define TARGET_VT 013 | |
2421 | #define TARGET_FF 014 | |
2422 | #define TARGET_CR 015 | |
2423 | ||
2424 | #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \ | |
2425 | ((CHAR) == '@' || (CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^') | |
2426 | ||
2427 | /* Print operand X (an rtx) in assembler syntax to file FILE. | |
2428 | CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. | |
2429 | For `%' followed by punctuation, CODE is the punctuation and X is null. | |
2430 | ||
3f8f5a3f | 2431 | On the HP-PA, the CODE can be `r', meaning this is a register-only operand |
eabd3262 RK |
2432 | and an immediate zero should be represented as `r0'. |
2433 | ||
2434 | Several % codes are defined: | |
2435 | O an operation | |
2436 | C compare conditions | |
2437 | N extract conditions | |
2438 | M modifier to handle preincrement addressing for memory refs. | |
2439 | F modifier to handle preincrement addressing for fp memory refs */ | |
2440 | ||
2441 | #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE) | |
2442 | ||
2443 | \f | |
2444 | /* Print a memory address as an operand to reference that memory location. */ | |
2445 | ||
2446 | #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \ | |
2447 | { register rtx addr = ADDR; \ | |
2448 | register rtx base; \ | |
2449 | int offset; \ | |
2450 | switch (GET_CODE (addr)) \ | |
2451 | { \ | |
2452 | case REG: \ | |
d2d28085 | 2453 | fprintf (FILE, "0(%s)", reg_names [REGNO (addr)]); \ |
eabd3262 RK |
2454 | break; \ |
2455 | case PLUS: \ | |
2456 | if (GET_CODE (XEXP (addr, 0)) == CONST_INT) \ | |
2457 | offset = INTVAL (XEXP (addr, 0)), base = XEXP (addr, 1); \ | |
2458 | else if (GET_CODE (XEXP (addr, 1)) == CONST_INT) \ | |
2459 | offset = INTVAL (XEXP (addr, 1)), base = XEXP (addr, 0); \ | |
2460 | else \ | |
2461 | abort (); \ | |
d2d28085 | 2462 | fprintf (FILE, "%d(%s)", offset, reg_names [REGNO (base)]); \ |
eabd3262 RK |
2463 | break; \ |
2464 | case LO_SUM: \ | |
0f8f654e RK |
2465 | if (!symbolic_operand (XEXP (addr, 1))) \ |
2466 | fputs ("R'", FILE); \ | |
2467 | else if (flag_pic == 0) \ | |
2468 | fputs ("RR'", FILE); \ | |
6bb36601 JL |
2469 | else if (flag_pic == 1) \ |
2470 | abort (); \ | |
2471 | else if (flag_pic == 2) \ | |
2472 | fputs ("RT'", FILE); \ | |
ad238e4b | 2473 | output_global_address (FILE, XEXP (addr, 1), 0); \ |
eabd3262 RK |
2474 | fputs ("(", FILE); \ |
2475 | output_operand (XEXP (addr, 0), 0); \ | |
2476 | fputs (")", FILE); \ | |
2477 | break; \ | |
09a1d028 | 2478 | case CONST_INT: \ |
81a1c8c3 | 2479 | fprintf (FILE, "%d(%%r0)", INTVAL (addr)); \ |
09a1d028 | 2480 | break; \ |
eabd3262 RK |
2481 | default: \ |
2482 | output_addr_const (FILE, addr); \ | |
2483 | }} | |
2484 | ||
2485 | \f | |
09a1d028 | 2486 | /* Define functions in pa.c and used in insn-output.c. */ |
eabd3262 | 2487 | |
7254dbd4 TG |
2488 | extern char *output_and (); |
2489 | extern char *output_ior (); | |
eabd3262 RK |
2490 | extern char *output_move_double (); |
2491 | extern char *output_fp_move_double (); | |
2492 | extern char *output_block_move (); | |
eabd3262 | 2493 | extern char *output_cbranch (); |
e6878cb9 | 2494 | extern char *output_bb (); |
ad238e4b | 2495 | extern char *output_bvb (); |
6bd5174e JL |
2496 | extern char *output_dbra (); |
2497 | extern char *output_movb (); | |
b1092901 JL |
2498 | extern char *output_parallel_movb (); |
2499 | extern char *output_parallel_addb (); | |
eabd3262 | 2500 | extern char *output_return (); |
0a1daad4 | 2501 | extern char *output_call (); |
ad238e4b | 2502 | extern char *output_millicode_call (); |
eabd3262 RK |
2503 | extern char *output_mul_insn (); |
2504 | extern char *output_div_insn (); | |
2505 | extern char *output_mod_insn (); | |
a4e4b55c | 2506 | extern char *singlemove_string (); |
eabd3262 | 2507 | extern void output_arg_descriptor (); |
0b17dd98 KG |
2508 | extern void output_deferred_plabels (); |
2509 | extern void override_options (); | |
2510 | extern void output_ascii (); | |
2511 | extern void output_function_prologue (); | |
2512 | extern void output_function_epilogue (); | |
eabd3262 | 2513 | extern void output_global_address (); |
0b17dd98 | 2514 | extern void print_operand (); |
eabd3262 | 2515 | extern struct rtx_def *legitimize_pic_address (); |
4fc473c1 | 2516 | extern struct rtx_def *gen_cmp_fp (); |
d2a94ec0 | 2517 | extern void hppa_encode_label (); |
ba0b8436 | 2518 | extern int arith11_operand (); |
0b17dd98 KG |
2519 | extern int symbolic_expression_p (); |
2520 | extern int reloc_needed (); | |
2521 | extern int compute_frame_size (); | |
2522 | extern int hppa_address_cost (); | |
2523 | extern int and_mask_p (); | |
2524 | extern int symbolic_memory_operand (); | |
2525 | extern int pa_adjust_cost (); | |
2526 | extern int pa_adjust_insn_length (); | |
ba0b8436 JL |
2527 | extern int int11_operand (); |
2528 | extern int reg_or_cint_move_operand (); | |
2529 | extern int arith5_operand (); | |
2530 | extern int uint5_operand (); | |
2531 | extern int pic_label_operand (); | |
2532 | extern int plus_xor_ior_operator (); | |
2533 | extern int basereg_operand (); | |
2534 | extern int shadd_operand (); | |
2535 | extern int arith_operand (); | |
2536 | extern int read_only_operand (); | |
2537 | extern int move_operand (); | |
2538 | extern int and_operand (); | |
2539 | extern int ior_operand (); | |
2540 | extern int arith32_operand (); | |
2541 | extern int uint32_operand (); | |
2542 | extern int reg_or_nonsymb_mem_operand (); | |
2543 | extern int reg_or_0_operand (); | |
2544 | extern int reg_or_0_or_nonsymb_mem_operand (); | |
2545 | extern int pre_cint_operand (); | |
2546 | extern int post_cint_operand (); | |
2547 | extern int div_operand (); | |
2548 | extern int int5_operand (); | |
2549 | extern int movb_comparison_operator (); | |
2550 | extern int ireg_or_int5_operand (); | |
2551 | extern int fmpyaddoperands (); | |
2552 | extern int fmpysuboperands (); | |
2553 | extern int call_operand_address (); | |
2554 | extern int cint_ok_for_move (); | |
2555 | extern int ior_operand (); | |
2556 | extern void emit_bcond_fp (); | |
2557 | extern int emit_move_sequence (); | |
2558 | extern int emit_hpdiv_const (); | |
2559 | extern void hppa_expand_prologue (); | |
2560 | extern void hppa_expand_epilogue (); | |
2561 | extern int hppa_can_use_return_insn_p (); | |
2562 | extern int is_function_label_plus_const (); | |
2563 | extern int jump_in_call_delay (); | |
0b17dd98 | 2564 | extern enum reg_class secondary_reload_class (); |
b9cd54d2 | 2565 | extern int insn_sets_and_refs_are_delayed (); |
81f433e4 | 2566 | |
e99d6592 MS |
2567 | /* Declare functions defined in pa.c and used in templates. */ |
2568 | ||
2569 | extern struct rtx_def *return_addr_rtx (); | |
2570 | ||
a65c4284 | 2571 | /* We want __gcc_plt_call to appear in every program built by |
185496bb RK |
2572 | gcc, so we make a reference to it out of __main. |
2573 | We use the asm statement to fool the optimizer into not | |
2574 | removing the dead (but important) initialization of | |
2575 | REFERENCE. */ | |
2576 | ||
bbe79f84 MS |
2577 | #define DO_GLOBAL_DTORS_BODY \ |
2578 | do { \ | |
2579 | extern void __gcc_plt_call (); \ | |
2580 | void (*reference)() = &__gcc_plt_call; \ | |
2581 | func_ptr *p; \ | |
2582 | __asm__ ("" : : "r" (reference)); \ | |
2583 | for (p = __DTOR_LIST__ + 1; *p; ) \ | |
2584 | (*p++) (); \ | |
ffa8b829 | 2585 | } while (0) |
bbe79f84 | 2586 | |
e99d6592 MS |
2587 | /* Find the return address associated with the frame given by |
2588 | FRAMEADDR. */ | |
2589 | #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \ | |
2590 | (return_addr_rtx (COUNT, FRAMEADDR)) | |
bbe79f84 MS |
2591 | |
2592 | /* Used to mask out junk bits from the return address, such as | |
2593 | processor state, interrupt status, condition codes and the like. */ | |
e99d6592 MS |
2594 | #define MASK_RETURN_ADDR \ |
2595 | /* The privilege level is in the two low order bits, mask em out \ | |
bbe79f84 MS |
2596 | of the return address. */ \ |
2597 | (GEN_INT (0xfffffffc)) | |
27a36778 MS |
2598 | |
2599 | /* The number of Pmode words for the setjmp buffer. */ | |
2600 | #define JMP_BUF_SIZE 50 |