]> gcc.gnu.org Git - gcc.git/blob - gcc/config/alpha/alpha.h
Initial revision
[gcc.git] / gcc / config / alpha / alpha.h
1 /* Definitions of target machine for GNU compiler, for DEC Alpha.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3 Contributed by Richard Kenner (kenner@nyu.edu)
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22 /* Names to predefine in the preprocessor for this target machine. */
23
24 #define CPP_PREDEFINES "\
25 -Dunix -D__osf__ -D__alpha -D__alpha__ -D_LONGLONG -DSYSTYPE_BSD \
26 -D_SYSTYPE_BSD"
27
28 /* Write out the correct language type definition for the header files. */
29 #define CPP_SPEC "\
30 %{.c: -D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}} \
31 %{.h: -D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}} \
32 %{.S: -D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
33 %{.cc: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS} \
34 %{.cxx: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS} \
35 %{.C: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS} \
36 %{.m: -D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C}"
37
38 /* Set the spec to use for signed char. The default tests the above macro
39 but DEC's compiler can't handle the conditional in a "constant"
40 operand. */
41
42 #define SIGNED_CHAR_SPEC "%{funsigned-char:-D__CHAR_UNSIGNED__}"
43
44 /* Right now Alpha OSF/1 doesn't seem to have debugging or profiled
45 libraries. */
46
47 #define LIB_SPEC "-lc"
48
49 /* Print subsidiary information on the compiler version in use. */
50 #define TARGET_VERSION
51
52 /* Define the location for the startup file on OSF/1 for Alpha. */
53
54 #define MD_STARTFILE_PREFIX "/usr/lib/cmplrs/cc/"
55
56 /* Run-time compilation parameters selecting different hardware subsets. */
57
58 extern int target_flags;
59
60 /* This means that floating-point support exists in the target implementation
61 of the Alpha architecture. This is usually the default. */
62
63 #define TARGET_FP (target_flags & 1)
64
65 /* This means that floating-point registers are allowed to be used. Note
66 that Alpha implementations without FP operations are required to
67 provide the FP registers. */
68
69 #define TARGET_FPREGS (target_flags & 2)
70
71 /* Macro to define tables used to set the flags.
72 This is a list in braces of pairs in braces,
73 each pair being { "NAME", VALUE }
74 where VALUE is the bits to set or minus the bits to clear.
75 An empty string NAME is used to identify the default VALUE. */
76
77 #define TARGET_SWITCHES \
78 { {"no-soft-float", 1}, \
79 {"soft-float", -1}, \
80 {"fp-regs", 2}, \
81 {"no-fp-regs", -3}, \
82 {"", TARGET_DEFAULT} }
83
84 #define TARGET_DEFAULT 3
85
86 /* Define this macro to change register usage conditional on target flags.
87
88 On the Alpha, we use this to disable the floating-point registers when
89 they don't exist. */
90
91 #define CONDITIONAL_REGISTER_USAGE \
92 if (! TARGET_FPREGS) \
93 for (i = 32; i < 64; i++) \
94 fixed_regs[i] = call_used_regs[i] = 1;
95
96 /* Define this to change the optimizations performed by default. */
97
98 #define OPTIMIZATION_OPTIONS(LEVEL) \
99 { \
100 if ((LEVEL) > 0) \
101 { \
102 flag_force_addr = 1; \
103 flag_force_mem = 1; \
104 flag_omit_frame_pointer = 1; \
105 } \
106 }
107 \f
108 /* target machine storage layout */
109
110 /* Define the size of `int'. The default is the same as the word size. */
111 #define INT_TYPE_SIZE 32
112
113 /* Define the size of `long long'. The default is the twice the word size. */
114 #define LONG_LONG_TYPE_SIZE 64
115
116 /* The two floating-point formats we support are S-floating, which is
117 4 bytes, and T-floating, which is 8 bytes. `float' is S and `double'
118 and `long double' are T. */
119
120 #define FLOAT_TYPE_SIZE 32
121 #define DOUBLE_TYPE_SIZE 64
122 #define LONG_DOUBLE_TYPE_SIZE 64
123
124 #define WCHAR_TYPE "short unsigned int"
125 #define WCHAR_TYPE_SIZE 16
126
127 /* Define this macro if it is advisible to hold scalars in registers
128 in a wider mode than that declared by the program. In such cases,
129 the value is constrained to be within the bounds of the declared
130 type, but kept valid in the wider mode. The signedness of the
131 extension may differ from that of the type.
132
133 For Alpha, we always store objects in a full register. 32-bit objects
134 are always sign-extended, but smaller objects retain their signedness. */
135
136 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
137 if (GET_MODE_CLASS (MODE) == MODE_INT \
138 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
139 { \
140 if ((MODE) == SImode) \
141 (UNSIGNEDP) = 0; \
142 (MODE) = DImode; \
143 }
144
145 /* Define this if function arguments should also be promoted using the above
146 procedure. */
147
148 #define PROMOTE_FUNCTION_ARGS
149
150 /* Likewise, if the function return value is promoted. */
151
152 #define PROMOTE_FUNCTION_RETURN
153
154 /* Define this if most significant bit is lowest numbered
155 in instructions that operate on numbered bit-fields.
156
157 There are no such instructions on the Alpha, but the documentation
158 is little endian. */
159 #define BITS_BIG_ENDIAN 0
160
161 /* Define this if most significant byte of a word is the lowest numbered.
162 This is false on the Alpha. */
163 #define BYTES_BIG_ENDIAN 0
164
165 /* Define this if most significant word of a multiword number is lowest
166 numbered.
167
168 For Alpha we can decide arbitrarily since there are no machine instructions
169 for them. Might as well be consistent with bytes. */
170 #define WORDS_BIG_ENDIAN 0
171
172 /* number of bits in an addressable storage unit */
173 #define BITS_PER_UNIT 8
174
175 /* Width in bits of a "word", which is the contents of a machine register.
176 Note that this is not necessarily the width of data type `int';
177 if using 16-bit ints on a 68000, this would still be 32.
178 But on a machine with 16-bit registers, this would be 16. */
179 #define BITS_PER_WORD 64
180
181 /* Width of a word, in units (bytes). */
182 #define UNITS_PER_WORD 8
183
184 /* Width in bits of a pointer.
185 See also the macro `Pmode' defined below. */
186 #define POINTER_SIZE 64
187
188 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
189 #define PARM_BOUNDARY 64
190
191 /* Boundary (in *bits*) on which stack pointer should be aligned. */
192 #define STACK_BOUNDARY 64
193
194 /* Allocation boundary (in *bits*) for the code of a function. */
195 #define FUNCTION_BOUNDARY 64
196
197 /* Alignment of field after `int : 0' in a structure. */
198 #define EMPTY_FIELD_BOUNDARY 64
199
200 /* Every structure's size must be a multiple of this. */
201 #define STRUCTURE_SIZE_BOUNDARY 8
202
203 /* A bitfield declared as `int' forces `int' alignment for the struct. */
204 #define PCC_BITFIELD_TYPE_MATTERS 1
205
206 /* Align loop starts for optimal branching.
207
208 Don't do this until they fix the assembler. */
209
210 /* #define ASM_OUTPUT_LOOP_ALIGN(FILE) \
211 ASM_OUTPUT_ALIGN (FILE, 5) */
212
213 /* This is how to align an instruction for optimal branching.
214 On Alpha we'll get better performance by aligning on a quadword
215 boundary. */
216 #define ASM_OUTPUT_ALIGN_CODE(FILE) \
217 ASM_OUTPUT_ALIGN ((FILE), 4)
218
219 /* No data type wants to be aligned rounder than this. */
220 #define BIGGEST_ALIGNMENT 64
221
222 /* Make strings word-aligned so strcpy from constants will be faster. */
223 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
224 (TREE_CODE (EXP) == STRING_CST \
225 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
226
227 /* Make arrays of chars word-aligned for the same reasons. */
228 #define DATA_ALIGNMENT(TYPE, ALIGN) \
229 (TREE_CODE (TYPE) == ARRAY_TYPE \
230 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
231 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
232
233 /* Set this non-zero if move instructions will actually fail to work
234 when given unaligned data.
235
236 Since we get an error message when we do one, call them invalid. */
237
238 #define STRICT_ALIGNMENT 1
239
240 /* Set this non-zero if unaligned move instructions are extremely slow.
241
242 On the Alpha, they trap. */
243 /* #define SLOW_UNALIGNED_ACCESS 1 */
244 \f
245 /* Standard register usage. */
246
247 /* Number of actual hardware registers.
248 The hardware registers are assigned numbers for the compiler
249 from 0 to just below FIRST_PSEUDO_REGISTER.
250 All registers that the compiler knows about must be given numbers,
251 even those that are not normally considered general registers.
252
253 We define all 32 integer registers, even though $31 is always zero,
254 and all 32 floating-point registers, even though $f31 is also
255 always zero. We do not bother defining the FP status register and
256 there are no other registers. */
257
258 #define FIRST_PSEUDO_REGISTER 64
259
260 /* 1 for registers that have pervasive standard uses
261 and are not available for the register allocator. */
262
263 #define FIXED_REGISTERS \
264 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, \
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
268
269 /* 1 for registers not available across function calls.
270 These must include the FIXED_REGISTERS and also any
271 registers that can be used without being saved.
272 The latter must include the registers where values are returned
273 and the register where structure-value addresses are passed.
274 Aside from that, you can include as many other registers as you like. */
275 #define CALL_USED_REGISTERS \
276 {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, \
277 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, \
278 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, \
279 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
280
281 /* List the order in which to allocate registers. Each register must be
282 listed once, even those in FIXED_REGISTERS.
283
284 We allocate in the following order:
285 $f1 (nonsaved floating-point register)
286 $f10-$f15 (likewise)
287 $f22-$f30 (likewise)
288 $f21-$f16 (likewise, but input args)
289 $f0 (nonsaved, but return value)
290 $f2-$f9 (saved floating-point registers)
291 $1-$8 (nonsaved integer registers)
292 $22-$25 (likewise)
293 $28 (likewise)
294 $0 (likewise, but return value)
295 $21-$16 (likewise, but input args)
296 $27 (procedure value)
297 $9-$14 (saved integer registers)
298 $26 (return PC)
299 $15 (frame pointer)
300 $29 (global pointer)
301 $30, $31, $f31 (stack pointer and always zero) */
302
303 #define REG_ALLOC_ORDER \
304 {33, \
305 42, 43, 44, 45, \
306 54, 55, 56, 57, 58, 59, 60, 61, 62, \
307 53, 52, 51, 50, 49, 48, \
308 32, \
309 34, 35, 36, 37, 38, 39, 40, 41, \
310 1, 2, 3, 4, 5, 6, 7, 8, \
311 22, 23, 24, 25, \
312 28, \
313 0, \
314 21, 20, 19, 18, 17, 16, \
315 27, \
316 9, 10, 11, 12, 13, 14, \
317 26, \
318 15, \
319 29, \
320 30, 31, 63 }
321
322 /* Return number of consecutive hard regs needed starting at reg REGNO
323 to hold something of mode MODE.
324 This is ordinarily the length in words of a value of mode MODE
325 but can be less for certain modes in special long registers. */
326
327 #define HARD_REGNO_NREGS(REGNO, MODE) \
328 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
329
330 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
331 On Alpha, the integer registers can hold any mode. The floating-point
332 registers can hold 32-bit and 64-bit integers as well, but not 16-bit
333 or 8-bit values. If we only allowed the larger integers into FP registers,
334 we'd have to say that QImode and SImode aren't tiable, which is a
335 pain. So say all registers can hold everything and see how that works. */
336
337 #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
338
339 /* Value is 1 if it is a good idea to tie two pseudo registers
340 when one has mode MODE1 and one has mode MODE2.
341 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
342 for any hard reg, then this must be 0 for correct output. */
343
344 #define MODES_TIEABLE_P(MODE1, MODE2) 1
345
346 /* Specify the registers used for certain standard purposes.
347 The values of these macros are register numbers. */
348
349 /* Alpha pc isn't overloaded on a register that the compiler knows about. */
350 /* #define PC_REGNUM */
351
352 /* Register to use for pushing function arguments. */
353 #define STACK_POINTER_REGNUM 30
354
355 /* Base register for access to local variables of the function. */
356 #define FRAME_POINTER_REGNUM 15
357
358 /* Value should be nonzero if functions must have frame pointers.
359 Zero means the frame pointer need not be set up (and parms
360 may be accessed via the stack pointer) in functions that seem suitable.
361 This is computed in `reload', in reload1.c. */
362 #define FRAME_POINTER_REQUIRED 0
363
364 /* Base register for access to arguments of the function. */
365 #define ARG_POINTER_REGNUM 15
366
367 /* Register in which static-chain is passed to a function.
368
369 For the Alpha, this is based on an example; the calling sequence
370 doesn't seem to specify this. */
371 #define STATIC_CHAIN_REGNUM 1
372
373 /* Register in which address to store a structure value
374 arrives in the function. On the Alpha, the address is passed
375 as a hidden argument. */
376 #define STRUCT_VALUE 0
377 \f
378 /* Define the classes of registers for register constraints in the
379 machine description. Also define ranges of constants.
380
381 One of the classes must always be named ALL_REGS and include all hard regs.
382 If there is more than one class, another class must be named NO_REGS
383 and contain no registers.
384
385 The name GENERAL_REGS must be the name of a class (or an alias for
386 another name such as ALL_REGS). This is the class of registers
387 that is allowed by "g" or "r" in a register constraint.
388 Also, registers outside this class are allocated only when
389 instructions express preferences for them.
390
391 The classes must be numbered in nondecreasing order; that is,
392 a larger-numbered class must never be contained completely
393 in a smaller-numbered class.
394
395 For any two classes, it is very desirable that there be another
396 class that represents their union. */
397
398 enum reg_class { NO_REGS, GENERAL_REGS, FLOAT_REGS, ALL_REGS,
399 LIM_REG_CLASSES };
400
401 #define N_REG_CLASSES (int) LIM_REG_CLASSES
402
403 /* Give names of register classes as strings for dump file. */
404
405 #define REG_CLASS_NAMES \
406 {"NO_REGS", "GENERAL_REGS", "FLOAT_REGS", "ALL_REGS" }
407
408 /* Define which registers fit in which classes.
409 This is an initializer for a vector of HARD_REG_SET
410 of length N_REG_CLASSES. */
411
412 #define REG_CLASS_CONTENTS \
413 { {0, 0}, {~0, 0}, {0, ~0}, {~0, ~0} }
414
415 /* The same information, inverted:
416 Return the class number of the smallest class containing
417 reg number REGNO. This could be a conditional expression
418 or could index an array. */
419
420 #define REGNO_REG_CLASS(REGNO) ((REGNO) >= 32 ? FLOAT_REGS : GENERAL_REGS)
421
422 /* The class value for index registers, and the one for base regs. */
423 #define INDEX_REG_CLASS NO_REGS
424 #define BASE_REG_CLASS GENERAL_REGS
425
426 /* Get reg_class from a letter such as appears in the machine description. */
427
428 #define REG_CLASS_FROM_LETTER(C) \
429 ((C) == 'f' ? FLOAT_REGS : NO_REGS)
430
431 /* Define this macro to change register usage conditional on target flags. */
432 /* #define CONDITIONAL_REGISTER_USAGE */
433
434 /* The letters I, J, K, L, M, N, O, and P in a register constraint string
435 can be used to stand for particular ranges of immediate operands.
436 This macro defines what the ranges are.
437 C is the letter, and VALUE is a constant value.
438 Return 1 if VALUE is in the range specified by C.
439
440 For Alpha:
441 `I' is used for the range of constants most insns can contain.
442 `J' is the constant zero.
443 `K' is used for the constant in an LDA insn.
444 `L' is used for the constant in a LDAH insn.
445 `M' is used for the constants that can be AND'ed with using a ZAP insn.
446 `N' is used for complemented 8-bit constants.
447 `O' is used for negated 8-bit constants.
448 `P' is used for the constants 1, 2 and 3. */
449
450 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
451 ((C) == 'I' ? (unsigned HOST_WIDE_INT) (VALUE) < 0x100 \
452 : (C) == 'J' ? (VALUE) == 0 \
453 : (C) == 'K' ? (unsigned HOST_WIDE_INT) ((VALUE) + 0x8000) < 0x10000 \
454 : (C) == 'L' ? (((VALUE) & 0xffff) == 0 \
455 && (((VALUE)) >> 31 == -1 || (VALUE) >> 31 == 0)) \
456 : (C) == 'M' ? zap_mask (VALUE) \
457 : (C) == 'N' ? (unsigned HOST_WIDE_INT) (~ (VALUE)) < 0x100 \
458 : (C) == 'O' ? (unsigned HOST_WIDE_INT) (- (VALUE)) < 0x100 \
459 : (C) == 'P' ? (VALUE) == 1 || (VALUE) == 2 || (VALUE) == 3 \
460 : 0)
461
462 /* Similar, but for floating or large integer constants, and defining letters
463 G and H. Here VALUE is the CONST_DOUBLE rtx itself.
464
465 For Alpha, `G' is the floating-point constant zero. `H' is a CONST_DOUBLE
466 that is the operand of a ZAP insn. */
467
468 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
469 ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT \
470 && (VALUE) == CONST0_RTX (GET_MODE (VALUE))) \
471 : (C) == 'H' ? (GET_MODE (VALUE) == VOIDmode \
472 && zap_mask (CONST_DOUBLE_LOW (VALUE)) \
473 && zap_mask (CONST_DOUBLE_HIGH (VALUE))) \
474 : 0)
475
476 /* Given an rtx X being reloaded into a reg required to be
477 in class CLASS, return the class of reg to actually use.
478 In general this is just CLASS; but on some machines
479 in some cases it is preferable to use a more restrictive class.
480
481 On the Alpha, all constants except zero go into a floating-point
482 register via memory. */
483
484 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
485 (CONSTANT_P (X) && (X) != const0_rtx && (X) != CONST0_RTX (GET_MODE (X)) \
486 ? ((CLASS) == FLOAT_REGS ? NO_REGS : GENERAL_REGS) \
487 : (CLASS))
488
489 /* Loading and storing HImode or QImode values to and from memory
490 usually requires a scratch register. The exceptions are loading
491 QImode and HImode from an aligned address to a general register. */
492
493 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,IN) \
494 (((GET_CODE (IN) == MEM \
495 || (GET_CODE (IN) == REG && REGNO (IN) >= FIRST_PSEUDO_REGISTER) \
496 || (GET_CODE (IN) == SUBREG \
497 && (GET_CODE (SUBREG_REG (IN)) == MEM \
498 || (GET_CODE (SUBREG_REG (IN)) == REG \
499 && REGNO (SUBREG_REG (IN)) >= FIRST_PSEUDO_REGISTER)))) \
500 && (((CLASS) == FLOAT_REGS \
501 && ((MODE) == SImode || (MODE) == HImode || (MODE) == QImode)) \
502 || (((MODE) == QImode || (MODE) == HImode) \
503 && unaligned_memory_operand (IN, MODE)))) \
504 ? GENERAL_REGS : NO_REGS)
505
506 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,OUT) \
507 (((GET_CODE (OUT) == MEM \
508 || (GET_CODE (OUT) == REG && REGNO (OUT) >= FIRST_PSEUDO_REGISTER) \
509 || (GET_CODE (OUT) == SUBREG \
510 && (GET_CODE (SUBREG_REG (OUT)) == MEM \
511 || (GET_CODE (SUBREG_REG (OUT)) == REG \
512 && REGNO (SUBREG_REG (OUT)) >= FIRST_PSEUDO_REGISTER)))) \
513 && (((MODE) == HImode || (MODE) == QImode \
514 || ((MODE) == SImode && (CLASS) == FLOAT_REGS)))) \
515 ? GENERAL_REGS : NO_REGS)
516
517 /* If we are copying between general and FP registers, we need a memory
518 location. */
519
520 #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) ((CLASS1) != (CLASS2))
521
522 /* Return the maximum number of consecutive registers
523 needed to represent mode MODE in a register of class CLASS. */
524
525 #define CLASS_MAX_NREGS(CLASS, MODE) \
526 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
527
528 /* Define the cost of moving between registers of various classes. Moving
529 between FLOAT_REGS and anything else except float regs is expensive.
530 In fact, we make it quite expensive because we really don't want to
531 do these moves unless it is clearly worth it. Optimizations may
532 reduce the impact of not being able to allocate a pseudo to a
533 hard register. */
534
535 #define REGISTER_MOVE_COST(CLASS1, CLASS2) \
536 (((CLASS1) == FLOAT_REGS) == ((CLASS2) == FLOAT_REGS) ? 2 : 20)
537
538 /* A C expressions returning the cost of moving data of MODE from a register to
539 or from memory.
540
541 On the Alpha, bump this up a bit. */
542
543 #define MEMORY_MOVE_COST(MODE) 6
544
545 /* Provide the cost of a branch. Exact meaning under development. */
546 #define BRANCH_COST 5
547
548 /* Adjust the cost of dependencies. */
549
550 #define ADJUST_COST(INSN,LINK,DEP,COST) \
551 (COST) = alpha_adjust_cost (INSN, LINK, DEP, COST)
552 \f
553 /* Stack layout; function entry, exit and calling. */
554
555 /* Define this if pushing a word on the stack
556 makes the stack pointer a smaller address. */
557 #define STACK_GROWS_DOWNWARD
558
559 /* Define this if the nominal address of the stack frame
560 is at the high-address end of the local variables;
561 that is, each additional local variable allocated
562 goes at a more negative offset in the frame. */
563 #define FRAME_GROWS_DOWNWARD
564
565 /* Offset within stack frame to start allocating local variables at.
566 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
567 first local allocated. Otherwise, it is the offset to the BEGINNING
568 of the first local allocated. */
569
570 #define STARTING_FRAME_OFFSET (- current_function_pretend_args_size)
571
572 /* If we generate an insn to push BYTES bytes,
573 this says how many the stack pointer really advances by.
574 On Alpha, don't define this because there are no push insns. */
575 /* #define PUSH_ROUNDING(BYTES) */
576
577 /* Define this if the maximum size of all the outgoing args is to be
578 accumulated and pushed during the prologue. The amount can be
579 found in the variable current_function_outgoing_args_size. */
580 #define ACCUMULATE_OUTGOING_ARGS
581
582 /* Offset of first parameter from the argument pointer register value. */
583
584 #define FIRST_PARM_OFFSET(FNDECL) (- current_function_pretend_args_size)
585
586 /* Definitions for register eliminations.
587
588 We have one register that can be eliminated on the Alpha. The
589 frame pointer register can often be eliminated in favor of the stack
590 pointer register.
591
592 In addition, we use the elimination mechanism to see if gp (r29) is needed.
593 Initially we assume that it isn't. If it is, we spill it. This is done
594 by making it an eliminable register. It doesn't matter what we replace
595 it with, since it will never occur in the rtl at this point. */
596
597 /* This is an array of structures. Each structure initializes one pair
598 of eliminable registers. The "from" register number is given first,
599 followed by "to". Eliminations of the same "from" register are listed
600 in order of preference. */
601
602 #define ELIMINABLE_REGS \
603 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
604 { 29, 0}}
605
606 /* Given FROM and TO register numbers, say whether this elimination is allowed.
607 Frame pointer elimination is automatically handled.
608
609 We need gp (r29) if we have calls or load symbols
610 (tested in alpha_need_gp).
611
612 All other eliminations are valid since the cases where FP can't be
613 eliminated are already handled. */
614
615 #define CAN_ELIMINATE(FROM, TO) ((FROM) == 29 ? ! alpha_need_gp () : 1)
616
617 /* Define the offset between two registers, one to be eliminated, and the other
618 its replacement, at the start of a routine. */
619 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
620 { if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
621 (OFFSET) = (get_frame_size () + current_function_outgoing_args_size \
622 + current_function_pretend_args_size \
623 + alpha_sa_size () + 15) & ~ 15; \
624 }
625
626 /* Define this if stack space is still allocated for a parameter passed
627 in a register. */
628 /* #define REG_PARM_STACK_SPACE */
629
630 /* Value is the number of bytes of arguments automatically
631 popped when returning from a subroutine call.
632 FUNTYPE is the data type of the function (as a tree),
633 or for a library call it is an identifier node for the subroutine name.
634 SIZE is the number of bytes of arguments passed on the stack. */
635
636 #define RETURN_POPS_ARGS(FUNTYPE,SIZE) 0
637
638 /* Define how to find the value returned by a function.
639 VALTYPE is the data type of the value (as a tree).
640 If the precise function being called is known, FUNC is its FUNCTION_DECL;
641 otherwise, FUNC is 0.
642
643 On Alpha the value is found in $0 for integer functions and
644 $f0 for floating-point functions. */
645
646 #define FUNCTION_VALUE(VALTYPE, FUNC) \
647 gen_rtx (REG, \
648 ((TREE_CODE (VALTYPE) == INTEGER_TYPE \
649 || TREE_CODE (VALTYPE) == ENUMERAL_TYPE \
650 || TREE_CODE (VALTYPE) == BOOLEAN_TYPE \
651 || TREE_CODE (VALTYPE) == CHAR_TYPE \
652 || TREE_CODE (VALTYPE) == POINTER_TYPE \
653 || TREE_CODE (VALTYPE) == OFFSET_TYPE) \
654 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
655 ? word_mode : TYPE_MODE (VALTYPE), \
656 TARGET_FPREGS && TREE_CODE (VALTYPE) == REAL_TYPE ? 32 : 0)
657
658 /* Define how to find the value returned by a library function
659 assuming the value has mode MODE. */
660
661 #define LIBCALL_VALUE(MODE) \
662 gen_rtx (REG, MODE, \
663 TARGET_FPREGS && GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 : 0)
664
665 /* 1 if N is a possible register number for a function value
666 as seen by the caller. */
667
668 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 32)
669
670 /* 1 if N is a possible register number for function argument passing.
671 On Alpha, these are $16-$21 and $f16-$f21. */
672
673 #define FUNCTION_ARG_REGNO_P(N) \
674 (((N) >= 16 && (N) <= 21) || ((N) >= 16 + 32 && (N) <= 21 + 32))
675 \f
676 /* Define a data type for recording info about an argument list
677 during the scan of that argument list. This data type should
678 hold all necessary information about the function itself
679 and about the args processed so far, enough to enable macros
680 such as FUNCTION_ARG to determine where the next arg should go.
681
682 On Alpha, this is a single integer, which is a number of words
683 of arguments scanned so far.
684 Thus 6 or more means all following args should go on the stack. */
685
686 #define CUMULATIVE_ARGS int
687
688 /* Initialize a variable CUM of type CUMULATIVE_ARGS
689 for a call to a function whose data type is FNTYPE.
690 For a library call, FNTYPE is 0. */
691
692 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) (CUM) = 0
693
694 /* Define intermediate macro to compute the size (in registers) of an argument
695 for the Alpha. */
696
697 #define ALPHA_ARG_SIZE(MODE, TYPE, NAMED) \
698 ((MODE) != BLKmode \
699 ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD \
700 : (int_size_in_bytes (TYPE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
701
702 /* Update the data in CUM to advance over an argument
703 of mode MODE and data type TYPE.
704 (TYPE is null for libcalls where that information may not be available.) */
705
706 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
707 if (MUST_PASS_IN_STACK (MODE, TYPE)) \
708 (CUM) = 6; \
709 else \
710 (CUM) += ALPHA_ARG_SIZE (MODE, TYPE, NAMED)
711
712 /* Determine where to put an argument to a function.
713 Value is zero to push the argument on the stack,
714 or a hard register in which to store the argument.
715
716 MODE is the argument's machine mode.
717 TYPE is the data type of the argument (as a tree).
718 This is null for libcalls where that information may
719 not be available.
720 CUM is a variable of type CUMULATIVE_ARGS which gives info about
721 the preceding args and about the function being called.
722 NAMED is nonzero if this argument is a named parameter
723 (otherwise it is an extra parameter matching an ellipsis).
724
725 On Alpha the first 6 words of args are normally in registers
726 and the rest are pushed. */
727
728 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
729 ((CUM) < 6 && ! MUST_PASS_IN_STACK (MODE, TYPE) \
730 ? gen_rtx(REG, (MODE), \
731 (CUM) + 16 + (TARGET_FPREGS \
732 && GET_MODE_CLASS (MODE) == MODE_FLOAT) * 32) : 0)
733
734 /* This indicates that an argument is to be passed with an invisible reference
735 (i.e., a pointer to the object is passed).
736
737 On the Alpha, we do this if it must be passed on the stack. */
738
739 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
740 (MUST_PASS_IN_STACK (MODE, TYPE))
741
742 /* Specify the padding direction of arguments.
743
744 On the Alpha, we must pad upwards in order to be able to pass args in
745 registers. */
746
747 #define FUNCTION_ARG_PADDING(MODE, TYPE) upward
748
749 /* For an arg passed partly in registers and partly in memory,
750 this is the number of registers used.
751 For args passed entirely in registers or entirely in memory, zero. */
752
753 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
754 ((CUM) < 6 && 6 < (CUM) + ALPHA_ARG_SIZE (MODE, TYPE, NAMED) \
755 ? 6 - (CUM) : 0)
756
757 /* Generate necessary RTL for __builtin_saveregs().
758 ARGLIST is the argument list; see expr.c. */
759 extern struct rtx_def *alpha_builtin_saveregs ();
760 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) alpha_builtin_saveregs (ARGLIST)
761
762 /* Define the information needed to generate branch and scc insns. This is
763 stored from the compare operation. Note that we can't use "rtx" here
764 since it hasn't been defined! */
765
766 extern struct rtx_def *alpha_compare_op0, *alpha_compare_op1;
767 extern int alpha_compare_fp_p;
768
769 /* This macro produces the initial definition of a function name. On the
770 29k, we need to save the function name for the epilogue. */
771
772 extern char *alpha_function_name;
773
774 #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \
775 { fprintf (FILE, "\t.ent %s 2\n", NAME); \
776 ASM_OUTPUT_LABEL (FILE, NAME); \
777 alpha_function_name = NAME; \
778 }
779
780 /* This macro generates the assembly code for function entry.
781 FILE is a stdio stream to output the code to.
782 SIZE is an int: how many units of temporary storage to allocate.
783 Refer to the array `regs_ever_live' to determine which registers
784 to save; `regs_ever_live[I]' is nonzero if register number I
785 is ever used in the function. This macro is responsible for
786 knowing which registers should not be saved even if used. */
787
788 #define FUNCTION_PROLOGUE(FILE, SIZE) output_prolog (FILE, SIZE)
789
790 /* Output assembler code to FILE to increment profiler label # LABELNO
791 for profiling a function entry. */
792
793 #define FUNCTION_PROFILER(FILE, LABELNO)
794
795 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
796 the stack pointer does not matter. The value is tested only in
797 functions that have frame pointers.
798 No definition is equivalent to always zero. */
799
800 #define EXIT_IGNORE_STACK 1
801
802 /* This macro generates the assembly code for function exit,
803 on machines that need it. If FUNCTION_EPILOGUE is not defined
804 then individual return instructions are generated for each
805 return statement. Args are same as for FUNCTION_PROLOGUE.
806
807 The function epilogue should not depend on the current stack pointer!
808 It should use the frame pointer only. This is mandatory because
809 of alloca; we also take advantage of it to omit stack adjustments
810 before returning. */
811
812 #define FUNCTION_EPILOGUE(FILE, SIZE) output_epilog (FILE, SIZE)
813
814 \f
815 /* Output assembler code for a block containing the constant parts
816 of a trampoline, leaving space for the variable parts.
817
818 The trampoline should set the static chain pointer to value placed
819 into the trampoline and should branch to the specified routine. We
820 use $28 (at) as a temporary. Note that $27 has been set to the
821 address of the trampoline, so we can use it for addressability
822 of the two data items. Trampolines are always aligned to
823 FUNCTION_BOUNDARY, which is 64 bits. */
824
825 #define TRAMPOLINE_TEMPLATE(FILE) \
826 { \
827 fprintf (FILE, "\tbis $27,$27,$28\n"); \
828 fprintf (FILE, "\tldq $27,16($27)\n"); \
829 fprintf (FILE, "\tldq $1,20($28)\n"); \
830 fprintf (FILE, "\tjmp $31,0($27),0\n"); \
831 fprintf (FILE, "\t.quad 0,0\n"); \
832 }
833
834 /* Length in units of the trampoline for entering a nested function. */
835
836 #define TRAMPOLINE_SIZE 24
837
838 /* Emit RTL insns to initialize the variable parts of a trampoline.
839 FNADDR is an RTX for the address of the function's pure code.
840 CXT is an RTX for the static chain value for the function. We assume
841 here that a function will be called many more times than its address
842 is taken (e.g., it might be passed to qsort), so we take the trouble
843 to initialize the "hint" field in the JMP insn. */
844
845 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
846 { \
847 rtx _temp, _temp1, _addr; \
848 \
849 _addr = memory_address (Pmode, plus_constant ((TRAMP), 16)); \
850 emit_move_insn (gen_rtx (MEM, Pmode, _addr), (FNADDR)); \
851 _addr = memory_address (Pmode, plus_constant ((TRAMP), 20)); \
852 emit_move_insn (gen_rtx (MEM, Pmode, _addr), (CXT)); \
853 \
854 _temp = expand_shift (RSHIFT_EXPR, Pmode, (FNADDR), \
855 build_int_2 (2, 0), NULL_RTX, 1); \
856 _temp = expand_and (_temp, GEN_INT (0x1fff), 0); \
857 \
858 _addr = memory_address (SImode, plus_constant ((TRAMP), 12)); \
859 _temp1 = force_reg (SImode, gen_rtx (MEM, SImode, _addr)); \
860 _temp1 = expand_and (_temp, GEN_INT (0xfffe000), NULL_RTX); \
861 _temp1 = expand_binop (SImode, ior_optab, _temp1, _temp, _temp1, 1, \
862 OPTAB_WIDEN); \
863 \
864 emit_move_insn (gen_rtx (MEM, SImode, _addr), _temp1); \
865 }
866 \f
867 /* Addressing modes, and classification of registers for them. */
868
869 /* #define HAVE_POST_INCREMENT */
870 /* #define HAVE_POST_DECREMENT */
871
872 /* #define HAVE_PRE_DECREMENT */
873 /* #define HAVE_PRE_INCREMENT */
874
875 /* Macros to check register numbers against specific register classes. */
876
877 /* These assume that REGNO is a hard or pseudo reg number.
878 They give nonzero only if REGNO is a hard reg of the suitable class
879 or a pseudo reg currently allocated to a suitable hard reg.
880 Since they use reg_renumber, they are safe only once reg_renumber
881 has been allocated, which happens in local-alloc.c. */
882
883 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
884 #define REGNO_OK_FOR_BASE_P(REGNO) \
885 (((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32))
886 \f
887 /* Maximum number of registers that can appear in a valid memory address. */
888 #define MAX_REGS_PER_ADDRESS 1
889
890 /* Recognize any constant value that is a valid address. For the Alpha,
891 there are only constants none since we want to use LDA to load any
892 symbolic addresses into registers. */
893
894 #define CONSTANT_ADDRESS_P(X) \
895 (GET_CODE (X) == CONST_INT \
896 && (unsigned HOST_WIDE_INT) (INTVAL (X) + 0x8000) < 0x10000)
897
898 /* Include all constant integers and constant doubles, but not
899 floating-point, except for floating-point zero. */
900
901 #define LEGITIMATE_CONSTANT_P(X) \
902 (GET_MODE_CLASS (GET_MODE (X)) != MODE_FLOAT \
903 || (X) == CONST0_RTX (GET_MODE (X)))
904
905 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
906 and check its validity for a certain class.
907 We have two alternate definitions for each of them.
908 The usual definition accepts all pseudo regs; the other rejects
909 them unless they have been allocated suitable hard regs.
910 The symbol REG_OK_STRICT causes the latter definition to be used.
911
912 Most source files want to accept pseudo regs in the hope that
913 they will get allocated to the class that the insn wants them to be in.
914 Source files for reload pass need to be strict.
915 After reload, it makes no difference, since pseudo regs have
916 been eliminated by then. */
917
918 #ifndef REG_OK_STRICT
919
920 /* Nonzero if X is a hard reg that can be used as an index
921 or if it is a pseudo reg. */
922 #define REG_OK_FOR_INDEX_P(X) 0
923 /* Nonzero if X is a hard reg that can be used as a base reg
924 or if it is a pseudo reg. */
925 #define REG_OK_FOR_BASE_P(X) \
926 (REGNO (X) < 32 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
927
928 #else
929
930 /* Nonzero if X is a hard reg that can be used as an index. */
931 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
932 /* Nonzero if X is a hard reg that can be used as a base reg. */
933 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
934
935 #endif
936 \f
937 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
938 that is a valid memory address for an instruction.
939 The MODE argument is the machine mode for the MEM expression
940 that wants to use this address.
941
942 For Alpha, we have either a constant address or the sum of a register
943 and a constant address, or just a register. For DImode, any of those
944 forms can be surrounded with an AND that clear the low-order three bits;
945 this is an "unaligned" access.
946
947 We also allow a SYMBOL_REF that is the name of the current function as
948 valid address. This is for CALL_INSNs. It cannot be used in any other
949 context.
950
951 First define the basic valid address. */
952
953 #define GO_IF_LEGITIMATE_SIMPLE_ADDRESS(MODE, X, ADDR) \
954 { if (REG_P (X) && REG_OK_FOR_BASE_P (X)) \
955 goto ADDR; \
956 if (CONSTANT_ADDRESS_P (X)) \
957 goto ADDR; \
958 if (GET_CODE (X) == PLUS \
959 && REG_P (XEXP (X, 0)) \
960 && REG_OK_FOR_BASE_P (XEXP (X, 0)) \
961 && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
962 goto ADDR; \
963 }
964
965 /* Now accept the simple address, or, for DImode only, an AND of a simple
966 address that turns off the low three bits. */
967
968 extern char *current_function_name;
969
970 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
971 { GO_IF_LEGITIMATE_SIMPLE_ADDRESS (MODE, X, ADDR); \
972 if ((MODE) == DImode \
973 && GET_CODE (X) == AND \
974 && GET_CODE (XEXP (X, 1)) == CONST_INT \
975 && INTVAL (XEXP (X, 1)) == -8) \
976 GO_IF_LEGITIMATE_SIMPLE_ADDRESS (MODE, XEXP (X, 0), ADDR); \
977 if ((MODE) == Pmode && GET_CODE (X) == SYMBOL_REF \
978 && ! strcmp (XSTR (X, 0), current_function_name)) \
979 goto ADDR; \
980 }
981
982 /* Try machine-dependent ways of modifying an illegitimate address
983 to be legitimate. If we find one, return the new, valid address.
984 This macro is used in only one place: `memory_address' in explow.c.
985
986 OLDX is the address as it was before break_out_memory_refs was called.
987 In some cases it is useful to look at this to decide what needs to be done.
988
989 MODE and WIN are passed so that this macro can use
990 GO_IF_LEGITIMATE_ADDRESS.
991
992 It is always safe for this macro to do nothing. It exists to recognize
993 opportunities to optimize the output.
994
995 For the Alpha, there are three cases we handle:
996
997 (1) If the address is (plus reg const_int) and the CONST_INT is not a
998 valid offset, compute the high part of the constant and add it to the
999 register. Then our address is (plus temp low-part-const).
1000 (2) If the address is (const (plus FOO const_int)), find the low-order
1001 part of the CONST_INT. Then load FOO plus any high-order part of the
1002 CONST_INT into a register. Our address is (plus reg low-part-const).
1003 This is done to reduce the number of GOT entries.
1004 (3) If we have a (plus reg const), emit the load as in (2), then add
1005 the two registers, and finally generate (plus reg low-part-const) as
1006 our address. */
1007
1008 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1009 { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
1010 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1011 && ! CONSTANT_ADDRESS_P (XEXP (X, 1))) \
1012 { \
1013 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1014 HOST_WIDE_INT lowpart = (val & 0xffff) - 2 * (val & 0x8000); \
1015 HOST_WIDE_INT highpart = val - lowpart; \
1016 rtx high = GEN_INT (highpart); \
1017 rtx temp = expand_binop (Pmode, add_optab, XEXP (x, 0), \
1018 high, 0, OPTAB_LIB_WIDEN); \
1019 \
1020 (X) = plus_constant (temp, lowpart); \
1021 goto WIN; \
1022 } \
1023 else if (GET_CODE (X) == CONST \
1024 && GET_CODE (XEXP (X, 0)) == PLUS \
1025 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT) \
1026 { \
1027 HOST_WIDE_INT val = INTVAL (XEXP (XEXP (X, 0), 1)); \
1028 HOST_WIDE_INT lowpart = (val & 0xffff) - 2 * (val & 0x8000); \
1029 HOST_WIDE_INT highpart = val - lowpart; \
1030 rtx high = XEXP (XEXP (X, 0), 0); \
1031 \
1032 if (highpart) \
1033 high = plus_constant (high, highpart); \
1034 \
1035 (X) = plus_constant (force_reg (Pmode, high), lowpart); \
1036 goto WIN; \
1037 } \
1038 else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
1039 && GET_CODE (XEXP (X, 1)) == CONST \
1040 && GET_CODE (XEXP (XEXP (X, 1), 0)) == PLUS \
1041 && GET_CODE (XEXP (XEXP (XEXP (X, 1), 0), 1)) == CONST_INT) \
1042 { \
1043 HOST_WIDE_INT val = INTVAL (XEXP (XEXP (XEXP (X, 1), 0), 1)); \
1044 HOST_WIDE_INT lowpart = (val & 0xffff) - 2 * (val & 0x8000); \
1045 HOST_WIDE_INT highpart = val - lowpart; \
1046 rtx high = XEXP (XEXP (XEXP (X, 1), 0), 0); \
1047 \
1048 if (highpart) \
1049 high = plus_constant (high, highpart); \
1050 \
1051 high = expand_binop (Pmode, add_optab, XEXP (X, 0), \
1052 force_reg (Pmode, high), \
1053 high, OPTAB_LIB_WIDEN); \
1054 (X) = plus_constant (high, lowpart); \
1055 goto WIN; \
1056 } \
1057 }
1058
1059 /* Go to LABEL if ADDR (a legitimate address expression)
1060 has an effect that depends on the machine mode it is used for.
1061 On the Alpha this is true only for the unaligned modes. We can
1062 simplify this test since we know that the address must be valid. */
1063
1064 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1065 { if (GET_CODE (ADDR) == AND) goto LABEL; }
1066
1067 /* Compute the cost of an address. For the Alpha, all valid addresses are
1068 the same cost. */
1069
1070 #define ADDRESS_COST(X) 0
1071
1072 /* Define this if some processing needs to be done immediately before
1073 emitting code for an insn. */
1074
1075 /* #define FINAL_PRESCAN_INSN(INSN,OPERANDS,NOPERANDS) */
1076 \f
1077 /* Specify the machine mode that this machine uses
1078 for the index in the tablejump instruction. */
1079 #define CASE_VECTOR_MODE SImode
1080
1081 /* Define this if the tablejump instruction expects the table
1082 to contain offsets from the address of the table.
1083 Do not define this if the table should contain absolute addresses. */
1084 /* #define CASE_VECTOR_PC_RELATIVE */
1085
1086 /* Specify the tree operation to be used to convert reals to integers. */
1087 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1088
1089 /* This is the kind of divide that is easiest to do in the general case. */
1090 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1091
1092 /* Define this as 1 if `char' should by default be signed; else as 0. */
1093 #define DEFAULT_SIGNED_CHAR 1
1094
1095 /* This flag, if defined, says the same insns that convert to a signed fixnum
1096 also convert validly to an unsigned one.
1097
1098 We actually lie a bit here as overflow conditions are different. But
1099 they aren't being checked anyway. */
1100
1101 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
1102
1103 /* Max number of bytes we can move to or from memory
1104 in one reasonably fast instruction. */
1105
1106 #define MOVE_MAX 8
1107
1108 /* Largest number of bytes of an object that can be placed in a register.
1109 On the Alpha we have plenty of registers, so use TImode. */
1110 #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TImode)
1111
1112 /* Nonzero if access to memory by bytes is no faster than for words.
1113 Also non-zero if doing byte operations (specifically shifts) in registers
1114 is undesirable.
1115
1116 On the Alpha, we want to not use the byte operation and instead use
1117 masking operations to access fields; these will save instructions. */
1118
1119 #define SLOW_BYTE_ACCESS 1
1120
1121 /* Define if normal loads of shorter-than-word items from memory clears
1122 the rest of the bits in the register. */
1123 /* #define BYTE_LOADS_ZERO_EXTEND */
1124
1125 /* Define if normal loads of shorter-than-word items from memory sign-extends
1126 the rest of the bits in the register. */
1127 #define BYTE_LOADS_SIGN_EXTEND
1128
1129 /* We aren't doing ANYTHING about debugging for now. */
1130 /* #define SDB_DEBUGGING_INFO */
1131
1132 /* Do not break .stabs pseudos into continuations. */
1133 #define DBX_CONTIN_LENGTH 0
1134
1135 /* Don't try to use the `x' type-cross-reference character in DBX data.
1136 Also has the consequence of putting each struct, union or enum
1137 into a separate .stabs, containing only cross-refs to the others. */
1138 #define DBX_NO_XREFS
1139
1140 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1141 is done just by pretending it is already truncated. */
1142 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1143
1144 /* We assume that the store-condition-codes instructions store 0 for false
1145 and some other value for true. This is the value stored for true. */
1146
1147 #define STORE_FLAG_VALUE 1
1148
1149 /* Define the value returned by a floating-point comparison instruction. */
1150
1151 #define FLOAT_STORE_FLAG_VALUE 0.5
1152
1153 /* Specify the machine mode that pointers have.
1154 After generation of rtl, the compiler makes no further distinction
1155 between pointers and any other objects of this machine mode. */
1156 #define Pmode DImode
1157
1158 /* Mode of a function address in a call instruction (for indexing purposes). */
1159
1160 #define FUNCTION_MODE Pmode
1161
1162 /* Define this if addresses of constant functions
1163 shouldn't be put through pseudo regs where they can be cse'd.
1164 Desirable on machines where ordinary constants are expensive
1165 but a CALL with constant address is cheap.
1166
1167 We define this on the Alpha so that gen_call and gen_call_value
1168 get to see the SYMBOL_REF (for the hint field of the jsr). It will
1169 then copy it into a register, thus actually letting the address be
1170 cse'ed. */
1171
1172 #define NO_FUNCTION_CSE
1173
1174 /* Define this if shift instructions ignore all but the low-order
1175 few bits. */
1176 #define SHIFT_COUNT_TRUNCATED
1177
1178 /* Compute the cost of computing a constant rtl expression RTX
1179 whose rtx-code is CODE. The body of this macro is a portion
1180 of a switch statement. If the code is computed here,
1181 return it with a return statement. Otherwise, break from the switch.
1182
1183 We only care about the cost if it is valid in an insn, so all constants
1184 are cheap. */
1185
1186 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1187 case CONST_INT: \
1188 case CONST_DOUBLE: \
1189 return 0; \
1190 case CONST: \
1191 case SYMBOL_REF: \
1192 case LABEL_REF: \
1193 return 6; \
1194
1195 /* Provide the costs of a rtl expression. This is in the body of a
1196 switch on CODE. */
1197
1198 #define RTX_COSTS(X,CODE,OUTER_CODE) \
1199 case PLUS: \
1200 case MINUS: \
1201 if (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
1202 return COSTS_N_INSNS (6); \
1203 break; \
1204 case MULT: \
1205 if (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
1206 return COSTS_N_INSNS (6); \
1207 else \
1208 return COSTS_N_INSNS (21); \
1209 case DIV: \
1210 case UDIV: \
1211 case MOD: \
1212 case UMOD: \
1213 if (GET_MODE (X) == SFmode) \
1214 return COSTS_N_INSNS (34); \
1215 else if (GET_MODE (X) == DFmode) \
1216 return COSTS_N_INSNS (63); \
1217 else \
1218 return COSTS_N_INSNS (70); \
1219 case MEM: \
1220 return COSTS_N_INSNS (3);
1221 \f
1222 /* Control the assembler format that we output. */
1223
1224 /* Output at beginning of assembler file. */
1225
1226 #define ASM_FILE_START(FILE) \
1227 { extern char *version_string; \
1228 char *p, *after_dir = main_input_filename; \
1229 \
1230 fprintf (FILE, "\t.verstamp 9 0 "); \
1231 for (p = version_string; *p != 0; p++) \
1232 fprintf (FILE, "%c", *p == '.' ? ' ' : *p); \
1233 fprintf (FILE, "\n\t.set noreorder\n"); \
1234 fprintf (FILE, "\t.set noat\n"); \
1235 for (p = main_input_filename; *p; p++) \
1236 if (*p == '/') \
1237 after_dir = p + 1; \
1238 fprintf (FILE, "\n\t.file 2 \"%s\"\n", after_dir); \
1239 }
1240
1241 /* Output to assembler file text saying following lines
1242 may contain character constants, extra white space, comments, etc. */
1243
1244 #define ASM_APP_ON ""
1245
1246 /* Output to assembler file text saying following lines
1247 no longer contain unusual constructs. */
1248
1249 #define ASM_APP_OFF ""
1250
1251 #define TEXT_SECTION_ASM_OP ".text"
1252
1253 /* Output before read-only data. */
1254
1255 #define READONLY_DATA_SECTION_ASM_OP ".rdata"
1256
1257 /* Output before writable data. */
1258
1259 #define DATA_SECTION_ASM_OP ".data"
1260
1261 /* Define an extra section for read-only data, a routine to enter it, and
1262 indicate that it is for read-only data. */
1263
1264 #define EXTRA_SECTIONS readonly_data
1265
1266 #define EXTRA_SECTION_FUNCTIONS \
1267 void \
1268 literal_section () \
1269 { \
1270 if (in_section != readonly_data) \
1271 { \
1272 fprintf (asm_out_file, "%s\n", READONLY_DATA_SECTION_ASM_OP); \
1273 in_section = readonly_data; \
1274 } \
1275 } \
1276
1277 #define READONLY_DATA_SECTION literal_section
1278
1279 /* How to refer to registers in assembler output.
1280 This sequence is indexed by compiler's hard-register-number (see above). */
1281
1282 #define REGISTER_NAMES \
1283 {"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
1284 "$9", "$10", "$11", "$12", "$13", "$14", "$15", \
1285 "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", \
1286 "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31", \
1287 "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", \
1288 "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", \
1289 "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",\
1290 "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31"}
1291
1292 /* How to renumber registers for dbx and gdb. */
1293
1294 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1295
1296 /* This is how to output the definition of a user-level label named NAME,
1297 such as the label on a static function or variable NAME. */
1298
1299 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1300 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1301
1302 /* This is how to output a command to make the user-level label named NAME
1303 defined for reference from other files. */
1304
1305 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
1306 do { fputs ("\t.globl ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
1307
1308 /* This is how to output a reference to a user-level label named NAME.
1309 `assemble_name' uses this. */
1310
1311 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
1312 fprintf (FILE, "%s", NAME)
1313
1314 /* This is how to output an internal numbered label where
1315 PREFIX is the class of label and NUM is the number within the class. */
1316
1317 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1318 if ((PREFIX)[0] == 'L') \
1319 fprintf (FILE, "$%s%d:\n", & (PREFIX)[1], NUM + 32); \
1320 else \
1321 fprintf (FILE, "%s%d:\n", PREFIX, NUM);
1322
1323 /* This is how to output a label for a jump table. Arguments are the same as
1324 for ASM_OUTPUT_INTERNAL_LABEL, except the insn for the jump table is
1325 passed. */
1326
1327 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \
1328 { ASM_OUTPUT_ALIGN (FILE, 2); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); }
1329
1330 /* This is how to store into the string LABEL
1331 the symbol_ref name of an internal numbered label where
1332 PREFIX is the class of label and NUM is the number within the class.
1333 This is suitable for output with `assemble_name'. */
1334
1335 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
1336 if ((PREFIX)[0] == 'L') \
1337 sprintf (LABEL, "*$%s%d", & (PREFIX)[1], NUM + 32); \
1338 else \
1339 sprintf (LABEL, "*%s%d", PREFIX, NUM)
1340
1341 /* This is how to output an assembler line defining a `double' constant. */
1342
1343 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1344 fprintf (FILE, "\t.t_floating %.20e\n", (VALUE))
1345
1346 /* This is how to output an assembler line defining a `float' constant. */
1347
1348 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1349 fprintf (FILE, "\t.s_floating %.20e\n", (VALUE))
1350
1351 /* This is how to output an assembler line defining an `int' constant. */
1352
1353 #define ASM_OUTPUT_INT(FILE,VALUE) \
1354 ( fprintf (FILE, "\t.long "), \
1355 output_addr_const (FILE, (VALUE)), \
1356 fprintf (FILE, "\n"))
1357
1358 /* This is how to output an assembler line defining a `long' constant. */
1359
1360 #define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE) \
1361 ( fprintf (FILE, "\t.quad "), \
1362 output_addr_const (FILE, (VALUE)), \
1363 fprintf (FILE, "\n"))
1364
1365 /* Likewise for `char' and `short' constants. */
1366
1367 #define ASM_OUTPUT_SHORT(FILE,VALUE) \
1368 ( fprintf (FILE, "\t.word "), \
1369 output_addr_const (FILE, (VALUE)), \
1370 fprintf (FILE, "\n"))
1371
1372 #define ASM_OUTPUT_CHAR(FILE,VALUE) \
1373 ( fprintf (FILE, "\t.byte "), \
1374 output_addr_const (FILE, (VALUE)), \
1375 fprintf (FILE, "\n"))
1376
1377 /* We use the default ASCII-output routine, except that we don't write more
1378 than 50 characters since the assembler doesn't support very long lines. */
1379
1380 #define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
1381 do { \
1382 FILE *_hide_asm_out_file = (MYFILE); \
1383 unsigned char *_hide_p = (unsigned char *) (MYSTRING); \
1384 int _hide_thissize = (MYLENGTH); \
1385 int _size_so_far = 0; \
1386 { \
1387 FILE *asm_out_file = _hide_asm_out_file; \
1388 unsigned char *p = _hide_p; \
1389 int thissize = _hide_thissize; \
1390 int i; \
1391 fprintf (asm_out_file, "\t.ascii \""); \
1392 \
1393 for (i = 0; i < thissize; i++) \
1394 { \
1395 register int c = p[i]; \
1396 \
1397 if (_size_so_far ++ > 50 && i < thissize - 4) \
1398 _size_so_far = 0, fprintf (asm_out_file, "\"\n\t.ascii \""); \
1399 \
1400 if (c == '\"' || c == '\\') \
1401 putc ('\\', asm_out_file); \
1402 if (c >= ' ' && c < 0177) \
1403 putc (c, asm_out_file); \
1404 else \
1405 { \
1406 fprintf (asm_out_file, "\\%o", c); \
1407 /* After an octal-escape, if a digit follows, \
1408 terminate one string constant and start another. \
1409 The Vax assembler fails to stop reading the escape \
1410 after three digits, so this is the only way we \
1411 can get it to parse the data properly. */ \
1412 if (i < thissize - 1 \
1413 && p[i + 1] >= '0' && p[i + 1] <= '9') \
1414 fprintf (asm_out_file, "\"\n\t.ascii \""); \
1415 } \
1416 } \
1417 fprintf (asm_out_file, "\"\n"); \
1418 } \
1419 } \
1420 while (0)
1421 /* This is how to output an insn to push a register on the stack.
1422 It need not be very fast code. */
1423
1424 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
1425 fprintf (FILE, "\tsubq $30,8,$30\n\tst%s $%s%d,0($30)\n", \
1426 (REGNO) > 32 ? "t" : "q", (REGNO) > 32 ? "f" : "", \
1427 (REGNO) & 31);
1428
1429 /* This is how to output an insn to pop a register from the stack.
1430 It need not be very fast code. */
1431
1432 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
1433 fprintf (FILE, "\tld%s $%s%d,0($30)\n\taddq $30,8,$30\n", \
1434 (REGNO) > 32 ? "t" : "q", (REGNO) > 32 ? "f" : "", \
1435 (REGNO) & 31);
1436
1437 /* This is how to output an assembler line for a numeric constant byte. */
1438
1439 #define ASM_OUTPUT_BYTE(FILE,VALUE) \
1440 fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
1441
1442 /* This is how to output an element of a case-vector that is absolute. */
1443
1444 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1445 fprintf (FILE, "\t.gprel32 $%d\n", (VALUE) + 32)
1446
1447 /* This is how to output an element of a case-vector that is relative.
1448 (Alpha does not use such vectors, but we must define this macro anyway.) */
1449
1450 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) abort ()
1451
1452 /* This is how to output an assembler line
1453 that says to advance the location counter
1454 to a multiple of 2**LOG bytes. */
1455
1456 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1457 if ((LOG) != 0) \
1458 fprintf (FILE, "\t.align %d\n", LOG);
1459
1460 /* This is how to advance the location counter by SIZE bytes. */
1461
1462 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1463 fprintf (FILE, "\t.space %d\n", (SIZE))
1464
1465 /* This says how to output an assembler line
1466 to define a global common symbol. */
1467
1468 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1469 ( fputs ("\t.comm ", (FILE)), \
1470 assemble_name ((FILE), (NAME)), \
1471 fprintf ((FILE), ",%d\n", (SIZE)))
1472
1473 /* This says how to output an assembler line
1474 to define a local common symbol. */
1475
1476 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \
1477 ( fputs ("\t.lcomm ", (FILE)), \
1478 assemble_name ((FILE), (NAME)), \
1479 fprintf ((FILE), ",%d\n", (SIZE)))
1480
1481 /* Store in OUTPUT a string (made with alloca) containing
1482 an assembler-name for a local static variable named NAME.
1483 LABELNO is an integer which is different for each call. */
1484
1485 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1486 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1487 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1488
1489 /* Define the parentheses used to group arithmetic operations
1490 in assembler code. */
1491
1492 #define ASM_OPEN_PAREN "("
1493 #define ASM_CLOSE_PAREN ")"
1494
1495 /* Define results of standard character escape sequences. */
1496 #define TARGET_BELL 007
1497 #define TARGET_BS 010
1498 #define TARGET_TAB 011
1499 #define TARGET_NEWLINE 012
1500 #define TARGET_VT 013
1501 #define TARGET_FF 014
1502 #define TARGET_CR 015
1503
1504 /* Print operand X (an rtx) in assembler syntax to file FILE.
1505 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1506 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1507
1508 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
1509
1510 /* Determine which codes are valid without a following integer. These must
1511 not be alphabetic. */
1512
1513 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) 0
1514 \f
1515 /* Print a memory address as an operand to reference that memory location. */
1516
1517 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1518 { rtx addr = (ADDR); \
1519 int basereg = 31; \
1520 HOST_WIDE_INT offset = 0; \
1521 \
1522 if (GET_CODE (addr) == AND) \
1523 addr = XEXP (addr, 0); \
1524 \
1525 if (GET_CODE (addr) == REG) \
1526 basereg = REGNO (addr); \
1527 else if (GET_CODE (addr) == CONST_INT) \
1528 offset = INTVAL (addr); \
1529 else if (GET_CODE (addr) == PLUS \
1530 && GET_CODE (XEXP (addr, 0)) == REG \
1531 && GET_CODE (XEXP (addr, 1)) == CONST_INT) \
1532 basereg = REGNO (XEXP (addr, 0)), offset = INTVAL (XEXP (addr, 1)); \
1533 else \
1534 abort (); \
1535 \
1536 fprintf (FILE, "%d($%d)", offset, basereg); \
1537 }
1538 /* Define the codes that are matched by predicates in alpha.c. */
1539
1540 #define PREDICATE_CODES \
1541 {"reg_or_0_operand", {SUBREG, REG, CONST_INT}}, \
1542 {"reg_or_8bit_operand", {SUBREG, REG, CONST_INT}}, \
1543 {"reg_or_cint_operand", {SUBREG, REG, CONST_INT}}, \
1544 {"add_operand", {SUBREG, REG, CONST_INT}}, \
1545 {"sext_add_operand", {SUBREG, REG, CONST_INT}}, \
1546 {"const48_operand", {CONST_INT}}, \
1547 {"and_operand", {SUBREG, REG, CONST_INT}}, \
1548 {"mode_mask_operand", {CONST_INT}}, \
1549 {"mul8_operand", {CONST_INT}}, \
1550 {"mode_width_operand", {CONST_INT}}, \
1551 {"reg_or_fp0_operand", {SUBREG, REG, CONST_DOUBLE}}, \
1552 {"alpha_comparison_operator", {EQ, LE, LT, LEU, LTU}}, \
1553 {"signed_comparison_operator", {EQ, NE, LE, LT, GE, GT}}, \
1554 {"fp0_operand", {CONST_DOUBLE}}, \
1555 {"input_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE, \
1556 SYMBOL_REF, CONST, LABEL_REF}}, \
1557 {"aligned_memory_operand", {MEM}}, \
1558 {"unaligned_memory_operand", {MEM}}, \
1559 {"any_memory_operand", {MEM}},
This page took 0.111412 seconds and 5 git commands to generate.