1 /* Subroutines used for code generation on the DEC Alpha.
2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001 Free Software Foundation, Inc.
4 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
34 #include "insn-attr.h"
45 #include "integrate.h"
48 #include "target-def.h"
51 extern int rtx_equal_function_value_matters
;
53 /* Specify which cpu to schedule for. */
55 enum processor_type alpha_cpu
;
56 static const char * const alpha_cpu_name
[] =
61 /* Specify how accurate floating-point traps need to be. */
63 enum alpha_trap_precision alpha_tp
;
65 /* Specify the floating-point rounding mode. */
67 enum alpha_fp_rounding_mode alpha_fprm
;
69 /* Specify which things cause traps. */
71 enum alpha_fp_trap_mode alpha_fptm
;
73 /* Strings decoded into the above options. */
75 const char *alpha_cpu_string
; /* -mcpu= */
76 const char *alpha_tune_string
; /* -mtune= */
77 const char *alpha_tp_string
; /* -mtrap-precision=[p|s|i] */
78 const char *alpha_fprm_string
; /* -mfp-rounding-mode=[n|m|c|d] */
79 const char *alpha_fptm_string
; /* -mfp-trap-mode=[n|u|su|sui] */
80 const char *alpha_mlat_string
; /* -mmemory-latency= */
82 /* Save information from a "cmpxx" operation until the branch or scc is
85 struct alpha_compare alpha_compare
;
87 /* Non-zero if inside of a function, because the Alpha asm can't
88 handle .files inside of functions. */
90 static int inside_function
= FALSE
;
92 /* The number of cycles of latency we should assume on memory reads. */
94 int alpha_memory_latency
= 3;
96 /* Whether the function needs the GP. */
98 static int alpha_function_needs_gp
;
100 /* The alias set for prologue/epilogue register save/restore. */
102 static int alpha_sr_alias_set
;
104 /* The assembler name of the current function. */
106 static const char *alpha_fnname
;
108 /* The next explicit relocation sequence number. */
109 int alpha_next_sequence_number
= 1;
111 /* The literal and gpdisp sequence numbers for this insn, as printed
112 by %# and %* respectively. */
113 int alpha_this_literal_sequence_number
;
114 int alpha_this_gpdisp_sequence_number
;
116 /* Declarations of static functions. */
117 static bool decl_in_text_section
119 static bool local_symbol_p
121 static void alpha_set_memflags_1
122 PARAMS ((rtx
, int, int, int));
123 static rtx alpha_emit_set_const_1
124 PARAMS ((rtx
, enum machine_mode
, HOST_WIDE_INT
, int));
125 static void alpha_expand_unaligned_load_words
126 PARAMS ((rtx
*out_regs
, rtx smem
, HOST_WIDE_INT words
, HOST_WIDE_INT ofs
));
127 static void alpha_expand_unaligned_store_words
128 PARAMS ((rtx
*out_regs
, rtx smem
, HOST_WIDE_INT words
, HOST_WIDE_INT ofs
));
129 static void alpha_sa_mask
130 PARAMS ((unsigned long *imaskP
, unsigned long *fmaskP
));
131 static int find_lo_sum
132 PARAMS ((rtx
*, void *));
133 static int alpha_does_function_need_gp
135 static int alpha_ra_ever_killed
137 static const char *get_trap_mode_suffix
139 static const char *get_round_mode_suffix
141 static rtx set_frame_related_p
143 static const char *alpha_lookup_xfloating_lib_func
144 PARAMS ((enum rtx_code
));
145 static int alpha_compute_xfloating_mode_arg
146 PARAMS ((enum rtx_code
, enum alpha_fp_rounding_mode
));
147 static void alpha_emit_xfloating_libcall
148 PARAMS ((const char *, rtx
, rtx
[], int, rtx
));
149 static rtx alpha_emit_xfloating_compare
150 PARAMS ((enum rtx_code
, rtx
, rtx
));
151 static void alpha_output_function_end_prologue
153 static int alpha_adjust_cost
154 PARAMS ((rtx
, rtx
, rtx
, int));
155 static int alpha_issue_rate
157 static int alpha_variable_issue
158 PARAMS ((FILE *, int, rtx
, int));
160 #if TARGET_ABI_UNICOSMK
161 static void alpha_init_machine_status
162 PARAMS ((struct function
*p
));
163 static void alpha_mark_machine_status
164 PARAMS ((struct function
*p
));
165 static void alpha_free_machine_status
166 PARAMS ((struct function
*p
));
169 static void unicosmk_output_deferred_case_vectors
PARAMS ((FILE *));
170 static void unicosmk_gen_dsib
PARAMS ((unsigned long *imaskP
));
171 static void unicosmk_output_ssib
PARAMS ((FILE *, const char *));
172 static int unicosmk_need_dex
PARAMS ((rtx
));
174 /* Get the number of args of a function in one of two ways. */
175 #if TARGET_ABI_OPEN_VMS || TARGET_ABI_UNICOSMK
176 #define NUM_ARGS current_function_args_info.num_args
178 #define NUM_ARGS current_function_args_info
184 /* Initialize the GCC target structure. */
185 #if TARGET_ABI_OPEN_VMS
186 const struct attribute_spec vms_attribute_table
[];
187 static unsigned int vms_section_type_flags
PARAMS ((tree
, const char *, int));
188 static void vms_asm_named_section
PARAMS ((const char *, unsigned int));
189 static void vms_asm_out_constructor
PARAMS ((rtx
, int));
190 static void vms_asm_out_destructor
PARAMS ((rtx
, int));
191 # undef TARGET_ATTRIBUTE_TABLE
192 # define TARGET_ATTRIBUTE_TABLE vms_attribute_table
193 # undef TARGET_SECTION_TYPE_FLAGS
194 # define TARGET_SECTION_TYPE_FLAGS vms_section_type_flags
197 #if TARGET_ABI_UNICOSMK
198 static void unicosmk_asm_named_section
PARAMS ((const char *, unsigned int));
199 static void unicosmk_insert_attributes
PARAMS ((tree
, tree
*));
200 static unsigned int unicosmk_section_type_flags
PARAMS ((tree
, const char *,
202 # undef TARGET_INSERT_ATTRIBUTES
203 # define TARGET_INSERT_ATTRIBUTES unicosmk_insert_attributes
204 # undef TARGET_SECTION_TYPE_FLAGS
205 # define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags
208 #undef TARGET_ASM_FUNCTION_END_PROLOGUE
209 #define TARGET_ASM_FUNCTION_END_PROLOGUE alpha_output_function_end_prologue
211 #undef TARGET_SCHED_ADJUST_COST
212 #define TARGET_SCHED_ADJUST_COST alpha_adjust_cost
213 #undef TARGET_SCHED_ISSUE_RATE
214 #define TARGET_SCHED_ISSUE_RATE alpha_issue_rate
215 #undef TARGET_SCHED_VARIABLE_ISSUE
216 #define TARGET_SCHED_VARIABLE_ISSUE alpha_variable_issue
218 struct gcc_target targetm
= TARGET_INITIALIZER
;
220 /* Parse target option strings. */
226 static const struct cpu_table
{
227 const char *const name
;
228 const enum processor_type processor
;
231 #define EV5_MASK (MASK_CPU_EV5)
232 #define EV6_MASK (MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX)
233 { "ev4", PROCESSOR_EV4
, 0 },
234 { "ev45", PROCESSOR_EV4
, 0 },
235 { "21064", PROCESSOR_EV4
, 0 },
236 { "ev5", PROCESSOR_EV5
, EV5_MASK
},
237 { "21164", PROCESSOR_EV5
, EV5_MASK
},
238 { "ev56", PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
},
239 { "21164a", PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
},
240 { "pca56", PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
|MASK_MAX
},
241 { "21164PC",PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
|MASK_MAX
},
242 { "21164pc",PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
|MASK_MAX
},
243 { "ev6", PROCESSOR_EV6
, EV6_MASK
},
244 { "21264", PROCESSOR_EV6
, EV6_MASK
},
245 { "ev67", PROCESSOR_EV6
, EV6_MASK
|MASK_CIX
},
246 { "21264a", PROCESSOR_EV6
, EV6_MASK
|MASK_CIX
},
250 /* Unicos/Mk doesn't have shared libraries. */
251 if (TARGET_ABI_UNICOSMK
&& flag_pic
)
253 warning ("-f%s ignored for Unicos/Mk (not supported)",
254 (flag_pic
> 1) ? "PIC" : "pic");
258 /* On Unicos/Mk, the native compiler consistenly generates /d suffices for
259 floating-point instructions. Make that the default for this target. */
260 if (TARGET_ABI_UNICOSMK
)
261 alpha_fprm
= ALPHA_FPRM_DYN
;
263 alpha_fprm
= ALPHA_FPRM_NORM
;
265 alpha_tp
= ALPHA_TP_PROG
;
266 alpha_fptm
= ALPHA_FPTM_N
;
268 /* We cannot use su and sui qualifiers for conversion instructions on
269 Unicos/Mk. I'm not sure if this is due to assembler or hardware
270 limitations. Right now, we issue a warning if -mieee is specified
271 and then ignore it; eventually, we should either get it right or
272 disable the option altogether. */
276 if (TARGET_ABI_UNICOSMK
)
277 warning ("-mieee not supported on Unicos/Mk");
280 alpha_tp
= ALPHA_TP_INSN
;
281 alpha_fptm
= ALPHA_FPTM_SU
;
285 if (TARGET_IEEE_WITH_INEXACT
)
287 if (TARGET_ABI_UNICOSMK
)
288 warning ("-mieee-with-inexact not supported on Unicos/Mk");
291 alpha_tp
= ALPHA_TP_INSN
;
292 alpha_fptm
= ALPHA_FPTM_SUI
;
298 if (! strcmp (alpha_tp_string
, "p"))
299 alpha_tp
= ALPHA_TP_PROG
;
300 else if (! strcmp (alpha_tp_string
, "f"))
301 alpha_tp
= ALPHA_TP_FUNC
;
302 else if (! strcmp (alpha_tp_string
, "i"))
303 alpha_tp
= ALPHA_TP_INSN
;
305 error ("bad value `%s' for -mtrap-precision switch", alpha_tp_string
);
308 if (alpha_fprm_string
)
310 if (! strcmp (alpha_fprm_string
, "n"))
311 alpha_fprm
= ALPHA_FPRM_NORM
;
312 else if (! strcmp (alpha_fprm_string
, "m"))
313 alpha_fprm
= ALPHA_FPRM_MINF
;
314 else if (! strcmp (alpha_fprm_string
, "c"))
315 alpha_fprm
= ALPHA_FPRM_CHOP
;
316 else if (! strcmp (alpha_fprm_string
,"d"))
317 alpha_fprm
= ALPHA_FPRM_DYN
;
319 error ("bad value `%s' for -mfp-rounding-mode switch",
323 if (alpha_fptm_string
)
325 if (strcmp (alpha_fptm_string
, "n") == 0)
326 alpha_fptm
= ALPHA_FPTM_N
;
327 else if (strcmp (alpha_fptm_string
, "u") == 0)
328 alpha_fptm
= ALPHA_FPTM_U
;
329 else if (strcmp (alpha_fptm_string
, "su") == 0)
330 alpha_fptm
= ALPHA_FPTM_SU
;
331 else if (strcmp (alpha_fptm_string
, "sui") == 0)
332 alpha_fptm
= ALPHA_FPTM_SUI
;
334 error ("bad value `%s' for -mfp-trap-mode switch", alpha_fptm_string
);
338 = TARGET_CPU_DEFAULT
& MASK_CPU_EV6
? PROCESSOR_EV6
339 : (TARGET_CPU_DEFAULT
& MASK_CPU_EV5
? PROCESSOR_EV5
: PROCESSOR_EV4
);
341 if (alpha_cpu_string
)
343 for (i
= 0; cpu_table
[i
].name
; i
++)
344 if (! strcmp (alpha_cpu_string
, cpu_table
[i
].name
))
346 alpha_cpu
= cpu_table
[i
].processor
;
347 target_flags
&= ~ (MASK_BWX
| MASK_MAX
| MASK_FIX
| MASK_CIX
348 | MASK_CPU_EV5
| MASK_CPU_EV6
);
349 target_flags
|= cpu_table
[i
].flags
;
352 if (! cpu_table
[i
].name
)
353 error ("bad value `%s' for -mcpu switch", alpha_cpu_string
);
356 if (alpha_tune_string
)
358 for (i
= 0; cpu_table
[i
].name
; i
++)
359 if (! strcmp (alpha_tune_string
, cpu_table
[i
].name
))
361 alpha_cpu
= cpu_table
[i
].processor
;
364 if (! cpu_table
[i
].name
)
365 error ("bad value `%s' for -mcpu switch", alpha_tune_string
);
368 /* Do some sanity checks on the above options. */
370 if (TARGET_ABI_UNICOSMK
&& alpha_fptm
!= ALPHA_FPTM_N
)
372 warning ("trap mode not supported on Unicos/Mk");
373 alpha_fptm
= ALPHA_FPTM_N
;
376 if ((alpha_fptm
== ALPHA_FPTM_SU
|| alpha_fptm
== ALPHA_FPTM_SUI
)
377 && alpha_tp
!= ALPHA_TP_INSN
&& ! TARGET_CPU_EV6
)
379 warning ("fp software completion requires -mtrap-precision=i");
380 alpha_tp
= ALPHA_TP_INSN
;
385 /* Except for EV6 pass 1 (not released), we always have precise
386 arithmetic traps. Which means we can do software completion
387 without minding trap shadows. */
388 alpha_tp
= ALPHA_TP_PROG
;
391 if (TARGET_FLOAT_VAX
)
393 if (alpha_fprm
== ALPHA_FPRM_MINF
|| alpha_fprm
== ALPHA_FPRM_DYN
)
395 warning ("rounding mode not supported for VAX floats");
396 alpha_fprm
= ALPHA_FPRM_NORM
;
398 if (alpha_fptm
== ALPHA_FPTM_SUI
)
400 warning ("trap mode not supported for VAX floats");
401 alpha_fptm
= ALPHA_FPTM_SU
;
409 if (!alpha_mlat_string
)
410 alpha_mlat_string
= "L1";
412 if (ISDIGIT ((unsigned char)alpha_mlat_string
[0])
413 && (lat
= strtol (alpha_mlat_string
, &end
, 10), *end
== '\0'))
415 else if ((alpha_mlat_string
[0] == 'L' || alpha_mlat_string
[0] == 'l')
416 && ISDIGIT ((unsigned char)alpha_mlat_string
[1])
417 && alpha_mlat_string
[2] == '\0')
419 static int const cache_latency
[][4] =
421 { 3, 30, -1 }, /* ev4 -- Bcache is a guess */
422 { 2, 12, 38 }, /* ev5 -- Bcache from PC164 LMbench numbers */
423 { 3, 12, 30 }, /* ev6 -- Bcache from DS20 LMbench. */
426 lat
= alpha_mlat_string
[1] - '0';
427 if (lat
<= 0 || lat
> 3 || cache_latency
[alpha_cpu
][lat
-1] == -1)
429 warning ("L%d cache latency unknown for %s",
430 lat
, alpha_cpu_name
[alpha_cpu
]);
434 lat
= cache_latency
[alpha_cpu
][lat
-1];
436 else if (! strcmp (alpha_mlat_string
, "main"))
438 /* Most current memories have about 370ns latency. This is
439 a reasonable guess for a fast cpu. */
444 warning ("bad value `%s' for -mmemory-latency", alpha_mlat_string
);
448 alpha_memory_latency
= lat
;
451 /* Default the definition of "small data" to 8 bytes. */
455 /* Infer TARGET_SMALL_DATA from -fpic/-fPIC. */
457 target_flags
|= MASK_SMALL_DATA
;
458 else if (flag_pic
== 2)
459 target_flags
&= ~MASK_SMALL_DATA
;
461 /* Align labels and loops for optimal branching. */
462 /* ??? Kludge these by not doing anything if we don't optimize and also if
463 we are writing ECOFF symbols to work around a bug in DEC's assembler. */
464 if (optimize
> 0 && write_symbols
!= SDB_DEBUG
)
466 if (align_loops
<= 0)
468 if (align_jumps
<= 0)
471 if (align_functions
<= 0)
472 align_functions
= 16;
474 /* Acquire a unique set number for our register saves and restores. */
475 alpha_sr_alias_set
= new_alias_set ();
477 /* Register variables and functions with the garbage collector. */
479 #if TARGET_ABI_UNICOSMK
480 /* Set up function hooks. */
481 init_machine_status
= alpha_init_machine_status
;
482 mark_machine_status
= alpha_mark_machine_status
;
483 free_machine_status
= alpha_free_machine_status
;
487 /* Returns 1 if VALUE is a mask that contains full bytes of zero or ones. */
495 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
;
497 if ((value
& 0xff) != 0 && (value
& 0xff) != 0xff)
503 /* Returns 1 if OP is either the constant zero or a register. If a
504 register, it must be in the proper mode unless MODE is VOIDmode. */
507 reg_or_0_operand (op
, mode
)
509 enum machine_mode mode
;
511 return op
== const0_rtx
|| register_operand (op
, mode
);
514 /* Return 1 if OP is a constant in the range of 0-63 (for a shift) or
518 reg_or_6bit_operand (op
, mode
)
520 enum machine_mode mode
;
522 return ((GET_CODE (op
) == CONST_INT
523 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 64)
524 || register_operand (op
, mode
));
528 /* Return 1 if OP is an 8-bit constant or any register. */
531 reg_or_8bit_operand (op
, mode
)
533 enum machine_mode mode
;
535 return ((GET_CODE (op
) == CONST_INT
536 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100)
537 || register_operand (op
, mode
));
540 /* Return 1 if OP is an 8-bit constant. */
543 cint8_operand (op
, mode
)
545 enum machine_mode mode ATTRIBUTE_UNUSED
;
547 return ((GET_CODE (op
) == CONST_INT
548 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100));
551 /* Return 1 if the operand is a valid second operand to an add insn. */
554 add_operand (op
, mode
)
556 enum machine_mode mode
;
558 if (GET_CODE (op
) == CONST_INT
)
559 /* Constraints I, J, O and P are covered by K. */
560 return (CONST_OK_FOR_LETTER_P (INTVAL (op
), 'K')
561 || CONST_OK_FOR_LETTER_P (INTVAL (op
), 'L'));
563 return register_operand (op
, mode
);
566 /* Return 1 if the operand is a valid second operand to a sign-extending
570 sext_add_operand (op
, mode
)
572 enum machine_mode mode
;
574 if (GET_CODE (op
) == CONST_INT
)
575 return (CONST_OK_FOR_LETTER_P (INTVAL (op
), 'I')
576 || CONST_OK_FOR_LETTER_P (INTVAL (op
), 'O'));
578 return reg_not_elim_operand (op
, mode
);
581 /* Return 1 if OP is the constant 4 or 8. */
584 const48_operand (op
, mode
)
586 enum machine_mode mode ATTRIBUTE_UNUSED
;
588 return (GET_CODE (op
) == CONST_INT
589 && (INTVAL (op
) == 4 || INTVAL (op
) == 8));
592 /* Return 1 if OP is a valid first operand to an AND insn. */
595 and_operand (op
, mode
)
597 enum machine_mode mode
;
599 if (GET_CODE (op
) == CONST_DOUBLE
&& GET_MODE (op
) == VOIDmode
)
600 return (zap_mask (CONST_DOUBLE_LOW (op
))
601 && zap_mask (CONST_DOUBLE_HIGH (op
)));
603 if (GET_CODE (op
) == CONST_INT
)
604 return ((unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100
605 || (unsigned HOST_WIDE_INT
) ~ INTVAL (op
) < 0x100
606 || zap_mask (INTVAL (op
)));
608 return register_operand (op
, mode
);
611 /* Return 1 if OP is a valid first operand to an IOR or XOR insn. */
614 or_operand (op
, mode
)
616 enum machine_mode mode
;
618 if (GET_CODE (op
) == CONST_INT
)
619 return ((unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100
620 || (unsigned HOST_WIDE_INT
) ~ INTVAL (op
) < 0x100);
622 return register_operand (op
, mode
);
625 /* Return 1 if OP is a constant that is the width, in bits, of an integral
626 mode smaller than DImode. */
629 mode_width_operand (op
, mode
)
631 enum machine_mode mode ATTRIBUTE_UNUSED
;
633 return (GET_CODE (op
) == CONST_INT
634 && (INTVAL (op
) == 8 || INTVAL (op
) == 16
635 || INTVAL (op
) == 32 || INTVAL (op
) == 64));
638 /* Return 1 if OP is a constant that is the width of an integral machine mode
639 smaller than an integer. */
642 mode_mask_operand (op
, mode
)
644 enum machine_mode mode ATTRIBUTE_UNUSED
;
646 #if HOST_BITS_PER_WIDE_INT == 32
647 if (GET_CODE (op
) == CONST_DOUBLE
)
648 return (CONST_DOUBLE_LOW (op
) == -1
649 && (CONST_DOUBLE_HIGH (op
) == -1
650 || CONST_DOUBLE_HIGH (op
) == 0));
652 if (GET_CODE (op
) == CONST_DOUBLE
)
653 return (CONST_DOUBLE_LOW (op
) == -1 && CONST_DOUBLE_HIGH (op
) == 0);
656 return (GET_CODE (op
) == CONST_INT
657 && (INTVAL (op
) == 0xff
658 || INTVAL (op
) == 0xffff
659 || INTVAL (op
) == (HOST_WIDE_INT
)0xffffffff
660 #if HOST_BITS_PER_WIDE_INT == 64
666 /* Return 1 if OP is a multiple of 8 less than 64. */
669 mul8_operand (op
, mode
)
671 enum machine_mode mode ATTRIBUTE_UNUSED
;
673 return (GET_CODE (op
) == CONST_INT
674 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 64
675 && (INTVAL (op
) & 7) == 0);
678 /* Return 1 if OP is the constant zero in floating-point. */
681 fp0_operand (op
, mode
)
683 enum machine_mode mode
;
685 return (GET_MODE (op
) == mode
686 && GET_MODE_CLASS (mode
) == MODE_FLOAT
&& op
== CONST0_RTX (mode
));
689 /* Return 1 if OP is the floating-point constant zero or a register. */
692 reg_or_fp0_operand (op
, mode
)
694 enum machine_mode mode
;
696 return fp0_operand (op
, mode
) || register_operand (op
, mode
);
699 /* Return 1 if OP is a hard floating-point register. */
702 hard_fp_register_operand (op
, mode
)
704 enum machine_mode mode
;
706 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
709 if (GET_CODE (op
) == SUBREG
)
710 op
= SUBREG_REG (op
);
711 return GET_CODE (op
) == REG
&& REGNO_REG_CLASS (REGNO (op
)) == FLOAT_REGS
;
714 /* Return 1 if OP is a hard general register. */
717 hard_int_register_operand (op
, mode
)
719 enum machine_mode mode
;
721 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
724 if (GET_CODE (op
) == SUBREG
)
725 op
= SUBREG_REG (op
);
726 return GET_CODE (op
) == REG
&& REGNO_REG_CLASS (REGNO (op
)) == GENERAL_REGS
;
729 /* Return 1 if OP is a register or a constant integer. */
733 reg_or_cint_operand (op
, mode
)
735 enum machine_mode mode
;
737 return (GET_CODE (op
) == CONST_INT
738 || register_operand (op
, mode
));
741 /* Return 1 if OP is something that can be reloaded into a register;
742 if it is a MEM, it need not be valid. */
745 some_operand (op
, mode
)
747 enum machine_mode mode
;
749 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
752 switch (GET_CODE (op
))
754 case REG
: case MEM
: case CONST_DOUBLE
: case CONST_INT
: case LABEL_REF
:
755 case SYMBOL_REF
: case CONST
:
759 return some_operand (SUBREG_REG (op
), VOIDmode
);
768 /* Likewise, but don't accept constants. */
771 some_ni_operand (op
, mode
)
773 enum machine_mode mode
;
775 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
778 if (GET_CODE (op
) == SUBREG
)
779 op
= SUBREG_REG (op
);
781 return (GET_CODE (op
) == REG
|| GET_CODE (op
) == MEM
);
784 /* Return 1 if OP is a valid operand for the source of a move insn. */
787 input_operand (op
, mode
)
789 enum machine_mode mode
;
791 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
794 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
&& GET_MODE (op
) != mode
)
797 switch (GET_CODE (op
))
802 if (TARGET_EXPLICIT_RELOCS
)
805 /* This handles both the Windows/NT and OSF cases. */
806 return mode
== ptr_mode
|| mode
== DImode
;
813 if (register_operand (op
, mode
))
815 /* ... fall through ... */
817 return ((TARGET_BWX
|| (mode
!= HImode
&& mode
!= QImode
))
818 && general_operand (op
, mode
));
821 return GET_MODE_CLASS (mode
) == MODE_FLOAT
&& op
== CONST0_RTX (mode
);
824 return mode
== QImode
|| mode
== HImode
|| add_operand (op
, mode
);
836 /* Return 1 if OP is a SYMBOL_REF for a function known to be in this
837 file, and in the same section as the current function. */
840 current_file_function_operand (op
, mode
)
842 enum machine_mode mode ATTRIBUTE_UNUSED
;
844 if (GET_CODE (op
) != SYMBOL_REF
)
847 /* Easy test for recursion. */
848 if (op
== XEXP (DECL_RTL (current_function_decl
), 0))
851 /* Otherwise, we need the DECL for the SYMBOL_REF, which we can't get.
852 So SYMBOL_REF_FLAG has been declared to imply that the function is
853 in the default text section. So we must also check that the current
854 function is also in the text section. */
855 if (SYMBOL_REF_FLAG (op
) && decl_in_text_section (current_function_decl
))
861 /* Return 1 if OP is a SYMBOL_REF for which we can make a call via bsr. */
864 direct_call_operand (op
, mode
)
866 enum machine_mode mode
;
868 /* Must be defined in this file. */
869 if (! current_file_function_operand (op
, mode
))
872 /* If profiling is implemented via linker tricks, we can't jump
873 to the nogp alternate entry point. */
874 /* ??? TARGET_PROFILING_NEEDS_GP isn't really the right test,
875 but is approximately correct for the OSF ABIs. Don't know
876 what to do for VMS, NT, or UMK. */
877 if (! TARGET_PROFILING_NEEDS_GP
884 /* Return true if OP is a LABEL_REF, or SYMBOL_REF or CONST referencing
885 a variable known to be defined in this file. */
891 const char *str
= XSTR (op
, 0);
893 /* ??? SYMBOL_REF_FLAG is set for local function symbols, but we
894 run into problems with the rtl inliner in that the symbol was
895 once external, but is local after inlining, which results in
896 unrecognizable insns. */
898 return (CONSTANT_POOL_ADDRESS_P (op
)
899 /* If @, then ENCODE_SECTION_INFO sez it's local. */
901 /* If *$, then ASM_GENERATE_INTERNAL_LABEL sez it's local. */
902 || (str
[0] == '*' && str
[1] == '$'));
906 local_symbolic_operand (op
, mode
)
908 enum machine_mode mode
;
910 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
913 if (GET_CODE (op
) == LABEL_REF
)
916 if (GET_CODE (op
) == CONST
917 && GET_CODE (XEXP (op
, 0)) == PLUS
918 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
919 op
= XEXP (XEXP (op
, 0), 0);
921 if (GET_CODE (op
) != SYMBOL_REF
)
924 return local_symbol_p (op
);
927 /* Return true if OP is a SYMBOL_REF or CONST referencing a variable
928 known to be defined in this file in the small data area. */
931 small_symbolic_operand (op
, mode
)
933 enum machine_mode mode ATTRIBUTE_UNUSED
;
937 if (! TARGET_SMALL_DATA
)
940 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
943 if (GET_CODE (op
) == CONST
944 && GET_CODE (XEXP (op
, 0)) == PLUS
945 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
946 op
= XEXP (XEXP (op
, 0), 0);
948 if (GET_CODE (op
) != SYMBOL_REF
)
951 if (CONSTANT_POOL_ADDRESS_P (op
))
952 return GET_MODE_SIZE (get_pool_mode (op
)) <= (unsigned) g_switch_value
;
956 return str
[0] == '@' && str
[1] == 's';
960 /* Return true if OP is a SYMBOL_REF or CONST referencing a variable
961 not known (or known not) to be defined in this file. */
964 global_symbolic_operand (op
, mode
)
966 enum machine_mode mode
;
968 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
971 if (GET_CODE (op
) == CONST
972 && GET_CODE (XEXP (op
, 0)) == PLUS
973 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
974 op
= XEXP (XEXP (op
, 0), 0);
976 if (GET_CODE (op
) != SYMBOL_REF
)
979 return ! local_symbol_p (op
);
982 /* Return 1 if OP is a valid operand for the MEM of a CALL insn. */
985 call_operand (op
, mode
)
987 enum machine_mode mode
;
992 if (GET_CODE (op
) == REG
)
995 return REGNO (op
) == 27;
999 if (TARGET_ABI_UNICOSMK
)
1001 if (GET_CODE (op
) == SYMBOL_REF
)
1007 /* Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
1008 possibly with an offset. */
1011 symbolic_operand (op
, mode
)
1013 enum machine_mode mode
;
1015 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1017 if (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == LABEL_REF
)
1019 if (GET_CODE (op
) == CONST
1020 && GET_CODE (XEXP (op
,0)) == PLUS
1021 && GET_CODE (XEXP (XEXP (op
,0), 0)) == SYMBOL_REF
1022 && GET_CODE (XEXP (XEXP (op
,0), 1)) == CONST_INT
)
1027 /* Return 1 if OP is a valid Alpha comparison operator. Here we know which
1028 comparisons are valid in which insn. */
1031 alpha_comparison_operator (op
, mode
)
1033 enum machine_mode mode
;
1035 enum rtx_code code
= GET_CODE (op
);
1037 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1040 return (code
== EQ
|| code
== LE
|| code
== LT
1041 || code
== LEU
|| code
== LTU
);
1044 /* Return 1 if OP is a valid Alpha comparison operator against zero.
1045 Here we know which comparisons are valid in which insn. */
1048 alpha_zero_comparison_operator (op
, mode
)
1050 enum machine_mode mode
;
1052 enum rtx_code code
= GET_CODE (op
);
1054 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1057 return (code
== EQ
|| code
== NE
|| code
== LE
|| code
== LT
1058 || code
== LEU
|| code
== LTU
);
1061 /* Return 1 if OP is a valid Alpha swapped comparison operator. */
1064 alpha_swapped_comparison_operator (op
, mode
)
1066 enum machine_mode mode
;
1068 enum rtx_code code
= GET_CODE (op
);
1070 if ((mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1071 || GET_RTX_CLASS (code
) != '<')
1074 code
= swap_condition (code
);
1075 return (code
== EQ
|| code
== LE
|| code
== LT
1076 || code
== LEU
|| code
== LTU
);
1079 /* Return 1 if OP is a signed comparison operation. */
1082 signed_comparison_operator (op
, mode
)
1084 enum machine_mode mode ATTRIBUTE_UNUSED
;
1086 enum rtx_code code
= GET_CODE (op
);
1088 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1091 return (code
== EQ
|| code
== NE
1092 || code
== LE
|| code
== LT
1093 || code
== GE
|| code
== GT
);
1096 /* Return 1 if OP is a valid Alpha floating point comparison operator.
1097 Here we know which comparisons are valid in which insn. */
1100 alpha_fp_comparison_operator (op
, mode
)
1102 enum machine_mode mode
;
1104 enum rtx_code code
= GET_CODE (op
);
1106 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1109 return (code
== EQ
|| code
== LE
|| code
== LT
|| code
== UNORDERED
);
1112 /* Return 1 if this is a divide or modulus operator. */
1115 divmod_operator (op
, mode
)
1117 enum machine_mode mode ATTRIBUTE_UNUSED
;
1119 switch (GET_CODE (op
))
1121 case DIV
: case MOD
: case UDIV
: case UMOD
:
1131 /* Return 1 if this memory address is a known aligned register plus
1132 a constant. It must be a valid address. This means that we can do
1133 this as an aligned reference plus some offset.
1135 Take into account what reload will do. */
1138 aligned_memory_operand (op
, mode
)
1140 enum machine_mode mode
;
1144 if (reload_in_progress
)
1147 if (GET_CODE (tmp
) == SUBREG
)
1148 tmp
= SUBREG_REG (tmp
);
1149 if (GET_CODE (tmp
) == REG
1150 && REGNO (tmp
) >= FIRST_PSEUDO_REGISTER
)
1152 op
= reg_equiv_memory_loc
[REGNO (tmp
)];
1158 if (GET_CODE (op
) != MEM
1159 || GET_MODE (op
) != mode
)
1163 /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
1164 sorts of constructs. Dig for the real base register. */
1165 if (reload_in_progress
1166 && GET_CODE (op
) == PLUS
1167 && GET_CODE (XEXP (op
, 0)) == PLUS
)
1168 base
= XEXP (XEXP (op
, 0), 0);
1171 if (! memory_address_p (mode
, op
))
1173 base
= (GET_CODE (op
) == PLUS
? XEXP (op
, 0) : op
);
1176 return (GET_CODE (base
) == REG
&& REGNO_POINTER_ALIGN (REGNO (base
)) >= 32);
1179 /* Similar, but return 1 if OP is a MEM which is not alignable. */
1182 unaligned_memory_operand (op
, mode
)
1184 enum machine_mode mode
;
1188 if (reload_in_progress
)
1191 if (GET_CODE (tmp
) == SUBREG
)
1192 tmp
= SUBREG_REG (tmp
);
1193 if (GET_CODE (tmp
) == REG
1194 && REGNO (tmp
) >= FIRST_PSEUDO_REGISTER
)
1196 op
= reg_equiv_memory_loc
[REGNO (tmp
)];
1202 if (GET_CODE (op
) != MEM
1203 || GET_MODE (op
) != mode
)
1207 /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
1208 sorts of constructs. Dig for the real base register. */
1209 if (reload_in_progress
1210 && GET_CODE (op
) == PLUS
1211 && GET_CODE (XEXP (op
, 0)) == PLUS
)
1212 base
= XEXP (XEXP (op
, 0), 0);
1215 if (! memory_address_p (mode
, op
))
1217 base
= (GET_CODE (op
) == PLUS
? XEXP (op
, 0) : op
);
1220 return (GET_CODE (base
) == REG
&& REGNO_POINTER_ALIGN (REGNO (base
)) < 32);
1223 /* Return 1 if OP is either a register or an unaligned memory location. */
1226 reg_or_unaligned_mem_operand (op
, mode
)
1228 enum machine_mode mode
;
1230 return register_operand (op
, mode
) || unaligned_memory_operand (op
, mode
);
1233 /* Return 1 if OP is any memory location. During reload a pseudo matches. */
1236 any_memory_operand (op
, mode
)
1238 enum machine_mode mode ATTRIBUTE_UNUSED
;
1240 return (GET_CODE (op
) == MEM
1241 || (GET_CODE (op
) == SUBREG
&& GET_CODE (SUBREG_REG (op
)) == REG
)
1242 || (reload_in_progress
&& GET_CODE (op
) == REG
1243 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
)
1244 || (reload_in_progress
&& GET_CODE (op
) == SUBREG
1245 && GET_CODE (SUBREG_REG (op
)) == REG
1246 && REGNO (SUBREG_REG (op
)) >= FIRST_PSEUDO_REGISTER
));
1249 /* Returns 1 if OP is not an eliminable register.
1251 This exists to cure a pathological abort in the s8addq (et al) patterns,
1253 long foo () { long t; bar(); return (long) &t * 26107; }
1255 which run afoul of a hack in reload to cure a (presumably) similar
1256 problem with lea-type instructions on other targets. But there is
1257 one of us and many of them, so work around the problem by selectively
1258 preventing combine from making the optimization. */
1261 reg_not_elim_operand (op
, mode
)
1263 enum machine_mode mode
;
1266 if (GET_CODE (op
) == SUBREG
)
1267 inner
= SUBREG_REG (op
);
1268 if (inner
== frame_pointer_rtx
|| inner
== arg_pointer_rtx
)
1271 return register_operand (op
, mode
);
1274 /* Return 1 is OP is a memory location that is not a reference (using
1275 an AND) to an unaligned location. Take into account what reload
1279 normal_memory_operand (op
, mode
)
1281 enum machine_mode mode ATTRIBUTE_UNUSED
;
1283 if (reload_in_progress
)
1286 if (GET_CODE (tmp
) == SUBREG
)
1287 tmp
= SUBREG_REG (tmp
);
1288 if (GET_CODE (tmp
) == REG
1289 && REGNO (tmp
) >= FIRST_PSEUDO_REGISTER
)
1291 op
= reg_equiv_memory_loc
[REGNO (tmp
)];
1293 /* This may not have been assigned an equivalent address if it will
1294 be eliminated. In that case, it doesn't matter what we do. */
1300 return GET_CODE (op
) == MEM
&& GET_CODE (XEXP (op
, 0)) != AND
;
1303 /* Accept a register, but not a subreg of any kind. This allows us to
1304 avoid pathological cases in reload wrt data movement common in
1305 int->fp conversion. */
1308 reg_no_subreg_operand (op
, mode
)
1310 enum machine_mode mode
;
1312 if (GET_CODE (op
) == SUBREG
)
1314 return register_operand (op
, mode
);
1317 /* Recognize an addition operation that includes a constant. Used to
1318 convince reload to canonize (plus (plus reg c1) c2) during register
1322 addition_operation (op
, mode
)
1324 enum machine_mode mode
;
1326 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1328 if (GET_CODE (op
) == PLUS
1329 && register_operand (XEXP (op
, 0), mode
)
1330 && GET_CODE (XEXP (op
, 1)) == CONST_INT
1331 && CONST_OK_FOR_LETTER_P (INTVAL (XEXP (op
, 1)), 'K'))
1336 /* Return 1 if this function can directly return via $26. */
1341 return (! TARGET_ABI_OPEN_VMS
&& ! TARGET_ABI_UNICOSMK
1343 && alpha_sa_size () == 0
1344 && get_frame_size () == 0
1345 && current_function_outgoing_args_size
== 0
1346 && current_function_pretend_args_size
== 0);
1349 /* Return the ADDR_VEC associated with a tablejump insn. */
1352 alpha_tablejump_addr_vec (insn
)
1357 tmp
= JUMP_LABEL (insn
);
1360 tmp
= NEXT_INSN (tmp
);
1363 if (GET_CODE (tmp
) == JUMP_INSN
1364 && GET_CODE (PATTERN (tmp
)) == ADDR_DIFF_VEC
)
1365 return PATTERN (tmp
);
1369 /* Return the label of the predicted edge, or CONST0_RTX if we don't know. */
1372 alpha_tablejump_best_label (insn
)
1375 rtx jump_table
= alpha_tablejump_addr_vec (insn
);
1376 rtx best_label
= NULL_RTX
;
1378 /* ??? Once the CFG doesn't keep getting completely rebuilt, look
1379 there for edge frequency counts from profile data. */
1383 int n_labels
= XVECLEN (jump_table
, 1);
1384 int best_count
= -1;
1387 for (i
= 0; i
< n_labels
; i
++)
1391 for (j
= i
+ 1; j
< n_labels
; j
++)
1392 if (XEXP (XVECEXP (jump_table
, 1, i
), 0)
1393 == XEXP (XVECEXP (jump_table
, 1, j
), 0))
1396 if (count
> best_count
)
1397 best_count
= count
, best_label
= XVECEXP (jump_table
, 1, i
);
1401 return best_label
? best_label
: const0_rtx
;
1404 /* Return true if the function DECL will be placed in the default text
1406 /* ??? Ideally we'd be able to always move from a SYMBOL_REF back to the
1407 decl, as that would allow us to determine if two functions are in the
1408 same section, which is what we really want to know. */
1411 decl_in_text_section (decl
)
1414 return (DECL_SECTION_NAME (decl
) == NULL_TREE
1415 && ! (flag_function_sections
1416 || (targetm
.have_named_sections
1417 && DECL_ONE_ONLY (decl
))));
1420 /* If we are referencing a function that is static, make the SYMBOL_REF
1421 special. We use this to see indicate we can branch to this function
1422 without setting PV or restoring GP.
1424 If this is a variable that is known to be defined locally, add "@v"
1425 to the name. If in addition the variable is to go in .sdata/.sbss,
1426 then add "@s" instead. */
1429 alpha_encode_section_info (decl
)
1432 const char *symbol_str
;
1433 bool is_local
, is_small
;
1435 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1437 /* We mark public functions once they are emitted; otherwise we
1438 don't know that they exist in this unit of translation. */
1439 if (TREE_PUBLIC (decl
))
1441 /* Do not mark functions that are not in .text; otherwise we
1442 don't know that they are near enough for a direct branch. */
1443 if (! decl_in_text_section (decl
))
1446 SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl
), 0)) = 1;
1450 /* Early out if we're not going to do anything with this data. */
1451 if (! TARGET_EXPLICIT_RELOCS
)
1454 /* Careful not to prod global register variables. */
1455 if (TREE_CODE (decl
) != VAR_DECL
1456 || GET_CODE (DECL_RTL (decl
)) != MEM
1457 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1460 symbol_str
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1462 /* A variable is considered "local" if it is defined in this module. */
1464 if (DECL_EXTERNAL (decl
))
1466 /* Linkonce and weak data is never local. */
1467 else if (DECL_ONE_ONLY (decl
) || DECL_WEAK (decl
))
1469 else if (! TREE_PUBLIC (decl
))
1471 /* If PIC, then assume that any global name can be overridden by
1472 symbols resolved from other modules. */
1475 /* Uninitialized COMMON variable may be unified with symbols
1476 resolved from other modules. */
1477 else if (DECL_COMMON (decl
)
1478 && (DECL_INITIAL (decl
) == NULL
1479 || DECL_INITIAL (decl
) == error_mark_node
))
1481 /* Otherwise we're left with initialized (or non-common) global data
1482 which is of necessity defined locally. */
1486 /* Determine if DECL will wind up in .sdata/.sbss. */
1489 if (DECL_SECTION_NAME (decl
))
1491 const char *section
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
1492 if (strcmp (section
, ".sdata") == 0
1493 || strcmp (section
, ".sbss") == 0)
1498 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (decl
));
1500 /* If the variable has already been defined in the output file, then it
1501 is too late to put it in sdata if it wasn't put there in the first
1502 place. The test is here rather than above, because if it is already
1503 in sdata, then it can stay there. */
1505 if (TREE_ASM_WRITTEN (decl
))
1508 /* If this is an incomplete type with size 0, then we can't put it in
1509 sdata because it might be too big when completed. */
1510 else if (size
> 0 && size
<= g_switch_value
)
1514 /* Finally, encode this into the symbol string. */
1521 if (symbol_str
[0] == '@')
1523 if (symbol_str
[1] == (is_small
? 's' : 'v'))
1528 len
= strlen (symbol_str
) + 1;
1529 newstr
= alloca (len
+ 2);
1532 newstr
[1] = (is_small
? 's' : 'v');
1533 memcpy (newstr
+ 2, symbol_str
, len
);
1535 string
= ggc_alloc_string (newstr
, len
+ 2 - 1);
1536 XSTR (XEXP (DECL_RTL (decl
), 0), 0) = string
;
1538 else if (symbol_str
[0] == '@')
1542 /* legitimate_address_p recognizes an RTL expression that is a valid
1543 memory address for an instruction. The MODE argument is the
1544 machine mode for the MEM expression that wants to use this address.
1546 For Alpha, we have either a constant address or the sum of a
1547 register and a constant address, or just a register. For DImode,
1548 any of those forms can be surrounded with an AND that clear the
1549 low-order three bits; this is an "unaligned" access. */
1552 alpha_legitimate_address_p (mode
, x
, strict
)
1553 enum machine_mode mode
;
1557 /* If this is an ldq_u type address, discard the outer AND. */
1559 && GET_CODE (x
) == AND
1560 && GET_CODE (XEXP (x
, 1)) == CONST_INT
1561 && INTVAL (XEXP (x
, 1)) == -8)
1564 /* Discard non-paradoxical subregs. */
1565 if (GET_CODE (x
) == SUBREG
1566 && (GET_MODE_SIZE (GET_MODE (x
))
1567 < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
1570 /* Unadorned general registers are valid. */
1573 ? STRICT_REG_OK_FOR_BASE_P (x
)
1574 : NONSTRICT_REG_OK_FOR_BASE_P (x
)))
1577 /* Constant addresses (i.e. +/- 32k) are valid. */
1578 if (CONSTANT_ADDRESS_P (x
))
1581 /* Register plus a small constant offset is valid. */
1582 if (GET_CODE (x
) == PLUS
)
1584 rtx ofs
= XEXP (x
, 1);
1587 /* Discard non-paradoxical subregs. */
1588 if (GET_CODE (x
) == SUBREG
1589 && (GET_MODE_SIZE (GET_MODE (x
))
1590 < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
1596 && NONSTRICT_REG_OK_FP_BASE_P (x
)
1597 && GET_CODE (ofs
) == CONST_INT
)
1600 ? STRICT_REG_OK_FOR_BASE_P (x
)
1601 : NONSTRICT_REG_OK_FOR_BASE_P (x
))
1602 && CONSTANT_ADDRESS_P (ofs
))
1605 else if (GET_CODE (x
) == ADDRESSOF
1606 && GET_CODE (ofs
) == CONST_INT
)
1610 /* If we're managing explicit relocations, LO_SUM is valid. */
1611 else if (TARGET_EXPLICIT_RELOCS
&& GET_CODE (x
) == LO_SUM
)
1613 rtx ofs
= XEXP (x
, 1);
1616 /* Discard non-paradoxical subregs. */
1617 if (GET_CODE (x
) == SUBREG
1618 && (GET_MODE_SIZE (GET_MODE (x
))
1619 < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
1622 /* Must have a valid base register. */
1625 ? STRICT_REG_OK_FOR_BASE_P (x
)
1626 : NONSTRICT_REG_OK_FOR_BASE_P (x
))))
1629 /* The symbol must be local. */
1630 if (local_symbolic_operand (ofs
, Pmode
))
1637 /* Try machine-dependent ways of modifying an illegitimate address
1638 to be legitimate. If we find one, return the new, valid address. */
1641 alpha_legitimize_address (x
, oldx
, mode
)
1643 rtx oldx ATTRIBUTE_UNUSED
;
1644 enum machine_mode mode ATTRIBUTE_UNUSED
;
1646 HOST_WIDE_INT addend
;
1648 /* If the address is (plus reg const_int) and the CONST_INT is not a
1649 valid offset, compute the high part of the constant and add it to
1650 the register. Then our address is (plus temp low-part-const). */
1651 if (GET_CODE (x
) == PLUS
1652 && GET_CODE (XEXP (x
, 0)) == REG
1653 && GET_CODE (XEXP (x
, 1)) == CONST_INT
1654 && ! CONSTANT_ADDRESS_P (XEXP (x
, 1)))
1656 addend
= INTVAL (XEXP (x
, 1));
1661 /* If the address is (const (plus FOO const_int)), find the low-order
1662 part of the CONST_INT. Then load FOO plus any high-order part of the
1663 CONST_INT into a register. Our address is (plus reg low-part-const).
1664 This is done to reduce the number of GOT entries. */
1665 if (GET_CODE (x
) == CONST
1666 && GET_CODE (XEXP (x
, 0)) == PLUS
1667 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
)
1669 addend
= INTVAL (XEXP (XEXP (x
, 0), 1));
1670 x
= force_reg (Pmode
, XEXP (XEXP (x
, 0), 0));
1674 /* If we have a (plus reg const), emit the load as in (2), then add
1675 the two registers, and finally generate (plus reg low-part-const) as
1677 if (GET_CODE (x
) == PLUS
1678 && GET_CODE (XEXP (x
, 0)) == REG
1679 && GET_CODE (XEXP (x
, 1)) == CONST
1680 && GET_CODE (XEXP (XEXP (x
, 1), 0)) == PLUS
1681 && GET_CODE (XEXP (XEXP (XEXP (x
, 1), 0), 1)) == CONST_INT
)
1683 addend
= INTVAL (XEXP (XEXP (XEXP (x
, 1), 0), 1));
1684 x
= expand_simple_binop (Pmode
, PLUS
, XEXP (x
, 0),
1685 XEXP (XEXP (XEXP (x
, 1), 0), 0),
1686 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1690 /* If this is a local symbol, split the address into HIGH/LO_SUM parts. */
1691 if (TARGET_EXPLICIT_RELOCS
&& symbolic_operand (x
, Pmode
))
1694 if (local_symbolic_operand (x
, Pmode
))
1696 if (small_symbolic_operand (x
, Pmode
))
1697 scratch
= pic_offset_table_rtx
;
1702 scratch
= gen_reg_rtx (Pmode
);
1704 tmp
= gen_rtx_HIGH (Pmode
, x
);
1705 tmp
= gen_rtx_PLUS (Pmode
, pic_offset_table_rtx
, tmp
);
1706 insn
= emit_insn (gen_rtx_SET (VOIDmode
, scratch
, tmp
));
1707 REG_NOTES (insn
) = gen_rtx_EXPR_LIST (REG_EQUAL
, tmp
,
1711 return gen_rtx_LO_SUM (Pmode
, scratch
, x
);
1715 scratch
= gen_reg_rtx (Pmode
);
1716 emit_insn (gen_movdi_er_high_g (scratch
, pic_offset_table_rtx
,
1718 /* ??? FIXME: Tag the use of scratch with a lituse. */
1727 HOST_WIDE_INT lowpart
= (addend
& 0xffff) - 2 * (addend
& 0x8000);
1728 HOST_WIDE_INT highpart
= addend
- lowpart
;
1729 x
= expand_simple_binop (Pmode
, PLUS
, x
, GEN_INT (highpart
),
1730 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
1731 return plus_constant (x
, lowpart
);
1735 /* Try a machine-dependent way of reloading an illegitimate address
1736 operand. If we find one, push the reload and return the new rtx. */
1739 alpha_legitimize_reload_address (x
, mode
, opnum
, type
, ind_levels
)
1741 enum machine_mode mode ATTRIBUTE_UNUSED
;
1744 int ind_levels ATTRIBUTE_UNUSED
;
1746 /* We must recognize output that we have already generated ourselves. */
1747 if (GET_CODE (x
) == PLUS
1748 && GET_CODE (XEXP (x
, 0)) == PLUS
1749 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == REG
1750 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
1751 && GET_CODE (XEXP (x
, 1)) == CONST_INT
)
1753 push_reload (XEXP (x
, 0), NULL_RTX
, &XEXP (x
, 0), NULL
,
1754 BASE_REG_CLASS
, GET_MODE (x
), VOIDmode
, 0, 0,
1759 /* We wish to handle large displacements off a base register by
1760 splitting the addend across an ldah and the mem insn. This
1761 cuts number of extra insns needed from 3 to 1. */
1762 if (GET_CODE (x
) == PLUS
1763 && GET_CODE (XEXP (x
, 0)) == REG
1764 && REGNO (XEXP (x
, 0)) < FIRST_PSEUDO_REGISTER
1765 && REGNO_OK_FOR_BASE_P (REGNO (XEXP (x
, 0)))
1766 && GET_CODE (XEXP (x
, 1)) == CONST_INT
)
1768 HOST_WIDE_INT val
= INTVAL (XEXP (x
, 1));
1769 HOST_WIDE_INT low
= ((val
& 0xffff) ^ 0x8000) - 0x8000;
1771 = (((val
- low
) & 0xffffffff) ^ 0x80000000) - 0x80000000;
1773 /* Check for 32-bit overflow. */
1774 if (high
+ low
!= val
)
1777 /* Reload the high part into a base reg; leave the low part
1778 in the mem directly. */
1779 x
= gen_rtx_PLUS (GET_MODE (x
),
1780 gen_rtx_PLUS (GET_MODE (x
), XEXP (x
, 0),
1784 push_reload (XEXP (x
, 0), NULL_RTX
, &XEXP (x
, 0), NULL
,
1785 BASE_REG_CLASS
, GET_MODE (x
), VOIDmode
, 0, 0,
1793 /* REF is an alignable memory location. Place an aligned SImode
1794 reference into *PALIGNED_MEM and the number of bits to shift into
1795 *PBITNUM. SCRATCH is a free register for use in reloading out
1796 of range stack slots. */
1799 get_aligned_mem (ref
, paligned_mem
, pbitnum
)
1801 rtx
*paligned_mem
, *pbitnum
;
1804 HOST_WIDE_INT offset
= 0;
1806 if (GET_CODE (ref
) != MEM
)
1809 if (reload_in_progress
1810 && ! memory_address_p (GET_MODE (ref
), XEXP (ref
, 0)))
1812 base
= find_replacement (&XEXP (ref
, 0));
1814 if (! memory_address_p (GET_MODE (ref
), base
))
1819 base
= XEXP (ref
, 0);
1822 if (GET_CODE (base
) == PLUS
)
1823 offset
+= INTVAL (XEXP (base
, 1)), base
= XEXP (base
, 0);
1825 *paligned_mem
= gen_rtx_MEM (SImode
, plus_constant (base
, offset
& ~3));
1826 MEM_COPY_ATTRIBUTES (*paligned_mem
, ref
);
1828 /* Sadly, we cannot use alias sets here because we may overlap other
1829 data in a different alias set. */
1830 set_mem_alias_set (*paligned_mem
, 0);
1832 if (WORDS_BIG_ENDIAN
)
1833 *pbitnum
= GEN_INT (32 - (GET_MODE_BITSIZE (GET_MODE (ref
))
1834 + (offset
& 3) * 8));
1836 *pbitnum
= GEN_INT ((offset
& 3) * 8);
1839 /* Similar, but just get the address. Handle the two reload cases.
1840 Add EXTRA_OFFSET to the address we return. */
1843 get_unaligned_address (ref
, extra_offset
)
1848 HOST_WIDE_INT offset
= 0;
1850 if (GET_CODE (ref
) != MEM
)
1853 if (reload_in_progress
1854 && ! memory_address_p (GET_MODE (ref
), XEXP (ref
, 0)))
1856 base
= find_replacement (&XEXP (ref
, 0));
1858 if (! memory_address_p (GET_MODE (ref
), base
))
1863 base
= XEXP (ref
, 0);
1866 if (GET_CODE (base
) == PLUS
)
1867 offset
+= INTVAL (XEXP (base
, 1)), base
= XEXP (base
, 0);
1869 return plus_constant (base
, offset
+ extra_offset
);
1872 /* Loading and storing HImode or QImode values to and from memory
1873 usually requires a scratch register. The exceptions are loading
1874 QImode and HImode from an aligned address to a general register
1875 unless byte instructions are permitted.
1877 We also cannot load an unaligned address or a paradoxical SUBREG
1878 into an FP register.
1880 We also cannot do integral arithmetic into FP regs, as might result
1881 from register elimination into a DImode fp register. */
1884 secondary_reload_class (class, mode
, x
, in
)
1885 enum reg_class
class;
1886 enum machine_mode mode
;
1890 if ((mode
== QImode
|| mode
== HImode
) && ! TARGET_BWX
)
1892 if (GET_CODE (x
) == MEM
1893 || (GET_CODE (x
) == REG
&& REGNO (x
) >= FIRST_PSEUDO_REGISTER
)
1894 || (GET_CODE (x
) == SUBREG
1895 && (GET_CODE (SUBREG_REG (x
)) == MEM
1896 || (GET_CODE (SUBREG_REG (x
)) == REG
1897 && REGNO (SUBREG_REG (x
)) >= FIRST_PSEUDO_REGISTER
))))
1899 if (!in
|| !aligned_memory_operand(x
, mode
))
1900 return GENERAL_REGS
;
1904 if (class == FLOAT_REGS
)
1906 if (GET_CODE (x
) == MEM
&& GET_CODE (XEXP (x
, 0)) == AND
)
1907 return GENERAL_REGS
;
1909 if (GET_CODE (x
) == SUBREG
1910 && (GET_MODE_SIZE (GET_MODE (x
))
1911 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
1912 return GENERAL_REGS
;
1914 if (in
&& INTEGRAL_MODE_P (mode
)
1915 && ! (memory_operand (x
, mode
) || x
== const0_rtx
))
1916 return GENERAL_REGS
;
1922 /* Subfunction of the following function. Update the flags of any MEM
1923 found in part of X. */
1926 alpha_set_memflags_1 (x
, in_struct_p
, volatile_p
, unchanging_p
)
1928 int in_struct_p
, volatile_p
, unchanging_p
;
1932 switch (GET_CODE (x
))
1936 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
1937 alpha_set_memflags_1 (XVECEXP (x
, 0, i
), in_struct_p
, volatile_p
,
1942 alpha_set_memflags_1 (PATTERN (x
), in_struct_p
, volatile_p
,
1947 alpha_set_memflags_1 (SET_DEST (x
), in_struct_p
, volatile_p
,
1949 alpha_set_memflags_1 (SET_SRC (x
), in_struct_p
, volatile_p
,
1954 MEM_IN_STRUCT_P (x
) = in_struct_p
;
1955 MEM_VOLATILE_P (x
) = volatile_p
;
1956 RTX_UNCHANGING_P (x
) = unchanging_p
;
1957 /* Sadly, we cannot use alias sets because the extra aliasing
1958 produced by the AND interferes. Given that two-byte quantities
1959 are the only thing we would be able to differentiate anyway,
1960 there does not seem to be any point in convoluting the early
1961 out of the alias check. */
1969 /* Given INSN, which is either an INSN or a SEQUENCE generated to
1970 perform a memory operation, look for any MEMs in either a SET_DEST or
1971 a SET_SRC and copy the in-struct, unchanging, and volatile flags from
1972 REF into each of the MEMs found. If REF is not a MEM, don't do
1976 alpha_set_memflags (insn
, ref
)
1980 int in_struct_p
, volatile_p
, unchanging_p
;
1982 if (GET_CODE (ref
) != MEM
)
1985 in_struct_p
= MEM_IN_STRUCT_P (ref
);
1986 volatile_p
= MEM_VOLATILE_P (ref
);
1987 unchanging_p
= RTX_UNCHANGING_P (ref
);
1989 /* This is only called from alpha.md, after having had something
1990 generated from one of the insn patterns. So if everything is
1991 zero, the pattern is already up-to-date. */
1992 if (! in_struct_p
&& ! volatile_p
&& ! unchanging_p
)
1995 alpha_set_memflags_1 (insn
, in_struct_p
, volatile_p
, unchanging_p
);
1998 /* Try to output insns to set TARGET equal to the constant C if it can be
1999 done in less than N insns. Do all computations in MODE. Returns the place
2000 where the output has been placed if it can be done and the insns have been
2001 emitted. If it would take more than N insns, zero is returned and no
2002 insns and emitted. */
2005 alpha_emit_set_const (target
, mode
, c
, n
)
2007 enum machine_mode mode
;
2014 /* Try 1 insn, then 2, then up to N. */
2015 for (i
= 1; i
<= n
; i
++)
2016 if ((pat
= alpha_emit_set_const_1 (target
, mode
, c
, i
)) != 0)
2022 /* Internal routine for the above to check for N or below insns. */
2025 alpha_emit_set_const_1 (target
, mode
, c
, n
)
2027 enum machine_mode mode
;
2033 /* Use a pseudo if highly optimizing and still generating RTL. */
2035 = (flag_expensive_optimizations
&& rtx_equal_function_value_matters
2039 #if HOST_BITS_PER_WIDE_INT == 64
2040 /* We are only called for SImode and DImode. If this is SImode, ensure that
2041 we are sign extended to a full word. This does not make any sense when
2042 cross-compiling on a narrow machine. */
2045 c
= ((c
& 0xffffffff) ^ 0x80000000) - 0x80000000;
2048 /* If this is a sign-extended 32-bit constant, we can do this in at most
2049 three insns, so do it if we have enough insns left. We always have
2050 a sign-extended 32-bit constant when compiling on a narrow machine. */
2052 if (HOST_BITS_PER_WIDE_INT
!= 64
2053 || c
>> 31 == -1 || c
>> 31 == 0)
2055 HOST_WIDE_INT low
= ((c
& 0xffff) ^ 0x8000) - 0x8000;
2056 HOST_WIDE_INT tmp1
= c
- low
;
2057 HOST_WIDE_INT high
= (((tmp1
>> 16) & 0xffff) ^ 0x8000) - 0x8000;
2058 HOST_WIDE_INT extra
= 0;
2060 /* If HIGH will be interpreted as negative but the constant is
2061 positive, we must adjust it to do two ldha insns. */
2063 if ((high
& 0x8000) != 0 && c
>= 0)
2067 high
= ((tmp1
>> 16) & 0xffff) - 2 * ((tmp1
>> 16) & 0x8000);
2070 if (c
== low
|| (low
== 0 && extra
== 0))
2072 /* We used to use copy_to_suggested_reg (GEN_INT (c), target, mode)
2073 but that meant that we can't handle INT_MIN on 32-bit machines
2074 (like NT/Alpha), because we recurse indefinitely through
2075 emit_move_insn to gen_movdi. So instead, since we know exactly
2076 what we want, create it explicitly. */
2079 target
= gen_reg_rtx (mode
);
2080 emit_insn (gen_rtx_SET (VOIDmode
, target
, GEN_INT (c
)));
2083 else if (n
>= 2 + (extra
!= 0))
2085 temp
= copy_to_suggested_reg (GEN_INT (high
<< 16), subtarget
, mode
);
2088 temp
= expand_binop (mode
, add_optab
, temp
, GEN_INT (extra
<< 16),
2089 subtarget
, 0, OPTAB_WIDEN
);
2091 return expand_binop (mode
, add_optab
, temp
, GEN_INT (low
),
2092 target
, 0, OPTAB_WIDEN
);
2096 /* If we couldn't do it that way, try some other methods. But if we have
2097 no instructions left, don't bother. Likewise, if this is SImode and
2098 we can't make pseudos, we can't do anything since the expand_binop
2099 and expand_unop calls will widen and try to make pseudos. */
2102 || (mode
== SImode
&& ! rtx_equal_function_value_matters
))
2105 /* Next, see if we can load a related constant and then shift and possibly
2106 negate it to get the constant we want. Try this once each increasing
2107 numbers of insns. */
2109 for (i
= 1; i
< n
; i
++)
2111 /* First, see if minus some low bits, we've an easy load of
2114 new = ((c
& 0xffff) ^ 0x8000) - 0x8000;
2116 && (temp
= alpha_emit_set_const (subtarget
, mode
, c
- new, i
)) != 0)
2117 return expand_binop (mode
, add_optab
, temp
, GEN_INT (new),
2118 target
, 0, OPTAB_WIDEN
);
2120 /* Next try complementing. */
2121 if ((temp
= alpha_emit_set_const (subtarget
, mode
, ~ c
, i
)) != 0)
2122 return expand_unop (mode
, one_cmpl_optab
, temp
, target
, 0);
2124 /* Next try to form a constant and do a left shift. We can do this
2125 if some low-order bits are zero; the exact_log2 call below tells
2126 us that information. The bits we are shifting out could be any
2127 value, but here we'll just try the 0- and sign-extended forms of
2128 the constant. To try to increase the chance of having the same
2129 constant in more than one insn, start at the highest number of
2130 bits to shift, but try all possibilities in case a ZAPNOT will
2133 if ((bits
= exact_log2 (c
& - c
)) > 0)
2134 for (; bits
> 0; bits
--)
2135 if ((temp
= (alpha_emit_set_const
2136 (subtarget
, mode
, c
>> bits
, i
))) != 0
2137 || ((temp
= (alpha_emit_set_const
2139 ((unsigned HOST_WIDE_INT
) c
) >> bits
, i
)))
2141 return expand_binop (mode
, ashl_optab
, temp
, GEN_INT (bits
),
2142 target
, 0, OPTAB_WIDEN
);
2144 /* Now try high-order zero bits. Here we try the shifted-in bits as
2145 all zero and all ones. Be careful to avoid shifting outside the
2146 mode and to avoid shifting outside the host wide int size. */
2147 /* On narrow hosts, don't shift a 1 into the high bit, since we'll
2148 confuse the recursive call and set all of the high 32 bits. */
2150 if ((bits
= (MIN (HOST_BITS_PER_WIDE_INT
, GET_MODE_SIZE (mode
) * 8)
2151 - floor_log2 (c
) - 1 - (HOST_BITS_PER_WIDE_INT
< 64))) > 0)
2152 for (; bits
> 0; bits
--)
2153 if ((temp
= alpha_emit_set_const (subtarget
, mode
,
2155 || ((temp
= (alpha_emit_set_const
2157 ((c
<< bits
) | (((HOST_WIDE_INT
) 1 << bits
) - 1)),
2160 return expand_binop (mode
, lshr_optab
, temp
, GEN_INT (bits
),
2161 target
, 1, OPTAB_WIDEN
);
2163 /* Now try high-order 1 bits. We get that with a sign-extension.
2164 But one bit isn't enough here. Be careful to avoid shifting outside
2165 the mode and to avoid shifting outside the host wide int size. */
2167 if ((bits
= (MIN (HOST_BITS_PER_WIDE_INT
, GET_MODE_SIZE (mode
) * 8)
2168 - floor_log2 (~ c
) - 2)) > 0)
2169 for (; bits
> 0; bits
--)
2170 if ((temp
= alpha_emit_set_const (subtarget
, mode
,
2172 || ((temp
= (alpha_emit_set_const
2174 ((c
<< bits
) | (((HOST_WIDE_INT
) 1 << bits
) - 1)),
2177 return expand_binop (mode
, ashr_optab
, temp
, GEN_INT (bits
),
2178 target
, 0, OPTAB_WIDEN
);
2181 #if HOST_BITS_PER_WIDE_INT == 64
2182 /* Finally, see if can load a value into the target that is the same as the
2183 constant except that all bytes that are 0 are changed to be 0xff. If we
2184 can, then we can do a ZAPNOT to obtain the desired constant. */
2187 for (i
= 0; i
< 64; i
+= 8)
2188 if ((new & ((HOST_WIDE_INT
) 0xff << i
)) == 0)
2189 new |= (HOST_WIDE_INT
) 0xff << i
;
2191 /* We are only called for SImode and DImode. If this is SImode, ensure that
2192 we are sign extended to a full word. */
2195 new = ((new & 0xffffffff) ^ 0x80000000) - 0x80000000;
2197 if (new != c
&& new != -1
2198 && (temp
= alpha_emit_set_const (subtarget
, mode
, new, n
- 1)) != 0)
2199 return expand_binop (mode
, and_optab
, temp
, GEN_INT (c
| ~ new),
2200 target
, 0, OPTAB_WIDEN
);
2206 /* Having failed to find a 3 insn sequence in alpha_emit_set_const,
2207 fall back to a straight forward decomposition. We do this to avoid
2208 exponential run times encountered when looking for longer sequences
2209 with alpha_emit_set_const. */
2212 alpha_emit_set_long_const (target
, c1
, c2
)
2214 HOST_WIDE_INT c1
, c2
;
2216 HOST_WIDE_INT d1
, d2
, d3
, d4
;
2218 /* Decompose the entire word */
2219 #if HOST_BITS_PER_WIDE_INT >= 64
2220 if (c2
!= -(c1
< 0))
2222 d1
= ((c1
& 0xffff) ^ 0x8000) - 0x8000;
2224 d2
= ((c1
& 0xffffffff) ^ 0x80000000) - 0x80000000;
2225 c1
= (c1
- d2
) >> 32;
2226 d3
= ((c1
& 0xffff) ^ 0x8000) - 0x8000;
2228 d4
= ((c1
& 0xffffffff) ^ 0x80000000) - 0x80000000;
2232 d1
= ((c1
& 0xffff) ^ 0x8000) - 0x8000;
2234 d2
= ((c1
& 0xffffffff) ^ 0x80000000) - 0x80000000;
2238 d3
= ((c2
& 0xffff) ^ 0x8000) - 0x8000;
2240 d4
= ((c2
& 0xffffffff) ^ 0x80000000) - 0x80000000;
2245 /* Construct the high word */
2248 emit_move_insn (target
, GEN_INT (d4
));
2250 emit_move_insn (target
, gen_rtx_PLUS (DImode
, target
, GEN_INT (d3
)));
2253 emit_move_insn (target
, GEN_INT (d3
));
2255 /* Shift it into place */
2256 emit_move_insn (target
, gen_rtx_ASHIFT (DImode
, target
, GEN_INT (32)));
2258 /* Add in the low bits. */
2260 emit_move_insn (target
, gen_rtx_PLUS (DImode
, target
, GEN_INT (d2
)));
2262 emit_move_insn (target
, gen_rtx_PLUS (DImode
, target
, GEN_INT (d1
)));
2267 /* Expand a move instruction; return true if all work is done.
2268 We don't handle non-bwx subword loads here. */
2271 alpha_expand_mov (mode
, operands
)
2272 enum machine_mode mode
;
2275 /* If the output is not a register, the input must be. */
2276 if (GET_CODE (operands
[0]) == MEM
2277 && ! reg_or_0_operand (operands
[1], mode
))
2278 operands
[1] = force_reg (mode
, operands
[1]);
2280 if (TARGET_EXPLICIT_RELOCS
&& symbolic_operand (operands
[1], mode
))
2282 if (local_symbolic_operand (operands
[1], mode
))
2286 if (small_symbolic_operand (operands
[1], Pmode
))
2287 scratch
= pic_offset_table_rtx
;
2292 scratch
= no_new_pseudos
? operands
[0] : gen_reg_rtx (Pmode
);
2294 tmp
= gen_rtx_HIGH (Pmode
, operands
[1]);
2295 tmp
= gen_rtx_PLUS (Pmode
, pic_offset_table_rtx
, tmp
);
2296 insn
= emit_insn (gen_rtx_SET (VOIDmode
, scratch
, tmp
));
2297 REG_NOTES (insn
) = gen_rtx_EXPR_LIST (REG_EQUAL
, tmp
,
2301 operands
[1] = gen_rtx_LO_SUM (Pmode
, scratch
, operands
[1]);
2306 emit_insn (gen_movdi_er_high_g (operands
[0], pic_offset_table_rtx
,
2307 operands
[1], const0_rtx
));
2312 /* Early out for non-constants and valid constants. */
2313 if (! CONSTANT_P (operands
[1]) || input_operand (operands
[1], mode
))
2316 /* Split large integers. */
2317 if (GET_CODE (operands
[1]) == CONST_INT
2318 || GET_CODE (operands
[1]) == CONST_DOUBLE
)
2320 HOST_WIDE_INT i0
, i1
;
2321 rtx temp
= NULL_RTX
;
2323 if (GET_CODE (operands
[1]) == CONST_INT
)
2325 i0
= INTVAL (operands
[1]);
2328 else if (HOST_BITS_PER_WIDE_INT
>= 64)
2330 i0
= CONST_DOUBLE_LOW (operands
[1]);
2335 i0
= CONST_DOUBLE_LOW (operands
[1]);
2336 i1
= CONST_DOUBLE_HIGH (operands
[1]);
2339 if (HOST_BITS_PER_WIDE_INT
>= 64 || i1
== -(i0
< 0))
2340 temp
= alpha_emit_set_const (operands
[0], mode
, i0
, 3);
2342 if (!temp
&& TARGET_BUILD_CONSTANTS
)
2343 temp
= alpha_emit_set_long_const (operands
[0], i0
, i1
);
2347 if (rtx_equal_p (operands
[0], temp
))
2354 /* Otherwise we've nothing left but to drop the thing to memory. */
2355 operands
[1] = force_const_mem (DImode
, operands
[1]);
2356 if (reload_in_progress
)
2358 emit_move_insn (operands
[0], XEXP (operands
[1], 0));
2359 operands
[1] = copy_rtx (operands
[1]);
2360 XEXP (operands
[1], 0) = operands
[0];
2363 operands
[1] = validize_mem (operands
[1]);
2367 /* Expand a non-bwx QImode or HImode move instruction;
2368 return true if all work is done. */
2371 alpha_expand_mov_nobwx (mode
, operands
)
2372 enum machine_mode mode
;
2375 /* If the output is not a register, the input must be. */
2376 if (GET_CODE (operands
[0]) == MEM
)
2377 operands
[1] = force_reg (mode
, operands
[1]);
2379 /* Handle four memory cases, unaligned and aligned for either the input
2380 or the output. The only case where we can be called during reload is
2381 for aligned loads; all other cases require temporaries. */
2383 if (GET_CODE (operands
[1]) == MEM
2384 || (GET_CODE (operands
[1]) == SUBREG
2385 && GET_CODE (SUBREG_REG (operands
[1])) == MEM
)
2386 || (reload_in_progress
&& GET_CODE (operands
[1]) == REG
2387 && REGNO (operands
[1]) >= FIRST_PSEUDO_REGISTER
)
2388 || (reload_in_progress
&& GET_CODE (operands
[1]) == SUBREG
2389 && GET_CODE (SUBREG_REG (operands
[1])) == REG
2390 && REGNO (SUBREG_REG (operands
[1])) >= FIRST_PSEUDO_REGISTER
))
2392 if (aligned_memory_operand (operands
[1], mode
))
2394 if (reload_in_progress
)
2396 emit_insn ((mode
== QImode
2397 ? gen_reload_inqi_help
2398 : gen_reload_inhi_help
)
2399 (operands
[0], operands
[1],
2400 gen_rtx_REG (SImode
, REGNO (operands
[0]))));
2404 rtx aligned_mem
, bitnum
;
2405 rtx scratch
= gen_reg_rtx (SImode
);
2407 get_aligned_mem (operands
[1], &aligned_mem
, &bitnum
);
2409 emit_insn ((mode
== QImode
2410 ? gen_aligned_loadqi
2411 : gen_aligned_loadhi
)
2412 (operands
[0], aligned_mem
, bitnum
, scratch
));
2417 /* Don't pass these as parameters since that makes the generated
2418 code depend on parameter evaluation order which will cause
2419 bootstrap failures. */
2421 rtx temp1
= gen_reg_rtx (DImode
);
2422 rtx temp2
= gen_reg_rtx (DImode
);
2423 rtx seq
= ((mode
== QImode
2424 ? gen_unaligned_loadqi
2425 : gen_unaligned_loadhi
)
2426 (operands
[0], get_unaligned_address (operands
[1], 0),
2429 alpha_set_memflags (seq
, operands
[1]);
2435 if (GET_CODE (operands
[0]) == MEM
2436 || (GET_CODE (operands
[0]) == SUBREG
2437 && GET_CODE (SUBREG_REG (operands
[0])) == MEM
)
2438 || (reload_in_progress
&& GET_CODE (operands
[0]) == REG
2439 && REGNO (operands
[0]) >= FIRST_PSEUDO_REGISTER
)
2440 || (reload_in_progress
&& GET_CODE (operands
[0]) == SUBREG
2441 && GET_CODE (SUBREG_REG (operands
[0])) == REG
2442 && REGNO (operands
[0]) >= FIRST_PSEUDO_REGISTER
))
2444 if (aligned_memory_operand (operands
[0], mode
))
2446 rtx aligned_mem
, bitnum
;
2447 rtx temp1
= gen_reg_rtx (SImode
);
2448 rtx temp2
= gen_reg_rtx (SImode
);
2450 get_aligned_mem (operands
[0], &aligned_mem
, &bitnum
);
2452 emit_insn (gen_aligned_store (aligned_mem
, operands
[1], bitnum
,
2457 rtx temp1
= gen_reg_rtx (DImode
);
2458 rtx temp2
= gen_reg_rtx (DImode
);
2459 rtx temp3
= gen_reg_rtx (DImode
);
2460 rtx seq
= ((mode
== QImode
2461 ? gen_unaligned_storeqi
2462 : gen_unaligned_storehi
)
2463 (get_unaligned_address (operands
[0], 0),
2464 operands
[1], temp1
, temp2
, temp3
));
2466 alpha_set_memflags (seq
, operands
[0]);
2475 /* Generate an unsigned DImode to FP conversion. This is the same code
2476 optabs would emit if we didn't have TFmode patterns.
2478 For SFmode, this is the only construction I've found that can pass
2479 gcc.c-torture/execute/ieee/rbug.c. No scenario that uses DFmode
2480 intermediates will work, because you'll get intermediate rounding
2481 that ruins the end result. Some of this could be fixed by turning
2482 on round-to-positive-infinity, but that requires diddling the fpsr,
2483 which kills performance. I tried turning this around and converting
2484 to a negative number, so that I could turn on /m, but either I did
2485 it wrong or there's something else cause I wound up with the exact
2486 same single-bit error. There is a branch-less form of this same code:
2497 fcmoveq $f10,$f11,$f0
2499 I'm not using it because it's the same number of instructions as
2500 this branch-full form, and it has more serialized long latency
2501 instructions on the critical path.
2503 For DFmode, we can avoid rounding errors by breaking up the word
2504 into two pieces, converting them separately, and adding them back:
2506 LC0: .long 0,0x5f800000
2511 cpyse $f11,$f31,$f10
2512 cpyse $f31,$f11,$f11
2520 This doesn't seem to be a clear-cut win over the optabs form.
2521 It probably all depends on the distribution of numbers being
2522 converted -- in the optabs form, all but high-bit-set has a
2523 much lower minimum execution time. */
2526 alpha_emit_floatuns (operands
)
2529 rtx neglab
, donelab
, i0
, i1
, f0
, in
, out
;
2530 enum machine_mode mode
;
2533 in
= force_reg (DImode
, operands
[1]);
2534 mode
= GET_MODE (out
);
2535 neglab
= gen_label_rtx ();
2536 donelab
= gen_label_rtx ();
2537 i0
= gen_reg_rtx (DImode
);
2538 i1
= gen_reg_rtx (DImode
);
2539 f0
= gen_reg_rtx (mode
);
2541 emit_cmp_and_jump_insns (in
, const0_rtx
, LT
, const0_rtx
, DImode
, 0, neglab
);
2543 emit_insn (gen_rtx_SET (VOIDmode
, out
, gen_rtx_FLOAT (mode
, in
)));
2544 emit_jump_insn (gen_jump (donelab
));
2547 emit_label (neglab
);
2549 emit_insn (gen_lshrdi3 (i0
, in
, const1_rtx
));
2550 emit_insn (gen_anddi3 (i1
, in
, const1_rtx
));
2551 emit_insn (gen_iordi3 (i0
, i0
, i1
));
2552 emit_insn (gen_rtx_SET (VOIDmode
, f0
, gen_rtx_FLOAT (mode
, i0
)));
2553 emit_insn (gen_rtx_SET (VOIDmode
, out
, gen_rtx_PLUS (mode
, f0
, f0
)));
2555 emit_label (donelab
);
2558 /* Generate the comparison for a conditional branch. */
2561 alpha_emit_conditional_branch (code
)
2564 enum rtx_code cmp_code
, branch_code
;
2565 enum machine_mode cmp_mode
, branch_mode
= VOIDmode
;
2566 rtx op0
= alpha_compare
.op0
, op1
= alpha_compare
.op1
;
2569 if (alpha_compare
.fp_p
&& GET_MODE (op0
) == TFmode
)
2571 if (! TARGET_HAS_XFLOATING_LIBS
)
2574 /* X_floating library comparison functions return
2578 Convert the compare against the raw return value. */
2580 if (code
== UNORDERED
|| code
== ORDERED
)
2585 op0
= alpha_emit_xfloating_compare (cmp_code
, op0
, op1
);
2587 alpha_compare
.fp_p
= 0;
2589 if (code
== UNORDERED
)
2591 else if (code
== ORDERED
)
2597 /* The general case: fold the comparison code to the types of compares
2598 that we have, choosing the branch as necessary. */
2601 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
2603 /* We have these compares: */
2604 cmp_code
= code
, branch_code
= NE
;
2609 /* These must be reversed. */
2610 cmp_code
= reverse_condition (code
), branch_code
= EQ
;
2613 case GE
: case GT
: case GEU
: case GTU
:
2614 /* For FP, we swap them, for INT, we reverse them. */
2615 if (alpha_compare
.fp_p
)
2617 cmp_code
= swap_condition (code
);
2619 tem
= op0
, op0
= op1
, op1
= tem
;
2623 cmp_code
= reverse_condition (code
);
2632 if (alpha_compare
.fp_p
)
2635 if (flag_unsafe_math_optimizations
)
2637 /* When we are not as concerned about non-finite values, and we
2638 are comparing against zero, we can branch directly. */
2639 if (op1
== CONST0_RTX (DFmode
))
2640 cmp_code
= NIL
, branch_code
= code
;
2641 else if (op0
== CONST0_RTX (DFmode
))
2643 /* Undo the swap we probably did just above. */
2644 tem
= op0
, op0
= op1
, op1
= tem
;
2645 branch_code
= swap_condition (cmp_code
);
2651 /* ??? We mark the the branch mode to be CCmode to prevent the
2652 compare and branch from being combined, since the compare
2653 insn follows IEEE rules that the branch does not. */
2654 branch_mode
= CCmode
;
2661 /* The following optimizations are only for signed compares. */
2662 if (code
!= LEU
&& code
!= LTU
&& code
!= GEU
&& code
!= GTU
)
2664 /* Whee. Compare and branch against 0 directly. */
2665 if (op1
== const0_rtx
)
2666 cmp_code
= NIL
, branch_code
= code
;
2668 /* We want to use cmpcc/bcc when we can, since there is a zero delay
2669 bypass between logicals and br/cmov on EV5. But we don't want to
2670 force valid immediate constants into registers needlessly. */
2671 else if (GET_CODE (op1
) == CONST_INT
)
2673 HOST_WIDE_INT v
= INTVAL (op1
), n
= -v
;
2675 if (! CONST_OK_FOR_LETTER_P (v
, 'I')
2676 && (CONST_OK_FOR_LETTER_P (n
, 'K')
2677 || CONST_OK_FOR_LETTER_P (n
, 'L')))
2679 cmp_code
= PLUS
, branch_code
= code
;
2685 if (!reg_or_0_operand (op0
, DImode
))
2686 op0
= force_reg (DImode
, op0
);
2687 if (cmp_code
!= PLUS
&& !reg_or_8bit_operand (op1
, DImode
))
2688 op1
= force_reg (DImode
, op1
);
2691 /* Emit an initial compare instruction, if necessary. */
2693 if (cmp_code
!= NIL
)
2695 tem
= gen_reg_rtx (cmp_mode
);
2696 emit_move_insn (tem
, gen_rtx_fmt_ee (cmp_code
, cmp_mode
, op0
, op1
));
2699 /* Zero the operands. */
2700 memset (&alpha_compare
, 0, sizeof (alpha_compare
));
2702 /* Return the branch comparison. */
2703 return gen_rtx_fmt_ee (branch_code
, branch_mode
, tem
, CONST0_RTX (cmp_mode
));
2706 /* Certain simplifications can be done to make invalid setcc operations
2707 valid. Return the final comparison, or NULL if we can't work. */
2710 alpha_emit_setcc (code
)
2713 enum rtx_code cmp_code
;
2714 rtx op0
= alpha_compare
.op0
, op1
= alpha_compare
.op1
;
2715 int fp_p
= alpha_compare
.fp_p
;
2718 /* Zero the operands. */
2719 memset (&alpha_compare
, 0, sizeof (alpha_compare
));
2721 if (fp_p
&& GET_MODE (op0
) == TFmode
)
2723 if (! TARGET_HAS_XFLOATING_LIBS
)
2726 /* X_floating library comparison functions return
2730 Convert the compare against the raw return value. */
2732 if (code
== UNORDERED
|| code
== ORDERED
)
2737 op0
= alpha_emit_xfloating_compare (cmp_code
, op0
, op1
);
2741 if (code
== UNORDERED
)
2743 else if (code
== ORDERED
)
2749 if (fp_p
&& !TARGET_FIX
)
2752 /* The general case: fold the comparison code to the types of compares
2753 that we have, choosing the branch as necessary. */
2758 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
2760 /* We have these compares. */
2762 cmp_code
= code
, code
= NE
;
2766 if (!fp_p
&& op1
== const0_rtx
)
2771 cmp_code
= reverse_condition (code
);
2775 case GE
: case GT
: case GEU
: case GTU
:
2776 /* These normally need swapping, but for integer zero we have
2777 special patterns that recognize swapped operands. */
2778 if (!fp_p
&& op1
== const0_rtx
)
2780 code
= swap_condition (code
);
2782 cmp_code
= code
, code
= NE
;
2783 tmp
= op0
, op0
= op1
, op1
= tmp
;
2792 if (!register_operand (op0
, DImode
))
2793 op0
= force_reg (DImode
, op0
);
2794 if (!reg_or_8bit_operand (op1
, DImode
))
2795 op1
= force_reg (DImode
, op1
);
2798 /* Emit an initial compare instruction, if necessary. */
2799 if (cmp_code
!= NIL
)
2801 enum machine_mode mode
= fp_p
? DFmode
: DImode
;
2803 tmp
= gen_reg_rtx (mode
);
2804 emit_insn (gen_rtx_SET (VOIDmode
, tmp
,
2805 gen_rtx_fmt_ee (cmp_code
, mode
, op0
, op1
)));
2807 op0
= fp_p
? gen_lowpart (DImode
, tmp
) : tmp
;
2811 /* Return the setcc comparison. */
2812 return gen_rtx_fmt_ee (code
, DImode
, op0
, op1
);
2816 /* Rewrite a comparison against zero CMP of the form
2817 (CODE (cc0) (const_int 0)) so it can be written validly in
2818 a conditional move (if_then_else CMP ...).
2819 If both of the operands that set cc0 are non-zero we must emit
2820 an insn to perform the compare (it can't be done within
2821 the conditional move). */
2823 alpha_emit_conditional_move (cmp
, mode
)
2825 enum machine_mode mode
;
2827 enum rtx_code code
= GET_CODE (cmp
);
2828 enum rtx_code cmov_code
= NE
;
2829 rtx op0
= alpha_compare
.op0
;
2830 rtx op1
= alpha_compare
.op1
;
2831 int fp_p
= alpha_compare
.fp_p
;
2832 enum machine_mode cmp_mode
2833 = (GET_MODE (op0
) == VOIDmode
? DImode
: GET_MODE (op0
));
2834 enum machine_mode cmp_op_mode
= fp_p
? DFmode
: DImode
;
2835 enum machine_mode cmov_mode
= VOIDmode
;
2836 int local_fast_math
= flag_unsafe_math_optimizations
;
2839 /* Zero the operands. */
2840 memset (&alpha_compare
, 0, sizeof (alpha_compare
));
2842 if (fp_p
!= FLOAT_MODE_P (mode
))
2844 enum rtx_code cmp_code
;
2849 /* If we have fp<->int register move instructions, do a cmov by
2850 performing the comparison in fp registers, and move the
2851 zero/non-zero value to integer registers, where we can then
2852 use a normal cmov, or vice-versa. */
2856 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
2857 /* We have these compares. */
2858 cmp_code
= code
, code
= NE
;
2862 /* This must be reversed. */
2863 cmp_code
= EQ
, code
= EQ
;
2866 case GE
: case GT
: case GEU
: case GTU
:
2867 /* These normally need swapping, but for integer zero we have
2868 special patterns that recognize swapped operands. */
2869 if (!fp_p
&& op1
== const0_rtx
)
2870 cmp_code
= code
, code
= NE
;
2873 cmp_code
= swap_condition (code
);
2875 tem
= op0
, op0
= op1
, op1
= tem
;
2883 tem
= gen_reg_rtx (cmp_op_mode
);
2884 emit_insn (gen_rtx_SET (VOIDmode
, tem
,
2885 gen_rtx_fmt_ee (cmp_code
, cmp_op_mode
,
2888 cmp_mode
= cmp_op_mode
= fp_p
? DImode
: DFmode
;
2889 op0
= gen_lowpart (cmp_op_mode
, tem
);
2890 op1
= CONST0_RTX (cmp_op_mode
);
2892 local_fast_math
= 1;
2895 /* We may be able to use a conditional move directly.
2896 This avoids emitting spurious compares. */
2897 if (signed_comparison_operator (cmp
, VOIDmode
)
2898 && (!fp_p
|| local_fast_math
)
2899 && (op0
== CONST0_RTX (cmp_mode
) || op1
== CONST0_RTX (cmp_mode
)))
2900 return gen_rtx_fmt_ee (code
, VOIDmode
, op0
, op1
);
2902 /* We can't put the comparison inside the conditional move;
2903 emit a compare instruction and put that inside the
2904 conditional move. Make sure we emit only comparisons we have;
2905 swap or reverse as necessary. */
2912 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
2913 /* We have these compares: */
2917 /* This must be reversed. */
2918 code
= reverse_condition (code
);
2922 case GE
: case GT
: case GEU
: case GTU
:
2923 /* These must be swapped. */
2924 if (op1
!= CONST0_RTX (cmp_mode
))
2926 code
= swap_condition (code
);
2927 tem
= op0
, op0
= op1
, op1
= tem
;
2937 if (!reg_or_0_operand (op0
, DImode
))
2938 op0
= force_reg (DImode
, op0
);
2939 if (!reg_or_8bit_operand (op1
, DImode
))
2940 op1
= force_reg (DImode
, op1
);
2943 /* ??? We mark the branch mode to be CCmode to prevent the compare
2944 and cmov from being combined, since the compare insn follows IEEE
2945 rules that the cmov does not. */
2946 if (fp_p
&& !local_fast_math
)
2949 tem
= gen_reg_rtx (cmp_op_mode
);
2950 emit_move_insn (tem
, gen_rtx_fmt_ee (code
, cmp_op_mode
, op0
, op1
));
2951 return gen_rtx_fmt_ee (cmov_code
, cmov_mode
, tem
, CONST0_RTX (cmp_op_mode
));
2954 /* Simplify a conditional move of two constants into a setcc with
2955 arithmetic. This is done with a splitter since combine would
2956 just undo the work if done during code generation. It also catches
2957 cases we wouldn't have before cse. */
2960 alpha_split_conditional_move (code
, dest
, cond
, t_rtx
, f_rtx
)
2962 rtx dest
, cond
, t_rtx
, f_rtx
;
2964 HOST_WIDE_INT t
, f
, diff
;
2965 enum machine_mode mode
;
2966 rtx target
, subtarget
, tmp
;
2968 mode
= GET_MODE (dest
);
2973 if (((code
== NE
|| code
== EQ
) && diff
< 0)
2974 || (code
== GE
|| code
== GT
))
2976 code
= reverse_condition (code
);
2977 diff
= t
, t
= f
, f
= diff
;
2981 subtarget
= target
= dest
;
2984 target
= gen_lowpart (DImode
, dest
);
2985 if (! no_new_pseudos
)
2986 subtarget
= gen_reg_rtx (DImode
);
2991 if (f
== 0 && exact_log2 (diff
) > 0
2992 /* On EV6, we've got enough shifters to make non-arithmatic shifts
2993 viable over a longer latency cmove. On EV5, the E0 slot is a
2994 scarce resource, and on EV4 shift has the same latency as a cmove. */
2995 && (diff
<= 8 || alpha_cpu
== PROCESSOR_EV6
))
2997 tmp
= gen_rtx_fmt_ee (code
, DImode
, cond
, const0_rtx
);
2998 emit_insn (gen_rtx_SET (VOIDmode
, subtarget
, tmp
));
3000 tmp
= gen_rtx_ASHIFT (DImode
, subtarget
, GEN_INT (exact_log2 (t
)));
3001 emit_insn (gen_rtx_SET (VOIDmode
, target
, tmp
));
3003 else if (f
== 0 && t
== -1)
3005 tmp
= gen_rtx_fmt_ee (code
, DImode
, cond
, const0_rtx
);
3006 emit_insn (gen_rtx_SET (VOIDmode
, subtarget
, tmp
));
3008 emit_insn (gen_negdi2 (target
, subtarget
));
3010 else if (diff
== 1 || diff
== 4 || diff
== 8)
3014 tmp
= gen_rtx_fmt_ee (code
, DImode
, cond
, const0_rtx
);
3015 emit_insn (gen_rtx_SET (VOIDmode
, subtarget
, tmp
));
3018 emit_insn (gen_adddi3 (target
, subtarget
, GEN_INT (f
)));
3021 add_op
= GEN_INT (f
);
3022 if (sext_add_operand (add_op
, mode
))
3024 tmp
= gen_rtx_MULT (DImode
, subtarget
, GEN_INT (diff
));
3025 tmp
= gen_rtx_PLUS (DImode
, tmp
, add_op
);
3026 emit_insn (gen_rtx_SET (VOIDmode
, target
, tmp
));
3038 /* Look up the function X_floating library function name for the
3042 alpha_lookup_xfloating_lib_func (code
)
3047 const enum rtx_code code
;
3048 const char *const func
;
3051 static const struct xfloating_op vms_xfloating_ops
[] =
3053 { PLUS
, "OTS$ADD_X" },
3054 { MINUS
, "OTS$SUB_X" },
3055 { MULT
, "OTS$MUL_X" },
3056 { DIV
, "OTS$DIV_X" },
3057 { EQ
, "OTS$EQL_X" },
3058 { NE
, "OTS$NEQ_X" },
3059 { LT
, "OTS$LSS_X" },
3060 { LE
, "OTS$LEQ_X" },
3061 { GT
, "OTS$GTR_X" },
3062 { GE
, "OTS$GEQ_X" },
3063 { FIX
, "OTS$CVTXQ" },
3064 { FLOAT
, "OTS$CVTQX" },
3065 { UNSIGNED_FLOAT
, "OTS$CVTQUX" },
3066 { FLOAT_EXTEND
, "OTS$CVT_FLOAT_T_X" },
3067 { FLOAT_TRUNCATE
, "OTS$CVT_FLOAT_X_T" },
3070 static const struct xfloating_op osf_xfloating_ops
[] =
3072 { PLUS
, "_OtsAddX" },
3073 { MINUS
, "_OtsSubX" },
3074 { MULT
, "_OtsMulX" },
3075 { DIV
, "_OtsDivX" },
3082 { FIX
, "_OtsCvtXQ" },
3083 { FLOAT
, "_OtsCvtQX" },
3084 { UNSIGNED_FLOAT
, "_OtsCvtQUX" },
3085 { FLOAT_EXTEND
, "_OtsConvertFloatTX" },
3086 { FLOAT_TRUNCATE
, "_OtsConvertFloatXT" },
3089 const struct xfloating_op
*ops
;
3090 const long n
= ARRAY_SIZE (osf_xfloating_ops
);
3093 /* How irritating. Nothing to key off for the table. Hardcode
3094 knowledge of the G_floating routines. */
3095 if (TARGET_FLOAT_VAX
)
3097 if (TARGET_ABI_OPEN_VMS
)
3099 if (code
== FLOAT_EXTEND
)
3100 return "OTS$CVT_FLOAT_G_X";
3101 if (code
== FLOAT_TRUNCATE
)
3102 return "OTS$CVT_FLOAT_X_G";
3106 if (code
== FLOAT_EXTEND
)
3107 return "_OtsConvertFloatGX";
3108 if (code
== FLOAT_TRUNCATE
)
3109 return "_OtsConvertFloatXG";
3113 if (TARGET_ABI_OPEN_VMS
)
3114 ops
= vms_xfloating_ops
;
3116 ops
= osf_xfloating_ops
;
3118 for (i
= 0; i
< n
; ++i
)
3119 if (ops
[i
].code
== code
)
3125 /* Most X_floating operations take the rounding mode as an argument.
3126 Compute that here. */
3129 alpha_compute_xfloating_mode_arg (code
, round
)
3131 enum alpha_fp_rounding_mode round
;
3137 case ALPHA_FPRM_NORM
:
3140 case ALPHA_FPRM_MINF
:
3143 case ALPHA_FPRM_CHOP
:
3146 case ALPHA_FPRM_DYN
:
3152 /* XXX For reference, round to +inf is mode = 3. */
3155 if (code
== FLOAT_TRUNCATE
&& alpha_fptm
== ALPHA_FPTM_N
)
3161 /* Emit an X_floating library function call.
3163 Note that these functions do not follow normal calling conventions:
3164 TFmode arguments are passed in two integer registers (as opposed to
3165 indirect); TFmode return values appear in R16+R17.
3167 FUNC is the function name to call.
3168 TARGET is where the output belongs.
3169 OPERANDS are the inputs.
3170 NOPERANDS is the count of inputs.
3171 EQUIV is the expression equivalent for the function.
3175 alpha_emit_xfloating_libcall (func
, target
, operands
, noperands
, equiv
)
3182 rtx usage
= NULL_RTX
, tmp
, reg
;
3187 for (i
= 0; i
< noperands
; ++i
)
3189 switch (GET_MODE (operands
[i
]))
3192 reg
= gen_rtx_REG (TFmode
, regno
);
3197 reg
= gen_rtx_REG (DFmode
, regno
+ 32);
3202 if (GET_CODE (operands
[i
]) != CONST_INT
)
3206 reg
= gen_rtx_REG (DImode
, regno
);
3214 emit_move_insn (reg
, operands
[i
]);
3215 usage
= alloc_EXPR_LIST (0, gen_rtx_USE (VOIDmode
, reg
), usage
);
3218 switch (GET_MODE (target
))
3221 reg
= gen_rtx_REG (TFmode
, 16);
3224 reg
= gen_rtx_REG (DFmode
, 32);
3227 reg
= gen_rtx_REG (DImode
, 0);
3233 tmp
= gen_rtx_MEM (QImode
, gen_rtx_SYMBOL_REF (Pmode
, (char *) func
));
3234 tmp
= emit_call_insn (GEN_CALL_VALUE (reg
, tmp
, const0_rtx
,
3235 const0_rtx
, const0_rtx
));
3236 CALL_INSN_FUNCTION_USAGE (tmp
) = usage
;
3241 emit_libcall_block (tmp
, target
, reg
, equiv
);
3244 /* Emit an X_floating library function call for arithmetic (+,-,*,/). */
3247 alpha_emit_xfloating_arith (code
, operands
)
3253 rtx out_operands
[3];
3255 func
= alpha_lookup_xfloating_lib_func (code
);
3256 mode
= alpha_compute_xfloating_mode_arg (code
, alpha_fprm
);
3258 out_operands
[0] = operands
[1];
3259 out_operands
[1] = operands
[2];
3260 out_operands
[2] = GEN_INT (mode
);
3261 alpha_emit_xfloating_libcall (func
, operands
[0], out_operands
, 3,
3262 gen_rtx_fmt_ee (code
, TFmode
, operands
[1],
3266 /* Emit an X_floating library function call for a comparison. */
3269 alpha_emit_xfloating_compare (code
, op0
, op1
)
3274 rtx out
, operands
[2];
3276 func
= alpha_lookup_xfloating_lib_func (code
);
3280 out
= gen_reg_rtx (DImode
);
3282 /* ??? Strange mode for equiv because what's actually returned
3283 is -1,0,1, not a proper boolean value. */
3284 alpha_emit_xfloating_libcall (func
, out
, operands
, 2,
3285 gen_rtx_fmt_ee (code
, CCmode
, op0
, op1
));
3290 /* Emit an X_floating library function call for a conversion. */
3293 alpha_emit_xfloating_cvt (code
, operands
)
3297 int noperands
= 1, mode
;
3298 rtx out_operands
[2];
3301 func
= alpha_lookup_xfloating_lib_func (code
);
3303 out_operands
[0] = operands
[1];
3308 mode
= alpha_compute_xfloating_mode_arg (code
, ALPHA_FPRM_CHOP
);
3309 out_operands
[1] = GEN_INT (mode
);
3312 case FLOAT_TRUNCATE
:
3313 mode
= alpha_compute_xfloating_mode_arg (code
, alpha_fprm
);
3314 out_operands
[1] = GEN_INT (mode
);
3321 alpha_emit_xfloating_libcall (func
, operands
[0], out_operands
, noperands
,
3322 gen_rtx_fmt_e (code
, GET_MODE (operands
[0]),
3326 /* Split a TFmode OP[1] into DImode OP[2,3] and likewise for
3327 OP[0] into OP[0,1]. Naturally, output operand ordering is
3331 alpha_split_tfmode_pair (operands
)
3334 if (GET_CODE (operands
[1]) == REG
)
3336 operands
[3] = gen_rtx_REG (DImode
, REGNO (operands
[1]) + 1);
3337 operands
[2] = gen_rtx_REG (DImode
, REGNO (operands
[1]));
3339 else if (GET_CODE (operands
[1]) == MEM
)
3341 operands
[3] = adjust_address (operands
[1], DImode
, 8);
3342 operands
[2] = adjust_address (operands
[1], DImode
, 0);
3344 else if (operands
[1] == CONST0_RTX (TFmode
))
3345 operands
[2] = operands
[3] = const0_rtx
;
3349 if (GET_CODE (operands
[0]) == REG
)
3351 operands
[1] = gen_rtx_REG (DImode
, REGNO (operands
[0]) + 1);
3352 operands
[0] = gen_rtx_REG (DImode
, REGNO (operands
[0]));
3354 else if (GET_CODE (operands
[0]) == MEM
)
3356 operands
[1] = adjust_address (operands
[0], DImode
, 8);
3357 operands
[0] = adjust_address (operands
[0], DImode
, 0);
3363 /* Implement negtf2 or abstf2. Op0 is destination, op1 is source,
3364 op2 is a register containing the sign bit, operation is the
3365 logical operation to be performed. */
3368 alpha_split_tfmode_frobsign (operands
, operation
)
3370 rtx (*operation
) PARAMS ((rtx
, rtx
, rtx
));
3372 rtx high_bit
= operands
[2];
3376 alpha_split_tfmode_pair (operands
);
3378 /* Detect three flavours of operand overlap. */
3380 if (rtx_equal_p (operands
[0], operands
[2]))
3382 else if (rtx_equal_p (operands
[1], operands
[2]))
3384 if (rtx_equal_p (operands
[0], high_bit
))
3391 emit_move_insn (operands
[0], operands
[2]);
3393 /* ??? If the destination overlaps both source tf and high_bit, then
3394 assume source tf is dead in its entirety and use the other half
3395 for a scratch register. Otherwise "scratch" is just the proper
3396 destination register. */
3397 scratch
= operands
[move
< 2 ? 1 : 3];
3399 emit_insn ((*operation
) (scratch
, high_bit
, operands
[3]));
3403 emit_move_insn (operands
[0], operands
[2]);
3405 emit_move_insn (operands
[1], scratch
);
3409 /* Use ext[wlq][lh] as the Architecture Handbook describes for extracting
3413 word: ldq_u r1,X(r11) ldq_u r1,X(r11)
3414 ldq_u r2,X+1(r11) ldq_u r2,X+1(r11)
3415 lda r3,X(r11) lda r3,X+2(r11)
3416 extwl r1,r3,r1 extql r1,r3,r1
3417 extwh r2,r3,r2 extqh r2,r3,r2
3418 or r1.r2.r1 or r1,r2,r1
3421 long: ldq_u r1,X(r11) ldq_u r1,X(r11)
3422 ldq_u r2,X+3(r11) ldq_u r2,X+3(r11)
3423 lda r3,X(r11) lda r3,X(r11)
3424 extll r1,r3,r1 extll r1,r3,r1
3425 extlh r2,r3,r2 extlh r2,r3,r2
3426 or r1.r2.r1 addl r1,r2,r1
3428 quad: ldq_u r1,X(r11)
3437 alpha_expand_unaligned_load (tgt
, mem
, size
, ofs
, sign
)
3439 HOST_WIDE_INT size
, ofs
;
3442 rtx meml
, memh
, addr
, extl
, exth
, tmp
, mema
;
3443 enum machine_mode mode
;
3445 meml
= gen_reg_rtx (DImode
);
3446 memh
= gen_reg_rtx (DImode
);
3447 addr
= gen_reg_rtx (DImode
);
3448 extl
= gen_reg_rtx (DImode
);
3449 exth
= gen_reg_rtx (DImode
);
3451 mema
= XEXP (mem
, 0);
3452 if (GET_CODE (mema
) == LO_SUM
)
3453 mema
= force_reg (Pmode
, mema
);
3455 /* AND addresses cannot be in any alias set, since they may implicitly
3456 alias surrounding code. Ideally we'd have some alias set that
3457 covered all types except those with alignment 8 or higher. */
3459 tmp
= change_address (mem
, DImode
,
3460 gen_rtx_AND (DImode
,
3461 plus_constant (mema
, ofs
),
3463 set_mem_alias_set (tmp
, 0);
3464 emit_move_insn (meml
, tmp
);
3466 tmp
= change_address (mem
, DImode
,
3467 gen_rtx_AND (DImode
,
3468 plus_constant (mema
, ofs
+ size
- 1),
3470 set_mem_alias_set (tmp
, 0);
3471 emit_move_insn (memh
, tmp
);
3473 if (WORDS_BIG_ENDIAN
&& sign
&& (size
== 2 || size
== 4))
3475 emit_move_insn (addr
, plus_constant (mema
, -1));
3477 emit_insn (gen_extqh_be (extl
, meml
, addr
));
3478 emit_insn (gen_extxl_be (exth
, memh
, GEN_INT (64), addr
));
3480 addr
= expand_binop (DImode
, ior_optab
, extl
, exth
, tgt
, 1, OPTAB_WIDEN
);
3481 addr
= expand_binop (DImode
, ashr_optab
, addr
, GEN_INT (64 - size
*8),
3482 addr
, 1, OPTAB_WIDEN
);
3484 else if (sign
&& size
== 2)
3486 emit_move_insn (addr
, plus_constant (mema
, ofs
+2));
3488 emit_insn (gen_extxl_le (extl
, meml
, GEN_INT (64), addr
));
3489 emit_insn (gen_extqh_le (exth
, memh
, addr
));
3491 /* We must use tgt here for the target. Alpha-vms port fails if we use
3492 addr for the target, because addr is marked as a pointer and combine
3493 knows that pointers are always sign-extended 32 bit values. */
3494 addr
= expand_binop (DImode
, ior_optab
, extl
, exth
, tgt
, 1, OPTAB_WIDEN
);
3495 addr
= expand_binop (DImode
, ashr_optab
, addr
, GEN_INT (48),
3496 addr
, 1, OPTAB_WIDEN
);
3500 if (WORDS_BIG_ENDIAN
)
3502 emit_move_insn (addr
, plus_constant (mema
, ofs
+size
-1));
3506 emit_insn (gen_extwh_be (extl
, meml
, addr
));
3511 emit_insn (gen_extlh_be (extl
, meml
, addr
));
3516 emit_insn (gen_extqh_be (extl
, meml
, addr
));
3523 emit_insn (gen_extxl_be (exth
, memh
, GEN_INT (size
*8), addr
));
3527 emit_move_insn (addr
, plus_constant (mema
, ofs
));
3528 emit_insn (gen_extxl_le (extl
, meml
, GEN_INT (size
*8), addr
));
3532 emit_insn (gen_extwh_le (exth
, memh
, addr
));
3537 emit_insn (gen_extlh_le (exth
, memh
, addr
));
3542 emit_insn (gen_extqh_le (exth
, memh
, addr
));
3551 addr
= expand_binop (mode
, ior_optab
, gen_lowpart (mode
, extl
),
3552 gen_lowpart (mode
, exth
), gen_lowpart (mode
, tgt
),
3557 emit_move_insn (tgt
, gen_lowpart(GET_MODE (tgt
), addr
));
3560 /* Similarly, use ins and msk instructions to perform unaligned stores. */
3563 alpha_expand_unaligned_store (dst
, src
, size
, ofs
)
3565 HOST_WIDE_INT size
, ofs
;
3567 rtx dstl
, dsth
, addr
, insl
, insh
, meml
, memh
, dsta
;
3569 dstl
= gen_reg_rtx (DImode
);
3570 dsth
= gen_reg_rtx (DImode
);
3571 insl
= gen_reg_rtx (DImode
);
3572 insh
= gen_reg_rtx (DImode
);
3574 dsta
= XEXP (dst
, 0);
3575 if (GET_CODE (dsta
) == LO_SUM
)
3576 dsta
= force_reg (Pmode
, dsta
);
3578 /* AND addresses cannot be in any alias set, since they may implicitly
3579 alias surrounding code. Ideally we'd have some alias set that
3580 covered all types except those with alignment 8 or higher. */
3582 meml
= change_address (dst
, DImode
,
3583 gen_rtx_AND (DImode
,
3584 plus_constant (dsta
, ofs
),
3586 set_mem_alias_set (meml
, 0);
3588 memh
= change_address (dst
, DImode
,
3589 gen_rtx_AND (DImode
,
3590 plus_constant (dsta
, ofs
+ size
- 1),
3592 set_mem_alias_set (memh
, 0);
3594 emit_move_insn (dsth
, memh
);
3595 emit_move_insn (dstl
, meml
);
3596 if (WORDS_BIG_ENDIAN
)
3598 addr
= copy_addr_to_reg (plus_constant (dsta
, ofs
+size
-1));
3600 if (src
!= const0_rtx
)
3605 emit_insn (gen_inswl_be (insh
, gen_lowpart (HImode
,src
), addr
));
3608 emit_insn (gen_insll_be (insh
, gen_lowpart (SImode
,src
), addr
));
3611 emit_insn (gen_insql_be (insh
, gen_lowpart (DImode
,src
), addr
));
3614 emit_insn (gen_insxh (insl
, gen_lowpart (DImode
, src
),
3615 GEN_INT (size
*8), addr
));
3621 emit_insn (gen_mskxl_be (dsth
, dsth
, GEN_INT (0xffff), addr
));
3624 emit_insn (gen_mskxl_be (dsth
, dsth
, GEN_INT (0xffffffff), addr
));
3628 #if HOST_BITS_PER_WIDE_INT == 32
3629 rtx msk
= immed_double_const (0xffffffff, 0xffffffff, DImode
);
3631 rtx msk
= constm1_rtx
;
3633 emit_insn (gen_mskxl_be (dsth
, dsth
, msk
, addr
));
3638 emit_insn (gen_mskxh (dstl
, dstl
, GEN_INT (size
*8), addr
));
3642 addr
= copy_addr_to_reg (plus_constant (dsta
, ofs
));
3644 if (src
!= const0_rtx
)
3646 emit_insn (gen_insxh (insh
, gen_lowpart (DImode
, src
),
3647 GEN_INT (size
*8), addr
));
3652 emit_insn (gen_inswl_le (insl
, gen_lowpart (HImode
, src
), addr
));
3655 emit_insn (gen_insll_le (insl
, gen_lowpart (SImode
, src
), addr
));
3658 emit_insn (gen_insql_le (insl
, src
, addr
));
3663 emit_insn (gen_mskxh (dsth
, dsth
, GEN_INT (size
*8), addr
));
3668 emit_insn (gen_mskxl_le (dstl
, dstl
, GEN_INT (0xffff), addr
));
3671 emit_insn (gen_mskxl_le (dstl
, dstl
, GEN_INT (0xffffffff), addr
));
3675 #if HOST_BITS_PER_WIDE_INT == 32
3676 rtx msk
= immed_double_const (0xffffffff, 0xffffffff, DImode
);
3678 rtx msk
= constm1_rtx
;
3680 emit_insn (gen_mskxl_le (dstl
, dstl
, msk
, addr
));
3686 if (src
!= const0_rtx
)
3688 dsth
= expand_binop (DImode
, ior_optab
, insh
, dsth
, dsth
, 0, OPTAB_WIDEN
);
3689 dstl
= expand_binop (DImode
, ior_optab
, insl
, dstl
, dstl
, 0, OPTAB_WIDEN
);
3692 if (WORDS_BIG_ENDIAN
)
3694 emit_move_insn (meml
, dstl
);
3695 emit_move_insn (memh
, dsth
);
3699 /* Must store high before low for degenerate case of aligned. */
3700 emit_move_insn (memh
, dsth
);
3701 emit_move_insn (meml
, dstl
);
3705 /* The block move code tries to maximize speed by separating loads and
3706 stores at the expense of register pressure: we load all of the data
3707 before we store it back out. There are two secondary effects worth
3708 mentioning, that this speeds copying to/from aligned and unaligned
3709 buffers, and that it makes the code significantly easier to write. */
3711 #define MAX_MOVE_WORDS 8
3713 /* Load an integral number of consecutive unaligned quadwords. */
3716 alpha_expand_unaligned_load_words (out_regs
, smem
, words
, ofs
)
3719 HOST_WIDE_INT words
, ofs
;
3721 rtx
const im8
= GEN_INT (-8);
3722 rtx
const i64
= GEN_INT (64);
3723 rtx ext_tmps
[MAX_MOVE_WORDS
], data_regs
[MAX_MOVE_WORDS
+1];
3724 rtx sreg
, areg
, tmp
, smema
;
3727 smema
= XEXP (smem
, 0);
3728 if (GET_CODE (smema
) == LO_SUM
)
3729 smema
= force_reg (Pmode
, smema
);
3731 /* Generate all the tmp registers we need. */
3732 for (i
= 0; i
< words
; ++i
)
3734 data_regs
[i
] = out_regs
[i
];
3735 ext_tmps
[i
] = gen_reg_rtx (DImode
);
3737 data_regs
[words
] = gen_reg_rtx (DImode
);
3740 smem
= adjust_address (smem
, GET_MODE (smem
), ofs
);
3742 /* Load up all of the source data. */
3743 for (i
= 0; i
< words
; ++i
)
3745 tmp
= change_address (smem
, DImode
,
3746 gen_rtx_AND (DImode
,
3747 plus_constant (smema
, 8*i
),
3749 set_mem_alias_set (tmp
, 0);
3750 emit_move_insn (data_regs
[i
], tmp
);
3753 tmp
= change_address (smem
, DImode
,
3754 gen_rtx_AND (DImode
,
3755 plus_constant (smema
, 8*words
- 1),
3757 set_mem_alias_set (tmp
, 0);
3758 emit_move_insn (data_regs
[words
], tmp
);
3760 /* Extract the half-word fragments. Unfortunately DEC decided to make
3761 extxh with offset zero a noop instead of zeroing the register, so
3762 we must take care of that edge condition ourselves with cmov. */
3764 sreg
= copy_addr_to_reg (smema
);
3765 areg
= expand_binop (DImode
, and_optab
, sreg
, GEN_INT (7), NULL
,
3767 if (WORDS_BIG_ENDIAN
)
3768 emit_move_insn (sreg
, plus_constant (sreg
, 7));
3769 for (i
= 0; i
< words
; ++i
)
3771 if (WORDS_BIG_ENDIAN
)
3773 emit_insn (gen_extqh_be (data_regs
[i
], data_regs
[i
], sreg
));
3774 emit_insn (gen_extxl_be (ext_tmps
[i
], data_regs
[i
+1], i64
, sreg
));
3778 emit_insn (gen_extxl_le (data_regs
[i
], data_regs
[i
], i64
, sreg
));
3779 emit_insn (gen_extqh_le (ext_tmps
[i
], data_regs
[i
+1], sreg
));
3781 emit_insn (gen_rtx_SET (VOIDmode
, ext_tmps
[i
],
3782 gen_rtx_IF_THEN_ELSE (DImode
,
3783 gen_rtx_EQ (DImode
, areg
,
3785 const0_rtx
, ext_tmps
[i
])));
3788 /* Merge the half-words into whole words. */
3789 for (i
= 0; i
< words
; ++i
)
3791 out_regs
[i
] = expand_binop (DImode
, ior_optab
, data_regs
[i
],
3792 ext_tmps
[i
], data_regs
[i
], 1, OPTAB_WIDEN
);
3796 /* Store an integral number of consecutive unaligned quadwords. DATA_REGS
3797 may be NULL to store zeros. */
3800 alpha_expand_unaligned_store_words (data_regs
, dmem
, words
, ofs
)
3803 HOST_WIDE_INT words
, ofs
;
3805 rtx
const im8
= GEN_INT (-8);
3806 rtx
const i64
= GEN_INT (64);
3807 #if HOST_BITS_PER_WIDE_INT == 32
3808 rtx
const im1
= immed_double_const (0xffffffff, 0xffffffff, DImode
);
3810 rtx
const im1
= constm1_rtx
;
3812 rtx ins_tmps
[MAX_MOVE_WORDS
];
3813 rtx st_tmp_1
, st_tmp_2
, dreg
;
3814 rtx st_addr_1
, st_addr_2
, dmema
;
3817 dmema
= XEXP (dmem
, 0);
3818 if (GET_CODE (dmema
) == LO_SUM
)
3819 dmema
= force_reg (Pmode
, dmema
);
3821 /* Generate all the tmp registers we need. */
3822 if (data_regs
!= NULL
)
3823 for (i
= 0; i
< words
; ++i
)
3824 ins_tmps
[i
] = gen_reg_rtx(DImode
);
3825 st_tmp_1
= gen_reg_rtx(DImode
);
3826 st_tmp_2
= gen_reg_rtx(DImode
);
3829 dmem
= adjust_address (dmem
, GET_MODE (dmem
), ofs
);
3831 st_addr_2
= change_address (dmem
, DImode
,
3832 gen_rtx_AND (DImode
,
3833 plus_constant (dmema
, words
*8 - 1),
3835 set_mem_alias_set (st_addr_2
, 0);
3837 st_addr_1
= change_address (dmem
, DImode
,
3838 gen_rtx_AND (DImode
, dmema
, im8
));
3839 set_mem_alias_set (st_addr_1
, 0);
3841 /* Load up the destination end bits. */
3842 emit_move_insn (st_tmp_2
, st_addr_2
);
3843 emit_move_insn (st_tmp_1
, st_addr_1
);
3845 /* Shift the input data into place. */
3846 dreg
= copy_addr_to_reg (dmema
);
3847 if (WORDS_BIG_ENDIAN
)
3848 emit_move_insn (dreg
, plus_constant (dreg
, 7));
3849 if (data_regs
!= NULL
)
3851 for (i
= words
-1; i
>= 0; --i
)
3853 if (WORDS_BIG_ENDIAN
)
3855 emit_insn (gen_insql_be (ins_tmps
[i
], data_regs
[i
], dreg
));
3856 emit_insn (gen_insxh (data_regs
[i
], data_regs
[i
], i64
, dreg
));
3860 emit_insn (gen_insxh (ins_tmps
[i
], data_regs
[i
], i64
, dreg
));
3861 emit_insn (gen_insql_le (data_regs
[i
], data_regs
[i
], dreg
));
3864 for (i
= words
-1; i
> 0; --i
)
3866 ins_tmps
[i
-1] = expand_binop (DImode
, ior_optab
, data_regs
[i
],
3867 ins_tmps
[i
-1], ins_tmps
[i
-1], 1,
3872 /* Split and merge the ends with the destination data. */
3873 if (WORDS_BIG_ENDIAN
)
3875 emit_insn (gen_mskxl_be (st_tmp_2
, st_tmp_2
, im1
, dreg
));
3876 emit_insn (gen_mskxh (st_tmp_1
, st_tmp_1
, i64
, dreg
));
3880 emit_insn (gen_mskxh (st_tmp_2
, st_tmp_2
, i64
, dreg
));
3881 emit_insn (gen_mskxl_le (st_tmp_1
, st_tmp_1
, im1
, dreg
));
3884 if (data_regs
!= NULL
)
3886 st_tmp_2
= expand_binop (DImode
, ior_optab
, st_tmp_2
, ins_tmps
[words
-1],
3887 st_tmp_2
, 1, OPTAB_WIDEN
);
3888 st_tmp_1
= expand_binop (DImode
, ior_optab
, st_tmp_1
, data_regs
[0],
3889 st_tmp_1
, 1, OPTAB_WIDEN
);
3893 if (WORDS_BIG_ENDIAN
)
3894 emit_move_insn (st_addr_1
, st_tmp_1
);
3896 emit_move_insn (st_addr_2
, st_tmp_2
);
3897 for (i
= words
-1; i
> 0; --i
)
3899 rtx tmp
= change_address (dmem
, DImode
,
3900 gen_rtx_AND (DImode
,
3901 plus_constant(dmema
,
3902 WORDS_BIG_ENDIAN
? i
*8-1 : i
*8),
3904 set_mem_alias_set (tmp
, 0);
3905 emit_move_insn (tmp
, data_regs
? ins_tmps
[i
-1] : const0_rtx
);
3907 if (WORDS_BIG_ENDIAN
)
3908 emit_move_insn (st_addr_2
, st_tmp_2
);
3910 emit_move_insn (st_addr_1
, st_tmp_1
);
3914 /* Expand string/block move operations.
3916 operands[0] is the pointer to the destination.
3917 operands[1] is the pointer to the source.
3918 operands[2] is the number of bytes to move.
3919 operands[3] is the alignment. */
3922 alpha_expand_block_move (operands
)
3925 rtx bytes_rtx
= operands
[2];
3926 rtx align_rtx
= operands
[3];
3927 HOST_WIDE_INT orig_bytes
= INTVAL (bytes_rtx
);
3928 HOST_WIDE_INT bytes
= orig_bytes
;
3929 HOST_WIDE_INT src_align
= INTVAL (align_rtx
) * BITS_PER_UNIT
;
3930 HOST_WIDE_INT dst_align
= src_align
;
3931 rtx orig_src
= operands
[1];
3932 rtx orig_dst
= operands
[0];
3933 rtx data_regs
[2 * MAX_MOVE_WORDS
+ 16];
3935 unsigned int i
, words
, ofs
, nregs
= 0;
3937 if (orig_bytes
<= 0)
3939 else if (orig_bytes
> MAX_MOVE_WORDS
* UNITS_PER_WORD
)
3942 /* Look for additional alignment information from recorded register info. */
3944 tmp
= XEXP (orig_src
, 0);
3945 if (GET_CODE (tmp
) == REG
)
3946 src_align
= MAX (src_align
, REGNO_POINTER_ALIGN (REGNO (tmp
)));
3947 else if (GET_CODE (tmp
) == PLUS
3948 && GET_CODE (XEXP (tmp
, 0)) == REG
3949 && GET_CODE (XEXP (tmp
, 1)) == CONST_INT
)
3951 unsigned HOST_WIDE_INT c
= INTVAL (XEXP (tmp
, 1));
3952 unsigned int a
= REGNO_POINTER_ALIGN (REGNO (XEXP (tmp
, 0)));
3956 if (a
>= 64 && c
% 8 == 0)
3958 else if (a
>= 32 && c
% 4 == 0)
3960 else if (a
>= 16 && c
% 2 == 0)
3965 tmp
= XEXP (orig_dst
, 0);
3966 if (GET_CODE (tmp
) == REG
)
3967 dst_align
= MAX (dst_align
, REGNO_POINTER_ALIGN (REGNO (tmp
)));
3968 else if (GET_CODE (tmp
) == PLUS
3969 && GET_CODE (XEXP (tmp
, 0)) == REG
3970 && GET_CODE (XEXP (tmp
, 1)) == CONST_INT
)
3972 unsigned HOST_WIDE_INT c
= INTVAL (XEXP (tmp
, 1));
3973 unsigned int a
= REGNO_POINTER_ALIGN (REGNO (XEXP (tmp
, 0)));
3977 if (a
>= 64 && c
% 8 == 0)
3979 else if (a
>= 32 && c
% 4 == 0)
3981 else if (a
>= 16 && c
% 2 == 0)
3986 /* Load the entire block into registers. */
3987 if (GET_CODE (XEXP (orig_src
, 0)) == ADDRESSOF
)
3989 enum machine_mode mode
;
3991 tmp
= XEXP (XEXP (orig_src
, 0), 0);
3993 /* Don't use the existing register if we're reading more than
3994 is held in the register. Nor if there is not a mode that
3995 handles the exact size. */
3996 mode
= mode_for_size (bytes
* BITS_PER_UNIT
, MODE_INT
, 1);
3998 && GET_MODE_SIZE (GET_MODE (tmp
)) >= bytes
)
4002 data_regs
[nregs
] = gen_lowpart (DImode
, tmp
);
4003 data_regs
[nregs
+ 1] = gen_highpart (DImode
, tmp
);
4007 data_regs
[nregs
++] = gen_lowpart (mode
, tmp
);
4012 /* No appropriate mode; fall back on memory. */
4013 orig_src
= replace_equiv_address (orig_src
,
4014 copy_addr_to_reg (XEXP (orig_src
, 0)));
4015 src_align
= GET_MODE_BITSIZE (GET_MODE (tmp
));
4019 if (src_align
>= 64 && bytes
>= 8)
4023 for (i
= 0; i
< words
; ++i
)
4024 data_regs
[nregs
+ i
] = gen_reg_rtx (DImode
);
4026 for (i
= 0; i
< words
; ++i
)
4027 emit_move_insn (data_regs
[nregs
+ i
],
4028 adjust_address (orig_src
, DImode
, ofs
+ i
* 8));
4035 if (src_align
>= 32 && bytes
>= 4)
4039 for (i
= 0; i
< words
; ++i
)
4040 data_regs
[nregs
+ i
] = gen_reg_rtx (SImode
);
4042 for (i
= 0; i
< words
; ++i
)
4043 emit_move_insn (data_regs
[nregs
+ i
],
4044 adjust_address (orig_src
, SImode
, ofs
+ i
* 4));
4055 for (i
= 0; i
< words
+1; ++i
)
4056 data_regs
[nregs
+ i
] = gen_reg_rtx (DImode
);
4058 alpha_expand_unaligned_load_words (data_regs
+ nregs
, orig_src
,
4066 if (! TARGET_BWX
&& bytes
>= 4)
4068 data_regs
[nregs
++] = tmp
= gen_reg_rtx (SImode
);
4069 alpha_expand_unaligned_load (tmp
, orig_src
, 4, ofs
, 0);
4076 if (src_align
>= 16)
4079 data_regs
[nregs
++] = tmp
= gen_reg_rtx (HImode
);
4080 emit_move_insn (tmp
, adjust_address (orig_src
, HImode
, ofs
));
4083 } while (bytes
>= 2);
4085 else if (! TARGET_BWX
)
4087 data_regs
[nregs
++] = tmp
= gen_reg_rtx (HImode
);
4088 alpha_expand_unaligned_load (tmp
, orig_src
, 2, ofs
, 0);
4096 data_regs
[nregs
++] = tmp
= gen_reg_rtx (QImode
);
4097 emit_move_insn (tmp
, adjust_address (orig_src
, QImode
, ofs
));
4104 if (nregs
> ARRAY_SIZE (data_regs
))
4107 /* Now save it back out again. */
4111 if (GET_CODE (XEXP (orig_dst
, 0)) == ADDRESSOF
)
4113 enum machine_mode mode
;
4114 tmp
= XEXP (XEXP (orig_dst
, 0), 0);
4116 mode
= mode_for_size (orig_bytes
* BITS_PER_UNIT
, MODE_INT
, 1);
4117 if (GET_MODE (tmp
) == mode
)
4121 emit_move_insn (tmp
, data_regs
[0]);
4126 else if (nregs
== 2 && mode
== TImode
)
4128 /* Undo the subregging done above when copying between
4129 two TImode registers. */
4130 if (GET_CODE (data_regs
[0]) == SUBREG
4131 && GET_MODE (SUBREG_REG (data_regs
[0])) == TImode
)
4132 emit_move_insn (tmp
, SUBREG_REG (data_regs
[0]));
4138 emit_move_insn (gen_lowpart (DImode
, tmp
), data_regs
[0]);
4139 emit_move_insn (gen_highpart (DImode
, tmp
), data_regs
[1]);
4143 emit_no_conflict_block (seq
, tmp
, data_regs
[0],
4144 data_regs
[1], NULL_RTX
);
4152 /* ??? If nregs > 1, consider reconstructing the word in regs. */
4153 /* ??? Optimize mode < dst_mode with strict_low_part. */
4155 /* No appropriate mode; fall back on memory. We can speed things
4156 up by recognizing extra alignment information. */
4157 orig_dst
= replace_equiv_address (orig_dst
,
4158 copy_addr_to_reg (XEXP (orig_dst
, 0)));
4159 dst_align
= GET_MODE_BITSIZE (GET_MODE (tmp
));
4162 /* Write out the data in whatever chunks reading the source allowed. */
4163 if (dst_align
>= 64)
4165 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == DImode
)
4167 emit_move_insn (adjust_address (orig_dst
, DImode
, ofs
),
4174 if (dst_align
>= 32)
4176 /* If the source has remaining DImode regs, write them out in
4178 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == DImode
)
4180 tmp
= expand_binop (DImode
, lshr_optab
, data_regs
[i
], GEN_INT (32),
4181 NULL_RTX
, 1, OPTAB_WIDEN
);
4183 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
),
4184 gen_lowpart (SImode
, data_regs
[i
]));
4185 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
+ 4),
4186 gen_lowpart (SImode
, tmp
));
4191 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == SImode
)
4193 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
),
4200 if (i
< nregs
&& GET_MODE (data_regs
[i
]) == DImode
)
4202 /* Write out a remaining block of words using unaligned methods. */
4204 for (words
= 1; i
+ words
< nregs
; words
++)
4205 if (GET_MODE (data_regs
[i
+ words
]) != DImode
)
4209 alpha_expand_unaligned_store (orig_dst
, data_regs
[i
], 8, ofs
);
4211 alpha_expand_unaligned_store_words (data_regs
+ i
, orig_dst
,
4218 /* Due to the above, this won't be aligned. */
4219 /* ??? If we have more than one of these, consider constructing full
4220 words in registers and using alpha_expand_unaligned_store_words. */
4221 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == SImode
)
4223 alpha_expand_unaligned_store (orig_dst
, data_regs
[i
], 4, ofs
);
4228 if (dst_align
>= 16)
4229 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == HImode
)
4231 emit_move_insn (adjust_address (orig_dst
, HImode
, ofs
), data_regs
[i
]);
4236 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == HImode
)
4238 alpha_expand_unaligned_store (orig_dst
, data_regs
[i
], 2, ofs
);
4243 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == QImode
)
4245 emit_move_insn (adjust_address (orig_dst
, QImode
, ofs
), data_regs
[i
]);
4259 alpha_expand_block_clear (operands
)
4262 rtx bytes_rtx
= operands
[1];
4263 rtx align_rtx
= operands
[2];
4264 HOST_WIDE_INT orig_bytes
= INTVAL (bytes_rtx
);
4265 HOST_WIDE_INT bytes
= orig_bytes
;
4266 HOST_WIDE_INT align
= INTVAL (align_rtx
) * BITS_PER_UNIT
;
4267 HOST_WIDE_INT alignofs
= 0;
4268 rtx orig_dst
= operands
[0];
4270 int i
, words
, ofs
= 0;
4272 if (orig_bytes
<= 0)
4274 if (orig_bytes
> MAX_MOVE_WORDS
* UNITS_PER_WORD
)
4277 /* Look for stricter alignment. */
4278 tmp
= XEXP (orig_dst
, 0);
4279 if (GET_CODE (tmp
) == REG
)
4280 align
= MAX (align
, REGNO_POINTER_ALIGN (REGNO (tmp
)));
4281 else if (GET_CODE (tmp
) == PLUS
4282 && GET_CODE (XEXP (tmp
, 0)) == REG
4283 && GET_CODE (XEXP (tmp
, 1)) == CONST_INT
)
4285 HOST_WIDE_INT c
= INTVAL (XEXP (tmp
, 1));
4286 int a
= REGNO_POINTER_ALIGN (REGNO (XEXP (tmp
, 0)));
4291 align
= a
, alignofs
= 8 - c
% 8;
4293 align
= a
, alignofs
= 4 - c
% 4;
4295 align
= a
, alignofs
= 2 - c
% 2;
4298 else if (GET_CODE (tmp
) == ADDRESSOF
)
4300 enum machine_mode mode
;
4302 mode
= mode_for_size (bytes
* BITS_PER_UNIT
, MODE_INT
, 1);
4303 if (GET_MODE (XEXP (tmp
, 0)) == mode
)
4305 emit_move_insn (XEXP (tmp
, 0), const0_rtx
);
4309 /* No appropriate mode; fall back on memory. */
4310 orig_dst
= replace_equiv_address (orig_dst
, copy_addr_to_reg (tmp
));
4311 align
= GET_MODE_BITSIZE (GET_MODE (XEXP (tmp
, 0)));
4314 /* Handle an unaligned prefix first. */
4318 #if HOST_BITS_PER_WIDE_INT >= 64
4319 /* Given that alignofs is bounded by align, the only time BWX could
4320 generate three stores is for a 7 byte fill. Prefer two individual
4321 stores over a load/mask/store sequence. */
4322 if ((!TARGET_BWX
|| alignofs
== 7)
4324 && !(alignofs
== 4 && bytes
>= 4))
4326 enum machine_mode mode
= (align
>= 64 ? DImode
: SImode
);
4327 int inv_alignofs
= (align
>= 64 ? 8 : 4) - alignofs
;
4331 mem
= adjust_address (orig_dst
, mode
, ofs
- inv_alignofs
);
4332 set_mem_alias_set (mem
, 0);
4334 mask
= ~(~(HOST_WIDE_INT
)0 << (inv_alignofs
* 8));
4335 if (bytes
< alignofs
)
4337 mask
|= ~(HOST_WIDE_INT
)0 << ((inv_alignofs
+ bytes
) * 8);
4348 tmp
= expand_binop (mode
, and_optab
, mem
, GEN_INT (mask
),
4349 NULL_RTX
, 1, OPTAB_WIDEN
);
4351 emit_move_insn (mem
, tmp
);
4355 if (TARGET_BWX
&& (alignofs
& 1) && bytes
>= 1)
4357 emit_move_insn (adjust_address (orig_dst
, QImode
, ofs
), const0_rtx
);
4362 if (TARGET_BWX
&& align
>= 16 && (alignofs
& 3) == 2 && bytes
>= 2)
4364 emit_move_insn (adjust_address (orig_dst
, HImode
, ofs
), const0_rtx
);
4369 if (alignofs
== 4 && bytes
>= 4)
4371 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
), const0_rtx
);
4377 /* If we've not used the extra lead alignment information by now,
4378 we won't be able to. Downgrade align to match what's left over. */
4381 alignofs
= alignofs
& -alignofs
;
4382 align
= MIN (align
, alignofs
* BITS_PER_UNIT
);
4386 /* Handle a block of contiguous long-words. */
4388 if (align
>= 64 && bytes
>= 8)
4392 for (i
= 0; i
< words
; ++i
)
4393 emit_move_insn (adjust_address (orig_dst
, DImode
, ofs
+ i
* 8),
4400 /* If the block is large and appropriately aligned, emit a single
4401 store followed by a sequence of stq_u insns. */
4403 if (align
>= 32 && bytes
> 16)
4407 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
), const0_rtx
);
4411 orig_dsta
= XEXP (orig_dst
, 0);
4412 if (GET_CODE (orig_dsta
) == LO_SUM
)
4413 orig_dsta
= force_reg (Pmode
, orig_dsta
);
4416 for (i
= 0; i
< words
; ++i
)
4419 = change_address (orig_dst
, DImode
,
4420 gen_rtx_AND (DImode
,
4421 plus_constant (orig_dsta
, ofs
+ i
*8),
4423 set_mem_alias_set (mem
, 0);
4424 emit_move_insn (mem
, const0_rtx
);
4427 /* Depending on the alignment, the first stq_u may have overlapped
4428 with the initial stl, which means that the last stq_u didn't
4429 write as much as it would appear. Leave those questionable bytes
4431 bytes
-= words
* 8 - 4;
4432 ofs
+= words
* 8 - 4;
4435 /* Handle a smaller block of aligned words. */
4437 if ((align
>= 64 && bytes
== 4)
4438 || (align
== 32 && bytes
>= 4))
4442 for (i
= 0; i
< words
; ++i
)
4443 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
+ i
* 4),
4450 /* An unaligned block uses stq_u stores for as many as possible. */
4456 alpha_expand_unaligned_store_words (NULL
, orig_dst
, words
, ofs
);
4462 /* Next clean up any trailing pieces. */
4464 #if HOST_BITS_PER_WIDE_INT >= 64
4465 /* Count the number of bits in BYTES for which aligned stores could
4468 for (i
= (TARGET_BWX
? 1 : 4); i
* BITS_PER_UNIT
<= align
; i
<<= 1)
4472 /* If we have appropriate alignment (and it wouldn't take too many
4473 instructions otherwise), mask out the bytes we need. */
4474 if (TARGET_BWX
? words
> 2 : bytes
> 0)
4481 mem
= adjust_address (orig_dst
, DImode
, ofs
);
4482 set_mem_alias_set (mem
, 0);
4484 mask
= ~(HOST_WIDE_INT
)0 << (bytes
* 8);
4486 tmp
= expand_binop (DImode
, and_optab
, mem
, GEN_INT (mask
),
4487 NULL_RTX
, 1, OPTAB_WIDEN
);
4489 emit_move_insn (mem
, tmp
);
4492 else if (align
>= 32 && bytes
< 4)
4497 mem
= adjust_address (orig_dst
, SImode
, ofs
);
4498 set_mem_alias_set (mem
, 0);
4500 mask
= ~(HOST_WIDE_INT
)0 << (bytes
* 8);
4502 tmp
= expand_binop (SImode
, and_optab
, mem
, GEN_INT (mask
),
4503 NULL_RTX
, 1, OPTAB_WIDEN
);
4505 emit_move_insn (mem
, tmp
);
4511 if (!TARGET_BWX
&& bytes
>= 4)
4513 alpha_expand_unaligned_store (orig_dst
, const0_rtx
, 4, ofs
);
4523 emit_move_insn (adjust_address (orig_dst
, HImode
, ofs
),
4527 } while (bytes
>= 2);
4529 else if (! TARGET_BWX
)
4531 alpha_expand_unaligned_store (orig_dst
, const0_rtx
, 2, ofs
);
4539 emit_move_insn (adjust_address (orig_dst
, QImode
, ofs
), const0_rtx
);
4547 /* Adjust the cost of a scheduling dependency. Return the new cost of
4548 a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
4551 alpha_adjust_cost (insn
, link
, dep_insn
, cost
)
4558 enum attr_type insn_type
, dep_insn_type
;
4560 /* If the dependence is an anti-dependence, there is no cost. For an
4561 output dependence, there is sometimes a cost, but it doesn't seem
4562 worth handling those few cases. */
4564 if (REG_NOTE_KIND (link
) != 0)
4567 /* If we can't recognize the insns, we can't really do anything. */
4568 if (recog_memoized (insn
) < 0 || recog_memoized (dep_insn
) < 0)
4571 insn_type
= get_attr_type (insn
);
4572 dep_insn_type
= get_attr_type (dep_insn
);
4574 /* Bring in the user-defined memory latency. */
4575 if (dep_insn_type
== TYPE_ILD
4576 || dep_insn_type
== TYPE_FLD
4577 || dep_insn_type
== TYPE_LDSYM
)
4578 cost
+= alpha_memory_latency
-1;
4583 /* On EV4, if INSN is a store insn and DEP_INSN is setting the data
4584 being stored, we can sometimes lower the cost. */
4586 if ((insn_type
== TYPE_IST
|| insn_type
== TYPE_FST
)
4587 && (set
= single_set (dep_insn
)) != 0
4588 && GET_CODE (PATTERN (insn
)) == SET
4589 && rtx_equal_p (SET_DEST (set
), SET_SRC (PATTERN (insn
))))
4591 switch (dep_insn_type
)
4595 /* No savings here. */
4599 /* In these cases, we save one cycle. */
4603 /* In all other cases, we save two cycles. */
4604 return MAX (0, cost
- 2);
4608 /* Another case that needs adjustment is an arithmetic or logical
4609 operation. It's cost is usually one cycle, but we default it to
4610 two in the MD file. The only case that it is actually two is
4611 for the address in loads, stores, and jumps. */
4613 if (dep_insn_type
== TYPE_IADD
|| dep_insn_type
== TYPE_ILOG
)
4628 /* The final case is when a compare feeds into an integer branch;
4629 the cost is only one cycle in that case. */
4631 if (dep_insn_type
== TYPE_ICMP
&& insn_type
== TYPE_IBR
)
4636 /* And the lord DEC saith: "A special bypass provides an effective
4637 latency of 0 cycles for an ICMP or ILOG insn producing the test
4638 operand of an IBR or ICMOV insn." */
4640 if ((dep_insn_type
== TYPE_ICMP
|| dep_insn_type
== TYPE_ILOG
)
4641 && (set
= single_set (dep_insn
)) != 0)
4643 /* A branch only has one input. This must be it. */
4644 if (insn_type
== TYPE_IBR
)
4646 /* A conditional move has three, make sure it is the test. */
4647 if (insn_type
== TYPE_ICMOV
4648 && GET_CODE (set_src
= PATTERN (insn
)) == SET
4649 && GET_CODE (set_src
= SET_SRC (set_src
)) == IF_THEN_ELSE
4650 && rtx_equal_p (SET_DEST (set
), XEXP (set_src
, 0)))
4654 /* "The multiplier is unable to receive data from IEU bypass paths.
4655 The instruction issues at the expected time, but its latency is
4656 increased by the time it takes for the input data to become
4657 available to the multiplier" -- which happens in pipeline stage
4658 six, when results are comitted to the register file. */
4660 if (insn_type
== TYPE_IMUL
)
4662 switch (dep_insn_type
)
4664 /* These insns produce their results in pipeline stage five. */
4671 /* Other integer insns produce results in pipeline stage four. */
4679 /* There is additional latency to move the result of (most) FP
4680 operations anywhere but the FP register file. */
4682 if ((insn_type
== TYPE_FST
|| insn_type
== TYPE_FTOI
)
4683 && (dep_insn_type
== TYPE_FADD
||
4684 dep_insn_type
== TYPE_FMUL
||
4685 dep_insn_type
== TYPE_FCMOV
))
4691 /* Otherwise, return the default cost. */
4695 /* Function to initialize the issue rate used by the scheduler. */
4699 return (alpha_cpu
== PROCESSOR_EV4
? 2 : 4);
4703 alpha_variable_issue (dump
, verbose
, insn
, cim
)
4704 FILE *dump ATTRIBUTE_UNUSED
;
4705 int verbose ATTRIBUTE_UNUSED
;
4709 if (recog_memoized (insn
) < 0 || get_attr_type (insn
) == TYPE_MULTI
)
4716 /* Register global variables and machine-specific functions with the
4717 garbage collector. */
4719 #if TARGET_ABI_UNICOSMK
4721 alpha_init_machine_status (p
)
4725 (struct machine_function
*) xcalloc (1, sizeof (struct machine_function
));
4727 p
->machine
->first_ciw
= NULL_RTX
;
4728 p
->machine
->last_ciw
= NULL_RTX
;
4729 p
->machine
->ciw_count
= 0;
4730 p
->machine
->addr_list
= NULL_RTX
;
4734 alpha_mark_machine_status (p
)
4737 struct machine_function
*machine
= p
->machine
;
4741 ggc_mark_rtx (machine
->first_ciw
);
4742 ggc_mark_rtx (machine
->addr_list
);
4747 alpha_free_machine_status (p
)
4753 #endif /* TARGET_ABI_UNICOSMK */
4755 /* Functions to save and restore alpha_return_addr_rtx. */
4757 /* Start the ball rolling with RETURN_ADDR_RTX. */
4760 alpha_return_addr (count
, frame
)
4762 rtx frame ATTRIBUTE_UNUSED
;
4767 return get_hard_reg_initial_val (Pmode
, REG_RA
);
4770 /* Return or create a pseudo containing the gp value for the current
4771 function. Needed only if TARGET_LD_BUGGY_LDGP. */
4774 alpha_gp_save_rtx ()
4776 return get_hard_reg_initial_val (DImode
, 29);
4780 alpha_ra_ever_killed ()
4784 #ifdef ASM_OUTPUT_MI_THUNK
4785 if (current_function_is_thunk
)
4788 if (!has_hard_reg_initial_val (Pmode
, REG_RA
))
4789 return regs_ever_live
[REG_RA
];
4791 push_topmost_sequence ();
4793 pop_topmost_sequence ();
4795 return reg_set_between_p (gen_rtx_REG (Pmode
, REG_RA
), top
, NULL_RTX
);
4799 /* Return the trap mode suffix applicable to the current
4800 instruction, or NULL. */
4803 get_trap_mode_suffix ()
4805 enum attr_trap_suffix s
= get_attr_trap_suffix (current_output_insn
);
4809 case TRAP_SUFFIX_NONE
:
4812 case TRAP_SUFFIX_SU
:
4813 if (alpha_fptm
>= ALPHA_FPTM_SU
)
4817 case TRAP_SUFFIX_SUI
:
4818 if (alpha_fptm
>= ALPHA_FPTM_SUI
)
4822 case TRAP_SUFFIX_V_SV
:
4830 case ALPHA_FPTM_SUI
:
4835 case TRAP_SUFFIX_V_SV_SVI
:
4844 case ALPHA_FPTM_SUI
:
4849 case TRAP_SUFFIX_U_SU_SUI
:
4858 case ALPHA_FPTM_SUI
:
4866 /* Return the rounding mode suffix applicable to the current
4867 instruction, or NULL. */
4870 get_round_mode_suffix ()
4872 enum attr_round_suffix s
= get_attr_round_suffix (current_output_insn
);
4876 case ROUND_SUFFIX_NONE
:
4878 case ROUND_SUFFIX_NORMAL
:
4881 case ALPHA_FPRM_NORM
:
4883 case ALPHA_FPRM_MINF
:
4885 case ALPHA_FPRM_CHOP
:
4887 case ALPHA_FPRM_DYN
:
4892 case ROUND_SUFFIX_C
:
4898 /* Print an operand. Recognize special options, documented below. */
4901 print_operand (file
, x
, code
)
4911 /* Print the assembler name of the current function. */
4912 assemble_name (file
, alpha_fnname
);
4917 const char *trap
= get_trap_mode_suffix ();
4918 const char *round
= get_round_mode_suffix ();
4921 fprintf (file
, (TARGET_AS_SLASH_BEFORE_SUFFIX
? "/%s%s" : "%s%s"),
4922 (trap
? trap
: ""), (round
? round
: ""));
4927 /* Generates single precision instruction suffix. */
4928 fputc ((TARGET_FLOAT_VAX
? 'f' : 's'), file
);
4932 /* Generates double precision instruction suffix. */
4933 fputc ((TARGET_FLOAT_VAX
? 'g' : 't'), file
);
4937 if (alpha_this_literal_sequence_number
== 0)
4938 alpha_this_literal_sequence_number
= alpha_next_sequence_number
++;
4939 fprintf (file
, "%d", alpha_this_literal_sequence_number
);
4943 if (alpha_this_gpdisp_sequence_number
== 0)
4944 alpha_this_gpdisp_sequence_number
= alpha_next_sequence_number
++;
4945 fprintf (file
, "%d", alpha_this_gpdisp_sequence_number
);
4949 if (GET_CODE (x
) == HIGH
)
4950 output_addr_const (file
, XEXP (x
, 0));
4952 output_operand_lossage ("invalid %%H value");
4956 /* If this operand is the constant zero, write it as "$31". */
4957 if (GET_CODE (x
) == REG
)
4958 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
4959 else if (x
== CONST0_RTX (GET_MODE (x
)))
4960 fprintf (file
, "$31");
4962 output_operand_lossage ("invalid %%r value");
4966 /* Similar, but for floating-point. */
4967 if (GET_CODE (x
) == REG
)
4968 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
4969 else if (x
== CONST0_RTX (GET_MODE (x
)))
4970 fprintf (file
, "$f31");
4972 output_operand_lossage ("invalid %%R value");
4976 /* Write the 1's complement of a constant. */
4977 if (GET_CODE (x
) != CONST_INT
)
4978 output_operand_lossage ("invalid %%N value");
4980 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, ~ INTVAL (x
));
4984 /* Write 1 << C, for a constant C. */
4985 if (GET_CODE (x
) != CONST_INT
)
4986 output_operand_lossage ("invalid %%P value");
4988 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, (HOST_WIDE_INT
) 1 << INTVAL (x
));
4992 /* Write the high-order 16 bits of a constant, sign-extended. */
4993 if (GET_CODE (x
) != CONST_INT
)
4994 output_operand_lossage ("invalid %%h value");
4996 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
) >> 16);
5000 /* Write the low-order 16 bits of a constant, sign-extended. */
5001 if (GET_CODE (x
) != CONST_INT
)
5002 output_operand_lossage ("invalid %%L value");
5004 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
5005 (INTVAL (x
) & 0xffff) - 2 * (INTVAL (x
) & 0x8000));
5009 /* Write mask for ZAP insn. */
5010 if (GET_CODE (x
) == CONST_DOUBLE
)
5012 HOST_WIDE_INT mask
= 0;
5013 HOST_WIDE_INT value
;
5015 value
= CONST_DOUBLE_LOW (x
);
5016 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
;
5021 value
= CONST_DOUBLE_HIGH (x
);
5022 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
;
5025 mask
|= (1 << (i
+ sizeof (int)));
5027 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, mask
& 0xff);
5030 else if (GET_CODE (x
) == CONST_INT
)
5032 HOST_WIDE_INT mask
= 0, value
= INTVAL (x
);
5034 for (i
= 0; i
< 8; i
++, value
>>= 8)
5038 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, mask
);
5041 output_operand_lossage ("invalid %%m value");
5045 /* 'b', 'w', 'l', or 'q' as the value of the constant. */
5046 if (GET_CODE (x
) != CONST_INT
5047 || (INTVAL (x
) != 8 && INTVAL (x
) != 16
5048 && INTVAL (x
) != 32 && INTVAL (x
) != 64))
5049 output_operand_lossage ("invalid %%M value");
5051 fprintf (file
, "%s",
5052 (INTVAL (x
) == 8 ? "b"
5053 : INTVAL (x
) == 16 ? "w"
5054 : INTVAL (x
) == 32 ? "l"
5059 /* Similar, except do it from the mask. */
5060 if (GET_CODE (x
) == CONST_INT
&& INTVAL (x
) == 0xff)
5061 fprintf (file
, "b");
5062 else if (GET_CODE (x
) == CONST_INT
&& INTVAL (x
) == 0xffff)
5063 fprintf (file
, "w");
5064 else if (GET_CODE (x
) == CONST_INT
&& INTVAL (x
) == 0xffffffff)
5065 fprintf (file
, "l");
5066 #if HOST_BITS_PER_WIDE_INT == 32
5067 else if (GET_CODE (x
) == CONST_DOUBLE
5068 && CONST_DOUBLE_HIGH (x
) == 0
5069 && CONST_DOUBLE_LOW (x
) == -1)
5070 fprintf (file
, "l");
5071 else if (GET_CODE (x
) == CONST_DOUBLE
5072 && CONST_DOUBLE_HIGH (x
) == -1
5073 && CONST_DOUBLE_LOW (x
) == -1)
5074 fprintf (file
, "q");
5076 else if (GET_CODE (x
) == CONST_INT
&& INTVAL (x
) == -1)
5077 fprintf (file
, "q");
5078 else if (GET_CODE (x
) == CONST_DOUBLE
5079 && CONST_DOUBLE_HIGH (x
) == 0
5080 && CONST_DOUBLE_LOW (x
) == -1)
5081 fprintf (file
, "q");
5084 output_operand_lossage ("invalid %%U value");
5088 /* Write the constant value divided by 8 for little-endian mode or
5089 (56 - value) / 8 for big-endian mode. */
5091 if (GET_CODE (x
) != CONST_INT
5092 || (unsigned HOST_WIDE_INT
) INTVAL (x
) >= (WORDS_BIG_ENDIAN
5095 || (INTVAL (x
) & 7) != 0)
5096 output_operand_lossage ("invalid %%s value");
5098 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
5100 ? (56 - INTVAL (x
)) / 8
5105 /* Same, except compute (64 - c) / 8 */
5107 if (GET_CODE (x
) != CONST_INT
5108 && (unsigned HOST_WIDE_INT
) INTVAL (x
) >= 64
5109 && (INTVAL (x
) & 7) != 8)
5110 output_operand_lossage ("invalid %%s value");
5112 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, (64 - INTVAL (x
)) / 8);
5117 /* On Unicos/Mk systems: use a DEX expression if the symbol
5118 clashes with a register name. */
5119 int dex
= unicosmk_need_dex (x
);
5121 fprintf (file
, "DEX(%d)", dex
);
5123 output_addr_const (file
, x
);
5127 case 'C': case 'D': case 'c': case 'd':
5128 /* Write out comparison name. */
5130 enum rtx_code c
= GET_CODE (x
);
5132 if (GET_RTX_CLASS (c
) != '<')
5133 output_operand_lossage ("invalid %%C value");
5135 else if (code
== 'D')
5136 c
= reverse_condition (c
);
5137 else if (code
== 'c')
5138 c
= swap_condition (c
);
5139 else if (code
== 'd')
5140 c
= swap_condition (reverse_condition (c
));
5143 fprintf (file
, "ule");
5145 fprintf (file
, "ult");
5146 else if (c
== UNORDERED
)
5147 fprintf (file
, "un");
5149 fprintf (file
, "%s", GET_RTX_NAME (c
));
5154 /* Write the divide or modulus operator. */
5155 switch (GET_CODE (x
))
5158 fprintf (file
, "div%s", GET_MODE (x
) == SImode
? "l" : "q");
5161 fprintf (file
, "div%su", GET_MODE (x
) == SImode
? "l" : "q");
5164 fprintf (file
, "rem%s", GET_MODE (x
) == SImode
? "l" : "q");
5167 fprintf (file
, "rem%su", GET_MODE (x
) == SImode
? "l" : "q");
5170 output_operand_lossage ("invalid %%E value");
5176 /* Write "_u" for unaligned access. */
5177 if (GET_CODE (x
) == MEM
&& GET_CODE (XEXP (x
, 0)) == AND
)
5178 fprintf (file
, "_u");
5182 if (GET_CODE (x
) == REG
)
5183 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
5184 else if (GET_CODE (x
) == MEM
)
5185 output_address (XEXP (x
, 0));
5187 output_addr_const (file
, x
);
5191 output_operand_lossage ("invalid %%xn code");
5196 print_operand_address (file
, addr
)
5201 HOST_WIDE_INT offset
= 0;
5203 if (GET_CODE (addr
) == AND
)
5204 addr
= XEXP (addr
, 0);
5206 if (GET_CODE (addr
) == PLUS
5207 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
5209 offset
= INTVAL (XEXP (addr
, 1));
5210 addr
= XEXP (addr
, 0);
5213 if (GET_CODE (addr
) == LO_SUM
)
5215 output_addr_const (file
, XEXP (addr
, 1));
5219 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, offset
);
5222 addr
= XEXP (addr
, 0);
5223 if (GET_CODE (addr
) == REG
)
5224 basereg
= REGNO (addr
);
5225 else if (GET_CODE (addr
) == SUBREG
5226 && GET_CODE (SUBREG_REG (addr
)) == REG
)
5227 basereg
= subreg_regno (addr
);
5231 fprintf (file
, "($%d)\t\t!%s", basereg
,
5232 (basereg
== 29 ? "gprel" : "gprellow"));
5236 if (GET_CODE (addr
) == REG
)
5237 basereg
= REGNO (addr
);
5238 else if (GET_CODE (addr
) == SUBREG
5239 && GET_CODE (SUBREG_REG (addr
)) == REG
)
5240 basereg
= subreg_regno (addr
);
5241 else if (GET_CODE (addr
) == CONST_INT
)
5242 offset
= INTVAL (addr
);
5246 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, offset
);
5247 fprintf (file
, "($%d)", basereg
);
5250 /* Emit RTL insns to initialize the variable parts of a trampoline at
5251 TRAMP. FNADDR is an RTX for the address of the function's pure
5252 code. CXT is an RTX for the static chain value for the function.
5254 The three offset parameters are for the individual template's
5255 layout. A JMPOFS < 0 indicates that the trampoline does not
5256 contain instructions at all.
5258 We assume here that a function will be called many more times than
5259 its address is taken (e.g., it might be passed to qsort), so we
5260 take the trouble to initialize the "hint" field in the JMP insn.
5261 Note that the hint field is PC (new) + 4 * bits 13:0. */
5264 alpha_initialize_trampoline (tramp
, fnaddr
, cxt
, fnofs
, cxtofs
, jmpofs
)
5265 rtx tramp
, fnaddr
, cxt
;
5266 int fnofs
, cxtofs
, jmpofs
;
5268 rtx temp
, temp1
, addr
;
5269 /* VMS really uses DImode pointers in memory at this point. */
5270 enum machine_mode mode
= TARGET_ABI_OPEN_VMS
? Pmode
: ptr_mode
;
5272 #ifdef POINTERS_EXTEND_UNSIGNED
5273 fnaddr
= convert_memory_address (mode
, fnaddr
);
5274 cxt
= convert_memory_address (mode
, cxt
);
5277 /* Store function address and CXT. */
5278 addr
= memory_address (mode
, plus_constant (tramp
, fnofs
));
5279 emit_move_insn (gen_rtx_MEM (mode
, addr
), fnaddr
);
5280 addr
= memory_address (mode
, plus_constant (tramp
, cxtofs
));
5281 emit_move_insn (gen_rtx_MEM (mode
, addr
), cxt
);
5283 /* This has been disabled since the hint only has a 32k range, and in
5284 no existing OS is the stack within 32k of the text segment. */
5285 if (0 && jmpofs
>= 0)
5287 /* Compute hint value. */
5288 temp
= force_operand (plus_constant (tramp
, jmpofs
+4), NULL_RTX
);
5289 temp
= expand_binop (DImode
, sub_optab
, fnaddr
, temp
, temp
, 1,
5291 temp
= expand_shift (RSHIFT_EXPR
, Pmode
, temp
,
5292 build_int_2 (2, 0), NULL_RTX
, 1);
5293 temp
= expand_and (gen_lowpart (SImode
, temp
), GEN_INT (0x3fff), 0);
5295 /* Merge in the hint. */
5296 addr
= memory_address (SImode
, plus_constant (tramp
, jmpofs
));
5297 temp1
= force_reg (SImode
, gen_rtx_MEM (SImode
, addr
));
5298 temp1
= expand_and (temp1
, GEN_INT (0xffffc000), NULL_RTX
);
5299 temp1
= expand_binop (SImode
, ior_optab
, temp1
, temp
, temp1
, 1,
5301 emit_move_insn (gen_rtx_MEM (SImode
, addr
), temp1
);
5304 #ifdef TRANSFER_FROM_TRAMPOLINE
5305 emit_library_call (gen_rtx_SYMBOL_REF (Pmode
, "__enable_execute_stack"),
5306 0, VOIDmode
, 1, addr
, Pmode
);
5310 emit_insn (gen_imb ());
5313 /* Determine where to put an argument to a function.
5314 Value is zero to push the argument on the stack,
5315 or a hard register in which to store the argument.
5317 MODE is the argument's machine mode.
5318 TYPE is the data type of the argument (as a tree).
5319 This is null for libcalls where that information may
5321 CUM is a variable of type CUMULATIVE_ARGS which gives info about
5322 the preceding args and about the function being called.
5323 NAMED is nonzero if this argument is a named parameter
5324 (otherwise it is an extra parameter matching an ellipsis).
5326 On Alpha the first 6 words of args are normally in registers
5327 and the rest are pushed. */
5330 function_arg (cum
, mode
, type
, named
)
5331 CUMULATIVE_ARGS cum
;
5332 enum machine_mode mode
;
5334 int named ATTRIBUTE_UNUSED
;
5339 /* Set up defaults for FP operands passed in FP registers, and
5340 integral operands passed in integer registers. */
5342 && (GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
5343 || GET_MODE_CLASS (mode
) == MODE_FLOAT
))
5348 /* ??? Irritatingly, the definition of CUMULATIVE_ARGS is different for
5349 the three platforms, so we can't avoid conditional compilation. */
5350 #if TARGET_ABI_OPEN_VMS
5352 if (mode
== VOIDmode
)
5353 return alpha_arg_info_reg_val (cum
);
5355 num_args
= cum
.num_args
;
5356 if (num_args
>= 6 || MUST_PASS_IN_STACK (mode
, type
))
5360 #if TARGET_ABI_UNICOSMK
5364 /* If this is the last argument, generate the call info word (CIW). */
5365 /* ??? We don't include the caller's line number in the CIW because
5366 I don't know how to determine it if debug infos are turned off. */
5367 if (mode
== VOIDmode
)
5376 for (i
= 0; i
< cum
.num_reg_words
&& i
< 5; i
++)
5377 if (cum
.reg_args_type
[i
])
5378 lo
|= (1 << (7 - i
));
5380 if (cum
.num_reg_words
== 6 && cum
.reg_args_type
[5])
5383 lo
|= cum
.num_reg_words
;
5385 #if HOST_BITS_PER_WIDE_INT == 32
5386 hi
= (cum
.num_args
<< 20) | cum
.num_arg_words
;
5388 lo
= lo
| ((HOST_WIDE_INT
) cum
.num_args
<< 52)
5389 | ((HOST_WIDE_INT
) cum
.num_arg_words
<< 32);
5392 ciw
= immed_double_const (lo
, hi
, DImode
);
5394 return gen_rtx_UNSPEC (DImode
, gen_rtvec (1, ciw
),
5395 UNSPEC_UMK_LOAD_CIW
);
5398 size
= ALPHA_ARG_SIZE (mode
, type
, named
);
5399 num_args
= cum
.num_reg_words
;
5400 if (MUST_PASS_IN_STACK (mode
, type
)
5401 || cum
.num_reg_words
+ size
> 6 || cum
.force_stack
)
5403 else if (type
&& TYPE_MODE (type
) == BLKmode
)
5407 reg1
= gen_rtx_REG (DImode
, num_args
+ 16);
5408 reg1
= gen_rtx_EXPR_LIST (DImode
, reg1
, const0_rtx
);
5410 /* The argument fits in two registers. Note that we still need to
5411 reserve a register for empty structures. */
5415 return gen_rtx_PARALLEL (mode
, gen_rtvec (1, reg1
));
5418 reg2
= gen_rtx_REG (DImode
, num_args
+ 17);
5419 reg2
= gen_rtx_EXPR_LIST (DImode
, reg2
, GEN_INT (8));
5420 return gen_rtx_PARALLEL (mode
, gen_rtvec (2, reg1
, reg2
));
5430 /* VOID is passed as a special flag for "last argument". */
5431 if (type
== void_type_node
)
5433 else if (MUST_PASS_IN_STACK (mode
, type
))
5435 else if (FUNCTION_ARG_PASS_BY_REFERENCE (cum
, mode
, type
, named
))
5438 #endif /* TARGET_ABI_UNICOSMK */
5439 #endif /* TARGET_ABI_OPEN_VMS */
5441 return gen_rtx_REG (mode
, num_args
+ basereg
);
5445 alpha_build_va_list ()
5447 tree base
, ofs
, record
, type_decl
;
5449 if (TARGET_ABI_OPEN_VMS
|| TARGET_ABI_UNICOSMK
)
5450 return ptr_type_node
;
5452 record
= make_lang_type (RECORD_TYPE
);
5453 type_decl
= build_decl (TYPE_DECL
, get_identifier ("__va_list_tag"), record
);
5454 TREE_CHAIN (record
) = type_decl
;
5455 TYPE_NAME (record
) = type_decl
;
5457 /* C++? SET_IS_AGGR_TYPE (record, 1); */
5459 ofs
= build_decl (FIELD_DECL
, get_identifier ("__offset"),
5461 DECL_FIELD_CONTEXT (ofs
) = record
;
5463 base
= build_decl (FIELD_DECL
, get_identifier ("__base"),
5465 DECL_FIELD_CONTEXT (base
) = record
;
5466 TREE_CHAIN (base
) = ofs
;
5468 TYPE_FIELDS (record
) = base
;
5469 layout_type (record
);
5475 alpha_va_start (stdarg_p
, valist
, nextarg
)
5478 rtx nextarg ATTRIBUTE_UNUSED
;
5480 HOST_WIDE_INT offset
;
5481 tree t
, offset_field
, base_field
;
5483 if (TREE_CODE (TREE_TYPE (valist
)) == ERROR_MARK
)
5486 if (TARGET_ABI_UNICOSMK
)
5487 std_expand_builtin_va_start (stdarg_p
, valist
, nextarg
);
5489 /* For Unix, SETUP_INCOMING_VARARGS moves the starting address base
5490 up by 48, storing fp arg registers in the first 48 bytes, and the
5491 integer arg registers in the next 48 bytes. This is only done,
5492 however, if any integer registers need to be stored.
5494 If no integer registers need be stored, then we must subtract 48
5495 in order to account for the integer arg registers which are counted
5496 in argsize above, but which are not actually stored on the stack. */
5498 if (NUM_ARGS
<= 5 + stdarg_p
)
5499 offset
= TARGET_ABI_OPEN_VMS
? UNITS_PER_WORD
: 6 * UNITS_PER_WORD
;
5501 offset
= -6 * UNITS_PER_WORD
;
5503 if (TARGET_ABI_OPEN_VMS
)
5505 nextarg
= plus_constant (nextarg
, offset
);
5506 nextarg
= plus_constant (nextarg
, NUM_ARGS
* UNITS_PER_WORD
);
5507 t
= build (MODIFY_EXPR
, TREE_TYPE (valist
), valist
,
5508 make_tree (ptr_type_node
, nextarg
));
5509 TREE_SIDE_EFFECTS (t
) = 1;
5511 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
5515 base_field
= TYPE_FIELDS (TREE_TYPE (valist
));
5516 offset_field
= TREE_CHAIN (base_field
);
5518 base_field
= build (COMPONENT_REF
, TREE_TYPE (base_field
),
5519 valist
, base_field
);
5520 offset_field
= build (COMPONENT_REF
, TREE_TYPE (offset_field
),
5521 valist
, offset_field
);
5523 t
= make_tree (ptr_type_node
, virtual_incoming_args_rtx
);
5524 t
= build (PLUS_EXPR
, ptr_type_node
, t
, build_int_2 (offset
, 0));
5525 t
= build (MODIFY_EXPR
, TREE_TYPE (base_field
), base_field
, t
);
5526 TREE_SIDE_EFFECTS (t
) = 1;
5527 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
5529 t
= build_int_2 (NUM_ARGS
* UNITS_PER_WORD
, 0);
5530 t
= build (MODIFY_EXPR
, TREE_TYPE (offset_field
), offset_field
, t
);
5531 TREE_SIDE_EFFECTS (t
) = 1;
5532 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
5537 alpha_va_arg (valist
, type
)
5540 HOST_WIDE_INT tsize
;
5543 tree offset_field
, base_field
, addr_tree
, addend
;
5544 tree wide_type
, wide_ofs
;
5547 if (TARGET_ABI_OPEN_VMS
|| TARGET_ABI_UNICOSMK
)
5548 return std_expand_builtin_va_arg (valist
, type
);
5550 tsize
= ((TREE_INT_CST_LOW (TYPE_SIZE (type
)) / BITS_PER_UNIT
+ 7) / 8) * 8;
5552 base_field
= TYPE_FIELDS (TREE_TYPE (valist
));
5553 offset_field
= TREE_CHAIN (base_field
);
5555 base_field
= build (COMPONENT_REF
, TREE_TYPE (base_field
),
5556 valist
, base_field
);
5557 offset_field
= build (COMPONENT_REF
, TREE_TYPE (offset_field
),
5558 valist
, offset_field
);
5560 wide_type
= make_signed_type (64);
5561 wide_ofs
= save_expr (build1 (CONVERT_EXPR
, wide_type
, offset_field
));
5565 if (TYPE_MODE (type
) == TFmode
|| TYPE_MODE (type
) == TCmode
)
5568 tsize
= UNITS_PER_WORD
;
5570 else if (FLOAT_TYPE_P (type
))
5572 tree fpaddend
, cond
;
5574 fpaddend
= fold (build (PLUS_EXPR
, TREE_TYPE (addend
),
5575 addend
, build_int_2 (-6*8, 0)));
5577 cond
= fold (build (LT_EXPR
, integer_type_node
,
5578 wide_ofs
, build_int_2 (6*8, 0)));
5580 addend
= fold (build (COND_EXPR
, TREE_TYPE (addend
), cond
,
5584 addr_tree
= build (PLUS_EXPR
, TREE_TYPE (base_field
),
5585 base_field
, addend
);
5587 addr
= expand_expr (addr_tree
, NULL_RTX
, Pmode
, EXPAND_NORMAL
);
5588 addr
= copy_to_reg (addr
);
5590 t
= build (MODIFY_EXPR
, TREE_TYPE (offset_field
), offset_field
,
5591 build (PLUS_EXPR
, TREE_TYPE (offset_field
),
5592 offset_field
, build_int_2 (tsize
, 0)));
5593 TREE_SIDE_EFFECTS (t
) = 1;
5594 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
5598 addr
= force_reg (Pmode
, addr
);
5599 addr
= gen_rtx_MEM (Pmode
, addr
);
5605 /* This page contains routines that are used to determine what the function
5606 prologue and epilogue code will do and write them out. */
5608 /* Compute the size of the save area in the stack. */
5610 /* These variables are used for communication between the following functions.
5611 They indicate various things about the current function being compiled
5612 that are used to tell what kind of prologue, epilogue and procedure
5613 descriptior to generate. */
5615 /* Nonzero if we need a stack procedure. */
5616 static int alpha_is_stack_procedure
;
5618 /* Register number (either FP or SP) that is used to unwind the frame. */
5619 static int vms_unwind_regno
;
5621 /* Register number used to save FP. We need not have one for RA since
5622 we don't modify it for register procedures. This is only defined
5623 for register frame procedures. */
5624 static int vms_save_fp_regno
;
5626 /* Register number used to reference objects off our PV. */
5627 static int vms_base_regno
;
5629 /* Compute register masks for saved registers. */
5632 alpha_sa_mask (imaskP
, fmaskP
)
5633 unsigned long *imaskP
;
5634 unsigned long *fmaskP
;
5636 unsigned long imask
= 0;
5637 unsigned long fmask
= 0;
5640 #ifdef ASM_OUTPUT_MI_THUNK
5641 if (!current_function_is_thunk
)
5644 if (TARGET_ABI_OPEN_VMS
&& alpha_is_stack_procedure
)
5645 imask
|= (1L << HARD_FRAME_POINTER_REGNUM
);
5647 /* One for every register we have to save. */
5648 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
5649 if (! fixed_regs
[i
] && ! call_used_regs
[i
]
5650 && regs_ever_live
[i
] && i
!= REG_RA
5651 && (!TARGET_ABI_UNICOSMK
|| i
!= HARD_FRAME_POINTER_REGNUM
))
5656 fmask
|= (1L << (i
- 32));
5659 /* We need to restore these for the handler. */
5660 if (current_function_calls_eh_return
)
5664 unsigned regno
= EH_RETURN_DATA_REGNO (i
);
5665 if (regno
== INVALID_REGNUM
)
5667 imask
|= 1L << regno
;
5671 if (!TARGET_ABI_UNICOSMK
)
5673 /* If any register spilled, then spill the return address also. */
5674 /* ??? This is required by the Digital stack unwind specification
5675 and isn't needed if we're doing Dwarf2 unwinding. */
5676 if (imask
|| fmask
|| alpha_ra_ever_killed ())
5677 imask
|= (1L << REG_RA
);
5691 #ifdef ASM_OUTPUT_MI_THUNK
5692 if (current_function_is_thunk
)
5697 if (TARGET_ABI_UNICOSMK
)
5699 for (i
= 9; i
< 15 && sa_size
== 0; i
++)
5700 if (! fixed_regs
[i
] && ! call_used_regs
[i
]
5701 && regs_ever_live
[i
])
5703 for (i
= 32 + 2; i
< 32 + 10 && sa_size
== 0; i
++)
5704 if (! fixed_regs
[i
] && ! call_used_regs
[i
]
5705 && regs_ever_live
[i
])
5710 /* One for every register we have to save. */
5711 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
5712 if (! fixed_regs
[i
] && ! call_used_regs
[i
]
5713 && regs_ever_live
[i
] && i
!= REG_RA
)
5718 if (TARGET_ABI_UNICOSMK
)
5720 /* We might not need to generate a frame if we don't make any calls
5721 (including calls to __T3E_MISMATCH if this is a vararg function),
5722 don't have any local variables which require stack slots, don't
5723 use alloca and have not determined that we need a frame for other
5726 alpha_is_stack_procedure
= sa_size
!= 0
5727 || alpha_ra_ever_killed ()
5728 || get_frame_size() != 0
5729 || current_function_outgoing_args_size
5730 || current_function_varargs
5731 || current_function_stdarg
5732 || current_function_calls_alloca
5733 || frame_pointer_needed
;
5735 /* Always reserve space for saving callee-saved registers if we
5736 need a frame as required by the calling convention. */
5737 if (alpha_is_stack_procedure
)
5740 else if (TARGET_ABI_OPEN_VMS
)
5742 /* Start by assuming we can use a register procedure if we don't
5743 make any calls (REG_RA not used) or need to save any
5744 registers and a stack procedure if we do. */
5745 alpha_is_stack_procedure
= sa_size
!= 0 || alpha_ra_ever_killed ();
5747 /* Decide whether to refer to objects off our PV via FP or PV.
5748 If we need FP for something else or if we receive a nonlocal
5749 goto (which expects PV to contain the value), we must use PV.
5750 Otherwise, start by assuming we can use FP. */
5751 vms_base_regno
= (frame_pointer_needed
5752 || current_function_has_nonlocal_label
5753 || alpha_is_stack_procedure
5754 || current_function_outgoing_args_size
5755 ? REG_PV
: HARD_FRAME_POINTER_REGNUM
);
5757 /* If we want to copy PV into FP, we need to find some register
5758 in which to save FP. */
5760 vms_save_fp_regno
= -1;
5761 if (vms_base_regno
== HARD_FRAME_POINTER_REGNUM
)
5762 for (i
= 0; i
< 32; i
++)
5763 if (! fixed_regs
[i
] && call_used_regs
[i
] && ! regs_ever_live
[i
])
5764 vms_save_fp_regno
= i
;
5766 if (vms_save_fp_regno
== -1)
5767 vms_base_regno
= REG_PV
, alpha_is_stack_procedure
= 1;
5769 /* Stack unwinding should be done via FP unless we use it for PV. */
5770 vms_unwind_regno
= (vms_base_regno
== REG_PV
5771 ? HARD_FRAME_POINTER_REGNUM
: STACK_POINTER_REGNUM
);
5773 /* If this is a stack procedure, allow space for saving FP and RA. */
5774 if (alpha_is_stack_procedure
)
5779 /* If some registers were saved but not RA, RA must also be saved,
5780 so leave space for it. */
5781 if (!TARGET_ABI_UNICOSMK
&& (sa_size
!= 0 || alpha_ra_ever_killed ()))
5784 /* Our size must be even (multiple of 16 bytes). */
5793 alpha_pv_save_size ()
5796 return alpha_is_stack_procedure
? 8 : 0;
5803 return vms_unwind_regno
== HARD_FRAME_POINTER_REGNUM
;
5806 #if TARGET_ABI_OPEN_VMS
5808 const struct attribute_spec vms_attribute_table
[] =
5810 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
5811 { "overlaid", 0, 0, true, false, false, NULL
},
5812 { NULL
, 0, 0, false, false, false, NULL
}
5818 find_lo_sum (px
, data
)
5820 void *data ATTRIBUTE_UNUSED
;
5822 return GET_CODE (*px
) == LO_SUM
;
5826 alpha_does_function_need_gp ()
5830 /* The GP being variable is an OSF abi thing. */
5831 if (! TARGET_ABI_OSF
)
5834 if (TARGET_PROFILING_NEEDS_GP
&& profile_flag
)
5837 #ifdef ASM_OUTPUT_MI_THUNK
5838 if (current_function_is_thunk
)
5842 /* If we need a GP (we have a LDSYM insn or a CALL_INSN), load it first.
5843 Even if we are a static function, we still need to do this in case
5844 our address is taken and passed to something like qsort. */
5846 push_topmost_sequence ();
5847 insn
= get_insns ();
5848 pop_topmost_sequence ();
5850 for (; insn
; insn
= NEXT_INSN (insn
))
5852 && GET_CODE (PATTERN (insn
)) != USE
5853 && GET_CODE (PATTERN (insn
)) != CLOBBER
)
5855 enum attr_type type
= get_attr_type (insn
);
5856 if (type
== TYPE_LDSYM
|| type
== TYPE_JSR
)
5858 if (TARGET_EXPLICIT_RELOCS
5859 && for_each_rtx (&PATTERN (insn
), find_lo_sum
, NULL
) > 0)
5866 /* Write a version stamp. Don't write anything if we are running as a
5867 cross-compiler. Otherwise, use the versions in /usr/include/stamp.h. */
5874 alpha_write_verstamp (file
)
5875 FILE *file ATTRIBUTE_UNUSED
;
5878 fprintf (file
, "\t.verstamp %d %d\n", MS_STAMP
, LS_STAMP
);
5882 /* Helper function to set RTX_FRAME_RELATED_P on instructions, including
5886 set_frame_related_p ()
5888 rtx seq
= gen_sequence ();
5891 if (GET_CODE (seq
) == SEQUENCE
)
5893 int i
= XVECLEN (seq
, 0);
5895 RTX_FRAME_RELATED_P (XVECEXP (seq
, 0, i
)) = 1;
5896 return emit_insn (seq
);
5900 seq
= emit_insn (seq
);
5901 RTX_FRAME_RELATED_P (seq
) = 1;
5906 #define FRP(exp) (start_sequence (), exp, set_frame_related_p ())
5908 /* Write function prologue. */
5910 /* On vms we have two kinds of functions:
5912 - stack frame (PROC_STACK)
5913 these are 'normal' functions with local vars and which are
5914 calling other functions
5915 - register frame (PROC_REGISTER)
5916 keeps all data in registers, needs no stack
5918 We must pass this to the assembler so it can generate the
5919 proper pdsc (procedure descriptor)
5920 This is done with the '.pdesc' command.
5922 On not-vms, we don't really differentiate between the two, as we can
5923 simply allocate stack without saving registers. */
5926 alpha_expand_prologue ()
5928 /* Registers to save. */
5929 unsigned long imask
= 0;
5930 unsigned long fmask
= 0;
5931 /* Stack space needed for pushing registers clobbered by us. */
5932 HOST_WIDE_INT sa_size
;
5933 /* Complete stack size needed. */
5934 HOST_WIDE_INT frame_size
;
5935 /* Offset from base reg to register save area. */
5936 HOST_WIDE_INT reg_offset
;
5940 sa_size
= alpha_sa_size ();
5942 frame_size
= get_frame_size ();
5943 if (TARGET_ABI_OPEN_VMS
)
5944 frame_size
= ALPHA_ROUND (sa_size
5945 + (alpha_is_stack_procedure
? 8 : 0)
5947 + current_function_pretend_args_size
);
5948 else if (TARGET_ABI_UNICOSMK
)
5949 /* We have to allocate space for the DSIB if we generate a frame. */
5950 frame_size
= ALPHA_ROUND (sa_size
5951 + (alpha_is_stack_procedure
? 48 : 0))
5952 + ALPHA_ROUND (frame_size
5953 + current_function_outgoing_args_size
);
5955 frame_size
= (ALPHA_ROUND (current_function_outgoing_args_size
)
5957 + ALPHA_ROUND (frame_size
5958 + current_function_pretend_args_size
));
5960 if (TARGET_ABI_OPEN_VMS
)
5963 reg_offset
= ALPHA_ROUND (current_function_outgoing_args_size
);
5965 alpha_sa_mask (&imask
, &fmask
);
5967 /* Emit an insn to reload GP, if needed. */
5970 alpha_function_needs_gp
= alpha_does_function_need_gp ();
5971 if (alpha_function_needs_gp
)
5972 emit_insn (gen_prologue_ldgp ());
5975 /* TARGET_PROFILING_NEEDS_GP actually implies that we need to insert
5976 the call to mcount ourselves, rather than having the linker do it
5977 magically in response to -pg. Since _mcount has special linkage,
5978 don't represent the call as a call. */
5979 if (TARGET_PROFILING_NEEDS_GP
&& profile_flag
)
5980 emit_insn (gen_prologue_mcount ());
5982 if (TARGET_ABI_UNICOSMK
)
5983 unicosmk_gen_dsib (&imask
);
5985 /* Adjust the stack by the frame size. If the frame size is > 4096
5986 bytes, we need to be sure we probe somewhere in the first and last
5987 4096 bytes (we can probably get away without the latter test) and
5988 every 8192 bytes in between. If the frame size is > 32768, we
5989 do this in a loop. Otherwise, we generate the explicit probe
5992 Note that we are only allowed to adjust sp once in the prologue. */
5994 if (frame_size
<= 32768)
5996 if (frame_size
> 4096)
6001 emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
6004 while ((probed
+= 8192) < frame_size
);
6006 /* We only have to do this probe if we aren't saving registers. */
6007 if (sa_size
== 0 && probed
+ 4096 < frame_size
)
6008 emit_insn (gen_probe_stack (GEN_INT (-frame_size
)));
6011 if (frame_size
!= 0)
6012 FRP (emit_insn (gen_adddi3 (stack_pointer_rtx
, stack_pointer_rtx
,
6013 GEN_INT (TARGET_ABI_UNICOSMK
6019 /* Here we generate code to set R22 to SP + 4096 and set R23 to the
6020 number of 8192 byte blocks to probe. We then probe each block
6021 in the loop and then set SP to the proper location. If the
6022 amount remaining is > 4096, we have to do one more probe if we
6023 are not saving any registers. */
6025 HOST_WIDE_INT blocks
= (frame_size
+ 4096) / 8192;
6026 HOST_WIDE_INT leftover
= frame_size
+ 4096 - blocks
* 8192;
6027 rtx ptr
= gen_rtx_REG (DImode
, 22);
6028 rtx count
= gen_rtx_REG (DImode
, 23);
6031 emit_move_insn (count
, GEN_INT (blocks
));
6032 emit_insn (gen_adddi3 (ptr
, stack_pointer_rtx
,
6033 GEN_INT (TARGET_ABI_UNICOSMK
? 4096 - 64 : 4096)));
6035 /* Because of the difficulty in emitting a new basic block this
6036 late in the compilation, generate the loop as a single insn. */
6037 emit_insn (gen_prologue_stack_probe_loop (count
, ptr
));
6039 if (leftover
> 4096 && sa_size
== 0)
6041 rtx last
= gen_rtx_MEM (DImode
, plus_constant (ptr
, -leftover
));
6042 MEM_VOLATILE_P (last
) = 1;
6043 emit_move_insn (last
, const0_rtx
);
6046 if (TARGET_ABI_WINDOWS_NT
)
6048 /* For NT stack unwind (done by 'reverse execution'), it's
6049 not OK to take the result of a loop, even though the value
6050 is already in ptr, so we reload it via a single operation
6051 and subtract it to sp.
6053 Yes, that's correct -- we have to reload the whole constant
6054 into a temporary via ldah+lda then subtract from sp. To
6055 ensure we get ldah+lda, we use a special pattern. */
6057 HOST_WIDE_INT lo
, hi
;
6058 lo
= ((frame_size
& 0xffff) ^ 0x8000) - 0x8000;
6059 hi
= frame_size
- lo
;
6061 emit_move_insn (ptr
, GEN_INT (hi
));
6062 emit_insn (gen_nt_lda (ptr
, GEN_INT (lo
)));
6063 seq
= emit_insn (gen_subdi3 (stack_pointer_rtx
, stack_pointer_rtx
,
6068 seq
= emit_insn (gen_adddi3 (stack_pointer_rtx
, ptr
,
6069 GEN_INT (-leftover
)));
6072 /* This alternative is special, because the DWARF code cannot
6073 possibly intuit through the loop above. So we invent this
6074 note it looks at instead. */
6075 RTX_FRAME_RELATED_P (seq
) = 1;
6077 = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR
,
6078 gen_rtx_SET (VOIDmode
, stack_pointer_rtx
,
6079 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
6080 GEN_INT (TARGET_ABI_UNICOSMK
6086 if (!TARGET_ABI_UNICOSMK
)
6088 /* Cope with very large offsets to the register save area. */
6089 sa_reg
= stack_pointer_rtx
;
6090 if (reg_offset
+ sa_size
> 0x8000)
6092 int low
= ((reg_offset
& 0xffff) ^ 0x8000) - 0x8000;
6095 if (low
+ sa_size
<= 0x8000)
6096 bias
= reg_offset
- low
, reg_offset
= low
;
6098 bias
= reg_offset
, reg_offset
= 0;
6100 sa_reg
= gen_rtx_REG (DImode
, 24);
6101 FRP (emit_insn (gen_adddi3 (sa_reg
, stack_pointer_rtx
,
6105 /* Save regs in stack order. Beginning with VMS PV. */
6106 if (TARGET_ABI_OPEN_VMS
&& alpha_is_stack_procedure
)
6108 mem
= gen_rtx_MEM (DImode
, stack_pointer_rtx
);
6109 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6110 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, REG_PV
)));
6113 /* Save register RA next. */
6114 if (imask
& (1L << REG_RA
))
6116 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, reg_offset
));
6117 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6118 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, REG_RA
)));
6119 imask
&= ~(1L << REG_RA
);
6123 /* Now save any other registers required to be saved. */
6124 for (i
= 0; i
< 32; i
++)
6125 if (imask
& (1L << i
))
6127 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, reg_offset
));
6128 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6129 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, i
)));
6133 for (i
= 0; i
< 32; i
++)
6134 if (fmask
& (1L << i
))
6136 mem
= gen_rtx_MEM (DFmode
, plus_constant (sa_reg
, reg_offset
));
6137 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6138 FRP (emit_move_insn (mem
, gen_rtx_REG (DFmode
, i
+32)));
6142 else if (TARGET_ABI_UNICOSMK
&& alpha_is_stack_procedure
)
6144 /* The standard frame on the T3E includes space for saving registers.
6145 We just have to use it. We don't have to save the return address and
6146 the old frame pointer here - they are saved in the DSIB. */
6149 for (i
= 9; i
< 15; i
++)
6150 if (imask
& (1L << i
))
6152 mem
= gen_rtx_MEM (DImode
, plus_constant(hard_frame_pointer_rtx
,
6154 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6155 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, i
)));
6158 for (i
= 2; i
< 10; i
++)
6159 if (fmask
& (1L << i
))
6161 mem
= gen_rtx_MEM (DFmode
, plus_constant (hard_frame_pointer_rtx
,
6163 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6164 FRP (emit_move_insn (mem
, gen_rtx_REG (DFmode
, i
+32)));
6169 if (TARGET_ABI_OPEN_VMS
)
6171 if (!alpha_is_stack_procedure
)
6172 /* Register frame procedures save the fp. */
6173 /* ??? Ought to have a dwarf2 save for this. */
6174 emit_move_insn (gen_rtx_REG (DImode
, vms_save_fp_regno
),
6175 hard_frame_pointer_rtx
);
6177 if (vms_base_regno
!= REG_PV
)
6178 emit_insn (gen_force_movdi (gen_rtx_REG (DImode
, vms_base_regno
),
6179 gen_rtx_REG (DImode
, REG_PV
)));
6181 if (vms_unwind_regno
== HARD_FRAME_POINTER_REGNUM
)
6182 FRP (emit_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
));
6184 /* If we have to allocate space for outgoing args, do it now. */
6185 if (current_function_outgoing_args_size
!= 0)
6188 plus_constant (hard_frame_pointer_rtx
,
6190 (current_function_outgoing_args_size
)))));
6192 else if (!TARGET_ABI_UNICOSMK
)
6194 /* If we need a frame pointer, set it from the stack pointer. */
6195 if (frame_pointer_needed
)
6197 if (TARGET_CAN_FAULT_IN_PROLOGUE
)
6198 FRP (emit_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
));
6200 /* This must always be the last instruction in the
6201 prologue, thus we emit a special move + clobber. */
6202 FRP (emit_insn (gen_init_fp (hard_frame_pointer_rtx
,
6203 stack_pointer_rtx
, sa_reg
)));
6207 /* The ABIs for VMS and OSF/1 say that while we can schedule insns into
6208 the prologue, for exception handling reasons, we cannot do this for
6209 any insn that might fault. We could prevent this for mems with a
6210 (clobber:BLK (scratch)), but this doesn't work for fp insns. So we
6211 have to prevent all such scheduling with a blockage.
6213 Linux, on the other hand, never bothered to implement OSF/1's
6214 exception handling, and so doesn't care about such things. Anyone
6215 planning to use dwarf2 frame-unwind info can also omit the blockage. */
6217 if (! TARGET_CAN_FAULT_IN_PROLOGUE
)
6218 emit_insn (gen_blockage ());
6221 /* Output the textual info surrounding the prologue. */
6224 alpha_start_function (file
, fnname
, decl
)
6227 tree decl ATTRIBUTE_UNUSED
;
6229 unsigned long imask
= 0;
6230 unsigned long fmask
= 0;
6231 /* Stack space needed for pushing registers clobbered by us. */
6232 HOST_WIDE_INT sa_size
;
6233 /* Complete stack size needed. */
6234 HOST_WIDE_INT frame_size
;
6235 /* Offset from base reg to register save area. */
6236 HOST_WIDE_INT reg_offset
;
6237 char *entry_label
= (char *) alloca (strlen (fnname
) + 6);
6240 /* Don't emit an extern directive for functions defined in the same file. */
6241 if (TARGET_ABI_UNICOSMK
)
6244 name_tree
= get_identifier (fnname
);
6245 TREE_ASM_WRITTEN (name_tree
) = 1;
6248 alpha_fnname
= fnname
;
6249 sa_size
= alpha_sa_size ();
6251 frame_size
= get_frame_size ();
6252 if (TARGET_ABI_OPEN_VMS
)
6253 frame_size
= ALPHA_ROUND (sa_size
6254 + (alpha_is_stack_procedure
? 8 : 0)
6256 + current_function_pretend_args_size
);
6257 else if (TARGET_ABI_UNICOSMK
)
6258 frame_size
= ALPHA_ROUND (sa_size
6259 + (alpha_is_stack_procedure
? 48 : 0))
6260 + ALPHA_ROUND (frame_size
6261 + current_function_outgoing_args_size
);
6263 frame_size
= (ALPHA_ROUND (current_function_outgoing_args_size
)
6265 + ALPHA_ROUND (frame_size
6266 + current_function_pretend_args_size
));
6268 if (TARGET_ABI_OPEN_VMS
)
6271 reg_offset
= ALPHA_ROUND (current_function_outgoing_args_size
);
6273 alpha_sa_mask (&imask
, &fmask
);
6275 /* Ecoff can handle multiple .file directives, so put out file and lineno.
6276 We have to do that before the .ent directive as we cannot switch
6277 files within procedures with native ecoff because line numbers are
6278 linked to procedure descriptors.
6279 Outputting the lineno helps debugging of one line functions as they
6280 would otherwise get no line number at all. Please note that we would
6281 like to put out last_linenum from final.c, but it is not accessible. */
6283 if (write_symbols
== SDB_DEBUG
)
6285 #ifdef ASM_OUTPUT_SOURCE_FILENAME
6286 ASM_OUTPUT_SOURCE_FILENAME (file
,
6287 DECL_SOURCE_FILE (current_function_decl
));
6289 #ifdef ASM_OUTPUT_SOURCE_LINE
6290 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
6291 ASM_OUTPUT_SOURCE_LINE (file
,
6292 DECL_SOURCE_LINE (current_function_decl
));
6296 /* Issue function start and label. */
6297 if (TARGET_ABI_OPEN_VMS
6298 || (!TARGET_ABI_UNICOSMK
&& !flag_inhibit_size_directive
))
6300 fputs ("\t.ent ", file
);
6301 assemble_name (file
, fnname
);
6304 /* If the function needs GP, we'll write the "..ng" label there.
6305 Otherwise, do it here. */
6306 if (TARGET_ABI_OSF
&& ! alpha_function_needs_gp
)
6309 assemble_name (file
, fnname
);
6310 fputs ("..ng:\n", file
);
6314 strcpy (entry_label
, fnname
);
6315 if (TARGET_ABI_OPEN_VMS
)
6316 strcat (entry_label
, "..en");
6318 /* For public functions, the label must be globalized by appending an
6319 additional colon. */
6320 if (TARGET_ABI_UNICOSMK
&& TREE_PUBLIC (decl
))
6321 strcat (entry_label
, ":");
6323 ASM_OUTPUT_LABEL (file
, entry_label
);
6324 inside_function
= TRUE
;
6326 if (TARGET_ABI_OPEN_VMS
)
6327 fprintf (file
, "\t.base $%d\n", vms_base_regno
);
6329 if (!TARGET_ABI_OPEN_VMS
&& !TARGET_ABI_UNICOSMK
&& TARGET_IEEE_CONFORMANT
6330 && !flag_inhibit_size_directive
)
6332 /* Set flags in procedure descriptor to request IEEE-conformant
6333 math-library routines. The value we set it to is PDSC_EXC_IEEE
6334 (/usr/include/pdsc.h). */
6335 fputs ("\t.eflag 48\n", file
);
6338 /* Set up offsets to alpha virtual arg/local debugging pointer. */
6339 alpha_auto_offset
= -frame_size
+ current_function_pretend_args_size
;
6340 alpha_arg_offset
= -frame_size
+ 48;
6342 /* Describe our frame. If the frame size is larger than an integer,
6343 print it as zero to avoid an assembler error. We won't be
6344 properly describing such a frame, but that's the best we can do. */
6345 if (TARGET_ABI_UNICOSMK
)
6347 else if (TARGET_ABI_OPEN_VMS
)
6349 fprintf (file
, "\t.frame $%d,", vms_unwind_regno
);
6350 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
6351 frame_size
>= ((HOST_WIDE_INT
) 1 << 31) ? 0 : frame_size
);
6352 fputs (",$26,", file
);
6353 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, reg_offset
);
6356 else if (!flag_inhibit_size_directive
)
6358 fprintf (file
, "\t.frame $%d,",
6359 (frame_pointer_needed
6360 ? HARD_FRAME_POINTER_REGNUM
: STACK_POINTER_REGNUM
));
6361 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
6362 frame_size
>= (1l << 31) ? 0 : frame_size
);
6363 fprintf (file
, ",$26,%d\n", current_function_pretend_args_size
);
6366 /* Describe which registers were spilled. */
6367 if (TARGET_ABI_UNICOSMK
)
6369 else if (TARGET_ABI_OPEN_VMS
)
6372 /* ??? Does VMS care if mask contains ra? The old code didn't
6373 set it, so I don't here. */
6374 fprintf (file
, "\t.mask 0x%lx,0\n", imask
& ~(1L << REG_RA
));
6376 fprintf (file
, "\t.fmask 0x%lx,0\n", fmask
);
6377 if (!alpha_is_stack_procedure
)
6378 fprintf (file
, "\t.fp_save $%d\n", vms_save_fp_regno
);
6380 else if (!flag_inhibit_size_directive
)
6384 fprintf (file
, "\t.mask 0x%lx,", imask
);
6385 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
6386 frame_size
>= (1l << 31) ? 0 : reg_offset
- frame_size
);
6389 for (i
= 0; i
< 32; ++i
)
6390 if (imask
& (1L << i
))
6396 fprintf (file
, "\t.fmask 0x%lx,", fmask
);
6397 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
6398 frame_size
>= (1l << 31) ? 0 : reg_offset
- frame_size
);
6403 #if TARGET_ABI_OPEN_VMS
6404 /* Ifdef'ed cause readonly_section and link_section are only
6406 readonly_section ();
6407 fprintf (file
, "\t.align 3\n");
6408 assemble_name (file
, fnname
); fputs ("..na:\n", file
);
6409 fputs ("\t.ascii \"", file
);
6410 assemble_name (file
, fnname
);
6411 fputs ("\\0\"\n", file
);
6414 fprintf (file
, "\t.align 3\n");
6415 fputs ("\t.name ", file
);
6416 assemble_name (file
, fnname
);
6417 fputs ("..na\n", file
);
6418 ASM_OUTPUT_LABEL (file
, fnname
);
6419 fprintf (file
, "\t.pdesc ");
6420 assemble_name (file
, fnname
);
6421 fprintf (file
, "..en,%s\n", alpha_is_stack_procedure
? "stack" : "reg");
6422 alpha_need_linkage (fnname
, 1);
6427 /* Emit the .prologue note at the scheduled end of the prologue. */
6430 alpha_output_function_end_prologue (file
)
6433 if (TARGET_ABI_UNICOSMK
)
6435 else if (TARGET_ABI_OPEN_VMS
)
6436 fputs ("\t.prologue\n", file
);
6437 else if (TARGET_ABI_WINDOWS_NT
)
6438 fputs ("\t.prologue 0\n", file
);
6439 else if (!flag_inhibit_size_directive
)
6440 fprintf (file
, "\t.prologue %d\n", alpha_function_needs_gp
);
6443 /* Write function epilogue. */
6445 /* ??? At some point we will want to support full unwind, and so will
6446 need to mark the epilogue as well. At the moment, we just confuse
6449 #define FRP(exp) exp
6452 alpha_expand_epilogue ()
6454 /* Registers to save. */
6455 unsigned long imask
= 0;
6456 unsigned long fmask
= 0;
6457 /* Stack space needed for pushing registers clobbered by us. */
6458 HOST_WIDE_INT sa_size
;
6459 /* Complete stack size needed. */
6460 HOST_WIDE_INT frame_size
;
6461 /* Offset from base reg to register save area. */
6462 HOST_WIDE_INT reg_offset
;
6463 int fp_is_frame_pointer
, fp_offset
;
6464 rtx sa_reg
, sa_reg_exp
= NULL
;
6465 rtx sp_adj1
, sp_adj2
, mem
;
6469 sa_size
= alpha_sa_size ();
6471 frame_size
= get_frame_size ();
6472 if (TARGET_ABI_OPEN_VMS
)
6473 frame_size
= ALPHA_ROUND (sa_size
6474 + (alpha_is_stack_procedure
? 8 : 0)
6476 + current_function_pretend_args_size
);
6477 else if (TARGET_ABI_UNICOSMK
)
6478 frame_size
= ALPHA_ROUND (sa_size
6479 + (alpha_is_stack_procedure
? 48 : 0))
6480 + ALPHA_ROUND (frame_size
6481 + current_function_outgoing_args_size
);
6483 frame_size
= (ALPHA_ROUND (current_function_outgoing_args_size
)
6485 + ALPHA_ROUND (frame_size
6486 + current_function_pretend_args_size
));
6488 if (TARGET_ABI_OPEN_VMS
)
6491 reg_offset
= ALPHA_ROUND (current_function_outgoing_args_size
);
6493 alpha_sa_mask (&imask
, &fmask
);
6495 fp_is_frame_pointer
= ((TARGET_ABI_OPEN_VMS
&& alpha_is_stack_procedure
)
6496 || (!TARGET_ABI_OPEN_VMS
&& frame_pointer_needed
));
6498 sa_reg
= stack_pointer_rtx
;
6500 if (current_function_calls_eh_return
)
6501 eh_ofs
= EH_RETURN_STACKADJ_RTX
;
6505 if (!TARGET_ABI_UNICOSMK
&& sa_size
)
6507 /* If we have a frame pointer, restore SP from it. */
6508 if ((TARGET_ABI_OPEN_VMS
6509 && vms_unwind_regno
== HARD_FRAME_POINTER_REGNUM
)
6510 || (!TARGET_ABI_OPEN_VMS
&& frame_pointer_needed
))
6511 FRP (emit_move_insn (stack_pointer_rtx
, hard_frame_pointer_rtx
));
6513 /* Cope with very large offsets to the register save area. */
6514 if (reg_offset
+ sa_size
> 0x8000)
6516 int low
= ((reg_offset
& 0xffff) ^ 0x8000) - 0x8000;
6519 if (low
+ sa_size
<= 0x8000)
6520 bias
= reg_offset
- low
, reg_offset
= low
;
6522 bias
= reg_offset
, reg_offset
= 0;
6524 sa_reg
= gen_rtx_REG (DImode
, 22);
6525 sa_reg_exp
= plus_constant (stack_pointer_rtx
, bias
);
6527 FRP (emit_move_insn (sa_reg
, sa_reg_exp
));
6530 /* Restore registers in order, excepting a true frame pointer. */
6532 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, reg_offset
));
6534 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6535 FRP (emit_move_insn (gen_rtx_REG (DImode
, REG_RA
), mem
));
6538 imask
&= ~(1L << REG_RA
);
6540 for (i
= 0; i
< 32; ++i
)
6541 if (imask
& (1L << i
))
6543 if (i
== HARD_FRAME_POINTER_REGNUM
&& fp_is_frame_pointer
)
6544 fp_offset
= reg_offset
;
6547 mem
= gen_rtx_MEM (DImode
, plus_constant(sa_reg
, reg_offset
));
6548 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6549 FRP (emit_move_insn (gen_rtx_REG (DImode
, i
), mem
));
6554 for (i
= 0; i
< 32; ++i
)
6555 if (fmask
& (1L << i
))
6557 mem
= gen_rtx_MEM (DFmode
, plus_constant(sa_reg
, reg_offset
));
6558 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6559 FRP (emit_move_insn (gen_rtx_REG (DFmode
, i
+32), mem
));
6563 else if (TARGET_ABI_UNICOSMK
&& alpha_is_stack_procedure
)
6565 /* Restore callee-saved general-purpose registers. */
6569 for (i
= 9; i
< 15; i
++)
6570 if (imask
& (1L << i
))
6572 mem
= gen_rtx_MEM (DImode
, plus_constant(hard_frame_pointer_rtx
,
6574 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6575 FRP (emit_move_insn (gen_rtx_REG (DImode
, i
), mem
));
6579 for (i
= 2; i
< 10; i
++)
6580 if (fmask
& (1L << i
))
6582 mem
= gen_rtx_MEM (DFmode
, plus_constant(hard_frame_pointer_rtx
,
6584 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6585 FRP (emit_move_insn (gen_rtx_REG (DFmode
, i
+32), mem
));
6589 /* Restore the return address from the DSIB. */
6591 mem
= gen_rtx_MEM (DImode
, plus_constant(hard_frame_pointer_rtx
, -8));
6592 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6593 FRP (emit_move_insn (gen_rtx_REG (DImode
, REG_RA
), mem
));
6596 if (frame_size
|| eh_ofs
)
6598 sp_adj1
= stack_pointer_rtx
;
6602 sp_adj1
= gen_rtx_REG (DImode
, 23);
6603 emit_move_insn (sp_adj1
,
6604 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, eh_ofs
));
6607 /* If the stack size is large, begin computation into a temporary
6608 register so as not to interfere with a potential fp restore,
6609 which must be consecutive with an SP restore. */
6610 if (frame_size
< 32768
6611 && ! (TARGET_ABI_UNICOSMK
&& current_function_calls_alloca
))
6612 sp_adj2
= GEN_INT (frame_size
);
6613 else if (TARGET_ABI_UNICOSMK
)
6615 sp_adj1
= gen_rtx_REG (DImode
, 23);
6616 FRP (emit_move_insn (sp_adj1
, hard_frame_pointer_rtx
));
6617 sp_adj2
= const0_rtx
;
6619 else if (frame_size
< 0x40007fffL
)
6621 int low
= ((frame_size
& 0xffff) ^ 0x8000) - 0x8000;
6623 sp_adj2
= plus_constant (sp_adj1
, frame_size
- low
);
6624 if (sa_reg_exp
&& rtx_equal_p (sa_reg_exp
, sp_adj2
))
6628 sp_adj1
= gen_rtx_REG (DImode
, 23);
6629 FRP (emit_move_insn (sp_adj1
, sp_adj2
));
6631 sp_adj2
= GEN_INT (low
);
6635 rtx tmp
= gen_rtx_REG (DImode
, 23);
6636 FRP (sp_adj2
= alpha_emit_set_const (tmp
, DImode
, frame_size
, 3));
6639 /* We can't drop new things to memory this late, afaik,
6640 so build it up by pieces. */
6641 FRP (sp_adj2
= alpha_emit_set_long_const (tmp
, frame_size
,
6642 -(frame_size
< 0)));
6648 /* From now on, things must be in order. So emit blockages. */
6650 /* Restore the frame pointer. */
6651 if (TARGET_ABI_UNICOSMK
)
6653 emit_insn (gen_blockage ());
6654 mem
= gen_rtx_MEM (DImode
,
6655 plus_constant (hard_frame_pointer_rtx
, -16));
6656 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6657 FRP (emit_move_insn (hard_frame_pointer_rtx
, mem
));
6659 else if (fp_is_frame_pointer
)
6661 emit_insn (gen_blockage ());
6662 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, fp_offset
));
6663 set_mem_alias_set (mem
, alpha_sr_alias_set
);
6664 FRP (emit_move_insn (hard_frame_pointer_rtx
, mem
));
6666 else if (TARGET_ABI_OPEN_VMS
)
6668 emit_insn (gen_blockage ());
6669 FRP (emit_move_insn (hard_frame_pointer_rtx
,
6670 gen_rtx_REG (DImode
, vms_save_fp_regno
)));
6673 /* Restore the stack pointer. */
6674 emit_insn (gen_blockage ());
6675 if (sp_adj2
== const0_rtx
)
6676 FRP (emit_move_insn (stack_pointer_rtx
, sp_adj1
));
6678 FRP (emit_move_insn (stack_pointer_rtx
,
6679 gen_rtx_PLUS (DImode
, sp_adj1
, sp_adj2
)));
6683 if (TARGET_ABI_OPEN_VMS
&& !alpha_is_stack_procedure
)
6685 emit_insn (gen_blockage ());
6686 FRP (emit_move_insn (hard_frame_pointer_rtx
,
6687 gen_rtx_REG (DImode
, vms_save_fp_regno
)));
6689 else if (TARGET_ABI_UNICOSMK
&& !alpha_is_stack_procedure
)
6691 /* Decrement the frame pointer if the function does not have a
6694 emit_insn (gen_blockage ());
6695 FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx
,
6696 hard_frame_pointer_rtx
, GEN_INT (-1))));
6701 /* Output the rest of the textual info surrounding the epilogue. */
6704 alpha_end_function (file
, fnname
, decl
)
6707 tree decl ATTRIBUTE_UNUSED
;
6709 /* End the function. */
6710 if (!TARGET_ABI_UNICOSMK
&& !flag_inhibit_size_directive
)
6712 fputs ("\t.end ", file
);
6713 assemble_name (file
, fnname
);
6716 inside_function
= FALSE
;
6718 /* Show that we know this function if it is called again.
6720 Don't do this for global functions in object files destined for a
6721 shared library because the function may be overridden by the application
6722 or other libraries. Similarly, don't do this for weak functions.
6724 Don't do this for functions not defined in the .text section, as
6725 otherwise it's not unlikely that the destination is out of range
6726 for a direct branch. */
6728 if (!DECL_WEAK (current_function_decl
)
6729 && (!flag_pic
|| !TREE_PUBLIC (current_function_decl
))
6730 && decl_in_text_section (current_function_decl
))
6731 SYMBOL_REF_FLAG (XEXP (DECL_RTL (current_function_decl
), 0)) = 1;
6733 /* Output jump tables and the static subroutine information block. */
6734 if (TARGET_ABI_UNICOSMK
)
6736 unicosmk_output_ssib (file
, fnname
);
6737 unicosmk_output_deferred_case_vectors (file
);
6741 /* Debugging support. */
6745 /* Count the number of sdb related labels are generated (to find block
6746 start and end boundaries). */
6748 int sdb_label_count
= 0;
6750 /* Next label # for each statement. */
6752 static int sym_lineno
= 0;
6754 /* Count the number of .file directives, so that .loc is up to date. */
6756 static int num_source_filenames
= 0;
6758 /* Name of the file containing the current function. */
6760 static const char *current_function_file
= "";
6762 /* Offsets to alpha virtual arg/local debugging pointers. */
6764 long alpha_arg_offset
;
6765 long alpha_auto_offset
;
6767 /* Emit a new filename to a stream. */
6770 alpha_output_filename (stream
, name
)
6774 static int first_time
= TRUE
;
6775 char ltext_label_name
[100];
6780 ++num_source_filenames
;
6781 current_function_file
= name
;
6782 fprintf (stream
, "\t.file\t%d ", num_source_filenames
);
6783 output_quoted_string (stream
, name
);
6784 fprintf (stream
, "\n");
6785 if (!TARGET_GAS
&& write_symbols
== DBX_DEBUG
)
6786 fprintf (stream
, "\t#@stabs\n");
6789 else if (write_symbols
== DBX_DEBUG
)
6791 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
6792 fprintf (stream
, "%s", ASM_STABS_OP
);
6793 output_quoted_string (stream
, name
);
6794 fprintf (stream
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
6797 else if (name
!= current_function_file
6798 && strcmp (name
, current_function_file
) != 0)
6800 if (inside_function
&& ! TARGET_GAS
)
6801 fprintf (stream
, "\t#.file\t%d ", num_source_filenames
);
6804 ++num_source_filenames
;
6805 current_function_file
= name
;
6806 fprintf (stream
, "\t.file\t%d ", num_source_filenames
);
6809 output_quoted_string (stream
, name
);
6810 fprintf (stream
, "\n");
6814 /* Emit a linenumber to a stream. */
6817 alpha_output_lineno (stream
, line
)
6821 if (write_symbols
== DBX_DEBUG
)
6823 /* mips-tfile doesn't understand .stabd directives. */
6825 fprintf (stream
, "$LM%d:\n%s%d,0,%d,$LM%d\n",
6826 sym_lineno
, ASM_STABN_OP
, N_SLINE
, line
, sym_lineno
);
6829 fprintf (stream
, "\n\t.loc\t%d %d\n", num_source_filenames
, line
);
6832 /* Structure to show the current status of registers and memory. */
6834 struct shadow_summary
6837 unsigned int i
: 31; /* Mask of int regs */
6838 unsigned int fp
: 31; /* Mask of fp regs */
6839 unsigned int mem
: 1; /* mem == imem | fpmem */
6843 static void summarize_insn
PARAMS ((rtx
, struct shadow_summary
*, int));
6844 static void alpha_handle_trap_shadows
PARAMS ((rtx
));
6846 /* Summary the effects of expression X on the machine. Update SUM, a pointer
6847 to the summary structure. SET is nonzero if the insn is setting the
6848 object, otherwise zero. */
6851 summarize_insn (x
, sum
, set
)
6853 struct shadow_summary
*sum
;
6856 const char *format_ptr
;
6862 switch (GET_CODE (x
))
6864 /* ??? Note that this case would be incorrect if the Alpha had a
6865 ZERO_EXTRACT in SET_DEST. */
6867 summarize_insn (SET_SRC (x
), sum
, 0);
6868 summarize_insn (SET_DEST (x
), sum
, 1);
6872 summarize_insn (XEXP (x
, 0), sum
, 1);
6876 summarize_insn (XEXP (x
, 0), sum
, 0);
6880 for (i
= ASM_OPERANDS_INPUT_LENGTH (x
) - 1; i
>= 0; i
--)
6881 summarize_insn (ASM_OPERANDS_INPUT (x
, i
), sum
, 0);
6885 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
6886 summarize_insn (XVECEXP (x
, 0, i
), sum
, 0);
6890 summarize_insn (SUBREG_REG (x
), sum
, 0);
6895 int regno
= REGNO (x
);
6896 unsigned long mask
= ((unsigned long) 1) << (regno
% 32);
6898 if (regno
== 31 || regno
== 63)
6904 sum
->defd
.i
|= mask
;
6906 sum
->defd
.fp
|= mask
;
6911 sum
->used
.i
|= mask
;
6913 sum
->used
.fp
|= mask
;
6924 /* Find the regs used in memory address computation: */
6925 summarize_insn (XEXP (x
, 0), sum
, 0);
6928 case CONST_INT
: case CONST_DOUBLE
:
6929 case SYMBOL_REF
: case LABEL_REF
: case CONST
:
6930 case SCRATCH
: case ASM_INPUT
:
6933 /* Handle common unary and binary ops for efficiency. */
6934 case COMPARE
: case PLUS
: case MINUS
: case MULT
: case DIV
:
6935 case MOD
: case UDIV
: case UMOD
: case AND
: case IOR
:
6936 case XOR
: case ASHIFT
: case ROTATE
: case ASHIFTRT
: case LSHIFTRT
:
6937 case ROTATERT
: case SMIN
: case SMAX
: case UMIN
: case UMAX
:
6938 case NE
: case EQ
: case GE
: case GT
: case LE
:
6939 case LT
: case GEU
: case GTU
: case LEU
: case LTU
:
6940 summarize_insn (XEXP (x
, 0), sum
, 0);
6941 summarize_insn (XEXP (x
, 1), sum
, 0);
6944 case NEG
: case NOT
: case SIGN_EXTEND
: case ZERO_EXTEND
:
6945 case TRUNCATE
: case FLOAT_EXTEND
: case FLOAT_TRUNCATE
: case FLOAT
:
6946 case FIX
: case UNSIGNED_FLOAT
: case UNSIGNED_FIX
: case ABS
:
6947 case SQRT
: case FFS
:
6948 summarize_insn (XEXP (x
, 0), sum
, 0);
6952 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
6953 for (i
= GET_RTX_LENGTH (GET_CODE (x
)) - 1; i
>= 0; i
--)
6954 switch (format_ptr
[i
])
6957 summarize_insn (XEXP (x
, i
), sum
, 0);
6961 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
6962 summarize_insn (XVECEXP (x
, i
, j
), sum
, 0);
6974 /* Ensure a sufficient number of `trapb' insns are in the code when
6975 the user requests code with a trap precision of functions or
6978 In naive mode, when the user requests a trap-precision of
6979 "instruction", a trapb is needed after every instruction that may
6980 generate a trap. This ensures that the code is resumption safe but
6983 When optimizations are turned on, we delay issuing a trapb as long
6984 as possible. In this context, a trap shadow is the sequence of
6985 instructions that starts with a (potentially) trap generating
6986 instruction and extends to the next trapb or call_pal instruction
6987 (but GCC never generates call_pal by itself). We can delay (and
6988 therefore sometimes omit) a trapb subject to the following
6991 (a) On entry to the trap shadow, if any Alpha register or memory
6992 location contains a value that is used as an operand value by some
6993 instruction in the trap shadow (live on entry), then no instruction
6994 in the trap shadow may modify the register or memory location.
6996 (b) Within the trap shadow, the computation of the base register
6997 for a memory load or store instruction may not involve using the
6998 result of an instruction that might generate an UNPREDICTABLE
7001 (c) Within the trap shadow, no register may be used more than once
7002 as a destination register. (This is to make life easier for the
7005 (d) The trap shadow may not include any branch instructions. */
7008 alpha_handle_trap_shadows (insns
)
7011 struct shadow_summary shadow
;
7012 int trap_pending
, exception_nesting
;
7016 exception_nesting
= 0;
7019 shadow
.used
.mem
= 0;
7020 shadow
.defd
= shadow
.used
;
7022 for (i
= insns
; i
; i
= NEXT_INSN (i
))
7024 if (GET_CODE (i
) == NOTE
)
7026 switch (NOTE_LINE_NUMBER (i
))
7028 case NOTE_INSN_EH_REGION_BEG
:
7029 exception_nesting
++;
7034 case NOTE_INSN_EH_REGION_END
:
7035 exception_nesting
--;
7040 case NOTE_INSN_EPILOGUE_BEG
:
7041 if (trap_pending
&& alpha_tp
>= ALPHA_TP_FUNC
)
7046 else if (trap_pending
)
7048 if (alpha_tp
== ALPHA_TP_FUNC
)
7050 if (GET_CODE (i
) == JUMP_INSN
7051 && GET_CODE (PATTERN (i
)) == RETURN
)
7054 else if (alpha_tp
== ALPHA_TP_INSN
)
7058 struct shadow_summary sum
;
7063 sum
.defd
= sum
.used
;
7065 switch (GET_CODE (i
))
7068 /* Annoyingly, get_attr_trap will abort on these. */
7069 if (GET_CODE (PATTERN (i
)) == USE
7070 || GET_CODE (PATTERN (i
)) == CLOBBER
)
7073 summarize_insn (PATTERN (i
), &sum
, 0);
7075 if ((sum
.defd
.i
& shadow
.defd
.i
)
7076 || (sum
.defd
.fp
& shadow
.defd
.fp
))
7078 /* (c) would be violated */
7082 /* Combine shadow with summary of current insn: */
7083 shadow
.used
.i
|= sum
.used
.i
;
7084 shadow
.used
.fp
|= sum
.used
.fp
;
7085 shadow
.used
.mem
|= sum
.used
.mem
;
7086 shadow
.defd
.i
|= sum
.defd
.i
;
7087 shadow
.defd
.fp
|= sum
.defd
.fp
;
7088 shadow
.defd
.mem
|= sum
.defd
.mem
;
7090 if ((sum
.defd
.i
& shadow
.used
.i
)
7091 || (sum
.defd
.fp
& shadow
.used
.fp
)
7092 || (sum
.defd
.mem
& shadow
.used
.mem
))
7094 /* (a) would be violated (also takes care of (b)) */
7095 if (get_attr_trap (i
) == TRAP_YES
7096 && ((sum
.defd
.i
& sum
.used
.i
)
7097 || (sum
.defd
.fp
& sum
.used
.fp
)))
7116 n
= emit_insn_before (gen_trapb (), i
);
7117 PUT_MODE (n
, TImode
);
7118 PUT_MODE (i
, TImode
);
7122 shadow
.used
.mem
= 0;
7123 shadow
.defd
= shadow
.used
;
7128 if ((exception_nesting
> 0 || alpha_tp
>= ALPHA_TP_FUNC
)
7129 && GET_CODE (i
) == INSN
7130 && GET_CODE (PATTERN (i
)) != USE
7131 && GET_CODE (PATTERN (i
)) != CLOBBER
7132 && get_attr_trap (i
) == TRAP_YES
)
7134 if (optimize
&& !trap_pending
)
7135 summarize_insn (PATTERN (i
), &shadow
, 0);
7141 /* Alpha can only issue instruction groups simultaneously if they are
7142 suitibly aligned. This is very processor-specific. */
7144 enum alphaev4_pipe
{
7151 enum alphaev5_pipe
{
7162 static enum alphaev4_pipe alphaev4_insn_pipe
PARAMS ((rtx
));
7163 static enum alphaev5_pipe alphaev5_insn_pipe
PARAMS ((rtx
));
7164 static rtx alphaev4_next_group
PARAMS ((rtx
, int *, int *));
7165 static rtx alphaev5_next_group
PARAMS ((rtx
, int *, int *));
7166 static rtx alphaev4_next_nop
PARAMS ((int *));
7167 static rtx alphaev5_next_nop
PARAMS ((int *));
7169 static void alpha_align_insns
7170 PARAMS ((rtx
, unsigned int, rtx (*)(rtx
, int *, int *), rtx (*)(int *)));
7172 static enum alphaev4_pipe
7173 alphaev4_insn_pipe (insn
)
7176 if (recog_memoized (insn
) < 0)
7178 if (get_attr_length (insn
) != 4)
7181 switch (get_attr_type (insn
))
7214 static enum alphaev5_pipe
7215 alphaev5_insn_pipe (insn
)
7218 if (recog_memoized (insn
) < 0)
7220 if (get_attr_length (insn
) != 4)
7223 switch (get_attr_type (insn
))
7263 /* IN_USE is a mask of the slots currently filled within the insn group.
7264 The mask bits come from alphaev4_pipe above. If EV4_IBX is set, then
7265 the insn in EV4_IB0 can be swapped by the hardware into EV4_IB1.
7267 LEN is, of course, the length of the group in bytes. */
7270 alphaev4_next_group (insn
, pin_use
, plen
)
7272 int *pin_use
, *plen
;
7279 || GET_CODE (PATTERN (insn
)) == CLOBBER
7280 || GET_CODE (PATTERN (insn
)) == USE
)
7285 enum alphaev4_pipe pipe
;
7287 pipe
= alphaev4_insn_pipe (insn
);
7291 /* Force complex instructions to start new groups. */
7295 /* If this is a completely unrecognized insn, its an asm.
7296 We don't know how long it is, so record length as -1 to
7297 signal a needed realignment. */
7298 if (recog_memoized (insn
) < 0)
7301 len
= get_attr_length (insn
);
7305 if (in_use
& EV4_IB0
)
7307 if (in_use
& EV4_IB1
)
7312 in_use
|= EV4_IB0
| EV4_IBX
;
7316 if (in_use
& EV4_IB0
)
7318 if (!(in_use
& EV4_IBX
) || (in_use
& EV4_IB1
))
7326 if (in_use
& EV4_IB1
)
7336 /* Haifa doesn't do well scheduling branches. */
7337 if (GET_CODE (insn
) == JUMP_INSN
)
7341 insn
= next_nonnote_insn (insn
);
7343 if (!insn
|| ! INSN_P (insn
))
7346 /* Let Haifa tell us where it thinks insn group boundaries are. */
7347 if (GET_MODE (insn
) == TImode
)
7350 if (GET_CODE (insn
) == CLOBBER
|| GET_CODE (insn
) == USE
)
7355 insn
= next_nonnote_insn (insn
);
7363 /* IN_USE is a mask of the slots currently filled within the insn group.
7364 The mask bits come from alphaev5_pipe above. If EV5_E01 is set, then
7365 the insn in EV5_E0 can be swapped by the hardware into EV5_E1.
7367 LEN is, of course, the length of the group in bytes. */
7370 alphaev5_next_group (insn
, pin_use
, plen
)
7372 int *pin_use
, *plen
;
7379 || GET_CODE (PATTERN (insn
)) == CLOBBER
7380 || GET_CODE (PATTERN (insn
)) == USE
)
7385 enum alphaev5_pipe pipe
;
7387 pipe
= alphaev5_insn_pipe (insn
);
7391 /* Force complex instructions to start new groups. */
7395 /* If this is a completely unrecognized insn, its an asm.
7396 We don't know how long it is, so record length as -1 to
7397 signal a needed realignment. */
7398 if (recog_memoized (insn
) < 0)
7401 len
= get_attr_length (insn
);
7404 /* ??? Most of the places below, we would like to abort, as
7405 it would indicate an error either in Haifa, or in the
7406 scheduling description. Unfortunately, Haifa never
7407 schedules the last instruction of the BB, so we don't
7408 have an accurate TI bit to go off. */
7410 if (in_use
& EV5_E0
)
7412 if (in_use
& EV5_E1
)
7417 in_use
|= EV5_E0
| EV5_E01
;
7421 if (in_use
& EV5_E0
)
7423 if (!(in_use
& EV5_E01
) || (in_use
& EV5_E1
))
7431 if (in_use
& EV5_E1
)
7437 if (in_use
& EV5_FA
)
7439 if (in_use
& EV5_FM
)
7444 in_use
|= EV5_FA
| EV5_FAM
;
7448 if (in_use
& EV5_FA
)
7454 if (in_use
& EV5_FM
)
7467 /* Haifa doesn't do well scheduling branches. */
7468 /* ??? If this is predicted not-taken, slotting continues, except
7469 that no more IBR, FBR, or JSR insns may be slotted. */
7470 if (GET_CODE (insn
) == JUMP_INSN
)
7474 insn
= next_nonnote_insn (insn
);
7476 if (!insn
|| ! INSN_P (insn
))
7479 /* Let Haifa tell us where it thinks insn group boundaries are. */
7480 if (GET_MODE (insn
) == TImode
)
7483 if (GET_CODE (insn
) == CLOBBER
|| GET_CODE (insn
) == USE
)
7488 insn
= next_nonnote_insn (insn
);
7497 alphaev4_next_nop (pin_use
)
7500 int in_use
= *pin_use
;
7503 if (!(in_use
& EV4_IB0
))
7508 else if ((in_use
& (EV4_IBX
|EV4_IB1
)) == EV4_IBX
)
7513 else if (TARGET_FP
&& !(in_use
& EV4_IB1
))
7526 alphaev5_next_nop (pin_use
)
7529 int in_use
= *pin_use
;
7532 if (!(in_use
& EV5_E1
))
7537 else if (TARGET_FP
&& !(in_use
& EV5_FA
))
7542 else if (TARGET_FP
&& !(in_use
& EV5_FM
))
7554 /* The instruction group alignment main loop. */
7557 alpha_align_insns (insns
, max_align
, next_group
, next_nop
)
7559 unsigned int max_align
;
7560 rtx (*next_group
) PARAMS ((rtx
, int *, int *));
7561 rtx (*next_nop
) PARAMS ((int *));
7563 /* ALIGN is the known alignment for the insn group. */
7565 /* OFS is the offset of the current insn in the insn group. */
7567 int prev_in_use
, in_use
, len
;
7570 /* Let shorten branches care for assigning alignments to code labels. */
7571 shorten_branches (insns
);
7573 if (align_functions
< 4)
7575 else if (align_functions
< max_align
)
7576 align
= align_functions
;
7580 ofs
= prev_in_use
= 0;
7582 if (GET_CODE (i
) == NOTE
)
7583 i
= next_nonnote_insn (i
);
7587 next
= (*next_group
) (i
, &in_use
, &len
);
7589 /* When we see a label, resync alignment etc. */
7590 if (GET_CODE (i
) == CODE_LABEL
)
7592 unsigned int new_align
= 1 << label_to_alignment (i
);
7594 if (new_align
>= align
)
7596 align
= new_align
< max_align
? new_align
: max_align
;
7600 else if (ofs
& (new_align
-1))
7601 ofs
= (ofs
| (new_align
-1)) + 1;
7606 /* Handle complex instructions special. */
7607 else if (in_use
== 0)
7609 /* Asms will have length < 0. This is a signal that we have
7610 lost alignment knowledge. Assume, however, that the asm
7611 will not mis-align instructions. */
7620 /* If the known alignment is smaller than the recognized insn group,
7621 realign the output. */
7622 else if ((int) align
< len
)
7624 unsigned int new_log_align
= len
> 8 ? 4 : 3;
7627 where
= prev
= prev_nonnote_insn (i
);
7628 if (!where
|| GET_CODE (where
) != CODE_LABEL
)
7631 /* Can't realign between a call and its gp reload. */
7632 if (! (TARGET_EXPLICIT_RELOCS
7633 && prev
&& GET_CODE (prev
) == CALL_INSN
))
7635 emit_insn_before (gen_realign (GEN_INT (new_log_align
)), where
);
7636 align
= 1 << new_log_align
;
7641 /* If the group won't fit in the same INT16 as the previous,
7642 we need to add padding to keep the group together. Rather
7643 than simply leaving the insn filling to the assembler, we
7644 can make use of the knowledge of what sorts of instructions
7645 were issued in the previous group to make sure that all of
7646 the added nops are really free. */
7647 else if (ofs
+ len
> (int) align
)
7649 int nop_count
= (align
- ofs
) / 4;
7652 /* Insert nops before labels, branches, and calls to truely merge
7653 the execution of the nops with the previous instruction group. */
7654 where
= prev_nonnote_insn (i
);
7657 if (GET_CODE (where
) == CODE_LABEL
)
7659 rtx where2
= prev_nonnote_insn (where
);
7660 if (where2
&& GET_CODE (where2
) == JUMP_INSN
)
7663 else if (GET_CODE (where
) == INSN
)
7670 emit_insn_before ((*next_nop
)(&prev_in_use
), where
);
7671 while (--nop_count
);
7675 ofs
= (ofs
+ len
) & (align
- 1);
7676 prev_in_use
= in_use
;
7681 /* Machine dependent reorg pass. */
7687 if (alpha_tp
!= ALPHA_TP_PROG
|| flag_exceptions
)
7688 alpha_handle_trap_shadows (insns
);
7690 /* Due to the number of extra trapb insns, don't bother fixing up
7691 alignment when trap precision is instruction. Moreover, we can
7692 only do our job when sched2 is run. */
7693 if (optimize
&& !optimize_size
7694 && alpha_tp
!= ALPHA_TP_INSN
7695 && flag_schedule_insns_after_reload
)
7697 if (alpha_cpu
== PROCESSOR_EV4
)
7698 alpha_align_insns (insns
, 8, alphaev4_next_group
, alphaev4_next_nop
);
7699 else if (alpha_cpu
== PROCESSOR_EV5
)
7700 alpha_align_insns (insns
, 16, alphaev5_next_group
, alphaev5_next_nop
);
7704 /* Check a floating-point value for validity for a particular machine mode. */
7706 static const char * const float_strings
[] =
7708 /* These are for FLOAT_VAX. */
7709 "1.70141173319264430e+38", /* 2^127 (2^24 - 1) / 2^24 */
7710 "-1.70141173319264430e+38",
7711 "2.93873587705571877e-39", /* 2^-128 */
7712 "-2.93873587705571877e-39",
7713 /* These are for the default broken IEEE mode, which traps
7714 on infinity or denormal numbers. */
7715 "3.402823466385288598117e+38", /* 2^128 (1 - 2^-24) */
7716 "-3.402823466385288598117e+38",
7717 "1.1754943508222875079687e-38", /* 2^-126 */
7718 "-1.1754943508222875079687e-38",
7721 static REAL_VALUE_TYPE float_values
[8];
7722 static int inited_float_values
= 0;
7725 check_float_value (mode
, d
, overflow
)
7726 enum machine_mode mode
;
7728 int overflow ATTRIBUTE_UNUSED
;
7731 if (TARGET_IEEE
|| TARGET_IEEE_CONFORMANT
|| TARGET_IEEE_WITH_INEXACT
)
7734 if (inited_float_values
== 0)
7737 for (i
= 0; i
< 8; i
++)
7738 float_values
[i
] = REAL_VALUE_ATOF (float_strings
[i
], DFmode
);
7740 inited_float_values
= 1;
7746 REAL_VALUE_TYPE
*fvptr
;
7748 if (TARGET_FLOAT_VAX
)
7749 fvptr
= &float_values
[0];
7751 fvptr
= &float_values
[4];
7753 memcpy (&r
, d
, sizeof (REAL_VALUE_TYPE
));
7754 if (REAL_VALUES_LESS (fvptr
[0], r
))
7756 memcpy (d
, &fvptr
[0], sizeof (REAL_VALUE_TYPE
));
7759 else if (REAL_VALUES_LESS (r
, fvptr
[1]))
7761 memcpy (d
, &fvptr
[1], sizeof (REAL_VALUE_TYPE
));
7764 else if (REAL_VALUES_LESS (dconst0
, r
)
7765 && REAL_VALUES_LESS (r
, fvptr
[2]))
7767 memcpy (d
, &dconst0
, sizeof (REAL_VALUE_TYPE
));
7770 else if (REAL_VALUES_LESS (r
, dconst0
)
7771 && REAL_VALUES_LESS (fvptr
[3], r
))
7773 memcpy (d
, &dconst0
, sizeof (REAL_VALUE_TYPE
));
7781 #if TARGET_ABI_OPEN_VMS
7783 /* Return the VMS argument type corresponding to MODE. */
7786 alpha_arg_type (mode
)
7787 enum machine_mode mode
;
7792 return TARGET_FLOAT_VAX
? FF
: FS
;
7794 return TARGET_FLOAT_VAX
? FD
: FT
;
7800 /* Return an rtx for an integer representing the VMS Argument Information
7804 alpha_arg_info_reg_val (cum
)
7805 CUMULATIVE_ARGS cum
;
7807 unsigned HOST_WIDE_INT regval
= cum
.num_args
;
7810 for (i
= 0; i
< 6; i
++)
7811 regval
|= ((int) cum
.atypes
[i
]) << (i
* 3 + 8);
7813 return GEN_INT (regval
);
7816 #include <splay-tree.h>
7818 /* Structure to collect function names for final output
7821 enum links_kind
{KIND_UNUSED
, KIND_LOCAL
, KIND_EXTERN
};
7826 enum links_kind kind
;
7829 static splay_tree alpha_links
;
7831 static int mark_alpha_links_node
PARAMS ((splay_tree_node
, void *));
7832 static void mark_alpha_links
PARAMS ((void *));
7833 static int alpha_write_one_linkage
PARAMS ((splay_tree_node
, void *));
7835 /* Protect alpha_links from garbage collection. */
7838 mark_alpha_links_node (node
, data
)
7839 splay_tree_node node
;
7840 void *data ATTRIBUTE_UNUSED
;
7842 struct alpha_links
*links
= (struct alpha_links
*) node
->value
;
7843 ggc_mark_rtx (links
->linkage
);
7848 mark_alpha_links (ptr
)
7851 splay_tree tree
= *(splay_tree
*) ptr
;
7852 splay_tree_foreach (tree
, mark_alpha_links_node
, NULL
);
7855 /* Make (or fake) .linkage entry for function call.
7857 IS_LOCAL is 0 if name is used in call, 1 if name is used in definition.
7859 Return an SYMBOL_REF rtx for the linkage. */
7862 alpha_need_linkage (name
, is_local
)
7866 splay_tree_node node
;
7867 struct alpha_links
*al
;
7874 /* Is this name already defined? */
7876 node
= splay_tree_lookup (alpha_links
, (splay_tree_key
) name
);
7879 al
= (struct alpha_links
*) node
->value
;
7882 /* Defined here but external assumed. */
7883 if (al
->kind
== KIND_EXTERN
)
7884 al
->kind
= KIND_LOCAL
;
7888 /* Used here but unused assumed. */
7889 if (al
->kind
== KIND_UNUSED
)
7890 al
->kind
= KIND_LOCAL
;
7897 alpha_links
= splay_tree_new ((splay_tree_compare_fn
) strcmp
,
7898 (splay_tree_delete_key_fn
) free
,
7899 (splay_tree_delete_key_fn
) free
);
7900 ggc_add_root (&alpha_links
, 1, 1, mark_alpha_links
);
7903 al
= (struct alpha_links
*) xmalloc (sizeof (struct alpha_links
));
7904 name
= xstrdup (name
);
7906 /* Assume external if no definition. */
7907 al
->kind
= (is_local
? KIND_UNUSED
: KIND_EXTERN
);
7909 /* Ensure we have an IDENTIFIER so assemble_name can mark it used. */
7910 get_identifier (name
);
7912 /* Construct a SYMBOL_REF for us to call. */
7914 size_t name_len
= strlen (name
);
7915 char *linksym
= alloca (name_len
+ 6);
7917 memcpy (linksym
+ 1, name
, name_len
);
7918 memcpy (linksym
+ 1 + name_len
, "..lk", 5);
7919 al
->linkage
= gen_rtx_SYMBOL_REF (Pmode
,
7920 ggc_alloc_string (linksym
, name_len
+ 5));
7923 splay_tree_insert (alpha_links
, (splay_tree_key
) name
,
7924 (splay_tree_value
) al
);
7930 alpha_write_one_linkage (node
, data
)
7931 splay_tree_node node
;
7934 const char *const name
= (const char *) node
->key
;
7935 struct alpha_links
*links
= (struct alpha_links
*) node
->value
;
7936 FILE *stream
= (FILE *) data
;
7938 if (links
->kind
== KIND_UNUSED
7939 || ! TREE_SYMBOL_REFERENCED (get_identifier (name
)))
7942 fprintf (stream
, "$%s..lk:\n", name
);
7943 if (links
->kind
== KIND_LOCAL
)
7945 /* Local and used, build linkage pair. */
7946 fprintf (stream
, "\t.quad %s..en\n", name
);
7947 fprintf (stream
, "\t.quad %s\n", name
);
7951 /* External and used, request linkage pair. */
7952 fprintf (stream
, "\t.linkage %s\n", name
);
7959 alpha_write_linkage (stream
)
7962 readonly_section ();
7963 fprintf (stream
, "\t.align 3\n");
7964 splay_tree_foreach (alpha_links
, alpha_write_one_linkage
, stream
);
7967 /* Given a decl, a section name, and whether the decl initializer
7968 has relocs, choose attributes for the section. */
7970 #define SECTION_VMS_OVERLAY SECTION_FORGET
7973 vms_section_type_flags (decl
, name
, reloc
)
7978 unsigned int flags
= default_section_type_flags (decl
, name
, reloc
);
7980 if (decl
&& DECL_ATTRIBUTES (decl
)
7981 && lookup_attribute ("overlaid", DECL_ATTRIBUTES (decl
)))
7982 flags
|= SECTION_VMS_OVERLAY
;
7987 /* Switch to an arbitrary section NAME with attributes as specified
7988 by FLAGS. ALIGN specifies any known alignment requirements for
7989 the section; 0 if the default should be used. */
7992 vms_asm_named_section (name
, flags
)
7996 const char *flag_str
= "";
7998 if (flags
& SECTION_VMS_OVERLAY
)
8000 else if (flags
& SECTION_DEBUG
)
8001 flag_str
= ",NOWRT";
8003 fprintf (asm_out_file
, ".section\t%s%s\n", name
, flag_str
);
8006 /* Record an element in the table of global constructors. SYMBOL is
8007 a SYMBOL_REF of the function to be called; PRIORITY is a number
8008 between 0 and MAX_INIT_PRIORITY.
8010 Differs from default_ctors_section_asm_out_constructor in that the
8011 width of the .ctors entry is always 64 bits, rather than the 32 bits
8012 used by a normal pointer. */
8015 vms_asm_out_constructor (symbol
, priority
)
8017 int priority ATTRIBUTE_UNUSED
;
8020 assemble_align (BITS_PER_WORD
);
8021 assemble_integer (symbol
, UNITS_PER_WORD
, BITS_PER_WORD
, 1);
8025 vms_asm_out_destructor (symbol
, priority
)
8027 int priority ATTRIBUTE_UNUSED
;
8030 assemble_align (BITS_PER_WORD
);
8031 assemble_integer (symbol
, UNITS_PER_WORD
, BITS_PER_WORD
, 1);
8036 alpha_need_linkage (name
, is_local
)
8037 const char *name ATTRIBUTE_UNUSED
;
8038 int is_local ATTRIBUTE_UNUSED
;
8043 #endif /* TARGET_ABI_OPEN_VMS */
8045 #if TARGET_ABI_UNICOSMK
8047 static void unicosmk_output_module_name
PARAMS ((FILE *));
8048 static void unicosmk_output_default_externs
PARAMS ((FILE *));
8049 static void unicosmk_output_dex
PARAMS ((FILE *));
8050 static void unicosmk_output_externs
PARAMS ((FILE *));
8051 static void unicosmk_output_addr_vec
PARAMS ((FILE *, rtx
));
8052 static const char *unicosmk_ssib_name
PARAMS ((void));
8053 static int unicosmk_special_name
PARAMS ((const char *));
8055 /* Define the offset between two registers, one to be eliminated, and the
8056 other its replacement, at the start of a routine. */
8059 unicosmk_initial_elimination_offset (from
, to
)
8065 fixed_size
= alpha_sa_size();
8066 if (fixed_size
!= 0)
8069 if (from
== FRAME_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
8071 else if (from
== ARG_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
8073 else if (from
== FRAME_POINTER_REGNUM
&& to
== STACK_POINTER_REGNUM
)
8074 return (ALPHA_ROUND (current_function_outgoing_args_size
)
8075 + ALPHA_ROUND (get_frame_size()));
8076 else if (from
== ARG_POINTER_REGNUM
&& to
== STACK_POINTER_REGNUM
)
8077 return (ALPHA_ROUND (fixed_size
)
8078 + ALPHA_ROUND (get_frame_size()
8079 + current_function_outgoing_args_size
));
8084 /* Output the module name for .ident and .end directives. We have to strip
8085 directories and add make sure that the module name starts with a letter
8089 unicosmk_output_module_name (file
)
8094 /* Strip directories. */
8096 name
= strrchr (main_input_filename
, '/');
8100 name
= main_input_filename
;
8102 /* CAM only accepts module names that start with a letter or '$'. We
8103 prefix the module name with a '$' if necessary. */
8105 if (!ISALPHA (*name
))
8106 fprintf (file
, "$%s", name
);
8111 /* Output text that to appear at the beginning of an assembler file. */
8114 unicosmk_asm_file_start (file
)
8119 fputs ("\t.ident\t", file
);
8120 unicosmk_output_module_name (file
);
8121 fputs ("\n\n", file
);
8123 /* The Unicos/Mk assembler uses different register names. Instead of trying
8124 to support them, we simply use micro definitions. */
8126 /* CAM has different register names: rN for the integer register N and fN
8127 for the floating-point register N. Instead of trying to use these in
8128 alpha.md, we define the symbols $N and $fN to refer to the appropriate
8131 for (i
= 0; i
< 32; ++i
)
8132 fprintf (file
, "$%d <- r%d\n", i
, i
);
8134 for (i
= 0; i
< 32; ++i
)
8135 fprintf (file
, "$f%d <- f%d\n", i
, i
);
8139 /* The .align directive fill unused space with zeroes which does not work
8140 in code sections. We define the macro 'gcc@code@align' which uses nops
8141 instead. Note that it assumes that code sections always have the
8142 biggest possible alignment since . refers to the current offset from
8143 the beginning of the section. */
8145 fputs ("\t.macro gcc@code@align n\n", file
);
8146 fputs ("gcc@n@bytes = 1 << n\n", file
);
8147 fputs ("gcc@here = . % gcc@n@bytes\n", file
);
8148 fputs ("\t.if ne, gcc@here, 0\n", file
);
8149 fputs ("\t.repeat (gcc@n@bytes - gcc@here) / 4\n", file
);
8150 fputs ("\tbis r31,r31,r31\n", file
);
8151 fputs ("\t.endr\n", file
);
8152 fputs ("\t.endif\n", file
);
8153 fputs ("\t.endm gcc@code@align\n\n", file
);
8155 /* Output extern declarations which should always be visible. */
8156 unicosmk_output_default_externs (file
);
8158 /* Open a dummy section. We always need to be inside a section for the
8159 section-switching code to work correctly.
8160 ??? This should be a module id or something like that. I still have to
8161 figure out what the rules for those are. */
8162 fputs ("\n\t.psect\t$SG00000,data\n", file
);
8165 /* Output text to appear at the end of an assembler file. This includes all
8166 pending extern declarations and DEX expressions. */
8169 unicosmk_asm_file_end (file
)
8172 fputs ("\t.endp\n\n", file
);
8174 /* Output all pending externs. */
8176 unicosmk_output_externs (file
);
8178 /* Output dex definitions used for functions whose names conflict with
8181 unicosmk_output_dex (file
);
8183 fputs ("\t.end\t", file
);
8184 unicosmk_output_module_name (file
);
8188 /* Output the definition of a common variable. */
8191 unicosmk_output_common (file
, name
, size
, align
)
8198 printf ("T3E__: common %s\n", name
);
8201 fputs("\t.endp\n\n\t.psect ", file
);
8202 assemble_name(file
, name
);
8203 fprintf(file
, ",%d,common\n", floor_log2 (align
/ BITS_PER_UNIT
));
8204 fprintf(file
, "\t.byte\t0:%d\n", size
);
8206 /* Mark the symbol as defined in this module. */
8207 name_tree
= get_identifier (name
);
8208 TREE_ASM_WRITTEN (name_tree
) = 1;
8211 #define SECTION_PUBLIC SECTION_MACH_DEP
8212 #define SECTION_MAIN (SECTION_PUBLIC << 1)
8213 static int current_section_align
;
8216 unicosmk_section_type_flags (decl
, name
, reloc
)
8219 int reloc ATTRIBUTE_UNUSED
;
8221 unsigned int flags
= default_section_type_flags (decl
, name
, reloc
);
8226 if (TREE_CODE (decl
) == FUNCTION_DECL
)
8228 current_section_align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
8229 if (align_functions_log
> current_section_align
)
8230 current_section_align
= align_functions_log
;
8232 if (! strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), "main"))
8233 flags
|= SECTION_MAIN
;
8236 current_section_align
= floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
);
8238 if (TREE_PUBLIC (decl
))
8239 flags
|= SECTION_PUBLIC
;
8244 /* Generate a section name for decl and associate it with the
8248 unicosmk_unique_section (decl
, reloc
)
8250 int reloc ATTRIBUTE_UNUSED
;
8258 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
8259 STRIP_NAME_ENCODING (name
, name
);
8260 len
= strlen (name
);
8262 if (TREE_CODE (decl
) == FUNCTION_DECL
)
8266 /* It is essential that we prefix the section name here because
8267 otherwise the section names generated for constructors and
8268 destructors confuse collect2. */
8270 string
= alloca (len
+ 6);
8271 sprintf (string
, "code@%s", name
);
8272 DECL_SECTION_NAME (decl
) = build_string (len
+ 5, string
);
8274 else if (TREE_PUBLIC (decl
))
8275 DECL_SECTION_NAME (decl
) = build_string (len
, name
);
8280 string
= alloca (len
+ 6);
8281 sprintf (string
, "data@%s", name
);
8282 DECL_SECTION_NAME (decl
) = build_string (len
+ 5, string
);
8286 /* Switch to an arbitrary section NAME with attributes as specified
8287 by FLAGS. ALIGN specifies any known alignment requirements for
8288 the section; 0 if the default should be used. */
8291 unicosmk_asm_named_section (name
, flags
)
8297 /* Close the previous section. */
8299 fputs ("\t.endp\n\n", asm_out_file
);
8301 /* Find out what kind of section we are opening. */
8303 if (flags
& SECTION_MAIN
)
8304 fputs ("\t.start\tmain\n", asm_out_file
);
8306 if (flags
& SECTION_CODE
)
8308 else if (flags
& SECTION_PUBLIC
)
8313 if (current_section_align
!= 0)
8314 fprintf (asm_out_file
, "\t.psect\t%s,%d,%s\n", name
,
8315 current_section_align
, kind
);
8317 fprintf (asm_out_file
, "\t.psect\t%s,%s\n", name
, kind
);
8321 unicosmk_insert_attributes (decl
, attr_ptr
)
8323 tree
*attr_ptr ATTRIBUTE_UNUSED
;
8326 && (TREE_PUBLIC (decl
) || TREE_CODE (decl
) == FUNCTION_DECL
))
8327 UNIQUE_SECTION (decl
, 0);
8330 /* Output an alignment directive. We have to use the macro 'gcc@code@align'
8331 in code sections because .align fill unused space with zeroes. */
8334 unicosmk_output_align (file
, align
)
8338 if (inside_function
)
8339 fprintf (file
, "\tgcc@code@align\t%d\n", align
);
8341 fprintf (file
, "\t.align\t%d\n", align
);
8344 /* Add a case vector to the current function's list of deferred case
8345 vectors. Case vectors have to be put into a separate section because CAM
8346 does not allow data definitions in code sections. */
8349 unicosmk_defer_case_vector (lab
, vec
)
8353 struct machine_function
*machine
= cfun
->machine
;
8355 vec
= gen_rtx_EXPR_LIST (VOIDmode
, lab
, vec
);
8356 machine
->addr_list
= gen_rtx_EXPR_LIST (VOIDmode
, vec
,
8357 machine
->addr_list
);
8360 /* Output a case vector. */
8363 unicosmk_output_addr_vec (file
, vec
)
8367 rtx lab
= XEXP (vec
, 0);
8368 rtx body
= XEXP (vec
, 1);
8369 int vlen
= XVECLEN (body
, 0);
8372 ASM_OUTPUT_INTERNAL_LABEL (file
, "L", CODE_LABEL_NUMBER (lab
));
8374 for (idx
= 0; idx
< vlen
; idx
++)
8376 ASM_OUTPUT_ADDR_VEC_ELT
8377 (file
, CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 0, idx
), 0)));
8381 /* Output current function's deferred case vectors. */
8384 unicosmk_output_deferred_case_vectors (file
)
8387 struct machine_function
*machine
= cfun
->machine
;
8390 if (machine
->addr_list
== NULL_RTX
)
8394 for (t
= machine
->addr_list
; t
; t
= XEXP (t
, 1))
8395 unicosmk_output_addr_vec (file
, XEXP (t
, 0));
8398 /* Set up the dynamic subprogram information block (DSIB) and update the
8399 frame pointer register ($15) for subroutines which have a frame. If the
8400 subroutine doesn't have a frame, simply increment $15. */
8403 unicosmk_gen_dsib (imaskP
)
8404 unsigned long * imaskP
;
8406 if (alpha_is_stack_procedure
)
8408 const char *ssib_name
;
8411 /* Allocate 64 bytes for the DSIB. */
8413 FRP (emit_insn (gen_adddi3 (stack_pointer_rtx
, stack_pointer_rtx
,
8415 emit_insn (gen_blockage ());
8417 /* Save the return address. */
8419 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 56));
8420 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8421 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, REG_RA
)));
8422 (*imaskP
) &= ~(1L << REG_RA
);
8424 /* Save the old frame pointer. */
8426 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 48));
8427 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8428 FRP (emit_move_insn (mem
, hard_frame_pointer_rtx
));
8429 (*imaskP
) &= ~(1L << HARD_FRAME_POINTER_REGNUM
);
8431 emit_insn (gen_blockage ());
8433 /* Store the SSIB pointer. */
8435 ssib_name
= ggc_strdup (unicosmk_ssib_name ());
8436 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 32));
8437 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8439 FRP (emit_move_insn (gen_rtx_REG (DImode
, 5),
8440 gen_rtx_SYMBOL_REF (Pmode
, ssib_name
)));
8441 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, 5)));
8443 /* Save the CIW index. */
8445 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 24));
8446 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8447 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, 25)));
8449 emit_insn (gen_blockage ());
8451 /* Set the new frame pointer. */
8453 FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx
,
8454 stack_pointer_rtx
, GEN_INT (64))));
8459 /* Increment the frame pointer register to indicate that we do not
8462 FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx
,
8463 hard_frame_pointer_rtx
, GEN_INT (1))));
8467 #define SSIB_PREFIX "__SSIB_"
8468 #define SSIB_PREFIX_LEN 7
8470 /* Generate the name of the SSIB section for the current function. */
8473 unicosmk_ssib_name ()
8475 /* This is ok since CAM won't be able to deal with names longer than that
8478 static char name
[256];
8484 x
= DECL_RTL (cfun
->decl
);
8485 if (GET_CODE (x
) != MEM
)
8488 if (GET_CODE (x
) != SYMBOL_REF
)
8490 fnname
= XSTR (x
, 0);
8491 STRIP_NAME_ENCODING (fnname
, fnname
);
8493 len
= strlen (fnname
);
8494 if (len
+ SSIB_PREFIX_LEN
> 255)
8495 len
= 255 - SSIB_PREFIX_LEN
;
8497 strcpy (name
, SSIB_PREFIX
);
8498 strncpy (name
+ SSIB_PREFIX_LEN
, fnname
, len
);
8499 name
[len
+ SSIB_PREFIX_LEN
] = 0;
8504 /* Output the static subroutine information block for the current
8508 unicosmk_output_ssib (file
, fnname
)
8516 struct machine_function
*machine
= cfun
->machine
;
8519 fprintf (file
, "\t.endp\n\n\t.psect\t%s%s,data\n", user_label_prefix
,
8520 unicosmk_ssib_name ());
8522 /* Some required stuff and the function name length. */
8524 len
= strlen (fnname
);
8525 fprintf (file
, "\t.quad\t^X20008%2.2X28\n", len
);
8528 ??? We don't do that yet. */
8530 fputs ("\t.quad\t0\n", file
);
8532 /* Function address. */
8534 fputs ("\t.quad\t", file
);
8535 assemble_name (file
, fnname
);
8538 fputs ("\t.quad\t0\n", file
);
8539 fputs ("\t.quad\t0\n", file
);
8542 ??? We do it the same way Cray CC does it but this could be
8545 for( i
= 0; i
< len
; i
++ )
8546 fprintf (file
, "\t.byte\t%d\n", (int)(fnname
[i
]));
8547 if( (len
% 8) == 0 )
8548 fputs ("\t.quad\t0\n", file
);
8550 fprintf (file
, "\t.bits\t%d : 0\n", (8 - (len
% 8))*8);
8552 /* All call information words used in the function. */
8554 for (x
= machine
->first_ciw
; x
; x
= XEXP (x
, 1))
8557 fprintf (file
, "\t.quad\t");
8558 #if HOST_BITS_PER_WIDE_INT == 32
8559 fprintf (file
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
8560 CONST_DOUBLE_HIGH (ciw
), CONST_DOUBLE_LOW (ciw
));
8562 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
, INTVAL (ciw
));
8564 fprintf (file
, "\n");
8568 /* Add a call information word (CIW) to the list of the current function's
8569 CIWs and return its index.
8571 X is a CONST_INT or CONST_DOUBLE representing the CIW. */
8574 unicosmk_add_call_info_word (x
)
8578 struct machine_function
*machine
= cfun
->machine
;
8580 node
= gen_rtx_EXPR_LIST (VOIDmode
, x
, NULL_RTX
);
8581 if (machine
->first_ciw
== NULL_RTX
)
8582 machine
->first_ciw
= node
;
8584 XEXP (machine
->last_ciw
, 1) = node
;
8586 machine
->last_ciw
= node
;
8587 ++machine
->ciw_count
;
8589 return GEN_INT (machine
->ciw_count
8590 + strlen (current_function_name
)/8 + 5);
8593 static char unicosmk_section_buf
[100];
8596 unicosmk_text_section ()
8598 static int count
= 0;
8599 sprintf (unicosmk_section_buf
, "\t.endp\n\n\t.psect\tgcc@text___%d,code",
8601 return unicosmk_section_buf
;
8605 unicosmk_data_section ()
8607 static int count
= 1;
8608 sprintf (unicosmk_section_buf
, "\t.endp\n\n\t.psect\tgcc@data___%d,data",
8610 return unicosmk_section_buf
;
8613 /* The Cray assembler doesn't accept extern declarations for symbols which
8614 are defined in the same file. We have to keep track of all global
8615 symbols which are referenced and/or defined in a source file and output
8616 extern declarations for those which are referenced but not defined at
8619 /* List of identifiers for which an extern declaration might have to be
8622 struct unicosmk_extern_list
8624 struct unicosmk_extern_list
*next
;
8628 static struct unicosmk_extern_list
*unicosmk_extern_head
= 0;
8630 /* Output extern declarations which are required for every asm file. */
8633 unicosmk_output_default_externs (file
)
8636 static const char *const externs
[] =
8637 { "__T3E_MISMATCH" };
8642 n
= ARRAY_SIZE (externs
);
8644 for (i
= 0; i
< n
; i
++)
8645 fprintf (file
, "\t.extern\t%s\n", externs
[i
]);
8648 /* Output extern declarations for global symbols which are have been
8649 referenced but not defined. */
8652 unicosmk_output_externs (file
)
8655 struct unicosmk_extern_list
*p
;
8656 const char *real_name
;
8660 len
= strlen (user_label_prefix
);
8661 for (p
= unicosmk_extern_head
; p
!= 0; p
= p
->next
)
8663 /* We have to strip the encoding and possibly remove user_label_prefix
8664 from the identifier in order to handle -fleading-underscore and
8665 explicit asm names correctly (cf. gcc.dg/asm-names-1.c). */
8666 STRIP_NAME_ENCODING (real_name
, p
->name
);
8667 if (len
&& p
->name
[0] == '*'
8668 && !memcmp (real_name
, user_label_prefix
, len
))
8671 name_tree
= get_identifier (real_name
);
8672 if (! TREE_ASM_WRITTEN (name_tree
))
8674 TREE_ASM_WRITTEN (name_tree
) = 1;
8675 fputs ("\t.extern\t", file
);
8676 assemble_name (file
, p
->name
);
8682 /* Record an extern. */
8685 unicosmk_add_extern (name
)
8688 struct unicosmk_extern_list
*p
;
8690 p
= (struct unicosmk_extern_list
*)
8691 permalloc (sizeof (struct unicosmk_extern_list
));
8692 p
->next
= unicosmk_extern_head
;
8694 unicosmk_extern_head
= p
;
8697 /* The Cray assembler generates incorrect code if identifiers which
8698 conflict with register names are used as instruction operands. We have
8699 to replace such identifiers with DEX expressions. */
8701 /* Structure to collect identifiers which have been replaced by DEX
8704 struct unicosmk_dex
{
8705 struct unicosmk_dex
*next
;
8709 /* List of identifiers which have been replaced by DEX expressions. The DEX
8710 number is determined by the position in the list. */
8712 static struct unicosmk_dex
*unicosmk_dex_list
= NULL
;
8714 /* The number of elements in the DEX list. */
8716 static int unicosmk_dex_count
= 0;
8718 /* Check if NAME must be replaced by a DEX expression. */
8721 unicosmk_special_name (name
)
8730 if (name
[0] != 'r' && name
[0] != 'f' && name
[0] != 'R' && name
[0] != 'F')
8736 return (name
[2] == '\0' || (ISDIGIT (name
[2]) && name
[3] == '\0'));
8739 return (name
[2] == '\0'
8740 || ((name
[2] == '0' || name
[2] == '1') && name
[3] == '\0'));
8743 return (ISDIGIT (name
[1]) && name
[2] == '\0');
8747 /* Return the DEX number if X must be replaced by a DEX expression and 0
8751 unicosmk_need_dex (x
)
8754 struct unicosmk_dex
*dex
;
8758 if (GET_CODE (x
) != SYMBOL_REF
)
8762 if (! unicosmk_special_name (name
))
8765 i
= unicosmk_dex_count
;
8766 for (dex
= unicosmk_dex_list
; dex
; dex
= dex
->next
)
8768 if (! strcmp (name
, dex
->name
))
8773 dex
= (struct unicosmk_dex
*) permalloc (sizeof (struct unicosmk_dex
));
8775 dex
->next
= unicosmk_dex_list
;
8776 unicosmk_dex_list
= dex
;
8778 ++unicosmk_dex_count
;
8779 return unicosmk_dex_count
;
8782 /* Output the DEX definitions for this file. */
8785 unicosmk_output_dex (file
)
8788 struct unicosmk_dex
*dex
;
8791 if (unicosmk_dex_list
== NULL
)
8794 fprintf (file
, "\t.dexstart\n");
8796 i
= unicosmk_dex_count
;
8797 for (dex
= unicosmk_dex_list
; dex
; dex
= dex
->next
)
8799 fprintf (file
, "\tDEX (%d) = ", i
);
8800 assemble_name (file
, dex
->name
);
8805 fprintf (file
, "\t.dexend\n");
8811 unicosmk_output_deferred_case_vectors (file
)
8812 FILE *file ATTRIBUTE_UNUSED
;
8816 unicosmk_gen_dsib (imaskP
)
8817 unsigned long * imaskP ATTRIBUTE_UNUSED
;
8821 unicosmk_output_ssib (file
, fnname
)
8822 FILE * file ATTRIBUTE_UNUSED
;
8823 const char * fnname ATTRIBUTE_UNUSED
;
8827 unicosmk_add_call_info_word (x
)
8828 rtx x ATTRIBUTE_UNUSED
;
8834 unicosmk_need_dex (x
)
8835 rtx x ATTRIBUTE_UNUSED
;
8840 #endif /* TARGET_ABI_UNICOSMK */