1 /* Subroutines for insn-output.c for Sun SPARC.
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
4 Contributed by Michael Tiemann (tiemann@cygnus.com)
5 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
8 This file is part of GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
30 #include "hard-reg-set.h"
32 #include "insn-config.h"
33 #include "conditions.h"
35 #include "insn-attr.h"
47 #include "target-def.h"
49 /* 1 if the caller has placed an "unimp" insn immediately after the call.
50 This is used in v8 code when calling a function that returns a structure.
51 v9 doesn't have this. Be careful to have this test be the same as that
54 #define SKIP_CALLERS_UNIMP_P \
55 (!TARGET_ARCH64 && current_function_returns_struct \
56 && ! integer_zerop (DECL_SIZE (DECL_RESULT (current_function_decl))) \
57 && (TREE_CODE (DECL_SIZE (DECL_RESULT (current_function_decl))) \
60 /* Global variables for machine-dependent things. */
62 /* Size of frame. Need to know this to emit return insns from leaf procedures.
63 ACTUAL_FSIZE is set by compute_frame_size() which is called during the
64 reload pass. This is important as the value is later used in insn
65 scheduling (to see what can go in a delay slot).
66 APPARENT_FSIZE is the size of the stack less the register save area and less
67 the outgoing argument area. It is used when saving call preserved regs. */
68 static int apparent_fsize
;
69 static int actual_fsize
;
71 /* Number of live general or floating point registers needed to be
72 saved (as 4-byte quantities). */
73 static int num_gfregs
;
75 /* Save the operands last given to a compare for use when we
76 generate a scc or bcc insn. */
77 rtx sparc_compare_op0
, sparc_compare_op1
;
79 /* Coordinate with the md file wrt special insns created by
80 sparc_nonflat_function_epilogue. */
81 bool sparc_emitting_epilogue
;
85 /* Vector to say how input registers are mapped to output registers.
86 HARD_FRAME_POINTER_REGNUM cannot be remapped by this function to
87 eliminate it. You must use -fomit-frame-pointer to get that. */
88 const char leaf_reg_remap
[] =
89 { 0, 1, 2, 3, 4, 5, 6, 7,
90 -1, -1, -1, -1, -1, -1, 14, -1,
91 -1, -1, -1, -1, -1, -1, -1, -1,
92 8, 9, 10, 11, 12, 13, -1, 15,
94 32, 33, 34, 35, 36, 37, 38, 39,
95 40, 41, 42, 43, 44, 45, 46, 47,
96 48, 49, 50, 51, 52, 53, 54, 55,
97 56, 57, 58, 59, 60, 61, 62, 63,
98 64, 65, 66, 67, 68, 69, 70, 71,
99 72, 73, 74, 75, 76, 77, 78, 79,
100 80, 81, 82, 83, 84, 85, 86, 87,
101 88, 89, 90, 91, 92, 93, 94, 95,
102 96, 97, 98, 99, 100};
104 /* Vector, indexed by hard register number, which contains 1
105 for a register that is allowable in a candidate for leaf
106 function treatment. */
107 char sparc_leaf_regs
[] =
108 { 1, 1, 1, 1, 1, 1, 1, 1,
109 0, 0, 0, 0, 0, 0, 1, 0,
110 0, 0, 0, 0, 0, 0, 0, 0,
111 1, 1, 1, 1, 1, 1, 0, 1,
112 1, 1, 1, 1, 1, 1, 1, 1,
113 1, 1, 1, 1, 1, 1, 1, 1,
114 1, 1, 1, 1, 1, 1, 1, 1,
115 1, 1, 1, 1, 1, 1, 1, 1,
116 1, 1, 1, 1, 1, 1, 1, 1,
117 1, 1, 1, 1, 1, 1, 1, 1,
118 1, 1, 1, 1, 1, 1, 1, 1,
119 1, 1, 1, 1, 1, 1, 1, 1,
124 /* Name of where we pretend to think the frame pointer points.
125 Normally, this is "%fp", but if we are in a leaf procedure,
126 this is "%sp+something". We record "something" separately as it may be
127 too big for reg+constant addressing. */
129 static const char *frame_base_name
;
130 static int frame_base_offset
;
132 static void sparc_init_modes
PARAMS ((void));
133 static int save_regs
PARAMS ((FILE *, int, int, const char *,
135 static int restore_regs
PARAMS ((FILE *, int, int, const char *, int, int));
136 static void build_big_number
PARAMS ((FILE *, int, const char *));
137 static int function_arg_slotno
PARAMS ((const CUMULATIVE_ARGS
*,
138 enum machine_mode
, tree
, int, int,
141 static int supersparc_adjust_cost
PARAMS ((rtx
, rtx
, rtx
, int));
142 static int hypersparc_adjust_cost
PARAMS ((rtx
, rtx
, rtx
, int));
143 static int ultrasparc_adjust_cost
PARAMS ((rtx
, rtx
, rtx
, int));
145 static void sparc_output_addr_vec
PARAMS ((rtx
));
146 static void sparc_output_addr_diff_vec
PARAMS ((rtx
));
147 static void sparc_output_deferred_case_vectors
PARAMS ((void));
148 static void sparc_add_gc_roots
PARAMS ((void));
149 static void mark_ultrasparc_pipeline_state
PARAMS ((void *));
150 static int check_return_regs
PARAMS ((rtx
));
151 static int epilogue_renumber
PARAMS ((rtx
*, int));
152 static bool sparc_assemble_integer
PARAMS ((rtx
, unsigned int, int));
153 static int ultra_cmove_results_ready_p
PARAMS ((rtx
));
154 static int ultra_fpmode_conflict_exists
PARAMS ((enum machine_mode
));
155 static rtx
*ultra_find_type
PARAMS ((int, rtx
*, int));
156 static void ultra_build_types_avail
PARAMS ((rtx
*, int));
157 static void ultra_flush_pipeline
PARAMS ((void));
158 static void ultra_rescan_pipeline_state
PARAMS ((rtx
*, int));
159 static int set_extends
PARAMS ((rtx
));
160 static void output_restore_regs
PARAMS ((FILE *, int));
161 static void sparc_output_function_prologue
PARAMS ((FILE *, HOST_WIDE_INT
));
162 static void sparc_output_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
));
163 static void sparc_flat_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
));
164 static void sparc_flat_function_prologue
PARAMS ((FILE *, HOST_WIDE_INT
));
165 static void sparc_nonflat_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
,
167 static void sparc_nonflat_function_prologue
PARAMS ((FILE *, HOST_WIDE_INT
,
169 #ifdef OBJECT_FORMAT_ELF
170 static void sparc_elf_asm_named_section
PARAMS ((const char *, unsigned int));
172 static void ultrasparc_sched_reorder
PARAMS ((FILE *, int, rtx
*, int));
173 static int ultrasparc_variable_issue
PARAMS ((rtx
));
174 static void ultrasparc_sched_init
PARAMS ((void));
176 static int sparc_adjust_cost
PARAMS ((rtx
, rtx
, rtx
, int));
177 static int sparc_issue_rate
PARAMS ((void));
178 static int sparc_variable_issue
PARAMS ((FILE *, int, rtx
, int));
179 static void sparc_sched_init
PARAMS ((FILE *, int, int));
180 static int sparc_sched_reorder
PARAMS ((FILE *, int, rtx
*, int *, int));
182 /* Option handling. */
184 /* Code model option as passed by user. */
185 const char *sparc_cmodel_string
;
187 enum cmodel sparc_cmodel
;
189 char sparc_hard_reg_printed
[8];
191 struct sparc_cpu_select sparc_select
[] =
193 /* switch name, tune arch */
194 { (char *)0, "default", 1, 1 },
195 { (char *)0, "-mcpu=", 1, 1 },
196 { (char *)0, "-mtune=", 1, 0 },
200 /* CPU type. This is set from TARGET_CPU_DEFAULT and -m{cpu,tune}=xxx. */
201 enum processor_type sparc_cpu
;
203 /* Initialize the GCC target structure. */
205 /* The sparc default is to use .half rather than .short for aligned
206 HI objects. Use .word instead of .long on non-ELF systems. */
207 #undef TARGET_ASM_ALIGNED_HI_OP
208 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
209 #ifndef OBJECT_FORMAT_ELF
210 #undef TARGET_ASM_ALIGNED_SI_OP
211 #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
214 #undef TARGET_ASM_UNALIGNED_HI_OP
215 #define TARGET_ASM_UNALIGNED_HI_OP "\t.uahalf\t"
216 #undef TARGET_ASM_UNALIGNED_SI_OP
217 #define TARGET_ASM_UNALIGNED_SI_OP "\t.uaword\t"
218 #undef TARGET_ASM_UNALIGNED_DI_OP
219 #define TARGET_ASM_UNALIGNED_DI_OP "\t.uaxword\t"
221 /* The target hook has to handle DI-mode values. */
222 #undef TARGET_ASM_INTEGER
223 #define TARGET_ASM_INTEGER sparc_assemble_integer
225 #undef TARGET_ASM_FUNCTION_PROLOGUE
226 #define TARGET_ASM_FUNCTION_PROLOGUE sparc_output_function_prologue
227 #undef TARGET_ASM_FUNCTION_EPILOGUE
228 #define TARGET_ASM_FUNCTION_EPILOGUE sparc_output_function_epilogue
230 #undef TARGET_SCHED_ADJUST_COST
231 #define TARGET_SCHED_ADJUST_COST sparc_adjust_cost
232 #undef TARGET_SCHED_ISSUE_RATE
233 #define TARGET_SCHED_ISSUE_RATE sparc_issue_rate
234 #undef TARGET_SCHED_VARIABLE_ISSUE
235 #define TARGET_SCHED_VARIABLE_ISSUE sparc_variable_issue
236 #undef TARGET_SCHED_INIT
237 #define TARGET_SCHED_INIT sparc_sched_init
238 #undef TARGET_SCHED_REORDER
239 #define TARGET_SCHED_REORDER sparc_sched_reorder
241 struct gcc_target targetm
= TARGET_INITIALIZER
;
243 /* Validate and override various options, and do some machine dependent
247 sparc_override_options ()
249 static struct code_model
{
250 const char *const name
;
252 } const cmodels
[] = {
254 { "medlow", CM_MEDLOW
},
255 { "medmid", CM_MEDMID
},
256 { "medany", CM_MEDANY
},
257 { "embmedany", CM_EMBMEDANY
},
260 const struct code_model
*cmodel
;
261 /* Map TARGET_CPU_DEFAULT to value for -m{arch,tune}=. */
262 static struct cpu_default
{
264 const char *const name
;
265 } const cpu_default
[] = {
266 /* There must be one entry here for each TARGET_CPU value. */
267 { TARGET_CPU_sparc
, "cypress" },
268 { TARGET_CPU_sparclet
, "tsc701" },
269 { TARGET_CPU_sparclite
, "f930" },
270 { TARGET_CPU_v8
, "v8" },
271 { TARGET_CPU_hypersparc
, "hypersparc" },
272 { TARGET_CPU_sparclite86x
, "sparclite86x" },
273 { TARGET_CPU_supersparc
, "supersparc" },
274 { TARGET_CPU_v9
, "v9" },
275 { TARGET_CPU_ultrasparc
, "ultrasparc" },
278 const struct cpu_default
*def
;
279 /* Table of values for -m{cpu,tune}=. */
280 static struct cpu_table
{
281 const char *const name
;
282 const enum processor_type processor
;
285 } const cpu_table
[] = {
286 { "v7", PROCESSOR_V7
, MASK_ISA
, 0 },
287 { "cypress", PROCESSOR_CYPRESS
, MASK_ISA
, 0 },
288 { "v8", PROCESSOR_V8
, MASK_ISA
, MASK_V8
},
289 /* TI TMS390Z55 supersparc */
290 { "supersparc", PROCESSOR_SUPERSPARC
, MASK_ISA
, MASK_V8
},
291 { "sparclite", PROCESSOR_SPARCLITE
, MASK_ISA
, MASK_SPARCLITE
},
292 /* The Fujitsu MB86930 is the original sparclite chip, with no fpu.
293 The Fujitsu MB86934 is the recent sparclite chip, with an fpu. */
294 { "f930", PROCESSOR_F930
, MASK_ISA
|MASK_FPU
, MASK_SPARCLITE
},
295 { "f934", PROCESSOR_F934
, MASK_ISA
, MASK_SPARCLITE
|MASK_FPU
},
296 { "hypersparc", PROCESSOR_HYPERSPARC
, MASK_ISA
, MASK_V8
|MASK_FPU
},
297 { "sparclite86x", PROCESSOR_SPARCLITE86X
, MASK_ISA
|MASK_FPU
,
299 { "sparclet", PROCESSOR_SPARCLET
, MASK_ISA
, MASK_SPARCLET
},
301 { "tsc701", PROCESSOR_TSC701
, MASK_ISA
, MASK_SPARCLET
},
302 { "v9", PROCESSOR_V9
, MASK_ISA
, MASK_V9
},
303 /* TI ultrasparc I, II, IIi */
304 { "ultrasparc", PROCESSOR_ULTRASPARC
, MASK_ISA
, MASK_V9
305 /* Although insns using %y are deprecated, it is a clear win on current
307 |MASK_DEPRECATED_V8_INSNS
},
310 const struct cpu_table
*cpu
;
311 const struct sparc_cpu_select
*sel
;
314 #ifndef SPARC_BI_ARCH
315 /* Check for unsupported architecture size. */
316 if (! TARGET_64BIT
!= DEFAULT_ARCH32_P
)
317 error ("%s is not supported by this configuration",
318 DEFAULT_ARCH32_P
? "-m64" : "-m32");
321 /* We force all 64bit archs to use 128 bit long double */
322 if (TARGET_64BIT
&& ! TARGET_LONG_DOUBLE_128
)
324 error ("-mlong-double-64 not allowed with -m64");
325 target_flags
|= MASK_LONG_DOUBLE_128
;
328 /* Code model selection. */
329 sparc_cmodel
= SPARC_DEFAULT_CMODEL
;
333 sparc_cmodel
= CM_32
;
336 if (sparc_cmodel_string
!= NULL
)
340 for (cmodel
= &cmodels
[0]; cmodel
->name
; cmodel
++)
341 if (strcmp (sparc_cmodel_string
, cmodel
->name
) == 0)
343 if (cmodel
->name
== NULL
)
344 error ("bad value (%s) for -mcmodel= switch", sparc_cmodel_string
);
346 sparc_cmodel
= cmodel
->value
;
349 error ("-mcmodel= is not supported on 32 bit systems");
352 fpu
= TARGET_FPU
; /* save current -mfpu status */
354 /* Set the default CPU. */
355 for (def
= &cpu_default
[0]; def
->name
; ++def
)
356 if (def
->cpu
== TARGET_CPU_DEFAULT
)
360 sparc_select
[0].string
= def
->name
;
362 for (sel
= &sparc_select
[0]; sel
->name
; ++sel
)
366 for (cpu
= &cpu_table
[0]; cpu
->name
; ++cpu
)
367 if (! strcmp (sel
->string
, cpu
->name
))
370 sparc_cpu
= cpu
->processor
;
374 target_flags
&= ~cpu
->disable
;
375 target_flags
|= cpu
->enable
;
381 error ("bad value (%s) for %s switch", sel
->string
, sel
->name
);
385 /* If -mfpu or -mno-fpu was explicitly used, don't override with
386 the processor default. Clear MASK_FPU_SET to avoid confusing
387 the reverse mapping from switch values to names. */
390 target_flags
= (target_flags
& ~MASK_FPU
) | fpu
;
391 target_flags
&= ~MASK_FPU_SET
;
394 /* Don't allow -mvis if FPU is disabled. */
396 target_flags
&= ~MASK_VIS
;
398 /* -mvis assumes UltraSPARC+, so we are sure v9 instructions
400 -m64 also implies v9. */
401 if (TARGET_VIS
|| TARGET_ARCH64
)
403 target_flags
|= MASK_V9
;
404 target_flags
&= ~(MASK_V8
| MASK_SPARCLET
| MASK_SPARCLITE
);
407 /* Use the deprecated v8 insns for sparc64 in 32 bit mode. */
408 if (TARGET_V9
&& TARGET_ARCH32
)
409 target_flags
|= MASK_DEPRECATED_V8_INSNS
;
411 /* V8PLUS requires V9, makes no sense in 64 bit mode. */
412 if (! TARGET_V9
|| TARGET_ARCH64
)
413 target_flags
&= ~MASK_V8PLUS
;
415 /* Don't use stack biasing in 32 bit mode. */
417 target_flags
&= ~MASK_STACK_BIAS
;
419 /* Supply a default value for align_functions. */
420 if (align_functions
== 0 && sparc_cpu
== PROCESSOR_ULTRASPARC
)
421 align_functions
= 32;
423 /* Validate PCC_STRUCT_RETURN. */
424 if (flag_pcc_struct_return
== DEFAULT_PCC_STRUCT_RETURN
)
425 flag_pcc_struct_return
= (TARGET_ARCH64
? 0 : 1);
427 /* Only use .uaxword when compiling for a 64-bit target. */
429 targetm
.asm_out
.unaligned_op
.di
= NULL
;
431 /* Do various machine dependent initializations. */
434 /* Register global variables with the garbage collector. */
435 sparc_add_gc_roots ();
438 /* Miscellaneous utilities. */
440 /* Nonzero if CODE, a comparison, is suitable for use in v9 conditional move
441 or branch on register contents instructions. */
447 return (code
== EQ
|| code
== NE
|| code
== GE
|| code
== LT
448 || code
== LE
|| code
== GT
);
452 /* Operand constraints. */
454 /* Return non-zero only if OP is a register of mode MODE,
458 reg_or_0_operand (op
, mode
)
460 enum machine_mode mode
;
462 if (register_operand (op
, mode
))
464 if (op
== const0_rtx
)
466 if (GET_MODE (op
) == VOIDmode
&& GET_CODE (op
) == CONST_DOUBLE
467 && CONST_DOUBLE_HIGH (op
) == 0
468 && CONST_DOUBLE_LOW (op
) == 0)
470 if (fp_zero_operand (op
, mode
))
475 /* Nonzero if OP is a floating point value with value 0.0. */
478 fp_zero_operand (op
, mode
)
480 enum machine_mode mode
;
482 if (GET_MODE_CLASS (GET_MODE (op
)) != MODE_FLOAT
)
484 return op
== CONST0_RTX (mode
);
487 /* Nonzero if OP is a floating point constant which can
488 be loaded into an integer register using a single
489 sethi instruction. */
495 if (GET_CODE (op
) == CONST_DOUBLE
)
500 REAL_VALUE_FROM_CONST_DOUBLE (r
, op
);
501 if (REAL_VALUES_EQUAL (r
, dconst0
) &&
502 ! REAL_VALUE_MINUS_ZERO (r
))
504 REAL_VALUE_TO_TARGET_SINGLE (r
, i
);
505 if (SPARC_SETHI_P (i
))
512 /* Nonzero if OP is a floating point constant which can
513 be loaded into an integer register using a single
520 if (GET_CODE (op
) == CONST_DOUBLE
)
525 REAL_VALUE_FROM_CONST_DOUBLE (r
, op
);
526 if (REAL_VALUES_EQUAL (r
, dconst0
) &&
527 ! REAL_VALUE_MINUS_ZERO (r
))
529 REAL_VALUE_TO_TARGET_SINGLE (r
, i
);
530 if (SPARC_SIMM13_P (i
))
537 /* Nonzero if OP is a floating point constant which can
538 be loaded into an integer register using a high/losum
539 instruction sequence. */
545 /* The constraints calling this should only be in
546 SFmode move insns, so any constant which cannot
547 be moved using a single insn will do. */
548 if (GET_CODE (op
) == CONST_DOUBLE
)
553 REAL_VALUE_FROM_CONST_DOUBLE (r
, op
);
554 if (REAL_VALUES_EQUAL (r
, dconst0
) &&
555 ! REAL_VALUE_MINUS_ZERO (r
))
557 REAL_VALUE_TO_TARGET_SINGLE (r
, i
);
558 if (! SPARC_SETHI_P (i
)
559 && ! SPARC_SIMM13_P (i
))
566 /* Nonzero if OP is an integer register. */
569 intreg_operand (op
, mode
)
571 enum machine_mode mode ATTRIBUTE_UNUSED
;
573 return (register_operand (op
, SImode
)
574 || (TARGET_ARCH64
&& register_operand (op
, DImode
)));
577 /* Nonzero if OP is a floating point condition code register. */
580 fcc_reg_operand (op
, mode
)
582 enum machine_mode mode
;
584 /* This can happen when recog is called from combine. Op may be a MEM.
585 Fail instead of calling abort in this case. */
586 if (GET_CODE (op
) != REG
)
589 if (mode
!= VOIDmode
&& mode
!= GET_MODE (op
))
592 && (GET_MODE (op
) != CCFPmode
&& GET_MODE (op
) != CCFPEmode
))
595 #if 0 /* ??? ==> 1 when %fcc0-3 are pseudos first. See gen_compare_reg(). */
596 if (reg_renumber
== 0)
597 return REGNO (op
) >= FIRST_PSEUDO_REGISTER
;
598 return REGNO_OK_FOR_CCFP_P (REGNO (op
));
600 return (unsigned) REGNO (op
) - SPARC_FIRST_V9_FCC_REG
< 4;
604 /* Nonzero if OP is a floating point condition code fcc0 register. */
607 fcc0_reg_operand (op
, mode
)
609 enum machine_mode mode
;
611 /* This can happen when recog is called from combine. Op may be a MEM.
612 Fail instead of calling abort in this case. */
613 if (GET_CODE (op
) != REG
)
616 if (mode
!= VOIDmode
&& mode
!= GET_MODE (op
))
619 && (GET_MODE (op
) != CCFPmode
&& GET_MODE (op
) != CCFPEmode
))
622 return REGNO (op
) == SPARC_FCC_REG
;
625 /* Nonzero if OP is an integer or floating point condition code register. */
628 icc_or_fcc_reg_operand (op
, mode
)
630 enum machine_mode mode
;
632 if (GET_CODE (op
) == REG
&& REGNO (op
) == SPARC_ICC_REG
)
634 if (mode
!= VOIDmode
&& mode
!= GET_MODE (op
))
637 && GET_MODE (op
) != CCmode
&& GET_MODE (op
) != CCXmode
)
642 return fcc_reg_operand (op
, mode
);
645 /* Nonzero if OP can appear as the dest of a RESTORE insn. */
647 restore_operand (op
, mode
)
649 enum machine_mode mode
;
651 return (GET_CODE (op
) == REG
&& GET_MODE (op
) == mode
652 && (REGNO (op
) < 8 || (REGNO (op
) >= 24 && REGNO (op
) < 32)));
655 /* Call insn on SPARC can take a PC-relative constant address, or any regular
659 call_operand (op
, mode
)
661 enum machine_mode mode
;
663 if (GET_CODE (op
) != MEM
)
666 return (symbolic_operand (op
, mode
) || memory_address_p (Pmode
, op
));
670 call_operand_address (op
, mode
)
672 enum machine_mode mode
;
674 return (symbolic_operand (op
, mode
) || memory_address_p (Pmode
, op
));
677 /* Returns 1 if OP is either a symbol reference or a sum of a symbol
678 reference and a constant. */
681 symbolic_operand (op
, mode
)
683 enum machine_mode mode
;
685 enum machine_mode omode
= GET_MODE (op
);
687 if (omode
!= mode
&& omode
!= VOIDmode
&& mode
!= VOIDmode
)
690 switch (GET_CODE (op
))
698 return ((GET_CODE (XEXP (op
, 0)) == SYMBOL_REF
699 || GET_CODE (XEXP (op
, 0)) == LABEL_REF
)
700 && GET_CODE (XEXP (op
, 1)) == CONST_INT
);
707 /* Return truth value of statement that OP is a symbolic memory
708 operand of mode MODE. */
711 symbolic_memory_operand (op
, mode
)
713 enum machine_mode mode ATTRIBUTE_UNUSED
;
715 if (GET_CODE (op
) == SUBREG
)
716 op
= SUBREG_REG (op
);
717 if (GET_CODE (op
) != MEM
)
720 return (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == CONST
721 || GET_CODE (op
) == HIGH
|| GET_CODE (op
) == LABEL_REF
);
724 /* Return truth value of statement that OP is a LABEL_REF of mode MODE. */
727 label_ref_operand (op
, mode
)
729 enum machine_mode mode
;
731 if (GET_CODE (op
) != LABEL_REF
)
733 if (GET_MODE (op
) != mode
)
738 /* Return 1 if the operand is an argument used in generating pic references
739 in either the medium/low or medium/anywhere code models of sparc64. */
742 sp64_medium_pic_operand (op
, mode
)
744 enum machine_mode mode ATTRIBUTE_UNUSED
;
746 /* Check for (const (minus (symbol_ref:GOT)
747 (const (minus (label) (pc))))). */
748 if (GET_CODE (op
) != CONST
)
751 if (GET_CODE (op
) != MINUS
)
753 if (GET_CODE (XEXP (op
, 0)) != SYMBOL_REF
)
755 /* ??? Ensure symbol is GOT. */
756 if (GET_CODE (XEXP (op
, 1)) != CONST
)
758 if (GET_CODE (XEXP (XEXP (op
, 1), 0)) != MINUS
)
763 /* Return 1 if the operand is a data segment reference. This includes
764 the readonly data segment, or in other words anything but the text segment.
765 This is needed in the medium/anywhere code model on v9. These values
766 are accessed with EMBMEDANY_BASE_REG. */
769 data_segment_operand (op
, mode
)
771 enum machine_mode mode ATTRIBUTE_UNUSED
;
773 switch (GET_CODE (op
))
776 return ! SYMBOL_REF_FLAG (op
);
778 /* Assume canonical format of symbol + constant.
781 return data_segment_operand (XEXP (op
, 0), VOIDmode
);
787 /* Return 1 if the operand is a text segment reference.
788 This is needed in the medium/anywhere code model on v9. */
791 text_segment_operand (op
, mode
)
793 enum machine_mode mode ATTRIBUTE_UNUSED
;
795 switch (GET_CODE (op
))
800 return SYMBOL_REF_FLAG (op
);
802 /* Assume canonical format of symbol + constant.
805 return text_segment_operand (XEXP (op
, 0), VOIDmode
);
811 /* Return 1 if the operand is either a register or a memory operand that is
815 reg_or_nonsymb_mem_operand (op
, mode
)
817 enum machine_mode mode
;
819 if (register_operand (op
, mode
))
822 if (memory_operand (op
, mode
) && ! symbolic_memory_operand (op
, mode
))
829 splittable_symbolic_memory_operand (op
, mode
)
831 enum machine_mode mode ATTRIBUTE_UNUSED
;
833 if (GET_CODE (op
) != MEM
)
835 if (! symbolic_operand (XEXP (op
, 0), Pmode
))
841 splittable_immediate_memory_operand (op
, mode
)
843 enum machine_mode mode ATTRIBUTE_UNUSED
;
845 if (GET_CODE (op
) != MEM
)
847 if (! immediate_operand (XEXP (op
, 0), Pmode
))
852 /* Return truth value of whether OP is EQ or NE. */
857 enum machine_mode mode ATTRIBUTE_UNUSED
;
859 return (GET_CODE (op
) == EQ
|| GET_CODE (op
) == NE
);
862 /* Return 1 if this is a comparison operator, but not an EQ, NE, GEU,
863 or LTU for non-floating-point. We handle those specially. */
866 normal_comp_operator (op
, mode
)
868 enum machine_mode mode ATTRIBUTE_UNUSED
;
870 enum rtx_code code
= GET_CODE (op
);
872 if (GET_RTX_CLASS (code
) != '<')
875 if (GET_MODE (XEXP (op
, 0)) == CCFPmode
876 || GET_MODE (XEXP (op
, 0)) == CCFPEmode
)
879 return (code
!= NE
&& code
!= EQ
&& code
!= GEU
&& code
!= LTU
);
882 /* Return 1 if this is a comparison operator. This allows the use of
883 MATCH_OPERATOR to recognize all the branch insns. */
886 noov_compare_op (op
, mode
)
888 enum machine_mode mode ATTRIBUTE_UNUSED
;
890 enum rtx_code code
= GET_CODE (op
);
892 if (GET_RTX_CLASS (code
) != '<')
895 if (GET_MODE (XEXP (op
, 0)) == CC_NOOVmode
896 || GET_MODE (XEXP (op
, 0)) == CCX_NOOVmode
)
897 /* These are the only branches which work with CC_NOOVmode. */
898 return (code
== EQ
|| code
== NE
|| code
== GE
|| code
== LT
);
902 /* Return 1 if this is a 64-bit comparison operator. This allows the use of
903 MATCH_OPERATOR to recognize all the branch insns. */
906 noov_compare64_op (op
, mode
)
908 enum machine_mode mode ATTRIBUTE_UNUSED
;
910 enum rtx_code code
= GET_CODE (op
);
915 if (GET_RTX_CLASS (code
) != '<')
918 if (GET_MODE (XEXP (op
, 0)) == CCX_NOOVmode
)
919 /* These are the only branches which work with CCX_NOOVmode. */
920 return (code
== EQ
|| code
== NE
|| code
== GE
|| code
== LT
);
921 return (GET_MODE (XEXP (op
, 0)) == CCXmode
);
924 /* Nonzero if OP is a comparison operator suitable for use in v9
925 conditional move or branch on register contents instructions. */
928 v9_regcmp_op (op
, mode
)
930 enum machine_mode mode ATTRIBUTE_UNUSED
;
932 enum rtx_code code
= GET_CODE (op
);
934 if (GET_RTX_CLASS (code
) != '<')
937 return v9_regcmp_p (code
);
940 /* Return 1 if this is a SIGN_EXTEND or ZERO_EXTEND operation. */
945 enum machine_mode mode ATTRIBUTE_UNUSED
;
947 return GET_CODE (op
) == SIGN_EXTEND
|| GET_CODE (op
) == ZERO_EXTEND
;
950 /* Return nonzero if OP is an operator of mode MODE which can set
951 the condition codes explicitly. We do not include PLUS and MINUS
952 because these require CC_NOOVmode, which we handle explicitly. */
955 cc_arithop (op
, mode
)
957 enum machine_mode mode ATTRIBUTE_UNUSED
;
959 if (GET_CODE (op
) == AND
960 || GET_CODE (op
) == IOR
961 || GET_CODE (op
) == XOR
)
967 /* Return nonzero if OP is an operator of mode MODE which can bitwise
968 complement its second operand and set the condition codes explicitly. */
971 cc_arithopn (op
, mode
)
973 enum machine_mode mode ATTRIBUTE_UNUSED
;
975 /* XOR is not here because combine canonicalizes (xor (not ...) ...)
976 and (xor ... (not ...)) to (not (xor ...)). */
977 return (GET_CODE (op
) == AND
978 || GET_CODE (op
) == IOR
);
981 /* Return true if OP is a register, or is a CONST_INT that can fit in a
982 signed 13 bit immediate field. This is an acceptable SImode operand for
983 most 3 address instructions. */
986 arith_operand (op
, mode
)
988 enum machine_mode mode
;
990 if (register_operand (op
, mode
))
992 if (GET_CODE (op
) != CONST_INT
)
994 return SMALL_INT32 (op
);
997 /* Return true if OP is a constant 4096 */
1000 arith_4096_operand (op
, mode
)
1002 enum machine_mode mode ATTRIBUTE_UNUSED
;
1004 if (GET_CODE (op
) != CONST_INT
)
1007 return INTVAL (op
) == 4096;
1010 /* Return true if OP is suitable as second operand for add/sub */
1013 arith_add_operand (op
, mode
)
1015 enum machine_mode mode
;
1017 return arith_operand (op
, mode
) || arith_4096_operand (op
, mode
);
1020 /* Return true if OP is a CONST_INT or a CONST_DOUBLE which can fit in the
1021 immediate field of OR and XOR instructions. Used for 64-bit
1022 constant formation patterns. */
1024 const64_operand (op
, mode
)
1026 enum machine_mode mode ATTRIBUTE_UNUSED
;
1028 return ((GET_CODE (op
) == CONST_INT
1029 && SPARC_SIMM13_P (INTVAL (op
)))
1030 #if HOST_BITS_PER_WIDE_INT != 64
1031 || (GET_CODE (op
) == CONST_DOUBLE
1032 && SPARC_SIMM13_P (CONST_DOUBLE_LOW (op
))
1033 && (CONST_DOUBLE_HIGH (op
) ==
1034 ((CONST_DOUBLE_LOW (op
) & 0x80000000) != 0 ?
1035 (HOST_WIDE_INT
)-1 : 0)))
1040 /* The same, but only for sethi instructions. */
1042 const64_high_operand (op
, mode
)
1044 enum machine_mode mode
;
1046 return ((GET_CODE (op
) == CONST_INT
1047 && (INTVAL (op
) & ~(HOST_WIDE_INT
)0x3ff) != 0
1048 && SPARC_SETHI_P (INTVAL (op
) & GET_MODE_MASK (mode
))
1050 || (GET_CODE (op
) == CONST_DOUBLE
1051 && CONST_DOUBLE_HIGH (op
) == 0
1052 && (CONST_DOUBLE_LOW (op
) & ~(HOST_WIDE_INT
)0x3ff) != 0
1053 && SPARC_SETHI_P (CONST_DOUBLE_LOW (op
))));
1056 /* Return true if OP is a register, or is a CONST_INT that can fit in a
1057 signed 11 bit immediate field. This is an acceptable SImode operand for
1058 the movcc instructions. */
1061 arith11_operand (op
, mode
)
1063 enum machine_mode mode
;
1065 return (register_operand (op
, mode
)
1066 || (GET_CODE (op
) == CONST_INT
&& SPARC_SIMM11_P (INTVAL (op
))));
1069 /* Return true if OP is a register, or is a CONST_INT that can fit in a
1070 signed 10 bit immediate field. This is an acceptable SImode operand for
1071 the movrcc instructions. */
1074 arith10_operand (op
, mode
)
1076 enum machine_mode mode
;
1078 return (register_operand (op
, mode
)
1079 || (GET_CODE (op
) == CONST_INT
&& SPARC_SIMM10_P (INTVAL (op
))));
1082 /* Return true if OP is a register, is a CONST_INT that fits in a 13 bit
1083 immediate field, or is a CONST_DOUBLE whose both parts fit in a 13 bit
1085 v9: Return true if OP is a register, or is a CONST_INT or CONST_DOUBLE that
1086 can fit in a 13 bit immediate field. This is an acceptable DImode operand
1087 for most 3 address instructions. */
1090 arith_double_operand (op
, mode
)
1092 enum machine_mode mode
;
1094 return (register_operand (op
, mode
)
1095 || (GET_CODE (op
) == CONST_INT
&& SMALL_INT (op
))
1097 && GET_CODE (op
) == CONST_DOUBLE
1098 && (unsigned HOST_WIDE_INT
) (CONST_DOUBLE_LOW (op
) + 0x1000) < 0x2000
1099 && (unsigned HOST_WIDE_INT
) (CONST_DOUBLE_HIGH (op
) + 0x1000) < 0x2000)
1101 && GET_CODE (op
) == CONST_DOUBLE
1102 && (unsigned HOST_WIDE_INT
) (CONST_DOUBLE_LOW (op
) + 0x1000) < 0x2000
1103 && ((CONST_DOUBLE_HIGH (op
) == -1
1104 && (CONST_DOUBLE_LOW (op
) & 0x1000) == 0x1000)
1105 || (CONST_DOUBLE_HIGH (op
) == 0
1106 && (CONST_DOUBLE_LOW (op
) & 0x1000) == 0))));
1109 /* Return true if OP is a constant 4096 for DImode on ARCH64 */
1112 arith_double_4096_operand (op
, mode
)
1114 enum machine_mode mode ATTRIBUTE_UNUSED
;
1116 return (TARGET_ARCH64
&&
1117 ((GET_CODE (op
) == CONST_INT
&& INTVAL (op
) == 4096) ||
1118 (GET_CODE (op
) == CONST_DOUBLE
&&
1119 CONST_DOUBLE_LOW (op
) == 4096 &&
1120 CONST_DOUBLE_HIGH (op
) == 0)));
1123 /* Return true if OP is suitable as second operand for add/sub in DImode */
1126 arith_double_add_operand (op
, mode
)
1128 enum machine_mode mode
;
1130 return arith_double_operand (op
, mode
) || arith_double_4096_operand (op
, mode
);
1133 /* Return true if OP is a register, or is a CONST_INT or CONST_DOUBLE that
1134 can fit in an 11 bit immediate field. This is an acceptable DImode
1135 operand for the movcc instructions. */
1136 /* ??? Replace with arith11_operand? */
1139 arith11_double_operand (op
, mode
)
1141 enum machine_mode mode
;
1143 return (register_operand (op
, mode
)
1144 || (GET_CODE (op
) == CONST_DOUBLE
1145 && (GET_MODE (op
) == mode
|| GET_MODE (op
) == VOIDmode
)
1146 && (unsigned HOST_WIDE_INT
) (CONST_DOUBLE_LOW (op
) + 0x400) < 0x800
1147 && ((CONST_DOUBLE_HIGH (op
) == -1
1148 && (CONST_DOUBLE_LOW (op
) & 0x400) == 0x400)
1149 || (CONST_DOUBLE_HIGH (op
) == 0
1150 && (CONST_DOUBLE_LOW (op
) & 0x400) == 0)))
1151 || (GET_CODE (op
) == CONST_INT
1152 && (GET_MODE (op
) == mode
|| GET_MODE (op
) == VOIDmode
)
1153 && (unsigned HOST_WIDE_INT
) (INTVAL (op
) + 0x400) < 0x800));
1156 /* Return true if OP is a register, or is a CONST_INT or CONST_DOUBLE that
1157 can fit in an 10 bit immediate field. This is an acceptable DImode
1158 operand for the movrcc instructions. */
1159 /* ??? Replace with arith10_operand? */
1162 arith10_double_operand (op
, mode
)
1164 enum machine_mode mode
;
1166 return (register_operand (op
, mode
)
1167 || (GET_CODE (op
) == CONST_DOUBLE
1168 && (GET_MODE (op
) == mode
|| GET_MODE (op
) == VOIDmode
)
1169 && (unsigned) (CONST_DOUBLE_LOW (op
) + 0x200) < 0x400
1170 && ((CONST_DOUBLE_HIGH (op
) == -1
1171 && (CONST_DOUBLE_LOW (op
) & 0x200) == 0x200)
1172 || (CONST_DOUBLE_HIGH (op
) == 0
1173 && (CONST_DOUBLE_LOW (op
) & 0x200) == 0)))
1174 || (GET_CODE (op
) == CONST_INT
1175 && (GET_MODE (op
) == mode
|| GET_MODE (op
) == VOIDmode
)
1176 && (unsigned HOST_WIDE_INT
) (INTVAL (op
) + 0x200) < 0x400));
1179 /* Return truth value of whether OP is an integer which fits the
1180 range constraining immediate operands in most three-address insns,
1181 which have a 13 bit immediate field. */
1184 small_int (op
, mode
)
1186 enum machine_mode mode ATTRIBUTE_UNUSED
;
1188 return (GET_CODE (op
) == CONST_INT
&& SMALL_INT (op
));
1192 small_int_or_double (op
, mode
)
1194 enum machine_mode mode ATTRIBUTE_UNUSED
;
1196 return ((GET_CODE (op
) == CONST_INT
&& SMALL_INT (op
))
1197 || (GET_CODE (op
) == CONST_DOUBLE
1198 && CONST_DOUBLE_HIGH (op
) == 0
1199 && SPARC_SIMM13_P (CONST_DOUBLE_LOW (op
))));
1202 /* Recognize operand values for the umul instruction. That instruction sign
1203 extends immediate values just like all other sparc instructions, but
1204 interprets the extended result as an unsigned number. */
1207 uns_small_int (op
, mode
)
1209 enum machine_mode mode ATTRIBUTE_UNUSED
;
1211 #if HOST_BITS_PER_WIDE_INT > 32
1212 /* All allowed constants will fit a CONST_INT. */
1213 return (GET_CODE (op
) == CONST_INT
1214 && ((INTVAL (op
) >= 0 && INTVAL (op
) < 0x1000)
1215 || (INTVAL (op
) >= 0xFFFFF000
1216 && INTVAL (op
) <= 0xFFFFFFFF)));
1218 return ((GET_CODE (op
) == CONST_INT
&& (unsigned) INTVAL (op
) < 0x1000)
1219 || (GET_CODE (op
) == CONST_DOUBLE
1220 && CONST_DOUBLE_HIGH (op
) == 0
1221 && (unsigned) CONST_DOUBLE_LOW (op
) - 0xFFFFF000 < 0x1000));
1226 uns_arith_operand (op
, mode
)
1228 enum machine_mode mode
;
1230 return register_operand (op
, mode
) || uns_small_int (op
, mode
);
1233 /* Return truth value of statement that OP is a call-clobbered register. */
1235 clobbered_register (op
, mode
)
1237 enum machine_mode mode ATTRIBUTE_UNUSED
;
1239 return (GET_CODE (op
) == REG
&& call_used_regs
[REGNO (op
)]);
1242 /* Return 1 if OP is a valid operand for the source of a move insn. */
1245 input_operand (op
, mode
)
1247 enum machine_mode mode
;
1249 /* If both modes are non-void they must be the same. */
1250 if (mode
!= VOIDmode
&& GET_MODE (op
) != VOIDmode
&& mode
!= GET_MODE (op
))
1253 /* Only a tiny bit of handling for CONSTANT_P_RTX is necessary. */
1254 if (GET_CODE (op
) == CONST
&& GET_CODE (XEXP (op
, 0)) == CONSTANT_P_RTX
)
1257 /* Allow any one instruction integer constant, and all CONST_INT
1258 variants when we are working in DImode and !arch64. */
1259 if (GET_MODE_CLASS (mode
) == MODE_INT
1260 && ((GET_CODE (op
) == CONST_INT
1261 && (SPARC_SETHI_P (INTVAL (op
) & GET_MODE_MASK (mode
))
1262 || SPARC_SIMM13_P (INTVAL (op
))
1264 && ! TARGET_ARCH64
)))
1266 && GET_CODE (op
) == CONST_DOUBLE
1267 && ((CONST_DOUBLE_HIGH (op
) == 0
1268 && SPARC_SETHI_P (CONST_DOUBLE_LOW (op
)))
1270 #if HOST_BITS_PER_WIDE_INT == 64
1271 (CONST_DOUBLE_HIGH (op
) == 0
1272 && SPARC_SIMM13_P (CONST_DOUBLE_LOW (op
)))
1274 (SPARC_SIMM13_P (CONST_DOUBLE_LOW (op
))
1275 && (((CONST_DOUBLE_LOW (op
) & 0x80000000) == 0
1276 && CONST_DOUBLE_HIGH (op
) == 0)
1277 || (CONST_DOUBLE_HIGH (op
) == -1
1278 && CONST_DOUBLE_LOW (op
) & 0x80000000) != 0))
1283 /* If !arch64 and this is a DImode const, allow it so that
1284 the splits can be generated. */
1287 && GET_CODE (op
) == CONST_DOUBLE
)
1290 if (register_operand (op
, mode
))
1293 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
1294 && GET_CODE (op
) == CONST_DOUBLE
)
1297 /* If this is a SUBREG, look inside so that we handle
1298 paradoxical ones. */
1299 if (GET_CODE (op
) == SUBREG
)
1300 op
= SUBREG_REG (op
);
1302 /* Check for valid MEM forms. */
1303 if (GET_CODE (op
) == MEM
)
1305 rtx inside
= XEXP (op
, 0);
1307 if (GET_CODE (inside
) == LO_SUM
)
1309 /* We can't allow these because all of the splits
1310 (eventually as they trickle down into DFmode
1311 splits) require offsettable memory references. */
1313 && GET_MODE (op
) == TFmode
)
1316 return (register_operand (XEXP (inside
, 0), Pmode
)
1317 && CONSTANT_P (XEXP (inside
, 1)));
1319 return memory_address_p (mode
, inside
);
1326 /* We know it can't be done in one insn when we get here,
1327 the movsi expander guarentees this. */
1329 sparc_emit_set_const32 (op0
, op1
)
1333 enum machine_mode mode
= GET_MODE (op0
);
1336 if (GET_CODE (op1
) == CONST_INT
)
1338 HOST_WIDE_INT value
= INTVAL (op1
);
1340 if (SPARC_SETHI_P (value
& GET_MODE_MASK (mode
))
1341 || SPARC_SIMM13_P (value
))
1345 /* Full 2-insn decomposition is needed. */
1346 if (reload_in_progress
|| reload_completed
)
1349 temp
= gen_reg_rtx (mode
);
1351 if (GET_CODE (op1
) == CONST_INT
)
1353 /* Emit them as real moves instead of a HIGH/LO_SUM,
1354 this way CSE can see everything and reuse intermediate
1355 values if it wants. */
1357 && HOST_BITS_PER_WIDE_INT
!= 64
1358 && (INTVAL (op1
) & 0x80000000) != 0)
1359 emit_insn (gen_rtx_SET
1361 gen_rtx_CONST_DOUBLE (VOIDmode
,
1362 INTVAL (op1
) & ~(HOST_WIDE_INT
)0x3ff,
1365 emit_insn (gen_rtx_SET (VOIDmode
, temp
,
1366 GEN_INT (INTVAL (op1
)
1367 & ~(HOST_WIDE_INT
)0x3ff)));
1369 emit_insn (gen_rtx_SET (VOIDmode
,
1371 gen_rtx_IOR (mode
, temp
,
1372 GEN_INT (INTVAL (op1
) & 0x3ff))));
1376 /* A symbol, emit in the traditional way. */
1377 emit_insn (gen_rtx_SET (VOIDmode
, temp
,
1378 gen_rtx_HIGH (mode
, op1
)));
1379 emit_insn (gen_rtx_SET (VOIDmode
,
1380 op0
, gen_rtx_LO_SUM (mode
, temp
, op1
)));
1386 /* Sparc-v9 code-model support. */
1388 sparc_emit_set_symbolic_const64 (op0
, op1
, temp1
)
1395 if (temp1
&& GET_MODE (temp1
) == TImode
)
1398 temp1
= gen_rtx_REG (DImode
, REGNO (temp1
));
1401 switch (sparc_cmodel
)
1404 /* The range spanned by all instructions in the object is less
1405 than 2^31 bytes (2GB) and the distance from any instruction
1406 to the location of the label _GLOBAL_OFFSET_TABLE_ is less
1407 than 2^31 bytes (2GB).
1409 The executable must be in the low 4TB of the virtual address
1412 sethi %hi(symbol), %temp
1413 or %temp, %lo(symbol), %reg */
1414 emit_insn (gen_rtx_SET (VOIDmode
, temp1
, gen_rtx_HIGH (DImode
, op1
)));
1415 emit_insn (gen_rtx_SET (VOIDmode
, op0
, gen_rtx_LO_SUM (DImode
, temp1
, op1
)));
1419 /* The range spanned by all instructions in the object is less
1420 than 2^31 bytes (2GB) and the distance from any instruction
1421 to the location of the label _GLOBAL_OFFSET_TABLE_ is less
1422 than 2^31 bytes (2GB).
1424 The executable must be in the low 16TB of the virtual address
1427 sethi %h44(symbol), %temp1
1428 or %temp1, %m44(symbol), %temp2
1429 sllx %temp2, 12, %temp3
1430 or %temp3, %l44(symbol), %reg */
1431 emit_insn (gen_seth44 (op0
, op1
));
1432 emit_insn (gen_setm44 (op0
, op0
, op1
));
1433 emit_insn (gen_rtx_SET (VOIDmode
, temp1
,
1434 gen_rtx_ASHIFT (DImode
, op0
, GEN_INT (12))));
1435 emit_insn (gen_setl44 (op0
, temp1
, op1
));
1439 /* The range spanned by all instructions in the object is less
1440 than 2^31 bytes (2GB) and the distance from any instruction
1441 to the location of the label _GLOBAL_OFFSET_TABLE_ is less
1442 than 2^31 bytes (2GB).
1444 The executable can be placed anywhere in the virtual address
1447 sethi %hh(symbol), %temp1
1448 sethi %lm(symbol), %temp2
1449 or %temp1, %hm(symbol), %temp3
1450 or %temp2, %lo(symbol), %temp4
1451 sllx %temp3, 32, %temp5
1452 or %temp4, %temp5, %reg */
1454 /* It is possible that one of the registers we got for operands[2]
1455 might coincide with that of operands[0] (which is why we made
1456 it TImode). Pick the other one to use as our scratch. */
1457 if (rtx_equal_p (temp1
, op0
))
1460 temp1
= gen_rtx_REG (DImode
, REGNO (temp1
) + 1);
1465 emit_insn (gen_sethh (op0
, op1
));
1466 emit_insn (gen_setlm (temp1
, op1
));
1467 emit_insn (gen_sethm (op0
, op0
, op1
));
1468 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1469 gen_rtx_ASHIFT (DImode
, op0
, GEN_INT (32))));
1470 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1471 gen_rtx_PLUS (DImode
, op0
, temp1
)));
1472 emit_insn (gen_setlo (op0
, op0
, op1
));
1476 /* Old old old backwards compatibility kruft here.
1477 Essentially it is MEDLOW with a fixed 64-bit
1478 virtual base added to all data segment addresses.
1479 Text-segment stuff is computed like MEDANY, we can't
1480 reuse the code above because the relocation knobs
1483 Data segment: sethi %hi(symbol), %temp1
1484 or %temp1, %lo(symbol), %temp2
1485 add %temp2, EMBMEDANY_BASE_REG, %reg
1487 Text segment: sethi %uhi(symbol), %temp1
1488 sethi %hi(symbol), %temp2
1489 or %temp1, %ulo(symbol), %temp3
1490 or %temp2, %lo(symbol), %temp4
1491 sllx %temp3, 32, %temp5
1492 or %temp4, %temp5, %reg */
1493 if (data_segment_operand (op1
, GET_MODE (op1
)))
1495 emit_insn (gen_embmedany_sethi (temp1
, op1
));
1496 emit_insn (gen_embmedany_brsum (op0
, temp1
));
1497 emit_insn (gen_embmedany_losum (op0
, op0
, op1
));
1501 /* It is possible that one of the registers we got for operands[2]
1502 might coincide with that of operands[0] (which is why we made
1503 it TImode). Pick the other one to use as our scratch. */
1504 if (rtx_equal_p (temp1
, op0
))
1507 temp1
= gen_rtx_REG (DImode
, REGNO (temp1
) + 1);
1512 emit_insn (gen_embmedany_textuhi (op0
, op1
));
1513 emit_insn (gen_embmedany_texthi (temp1
, op1
));
1514 emit_insn (gen_embmedany_textulo (op0
, op0
, op1
));
1515 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1516 gen_rtx_ASHIFT (DImode
, op0
, GEN_INT (32))));
1517 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1518 gen_rtx_PLUS (DImode
, op0
, temp1
)));
1519 emit_insn (gen_embmedany_textlo (op0
, op0
, op1
));
1528 /* These avoid problems when cross compiling. If we do not
1529 go through all this hair then the optimizer will see
1530 invalid REG_EQUAL notes or in some cases none at all. */
1531 static void sparc_emit_set_safe_HIGH64
PARAMS ((rtx
, HOST_WIDE_INT
));
1532 static rtx gen_safe_SET64
PARAMS ((rtx
, HOST_WIDE_INT
));
1533 static rtx gen_safe_OR64
PARAMS ((rtx
, HOST_WIDE_INT
));
1534 static rtx gen_safe_XOR64
PARAMS ((rtx
, HOST_WIDE_INT
));
1536 #if HOST_BITS_PER_WIDE_INT == 64
1537 #define GEN_HIGHINT64(__x) GEN_INT ((__x) & ~(HOST_WIDE_INT)0x3ff)
1538 #define GEN_INT64(__x) GEN_INT (__x)
1540 #define GEN_HIGHINT64(__x) \
1541 gen_rtx_CONST_DOUBLE (VOIDmode, (__x) & ~(HOST_WIDE_INT)0x3ff, 0)
1542 #define GEN_INT64(__x) \
1543 gen_rtx_CONST_DOUBLE (VOIDmode, (__x) & 0xffffffff, \
1544 ((__x) & 0x80000000 \
1548 /* The optimizer is not to assume anything about exactly
1549 which bits are set for a HIGH, they are unspecified.
1550 Unfortunately this leads to many missed optimizations
1551 during CSE. We mask out the non-HIGH bits, and matches
1552 a plain movdi, to alleviate this problem. */
1554 sparc_emit_set_safe_HIGH64 (dest
, val
)
1558 emit_insn (gen_rtx_SET (VOIDmode
, dest
, GEN_HIGHINT64 (val
)));
1562 gen_safe_SET64 (dest
, val
)
1566 return gen_rtx_SET (VOIDmode
, dest
, GEN_INT64 (val
));
1570 gen_safe_OR64 (src
, val
)
1574 return gen_rtx_IOR (DImode
, src
, GEN_INT64 (val
));
1578 gen_safe_XOR64 (src
, val
)
1582 return gen_rtx_XOR (DImode
, src
, GEN_INT64 (val
));
1585 /* Worker routines for 64-bit constant formation on arch64.
1586 One of the key things to be doing in these emissions is
1587 to create as many temp REGs as possible. This makes it
1588 possible for half-built constants to be used later when
1589 such values are similar to something required later on.
1590 Without doing this, the optimizer cannot see such
1593 static void sparc_emit_set_const64_quick1
1594 PARAMS ((rtx
, rtx
, unsigned HOST_WIDE_INT
, int));
1597 sparc_emit_set_const64_quick1 (op0
, temp
, low_bits
, is_neg
)
1600 unsigned HOST_WIDE_INT low_bits
;
1603 unsigned HOST_WIDE_INT high_bits
;
1606 high_bits
= (~low_bits
) & 0xffffffff;
1608 high_bits
= low_bits
;
1610 sparc_emit_set_safe_HIGH64 (temp
, high_bits
);
1613 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1614 gen_safe_OR64 (temp
, (high_bits
& 0x3ff))));
1618 /* If we are XOR'ing with -1, then we should emit a one's complement
1619 instead. This way the combiner will notice logical operations
1620 such as ANDN later on and substitute. */
1621 if ((low_bits
& 0x3ff) == 0x3ff)
1623 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1624 gen_rtx_NOT (DImode
, temp
)));
1628 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1629 gen_safe_XOR64 (temp
,
1630 (-(HOST_WIDE_INT
)0x400
1631 | (low_bits
& 0x3ff)))));
1636 static void sparc_emit_set_const64_quick2
1637 PARAMS ((rtx
, rtx
, unsigned HOST_WIDE_INT
,
1638 unsigned HOST_WIDE_INT
, int));
1641 sparc_emit_set_const64_quick2 (op0
, temp
, high_bits
, low_immediate
, shift_count
)
1644 unsigned HOST_WIDE_INT high_bits
;
1645 unsigned HOST_WIDE_INT low_immediate
;
1650 if ((high_bits
& 0xfffffc00) != 0)
1652 sparc_emit_set_safe_HIGH64 (temp
, high_bits
);
1653 if ((high_bits
& ~0xfffffc00) != 0)
1654 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1655 gen_safe_OR64 (temp
, (high_bits
& 0x3ff))));
1661 emit_insn (gen_safe_SET64 (temp
, high_bits
));
1665 /* Now shift it up into place. */
1666 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1667 gen_rtx_ASHIFT (DImode
, temp2
,
1668 GEN_INT (shift_count
))));
1670 /* If there is a low immediate part piece, finish up by
1671 putting that in as well. */
1672 if (low_immediate
!= 0)
1673 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1674 gen_safe_OR64 (op0
, low_immediate
)));
1677 static void sparc_emit_set_const64_longway
1678 PARAMS ((rtx
, rtx
, unsigned HOST_WIDE_INT
, unsigned HOST_WIDE_INT
));
1680 /* Full 64-bit constant decomposition. Even though this is the
1681 'worst' case, we still optimize a few things away. */
1683 sparc_emit_set_const64_longway (op0
, temp
, high_bits
, low_bits
)
1686 unsigned HOST_WIDE_INT high_bits
;
1687 unsigned HOST_WIDE_INT low_bits
;
1691 if (reload_in_progress
|| reload_completed
)
1694 sub_temp
= gen_reg_rtx (DImode
);
1696 if ((high_bits
& 0xfffffc00) != 0)
1698 sparc_emit_set_safe_HIGH64 (temp
, high_bits
);
1699 if ((high_bits
& ~0xfffffc00) != 0)
1700 emit_insn (gen_rtx_SET (VOIDmode
,
1702 gen_safe_OR64 (temp
, (high_bits
& 0x3ff))));
1708 emit_insn (gen_safe_SET64 (temp
, high_bits
));
1712 if (!reload_in_progress
&& !reload_completed
)
1714 rtx temp2
= gen_reg_rtx (DImode
);
1715 rtx temp3
= gen_reg_rtx (DImode
);
1716 rtx temp4
= gen_reg_rtx (DImode
);
1718 emit_insn (gen_rtx_SET (VOIDmode
, temp4
,
1719 gen_rtx_ASHIFT (DImode
, sub_temp
,
1722 sparc_emit_set_safe_HIGH64 (temp2
, low_bits
);
1723 if ((low_bits
& ~0xfffffc00) != 0)
1725 emit_insn (gen_rtx_SET (VOIDmode
, temp3
,
1726 gen_safe_OR64 (temp2
, (low_bits
& 0x3ff))));
1727 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1728 gen_rtx_PLUS (DImode
, temp4
, temp3
)));
1732 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1733 gen_rtx_PLUS (DImode
, temp4
, temp2
)));
1738 rtx low1
= GEN_INT ((low_bits
>> (32 - 12)) & 0xfff);
1739 rtx low2
= GEN_INT ((low_bits
>> (32 - 12 - 12)) & 0xfff);
1740 rtx low3
= GEN_INT ((low_bits
>> (32 - 12 - 12 - 8)) & 0x0ff);
1743 /* We are in the middle of reload, so this is really
1744 painful. However we do still make an attempt to
1745 avoid emitting truly stupid code. */
1746 if (low1
!= const0_rtx
)
1748 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1749 gen_rtx_ASHIFT (DImode
, sub_temp
,
1750 GEN_INT (to_shift
))));
1751 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1752 gen_rtx_IOR (DImode
, op0
, low1
)));
1760 if (low2
!= const0_rtx
)
1762 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1763 gen_rtx_ASHIFT (DImode
, sub_temp
,
1764 GEN_INT (to_shift
))));
1765 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1766 gen_rtx_IOR (DImode
, op0
, low2
)));
1774 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1775 gen_rtx_ASHIFT (DImode
, sub_temp
,
1776 GEN_INT (to_shift
))));
1777 if (low3
!= const0_rtx
)
1778 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
1779 gen_rtx_IOR (DImode
, op0
, low3
)));
1784 /* Analyze a 64-bit constant for certain properties. */
1785 static void analyze_64bit_constant
1786 PARAMS ((unsigned HOST_WIDE_INT
,
1787 unsigned HOST_WIDE_INT
,
1788 int *, int *, int *));
1791 analyze_64bit_constant (high_bits
, low_bits
, hbsp
, lbsp
, abbasp
)
1792 unsigned HOST_WIDE_INT high_bits
, low_bits
;
1793 int *hbsp
, *lbsp
, *abbasp
;
1795 int lowest_bit_set
, highest_bit_set
, all_bits_between_are_set
;
1798 lowest_bit_set
= highest_bit_set
= -1;
1802 if ((lowest_bit_set
== -1)
1803 && ((low_bits
>> i
) & 1))
1805 if ((highest_bit_set
== -1)
1806 && ((high_bits
>> (32 - i
- 1)) & 1))
1807 highest_bit_set
= (64 - i
- 1);
1810 && ((highest_bit_set
== -1)
1811 || (lowest_bit_set
== -1)));
1817 if ((lowest_bit_set
== -1)
1818 && ((high_bits
>> i
) & 1))
1819 lowest_bit_set
= i
+ 32;
1820 if ((highest_bit_set
== -1)
1821 && ((low_bits
>> (32 - i
- 1)) & 1))
1822 highest_bit_set
= 32 - i
- 1;
1825 && ((highest_bit_set
== -1)
1826 || (lowest_bit_set
== -1)));
1828 /* If there are no bits set this should have gone out
1829 as one instruction! */
1830 if (lowest_bit_set
== -1
1831 || highest_bit_set
== -1)
1833 all_bits_between_are_set
= 1;
1834 for (i
= lowest_bit_set
; i
<= highest_bit_set
; i
++)
1838 if ((low_bits
& (1 << i
)) != 0)
1843 if ((high_bits
& (1 << (i
- 32))) != 0)
1846 all_bits_between_are_set
= 0;
1849 *hbsp
= highest_bit_set
;
1850 *lbsp
= lowest_bit_set
;
1851 *abbasp
= all_bits_between_are_set
;
1854 static int const64_is_2insns
1855 PARAMS ((unsigned HOST_WIDE_INT
, unsigned HOST_WIDE_INT
));
1858 const64_is_2insns (high_bits
, low_bits
)
1859 unsigned HOST_WIDE_INT high_bits
, low_bits
;
1861 int highest_bit_set
, lowest_bit_set
, all_bits_between_are_set
;
1864 || high_bits
== 0xffffffff)
1867 analyze_64bit_constant (high_bits
, low_bits
,
1868 &highest_bit_set
, &lowest_bit_set
,
1869 &all_bits_between_are_set
);
1871 if ((highest_bit_set
== 63
1872 || lowest_bit_set
== 0)
1873 && all_bits_between_are_set
!= 0)
1876 if ((highest_bit_set
- lowest_bit_set
) < 21)
1882 static unsigned HOST_WIDE_INT create_simple_focus_bits
1883 PARAMS ((unsigned HOST_WIDE_INT
, unsigned HOST_WIDE_INT
,
1886 static unsigned HOST_WIDE_INT
1887 create_simple_focus_bits (high_bits
, low_bits
, lowest_bit_set
, shift
)
1888 unsigned HOST_WIDE_INT high_bits
, low_bits
;
1889 int lowest_bit_set
, shift
;
1891 HOST_WIDE_INT hi
, lo
;
1893 if (lowest_bit_set
< 32)
1895 lo
= (low_bits
>> lowest_bit_set
) << shift
;
1896 hi
= ((high_bits
<< (32 - lowest_bit_set
)) << shift
);
1901 hi
= ((high_bits
>> (lowest_bit_set
- 32)) << shift
);
1908 /* Here we are sure to be arch64 and this is an integer constant
1909 being loaded into a register. Emit the most efficient
1910 insn sequence possible. Detection of all the 1-insn cases
1911 has been done already. */
1913 sparc_emit_set_const64 (op0
, op1
)
1917 unsigned HOST_WIDE_INT high_bits
, low_bits
;
1918 int lowest_bit_set
, highest_bit_set
;
1919 int all_bits_between_are_set
;
1922 /* Sanity check that we know what we are working with. */
1923 if (! TARGET_ARCH64
)
1926 if (GET_CODE (op0
) != SUBREG
)
1928 if (GET_CODE (op0
) != REG
1929 || (REGNO (op0
) >= SPARC_FIRST_FP_REG
1930 && REGNO (op0
) <= SPARC_LAST_V9_FP_REG
))
1934 if (reload_in_progress
|| reload_completed
)
1937 temp
= gen_reg_rtx (DImode
);
1939 if (GET_CODE (op1
) != CONST_DOUBLE
1940 && GET_CODE (op1
) != CONST_INT
)
1942 sparc_emit_set_symbolic_const64 (op0
, op1
, temp
);
1946 if (GET_CODE (op1
) == CONST_DOUBLE
)
1948 #if HOST_BITS_PER_WIDE_INT == 64
1949 high_bits
= (CONST_DOUBLE_LOW (op1
) >> 32) & 0xffffffff;
1950 low_bits
= CONST_DOUBLE_LOW (op1
) & 0xffffffff;
1952 high_bits
= CONST_DOUBLE_HIGH (op1
);
1953 low_bits
= CONST_DOUBLE_LOW (op1
);
1958 #if HOST_BITS_PER_WIDE_INT == 64
1959 high_bits
= ((INTVAL (op1
) >> 32) & 0xffffffff);
1960 low_bits
= (INTVAL (op1
) & 0xffffffff);
1962 high_bits
= ((INTVAL (op1
) < 0) ?
1965 low_bits
= INTVAL (op1
);
1969 /* low_bits bits 0 --> 31
1970 high_bits bits 32 --> 63 */
1972 analyze_64bit_constant (high_bits
, low_bits
,
1973 &highest_bit_set
, &lowest_bit_set
,
1974 &all_bits_between_are_set
);
1976 /* First try for a 2-insn sequence. */
1978 /* These situations are preferred because the optimizer can
1979 * do more things with them:
1981 * sllx %reg, shift, %reg
1983 * srlx %reg, shift, %reg
1984 * 3) mov some_small_const, %reg
1985 * sllx %reg, shift, %reg
1987 if (((highest_bit_set
== 63
1988 || lowest_bit_set
== 0)
1989 && all_bits_between_are_set
!= 0)
1990 || ((highest_bit_set
- lowest_bit_set
) < 12))
1992 HOST_WIDE_INT the_const
= -1;
1993 int shift
= lowest_bit_set
;
1995 if ((highest_bit_set
!= 63
1996 && lowest_bit_set
!= 0)
1997 || all_bits_between_are_set
== 0)
2000 create_simple_focus_bits (high_bits
, low_bits
,
2003 else if (lowest_bit_set
== 0)
2004 shift
= -(63 - highest_bit_set
);
2006 if (! SPARC_SIMM13_P (the_const
))
2009 emit_insn (gen_safe_SET64 (temp
, the_const
));
2011 emit_insn (gen_rtx_SET (VOIDmode
,
2013 gen_rtx_ASHIFT (DImode
,
2017 emit_insn (gen_rtx_SET (VOIDmode
,
2019 gen_rtx_LSHIFTRT (DImode
,
2021 GEN_INT (-shift
))));
2027 /* Now a range of 22 or less bits set somewhere.
2028 * 1) sethi %hi(focus_bits), %reg
2029 * sllx %reg, shift, %reg
2030 * 2) sethi %hi(focus_bits), %reg
2031 * srlx %reg, shift, %reg
2033 if ((highest_bit_set
- lowest_bit_set
) < 21)
2035 unsigned HOST_WIDE_INT focus_bits
=
2036 create_simple_focus_bits (high_bits
, low_bits
,
2037 lowest_bit_set
, 10);
2039 if (! SPARC_SETHI_P (focus_bits
))
2042 sparc_emit_set_safe_HIGH64 (temp
, focus_bits
);
2044 /* If lowest_bit_set == 10 then a sethi alone could have done it. */
2045 if (lowest_bit_set
< 10)
2046 emit_insn (gen_rtx_SET (VOIDmode
,
2048 gen_rtx_LSHIFTRT (DImode
, temp
,
2049 GEN_INT (10 - lowest_bit_set
))));
2050 else if (lowest_bit_set
> 10)
2051 emit_insn (gen_rtx_SET (VOIDmode
,
2053 gen_rtx_ASHIFT (DImode
, temp
,
2054 GEN_INT (lowest_bit_set
- 10))));
2060 /* 1) sethi %hi(low_bits), %reg
2061 * or %reg, %lo(low_bits), %reg
2062 * 2) sethi %hi(~low_bits), %reg
2063 * xor %reg, %lo(-0x400 | (low_bits & 0x3ff)), %reg
2066 || high_bits
== 0xffffffff)
2068 sparc_emit_set_const64_quick1 (op0
, temp
, low_bits
,
2069 (high_bits
== 0xffffffff));
2073 /* Now, try 3-insn sequences. */
2075 /* 1) sethi %hi(high_bits), %reg
2076 * or %reg, %lo(high_bits), %reg
2077 * sllx %reg, 32, %reg
2081 sparc_emit_set_const64_quick2 (op0
, temp
, high_bits
, 0, 32);
2085 /* We may be able to do something quick
2086 when the constant is negated, so try that. */
2087 if (const64_is_2insns ((~high_bits
) & 0xffffffff,
2088 (~low_bits
) & 0xfffffc00))
2090 /* NOTE: The trailing bits get XOR'd so we need the
2091 non-negated bits, not the negated ones. */
2092 unsigned HOST_WIDE_INT trailing_bits
= low_bits
& 0x3ff;
2094 if ((((~high_bits
) & 0xffffffff) == 0
2095 && ((~low_bits
) & 0x80000000) == 0)
2096 || (((~high_bits
) & 0xffffffff) == 0xffffffff
2097 && ((~low_bits
) & 0x80000000) != 0))
2099 int fast_int
= (~low_bits
& 0xffffffff);
2101 if ((SPARC_SETHI_P (fast_int
)
2102 && (~high_bits
& 0xffffffff) == 0)
2103 || SPARC_SIMM13_P (fast_int
))
2104 emit_insn (gen_safe_SET64 (temp
, fast_int
));
2106 sparc_emit_set_const64 (temp
, GEN_INT64 (fast_int
));
2111 #if HOST_BITS_PER_WIDE_INT == 64
2112 negated_const
= GEN_INT (((~low_bits
) & 0xfffffc00) |
2113 (((HOST_WIDE_INT
)((~high_bits
) & 0xffffffff))<<32));
2115 negated_const
= gen_rtx_CONST_DOUBLE (DImode
,
2116 (~low_bits
) & 0xfffffc00,
2117 (~high_bits
) & 0xffffffff);
2119 sparc_emit_set_const64 (temp
, negated_const
);
2122 /* If we are XOR'ing with -1, then we should emit a one's complement
2123 instead. This way the combiner will notice logical operations
2124 such as ANDN later on and substitute. */
2125 if (trailing_bits
== 0x3ff)
2127 emit_insn (gen_rtx_SET (VOIDmode
, op0
,
2128 gen_rtx_NOT (DImode
, temp
)));
2132 emit_insn (gen_rtx_SET (VOIDmode
,
2134 gen_safe_XOR64 (temp
,
2135 (-0x400 | trailing_bits
))));
2140 /* 1) sethi %hi(xxx), %reg
2141 * or %reg, %lo(xxx), %reg
2142 * sllx %reg, yyy, %reg
2144 * ??? This is just a generalized version of the low_bits==0
2145 * thing above, FIXME...
2147 if ((highest_bit_set
- lowest_bit_set
) < 32)
2149 unsigned HOST_WIDE_INT focus_bits
=
2150 create_simple_focus_bits (high_bits
, low_bits
,
2153 /* We can't get here in this state. */
2154 if (highest_bit_set
< 32
2155 || lowest_bit_set
>= 32)
2158 /* So what we know is that the set bits straddle the
2159 middle of the 64-bit word. */
2160 sparc_emit_set_const64_quick2 (op0
, temp
,
2166 /* 1) sethi %hi(high_bits), %reg
2167 * or %reg, %lo(high_bits), %reg
2168 * sllx %reg, 32, %reg
2169 * or %reg, low_bits, %reg
2171 if (SPARC_SIMM13_P(low_bits
)
2172 && ((int)low_bits
> 0))
2174 sparc_emit_set_const64_quick2 (op0
, temp
, high_bits
, low_bits
, 32);
2178 /* The easiest way when all else fails, is full decomposition. */
2180 printf ("sparc_emit_set_const64: Hard constant [%08lx%08lx] neg[%08lx%08lx]\n",
2181 high_bits
, low_bits
, ~high_bits
, ~low_bits
);
2183 sparc_emit_set_const64_longway (op0
, temp
, high_bits
, low_bits
);
2186 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
2187 return the mode to be used for the comparison. For floating-point,
2188 CCFP[E]mode is used. CC_NOOVmode should be used when the first operand
2189 is a PLUS, MINUS, NEG, or ASHIFT. CCmode should be used when no special
2190 processing is needed. */
2193 select_cc_mode (op
, x
, y
)
2196 rtx y ATTRIBUTE_UNUSED
;
2198 if (GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
)
2224 else if (GET_CODE (x
) == PLUS
|| GET_CODE (x
) == MINUS
2225 || GET_CODE (x
) == NEG
|| GET_CODE (x
) == ASHIFT
)
2227 if (TARGET_ARCH64
&& GET_MODE (x
) == DImode
)
2228 return CCX_NOOVmode
;
2234 if (TARGET_ARCH64
&& GET_MODE (x
) == DImode
)
2241 /* X and Y are two things to compare using CODE. Emit the compare insn and
2242 return the rtx for the cc reg in the proper mode. */
2245 gen_compare_reg (code
, x
, y
)
2249 enum machine_mode mode
= SELECT_CC_MODE (code
, x
, y
);
2252 /* ??? We don't have movcc patterns so we cannot generate pseudo regs for the
2253 fcc regs (cse can't tell they're really call clobbered regs and will
2254 remove a duplicate comparison even if there is an intervening function
2255 call - it will then try to reload the cc reg via an int reg which is why
2256 we need the movcc patterns). It is possible to provide the movcc
2257 patterns by using the ldxfsr/stxfsr v9 insns. I tried it: you need two
2258 registers (say %g1,%g5) and it takes about 6 insns. A better fix would be
2259 to tell cse that CCFPE mode registers (even pseudos) are call
2262 /* ??? This is an experiment. Rather than making changes to cse which may
2263 or may not be easy/clean, we do our own cse. This is possible because
2264 we will generate hard registers. Cse knows they're call clobbered (it
2265 doesn't know the same thing about pseudos). If we guess wrong, no big
2266 deal, but if we win, great! */
2268 if (TARGET_V9
&& GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
)
2269 #if 1 /* experiment */
2272 /* We cycle through the registers to ensure they're all exercised. */
2273 static int next_fcc_reg
= 0;
2274 /* Previous x,y for each fcc reg. */
2275 static rtx prev_args
[4][2];
2277 /* Scan prev_args for x,y. */
2278 for (reg
= 0; reg
< 4; reg
++)
2279 if (prev_args
[reg
][0] == x
&& prev_args
[reg
][1] == y
)
2284 prev_args
[reg
][0] = x
;
2285 prev_args
[reg
][1] = y
;
2286 next_fcc_reg
= (next_fcc_reg
+ 1) & 3;
2288 cc_reg
= gen_rtx_REG (mode
, reg
+ SPARC_FIRST_V9_FCC_REG
);
2291 cc_reg
= gen_reg_rtx (mode
);
2292 #endif /* ! experiment */
2293 else if (GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
)
2294 cc_reg
= gen_rtx_REG (mode
, SPARC_FCC_REG
);
2296 cc_reg
= gen_rtx_REG (mode
, SPARC_ICC_REG
);
2298 emit_insn (gen_rtx_SET (VOIDmode
, cc_reg
,
2299 gen_rtx_COMPARE (mode
, x
, y
)));
2304 /* This function is used for v9 only.
2305 CODE is the code for an Scc's comparison.
2306 OPERANDS[0] is the target of the Scc insn.
2307 OPERANDS[1] is the value we compare against const0_rtx (which hasn't
2308 been generated yet).
2310 This function is needed to turn
2313 (gt (reg:CCX 100 %icc)
2317 (gt:DI (reg:CCX 100 %icc)
2320 IE: The instruction recognizer needs to see the mode of the comparison to
2321 find the right instruction. We could use "gt:DI" right in the
2322 define_expand, but leaving it out allows us to handle DI, SI, etc.
2324 We refer to the global sparc compare operands sparc_compare_op0 and
2325 sparc_compare_op1. */
2328 gen_v9_scc (compare_code
, operands
)
2329 enum rtx_code compare_code
;
2330 register rtx
*operands
;
2335 && (GET_MODE (sparc_compare_op0
) == DImode
2336 || GET_MODE (operands
[0]) == DImode
))
2339 op0
= sparc_compare_op0
;
2340 op1
= sparc_compare_op1
;
2342 /* Try to use the movrCC insns. */
2344 && GET_MODE_CLASS (GET_MODE (op0
)) == MODE_INT
2345 && op1
== const0_rtx
2346 && v9_regcmp_p (compare_code
))
2348 /* Special case for op0 != 0. This can be done with one instruction if
2349 operands[0] == sparc_compare_op0. */
2351 if (compare_code
== NE
2352 && GET_MODE (operands
[0]) == DImode
2353 && rtx_equal_p (op0
, operands
[0]))
2355 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
2356 gen_rtx_IF_THEN_ELSE (DImode
,
2357 gen_rtx_fmt_ee (compare_code
, DImode
,
2364 if (reg_overlap_mentioned_p (operands
[0], op0
))
2366 /* Handle the case where operands[0] == sparc_compare_op0.
2367 We "early clobber" the result. */
2368 op0
= gen_reg_rtx (GET_MODE (sparc_compare_op0
));
2369 emit_move_insn (op0
, sparc_compare_op0
);
2372 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0], const0_rtx
));
2373 if (GET_MODE (op0
) != DImode
)
2375 temp
= gen_reg_rtx (DImode
);
2376 convert_move (temp
, op0
, 0);
2380 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
2381 gen_rtx_IF_THEN_ELSE (GET_MODE (operands
[0]),
2382 gen_rtx_fmt_ee (compare_code
, DImode
,
2390 operands
[1] = gen_compare_reg (compare_code
, op0
, op1
);
2392 switch (GET_MODE (operands
[1]))
2402 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0], const0_rtx
));
2403 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
2404 gen_rtx_IF_THEN_ELSE (GET_MODE (operands
[0]),
2405 gen_rtx_fmt_ee (compare_code
,
2406 GET_MODE (operands
[1]),
2407 operands
[1], const0_rtx
),
2408 const1_rtx
, operands
[0])));
2413 /* Emit a conditional jump insn for the v9 architecture using comparison code
2414 CODE and jump target LABEL.
2415 This function exists to take advantage of the v9 brxx insns. */
2418 emit_v9_brxx_insn (code
, op0
, label
)
2422 emit_jump_insn (gen_rtx_SET (VOIDmode
,
2424 gen_rtx_IF_THEN_ELSE (VOIDmode
,
2425 gen_rtx_fmt_ee (code
, GET_MODE (op0
),
2427 gen_rtx_LABEL_REF (VOIDmode
, label
),
2431 /* Generate a DFmode part of a hard TFmode register.
2432 REG is the TFmode hard register, LOW is 1 for the
2433 low 64bit of the register and 0 otherwise.
2436 gen_df_reg (reg
, low
)
2440 int regno
= REGNO (reg
);
2442 if ((WORDS_BIG_ENDIAN
== 0) ^ (low
!= 0))
2443 regno
+= (TARGET_ARCH64
&& regno
< 32) ? 1 : 2;
2444 return gen_rtx_REG (DFmode
, regno
);
2447 /* Return nonzero if a return peephole merging return with
2448 setting of output register is ok. */
2450 leaf_return_peephole_ok ()
2452 return (actual_fsize
== 0);
2455 /* Return nonzero if a branch/jump/call instruction will be emitting
2456 nop into its delay slot. */
2459 empty_delay_slot (insn
)
2464 /* If no previous instruction (should not happen), return true. */
2465 if (PREV_INSN (insn
) == NULL
)
2468 seq
= NEXT_INSN (PREV_INSN (insn
));
2469 if (GET_CODE (PATTERN (seq
)) == SEQUENCE
)
2475 /* Return nonzero if TRIAL can go into the function epilogue's
2476 delay slot. SLOT is the slot we are trying to fill. */
2479 eligible_for_epilogue_delay (trial
, slot
)
2488 if (GET_CODE (trial
) != INSN
|| GET_CODE (PATTERN (trial
)) != SET
)
2491 if (get_attr_length (trial
) != 1)
2494 /* If there are any call-saved registers, we should scan TRIAL if it
2495 does not reference them. For now just make it easy. */
2499 /* If the function uses __builtin_eh_return, the eh_return machinery
2500 occupies the delay slot. */
2501 if (current_function_calls_eh_return
)
2504 /* In the case of a true leaf function, anything can go into the delay slot.
2505 A delay slot only exists however if the frame size is zero, otherwise
2506 we will put an insn to adjust the stack after the return. */
2507 if (current_function_uses_only_leaf_regs
)
2509 if (leaf_return_peephole_ok ())
2510 return ((get_attr_in_uncond_branch_delay (trial
)
2511 == IN_BRANCH_DELAY_TRUE
));
2515 pat
= PATTERN (trial
);
2517 /* Otherwise, only operations which can be done in tandem with
2518 a `restore' or `return' insn can go into the delay slot. */
2519 if (GET_CODE (SET_DEST (pat
)) != REG
2520 || REGNO (SET_DEST (pat
)) < 24)
2523 /* If this instruction sets up floating point register and we have a return
2524 instruction, it can probably go in. But restore will not work
2526 if (REGNO (SET_DEST (pat
)) >= 32)
2528 if (TARGET_V9
&& ! epilogue_renumber (&pat
, 1)
2529 && (get_attr_in_uncond_branch_delay (trial
) == IN_BRANCH_DELAY_TRUE
))
2534 /* The set of insns matched here must agree precisely with the set of
2535 patterns paired with a RETURN in sparc.md. */
2537 src
= SET_SRC (pat
);
2539 /* This matches "*return_[qhs]i" or even "*return_di" on TARGET_ARCH64. */
2540 if (GET_MODE_CLASS (GET_MODE (src
)) != MODE_FLOAT
2541 && arith_operand (src
, GET_MODE (src
)))
2544 return GET_MODE_SIZE (GET_MODE (src
)) <= GET_MODE_SIZE (DImode
);
2546 return GET_MODE_SIZE (GET_MODE (src
)) <= GET_MODE_SIZE (SImode
);
2549 /* This matches "*return_di". */
2550 else if (GET_MODE_CLASS (GET_MODE (src
)) != MODE_FLOAT
2551 && arith_double_operand (src
, GET_MODE (src
)))
2552 return GET_MODE_SIZE (GET_MODE (src
)) <= GET_MODE_SIZE (DImode
);
2554 /* This matches "*return_sf_no_fpu". */
2555 else if (! TARGET_FPU
&& restore_operand (SET_DEST (pat
), SFmode
)
2556 && register_operand (src
, SFmode
))
2559 /* If we have return instruction, anything that does not use
2560 local or output registers and can go into a delay slot wins. */
2561 else if (TARGET_V9
&& ! epilogue_renumber (&pat
, 1)
2562 && (get_attr_in_uncond_branch_delay (trial
) == IN_BRANCH_DELAY_TRUE
))
2565 /* This matches "*return_addsi". */
2566 else if (GET_CODE (src
) == PLUS
2567 && arith_operand (XEXP (src
, 0), SImode
)
2568 && arith_operand (XEXP (src
, 1), SImode
)
2569 && (register_operand (XEXP (src
, 0), SImode
)
2570 || register_operand (XEXP (src
, 1), SImode
)))
2573 /* This matches "*return_adddi". */
2574 else if (GET_CODE (src
) == PLUS
2575 && arith_double_operand (XEXP (src
, 0), DImode
)
2576 && arith_double_operand (XEXP (src
, 1), DImode
)
2577 && (register_operand (XEXP (src
, 0), DImode
)
2578 || register_operand (XEXP (src
, 1), DImode
)))
2581 /* This can match "*return_losum_[sd]i".
2582 Catch only some cases, so that return_losum* don't have
2584 else if (GET_CODE (src
) == LO_SUM
2585 && ! TARGET_CM_MEDMID
2586 && ((register_operand (XEXP (src
, 0), SImode
)
2587 && immediate_operand (XEXP (src
, 1), SImode
))
2589 && register_operand (XEXP (src
, 0), DImode
)
2590 && immediate_operand (XEXP (src
, 1), DImode
))))
2593 /* sll{,x} reg,1,reg2 is add reg,reg,reg2 as well. */
2594 else if (GET_CODE (src
) == ASHIFT
2595 && (register_operand (XEXP (src
, 0), SImode
)
2596 || register_operand (XEXP (src
, 0), DImode
))
2597 && XEXP (src
, 1) == const1_rtx
)
2603 /* Return nonzero if TRIAL can go into the sibling call
2607 eligible_for_sibcall_delay (trial
)
2612 if (GET_CODE (trial
) != INSN
|| GET_CODE (PATTERN (trial
)) != SET
)
2615 if (get_attr_length (trial
) != 1)
2618 pat
= PATTERN (trial
);
2620 if (current_function_uses_only_leaf_regs
)
2622 /* If the tail call is done using the call instruction,
2623 we have to restore %o7 in the delay slot. */
2624 if ((TARGET_ARCH64
&& ! TARGET_CM_MEDLOW
) || flag_pic
)
2627 /* %g1 is used to build the function address */
2628 if (reg_mentioned_p (gen_rtx_REG (Pmode
, 1), pat
))
2634 /* Otherwise, only operations which can be done in tandem with
2635 a `restore' insn can go into the delay slot. */
2636 if (GET_CODE (SET_DEST (pat
)) != REG
2637 || REGNO (SET_DEST (pat
)) < 24
2638 || REGNO (SET_DEST (pat
)) >= 32)
2641 /* If it mentions %o7, it can't go in, because sibcall will clobber it
2643 if (reg_mentioned_p (gen_rtx_REG (Pmode
, 15), pat
))
2646 src
= SET_SRC (pat
);
2648 if (GET_MODE_CLASS (GET_MODE (src
)) != MODE_FLOAT
2649 && arith_operand (src
, GET_MODE (src
)))
2652 return GET_MODE_SIZE (GET_MODE (src
)) <= GET_MODE_SIZE (DImode
);
2654 return GET_MODE_SIZE (GET_MODE (src
)) <= GET_MODE_SIZE (SImode
);
2657 else if (GET_MODE_CLASS (GET_MODE (src
)) != MODE_FLOAT
2658 && arith_double_operand (src
, GET_MODE (src
)))
2659 return GET_MODE_SIZE (GET_MODE (src
)) <= GET_MODE_SIZE (DImode
);
2661 else if (! TARGET_FPU
&& restore_operand (SET_DEST (pat
), SFmode
)
2662 && register_operand (src
, SFmode
))
2665 else if (GET_CODE (src
) == PLUS
2666 && arith_operand (XEXP (src
, 0), SImode
)
2667 && arith_operand (XEXP (src
, 1), SImode
)
2668 && (register_operand (XEXP (src
, 0), SImode
)
2669 || register_operand (XEXP (src
, 1), SImode
)))
2672 else if (GET_CODE (src
) == PLUS
2673 && arith_double_operand (XEXP (src
, 0), DImode
)
2674 && arith_double_operand (XEXP (src
, 1), DImode
)
2675 && (register_operand (XEXP (src
, 0), DImode
)
2676 || register_operand (XEXP (src
, 1), DImode
)))
2679 else if (GET_CODE (src
) == LO_SUM
2680 && ! TARGET_CM_MEDMID
2681 && ((register_operand (XEXP (src
, 0), SImode
)
2682 && immediate_operand (XEXP (src
, 1), SImode
))
2684 && register_operand (XEXP (src
, 0), DImode
)
2685 && immediate_operand (XEXP (src
, 1), DImode
))))
2688 else if (GET_CODE (src
) == ASHIFT
2689 && (register_operand (XEXP (src
, 0), SImode
)
2690 || register_operand (XEXP (src
, 0), DImode
))
2691 && XEXP (src
, 1) == const1_rtx
)
2698 check_return_regs (x
)
2701 switch (GET_CODE (x
))
2704 return IN_OR_GLOBAL_P (x
);
2719 if (check_return_regs (XEXP (x
, 1)) == 0)
2724 return check_return_regs (XEXP (x
, 0));
2732 /* Return 1 if TRIAL references only in and global registers. */
2734 eligible_for_return_delay (trial
)
2737 if (GET_CODE (PATTERN (trial
)) != SET
)
2740 return check_return_regs (PATTERN (trial
));
2744 short_branch (uid1
, uid2
)
2747 int delta
= INSN_ADDRESSES (uid1
) - INSN_ADDRESSES (uid2
);
2749 /* Leave a few words of "slop". */
2750 if (delta
>= -1023 && delta
<= 1022)
2756 /* Return non-zero if REG is not used after INSN.
2757 We assume REG is a reload reg, and therefore does
2758 not live past labels or calls or jumps. */
2760 reg_unused_after (reg
, insn
)
2764 enum rtx_code code
, prev_code
= UNKNOWN
;
2766 while ((insn
= NEXT_INSN (insn
)))
2768 if (prev_code
== CALL_INSN
&& call_used_regs
[REGNO (reg
)])
2771 code
= GET_CODE (insn
);
2772 if (GET_CODE (insn
) == CODE_LABEL
)
2775 if (GET_RTX_CLASS (code
) == 'i')
2777 rtx set
= single_set (insn
);
2778 int in_src
= set
&& reg_overlap_mentioned_p (reg
, SET_SRC (set
));
2781 if (set
&& reg_overlap_mentioned_p (reg
, SET_DEST (set
)))
2783 if (set
== 0 && reg_overlap_mentioned_p (reg
, PATTERN (insn
)))
2791 /* The table we use to reference PIC data. */
2792 static rtx global_offset_table
;
2794 /* The function we use to get at it. */
2795 static rtx get_pc_symbol
;
2796 static char get_pc_symbol_name
[256];
2798 /* Ensure that we are not using patterns that are not OK with PIC. */
2807 if (GET_CODE (recog_data
.operand
[i
]) == SYMBOL_REF
2808 || (GET_CODE (recog_data
.operand
[i
]) == CONST
2809 && ! (GET_CODE (XEXP (recog_data
.operand
[i
], 0)) == MINUS
2810 && (XEXP (XEXP (recog_data
.operand
[i
], 0), 0)
2811 == global_offset_table
)
2812 && (GET_CODE (XEXP (XEXP (recog_data
.operand
[i
], 0), 1))
2821 /* Return true if X is an address which needs a temporary register when
2822 reloaded while generating PIC code. */
2825 pic_address_needs_scratch (x
)
2828 /* An address which is a symbolic plus a non SMALL_INT needs a temp reg. */
2829 if (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
2830 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == SYMBOL_REF
2831 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
2832 && ! SMALL_INT (XEXP (XEXP (x
, 0), 1)))
2838 /* Legitimize PIC addresses. If the address is already position-independent,
2839 we return ORIG. Newly generated position-independent addresses go into a
2840 reg. This is REG if non zero, otherwise we allocate register(s) as
2844 legitimize_pic_address (orig
, mode
, reg
)
2846 enum machine_mode mode ATTRIBUTE_UNUSED
;
2849 if (GET_CODE (orig
) == SYMBOL_REF
)
2851 rtx pic_ref
, address
;
2856 if (reload_in_progress
|| reload_completed
)
2859 reg
= gen_reg_rtx (Pmode
);
2864 /* If not during reload, allocate another temp reg here for loading
2865 in the address, so that these instructions can be optimized
2867 rtx temp_reg
= ((reload_in_progress
|| reload_completed
)
2868 ? reg
: gen_reg_rtx (Pmode
));
2870 /* Must put the SYMBOL_REF inside an UNSPEC here so that cse
2871 won't get confused into thinking that these two instructions
2872 are loading in the true address of the symbol. If in the
2873 future a PIC rtx exists, that should be used instead. */
2874 if (Pmode
== SImode
)
2876 emit_insn (gen_movsi_high_pic (temp_reg
, orig
));
2877 emit_insn (gen_movsi_lo_sum_pic (temp_reg
, temp_reg
, orig
));
2881 emit_insn (gen_movdi_high_pic (temp_reg
, orig
));
2882 emit_insn (gen_movdi_lo_sum_pic (temp_reg
, temp_reg
, orig
));
2889 pic_ref
= gen_rtx_MEM (Pmode
,
2890 gen_rtx_PLUS (Pmode
,
2891 pic_offset_table_rtx
, address
));
2892 current_function_uses_pic_offset_table
= 1;
2893 RTX_UNCHANGING_P (pic_ref
) = 1;
2894 insn
= emit_move_insn (reg
, pic_ref
);
2895 /* Put a REG_EQUAL note on this insn, so that it can be optimized
2897 REG_NOTES (insn
) = gen_rtx_EXPR_LIST (REG_EQUAL
, orig
,
2901 else if (GET_CODE (orig
) == CONST
)
2905 if (GET_CODE (XEXP (orig
, 0)) == PLUS
2906 && XEXP (XEXP (orig
, 0), 0) == pic_offset_table_rtx
)
2911 if (reload_in_progress
|| reload_completed
)
2914 reg
= gen_reg_rtx (Pmode
);
2917 if (GET_CODE (XEXP (orig
, 0)) == PLUS
)
2919 base
= legitimize_pic_address (XEXP (XEXP (orig
, 0), 0), Pmode
, reg
);
2920 offset
= legitimize_pic_address (XEXP (XEXP (orig
, 0), 1), Pmode
,
2921 base
== reg
? 0 : reg
);
2926 if (GET_CODE (offset
) == CONST_INT
)
2928 if (SMALL_INT (offset
))
2929 return plus_constant (base
, INTVAL (offset
));
2930 else if (! reload_in_progress
&& ! reload_completed
)
2931 offset
= force_reg (Pmode
, offset
);
2933 /* If we reach here, then something is seriously wrong. */
2936 return gen_rtx_PLUS (Pmode
, base
, offset
);
2938 else if (GET_CODE (orig
) == LABEL_REF
)
2939 /* ??? Why do we do this? */
2940 /* Now movsi_pic_label_ref uses it, but we ought to be checking that
2941 the register is live instead, in case it is eliminated. */
2942 current_function_uses_pic_offset_table
= 1;
2947 /* Emit special PIC prologues. */
2950 load_pic_register ()
2952 /* Labels to get the PC in the prologue of this function. */
2953 int orig_flag_pic
= flag_pic
;
2958 /* If we haven't emitted the special get_pc helper function, do so now. */
2959 if (get_pc_symbol_name
[0] == 0)
2963 ASM_GENERATE_INTERNAL_LABEL (get_pc_symbol_name
, "LGETPC", 0);
2966 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
2968 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
2969 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LGETPC", 0);
2970 fputs ("\tretl\n\tadd\t%o7, %l7, %l7\n", asm_out_file
);
2973 /* Initialize every time through, since we can't easily
2974 know this to be permanent. */
2975 global_offset_table
= gen_rtx_SYMBOL_REF (Pmode
, "_GLOBAL_OFFSET_TABLE_");
2976 get_pc_symbol
= gen_rtx_SYMBOL_REF (Pmode
, get_pc_symbol_name
);
2979 emit_insn (gen_get_pc (pic_offset_table_rtx
, global_offset_table
,
2982 flag_pic
= orig_flag_pic
;
2984 /* Need to emit this whether or not we obey regdecls,
2985 since setjmp/longjmp can cause life info to screw up.
2986 ??? In the case where we don't obey regdecls, this is not sufficient
2987 since we may not fall out the bottom. */
2988 emit_insn (gen_rtx_USE (VOIDmode
, pic_offset_table_rtx
));
2991 /* Return 1 if RTX is a MEM which is known to be aligned to at
2992 least a DESIRED byte boundary. */
2995 mem_min_alignment (mem
, desired
)
2999 rtx addr
, base
, offset
;
3001 /* If it's not a MEM we can't accept it. */
3002 if (GET_CODE (mem
) != MEM
)
3005 addr
= XEXP (mem
, 0);
3006 base
= offset
= NULL_RTX
;
3007 if (GET_CODE (addr
) == PLUS
)
3009 if (GET_CODE (XEXP (addr
, 0)) == REG
)
3011 base
= XEXP (addr
, 0);
3013 /* What we are saying here is that if the base
3014 REG is aligned properly, the compiler will make
3015 sure any REG based index upon it will be so
3017 if (GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
3018 offset
= XEXP (addr
, 1);
3020 offset
= const0_rtx
;
3023 else if (GET_CODE (addr
) == REG
)
3026 offset
= const0_rtx
;
3029 if (base
!= NULL_RTX
)
3031 int regno
= REGNO (base
);
3033 if (regno
!= HARD_FRAME_POINTER_REGNUM
&& regno
!= STACK_POINTER_REGNUM
)
3035 /* Check if the compiler has recorded some information
3036 about the alignment of the base REG. If reload has
3037 completed, we already matched with proper alignments.
3038 If not running global_alloc, reload might give us
3039 unaligned pointer to local stack though. */
3041 && REGNO_POINTER_ALIGN (regno
) >= desired
* BITS_PER_UNIT
)
3042 || (optimize
&& reload_completed
))
3043 && (INTVAL (offset
) & (desired
- 1)) == 0)
3048 if (((INTVAL (offset
) - SPARC_STACK_BIAS
) & (desired
- 1)) == 0)
3052 else if (! TARGET_UNALIGNED_DOUBLES
3053 || CONSTANT_P (addr
)
3054 || GET_CODE (addr
) == LO_SUM
)
3056 /* Anything else we know is properly aligned unless TARGET_UNALIGNED_DOUBLES
3057 is true, in which case we can only assume that an access is aligned if
3058 it is to a constant address, or the address involves a LO_SUM. */
3062 /* An obviously unaligned address. */
3067 /* Vectors to keep interesting information about registers where it can easily
3068 be got. We use to use the actual mode value as the bit number, but there
3069 are more than 32 modes now. Instead we use two tables: one indexed by
3070 hard register number, and one indexed by mode. */
3072 /* The purpose of sparc_mode_class is to shrink the range of modes so that
3073 they all fit (as bit numbers) in a 32 bit word (again). Each real mode is
3074 mapped into one sparc_mode_class mode. */
3076 enum sparc_mode_class
{
3077 S_MODE
, D_MODE
, T_MODE
, O_MODE
,
3078 SF_MODE
, DF_MODE
, TF_MODE
, OF_MODE
,
3082 /* Modes for single-word and smaller quantities. */
3083 #define S_MODES ((1 << (int) S_MODE) | (1 << (int) SF_MODE))
3085 /* Modes for double-word and smaller quantities. */
3086 #define D_MODES (S_MODES | (1 << (int) D_MODE) | (1 << DF_MODE))
3088 /* Modes for quad-word and smaller quantities. */
3089 #define T_MODES (D_MODES | (1 << (int) T_MODE) | (1 << (int) TF_MODE))
3091 /* Modes for 8-word and smaller quantities. */
3092 #define O_MODES (T_MODES | (1 << (int) O_MODE) | (1 << (int) OF_MODE))
3094 /* Modes for single-float quantities. We must allow any single word or
3095 smaller quantity. This is because the fix/float conversion instructions
3096 take integer inputs/outputs from the float registers. */
3097 #define SF_MODES (S_MODES)
3099 /* Modes for double-float and smaller quantities. */
3100 #define DF_MODES (S_MODES | D_MODES)
3102 /* Modes for double-float only quantities. */
3103 #define DF_MODES_NO_S ((1 << (int) D_MODE) | (1 << (int) DF_MODE))
3105 /* Modes for quad-float only quantities. */
3106 #define TF_ONLY_MODES (1 << (int) TF_MODE)
3108 /* Modes for quad-float and smaller quantities. */
3109 #define TF_MODES (DF_MODES | TF_ONLY_MODES)
3111 /* Modes for quad-float and double-float quantities. */
3112 #define TF_MODES_NO_S (DF_MODES_NO_S | TF_ONLY_MODES)
3114 /* Modes for quad-float pair only quantities. */
3115 #define OF_ONLY_MODES (1 << (int) OF_MODE)
3117 /* Modes for quad-float pairs and smaller quantities. */
3118 #define OF_MODES (TF_MODES | OF_ONLY_MODES)
3120 #define OF_MODES_NO_S (TF_MODES_NO_S | OF_ONLY_MODES)
3122 /* Modes for condition codes. */
3123 #define CC_MODES (1 << (int) CC_MODE)
3124 #define CCFP_MODES (1 << (int) CCFP_MODE)
3126 /* Value is 1 if register/mode pair is acceptable on sparc.
3127 The funny mixture of D and T modes is because integer operations
3128 do not specially operate on tetra quantities, so non-quad-aligned
3129 registers can hold quadword quantities (except %o4 and %i4 because
3130 they cross fixed registers). */
3132 /* This points to either the 32 bit or the 64 bit version. */
3133 const int *hard_regno_mode_classes
;
3135 static const int hard_32bit_mode_classes
[] = {
3136 S_MODES
, S_MODES
, T_MODES
, S_MODES
, T_MODES
, S_MODES
, D_MODES
, S_MODES
,
3137 T_MODES
, S_MODES
, T_MODES
, S_MODES
, D_MODES
, S_MODES
, D_MODES
, S_MODES
,
3138 T_MODES
, S_MODES
, T_MODES
, S_MODES
, T_MODES
, S_MODES
, D_MODES
, S_MODES
,
3139 T_MODES
, S_MODES
, T_MODES
, S_MODES
, D_MODES
, S_MODES
, D_MODES
, S_MODES
,
3141 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3142 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3143 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3144 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, TF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3146 /* FP regs f32 to f63. Only the even numbered registers actually exist,
3147 and none can hold SFmode/SImode values. */
3148 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3149 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3150 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3151 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, TF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3154 CCFP_MODES
, CCFP_MODES
, CCFP_MODES
, CCFP_MODES
,
3160 static const int hard_64bit_mode_classes
[] = {
3161 D_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
,
3162 O_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
,
3163 T_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
,
3164 O_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
, T_MODES
, D_MODES
,
3166 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3167 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3168 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3169 OF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
, TF_MODES
, SF_MODES
, DF_MODES
, SF_MODES
,
3171 /* FP regs f32 to f63. Only the even numbered registers actually exist,
3172 and none can hold SFmode/SImode values. */
3173 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3174 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3175 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3176 OF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0, TF_MODES_NO_S
, 0, DF_MODES_NO_S
, 0,
3179 CCFP_MODES
, CCFP_MODES
, CCFP_MODES
, CCFP_MODES
,
3185 int sparc_mode_class
[NUM_MACHINE_MODES
];
3187 enum reg_class sparc_regno_reg_class
[FIRST_PSEUDO_REGISTER
];
3194 for (i
= 0; i
< NUM_MACHINE_MODES
; i
++)
3196 switch (GET_MODE_CLASS (i
))
3199 case MODE_PARTIAL_INT
:
3200 case MODE_COMPLEX_INT
:
3201 if (GET_MODE_SIZE (i
) <= 4)
3202 sparc_mode_class
[i
] = 1 << (int) S_MODE
;
3203 else if (GET_MODE_SIZE (i
) == 8)
3204 sparc_mode_class
[i
] = 1 << (int) D_MODE
;
3205 else if (GET_MODE_SIZE (i
) == 16)
3206 sparc_mode_class
[i
] = 1 << (int) T_MODE
;
3207 else if (GET_MODE_SIZE (i
) == 32)
3208 sparc_mode_class
[i
] = 1 << (int) O_MODE
;
3210 sparc_mode_class
[i
] = 0;
3213 case MODE_COMPLEX_FLOAT
:
3214 if (GET_MODE_SIZE (i
) <= 4)
3215 sparc_mode_class
[i
] = 1 << (int) SF_MODE
;
3216 else if (GET_MODE_SIZE (i
) == 8)
3217 sparc_mode_class
[i
] = 1 << (int) DF_MODE
;
3218 else if (GET_MODE_SIZE (i
) == 16)
3219 sparc_mode_class
[i
] = 1 << (int) TF_MODE
;
3220 else if (GET_MODE_SIZE (i
) == 32)
3221 sparc_mode_class
[i
] = 1 << (int) OF_MODE
;
3223 sparc_mode_class
[i
] = 0;
3227 /* mode_class hasn't been initialized yet for EXTRA_CC_MODES, so
3228 we must explicitly check for them here. */
3229 if (i
== (int) CCFPmode
|| i
== (int) CCFPEmode
)
3230 sparc_mode_class
[i
] = 1 << (int) CCFP_MODE
;
3231 else if (i
== (int) CCmode
|| i
== (int) CC_NOOVmode
3232 || i
== (int) CCXmode
|| i
== (int) CCX_NOOVmode
)
3233 sparc_mode_class
[i
] = 1 << (int) CC_MODE
;
3235 sparc_mode_class
[i
] = 0;
3241 hard_regno_mode_classes
= hard_64bit_mode_classes
;
3243 hard_regno_mode_classes
= hard_32bit_mode_classes
;
3245 /* Initialize the array used by REGNO_REG_CLASS. */
3246 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
3248 if (i
< 16 && TARGET_V8PLUS
)
3249 sparc_regno_reg_class
[i
] = I64_REGS
;
3250 else if (i
< 32 || i
== FRAME_POINTER_REGNUM
)
3251 sparc_regno_reg_class
[i
] = GENERAL_REGS
;
3253 sparc_regno_reg_class
[i
] = FP_REGS
;
3255 sparc_regno_reg_class
[i
] = EXTRA_FP_REGS
;
3257 sparc_regno_reg_class
[i
] = FPCC_REGS
;
3259 sparc_regno_reg_class
[i
] = NO_REGS
;
3263 /* Save non call used registers from LOW to HIGH at BASE+OFFSET.
3264 N_REGS is the number of 4-byte regs saved thus far. This applies even to
3265 v9 int regs as it simplifies the code. */
3268 save_regs (file
, low
, high
, base
, offset
, n_regs
, real_offset
)
3278 if (TARGET_ARCH64
&& high
<= 32)
3280 for (i
= low
; i
< high
; i
++)
3282 if (regs_ever_live
[i
] && ! call_used_regs
[i
])
3284 fprintf (file
, "\tstx\t%s, [%s+%d]\n",
3285 reg_names
[i
], base
, offset
+ 4 * n_regs
);
3286 if (dwarf2out_do_frame ())
3287 dwarf2out_reg_save ("", i
, real_offset
+ 4 * n_regs
);
3294 for (i
= low
; i
< high
; i
+= 2)
3296 if (regs_ever_live
[i
] && ! call_used_regs
[i
])
3298 if (regs_ever_live
[i
+1] && ! call_used_regs
[i
+1])
3300 fprintf (file
, "\tstd\t%s, [%s+%d]\n",
3301 reg_names
[i
], base
, offset
+ 4 * n_regs
);
3302 if (dwarf2out_do_frame ())
3304 char *l
= dwarf2out_cfi_label ();
3305 dwarf2out_reg_save (l
, i
, real_offset
+ 4 * n_regs
);
3306 dwarf2out_reg_save (l
, i
+1, real_offset
+ 4 * n_regs
+ 4);
3312 fprintf (file
, "\tst\t%s, [%s+%d]\n",
3313 reg_names
[i
], base
, offset
+ 4 * n_regs
);
3314 if (dwarf2out_do_frame ())
3315 dwarf2out_reg_save ("", i
, real_offset
+ 4 * n_regs
);
3321 if (regs_ever_live
[i
+1] && ! call_used_regs
[i
+1])
3323 fprintf (file
, "\tst\t%s, [%s+%d]\n",
3324 reg_names
[i
+1], base
, offset
+ 4 * n_regs
+ 4);
3325 if (dwarf2out_do_frame ())
3326 dwarf2out_reg_save ("", i
+ 1, real_offset
+ 4 * n_regs
+ 4);
3335 /* Restore non call used registers from LOW to HIGH at BASE+OFFSET.
3337 N_REGS is the number of 4-byte regs saved thus far. This applies even to
3338 v9 int regs as it simplifies the code. */
3341 restore_regs (file
, low
, high
, base
, offset
, n_regs
)
3350 if (TARGET_ARCH64
&& high
<= 32)
3352 for (i
= low
; i
< high
; i
++)
3354 if (regs_ever_live
[i
] && ! call_used_regs
[i
])
3355 fprintf (file
, "\tldx\t[%s+%d], %s\n",
3356 base
, offset
+ 4 * n_regs
, reg_names
[i
]),
3362 for (i
= low
; i
< high
; i
+= 2)
3364 if (regs_ever_live
[i
] && ! call_used_regs
[i
])
3365 if (regs_ever_live
[i
+1] && ! call_used_regs
[i
+1])
3366 fprintf (file
, "\tldd\t[%s+%d], %s\n",
3367 base
, offset
+ 4 * n_regs
, reg_names
[i
]),
3370 fprintf (file
, "\tld\t[%s+%d], %s\n",
3371 base
, offset
+ 4 * n_regs
, reg_names
[i
]),
3373 else if (regs_ever_live
[i
+1] && ! call_used_regs
[i
+1])
3374 fprintf (file
, "\tld\t[%s+%d], %s\n",
3375 base
, offset
+ 4 * n_regs
+ 4, reg_names
[i
+1]),
3382 /* Compute the frame size required by the function. This function is called
3383 during the reload pass and also by output_function_prologue(). */
3386 compute_frame_size (size
, leaf_function
)
3391 int outgoing_args_size
= (current_function_outgoing_args_size
3392 + REG_PARM_STACK_SPACE (current_function_decl
));
3394 /* N_REGS is the number of 4-byte regs saved thus far. This applies
3395 even to v9 int regs to be consistent with save_regs/restore_regs. */
3399 for (i
= 0; i
< 8; i
++)
3400 if (regs_ever_live
[i
] && ! call_used_regs
[i
])
3405 for (i
= 0; i
< 8; i
+= 2)
3406 if ((regs_ever_live
[i
] && ! call_used_regs
[i
])
3407 || (regs_ever_live
[i
+1] && ! call_used_regs
[i
+1]))
3411 for (i
= 32; i
< (TARGET_V9
? 96 : 64); i
+= 2)
3412 if ((regs_ever_live
[i
] && ! call_used_regs
[i
])
3413 || (regs_ever_live
[i
+1] && ! call_used_regs
[i
+1]))
3416 /* Set up values for use in `function_epilogue'. */
3417 num_gfregs
= n_regs
;
3419 if (leaf_function
&& n_regs
== 0
3420 && size
== 0 && current_function_outgoing_args_size
== 0)
3422 actual_fsize
= apparent_fsize
= 0;
3426 /* We subtract STARTING_FRAME_OFFSET, remember it's negative. */
3427 apparent_fsize
= (size
- STARTING_FRAME_OFFSET
+ 7) & -8;
3428 apparent_fsize
+= n_regs
* 4;
3429 actual_fsize
= apparent_fsize
+ ((outgoing_args_size
+ 7) & -8);
3432 /* Make sure nothing can clobber our register windows.
3433 If a SAVE must be done, or there is a stack-local variable,
3434 the register window area must be allocated.
3435 ??? For v8 we apparently need an additional 8 bytes of reserved space. */
3436 if (leaf_function
== 0 || size
> 0)
3437 actual_fsize
+= (16 * UNITS_PER_WORD
) + (TARGET_ARCH64
? 0 : 8);
3439 return SPARC_STACK_ALIGN (actual_fsize
);
3442 /* Build a (32 bit) big number in a register. */
3443 /* ??? We may be able to use the set macro here too. */
3446 build_big_number (file
, num
, reg
)
3451 if (num
>= 0 || ! TARGET_ARCH64
)
3453 fprintf (file
, "\tsethi\t%%hi(%d), %s\n", num
, reg
);
3454 if ((num
& 0x3ff) != 0)
3455 fprintf (file
, "\tor\t%s, %%lo(%d), %s\n", reg
, num
, reg
);
3457 else /* num < 0 && TARGET_ARCH64 */
3459 /* Sethi does not sign extend, so we must use a little trickery
3460 to use it for negative numbers. Invert the constant before
3461 loading it in, then use xor immediate to invert the loaded bits
3462 (along with the upper 32 bits) to the desired constant. This
3463 works because the sethi and immediate fields overlap. */
3466 int low
= -0x400 + (asize
& 0x3FF);
3468 fprintf (file
, "\tsethi\t%%hi(%d), %s\n\txor\t%s, %d, %s\n",
3469 inv
, reg
, reg
, low
, reg
);
3473 /* Output any necessary .register pseudo-ops. */
3475 sparc_output_scratch_registers (file
)
3476 FILE *file ATTRIBUTE_UNUSED
;
3478 #ifdef HAVE_AS_REGISTER_PSEUDO_OP
3484 /* Check if %g[2367] were used without
3485 .register being printed for them already. */
3486 for (i
= 2; i
< 8; i
++)
3488 if (regs_ever_live
[i
]
3489 && ! sparc_hard_reg_printed
[i
])
3491 sparc_hard_reg_printed
[i
] = 1;
3492 fprintf (file
, "\t.register\t%%g%d, #scratch\n", i
);
3499 /* This function generates the assembly code for function entry.
3500 FILE is a stdio stream to output the code to.
3501 SIZE is an int: how many units of temporary storage to allocate.
3502 Refer to the array `regs_ever_live' to determine which registers
3503 to save; `regs_ever_live[I]' is nonzero if register number I
3504 is ever used in the function. This macro is responsible for
3505 knowing which registers should not be saved even if used. */
3507 /* On SPARC, move-double insns between fpu and cpu need an 8-byte block
3508 of memory. If any fpu reg is used in the function, we allocate
3509 such a block here, at the bottom of the frame, just in case it's needed.
3511 If this function is a leaf procedure, then we may choose not
3512 to do a "save" insn. The decision about whether or not
3513 to do this is made in regclass.c. */
3516 sparc_output_function_prologue (file
, size
)
3521 sparc_flat_function_prologue (file
, size
);
3523 sparc_nonflat_function_prologue (file
, size
,
3524 current_function_uses_only_leaf_regs
);
3527 /* Output code for the function prologue. */
3530 sparc_nonflat_function_prologue (file
, size
, leaf_function
)
3535 sparc_output_scratch_registers (file
);
3537 /* Need to use actual_fsize, since we are also allocating
3538 space for our callee (and our own register save area). */
3539 actual_fsize
= compute_frame_size (size
, leaf_function
);
3543 frame_base_name
= "%sp";
3544 frame_base_offset
= actual_fsize
+ SPARC_STACK_BIAS
;
3548 frame_base_name
= "%fp";
3549 frame_base_offset
= SPARC_STACK_BIAS
;
3552 /* This is only for the human reader. */
3553 fprintf (file
, "\t%s#PROLOGUE# 0\n", ASM_COMMENT_START
);
3555 if (actual_fsize
== 0)
3557 else if (! leaf_function
)
3559 if (actual_fsize
<= 4096)
3560 fprintf (file
, "\tsave\t%%sp, -%d, %%sp\n", actual_fsize
);
3561 else if (actual_fsize
<= 8192)
3563 fprintf (file
, "\tsave\t%%sp, -4096, %%sp\n");
3564 fprintf (file
, "\tadd\t%%sp, -%d, %%sp\n", actual_fsize
- 4096);
3568 build_big_number (file
, -actual_fsize
, "%g1");
3569 fprintf (file
, "\tsave\t%%sp, %%g1, %%sp\n");
3572 else /* leaf function */
3574 if (actual_fsize
<= 4096)
3575 fprintf (file
, "\tadd\t%%sp, -%d, %%sp\n", actual_fsize
);
3576 else if (actual_fsize
<= 8192)
3578 fprintf (file
, "\tadd\t%%sp, -4096, %%sp\n");
3579 fprintf (file
, "\tadd\t%%sp, -%d, %%sp\n", actual_fsize
- 4096);
3583 build_big_number (file
, -actual_fsize
, "%g1");
3584 fprintf (file
, "\tadd\t%%sp, %%g1, %%sp\n");
3588 if (dwarf2out_do_frame () && actual_fsize
)
3590 char *label
= dwarf2out_cfi_label ();
3592 /* The canonical frame address refers to the top of the frame. */
3593 dwarf2out_def_cfa (label
, (leaf_function
? STACK_POINTER_REGNUM
3594 : HARD_FRAME_POINTER_REGNUM
),
3597 if (! leaf_function
)
3599 /* Note the register window save. This tells the unwinder that
3600 it needs to restore the window registers from the previous
3601 frame's window save area at 0(cfa). */
3602 dwarf2out_window_save (label
);
3604 /* The return address (-8) is now in %i7. */
3605 dwarf2out_return_reg (label
, 31);
3609 /* If doing anything with PIC, do it now. */
3611 fprintf (file
, "\t%s#PROLOGUE# 1\n", ASM_COMMENT_START
);
3613 /* Call saved registers are saved just above the outgoing argument area. */
3616 int offset
, real_offset
, n_regs
;
3619 real_offset
= -apparent_fsize
;
3620 offset
= -apparent_fsize
+ frame_base_offset
;
3621 if (offset
< -4096 || offset
+ num_gfregs
* 4 > 4096)
3623 /* ??? This might be optimized a little as %g1 might already have a
3624 value close enough that a single add insn will do. */
3625 /* ??? Although, all of this is probably only a temporary fix
3626 because if %g1 can hold a function result, then
3627 output_function_epilogue will lose (the result will get
3629 build_big_number (file
, offset
, "%g1");
3630 fprintf (file
, "\tadd\t%s, %%g1, %%g1\n", frame_base_name
);
3636 base
= frame_base_name
;
3639 n_regs
= save_regs (file
, 0, 8, base
, offset
, 0, real_offset
);
3640 save_regs (file
, 32, TARGET_V9
? 96 : 64, base
, offset
, n_regs
,
3645 /* Output code to restore any call saved registers. */
3648 output_restore_regs (file
, leaf_function
)
3650 int leaf_function ATTRIBUTE_UNUSED
;
3655 offset
= -apparent_fsize
+ frame_base_offset
;
3656 if (offset
< -4096 || offset
+ num_gfregs
* 4 > 4096 - 8 /*double*/)
3658 build_big_number (file
, offset
, "%g1");
3659 fprintf (file
, "\tadd\t%s, %%g1, %%g1\n", frame_base_name
);
3665 base
= frame_base_name
;
3668 n_regs
= restore_regs (file
, 0, 8, base
, offset
, 0);
3669 restore_regs (file
, 32, TARGET_V9
? 96 : 64, base
, offset
, n_regs
);
3672 /* This function generates the assembly code for function exit,
3673 on machines that need it.
3675 The function epilogue should not depend on the current stack pointer!
3676 It should use the frame pointer only. This is mandatory because
3677 of alloca; we also take advantage of it to omit stack adjustments
3678 before returning. */
3681 sparc_output_function_epilogue (file
, size
)
3686 sparc_flat_function_epilogue (file
, size
);
3688 sparc_nonflat_function_epilogue (file
, size
,
3689 current_function_uses_only_leaf_regs
);
3692 /* Output code for the function epilogue. */
3695 sparc_nonflat_function_epilogue (file
, size
, leaf_function
)
3697 HOST_WIDE_INT size ATTRIBUTE_UNUSED
;
3702 if (current_function_epilogue_delay_list
== 0)
3704 /* If code does not drop into the epilogue, we need
3705 do nothing except output pending case vectors.
3707 We have to still output a dummy nop for the sake of
3708 sane backtraces. Otherwise, if the last two instructions
3709 of a function were call foo; dslot; this can make the return
3710 PC of foo (ie. address of call instruction plus 8) point to
3711 the first instruction in the next function. */
3714 fputs("\tnop\n", file
);
3716 insn
= get_last_insn ();
3717 if (GET_CODE (insn
) == NOTE
)
3718 insn
= prev_nonnote_insn (insn
);
3719 if (insn
&& GET_CODE (insn
) == BARRIER
)
3720 goto output_vectors
;
3724 output_restore_regs (file
, leaf_function
);
3726 /* Work out how to skip the caller's unimp instruction if required. */
3728 ret
= (SKIP_CALLERS_UNIMP_P
? "jmp\t%o7+12" : "retl");
3730 ret
= (SKIP_CALLERS_UNIMP_P
? "jmp\t%i7+12" : "ret");
3732 if (! leaf_function
)
3734 if (current_function_calls_eh_return
)
3736 if (current_function_epilogue_delay_list
)
3738 if (SKIP_CALLERS_UNIMP_P
)
3741 fputs ("\trestore\n\tretl\n\tadd\t%sp, %g1, %sp\n", file
);
3743 /* If we wound up with things in our delay slot, flush them here. */
3744 else if (current_function_epilogue_delay_list
)
3746 rtx delay
= PATTERN (XEXP (current_function_epilogue_delay_list
, 0));
3748 if (TARGET_V9
&& ! epilogue_renumber (&delay
, 1))
3750 epilogue_renumber (&delay
, 0);
3751 fputs (SKIP_CALLERS_UNIMP_P
3752 ? "\treturn\t%i7+12\n"
3753 : "\treturn\t%i7+8\n", file
);
3754 final_scan_insn (XEXP (current_function_epilogue_delay_list
, 0),
3761 if (GET_CODE (delay
) != SET
)
3764 src
= SET_SRC (delay
);
3765 if (GET_CODE (src
) == ASHIFT
)
3767 if (XEXP (src
, 1) != const1_rtx
)
3770 = gen_rtx_PLUS (GET_MODE (src
), XEXP (src
, 0),
3774 insn
= gen_rtx_PARALLEL (VOIDmode
,
3775 gen_rtvec (2, delay
,
3776 gen_rtx_RETURN (VOIDmode
)));
3777 insn
= emit_jump_insn (insn
);
3779 sparc_emitting_epilogue
= true;
3780 final_scan_insn (insn
, file
, 1, 0, 1);
3781 sparc_emitting_epilogue
= false;
3784 else if (TARGET_V9
&& ! SKIP_CALLERS_UNIMP_P
)
3785 fputs ("\treturn\t%i7+8\n\tnop\n", file
);
3787 fprintf (file
, "\t%s\n\trestore\n", ret
);
3789 /* All of the following cases are for leaf functions. */
3790 else if (current_function_calls_eh_return
)
3792 else if (current_function_epilogue_delay_list
)
3794 /* eligible_for_epilogue_delay_slot ensures that if this is a
3795 leaf function, then we will only have insn in the delay slot
3796 if the frame size is zero, thus no adjust for the stack is
3798 if (actual_fsize
!= 0)
3800 fprintf (file
, "\t%s\n", ret
);
3801 final_scan_insn (XEXP (current_function_epilogue_delay_list
, 0),
3804 /* Output 'nop' instead of 'sub %sp,-0,%sp' when no frame, so as to
3805 avoid generating confusing assembly language output. */
3806 else if (actual_fsize
== 0)
3807 fprintf (file
, "\t%s\n\tnop\n", ret
);
3808 else if (actual_fsize
<= 4096)
3809 fprintf (file
, "\t%s\n\tsub\t%%sp, -%d, %%sp\n", ret
, actual_fsize
);
3810 else if (actual_fsize
<= 8192)
3811 fprintf (file
, "\tsub\t%%sp, -4096, %%sp\n\t%s\n\tsub\t%%sp, -%d, %%sp\n",
3812 ret
, actual_fsize
- 4096);
3813 else if ((actual_fsize
& 0x3ff) == 0)
3814 fprintf (file
, "\tsethi\t%%hi(%d), %%g1\n\t%s\n\tadd\t%%sp, %%g1, %%sp\n",
3817 fprintf (file
, "\tsethi\t%%hi(%d), %%g1\n\tor\t%%g1, %%lo(%d), %%g1\n\t%s\n\tadd\t%%sp, %%g1, %%sp\n",
3818 actual_fsize
, actual_fsize
, ret
);
3821 sparc_output_deferred_case_vectors ();
3824 /* Output a sibling call. */
3827 output_sibcall (insn
, call_operand
)
3828 rtx insn
, call_operand
;
3830 int leaf_regs
= current_function_uses_only_leaf_regs
;
3832 int delay_slot
= dbr_sequence_length () > 0;
3836 /* Call to restore global regs might clobber
3837 the delay slot. Instead of checking for this
3838 output the delay slot now. */
3841 rtx delay
= NEXT_INSN (insn
);
3846 final_scan_insn (delay
, asm_out_file
, 1, 0, 1);
3847 PATTERN (delay
) = gen_blockage ();
3848 INSN_CODE (delay
) = -1;
3851 output_restore_regs (asm_out_file
, leaf_regs
);
3854 operands
[0] = call_operand
;
3858 #ifdef HAVE_AS_RELAX_OPTION
3859 /* If as and ld are relaxing tail call insns into branch always,
3860 use or %o7,%g0,X; call Y; or X,%g0,%o7 always, so that it can
3861 be optimized. With sethi/jmpl as nor ld has no easy way how to
3862 find out if somebody does not branch between the sethi and jmpl. */
3865 int spare_slot
= ((TARGET_ARCH32
|| TARGET_CM_MEDLOW
) && ! flag_pic
);
3869 if ((actual_fsize
|| ! spare_slot
) && delay_slot
)
3871 rtx delay
= NEXT_INSN (insn
);
3876 final_scan_insn (delay
, asm_out_file
, 1, 0, 1);
3877 PATTERN (delay
) = gen_blockage ();
3878 INSN_CODE (delay
) = -1;
3883 if (actual_fsize
<= 4096)
3884 size
= actual_fsize
;
3885 else if (actual_fsize
<= 8192)
3887 fputs ("\tsub\t%sp, -4096, %sp\n", asm_out_file
);
3888 size
= actual_fsize
- 4096;
3890 else if ((actual_fsize
& 0x3ff) == 0)
3891 fprintf (asm_out_file
,
3892 "\tsethi\t%%hi(%d), %%g1\n\tadd\t%%sp, %%g1, %%sp\n",
3896 fprintf (asm_out_file
,
3897 "\tsethi\t%%hi(%d), %%g1\n\tor\t%%g1, %%lo(%d), %%g1\n",
3898 actual_fsize
, actual_fsize
);
3899 fputs ("\tadd\t%%sp, %%g1, %%sp\n", asm_out_file
);
3904 output_asm_insn ("sethi\t%%hi(%a0), %%g1", operands
);
3905 output_asm_insn ("jmpl\t%%g1 + %%lo(%a0), %%g0", operands
);
3907 fprintf (asm_out_file
, "\t sub\t%%sp, -%d, %%sp\n", size
);
3908 else if (! delay_slot
)
3909 fputs ("\t nop\n", asm_out_file
);
3914 fprintf (asm_out_file
, "\tsub\t%%sp, -%d, %%sp\n", size
);
3915 /* Use or with rs2 %%g0 instead of mov, so that as/ld can optimize
3916 it into branch if possible. */
3917 output_asm_insn ("or\t%%o7, %%g0, %%g1", operands
);
3918 output_asm_insn ("call\t%a0, 0", operands
);
3919 output_asm_insn (" or\t%%g1, %%g0, %%o7", operands
);
3924 output_asm_insn ("call\t%a0, 0", operands
);
3927 rtx delay
= NEXT_INSN (insn
), pat
;
3932 pat
= PATTERN (delay
);
3933 if (GET_CODE (pat
) != SET
)
3936 operands
[0] = SET_DEST (pat
);
3937 pat
= SET_SRC (pat
);
3938 switch (GET_CODE (pat
))
3941 operands
[1] = XEXP (pat
, 0);
3942 operands
[2] = XEXP (pat
, 1);
3943 output_asm_insn (" restore %r1, %2, %Y0", operands
);
3946 operands
[1] = XEXP (pat
, 0);
3947 operands
[2] = XEXP (pat
, 1);
3948 output_asm_insn (" restore %r1, %%lo(%a2), %Y0", operands
);
3951 operands
[1] = XEXP (pat
, 0);
3952 output_asm_insn (" restore %r1, %r1, %Y0", operands
);
3956 output_asm_insn (" restore %%g0, %1, %Y0", operands
);
3959 PATTERN (delay
) = gen_blockage ();
3960 INSN_CODE (delay
) = -1;
3963 fputs ("\t restore\n", asm_out_file
);
3967 /* Functions for handling argument passing.
3969 For v8 the first six args are normally in registers and the rest are
3970 pushed. Any arg that starts within the first 6 words is at least
3971 partially passed in a register unless its data type forbids.
3973 For v9, the argument registers are laid out as an array of 16 elements
3974 and arguments are added sequentially. The first 6 int args and up to the
3975 first 16 fp args (depending on size) are passed in regs.
3977 Slot Stack Integral Float Float in structure Double Long Double
3978 ---- ----- -------- ----- ------------------ ------ -----------
3979 15 [SP+248] %f31 %f30,%f31 %d30
3980 14 [SP+240] %f29 %f28,%f29 %d28 %q28
3981 13 [SP+232] %f27 %f26,%f27 %d26
3982 12 [SP+224] %f25 %f24,%f25 %d24 %q24
3983 11 [SP+216] %f23 %f22,%f23 %d22
3984 10 [SP+208] %f21 %f20,%f21 %d20 %q20
3985 9 [SP+200] %f19 %f18,%f19 %d18
3986 8 [SP+192] %f17 %f16,%f17 %d16 %q16
3987 7 [SP+184] %f15 %f14,%f15 %d14
3988 6 [SP+176] %f13 %f12,%f13 %d12 %q12
3989 5 [SP+168] %o5 %f11 %f10,%f11 %d10
3990 4 [SP+160] %o4 %f9 %f8,%f9 %d8 %q8
3991 3 [SP+152] %o3 %f7 %f6,%f7 %d6
3992 2 [SP+144] %o2 %f5 %f4,%f5 %d4 %q4
3993 1 [SP+136] %o1 %f3 %f2,%f3 %d2
3994 0 [SP+128] %o0 %f1 %f0,%f1 %d0 %q0
3996 Here SP = %sp if -mno-stack-bias or %sp+stack_bias otherwise.
3998 Integral arguments are always passed as 64 bit quantities appropriately
4001 Passing of floating point values is handled as follows.
4002 If a prototype is in scope:
4003 If the value is in a named argument (i.e. not a stdarg function or a
4004 value not part of the `...') then the value is passed in the appropriate
4006 If the value is part of the `...' and is passed in one of the first 6
4007 slots then the value is passed in the appropriate int reg.
4008 If the value is part of the `...' and is not passed in one of the first 6
4009 slots then the value is passed in memory.
4010 If a prototype is not in scope:
4011 If the value is one of the first 6 arguments the value is passed in the
4012 appropriate integer reg and the appropriate fp reg.
4013 If the value is not one of the first 6 arguments the value is passed in
4014 the appropriate fp reg and in memory.
4017 /* Maximum number of int regs for args. */
4018 #define SPARC_INT_ARG_MAX 6
4019 /* Maximum number of fp regs for args. */
4020 #define SPARC_FP_ARG_MAX 16
4022 #define ROUND_ADVANCE(SIZE) (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
4024 /* Handle the INIT_CUMULATIVE_ARGS macro.
4025 Initialize a variable CUM of type CUMULATIVE_ARGS
4026 for a call to a function whose data type is FNTYPE.
4027 For a library call, FNTYPE is 0. */
4030 init_cumulative_args (cum
, fntype
, libname
, indirect
)
4031 CUMULATIVE_ARGS
*cum
;
4033 rtx libname ATTRIBUTE_UNUSED
;
4034 int indirect ATTRIBUTE_UNUSED
;
4037 cum
->prototype_p
= fntype
&& TYPE_ARG_TYPES (fntype
);
4038 cum
->libcall_p
= fntype
== 0;
4041 /* Compute the slot number to pass an argument in.
4042 Returns the slot number or -1 if passing on the stack.
4044 CUM is a variable of type CUMULATIVE_ARGS which gives info about
4045 the preceding args and about the function being called.
4046 MODE is the argument's machine mode.
4047 TYPE is the data type of the argument (as a tree).
4048 This is null for libcalls where that information may
4050 NAMED is nonzero if this argument is a named parameter
4051 (otherwise it is an extra parameter matching an ellipsis).
4052 INCOMING_P is zero for FUNCTION_ARG, nonzero for FUNCTION_INCOMING_ARG.
4053 *PREGNO records the register number to use if scalar type.
4054 *PPADDING records the amount of padding needed in words. */
4057 function_arg_slotno (cum
, mode
, type
, named
, incoming_p
, pregno
, ppadding
)
4058 const CUMULATIVE_ARGS
*cum
;
4059 enum machine_mode mode
;
4066 int regbase
= (incoming_p
4067 ? SPARC_INCOMING_INT_ARG_FIRST
4068 : SPARC_OUTGOING_INT_ARG_FIRST
);
4069 int slotno
= cum
->words
;
4074 if (type
!= 0 && TREE_ADDRESSABLE (type
))
4077 && type
!= 0 && mode
== BLKmode
4078 && TYPE_ALIGN (type
) % PARM_BOUNDARY
!= 0)
4084 /* MODE is VOIDmode when generating the actual call.
4088 case QImode
: case CQImode
:
4089 case HImode
: case CHImode
:
4090 case SImode
: case CSImode
:
4091 case DImode
: case CDImode
:
4092 case TImode
: case CTImode
:
4093 if (slotno
>= SPARC_INT_ARG_MAX
)
4095 regno
= regbase
+ slotno
;
4098 case SFmode
: case SCmode
:
4099 case DFmode
: case DCmode
:
4100 case TFmode
: case TCmode
:
4103 if (slotno
>= SPARC_INT_ARG_MAX
)
4105 regno
= regbase
+ slotno
;
4109 if ((mode
== TFmode
|| mode
== TCmode
)
4110 && (slotno
& 1) != 0)
4111 slotno
++, *ppadding
= 1;
4112 if (TARGET_FPU
&& named
)
4114 if (slotno
>= SPARC_FP_ARG_MAX
)
4116 regno
= SPARC_FP_ARG_FIRST
+ slotno
* 2;
4122 if (slotno
>= SPARC_INT_ARG_MAX
)
4124 regno
= regbase
+ slotno
;
4130 /* For sparc64, objects requiring 16 byte alignment get it. */
4133 if (type
&& TYPE_ALIGN (type
) == 128 && (slotno
& 1) != 0)
4134 slotno
++, *ppadding
= 1;
4138 || (type
&& TREE_CODE (type
) == UNION_TYPE
))
4140 if (slotno
>= SPARC_INT_ARG_MAX
)
4142 regno
= regbase
+ slotno
;
4147 int intregs_p
= 0, fpregs_p
= 0;
4148 /* The ABI obviously doesn't specify how packed
4149 structures are passed. These are defined to be passed
4150 in int regs if possible, otherwise memory. */
4153 /* First see what kinds of registers we need. */
4154 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
4156 if (TREE_CODE (field
) == FIELD_DECL
)
4158 if (TREE_CODE (TREE_TYPE (field
)) == REAL_TYPE
4163 if (DECL_PACKED (field
))
4167 if (packed_p
|| !named
)
4168 fpregs_p
= 0, intregs_p
= 1;
4170 /* If all arg slots are filled, then must pass on stack. */
4171 if (fpregs_p
&& slotno
>= SPARC_FP_ARG_MAX
)
4173 /* If there are only int args and all int arg slots are filled,
4174 then must pass on stack. */
4175 if (!fpregs_p
&& intregs_p
&& slotno
>= SPARC_INT_ARG_MAX
)
4177 /* Note that even if all int arg slots are filled, fp members may
4178 still be passed in regs if such regs are available.
4179 *PREGNO isn't set because there may be more than one, it's up
4180 to the caller to compute them. */
4193 /* Handle recursive register counting for structure field layout. */
4195 struct function_arg_record_value_parms
4198 int slotno
, named
, regbase
;
4203 static void function_arg_record_value_3
4204 PARAMS ((HOST_WIDE_INT
, struct function_arg_record_value_parms
*));
4205 static void function_arg_record_value_2
4206 PARAMS ((tree
, HOST_WIDE_INT
,
4207 struct function_arg_record_value_parms
*));
4208 static void function_arg_record_value_1
4209 PARAMS ((tree
, HOST_WIDE_INT
,
4210 struct function_arg_record_value_parms
*));
4211 static rtx function_arg_record_value
4212 PARAMS ((tree
, enum machine_mode
, int, int, int));
4214 /* A subroutine of function_arg_record_value. Traverse the structure
4215 recusively and determine how many registers will be required. */
4218 function_arg_record_value_1 (type
, startbitpos
, parms
)
4220 HOST_WIDE_INT startbitpos
;
4221 struct function_arg_record_value_parms
*parms
;
4225 /* The ABI obviously doesn't specify how packed structures are
4226 passed. These are defined to be passed in int regs if possible,
4227 otherwise memory. */
4230 /* We need to compute how many registers are needed so we can
4231 allocate the PARALLEL but before we can do that we need to know
4232 whether there are any packed fields. If there are, int regs are
4233 used regardless of whether there are fp values present. */
4234 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
4236 if (TREE_CODE (field
) == FIELD_DECL
&& DECL_PACKED (field
))
4243 /* Compute how many registers we need. */
4244 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
4246 if (TREE_CODE (field
) == FIELD_DECL
)
4248 HOST_WIDE_INT bitpos
= startbitpos
;
4250 if (DECL_SIZE (field
) != 0
4251 && host_integerp (bit_position (field
), 1))
4252 bitpos
+= int_bit_position (field
);
4254 /* ??? FIXME: else assume zero offset. */
4256 if (TREE_CODE (TREE_TYPE (field
)) == RECORD_TYPE
)
4257 function_arg_record_value_1 (TREE_TYPE (field
), bitpos
, parms
);
4258 else if ((TREE_CODE (TREE_TYPE (field
)) == REAL_TYPE
4259 || (TREE_CODE (TREE_TYPE (field
)) == COMPLEX_TYPE
4260 && (TREE_CODE (TREE_TYPE (TREE_TYPE (field
)))
4266 if (parms
->intoffset
!= -1)
4268 int intslots
, this_slotno
;
4270 intslots
= (bitpos
- parms
->intoffset
+ BITS_PER_WORD
- 1)
4272 this_slotno
= parms
->slotno
+ parms
->intoffset
4275 intslots
= MIN (intslots
, SPARC_INT_ARG_MAX
- this_slotno
);
4276 intslots
= MAX (intslots
, 0);
4277 parms
->nregs
+= intslots
;
4278 parms
->intoffset
= -1;
4281 /* There's no need to check this_slotno < SPARC_FP_ARG MAX.
4282 If it wasn't true we wouldn't be here. */
4284 if (TREE_CODE (TREE_TYPE (field
)) == COMPLEX_TYPE
)
4289 if (parms
->intoffset
== -1)
4290 parms
->intoffset
= bitpos
;
4296 /* A subroutine of function_arg_record_value. Assign the bits of the
4297 structure between parms->intoffset and bitpos to integer registers. */
4300 function_arg_record_value_3 (bitpos
, parms
)
4301 HOST_WIDE_INT bitpos
;
4302 struct function_arg_record_value_parms
*parms
;
4304 enum machine_mode mode
;
4306 unsigned int startbit
, endbit
;
4307 int this_slotno
, intslots
, intoffset
;
4310 if (parms
->intoffset
== -1)
4313 intoffset
= parms
->intoffset
;
4314 parms
->intoffset
= -1;
4316 startbit
= intoffset
& -BITS_PER_WORD
;
4317 endbit
= (bitpos
+ BITS_PER_WORD
- 1) & -BITS_PER_WORD
;
4318 intslots
= (endbit
- startbit
) / BITS_PER_WORD
;
4319 this_slotno
= parms
->slotno
+ intoffset
/ BITS_PER_WORD
;
4321 intslots
= MIN (intslots
, SPARC_INT_ARG_MAX
- this_slotno
);
4325 /* If this is the trailing part of a word, only load that much into
4326 the register. Otherwise load the whole register. Note that in
4327 the latter case we may pick up unwanted bits. It's not a problem
4328 at the moment but may wish to revisit. */
4330 if (intoffset
% BITS_PER_WORD
!= 0)
4331 mode
= mode_for_size (BITS_PER_WORD
- intoffset
% BITS_PER_WORD
,
4336 intoffset
/= BITS_PER_UNIT
;
4339 regno
= parms
->regbase
+ this_slotno
;
4340 reg
= gen_rtx_REG (mode
, regno
);
4341 XVECEXP (parms
->ret
, 0, parms
->nregs
)
4342 = gen_rtx_EXPR_LIST (VOIDmode
, reg
, GEN_INT (intoffset
));
4345 intoffset
= (intoffset
| (UNITS_PER_WORD
-1)) + 1;
4349 while (intslots
> 0);
4352 /* A subroutine of function_arg_record_value. Traverse the structure
4353 recursively and assign bits to floating point registers. Track which
4354 bits in between need integer registers; invoke function_arg_record_value_3
4355 to make that happen. */
4358 function_arg_record_value_2 (type
, startbitpos
, parms
)
4360 HOST_WIDE_INT startbitpos
;
4361 struct function_arg_record_value_parms
*parms
;
4366 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
4368 if (TREE_CODE (field
) == FIELD_DECL
&& DECL_PACKED (field
))
4375 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
4377 if (TREE_CODE (field
) == FIELD_DECL
)
4379 HOST_WIDE_INT bitpos
= startbitpos
;
4381 if (DECL_SIZE (field
) != 0
4382 && host_integerp (bit_position (field
), 1))
4383 bitpos
+= int_bit_position (field
);
4385 /* ??? FIXME: else assume zero offset. */
4387 if (TREE_CODE (TREE_TYPE (field
)) == RECORD_TYPE
)
4388 function_arg_record_value_2 (TREE_TYPE (field
), bitpos
, parms
);
4389 else if ((TREE_CODE (TREE_TYPE (field
)) == REAL_TYPE
4390 || (TREE_CODE (TREE_TYPE (field
)) == COMPLEX_TYPE
4391 && (TREE_CODE (TREE_TYPE (TREE_TYPE (field
)))
4397 int this_slotno
= parms
->slotno
+ bitpos
/ BITS_PER_WORD
;
4399 enum machine_mode mode
= DECL_MODE (field
);
4402 function_arg_record_value_3 (bitpos
, parms
);
4403 regno
= SPARC_FP_ARG_FIRST
+ this_slotno
* 2
4404 + ((mode
== SFmode
|| mode
== SCmode
)
4405 && (bitpos
& 32) != 0);
4408 case SCmode
: mode
= SFmode
; break;
4409 case DCmode
: mode
= DFmode
; break;
4410 case TCmode
: mode
= TFmode
; break;
4413 reg
= gen_rtx_REG (mode
, regno
);
4414 XVECEXP (parms
->ret
, 0, parms
->nregs
)
4415 = gen_rtx_EXPR_LIST (VOIDmode
, reg
,
4416 GEN_INT (bitpos
/ BITS_PER_UNIT
));
4418 if (TREE_CODE (TREE_TYPE (field
)) == COMPLEX_TYPE
)
4420 regno
+= GET_MODE_SIZE (mode
) / 4;
4421 reg
= gen_rtx_REG (mode
, regno
);
4422 XVECEXP (parms
->ret
, 0, parms
->nregs
)
4423 = gen_rtx_EXPR_LIST (VOIDmode
, reg
,
4424 GEN_INT ((bitpos
+ GET_MODE_BITSIZE (mode
))
4431 if (parms
->intoffset
== -1)
4432 parms
->intoffset
= bitpos
;
4438 /* Used by function_arg and function_value to implement the complex
4439 Sparc64 structure calling conventions. */
4442 function_arg_record_value (type
, mode
, slotno
, named
, regbase
)
4444 enum machine_mode mode
;
4445 int slotno
, named
, regbase
;
4447 HOST_WIDE_INT typesize
= int_size_in_bytes (type
);
4448 struct function_arg_record_value_parms parms
;
4451 parms
.ret
= NULL_RTX
;
4452 parms
.slotno
= slotno
;
4453 parms
.named
= named
;
4454 parms
.regbase
= regbase
;
4456 /* Compute how many registers we need. */
4458 parms
.intoffset
= 0;
4459 function_arg_record_value_1 (type
, 0, &parms
);
4461 if (parms
.intoffset
!= -1)
4463 unsigned int startbit
, endbit
;
4464 int intslots
, this_slotno
;
4466 startbit
= parms
.intoffset
& -BITS_PER_WORD
;
4467 endbit
= (typesize
*BITS_PER_UNIT
+ BITS_PER_WORD
- 1) & -BITS_PER_WORD
;
4468 intslots
= (endbit
- startbit
) / BITS_PER_WORD
;
4469 this_slotno
= slotno
+ parms
.intoffset
/ BITS_PER_WORD
;
4471 intslots
= MIN (intslots
, SPARC_INT_ARG_MAX
- this_slotno
);
4472 intslots
= MAX (intslots
, 0);
4474 parms
.nregs
+= intslots
;
4476 nregs
= parms
.nregs
;
4478 /* Allocate the vector and handle some annoying special cases. */
4481 /* ??? Empty structure has no value? Duh? */
4484 /* Though there's nothing really to store, return a word register
4485 anyway so the rest of gcc doesn't go nuts. Returning a PARALLEL
4486 leads to breakage due to the fact that there are zero bytes to
4488 return gen_rtx_REG (mode
, regbase
);
4492 /* ??? C++ has structures with no fields, and yet a size. Give up
4493 for now and pass everything back in integer registers. */
4494 nregs
= (typesize
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
4496 if (nregs
+ slotno
> SPARC_INT_ARG_MAX
)
4497 nregs
= SPARC_INT_ARG_MAX
- slotno
;
4502 parms
.ret
= gen_rtx_PARALLEL (mode
, rtvec_alloc (nregs
));
4504 /* Fill in the entries. */
4506 parms
.intoffset
= 0;
4507 function_arg_record_value_2 (type
, 0, &parms
);
4508 function_arg_record_value_3 (typesize
* BITS_PER_UNIT
, &parms
);
4510 if (parms
.nregs
!= nregs
)
4516 /* Handle the FUNCTION_ARG macro.
4517 Determine where to put an argument to a function.
4518 Value is zero to push the argument on the stack,
4519 or a hard register in which to store the argument.
4521 CUM is a variable of type CUMULATIVE_ARGS which gives info about
4522 the preceding args and about the function being called.
4523 MODE is the argument's machine mode.
4524 TYPE is the data type of the argument (as a tree).
4525 This is null for libcalls where that information may
4527 NAMED is nonzero if this argument is a named parameter
4528 (otherwise it is an extra parameter matching an ellipsis).
4529 INCOMING_P is zero for FUNCTION_ARG, nonzero for FUNCTION_INCOMING_ARG. */
4532 function_arg (cum
, mode
, type
, named
, incoming_p
)
4533 const CUMULATIVE_ARGS
*cum
;
4534 enum machine_mode mode
;
4539 int regbase
= (incoming_p
4540 ? SPARC_INCOMING_INT_ARG_FIRST
4541 : SPARC_OUTGOING_INT_ARG_FIRST
);
4542 int slotno
, regno
, padding
;
4545 slotno
= function_arg_slotno (cum
, mode
, type
, named
, incoming_p
,
4553 reg
= gen_rtx_REG (mode
, regno
);
4557 /* v9 fp args in reg slots beyond the int reg slots get passed in regs
4558 but also have the slot allocated for them.
4559 If no prototype is in scope fp values in register slots get passed
4560 in two places, either fp regs and int regs or fp regs and memory. */
4561 if ((GET_MODE_CLASS (mode
) == MODE_FLOAT
4562 || GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
)
4563 && SPARC_FP_REG_P (regno
))
4565 reg
= gen_rtx_REG (mode
, regno
);
4566 if (cum
->prototype_p
|| cum
->libcall_p
)
4568 /* "* 2" because fp reg numbers are recorded in 4 byte
4571 /* ??? This will cause the value to be passed in the fp reg and
4572 in the stack. When a prototype exists we want to pass the
4573 value in the reg but reserve space on the stack. That's an
4574 optimization, and is deferred [for a bit]. */
4575 if ((regno
- SPARC_FP_ARG_FIRST
) >= SPARC_INT_ARG_MAX
* 2)
4576 return gen_rtx_PARALLEL (mode
,
4578 gen_rtx_EXPR_LIST (VOIDmode
,
4579 NULL_RTX
, const0_rtx
),
4580 gen_rtx_EXPR_LIST (VOIDmode
,
4584 /* ??? It seems that passing back a register even when past
4585 the area declared by REG_PARM_STACK_SPACE will allocate
4586 space appropriately, and will not copy the data onto the
4587 stack, exactly as we desire.
4589 This is due to locate_and_pad_parm being called in
4590 expand_call whenever reg_parm_stack_space > 0, which
4591 while benefical to our example here, would seem to be
4592 in error from what had been intended. Ho hum... -- r~ */
4600 if ((regno
- SPARC_FP_ARG_FIRST
) < SPARC_INT_ARG_MAX
* 2)
4604 /* On incoming, we don't need to know that the value
4605 is passed in %f0 and %i0, and it confuses other parts
4606 causing needless spillage even on the simplest cases. */
4610 intreg
= (SPARC_OUTGOING_INT_ARG_FIRST
4611 + (regno
- SPARC_FP_ARG_FIRST
) / 2);
4613 v0
= gen_rtx_EXPR_LIST (VOIDmode
, reg
, const0_rtx
);
4614 v1
= gen_rtx_EXPR_LIST (VOIDmode
, gen_rtx_REG (mode
, intreg
),
4616 return gen_rtx_PARALLEL (mode
, gen_rtvec (2, v0
, v1
));
4620 v0
= gen_rtx_EXPR_LIST (VOIDmode
, NULL_RTX
, const0_rtx
);
4621 v1
= gen_rtx_EXPR_LIST (VOIDmode
, reg
, const0_rtx
);
4622 return gen_rtx_PARALLEL (mode
, gen_rtvec (2, v0
, v1
));
4626 else if (type
&& TREE_CODE (type
) == RECORD_TYPE
)
4628 /* Structures up to 16 bytes in size are passed in arg slots on the
4629 stack and are promoted to registers where possible. */
4631 if (int_size_in_bytes (type
) > 16)
4632 abort (); /* shouldn't get here */
4634 return function_arg_record_value (type
, mode
, slotno
, named
, regbase
);
4636 else if (type
&& TREE_CODE (type
) == UNION_TYPE
)
4638 enum machine_mode mode
;
4639 int bytes
= int_size_in_bytes (type
);
4644 mode
= mode_for_size (bytes
* BITS_PER_UNIT
, MODE_INT
, 0);
4645 reg
= gen_rtx_REG (mode
, regno
);
4649 /* Scalar or complex int. */
4650 reg
= gen_rtx_REG (mode
, regno
);
4656 /* Handle the FUNCTION_ARG_PARTIAL_NREGS macro.
4657 For an arg passed partly in registers and partly in memory,
4658 this is the number of registers used.
4659 For args passed entirely in registers or entirely in memory, zero.
4661 Any arg that starts in the first 6 regs but won't entirely fit in them
4662 needs partial registers on v8. On v9, structures with integer
4663 values in arg slots 5,6 will be passed in %o5 and SP+176, and complex fp
4664 values that begin in the last fp reg [where "last fp reg" varies with the
4665 mode] will be split between that reg and memory. */
4668 function_arg_partial_nregs (cum
, mode
, type
, named
)
4669 const CUMULATIVE_ARGS
*cum
;
4670 enum machine_mode mode
;
4674 int slotno
, regno
, padding
;
4676 /* We pass 0 for incoming_p here, it doesn't matter. */
4677 slotno
= function_arg_slotno (cum
, mode
, type
, named
, 0, ®no
, &padding
);
4684 if ((slotno
+ (mode
== BLKmode
4685 ? ROUND_ADVANCE (int_size_in_bytes (type
))
4686 : ROUND_ADVANCE (GET_MODE_SIZE (mode
))))
4687 > NPARM_REGS (SImode
))
4688 return NPARM_REGS (SImode
) - slotno
;
4693 if (type
&& AGGREGATE_TYPE_P (type
))
4695 int size
= int_size_in_bytes (type
);
4696 int align
= TYPE_ALIGN (type
);
4699 slotno
+= slotno
& 1;
4700 if (size
> 8 && size
<= 16
4701 && slotno
== SPARC_INT_ARG_MAX
- 1)
4704 else if (GET_MODE_CLASS (mode
) == MODE_COMPLEX_INT
4705 || (GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
4708 if (GET_MODE_ALIGNMENT (mode
) == 128)
4710 slotno
+= slotno
& 1;
4711 if (slotno
== SPARC_INT_ARG_MAX
- 2)
4716 if (slotno
== SPARC_INT_ARG_MAX
- 1)
4720 else if (GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
)
4722 if (GET_MODE_ALIGNMENT (mode
) == 128)
4723 slotno
+= slotno
& 1;
4724 if ((slotno
+ GET_MODE_SIZE (mode
) / UNITS_PER_WORD
)
4732 /* Handle the FUNCTION_ARG_PASS_BY_REFERENCE macro.
4733 !v9: The SPARC ABI stipulates passing struct arguments (of any size) and
4734 quad-precision floats by invisible reference.
4735 v9: Aggregates greater than 16 bytes are passed by reference.
4736 For Pascal, also pass arrays by reference. */
4739 function_arg_pass_by_reference (cum
, mode
, type
, named
)
4740 const CUMULATIVE_ARGS
*cum ATTRIBUTE_UNUSED
;
4741 enum machine_mode mode
;
4743 int named ATTRIBUTE_UNUSED
;
4747 return ((type
&& AGGREGATE_TYPE_P (type
))
4748 || mode
== TFmode
|| mode
== TCmode
);
4752 return ((type
&& TREE_CODE (type
) == ARRAY_TYPE
)
4753 /* Consider complex values as aggregates, so care for TCmode. */
4754 || GET_MODE_SIZE (mode
) > 16
4756 && AGGREGATE_TYPE_P (type
)
4757 && (unsigned HOST_WIDE_INT
) int_size_in_bytes (type
) > 16));
4761 /* Handle the FUNCTION_ARG_ADVANCE macro.
4762 Update the data in CUM to advance over an argument
4763 of mode MODE and data type TYPE.
4764 TYPE is null for libcalls where that information may not be available. */
4767 function_arg_advance (cum
, mode
, type
, named
)
4768 CUMULATIVE_ARGS
*cum
;
4769 enum machine_mode mode
;
4773 int slotno
, regno
, padding
;
4775 /* We pass 0 for incoming_p here, it doesn't matter. */
4776 slotno
= function_arg_slotno (cum
, mode
, type
, named
, 0, ®no
, &padding
);
4778 /* If register required leading padding, add it. */
4780 cum
->words
+= padding
;
4784 cum
->words
+= (mode
!= BLKmode
4785 ? ROUND_ADVANCE (GET_MODE_SIZE (mode
))
4786 : ROUND_ADVANCE (int_size_in_bytes (type
)));
4790 if (type
&& AGGREGATE_TYPE_P (type
))
4792 int size
= int_size_in_bytes (type
);
4796 else if (size
<= 16)
4798 else /* passed by reference */
4801 else if (GET_MODE_CLASS (mode
) == MODE_COMPLEX_INT
)
4805 else if (GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
)
4807 cum
->words
+= GET_MODE_SIZE (mode
) / UNITS_PER_WORD
;
4811 cum
->words
+= (mode
!= BLKmode
4812 ? ROUND_ADVANCE (GET_MODE_SIZE (mode
))
4813 : ROUND_ADVANCE (int_size_in_bytes (type
)));
4818 /* Handle the FUNCTION_ARG_PADDING macro.
4819 For the 64 bit ABI structs are always stored left shifted in their
4823 function_arg_padding (mode
, type
)
4824 enum machine_mode mode
;
4827 if (TARGET_ARCH64
&& type
!= 0 && AGGREGATE_TYPE_P (type
))
4830 /* This is the default definition. */
4831 return (! BYTES_BIG_ENDIAN
4834 ? (type
&& TREE_CODE (TYPE_SIZE (type
)) == INTEGER_CST
4835 && int_size_in_bytes (type
) < (PARM_BOUNDARY
/ BITS_PER_UNIT
))
4836 : GET_MODE_BITSIZE (mode
) < PARM_BOUNDARY
)
4837 ? downward
: upward
));
4840 /* Handle FUNCTION_VALUE, FUNCTION_OUTGOING_VALUE, and LIBCALL_VALUE macros.
4841 For v9, function return values are subject to the same rules as arguments,
4842 except that up to 32-bytes may be returned in registers. */
4845 function_value (type
, mode
, incoming_p
)
4847 enum machine_mode mode
;
4851 int regbase
= (incoming_p
4852 ? SPARC_OUTGOING_INT_ARG_FIRST
4853 : SPARC_INCOMING_INT_ARG_FIRST
);
4855 if (TARGET_ARCH64
&& type
)
4857 if (TREE_CODE (type
) == RECORD_TYPE
)
4859 /* Structures up to 32 bytes in size are passed in registers,
4860 promoted to fp registers where possible. */
4862 if (int_size_in_bytes (type
) > 32)
4863 abort (); /* shouldn't get here */
4865 return function_arg_record_value (type
, mode
, 0, 1, regbase
);
4867 else if (AGGREGATE_TYPE_P (type
))
4869 /* All other aggregate types are passed in an integer register
4870 in a mode corresponding to the size of the type. */
4871 HOST_WIDE_INT bytes
= int_size_in_bytes (type
);
4876 mode
= mode_for_size (bytes
* BITS_PER_UNIT
, MODE_INT
, 0);
4881 && GET_MODE_CLASS (mode
) == MODE_INT
4882 && GET_MODE_SIZE (mode
) < UNITS_PER_WORD
4883 && type
&& ! AGGREGATE_TYPE_P (type
))
4887 regno
= BASE_RETURN_VALUE_REG (mode
);
4889 regno
= BASE_OUTGOING_VALUE_REG (mode
);
4891 return gen_rtx_REG (mode
, regno
);
4894 /* Do what is necessary for `va_start'. We look at the current function
4895 to determine if stdarg or varargs is used and return the address of
4896 the first unnamed parameter. */
4899 sparc_builtin_saveregs ()
4901 int first_reg
= current_function_args_info
.words
;
4905 for (regno
= first_reg
; regno
< NPARM_REGS (word_mode
); regno
++)
4906 emit_move_insn (gen_rtx_MEM (word_mode
,
4907 gen_rtx_PLUS (Pmode
,
4909 GEN_INT (FIRST_PARM_OFFSET (0)
4912 gen_rtx_REG (word_mode
,
4913 BASE_INCOMING_ARG_REG (word_mode
) + regno
));
4915 address
= gen_rtx_PLUS (Pmode
,
4917 GEN_INT (FIRST_PARM_OFFSET (0)
4918 + UNITS_PER_WORD
* first_reg
));
4923 /* Implement `va_start' for varargs and stdarg. */
4926 sparc_va_start (stdarg_p
, valist
, nextarg
)
4927 int stdarg_p ATTRIBUTE_UNUSED
;
4931 nextarg
= expand_builtin_saveregs ();
4932 std_expand_builtin_va_start (1, valist
, nextarg
);
4935 /* Implement `va_arg'. */
4938 sparc_va_arg (valist
, type
)
4941 HOST_WIDE_INT size
, rsize
, align
;
4946 /* Round up sizeof(type) to a word. */
4947 size
= int_size_in_bytes (type
);
4948 rsize
= (size
+ UNITS_PER_WORD
- 1) & -UNITS_PER_WORD
;
4953 if (TYPE_ALIGN (type
) >= 2 * (unsigned) BITS_PER_WORD
)
4954 align
= 2 * UNITS_PER_WORD
;
4956 if (AGGREGATE_TYPE_P (type
))
4958 if ((unsigned HOST_WIDE_INT
) size
> 16)
4961 size
= rsize
= UNITS_PER_WORD
;
4963 /* SPARC v9 ABI states that structures up to 8 bytes in size are
4964 given one 8 byte slot. */
4966 size
= rsize
= UNITS_PER_WORD
;
4973 if (AGGREGATE_TYPE_P (type
)
4974 || TYPE_MODE (type
) == TFmode
4975 || TYPE_MODE (type
) == TCmode
)
4978 size
= rsize
= UNITS_PER_WORD
;
4985 incr
= fold (build (PLUS_EXPR
, ptr_type_node
, incr
,
4986 build_int_2 (align
- 1, 0)));
4987 incr
= fold (build (BIT_AND_EXPR
, ptr_type_node
, incr
,
4988 build_int_2 (-align
, -1)));
4991 addr
= incr
= save_expr (incr
);
4992 if (BYTES_BIG_ENDIAN
&& size
< rsize
)
4994 addr
= fold (build (PLUS_EXPR
, ptr_type_node
, incr
,
4995 build_int_2 (rsize
- size
, 0)));
4997 incr
= fold (build (PLUS_EXPR
, ptr_type_node
, incr
,
4998 build_int_2 (rsize
, 0)));
5000 incr
= build (MODIFY_EXPR
, ptr_type_node
, valist
, incr
);
5001 TREE_SIDE_EFFECTS (incr
) = 1;
5002 expand_expr (incr
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
5004 addr_rtx
= expand_expr (addr
, NULL
, Pmode
, EXPAND_NORMAL
);
5006 /* If the address isn't aligned properly for the type,
5007 we may need to copy to a temporary.
5008 FIXME: This is inefficient. Usually we can do this
5011 && TYPE_ALIGN (type
) > BITS_PER_WORD
5014 /* FIXME: We really need to specify that the temporary is live
5015 for the whole function because expand_builtin_va_arg wants
5016 the alias set to be get_varargs_alias_set (), but in this
5017 case the alias set is that for TYPE and if the memory gets
5018 reused it will be reused with alias set TYPE. */
5019 rtx tmp
= assign_temp (type
, 0, 1, 0);
5022 addr_rtx
= force_reg (Pmode
, addr_rtx
);
5023 addr_rtx
= gen_rtx_MEM (BLKmode
, addr_rtx
);
5024 set_mem_alias_set (addr_rtx
, get_varargs_alias_set ());
5025 set_mem_align (addr_rtx
, BITS_PER_WORD
);
5026 tmp
= shallow_copy_rtx (tmp
);
5027 PUT_MODE (tmp
, BLKmode
);
5028 set_mem_alias_set (tmp
, 0);
5030 dest_addr
= emit_block_move (tmp
, addr_rtx
, GEN_INT (rsize
));
5031 if (dest_addr
!= NULL_RTX
)
5032 addr_rtx
= dest_addr
;
5034 addr_rtx
= XCEXP (tmp
, 0, MEM
);
5039 addr_rtx
= force_reg (Pmode
, addr_rtx
);
5040 addr_rtx
= gen_rtx_MEM (Pmode
, addr_rtx
);
5041 set_mem_alias_set (addr_rtx
, get_varargs_alias_set ());
5047 /* Return the string to output a conditional branch to LABEL, which is
5048 the operand number of the label. OP is the conditional expression.
5049 XEXP (OP, 0) is assumed to be a condition code register (integer or
5050 floating point) and its mode specifies what kind of comparison we made.
5052 REVERSED is non-zero if we should reverse the sense of the comparison.
5054 ANNUL is non-zero if we should generate an annulling branch.
5056 NOOP is non-zero if we have to follow this branch by a noop.
5058 INSN, if set, is the insn. */
5061 output_cbranch (op
, dest
, label
, reversed
, annul
, noop
, insn
)
5064 int reversed
, annul
, noop
;
5067 static char string
[50];
5068 enum rtx_code code
= GET_CODE (op
);
5069 rtx cc_reg
= XEXP (op
, 0);
5070 enum machine_mode mode
= GET_MODE (cc_reg
);
5071 const char *labelno
, *branch
;
5072 int spaces
= 8, far
;
5075 /* v9 branches are limited to +-1MB. If it is too far away,
5088 fbne,a,pn %fcc2, .LC29
5096 far
= get_attr_length (insn
) >= 3;
5099 /* Reversal of FP compares takes care -- an ordered compare
5100 becomes an unordered compare and vice versa. */
5101 if (mode
== CCFPmode
|| mode
== CCFPEmode
)
5102 code
= reverse_condition_maybe_unordered (code
);
5104 code
= reverse_condition (code
);
5107 /* Start by writing the branch condition. */
5108 if (mode
== CCFPmode
|| mode
== CCFPEmode
)
5159 /* ??? !v9: FP branches cannot be preceded by another floating point
5160 insn. Because there is currently no concept of pre-delay slots,
5161 we can fix this only by always emitting a nop before a floating
5166 strcpy (string
, "nop\n\t");
5167 strcat (string
, branch
);
5180 if (mode
== CC_NOOVmode
|| mode
== CCX_NOOVmode
)
5192 if (mode
== CC_NOOVmode
|| mode
== CCX_NOOVmode
)
5213 strcpy (string
, branch
);
5215 spaces
-= strlen (branch
);
5216 p
= strchr (string
, '\0');
5218 /* Now add the annulling, the label, and a possible noop. */
5233 if (! far
&& insn
&& INSN_ADDRESSES_SET_P ())
5235 int delta
= (INSN_ADDRESSES (INSN_UID (dest
))
5236 - INSN_ADDRESSES (INSN_UID (insn
)));
5237 /* Leave some instructions for "slop". */
5238 if (delta
< -260000 || delta
>= 260000)
5242 if (mode
== CCFPmode
|| mode
== CCFPEmode
)
5244 static char v9_fcc_labelno
[] = "%%fccX, ";
5245 /* Set the char indicating the number of the fcc reg to use. */
5246 v9_fcc_labelno
[5] = REGNO (cc_reg
) - SPARC_FIRST_V9_FCC_REG
+ '0';
5247 labelno
= v9_fcc_labelno
;
5250 if (REGNO (cc_reg
) == SPARC_FCC_REG
)
5256 else if (mode
== CCXmode
|| mode
== CCX_NOOVmode
)
5258 labelno
= "%%xcc, ";
5264 labelno
= "%%icc, ";
5269 if (*labelno
&& insn
&& (note
= find_reg_note (insn
, REG_BR_PROB
, NULL_RTX
)))
5272 ((INTVAL (XEXP (note
, 0)) >= REG_BR_PROB_BASE
/ 2) ^ far
)
5282 strcpy (p
, labelno
);
5283 p
= strchr (p
, '\0');
5286 strcpy (p
, ".+12\n\tnop\n\tb\t");
5293 /* Set the char indicating the number of the operand containing the
5298 strcpy (p
, "\n\tnop");
5303 /* Emit a library call comparison between floating point X and Y.
5304 COMPARISON is the rtl operator to compare with (EQ, NE, GT, etc.).
5305 TARGET_ARCH64 uses _Qp_* functions, which use pointers to TFmode
5306 values as arguments instead of the TFmode registers themselves,
5307 that's why we cannot call emit_float_lib_cmp. */
5309 sparc_emit_float_lib_cmp (x
, y
, comparison
)
5311 enum rtx_code comparison
;
5314 rtx slot0
, slot1
, result
, tem
, tem2
;
5315 enum machine_mode mode
;
5320 qpfunc
= (TARGET_ARCH64
) ? "_Qp_feq" : "_Q_feq";
5324 qpfunc
= (TARGET_ARCH64
) ? "_Qp_fne" : "_Q_fne";
5328 qpfunc
= (TARGET_ARCH64
) ? "_Qp_fgt" : "_Q_fgt";
5332 qpfunc
= (TARGET_ARCH64
) ? "_Qp_fge" : "_Q_fge";
5336 qpfunc
= (TARGET_ARCH64
) ? "_Qp_flt" : "_Q_flt";
5340 qpfunc
= (TARGET_ARCH64
) ? "_Qp_fle" : "_Q_fle";
5351 qpfunc
= (TARGET_ARCH64
) ? "_Qp_cmp" : "_Q_cmp";
5361 if (GET_CODE (x
) != MEM
)
5363 slot0
= assign_stack_temp (TFmode
, GET_MODE_SIZE(TFmode
), 0);
5364 emit_insn (gen_rtx_SET (VOIDmode
, slot0
, x
));
5369 if (GET_CODE (y
) != MEM
)
5371 slot1
= assign_stack_temp (TFmode
, GET_MODE_SIZE(TFmode
), 0);
5372 emit_insn (gen_rtx_SET (VOIDmode
, slot1
, y
));
5377 emit_library_call (gen_rtx_SYMBOL_REF (Pmode
, qpfunc
), 1,
5379 XEXP (slot0
, 0), Pmode
,
5380 XEXP (slot1
, 0), Pmode
);
5386 emit_library_call (gen_rtx_SYMBOL_REF (Pmode
, qpfunc
), 1,
5388 x
, TFmode
, y
, TFmode
);
5394 /* Immediately move the result of the libcall into a pseudo
5395 register so reload doesn't clobber the value if it needs
5396 the return register for a spill reg. */
5397 result
= gen_reg_rtx (mode
);
5398 emit_move_insn (result
, hard_libcall_value (mode
));
5403 emit_cmp_insn (result
, const0_rtx
, NE
, NULL_RTX
, mode
, 0);
5407 emit_cmp_insn (result
, GEN_INT(3), comparison
== UNORDERED
? EQ
: NE
,
5412 emit_cmp_insn (result
, const1_rtx
,
5413 comparison
== UNGT
? GT
: NE
, NULL_RTX
, mode
, 0);
5416 emit_cmp_insn (result
, const2_rtx
, NE
, NULL_RTX
, mode
, 0);
5419 tem
= gen_reg_rtx (mode
);
5421 emit_insn (gen_andsi3 (tem
, result
, const1_rtx
));
5423 emit_insn (gen_anddi3 (tem
, result
, const1_rtx
));
5424 emit_cmp_insn (tem
, const0_rtx
, NE
, NULL_RTX
, mode
, 0);
5428 tem
= gen_reg_rtx (mode
);
5430 emit_insn (gen_addsi3 (tem
, result
, const1_rtx
));
5432 emit_insn (gen_adddi3 (tem
, result
, const1_rtx
));
5433 tem2
= gen_reg_rtx (mode
);
5435 emit_insn (gen_andsi3 (tem2
, tem
, const2_rtx
));
5437 emit_insn (gen_anddi3 (tem2
, tem
, const2_rtx
));
5438 emit_cmp_insn (tem2
, const0_rtx
, comparison
== UNEQ
? EQ
: NE
,
5444 /* Generate an unsigned DImode to FP conversion. This is the same code
5445 optabs would emit if we didn't have TFmode patterns. */
5448 sparc_emit_floatunsdi (operands
)
5451 rtx neglab
, donelab
, i0
, i1
, f0
, in
, out
;
5452 enum machine_mode mode
;
5455 in
= force_reg (DImode
, operands
[1]);
5456 mode
= GET_MODE (out
);
5457 neglab
= gen_label_rtx ();
5458 donelab
= gen_label_rtx ();
5459 i0
= gen_reg_rtx (DImode
);
5460 i1
= gen_reg_rtx (DImode
);
5461 f0
= gen_reg_rtx (mode
);
5463 emit_cmp_and_jump_insns (in
, const0_rtx
, LT
, const0_rtx
, DImode
, 0, neglab
);
5465 emit_insn (gen_rtx_SET (VOIDmode
, out
, gen_rtx_FLOAT (mode
, in
)));
5466 emit_jump_insn (gen_jump (donelab
));
5469 emit_label (neglab
);
5471 emit_insn (gen_lshrdi3 (i0
, in
, const1_rtx
));
5472 emit_insn (gen_anddi3 (i1
, in
, const1_rtx
));
5473 emit_insn (gen_iordi3 (i0
, i0
, i1
));
5474 emit_insn (gen_rtx_SET (VOIDmode
, f0
, gen_rtx_FLOAT (mode
, i0
)));
5475 emit_insn (gen_rtx_SET (VOIDmode
, out
, gen_rtx_PLUS (mode
, f0
, f0
)));
5477 emit_label (donelab
);
5480 /* Return the string to output a conditional branch to LABEL, testing
5481 register REG. LABEL is the operand number of the label; REG is the
5482 operand number of the reg. OP is the conditional expression. The mode
5483 of REG says what kind of comparison we made.
5485 REVERSED is non-zero if we should reverse the sense of the comparison.
5487 ANNUL is non-zero if we should generate an annulling branch.
5489 NOOP is non-zero if we have to follow this branch by a noop. */
5492 output_v9branch (op
, dest
, reg
, label
, reversed
, annul
, noop
, insn
)
5495 int reversed
, annul
, noop
;
5498 static char string
[50];
5499 enum rtx_code code
= GET_CODE (op
);
5500 enum machine_mode mode
= GET_MODE (XEXP (op
, 0));
5505 /* branch on register are limited to +-128KB. If it is too far away,
5518 brgez,a,pn %o1, .LC29
5524 ba,pt %xcc, .LC29 */
5526 far
= get_attr_length (insn
) >= 3;
5528 /* If not floating-point or if EQ or NE, we can just reverse the code. */
5530 code
= reverse_condition (code
);
5532 /* Only 64 bit versions of these instructions exist. */
5536 /* Start by writing the branch condition. */
5541 strcpy (string
, "brnz");
5545 strcpy (string
, "brz");
5549 strcpy (string
, "brgez");
5553 strcpy (string
, "brlz");
5557 strcpy (string
, "brlez");
5561 strcpy (string
, "brgz");
5568 p
= strchr (string
, '\0');
5570 /* Now add the annulling, reg, label, and nop. */
5577 if (insn
&& (note
= find_reg_note (insn
, REG_BR_PROB
, NULL_RTX
)))
5580 ((INTVAL (XEXP (note
, 0)) >= REG_BR_PROB_BASE
/ 2) ^ far
)
5585 *p
= p
< string
+ 8 ? '\t' : ' ';
5593 int veryfar
= 1, delta
;
5595 if (INSN_ADDRESSES_SET_P ())
5597 delta
= (INSN_ADDRESSES (INSN_UID (dest
))
5598 - INSN_ADDRESSES (INSN_UID (insn
)));
5599 /* Leave some instructions for "slop". */
5600 if (delta
>= -260000 && delta
< 260000)
5604 strcpy (p
, ".+12\n\tnop\n\t");
5615 strcpy (p
, "ba,pt\t%%xcc, ");
5625 strcpy (p
, "\n\tnop");
5630 /* Return 1, if any of the registers of the instruction are %l[0-7] or %o[0-7].
5631 Such instructions cannot be used in the delay slot of return insn on v9.
5632 If TEST is 0, also rename all %i[0-7] registers to their %o[0-7] counterparts.
5636 epilogue_renumber (where
, test
)
5637 register rtx
*where
;
5640 register const char *fmt
;
5642 register enum rtx_code code
;
5647 code
= GET_CODE (*where
);
5652 if (REGNO (*where
) >= 8 && REGNO (*where
) < 24) /* oX or lX */
5654 if (! test
&& REGNO (*where
) >= 24 && REGNO (*where
) < 32)
5655 *where
= gen_rtx (REG
, GET_MODE (*where
), OUTGOING_REGNO (REGNO(*where
)));
5663 /* Do not replace the frame pointer with the stack pointer because
5664 it can cause the delayed instruction to load below the stack.
5665 This occurs when instructions like:
5667 (set (reg/i:SI 24 %i0)
5668 (mem/f:SI (plus:SI (reg/f:SI 30 %fp)
5669 (const_int -20 [0xffffffec])) 0))
5671 are in the return delayed slot. */
5673 if (GET_CODE (XEXP (*where
, 0)) == REG
5674 && REGNO (XEXP (*where
, 0)) == HARD_FRAME_POINTER_REGNUM
5675 && (GET_CODE (XEXP (*where
, 1)) != CONST_INT
5676 || INTVAL (XEXP (*where
, 1)) < SPARC_STACK_BIAS
))
5681 if (SPARC_STACK_BIAS
5682 && GET_CODE (XEXP (*where
, 0)) == REG
5683 && REGNO (XEXP (*where
, 0)) == HARD_FRAME_POINTER_REGNUM
)
5691 fmt
= GET_RTX_FORMAT (code
);
5693 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
5698 for (j
= XVECLEN (*where
, i
) - 1; j
>= 0; j
--)
5699 if (epilogue_renumber (&(XVECEXP (*where
, i
, j
)), test
))
5702 else if (fmt
[i
] == 'e'
5703 && epilogue_renumber (&(XEXP (*where
, i
)), test
))
5709 /* Leaf functions and non-leaf functions have different needs. */
5712 reg_leaf_alloc_order
[] = REG_LEAF_ALLOC_ORDER
;
5715 reg_nonleaf_alloc_order
[] = REG_ALLOC_ORDER
;
5717 static const int *const reg_alloc_orders
[] = {
5718 reg_leaf_alloc_order
,
5719 reg_nonleaf_alloc_order
};
5722 order_regs_for_local_alloc ()
5724 static int last_order_nonleaf
= 1;
5726 if (regs_ever_live
[15] != last_order_nonleaf
)
5728 last_order_nonleaf
= !last_order_nonleaf
;
5729 memcpy ((char *) reg_alloc_order
,
5730 (const char *) reg_alloc_orders
[last_order_nonleaf
],
5731 FIRST_PSEUDO_REGISTER
* sizeof (int));
5735 /* Return 1 if REG and MEM are legitimate enough to allow the various
5736 mem<-->reg splits to be run. */
5739 sparc_splitdi_legitimate (reg
, mem
)
5743 /* Punt if we are here by mistake. */
5744 if (! reload_completed
)
5747 /* We must have an offsettable memory reference. */
5748 if (! offsettable_memref_p (mem
))
5751 /* If we have legitimate args for ldd/std, we do not want
5752 the split to happen. */
5753 if ((REGNO (reg
) % 2) == 0
5754 && mem_min_alignment (mem
, 8))
5761 /* Return 1 if x and y are some kind of REG and they refer to
5762 different hard registers. This test is guarenteed to be
5763 run after reload. */
5766 sparc_absnegfloat_split_legitimate (x
, y
)
5769 if (GET_CODE (x
) != REG
)
5771 if (GET_CODE (y
) != REG
)
5773 if (REGNO (x
) == REGNO (y
))
5778 /* Return 1 if REGNO (reg1) is even and REGNO (reg1) == REGNO (reg2) - 1.
5779 This makes them candidates for using ldd and std insns.
5781 Note reg1 and reg2 *must* be hard registers. */
5784 registers_ok_for_ldd_peep (reg1
, reg2
)
5787 /* We might have been passed a SUBREG. */
5788 if (GET_CODE (reg1
) != REG
|| GET_CODE (reg2
) != REG
)
5791 if (REGNO (reg1
) % 2 != 0)
5794 /* Integer ldd is deprecated in SPARC V9 */
5795 if (TARGET_V9
&& REGNO (reg1
) < 32)
5798 return (REGNO (reg1
) == REGNO (reg2
) - 1);
5801 /* Return 1 if the addresses in mem1 and mem2 are suitable for use in
5804 This can only happen when addr1 and addr2, the addresses in mem1
5805 and mem2, are consecutive memory locations (addr1 + 4 == addr2).
5806 addr1 must also be aligned on a 64-bit boundary.
5808 Also iff dependent_reg_rtx is not null it should not be used to
5809 compute the address for mem1, i.e. we cannot optimize a sequence
5821 But, note that the transformation from:
5826 is perfectly fine. Thus, the peephole2 patterns always pass us
5827 the destination register of the first load, never the second one.
5829 For stores we don't have a similar problem, so dependent_reg_rtx is
5833 mems_ok_for_ldd_peep (mem1
, mem2
, dependent_reg_rtx
)
5834 rtx mem1
, mem2
, dependent_reg_rtx
;
5840 /* The mems cannot be volatile. */
5841 if (MEM_VOLATILE_P (mem1
) || MEM_VOLATILE_P (mem2
))
5844 /* MEM1 should be aligned on a 64-bit boundary. */
5845 if (MEM_ALIGN (mem1
) < 64)
5848 addr1
= XEXP (mem1
, 0);
5849 addr2
= XEXP (mem2
, 0);
5851 /* Extract a register number and offset (if used) from the first addr. */
5852 if (GET_CODE (addr1
) == PLUS
)
5854 /* If not a REG, return zero. */
5855 if (GET_CODE (XEXP (addr1
, 0)) != REG
)
5859 reg1
= REGNO (XEXP (addr1
, 0));
5860 /* The offset must be constant! */
5861 if (GET_CODE (XEXP (addr1
, 1)) != CONST_INT
)
5863 offset1
= INTVAL (XEXP (addr1
, 1));
5866 else if (GET_CODE (addr1
) != REG
)
5870 reg1
= REGNO (addr1
);
5871 /* This was a simple (mem (reg)) expression. Offset is 0. */
5875 /* Make sure the second address is a (mem (plus (reg) (const_int). */
5876 if (GET_CODE (addr2
) != PLUS
)
5879 if (GET_CODE (XEXP (addr2
, 0)) != REG
5880 || GET_CODE (XEXP (addr2
, 1)) != CONST_INT
)
5883 if (reg1
!= REGNO (XEXP (addr2
, 0)))
5886 if (dependent_reg_rtx
!= NULL_RTX
&& reg1
== REGNO (dependent_reg_rtx
))
5889 /* The first offset must be evenly divisible by 8 to ensure the
5890 address is 64 bit aligned. */
5891 if (offset1
% 8 != 0)
5894 /* The offset for the second addr must be 4 more than the first addr. */
5895 if (INTVAL (XEXP (addr2
, 1)) != offset1
+ 4)
5898 /* All the tests passed. addr1 and addr2 are valid for ldd and std
5903 /* Return 1 if reg is a pseudo, or is the first register in
5904 a hard register pair. This makes it a candidate for use in
5905 ldd and std insns. */
5908 register_ok_for_ldd (reg
)
5911 /* We might have been passed a SUBREG. */
5912 if (GET_CODE (reg
) != REG
)
5915 if (REGNO (reg
) < FIRST_PSEUDO_REGISTER
)
5916 return (REGNO (reg
) % 2 == 0);
5921 /* Print operand X (an rtx) in assembler syntax to file FILE.
5922 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
5923 For `%' followed by punctuation, CODE is the punctuation and X is null. */
5926 print_operand (file
, x
, code
)
5934 /* Output a 'nop' if there's nothing for the delay slot. */
5935 if (dbr_sequence_length () == 0)
5936 fputs ("\n\t nop", file
);
5939 /* Output an annul flag if there's nothing for the delay slot and we
5940 are optimizing. This is always used with '(' below. */
5941 /* Sun OS 4.1.1 dbx can't handle an annulled unconditional branch;
5942 this is a dbx bug. So, we only do this when optimizing. */
5943 /* On UltraSPARC, a branch in a delay slot causes a pipeline flush.
5944 Always emit a nop in case the next instruction is a branch. */
5945 if (dbr_sequence_length () == 0
5946 && (optimize
&& (int)sparc_cpu
< PROCESSOR_V9
))
5950 /* Output a 'nop' if there's nothing for the delay slot and we are
5951 not optimizing. This is always used with '*' above. */
5952 if (dbr_sequence_length () == 0
5953 && ! (optimize
&& (int)sparc_cpu
< PROCESSOR_V9
))
5954 fputs ("\n\t nop", file
);
5957 /* Output the Embedded Medium/Anywhere code model base register. */
5958 fputs (EMBMEDANY_BASE_REG
, file
);
5961 /* Print out what we are using as the frame pointer. This might
5962 be %fp, or might be %sp+offset. */
5963 /* ??? What if offset is too big? Perhaps the caller knows it isn't? */
5964 fprintf (file
, "%s+%d", frame_base_name
, frame_base_offset
);
5967 /* Adjust the operand to take into account a RESTORE operation. */
5968 if (GET_CODE (x
) == CONST_INT
)
5970 else if (GET_CODE (x
) != REG
)
5971 output_operand_lossage ("invalid %%Y operand");
5972 else if (REGNO (x
) < 8)
5973 fputs (reg_names
[REGNO (x
)], file
);
5974 else if (REGNO (x
) >= 24 && REGNO (x
) < 32)
5975 fputs (reg_names
[REGNO (x
)-16], file
);
5977 output_operand_lossage ("invalid %%Y operand");
5980 /* Print out the low order register name of a register pair. */
5981 if (WORDS_BIG_ENDIAN
)
5982 fputs (reg_names
[REGNO (x
)+1], file
);
5984 fputs (reg_names
[REGNO (x
)], file
);
5987 /* Print out the high order register name of a register pair. */
5988 if (WORDS_BIG_ENDIAN
)
5989 fputs (reg_names
[REGNO (x
)], file
);
5991 fputs (reg_names
[REGNO (x
)+1], file
);
5994 /* Print out the second register name of a register pair or quad.
5995 I.e., R (%o0) => %o1. */
5996 fputs (reg_names
[REGNO (x
)+1], file
);
5999 /* Print out the third register name of a register quad.
6000 I.e., S (%o0) => %o2. */
6001 fputs (reg_names
[REGNO (x
)+2], file
);
6004 /* Print out the fourth register name of a register quad.
6005 I.e., T (%o0) => %o3. */
6006 fputs (reg_names
[REGNO (x
)+3], file
);
6009 /* Print a condition code register. */
6010 if (REGNO (x
) == SPARC_ICC_REG
)
6012 /* We don't handle CC[X]_NOOVmode because they're not supposed
6014 if (GET_MODE (x
) == CCmode
)
6015 fputs ("%icc", file
);
6016 else if (GET_MODE (x
) == CCXmode
)
6017 fputs ("%xcc", file
);
6022 /* %fccN register */
6023 fputs (reg_names
[REGNO (x
)], file
);
6026 /* Print the operand's address only. */
6027 output_address (XEXP (x
, 0));
6030 /* In this case we need a register. Use %g0 if the
6031 operand is const0_rtx. */
6033 || (GET_MODE (x
) != VOIDmode
&& x
== CONST0_RTX (GET_MODE (x
))))
6035 fputs ("%g0", file
);
6042 switch (GET_CODE (x
))
6044 case IOR
: fputs ("or", file
); break;
6045 case AND
: fputs ("and", file
); break;
6046 case XOR
: fputs ("xor", file
); break;
6047 default: output_operand_lossage ("invalid %%A operand");
6052 switch (GET_CODE (x
))
6054 case IOR
: fputs ("orn", file
); break;
6055 case AND
: fputs ("andn", file
); break;
6056 case XOR
: fputs ("xnor", file
); break;
6057 default: output_operand_lossage ("invalid %%B operand");
6061 /* These are used by the conditional move instructions. */
6065 enum rtx_code rc
= GET_CODE (x
);
6069 enum machine_mode mode
= GET_MODE (XEXP (x
, 0));
6070 if (mode
== CCFPmode
|| mode
== CCFPEmode
)
6071 rc
= reverse_condition_maybe_unordered (GET_CODE (x
));
6073 rc
= reverse_condition (GET_CODE (x
));
6077 case NE
: fputs ("ne", file
); break;
6078 case EQ
: fputs ("e", file
); break;
6079 case GE
: fputs ("ge", file
); break;
6080 case GT
: fputs ("g", file
); break;
6081 case LE
: fputs ("le", file
); break;
6082 case LT
: fputs ("l", file
); break;
6083 case GEU
: fputs ("geu", file
); break;
6084 case GTU
: fputs ("gu", file
); break;
6085 case LEU
: fputs ("leu", file
); break;
6086 case LTU
: fputs ("lu", file
); break;
6087 case LTGT
: fputs ("lg", file
); break;
6088 case UNORDERED
: fputs ("u", file
); break;
6089 case ORDERED
: fputs ("o", file
); break;
6090 case UNLT
: fputs ("ul", file
); break;
6091 case UNLE
: fputs ("ule", file
); break;
6092 case UNGT
: fputs ("ug", file
); break;
6093 case UNGE
: fputs ("uge", file
); break;
6094 case UNEQ
: fputs ("ue", file
); break;
6095 default: output_operand_lossage (code
== 'c'
6096 ? "invalid %%c operand"
6097 : "invalid %%C operand");
6102 /* These are used by the movr instruction pattern. */
6106 enum rtx_code rc
= (code
== 'd'
6107 ? reverse_condition (GET_CODE (x
))
6111 case NE
: fputs ("ne", file
); break;
6112 case EQ
: fputs ("e", file
); break;
6113 case GE
: fputs ("gez", file
); break;
6114 case LT
: fputs ("lz", file
); break;
6115 case LE
: fputs ("lez", file
); break;
6116 case GT
: fputs ("gz", file
); break;
6117 default: output_operand_lossage (code
== 'd'
6118 ? "invalid %%d operand"
6119 : "invalid %%D operand");
6126 /* Print a sign-extended character. */
6127 int i
= trunc_int_for_mode (INTVAL (x
), QImode
);
6128 fprintf (file
, "%d", i
);
6133 /* Operand must be a MEM; write its address. */
6134 if (GET_CODE (x
) != MEM
)
6135 output_operand_lossage ("invalid %%f operand");
6136 output_address (XEXP (x
, 0));
6140 /* Do nothing special. */
6144 /* Undocumented flag. */
6145 output_operand_lossage ("invalid operand output code");
6148 if (GET_CODE (x
) == REG
)
6149 fputs (reg_names
[REGNO (x
)], file
);
6150 else if (GET_CODE (x
) == MEM
)
6153 /* Poor Sun assembler doesn't understand absolute addressing. */
6154 if (CONSTANT_P (XEXP (x
, 0)))
6155 fputs ("%g0+", file
);
6156 output_address (XEXP (x
, 0));
6159 else if (GET_CODE (x
) == HIGH
)
6161 fputs ("%hi(", file
);
6162 output_addr_const (file
, XEXP (x
, 0));
6165 else if (GET_CODE (x
) == LO_SUM
)
6167 print_operand (file
, XEXP (x
, 0), 0);
6168 if (TARGET_CM_MEDMID
)
6169 fputs ("+%l44(", file
);
6171 fputs ("+%lo(", file
);
6172 output_addr_const (file
, XEXP (x
, 1));
6175 else if (GET_CODE (x
) == CONST_DOUBLE
6176 && (GET_MODE (x
) == VOIDmode
6177 || GET_MODE_CLASS (GET_MODE (x
)) == MODE_INT
))
6179 if (CONST_DOUBLE_HIGH (x
) == 0)
6180 fprintf (file
, "%u", (unsigned int) CONST_DOUBLE_LOW (x
));
6181 else if (CONST_DOUBLE_HIGH (x
) == -1
6182 && CONST_DOUBLE_LOW (x
) < 0)
6183 fprintf (file
, "%d", (int) CONST_DOUBLE_LOW (x
));
6185 output_operand_lossage ("long long constant not a valid immediate operand");
6187 else if (GET_CODE (x
) == CONST_DOUBLE
)
6188 output_operand_lossage ("floating point constant not a valid immediate operand");
6189 else { output_addr_const (file
, x
); }
6192 /* Target hook for assembling integer objects. The sparc version has
6193 special handling for aligned DI-mode objects. */
6196 sparc_assemble_integer (x
, size
, aligned_p
)
6201 /* ??? We only output .xword's for symbols and only then in environments
6202 where the assembler can handle them. */
6203 if (aligned_p
&& size
== 8
6204 && (GET_CODE (x
) != CONST_INT
&& GET_CODE (x
) != CONST_DOUBLE
))
6208 assemble_integer_with_op ("\t.xword\t", x
);
6213 assemble_aligned_integer (4, const0_rtx
);
6214 assemble_aligned_integer (4, x
);
6218 return default_assemble_integer (x
, size
, aligned_p
);
6221 /* Return the value of a code used in the .proc pseudo-op that says
6222 what kind of result this function returns. For non-C types, we pick
6223 the closest C type. */
6225 #ifndef SHORT_TYPE_SIZE
6226 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
6229 #ifndef INT_TYPE_SIZE
6230 #define INT_TYPE_SIZE BITS_PER_WORD
6233 #ifndef LONG_TYPE_SIZE
6234 #define LONG_TYPE_SIZE BITS_PER_WORD
6237 #ifndef LONG_LONG_TYPE_SIZE
6238 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
6241 #ifndef FLOAT_TYPE_SIZE
6242 #define FLOAT_TYPE_SIZE BITS_PER_WORD
6245 #ifndef DOUBLE_TYPE_SIZE
6246 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
6249 #ifndef LONG_DOUBLE_TYPE_SIZE
6250 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
6254 sparc_type_code (type
)
6257 register unsigned long qualifiers
= 0;
6258 register unsigned shift
;
6260 /* Only the first 30 bits of the qualifier are valid. We must refrain from
6261 setting more, since some assemblers will give an error for this. Also,
6262 we must be careful to avoid shifts of 32 bits or more to avoid getting
6263 unpredictable results. */
6265 for (shift
= 6; shift
< 30; shift
+= 2, type
= TREE_TYPE (type
))
6267 switch (TREE_CODE (type
))
6273 qualifiers
|= (3 << shift
);
6278 qualifiers
|= (2 << shift
);
6282 case REFERENCE_TYPE
:
6284 qualifiers
|= (1 << shift
);
6288 return (qualifiers
| 8);
6291 case QUAL_UNION_TYPE
:
6292 return (qualifiers
| 9);
6295 return (qualifiers
| 10);
6298 return (qualifiers
| 16);
6301 /* If this is a range type, consider it to be the underlying
6303 if (TREE_TYPE (type
) != 0)
6306 /* Carefully distinguish all the standard types of C,
6307 without messing up if the language is not C. We do this by
6308 testing TYPE_PRECISION and TREE_UNSIGNED. The old code used to
6309 look at both the names and the above fields, but that's redundant.
6310 Any type whose size is between two C types will be considered
6311 to be the wider of the two types. Also, we do not have a
6312 special code to use for "long long", so anything wider than
6313 long is treated the same. Note that we can't distinguish
6314 between "int" and "long" in this code if they are the same
6315 size, but that's fine, since neither can the assembler. */
6317 if (TYPE_PRECISION (type
) <= CHAR_TYPE_SIZE
)
6318 return (qualifiers
| (TREE_UNSIGNED (type
) ? 12 : 2));
6320 else if (TYPE_PRECISION (type
) <= SHORT_TYPE_SIZE
)
6321 return (qualifiers
| (TREE_UNSIGNED (type
) ? 13 : 3));
6323 else if (TYPE_PRECISION (type
) <= INT_TYPE_SIZE
)
6324 return (qualifiers
| (TREE_UNSIGNED (type
) ? 14 : 4));
6327 return (qualifiers
| (TREE_UNSIGNED (type
) ? 15 : 5));
6330 /* If this is a range type, consider it to be the underlying
6332 if (TREE_TYPE (type
) != 0)
6335 /* Carefully distinguish all the standard types of C,
6336 without messing up if the language is not C. */
6338 if (TYPE_PRECISION (type
) == FLOAT_TYPE_SIZE
)
6339 return (qualifiers
| 6);
6342 return (qualifiers
| 7);
6344 case COMPLEX_TYPE
: /* GNU Fortran COMPLEX type. */
6345 /* ??? We need to distinguish between double and float complex types,
6346 but I don't know how yet because I can't reach this code from
6347 existing front-ends. */
6348 return (qualifiers
| 7); /* Who knows? */
6350 case CHAR_TYPE
: /* GNU Pascal CHAR type. Not used in C. */
6351 case BOOLEAN_TYPE
: /* GNU Fortran BOOLEAN type. */
6352 case FILE_TYPE
: /* GNU Pascal FILE type. */
6353 case SET_TYPE
: /* GNU Pascal SET type. */
6354 case LANG_TYPE
: /* ? */
6358 abort (); /* Not a type! */
6365 /* Nested function support. */
6367 /* Emit RTL insns to initialize the variable parts of a trampoline.
6368 FNADDR is an RTX for the address of the function's pure code.
6369 CXT is an RTX for the static chain value for the function.
6371 This takes 16 insns: 2 shifts & 2 ands (to split up addresses), 4 sethi
6372 (to load in opcodes), 4 iors (to merge address and opcodes), and 4 writes
6373 (to store insns). This is a bit excessive. Perhaps a different
6374 mechanism would be better here.
6376 Emit enough FLUSH insns to synchronize the data and instruction caches. */
6379 sparc_initialize_trampoline (tramp
, fnaddr
, cxt
)
6380 rtx tramp
, fnaddr
, cxt
;
6382 /* SPARC 32 bit trampoline:
6385 sethi %hi(static), %g2
6387 or %g2, %lo(static), %g2
6389 SETHI i,r = 00rr rrr1 00ii iiii iiii iiii iiii iiii
6390 JMPL r+i,d = 10dd ddd1 1100 0rrr rr1i iiii iiii iiii
6392 #ifdef TRANSFER_FROM_TRAMPOLINE
6393 emit_library_call (gen_rtx (SYMBOL_REF
, Pmode
, "__enable_execute_stack"),
6394 0, VOIDmode
, 1, tramp
, Pmode
);
6398 (gen_rtx_MEM (SImode
, plus_constant (tramp
, 0)),
6399 expand_binop (SImode
, ior_optab
,
6400 expand_shift (RSHIFT_EXPR
, SImode
, fnaddr
,
6401 size_int (10), 0, 1),
6402 GEN_INT (trunc_int_for_mode (0x03000000, SImode
)),
6403 NULL_RTX
, 1, OPTAB_DIRECT
));
6406 (gen_rtx_MEM (SImode
, plus_constant (tramp
, 4)),
6407 expand_binop (SImode
, ior_optab
,
6408 expand_shift (RSHIFT_EXPR
, SImode
, cxt
,
6409 size_int (10), 0, 1),
6410 GEN_INT (trunc_int_for_mode (0x05000000, SImode
)),
6411 NULL_RTX
, 1, OPTAB_DIRECT
));
6414 (gen_rtx_MEM (SImode
, plus_constant (tramp
, 8)),
6415 expand_binop (SImode
, ior_optab
,
6416 expand_and (SImode
, fnaddr
, GEN_INT (0x3ff), NULL_RTX
),
6417 GEN_INT (trunc_int_for_mode (0x81c06000, SImode
)),
6418 NULL_RTX
, 1, OPTAB_DIRECT
));
6421 (gen_rtx_MEM (SImode
, plus_constant (tramp
, 12)),
6422 expand_binop (SImode
, ior_optab
,
6423 expand_and (SImode
, cxt
, GEN_INT (0x3ff), NULL_RTX
),
6424 GEN_INT (trunc_int_for_mode (0x8410a000, SImode
)),
6425 NULL_RTX
, 1, OPTAB_DIRECT
));
6427 /* On UltraSPARC a flush flushes an entire cache line. The trampoline is
6428 aligned on a 16 byte boundary so one flush clears it all. */
6429 emit_insn (gen_flush (validize_mem (gen_rtx_MEM (SImode
, tramp
))));
6430 if (sparc_cpu
!= PROCESSOR_ULTRASPARC
)
6431 emit_insn (gen_flush (validize_mem (gen_rtx_MEM (SImode
,
6432 plus_constant (tramp
, 8)))));
6435 /* The 64 bit version is simpler because it makes more sense to load the
6436 values as "immediate" data out of the trampoline. It's also easier since
6437 we can read the PC without clobbering a register. */
6440 sparc64_initialize_trampoline (tramp
, fnaddr
, cxt
)
6441 rtx tramp
, fnaddr
, cxt
;
6443 #ifdef TRANSFER_FROM_TRAMPOLINE
6444 emit_library_call (gen_rtx (SYMBOL_REF
, Pmode
, "__enable_execute_stack"),
6445 0, VOIDmode
, 1, tramp
, Pmode
);
6456 emit_move_insn (gen_rtx_MEM (SImode
, tramp
),
6457 GEN_INT (trunc_int_for_mode (0x83414000, SImode
)));
6458 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 4)),
6459 GEN_INT (trunc_int_for_mode (0xca586018, SImode
)));
6460 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 8)),
6461 GEN_INT (trunc_int_for_mode (0x81c14000, SImode
)));
6462 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 12)),
6463 GEN_INT (trunc_int_for_mode (0xca586010, SImode
)));
6464 emit_move_insn (gen_rtx_MEM (DImode
, plus_constant (tramp
, 16)), cxt
);
6465 emit_move_insn (gen_rtx_MEM (DImode
, plus_constant (tramp
, 24)), fnaddr
);
6466 emit_insn (gen_flushdi (validize_mem (gen_rtx_MEM (DImode
, tramp
))));
6468 if (sparc_cpu
!= PROCESSOR_ULTRASPARC
)
6469 emit_insn (gen_flushdi (validize_mem (gen_rtx_MEM (DImode
, plus_constant (tramp
, 8)))));
6472 /* Subroutines to support a flat (single) register window calling
6475 /* Single-register window sparc stack frames look like:
6477 Before call After call
6478 +-----------------------+ +-----------------------+
6480 mem | caller's temps. | | caller's temps. |
6482 +-----------------------+ +-----------------------+
6484 | arguments on stack. | | arguments on stack. |
6486 +-----------------------+FP+92->+-----------------------+
6487 | 6 words to save | | 6 words to save |
6488 | arguments passed | | arguments passed |
6489 | in registers, even | | in registers, even |
6490 | if not passed. | | if not passed. |
6491 SP+68->+-----------------------+FP+68->+-----------------------+
6492 | 1 word struct addr | | 1 word struct addr |
6493 +-----------------------+FP+64->+-----------------------+
6495 | 16 word reg save area | | 16 word reg save area |
6497 SP->+-----------------------+ FP->+-----------------------+
6499 | fp/alu reg moves |
6500 FP-16->+-----------------------+
6504 +-----------------------+
6506 | fp register save |
6508 +-----------------------+
6510 | gp register save |
6512 +-----------------------+
6514 | alloca allocations |
6516 +-----------------------+
6518 | arguments on stack |
6520 SP+92->+-----------------------+
6522 | arguments passed |
6523 | in registers, even |
6524 low | if not passed. |
6525 memory SP+68->+-----------------------+
6526 | 1 word struct addr |
6527 SP+64->+-----------------------+
6529 I 16 word reg save area |
6531 SP->+-----------------------+ */
6533 /* Structure to be filled in by sparc_flat_compute_frame_size with register
6534 save masks, and offsets for the current function. */
6536 struct sparc_frame_info
6538 unsigned long total_size
; /* # bytes that the entire frame takes up. */
6539 unsigned long var_size
; /* # bytes that variables take up. */
6540 unsigned long args_size
; /* # bytes that outgoing arguments take up. */
6541 unsigned long extra_size
; /* # bytes of extra gunk. */
6542 unsigned int gp_reg_size
; /* # bytes needed to store gp regs. */
6543 unsigned int fp_reg_size
; /* # bytes needed to store fp regs. */
6544 unsigned long gmask
; /* Mask of saved gp registers. */
6545 unsigned long fmask
; /* Mask of saved fp registers. */
6546 unsigned long reg_offset
; /* Offset from new sp to store regs. */
6547 int initialized
; /* Nonzero if frame size already calculated. */
6550 /* Current frame information calculated by sparc_flat_compute_frame_size. */
6551 struct sparc_frame_info current_frame_info
;
6553 /* Zero structure to initialize current_frame_info. */
6554 struct sparc_frame_info zero_frame_info
;
6556 /* Tell prologue and epilogue if register REGNO should be saved / restored. */
6558 #define RETURN_ADDR_REGNUM 15
6559 #define HARD_FRAME_POINTER_MASK (1 << (HARD_FRAME_POINTER_REGNUM))
6560 #define RETURN_ADDR_MASK (1 << (RETURN_ADDR_REGNUM))
6562 #define MUST_SAVE_REGISTER(regno) \
6563 ((regs_ever_live[regno] && !call_used_regs[regno]) \
6564 || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed) \
6565 || (regno == RETURN_ADDR_REGNUM && regs_ever_live[RETURN_ADDR_REGNUM]))
6567 /* Return the bytes needed to compute the frame pointer from the current
6571 sparc_flat_compute_frame_size (size
)
6572 int size
; /* # of var. bytes allocated. */
6575 unsigned long total_size
; /* # bytes that the entire frame takes up. */
6576 unsigned long var_size
; /* # bytes that variables take up. */
6577 unsigned long args_size
; /* # bytes that outgoing arguments take up. */
6578 unsigned long extra_size
; /* # extra bytes. */
6579 unsigned int gp_reg_size
; /* # bytes needed to store gp regs. */
6580 unsigned int fp_reg_size
; /* # bytes needed to store fp regs. */
6581 unsigned long gmask
; /* Mask of saved gp registers. */
6582 unsigned long fmask
; /* Mask of saved fp registers. */
6583 unsigned long reg_offset
; /* Offset to register save area. */
6584 int need_aligned_p
; /* 1 if need the save area 8 byte aligned. */
6586 /* This is the size of the 16 word reg save area, 1 word struct addr
6587 area, and 4 word fp/alu register copy area. */
6588 extra_size
= -STARTING_FRAME_OFFSET
+ FIRST_PARM_OFFSET(0);
6598 if (!leaf_function_p ())
6600 /* Also include the size needed for the 6 parameter registers. */
6601 args_size
= current_function_outgoing_args_size
+ 24;
6603 total_size
= var_size
+ args_size
;
6605 /* Calculate space needed for gp registers. */
6606 for (regno
= 1; regno
<= 31; regno
++)
6608 if (MUST_SAVE_REGISTER (regno
))
6610 /* If we need to save two regs in a row, ensure there's room to bump
6611 up the address to align it to a doubleword boundary. */
6612 if ((regno
& 0x1) == 0 && MUST_SAVE_REGISTER (regno
+1))
6614 if (gp_reg_size
% 8 != 0)
6616 gp_reg_size
+= 2 * UNITS_PER_WORD
;
6617 gmask
|= 3 << regno
;
6623 gp_reg_size
+= UNITS_PER_WORD
;
6624 gmask
|= 1 << regno
;
6629 /* Calculate space needed for fp registers. */
6630 for (regno
= 32; regno
<= 63; regno
++)
6632 if (regs_ever_live
[regno
] && !call_used_regs
[regno
])
6634 fp_reg_size
+= UNITS_PER_WORD
;
6635 fmask
|= 1 << (regno
- 32);
6642 reg_offset
= FIRST_PARM_OFFSET(0) + args_size
;
6643 /* Ensure save area is 8 byte aligned if we need it. */
6645 if (need_aligned_p
&& n
!= 0)
6647 total_size
+= 8 - n
;
6648 reg_offset
+= 8 - n
;
6650 total_size
+= gp_reg_size
+ fp_reg_size
;
6653 /* If we must allocate a stack frame at all, we must also allocate
6654 room for register window spillage, so as to be binary compatible
6655 with libraries and operating systems that do not use -mflat. */
6657 total_size
+= extra_size
;
6661 total_size
= SPARC_STACK_ALIGN (total_size
);
6663 /* Save other computed information. */
6664 current_frame_info
.total_size
= total_size
;
6665 current_frame_info
.var_size
= var_size
;
6666 current_frame_info
.args_size
= args_size
;
6667 current_frame_info
.extra_size
= extra_size
;
6668 current_frame_info
.gp_reg_size
= gp_reg_size
;
6669 current_frame_info
.fp_reg_size
= fp_reg_size
;
6670 current_frame_info
.gmask
= gmask
;
6671 current_frame_info
.fmask
= fmask
;
6672 current_frame_info
.reg_offset
= reg_offset
;
6673 current_frame_info
.initialized
= reload_completed
;
6675 /* Ok, we're done. */
6679 /* Save/restore registers in GMASK and FMASK at register BASE_REG plus offset
6682 BASE_REG must be 8 byte aligned. This allows us to test OFFSET for
6683 appropriate alignment and use DOUBLEWORD_OP when we can. We assume
6684 [BASE_REG+OFFSET] will always be a valid address.
6686 WORD_OP is either "st" for save, "ld" for restore.
6687 DOUBLEWORD_OP is either "std" for save, "ldd" for restore. */
6690 sparc_flat_save_restore (file
, base_reg
, offset
, gmask
, fmask
, word_op
,
6691 doubleword_op
, base_offset
)
6693 const char *base_reg
;
6694 unsigned int offset
;
6695 unsigned long gmask
;
6696 unsigned long fmask
;
6697 const char *word_op
;
6698 const char *doubleword_op
;
6699 unsigned long base_offset
;
6703 if (gmask
== 0 && fmask
== 0)
6706 /* Save registers starting from high to low. We've already saved the
6707 previous frame pointer and previous return address for the debugger's
6708 sake. The debugger allows us to not need a nop in the epilog if at least
6709 one register is reloaded in addition to return address. */
6713 for (regno
= 1; regno
<= 31; regno
++)
6715 if ((gmask
& (1L << regno
)) != 0)
6717 if ((regno
& 0x1) == 0 && ((gmask
& (1L << (regno
+1))) != 0))
6719 /* We can save two registers in a row. If we're not at a
6720 double word boundary, move to one.
6721 sparc_flat_compute_frame_size ensures there's room to do
6723 if (offset
% 8 != 0)
6724 offset
+= UNITS_PER_WORD
;
6726 if (word_op
[0] == 's')
6728 fprintf (file
, "\t%s\t%s, [%s+%d]\n",
6729 doubleword_op
, reg_names
[regno
],
6731 if (dwarf2out_do_frame ())
6733 char *l
= dwarf2out_cfi_label ();
6734 dwarf2out_reg_save (l
, regno
, offset
+ base_offset
);
6736 (l
, regno
+1, offset
+base_offset
+ UNITS_PER_WORD
);
6740 fprintf (file
, "\t%s\t[%s+%d], %s\n",
6741 doubleword_op
, base_reg
, offset
,
6744 offset
+= 2 * UNITS_PER_WORD
;
6749 if (word_op
[0] == 's')
6751 fprintf (file
, "\t%s\t%s, [%s+%d]\n",
6752 word_op
, reg_names
[regno
],
6754 if (dwarf2out_do_frame ())
6755 dwarf2out_reg_save ("", regno
, offset
+ base_offset
);
6758 fprintf (file
, "\t%s\t[%s+%d], %s\n",
6759 word_op
, base_reg
, offset
, reg_names
[regno
]);
6761 offset
+= UNITS_PER_WORD
;
6769 for (regno
= 32; regno
<= 63; regno
++)
6771 if ((fmask
& (1L << (regno
- 32))) != 0)
6773 if (word_op
[0] == 's')
6775 fprintf (file
, "\t%s\t%s, [%s+%d]\n",
6776 word_op
, reg_names
[regno
],
6778 if (dwarf2out_do_frame ())
6779 dwarf2out_reg_save ("", regno
, offset
+ base_offset
);
6782 fprintf (file
, "\t%s\t[%s+%d], %s\n",
6783 word_op
, base_reg
, offset
, reg_names
[regno
]);
6785 offset
+= UNITS_PER_WORD
;
6791 /* Set up the stack and frame (if desired) for the function. */
6794 sparc_flat_function_prologue (file
, size
)
6798 const char *sp_str
= reg_names
[STACK_POINTER_REGNUM
];
6799 unsigned long gmask
= current_frame_info
.gmask
;
6801 sparc_output_scratch_registers (file
);
6803 /* This is only for the human reader. */
6804 fprintf (file
, "\t%s#PROLOGUE# 0\n", ASM_COMMENT_START
);
6805 fprintf (file
, "\t%s# vars= %ld, regs= %d/%d, args= %d, extra= %ld\n",
6807 current_frame_info
.var_size
,
6808 current_frame_info
.gp_reg_size
/ 4,
6809 current_frame_info
.fp_reg_size
/ 4,
6810 current_function_outgoing_args_size
,
6811 current_frame_info
.extra_size
);
6813 size
= SPARC_STACK_ALIGN (size
);
6814 size
= (! current_frame_info
.initialized
6815 ? sparc_flat_compute_frame_size (size
)
6816 : current_frame_info
.total_size
);
6818 /* These cases shouldn't happen. Catch them now. */
6819 if (size
== 0 && (gmask
|| current_frame_info
.fmask
))
6822 /* Allocate our stack frame by decrementing %sp.
6823 At present, the only algorithm gdb can use to determine if this is a
6824 flat frame is if we always set %i7 if we set %sp. This can be optimized
6825 in the future by putting in some sort of debugging information that says
6826 this is a `flat' function. However, there is still the case of debugging
6827 code without such debugging information (including cases where most fns
6828 have such info, but there is one that doesn't). So, always do this now
6829 so we don't get a lot of code out there that gdb can't handle.
6830 If the frame pointer isn't needn't then that's ok - gdb won't be able to
6831 distinguish us from a non-flat function but there won't (and shouldn't)
6832 be any differences anyway. The return pc is saved (if necessary) right
6833 after %i7 so gdb won't have to look too far to find it. */
6836 unsigned int reg_offset
= current_frame_info
.reg_offset
;
6837 const char *const fp_str
= reg_names
[HARD_FRAME_POINTER_REGNUM
];
6838 static const char *const t1_str
= "%g1";
6840 /* Things get a little tricky if local variables take up more than ~4096
6841 bytes and outgoing arguments take up more than ~4096 bytes. When that
6842 happens, the register save area can't be accessed from either end of
6843 the frame. Handle this by decrementing %sp to the start of the gp
6844 register save area, save the regs, update %i7, and then set %sp to its
6845 final value. Given that we only have one scratch register to play
6846 with it is the cheapest solution, and it helps gdb out as it won't
6847 slow down recognition of flat functions.
6848 Don't change the order of insns emitted here without checking with
6849 the gdb folk first. */
6851 /* Is the entire register save area offsettable from %sp? */
6852 if (reg_offset
< 4096 - 64 * (unsigned) UNITS_PER_WORD
)
6856 fprintf (file
, "\tadd\t%s, %d, %s\n",
6857 sp_str
, (int) -size
, sp_str
);
6858 if (gmask
& HARD_FRAME_POINTER_MASK
)
6860 fprintf (file
, "\tst\t%s, [%s+%d]\n",
6861 fp_str
, sp_str
, reg_offset
);
6862 fprintf (file
, "\tsub\t%s, %d, %s\t%s# set up frame pointer\n",
6863 sp_str
, (int) -size
, fp_str
, ASM_COMMENT_START
);
6869 fprintf (file
, "\tset\t");
6870 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, size
);
6871 fprintf (file
, ", %s\n\tsub\t%s, %s, %s\n",
6872 t1_str
, sp_str
, t1_str
, sp_str
);
6873 if (gmask
& HARD_FRAME_POINTER_MASK
)
6875 fprintf (file
, "\tst\t%s, [%s+%d]\n",
6876 fp_str
, sp_str
, reg_offset
);
6877 fprintf (file
, "\tadd\t%s, %s, %s\t%s# set up frame pointer\n",
6878 sp_str
, t1_str
, fp_str
, ASM_COMMENT_START
);
6882 if (dwarf2out_do_frame ())
6884 char *l
= dwarf2out_cfi_label ();
6885 if (gmask
& HARD_FRAME_POINTER_MASK
)
6887 dwarf2out_reg_save (l
, HARD_FRAME_POINTER_REGNUM
,
6888 reg_offset
- 4 - size
);
6889 dwarf2out_def_cfa (l
, HARD_FRAME_POINTER_REGNUM
, 0);
6892 dwarf2out_def_cfa (l
, STACK_POINTER_REGNUM
, size
);
6894 if (gmask
& RETURN_ADDR_MASK
)
6896 fprintf (file
, "\tst\t%s, [%s+%d]\n",
6897 reg_names
[RETURN_ADDR_REGNUM
], sp_str
, reg_offset
);
6898 if (dwarf2out_do_frame ())
6899 dwarf2out_return_save ("", reg_offset
- size
);
6902 sparc_flat_save_restore (file
, sp_str
, reg_offset
,
6903 gmask
& ~(HARD_FRAME_POINTER_MASK
| RETURN_ADDR_MASK
),
6904 current_frame_info
.fmask
,
6905 "st", "std", -size
);
6909 /* Subtract %sp in two steps, but make sure there is always a
6910 64 byte register save area, and %sp is properly aligned. */
6911 /* Amount to decrement %sp by, the first time. */
6912 unsigned HOST_WIDE_INT size1
= ((size
- reg_offset
+ 64) + 15) & -16;
6913 /* Offset to register save area from %sp. */
6914 unsigned HOST_WIDE_INT offset
= size1
- (size
- reg_offset
);
6918 fprintf (file
, "\tadd\t%s, %d, %s\n",
6919 sp_str
, (int) -size1
, sp_str
);
6920 if (gmask
& HARD_FRAME_POINTER_MASK
)
6922 fprintf (file
, "\tst\t%s, [%s+%d]\n\tsub\t%s, %d, %s\t%s# set up frame pointer\n",
6923 fp_str
, sp_str
, (int) offset
, sp_str
, (int) -size1
,
6924 fp_str
, ASM_COMMENT_START
);
6930 fprintf (file
, "\tset\t");
6931 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, size1
);
6932 fprintf (file
, ", %s\n\tsub\t%s, %s, %s\n",
6933 t1_str
, sp_str
, t1_str
, sp_str
);
6934 if (gmask
& HARD_FRAME_POINTER_MASK
)
6936 fprintf (file
, "\tst\t%s, [%s+%d]\n\tadd\t%s, %s, %s\t%s# set up frame pointer\n",
6937 fp_str
, sp_str
, (int) offset
, sp_str
, t1_str
,
6938 fp_str
, ASM_COMMENT_START
);
6942 if (dwarf2out_do_frame ())
6944 char *l
= dwarf2out_cfi_label ();
6945 if (gmask
& HARD_FRAME_POINTER_MASK
)
6947 dwarf2out_reg_save (l
, HARD_FRAME_POINTER_REGNUM
,
6948 offset
- 4 - size1
);
6949 dwarf2out_def_cfa (l
, HARD_FRAME_POINTER_REGNUM
, 0);
6952 dwarf2out_def_cfa (l
, STACK_POINTER_REGNUM
, size1
);
6954 if (gmask
& RETURN_ADDR_MASK
)
6956 fprintf (file
, "\tst\t%s, [%s+%d]\n",
6957 reg_names
[RETURN_ADDR_REGNUM
], sp_str
, (int) offset
);
6958 if (dwarf2out_do_frame ())
6959 /* offset - size1 == reg_offset - size
6960 if reg_offset were updated above like offset. */
6961 dwarf2out_return_save ("", offset
- size1
);
6964 sparc_flat_save_restore (file
, sp_str
, offset
,
6965 gmask
& ~(HARD_FRAME_POINTER_MASK
| RETURN_ADDR_MASK
),
6966 current_frame_info
.fmask
,
6967 "st", "std", -size1
);
6968 fprintf (file
, "\tset\t");
6969 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, size
- size1
);
6970 fprintf (file
, ", %s\n\tsub\t%s, %s, %s\n",
6971 t1_str
, sp_str
, t1_str
, sp_str
);
6972 if (dwarf2out_do_frame ())
6973 if (! (gmask
& HARD_FRAME_POINTER_MASK
))
6974 dwarf2out_def_cfa ("", STACK_POINTER_REGNUM
, size
);
6978 fprintf (file
, "\t%s#PROLOGUE# 1\n", ASM_COMMENT_START
);
6981 /* Do any necessary cleanup after a function to restore stack, frame,
6985 sparc_flat_function_epilogue (file
, size
)
6989 rtx epilogue_delay
= current_function_epilogue_delay_list
;
6990 int noepilogue
= FALSE
;
6992 /* This is only for the human reader. */
6993 fprintf (file
, "\t%s#EPILOGUE#\n", ASM_COMMENT_START
);
6995 /* The epilogue does not depend on any registers, but the stack
6996 registers, so we assume that if we have 1 pending nop, it can be
6997 ignored, and 2 it must be filled (2 nops occur for integer
6998 multiply and divide). */
7000 size
= SPARC_STACK_ALIGN (size
);
7001 size
= (!current_frame_info
.initialized
7002 ? sparc_flat_compute_frame_size (size
)
7003 : current_frame_info
.total_size
);
7005 if (size
== 0 && epilogue_delay
== 0)
7007 rtx insn
= get_last_insn ();
7009 /* If the last insn was a BARRIER, we don't have to write any code
7010 because a jump (aka return) was put there. */
7011 if (GET_CODE (insn
) == NOTE
)
7012 insn
= prev_nonnote_insn (insn
);
7013 if (insn
&& GET_CODE (insn
) == BARRIER
)
7019 unsigned HOST_WIDE_INT reg_offset
= current_frame_info
.reg_offset
;
7020 unsigned HOST_WIDE_INT size1
;
7021 const char *const sp_str
= reg_names
[STACK_POINTER_REGNUM
];
7022 const char *const fp_str
= reg_names
[HARD_FRAME_POINTER_REGNUM
];
7023 static const char *const t1_str
= "%g1";
7025 /* In the reload sequence, we don't need to fill the load delay
7026 slots for most of the loads, also see if we can fill the final
7027 delay slot if not otherwise filled by the reload sequence. */
7031 fprintf (file
, "\tset\t");
7032 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, size
);
7033 fprintf (file
, ", %s\n", t1_str
);
7036 if (frame_pointer_needed
)
7039 fprintf (file
,"\tsub\t%s, %s, %s\t\t%s# sp not trusted here\n",
7040 fp_str
, t1_str
, sp_str
, ASM_COMMENT_START
);
7042 fprintf (file
,"\tsub\t%s, %d, %s\t\t%s# sp not trusted here\n",
7043 fp_str
, (int) size
, sp_str
, ASM_COMMENT_START
);
7046 /* Is the entire register save area offsettable from %sp? */
7047 if (reg_offset
< 4096 - 64 * (unsigned) UNITS_PER_WORD
)
7053 /* Restore %sp in two steps, but make sure there is always a
7054 64 byte register save area, and %sp is properly aligned. */
7055 /* Amount to increment %sp by, the first time. */
7056 size1
= ((reg_offset
- 64 - 16) + 15) & -16;
7057 /* Offset to register save area from %sp. */
7058 reg_offset
= size1
- reg_offset
;
7060 fprintf (file
, "\tset\t");
7061 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, size1
);
7062 fprintf (file
, ", %s\n\tadd\t%s, %s, %s\n",
7063 t1_str
, sp_str
, t1_str
, sp_str
);
7066 /* We must restore the frame pointer and return address reg first
7067 because they are treated specially by the prologue output code. */
7068 if (current_frame_info
.gmask
& HARD_FRAME_POINTER_MASK
)
7070 fprintf (file
, "\tld\t[%s+%d], %s\n",
7071 sp_str
, (int) reg_offset
, fp_str
);
7074 if (current_frame_info
.gmask
& RETURN_ADDR_MASK
)
7076 fprintf (file
, "\tld\t[%s+%d], %s\n",
7077 sp_str
, (int) reg_offset
, reg_names
[RETURN_ADDR_REGNUM
]);
7081 /* Restore any remaining saved registers. */
7082 sparc_flat_save_restore (file
, sp_str
, reg_offset
,
7083 current_frame_info
.gmask
& ~(HARD_FRAME_POINTER_MASK
| RETURN_ADDR_MASK
),
7084 current_frame_info
.fmask
,
7087 /* If we had to increment %sp in two steps, record it so the second
7088 restoration in the epilogue finishes up. */
7094 fprintf (file
, "\tset\t");
7095 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, size
);
7096 fprintf (file
, ", %s\n", t1_str
);
7100 if (current_function_returns_struct
)
7101 fprintf (file
, "\tjmp\t%%o7+12\n");
7103 fprintf (file
, "\tretl\n");
7105 /* If the only register saved is the return address, we need a
7106 nop, unless we have an instruction to put into it. Otherwise
7107 we don't since reloading multiple registers doesn't reference
7108 the register being loaded. */
7114 final_scan_insn (XEXP (epilogue_delay
, 0), file
, 1, -2, 1);
7117 else if (size
> 4095)
7118 fprintf (file
, "\tadd\t%s, %s, %s\n", sp_str
, t1_str
, sp_str
);
7121 fprintf (file
, "\tadd\t%s, %d, %s\n", sp_str
, (int) size
, sp_str
);
7124 fprintf (file
, "\tnop\n");
7127 /* Reset state info for each function. */
7128 current_frame_info
= zero_frame_info
;
7130 sparc_output_deferred_case_vectors ();
7133 /* Define the number of delay slots needed for the function epilogue.
7135 On the sparc, we need a slot if either no stack has been allocated,
7136 or the only register saved is the return register. */
7139 sparc_flat_epilogue_delay_slots ()
7141 if (!current_frame_info
.initialized
)
7142 (void) sparc_flat_compute_frame_size (get_frame_size ());
7144 if (current_frame_info
.total_size
== 0)
7150 /* Return true if TRIAL is a valid insn for the epilogue delay slot.
7151 Any single length instruction which doesn't reference the stack or frame
7155 sparc_flat_eligible_for_epilogue_delay (trial
, slot
)
7157 int slot ATTRIBUTE_UNUSED
;
7159 rtx pat
= PATTERN (trial
);
7161 if (get_attr_length (trial
) != 1)
7164 if (! reg_mentioned_p (stack_pointer_rtx
, pat
)
7165 && ! reg_mentioned_p (frame_pointer_rtx
, pat
))
7171 /* Adjust the cost of a scheduling dependency. Return the new cost of
7172 a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
7175 supersparc_adjust_cost (insn
, link
, dep_insn
, cost
)
7181 enum attr_type insn_type
;
7183 if (! recog_memoized (insn
))
7186 insn_type
= get_attr_type (insn
);
7188 if (REG_NOTE_KIND (link
) == 0)
7190 /* Data dependency; DEP_INSN writes a register that INSN reads some
7193 /* if a load, then the dependence must be on the memory address;
7194 add an extra "cycle". Note that the cost could be two cycles
7195 if the reg was written late in an instruction group; we ca not tell
7197 if (insn_type
== TYPE_LOAD
|| insn_type
== TYPE_FPLOAD
)
7200 /* Get the delay only if the address of the store is the dependence. */
7201 if (insn_type
== TYPE_STORE
|| insn_type
== TYPE_FPSTORE
)
7203 rtx pat
= PATTERN(insn
);
7204 rtx dep_pat
= PATTERN (dep_insn
);
7206 if (GET_CODE (pat
) != SET
|| GET_CODE (dep_pat
) != SET
)
7207 return cost
; /* This should not happen! */
7209 /* The dependency between the two instructions was on the data that
7210 is being stored. Assume that this implies that the address of the
7211 store is not dependent. */
7212 if (rtx_equal_p (SET_DEST (dep_pat
), SET_SRC (pat
)))
7215 return cost
+ 3; /* An approximation. */
7218 /* A shift instruction cannot receive its data from an instruction
7219 in the same cycle; add a one cycle penalty. */
7220 if (insn_type
== TYPE_SHIFT
)
7221 return cost
+ 3; /* Split before cascade into shift. */
7225 /* Anti- or output- dependency; DEP_INSN reads/writes a register that
7226 INSN writes some cycles later. */
7228 /* These are only significant for the fpu unit; writing a fp reg before
7229 the fpu has finished with it stalls the processor. */
7231 /* Reusing an integer register causes no problems. */
7232 if (insn_type
== TYPE_IALU
|| insn_type
== TYPE_SHIFT
)
7240 hypersparc_adjust_cost (insn
, link
, dep_insn
, cost
)
7246 enum attr_type insn_type
, dep_type
;
7247 rtx pat
= PATTERN(insn
);
7248 rtx dep_pat
= PATTERN (dep_insn
);
7250 if (recog_memoized (insn
) < 0 || recog_memoized (dep_insn
) < 0)
7253 insn_type
= get_attr_type (insn
);
7254 dep_type
= get_attr_type (dep_insn
);
7256 switch (REG_NOTE_KIND (link
))
7259 /* Data dependency; DEP_INSN writes a register that INSN reads some
7266 /* Get the delay iff the address of the store is the dependence. */
7267 if (GET_CODE (pat
) != SET
|| GET_CODE (dep_pat
) != SET
)
7270 if (rtx_equal_p (SET_DEST (dep_pat
), SET_SRC (pat
)))
7277 /* If a load, then the dependence must be on the memory address. If
7278 the addresses aren't equal, then it might be a false dependency */
7279 if (dep_type
== TYPE_STORE
|| dep_type
== TYPE_FPSTORE
)
7281 if (GET_CODE (pat
) != SET
|| GET_CODE (dep_pat
) != SET
7282 || GET_CODE (SET_DEST (dep_pat
)) != MEM
7283 || GET_CODE (SET_SRC (pat
)) != MEM
7284 || ! rtx_equal_p (XEXP (SET_DEST (dep_pat
), 0),
7285 XEXP (SET_SRC (pat
), 0)))
7293 /* Compare to branch latency is 0. There is no benefit from
7294 separating compare and branch. */
7295 if (dep_type
== TYPE_COMPARE
)
7297 /* Floating point compare to branch latency is less than
7298 compare to conditional move. */
7299 if (dep_type
== TYPE_FPCMP
)
7308 /* Anti-dependencies only penalize the fpu unit. */
7309 if (insn_type
== TYPE_IALU
|| insn_type
== TYPE_SHIFT
)
7321 ultrasparc_adjust_cost (insn
, link
, dep_insn
, cost
)
7327 enum attr_type insn_type
, dep_type
;
7328 rtx pat
= PATTERN(insn
);
7329 rtx dep_pat
= PATTERN (dep_insn
);
7331 if (recog_memoized (insn
) < 0 || recog_memoized (dep_insn
) < 0)
7334 insn_type
= get_attr_type (insn
);
7335 dep_type
= get_attr_type (dep_insn
);
7337 /* Nothing issues in parallel with integer multiplies, so
7338 mark as zero cost since the scheduler can not do anything
7340 if (insn_type
== TYPE_IMUL
|| insn_type
== TYPE_IDIV
)
7343 #define SLOW_FP(dep_type) \
7344 (dep_type == TYPE_FPSQRTS || dep_type == TYPE_FPSQRTD || \
7345 dep_type == TYPE_FPDIVS || dep_type == TYPE_FPDIVD)
7347 switch (REG_NOTE_KIND (link
))
7350 /* Data dependency; DEP_INSN writes a register that INSN reads some
7353 if (dep_type
== TYPE_CMOVE
)
7355 /* Instructions that read the result of conditional moves cannot
7356 be in the same group or the following group. */
7362 /* UltraSPARC can dual issue a store and an instruction setting
7363 the value stored, except for divide and square root. */
7365 if (! SLOW_FP (dep_type
))
7370 if (GET_CODE (pat
) != SET
|| GET_CODE (dep_pat
) != SET
)
7373 if (rtx_equal_p (SET_DEST (dep_pat
), SET_SRC (pat
)))
7374 /* The dependency between the two instructions is on the data
7375 that is being stored. Assume that the address of the store
7376 is not also dependent. */
7383 /* A load does not return data until at least 11 cycles after
7384 a store to the same location. 3 cycles are accounted for
7385 in the load latency; add the other 8 here. */
7386 if (dep_type
== TYPE_STORE
|| dep_type
== TYPE_FPSTORE
)
7388 /* If the addresses are not equal this may be a false
7389 dependency because pointer aliasing could not be
7390 determined. Add only 2 cycles in that case. 2 is
7391 an arbitrary compromise between 8, which would cause
7392 the scheduler to generate worse code elsewhere to
7393 compensate for a dependency which might not really
7395 if (GET_CODE (pat
) != SET
|| GET_CODE (dep_pat
) != SET
7396 || GET_CODE (SET_SRC (pat
)) != MEM
7397 || GET_CODE (SET_DEST (dep_pat
)) != MEM
7398 || ! rtx_equal_p (XEXP (SET_SRC (pat
), 0),
7399 XEXP (SET_DEST (dep_pat
), 0)))
7407 /* Compare to branch latency is 0. There is no benefit from
7408 separating compare and branch. */
7409 if (dep_type
== TYPE_COMPARE
)
7411 /* Floating point compare to branch latency is less than
7412 compare to conditional move. */
7413 if (dep_type
== TYPE_FPCMP
)
7418 /* FMOVR class instructions can not issue in the same cycle
7419 or the cycle after an instruction which writes any
7420 integer register. Model this as cost 2 for dependent
7422 if (dep_type
== TYPE_IALU
7425 /* Otherwise check as for integer conditional moves. */
7428 /* Conditional moves involving integer registers wait until
7429 3 cycles after loads return data. The interlock applies
7430 to all loads, not just dependent loads, but that is hard
7432 if (dep_type
== TYPE_LOAD
|| dep_type
== TYPE_SLOAD
)
7442 /* Divide and square root lock destination registers for full latency. */
7443 if (! SLOW_FP (dep_type
))
7447 case REG_DEP_OUTPUT
:
7448 /* IEU and FPU instruction that have the same destination
7449 register cannot be grouped together. */
7456 /* Other costs not accounted for:
7457 - Single precision floating point loads lock the other half of
7458 the even/odd register pair.
7459 - Several hazards associated with ldd/std are ignored because these
7460 instructions are rarely generated for V9.
7461 - The floating point pipeline can not have both a single and double
7462 precision operation active at the same time. Format conversions
7463 and graphics instructions are given honorary double precision status.
7464 - call and jmpl are always the first instruction in a group. */
7472 sparc_adjust_cost(insn
, link
, dep
, cost
)
7480 case PROCESSOR_SUPERSPARC
:
7481 cost
= supersparc_adjust_cost (insn
, link
, dep
, cost
);
7483 case PROCESSOR_HYPERSPARC
:
7484 case PROCESSOR_SPARCLITE86X
:
7485 cost
= hypersparc_adjust_cost (insn
, link
, dep
, cost
);
7487 case PROCESSOR_ULTRASPARC
:
7488 cost
= ultrasparc_adjust_cost (insn
, link
, dep
, cost
);
7496 /* This describes the state of the UltraSPARC pipeline during
7497 instruction scheduling. */
7499 #define TMASK(__x) ((unsigned)1 << ((int)(__x)))
7500 #define UMASK(__x) ((unsigned)1 << ((int)(__x)))
7502 enum ultra_code
{ NONE
=0, /* no insn at all */
7503 IEU0
, /* shifts and conditional moves */
7504 IEU1
, /* condition code setting insns, calls+jumps */
7505 IEUN
, /* all other single cycle ieu insns */
7506 LSU
, /* loads and stores */
7508 FPM
, /* FPU pipeline 1, multiplies and divides */
7509 FPA
, /* FPU pipeline 2, all other operations */
7510 SINGLE
, /* single issue instructions */
7513 static enum ultra_code ultra_code_from_mask
PARAMS ((int));
7514 static void ultra_schedule_insn
PARAMS ((rtx
*, rtx
*, int, enum ultra_code
));
7516 static const char *const ultra_code_names
[NUM_ULTRA_CODES
] = {
7517 "NONE", "IEU0", "IEU1", "IEUN", "LSU", "CTI",
7518 "FPM", "FPA", "SINGLE" };
7520 struct ultrasparc_pipeline_state
{
7521 /* The insns in this group. */
7524 /* The code for each insn. */
7525 enum ultra_code codes
[4];
7527 /* Which insns in this group have been committed by the
7528 scheduler. This is how we determine how many more
7529 can issue this cycle. */
7532 /* How many insns in this group. */
7535 /* Mask of free slots still in this group. */
7536 char free_slot_mask
;
7538 /* The slotter uses the following to determine what other
7539 insn types can still make their way into this group. */
7540 char contents
[NUM_ULTRA_CODES
];
7544 #define ULTRA_NUM_HIST 8
7545 static struct ultrasparc_pipeline_state ultra_pipe_hist
[ULTRA_NUM_HIST
];
7546 static int ultra_cur_hist
;
7547 static int ultra_cycles_elapsed
;
7549 #define ultra_pipe (ultra_pipe_hist[ultra_cur_hist])
7551 /* Given TYPE_MASK compute the ultra_code it has. */
7552 static enum ultra_code
7553 ultra_code_from_mask (type_mask
)
7556 if (type_mask
& (TMASK (TYPE_SHIFT
) | TMASK (TYPE_CMOVE
)))
7558 else if (type_mask
& (TMASK (TYPE_COMPARE
) |
7560 TMASK (TYPE_SIBCALL
) |
7561 TMASK (TYPE_UNCOND_BRANCH
)))
7563 else if (type_mask
& TMASK (TYPE_IALU
))
7565 else if (type_mask
& (TMASK (TYPE_LOAD
) | TMASK (TYPE_SLOAD
) |
7566 TMASK (TYPE_STORE
) | TMASK (TYPE_FPLOAD
) |
7567 TMASK (TYPE_FPSTORE
)))
7569 else if (type_mask
& (TMASK (TYPE_FPMUL
) | TMASK (TYPE_FPDIVS
) |
7570 TMASK (TYPE_FPDIVD
) | TMASK (TYPE_FPSQRTS
) |
7571 TMASK (TYPE_FPSQRTD
)))
7573 else if (type_mask
& (TMASK (TYPE_FPMOVE
) | TMASK (TYPE_FPCMOVE
) |
7574 TMASK (TYPE_FP
) | TMASK (TYPE_FPCMP
)))
7576 else if (type_mask
& TMASK (TYPE_BRANCH
))
7582 /* Check INSN (a conditional move) and make sure that it's
7583 results are available at this cycle. Return 1 if the
7584 results are in fact ready. */
7586 ultra_cmove_results_ready_p (insn
)
7589 struct ultrasparc_pipeline_state
*up
;
7592 /* If this got dispatched in the previous
7593 group, the results are not ready. */
7594 entry
= (ultra_cur_hist
- 1) & (ULTRA_NUM_HIST
- 1);
7595 up
= &ultra_pipe_hist
[entry
];
7598 if (up
->group
[slot
] == insn
)
7604 /* Walk backwards in pipeline history looking for FPU
7605 operations which use a mode different than FPMODE and
7606 will create a stall if an insn using FPMODE were to be
7607 dispatched this cycle. */
7609 ultra_fpmode_conflict_exists (fpmode
)
7610 enum machine_mode fpmode
;
7615 hist_ent
= (ultra_cur_hist
- 1) & (ULTRA_NUM_HIST
- 1);
7616 if (ultra_cycles_elapsed
< 4)
7617 hist_lim
= ultra_cycles_elapsed
;
7620 while (hist_lim
> 0)
7622 struct ultrasparc_pipeline_state
*up
= &ultra_pipe_hist
[hist_ent
];
7627 rtx insn
= up
->group
[slot
];
7628 enum machine_mode this_mode
;
7632 || GET_CODE (insn
) != INSN
7633 || (pat
= PATTERN (insn
)) == 0
7634 || GET_CODE (pat
) != SET
)
7637 this_mode
= GET_MODE (SET_DEST (pat
));
7638 if ((this_mode
!= SFmode
7639 && this_mode
!= DFmode
)
7640 || this_mode
== fpmode
)
7643 /* If it is not FMOV, FABS, FNEG, FDIV, or FSQRT then
7644 we will get a stall. Loads and stores are independent
7646 if (GET_CODE (SET_SRC (pat
)) != ABS
7647 && GET_CODE (SET_SRC (pat
)) != NEG
7648 && ((TMASK (get_attr_type (insn
)) &
7649 (TMASK (TYPE_FPDIVS
) | TMASK (TYPE_FPDIVD
) |
7650 TMASK (TYPE_FPMOVE
) | TMASK (TYPE_FPSQRTS
) |
7651 TMASK (TYPE_FPSQRTD
) |
7652 TMASK (TYPE_LOAD
) | TMASK (TYPE_STORE
))) == 0))
7656 hist_ent
= (hist_ent
- 1) & (ULTRA_NUM_HIST
- 1);
7659 /* No conflicts, safe to dispatch. */
7663 /* Find an instruction in LIST which has one of the
7664 type attributes enumerated in TYPE_MASK. START
7665 says where to begin the search.
7667 NOTE: This scheme depends upon the fact that we
7668 have less than 32 distinct type attributes. */
7670 static int ultra_types_avail
;
7673 ultra_find_type (type_mask
, list
, start
)
7680 /* Short circuit if no such insn exists in the ready
7682 if ((type_mask
& ultra_types_avail
) == 0)
7685 for (i
= start
; i
>= 0; i
--)
7689 if (recog_memoized (insn
) >= 0
7690 && (TMASK(get_attr_type (insn
)) & type_mask
))
7692 enum machine_mode fpmode
= SFmode
;
7695 int check_depend
= 0;
7696 int check_fpmode_conflict
= 0;
7698 if (GET_CODE (insn
) == INSN
7699 && (pat
= PATTERN(insn
)) != 0
7700 && GET_CODE (pat
) == SET
7701 && !(type_mask
& (TMASK (TYPE_STORE
) |
7702 TMASK (TYPE_FPSTORE
))))
7705 if (GET_MODE (SET_DEST (pat
)) == SFmode
7706 || GET_MODE (SET_DEST (pat
)) == DFmode
)
7708 fpmode
= GET_MODE (SET_DEST (pat
));
7709 check_fpmode_conflict
= 1;
7716 rtx slot_insn
= ultra_pipe
.group
[slot
];
7719 /* Already issued, bad dependency, or FPU
7722 && (slot_pat
= PATTERN (slot_insn
)) != 0
7723 && ((insn
== slot_insn
)
7724 || (check_depend
== 1
7725 && GET_CODE (slot_insn
) == INSN
7726 && GET_CODE (slot_pat
) == SET
7727 && ((GET_CODE (SET_DEST (slot_pat
)) == REG
7728 && GET_CODE (SET_SRC (pat
)) == REG
7729 && REGNO (SET_DEST (slot_pat
)) ==
7730 REGNO (SET_SRC (pat
)))
7731 || (GET_CODE (SET_DEST (slot_pat
)) == SUBREG
7732 && GET_CODE (SET_SRC (pat
)) == SUBREG
7733 && REGNO (SUBREG_REG (SET_DEST (slot_pat
))) ==
7734 REGNO (SUBREG_REG (SET_SRC (pat
)))
7735 && SUBREG_BYTE (SET_DEST (slot_pat
)) ==
7736 SUBREG_BYTE (SET_SRC (pat
)))))
7737 || (check_fpmode_conflict
== 1
7738 && GET_CODE (slot_insn
) == INSN
7739 && GET_CODE (slot_pat
) == SET
7740 && (GET_MODE (SET_DEST (slot_pat
)) == SFmode
7741 || GET_MODE (SET_DEST (slot_pat
)) == DFmode
)
7742 && GET_MODE (SET_DEST (slot_pat
)) != fpmode
)))
7746 /* Check for peculiar result availability and dispatch
7747 interference situations. */
7749 && ultra_cycles_elapsed
> 0)
7753 for (link
= LOG_LINKS (insn
); link
; link
= XEXP (link
, 1))
7755 rtx link_insn
= XEXP (link
, 0);
7756 if (GET_CODE (link_insn
) == INSN
7757 && recog_memoized (link_insn
) >= 0
7758 && (TMASK (get_attr_type (link_insn
)) &
7759 (TMASK (TYPE_CMOVE
) | TMASK (TYPE_FPCMOVE
)))
7760 && ! ultra_cmove_results_ready_p (link_insn
))
7764 if (check_fpmode_conflict
7765 && ultra_fpmode_conflict_exists (fpmode
))
7778 ultra_build_types_avail (ready
, n_ready
)
7782 int i
= n_ready
- 1;
7784 ultra_types_avail
= 0;
7787 rtx insn
= ready
[i
];
7789 if (recog_memoized (insn
) >= 0)
7790 ultra_types_avail
|= TMASK (get_attr_type (insn
));
7796 /* Place insn pointed to my IP into the pipeline.
7797 Make element THIS of READY be that insn if it
7798 is not already. TYPE indicates the pipeline class
7799 this insn falls into. */
7801 ultra_schedule_insn (ip
, ready
, this, type
)
7805 enum ultra_code type
;
7808 char mask
= ultra_pipe
.free_slot_mask
;
7811 /* Obtain free slot. */
7812 for (pipe_slot
= 0; pipe_slot
< 4; pipe_slot
++)
7813 if ((mask
& (1 << pipe_slot
)) != 0)
7818 /* In it goes, and it hasn't been committed yet. */
7819 ultra_pipe
.group
[pipe_slot
] = *ip
;
7820 ultra_pipe
.codes
[pipe_slot
] = type
;
7821 ultra_pipe
.contents
[type
] = 1;
7823 (UMASK (IEUN
) | UMASK (IEU0
) | UMASK (IEU1
)))
7824 ultra_pipe
.num_ieu_insns
+= 1;
7826 ultra_pipe
.free_slot_mask
= (mask
& ~(1 << pipe_slot
));
7827 ultra_pipe
.group_size
+= 1;
7828 ultra_pipe
.commit
[pipe_slot
] = 0;
7830 /* Update ready list. */
7832 while (ip
!= &ready
[this])
7840 /* Advance to the next pipeline group. */
7842 ultra_flush_pipeline ()
7844 ultra_cur_hist
= (ultra_cur_hist
+ 1) & (ULTRA_NUM_HIST
- 1);
7845 ultra_cycles_elapsed
+= 1;
7846 memset ((char *) &ultra_pipe
, 0, sizeof ultra_pipe
);
7847 ultra_pipe
.free_slot_mask
= 0xf;
7850 /* Init our data structures for this current block. */
7852 ultrasparc_sched_init ()
7854 memset ((char *) ultra_pipe_hist
, 0, sizeof ultra_pipe_hist
);
7856 ultra_cycles_elapsed
= 0;
7857 ultra_pipe
.free_slot_mask
= 0xf;
7861 sparc_sched_init (dump
, sched_verbose
, max_ready
)
7862 FILE *dump ATTRIBUTE_UNUSED
;
7863 int sched_verbose ATTRIBUTE_UNUSED
;
7864 int max_ready ATTRIBUTE_UNUSED
;
7866 if (sparc_cpu
== PROCESSOR_ULTRASPARC
)
7867 ultrasparc_sched_init ();
7870 /* INSN has been scheduled, update pipeline commit state
7871 and return how many instructions are still to be
7872 scheduled in this group. */
7874 ultrasparc_variable_issue (insn
)
7877 struct ultrasparc_pipeline_state
*up
= &ultra_pipe
;
7878 int i
, left_to_fire
;
7881 for (i
= 0; i
< 4; i
++)
7883 if (up
->group
[i
] == 0)
7886 if (up
->group
[i
] == insn
)
7890 else if (! up
->commit
[i
])
7894 return left_to_fire
;
7898 sparc_variable_issue (dump
, sched_verbose
, insn
, cim
)
7899 FILE *dump ATTRIBUTE_UNUSED
;
7900 int sched_verbose ATTRIBUTE_UNUSED
;
7904 if (sparc_cpu
== PROCESSOR_ULTRASPARC
)
7905 return ultrasparc_variable_issue (insn
);
7910 /* In actual_hazard_this_instance, we may have yanked some
7911 instructions from the ready list due to conflict cost
7912 adjustments. If so, and such an insn was in our pipeline
7913 group, remove it and update state. */
7915 ultra_rescan_pipeline_state (ready
, n_ready
)
7919 struct ultrasparc_pipeline_state
*up
= &ultra_pipe
;
7922 for (i
= 0; i
< 4; i
++)
7924 rtx insn
= up
->group
[i
];
7930 /* If it has been committed, then it was removed from
7931 the ready list because it was actually scheduled,
7932 and that is not the case we are searching for here. */
7933 if (up
->commit
[i
] != 0)
7936 for (j
= n_ready
- 1; j
>= 0; j
--)
7937 if (ready
[j
] == insn
)
7940 /* If we didn't find it, toss it. */
7943 enum ultra_code ucode
= up
->codes
[i
];
7946 up
->codes
[i
] = NONE
;
7947 up
->contents
[ucode
] = 0;
7949 (UMASK (IEUN
) | UMASK (IEU0
) | UMASK (IEU1
)))
7950 up
->num_ieu_insns
-= 1;
7952 up
->free_slot_mask
|= (1 << i
);
7953 up
->group_size
-= 1;
7960 ultrasparc_sched_reorder (dump
, sched_verbose
, ready
, n_ready
)
7966 struct ultrasparc_pipeline_state
*up
= &ultra_pipe
;
7973 fprintf (dump
, "\n;;\tUltraSPARC Looking at [");
7974 for (n
= n_ready
- 1; n
>= 0; n
--)
7976 rtx insn
= ready
[n
];
7977 enum ultra_code ucode
;
7979 if (recog_memoized (insn
) < 0)
7981 ucode
= ultra_code_from_mask (TMASK (get_attr_type (insn
)));
7983 fprintf (dump
, "%s(%d) ",
7984 ultra_code_names
[ucode
],
7987 fprintf (dump
, "%s(%d)",
7988 ultra_code_names
[ucode
],
7991 fprintf (dump
, "]\n");
7994 this_insn
= n_ready
- 1;
7996 /* Skip over junk we don't understand. */
7997 while ((this_insn
>= 0)
7998 && recog_memoized (ready
[this_insn
]) < 0)
8001 ultra_build_types_avail (ready
, this_insn
+ 1);
8003 while (this_insn
>= 0) {
8004 int old_group_size
= up
->group_size
;
8006 if (up
->group_size
!= 0)
8010 num_committed
= (up
->commit
[0] + up
->commit
[1] +
8011 up
->commit
[2] + up
->commit
[3]);
8012 /* If nothing has been commited from our group, or all of
8013 them have. Clear out the (current cycle's) pipeline
8014 state and start afresh. */
8015 if (num_committed
== 0
8016 || num_committed
== up
->group_size
)
8018 ultra_flush_pipeline ();
8024 /* OK, some ready list insns got requeued and thus removed
8025 from the ready list. Account for this fact. */
8026 ultra_rescan_pipeline_state (ready
, n_ready
);
8028 /* Something "changed", make this look like a newly
8029 formed group so the code at the end of the loop
8030 knows that progress was in fact made. */
8031 if (up
->group_size
!= old_group_size
)
8036 if (up
->group_size
== 0)
8038 /* If the pipeline is (still) empty and we have any single
8039 group insns, get them out now as this is a good time. */
8040 rtx
*ip
= ultra_find_type ((TMASK (TYPE_RETURN
) | TMASK (TYPE_IDIV
) |
8041 TMASK (TYPE_IMUL
) | TMASK (TYPE_CMOVE
) |
8042 TMASK (TYPE_MULTI
) | TMASK (TYPE_MISC
)),
8046 ultra_schedule_insn (ip
, ready
, this_insn
, SINGLE
);
8050 /* If we are not in the process of emptying out the pipe, try to
8051 obtain an instruction which must be the first in it's group. */
8052 ip
= ultra_find_type ((TMASK (TYPE_CALL
) |
8053 TMASK (TYPE_SIBCALL
) |
8054 TMASK (TYPE_CALL_NO_DELAY_SLOT
) |
8055 TMASK (TYPE_UNCOND_BRANCH
)),
8059 ultra_schedule_insn (ip
, ready
, this_insn
, IEU1
);
8062 else if ((ip
= ultra_find_type ((TMASK (TYPE_FPDIVS
) |
8063 TMASK (TYPE_FPDIVD
) |
8064 TMASK (TYPE_FPSQRTS
) |
8065 TMASK (TYPE_FPSQRTD
)),
8066 ready
, this_insn
)) != 0)
8068 ultra_schedule_insn (ip
, ready
, this_insn
, FPM
);
8073 /* Try to fill the integer pipeline. First, look for an IEU0 specific
8074 operation. We can't do more IEU operations if the first 3 slots are
8075 all full or we have dispatched two IEU insns already. */
8076 if ((up
->free_slot_mask
& 0x7) != 0
8077 && up
->num_ieu_insns
< 2
8078 && up
->contents
[IEU0
] == 0
8079 && up
->contents
[IEUN
] == 0)
8081 rtx
*ip
= ultra_find_type (TMASK(TYPE_SHIFT
), ready
, this_insn
);
8084 ultra_schedule_insn (ip
, ready
, this_insn
, IEU0
);
8089 /* If we can, try to find an IEU1 specific or an unnamed
8091 if ((up
->free_slot_mask
& 0x7) != 0
8092 && up
->num_ieu_insns
< 2)
8094 rtx
*ip
= ultra_find_type ((TMASK (TYPE_IALU
) |
8095 (up
->contents
[IEU1
] == 0 ? TMASK (TYPE_COMPARE
) : 0)),
8101 ultra_schedule_insn (ip
, ready
, this_insn
,
8102 (!up
->contents
[IEU1
]
8103 && get_attr_type (insn
) == TYPE_COMPARE
)
8109 /* If only one IEU insn has been found, try to find another unnamed
8110 IEU operation or an IEU1 specific one. */
8111 if ((up
->free_slot_mask
& 0x7) != 0
8112 && up
->num_ieu_insns
< 2)
8115 int tmask
= TMASK (TYPE_IALU
);
8117 if (!up
->contents
[IEU1
])
8118 tmask
|= TMASK (TYPE_COMPARE
);
8119 ip
= ultra_find_type (tmask
, ready
, this_insn
);
8124 ultra_schedule_insn (ip
, ready
, this_insn
,
8125 (!up
->contents
[IEU1
]
8126 && get_attr_type (insn
) == TYPE_COMPARE
)
8132 /* Try for a load or store, but such an insn can only be issued
8133 if it is within' one of the first 3 slots. */
8134 if ((up
->free_slot_mask
& 0x7) != 0
8135 && up
->contents
[LSU
] == 0)
8137 rtx
*ip
= ultra_find_type ((TMASK (TYPE_LOAD
) | TMASK (TYPE_SLOAD
) |
8138 TMASK (TYPE_STORE
) | TMASK (TYPE_FPLOAD
) |
8139 TMASK (TYPE_FPSTORE
)), ready
, this_insn
);
8142 ultra_schedule_insn (ip
, ready
, this_insn
, LSU
);
8147 /* Now find FPU operations, first FPM class. But not divisions or
8148 square-roots because those will break the group up. Unlike all
8149 the previous types, these can go in any slot. */
8150 if (up
->free_slot_mask
!= 0
8151 && up
->contents
[FPM
] == 0)
8153 rtx
*ip
= ultra_find_type (TMASK (TYPE_FPMUL
), ready
, this_insn
);
8156 ultra_schedule_insn (ip
, ready
, this_insn
, FPM
);
8161 /* Continue on with FPA class if we have not filled the group already. */
8162 if (up
->free_slot_mask
!= 0
8163 && up
->contents
[FPA
] == 0)
8165 rtx
*ip
= ultra_find_type ((TMASK (TYPE_FPMOVE
) | TMASK (TYPE_FPCMOVE
) |
8166 TMASK (TYPE_FP
) | TMASK (TYPE_FPCMP
)),
8170 ultra_schedule_insn (ip
, ready
, this_insn
, FPA
);
8175 /* Finally, maybe stick a branch in here. */
8176 if (up
->free_slot_mask
!= 0
8177 && up
->contents
[CTI
] == 0)
8179 rtx
*ip
= ultra_find_type (TMASK (TYPE_BRANCH
), ready
, this_insn
);
8181 /* Try to slip in a branch only if it is one of the
8182 next 2 in the ready list. */
8183 if (ip
&& ((&ready
[this_insn
] - ip
) < 2))
8185 ultra_schedule_insn (ip
, ready
, this_insn
, CTI
);
8191 for (i
= 0; i
< 4; i
++)
8192 if ((up
->free_slot_mask
& (1 << i
)) == 0)
8195 /* See if we made any progress... */
8196 if (old_group_size
!= up
->group_size
)
8199 /* Clean out the (current cycle's) pipeline state
8200 and try once more. If we placed no instructions
8201 into the pipeline at all, it means a real hard
8202 conflict exists with some earlier issued instruction
8203 so we must advance to the next cycle to clear it up. */
8204 if (up
->group_size
== 0)
8206 ultra_flush_pipeline ();
8211 memset ((char *) &ultra_pipe
, 0, sizeof ultra_pipe
);
8212 ultra_pipe
.free_slot_mask
= 0xf;
8220 fprintf (dump
, ";;\tUltraSPARC Launched [");
8221 gsize
= up
->group_size
;
8222 for (n
= 0; n
< 4; n
++)
8224 rtx insn
= up
->group
[n
];
8231 fprintf (dump
, "%s(%d) ",
8232 ultra_code_names
[up
->codes
[n
]],
8235 fprintf (dump
, "%s(%d)",
8236 ultra_code_names
[up
->codes
[n
]],
8239 fprintf (dump
, "]\n");
8244 sparc_sched_reorder (dump
, sched_verbose
, ready
, n_readyp
, clock
)
8249 int clock ATTRIBUTE_UNUSED
;
8251 if (sparc_cpu
== PROCESSOR_ULTRASPARC
)
8252 ultrasparc_sched_reorder (dump
, sched_verbose
, ready
, *n_readyp
);
8253 return sparc_issue_rate ();
8264 /* Assume V9 processors are capable of at least dual-issue. */
8266 case PROCESSOR_SUPERSPARC
:
8268 case PROCESSOR_HYPERSPARC
:
8269 case PROCESSOR_SPARCLITE86X
:
8271 case PROCESSOR_ULTRASPARC
:
8280 register rtx pat
= PATTERN (insn
);
8282 switch (GET_CODE (SET_SRC (pat
)))
8284 /* Load and some shift instructions zero extend. */
8287 /* sethi clears the high bits */
8289 /* LO_SUM is used with sethi. sethi cleared the high
8290 bits and the values used with lo_sum are positive */
8292 /* Store flag stores 0 or 1 */
8302 rtx op0
= XEXP (SET_SRC (pat
), 0);
8303 rtx op1
= XEXP (SET_SRC (pat
), 1);
8304 if (GET_CODE (op1
) == CONST_INT
)
8305 return INTVAL (op1
) >= 0;
8306 if (GET_CODE (op0
) != REG
)
8308 if (sparc_check_64 (op0
, insn
) == 1)
8310 return (GET_CODE (op1
) == REG
&& sparc_check_64 (op1
, insn
) == 1);
8315 rtx op0
= XEXP (SET_SRC (pat
), 0);
8316 rtx op1
= XEXP (SET_SRC (pat
), 1);
8317 if (GET_CODE (op0
) != REG
|| sparc_check_64 (op0
, insn
) <= 0)
8319 if (GET_CODE (op1
) == CONST_INT
)
8320 return INTVAL (op1
) >= 0;
8321 return (GET_CODE (op1
) == REG
&& sparc_check_64 (op1
, insn
) == 1);
8325 return GET_MODE (SET_SRC (pat
)) == SImode
;
8326 /* Positive integers leave the high bits zero. */
8328 return ! (CONST_DOUBLE_LOW (SET_SRC (pat
)) & 0x80000000);
8330 return ! (INTVAL (SET_SRC (pat
)) & 0x80000000);
8333 return - (GET_MODE (SET_SRC (pat
)) == SImode
);
8335 return sparc_check_64 (SET_SRC (pat
), insn
);
8341 /* We _ought_ to have only one kind per function, but... */
8342 static rtx sparc_addr_diff_list
;
8343 static rtx sparc_addr_list
;
8346 sparc_defer_case_vector (lab
, vec
, diff
)
8350 vec
= gen_rtx_EXPR_LIST (VOIDmode
, lab
, vec
);
8352 sparc_addr_diff_list
8353 = gen_rtx_EXPR_LIST (VOIDmode
, vec
, sparc_addr_diff_list
);
8355 sparc_addr_list
= gen_rtx_EXPR_LIST (VOIDmode
, vec
, sparc_addr_list
);
8359 sparc_output_addr_vec (vec
)
8362 rtx lab
= XEXP (vec
, 0), body
= XEXP (vec
, 1);
8363 int idx
, vlen
= XVECLEN (body
, 0);
8365 #ifdef ASM_OUTPUT_ADDR_VEC_START
8366 ASM_OUTPUT_ADDR_VEC_START (asm_out_file
);
8369 #ifdef ASM_OUTPUT_CASE_LABEL
8370 ASM_OUTPUT_CASE_LABEL (asm_out_file
, "L", CODE_LABEL_NUMBER (lab
),
8373 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "L", CODE_LABEL_NUMBER (lab
));
8376 for (idx
= 0; idx
< vlen
; idx
++)
8378 ASM_OUTPUT_ADDR_VEC_ELT
8379 (asm_out_file
, CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 0, idx
), 0)));
8382 #ifdef ASM_OUTPUT_ADDR_VEC_END
8383 ASM_OUTPUT_ADDR_VEC_END (asm_out_file
);
8388 sparc_output_addr_diff_vec (vec
)
8391 rtx lab
= XEXP (vec
, 0), body
= XEXP (vec
, 1);
8392 rtx base
= XEXP (XEXP (body
, 0), 0);
8393 int idx
, vlen
= XVECLEN (body
, 1);
8395 #ifdef ASM_OUTPUT_ADDR_VEC_START
8396 ASM_OUTPUT_ADDR_VEC_START (asm_out_file
);
8399 #ifdef ASM_OUTPUT_CASE_LABEL
8400 ASM_OUTPUT_CASE_LABEL (asm_out_file
, "L", CODE_LABEL_NUMBER (lab
),
8403 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "L", CODE_LABEL_NUMBER (lab
));
8406 for (idx
= 0; idx
< vlen
; idx
++)
8408 ASM_OUTPUT_ADDR_DIFF_ELT
8411 CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 1, idx
), 0)),
8412 CODE_LABEL_NUMBER (base
));
8415 #ifdef ASM_OUTPUT_ADDR_VEC_END
8416 ASM_OUTPUT_ADDR_VEC_END (asm_out_file
);
8421 sparc_output_deferred_case_vectors ()
8426 if (sparc_addr_list
== NULL_RTX
8427 && sparc_addr_diff_list
== NULL_RTX
)
8430 /* Align to cache line in the function's code section. */
8431 function_section (current_function_decl
);
8433 align
= floor_log2 (FUNCTION_BOUNDARY
/ BITS_PER_UNIT
);
8435 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
8437 for (t
= sparc_addr_list
; t
; t
= XEXP (t
, 1))
8438 sparc_output_addr_vec (XEXP (t
, 0));
8439 for (t
= sparc_addr_diff_list
; t
; t
= XEXP (t
, 1))
8440 sparc_output_addr_diff_vec (XEXP (t
, 0));
8442 sparc_addr_list
= sparc_addr_diff_list
= NULL_RTX
;
8445 /* Return 0 if the high 32 bits of X (the low word of X, if DImode) are
8446 unknown. Return 1 if the high bits are zero, -1 if the register is
8449 sparc_check_64 (x
, insn
)
8452 /* If a register is set only once it is safe to ignore insns this
8453 code does not know how to handle. The loop will either recognize
8454 the single set and return the correct value or fail to recognize
8459 if (GET_CODE (x
) != REG
)
8462 if (GET_MODE (x
) == DImode
)
8463 y
= gen_rtx_REG (SImode
, REGNO (x
) + WORDS_BIG_ENDIAN
);
8465 if (flag_expensive_optimizations
8466 && REG_N_SETS (REGNO (y
)) == 1)
8472 insn
= get_last_insn_anywhere ();
8477 while ((insn
= PREV_INSN (insn
)))
8479 switch (GET_CODE (insn
))
8492 rtx pat
= PATTERN (insn
);
8493 if (GET_CODE (pat
) != SET
)
8495 if (rtx_equal_p (x
, SET_DEST (pat
)))
8496 return set_extends (insn
);
8497 if (y
&& rtx_equal_p (y
, SET_DEST (pat
)))
8498 return set_extends (insn
);
8499 if (reg_overlap_mentioned_p (SET_DEST (pat
), y
))
8508 sparc_v8plus_shift (operands
, insn
, opcode
)
8513 static char asm_code
[60];
8515 if (GET_CODE (operands
[3]) == SCRATCH
)
8516 operands
[3] = operands
[0];
8517 if (GET_CODE (operands
[1]) == CONST_INT
)
8519 output_asm_insn ("mov\t%1, %3", operands
);
8523 output_asm_insn ("sllx\t%H1, 32, %3", operands
);
8524 if (sparc_check_64 (operands
[1], insn
) <= 0)
8525 output_asm_insn ("srl\t%L1, 0, %L1", operands
);
8526 output_asm_insn ("or\t%L1, %3, %3", operands
);
8529 strcpy(asm_code
, opcode
);
8530 if (which_alternative
!= 2)
8531 return strcat (asm_code
, "\t%0, %2, %L0\n\tsrlx\t%L0, 32, %H0");
8533 return strcat (asm_code
, "\t%3, %2, %3\n\tsrlx\t%3, 32, %H0\n\tmov\t%3, %L0");
8536 /* Output rtl to increment the profiler label LABELNO
8537 for profiling a function entry. */
8540 sparc_profile_hook (labelno
)
8546 ASM_GENERATE_INTERNAL_LABEL (buf
, "LP", labelno
);
8547 lab
= gen_rtx_SYMBOL_REF (Pmode
, ggc_strdup (buf
));
8548 fun
= gen_rtx_SYMBOL_REF (Pmode
, MCOUNT_FUNCTION
);
8550 emit_library_call (fun
, 0, VOIDmode
, 1, lab
, Pmode
);
8553 /* Mark ARG, which is really a struct ultrasparc_pipline_state *, for
8557 mark_ultrasparc_pipeline_state (arg
)
8560 struct ultrasparc_pipeline_state
*ups
;
8563 ups
= (struct ultrasparc_pipeline_state
*) arg
;
8564 for (i
= 0; i
< ARRAY_SIZE (ups
->group
); ++i
)
8565 ggc_mark_rtx (ups
->group
[i
]);
8568 /* Called to register all of our global variables with the garbage
8572 sparc_add_gc_roots ()
8574 ggc_add_rtx_root (&sparc_compare_op0
, 1);
8575 ggc_add_rtx_root (&sparc_compare_op1
, 1);
8576 ggc_add_rtx_root (&global_offset_table
, 1);
8577 ggc_add_rtx_root (&get_pc_symbol
, 1);
8578 ggc_add_rtx_root (&sparc_addr_diff_list
, 1);
8579 ggc_add_rtx_root (&sparc_addr_list
, 1);
8580 ggc_add_root (ultra_pipe_hist
, ARRAY_SIZE (ultra_pipe_hist
),
8581 sizeof (ultra_pipe_hist
[0]), &mark_ultrasparc_pipeline_state
);
8584 #ifdef OBJECT_FORMAT_ELF
8586 sparc_elf_asm_named_section (name
, flags
)
8590 if (flags
& SECTION_MERGE
)
8592 /* entsize cannot be expressed in this section attributes
8594 default_elf_asm_named_section (name
, flags
);
8598 fprintf (asm_out_file
, "\t.section\t\"%s\"", name
);
8600 if (!(flags
& SECTION_DEBUG
))
8601 fputs (",#alloc", asm_out_file
);
8602 if (flags
& SECTION_WRITE
)
8603 fputs (",#write", asm_out_file
);
8604 if (flags
& SECTION_CODE
)
8605 fputs (",#execinstr", asm_out_file
);
8607 /* ??? Handle SECTION_BSS. */
8609 fputc ('\n', asm_out_file
);
8611 #endif /* OBJECT_FORMAT_ELF */
8614 sparc_extra_constraint_check (op
, c
, strict
)
8622 && (c
== 'T' || c
== 'U'))
8628 return fp_sethi_p (op
);
8631 return fp_mov_p (op
);
8634 return fp_high_losum_p (op
);
8638 || (GET_CODE (op
) == REG
8639 && (REGNO (op
) < FIRST_PSEUDO_REGISTER
8640 || reg_renumber
[REGNO (op
)] >= 0)))
8641 return register_ok_for_ldd (op
);
8653 /* Our memory extra constraints have to emulate the
8654 behavior of 'm' and 'o' in order for reload to work
8656 if (GET_CODE (op
) == MEM
)
8659 if ((TARGET_ARCH64
|| mem_min_alignment (op
, 8))
8661 || strict_memory_address_p (Pmode
, XEXP (op
, 0))))
8666 reload_ok_mem
= (reload_in_progress
8667 && GET_CODE (op
) == REG
8668 && REGNO (op
) >= FIRST_PSEUDO_REGISTER
8669 && reg_renumber
[REGNO (op
)] < 0);
8672 return reload_ok_mem
;