| 1 |
709 |
jeremybenn |
/* Definitions for GCC. Part of the machine description for CRIS.
|
| 2 |
|
|
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
| 3 |
|
|
2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
| 4 |
|
|
Contributed by Axis Communications. Written by Hans-Peter Nilsson.
|
| 5 |
|
|
|
| 6 |
|
|
This file is part of GCC.
|
| 7 |
|
|
|
| 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)
|
| 11 |
|
|
any later version.
|
| 12 |
|
|
|
| 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.
|
| 17 |
|
|
|
| 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/>. */
|
| 21 |
|
|
|
| 22 |
|
|
#include "config.h"
|
| 23 |
|
|
#include "system.h"
|
| 24 |
|
|
#include "coretypes.h"
|
| 25 |
|
|
#include "tm.h"
|
| 26 |
|
|
#include "rtl.h"
|
| 27 |
|
|
#include "regs.h"
|
| 28 |
|
|
#include "hard-reg-set.h"
|
| 29 |
|
|
#include "insn-config.h"
|
| 30 |
|
|
#include "conditions.h"
|
| 31 |
|
|
#include "insn-attr.h"
|
| 32 |
|
|
#include "flags.h"
|
| 33 |
|
|
#include "tree.h"
|
| 34 |
|
|
#include "expr.h"
|
| 35 |
|
|
#include "except.h"
|
| 36 |
|
|
#include "function.h"
|
| 37 |
|
|
#include "diagnostic-core.h"
|
| 38 |
|
|
#include "recog.h"
|
| 39 |
|
|
#include "reload.h"
|
| 40 |
|
|
#include "tm_p.h"
|
| 41 |
|
|
#include "debug.h"
|
| 42 |
|
|
#include "output.h"
|
| 43 |
|
|
#include "tm-constrs.h"
|
| 44 |
|
|
#include "target.h"
|
| 45 |
|
|
#include "target-def.h"
|
| 46 |
|
|
#include "ggc.h"
|
| 47 |
|
|
#include "optabs.h"
|
| 48 |
|
|
#include "df.h"
|
| 49 |
|
|
#include "opts.h"
|
| 50 |
|
|
|
| 51 |
|
|
/* Usable when we have an amount to add or subtract, and want the
|
| 52 |
|
|
optimal size of the insn. */
|
| 53 |
|
|
#define ADDITIVE_SIZE_MODIFIER(size) \
|
| 54 |
|
|
((size) <= 63 ? "q" : (size) <= 255 ? "u.b" : (size) <= 65535 ? "u.w" : ".d")
|
| 55 |
|
|
|
| 56 |
|
|
#define LOSE_AND_RETURN(msgid, x) \
|
| 57 |
|
|
do \
|
| 58 |
|
|
{ \
|
| 59 |
|
|
cris_operand_lossage (msgid, x); \
|
| 60 |
|
|
return; \
|
| 61 |
|
|
} while (0)
|
| 62 |
|
|
|
| 63 |
|
|
enum cris_retinsn_type
|
| 64 |
|
|
{ CRIS_RETINSN_UNKNOWN = 0, CRIS_RETINSN_RET, CRIS_RETINSN_JUMP };
|
| 65 |
|
|
|
| 66 |
|
|
/* Per-function machine data. */
|
| 67 |
|
|
struct GTY(()) machine_function
|
| 68 |
|
|
{
|
| 69 |
|
|
int needs_return_address_on_stack;
|
| 70 |
|
|
|
| 71 |
|
|
/* This is the number of registers we save in the prologue due to
|
| 72 |
|
|
stdarg. */
|
| 73 |
|
|
int stdarg_regs;
|
| 74 |
|
|
|
| 75 |
|
|
enum cris_retinsn_type return_type;
|
| 76 |
|
|
};
|
| 77 |
|
|
|
| 78 |
|
|
/* This little fix suppresses the 'u' or 's' when '%e' in assembly
|
| 79 |
|
|
pattern. */
|
| 80 |
|
|
static char cris_output_insn_is_bound = 0;
|
| 81 |
|
|
|
| 82 |
|
|
/* In code for output macros, this is how we know whether e.g. constant
|
| 83 |
|
|
goes in code or in a static initializer. */
|
| 84 |
|
|
static int in_code = 0;
|
| 85 |
|
|
|
| 86 |
|
|
/* Fix for reg_overlap_mentioned_p. */
|
| 87 |
|
|
static int cris_reg_overlap_mentioned_p (rtx, rtx);
|
| 88 |
|
|
|
| 89 |
|
|
static enum machine_mode cris_promote_function_mode (const_tree, enum machine_mode,
|
| 90 |
|
|
int *, const_tree, int);
|
| 91 |
|
|
|
| 92 |
|
|
static void cris_print_base (rtx, FILE *);
|
| 93 |
|
|
|
| 94 |
|
|
static void cris_print_index (rtx, FILE *);
|
| 95 |
|
|
|
| 96 |
|
|
static void cris_output_addr_const (FILE *, rtx);
|
| 97 |
|
|
|
| 98 |
|
|
static struct machine_function * cris_init_machine_status (void);
|
| 99 |
|
|
|
| 100 |
|
|
static rtx cris_struct_value_rtx (tree, int);
|
| 101 |
|
|
|
| 102 |
|
|
static void cris_setup_incoming_varargs (cumulative_args_t, enum machine_mode,
|
| 103 |
|
|
tree type, int *, int);
|
| 104 |
|
|
|
| 105 |
|
|
static int cris_initial_frame_pointer_offset (void);
|
| 106 |
|
|
|
| 107 |
|
|
static void cris_operand_lossage (const char *, rtx);
|
| 108 |
|
|
|
| 109 |
|
|
static int cris_reg_saved_in_regsave_area (unsigned int, bool);
|
| 110 |
|
|
|
| 111 |
|
|
static void cris_print_operand (FILE *, rtx, int);
|
| 112 |
|
|
|
| 113 |
|
|
static void cris_print_operand_address (FILE *, rtx);
|
| 114 |
|
|
|
| 115 |
|
|
static bool cris_print_operand_punct_valid_p (unsigned char code);
|
| 116 |
|
|
|
| 117 |
|
|
static bool cris_output_addr_const_extra (FILE *, rtx);
|
| 118 |
|
|
|
| 119 |
|
|
static void cris_conditional_register_usage (void);
|
| 120 |
|
|
|
| 121 |
|
|
static void cris_asm_output_mi_thunk
|
| 122 |
|
|
(FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);
|
| 123 |
|
|
|
| 124 |
|
|
static void cris_file_start (void);
|
| 125 |
|
|
static void cris_init_libfuncs (void);
|
| 126 |
|
|
|
| 127 |
|
|
static reg_class_t cris_preferred_reload_class (rtx, reg_class_t);
|
| 128 |
|
|
|
| 129 |
|
|
static bool cris_legitimate_address_p (enum machine_mode, rtx, bool);
|
| 130 |
|
|
|
| 131 |
|
|
static int cris_register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
|
| 132 |
|
|
static int cris_memory_move_cost (enum machine_mode, reg_class_t, bool);
|
| 133 |
|
|
static bool cris_rtx_costs (rtx, int, int, int, int *, bool);
|
| 134 |
|
|
static int cris_address_cost (rtx, bool);
|
| 135 |
|
|
static bool cris_pass_by_reference (cumulative_args_t, enum machine_mode,
|
| 136 |
|
|
const_tree, bool);
|
| 137 |
|
|
static int cris_arg_partial_bytes (cumulative_args_t, enum machine_mode,
|
| 138 |
|
|
tree, bool);
|
| 139 |
|
|
static rtx cris_function_arg (cumulative_args_t, enum machine_mode,
|
| 140 |
|
|
const_tree, bool);
|
| 141 |
|
|
static rtx cris_function_incoming_arg (cumulative_args_t,
|
| 142 |
|
|
enum machine_mode, const_tree, bool);
|
| 143 |
|
|
static void cris_function_arg_advance (cumulative_args_t, enum machine_mode,
|
| 144 |
|
|
const_tree, bool);
|
| 145 |
|
|
static tree cris_md_asm_clobbers (tree, tree, tree);
|
| 146 |
|
|
|
| 147 |
|
|
static void cris_option_override (void);
|
| 148 |
|
|
|
| 149 |
|
|
static bool cris_frame_pointer_required (void);
|
| 150 |
|
|
|
| 151 |
|
|
static void cris_asm_trampoline_template (FILE *);
|
| 152 |
|
|
static void cris_trampoline_init (rtx, tree, rtx);
|
| 153 |
|
|
|
| 154 |
|
|
static rtx cris_function_value(const_tree, const_tree, bool);
|
| 155 |
|
|
static rtx cris_libcall_value (enum machine_mode, const_rtx);
|
| 156 |
|
|
static bool cris_function_value_regno_p (const unsigned int);
|
| 157 |
|
|
|
| 158 |
|
|
/* This is the parsed result of the "-max-stack-stackframe=" option. If
|
| 159 |
|
|
it (still) is zero, then there was no such option given. */
|
| 160 |
|
|
int cris_max_stackframe = 0;
|
| 161 |
|
|
|
| 162 |
|
|
/* This is the parsed result of the "-march=" option, if given. */
|
| 163 |
|
|
int cris_cpu_version = CRIS_DEFAULT_CPU_VERSION;
|
| 164 |
|
|
|
| 165 |
|
|
#undef TARGET_ASM_ALIGNED_HI_OP
|
| 166 |
|
|
#define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
|
| 167 |
|
|
#undef TARGET_ASM_ALIGNED_SI_OP
|
| 168 |
|
|
#define TARGET_ASM_ALIGNED_SI_OP "\t.dword\t"
|
| 169 |
|
|
#undef TARGET_ASM_ALIGNED_DI_OP
|
| 170 |
|
|
#define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
|
| 171 |
|
|
|
| 172 |
|
|
/* We need to define these, since the 2byte, 4byte, 8byte op:s are only
|
| 173 |
|
|
available in ELF. These "normal" pseudos do not have any alignment
|
| 174 |
|
|
constraints or side-effects. */
|
| 175 |
|
|
#undef TARGET_ASM_UNALIGNED_HI_OP
|
| 176 |
|
|
#define TARGET_ASM_UNALIGNED_HI_OP TARGET_ASM_ALIGNED_HI_OP
|
| 177 |
|
|
|
| 178 |
|
|
#undef TARGET_ASM_UNALIGNED_SI_OP
|
| 179 |
|
|
#define TARGET_ASM_UNALIGNED_SI_OP TARGET_ASM_ALIGNED_SI_OP
|
| 180 |
|
|
|
| 181 |
|
|
#undef TARGET_ASM_UNALIGNED_DI_OP
|
| 182 |
|
|
#define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP
|
| 183 |
|
|
|
| 184 |
|
|
#undef TARGET_PRINT_OPERAND
|
| 185 |
|
|
#define TARGET_PRINT_OPERAND cris_print_operand
|
| 186 |
|
|
#undef TARGET_PRINT_OPERAND_ADDRESS
|
| 187 |
|
|
#define TARGET_PRINT_OPERAND_ADDRESS cris_print_operand_address
|
| 188 |
|
|
#undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
|
| 189 |
|
|
#define TARGET_PRINT_OPERAND_PUNCT_VALID_P cris_print_operand_punct_valid_p
|
| 190 |
|
|
#undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
|
| 191 |
|
|
#define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA cris_output_addr_const_extra
|
| 192 |
|
|
|
| 193 |
|
|
#undef TARGET_CONDITIONAL_REGISTER_USAGE
|
| 194 |
|
|
#define TARGET_CONDITIONAL_REGISTER_USAGE cris_conditional_register_usage
|
| 195 |
|
|
|
| 196 |
|
|
#undef TARGET_ASM_OUTPUT_MI_THUNK
|
| 197 |
|
|
#define TARGET_ASM_OUTPUT_MI_THUNK cris_asm_output_mi_thunk
|
| 198 |
|
|
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
|
| 199 |
|
|
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
|
| 200 |
|
|
|
| 201 |
|
|
#undef TARGET_ASM_FILE_START
|
| 202 |
|
|
#define TARGET_ASM_FILE_START cris_file_start
|
| 203 |
|
|
|
| 204 |
|
|
#undef TARGET_INIT_LIBFUNCS
|
| 205 |
|
|
#define TARGET_INIT_LIBFUNCS cris_init_libfuncs
|
| 206 |
|
|
|
| 207 |
|
|
#undef TARGET_LEGITIMATE_ADDRESS_P
|
| 208 |
|
|
#define TARGET_LEGITIMATE_ADDRESS_P cris_legitimate_address_p
|
| 209 |
|
|
|
| 210 |
|
|
#undef TARGET_PREFERRED_RELOAD_CLASS
|
| 211 |
|
|
#define TARGET_PREFERRED_RELOAD_CLASS cris_preferred_reload_class
|
| 212 |
|
|
|
| 213 |
|
|
#undef TARGET_REGISTER_MOVE_COST
|
| 214 |
|
|
#define TARGET_REGISTER_MOVE_COST cris_register_move_cost
|
| 215 |
|
|
#undef TARGET_MEMORY_MOVE_COST
|
| 216 |
|
|
#define TARGET_MEMORY_MOVE_COST cris_memory_move_cost
|
| 217 |
|
|
#undef TARGET_RTX_COSTS
|
| 218 |
|
|
#define TARGET_RTX_COSTS cris_rtx_costs
|
| 219 |
|
|
#undef TARGET_ADDRESS_COST
|
| 220 |
|
|
#define TARGET_ADDRESS_COST cris_address_cost
|
| 221 |
|
|
|
| 222 |
|
|
#undef TARGET_PROMOTE_FUNCTION_MODE
|
| 223 |
|
|
#define TARGET_PROMOTE_FUNCTION_MODE cris_promote_function_mode
|
| 224 |
|
|
|
| 225 |
|
|
#undef TARGET_STRUCT_VALUE_RTX
|
| 226 |
|
|
#define TARGET_STRUCT_VALUE_RTX cris_struct_value_rtx
|
| 227 |
|
|
#undef TARGET_SETUP_INCOMING_VARARGS
|
| 228 |
|
|
#define TARGET_SETUP_INCOMING_VARARGS cris_setup_incoming_varargs
|
| 229 |
|
|
#undef TARGET_PASS_BY_REFERENCE
|
| 230 |
|
|
#define TARGET_PASS_BY_REFERENCE cris_pass_by_reference
|
| 231 |
|
|
#undef TARGET_ARG_PARTIAL_BYTES
|
| 232 |
|
|
#define TARGET_ARG_PARTIAL_BYTES cris_arg_partial_bytes
|
| 233 |
|
|
#undef TARGET_FUNCTION_ARG
|
| 234 |
|
|
#define TARGET_FUNCTION_ARG cris_function_arg
|
| 235 |
|
|
#undef TARGET_FUNCTION_INCOMING_ARG
|
| 236 |
|
|
#define TARGET_FUNCTION_INCOMING_ARG cris_function_incoming_arg
|
| 237 |
|
|
#undef TARGET_FUNCTION_ARG_ADVANCE
|
| 238 |
|
|
#define TARGET_FUNCTION_ARG_ADVANCE cris_function_arg_advance
|
| 239 |
|
|
#undef TARGET_MD_ASM_CLOBBERS
|
| 240 |
|
|
#define TARGET_MD_ASM_CLOBBERS cris_md_asm_clobbers
|
| 241 |
|
|
#undef TARGET_FRAME_POINTER_REQUIRED
|
| 242 |
|
|
#define TARGET_FRAME_POINTER_REQUIRED cris_frame_pointer_required
|
| 243 |
|
|
|
| 244 |
|
|
#undef TARGET_OPTION_OVERRIDE
|
| 245 |
|
|
#define TARGET_OPTION_OVERRIDE cris_option_override
|
| 246 |
|
|
|
| 247 |
|
|
#undef TARGET_ASM_TRAMPOLINE_TEMPLATE
|
| 248 |
|
|
#define TARGET_ASM_TRAMPOLINE_TEMPLATE cris_asm_trampoline_template
|
| 249 |
|
|
#undef TARGET_TRAMPOLINE_INIT
|
| 250 |
|
|
#define TARGET_TRAMPOLINE_INIT cris_trampoline_init
|
| 251 |
|
|
|
| 252 |
|
|
#undef TARGET_FUNCTION_VALUE
|
| 253 |
|
|
#define TARGET_FUNCTION_VALUE cris_function_value
|
| 254 |
|
|
#undef TARGET_LIBCALL_VALUE
|
| 255 |
|
|
#define TARGET_LIBCALL_VALUE cris_libcall_value
|
| 256 |
|
|
#undef TARGET_FUNCTION_VALUE_REGNO_P
|
| 257 |
|
|
#define TARGET_FUNCTION_VALUE_REGNO_P cris_function_value_regno_p
|
| 258 |
|
|
|
| 259 |
|
|
struct gcc_target targetm = TARGET_INITIALIZER;
|
| 260 |
|
|
|
| 261 |
|
|
/* Helper for cris_load_multiple_op and cris_ret_movem_op. */
|
| 262 |
|
|
|
| 263 |
|
|
bool
|
| 264 |
|
|
cris_movem_load_rest_p (rtx op, int offs)
|
| 265 |
|
|
{
|
| 266 |
|
|
unsigned int reg_count = XVECLEN (op, 0) - offs;
|
| 267 |
|
|
rtx src_addr;
|
| 268 |
|
|
int i;
|
| 269 |
|
|
rtx elt;
|
| 270 |
|
|
int setno;
|
| 271 |
|
|
int regno_dir = 1;
|
| 272 |
|
|
unsigned int regno = 0;
|
| 273 |
|
|
|
| 274 |
|
|
/* Perform a quick check so we don't blow up below. FIXME: Adjust for
|
| 275 |
|
|
other than (MEM reg). */
|
| 276 |
|
|
if (reg_count <= 1
|
| 277 |
|
|
|| GET_CODE (XVECEXP (op, 0, offs)) != SET
|
| 278 |
|
|
|| !REG_P (SET_DEST (XVECEXP (op, 0, offs)))
|
| 279 |
|
|
|| !MEM_P (SET_SRC (XVECEXP (op, 0, offs))))
|
| 280 |
|
|
return false;
|
| 281 |
|
|
|
| 282 |
|
|
/* Check a possible post-inc indicator. */
|
| 283 |
|
|
if (GET_CODE (SET_SRC (XVECEXP (op, 0, offs + 1))) == PLUS)
|
| 284 |
|
|
{
|
| 285 |
|
|
rtx reg = XEXP (SET_SRC (XVECEXP (op, 0, offs + 1)), 0);
|
| 286 |
|
|
rtx inc = XEXP (SET_SRC (XVECEXP (op, 0, offs + 1)), 1);
|
| 287 |
|
|
|
| 288 |
|
|
reg_count--;
|
| 289 |
|
|
|
| 290 |
|
|
if (reg_count == 1
|
| 291 |
|
|
|| !REG_P (reg)
|
| 292 |
|
|
|| !REG_P (SET_DEST (XVECEXP (op, 0, offs + 1)))
|
| 293 |
|
|
|| REGNO (reg) != REGNO (SET_DEST (XVECEXP (op, 0, offs + 1)))
|
| 294 |
|
|
|| !CONST_INT_P (inc)
|
| 295 |
|
|
|| INTVAL (inc) != (HOST_WIDE_INT) reg_count * 4)
|
| 296 |
|
|
return false;
|
| 297 |
|
|
i = offs + 2;
|
| 298 |
|
|
}
|
| 299 |
|
|
else
|
| 300 |
|
|
i = offs + 1;
|
| 301 |
|
|
|
| 302 |
|
|
if (!TARGET_V32)
|
| 303 |
|
|
{
|
| 304 |
|
|
regno_dir = -1;
|
| 305 |
|
|
regno = reg_count - 1;
|
| 306 |
|
|
}
|
| 307 |
|
|
|
| 308 |
|
|
elt = XVECEXP (op, 0, offs);
|
| 309 |
|
|
src_addr = XEXP (SET_SRC (elt), 0);
|
| 310 |
|
|
|
| 311 |
|
|
if (GET_CODE (elt) != SET
|
| 312 |
|
|
|| !REG_P (SET_DEST (elt))
|
| 313 |
|
|
|| GET_MODE (SET_DEST (elt)) != SImode
|
| 314 |
|
|
|| REGNO (SET_DEST (elt)) != regno
|
| 315 |
|
|
|| !MEM_P (SET_SRC (elt))
|
| 316 |
|
|
|| GET_MODE (SET_SRC (elt)) != SImode
|
| 317 |
|
|
|| !memory_address_p (SImode, src_addr))
|
| 318 |
|
|
return false;
|
| 319 |
|
|
|
| 320 |
|
|
for (setno = 1; i < XVECLEN (op, 0); setno++, i++)
|
| 321 |
|
|
{
|
| 322 |
|
|
rtx elt = XVECEXP (op, 0, i);
|
| 323 |
|
|
regno += regno_dir;
|
| 324 |
|
|
|
| 325 |
|
|
if (GET_CODE (elt) != SET
|
| 326 |
|
|
|| !REG_P (SET_DEST (elt))
|
| 327 |
|
|
|| GET_MODE (SET_DEST (elt)) != SImode
|
| 328 |
|
|
|| REGNO (SET_DEST (elt)) != regno
|
| 329 |
|
|
|| !MEM_P (SET_SRC (elt))
|
| 330 |
|
|
|| GET_MODE (SET_SRC (elt)) != SImode
|
| 331 |
|
|
|| GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
|
| 332 |
|
|
|| ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
|
| 333 |
|
|
|| !CONST_INT_P (XEXP (XEXP (SET_SRC (elt), 0), 1))
|
| 334 |
|
|
|| INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != setno * 4)
|
| 335 |
|
|
return false;
|
| 336 |
|
|
}
|
| 337 |
|
|
|
| 338 |
|
|
return true;
|
| 339 |
|
|
}
|
| 340 |
|
|
|
| 341 |
|
|
/* Worker function for predicate for the parallel contents in a movem
|
| 342 |
|
|
to-memory. */
|
| 343 |
|
|
|
| 344 |
|
|
bool
|
| 345 |
|
|
cris_store_multiple_op_p (rtx op)
|
| 346 |
|
|
{
|
| 347 |
|
|
int reg_count = XVECLEN (op, 0);
|
| 348 |
|
|
rtx dest;
|
| 349 |
|
|
rtx dest_addr;
|
| 350 |
|
|
rtx dest_base;
|
| 351 |
|
|
int i;
|
| 352 |
|
|
rtx elt;
|
| 353 |
|
|
int setno;
|
| 354 |
|
|
int regno_dir = 1;
|
| 355 |
|
|
int regno = 0;
|
| 356 |
|
|
int offset = 0;
|
| 357 |
|
|
|
| 358 |
|
|
/* Perform a quick check so we don't blow up below. FIXME: Adjust for
|
| 359 |
|
|
other than (MEM reg) and (MEM (PLUS reg const)). */
|
| 360 |
|
|
if (reg_count <= 1)
|
| 361 |
|
|
return false;
|
| 362 |
|
|
|
| 363 |
|
|
elt = XVECEXP (op, 0, 0);
|
| 364 |
|
|
|
| 365 |
|
|
if (GET_CODE (elt) != SET)
|
| 366 |
|
|
return false;
|
| 367 |
|
|
|
| 368 |
|
|
dest = SET_DEST (elt);
|
| 369 |
|
|
|
| 370 |
|
|
if (!REG_P (SET_SRC (elt)) || !MEM_P (dest))
|
| 371 |
|
|
return false;
|
| 372 |
|
|
|
| 373 |
|
|
dest_addr = XEXP (dest, 0);
|
| 374 |
|
|
|
| 375 |
|
|
/* Check a possible post-inc indicator. */
|
| 376 |
|
|
if (GET_CODE (SET_SRC (XVECEXP (op, 0, 1))) == PLUS)
|
| 377 |
|
|
{
|
| 378 |
|
|
rtx reg = XEXP (SET_SRC (XVECEXP (op, 0, 1)), 0);
|
| 379 |
|
|
rtx inc = XEXP (SET_SRC (XVECEXP (op, 0, 1)), 1);
|
| 380 |
|
|
|
| 381 |
|
|
reg_count--;
|
| 382 |
|
|
|
| 383 |
|
|
if (reg_count == 1
|
| 384 |
|
|
|| !REG_P (reg)
|
| 385 |
|
|
|| !REG_P (SET_DEST (XVECEXP (op, 0, 1)))
|
| 386 |
|
|
|| REGNO (reg) != REGNO (SET_DEST (XVECEXP (op, 0, 1)))
|
| 387 |
|
|
|| !CONST_INT_P (inc)
|
| 388 |
|
|
/* Support increment by number of registers, and by the offset
|
| 389 |
|
|
of the destination, if it has the form (MEM (PLUS reg
|
| 390 |
|
|
offset)). */
|
| 391 |
|
|
|| !((REG_P (dest_addr)
|
| 392 |
|
|
&& REGNO (dest_addr) == REGNO (reg)
|
| 393 |
|
|
&& INTVAL (inc) == (HOST_WIDE_INT) reg_count * 4)
|
| 394 |
|
|
|| (GET_CODE (dest_addr) == PLUS
|
| 395 |
|
|
&& REG_P (XEXP (dest_addr, 0))
|
| 396 |
|
|
&& REGNO (XEXP (dest_addr, 0)) == REGNO (reg)
|
| 397 |
|
|
&& CONST_INT_P (XEXP (dest_addr, 1))
|
| 398 |
|
|
&& INTVAL (XEXP (dest_addr, 1)) == INTVAL (inc))))
|
| 399 |
|
|
return false;
|
| 400 |
|
|
|
| 401 |
|
|
i = 2;
|
| 402 |
|
|
}
|
| 403 |
|
|
else
|
| 404 |
|
|
i = 1;
|
| 405 |
|
|
|
| 406 |
|
|
if (!TARGET_V32)
|
| 407 |
|
|
{
|
| 408 |
|
|
regno_dir = -1;
|
| 409 |
|
|
regno = reg_count - 1;
|
| 410 |
|
|
}
|
| 411 |
|
|
|
| 412 |
|
|
if (GET_CODE (elt) != SET
|
| 413 |
|
|
|| !REG_P (SET_SRC (elt))
|
| 414 |
|
|
|| GET_MODE (SET_SRC (elt)) != SImode
|
| 415 |
|
|
|| REGNO (SET_SRC (elt)) != (unsigned int) regno
|
| 416 |
|
|
|| !MEM_P (SET_DEST (elt))
|
| 417 |
|
|
|| GET_MODE (SET_DEST (elt)) != SImode)
|
| 418 |
|
|
return false;
|
| 419 |
|
|
|
| 420 |
|
|
if (REG_P (dest_addr))
|
| 421 |
|
|
{
|
| 422 |
|
|
dest_base = dest_addr;
|
| 423 |
|
|
offset = 0;
|
| 424 |
|
|
}
|
| 425 |
|
|
else if (GET_CODE (dest_addr) == PLUS
|
| 426 |
|
|
&& REG_P (XEXP (dest_addr, 0))
|
| 427 |
|
|
&& CONST_INT_P (XEXP (dest_addr, 1)))
|
| 428 |
|
|
{
|
| 429 |
|
|
dest_base = XEXP (dest_addr, 0);
|
| 430 |
|
|
offset = INTVAL (XEXP (dest_addr, 1));
|
| 431 |
|
|
}
|
| 432 |
|
|
else
|
| 433 |
|
|
return false;
|
| 434 |
|
|
|
| 435 |
|
|
for (setno = 1; i < XVECLEN (op, 0); setno++, i++)
|
| 436 |
|
|
{
|
| 437 |
|
|
rtx elt = XVECEXP (op, 0, i);
|
| 438 |
|
|
regno += regno_dir;
|
| 439 |
|
|
|
| 440 |
|
|
if (GET_CODE (elt) != SET
|
| 441 |
|
|
|| !REG_P (SET_SRC (elt))
|
| 442 |
|
|
|| GET_MODE (SET_SRC (elt)) != SImode
|
| 443 |
|
|
|| REGNO (SET_SRC (elt)) != (unsigned int) regno
|
| 444 |
|
|
|| !MEM_P (SET_DEST (elt))
|
| 445 |
|
|
|| GET_MODE (SET_DEST (elt)) != SImode
|
| 446 |
|
|
|| GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
|
| 447 |
|
|
|| ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_base)
|
| 448 |
|
|
|| !CONST_INT_P (XEXP (XEXP (SET_DEST (elt), 0), 1))
|
| 449 |
|
|
|| INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != setno * 4 + offset)
|
| 450 |
|
|
return false;
|
| 451 |
|
|
}
|
| 452 |
|
|
|
| 453 |
|
|
return true;
|
| 454 |
|
|
}
|
| 455 |
|
|
|
| 456 |
|
|
/* The TARGET_CONDITIONAL_REGISTER_USAGE worker. */
|
| 457 |
|
|
|
| 458 |
|
|
static void
|
| 459 |
|
|
cris_conditional_register_usage (void)
|
| 460 |
|
|
{
|
| 461 |
|
|
/* FIXME: This isn't nice. We should be able to use that register for
|
| 462 |
|
|
something else if the PIC table isn't needed. */
|
| 463 |
|
|
if (flag_pic)
|
| 464 |
|
|
fixed_regs[PIC_OFFSET_TABLE_REGNUM]
|
| 465 |
|
|
= call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;
|
| 466 |
|
|
|
| 467 |
|
|
/* Allow use of ACR (PC in pre-V32) and tweak order. */
|
| 468 |
|
|
if (TARGET_V32)
|
| 469 |
|
|
{
|
| 470 |
|
|
static const int reg_alloc_order_v32[] = REG_ALLOC_ORDER_V32;
|
| 471 |
|
|
unsigned int i;
|
| 472 |
|
|
|
| 473 |
|
|
fixed_regs[CRIS_ACR_REGNUM] = 0;
|
| 474 |
|
|
|
| 475 |
|
|
for (i = 0;
|
| 476 |
|
|
i < sizeof (reg_alloc_order_v32)/sizeof (reg_alloc_order_v32[0]);
|
| 477 |
|
|
i++)
|
| 478 |
|
|
reg_alloc_order[i] = reg_alloc_order_v32[i];
|
| 479 |
|
|
}
|
| 480 |
|
|
|
| 481 |
|
|
if (TARGET_HAS_MUL_INSNS)
|
| 482 |
|
|
fixed_regs[CRIS_MOF_REGNUM] = 0;
|
| 483 |
|
|
|
| 484 |
|
|
/* On early versions, we must use the 16-bit condition-code register,
|
| 485 |
|
|
which has another name. */
|
| 486 |
|
|
if (cris_cpu_version < 8)
|
| 487 |
|
|
reg_names[CRIS_CC0_REGNUM] = "ccr";
|
| 488 |
|
|
}
|
| 489 |
|
|
|
| 490 |
|
|
/* Return crtl->uses_pic_offset_table. For use in cris.md,
|
| 491 |
|
|
since some generated files do not include function.h. */
|
| 492 |
|
|
|
| 493 |
|
|
int
|
| 494 |
|
|
cris_cfun_uses_pic_table (void)
|
| 495 |
|
|
{
|
| 496 |
|
|
return crtl->uses_pic_offset_table;
|
| 497 |
|
|
}
|
| 498 |
|
|
|
| 499 |
|
|
/* Given an rtx, return the text string corresponding to the CODE of X.
|
| 500 |
|
|
Intended for use in the assembly language output section of a
|
| 501 |
|
|
define_insn. */
|
| 502 |
|
|
|
| 503 |
|
|
const char *
|
| 504 |
|
|
cris_op_str (rtx x)
|
| 505 |
|
|
{
|
| 506 |
|
|
cris_output_insn_is_bound = 0;
|
| 507 |
|
|
switch (GET_CODE (x))
|
| 508 |
|
|
{
|
| 509 |
|
|
case PLUS:
|
| 510 |
|
|
return "add";
|
| 511 |
|
|
break;
|
| 512 |
|
|
|
| 513 |
|
|
case MINUS:
|
| 514 |
|
|
return "sub";
|
| 515 |
|
|
break;
|
| 516 |
|
|
|
| 517 |
|
|
case MULT:
|
| 518 |
|
|
/* This function is for retrieving a part of an instruction name for
|
| 519 |
|
|
an operator, for immediate output. If that ever happens for
|
| 520 |
|
|
MULT, we need to apply TARGET_MUL_BUG in the caller. Make sure
|
| 521 |
|
|
we notice. */
|
| 522 |
|
|
internal_error ("MULT case in cris_op_str");
|
| 523 |
|
|
break;
|
| 524 |
|
|
|
| 525 |
|
|
case DIV:
|
| 526 |
|
|
return "div";
|
| 527 |
|
|
break;
|
| 528 |
|
|
|
| 529 |
|
|
case AND:
|
| 530 |
|
|
return "and";
|
| 531 |
|
|
break;
|
| 532 |
|
|
|
| 533 |
|
|
case IOR:
|
| 534 |
|
|
return "or";
|
| 535 |
|
|
break;
|
| 536 |
|
|
|
| 537 |
|
|
case XOR:
|
| 538 |
|
|
return "xor";
|
| 539 |
|
|
break;
|
| 540 |
|
|
|
| 541 |
|
|
case NOT:
|
| 542 |
|
|
return "not";
|
| 543 |
|
|
break;
|
| 544 |
|
|
|
| 545 |
|
|
case ASHIFT:
|
| 546 |
|
|
return "lsl";
|
| 547 |
|
|
break;
|
| 548 |
|
|
|
| 549 |
|
|
case LSHIFTRT:
|
| 550 |
|
|
return "lsr";
|
| 551 |
|
|
break;
|
| 552 |
|
|
|
| 553 |
|
|
case ASHIFTRT:
|
| 554 |
|
|
return "asr";
|
| 555 |
|
|
break;
|
| 556 |
|
|
|
| 557 |
|
|
case UMIN:
|
| 558 |
|
|
/* Used to control the sign/zero-extend character for the 'E' modifier.
|
| 559 |
|
|
BOUND has none. */
|
| 560 |
|
|
cris_output_insn_is_bound = 1;
|
| 561 |
|
|
return "bound";
|
| 562 |
|
|
break;
|
| 563 |
|
|
|
| 564 |
|
|
default:
|
| 565 |
|
|
return "Unknown operator";
|
| 566 |
|
|
break;
|
| 567 |
|
|
}
|
| 568 |
|
|
}
|
| 569 |
|
|
|
| 570 |
|
|
/* Emit an error message when we're in an asm, and a fatal error for
|
| 571 |
|
|
"normal" insns. Formatted output isn't easily implemented, since we
|
| 572 |
|
|
use output_operand_lossage to output the actual message and handle the
|
| 573 |
|
|
categorization of the error. */
|
| 574 |
|
|
|
| 575 |
|
|
static void
|
| 576 |
|
|
cris_operand_lossage (const char *msgid, rtx op)
|
| 577 |
|
|
{
|
| 578 |
|
|
debug_rtx (op);
|
| 579 |
|
|
output_operand_lossage ("%s", msgid);
|
| 580 |
|
|
}
|
| 581 |
|
|
|
| 582 |
|
|
/* Print an index part of an address to file. */
|
| 583 |
|
|
|
| 584 |
|
|
static void
|
| 585 |
|
|
cris_print_index (rtx index, FILE *file)
|
| 586 |
|
|
{
|
| 587 |
|
|
/* Make the index "additive" unless we'll output a negative number, in
|
| 588 |
|
|
which case the sign character is free (as in free beer). */
|
| 589 |
|
|
if (!CONST_INT_P (index) || INTVAL (index) >= 0)
|
| 590 |
|
|
putc ('+', file);
|
| 591 |
|
|
|
| 592 |
|
|
if (REG_P (index))
|
| 593 |
|
|
fprintf (file, "$%s.b", reg_names[REGNO (index)]);
|
| 594 |
|
|
else if (CONSTANT_P (index))
|
| 595 |
|
|
cris_output_addr_const (file, index);
|
| 596 |
|
|
else if (GET_CODE (index) == MULT)
|
| 597 |
|
|
{
|
| 598 |
|
|
fprintf (file, "$%s.",
|
| 599 |
|
|
reg_names[REGNO (XEXP (index, 0))]);
|
| 600 |
|
|
|
| 601 |
|
|
putc (INTVAL (XEXP (index, 1)) == 2 ? 'w' : 'd', file);
|
| 602 |
|
|
}
|
| 603 |
|
|
else if (GET_CODE (index) == SIGN_EXTEND && MEM_P (XEXP (index, 0)))
|
| 604 |
|
|
{
|
| 605 |
|
|
rtx inner = XEXP (index, 0);
|
| 606 |
|
|
rtx inner_inner = XEXP (inner, 0);
|
| 607 |
|
|
|
| 608 |
|
|
if (GET_CODE (inner_inner) == POST_INC)
|
| 609 |
|
|
{
|
| 610 |
|
|
fprintf (file, "[$%s+].",
|
| 611 |
|
|
reg_names[REGNO (XEXP (inner_inner, 0))]);
|
| 612 |
|
|
putc (GET_MODE (inner) == HImode ? 'w' : 'b', file);
|
| 613 |
|
|
}
|
| 614 |
|
|
else
|
| 615 |
|
|
{
|
| 616 |
|
|
fprintf (file, "[$%s].", reg_names[REGNO (inner_inner)]);
|
| 617 |
|
|
|
| 618 |
|
|
putc (GET_MODE (inner) == HImode ? 'w' : 'b', file);
|
| 619 |
|
|
}
|
| 620 |
|
|
}
|
| 621 |
|
|
else if (MEM_P (index))
|
| 622 |
|
|
{
|
| 623 |
|
|
rtx inner = XEXP (index, 0);
|
| 624 |
|
|
if (GET_CODE (inner) == POST_INC)
|
| 625 |
|
|
fprintf (file, "[$%s+].d", reg_names[REGNO (XEXP (inner, 0))]);
|
| 626 |
|
|
else
|
| 627 |
|
|
fprintf (file, "[$%s].d", reg_names[REGNO (inner)]);
|
| 628 |
|
|
}
|
| 629 |
|
|
else
|
| 630 |
|
|
cris_operand_lossage ("unexpected index-type in cris_print_index",
|
| 631 |
|
|
index);
|
| 632 |
|
|
}
|
| 633 |
|
|
|
| 634 |
|
|
/* Print a base rtx of an address to file. */
|
| 635 |
|
|
|
| 636 |
|
|
static void
|
| 637 |
|
|
cris_print_base (rtx base, FILE *file)
|
| 638 |
|
|
{
|
| 639 |
|
|
if (REG_P (base))
|
| 640 |
|
|
fprintf (file, "$%s", reg_names[REGNO (base)]);
|
| 641 |
|
|
else if (GET_CODE (base) == POST_INC)
|
| 642 |
|
|
{
|
| 643 |
|
|
gcc_assert (REGNO (XEXP (base, 0)) != CRIS_ACR_REGNUM);
|
| 644 |
|
|
fprintf (file, "$%s+", reg_names[REGNO (XEXP (base, 0))]);
|
| 645 |
|
|
}
|
| 646 |
|
|
else
|
| 647 |
|
|
cris_operand_lossage ("unexpected base-type in cris_print_base",
|
| 648 |
|
|
base);
|
| 649 |
|
|
}
|
| 650 |
|
|
|
| 651 |
|
|
/* Usable as a guard in expressions. */
|
| 652 |
|
|
|
| 653 |
|
|
int
|
| 654 |
|
|
cris_fatal (char *arg)
|
| 655 |
|
|
{
|
| 656 |
|
|
internal_error (arg);
|
| 657 |
|
|
|
| 658 |
|
|
/* We'll never get here; this is just to appease compilers. */
|
| 659 |
|
|
return 0;
|
| 660 |
|
|
}
|
| 661 |
|
|
|
| 662 |
|
|
/* Return nonzero if REGNO is an ordinary register that *needs* to be
|
| 663 |
|
|
saved together with other registers, possibly by a MOVEM instruction,
|
| 664 |
|
|
or is saved for target-independent reasons. There may be
|
| 665 |
|
|
target-dependent reasons to save the register anyway; this is just a
|
| 666 |
|
|
wrapper for a complicated conditional. */
|
| 667 |
|
|
|
| 668 |
|
|
static int
|
| 669 |
|
|
cris_reg_saved_in_regsave_area (unsigned int regno, bool got_really_used)
|
| 670 |
|
|
{
|
| 671 |
|
|
return
|
| 672 |
|
|
(((df_regs_ever_live_p (regno)
|
| 673 |
|
|
&& !call_used_regs[regno])
|
| 674 |
|
|
|| (regno == PIC_OFFSET_TABLE_REGNUM
|
| 675 |
|
|
&& (got_really_used
|
| 676 |
|
|
/* It is saved anyway, if there would be a gap. */
|
| 677 |
|
|
|| (flag_pic
|
| 678 |
|
|
&& df_regs_ever_live_p (regno + 1)
|
| 679 |
|
|
&& !call_used_regs[regno + 1]))))
|
| 680 |
|
|
&& (regno != FRAME_POINTER_REGNUM || !frame_pointer_needed)
|
| 681 |
|
|
&& regno != CRIS_SRP_REGNUM)
|
| 682 |
|
|
|| (crtl->calls_eh_return
|
| 683 |
|
|
&& (regno == EH_RETURN_DATA_REGNO (0)
|
| 684 |
|
|
|| regno == EH_RETURN_DATA_REGNO (1)
|
| 685 |
|
|
|| regno == EH_RETURN_DATA_REGNO (2)
|
| 686 |
|
|
|| regno == EH_RETURN_DATA_REGNO (3)));
|
| 687 |
|
|
}
|
| 688 |
|
|
|
| 689 |
|
|
/* The PRINT_OPERAND worker. */
|
| 690 |
|
|
|
| 691 |
|
|
static void
|
| 692 |
|
|
cris_print_operand (FILE *file, rtx x, int code)
|
| 693 |
|
|
{
|
| 694 |
|
|
rtx operand = x;
|
| 695 |
|
|
|
| 696 |
|
|
/* Size-strings corresponding to MULT expressions. */
|
| 697 |
|
|
static const char *const mults[] = { "BAD:0", ".b", ".w", "BAD:3", ".d" };
|
| 698 |
|
|
|
| 699 |
|
|
/* New code entries should just be added to the switch below. If
|
| 700 |
|
|
handling is finished, just return. If handling was just a
|
| 701 |
|
|
modification of the operand, the modified operand should be put in
|
| 702 |
|
|
"operand", and then do a break to let default handling
|
| 703 |
|
|
(zero-modifier) output the operand. */
|
| 704 |
|
|
|
| 705 |
|
|
switch (code)
|
| 706 |
|
|
{
|
| 707 |
|
|
case 'b':
|
| 708 |
|
|
/* Print the unsigned supplied integer as if it were signed
|
| 709 |
|
|
and < 0, i.e print 255 or 65535 as -1, 254, 65534 as -2, etc. */
|
| 710 |
|
|
if (!satisfies_constraint_O (x))
|
| 711 |
|
|
LOSE_AND_RETURN ("invalid operand for 'b' modifier", x);
|
| 712 |
|
|
fprintf (file, HOST_WIDE_INT_PRINT_DEC,
|
| 713 |
|
|
INTVAL (x)| (INTVAL (x) <= 255 ? ~255 : ~65535));
|
| 714 |
|
|
return;
|
| 715 |
|
|
|
| 716 |
|
|
case 'x':
|
| 717 |
|
|
/* Print assembler code for operator. */
|
| 718 |
|
|
fprintf (file, "%s", cris_op_str (operand));
|
| 719 |
|
|
return;
|
| 720 |
|
|
|
| 721 |
|
|
case 'o':
|
| 722 |
|
|
{
|
| 723 |
|
|
/* A movem modifier working on a parallel; output the register
|
| 724 |
|
|
name. */
|
| 725 |
|
|
int regno;
|
| 726 |
|
|
|
| 727 |
|
|
if (GET_CODE (x) != PARALLEL)
|
| 728 |
|
|
LOSE_AND_RETURN ("invalid operand for 'o' modifier", x);
|
| 729 |
|
|
|
| 730 |
|
|
/* The second item can be (set reg (plus reg const)) to denote a
|
| 731 |
|
|
postincrement. */
|
| 732 |
|
|
regno
|
| 733 |
|
|
= (GET_CODE (SET_SRC (XVECEXP (x, 0, 1))) == PLUS
|
| 734 |
|
|
? XVECLEN (x, 0) - 2
|
| 735 |
|
|
: XVECLEN (x, 0) - 1);
|
| 736 |
|
|
|
| 737 |
|
|
fprintf (file, "$%s", reg_names [regno]);
|
| 738 |
|
|
}
|
| 739 |
|
|
return;
|
| 740 |
|
|
|
| 741 |
|
|
case 'O':
|
| 742 |
|
|
{
|
| 743 |
|
|
/* A similar movem modifier; output the memory operand. */
|
| 744 |
|
|
rtx addr;
|
| 745 |
|
|
|
| 746 |
|
|
if (GET_CODE (x) != PARALLEL)
|
| 747 |
|
|
LOSE_AND_RETURN ("invalid operand for 'O' modifier", x);
|
| 748 |
|
|
|
| 749 |
|
|
/* The lowest mem operand is in the first item, but perhaps it
|
| 750 |
|
|
needs to be output as postincremented. */
|
| 751 |
|
|
addr = MEM_P (SET_SRC (XVECEXP (x, 0, 0)))
|
| 752 |
|
|
? XEXP (SET_SRC (XVECEXP (x, 0, 0)), 0)
|
| 753 |
|
|
: XEXP (SET_DEST (XVECEXP (x, 0, 0)), 0);
|
| 754 |
|
|
|
| 755 |
|
|
/* The second item can be a (set reg (plus reg const)) to denote
|
| 756 |
|
|
a modification. */
|
| 757 |
|
|
if (GET_CODE (SET_SRC (XVECEXP (x, 0, 1))) == PLUS)
|
| 758 |
|
|
{
|
| 759 |
|
|
/* It's a post-increment, if the address is a naked (reg). */
|
| 760 |
|
|
if (REG_P (addr))
|
| 761 |
|
|
addr = gen_rtx_POST_INC (SImode, addr);
|
| 762 |
|
|
else
|
| 763 |
|
|
{
|
| 764 |
|
|
/* Otherwise, it's a side-effect; RN=RN+M. */
|
| 765 |
|
|
fprintf (file, "[$%s=$%s%s%d]",
|
| 766 |
|
|
reg_names [REGNO (SET_DEST (XVECEXP (x, 0, 1)))],
|
| 767 |
|
|
reg_names [REGNO (XEXP (addr, 0))],
|
| 768 |
|
|
INTVAL (XEXP (addr, 1)) < 0 ? "" : "+",
|
| 769 |
|
|
(int) INTVAL (XEXP (addr, 1)));
|
| 770 |
|
|
return;
|
| 771 |
|
|
}
|
| 772 |
|
|
}
|
| 773 |
|
|
output_address (addr);
|
| 774 |
|
|
}
|
| 775 |
|
|
return;
|
| 776 |
|
|
|
| 777 |
|
|
case 'p':
|
| 778 |
|
|
/* Adjust a power of two to its log2. */
|
| 779 |
|
|
if (!CONST_INT_P (x) || exact_log2 (INTVAL (x)) < 0 )
|
| 780 |
|
|
LOSE_AND_RETURN ("invalid operand for 'p' modifier", x);
|
| 781 |
|
|
fprintf (file, "%d", exact_log2 (INTVAL (x)));
|
| 782 |
|
|
return;
|
| 783 |
|
|
|
| 784 |
|
|
case 's':
|
| 785 |
|
|
/* For an integer, print 'b' or 'w' if <= 255 or <= 65535
|
| 786 |
|
|
respectively. This modifier also terminates the inhibiting
|
| 787 |
|
|
effects of the 'x' modifier. */
|
| 788 |
|
|
cris_output_insn_is_bound = 0;
|
| 789 |
|
|
if (GET_MODE (x) == VOIDmode && CONST_INT_P (x))
|
| 790 |
|
|
{
|
| 791 |
|
|
if (INTVAL (x) >= 0)
|
| 792 |
|
|
{
|
| 793 |
|
|
if (INTVAL (x) <= 255)
|
| 794 |
|
|
putc ('b', file);
|
| 795 |
|
|
else if (INTVAL (x) <= 65535)
|
| 796 |
|
|
putc ('w', file);
|
| 797 |
|
|
else
|
| 798 |
|
|
putc ('d', file);
|
| 799 |
|
|
}
|
| 800 |
|
|
else
|
| 801 |
|
|
putc ('d', file);
|
| 802 |
|
|
return;
|
| 803 |
|
|
}
|
| 804 |
|
|
|
| 805 |
|
|
/* For a non-integer, print the size of the operand. */
|
| 806 |
|
|
putc ((GET_MODE (x) == SImode || GET_MODE (x) == SFmode)
|
| 807 |
|
|
? 'd' : GET_MODE (x) == HImode ? 'w'
|
| 808 |
|
|
: GET_MODE (x) == QImode ? 'b'
|
| 809 |
|
|
/* If none of the above, emit an erroneous size letter. */
|
| 810 |
|
|
: 'X',
|
| 811 |
|
|
file);
|
| 812 |
|
|
return;
|
| 813 |
|
|
|
| 814 |
|
|
case 'z':
|
| 815 |
|
|
/* Const_int: print b for -127 <= x <= 255,
|
| 816 |
|
|
w for -32768 <= x <= 65535, else die. */
|
| 817 |
|
|
if (!CONST_INT_P (x)
|
| 818 |
|
|
|| INTVAL (x) < -32768 || INTVAL (x) > 65535)
|
| 819 |
|
|
LOSE_AND_RETURN ("invalid operand for 'z' modifier", x);
|
| 820 |
|
|
putc (INTVAL (x) >= -128 && INTVAL (x) <= 255 ? 'b' : 'w', file);
|
| 821 |
|
|
return;
|
| 822 |
|
|
|
| 823 |
|
|
case 'Z':
|
| 824 |
|
|
/* If this is a GOT-symbol, print the size-letter corresponding to
|
| 825 |
|
|
-fpic/-fPIC. For everything else, print "d". */
|
| 826 |
|
|
putc ((flag_pic == 1
|
| 827 |
|
|
&& GET_CODE (x) == CONST
|
| 828 |
|
|
&& GET_CODE (XEXP (x, 0)) == UNSPEC
|
| 829 |
|
|
&& XINT (XEXP (x, 0), 1) == CRIS_UNSPEC_GOTREAD)
|
| 830 |
|
|
? 'w' : 'd', file);
|
| 831 |
|
|
return;
|
| 832 |
|
|
|
| 833 |
|
|
case '#':
|
| 834 |
|
|
/* Output a 'nop' if there's nothing for the delay slot.
|
| 835 |
|
|
This method stolen from the sparc files. */
|
| 836 |
|
|
if (dbr_sequence_length () == 0)
|
| 837 |
|
|
fputs ("\n\tnop", file);
|
| 838 |
|
|
return;
|
| 839 |
|
|
|
| 840 |
|
|
case '!':
|
| 841 |
|
|
/* Output directive for alignment padded with "nop" insns.
|
| 842 |
|
|
Optimizing for size, it's plain 4-byte alignment, otherwise we
|
| 843 |
|
|
align the section to a cache-line (32 bytes) and skip at max 2
|
| 844 |
|
|
bytes, i.e. we skip if it's the last insn on a cache-line. The
|
| 845 |
|
|
latter is faster by a small amount (for two test-programs 99.6%
|
| 846 |
|
|
and 99.9%) and larger by a small amount (ditto 100.1% and
|
| 847 |
|
|
100.2%). This is supposed to be the simplest yet performance-
|
| 848 |
|
|
wise least intrusive way to make sure the immediately following
|
| 849 |
|
|
(supposed) muls/mulu insn isn't located at the end of a
|
| 850 |
|
|
cache-line. */
|
| 851 |
|
|
if (TARGET_MUL_BUG)
|
| 852 |
|
|
fputs (optimize_size
|
| 853 |
|
|
? ".p2alignw 2,0x050f\n\t"
|
| 854 |
|
|
: ".p2alignw 5,0x050f,2\n\t", file);
|
| 855 |
|
|
return;
|
| 856 |
|
|
|
| 857 |
|
|
case ':':
|
| 858 |
|
|
/* The PIC register. */
|
| 859 |
|
|
if (! flag_pic)
|
| 860 |
|
|
internal_error ("invalid use of ':' modifier");
|
| 861 |
|
|
fprintf (file, "$%s", reg_names [PIC_OFFSET_TABLE_REGNUM]);
|
| 862 |
|
|
return;
|
| 863 |
|
|
|
| 864 |
|
|
case 'H':
|
| 865 |
|
|
/* Print high (most significant) part of something. */
|
| 866 |
|
|
switch (GET_CODE (operand))
|
| 867 |
|
|
{
|
| 868 |
|
|
case CONST_INT:
|
| 869 |
|
|
/* If we're having 64-bit HOST_WIDE_INTs, the whole (DImode)
|
| 870 |
|
|
value is kept here, and so may be other than 0 or -1. */
|
| 871 |
|
|
fprintf (file, HOST_WIDE_INT_PRINT_DEC,
|
| 872 |
|
|
INTVAL (operand_subword (operand, 1, 0, DImode)));
|
| 873 |
|
|
return;
|
| 874 |
|
|
|
| 875 |
|
|
case CONST_DOUBLE:
|
| 876 |
|
|
/* High part of a long long constant. */
|
| 877 |
|
|
if (GET_MODE (operand) == VOIDmode)
|
| 878 |
|
|
{
|
| 879 |
|
|
fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_HIGH (x));
|
| 880 |
|
|
return;
|
| 881 |
|
|
}
|
| 882 |
|
|
else
|
| 883 |
|
|
LOSE_AND_RETURN ("invalid operand for 'H' modifier", x);
|
| 884 |
|
|
|
| 885 |
|
|
case REG:
|
| 886 |
|
|
/* Print reg + 1. Check that there's not an attempt to print
|
| 887 |
|
|
high-parts of registers like stack-pointer or higher, except
|
| 888 |
|
|
for SRP (where the "high part" is MOF). */
|
| 889 |
|
|
if (REGNO (operand) > STACK_POINTER_REGNUM - 2
|
| 890 |
|
|
&& (REGNO (operand) != CRIS_SRP_REGNUM
|
| 891 |
|
|
|| CRIS_SRP_REGNUM + 1 != CRIS_MOF_REGNUM
|
| 892 |
|
|
|| fixed_regs[CRIS_MOF_REGNUM] != 0))
|
| 893 |
|
|
LOSE_AND_RETURN ("bad register", operand);
|
| 894 |
|
|
fprintf (file, "$%s", reg_names[REGNO (operand) + 1]);
|
| 895 |
|
|
return;
|
| 896 |
|
|
|
| 897 |
|
|
case MEM:
|
| 898 |
|
|
/* Adjust memory address to high part. */
|
| 899 |
|
|
{
|
| 900 |
|
|
rtx adj_mem = operand;
|
| 901 |
|
|
int size
|
| 902 |
|
|
= GET_MODE_BITSIZE (GET_MODE (operand)) / BITS_PER_UNIT;
|
| 903 |
|
|
|
| 904 |
|
|
/* Adjust so we can use two SImode in DImode.
|
| 905 |
|
|
Calling adj_offsettable_operand will make sure it is an
|
| 906 |
|
|
offsettable address. Don't do this for a postincrement
|
| 907 |
|
|
though; it should remain as it was. */
|
| 908 |
|
|
if (GET_CODE (XEXP (adj_mem, 0)) != POST_INC)
|
| 909 |
|
|
adj_mem
|
| 910 |
|
|
= adjust_address (adj_mem, GET_MODE (adj_mem), size / 2);
|
| 911 |
|
|
|
| 912 |
|
|
output_address (XEXP (adj_mem, 0));
|
| 913 |
|
|
return;
|
| 914 |
|
|
}
|
| 915 |
|
|
|
| 916 |
|
|
default:
|
| 917 |
|
|
LOSE_AND_RETURN ("invalid operand for 'H' modifier", x);
|
| 918 |
|
|
}
|
| 919 |
|
|
|
| 920 |
|
|
case 'L':
|
| 921 |
|
|
/* Strip the MEM expression. */
|
| 922 |
|
|
operand = XEXP (operand, 0);
|
| 923 |
|
|
break;
|
| 924 |
|
|
|
| 925 |
|
|
case 'e':
|
| 926 |
|
|
/* Like 'E', but ignore state set by 'x'. FIXME: Use code
|
| 927 |
|
|
iterators and attributes in cris.md to avoid the need for %x
|
| 928 |
|
|
and %E (and %e) and state passed between those modifiers. */
|
| 929 |
|
|
cris_output_insn_is_bound = 0;
|
| 930 |
|
|
/* FALL THROUGH. */
|
| 931 |
|
|
case 'E':
|
| 932 |
|
|
/* Print 's' if operand is SIGN_EXTEND or 'u' if ZERO_EXTEND unless
|
| 933 |
|
|
cris_output_insn_is_bound is nonzero. */
|
| 934 |
|
|
if (GET_CODE (operand) != SIGN_EXTEND
|
| 935 |
|
|
&& GET_CODE (operand) != ZERO_EXTEND
|
| 936 |
|
|
&& !CONST_INT_P (operand))
|
| 937 |
|
|
LOSE_AND_RETURN ("invalid operand for 'e' modifier", x);
|
| 938 |
|
|
|
| 939 |
|
|
if (cris_output_insn_is_bound)
|
| 940 |
|
|
{
|
| 941 |
|
|
cris_output_insn_is_bound = 0;
|
| 942 |
|
|
return;
|
| 943 |
|
|
}
|
| 944 |
|
|
|
| 945 |
|
|
putc (GET_CODE (operand) == SIGN_EXTEND
|
| 946 |
|
|
|| (CONST_INT_P (operand) && INTVAL (operand) < 0)
|
| 947 |
|
|
? 's' : 'u', file);
|
| 948 |
|
|
return;
|
| 949 |
|
|
|
| 950 |
|
|
case 'm':
|
| 951 |
|
|
/* Print the size letter of the inner element. We can do it by
|
| 952 |
|
|
calling ourselves with the 's' modifier. */
|
| 953 |
|
|
if (GET_CODE (operand) != SIGN_EXTEND && GET_CODE (operand) != ZERO_EXTEND)
|
| 954 |
|
|
LOSE_AND_RETURN ("invalid operand for 'm' modifier", x);
|
| 955 |
|
|
cris_print_operand (file, XEXP (operand, 0), 's');
|
| 956 |
|
|
return;
|
| 957 |
|
|
|
| 958 |
|
|
case 'M':
|
| 959 |
|
|
/* Print the least significant part of operand. */
|
| 960 |
|
|
if (GET_CODE (operand) == CONST_DOUBLE)
|
| 961 |
|
|
{
|
| 962 |
|
|
fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (x));
|
| 963 |
|
|
return;
|
| 964 |
|
|
}
|
| 965 |
|
|
else if (HOST_BITS_PER_WIDE_INT > 32 && CONST_INT_P (operand))
|
| 966 |
|
|
{
|
| 967 |
|
|
fprintf (file, HOST_WIDE_INT_PRINT_HEX,
|
| 968 |
|
|
INTVAL (x) & ((unsigned int) 0x7fffffff * 2 + 1));
|
| 969 |
|
|
return;
|
| 970 |
|
|
}
|
| 971 |
|
|
/* Otherwise the least significant part equals the normal part,
|
| 972 |
|
|
so handle it normally. */
|
| 973 |
|
|
break;
|
| 974 |
|
|
|
| 975 |
|
|
case 'A':
|
| 976 |
|
|
/* When emitting an add for the high part of a DImode constant, we
|
| 977 |
|
|
want to use addq for 0 and adds.w for -1. */
|
| 978 |
|
|
if (!CONST_INT_P (operand))
|
| 979 |
|
|
LOSE_AND_RETURN ("invalid operand for 'A' modifier", x);
|
| 980 |
|
|
fprintf (file, INTVAL (operand) < 0 ? "adds.w" : "addq");
|
| 981 |
|
|
return;
|
| 982 |
|
|
|
| 983 |
|
|
case 'd':
|
| 984 |
|
|
/* If this is a GOT symbol, force it to be emitted as :GOT and
|
| 985 |
|
|
:GOTPLT regardless of -fpic (i.e. not as :GOT16, :GOTPLT16).
|
| 986 |
|
|
Avoid making this too much of a special case. */
|
| 987 |
|
|
if (flag_pic == 1 && CONSTANT_P (operand))
|
| 988 |
|
|
{
|
| 989 |
|
|
int flag_pic_save = flag_pic;
|
| 990 |
|
|
|
| 991 |
|
|
flag_pic = 2;
|
| 992 |
|
|
cris_output_addr_const (file, operand);
|
| 993 |
|
|
flag_pic = flag_pic_save;
|
| 994 |
|
|
return;
|
| 995 |
|
|
}
|
| 996 |
|
|
break;
|
| 997 |
|
|
|
| 998 |
|
|
case 'D':
|
| 999 |
|
|
/* When emitting an sub for the high part of a DImode constant, we
|
| 1000 |
|
|
want to use subq for 0 and subs.w for -1. */
|
| 1001 |
|
|
if (!CONST_INT_P (operand))
|
| 1002 |
|
|
LOSE_AND_RETURN ("invalid operand for 'D' modifier", x);
|
| 1003 |
|
|
fprintf (file, INTVAL (operand) < 0 ? "subs.w" : "subq");
|
| 1004 |
|
|
return;
|
| 1005 |
|
|
|
| 1006 |
|
|
case 'S':
|
| 1007 |
|
|
/* Print the operand as the index-part of an address.
|
| 1008 |
|
|
Easiest way out is to use cris_print_index. */
|
| 1009 |
|
|
cris_print_index (operand, file);
|
| 1010 |
|
|
return;
|
| 1011 |
|
|
|
| 1012 |
|
|
case 'T':
|
| 1013 |
|
|
/* Print the size letter for an operand to a MULT, which must be a
|
| 1014 |
|
|
const_int with a suitable value. */
|
| 1015 |
|
|
if (!CONST_INT_P (operand) || INTVAL (operand) > 4)
|
| 1016 |
|
|
LOSE_AND_RETURN ("invalid operand for 'T' modifier", x);
|
| 1017 |
|
|
fprintf (file, "%s", mults[INTVAL (operand)]);
|
| 1018 |
|
|
return;
|
| 1019 |
|
|
|
| 1020 |
|
|
case 'u':
|
| 1021 |
|
|
/* Print "u.w" if a GOT symbol and flag_pic == 1, else ".d". */
|
| 1022 |
|
|
if (flag_pic == 1
|
| 1023 |
|
|
&& GET_CODE (operand) == CONST
|
| 1024 |
|
|
&& GET_CODE (XEXP (operand, 0)) == UNSPEC
|
| 1025 |
|
|
&& XINT (XEXP (operand, 0), 1) == CRIS_UNSPEC_GOTREAD)
|
| 1026 |
|
|
fprintf (file, "u.w");
|
| 1027 |
|
|
else
|
| 1028 |
|
|
fprintf (file, ".d");
|
| 1029 |
|
|
return;
|
| 1030 |
|
|
|
| 1031 |
|
|
case 0:
|
| 1032 |
|
|
/* No code, print as usual. */
|
| 1033 |
|
|
break;
|
| 1034 |
|
|
|
| 1035 |
|
|
default:
|
| 1036 |
|
|
LOSE_AND_RETURN ("invalid operand modifier letter", x);
|
| 1037 |
|
|
}
|
| 1038 |
|
|
|
| 1039 |
|
|
/* Print an operand as without a modifier letter. */
|
| 1040 |
|
|
switch (GET_CODE (operand))
|
| 1041 |
|
|
{
|
| 1042 |
|
|
case REG:
|
| 1043 |
|
|
if (REGNO (operand) > 15
|
| 1044 |
|
|
&& REGNO (operand) != CRIS_MOF_REGNUM
|
| 1045 |
|
|
&& REGNO (operand) != CRIS_SRP_REGNUM
|
| 1046 |
|
|
&& REGNO (operand) != CRIS_CC0_REGNUM)
|
| 1047 |
|
|
internal_error ("internal error: bad register: %d", REGNO (operand));
|
| 1048 |
|
|
fprintf (file, "$%s", reg_names[REGNO (operand)]);
|
| 1049 |
|
|
return;
|
| 1050 |
|
|
|
| 1051 |
|
|
case MEM:
|
| 1052 |
|
|
output_address (XEXP (operand, 0));
|
| 1053 |
|
|
return;
|
| 1054 |
|
|
|
| 1055 |
|
|
case CONST_DOUBLE:
|
| 1056 |
|
|
if (GET_MODE (operand) == VOIDmode)
|
| 1057 |
|
|
/* A long long constant. */
|
| 1058 |
|
|
output_addr_const (file, operand);
|
| 1059 |
|
|
else
|
| 1060 |
|
|
{
|
| 1061 |
|
|
/* Only single precision is allowed as plain operands the
|
| 1062 |
|
|
moment. FIXME: REAL_VALUE_FROM_CONST_DOUBLE isn't
|
| 1063 |
|
|
documented. */
|
| 1064 |
|
|
REAL_VALUE_TYPE r;
|
| 1065 |
|
|
long l;
|
| 1066 |
|
|
|
| 1067 |
|
|
/* FIXME: Perhaps check overflow of the "single". */
|
| 1068 |
|
|
REAL_VALUE_FROM_CONST_DOUBLE (r, operand);
|
| 1069 |
|
|
REAL_VALUE_TO_TARGET_SINGLE (r, l);
|
| 1070 |
|
|
|
| 1071 |
|
|
fprintf (file, "0x%lx", l);
|
| 1072 |
|
|
}
|
| 1073 |
|
|
return;
|
| 1074 |
|
|
|
| 1075 |
|
|
case UNSPEC:
|
| 1076 |
|
|
/* Fall through. */
|
| 1077 |
|
|
case CONST:
|
| 1078 |
|
|
cris_output_addr_const (file, operand);
|
| 1079 |
|
|
return;
|
| 1080 |
|
|
|
| 1081 |
|
|
case MULT:
|
| 1082 |
|
|
case ASHIFT:
|
| 1083 |
|
|
{
|
| 1084 |
|
|
/* For a (MULT (reg X) const_int) we output "rX.S". */
|
| 1085 |
|
|
int i = CONST_INT_P (XEXP (operand, 1))
|
| 1086 |
|
|
? INTVAL (XEXP (operand, 1)) : INTVAL (XEXP (operand, 0));
|
| 1087 |
|
|
rtx reg = CONST_INT_P (XEXP (operand, 1))
|
| 1088 |
|
|
? XEXP (operand, 0) : XEXP (operand, 1);
|
| 1089 |
|
|
|
| 1090 |
|
|
if (!REG_P (reg)
|
| 1091 |
|
|
|| (!CONST_INT_P (XEXP (operand, 0))
|
| 1092 |
|
|
&& !CONST_INT_P (XEXP (operand, 1))))
|
| 1093 |
|
|
LOSE_AND_RETURN ("unexpected multiplicative operand", x);
|
| 1094 |
|
|
|
| 1095 |
|
|
cris_print_base (reg, file);
|
| 1096 |
|
|
fprintf (file, ".%c",
|
| 1097 |
|
|
i == 0 || (i == 1 && GET_CODE (operand) == MULT) ? 'b'
|
| 1098 |
|
|
: i == 4 ? 'd'
|
| 1099 |
|
|
: (i == 2 && GET_CODE (operand) == MULT) || i == 1 ? 'w'
|
| 1100 |
|
|
: 'd');
|
| 1101 |
|
|
return;
|
| 1102 |
|
|
}
|
| 1103 |
|
|
|
| 1104 |
|
|
default:
|
| 1105 |
|
|
/* No need to handle all strange variants, let output_addr_const
|
| 1106 |
|
|
do it for us. */
|
| 1107 |
|
|
if (CONSTANT_P (operand))
|
| 1108 |
|
|
{
|
| 1109 |
|
|
cris_output_addr_const (file, operand);
|
| 1110 |
|
|
return;
|
| 1111 |
|
|
}
|
| 1112 |
|
|
|
| 1113 |
|
|
LOSE_AND_RETURN ("unexpected operand", x);
|
| 1114 |
|
|
}
|
| 1115 |
|
|
}
|
| 1116 |
|
|
|
| 1117 |
|
|
static bool
|
| 1118 |
|
|
cris_print_operand_punct_valid_p (unsigned char code)
|
| 1119 |
|
|
{
|
| 1120 |
|
|
return (code == '#' || code == '!' || code == ':');
|
| 1121 |
|
|
}
|
| 1122 |
|
|
|
| 1123 |
|
|
/* The PRINT_OPERAND_ADDRESS worker. */
|
| 1124 |
|
|
|
| 1125 |
|
|
static void
|
| 1126 |
|
|
cris_print_operand_address (FILE *file, rtx x)
|
| 1127 |
|
|
{
|
| 1128 |
|
|
/* All these were inside MEM:s so output indirection characters. */
|
| 1129 |
|
|
putc ('[', file);
|
| 1130 |
|
|
|
| 1131 |
|
|
if (CONSTANT_ADDRESS_P (x))
|
| 1132 |
|
|
cris_output_addr_const (file, x);
|
| 1133 |
|
|
else if (cris_base_or_autoincr_p (x, true))
|
| 1134 |
|
|
cris_print_base (x, file);
|
| 1135 |
|
|
else if (GET_CODE (x) == PLUS)
|
| 1136 |
|
|
{
|
| 1137 |
|
|
rtx x1, x2;
|
| 1138 |
|
|
|
| 1139 |
|
|
x1 = XEXP (x, 0);
|
| 1140 |
|
|
x2 = XEXP (x, 1);
|
| 1141 |
|
|
if (cris_base_p (x1, true))
|
| 1142 |
|
|
{
|
| 1143 |
|
|
cris_print_base (x1, file);
|
| 1144 |
|
|
cris_print_index (x2, file);
|
| 1145 |
|
|
}
|
| 1146 |
|
|
else if (cris_base_p (x2, true))
|
| 1147 |
|
|
{
|
| 1148 |
|
|
cris_print_base (x2, file);
|
| 1149 |
|
|
cris_print_index (x1, file);
|
| 1150 |
|
|
}
|
| 1151 |
|
|
else
|
| 1152 |
|
|
LOSE_AND_RETURN ("unrecognized address", x);
|
| 1153 |
|
|
}
|
| 1154 |
|
|
else if (MEM_P (x))
|
| 1155 |
|
|
{
|
| 1156 |
|
|
/* A DIP. Output more indirection characters. */
|
| 1157 |
|
|
putc ('[', file);
|
| 1158 |
|
|
cris_print_base (XEXP (x, 0), file);
|
| 1159 |
|
|
putc (']', file);
|
| 1160 |
|
|
}
|
| 1161 |
|
|
else
|
| 1162 |
|
|
LOSE_AND_RETURN ("unrecognized address", x);
|
| 1163 |
|
|
|
| 1164 |
|
|
putc (']', file);
|
| 1165 |
|
|
}
|
| 1166 |
|
|
|
| 1167 |
|
|
/* The RETURN_ADDR_RTX worker.
|
| 1168 |
|
|
We mark that the return address is used, either by EH or
|
| 1169 |
|
|
__builtin_return_address, for use by the function prologue and
|
| 1170 |
|
|
epilogue. FIXME: This isn't optimal; we just use the mark in the
|
| 1171 |
|
|
prologue and epilogue to say that the return address is to be stored
|
| 1172 |
|
|
in the stack frame. We could return SRP for leaf-functions and use the
|
| 1173 |
|
|
initial-value machinery. */
|
| 1174 |
|
|
|
| 1175 |
|
|
rtx
|
| 1176 |
|
|
cris_return_addr_rtx (int count, rtx frameaddr ATTRIBUTE_UNUSED)
|
| 1177 |
|
|
{
|
| 1178 |
|
|
cfun->machine->needs_return_address_on_stack = 1;
|
| 1179 |
|
|
|
| 1180 |
|
|
/* The return-address is stored just above the saved frame-pointer (if
|
| 1181 |
|
|
present). Apparently we can't eliminate from the frame-pointer in
|
| 1182 |
|
|
that direction, so use the incoming args (maybe pretended) pointer. */
|
| 1183 |
|
|
return count == 0
|
| 1184 |
|
|
? gen_rtx_MEM (Pmode, plus_constant (virtual_incoming_args_rtx, -4))
|
| 1185 |
|
|
: NULL_RTX;
|
| 1186 |
|
|
}
|
| 1187 |
|
|
|
| 1188 |
|
|
/* Accessor used in cris.md:return because cfun->machine isn't available
|
| 1189 |
|
|
there. */
|
| 1190 |
|
|
|
| 1191 |
|
|
bool
|
| 1192 |
|
|
cris_return_address_on_stack (void)
|
| 1193 |
|
|
{
|
| 1194 |
|
|
return df_regs_ever_live_p (CRIS_SRP_REGNUM)
|
| 1195 |
|
|
|| cfun->machine->needs_return_address_on_stack;
|
| 1196 |
|
|
}
|
| 1197 |
|
|
|
| 1198 |
|
|
/* Accessor used in cris.md:return because cfun->machine isn't available
|
| 1199 |
|
|
there. */
|
| 1200 |
|
|
|
| 1201 |
|
|
bool
|
| 1202 |
|
|
cris_return_address_on_stack_for_return (void)
|
| 1203 |
|
|
{
|
| 1204 |
|
|
return cfun->machine->return_type == CRIS_RETINSN_RET ? false
|
| 1205 |
|
|
: cris_return_address_on_stack ();
|
| 1206 |
|
|
}
|
| 1207 |
|
|
|
| 1208 |
|
|
/* This used to be the INITIAL_FRAME_POINTER_OFFSET worker; now only
|
| 1209 |
|
|
handles FP -> SP elimination offset. */
|
| 1210 |
|
|
|
| 1211 |
|
|
static int
|
| 1212 |
|
|
cris_initial_frame_pointer_offset (void)
|
| 1213 |
|
|
{
|
| 1214 |
|
|
int regno;
|
| 1215 |
|
|
|
| 1216 |
|
|
/* Initial offset is 0 if we don't have a frame pointer. */
|
| 1217 |
|
|
int offs = 0;
|
| 1218 |
|
|
bool got_really_used = false;
|
| 1219 |
|
|
|
| 1220 |
|
|
if (crtl->uses_pic_offset_table)
|
| 1221 |
|
|
{
|
| 1222 |
|
|
push_topmost_sequence ();
|
| 1223 |
|
|
got_really_used
|
| 1224 |
|
|
= reg_used_between_p (pic_offset_table_rtx, get_insns (),
|
| 1225 |
|
|
NULL_RTX);
|
| 1226 |
|
|
pop_topmost_sequence ();
|
| 1227 |
|
|
}
|
| 1228 |
|
|
|
| 1229 |
|
|
/* And 4 for each register pushed. */
|
| 1230 |
|
|
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
|
| 1231 |
|
|
if (cris_reg_saved_in_regsave_area (regno, got_really_used))
|
| 1232 |
|
|
offs += 4;
|
| 1233 |
|
|
|
| 1234 |
|
|
/* And then, last, we add the locals allocated. */
|
| 1235 |
|
|
offs += get_frame_size ();
|
| 1236 |
|
|
|
| 1237 |
|
|
/* And more; the accumulated args size. */
|
| 1238 |
|
|
offs += crtl->outgoing_args_size;
|
| 1239 |
|
|
|
| 1240 |
|
|
/* Then round it off, in case we use aligned stack. */
|
| 1241 |
|
|
if (TARGET_STACK_ALIGN)
|
| 1242 |
|
|
offs = TARGET_ALIGN_BY_32 ? (offs + 3) & ~3 : (offs + 1) & ~1;
|
| 1243 |
|
|
|
| 1244 |
|
|
return offs;
|
| 1245 |
|
|
}
|
| 1246 |
|
|
|
| 1247 |
|
|
/* The INITIAL_ELIMINATION_OFFSET worker.
|
| 1248 |
|
|
Calculate the difference between imaginary registers such as frame
|
| 1249 |
|
|
pointer and the stack pointer. Used to eliminate the frame pointer
|
| 1250 |
|
|
and imaginary arg pointer. */
|
| 1251 |
|
|
|
| 1252 |
|
|
int
|
| 1253 |
|
|
cris_initial_elimination_offset (int fromreg, int toreg)
|
| 1254 |
|
|
{
|
| 1255 |
|
|
int fp_sp_offset
|
| 1256 |
|
|
= cris_initial_frame_pointer_offset ();
|
| 1257 |
|
|
|
| 1258 |
|
|
/* We should be able to use regs_ever_live and related prologue
|
| 1259 |
|
|
information here, or alpha should not as well. */
|
| 1260 |
|
|
bool return_address_on_stack = cris_return_address_on_stack ();
|
| 1261 |
|
|
|
| 1262 |
|
|
/* Here we act as if the frame-pointer were needed. */
|
| 1263 |
|
|
int ap_fp_offset = 4 + (return_address_on_stack ? 4 : 0);
|
| 1264 |
|
|
|
| 1265 |
|
|
if (fromreg == ARG_POINTER_REGNUM
|
| 1266 |
|
|
&& toreg == FRAME_POINTER_REGNUM)
|
| 1267 |
|
|
return ap_fp_offset;
|
| 1268 |
|
|
|
| 1269 |
|
|
/* Between the frame pointer and the stack are only "normal" stack
|
| 1270 |
|
|
variables and saved registers. */
|
| 1271 |
|
|
if (fromreg == FRAME_POINTER_REGNUM
|
| 1272 |
|
|
&& toreg == STACK_POINTER_REGNUM)
|
| 1273 |
|
|
return fp_sp_offset;
|
| 1274 |
|
|
|
| 1275 |
|
|
/* We need to balance out the frame pointer here. */
|
| 1276 |
|
|
if (fromreg == ARG_POINTER_REGNUM
|
| 1277 |
|
|
&& toreg == STACK_POINTER_REGNUM)
|
| 1278 |
|
|
return ap_fp_offset + fp_sp_offset - 4;
|
| 1279 |
|
|
|
| 1280 |
|
|
gcc_unreachable ();
|
| 1281 |
|
|
}
|
| 1282 |
|
|
|
| 1283 |
|
|
/* Nonzero if X is a hard reg that can be used as an index. */
|
| 1284 |
|
|
static inline bool
|
| 1285 |
|
|
reg_ok_for_base_p (const_rtx x, bool strict)
|
| 1286 |
|
|
{
|
| 1287 |
|
|
return ((! strict && ! HARD_REGISTER_P (x))
|
| 1288 |
|
|
|| REGNO_OK_FOR_BASE_P (REGNO (x)));
|
| 1289 |
|
|
}
|
| 1290 |
|
|
|
| 1291 |
|
|
/* Nonzero if X is a hard reg that can be used as an index. */
|
| 1292 |
|
|
static inline bool
|
| 1293 |
|
|
reg_ok_for_index_p (const_rtx x, bool strict)
|
| 1294 |
|
|
{
|
| 1295 |
|
|
return reg_ok_for_base_p (x, strict);
|
| 1296 |
|
|
}
|
| 1297 |
|
|
|
| 1298 |
|
|
/* No symbol can be used as an index (or more correct, as a base) together
|
| 1299 |
|
|
with a register with PIC; the PIC register must be there. */
|
| 1300 |
|
|
|
| 1301 |
|
|
bool
|
| 1302 |
|
|
cris_constant_index_p (const_rtx x)
|
| 1303 |
|
|
{
|
| 1304 |
|
|
return (CONSTANT_P (x) && (!flag_pic || cris_valid_pic_const (x, true)));
|
| 1305 |
|
|
}
|
| 1306 |
|
|
|
| 1307 |
|
|
/* True if X is a valid base register. */
|
| 1308 |
|
|
|
| 1309 |
|
|
bool
|
| 1310 |
|
|
cris_base_p (const_rtx x, bool strict)
|
| 1311 |
|
|
{
|
| 1312 |
|
|
return (REG_P (x) && reg_ok_for_base_p (x, strict));
|
| 1313 |
|
|
}
|
| 1314 |
|
|
|
| 1315 |
|
|
/* True if X is a valid index register. */
|
| 1316 |
|
|
|
| 1317 |
|
|
static inline bool
|
| 1318 |
|
|
cris_index_p (const_rtx x, bool strict)
|
| 1319 |
|
|
{
|
| 1320 |
|
|
return (REG_P (x) && reg_ok_for_index_p (x, strict));
|
| 1321 |
|
|
}
|
| 1322 |
|
|
|
| 1323 |
|
|
/* True if X is a valid base register with or without autoincrement. */
|
| 1324 |
|
|
|
| 1325 |
|
|
bool
|
| 1326 |
|
|
cris_base_or_autoincr_p (const_rtx x, bool strict)
|
| 1327 |
|
|
{
|
| 1328 |
|
|
return (cris_base_p (x, strict)
|
| 1329 |
|
|
|| (GET_CODE (x) == POST_INC
|
| 1330 |
|
|
&& cris_base_p (XEXP (x, 0), strict)
|
| 1331 |
|
|
&& REGNO (XEXP (x, 0)) != CRIS_ACR_REGNUM));
|
| 1332 |
|
|
}
|
| 1333 |
|
|
|
| 1334 |
|
|
/* True if X is a valid (register) index for BDAP, i.e. [Rs].S or [Rs+].S. */
|
| 1335 |
|
|
|
| 1336 |
|
|
bool
|
| 1337 |
|
|
cris_bdap_index_p (const_rtx x, bool strict)
|
| 1338 |
|
|
{
|
| 1339 |
|
|
return ((MEM_P (x)
|
| 1340 |
|
|
&& GET_MODE (x) == SImode
|
| 1341 |
|
|
&& cris_base_or_autoincr_p (XEXP (x, 0), strict))
|
| 1342 |
|
|
|| (GET_CODE (x) == SIGN_EXTEND
|
| 1343 |
|
|
&& MEM_P (XEXP (x, 0))
|
| 1344 |
|
|
&& (GET_MODE (XEXP (x, 0)) == HImode
|
| 1345 |
|
|
|| GET_MODE (XEXP (x, 0)) == QImode)
|
| 1346 |
|
|
&& cris_base_or_autoincr_p (XEXP (XEXP (x, 0), 0), strict)));
|
| 1347 |
|
|
}
|
| 1348 |
|
|
|
| 1349 |
|
|
/* True if X is a valid (register) index for BIAP, i.e. Rd.m. */
|
| 1350 |
|
|
|
| 1351 |
|
|
bool
|
| 1352 |
|
|
cris_biap_index_p (const_rtx x, bool strict)
|
| 1353 |
|
|
{
|
| 1354 |
|
|
return (cris_index_p (x, strict)
|
| 1355 |
|
|
|| (GET_CODE (x) == MULT
|
| 1356 |
|
|
&& cris_index_p (XEXP (x, 0), strict)
|
| 1357 |
|
|
&& cris_scale_int_operand (XEXP (x, 1), VOIDmode)));
|
| 1358 |
|
|
}
|
| 1359 |
|
|
|
| 1360 |
|
|
/* Worker function for TARGET_LEGITIMATE_ADDRESS_P.
|
| 1361 |
|
|
|
| 1362 |
|
|
A PIC operand looks like a normal symbol here. At output we dress it
|
| 1363 |
|
|
in "[rPIC+symbol:GOT]" (global symbol) or "rPIC+symbol:GOTOFF" (local
|
| 1364 |
|
|
symbol) so we exclude all addressing modes where we can't replace a
|
| 1365 |
|
|
plain "symbol" with that. A global PIC symbol does not fit anywhere
|
| 1366 |
|
|
here (but is thankfully a general_operand in itself). A local PIC
|
| 1367 |
|
|
symbol is valid for the plain "symbol + offset" case. */
|
| 1368 |
|
|
|
| 1369 |
|
|
static bool
|
| 1370 |
|
|
cris_legitimate_address_p (enum machine_mode mode, rtx x, bool strict)
|
| 1371 |
|
|
{
|
| 1372 |
|
|
const_rtx x1, x2;
|
| 1373 |
|
|
|
| 1374 |
|
|
if (cris_base_or_autoincr_p (x, strict))
|
| 1375 |
|
|
return true;
|
| 1376 |
|
|
else if (TARGET_V32)
|
| 1377 |
|
|
/* Nothing else is valid then. */
|
| 1378 |
|
|
return false;
|
| 1379 |
|
|
else if (cris_constant_index_p (x))
|
| 1380 |
|
|
return true;
|
| 1381 |
|
|
/* Indexed? */
|
| 1382 |
|
|
else if (GET_CODE (x) == PLUS)
|
| 1383 |
|
|
{
|
| 1384 |
|
|
x1 = XEXP (x, 0);
|
| 1385 |
|
|
x2 = XEXP (x, 1);
|
| 1386 |
|
|
/* BDAP o, Rd. */
|
| 1387 |
|
|
if ((cris_base_p (x1, strict) && cris_constant_index_p (x2))
|
| 1388 |
|
|
|| (cris_base_p (x2, strict) && cris_constant_index_p (x1))
|
| 1389 |
|
|
/* BDAP Rs[+], Rd. */
|
| 1390 |
|
|
|| (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
|
| 1391 |
|
|
&& ((cris_base_p (x1, strict)
|
| 1392 |
|
|
&& cris_bdap_index_p (x2, strict))
|
| 1393 |
|
|
|| (cris_base_p (x2, strict)
|
| 1394 |
|
|
&& cris_bdap_index_p (x1, strict))
|
| 1395 |
|
|
/* BIAP.m Rs, Rd */
|
| 1396 |
|
|
|| (cris_base_p (x1, strict)
|
| 1397 |
|
|
&& cris_biap_index_p (x2, strict))
|
| 1398 |
|
|
|| (cris_base_p (x2, strict)
|
| 1399 |
|
|
&& cris_biap_index_p (x1, strict)))))
|
| 1400 |
|
|
return true;
|
| 1401 |
|
|
}
|
| 1402 |
|
|
else if (MEM_P (x))
|
| 1403 |
|
|
{
|
| 1404 |
|
|
/* DIP (Rs). Reject [[reg+]] and [[reg]] for DImode (long long). */
|
| 1405 |
|
|
if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
|
| 1406 |
|
|
&& cris_base_or_autoincr_p (XEXP (x, 0), strict))
|
| 1407 |
|
|
return true;
|
| 1408 |
|
|
}
|
| 1409 |
|
|
|
| 1410 |
|
|
return false;
|
| 1411 |
|
|
}
|
| 1412 |
|
|
|
| 1413 |
|
|
/* Worker function for LEGITIMIZE_RELOAD_ADDRESS. */
|
| 1414 |
|
|
|
| 1415 |
|
|
bool
|
| 1416 |
|
|
cris_reload_address_legitimized (rtx x,
|
| 1417 |
|
|
enum machine_mode mode ATTRIBUTE_UNUSED,
|
| 1418 |
|
|
int opnum ATTRIBUTE_UNUSED,
|
| 1419 |
|
|
int itype,
|
| 1420 |
|
|
int ind_levels ATTRIBUTE_UNUSED)
|
| 1421 |
|
|
{
|
| 1422 |
|
|
enum reload_type type = (enum reload_type) itype;
|
| 1423 |
|
|
rtx op0, op1;
|
| 1424 |
|
|
rtx *op1p;
|
| 1425 |
|
|
|
| 1426 |
|
|
if (GET_CODE (x) != PLUS)
|
| 1427 |
|
|
return false;
|
| 1428 |
|
|
|
| 1429 |
|
|
if (TARGET_V32)
|
| 1430 |
|
|
return false;
|
| 1431 |
|
|
|
| 1432 |
|
|
op0 = XEXP (x, 0);
|
| 1433 |
|
|
op1 = XEXP (x, 1);
|
| 1434 |
|
|
op1p = &XEXP (x, 1);
|
| 1435 |
|
|
|
| 1436 |
|
|
if (!REG_P (op1))
|
| 1437 |
|
|
return false;
|
| 1438 |
|
|
|
| 1439 |
|
|
if (GET_CODE (op0) == SIGN_EXTEND && MEM_P (XEXP (op0, 0)))
|
| 1440 |
|
|
{
|
| 1441 |
|
|
rtx op00 = XEXP (op0, 0);
|
| 1442 |
|
|
rtx op000 = XEXP (op00, 0);
|
| 1443 |
|
|
rtx *op000p = &XEXP (op00, 0);
|
| 1444 |
|
|
|
| 1445 |
|
|
if ((GET_MODE (op00) == HImode || GET_MODE (op00) == QImode)
|
| 1446 |
|
|
&& (REG_P (op000)
|
| 1447 |
|
|
|| (GET_CODE (op000) == POST_INC && REG_P (XEXP (op000, 0)))))
|
| 1448 |
|
|
{
|
| 1449 |
|
|
bool something_reloaded = false;
|
| 1450 |
|
|
|
| 1451 |
|
|
if (GET_CODE (op000) == POST_INC
|
| 1452 |
|
|
&& REG_P (XEXP (op000, 0))
|
| 1453 |
|
|
&& REGNO (XEXP (op000, 0)) > CRIS_LAST_GENERAL_REGISTER)
|
| 1454 |
|
|
/* No, this gets too complicated and is too rare to care
|
| 1455 |
|
|
about trying to improve on the general code Here.
|
| 1456 |
|
|
As the return-value is an all-or-nothing indicator, we
|
| 1457 |
|
|
punt on the other register too. */
|
| 1458 |
|
|
return false;
|
| 1459 |
|
|
|
| 1460 |
|
|
if ((REG_P (op000)
|
| 1461 |
|
|
&& REGNO (op000) > CRIS_LAST_GENERAL_REGISTER))
|
| 1462 |
|
|
{
|
| 1463 |
|
|
/* The address of the inner mem is a pseudo or wrong
|
| 1464 |
|
|
reg: reload that. */
|
| 1465 |
|
|
push_reload (op000, NULL_RTX, op000p, NULL, GENERAL_REGS,
|
| 1466 |
|
|
GET_MODE (x), VOIDmode, 0, 0, opnum, type);
|
| 1467 |
|
|
something_reloaded = true;
|
| 1468 |
|
|
}
|
| 1469 |
|
|
|
| 1470 |
|
|
if (REGNO (op1) > CRIS_LAST_GENERAL_REGISTER)
|
| 1471 |
|
|
{
|
| 1472 |
|
|
/* Base register is a pseudo or wrong reg: reload it. */
|
| 1473 |
|
|
push_reload (op1, NULL_RTX, op1p, NULL, GENERAL_REGS,
|
| 1474 |
|
|
GET_MODE (x), VOIDmode, 0, 0,
|
| 1475 |
|
|
opnum, type);
|
| 1476 |
|
|
something_reloaded = true;
|
| 1477 |
|
|
}
|
| 1478 |
|
|
|
| 1479 |
|
|
gcc_assert (something_reloaded);
|
| 1480 |
|
|
|
| 1481 |
|
|
return true;
|
| 1482 |
|
|
}
|
| 1483 |
|
|
}
|
| 1484 |
|
|
|
| 1485 |
|
|
return false;
|
| 1486 |
|
|
}
|
| 1487 |
|
|
|
| 1488 |
|
|
|
| 1489 |
|
|
/* Worker function for TARGET_PREFERRED_RELOAD_CLASS.
|
| 1490 |
|
|
|
| 1491 |
|
|
It seems like gcc (2.7.2 and 2.9x of 2000-03-22) may send "NO_REGS" as
|
| 1492 |
|
|
the class for a constant (testcase: __Mul in arit.c). To avoid forcing
|
| 1493 |
|
|
out a constant into the constant pool, we will trap this case and
|
| 1494 |
|
|
return something a bit more sane. FIXME: Check if this is a bug.
|
| 1495 |
|
|
Beware that we must not "override" classes that can be specified as
|
| 1496 |
|
|
constraint letters, or else asm operands using them will fail when
|
| 1497 |
|
|
they need to be reloaded. FIXME: Investigate whether that constitutes
|
| 1498 |
|
|
a bug. */
|
| 1499 |
|
|
|
| 1500 |
|
|
static reg_class_t
|
| 1501 |
|
|
cris_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass)
|
| 1502 |
|
|
{
|
| 1503 |
|
|
if (rclass != ACR_REGS
|
| 1504 |
|
|
&& rclass != MOF_REGS
|
| 1505 |
|
|
&& rclass != SRP_REGS
|
| 1506 |
|
|
&& rclass != CC0_REGS
|
| 1507 |
|
|
&& rclass != SPECIAL_REGS)
|
| 1508 |
|
|
return GENERAL_REGS;
|
| 1509 |
|
|
|
| 1510 |
|
|
return rclass;
|
| 1511 |
|
|
}
|
| 1512 |
|
|
|
| 1513 |
|
|
/* Worker function for TARGET_REGISTER_MOVE_COST. */
|
| 1514 |
|
|
|
| 1515 |
|
|
static int
|
| 1516 |
|
|
cris_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
|
| 1517 |
|
|
reg_class_t from, reg_class_t to)
|
| 1518 |
|
|
{
|
| 1519 |
|
|
/* Can't move to and from a SPECIAL_REGS register, so we have to say
|
| 1520 |
|
|
their move cost within that class is higher. How about 7? That's 3
|
| 1521 |
|
|
for a move to a GENERAL_REGS register, 3 for the move from the
|
| 1522 |
|
|
GENERAL_REGS register, and 1 for the increased register pressure.
|
| 1523 |
|
|
Also, it's higher than the memory move cost, as it should.
|
| 1524 |
|
|
We also do this for ALL_REGS, since we don't want that class to be
|
| 1525 |
|
|
preferred (even to memory) at all where GENERAL_REGS doesn't fit.
|
| 1526 |
|
|
Whenever it's about to be used, it's for SPECIAL_REGS. If we don't
|
| 1527 |
|
|
present a higher cost for ALL_REGS than memory, a SPECIAL_REGS may be
|
| 1528 |
|
|
used when a GENERAL_REGS should be used, even if there are call-saved
|
| 1529 |
|
|
GENERAL_REGS left to allocate. This is because the fall-back when
|
| 1530 |
|
|
the most preferred register class isn't available, isn't the next
|
| 1531 |
|
|
(or next good) wider register class, but the *most widest* register
|
| 1532 |
|
|
class. FIXME: pre-IRA comment, perhaps obsolete now. */
|
| 1533 |
|
|
|
| 1534 |
|
|
if ((reg_classes_intersect_p (from, SPECIAL_REGS)
|
| 1535 |
|
|
&& reg_classes_intersect_p (to, SPECIAL_REGS))
|
| 1536 |
|
|
|| from == ALL_REGS || to == ALL_REGS)
|
| 1537 |
|
|
return 7;
|
| 1538 |
|
|
|
| 1539 |
|
|
/* Make moves to/from SPECIAL_REGS slightly more expensive, as we
|
| 1540 |
|
|
generally prefer GENERAL_REGS. */
|
| 1541 |
|
|
if (reg_classes_intersect_p (from, SPECIAL_REGS)
|
| 1542 |
|
|
|| reg_classes_intersect_p (to, SPECIAL_REGS))
|
| 1543 |
|
|
return 3;
|
| 1544 |
|
|
|
| 1545 |
|
|
return 2;
|
| 1546 |
|
|
}
|
| 1547 |
|
|
|
| 1548 |
|
|
/* Worker function for TARGET_MEMORY_MOVE_COST.
|
| 1549 |
|
|
|
| 1550 |
|
|
This isn't strictly correct for v0..3 in buswidth-8bit mode, but should
|
| 1551 |
|
|
suffice. */
|
| 1552 |
|
|
|
| 1553 |
|
|
static int
|
| 1554 |
|
|
cris_memory_move_cost (enum machine_mode mode,
|
| 1555 |
|
|
reg_class_t rclass ATTRIBUTE_UNUSED,
|
| 1556 |
|
|
bool in ATTRIBUTE_UNUSED)
|
| 1557 |
|
|
{
|
| 1558 |
|
|
if (mode == QImode
|
| 1559 |
|
|
|| mode == HImode)
|
| 1560 |
|
|
return 4;
|
| 1561 |
|
|
else
|
| 1562 |
|
|
return 6;
|
| 1563 |
|
|
}
|
| 1564 |
|
|
|
| 1565 |
|
|
/* Worker for cris_notice_update_cc; handles the "normal" cases.
|
| 1566 |
|
|
FIXME: this code is historical; its functionality should be
|
| 1567 |
|
|
refactored to look at insn attributes and moved to
|
| 1568 |
|
|
cris_notice_update_cc. Except, we better lose cc0 entirely. */
|
| 1569 |
|
|
|
| 1570 |
|
|
static void
|
| 1571 |
|
|
cris_normal_notice_update_cc (rtx exp, rtx insn)
|
| 1572 |
|
|
{
|
| 1573 |
|
|
/* "Normal" means, for:
|
| 1574 |
|
|
(set (cc0) (...)):
|
| 1575 |
|
|
CC is (...).
|
| 1576 |
|
|
|
| 1577 |
|
|
(set (reg) (...)):
|
| 1578 |
|
|
CC is (reg) and (...) - unless (...) is 0 or reg is a special
|
| 1579 |
|
|
register or (v32 and (...) is -32..-1), then CC does not change.
|
| 1580 |
|
|
CC_NO_OVERFLOW unless (...) is reg or mem.
|
| 1581 |
|
|
|
| 1582 |
|
|
(set (mem) (...)):
|
| 1583 |
|
|
CC does not change.
|
| 1584 |
|
|
|
| 1585 |
|
|
(set (pc) (...)):
|
| 1586 |
|
|
CC does not change.
|
| 1587 |
|
|
|
| 1588 |
|
|
(parallel
|
| 1589 |
|
|
(set (reg1) (mem (bdap/biap)))
|
| 1590 |
|
|
(set (reg2) (bdap/biap))):
|
| 1591 |
|
|
CC is (reg1) and (mem (reg2))
|
| 1592 |
|
|
|
| 1593 |
|
|
(parallel
|
| 1594 |
|
|
(set (mem (bdap/biap)) (reg1)) [or 0]
|
| 1595 |
|
|
(set (reg2) (bdap/biap))):
|
| 1596 |
|
|
CC does not change.
|
| 1597 |
|
|
|
| 1598 |
|
|
(where reg and mem includes strict_low_parts variants thereof)
|
| 1599 |
|
|
|
| 1600 |
|
|
For all others, assume CC is clobbered.
|
| 1601 |
|
|
Note that we do not have to care about setting CC_NO_OVERFLOW,
|
| 1602 |
|
|
since the overflow flag is set to 0 (i.e. right) for
|
| 1603 |
|
|
instructions where it does not have any sane sense, but where
|
| 1604 |
|
|
other flags have meanings. (This includes shifts; the carry is
|
| 1605 |
|
|
not set by them).
|
| 1606 |
|
|
|
| 1607 |
|
|
Note that there are other parallel constructs we could match,
|
| 1608 |
|
|
but we don't do that yet. */
|
| 1609 |
|
|
|
| 1610 |
|
|
if (GET_CODE (exp) == SET)
|
| 1611 |
|
|
{
|
| 1612 |
|
|
/* FIXME: Check when this happens. It looks like we should
|
| 1613 |
|
|
actually do a CC_STATUS_INIT here to be safe. */
|
| 1614 |
|
|
if (SET_DEST (exp) == pc_rtx)
|
| 1615 |
|
|
return;
|
| 1616 |
|
|
|
| 1617 |
|
|
/* Record CC0 changes, so we do not have to output multiple
|
| 1618 |
|
|
test insns. */
|
| 1619 |
|
|
if (SET_DEST (exp) == cc0_rtx)
|
| 1620 |
|
|
{
|
| 1621 |
|
|
CC_STATUS_INIT;
|
| 1622 |
|
|
|
| 1623 |
|
|
if (GET_CODE (SET_SRC (exp)) == COMPARE
|
| 1624 |
|
|
&& XEXP (SET_SRC (exp), 1) == const0_rtx)
|
| 1625 |
|
|
cc_status.value1 = XEXP (SET_SRC (exp), 0);
|
| 1626 |
|
|
else
|
| 1627 |
|
|
cc_status.value1 = SET_SRC (exp);
|
| 1628 |
|
|
|
| 1629 |
|
|
/* Handle flags for the special btstq on one bit. */
|
| 1630 |
|
|
if (GET_CODE (cc_status.value1) == ZERO_EXTRACT
|
| 1631 |
|
|
&& XEXP (cc_status.value1, 1) == const1_rtx)
|
| 1632 |
|
|
{
|
| 1633 |
|
|
if (CONST_INT_P (XEXP (cc_status.value1, 0)))
|
| 1634 |
|
|
/* Using cmpq. */
|
| 1635 |
|
|
cc_status.flags = CC_INVERTED;
|
| 1636 |
|
|
else
|
| 1637 |
|
|
/* A one-bit btstq. */
|
| 1638 |
|
|
cc_status.flags = CC_Z_IN_NOT_N;
|
| 1639 |
|
|
}
|
| 1640 |
|
|
|
| 1641 |
|
|
else if (GET_CODE (SET_SRC (exp)) == COMPARE)
|
| 1642 |
|
|
{
|
| 1643 |
|
|
if (!REG_P (XEXP (SET_SRC (exp), 0))
|
| 1644 |
|
|
&& XEXP (SET_SRC (exp), 1) != const0_rtx)
|
| 1645 |
|
|
/* For some reason gcc will not canonicalize compare
|
| 1646 |
|
|
operations, reversing the sign by itself if
|
| 1647 |
|
|
operands are in wrong order. */
|
| 1648 |
|
|
/* (But NOT inverted; eq is still eq.) */
|
| 1649 |
|
|
cc_status.flags = CC_REVERSED;
|
| 1650 |
|
|
|
| 1651 |
|
|
/* This seems to be overlooked by gcc. FIXME: Check again.
|
| 1652 |
|
|
FIXME: Is it really safe? */
|
| 1653 |
|
|
cc_status.value2
|
| 1654 |
|
|
= gen_rtx_MINUS (GET_MODE (SET_SRC (exp)),
|
| 1655 |
|
|
XEXP (SET_SRC (exp), 0),
|
| 1656 |
|
|
XEXP (SET_SRC (exp), 1));
|
| 1657 |
|
|
}
|
| 1658 |
|
|
return;
|
| 1659 |
|
|
}
|
| 1660 |
|
|
else if (REG_P (SET_DEST (exp))
|
| 1661 |
|
|
|| (GET_CODE (SET_DEST (exp)) == STRICT_LOW_PART
|
| 1662 |
|
|
&& REG_P (XEXP (SET_DEST (exp), 0))))
|
| 1663 |
|
|
{
|
| 1664 |
|
|
/* A register is set; normally CC is set to show that no
|
| 1665 |
|
|
test insn is needed. Catch the exceptions. */
|
| 1666 |
|
|
|
| 1667 |
|
|
/* If not to cc0, then no "set"s in non-natural mode give
|
| 1668 |
|
|
ok cc0... */
|
| 1669 |
|
|
if (GET_MODE_SIZE (GET_MODE (SET_DEST (exp))) > UNITS_PER_WORD
|
| 1670 |
|
|
|| GET_MODE_CLASS (GET_MODE (SET_DEST (exp))) == MODE_FLOAT)
|
| 1671 |
|
|
{
|
| 1672 |
|
|
/* ... except add:s and sub:s in DImode. */
|
| 1673 |
|
|
if (GET_MODE (SET_DEST (exp)) == DImode
|
| 1674 |
|
|
&& (GET_CODE (SET_SRC (exp)) == PLUS
|
| 1675 |
|
|
|| GET_CODE (SET_SRC (exp)) == MINUS))
|
| 1676 |
|
|
{
|
| 1677 |
|
|
CC_STATUS_INIT;
|
| 1678 |
|
|
cc_status.value1 = SET_DEST (exp);
|
| 1679 |
|
|
cc_status.value2 = SET_SRC (exp);
|
| 1680 |
|
|
|
| 1681 |
|
|
if (cris_reg_overlap_mentioned_p (cc_status.value1,
|
| 1682 |
|
|
cc_status.value2))
|
| 1683 |
|
|
cc_status.value2 = 0;
|
| 1684 |
|
|
|
| 1685 |
|
|
/* Add and sub may set V, which gets us
|
| 1686 |
|
|
unoptimizable results in "gt" and "le" condition
|
| 1687 |
|
|
codes. */
|
| 1688 |
|
|
cc_status.flags |= CC_NO_OVERFLOW;
|
| 1689 |
|
|
|
| 1690 |
|
|
return;
|
| 1691 |
|
|
}
|
| 1692 |
|
|
}
|
| 1693 |
|
|
else if (SET_SRC (exp) == const0_rtx
|
| 1694 |
|
|
|| (REG_P (SET_SRC (exp))
|
| 1695 |
|
|
&& (REGNO (SET_SRC (exp))
|
| 1696 |
|
|
> CRIS_LAST_GENERAL_REGISTER))
|
| 1697 |
|
|
|| (TARGET_V32
|
| 1698 |
|
|
&& satisfies_constraint_I (SET_SRC (exp))))
|
| 1699 |
|
|
{
|
| 1700 |
|
|
/* There's no CC0 change for this case. Just check
|
| 1701 |
|
|
for overlap. */
|
| 1702 |
|
|
if (cc_status.value1
|
| 1703 |
|
|
&& modified_in_p (cc_status.value1, insn))
|
| 1704 |
|
|
cc_status.value1 = 0;
|
| 1705 |
|
|
|
| 1706 |
|
|
if (cc_status.value2
|
| 1707 |
|
|
&& modified_in_p (cc_status.value2, insn))
|
| 1708 |
|
|
cc_status.value2 = 0;
|
| 1709 |
|
|
|
| 1710 |
|
|
return;
|
| 1711 |
|
|
}
|
| 1712 |
|
|
else
|
| 1713 |
|
|
{
|
| 1714 |
|
|
CC_STATUS_INIT;
|
| 1715 |
|
|
cc_status.value1 = SET_DEST (exp);
|
| 1716 |
|
|
cc_status.value2 = SET_SRC (exp);
|
| 1717 |
|
|
|
| 1718 |
|
|
if (cris_reg_overlap_mentioned_p (cc_status.value1,
|
| 1719 |
|
|
cc_status.value2))
|
| 1720 |
|
|
cc_status.value2 = 0;
|
| 1721 |
|
|
|
| 1722 |
|
|
/* Some operations may set V, which gets us
|
| 1723 |
|
|
unoptimizable results in "gt" and "le" condition
|
| 1724 |
|
|
codes. */
|
| 1725 |
|
|
if (GET_CODE (SET_SRC (exp)) == PLUS
|
| 1726 |
|
|
|| GET_CODE (SET_SRC (exp)) == MINUS
|
| 1727 |
|
|
|| GET_CODE (SET_SRC (exp)) == NEG)
|
| 1728 |
|
|
cc_status.flags |= CC_NO_OVERFLOW;
|
| 1729 |
|
|
|
| 1730 |
|
|
/* For V32, nothing with a register destination sets
|
| 1731 |
|
|
C and V usefully. */
|
| 1732 |
|
|
if (TARGET_V32)
|
| 1733 |
|
|
cc_status.flags |= CC_NO_OVERFLOW;
|
| 1734 |
|
|
|
| 1735 |
|
|
return;
|
| 1736 |
|
|
}
|
| 1737 |
|
|
}
|
| 1738 |
|
|
else if (MEM_P (SET_DEST (exp))
|
| 1739 |
|
|
|| (GET_CODE (SET_DEST (exp)) == STRICT_LOW_PART
|
| 1740 |
|
|
&& MEM_P (XEXP (SET_DEST (exp), 0))))
|
| 1741 |
|
|
{
|
| 1742 |
|
|
/* When SET to MEM, then CC is not changed (except for
|
| 1743 |
|
|
overlap). */
|
| 1744 |
|
|
if (cc_status.value1
|
| 1745 |
|
|
&& modified_in_p (cc_status.value1, insn))
|
| 1746 |
|
|
cc_status.value1 = 0;
|
| 1747 |
|
|
|
| 1748 |
|
|
if (cc_status.value2
|
| 1749 |
|
|
&& modified_in_p (cc_status.value2, insn))
|
| 1750 |
|
|
cc_status.value2 = 0;
|
| 1751 |
|
|
|
| 1752 |
|
|
return;
|
| 1753 |
|
|
}
|
| 1754 |
|
|
}
|
| 1755 |
|
|
else if (GET_CODE (exp) == PARALLEL)
|
| 1756 |
|
|
{
|
| 1757 |
|
|
if (GET_CODE (XVECEXP (exp, 0, 0)) == SET
|
| 1758 |
|
|
&& GET_CODE (XVECEXP (exp, 0, 1)) == SET
|
| 1759 |
|
|
&& REG_P (XEXP (XVECEXP (exp, 0, 1), 0)))
|
| 1760 |
|
|
{
|
| 1761 |
|
|
if (REG_P (XEXP (XVECEXP (exp, 0, 0), 0))
|
| 1762 |
|
|
&& MEM_P (XEXP (XVECEXP (exp, 0, 0), 1)))
|
| 1763 |
|
|
{
|
| 1764 |
|
|
CC_STATUS_INIT;
|
| 1765 |
|
|
|
| 1766 |
|
|
/* For "move.S [rx=ry+o],rz", say CC reflects
|
| 1767 |
|
|
value1=rz and value2=[rx] */
|
| 1768 |
|
|
cc_status.value1 = XEXP (XVECEXP (exp, 0, 0), 0);
|
| 1769 |
|
|
cc_status.value2
|
| 1770 |
|
|
= replace_equiv_address (XEXP (XVECEXP (exp, 0, 0), 1),
|
| 1771 |
|
|
XEXP (XVECEXP (exp, 0, 1), 0));
|
| 1772 |
|
|
|
| 1773 |
|
|
/* Huh? A side-effect cannot change the destination
|
| 1774 |
|
|
register. */
|
| 1775 |
|
|
if (cris_reg_overlap_mentioned_p (cc_status.value1,
|
| 1776 |
|
|
cc_status.value2))
|
| 1777 |
|
|
internal_error ("internal error: sideeffect-insn affecting main effect");
|
| 1778 |
|
|
|
| 1779 |
|
|
/* For V32, moves to registers don't set C and V. */
|
| 1780 |
|
|
if (TARGET_V32)
|
| 1781 |
|
|
cc_status.flags |= CC_NO_OVERFLOW;
|
| 1782 |
|
|
return;
|
| 1783 |
|
|
}
|
| 1784 |
|
|
else if ((REG_P (XEXP (XVECEXP (exp, 0, 0), 1))
|
| 1785 |
|
|
|| XEXP (XVECEXP (exp, 0, 0), 1) == const0_rtx)
|
| 1786 |
|
|
&& MEM_P (XEXP (XVECEXP (exp, 0, 0), 0)))
|
| 1787 |
|
|
{
|
| 1788 |
|
|
/* For "move.S rz,[rx=ry+o]" and "clear.S [rx=ry+o]",
|
| 1789 |
|
|
say flags are not changed, except for overlap. */
|
| 1790 |
|
|
if (cc_status.value1
|
| 1791 |
|
|
&& modified_in_p (cc_status.value1, insn))
|
| 1792 |
|
|
cc_status.value1 = 0;
|
| 1793 |
|
|
|
| 1794 |
|
|
if (cc_status.value2
|
| 1795 |
|
|
&& modified_in_p (cc_status.value2, insn))
|
| 1796 |
|
|
cc_status.value2 = 0;
|
| 1797 |
|
|
|
| 1798 |
|
|
return;
|
| 1799 |
|
|
}
|
| 1800 |
|
|
}
|
| 1801 |
|
|
}
|
| 1802 |
|
|
|
| 1803 |
|
|
/* If we got here, the case wasn't covered by the code above. */
|
| 1804 |
|
|
CC_STATUS_INIT;
|
| 1805 |
|
|
}
|
| 1806 |
|
|
|
| 1807 |
|
|
/* This function looks into the pattern to see how this insn affects
|
| 1808 |
|
|
condition codes.
|
| 1809 |
|
|
|
| 1810 |
|
|
Used when to eliminate test insns before a condition-code user,
|
| 1811 |
|
|
such as a "scc" insn or a conditional branch. This includes
|
| 1812 |
|
|
checking if the entities that cc was updated by, are changed by the
|
| 1813 |
|
|
operation.
|
| 1814 |
|
|
|
| 1815 |
|
|
Currently a jumble of the old peek-inside-the-insn and the newer
|
| 1816 |
|
|
check-cc-attribute methods. */
|
| 1817 |
|
|
|
| 1818 |
|
|
void
|
| 1819 |
|
|
cris_notice_update_cc (rtx exp, rtx insn)
|
| 1820 |
|
|
{
|
| 1821 |
|
|
enum attr_cc attrval = get_attr_cc (insn);
|
| 1822 |
|
|
|
| 1823 |
|
|
/* Check if user specified "-mcc-init" as a bug-workaround. Remember
|
| 1824 |
|
|
to still set CC_REVERSED as below, since that's required by some
|
| 1825 |
|
|
compare insn alternatives. (FIXME: GCC should do this virtual
|
| 1826 |
|
|
operand swap by itself.) A test-case that may otherwise fail is
|
| 1827 |
|
|
gcc.c-torture/execute/20000217-1.c -O0 and -O1. */
|
| 1828 |
|
|
if (TARGET_CCINIT)
|
| 1829 |
|
|
{
|
| 1830 |
|
|
CC_STATUS_INIT;
|
| 1831 |
|
|
|
| 1832 |
|
|
if (attrval == CC_REV)
|
| 1833 |
|
|
cc_status.flags = CC_REVERSED;
|
| 1834 |
|
|
return;
|
| 1835 |
|
|
}
|
| 1836 |
|
|
|
| 1837 |
|
|
/* Slowly, we're converting to using attributes to control the setting
|
| 1838 |
|
|
of condition-code status. */
|
| 1839 |
|
|
switch (attrval)
|
| 1840 |
|
|
{
|
| 1841 |
|
|
case CC_NONE:
|
| 1842 |
|
|
/* Even if it is "none", a setting may clobber a previous
|
| 1843 |
|
|
cc-value, so check. */
|
| 1844 |
|
|
if (GET_CODE (exp) == SET)
|
| 1845 |
|
|
{
|
| 1846 |
|
|
if (cc_status.value1
|
| 1847 |
|
|
&& modified_in_p (cc_status.value1, insn))
|
| 1848 |
|
|
cc_status.value1 = 0;
|
| 1849 |
|
|
|
| 1850 |
|
|
if (cc_status.value2
|
| 1851 |
|
|
&& modified_in_p (cc_status.value2, insn))
|
| 1852 |
|
|
cc_status.value2 = 0;
|
| 1853 |
|
|
}
|
| 1854 |
|
|
return;
|
| 1855 |
|
|
|
| 1856 |
|
|
case CC_CLOBBER:
|
| 1857 |
|
|
CC_STATUS_INIT;
|
| 1858 |
|
|
return;
|
| 1859 |
|
|
|
| 1860 |
|
|
case CC_REV:
|
| 1861 |
|
|
case CC_NOOV32:
|
| 1862 |
|
|
case CC_NORMAL:
|
| 1863 |
|
|
cris_normal_notice_update_cc (exp, insn);
|
| 1864 |
|
|
|
| 1865 |
|
|
/* The "test" insn doesn't clear (carry and) overflow on V32. We
|
| 1866 |
|
|
can change bge => bpl and blt => bmi by passing on to the cc0
|
| 1867 |
|
|
user that V should not be considered; bgt and ble are taken
|
| 1868 |
|
|
care of by other methods (see {tst,cmp}{si,hi,qi}). */
|
| 1869 |
|
|
if (attrval == CC_NOOV32 && TARGET_V32)
|
| 1870 |
|
|
cc_status.flags |= CC_NO_OVERFLOW;
|
| 1871 |
|
|
return;
|
| 1872 |
|
|
|
| 1873 |
|
|
default:
|
| 1874 |
|
|
internal_error ("unknown cc_attr value");
|
| 1875 |
|
|
}
|
| 1876 |
|
|
|
| 1877 |
|
|
CC_STATUS_INIT;
|
| 1878 |
|
|
}
|
| 1879 |
|
|
|
| 1880 |
|
|
/* Return != 0 if the return sequence for the current function is short,
|
| 1881 |
|
|
like "ret" or "jump [sp+]". Prior to reloading, we can't tell if
|
| 1882 |
|
|
registers must be saved, so return 0 then. */
|
| 1883 |
|
|
|
| 1884 |
|
|
bool
|
| 1885 |
|
|
cris_simple_epilogue (void)
|
| 1886 |
|
|
{
|
| 1887 |
|
|
unsigned int regno;
|
| 1888 |
|
|
unsigned int reglimit = STACK_POINTER_REGNUM;
|
| 1889 |
|
|
bool got_really_used = false;
|
| 1890 |
|
|
|
| 1891 |
|
|
if (! reload_completed
|
| 1892 |
|
|
|| frame_pointer_needed
|
| 1893 |
|
|
|| get_frame_size () != 0
|
| 1894 |
|
|
|| crtl->args.pretend_args_size
|
| 1895 |
|
|
|| crtl->args.size
|
| 1896 |
|
|
|| crtl->outgoing_args_size
|
| 1897 |
|
|
|| crtl->calls_eh_return
|
| 1898 |
|
|
|
| 1899 |
|
|
/* If we're not supposed to emit prologue and epilogue, we must
|
| 1900 |
|
|
not emit return-type instructions. */
|
| 1901 |
|
|
|| !TARGET_PROLOGUE_EPILOGUE)
|
| 1902 |
|
|
return false;
|
| 1903 |
|
|
|
| 1904 |
|
|
/* Can't return from stacked return address with v32. */
|
| 1905 |
|
|
if (TARGET_V32 && cris_return_address_on_stack ())
|
| 1906 |
|
|
return false;
|
| 1907 |
|
|
|
| 1908 |
|
|
if (crtl->uses_pic_offset_table)
|
| 1909 |
|
|
{
|
| 1910 |
|
|
push_topmost_sequence ();
|
| 1911 |
|
|
got_really_used
|
| 1912 |
|
|
= reg_used_between_p (pic_offset_table_rtx, get_insns (), NULL_RTX);
|
| 1913 |
|
|
pop_topmost_sequence ();
|
| 1914 |
|
|
}
|
| 1915 |
|
|
|
| 1916 |
|
|
/* No simple epilogue if there are saved registers. */
|
| 1917 |
|
|
for (regno = 0; regno < reglimit; regno++)
|
| 1918 |
|
|
if (cris_reg_saved_in_regsave_area (regno, got_really_used))
|
| 1919 |
|
|
return false;
|
| 1920 |
|
|
|
| 1921 |
|
|
return true;
|
| 1922 |
|
|
}
|
| 1923 |
|
|
|
| 1924 |
|
|
/* Expand a return insn (just one insn) marked as using SRP or stack
|
| 1925 |
|
|
slot depending on parameter ON_STACK. */
|
| 1926 |
|
|
|
| 1927 |
|
|
void
|
| 1928 |
|
|
cris_expand_return (bool on_stack)
|
| 1929 |
|
|
{
|
| 1930 |
|
|
/* FIXME: emit a parallel with a USE for SRP or the stack-slot, to
|
| 1931 |
|
|
tell "ret" from "jump [sp+]". Some, but not all, other parts of
|
| 1932 |
|
|
GCC expect just (return) to do the right thing when optimizing, so
|
| 1933 |
|
|
we do that until they're fixed. Currently, all return insns in a
|
| 1934 |
|
|
function must be the same (not really a limiting factor) so we need
|
| 1935 |
|
|
to check that it doesn't change half-way through. */
|
| 1936 |
|
|
emit_jump_insn (ret_rtx);
|
| 1937 |
|
|
|
| 1938 |
|
|
CRIS_ASSERT (cfun->machine->return_type != CRIS_RETINSN_RET || !on_stack);
|
| 1939 |
|
|
CRIS_ASSERT (cfun->machine->return_type != CRIS_RETINSN_JUMP || on_stack);
|
| 1940 |
|
|
|
| 1941 |
|
|
cfun->machine->return_type
|
| 1942 |
|
|
= on_stack ? CRIS_RETINSN_JUMP : CRIS_RETINSN_RET;
|
| 1943 |
|
|
}
|
| 1944 |
|
|
|
| 1945 |
|
|
/* Compute a (partial) cost for rtx X. Return true if the complete
|
| 1946 |
|
|
cost has been computed, and false if subexpressions should be
|
| 1947 |
|
|
scanned. In either case, *TOTAL contains the cost result. */
|
| 1948 |
|
|
|
| 1949 |
|
|
static bool
|
| 1950 |
|
|
cris_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
|
| 1951 |
|
|
bool speed)
|
| 1952 |
|
|
{
|
| 1953 |
|
|
switch (code)
|
| 1954 |
|
|
{
|
| 1955 |
|
|
case CONST_INT:
|
| 1956 |
|
|
{
|
| 1957 |
|
|
HOST_WIDE_INT val = INTVAL (x);
|
| 1958 |
|
|
if (val == 0)
|
| 1959 |
|
|
*total = 0;
|
| 1960 |
|
|
else if (val < 32 && val >= -32)
|
| 1961 |
|
|
*total = 1;
|
| 1962 |
|
|
/* Eight or 16 bits are a word and cycle more expensive. */
|
| 1963 |
|
|
else if (val <= 32767 && val >= -32768)
|
| 1964 |
|
|
*total = 2;
|
| 1965 |
|
|
/* A 32-bit constant (or very seldom, unsigned 16 bits) costs
|
| 1966 |
|
|
another word. FIXME: This isn't linear to 16 bits. */
|
| 1967 |
|
|
else
|
| 1968 |
|
|
*total = 4;
|
| 1969 |
|
|
return true;
|
| 1970 |
|
|
}
|
| 1971 |
|
|
|
| 1972 |
|
|
case LABEL_REF:
|
| 1973 |
|
|
*total = 6;
|
| 1974 |
|
|
return true;
|
| 1975 |
|
|
|
| 1976 |
|
|
case CONST:
|
| 1977 |
|
|
case SYMBOL_REF:
|
| 1978 |
|
|
*total = 6;
|
| 1979 |
|
|
return true;
|
| 1980 |
|
|
|
| 1981 |
|
|
case CONST_DOUBLE:
|
| 1982 |
|
|
if (x != CONST0_RTX (GET_MODE (x) == VOIDmode ? DImode : GET_MODE (x)))
|
| 1983 |
|
|
*total = 12;
|
| 1984 |
|
|
else
|
| 1985 |
|
|
/* Make 0.0 cheap, else test-insns will not be used. */
|
| 1986 |
|
|
*total = 0;
|
| 1987 |
|
|
return true;
|
| 1988 |
|
|
|
| 1989 |
|
|
case MULT:
|
| 1990 |
|
|
/* If we have one arm of an ADDI, make sure it gets the cost of
|
| 1991 |
|
|
one insn, i.e. zero cost for this operand, and just the cost
|
| 1992 |
|
|
of the PLUS, as the insn is created by combine from a PLUS
|
| 1993 |
|
|
and an ASHIFT, and the MULT cost below would make the
|
| 1994 |
|
|
combined value be larger than the separate insns. The insn
|
| 1995 |
|
|
validity is checked elsewhere by combine.
|
| 1996 |
|
|
|
| 1997 |
|
|
FIXME: this case is a stop-gap for 4.3 and 4.4, this whole
|
| 1998 |
|
|
function should be rewritten. */
|
| 1999 |
|
|
if (outer_code == PLUS && cris_biap_index_p (x, false))
|
| 2000 |
|
|
{
|
| 2001 |
|
|
*total = 0;
|
| 2002 |
|
|
return true;
|
| 2003 |
|
|
}
|
| 2004 |
|
|
|
| 2005 |
|
|
/* Identify values that are no powers of two. Powers of 2 are
|
| 2006 |
|
|
taken care of already and those values should not be changed. */
|
| 2007 |
|
|
if (!CONST_INT_P (XEXP (x, 1))
|
| 2008 |
|
|
|| exact_log2 (INTVAL (XEXP (x, 1)) < 0))
|
| 2009 |
|
|
{
|
| 2010 |
|
|
/* If we have a multiply insn, then the cost is between
|
| 2011 |
|
|
1 and 2 "fast" instructions. */
|
| 2012 |
|
|
if (TARGET_HAS_MUL_INSNS)
|
| 2013 |
|
|
{
|
| 2014 |
|
|
*total = COSTS_N_INSNS (1) + COSTS_N_INSNS (1) / 2;
|
| 2015 |
|
|
return true;
|
| 2016 |
|
|
}
|
| 2017 |
|
|
|
| 2018 |
|
|
/* Estimate as 4 + 4 * #ofbits. */
|
| 2019 |
|
|
*total = COSTS_N_INSNS (132);
|
| 2020 |
|
|
return true;
|
| 2021 |
|
|
}
|
| 2022 |
|
|
return false;
|
| 2023 |
|
|
|
| 2024 |
|
|
case UDIV:
|
| 2025 |
|
|
case MOD:
|
| 2026 |
|
|
case UMOD:
|
| 2027 |
|
|
case DIV:
|
| 2028 |
|
|
if (!CONST_INT_P (XEXP (x, 1))
|
| 2029 |
|
|
|| exact_log2 (INTVAL (XEXP (x, 1)) < 0))
|
| 2030 |
|
|
{
|
| 2031 |
|
|
/* Estimate this as 4 + 8 * #of bits. */
|
| 2032 |
|
|
*total = COSTS_N_INSNS (260);
|
| 2033 |
|
|
return true;
|
| 2034 |
|
|
}
|
| 2035 |
|
|
return false;
|
| 2036 |
|
|
|
| 2037 |
|
|
case AND:
|
| 2038 |
|
|
if (CONST_INT_P (XEXP (x, 1))
|
| 2039 |
|
|
/* Two constants may actually happen before optimization. */
|
| 2040 |
|
|
&& !CONST_INT_P (XEXP (x, 0))
|
| 2041 |
|
|
&& !satisfies_constraint_I (XEXP (x, 1)))
|
| 2042 |
|
|
{
|
| 2043 |
|
|
*total
|
| 2044 |
|
|
= (rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code,
|
| 2045 |
|
|
opno, speed) + 2
|
| 2046 |
|
|
+ 2 * GET_MODE_NUNITS (GET_MODE (XEXP (x, 0))));
|
| 2047 |
|
|
return true;
|
| 2048 |
|
|
}
|
| 2049 |
|
|
return false;
|
| 2050 |
|
|
|
| 2051 |
|
|
case ZERO_EXTRACT:
|
| 2052 |
|
|
if (outer_code != COMPARE)
|
| 2053 |
|
|
return false;
|
| 2054 |
|
|
/* fall through */
|
| 2055 |
|
|
|
| 2056 |
|
|
case ZERO_EXTEND: case SIGN_EXTEND:
|
| 2057 |
|
|
*total = rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, opno, speed);
|
| 2058 |
|
|
return true;
|
| 2059 |
|
|
|
| 2060 |
|
|
default:
|
| 2061 |
|
|
return false;
|
| 2062 |
|
|
}
|
| 2063 |
|
|
}
|
| 2064 |
|
|
|
| 2065 |
|
|
/* The ADDRESS_COST worker. */
|
| 2066 |
|
|
|
| 2067 |
|
|
static int
|
| 2068 |
|
|
cris_address_cost (rtx x, bool speed ATTRIBUTE_UNUSED)
|
| 2069 |
|
|
{
|
| 2070 |
|
|
/* The metric to use for the cost-macros is unclear.
|
| 2071 |
|
|
The metric used here is (the number of cycles needed) / 2,
|
| 2072 |
|
|
where we consider equal a cycle for a word of code and a cycle to
|
| 2073 |
|
|
read memory. FIXME: Adding "+ 1" to all values would avoid
|
| 2074 |
|
|
returning 0, as tree-ssa-loop-ivopts.c as of r128272 "normalizes"
|
| 2075 |
|
|
|
| 2076 |
|
|
Unfortunately(?) such a hack would expose other pessimizations,
|
| 2077 |
|
|
at least with g++.dg/tree-ssa/ivopts-1.C, adding insns to the
|
| 2078 |
|
|
loop there, without apparent reason. */
|
| 2079 |
|
|
|
| 2080 |
|
|
/* The cheapest addressing modes get 0, since nothing extra is needed. */
|
| 2081 |
|
|
if (cris_base_or_autoincr_p (x, false))
|
| 2082 |
|
|
return 0;
|
| 2083 |
|
|
|
| 2084 |
|
|
/* An indirect mem must be a DIP. This means two bytes extra for code,
|
| 2085 |
|
|
and 4 bytes extra for memory read, i.e. (2 + 4) / 2. */
|
| 2086 |
|
|
if (MEM_P (x))
|
| 2087 |
|
|
return (2 + 4) / 2;
|
| 2088 |
|
|
|
| 2089 |
|
|
/* Assume (2 + 4) / 2 for a single constant; a dword, since it needs
|
| 2090 |
|
|
an extra DIP prefix and 4 bytes of constant in most cases. */
|
| 2091 |
|
|
if (CONSTANT_P (x))
|
| 2092 |
|
|
return (2 + 4) / 2;
|
| 2093 |
|
|
|
| 2094 |
|
|
/* Handle BIAP and BDAP prefixes. */
|
| 2095 |
|
|
if (GET_CODE (x) == PLUS)
|
| 2096 |
|
|
{
|
| 2097 |
|
|
rtx tem1 = XEXP (x, 0);
|
| 2098 |
|
|
rtx tem2 = XEXP (x, 1);
|
| 2099 |
|
|
|
| 2100 |
|
|
/* Local extended canonicalization rule: the first operand must
|
| 2101 |
|
|
be REG, unless it's an operation (MULT). */
|
| 2102 |
|
|
if (!REG_P (tem1) && GET_CODE (tem1) != MULT)
|
| 2103 |
|
|
tem1 = tem2, tem2 = XEXP (x, 0);
|
| 2104 |
|
|
|
| 2105 |
|
|
/* We'll "assume" we have canonical RTX now. */
|
| 2106 |
|
|
gcc_assert (REG_P (tem1) || GET_CODE (tem1) == MULT);
|
| 2107 |
|
|
|
| 2108 |
|
|
/* A BIAP is 2 extra bytes for the prefix insn, nothing more. We
|
| 2109 |
|
|
recognize the typical MULT which is always in tem1 because of
|
| 2110 |
|
|
insn canonicalization. */
|
| 2111 |
|
|
if ((GET_CODE (tem1) == MULT && cris_biap_index_p (tem1, false))
|
| 2112 |
|
|
|| REG_P (tem2))
|
| 2113 |
|
|
return 2 / 2;
|
| 2114 |
|
|
|
| 2115 |
|
|
/* A BDAP (quick) is 2 extra bytes. Any constant operand to the
|
| 2116 |
|
|
PLUS is always found in tem2. */
|
| 2117 |
|
|
if (CONST_INT_P (tem2) && INTVAL (tem2) < 128 && INTVAL (tem2) >= -128)
|
| 2118 |
|
|
return 2 / 2;
|
| 2119 |
|
|
|
| 2120 |
|
|
/* A BDAP -32768 .. 32767 is like BDAP quick, but with 2 extra
|
| 2121 |
|
|
bytes. */
|
| 2122 |
|
|
if (satisfies_constraint_L (tem2))
|
| 2123 |
|
|
return (2 + 2) / 2;
|
| 2124 |
|
|
|
| 2125 |
|
|
/* A BDAP with some other constant is 2 bytes extra. */
|
| 2126 |
|
|
if (CONSTANT_P (tem2))
|
| 2127 |
|
|
return (2 + 2 + 2) / 2;
|
| 2128 |
|
|
|
| 2129 |
|
|
/* BDAP with something indirect should have a higher cost than
|
| 2130 |
|
|
BIAP with register. FIXME: Should it cost like a MEM or more? */
|
| 2131 |
|
|
return (2 + 2 + 2) / 2;
|
| 2132 |
|
|
}
|
| 2133 |
|
|
|
| 2134 |
|
|
/* What else? Return a high cost. It matters only for valid
|
| 2135 |
|
|
addressing modes. */
|
| 2136 |
|
|
return 10;
|
| 2137 |
|
|
}
|
| 2138 |
|
|
|
| 2139 |
|
|
/* Check various objections to the side-effect. Used in the test-part
|
| 2140 |
|
|
of an anonymous insn describing an insn with a possible side-effect.
|
| 2141 |
|
|
Returns nonzero if the implied side-effect is ok.
|
| 2142 |
|
|
|
| 2143 |
|
|
code : PLUS or MULT
|
| 2144 |
|
|
ops : An array of rtx:es. lreg, rreg, rval,
|
| 2145 |
|
|
The variables multop and other_op are indexes into this,
|
| 2146 |
|
|
or -1 if they are not applicable.
|
| 2147 |
|
|
lreg : The register that gets assigned in the side-effect.
|
| 2148 |
|
|
rreg : One register in the side-effect expression
|
| 2149 |
|
|
rval : The other register, or an int.
|
| 2150 |
|
|
multop : An integer to multiply rval with.
|
| 2151 |
|
|
other_op : One of the entities of the main effect,
|
| 2152 |
|
|
whose mode we must consider. */
|
| 2153 |
|
|
|
| 2154 |
|
|
int
|
| 2155 |
|
|
cris_side_effect_mode_ok (enum rtx_code code, rtx *ops,
|
| 2156 |
|
|
int lreg, int rreg, int rval,
|
| 2157 |
|
|
int multop, int other_op)
|
| 2158 |
|
|
{
|
| 2159 |
|
|
/* Find what value to multiply with, for rx =ry + rz * n. */
|
| 2160 |
|
|
int mult = multop < 0 ? 1 : INTVAL (ops[multop]);
|
| 2161 |
|
|
|
| 2162 |
|
|
rtx reg_rtx = ops[rreg];
|
| 2163 |
|
|
rtx val_rtx = ops[rval];
|
| 2164 |
|
|
|
| 2165 |
|
|
/* The operands may be swapped. Canonicalize them in reg_rtx and
|
| 2166 |
|
|
val_rtx, where reg_rtx always is a reg (for this constraint to
|
| 2167 |
|
|
match). */
|
| 2168 |
|
|
if (! cris_base_p (reg_rtx, reload_in_progress || reload_completed))
|
| 2169 |
|
|
reg_rtx = val_rtx, val_rtx = ops[rreg];
|
| 2170 |
|
|
|
| 2171 |
|
|
/* Don't forget to check that reg_rtx really is a reg. If it isn't,
|
| 2172 |
|
|
we have no business. */
|
| 2173 |
|
|
if (! cris_base_p (reg_rtx, reload_in_progress || reload_completed))
|
| 2174 |
|
|
return 0;
|
| 2175 |
|
|
|
| 2176 |
|
|
/* Don't do this when -mno-split. */
|
| 2177 |
|
|
if (!TARGET_SIDE_EFFECT_PREFIXES)
|
| 2178 |
|
|
return 0;
|
| 2179 |
|
|
|
| 2180 |
|
|
/* The mult expression may be hidden in lreg. FIXME: Add more
|
| 2181 |
|
|
commentary about that. */
|
| 2182 |
|
|
if (GET_CODE (val_rtx) == MULT)
|
| 2183 |
|
|
{
|
| 2184 |
|
|
mult = INTVAL (XEXP (val_rtx, 1));
|
| 2185 |
|
|
val_rtx = XEXP (val_rtx, 0);
|
| 2186 |
|
|
code = MULT;
|
| 2187 |
|
|
}
|
| 2188 |
|
|
|
| 2189 |
|
|
/* First check the "other operand". */
|
| 2190 |
|
|
if (other_op >= 0)
|
| 2191 |
|
|
{
|
| 2192 |
|
|
if (GET_MODE_SIZE (GET_MODE (ops[other_op])) > UNITS_PER_WORD)
|
| 2193 |
|
|
return 0;
|
| 2194 |
|
|
|
| 2195 |
|
|
/* Check if the lvalue register is the same as the "other
|
| 2196 |
|
|
operand". If so, the result is undefined and we shouldn't do
|
| 2197 |
|
|
this. FIXME: Check again. */
|
| 2198 |
|
|
if ((cris_base_p (ops[lreg], reload_in_progress || reload_completed)
|
| 2199 |
|
|
&& cris_base_p (ops[other_op],
|
| 2200 |
|
|
reload_in_progress || reload_completed)
|
| 2201 |
|
|
&& REGNO (ops[lreg]) == REGNO (ops[other_op]))
|
| 2202 |
|
|
|| rtx_equal_p (ops[other_op], ops[lreg]))
|
| 2203 |
|
|
return 0;
|
| 2204 |
|
|
}
|
| 2205 |
|
|
|
| 2206 |
|
|
/* Do not accept frame_pointer_rtx as any operand. */
|
| 2207 |
|
|
if (ops[lreg] == frame_pointer_rtx || ops[rreg] == frame_pointer_rtx
|
| 2208 |
|
|
|| ops[rval] == frame_pointer_rtx
|
| 2209 |
|
|
|| (other_op >= 0 && ops[other_op] == frame_pointer_rtx))
|
| 2210 |
|
|
return 0;
|
| 2211 |
|
|
|
| 2212 |
|
|
if (code == PLUS
|
| 2213 |
|
|
&& ! cris_base_p (val_rtx, reload_in_progress || reload_completed))
|
| 2214 |
|
|
{
|
| 2215 |
|
|
|
| 2216 |
|
|
/* Do not allow rx = rx + n if a normal add or sub with same size
|
| 2217 |
|
|
would do. */
|
| 2218 |
|
|
if (rtx_equal_p (ops[lreg], reg_rtx)
|
| 2219 |
|
|
&& CONST_INT_P (val_rtx)
|
| 2220 |
|
|
&& (INTVAL (val_rtx) <= 63 && INTVAL (val_rtx) >= -63))
|
| 2221 |
|
|
return 0;
|
| 2222 |
|
|
|
| 2223 |
|
|
/* Check allowed cases, like [r(+)?].[bwd] and const. */
|
| 2224 |
|
|
if (CONSTANT_P (val_rtx))
|
| 2225 |
|
|
return 1;
|
| 2226 |
|
|
|
| 2227 |
|
|
if (MEM_P (val_rtx)
|
| 2228 |
|
|
&& cris_base_or_autoincr_p (XEXP (val_rtx, 0),
|
| 2229 |
|
|
reload_in_progress || reload_completed))
|
| 2230 |
|
|
return 1;
|
| 2231 |
|
|
|
| 2232 |
|
|
if (GET_CODE (val_rtx) == SIGN_EXTEND
|
| 2233 |
|
|
&& MEM_P (XEXP (val_rtx, 0))
|
| 2234 |
|
|
&& cris_base_or_autoincr_p (XEXP (XEXP (val_rtx, 0), 0),
|
| 2235 |
|
|
reload_in_progress || reload_completed))
|
| 2236 |
|
|
return 1;
|
| 2237 |
|
|
|
| 2238 |
|
|
/* If we got here, it's not a valid addressing mode. */
|
| 2239 |
|
|
return 0;
|
| 2240 |
|
|
}
|
| 2241 |
|
|
else if (code == MULT
|
| 2242 |
|
|
|| (code == PLUS
|
| 2243 |
|
|
&& cris_base_p (val_rtx,
|
| 2244 |
|
|
reload_in_progress || reload_completed)))
|
| 2245 |
|
|
{
|
| 2246 |
|
|
/* Do not allow rx = rx + ry.S, since it doesn't give better code. */
|
| 2247 |
|
|
if (rtx_equal_p (ops[lreg], reg_rtx)
|
| 2248 |
|
|
|| (mult == 1 && rtx_equal_p (ops[lreg], val_rtx)))
|
| 2249 |
|
|
return 0;
|
| 2250 |
|
|
|
| 2251 |
|
|
/* Do not allow bad multiply-values. */
|
| 2252 |
|
|
if (mult != 1 && mult != 2 && mult != 4)
|
| 2253 |
|
|
return 0;
|
| 2254 |
|
|
|
| 2255 |
|
|
/* Only allow r + ... */
|
| 2256 |
|
|
if (! cris_base_p (reg_rtx, reload_in_progress || reload_completed))
|
| 2257 |
|
|
return 0;
|
| 2258 |
|
|
|
| 2259 |
|
|
/* If we got here, all seems ok.
|
| 2260 |
|
|
(All checks need to be done above). */
|
| 2261 |
|
|
return 1;
|
| 2262 |
|
|
}
|
| 2263 |
|
|
|
| 2264 |
|
|
/* If we get here, the caller got its initial tests wrong. */
|
| 2265 |
|
|
internal_error ("internal error: cris_side_effect_mode_ok with bad operands");
|
| 2266 |
|
|
}
|
| 2267 |
|
|
|
| 2268 |
|
|
/* Whether next_cc0_user of insn is LE or GT or requires a real compare
|
| 2269 |
|
|
insn for other reasons. */
|
| 2270 |
|
|
|
| 2271 |
|
|
bool
|
| 2272 |
|
|
cris_cc0_user_requires_cmp (rtx insn)
|
| 2273 |
|
|
{
|
| 2274 |
|
|
rtx cc0_user = NULL;
|
| 2275 |
|
|
rtx body;
|
| 2276 |
|
|
rtx set;
|
| 2277 |
|
|
|
| 2278 |
|
|
gcc_assert (insn != NULL);
|
| 2279 |
|
|
|
| 2280 |
|
|
if (!TARGET_V32)
|
| 2281 |
|
|
return false;
|
| 2282 |
|
|
|
| 2283 |
|
|
cc0_user = next_cc0_user (insn);
|
| 2284 |
|
|
if (cc0_user == NULL)
|
| 2285 |
|
|
return false;
|
| 2286 |
|
|
|
| 2287 |
|
|
body = PATTERN (cc0_user);
|
| 2288 |
|
|
set = single_set (cc0_user);
|
| 2289 |
|
|
|
| 2290 |
|
|
/* Users can be sCC and bCC. */
|
| 2291 |
|
|
if (JUMP_P (cc0_user)
|
| 2292 |
|
|
&& GET_CODE (body) == SET
|
| 2293 |
|
|
&& SET_DEST (body) == pc_rtx
|
| 2294 |
|
|
&& GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
|
| 2295 |
|
|
&& XEXP (XEXP (SET_SRC (body), 0), 0) == cc0_rtx)
|
| 2296 |
|
|
{
|
| 2297 |
|
|
return
|
| 2298 |
|
|
GET_CODE (XEXP (SET_SRC (body), 0)) == GT
|
| 2299 |
|
|
|| GET_CODE (XEXP (SET_SRC (body), 0)) == LE;
|
| 2300 |
|
|
}
|
| 2301 |
|
|
else if (set)
|
| 2302 |
|
|
{
|
| 2303 |
|
|
return
|
| 2304 |
|
|
GET_CODE (SET_SRC (body)) == GT
|
| 2305 |
|
|
|| GET_CODE (SET_SRC (body)) == LE;
|
| 2306 |
|
|
}
|
| 2307 |
|
|
|
| 2308 |
|
|
gcc_unreachable ();
|
| 2309 |
|
|
}
|
| 2310 |
|
|
|
| 2311 |
|
|
/* The function reg_overlap_mentioned_p in CVS (still as of 2001-05-16)
|
| 2312 |
|
|
does not handle the case where the IN operand is strict_low_part; it
|
| 2313 |
|
|
does handle it for X. Test-case in Axis-20010516. This function takes
|
| 2314 |
|
|
care of that for THIS port. FIXME: strict_low_part is going away
|
| 2315 |
|
|
anyway. */
|
| 2316 |
|
|
|
| 2317 |
|
|
static int
|
| 2318 |
|
|
cris_reg_overlap_mentioned_p (rtx x, rtx in)
|
| 2319 |
|
|
{
|
| 2320 |
|
|
/* The function reg_overlap_mentioned now handles when X is
|
| 2321 |
|
|
strict_low_part, but not when IN is a STRICT_LOW_PART. */
|
| 2322 |
|
|
if (GET_CODE (in) == STRICT_LOW_PART)
|
| 2323 |
|
|
in = XEXP (in, 0);
|
| 2324 |
|
|
|
| 2325 |
|
|
return reg_overlap_mentioned_p (x, in);
|
| 2326 |
|
|
}
|
| 2327 |
|
|
|
| 2328 |
|
|
/* The TARGET_ASM_NAMED_SECTION worker.
|
| 2329 |
|
|
We just dispatch to the functions for ELF and a.out. */
|
| 2330 |
|
|
|
| 2331 |
|
|
void
|
| 2332 |
|
|
cris_target_asm_named_section (const char *name, unsigned int flags,
|
| 2333 |
|
|
tree decl)
|
| 2334 |
|
|
{
|
| 2335 |
|
|
if (! TARGET_ELF)
|
| 2336 |
|
|
default_no_named_section (name, flags, decl);
|
| 2337 |
|
|
else
|
| 2338 |
|
|
default_elf_asm_named_section (name, flags, decl);
|
| 2339 |
|
|
}
|
| 2340 |
|
|
|
| 2341 |
|
|
/* Return TRUE iff X is a CONST valid for e.g. indexing.
|
| 2342 |
|
|
ANY_OPERAND is 0 if X is in a CALL_P insn or movsi, 1
|
| 2343 |
|
|
elsewhere. */
|
| 2344 |
|
|
|
| 2345 |
|
|
bool
|
| 2346 |
|
|
cris_valid_pic_const (const_rtx x, bool any_operand)
|
| 2347 |
|
|
{
|
| 2348 |
|
|
gcc_assert (flag_pic);
|
| 2349 |
|
|
|
| 2350 |
|
|
switch (GET_CODE (x))
|
| 2351 |
|
|
{
|
| 2352 |
|
|
case CONST_INT:
|
| 2353 |
|
|
case CONST_DOUBLE:
|
| 2354 |
|
|
return true;
|
| 2355 |
|
|
default:
|
| 2356 |
|
|
;
|
| 2357 |
|
|
}
|
| 2358 |
|
|
|
| 2359 |
|
|
if (GET_CODE (x) != CONST)
|
| 2360 |
|
|
return false;
|
| 2361 |
|
|
|
| 2362 |
|
|
x = XEXP (x, 0);
|
| 2363 |
|
|
|
| 2364 |
|
|
/* Handle (const (plus (unspec .. UNSPEC_GOTREL) (const_int ...))). */
|
| 2365 |
|
|
if (GET_CODE (x) == PLUS
|
| 2366 |
|
|
&& GET_CODE (XEXP (x, 0)) == UNSPEC
|
| 2367 |
|
|
&& (XINT (XEXP (x, 0), 1) == CRIS_UNSPEC_GOTREL
|
| 2368 |
|
|
|| XINT (XEXP (x, 0), 1) == CRIS_UNSPEC_PCREL)
|
| 2369 |
|
|
&& CONST_INT_P (XEXP (x, 1)))
|
| 2370 |
|
|
x = XEXP (x, 0);
|
| 2371 |
|
|
|
| 2372 |
|
|
if (GET_CODE (x) == UNSPEC)
|
| 2373 |
|
|
switch (XINT (x, 1))
|
| 2374 |
|
|
{
|
| 2375 |
|
|
/* A PCREL operand is only valid for call and movsi. */
|
| 2376 |
|
|
case CRIS_UNSPEC_PLT_PCREL:
|
| 2377 |
|
|
case CRIS_UNSPEC_PCREL:
|
| 2378 |
|
|
return !any_operand;
|
| 2379 |
|
|
|
| 2380 |
|
|
case CRIS_UNSPEC_PLT_GOTREL:
|
| 2381 |
|
|
case CRIS_UNSPEC_PLTGOTREAD:
|
| 2382 |
|
|
case CRIS_UNSPEC_GOTREAD:
|
| 2383 |
|
|
case CRIS_UNSPEC_GOTREL:
|
| 2384 |
|
|
return true;
|
| 2385 |
|
|
default:
|
| 2386 |
|
|
gcc_unreachable ();
|
| 2387 |
|
|
}
|
| 2388 |
|
|
|
| 2389 |
|
|
return cris_pic_symbol_type_of (x) == cris_no_symbol;
|
| 2390 |
|
|
}
|
| 2391 |
|
|
|
| 2392 |
|
|
/* Helper function to find the right PIC-type symbol to generate,
|
| 2393 |
|
|
given the original (non-PIC) representation. */
|
| 2394 |
|
|
|
| 2395 |
|
|
enum cris_pic_symbol_type
|
| 2396 |
|
|
cris_pic_symbol_type_of (const_rtx x)
|
| 2397 |
|
|
{
|
| 2398 |
|
|
switch (GET_CODE (x))
|
| 2399 |
|
|
{
|
| 2400 |
|
|
case SYMBOL_REF:
|
| 2401 |
|
|
return SYMBOL_REF_LOCAL_P (x)
|
| 2402 |
|
|
? cris_rel_symbol : cris_got_symbol;
|
| 2403 |
|
|
|
| 2404 |
|
|
case LABEL_REF:
|
| 2405 |
|
|
return cris_rel_symbol;
|
| 2406 |
|
|
|
| 2407 |
|
|
case CONST:
|
| 2408 |
|
|
return cris_pic_symbol_type_of (XEXP (x, 0));
|
| 2409 |
|
|
|
| 2410 |
|
|
case PLUS:
|
| 2411 |
|
|
case MINUS:
|
| 2412 |
|
|
{
|
| 2413 |
|
|
enum cris_pic_symbol_type t1 = cris_pic_symbol_type_of (XEXP (x, 0));
|
| 2414 |
|
|
enum cris_pic_symbol_type t2 = cris_pic_symbol_type_of (XEXP (x, 1));
|
| 2415 |
|
|
|
| 2416 |
|
|
gcc_assert (t1 == cris_no_symbol || t2 == cris_no_symbol);
|
| 2417 |
|
|
|
| 2418 |
|
|
if (t1 == cris_got_symbol || t1 == cris_got_symbol)
|
| 2419 |
|
|
return cris_got_symbol_needing_fixup;
|
| 2420 |
|
|
|
| 2421 |
|
|
return t1 != cris_no_symbol ? t1 : t2;
|
| 2422 |
|
|
}
|
| 2423 |
|
|
|
| 2424 |
|
|
case CONST_INT:
|
| 2425 |
|
|
case CONST_DOUBLE:
|
| 2426 |
|
|
return cris_no_symbol;
|
| 2427 |
|
|
|
| 2428 |
|
|
case UNSPEC:
|
| 2429 |
|
|
/* Likely an offsettability-test attempting to add a constant to
|
| 2430 |
|
|
a GOTREAD symbol, which can't be handled. */
|
| 2431 |
|
|
return cris_invalid_pic_symbol;
|
| 2432 |
|
|
|
| 2433 |
|
|
default:
|
| 2434 |
|
|
fatal_insn ("unrecognized supposed constant", x);
|
| 2435 |
|
|
}
|
| 2436 |
|
|
|
| 2437 |
|
|
gcc_unreachable ();
|
| 2438 |
|
|
}
|
| 2439 |
|
|
|
| 2440 |
|
|
/* The LEGITIMATE_PIC_OPERAND_P worker. */
|
| 2441 |
|
|
|
| 2442 |
|
|
int
|
| 2443 |
|
|
cris_legitimate_pic_operand (rtx x)
|
| 2444 |
|
|
{
|
| 2445 |
|
|
/* Symbols are not valid PIC operands as-is; just constants. */
|
| 2446 |
|
|
return cris_valid_pic_const (x, true);
|
| 2447 |
|
|
}
|
| 2448 |
|
|
|
| 2449 |
|
|
/* The ASM_OUTPUT_CASE_END worker. */
|
| 2450 |
|
|
|
| 2451 |
|
|
void
|
| 2452 |
|
|
cris_asm_output_case_end (FILE *stream, int num, rtx table)
|
| 2453 |
|
|
{
|
| 2454 |
|
|
/* Step back, over the label for the table, to the actual casejump and
|
| 2455 |
|
|
assert that we find only what's expected. */
|
| 2456 |
|
|
rtx whole_jump_insn = prev_nonnote_nondebug_insn (table);
|
| 2457 |
|
|
gcc_assert (whole_jump_insn != NULL_RTX && LABEL_P (whole_jump_insn));
|
| 2458 |
|
|
whole_jump_insn = prev_nonnote_nondebug_insn (whole_jump_insn);
|
| 2459 |
|
|
gcc_assert (whole_jump_insn != NULL_RTX
|
| 2460 |
|
|
&& (JUMP_P (whole_jump_insn)
|
| 2461 |
|
|
|| (TARGET_V32 && INSN_P (whole_jump_insn)
|
| 2462 |
|
|
&& GET_CODE (PATTERN (whole_jump_insn)) == SEQUENCE)));
|
| 2463 |
|
|
/* Get the pattern of the casejump, so we can extract the default label. */
|
| 2464 |
|
|
whole_jump_insn = PATTERN (whole_jump_insn);
|
| 2465 |
|
|
|
| 2466 |
|
|
if (TARGET_V32)
|
| 2467 |
|
|
{
|
| 2468 |
|
|
/* This can be a SEQUENCE, meaning the delay-slot of the jump is
|
| 2469 |
|
|
filled. We also output the offset word a little differently. */
|
| 2470 |
|
|
rtx parallel_jump
|
| 2471 |
|
|
= (GET_CODE (whole_jump_insn) == SEQUENCE
|
| 2472 |
|
|
? PATTERN (XVECEXP (whole_jump_insn, 0, 0)) : whole_jump_insn);
|
| 2473 |
|
|
|
| 2474 |
|
|
asm_fprintf (stream,
|
| 2475 |
|
|
"\t.word %LL%d-.%s\n",
|
| 2476 |
|
|
CODE_LABEL_NUMBER (XEXP (XEXP (XEXP (XVECEXP
|
| 2477 |
|
|
(parallel_jump, 0, 0),
|
| 2478 |
|
|
1), 2), 0)),
|
| 2479 |
|
|
(TARGET_PDEBUG ? "; default" : ""));
|
| 2480 |
|
|
return;
|
| 2481 |
|
|
}
|
| 2482 |
|
|
|
| 2483 |
|
|
asm_fprintf (stream,
|
| 2484 |
|
|
"\t.word %LL%d-%LL%d%s\n",
|
| 2485 |
|
|
CODE_LABEL_NUMBER (XEXP
|
| 2486 |
|
|
(XEXP
|
| 2487 |
|
|
(XEXP (XVECEXP (whole_jump_insn, 0, 0), 1),
|
| 2488 |
|
|
2), 0)),
|
| 2489 |
|
|
num,
|
| 2490 |
|
|
(TARGET_PDEBUG ? "; default" : ""));
|
| 2491 |
|
|
}
|
| 2492 |
|
|
|
| 2493 |
|
|
/* The TARGET_OPTION_OVERRIDE worker.
|
| 2494 |
|
|
As is the norm, this also parses -mfoo=bar type parameters. */
|
| 2495 |
|
|
|
| 2496 |
|
|
static void
|
| 2497 |
|
|
cris_option_override (void)
|
| 2498 |
|
|
{
|
| 2499 |
|
|
if (cris_max_stackframe_str)
|
| 2500 |
|
|
{
|
| 2501 |
|
|
cris_max_stackframe = atoi (cris_max_stackframe_str);
|
| 2502 |
|
|
|
| 2503 |
|
|
/* Do some sanity checking. */
|
| 2504 |
|
|
if (cris_max_stackframe < 0 || cris_max_stackframe > 0x20000000)
|
| 2505 |
|
|
internal_error ("-max-stackframe=%d is not usable, not between 0 and %d",
|
| 2506 |
|
|
cris_max_stackframe, 0x20000000);
|
| 2507 |
|
|
}
|
| 2508 |
|
|
|
| 2509 |
|
|
/* Let "-metrax4" and "-metrax100" change the cpu version. */
|
| 2510 |
|
|
if (TARGET_SVINTO && cris_cpu_version < CRIS_CPU_SVINTO)
|
| 2511 |
|
|
cris_cpu_version = CRIS_CPU_SVINTO;
|
| 2512 |
|
|
else if (TARGET_ETRAX4_ADD && cris_cpu_version < CRIS_CPU_ETRAX4)
|
| 2513 |
|
|
cris_cpu_version = CRIS_CPU_ETRAX4;
|
| 2514 |
|
|
|
| 2515 |
|
|
/* Parse -march=... and its synonym, the deprecated -mcpu=... */
|
| 2516 |
|
|
if (cris_cpu_str)
|
| 2517 |
|
|
{
|
| 2518 |
|
|
cris_cpu_version
|
| 2519 |
|
|
= (*cris_cpu_str == 'v' ? atoi (cris_cpu_str + 1) : -1);
|
| 2520 |
|
|
|
| 2521 |
|
|
if (strcmp ("etrax4", cris_cpu_str) == 0)
|
| 2522 |
|
|
cris_cpu_version = 3;
|
| 2523 |
|
|
|
| 2524 |
|
|
if (strcmp ("svinto", cris_cpu_str) == 0
|
| 2525 |
|
|
|| strcmp ("etrax100", cris_cpu_str) == 0)
|
| 2526 |
|
|
cris_cpu_version = 8;
|
| 2527 |
|
|
|
| 2528 |
|
|
if (strcmp ("ng", cris_cpu_str) == 0
|
| 2529 |
|
|
|| strcmp ("etrax100lx", cris_cpu_str) == 0)
|
| 2530 |
|
|
cris_cpu_version = 10;
|
| 2531 |
|
|
|
| 2532 |
|
|
if (cris_cpu_version < 0 || cris_cpu_version > 32)
|
| 2533 |
|
|
error ("unknown CRIS version specification in -march= or -mcpu= : %s",
|
| 2534 |
|
|
cris_cpu_str);
|
| 2535 |
|
|
|
| 2536 |
|
|
/* Set the target flags. */
|
| 2537 |
|
|
if (cris_cpu_version >= CRIS_CPU_ETRAX4)
|
| 2538 |
|
|
target_flags |= MASK_ETRAX4_ADD;
|
| 2539 |
|
|
|
| 2540 |
|
|
/* If this is Svinto or higher, align for 32 bit accesses. */
|
| 2541 |
|
|
if (cris_cpu_version >= CRIS_CPU_SVINTO)
|
| 2542 |
|
|
target_flags
|
| 2543 |
|
|
|= (MASK_SVINTO | MASK_ALIGN_BY_32
|
| 2544 |
|
|
| MASK_STACK_ALIGN | MASK_CONST_ALIGN
|
| 2545 |
|
|
| MASK_DATA_ALIGN);
|
| 2546 |
|
|
|
| 2547 |
|
|
/* Note that we do not add new flags when it can be completely
|
| 2548 |
|
|
described with a macro that uses -mcpu=X. So
|
| 2549 |
|
|
TARGET_HAS_MUL_INSNS is (cris_cpu_version >= CRIS_CPU_NG). */
|
| 2550 |
|
|
}
|
| 2551 |
|
|
|
| 2552 |
|
|
if (cris_tune_str)
|
| 2553 |
|
|
{
|
| 2554 |
|
|
int cris_tune
|
| 2555 |
|
|
= (*cris_tune_str == 'v' ? atoi (cris_tune_str + 1) : -1);
|
| 2556 |
|
|
|
| 2557 |
|
|
if (strcmp ("etrax4", cris_tune_str) == 0)
|
| 2558 |
|
|
cris_tune = 3;
|
| 2559 |
|
|
|
| 2560 |
|
|
if (strcmp ("svinto", cris_tune_str) == 0
|
| 2561 |
|
|
|| strcmp ("etrax100", cris_tune_str) == 0)
|
| 2562 |
|
|
cris_tune = 8;
|
| 2563 |
|
|
|
| 2564 |
|
|
if (strcmp ("ng", cris_tune_str) == 0
|
| 2565 |
|
|
|| strcmp ("etrax100lx", cris_tune_str) == 0)
|
| 2566 |
|
|
cris_tune = 10;
|
| 2567 |
|
|
|
| 2568 |
|
|
if (cris_tune < 0 || cris_tune > 32)
|
| 2569 |
|
|
error ("unknown CRIS cpu version specification in -mtune= : %s",
|
| 2570 |
|
|
cris_tune_str);
|
| 2571 |
|
|
|
| 2572 |
|
|
if (cris_tune >= CRIS_CPU_SVINTO)
|
| 2573 |
|
|
/* We have currently nothing more to tune than alignment for
|
| 2574 |
|
|
memory accesses. */
|
| 2575 |
|
|
target_flags
|
| 2576 |
|
|
|= (MASK_STACK_ALIGN | MASK_CONST_ALIGN
|
| 2577 |
|
|
| MASK_DATA_ALIGN | MASK_ALIGN_BY_32);
|
| 2578 |
|
|
}
|
| 2579 |
|
|
|
| 2580 |
|
|
if (cris_cpu_version >= CRIS_CPU_V32)
|
| 2581 |
|
|
target_flags &= ~(MASK_SIDE_EFFECT_PREFIXES|MASK_MUL_BUG);
|
| 2582 |
|
|
|
| 2583 |
|
|
if (flag_pic)
|
| 2584 |
|
|
{
|
| 2585 |
|
|
/* Use error rather than warning, so invalid use is easily
|
| 2586 |
|
|
detectable. Still change to the values we expect, to avoid
|
| 2587 |
|
|
further errors. */
|
| 2588 |
|
|
if (! TARGET_LINUX)
|
| 2589 |
|
|
{
|
| 2590 |
|
|
error ("-fPIC and -fpic are not supported in this configuration");
|
| 2591 |
|
|
flag_pic = 0;
|
| 2592 |
|
|
}
|
| 2593 |
|
|
|
| 2594 |
|
|
/* Turn off function CSE. We need to have the addresses reach the
|
| 2595 |
|
|
call expanders to get PLT-marked, as they could otherwise be
|
| 2596 |
|
|
compared against zero directly or indirectly. After visiting the
|
| 2597 |
|
|
call expanders they will then be cse:ed, as the call expanders
|
| 2598 |
|
|
force_reg the addresses, effectively forcing flag_no_function_cse
|
| 2599 |
|
|
to 0. */
|
| 2600 |
|
|
flag_no_function_cse = 1;
|
| 2601 |
|
|
}
|
| 2602 |
|
|
|
| 2603 |
|
|
if (write_symbols == DWARF2_DEBUG && ! TARGET_ELF)
|
| 2604 |
|
|
{
|
| 2605 |
|
|
warning (0, "that particular -g option is invalid with -maout and -melinux");
|
| 2606 |
|
|
write_symbols = DBX_DEBUG;
|
| 2607 |
|
|
}
|
| 2608 |
|
|
|
| 2609 |
|
|
/* Set the per-function-data initializer. */
|
| 2610 |
|
|
init_machine_status = cris_init_machine_status;
|
| 2611 |
|
|
}
|
| 2612 |
|
|
|
| 2613 |
|
|
/* The TARGET_ASM_OUTPUT_MI_THUNK worker. */
|
| 2614 |
|
|
|
| 2615 |
|
|
static void
|
| 2616 |
|
|
cris_asm_output_mi_thunk (FILE *stream,
|
| 2617 |
|
|
tree thunkdecl ATTRIBUTE_UNUSED,
|
| 2618 |
|
|
HOST_WIDE_INT delta,
|
| 2619 |
|
|
HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
|
| 2620 |
|
|
tree funcdecl)
|
| 2621 |
|
|
{
|
| 2622 |
|
|
if (delta > 0)
|
| 2623 |
|
|
fprintf (stream, "\tadd%s " HOST_WIDE_INT_PRINT_DEC ",$%s\n",
|
| 2624 |
|
|
ADDITIVE_SIZE_MODIFIER (delta), delta,
|
| 2625 |
|
|
reg_names[CRIS_FIRST_ARG_REG]);
|
| 2626 |
|
|
else if (delta < 0)
|
| 2627 |
|
|
fprintf (stream, "\tsub%s " HOST_WIDE_INT_PRINT_DEC ",$%s\n",
|
| 2628 |
|
|
ADDITIVE_SIZE_MODIFIER (-delta), -delta,
|
| 2629 |
|
|
reg_names[CRIS_FIRST_ARG_REG]);
|
| 2630 |
|
|
|
| 2631 |
|
|
if (flag_pic)
|
| 2632 |
|
|
{
|
| 2633 |
|
|
const char *name = XSTR (XEXP (DECL_RTL (funcdecl), 0), 0);
|
| 2634 |
|
|
|
| 2635 |
|
|
name = (* targetm.strip_name_encoding) (name);
|
| 2636 |
|
|
|
| 2637 |
|
|
if (TARGET_V32)
|
| 2638 |
|
|
{
|
| 2639 |
|
|
fprintf (stream, "\tba ");
|
| 2640 |
|
|
assemble_name (stream, name);
|
| 2641 |
|
|
fprintf (stream, "%s\n", CRIS_PLT_PCOFFSET_SUFFIX);
|
| 2642 |
|
|
}
|
| 2643 |
|
|
else
|
| 2644 |
|
|
{
|
| 2645 |
|
|
fprintf (stream, "add.d ");
|
| 2646 |
|
|
assemble_name (stream, name);
|
| 2647 |
|
|
fprintf (stream, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX);
|
| 2648 |
|
|
}
|
| 2649 |
|
|
}
|
| 2650 |
|
|
else
|
| 2651 |
|
|
{
|
| 2652 |
|
|
fprintf (stream, "jump ");
|
| 2653 |
|
|
assemble_name (stream, XSTR (XEXP (DECL_RTL (funcdecl), 0), 0));
|
| 2654 |
|
|
fprintf (stream, "\n");
|
| 2655 |
|
|
|
| 2656 |
|
|
if (TARGET_V32)
|
| 2657 |
|
|
fprintf (stream, "\tnop\n");
|
| 2658 |
|
|
}
|
| 2659 |
|
|
}
|
| 2660 |
|
|
|
| 2661 |
|
|
/* Boilerplate emitted at start of file.
|
| 2662 |
|
|
|
| 2663 |
|
|
NO_APP *only at file start* means faster assembly. It also means
|
| 2664 |
|
|
comments are not allowed. In some cases comments will be output
|
| 2665 |
|
|
for debugging purposes. Make sure they are allowed then.
|
| 2666 |
|
|
|
| 2667 |
|
|
We want a .file directive only if TARGET_ELF. */
|
| 2668 |
|
|
static void
|
| 2669 |
|
|
cris_file_start (void)
|
| 2670 |
|
|
{
|
| 2671 |
|
|
/* These expressions can vary at run time, so we cannot put
|
| 2672 |
|
|
them into TARGET_INITIALIZER. */
|
| 2673 |
|
|
targetm.asm_file_start_app_off = !(TARGET_PDEBUG || flag_print_asm_name);
|
| 2674 |
|
|
targetm.asm_file_start_file_directive = TARGET_ELF;
|
| 2675 |
|
|
|
| 2676 |
|
|
default_file_start ();
|
| 2677 |
|
|
}
|
| 2678 |
|
|
|
| 2679 |
|
|
/* Rename the function calls for integer multiply and divide. */
|
| 2680 |
|
|
static void
|
| 2681 |
|
|
cris_init_libfuncs (void)
|
| 2682 |
|
|
{
|
| 2683 |
|
|
set_optab_libfunc (smul_optab, SImode, "__Mul");
|
| 2684 |
|
|
set_optab_libfunc (sdiv_optab, SImode, "__Div");
|
| 2685 |
|
|
set_optab_libfunc (udiv_optab, SImode, "__Udiv");
|
| 2686 |
|
|
set_optab_libfunc (smod_optab, SImode, "__Mod");
|
| 2687 |
|
|
set_optab_libfunc (umod_optab, SImode, "__Umod");
|
| 2688 |
|
|
}
|
| 2689 |
|
|
|
| 2690 |
|
|
/* The INIT_EXPANDERS worker sets the per-function-data initializer and
|
| 2691 |
|
|
mark functions. */
|
| 2692 |
|
|
|
| 2693 |
|
|
void
|
| 2694 |
|
|
cris_init_expanders (void)
|
| 2695 |
|
|
{
|
| 2696 |
|
|
/* Nothing here at the moment. */
|
| 2697 |
|
|
}
|
| 2698 |
|
|
|
| 2699 |
|
|
/* Zero initialization is OK for all current fields. */
|
| 2700 |
|
|
|
| 2701 |
|
|
static struct machine_function *
|
| 2702 |
|
|
cris_init_machine_status (void)
|
| 2703 |
|
|
{
|
| 2704 |
|
|
return ggc_alloc_cleared_machine_function ();
|
| 2705 |
|
|
}
|
| 2706 |
|
|
|
| 2707 |
|
|
/* Split a 2 word move (DI or presumably DF) into component parts.
|
| 2708 |
|
|
Originally a copy of gen_split_move_double in m32r.c. */
|
| 2709 |
|
|
|
| 2710 |
|
|
rtx
|
| 2711 |
|
|
cris_split_movdx (rtx *operands)
|
| 2712 |
|
|
{
|
| 2713 |
|
|
enum machine_mode mode = GET_MODE (operands[0]);
|
| 2714 |
|
|
rtx dest = operands[0];
|
| 2715 |
|
|
rtx src = operands[1];
|
| 2716 |
|
|
rtx val;
|
| 2717 |
|
|
|
| 2718 |
|
|
/* We used to have to handle (SUBREG (MEM)) here, but that should no
|
| 2719 |
|
|
longer happen; after reload there are no SUBREGs any more, and we're
|
| 2720 |
|
|
only called after reload. */
|
| 2721 |
|
|
CRIS_ASSERT (GET_CODE (dest) != SUBREG && GET_CODE (src) != SUBREG);
|
| 2722 |
|
|
|
| 2723 |
|
|
start_sequence ();
|
| 2724 |
|
|
if (REG_P (dest))
|
| 2725 |
|
|
{
|
| 2726 |
|
|
int dregno = REGNO (dest);
|
| 2727 |
|
|
|
| 2728 |
|
|
/* Reg-to-reg copy. */
|
| 2729 |
|
|
if (REG_P (src))
|
| 2730 |
|
|
{
|
| 2731 |
|
|
int sregno = REGNO (src);
|
| 2732 |
|
|
|
| 2733 |
|
|
int reverse = (dregno == sregno + 1);
|
| 2734 |
|
|
|
| 2735 |
|
|
/* We normally copy the low-numbered register first. However, if
|
| 2736 |
|
|
the first register operand 0 is the same as the second register of
|
| 2737 |
|
|
operand 1, we must copy in the opposite order. */
|
| 2738 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 2739 |
|
|
operand_subword (dest, reverse, TRUE, mode),
|
| 2740 |
|
|
operand_subword (src, reverse, TRUE, mode)));
|
| 2741 |
|
|
|
| 2742 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 2743 |
|
|
operand_subword (dest, !reverse, TRUE, mode),
|
| 2744 |
|
|
operand_subword (src, !reverse, TRUE, mode)));
|
| 2745 |
|
|
}
|
| 2746 |
|
|
/* Constant-to-reg copy. */
|
| 2747 |
|
|
else if (CONST_INT_P (src) || GET_CODE (src) == CONST_DOUBLE)
|
| 2748 |
|
|
{
|
| 2749 |
|
|
rtx words[2];
|
| 2750 |
|
|
split_double (src, &words[0], &words[1]);
|
| 2751 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 2752 |
|
|
operand_subword (dest, 0, TRUE, mode),
|
| 2753 |
|
|
words[0]));
|
| 2754 |
|
|
|
| 2755 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 2756 |
|
|
operand_subword (dest, 1, TRUE, mode),
|
| 2757 |
|
|
words[1]));
|
| 2758 |
|
|
}
|
| 2759 |
|
|
/* Mem-to-reg copy. */
|
| 2760 |
|
|
else if (MEM_P (src))
|
| 2761 |
|
|
{
|
| 2762 |
|
|
/* If the high-address word is used in the address, we must load it
|
| 2763 |
|
|
last. Otherwise, load it first. */
|
| 2764 |
|
|
rtx addr = XEXP (src, 0);
|
| 2765 |
|
|
int reverse
|
| 2766 |
|
|
= (refers_to_regno_p (dregno, dregno + 1, addr, NULL) != 0);
|
| 2767 |
|
|
|
| 2768 |
|
|
/* The original code implies that we can't do
|
| 2769 |
|
|
move.x [rN+],rM move.x [rN],rM+1
|
| 2770 |
|
|
when rN is dead, because of REG_NOTES damage. That is
|
| 2771 |
|
|
consistent with what I've seen, so don't try it.
|
| 2772 |
|
|
|
| 2773 |
|
|
We have two different cases here; if the addr is POST_INC,
|
| 2774 |
|
|
just pass it through, otherwise add constants. */
|
| 2775 |
|
|
|
| 2776 |
|
|
if (GET_CODE (addr) == POST_INC)
|
| 2777 |
|
|
{
|
| 2778 |
|
|
rtx mem;
|
| 2779 |
|
|
rtx insn;
|
| 2780 |
|
|
|
| 2781 |
|
|
/* Whenever we emit insns with post-incremented
|
| 2782 |
|
|
addresses ourselves, we must add a post-inc note
|
| 2783 |
|
|
manually. */
|
| 2784 |
|
|
mem = change_address (src, SImode, addr);
|
| 2785 |
|
|
insn
|
| 2786 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 2787 |
|
|
operand_subword (dest, 0, TRUE, mode), mem);
|
| 2788 |
|
|
insn = emit_insn (insn);
|
| 2789 |
|
|
if (GET_CODE (XEXP (mem, 0)) == POST_INC)
|
| 2790 |
|
|
REG_NOTES (insn)
|
| 2791 |
|
|
= alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0),
|
| 2792 |
|
|
REG_NOTES (insn));
|
| 2793 |
|
|
|
| 2794 |
|
|
mem = copy_rtx (mem);
|
| 2795 |
|
|
insn
|
| 2796 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 2797 |
|
|
operand_subword (dest, 1, TRUE, mode), mem);
|
| 2798 |
|
|
insn = emit_insn (insn);
|
| 2799 |
|
|
if (GET_CODE (XEXP (mem, 0)) == POST_INC)
|
| 2800 |
|
|
REG_NOTES (insn)
|
| 2801 |
|
|
= alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0),
|
| 2802 |
|
|
REG_NOTES (insn));
|
| 2803 |
|
|
}
|
| 2804 |
|
|
else
|
| 2805 |
|
|
{
|
| 2806 |
|
|
/* Make sure we don't get any other addresses with
|
| 2807 |
|
|
embedded postincrements. They should be stopped in
|
| 2808 |
|
|
GO_IF_LEGITIMATE_ADDRESS, but we're here for your
|
| 2809 |
|
|
safety. */
|
| 2810 |
|
|
if (side_effects_p (addr))
|
| 2811 |
|
|
fatal_insn ("unexpected side-effects in address", addr);
|
| 2812 |
|
|
|
| 2813 |
|
|
emit_insn (gen_rtx_SET
|
| 2814 |
|
|
(VOIDmode,
|
| 2815 |
|
|
operand_subword (dest, reverse, TRUE, mode),
|
| 2816 |
|
|
change_address
|
| 2817 |
|
|
(src, SImode,
|
| 2818 |
|
|
plus_constant (addr,
|
| 2819 |
|
|
reverse * UNITS_PER_WORD))));
|
| 2820 |
|
|
emit_insn (gen_rtx_SET
|
| 2821 |
|
|
(VOIDmode,
|
| 2822 |
|
|
operand_subword (dest, ! reverse, TRUE, mode),
|
| 2823 |
|
|
change_address
|
| 2824 |
|
|
(src, SImode,
|
| 2825 |
|
|
plus_constant (addr,
|
| 2826 |
|
|
(! reverse) *
|
| 2827 |
|
|
UNITS_PER_WORD))));
|
| 2828 |
|
|
}
|
| 2829 |
|
|
}
|
| 2830 |
|
|
else
|
| 2831 |
|
|
internal_error ("unknown src");
|
| 2832 |
|
|
}
|
| 2833 |
|
|
/* Reg-to-mem copy or clear mem. */
|
| 2834 |
|
|
else if (MEM_P (dest)
|
| 2835 |
|
|
&& (REG_P (src)
|
| 2836 |
|
|
|| src == const0_rtx
|
| 2837 |
|
|
|| src == CONST0_RTX (DFmode)))
|
| 2838 |
|
|
{
|
| 2839 |
|
|
rtx addr = XEXP (dest, 0);
|
| 2840 |
|
|
|
| 2841 |
|
|
if (GET_CODE (addr) == POST_INC)
|
| 2842 |
|
|
{
|
| 2843 |
|
|
rtx mem;
|
| 2844 |
|
|
rtx insn;
|
| 2845 |
|
|
|
| 2846 |
|
|
/* Whenever we emit insns with post-incremented addresses
|
| 2847 |
|
|
ourselves, we must add a post-inc note manually. */
|
| 2848 |
|
|
mem = change_address (dest, SImode, addr);
|
| 2849 |
|
|
insn
|
| 2850 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 2851 |
|
|
mem, operand_subword (src, 0, TRUE, mode));
|
| 2852 |
|
|
insn = emit_insn (insn);
|
| 2853 |
|
|
if (GET_CODE (XEXP (mem, 0)) == POST_INC)
|
| 2854 |
|
|
REG_NOTES (insn)
|
| 2855 |
|
|
= alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0),
|
| 2856 |
|
|
REG_NOTES (insn));
|
| 2857 |
|
|
|
| 2858 |
|
|
mem = copy_rtx (mem);
|
| 2859 |
|
|
insn
|
| 2860 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 2861 |
|
|
mem,
|
| 2862 |
|
|
operand_subword (src, 1, TRUE, mode));
|
| 2863 |
|
|
insn = emit_insn (insn);
|
| 2864 |
|
|
if (GET_CODE (XEXP (mem, 0)) == POST_INC)
|
| 2865 |
|
|
REG_NOTES (insn)
|
| 2866 |
|
|
= alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0),
|
| 2867 |
|
|
REG_NOTES (insn));
|
| 2868 |
|
|
}
|
| 2869 |
|
|
else
|
| 2870 |
|
|
{
|
| 2871 |
|
|
/* Make sure we don't get any other addresses with embedded
|
| 2872 |
|
|
postincrements. They should be stopped in
|
| 2873 |
|
|
GO_IF_LEGITIMATE_ADDRESS, but we're here for your safety. */
|
| 2874 |
|
|
if (side_effects_p (addr))
|
| 2875 |
|
|
fatal_insn ("unexpected side-effects in address", addr);
|
| 2876 |
|
|
|
| 2877 |
|
|
emit_insn (gen_rtx_SET
|
| 2878 |
|
|
(VOIDmode,
|
| 2879 |
|
|
change_address (dest, SImode, addr),
|
| 2880 |
|
|
operand_subword (src, 0, TRUE, mode)));
|
| 2881 |
|
|
|
| 2882 |
|
|
emit_insn (gen_rtx_SET
|
| 2883 |
|
|
(VOIDmode,
|
| 2884 |
|
|
change_address (dest, SImode,
|
| 2885 |
|
|
plus_constant (addr,
|
| 2886 |
|
|
UNITS_PER_WORD)),
|
| 2887 |
|
|
operand_subword (src, 1, TRUE, mode)));
|
| 2888 |
|
|
}
|
| 2889 |
|
|
}
|
| 2890 |
|
|
|
| 2891 |
|
|
else
|
| 2892 |
|
|
internal_error ("unknown dest");
|
| 2893 |
|
|
|
| 2894 |
|
|
val = get_insns ();
|
| 2895 |
|
|
end_sequence ();
|
| 2896 |
|
|
return val;
|
| 2897 |
|
|
}
|
| 2898 |
|
|
|
| 2899 |
|
|
/* The expander for the prologue pattern name. */
|
| 2900 |
|
|
|
| 2901 |
|
|
void
|
| 2902 |
|
|
cris_expand_prologue (void)
|
| 2903 |
|
|
{
|
| 2904 |
|
|
int regno;
|
| 2905 |
|
|
int size = get_frame_size ();
|
| 2906 |
|
|
/* Shorten the used name for readability. */
|
| 2907 |
|
|
int cfoa_size = crtl->outgoing_args_size;
|
| 2908 |
|
|
int last_movem_reg = -1;
|
| 2909 |
|
|
int framesize = 0;
|
| 2910 |
|
|
rtx mem, insn;
|
| 2911 |
|
|
int return_address_on_stack = cris_return_address_on_stack ();
|
| 2912 |
|
|
int got_really_used = false;
|
| 2913 |
|
|
int n_movem_regs = 0;
|
| 2914 |
|
|
int pretend = crtl->args.pretend_args_size;
|
| 2915 |
|
|
|
| 2916 |
|
|
/* Don't do anything if no prologues or epilogues are wanted. */
|
| 2917 |
|
|
if (!TARGET_PROLOGUE_EPILOGUE)
|
| 2918 |
|
|
return;
|
| 2919 |
|
|
|
| 2920 |
|
|
CRIS_ASSERT (size >= 0);
|
| 2921 |
|
|
|
| 2922 |
|
|
if (crtl->uses_pic_offset_table)
|
| 2923 |
|
|
{
|
| 2924 |
|
|
/* A reference may have been optimized out (like the abort () in
|
| 2925 |
|
|
fde_split in unwind-dw2-fde.c, at least 3.2.1) so check that
|
| 2926 |
|
|
it's still used. */
|
| 2927 |
|
|
push_topmost_sequence ();
|
| 2928 |
|
|
got_really_used
|
| 2929 |
|
|
= reg_used_between_p (pic_offset_table_rtx, get_insns (), NULL_RTX);
|
| 2930 |
|
|
pop_topmost_sequence ();
|
| 2931 |
|
|
}
|
| 2932 |
|
|
|
| 2933 |
|
|
/* Align the size to what's best for the CPU model. */
|
| 2934 |
|
|
if (TARGET_STACK_ALIGN)
|
| 2935 |
|
|
size = TARGET_ALIGN_BY_32 ? (size + 3) & ~3 : (size + 1) & ~1;
|
| 2936 |
|
|
|
| 2937 |
|
|
if (pretend)
|
| 2938 |
|
|
{
|
| 2939 |
|
|
/* See also cris_setup_incoming_varargs where
|
| 2940 |
|
|
cfun->machine->stdarg_regs is set. There are other setters of
|
| 2941 |
|
|
crtl->args.pretend_args_size than stdarg handling, like
|
| 2942 |
|
|
for an argument passed with parts in R13 and stack. We must
|
| 2943 |
|
|
not store R13 into the pretend-area for that case, as GCC does
|
| 2944 |
|
|
that itself. "Our" store would be marked as redundant and GCC
|
| 2945 |
|
|
will attempt to remove it, which will then be flagged as an
|
| 2946 |
|
|
internal error; trying to remove a frame-related insn. */
|
| 2947 |
|
|
int stdarg_regs = cfun->machine->stdarg_regs;
|
| 2948 |
|
|
|
| 2949 |
|
|
framesize += pretend;
|
| 2950 |
|
|
|
| 2951 |
|
|
for (regno = CRIS_FIRST_ARG_REG + CRIS_MAX_ARGS_IN_REGS - 1;
|
| 2952 |
|
|
stdarg_regs > 0;
|
| 2953 |
|
|
regno--, pretend -= 4, stdarg_regs--)
|
| 2954 |
|
|
{
|
| 2955 |
|
|
insn = emit_insn (gen_rtx_SET (VOIDmode,
|
| 2956 |
|
|
stack_pointer_rtx,
|
| 2957 |
|
|
plus_constant (stack_pointer_rtx,
|
| 2958 |
|
|
-4)));
|
| 2959 |
|
|
/* FIXME: When dwarf2 frame output and unless asynchronous
|
| 2960 |
|
|
exceptions, make dwarf2 bundle together all stack
|
| 2961 |
|
|
adjustments like it does for registers between stack
|
| 2962 |
|
|
adjustments. */
|
| 2963 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 2964 |
|
|
|
| 2965 |
|
|
mem = gen_rtx_MEM (SImode, stack_pointer_rtx);
|
| 2966 |
|
|
set_mem_alias_set (mem, get_varargs_alias_set ());
|
| 2967 |
|
|
insn = emit_move_insn (mem, gen_rtx_raw_REG (SImode, regno));
|
| 2968 |
|
|
|
| 2969 |
|
|
/* Note the absence of RTX_FRAME_RELATED_P on the above insn:
|
| 2970 |
|
|
the value isn't restored, so we don't want to tell dwarf2
|
| 2971 |
|
|
that it's been stored to stack, else EH handling info would
|
| 2972 |
|
|
get confused. */
|
| 2973 |
|
|
}
|
| 2974 |
|
|
|
| 2975 |
|
|
/* For other setters of crtl->args.pretend_args_size, we
|
| 2976 |
|
|
just adjust the stack by leaving the remaining size in
|
| 2977 |
|
|
"pretend", handled below. */
|
| 2978 |
|
|
}
|
| 2979 |
|
|
|
| 2980 |
|
|
/* Save SRP if not a leaf function. */
|
| 2981 |
|
|
if (return_address_on_stack)
|
| 2982 |
|
|
{
|
| 2983 |
|
|
insn = emit_insn (gen_rtx_SET (VOIDmode,
|
| 2984 |
|
|
stack_pointer_rtx,
|
| 2985 |
|
|
plus_constant (stack_pointer_rtx,
|
| 2986 |
|
|
-4 - pretend)));
|
| 2987 |
|
|
pretend = 0;
|
| 2988 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 2989 |
|
|
|
| 2990 |
|
|
mem = gen_rtx_MEM (SImode, stack_pointer_rtx);
|
| 2991 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 2992 |
|
|
insn = emit_move_insn (mem, gen_rtx_raw_REG (SImode, CRIS_SRP_REGNUM));
|
| 2993 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 2994 |
|
|
framesize += 4;
|
| 2995 |
|
|
}
|
| 2996 |
|
|
|
| 2997 |
|
|
/* Set up the frame pointer, if needed. */
|
| 2998 |
|
|
if (frame_pointer_needed)
|
| 2999 |
|
|
{
|
| 3000 |
|
|
insn = emit_insn (gen_rtx_SET (VOIDmode,
|
| 3001 |
|
|
stack_pointer_rtx,
|
| 3002 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3003 |
|
|
-4 - pretend)));
|
| 3004 |
|
|
pretend = 0;
|
| 3005 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3006 |
|
|
|
| 3007 |
|
|
mem = gen_rtx_MEM (SImode, stack_pointer_rtx);
|
| 3008 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3009 |
|
|
insn = emit_move_insn (mem, frame_pointer_rtx);
|
| 3010 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3011 |
|
|
|
| 3012 |
|
|
insn = emit_move_insn (frame_pointer_rtx, stack_pointer_rtx);
|
| 3013 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3014 |
|
|
|
| 3015 |
|
|
framesize += 4;
|
| 3016 |
|
|
}
|
| 3017 |
|
|
|
| 3018 |
|
|
/* Between frame-pointer and saved registers lie the area for local
|
| 3019 |
|
|
variables. If we get here with "pretended" size remaining, count
|
| 3020 |
|
|
it into the general stack size. */
|
| 3021 |
|
|
size += pretend;
|
| 3022 |
|
|
|
| 3023 |
|
|
/* Get a contiguous sequence of registers, starting with R0, that need
|
| 3024 |
|
|
to be saved. */
|
| 3025 |
|
|
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
|
| 3026 |
|
|
{
|
| 3027 |
|
|
if (cris_reg_saved_in_regsave_area (regno, got_really_used))
|
| 3028 |
|
|
{
|
| 3029 |
|
|
n_movem_regs++;
|
| 3030 |
|
|
|
| 3031 |
|
|
/* Check if movem may be used for registers so far. */
|
| 3032 |
|
|
if (regno == last_movem_reg + 1)
|
| 3033 |
|
|
/* Yes, update next expected register. */
|
| 3034 |
|
|
last_movem_reg = regno;
|
| 3035 |
|
|
else
|
| 3036 |
|
|
{
|
| 3037 |
|
|
/* We cannot use movem for all registers. We have to flush
|
| 3038 |
|
|
any movem:ed registers we got so far. */
|
| 3039 |
|
|
if (last_movem_reg != -1)
|
| 3040 |
|
|
{
|
| 3041 |
|
|
int n_saved
|
| 3042 |
|
|
= (n_movem_regs == 1) ? 1 : last_movem_reg + 1;
|
| 3043 |
|
|
|
| 3044 |
|
|
/* It is a win to use a side-effect assignment for
|
| 3045 |
|
|
64 <= size <= 128. But side-effect on movem was
|
| 3046 |
|
|
not usable for CRIS v0..3. Also only do it if
|
| 3047 |
|
|
side-effects insns are allowed. */
|
| 3048 |
|
|
if ((last_movem_reg + 1) * 4 + size >= 64
|
| 3049 |
|
|
&& (last_movem_reg + 1) * 4 + size <= 128
|
| 3050 |
|
|
&& (cris_cpu_version >= CRIS_CPU_SVINTO || n_saved == 1)
|
| 3051 |
|
|
&& TARGET_SIDE_EFFECT_PREFIXES)
|
| 3052 |
|
|
{
|
| 3053 |
|
|
mem
|
| 3054 |
|
|
= gen_rtx_MEM (SImode,
|
| 3055 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3056 |
|
|
-(n_saved * 4 + size)));
|
| 3057 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3058 |
|
|
insn
|
| 3059 |
|
|
= cris_emit_movem_store (mem, GEN_INT (n_saved),
|
| 3060 |
|
|
-(n_saved * 4 + size),
|
| 3061 |
|
|
true);
|
| 3062 |
|
|
}
|
| 3063 |
|
|
else
|
| 3064 |
|
|
{
|
| 3065 |
|
|
insn
|
| 3066 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 3067 |
|
|
stack_pointer_rtx,
|
| 3068 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3069 |
|
|
-(n_saved * 4 + size)));
|
| 3070 |
|
|
insn = emit_insn (insn);
|
| 3071 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3072 |
|
|
|
| 3073 |
|
|
mem = gen_rtx_MEM (SImode, stack_pointer_rtx);
|
| 3074 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3075 |
|
|
insn = cris_emit_movem_store (mem, GEN_INT (n_saved),
|
| 3076 |
|
|
0, true);
|
| 3077 |
|
|
}
|
| 3078 |
|
|
|
| 3079 |
|
|
framesize += n_saved * 4 + size;
|
| 3080 |
|
|
last_movem_reg = -1;
|
| 3081 |
|
|
size = 0;
|
| 3082 |
|
|
}
|
| 3083 |
|
|
|
| 3084 |
|
|
insn = emit_insn (gen_rtx_SET (VOIDmode,
|
| 3085 |
|
|
stack_pointer_rtx,
|
| 3086 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3087 |
|
|
-4 - size)));
|
| 3088 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3089 |
|
|
|
| 3090 |
|
|
mem = gen_rtx_MEM (SImode, stack_pointer_rtx);
|
| 3091 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3092 |
|
|
insn = emit_move_insn (mem, gen_rtx_raw_REG (SImode, regno));
|
| 3093 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3094 |
|
|
|
| 3095 |
|
|
framesize += 4 + size;
|
| 3096 |
|
|
size = 0;
|
| 3097 |
|
|
}
|
| 3098 |
|
|
}
|
| 3099 |
|
|
}
|
| 3100 |
|
|
|
| 3101 |
|
|
/* Check after, if we could movem all registers. This is the normal case. */
|
| 3102 |
|
|
if (last_movem_reg != -1)
|
| 3103 |
|
|
{
|
| 3104 |
|
|
int n_saved
|
| 3105 |
|
|
= (n_movem_regs == 1) ? 1 : last_movem_reg + 1;
|
| 3106 |
|
|
|
| 3107 |
|
|
/* Side-effect on movem was not usable for CRIS v0..3. Also only
|
| 3108 |
|
|
do it if side-effects insns are allowed. */
|
| 3109 |
|
|
if ((last_movem_reg + 1) * 4 + size >= 64
|
| 3110 |
|
|
&& (last_movem_reg + 1) * 4 + size <= 128
|
| 3111 |
|
|
&& (cris_cpu_version >= CRIS_CPU_SVINTO || n_saved == 1)
|
| 3112 |
|
|
&& TARGET_SIDE_EFFECT_PREFIXES)
|
| 3113 |
|
|
{
|
| 3114 |
|
|
mem
|
| 3115 |
|
|
= gen_rtx_MEM (SImode,
|
| 3116 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3117 |
|
|
-(n_saved * 4 + size)));
|
| 3118 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3119 |
|
|
insn = cris_emit_movem_store (mem, GEN_INT (n_saved),
|
| 3120 |
|
|
-(n_saved * 4 + size), true);
|
| 3121 |
|
|
}
|
| 3122 |
|
|
else
|
| 3123 |
|
|
{
|
| 3124 |
|
|
insn
|
| 3125 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 3126 |
|
|
stack_pointer_rtx,
|
| 3127 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3128 |
|
|
-(n_saved * 4 + size)));
|
| 3129 |
|
|
insn = emit_insn (insn);
|
| 3130 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3131 |
|
|
|
| 3132 |
|
|
mem = gen_rtx_MEM (SImode, stack_pointer_rtx);
|
| 3133 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3134 |
|
|
insn = cris_emit_movem_store (mem, GEN_INT (n_saved), 0, true);
|
| 3135 |
|
|
}
|
| 3136 |
|
|
|
| 3137 |
|
|
framesize += n_saved * 4 + size;
|
| 3138 |
|
|
/* We have to put outgoing argument space after regs. */
|
| 3139 |
|
|
if (cfoa_size)
|
| 3140 |
|
|
{
|
| 3141 |
|
|
insn = emit_insn (gen_rtx_SET (VOIDmode,
|
| 3142 |
|
|
stack_pointer_rtx,
|
| 3143 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3144 |
|
|
-cfoa_size)));
|
| 3145 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3146 |
|
|
framesize += cfoa_size;
|
| 3147 |
|
|
}
|
| 3148 |
|
|
}
|
| 3149 |
|
|
else if ((size + cfoa_size) > 0)
|
| 3150 |
|
|
{
|
| 3151 |
|
|
insn = emit_insn (gen_rtx_SET (VOIDmode,
|
| 3152 |
|
|
stack_pointer_rtx,
|
| 3153 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3154 |
|
|
-(cfoa_size + size))));
|
| 3155 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3156 |
|
|
framesize += size + cfoa_size;
|
| 3157 |
|
|
}
|
| 3158 |
|
|
|
| 3159 |
|
|
/* Set up the PIC register, if it is used. */
|
| 3160 |
|
|
if (got_really_used)
|
| 3161 |
|
|
{
|
| 3162 |
|
|
rtx got
|
| 3163 |
|
|
= gen_rtx_UNSPEC (SImode, gen_rtvec (1, const0_rtx), CRIS_UNSPEC_GOT);
|
| 3164 |
|
|
emit_move_insn (pic_offset_table_rtx, got);
|
| 3165 |
|
|
|
| 3166 |
|
|
/* FIXME: This is a cover-up for flow2 messing up; it doesn't
|
| 3167 |
|
|
follow exceptional paths and tries to delete the GOT load as
|
| 3168 |
|
|
unused, if it isn't used on the non-exceptional paths. Other
|
| 3169 |
|
|
ports have similar or other cover-ups, or plain bugs marking
|
| 3170 |
|
|
the GOT register load as maybe-dead. To see this, remove the
|
| 3171 |
|
|
line below and try libsupc++/vec.cc or a trivial
|
| 3172 |
|
|
"static void y (); void x () {try {y ();} catch (...) {}}". */
|
| 3173 |
|
|
emit_use (pic_offset_table_rtx);
|
| 3174 |
|
|
}
|
| 3175 |
|
|
|
| 3176 |
|
|
if (cris_max_stackframe && framesize > cris_max_stackframe)
|
| 3177 |
|
|
warning (0, "stackframe too big: %d bytes", framesize);
|
| 3178 |
|
|
}
|
| 3179 |
|
|
|
| 3180 |
|
|
/* The expander for the epilogue pattern. */
|
| 3181 |
|
|
|
| 3182 |
|
|
void
|
| 3183 |
|
|
cris_expand_epilogue (void)
|
| 3184 |
|
|
{
|
| 3185 |
|
|
int regno;
|
| 3186 |
|
|
int size = get_frame_size ();
|
| 3187 |
|
|
int last_movem_reg = -1;
|
| 3188 |
|
|
int argspace_offset = crtl->outgoing_args_size;
|
| 3189 |
|
|
int pretend = crtl->args.pretend_args_size;
|
| 3190 |
|
|
rtx mem;
|
| 3191 |
|
|
bool return_address_on_stack = cris_return_address_on_stack ();
|
| 3192 |
|
|
/* A reference may have been optimized out
|
| 3193 |
|
|
(like the abort () in fde_split in unwind-dw2-fde.c, at least 3.2.1)
|
| 3194 |
|
|
so check that it's still used. */
|
| 3195 |
|
|
int got_really_used = false;
|
| 3196 |
|
|
int n_movem_regs = 0;
|
| 3197 |
|
|
|
| 3198 |
|
|
if (!TARGET_PROLOGUE_EPILOGUE)
|
| 3199 |
|
|
return;
|
| 3200 |
|
|
|
| 3201 |
|
|
if (crtl->uses_pic_offset_table)
|
| 3202 |
|
|
{
|
| 3203 |
|
|
/* A reference may have been optimized out (like the abort () in
|
| 3204 |
|
|
fde_split in unwind-dw2-fde.c, at least 3.2.1) so check that
|
| 3205 |
|
|
it's still used. */
|
| 3206 |
|
|
push_topmost_sequence ();
|
| 3207 |
|
|
got_really_used
|
| 3208 |
|
|
= reg_used_between_p (pic_offset_table_rtx, get_insns (), NULL_RTX);
|
| 3209 |
|
|
pop_topmost_sequence ();
|
| 3210 |
|
|
}
|
| 3211 |
|
|
|
| 3212 |
|
|
/* Align byte count of stack frame. */
|
| 3213 |
|
|
if (TARGET_STACK_ALIGN)
|
| 3214 |
|
|
size = TARGET_ALIGN_BY_32 ? (size + 3) & ~3 : (size + 1) & ~1;
|
| 3215 |
|
|
|
| 3216 |
|
|
/* Check how many saved regs we can movem. They start at r0 and must
|
| 3217 |
|
|
be contiguous. */
|
| 3218 |
|
|
for (regno = 0;
|
| 3219 |
|
|
regno < FIRST_PSEUDO_REGISTER;
|
| 3220 |
|
|
regno++)
|
| 3221 |
|
|
if (cris_reg_saved_in_regsave_area (regno, got_really_used))
|
| 3222 |
|
|
{
|
| 3223 |
|
|
n_movem_regs++;
|
| 3224 |
|
|
|
| 3225 |
|
|
if (regno == last_movem_reg + 1)
|
| 3226 |
|
|
last_movem_reg = regno;
|
| 3227 |
|
|
else
|
| 3228 |
|
|
break;
|
| 3229 |
|
|
}
|
| 3230 |
|
|
|
| 3231 |
|
|
/* If there was only one register that really needed to be saved
|
| 3232 |
|
|
through movem, don't use movem. */
|
| 3233 |
|
|
if (n_movem_regs == 1)
|
| 3234 |
|
|
last_movem_reg = -1;
|
| 3235 |
|
|
|
| 3236 |
|
|
/* Now emit "normal" move insns for all regs higher than the movem
|
| 3237 |
|
|
regs. */
|
| 3238 |
|
|
for (regno = FIRST_PSEUDO_REGISTER - 1;
|
| 3239 |
|
|
regno > last_movem_reg;
|
| 3240 |
|
|
regno--)
|
| 3241 |
|
|
if (cris_reg_saved_in_regsave_area (regno, got_really_used))
|
| 3242 |
|
|
{
|
| 3243 |
|
|
rtx insn;
|
| 3244 |
|
|
|
| 3245 |
|
|
if (argspace_offset)
|
| 3246 |
|
|
{
|
| 3247 |
|
|
/* There is an area for outgoing parameters located before
|
| 3248 |
|
|
the saved registers. We have to adjust for that. */
|
| 3249 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 3250 |
|
|
stack_pointer_rtx,
|
| 3251 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3252 |
|
|
argspace_offset)));
|
| 3253 |
|
|
/* Make sure we only do this once. */
|
| 3254 |
|
|
argspace_offset = 0;
|
| 3255 |
|
|
}
|
| 3256 |
|
|
|
| 3257 |
|
|
mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode,
|
| 3258 |
|
|
stack_pointer_rtx));
|
| 3259 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3260 |
|
|
insn = emit_move_insn (gen_rtx_raw_REG (SImode, regno), mem);
|
| 3261 |
|
|
|
| 3262 |
|
|
/* Whenever we emit insns with post-incremented addresses
|
| 3263 |
|
|
ourselves, we must add a post-inc note manually. */
|
| 3264 |
|
|
REG_NOTES (insn)
|
| 3265 |
|
|
= alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn));
|
| 3266 |
|
|
}
|
| 3267 |
|
|
|
| 3268 |
|
|
/* If we have any movem-restore, do it now. */
|
| 3269 |
|
|
if (last_movem_reg != -1)
|
| 3270 |
|
|
{
|
| 3271 |
|
|
rtx insn;
|
| 3272 |
|
|
|
| 3273 |
|
|
if (argspace_offset)
|
| 3274 |
|
|
{
|
| 3275 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 3276 |
|
|
stack_pointer_rtx,
|
| 3277 |
|
|
plus_constant (stack_pointer_rtx,
|
| 3278 |
|
|
argspace_offset)));
|
| 3279 |
|
|
argspace_offset = 0;
|
| 3280 |
|
|
}
|
| 3281 |
|
|
|
| 3282 |
|
|
mem = gen_rtx_MEM (SImode,
|
| 3283 |
|
|
gen_rtx_POST_INC (SImode, stack_pointer_rtx));
|
| 3284 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3285 |
|
|
insn
|
| 3286 |
|
|
= emit_insn (cris_gen_movem_load (mem,
|
| 3287 |
|
|
GEN_INT (last_movem_reg + 1), 0));
|
| 3288 |
|
|
/* Whenever we emit insns with post-incremented addresses
|
| 3289 |
|
|
ourselves, we must add a post-inc note manually. */
|
| 3290 |
|
|
if (side_effects_p (PATTERN (insn)))
|
| 3291 |
|
|
REG_NOTES (insn)
|
| 3292 |
|
|
= alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn));
|
| 3293 |
|
|
}
|
| 3294 |
|
|
|
| 3295 |
|
|
/* If we don't clobber all of the allocated stack area (we've already
|
| 3296 |
|
|
deallocated saved registers), GCC might want to schedule loads from
|
| 3297 |
|
|
the stack to *after* the stack-pointer restore, which introduces an
|
| 3298 |
|
|
interrupt race condition. This happened for the initial-value
|
| 3299 |
|
|
SRP-restore for g++.dg/eh/registers1.C (noticed by inspection of
|
| 3300 |
|
|
other failure for that test). It also happened for the stack slot
|
| 3301 |
|
|
for the return value in (one version of)
|
| 3302 |
|
|
linux/fs/dcache.c:__d_lookup, at least with "-O2
|
| 3303 |
|
|
-fno-omit-frame-pointer". */
|
| 3304 |
|
|
|
| 3305 |
|
|
/* Restore frame pointer if necessary. */
|
| 3306 |
|
|
if (frame_pointer_needed)
|
| 3307 |
|
|
{
|
| 3308 |
|
|
rtx insn;
|
| 3309 |
|
|
|
| 3310 |
|
|
emit_insn (gen_cris_frame_deallocated_barrier ());
|
| 3311 |
|
|
|
| 3312 |
|
|
emit_move_insn (stack_pointer_rtx, frame_pointer_rtx);
|
| 3313 |
|
|
mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode,
|
| 3314 |
|
|
stack_pointer_rtx));
|
| 3315 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3316 |
|
|
insn = emit_move_insn (frame_pointer_rtx, mem);
|
| 3317 |
|
|
|
| 3318 |
|
|
/* Whenever we emit insns with post-incremented addresses
|
| 3319 |
|
|
ourselves, we must add a post-inc note manually. */
|
| 3320 |
|
|
REG_NOTES (insn)
|
| 3321 |
|
|
= alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn));
|
| 3322 |
|
|
}
|
| 3323 |
|
|
else if ((size + argspace_offset) != 0)
|
| 3324 |
|
|
{
|
| 3325 |
|
|
emit_insn (gen_cris_frame_deallocated_barrier ());
|
| 3326 |
|
|
|
| 3327 |
|
|
/* If there was no frame-pointer to restore sp from, we must
|
| 3328 |
|
|
explicitly deallocate local variables. */
|
| 3329 |
|
|
|
| 3330 |
|
|
/* Handle space for outgoing parameters that hasn't been handled
|
| 3331 |
|
|
yet. */
|
| 3332 |
|
|
size += argspace_offset;
|
| 3333 |
|
|
|
| 3334 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 3335 |
|
|
stack_pointer_rtx,
|
| 3336 |
|
|
plus_constant (stack_pointer_rtx, size)));
|
| 3337 |
|
|
}
|
| 3338 |
|
|
|
| 3339 |
|
|
/* If this function has no pushed register parameters
|
| 3340 |
|
|
(stdargs/varargs), and if it is not a leaf function, then we have
|
| 3341 |
|
|
the return address on the stack. */
|
| 3342 |
|
|
if (return_address_on_stack && pretend == 0)
|
| 3343 |
|
|
{
|
| 3344 |
|
|
if (TARGET_V32 || crtl->calls_eh_return)
|
| 3345 |
|
|
{
|
| 3346 |
|
|
rtx mem;
|
| 3347 |
|
|
rtx insn;
|
| 3348 |
|
|
rtx srpreg = gen_rtx_raw_REG (SImode, CRIS_SRP_REGNUM);
|
| 3349 |
|
|
mem = gen_rtx_MEM (SImode,
|
| 3350 |
|
|
gen_rtx_POST_INC (SImode,
|
| 3351 |
|
|
stack_pointer_rtx));
|
| 3352 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3353 |
|
|
insn = emit_move_insn (srpreg, mem);
|
| 3354 |
|
|
|
| 3355 |
|
|
/* Whenever we emit insns with post-incremented addresses
|
| 3356 |
|
|
ourselves, we must add a post-inc note manually. */
|
| 3357 |
|
|
REG_NOTES (insn)
|
| 3358 |
|
|
= alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn));
|
| 3359 |
|
|
|
| 3360 |
|
|
if (crtl->calls_eh_return)
|
| 3361 |
|
|
emit_insn (gen_addsi3 (stack_pointer_rtx,
|
| 3362 |
|
|
stack_pointer_rtx,
|
| 3363 |
|
|
gen_rtx_raw_REG (SImode,
|
| 3364 |
|
|
CRIS_STACKADJ_REG)));
|
| 3365 |
|
|
cris_expand_return (false);
|
| 3366 |
|
|
}
|
| 3367 |
|
|
else
|
| 3368 |
|
|
cris_expand_return (true);
|
| 3369 |
|
|
|
| 3370 |
|
|
return;
|
| 3371 |
|
|
}
|
| 3372 |
|
|
|
| 3373 |
|
|
/* If we pushed some register parameters, then adjust the stack for
|
| 3374 |
|
|
them. */
|
| 3375 |
|
|
if (pretend != 0)
|
| 3376 |
|
|
{
|
| 3377 |
|
|
/* If SRP is stored on the way, we need to restore it first. */
|
| 3378 |
|
|
if (return_address_on_stack)
|
| 3379 |
|
|
{
|
| 3380 |
|
|
rtx mem;
|
| 3381 |
|
|
rtx srpreg = gen_rtx_raw_REG (SImode, CRIS_SRP_REGNUM);
|
| 3382 |
|
|
rtx insn;
|
| 3383 |
|
|
|
| 3384 |
|
|
mem = gen_rtx_MEM (SImode,
|
| 3385 |
|
|
gen_rtx_POST_INC (SImode,
|
| 3386 |
|
|
stack_pointer_rtx));
|
| 3387 |
|
|
set_mem_alias_set (mem, get_frame_alias_set ());
|
| 3388 |
|
|
insn = emit_move_insn (srpreg, mem);
|
| 3389 |
|
|
|
| 3390 |
|
|
/* Whenever we emit insns with post-incremented addresses
|
| 3391 |
|
|
ourselves, we must add a post-inc note manually. */
|
| 3392 |
|
|
REG_NOTES (insn)
|
| 3393 |
|
|
= alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn));
|
| 3394 |
|
|
}
|
| 3395 |
|
|
|
| 3396 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 3397 |
|
|
stack_pointer_rtx,
|
| 3398 |
|
|
plus_constant (stack_pointer_rtx, pretend)));
|
| 3399 |
|
|
}
|
| 3400 |
|
|
|
| 3401 |
|
|
/* Perform the "physical" unwinding that the EH machinery calculated. */
|
| 3402 |
|
|
if (crtl->calls_eh_return)
|
| 3403 |
|
|
emit_insn (gen_addsi3 (stack_pointer_rtx,
|
| 3404 |
|
|
stack_pointer_rtx,
|
| 3405 |
|
|
gen_rtx_raw_REG (SImode,
|
| 3406 |
|
|
CRIS_STACKADJ_REG)));
|
| 3407 |
|
|
cris_expand_return (false);
|
| 3408 |
|
|
}
|
| 3409 |
|
|
|
| 3410 |
|
|
/* Worker function for generating movem from mem for load_multiple. */
|
| 3411 |
|
|
|
| 3412 |
|
|
rtx
|
| 3413 |
|
|
cris_gen_movem_load (rtx src, rtx nregs_rtx, int nprefix)
|
| 3414 |
|
|
{
|
| 3415 |
|
|
int nregs = INTVAL (nregs_rtx);
|
| 3416 |
|
|
rtvec vec;
|
| 3417 |
|
|
int eltno = 1;
|
| 3418 |
|
|
int i;
|
| 3419 |
|
|
rtx srcreg = XEXP (src, 0);
|
| 3420 |
|
|
unsigned int regno = nregs - 1;
|
| 3421 |
|
|
int regno_inc = -1;
|
| 3422 |
|
|
|
| 3423 |
|
|
if (TARGET_V32)
|
| 3424 |
|
|
{
|
| 3425 |
|
|
regno = 0;
|
| 3426 |
|
|
regno_inc = 1;
|
| 3427 |
|
|
}
|
| 3428 |
|
|
|
| 3429 |
|
|
if (GET_CODE (srcreg) == POST_INC)
|
| 3430 |
|
|
srcreg = XEXP (srcreg, 0);
|
| 3431 |
|
|
|
| 3432 |
|
|
CRIS_ASSERT (REG_P (srcreg));
|
| 3433 |
|
|
|
| 3434 |
|
|
/* Don't use movem for just one insn. The insns are equivalent except
|
| 3435 |
|
|
for the pipeline hazard (on v32); movem does not forward the loaded
|
| 3436 |
|
|
registers so there's a three cycles penalty for their use. */
|
| 3437 |
|
|
if (nregs == 1)
|
| 3438 |
|
|
return gen_movsi (gen_rtx_REG (SImode, 0), src);
|
| 3439 |
|
|
|
| 3440 |
|
|
vec = rtvec_alloc (nprefix + nregs
|
| 3441 |
|
|
+ (GET_CODE (XEXP (src, 0)) == POST_INC));
|
| 3442 |
|
|
|
| 3443 |
|
|
if (GET_CODE (XEXP (src, 0)) == POST_INC)
|
| 3444 |
|
|
{
|
| 3445 |
|
|
RTVEC_ELT (vec, nprefix + 1)
|
| 3446 |
|
|
= gen_rtx_SET (VOIDmode, srcreg, plus_constant (srcreg, nregs * 4));
|
| 3447 |
|
|
eltno++;
|
| 3448 |
|
|
}
|
| 3449 |
|
|
|
| 3450 |
|
|
src = replace_equiv_address (src, srcreg);
|
| 3451 |
|
|
RTVEC_ELT (vec, nprefix)
|
| 3452 |
|
|
= gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno), src);
|
| 3453 |
|
|
regno += regno_inc;
|
| 3454 |
|
|
|
| 3455 |
|
|
for (i = 1; i < nregs; i++, eltno++)
|
| 3456 |
|
|
{
|
| 3457 |
|
|
RTVEC_ELT (vec, nprefix + eltno)
|
| 3458 |
|
|
= gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno),
|
| 3459 |
|
|
adjust_address_nv (src, SImode, i * 4));
|
| 3460 |
|
|
regno += regno_inc;
|
| 3461 |
|
|
}
|
| 3462 |
|
|
|
| 3463 |
|
|
return gen_rtx_PARALLEL (VOIDmode, vec);
|
| 3464 |
|
|
}
|
| 3465 |
|
|
|
| 3466 |
|
|
/* Worker function for generating movem to mem. If FRAME_RELATED, notes
|
| 3467 |
|
|
are added that the dwarf2 machinery understands. */
|
| 3468 |
|
|
|
| 3469 |
|
|
rtx
|
| 3470 |
|
|
cris_emit_movem_store (rtx dest, rtx nregs_rtx, int increment,
|
| 3471 |
|
|
bool frame_related)
|
| 3472 |
|
|
{
|
| 3473 |
|
|
int nregs = INTVAL (nregs_rtx);
|
| 3474 |
|
|
rtvec vec;
|
| 3475 |
|
|
int eltno = 1;
|
| 3476 |
|
|
int i;
|
| 3477 |
|
|
rtx insn;
|
| 3478 |
|
|
rtx destreg = XEXP (dest, 0);
|
| 3479 |
|
|
unsigned int regno = nregs - 1;
|
| 3480 |
|
|
int regno_inc = -1;
|
| 3481 |
|
|
|
| 3482 |
|
|
if (TARGET_V32)
|
| 3483 |
|
|
{
|
| 3484 |
|
|
regno = 0;
|
| 3485 |
|
|
regno_inc = 1;
|
| 3486 |
|
|
}
|
| 3487 |
|
|
|
| 3488 |
|
|
if (GET_CODE (destreg) == POST_INC)
|
| 3489 |
|
|
increment += nregs * 4;
|
| 3490 |
|
|
|
| 3491 |
|
|
if (GET_CODE (destreg) == POST_INC || GET_CODE (destreg) == PLUS)
|
| 3492 |
|
|
destreg = XEXP (destreg, 0);
|
| 3493 |
|
|
|
| 3494 |
|
|
CRIS_ASSERT (REG_P (destreg));
|
| 3495 |
|
|
|
| 3496 |
|
|
/* Don't use movem for just one insn. The insns are equivalent except
|
| 3497 |
|
|
for the pipeline hazard (on v32); movem does not forward the loaded
|
| 3498 |
|
|
registers so there's a three cycles penalty for use. */
|
| 3499 |
|
|
if (nregs == 1)
|
| 3500 |
|
|
{
|
| 3501 |
|
|
rtx mov = gen_rtx_SET (VOIDmode, dest, gen_rtx_REG (SImode, 0));
|
| 3502 |
|
|
|
| 3503 |
|
|
if (increment == 0)
|
| 3504 |
|
|
{
|
| 3505 |
|
|
insn = emit_insn (mov);
|
| 3506 |
|
|
if (frame_related)
|
| 3507 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3508 |
|
|
return insn;
|
| 3509 |
|
|
}
|
| 3510 |
|
|
|
| 3511 |
|
|
/* If there was a request for a side-effect, create the ordinary
|
| 3512 |
|
|
parallel. */
|
| 3513 |
|
|
vec = rtvec_alloc (2);
|
| 3514 |
|
|
|
| 3515 |
|
|
RTVEC_ELT (vec, 0) = mov;
|
| 3516 |
|
|
RTVEC_ELT (vec, 1) = gen_rtx_SET (VOIDmode, destreg,
|
| 3517 |
|
|
plus_constant (destreg, increment));
|
| 3518 |
|
|
if (frame_related)
|
| 3519 |
|
|
{
|
| 3520 |
|
|
RTX_FRAME_RELATED_P (mov) = 1;
|
| 3521 |
|
|
RTX_FRAME_RELATED_P (RTVEC_ELT (vec, 1)) = 1;
|
| 3522 |
|
|
}
|
| 3523 |
|
|
}
|
| 3524 |
|
|
else
|
| 3525 |
|
|
{
|
| 3526 |
|
|
vec = rtvec_alloc (nregs + (increment != 0 ? 1 : 0));
|
| 3527 |
|
|
RTVEC_ELT (vec, 0)
|
| 3528 |
|
|
= gen_rtx_SET (VOIDmode,
|
| 3529 |
|
|
replace_equiv_address (dest,
|
| 3530 |
|
|
plus_constant (destreg,
|
| 3531 |
|
|
increment)),
|
| 3532 |
|
|
gen_rtx_REG (SImode, regno));
|
| 3533 |
|
|
regno += regno_inc;
|
| 3534 |
|
|
|
| 3535 |
|
|
/* The dwarf2 info wants this mark on each component in a parallel
|
| 3536 |
|
|
that's part of the prologue (though it's optional on the first
|
| 3537 |
|
|
component). */
|
| 3538 |
|
|
if (frame_related)
|
| 3539 |
|
|
RTX_FRAME_RELATED_P (RTVEC_ELT (vec, 0)) = 1;
|
| 3540 |
|
|
|
| 3541 |
|
|
if (increment != 0)
|
| 3542 |
|
|
{
|
| 3543 |
|
|
RTVEC_ELT (vec, 1)
|
| 3544 |
|
|
= gen_rtx_SET (VOIDmode, destreg,
|
| 3545 |
|
|
plus_constant (destreg,
|
| 3546 |
|
|
increment != 0
|
| 3547 |
|
|
? increment : nregs * 4));
|
| 3548 |
|
|
eltno++;
|
| 3549 |
|
|
|
| 3550 |
|
|
if (frame_related)
|
| 3551 |
|
|
RTX_FRAME_RELATED_P (RTVEC_ELT (vec, 1)) = 1;
|
| 3552 |
|
|
|
| 3553 |
|
|
/* Don't call adjust_address_nv on a post-incremented address if
|
| 3554 |
|
|
we can help it. */
|
| 3555 |
|
|
if (GET_CODE (XEXP (dest, 0)) == POST_INC)
|
| 3556 |
|
|
dest = replace_equiv_address (dest, destreg);
|
| 3557 |
|
|
}
|
| 3558 |
|
|
|
| 3559 |
|
|
for (i = 1; i < nregs; i++, eltno++)
|
| 3560 |
|
|
{
|
| 3561 |
|
|
RTVEC_ELT (vec, eltno)
|
| 3562 |
|
|
= gen_rtx_SET (VOIDmode, adjust_address_nv (dest, SImode, i * 4),
|
| 3563 |
|
|
gen_rtx_REG (SImode, regno));
|
| 3564 |
|
|
if (frame_related)
|
| 3565 |
|
|
RTX_FRAME_RELATED_P (RTVEC_ELT (vec, eltno)) = 1;
|
| 3566 |
|
|
regno += regno_inc;
|
| 3567 |
|
|
}
|
| 3568 |
|
|
}
|
| 3569 |
|
|
|
| 3570 |
|
|
insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, vec));
|
| 3571 |
|
|
|
| 3572 |
|
|
/* Because dwarf2out.c handles the insns in a parallel as a sequence,
|
| 3573 |
|
|
we need to keep the stack adjustment separate, after the
|
| 3574 |
|
|
MEM-setters. Else the stack-adjustment in the second component of
|
| 3575 |
|
|
the parallel would be mishandled; the offsets for the SETs that
|
| 3576 |
|
|
follow it would be wrong. We prepare for this by adding a
|
| 3577 |
|
|
REG_FRAME_RELATED_EXPR with the MEM-setting parts in a SEQUENCE
|
| 3578 |
|
|
followed by the increment. Note that we have FRAME_RELATED_P on
|
| 3579 |
|
|
all the SETs, including the original stack adjustment SET in the
|
| 3580 |
|
|
parallel. */
|
| 3581 |
|
|
if (frame_related)
|
| 3582 |
|
|
{
|
| 3583 |
|
|
if (increment != 0)
|
| 3584 |
|
|
{
|
| 3585 |
|
|
rtx seq = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (nregs + 1));
|
| 3586 |
|
|
XVECEXP (seq, 0, 0) = copy_rtx (XVECEXP (PATTERN (insn), 0, 0));
|
| 3587 |
|
|
for (i = 1; i < nregs; i++)
|
| 3588 |
|
|
XVECEXP (seq, 0, i)
|
| 3589 |
|
|
= copy_rtx (XVECEXP (PATTERN (insn), 0, i + 1));
|
| 3590 |
|
|
XVECEXP (seq, 0, nregs) = copy_rtx (XVECEXP (PATTERN (insn), 0, 1));
|
| 3591 |
|
|
add_reg_note (insn, REG_FRAME_RELATED_EXPR, seq);
|
| 3592 |
|
|
}
|
| 3593 |
|
|
|
| 3594 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 3595 |
|
|
}
|
| 3596 |
|
|
|
| 3597 |
|
|
return insn;
|
| 3598 |
|
|
}
|
| 3599 |
|
|
|
| 3600 |
|
|
/* Worker function for expanding the address for PIC function calls. */
|
| 3601 |
|
|
|
| 3602 |
|
|
void
|
| 3603 |
|
|
cris_expand_pic_call_address (rtx *opp)
|
| 3604 |
|
|
{
|
| 3605 |
|
|
rtx op = *opp;
|
| 3606 |
|
|
|
| 3607 |
|
|
gcc_assert (MEM_P (op));
|
| 3608 |
|
|
op = XEXP (op, 0);
|
| 3609 |
|
|
|
| 3610 |
|
|
/* It might be that code can be generated that jumps to 0 (or to a
|
| 3611 |
|
|
specific address). Don't die on that. (There is a
|
| 3612 |
|
|
testcase.) */
|
| 3613 |
|
|
if (CONSTANT_ADDRESS_P (op) && !CONST_INT_P (op))
|
| 3614 |
|
|
{
|
| 3615 |
|
|
enum cris_pic_symbol_type t = cris_pic_symbol_type_of (op);
|
| 3616 |
|
|
|
| 3617 |
|
|
CRIS_ASSERT (can_create_pseudo_p ());
|
| 3618 |
|
|
|
| 3619 |
|
|
/* For local symbols (non-PLT), just get the plain symbol
|
| 3620 |
|
|
reference into a register. For symbols that can be PLT, make
|
| 3621 |
|
|
them PLT. */
|
| 3622 |
|
|
if (t == cris_rel_symbol)
|
| 3623 |
|
|
{
|
| 3624 |
|
|
/* For v32, we're fine as-is; just PICify the symbol. Forcing
|
| 3625 |
|
|
into a register caused performance regression for 3.2.1,
|
| 3626 |
|
|
observable in __floatdidf and elsewhere in libgcc. */
|
| 3627 |
|
|
if (TARGET_V32)
|
| 3628 |
|
|
{
|
| 3629 |
|
|
rtx sym = GET_CODE (op) != CONST ? op : get_related_value (op);
|
| 3630 |
|
|
HOST_WIDE_INT offs = get_integer_term (op);
|
| 3631 |
|
|
|
| 3632 |
|
|
/* We can't get calls to sym+N, N integer, can we? */
|
| 3633 |
|
|
gcc_assert (offs == 0);
|
| 3634 |
|
|
|
| 3635 |
|
|
op = gen_rtx_CONST (Pmode,
|
| 3636 |
|
|
gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym),
|
| 3637 |
|
|
CRIS_UNSPEC_PCREL));
|
| 3638 |
|
|
}
|
| 3639 |
|
|
else
|
| 3640 |
|
|
op = force_reg (Pmode, op);
|
| 3641 |
|
|
}
|
| 3642 |
|
|
else if (t == cris_got_symbol)
|
| 3643 |
|
|
{
|
| 3644 |
|
|
if (TARGET_AVOID_GOTPLT)
|
| 3645 |
|
|
{
|
| 3646 |
|
|
/* Change a "jsr sym" into (allocate register rM, rO)
|
| 3647 |
|
|
"move.d (const (unspec [sym rPIC] CRIS_UNSPEC_PLT_GOTREL)),rM"
|
| 3648 |
|
|
"add.d rPIC,rM,rO", "jsr rO" for pre-v32 and
|
| 3649 |
|
|
"jsr (const (unspec [sym rPIC] CRIS_UNSPEC_PLT_PCREL))"
|
| 3650 |
|
|
for v32. */
|
| 3651 |
|
|
rtx tem, rm, ro;
|
| 3652 |
|
|
gcc_assert (can_create_pseudo_p ());
|
| 3653 |
|
|
crtl->uses_pic_offset_table = 1;
|
| 3654 |
|
|
tem = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op),
|
| 3655 |
|
|
TARGET_V32
|
| 3656 |
|
|
? CRIS_UNSPEC_PLT_PCREL
|
| 3657 |
|
|
: CRIS_UNSPEC_PLT_GOTREL);
|
| 3658 |
|
|
tem = gen_rtx_CONST (Pmode, tem);
|
| 3659 |
|
|
if (TARGET_V32)
|
| 3660 |
|
|
op = tem;
|
| 3661 |
|
|
else
|
| 3662 |
|
|
{
|
| 3663 |
|
|
rm = gen_reg_rtx (Pmode);
|
| 3664 |
|
|
emit_move_insn (rm, tem);
|
| 3665 |
|
|
ro = gen_reg_rtx (Pmode);
|
| 3666 |
|
|
if (expand_binop (Pmode, add_optab, rm,
|
| 3667 |
|
|
pic_offset_table_rtx,
|
| 3668 |
|
|
ro, 0, OPTAB_LIB_WIDEN) != ro)
|
| 3669 |
|
|
internal_error ("expand_binop failed in movsi got");
|
| 3670 |
|
|
op = ro;
|
| 3671 |
|
|
}
|
| 3672 |
|
|
}
|
| 3673 |
|
|
else
|
| 3674 |
|
|
{
|
| 3675 |
|
|
/* Change a "jsr sym" into (allocate register rM, rO)
|
| 3676 |
|
|
"move.d (const (unspec [sym] CRIS_UNSPEC_PLTGOTREAD)),rM"
|
| 3677 |
|
|
"add.d rPIC,rM,rO" "jsr [rO]" with the memory access
|
| 3678 |
|
|
marked as not trapping and not aliasing. No "move.d
|
| 3679 |
|
|
[rO],rP" as that would invite to re-use of a value
|
| 3680 |
|
|
that should not be reused. FIXME: Need a peephole2
|
| 3681 |
|
|
for cases when this is cse:d from the call, to change
|
| 3682 |
|
|
back to just get the PLT entry address, so we don't
|
| 3683 |
|
|
resolve the same symbol over and over (the memory
|
| 3684 |
|
|
access of the PLTGOT isn't constant). */
|
| 3685 |
|
|
rtx tem, mem, rm, ro;
|
| 3686 |
|
|
|
| 3687 |
|
|
gcc_assert (can_create_pseudo_p ());
|
| 3688 |
|
|
crtl->uses_pic_offset_table = 1;
|
| 3689 |
|
|
tem = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op),
|
| 3690 |
|
|
CRIS_UNSPEC_PLTGOTREAD);
|
| 3691 |
|
|
rm = gen_reg_rtx (Pmode);
|
| 3692 |
|
|
emit_move_insn (rm, gen_rtx_CONST (Pmode, tem));
|
| 3693 |
|
|
ro = gen_reg_rtx (Pmode);
|
| 3694 |
|
|
if (expand_binop (Pmode, add_optab, rm,
|
| 3695 |
|
|
pic_offset_table_rtx,
|
| 3696 |
|
|
ro, 0, OPTAB_LIB_WIDEN) != ro)
|
| 3697 |
|
|
internal_error ("expand_binop failed in movsi got");
|
| 3698 |
|
|
mem = gen_rtx_MEM (Pmode, ro);
|
| 3699 |
|
|
|
| 3700 |
|
|
/* This MEM doesn't alias anything. Whether it aliases
|
| 3701 |
|
|
other same symbols is unimportant. */
|
| 3702 |
|
|
set_mem_alias_set (mem, new_alias_set ());
|
| 3703 |
|
|
MEM_NOTRAP_P (mem) = 1;
|
| 3704 |
|
|
op = mem;
|
| 3705 |
|
|
}
|
| 3706 |
|
|
}
|
| 3707 |
|
|
else
|
| 3708 |
|
|
/* Can't possibly get a GOT-needing-fixup for a function-call,
|
| 3709 |
|
|
right? */
|
| 3710 |
|
|
fatal_insn ("unidentifiable call op", op);
|
| 3711 |
|
|
|
| 3712 |
|
|
*opp = replace_equiv_address (*opp, op);
|
| 3713 |
|
|
}
|
| 3714 |
|
|
}
|
| 3715 |
|
|
|
| 3716 |
|
|
/* Make sure operands are in the right order for an addsi3 insn as
|
| 3717 |
|
|
generated by a define_split. Nothing but REG_P as the first
|
| 3718 |
|
|
operand is recognized by addsi3 after reload. OPERANDS contains
|
| 3719 |
|
|
the operands, with the first at OPERANDS[N] and the second at
|
| 3720 |
|
|
OPERANDS[N+1]. */
|
| 3721 |
|
|
|
| 3722 |
|
|
void
|
| 3723 |
|
|
cris_order_for_addsi3 (rtx *operands, int n)
|
| 3724 |
|
|
{
|
| 3725 |
|
|
if (!REG_P (operands[n]))
|
| 3726 |
|
|
{
|
| 3727 |
|
|
rtx tem = operands[n];
|
| 3728 |
|
|
operands[n] = operands[n + 1];
|
| 3729 |
|
|
operands[n + 1] = tem;
|
| 3730 |
|
|
}
|
| 3731 |
|
|
}
|
| 3732 |
|
|
|
| 3733 |
|
|
/* Use from within code, from e.g. PRINT_OPERAND and
|
| 3734 |
|
|
PRINT_OPERAND_ADDRESS. Macros used in output_addr_const need to emit
|
| 3735 |
|
|
different things depending on whether code operand or constant is
|
| 3736 |
|
|
emitted. */
|
| 3737 |
|
|
|
| 3738 |
|
|
static void
|
| 3739 |
|
|
cris_output_addr_const (FILE *file, rtx x)
|
| 3740 |
|
|
{
|
| 3741 |
|
|
in_code++;
|
| 3742 |
|
|
output_addr_const (file, x);
|
| 3743 |
|
|
in_code--;
|
| 3744 |
|
|
}
|
| 3745 |
|
|
|
| 3746 |
|
|
/* Worker function for ASM_OUTPUT_SYMBOL_REF. */
|
| 3747 |
|
|
|
| 3748 |
|
|
void
|
| 3749 |
|
|
cris_asm_output_symbol_ref (FILE *file, rtx x)
|
| 3750 |
|
|
{
|
| 3751 |
|
|
gcc_assert (GET_CODE (x) == SYMBOL_REF);
|
| 3752 |
|
|
|
| 3753 |
|
|
if (flag_pic && in_code > 0)
|
| 3754 |
|
|
{
|
| 3755 |
|
|
const char *origstr = XSTR (x, 0);
|
| 3756 |
|
|
const char *str;
|
| 3757 |
|
|
str = (* targetm.strip_name_encoding) (origstr);
|
| 3758 |
|
|
assemble_name (file, str);
|
| 3759 |
|
|
|
| 3760 |
|
|
/* Sanity check. */
|
| 3761 |
|
|
if (!TARGET_V32 && !crtl->uses_pic_offset_table)
|
| 3762 |
|
|
output_operand_lossage ("PIC register isn't set up");
|
| 3763 |
|
|
}
|
| 3764 |
|
|
else
|
| 3765 |
|
|
assemble_name (file, XSTR (x, 0));
|
| 3766 |
|
|
}
|
| 3767 |
|
|
|
| 3768 |
|
|
/* Worker function for ASM_OUTPUT_LABEL_REF. */
|
| 3769 |
|
|
|
| 3770 |
|
|
void
|
| 3771 |
|
|
cris_asm_output_label_ref (FILE *file, char *buf)
|
| 3772 |
|
|
{
|
| 3773 |
|
|
if (flag_pic && in_code > 0)
|
| 3774 |
|
|
{
|
| 3775 |
|
|
assemble_name (file, buf);
|
| 3776 |
|
|
|
| 3777 |
|
|
/* Sanity check. */
|
| 3778 |
|
|
if (!TARGET_V32 && !crtl->uses_pic_offset_table)
|
| 3779 |
|
|
internal_error ("emitting PIC operand, but PIC register "
|
| 3780 |
|
|
"isn%'t set up");
|
| 3781 |
|
|
}
|
| 3782 |
|
|
else
|
| 3783 |
|
|
assemble_name (file, buf);
|
| 3784 |
|
|
}
|
| 3785 |
|
|
|
| 3786 |
|
|
/* Worker function for TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */
|
| 3787 |
|
|
|
| 3788 |
|
|
static bool
|
| 3789 |
|
|
cris_output_addr_const_extra (FILE *file, rtx xconst)
|
| 3790 |
|
|
{
|
| 3791 |
|
|
switch (GET_CODE (xconst))
|
| 3792 |
|
|
{
|
| 3793 |
|
|
rtx x;
|
| 3794 |
|
|
|
| 3795 |
|
|
case UNSPEC:
|
| 3796 |
|
|
x = XVECEXP (xconst, 0, 0);
|
| 3797 |
|
|
CRIS_ASSERT (GET_CODE (x) == SYMBOL_REF
|
| 3798 |
|
|
|| GET_CODE (x) == LABEL_REF
|
| 3799 |
|
|
|| GET_CODE (x) == CONST);
|
| 3800 |
|
|
output_addr_const (file, x);
|
| 3801 |
|
|
switch (XINT (xconst, 1))
|
| 3802 |
|
|
{
|
| 3803 |
|
|
case CRIS_UNSPEC_PCREL:
|
| 3804 |
|
|
/* We only get this with -fpic/PIC to tell it apart from an
|
| 3805 |
|
|
invalid symbol. We can't tell here, but it should only
|
| 3806 |
|
|
be the operand of a call or movsi. */
|
| 3807 |
|
|
gcc_assert (TARGET_V32 && flag_pic);
|
| 3808 |
|
|
break;
|
| 3809 |
|
|
|
| 3810 |
|
|
case CRIS_UNSPEC_PLT_PCREL:
|
| 3811 |
|
|
gcc_assert (TARGET_V32);
|
| 3812 |
|
|
fprintf (file, ":PLT");
|
| 3813 |
|
|
break;
|
| 3814 |
|
|
|
| 3815 |
|
|
case CRIS_UNSPEC_PLT_GOTREL:
|
| 3816 |
|
|
gcc_assert (!TARGET_V32);
|
| 3817 |
|
|
fprintf (file, ":PLTG");
|
| 3818 |
|
|
break;
|
| 3819 |
|
|
|
| 3820 |
|
|
case CRIS_UNSPEC_GOTREL:
|
| 3821 |
|
|
gcc_assert (!TARGET_V32);
|
| 3822 |
|
|
fprintf (file, ":GOTOFF");
|
| 3823 |
|
|
break;
|
| 3824 |
|
|
|
| 3825 |
|
|
case CRIS_UNSPEC_GOTREAD:
|
| 3826 |
|
|
if (flag_pic == 1)
|
| 3827 |
|
|
fprintf (file, ":GOT16");
|
| 3828 |
|
|
else
|
| 3829 |
|
|
fprintf (file, ":GOT");
|
| 3830 |
|
|
break;
|
| 3831 |
|
|
|
| 3832 |
|
|
case CRIS_UNSPEC_PLTGOTREAD:
|
| 3833 |
|
|
if (flag_pic == 1)
|
| 3834 |
|
|
fprintf (file, CRIS_GOTPLT_SUFFIX "16");
|
| 3835 |
|
|
else
|
| 3836 |
|
|
fprintf (file, CRIS_GOTPLT_SUFFIX);
|
| 3837 |
|
|
break;
|
| 3838 |
|
|
|
| 3839 |
|
|
default:
|
| 3840 |
|
|
gcc_unreachable ();
|
| 3841 |
|
|
}
|
| 3842 |
|
|
return true;
|
| 3843 |
|
|
|
| 3844 |
|
|
default:
|
| 3845 |
|
|
return false;
|
| 3846 |
|
|
}
|
| 3847 |
|
|
}
|
| 3848 |
|
|
|
| 3849 |
|
|
/* Worker function for TARGET_STRUCT_VALUE_RTX. */
|
| 3850 |
|
|
|
| 3851 |
|
|
static rtx
|
| 3852 |
|
|
cris_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
|
| 3853 |
|
|
int incoming ATTRIBUTE_UNUSED)
|
| 3854 |
|
|
{
|
| 3855 |
|
|
return gen_rtx_REG (Pmode, CRIS_STRUCT_VALUE_REGNUM);
|
| 3856 |
|
|
}
|
| 3857 |
|
|
|
| 3858 |
|
|
/* Worker function for TARGET_SETUP_INCOMING_VARARGS. */
|
| 3859 |
|
|
|
| 3860 |
|
|
static void
|
| 3861 |
|
|
cris_setup_incoming_varargs (cumulative_args_t ca_v,
|
| 3862 |
|
|
enum machine_mode mode ATTRIBUTE_UNUSED,
|
| 3863 |
|
|
tree type ATTRIBUTE_UNUSED,
|
| 3864 |
|
|
int *pretend_arg_size,
|
| 3865 |
|
|
int second_time)
|
| 3866 |
|
|
{
|
| 3867 |
|
|
CUMULATIVE_ARGS *ca = get_cumulative_args (ca_v);
|
| 3868 |
|
|
|
| 3869 |
|
|
if (ca->regs < CRIS_MAX_ARGS_IN_REGS)
|
| 3870 |
|
|
{
|
| 3871 |
|
|
int stdarg_regs = CRIS_MAX_ARGS_IN_REGS - ca->regs;
|
| 3872 |
|
|
cfun->machine->stdarg_regs = stdarg_regs;
|
| 3873 |
|
|
*pretend_arg_size = stdarg_regs * 4;
|
| 3874 |
|
|
}
|
| 3875 |
|
|
|
| 3876 |
|
|
if (TARGET_PDEBUG)
|
| 3877 |
|
|
fprintf (asm_out_file,
|
| 3878 |
|
|
"\n; VA:: ANSI: %d args before, anon @ #%d, %dtime\n",
|
| 3879 |
|
|
ca->regs, *pretend_arg_size, second_time);
|
| 3880 |
|
|
}
|
| 3881 |
|
|
|
| 3882 |
|
|
/* Return true if TYPE must be passed by invisible reference.
|
| 3883 |
|
|
For cris, we pass <= 8 bytes by value, others by reference. */
|
| 3884 |
|
|
|
| 3885 |
|
|
static bool
|
| 3886 |
|
|
cris_pass_by_reference (cumulative_args_t ca ATTRIBUTE_UNUSED,
|
| 3887 |
|
|
enum machine_mode mode, const_tree type,
|
| 3888 |
|
|
bool named ATTRIBUTE_UNUSED)
|
| 3889 |
|
|
{
|
| 3890 |
|
|
return (targetm.calls.must_pass_in_stack (mode, type)
|
| 3891 |
|
|
|| CRIS_FUNCTION_ARG_SIZE (mode, type) > 8);
|
| 3892 |
|
|
}
|
| 3893 |
|
|
|
| 3894 |
|
|
/* A combination of defining TARGET_PROMOTE_FUNCTION_MODE, promoting arguments
|
| 3895 |
|
|
and *not* defining TARGET_PROMOTE_PROTOTYPES or PROMOTE_MODE gives the
|
| 3896 |
|
|
best code size and speed for gcc, ipps and products in gcc-2.7.2. */
|
| 3897 |
|
|
|
| 3898 |
|
|
enum machine_mode
|
| 3899 |
|
|
cris_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
|
| 3900 |
|
|
enum machine_mode mode,
|
| 3901 |
|
|
int *punsignedp ATTRIBUTE_UNUSED,
|
| 3902 |
|
|
const_tree fntype ATTRIBUTE_UNUSED,
|
| 3903 |
|
|
int for_return)
|
| 3904 |
|
|
{
|
| 3905 |
|
|
/* Defining PROMOTE_FUNCTION_RETURN in gcc-2.7.2 uncovered bug 981110 (even
|
| 3906 |
|
|
when modifying TARGET_FUNCTION_VALUE to return the promoted mode).
|
| 3907 |
|
|
Maybe pointless as of now, but let's keep the old behavior. */
|
| 3908 |
|
|
if (for_return == 1)
|
| 3909 |
|
|
return mode;
|
| 3910 |
|
|
return CRIS_PROMOTED_MODE (mode, *punsignedp, type);
|
| 3911 |
|
|
}
|
| 3912 |
|
|
|
| 3913 |
|
|
/* Let's assume all functions return in r[CRIS_FIRST_ARG_REG] for the
|
| 3914 |
|
|
time being. */
|
| 3915 |
|
|
|
| 3916 |
|
|
static rtx
|
| 3917 |
|
|
cris_function_value(const_tree type,
|
| 3918 |
|
|
const_tree func ATTRIBUTE_UNUSED,
|
| 3919 |
|
|
bool outgoing ATTRIBUTE_UNUSED)
|
| 3920 |
|
|
{
|
| 3921 |
|
|
return gen_rtx_REG (TYPE_MODE (type), CRIS_FIRST_ARG_REG);
|
| 3922 |
|
|
}
|
| 3923 |
|
|
|
| 3924 |
|
|
/* Let's assume all functions return in r[CRIS_FIRST_ARG_REG] for the
|
| 3925 |
|
|
time being. */
|
| 3926 |
|
|
|
| 3927 |
|
|
static rtx
|
| 3928 |
|
|
cris_libcall_value (enum machine_mode mode,
|
| 3929 |
|
|
const_rtx fun ATTRIBUTE_UNUSED)
|
| 3930 |
|
|
{
|
| 3931 |
|
|
return gen_rtx_REG (mode, CRIS_FIRST_ARG_REG);
|
| 3932 |
|
|
}
|
| 3933 |
|
|
|
| 3934 |
|
|
/* Let's assume all functions return in r[CRIS_FIRST_ARG_REG] for the
|
| 3935 |
|
|
time being. */
|
| 3936 |
|
|
|
| 3937 |
|
|
static bool
|
| 3938 |
|
|
cris_function_value_regno_p (const unsigned int regno)
|
| 3939 |
|
|
{
|
| 3940 |
|
|
return (regno == CRIS_FIRST_ARG_REG);
|
| 3941 |
|
|
}
|
| 3942 |
|
|
|
| 3943 |
|
|
static int
|
| 3944 |
|
|
cris_arg_partial_bytes (cumulative_args_t ca, enum machine_mode mode,
|
| 3945 |
|
|
tree type, bool named ATTRIBUTE_UNUSED)
|
| 3946 |
|
|
{
|
| 3947 |
|
|
if (get_cumulative_args (ca)->regs == CRIS_MAX_ARGS_IN_REGS - 1
|
| 3948 |
|
|
&& !targetm.calls.must_pass_in_stack (mode, type)
|
| 3949 |
|
|
&& CRIS_FUNCTION_ARG_SIZE (mode, type) > 4
|
| 3950 |
|
|
&& CRIS_FUNCTION_ARG_SIZE (mode, type) <= 8)
|
| 3951 |
|
|
return UNITS_PER_WORD;
|
| 3952 |
|
|
else
|
| 3953 |
|
|
return 0;
|
| 3954 |
|
|
}
|
| 3955 |
|
|
|
| 3956 |
|
|
static rtx
|
| 3957 |
|
|
cris_function_arg_1 (cumulative_args_t ca_v,
|
| 3958 |
|
|
enum machine_mode mode ATTRIBUTE_UNUSED,
|
| 3959 |
|
|
const_tree type ATTRIBUTE_UNUSED,
|
| 3960 |
|
|
bool named, bool incoming)
|
| 3961 |
|
|
{
|
| 3962 |
|
|
const CUMULATIVE_ARGS *ca = get_cumulative_args (ca_v);
|
| 3963 |
|
|
|
| 3964 |
|
|
if ((!incoming || named) && ca->regs < CRIS_MAX_ARGS_IN_REGS)
|
| 3965 |
|
|
return gen_rtx_REG (mode, CRIS_FIRST_ARG_REG + ca->regs);
|
| 3966 |
|
|
else
|
| 3967 |
|
|
return NULL_RTX;
|
| 3968 |
|
|
}
|
| 3969 |
|
|
|
| 3970 |
|
|
/* Worker function for TARGET_FUNCTION_ARG.
|
| 3971 |
|
|
The void_type_node is sent as a "closing" call. */
|
| 3972 |
|
|
|
| 3973 |
|
|
static rtx
|
| 3974 |
|
|
cris_function_arg (cumulative_args_t ca, enum machine_mode mode,
|
| 3975 |
|
|
const_tree type, bool named)
|
| 3976 |
|
|
{
|
| 3977 |
|
|
return cris_function_arg_1 (ca, mode, type, named, false);
|
| 3978 |
|
|
}
|
| 3979 |
|
|
|
| 3980 |
|
|
/* Worker function for TARGET_FUNCTION_INCOMING_ARG.
|
| 3981 |
|
|
|
| 3982 |
|
|
The differences between this and the previous, is that this one checks
|
| 3983 |
|
|
that an argument is named, since incoming stdarg/varargs arguments are
|
| 3984 |
|
|
pushed onto the stack, and we don't have to check against the "closing"
|
| 3985 |
|
|
void_type_node TYPE parameter. */
|
| 3986 |
|
|
|
| 3987 |
|
|
static rtx
|
| 3988 |
|
|
cris_function_incoming_arg (cumulative_args_t ca, enum machine_mode mode,
|
| 3989 |
|
|
const_tree type, bool named)
|
| 3990 |
|
|
{
|
| 3991 |
|
|
return cris_function_arg_1 (ca, mode, type, named, true);
|
| 3992 |
|
|
}
|
| 3993 |
|
|
|
| 3994 |
|
|
/* Worker function for TARGET_FUNCTION_ARG_ADVANCE. */
|
| 3995 |
|
|
|
| 3996 |
|
|
static void
|
| 3997 |
|
|
cris_function_arg_advance (cumulative_args_t ca_v, enum machine_mode mode,
|
| 3998 |
|
|
const_tree type, bool named ATTRIBUTE_UNUSED)
|
| 3999 |
|
|
{
|
| 4000 |
|
|
CUMULATIVE_ARGS *ca = get_cumulative_args (ca_v);
|
| 4001 |
|
|
|
| 4002 |
|
|
ca->regs += (3 + CRIS_FUNCTION_ARG_SIZE (mode, type)) / 4;
|
| 4003 |
|
|
}
|
| 4004 |
|
|
|
| 4005 |
|
|
/* Worker function for TARGET_MD_ASM_CLOBBERS. */
|
| 4006 |
|
|
|
| 4007 |
|
|
static tree
|
| 4008 |
|
|
cris_md_asm_clobbers (tree outputs, tree inputs, tree in_clobbers)
|
| 4009 |
|
|
{
|
| 4010 |
|
|
HARD_REG_SET mof_set;
|
| 4011 |
|
|
tree clobbers;
|
| 4012 |
|
|
tree t;
|
| 4013 |
|
|
|
| 4014 |
|
|
CLEAR_HARD_REG_SET (mof_set);
|
| 4015 |
|
|
SET_HARD_REG_BIT (mof_set, CRIS_MOF_REGNUM);
|
| 4016 |
|
|
|
| 4017 |
|
|
/* For the time being, all asms clobber condition codes. Revisit when
|
| 4018 |
|
|
there's a reasonable use for inputs/outputs that mention condition
|
| 4019 |
|
|
codes. */
|
| 4020 |
|
|
clobbers
|
| 4021 |
|
|
= tree_cons (NULL_TREE,
|
| 4022 |
|
|
build_string (strlen (reg_names[CRIS_CC0_REGNUM]),
|
| 4023 |
|
|
reg_names[CRIS_CC0_REGNUM]),
|
| 4024 |
|
|
in_clobbers);
|
| 4025 |
|
|
|
| 4026 |
|
|
for (t = outputs; t != NULL; t = TREE_CHAIN (t))
|
| 4027 |
|
|
{
|
| 4028 |
|
|
tree val = TREE_VALUE (t);
|
| 4029 |
|
|
|
| 4030 |
|
|
/* The constraint letter for the singleton register class of MOF
|
| 4031 |
|
|
is 'h'. If it's mentioned in the constraints, the asm is
|
| 4032 |
|
|
MOF-aware and adding it to the clobbers would cause it to have
|
| 4033 |
|
|
impossible constraints. */
|
| 4034 |
|
|
if (strchr (TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t))),
|
| 4035 |
|
|
'h') != NULL
|
| 4036 |
|
|
|| tree_overlaps_hard_reg_set (val, &mof_set) != NULL_TREE)
|
| 4037 |
|
|
return clobbers;
|
| 4038 |
|
|
}
|
| 4039 |
|
|
|
| 4040 |
|
|
for (t = inputs; t != NULL; t = TREE_CHAIN (t))
|
| 4041 |
|
|
{
|
| 4042 |
|
|
tree val = TREE_VALUE (t);
|
| 4043 |
|
|
|
| 4044 |
|
|
if (strchr (TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t))),
|
| 4045 |
|
|
'h') != NULL
|
| 4046 |
|
|
|| tree_overlaps_hard_reg_set (val, &mof_set) != NULL_TREE)
|
| 4047 |
|
|
return clobbers;
|
| 4048 |
|
|
}
|
| 4049 |
|
|
|
| 4050 |
|
|
return tree_cons (NULL_TREE,
|
| 4051 |
|
|
build_string (strlen (reg_names[CRIS_MOF_REGNUM]),
|
| 4052 |
|
|
reg_names[CRIS_MOF_REGNUM]),
|
| 4053 |
|
|
clobbers);
|
| 4054 |
|
|
}
|
| 4055 |
|
|
|
| 4056 |
|
|
/* Implement TARGET_FRAME_POINTER_REQUIRED.
|
| 4057 |
|
|
|
| 4058 |
|
|
Really only needed if the stack frame has variable length (alloca
|
| 4059 |
|
|
or variable sized local arguments (GNU C extension). See PR39499 and
|
| 4060 |
|
|
PR38609 for the reason this isn't just 0. */
|
| 4061 |
|
|
|
| 4062 |
|
|
bool
|
| 4063 |
|
|
cris_frame_pointer_required (void)
|
| 4064 |
|
|
{
|
| 4065 |
|
|
return !current_function_sp_is_unchanging;
|
| 4066 |
|
|
}
|
| 4067 |
|
|
|
| 4068 |
|
|
/* Implement TARGET_ASM_TRAMPOLINE_TEMPLATE.
|
| 4069 |
|
|
|
| 4070 |
|
|
This looks too complicated, and it is. I assigned r7 to be the
|
| 4071 |
|
|
static chain register, but it is call-saved, so we have to save it,
|
| 4072 |
|
|
and come back to restore it after the call, so we have to save srp...
|
| 4073 |
|
|
Anyway, trampolines are rare enough that we can cope with this
|
| 4074 |
|
|
somewhat lack of elegance.
|
| 4075 |
|
|
(Do not be tempted to "straighten up" whitespace in the asms; the
|
| 4076 |
|
|
assembler #NO_APP state mandates strict spacing). */
|
| 4077 |
|
|
/* ??? See the i386 regparm=3 implementation that pushes the static
|
| 4078 |
|
|
chain value to the stack in the trampoline, and uses a call-saved
|
| 4079 |
|
|
register when called directly. */
|
| 4080 |
|
|
|
| 4081 |
|
|
static void
|
| 4082 |
|
|
cris_asm_trampoline_template (FILE *f)
|
| 4083 |
|
|
{
|
| 4084 |
|
|
if (TARGET_V32)
|
| 4085 |
|
|
{
|
| 4086 |
|
|
/* This normally-unused nop insn acts as an instruction to
|
| 4087 |
|
|
the simulator to flush its instruction cache. None of
|
| 4088 |
|
|
the other instructions in the trampoline template suits
|
| 4089 |
|
|
as a trigger for V32. The pc-relative addressing mode
|
| 4090 |
|
|
works nicely as a trigger for V10.
|
| 4091 |
|
|
FIXME: Have specific V32 template (possibly avoiding the
|
| 4092 |
|
|
use of a special instruction). */
|
| 4093 |
|
|
fprintf (f, "\tclearf x\n");
|
| 4094 |
|
|
/* We have to use a register as an intermediate, choosing
|
| 4095 |
|
|
semi-randomly R1 (which has to not be the STATIC_CHAIN_REGNUM),
|
| 4096 |
|
|
so we can use it for address indirection and jsr target. */
|
| 4097 |
|
|
fprintf (f, "\tmove $r1,$mof\n");
|
| 4098 |
|
|
/* +4 */
|
| 4099 |
|
|
fprintf (f, "\tmove.d 0,$r1\n");
|
| 4100 |
|
|
fprintf (f, "\tmove.d $%s,[$r1]\n", reg_names[STATIC_CHAIN_REGNUM]);
|
| 4101 |
|
|
fprintf (f, "\taddq 6,$r1\n");
|
| 4102 |
|
|
fprintf (f, "\tmove $mof,[$r1]\n");
|
| 4103 |
|
|
fprintf (f, "\taddq 6,$r1\n");
|
| 4104 |
|
|
fprintf (f, "\tmove $srp,[$r1]\n");
|
| 4105 |
|
|
/* +20 */
|
| 4106 |
|
|
fprintf (f, "\tmove.d 0,$%s\n", reg_names[STATIC_CHAIN_REGNUM]);
|
| 4107 |
|
|
/* +26 */
|
| 4108 |
|
|
fprintf (f, "\tmove.d 0,$r1\n");
|
| 4109 |
|
|
fprintf (f, "\tjsr $r1\n");
|
| 4110 |
|
|
fprintf (f, "\tsetf\n");
|
| 4111 |
|
|
/* +36 */
|
| 4112 |
|
|
fprintf (f, "\tmove.d 0,$%s\n", reg_names[STATIC_CHAIN_REGNUM]);
|
| 4113 |
|
|
/* +42 */
|
| 4114 |
|
|
fprintf (f, "\tmove.d 0,$r1\n");
|
| 4115 |
|
|
/* +48 */
|
| 4116 |
|
|
fprintf (f, "\tmove.d 0,$r9\n");
|
| 4117 |
|
|
fprintf (f, "\tjump $r9\n");
|
| 4118 |
|
|
fprintf (f, "\tsetf\n");
|
| 4119 |
|
|
}
|
| 4120 |
|
|
else
|
| 4121 |
|
|
{
|
| 4122 |
|
|
fprintf (f, "\tmove.d $%s,[$pc+20]\n", reg_names[STATIC_CHAIN_REGNUM]);
|
| 4123 |
|
|
fprintf (f, "\tmove $srp,[$pc+22]\n");
|
| 4124 |
|
|
fprintf (f, "\tmove.d 0,$%s\n", reg_names[STATIC_CHAIN_REGNUM]);
|
| 4125 |
|
|
fprintf (f, "\tjsr 0\n");
|
| 4126 |
|
|
fprintf (f, "\tmove.d 0,$%s\n", reg_names[STATIC_CHAIN_REGNUM]);
|
| 4127 |
|
|
fprintf (f, "\tjump 0\n");
|
| 4128 |
|
|
}
|
| 4129 |
|
|
}
|
| 4130 |
|
|
|
| 4131 |
|
|
/* Implement TARGET_TRAMPOLINE_INIT. */
|
| 4132 |
|
|
|
| 4133 |
|
|
static void
|
| 4134 |
|
|
cris_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
|
| 4135 |
|
|
{
|
| 4136 |
|
|
rtx fnaddr = XEXP (DECL_RTL (fndecl), 0);
|
| 4137 |
|
|
rtx tramp = XEXP (m_tramp, 0);
|
| 4138 |
|
|
rtx mem;
|
| 4139 |
|
|
|
| 4140 |
|
|
emit_block_move (m_tramp, assemble_trampoline_template (),
|
| 4141 |
|
|
GEN_INT (TRAMPOLINE_SIZE), BLOCK_OP_NORMAL);
|
| 4142 |
|
|
|
| 4143 |
|
|
if (TARGET_V32)
|
| 4144 |
|
|
{
|
| 4145 |
|
|
mem = adjust_address (m_tramp, SImode, 6);
|
| 4146 |
|
|
emit_move_insn (mem, plus_constant (tramp, 38));
|
| 4147 |
|
|
mem = adjust_address (m_tramp, SImode, 22);
|
| 4148 |
|
|
emit_move_insn (mem, chain_value);
|
| 4149 |
|
|
mem = adjust_address (m_tramp, SImode, 28);
|
| 4150 |
|
|
emit_move_insn (mem, fnaddr);
|
| 4151 |
|
|
}
|
| 4152 |
|
|
else
|
| 4153 |
|
|
{
|
| 4154 |
|
|
mem = adjust_address (m_tramp, SImode, 10);
|
| 4155 |
|
|
emit_move_insn (mem, chain_value);
|
| 4156 |
|
|
mem = adjust_address (m_tramp, SImode, 16);
|
| 4157 |
|
|
emit_move_insn (mem, fnaddr);
|
| 4158 |
|
|
}
|
| 4159 |
|
|
|
| 4160 |
|
|
/* Note that there is no need to do anything with the cache for
|
| 4161 |
|
|
sake of a trampoline. */
|
| 4162 |
|
|
}
|
| 4163 |
|
|
|
| 4164 |
|
|
|
| 4165 |
|
|
#if 0
|
| 4166 |
|
|
/* Various small functions to replace macros. Only called from a
|
| 4167 |
|
|
debugger. They might collide with gcc functions or system functions,
|
| 4168 |
|
|
so only emit them when '#if 1' above. */
|
| 4169 |
|
|
|
| 4170 |
|
|
enum rtx_code Get_code (rtx);
|
| 4171 |
|
|
|
| 4172 |
|
|
enum rtx_code
|
| 4173 |
|
|
Get_code (rtx x)
|
| 4174 |
|
|
{
|
| 4175 |
|
|
return GET_CODE (x);
|
| 4176 |
|
|
}
|
| 4177 |
|
|
|
| 4178 |
|
|
const char *Get_mode (rtx);
|
| 4179 |
|
|
|
| 4180 |
|
|
const char *
|
| 4181 |
|
|
Get_mode (rtx x)
|
| 4182 |
|
|
{
|
| 4183 |
|
|
return GET_MODE_NAME (GET_MODE (x));
|
| 4184 |
|
|
}
|
| 4185 |
|
|
|
| 4186 |
|
|
rtx Xexp (rtx, int);
|
| 4187 |
|
|
|
| 4188 |
|
|
rtx
|
| 4189 |
|
|
Xexp (rtx x, int n)
|
| 4190 |
|
|
{
|
| 4191 |
|
|
return XEXP (x, n);
|
| 4192 |
|
|
}
|
| 4193 |
|
|
|
| 4194 |
|
|
rtx Xvecexp (rtx, int, int);
|
| 4195 |
|
|
|
| 4196 |
|
|
rtx
|
| 4197 |
|
|
Xvecexp (rtx x, int n, int m)
|
| 4198 |
|
|
{
|
| 4199 |
|
|
return XVECEXP (x, n, m);
|
| 4200 |
|
|
}
|
| 4201 |
|
|
|
| 4202 |
|
|
int Get_rtx_len (rtx);
|
| 4203 |
|
|
|
| 4204 |
|
|
int
|
| 4205 |
|
|
Get_rtx_len (rtx x)
|
| 4206 |
|
|
{
|
| 4207 |
|
|
return GET_RTX_LENGTH (GET_CODE (x));
|
| 4208 |
|
|
}
|
| 4209 |
|
|
|
| 4210 |
|
|
/* Use upper-case to distinguish from local variables that are sometimes
|
| 4211 |
|
|
called next_insn and prev_insn. */
|
| 4212 |
|
|
|
| 4213 |
|
|
rtx Next_insn (rtx);
|
| 4214 |
|
|
|
| 4215 |
|
|
rtx
|
| 4216 |
|
|
Next_insn (rtx insn)
|
| 4217 |
|
|
{
|
| 4218 |
|
|
return NEXT_INSN (insn);
|
| 4219 |
|
|
}
|
| 4220 |
|
|
|
| 4221 |
|
|
rtx Prev_insn (rtx);
|
| 4222 |
|
|
|
| 4223 |
|
|
rtx
|
| 4224 |
|
|
Prev_insn (rtx insn)
|
| 4225 |
|
|
{
|
| 4226 |
|
|
return PREV_INSN (insn);
|
| 4227 |
|
|
}
|
| 4228 |
|
|
#endif
|
| 4229 |
|
|
|
| 4230 |
|
|
#include "gt-cris.h"
|
| 4231 |
|
|
|
| 4232 |
|
|
/*
|
| 4233 |
|
|
* Local variables:
|
| 4234 |
|
|
* eval: (c-set-style "gnu")
|
| 4235 |
|
|
* indent-tabs-mode: t
|
| 4236 |
|
|
* End:
|
| 4237 |
|
|
*/
|