]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/gcc/config/alpha/alpha.h
This commit was generated by cvs2svn to compensate for changes in r51292,
[FreeBSD/FreeBSD.git] / contrib / gcc / config / alpha / alpha.h
1 /* Definitions of target machine for GNU compiler, for DEC Alpha.
2    Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
3    Contributed by Richard Kenner (kenner@vlsi1.ultra.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, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22
23 /* Write out the correct language type definition for the header files.  
24    Unless we have assembler language, write out the symbols for C.  */
25 #define CPP_SPEC "\
26 %{!undef:\
27 %{.S:-D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY }}\
28 %{.cc|.cxx|.C:-D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus }\
29 %{.m:-D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C }\
30 %{!.S:%{!.cc:%{!.cxx:%{!.C:%{!.m:-D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C }}}}}}\
31 %{mieee:-D_IEEE_FP }\
32 %{mieee-with-inexact:-D_IEEE_FP -D_IEEE_FP_INEXACT }}\
33 %(cpp_cpu) %(cpp_subtarget)"
34
35 #ifndef CPP_SUBTARGET_SPEC
36 #define CPP_SUBTARGET_SPEC ""
37 #endif
38
39 /* Set the spec to use for signed char.  The default tests the above macro
40    but DEC's compiler can't handle the conditional in a "constant"
41    operand.  */
42
43 #define SIGNED_CHAR_SPEC "%{funsigned-char:-D__CHAR_UNSIGNED__}"
44
45 #define WORD_SWITCH_TAKES_ARG(STR)              \
46  (!strcmp (STR, "rpath") || !strcmp (STR, "include")    \
47   || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
48   || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
49   || !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
50   || !strcmp (STR, "isystem"))
51
52 /* Print subsidiary information on the compiler version in use.  */
53 #define TARGET_VERSION
54
55 /* Run-time compilation parameters selecting different hardware subsets.  */
56
57 /* Which processor to schedule for. The cpu attribute defines a list that
58    mirrors this list, so changes to alpha.md must be made at the same time.  */
59
60 enum processor_type
61  {PROCESSOR_EV4,                        /* 2106[46]{a,} */
62   PROCESSOR_EV5,                        /* 21164{a,pc,} */
63   PROCESSOR_EV6};                       /* 21264 */
64
65 extern enum processor_type alpha_cpu;
66
67 enum alpha_trap_precision
68 {
69   ALPHA_TP_PROG,        /* No precision (default).  */
70   ALPHA_TP_FUNC,        /* Trap contained within originating function.  */
71   ALPHA_TP_INSN         /* Instruction accuracy and code is resumption safe. */
72 };
73
74 enum alpha_fp_rounding_mode
75 {
76   ALPHA_FPRM_NORM,      /* Normal rounding mode.  */
77   ALPHA_FPRM_MINF,      /* Round towards minus-infinity.  */
78   ALPHA_FPRM_CHOP,      /* Chopped rounding mode (towards 0). */
79   ALPHA_FPRM_DYN        /* Dynamic rounding mode.  */
80 };
81
82 enum alpha_fp_trap_mode
83 {
84   ALPHA_FPTM_N,         /* Normal trap mode. */
85   ALPHA_FPTM_U,         /* Underflow traps enabled.  */
86   ALPHA_FPTM_SU,        /* Software completion, w/underflow traps */
87   ALPHA_FPTM_SUI        /* Software completion, w/underflow & inexact traps */
88 };
89
90 extern int target_flags;
91
92 extern enum alpha_trap_precision alpha_tp;
93 extern enum alpha_fp_rounding_mode alpha_fprm;
94 extern enum alpha_fp_trap_mode alpha_fptm;
95
96 /* This means that floating-point support exists in the target implementation
97    of the Alpha architecture.  This is usually the default.  */
98
99 #define MASK_FP         1
100 #define TARGET_FP       (target_flags & MASK_FP)
101
102 /* This means that floating-point registers are allowed to be used.  Note
103    that Alpha implementations without FP operations are required to
104    provide the FP registers.  */
105
106 #define MASK_FPREGS     2
107 #define TARGET_FPREGS   (target_flags & MASK_FPREGS)
108
109 /* This means that gas is used to process the assembler file.  */
110
111 #define MASK_GAS 4
112 #define TARGET_GAS      (target_flags & MASK_GAS)
113
114 /* This means that we should mark procedures as IEEE conformant. */
115
116 #define MASK_IEEE_CONFORMANT 8
117 #define TARGET_IEEE_CONFORMANT  (target_flags & MASK_IEEE_CONFORMANT)
118
119 /* This means we should be IEEE-compliant except for inexact.  */
120
121 #define MASK_IEEE       16
122 #define TARGET_IEEE     (target_flags & MASK_IEEE)
123
124 /* This means we should be fully IEEE-compliant.  */
125
126 #define MASK_IEEE_WITH_INEXACT 32
127 #define TARGET_IEEE_WITH_INEXACT (target_flags & MASK_IEEE_WITH_INEXACT)
128
129 /* This means we must construct all constants rather than emitting
130    them as literal data.  */
131
132 #define MASK_BUILD_CONSTANTS 128
133 #define TARGET_BUILD_CONSTANTS (target_flags & MASK_BUILD_CONSTANTS)
134
135 /* This means we handle floating points in VAX F- (float)
136    or G- (double) Format.  */
137
138 #define MASK_FLOAT_VAX 512
139 #define TARGET_FLOAT_VAX (target_flags & MASK_FLOAT_VAX)
140
141 /* This means that the processor has byte and half word loads and stores
142    (the BWX extension).  */
143
144 #define MASK_BWX 1024
145 #define TARGET_BWX      (target_flags & MASK_BWX)
146
147 /* This means that the processor has the CIX extension.  */
148 #define MASK_CIX 2048
149 #define TARGET_CIX      (target_flags & MASK_CIX)
150
151 /* This means that the processor has the MAX extension.  */
152 #define MASK_MAX 4096
153 #define TARGET_MAX      (target_flags & MASK_MAX)
154
155 /* This means that the processor is an EV5, EV56, or PCA56.  This is defined
156    only in TARGET_CPU_DEFAULT.  */
157 #define MASK_CPU_EV5 8192
158
159 /* Likewise for EV6.  */
160 #define MASK_CPU_EV6 16384
161
162 /* This means we support the .arch directive in the assembler.  Only
163    defined in TARGET_CPU_DEFAULT.  */
164 #define MASK_SUPPORT_ARCH 32768
165 #define TARGET_SUPPORT_ARCH     (target_flags & MASK_SUPPORT_ARCH)
166
167 /* These are for target os support and cannot be changed at runtime.  */
168 #ifndef TARGET_WINDOWS_NT
169 #define TARGET_WINDOWS_NT 0
170 #endif
171 #ifndef TARGET_OPEN_VMS
172 #define TARGET_OPEN_VMS 0
173 #endif
174
175 #ifndef TARGET_AS_CAN_SUBTRACT_LABELS
176 #define TARGET_AS_CAN_SUBTRACT_LABELS TARGET_GAS
177 #endif
178 #ifndef TARGET_CAN_FAULT_IN_PROLOGUE
179 #define TARGET_CAN_FAULT_IN_PROLOGUE 0
180 #endif
181
182 /* Macro to define tables used to set the flags.
183    This is a list in braces of pairs in braces,
184    each pair being { "NAME", VALUE }
185    where VALUE is the bits to set or minus the bits to clear.
186    An empty string NAME is used to identify the default VALUE.  */
187
188 #define TARGET_SWITCHES                         \
189   { {"no-soft-float", MASK_FP},                 \
190     {"soft-float", - MASK_FP},                  \
191     {"fp-regs", MASK_FPREGS},                   \
192     {"no-fp-regs", - (MASK_FP|MASK_FPREGS)},    \
193     {"alpha-as", -MASK_GAS},                    \
194     {"gas", MASK_GAS},                          \
195     {"ieee-conformant", MASK_IEEE_CONFORMANT},  \
196     {"ieee", MASK_IEEE|MASK_IEEE_CONFORMANT},   \
197     {"ieee-with-inexact", MASK_IEEE_WITH_INEXACT|MASK_IEEE_CONFORMANT}, \
198     {"build-constants", MASK_BUILD_CONSTANTS},  \
199     {"float-vax", MASK_FLOAT_VAX},              \
200     {"float-ieee", -MASK_FLOAT_VAX},            \
201     {"bwx", MASK_BWX},                          \
202     {"no-bwx", -MASK_BWX},                      \
203     {"cix", MASK_CIX},                          \
204     {"no-cix", -MASK_CIX},                      \
205     {"max", MASK_MAX},                          \
206     {"no-max", -MASK_MAX},                      \
207     {"", TARGET_DEFAULT | TARGET_CPU_DEFAULT} }
208
209 #define TARGET_DEFAULT MASK_FP|MASK_FPREGS
210
211 #ifndef TARGET_CPU_DEFAULT
212 #define TARGET_CPU_DEFAULT 0
213 #endif
214
215 /* This macro is similar to `TARGET_SWITCHES' but defines names of
216    command options that have values.  Its definition is an initializer
217    with a subgrouping for each command option.
218
219    Each subgrouping contains a string constant, that defines the fixed
220    part of the option name, and the address of a variable.  The
221    variable, type `char *', is set to the variable part of the given
222    option if the fixed part matches.  The actual option name is made
223    by appending `-m' to the specified name.
224
225    Here is an example which defines `-mshort-data-NUMBER'.  If the
226    given option is `-mshort-data-512', the variable `m88k_short_data'
227    will be set to the string `"512"'.
228
229         extern char *m88k_short_data;
230         #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } }  */
231
232 extern char *alpha_cpu_string;  /* For -mcpu= */
233 extern char *alpha_fprm_string; /* For -mfp-rounding-mode=[n|m|c|d] */
234 extern char *alpha_fptm_string; /* For -mfp-trap-mode=[n|u|su|sui]  */
235 extern char *alpha_tp_string;   /* For -mtrap-precision=[p|f|i] */
236 extern char *alpha_mlat_string; /* For -mmemory-latency= */
237
238 #define TARGET_OPTIONS                          \
239 {                                               \
240   {"cpu=",              &alpha_cpu_string},     \
241   {"fp-rounding-mode=", &alpha_fprm_string},    \
242   {"fp-trap-mode=",     &alpha_fptm_string},    \
243   {"trap-precision=",   &alpha_tp_string},      \
244   {"memory-latency=",   &alpha_mlat_string},    \
245 }
246
247 /* Attempt to describe CPU characteristics to the preprocessor.  */
248
249 /* Corresponding to amask... */
250 #define CPP_AM_BWX_SPEC "-D__alpha_bwx__ -Acpu(bwx)"
251 #define CPP_AM_MAX_SPEC "-D__alpha_max__ -Acpu(max)"
252 #define CPP_AM_CIX_SPEC "-D__alpha_cix__ -Acpu(cix)"
253
254 /* Corresponding to implver... */
255 #define CPP_IM_EV4_SPEC "-D__alpha_ev4__ -Acpu(ev4)"
256 #define CPP_IM_EV5_SPEC "-D__alpha_ev5__ -Acpu(ev5)"
257 #define CPP_IM_EV6_SPEC "-D__alpha_ev6__ -Acpu(ev6)"
258
259 /* Common combinations.  */
260 #define CPP_CPU_EV4_SPEC        "%(cpp_im_ev4)"
261 #define CPP_CPU_EV5_SPEC        "%(cpp_im_ev5)"
262 #define CPP_CPU_EV56_SPEC       "%(cpp_im_ev5) %(cpp_am_bwx)"
263 #define CPP_CPU_PCA56_SPEC      "%(cpp_im_ev5) %(cpp_am_bwx) %(cpp_am_max)"
264 #define CPP_CPU_EV6_SPEC        "%(cpp_im_ev6) %(cpp_am_bwx) %(cpp_am_max) %(cpp_am_cix)"
265
266 #ifndef CPP_CPU_DEFAULT_SPEC
267 # if TARGET_CPU_DEFAULT & MASK_CPU_EV6
268 #  define CPP_CPU_DEFAULT_SPEC          CPP_CPU_EV6_SPEC
269 # else
270 #  if TARGET_CPU_DEFAULT & MASK_CPU_EV5
271 #   if TARGET_CPU_DEFAULT & MASK_MAX
272 #    define CPP_CPU_DEFAULT_SPEC        CPP_CPU_PCA56_SPEC
273 #   else
274 #    if TARGET_CPU_DEFAULT & MASK_BWX
275 #     define CPP_CPU_DEFAULT_SPEC       CPP_CPU_EV56_SPEC
276 #    else
277 #     define CPP_CPU_DEFAULT_SPEC       CPP_CPU_EV5_SPEC
278 #    endif
279 #   endif
280 #  else
281 #   define CPP_CPU_DEFAULT_SPEC         CPP_CPU_EV4_SPEC
282 #  endif
283 # endif
284 #endif /* CPP_CPU_DEFAULT_SPEC */
285
286 #ifndef CPP_CPU_SPEC
287 #define CPP_CPU_SPEC "\
288 %{!undef:-Acpu(alpha) -Amachine(alpha) -D__alpha -D__alpha__ \
289 %{mcpu=ev4|mcpu=21064:%(cpp_cpu_ev4) }\
290 %{mcpu=ev5|mcpu=21164:%(cpp_cpu_ev5) }\
291 %{mcpu=ev56|mcpu=21164a:%(cpp_cpu_ev56) }\
292 %{mcpu=pca56|mcpu=21164pc|mcpu=21164PC:%(cpp_cpu_pca56) }\
293 %{mcpu=ev6|mcpu=21264:%(cpp_cpu_ev6) }\
294 %{!mcpu*:%(cpp_cpu_default) }}"
295 #endif
296
297 /* This macro defines names of additional specifications to put in the
298    specs that can be used in various specifications like CC1_SPEC.  Its
299    definition is an initializer with a subgrouping for each command option.
300
301    Each subgrouping contains a string constant, that defines the
302    specification name, and a string constant that used by the GNU CC driver
303    program.
304
305    Do not define this macro if it does not need to do anything.  */
306
307 #ifndef SUBTARGET_EXTRA_SPECS
308 #define SUBTARGET_EXTRA_SPECS
309 #endif
310
311 #define EXTRA_SPECS                             \
312   { "cpp_am_bwx", CPP_AM_BWX_SPEC },            \
313   { "cpp_am_max", CPP_AM_MAX_SPEC },            \
314   { "cpp_am_cix", CPP_AM_CIX_SPEC },            \
315   { "cpp_im_ev4", CPP_IM_EV4_SPEC },            \
316   { "cpp_im_ev5", CPP_IM_EV5_SPEC },            \
317   { "cpp_im_ev6", CPP_IM_EV6_SPEC },            \
318   { "cpp_cpu_ev4", CPP_CPU_EV4_SPEC },          \
319   { "cpp_cpu_ev5", CPP_CPU_EV5_SPEC },          \
320   { "cpp_cpu_ev56", CPP_CPU_EV56_SPEC },        \
321   { "cpp_cpu_pca56", CPP_CPU_PCA56_SPEC },      \
322   { "cpp_cpu_ev6", CPP_CPU_EV6_SPEC },          \
323   { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC },  \
324   { "cpp_cpu", CPP_CPU_SPEC },                  \
325   { "cpp_subtarget", CPP_SUBTARGET_SPEC },      \
326   SUBTARGET_EXTRA_SPECS
327
328
329 /* Sometimes certain combinations of command options do not make sense
330    on a particular target machine.  You can define a macro
331    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
332    defined, is executed once just after all the command options have
333    been parsed.
334
335    On the Alpha, it is used to translate target-option strings into
336    numeric values.  */
337
338 extern void override_options ();
339 #define OVERRIDE_OPTIONS override_options ()
340
341
342 /* Define this macro to change register usage conditional on target flags.
343
344    On the Alpha, we use this to disable the floating-point registers when
345    they don't exist.  */
346
347 #define CONDITIONAL_REGISTER_USAGE      \
348   if (! TARGET_FPREGS)                  \
349     for (i = 32; i < 63; i++)           \
350       fixed_regs[i] = call_used_regs[i] = 1;
351
352 /* Show we can debug even without a frame pointer.  */
353 #define CAN_DEBUG_WITHOUT_FP
354 \f
355 /* target machine storage layout */
356
357 /* Define to enable software floating point emulation. */
358 #define REAL_ARITHMETIC
359
360 /* The following #defines are used when compiling the routines in
361    libgcc1.c.  Since the Alpha calling conventions require single
362    precision floats to be passed in the floating-point registers
363    (rather than in the general registers) we have to build the
364    libgcc1.c routines in such a way that they know the actual types
365    of their formal arguments and the actual types of their return
366    values.  Otherwise, gcc will generate calls to the libgcc1.c
367    routines, passing arguments in the floating-point registers,
368    but the libgcc1.c routines will expect their arguments on the
369    stack (where the Alpha calling conventions require structs &
370    unions to be passed).  */
371
372 #define FLOAT_VALUE_TYPE        double
373 #define INTIFY(FLOATVAL)        (FLOATVAL)
374 #define FLOATIFY(INTVAL)        (INTVAL)
375 #define FLOAT_ARG_TYPE          double
376
377 /* Define the size of `int'.  The default is the same as the word size.  */
378 #define INT_TYPE_SIZE 32
379
380 /* Define the size of `long long'.  The default is the twice the word size.  */
381 #define LONG_LONG_TYPE_SIZE 64
382
383 /* The two floating-point formats we support are S-floating, which is
384    4 bytes, and T-floating, which is 8 bytes.  `float' is S and `double'
385    and `long double' are T.  */
386
387 #define FLOAT_TYPE_SIZE 32
388 #define DOUBLE_TYPE_SIZE 64
389 #define LONG_DOUBLE_TYPE_SIZE 64
390
391 #define WCHAR_TYPE "unsigned int"
392 #define WCHAR_TYPE_SIZE 32
393
394 /* Define this macro if it is advisable to hold scalars in registers
395    in a wider mode than that declared by the program.  In such cases, 
396    the value is constrained to be within the bounds of the declared
397    type, but kept valid in the wider mode.  The signedness of the
398    extension may differ from that of the type.
399
400    For Alpha, we always store objects in a full register.  32-bit objects
401    are always sign-extended, but smaller objects retain their signedness.  */
402
403 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)  \
404   if (GET_MODE_CLASS (MODE) == MODE_INT         \
405       && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
406     {                                           \
407       if ((MODE) == SImode)                     \
408         (UNSIGNEDP) = 0;                        \
409       (MODE) = DImode;                          \
410     }
411
412 /* Define this if function arguments should also be promoted using the above
413    procedure.  */
414
415 #define PROMOTE_FUNCTION_ARGS
416
417 /* Likewise, if the function return value is promoted.  */
418
419 #define PROMOTE_FUNCTION_RETURN
420
421 /* Define this if most significant bit is lowest numbered
422    in instructions that operate on numbered bit-fields.
423
424    There are no such instructions on the Alpha, but the documentation
425    is little endian.  */
426 #define BITS_BIG_ENDIAN 0
427
428 /* Define this if most significant byte of a word is the lowest numbered.
429    This is false on the Alpha.  */
430 #define BYTES_BIG_ENDIAN 0
431
432 /* Define this if most significant word of a multiword number is lowest
433    numbered.
434
435    For Alpha we can decide arbitrarily since there are no machine instructions
436    for them.  Might as well be consistent with bytes. */
437 #define WORDS_BIG_ENDIAN 0
438
439 /* number of bits in an addressable storage unit */
440 #define BITS_PER_UNIT 8
441
442 /* Width in bits of a "word", which is the contents of a machine register.
443    Note that this is not necessarily the width of data type `int';
444    if using 16-bit ints on a 68000, this would still be 32.
445    But on a machine with 16-bit registers, this would be 16.  */
446 #define BITS_PER_WORD 64
447
448 /* Width of a word, in units (bytes).  */
449 #define UNITS_PER_WORD 8
450
451 /* Width in bits of a pointer.
452    See also the macro `Pmode' defined below.  */
453 #define POINTER_SIZE 64
454
455 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
456 #define PARM_BOUNDARY 64
457
458 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
459 #define STACK_BOUNDARY 64
460
461 /* Allocation boundary (in *bits*) for the code of a function.  */
462 #define FUNCTION_BOUNDARY 256
463
464 /* Alignment of field after `int : 0' in a structure.  */
465 #define EMPTY_FIELD_BOUNDARY 64
466
467 /* Every structure's size must be a multiple of this.  */
468 #define STRUCTURE_SIZE_BOUNDARY 8
469
470 /* A bitfield declared as `int' forces `int' alignment for the struct.  */
471 #define PCC_BITFIELD_TYPE_MATTERS 1
472
473 /* Align loop starts for optimal branching.  
474
475    ??? Kludge this and the next macro for the moment by not doing anything if
476    we don't optimize and also if we are writing ECOFF symbols to work around
477    a bug in DEC's assembler. */
478
479 #define LOOP_ALIGN(LABEL) \
480   (optimize > 0 && write_symbols != SDB_DEBUG ? 4 : 0)
481
482 /* This is how to align an instruction for optimal branching.  On
483    Alpha we'll get better performance by aligning on an octaword
484    boundary.  */
485
486 #define ALIGN_LABEL_AFTER_BARRIER(FILE) \
487   (optimize > 0 && write_symbols != SDB_DEBUG ? 4 : 0)
488
489 /* No data type wants to be aligned rounder than this.  */
490 #define BIGGEST_ALIGNMENT 64
491
492 /* For atomic access to objects, must have at least 32-bit alignment
493    unless the machine has byte operations.  */
494 #define MINIMUM_ATOMIC_ALIGNMENT (TARGET_BWX ? 8 : 32)
495
496 /* Align all constants and variables to at least a word boundary so
497    we can pick up pieces of them faster.  */
498 /* ??? Only if block-move stuff knows about different source/destination
499    alignment.  */
500 #if 0
501 #define CONSTANT_ALIGNMENT(EXP, ALIGN) MAX ((ALIGN), BITS_PER_WORD)
502 #define DATA_ALIGNMENT(EXP, ALIGN) MAX ((ALIGN), BITS_PER_WORD)
503 #endif
504
505 /* Set this non-zero if move instructions will actually fail to work
506    when given unaligned data.
507
508    Since we get an error message when we do one, call them invalid.  */
509
510 #define STRICT_ALIGNMENT 1
511
512 /* Set this non-zero if unaligned move instructions are extremely slow.
513
514    On the Alpha, they trap.  */
515
516 #define SLOW_UNALIGNED_ACCESS 1
517 \f
518 /* Standard register usage.  */
519
520 /* Number of actual hardware registers.
521    The hardware registers are assigned numbers for the compiler
522    from 0 to just below FIRST_PSEUDO_REGISTER.
523    All registers that the compiler knows about must be given numbers,
524    even those that are not normally considered general registers.
525
526    We define all 32 integer registers, even though $31 is always zero,
527    and all 32 floating-point registers, even though $f31 is also
528    always zero.  We do not bother defining the FP status register and
529    there are no other registers. 
530
531    Since $31 is always zero, we will use register number 31 as the
532    argument pointer.  It will never appear in the generated code
533    because we will always be eliminating it in favor of the stack
534    pointer or hardware frame pointer.
535
536    Likewise, we use $f31 for the frame pointer, which will always
537    be eliminated in favor of the hardware frame pointer or the
538    stack pointer.  */
539
540 #define FIRST_PSEUDO_REGISTER 64
541
542 /* 1 for registers that have pervasive standard uses
543    and are not available for the register allocator.  */
544
545 #define FIXED_REGISTERS  \
546  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
547   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, \
548   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
549   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
550
551 /* 1 for registers not available across function calls.
552    These must include the FIXED_REGISTERS and also any
553    registers that can be used without being saved.
554    The latter must include the registers where values are returned
555    and the register where structure-value addresses are passed.
556    Aside from that, you can include as many other registers as you like.  */
557 #define CALL_USED_REGISTERS  \
558  {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, \
559   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, \
560   1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, \
561   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
562
563 /* List the order in which to allocate registers.  Each register must be
564    listed once, even those in FIXED_REGISTERS.
565
566    We allocate in the following order:
567    $f10-$f15            (nonsaved floating-point register)
568    $f22-$f30            (likewise)
569    $f21-$f16            (likewise, but input args)
570    $f0                  (nonsaved, but return value)
571    $f1                  (nonsaved, but immediate before saved)
572    $f2-$f9              (saved floating-point registers)
573    $1-$8                (nonsaved integer registers)
574    $22-$25              (likewise)
575    $28                  (likewise)
576    $0                   (likewise, but return value)
577    $21-$16              (likewise, but input args)
578    $27                  (procedure value in OSF, nonsaved in NT)
579    $9-$14               (saved integer registers)
580    $26                  (return PC)
581    $15                  (frame pointer)
582    $29                  (global pointer)
583    $30, $31, $f31       (stack pointer and always zero/ap & fp)  */
584
585 #define REG_ALLOC_ORDER         \
586   {42, 43, 44, 45, 46, 47,              \
587    54, 55, 56, 57, 58, 59, 60, 61, 62,  \
588    53, 52, 51, 50, 49, 48,              \
589    32, 33,                              \
590    34, 35, 36, 37, 38, 39, 40, 41,      \
591    1, 2, 3, 4, 5, 6, 7, 8,              \
592    22, 23, 24, 25,                      \
593    28,                                  \
594    0,                                   \
595    21, 20, 19, 18, 17, 16,              \
596    27,                                  \
597    9, 10, 11, 12, 13, 14,               \
598    26,                                  \
599    15,                                  \
600    29,                                  \
601    30, 31, 63 }
602
603 /* Return number of consecutive hard regs needed starting at reg REGNO
604    to hold something of mode MODE.
605    This is ordinarily the length in words of a value of mode MODE
606    but can be less for certain modes in special long registers.  */
607
608 #define HARD_REGNO_NREGS(REGNO, MODE)   \
609   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
610
611 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
612    On Alpha, the integer registers can hold any mode.  The floating-point
613    registers can hold 32-bit and 64-bit integers as well, but not 16-bit
614    or 8-bit values.  */
615
616 #define HARD_REGNO_MODE_OK(REGNO, MODE)                         \
617   ((REGNO) < 32 || ((MODE) != QImode && (MODE) != HImode))
618
619 /* Value is 1 if it is a good idea to tie two pseudo registers
620    when one has mode MODE1 and one has mode MODE2.
621    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
622    for any hard reg, then this must be 0 for correct output.  */
623
624 #define MODES_TIEABLE_P(MODE1, MODE2)                           \
625   ((MODE1) == QImode || (MODE1) == HImode                       \
626    ? (MODE2) == QImode || (MODE2) == HImode                     \
627    : 1)
628
629 /* Specify the registers used for certain standard purposes.
630    The values of these macros are register numbers.  */
631
632 /* Alpha pc isn't overloaded on a register that the compiler knows about.  */
633 /* #define PC_REGNUM  */
634
635 /* Register to use for pushing function arguments.  */
636 #define STACK_POINTER_REGNUM 30
637
638 /* Base register for access to local variables of the function.  */
639 #define HARD_FRAME_POINTER_REGNUM 15
640
641 /* Value should be nonzero if functions must have frame pointers.
642    Zero means the frame pointer need not be set up (and parms
643    may be accessed via the stack pointer) in functions that seem suitable.
644    This is computed in `reload', in reload1.c.  */
645 #define FRAME_POINTER_REQUIRED 0
646
647 /* Base register for access to arguments of the function.  */
648 #define ARG_POINTER_REGNUM 31
649
650 /* Base register for access to local variables of function.  */
651 #define FRAME_POINTER_REGNUM 63
652
653 /* Register in which static-chain is passed to a function. 
654
655    For the Alpha, this is based on an example; the calling sequence
656    doesn't seem to specify this.  */
657 #define STATIC_CHAIN_REGNUM 1
658
659 /* Register in which address to store a structure value
660    arrives in the function.  On the Alpha, the address is passed
661    as a hidden argument.  */
662 #define STRUCT_VALUE 0
663 \f
664 /* Define the classes of registers for register constraints in the
665    machine description.  Also define ranges of constants.
666
667    One of the classes must always be named ALL_REGS and include all hard regs.
668    If there is more than one class, another class must be named NO_REGS
669    and contain no registers.
670
671    The name GENERAL_REGS must be the name of a class (or an alias for
672    another name such as ALL_REGS).  This is the class of registers
673    that is allowed by "g" or "r" in a register constraint.
674    Also, registers outside this class are allocated only when
675    instructions express preferences for them.
676
677    The classes must be numbered in nondecreasing order; that is,
678    a larger-numbered class must never be contained completely
679    in a smaller-numbered class.
680
681    For any two classes, it is very desirable that there be another
682    class that represents their union.  */
683    
684 enum reg_class { NO_REGS, GENERAL_REGS, FLOAT_REGS, ALL_REGS,
685                  LIM_REG_CLASSES };
686
687 #define N_REG_CLASSES (int) LIM_REG_CLASSES
688
689 /* Give names of register classes as strings for dump file.   */
690
691 #define REG_CLASS_NAMES                         \
692  {"NO_REGS", "GENERAL_REGS", "FLOAT_REGS", "ALL_REGS" }
693
694 /* Define which registers fit in which classes.
695    This is an initializer for a vector of HARD_REG_SET
696    of length N_REG_CLASSES.  */
697
698 #define REG_CLASS_CONTENTS      \
699   { {0, 0}, {~0, 0x80000000}, {0, 0x7fffffff}, {~0, ~0} }
700
701 /* The same information, inverted:
702    Return the class number of the smallest class containing
703    reg number REGNO.  This could be a conditional expression
704    or could index an array.  */
705
706 #define REGNO_REG_CLASS(REGNO) \
707  ((REGNO) >= 32 && (REGNO) <= 62 ? FLOAT_REGS : GENERAL_REGS)
708
709 /* The class value for index registers, and the one for base regs.  */
710 #define INDEX_REG_CLASS NO_REGS
711 #define BASE_REG_CLASS GENERAL_REGS
712
713 /* Get reg_class from a letter such as appears in the machine description.  */
714
715 #define REG_CLASS_FROM_LETTER(C)        \
716  ((C) == 'f' ? FLOAT_REGS : NO_REGS)
717
718 /* Define this macro to change register usage conditional on target flags.  */
719 /* #define CONDITIONAL_REGISTER_USAGE  */
720
721 /* The letters I, J, K, L, M, N, O, and P in a register constraint string
722    can be used to stand for particular ranges of immediate operands.
723    This macro defines what the ranges are.
724    C is the letter, and VALUE is a constant value.
725    Return 1 if VALUE is in the range specified by C.
726
727    For Alpha:
728    `I' is used for the range of constants most insns can contain.
729    `J' is the constant zero.
730    `K' is used for the constant in an LDA insn.
731    `L' is used for the constant in a LDAH insn.
732    `M' is used for the constants that can be AND'ed with using a ZAP insn.
733    `N' is used for complemented 8-bit constants.
734    `O' is used for negated 8-bit constants.
735    `P' is used for the constants 1, 2 and 3.  */
736
737 #define CONST_OK_FOR_LETTER_P(VALUE, C)                         \
738   ((C) == 'I' ? (unsigned HOST_WIDE_INT) (VALUE) < 0x100        \
739    : (C) == 'J' ? (VALUE) == 0                                  \
740    : (C) == 'K' ? (unsigned HOST_WIDE_INT) ((VALUE) + 0x8000) < 0x10000 \
741    : (C) == 'L' ? (((VALUE) & 0xffff) == 0                      \
742                   && (((VALUE)) >> 31 == -1 || (VALUE) >> 31 == 0)) \
743    : (C) == 'M' ? zap_mask (VALUE)                              \
744    : (C) == 'N' ? (unsigned HOST_WIDE_INT) (~ (VALUE)) < 0x100  \
745    : (C) == 'O' ? (unsigned HOST_WIDE_INT) (- (VALUE)) < 0x100  \
746    : (C) == 'P' ? (VALUE) == 1 || (VALUE) == 2 || (VALUE) == 3  \
747    : 0)
748
749 /* Similar, but for floating or large integer constants, and defining letters
750    G and H.   Here VALUE is the CONST_DOUBLE rtx itself.
751
752    For Alpha, `G' is the floating-point constant zero.  `H' is a CONST_DOUBLE
753    that is the operand of a ZAP insn.  */
754
755 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)                          \
756   ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT        \
757                  && (VALUE) == CONST0_RTX (GET_MODE (VALUE)))           \
758    : (C) == 'H' ? (GET_MODE (VALUE) == VOIDmode                         \
759                    && zap_mask (CONST_DOUBLE_LOW (VALUE))               \
760                    && zap_mask (CONST_DOUBLE_HIGH (VALUE)))             \
761    : 0)
762
763 /* Optional extra constraints for this machine.
764
765    For the Alpha, `Q' means that this is a memory operand but not a
766    reference to an unaligned location.
767
768    `R' is a SYMBOL_REF that has SYMBOL_REF_FLAG set or is the current
769    function.
770
771    'S' is a 6-bit constant (valid for a shift insn).  */
772
773 #define EXTRA_CONSTRAINT(OP, C)                         \
774   ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) != AND  \
775    : (C) == 'R' ? current_file_function_operand (OP, Pmode)             \
776    : (C) == 'S' ? (GET_CODE (OP) == CONST_INT                           \
777                    && (unsigned HOST_WIDE_INT) INTVAL (OP) < 64)        \
778    : 0)
779
780 /* Given an rtx X being reloaded into a reg required to be
781    in class CLASS, return the class of reg to actually use.
782    In general this is just CLASS; but on some machines
783    in some cases it is preferable to use a more restrictive class.
784
785    On the Alpha, all constants except zero go into a floating-point
786    register via memory.  */
787
788 #define PREFERRED_RELOAD_CLASS(X, CLASS)                \
789   (CONSTANT_P (X) && (X) != const0_rtx && (X) != CONST0_RTX (GET_MODE (X)) \
790    ? ((CLASS) == FLOAT_REGS || (CLASS) == NO_REGS ? NO_REGS : GENERAL_REGS)\
791    : (CLASS))
792
793 /* Loading and storing HImode or QImode values to and from memory
794    usually requires a scratch register.  The exceptions are loading
795    QImode and HImode from an aligned address to a general register
796    unless byte instructions are permitted.
797    We also cannot load an unaligned address or a paradoxical SUBREG into an
798    FP register.   */
799
800 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,IN)                     \
801 (((GET_CODE (IN) == MEM                                                 \
802    || (GET_CODE (IN) == REG && REGNO (IN) >= FIRST_PSEUDO_REGISTER)     \
803    || (GET_CODE (IN) == SUBREG                                          \
804        && (GET_CODE (SUBREG_REG (IN)) == MEM                            \
805            || (GET_CODE (SUBREG_REG (IN)) == REG                        \
806                && REGNO (SUBREG_REG (IN)) >= FIRST_PSEUDO_REGISTER))))  \
807   && (((CLASS) == FLOAT_REGS                                            \
808        && ((MODE) == SImode || (MODE) == HImode || (MODE) == QImode))   \
809       || (((MODE) == QImode || (MODE) == HImode)                        \
810           && ! TARGET_BWX && unaligned_memory_operand (IN, MODE)))) \
811  ? GENERAL_REGS                                                         \
812  : ((CLASS) == FLOAT_REGS && GET_CODE (IN) == MEM                       \
813     && GET_CODE (XEXP (IN, 0)) == AND) ? GENERAL_REGS                   \
814  : ((CLASS) == FLOAT_REGS && GET_CODE (IN) == SUBREG                    \
815     && (GET_MODE_SIZE (GET_MODE (IN))                                   \
816         > GET_MODE_SIZE (GET_MODE (SUBREG_REG (IN))))) ? GENERAL_REGS   \
817  : NO_REGS)
818
819 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,OUT)                   \
820 (((GET_CODE (OUT) == MEM                                                \
821    || (GET_CODE (OUT) == REG && REGNO (OUT) >= FIRST_PSEUDO_REGISTER)   \
822    || (GET_CODE (OUT) == SUBREG                                         \
823        && (GET_CODE (SUBREG_REG (OUT)) == MEM                           \
824            || (GET_CODE (SUBREG_REG (OUT)) == REG                       \
825                && REGNO (SUBREG_REG (OUT)) >= FIRST_PSEUDO_REGISTER)))) \
826   && ((((MODE) == HImode || (MODE) == QImode)                           \
827        && (! TARGET_BWX || (CLASS) == FLOAT_REGS))                      \
828       || ((MODE) == SImode && (CLASS) == FLOAT_REGS)))                  \
829  ? GENERAL_REGS                                                         \
830  : ((CLASS) == FLOAT_REGS && GET_CODE (OUT) == MEM                      \
831     && GET_CODE (XEXP (OUT, 0)) == AND) ? GENERAL_REGS                  \
832  : ((CLASS) == FLOAT_REGS && GET_CODE (OUT) == SUBREG                   \
833     && (GET_MODE_SIZE (GET_MODE (OUT))                                  \
834         > GET_MODE_SIZE (GET_MODE (SUBREG_REG (OUT))))) ? GENERAL_REGS  \
835  : NO_REGS)
836
837 /* If we are copying between general and FP registers, we need a memory
838    location unless the CIX extension is available.  */
839
840 #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \
841  (! TARGET_CIX && (CLASS1) != (CLASS2))
842
843 /* Specify the mode to be used for memory when a secondary memory
844    location is needed.  If MODE is floating-point, use it.  Otherwise,
845    widen to a word like the default.  This is needed because we always
846    store integers in FP registers in quadword format.  This whole
847    area is very tricky! */
848 #define SECONDARY_MEMORY_NEEDED_MODE(MODE)              \
849   (GET_MODE_CLASS (MODE) == MODE_FLOAT ? (MODE)         \
850    : GET_MODE_SIZE (MODE) >= 4 ? (MODE)                 \
851    : mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (MODE), 0))
852
853 /* Return the maximum number of consecutive registers
854    needed to represent mode MODE in a register of class CLASS.  */
855
856 #define CLASS_MAX_NREGS(CLASS, MODE)                            \
857  ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
858
859 /* If defined, gives a class of registers that cannot be used as the
860    operand of a SUBREG that changes the size of the object.  */
861
862 #define CLASS_CANNOT_CHANGE_SIZE        FLOAT_REGS
863
864 /* Define the cost of moving between registers of various classes.  Moving
865    between FLOAT_REGS and anything else except float regs is expensive. 
866    In fact, we make it quite expensive because we really don't want to
867    do these moves unless it is clearly worth it.  Optimizations may
868    reduce the impact of not being able to allocate a pseudo to a
869    hard register.  */
870
871 #define REGISTER_MOVE_COST(CLASS1, CLASS2)              \
872   (((CLASS1) == FLOAT_REGS) == ((CLASS2) == FLOAT_REGS) \
873    ? 2                                                  \
874    : TARGET_CIX ? 3 : 4+2*alpha_memory_latency)
875
876 /* A C expressions returning the cost of moving data of MODE from a register to
877    or from memory.
878
879    On the Alpha, bump this up a bit.  */
880
881 extern int alpha_memory_latency;
882 #define MEMORY_MOVE_COST(MODE,CLASS,IN)  (2*alpha_memory_latency)
883
884 /* Provide the cost of a branch.  Exact meaning under development.  */
885 #define BRANCH_COST 5
886
887 /* Adjust the cost of dependencies.  */
888
889 #define ADJUST_COST(INSN,LINK,DEP,COST) \
890   (COST) = alpha_adjust_cost (INSN, LINK, DEP, COST)
891 \f
892 /* Stack layout; function entry, exit and calling.  */
893
894 /* Define this if pushing a word on the stack
895    makes the stack pointer a smaller address.  */
896 #define STACK_GROWS_DOWNWARD
897
898 /* Define this if the nominal address of the stack frame
899    is at the high-address end of the local variables;
900    that is, each additional local variable allocated
901    goes at a more negative offset in the frame.  */
902 /* #define FRAME_GROWS_DOWNWARD */
903
904 /* Offset within stack frame to start allocating local variables at.
905    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
906    first local allocated.  Otherwise, it is the offset to the BEGINNING
907    of the first local allocated.  */
908
909 #define STARTING_FRAME_OFFSET 0
910
911 /* If we generate an insn to push BYTES bytes,
912    this says how many the stack pointer really advances by.
913    On Alpha, don't define this because there are no push insns.  */
914 /*  #define PUSH_ROUNDING(BYTES) */
915
916 /* Define this to be nonzero if stack checking is built into the ABI.  */
917 #define STACK_CHECK_BUILTIN 1
918
919 /* Define this if the maximum size of all the outgoing args is to be
920    accumulated and pushed during the prologue.  The amount can be
921    found in the variable current_function_outgoing_args_size.  */
922 #define ACCUMULATE_OUTGOING_ARGS
923
924 /* Offset of first parameter from the argument pointer register value.  */
925
926 #define FIRST_PARM_OFFSET(FNDECL) 0
927
928 /* Definitions for register eliminations.
929
930    We have two registers that can be eliminated on the Alpha.  First, the
931    frame pointer register can often be eliminated in favor of the stack
932    pointer register.  Secondly, the argument pointer register can always be
933    eliminated; it is replaced with either the stack or frame pointer. */
934
935 /* This is an array of structures.  Each structure initializes one pair
936    of eliminable registers.  The "from" register number is given first,
937    followed by "to".  Eliminations of the same "from" register are listed
938    in order of preference.  */
939
940 #define ELIMINABLE_REGS                              \
941 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},        \
942  { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},   \
943  { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},      \
944  { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
945
946 /* Given FROM and TO register numbers, say whether this elimination is allowed.
947    Frame pointer elimination is automatically handled.
948
949    All eliminations are valid since the cases where FP can't be
950    eliminated are already handled.  */
951
952 #define CAN_ELIMINATE(FROM, TO) 1
953
954 /* Round up to a multiple of 16 bytes.  */
955 #define ALPHA_ROUND(X) (((X) + 15) & ~ 15)
956
957 /* Define the offset between two registers, one to be eliminated, and the other
958    its replacement, at the start of a routine.  */
959 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
960 { if ((FROM) == FRAME_POINTER_REGNUM)                                   \
961     (OFFSET) = (ALPHA_ROUND (current_function_outgoing_args_size)       \
962                 + alpha_sa_size ());                                    \
963   else if ((FROM) == ARG_POINTER_REGNUM)                                \
964     (OFFSET) = (ALPHA_ROUND (current_function_outgoing_args_size)       \
965                 + alpha_sa_size ()                                      \
966                 + (ALPHA_ROUND (get_frame_size ()                       \
967                                + current_function_pretend_args_size)    \
968                    - current_function_pretend_args_size));              \
969 }
970
971 /* Define this if stack space is still allocated for a parameter passed
972    in a register.  */
973 /* #define REG_PARM_STACK_SPACE */
974
975 /* Value is the number of bytes of arguments automatically
976    popped when returning from a subroutine call.
977    FUNDECL is the declaration node of the function (as a tree),
978    FUNTYPE is the data type of the function (as a tree),
979    or for a library call it is an identifier node for the subroutine name.
980    SIZE is the number of bytes of arguments passed on the stack.  */
981
982 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
983
984 /* Define how to find the value returned by a function.
985    VALTYPE is the data type of the value (as a tree).
986    If the precise function being called is known, FUNC is its FUNCTION_DECL;
987    otherwise, FUNC is 0.
988
989    On Alpha the value is found in $0 for integer functions and
990    $f0 for floating-point functions.  */
991
992 #define FUNCTION_VALUE(VALTYPE, FUNC)   \
993   gen_rtx (REG,                                                 \
994            ((INTEGRAL_TYPE_P (VALTYPE)                          \
995              && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD)       \
996             || POINTER_TYPE_P (VALTYPE))                        \
997            ? word_mode : TYPE_MODE (VALTYPE),                   \
998            ((TARGET_FPREGS                                      \
999              && (TREE_CODE (VALTYPE) == REAL_TYPE               \
1000                  || TREE_CODE (VALTYPE) == COMPLEX_TYPE))       \
1001             ? 32 : 0))
1002
1003 /* Define how to find the value returned by a library function
1004    assuming the value has mode MODE.  */
1005
1006 #define LIBCALL_VALUE(MODE)     \
1007    gen_rtx (REG, MODE,                                          \
1008             (TARGET_FPREGS                                      \
1009              && (GET_MODE_CLASS (MODE) == MODE_FLOAT            \
1010                  || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
1011              ? 32 : 0))
1012
1013 /* The definition of this macro implies that there are cases where
1014    a scalar value cannot be returned in registers.
1015
1016    For the Alpha, any structure or union type is returned in memory, as
1017    are integers whose size is larger than 64 bits.  */
1018
1019 #define RETURN_IN_MEMORY(TYPE) \
1020   (TYPE_MODE (TYPE) == BLKmode \
1021    || (TREE_CODE (TYPE) == INTEGER_TYPE && TYPE_PRECISION (TYPE) > 64))
1022
1023 /* 1 if N is a possible register number for a function value
1024    as seen by the caller.  */
1025
1026 #define FUNCTION_VALUE_REGNO_P(N)  \
1027   ((N) == 0 || (N) == 1 || (N) == 32 || (N) == 33)
1028
1029 /* 1 if N is a possible register number for function argument passing.
1030    On Alpha, these are $16-$21 and $f16-$f21.  */
1031
1032 #define FUNCTION_ARG_REGNO_P(N) \
1033   (((N) >= 16 && (N) <= 21) || ((N) >= 16 + 32 && (N) <= 21 + 32))
1034 \f
1035 /* Define a data type for recording info about an argument list
1036    during the scan of that argument list.  This data type should
1037    hold all necessary information about the function itself
1038    and about the args processed so far, enough to enable macros
1039    such as FUNCTION_ARG to determine where the next arg should go.
1040
1041    On Alpha, this is a single integer, which is a number of words
1042    of arguments scanned so far.
1043    Thus 6 or more means all following args should go on the stack.  */
1044
1045 #define CUMULATIVE_ARGS int
1046
1047 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1048    for a call to a function whose data type is FNTYPE.
1049    For a library call, FNTYPE is 0.  */
1050
1051 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT)  (CUM) = 0
1052
1053 /* Define intermediate macro to compute the size (in registers) of an argument
1054    for the Alpha.  */
1055
1056 #define ALPHA_ARG_SIZE(MODE, TYPE, NAMED)                               \
1057 ((MODE) != BLKmode                                                      \
1058  ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD       \
1059  : (int_size_in_bytes (TYPE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
1060
1061 /* Update the data in CUM to advance over an argument
1062    of mode MODE and data type TYPE.
1063    (TYPE is null for libcalls where that information may not be available.)  */
1064
1065 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                    \
1066   if (MUST_PASS_IN_STACK (MODE, TYPE))                                  \
1067     (CUM) = 6;                                                          \
1068   else                                                                  \
1069     (CUM) += ALPHA_ARG_SIZE (MODE, TYPE, NAMED)
1070
1071 /* Determine where to put an argument to a function.
1072    Value is zero to push the argument on the stack,
1073    or a hard register in which to store the argument.
1074
1075    MODE is the argument's machine mode.
1076    TYPE is the data type of the argument (as a tree).
1077     This is null for libcalls where that information may
1078     not be available.
1079    CUM is a variable of type CUMULATIVE_ARGS which gives info about
1080     the preceding args and about the function being called.
1081    NAMED is nonzero if this argument is a named parameter
1082     (otherwise it is an extra parameter matching an ellipsis).
1083
1084    On Alpha the first 6 words of args are normally in registers
1085    and the rest are pushed.  */
1086
1087 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)    \
1088 ((CUM) < 6 && ! MUST_PASS_IN_STACK (MODE, TYPE) \
1089  ? gen_rtx(REG, (MODE),                         \
1090            (CUM) + 16 + ((TARGET_FPREGS         \
1091                           && (GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT  \
1092                               || GET_MODE_CLASS (MODE) == MODE_FLOAT)) \
1093                          * 32))                 \
1094  : 0)
1095
1096 /* Specify the padding direction of arguments.
1097
1098    On the Alpha, we must pad upwards in order to be able to pass args in
1099    registers.  */
1100
1101 #define FUNCTION_ARG_PADDING(MODE, TYPE)        upward
1102
1103 /* For an arg passed partly in registers and partly in memory,
1104    this is the number of registers used.
1105    For args passed entirely in registers or entirely in memory, zero.  */
1106
1107 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED)      \
1108 ((CUM) < 6 && 6 < (CUM) + ALPHA_ARG_SIZE (MODE, TYPE, NAMED)    \
1109  ? 6 - (CUM) : 0)
1110
1111 /* Perform any needed actions needed for a function that is receiving a
1112    variable number of arguments. 
1113
1114    CUM is as above.
1115
1116    MODE and TYPE are the mode and type of the current parameter.
1117
1118    PRETEND_SIZE is a variable that should be set to the amount of stack
1119    that must be pushed by the prolog to pretend that our caller pushed
1120    it.
1121
1122    Normally, this macro will push all remaining incoming registers on the
1123    stack and set PRETEND_SIZE to the length of the registers pushed. 
1124
1125    On the Alpha, we allocate space for all 12 arg registers, but only
1126    push those that are remaining.
1127
1128    However, if NO registers need to be saved, don't allocate any space.
1129    This is not only because we won't need the space, but because AP includes
1130    the current_pretend_args_size and we don't want to mess up any
1131    ap-relative addresses already made.
1132
1133    If we are not to use the floating-point registers, save the integer
1134    registers where we would put the floating-point registers.  This is
1135    not the most efficient way to implement varargs with just one register
1136    class, but it isn't worth doing anything more efficient in this rare
1137    case.  */
1138    
1139
1140 #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)       \
1141 { if ((CUM) < 6)                                                        \
1142     {                                                                   \
1143       if (! (NO_RTL))                                                   \
1144         {                                                               \
1145           move_block_from_reg                                           \
1146             (16 + CUM,                                                  \
1147              gen_rtx (MEM, BLKmode,                                     \
1148                       plus_constant (virtual_incoming_args_rtx,         \
1149                                      ((CUM) + 6)* UNITS_PER_WORD)),     \
1150              6 - (CUM), (6 - (CUM)) * UNITS_PER_WORD);                  \
1151           move_block_from_reg                                           \
1152             (16 + (TARGET_FPREGS ? 32 : 0) + CUM,                       \
1153              gen_rtx (MEM, BLKmode,                                     \
1154                       plus_constant (virtual_incoming_args_rtx,         \
1155                                      (CUM) * UNITS_PER_WORD)),          \
1156              6 - (CUM), (6 - (CUM)) * UNITS_PER_WORD);                  \
1157            emit_insn (gen_blockage ());                                 \
1158          }                                                              \
1159       PRETEND_SIZE = 12 * UNITS_PER_WORD;                               \
1160     }                                                                   \
1161 }
1162
1163 /* Try to output insns to set TARGET equal to the constant C if it can be
1164    done in less than N insns.  Do all computations in MODE.  Returns the place
1165    where the output has been placed if it can be done and the insns have been
1166    emitted.  If it would take more than N insns, zero is returned and no
1167    insns and emitted.  */
1168 extern struct rtx_def *alpha_emit_set_const ();
1169 extern struct rtx_def *alpha_emit_set_long_const ();
1170 extern struct rtx_def *alpha_emit_conditional_branch ();
1171 extern struct rtx_def *alpha_emit_conditional_move ();
1172
1173 /* Generate necessary RTL for __builtin_saveregs().
1174    ARGLIST is the argument list; see expr.c.  */
1175 extern struct rtx_def *alpha_builtin_saveregs ();
1176 #define EXPAND_BUILTIN_SAVEREGS(ARGLIST) alpha_builtin_saveregs (ARGLIST)
1177
1178 /* Define the information needed to generate branch and scc insns.  This is
1179    stored from the compare operation.  Note that we can't use "rtx" here
1180    since it hasn't been defined!  */
1181
1182 extern struct rtx_def *alpha_compare_op0, *alpha_compare_op1;
1183 extern int alpha_compare_fp_p;
1184
1185 /* Make (or fake) .linkage entry for function call.
1186    IS_LOCAL is 0 if name is used in call, 1 if name is used in definition.  */
1187 extern void alpha_need_linkage ();
1188
1189 /* This macro defines the start of an assembly comment.  */
1190
1191 #define ASM_COMMENT_START " #"
1192
1193 /* This macro produces the initial definition of a function.  */
1194
1195 #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \
1196   alpha_start_function(FILE,NAME,DECL);
1197 extern void alpha_start_function ();
1198
1199 /* This macro closes up a function definition for the assembler.  */
1200
1201 #define ASM_DECLARE_FUNCTION_SIZE(FILE,NAME,DECL) \
1202   alpha_end_function(FILE,NAME,DECL)
1203 extern void alpha_end_function ();
1204    
1205 /* This macro notes the end of the prologue.  */
1206
1207 #define FUNCTION_END_PROLOGUE(FILE)  output_end_prologue (FILE)
1208 extern void output_end_prologue ();
1209
1210 /* Output any profiling code before the prologue.  */
1211
1212 #define PROFILE_BEFORE_PROLOGUE 1
1213
1214 /* Output assembler code to FILE to increment profiler label # LABELNO
1215    for profiling a function entry.  Under OSF/1, profiling is enabled
1216    by simply passing -pg to the assembler and linker.  */
1217
1218 #define FUNCTION_PROFILER(FILE, LABELNO)
1219
1220 /* Output assembler code to FILE to initialize this source file's
1221    basic block profiling info, if that has not already been done.
1222    This assumes that __bb_init_func doesn't garble a1-a5. */
1223
1224 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)                  \
1225     do {                                                        \
1226         ASM_OUTPUT_REG_PUSH (FILE, 16);                         \
1227         fputs ("\tlda $16,$PBX32\n", (FILE));                   \
1228         fputs ("\tldq $26,0($16)\n", (FILE));                   \
1229         fputs ("\tbne $26,1f\n", (FILE));                       \
1230         fputs ("\tlda $27,__bb_init_func\n", (FILE));           \
1231         fputs ("\tjsr $26,($27),__bb_init_func\n", (FILE));     \
1232         fputs ("\tldgp $29,0($26)\n", (FILE));                  \
1233         fputs ("1:\n", (FILE));                                 \
1234         ASM_OUTPUT_REG_POP (FILE, 16);                          \
1235     } while (0);
1236
1237 /* Output assembler code to FILE to increment the entry-count for
1238    the BLOCKNO'th basic block in this source file.  */
1239
1240 #define BLOCK_PROFILER(FILE, BLOCKNO)                           \
1241     do {                                                        \
1242         int blockn = (BLOCKNO);                                 \
1243         fputs ("\tsubq $30,16,$30\n", (FILE));                  \
1244         fputs ("\tstq $26,0($30)\n", (FILE));                   \
1245         fputs ("\tstq $27,8($30)\n", (FILE));                   \
1246         fputs ("\tlda $26,$PBX34\n", (FILE));                   \
1247         fprintf ((FILE), "\tldq $27,%d($26)\n", 8*blockn);      \
1248         fputs ("\taddq $27,1,$27\n", (FILE));                   \
1249         fprintf ((FILE), "\tstq $27,%d($26)\n", 8*blockn);      \
1250         fputs ("\tldq $26,0($30)\n", (FILE));                   \
1251         fputs ("\tldq $27,8($30)\n", (FILE));                   \
1252         fputs ("\taddq $30,16,$30\n", (FILE));                  \
1253     } while (0)
1254
1255
1256 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1257    the stack pointer does not matter.  The value is tested only in
1258    functions that have frame pointers.
1259    No definition is equivalent to always zero.  */
1260
1261 #define EXIT_IGNORE_STACK 1
1262 \f
1263 /* Output assembler code for a block containing the constant parts
1264    of a trampoline, leaving space for the variable parts.
1265
1266    The trampoline should set the static chain pointer to value placed
1267    into the trampoline and should branch to the specified routine.  
1268    Note that $27 has been set to the address of the trampoline, so we can
1269    use it for addressability of the two data items.  Trampolines are always
1270    aligned to FUNCTION_BOUNDARY, which is 64 bits.  */
1271
1272 #define TRAMPOLINE_TEMPLATE(FILE)               \
1273 do {                                            \
1274   fprintf (FILE, "\tldq $1,24($27)\n");         \
1275   fprintf (FILE, "\tldq $27,16($27)\n");        \
1276   fprintf (FILE, "\tjmp $31,($27),0\n");        \
1277   fprintf (FILE, "\tnop\n");                    \
1278   fprintf (FILE, "\t.quad 0,0\n");              \
1279 } while (0)
1280
1281 /* Section in which to place the trampoline.  On Alpha, instructions
1282    may only be placed in a text segment.  */
1283
1284 #define TRAMPOLINE_SECTION text_section
1285
1286 /* Length in units of the trampoline for entering a nested function.  */
1287
1288 #define TRAMPOLINE_SIZE    32
1289
1290 /* Emit RTL insns to initialize the variable parts of a trampoline.
1291    FNADDR is an RTX for the address of the function's pure code.
1292    CXT is an RTX for the static chain value for the function.  */
1293
1294 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1295   alpha_initialize_trampoline (TRAMP, FNADDR, CXT, 16, 24, 8)
1296
1297 /* A C expression whose value is RTL representing the value of the return
1298    address for the frame COUNT steps up from the current frame.
1299    FRAMEADDR is the frame pointer of the COUNT frame, or the frame pointer of
1300    the COUNT-1 frame if RETURN_ADDR_IN_PREVIOUS_FRAME is defined.  */
1301
1302 #define RETURN_ADDR_RTX  alpha_return_addr
1303 extern struct rtx_def *alpha_return_addr ();
1304
1305 /* Initialize data used by insn expanders.  This is called from insn_emit,
1306    once for every function before code is generated.  */
1307
1308 #define INIT_EXPANDERS  alpha_init_expanders ()
1309 extern void alpha_init_expanders ();
1310 \f
1311 /* Addressing modes, and classification of registers for them.  */
1312
1313 /* #define HAVE_POST_INCREMENT */
1314 /* #define HAVE_POST_DECREMENT */
1315
1316 /* #define HAVE_PRE_DECREMENT */
1317 /* #define HAVE_PRE_INCREMENT */
1318
1319 /* Macros to check register numbers against specific register classes.  */
1320
1321 /* These assume that REGNO is a hard or pseudo reg number.
1322    They give nonzero only if REGNO is a hard reg of the suitable class
1323    or a pseudo reg currently allocated to a suitable hard reg.
1324    Since they use reg_renumber, they are safe only once reg_renumber
1325    has been allocated, which happens in local-alloc.c.  */
1326
1327 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
1328 #define REGNO_OK_FOR_BASE_P(REGNO) \
1329 ((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32  \
1330  || (REGNO) == 63 || reg_renumber[REGNO] == 63)
1331 \f
1332 /* Maximum number of registers that can appear in a valid memory address.  */
1333 #define MAX_REGS_PER_ADDRESS 1
1334
1335 /* Recognize any constant value that is a valid address.  For the Alpha,
1336    there are only constants none since we want to use LDA to load any
1337    symbolic addresses into registers.  */
1338
1339 #define CONSTANT_ADDRESS_P(X)   \
1340   (GET_CODE (X) == CONST_INT    \
1341    && (unsigned HOST_WIDE_INT) (INTVAL (X) + 0x8000) < 0x10000)
1342
1343 /* Include all constant integers and constant doubles, but not
1344    floating-point, except for floating-point zero.  */
1345
1346 #define LEGITIMATE_CONSTANT_P(X)                \
1347   (GET_MODE_CLASS (GET_MODE (X)) != MODE_FLOAT  \
1348    || (X) == CONST0_RTX (GET_MODE (X)))
1349
1350 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1351    and check its validity for a certain class.
1352    We have two alternate definitions for each of them.
1353    The usual definition accepts all pseudo regs; the other rejects
1354    them unless they have been allocated suitable hard regs.
1355    The symbol REG_OK_STRICT causes the latter definition to be used.
1356
1357    Most source files want to accept pseudo regs in the hope that
1358    they will get allocated to the class that the insn wants them to be in.
1359    Source files for reload pass need to be strict.
1360    After reload, it makes no difference, since pseudo regs have
1361    been eliminated by then.  */
1362
1363 #ifndef REG_OK_STRICT
1364
1365 /* Nonzero if X is a hard reg that can be used as an index
1366    or if it is a pseudo reg.  */
1367 #define REG_OK_FOR_INDEX_P(X) 0
1368 /* Nonzero if X is a hard reg that can be used as a base reg
1369    or if it is a pseudo reg.  */
1370 #define REG_OK_FOR_BASE_P(X)  \
1371   (REGNO (X) < 32 || REGNO (X) == 63 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1372
1373 #else
1374
1375 /* Nonzero if X is a hard reg that can be used as an index.  */
1376 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1377 /* Nonzero if X is a hard reg that can be used as a base reg.  */
1378 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1379
1380 #endif
1381 \f
1382 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1383    that is a valid memory address for an instruction.
1384    The MODE argument is the machine mode for the MEM expression
1385    that wants to use this address. 
1386
1387    For Alpha, we have either a constant address or the sum of a register
1388    and a constant address, or just a register.  For DImode, any of those
1389    forms can be surrounded with an AND that clear the low-order three bits;
1390    this is an "unaligned" access.
1391
1392    First define the basic valid address.  */
1393
1394 #define GO_IF_LEGITIMATE_SIMPLE_ADDRESS(MODE, X, ADDR) \
1395 { if (REG_P (X) && REG_OK_FOR_BASE_P (X))       \
1396     goto ADDR;                                  \
1397   if (CONSTANT_ADDRESS_P (X))                   \
1398     goto ADDR;                                  \
1399   if (GET_CODE (X) == PLUS                      \
1400       && REG_P (XEXP (X, 0))                    \
1401       && REG_OK_FOR_BASE_P (XEXP (X, 0))        \
1402       && CONSTANT_ADDRESS_P (XEXP (X, 1)))      \
1403     goto ADDR;                                  \
1404 }
1405
1406 /* Now accept the simple address, or, for DImode only, an AND of a simple
1407    address that turns off the low three bits.  */
1408
1409 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1410 { GO_IF_LEGITIMATE_SIMPLE_ADDRESS (MODE, X, ADDR); \
1411   if ((MODE) == DImode                          \
1412       && GET_CODE (X) == AND                    \
1413       && GET_CODE (XEXP (X, 1)) == CONST_INT    \
1414       && INTVAL (XEXP (X, 1)) == -8)            \
1415     GO_IF_LEGITIMATE_SIMPLE_ADDRESS (MODE, XEXP (X, 0), ADDR); \
1416 }
1417
1418 /* Try machine-dependent ways of modifying an illegitimate address
1419    to be legitimate.  If we find one, return the new, valid address.
1420    This macro is used in only one place: `memory_address' in explow.c.
1421
1422    OLDX is the address as it was before break_out_memory_refs was called.
1423    In some cases it is useful to look at this to decide what needs to be done.
1424
1425    MODE and WIN are passed so that this macro can use
1426    GO_IF_LEGITIMATE_ADDRESS.
1427
1428    It is always safe for this macro to do nothing.  It exists to recognize
1429    opportunities to optimize the output. 
1430
1431    For the Alpha, there are three cases we handle:
1432
1433    (1) If the address is (plus reg const_int) and the CONST_INT is not a
1434        valid offset, compute the high part of the constant and add it to the
1435        register.  Then our address is (plus temp low-part-const).
1436    (2) If the address is (const (plus FOO const_int)), find the low-order
1437        part of the CONST_INT.  Then load FOO plus any high-order part of the
1438        CONST_INT into a register.  Our address is (plus reg low-part-const).
1439        This is done to reduce the number of GOT entries.
1440    (3) If we have a (plus reg const), emit the load as in (2), then add
1441        the two registers, and finally generate (plus reg low-part-const) as
1442        our address.  */
1443
1444 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                     \
1445 { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG     \
1446       && GET_CODE (XEXP (X, 1)) == CONST_INT                    \
1447       && ! CONSTANT_ADDRESS_P (XEXP (X, 1)))                    \
1448     {                                                           \
1449       HOST_WIDE_INT val = INTVAL (XEXP (X, 1));                 \
1450       HOST_WIDE_INT lowpart = (val & 0xffff) - 2 * (val & 0x8000); \
1451       HOST_WIDE_INT highpart = val - lowpart;                   \
1452       rtx high = GEN_INT (highpart);                            \
1453       rtx temp = expand_binop (Pmode, add_optab, XEXP (x, 0),   \
1454                                high, NULL_RTX, 1, OPTAB_LIB_WIDEN); \
1455                                                                 \
1456       (X) = plus_constant (temp, lowpart);                      \
1457       goto WIN;                                                 \
1458     }                                                           \
1459   else if (GET_CODE (X) == CONST                                \
1460            && GET_CODE (XEXP (X, 0)) == PLUS                    \
1461            && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT)    \
1462     {                                                           \
1463       HOST_WIDE_INT val = INTVAL (XEXP (XEXP (X, 0), 1));       \
1464       HOST_WIDE_INT lowpart = (val & 0xffff) - 2 * (val & 0x8000); \
1465       HOST_WIDE_INT highpart = val - lowpart;                   \
1466       rtx high = XEXP (XEXP (X, 0), 0);                         \
1467                                                                 \
1468       if (highpart)                                             \
1469         high = plus_constant (high, highpart);                  \
1470                                                                 \
1471       (X) = plus_constant (force_reg (Pmode, high), lowpart);   \
1472       goto WIN;                                                 \
1473     }                                                           \
1474   else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
1475            && GET_CODE (XEXP (X, 1)) == CONST                   \
1476            && GET_CODE (XEXP (XEXP (X, 1), 0)) == PLUS          \
1477            && GET_CODE (XEXP (XEXP (XEXP (X, 1), 0), 1)) == CONST_INT) \
1478     {                                                           \
1479       HOST_WIDE_INT val = INTVAL (XEXP (XEXP (XEXP (X, 1), 0), 1)); \
1480       HOST_WIDE_INT lowpart = (val & 0xffff) - 2 * (val & 0x8000); \
1481       HOST_WIDE_INT highpart = val - lowpart;                   \
1482       rtx high = XEXP (XEXP (XEXP (X, 1), 0), 0);               \
1483                                                                 \
1484       if (highpart)                                             \
1485         high = plus_constant (high, highpart);                  \
1486                                                                 \
1487       high = expand_binop (Pmode, add_optab, XEXP (X, 0),       \
1488                            force_reg (Pmode, high),             \
1489                            high, 1, OPTAB_LIB_WIDEN);           \
1490       (X) = plus_constant (high, lowpart);                      \
1491       goto WIN;                                                 \
1492     }                                                           \
1493 }
1494
1495 /* Try a machine-dependent way of reloading an illegitimate address
1496    operand.  If we find one, push the reload and jump to WIN.  This
1497    macro is used in only one place: `find_reloads_address' in reload.c.
1498
1499    For the Alpha, we wish to handle large displacements off a base
1500    register by splitting the addend across an ldah and the mem insn.
1501    This cuts number of extra insns needed from 3 to 1.  */
1502    
1503 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN)     \
1504 do {                                                                    \
1505   /* We must recognize output that we have already generated ourselves.  */ \
1506   if (GET_CODE (X) == PLUS                                              \
1507       && GET_CODE (XEXP (X, 0)) == PLUS                                 \
1508       && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG                        \
1509       && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT                  \
1510       && GET_CODE (XEXP (X, 1)) == CONST_INT)                           \
1511     {                                                                   \
1512       push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL_PTR,       \
1513                    BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0,        \
1514                    OPNUM, TYPE);                                        \
1515       goto WIN;                                                         \
1516     }                                                                   \
1517   if (GET_CODE (X) == PLUS                                              \
1518       && GET_CODE (XEXP (X, 0)) == REG                                  \
1519       && REGNO (XEXP (X, 0)) < FIRST_PSEUDO_REGISTER                    \
1520       && REG_MODE_OK_FOR_BASE_P (XEXP (X, 0), MODE)                     \
1521       && GET_CODE (XEXP (X, 1)) == CONST_INT)                           \
1522     {                                                                   \
1523       HOST_WIDE_INT val = INTVAL (XEXP (X, 1));                         \
1524       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;           \
1525       HOST_WIDE_INT high                                                \
1526         = (((val - low) & 0xffffffff) ^ 0x80000000) - 0x80000000;       \
1527                                                                         \
1528       /* Check for 32-bit overflow.  */                                 \
1529       if (high + low != val)                                            \
1530         break;                                                          \
1531                                                                         \
1532       /* Reload the high part into a base reg; leave the low part       \
1533          in the mem directly.  */                                       \
1534                                                                         \
1535       X = gen_rtx_PLUS (GET_MODE (X),                                   \
1536                         gen_rtx_PLUS (GET_MODE (X), XEXP (X, 0),        \
1537                                       GEN_INT (high)),                  \
1538                         GEN_INT (low));                                 \
1539                                                                         \
1540       push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL_PTR,       \
1541                    BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0,        \
1542                    OPNUM, TYPE);                                        \
1543       goto WIN;                                                         \
1544     }                                                                   \
1545 } while (0)
1546
1547 /* Go to LABEL if ADDR (a legitimate address expression)
1548    has an effect that depends on the machine mode it is used for.
1549    On the Alpha this is true only for the unaligned modes.   We can
1550    simplify this test since we know that the address must be valid.  */
1551
1552 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)  \
1553 { if (GET_CODE (ADDR) == AND) goto LABEL; }
1554
1555 /* Compute the cost of an address.  For the Alpha, all valid addresses are
1556    the same cost.  */
1557
1558 #define ADDRESS_COST(X)  0
1559
1560 /* Machine-dependent reorg pass.   */
1561 #define MACHINE_DEPENDENT_REORG(X)      alpha_reorg(X)
1562 \f
1563 /* Specify the machine mode that this machine uses
1564    for the index in the tablejump instruction.  */
1565 #define CASE_VECTOR_MODE SImode
1566
1567 /* Define as C expression which evaluates to nonzero if the tablejump
1568    instruction expects the table to contain offsets from the address of the
1569    table.
1570
1571    Do not define this if the table should contain absolute addresses.
1572    On the Alpha, the table is really GP-relative, not relative to the PC
1573    of the table, but we pretend that it is PC-relative; this should be OK,
1574    but we should try to find some better way sometime.  */
1575 #define CASE_VECTOR_PC_RELATIVE 1
1576
1577 /* Specify the tree operation to be used to convert reals to integers.  */
1578 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1579
1580 /* This is the kind of divide that is easiest to do in the general case.  */
1581 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1582
1583 /* Define this as 1 if `char' should by default be signed; else as 0.  */
1584 #define DEFAULT_SIGNED_CHAR 1
1585
1586 /* This flag, if defined, says the same insns that convert to a signed fixnum
1587    also convert validly to an unsigned one.
1588
1589    We actually lie a bit here as overflow conditions are different.  But
1590    they aren't being checked anyway.  */
1591
1592 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
1593
1594 /* Max number of bytes we can move to or from memory
1595    in one reasonably fast instruction.  */
1596
1597 #define MOVE_MAX 8
1598
1599 /* Controls how many units are moved by expr.c before resorting to movstr.
1600    Without byte/word accesses, we want no more than one; with, several single
1601    byte accesses are better.   */
1602
1603 #define MOVE_RATIO  (TARGET_BWX ? 7 : 2)
1604
1605 /* Largest number of bytes of an object that can be placed in a register.
1606    On the Alpha we have plenty of registers, so use TImode.  */
1607 #define MAX_FIXED_MODE_SIZE     GET_MODE_BITSIZE (TImode)
1608
1609 /* Nonzero if access to memory by bytes is no faster than for words.
1610    Also non-zero if doing byte operations (specifically shifts) in registers
1611    is undesirable. 
1612
1613    On the Alpha, we want to not use the byte operation and instead use
1614    masking operations to access fields; these will save instructions.  */
1615
1616 #define SLOW_BYTE_ACCESS        1
1617
1618 /* Define if operations between registers always perform the operation
1619    on the full register even if a narrower mode is specified.  */
1620 #define WORD_REGISTER_OPERATIONS
1621
1622 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1623    will either zero-extend or sign-extend.  The value of this macro should
1624    be the code that says which one of the two operations is implicitly
1625    done, NIL if none.  */
1626 #define LOAD_EXTEND_OP(MODE) ((MODE) == SImode ? SIGN_EXTEND : ZERO_EXTEND)
1627
1628 /* Define if loading short immediate values into registers sign extends.  */
1629 #define SHORT_IMMEDIATES_SIGN_EXTEND
1630
1631 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1632    is done just by pretending it is already truncated.  */
1633 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1634
1635 /* We assume that the store-condition-codes instructions store 0 for false
1636    and some other value for true.  This is the value stored for true.  */
1637
1638 #define STORE_FLAG_VALUE 1
1639
1640 /* Define the value returned by a floating-point comparison instruction.  */
1641
1642 #define FLOAT_STORE_FLAG_VALUE (TARGET_FLOAT_VAX ? 0.5 : 2.0)
1643
1644 /* Canonicalize a comparison from one we don't have to one we do have.  */
1645
1646 #define CANONICALIZE_COMPARISON(CODE,OP0,OP1) \
1647   do {                                                                  \
1648     if (((CODE) == GE || (CODE) == GT || (CODE) == GEU || (CODE) == GTU) \
1649         && (GET_CODE (OP1) == REG || (OP1) == const0_rtx))              \
1650       {                                                                 \
1651         rtx tem = (OP0);                                                \
1652         (OP0) = (OP1);                                                  \
1653         (OP1) = tem;                                                    \
1654         (CODE) = swap_condition (CODE);                                 \
1655       }                                                                 \
1656     if (((CODE) == LT || (CODE) == LTU)                                 \
1657         && GET_CODE (OP1) == CONST_INT && INTVAL (OP1) == 256)          \
1658       {                                                                 \
1659         (CODE) = (CODE) == LT ? LE : LEU;                               \
1660         (OP1) = GEN_INT (255);                                          \
1661       }                                                                 \
1662   } while (0)
1663
1664 /* Specify the machine mode that pointers have.
1665    After generation of rtl, the compiler makes no further distinction
1666    between pointers and any other objects of this machine mode.  */
1667 #define Pmode DImode
1668
1669 /* Mode of a function address in a call instruction (for indexing purposes). */
1670
1671 #define FUNCTION_MODE Pmode
1672
1673 /* Define this if addresses of constant functions
1674    shouldn't be put through pseudo regs where they can be cse'd.
1675    Desirable on machines where ordinary constants are expensive
1676    but a CALL with constant address is cheap.
1677
1678    We define this on the Alpha so that gen_call and gen_call_value
1679    get to see the SYMBOL_REF (for the hint field of the jsr).  It will
1680    then copy it into a register, thus actually letting the address be
1681    cse'ed.  */
1682
1683 #define NO_FUNCTION_CSE
1684
1685 /* Define this to be nonzero if shift instructions ignore all but the low-order
1686    few bits. */
1687 #define SHIFT_COUNT_TRUNCATED 1
1688
1689 /* Use atexit for static constructors/destructors, instead of defining
1690    our own exit function.  */
1691 #define HAVE_ATEXIT
1692
1693 /* The EV4 is dual issue; EV5/EV6 are quad issue.  */
1694 #define ISSUE_RATE  (alpha_cpu == PROCESSOR_EV4 ? 2 : 4)
1695
1696 /* Compute the cost of computing a constant rtl expression RTX
1697    whose rtx-code is CODE.  The body of this macro is a portion
1698    of a switch statement.  If the code is computed here,
1699    return it with a return statement.  Otherwise, break from the switch.
1700
1701    If this is an 8-bit constant, return zero since it can be used
1702    nearly anywhere with no cost.  If it is a valid operand for an
1703    ADD or AND, likewise return 0 if we know it will be used in that
1704    context.  Otherwise, return 2 since it might be used there later.
1705    All other constants take at least two insns.  */
1706
1707 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1708   case CONST_INT:                                               \
1709     if (INTVAL (RTX) >= 0 && INTVAL (RTX) < 256)                \
1710       return 0;                                                 \
1711   case CONST_DOUBLE:                                            \
1712     if ((RTX) == CONST0_RTX (GET_MODE (RTX)))                   \
1713       return 0;                                                 \
1714     else if (((OUTER_CODE) == PLUS && add_operand (RTX, VOIDmode)) \
1715         || ((OUTER_CODE) == AND && and_operand (RTX, VOIDmode))) \
1716       return 0;                                                 \
1717     else if (add_operand (RTX, VOIDmode) || and_operand (RTX, VOIDmode)) \
1718       return 2;                                                 \
1719     else                                                        \
1720       return COSTS_N_INSNS (2);                                 \
1721   case CONST:                                                   \
1722   case SYMBOL_REF:                                              \
1723   case LABEL_REF:                                               \
1724   switch (alpha_cpu)                                            \
1725     {                                                           \
1726     case PROCESSOR_EV4:                                         \
1727       return COSTS_N_INSNS (3);                                 \
1728     case PROCESSOR_EV5:                                         \
1729     case PROCESSOR_EV6:                                         \
1730       return COSTS_N_INSNS (2);                                 \
1731     default: abort();                                           \
1732     }
1733     
1734 /* Provide the costs of a rtl expression.  This is in the body of a
1735    switch on CODE.  */
1736    
1737 #define RTX_COSTS(X,CODE,OUTER_CODE)                    \
1738   case PLUS:  case MINUS:                               \
1739     if (FLOAT_MODE_P (GET_MODE (X)))                    \
1740       switch (alpha_cpu)                                \
1741         {                                               \
1742         case PROCESSOR_EV4:                             \
1743           return COSTS_N_INSNS (6);                     \
1744         case PROCESSOR_EV5:                             \
1745         case PROCESSOR_EV6:                             \
1746           return COSTS_N_INSNS (4);                     \
1747         default: abort();                               \
1748         }                                               \
1749     else if (GET_CODE (XEXP (X, 0)) == MULT             \
1750              && const48_operand (XEXP (XEXP (X, 0), 1), VOIDmode)) \
1751       return (2 + rtx_cost (XEXP (XEXP (X, 0), 0), OUTER_CODE)  \
1752               + rtx_cost (XEXP (X, 1), OUTER_CODE));    \
1753     break;                                              \
1754   case MULT:                                            \
1755     switch (alpha_cpu)                                  \
1756       {                                                 \
1757       case PROCESSOR_EV4:                               \
1758         if (FLOAT_MODE_P (GET_MODE (X)))                \
1759           return COSTS_N_INSNS (6);                     \
1760         return COSTS_N_INSNS (23);                      \
1761       case PROCESSOR_EV5:                               \
1762         if (FLOAT_MODE_P (GET_MODE (X)))                \
1763           return COSTS_N_INSNS (4);                     \
1764         else if (GET_MODE (X) == DImode)                \
1765           return COSTS_N_INSNS (12);                    \
1766         else                                            \
1767           return COSTS_N_INSNS (8);                     \
1768       case PROCESSOR_EV6:                               \
1769         if (FLOAT_MODE_P (GET_MODE (X)))                \
1770           return COSTS_N_INSNS (4);                     \
1771         else                                            \
1772           return COSTS_N_INSNS (7);                     \
1773       default: abort();                                 \
1774       }                                                 \
1775   case ASHIFT:                                          \
1776     if (GET_CODE (XEXP (X, 1)) == CONST_INT             \
1777         && INTVAL (XEXP (X, 1)) <= 3)                   \
1778       break;                                            \
1779     /* ... fall through ... */                          \
1780   case ASHIFTRT:  case LSHIFTRT:                        \
1781     switch (alpha_cpu)                                  \
1782       {                                                 \
1783       case PROCESSOR_EV4:                               \
1784         return COSTS_N_INSNS (2);                       \
1785       case PROCESSOR_EV5:                               \
1786       case PROCESSOR_EV6:                               \
1787         return COSTS_N_INSNS (1);                       \
1788       default: abort();                                 \
1789       }                                                 \
1790   case IF_THEN_ELSE:                                    \
1791     switch (alpha_cpu)                                  \
1792       {                                                 \
1793       case PROCESSOR_EV4:                               \
1794       case PROCESSOR_EV6:                               \
1795         return COSTS_N_INSNS (2);                       \
1796       case PROCESSOR_EV5:                               \
1797         return COSTS_N_INSNS (1);                       \
1798       default: abort();                                 \
1799       }                                                 \
1800   case DIV:  case UDIV:  case MOD:  case UMOD:          \
1801     switch (alpha_cpu)                                  \
1802       {                                                 \
1803       case PROCESSOR_EV4:                               \
1804         if (GET_MODE (X) == SFmode)                     \
1805           return COSTS_N_INSNS (34);                    \
1806         else if (GET_MODE (X) == DFmode)                \
1807           return COSTS_N_INSNS (63);                    \
1808         else                                            \
1809           return COSTS_N_INSNS (70);                    \
1810       case PROCESSOR_EV5:                               \
1811         if (GET_MODE (X) == SFmode)                     \
1812           return COSTS_N_INSNS (15);                    \
1813         else if (GET_MODE (X) == DFmode)                \
1814           return COSTS_N_INSNS (22);                    \
1815         else                                            \
1816           return COSTS_N_INSNS (70);    /* ??? */       \
1817       case PROCESSOR_EV6:                               \
1818         if (GET_MODE (X) == SFmode)                     \
1819           return COSTS_N_INSNS (12);                    \
1820         else if (GET_MODE (X) == DFmode)                \
1821           return COSTS_N_INSNS (15);                    \
1822         else                                            \
1823           return COSTS_N_INSNS (70);    /* ??? */       \
1824       default: abort();                                 \
1825       }                                                 \
1826   case MEM:                                             \
1827     switch (alpha_cpu)                                  \
1828       {                                                 \
1829       case PROCESSOR_EV4:                               \
1830       case PROCESSOR_EV6:                               \
1831         return COSTS_N_INSNS (3);                       \
1832       case PROCESSOR_EV5:                               \
1833         return COSTS_N_INSNS (2);                       \
1834       default: abort();                                 \
1835       }                                                 \
1836   case NEG:  case ABS:                                  \
1837     if (! FLOAT_MODE_P (GET_MODE (X)))                  \
1838       break;                                            \
1839     /* ... fall through ... */                          \
1840   case FLOAT:  case UNSIGNED_FLOAT:  case FIX:  case UNSIGNED_FIX: \
1841   case FLOAT_EXTEND:  case FLOAT_TRUNCATE:              \
1842     switch (alpha_cpu)                                  \
1843       {                                                 \
1844       case PROCESSOR_EV4:                               \
1845         return COSTS_N_INSNS (6);                       \
1846       case PROCESSOR_EV5:                               \
1847       case PROCESSOR_EV6:                               \
1848         return COSTS_N_INSNS (4);                       \
1849       default: abort();                                 \
1850       }
1851 \f
1852 /* Control the assembler format that we output.  */
1853
1854 /* We don't emit these labels, so as to avoid getting linker errors about
1855    missing exception handling info.  If we emit a gcc_compiled. label into
1856    text, and the file has no code, then the DEC assembler gives us a zero
1857    sized text section with no associated exception handling info.  The
1858    DEC linker sees this text section, and gives a warning saying that
1859    the exception handling info is missing.  */
1860 #define ASM_IDENTIFY_GCC(x)
1861 #define ASM_IDENTIFY_LANGUAGE(x)
1862
1863 /* Output to assembler file text saying following lines
1864    may contain character constants, extra white space, comments, etc.  */
1865
1866 #define ASM_APP_ON ""
1867
1868 /* Output to assembler file text saying following lines
1869    no longer contain unusual constructs.  */
1870
1871 #define ASM_APP_OFF ""
1872
1873 #define TEXT_SECTION_ASM_OP ".text"
1874
1875 /* Output before read-only data.  */
1876
1877 #define READONLY_DATA_SECTION_ASM_OP ".rdata"
1878
1879 /* Output before writable data.  */
1880
1881 #define DATA_SECTION_ASM_OP ".data"
1882
1883 /* Define an extra section for read-only data, a routine to enter it, and
1884    indicate that it is for read-only data.
1885
1886    The first time we enter the readonly data section for a file, we write
1887    eight bytes of zero.  This works around a bug in DEC's assembler in
1888    some versions of OSF/1 V3.x.  */
1889
1890 #define EXTRA_SECTIONS  readonly_data
1891
1892 #define EXTRA_SECTION_FUNCTIONS                                 \
1893 void                                                            \
1894 literal_section ()                                              \
1895 {                                                               \
1896   if (in_section != readonly_data)                              \
1897     {                                                           \
1898       static int firsttime = 1;                                 \
1899                                                                 \
1900       fprintf (asm_out_file, "%s\n", READONLY_DATA_SECTION_ASM_OP); \
1901       if (firsttime)                                            \
1902         {                                                       \
1903           firsttime = 0;                                        \
1904           ASM_OUTPUT_DOUBLE_INT (asm_out_file, const0_rtx);     \
1905         }                                                       \
1906                                                                 \
1907       in_section = readonly_data;                               \
1908     }                                                           \
1909 }                                                               \
1910
1911 #define READONLY_DATA_SECTION   literal_section
1912
1913 /* If we are referencing a function that is static, make the SYMBOL_REF
1914    special.  We use this to see indicate we can branch to this function
1915    without setting PV or restoring GP.  */
1916
1917 #define ENCODE_SECTION_INFO(DECL)  \
1918   if (TREE_CODE (DECL) == FUNCTION_DECL && ! TREE_PUBLIC (DECL)) \
1919     SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;
1920
1921 /* How to refer to registers in assembler output.
1922    This sequence is indexed by compiler's hard-register-number (see above).  */
1923
1924 #define REGISTER_NAMES                                          \
1925 {"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",          \
1926  "$9", "$10", "$11", "$12", "$13", "$14", "$15",                \
1927  "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",        \
1928  "$24", "$25", "$26", "$27", "$28", "$29", "$30", "AP",         \
1929  "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", \
1930  "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15",         \
1931  "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",\
1932  "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "FP"}
1933
1934 /* How to renumber registers for dbx and gdb.  */
1935
1936 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
1937
1938 /* This is how to output the definition of a user-level label named NAME,
1939    such as the label on a static function or variable NAME.  */
1940
1941 #define ASM_OUTPUT_LABEL(FILE,NAME)     \
1942   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1943
1944 /* This is how to output a command to make the user-level label named NAME
1945    defined for reference from other files.  */
1946
1947 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
1948   do { fputs ("\t.globl ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
1949
1950 /* The prefix to add to user-visible assembler symbols. */
1951
1952 #define USER_LABEL_PREFIX ""
1953
1954 /* This is how to output an internal numbered label where
1955    PREFIX is the class of label and NUM is the number within the class.  */
1956
1957 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
1958   fprintf (FILE, "$%s%d:\n", PREFIX, NUM)
1959
1960 /* This is how to output a label for a jump table.  Arguments are the same as
1961    for ASM_OUTPUT_INTERNAL_LABEL, except the insn for the jump table is
1962    passed. */
1963
1964 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN)        \
1965 { ASM_OUTPUT_ALIGN (FILE, 2); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); }
1966
1967 /* This is how to store into the string LABEL
1968    the symbol_ref name of an internal numbered label where
1969    PREFIX is the class of label and NUM is the number within the class.
1970    This is suitable for output with `assemble_name'.  */
1971
1972 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
1973   sprintf (LABEL, "*$%s%d", PREFIX, NUM)
1974
1975 /* Check a floating-point value for validity for a particular machine mode.  */
1976
1977 #define CHECK_FLOAT_VALUE(MODE, D, OVERFLOW) \
1978   ((OVERFLOW) = check_float_value (MODE, &D, OVERFLOW))
1979
1980 /* This is how to output an assembler line defining a `double' constant.  */
1981
1982 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                                   \
1983   {                                                                     \
1984     if (REAL_VALUE_ISINF (VALUE)                                        \
1985         || REAL_VALUE_ISNAN (VALUE)                                     \
1986         || REAL_VALUE_MINUS_ZERO (VALUE))                               \
1987       {                                                                 \
1988         long t[2];                                                      \
1989         REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t);                       \
1990         fprintf (FILE, "\t.quad 0x%lx%08lx\n",                          \
1991                 t[1] & 0xffffffff, t[0] & 0xffffffff);                  \
1992       }                                                                 \
1993     else                                                                \
1994       {                                                                 \
1995         char str[30];                                                   \
1996         REAL_VALUE_TO_DECIMAL (VALUE, "%.20e", str);                    \
1997         fprintf (FILE, "\t.%c_floating %s\n", (TARGET_FLOAT_VAX)?'g':'t', str);                 \
1998       }                                                                 \
1999   }
2000
2001 /* This is how to output an assembler line defining a `float' constant.  */
2002
2003 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                            \
2004   do {                                                          \
2005     long t;                                                     \
2006     REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t);                   \
2007     fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff);          \
2008 } while (0)
2009   
2010 /* This is how to output an assembler line defining an `int' constant.  */
2011
2012 #define ASM_OUTPUT_INT(FILE,VALUE)              \
2013 ( fprintf (FILE, "\t.long "),                   \
2014   output_addr_const (FILE, (VALUE)),            \
2015   fprintf (FILE, "\n"))
2016
2017 /* This is how to output an assembler line defining a `long' constant.  */
2018
2019 #define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE)       \
2020 ( fprintf (FILE, "\t.quad "),                   \
2021   output_addr_const (FILE, (VALUE)),            \
2022   fprintf (FILE, "\n"))
2023
2024 /* Likewise for `char' and `short' constants.  */
2025
2026 #define ASM_OUTPUT_SHORT(FILE,VALUE)  \
2027   fprintf (FILE, "\t.word %d\n",                \
2028     (int)(GET_CODE (VALUE) == CONST_INT         \
2029      ? INTVAL (VALUE) & 0xffff : (abort (), 0)))
2030
2031 #define ASM_OUTPUT_CHAR(FILE,VALUE)             \
2032   fprintf (FILE, "\t.byte %d\n",                \
2033     (int)(GET_CODE (VALUE) == CONST_INT         \
2034      ? INTVAL (VALUE) & 0xff : (abort (), 0)))
2035
2036 /* We use the default ASCII-output routine, except that we don't write more
2037    than 50 characters since the assembler doesn't support very long lines.  */
2038
2039 #define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
2040   do {                                                                        \
2041     FILE *_hide_asm_out_file = (MYFILE);                                      \
2042     unsigned char *_hide_p = (unsigned char *) (MYSTRING);                    \
2043     int _hide_thissize = (MYLENGTH);                                          \
2044     int _size_so_far = 0;                                                     \
2045     {                                                                         \
2046       FILE *asm_out_file = _hide_asm_out_file;                                \
2047       unsigned char *p = _hide_p;                                             \
2048       int thissize = _hide_thissize;                                          \
2049       int i;                                                                  \
2050       fprintf (asm_out_file, "\t.ascii \"");                                  \
2051                                                                               \
2052       for (i = 0; i < thissize; i++)                                          \
2053         {                                                                     \
2054           register int c = p[i];                                              \
2055                                                                               \
2056           if (_size_so_far ++ > 50 && i < thissize - 4)                       \
2057             _size_so_far = 0, fprintf (asm_out_file, "\"\n\t.ascii \"");      \
2058                                                                               \
2059           if (c == '\"' || c == '\\')                                         \
2060             putc ('\\', asm_out_file);                                        \
2061           if (c >= ' ' && c < 0177)                                           \
2062             putc (c, asm_out_file);                                           \
2063           else                                                                \
2064             {                                                                 \
2065               fprintf (asm_out_file, "\\%o", c);                              \
2066               /* After an octal-escape, if a digit follows,                   \
2067                  terminate one string constant and start another.             \
2068                  The Vax assembler fails to stop reading the escape           \
2069                  after three digits, so this is the only way we               \
2070                  can get it to parse the data properly.  */                   \
2071               if (i < thissize - 1                                            \
2072                   && p[i + 1] >= '0' && p[i + 1] <= '9')                      \
2073                 _size_so_far = 0, fprintf (asm_out_file, "\"\n\t.ascii \"");  \
2074           }                                                                   \
2075         }                                                                     \
2076       fprintf (asm_out_file, "\"\n");                                         \
2077     }                                                                         \
2078   }                                                                           \
2079   while (0)
2080
2081 /* This is how to output an insn to push a register on the stack.
2082    It need not be very fast code.  */
2083
2084 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)                                 \
2085  fprintf (FILE, "\tsubq $30,8,$30\n\tst%s $%s%d,0($30)\n",              \
2086           (REGNO) > 32 ? "t" : "q", (REGNO) > 32 ? "f" : "",            \
2087           (REGNO) & 31);
2088
2089 /* This is how to output an insn to pop a register from the stack.
2090    It need not be very fast code.  */
2091
2092 #define ASM_OUTPUT_REG_POP(FILE,REGNO)                                  \
2093   fprintf (FILE, "\tld%s $%s%d,0($30)\n\taddq $30,8,$30\n",             \
2094           (REGNO) > 32 ? "t" : "q", (REGNO) > 32 ? "f" : "",            \
2095           (REGNO) & 31);
2096
2097 /* This is how to output an assembler line for a numeric constant byte.  */
2098
2099 #define ASM_OUTPUT_BYTE(FILE,VALUE)  \
2100   fprintf (FILE, "\t.byte 0x%x\n", (int) ((VALUE) & 0xff))
2101
2102 /* This is how to output an element of a case-vector that is absolute.
2103    (Alpha does not use such vectors, but we must define this macro anyway.)  */
2104
2105 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) abort ()
2106
2107 /* This is how to output an element of a case-vector that is relative.  */
2108
2109 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
2110   fprintf (FILE, "\t.%s $L%d\n", TARGET_WINDOWS_NT ? "long" : "gprel32", \
2111            (VALUE))
2112
2113 /* This is how to output an assembler line
2114    that says to advance the location counter
2115    to a multiple of 2**LOG bytes.  */
2116
2117 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
2118   if ((LOG) != 0)                       \
2119     fprintf (FILE, "\t.align %d\n", LOG);
2120
2121 /* This is how to advance the location counter by SIZE bytes.  */
2122
2123 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
2124   fprintf (FILE, "\t.space %d\n", (SIZE))
2125
2126 /* This says how to output an assembler line
2127    to define a global common symbol.  */
2128
2129 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
2130 ( fputs ("\t.comm ", (FILE)),                   \
2131   assemble_name ((FILE), (NAME)),               \
2132   fprintf ((FILE), ",%d\n", (SIZE)))
2133
2134 /* This says how to output an assembler line
2135    to define a local common symbol.  */
2136
2137 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED)      \
2138 ( fputs ("\t.lcomm ", (FILE)),                          \
2139   assemble_name ((FILE), (NAME)),                       \
2140   fprintf ((FILE), ",%d\n", (SIZE)))
2141
2142 /* Store in OUTPUT a string (made with alloca) containing
2143    an assembler-name for a local static variable named NAME.
2144    LABELNO is an integer which is different for each call.  */
2145
2146 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)  \
2147 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),    \
2148   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2149
2150 /* Define the parentheses used to group arithmetic operations
2151    in assembler code.  */
2152
2153 #define ASM_OPEN_PAREN "("
2154 #define ASM_CLOSE_PAREN ")"
2155
2156 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
2157    Used for C++ multiple inheritance.  */
2158
2159 #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION)        \
2160 do {                                                                    \
2161   char *fn_name = XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0);              \
2162   int reg;                                                              \
2163                                                                         \
2164   /* Mark end of prologue.  */                                          \
2165   output_end_prologue (FILE);                                           \
2166                                                                         \
2167   /* Rely on the assembler to macro expand a large delta.  */           \
2168   reg = aggregate_value_p (TREE_TYPE (TREE_TYPE (FUNCTION))) ? 17 : 16; \
2169   fprintf (FILE, "\tlda $%d,%ld($%d)\n", reg, (long)(DELTA), reg);      \
2170                                                                         \
2171   if (current_file_function_operand (XEXP (DECL_RTL (FUNCTION), 0)))    \
2172     {                                                                   \
2173       fprintf (FILE, "\tbr $31,$");                                     \
2174       assemble_name (FILE, fn_name);                                    \
2175       fprintf (FILE, "..ng\n");                                         \
2176     }                                                                   \
2177   else                                                                  \
2178     {                                                                   \
2179       fprintf (FILE, "\tjmp $31,");                                     \
2180       assemble_name (FILE, fn_name);                                    \
2181       fputc ('\n', FILE);                                               \
2182     }                                                                   \
2183 } while (0)
2184 \f
2185
2186 /* Define results of standard character escape sequences.  */
2187 #define TARGET_BELL 007
2188 #define TARGET_BS 010
2189 #define TARGET_TAB 011
2190 #define TARGET_NEWLINE 012
2191 #define TARGET_VT 013
2192 #define TARGET_FF 014
2193 #define TARGET_CR 015
2194
2195 /* Print operand X (an rtx) in assembler syntax to file FILE.
2196    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2197    For `%' followed by punctuation, CODE is the punctuation and X is null.  */
2198
2199 #define PRINT_OPERAND(FILE, X, CODE)  print_operand (FILE, X, CODE)
2200
2201 /* Determine which codes are valid without a following integer.  These must
2202    not be alphabetic (the characters are chosen so that
2203    PRINT_OPERAND_PUNCT_VALID_P translates into a simple range change when
2204    using ASCII).
2205
2206    &    Generates fp-rounding mode suffix: nothing for normal, 'c' for
2207         chopped, 'm' for minus-infinity, and 'd' for dynamic rounding
2208         mode.  alpha_fprm controls which suffix is generated.
2209
2210    '    Generates trap-mode suffix for instructions that accept the
2211         su suffix only (cmpt et al).
2212
2213    `    Generates trap-mode suffix for instructions that accept the
2214         v and sv suffix.  The only instruction that needs this is cvtql.
2215
2216    (    Generates trap-mode suffix for instructions that accept the
2217         v, sv, and svi suffix.  The only instruction that needs this
2218         is cvttq.
2219
2220    )    Generates trap-mode suffix for instructions that accept the
2221         u, su, and sui suffix.  This is the bulk of the IEEE floating
2222         point instructions (addt et al).
2223
2224    +    Generates trap-mode suffix for instructions that accept the
2225         sui suffix (cvtqt and cvtqs).
2226
2227    ,    Generates single precision suffix for floating point
2228         instructions (s for IEEE, f for VAX)
2229
2230    -    Generates double precision suffix for floating point
2231         instructions (t for IEEE, g for VAX)
2232    */
2233
2234 #define PRINT_OPERAND_PUNCT_VALID_P(CODE)                               \
2235   ((CODE) == '&' || (CODE) == '`' || (CODE) == '\'' || (CODE) == '('    \
2236    || (CODE) == ')' || (CODE) == '+' || (CODE) == ',' || (CODE) == '-')
2237 \f
2238 /* Print a memory address as an operand to reference that memory location.  */
2239
2240 #define PRINT_OPERAND_ADDRESS(FILE, ADDR)               \
2241 { rtx addr = (ADDR);                                    \
2242   int basereg = 31;                                     \
2243   HOST_WIDE_INT offset = 0;                             \
2244                                                         \
2245   if (GET_CODE (addr) == AND)                           \
2246     addr = XEXP (addr, 0);                              \
2247                                                         \
2248   if (GET_CODE (addr) == REG)                           \
2249     basereg = REGNO (addr);                             \
2250   else if (GET_CODE (addr) == CONST_INT)                \
2251     offset = INTVAL (addr);                             \
2252   else if (GET_CODE (addr) == PLUS                      \
2253            && GET_CODE (XEXP (addr, 0)) == REG          \
2254            && GET_CODE (XEXP (addr, 1)) == CONST_INT)   \
2255     basereg = REGNO (XEXP (addr, 0)), offset = INTVAL (XEXP (addr, 1)); \
2256   else                                                  \
2257     abort ();                                           \
2258                                                         \
2259   fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, offset);              \
2260   fprintf (FILE, "($%d)", basereg);             \
2261 }
2262 /* Define the codes that are matched by predicates in alpha.c.  */
2263
2264 #define PREDICATE_CODES                                                 \
2265   {"reg_or_0_operand", {SUBREG, REG, CONST_INT}},                       \
2266   {"reg_or_6bit_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},    \
2267   {"reg_or_8bit_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},    \
2268   {"cint8_operand", {CONST_INT, CONSTANT_P_RTX}},                       \
2269   {"reg_or_cint_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},    \
2270   {"add_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},            \
2271   {"sext_add_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},       \
2272   {"const48_operand", {CONST_INT}},                                     \
2273   {"and_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},            \
2274   {"or_operand", {SUBREG, REG, CONST_INT, CONSTANT_P_RTX}},             \
2275   {"mode_mask_operand", {CONST_INT}},                                   \
2276   {"mul8_operand", {CONST_INT}},                                        \
2277   {"mode_width_operand", {CONST_INT}},                                  \
2278   {"reg_or_fp0_operand", {SUBREG, REG, CONST_DOUBLE}},                  \
2279   {"alpha_comparison_operator", {EQ, LE, LT, LEU, LTU}},                \
2280   {"alpha_swapped_comparison_operator", {EQ, GE, GT, GEU, GTU}},        \
2281   {"signed_comparison_operator", {EQ, NE, LE, LT, GE, GT}},             \
2282   {"divmod_operator", {DIV, MOD, UDIV, UMOD}},                          \
2283   {"fp0_operand", {CONST_DOUBLE}},                                      \
2284   {"current_file_function_operand", {SYMBOL_REF}},                      \
2285   {"call_operand", {REG, SYMBOL_REF}},                                  \
2286   {"input_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE,         \
2287                      SYMBOL_REF, CONST, LABEL_REF, CONSTANT_P_RTX}},    \
2288   {"some_operand", {SUBREG, REG, MEM, CONST_INT, CONST_DOUBLE,          \
2289                     SYMBOL_REF, CONST, LABEL_REF, CONSTANT_P_RTX}},     \
2290   {"aligned_memory_operand", {MEM}},                                    \
2291   {"unaligned_memory_operand", {MEM}},                                  \
2292   {"reg_or_unaligned_mem_operand", {SUBREG, REG, MEM}},                 \
2293   {"any_memory_operand", {MEM}},                                        \
2294   {"hard_fp_register_operand", {SUBREG, REG}},
2295 \f
2296 /* Tell collect that the object format is ECOFF.  */
2297 #define OBJECT_FORMAT_COFF
2298 #define EXTENDED_COFF
2299
2300 /* If we use NM, pass -g to it so it only lists globals.  */
2301 #define NM_FLAGS "-pg"
2302
2303 /* Definitions for debugging.  */
2304
2305 #define SDB_DEBUGGING_INFO              /* generate info for mips-tfile */
2306 #define DBX_DEBUGGING_INFO              /* generate embedded stabs */
2307 #define MIPS_DEBUGGING_INFO             /* MIPS specific debugging info */
2308
2309 #ifndef PREFERRED_DEBUGGING_TYPE        /* assume SDB_DEBUGGING_INFO */
2310 #define PREFERRED_DEBUGGING_TYPE  SDB_DEBUG
2311 #endif
2312
2313
2314 /* Correct the offset of automatic variables and arguments.  Note that
2315    the Alpha debug format wants all automatic variables and arguments
2316    to be in terms of two different offsets from the virtual frame pointer,
2317    which is the stack pointer before any adjustment in the function.
2318    The offset for the argument pointer is fixed for the native compiler,
2319    it is either zero (for the no arguments case) or large enough to hold
2320    all argument registers.
2321    The offset for the auto pointer is the fourth argument to the .frame
2322    directive (local_offset).
2323    To stay compatible with the native tools we use the same offsets
2324    from the virtual frame pointer and adjust the debugger arg/auto offsets
2325    accordingly. These debugger offsets are set up in output_prolog.  */
2326
2327 extern long alpha_arg_offset;
2328 extern long alpha_auto_offset;
2329 #define DEBUGGER_AUTO_OFFSET(X) \
2330   ((GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) + alpha_auto_offset)
2331 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET + alpha_arg_offset)
2332
2333
2334 #define ASM_OUTPUT_SOURCE_LINE(STREAM, LINE)                            \
2335   alpha_output_lineno (STREAM, LINE)
2336 extern void alpha_output_lineno ();
2337
2338 #define ASM_OUTPUT_SOURCE_FILENAME(STREAM, NAME)                        \
2339   alpha_output_filename (STREAM, NAME)
2340 extern void alpha_output_filename ();
2341
2342 /* mips-tfile.c limits us to strings of one page.  We must underestimate this
2343    number, because the real length runs past this up to the next
2344    continuation point.  This is really a dbxout.c bug.  */
2345 #define DBX_CONTIN_LENGTH 3000
2346
2347 /* By default, turn on GDB extensions.  */
2348 #define DEFAULT_GDB_EXTENSIONS 1
2349
2350 /* Stabs-in-ECOFF can't handle dbxout_function_end().  */
2351 #define NO_DBX_FUNCTION_END 1
2352
2353 /* If we are smuggling stabs through the ALPHA ECOFF object
2354    format, put a comment in front of the .stab<x> operation so
2355    that the ALPHA assembler does not choke.  The mips-tfile program
2356    will correctly put the stab into the object file.  */
2357
2358 #define ASM_STABS_OP    ((TARGET_GAS) ? ".stabs" : " #.stabs")
2359 #define ASM_STABN_OP    ((TARGET_GAS) ? ".stabn" : " #.stabn")
2360 #define ASM_STABD_OP    ((TARGET_GAS) ? ".stabd" : " #.stabd")
2361
2362 /* Forward references to tags are allowed.  */
2363 #define SDB_ALLOW_FORWARD_REFERENCES
2364
2365 /* Unknown tags are also allowed.  */
2366 #define SDB_ALLOW_UNKNOWN_REFERENCES
2367
2368 #define PUT_SDB_DEF(a)                                  \
2369 do {                                                    \
2370   fprintf (asm_out_file, "\t%s.def\t",                  \
2371            (TARGET_GAS) ? "" : "#");                    \
2372   ASM_OUTPUT_LABELREF (asm_out_file, a);                \
2373   fputc (';', asm_out_file);                            \
2374 } while (0)
2375
2376 #define PUT_SDB_PLAIN_DEF(a)                            \
2377 do {                                                    \
2378   fprintf (asm_out_file, "\t%s.def\t.%s;",              \
2379            (TARGET_GAS) ? "" : "#", (a));               \
2380 } while (0)
2381
2382 #define PUT_SDB_TYPE(a)                                 \
2383 do {                                                    \
2384   fprintf (asm_out_file, "\t.type\t0x%x;", (a));        \
2385 } while (0)
2386
2387 /* For block start and end, we create labels, so that
2388    later we can figure out where the correct offset is.
2389    The normal .ent/.end serve well enough for functions,
2390    so those are just commented out.  */
2391
2392 extern int sdb_label_count;             /* block start/end next label # */
2393
2394 #define PUT_SDB_BLOCK_START(LINE)                       \
2395 do {                                                    \
2396   fprintf (asm_out_file,                                \
2397            "$Lb%d:\n\t%s.begin\t$Lb%d\t%d\n",           \
2398            sdb_label_count,                             \
2399            (TARGET_GAS) ? "" : "#",                     \
2400            sdb_label_count,                             \
2401            (LINE));                                     \
2402   sdb_label_count++;                                    \
2403 } while (0)
2404
2405 #define PUT_SDB_BLOCK_END(LINE)                         \
2406 do {                                                    \
2407   fprintf (asm_out_file,                                \
2408            "$Le%d:\n\t%s.bend\t$Le%d\t%d\n",            \
2409            sdb_label_count,                             \
2410            (TARGET_GAS) ? "" : "#",                     \
2411            sdb_label_count,                             \
2412            (LINE));                                     \
2413   sdb_label_count++;                                    \
2414 } while (0)
2415
2416 #define PUT_SDB_FUNCTION_START(LINE)
2417
2418 #define PUT_SDB_FUNCTION_END(LINE)
2419
2420 #define PUT_SDB_EPILOGUE_END(NAME) ((void)(NAME))
2421
2422 /* Macros for mips-tfile.c to encapsulate stabs in ECOFF, and for
2423    mips-tdump.c to print them out.
2424
2425    These must match the corresponding definitions in gdb/mipsread.c.
2426    Unfortunately, gcc and gdb do not currently share any directories. */
2427
2428 #define CODE_MASK 0x8F300
2429 #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
2430 #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
2431 #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
2432
2433 /* Override some mips-tfile definitions.  */
2434
2435 #define SHASH_SIZE 511
2436 #define THASH_SIZE 55
2437
2438 /* Align ecoff symbol tables to avoid OSF1/1.3 nm complaints.  */
2439
2440 #define ALIGN_SYMTABLE_OFFSET(OFFSET) (((OFFSET) + 7) & ~7)
2441
2442 /* The linker will stick __main into the .init section.  */
2443 #define HAS_INIT_SECTION
2444 #define LD_INIT_SWITCH "-init"
2445 #define LD_FINI_SWITCH "-fini"
2446
2447 /* The system headers under Alpha systems are generally C++-aware.  */
2448 #define NO_IMPLICIT_EXTERN_C
2449
2450 /* Prototypes for alpha.c functions used in the md file & elsewhere.  */
2451 extern struct rtx_def *get_unaligned_address ();
2452 extern void alpha_write_verstamp ();
2453 extern void alpha_reorg ();
2454 extern int check_float_value ();
2455 extern int direct_return ();
2456 extern int const48_operand ();
2457 extern int add_operand ();
2458 extern int and_operand ();
2459 extern int unaligned_memory_operand ();
2460 extern int zap_mask ();
2461 extern int current_file_function_operand ();
2462 extern int alpha_sa_size ();
2463 extern int alpha_adjust_cost ();
2464 extern void print_operand ();
2465 extern int reg_or_0_operand ();
2466 extern int reg_or_8bit_operand ();
2467 extern int mul8_operand ();
2468 extern int reg_or_6bit_operand ();
2469 extern int alpha_comparison_operator ();
2470 extern int alpha_swapped_comparison_operator ();
2471 extern int sext_add_operand ();
2472 extern int cint8_operand ();
2473 extern int mode_mask_operand ();
2474 extern int or_operand ();
2475 extern int mode_width_operand ();
2476 extern int reg_or_fp0_operand ();
2477 extern int signed_comparison_operator ();
2478 extern int fp0_operand ();
2479 extern int some_operand ();
2480 extern int input_operand ();
2481 extern int divmod_operator ();
2482 extern int call_operand ();
2483 extern int reg_or_cint_operand ();
2484 extern int hard_fp_register_operand ();
2485 extern void alpha_set_memflags ();
2486 extern int aligned_memory_operand ();
2487 extern void get_aligned_mem ();
2488 extern void alpha_expand_unaligned_load ();
2489 extern void alpha_expand_unaligned_store ();
2490 extern int alpha_expand_block_move ();
2491 extern int alpha_expand_block_clear ();
2492 extern void alpha_expand_prologue ();
2493 extern void alpha_expand_epilogue ();