1 /* Subroutines used for code generation on the EPIPHANY cpu.
2 Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
4 Contributed by Embecosm on behalf of Adapteva, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
34 #include "insn-attr.h"
38 #include "diagnostic-core.h"
44 #include "langhooks.h"
45 #include "insn-codes.h"
47 #include "tm-constrs.h"
48 #include "tree-pass.h"
49 #include "integrate.h"
51 /* Which cpu we're compiling for. */
52 int epiphany_cpu_type
;
54 /* Name of mangle string to add to symbols to separate code compiled for each
56 const char *epiphany_mangle_cpu
;
58 /* Array of valid operand punctuation characters. */
59 char epiphany_punct_chars
[256];
61 /* The rounding mode that we generally use for floating point. */
62 int epiphany_normal_fp_rounding
;
64 static void epiphany_init_reg_tables (void);
65 static int get_epiphany_condition_code (rtx
);
66 static tree
epiphany_handle_interrupt_attribute (tree
*, tree
, tree
, int, bool *);
67 static bool epiphany_pass_by_reference (cumulative_args_t
, enum machine_mode
,
69 static rtx
frame_insn (rtx
);
71 /* defines for the initialization of the GCC target structure. */
72 #define TARGET_ATTRIBUTE_TABLE epiphany_attribute_table
74 #define TARGET_PRINT_OPERAND epiphany_print_operand
75 #define TARGET_PRINT_OPERAND_ADDRESS epiphany_print_operand_address
77 #define TARGET_RTX_COSTS epiphany_rtx_costs
78 #define TARGET_ADDRESS_COST epiphany_address_cost
79 #define TARGET_MEMORY_MOVE_COST epiphany_memory_move_cost
81 #define TARGET_PROMOTE_FUNCTION_MODE epiphany_promote_function_mode
82 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true
84 #define TARGET_RETURN_IN_MEMORY epiphany_return_in_memory
85 #define TARGET_PASS_BY_REFERENCE epiphany_pass_by_reference
86 #define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true
87 #define TARGET_FUNCTION_VALUE epiphany_function_value
88 #define TARGET_LIBCALL_VALUE epiphany_libcall_value
89 #define TARGET_FUNCTION_VALUE_REGNO_P epiphany_function_value_regno_p
91 #define TARGET_SETUP_INCOMING_VARARGS epiphany_setup_incoming_varargs
93 /* Using the simplistic varags handling forces us to do partial reg/stack
94 argument passing for types with larger size (> 4 bytes) than alignemnt. */
95 #define TARGET_ARG_PARTIAL_BYTES epiphany_arg_partial_bytes
97 #define TARGET_FUNCTION_OK_FOR_SIBCALL epiphany_function_ok_for_sibcall
99 #define TARGET_SCHED_ISSUE_RATE epiphany_issue_rate
100 #define TARGET_SCHED_ADJUST_COST epiphany_adjust_cost
102 #define TARGET_LEGITIMATE_ADDRESS_P epiphany_legitimate_address_p
104 #define TARGET_SECONDARY_RELOAD epiphany_secondary_reload
106 #define TARGET_OPTION_OVERRIDE epiphany_override_options
108 #define TARGET_CONDITIONAL_REGISTER_USAGE epiphany_conditional_register_usage
110 #define TARGET_FUNCTION_ARG epiphany_function_arg
112 #define TARGET_FUNCTION_ARG_ADVANCE epiphany_function_arg_advance
114 #define TARGET_FUNCTION_ARG_BOUNDARY epiphany_function_arg_boundary
116 #define TARGET_TRAMPOLINE_INIT epiphany_trampoline_init
118 /* Nonzero if the constant rtx value is a legitimate general operand.
119 We can handle any 32- or 64-bit constant. */
120 #define TARGET_LEGITIMATE_CONSTANT_P hook_bool_mode_rtx_true
122 #define TARGET_MIN_DIVISIONS_FOR_RECIP_MUL \
123 epiphany_min_divisions_for_recip_mul
125 #define TARGET_VECTORIZE_PREFERRED_SIMD_MODE epiphany_preferred_simd_mode
127 #define TARGET_VECTOR_MODE_SUPPORTED_P epiphany_vector_mode_supported_p
129 #define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE \
130 epiphany_vector_alignment_reachable
132 #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
133 epiphany_support_vector_misalignment
135 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK \
136 hook_bool_const_tree_hwi_hwi_const_tree_true
137 #define TARGET_ASM_OUTPUT_MI_THUNK epiphany_output_mi_thunk
139 #include "target-def.h"
141 #undef TARGET_ASM_ALIGNED_HI_OP
142 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
143 #undef TARGET_ASM_ALIGNED_SI_OP
144 #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
147 epiphany_is_interrupt_p (tree decl
)
151 attrs
= DECL_ATTRIBUTES (decl
);
152 if (lookup_attribute ("interrupt", attrs
))
158 /* Called from epiphany_override_options.
159 We use this to initialize various things. */
164 /* N.B. this pass must not run before the first optimize_mode_switching
165 pass because of the side offect of epiphany_mode_needed on
166 MACHINE_FUNCTION(cfun)->unknown_mode_uses. But it must run before
167 pass_resolve_sw_modes. */
168 static struct register_pass_info insert_use_info
169 = { &pass_mode_switch_use
.pass
, "mode_sw",
170 1, PASS_POS_INSERT_AFTER
172 static struct register_pass_info mode_sw2_info
173 = { &pass_mode_switching
.pass
, "mode_sw",
174 1, PASS_POS_INSERT_AFTER
176 static struct register_pass_info mode_sw3_info
177 = { &pass_resolve_sw_modes
.pass
, "mode_sw",
178 1, PASS_POS_INSERT_AFTER
180 static struct register_pass_info mode_sw4_info
181 = { &pass_split_all_insns
.pass
, "mode_sw",
182 1, PASS_POS_INSERT_AFTER
185 epiphany_init_reg_tables ();
187 /* Initialize array for PRINT_OPERAND_PUNCT_VALID_P. */
188 memset (epiphany_punct_chars
, 0, sizeof (epiphany_punct_chars
));
189 epiphany_punct_chars
['-'] = 1;
191 epiphany_normal_fp_rounding
192 = (epiphany_normal_fp_mode
== FP_MODE_ROUND_TRUNC
193 ? FP_MODE_ROUND_TRUNC
: FP_MODE_ROUND_NEAREST
);
194 register_pass (&mode_sw4_info
);
195 register_pass (&mode_sw2_info
);
196 register_pass (&mode_sw3_info
);
197 register_pass (&insert_use_info
);
198 register_pass (&mode_sw2_info
);
200 #if 1 /* As long as peep2_rescan is not implemented,
201 (see http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02819.html,)
202 we need a second peephole2 pass to get reasonable code. */
204 static struct register_pass_info peep2_2_info
205 = { &pass_peephole2
.pass
, "peephole2",
206 1, PASS_POS_INSERT_AFTER
209 register_pass (&peep2_2_info
);
214 /* The condition codes of the EPIPHANY, and the inverse function. */
215 static const char *const epiphany_condition_codes
[] =
216 { /* 0 1 2 3 4 5 6 7 8 9 */
217 "eq", "ne", "ltu", "gteu", "gt", "lte", "gte", "lt", "gtu", "lteu",
219 "beq","bne","blt", "blte",
222 #define EPIPHANY_INVERSE_CONDITION_CODE(X) ((X) ^ 1)
224 /* Returns the index of the EPIPHANY condition code string in
225 `epiphany_condition_codes'. COMPARISON should be an rtx like
226 `(eq (...) (...))'. */
229 get_epiphany_condition_code (rtx comparison
)
231 switch (GET_MODE (XEXP (comparison
, 0)))
234 switch (GET_CODE (comparison
))
247 default : gcc_unreachable ();
250 switch (GET_CODE (comparison
))
254 default: gcc_unreachable ();
257 switch (GET_CODE (comparison
))
261 default: gcc_unreachable ();
264 switch (GET_CODE (comparison
))
268 default: gcc_unreachable ();
271 switch (GET_CODE (comparison
))
277 default: gcc_unreachable ();
280 switch (GET_CODE (comparison
))
284 default: gcc_unreachable ();
287 switch (GET_CODE (comparison
))
293 case UNLE
: return 5;
294 case UNLT
: return 7;
295 default: gcc_unreachable ();
298 switch (GET_CODE (comparison
))
300 case ORDERED
: return 9;
301 case UNORDERED
: return 8;
302 default: gcc_unreachable ();
305 switch (GET_CODE (comparison
))
309 default: gcc_unreachable ();
311 default: gcc_unreachable ();
318 /* Return 1 if hard register REGNO can hold a value of machine_mode MODE. */
320 hard_regno_mode_ok (int regno
, enum machine_mode mode
)
322 if (GET_MODE_SIZE (mode
) > UNITS_PER_WORD
)
323 return (regno
& 1) == 0 && GPR_P (regno
);
328 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
329 return the mode to be used for the comparison. */
332 epiphany_select_cc_mode (enum rtx_code op
,
333 rtx x ATTRIBUTE_UNUSED
,
334 rtx y ATTRIBUTE_UNUSED
)
336 if (GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
)
338 if (TARGET_SOFT_CMPSF
)
340 if (op
== EQ
|| op
== NE
)
342 if (op
== ORDERED
|| op
== UNORDERED
)
343 return CC_FP_ORDmode
;
344 if (op
== UNEQ
|| op
== LTGT
)
345 return CC_FP_UNEQmode
;
346 return CC_FP_GTEmode
;
350 /* recognize combiner pattern ashlsi_btst:
352 (set (reg:N_NE 65 cc1)
353 (compare:N_NE (zero_extract:SI (reg/v:SI 75 [ a ])
356 (const_int 0 [0x0])))
357 (clobber (scratch:SI)) */
358 else if ((op
== EQ
|| op
== NE
)
359 && GET_CODE (x
) == ZERO_EXTRACT
360 && XEXP (x
, 1) == const1_rtx
361 && CONST_INT_P (XEXP (x
, 2)))
363 else if ((op
== GEU
|| op
== LTU
) && GET_CODE (x
) == PLUS
)
365 else if ((op
== LEU
|| op
== GTU
) && GET_CODE (x
) == MINUS
)
371 enum reg_class epiphany_regno_reg_class
[FIRST_PSEUDO_REGISTER
];
374 epiphany_init_reg_tables (void)
378 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
381 epiphany_regno_reg_class
[i
] = LR_REGS
;
382 else if (i
<= 7 && TARGET_PREFER_SHORT_INSN_REGS
)
383 epiphany_regno_reg_class
[i
] = SHORT_INSN_REGS
;
384 else if (call_used_regs
[i
]
385 && TEST_HARD_REG_BIT (reg_class_contents
[GENERAL_REGS
], i
))
386 epiphany_regno_reg_class
[i
] = SIBCALL_REGS
;
387 else if (i
>= CORE_CONTROL_FIRST
&& i
<= CORE_CONTROL_LAST
)
388 epiphany_regno_reg_class
[i
] = CORE_CONTROL_REGS
;
389 else if (i
< (GPR_LAST
+1)
390 || i
== ARG_POINTER_REGNUM
|| i
== FRAME_POINTER_REGNUM
)
391 epiphany_regno_reg_class
[i
] = GENERAL_REGS
;
392 else if (i
== CC_REGNUM
)
393 epiphany_regno_reg_class
[i
] = NO_REGS
/* CC_REG: must be NO_REGS */;
395 epiphany_regno_reg_class
[i
] = NO_REGS
;
399 /* EPIPHANY specific attribute support.
401 The EPIPHANY has these attributes:
402 interrupt - for interrupt functions.
403 short_call - the function is assumed to be reachable with the b / bl
405 long_call - the function address is loaded into a register before use.
406 disinterrupt - functions which mask interrupts throughout.
407 They unmask them while calling an interruptible
410 static const struct attribute_spec epiphany_attribute_table
[] =
412 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
413 { "interrupt", 1, 1, true, false, false, epiphany_handle_interrupt_attribute
, true },
414 { "long_call", 0, 0, false, true, true, NULL
, false },
415 { "short_call", 0, 0, false, true, true, NULL
, false },
416 { "disinterrupt", 0, 0, false, true, true, NULL
, false },
417 { NULL
, 0, 0, false, false, false, NULL
, false }
420 /* Handle an "interrupt" attribute; arguments as in
421 struct attribute_spec.handler. */
423 epiphany_handle_interrupt_attribute (tree
*node ATTRIBUTE_UNUSED
,
424 tree name
, tree args
,
425 int flags ATTRIBUTE_UNUSED
,
428 tree value
= TREE_VALUE (args
);
430 if (TREE_CODE (value
) != STRING_CST
)
432 warning (OPT_Wattributes
,
433 "argument of %qE attribute is not a string constant", name
);
434 *no_add_attrs
= true;
436 else if (strcmp (TREE_STRING_POINTER (value
), "reset")
437 && strcmp (TREE_STRING_POINTER (value
), "software_exception")
438 && strcmp (TREE_STRING_POINTER (value
), "page_miss")
439 && strcmp (TREE_STRING_POINTER (value
), "timer0")
440 && strcmp (TREE_STRING_POINTER (value
), "timer1")
441 && strcmp (TREE_STRING_POINTER (value
), "message")
442 && strcmp (TREE_STRING_POINTER (value
), "dma0")
443 && strcmp (TREE_STRING_POINTER (value
), "dma1")
444 && strcmp (TREE_STRING_POINTER (value
), "wand")
445 && strcmp (TREE_STRING_POINTER (value
), "swi"))
447 warning (OPT_Wattributes
,
448 "argument of %qE attribute is not \"reset\", \"software_exception\", \"page_miss\", \"timer0\", \"timer1\", \"message\", \"dma0\", \"dma1\", \"wand\" or \"swi\"",
450 *no_add_attrs
= true;
457 /* Misc. utilities. */
459 /* Generate a SYMBOL_REF for the special function NAME. When the address
460 can't be placed directly into a call instruction, and if possible, copy
461 it to a register so that cse / code hoisting is possible. */
463 sfunc_symbol (const char *name
)
465 rtx sym
= gen_rtx_SYMBOL_REF (Pmode
, name
);
467 /* These sfuncs should be hidden, and every dso should get a copy. */
468 SYMBOL_REF_FLAGS (sym
) = SYMBOL_FLAG_FUNCTION
| SYMBOL_FLAG_LOCAL
;
469 if (TARGET_SHORT_CALLS
)
470 ; /* Nothing to be done. */
471 else if (can_create_pseudo_p ())
472 sym
= copy_to_mode_reg (Pmode
, sym
);
473 else /* We rely on reload to fix this up. */
474 gcc_assert (!reload_in_progress
|| reload_completed
);
478 /* X and Y are two things to compare using CODE in IN_MODE.
479 Emit the compare insn, construct the the proper cc reg in the proper
480 mode, and return the rtx for the cc reg comparison in CMODE. */
483 gen_compare_reg (enum machine_mode cmode
, enum rtx_code code
,
484 enum machine_mode in_mode
, rtx x
, rtx y
)
486 enum machine_mode mode
= SELECT_CC_MODE (code
, x
, y
);
487 rtx cc_reg
, pat
, clob0
, clob1
, clob2
;
489 if (in_mode
== VOIDmode
)
490 in_mode
= GET_MODE (x
);
491 if (in_mode
== VOIDmode
)
492 in_mode
= GET_MODE (y
);
494 if (mode
== CC_FPmode
)
496 /* The epiphany has only EQ / NE / LT / LE conditions for
497 hardware floating point. */
498 if (code
== GT
|| code
== GE
|| code
== UNLE
|| code
== UNLT
)
500 rtx tmp
= x
; x
= y
; y
= tmp
;
501 code
= swap_condition (code
);
503 cc_reg
= gen_rtx_REG (mode
, CCFP_REGNUM
);
504 y
= force_reg (in_mode
, y
);
508 if (mode
== CC_FP_GTEmode
509 && (code
== LE
|| code
== LT
|| code
== UNGT
|| code
== UNGE
))
511 rtx tmp
= x
; x
= y
; y
= tmp
;
512 code
= swap_condition (code
);
514 cc_reg
= gen_rtx_REG (mode
, CC_REGNUM
);
516 if ((mode
== CC_FP_EQmode
|| mode
== CC_FP_GTEmode
517 || mode
== CC_FP_ORDmode
|| mode
== CC_FP_UNEQmode
)
518 /* mov<mode>cc might want to re-emit a comparison during ifcvt. */
519 && (!REG_P (x
) || REGNO (x
) != 0 || !REG_P (y
) || REGNO (y
) != 1))
523 gcc_assert (currently_expanding_to_rtl
);
524 reg
= gen_rtx_REG (in_mode
, 0);
525 gcc_assert (!reg_overlap_mentioned_p (reg
, y
));
526 emit_move_insn (reg
, x
);
528 reg
= gen_rtx_REG (in_mode
, 1);
529 emit_move_insn (reg
, y
);
533 x
= force_reg (in_mode
, x
);
535 pat
= gen_rtx_SET (VOIDmode
, cc_reg
, gen_rtx_COMPARE (mode
, x
, y
));
536 if (mode
== CC_FP_EQmode
|| mode
== CC_FP_GTEmode
)
538 const char *name
= mode
== CC_FP_EQmode
? "__eqsf2" : "__gtesf2";
539 rtx use
= gen_rtx_USE (VOIDmode
, sfunc_symbol (name
));
541 clob0
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (SImode
, GPR_IP
));
542 clob1
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (SImode
, GPR_LR
));
543 pat
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (4, pat
, use
, clob0
, clob1
));
545 else if (mode
== CC_FP_ORDmode
|| mode
== CC_FP_UNEQmode
)
547 const char *name
= mode
== CC_FP_ORDmode
? "__ordsf2" : "__uneqsf2";
548 rtx use
= gen_rtx_USE (VOIDmode
, sfunc_symbol (name
));
550 clob0
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (SImode
, GPR_IP
));
551 clob1
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (SImode
, GPR_16
));
552 clob2
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (SImode
, GPR_LR
));
553 pat
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (5, pat
, use
,
554 clob0
, clob1
, clob2
));
558 clob0
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_SCRATCH (in_mode
));
559 pat
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, pat
, clob0
));
562 return gen_rtx_fmt_ee (code
, cmode
, cc_reg
, const0_rtx
);
565 /* The ROUND_ADVANCE* macros are local to this file. */
566 /* Round SIZE up to a word boundary. */
567 #define ROUND_ADVANCE(SIZE) \
568 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
570 /* Round arg MODE/TYPE up to the next word boundary. */
571 #define ROUND_ADVANCE_ARG(MODE, TYPE) \
573 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
574 : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))
576 /* Round CUM up to the necessary point for argument MODE/TYPE. */
577 #define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) \
578 (epiphany_function_arg_boundary ((MODE), (TYPE)) > BITS_PER_WORD \
579 ? (((CUM) + 1) & ~1) \
583 epiphany_function_arg_boundary (enum machine_mode mode
, const_tree type
)
585 if ((type
? TYPE_ALIGN (type
) : GET_MODE_BITSIZE (mode
)) <= PARM_BOUNDARY
)
586 return PARM_BOUNDARY
;
587 return 2 * PARM_BOUNDARY
;
590 /* Do any needed setup for a variadic function. For the EPIPHANY, we
591 actually emit the code in epiphany_expand_prologue.
593 CUM has not been updated for the last named argument which has type TYPE
594 and mode MODE, and we rely on this fact. */
598 epiphany_setup_incoming_varargs (cumulative_args_t cum
, enum machine_mode mode
,
599 tree type
, int *pretend_size
, int no_rtl
)
602 CUMULATIVE_ARGS next_cum
;
603 machine_function_t
*mf
= MACHINE_FUNCTION (cfun
);
605 /* All BLKmode values are passed by reference. */
606 gcc_assert (mode
!= BLKmode
);
608 next_cum
= *get_cumulative_args (cum
);
610 = ROUND_ADVANCE_CUM (next_cum
, mode
, type
) + ROUND_ADVANCE_ARG (mode
, type
);
611 first_anon_arg
= next_cum
;
613 if (first_anon_arg
< MAX_EPIPHANY_PARM_REGS
&& !no_rtl
)
615 /* Note that first_reg_offset < MAX_EPIPHANY_PARM_REGS. */
616 int first_reg_offset
= first_anon_arg
;
618 *pretend_size
= ((MAX_EPIPHANY_PARM_REGS
- first_reg_offset
)
622 mf
->pretend_args_odd
= ((*pretend_size
& UNITS_PER_WORD
) ? 1 : 0);
626 epiphany_arg_partial_bytes (cumulative_args_t cum
, enum machine_mode mode
,
627 tree type
, bool named ATTRIBUTE_UNUSED
)
629 int words
= 0, rounded_cum
;
631 gcc_assert (!epiphany_pass_by_reference (cum
, mode
, type
, /* named */ true));
633 rounded_cum
= ROUND_ADVANCE_CUM (*get_cumulative_args (cum
), mode
, type
);
634 if (rounded_cum
< MAX_EPIPHANY_PARM_REGS
)
636 words
= MAX_EPIPHANY_PARM_REGS
- rounded_cum
;
637 if (words
>= ROUND_ADVANCE_ARG (mode
, type
))
640 return words
* UNITS_PER_WORD
;
643 /* Cost functions. */
645 /* Compute a (partial) cost for rtx X. Return true if the complete
646 cost has been computed, and false if subexpressions should be
647 scanned. In either case, *TOTAL contains the cost result. */
650 epiphany_rtx_costs (rtx x
, int code
, int outer_code
, int opno ATTRIBUTE_UNUSED
,
651 int *total
, bool speed ATTRIBUTE_UNUSED
)
655 /* Small integers in the right context are as cheap as registers. */
657 if ((outer_code
== PLUS
|| outer_code
== MINUS
)
658 && SIMM11 (INTVAL (x
)))
663 if (IMM16 (INTVAL (x
)))
665 *total
= outer_code
== SET
? 0 : COSTS_N_INSNS (1);
673 *total
= COSTS_N_INSNS ((epiphany_small16 (x
) ? 0 : 1)
674 + (outer_code
== SET
? 0 : 1));
680 split_double (x
, &high
, &low
);
681 *total
= COSTS_N_INSNS (!IMM16 (INTVAL (high
))
682 + !IMM16 (INTVAL (low
)));
689 *total
= COSTS_N_INSNS (1);
698 /* Provide the costs of an addressing mode that contains ADDR.
699 If ADDR is not a valid address, its cost is irrelevant. */
702 epiphany_address_cost (rtx addr
, bool speed
)
705 rtx off
= const0_rtx
;
710 /* Return 0 for addresses valid in short insns, 1 for addresses only valid
712 switch (GET_CODE (addr
))
715 reg
= XEXP (addr
, 0);
716 off
= XEXP (addr
, 1);
719 reg
= XEXP (addr
, 0);
720 off
= XEXP (addr
, 1);
721 gcc_assert (GET_CODE (off
) == PLUS
&& rtx_equal_p (reg
, XEXP (off
, 0)));
723 if (satisfies_constraint_Rgs (reg
) && satisfies_constraint_Rgs (off
))
731 if (!satisfies_constraint_Rgs (reg
))
733 /* ??? We don't know the mode of the memory access. We are going to assume
734 SImode, unless lack of offset alignment indicates a smaller access. */
735 /* First, make sure we have a valid integer. */
736 if (!satisfies_constraint_L (off
))
748 /* Compute the cost of moving data between registers and memory.
749 For integer, load latency is twice as long as register-register moves,
750 but issue pich is the same. For floating point, load latency is three
751 times as much as a reg-reg move. */
753 epiphany_memory_move_cost (enum machine_mode mode
,
754 reg_class_t rclass ATTRIBUTE_UNUSED
,
755 bool in ATTRIBUTE_UNUSED
)
757 return GET_MODE_CLASS (mode
) == MODE_INT
? 3 : 4;
760 /* Function prologue/epilogue handlers. */
762 /* EPIPHANY stack frames look like:
764 Before call After call
765 +-----------------------+ +-----------------------+
767 high | local variables, | | local variables, |
768 mem | reg save area, etc. | | reg save area, etc. |
770 +-----------------------+ +-----------------------+
772 | arguments on stack. | | arguments on stack. |
774 SP+8->+-----------------------+FP+8m->+-----------------------+
775 | 2 word save area for | | reg parm save area, |
776 | leaf funcs / flags | | only created for |
777 SP+0->+-----------------------+ | variable argument |
779 FP+8n->+-----------------------+
781 | register save area |
783 +-----------------------+
787 FP+0->+-----------------------+
789 | alloca allocations |
791 +-----------------------+
793 | arguments on stack |
795 SP+8->+-----------------------+
796 low | 2 word save area for |
797 memory | leaf funcs / flags |
798 SP+0->+-----------------------+
801 1) The "reg parm save area" does not exist for non variable argument fns.
802 The "reg parm save area" could be eliminated if we created our
803 own TARGET_GIMPLIFY_VA_ARG_EXPR, but that has tradeoffs as well
804 (so it's not done). */
806 /* Structure to be filled in by epiphany_compute_frame_size with register
807 save masks, and offsets for the current function. */
808 struct epiphany_frame_info
810 unsigned int total_size
; /* # bytes that the entire frame takes up. */
811 unsigned int pretend_size
; /* # bytes we push and pretend caller did. */
812 unsigned int args_size
; /* # bytes that outgoing arguments take up. */
813 unsigned int reg_size
; /* # bytes needed to store regs. */
814 unsigned int var_size
; /* # bytes that variables take up. */
815 HARD_REG_SET gmask
; /* Set of saved gp registers. */
816 int initialized
; /* Nonzero if frame size already calculated. */
817 int stld_sz
; /* Current load/store data size for offset
819 int need_fp
; /* value to override "frame_pointer_needed */
820 int first_slot
, last_slot
, first_slot_offset
, last_slot_offset
;
825 /* Current frame information calculated by epiphany_compute_frame_size. */
826 static struct epiphany_frame_info current_frame_info
;
828 /* Zero structure to initialize current_frame_info. */
829 static struct epiphany_frame_info zero_frame_info
;
831 /* The usual; we set up our machine_function data. */
832 static struct machine_function
*
833 epiphany_init_machine_status (void)
835 struct machine_function
*machine
;
837 /* Reset state info for each function. */
838 current_frame_info
= zero_frame_info
;
840 machine
= ggc_alloc_cleared_machine_function_t ();
845 /* Implements INIT_EXPANDERS. We just set up to call the above
848 epiphany_init_expanders (void)
850 init_machine_status
= epiphany_init_machine_status
;
853 /* Type of function DECL.
855 The result is cached. To reset the cache at the end of a function,
856 call with DECL = NULL_TREE. */
858 static enum epiphany_function_type
859 epiphany_compute_function_type (tree decl
)
863 static enum epiphany_function_type fn_type
= EPIPHANY_FUNCTION_UNKNOWN
;
864 /* Last function we were called for. */
865 static tree last_fn
= NULL_TREE
;
867 /* Resetting the cached value? */
868 if (decl
== NULL_TREE
)
870 fn_type
= EPIPHANY_FUNCTION_UNKNOWN
;
875 if (decl
== last_fn
&& fn_type
!= EPIPHANY_FUNCTION_UNKNOWN
)
878 /* Assume we have a normal function (not an interrupt handler). */
879 fn_type
= EPIPHANY_FUNCTION_NORMAL
;
881 /* Now see if this is an interrupt handler. */
882 for (a
= DECL_ATTRIBUTES (decl
);
886 tree name
= TREE_PURPOSE (a
), args
= TREE_VALUE (a
);
888 if (name
== get_identifier ("interrupt")
889 && list_length (args
) == 1
890 && TREE_CODE (TREE_VALUE (args
)) == STRING_CST
)
892 tree value
= TREE_VALUE (args
);
894 if (!strcmp (TREE_STRING_POINTER (value
), "reset"))
895 fn_type
= EPIPHANY_FUNCTION_RESET
;
896 else if (!strcmp (TREE_STRING_POINTER (value
), "software_exception"))
897 fn_type
= EPIPHANY_FUNCTION_SOFTWARE_EXCEPTION
;
898 else if (!strcmp (TREE_STRING_POINTER (value
), "page_miss"))
899 fn_type
= EPIPHANY_FUNCTION_PAGE_MISS
;
900 else if (!strcmp (TREE_STRING_POINTER (value
), "timer0"))
901 fn_type
= EPIPHANY_FUNCTION_TIMER0
;
902 else if (!strcmp (TREE_STRING_POINTER (value
), "timer1"))
903 fn_type
= EPIPHANY_FUNCTION_TIMER1
;
904 else if (!strcmp (TREE_STRING_POINTER (value
), "message"))
905 fn_type
= EPIPHANY_FUNCTION_MESSAGE
;
906 else if (!strcmp (TREE_STRING_POINTER (value
), "dma0"))
907 fn_type
= EPIPHANY_FUNCTION_DMA0
;
908 else if (!strcmp (TREE_STRING_POINTER (value
), "dma1"))
909 fn_type
= EPIPHANY_FUNCTION_DMA1
;
910 else if (!strcmp (TREE_STRING_POINTER (value
), "wand"))
911 fn_type
= EPIPHANY_FUNCTION_WAND
;
912 else if (!strcmp (TREE_STRING_POINTER (value
), "swi"))
913 fn_type
= EPIPHANY_FUNCTION_SWI
;
924 #define RETURN_ADDR_REGNUM GPR_LR
925 #define FRAME_POINTER_MASK (1 << (FRAME_POINTER_REGNUM))
926 #define RETURN_ADDR_MASK (1 << (RETURN_ADDR_REGNUM))
928 /* Tell prologue and epilogue if register REGNO should be saved / restored.
929 The return address and frame pointer are treated separately.
930 Don't consider them here. */
931 #define MUST_SAVE_REGISTER(regno, interrupt_p) \
932 ((df_regs_ever_live_p (regno) \
933 || (interrupt_p && !current_function_is_leaf \
934 && call_used_regs[regno] && !fixed_regs[regno])) \
935 && (!call_used_regs[regno] || regno == GPR_LR \
936 || (interrupt_p && regno != GPR_SP)))
938 #define MUST_SAVE_RETURN_ADDR 0
940 /* Return the bytes needed to compute the frame pointer from the current
943 SIZE is the size needed for local variables. */
946 epiphany_compute_frame_size (int size
/* # of var. bytes allocated. */)
949 unsigned int total_size
, var_size
, args_size
, pretend_size
, reg_size
;
951 enum epiphany_function_type fn_type
;
953 int first_slot
, last_slot
, first_slot_offset
, last_slot_offset
;
959 args_size
= crtl
->outgoing_args_size
;
960 pretend_size
= crtl
->args
.pretend_args_size
;
961 total_size
= args_size
+ var_size
;
963 CLEAR_HARD_REG_SET (gmask
);
965 first_slot_offset
= 0;
967 last_slot_offset
= 0;
968 first_slot_size
= UNITS_PER_WORD
;
970 /* See if this is an interrupt handler. Call used registers must be saved
972 fn_type
= epiphany_compute_function_type (current_function_decl
);
973 interrupt_p
= EPIPHANY_INTERRUPT_P (fn_type
);
975 /* Calculate space needed for registers. */
977 for (regno
= MAX_EPIPHANY_PARM_REGS
- 1; pretend_size
> reg_size
; regno
--)
979 reg_size
+= UNITS_PER_WORD
;
980 SET_HARD_REG_BIT (gmask
, regno
);
981 if (epiphany_stack_offset
- reg_size
== 0)
986 reg_size
+= 2 * UNITS_PER_WORD
;
988 small_slots
= epiphany_stack_offset
/ UNITS_PER_WORD
;
990 if (frame_pointer_needed
)
992 current_frame_info
.need_fp
= 1;
993 if (!interrupt_p
&& first_slot
< 0)
997 current_frame_info
.need_fp
= 0;
998 for (regno
= 0; regno
<= GPR_LAST
; regno
++)
1000 if (MUST_SAVE_REGISTER (regno
, interrupt_p
))
1002 gcc_assert (!TEST_HARD_REG_BIT (gmask
, regno
));
1003 reg_size
+= UNITS_PER_WORD
;
1004 SET_HARD_REG_BIT (gmask
, regno
);
1005 /* FIXME: when optimizing for speed, take schedling into account
1006 when selecting these registers. */
1007 if (regno
== first_slot
)
1008 gcc_assert (regno
== GPR_FP
&& frame_pointer_needed
);
1009 else if (!interrupt_p
&& first_slot
< 0)
1011 else if (last_slot
< 0
1012 && (first_slot
^ regno
) != 1
1013 && (!interrupt_p
|| regno
> GPR_0
+ 1))
1017 if (TEST_HARD_REG_BIT (gmask
, GPR_LR
))
1018 MACHINE_FUNCTION (cfun
)->lr_clobbered
= 1;
1019 /* ??? Could sometimes do better than that. */
1020 current_frame_info
.small_threshold
1021 = (optimize
>= 3 || interrupt_p
? 0
1022 : pretend_size
? small_slots
1023 : 4 + small_slots
- (first_slot
== GPR_FP
));
1025 /* If there might be variables with 64-bit alignment requirement, align the
1026 start of the variables. */
1027 if (var_size
>= 2 * UNITS_PER_WORD
1028 /* We don't want to split a double reg save/restore across two unpaired
1029 stack slots when optimizing. This rounding could be avoided with
1030 more complex reordering of the register saves, but that would seem
1031 to be a lot of code complexity for little gain. */
1032 || (reg_size
> 8 && optimize
))
1033 reg_size
= EPIPHANY_STACK_ALIGN (reg_size
);
1034 if (total_size
+ reg_size
<= (unsigned) epiphany_stack_offset
1036 && current_function_is_leaf
&& !frame_pointer_needed
)
1044 && reg_size
< (unsigned HOST_WIDE_INT
) epiphany_stack_offset
)
1045 reg_size
= epiphany_stack_offset
;
1048 if (total_size
+ reg_size
< 0x3fc)
1050 first_slot_offset
= EPIPHANY_STACK_ALIGN (total_size
+ reg_size
);
1051 first_slot_offset
+= EPIPHANY_STACK_ALIGN (epiphany_stack_offset
);
1056 first_slot_offset
= EPIPHANY_STACK_ALIGN (reg_size
);
1057 last_slot_offset
= EPIPHANY_STACK_ALIGN (total_size
);
1058 last_slot_offset
+= EPIPHANY_STACK_ALIGN (epiphany_stack_offset
);
1060 CLEAR_HARD_REG_BIT (gmask
, last_slot
);
1063 else if (total_size
+ reg_size
< 0x1ffc && first_slot
>= 0)
1065 first_slot_offset
= EPIPHANY_STACK_ALIGN (total_size
+ reg_size
);
1070 if (total_size
+ reg_size
<= (unsigned) epiphany_stack_offset
)
1072 gcc_assert (first_slot
< 0);
1073 gcc_assert (reg_size
== 0);
1074 last_slot_offset
= EPIPHANY_STACK_ALIGN (total_size
+ reg_size
);
1080 ? EPIPHANY_STACK_ALIGN (reg_size
- epiphany_stack_offset
) : 0);
1081 if (!first_slot_offset
)
1083 if (first_slot
!= GPR_FP
|| !current_frame_info
.need_fp
)
1084 last_slot
= first_slot
;
1087 last_slot_offset
= EPIPHANY_STACK_ALIGN (total_size
);
1089 last_slot_offset
+= EPIPHANY_STACK_ALIGN (epiphany_stack_offset
);
1092 CLEAR_HARD_REG_BIT (gmask
, last_slot
);
1095 if (first_slot
>= 0)
1097 CLEAR_HARD_REG_BIT (gmask
, first_slot
);
1098 if (TEST_HARD_REG_BIT (gmask
, first_slot
^ 1)
1099 && epiphany_stack_offset
- pretend_size
>= 2 * UNITS_PER_WORD
)
1101 CLEAR_HARD_REG_BIT (gmask
, first_slot
^ 1);
1102 first_slot_size
= 2 * UNITS_PER_WORD
;
1106 total_size
= first_slot_offset
+ last_slot_offset
;
1109 = (frame_pointer_needed
? first_slot_offset
: (long) total_size
);
1110 if (first_slot
!= GPR_LR
)
1112 int stack_offset
= epiphany_stack_offset
- UNITS_PER_WORD
;
1114 for (regno
= 0; ; regno
++)
1116 if (stack_offset
+ UNITS_PER_WORD
- first_slot_size
== 0
1119 stack_offset
-= first_slot_size
;
1122 else if (regno
== GPR_LR
)
1124 else if TEST_HARD_REG_BIT (gmask
, regno
)
1125 stack_offset
-= UNITS_PER_WORD
;
1127 lr_slot_offset
+= stack_offset
;
1130 /* Save computed information. */
1131 current_frame_info
.total_size
= total_size
;
1132 current_frame_info
.pretend_size
= pretend_size
;
1133 current_frame_info
.var_size
= var_size
;
1134 current_frame_info
.args_size
= args_size
;
1135 current_frame_info
.reg_size
= reg_size
;
1136 COPY_HARD_REG_SET (current_frame_info
.gmask
, gmask
);
1137 current_frame_info
.first_slot
= first_slot
;
1138 current_frame_info
.last_slot
= last_slot
;
1139 current_frame_info
.first_slot_offset
= first_slot_offset
;
1140 current_frame_info
.first_slot_size
= first_slot_size
;
1141 current_frame_info
.last_slot_offset
= last_slot_offset
;
1142 MACHINE_FUNCTION (cfun
)->lr_slot_offset
= lr_slot_offset
;
1144 current_frame_info
.initialized
= reload_completed
;
1146 /* Ok, we're done. */
1150 /* Print operand X (an rtx) in assembler syntax to file FILE.
1151 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1152 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1155 epiphany_print_operand (FILE *file
, rtx x
, int code
)
1160 fputs (epiphany_condition_codes
[get_epiphany_condition_code (x
)], file
);
1163 fputs (epiphany_condition_codes
[EPIPHANY_INVERSE_CONDITION_CODE
1164 (get_epiphany_condition_code (x
))],
1169 current_frame_info
.stld_sz
= 8;
1173 current_frame_info
.stld_sz
= 4;
1177 current_frame_info
.stld_sz
= 2;
1181 fputs (REG_P (x
) ? "jalr " : "bl ", file
);
1185 fprintf (file
, "r%d", epiphany_m1reg
);
1189 /* Do nothing special. */
1193 output_operand_lossage ("invalid operand output code");
1196 switch (GET_CODE (x
))
1202 fputs (reg_names
[REGNO (x
)], file
);
1206 current_frame_info
.stld_sz
= 1;
1209 switch (GET_CODE (addr
))
1212 offset
= GEN_INT (GET_MODE_SIZE (GET_MODE (x
)));
1213 addr
= XEXP (addr
, 0);
1216 offset
= GEN_INT (-GET_MODE_SIZE (GET_MODE (x
)));
1217 addr
= XEXP (addr
, 0);
1220 offset
= XEXP (XEXP (addr
, 1), 1);
1221 addr
= XEXP (addr
, 0);
1227 output_address (addr
);
1232 if (CONST_INT_P (offset
)) switch (GET_MODE_SIZE (GET_MODE (x
)))
1237 offset
= GEN_INT (INTVAL (offset
) >> 3);
1240 offset
= GEN_INT (INTVAL (offset
) >> 2);
1243 offset
= GEN_INT (INTVAL (offset
) >> 1);
1248 output_address (offset
);
1252 /* We handle SFmode constants here as output_addr_const doesn't. */
1253 if (GET_MODE (x
) == SFmode
)
1258 REAL_VALUE_FROM_CONST_DOUBLE (d
, x
);
1259 REAL_VALUE_TO_TARGET_SINGLE (d
, l
);
1260 fprintf (file
, "%s0x%08lx", IMMEDIATE_PREFIX
, l
);
1263 /* Fall through. Let output_addr_const deal with it. */
1265 fprintf(file
,"%s",IMMEDIATE_PREFIX
);
1266 if (code
== 'C' || code
== 'X')
1268 fprintf (file
, "%ld",
1269 (long) (INTVAL (x
) / current_frame_info
.stld_sz
));
1274 output_addr_const (file
, x
);
1279 /* Print a memory address as an operand to reference that memory location. */
1282 epiphany_print_operand_address (FILE *file
, rtx addr
)
1284 register rtx base
, index
= 0;
1287 switch (GET_CODE (addr
))
1290 fputs (reg_names
[REGNO (addr
)], file
);
1293 if (/*???*/ 0 && SYMBOL_REF_FUNCTION_P (addr
))
1295 output_addr_const (file
, addr
);
1299 output_addr_const (file
, addr
);
1303 if (GET_CODE (XEXP (addr
, 0)) == CONST_INT
)
1304 offset
= INTVAL (XEXP (addr
, 0)), base
= XEXP (addr
, 1);
1305 else if (GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1306 offset
= INTVAL (XEXP (addr
, 1)), base
= XEXP (addr
, 0);
1308 base
= XEXP (addr
, 0), index
= XEXP (addr
, 1);
1309 gcc_assert (GET_CODE (base
) == REG
);
1310 fputs (reg_names
[REGNO (base
)], file
);
1314 ** ++rk quirky method to scale offset for ld/str.......
1316 fprintf (file
, ",%s%d", IMMEDIATE_PREFIX
,
1317 offset
/current_frame_info
.stld_sz
);
1321 switch (GET_CODE (index
))
1324 fprintf (file
, ",%s", reg_names
[REGNO (index
)]);
1327 fputc (',', file
), output_addr_const (file
, index
);
1334 case PRE_INC
: case PRE_DEC
: case POST_INC
: case POST_DEC
: case POST_MODIFY
:
1335 /* We shouldn't get here as we've lost the mode of the memory object
1336 (which says how much to inc/dec by. */
1340 output_addr_const (file
, addr
);
1346 epiphany_final_prescan_insn (rtx insn ATTRIBUTE_UNUSED
,
1347 rtx
*opvec ATTRIBUTE_UNUSED
,
1348 int noperands ATTRIBUTE_UNUSED
)
1350 int i
= epiphany_n_nops
;
1351 rtx pat ATTRIBUTE_UNUSED
;
1354 fputs ("\tnop\n", asm_out_file
);
1358 /* Worker function for TARGET_RETURN_IN_MEMORY. */
1361 epiphany_return_in_memory (const_tree type
, const_tree fntype ATTRIBUTE_UNUSED
)
1363 HOST_WIDE_INT size
= int_size_in_bytes (type
);
1365 if (AGGREGATE_TYPE_P (type
)
1366 && (TYPE_MODE (type
) == BLKmode
|| TYPE_NEEDS_CONSTRUCTING (type
)))
1368 return (size
== -1 || size
> 8);
1371 /* For EPIPHANY, All aggregates and arguments greater than 8 bytes are
1372 passed by reference. */
1375 epiphany_pass_by_reference (cumulative_args_t ca ATTRIBUTE_UNUSED
,
1376 enum machine_mode mode
, const_tree type
,
1377 bool named ATTRIBUTE_UNUSED
)
1381 if (AGGREGATE_TYPE_P (type
)
1382 && (mode
== BLKmode
|| TYPE_NEEDS_CONSTRUCTING (type
)))
1390 epiphany_function_value (const_tree ret_type
,
1391 const_tree fn_decl_or_type ATTRIBUTE_UNUSED
,
1392 bool outgoing ATTRIBUTE_UNUSED
)
1394 enum machine_mode mode
;
1396 mode
= TYPE_MODE (ret_type
);
1397 /* We must change the mode like PROMOTE_MODE does.
1398 ??? PROMOTE_MODE is ignored for non-scalar types.
1399 The set of types tested here has to be kept in sync
1400 with the one in explow.c:promote_mode. */
1401 if (GET_MODE_CLASS (mode
) == MODE_INT
1402 && GET_MODE_SIZE (mode
) < 4
1403 && (TREE_CODE (ret_type
) == INTEGER_TYPE
1404 || TREE_CODE (ret_type
) == ENUMERAL_TYPE
1405 || TREE_CODE (ret_type
) == BOOLEAN_TYPE
1406 || TREE_CODE (ret_type
) == OFFSET_TYPE
))
1408 return gen_rtx_REG (mode
, 0);
1412 epiphany_libcall_value (enum machine_mode mode
, const_rtx fun ATTRIBUTE_UNUSED
)
1414 return gen_rtx_REG (mode
, 0);
1418 epiphany_function_value_regno_p (const unsigned int regno ATTRIBUTE_UNUSED
)
1423 /* Fix up invalid option settings. */
1425 epiphany_override_options (void)
1427 if (epiphany_stack_offset
< 4)
1428 error ("stack_offset must be at least 4");
1429 if (epiphany_stack_offset
& 3)
1430 error ("stack_offset must be a multiple of 4");
1431 epiphany_stack_offset
= (epiphany_stack_offset
+ 3) & -4;
1433 /* This needs to be done at start up. It's convenient to do it here. */
1437 /* For a DImode load / store SET, make a SImode set for a
1438 REG_FRAME_RELATED_EXPR note, using OFFSET to create a high or lowpart
1441 frame_subreg_note (rtx set
, int offset
)
1443 rtx src
= simplify_gen_subreg (SImode
, SET_SRC (set
), DImode
, offset
);
1444 rtx dst
= simplify_gen_subreg (SImode
, SET_DEST (set
), DImode
, offset
);
1446 set
= gen_rtx_SET (VOIDmode
, dst
,src
);
1447 RTX_FRAME_RELATED_P (set
) = 1;
1455 rtx note
= NULL_RTX
;
1457 if (GET_CODE (x
) == PARALLEL
)
1459 rtx part
= XVECEXP (x
, 0, 0);
1461 if (GET_MODE (SET_DEST (part
)) == DImode
)
1463 note
= gen_rtx_PARALLEL (VOIDmode
, rtvec_alloc (XVECLEN (x
, 0) + 1));
1464 XVECEXP (note
, 0, 0) = frame_subreg_note (part
, 0);
1465 XVECEXP (note
, 0, 1) = frame_subreg_note (part
, UNITS_PER_WORD
);
1466 for (i
= XVECLEN (x
, 0) - 1; i
>= 1; i
--)
1468 part
= copy_rtx (XVECEXP (x
, 0, i
));
1470 if (GET_CODE (part
) == SET
)
1471 RTX_FRAME_RELATED_P (part
) = 1;
1472 XVECEXP (note
, 0, i
+ 1) = part
;
1477 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
1479 part
= XVECEXP (x
, 0, i
);
1481 if (GET_CODE (part
) == SET
)
1482 RTX_FRAME_RELATED_P (part
) = 1;
1486 else if (GET_CODE (x
) == SET
&& GET_MODE (SET_DEST (x
)) == DImode
)
1487 note
= gen_rtx_PARALLEL (VOIDmode
,
1488 gen_rtvec (2, frame_subreg_note (x
, 0),
1489 frame_subreg_note (x
, UNITS_PER_WORD
)));
1491 RTX_FRAME_RELATED_P (x
) = 1;
1493 add_reg_note (x
, REG_FRAME_RELATED_EXPR
, note
);
1498 frame_move_insn (rtx to
, rtx from
)
1500 return frame_insn (gen_rtx_SET (VOIDmode
, to
, from
));
1503 /* Generate a MEM referring to a varargs argument slot. */
1506 gen_varargs_mem (enum machine_mode mode
, rtx addr
)
1508 rtx mem
= gen_rtx_MEM (mode
, addr
);
1509 MEM_NOTRAP_P (mem
) = 1;
1510 set_mem_alias_set (mem
, get_varargs_alias_set ());
1514 /* Emit instructions to save or restore registers in the range [MIN..LIMIT) .
1515 If EPILOGUE_P is 0, save; if it is one, restore.
1516 ADDR is the stack slot to save the first register to; subsequent
1517 registers are written to lower addresses.
1518 However, the order of register pairs can be reversed in order to
1519 use double-word load-store instructions. Likewise, an unpaired single
1520 word save slot can be skipped while double saves are carried out, and
1521 reused when a single register is to be saved. */
1524 epiphany_emit_save_restore (int min
, int limit
, rtx addr
, int epilogue_p
)
1528 = current_frame_info
.first_slot
>= 0 ? epiphany_stack_offset
: 0;
1529 rtx skipped_mem
= NULL_RTX
;
1530 int last_saved
= limit
- 1;
1533 while (last_saved
>= 0
1534 && !TEST_HARD_REG_BIT (current_frame_info
.gmask
, last_saved
))
1536 for (i
= 0; i
< limit
; i
++)
1538 enum machine_mode mode
= word_mode
;
1541 rtx (*gen_mem
) (enum machine_mode
, rtx
) = gen_frame_mem
;
1543 /* Make sure we push the arguments in the right order. */
1544 if (n
< MAX_EPIPHANY_PARM_REGS
&& crtl
->args
.pretend_args_size
)
1546 n
= MAX_EPIPHANY_PARM_REGS
- 1 - n
;
1547 gen_mem
= gen_varargs_mem
;
1549 if (stack_offset
== current_frame_info
.first_slot_size
1550 && current_frame_info
.first_slot
>= 0)
1552 if (current_frame_info
.first_slot_size
> UNITS_PER_WORD
)
1555 addr
= plus_constant (addr
, - (HOST_WIDE_INT
) UNITS_PER_WORD
);
1557 if (i
-- < min
|| !epilogue_p
)
1559 n
= current_frame_info
.first_slot
;
1560 gen_mem
= gen_frame_mem
;
1562 else if (n
== UNKNOWN_REGNUM
1563 && stack_offset
> current_frame_info
.first_slot_size
)
1568 else if (!TEST_HARD_REG_BIT (current_frame_info
.gmask
, n
))
1573 /* Check for a register pair to save. */
1575 && (n
>= MAX_EPIPHANY_PARM_REGS
|| crtl
->args
.pretend_args_size
== 0)
1576 && (n
& 1) == 0 && n
+1 < limit
1577 && TEST_HARD_REG_BIT (current_frame_info
.gmask
, n
+1))
1579 /* If it fits in the current stack slot pair, place it there. */
1580 if (GET_CODE (addr
) == PLUS
&& (stack_offset
& 7) == 0
1581 && stack_offset
!= 2 * UNITS_PER_WORD
1582 && (current_frame_info
.last_slot
< 0
1583 || INTVAL (XEXP (addr
, 1)) != UNITS_PER_WORD
)
1584 && (n
+1 != last_saved
|| !skipped_mem
))
1588 addr
= plus_constant (addr
, - (HOST_WIDE_INT
) UNITS_PER_WORD
);
1590 /* If it fits in the following stack slot pair, that's fine, too. */
1591 else if (GET_CODE (addr
) == PLUS
&& (stack_offset
& 7) == 4
1592 && stack_offset
!= 2 * UNITS_PER_WORD
1593 && stack_offset
!= 3 * UNITS_PER_WORD
1594 && (current_frame_info
.last_slot
< 0
1595 || INTVAL (XEXP (addr
, 1)) != 2 * UNITS_PER_WORD
)
1596 && n
+ 1 != last_saved
)
1598 gcc_assert (!skipped_mem
);
1599 stack_offset
-= GET_MODE_SIZE (mode
);
1600 skipped_mem
= gen_mem (mode
, addr
);
1603 addr
= plus_constant (addr
, - (HOST_WIDE_INT
) 2 * UNITS_PER_WORD
);
1606 reg
= gen_rtx_REG (mode
, n
);
1607 if (mode
!= DImode
&& skipped_mem
)
1610 mem
= gen_mem (mode
, addr
);
1612 frame_move_insn (mem
, reg
);
1613 else if (n
>= MAX_EPIPHANY_PARM_REGS
|| !crtl
->args
.pretend_args_size
)
1614 emit_move_insn (reg
, mem
);
1615 if (mem
== skipped_mem
)
1617 skipped_mem
= NULL_RTX
;
1621 addr
= plus_constant (addr
, - (HOST_WIDE_INT
) UNITS_PER_WORD
);
1622 stack_offset
-= GET_MODE_SIZE (mode
);
1627 epiphany_expand_prologue (void)
1630 enum epiphany_function_type fn_type
;
1631 rtx addr
, mem
, off
, reg
;
1634 if (!current_frame_info
.initialized
)
1635 epiphany_compute_frame_size (get_frame_size ());
1637 /* It is debatable if we should adjust this by epiphany_stack_offset. */
1638 if (flag_stack_usage_info
)
1639 current_function_static_stack_size
= current_frame_info
.total_size
;
1641 fn_type
= epiphany_compute_function_type (current_function_decl
);
1642 interrupt_p
= EPIPHANY_INTERRUPT_P (fn_type
);
1646 addr
= plus_constant (stack_pointer_rtx
,
1647 - (HOST_WIDE_INT
) 2 * UNITS_PER_WORD
);
1648 frame_move_insn (gen_frame_mem (DImode
, addr
),
1649 gen_rtx_REG (DImode
, GPR_0
));
1650 frame_move_insn (gen_rtx_REG (SImode
, GPR_0
),
1651 gen_rtx_REG (word_mode
, STATUS_REGNUM
));
1652 frame_move_insn (gen_rtx_REG (SImode
, GPR_0
+1),
1653 gen_rtx_REG (word_mode
, IRET_REGNUM
));
1654 mem
= gen_frame_mem (BLKmode
, stack_pointer_rtx
);
1655 off
= GEN_INT (-current_frame_info
.first_slot_offset
);
1656 frame_insn (gen_stack_adjust_add (off
, mem
));
1657 if (!epiphany_uninterruptible_p (current_function_decl
))
1658 emit_insn (gen_gie ());
1659 addr
= plus_constant (stack_pointer_rtx
,
1660 current_frame_info
.first_slot_offset
1661 - (HOST_WIDE_INT
) 3 * UNITS_PER_WORD
);
1665 addr
= plus_constant (stack_pointer_rtx
,
1666 epiphany_stack_offset
1667 - (HOST_WIDE_INT
) UNITS_PER_WORD
);
1668 epiphany_emit_save_restore (0, current_frame_info
.small_threshold
,
1670 /* Allocate register save area; for small to medium size frames,
1671 allocate the entire frame; this is joint with one register save. */
1672 if (current_frame_info
.first_slot
>= 0)
1674 enum machine_mode mode
1675 = (current_frame_info
.first_slot_size
== UNITS_PER_WORD
1676 ? word_mode
: DImode
);
1678 off
= GEN_INT (-current_frame_info
.first_slot_offset
);
1679 mem
= gen_frame_mem (BLKmode
,
1680 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, off
));
1681 frame_insn (gen_stack_adjust_str
1682 (gen_frame_mem (mode
, stack_pointer_rtx
),
1683 gen_rtx_REG (mode
, current_frame_info
.first_slot
),
1685 addr
= plus_constant (addr
, current_frame_info
.first_slot_offset
);
1688 epiphany_emit_save_restore (current_frame_info
.small_threshold
,
1689 FIRST_PSEUDO_REGISTER
, addr
, 0);
1690 if (current_frame_info
.need_fp
)
1691 frame_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
);
1692 /* For large frames, allocate bulk of frame. This is usually joint with one
1694 if (current_frame_info
.last_slot
>= 0)
1696 gcc_assert (current_frame_info
.last_slot
!= GPR_FP
1697 || (!current_frame_info
.need_fp
1698 && current_frame_info
.first_slot
< 0));
1699 off
= GEN_INT (-current_frame_info
.last_slot_offset
);
1700 mem
= gen_frame_mem (BLKmode
,
1701 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, off
));
1702 reg
= gen_rtx_REG (Pmode
, GPR_IP
);
1703 frame_move_insn (reg
, off
);
1704 frame_insn (gen_stack_adjust_str
1705 (gen_frame_mem (word_mode
, stack_pointer_rtx
),
1706 gen_rtx_REG (word_mode
, current_frame_info
.last_slot
),
1709 /* If there is only one or no register to save, yet we have a large frame,
1711 else if (current_frame_info
.last_slot_offset
)
1713 mem
= gen_frame_mem (BLKmode
,
1714 plus_constant (stack_pointer_rtx
,
1715 current_frame_info
.last_slot_offset
));
1716 off
= GEN_INT (-current_frame_info
.last_slot_offset
);
1717 if (!SIMM11 (INTVAL (off
)))
1719 reg
= gen_rtx_REG (Pmode
, GPR_IP
);
1720 frame_move_insn (reg
, off
);
1723 frame_insn (gen_stack_adjust_add (off
, mem
));
1726 /* Mode switching uses get_hard_reg_initial_val after
1727 emit_initial_value_sets, so we have to fix this up now. */
1728 save_config
= has_hard_reg_initial_val (SImode
, CONFIG_REGNUM
);
1731 if (REG_P (save_config
))
1733 if (REGNO (save_config
) >= FIRST_PSEUDO_REGISTER
)
1734 gcc_assert (!df_regs_ever_live_p (REGNO (save_config
)));
1736 frame_move_insn (save_config
,
1737 get_hard_reg_initial_reg (save_config
));
1741 rtx save_dst
= save_config
;
1743 reg
= gen_rtx_REG (SImode
, GPR_IP
);
1744 gcc_assert (MEM_P (save_dst
));
1745 if (!memory_operand (save_dst
, SImode
))
1747 rtx addr
= XEXP (save_dst
, 0);
1748 rtx reg2
= gen_rtx_REG (SImode
, GPR_16
);
1750 gcc_assert (GET_CODE (addr
) == PLUS
);
1751 gcc_assert (XEXP (addr
, 0) == hard_frame_pointer_rtx
1752 || XEXP (addr
, 0) == stack_pointer_rtx
);
1753 emit_move_insn (reg2
, XEXP (addr
, 1));
1755 = replace_equiv_address (save_dst
,
1756 gen_rtx_PLUS (Pmode
, XEXP (addr
, 0),
1759 emit_move_insn (reg
, get_hard_reg_initial_reg (save_config
));
1760 emit_move_insn (save_dst
, reg
);
1766 epiphany_expand_epilogue (int sibcall_p
)
1769 enum epiphany_function_type fn_type
;
1770 rtx mem
, addr
, reg
, off
;
1771 HOST_WIDE_INT restore_offset
;
1773 fn_type
= epiphany_compute_function_type( current_function_decl
);
1774 interrupt_p
= EPIPHANY_INTERRUPT_P (fn_type
);
1776 /* For variable frames, deallocate bulk of frame. */
1777 if (current_frame_info
.need_fp
)
1779 mem
= gen_frame_mem (BLKmode
, stack_pointer_rtx
);
1780 emit_insn (gen_stack_adjust_mov (mem
));
1782 /* Else for large static frames, deallocate bulk of frame. */
1783 else if (current_frame_info
.last_slot_offset
)
1785 mem
= gen_frame_mem (BLKmode
, stack_pointer_rtx
);
1786 reg
= gen_rtx_REG (Pmode
, GPR_IP
);
1787 emit_move_insn (reg
, GEN_INT (current_frame_info
.last_slot_offset
));
1788 emit_insn (gen_stack_adjust_add (reg
, mem
));
1790 restore_offset
= (interrupt_p
1791 ? - 3 * UNITS_PER_WORD
1792 : epiphany_stack_offset
- (HOST_WIDE_INT
) UNITS_PER_WORD
);
1793 addr
= plus_constant (stack_pointer_rtx
,
1794 (current_frame_info
.first_slot_offset
1796 epiphany_emit_save_restore (current_frame_info
.small_threshold
,
1797 FIRST_PSEUDO_REGISTER
, addr
, 1);
1799 if (interrupt_p
&& !epiphany_uninterruptible_p (current_function_decl
))
1800 emit_insn (gen_gid ());
1802 off
= GEN_INT (current_frame_info
.first_slot_offset
);
1803 mem
= gen_frame_mem (BLKmode
, stack_pointer_rtx
);
1804 /* For large / variable size frames, deallocating the register save area is
1805 joint with one register restore; for medium size frames, we use a
1806 dummy post-increment load to dealloacte the whole frame. */
1807 if (!SIMM11 (INTVAL (off
)) || current_frame_info
.last_slot
>= 0)
1809 emit_insn (gen_stack_adjust_ldr
1810 (gen_rtx_REG (word_mode
,
1811 (current_frame_info
.last_slot
>= 0
1812 ? current_frame_info
.last_slot
: GPR_IP
)),
1813 gen_frame_mem (word_mode
, stack_pointer_rtx
),
1817 /* While for small frames, we deallocate the entire frame with one add. */
1818 else if (INTVAL (off
))
1820 emit_insn (gen_stack_adjust_add (off
, mem
));
1824 emit_move_insn (gen_rtx_REG (word_mode
, STATUS_REGNUM
),
1825 gen_rtx_REG (SImode
, GPR_0
));
1826 emit_move_insn (gen_rtx_REG (word_mode
, IRET_REGNUM
),
1827 gen_rtx_REG (SImode
, GPR_0
+1));
1828 addr
= plus_constant (stack_pointer_rtx
,
1829 - (HOST_WIDE_INT
) 2 * UNITS_PER_WORD
);
1830 emit_move_insn (gen_rtx_REG (DImode
, GPR_0
),
1831 gen_frame_mem (DImode
, addr
));
1833 addr
= plus_constant (stack_pointer_rtx
,
1834 epiphany_stack_offset
- (HOST_WIDE_INT
) UNITS_PER_WORD
);
1835 epiphany_emit_save_restore (0, current_frame_info
.small_threshold
, addr
, 1);
1839 emit_jump_insn (gen_return_internal_interrupt());
1841 emit_jump_insn (gen_return_i ());
1846 epiphany_initial_elimination_offset (int from
, int to
)
1848 epiphany_compute_frame_size (get_frame_size ());
1849 if (from
== FRAME_POINTER_REGNUM
&& to
== STACK_POINTER_REGNUM
)
1850 return current_frame_info
.total_size
- current_frame_info
.reg_size
;
1851 if (from
== FRAME_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
1852 return current_frame_info
.first_slot_offset
- current_frame_info
.reg_size
;
1853 if (from
== ARG_POINTER_REGNUM
&& to
== STACK_POINTER_REGNUM
)
1854 return (current_frame_info
.total_size
1855 - ((current_frame_info
.pretend_size
+ 4) & -8));
1856 if (from
== ARG_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
1857 return (current_frame_info
.first_slot_offset
1858 - ((current_frame_info
.pretend_size
+ 4) & -8));
1863 epiphany_issue_rate (void)
1868 /* Function to update the integer COST
1869 based on the relationship between INSN that is dependent on
1870 DEP_INSN through the dependence LINK. The default is to make no
1871 adjustment to COST. This can be used for example to specify to
1872 the scheduler that an output- or anti-dependence does not incur
1873 the same cost as a data-dependence. The return value should be
1874 the new value for COST. */
1876 epiphany_adjust_cost (rtx insn
, rtx link
, rtx dep_insn
, int cost
)
1878 if (REG_NOTE_KIND (link
) == 0)
1882 if (recog_memoized (insn
) < 0
1883 || recog_memoized (dep_insn
) < 0)
1886 dep_set
= single_set (dep_insn
);
1888 /* The latency that we specify in the scheduling description refers
1889 to the actual output, not to an auto-increment register; for that,
1890 the latency is one. */
1891 if (dep_set
&& MEM_P (SET_SRC (dep_set
)) && cost
> 1)
1893 rtx set
= single_set (insn
);
1896 && !reg_mentioned_p (SET_DEST (dep_set
), SET_SRC (set
))
1897 && (!MEM_P (SET_DEST (set
))
1898 || !reg_mentioned_p (SET_DEST (dep_set
),
1899 XEXP (SET_DEST (set
), 0))))
1906 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
1908 #define RTX_OK_FOR_BASE_P(X) \
1909 (REG_P (X) && REG_OK_FOR_BASE_P (X))
1911 #define RTX_OK_FOR_INDEX_P(MODE, X) \
1912 ((GET_MODE_CLASS (MODE) != MODE_VECTOR_INT \
1913 || epiphany_vect_align >= GET_MODE_SIZE (MODE)) \
1914 && (REG_P (X) && REG_OK_FOR_INDEX_P (X)))
1916 #define LEGITIMATE_OFFSET_ADDRESS_P(MODE, X) \
1917 (GET_CODE (X) == PLUS \
1918 && RTX_OK_FOR_BASE_P (XEXP (X, 0)) \
1919 && (RTX_OK_FOR_INDEX_P (MODE, XEXP (X, 1)) \
1920 || RTX_OK_FOR_OFFSET_P (MODE, XEXP (X, 1))))
1923 epiphany_legitimate_address_p (enum machine_mode mode
, rtx x
, bool strict
)
1925 #define REG_OK_FOR_BASE_P(X) \
1926 (strict ? GPR_P (REGNO (X)) : GPR_AP_OR_PSEUDO_P (REGNO (X)))
1927 if (RTX_OK_FOR_BASE_P (x
))
1929 if (RTX_FRAME_OFFSET_P (x
))
1931 if (LEGITIMATE_OFFSET_ADDRESS_P (mode
, x
))
1934 && (GET_CODE (x
) == POST_DEC
|| GET_CODE (x
) == POST_INC
)
1935 && RTX_OK_FOR_BASE_P (XEXP ((x
), 0)))
1937 if ((TARGET_POST_MODIFY
|| reload_completed
)
1938 && GET_CODE (x
) == POST_MODIFY
1939 && GET_CODE (XEXP ((x
), 1)) == PLUS
1940 && rtx_equal_p (XEXP ((x
), 0), XEXP (XEXP ((x
), 1), 0))
1941 && LEGITIMATE_OFFSET_ADDRESS_P (mode
, XEXP ((x
), 1)))
1943 if (mode
== BLKmode
)
1949 epiphany_secondary_reload (bool in_p
, rtx x
, reg_class_t rclass
,
1950 enum machine_mode mode ATTRIBUTE_UNUSED
,
1951 secondary_reload_info
*sri
)
1953 /* This could give more reload inheritance, but we are missing some
1954 reload infrastructure. */
1956 if (in_p
&& GET_CODE (x
) == UNSPEC
1957 && satisfies_constraint_Sra (x
) && !satisfies_constraint_Rra (x
))
1959 gcc_assert (rclass
== GENERAL_REGS
);
1960 sri
->icode
= CODE_FOR_reload_insi_ra
;
1967 epiphany_is_long_call_p (rtx x
)
1969 tree decl
= SYMBOL_REF_DECL (x
);
1970 bool ret_val
= !TARGET_SHORT_CALLS
;
1973 /* ??? Is it safe to default to ret_val if decl is NULL? We should
1974 probably encode information via encode_section_info, and also
1975 have (an) option(s) to take SYMBOL_FLAG_LOCAL and/or SYMBOL_FLAG_EXTERNAL
1979 attrs
= TYPE_ATTRIBUTES (TREE_TYPE (decl
));
1980 if (lookup_attribute ("long_call", attrs
))
1982 else if (lookup_attribute ("short_call", attrs
))
1989 epiphany_small16 (rtx x
)
1992 rtx offs ATTRIBUTE_UNUSED
= const0_rtx
;
1994 if (GET_CODE (x
) == CONST
&& GET_CODE (XEXP (x
, 0)) == PLUS
)
1996 base
= XEXP (XEXP (x
, 0), 0);
1997 offs
= XEXP (XEXP (x
, 0), 1);
1999 if (GET_CODE (base
) == SYMBOL_REF
&& SYMBOL_REF_FUNCTION_P (base
)
2000 && epiphany_is_long_call_p (base
))
2002 return TARGET_SMALL16
!= 0;
2005 /* Return nonzero if it is ok to make a tail-call to DECL. */
2007 epiphany_function_ok_for_sibcall (tree decl
, tree exp
)
2009 bool cfun_interrupt_p
, call_interrupt_p
;
2011 cfun_interrupt_p
= EPIPHANY_INTERRUPT_P (epiphany_compute_function_type
2012 (current_function_decl
));
2014 call_interrupt_p
= EPIPHANY_INTERRUPT_P (epiphany_compute_function_type (decl
));
2017 tree fn_type
= TREE_TYPE (CALL_EXPR_FN (exp
));
2019 gcc_assert (POINTER_TYPE_P (fn_type
));
2020 fn_type
= TREE_TYPE (fn_type
);
2021 gcc_assert (TREE_CODE (fn_type
) == FUNCTION_TYPE
2022 || TREE_CODE (fn_type
) == METHOD_TYPE
);
2024 = lookup_attribute ("interrupt", TYPE_ATTRIBUTES (fn_type
)) != NULL
;
2027 /* Don't tailcall from or to an ISR routine - although we could in
2028 principle tailcall from one ISR routine to another, we'd need to
2029 handle this in sibcall_epilogue to make it work. */
2030 if (cfun_interrupt_p
|| call_interrupt_p
)
2033 /* Everything else is ok. */
2037 /* T is a function declaration or the MEM_EXPR of a MEM passed to a call
2039 Return true iff the type of T has the uninterruptible attribute.
2040 If T is NULL, return false. */
2042 epiphany_uninterruptible_p (tree t
)
2048 attrs
= TYPE_ATTRIBUTES (TREE_TYPE (t
));
2049 if (lookup_attribute ("disinterrupt", attrs
))
2056 epiphany_call_uninterruptible_p (rtx mem
)
2058 rtx addr
= XEXP (mem
, 0);
2061 if (GET_CODE (addr
) == SYMBOL_REF
)
2062 t
= SYMBOL_REF_DECL (addr
);
2065 return epiphany_uninterruptible_p (t
);
2068 static enum machine_mode
2069 epiphany_promote_function_mode (const_tree type
, enum machine_mode mode
,
2070 int *punsignedp ATTRIBUTE_UNUSED
,
2071 const_tree funtype ATTRIBUTE_UNUSED
,
2072 int for_return ATTRIBUTE_UNUSED
)
2076 return promote_mode (type
, mode
, &dummy
);
2080 epiphany_conditional_register_usage (void)
2084 if (PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
)
2086 fixed_regs
[PIC_OFFSET_TABLE_REGNUM
] = 1;
2087 call_used_regs
[PIC_OFFSET_TABLE_REGNUM
] = 1;
2089 if (TARGET_HALF_REG_FILE
)
2091 for (i
= 32; i
<= 63; i
++)
2094 call_used_regs
[i
] = 1;
2097 if (epiphany_m1reg
>= 0)
2099 fixed_regs
[epiphany_m1reg
] = 1;
2100 call_used_regs
[epiphany_m1reg
] = 1;
2102 if (!TARGET_PREFER_SHORT_INSN_REGS
)
2103 CLEAR_HARD_REG_SET (reg_class_contents
[SHORT_INSN_REGS
]);
2104 COPY_HARD_REG_SET (reg_class_contents
[SIBCALL_REGS
],
2105 reg_class_contents
[GENERAL_REGS
]);
2106 /* It would be simpler and quicker if we could just use
2107 AND_COMPL_HARD_REG_SET, alas, call_used_reg_set is yet uninitialized;
2108 it is set up later by our caller. */
2109 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
2110 if (!call_used_regs
[i
])
2111 CLEAR_HARD_REG_BIT (reg_class_contents
[SIBCALL_REGS
], i
);
2114 /* Determine where to put an argument to a function.
2115 Value is zero to push the argument on the stack,
2116 or a hard register in which to store the argument.
2118 MODE is the argument's machine mode.
2119 TYPE is the data type of the argument (as a tree).
2120 This is null for libcalls where that information may
2122 CUM is a variable of type CUMULATIVE_ARGS which gives info about
2123 the preceding args and about the function being called.
2124 NAMED is nonzero if this argument is a named parameter
2125 (otherwise it is an extra parameter matching an ellipsis). */
2126 /* On the EPIPHANY the first MAX_EPIPHANY_PARM_REGS args are normally in
2127 registers and the rest are pushed. */
2129 epiphany_function_arg (cumulative_args_t cum_v
, enum machine_mode mode
,
2130 const_tree type
, bool named ATTRIBUTE_UNUSED
)
2132 CUMULATIVE_ARGS cum
= *get_cumulative_args (cum_v
);
2134 if (PASS_IN_REG_P (cum
, mode
, type
))
2135 return gen_rtx_REG (mode
, ROUND_ADVANCE_CUM (cum
, mode
, type
));
2139 /* Update the data in CUM to advance over an argument
2140 of mode MODE and data type TYPE.
2141 (TYPE is null for libcalls where that information may not be available.) */
2143 epiphany_function_arg_advance (cumulative_args_t cum_v
, enum machine_mode mode
,
2144 const_tree type
, bool named ATTRIBUTE_UNUSED
)
2146 CUMULATIVE_ARGS
*cum
= get_cumulative_args (cum_v
);
2148 *cum
= ROUND_ADVANCE_CUM (*cum
, mode
, type
) + ROUND_ADVANCE_ARG (mode
, type
);
2151 /* Nested function support.
2152 An epiphany trampoline looks like this:
2153 mov r16,%low(fnaddr)
2154 movt r16,%high(fnaddr)
2159 #define EPIPHANY_LOW_RTX(X) \
2160 (gen_rtx_IOR (SImode, \
2161 gen_rtx_ASHIFT (SImode, \
2162 gen_rtx_AND (SImode, (X), GEN_INT (0xff)), GEN_INT (5)), \
2163 gen_rtx_ASHIFT (SImode, \
2164 gen_rtx_AND (SImode, (X), GEN_INT (0xff00)), GEN_INT (12))))
2165 #define EPIPHANY_HIGH_RTX(X) \
2166 EPIPHANY_LOW_RTX (gen_rtx_LSHIFTRT (SImode, (X), GEN_INT (16)))
2168 /* Emit RTL insns to initialize the variable parts of a trampoline.
2169 FNADDR is an RTX for the address of the function's pure code.
2170 CXT is an RTX for the static chain value for the function. */
2172 epiphany_trampoline_init (rtx tramp_mem
, tree fndecl
, rtx cxt
)
2174 rtx fnaddr
= XEXP (DECL_RTL (fndecl
), 0);
2175 rtx tramp
= force_reg (Pmode
, XEXP (tramp_mem
, 0));
2177 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 0)),
2178 gen_rtx_IOR (SImode
, GEN_INT (0x4002000b),
2179 EPIPHANY_LOW_RTX (fnaddr
)));
2180 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 4)),
2181 gen_rtx_IOR (SImode
, GEN_INT (0x5002000b),
2182 EPIPHANY_HIGH_RTX (fnaddr
)));
2183 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 8)),
2184 gen_rtx_IOR (SImode
, GEN_INT (0x2002800b),
2185 EPIPHANY_LOW_RTX (cxt
)));
2186 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 12)),
2187 gen_rtx_IOR (SImode
, GEN_INT (0x3002800b),
2188 EPIPHANY_HIGH_RTX (cxt
)));
2189 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 16)),
2190 GEN_INT (0x0802014f));
2194 epiphany_optimize_mode_switching (int entity
)
2196 if (MACHINE_FUNCTION (cfun
)->sw_entities_processed
& (1 << entity
))
2200 case EPIPHANY_MSW_ENTITY_AND
:
2201 case EPIPHANY_MSW_ENTITY_OR
:
2203 case EPIPHANY_MSW_ENTITY_NEAREST
:
2204 case EPIPHANY_MSW_ENTITY_TRUNC
:
2205 return optimize
> 0;
2206 case EPIPHANY_MSW_ENTITY_ROUND_UNKNOWN
:
2207 return MACHINE_FUNCTION (cfun
)->unknown_mode_uses
!= 0;
2208 case EPIPHANY_MSW_ENTITY_ROUND_KNOWN
:
2209 return (MACHINE_FUNCTION (cfun
)->sw_entities_processed
2210 & (1 << EPIPHANY_MSW_ENTITY_ROUND_UNKNOWN
)) != 0;
2211 case EPIPHANY_MSW_ENTITY_FPU_OMNIBUS
:
2212 return optimize
== 0 || current_pass
== &pass_mode_switch_use
.pass
;
2218 epiphany_mode_priority_to_mode (int entity
, unsigned priority
)
2220 if (entity
== EPIPHANY_MSW_ENTITY_AND
|| entity
== EPIPHANY_MSW_ENTITY_OR
)
2225 case 4: return FP_MODE_ROUND_UNKNOWN
;
2226 case 5: return FP_MODE_NONE
;
2227 default: gcc_unreachable ();
2229 switch ((enum attr_fp_mode
) epiphany_normal_fp_mode
)
2234 case 0: return FP_MODE_INT
;
2235 case 1: return epiphany_normal_fp_rounding
;
2236 case 2: return (epiphany_normal_fp_rounding
== FP_MODE_ROUND_NEAREST
2237 ? FP_MODE_ROUND_TRUNC
: FP_MODE_ROUND_NEAREST
);
2238 case 3: return FP_MODE_CALLER
;
2240 case FP_MODE_ROUND_NEAREST
:
2241 case FP_MODE_CALLER
:
2244 case 0: return FP_MODE_ROUND_NEAREST
;
2245 case 1: return FP_MODE_ROUND_TRUNC
;
2246 case 2: return FP_MODE_INT
;
2247 case 3: return FP_MODE_CALLER
;
2249 case FP_MODE_ROUND_TRUNC
:
2252 case 0: return FP_MODE_ROUND_TRUNC
;
2253 case 1: return FP_MODE_ROUND_NEAREST
;
2254 case 2: return FP_MODE_INT
;
2255 case 3: return FP_MODE_CALLER
;
2257 case FP_MODE_ROUND_UNKNOWN
:
2265 epiphany_mode_needed (int entity
, rtx insn
)
2267 enum attr_fp_mode mode
;
2269 if (recog_memoized (insn
) < 0)
2271 if (entity
== EPIPHANY_MSW_ENTITY_AND
2272 || entity
== EPIPHANY_MSW_ENTITY_OR
)
2274 return FP_MODE_NONE
;
2276 mode
= get_attr_fp_mode (insn
);
2280 case EPIPHANY_MSW_ENTITY_AND
:
2281 return mode
!= FP_MODE_INT
? 1 : 2;
2282 case EPIPHANY_MSW_ENTITY_OR
:
2283 return mode
== FP_MODE_INT
? 1 : 2;
2284 case EPIPHANY_MSW_ENTITY_ROUND_KNOWN
:
2285 if (recog_memoized (insn
) == CODE_FOR_set_fp_mode
)
2286 mode
= (enum attr_fp_mode
) epiphany_mode_after (entity
, mode
, insn
);
2288 case EPIPHANY_MSW_ENTITY_NEAREST
:
2289 case EPIPHANY_MSW_ENTITY_TRUNC
:
2290 if (mode
== FP_MODE_ROUND_UNKNOWN
)
2292 MACHINE_FUNCTION (cfun
)->unknown_mode_uses
++;
2293 return FP_MODE_NONE
;
2296 case EPIPHANY_MSW_ENTITY_ROUND_UNKNOWN
:
2297 if (mode
== FP_MODE_ROUND_NEAREST
|| mode
== FP_MODE_ROUND_TRUNC
)
2298 return FP_MODE_ROUND_UNKNOWN
;
2300 case EPIPHANY_MSW_ENTITY_FPU_OMNIBUS
:
2301 if (mode
== FP_MODE_ROUND_UNKNOWN
)
2302 return epiphany_normal_fp_rounding
;
2310 epiphany_mode_entry_exit (int entity
, bool exit
)
2312 int normal_mode
= epiphany_normal_fp_mode
;
2314 MACHINE_FUNCTION (cfun
)->sw_entities_processed
|= (1 << entity
);
2315 if (epiphany_is_interrupt_p (current_function_decl
))
2316 normal_mode
= FP_MODE_CALLER
;
2319 case EPIPHANY_MSW_ENTITY_AND
:
2321 return normal_mode
!= FP_MODE_INT
? 1 : 2;
2323 case EPIPHANY_MSW_ENTITY_OR
:
2325 return normal_mode
== FP_MODE_INT
? 1 : 2;
2327 case EPIPHANY_MSW_ENTITY_ROUND_UNKNOWN
:
2328 if (normal_mode
== FP_MODE_ROUND_NEAREST
2329 || normal_mode
== FP_MODE_ROUND_TRUNC
)
2330 return FP_MODE_ROUND_UNKNOWN
;
2332 case EPIPHANY_MSW_ENTITY_NEAREST
:
2333 case EPIPHANY_MSW_ENTITY_TRUNC
:
2334 case EPIPHANY_MSW_ENTITY_ROUND_KNOWN
:
2335 case EPIPHANY_MSW_ENTITY_FPU_OMNIBUS
:
2343 epiphany_mode_after (int entity
, int last_mode
, rtx insn
)
2345 /* We have too few call-saved registers to hope to keep the masks across
2347 if (entity
== EPIPHANY_MSW_ENTITY_AND
|| entity
== EPIPHANY_MSW_ENTITY_OR
)
2349 if (GET_CODE (insn
) == CALL_INSN
)
2353 if (recog_memoized (insn
) < 0)
2355 if (get_attr_fp_mode (insn
) == FP_MODE_ROUND_UNKNOWN
2356 && last_mode
!= FP_MODE_ROUND_NEAREST
&& last_mode
!= FP_MODE_ROUND_TRUNC
)
2358 if (entity
== EPIPHANY_MSW_ENTITY_NEAREST
)
2359 return FP_MODE_ROUND_NEAREST
;
2360 if (entity
== EPIPHANY_MSW_ENTITY_TRUNC
)
2361 return FP_MODE_ROUND_TRUNC
;
2363 if (recog_memoized (insn
) == CODE_FOR_set_fp_mode
)
2365 rtx src
= SET_SRC (XVECEXP (PATTERN (insn
), 0, 0));
2369 return FP_MODE_CALLER
;
2370 fp_mode
= INTVAL (XVECEXP (XEXP (src
, 0), 0, 0));
2371 if (entity
== EPIPHANY_MSW_ENTITY_ROUND_UNKNOWN
2372 && (fp_mode
== FP_MODE_ROUND_NEAREST
2373 || fp_mode
== EPIPHANY_MSW_ENTITY_TRUNC
))
2374 return FP_MODE_ROUND_UNKNOWN
;
2381 emit_set_fp_mode (int entity
, int mode
, HARD_REG_SET regs_live ATTRIBUTE_UNUSED
)
2383 rtx save_cc
, cc_reg
, mask
, src
, src2
;
2384 enum attr_fp_mode fp_mode
;
2386 if (!MACHINE_FUNCTION (cfun
)->and_mask
)
2388 MACHINE_FUNCTION (cfun
)->and_mask
= gen_reg_rtx (SImode
);
2389 MACHINE_FUNCTION (cfun
)->or_mask
= gen_reg_rtx (SImode
);
2391 if (entity
== EPIPHANY_MSW_ENTITY_AND
)
2393 gcc_assert (mode
>= 0 && mode
<= 2);
2395 emit_move_insn (MACHINE_FUNCTION (cfun
)->and_mask
,
2396 gen_int_mode (0xfff1fffe, SImode
));
2399 else if (entity
== EPIPHANY_MSW_ENTITY_OR
)
2401 gcc_assert (mode
>= 0 && mode
<= 2);
2403 emit_move_insn (MACHINE_FUNCTION (cfun
)->or_mask
, GEN_INT(0x00080000));
2406 fp_mode
= (enum attr_fp_mode
) mode
;
2411 case FP_MODE_CALLER
:
2412 src
= get_hard_reg_initial_val (SImode
, CONFIG_REGNUM
);
2413 mask
= MACHINE_FUNCTION (cfun
)->and_mask
;
2415 case FP_MODE_ROUND_UNKNOWN
:
2416 MACHINE_FUNCTION (cfun
)->unknown_mode_sets
++;
2417 mask
= MACHINE_FUNCTION (cfun
)->and_mask
;
2419 case FP_MODE_ROUND_NEAREST
:
2420 if (entity
== EPIPHANY_MSW_ENTITY_TRUNC
)
2422 mask
= MACHINE_FUNCTION (cfun
)->and_mask
;
2424 case FP_MODE_ROUND_TRUNC
:
2425 if (entity
== EPIPHANY_MSW_ENTITY_NEAREST
)
2427 mask
= MACHINE_FUNCTION (cfun
)->and_mask
;
2430 mask
= MACHINE_FUNCTION (cfun
)->or_mask
;
2436 save_cc
= gen_reg_rtx (CCmode
);
2437 cc_reg
= gen_rtx_REG (CCmode
, CC_REGNUM
);
2438 emit_move_insn (save_cc
, cc_reg
);
2439 mask
= force_reg (SImode
, mask
);
2442 rtvec v
= gen_rtvec (1, GEN_INT (fp_mode
));
2444 src
= gen_rtx_CONST (SImode
, gen_rtx_UNSPEC (SImode
, v
, UNSPEC_FP_MODE
));
2446 if (entity
== EPIPHANY_MSW_ENTITY_ROUND_KNOWN
2447 || entity
== EPIPHANY_MSW_ENTITY_FPU_OMNIBUS
)
2448 src2
= copy_rtx (src
);
2451 rtvec v
= gen_rtvec (1, GEN_INT (FP_MODE_ROUND_UNKNOWN
));
2453 src2
= gen_rtx_CONST (SImode
, gen_rtx_UNSPEC (SImode
, v
, UNSPEC_FP_MODE
));
2455 emit_insn (gen_set_fp_mode (src
, src2
, mask
));
2456 emit_move_insn (cc_reg
, save_cc
);
2460 epiphany_expand_set_fp_mode (rtx
*operands
)
2462 rtx ctrl
= gen_rtx_REG (SImode
, CONFIG_REGNUM
);
2463 rtx src
= operands
[0];
2464 rtx mask_reg
= operands
[2];
2465 rtx scratch
= operands
[3];
2466 enum attr_fp_mode fp_mode
;
2469 gcc_assert (rtx_equal_p (src
, operands
[1])
2470 /* Sometimes reload gets silly and reloads the same pseudo
2471 into different registers. */
2472 || (REG_P (src
) && REG_P (operands
[1])));
2474 if (!epiphany_uninterruptible_p (current_function_decl
))
2475 emit_insn (gen_gid ());
2476 emit_move_insn (scratch
, ctrl
);
2478 if (GET_CODE (src
) == REG
)
2480 /* FP_MODE_CALLER */
2481 emit_insn (gen_xorsi3 (scratch
, scratch
, src
));
2482 emit_insn (gen_andsi3 (scratch
, scratch
, mask_reg
));
2483 emit_insn (gen_xorsi3 (scratch
, scratch
, src
));
2487 gcc_assert (GET_CODE (src
) == CONST
);
2488 src
= XEXP (src
, 0);
2489 fp_mode
= (enum attr_fp_mode
) INTVAL (XVECEXP (src
, 0, 0));
2492 case FP_MODE_ROUND_NEAREST
:
2493 emit_insn (gen_andsi3 (scratch
, scratch
, mask_reg
));
2495 case FP_MODE_ROUND_TRUNC
:
2496 emit_insn (gen_andsi3 (scratch
, scratch
, mask_reg
));
2497 emit_insn (gen_add2_insn (scratch
, const1_rtx
));
2500 emit_insn (gen_iorsi3 (scratch
, scratch
, mask_reg
));
2502 case FP_MODE_CALLER
:
2503 case FP_MODE_ROUND_UNKNOWN
:
2508 emit_move_insn (ctrl
, scratch
);
2509 if (!epiphany_uninterruptible_p (current_function_decl
))
2510 emit_insn (gen_gie ());
2514 epiphany_insert_mode_switch_use (rtx insn
,
2515 int entity ATTRIBUTE_UNUSED
,
2516 int mode ATTRIBUTE_UNUSED
)
2518 rtx pat
= PATTERN (insn
);
2521 rtx near
= gen_rtx_REG (SImode
, FP_NEAREST_REGNUM
);
2522 rtx trunc
= gen_rtx_REG (SImode
, FP_TRUNCATE_REGNUM
);
2524 if (entity
!= EPIPHANY_MSW_ENTITY_FPU_OMNIBUS
)
2526 switch ((enum attr_fp_mode
) get_attr_fp_mode (insn
))
2528 case FP_MODE_ROUND_NEAREST
:
2529 near
= gen_rtx_USE (VOIDmode
, near
);
2530 trunc
= gen_rtx_CLOBBER (VOIDmode
, trunc
);
2532 case FP_MODE_ROUND_TRUNC
:
2533 near
= gen_rtx_CLOBBER (VOIDmode
, near
);
2534 trunc
= gen_rtx_USE (VOIDmode
, trunc
);
2536 case FP_MODE_ROUND_UNKNOWN
:
2537 near
= gen_rtx_USE (VOIDmode
, gen_rtx_REG (SImode
, FP_ANYFP_REGNUM
));
2538 trunc
= copy_rtx (near
);
2541 case FP_MODE_CALLER
:
2542 near
= gen_rtx_USE (VOIDmode
, near
);
2543 trunc
= gen_rtx_USE (VOIDmode
, trunc
);
2548 gcc_assert (GET_CODE (pat
) == PARALLEL
);
2549 len
= XVECLEN (pat
, 0);
2550 v
= rtvec_alloc (len
+ 2);
2551 for (i
= 0; i
< len
; i
++)
2552 RTVEC_ELT (v
, i
) = XVECEXP (pat
, 0, i
);
2553 RTVEC_ELT (v
, len
) = near
;
2554 RTVEC_ELT (v
, len
+ 1) = trunc
;
2555 pat
= gen_rtx_PARALLEL (VOIDmode
, v
);
2556 PATTERN (insn
) = pat
;
2557 MACHINE_FUNCTION (cfun
)->control_use_inserted
= true;
2561 epiphany_epilogue_uses (int regno
)
2563 if (regno
== GPR_LR
)
2565 if (reload_completed
&& epiphany_is_interrupt_p (current_function_decl
))
2567 if (fixed_regs
[regno
]
2568 && regno
!= STATUS_REGNUM
&& regno
!= IRET_REGNUM
2569 && regno
!= FP_NEAREST_REGNUM
&& regno
!= FP_TRUNCATE_REGNUM
)
2573 if (regno
== FP_NEAREST_REGNUM
2574 && epiphany_normal_fp_mode
!= FP_MODE_ROUND_TRUNC
)
2576 if (regno
== FP_TRUNCATE_REGNUM
2577 && epiphany_normal_fp_mode
!= FP_MODE_ROUND_NEAREST
)
2583 epiphany_min_divisions_for_recip_mul (enum machine_mode mode
)
2585 if (flag_reciprocal_math
&& mode
== SFmode
)
2586 /* We'll expand into a multiply-by-reciprocal anyway, so we might a well do
2587 it already at the tree level and expose it to further optimizations. */
2589 return default_min_divisions_for_recip_mul (mode
);
2592 static enum machine_mode
2593 epiphany_preferred_simd_mode (enum machine_mode mode ATTRIBUTE_UNUSED
)
2595 return TARGET_VECT_DOUBLE
? DImode
: SImode
;
2599 epiphany_vector_mode_supported_p (enum machine_mode mode
)
2601 if (mode
== V2SFmode
)
2603 if (GET_MODE_CLASS (mode
) == MODE_VECTOR_INT
2604 && (GET_MODE_SIZE (mode
) == 4 || GET_MODE_SIZE (mode
) == 8))
2610 epiphany_vector_alignment_reachable (const_tree type
, bool is_packed
)
2612 /* Vectors which aren't in packed structures will not be less aligned than
2613 the natural alignment of their element type, so this is safe. */
2614 if (TYPE_ALIGN_UNIT (type
) == 4)
2617 return default_builtin_vector_alignment_reachable (type
, is_packed
);
2621 epiphany_support_vector_misalignment (enum machine_mode mode
, const_tree type
,
2622 int misalignment
, bool is_packed
)
2624 if (GET_MODE_SIZE (mode
) == 8 && misalignment
% 4 == 0)
2626 return default_builtin_support_vector_misalignment (mode
, type
, misalignment
,
2630 /* STRUCTURE_SIZE_BOUNDARY seems a bit crude in how it enlarges small
2631 structs. Make structs double-word-aligned it they are a double word or
2632 (potentially) larger; failing that, do the same for a size of 32 bits. */
2634 epiphany_special_round_type_align (tree type
, unsigned computed
,
2637 unsigned align
= MAX (computed
, specified
);
2639 HOST_WIDE_INT total
, max
;
2640 unsigned try_align
= FASTEST_ALIGNMENT
;
2642 if (maximum_field_alignment
&& try_align
> maximum_field_alignment
)
2643 try_align
= maximum_field_alignment
;
2644 if (align
>= try_align
)
2646 for (max
= 0, field
= TYPE_FIELDS (type
); field
; field
= DECL_CHAIN (field
))
2650 if (TREE_CODE (field
) != FIELD_DECL
2651 || TREE_TYPE (field
) == error_mark_node
)
2653 offset
= bit_position (field
);
2654 size
= DECL_SIZE (field
);
2655 if (!host_integerp (offset
, 1) || !host_integerp (size
, 1)
2656 || TREE_INT_CST_LOW (offset
) >= try_align
2657 || TREE_INT_CST_LOW (size
) >= try_align
)
2659 total
= TREE_INT_CST_LOW (offset
) + TREE_INT_CST_LOW (size
);
2663 if (max
>= (HOST_WIDE_INT
) try_align
)
2665 else if (try_align
> 32 && max
>= 32)
2666 align
= max
> 32 ? 64 : 32;
2670 /* Upping the alignment of arrays in structs is not only a performance
2671 enhancement, it also helps preserve assumptions about how
2672 arrays-at-the-end-of-structs work, like for struct gcov_fn_info in
2675 epiphany_adjust_field_align (tree field
, unsigned computed
)
2678 && TREE_CODE (TREE_TYPE (field
)) == ARRAY_TYPE
)
2680 tree elmsz
= TYPE_SIZE (TREE_TYPE (TREE_TYPE (field
)));
2682 if (!host_integerp (elmsz
, 1) || tree_low_cst (elmsz
, 1) >= 32)
2688 /* Output code to add DELTA to the first argument, and then jump
2689 to FUNCTION. Used for C++ multiple inheritance. */
2691 epiphany_output_mi_thunk (FILE *file
, tree thunk ATTRIBUTE_UNUSED
,
2692 HOST_WIDE_INT delta
,
2693 HOST_WIDE_INT vcall_offset
,
2697 = aggregate_value_p (TREE_TYPE (TREE_TYPE (function
)), function
) ? 1 : 0;
2698 const char *this_name
= reg_names
[this_regno
];
2701 /* We use IP and R16 as a scratch registers. */
2702 gcc_assert (call_used_regs
[GPR_IP
]);
2703 gcc_assert (call_used_regs
[GPR_16
]);
2705 /* Add DELTA. When possible use a plain add, otherwise load it into
2706 a register first. */
2709 else if (SIMM11 (delta
))
2710 asm_fprintf (file
, "\tadd\t%s,%s,%d\n", this_name
, this_name
, (int) delta
);
2711 else if (delta
< 0 && delta
>= -0xffff)
2713 asm_fprintf (file
, "\tmov\tip,%d\n", (int) -delta
);
2714 asm_fprintf (file
, "\tsub\t%s,%s,ip\n", this_name
, this_name
);
2718 asm_fprintf (file
, "\tmov\tip,%%low(%ld)\n", (long) delta
);
2719 if (delta
& ~0xffff)
2720 asm_fprintf (file
, "\tmovt\tip,%%high(%ld)\n", (long) delta
);
2721 asm_fprintf (file
, "\tadd\t%s,%s,ip\n", this_name
, this_name
);
2724 /* If needed, add *(*THIS + VCALL_OFFSET) to THIS. */
2725 if (vcall_offset
!= 0)
2727 /* ldr ip,[this] --> temp = *this
2728 ldr ip,[ip,vcall_offset] > temp = *(*this + vcall_offset)
2729 add this,this,ip --> this+ = *(*this + vcall_offset) */
2730 asm_fprintf (file
, "\tldr\tip, [%s]\n", this_name
);
2731 if (vcall_offset
< -0x7ff * 4 || vcall_offset
> 0x7ff * 4
2732 || (vcall_offset
& 3) != 0)
2734 asm_fprintf (file
, "\tmov\tr16, %%low(%ld)\n", (long) vcall_offset
);
2735 asm_fprintf (file
, "\tmovt\tr16, %%high(%ld)\n", (long) vcall_offset
);
2736 asm_fprintf (file
, "\tldr\tip, [ip,r16]\n");
2739 asm_fprintf (file
, "\tldr\tip, [ip,%d]\n", (int) vcall_offset
/ 4);
2740 asm_fprintf (file
, "\tadd\t%s, %s, ip\n", this_name
, this_name
);
2743 fname
= XSTR (XEXP (DECL_RTL (function
), 0), 0);
2744 if (epiphany_is_long_call_p (XEXP (DECL_RTL (function
), 0)))
2746 fputs ("\tmov\tip,%low(", file
);
2747 assemble_name (file
, fname
);
2748 fputs (")\n\tmovt\tip,%high(", file
);
2749 assemble_name (file
, fname
);
2750 fputs (")\n\tjr ip\n", file
);
2754 fputs ("\tb\t", file
);
2755 assemble_name (file
, fname
);
2761 epiphany_start_function (FILE *file
, const char *name
, tree decl
)
2763 tree attrs
, int_attr
;
2765 attrs
= DECL_ATTRIBUTES (decl
);
2766 int_attr
= lookup_attribute ("interrupt", attrs
);
2772 int_attr
= TREE_VALUE (TREE_VALUE (int_attr
));
2773 sprintf (buf
, "ivt_entry_%.80s", TREE_STRING_POINTER (int_attr
));
2774 switch_to_section (get_section (buf
, SECTION_CODE
, decl
));
2775 fname
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
2776 fputs ("\tb\t", file
);
2777 assemble_name (file
, fname
);
2779 switch_to_section (function_section (decl
));
2781 ASM_OUTPUT_FUNCTION_LABEL (file
, name
, decl
);
2784 struct gcc_target targetm
= TARGET_INITIALIZER
;