1 /* Subroutines used for code generation on the DEC Alpha.
2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003 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. */
26 #include "coretypes.h"
31 #include "hard-reg-set.h"
33 #include "insn-config.h"
34 #include "conditions.h"
36 #include "insn-attr.h"
47 #include "integrate.h"
50 #include "target-def.h"
52 #include "langhooks.h"
53 #include <splay-tree.h>
55 /* Specify which cpu to schedule for. */
57 enum processor_type alpha_cpu
;
58 static const char * const alpha_cpu_name
[] =
63 /* Specify how accurate floating-point traps need to be. */
65 enum alpha_trap_precision alpha_tp
;
67 /* Specify the floating-point rounding mode. */
69 enum alpha_fp_rounding_mode alpha_fprm
;
71 /* Specify which things cause traps. */
73 enum alpha_fp_trap_mode alpha_fptm
;
75 /* Specify bit size of immediate TLS offsets. */
77 int alpha_tls_size
= 32;
79 /* Strings decoded into the above options. */
81 const char *alpha_cpu_string
; /* -mcpu= */
82 const char *alpha_tune_string
; /* -mtune= */
83 const char *alpha_tp_string
; /* -mtrap-precision=[p|s|i] */
84 const char *alpha_fprm_string
; /* -mfp-rounding-mode=[n|m|c|d] */
85 const char *alpha_fptm_string
; /* -mfp-trap-mode=[n|u|su|sui] */
86 const char *alpha_mlat_string
; /* -mmemory-latency= */
87 const char *alpha_tls_size_string
; /* -mtls-size=[16|32|64] */
89 /* Save information from a "cmpxx" operation until the branch or scc is
92 struct alpha_compare alpha_compare
;
94 /* Nonzero if inside of a function, because the Alpha asm can't
95 handle .files inside of functions. */
97 static int inside_function
= FALSE
;
99 /* The number of cycles of latency we should assume on memory reads. */
101 int alpha_memory_latency
= 3;
103 /* Whether the function needs the GP. */
105 static int alpha_function_needs_gp
;
107 /* The alias set for prologue/epilogue register save/restore. */
109 static GTY(()) int alpha_sr_alias_set
;
111 /* The assembler name of the current function. */
113 static const char *alpha_fnname
;
115 /* The next explicit relocation sequence number. */
116 extern GTY(()) int alpha_next_sequence_number
;
117 int alpha_next_sequence_number
= 1;
119 /* The literal and gpdisp sequence numbers for this insn, as printed
120 by %# and %* respectively. */
121 extern GTY(()) int alpha_this_literal_sequence_number
;
122 extern GTY(()) int alpha_this_gpdisp_sequence_number
;
123 int alpha_this_literal_sequence_number
;
124 int alpha_this_gpdisp_sequence_number
;
126 /* Costs of various operations on the different architectures. */
128 struct alpha_rtx_cost_data
130 unsigned char fp_add
;
131 unsigned char fp_mult
;
132 unsigned char fp_div_sf
;
133 unsigned char fp_div_df
;
134 unsigned char int_mult_si
;
135 unsigned char int_mult_di
;
136 unsigned char int_shift
;
137 unsigned char int_cmov
;
140 static struct alpha_rtx_cost_data
const alpha_rtx_cost_data
[PROCESSOR_MAX
] =
143 COSTS_N_INSNS (6), /* fp_add */
144 COSTS_N_INSNS (6), /* fp_mult */
145 COSTS_N_INSNS (34), /* fp_div_sf */
146 COSTS_N_INSNS (63), /* fp_div_df */
147 COSTS_N_INSNS (23), /* int_mult_si */
148 COSTS_N_INSNS (23), /* int_mult_di */
149 COSTS_N_INSNS (2), /* int_shift */
150 COSTS_N_INSNS (2), /* int_cmov */
153 COSTS_N_INSNS (4), /* fp_add */
154 COSTS_N_INSNS (4), /* fp_mult */
155 COSTS_N_INSNS (15), /* fp_div_sf */
156 COSTS_N_INSNS (22), /* fp_div_df */
157 COSTS_N_INSNS (8), /* int_mult_si */
158 COSTS_N_INSNS (12), /* int_mult_di */
159 COSTS_N_INSNS (1) + 1, /* int_shift */
160 COSTS_N_INSNS (1), /* int_cmov */
163 COSTS_N_INSNS (4), /* fp_add */
164 COSTS_N_INSNS (4), /* fp_mult */
165 COSTS_N_INSNS (12), /* fp_div_sf */
166 COSTS_N_INSNS (15), /* fp_div_df */
167 COSTS_N_INSNS (7), /* int_mult_si */
168 COSTS_N_INSNS (7), /* int_mult_di */
169 COSTS_N_INSNS (1), /* int_shift */
170 COSTS_N_INSNS (2), /* int_cmov */
174 /* Declarations of static functions. */
175 static bool alpha_function_ok_for_sibcall
176 PARAMS ((tree
, tree
));
177 static int tls_symbolic_operand_1
178 PARAMS ((rtx
, enum machine_mode
, int, int));
179 static enum tls_model tls_symbolic_operand_type
181 static bool decl_in_text_section
183 static bool decl_has_samegp
185 static bool alpha_in_small_data_p
187 static void alpha_encode_section_info
188 PARAMS ((tree
, int));
189 static const char *alpha_strip_name_encoding
190 PARAMS ((const char *));
191 static int some_small_symbolic_operand_1
192 PARAMS ((rtx
*, void *));
193 static int split_small_symbolic_operand_1
194 PARAMS ((rtx
*, void *));
195 static bool alpha_cannot_copy_insn_p
197 static bool alpha_rtx_costs
198 PARAMS ((rtx
, int, int, int *));
199 static void alpha_set_memflags_1
200 PARAMS ((rtx
, int, int, int));
201 static rtx alpha_emit_set_const_1
202 PARAMS ((rtx
, enum machine_mode
, HOST_WIDE_INT
, int));
203 static void alpha_expand_unaligned_load_words
204 PARAMS ((rtx
*out_regs
, rtx smem
, HOST_WIDE_INT words
, HOST_WIDE_INT ofs
));
205 static void alpha_expand_unaligned_store_words
206 PARAMS ((rtx
*out_regs
, rtx smem
, HOST_WIDE_INT words
, HOST_WIDE_INT ofs
));
207 static void alpha_init_builtins
209 static rtx alpha_expand_builtin
210 PARAMS ((tree
, rtx
, rtx
, enum machine_mode
, int));
211 static void alpha_sa_mask
212 PARAMS ((unsigned long *imaskP
, unsigned long *fmaskP
));
213 static int find_lo_sum_using_gp
214 PARAMS ((rtx
*, void *));
215 static int alpha_does_function_need_gp
217 static int alpha_ra_ever_killed
219 static const char *get_trap_mode_suffix
221 static const char *get_round_mode_suffix
223 static const char *get_some_local_dynamic_name
225 static int get_some_local_dynamic_name_1
226 PARAMS ((rtx
*, void *));
227 static rtx set_frame_related_p
229 static const char *alpha_lookup_xfloating_lib_func
230 PARAMS ((enum rtx_code
));
231 static int alpha_compute_xfloating_mode_arg
232 PARAMS ((enum rtx_code
, enum alpha_fp_rounding_mode
));
233 static void alpha_emit_xfloating_libcall
234 PARAMS ((const char *, rtx
, rtx
[], int, rtx
));
235 static rtx alpha_emit_xfloating_compare
236 PARAMS ((enum rtx_code
, rtx
, rtx
));
237 static void alpha_output_function_end_prologue
239 static int alpha_adjust_cost
240 PARAMS ((rtx
, rtx
, rtx
, int));
241 static int alpha_issue_rate
243 static int alpha_use_dfa_pipeline_interface
245 static int alpha_multipass_dfa_lookahead
248 #ifdef OBJECT_FORMAT_ELF
249 static void alpha_elf_select_rtx_section
250 PARAMS ((enum machine_mode
, rtx
, unsigned HOST_WIDE_INT
));
253 #if TARGET_ABI_OPEN_VMS
254 static bool alpha_linkage_symbol_p
255 PARAMS ((const char *symname
));
256 static int alpha_write_one_linkage
257 PARAMS ((splay_tree_node
, void *));
258 static void alpha_write_linkage
259 PARAMS ((FILE *, const char *, tree
));
263 static void alpha_output_mi_thunk_osf
264 PARAMS ((FILE *, tree
, HOST_WIDE_INT
, HOST_WIDE_INT
, tree
));
267 static struct machine_function
* alpha_init_machine_status
270 static void unicosmk_output_deferred_case_vectors
PARAMS ((FILE *));
271 static void unicosmk_gen_dsib
PARAMS ((unsigned long *imaskP
));
272 static void unicosmk_output_ssib
PARAMS ((FILE *, const char *));
273 static int unicosmk_need_dex
PARAMS ((rtx
));
275 /* Get the number of args of a function in one of two ways. */
276 #if TARGET_ABI_OPEN_VMS || TARGET_ABI_UNICOSMK
277 #define NUM_ARGS current_function_args_info.num_args
279 #define NUM_ARGS current_function_args_info
285 /* Initialize the GCC target structure. */
286 #if TARGET_ABI_OPEN_VMS
287 const struct attribute_spec vms_attribute_table
[];
288 static unsigned int vms_section_type_flags
PARAMS ((tree
, const char *, int));
289 static void vms_asm_named_section
PARAMS ((const char *, unsigned int));
290 static void vms_asm_out_constructor
PARAMS ((rtx
, int));
291 static void vms_asm_out_destructor
PARAMS ((rtx
, int));
292 # undef TARGET_ATTRIBUTE_TABLE
293 # define TARGET_ATTRIBUTE_TABLE vms_attribute_table
294 # undef TARGET_SECTION_TYPE_FLAGS
295 # define TARGET_SECTION_TYPE_FLAGS vms_section_type_flags
298 #undef TARGET_IN_SMALL_DATA_P
299 #define TARGET_IN_SMALL_DATA_P alpha_in_small_data_p
300 #undef TARGET_ENCODE_SECTION_INFO
301 #define TARGET_ENCODE_SECTION_INFO alpha_encode_section_info
302 #undef TARGET_STRIP_NAME_ENCODING
303 #define TARGET_STRIP_NAME_ENCODING alpha_strip_name_encoding
305 #if TARGET_ABI_UNICOSMK
306 static void unicosmk_asm_named_section
PARAMS ((const char *, unsigned int));
307 static void unicosmk_insert_attributes
PARAMS ((tree
, tree
*));
308 static unsigned int unicosmk_section_type_flags
PARAMS ((tree
, const char *,
310 static void unicosmk_unique_section
PARAMS ((tree
, int));
311 # undef TARGET_INSERT_ATTRIBUTES
312 # define TARGET_INSERT_ATTRIBUTES unicosmk_insert_attributes
313 # undef TARGET_SECTION_TYPE_FLAGS
314 # define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags
315 # undef TARGET_ASM_UNIQUE_SECTION
316 # define TARGET_ASM_UNIQUE_SECTION unicosmk_unique_section
317 # undef TARGET_ASM_GLOBALIZE_LABEL
318 # define TARGET_ASM_GLOBALIZE_LABEL hook_FILEptr_constcharptr_void
321 #undef TARGET_ASM_ALIGNED_HI_OP
322 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
323 #undef TARGET_ASM_ALIGNED_DI_OP
324 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
326 /* Default unaligned ops are provided for ELF systems. To get unaligned
327 data for non-ELF systems, we have to turn off auto alignment. */
328 #ifndef OBJECT_FORMAT_ELF
329 #undef TARGET_ASM_UNALIGNED_HI_OP
330 #define TARGET_ASM_UNALIGNED_HI_OP "\t.align 0\n\t.word\t"
331 #undef TARGET_ASM_UNALIGNED_SI_OP
332 #define TARGET_ASM_UNALIGNED_SI_OP "\t.align 0\n\t.long\t"
333 #undef TARGET_ASM_UNALIGNED_DI_OP
334 #define TARGET_ASM_UNALIGNED_DI_OP "\t.align 0\n\t.quad\t"
337 #ifdef OBJECT_FORMAT_ELF
338 #undef TARGET_ASM_SELECT_RTX_SECTION
339 #define TARGET_ASM_SELECT_RTX_SECTION alpha_elf_select_rtx_section
342 #undef TARGET_ASM_FUNCTION_END_PROLOGUE
343 #define TARGET_ASM_FUNCTION_END_PROLOGUE alpha_output_function_end_prologue
345 #undef TARGET_SCHED_ADJUST_COST
346 #define TARGET_SCHED_ADJUST_COST alpha_adjust_cost
347 #undef TARGET_SCHED_ISSUE_RATE
348 #define TARGET_SCHED_ISSUE_RATE alpha_issue_rate
349 #undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE
350 #define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE \
351 alpha_use_dfa_pipeline_interface
352 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
353 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD \
354 alpha_multipass_dfa_lookahead
356 #undef TARGET_HAVE_TLS
357 #define TARGET_HAVE_TLS HAVE_AS_TLS
359 #undef TARGET_INIT_BUILTINS
360 #define TARGET_INIT_BUILTINS alpha_init_builtins
361 #undef TARGET_EXPAND_BUILTIN
362 #define TARGET_EXPAND_BUILTIN alpha_expand_builtin
364 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
365 #define TARGET_FUNCTION_OK_FOR_SIBCALL alpha_function_ok_for_sibcall
366 #undef TARGET_CANNOT_COPY_INSN_P
367 #define TARGET_CANNOT_COPY_INSN_P alpha_cannot_copy_insn_p
370 #undef TARGET_ASM_OUTPUT_MI_THUNK
371 #define TARGET_ASM_OUTPUT_MI_THUNK alpha_output_mi_thunk_osf
372 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
373 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
376 #undef TARGET_RTX_COSTS
377 #define TARGET_RTX_COSTS alpha_rtx_costs
378 #undef TARGET_ADDRESS_COST
379 #define TARGET_ADDRESS_COST hook_int_rtx_0
381 struct gcc_target targetm
= TARGET_INITIALIZER
;
383 /* Parse target option strings. */
389 static const struct cpu_table
{
390 const char *const name
;
391 const enum processor_type processor
;
394 #define EV5_MASK (MASK_CPU_EV5)
395 #define EV6_MASK (MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX)
396 { "ev4", PROCESSOR_EV4
, 0 },
397 { "ev45", PROCESSOR_EV4
, 0 },
398 { "21064", PROCESSOR_EV4
, 0 },
399 { "ev5", PROCESSOR_EV5
, EV5_MASK
},
400 { "21164", PROCESSOR_EV5
, EV5_MASK
},
401 { "ev56", PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
},
402 { "21164a", PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
},
403 { "pca56", PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
|MASK_MAX
},
404 { "21164PC",PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
|MASK_MAX
},
405 { "21164pc",PROCESSOR_EV5
, EV5_MASK
|MASK_BWX
|MASK_MAX
},
406 { "ev6", PROCESSOR_EV6
, EV6_MASK
},
407 { "21264", PROCESSOR_EV6
, EV6_MASK
},
408 { "ev67", PROCESSOR_EV6
, EV6_MASK
|MASK_CIX
},
409 { "21264a", PROCESSOR_EV6
, EV6_MASK
|MASK_CIX
},
413 /* Unicos/Mk doesn't have shared libraries. */
414 if (TARGET_ABI_UNICOSMK
&& flag_pic
)
416 warning ("-f%s ignored for Unicos/Mk (not supported)",
417 (flag_pic
> 1) ? "PIC" : "pic");
421 /* On Unicos/Mk, the native compiler consistenly generates /d suffices for
422 floating-point instructions. Make that the default for this target. */
423 if (TARGET_ABI_UNICOSMK
)
424 alpha_fprm
= ALPHA_FPRM_DYN
;
426 alpha_fprm
= ALPHA_FPRM_NORM
;
428 alpha_tp
= ALPHA_TP_PROG
;
429 alpha_fptm
= ALPHA_FPTM_N
;
431 /* We cannot use su and sui qualifiers for conversion instructions on
432 Unicos/Mk. I'm not sure if this is due to assembler or hardware
433 limitations. Right now, we issue a warning if -mieee is specified
434 and then ignore it; eventually, we should either get it right or
435 disable the option altogether. */
439 if (TARGET_ABI_UNICOSMK
)
440 warning ("-mieee not supported on Unicos/Mk");
443 alpha_tp
= ALPHA_TP_INSN
;
444 alpha_fptm
= ALPHA_FPTM_SU
;
448 if (TARGET_IEEE_WITH_INEXACT
)
450 if (TARGET_ABI_UNICOSMK
)
451 warning ("-mieee-with-inexact not supported on Unicos/Mk");
454 alpha_tp
= ALPHA_TP_INSN
;
455 alpha_fptm
= ALPHA_FPTM_SUI
;
461 if (! strcmp (alpha_tp_string
, "p"))
462 alpha_tp
= ALPHA_TP_PROG
;
463 else if (! strcmp (alpha_tp_string
, "f"))
464 alpha_tp
= ALPHA_TP_FUNC
;
465 else if (! strcmp (alpha_tp_string
, "i"))
466 alpha_tp
= ALPHA_TP_INSN
;
468 error ("bad value `%s' for -mtrap-precision switch", alpha_tp_string
);
471 if (alpha_fprm_string
)
473 if (! strcmp (alpha_fprm_string
, "n"))
474 alpha_fprm
= ALPHA_FPRM_NORM
;
475 else if (! strcmp (alpha_fprm_string
, "m"))
476 alpha_fprm
= ALPHA_FPRM_MINF
;
477 else if (! strcmp (alpha_fprm_string
, "c"))
478 alpha_fprm
= ALPHA_FPRM_CHOP
;
479 else if (! strcmp (alpha_fprm_string
,"d"))
480 alpha_fprm
= ALPHA_FPRM_DYN
;
482 error ("bad value `%s' for -mfp-rounding-mode switch",
486 if (alpha_fptm_string
)
488 if (strcmp (alpha_fptm_string
, "n") == 0)
489 alpha_fptm
= ALPHA_FPTM_N
;
490 else if (strcmp (alpha_fptm_string
, "u") == 0)
491 alpha_fptm
= ALPHA_FPTM_U
;
492 else if (strcmp (alpha_fptm_string
, "su") == 0)
493 alpha_fptm
= ALPHA_FPTM_SU
;
494 else if (strcmp (alpha_fptm_string
, "sui") == 0)
495 alpha_fptm
= ALPHA_FPTM_SUI
;
497 error ("bad value `%s' for -mfp-trap-mode switch", alpha_fptm_string
);
500 if (alpha_tls_size_string
)
502 if (strcmp (alpha_tls_size_string
, "16") == 0)
504 else if (strcmp (alpha_tls_size_string
, "32") == 0)
506 else if (strcmp (alpha_tls_size_string
, "64") == 0)
509 error ("bad value `%s' for -mtls-size switch", alpha_tls_size_string
);
513 = TARGET_CPU_DEFAULT
& MASK_CPU_EV6
? PROCESSOR_EV6
514 : (TARGET_CPU_DEFAULT
& MASK_CPU_EV5
? PROCESSOR_EV5
: PROCESSOR_EV4
);
516 if (alpha_cpu_string
)
518 for (i
= 0; cpu_table
[i
].name
; i
++)
519 if (! strcmp (alpha_cpu_string
, cpu_table
[i
].name
))
521 alpha_cpu
= cpu_table
[i
].processor
;
522 target_flags
&= ~ (MASK_BWX
| MASK_MAX
| MASK_FIX
| MASK_CIX
523 | MASK_CPU_EV5
| MASK_CPU_EV6
);
524 target_flags
|= cpu_table
[i
].flags
;
527 if (! cpu_table
[i
].name
)
528 error ("bad value `%s' for -mcpu switch", alpha_cpu_string
);
531 if (alpha_tune_string
)
533 for (i
= 0; cpu_table
[i
].name
; i
++)
534 if (! strcmp (alpha_tune_string
, cpu_table
[i
].name
))
536 alpha_cpu
= cpu_table
[i
].processor
;
539 if (! cpu_table
[i
].name
)
540 error ("bad value `%s' for -mcpu switch", alpha_tune_string
);
543 /* Do some sanity checks on the above options. */
545 if (TARGET_ABI_UNICOSMK
&& alpha_fptm
!= ALPHA_FPTM_N
)
547 warning ("trap mode not supported on Unicos/Mk");
548 alpha_fptm
= ALPHA_FPTM_N
;
551 if ((alpha_fptm
== ALPHA_FPTM_SU
|| alpha_fptm
== ALPHA_FPTM_SUI
)
552 && alpha_tp
!= ALPHA_TP_INSN
&& ! TARGET_CPU_EV6
)
554 warning ("fp software completion requires -mtrap-precision=i");
555 alpha_tp
= ALPHA_TP_INSN
;
560 /* Except for EV6 pass 1 (not released), we always have precise
561 arithmetic traps. Which means we can do software completion
562 without minding trap shadows. */
563 alpha_tp
= ALPHA_TP_PROG
;
566 if (TARGET_FLOAT_VAX
)
568 if (alpha_fprm
== ALPHA_FPRM_MINF
|| alpha_fprm
== ALPHA_FPRM_DYN
)
570 warning ("rounding mode not supported for VAX floats");
571 alpha_fprm
= ALPHA_FPRM_NORM
;
573 if (alpha_fptm
== ALPHA_FPTM_SUI
)
575 warning ("trap mode not supported for VAX floats");
576 alpha_fptm
= ALPHA_FPTM_SU
;
584 if (!alpha_mlat_string
)
585 alpha_mlat_string
= "L1";
587 if (ISDIGIT ((unsigned char)alpha_mlat_string
[0])
588 && (lat
= strtol (alpha_mlat_string
, &end
, 10), *end
== '\0'))
590 else if ((alpha_mlat_string
[0] == 'L' || alpha_mlat_string
[0] == 'l')
591 && ISDIGIT ((unsigned char)alpha_mlat_string
[1])
592 && alpha_mlat_string
[2] == '\0')
594 static int const cache_latency
[][4] =
596 { 3, 30, -1 }, /* ev4 -- Bcache is a guess */
597 { 2, 12, 38 }, /* ev5 -- Bcache from PC164 LMbench numbers */
598 { 3, 12, 30 }, /* ev6 -- Bcache from DS20 LMbench. */
601 lat
= alpha_mlat_string
[1] - '0';
602 if (lat
<= 0 || lat
> 3 || cache_latency
[alpha_cpu
][lat
-1] == -1)
604 warning ("L%d cache latency unknown for %s",
605 lat
, alpha_cpu_name
[alpha_cpu
]);
609 lat
= cache_latency
[alpha_cpu
][lat
-1];
611 else if (! strcmp (alpha_mlat_string
, "main"))
613 /* Most current memories have about 370ns latency. This is
614 a reasonable guess for a fast cpu. */
619 warning ("bad value `%s' for -mmemory-latency", alpha_mlat_string
);
623 alpha_memory_latency
= lat
;
626 /* Default the definition of "small data" to 8 bytes. */
630 /* Infer TARGET_SMALL_DATA from -fpic/-fPIC. */
632 target_flags
|= MASK_SMALL_DATA
;
633 else if (flag_pic
== 2)
634 target_flags
&= ~MASK_SMALL_DATA
;
636 /* Align labels and loops for optimal branching. */
637 /* ??? Kludge these by not doing anything if we don't optimize and also if
638 we are writing ECOFF symbols to work around a bug in DEC's assembler. */
639 if (optimize
> 0 && write_symbols
!= SDB_DEBUG
)
641 if (align_loops
<= 0)
643 if (align_jumps
<= 0)
646 if (align_functions
<= 0)
647 align_functions
= 16;
649 /* Acquire a unique set number for our register saves and restores. */
650 alpha_sr_alias_set
= new_alias_set ();
652 /* Register variables and functions with the garbage collector. */
654 /* Set up function hooks. */
655 init_machine_status
= alpha_init_machine_status
;
657 /* Tell the compiler when we're using VAX floating point. */
658 if (TARGET_FLOAT_VAX
)
660 real_format_for_mode
[SFmode
- QFmode
] = &vax_f_format
;
661 real_format_for_mode
[DFmode
- QFmode
] = &vax_g_format
;
662 real_format_for_mode
[TFmode
- QFmode
] = NULL
;
666 /* Returns 1 if VALUE is a mask that contains full bytes of zero or ones. */
674 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
;
676 if ((value
& 0xff) != 0 && (value
& 0xff) != 0xff)
682 /* Returns 1 if OP is either the constant zero or a register. If a
683 register, it must be in the proper mode unless MODE is VOIDmode. */
686 reg_or_0_operand (op
, mode
)
688 enum machine_mode mode
;
690 return op
== CONST0_RTX (mode
) || register_operand (op
, mode
);
693 /* Return 1 if OP is a constant in the range of 0-63 (for a shift) or
697 reg_or_6bit_operand (op
, mode
)
699 enum machine_mode mode
;
701 return ((GET_CODE (op
) == CONST_INT
702 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 64)
703 || register_operand (op
, mode
));
707 /* Return 1 if OP is an 8-bit constant or any register. */
710 reg_or_8bit_operand (op
, mode
)
712 enum machine_mode mode
;
714 return ((GET_CODE (op
) == CONST_INT
715 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100)
716 || register_operand (op
, mode
));
719 /* Return 1 if OP is a constant or any register. */
722 reg_or_const_int_operand (op
, mode
)
724 enum machine_mode mode
;
726 return GET_CODE (op
) == CONST_INT
|| register_operand (op
, mode
);
729 /* Return 1 if OP is an 8-bit constant. */
732 cint8_operand (op
, mode
)
734 enum machine_mode mode ATTRIBUTE_UNUSED
;
736 return ((GET_CODE (op
) == CONST_INT
737 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100));
740 /* Return 1 if the operand is a valid second operand to an add insn. */
743 add_operand (op
, mode
)
745 enum machine_mode mode
;
747 if (GET_CODE (op
) == CONST_INT
)
748 /* Constraints I, J, O and P are covered by K. */
749 return (CONST_OK_FOR_LETTER_P (INTVAL (op
), 'K')
750 || CONST_OK_FOR_LETTER_P (INTVAL (op
), 'L'));
752 return register_operand (op
, mode
);
755 /* Return 1 if the operand is a valid second operand to a sign-extending
759 sext_add_operand (op
, mode
)
761 enum machine_mode mode
;
763 if (GET_CODE (op
) == CONST_INT
)
764 return (CONST_OK_FOR_LETTER_P (INTVAL (op
), 'I')
765 || CONST_OK_FOR_LETTER_P (INTVAL (op
), 'O'));
767 return reg_not_elim_operand (op
, mode
);
770 /* Return 1 if OP is the constant 4 or 8. */
773 const48_operand (op
, mode
)
775 enum machine_mode mode ATTRIBUTE_UNUSED
;
777 return (GET_CODE (op
) == CONST_INT
778 && (INTVAL (op
) == 4 || INTVAL (op
) == 8));
781 /* Return 1 if OP is a valid first operand to an AND insn. */
784 and_operand (op
, mode
)
786 enum machine_mode mode
;
788 if (GET_CODE (op
) == CONST_DOUBLE
&& GET_MODE (op
) == VOIDmode
)
789 return (zap_mask (CONST_DOUBLE_LOW (op
))
790 && zap_mask (CONST_DOUBLE_HIGH (op
)));
792 if (GET_CODE (op
) == CONST_INT
)
793 return ((unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100
794 || (unsigned HOST_WIDE_INT
) ~ INTVAL (op
) < 0x100
795 || zap_mask (INTVAL (op
)));
797 return register_operand (op
, mode
);
800 /* Return 1 if OP is a valid first operand to an IOR or XOR insn. */
803 or_operand (op
, mode
)
805 enum machine_mode mode
;
807 if (GET_CODE (op
) == CONST_INT
)
808 return ((unsigned HOST_WIDE_INT
) INTVAL (op
) < 0x100
809 || (unsigned HOST_WIDE_INT
) ~ INTVAL (op
) < 0x100);
811 return register_operand (op
, mode
);
814 /* Return 1 if OP is a constant that is the width, in bits, of an integral
815 mode smaller than DImode. */
818 mode_width_operand (op
, mode
)
820 enum machine_mode mode ATTRIBUTE_UNUSED
;
822 return (GET_CODE (op
) == CONST_INT
823 && (INTVAL (op
) == 8 || INTVAL (op
) == 16
824 || INTVAL (op
) == 32 || INTVAL (op
) == 64));
827 /* Return 1 if OP is a constant that is the width of an integral machine mode
828 smaller than an integer. */
831 mode_mask_operand (op
, mode
)
833 enum machine_mode mode ATTRIBUTE_UNUSED
;
835 if (GET_CODE (op
) == CONST_INT
)
837 HOST_WIDE_INT value
= INTVAL (op
);
843 if (value
== 0xffffffff)
848 else if (HOST_BITS_PER_WIDE_INT
== 32 && GET_CODE (op
) == CONST_DOUBLE
)
850 if (CONST_DOUBLE_LOW (op
) == 0xffffffff && CONST_DOUBLE_HIGH (op
) == 0)
857 /* Return 1 if OP is a multiple of 8 less than 64. */
860 mul8_operand (op
, mode
)
862 enum machine_mode mode ATTRIBUTE_UNUSED
;
864 return (GET_CODE (op
) == CONST_INT
865 && (unsigned HOST_WIDE_INT
) INTVAL (op
) < 64
866 && (INTVAL (op
) & 7) == 0);
869 /* Return 1 if OP is the zero constant for MODE. */
872 const0_operand (op
, mode
)
874 enum machine_mode mode
;
876 return op
== CONST0_RTX (mode
);
879 /* Return 1 if OP is a hard floating-point register. */
882 hard_fp_register_operand (op
, mode
)
884 enum machine_mode mode
;
886 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
889 if (GET_CODE (op
) == SUBREG
)
890 op
= SUBREG_REG (op
);
891 return GET_CODE (op
) == REG
&& REGNO_REG_CLASS (REGNO (op
)) == FLOAT_REGS
;
894 /* Return 1 if OP is a hard general register. */
897 hard_int_register_operand (op
, mode
)
899 enum machine_mode mode
;
901 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
904 if (GET_CODE (op
) == SUBREG
)
905 op
= SUBREG_REG (op
);
906 return GET_CODE (op
) == REG
&& REGNO_REG_CLASS (REGNO (op
)) == GENERAL_REGS
;
909 /* Return 1 if OP is a register or a constant integer. */
913 reg_or_cint_operand (op
, mode
)
915 enum machine_mode mode
;
917 return (GET_CODE (op
) == CONST_INT
918 || register_operand (op
, mode
));
921 /* Return 1 if OP is something that can be reloaded into a register;
922 if it is a MEM, it need not be valid. */
925 some_operand (op
, mode
)
927 enum machine_mode mode
;
929 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
932 switch (GET_CODE (op
))
946 return some_operand (SUBREG_REG (op
), VOIDmode
);
955 /* Likewise, but don't accept constants. */
958 some_ni_operand (op
, mode
)
960 enum machine_mode mode
;
962 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
965 if (GET_CODE (op
) == SUBREG
)
966 op
= SUBREG_REG (op
);
968 return (GET_CODE (op
) == REG
|| GET_CODE (op
) == MEM
);
971 /* Return 1 if OP is a valid operand for the source of a move insn. */
974 input_operand (op
, mode
)
976 enum machine_mode mode
;
978 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
981 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
&& GET_MODE (op
) != mode
)
984 switch (GET_CODE (op
))
989 if (TARGET_EXPLICIT_RELOCS
)
991 /* We don't split symbolic operands into something unintelligable
992 until after reload, but we do not wish non-small, non-global
993 symbolic operands to be reconstructed from their high/lo_sum
995 return (small_symbolic_operand (op
, mode
)
996 || global_symbolic_operand (op
, mode
)
997 || gotdtp_symbolic_operand (op
, mode
)
998 || gottp_symbolic_operand (op
, mode
));
1001 /* This handles both the Windows/NT and OSF cases. */
1002 return mode
== ptr_mode
|| mode
== DImode
;
1005 return (TARGET_EXPLICIT_RELOCS
1006 && local_symbolic_operand (XEXP (op
, 0), mode
));
1013 if (register_operand (op
, mode
))
1015 /* ... fall through ... */
1017 return ((TARGET_BWX
|| (mode
!= HImode
&& mode
!= QImode
))
1018 && general_operand (op
, mode
));
1022 return op
== CONST0_RTX (mode
);
1025 return mode
== QImode
|| mode
== HImode
|| add_operand (op
, mode
);
1027 case CONSTANT_P_RTX
:
1037 /* Return 1 if OP is a SYMBOL_REF for a function known to be in this
1038 file, and in the same section as the current function. */
1041 samegp_function_operand (op
, mode
)
1043 enum machine_mode mode ATTRIBUTE_UNUSED
;
1045 if (GET_CODE (op
) != SYMBOL_REF
)
1048 /* Easy test for recursion. */
1049 if (op
== XEXP (DECL_RTL (current_function_decl
), 0))
1052 /* Otherwise, encode_section_info recorded whether we are to treat
1053 this symbol as having the same GP. */
1054 return SYMBOL_REF_FLAG (op
);
1057 /* Return 1 if OP is a SYMBOL_REF for which we can make a call via bsr. */
1060 direct_call_operand (op
, mode
)
1062 enum machine_mode mode
;
1064 /* Must share the same GP. */
1065 if (!samegp_function_operand (op
, mode
))
1068 /* If profiling is implemented via linker tricks, we can't jump
1069 to the nogp alternate entry point. Note that current_function_profile
1070 would not be correct, since that doesn't indicate if the target
1071 function uses profiling. */
1072 /* ??? TARGET_PROFILING_NEEDS_GP isn't really the right test,
1073 but is approximately correct for the OSF ABIs. Don't know
1074 what to do for VMS, NT, or UMK. */
1075 if (!TARGET_PROFILING_NEEDS_GP
&& profile_flag
)
1078 /* Must be "near" so that the branch is assumed to reach. With
1079 -msmall-text, this is true of all local symbols. */
1080 if (TARGET_SMALL_TEXT
)
1083 /* Otherwise, a decl is "near" if it is defined in the same section.
1084 See alpha_encode_section_info for commentary. */
1085 return op
->jump
&& decl_in_text_section (cfun
->decl
);
1088 /* Return true if OP is a LABEL_REF, or SYMBOL_REF or CONST referencing
1089 a (non-tls) variable known to be defined in this file. */
1092 local_symbolic_operand (op
, mode
)
1094 enum machine_mode mode
;
1098 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1101 if (GET_CODE (op
) == LABEL_REF
)
1104 if (GET_CODE (op
) == CONST
1105 && GET_CODE (XEXP (op
, 0)) == PLUS
1106 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
1107 op
= XEXP (XEXP (op
, 0), 0);
1109 if (GET_CODE (op
) != SYMBOL_REF
)
1112 /* Easy pickings. */
1113 if (CONSTANT_POOL_ADDRESS_P (op
) || STRING_POOL_ADDRESS_P (op
))
1116 /* ??? SYMBOL_REF_FLAG is set for local function symbols, but we
1117 run into problems with the rtl inliner in that the symbol was
1118 once external, but is local after inlining, which results in
1119 unrecognizable insns. */
1123 /* If @[LS], then alpha_encode_section_info sez it's local. */
1124 if (str
[0] == '@' && (str
[1] == 'L' || str
[1] == 'S'))
1127 /* If *$, then ASM_GENERATE_INTERNAL_LABEL sez it's local. */
1128 if (str
[0] == '*' && str
[1] == '$')
1134 /* Return true if OP is a SYMBOL_REF or CONST referencing a variable
1135 known to be defined in this file in the small data area. */
1138 small_symbolic_operand (op
, mode
)
1140 enum machine_mode mode ATTRIBUTE_UNUSED
;
1144 if (! TARGET_SMALL_DATA
)
1147 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1150 if (GET_CODE (op
) == CONST
1151 && GET_CODE (XEXP (op
, 0)) == PLUS
1152 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
1153 op
= XEXP (XEXP (op
, 0), 0);
1155 if (GET_CODE (op
) != SYMBOL_REF
)
1158 if (CONSTANT_POOL_ADDRESS_P (op
))
1159 return GET_MODE_SIZE (get_pool_mode (op
)) <= (unsigned) g_switch_value
;
1163 return str
[0] == '@' && str
[1] == 'S';
1167 /* Return true if OP is a SYMBOL_REF or CONST referencing a variable
1168 not known (or known not) to be defined in this file. */
1171 global_symbolic_operand (op
, mode
)
1173 enum machine_mode mode
;
1177 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1180 if (GET_CODE (op
) == CONST
1181 && GET_CODE (XEXP (op
, 0)) == PLUS
1182 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
1183 op
= XEXP (XEXP (op
, 0), 0);
1185 if (GET_CODE (op
) != SYMBOL_REF
)
1188 if (local_symbolic_operand (op
, mode
))
1191 /* Also verify that it's not a TLS symbol. */
1193 return str
[0] != '%' && str
[0] != '@';
1196 /* Return 1 if OP is a valid operand for the MEM of a CALL insn. */
1199 call_operand (op
, mode
)
1201 enum machine_mode mode
;
1206 if (GET_CODE (op
) == REG
)
1210 /* Disallow virtual registers to cope with pathalogical test cases
1211 such as compile/930117-1.c in which the virtual reg decomposes
1212 to the frame pointer. Which is a hard reg that is not $27. */
1213 return (REGNO (op
) == 27 || REGNO (op
) > LAST_VIRTUAL_REGISTER
);
1218 if (TARGET_ABI_UNICOSMK
)
1220 if (GET_CODE (op
) == SYMBOL_REF
)
1226 /* Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
1227 possibly with an offset. */
1230 symbolic_operand (op
, mode
)
1232 enum machine_mode mode
;
1234 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1236 if (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == LABEL_REF
)
1238 if (GET_CODE (op
) == CONST
1239 && GET_CODE (XEXP (op
,0)) == PLUS
1240 && GET_CODE (XEXP (XEXP (op
,0), 0)) == SYMBOL_REF
1241 && GET_CODE (XEXP (XEXP (op
,0), 1)) == CONST_INT
)
1246 /* Return true if OP is valid for a particular TLS relocation. */
1249 tls_symbolic_operand_1 (op
, mode
, size
, unspec
)
1251 enum machine_mode mode
;
1256 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1259 if (GET_CODE (op
) != CONST
)
1263 if (GET_CODE (op
) != UNSPEC
|| XINT (op
, 1) != unspec
)
1265 op
= XVECEXP (op
, 0, 0);
1267 if (GET_CODE (op
) != SYMBOL_REF
)
1276 else if (str
[0] == '@')
1278 if (alpha_tls_size
> size
)
1287 return unspec
== UNSPEC_DTPREL
;
1289 return unspec
== UNSPEC_TPREL
&& size
== 64;
1291 return unspec
== UNSPEC_TPREL
&& size
< 64;
1297 /* Return true if OP is valid for 16-bit DTP relative relocations. */
1300 dtp16_symbolic_operand (op
, mode
)
1302 enum machine_mode mode
;
1304 return tls_symbolic_operand_1 (op
, mode
, 16, UNSPEC_DTPREL
);
1307 /* Return true if OP is valid for 32-bit DTP relative relocations. */
1310 dtp32_symbolic_operand (op
, mode
)
1312 enum machine_mode mode
;
1314 return tls_symbolic_operand_1 (op
, mode
, 32, UNSPEC_DTPREL
);
1317 /* Return true if OP is valid for 64-bit DTP relative relocations. */
1320 gotdtp_symbolic_operand (op
, mode
)
1322 enum machine_mode mode
;
1324 return tls_symbolic_operand_1 (op
, mode
, 64, UNSPEC_DTPREL
);
1327 /* Return true if OP is valid for 16-bit TP relative relocations. */
1330 tp16_symbolic_operand (op
, mode
)
1332 enum machine_mode mode
;
1334 return tls_symbolic_operand_1 (op
, mode
, 16, UNSPEC_TPREL
);
1337 /* Return true if OP is valid for 32-bit TP relative relocations. */
1340 tp32_symbolic_operand (op
, mode
)
1342 enum machine_mode mode
;
1344 return tls_symbolic_operand_1 (op
, mode
, 32, UNSPEC_TPREL
);
1347 /* Return true if OP is valid for 64-bit TP relative relocations. */
1350 gottp_symbolic_operand (op
, mode
)
1352 enum machine_mode mode
;
1354 return tls_symbolic_operand_1 (op
, mode
, 64, UNSPEC_TPREL
);
1357 /* Return 1 if OP is a valid Alpha comparison operator. Here we know which
1358 comparisons are valid in which insn. */
1361 alpha_comparison_operator (op
, mode
)
1363 enum machine_mode mode
;
1365 enum rtx_code code
= GET_CODE (op
);
1367 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1370 return (code
== EQ
|| code
== LE
|| code
== LT
1371 || code
== LEU
|| code
== LTU
);
1374 /* Return 1 if OP is a valid Alpha comparison operator against zero.
1375 Here we know which comparisons are valid in which insn. */
1378 alpha_zero_comparison_operator (op
, mode
)
1380 enum machine_mode mode
;
1382 enum rtx_code code
= GET_CODE (op
);
1384 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1387 return (code
== EQ
|| code
== NE
|| code
== LE
|| code
== LT
1388 || code
== LEU
|| code
== LTU
);
1391 /* Return 1 if OP is a valid Alpha swapped comparison operator. */
1394 alpha_swapped_comparison_operator (op
, mode
)
1396 enum machine_mode mode
;
1398 enum rtx_code code
= GET_CODE (op
);
1400 if ((mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1401 || GET_RTX_CLASS (code
) != '<')
1404 code
= swap_condition (code
);
1405 return (code
== EQ
|| code
== LE
|| code
== LT
1406 || code
== LEU
|| code
== LTU
);
1409 /* Return 1 if OP is a signed comparison operation. */
1412 signed_comparison_operator (op
, mode
)
1414 enum machine_mode mode ATTRIBUTE_UNUSED
;
1416 enum rtx_code code
= GET_CODE (op
);
1418 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1421 return (code
== EQ
|| code
== NE
1422 || code
== LE
|| code
== LT
1423 || code
== GE
|| code
== GT
);
1426 /* Return 1 if OP is a valid Alpha floating point comparison operator.
1427 Here we know which comparisons are valid in which insn. */
1430 alpha_fp_comparison_operator (op
, mode
)
1432 enum machine_mode mode
;
1434 enum rtx_code code
= GET_CODE (op
);
1436 if (mode
!= GET_MODE (op
) && mode
!= VOIDmode
)
1439 return (code
== EQ
|| code
== LE
|| code
== LT
|| code
== UNORDERED
);
1442 /* Return 1 if this is a divide or modulus operator. */
1445 divmod_operator (op
, mode
)
1447 enum machine_mode mode ATTRIBUTE_UNUSED
;
1449 switch (GET_CODE (op
))
1451 case DIV
: case MOD
: case UDIV
: case UMOD
:
1461 /* Return 1 if this memory address is a known aligned register plus
1462 a constant. It must be a valid address. This means that we can do
1463 this as an aligned reference plus some offset.
1465 Take into account what reload will do. */
1468 aligned_memory_operand (op
, mode
)
1470 enum machine_mode mode
;
1474 if (reload_in_progress
)
1477 if (GET_CODE (tmp
) == SUBREG
)
1478 tmp
= SUBREG_REG (tmp
);
1479 if (GET_CODE (tmp
) == REG
1480 && REGNO (tmp
) >= FIRST_PSEUDO_REGISTER
)
1482 op
= reg_equiv_memory_loc
[REGNO (tmp
)];
1488 if (GET_CODE (op
) != MEM
1489 || GET_MODE (op
) != mode
)
1493 /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
1494 sorts of constructs. Dig for the real base register. */
1495 if (reload_in_progress
1496 && GET_CODE (op
) == PLUS
1497 && GET_CODE (XEXP (op
, 0)) == PLUS
)
1498 base
= XEXP (XEXP (op
, 0), 0);
1501 if (! memory_address_p (mode
, op
))
1503 base
= (GET_CODE (op
) == PLUS
? XEXP (op
, 0) : op
);
1506 return (GET_CODE (base
) == REG
&& REGNO_POINTER_ALIGN (REGNO (base
)) >= 32);
1509 /* Similar, but return 1 if OP is a MEM which is not alignable. */
1512 unaligned_memory_operand (op
, mode
)
1514 enum machine_mode mode
;
1518 if (reload_in_progress
)
1521 if (GET_CODE (tmp
) == SUBREG
)
1522 tmp
= SUBREG_REG (tmp
);
1523 if (GET_CODE (tmp
) == REG
1524 && REGNO (tmp
) >= FIRST_PSEUDO_REGISTER
)
1526 op
= reg_equiv_memory_loc
[REGNO (tmp
)];
1532 if (GET_CODE (op
) != MEM
1533 || GET_MODE (op
) != mode
)
1537 /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
1538 sorts of constructs. Dig for the real base register. */
1539 if (reload_in_progress
1540 && GET_CODE (op
) == PLUS
1541 && GET_CODE (XEXP (op
, 0)) == PLUS
)
1542 base
= XEXP (XEXP (op
, 0), 0);
1545 if (! memory_address_p (mode
, op
))
1547 base
= (GET_CODE (op
) == PLUS
? XEXP (op
, 0) : op
);
1550 return (GET_CODE (base
) == REG
&& REGNO_POINTER_ALIGN (REGNO (base
)) < 32);
1553 /* Return 1 if OP is either a register or an unaligned memory location. */
1556 reg_or_unaligned_mem_operand (op
, mode
)
1558 enum machine_mode mode
;
1560 return register_operand (op
, mode
) || unaligned_memory_operand (op
, mode
);
1563 /* Return 1 if OP is any memory location. During reload a pseudo matches. */
1566 any_memory_operand (op
, mode
)
1568 enum machine_mode mode ATTRIBUTE_UNUSED
;
1570 return (GET_CODE (op
) == MEM
1571 || (GET_CODE (op
) == SUBREG
&& GET_CODE (SUBREG_REG (op
)) == REG
)
1572 || (reload_in_progress
&& GET_CODE (op
) == REG
1573 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
)
1574 || (reload_in_progress
&& GET_CODE (op
) == SUBREG
1575 && GET_CODE (SUBREG_REG (op
)) == REG
1576 && REGNO (SUBREG_REG (op
)) >= FIRST_PSEUDO_REGISTER
));
1579 /* Returns 1 if OP is not an eliminable register.
1581 This exists to cure a pathological abort in the s8addq (et al) patterns,
1583 long foo () { long t; bar(); return (long) &t * 26107; }
1585 which run afoul of a hack in reload to cure a (presumably) similar
1586 problem with lea-type instructions on other targets. But there is
1587 one of us and many of them, so work around the problem by selectively
1588 preventing combine from making the optimization. */
1591 reg_not_elim_operand (op
, mode
)
1593 enum machine_mode mode
;
1596 if (GET_CODE (op
) == SUBREG
)
1597 inner
= SUBREG_REG (op
);
1598 if (inner
== frame_pointer_rtx
|| inner
== arg_pointer_rtx
)
1601 return register_operand (op
, mode
);
1604 /* Return 1 is OP is a memory location that is not a reference (using
1605 an AND) to an unaligned location. Take into account what reload
1609 normal_memory_operand (op
, mode
)
1611 enum machine_mode mode ATTRIBUTE_UNUSED
;
1613 if (reload_in_progress
)
1616 if (GET_CODE (tmp
) == SUBREG
)
1617 tmp
= SUBREG_REG (tmp
);
1618 if (GET_CODE (tmp
) == REG
1619 && REGNO (tmp
) >= FIRST_PSEUDO_REGISTER
)
1621 op
= reg_equiv_memory_loc
[REGNO (tmp
)];
1623 /* This may not have been assigned an equivalent address if it will
1624 be eliminated. In that case, it doesn't matter what we do. */
1630 return GET_CODE (op
) == MEM
&& GET_CODE (XEXP (op
, 0)) != AND
;
1633 /* Accept a register, but not a subreg of any kind. This allows us to
1634 avoid pathological cases in reload wrt data movement common in
1635 int->fp conversion. */
1638 reg_no_subreg_operand (op
, mode
)
1640 enum machine_mode mode
;
1642 if (GET_CODE (op
) != REG
)
1644 return register_operand (op
, mode
);
1647 /* Recognize an addition operation that includes a constant. Used to
1648 convince reload to canonize (plus (plus reg c1) c2) during register
1652 addition_operation (op
, mode
)
1654 enum machine_mode mode
;
1656 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1658 if (GET_CODE (op
) == PLUS
1659 && register_operand (XEXP (op
, 0), mode
)
1660 && GET_CODE (XEXP (op
, 1)) == CONST_INT
1661 && CONST_OK_FOR_LETTER_P (INTVAL (XEXP (op
, 1)), 'K'))
1666 /* Implements CONST_OK_FOR_LETTER_P. Return true if the value matches
1667 the range defined for C in [I-P]. */
1670 alpha_const_ok_for_letter_p (value
, c
)
1671 HOST_WIDE_INT value
;
1677 /* An unsigned 8 bit constant. */
1678 return (unsigned HOST_WIDE_INT
) value
< 0x100;
1680 /* The constant zero. */
1683 /* A signed 16 bit constant. */
1684 return (unsigned HOST_WIDE_INT
) (value
+ 0x8000) < 0x10000;
1686 /* A shifted signed 16 bit constant appropriate for LDAH. */
1687 return ((value
& 0xffff) == 0
1688 && ((value
) >> 31 == -1 || value
>> 31 == 0));
1690 /* A constant that can be AND'ed with using a ZAP insn. */
1691 return zap_mask (value
);
1693 /* A complemented unsigned 8 bit constant. */
1694 return (unsigned HOST_WIDE_INT
) (~ value
) < 0x100;
1696 /* A negated unsigned 8 bit constant. */
1697 return (unsigned HOST_WIDE_INT
) (- value
) < 0x100;
1699 /* The constant 1, 2 or 3. */
1700 return value
== 1 || value
== 2 || value
== 3;
1707 /* Implements CONST_DOUBLE_OK_FOR_LETTER_P. Return true if VALUE
1708 matches for C in [GH]. */
1711 alpha_const_double_ok_for_letter_p (value
, c
)
1718 /* The floating point zero constant. */
1719 return (GET_MODE_CLASS (GET_MODE (value
)) == MODE_FLOAT
1720 && value
== CONST0_RTX (GET_MODE (value
)));
1723 /* A valid operand of a ZAP insn. */
1724 return (GET_MODE (value
) == VOIDmode
1725 && zap_mask (CONST_DOUBLE_LOW (value
))
1726 && zap_mask (CONST_DOUBLE_HIGH (value
)));
1733 /* Implements CONST_DOUBLE_OK_FOR_LETTER_P. Return true if VALUE
1737 alpha_extra_constraint (value
, c
)
1744 return normal_memory_operand (value
, VOIDmode
);
1746 return direct_call_operand (value
, Pmode
);
1748 return (GET_CODE (value
) == CONST_INT
1749 && (unsigned HOST_WIDE_INT
) INTVAL (value
) < 64);
1751 return GET_CODE (value
) == HIGH
;
1753 return TARGET_ABI_UNICOSMK
&& symbolic_operand (value
, VOIDmode
);
1755 return (GET_CODE (value
) == CONST_VECTOR
1756 && value
== CONST0_RTX (GET_MODE (value
)));
1762 /* Return 1 if this function can directly return via $26. */
1767 return (! TARGET_ABI_OPEN_VMS
&& ! TARGET_ABI_UNICOSMK
1769 && alpha_sa_size () == 0
1770 && get_frame_size () == 0
1771 && current_function_outgoing_args_size
== 0
1772 && current_function_pretend_args_size
== 0);
1775 /* Return the ADDR_VEC associated with a tablejump insn. */
1778 alpha_tablejump_addr_vec (insn
)
1783 tmp
= JUMP_LABEL (insn
);
1786 tmp
= NEXT_INSN (tmp
);
1789 if (GET_CODE (tmp
) == JUMP_INSN
1790 && GET_CODE (PATTERN (tmp
)) == ADDR_DIFF_VEC
)
1791 return PATTERN (tmp
);
1795 /* Return the label of the predicted edge, or CONST0_RTX if we don't know. */
1798 alpha_tablejump_best_label (insn
)
1801 rtx jump_table
= alpha_tablejump_addr_vec (insn
);
1802 rtx best_label
= NULL_RTX
;
1804 /* ??? Once the CFG doesn't keep getting completely rebuilt, look
1805 there for edge frequency counts from profile data. */
1809 int n_labels
= XVECLEN (jump_table
, 1);
1810 int best_count
= -1;
1813 for (i
= 0; i
< n_labels
; i
++)
1817 for (j
= i
+ 1; j
< n_labels
; j
++)
1818 if (XEXP (XVECEXP (jump_table
, 1, i
), 0)
1819 == XEXP (XVECEXP (jump_table
, 1, j
), 0))
1822 if (count
> best_count
)
1823 best_count
= count
, best_label
= XVECEXP (jump_table
, 1, i
);
1827 return best_label
? best_label
: const0_rtx
;
1830 /* Return the TLS model to use for SYMBOL. */
1832 static enum tls_model
1833 tls_symbolic_operand_type (symbol
)
1838 if (GET_CODE (symbol
) != SYMBOL_REF
)
1840 str
= XSTR (symbol
, 0);
1844 /* ??? Be prepared for -ftls-model=local-dynamic. Perhaps we shouldn't
1845 have separately encoded local-ness. On well, maybe the user will use
1846 attribute visibility next time. At least we don't crash... */
1847 if (str
[1] == 'G' || str
[1] == 'D')
1848 return TLS_MODEL_GLOBAL_DYNAMIC
;
1850 return TLS_MODEL_INITIAL_EXEC
;
1852 else if (str
[0] == '@')
1856 /* Local dynamic is a waste if we're not going to combine
1857 the __tls_get_addr calls. So avoid it if not optimizing. */
1859 return TLS_MODEL_LOCAL_DYNAMIC
;
1861 return TLS_MODEL_GLOBAL_DYNAMIC
;
1864 return TLS_MODEL_INITIAL_EXEC
;
1866 return TLS_MODEL_LOCAL_EXEC
;
1873 /* Return true if the function DECL will be placed in the default text
1875 /* ??? Ideally we'd be able to always move from a SYMBOL_REF back to the
1876 decl, as that would allow us to determine if two functions are in the
1877 same section, which is what we really want to know. */
1880 decl_in_text_section (decl
)
1883 return (DECL_SECTION_NAME (decl
) == NULL_TREE
1884 && ! (flag_function_sections
1885 || (targetm
.have_named_sections
1886 && DECL_ONE_ONLY (decl
))));
1889 /* Return true if the function DECL will share the same GP as any
1890 function in the current unit of translation. */
1893 decl_has_samegp (decl
)
1896 /* Functions that are not local can be overridden, and thus may
1897 not share the same gp. */
1898 if (!(*targetm
.binds_local_p
) (decl
))
1901 /* If -msmall-data is in effect, assume that there is only one GP
1902 for the module, and so any local symbol has this property. We
1903 need explicit relocations to be able to enforce this for symbols
1904 not defined in this unit of translation, however. */
1905 if (TARGET_EXPLICIT_RELOCS
&& TARGET_SMALL_DATA
)
1908 /* Functions that are not external are defined in this UoT. */
1909 /* ??? Irritatingly, static functions not yet emitted are still
1910 marked "external". Apply this to non-static functions only. */
1911 return !TREE_PUBLIC (decl
) || !DECL_EXTERNAL (decl
);
1914 /* Return true if EXP should be placed in the small data section. */
1917 alpha_in_small_data_p (exp
)
1920 /* We want to merge strings, so we never consider them small data. */
1921 if (TREE_CODE (exp
) == STRING_CST
)
1924 if (TREE_CODE (exp
) == VAR_DECL
&& DECL_SECTION_NAME (exp
))
1926 const char *section
= TREE_STRING_POINTER (DECL_SECTION_NAME (exp
));
1927 if (strcmp (section
, ".sdata") == 0
1928 || strcmp (section
, ".sbss") == 0)
1933 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (exp
));
1935 /* If this is an incomplete type with size 0, then we can't put it
1936 in sdata because it might be too big when completed. */
1937 if (size
> 0 && size
<= g_switch_value
)
1944 /* If we are referencing a function that is static, make the SYMBOL_REF
1945 special. We use this to see indicate we can branch to this function
1946 without setting PV or restoring GP.
1948 If this is a variable that is known to be defined locally, add "@v"
1949 to the name. If in addition the variable is to go in .sdata/.sbss,
1950 then add "@s" instead. */
1953 alpha_encode_section_info (decl
, first
)
1955 int first ATTRIBUTE_UNUSED
;
1957 const char *symbol_str
;
1962 rtl
= DECL_P (decl
) ? DECL_RTL (decl
) : TREE_CST_RTL (decl
);
1964 /* Careful not to prod global register variables. */
1965 if (GET_CODE (rtl
) != MEM
)
1967 symbol
= XEXP (rtl
, 0);
1968 if (GET_CODE (symbol
) != SYMBOL_REF
)
1971 /* A variable is considered "local" if it is defined in this module. */
1972 is_local
= (*targetm
.binds_local_p
) (decl
);
1974 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1976 /* Mark whether the decl is "near" in distance. If -msmall-text is
1977 in effect, this is trivially true of all local symbols. */
1978 if (TARGET_SMALL_TEXT
)
1985 /* Otherwise, a decl is "near" if it is defined in this same
1986 section. What we really need is to be able to access the
1987 target decl of a call from the call_insn pattern, so that
1988 we can determine if the call is from the same section. We
1989 can't do that at present, so handle the common case and
1990 match up .text with .text.
1992 Delay marking public functions until they are emitted; otherwise
1993 we don't know that they exist in this unit of translation. */
1994 if (!TREE_PUBLIC (decl
) && decl_in_text_section (decl
))
1998 /* Indicate whether the target function shares the same GP as any
1999 function emitted in this unit of translation. */
2000 if (decl_has_samegp (decl
))
2001 SYMBOL_REF_FLAG (symbol
) = 1;
2005 /* Early out if we're not going to do anything with this data. */
2006 if (! TARGET_EXPLICIT_RELOCS
)
2009 symbol_str
= XSTR (symbol
, 0);
2011 /* Care for TLS variables. */
2012 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_THREAD_LOCAL (decl
))
2014 switch (decl_tls_model (decl
))
2016 case TLS_MODEL_GLOBAL_DYNAMIC
:
2019 case TLS_MODEL_LOCAL_DYNAMIC
:
2022 case TLS_MODEL_INITIAL_EXEC
:
2025 case TLS_MODEL_LOCAL_EXEC
:
2026 encoding
= (alpha_tls_size
== 64 ? 'T' : 't');
2032 /* Determine if DECL will wind up in .sdata/.sbss. */
2033 if (alpha_in_small_data_p (decl
))
2039 /* Finally, encode this into the symbol string. */
2044 char want_prefix
= (is_local
? '@' : '%');
2045 char other_prefix
= (is_local
? '%' : '@');
2047 if (symbol_str
[0] == want_prefix
)
2049 if (symbol_str
[1] == encoding
)
2053 else if (symbol_str
[0] == other_prefix
)
2056 len
= strlen (symbol_str
) + 1;
2057 newstr
= alloca (len
+ 2);
2059 newstr
[0] = want_prefix
;
2060 newstr
[1] = encoding
;
2061 memcpy (newstr
+ 2, symbol_str
, len
);
2063 XSTR (symbol
, 0) = ggc_alloc_string (newstr
, len
+ 2 - 1);
2067 /* Undo the effects of the above. */
2070 alpha_strip_name_encoding (str
)
2073 if (str
[0] == '@' || str
[0] == '%')
2080 #if TARGET_ABI_OPEN_VMS
2082 alpha_linkage_symbol_p (symname
)
2083 const char *symname
;
2085 int symlen
= strlen (symname
);
2088 return strcmp (&symname
[symlen
- 4], "..lk") == 0;
2093 #define LINKAGE_SYMBOL_REF_P(X) \
2094 ((GET_CODE (X) == SYMBOL_REF \
2095 && alpha_linkage_symbol_p (XSTR (X, 0))) \
2096 || (GET_CODE (X) == CONST \
2097 && GET_CODE (XEXP (X, 0)) == PLUS \
2098 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF \
2099 && alpha_linkage_symbol_p (XSTR (XEXP (XEXP (X, 0), 0), 0))))
2102 /* legitimate_address_p recognizes an RTL expression that is a valid
2103 memory address for an instruction. The MODE argument is the
2104 machine mode for the MEM expression that wants to use this address.
2106 For Alpha, we have either a constant address or the sum of a
2107 register and a constant address, or just a register. For DImode,
2108 any of those forms can be surrounded with an AND that clear the
2109 low-order three bits; this is an "unaligned" access. */
2112 alpha_legitimate_address_p (mode
, x
, strict
)
2113 enum machine_mode mode
;
2117 /* If this is an ldq_u type address, discard the outer AND. */
2119 && GET_CODE (x
) == AND
2120 && GET_CODE (XEXP (x
, 1)) == CONST_INT
2121 && INTVAL (XEXP (x
, 1)) == -8)
2124 /* Discard non-paradoxical subregs. */
2125 if (GET_CODE (x
) == SUBREG
2126 && (GET_MODE_SIZE (GET_MODE (x
))
2127 < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
2130 /* Unadorned general registers are valid. */
2133 ? STRICT_REG_OK_FOR_BASE_P (x
)
2134 : NONSTRICT_REG_OK_FOR_BASE_P (x
)))
2137 /* Constant addresses (i.e. +/- 32k) are valid. */
2138 if (CONSTANT_ADDRESS_P (x
))
2141 #if TARGET_ABI_OPEN_VMS
2142 if (LINKAGE_SYMBOL_REF_P (x
))
2146 /* Register plus a small constant offset is valid. */
2147 if (GET_CODE (x
) == PLUS
)
2149 rtx ofs
= XEXP (x
, 1);
2152 /* Discard non-paradoxical subregs. */
2153 if (GET_CODE (x
) == SUBREG
2154 && (GET_MODE_SIZE (GET_MODE (x
))
2155 < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
2161 && NONSTRICT_REG_OK_FP_BASE_P (x
)
2162 && GET_CODE (ofs
) == CONST_INT
)
2165 ? STRICT_REG_OK_FOR_BASE_P (x
)
2166 : NONSTRICT_REG_OK_FOR_BASE_P (x
))
2167 && CONSTANT_ADDRESS_P (ofs
))
2170 else if (GET_CODE (x
) == ADDRESSOF
2171 && GET_CODE (ofs
) == CONST_INT
)
2175 /* If we're managing explicit relocations, LO_SUM is valid, as
2176 are small data symbols. */
2177 else if (TARGET_EXPLICIT_RELOCS
)
2179 if (small_symbolic_operand (x
, Pmode
))
2182 if (GET_CODE (x
) == LO_SUM
)
2184 rtx ofs
= XEXP (x
, 1);
2187 /* Discard non-paradoxical subregs. */
2188 if (GET_CODE (x
) == SUBREG
2189 && (GET_MODE_SIZE (GET_MODE (x
))
2190 < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
2193 /* Must have a valid base register. */
2196 ? STRICT_REG_OK_FOR_BASE_P (x
)
2197 : NONSTRICT_REG_OK_FOR_BASE_P (x
))))
2200 /* The symbol must be local. */
2201 if (local_symbolic_operand (ofs
, Pmode
)
2202 || dtp32_symbolic_operand (ofs
, Pmode
)
2203 || tp32_symbolic_operand (ofs
, Pmode
))
2211 /* Try machine-dependent ways of modifying an illegitimate address
2212 to be legitimate. If we find one, return the new, valid address. */
2215 alpha_legitimize_address (x
, scratch
, mode
)
2218 enum machine_mode mode ATTRIBUTE_UNUSED
;
2220 HOST_WIDE_INT addend
;
2222 /* If the address is (plus reg const_int) and the CONST_INT is not a
2223 valid offset, compute the high part of the constant and add it to
2224 the register. Then our address is (plus temp low-part-const). */
2225 if (GET_CODE (x
) == PLUS
2226 && GET_CODE (XEXP (x
, 0)) == REG
2227 && GET_CODE (XEXP (x
, 1)) == CONST_INT
2228 && ! CONSTANT_ADDRESS_P (XEXP (x
, 1)))
2230 addend
= INTVAL (XEXP (x
, 1));
2235 /* If the address is (const (plus FOO const_int)), find the low-order
2236 part of the CONST_INT. Then load FOO plus any high-order part of the
2237 CONST_INT into a register. Our address is (plus reg low-part-const).
2238 This is done to reduce the number of GOT entries. */
2240 && GET_CODE (x
) == CONST
2241 && GET_CODE (XEXP (x
, 0)) == PLUS
2242 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
)
2244 addend
= INTVAL (XEXP (XEXP (x
, 0), 1));
2245 x
= force_reg (Pmode
, XEXP (XEXP (x
, 0), 0));
2249 /* If we have a (plus reg const), emit the load as in (2), then add
2250 the two registers, and finally generate (plus reg low-part-const) as
2253 && GET_CODE (x
) == PLUS
2254 && GET_CODE (XEXP (x
, 0)) == REG
2255 && GET_CODE (XEXP (x
, 1)) == CONST
2256 && GET_CODE (XEXP (XEXP (x
, 1), 0)) == PLUS
2257 && GET_CODE (XEXP (XEXP (XEXP (x
, 1), 0), 1)) == CONST_INT
)
2259 addend
= INTVAL (XEXP (XEXP (XEXP (x
, 1), 0), 1));
2260 x
= expand_simple_binop (Pmode
, PLUS
, XEXP (x
, 0),
2261 XEXP (XEXP (XEXP (x
, 1), 0), 0),
2262 NULL_RTX
, 1, OPTAB_LIB_WIDEN
);
2266 /* If this is a local symbol, split the address into HIGH/LO_SUM parts. */
2267 if (TARGET_EXPLICIT_RELOCS
&& symbolic_operand (x
, Pmode
))
2269 rtx r0
, r16
, eqv
, tga
, tp
, insn
, dest
, seq
;
2271 switch (tls_symbolic_operand_type (x
))
2273 case TLS_MODEL_GLOBAL_DYNAMIC
:
2276 r0
= gen_rtx_REG (Pmode
, 0);
2277 r16
= gen_rtx_REG (Pmode
, 16);
2278 tga
= gen_rtx_SYMBOL_REF (Pmode
, "__tls_get_addr");
2279 dest
= gen_reg_rtx (Pmode
);
2280 seq
= GEN_INT (alpha_next_sequence_number
++);
2282 emit_insn (gen_movdi_er_tlsgd (r16
, pic_offset_table_rtx
, x
, seq
));
2283 insn
= gen_call_value_osf_tlsgd (r0
, tga
, seq
);
2284 insn
= emit_call_insn (insn
);
2285 CONST_OR_PURE_CALL_P (insn
) = 1;
2286 use_reg (&CALL_INSN_FUNCTION_USAGE (insn
), r16
);
2288 insn
= get_insns ();
2291 emit_libcall_block (insn
, dest
, r0
, x
);
2294 case TLS_MODEL_LOCAL_DYNAMIC
:
2297 r0
= gen_rtx_REG (Pmode
, 0);
2298 r16
= gen_rtx_REG (Pmode
, 16);
2299 tga
= gen_rtx_SYMBOL_REF (Pmode
, "__tls_get_addr");
2300 scratch
= gen_reg_rtx (Pmode
);
2301 seq
= GEN_INT (alpha_next_sequence_number
++);
2303 emit_insn (gen_movdi_er_tlsldm (r16
, pic_offset_table_rtx
, seq
));
2304 insn
= gen_call_value_osf_tlsldm (r0
, tga
, seq
);
2305 insn
= emit_call_insn (insn
);
2306 CONST_OR_PURE_CALL_P (insn
) = 1;
2307 use_reg (&CALL_INSN_FUNCTION_USAGE (insn
), r16
);
2309 insn
= get_insns ();
2312 eqv
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, const0_rtx
),
2313 UNSPEC_TLSLDM_CALL
);
2314 emit_libcall_block (insn
, scratch
, r0
, eqv
);
2316 eqv
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
), UNSPEC_DTPREL
);
2317 eqv
= gen_rtx_CONST (Pmode
, eqv
);
2319 if (alpha_tls_size
== 64)
2321 dest
= gen_reg_rtx (Pmode
);
2322 emit_insn (gen_rtx_SET (VOIDmode
, dest
, eqv
));
2323 emit_insn (gen_adddi3 (dest
, dest
, scratch
));
2326 if (alpha_tls_size
== 32)
2328 insn
= gen_rtx_HIGH (Pmode
, eqv
);
2329 insn
= gen_rtx_PLUS (Pmode
, scratch
, insn
);
2330 scratch
= gen_reg_rtx (Pmode
);
2331 emit_insn (gen_rtx_SET (VOIDmode
, scratch
, insn
));
2333 return gen_rtx_LO_SUM (Pmode
, scratch
, eqv
);
2335 case TLS_MODEL_INITIAL_EXEC
:
2336 eqv
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
), UNSPEC_TPREL
);
2337 eqv
= gen_rtx_CONST (Pmode
, eqv
);
2338 tp
= gen_reg_rtx (Pmode
);
2339 scratch
= gen_reg_rtx (Pmode
);
2340 dest
= gen_reg_rtx (Pmode
);
2342 emit_insn (gen_load_tp (tp
));
2343 emit_insn (gen_rtx_SET (VOIDmode
, scratch
, eqv
));
2344 emit_insn (gen_adddi3 (dest
, tp
, scratch
));
2347 case TLS_MODEL_LOCAL_EXEC
:
2348 eqv
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
), UNSPEC_TPREL
);
2349 eqv
= gen_rtx_CONST (Pmode
, eqv
);
2350 tp
= gen_reg_rtx (Pmode
);
2352 emit_insn (gen_load_tp (tp
));
2353 if (alpha_tls_size
== 32)
2355 insn
= gen_rtx_HIGH (Pmode
, eqv
);
2356 insn
= gen_rtx_PLUS (Pmode
, tp
, insn
);
2357 tp
= gen_reg_rtx (Pmode
);
2358 emit_insn (gen_rtx_SET (VOIDmode
, tp
, insn
));
2360 return gen_rtx_LO_SUM (Pmode
, tp
, eqv
);
2363 if (local_symbolic_operand (x
, Pmode
))
2365 if (small_symbolic_operand (x
, Pmode
))
2369 if (!no_new_pseudos
)
2370 scratch
= gen_reg_rtx (Pmode
);
2371 emit_insn (gen_rtx_SET (VOIDmode
, scratch
,
2372 gen_rtx_HIGH (Pmode
, x
)));
2373 return gen_rtx_LO_SUM (Pmode
, scratch
, x
);
2382 HOST_WIDE_INT low
, high
;
2384 low
= ((addend
& 0xffff) ^ 0x8000) - 0x8000;
2386 high
= ((addend
& 0xffffffff) ^ 0x80000000) - 0x80000000;
2390 x
= expand_simple_binop (Pmode
, PLUS
, x
, GEN_INT (addend
),
2391 (no_new_pseudos
? scratch
: NULL_RTX
),
2392 1, OPTAB_LIB_WIDEN
);
2394 x
= expand_simple_binop (Pmode
, PLUS
, x
, GEN_INT (high
),
2395 (no_new_pseudos
? scratch
: NULL_RTX
),
2396 1, OPTAB_LIB_WIDEN
);
2398 return plus_constant (x
, low
);
2402 /* We do not allow indirect calls to be optimized into sibling calls, nor
2403 can we allow a call to a function with a different GP to be optimized
2407 alpha_function_ok_for_sibcall (decl
, exp
)
2409 tree exp ATTRIBUTE_UNUSED
;
2411 /* Can't do indirect tail calls, since we don't know if the target
2412 uses the same GP. */
2416 /* Otherwise, we can make a tail call if the target function shares
2418 return decl_has_samegp (decl
);
2421 /* For TARGET_EXPLICIT_RELOCS, we don't obfuscate a SYMBOL_REF to a
2422 small symbolic operand until after reload. At which point we need
2423 to replace (mem (symbol_ref)) with (mem (lo_sum $29 symbol_ref))
2424 so that sched2 has the proper dependency information. */
2427 some_small_symbolic_operand (x
, mode
)
2429 enum machine_mode mode ATTRIBUTE_UNUSED
;
2431 return for_each_rtx (&x
, some_small_symbolic_operand_1
, NULL
);
2435 some_small_symbolic_operand_1 (px
, data
)
2437 void *data ATTRIBUTE_UNUSED
;
2441 /* Don't re-split. */
2442 if (GET_CODE (x
) == LO_SUM
)
2445 return small_symbolic_operand (x
, Pmode
) != 0;
2449 split_small_symbolic_operand (x
)
2453 for_each_rtx (&x
, split_small_symbolic_operand_1
, NULL
);
2458 split_small_symbolic_operand_1 (px
, data
)
2460 void *data ATTRIBUTE_UNUSED
;
2464 /* Don't re-split. */
2465 if (GET_CODE (x
) == LO_SUM
)
2468 if (small_symbolic_operand (x
, Pmode
))
2470 x
= gen_rtx_LO_SUM (Pmode
, pic_offset_table_rtx
, x
);
2478 /* Indicate that INSN cannot be duplicated. This is true for any insn
2479 that we've marked with gpdisp relocs, since those have to stay in
2480 1-1 correspondence with one another.
2482 Techinically we could copy them if we could set up a mapping from one
2483 sequence number to another, across the set of insns to be duplicated.
2484 This seems overly complicated and error-prone since interblock motion
2485 from sched-ebb could move one of the pair of insns to a different block. */
2488 alpha_cannot_copy_insn_p (insn
)
2493 if (!reload_completed
|| !TARGET_EXPLICIT_RELOCS
)
2496 if (GET_CODE (insn
) != INSN
)
2498 if (asm_noperands (insn
) >= 0)
2501 pat
= PATTERN (insn
);
2502 if (GET_CODE (pat
) != SET
)
2504 pat
= SET_SRC (pat
);
2505 if (GET_CODE (pat
) == UNSPEC_VOLATILE
)
2507 if (XINT (pat
, 1) == UNSPECV_LDGP1
2508 || XINT (pat
, 1) == UNSPECV_PLDGP2
)
2511 else if (GET_CODE (pat
) == UNSPEC
)
2513 if (XINT (pat
, 1) == UNSPEC_LDGP2
)
2521 /* Try a machine-dependent way of reloading an illegitimate address
2522 operand. If we find one, push the reload and return the new rtx. */
2525 alpha_legitimize_reload_address (x
, mode
, opnum
, type
, ind_levels
)
2527 enum machine_mode mode ATTRIBUTE_UNUSED
;
2530 int ind_levels ATTRIBUTE_UNUSED
;
2532 /* We must recognize output that we have already generated ourselves. */
2533 if (GET_CODE (x
) == PLUS
2534 && GET_CODE (XEXP (x
, 0)) == PLUS
2535 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == REG
2536 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
2537 && GET_CODE (XEXP (x
, 1)) == CONST_INT
)
2539 push_reload (XEXP (x
, 0), NULL_RTX
, &XEXP (x
, 0), NULL
,
2540 BASE_REG_CLASS
, GET_MODE (x
), VOIDmode
, 0, 0,
2545 /* We wish to handle large displacements off a base register by
2546 splitting the addend across an ldah and the mem insn. This
2547 cuts number of extra insns needed from 3 to 1. */
2548 if (GET_CODE (x
) == PLUS
2549 && GET_CODE (XEXP (x
, 0)) == REG
2550 && REGNO (XEXP (x
, 0)) < FIRST_PSEUDO_REGISTER
2551 && REGNO_OK_FOR_BASE_P (REGNO (XEXP (x
, 0)))
2552 && GET_CODE (XEXP (x
, 1)) == CONST_INT
)
2554 HOST_WIDE_INT val
= INTVAL (XEXP (x
, 1));
2555 HOST_WIDE_INT low
= ((val
& 0xffff) ^ 0x8000) - 0x8000;
2557 = (((val
- low
) & 0xffffffff) ^ 0x80000000) - 0x80000000;
2559 /* Check for 32-bit overflow. */
2560 if (high
+ low
!= val
)
2563 /* Reload the high part into a base reg; leave the low part
2564 in the mem directly. */
2565 x
= gen_rtx_PLUS (GET_MODE (x
),
2566 gen_rtx_PLUS (GET_MODE (x
), XEXP (x
, 0),
2570 push_reload (XEXP (x
, 0), NULL_RTX
, &XEXP (x
, 0), NULL
,
2571 BASE_REG_CLASS
, GET_MODE (x
), VOIDmode
, 0, 0,
2579 /* Compute a (partial) cost for rtx X. Return true if the complete
2580 cost has been computed, and false if subexpressions should be
2581 scanned. In either case, *TOTAL contains the cost result. */
2584 alpha_rtx_costs (x
, code
, outer_code
, total
)
2586 int code
, outer_code
;
2589 enum machine_mode mode
= GET_MODE (x
);
2590 bool float_mode_p
= FLOAT_MODE_P (mode
);
2594 /* If this is an 8-bit constant, return zero since it can be used
2595 nearly anywhere with no cost. If it is a valid operand for an
2596 ADD or AND, likewise return 0 if we know it will be used in that
2597 context. Otherwise, return 2 since it might be used there later.
2598 All other constants take at least two insns. */
2600 if (INTVAL (x
) >= 0 && INTVAL (x
) < 256)
2608 if (x
== CONST0_RTX (mode
))
2610 else if ((outer_code
== PLUS
&& add_operand (x
, VOIDmode
))
2611 || (outer_code
== AND
&& and_operand (x
, VOIDmode
)))
2613 else if (add_operand (x
, VOIDmode
) || and_operand (x
, VOIDmode
))
2616 *total
= COSTS_N_INSNS (2);
2622 if (TARGET_EXPLICIT_RELOCS
&& small_symbolic_operand (x
, VOIDmode
))
2623 *total
= COSTS_N_INSNS (outer_code
!= MEM
);
2624 else if (TARGET_EXPLICIT_RELOCS
&& local_symbolic_operand (x
, VOIDmode
))
2625 *total
= COSTS_N_INSNS (1 + (outer_code
!= MEM
));
2626 else if (tls_symbolic_operand_type (x
))
2627 /* Estimate of cost for call_pal rduniq. */
2628 *total
= COSTS_N_INSNS (15);
2630 /* Otherwise we do a load from the GOT. */
2631 *total
= COSTS_N_INSNS (alpha_memory_latency
);
2637 *total
= alpha_rtx_cost_data
[alpha_cpu
].fp_add
;
2638 else if (GET_CODE (XEXP (x
, 0)) == MULT
2639 && const48_operand (XEXP (XEXP (x
, 0), 1), VOIDmode
))
2641 *total
= (rtx_cost (XEXP (XEXP (x
, 0), 0), outer_code
)
2642 + rtx_cost (XEXP (x
, 1), outer_code
) + 2);
2649 *total
= alpha_rtx_cost_data
[alpha_cpu
].fp_mult
;
2650 else if (mode
== DImode
)
2651 *total
= alpha_rtx_cost_data
[alpha_cpu
].int_mult_di
;
2653 *total
= alpha_rtx_cost_data
[alpha_cpu
].int_mult_si
;
2657 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
2658 && INTVAL (XEXP (x
, 1)) <= 3)
2660 *total
= COSTS_N_INSNS (1);
2667 *total
= alpha_rtx_cost_data
[alpha_cpu
].int_shift
;
2672 *total
= alpha_rtx_cost_data
[alpha_cpu
].fp_add
;
2674 *total
= alpha_rtx_cost_data
[alpha_cpu
].int_cmov
;
2682 *total
= COSTS_N_INSNS (70); /* ??? */
2683 else if (mode
== SFmode
)
2684 *total
= alpha_rtx_cost_data
[alpha_cpu
].fp_div_sf
;
2686 *total
= alpha_rtx_cost_data
[alpha_cpu
].fp_div_df
;
2690 *total
= COSTS_N_INSNS (alpha_memory_latency
);
2696 *total
= COSTS_N_INSNS (1);
2704 *total
= COSTS_N_INSNS (1) + alpha_rtx_cost_data
[alpha_cpu
].int_cmov
;
2710 case UNSIGNED_FLOAT
:
2714 case FLOAT_TRUNCATE
:
2715 *total
= alpha_rtx_cost_data
[alpha_cpu
].fp_add
;
2723 /* REF is an alignable memory location. Place an aligned SImode
2724 reference into *PALIGNED_MEM and the number of bits to shift into
2725 *PBITNUM. SCRATCH is a free register for use in reloading out
2726 of range stack slots. */
2729 get_aligned_mem (ref
, paligned_mem
, pbitnum
)
2731 rtx
*paligned_mem
, *pbitnum
;
2734 HOST_WIDE_INT offset
= 0;
2736 if (GET_CODE (ref
) != MEM
)
2739 if (reload_in_progress
2740 && ! memory_address_p (GET_MODE (ref
), XEXP (ref
, 0)))
2742 base
= find_replacement (&XEXP (ref
, 0));
2744 if (! memory_address_p (GET_MODE (ref
), base
))
2749 base
= XEXP (ref
, 0);
2752 if (GET_CODE (base
) == PLUS
)
2753 offset
+= INTVAL (XEXP (base
, 1)), base
= XEXP (base
, 0);
2756 = widen_memory_access (ref
, SImode
, (offset
& ~3) - offset
);
2758 if (WORDS_BIG_ENDIAN
)
2759 *pbitnum
= GEN_INT (32 - (GET_MODE_BITSIZE (GET_MODE (ref
))
2760 + (offset
& 3) * 8));
2762 *pbitnum
= GEN_INT ((offset
& 3) * 8);
2765 /* Similar, but just get the address. Handle the two reload cases.
2766 Add EXTRA_OFFSET to the address we return. */
2769 get_unaligned_address (ref
, extra_offset
)
2774 HOST_WIDE_INT offset
= 0;
2776 if (GET_CODE (ref
) != MEM
)
2779 if (reload_in_progress
2780 && ! memory_address_p (GET_MODE (ref
), XEXP (ref
, 0)))
2782 base
= find_replacement (&XEXP (ref
, 0));
2784 if (! memory_address_p (GET_MODE (ref
), base
))
2789 base
= XEXP (ref
, 0);
2792 if (GET_CODE (base
) == PLUS
)
2793 offset
+= INTVAL (XEXP (base
, 1)), base
= XEXP (base
, 0);
2795 return plus_constant (base
, offset
+ extra_offset
);
2798 /* On the Alpha, all (non-symbolic) constants except zero go into
2799 a floating-point register via memory. Note that we cannot
2800 return anything that is not a subset of CLASS, and that some
2801 symbolic constants cannot be dropped to memory. */
2804 alpha_preferred_reload_class(x
, class)
2806 enum reg_class
class;
2808 /* Zero is present in any register class. */
2809 if (x
== CONST0_RTX (GET_MODE (x
)))
2812 /* These sorts of constants we can easily drop to memory. */
2813 if (GET_CODE (x
) == CONST_INT
|| GET_CODE (x
) == CONST_DOUBLE
)
2815 if (class == FLOAT_REGS
)
2817 if (class == ALL_REGS
)
2818 return GENERAL_REGS
;
2822 /* All other kinds of constants should not (and in the case of HIGH
2823 cannot) be dropped to memory -- instead we use a GENERAL_REGS
2824 secondary reload. */
2826 return (class == ALL_REGS
? GENERAL_REGS
: class);
2831 /* Loading and storing HImode or QImode values to and from memory
2832 usually requires a scratch register. The exceptions are loading
2833 QImode and HImode from an aligned address to a general register
2834 unless byte instructions are permitted.
2836 We also cannot load an unaligned address or a paradoxical SUBREG
2837 into an FP register.
2839 We also cannot do integral arithmetic into FP regs, as might result
2840 from register elimination into a DImode fp register. */
2843 secondary_reload_class (class, mode
, x
, in
)
2844 enum reg_class
class;
2845 enum machine_mode mode
;
2849 if ((mode
== QImode
|| mode
== HImode
) && ! TARGET_BWX
)
2851 if (GET_CODE (x
) == MEM
2852 || (GET_CODE (x
) == REG
&& REGNO (x
) >= FIRST_PSEUDO_REGISTER
)
2853 || (GET_CODE (x
) == SUBREG
2854 && (GET_CODE (SUBREG_REG (x
)) == MEM
2855 || (GET_CODE (SUBREG_REG (x
)) == REG
2856 && REGNO (SUBREG_REG (x
)) >= FIRST_PSEUDO_REGISTER
))))
2858 if (!in
|| !aligned_memory_operand(x
, mode
))
2859 return GENERAL_REGS
;
2863 if (class == FLOAT_REGS
)
2865 if (GET_CODE (x
) == MEM
&& GET_CODE (XEXP (x
, 0)) == AND
)
2866 return GENERAL_REGS
;
2868 if (GET_CODE (x
) == SUBREG
2869 && (GET_MODE_SIZE (GET_MODE (x
))
2870 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))))
2871 return GENERAL_REGS
;
2873 if (in
&& INTEGRAL_MODE_P (mode
)
2874 && ! (memory_operand (x
, mode
) || x
== const0_rtx
))
2875 return GENERAL_REGS
;
2881 /* Subfunction of the following function. Update the flags of any MEM
2882 found in part of X. */
2885 alpha_set_memflags_1 (x
, in_struct_p
, volatile_p
, unchanging_p
)
2887 int in_struct_p
, volatile_p
, unchanging_p
;
2891 switch (GET_CODE (x
))
2897 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
2898 alpha_set_memflags_1 (XVECEXP (x
, 0, i
), in_struct_p
, volatile_p
,
2903 alpha_set_memflags_1 (PATTERN (x
), in_struct_p
, volatile_p
,
2908 alpha_set_memflags_1 (SET_DEST (x
), in_struct_p
, volatile_p
,
2910 alpha_set_memflags_1 (SET_SRC (x
), in_struct_p
, volatile_p
,
2915 MEM_IN_STRUCT_P (x
) = in_struct_p
;
2916 MEM_VOLATILE_P (x
) = volatile_p
;
2917 RTX_UNCHANGING_P (x
) = unchanging_p
;
2918 /* Sadly, we cannot use alias sets because the extra aliasing
2919 produced by the AND interferes. Given that two-byte quantities
2920 are the only thing we would be able to differentiate anyway,
2921 there does not seem to be any point in convoluting the early
2922 out of the alias check. */
2930 /* Given INSN, which is an INSN list or the PATTERN of a single insn
2931 generated to perform a memory operation, look for any MEMs in either
2932 a SET_DEST or a SET_SRC and copy the in-struct, unchanging, and
2933 volatile flags from REF into each of the MEMs found. If REF is not
2934 a MEM, don't do anything. */
2937 alpha_set_memflags (insn
, ref
)
2941 int in_struct_p
, volatile_p
, unchanging_p
;
2943 if (GET_CODE (ref
) != MEM
)
2946 in_struct_p
= MEM_IN_STRUCT_P (ref
);
2947 volatile_p
= MEM_VOLATILE_P (ref
);
2948 unchanging_p
= RTX_UNCHANGING_P (ref
);
2950 /* This is only called from alpha.md, after having had something
2951 generated from one of the insn patterns. So if everything is
2952 zero, the pattern is already up-to-date. */
2953 if (! in_struct_p
&& ! volatile_p
&& ! unchanging_p
)
2956 alpha_set_memflags_1 (insn
, in_struct_p
, volatile_p
, unchanging_p
);
2959 /* Try to output insns to set TARGET equal to the constant C if it can be
2960 done in less than N insns. Do all computations in MODE. Returns the place
2961 where the output has been placed if it can be done and the insns have been
2962 emitted. If it would take more than N insns, zero is returned and no
2963 insns and emitted. */
2966 alpha_emit_set_const (target
, mode
, c
, n
)
2968 enum machine_mode mode
;
2973 rtx orig_target
= target
;
2976 /* If we can't make any pseudos, TARGET is an SImode hard register, we
2977 can't load this constant in one insn, do this in DImode. */
2978 if (no_new_pseudos
&& mode
== SImode
2979 && GET_CODE (target
) == REG
&& REGNO (target
) < FIRST_PSEUDO_REGISTER
2980 && (result
= alpha_emit_set_const_1 (target
, mode
, c
, 1)) == 0)
2982 target
= gen_lowpart (DImode
, target
);
2986 /* Try 1 insn, then 2, then up to N. */
2987 for (i
= 1; i
<= n
; i
++)
2989 result
= alpha_emit_set_const_1 (target
, mode
, c
, i
);
2992 rtx insn
= get_last_insn ();
2993 rtx set
= single_set (insn
);
2994 if (! CONSTANT_P (SET_SRC (set
)))
2995 set_unique_reg_note (get_last_insn (), REG_EQUAL
, GEN_INT (c
));
3000 /* Allow for the case where we changed the mode of TARGET. */
3001 if (result
== target
)
3002 result
= orig_target
;
3007 /* Internal routine for the above to check for N or below insns. */
3010 alpha_emit_set_const_1 (target
, mode
, c
, n
)
3012 enum machine_mode mode
;
3018 /* Use a pseudo if highly optimizing and still generating RTL. */
3020 = (flag_expensive_optimizations
&& !no_new_pseudos
? 0 : target
);
3023 /* If this is a sign-extended 32-bit constant, we can do this in at most
3024 three insns, so do it if we have enough insns left. We always have
3025 a sign-extended 32-bit constant when compiling on a narrow machine. */
3027 if (HOST_BITS_PER_WIDE_INT
!= 64
3028 || c
>> 31 == -1 || c
>> 31 == 0)
3030 HOST_WIDE_INT low
= ((c
& 0xffff) ^ 0x8000) - 0x8000;
3031 HOST_WIDE_INT tmp1
= c
- low
;
3032 HOST_WIDE_INT high
= (((tmp1
>> 16) & 0xffff) ^ 0x8000) - 0x8000;
3033 HOST_WIDE_INT extra
= 0;
3035 /* If HIGH will be interpreted as negative but the constant is
3036 positive, we must adjust it to do two ldha insns. */
3038 if ((high
& 0x8000) != 0 && c
>= 0)
3042 high
= ((tmp1
>> 16) & 0xffff) - 2 * ((tmp1
>> 16) & 0x8000);
3045 if (c
== low
|| (low
== 0 && extra
== 0))
3047 /* We used to use copy_to_suggested_reg (GEN_INT (c), target, mode)
3048 but that meant that we can't handle INT_MIN on 32-bit machines
3049 (like NT/Alpha), because we recurse indefinitely through
3050 emit_move_insn to gen_movdi. So instead, since we know exactly
3051 what we want, create it explicitly. */
3054 target
= gen_reg_rtx (mode
);
3055 emit_insn (gen_rtx_SET (VOIDmode
, target
, GEN_INT (c
)));
3058 else if (n
>= 2 + (extra
!= 0))
3060 temp
= copy_to_suggested_reg (GEN_INT (high
<< 16), subtarget
, mode
);
3062 /* As of 2002-02-23, addsi3 is only available when not optimizing.
3063 This means that if we go through expand_binop, we'll try to
3064 generate extensions, etc, which will require new pseudos, which
3065 will fail during some split phases. The SImode add patterns
3066 still exist, but are not named. So build the insns by hand. */
3071 subtarget
= gen_reg_rtx (mode
);
3072 insn
= gen_rtx_PLUS (mode
, temp
, GEN_INT (extra
<< 16));
3073 insn
= gen_rtx_SET (VOIDmode
, subtarget
, insn
);
3079 target
= gen_reg_rtx (mode
);
3080 insn
= gen_rtx_PLUS (mode
, temp
, GEN_INT (low
));
3081 insn
= gen_rtx_SET (VOIDmode
, target
, insn
);
3087 /* If we couldn't do it that way, try some other methods. But if we have
3088 no instructions left, don't bother. Likewise, if this is SImode and
3089 we can't make pseudos, we can't do anything since the expand_binop
3090 and expand_unop calls will widen and try to make pseudos. */
3092 if (n
== 1 || (mode
== SImode
&& no_new_pseudos
))
3095 /* Next, see if we can load a related constant and then shift and possibly
3096 negate it to get the constant we want. Try this once each increasing
3097 numbers of insns. */
3099 for (i
= 1; i
< n
; i
++)
3101 /* First, see if minus some low bits, we've an easy load of
3104 new = ((c
& 0xffff) ^ 0x8000) - 0x8000;
3106 && (temp
= alpha_emit_set_const (subtarget
, mode
, c
- new, i
)) != 0)
3107 return expand_binop (mode
, add_optab
, temp
, GEN_INT (new),
3108 target
, 0, OPTAB_WIDEN
);
3110 /* Next try complementing. */
3111 if ((temp
= alpha_emit_set_const (subtarget
, mode
, ~ c
, i
)) != 0)
3112 return expand_unop (mode
, one_cmpl_optab
, temp
, target
, 0);
3114 /* Next try to form a constant and do a left shift. We can do this
3115 if some low-order bits are zero; the exact_log2 call below tells
3116 us that information. The bits we are shifting out could be any
3117 value, but here we'll just try the 0- and sign-extended forms of
3118 the constant. To try to increase the chance of having the same
3119 constant in more than one insn, start at the highest number of
3120 bits to shift, but try all possibilities in case a ZAPNOT will
3123 if ((bits
= exact_log2 (c
& - c
)) > 0)
3124 for (; bits
> 0; bits
--)
3125 if ((temp
= (alpha_emit_set_const
3126 (subtarget
, mode
, c
>> bits
, i
))) != 0
3127 || ((temp
= (alpha_emit_set_const
3129 ((unsigned HOST_WIDE_INT
) c
) >> bits
, i
)))
3131 return expand_binop (mode
, ashl_optab
, temp
, GEN_INT (bits
),
3132 target
, 0, OPTAB_WIDEN
);
3134 /* Now try high-order zero bits. Here we try the shifted-in bits as
3135 all zero and all ones. Be careful to avoid shifting outside the
3136 mode and to avoid shifting outside the host wide int size. */
3137 /* On narrow hosts, don't shift a 1 into the high bit, since we'll
3138 confuse the recursive call and set all of the high 32 bits. */
3140 if ((bits
= (MIN (HOST_BITS_PER_WIDE_INT
, GET_MODE_SIZE (mode
) * 8)
3141 - floor_log2 (c
) - 1 - (HOST_BITS_PER_WIDE_INT
< 64))) > 0)
3142 for (; bits
> 0; bits
--)
3143 if ((temp
= alpha_emit_set_const (subtarget
, mode
,
3145 || ((temp
= (alpha_emit_set_const
3147 ((c
<< bits
) | (((HOST_WIDE_INT
) 1 << bits
) - 1)),
3150 return expand_binop (mode
, lshr_optab
, temp
, GEN_INT (bits
),
3151 target
, 1, OPTAB_WIDEN
);
3153 /* Now try high-order 1 bits. We get that with a sign-extension.
3154 But one bit isn't enough here. Be careful to avoid shifting outside
3155 the mode and to avoid shifting outside the host wide int size. */
3157 if ((bits
= (MIN (HOST_BITS_PER_WIDE_INT
, GET_MODE_SIZE (mode
) * 8)
3158 - floor_log2 (~ c
) - 2)) > 0)
3159 for (; bits
> 0; bits
--)
3160 if ((temp
= alpha_emit_set_const (subtarget
, mode
,
3162 || ((temp
= (alpha_emit_set_const
3164 ((c
<< bits
) | (((HOST_WIDE_INT
) 1 << bits
) - 1)),
3167 return expand_binop (mode
, ashr_optab
, temp
, GEN_INT (bits
),
3168 target
, 0, OPTAB_WIDEN
);
3171 #if HOST_BITS_PER_WIDE_INT == 64
3172 /* Finally, see if can load a value into the target that is the same as the
3173 constant except that all bytes that are 0 are changed to be 0xff. If we
3174 can, then we can do a ZAPNOT to obtain the desired constant. */
3177 for (i
= 0; i
< 64; i
+= 8)
3178 if ((new & ((HOST_WIDE_INT
) 0xff << i
)) == 0)
3179 new |= (HOST_WIDE_INT
) 0xff << i
;
3181 /* We are only called for SImode and DImode. If this is SImode, ensure that
3182 we are sign extended to a full word. */
3185 new = ((new & 0xffffffff) ^ 0x80000000) - 0x80000000;
3187 if (new != c
&& new != -1
3188 && (temp
= alpha_emit_set_const (subtarget
, mode
, new, n
- 1)) != 0)
3189 return expand_binop (mode
, and_optab
, temp
, GEN_INT (c
| ~ new),
3190 target
, 0, OPTAB_WIDEN
);
3196 /* Having failed to find a 3 insn sequence in alpha_emit_set_const,
3197 fall back to a straight forward decomposition. We do this to avoid
3198 exponential run times encountered when looking for longer sequences
3199 with alpha_emit_set_const. */
3202 alpha_emit_set_long_const (target
, c1
, c2
)
3204 HOST_WIDE_INT c1
, c2
;
3206 HOST_WIDE_INT d1
, d2
, d3
, d4
;
3208 /* Decompose the entire word */
3209 #if HOST_BITS_PER_WIDE_INT >= 64
3210 if (c2
!= -(c1
< 0))
3212 d1
= ((c1
& 0xffff) ^ 0x8000) - 0x8000;
3214 d2
= ((c1
& 0xffffffff) ^ 0x80000000) - 0x80000000;
3215 c1
= (c1
- d2
) >> 32;
3216 d3
= ((c1
& 0xffff) ^ 0x8000) - 0x8000;
3218 d4
= ((c1
& 0xffffffff) ^ 0x80000000) - 0x80000000;
3222 d1
= ((c1
& 0xffff) ^ 0x8000) - 0x8000;
3224 d2
= ((c1
& 0xffffffff) ^ 0x80000000) - 0x80000000;
3228 d3
= ((c2
& 0xffff) ^ 0x8000) - 0x8000;
3230 d4
= ((c2
& 0xffffffff) ^ 0x80000000) - 0x80000000;
3235 /* Construct the high word */
3238 emit_move_insn (target
, GEN_INT (d4
));
3240 emit_move_insn (target
, gen_rtx_PLUS (DImode
, target
, GEN_INT (d3
)));
3243 emit_move_insn (target
, GEN_INT (d3
));
3245 /* Shift it into place */
3246 emit_move_insn (target
, gen_rtx_ASHIFT (DImode
, target
, GEN_INT (32)));
3248 /* Add in the low bits. */
3250 emit_move_insn (target
, gen_rtx_PLUS (DImode
, target
, GEN_INT (d2
)));
3252 emit_move_insn (target
, gen_rtx_PLUS (DImode
, target
, GEN_INT (d1
)));
3257 /* Expand a move instruction; return true if all work is done.
3258 We don't handle non-bwx subword loads here. */
3261 alpha_expand_mov (mode
, operands
)
3262 enum machine_mode mode
;
3265 /* If the output is not a register, the input must be. */
3266 if (GET_CODE (operands
[0]) == MEM
3267 && ! reg_or_0_operand (operands
[1], mode
))
3268 operands
[1] = force_reg (mode
, operands
[1]);
3270 /* Allow legitimize_address to perform some simplifications. */
3271 if (mode
== Pmode
&& symbolic_operand (operands
[1], mode
))
3275 /* With RTL inlining, at -O3, rtl is generated, stored, then actually
3276 compiled at the end of compilation. In the meantime, someone can
3277 re-encode-section-info on some symbol changing it e.g. from global
3278 to local-not-small. If this happens, we'd have emitted a plain
3279 load rather than a high+losum load and not recognize the insn.
3281 So if rtl inlining is in effect, we delay the global/not-global
3282 decision until rest_of_compilation by wrapping it in an
3284 if (TARGET_EXPLICIT_RELOCS
&& flag_inline_functions
3285 && rtx_equal_function_value_matters
3286 && global_symbolic_operand (operands
[1], mode
))
3288 emit_insn (gen_movdi_er_maybe_g (operands
[0], operands
[1]));
3292 tmp
= alpha_legitimize_address (operands
[1], operands
[0], mode
);
3295 if (tmp
== operands
[0])
3302 /* Early out for non-constants and valid constants. */
3303 if (! CONSTANT_P (operands
[1]) || input_operand (operands
[1], mode
))
3306 /* Split large integers. */
3307 if (GET_CODE (operands
[1]) == CONST_INT
3308 || GET_CODE (operands
[1]) == CONST_DOUBLE
)
3310 HOST_WIDE_INT i0
, i1
;
3311 rtx temp
= NULL_RTX
;
3313 if (GET_CODE (operands
[1]) == CONST_INT
)
3315 i0
= INTVAL (operands
[1]);
3318 else if (HOST_BITS_PER_WIDE_INT
>= 64)
3320 i0
= CONST_DOUBLE_LOW (operands
[1]);
3325 i0
= CONST_DOUBLE_LOW (operands
[1]);
3326 i1
= CONST_DOUBLE_HIGH (operands
[1]);
3329 if (HOST_BITS_PER_WIDE_INT
>= 64 || i1
== -(i0
< 0))
3330 temp
= alpha_emit_set_const (operands
[0], mode
, i0
, 3);
3332 if (!temp
&& TARGET_BUILD_CONSTANTS
)
3333 temp
= alpha_emit_set_long_const (operands
[0], i0
, i1
);
3337 if (rtx_equal_p (operands
[0], temp
))
3344 /* Otherwise we've nothing left but to drop the thing to memory. */
3345 operands
[1] = force_const_mem (mode
, operands
[1]);
3346 if (reload_in_progress
)
3348 emit_move_insn (operands
[0], XEXP (operands
[1], 0));
3349 operands
[1] = copy_rtx (operands
[1]);
3350 XEXP (operands
[1], 0) = operands
[0];
3353 operands
[1] = validize_mem (operands
[1]);
3357 /* Expand a non-bwx QImode or HImode move instruction;
3358 return true if all work is done. */
3361 alpha_expand_mov_nobwx (mode
, operands
)
3362 enum machine_mode mode
;
3365 /* If the output is not a register, the input must be. */
3366 if (GET_CODE (operands
[0]) == MEM
)
3367 operands
[1] = force_reg (mode
, operands
[1]);
3369 /* Handle four memory cases, unaligned and aligned for either the input
3370 or the output. The only case where we can be called during reload is
3371 for aligned loads; all other cases require temporaries. */
3373 if (GET_CODE (operands
[1]) == MEM
3374 || (GET_CODE (operands
[1]) == SUBREG
3375 && GET_CODE (SUBREG_REG (operands
[1])) == MEM
)
3376 || (reload_in_progress
&& GET_CODE (operands
[1]) == REG
3377 && REGNO (operands
[1]) >= FIRST_PSEUDO_REGISTER
)
3378 || (reload_in_progress
&& GET_CODE (operands
[1]) == SUBREG
3379 && GET_CODE (SUBREG_REG (operands
[1])) == REG
3380 && REGNO (SUBREG_REG (operands
[1])) >= FIRST_PSEUDO_REGISTER
))
3382 if (aligned_memory_operand (operands
[1], mode
))
3384 if (reload_in_progress
)
3386 emit_insn ((mode
== QImode
3387 ? gen_reload_inqi_help
3388 : gen_reload_inhi_help
)
3389 (operands
[0], operands
[1],
3390 gen_rtx_REG (SImode
, REGNO (operands
[0]))));
3394 rtx aligned_mem
, bitnum
;
3395 rtx scratch
= gen_reg_rtx (SImode
);
3397 get_aligned_mem (operands
[1], &aligned_mem
, &bitnum
);
3399 emit_insn ((mode
== QImode
3400 ? gen_aligned_loadqi
3401 : gen_aligned_loadhi
)
3402 (operands
[0], aligned_mem
, bitnum
, scratch
));
3407 /* Don't pass these as parameters since that makes the generated
3408 code depend on parameter evaluation order which will cause
3409 bootstrap failures. */
3411 rtx temp1
= gen_reg_rtx (DImode
);
3412 rtx temp2
= gen_reg_rtx (DImode
);
3413 rtx seq
= ((mode
== QImode
3414 ? gen_unaligned_loadqi
3415 : gen_unaligned_loadhi
)
3416 (operands
[0], get_unaligned_address (operands
[1], 0),
3419 alpha_set_memflags (seq
, operands
[1]);
3425 if (GET_CODE (operands
[0]) == MEM
3426 || (GET_CODE (operands
[0]) == SUBREG
3427 && GET_CODE (SUBREG_REG (operands
[0])) == MEM
)
3428 || (reload_in_progress
&& GET_CODE (operands
[0]) == REG
3429 && REGNO (operands
[0]) >= FIRST_PSEUDO_REGISTER
)
3430 || (reload_in_progress
&& GET_CODE (operands
[0]) == SUBREG
3431 && GET_CODE (SUBREG_REG (operands
[0])) == REG
3432 && REGNO (operands
[0]) >= FIRST_PSEUDO_REGISTER
))
3434 if (aligned_memory_operand (operands
[0], mode
))
3436 rtx aligned_mem
, bitnum
;
3437 rtx temp1
= gen_reg_rtx (SImode
);
3438 rtx temp2
= gen_reg_rtx (SImode
);
3440 get_aligned_mem (operands
[0], &aligned_mem
, &bitnum
);
3442 emit_insn (gen_aligned_store (aligned_mem
, operands
[1], bitnum
,
3447 rtx temp1
= gen_reg_rtx (DImode
);
3448 rtx temp2
= gen_reg_rtx (DImode
);
3449 rtx temp3
= gen_reg_rtx (DImode
);
3450 rtx seq
= ((mode
== QImode
3451 ? gen_unaligned_storeqi
3452 : gen_unaligned_storehi
)
3453 (get_unaligned_address (operands
[0], 0),
3454 operands
[1], temp1
, temp2
, temp3
));
3456 alpha_set_memflags (seq
, operands
[0]);
3465 /* Generate an unsigned DImode to FP conversion. This is the same code
3466 optabs would emit if we didn't have TFmode patterns.
3468 For SFmode, this is the only construction I've found that can pass
3469 gcc.c-torture/execute/ieee/rbug.c. No scenario that uses DFmode
3470 intermediates will work, because you'll get intermediate rounding
3471 that ruins the end result. Some of this could be fixed by turning
3472 on round-to-positive-infinity, but that requires diddling the fpsr,
3473 which kills performance. I tried turning this around and converting
3474 to a negative number, so that I could turn on /m, but either I did
3475 it wrong or there's something else cause I wound up with the exact
3476 same single-bit error. There is a branch-less form of this same code:
3487 fcmoveq $f10,$f11,$f0
3489 I'm not using it because it's the same number of instructions as
3490 this branch-full form, and it has more serialized long latency
3491 instructions on the critical path.
3493 For DFmode, we can avoid rounding errors by breaking up the word
3494 into two pieces, converting them separately, and adding them back:
3496 LC0: .long 0,0x5f800000
3501 cpyse $f11,$f31,$f10
3502 cpyse $f31,$f11,$f11
3510 This doesn't seem to be a clear-cut win over the optabs form.
3511 It probably all depends on the distribution of numbers being
3512 converted -- in the optabs form, all but high-bit-set has a
3513 much lower minimum execution time. */
3516 alpha_emit_floatuns (operands
)
3519 rtx neglab
, donelab
, i0
, i1
, f0
, in
, out
;
3520 enum machine_mode mode
;
3523 in
= force_reg (DImode
, operands
[1]);
3524 mode
= GET_MODE (out
);
3525 neglab
= gen_label_rtx ();
3526 donelab
= gen_label_rtx ();
3527 i0
= gen_reg_rtx (DImode
);
3528 i1
= gen_reg_rtx (DImode
);
3529 f0
= gen_reg_rtx (mode
);
3531 emit_cmp_and_jump_insns (in
, const0_rtx
, LT
, const0_rtx
, DImode
, 0, neglab
);
3533 emit_insn (gen_rtx_SET (VOIDmode
, out
, gen_rtx_FLOAT (mode
, in
)));
3534 emit_jump_insn (gen_jump (donelab
));
3537 emit_label (neglab
);
3539 emit_insn (gen_lshrdi3 (i0
, in
, const1_rtx
));
3540 emit_insn (gen_anddi3 (i1
, in
, const1_rtx
));
3541 emit_insn (gen_iordi3 (i0
, i0
, i1
));
3542 emit_insn (gen_rtx_SET (VOIDmode
, f0
, gen_rtx_FLOAT (mode
, i0
)));
3543 emit_insn (gen_rtx_SET (VOIDmode
, out
, gen_rtx_PLUS (mode
, f0
, f0
)));
3545 emit_label (donelab
);
3548 /* Generate the comparison for a conditional branch. */
3551 alpha_emit_conditional_branch (code
)
3554 enum rtx_code cmp_code
, branch_code
;
3555 enum machine_mode cmp_mode
, branch_mode
= VOIDmode
;
3556 rtx op0
= alpha_compare
.op0
, op1
= alpha_compare
.op1
;
3559 if (alpha_compare
.fp_p
&& GET_MODE (op0
) == TFmode
)
3561 if (! TARGET_HAS_XFLOATING_LIBS
)
3564 /* X_floating library comparison functions return
3568 Convert the compare against the raw return value. */
3590 op0
= alpha_emit_xfloating_compare (cmp_code
, op0
, op1
);
3592 alpha_compare
.fp_p
= 0;
3595 /* The general case: fold the comparison code to the types of compares
3596 that we have, choosing the branch as necessary. */
3599 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
3601 /* We have these compares: */
3602 cmp_code
= code
, branch_code
= NE
;
3607 /* These must be reversed. */
3608 cmp_code
= reverse_condition (code
), branch_code
= EQ
;
3611 case GE
: case GT
: case GEU
: case GTU
:
3612 /* For FP, we swap them, for INT, we reverse them. */
3613 if (alpha_compare
.fp_p
)
3615 cmp_code
= swap_condition (code
);
3617 tem
= op0
, op0
= op1
, op1
= tem
;
3621 cmp_code
= reverse_condition (code
);
3630 if (alpha_compare
.fp_p
)
3633 if (flag_unsafe_math_optimizations
)
3635 /* When we are not as concerned about non-finite values, and we
3636 are comparing against zero, we can branch directly. */
3637 if (op1
== CONST0_RTX (DFmode
))
3638 cmp_code
= NIL
, branch_code
= code
;
3639 else if (op0
== CONST0_RTX (DFmode
))
3641 /* Undo the swap we probably did just above. */
3642 tem
= op0
, op0
= op1
, op1
= tem
;
3643 branch_code
= swap_condition (cmp_code
);
3649 /* ??? We mark the branch mode to be CCmode to prevent the
3650 compare and branch from being combined, since the compare
3651 insn follows IEEE rules that the branch does not. */
3652 branch_mode
= CCmode
;
3659 /* The following optimizations are only for signed compares. */
3660 if (code
!= LEU
&& code
!= LTU
&& code
!= GEU
&& code
!= GTU
)
3662 /* Whee. Compare and branch against 0 directly. */
3663 if (op1
== const0_rtx
)
3664 cmp_code
= NIL
, branch_code
= code
;
3666 /* We want to use cmpcc/bcc when we can, since there is a zero delay
3667 bypass between logicals and br/cmov on EV5. But we don't want to
3668 force valid immediate constants into registers needlessly. */
3669 else if (GET_CODE (op1
) == CONST_INT
)
3671 HOST_WIDE_INT v
= INTVAL (op1
), n
= -v
;
3673 if (! CONST_OK_FOR_LETTER_P (v
, 'I')
3674 && (CONST_OK_FOR_LETTER_P (n
, 'K')
3675 || CONST_OK_FOR_LETTER_P (n
, 'L')))
3677 cmp_code
= PLUS
, branch_code
= code
;
3683 if (!reg_or_0_operand (op0
, DImode
))
3684 op0
= force_reg (DImode
, op0
);
3685 if (cmp_code
!= PLUS
&& !reg_or_8bit_operand (op1
, DImode
))
3686 op1
= force_reg (DImode
, op1
);
3689 /* Emit an initial compare instruction, if necessary. */
3691 if (cmp_code
!= NIL
)
3693 tem
= gen_reg_rtx (cmp_mode
);
3694 emit_move_insn (tem
, gen_rtx_fmt_ee (cmp_code
, cmp_mode
, op0
, op1
));
3697 /* Zero the operands. */
3698 memset (&alpha_compare
, 0, sizeof (alpha_compare
));
3700 /* Return the branch comparison. */
3701 return gen_rtx_fmt_ee (branch_code
, branch_mode
, tem
, CONST0_RTX (cmp_mode
));
3704 /* Certain simplifications can be done to make invalid setcc operations
3705 valid. Return the final comparison, or NULL if we can't work. */
3708 alpha_emit_setcc (code
)
3711 enum rtx_code cmp_code
;
3712 rtx op0
= alpha_compare
.op0
, op1
= alpha_compare
.op1
;
3713 int fp_p
= alpha_compare
.fp_p
;
3716 /* Zero the operands. */
3717 memset (&alpha_compare
, 0, sizeof (alpha_compare
));
3719 if (fp_p
&& GET_MODE (op0
) == TFmode
)
3721 if (! TARGET_HAS_XFLOATING_LIBS
)
3724 /* X_floating library comparison functions return
3728 Convert the compare against the raw return value. */
3730 if (code
== UNORDERED
|| code
== ORDERED
)
3735 op0
= alpha_emit_xfloating_compare (cmp_code
, op0
, op1
);
3739 if (code
== UNORDERED
)
3741 else if (code
== ORDERED
)
3747 if (fp_p
&& !TARGET_FIX
)
3750 /* The general case: fold the comparison code to the types of compares
3751 that we have, choosing the branch as necessary. */
3756 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
3758 /* We have these compares. */
3760 cmp_code
= code
, code
= NE
;
3764 if (!fp_p
&& op1
== const0_rtx
)
3769 cmp_code
= reverse_condition (code
);
3773 case GE
: case GT
: case GEU
: case GTU
:
3774 /* These normally need swapping, but for integer zero we have
3775 special patterns that recognize swapped operands. */
3776 if (!fp_p
&& op1
== const0_rtx
)
3778 code
= swap_condition (code
);
3780 cmp_code
= code
, code
= NE
;
3781 tmp
= op0
, op0
= op1
, op1
= tmp
;
3790 if (!register_operand (op0
, DImode
))
3791 op0
= force_reg (DImode
, op0
);
3792 if (!reg_or_8bit_operand (op1
, DImode
))
3793 op1
= force_reg (DImode
, op1
);
3796 /* Emit an initial compare instruction, if necessary. */
3797 if (cmp_code
!= NIL
)
3799 enum machine_mode mode
= fp_p
? DFmode
: DImode
;
3801 tmp
= gen_reg_rtx (mode
);
3802 emit_insn (gen_rtx_SET (VOIDmode
, tmp
,
3803 gen_rtx_fmt_ee (cmp_code
, mode
, op0
, op1
)));
3805 op0
= fp_p
? gen_lowpart (DImode
, tmp
) : tmp
;
3809 /* Return the setcc comparison. */
3810 return gen_rtx_fmt_ee (code
, DImode
, op0
, op1
);
3814 /* Rewrite a comparison against zero CMP of the form
3815 (CODE (cc0) (const_int 0)) so it can be written validly in
3816 a conditional move (if_then_else CMP ...).
3817 If both of the operands that set cc0 are nonzero we must emit
3818 an insn to perform the compare (it can't be done within
3819 the conditional move). */
3821 alpha_emit_conditional_move (cmp
, mode
)
3823 enum machine_mode mode
;
3825 enum rtx_code code
= GET_CODE (cmp
);
3826 enum rtx_code cmov_code
= NE
;
3827 rtx op0
= alpha_compare
.op0
;
3828 rtx op1
= alpha_compare
.op1
;
3829 int fp_p
= alpha_compare
.fp_p
;
3830 enum machine_mode cmp_mode
3831 = (GET_MODE (op0
) == VOIDmode
? DImode
: GET_MODE (op0
));
3832 enum machine_mode cmp_op_mode
= fp_p
? DFmode
: DImode
;
3833 enum machine_mode cmov_mode
= VOIDmode
;
3834 int local_fast_math
= flag_unsafe_math_optimizations
;
3837 /* Zero the operands. */
3838 memset (&alpha_compare
, 0, sizeof (alpha_compare
));
3840 if (fp_p
!= FLOAT_MODE_P (mode
))
3842 enum rtx_code cmp_code
;
3847 /* If we have fp<->int register move instructions, do a cmov by
3848 performing the comparison in fp registers, and move the
3849 zero/nonzero value to integer registers, where we can then
3850 use a normal cmov, or vice-versa. */
3854 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
3855 /* We have these compares. */
3856 cmp_code
= code
, code
= NE
;
3860 /* This must be reversed. */
3861 cmp_code
= EQ
, code
= EQ
;
3864 case GE
: case GT
: case GEU
: case GTU
:
3865 /* These normally need swapping, but for integer zero we have
3866 special patterns that recognize swapped operands. */
3867 if (!fp_p
&& op1
== const0_rtx
)
3868 cmp_code
= code
, code
= NE
;
3871 cmp_code
= swap_condition (code
);
3873 tem
= op0
, op0
= op1
, op1
= tem
;
3881 tem
= gen_reg_rtx (cmp_op_mode
);
3882 emit_insn (gen_rtx_SET (VOIDmode
, tem
,
3883 gen_rtx_fmt_ee (cmp_code
, cmp_op_mode
,
3886 cmp_mode
= cmp_op_mode
= fp_p
? DImode
: DFmode
;
3887 op0
= gen_lowpart (cmp_op_mode
, tem
);
3888 op1
= CONST0_RTX (cmp_op_mode
);
3890 local_fast_math
= 1;
3893 /* We may be able to use a conditional move directly.
3894 This avoids emitting spurious compares. */
3895 if (signed_comparison_operator (cmp
, VOIDmode
)
3896 && (!fp_p
|| local_fast_math
)
3897 && (op0
== CONST0_RTX (cmp_mode
) || op1
== CONST0_RTX (cmp_mode
)))
3898 return gen_rtx_fmt_ee (code
, VOIDmode
, op0
, op1
);
3900 /* We can't put the comparison inside the conditional move;
3901 emit a compare instruction and put that inside the
3902 conditional move. Make sure we emit only comparisons we have;
3903 swap or reverse as necessary. */
3910 case EQ
: case LE
: case LT
: case LEU
: case LTU
:
3911 /* We have these compares: */
3915 /* This must be reversed. */
3916 code
= reverse_condition (code
);
3920 case GE
: case GT
: case GEU
: case GTU
:
3921 /* These must be swapped. */
3922 if (op1
!= CONST0_RTX (cmp_mode
))
3924 code
= swap_condition (code
);
3925 tem
= op0
, op0
= op1
, op1
= tem
;
3935 if (!reg_or_0_operand (op0
, DImode
))
3936 op0
= force_reg (DImode
, op0
);
3937 if (!reg_or_8bit_operand (op1
, DImode
))
3938 op1
= force_reg (DImode
, op1
);
3941 /* ??? We mark the branch mode to be CCmode to prevent the compare
3942 and cmov from being combined, since the compare insn follows IEEE
3943 rules that the cmov does not. */
3944 if (fp_p
&& !local_fast_math
)
3947 tem
= gen_reg_rtx (cmp_op_mode
);
3948 emit_move_insn (tem
, gen_rtx_fmt_ee (code
, cmp_op_mode
, op0
, op1
));
3949 return gen_rtx_fmt_ee (cmov_code
, cmov_mode
, tem
, CONST0_RTX (cmp_op_mode
));
3952 /* Simplify a conditional move of two constants into a setcc with
3953 arithmetic. This is done with a splitter since combine would
3954 just undo the work if done during code generation. It also catches
3955 cases we wouldn't have before cse. */
3958 alpha_split_conditional_move (code
, dest
, cond
, t_rtx
, f_rtx
)
3960 rtx dest
, cond
, t_rtx
, f_rtx
;
3962 HOST_WIDE_INT t
, f
, diff
;
3963 enum machine_mode mode
;
3964 rtx target
, subtarget
, tmp
;
3966 mode
= GET_MODE (dest
);
3971 if (((code
== NE
|| code
== EQ
) && diff
< 0)
3972 || (code
== GE
|| code
== GT
))
3974 code
= reverse_condition (code
);
3975 diff
= t
, t
= f
, f
= diff
;
3979 subtarget
= target
= dest
;
3982 target
= gen_lowpart (DImode
, dest
);
3983 if (! no_new_pseudos
)
3984 subtarget
= gen_reg_rtx (DImode
);
3988 /* Below, we must be careful to use copy_rtx on target and subtarget
3989 in intermediate insns, as they may be a subreg rtx, which may not
3992 if (f
== 0 && exact_log2 (diff
) > 0
3993 /* On EV6, we've got enough shifters to make non-arithmatic shifts
3994 viable over a longer latency cmove. On EV5, the E0 slot is a
3995 scarce resource, and on EV4 shift has the same latency as a cmove. */
3996 && (diff
<= 8 || alpha_cpu
== PROCESSOR_EV6
))
3998 tmp
= gen_rtx_fmt_ee (code
, DImode
, cond
, const0_rtx
);
3999 emit_insn (gen_rtx_SET (VOIDmode
, copy_rtx (subtarget
), tmp
));
4001 tmp
= gen_rtx_ASHIFT (DImode
, copy_rtx (subtarget
),
4002 GEN_INT (exact_log2 (t
)));
4003 emit_insn (gen_rtx_SET (VOIDmode
, target
, tmp
));
4005 else if (f
== 0 && t
== -1)
4007 tmp
= gen_rtx_fmt_ee (code
, DImode
, cond
, const0_rtx
);
4008 emit_insn (gen_rtx_SET (VOIDmode
, copy_rtx (subtarget
), tmp
));
4010 emit_insn (gen_negdi2 (target
, copy_rtx (subtarget
)));
4012 else if (diff
== 1 || diff
== 4 || diff
== 8)
4016 tmp
= gen_rtx_fmt_ee (code
, DImode
, cond
, const0_rtx
);
4017 emit_insn (gen_rtx_SET (VOIDmode
, copy_rtx (subtarget
), tmp
));
4020 emit_insn (gen_adddi3 (target
, copy_rtx (subtarget
), GEN_INT (f
)));
4023 add_op
= GEN_INT (f
);
4024 if (sext_add_operand (add_op
, mode
))
4026 tmp
= gen_rtx_MULT (DImode
, copy_rtx (subtarget
),
4028 tmp
= gen_rtx_PLUS (DImode
, tmp
, add_op
);
4029 emit_insn (gen_rtx_SET (VOIDmode
, target
, tmp
));
4041 /* Look up the function X_floating library function name for the
4045 alpha_lookup_xfloating_lib_func (code
)
4050 const enum rtx_code code
;
4051 const char *const func
;
4054 static const struct xfloating_op vms_xfloating_ops
[] =
4056 { PLUS
, "OTS$ADD_X" },
4057 { MINUS
, "OTS$SUB_X" },
4058 { MULT
, "OTS$MUL_X" },
4059 { DIV
, "OTS$DIV_X" },
4060 { EQ
, "OTS$EQL_X" },
4061 { NE
, "OTS$NEQ_X" },
4062 { LT
, "OTS$LSS_X" },
4063 { LE
, "OTS$LEQ_X" },
4064 { GT
, "OTS$GTR_X" },
4065 { GE
, "OTS$GEQ_X" },
4066 { FIX
, "OTS$CVTXQ" },
4067 { FLOAT
, "OTS$CVTQX" },
4068 { UNSIGNED_FLOAT
, "OTS$CVTQUX" },
4069 { FLOAT_EXTEND
, "OTS$CVT_FLOAT_T_X" },
4070 { FLOAT_TRUNCATE
, "OTS$CVT_FLOAT_X_T" },
4073 static const struct xfloating_op osf_xfloating_ops
[] =
4075 { PLUS
, "_OtsAddX" },
4076 { MINUS
, "_OtsSubX" },
4077 { MULT
, "_OtsMulX" },
4078 { DIV
, "_OtsDivX" },
4085 { FIX
, "_OtsCvtXQ" },
4086 { FLOAT
, "_OtsCvtQX" },
4087 { UNSIGNED_FLOAT
, "_OtsCvtQUX" },
4088 { FLOAT_EXTEND
, "_OtsConvertFloatTX" },
4089 { FLOAT_TRUNCATE
, "_OtsConvertFloatXT" },
4092 const struct xfloating_op
*ops
;
4093 const long n
= ARRAY_SIZE (osf_xfloating_ops
);
4096 /* How irritating. Nothing to key off for the table. Hardcode
4097 knowledge of the G_floating routines. */
4098 if (TARGET_FLOAT_VAX
)
4100 if (TARGET_ABI_OPEN_VMS
)
4102 if (code
== FLOAT_EXTEND
)
4103 return "OTS$CVT_FLOAT_G_X";
4104 if (code
== FLOAT_TRUNCATE
)
4105 return "OTS$CVT_FLOAT_X_G";
4109 if (code
== FLOAT_EXTEND
)
4110 return "_OtsConvertFloatGX";
4111 if (code
== FLOAT_TRUNCATE
)
4112 return "_OtsConvertFloatXG";
4116 if (TARGET_ABI_OPEN_VMS
)
4117 ops
= vms_xfloating_ops
;
4119 ops
= osf_xfloating_ops
;
4121 for (i
= 0; i
< n
; ++i
)
4122 if (ops
[i
].code
== code
)
4128 /* Most X_floating operations take the rounding mode as an argument.
4129 Compute that here. */
4132 alpha_compute_xfloating_mode_arg (code
, round
)
4134 enum alpha_fp_rounding_mode round
;
4140 case ALPHA_FPRM_NORM
:
4143 case ALPHA_FPRM_MINF
:
4146 case ALPHA_FPRM_CHOP
:
4149 case ALPHA_FPRM_DYN
:
4155 /* XXX For reference, round to +inf is mode = 3. */
4158 if (code
== FLOAT_TRUNCATE
&& alpha_fptm
== ALPHA_FPTM_N
)
4164 /* Emit an X_floating library function call.
4166 Note that these functions do not follow normal calling conventions:
4167 TFmode arguments are passed in two integer registers (as opposed to
4168 indirect); TFmode return values appear in R16+R17.
4170 FUNC is the function name to call.
4171 TARGET is where the output belongs.
4172 OPERANDS are the inputs.
4173 NOPERANDS is the count of inputs.
4174 EQUIV is the expression equivalent for the function.
4178 alpha_emit_xfloating_libcall (func
, target
, operands
, noperands
, equiv
)
4185 rtx usage
= NULL_RTX
, tmp
, reg
;
4190 for (i
= 0; i
< noperands
; ++i
)
4192 switch (GET_MODE (operands
[i
]))
4195 reg
= gen_rtx_REG (TFmode
, regno
);
4200 reg
= gen_rtx_REG (DFmode
, regno
+ 32);
4205 if (GET_CODE (operands
[i
]) != CONST_INT
)
4209 reg
= gen_rtx_REG (DImode
, regno
);
4217 emit_move_insn (reg
, operands
[i
]);
4218 usage
= alloc_EXPR_LIST (0, gen_rtx_USE (VOIDmode
, reg
), usage
);
4221 switch (GET_MODE (target
))
4224 reg
= gen_rtx_REG (TFmode
, 16);
4227 reg
= gen_rtx_REG (DFmode
, 32);
4230 reg
= gen_rtx_REG (DImode
, 0);
4236 tmp
= gen_rtx_MEM (QImode
, gen_rtx_SYMBOL_REF (Pmode
, (char *) func
));
4237 tmp
= emit_call_insn (GEN_CALL_VALUE (reg
, tmp
, const0_rtx
,
4238 const0_rtx
, const0_rtx
));
4239 CALL_INSN_FUNCTION_USAGE (tmp
) = usage
;
4244 emit_libcall_block (tmp
, target
, reg
, equiv
);
4247 /* Emit an X_floating library function call for arithmetic (+,-,*,/). */
4250 alpha_emit_xfloating_arith (code
, operands
)
4256 rtx out_operands
[3];
4258 func
= alpha_lookup_xfloating_lib_func (code
);
4259 mode
= alpha_compute_xfloating_mode_arg (code
, alpha_fprm
);
4261 out_operands
[0] = operands
[1];
4262 out_operands
[1] = operands
[2];
4263 out_operands
[2] = GEN_INT (mode
);
4264 alpha_emit_xfloating_libcall (func
, operands
[0], out_operands
, 3,
4265 gen_rtx_fmt_ee (code
, TFmode
, operands
[1],
4269 /* Emit an X_floating library function call for a comparison. */
4272 alpha_emit_xfloating_compare (code
, op0
, op1
)
4277 rtx out
, operands
[2];
4279 func
= alpha_lookup_xfloating_lib_func (code
);
4283 out
= gen_reg_rtx (DImode
);
4285 /* ??? Strange mode for equiv because what's actually returned
4286 is -1,0,1, not a proper boolean value. */
4287 alpha_emit_xfloating_libcall (func
, out
, operands
, 2,
4288 gen_rtx_fmt_ee (code
, CCmode
, op0
, op1
));
4293 /* Emit an X_floating library function call for a conversion. */
4296 alpha_emit_xfloating_cvt (code
, operands
)
4300 int noperands
= 1, mode
;
4301 rtx out_operands
[2];
4304 func
= alpha_lookup_xfloating_lib_func (code
);
4306 out_operands
[0] = operands
[1];
4311 mode
= alpha_compute_xfloating_mode_arg (code
, ALPHA_FPRM_CHOP
);
4312 out_operands
[1] = GEN_INT (mode
);
4315 case FLOAT_TRUNCATE
:
4316 mode
= alpha_compute_xfloating_mode_arg (code
, alpha_fprm
);
4317 out_operands
[1] = GEN_INT (mode
);
4324 alpha_emit_xfloating_libcall (func
, operands
[0], out_operands
, noperands
,
4325 gen_rtx_fmt_e (code
, GET_MODE (operands
[0]),
4329 /* Split a TFmode OP[1] into DImode OP[2,3] and likewise for
4330 OP[0] into OP[0,1]. Naturally, output operand ordering is
4334 alpha_split_tfmode_pair (operands
)
4337 if (GET_CODE (operands
[1]) == REG
)
4339 operands
[3] = gen_rtx_REG (DImode
, REGNO (operands
[1]) + 1);
4340 operands
[2] = gen_rtx_REG (DImode
, REGNO (operands
[1]));
4342 else if (GET_CODE (operands
[1]) == MEM
)
4344 operands
[3] = adjust_address (operands
[1], DImode
, 8);
4345 operands
[2] = adjust_address (operands
[1], DImode
, 0);
4347 else if (operands
[1] == CONST0_RTX (TFmode
))
4348 operands
[2] = operands
[3] = const0_rtx
;
4352 if (GET_CODE (operands
[0]) == REG
)
4354 operands
[1] = gen_rtx_REG (DImode
, REGNO (operands
[0]) + 1);
4355 operands
[0] = gen_rtx_REG (DImode
, REGNO (operands
[0]));
4357 else if (GET_CODE (operands
[0]) == MEM
)
4359 operands
[1] = adjust_address (operands
[0], DImode
, 8);
4360 operands
[0] = adjust_address (operands
[0], DImode
, 0);
4366 /* Implement negtf2 or abstf2. Op0 is destination, op1 is source,
4367 op2 is a register containing the sign bit, operation is the
4368 logical operation to be performed. */
4371 alpha_split_tfmode_frobsign (operands
, operation
)
4373 rtx (*operation
) PARAMS ((rtx
, rtx
, rtx
));
4375 rtx high_bit
= operands
[2];
4379 alpha_split_tfmode_pair (operands
);
4381 /* Detect three flavors of operand overlap. */
4383 if (rtx_equal_p (operands
[0], operands
[2]))
4385 else if (rtx_equal_p (operands
[1], operands
[2]))
4387 if (rtx_equal_p (operands
[0], high_bit
))
4394 emit_move_insn (operands
[0], operands
[2]);
4396 /* ??? If the destination overlaps both source tf and high_bit, then
4397 assume source tf is dead in its entirety and use the other half
4398 for a scratch register. Otherwise "scratch" is just the proper
4399 destination register. */
4400 scratch
= operands
[move
< 2 ? 1 : 3];
4402 emit_insn ((*operation
) (scratch
, high_bit
, operands
[3]));
4406 emit_move_insn (operands
[0], operands
[2]);
4408 emit_move_insn (operands
[1], scratch
);
4412 /* Use ext[wlq][lh] as the Architecture Handbook describes for extracting
4416 word: ldq_u r1,X(r11) ldq_u r1,X(r11)
4417 ldq_u r2,X+1(r11) ldq_u r2,X+1(r11)
4418 lda r3,X(r11) lda r3,X+2(r11)
4419 extwl r1,r3,r1 extql r1,r3,r1
4420 extwh r2,r3,r2 extqh r2,r3,r2
4421 or r1.r2.r1 or r1,r2,r1
4424 long: ldq_u r1,X(r11) ldq_u r1,X(r11)
4425 ldq_u r2,X+3(r11) ldq_u r2,X+3(r11)
4426 lda r3,X(r11) lda r3,X(r11)
4427 extll r1,r3,r1 extll r1,r3,r1
4428 extlh r2,r3,r2 extlh r2,r3,r2
4429 or r1.r2.r1 addl r1,r2,r1
4431 quad: ldq_u r1,X(r11)
4440 alpha_expand_unaligned_load (tgt
, mem
, size
, ofs
, sign
)
4442 HOST_WIDE_INT size
, ofs
;
4445 rtx meml
, memh
, addr
, extl
, exth
, tmp
, mema
;
4446 enum machine_mode mode
;
4448 meml
= gen_reg_rtx (DImode
);
4449 memh
= gen_reg_rtx (DImode
);
4450 addr
= gen_reg_rtx (DImode
);
4451 extl
= gen_reg_rtx (DImode
);
4452 exth
= gen_reg_rtx (DImode
);
4454 mema
= XEXP (mem
, 0);
4455 if (GET_CODE (mema
) == LO_SUM
)
4456 mema
= force_reg (Pmode
, mema
);
4458 /* AND addresses cannot be in any alias set, since they may implicitly
4459 alias surrounding code. Ideally we'd have some alias set that
4460 covered all types except those with alignment 8 or higher. */
4462 tmp
= change_address (mem
, DImode
,
4463 gen_rtx_AND (DImode
,
4464 plus_constant (mema
, ofs
),
4466 set_mem_alias_set (tmp
, 0);
4467 emit_move_insn (meml
, tmp
);
4469 tmp
= change_address (mem
, DImode
,
4470 gen_rtx_AND (DImode
,
4471 plus_constant (mema
, ofs
+ size
- 1),
4473 set_mem_alias_set (tmp
, 0);
4474 emit_move_insn (memh
, tmp
);
4476 if (WORDS_BIG_ENDIAN
&& sign
&& (size
== 2 || size
== 4))
4478 emit_move_insn (addr
, plus_constant (mema
, -1));
4480 emit_insn (gen_extqh_be (extl
, meml
, addr
));
4481 emit_insn (gen_extxl_be (exth
, memh
, GEN_INT (64), addr
));
4483 addr
= expand_binop (DImode
, ior_optab
, extl
, exth
, tgt
, 1, OPTAB_WIDEN
);
4484 addr
= expand_binop (DImode
, ashr_optab
, addr
, GEN_INT (64 - size
*8),
4485 addr
, 1, OPTAB_WIDEN
);
4487 else if (sign
&& size
== 2)
4489 emit_move_insn (addr
, plus_constant (mema
, ofs
+2));
4491 emit_insn (gen_extxl_le (extl
, meml
, GEN_INT (64), addr
));
4492 emit_insn (gen_extqh_le (exth
, memh
, addr
));
4494 /* We must use tgt here for the target. Alpha-vms port fails if we use
4495 addr for the target, because addr is marked as a pointer and combine
4496 knows that pointers are always sign-extended 32 bit values. */
4497 addr
= expand_binop (DImode
, ior_optab
, extl
, exth
, tgt
, 1, OPTAB_WIDEN
);
4498 addr
= expand_binop (DImode
, ashr_optab
, addr
, GEN_INT (48),
4499 addr
, 1, OPTAB_WIDEN
);
4503 if (WORDS_BIG_ENDIAN
)
4505 emit_move_insn (addr
, plus_constant (mema
, ofs
+size
-1));
4509 emit_insn (gen_extwh_be (extl
, meml
, addr
));
4514 emit_insn (gen_extlh_be (extl
, meml
, addr
));
4519 emit_insn (gen_extqh_be (extl
, meml
, addr
));
4526 emit_insn (gen_extxl_be (exth
, memh
, GEN_INT (size
*8), addr
));
4530 emit_move_insn (addr
, plus_constant (mema
, ofs
));
4531 emit_insn (gen_extxl_le (extl
, meml
, GEN_INT (size
*8), addr
));
4535 emit_insn (gen_extwh_le (exth
, memh
, addr
));
4540 emit_insn (gen_extlh_le (exth
, memh
, addr
));
4545 emit_insn (gen_extqh_le (exth
, memh
, addr
));
4554 addr
= expand_binop (mode
, ior_optab
, gen_lowpart (mode
, extl
),
4555 gen_lowpart (mode
, exth
), gen_lowpart (mode
, tgt
),
4560 emit_move_insn (tgt
, gen_lowpart(GET_MODE (tgt
), addr
));
4563 /* Similarly, use ins and msk instructions to perform unaligned stores. */
4566 alpha_expand_unaligned_store (dst
, src
, size
, ofs
)
4568 HOST_WIDE_INT size
, ofs
;
4570 rtx dstl
, dsth
, addr
, insl
, insh
, meml
, memh
, dsta
;
4572 dstl
= gen_reg_rtx (DImode
);
4573 dsth
= gen_reg_rtx (DImode
);
4574 insl
= gen_reg_rtx (DImode
);
4575 insh
= gen_reg_rtx (DImode
);
4577 dsta
= XEXP (dst
, 0);
4578 if (GET_CODE (dsta
) == LO_SUM
)
4579 dsta
= force_reg (Pmode
, dsta
);
4581 /* AND addresses cannot be in any alias set, since they may implicitly
4582 alias surrounding code. Ideally we'd have some alias set that
4583 covered all types except those with alignment 8 or higher. */
4585 meml
= change_address (dst
, DImode
,
4586 gen_rtx_AND (DImode
,
4587 plus_constant (dsta
, ofs
),
4589 set_mem_alias_set (meml
, 0);
4591 memh
= change_address (dst
, DImode
,
4592 gen_rtx_AND (DImode
,
4593 plus_constant (dsta
, ofs
+ size
- 1),
4595 set_mem_alias_set (memh
, 0);
4597 emit_move_insn (dsth
, memh
);
4598 emit_move_insn (dstl
, meml
);
4599 if (WORDS_BIG_ENDIAN
)
4601 addr
= copy_addr_to_reg (plus_constant (dsta
, ofs
+size
-1));
4603 if (src
!= const0_rtx
)
4608 emit_insn (gen_inswl_be (insh
, gen_lowpart (HImode
,src
), addr
));
4611 emit_insn (gen_insll_be (insh
, gen_lowpart (SImode
,src
), addr
));
4614 emit_insn (gen_insql_be (insh
, gen_lowpart (DImode
,src
), addr
));
4617 emit_insn (gen_insxh (insl
, gen_lowpart (DImode
, src
),
4618 GEN_INT (size
*8), addr
));
4624 emit_insn (gen_mskxl_be (dsth
, dsth
, GEN_INT (0xffff), addr
));
4628 rtx msk
= immed_double_const (0xffffffff, 0, DImode
);
4629 emit_insn (gen_mskxl_be (dsth
, dsth
, msk
, addr
));
4633 emit_insn (gen_mskxl_be (dsth
, dsth
, constm1_rtx
, addr
));
4637 emit_insn (gen_mskxh (dstl
, dstl
, GEN_INT (size
*8), addr
));
4641 addr
= copy_addr_to_reg (plus_constant (dsta
, ofs
));
4643 if (src
!= const0_rtx
)
4645 emit_insn (gen_insxh (insh
, gen_lowpart (DImode
, src
),
4646 GEN_INT (size
*8), addr
));
4651 emit_insn (gen_inswl_le (insl
, gen_lowpart (HImode
, src
), addr
));
4654 emit_insn (gen_insll_le (insl
, gen_lowpart (SImode
, src
), addr
));
4657 emit_insn (gen_insql_le (insl
, src
, addr
));
4662 emit_insn (gen_mskxh (dsth
, dsth
, GEN_INT (size
*8), addr
));
4667 emit_insn (gen_mskxl_le (dstl
, dstl
, GEN_INT (0xffff), addr
));
4671 rtx msk
= immed_double_const (0xffffffff, 0, DImode
);
4672 emit_insn (gen_mskxl_le (dstl
, dstl
, msk
, addr
));
4676 emit_insn (gen_mskxl_le (dstl
, dstl
, constm1_rtx
, addr
));
4681 if (src
!= const0_rtx
)
4683 dsth
= expand_binop (DImode
, ior_optab
, insh
, dsth
, dsth
, 0, OPTAB_WIDEN
);
4684 dstl
= expand_binop (DImode
, ior_optab
, insl
, dstl
, dstl
, 0, OPTAB_WIDEN
);
4687 if (WORDS_BIG_ENDIAN
)
4689 emit_move_insn (meml
, dstl
);
4690 emit_move_insn (memh
, dsth
);
4694 /* Must store high before low for degenerate case of aligned. */
4695 emit_move_insn (memh
, dsth
);
4696 emit_move_insn (meml
, dstl
);
4700 /* The block move code tries to maximize speed by separating loads and
4701 stores at the expense of register pressure: we load all of the data
4702 before we store it back out. There are two secondary effects worth
4703 mentioning, that this speeds copying to/from aligned and unaligned
4704 buffers, and that it makes the code significantly easier to write. */
4706 #define MAX_MOVE_WORDS 8
4708 /* Load an integral number of consecutive unaligned quadwords. */
4711 alpha_expand_unaligned_load_words (out_regs
, smem
, words
, ofs
)
4714 HOST_WIDE_INT words
, ofs
;
4716 rtx
const im8
= GEN_INT (-8);
4717 rtx
const i64
= GEN_INT (64);
4718 rtx ext_tmps
[MAX_MOVE_WORDS
], data_regs
[MAX_MOVE_WORDS
+1];
4719 rtx sreg
, areg
, tmp
, smema
;
4722 smema
= XEXP (smem
, 0);
4723 if (GET_CODE (smema
) == LO_SUM
)
4724 smema
= force_reg (Pmode
, smema
);
4726 /* Generate all the tmp registers we need. */
4727 for (i
= 0; i
< words
; ++i
)
4729 data_regs
[i
] = out_regs
[i
];
4730 ext_tmps
[i
] = gen_reg_rtx (DImode
);
4732 data_regs
[words
] = gen_reg_rtx (DImode
);
4735 smem
= adjust_address (smem
, GET_MODE (smem
), ofs
);
4737 /* Load up all of the source data. */
4738 for (i
= 0; i
< words
; ++i
)
4740 tmp
= change_address (smem
, DImode
,
4741 gen_rtx_AND (DImode
,
4742 plus_constant (smema
, 8*i
),
4744 set_mem_alias_set (tmp
, 0);
4745 emit_move_insn (data_regs
[i
], tmp
);
4748 tmp
= change_address (smem
, DImode
,
4749 gen_rtx_AND (DImode
,
4750 plus_constant (smema
, 8*words
- 1),
4752 set_mem_alias_set (tmp
, 0);
4753 emit_move_insn (data_regs
[words
], tmp
);
4755 /* Extract the half-word fragments. Unfortunately DEC decided to make
4756 extxh with offset zero a noop instead of zeroing the register, so
4757 we must take care of that edge condition ourselves with cmov. */
4759 sreg
= copy_addr_to_reg (smema
);
4760 areg
= expand_binop (DImode
, and_optab
, sreg
, GEN_INT (7), NULL
,
4762 if (WORDS_BIG_ENDIAN
)
4763 emit_move_insn (sreg
, plus_constant (sreg
, 7));
4764 for (i
= 0; i
< words
; ++i
)
4766 if (WORDS_BIG_ENDIAN
)
4768 emit_insn (gen_extqh_be (data_regs
[i
], data_regs
[i
], sreg
));
4769 emit_insn (gen_extxl_be (ext_tmps
[i
], data_regs
[i
+1], i64
, sreg
));
4773 emit_insn (gen_extxl_le (data_regs
[i
], data_regs
[i
], i64
, sreg
));
4774 emit_insn (gen_extqh_le (ext_tmps
[i
], data_regs
[i
+1], sreg
));
4776 emit_insn (gen_rtx_SET (VOIDmode
, ext_tmps
[i
],
4777 gen_rtx_IF_THEN_ELSE (DImode
,
4778 gen_rtx_EQ (DImode
, areg
,
4780 const0_rtx
, ext_tmps
[i
])));
4783 /* Merge the half-words into whole words. */
4784 for (i
= 0; i
< words
; ++i
)
4786 out_regs
[i
] = expand_binop (DImode
, ior_optab
, data_regs
[i
],
4787 ext_tmps
[i
], data_regs
[i
], 1, OPTAB_WIDEN
);
4791 /* Store an integral number of consecutive unaligned quadwords. DATA_REGS
4792 may be NULL to store zeros. */
4795 alpha_expand_unaligned_store_words (data_regs
, dmem
, words
, ofs
)
4798 HOST_WIDE_INT words
, ofs
;
4800 rtx
const im8
= GEN_INT (-8);
4801 rtx
const i64
= GEN_INT (64);
4802 rtx ins_tmps
[MAX_MOVE_WORDS
];
4803 rtx st_tmp_1
, st_tmp_2
, dreg
;
4804 rtx st_addr_1
, st_addr_2
, dmema
;
4807 dmema
= XEXP (dmem
, 0);
4808 if (GET_CODE (dmema
) == LO_SUM
)
4809 dmema
= force_reg (Pmode
, dmema
);
4811 /* Generate all the tmp registers we need. */
4812 if (data_regs
!= NULL
)
4813 for (i
= 0; i
< words
; ++i
)
4814 ins_tmps
[i
] = gen_reg_rtx(DImode
);
4815 st_tmp_1
= gen_reg_rtx(DImode
);
4816 st_tmp_2
= gen_reg_rtx(DImode
);
4819 dmem
= adjust_address (dmem
, GET_MODE (dmem
), ofs
);
4821 st_addr_2
= change_address (dmem
, DImode
,
4822 gen_rtx_AND (DImode
,
4823 plus_constant (dmema
, words
*8 - 1),
4825 set_mem_alias_set (st_addr_2
, 0);
4827 st_addr_1
= change_address (dmem
, DImode
,
4828 gen_rtx_AND (DImode
, dmema
, im8
));
4829 set_mem_alias_set (st_addr_1
, 0);
4831 /* Load up the destination end bits. */
4832 emit_move_insn (st_tmp_2
, st_addr_2
);
4833 emit_move_insn (st_tmp_1
, st_addr_1
);
4835 /* Shift the input data into place. */
4836 dreg
= copy_addr_to_reg (dmema
);
4837 if (WORDS_BIG_ENDIAN
)
4838 emit_move_insn (dreg
, plus_constant (dreg
, 7));
4839 if (data_regs
!= NULL
)
4841 for (i
= words
-1; i
>= 0; --i
)
4843 if (WORDS_BIG_ENDIAN
)
4845 emit_insn (gen_insql_be (ins_tmps
[i
], data_regs
[i
], dreg
));
4846 emit_insn (gen_insxh (data_regs
[i
], data_regs
[i
], i64
, dreg
));
4850 emit_insn (gen_insxh (ins_tmps
[i
], data_regs
[i
], i64
, dreg
));
4851 emit_insn (gen_insql_le (data_regs
[i
], data_regs
[i
], dreg
));
4854 for (i
= words
-1; i
> 0; --i
)
4856 ins_tmps
[i
-1] = expand_binop (DImode
, ior_optab
, data_regs
[i
],
4857 ins_tmps
[i
-1], ins_tmps
[i
-1], 1,
4862 /* Split and merge the ends with the destination data. */
4863 if (WORDS_BIG_ENDIAN
)
4865 emit_insn (gen_mskxl_be (st_tmp_2
, st_tmp_2
, constm1_rtx
, dreg
));
4866 emit_insn (gen_mskxh (st_tmp_1
, st_tmp_1
, i64
, dreg
));
4870 emit_insn (gen_mskxh (st_tmp_2
, st_tmp_2
, i64
, dreg
));
4871 emit_insn (gen_mskxl_le (st_tmp_1
, st_tmp_1
, constm1_rtx
, dreg
));
4874 if (data_regs
!= NULL
)
4876 st_tmp_2
= expand_binop (DImode
, ior_optab
, st_tmp_2
, ins_tmps
[words
-1],
4877 st_tmp_2
, 1, OPTAB_WIDEN
);
4878 st_tmp_1
= expand_binop (DImode
, ior_optab
, st_tmp_1
, data_regs
[0],
4879 st_tmp_1
, 1, OPTAB_WIDEN
);
4883 if (WORDS_BIG_ENDIAN
)
4884 emit_move_insn (st_addr_1
, st_tmp_1
);
4886 emit_move_insn (st_addr_2
, st_tmp_2
);
4887 for (i
= words
-1; i
> 0; --i
)
4889 rtx tmp
= change_address (dmem
, DImode
,
4890 gen_rtx_AND (DImode
,
4891 plus_constant(dmema
,
4892 WORDS_BIG_ENDIAN
? i
*8-1 : i
*8),
4894 set_mem_alias_set (tmp
, 0);
4895 emit_move_insn (tmp
, data_regs
? ins_tmps
[i
-1] : const0_rtx
);
4897 if (WORDS_BIG_ENDIAN
)
4898 emit_move_insn (st_addr_2
, st_tmp_2
);
4900 emit_move_insn (st_addr_1
, st_tmp_1
);
4904 /* Expand string/block move operations.
4906 operands[0] is the pointer to the destination.
4907 operands[1] is the pointer to the source.
4908 operands[2] is the number of bytes to move.
4909 operands[3] is the alignment. */
4912 alpha_expand_block_move (operands
)
4915 rtx bytes_rtx
= operands
[2];
4916 rtx align_rtx
= operands
[3];
4917 HOST_WIDE_INT orig_bytes
= INTVAL (bytes_rtx
);
4918 HOST_WIDE_INT bytes
= orig_bytes
;
4919 HOST_WIDE_INT src_align
= INTVAL (align_rtx
) * BITS_PER_UNIT
;
4920 HOST_WIDE_INT dst_align
= src_align
;
4921 rtx orig_src
= operands
[1];
4922 rtx orig_dst
= operands
[0];
4923 rtx data_regs
[2 * MAX_MOVE_WORDS
+ 16];
4925 unsigned int i
, words
, ofs
, nregs
= 0;
4927 if (orig_bytes
<= 0)
4929 else if (orig_bytes
> MAX_MOVE_WORDS
* UNITS_PER_WORD
)
4932 /* Look for additional alignment information from recorded register info. */
4934 tmp
= XEXP (orig_src
, 0);
4935 if (GET_CODE (tmp
) == REG
)
4936 src_align
= MAX (src_align
, REGNO_POINTER_ALIGN (REGNO (tmp
)));
4937 else if (GET_CODE (tmp
) == PLUS
4938 && GET_CODE (XEXP (tmp
, 0)) == REG
4939 && GET_CODE (XEXP (tmp
, 1)) == CONST_INT
)
4941 unsigned HOST_WIDE_INT c
= INTVAL (XEXP (tmp
, 1));
4942 unsigned int a
= REGNO_POINTER_ALIGN (REGNO (XEXP (tmp
, 0)));
4946 if (a
>= 64 && c
% 8 == 0)
4948 else if (a
>= 32 && c
% 4 == 0)
4950 else if (a
>= 16 && c
% 2 == 0)
4955 tmp
= XEXP (orig_dst
, 0);
4956 if (GET_CODE (tmp
) == REG
)
4957 dst_align
= MAX (dst_align
, REGNO_POINTER_ALIGN (REGNO (tmp
)));
4958 else if (GET_CODE (tmp
) == PLUS
4959 && GET_CODE (XEXP (tmp
, 0)) == REG
4960 && GET_CODE (XEXP (tmp
, 1)) == CONST_INT
)
4962 unsigned HOST_WIDE_INT c
= INTVAL (XEXP (tmp
, 1));
4963 unsigned int a
= REGNO_POINTER_ALIGN (REGNO (XEXP (tmp
, 0)));
4967 if (a
>= 64 && c
% 8 == 0)
4969 else if (a
>= 32 && c
% 4 == 0)
4971 else if (a
>= 16 && c
% 2 == 0)
4976 /* Load the entire block into registers. */
4977 if (GET_CODE (XEXP (orig_src
, 0)) == ADDRESSOF
)
4979 enum machine_mode mode
;
4981 tmp
= XEXP (XEXP (orig_src
, 0), 0);
4983 /* Don't use the existing register if we're reading more than
4984 is held in the register. Nor if there is not a mode that
4985 handles the exact size. */
4986 mode
= mode_for_size (bytes
* BITS_PER_UNIT
, MODE_INT
, 1);
4988 && GET_MODE_SIZE (GET_MODE (tmp
)) >= bytes
)
4992 data_regs
[nregs
] = gen_lowpart (DImode
, tmp
);
4993 data_regs
[nregs
+ 1] = gen_highpart (DImode
, tmp
);
4997 data_regs
[nregs
++] = gen_lowpart (mode
, tmp
);
5002 /* No appropriate mode; fall back on memory. */
5003 orig_src
= replace_equiv_address (orig_src
,
5004 copy_addr_to_reg (XEXP (orig_src
, 0)));
5005 src_align
= GET_MODE_BITSIZE (GET_MODE (tmp
));
5009 if (src_align
>= 64 && bytes
>= 8)
5013 for (i
= 0; i
< words
; ++i
)
5014 data_regs
[nregs
+ i
] = gen_reg_rtx (DImode
);
5016 for (i
= 0; i
< words
; ++i
)
5017 emit_move_insn (data_regs
[nregs
+ i
],
5018 adjust_address (orig_src
, DImode
, ofs
+ i
* 8));
5025 if (src_align
>= 32 && bytes
>= 4)
5029 for (i
= 0; i
< words
; ++i
)
5030 data_regs
[nregs
+ i
] = gen_reg_rtx (SImode
);
5032 for (i
= 0; i
< words
; ++i
)
5033 emit_move_insn (data_regs
[nregs
+ i
],
5034 adjust_address (orig_src
, SImode
, ofs
+ i
* 4));
5045 for (i
= 0; i
< words
+1; ++i
)
5046 data_regs
[nregs
+ i
] = gen_reg_rtx (DImode
);
5048 alpha_expand_unaligned_load_words (data_regs
+ nregs
, orig_src
,
5056 if (! TARGET_BWX
&& bytes
>= 4)
5058 data_regs
[nregs
++] = tmp
= gen_reg_rtx (SImode
);
5059 alpha_expand_unaligned_load (tmp
, orig_src
, 4, ofs
, 0);
5066 if (src_align
>= 16)
5069 data_regs
[nregs
++] = tmp
= gen_reg_rtx (HImode
);
5070 emit_move_insn (tmp
, adjust_address (orig_src
, HImode
, ofs
));
5073 } while (bytes
>= 2);
5075 else if (! TARGET_BWX
)
5077 data_regs
[nregs
++] = tmp
= gen_reg_rtx (HImode
);
5078 alpha_expand_unaligned_load (tmp
, orig_src
, 2, ofs
, 0);
5086 data_regs
[nregs
++] = tmp
= gen_reg_rtx (QImode
);
5087 emit_move_insn (tmp
, adjust_address (orig_src
, QImode
, ofs
));
5094 if (nregs
> ARRAY_SIZE (data_regs
))
5097 /* Now save it back out again. */
5101 if (GET_CODE (XEXP (orig_dst
, 0)) == ADDRESSOF
)
5103 enum machine_mode mode
;
5104 tmp
= XEXP (XEXP (orig_dst
, 0), 0);
5106 mode
= mode_for_size (orig_bytes
* BITS_PER_UNIT
, MODE_INT
, 1);
5107 if (GET_MODE (tmp
) == mode
)
5111 emit_move_insn (tmp
, data_regs
[0]);
5116 else if (nregs
== 2 && mode
== TImode
)
5118 /* Undo the subregging done above when copying between
5119 two TImode registers. */
5120 if (GET_CODE (data_regs
[0]) == SUBREG
5121 && GET_MODE (SUBREG_REG (data_regs
[0])) == TImode
)
5122 emit_move_insn (tmp
, SUBREG_REG (data_regs
[0]));
5128 emit_move_insn (gen_lowpart (DImode
, tmp
), data_regs
[0]);
5129 emit_move_insn (gen_highpart (DImode
, tmp
), data_regs
[1]);
5133 emit_no_conflict_block (seq
, tmp
, data_regs
[0],
5134 data_regs
[1], NULL_RTX
);
5142 /* ??? If nregs > 1, consider reconstructing the word in regs. */
5143 /* ??? Optimize mode < dst_mode with strict_low_part. */
5145 /* No appropriate mode; fall back on memory. We can speed things
5146 up by recognizing extra alignment information. */
5147 orig_dst
= replace_equiv_address (orig_dst
,
5148 copy_addr_to_reg (XEXP (orig_dst
, 0)));
5149 dst_align
= GET_MODE_BITSIZE (GET_MODE (tmp
));
5152 /* Write out the data in whatever chunks reading the source allowed. */
5153 if (dst_align
>= 64)
5155 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == DImode
)
5157 emit_move_insn (adjust_address (orig_dst
, DImode
, ofs
),
5164 if (dst_align
>= 32)
5166 /* If the source has remaining DImode regs, write them out in
5168 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == DImode
)
5170 tmp
= expand_binop (DImode
, lshr_optab
, data_regs
[i
], GEN_INT (32),
5171 NULL_RTX
, 1, OPTAB_WIDEN
);
5173 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
),
5174 gen_lowpart (SImode
, data_regs
[i
]));
5175 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
+ 4),
5176 gen_lowpart (SImode
, tmp
));
5181 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == SImode
)
5183 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
),
5190 if (i
< nregs
&& GET_MODE (data_regs
[i
]) == DImode
)
5192 /* Write out a remaining block of words using unaligned methods. */
5194 for (words
= 1; i
+ words
< nregs
; words
++)
5195 if (GET_MODE (data_regs
[i
+ words
]) != DImode
)
5199 alpha_expand_unaligned_store (orig_dst
, data_regs
[i
], 8, ofs
);
5201 alpha_expand_unaligned_store_words (data_regs
+ i
, orig_dst
,
5208 /* Due to the above, this won't be aligned. */
5209 /* ??? If we have more than one of these, consider constructing full
5210 words in registers and using alpha_expand_unaligned_store_words. */
5211 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == SImode
)
5213 alpha_expand_unaligned_store (orig_dst
, data_regs
[i
], 4, ofs
);
5218 if (dst_align
>= 16)
5219 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == HImode
)
5221 emit_move_insn (adjust_address (orig_dst
, HImode
, ofs
), data_regs
[i
]);
5226 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == HImode
)
5228 alpha_expand_unaligned_store (orig_dst
, data_regs
[i
], 2, ofs
);
5233 while (i
< nregs
&& GET_MODE (data_regs
[i
]) == QImode
)
5235 emit_move_insn (adjust_address (orig_dst
, QImode
, ofs
), data_regs
[i
]);
5249 alpha_expand_block_clear (operands
)
5252 rtx bytes_rtx
= operands
[1];
5253 rtx align_rtx
= operands
[2];
5254 HOST_WIDE_INT orig_bytes
= INTVAL (bytes_rtx
);
5255 HOST_WIDE_INT bytes
= orig_bytes
;
5256 HOST_WIDE_INT align
= INTVAL (align_rtx
) * BITS_PER_UNIT
;
5257 HOST_WIDE_INT alignofs
= 0;
5258 rtx orig_dst
= operands
[0];
5260 int i
, words
, ofs
= 0;
5262 if (orig_bytes
<= 0)
5264 if (orig_bytes
> MAX_MOVE_WORDS
* UNITS_PER_WORD
)
5267 /* Look for stricter alignment. */
5268 tmp
= XEXP (orig_dst
, 0);
5269 if (GET_CODE (tmp
) == REG
)
5270 align
= MAX (align
, REGNO_POINTER_ALIGN (REGNO (tmp
)));
5271 else if (GET_CODE (tmp
) == PLUS
5272 && GET_CODE (XEXP (tmp
, 0)) == REG
5273 && GET_CODE (XEXP (tmp
, 1)) == CONST_INT
)
5275 HOST_WIDE_INT c
= INTVAL (XEXP (tmp
, 1));
5276 int a
= REGNO_POINTER_ALIGN (REGNO (XEXP (tmp
, 0)));
5281 align
= a
, alignofs
= 8 - c
% 8;
5283 align
= a
, alignofs
= 4 - c
% 4;
5285 align
= a
, alignofs
= 2 - c
% 2;
5288 else if (GET_CODE (tmp
) == ADDRESSOF
)
5290 enum machine_mode mode
;
5292 mode
= mode_for_size (bytes
* BITS_PER_UNIT
, MODE_INT
, 1);
5293 if (GET_MODE (XEXP (tmp
, 0)) == mode
)
5295 emit_move_insn (XEXP (tmp
, 0), const0_rtx
);
5299 /* No appropriate mode; fall back on memory. */
5300 orig_dst
= replace_equiv_address (orig_dst
, copy_addr_to_reg (tmp
));
5301 align
= GET_MODE_BITSIZE (GET_MODE (XEXP (tmp
, 0)));
5304 /* Handle an unaligned prefix first. */
5308 #if HOST_BITS_PER_WIDE_INT >= 64
5309 /* Given that alignofs is bounded by align, the only time BWX could
5310 generate three stores is for a 7 byte fill. Prefer two individual
5311 stores over a load/mask/store sequence. */
5312 if ((!TARGET_BWX
|| alignofs
== 7)
5314 && !(alignofs
== 4 && bytes
>= 4))
5316 enum machine_mode mode
= (align
>= 64 ? DImode
: SImode
);
5317 int inv_alignofs
= (align
>= 64 ? 8 : 4) - alignofs
;
5321 mem
= adjust_address (orig_dst
, mode
, ofs
- inv_alignofs
);
5322 set_mem_alias_set (mem
, 0);
5324 mask
= ~(~(HOST_WIDE_INT
)0 << (inv_alignofs
* 8));
5325 if (bytes
< alignofs
)
5327 mask
|= ~(HOST_WIDE_INT
)0 << ((inv_alignofs
+ bytes
) * 8);
5338 tmp
= expand_binop (mode
, and_optab
, mem
, GEN_INT (mask
),
5339 NULL_RTX
, 1, OPTAB_WIDEN
);
5341 emit_move_insn (mem
, tmp
);
5345 if (TARGET_BWX
&& (alignofs
& 1) && bytes
>= 1)
5347 emit_move_insn (adjust_address (orig_dst
, QImode
, ofs
), const0_rtx
);
5352 if (TARGET_BWX
&& align
>= 16 && (alignofs
& 3) == 2 && bytes
>= 2)
5354 emit_move_insn (adjust_address (orig_dst
, HImode
, ofs
), const0_rtx
);
5359 if (alignofs
== 4 && bytes
>= 4)
5361 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
), const0_rtx
);
5367 /* If we've not used the extra lead alignment information by now,
5368 we won't be able to. Downgrade align to match what's left over. */
5371 alignofs
= alignofs
& -alignofs
;
5372 align
= MIN (align
, alignofs
* BITS_PER_UNIT
);
5376 /* Handle a block of contiguous long-words. */
5378 if (align
>= 64 && bytes
>= 8)
5382 for (i
= 0; i
< words
; ++i
)
5383 emit_move_insn (adjust_address (orig_dst
, DImode
, ofs
+ i
* 8),
5390 /* If the block is large and appropriately aligned, emit a single
5391 store followed by a sequence of stq_u insns. */
5393 if (align
>= 32 && bytes
> 16)
5397 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
), const0_rtx
);
5401 orig_dsta
= XEXP (orig_dst
, 0);
5402 if (GET_CODE (orig_dsta
) == LO_SUM
)
5403 orig_dsta
= force_reg (Pmode
, orig_dsta
);
5406 for (i
= 0; i
< words
; ++i
)
5409 = change_address (orig_dst
, DImode
,
5410 gen_rtx_AND (DImode
,
5411 plus_constant (orig_dsta
, ofs
+ i
*8),
5413 set_mem_alias_set (mem
, 0);
5414 emit_move_insn (mem
, const0_rtx
);
5417 /* Depending on the alignment, the first stq_u may have overlapped
5418 with the initial stl, which means that the last stq_u didn't
5419 write as much as it would appear. Leave those questionable bytes
5421 bytes
-= words
* 8 - 4;
5422 ofs
+= words
* 8 - 4;
5425 /* Handle a smaller block of aligned words. */
5427 if ((align
>= 64 && bytes
== 4)
5428 || (align
== 32 && bytes
>= 4))
5432 for (i
= 0; i
< words
; ++i
)
5433 emit_move_insn (adjust_address (orig_dst
, SImode
, ofs
+ i
* 4),
5440 /* An unaligned block uses stq_u stores for as many as possible. */
5446 alpha_expand_unaligned_store_words (NULL
, orig_dst
, words
, ofs
);
5452 /* Next clean up any trailing pieces. */
5454 #if HOST_BITS_PER_WIDE_INT >= 64
5455 /* Count the number of bits in BYTES for which aligned stores could
5458 for (i
= (TARGET_BWX
? 1 : 4); i
* BITS_PER_UNIT
<= align
; i
<<= 1)
5462 /* If we have appropriate alignment (and it wouldn't take too many
5463 instructions otherwise), mask out the bytes we need. */
5464 if (TARGET_BWX
? words
> 2 : bytes
> 0)
5471 mem
= adjust_address (orig_dst
, DImode
, ofs
);
5472 set_mem_alias_set (mem
, 0);
5474 mask
= ~(HOST_WIDE_INT
)0 << (bytes
* 8);
5476 tmp
= expand_binop (DImode
, and_optab
, mem
, GEN_INT (mask
),
5477 NULL_RTX
, 1, OPTAB_WIDEN
);
5479 emit_move_insn (mem
, tmp
);
5482 else if (align
>= 32 && bytes
< 4)
5487 mem
= adjust_address (orig_dst
, SImode
, ofs
);
5488 set_mem_alias_set (mem
, 0);
5490 mask
= ~(HOST_WIDE_INT
)0 << (bytes
* 8);
5492 tmp
= expand_binop (SImode
, and_optab
, mem
, GEN_INT (mask
),
5493 NULL_RTX
, 1, OPTAB_WIDEN
);
5495 emit_move_insn (mem
, tmp
);
5501 if (!TARGET_BWX
&& bytes
>= 4)
5503 alpha_expand_unaligned_store (orig_dst
, const0_rtx
, 4, ofs
);
5513 emit_move_insn (adjust_address (orig_dst
, HImode
, ofs
),
5517 } while (bytes
>= 2);
5519 else if (! TARGET_BWX
)
5521 alpha_expand_unaligned_store (orig_dst
, const0_rtx
, 2, ofs
);
5529 emit_move_insn (adjust_address (orig_dst
, QImode
, ofs
), const0_rtx
);
5537 /* Returns a mask so that zap(x, value) == x & mask. */
5540 alpha_expand_zap_mask (value
)
5541 HOST_WIDE_INT value
;
5546 if (HOST_BITS_PER_WIDE_INT
>= 64)
5548 HOST_WIDE_INT mask
= 0;
5550 for (i
= 7; i
>= 0; --i
)
5553 if (!((value
>> i
) & 1))
5557 result
= gen_int_mode (mask
, DImode
);
5559 else if (HOST_BITS_PER_WIDE_INT
== 32)
5561 HOST_WIDE_INT mask_lo
= 0, mask_hi
= 0;
5563 for (i
= 7; i
>= 4; --i
)
5566 if (!((value
>> i
) & 1))
5570 for (i
= 3; i
>= 0; --i
)
5573 if (!((value
>> i
) & 1))
5577 result
= immed_double_const (mask_lo
, mask_hi
, DImode
);
5586 alpha_expand_builtin_vector_binop (gen
, mode
, op0
, op1
, op2
)
5587 rtx (*gen
) PARAMS ((rtx
, rtx
, rtx
));
5588 enum machine_mode mode
;
5591 op0
= gen_lowpart (mode
, op0
);
5593 if (op1
== const0_rtx
)
5594 op1
= CONST0_RTX (mode
);
5596 op1
= gen_lowpart (mode
, op1
);
5598 if (op2
== const0_rtx
)
5599 op2
= CONST0_RTX (mode
);
5601 op2
= gen_lowpart (mode
, op2
);
5603 emit_insn ((*gen
) (op0
, op1
, op2
));
5606 /* Adjust the cost of a scheduling dependency. Return the new cost of
5607 a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
5610 alpha_adjust_cost (insn
, link
, dep_insn
, cost
)
5616 enum attr_type insn_type
, dep_insn_type
;
5618 /* If the dependence is an anti-dependence, there is no cost. For an
5619 output dependence, there is sometimes a cost, but it doesn't seem
5620 worth handling those few cases. */
5621 if (REG_NOTE_KIND (link
) != 0)
5624 /* If we can't recognize the insns, we can't really do anything. */
5625 if (recog_memoized (insn
) < 0 || recog_memoized (dep_insn
) < 0)
5628 insn_type
= get_attr_type (insn
);
5629 dep_insn_type
= get_attr_type (dep_insn
);
5631 /* Bring in the user-defined memory latency. */
5632 if (dep_insn_type
== TYPE_ILD
5633 || dep_insn_type
== TYPE_FLD
5634 || dep_insn_type
== TYPE_LDSYM
)
5635 cost
+= alpha_memory_latency
-1;
5637 /* Everything else handled in DFA bypasses now. */
5642 /* The number of instructions that can be issued per cycle. */
5647 return (alpha_cpu
== PROCESSOR_EV4
? 2 : 4);
5651 alpha_use_dfa_pipeline_interface ()
5656 /* How many alternative schedules to try. This should be as wide as the
5657 scheduling freedom in the DFA, but no wider. Making this value too
5658 large results extra work for the scheduler.
5660 For EV4, loads can be issued to either IB0 or IB1, thus we have 2
5661 alternative schedules. For EV5, we can choose between E0/E1 and
5662 FA/FM. For EV6, an arithmatic insn can be issued to U0/U1/L0/L1. */
5665 alpha_multipass_dfa_lookahead ()
5667 return (alpha_cpu
== PROCESSOR_EV6
? 4 : 2);
5670 /* Machine-specific function data. */
5672 struct machine_function
GTY(())
5675 /* List of call information words for calls from this function. */
5676 struct rtx_def
*first_ciw
;
5677 struct rtx_def
*last_ciw
;
5680 /* List of deferred case vectors. */
5681 struct rtx_def
*addr_list
;
5684 const char *some_ld_name
;
5687 /* How to allocate a 'struct machine_function'. */
5689 static struct machine_function
*
5690 alpha_init_machine_status ()
5692 return ((struct machine_function
*)
5693 ggc_alloc_cleared (sizeof (struct machine_function
)));
5696 /* Functions to save and restore alpha_return_addr_rtx. */
5698 /* Start the ball rolling with RETURN_ADDR_RTX. */
5701 alpha_return_addr (count
, frame
)
5703 rtx frame ATTRIBUTE_UNUSED
;
5708 return get_hard_reg_initial_val (Pmode
, REG_RA
);
5711 /* Return or create a pseudo containing the gp value for the current
5712 function. Needed only if TARGET_LD_BUGGY_LDGP. */
5715 alpha_gp_save_rtx ()
5717 rtx r
= get_hard_reg_initial_val (DImode
, 29);
5718 if (GET_CODE (r
) != MEM
)
5719 r
= gen_mem_addressof (r
, NULL_TREE
);
5724 alpha_ra_ever_killed ()
5728 if (!has_hard_reg_initial_val (Pmode
, REG_RA
))
5729 return regs_ever_live
[REG_RA
];
5731 push_topmost_sequence ();
5733 pop_topmost_sequence ();
5735 return reg_set_between_p (gen_rtx_REG (Pmode
, REG_RA
), top
, NULL_RTX
);
5739 /* Return the trap mode suffix applicable to the current
5740 instruction, or NULL. */
5743 get_trap_mode_suffix ()
5745 enum attr_trap_suffix s
= get_attr_trap_suffix (current_output_insn
);
5749 case TRAP_SUFFIX_NONE
:
5752 case TRAP_SUFFIX_SU
:
5753 if (alpha_fptm
>= ALPHA_FPTM_SU
)
5757 case TRAP_SUFFIX_SUI
:
5758 if (alpha_fptm
>= ALPHA_FPTM_SUI
)
5762 case TRAP_SUFFIX_V_SV
:
5770 case ALPHA_FPTM_SUI
:
5775 case TRAP_SUFFIX_V_SV_SVI
:
5784 case ALPHA_FPTM_SUI
:
5789 case TRAP_SUFFIX_U_SU_SUI
:
5798 case ALPHA_FPTM_SUI
:
5806 /* Return the rounding mode suffix applicable to the current
5807 instruction, or NULL. */
5810 get_round_mode_suffix ()
5812 enum attr_round_suffix s
= get_attr_round_suffix (current_output_insn
);
5816 case ROUND_SUFFIX_NONE
:
5818 case ROUND_SUFFIX_NORMAL
:
5821 case ALPHA_FPRM_NORM
:
5823 case ALPHA_FPRM_MINF
:
5825 case ALPHA_FPRM_CHOP
:
5827 case ALPHA_FPRM_DYN
:
5832 case ROUND_SUFFIX_C
:
5838 /* Locate some local-dynamic symbol still in use by this function
5839 so that we can print its name in some movdi_er_tlsldm pattern. */
5842 get_some_local_dynamic_name ()
5846 if (cfun
->machine
->some_ld_name
)
5847 return cfun
->machine
->some_ld_name
;
5849 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
5851 && for_each_rtx (&PATTERN (insn
), get_some_local_dynamic_name_1
, 0))
5852 return cfun
->machine
->some_ld_name
;
5858 get_some_local_dynamic_name_1 (px
, data
)
5860 void *data ATTRIBUTE_UNUSED
;
5864 if (GET_CODE (x
) == SYMBOL_REF
)
5866 const char *str
= XSTR (x
, 0);
5867 if (str
[0] == '@' && str
[1] == 'D')
5869 cfun
->machine
->some_ld_name
= str
;
5877 /* Print an operand. Recognize special options, documented below. */
5880 print_operand (file
, x
, code
)
5890 /* Print the assembler name of the current function. */
5891 assemble_name (file
, alpha_fnname
);
5895 assemble_name (file
, get_some_local_dynamic_name ());
5900 const char *trap
= get_trap_mode_suffix ();
5901 const char *round
= get_round_mode_suffix ();
5904 fprintf (file
, (TARGET_AS_SLASH_BEFORE_SUFFIX
? "/%s%s" : "%s%s"),
5905 (trap
? trap
: ""), (round
? round
: ""));
5910 /* Generates single precision instruction suffix. */
5911 fputc ((TARGET_FLOAT_VAX
? 'f' : 's'), file
);
5915 /* Generates double precision instruction suffix. */
5916 fputc ((TARGET_FLOAT_VAX
? 'g' : 't'), file
);
5920 /* Generates a nop after a noreturn call at the very end of the
5922 if (next_real_insn (current_output_insn
) == 0)
5923 fprintf (file
, "\n\tnop");
5927 if (alpha_this_literal_sequence_number
== 0)
5928 alpha_this_literal_sequence_number
= alpha_next_sequence_number
++;
5929 fprintf (file
, "%d", alpha_this_literal_sequence_number
);
5933 if (alpha_this_gpdisp_sequence_number
== 0)
5934 alpha_this_gpdisp_sequence_number
= alpha_next_sequence_number
++;
5935 fprintf (file
, "%d", alpha_this_gpdisp_sequence_number
);
5939 if (GET_CODE (x
) == HIGH
)
5940 output_addr_const (file
, XEXP (x
, 0));
5942 output_operand_lossage ("invalid %%H value");
5949 if (GET_CODE (x
) == UNSPEC
&& XINT (x
, 1) == UNSPEC_TLSGD_CALL
)
5951 x
= XVECEXP (x
, 0, 0);
5952 lituse
= "lituse_tlsgd";
5954 else if (GET_CODE (x
) == UNSPEC
&& XINT (x
, 1) == UNSPEC_TLSLDM_CALL
)
5956 x
= XVECEXP (x
, 0, 0);
5957 lituse
= "lituse_tlsldm";
5959 else if (GET_CODE (x
) == CONST_INT
)
5960 lituse
= "lituse_jsr";
5963 output_operand_lossage ("invalid %%J value");
5967 if (x
!= const0_rtx
)
5968 fprintf (file
, "\t\t!%s!%d", lituse
, (int) INTVAL (x
));
5973 /* If this operand is the constant zero, write it as "$31". */
5974 if (GET_CODE (x
) == REG
)
5975 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
5976 else if (x
== CONST0_RTX (GET_MODE (x
)))
5977 fprintf (file
, "$31");
5979 output_operand_lossage ("invalid %%r value");
5983 /* Similar, but for floating-point. */
5984 if (GET_CODE (x
) == REG
)
5985 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
5986 else if (x
== CONST0_RTX (GET_MODE (x
)))
5987 fprintf (file
, "$f31");
5989 output_operand_lossage ("invalid %%R value");
5993 /* Write the 1's complement of a constant. */
5994 if (GET_CODE (x
) != CONST_INT
)
5995 output_operand_lossage ("invalid %%N value");
5997 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, ~ INTVAL (x
));
6001 /* Write 1 << C, for a constant C. */
6002 if (GET_CODE (x
) != CONST_INT
)
6003 output_operand_lossage ("invalid %%P value");
6005 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, (HOST_WIDE_INT
) 1 << INTVAL (x
));
6009 /* Write the high-order 16 bits of a constant, sign-extended. */
6010 if (GET_CODE (x
) != CONST_INT
)
6011 output_operand_lossage ("invalid %%h value");
6013 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
) >> 16);
6017 /* Write the low-order 16 bits of a constant, sign-extended. */
6018 if (GET_CODE (x
) != CONST_INT
)
6019 output_operand_lossage ("invalid %%L value");
6021 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
6022 (INTVAL (x
) & 0xffff) - 2 * (INTVAL (x
) & 0x8000));
6026 /* Write mask for ZAP insn. */
6027 if (GET_CODE (x
) == CONST_DOUBLE
)
6029 HOST_WIDE_INT mask
= 0;
6030 HOST_WIDE_INT value
;
6032 value
= CONST_DOUBLE_LOW (x
);
6033 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
;
6038 value
= CONST_DOUBLE_HIGH (x
);
6039 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
;
6042 mask
|= (1 << (i
+ sizeof (int)));
6044 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, mask
& 0xff);
6047 else if (GET_CODE (x
) == CONST_INT
)
6049 HOST_WIDE_INT mask
= 0, value
= INTVAL (x
);
6051 for (i
= 0; i
< 8; i
++, value
>>= 8)
6055 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, mask
);
6058 output_operand_lossage ("invalid %%m value");
6062 /* 'b', 'w', 'l', or 'q' as the value of the constant. */
6063 if (GET_CODE (x
) != CONST_INT
6064 || (INTVAL (x
) != 8 && INTVAL (x
) != 16
6065 && INTVAL (x
) != 32 && INTVAL (x
) != 64))
6066 output_operand_lossage ("invalid %%M value");
6068 fprintf (file
, "%s",
6069 (INTVAL (x
) == 8 ? "b"
6070 : INTVAL (x
) == 16 ? "w"
6071 : INTVAL (x
) == 32 ? "l"
6076 /* Similar, except do it from the mask. */
6077 if (GET_CODE (x
) == CONST_INT
)
6079 HOST_WIDE_INT value
= INTVAL (x
);
6086 if (value
== 0xffff)
6091 if (value
== 0xffffffff)
6102 else if (HOST_BITS_PER_WIDE_INT
== 32
6103 && GET_CODE (x
) == CONST_DOUBLE
6104 && CONST_DOUBLE_LOW (x
) == 0xffffffff
6105 && CONST_DOUBLE_HIGH (x
) == 0)
6110 output_operand_lossage ("invalid %%U value");
6114 /* Write the constant value divided by 8 for little-endian mode or
6115 (56 - value) / 8 for big-endian mode. */
6117 if (GET_CODE (x
) != CONST_INT
6118 || (unsigned HOST_WIDE_INT
) INTVAL (x
) >= (WORDS_BIG_ENDIAN
6121 || (INTVAL (x
) & 7) != 0)
6122 output_operand_lossage ("invalid %%s value");
6124 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
6126 ? (56 - INTVAL (x
)) / 8
6131 /* Same, except compute (64 - c) / 8 */
6133 if (GET_CODE (x
) != CONST_INT
6134 && (unsigned HOST_WIDE_INT
) INTVAL (x
) >= 64
6135 && (INTVAL (x
) & 7) != 8)
6136 output_operand_lossage ("invalid %%s value");
6138 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, (64 - INTVAL (x
)) / 8);
6143 /* On Unicos/Mk systems: use a DEX expression if the symbol
6144 clashes with a register name. */
6145 int dex
= unicosmk_need_dex (x
);
6147 fprintf (file
, "DEX(%d)", dex
);
6149 output_addr_const (file
, x
);
6153 case 'C': case 'D': case 'c': case 'd':
6154 /* Write out comparison name. */
6156 enum rtx_code c
= GET_CODE (x
);
6158 if (GET_RTX_CLASS (c
) != '<')
6159 output_operand_lossage ("invalid %%C value");
6161 else if (code
== 'D')
6162 c
= reverse_condition (c
);
6163 else if (code
== 'c')
6164 c
= swap_condition (c
);
6165 else if (code
== 'd')
6166 c
= swap_condition (reverse_condition (c
));
6169 fprintf (file
, "ule");
6171 fprintf (file
, "ult");
6172 else if (c
== UNORDERED
)
6173 fprintf (file
, "un");
6175 fprintf (file
, "%s", GET_RTX_NAME (c
));
6180 /* Write the divide or modulus operator. */
6181 switch (GET_CODE (x
))
6184 fprintf (file
, "div%s", GET_MODE (x
) == SImode
? "l" : "q");
6187 fprintf (file
, "div%su", GET_MODE (x
) == SImode
? "l" : "q");
6190 fprintf (file
, "rem%s", GET_MODE (x
) == SImode
? "l" : "q");
6193 fprintf (file
, "rem%su", GET_MODE (x
) == SImode
? "l" : "q");
6196 output_operand_lossage ("invalid %%E value");
6202 /* Write "_u" for unaligned access. */
6203 if (GET_CODE (x
) == MEM
&& GET_CODE (XEXP (x
, 0)) == AND
)
6204 fprintf (file
, "_u");
6208 if (GET_CODE (x
) == REG
)
6209 fprintf (file
, "%s", reg_names
[REGNO (x
)]);
6210 else if (GET_CODE (x
) == MEM
)
6211 output_address (XEXP (x
, 0));
6212 else if (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == UNSPEC
)
6214 switch (XINT (XEXP (x
, 0), 1))
6218 output_addr_const (file
, XVECEXP (XEXP (x
, 0), 0, 0));
6221 output_operand_lossage ("unknown relocation unspec");
6226 output_addr_const (file
, x
);
6230 output_operand_lossage ("invalid %%xn code");
6235 print_operand_address (file
, addr
)
6240 HOST_WIDE_INT offset
= 0;
6242 if (GET_CODE (addr
) == AND
)
6243 addr
= XEXP (addr
, 0);
6245 if (GET_CODE (addr
) == PLUS
6246 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
6248 offset
= INTVAL (XEXP (addr
, 1));
6249 addr
= XEXP (addr
, 0);
6252 if (GET_CODE (addr
) == LO_SUM
)
6254 const char *reloc16
, *reloclo
;
6255 rtx op1
= XEXP (addr
, 1);
6257 if (GET_CODE (op1
) == CONST
&& GET_CODE (XEXP (op1
, 0)) == UNSPEC
)
6259 op1
= XEXP (op1
, 0);
6260 switch (XINT (op1
, 1))
6264 reloclo
= (alpha_tls_size
== 16 ? "dtprel" : "dtprello");
6268 reloclo
= (alpha_tls_size
== 16 ? "tprel" : "tprello");
6271 output_operand_lossage ("unknown relocation unspec");
6275 output_addr_const (file
, XVECEXP (op1
, 0, 0));
6280 reloclo
= "gprellow";
6281 output_addr_const (file
, op1
);
6287 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, offset
);
6290 addr
= XEXP (addr
, 0);
6291 if (GET_CODE (addr
) == REG
)
6292 basereg
= REGNO (addr
);
6293 else if (GET_CODE (addr
) == SUBREG
6294 && GET_CODE (SUBREG_REG (addr
)) == REG
)
6295 basereg
= subreg_regno (addr
);
6299 fprintf (file
, "($%d)\t\t!%s", basereg
,
6300 (basereg
== 29 ? reloc16
: reloclo
));
6304 if (GET_CODE (addr
) == REG
)
6305 basereg
= REGNO (addr
);
6306 else if (GET_CODE (addr
) == SUBREG
6307 && GET_CODE (SUBREG_REG (addr
)) == REG
)
6308 basereg
= subreg_regno (addr
);
6309 else if (GET_CODE (addr
) == CONST_INT
)
6310 offset
= INTVAL (addr
);
6312 #if TARGET_ABI_OPEN_VMS
6313 else if (GET_CODE (addr
) == SYMBOL_REF
)
6315 fprintf (file
, "%s", XSTR (addr
, 0));
6318 else if (GET_CODE (addr
) == CONST
6319 && GET_CODE (XEXP (addr
, 0)) == PLUS
6320 && GET_CODE (XEXP (XEXP (addr
, 0), 0)) == SYMBOL_REF
)
6322 fprintf (file
, "%s+%d",
6323 XSTR (XEXP (XEXP (addr
, 0), 0), 0),
6324 INTVAL (XEXP (XEXP (addr
, 0), 1)));
6332 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, offset
);
6333 fprintf (file
, "($%d)", basereg
);
6336 /* Emit RTL insns to initialize the variable parts of a trampoline at
6337 TRAMP. FNADDR is an RTX for the address of the function's pure
6338 code. CXT is an RTX for the static chain value for the function.
6340 The three offset parameters are for the individual template's
6341 layout. A JMPOFS < 0 indicates that the trampoline does not
6342 contain instructions at all.
6344 We assume here that a function will be called many more times than
6345 its address is taken (e.g., it might be passed to qsort), so we
6346 take the trouble to initialize the "hint" field in the JMP insn.
6347 Note that the hint field is PC (new) + 4 * bits 13:0. */
6350 alpha_initialize_trampoline (tramp
, fnaddr
, cxt
, fnofs
, cxtofs
, jmpofs
)
6351 rtx tramp
, fnaddr
, cxt
;
6352 int fnofs
, cxtofs
, jmpofs
;
6354 rtx temp
, temp1
, addr
;
6355 /* VMS really uses DImode pointers in memory at this point. */
6356 enum machine_mode mode
= TARGET_ABI_OPEN_VMS
? Pmode
: ptr_mode
;
6358 #ifdef POINTERS_EXTEND_UNSIGNED
6359 fnaddr
= convert_memory_address (mode
, fnaddr
);
6360 cxt
= convert_memory_address (mode
, cxt
);
6363 /* Store function address and CXT. */
6364 addr
= memory_address (mode
, plus_constant (tramp
, fnofs
));
6365 emit_move_insn (gen_rtx_MEM (mode
, addr
), fnaddr
);
6366 addr
= memory_address (mode
, plus_constant (tramp
, cxtofs
));
6367 emit_move_insn (gen_rtx_MEM (mode
, addr
), cxt
);
6369 /* This has been disabled since the hint only has a 32k range, and in
6370 no existing OS is the stack within 32k of the text segment. */
6371 if (0 && jmpofs
>= 0)
6373 /* Compute hint value. */
6374 temp
= force_operand (plus_constant (tramp
, jmpofs
+4), NULL_RTX
);
6375 temp
= expand_binop (DImode
, sub_optab
, fnaddr
, temp
, temp
, 1,
6377 temp
= expand_shift (RSHIFT_EXPR
, Pmode
, temp
,
6378 build_int_2 (2, 0), NULL_RTX
, 1);
6379 temp
= expand_and (SImode
, gen_lowpart (SImode
, temp
),
6380 GEN_INT (0x3fff), 0);
6382 /* Merge in the hint. */
6383 addr
= memory_address (SImode
, plus_constant (tramp
, jmpofs
));
6384 temp1
= force_reg (SImode
, gen_rtx_MEM (SImode
, addr
));
6385 temp1
= expand_and (SImode
, temp1
, GEN_INT (0xffffc000), NULL_RTX
);
6386 temp1
= expand_binop (SImode
, ior_optab
, temp1
, temp
, temp1
, 1,
6388 emit_move_insn (gen_rtx_MEM (SImode
, addr
), temp1
);
6391 #ifdef TRANSFER_FROM_TRAMPOLINE
6392 emit_library_call (gen_rtx_SYMBOL_REF (Pmode
, "__enable_execute_stack"),
6393 0, VOIDmode
, 1, tramp
, Pmode
);
6397 emit_insn (gen_imb ());
6400 /* Determine where to put an argument to a function.
6401 Value is zero to push the argument on the stack,
6402 or a hard register in which to store the argument.
6404 MODE is the argument's machine mode.
6405 TYPE is the data type of the argument (as a tree).
6406 This is null for libcalls where that information may
6408 CUM is a variable of type CUMULATIVE_ARGS which gives info about
6409 the preceding args and about the function being called.
6410 NAMED is nonzero if this argument is a named parameter
6411 (otherwise it is an extra parameter matching an ellipsis).
6413 On Alpha the first 6 words of args are normally in registers
6414 and the rest are pushed. */
6417 function_arg (cum
, mode
, type
, named
)
6418 CUMULATIVE_ARGS cum
;
6419 enum machine_mode mode
;
6421 int named ATTRIBUTE_UNUSED
;
6426 /* Set up defaults for FP operands passed in FP registers, and
6427 integral operands passed in integer registers. */
6429 && (GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
6430 || GET_MODE_CLASS (mode
) == MODE_FLOAT
))
6435 /* ??? Irritatingly, the definition of CUMULATIVE_ARGS is different for
6436 the three platforms, so we can't avoid conditional compilation. */
6437 #if TARGET_ABI_OPEN_VMS
6439 if (mode
== VOIDmode
)
6440 return alpha_arg_info_reg_val (cum
);
6442 num_args
= cum
.num_args
;
6443 if (num_args
>= 6 || MUST_PASS_IN_STACK (mode
, type
))
6447 #if TARGET_ABI_UNICOSMK
6451 /* If this is the last argument, generate the call info word (CIW). */
6452 /* ??? We don't include the caller's line number in the CIW because
6453 I don't know how to determine it if debug infos are turned off. */
6454 if (mode
== VOIDmode
)
6463 for (i
= 0; i
< cum
.num_reg_words
&& i
< 5; i
++)
6464 if (cum
.reg_args_type
[i
])
6465 lo
|= (1 << (7 - i
));
6467 if (cum
.num_reg_words
== 6 && cum
.reg_args_type
[5])
6470 lo
|= cum
.num_reg_words
;
6472 #if HOST_BITS_PER_WIDE_INT == 32
6473 hi
= (cum
.num_args
<< 20) | cum
.num_arg_words
;
6475 lo
= lo
| ((HOST_WIDE_INT
) cum
.num_args
<< 52)
6476 | ((HOST_WIDE_INT
) cum
.num_arg_words
<< 32);
6479 ciw
= immed_double_const (lo
, hi
, DImode
);
6481 return gen_rtx_UNSPEC (DImode
, gen_rtvec (1, ciw
),
6482 UNSPEC_UMK_LOAD_CIW
);
6485 size
= ALPHA_ARG_SIZE (mode
, type
, named
);
6486 num_args
= cum
.num_reg_words
;
6487 if (MUST_PASS_IN_STACK (mode
, type
)
6488 || cum
.num_reg_words
+ size
> 6 || cum
.force_stack
)
6490 else if (type
&& TYPE_MODE (type
) == BLKmode
)
6494 reg1
= gen_rtx_REG (DImode
, num_args
+ 16);
6495 reg1
= gen_rtx_EXPR_LIST (DImode
, reg1
, const0_rtx
);
6497 /* The argument fits in two registers. Note that we still need to
6498 reserve a register for empty structures. */
6502 return gen_rtx_PARALLEL (mode
, gen_rtvec (1, reg1
));
6505 reg2
= gen_rtx_REG (DImode
, num_args
+ 17);
6506 reg2
= gen_rtx_EXPR_LIST (DImode
, reg2
, GEN_INT (8));
6507 return gen_rtx_PARALLEL (mode
, gen_rtvec (2, reg1
, reg2
));
6517 /* VOID is passed as a special flag for "last argument". */
6518 if (type
== void_type_node
)
6520 else if (MUST_PASS_IN_STACK (mode
, type
))
6522 else if (FUNCTION_ARG_PASS_BY_REFERENCE (cum
, mode
, type
, named
))
6525 #endif /* TARGET_ABI_UNICOSMK */
6526 #endif /* TARGET_ABI_OPEN_VMS */
6528 return gen_rtx_REG (mode
, num_args
+ basereg
);
6532 alpha_build_va_list ()
6534 tree base
, ofs
, record
, type_decl
;
6536 if (TARGET_ABI_OPEN_VMS
|| TARGET_ABI_UNICOSMK
)
6537 return ptr_type_node
;
6539 record
= (*lang_hooks
.types
.make_type
) (RECORD_TYPE
);
6540 type_decl
= build_decl (TYPE_DECL
, get_identifier ("__va_list_tag"), record
);
6541 TREE_CHAIN (record
) = type_decl
;
6542 TYPE_NAME (record
) = type_decl
;
6544 /* C++? SET_IS_AGGR_TYPE (record, 1); */
6546 ofs
= build_decl (FIELD_DECL
, get_identifier ("__offset"),
6548 DECL_FIELD_CONTEXT (ofs
) = record
;
6550 base
= build_decl (FIELD_DECL
, get_identifier ("__base"),
6552 DECL_FIELD_CONTEXT (base
) = record
;
6553 TREE_CHAIN (base
) = ofs
;
6555 TYPE_FIELDS (record
) = base
;
6556 layout_type (record
);
6561 /* Perform any needed actions needed for a function that is receiving a
6562 variable number of arguments.
6564 On the Alpha, we allocate space for all 12 arg registers, but only
6565 push those that are remaining. However, if NO registers need to be
6566 saved, don't allocate any space. This is not only because we won't
6567 need the space, but because AP includes the current_pretend_args_size
6568 and we don't want to mess up any ap-relative addresses already made.
6570 If we are not to use the floating-point registers, save the integer
6571 registers where we would put the floating-point registers. This is
6572 not the most efficient way to implement varargs with just one register
6573 class, but it isn't worth doing anything more efficient in this rare
6577 alpha_setup_incoming_varargs(cum
, mode
, type
, pretend_size
, no_rtl
)
6578 CUMULATIVE_ARGS cum
;
6579 enum machine_mode mode
;
6589 int set
= get_varargs_alias_set ();
6592 tmp
= gen_rtx_MEM (BLKmode
,
6593 plus_constant (virtual_incoming_args_rtx
,
6594 (cum
+ 6) * UNITS_PER_WORD
));
6595 set_mem_alias_set (tmp
, set
);
6596 move_block_from_reg (16 + cum
, tmp
, 6 - cum
, (6 - cum
) * UNITS_PER_WORD
);
6598 tmp
= gen_rtx_MEM (BLKmode
,
6599 plus_constant (virtual_incoming_args_rtx
,
6600 cum
* UNITS_PER_WORD
));
6601 set_mem_alias_set (tmp
, set
);
6602 move_block_from_reg (16 + (TARGET_FPREGS
? 32 : 0) + cum
, tmp
,
6603 6 - cum
, (6 - cum
) * UNITS_PER_WORD
);
6605 *pretend_size
= 12 * UNITS_PER_WORD
;
6609 alpha_va_start (valist
, nextarg
)
6611 rtx nextarg ATTRIBUTE_UNUSED
;
6613 HOST_WIDE_INT offset
;
6614 tree t
, offset_field
, base_field
;
6616 if (TREE_CODE (TREE_TYPE (valist
)) == ERROR_MARK
)
6619 if (TARGET_ABI_UNICOSMK
)
6620 std_expand_builtin_va_start (valist
, nextarg
);
6622 /* For Unix, SETUP_INCOMING_VARARGS moves the starting address base
6623 up by 48, storing fp arg registers in the first 48 bytes, and the
6624 integer arg registers in the next 48 bytes. This is only done,
6625 however, if any integer registers need to be stored.
6627 If no integer registers need be stored, then we must subtract 48
6628 in order to account for the integer arg registers which are counted
6629 in argsize above, but which are not actually stored on the stack.
6630 Must further be careful here about structures straddling the last
6631 integer argument register; that futzes with pretend_args_size,
6632 which changes the meaning of AP. */
6635 offset
= TARGET_ABI_OPEN_VMS
? UNITS_PER_WORD
: 6 * UNITS_PER_WORD
;
6637 offset
= -6 * UNITS_PER_WORD
+ current_function_pretend_args_size
;
6639 if (TARGET_ABI_OPEN_VMS
)
6641 nextarg
= plus_constant (nextarg
, offset
);
6642 nextarg
= plus_constant (nextarg
, NUM_ARGS
* UNITS_PER_WORD
);
6643 t
= build (MODIFY_EXPR
, TREE_TYPE (valist
), valist
,
6644 make_tree (ptr_type_node
, nextarg
));
6645 TREE_SIDE_EFFECTS (t
) = 1;
6647 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
6651 base_field
= TYPE_FIELDS (TREE_TYPE (valist
));
6652 offset_field
= TREE_CHAIN (base_field
);
6654 base_field
= build (COMPONENT_REF
, TREE_TYPE (base_field
),
6655 valist
, base_field
);
6656 offset_field
= build (COMPONENT_REF
, TREE_TYPE (offset_field
),
6657 valist
, offset_field
);
6659 t
= make_tree (ptr_type_node
, virtual_incoming_args_rtx
);
6660 t
= build (PLUS_EXPR
, ptr_type_node
, t
, build_int_2 (offset
, 0));
6661 t
= build (MODIFY_EXPR
, TREE_TYPE (base_field
), base_field
, t
);
6662 TREE_SIDE_EFFECTS (t
) = 1;
6663 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
6665 t
= build_int_2 (NUM_ARGS
* UNITS_PER_WORD
, 0);
6666 t
= build (MODIFY_EXPR
, TREE_TYPE (offset_field
), offset_field
, t
);
6667 TREE_SIDE_EFFECTS (t
) = 1;
6668 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
6673 alpha_va_arg (valist
, type
)
6677 tree t
, type_size
, rounded_size
;
6678 tree offset_field
, base_field
, addr_tree
, addend
;
6679 tree wide_type
, wide_ofs
;
6682 if (TARGET_ABI_OPEN_VMS
|| TARGET_ABI_UNICOSMK
)
6683 return std_expand_builtin_va_arg (valist
, type
);
6685 if (type
== error_mark_node
6686 || (type_size
= TYPE_SIZE_UNIT (TYPE_MAIN_VARIANT (type
))) == NULL
6687 || TREE_OVERFLOW (type_size
))
6688 rounded_size
= size_zero_node
;
6690 rounded_size
= fold (build (MULT_EXPR
, sizetype
,
6691 fold (build (TRUNC_DIV_EXPR
, sizetype
,
6692 fold (build (PLUS_EXPR
, sizetype
,
6698 base_field
= TYPE_FIELDS (TREE_TYPE (valist
));
6699 offset_field
= TREE_CHAIN (base_field
);
6701 base_field
= build (COMPONENT_REF
, TREE_TYPE (base_field
),
6702 valist
, base_field
);
6703 offset_field
= build (COMPONENT_REF
, TREE_TYPE (offset_field
),
6704 valist
, offset_field
);
6706 /* If the type could not be passed in registers, skip the block
6707 reserved for the registers. */
6708 if (MUST_PASS_IN_STACK (TYPE_MODE (type
), type
))
6710 t
= build (MODIFY_EXPR
, TREE_TYPE (offset_field
), offset_field
,
6711 build (MAX_EXPR
, TREE_TYPE (offset_field
),
6712 offset_field
, build_int_2 (6*8, 0)));
6713 TREE_SIDE_EFFECTS (t
) = 1;
6714 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
6717 wide_type
= make_signed_type (64);
6718 wide_ofs
= save_expr (build1 (CONVERT_EXPR
, wide_type
, offset_field
));
6722 if (TYPE_MODE (type
) == TFmode
|| TYPE_MODE (type
) == TCmode
)
6725 rounded_size
= size_int (UNITS_PER_WORD
);
6727 else if (FLOAT_TYPE_P (type
))
6729 tree fpaddend
, cond
;
6731 fpaddend
= fold (build (PLUS_EXPR
, TREE_TYPE (addend
),
6732 addend
, build_int_2 (-6*8, 0)));
6734 cond
= fold (build (LT_EXPR
, integer_type_node
,
6735 wide_ofs
, build_int_2 (6*8, 0)));
6737 addend
= fold (build (COND_EXPR
, TREE_TYPE (addend
), cond
,
6741 addr_tree
= build (PLUS_EXPR
, TREE_TYPE (base_field
),
6742 base_field
, addend
);
6744 addr
= expand_expr (addr_tree
, NULL_RTX
, Pmode
, EXPAND_NORMAL
);
6745 addr
= copy_to_reg (addr
);
6747 t
= build (MODIFY_EXPR
, TREE_TYPE (offset_field
), offset_field
,
6748 build (PLUS_EXPR
, TREE_TYPE (offset_field
),
6749 offset_field
, rounded_size
));
6750 TREE_SIDE_EFFECTS (t
) = 1;
6751 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
6755 addr
= force_reg (Pmode
, addr
);
6756 addr
= gen_rtx_MEM (Pmode
, addr
);
6766 ALPHA_BUILTIN_CMPBGE
,
6767 ALPHA_BUILTIN_EXTBL
,
6768 ALPHA_BUILTIN_EXTWL
,
6769 ALPHA_BUILTIN_EXTLL
,
6770 ALPHA_BUILTIN_EXTQL
,
6771 ALPHA_BUILTIN_EXTWH
,
6772 ALPHA_BUILTIN_EXTLH
,
6773 ALPHA_BUILTIN_EXTQH
,
6774 ALPHA_BUILTIN_INSBL
,
6775 ALPHA_BUILTIN_INSWL
,
6776 ALPHA_BUILTIN_INSLL
,
6777 ALPHA_BUILTIN_INSQL
,
6778 ALPHA_BUILTIN_INSWH
,
6779 ALPHA_BUILTIN_INSLH
,
6780 ALPHA_BUILTIN_INSQH
,
6781 ALPHA_BUILTIN_MSKBL
,
6782 ALPHA_BUILTIN_MSKWL
,
6783 ALPHA_BUILTIN_MSKLL
,
6784 ALPHA_BUILTIN_MSKQL
,
6785 ALPHA_BUILTIN_MSKWH
,
6786 ALPHA_BUILTIN_MSKLH
,
6787 ALPHA_BUILTIN_MSKQH
,
6788 ALPHA_BUILTIN_UMULH
,
6790 ALPHA_BUILTIN_ZAPNOT
,
6791 ALPHA_BUILTIN_AMASK
,
6792 ALPHA_BUILTIN_IMPLVER
,
6794 ALPHA_BUILTIN_THREAD_POINTER
,
6795 ALPHA_BUILTIN_SET_THREAD_POINTER
,
6798 ALPHA_BUILTIN_MINUB8
,
6799 ALPHA_BUILTIN_MINSB8
,
6800 ALPHA_BUILTIN_MINUW4
,
6801 ALPHA_BUILTIN_MINSW4
,
6802 ALPHA_BUILTIN_MAXUB8
,
6803 ALPHA_BUILTIN_MAXSB8
,
6804 ALPHA_BUILTIN_MAXUW4
,
6805 ALPHA_BUILTIN_MAXSW4
,
6809 ALPHA_BUILTIN_UNPKBL
,
6810 ALPHA_BUILTIN_UNPKBW
,
6815 ALPHA_BUILTIN_CTPOP
,
6820 static unsigned int const code_for_builtin
[ALPHA_BUILTIN_max
] = {
6821 CODE_FOR_builtin_cmpbge
,
6822 CODE_FOR_builtin_extbl
,
6823 CODE_FOR_builtin_extwl
,
6824 CODE_FOR_builtin_extll
,
6825 CODE_FOR_builtin_extql
,
6826 CODE_FOR_builtin_extwh
,
6827 CODE_FOR_builtin_extlh
,
6828 CODE_FOR_builtin_extqh
,
6829 CODE_FOR_builtin_insbl
,
6830 CODE_FOR_builtin_inswl
,
6831 CODE_FOR_builtin_insll
,
6832 CODE_FOR_builtin_insql
,
6833 CODE_FOR_builtin_inswh
,
6834 CODE_FOR_builtin_inslh
,
6835 CODE_FOR_builtin_insqh
,
6836 CODE_FOR_builtin_mskbl
,
6837 CODE_FOR_builtin_mskwl
,
6838 CODE_FOR_builtin_mskll
,
6839 CODE_FOR_builtin_mskql
,
6840 CODE_FOR_builtin_mskwh
,
6841 CODE_FOR_builtin_msklh
,
6842 CODE_FOR_builtin_mskqh
,
6843 CODE_FOR_umuldi3_highpart
,
6844 CODE_FOR_builtin_zap
,
6845 CODE_FOR_builtin_zapnot
,
6846 CODE_FOR_builtin_amask
,
6847 CODE_FOR_builtin_implver
,
6848 CODE_FOR_builtin_rpcc
,
6853 CODE_FOR_builtin_minub8
,
6854 CODE_FOR_builtin_minsb8
,
6855 CODE_FOR_builtin_minuw4
,
6856 CODE_FOR_builtin_minsw4
,
6857 CODE_FOR_builtin_maxub8
,
6858 CODE_FOR_builtin_maxsb8
,
6859 CODE_FOR_builtin_maxuw4
,
6860 CODE_FOR_builtin_maxsw4
,
6861 CODE_FOR_builtin_perr
,
6862 CODE_FOR_builtin_pklb
,
6863 CODE_FOR_builtin_pkwb
,
6864 CODE_FOR_builtin_unpkbl
,
6865 CODE_FOR_builtin_unpkbw
,
6868 CODE_FOR_builtin_cttz
,
6869 CODE_FOR_builtin_ctlz
,
6870 CODE_FOR_builtin_ctpop
6873 struct alpha_builtin_def
6876 enum alpha_builtin code
;
6877 unsigned int target_mask
;
6880 static struct alpha_builtin_def
const zero_arg_builtins
[] = {
6881 { "__builtin_alpha_implver", ALPHA_BUILTIN_IMPLVER
, 0 },
6882 { "__builtin_alpha_rpcc", ALPHA_BUILTIN_RPCC
, 0 }
6885 static struct alpha_builtin_def
const one_arg_builtins
[] = {
6886 { "__builtin_alpha_amask", ALPHA_BUILTIN_AMASK
, 0 },
6887 { "__builtin_alpha_pklb", ALPHA_BUILTIN_PKLB
, MASK_MAX
},
6888 { "__builtin_alpha_pkwb", ALPHA_BUILTIN_PKWB
, MASK_MAX
},
6889 { "__builtin_alpha_unpkbl", ALPHA_BUILTIN_UNPKBL
, MASK_MAX
},
6890 { "__builtin_alpha_unpkbw", ALPHA_BUILTIN_UNPKBW
, MASK_MAX
},
6891 { "__builtin_alpha_cttz", ALPHA_BUILTIN_CTTZ
, MASK_CIX
},
6892 { "__builtin_alpha_ctlz", ALPHA_BUILTIN_CTLZ
, MASK_CIX
},
6893 { "__builtin_alpha_ctpop", ALPHA_BUILTIN_CTPOP
, MASK_CIX
}
6896 static struct alpha_builtin_def
const two_arg_builtins
[] = {
6897 { "__builtin_alpha_cmpbge", ALPHA_BUILTIN_CMPBGE
, 0 },
6898 { "__builtin_alpha_extbl", ALPHA_BUILTIN_EXTBL
, 0 },
6899 { "__builtin_alpha_extwl", ALPHA_BUILTIN_EXTWL
, 0 },
6900 { "__builtin_alpha_extll", ALPHA_BUILTIN_EXTLL
, 0 },
6901 { "__builtin_alpha_extql", ALPHA_BUILTIN_EXTQL
, 0 },
6902 { "__builtin_alpha_extwh", ALPHA_BUILTIN_EXTWH
, 0 },
6903 { "__builtin_alpha_extlh", ALPHA_BUILTIN_EXTLH
, 0 },
6904 { "__builtin_alpha_extqh", ALPHA_BUILTIN_EXTQH
, 0 },
6905 { "__builtin_alpha_insbl", ALPHA_BUILTIN_INSBL
, 0 },
6906 { "__builtin_alpha_inswl", ALPHA_BUILTIN_INSWL
, 0 },
6907 { "__builtin_alpha_insll", ALPHA_BUILTIN_INSLL
, 0 },
6908 { "__builtin_alpha_insql", ALPHA_BUILTIN_INSQL
, 0 },
6909 { "__builtin_alpha_inswh", ALPHA_BUILTIN_INSWH
, 0 },
6910 { "__builtin_alpha_inslh", ALPHA_BUILTIN_INSLH
, 0 },
6911 { "__builtin_alpha_insqh", ALPHA_BUILTIN_INSQH
, 0 },
6912 { "__builtin_alpha_mskbl", ALPHA_BUILTIN_MSKBL
, 0 },
6913 { "__builtin_alpha_mskwl", ALPHA_BUILTIN_MSKWL
, 0 },
6914 { "__builtin_alpha_mskll", ALPHA_BUILTIN_MSKLL
, 0 },
6915 { "__builtin_alpha_mskql", ALPHA_BUILTIN_MSKQL
, 0 },
6916 { "__builtin_alpha_mskwh", ALPHA_BUILTIN_MSKWH
, 0 },
6917 { "__builtin_alpha_msklh", ALPHA_BUILTIN_MSKLH
, 0 },
6918 { "__builtin_alpha_mskqh", ALPHA_BUILTIN_MSKQH
, 0 },
6919 { "__builtin_alpha_umulh", ALPHA_BUILTIN_UMULH
, 0 },
6920 { "__builtin_alpha_zap", ALPHA_BUILTIN_ZAP
, 0 },
6921 { "__builtin_alpha_zapnot", ALPHA_BUILTIN_ZAPNOT
, 0 },
6922 { "__builtin_alpha_minub8", ALPHA_BUILTIN_MINUB8
, MASK_MAX
},
6923 { "__builtin_alpha_minsb8", ALPHA_BUILTIN_MINSB8
, MASK_MAX
},
6924 { "__builtin_alpha_minuw4", ALPHA_BUILTIN_MINUW4
, MASK_MAX
},
6925 { "__builtin_alpha_minsw4", ALPHA_BUILTIN_MINSW4
, MASK_MAX
},
6926 { "__builtin_alpha_maxub8", ALPHA_BUILTIN_MAXUB8
, MASK_MAX
},
6927 { "__builtin_alpha_maxsb8", ALPHA_BUILTIN_MAXSB8
, MASK_MAX
},
6928 { "__builtin_alpha_maxuw4", ALPHA_BUILTIN_MAXUW4
, MASK_MAX
},
6929 { "__builtin_alpha_maxsw4", ALPHA_BUILTIN_MAXSW4
, MASK_MAX
},
6930 { "__builtin_alpha_perr", ALPHA_BUILTIN_PERR
, MASK_MAX
}
6934 alpha_init_builtins ()
6936 const struct alpha_builtin_def
*p
;
6940 ftype
= build_function_type (long_integer_type_node
, void_list_node
);
6942 p
= zero_arg_builtins
;
6943 for (i
= 0; i
< ARRAY_SIZE (zero_arg_builtins
); ++i
, ++p
)
6944 if ((target_flags
& p
->target_mask
) == p
->target_mask
)
6945 builtin_function (p
->name
, ftype
, p
->code
, BUILT_IN_MD
,
6948 ftype
= build_function_type_list (long_integer_type_node
,
6949 long_integer_type_node
, NULL_TREE
);
6951 p
= one_arg_builtins
;
6952 for (i
= 0; i
< ARRAY_SIZE (one_arg_builtins
); ++i
, ++p
)
6953 if ((target_flags
& p
->target_mask
) == p
->target_mask
)
6954 builtin_function (p
->name
, ftype
, p
->code
, BUILT_IN_MD
,
6957 ftype
= build_function_type_list (long_integer_type_node
,
6958 long_integer_type_node
,
6959 long_integer_type_node
, NULL_TREE
);
6961 p
= two_arg_builtins
;
6962 for (i
= 0; i
< ARRAY_SIZE (two_arg_builtins
); ++i
, ++p
)
6963 if ((target_flags
& p
->target_mask
) == p
->target_mask
)
6964 builtin_function (p
->name
, ftype
, p
->code
, BUILT_IN_MD
,
6967 ftype
= build_function_type (ptr_type_node
, void_list_node
);
6968 builtin_function ("__builtin_thread_pointer", ftype
,
6969 ALPHA_BUILTIN_THREAD_POINTER
, BUILT_IN_MD
,
6972 ftype
= build_function_type_list (void_type_node
, ptr_type_node
, NULL_TREE
);
6973 builtin_function ("__builtin_set_thread_pointer", ftype
,
6974 ALPHA_BUILTIN_SET_THREAD_POINTER
, BUILT_IN_MD
,
6978 /* Expand an expression EXP that calls a built-in function,
6979 with result going to TARGET if that's convenient
6980 (and in mode MODE if that's convenient).
6981 SUBTARGET may be used as the target for computing one of EXP's operands.
6982 IGNORE is nonzero if the value is to be ignored. */
6985 alpha_expand_builtin (exp
, target
, subtarget
, mode
, ignore
)
6988 rtx subtarget ATTRIBUTE_UNUSED
;
6989 enum machine_mode mode ATTRIBUTE_UNUSED
;
6990 int ignore ATTRIBUTE_UNUSED
;
6994 tree fndecl
= TREE_OPERAND (TREE_OPERAND (exp
, 0), 0);
6995 unsigned int fcode
= DECL_FUNCTION_CODE (fndecl
);
6996 tree arglist
= TREE_OPERAND (exp
, 1);
6997 enum insn_code icode
;
6998 rtx op
[MAX_ARGS
], pat
;
7002 if (fcode
>= ALPHA_BUILTIN_max
)
7003 internal_error ("bad builtin fcode");
7004 icode
= code_for_builtin
[fcode
];
7006 internal_error ("bad builtin fcode");
7008 nonvoid
= TREE_TYPE (TREE_TYPE (fndecl
)) != void_type_node
;
7010 for (arglist
= TREE_OPERAND (exp
, 1), arity
= 0;
7012 arglist
= TREE_CHAIN (arglist
), arity
++)
7014 const struct insn_operand_data
*insn_op
;
7016 tree arg
= TREE_VALUE (arglist
);
7017 if (arg
== error_mark_node
)
7019 if (arity
> MAX_ARGS
)
7022 insn_op
= &insn_data
[icode
].operand
[arity
+ nonvoid
];
7024 op
[arity
] = expand_expr (arg
, NULL_RTX
, insn_op
->mode
, 0);
7026 if (!(*insn_op
->predicate
) (op
[arity
], insn_op
->mode
))
7027 op
[arity
] = copy_to_mode_reg (insn_op
->mode
, op
[arity
]);
7032 enum machine_mode tmode
= insn_data
[icode
].operand
[0].mode
;
7034 || GET_MODE (target
) != tmode
7035 || !(*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
7036 target
= gen_reg_rtx (tmode
);
7042 pat
= GEN_FCN (icode
) (target
);
7046 pat
= GEN_FCN (icode
) (target
, op
[0]);
7048 pat
= GEN_FCN (icode
) (op
[0]);
7051 pat
= GEN_FCN (icode
) (target
, op
[0], op
[1]);
7066 /* This page contains routines that are used to determine what the function
7067 prologue and epilogue code will do and write them out. */
7069 /* Compute the size of the save area in the stack. */
7071 /* These variables are used for communication between the following functions.
7072 They indicate various things about the current function being compiled
7073 that are used to tell what kind of prologue, epilogue and procedure
7074 descriptior to generate. */
7076 /* Nonzero if we need a stack procedure. */
7077 enum alpha_procedure_types
{PT_NULL
= 0, PT_REGISTER
= 1, PT_STACK
= 2};
7078 static enum alpha_procedure_types alpha_procedure_type
;
7080 /* Register number (either FP or SP) that is used to unwind the frame. */
7081 static int vms_unwind_regno
;
7083 /* Register number used to save FP. We need not have one for RA since
7084 we don't modify it for register procedures. This is only defined
7085 for register frame procedures. */
7086 static int vms_save_fp_regno
;
7088 /* Register number used to reference objects off our PV. */
7089 static int vms_base_regno
;
7091 /* Compute register masks for saved registers. */
7094 alpha_sa_mask (imaskP
, fmaskP
)
7095 unsigned long *imaskP
;
7096 unsigned long *fmaskP
;
7098 unsigned long imask
= 0;
7099 unsigned long fmask
= 0;
7102 /* Irritatingly, there are two kinds of thunks -- those created with
7103 TARGET_ASM_OUTPUT_MI_THUNK and those with DECL_THUNK_P that go
7104 through the regular part of the compiler. In the
7105 TARGET_ASM_OUTPUT_MI_THUNK case we don't have valid register life
7106 info, but assemble_start_function wants to output .frame and
7107 .mask directives. */
7108 if (current_function_is_thunk
&& !no_new_pseudos
)
7115 if (TARGET_ABI_OPEN_VMS
&& alpha_procedure_type
== PT_STACK
)
7116 imask
|= (1L << HARD_FRAME_POINTER_REGNUM
);
7118 /* One for every register we have to save. */
7119 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
7120 if (! fixed_regs
[i
] && ! call_used_regs
[i
]
7121 && regs_ever_live
[i
] && i
!= REG_RA
7122 && (!TARGET_ABI_UNICOSMK
|| i
!= HARD_FRAME_POINTER_REGNUM
))
7127 fmask
|= (1L << (i
- 32));
7130 /* We need to restore these for the handler. */
7131 if (current_function_calls_eh_return
)
7134 unsigned regno
= EH_RETURN_DATA_REGNO (i
);
7135 if (regno
== INVALID_REGNUM
)
7137 imask
|= 1L << regno
;
7140 /* If any register spilled, then spill the return address also. */
7141 /* ??? This is required by the Digital stack unwind specification
7142 and isn't needed if we're doing Dwarf2 unwinding. */
7143 if (imask
|| fmask
|| alpha_ra_ever_killed ())
7144 imask
|= (1L << REG_RA
);
7153 unsigned long mask
[2];
7157 alpha_sa_mask (&mask
[0], &mask
[1]);
7159 if (TARGET_ABI_UNICOSMK
)
7161 if (mask
[0] || mask
[1])
7166 for (j
= 0; j
< 2; ++j
)
7167 for (i
= 0; i
< 32; ++i
)
7168 if ((mask
[j
] >> i
) & 1)
7172 if (TARGET_ABI_UNICOSMK
)
7174 /* We might not need to generate a frame if we don't make any calls
7175 (including calls to __T3E_MISMATCH if this is a vararg function),
7176 don't have any local variables which require stack slots, don't
7177 use alloca and have not determined that we need a frame for other
7180 alpha_procedure_type
7181 = (sa_size
|| get_frame_size() != 0
7182 || current_function_outgoing_args_size
7183 || current_function_stdarg
|| current_function_calls_alloca
7184 || frame_pointer_needed
)
7185 ? PT_STACK
: PT_REGISTER
;
7187 /* Always reserve space for saving callee-saved registers if we
7188 need a frame as required by the calling convention. */
7189 if (alpha_procedure_type
== PT_STACK
)
7192 else if (TARGET_ABI_OPEN_VMS
)
7194 /* Start by assuming we can use a register procedure if we don't
7195 make any calls (REG_RA not used) or need to save any
7196 registers and a stack procedure if we do. */
7197 if ((mask
[0] >> REG_RA
) & 1)
7198 alpha_procedure_type
= PT_STACK
;
7199 else if (get_frame_size() != 0)
7200 alpha_procedure_type
= PT_REGISTER
;
7202 alpha_procedure_type
= PT_NULL
;
7204 /* Don't reserve space for saving FP & RA yet. Do that later after we've
7205 made the final decision on stack procedure vs register procedure. */
7206 if (alpha_procedure_type
== PT_STACK
)
7209 /* Decide whether to refer to objects off our PV via FP or PV.
7210 If we need FP for something else or if we receive a nonlocal
7211 goto (which expects PV to contain the value), we must use PV.
7212 Otherwise, start by assuming we can use FP. */
7215 = (frame_pointer_needed
7216 || current_function_has_nonlocal_label
7217 || alpha_procedure_type
== PT_STACK
7218 || current_function_outgoing_args_size
)
7219 ? REG_PV
: HARD_FRAME_POINTER_REGNUM
;
7221 /* If we want to copy PV into FP, we need to find some register
7222 in which to save FP. */
7224 vms_save_fp_regno
= -1;
7225 if (vms_base_regno
== HARD_FRAME_POINTER_REGNUM
)
7226 for (i
= 0; i
< 32; i
++)
7227 if (! fixed_regs
[i
] && call_used_regs
[i
] && ! regs_ever_live
[i
])
7228 vms_save_fp_regno
= i
;
7230 if (vms_save_fp_regno
== -1 && alpha_procedure_type
== PT_REGISTER
)
7231 vms_base_regno
= REG_PV
, alpha_procedure_type
= PT_STACK
;
7232 else if (alpha_procedure_type
== PT_NULL
)
7233 vms_base_regno
= REG_PV
;
7235 /* Stack unwinding should be done via FP unless we use it for PV. */
7236 vms_unwind_regno
= (vms_base_regno
== REG_PV
7237 ? HARD_FRAME_POINTER_REGNUM
: STACK_POINTER_REGNUM
);
7239 /* If this is a stack procedure, allow space for saving FP and RA. */
7240 if (alpha_procedure_type
== PT_STACK
)
7245 /* Our size must be even (multiple of 16 bytes). */
7253 /* Define the offset between two registers, one to be eliminated,
7254 and the other its replacement, at the start of a routine. */
7257 alpha_initial_elimination_offset(from
, to
)
7258 unsigned int from
, to
;
7262 ret
= alpha_sa_size ();
7263 ret
+= ALPHA_ROUND (current_function_outgoing_args_size
);
7265 if (from
== FRAME_POINTER_REGNUM
)
7267 else if (from
== ARG_POINTER_REGNUM
)
7268 ret
+= (ALPHA_ROUND (get_frame_size ()
7269 + current_function_pretend_args_size
)
7270 - current_function_pretend_args_size
);
7278 alpha_pv_save_size ()
7281 return alpha_procedure_type
== PT_STACK
? 8 : 0;
7288 return vms_unwind_regno
== HARD_FRAME_POINTER_REGNUM
;
7291 #if TARGET_ABI_OPEN_VMS
7293 const struct attribute_spec vms_attribute_table
[] =
7295 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
7296 { "overlaid", 0, 0, true, false, false, NULL
},
7297 { "global", 0, 0, true, false, false, NULL
},
7298 { "initialize", 0, 0, true, false, false, NULL
},
7299 { NULL
, 0, 0, false, false, false, NULL
}
7305 find_lo_sum_using_gp (px
, data
)
7307 void *data ATTRIBUTE_UNUSED
;
7309 return GET_CODE (*px
) == LO_SUM
&& XEXP (*px
, 0) == pic_offset_table_rtx
;
7313 alpha_find_lo_sum_using_gp (insn
)
7316 return for_each_rtx (&PATTERN (insn
), find_lo_sum_using_gp
, NULL
) > 0;
7320 alpha_does_function_need_gp ()
7324 /* The GP being variable is an OSF abi thing. */
7325 if (! TARGET_ABI_OSF
)
7328 if (TARGET_PROFILING_NEEDS_GP
&& current_function_profile
)
7331 if (current_function_is_thunk
)
7334 /* If we need a GP (we have a LDSYM insn or a CALL_INSN), load it first.
7335 Even if we are a static function, we still need to do this in case
7336 our address is taken and passed to something like qsort. */
7338 push_topmost_sequence ();
7339 insn
= get_insns ();
7340 pop_topmost_sequence ();
7342 for (; insn
; insn
= NEXT_INSN (insn
))
7344 && GET_CODE (PATTERN (insn
)) != USE
7345 && GET_CODE (PATTERN (insn
)) != CLOBBER
7346 && get_attr_usegp (insn
))
7352 /* Write a version stamp. Don't write anything if we are running as a
7353 cross-compiler. Otherwise, use the versions in /usr/include/stamp.h. */
7360 alpha_write_verstamp (file
)
7361 FILE *file ATTRIBUTE_UNUSED
;
7364 fprintf (file
, "\t.verstamp %d %d\n", MS_STAMP
, LS_STAMP
);
7368 /* Helper function to set RTX_FRAME_RELATED_P on instructions, including
7372 set_frame_related_p ()
7374 rtx seq
= get_insns ();
7385 while (insn
!= NULL_RTX
)
7387 RTX_FRAME_RELATED_P (insn
) = 1;
7388 insn
= NEXT_INSN (insn
);
7390 seq
= emit_insn (seq
);
7394 seq
= emit_insn (seq
);
7395 RTX_FRAME_RELATED_P (seq
) = 1;
7400 #define FRP(exp) (start_sequence (), exp, set_frame_related_p ())
7402 /* Write function prologue. */
7404 /* On vms we have two kinds of functions:
7406 - stack frame (PROC_STACK)
7407 these are 'normal' functions with local vars and which are
7408 calling other functions
7409 - register frame (PROC_REGISTER)
7410 keeps all data in registers, needs no stack
7412 We must pass this to the assembler so it can generate the
7413 proper pdsc (procedure descriptor)
7414 This is done with the '.pdesc' command.
7416 On not-vms, we don't really differentiate between the two, as we can
7417 simply allocate stack without saving registers. */
7420 alpha_expand_prologue ()
7422 /* Registers to save. */
7423 unsigned long imask
= 0;
7424 unsigned long fmask
= 0;
7425 /* Stack space needed for pushing registers clobbered by us. */
7426 HOST_WIDE_INT sa_size
;
7427 /* Complete stack size needed. */
7428 HOST_WIDE_INT frame_size
;
7429 /* Offset from base reg to register save area. */
7430 HOST_WIDE_INT reg_offset
;
7434 sa_size
= alpha_sa_size ();
7436 frame_size
= get_frame_size ();
7437 if (TARGET_ABI_OPEN_VMS
)
7438 frame_size
= ALPHA_ROUND (sa_size
7439 + (alpha_procedure_type
== PT_STACK
? 8 : 0)
7441 + current_function_pretend_args_size
);
7442 else if (TARGET_ABI_UNICOSMK
)
7443 /* We have to allocate space for the DSIB if we generate a frame. */
7444 frame_size
= ALPHA_ROUND (sa_size
7445 + (alpha_procedure_type
== PT_STACK
? 48 : 0))
7446 + ALPHA_ROUND (frame_size
7447 + current_function_outgoing_args_size
);
7449 frame_size
= (ALPHA_ROUND (current_function_outgoing_args_size
)
7451 + ALPHA_ROUND (frame_size
7452 + current_function_pretend_args_size
));
7454 if (TARGET_ABI_OPEN_VMS
)
7457 reg_offset
= ALPHA_ROUND (current_function_outgoing_args_size
);
7459 alpha_sa_mask (&imask
, &fmask
);
7461 /* Emit an insn to reload GP, if needed. */
7464 alpha_function_needs_gp
= alpha_does_function_need_gp ();
7465 if (alpha_function_needs_gp
)
7466 emit_insn (gen_prologue_ldgp ());
7469 /* TARGET_PROFILING_NEEDS_GP actually implies that we need to insert
7470 the call to mcount ourselves, rather than having the linker do it
7471 magically in response to -pg. Since _mcount has special linkage,
7472 don't represent the call as a call. */
7473 if (TARGET_PROFILING_NEEDS_GP
&& current_function_profile
)
7474 emit_insn (gen_prologue_mcount ());
7476 if (TARGET_ABI_UNICOSMK
)
7477 unicosmk_gen_dsib (&imask
);
7479 /* Adjust the stack by the frame size. If the frame size is > 4096
7480 bytes, we need to be sure we probe somewhere in the first and last
7481 4096 bytes (we can probably get away without the latter test) and
7482 every 8192 bytes in between. If the frame size is > 32768, we
7483 do this in a loop. Otherwise, we generate the explicit probe
7486 Note that we are only allowed to adjust sp once in the prologue. */
7488 if (frame_size
<= 32768)
7490 if (frame_size
> 4096)
7495 emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
7498 while ((probed
+= 8192) < frame_size
);
7500 /* We only have to do this probe if we aren't saving registers. */
7501 if (sa_size
== 0 && probed
+ 4096 < frame_size
)
7502 emit_insn (gen_probe_stack (GEN_INT (-frame_size
)));
7505 if (frame_size
!= 0)
7506 FRP (emit_insn (gen_adddi3 (stack_pointer_rtx
, stack_pointer_rtx
,
7507 GEN_INT (TARGET_ABI_UNICOSMK
7513 /* Here we generate code to set R22 to SP + 4096 and set R23 to the
7514 number of 8192 byte blocks to probe. We then probe each block
7515 in the loop and then set SP to the proper location. If the
7516 amount remaining is > 4096, we have to do one more probe if we
7517 are not saving any registers. */
7519 HOST_WIDE_INT blocks
= (frame_size
+ 4096) / 8192;
7520 HOST_WIDE_INT leftover
= frame_size
+ 4096 - blocks
* 8192;
7521 rtx ptr
= gen_rtx_REG (DImode
, 22);
7522 rtx count
= gen_rtx_REG (DImode
, 23);
7525 emit_move_insn (count
, GEN_INT (blocks
));
7526 emit_insn (gen_adddi3 (ptr
, stack_pointer_rtx
,
7527 GEN_INT (TARGET_ABI_UNICOSMK
? 4096 - 64 : 4096)));
7529 /* Because of the difficulty in emitting a new basic block this
7530 late in the compilation, generate the loop as a single insn. */
7531 emit_insn (gen_prologue_stack_probe_loop (count
, ptr
));
7533 if (leftover
> 4096 && sa_size
== 0)
7535 rtx last
= gen_rtx_MEM (DImode
, plus_constant (ptr
, -leftover
));
7536 MEM_VOLATILE_P (last
) = 1;
7537 emit_move_insn (last
, const0_rtx
);
7540 if (TARGET_ABI_WINDOWS_NT
)
7542 /* For NT stack unwind (done by 'reverse execution'), it's
7543 not OK to take the result of a loop, even though the value
7544 is already in ptr, so we reload it via a single operation
7545 and subtract it to sp.
7547 Yes, that's correct -- we have to reload the whole constant
7548 into a temporary via ldah+lda then subtract from sp. To
7549 ensure we get ldah+lda, we use a special pattern. */
7551 HOST_WIDE_INT lo
, hi
;
7552 lo
= ((frame_size
& 0xffff) ^ 0x8000) - 0x8000;
7553 hi
= frame_size
- lo
;
7555 emit_move_insn (ptr
, GEN_INT (hi
));
7556 emit_insn (gen_nt_lda (ptr
, GEN_INT (lo
)));
7557 seq
= emit_insn (gen_subdi3 (stack_pointer_rtx
, stack_pointer_rtx
,
7562 seq
= emit_insn (gen_adddi3 (stack_pointer_rtx
, ptr
,
7563 GEN_INT (-leftover
)));
7566 /* This alternative is special, because the DWARF code cannot
7567 possibly intuit through the loop above. So we invent this
7568 note it looks at instead. */
7569 RTX_FRAME_RELATED_P (seq
) = 1;
7571 = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR
,
7572 gen_rtx_SET (VOIDmode
, stack_pointer_rtx
,
7573 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
7574 GEN_INT (TARGET_ABI_UNICOSMK
7580 if (!TARGET_ABI_UNICOSMK
)
7582 /* Cope with very large offsets to the register save area. */
7583 sa_reg
= stack_pointer_rtx
;
7584 if (reg_offset
+ sa_size
> 0x8000)
7586 int low
= ((reg_offset
& 0xffff) ^ 0x8000) - 0x8000;
7589 if (low
+ sa_size
<= 0x8000)
7590 bias
= reg_offset
- low
, reg_offset
= low
;
7592 bias
= reg_offset
, reg_offset
= 0;
7594 sa_reg
= gen_rtx_REG (DImode
, 24);
7595 FRP (emit_insn (gen_adddi3 (sa_reg
, stack_pointer_rtx
,
7599 /* Save regs in stack order. Beginning with VMS PV. */
7600 if (TARGET_ABI_OPEN_VMS
&& alpha_procedure_type
== PT_STACK
)
7602 mem
= gen_rtx_MEM (DImode
, stack_pointer_rtx
);
7603 set_mem_alias_set (mem
, alpha_sr_alias_set
);
7604 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, REG_PV
)));
7607 /* Save register RA next. */
7608 if (imask
& (1L << REG_RA
))
7610 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, reg_offset
));
7611 set_mem_alias_set (mem
, alpha_sr_alias_set
);
7612 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, REG_RA
)));
7613 imask
&= ~(1L << REG_RA
);
7617 /* Now save any other registers required to be saved. */
7618 for (i
= 0; i
< 32; i
++)
7619 if (imask
& (1L << i
))
7621 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, reg_offset
));
7622 set_mem_alias_set (mem
, alpha_sr_alias_set
);
7623 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, i
)));
7627 for (i
= 0; i
< 32; i
++)
7628 if (fmask
& (1L << i
))
7630 mem
= gen_rtx_MEM (DFmode
, plus_constant (sa_reg
, reg_offset
));
7631 set_mem_alias_set (mem
, alpha_sr_alias_set
);
7632 FRP (emit_move_insn (mem
, gen_rtx_REG (DFmode
, i
+32)));
7636 else if (TARGET_ABI_UNICOSMK
&& alpha_procedure_type
== PT_STACK
)
7638 /* The standard frame on the T3E includes space for saving registers.
7639 We just have to use it. We don't have to save the return address and
7640 the old frame pointer here - they are saved in the DSIB. */
7643 for (i
= 9; i
< 15; i
++)
7644 if (imask
& (1L << i
))
7646 mem
= gen_rtx_MEM (DImode
, plus_constant(hard_frame_pointer_rtx
,
7648 set_mem_alias_set (mem
, alpha_sr_alias_set
);
7649 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, i
)));
7652 for (i
= 2; i
< 10; i
++)
7653 if (fmask
& (1L << i
))
7655 mem
= gen_rtx_MEM (DFmode
, plus_constant (hard_frame_pointer_rtx
,
7657 set_mem_alias_set (mem
, alpha_sr_alias_set
);
7658 FRP (emit_move_insn (mem
, gen_rtx_REG (DFmode
, i
+32)));
7663 if (TARGET_ABI_OPEN_VMS
)
7665 if (alpha_procedure_type
== PT_REGISTER
)
7666 /* Register frame procedures save the fp.
7667 ?? Ought to have a dwarf2 save for this. */
7668 emit_move_insn (gen_rtx_REG (DImode
, vms_save_fp_regno
),
7669 hard_frame_pointer_rtx
);
7671 if (alpha_procedure_type
!= PT_NULL
&& vms_base_regno
!= REG_PV
)
7672 emit_insn (gen_force_movdi (gen_rtx_REG (DImode
, vms_base_regno
),
7673 gen_rtx_REG (DImode
, REG_PV
)));
7675 if (alpha_procedure_type
!= PT_NULL
7676 && vms_unwind_regno
== HARD_FRAME_POINTER_REGNUM
)
7677 FRP (emit_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
));
7679 /* If we have to allocate space for outgoing args, do it now. */
7680 if (current_function_outgoing_args_size
!= 0)
7683 plus_constant (hard_frame_pointer_rtx
,
7685 (current_function_outgoing_args_size
)))));
7687 else if (!TARGET_ABI_UNICOSMK
)
7689 /* If we need a frame pointer, set it from the stack pointer. */
7690 if (frame_pointer_needed
)
7692 if (TARGET_CAN_FAULT_IN_PROLOGUE
)
7693 FRP (emit_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
));
7695 /* This must always be the last instruction in the
7696 prologue, thus we emit a special move + clobber. */
7697 FRP (emit_insn (gen_init_fp (hard_frame_pointer_rtx
,
7698 stack_pointer_rtx
, sa_reg
)));
7702 /* The ABIs for VMS and OSF/1 say that while we can schedule insns into
7703 the prologue, for exception handling reasons, we cannot do this for
7704 any insn that might fault. We could prevent this for mems with a
7705 (clobber:BLK (scratch)), but this doesn't work for fp insns. So we
7706 have to prevent all such scheduling with a blockage.
7708 Linux, on the other hand, never bothered to implement OSF/1's
7709 exception handling, and so doesn't care about such things. Anyone
7710 planning to use dwarf2 frame-unwind info can also omit the blockage. */
7712 if (! TARGET_CAN_FAULT_IN_PROLOGUE
)
7713 emit_insn (gen_blockage ());
7716 /* Output the textual info surrounding the prologue. */
7719 alpha_start_function (file
, fnname
, decl
)
7722 tree decl ATTRIBUTE_UNUSED
;
7724 unsigned long imask
= 0;
7725 unsigned long fmask
= 0;
7726 /* Stack space needed for pushing registers clobbered by us. */
7727 HOST_WIDE_INT sa_size
;
7728 /* Complete stack size needed. */
7729 HOST_WIDE_INT frame_size
;
7730 /* Offset from base reg to register save area. */
7731 HOST_WIDE_INT reg_offset
;
7732 char *entry_label
= (char *) alloca (strlen (fnname
) + 6);
7735 /* Don't emit an extern directive for functions defined in the same file. */
7736 if (TARGET_ABI_UNICOSMK
)
7739 name_tree
= get_identifier (fnname
);
7740 TREE_ASM_WRITTEN (name_tree
) = 1;
7743 alpha_fnname
= fnname
;
7744 sa_size
= alpha_sa_size ();
7746 frame_size
= get_frame_size ();
7747 if (TARGET_ABI_OPEN_VMS
)
7748 frame_size
= ALPHA_ROUND (sa_size
7749 + (alpha_procedure_type
== PT_STACK
? 8 : 0)
7751 + current_function_pretend_args_size
);
7752 else if (TARGET_ABI_UNICOSMK
)
7753 frame_size
= ALPHA_ROUND (sa_size
7754 + (alpha_procedure_type
== PT_STACK
? 48 : 0))
7755 + ALPHA_ROUND (frame_size
7756 + current_function_outgoing_args_size
);
7758 frame_size
= (ALPHA_ROUND (current_function_outgoing_args_size
)
7760 + ALPHA_ROUND (frame_size
7761 + current_function_pretend_args_size
));
7763 if (TARGET_ABI_OPEN_VMS
)
7766 reg_offset
= ALPHA_ROUND (current_function_outgoing_args_size
);
7768 alpha_sa_mask (&imask
, &fmask
);
7770 /* Ecoff can handle multiple .file directives, so put out file and lineno.
7771 We have to do that before the .ent directive as we cannot switch
7772 files within procedures with native ecoff because line numbers are
7773 linked to procedure descriptors.
7774 Outputting the lineno helps debugging of one line functions as they
7775 would otherwise get no line number at all. Please note that we would
7776 like to put out last_linenum from final.c, but it is not accessible. */
7778 if (write_symbols
== SDB_DEBUG
)
7780 #ifdef ASM_OUTPUT_SOURCE_FILENAME
7781 ASM_OUTPUT_SOURCE_FILENAME (file
,
7782 DECL_SOURCE_FILE (current_function_decl
));
7784 #ifdef ASM_OUTPUT_SOURCE_LINE
7785 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
7786 ASM_OUTPUT_SOURCE_LINE (file
,
7787 DECL_SOURCE_LINE (current_function_decl
));
7791 /* Issue function start and label. */
7792 if (TARGET_ABI_OPEN_VMS
7793 || (!TARGET_ABI_UNICOSMK
&& !flag_inhibit_size_directive
))
7795 fputs ("\t.ent ", file
);
7796 assemble_name (file
, fnname
);
7799 /* If the function needs GP, we'll write the "..ng" label there.
7800 Otherwise, do it here. */
7802 && ! alpha_function_needs_gp
7803 && ! current_function_is_thunk
)
7806 assemble_name (file
, fnname
);
7807 fputs ("..ng:\n", file
);
7811 strcpy (entry_label
, fnname
);
7812 if (TARGET_ABI_OPEN_VMS
)
7813 strcat (entry_label
, "..en");
7815 /* For public functions, the label must be globalized by appending an
7816 additional colon. */
7817 if (TARGET_ABI_UNICOSMK
&& TREE_PUBLIC (decl
))
7818 strcat (entry_label
, ":");
7820 ASM_OUTPUT_LABEL (file
, entry_label
);
7821 inside_function
= TRUE
;
7823 if (TARGET_ABI_OPEN_VMS
)
7824 fprintf (file
, "\t.base $%d\n", vms_base_regno
);
7826 if (!TARGET_ABI_OPEN_VMS
&& !TARGET_ABI_UNICOSMK
&& TARGET_IEEE_CONFORMANT
7827 && !flag_inhibit_size_directive
)
7829 /* Set flags in procedure descriptor to request IEEE-conformant
7830 math-library routines. The value we set it to is PDSC_EXC_IEEE
7831 (/usr/include/pdsc.h). */
7832 fputs ("\t.eflag 48\n", file
);
7835 /* Set up offsets to alpha virtual arg/local debugging pointer. */
7836 alpha_auto_offset
= -frame_size
+ current_function_pretend_args_size
;
7837 alpha_arg_offset
= -frame_size
+ 48;
7839 /* Describe our frame. If the frame size is larger than an integer,
7840 print it as zero to avoid an assembler error. We won't be
7841 properly describing such a frame, but that's the best we can do. */
7842 if (TARGET_ABI_UNICOSMK
)
7844 else if (TARGET_ABI_OPEN_VMS
)
7846 fprintf (file
, "\t.frame $%d,", vms_unwind_regno
);
7847 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
7848 frame_size
>= ((HOST_WIDE_INT
) 1 << 31) ? 0 : frame_size
);
7849 fputs (",$26,", file
);
7850 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, reg_offset
);
7853 else if (!flag_inhibit_size_directive
)
7855 fprintf (file
, "\t.frame $%d,",
7856 (frame_pointer_needed
7857 ? HARD_FRAME_POINTER_REGNUM
: STACK_POINTER_REGNUM
));
7858 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
7859 frame_size
>= (1l << 31) ? 0 : frame_size
);
7860 fprintf (file
, ",$26,%d\n", current_function_pretend_args_size
);
7863 /* Describe which registers were spilled. */
7864 if (TARGET_ABI_UNICOSMK
)
7866 else if (TARGET_ABI_OPEN_VMS
)
7869 /* ??? Does VMS care if mask contains ra? The old code didn't
7870 set it, so I don't here. */
7871 fprintf (file
, "\t.mask 0x%lx,0\n", imask
& ~(1L << REG_RA
));
7873 fprintf (file
, "\t.fmask 0x%lx,0\n", fmask
);
7874 if (alpha_procedure_type
== PT_REGISTER
)
7875 fprintf (file
, "\t.fp_save $%d\n", vms_save_fp_regno
);
7877 else if (!flag_inhibit_size_directive
)
7881 fprintf (file
, "\t.mask 0x%lx,", imask
);
7882 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
7883 frame_size
>= (1l << 31) ? 0 : reg_offset
- frame_size
);
7886 for (i
= 0; i
< 32; ++i
)
7887 if (imask
& (1L << i
))
7893 fprintf (file
, "\t.fmask 0x%lx,", fmask
);
7894 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
7895 frame_size
>= (1l << 31) ? 0 : reg_offset
- frame_size
);
7900 #if TARGET_ABI_OPEN_VMS
7901 /* Ifdef'ed cause link_section are only available then. */
7902 readonly_data_section ();
7903 fprintf (file
, "\t.align 3\n");
7904 assemble_name (file
, fnname
); fputs ("..na:\n", file
);
7905 fputs ("\t.ascii \"", file
);
7906 assemble_name (file
, fnname
);
7907 fputs ("\\0\"\n", file
);
7908 alpha_need_linkage (fnname
, 1);
7913 /* Emit the .prologue note at the scheduled end of the prologue. */
7916 alpha_output_function_end_prologue (file
)
7919 if (TARGET_ABI_UNICOSMK
)
7921 else if (TARGET_ABI_OPEN_VMS
)
7922 fputs ("\t.prologue\n", file
);
7923 else if (TARGET_ABI_WINDOWS_NT
)
7924 fputs ("\t.prologue 0\n", file
);
7925 else if (!flag_inhibit_size_directive
)
7926 fprintf (file
, "\t.prologue %d\n",
7927 alpha_function_needs_gp
|| current_function_is_thunk
);
7930 /* Write function epilogue. */
7932 /* ??? At some point we will want to support full unwind, and so will
7933 need to mark the epilogue as well. At the moment, we just confuse
7936 #define FRP(exp) exp
7939 alpha_expand_epilogue ()
7941 /* Registers to save. */
7942 unsigned long imask
= 0;
7943 unsigned long fmask
= 0;
7944 /* Stack space needed for pushing registers clobbered by us. */
7945 HOST_WIDE_INT sa_size
;
7946 /* Complete stack size needed. */
7947 HOST_WIDE_INT frame_size
;
7948 /* Offset from base reg to register save area. */
7949 HOST_WIDE_INT reg_offset
;
7950 int fp_is_frame_pointer
, fp_offset
;
7951 rtx sa_reg
, sa_reg_exp
= NULL
;
7952 rtx sp_adj1
, sp_adj2
, mem
;
7956 sa_size
= alpha_sa_size ();
7958 frame_size
= get_frame_size ();
7959 if (TARGET_ABI_OPEN_VMS
)
7960 frame_size
= ALPHA_ROUND (sa_size
7961 + (alpha_procedure_type
== PT_STACK
? 8 : 0)
7963 + current_function_pretend_args_size
);
7964 else if (TARGET_ABI_UNICOSMK
)
7965 frame_size
= ALPHA_ROUND (sa_size
7966 + (alpha_procedure_type
== PT_STACK
? 48 : 0))
7967 + ALPHA_ROUND (frame_size
7968 + current_function_outgoing_args_size
);
7970 frame_size
= (ALPHA_ROUND (current_function_outgoing_args_size
)
7972 + ALPHA_ROUND (frame_size
7973 + current_function_pretend_args_size
));
7975 if (TARGET_ABI_OPEN_VMS
)
7977 if (alpha_procedure_type
== PT_STACK
)
7983 reg_offset
= ALPHA_ROUND (current_function_outgoing_args_size
);
7985 alpha_sa_mask (&imask
, &fmask
);
7988 = ((TARGET_ABI_OPEN_VMS
&& alpha_procedure_type
== PT_STACK
)
7989 || (!TARGET_ABI_OPEN_VMS
&& frame_pointer_needed
));
7991 sa_reg
= stack_pointer_rtx
;
7993 if (current_function_calls_eh_return
)
7994 eh_ofs
= EH_RETURN_STACKADJ_RTX
;
7998 if (!TARGET_ABI_UNICOSMK
&& sa_size
)
8000 /* If we have a frame pointer, restore SP from it. */
8001 if ((TARGET_ABI_OPEN_VMS
8002 && vms_unwind_regno
== HARD_FRAME_POINTER_REGNUM
)
8003 || (!TARGET_ABI_OPEN_VMS
&& frame_pointer_needed
))
8004 FRP (emit_move_insn (stack_pointer_rtx
, hard_frame_pointer_rtx
));
8006 /* Cope with very large offsets to the register save area. */
8007 if (reg_offset
+ sa_size
> 0x8000)
8009 int low
= ((reg_offset
& 0xffff) ^ 0x8000) - 0x8000;
8012 if (low
+ sa_size
<= 0x8000)
8013 bias
= reg_offset
- low
, reg_offset
= low
;
8015 bias
= reg_offset
, reg_offset
= 0;
8017 sa_reg
= gen_rtx_REG (DImode
, 22);
8018 sa_reg_exp
= plus_constant (stack_pointer_rtx
, bias
);
8020 FRP (emit_move_insn (sa_reg
, sa_reg_exp
));
8023 /* Restore registers in order, excepting a true frame pointer. */
8025 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, reg_offset
));
8027 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8028 FRP (emit_move_insn (gen_rtx_REG (DImode
, REG_RA
), mem
));
8031 imask
&= ~(1L << REG_RA
);
8033 for (i
= 0; i
< 32; ++i
)
8034 if (imask
& (1L << i
))
8036 if (i
== HARD_FRAME_POINTER_REGNUM
&& fp_is_frame_pointer
)
8037 fp_offset
= reg_offset
;
8040 mem
= gen_rtx_MEM (DImode
, plus_constant(sa_reg
, reg_offset
));
8041 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8042 FRP (emit_move_insn (gen_rtx_REG (DImode
, i
), mem
));
8047 for (i
= 0; i
< 32; ++i
)
8048 if (fmask
& (1L << i
))
8050 mem
= gen_rtx_MEM (DFmode
, plus_constant(sa_reg
, reg_offset
));
8051 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8052 FRP (emit_move_insn (gen_rtx_REG (DFmode
, i
+32), mem
));
8056 else if (TARGET_ABI_UNICOSMK
&& alpha_procedure_type
== PT_STACK
)
8058 /* Restore callee-saved general-purpose registers. */
8062 for (i
= 9; i
< 15; i
++)
8063 if (imask
& (1L << i
))
8065 mem
= gen_rtx_MEM (DImode
, plus_constant(hard_frame_pointer_rtx
,
8067 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8068 FRP (emit_move_insn (gen_rtx_REG (DImode
, i
), mem
));
8072 for (i
= 2; i
< 10; i
++)
8073 if (fmask
& (1L << i
))
8075 mem
= gen_rtx_MEM (DFmode
, plus_constant(hard_frame_pointer_rtx
,
8077 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8078 FRP (emit_move_insn (gen_rtx_REG (DFmode
, i
+32), mem
));
8082 /* Restore the return address from the DSIB. */
8084 mem
= gen_rtx_MEM (DImode
, plus_constant(hard_frame_pointer_rtx
, -8));
8085 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8086 FRP (emit_move_insn (gen_rtx_REG (DImode
, REG_RA
), mem
));
8089 if (frame_size
|| eh_ofs
)
8091 sp_adj1
= stack_pointer_rtx
;
8095 sp_adj1
= gen_rtx_REG (DImode
, 23);
8096 emit_move_insn (sp_adj1
,
8097 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, eh_ofs
));
8100 /* If the stack size is large, begin computation into a temporary
8101 register so as not to interfere with a potential fp restore,
8102 which must be consecutive with an SP restore. */
8103 if (frame_size
< 32768
8104 && ! (TARGET_ABI_UNICOSMK
&& current_function_calls_alloca
))
8105 sp_adj2
= GEN_INT (frame_size
);
8106 else if (TARGET_ABI_UNICOSMK
)
8108 sp_adj1
= gen_rtx_REG (DImode
, 23);
8109 FRP (emit_move_insn (sp_adj1
, hard_frame_pointer_rtx
));
8110 sp_adj2
= const0_rtx
;
8112 else if (frame_size
< 0x40007fffL
)
8114 int low
= ((frame_size
& 0xffff) ^ 0x8000) - 0x8000;
8116 sp_adj2
= plus_constant (sp_adj1
, frame_size
- low
);
8117 if (sa_reg_exp
&& rtx_equal_p (sa_reg_exp
, sp_adj2
))
8121 sp_adj1
= gen_rtx_REG (DImode
, 23);
8122 FRP (emit_move_insn (sp_adj1
, sp_adj2
));
8124 sp_adj2
= GEN_INT (low
);
8128 rtx tmp
= gen_rtx_REG (DImode
, 23);
8129 FRP (sp_adj2
= alpha_emit_set_const (tmp
, DImode
, frame_size
, 3));
8132 /* We can't drop new things to memory this late, afaik,
8133 so build it up by pieces. */
8134 FRP (sp_adj2
= alpha_emit_set_long_const (tmp
, frame_size
,
8135 -(frame_size
< 0)));
8141 /* From now on, things must be in order. So emit blockages. */
8143 /* Restore the frame pointer. */
8144 if (TARGET_ABI_UNICOSMK
)
8146 emit_insn (gen_blockage ());
8147 mem
= gen_rtx_MEM (DImode
,
8148 plus_constant (hard_frame_pointer_rtx
, -16));
8149 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8150 FRP (emit_move_insn (hard_frame_pointer_rtx
, mem
));
8152 else if (fp_is_frame_pointer
)
8154 emit_insn (gen_blockage ());
8155 mem
= gen_rtx_MEM (DImode
, plus_constant (sa_reg
, fp_offset
));
8156 set_mem_alias_set (mem
, alpha_sr_alias_set
);
8157 FRP (emit_move_insn (hard_frame_pointer_rtx
, mem
));
8159 else if (TARGET_ABI_OPEN_VMS
)
8161 emit_insn (gen_blockage ());
8162 FRP (emit_move_insn (hard_frame_pointer_rtx
,
8163 gen_rtx_REG (DImode
, vms_save_fp_regno
)));
8166 /* Restore the stack pointer. */
8167 emit_insn (gen_blockage ());
8168 if (sp_adj2
== const0_rtx
)
8169 FRP (emit_move_insn (stack_pointer_rtx
, sp_adj1
));
8171 FRP (emit_move_insn (stack_pointer_rtx
,
8172 gen_rtx_PLUS (DImode
, sp_adj1
, sp_adj2
)));
8176 if (TARGET_ABI_OPEN_VMS
&& alpha_procedure_type
== PT_REGISTER
)
8178 emit_insn (gen_blockage ());
8179 FRP (emit_move_insn (hard_frame_pointer_rtx
,
8180 gen_rtx_REG (DImode
, vms_save_fp_regno
)));
8182 else if (TARGET_ABI_UNICOSMK
&& alpha_procedure_type
!= PT_STACK
)
8184 /* Decrement the frame pointer if the function does not have a
8187 emit_insn (gen_blockage ());
8188 FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx
,
8189 hard_frame_pointer_rtx
, GEN_INT (-1))));
8194 /* Output the rest of the textual info surrounding the epilogue. */
8197 alpha_end_function (file
, fnname
, decl
)
8202 /* End the function. */
8203 if (!TARGET_ABI_UNICOSMK
&& !flag_inhibit_size_directive
)
8205 fputs ("\t.end ", file
);
8206 assemble_name (file
, fnname
);
8209 inside_function
= FALSE
;
8211 #if TARGET_ABI_OPEN_VMS
8212 alpha_write_linkage (file
, fnname
, decl
);
8215 /* Show that we know this function if it is called again.
8216 This is only meaningful for symbols that bind locally. */
8217 if ((*targetm
.binds_local_p
) (decl
))
8219 rtx symbol
= XEXP (DECL_RTL (decl
), 0);
8221 /* Mark whether the decl is "near". See the commentary in
8222 alpha_encode_section_info wrt the .text section. */
8223 if (decl_in_text_section (decl
))
8226 /* Mark whether the decl shares a GP with other functions
8227 in this unit of translation. This is trivially true of
8229 SYMBOL_REF_FLAG (symbol
) = 1;
8232 /* Output jump tables and the static subroutine information block. */
8233 if (TARGET_ABI_UNICOSMK
)
8235 unicosmk_output_ssib (file
, fnname
);
8236 unicosmk_output_deferred_case_vectors (file
);
8241 /* Emit a tail call to FUNCTION after adjusting THIS by DELTA.
8243 In order to avoid the hordes of differences between generated code
8244 with and without TARGET_EXPLICIT_RELOCS, and to avoid duplicating
8245 lots of code loading up large constants, generate rtl and emit it
8246 instead of going straight to text.
8248 Not sure why this idea hasn't been explored before... */
8251 alpha_output_mi_thunk_osf (file
, thunk_fndecl
, delta
, vcall_offset
, function
)
8253 tree thunk_fndecl ATTRIBUTE_UNUSED
;
8254 HOST_WIDE_INT delta
;
8255 HOST_WIDE_INT vcall_offset
;
8258 HOST_WIDE_INT hi
, lo
;
8259 rtx
this, insn
, funexp
;
8261 /* We always require a valid GP. */
8262 emit_insn (gen_prologue_ldgp ());
8263 emit_note (NULL
, NOTE_INSN_PROLOGUE_END
);
8265 /* Find the "this" pointer. If the function returns a structure,
8266 the structure return pointer is in $16. */
8267 if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function
))))
8268 this = gen_rtx_REG (Pmode
, 17);
8270 this = gen_rtx_REG (Pmode
, 16);
8272 /* Add DELTA. When possible we use ldah+lda. Otherwise load the
8273 entire constant for the add. */
8274 lo
= ((delta
& 0xffff) ^ 0x8000) - 0x8000;
8275 hi
= (((delta
- lo
) & 0xffffffff) ^ 0x80000000) - 0x80000000;
8276 if (hi
+ lo
== delta
)
8279 emit_insn (gen_adddi3 (this, this, GEN_INT (hi
)));
8281 emit_insn (gen_adddi3 (this, this, GEN_INT (lo
)));
8285 rtx tmp
= alpha_emit_set_long_const (gen_rtx_REG (Pmode
, 0),
8286 delta
, -(delta
< 0));
8287 emit_insn (gen_adddi3 (this, this, tmp
));
8290 /* Add a delta stored in the vtable at VCALL_OFFSET. */
8295 tmp
= gen_rtx_REG (Pmode
, 0);
8296 emit_move_insn (tmp
, gen_rtx_MEM (Pmode
, this));
8298 lo
= ((vcall_offset
& 0xffff) ^ 0x8000) - 0x8000;
8299 hi
= (((vcall_offset
- lo
) & 0xffffffff) ^ 0x80000000) - 0x80000000;
8300 if (hi
+ lo
== vcall_offset
)
8303 emit_insn (gen_adddi3 (tmp
, tmp
, GEN_INT (hi
)));
8307 tmp2
= alpha_emit_set_long_const (gen_rtx_REG (Pmode
, 1),
8308 vcall_offset
, -(vcall_offset
< 0));
8309 emit_insn (gen_adddi3 (tmp
, tmp
, tmp2
));
8313 tmp2
= gen_rtx_PLUS (Pmode
, tmp
, GEN_INT (lo
));
8316 emit_move_insn (tmp
, gen_rtx_MEM (Pmode
, tmp2
));
8318 emit_insn (gen_adddi3 (this, this, tmp
));
8321 /* Generate a tail call to the target function. */
8322 if (! TREE_USED (function
))
8324 assemble_external (function
);
8325 TREE_USED (function
) = 1;
8327 funexp
= XEXP (DECL_RTL (function
), 0);
8328 funexp
= gen_rtx_MEM (FUNCTION_MODE
, funexp
);
8329 insn
= emit_call_insn (gen_sibcall (funexp
, const0_rtx
));
8330 SIBLING_CALL_P (insn
) = 1;
8332 /* Run just enough of rest_of_compilation to get the insns emitted.
8333 There's not really enough bulk here to make other passes such as
8334 instruction scheduling worth while. Note that use_thunk calls
8335 assemble_start_function and assemble_end_function. */
8336 insn
= get_insns ();
8337 shorten_branches (insn
);
8338 final_start_function (insn
, file
, 1);
8339 final (insn
, file
, 1, 0);
8340 final_end_function ();
8342 #endif /* TARGET_ABI_OSF */
8344 /* Debugging support. */
8348 /* Count the number of sdb related labels are generated (to find block
8349 start and end boundaries). */
8351 int sdb_label_count
= 0;
8353 /* Next label # for each statement. */
8355 static int sym_lineno
= 0;
8357 /* Count the number of .file directives, so that .loc is up to date. */
8359 static int num_source_filenames
= 0;
8361 /* Name of the file containing the current function. */
8363 static const char *current_function_file
= "";
8365 /* Offsets to alpha virtual arg/local debugging pointers. */
8367 long alpha_arg_offset
;
8368 long alpha_auto_offset
;
8370 /* Emit a new filename to a stream. */
8373 alpha_output_filename (stream
, name
)
8377 static int first_time
= TRUE
;
8378 char ltext_label_name
[100];
8383 ++num_source_filenames
;
8384 current_function_file
= name
;
8385 fprintf (stream
, "\t.file\t%d ", num_source_filenames
);
8386 output_quoted_string (stream
, name
);
8387 fprintf (stream
, "\n");
8388 if (!TARGET_GAS
&& write_symbols
== DBX_DEBUG
)
8389 fprintf (stream
, "\t#@stabs\n");
8392 else if (write_symbols
== DBX_DEBUG
)
8394 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
8395 fprintf (stream
, "%s", ASM_STABS_OP
);
8396 output_quoted_string (stream
, name
);
8397 fprintf (stream
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
8400 else if (name
!= current_function_file
8401 && strcmp (name
, current_function_file
) != 0)
8403 if (inside_function
&& ! TARGET_GAS
)
8404 fprintf (stream
, "\t#.file\t%d ", num_source_filenames
);
8407 ++num_source_filenames
;
8408 current_function_file
= name
;
8409 fprintf (stream
, "\t.file\t%d ", num_source_filenames
);
8412 output_quoted_string (stream
, name
);
8413 fprintf (stream
, "\n");
8417 /* Emit a linenumber to a stream. */
8420 alpha_output_lineno (stream
, line
)
8424 if (write_symbols
== DBX_DEBUG
)
8426 /* mips-tfile doesn't understand .stabd directives. */
8428 fprintf (stream
, "$LM%d:\n%s%d,0,%d,$LM%d\n",
8429 sym_lineno
, ASM_STABN_OP
, N_SLINE
, line
, sym_lineno
);
8432 fprintf (stream
, "\n\t.loc\t%d %d\n", num_source_filenames
, line
);
8435 /* Structure to show the current status of registers and memory. */
8437 struct shadow_summary
8440 unsigned int i
: 31; /* Mask of int regs */
8441 unsigned int fp
: 31; /* Mask of fp regs */
8442 unsigned int mem
: 1; /* mem == imem | fpmem */
8446 static void summarize_insn
PARAMS ((rtx
, struct shadow_summary
*, int));
8447 static void alpha_handle_trap_shadows
PARAMS ((rtx
));
8449 /* Summary the effects of expression X on the machine. Update SUM, a pointer
8450 to the summary structure. SET is nonzero if the insn is setting the
8451 object, otherwise zero. */
8454 summarize_insn (x
, sum
, set
)
8456 struct shadow_summary
*sum
;
8459 const char *format_ptr
;
8465 switch (GET_CODE (x
))
8467 /* ??? Note that this case would be incorrect if the Alpha had a
8468 ZERO_EXTRACT in SET_DEST. */
8470 summarize_insn (SET_SRC (x
), sum
, 0);
8471 summarize_insn (SET_DEST (x
), sum
, 1);
8475 summarize_insn (XEXP (x
, 0), sum
, 1);
8479 summarize_insn (XEXP (x
, 0), sum
, 0);
8483 for (i
= ASM_OPERANDS_INPUT_LENGTH (x
) - 1; i
>= 0; i
--)
8484 summarize_insn (ASM_OPERANDS_INPUT (x
, i
), sum
, 0);
8488 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
8489 summarize_insn (XVECEXP (x
, 0, i
), sum
, 0);
8493 summarize_insn (SUBREG_REG (x
), sum
, 0);
8498 int regno
= REGNO (x
);
8499 unsigned long mask
= ((unsigned long) 1) << (regno
% 32);
8501 if (regno
== 31 || regno
== 63)
8507 sum
->defd
.i
|= mask
;
8509 sum
->defd
.fp
|= mask
;
8514 sum
->used
.i
|= mask
;
8516 sum
->used
.fp
|= mask
;
8527 /* Find the regs used in memory address computation: */
8528 summarize_insn (XEXP (x
, 0), sum
, 0);
8531 case CONST_INT
: case CONST_DOUBLE
:
8532 case SYMBOL_REF
: case LABEL_REF
: case CONST
:
8533 case SCRATCH
: case ASM_INPUT
:
8536 /* Handle common unary and binary ops for efficiency. */
8537 case COMPARE
: case PLUS
: case MINUS
: case MULT
: case DIV
:
8538 case MOD
: case UDIV
: case UMOD
: case AND
: case IOR
:
8539 case XOR
: case ASHIFT
: case ROTATE
: case ASHIFTRT
: case LSHIFTRT
:
8540 case ROTATERT
: case SMIN
: case SMAX
: case UMIN
: case UMAX
:
8541 case NE
: case EQ
: case GE
: case GT
: case LE
:
8542 case LT
: case GEU
: case GTU
: case LEU
: case LTU
:
8543 summarize_insn (XEXP (x
, 0), sum
, 0);
8544 summarize_insn (XEXP (x
, 1), sum
, 0);
8547 case NEG
: case NOT
: case SIGN_EXTEND
: case ZERO_EXTEND
:
8548 case TRUNCATE
: case FLOAT_EXTEND
: case FLOAT_TRUNCATE
: case FLOAT
:
8549 case FIX
: case UNSIGNED_FLOAT
: case UNSIGNED_FIX
: case ABS
:
8550 case SQRT
: case FFS
:
8551 summarize_insn (XEXP (x
, 0), sum
, 0);
8555 format_ptr
= GET_RTX_FORMAT (GET_CODE (x
));
8556 for (i
= GET_RTX_LENGTH (GET_CODE (x
)) - 1; i
>= 0; i
--)
8557 switch (format_ptr
[i
])
8560 summarize_insn (XEXP (x
, i
), sum
, 0);
8564 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
8565 summarize_insn (XVECEXP (x
, i
, j
), sum
, 0);
8577 /* Ensure a sufficient number of `trapb' insns are in the code when
8578 the user requests code with a trap precision of functions or
8581 In naive mode, when the user requests a trap-precision of
8582 "instruction", a trapb is needed after every instruction that may
8583 generate a trap. This ensures that the code is resumption safe but
8586 When optimizations are turned on, we delay issuing a trapb as long
8587 as possible. In this context, a trap shadow is the sequence of
8588 instructions that starts with a (potentially) trap generating
8589 instruction and extends to the next trapb or call_pal instruction
8590 (but GCC never generates call_pal by itself). We can delay (and
8591 therefore sometimes omit) a trapb subject to the following
8594 (a) On entry to the trap shadow, if any Alpha register or memory
8595 location contains a value that is used as an operand value by some
8596 instruction in the trap shadow (live on entry), then no instruction
8597 in the trap shadow may modify the register or memory location.
8599 (b) Within the trap shadow, the computation of the base register
8600 for a memory load or store instruction may not involve using the
8601 result of an instruction that might generate an UNPREDICTABLE
8604 (c) Within the trap shadow, no register may be used more than once
8605 as a destination register. (This is to make life easier for the
8608 (d) The trap shadow may not include any branch instructions. */
8611 alpha_handle_trap_shadows (insns
)
8614 struct shadow_summary shadow
;
8615 int trap_pending
, exception_nesting
;
8619 exception_nesting
= 0;
8622 shadow
.used
.mem
= 0;
8623 shadow
.defd
= shadow
.used
;
8625 for (i
= insns
; i
; i
= NEXT_INSN (i
))
8627 if (GET_CODE (i
) == NOTE
)
8629 switch (NOTE_LINE_NUMBER (i
))
8631 case NOTE_INSN_EH_REGION_BEG
:
8632 exception_nesting
++;
8637 case NOTE_INSN_EH_REGION_END
:
8638 exception_nesting
--;
8643 case NOTE_INSN_EPILOGUE_BEG
:
8644 if (trap_pending
&& alpha_tp
>= ALPHA_TP_FUNC
)
8649 else if (trap_pending
)
8651 if (alpha_tp
== ALPHA_TP_FUNC
)
8653 if (GET_CODE (i
) == JUMP_INSN
8654 && GET_CODE (PATTERN (i
)) == RETURN
)
8657 else if (alpha_tp
== ALPHA_TP_INSN
)
8661 struct shadow_summary sum
;
8666 sum
.defd
= sum
.used
;
8668 switch (GET_CODE (i
))
8671 /* Annoyingly, get_attr_trap will abort on these. */
8672 if (GET_CODE (PATTERN (i
)) == USE
8673 || GET_CODE (PATTERN (i
)) == CLOBBER
)
8676 summarize_insn (PATTERN (i
), &sum
, 0);
8678 if ((sum
.defd
.i
& shadow
.defd
.i
)
8679 || (sum
.defd
.fp
& shadow
.defd
.fp
))
8681 /* (c) would be violated */
8685 /* Combine shadow with summary of current insn: */
8686 shadow
.used
.i
|= sum
.used
.i
;
8687 shadow
.used
.fp
|= sum
.used
.fp
;
8688 shadow
.used
.mem
|= sum
.used
.mem
;
8689 shadow
.defd
.i
|= sum
.defd
.i
;
8690 shadow
.defd
.fp
|= sum
.defd
.fp
;
8691 shadow
.defd
.mem
|= sum
.defd
.mem
;
8693 if ((sum
.defd
.i
& shadow
.used
.i
)
8694 || (sum
.defd
.fp
& shadow
.used
.fp
)
8695 || (sum
.defd
.mem
& shadow
.used
.mem
))
8697 /* (a) would be violated (also takes care of (b)) */
8698 if (get_attr_trap (i
) == TRAP_YES
8699 && ((sum
.defd
.i
& sum
.used
.i
)
8700 || (sum
.defd
.fp
& sum
.used
.fp
)))
8719 n
= emit_insn_before (gen_trapb (), i
);
8720 PUT_MODE (n
, TImode
);
8721 PUT_MODE (i
, TImode
);
8725 shadow
.used
.mem
= 0;
8726 shadow
.defd
= shadow
.used
;
8731 if ((exception_nesting
> 0 || alpha_tp
>= ALPHA_TP_FUNC
)
8732 && GET_CODE (i
) == INSN
8733 && GET_CODE (PATTERN (i
)) != USE
8734 && GET_CODE (PATTERN (i
)) != CLOBBER
8735 && get_attr_trap (i
) == TRAP_YES
)
8737 if (optimize
&& !trap_pending
)
8738 summarize_insn (PATTERN (i
), &shadow
, 0);
8744 /* Alpha can only issue instruction groups simultaneously if they are
8745 suitibly aligned. This is very processor-specific. */
8747 enum alphaev4_pipe
{
8754 enum alphaev5_pipe
{
8765 static enum alphaev4_pipe alphaev4_insn_pipe
PARAMS ((rtx
));
8766 static enum alphaev5_pipe alphaev5_insn_pipe
PARAMS ((rtx
));
8767 static rtx alphaev4_next_group
PARAMS ((rtx
, int *, int *));
8768 static rtx alphaev5_next_group
PARAMS ((rtx
, int *, int *));
8769 static rtx alphaev4_next_nop
PARAMS ((int *));
8770 static rtx alphaev5_next_nop
PARAMS ((int *));
8772 static void alpha_align_insns
8773 PARAMS ((rtx
, unsigned int, rtx (*)(rtx
, int *, int *), rtx (*)(int *)));
8775 static enum alphaev4_pipe
8776 alphaev4_insn_pipe (insn
)
8779 if (recog_memoized (insn
) < 0)
8781 if (get_attr_length (insn
) != 4)
8784 switch (get_attr_type (insn
))
8818 static enum alphaev5_pipe
8819 alphaev5_insn_pipe (insn
)
8822 if (recog_memoized (insn
) < 0)
8824 if (get_attr_length (insn
) != 4)
8827 switch (get_attr_type (insn
))
8868 /* IN_USE is a mask of the slots currently filled within the insn group.
8869 The mask bits come from alphaev4_pipe above. If EV4_IBX is set, then
8870 the insn in EV4_IB0 can be swapped by the hardware into EV4_IB1.
8872 LEN is, of course, the length of the group in bytes. */
8875 alphaev4_next_group (insn
, pin_use
, plen
)
8877 int *pin_use
, *plen
;
8884 || GET_CODE (PATTERN (insn
)) == CLOBBER
8885 || GET_CODE (PATTERN (insn
)) == USE
)
8890 enum alphaev4_pipe pipe
;
8892 pipe
= alphaev4_insn_pipe (insn
);
8896 /* Force complex instructions to start new groups. */
8900 /* If this is a completely unrecognized insn, its an asm.
8901 We don't know how long it is, so record length as -1 to
8902 signal a needed realignment. */
8903 if (recog_memoized (insn
) < 0)
8906 len
= get_attr_length (insn
);
8910 if (in_use
& EV4_IB0
)
8912 if (in_use
& EV4_IB1
)
8917 in_use
|= EV4_IB0
| EV4_IBX
;
8921 if (in_use
& EV4_IB0
)
8923 if (!(in_use
& EV4_IBX
) || (in_use
& EV4_IB1
))
8931 if (in_use
& EV4_IB1
)
8941 /* Haifa doesn't do well scheduling branches. */
8942 if (GET_CODE (insn
) == JUMP_INSN
)
8946 insn
= next_nonnote_insn (insn
);
8948 if (!insn
|| ! INSN_P (insn
))
8951 /* Let Haifa tell us where it thinks insn group boundaries are. */
8952 if (GET_MODE (insn
) == TImode
)
8955 if (GET_CODE (insn
) == CLOBBER
|| GET_CODE (insn
) == USE
)
8960 insn
= next_nonnote_insn (insn
);
8968 /* IN_USE is a mask of the slots currently filled within the insn group.
8969 The mask bits come from alphaev5_pipe above. If EV5_E01 is set, then
8970 the insn in EV5_E0 can be swapped by the hardware into EV5_E1.
8972 LEN is, of course, the length of the group in bytes. */
8975 alphaev5_next_group (insn
, pin_use
, plen
)
8977 int *pin_use
, *plen
;
8984 || GET_CODE (PATTERN (insn
)) == CLOBBER
8985 || GET_CODE (PATTERN (insn
)) == USE
)
8990 enum alphaev5_pipe pipe
;
8992 pipe
= alphaev5_insn_pipe (insn
);
8996 /* Force complex instructions to start new groups. */
9000 /* If this is a completely unrecognized insn, its an asm.
9001 We don't know how long it is, so record length as -1 to
9002 signal a needed realignment. */
9003 if (recog_memoized (insn
) < 0)
9006 len
= get_attr_length (insn
);
9009 /* ??? Most of the places below, we would like to abort, as
9010 it would indicate an error either in Haifa, or in the
9011 scheduling description. Unfortunately, Haifa never
9012 schedules the last instruction of the BB, so we don't
9013 have an accurate TI bit to go off. */
9015 if (in_use
& EV5_E0
)
9017 if (in_use
& EV5_E1
)
9022 in_use
|= EV5_E0
| EV5_E01
;
9026 if (in_use
& EV5_E0
)
9028 if (!(in_use
& EV5_E01
) || (in_use
& EV5_E1
))
9036 if (in_use
& EV5_E1
)
9042 if (in_use
& EV5_FA
)
9044 if (in_use
& EV5_FM
)
9049 in_use
|= EV5_FA
| EV5_FAM
;
9053 if (in_use
& EV5_FA
)
9059 if (in_use
& EV5_FM
)
9072 /* Haifa doesn't do well scheduling branches. */
9073 /* ??? If this is predicted not-taken, slotting continues, except
9074 that no more IBR, FBR, or JSR insns may be slotted. */
9075 if (GET_CODE (insn
) == JUMP_INSN
)
9079 insn
= next_nonnote_insn (insn
);
9081 if (!insn
|| ! INSN_P (insn
))
9084 /* Let Haifa tell us where it thinks insn group boundaries are. */
9085 if (GET_MODE (insn
) == TImode
)
9088 if (GET_CODE (insn
) == CLOBBER
|| GET_CODE (insn
) == USE
)
9093 insn
= next_nonnote_insn (insn
);
9102 alphaev4_next_nop (pin_use
)
9105 int in_use
= *pin_use
;
9108 if (!(in_use
& EV4_IB0
))
9113 else if ((in_use
& (EV4_IBX
|EV4_IB1
)) == EV4_IBX
)
9118 else if (TARGET_FP
&& !(in_use
& EV4_IB1
))
9131 alphaev5_next_nop (pin_use
)
9134 int in_use
= *pin_use
;
9137 if (!(in_use
& EV5_E1
))
9142 else if (TARGET_FP
&& !(in_use
& EV5_FA
))
9147 else if (TARGET_FP
&& !(in_use
& EV5_FM
))
9159 /* The instruction group alignment main loop. */
9162 alpha_align_insns (insns
, max_align
, next_group
, next_nop
)
9164 unsigned int max_align
;
9165 rtx (*next_group
) PARAMS ((rtx
, int *, int *));
9166 rtx (*next_nop
) PARAMS ((int *));
9168 /* ALIGN is the known alignment for the insn group. */
9170 /* OFS is the offset of the current insn in the insn group. */
9172 int prev_in_use
, in_use
, len
;
9175 /* Let shorten branches care for assigning alignments to code labels. */
9176 shorten_branches (insns
);
9178 if (align_functions
< 4)
9180 else if ((unsigned int) align_functions
< max_align
)
9181 align
= align_functions
;
9185 ofs
= prev_in_use
= 0;
9187 if (GET_CODE (i
) == NOTE
)
9188 i
= next_nonnote_insn (i
);
9192 next
= (*next_group
) (i
, &in_use
, &len
);
9194 /* When we see a label, resync alignment etc. */
9195 if (GET_CODE (i
) == CODE_LABEL
)
9197 unsigned int new_align
= 1 << label_to_alignment (i
);
9199 if (new_align
>= align
)
9201 align
= new_align
< max_align
? new_align
: max_align
;
9205 else if (ofs
& (new_align
-1))
9206 ofs
= (ofs
| (new_align
-1)) + 1;
9211 /* Handle complex instructions special. */
9212 else if (in_use
== 0)
9214 /* Asms will have length < 0. This is a signal that we have
9215 lost alignment knowledge. Assume, however, that the asm
9216 will not mis-align instructions. */
9225 /* If the known alignment is smaller than the recognized insn group,
9226 realign the output. */
9227 else if ((int) align
< len
)
9229 unsigned int new_log_align
= len
> 8 ? 4 : 3;
9232 where
= prev
= prev_nonnote_insn (i
);
9233 if (!where
|| GET_CODE (where
) != CODE_LABEL
)
9236 /* Can't realign between a call and its gp reload. */
9237 if (! (TARGET_EXPLICIT_RELOCS
9238 && prev
&& GET_CODE (prev
) == CALL_INSN
))
9240 emit_insn_before (gen_realign (GEN_INT (new_log_align
)), where
);
9241 align
= 1 << new_log_align
;
9246 /* If the group won't fit in the same INT16 as the previous,
9247 we need to add padding to keep the group together. Rather
9248 than simply leaving the insn filling to the assembler, we
9249 can make use of the knowledge of what sorts of instructions
9250 were issued in the previous group to make sure that all of
9251 the added nops are really free. */
9252 else if (ofs
+ len
> (int) align
)
9254 int nop_count
= (align
- ofs
) / 4;
9257 /* Insert nops before labels, branches, and calls to truely merge
9258 the execution of the nops with the previous instruction group. */
9259 where
= prev_nonnote_insn (i
);
9262 if (GET_CODE (where
) == CODE_LABEL
)
9264 rtx where2
= prev_nonnote_insn (where
);
9265 if (where2
&& GET_CODE (where2
) == JUMP_INSN
)
9268 else if (GET_CODE (where
) == INSN
)
9275 emit_insn_before ((*next_nop
)(&prev_in_use
), where
);
9276 while (--nop_count
);
9280 ofs
= (ofs
+ len
) & (align
- 1);
9281 prev_in_use
= in_use
;
9286 /* Machine dependent reorg pass. */
9292 if (alpha_tp
!= ALPHA_TP_PROG
|| flag_exceptions
)
9293 alpha_handle_trap_shadows (insns
);
9295 /* Due to the number of extra trapb insns, don't bother fixing up
9296 alignment when trap precision is instruction. Moreover, we can
9297 only do our job when sched2 is run. */
9298 if (optimize
&& !optimize_size
9299 && alpha_tp
!= ALPHA_TP_INSN
9300 && flag_schedule_insns_after_reload
)
9302 if (alpha_cpu
== PROCESSOR_EV4
)
9303 alpha_align_insns (insns
, 8, alphaev4_next_group
, alphaev4_next_nop
);
9304 else if (alpha_cpu
== PROCESSOR_EV5
)
9305 alpha_align_insns (insns
, 16, alphaev5_next_group
, alphaev5_next_nop
);
9309 #ifdef OBJECT_FORMAT_ELF
9311 /* Switch to the section to which we should output X. The only thing
9312 special we do here is to honor small data. */
9315 alpha_elf_select_rtx_section (mode
, x
, align
)
9316 enum machine_mode mode
;
9318 unsigned HOST_WIDE_INT align
;
9320 if (TARGET_SMALL_DATA
&& GET_MODE_SIZE (mode
) <= g_switch_value
)
9321 /* ??? Consider using mergable sdata sections. */
9324 default_elf_select_rtx_section (mode
, x
, align
);
9327 #endif /* OBJECT_FORMAT_ELF */
9329 /* Structure to collect function names for final output in link section. */
9330 /* Note that items marked with GTY can't be ifdef'ed out. */
9332 enum links_kind
{KIND_UNUSED
, KIND_LOCAL
, KIND_EXTERN
};
9333 enum reloc_kind
{KIND_LINKAGE
, KIND_CODEADDR
};
9335 struct alpha_links
GTY(())
9339 enum links_kind lkind
;
9340 enum reloc_kind rkind
;
9343 struct alpha_funcs
GTY(())
9346 splay_tree
GTY ((param1_is (char *), param2_is (struct alpha_links
*)))
9350 static GTY ((param1_is (char *), param2_is (struct alpha_links
*)))
9351 splay_tree alpha_links_tree
;
9352 static GTY ((param1_is (tree
), param2_is (struct alpha_funcs
*)))
9353 splay_tree alpha_funcs_tree
;
9355 static GTY(()) int alpha_funcs_num
;
9357 #if TARGET_ABI_OPEN_VMS
9359 /* Return the VMS argument type corresponding to MODE. */
9362 alpha_arg_type (mode
)
9363 enum machine_mode mode
;
9368 return TARGET_FLOAT_VAX
? FF
: FS
;
9370 return TARGET_FLOAT_VAX
? FD
: FT
;
9376 /* Return an rtx for an integer representing the VMS Argument Information
9380 alpha_arg_info_reg_val (cum
)
9381 CUMULATIVE_ARGS cum
;
9383 unsigned HOST_WIDE_INT regval
= cum
.num_args
;
9386 for (i
= 0; i
< 6; i
++)
9387 regval
|= ((int) cum
.atypes
[i
]) << (i
* 3 + 8);
9389 return GEN_INT (regval
);
9392 /* Make (or fake) .linkage entry for function call.
9394 IS_LOCAL is 0 if name is used in call, 1 if name is used in definition.
9396 Return an SYMBOL_REF rtx for the linkage. */
9399 alpha_need_linkage (name
, is_local
)
9403 splay_tree_node node
;
9404 struct alpha_links
*al
;
9411 struct alpha_funcs
*cfaf
;
9413 if (!alpha_funcs_tree
)
9414 alpha_funcs_tree
= splay_tree_new_ggc ((splay_tree_compare_fn
)
9415 splay_tree_compare_pointers
);
9417 cfaf
= (struct alpha_funcs
*) ggc_alloc (sizeof (struct alpha_funcs
));
9420 cfaf
->num
= ++alpha_funcs_num
;
9422 splay_tree_insert (alpha_funcs_tree
,
9423 (splay_tree_key
) current_function_decl
,
9424 (splay_tree_value
) cfaf
);
9427 if (alpha_links_tree
)
9429 /* Is this name already defined? */
9431 node
= splay_tree_lookup (alpha_links_tree
, (splay_tree_key
) name
);
9434 al
= (struct alpha_links
*) node
->value
;
9437 /* Defined here but external assumed. */
9438 if (al
->lkind
== KIND_EXTERN
)
9439 al
->lkind
= KIND_LOCAL
;
9443 /* Used here but unused assumed. */
9444 if (al
->lkind
== KIND_UNUSED
)
9445 al
->lkind
= KIND_LOCAL
;
9451 alpha_links_tree
= splay_tree_new_ggc ((splay_tree_compare_fn
) strcmp
);
9453 al
= (struct alpha_links
*) ggc_alloc (sizeof (struct alpha_links
));
9454 name
= ggc_strdup (name
);
9456 /* Assume external if no definition. */
9457 al
->lkind
= (is_local
? KIND_UNUSED
: KIND_EXTERN
);
9459 /* Ensure we have an IDENTIFIER so assemble_name can mark it used. */
9460 get_identifier (name
);
9462 /* Construct a SYMBOL_REF for us to call. */
9464 size_t name_len
= strlen (name
);
9465 char *linksym
= alloca (name_len
+ 6);
9467 memcpy (linksym
+ 1, name
, name_len
);
9468 memcpy (linksym
+ 1 + name_len
, "..lk", 5);
9469 al
->linkage
= gen_rtx_SYMBOL_REF (Pmode
,
9470 ggc_alloc_string (linksym
, name_len
+ 5));
9473 splay_tree_insert (alpha_links_tree
, (splay_tree_key
) name
,
9474 (splay_tree_value
) al
);
9480 alpha_use_linkage (linkage
, cfundecl
, lflag
, rflag
)
9486 splay_tree_node cfunnode
;
9487 struct alpha_funcs
*cfaf
;
9488 struct alpha_links
*al
;
9489 const char *name
= XSTR (linkage
, 0);
9491 cfaf
= (struct alpha_funcs
*) 0;
9492 al
= (struct alpha_links
*) 0;
9494 cfunnode
= splay_tree_lookup (alpha_funcs_tree
, (splay_tree_key
) cfundecl
);
9495 cfaf
= (struct alpha_funcs
*) cfunnode
->value
;
9499 splay_tree_node lnode
;
9501 /* Is this name already defined? */
9503 lnode
= splay_tree_lookup (cfaf
->links
, (splay_tree_key
) name
);
9505 al
= (struct alpha_links
*) lnode
->value
;
9508 cfaf
->links
= splay_tree_new_ggc ((splay_tree_compare_fn
) strcmp
);
9516 splay_tree_node node
= 0;
9517 struct alpha_links
*anl
;
9522 name_len
= strlen (name
);
9524 al
= (struct alpha_links
*) ggc_alloc (sizeof (struct alpha_links
));
9525 al
->num
= cfaf
->num
;
9527 node
= splay_tree_lookup (alpha_links_tree
, (splay_tree_key
) name
);
9530 anl
= (struct alpha_links
*) node
->value
;
9531 al
->lkind
= anl
->lkind
;
9534 sprintf (buf
, "$%d..%s..lk", cfaf
->num
, name
);
9535 buflen
= strlen (buf
);
9536 linksym
= alloca (buflen
+ 1);
9537 memcpy (linksym
, buf
, buflen
+ 1);
9539 al
->linkage
= gen_rtx_SYMBOL_REF
9540 (Pmode
, ggc_alloc_string (linksym
, buflen
+ 1));
9542 splay_tree_insert (cfaf
->links
, (splay_tree_key
) name
,
9543 (splay_tree_value
) al
);
9547 al
->rkind
= KIND_CODEADDR
;
9549 al
->rkind
= KIND_LINKAGE
;
9552 return gen_rtx_MEM (Pmode
, plus_constant (al
->linkage
, 8));
9558 alpha_write_one_linkage (node
, data
)
9559 splay_tree_node node
;
9562 const char *const name
= (const char *) node
->key
;
9563 struct alpha_links
*link
= (struct alpha_links
*) node
->value
;
9564 FILE *stream
= (FILE *) data
;
9566 fprintf (stream
, "$%d..%s..lk:\n", link
->num
, name
);
9567 if (link
->rkind
== KIND_CODEADDR
)
9569 if (link
->lkind
== KIND_LOCAL
)
9571 /* Local and used */
9572 fprintf (stream
, "\t.quad %s..en\n", name
);
9576 /* External and used, request code address. */
9577 fprintf (stream
, "\t.code_address %s\n", name
);
9582 if (link
->lkind
== KIND_LOCAL
)
9584 /* Local and used, build linkage pair. */
9585 fprintf (stream
, "\t.quad %s..en\n", name
);
9586 fprintf (stream
, "\t.quad %s\n", name
);
9590 /* External and used, request linkage pair. */
9591 fprintf (stream
, "\t.linkage %s\n", name
);
9599 alpha_write_linkage (stream
, funname
, fundecl
)
9601 const char *funname
;
9604 splay_tree_node node
;
9605 struct alpha_funcs
*func
;
9608 fprintf (stream
, "\t.align 3\n");
9609 node
= splay_tree_lookup (alpha_funcs_tree
, (splay_tree_key
) fundecl
);
9610 func
= (struct alpha_funcs
*) node
->value
;
9612 fputs ("\t.name ", stream
);
9613 assemble_name (stream
, funname
);
9614 fputs ("..na\n", stream
);
9615 ASM_OUTPUT_LABEL (stream
, funname
);
9616 fprintf (stream
, "\t.pdesc ");
9617 assemble_name (stream
, funname
);
9618 fprintf (stream
, "..en,%s\n",
9619 alpha_procedure_type
== PT_STACK
? "stack"
9620 : alpha_procedure_type
== PT_REGISTER
? "reg" : "null");
9624 splay_tree_foreach (func
->links
, alpha_write_one_linkage
, stream
);
9625 /* splay_tree_delete (func->links); */
9629 /* Given a decl, a section name, and whether the decl initializer
9630 has relocs, choose attributes for the section. */
9632 #define SECTION_VMS_OVERLAY SECTION_FORGET
9633 #define SECTION_VMS_GLOBAL SECTION_MACH_DEP
9634 #define SECTION_VMS_INITIALIZE (SECTION_VMS_GLOBAL << 1)
9637 vms_section_type_flags (decl
, name
, reloc
)
9642 unsigned int flags
= default_section_type_flags (decl
, name
, reloc
);
9644 if (decl
&& DECL_ATTRIBUTES (decl
)
9645 && lookup_attribute ("overlaid", DECL_ATTRIBUTES (decl
)))
9646 flags
|= SECTION_VMS_OVERLAY
;
9647 if (decl
&& DECL_ATTRIBUTES (decl
)
9648 && lookup_attribute ("global", DECL_ATTRIBUTES (decl
)))
9649 flags
|= SECTION_VMS_GLOBAL
;
9650 if (decl
&& DECL_ATTRIBUTES (decl
)
9651 && lookup_attribute ("initialize", DECL_ATTRIBUTES (decl
)))
9652 flags
|= SECTION_VMS_INITIALIZE
;
9657 /* Switch to an arbitrary section NAME with attributes as specified
9658 by FLAGS. ALIGN specifies any known alignment requirements for
9659 the section; 0 if the default should be used. */
9662 vms_asm_named_section (name
, flags
)
9666 fputc ('\n', asm_out_file
);
9667 fprintf (asm_out_file
, ".section\t%s", name
);
9669 if (flags
& SECTION_VMS_OVERLAY
)
9670 fprintf (asm_out_file
, ",OVR");
9671 if (flags
& SECTION_VMS_GLOBAL
)
9672 fprintf (asm_out_file
, ",GBL");
9673 if (flags
& SECTION_VMS_INITIALIZE
)
9674 fprintf (asm_out_file
, ",NOMOD");
9675 if (flags
& SECTION_DEBUG
)
9676 fprintf (asm_out_file
, ",NOWRT");
9678 fputc ('\n', asm_out_file
);
9681 /* Record an element in the table of global constructors. SYMBOL is
9682 a SYMBOL_REF of the function to be called; PRIORITY is a number
9683 between 0 and MAX_INIT_PRIORITY.
9685 Differs from default_ctors_section_asm_out_constructor in that the
9686 width of the .ctors entry is always 64 bits, rather than the 32 bits
9687 used by a normal pointer. */
9690 vms_asm_out_constructor (symbol
, priority
)
9692 int priority ATTRIBUTE_UNUSED
;
9695 assemble_align (BITS_PER_WORD
);
9696 assemble_integer (symbol
, UNITS_PER_WORD
, BITS_PER_WORD
, 1);
9700 vms_asm_out_destructor (symbol
, priority
)
9702 int priority ATTRIBUTE_UNUSED
;
9705 assemble_align (BITS_PER_WORD
);
9706 assemble_integer (symbol
, UNITS_PER_WORD
, BITS_PER_WORD
, 1);
9711 alpha_need_linkage (name
, is_local
)
9712 const char *name ATTRIBUTE_UNUSED
;
9713 int is_local ATTRIBUTE_UNUSED
;
9719 alpha_use_linkage (linkage
, cfundecl
, lflag
, rflag
)
9720 rtx linkage ATTRIBUTE_UNUSED
;
9721 tree cfundecl ATTRIBUTE_UNUSED
;
9722 int lflag ATTRIBUTE_UNUSED
;
9723 int rflag ATTRIBUTE_UNUSED
;
9728 #endif /* TARGET_ABI_OPEN_VMS */
9730 #if TARGET_ABI_UNICOSMK
9732 static void unicosmk_output_module_name
PARAMS ((FILE *));
9733 static void unicosmk_output_default_externs
PARAMS ((FILE *));
9734 static void unicosmk_output_dex
PARAMS ((FILE *));
9735 static void unicosmk_output_externs
PARAMS ((FILE *));
9736 static void unicosmk_output_addr_vec
PARAMS ((FILE *, rtx
));
9737 static const char *unicosmk_ssib_name
PARAMS ((void));
9738 static int unicosmk_special_name
PARAMS ((const char *));
9740 /* Define the offset between two registers, one to be eliminated, and the
9741 other its replacement, at the start of a routine. */
9744 unicosmk_initial_elimination_offset (from
, to
)
9750 fixed_size
= alpha_sa_size();
9751 if (fixed_size
!= 0)
9754 if (from
== FRAME_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
9756 else if (from
== ARG_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
9758 else if (from
== FRAME_POINTER_REGNUM
&& to
== STACK_POINTER_REGNUM
)
9759 return (ALPHA_ROUND (current_function_outgoing_args_size
)
9760 + ALPHA_ROUND (get_frame_size()));
9761 else if (from
== ARG_POINTER_REGNUM
&& to
== STACK_POINTER_REGNUM
)
9762 return (ALPHA_ROUND (fixed_size
)
9763 + ALPHA_ROUND (get_frame_size()
9764 + current_function_outgoing_args_size
));
9769 /* Output the module name for .ident and .end directives. We have to strip
9770 directories and add make sure that the module name starts with a letter
9774 unicosmk_output_module_name (file
)
9779 /* Strip directories. */
9781 name
= strrchr (main_input_filename
, '/');
9785 name
= main_input_filename
;
9787 /* CAM only accepts module names that start with a letter or '$'. We
9788 prefix the module name with a '$' if necessary. */
9790 if (!ISALPHA (*name
))
9792 output_clean_symbol_name (file
, name
);
9795 /* Output text that to appear at the beginning of an assembler file. */
9798 unicosmk_asm_file_start (file
)
9803 fputs ("\t.ident\t", file
);
9804 unicosmk_output_module_name (file
);
9805 fputs ("\n\n", file
);
9807 /* The Unicos/Mk assembler uses different register names. Instead of trying
9808 to support them, we simply use micro definitions. */
9810 /* CAM has different register names: rN for the integer register N and fN
9811 for the floating-point register N. Instead of trying to use these in
9812 alpha.md, we define the symbols $N and $fN to refer to the appropriate
9815 for (i
= 0; i
< 32; ++i
)
9816 fprintf (file
, "$%d <- r%d\n", i
, i
);
9818 for (i
= 0; i
< 32; ++i
)
9819 fprintf (file
, "$f%d <- f%d\n", i
, i
);
9823 /* The .align directive fill unused space with zeroes which does not work
9824 in code sections. We define the macro 'gcc@code@align' which uses nops
9825 instead. Note that it assumes that code sections always have the
9826 biggest possible alignment since . refers to the current offset from
9827 the beginning of the section. */
9829 fputs ("\t.macro gcc@code@align n\n", file
);
9830 fputs ("gcc@n@bytes = 1 << n\n", file
);
9831 fputs ("gcc@here = . % gcc@n@bytes\n", file
);
9832 fputs ("\t.if ne, gcc@here, 0\n", file
);
9833 fputs ("\t.repeat (gcc@n@bytes - gcc@here) / 4\n", file
);
9834 fputs ("\tbis r31,r31,r31\n", file
);
9835 fputs ("\t.endr\n", file
);
9836 fputs ("\t.endif\n", file
);
9837 fputs ("\t.endm gcc@code@align\n\n", file
);
9839 /* Output extern declarations which should always be visible. */
9840 unicosmk_output_default_externs (file
);
9842 /* Open a dummy section. We always need to be inside a section for the
9843 section-switching code to work correctly.
9844 ??? This should be a module id or something like that. I still have to
9845 figure out what the rules for those are. */
9846 fputs ("\n\t.psect\t$SG00000,data\n", file
);
9849 /* Output text to appear at the end of an assembler file. This includes all
9850 pending extern declarations and DEX expressions. */
9853 unicosmk_asm_file_end (file
)
9856 fputs ("\t.endp\n\n", file
);
9858 /* Output all pending externs. */
9860 unicosmk_output_externs (file
);
9862 /* Output dex definitions used for functions whose names conflict with
9865 unicosmk_output_dex (file
);
9867 fputs ("\t.end\t", file
);
9868 unicosmk_output_module_name (file
);
9872 /* Output the definition of a common variable. */
9875 unicosmk_output_common (file
, name
, size
, align
)
9882 printf ("T3E__: common %s\n", name
);
9885 fputs("\t.endp\n\n\t.psect ", file
);
9886 assemble_name(file
, name
);
9887 fprintf(file
, ",%d,common\n", floor_log2 (align
/ BITS_PER_UNIT
));
9888 fprintf(file
, "\t.byte\t0:%d\n", size
);
9890 /* Mark the symbol as defined in this module. */
9891 name_tree
= get_identifier (name
);
9892 TREE_ASM_WRITTEN (name_tree
) = 1;
9895 #define SECTION_PUBLIC SECTION_MACH_DEP
9896 #define SECTION_MAIN (SECTION_PUBLIC << 1)
9897 static int current_section_align
;
9900 unicosmk_section_type_flags (decl
, name
, reloc
)
9903 int reloc ATTRIBUTE_UNUSED
;
9905 unsigned int flags
= default_section_type_flags (decl
, name
, reloc
);
9910 if (TREE_CODE (decl
) == FUNCTION_DECL
)
9912 current_section_align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
9913 if (align_functions_log
> current_section_align
)
9914 current_section_align
= align_functions_log
;
9916 if (! strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), "main"))
9917 flags
|= SECTION_MAIN
;
9920 current_section_align
= floor_log2 (DECL_ALIGN (decl
) / BITS_PER_UNIT
);
9922 if (TREE_PUBLIC (decl
))
9923 flags
|= SECTION_PUBLIC
;
9928 /* Generate a section name for decl and associate it with the
9932 unicosmk_unique_section (decl
, reloc
)
9934 int reloc ATTRIBUTE_UNUSED
;
9942 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
9943 name
= alpha_strip_name_encoding (name
);
9944 len
= strlen (name
);
9946 if (TREE_CODE (decl
) == FUNCTION_DECL
)
9950 /* It is essential that we prefix the section name here because
9951 otherwise the section names generated for constructors and
9952 destructors confuse collect2. */
9954 string
= alloca (len
+ 6);
9955 sprintf (string
, "code@%s", name
);
9956 DECL_SECTION_NAME (decl
) = build_string (len
+ 5, string
);
9958 else if (TREE_PUBLIC (decl
))
9959 DECL_SECTION_NAME (decl
) = build_string (len
, name
);
9964 string
= alloca (len
+ 6);
9965 sprintf (string
, "data@%s", name
);
9966 DECL_SECTION_NAME (decl
) = build_string (len
+ 5, string
);
9970 /* Switch to an arbitrary section NAME with attributes as specified
9971 by FLAGS. ALIGN specifies any known alignment requirements for
9972 the section; 0 if the default should be used. */
9975 unicosmk_asm_named_section (name
, flags
)
9981 /* Close the previous section. */
9983 fputs ("\t.endp\n\n", asm_out_file
);
9985 /* Find out what kind of section we are opening. */
9987 if (flags
& SECTION_MAIN
)
9988 fputs ("\t.start\tmain\n", asm_out_file
);
9990 if (flags
& SECTION_CODE
)
9992 else if (flags
& SECTION_PUBLIC
)
9997 if (current_section_align
!= 0)
9998 fprintf (asm_out_file
, "\t.psect\t%s,%d,%s\n", name
,
9999 current_section_align
, kind
);
10001 fprintf (asm_out_file
, "\t.psect\t%s,%s\n", name
, kind
);
10005 unicosmk_insert_attributes (decl
, attr_ptr
)
10007 tree
*attr_ptr ATTRIBUTE_UNUSED
;
10010 && (TREE_PUBLIC (decl
) || TREE_CODE (decl
) == FUNCTION_DECL
))
10011 unicosmk_unique_section (decl
, 0);
10014 /* Output an alignment directive. We have to use the macro 'gcc@code@align'
10015 in code sections because .align fill unused space with zeroes. */
10018 unicosmk_output_align (file
, align
)
10022 if (inside_function
)
10023 fprintf (file
, "\tgcc@code@align\t%d\n", align
);
10025 fprintf (file
, "\t.align\t%d\n", align
);
10028 /* Add a case vector to the current function's list of deferred case
10029 vectors. Case vectors have to be put into a separate section because CAM
10030 does not allow data definitions in code sections. */
10033 unicosmk_defer_case_vector (lab
, vec
)
10037 struct machine_function
*machine
= cfun
->machine
;
10039 vec
= gen_rtx_EXPR_LIST (VOIDmode
, lab
, vec
);
10040 machine
->addr_list
= gen_rtx_EXPR_LIST (VOIDmode
, vec
,
10041 machine
->addr_list
);
10044 /* Output a case vector. */
10047 unicosmk_output_addr_vec (file
, vec
)
10051 rtx lab
= XEXP (vec
, 0);
10052 rtx body
= XEXP (vec
, 1);
10053 int vlen
= XVECLEN (body
, 0);
10056 (*targetm
.asm_out
.internal_label
) (file
, "L", CODE_LABEL_NUMBER (lab
));
10058 for (idx
= 0; idx
< vlen
; idx
++)
10060 ASM_OUTPUT_ADDR_VEC_ELT
10061 (file
, CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 0, idx
), 0)));
10065 /* Output current function's deferred case vectors. */
10068 unicosmk_output_deferred_case_vectors (file
)
10071 struct machine_function
*machine
= cfun
->machine
;
10074 if (machine
->addr_list
== NULL_RTX
)
10078 for (t
= machine
->addr_list
; t
; t
= XEXP (t
, 1))
10079 unicosmk_output_addr_vec (file
, XEXP (t
, 0));
10082 /* Set up the dynamic subprogram information block (DSIB) and update the
10083 frame pointer register ($15) for subroutines which have a frame. If the
10084 subroutine doesn't have a frame, simply increment $15. */
10087 unicosmk_gen_dsib (imaskP
)
10088 unsigned long * imaskP
;
10090 if (alpha_procedure_type
== PT_STACK
)
10092 const char *ssib_name
;
10095 /* Allocate 64 bytes for the DSIB. */
10097 FRP (emit_insn (gen_adddi3 (stack_pointer_rtx
, stack_pointer_rtx
,
10099 emit_insn (gen_blockage ());
10101 /* Save the return address. */
10103 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 56));
10104 set_mem_alias_set (mem
, alpha_sr_alias_set
);
10105 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, REG_RA
)));
10106 (*imaskP
) &= ~(1L << REG_RA
);
10108 /* Save the old frame pointer. */
10110 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 48));
10111 set_mem_alias_set (mem
, alpha_sr_alias_set
);
10112 FRP (emit_move_insn (mem
, hard_frame_pointer_rtx
));
10113 (*imaskP
) &= ~(1L << HARD_FRAME_POINTER_REGNUM
);
10115 emit_insn (gen_blockage ());
10117 /* Store the SSIB pointer. */
10119 ssib_name
= ggc_strdup (unicosmk_ssib_name ());
10120 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 32));
10121 set_mem_alias_set (mem
, alpha_sr_alias_set
);
10123 FRP (emit_move_insn (gen_rtx_REG (DImode
, 5),
10124 gen_rtx_SYMBOL_REF (Pmode
, ssib_name
)));
10125 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, 5)));
10127 /* Save the CIW index. */
10129 mem
= gen_rtx_MEM (DImode
, plus_constant (stack_pointer_rtx
, 24));
10130 set_mem_alias_set (mem
, alpha_sr_alias_set
);
10131 FRP (emit_move_insn (mem
, gen_rtx_REG (DImode
, 25)));
10133 emit_insn (gen_blockage ());
10135 /* Set the new frame pointer. */
10137 FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx
,
10138 stack_pointer_rtx
, GEN_INT (64))));
10143 /* Increment the frame pointer register to indicate that we do not
10146 FRP (emit_insn (gen_adddi3 (hard_frame_pointer_rtx
,
10147 hard_frame_pointer_rtx
, GEN_INT (1))));
10151 #define SSIB_PREFIX "__SSIB_"
10152 #define SSIB_PREFIX_LEN 7
10154 /* Generate the name of the SSIB section for the current function. */
10156 static const char *
10157 unicosmk_ssib_name ()
10159 /* This is ok since CAM won't be able to deal with names longer than that
10162 static char name
[256];
10165 const char *fnname
;
10168 x
= DECL_RTL (cfun
->decl
);
10169 if (GET_CODE (x
) != MEM
)
10172 if (GET_CODE (x
) != SYMBOL_REF
)
10174 fnname
= alpha_strip_name_encoding (XSTR (x
, 0));
10176 len
= strlen (fnname
);
10177 if (len
+ SSIB_PREFIX_LEN
> 255)
10178 len
= 255 - SSIB_PREFIX_LEN
;
10180 strcpy (name
, SSIB_PREFIX
);
10181 strncpy (name
+ SSIB_PREFIX_LEN
, fnname
, len
);
10182 name
[len
+ SSIB_PREFIX_LEN
] = 0;
10187 /* Output the static subroutine information block for the current
10191 unicosmk_output_ssib (file
, fnname
)
10193 const char *fnname
;
10199 struct machine_function
*machine
= cfun
->machine
;
10202 fprintf (file
, "\t.endp\n\n\t.psect\t%s%s,data\n", user_label_prefix
,
10203 unicosmk_ssib_name ());
10205 /* Some required stuff and the function name length. */
10207 len
= strlen (fnname
);
10208 fprintf (file
, "\t.quad\t^X20008%2.2X28\n", len
);
10211 ??? We don't do that yet. */
10213 fputs ("\t.quad\t0\n", file
);
10215 /* Function address. */
10217 fputs ("\t.quad\t", file
);
10218 assemble_name (file
, fnname
);
10221 fputs ("\t.quad\t0\n", file
);
10222 fputs ("\t.quad\t0\n", file
);
10225 ??? We do it the same way Cray CC does it but this could be
10228 for( i
= 0; i
< len
; i
++ )
10229 fprintf (file
, "\t.byte\t%d\n", (int)(fnname
[i
]));
10230 if( (len
% 8) == 0 )
10231 fputs ("\t.quad\t0\n", file
);
10233 fprintf (file
, "\t.bits\t%d : 0\n", (8 - (len
% 8))*8);
10235 /* All call information words used in the function. */
10237 for (x
= machine
->first_ciw
; x
; x
= XEXP (x
, 1))
10240 fprintf (file
, "\t.quad\t");
10241 #if HOST_BITS_PER_WIDE_INT == 32
10242 fprintf (file
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
10243 CONST_DOUBLE_HIGH (ciw
), CONST_DOUBLE_LOW (ciw
));
10245 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
, INTVAL (ciw
));
10247 fprintf (file
, "\n");
10251 /* Add a call information word (CIW) to the list of the current function's
10252 CIWs and return its index.
10254 X is a CONST_INT or CONST_DOUBLE representing the CIW. */
10257 unicosmk_add_call_info_word (x
)
10261 struct machine_function
*machine
= cfun
->machine
;
10263 node
= gen_rtx_EXPR_LIST (VOIDmode
, x
, NULL_RTX
);
10264 if (machine
->first_ciw
== NULL_RTX
)
10265 machine
->first_ciw
= node
;
10267 XEXP (machine
->last_ciw
, 1) = node
;
10269 machine
->last_ciw
= node
;
10270 ++machine
->ciw_count
;
10272 return GEN_INT (machine
->ciw_count
10273 + strlen (current_function_name
)/8 + 5);
10276 static char unicosmk_section_buf
[100];
10279 unicosmk_text_section ()
10281 static int count
= 0;
10282 sprintf (unicosmk_section_buf
, "\t.endp\n\n\t.psect\tgcc@text___%d,code",
10284 return unicosmk_section_buf
;
10288 unicosmk_data_section ()
10290 static int count
= 1;
10291 sprintf (unicosmk_section_buf
, "\t.endp\n\n\t.psect\tgcc@data___%d,data",
10293 return unicosmk_section_buf
;
10296 /* The Cray assembler doesn't accept extern declarations for symbols which
10297 are defined in the same file. We have to keep track of all global
10298 symbols which are referenced and/or defined in a source file and output
10299 extern declarations for those which are referenced but not defined at
10300 the end of file. */
10302 /* List of identifiers for which an extern declaration might have to be
10304 /* FIXME: needs to use GC, so it can be saved and restored for PCH. */
10306 struct unicosmk_extern_list
10308 struct unicosmk_extern_list
*next
;
10312 static struct unicosmk_extern_list
*unicosmk_extern_head
= 0;
10314 /* Output extern declarations which are required for every asm file. */
10317 unicosmk_output_default_externs (file
)
10320 static const char *const externs
[] =
10321 { "__T3E_MISMATCH" };
10326 n
= ARRAY_SIZE (externs
);
10328 for (i
= 0; i
< n
; i
++)
10329 fprintf (file
, "\t.extern\t%s\n", externs
[i
]);
10332 /* Output extern declarations for global symbols which are have been
10333 referenced but not defined. */
10336 unicosmk_output_externs (file
)
10339 struct unicosmk_extern_list
*p
;
10340 const char *real_name
;
10344 len
= strlen (user_label_prefix
);
10345 for (p
= unicosmk_extern_head
; p
!= 0; p
= p
->next
)
10347 /* We have to strip the encoding and possibly remove user_label_prefix
10348 from the identifier in order to handle -fleading-underscore and
10349 explicit asm names correctly (cf. gcc.dg/asm-names-1.c). */
10350 real_name
= alpha_strip_name_encoding (p
->name
);
10351 if (len
&& p
->name
[0] == '*'
10352 && !memcmp (real_name
, user_label_prefix
, len
))
10355 name_tree
= get_identifier (real_name
);
10356 if (! TREE_ASM_WRITTEN (name_tree
))
10358 TREE_ASM_WRITTEN (name_tree
) = 1;
10359 fputs ("\t.extern\t", file
);
10360 assemble_name (file
, p
->name
);
10366 /* Record an extern. */
10369 unicosmk_add_extern (name
)
10372 struct unicosmk_extern_list
*p
;
10374 p
= (struct unicosmk_extern_list
*)
10375 xmalloc (sizeof (struct unicosmk_extern_list
));
10376 p
->next
= unicosmk_extern_head
;
10378 unicosmk_extern_head
= p
;
10381 /* The Cray assembler generates incorrect code if identifiers which
10382 conflict with register names are used as instruction operands. We have
10383 to replace such identifiers with DEX expressions. */
10385 /* Structure to collect identifiers which have been replaced by DEX
10387 /* FIXME: needs to use GC, so it can be saved and restored for PCH. */
10389 struct unicosmk_dex
{
10390 struct unicosmk_dex
*next
;
10394 /* List of identifiers which have been replaced by DEX expressions. The DEX
10395 number is determined by the position in the list. */
10397 static struct unicosmk_dex
*unicosmk_dex_list
= NULL
;
10399 /* The number of elements in the DEX list. */
10401 static int unicosmk_dex_count
= 0;
10403 /* Check if NAME must be replaced by a DEX expression. */
10406 unicosmk_special_name (name
)
10409 if (name
[0] == '*')
10412 if (name
[0] == '$')
10415 if (name
[0] != 'r' && name
[0] != 'f' && name
[0] != 'R' && name
[0] != 'F')
10420 case '1': case '2':
10421 return (name
[2] == '\0' || (ISDIGIT (name
[2]) && name
[3] == '\0'));
10424 return (name
[2] == '\0'
10425 || ((name
[2] == '0' || name
[2] == '1') && name
[3] == '\0'));
10428 return (ISDIGIT (name
[1]) && name
[2] == '\0');
10432 /* Return the DEX number if X must be replaced by a DEX expression and 0
10436 unicosmk_need_dex (x
)
10439 struct unicosmk_dex
*dex
;
10443 if (GET_CODE (x
) != SYMBOL_REF
)
10447 if (! unicosmk_special_name (name
))
10450 i
= unicosmk_dex_count
;
10451 for (dex
= unicosmk_dex_list
; dex
; dex
= dex
->next
)
10453 if (! strcmp (name
, dex
->name
))
10458 dex
= (struct unicosmk_dex
*) xmalloc (sizeof (struct unicosmk_dex
));
10460 dex
->next
= unicosmk_dex_list
;
10461 unicosmk_dex_list
= dex
;
10463 ++unicosmk_dex_count
;
10464 return unicosmk_dex_count
;
10467 /* Output the DEX definitions for this file. */
10470 unicosmk_output_dex (file
)
10473 struct unicosmk_dex
*dex
;
10476 if (unicosmk_dex_list
== NULL
)
10479 fprintf (file
, "\t.dexstart\n");
10481 i
= unicosmk_dex_count
;
10482 for (dex
= unicosmk_dex_list
; dex
; dex
= dex
->next
)
10484 fprintf (file
, "\tDEX (%d) = ", i
);
10485 assemble_name (file
, dex
->name
);
10490 fprintf (file
, "\t.dexend\n");
10496 unicosmk_output_deferred_case_vectors (file
)
10497 FILE *file ATTRIBUTE_UNUSED
;
10501 unicosmk_gen_dsib (imaskP
)
10502 unsigned long * imaskP ATTRIBUTE_UNUSED
;
10506 unicosmk_output_ssib (file
, fnname
)
10507 FILE * file ATTRIBUTE_UNUSED
;
10508 const char * fnname ATTRIBUTE_UNUSED
;
10512 unicosmk_add_call_info_word (x
)
10513 rtx x ATTRIBUTE_UNUSED
;
10519 unicosmk_need_dex (x
)
10520 rtx x ATTRIBUTE_UNUSED
;
10525 #endif /* TARGET_ABI_UNICOSMK */
10527 #include "gt-alpha.h"