]> gcc.gnu.org Git - gcc.git/blame - gcc/config/ns32k/ns32k.h
target.h (asm_out.file_start, [...]): New hooks.
[gcc.git] / gcc / config / ns32k / ns32k.h
CommitLineData
231ddcb7 1/* Definitions of target machine for GNU compiler. NS32000 version.
cf011243 2 Copyright (C) 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
16c484c7 3 2001, 2002 Free Software Foundation, Inc.
879cad45 4 Contributed by Michael Tiemann (tiemann@cygnus.com)
231ddcb7
RS
5
6This file is part of GNU CC.
7
8GNU CC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2, or (at your option)
11any later version.
12
13GNU CC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU CC; see the file COPYING. If not, write to
0e29e3c9
RK
20the Free Software Foundation, 59 Temple Place - Suite 330,
21Boston, MA 02111-1307, USA. */
231ddcb7
RS
22
23
a782515b
JT
24#define TARGET_CPU_CPP_BUILTINS() \
25 do \
26 { \
27 builtin_define ("__ns32000__"); \
28 \
29 /* CPU type */ \
30 if (TARGET_32532) \
31 builtin_define ("__ns32532__"); \
32 else if (TARGET_32332) \
33 builtin_define ("__ns32332__"); \
34 else \
35 builtin_define ("__ns32032__"); \
36 \
37 /* FPU type */ \
38 if (TARGET_32381) \
39 builtin_define ("__ns32381__"); \
40 else if (TARGET_32081) \
41 builtin_define ("__ns32081__"); \
42 \
43 /* Misc. */ \
44 if (TARGET_RTD) \
45 builtin_define ("__RTD__"); \
46 \
47 builtin_assert ("cpu=ns32k"); \
48 builtin_assert ("machine=ns32k"); \
49 } \
50 while (0)
231ddcb7
RS
51
52/* Print subsidiary information on the compiler version in use. */
53#define TARGET_VERSION fprintf (stderr, " (32000, GAS syntax)");
54
55\f
56/* ABSOLUTE PREFIX, IMMEDIATE_PREFIX and EXTERNAL_PREFIX can be defined
57 to cover most NS32k addressing syntax variations. This way we don't
58 need to redefine long macros in all the tm.h files for just slight
59 variations in assembler syntax. */
60
61#ifndef ABSOLUTE_PREFIX
62#define ABSOLUTE_PREFIX '@'
63#endif
64
65#if defined(IMMEDIATE_PREFIX) && IMMEDIATE_PREFIX
66#define PUT_IMMEDIATE_PREFIX(FILE) putc(IMMEDIATE_PREFIX, FILE)
67#else
68#define PUT_IMMEDIATE_PREFIX(FILE)
69#endif
70#if defined(ABSOLUTE_PREFIX) && ABSOLUTE_PREFIX
71#define PUT_ABSOLUTE_PREFIX(FILE) putc(ABSOLUTE_PREFIX, FILE)
72#else
73#define PUT_ABSOLUTE_PREFIX(FILE)
74#endif
75#if defined(EXTERNAL_PREFIX) && EXTERNAL_PREFIX
76#define PUT_EXTERNAL_PREFIX(FILE) putc(EXTERNAL_PREFIX, FILE)
77#else
78#define PUT_EXTERNAL_PREFIX(FILE)
79#endif
80
81/* Run-time compilation parameters selecting different hardware subsets. */
82
83extern int target_flags;
84
5d7c2819 85/* Masks for target_flags */
2eb2901a
JT
86#define MASK_32081 1
87#define MASK_RTD 2
88#define MASK_REGPARM 4
89#define MASK_32532 8
90#define MASK_32332 16
91#define MASK_NO_SB 32
92#define MASK_NO_BITFIELD 64
93#define MASK_HIMEM 128
94#define MASK_32381 256
95#define MASK_MULT_ADD 512
96#define MASK_SRC 1024
5d7c2819 97#define MASK_IEEE_COMPARE 2048
2eb2901a 98
231ddcb7
RS
99/* Macros used in the machine description to test the flags. */
100
101/* Compile 32081 insns for floating point (not library calls). */
2eb2901a
JT
102#define TARGET_32081 (target_flags & MASK_32081)
103#define TARGET_32381 (target_flags & MASK_32381)
83575957 104
4c54e4e4
ID
105/* The use of multiply-add instructions is optional because there may
106 * be cases where it produces worse code.
83575957
ID
107 */
108
2eb2901a 109#define TARGET_MULT_ADD (target_flags & MASK_MULT_ADD)
231ddcb7
RS
110
111/* Compile using rtd insn calling sequence.
112 This will not work unless you use prototypes at least
113 for all functions that can take varying numbers of args. */
2eb2901a 114#define TARGET_RTD (target_flags & MASK_RTD)
231ddcb7
RS
115
116/* Compile passing first two args in regs 0 and 1. */
2eb2901a 117#define TARGET_REGPARM (target_flags & MASK_REGPARM)
231ddcb7
RS
118
119/* Options to select type of CPU, for better optimization.
120 The output is correct for any kind of 32000 regardless of these options. */
2eb2901a
JT
121#define TARGET_32532 (target_flags & MASK_32532)
122#define TARGET_32332 (target_flags & MASK_32332)
231ddcb7
RS
123
124/* Ok to use the static base register (and presume it's 0) */
2eb2901a 125#define TARGET_SB ((target_flags & MASK_NO_SB) == 0)
5d7c2819 126
2eb2901a 127#define TARGET_HIMEM (target_flags & MASK_HIMEM)
231ddcb7 128
43a88a8c 129/* Compile using bit-field insns. */
2eb2901a 130#define TARGET_BITFIELD ((target_flags & MASK_NO_BITFIELD) == 0)
879cad45 131
ac14c725 132#define TARGET_IEEE_COMPARE (target_flags & MASK_IEEE_COMPARE)
5d7c2819 133
231ddcb7
RS
134/* Macro to define tables used to set the flags.
135 This is a list in braces of pairs in braces,
136 each pair being { "NAME", VALUE }
137 where VALUE is the bits to set or minus the bits to clear.
138 An empty string NAME is used to identify the default VALUE. */
047142d3 139#define TARGET_SWITCHES \
2eb2901a
JT
140 { { "32081", MASK_32081, N_("Use hardware fp")}, \
141 { "soft-float", -(MASK_32081|MASK_32381), \
142 N_("Don't use hardware fp")}, \
143 { "rtd", MASK_RTD, N_("Alternative calling convention")}, \
144 { "nortd", -MASK_RTD, N_("Use normal calling convention")}, \
145 { "regparm", MASK_REGPARM, N_("Pass some arguments in registers")}, \
146 { "noregparm", -MASK_REGPARM, N_("Pass all arguments on stack")}, \
147 { "32532", MASK_32532|MASK_32332, N_("Optimize for 32532 cpu")}, \
148 { "32332", MASK_32332, N_("Optimize for 32332 cpu")}, \
149 { "32332", -MASK_32532, 0}, \
150 { "32032", -(MASK_32532|MASK_32332), N_("Optimize for 32032")}, \
151 { "sb", -MASK_NO_SB, \
047142d3 152 N_("Register sb is zero. Use for absolute addressing")}, \
2eb2901a
JT
153 { "nosb", MASK_NO_SB, N_("Do not use register sb")}, \
154 { "bitfield", -MASK_NO_BITFIELD, \
5d7c2819
ID
155 N_("Use bit-field instructions")}, \
156 { "nobitfield", MASK_NO_BITFIELD, \
2eb2901a 157 N_("Do not use bit-field instructions")}, \
2eb2901a
JT
158 { "himem", MASK_HIMEM, N_("Generate code for high memory")}, \
159 { "nohimem", -MASK_HIMEM, N_("Generate code for low memory")}, \
160 { "32381", MASK_32381, N_("32381 fpu")}, \
161 { "mult-add", MASK_MULT_ADD, \
162 N_("Use multiply-accumulate fp instructions")}, \
163 { "nomult-add", -MASK_MULT_ADD, \
5d7c2819 164 N_("Do not use multiply-accumulate fp instructions") }, \
2eb2901a
JT
165 { "src", MASK_SRC, N_("\"Small register classes\" kludge")}, \
166 { "nosrc", -MASK_SRC, N_("No \"Small register classes\" kludge")}, \
5d7c2819
ID
167 { "ieee-compare", MASK_IEEE_COMPARE, N_("Use IEEE math for fp comparisons")}, \
168 { "noieee-compare", -MASK_IEEE_COMPARE, \
169 N_("Do not use IEEE math for fp comparisons")}, \
4c54e4e4 170 { "", TARGET_DEFAULT, 0}}
83575957 171
231ddcb7 172/* TARGET_DEFAULT is defined in encore.h, pc532.h, etc. */
666b023e
RK
173
174/* When we are generating PIC, the sb is used as a pointer
83575957 175 to the GOT. 32381 is a superset of 32081 */
666b023e 176
5d7c2819
ID
177#define OVERRIDE_OPTIONS \
178{ \
179 if (target_flags & MASK_32532) \
180 target_flags |= MASK_32332; \
181 if (flag_pic || TARGET_HIMEM) \
182 target_flags |= MASK_NO_SB; \
183 if (TARGET_32381) \
184 target_flags |= MASK_32081; \
185 else \
186 target_flags &= ~MASK_MULT_ADD; \
187 if (flag_unsafe_math_optimizations) \
188 target_flags &= ~MASK_IEEE_COMPARE; \
666b023e
RK
189}
190
83575957
ID
191/* Zero or more C statements that may conditionally modify two
192 variables `fixed_regs' and `call_used_regs' (both of type `char
193 []') after they have been initialized from the two preceding
194 macros.
195
196 This is necessary in case the fixed or call-clobbered registers
197 depend on target flags.
198
199 You need not define this macro if it has no work to do.
200
201 If the usage of an entire class of registers depends on the target
202 flags, you may indicate this to GCC by using this macro to modify
203 `fixed_regs' and `call_used_regs' to 1 for each of the registers in
204 the classes which should not be used by GCC. Also define the macro
205 `REG_CLASS_FROM_LETTER' to return `NO_REGS' if it is called with a
206 letter for a class that shouldn't be used.
207
208 (However, if this class is not included in `GENERAL_REGS' and all
209 of the insn patterns whose constraints permit this class are
210 controlled by target switches, then GCC will automatically avoid
211 using these registers when the target switches are opposed to
212 them.) */
213
214#define CONDITIONAL_REGISTER_USAGE \
215do \
216 { \
217 if (!TARGET_32081) \
218 { \
219 int regno; \
220 \
221 for (regno = F0_REGNUM; regno <= F0_REGNUM + 8; regno++) \
222 fixed_regs[regno] = call_used_regs[regno] = 1; \
223 } \
224 if (!TARGET_32381) \
225 { \
226 int regno; \
227 \
228 for (regno = L1_REGNUM; regno <= L1_REGNUM + 8; regno++) \
229 fixed_regs[regno] = call_used_regs[regno] = 1; \
230 } \
231 } \
232while (0)
233
231ddcb7
RS
234\f
235/* target machine storage layout */
236
237/* Define this if most significant bit is lowest numbered
238 in instructions that operate on numbered bit-fields.
239 This is not true on the ns32k. */
240#define BITS_BIG_ENDIAN 0
241
242/* Define this if most significant byte of a word is the lowest numbered. */
243/* That is not true on the ns32k. */
244#define BYTES_BIG_ENDIAN 0
245
246/* Define this if most significant word of a multiword number is lowest
247 numbered. This is not true on the ns32k. */
248#define WORDS_BIG_ENDIAN 0
249
231ddcb7
RS
250/* Width of a word, in units (bytes). */
251#define UNITS_PER_WORD 4
252
231ddcb7
RS
253/* Allocation boundary (in *bits*) for storing arguments in argument list. */
254#define PARM_BOUNDARY 32
255
256/* Boundary (in *bits*) on which stack pointer should be aligned. */
257#define STACK_BOUNDARY 32
258
259/* Allocation boundary (in *bits*) for the code of a function. */
260#define FUNCTION_BOUNDARY 16
261
262/* Alignment of field after `int : 0' in a structure. */
263#define EMPTY_FIELD_BOUNDARY 32
264
265/* Every structure's size must be a multiple of this. */
266#define STRUCTURE_SIZE_BOUNDARY 8
267
268/* No data type wants to be aligned rounder than this. */
269#define BIGGEST_ALIGNMENT 32
270
dfbe1b2f 271/* Set this nonzero if move instructions will actually fail to work
231ddcb7
RS
272 when given unaligned data. National claims that the NS32032
273 works without strict alignment, but rumor has it that operands
274 crossing a page boundary cause unpredictable results. */
dfbe1b2f 275#define STRICT_ALIGNMENT 1
231ddcb7 276
f710504c 277/* If bit field type is int, don't let it cross an int,
231ddcb7 278 and give entire struct the alignment of an int. */
43a88a8c 279/* Required on the 386 since it doesn't have a full set of bit-field insns.
231ddcb7
RS
280 (There is no signed extv insn.) */
281#define PCC_BITFIELD_TYPE_MATTERS 1
282\f
283/* Standard register usage. */
284
285/* Number of actual hardware registers.
286 The hardware registers are assigned numbers for the compiler
287 from 0 to just below FIRST_PSEUDO_REGISTER.
288 All registers that the compiler knows about must be given numbers,
289 even those that are not normally considered general registers. */
83575957 290#define FIRST_PSEUDO_REGISTER 26
231ddcb7
RS
291
292/* 1 for registers that have pervasive standard uses
293 and are not available for the register allocator.
294 On the ns32k, these are the FP, SP, (SB and PC are not included here). */
295#define FIXED_REGISTERS {0, 0, 0, 0, 0, 0, 0, 0, \
296 0, 0, 0, 0, 0, 0, 0, 0, \
83575957 297 0, 0, 0, 0, 0, 0, 0, 0, \
231ddcb7
RS
298 1, 1}
299
300/* 1 for registers not available across function calls.
301 These must include the FIXED_REGISTERS and also any
302 registers that can be used without being saved.
303 The latter must include the registers where values are returned
304 and the register where structure-value addresses are passed.
305 Aside from that, you can include as many other registers as you like. */
306#define CALL_USED_REGISTERS {1, 1, 1, 0, 0, 0, 0, 0, \
307 1, 1, 1, 1, 0, 0, 0, 0, \
83575957 308 1, 1, 0, 0, 0, 0, 0, 0, \
231ddcb7
RS
309 1, 1}
310
83575957
ID
311/* How to refer to registers in assembler output.
312 This sequence is indexed by compiler's hard-register-number (see above). */
313
314#define REGISTER_NAMES \
315{"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
316 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
317 "l1", "l1h","l3", "l3h","l5", "l5h","l7", "l7h", \
318 "fp", "sp"}
319
320
321#define ADDITIONAL_REGISTER_NAMES \
322{{"l0", 8}, {"l2", 10}, {"l4", 12}, {"l6", 14}}
323
324/* l0-7 are not recognized by the assembler. These are the names to use,
325 * but we don't want ambiguous names in REGISTER_NAMES
326 */
327#define OUTPUT_REGISTER_NAMES \
328{"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
329 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
330 "f1", "l1h","f3", "l3h","f5", "l5h","f7", "f7h", \
331 "fp", "sp"}
332
333#define REG_ALLOC_ORDER \
334{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 10, 11, 18, 12, 13, 20, 14, 15, 22, 24, 25, 17, 19, 23}
335
336/* How to renumber registers for dbx and gdb.
337 NS32000 may need more change in the numeration. XXX */
338
339#define DBX_REGISTER_NUMBER(REGNO) \
340 ((REGNO) < L1_REGNUM? (REGNO) \
341 : (REGNO) < FRAME_POINTER_REGNUM? (REGNO) - L1_REGNUM + 22 \
342 : (REGNO) == FRAME_POINTER_REGNUM? 17 \
343 : 16)
344
4c54e4e4
ID
345/* dwarf2out.c can't understand the funny DBX register numbering.
346 * We use dwarf2out.c for exception handling even though we use DBX
347 * for debugging
348 */
349#define DWARF_FRAME_REGNUM(REGNO) (REGNO)
83575957
ID
350
351
352
353#define R0_REGNUM 0
354#define F0_REGNUM 8
355#define L1_REGNUM 16
356
357/* Specify the registers used for certain standard purposes.
358 The values of these macros are register numbers. */
359
360/* NS32000 pc is not overloaded on a register. */
361/* #define PC_REGNUM */
362
363/* Register to use for pushing function arguments. */
364#define STACK_POINTER_REGNUM 25
365
366/* Base register for access to local variables of the function. */
367#define FRAME_POINTER_REGNUM 24
368
369
231ddcb7
RS
370/* Return number of consecutive hard regs needed starting at reg REGNO
371 to hold something of mode MODE.
372 This is ordinarily the length in words of a value of mode MODE
373 but can be less for certain modes in special long registers.
83575957
ID
374 On the ns32k, all registers are 32 bits long except for the 32381 "long"
375 registers but we treat those as pairs */
376#define LONG_FP_REGS_P(REGNO) ((REGNO) >= L1_REGNUM && (REGNO) < L1_REGNUM + 8)
231ddcb7
RS
377#define HARD_REGNO_NREGS(REGNO, MODE) \
378 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
379
380/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
381#define HARD_REGNO_MODE_OK(REGNO, MODE) hard_regno_mode_ok (REGNO, MODE)
382
383/* Value is 1 if it is a good idea to tie two pseudo registers
384 when one has mode MODE1 and one has mode MODE2.
385 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
83575957 386 for any hard reg, then this must be 0 for correct output.
231ddcb7 387
83575957
ID
388 Early documentation says SI and DI are not tieable if some reg can
389 be OK for SI but not for DI. However other ports (mips, i860, mvs
390 and tahoe) don't meet the above criterion. Evidently the real
391 requirement is somewhat laxer. Documentation was changed for gcc
392 2.8 but was not picked up by egcs (at least egcs 1.0). Having all
393 integer modes tieable definitely generates faster code. */
231ddcb7 394
83575957
ID
395#define MODES_TIEABLE_P(MODE1, MODE2) \
396 ((FLOAT_MODE_P(MODE1) && FLOAT_MODE_P(MODE2) \
397 && (GET_MODE_UNIT_SIZE(MODE1) == GET_MODE_UNIT_SIZE(MODE2))) \
398 || (!FLOAT_MODE_P(MODE1) && !FLOAT_MODE_P(MODE2)))
231ddcb7
RS
399
400/* Value should be nonzero if functions must have frame pointers.
401 Zero means the frame pointer need not be set up (and parms
402 may be accessed via the stack pointer) in functions that seem suitable.
403 This is computed in `reload', in reload1.c. */
404#define FRAME_POINTER_REQUIRED 0
405
406/* Base register for access to arguments of the function. */
83575957 407#define ARG_POINTER_REGNUM 24
231ddcb7
RS
408
409/* Register in which static-chain is passed to a function. */
410#define STATIC_CHAIN_REGNUM 1
411
412/* Register in which address to store a structure value
413 is passed to a function. */
414#define STRUCT_VALUE_REGNUM 2
415\f
416/* Define the classes of registers for register constraints in the
417 machine description. Also define ranges of constants.
418
419 One of the classes must always be named ALL_REGS and include all hard regs.
420 If there is more than one class, another class must be named NO_REGS
421 and contain no registers.
422
423 The name GENERAL_REGS must be the name of a class (or an alias for
424 another name such as ALL_REGS). This is the class of registers
425 that is allowed by "g" or "r" in a register constraint.
426 Also, registers outside this class are allocated only when
427 instructions express preferences for them.
428
429 The classes must be numbered in nondecreasing order; that is,
430 a larger-numbered class must never be contained completely
431 in a smaller-numbered class.
432
433 For any two classes, it is very desirable that there be another
434 class that represents their union. */
83575957
ID
435
436enum reg_class
437{ NO_REGS, GENERAL_REGS, FLOAT_REG0, LONG_FLOAT_REG0, FLOAT_REGS,
8056c5f2
ID
438 LONG_REGS, FP_REGS, GEN_AND_FP_REGS, FRAME_POINTER_REG,
439 STACK_POINTER_REG, GEN_AND_MEM_REGS, ALL_REGS, LIM_REG_CLASSES };
231ddcb7
RS
440
441#define N_REG_CLASSES (int) LIM_REG_CLASSES
442
443/* Give names of register classes as strings for dump file. */
444
8056c5f2 445#define REG_CLASS_NAMES \
83575957 446 {"NO_REGS", "GENERAL_REGS", "FLOAT_REG0", "LONG_FLOAT_REG0", "FLOAT_REGS", \
8056c5f2
ID
447 "LONG_REGS", "FP_REGS", "GEN_AND_FP_REGS", "FRAME_POINTER_REG", \
448 "STACK_POINTER_REG", "GEN_AND_MEM_REGS", "ALL_REGS" }
231ddcb7
RS
449
450/* Define which registers fit in which classes.
451 This is an initializer for a vector of HARD_REG_SET
452 of length N_REG_CLASSES. */
453
4c54e4e4
ID
454#define REG_CLASS_CONTENTS \
455 {{0}, /* NO_REGS */ \
456 {0x00ff}, /* GENERAL_REGS */ \
457 {0x100}, /* FLOAT_REG0 */ \
458 {0x300}, /* LONG_FLOAT_REG0 */ \
459 {0xff00}, /* FLOAT_REGS */ \
8056c5f2 460 {0xff0000}, /* LONG_REGS */ \
4c54e4e4
ID
461 {0xffff00}, /* FP_REGS */ \
462 {0xffffff}, /* GEN_AND_FP_REGS */ \
463 {0x1000000}, /* FRAME_POINTER_REG */ \
464 {0x2000000}, /* STACK_POINTER_REG */ \
465 {0x30000ff}, /* GEN_AND_MEM_REGS */ \
466 {0x3ffffff} /* ALL_REGS */ \
467 }
468
469#define SUBSET_P(CLASS1, CLASS2) \
470 ((ns32k_reg_class_contents[CLASS1][0] \
471 & ~ns32k_reg_class_contents[CLASS2][0]) == 0)
231ddcb7 472
8056c5f2
ID
473
474/* LONG_REGS are registers which can only hold double precision floats
475 * and can only be accessable by long float instructions.
476 */
e95ef187
RH
477#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
478 (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
479 ? reg_classes_intersect_p (LONG_REGS, CLASS) : 0)
8056c5f2 480
231ddcb7
RS
481/* The same information, inverted:
482 Return the class number of the smallest class containing
483 reg number REGNO. This could be a conditional expression
484 or could index an array. */
485
83575957 486#define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
231ddcb7
RS
487
488/* The class value for index registers, and the one for base regs. */
489
490#define INDEX_REG_CLASS GENERAL_REGS
491#define BASE_REG_CLASS GEN_AND_MEM_REGS
492
493/* Get reg_class from a letter such as appears in the machine description. */
494
83575957
ID
495#define REG_CLASS_FROM_LETTER(C) \
496 ((C) == 'u' ? FLOAT_REG0 \
497 : (C) == 'v' ? LONG_FLOAT_REG0 \
498 : (C) == 'f' ? FLOAT_REGS \
499 : (C) == 'l' ? FP_REGS \
500 : (C) == 'x' ? FRAME_POINTER_REG \
501 : (C) == 'y' ? STACK_POINTER_REG \
231ddcb7
RS
502 : NO_REGS)
503
504/* The letters I, J, K, L and M in a register constraint string
505 can be used to stand for particular ranges of immediate operands.
506 This macro defines what the ranges are.
507 C is the letter, and VALUE is a constant value.
508 Return 1 if VALUE is in the range specified by C.
509
510 On the ns32k, these letters are used as follows:
511
512 I : Matches integers which are valid shift amounts for scaled indexing.
513 These are 0, 1, 2, 3 for byte, word, double, and quadword.
514 Used for matching arithmetic shifts only on 32032 & 32332.
515 J : Matches integers which fit a "quick" operand.
516 K : Matches integers 0 to 7 (for inss and exts instructions).
517 */
518
519#define CONST_OK_FOR_LETTER_P(VALUE, C) \
520 ((VALUE) < 8 && (VALUE) + 8 >= 0 ? \
521 ((C) == 'I' ? (!TARGET_32532 && 0 <= (VALUE) && (VALUE) <= 3) : \
522 (C) == 'J' ? (VALUE) <= 7 : \
523 (C) == 'K' ? 0 <= (VALUE) : 0) : 0)
524
525/* Similar, but for floating constants, and defining letters G and H.
526 Here VALUE is the CONST_DOUBLE rtx itself. */
527
528#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 1
529
530/* Given an rtx X being reloaded into a reg required to be
531 in class CLASS, return the class of reg to actually use.
532 In general this is just CLASS; but on some machines
533 in some cases it is preferable to use a more restrictive class. */
534
1b6c8b12
RS
535/* We return GENERAL_REGS instead of GEN_AND_MEM_REGS.
536 The latter offers no real additional possibilities
83575957
ID
537 and can cause spurious secondary reloading. */
538
1b6c8b12
RS
539#define PREFERRED_RELOAD_CLASS(X,CLASS) \
540 ((CLASS) == GEN_AND_MEM_REGS ? GENERAL_REGS : (CLASS))
231ddcb7
RS
541
542/* Return the maximum number of consecutive registers
543 needed to represent mode MODE in a register of class CLASS. */
544/* On the 32000, this is the size of MODE in words */
83575957 545
231ddcb7
RS
546#define CLASS_MAX_NREGS(CLASS, MODE) \
547 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
548\f
549/* Stack layout; function entry, exit and calling. */
550
551/* Define this if pushing a word on the stack
552 makes the stack pointer a smaller address. */
553#define STACK_GROWS_DOWNWARD
554
555/* Define this if the nominal address of the stack frame
556 is at the high-address end of the local variables;
557 that is, each additional local variable allocated
558 goes at a more negative offset in the frame. */
559#define FRAME_GROWS_DOWNWARD
560
561/* Offset within stack frame to start allocating local variables at.
562 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
563 first local allocated. Otherwise, it is the offset to the BEGINNING
564 of the first local allocated. */
565#define STARTING_FRAME_OFFSET 0
566
83575957
ID
567/* A C expression whose value is RTL representing the location of the
568 incoming return address at the beginning of any function, before
569 the prologue. This RTL is either a `REG', indicating that the
570 return value is saved in `REG', or a `MEM' representing a location
571 in the stack.
572
573 You only need to define this macro if you want to support call
574 frame debugging information like that provided by DWARF 2.
575
576 Before the prologue, RA is at 0(sp). */
577
578#define INCOMING_RETURN_ADDR_RTX \
579 gen_rtx (MEM, VOIDmode, gen_rtx (REG, VOIDmode, STACK_POINTER_REGNUM))
580
581/* A C expression whose value is RTL representing the value of the
582 return address for the frame COUNT steps up from the current frame,
583 after the prologue. FRAMEADDR is the frame pointer of the COUNT
584 frame, or the frame pointer of the COUNT - 1 frame if
585 `RETURN_ADDR_IN_PREVIOUS_FRAME' is defined.
586
587 After the prologue, RA is at 4(fp) in the current frame. */
588
589#define RETURN_ADDR_RTX(COUNT, FRAME) \
ac14c725
ID
590 ((COUNT> 0 && flag_omit_frame_pointer)? NULL_RTX \
591 : gen_rtx (MEM, Pmode, gen_rtx (PLUS, Pmode, (FRAME), GEN_INT(4))))
83575957
ID
592
593/* A C expression whose value is an integer giving the offset, in
594 bytes, from the value of the stack pointer register to the top of
595 the stack frame at the beginning of any function, before the
596 prologue. The top of the frame is defined to be the value of the
597 stack pointer in the previous frame, just before the call
598 instruction.
599
600 You only need to define this macro if you want to support call
601 frame debugging information like that provided by DWARF 2. */
602
603#define INCOMING_FRAME_SP_OFFSET 4
604
231ddcb7
RS
605/* If we generate an insn to push BYTES bytes,
606 this says how many the stack pointer really advances by.
607 On the 32000, sp@- in a byte insn really pushes a BYTE. */
608#define PUSH_ROUNDING(BYTES) (BYTES)
609
610/* Offset of first parameter from the argument pointer register value. */
611#define FIRST_PARM_OFFSET(FNDECL) 8
612
613/* Value is the number of byte of arguments automatically
614 popped when returning from a subroutine call.
8b109b37 615 FUNDECL is the declaration node of the function (as a tree),
231ddcb7
RS
616 FUNTYPE is the data type of the function (as a tree),
617 or for a library call it is an identifier node for the subroutine name.
618 SIZE is the number of bytes of arguments passed on the stack.
619
620 On the 32000, the RET insn may be used to pop them if the number
621 of args is fixed, but if the number is variable then the caller
622 must pop them all. RET can't be used for library calls now
623 because the library is compiled with the Unix compiler.
624 Use of RET is a selectable option, since it is incompatible with
625 standard Unix calling sequences. If the option is not selected,
83575957
ID
626 the caller must always pop the args.
627
628 The attribute stdcall is equivalent to RTD on a per module basis. */
231ddcb7 629
83575957
ID
630#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
631 (ns32k_return_pops_args (FUNDECL, FUNTYPE, SIZE))
231ddcb7
RS
632
633/* Define how to find the value returned by a function.
634 VALTYPE is the data type of the value (as a tree).
635 If the precise function being called is known, FUNC is its FUNCTION_DECL;
636 otherwise, FUNC is 0. */
637
638/* On the 32000 the return value is in R0,
83575957 639 or perhaps in F0 if there is fp support. */
231ddcb7 640
83575957 641#define FUNCTION_VALUE(VALTYPE, FUNC) LIBCALL_VALUE(TYPE_MODE (VALTYPE))
231ddcb7
RS
642
643/* Define how to find the value returned by a library function
644 assuming the value has mode MODE. */
645
646/* On the 32000 the return value is in R0,
83575957 647 or perhaps F0 is there is fp support. */
231ddcb7
RS
648
649#define LIBCALL_VALUE(MODE) \
c5c76735
JL
650 gen_rtx_REG (MODE, \
651 FLOAT_MODE_P(MODE) && TARGET_32081 ? F0_REGNUM: R0_REGNUM)
231ddcb7
RS
652
653/* Define this if PCC uses the nonreentrant convention for returning
654 structure and union values. */
655
656#define PCC_STATIC_STRUCT_RETURN
657
658/* 1 if N is a possible register number for a function value.
659 On the 32000, R0 and F0 are the only registers thus used. */
660
661#define FUNCTION_VALUE_REGNO_P(N) (((N) & ~8) == 0)
662
663/* 1 if N is a possible register number for function argument passing.
664 On the 32000, no registers are used in this way. */
665
666#define FUNCTION_ARG_REGNO_P(N) 0
667\f
668/* Define a data type for recording info about an argument list
669 during the scan of that argument list. This data type should
670 hold all necessary information about the function itself
671 and about the args processed so far, enough to enable macros
672 such as FUNCTION_ARG to determine where the next arg should go.
673
674 On the ns32k, this is a single integer, which is a number of bytes
675 of arguments scanned so far. */
676
677#define CUMULATIVE_ARGS int
678
679/* Initialize a variable CUM of type CUMULATIVE_ARGS
680 for a call to a function whose data type is FNTYPE.
681 For a library call, FNTYPE is 0.
682
683 On the ns32k, the offset starts at 0. */
684
2c7ee1a6 685#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
231ddcb7
RS
686 ((CUM) = 0)
687
688/* Update the data in CUM to advance over an argument
689 of mode MODE and data type TYPE.
690 (TYPE is null for libcalls where that information may not be available.) */
691
692#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
693 ((CUM) += ((MODE) != BLKmode \
694 ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
695 : (int_size_in_bytes (TYPE) + 3) & ~3))
696
697/* Define where to put the arguments to a function.
698 Value is zero to push the argument on the stack,
699 or a hard register in which to store the argument.
700
701 MODE is the argument's machine mode.
702 TYPE is the data type of the argument (as a tree).
703 This is null for libcalls where that information may
704 not be available.
705 CUM is a variable of type CUMULATIVE_ARGS which gives info about
706 the preceding args and about the function being called.
707 NAMED is nonzero if this argument is a named parameter
708 (otherwise it is an extra parameter matching an ellipsis). */
709
710/* On the 32000 all args are pushed, except if -mregparm is specified
711 then the first two words of arguments are passed in r0, r1.
712 *NOTE* -mregparm does not work.
713 It exists only to test register calling conventions. */
714
715#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
c5c76735 716((TARGET_REGPARM && (CUM) < 8) ? gen_rtx_REG ((MODE), (CUM) / 4) : 0)
231ddcb7
RS
717
718/* For an arg passed partly in registers and partly in memory,
719 this is the number of registers used.
720 For args passed entirely in registers or entirely in memory, zero. */
721
722#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
723((TARGET_REGPARM && (CUM) < 8 \
724 && 8 < ((CUM) + ((MODE) == BLKmode \
725 ? int_size_in_bytes (TYPE) \
726 : GET_MODE_SIZE (MODE)))) \
727 ? 2 - (CUM) / 4 : 0)
728
231ddcb7
RS
729/* Output assembler code to FILE to increment profiler label # LABELNO
730 for profiling a function entry.
731
732 THIS DEFINITION FOR THE 32000 IS A GUESS. IT HAS NOT BEEN TESTED. */
733
734#define FUNCTION_PROFILER(FILE, LABELNO) \
735 fprintf (FILE, "\taddr LP%d,r0\n\tbsr mcount\n", (LABELNO))
736
737/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
738 the stack pointer does not matter. The value is tested only in
739 functions that have frame pointers.
740 No definition is equivalent to always zero.
741
08c148a8 742 We use 0, because using 1 requires hair in output_function_epilogue()
231ddcb7
RS
743 that is worse than the stack adjust we could save. */
744
745/* #define EXIT_IGNORE_STACK 1 */
746
231ddcb7
RS
747/* Store in the variable DEPTH the initial difference between the
748 frame pointer reg contents and the stack pointer reg contents,
749 as of the start of the function body. This depends on the layout
750 of the fixed parts of the stack frame and on how registers are saved. */
751
752#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \
753{ \
754 int regno; \
755 int offset = -4; \
ac14c725 756 for (regno = 0; regno < FRAME_POINTER_REGNUM; regno++) \
231ddcb7
RS
757 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
758 offset += 4; \
666b023e
RK
759 if (flag_pic && current_function_uses_pic_offset_table) \
760 offset += 4; \
7f2ab886
RS
761 (DEPTH) = (offset + get_frame_size () \
762 + (get_frame_size () == 0 ? 0 : 4)); \
231ddcb7
RS
763}
764\f
765
766/* Output assembler code for a block containing the constant parts
767 of a trampoline, leaving space for the variable parts. */
768
769/* On the 32k, the trampoline looks like this:
6cb64c6a 770 addr 0(pc),r2
231ddcb7
RS
771 jump @__trampoline
772 .int STATIC
773 .int FUNCTION
774Doing trampolines with a library assist function is easier than figuring
775out how to do stores to memory in reverse byte order (the way immediate
776operands on the 32k are stored). */
777
778#define TRAMPOLINE_TEMPLATE(FILE) \
779{ \
6cb64c6a 780 fprintf (FILE, "\taddr 0(pc),r2\n" ); \
e2ca2fab
RS
781 fprintf (FILE, "\tjump " ); \
782 PUT_ABSOLUTE_PREFIX (FILE); \
783 fprintf (FILE, "__trampoline\n" ); \
301d03af
RS
784 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
785 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
231ddcb7
RS
786}
787
788/* Length in units of the trampoline for entering a nested function. */
789
790#define TRAMPOLINE_SIZE 20
791
792/* Emit RTL insns to initialize the variable parts of a trampoline.
793 FNADDR is an RTX for the address of the function's pure code.
794 CXT is an RTX for the static chain value for the function. */
795
796#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
797{ \
c5c76735
JL
798 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 12)), CXT); \
799 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 16)), FNADDR); \
231ddcb7
RS
800}
801
802/* This is the library routine that is used
803 to transfer control from the trampoline
804 to the actual nested function. */
805
806/* The function name __transfer_from_trampoline is not actually used.
807 The function definition just permits use of "asm with operands"
808 (though the operand list is empty). */
809#define TRANSFER_FROM_TRAMPOLINE \
810void \
811__transfer_from_trampoline () \
812{ \
6cb64c6a
RK
813 asm (".globl __trampoline"); \
814 asm ("__trampoline:"); \
231ddcb7 815 asm ("movd 16(r2),tos"); \
6cb64c6a 816 asm ("movd 12(r2),r1"); \
b4ac57ab 817 asm ("ret 0"); \
231ddcb7 818}
231ddcb7
RS
819\f
820/* Addressing modes, and classification of registers for them. */
821
231ddcb7
RS
822/* Macros to check register numbers against specific register classes. */
823
824/* These assume that REGNO is a hard or pseudo reg number.
825 They give nonzero only if REGNO is a hard reg of the suitable class
826 or a pseudo reg currently allocated to a suitable hard reg.
827 Since they use reg_renumber, they are safe only once reg_renumber
828 has been allocated, which happens in local-alloc.c. */
829
830/* note that FP and SP cannot be used as an index. What about PC? */
831#define REGNO_OK_FOR_INDEX_P(REGNO) \
83575957 832((REGNO) < F0_REGNUM || (unsigned)reg_renumber[REGNO] < F0_REGNUM)
231ddcb7 833#define REGNO_OK_FOR_BASE_P(REGNO) \
83575957 834((REGNO) < F0_REGNUM || (unsigned)reg_renumber[REGNO] < F0_REGNUM \
231ddcb7
RS
835 || (REGNO) == FRAME_POINTER_REGNUM || (REGNO) == STACK_POINTER_REGNUM)
836
83575957
ID
837#define FP_REG_P(X) \
838 (GET_CODE (X) == REG && REGNO (X) >= F0_REGNUM && REGNO (X) < FRAME_POINTER_REGNUM)
231ddcb7
RS
839\f
840/* Maximum number of registers that can appear in a valid memory address. */
841
842#define MAX_REGS_PER_ADDRESS 2
843
844/* Recognize any constant value that is a valid address.
845 This might not work on future ns32k processors as negative
846 displacements are not officially allowed but a mode reserved
83575957
ID
847 to National. This works on processors up to 32532, though,
848 and we don't expect any new ones in the series ;-( */
231ddcb7
RS
849
850#define CONSTANT_ADDRESS_P(X) \
851 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
852 || GET_CODE (X) == CONST \
853 || (GET_CODE (X) == CONST_INT \
83575957 854 && NS32K_DISPLACEMENT_P (INTVAL (X))))
231ddcb7
RS
855
856#define CONSTANT_ADDRESS_NO_LABEL_P(X) \
857 (GET_CODE (X) == CONST_INT \
83575957 858 && NS32K_DISPLACEMENT_P (INTVAL (X)))
231ddcb7
RS
859
860/* Return the register class of a scratch register needed to copy IN into
861 or out of a register in CLASS in MODE. If it can be done directly,
862 NO_REGS is returned. */
863
864#define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \
865 secondary_reload_class (CLASS, MODE, IN)
866
83575957
ID
867/* Certain machines have the property that some registers cannot be
868 copied to some other registers without using memory. Define this
a0ab749a 869 macro on those machines to be a C expression that is nonzero if
83575957
ID
870 objects of mode M in registers of CLASS1 can only be copied to
871 registers of class CLASS2 by storing a register of CLASS1 into
872 memory and loading that memory location into a register of CLASS2.
873
874 On the ns32k, floating point regs can only be loaded through memory
875
876 The movdf and movsf insns in ns32k.md copy between general and
877 floating registers using the stack. In principle, we could get
878 better code not allowing that case in the constraints and defining
879 SECONDARY_MEMORY_NEEDED in practice, though the stack slots used
880 are not available for optimization. */
881
882#if 0
883#define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, M) \
884 secondary_memory_needed(CLASS1, CLASS2, M)
885#endif
886
4c54e4e4
ID
887/* SMALL_REGISTER_CLASSES is a run time option. This should no longer
888 be necessay and should go when we have confidence that we won't run
889 out of spill registers */
2eb2901a 890#define SMALL_REGISTER_CLASSES (target_flags & MASK_SRC)
83575957
ID
891
892/* A C expression whose value is nonzero if pseudos that have been
893 assigned to registers of class CLASS would likely be spilled
894 because registers of CLASS are needed for spill registers.
895
896 The default definition won't do because class LONG_FLOAT_REG0 has two
f5143c46 897 registers which are always accessed as a pair */
83575957
ID
898
899#define CLASS_LIKELY_SPILLED_P(CLASS) \
900 (reg_class_size[(int) (CLASS)] == 1 || (CLASS) == LONG_FLOAT_REG0)
901
902
231ddcb7
RS
903/* Nonzero if the constant value X is a legitimate general operand.
904 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
905
1ed37bfd 906#define LEGITIMATE_CONSTANT_P(X) 1
231ddcb7
RS
907
908/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
909 and check its validity for a certain class.
910 We have two alternate definitions for each of them.
911 The usual definition accepts all pseudo regs; the other rejects
912 them unless they have been allocated suitable hard regs.
913 The symbol REG_OK_STRICT causes the latter definition to be used.
914
915 Most source files want to accept pseudo regs in the hope that
916 they will get allocated to the class that the insn wants them to be in.
917 Source files for reload pass need to be strict.
918 After reload, it makes no difference, since pseudo regs have
919 been eliminated by then. */
920
921#ifndef REG_OK_STRICT
922
923/* Nonzero if X is a hard reg that can be used as an index
924 or if it is a pseudo reg. */
925#define REG_OK_FOR_INDEX_P(X) \
83575957 926 (REGNO (X) < F0_REGNUM || REGNO (X) >= FIRST_PSEUDO_REGISTER)
231ddcb7
RS
927/* Nonzero if X is a hard reg that can be used as a base reg
928 of if it is a pseudo reg. */
83575957 929#define REG_OK_FOR_BASE_P(X) (REGNO (X) < F0_REGNUM || REGNO (X) >= FRAME_POINTER_REGNUM)
231ddcb7
RS
930/* Nonzero if X is a floating point reg or a pseudo reg. */
931
932#else
933
934/* Nonzero if X is a hard reg that can be used as an index. */
935#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
936/* Nonzero if X is a hard reg that can be used as a base reg. */
937#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
938
939#endif
940\f
941/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
942 that is a valid memory address for an instruction.
943 The MODE argument is the machine mode for the MEM expression
944 that wants to use this address.
945
946 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
947
948/* 1 if X is an address that we could indirect through. */
949/***** NOTE ***** There is a bug in the Sequent assembler which fails
950 to fixup addressing information for symbols used as offsets
951 from registers which are not FP or SP (or SB or PC). This
952 makes _x(fp) valid, while _x(r0) is invalid. */
953
954#define INDIRECTABLE_1_ADDRESS_P(X) \
955 (CONSTANT_ADDRESS_P (X) \
956 || (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
957 || (GET_CODE (X) == PLUS \
958 && GET_CODE (XEXP (X, 0)) == REG \
959 && REG_OK_FOR_BASE_P (XEXP (X, 0)) \
2d33065a 960 && ((flag_pic || TARGET_HIMEM) ? \
1ed37bfd
RK
961 CONSTANT_ADDRESS_NO_LABEL_P (XEXP (X, 1)) \
962 : \
963 CONSTANT_ADDRESS_P (XEXP (X, 1))) \
b8168f0d
RS
964 && (GET_CODE (X) != CONST_INT || NS32K_DISPLACEMENT_P (INTVAL (X)))))
965
966/* 1 if integer I will fit in a 4 byte displacement field.
967 Strictly speaking, we can't be sure that a symbol will fit this range.
968 But, in practice, it always will. */
969
d24eed4d
RS
970/* idall@eleceng.adelaide.edu.au says that the 32016 and 32032
971 can handle the full range of displacements--it is only the addresses
972 that have a limited range. So the following was deleted:
973 (((i) <= 16777215 && (i) >= -16777216)
974 || ((TARGET_32532 || TARGET_32332) && ...)) */
50babe84 975#define NS32K_DISPLACEMENT_P(i) \
0b6d0e8b 976 ((i) < (1 << 29) && (i) >= - (1 << 29))
231ddcb7 977
47c95231 978/* Check for frame pointer or stack pointer. */
231ddcb7 979#define MEM_REG(X) \
83575957
ID
980 (GET_CODE (X) == REG && (REGNO (X) == FRAME_POINTER_REGNUM \
981 || REGNO(X) == STACK_POINTER_REGNUM))
231ddcb7 982
47c95231
RS
983/* A memory ref whose address is the FP or SP, with optional integer offset,
984 or (on certain machines) a constant address. */
231ddcb7
RS
985#define INDIRECTABLE_2_ADDRESS_P(X) \
986 (GET_CODE (X) == MEM \
987 && (((xfoo0 = XEXP (X, 0), MEM_REG (xfoo0)) \
988 || (GET_CODE (xfoo0) == PLUS \
231ddcb7
RS
989 && MEM_REG (XEXP (xfoo0, 0)) \
990 && CONSTANT_ADDRESS_NO_LABEL_P (XEXP (xfoo0, 1)))) \
991 || (TARGET_SB && CONSTANT_ADDRESS_P (xfoo0))))
992
231ddcb7
RS
993/* Go to ADDR if X is a valid address not using indexing.
994 (This much is the easy part.) */
4c54e4e4
ID
995#define GO_IF_NONINDEXED_ADDRESS(X, ADDR) \
996{ \
997 if (INDIRECTABLE_1_ADDRESS_P (X)) goto ADDR; \
998 if (INDIRECTABLE_2_ADDRESS_P (X)) goto ADDR; \
999 if (GET_CODE (X) == PLUS) \
1000 if (CONSTANT_ADDRESS_NO_LABEL_P (XEXP (X, 1))) \
1001 if (INDIRECTABLE_2_ADDRESS_P (XEXP (X, 0))) \
1002 goto ADDR; \
231ddcb7
RS
1003}
1004
47c95231
RS
1005/* Go to ADDR if X is a valid address not using indexing.
1006 (This much is the easy part.) */
fbaef11f 1007#define GO_IF_INDEXING(X, MODE, ADDR) \
47c95231 1008{ register rtx xfoob = (X); \
fbaef11f 1009 if (GET_CODE (xfoob) == PLUS && INDEX_TERM_P (XEXP (xfoob, 0), MODE)) \
47c95231 1010 GO_IF_INDEXABLE_ADDRESS (XEXP (xfoob, 1), ADDR); \
fbaef11f 1011 if (GET_CODE (xfoob) == PLUS && INDEX_TERM_P (XEXP (xfoob, 1), MODE)) \
47c95231
RS
1012 GO_IF_INDEXABLE_ADDRESS (XEXP (xfoob, 0), ADDR); } \
1013
1014#define GO_IF_INDEXABLE_ADDRESS(X, ADDR) \
1015{ if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; \
1016 if (INDIRECTABLE_2_ADDRESS_P (X)) goto ADDR; \
1ed37bfd 1017 if (INDIRECTABLE_1_ADDRESS_P (X)) goto ADDR; \
47c95231
RS
1018}
1019
231ddcb7
RS
1020/* 1 if PROD is either a reg times size of mode MODE
1021 or just a reg, if MODE is just one byte. Actually, on the ns32k,
1022 since the index mode is independent of the operand size,
1023 we can match more stuff...
1024
1025 This macro's expansion uses the temporary variables xfoo0, xfoo1
1026 and xfoo2 that must be declared in the surrounding context. */
1027#define INDEX_TERM_P(PROD, MODE) \
1028((GET_CODE (PROD) == REG && REG_OK_FOR_INDEX_P (PROD)) \
1029 || (GET_CODE (PROD) == MULT \
1030 && (xfoo0 = XEXP (PROD, 0), xfoo1 = XEXP (PROD, 1), \
1031 (GET_CODE (xfoo1) == CONST_INT \
1032 && GET_CODE (xfoo0) == REG \
1033 && FITS_INDEX_RANGE (INTVAL (xfoo1)) \
1034 && REG_OK_FOR_INDEX_P (xfoo0)))))
1035
1036#define FITS_INDEX_RANGE(X) \
1037 ((xfoo2 = (unsigned)(X)-1), \
1038 ((xfoo2 < 4 && xfoo2 != 2) || xfoo2 == 7))
1039
47c95231 1040/* Note that xfoo0, xfoo1, xfoo2 are used in some of the submacros above. */
4c54e4e4 1041#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
47c95231 1042{ register rtx xfooy, xfoo0, xfoo1; \
231ddcb7
RS
1043 unsigned xfoo2; \
1044 xfooy = X; \
4c54e4e4 1045 if (flag_pic && cfun && ! current_function_uses_pic_offset_table \
1ed37bfd 1046 && global_symbolic_reference_mentioned_p (X, 1)) \
666b023e 1047 current_function_uses_pic_offset_table = 1; \
231ddcb7
RS
1048 GO_IF_NONINDEXED_ADDRESS (xfooy, ADDR); \
1049 if (GET_CODE (xfooy) == PLUS) \
1050 { \
1051 if (CONSTANT_ADDRESS_NO_LABEL_P (XEXP (xfooy, 1)) \
1052 && GET_CODE (XEXP (xfooy, 0)) == PLUS) \
1053 xfooy = XEXP (xfooy, 0); \
1054 else if (CONSTANT_ADDRESS_NO_LABEL_P (XEXP (xfooy, 0)) \
1055 && GET_CODE (XEXP (xfooy, 1)) == PLUS) \
1056 xfooy = XEXP (xfooy, 1); \
fbaef11f 1057 GO_IF_INDEXING (xfooy, MODE, ADDR); \
231ddcb7
RS
1058 } \
1059 else if (INDEX_TERM_P (xfooy, MODE)) \
1060 goto ADDR; \
1061 else if (GET_CODE (xfooy) == PRE_DEC) \
fabf04b6
KG
1062 { \
1063 if (REGNO (XEXP (xfooy, 0)) == STACK_POINTER_REGNUM) goto ADDR; \
1064 } \
231ddcb7
RS
1065}
1066
1067/* Try machine-dependent ways of modifying an illegitimate address
1068 to be legitimate. If we find one, return the new, valid address.
1069 This macro is used in only one place: `memory_address' in explow.c.
1070
1071 OLDX is the address as it was before break_out_memory_refs was called.
1072 In some cases it is useful to look at this to decide what needs to be done.
1073
1074 MODE and WIN are passed so that this macro can use
1075 GO_IF_LEGITIMATE_ADDRESS.
1076
1077 It is always safe for this macro to do nothing. It exists to recognize
1078 opportunities to optimize the output.
1079
1080 For the ns32k, we do nothing */
1081
1082#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) {}
1083
1ed37bfd 1084/* Nonzero if the constant value X is a legitimate general operand
83575957 1085 when generating PIC code. It is given that flag_pic is on and
1ed37bfd
RK
1086 that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1087
1ed37bfd
RK
1088#define LEGITIMATE_PIC_OPERAND_P(X) \
1089 (((! current_function_uses_pic_offset_table \
83575957 1090 && symbolic_reference_mentioned_p (X))? \
1ed37bfd 1091 (current_function_uses_pic_offset_table = 1):0 \
83575957
ID
1092 ), (! SYMBOLIC_CONST (X) \
1093 || GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF))
1094
1095#define SYMBOLIC_CONST(X) \
1096(GET_CODE (X) == SYMBOL_REF \
1097 || GET_CODE (X) == LABEL_REF \
1098 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
1ed37bfd 1099
231ddcb7
RS
1100/* Go to LABEL if ADDR (a legitimate address expression)
1101 has an effect that depends on the machine mode it is used for.
1102 On the ns32k, only predecrement and postincrement address depend thus
1103 (the amount of decrement or increment being the length of the operand). */
1104
1105#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1106 { if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC) \
1107 goto LABEL;}
1108\f
1109/* Specify the machine mode that this machine uses
1110 for the index in the tablejump instruction.
386d1816
RK
1111 HI mode is more efficient but the range is not wide enough for
1112 all programs. */
1113#define CASE_VECTOR_MODE SImode
231ddcb7 1114
18543a22
ILT
1115/* Define as C expression which evaluates to nonzero if the tablejump
1116 instruction expects the table to contain offsets from the address of the
1117 table.
1118 Do not define this if the table should contain absolute addresses. */
1119#define CASE_VECTOR_PC_RELATIVE 1
231ddcb7 1120
231ddcb7
RS
1121/* Define this as 1 if `char' should by default be signed; else as 0. */
1122#define DEFAULT_SIGNED_CHAR 1
1123
1124/* Max number of bytes we can move from memory to memory
1125 in one reasonably fast instruction. */
1126#define MOVE_MAX 4
1127
83575957
ID
1128/* The number of scalar move insns which should be generated instead
1129 of a string move insn or a library call.
1130
1131 We have a smart movstrsi insn */
1132#define MOVE_RATIO 0
1133
8056c5f2
ID
1134#define STORE_RATIO (optimize_size ? 3 : 15)
1135#define STORE_BY_PIECES_P(SIZE, ALIGN) \
1136 (move_by_pieces_ninsns (SIZE, ALIGN) < (unsigned int) STORE_RATIO)
1137
1138
231ddcb7
RS
1139/* Nonzero if access to memory by bytes is slow and undesirable. */
1140#define SLOW_BYTE_ACCESS 0
1141
1142/* Define if shifts truncate the shift count
1143 which implies one can omit a sign-extension or zero-extension
1144 of a shift count. */
1145/* #define SHIFT_COUNT_TRUNCATED */
1146
1147/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1148 is done just by pretending it is already truncated. */
1149#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1150
231ddcb7
RS
1151/* Specify the machine mode that pointers have.
1152 After generation of rtl, the compiler makes no further distinction
1153 between pointers and any other objects of this machine mode. */
1154#define Pmode SImode
1155
1156/* A function address in a call instruction
1157 is a byte address (for indexing purposes)
1158 so give the MEM rtx a byte's mode. */
1159#define FUNCTION_MODE QImode
231ddcb7
RS
1160\f
1161/* Tell final.c how to eliminate redundant test instructions. */
1162
1163/* Here we define machine-dependent flags and fields in cc_status
1164 (see `conditions.h'). */
1165
1166/* This bit means that what ought to be in the Z bit
1167 should be tested in the F bit. */
1168#define CC_Z_IN_F 04000
1169
1170/* This bit means that what ought to be in the Z bit
1171 is complemented in the F bit. */
1172#define CC_Z_IN_NOT_F 010000
1173
5d7c2819
ID
1174/* This bit means that the L bit indicates unordered (IEEE) comparison.
1175 */
1176#define CC_UNORD 020000
1177
231ddcb7
RS
1178/* Store in cc_status the expressions
1179 that the condition codes will describe
1180 after execution of an instruction whose pattern is EXP.
1181 Do not alter them if the instruction would not alter the cc's. */
1182
1183#define NOTICE_UPDATE_CC(EXP, INSN) \
1184{ if (GET_CODE (EXP) == SET) \
1185 { if (GET_CODE (SET_DEST (EXP)) == CC0) \
1186 { cc_status.flags = 0; \
1187 cc_status.value1 = SET_DEST (EXP); \
1188 cc_status.value2 = SET_SRC (EXP); \
1189 } \
1190 else if (GET_CODE (SET_SRC (EXP)) == CALL) \
1191 { CC_STATUS_INIT; } \
1192 else if (GET_CODE (SET_DEST (EXP)) == REG) \
1193 { if (cc_status.value1 \
1194 && reg_overlap_mentioned_p (SET_DEST (EXP), cc_status.value1)) \
1195 cc_status.value1 = 0; \
1196 if (cc_status.value2 \
1197 && reg_overlap_mentioned_p (SET_DEST (EXP), cc_status.value2)) \
1198 cc_status.value2 = 0; \
1199 } \
1200 else if (GET_CODE (SET_DEST (EXP)) == MEM) \
1201 { CC_STATUS_INIT; } \
1202 } \
1203 else if (GET_CODE (EXP) == PARALLEL \
1204 && GET_CODE (XVECEXP (EXP, 0, 0)) == SET) \
1205 { if (GET_CODE (SET_DEST (XVECEXP (EXP, 0, 0))) == CC0) \
1206 { cc_status.flags = 0; \
1207 cc_status.value1 = SET_DEST (XVECEXP (EXP, 0, 0)); \
1208 cc_status.value2 = SET_SRC (XVECEXP (EXP, 0, 0)); \
1209 } \
1210 else if (GET_CODE (SET_DEST (XVECEXP (EXP, 0, 0))) == REG) \
1211 { if (cc_status.value1 \
1212 && reg_overlap_mentioned_p (SET_DEST (XVECEXP (EXP, 0, 0)), cc_status.value1)) \
1213 cc_status.value1 = 0; \
1214 if (cc_status.value2 \
1215 && reg_overlap_mentioned_p (SET_DEST (XVECEXP (EXP, 0, 0)), cc_status.value2)) \
1216 cc_status.value2 = 0; \
1217 } \
1218 else if (GET_CODE (SET_DEST (XVECEXP (EXP, 0, 0))) == MEM) \
1219 { CC_STATUS_INIT; } \
1220 } \
1221 else if (GET_CODE (EXP) == CALL) \
1222 { /* all bets are off */ CC_STATUS_INIT; } \
1223 else { /* nothing happens? CC_STATUS_INIT; */} \
1224 if (cc_status.value1 && GET_CODE (cc_status.value1) == REG \
1225 && cc_status.value2 \
1226 && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2)) \
1227 abort (); \
1228}
1229
1230/* Describe the costs of the following register moves which are discouraged:
1231 1.) Moves between the Floating point registers and the frame pointer and stack pointer
1232 2.) Moves between the stack pointer and the frame pointer
83575957
ID
1233 3.) Moves between the floating point and general registers
1234
1235 These all involve two memory references. This is worse than a memory
1236 to memory move (default cost 4)
1237 */
231ddcb7 1238
cf011243
AO
1239#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
1240 register_move_cost (CLASS1, CLASS2)
231ddcb7
RS
1241
1242#define OUTPUT_JUMP(NORMAL, NO_OV) \
1243{ if (cc_status.flags & CC_NO_OVERFLOW) \
1244 return NO_OV; \
1245 return NORMAL; }
1246\f
1247/* Dividing the output into sections */
1248
1249/* Output before read-only data. */
1250
76bbee81 1251#define TEXT_SECTION_ASM_OP "\t.text"
231ddcb7
RS
1252
1253/* Output before writable data. */
1254
76bbee81 1255#define DATA_SECTION_ASM_OP "\t.data"
231ddcb7
RS
1256
1257/* Define the output Assembly Language */
1258
231ddcb7
RS
1259/* Output to assembler file text saying following lines
1260 may contain character constants, extra white space, comments, etc. */
1261
1262#define ASM_APP_ON "#APP\n"
1263
1264/* Output to assembler file text saying following lines
1265 no longer contain unusual constructs. */
1266
1267#define ASM_APP_OFF "#NO_APP\n"
1268
1269/* Output of Data */
1270
231ddcb7
RS
1271/* This is how to output an assembler line defining an external/static
1272 address which is not in tree format (for collect.c). */
1273
83575957
ID
1274/* The prefix to add to user-visible assembler symbols. */
1275#define USER_LABEL_PREFIX "_"
231ddcb7
RS
1276
1277/* This is how to output an insn to push a register on the stack.
1278 It need not be very fast code. */
1279
1280#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
1281 fprintf (FILE, "\tmovd %s,tos\n", reg_names[REGNO])
1282
1283/* This is how to output an insn to pop a register from the stack.
1284 It need not be very fast code. */
1285
1286#define ASM_OUTPUT_REG_POP(FILE,REGNO) \
1287 fprintf (FILE, "\tmovd tos,%s\n", reg_names[REGNO])
1288
231ddcb7
RS
1289/* This is how to output a command to make the user-level label named NAME
1290 defined for reference from other files. */
1291
506a61b1
KG
1292/* Globalizing directive for a label. */
1293#define GLOBAL_ASM_OP ".globl "
231ddcb7 1294
231ddcb7
RS
1295/* This is how to store into the string LABEL
1296 the symbol_ref name of an internal numbered label where
1297 PREFIX is the class of label and NUM is the number within the class.
1298 This is suitable for output with `assemble_name'. */
1299
1300#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
fabf04b6 1301 sprintf (LABEL, "*%s%ld", PREFIX, (long) NUM)
231ddcb7 1302
fc470718 1303/* This is how to align the code that follows an unconditional branch. */
231ddcb7 1304
fc470718 1305#define LABEL_ALIGN_AFTER_BARRIER(LABEL) (2)
231ddcb7
RS
1306
1307/* This is how to output an element of a case-vector that is absolute.
1308 (The ns32k does not use such vectors,
1309 but we must define this macro anyway.) */
1310
1311#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1312 fprintf (FILE, "\t.long L%d\n", VALUE)
1313
1314/* This is how to output an element of a case-vector that is relative. */
a74853cb 1315/* ** Notice that the second element is LI format! */
33f7f353 1316#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
a74853cb 1317 fprintf (FILE, "\t.long L%d-LI%d\n", VALUE, REL)
231ddcb7
RS
1318
1319/* This is how to output an assembler line
1320 that says to advance the location counter
1321 to a multiple of 2**LOG bytes. */
1322
1323#define ASM_OUTPUT_ALIGN(FILE,LOG) \
1324 fprintf (FILE, "\t.align %d\n", (LOG))
1325
1326#define ASM_OUTPUT_SKIP(FILE,SIZE) \
58e15542 1327 fprintf (FILE, "\t.space %u\n", (int)(SIZE))
231ddcb7
RS
1328
1329/* This says how to output an assembler line
1330 to define a global common symbol. */
1331
1332#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1333( fputs (".comm ", (FILE)), \
1334 assemble_name ((FILE), (NAME)), \
58e15542 1335 fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
231ddcb7
RS
1336
1337/* This says how to output an assembler line
1338 to define a local common symbol. */
1339
1340#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1341( fputs (".lcomm ", (FILE)), \
1342 assemble_name ((FILE), (NAME)), \
58e15542 1343 fprintf ((FILE), ",%u\n", (int)(ROUNDED)))
231ddcb7 1344
231ddcb7
RS
1345/* Print an instruction operand X on file FILE.
1346 CODE is the code from the %-spec that requested printing this operand;
1347 if `%z3' was used to print operand 3, then CODE is 'z'. */
1348
1349/* %$ means print the prefix for an immediate operand. */
1350
1351#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1352 ((CODE) == '$' || (CODE) == '?')
1353
1354#define PRINT_OPERAND(FILE, X, CODE) print_operand(FILE, X, CODE)
1355
1356/* Print a memory operand whose address is X, on file FILE. */
1357
1358#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address(FILE, ADDR)
1359
0139adca
KG
1360extern const unsigned int ns32k_reg_class_contents[N_REG_CLASSES][1];
1361extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER]; /* smallest class containing REGNO */
231ddcb7
RS
1362
1363/*
1364Local variables:
1365version-control: t
1366End:
1367*/
This page took 1.604037 seconds and 5 git commands to generate.