| 1 |
282 |
jeremybenn |
/* Subroutines for insn-output.c for GNU compiler. OpenRISC 1000 version.
|
| 2 |
|
|
Copyright (C) 1987, 1992, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
|
| 3 |
|
|
2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc
|
| 4 |
|
|
Copyright (C) 2010 Embecosm Limited
|
| 5 |
|
|
|
| 6 |
|
|
Contributed by Damjan Lampret <damjanl@bsemi.com> in 1999.
|
| 7 |
|
|
Major optimizations by Matjaz Breskvar <matjazb@bsemi.com> in 2005.
|
| 8 |
|
|
Updated for GCC 4.5 by Jeremy Bennett <jeremy.bennett@embecoms.com> in 2010
|
| 9 |
|
|
|
| 10 |
|
|
This file is part of GNU CC.
|
| 11 |
|
|
|
| 12 |
|
|
This program is free software; you can redistribute it and/or modify it
|
| 13 |
|
|
under the terms of the GNU General Public License as published by the Free
|
| 14 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
| 15 |
|
|
any later version.
|
| 16 |
|
|
|
| 17 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
| 18 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 19 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
| 20 |
|
|
more details.
|
| 21 |
|
|
|
| 22 |
|
|
You should have received a copy of the GNU General Public License along
|
| 23 |
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
| 24 |
|
|
|
| 25 |
|
|
#include "config.h"
|
| 26 |
|
|
#include "system.h"
|
| 27 |
|
|
#include "coretypes.h"
|
| 28 |
|
|
#include "tm.h"
|
| 29 |
|
|
#include "rtl.h"
|
| 30 |
|
|
#include "tree.h"
|
| 31 |
|
|
#include "obstack.h"
|
| 32 |
|
|
#include "regs.h"
|
| 33 |
|
|
#include "hard-reg-set.h"
|
| 34 |
|
|
#include "real.h"
|
| 35 |
|
|
#include "insn-config.h"
|
| 36 |
|
|
#include "conditions.h"
|
| 37 |
|
|
#include "output.h"
|
| 38 |
|
|
#include "insn-attr.h"
|
| 39 |
|
|
#include "flags.h"
|
| 40 |
|
|
#include "reload.h"
|
| 41 |
|
|
#include "function.h"
|
| 42 |
|
|
#include "expr.h"
|
| 43 |
|
|
#include "toplev.h"
|
| 44 |
|
|
#include "recog.h"
|
| 45 |
|
|
#include "ggc.h"
|
| 46 |
|
|
#include "except.h"
|
| 47 |
|
|
#include "integrate.h"
|
| 48 |
|
|
#include "tm_p.h"
|
| 49 |
|
|
#include "target.h"
|
| 50 |
|
|
#include "target-def.h"
|
| 51 |
|
|
#include "debug.h"
|
| 52 |
|
|
#include "langhooks.h"
|
| 53 |
|
|
#include "df.h"
|
| 54 |
|
|
#include "dwarf2.h"
|
| 55 |
|
|
|
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
|
|
/* ========================================================================== */
|
| 59 |
|
|
/* Static variables (i.e. global to this file only. */
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
/* Save information from a "cmpxx" pattern until the branch or scc is
|
| 63 |
|
|
emitted. These record the two operands of the "cmpxx" */
|
| 64 |
|
|
rtx or32_compare_op0;
|
| 65 |
|
|
rtx or32_compare_op1;
|
| 66 |
|
|
|
| 67 |
|
|
/*!Stack layout we use for pushing and poping saved registers */
|
| 68 |
|
|
static struct
|
| 69 |
|
|
{
|
| 70 |
|
|
bool save_lr_p;
|
| 71 |
|
|
int lr_save_offset;
|
| 72 |
|
|
bool save_fp_p;
|
| 73 |
|
|
int fp_save_offset;
|
| 74 |
|
|
int gpr_size;
|
| 75 |
|
|
int gpr_offset;
|
| 76 |
|
|
int total_size;
|
| 77 |
|
|
int vars_size;
|
| 78 |
|
|
int args_size;
|
| 79 |
|
|
HOST_WIDE_INT mask;
|
| 80 |
|
|
} frame_info;
|
| 81 |
|
|
|
| 82 |
|
|
|
| 83 |
|
|
/* ========================================================================== */
|
| 84 |
|
|
/* Local (i.e. static) utility functions */
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
/* -------------------------------------------------------------------------- */
|
| 88 |
|
|
/*!Must the current function save a register?
|
| 89 |
|
|
|
| 90 |
|
|
@param[in] regno The register to consider.
|
| 91 |
|
|
|
| 92 |
|
|
@return Non-zero (TRUE) if current function must save "regno", zero
|
| 93 |
|
|
(FALSE) otherwise. */
|
| 94 |
|
|
/* -------------------------------------------------------------------------- */
|
| 95 |
|
|
static bool
|
| 96 |
|
|
or32_save_reg_p (int regno)
|
| 97 |
|
|
{
|
| 98 |
|
|
/* No need to save the faked cc0 register. */
|
| 99 |
|
|
if (regno == OR32_FLAGS_REG)
|
| 100 |
|
|
return false;
|
| 101 |
|
|
|
| 102 |
|
|
/* Check call-saved registers. */
|
| 103 |
|
|
if (df_regs_ever_live_p(regno) && !call_used_regs[regno])
|
| 104 |
|
|
return true;
|
| 105 |
|
|
|
| 106 |
|
|
/* We need to save the old frame pointer before setting up a new
|
| 107 |
|
|
one. */
|
| 108 |
|
|
if (regno == FRAME_POINTER_REGNUM && frame_pointer_needed)
|
| 109 |
|
|
return true;
|
| 110 |
|
|
|
| 111 |
|
|
/* We need to save the incoming return address if it is ever clobbered
|
| 112 |
|
|
within the function. */
|
| 113 |
|
|
if (regno == LINK_REGNUM && df_regs_ever_live_p(regno))
|
| 114 |
|
|
return true;
|
| 115 |
|
|
|
| 116 |
|
|
return false;
|
| 117 |
|
|
|
| 118 |
|
|
} /* or32_save_reg_p () */
|
| 119 |
|
|
|
| 120 |
|
|
|
| 121 |
|
|
/* -------------------------------------------------------------------------- */
|
| 122 |
|
|
/*!Compute full frame size and layout.
|
| 123 |
|
|
|
| 124 |
|
|
Store information in "frame_info".
|
| 125 |
|
|
|
| 126 |
|
|
@param[in] size The size of the function's local variables.
|
| 127 |
|
|
|
| 128 |
|
|
@return Total size of stack frame. */
|
| 129 |
|
|
/* -------------------------------------------------------------------------- */
|
| 130 |
|
|
static HOST_WIDE_INT
|
| 131 |
|
|
or32_compute_frame_size (HOST_WIDE_INT size)
|
| 132 |
|
|
{
|
| 133 |
|
|
HOST_WIDE_INT args_size;
|
| 134 |
|
|
HOST_WIDE_INT vars_size;
|
| 135 |
|
|
HOST_WIDE_INT stack_offset;
|
| 136 |
|
|
|
| 137 |
|
|
int regno;
|
| 138 |
|
|
|
| 139 |
|
|
args_size = crtl->outgoing_args_size;
|
| 140 |
|
|
vars_size = OR32_ALIGN (size, 4);
|
| 141 |
|
|
|
| 142 |
|
|
frame_info.args_size = args_size;
|
| 143 |
|
|
frame_info.vars_size = vars_size;
|
| 144 |
|
|
|
| 145 |
|
|
/* If the function has local variables, we're committed to
|
| 146 |
|
|
allocating it anyway. Otherwise reclaim it here. */
|
| 147 |
|
|
/* FIXME: Verify this. Got if from the MIPS port. */
|
| 148 |
|
|
if (vars_size == 0 && current_function_is_leaf)
|
| 149 |
|
|
args_size = 0;
|
| 150 |
|
|
|
| 151 |
|
|
stack_offset = args_size;
|
| 152 |
|
|
|
| 153 |
|
|
/* Save link register right after possible outgoing arguments. */
|
| 154 |
|
|
if (or32_save_reg_p (LINK_REGNUM))
|
| 155 |
|
|
{
|
| 156 |
|
|
frame_info.lr_save_offset = stack_offset;
|
| 157 |
|
|
frame_info.save_lr_p = true;
|
| 158 |
|
|
stack_offset = stack_offset + UNITS_PER_WORD;
|
| 159 |
|
|
}
|
| 160 |
|
|
else
|
| 161 |
|
|
frame_info.save_lr_p = false;
|
| 162 |
|
|
|
| 163 |
|
|
/* Save frame pointer right after possible link register. */
|
| 164 |
|
|
if (or32_save_reg_p (FRAME_POINTER_REGNUM))
|
| 165 |
|
|
{
|
| 166 |
|
|
frame_info.fp_save_offset = stack_offset;
|
| 167 |
|
|
frame_info.save_fp_p = true;
|
| 168 |
|
|
stack_offset = stack_offset + UNITS_PER_WORD;
|
| 169 |
|
|
}
|
| 170 |
|
|
else
|
| 171 |
|
|
frame_info.save_fp_p = false;
|
| 172 |
|
|
|
| 173 |
|
|
frame_info.gpr_size = 0;
|
| 174 |
|
|
frame_info.mask = 0;
|
| 175 |
|
|
frame_info.gpr_offset = stack_offset;
|
| 176 |
|
|
|
| 177 |
|
|
for (regno = 0; regno <= OR32_LAST_INT_REG; regno++)
|
| 178 |
|
|
{
|
| 179 |
|
|
if (regno == LINK_REGNUM || regno == FRAME_POINTER_REGNUM)
|
| 180 |
|
|
/* These have already been saved if so needed. */
|
| 181 |
|
|
continue;
|
| 182 |
|
|
|
| 183 |
|
|
if (or32_save_reg_p (regno))
|
| 184 |
|
|
{
|
| 185 |
|
|
frame_info.gpr_size += UNITS_PER_WORD;
|
| 186 |
|
|
frame_info.mask |= (1 << regno);
|
| 187 |
|
|
}
|
| 188 |
|
|
}
|
| 189 |
|
|
|
| 190 |
|
|
frame_info.total_size = ((frame_info.save_fp_p ? UNITS_PER_WORD : 0)
|
| 191 |
|
|
+ (frame_info.save_lr_p ? UNITS_PER_WORD : 0)
|
| 192 |
|
|
+ args_size + frame_info.gpr_size + vars_size);
|
| 193 |
|
|
|
| 194 |
|
|
return frame_info.total_size;
|
| 195 |
|
|
|
| 196 |
|
|
} /* or32_compute_frame_size () */
|
| 197 |
|
|
|
| 198 |
|
|
|
| 199 |
|
|
/* -------------------------------------------------------------------------- */
|
| 200 |
|
|
/*!Emit a frame related insn.
|
| 201 |
|
|
|
| 202 |
|
|
Same as emit_insn, but sets RTX_FRAME_RELATED_P to one. Getting this right
|
| 203 |
|
|
will matter for DWARF 2 output, if prologues are handled via the "prologue"
|
| 204 |
|
|
pattern rather than target hooks.
|
| 205 |
|
|
|
| 206 |
|
|
@param[in] insn The insn to emit.
|
| 207 |
|
|
|
| 208 |
|
|
@return The RTX for the emitted insn. */
|
| 209 |
|
|
/* -------------------------------------------------------------------------- */
|
| 210 |
|
|
static rtx
|
| 211 |
|
|
emit_frame_insn (rtx insn)
|
| 212 |
|
|
{
|
| 213 |
|
|
insn = emit_insn (insn);
|
| 214 |
|
|
RTX_FRAME_RELATED_P (insn) = 1;
|
| 215 |
|
|
return (insn);
|
| 216 |
|
|
|
| 217 |
|
|
} /* emit_frame_insn () */
|
| 218 |
|
|
|
| 219 |
|
|
|
| 220 |
|
|
/* -------------------------------------------------------------------------- */
|
| 221 |
|
|
/*!Generate the RTX for an indexed memory access
|
| 222 |
|
|
|
| 223 |
|
|
Generate a RTX for the indexed memory address based on a base address and a
|
| 224 |
|
|
displacement
|
| 225 |
|
|
|
| 226 |
|
|
@param[in] base The base address RTX
|
| 227 |
|
|
@param[in] disp The displacement
|
| 228 |
|
|
|
| 229 |
|
|
@return The RTX for the generated address. */
|
| 230 |
|
|
/* -------------------------------------------------------------------------- */
|
| 231 |
|
|
static rtx
|
| 232 |
|
|
indexed_memory (rtx base,
|
| 233 |
|
|
HOST_WIDE_INT disp)
|
| 234 |
|
|
{
|
| 235 |
|
|
return gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, base, GEN_INT (disp)));
|
| 236 |
|
|
|
| 237 |
|
|
} /* indexed_memory () */
|
| 238 |
|
|
|
| 239 |
|
|
|
| 240 |
|
|
/* -------------------------------------------------------------------------- */
|
| 241 |
|
|
/*!Generate insn patterns to do an integer compare of operands.
|
| 242 |
|
|
|
| 243 |
|
|
@param[in] code RTX for the condition code.
|
| 244 |
|
|
@param[in] op0 RTX for the first operand.
|
| 245 |
|
|
@param[in] op1 RTX for the second operand.
|
| 246 |
|
|
|
| 247 |
|
|
@return RTX for the comparison. */
|
| 248 |
|
|
/* -------------------------------------------------------------------------- */
|
| 249 |
|
|
static rtx
|
| 250 |
|
|
or32_expand_int_compare (enum rtx_code code,
|
| 251 |
|
|
rtx op0,
|
| 252 |
|
|
rtx op1)
|
| 253 |
|
|
{
|
| 254 |
|
|
enum machine_mode cmpmode;
|
| 255 |
|
|
rtx tmp, flags;
|
| 256 |
|
|
|
| 257 |
|
|
cmpmode = SELECT_CC_MODE (code, op0, op1);
|
| 258 |
|
|
flags = gen_rtx_REG (cmpmode, OR32_FLAGS_REG);
|
| 259 |
|
|
|
| 260 |
|
|
/* This is very simple, but making the interface the same as in the
|
| 261 |
|
|
FP case makes the rest of the code easier. */
|
| 262 |
|
|
tmp = gen_rtx_COMPARE (cmpmode, op0, op1);
|
| 263 |
|
|
emit_insn (gen_rtx_SET (VOIDmode, flags, tmp));
|
| 264 |
|
|
|
| 265 |
|
|
/* Return the test that should be put into the flags user, i.e.
|
| 266 |
|
|
the bcc, scc, or cmov instruction. */
|
| 267 |
|
|
return gen_rtx_fmt_ee (code, VOIDmode, flags, const0_rtx);
|
| 268 |
|
|
|
| 269 |
|
|
} /* or32_expand_int_compare () */
|
| 270 |
|
|
|
| 271 |
|
|
|
| 272 |
|
|
/* -------------------------------------------------------------------------- */
|
| 273 |
|
|
/*!Generate insn patterns to do an integer compare of operands.
|
| 274 |
|
|
|
| 275 |
|
|
We only deal with the case where the comparison is an integer
|
| 276 |
|
|
comparison. This wrapper function potentially allows reuse for non-integer
|
| 277 |
|
|
comparison in the future.
|
| 278 |
|
|
|
| 279 |
|
|
@param[in] code RTX for the condition code.
|
| 280 |
|
|
@param[in] op0 RTX for the first operand.
|
| 281 |
|
|
@param[in] op1 RTX for the second operand.
|
| 282 |
|
|
|
| 283 |
|
|
@return RTX for the comparison. */
|
| 284 |
|
|
/* -------------------------------------------------------------------------- */
|
| 285 |
|
|
static rtx
|
| 286 |
|
|
or32_expand_compare (enum rtx_code code, rtx op0, rtx op1)
|
| 287 |
|
|
{
|
| 288 |
|
|
return or32_expand_int_compare (code, op0, op1);
|
| 289 |
|
|
|
| 290 |
|
|
} /* or32_expand_compare () */
|
| 291 |
|
|
|
| 292 |
|
|
|
| 293 |
|
|
/* -------------------------------------------------------------------------- */
|
| 294 |
|
|
/*!Emit insns to use the l.cmov instruction
|
| 295 |
|
|
|
| 296 |
|
|
Emit a compare and then cmov. Only works for integer first operand.
|
| 297 |
|
|
|
| 298 |
|
|
@param[in] dest RTX for the destination operand.
|
| 299 |
|
|
@param[in] op RTX for the comparison operation
|
| 300 |
|
|
@param[in] true_cond RTX to move to dest if condition is TRUE.
|
| 301 |
|
|
@param[in] false_cond RTX to move to dest if condition is FALSE.
|
| 302 |
|
|
|
| 303 |
|
|
@return Non-zero (TRUE) if insns were emitted, zero (FALSE) otherwise. */
|
| 304 |
|
|
/* -------------------------------------------------------------------------- */
|
| 305 |
|
|
static int
|
| 306 |
|
|
or32_emit_int_cmove (rtx dest,
|
| 307 |
|
|
rtx op,
|
| 308 |
|
|
rtx true_cond,
|
| 309 |
|
|
rtx false_cond)
|
| 310 |
|
|
{
|
| 311 |
|
|
rtx condition_rtx, cr;
|
| 312 |
|
|
|
| 313 |
|
|
if ((GET_MODE (or32_compare_op0) != SImode) &&
|
| 314 |
|
|
(GET_MODE (or32_compare_op0) != HImode) &&
|
| 315 |
|
|
(GET_MODE (or32_compare_op0) != QImode))
|
| 316 |
|
|
{
|
| 317 |
|
|
return 0;
|
| 318 |
|
|
}
|
| 319 |
|
|
|
| 320 |
|
|
/* We still have to do the compare, because cmov doesn't do a compare, it
|
| 321 |
|
|
just looks at the FLAG bit set by a previous compare instruction. */
|
| 322 |
|
|
condition_rtx = or32_expand_compare (GET_CODE (op),
|
| 323 |
|
|
or32_compare_op0, or32_compare_op1);
|
| 324 |
|
|
|
| 325 |
|
|
cr = XEXP (condition_rtx, 0);
|
| 326 |
|
|
|
| 327 |
|
|
emit_insn (gen_cmov (dest, condition_rtx, true_cond, false_cond, cr));
|
| 328 |
|
|
|
| 329 |
|
|
return 1;
|
| 330 |
|
|
|
| 331 |
|
|
} /* or32_emit_int_cmove () */
|
| 332 |
|
|
|
| 333 |
|
|
|
| 334 |
|
|
/* -------------------------------------------------------------------------- */
|
| 335 |
|
|
/*!Calculate stack size for current function.
|
| 336 |
|
|
|
| 337 |
|
|
We need space for:
|
| 338 |
|
|
- any callee-saved registers that are live in the function
|
| 339 |
|
|
- any local variables
|
| 340 |
|
|
- the return address (if saved)
|
| 341 |
|
|
- the frame pointer (if saved)
|
| 342 |
|
|
- any outgoing arguments.
|
| 343 |
|
|
|
| 344 |
|
|
We also return information on whether the return address and frame pointer
|
| 345 |
|
|
must be saved, the space required to save callee-saved registers and the
|
| 346 |
|
|
sapce required to save the return address, frame pointer and outgoing
|
| 347 |
|
|
arguments.
|
| 348 |
|
|
|
| 349 |
|
|
Throughout adjust for OR32 alignment requirements.
|
| 350 |
|
|
|
| 351 |
|
|
@param[in] vars Bytes required for local variables (if any).
|
| 352 |
|
|
@param[out] lr_save_area Space required for return address (if any).
|
| 353 |
|
|
@param[out] fp_save_area Space required for frame pointer (if any).
|
| 354 |
|
|
@param[out] gpr_save_area Space required for callee-saved registers (if
|
| 355 |
|
|
any).
|
| 356 |
|
|
@param[out] save_area Space required for outgoing arguments (if any) +
|
| 357 |
|
|
return address (if any) and frame pointer (if
|
| 358 |
|
|
any).
|
| 359 |
|
|
|
| 360 |
|
|
@return Total space required (if any). */
|
| 361 |
|
|
/* -------------------------------------------------------------------------- */
|
| 362 |
|
|
static int
|
| 363 |
|
|
calculate_stack_size (int vars,
|
| 364 |
|
|
int *lr_save_area,
|
| 365 |
|
|
int *fp_save_area,
|
| 366 |
|
|
int *gpr_save_area,
|
| 367 |
|
|
int *save_area)
|
| 368 |
|
|
{
|
| 369 |
|
|
int regno;
|
| 370 |
|
|
|
| 371 |
|
|
*gpr_save_area = 0;
|
| 372 |
|
|
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
|
| 373 |
|
|
{
|
| 374 |
|
|
if (df_regs_ever_live_p(regno) && !call_used_regs[regno])
|
| 375 |
|
|
*gpr_save_area += 4;
|
| 376 |
|
|
}
|
| 377 |
|
|
|
| 378 |
|
|
*lr_save_area = (!current_function_is_leaf
|
| 379 |
|
|
|| df_regs_ever_live_p(LINK_REGNUM)) ? 4 : 0;
|
| 380 |
|
|
*fp_save_area = frame_pointer_needed ? 4 : 0;
|
| 381 |
|
|
*save_area = (OR32_ALIGN (crtl->outgoing_args_size, 4)
|
| 382 |
|
|
+ *lr_save_area + *fp_save_area);
|
| 383 |
|
|
|
| 384 |
|
|
return *save_area + *gpr_save_area + OR32_ALIGN (vars, 4);
|
| 385 |
|
|
|
| 386 |
|
|
} /* calculate_stack_size () */
|
| 387 |
|
|
|
| 388 |
|
|
|
| 389 |
|
|
/* -------------------------------------------------------------------------- */
|
| 390 |
|
|
/*!Is this a value suitable for an OR32 address displacement?
|
| 391 |
|
|
|
| 392 |
|
|
Must be an integer (signed) which fits into 16-bits. If the result is a
|
| 393 |
|
|
double word, we had better also check that we can also get at the second
|
| 394 |
|
|
word.
|
| 395 |
|
|
|
| 396 |
|
|
@param[in] mode Mode of the result for which this displacement will be
|
| 397 |
|
|
used.
|
| 398 |
|
|
@param[in] x RTX for an expression.
|
| 399 |
|
|
|
| 400 |
|
|
@return Non-zero (TRUE) if this is a valid 16-bit offset, zero (FALSE)
|
| 401 |
|
|
otherwise. */
|
| 402 |
|
|
/* -------------------------------------------------------------------------- */
|
| 403 |
|
|
static int
|
| 404 |
|
|
or32_legitimate_displacement_p (enum machine_mode mode,
|
| 405 |
|
|
rtx x)
|
| 406 |
|
|
{
|
| 407 |
|
|
if (CONST_INT == GET_CODE(x))
|
| 408 |
|
|
{
|
| 409 |
|
|
HOST_WIDE_INT disp = INTVAL (x);
|
| 410 |
|
|
|
| 411 |
|
|
/* Allow for a second access 4 bytes further on if double. */
|
| 412 |
|
|
if ((DFmode == mode) || (DImode == mode))
|
| 413 |
|
|
{
|
| 414 |
|
|
return (-32768 < disp) && (disp <= 32763);
|
| 415 |
|
|
}
|
| 416 |
|
|
else
|
| 417 |
|
|
{
|
| 418 |
|
|
return (-32768 < disp) && (disp <= 32767);
|
| 419 |
|
|
}
|
| 420 |
|
|
}
|
| 421 |
|
|
else
|
| 422 |
|
|
{
|
| 423 |
|
|
return 0;
|
| 424 |
|
|
}
|
| 425 |
|
|
} /* or32_legitimate_displacement_p () */
|
| 426 |
|
|
|
| 427 |
|
|
|
| 428 |
|
|
/* -------------------------------------------------------------------------- */
|
| 429 |
|
|
/*!Can this register be used as a base register?
|
| 430 |
|
|
|
| 431 |
|
|
We need a strict version, for which the register must either be a hard
|
| 432 |
|
|
register, or already renumbered to a hard register.
|
| 433 |
|
|
|
| 434 |
|
|
For the non-strict version, any register (other than the flag register will
|
| 435 |
|
|
do).
|
| 436 |
|
|
|
| 437 |
|
|
@todo The code from the old port does not allow r0 as a base when strict,
|
| 438 |
|
|
and does when non-strict. Surely it is always a valid register?
|
| 439 |
|
|
|
| 440 |
|
|
@param[in] regno The register to test
|
| 441 |
|
|
@param[in] strict Non-zero (TRUE) if this is a strict check, zero (FALSE)
|
| 442 |
|
|
otherwise.
|
| 443 |
|
|
|
| 444 |
|
|
@return Non-zero (TRUE) if this register can be used as a base register,
|
| 445 |
|
|
zero (FALSE) otherwise. */
|
| 446 |
|
|
/* -------------------------------------------------------------------------- */
|
| 447 |
|
|
static bool
|
| 448 |
|
|
or32_regnum_ok_for_base_p (HOST_WIDE_INT num,
|
| 449 |
|
|
bool strict)
|
| 450 |
|
|
{
|
| 451 |
|
|
if (strict)
|
| 452 |
|
|
{
|
| 453 |
|
|
return (num < FIRST_PSEUDO_REGISTER)
|
| 454 |
|
|
? (num > 0) && (num <= OR32_LAST_INT_REG)
|
| 455 |
|
|
: (reg_renumber[num] > 0) && (reg_renumber[num] <= OR32_LAST_INT_REG);
|
| 456 |
|
|
}
|
| 457 |
|
|
else
|
| 458 |
|
|
{
|
| 459 |
|
|
return (num <= OR32_LAST_INT_REG) || (num >= FIRST_PSEUDO_REGISTER);
|
| 460 |
|
|
}
|
| 461 |
|
|
} /* or32_regnum_ok_for_base_p () */
|
| 462 |
|
|
|
| 463 |
|
|
|
| 464 |
|
|
/* ========================================================================== */
|
| 465 |
|
|
/* Functions to support the Machine Description */
|
| 466 |
|
|
|
| 467 |
|
|
|
| 468 |
|
|
/* -------------------------------------------------------------------------- */
|
| 469 |
|
|
/*!Expand a prologue pattern.
|
| 470 |
|
|
|
| 471 |
|
|
Called after register allocation to add any instructions needed for the
|
| 472 |
|
|
prologue. Using a prologue insn is favored compared to putting all of the
|
| 473 |
|
|
instructions in output_function_prologue(), since it allows the scheduler
|
| 474 |
|
|
to intermix instructions with the saves of the caller saved registers. In
|
| 475 |
|
|
some cases, it might be necessary to emit a barrier instruction as the last
|
| 476 |
|
|
insn to prevent such scheduling.
|
| 477 |
|
|
|
| 478 |
|
|
For the OR32 this is currently controlled by the -mlogue option. It should
|
| 479 |
|
|
be the default, once it is proved to work. */
|
| 480 |
|
|
/* -------------------------------------------------------------------------- */
|
| 481 |
|
|
void
|
| 482 |
|
|
or32_expand_prologue (void)
|
| 483 |
|
|
{
|
| 484 |
|
|
int total_size = or32_compute_frame_size (get_frame_size ());
|
| 485 |
|
|
rtx sp_rtx;
|
| 486 |
|
|
rtx value_rtx;
|
| 487 |
|
|
|
| 488 |
|
|
if (!total_size)
|
| 489 |
|
|
/* No frame needed. */
|
| 490 |
|
|
return;
|
| 491 |
|
|
|
| 492 |
|
|
sp_rtx = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
|
| 493 |
|
|
|
| 494 |
|
|
if (total_size > 32767)
|
| 495 |
|
|
{
|
| 496 |
|
|
value_rtx = gen_rtx_REG (Pmode, GP_ARG_RETURN);
|
| 497 |
|
|
emit_frame_insn (gen_rtx_SET (Pmode, value_rtx, GEN_INT (total_size)));
|
| 498 |
|
|
}
|
| 499 |
|
|
else
|
| 500 |
|
|
value_rtx = GEN_INT (total_size);
|
| 501 |
|
|
|
| 502 |
|
|
/* Update the stack pointer to reflect frame size. */
|
| 503 |
|
|
emit_frame_insn
|
| 504 |
|
|
(gen_rtx_SET (Pmode, stack_pointer_rtx,
|
| 505 |
|
|
gen_rtx_MINUS (Pmode, stack_pointer_rtx, value_rtx)));
|
| 506 |
|
|
|
| 507 |
|
|
if (frame_info.save_fp_p)
|
| 508 |
|
|
{
|
| 509 |
|
|
emit_frame_insn
|
| 510 |
|
|
(gen_rtx_SET (Pmode,
|
| 511 |
|
|
indexed_memory (stack_pointer_rtx,
|
| 512 |
|
|
frame_info.fp_save_offset),
|
| 513 |
|
|
frame_pointer_rtx));
|
| 514 |
|
|
|
| 515 |
|
|
emit_frame_insn
|
| 516 |
|
|
(gen_rtx_SET (Pmode, frame_pointer_rtx,
|
| 517 |
|
|
gen_rtx_PLUS (Pmode, frame_pointer_rtx, value_rtx)));
|
| 518 |
|
|
}
|
| 519 |
|
|
if (frame_info.save_lr_p)
|
| 520 |
|
|
{
|
| 521 |
|
|
|
| 522 |
|
|
emit_frame_insn
|
| 523 |
|
|
(gen_rtx_SET (Pmode,
|
| 524 |
|
|
indexed_memory (stack_pointer_rtx,
|
| 525 |
|
|
frame_info.lr_save_offset),
|
| 526 |
|
|
gen_rtx_REG (Pmode, LINK_REGNUM)));
|
| 527 |
|
|
}
|
| 528 |
|
|
if (frame_info.gpr_size)
|
| 529 |
|
|
{
|
| 530 |
|
|
int offset = 0;
|
| 531 |
|
|
int regno;
|
| 532 |
|
|
|
| 533 |
|
|
for (regno = 0; regno <= OR32_LAST_INT_REG; regno++)
|
| 534 |
|
|
{
|
| 535 |
|
|
HOST_WIDE_INT disp = frame_info.gpr_offset + offset;
|
| 536 |
|
|
|
| 537 |
|
|
if (!(frame_info.mask & (1 << regno)))
|
| 538 |
|
|
continue;
|
| 539 |
|
|
|
| 540 |
|
|
emit_frame_insn
|
| 541 |
|
|
(gen_rtx_SET (Pmode,
|
| 542 |
|
|
indexed_memory (stack_pointer_rtx, disp),
|
| 543 |
|
|
gen_rtx_REG (Pmode, regno)));
|
| 544 |
|
|
offset = offset + UNITS_PER_WORD;
|
| 545 |
|
|
}
|
| 546 |
|
|
}
|
| 547 |
|
|
} /* or32_expand_prologue () */
|
| 548 |
|
|
|
| 549 |
|
|
|
| 550 |
|
|
/* -------------------------------------------------------------------------- */
|
| 551 |
|
|
/*!Expand an epilogue pattern.
|
| 552 |
|
|
|
| 553 |
|
|
Called after register allocation to add any instructions needed for the
|
| 554 |
|
|
epilogue. Using an epilogue insn is favored compared to putting all of the
|
| 555 |
|
|
instructions in output_function_epilogue(), since it allows the scheduler
|
| 556 |
|
|
to intermix instructions with the restores of the caller saved registers.
|
| 557 |
|
|
In some cases, it might be necessary to emit a barrier instruction as the
|
| 558 |
|
|
first insn to prevent such scheduling.
|
| 559 |
|
|
|
| 560 |
|
|
For the OR32 this is currently controlled by the -mlogue option. It should
|
| 561 |
|
|
be the default, once it is proved to work.
|
| 562 |
|
|
|
| 563 |
|
|
@param[in] sibcall Non-zero (TRUE) if this is a sibcall return, which can
|
| 564 |
|
|
benefit from tail call optimization. Zero (FALSE)
|
| 565 |
|
|
otherwise. */
|
| 566 |
|
|
/* -------------------------------------------------------------------------- */
|
| 567 |
|
|
void
|
| 568 |
|
|
or32_expand_epilogue (int sibcall)
|
| 569 |
|
|
{
|
| 570 |
|
|
int total_size = or32_compute_frame_size (get_frame_size ());
|
| 571 |
|
|
rtx value_rtx;
|
| 572 |
|
|
|
| 573 |
|
|
if (total_size > 32767)
|
| 574 |
|
|
{
|
| 575 |
|
|
value_rtx = gen_rtx_REG (Pmode, 3);
|
| 576 |
|
|
|
| 577 |
|
|
emit_insn (gen_rtx_SET (Pmode, value_rtx, GEN_INT (total_size)));
|
| 578 |
|
|
}
|
| 579 |
|
|
else
|
| 580 |
|
|
value_rtx = GEN_INT (total_size);
|
| 581 |
|
|
|
| 582 |
|
|
if (frame_info.save_lr_p)
|
| 583 |
|
|
{
|
| 584 |
|
|
emit_insn
|
| 585 |
|
|
(gen_rtx_SET (Pmode, gen_rtx_REG (Pmode, LINK_REGNUM),
|
| 586 |
|
|
indexed_memory (stack_pointer_rtx,
|
| 587 |
|
|
frame_info.lr_save_offset)));
|
| 588 |
|
|
}
|
| 589 |
|
|
if (frame_info.save_fp_p)
|
| 590 |
|
|
{
|
| 591 |
|
|
emit_insn
|
| 592 |
|
|
(gen_rtx_SET (Pmode, gen_rtx_REG (Pmode, FRAME_POINTER_REGNUM),
|
| 593 |
|
|
indexed_memory (stack_pointer_rtx,
|
| 594 |
|
|
frame_info.fp_save_offset)));
|
| 595 |
|
|
}
|
| 596 |
|
|
|
| 597 |
|
|
if (frame_info.gpr_size)
|
| 598 |
|
|
{
|
| 599 |
|
|
int offset = 0;
|
| 600 |
|
|
int regno;
|
| 601 |
|
|
|
| 602 |
|
|
for (regno = 0; regno <= OR32_LAST_INT_REG; regno++)
|
| 603 |
|
|
{
|
| 604 |
|
|
HOST_WIDE_INT disp = frame_info.gpr_offset + offset;
|
| 605 |
|
|
|
| 606 |
|
|
if (!(frame_info.mask & (1 << regno)))
|
| 607 |
|
|
continue;
|
| 608 |
|
|
|
| 609 |
|
|
emit_insn
|
| 610 |
|
|
(gen_rtx_SET (Pmode, gen_rtx_REG (Pmode, regno),
|
| 611 |
|
|
indexed_memory (stack_pointer_rtx, disp)));
|
| 612 |
|
|
offset = offset + UNITS_PER_WORD;
|
| 613 |
|
|
}
|
| 614 |
|
|
}
|
| 615 |
|
|
|
| 616 |
|
|
if (total_size)
|
| 617 |
|
|
{
|
| 618 |
|
|
emit_insn (gen_rtx_SET (Pmode, stack_pointer_rtx,
|
| 619 |
|
|
gen_rtx_PLUS (Pmode,
|
| 620 |
|
|
stack_pointer_rtx, value_rtx)));
|
| 621 |
|
|
}
|
| 622 |
|
|
|
| 623 |
|
|
if (!sibcall)
|
| 624 |
|
|
emit_jump_insn (gen_return_internal (gen_rtx_REG( Pmode, 9)));
|
| 625 |
|
|
|
| 626 |
|
|
} /* or32_expand_epilogue () */
|
| 627 |
|
|
|
| 628 |
|
|
|
| 629 |
|
|
/* -------------------------------------------------------------------------- */
|
| 630 |
|
|
/*!Generate assembler code for a movdi/movdf pattern
|
| 631 |
|
|
|
| 632 |
|
|
@param[in] operands Operands to the movdx pattern.
|
| 633 |
|
|
|
| 634 |
|
|
@return The assembler string to output (always "", since we've done the
|
| 635 |
|
|
output here). */
|
| 636 |
|
|
/* -------------------------------------------------------------------------- */
|
| 637 |
|
|
const char *
|
| 638 |
|
|
or32_output_move_double (rtx *operands)
|
| 639 |
|
|
{
|
| 640 |
|
|
rtx xoperands[3];
|
| 641 |
|
|
|
| 642 |
|
|
switch (GET_CODE (operands[0]))
|
| 643 |
|
|
{
|
| 644 |
|
|
case REG:
|
| 645 |
|
|
if (GET_CODE (operands[1]) == REG)
|
| 646 |
|
|
{
|
| 647 |
|
|
if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
|
| 648 |
|
|
{
|
| 649 |
|
|
output_asm_insn ("\tl.or \t%H0, %H1, r0", operands);
|
| 650 |
|
|
output_asm_insn ("\tl.or \t%0, %1, r0", operands);
|
| 651 |
|
|
return "";
|
| 652 |
|
|
}
|
| 653 |
|
|
else
|
| 654 |
|
|
{
|
| 655 |
|
|
output_asm_insn ("\tl.or \t%0, %1, r0", operands);
|
| 656 |
|
|
output_asm_insn ("\tl.or \t%H0, %H1, r0", operands);
|
| 657 |
|
|
return "";
|
| 658 |
|
|
}
|
| 659 |
|
|
}
|
| 660 |
|
|
else if (GET_CODE (operands[1]) == MEM)
|
| 661 |
|
|
{
|
| 662 |
|
|
xoperands[1] = XEXP (operands[1], 0);
|
| 663 |
|
|
if (GET_CODE (xoperands[1]) == REG)
|
| 664 |
|
|
{
|
| 665 |
|
|
xoperands[0] = operands[0];
|
| 666 |
|
|
if (REGNO (xoperands[0]) == REGNO (xoperands[1]))
|
| 667 |
|
|
{
|
| 668 |
|
|
output_asm_insn ("\tl.lwz \t%H0, 4(%1)", xoperands);
|
| 669 |
|
|
output_asm_insn ("\tl.lwz \t%0, 0(%1)", xoperands);
|
| 670 |
|
|
return "";
|
| 671 |
|
|
}
|
| 672 |
|
|
else
|
| 673 |
|
|
{
|
| 674 |
|
|
output_asm_insn ("\tl.lwz \t%0, 0(%1)", xoperands);
|
| 675 |
|
|
output_asm_insn ("\tl.lwz \t%H0, 4(%1)", xoperands);
|
| 676 |
|
|
return "";
|
| 677 |
|
|
}
|
| 678 |
|
|
}
|
| 679 |
|
|
else if (GET_CODE (xoperands[1]) == PLUS)
|
| 680 |
|
|
{
|
| 681 |
|
|
if (GET_CODE (xoperands[2] = XEXP (xoperands[1], 1)) == REG)
|
| 682 |
|
|
{
|
| 683 |
|
|
xoperands[0] = operands[0];
|
| 684 |
|
|
xoperands[1] = XEXP (xoperands[1], 0);
|
| 685 |
|
|
if (REGNO (xoperands[0]) == REGNO (xoperands[2]))
|
| 686 |
|
|
{
|
| 687 |
|
|
output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)",
|
| 688 |
|
|
xoperands);
|
| 689 |
|
|
output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands);
|
| 690 |
|
|
return "";
|
| 691 |
|
|
}
|
| 692 |
|
|
else
|
| 693 |
|
|
{
|
| 694 |
|
|
output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands);
|
| 695 |
|
|
output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)",
|
| 696 |
|
|
xoperands);
|
| 697 |
|
|
return "";
|
| 698 |
|
|
}
|
| 699 |
|
|
}
|
| 700 |
|
|
else if (GET_CODE (xoperands[2] = XEXP (xoperands[1], 0)) ==
|
| 701 |
|
|
REG)
|
| 702 |
|
|
{
|
| 703 |
|
|
xoperands[0] = operands[0];
|
| 704 |
|
|
xoperands[1] = XEXP (xoperands[1], 1);
|
| 705 |
|
|
if (REGNO (xoperands[0]) == REGNO (xoperands[2]))
|
| 706 |
|
|
{
|
| 707 |
|
|
output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)",
|
| 708 |
|
|
xoperands);
|
| 709 |
|
|
output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands);
|
| 710 |
|
|
return "";
|
| 711 |
|
|
}
|
| 712 |
|
|
else
|
| 713 |
|
|
{
|
| 714 |
|
|
output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands);
|
| 715 |
|
|
output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)",
|
| 716 |
|
|
xoperands);
|
| 717 |
|
|
return "";
|
| 718 |
|
|
}
|
| 719 |
|
|
}
|
| 720 |
|
|
else
|
| 721 |
|
|
abort ();
|
| 722 |
|
|
}
|
| 723 |
|
|
else
|
| 724 |
|
|
abort ();
|
| 725 |
|
|
}
|
| 726 |
|
|
else if (GET_CODE (operands[1]) == CONST_INT)
|
| 727 |
|
|
{
|
| 728 |
|
|
if (INTVAL (operands[1]) < 0)
|
| 729 |
|
|
output_asm_insn ("\tl.addi \t%0, r0, -1", operands);
|
| 730 |
|
|
else
|
| 731 |
|
|
output_asm_insn ("\tl.or \t%0, r0, r0", operands);
|
| 732 |
|
|
output_asm_insn ("\tl.movhi \t%H0, hi(%1)", operands);
|
| 733 |
|
|
output_asm_insn ("\tl.ori \t%H0, %H0, lo(%1)", operands);
|
| 734 |
|
|
return "";
|
| 735 |
|
|
}
|
| 736 |
|
|
else
|
| 737 |
|
|
abort ();
|
| 738 |
|
|
case MEM:
|
| 739 |
|
|
xoperands[0] = XEXP (operands[0], 0);
|
| 740 |
|
|
if (GET_CODE (xoperands[0]) == REG)
|
| 741 |
|
|
{
|
| 742 |
|
|
xoperands[1] = operands[1];
|
| 743 |
|
|
output_asm_insn ("\tl.sw \t0(%0), %1", xoperands);
|
| 744 |
|
|
output_asm_insn ("\tl.sw \t4(%0), %H1", xoperands);
|
| 745 |
|
|
return "";
|
| 746 |
|
|
}
|
| 747 |
|
|
else if (GET_CODE (xoperands[0]) == PLUS)
|
| 748 |
|
|
{
|
| 749 |
|
|
if (GET_CODE (xoperands[1] = XEXP (xoperands[0], 1)) == REG)
|
| 750 |
|
|
{
|
| 751 |
|
|
xoperands[0] = XEXP (xoperands[0], 0);
|
| 752 |
|
|
xoperands[2] = operands[1];
|
| 753 |
|
|
output_asm_insn ("\tl.sw \t%0(%1), %2", xoperands);
|
| 754 |
|
|
output_asm_insn ("\tl.sw \t%0+4(%1), %H2", xoperands);
|
| 755 |
|
|
return "";
|
| 756 |
|
|
}
|
| 757 |
|
|
else if (GET_CODE (xoperands[1] = XEXP (xoperands[0], 0)) == REG)
|
| 758 |
|
|
{
|
| 759 |
|
|
xoperands[0] = XEXP (xoperands[0], 1);
|
| 760 |
|
|
xoperands[2] = operands[1];
|
| 761 |
|
|
output_asm_insn ("\tl.sw \t%0(%1), %2", xoperands);
|
| 762 |
|
|
output_asm_insn ("\tl.sw \t%0+4(%1), %H2", xoperands);
|
| 763 |
|
|
return "";
|
| 764 |
|
|
}
|
| 765 |
|
|
else
|
| 766 |
|
|
abort ();
|
| 767 |
|
|
}
|
| 768 |
|
|
else
|
| 769 |
|
|
{
|
| 770 |
|
|
fprintf (stderr, " O/p error %s\n",
|
| 771 |
|
|
GET_RTX_NAME (GET_CODE (xoperands[0])));
|
| 772 |
|
|
return "";
|
| 773 |
|
|
/* abort (); */
|
| 774 |
|
|
}
|
| 775 |
|
|
default:
|
| 776 |
|
|
abort ();
|
| 777 |
|
|
}
|
| 778 |
|
|
} /* or32_output_move_double () */
|
| 779 |
|
|
|
| 780 |
|
|
|
| 781 |
|
|
/* -------------------------------------------------------------------------- */
|
| 782 |
|
|
/*!Expand a conditional branch
|
| 783 |
|
|
|
| 784 |
|
|
@param[in] operands Operands to the branch.
|
| 785 |
|
|
@param[in] mode Mode of the comparison. */
|
| 786 |
|
|
/* -------------------------------------------------------------------------- */
|
| 787 |
|
|
void
|
| 788 |
|
|
or32_expand_conditional_branch (rtx *operands,
|
| 789 |
|
|
enum machine_mode mode)
|
| 790 |
|
|
{
|
| 791 |
|
|
rtx tmp;
|
| 792 |
|
|
enum rtx_code test_code = GET_CODE(operands[0]);
|
| 793 |
|
|
|
| 794 |
|
|
switch (mode)
|
| 795 |
|
|
{
|
| 796 |
|
|
case SImode:
|
| 797 |
|
|
tmp = or32_expand_compare (test_code, operands[1], operands[2]);
|
| 798 |
|
|
tmp = gen_rtx_IF_THEN_ELSE (VOIDmode,
|
| 799 |
|
|
tmp,
|
| 800 |
|
|
gen_rtx_LABEL_REF (VOIDmode, operands[3]),
|
| 801 |
|
|
pc_rtx);
|
| 802 |
|
|
emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
|
| 803 |
|
|
return;
|
| 804 |
|
|
|
| 805 |
|
|
case SFmode:
|
| 806 |
|
|
tmp = or32_expand_compare (test_code, operands[1], operands[2]);
|
| 807 |
|
|
tmp = gen_rtx_IF_THEN_ELSE (VOIDmode,
|
| 808 |
|
|
tmp,
|
| 809 |
|
|
gen_rtx_LABEL_REF (VOIDmode, operands[3]),
|
| 810 |
|
|
pc_rtx);
|
| 811 |
|
|
emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
|
| 812 |
|
|
return;
|
| 813 |
|
|
|
| 814 |
|
|
default:
|
| 815 |
|
|
abort ();
|
| 816 |
|
|
}
|
| 817 |
|
|
|
| 818 |
|
|
} /* or32_expand_conditional_branch () */
|
| 819 |
|
|
|
| 820 |
|
|
|
| 821 |
|
|
/* -------------------------------------------------------------------------- */
|
| 822 |
|
|
/*!Emit a conditional move
|
| 823 |
|
|
|
| 824 |
|
|
move "true_cond" to "dest" if "op" of the operands of the last comparison
|
| 825 |
|
|
is nonzero/true, "false_cond" if it is zero/false.
|
| 826 |
|
|
|
| 827 |
|
|
@param[in] dest RTX for the destination operand.
|
| 828 |
|
|
@param[in] op RTX for the comparison operation
|
| 829 |
|
|
@param[in] true_cond RTX to move to dest if condition is TRUE.
|
| 830 |
|
|
@param[in] false_cond RTX to move to dest if condition is FALSE.
|
| 831 |
|
|
|
| 832 |
|
|
@return Non-zero (TRUE) if the hardware supports such an operation, zero
|
| 833 |
|
|
(FALSE) otherwise. */
|
| 834 |
|
|
/* -------------------------------------------------------------------------- */
|
| 835 |
|
|
int
|
| 836 |
|
|
or32_emit_cmove (rtx dest,
|
| 837 |
|
|
rtx op,
|
| 838 |
|
|
rtx true_cond,
|
| 839 |
|
|
rtx false_cond)
|
| 840 |
|
|
{
|
| 841 |
|
|
enum machine_mode result_mode = GET_MODE (dest);
|
| 842 |
|
|
|
| 843 |
|
|
if (GET_MODE (true_cond) != result_mode)
|
| 844 |
|
|
return 0;
|
| 845 |
|
|
|
| 846 |
|
|
if (GET_MODE (false_cond) != result_mode)
|
| 847 |
|
|
return 0;
|
| 848 |
|
|
|
| 849 |
|
|
/* First, work out if the hardware can do this at all */
|
| 850 |
|
|
return or32_emit_int_cmove (dest, op, true_cond, false_cond);
|
| 851 |
|
|
|
| 852 |
|
|
} /* or32_emit_cmove () */
|
| 853 |
|
|
|
| 854 |
|
|
|
| 855 |
|
|
/* -------------------------------------------------------------------------- */
|
| 856 |
|
|
/*!Output the assembler for a branch on flag instruction.
|
| 857 |
|
|
|
| 858 |
|
|
@param[in] operands Operands to the branch.
|
| 859 |
|
|
|
| 860 |
|
|
@return The assembler string to use. */
|
| 861 |
|
|
/* -------------------------------------------------------------------------- */
|
| 862 |
|
|
const char *
|
| 863 |
|
|
or32_output_bf (rtx * operands)
|
| 864 |
|
|
{
|
| 865 |
|
|
enum rtx_code code;
|
| 866 |
|
|
enum machine_mode mode_calc, mode_got;
|
| 867 |
|
|
|
| 868 |
|
|
code = GET_CODE (operands[1]);
|
| 869 |
|
|
mode_calc = SELECT_CC_MODE (code, or32_compare_op0, or32_compare_op1);
|
| 870 |
|
|
mode_got = GET_MODE (operands[2]);
|
| 871 |
|
|
|
| 872 |
|
|
if (!TARGET_MASK_ALIGNED_JUMPS)
|
| 873 |
|
|
{
|
| 874 |
|
|
if (mode_calc != mode_got)
|
| 875 |
|
|
return "\tl.bnf\t%l0%(";
|
| 876 |
|
|
else
|
| 877 |
|
|
return "\tl.bf\t%l0%(";
|
| 878 |
|
|
}
|
| 879 |
|
|
else
|
| 880 |
|
|
{
|
| 881 |
|
|
if (mode_calc != mode_got)
|
| 882 |
|
|
return "\t.balignl\t0x8,0x15000015,0x4\n\tl.bnf\t%l0%(";
|
| 883 |
|
|
else
|
| 884 |
|
|
return "\t.balignl 0x8,0x15000015,0x4;\n\tl.bf\t%l0%(";
|
| 885 |
|
|
}
|
| 886 |
|
|
} /* or32_output_bf () */
|
| 887 |
|
|
|
| 888 |
|
|
|
| 889 |
|
|
/* -------------------------------------------------------------------------- */
|
| 890 |
|
|
/*!Output the assembler for a conditional move instruction.
|
| 891 |
|
|
|
| 892 |
|
|
@param[in] operands Operands to the conditional move.
|
| 893 |
|
|
|
| 894 |
|
|
@return The assembler string to use. */
|
| 895 |
|
|
/* -------------------------------------------------------------------------- */
|
| 896 |
|
|
const char *
|
| 897 |
|
|
or32_output_cmov (rtx * operands)
|
| 898 |
|
|
{
|
| 899 |
|
|
enum rtx_code code;
|
| 900 |
|
|
enum machine_mode mode_calc, mode_got;
|
| 901 |
|
|
|
| 902 |
|
|
code = GET_CODE (operands[1]);
|
| 903 |
|
|
mode_calc = SELECT_CC_MODE (code, or32_compare_op0, or32_compare_op1);
|
| 904 |
|
|
mode_got = GET_MODE (operands[4]);
|
| 905 |
|
|
|
| 906 |
|
|
if (mode_calc != mode_got)
|
| 907 |
|
|
return "\tl.cmov\t%0,%3,%2"; /* reversed */
|
| 908 |
|
|
else
|
| 909 |
|
|
return "\tl.cmov\t%0,%2,%3";
|
| 910 |
|
|
|
| 911 |
|
|
} /* or32_output_cmov () */
|
| 912 |
|
|
|
| 913 |
|
|
|
| 914 |
|
|
/* -------------------------------------------------------------------------- */
|
| 915 |
|
|
/*!Expand a sibcall pattern.
|
| 916 |
|
|
|
| 917 |
|
|
For now this is very simple way for sibcall support (i.e tail call
|
| 918 |
|
|
optimization).
|
| 919 |
|
|
|
| 920 |
|
|
@param[in] result Not sure. RTX for the result location?
|
| 921 |
|
|
@param[in] addr Not sure. RXT for the address to call?
|
| 922 |
|
|
@param[in] args_size Not sure. RTX for the size of the args (in bytes?)? */
|
| 923 |
|
|
/* -------------------------------------------------------------------------- */
|
| 924 |
|
|
void
|
| 925 |
|
|
or32_expand_sibcall (rtx result ATTRIBUTE_UNUSED,
|
| 926 |
|
|
rtx addr,
|
| 927 |
|
|
rtx args_size)
|
| 928 |
|
|
{
|
| 929 |
|
|
emit_call_insn (gen_sibcall_internal (addr, args_size));
|
| 930 |
|
|
|
| 931 |
|
|
} /* or32_expand_sibcall () */
|
| 932 |
|
|
|
| 933 |
|
|
|
| 934 |
|
|
/* -------------------------------------------------------------------------- */
|
| 935 |
|
|
/*!Load a 32-bit constant.
|
| 936 |
|
|
|
| 937 |
|
|
We know it can't be done in one insn when we get here, the movsi expander
|
| 938 |
|
|
guarantees this.
|
| 939 |
|
|
|
| 940 |
|
|
@param[in] op0 RTX for the destination.
|
| 941 |
|
|
@param[in] op1 RTX for the (constant) source. */
|
| 942 |
|
|
/* -------------------------------------------------------------------------- */
|
| 943 |
|
|
void
|
| 944 |
|
|
or32_emit_set_const32 (rtx op0,
|
| 945 |
|
|
rtx op1)
|
| 946 |
|
|
{
|
| 947 |
|
|
enum machine_mode mode = GET_MODE (op0);
|
| 948 |
|
|
rtx temp;
|
| 949 |
|
|
|
| 950 |
|
|
/* Sanity check that we really can't do it in one instruction. I.e that we
|
| 951 |
|
|
don't have a 16-bit constant. */
|
| 952 |
|
|
if (GET_CODE (op1) == CONST_INT)
|
| 953 |
|
|
{
|
| 954 |
|
|
HOST_WIDE_INT val = INTVAL (op1) & GET_MODE_MASK (mode);
|
| 955 |
|
|
|
| 956 |
|
|
if ((-32768 <= val) && (val <= 32767))
|
| 957 |
|
|
{
|
| 958 |
|
|
abort ();
|
| 959 |
|
|
}
|
| 960 |
|
|
}
|
| 961 |
|
|
|
| 962 |
|
|
/* Full 2-insn decomposition is needed. */
|
| 963 |
|
|
if (reload_in_progress || reload_completed)
|
| 964 |
|
|
temp = op0;
|
| 965 |
|
|
else
|
| 966 |
|
|
temp = gen_reg_rtx (mode);
|
| 967 |
|
|
|
| 968 |
|
|
if (GET_CODE (op1) == CONST_INT)
|
| 969 |
|
|
{
|
| 970 |
|
|
/* Emit them as real moves instead of a HIGH/LO_SUM,
|
| 971 |
|
|
this way CSE can see everything and reuse intermediate
|
| 972 |
|
|
values if it wants. */
|
| 973 |
|
|
emit_insn (gen_rtx_SET (VOIDmode, temp,
|
| 974 |
|
|
GEN_INT (INTVAL (op1)
|
| 975 |
|
|
& ~(HOST_WIDE_INT) 0xffff)));
|
| 976 |
|
|
|
| 977 |
|
|
emit_insn (gen_rtx_SET (VOIDmode,
|
| 978 |
|
|
op0,
|
| 979 |
|
|
gen_rtx_IOR (mode, temp,
|
| 980 |
|
|
GEN_INT (INTVAL (op1) & 0xffff))));
|
| 981 |
|
|
}
|
| 982 |
|
|
else
|
| 983 |
|
|
{
|
| 984 |
|
|
/* since or32 bfd can not deal with relocs that are not of type
|
| 985 |
|
|
OR32_CONSTH_RELOC + OR32_CONST_RELOC (ie move high must be
|
| 986 |
|
|
followed by exactly one lo_sum)
|
| 987 |
|
|
*/
|
| 988 |
|
|
emit_insn (gen_movsi_insn_big (op0, op1));
|
| 989 |
|
|
}
|
| 990 |
|
|
} /* or32_emit_set_const32 () */
|
| 991 |
|
|
|
| 992 |
|
|
|
| 993 |
|
|
/* ========================================================================== */
|
| 994 |
|
|
/* Target hook functions.
|
| 995 |
|
|
|
| 996 |
|
|
These are initialized at the end of this file, to avoid having to
|
| 997 |
|
|
predeclare all the functions. They are only needed here, so are static. */
|
| 998 |
|
|
|
| 999 |
|
|
|
| 1000 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1001 |
|
|
/*!Set up the stack and frame pointer (if desired) for the function.
|
| 1002 |
|
|
|
| 1003 |
|
|
If defined, a function that outputs the assembler code for entry to a
|
| 1004 |
|
|
function. The prologue is responsible for setting up the stack frame,
|
| 1005 |
|
|
initializing the frame pointer register, saving registers that must be
|
| 1006 |
|
|
saved, and allocating "size" additional bytes of storage for the local
|
| 1007 |
|
|
variables. "size" is an integer. "file" is a stdio stream to which the
|
| 1008 |
|
|
assembler code should be output.
|
| 1009 |
|
|
|
| 1010 |
|
|
The label for the beginning of the function need not be output by this
|
| 1011 |
|
|
macro. That has already been done when the macro is run.
|
| 1012 |
|
|
|
| 1013 |
|
|
To determine which registers to save, the macro can refer to the array
|
| 1014 |
|
|
"regs_ever_live": element "r" is nonzero if hard register "r" is used
|
| 1015 |
|
|
anywhere within the function. This implies the function prologue should
|
| 1016 |
|
|
save register r, provided it is not one of the call-used
|
| 1017 |
|
|
registers. (TARGET_ASM_FUNCTION_EPILOGUE must likewise use
|
| 1018 |
|
|
"regs_ever_live".)
|
| 1019 |
|
|
|
| 1020 |
|
|
On machines that have "register windows", the function entry code does not
|
| 1021 |
|
|
save on the stack the registers that are in the windows, even if they are
|
| 1022 |
|
|
supposed to be preserved by function calls; instead it takes appropriate
|
| 1023 |
|
|
steps to “push” the register stack, if any non-call-used registers are used
|
| 1024 |
|
|
in the function.
|
| 1025 |
|
|
|
| 1026 |
|
|
On machines where functions may or may not have frame-pointers, the
|
| 1027 |
|
|
function entry code must vary accordingly; it must set up the frame pointer
|
| 1028 |
|
|
if one is wanted, and not otherwise. To determine whether a frame pointer
|
| 1029 |
|
|
is in wanted, the macro can refer to the variable frame_pointer_needed. The
|
| 1030 |
|
|
variable’s value will be 1 at run time in a function that needs a frame
|
| 1031 |
|
|
pointer. See the section on "Eliminating Frame Pointer and Arg Pointer" in
|
| 1032 |
|
|
the "Target Description Macros and Functions" chapter of the GCC internals
|
| 1033 |
|
|
manual.
|
| 1034 |
|
|
|
| 1035 |
|
|
The function entry code is responsible for allocating any stack space
|
| 1036 |
|
|
required for the function. This stack space consists of the regions listed
|
| 1037 |
|
|
below. In most cases, these regions are allocated in the order listed, with
|
| 1038 |
|
|
the last listed region closest to the top of the stack (the lowest address
|
| 1039 |
|
|
if STACK_GROWS_DOWNWARD is defined, and the highest address if it is not
|
| 1040 |
|
|
defined). You can use a different order for a machine if doing so is more
|
| 1041 |
|
|
convenient or required for compatibility reasons. Except in cases where
|
| 1042 |
|
|
required by standard or by a debugger, there is no reason why the stack
|
| 1043 |
|
|
layout used by GCC need agree with that used by other compilers for a
|
| 1044 |
|
|
machine.
|
| 1045 |
|
|
|
| 1046 |
|
|
@param[in] file File handle for any generated code.
|
| 1047 |
|
|
@param[in] size Number of bytes of storage needed for local variables. */
|
| 1048 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1049 |
|
|
static void
|
| 1050 |
|
|
or32_output_function_prologue (FILE *file,
|
| 1051 |
|
|
HOST_WIDE_INT size)
|
| 1052 |
|
|
{
|
| 1053 |
|
|
int save_area;
|
| 1054 |
|
|
int gpr_save_area;
|
| 1055 |
|
|
int lr_save_area;
|
| 1056 |
|
|
int fp_save_area;
|
| 1057 |
|
|
int stack_size;
|
| 1058 |
|
|
int regno;
|
| 1059 |
|
|
|
| 1060 |
|
|
/* If we are doing the prologue using the "prologue" pattern in the machine
|
| 1061 |
|
|
description, do nothing more here.
|
| 1062 |
|
|
|
| 1063 |
|
|
JPB 30-Aug-10: Surely that is not correct. If this option is set, we
|
| 1064 |
|
|
should never even be called! */
|
| 1065 |
|
|
if (TARGET_MASK_SCHED_LOGUE)
|
| 1066 |
|
|
return;
|
| 1067 |
|
|
|
| 1068 |
|
|
if (size < 0)
|
| 1069 |
|
|
abort ();
|
| 1070 |
|
|
|
| 1071 |
|
|
/* Work out and log the frame size */
|
| 1072 |
|
|
stack_size = calculate_stack_size (size, &lr_save_area, &fp_save_area,
|
| 1073 |
|
|
&gpr_save_area, &save_area);
|
| 1074 |
|
|
|
| 1075 |
|
|
fprintf (file,
|
| 1076 |
|
|
"\n\t# gpr_save_area %d size %ld crtl->outgoing_args_size %d\n",
|
| 1077 |
|
|
gpr_save_area, size, crtl->outgoing_args_size);
|
| 1078 |
|
|
|
| 1079 |
|
|
/* Decrement the stack pointer by the total frame size (if we have a
|
| 1080 |
|
|
frame). */
|
| 1081 |
|
|
if (stack_size > 0)
|
| 1082 |
|
|
{
|
| 1083 |
|
|
/* Special code for large stack frames */
|
| 1084 |
|
|
if (stack_size >= 0x8000)
|
| 1085 |
|
|
{
|
| 1086 |
|
|
fprintf (file, "\tl.movhi\tr%d,hi(%d)\n", GP_ARG_RETURN, stack_size);
|
| 1087 |
|
|
fprintf (file, "\tl.ori\tr%d,r%d,lo(%d)\n", GP_ARG_RETURN,
|
| 1088 |
|
|
GP_ARG_RETURN, stack_size);
|
| 1089 |
|
|
fprintf (file, "\tl.sub\tr%d,r%d,r%d\n", STACK_POINTER_REGNUM,
|
| 1090 |
|
|
STACK_POINTER_REGNUM, GP_ARG_RETURN);
|
| 1091 |
|
|
}
|
| 1092 |
|
|
else
|
| 1093 |
|
|
{
|
| 1094 |
|
|
fprintf (file, "\tl.addi\tr%d,r%d,%d\n", STACK_POINTER_REGNUM,
|
| 1095 |
|
|
STACK_POINTER_REGNUM, -stack_size);
|
| 1096 |
|
|
}
|
| 1097 |
|
|
|
| 1098 |
|
|
/* Update the DWARF2 CFA using the new stack pointer. After this the CFA
|
| 1099 |
|
|
will be the SP + frame size, i.e. the FP (or start of frame if we
|
| 1100 |
|
|
don't actually have a FP). All register refs should relate to this. */
|
| 1101 |
|
|
if (dwarf2out_do_frame ())
|
| 1102 |
|
|
{
|
| 1103 |
|
|
char *l = dwarf2out_cfi_label (false);
|
| 1104 |
|
|
|
| 1105 |
|
|
dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, stack_size);
|
| 1106 |
|
|
}
|
| 1107 |
|
|
}
|
| 1108 |
|
|
|
| 1109 |
|
|
/* Update the frame pointer if necessary */
|
| 1110 |
|
|
if (fp_save_area)
|
| 1111 |
|
|
{
|
| 1112 |
|
|
char *l = dwarf2out_cfi_label (false);
|
| 1113 |
|
|
int offset = OR32_ALIGN (crtl->outgoing_args_size, 4) + lr_save_area;
|
| 1114 |
|
|
|
| 1115 |
|
|
fprintf (file, "\tl.sw\t%d(r%d),r%d\n", offset,
|
| 1116 |
|
|
STACK_POINTER_REGNUM, FRAME_POINTER_REGNUM);
|
| 1117 |
|
|
|
| 1118 |
|
|
if (stack_size >= 0x8000)
|
| 1119 |
|
|
fprintf (file, "\tl.add\tr%d,r%d,r%d\n", FRAME_POINTER_REGNUM,
|
| 1120 |
|
|
STACK_POINTER_REGNUM, GP_ARG_RETURN);
|
| 1121 |
|
|
else
|
| 1122 |
|
|
fprintf (file, "\tl.addi\tr%d,r%d,%d\n", FRAME_POINTER_REGNUM,
|
| 1123 |
|
|
STACK_POINTER_REGNUM, stack_size);
|
| 1124 |
|
|
|
| 1125 |
|
|
/* The CFA is already pointing at the start of our frame (i.e. the new
|
| 1126 |
|
|
FP). The old FP has been saved relative to the SP, so we need to use
|
| 1127 |
|
|
stack_size to work out where. */
|
| 1128 |
|
|
dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, offset - stack_size);
|
| 1129 |
|
|
}
|
| 1130 |
|
|
|
| 1131 |
|
|
/* Save the return address if necessary */
|
| 1132 |
|
|
if (lr_save_area)
|
| 1133 |
|
|
{
|
| 1134 |
|
|
char *l = dwarf2out_cfi_label (false);
|
| 1135 |
|
|
int offset = OR32_ALIGN (crtl->outgoing_args_size, 4);
|
| 1136 |
|
|
|
| 1137 |
|
|
fprintf (file, "\tl.sw\t%d(r%d),r%d\n", offset, STACK_POINTER_REGNUM,
|
| 1138 |
|
|
LINK_REGNUM);
|
| 1139 |
|
|
|
| 1140 |
|
|
/* The CFA is already pointing at the start of our frame (i.e. the new
|
| 1141 |
|
|
FP). The LR has been saved relative to the SP, so we need to use
|
| 1142 |
|
|
stack_size to work out where. */
|
| 1143 |
|
|
dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, offset - stack_size);
|
| 1144 |
|
|
}
|
| 1145 |
|
|
|
| 1146 |
|
|
save_area = (OR32_ALIGN (crtl->outgoing_args_size, 4)
|
| 1147 |
|
|
+ lr_save_area + fp_save_area);
|
| 1148 |
|
|
|
| 1149 |
|
|
/* Save any callee saved registers */
|
| 1150 |
|
|
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
|
| 1151 |
|
|
{
|
| 1152 |
|
|
if (df_regs_ever_live_p(regno) && !call_used_regs[regno])
|
| 1153 |
|
|
{
|
| 1154 |
|
|
char *l = dwarf2out_cfi_label (false);
|
| 1155 |
|
|
|
| 1156 |
|
|
fprintf (file, "\tl.sw\t%d(r%d),r%d\n", save_area,
|
| 1157 |
|
|
STACK_POINTER_REGNUM, regno);
|
| 1158 |
|
|
|
| 1159 |
|
|
/* The CFA is already pointing at the start of our frame (i.e. the
|
| 1160 |
|
|
new FP). The register has been saved relative to the SP, so we
|
| 1161 |
|
|
need to use stack_size to work out where. */
|
| 1162 |
|
|
dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, save_area - stack_size);
|
| 1163 |
|
|
save_area += 4;
|
| 1164 |
|
|
}
|
| 1165 |
|
|
}
|
| 1166 |
|
|
} /* or32_output_function_prologue () */
|
| 1167 |
|
|
|
| 1168 |
|
|
|
| 1169 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1170 |
|
|
/*!Do any necessary cleanup after a function to restore stack, frame, and regs.
|
| 1171 |
|
|
|
| 1172 |
|
|
This is a function that outputs the assembler code for exit from a
|
| 1173 |
|
|
function. The epilogue is responsible for restoring the saved registers and
|
| 1174 |
|
|
stack pointer to their values when the function was called, and returning
|
| 1175 |
|
|
control to the caller. This macro takes the same arguments as the macro
|
| 1176 |
|
|
TARGET_ASM_FUNCTION_PROLOGUE, and the registers to restore are determined
|
| 1177 |
|
|
from regs_ever_live and CALL_USED_REGISTERS in the same way (@see
|
| 1178 |
|
|
or32_output_function_prologue ()) .
|
| 1179 |
|
|
|
| 1180 |
|
|
On some machines, there is a single instruction that does all the work of
|
| 1181 |
|
|
returning from the function. On these machines, give that instruction the
|
| 1182 |
|
|
name "return" (in the machine definition) and do not define the macro
|
| 1183 |
|
|
TARGET_ASM_FUNCTION_EPILOGUE at all.
|
| 1184 |
|
|
|
| 1185 |
|
|
Do not define a pattern named "return" if you want the
|
| 1186 |
|
|
TARGET_ASM_FUNCTION_EPILOGUE to be used. If you want the target switches to
|
| 1187 |
|
|
control whether return instructions or epilogues are used, define a
|
| 1188 |
|
|
"return" pattern with a validity condition that tests the target switches
|
| 1189 |
|
|
appropriately. If the "return" pattern’s validity condition is false,
|
| 1190 |
|
|
epilogues will be used.
|
| 1191 |
|
|
|
| 1192 |
|
|
On machines where functions may or may not have frame-pointers, the
|
| 1193 |
|
|
function exit code must vary accordingly. Sometimes the code for these two
|
| 1194 |
|
|
cases is completely different. To determine whether a frame pointer is
|
| 1195 |
|
|
wanted, the macro can refer to the variable frame_pointer_needed. The
|
| 1196 |
|
|
variable’s value will be 1 when compiling a function that needs a frame
|
| 1197 |
|
|
pointer.
|
| 1198 |
|
|
|
| 1199 |
|
|
Normally, TARGET_ASM_FUNCTION_PROLOGUE and TARGET_ASM_FUNCTION_EPILOGUE
|
| 1200 |
|
|
must treat leaf functions specially. The C variable
|
| 1201 |
|
|
"current_function_is_leaf" is nonzero for such a function. See "Handling
|
| 1202 |
|
|
Leaf Functions" in the "Target Description Macros and Functions" section of
|
| 1203 |
|
|
the GCC internals manual.
|
| 1204 |
|
|
|
| 1205 |
|
|
On some machines, some functions pop their arguments on exit while others
|
| 1206 |
|
|
leave that for the caller to do. For example, the 68020 when given "-mrtd"
|
| 1207 |
|
|
pops arguments in functions that take a fixed number of arguments.
|
| 1208 |
|
|
|
| 1209 |
|
|
Your definition of the macro RETURN_POPS_ARGS decides which functions pop
|
| 1210 |
|
|
their own arguments. TARGET_ASM_FUNCTION_EPILOGUE needs to know what was
|
| 1211 |
|
|
decided. The number of bytes of the current function’s arguments that this
|
| 1212 |
|
|
function should pop is available in "crtl->args.pops_args". See "How Scalar
|
| 1213 |
|
|
Function Values Are Returned" in the "Target Description Macros and
|
| 1214 |
|
|
Functions" section of the GCC internals manual.
|
| 1215 |
|
|
|
| 1216 |
|
|
@param[in] file File handle for any generated code.
|
| 1217 |
|
|
@param[in] size Number of bytes of storage needed for local variables. */
|
| 1218 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1219 |
|
|
static void
|
| 1220 |
|
|
or32_output_function_epilogue (FILE * file, HOST_WIDE_INT size)
|
| 1221 |
|
|
{
|
| 1222 |
|
|
int save_area;
|
| 1223 |
|
|
int gpr_save_area;
|
| 1224 |
|
|
int lr_save_area;
|
| 1225 |
|
|
int fp_save_area;
|
| 1226 |
|
|
int stack_size;
|
| 1227 |
|
|
int regno;
|
| 1228 |
|
|
|
| 1229 |
|
|
/* If we are doing the epilogue using the "epilogue" pattern in the machine
|
| 1230 |
|
|
description, do nothing more here.
|
| 1231 |
|
|
|
| 1232 |
|
|
JPB 30-Aug-10: Surely that is not correct. If this option is set, we
|
| 1233 |
|
|
should never even be called! */
|
| 1234 |
|
|
if (TARGET_MASK_SCHED_LOGUE)
|
| 1235 |
|
|
return;
|
| 1236 |
|
|
|
| 1237 |
|
|
/* Work out the frame size */
|
| 1238 |
|
|
stack_size = calculate_stack_size (size, &lr_save_area, &fp_save_area,
|
| 1239 |
|
|
&gpr_save_area, &save_area);
|
| 1240 |
|
|
|
| 1241 |
|
|
/* Restore the return address if necessary */
|
| 1242 |
|
|
if (lr_save_area)
|
| 1243 |
|
|
{
|
| 1244 |
|
|
fprintf (file, "\tl.lwz\tr%d,%d(r%d)\n", LINK_REGNUM,
|
| 1245 |
|
|
OR32_ALIGN (crtl->outgoing_args_size, 4),
|
| 1246 |
|
|
STACK_POINTER_REGNUM);
|
| 1247 |
|
|
}
|
| 1248 |
|
|
|
| 1249 |
|
|
/* Restore the frame pointer if necessary */
|
| 1250 |
|
|
if (fp_save_area)
|
| 1251 |
|
|
{
|
| 1252 |
|
|
fprintf (file, "\tl.lwz\tr%d,%d(r%d)\n", FRAME_POINTER_REGNUM,
|
| 1253 |
|
|
OR32_ALIGN (crtl->outgoing_args_size, 4)
|
| 1254 |
|
|
+ lr_save_area, STACK_POINTER_REGNUM);
|
| 1255 |
|
|
}
|
| 1256 |
|
|
|
| 1257 |
|
|
save_area = (OR32_ALIGN (crtl->outgoing_args_size, 4)
|
| 1258 |
|
|
+ lr_save_area + fp_save_area);
|
| 1259 |
|
|
|
| 1260 |
|
|
/* Restore any callee-saved registers */
|
| 1261 |
|
|
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
|
| 1262 |
|
|
{
|
| 1263 |
|
|
if (df_regs_ever_live_p(regno) && !call_used_regs[regno])
|
| 1264 |
|
|
{
|
| 1265 |
|
|
fprintf (file, "\tl.lwz\tr%d,%d(r%d)\n", regno, save_area,
|
| 1266 |
|
|
STACK_POINTER_REGNUM);
|
| 1267 |
|
|
save_area += 4;
|
| 1268 |
|
|
}
|
| 1269 |
|
|
}
|
| 1270 |
|
|
|
| 1271 |
|
|
/* Restore the stack pointer (if necessary) */
|
| 1272 |
|
|
if (stack_size >= 0x8000)
|
| 1273 |
|
|
{
|
| 1274 |
|
|
fprintf (file, "\tl.movhi\tr3,hi(%d)\n", stack_size);
|
| 1275 |
|
|
fprintf (file, "\tl.ori\tr3,r3,lo(%d)\n", stack_size);
|
| 1276 |
|
|
|
| 1277 |
|
|
if (!TARGET_MASK_ALIGNED_JUMPS)
|
| 1278 |
|
|
fprintf (file, "\tl.jr\tr%d\n", LINK_REGNUM);
|
| 1279 |
|
|
else
|
| 1280 |
|
|
{
|
| 1281 |
|
|
fprintf (file, "\t.balignl\t0x8,0x15000015,0x4\n");
|
| 1282 |
|
|
fprintf (file, "\tl.jr\tr%d\n", LINK_REGNUM);
|
| 1283 |
|
|
}
|
| 1284 |
|
|
|
| 1285 |
|
|
fprintf (file, "\tl.add\tr%d,r%d,r3\n", STACK_POINTER_REGNUM,
|
| 1286 |
|
|
STACK_POINTER_REGNUM);
|
| 1287 |
|
|
}
|
| 1288 |
|
|
else if (stack_size > 0)
|
| 1289 |
|
|
{
|
| 1290 |
|
|
if (!TARGET_MASK_ALIGNED_JUMPS)
|
| 1291 |
|
|
fprintf (file, "\tl.jr\tr%d\n", LINK_REGNUM);
|
| 1292 |
|
|
else
|
| 1293 |
|
|
{
|
| 1294 |
|
|
fprintf (file, "\t.balignl 0x8,0x15000015,0x4\n");
|
| 1295 |
|
|
fprintf (file, "\tl.jr\tr%d\n", LINK_REGNUM);
|
| 1296 |
|
|
}
|
| 1297 |
|
|
|
| 1298 |
|
|
fprintf (file, "\tl.addi\tr%d,r%d,%d\n", STACK_POINTER_REGNUM,
|
| 1299 |
|
|
STACK_POINTER_REGNUM, stack_size);
|
| 1300 |
|
|
}
|
| 1301 |
|
|
else
|
| 1302 |
|
|
{
|
| 1303 |
|
|
if (!TARGET_MASK_ALIGNED_JUMPS)
|
| 1304 |
|
|
fprintf (file, "\tl.jr\tr%d\n", LINK_REGNUM);
|
| 1305 |
|
|
else
|
| 1306 |
|
|
{
|
| 1307 |
|
|
fprintf (file, "\t.balignl\t0x8,0x15000015,0x4\n");
|
| 1308 |
|
|
fprintf (file, "\tl.jr\tr%d\n", LINK_REGNUM);
|
| 1309 |
|
|
}
|
| 1310 |
|
|
|
| 1311 |
|
|
fprintf (file, "\tl.nop\n"); /* Delay slot */
|
| 1312 |
|
|
}
|
| 1313 |
|
|
} /* or32_output_function_epilogue () */
|
| 1314 |
|
|
|
| 1315 |
|
|
|
| 1316 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1317 |
|
|
/*!Define where a function returns values.
|
| 1318 |
|
|
|
| 1319 |
|
|
Define this to return an RTX representing the place where a function
|
| 1320 |
|
|
returns or receives a value of data type ret type, a tree node representing
|
| 1321 |
|
|
a data type. "func" is a tree node representing FUNCTION_DECL or
|
| 1322 |
|
|
FUNCTION_TYPE of a function being called. If "outgoing" is false, the hook
|
| 1323 |
|
|
should compute the register in which the caller will see the return
|
| 1324 |
|
|
value. Otherwise, the hook should return an RTX representing the place
|
| 1325 |
|
|
where a function returns a value.
|
| 1326 |
|
|
|
| 1327 |
|
|
On many machines, only TYPE_MODE ("ret_type") is relevant. (Actually, on
|
| 1328 |
|
|
most machines, scalar values are returned in the same place regardless of
|
| 1329 |
|
|
mode.) The value of the expression is usually a reg RTX for the hard
|
| 1330 |
|
|
register where the return value is stored. The value can also be a parallel
|
| 1331 |
|
|
RTX, if the return value is in multiple places. See FUNCTION_ARG for an
|
| 1332 |
|
|
explanation of the parallel form. Note that the callee will populate every
|
| 1333 |
|
|
location specified in the parallel, but if the first element of the
|
| 1334 |
|
|
parallel contains the whole return value, callers will use that element as
|
| 1335 |
|
|
the canonical location and ignore the others. The m68k port uses this type
|
| 1336 |
|
|
of parallel to return pointers in both ‘%a0’ (the canonical location) and
|
| 1337 |
|
|
‘%d0’.
|
| 1338 |
|
|
|
| 1339 |
|
|
If TARGET_PROMOTE_FUNCTION_RETURN returns true, you must apply the same
|
| 1340 |
|
|
promotion rules specified in PROMOTE_MODE if valtype is a scalar type.
|
| 1341 |
|
|
|
| 1342 |
|
|
If the precise function being called is known, "func" is a tree node
|
| 1343 |
|
|
(FUNCTION_DECL) for it; otherwise, "func" is a null pointer. This makes it
|
| 1344 |
|
|
possible to use a different value-returning convention for specific
|
| 1345 |
|
|
functions when all their calls are known.
|
| 1346 |
|
|
|
| 1347 |
|
|
Some target machines have "register windows" so that the register in which
|
| 1348 |
|
|
a function returns its value is not the same as the one in which the caller
|
| 1349 |
|
|
sees the value. For such machines, you should return different RTX
|
| 1350 |
|
|
depending on outgoing.
|
| 1351 |
|
|
|
| 1352 |
|
|
TARGET_FUNCTION_VALUE is not used for return values with aggregate data
|
| 1353 |
|
|
types, because these are returned in another way. See
|
| 1354 |
|
|
TARGET_STRUCT_VALUE_RTX and related macros.
|
| 1355 |
|
|
|
| 1356 |
|
|
For the OR32, we can just use the result of LIBCALL_VALUE, since all
|
| 1357 |
|
|
functions return their result in the same place (register rv = r11).
|
| 1358 |
|
|
|
| 1359 |
|
|
JPB 30-Aug-10: What about 64-bit scalar returns (long long int, double),
|
| 1360 |
|
|
which also use rvh (=r12)?
|
| 1361 |
|
|
|
| 1362 |
|
|
@param[in] ret_type The return type of the function.
|
| 1363 |
|
|
@param[in] func Tree representing function being called.
|
| 1364 |
|
|
@param[in] outgoing Non-zero (TRUE) if the result represents where the
|
| 1365 |
|
|
function places the results, zero (FALSE) if the
|
| 1366 |
|
|
result represents where the caller sees the result.
|
| 1367 |
|
|
|
| 1368 |
|
|
@return A RTX representing where the result can be found. */
|
| 1369 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1370 |
|
|
static rtx
|
| 1371 |
|
|
or32_function_value (const_tree ret_type,
|
| 1372 |
|
|
const_tree func ATTRIBUTE_UNUSED,
|
| 1373 |
|
|
bool outgoing ATTRIBUTE_UNUSED)
|
| 1374 |
|
|
{
|
| 1375 |
|
|
return LIBCALL_VALUE (TYPE_MODE(ret_type));
|
| 1376 |
|
|
|
| 1377 |
|
|
} /* or32_function_value () */
|
| 1378 |
|
|
|
| 1379 |
|
|
|
| 1380 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1381 |
|
|
/*!Check if a function is suitable for tail call optimization.
|
| 1382 |
|
|
|
| 1383 |
|
|
True if it is OK to do sibling call optimization for the specified call
|
| 1384 |
|
|
expression "exp". "decl" will be the called function, or NULL if this is an
|
| 1385 |
|
|
indirect call.
|
| 1386 |
|
|
|
| 1387 |
|
|
It is not uncommon for limitations of calling conventions to prevent tail
|
| 1388 |
|
|
calls to functions outside the current unit of translation, or during PIC
|
| 1389 |
|
|
compilation. The hook is used to enforce these restrictions, as the sibcall
|
| 1390 |
|
|
md pattern can not fail, or fall over to a “normal” call. The criteria for
|
| 1391 |
|
|
successful sibling call optimization may vary greatly between different
|
| 1392 |
|
|
architectures.
|
| 1393 |
|
|
|
| 1394 |
|
|
For the OR32, we currently allow sibcall optimization if the -msibcall
|
| 1395 |
|
|
argument is passed.
|
| 1396 |
|
|
|
| 1397 |
|
|
JPB 30-Aug-10: Surely we should always allow this?
|
| 1398 |
|
|
|
| 1399 |
|
|
@param[in] decl The function for which we may optimize
|
| 1400 |
|
|
@param[in] exp The call expression which is candidate for optimization.
|
| 1401 |
|
|
|
| 1402 |
|
|
@return Non-zero (TRUE) if sibcall optimization is permitted, zero (FALSE)
|
| 1403 |
|
|
otherwise. */
|
| 1404 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1405 |
|
|
static bool
|
| 1406 |
|
|
or32_function_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED,
|
| 1407 |
|
|
tree exp ATTRIBUTE_UNUSED)
|
| 1408 |
|
|
{
|
| 1409 |
|
|
return TARGET_MASK_SIBCALL;
|
| 1410 |
|
|
|
| 1411 |
|
|
} /* or32_function_ok_for_sibcall () */
|
| 1412 |
|
|
|
| 1413 |
|
|
|
| 1414 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1415 |
|
|
/*!Should an argument be passed by reference.
|
| 1416 |
|
|
|
| 1417 |
|
|
This target hook should return true if an argument at the position
|
| 1418 |
|
|
indicated by "cum" should be passed by reference. This predicate is queried
|
| 1419 |
|
|
after target independent reasons for being passed by reference, such as
|
| 1420 |
|
|
TREE_ADDRESSABLE ("type").
|
| 1421 |
|
|
|
| 1422 |
|
|
If the hook returns TRUE, a copy of that argument is made in memory and a
|
| 1423 |
|
|
pointer to the argument is passed instead of the argument itself. The
|
| 1424 |
|
|
pointer is passed in whatever way is appropriate for passing a pointer to
|
| 1425 |
|
|
that type.
|
| 1426 |
|
|
|
| 1427 |
|
|
For the OR32, all aggregates and arguments greater than 8 bytes are passed
|
| 1428 |
|
|
this way.
|
| 1429 |
|
|
|
| 1430 |
|
|
@param[in] cum Position of argument under consideration.
|
| 1431 |
|
|
@param[in[ mode Not sure what this relates to.
|
| 1432 |
|
|
@param[in] type Type of the argument.
|
| 1433 |
|
|
@param[in] named Not sure what this relates to.
|
| 1434 |
|
|
|
| 1435 |
|
|
@return Non-zero (TRUE) if the argument should be passed by reference,
|
| 1436 |
|
|
zero (FALSE) otherwise. */
|
| 1437 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1438 |
|
|
static bool
|
| 1439 |
|
|
or32_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
|
| 1440 |
|
|
enum machine_mode mode ATTRIBUTE_UNUSED,
|
| 1441 |
|
|
const_tree type,
|
| 1442 |
|
|
bool named ATTRIBUTE_UNUSED)
|
| 1443 |
|
|
{
|
| 1444 |
|
|
return (type && (AGGREGATE_TYPE_P (type) || int_size_in_bytes (type) > 8));
|
| 1445 |
|
|
|
| 1446 |
|
|
} /* or32_pass_by_reference () */
|
| 1447 |
|
|
|
| 1448 |
|
|
|
| 1449 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1450 |
|
|
/*!Is a frame pointer required?
|
| 1451 |
|
|
|
| 1452 |
|
|
This target hook should return TRUE if a function must have and use a frame
|
| 1453 |
|
|
pointer. This target hook is called in the reload pass. If its return
|
| 1454 |
|
|
value is TRUE the function will have a frame pointer.
|
| 1455 |
|
|
|
| 1456 |
|
|
This target hook can in principle examine the current function and decide
|
| 1457 |
|
|
according to the facts, but on most machines the constant false or the
|
| 1458 |
|
|
constant true suffices. Use FALSE when the machine allows code to be
|
| 1459 |
|
|
generated with no frame pointer, and doing so saves some time or space. Use
|
| 1460 |
|
|
TRUE when there is no possible advantage to avoiding a frame pointer.
|
| 1461 |
|
|
|
| 1462 |
|
|
In certain cases, the compiler does not know how to produce valid code
|
| 1463 |
|
|
without a frame pointer. The compiler recognizes those cases and
|
| 1464 |
|
|
automatically gives the function a frame pointer regardless of what
|
| 1465 |
|
|
TARGET_FRAME_POINTER_REQUIRED returns. You don’t need to worry about them.
|
| 1466 |
|
|
|
| 1467 |
|
|
In a function that does not require a frame pointer, the frame pointer
|
| 1468 |
|
|
register can be allocated for ordinary usage, unless you mark it as a fixed
|
| 1469 |
|
|
register. See FIXED_REGISTERS for more information.
|
| 1470 |
|
|
|
| 1471 |
|
|
Default return value is false.
|
| 1472 |
|
|
|
| 1473 |
|
|
For the OR32 we do not need the frame pointer, so the default would have
|
| 1474 |
|
|
sufficed.
|
| 1475 |
|
|
|
| 1476 |
|
|
JPB 30-Aug-10: The version supplied returned TRUE, which is patently the
|
| 1477 |
|
|
wrong answer. This function really could be eliminated and
|
| 1478 |
|
|
the default used.
|
| 1479 |
|
|
|
| 1480 |
|
|
@return Non-zero (TRUE) if a frame pointer is not required, zero (FALSE)
|
| 1481 |
|
|
otherwise. */
|
| 1482 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1483 |
|
|
static bool
|
| 1484 |
|
|
or32_frame_pointer_required (void)
|
| 1485 |
|
|
{
|
| 1486 |
|
|
return 1;
|
| 1487 |
|
|
|
| 1488 |
|
|
} /* or32_frame_pointer_required () */
|
| 1489 |
|
|
|
| 1490 |
|
|
|
| 1491 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1492 |
|
|
/*!How many bytes at the beginning of an argument must be put into registers.
|
| 1493 |
|
|
|
| 1494 |
|
|
This target hook returns the number of bytes at the beginning of an
|
| 1495 |
|
|
argument that must be put in registers. The value must be zero for
|
| 1496 |
|
|
arguments that are passed entirely in registers or that are entirely pushed
|
| 1497 |
|
|
on the stack.
|
| 1498 |
|
|
|
| 1499 |
|
|
On some machines, certain arguments must be passed partially in registers
|
| 1500 |
|
|
and partially in memory. On these machines, typically the first few words
|
| 1501 |
|
|
of arguments a re passed in registers, and the rest on the stack. If a
|
| 1502 |
|
|
multi-word argument (a double or a structure) crosses that boundary, its
|
| 1503 |
|
|
first few words must be passed in registers and the rest must be
|
| 1504 |
|
|
pushed. This macro tells the compiler when this occurs, and how many bytes
|
| 1505 |
|
|
should go in registers.
|
| 1506 |
|
|
|
| 1507 |
|
|
FUNCTION_ARG for these arguments should return the first register to be
|
| 1508 |
|
|
used by the caller for this argument; likewise FUNCTION_INCOMING_ARG, for
|
| 1509 |
|
|
the called function.
|
| 1510 |
|
|
|
| 1511 |
|
|
On the OR32 we never split argumetns between registers and memory.
|
| 1512 |
|
|
|
| 1513 |
|
|
JPB 30-Aug-10: Is this correct? Surely we should allow this. The ABI spec
|
| 1514 |
|
|
is incomplete on this point.
|
| 1515 |
|
|
|
| 1516 |
|
|
@param[in] cum Position of argument under consideration.
|
| 1517 |
|
|
@param[in[ mode Not sure what this relates to.
|
| 1518 |
|
|
@param[in] type Type of the argument.
|
| 1519 |
|
|
@param[in] named Not sure what this relates to.
|
| 1520 |
|
|
|
| 1521 |
|
|
@return The number of bytes of the argument to go into registers */
|
| 1522 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1523 |
|
|
static int
|
| 1524 |
|
|
or32_arg_partial_bytes (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
|
| 1525 |
|
|
enum machine_mode mode ATTRIBUTE_UNUSED,
|
| 1526 |
|
|
tree type ATTRIBUTE_UNUSED,
|
| 1527 |
|
|
bool named ATTRIBUTE_UNUSED)
|
| 1528 |
|
|
{
|
| 1529 |
|
|
return 0;
|
| 1530 |
|
|
|
| 1531 |
|
|
} /* or32_arg_partial_bytes () */
|
| 1532 |
|
|
|
| 1533 |
|
|
|
| 1534 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1535 |
|
|
/*!Promote the mode of a function's arguments/return value.
|
| 1536 |
|
|
|
| 1537 |
|
|
Like PROMOTE_MODE, but it is applied to outgoing function arguments or
|
| 1538 |
|
|
function return values. The target hook should return the new mode and
|
| 1539 |
|
|
possibly change "*punsignedp" if the promotion should change
|
| 1540 |
|
|
signedness. This function is called only for scalar or pointer types.
|
| 1541 |
|
|
|
| 1542 |
|
|
"for_return" allows to distinguish the promotion of arguments and return
|
| 1543 |
|
|
values. If it is 1, a return value is being promoted and
|
| 1544 |
|
|
TARGET_FUNCTION_VALUE must perform the same promotions done here. If it is
|
| 1545 |
|
|
2, the returned mode should be that of the register in which an incoming
|
| 1546 |
|
|
parameter is copied, or the outgoing result is computed; then the hook
|
| 1547 |
|
|
should return the same mode as PROMOTE_MODE, though the signedness may be
|
| 1548 |
|
|
different.
|
| 1549 |
|
|
|
| 1550 |
|
|
The default is to not promote arguments and return values. You can also
|
| 1551 |
|
|
define the hook to "default_promote_function_mode_always_promote" if you
|
| 1552 |
|
|
would like to apply the same rules given by PROMOTE_MODE.
|
| 1553 |
|
|
|
| 1554 |
|
|
For the OR32, if the size of the mode is integral and less than 4, we
|
| 1555 |
|
|
promote to SImode, otherwise we return the mode we are supplied.
|
| 1556 |
|
|
|
| 1557 |
|
|
@param[in] type Not sure. Type of the argument?
|
| 1558 |
|
|
@param[in] mode The mode of argument/return value to consider.
|
| 1559 |
|
|
@param[out] punsignedp Signedness of the value.
|
| 1560 |
|
|
@param[in] fntype Not sure. Type of the function?
|
| 1561 |
|
|
@param[in] for_return 1 if a return value, 2 if an incoming value.
|
| 1562 |
|
|
|
| 1563 |
|
|
@return The new mode. */
|
| 1564 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1565 |
|
|
static enum machine_mode
|
| 1566 |
|
|
or32_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
|
| 1567 |
|
|
enum machine_mode mode,
|
| 1568 |
|
|
int *punsignedp ATTRIBUTE_UNUSED,
|
| 1569 |
|
|
const_tree fntype ATTRIBUTE_UNUSED,
|
| 1570 |
|
|
int for_return ATTRIBUTE_UNUSED)
|
| 1571 |
|
|
{
|
| 1572 |
|
|
return ( (GET_MODE_CLASS (mode) == MODE_INT)
|
| 1573 |
|
|
&& (GET_MODE_SIZE (mode) < 4)) ? SImode : mode;
|
| 1574 |
|
|
|
| 1575 |
|
|
} /* or32_promote_function_mode () */
|
| 1576 |
|
|
|
| 1577 |
|
|
|
| 1578 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1579 |
|
|
/*!Is this a legitimate address?
|
| 1580 |
|
|
|
| 1581 |
|
|
A function that returns whether x (an RTX) is a legitimate memory address on
|
| 1582 |
|
|
the target machine for a memory operand of mode mode.
|
| 1583 |
|
|
|
| 1584 |
|
|
Legitimate addresses are defined in two variants: a strict variant and a
|
| 1585 |
|
|
non-strict one. The strict parameter chooses which variant is desired by
|
| 1586 |
|
|
the caller.
|
| 1587 |
|
|
|
| 1588 |
|
|
The strict variant is used in the reload pass. It must be defined so that
|
| 1589 |
|
|
any pseudo- register that has not been allocated a hard register is
|
| 1590 |
|
|
considered a memory reference. This is because in contexts where some kind
|
| 1591 |
|
|
of register is required, a pseudo-register with no hard register must be
|
| 1592 |
|
|
rejected. For non-hard registers, the strict variant should look up the
|
| 1593 |
|
|
reg_renumber array; it should then proceed using the hard register number in
|
| 1594 |
|
|
the array, or treat the pseudo as a memory reference if the array holds -1.
|
| 1595 |
|
|
|
| 1596 |
|
|
The non-strict variant is used in other passes. It must be defined to accept
|
| 1597 |
|
|
all pseudo-registers in every context where some kind of register is
|
| 1598 |
|
|
required.
|
| 1599 |
|
|
|
| 1600 |
|
|
Normally, constant addresses which are the sum of a symbol_ref and an
|
| 1601 |
|
|
integer are stored inside a const RTX to mark them as constant. Therefore,
|
| 1602 |
|
|
there is no need to recognize such sums specifically as legitimate
|
| 1603 |
|
|
addresses. Normally you would simply recognize any const as legitimate.
|
| 1604 |
|
|
|
| 1605 |
|
|
Usually PRINT_OPERAND_ADDRESS is not prepared to handle constant sums that
|
| 1606 |
|
|
are not marked with const. It assumes that a naked plus indicates
|
| 1607 |
|
|
indexing. If so, then you must reject such naked constant sums as
|
| 1608 |
|
|
illegitimate addresses, so that none of them will be given to
|
| 1609 |
|
|
PRINT_OPERAND_ADDRESS.
|
| 1610 |
|
|
|
| 1611 |
|
|
On some machines, whether a symbolic address is legitimate depends on the
|
| 1612 |
|
|
section that the address refers to. On these machines, define the target
|
| 1613 |
|
|
hook TARGET_ENCODE_ SECTION_INFO to store the information into the
|
| 1614 |
|
|
symbol_ref, and then check for it here. When you see a const, you will have
|
| 1615 |
|
|
to look inside it to find the symbol_ref in order to determine the
|
| 1616 |
|
|
section. See the internals manual section on "Assembler Format" for more
|
| 1617 |
|
|
info.
|
| 1618 |
|
|
|
| 1619 |
|
|
Some ports are still using a deprecated legacy substitute for this hook, the
|
| 1620 |
|
|
GO_IF_LEGITIMATE_ADDRESS macro. This macro has this syntax:
|
| 1621 |
|
|
|
| 1622 |
|
|
#define GO_IF_LEGITIMATE_ADDRESS (mode, x, label )
|
| 1623 |
|
|
|
| 1624 |
|
|
and should goto label if the address x is a valid address on the target
|
| 1625 |
|
|
machine for a memory operand of mode mode. Whether the strict or non-strict
|
| 1626 |
|
|
variants are desired is defined by the REG_OK_STRICT macro introduced
|
| 1627 |
|
|
earlier in this section. Using the hook is usually simpler because it limits
|
| 1628 |
|
|
the number of files that are recompiled when changes are made.
|
| 1629 |
|
|
|
| 1630 |
|
|
The OR32 only has a single addressing mode, which is a base register with
|
| 1631 |
|
|
16-bit displacement. We can accept just 16-bit constants as addresses (they
|
| 1632 |
|
|
can use r0 as base address, and we can accept plain registers as addresses
|
| 1633 |
|
|
(they can use a displacement of zero).
|
| 1634 |
|
|
|
| 1635 |
|
|
@param[in] mode The mode of the address
|
| 1636 |
|
|
@param[in] x The address (RTX)
|
| 1637 |
|
|
@param[in] strict Non-zero (TRUE) if we are in "strict" mode, zero (FALSE)
|
| 1638 |
|
|
otherwise.
|
| 1639 |
|
|
|
| 1640 |
|
|
@return Non-zero (TRUE) if this is a legitimate address, zero (FALSE)
|
| 1641 |
|
|
otherwise. */
|
| 1642 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1643 |
|
|
static bool
|
| 1644 |
|
|
or32_legitimate_address_p (enum machine_mode mode,
|
| 1645 |
|
|
rtx x,
|
| 1646 |
|
|
bool strict)
|
| 1647 |
|
|
{
|
| 1648 |
|
|
/* You might think 16-bit constants are suitable. They can be built into
|
| 1649 |
|
|
addresses using r0 as the base. However this seems to lead to defective
|
| 1650 |
|
|
code. So for now this is a placeholder, and this code is not used.
|
| 1651 |
|
|
|
| 1652 |
|
|
if (or32_legitimate_displacement_p (mode, x))
|
| 1653 |
|
|
{
|
| 1654 |
|
|
return 1;
|
| 1655 |
|
|
}
|
| 1656 |
|
|
*/
|
| 1657 |
|
|
|
| 1658 |
|
|
/* Addresses consisting of a register and 16-bit displacement are also
|
| 1659 |
|
|
suitable. We need the mode, since for double words, we had better be
|
| 1660 |
|
|
able to address the full 8 bytes. */
|
| 1661 |
|
|
if (GET_CODE(x) == PLUS)
|
| 1662 |
|
|
{
|
| 1663 |
|
|
rtx reg = XEXP(x,0);
|
| 1664 |
|
|
|
| 1665 |
|
|
/* If valid register... */
|
| 1666 |
|
|
if ((GET_CODE(reg) == REG)
|
| 1667 |
|
|
&& or32_regnum_ok_for_base_p (INTVAL (reg), strict))
|
| 1668 |
|
|
{
|
| 1669 |
|
|
rtx offset = XEXP(x,1);
|
| 1670 |
|
|
|
| 1671 |
|
|
/* ...and valid offset */
|
| 1672 |
|
|
if (or32_legitimate_displacement_p (mode, offset))
|
| 1673 |
|
|
{
|
| 1674 |
|
|
return 1;
|
| 1675 |
|
|
}
|
| 1676 |
|
|
}
|
| 1677 |
|
|
}
|
| 1678 |
|
|
|
| 1679 |
|
|
/* Addresses consisting of just a register are OK. They can be built into
|
| 1680 |
|
|
addresses using an offset of zero (and an offset of four if double
|
| 1681 |
|
|
word). */
|
| 1682 |
|
|
if (GET_CODE(x) == REG && or32_regnum_ok_for_base_p( INTVAL (x), strict))
|
| 1683 |
|
|
{
|
| 1684 |
|
|
return 1;
|
| 1685 |
|
|
}
|
| 1686 |
|
|
|
| 1687 |
|
|
return 0;
|
| 1688 |
|
|
|
| 1689 |
|
|
} /* or32_legitimate_address_p () */
|
| 1690 |
|
|
|
| 1691 |
|
|
|
| 1692 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1693 |
|
|
/*!Provide support for DW_AT_calling_convention
|
| 1694 |
|
|
|
| 1695 |
|
|
Define this to enable the dwarf attribute DW_AT_calling_convention to be
|
| 1696 |
|
|
emitted for each function. Instead of an integer return the enum value for
|
| 1697 |
|
|
the DW_CC_ tag.
|
| 1698 |
|
|
|
| 1699 |
|
|
To support optional call frame debugging information, you must also define
|
| 1700 |
|
|
INCOMING_RETURN_ADDR_RTX and either set RTX_FRAME_RELATED_P on the prologue
|
| 1701 |
|
|
insns if you use RTL for the prologue, or call "dwarf2out_def_cfa" and
|
| 1702 |
|
|
"dwarf2out_reg_save" as appropriate from TARGET_ASM_FUNCTION_PROLOGUE if
|
| 1703 |
|
|
you don’t.
|
| 1704 |
|
|
|
| 1705 |
|
|
For the OR32, it should be sufficient to return DW_CC_normal in all cases.
|
| 1706 |
|
|
|
| 1707 |
|
|
@param[in] function The function requiring debug information
|
| 1708 |
|
|
|
| 1709 |
|
|
@return The enum of the DW_CC tag. */
|
| 1710 |
|
|
/* -------------------------------------------------------------------------- */
|
| 1711 |
|
|
static int
|
| 1712 |
|
|
or32_dwarf_calling_convention (const_tree function ATTRIBUTE_UNUSED)
|
| 1713 |
|
|
{
|
| 1714 |
|
|
return DW_CC_normal;
|
| 1715 |
|
|
|
| 1716 |
|
|
} /* or32_dwarf_calling_convention () */
|
| 1717 |
|
|
|
| 1718 |
|
|
|
| 1719 |
|
|
/* ========================================================================== */
|
| 1720 |
|
|
/* Target hook initialization.
|
| 1721 |
|
|
|
| 1722 |
|
|
In most cases these use the static functions declared above. They have
|
| 1723 |
|
|
defaults, so must be undefined first, before being redefined.
|
| 1724 |
|
|
|
| 1725 |
|
|
The description of what they do is found with the function above, unless
|
| 1726 |
|
|
it is a standard function, in which case it is defined here (as with
|
| 1727 |
|
|
TARGET_ASM_NAMED_SECTION).
|
| 1728 |
|
|
|
| 1729 |
|
|
The final declaration is of the global "targetm" structure. */
|
| 1730 |
|
|
|
| 1731 |
|
|
|
| 1732 |
|
|
/* Output assembly directives to switch to section name. The section should
|
| 1733 |
|
|
have attributes as specified by flags, which is a bit mask of the SECTION_*
|
| 1734 |
|
|
flags defined in ‘output.h’. If decl is non-NULL, it is the VAR_DECL or
|
| 1735 |
|
|
FUNCTION_DECL with which this section is associated.
|
| 1736 |
|
|
|
| 1737 |
|
|
For OR32, we use the default ELF sectioning. */
|
| 1738 |
|
|
#undef TARGET_ASM_NAMED_SECTION
|
| 1739 |
|
|
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
|
| 1740 |
|
|
|
| 1741 |
|
|
#undef TARGET_ASM_FUNCTION_PROLOGUE
|
| 1742 |
|
|
#define TARGET_ASM_FUNCTION_PROLOGUE or32_output_function_prologue
|
| 1743 |
|
|
|
| 1744 |
|
|
#undef TARGET_ASM_FUNCTION_EPILOGUE
|
| 1745 |
|
|
#define TARGET_ASM_FUNCTION_EPILOGUE or32_output_function_epilogue
|
| 1746 |
|
|
|
| 1747 |
|
|
#undef TARGET_FUNCTION_VALUE
|
| 1748 |
|
|
#define TARGET_FUNCTION_VALUE or32_function_value
|
| 1749 |
|
|
|
| 1750 |
|
|
#undef TARGET_FUNCTION_OK_FOR_SIBCALL
|
| 1751 |
|
|
#define TARGET_FUNCTION_OK_FOR_SIBCALL or32_function_ok_for_sibcall
|
| 1752 |
|
|
|
| 1753 |
|
|
#undef TARGET_PASS_BY_REFERENCE
|
| 1754 |
|
|
#define TARGET_PASS_BY_REFERENCE or32_pass_by_reference
|
| 1755 |
|
|
|
| 1756 |
|
|
#undef TARGET_FRAME_POINTER_REQUIRED
|
| 1757 |
|
|
#define TARGET_FRAME_POINTER_REQUIRED or32_frame_pointer_required
|
| 1758 |
|
|
|
| 1759 |
|
|
#undef TARGET_ARG_PARTIAL_BYTES
|
| 1760 |
|
|
#define TARGET_ARG_PARTIAL_BYTES or32_arg_partial_bytes
|
| 1761 |
|
|
|
| 1762 |
|
|
/* This target hook returns TRUE if an argument declared in a prototype as an
|
| 1763 |
|
|
integral type smaller than int should actually be passed as an int. In
|
| 1764 |
|
|
addition to avoiding errors in certain cases of mismatch, it also makes for
|
| 1765 |
|
|
better code on certain machines.
|
| 1766 |
|
|
|
| 1767 |
|
|
The default is to not promote prototypes.
|
| 1768 |
|
|
|
| 1769 |
|
|
For the OR32 we do require this, so use a utility hook, which always
|
| 1770 |
|
|
returns TRUE. */
|
| 1771 |
|
|
#undef TARGET_PROMOTE_PROTOTYPES
|
| 1772 |
|
|
#define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true
|
| 1773 |
|
|
|
| 1774 |
|
|
#undef TARGET_PROMOTE_FUNCTION_MODE
|
| 1775 |
|
|
#define TARGET_PROMOTE_FUNCTION_MODE or32_promote_function_mode
|
| 1776 |
|
|
|
| 1777 |
|
|
#undef TARGET_LEGITIMATE_ADDRESS_P
|
| 1778 |
|
|
#define TARGET_LEGITIMATE_ADDRESS_P or32_legitimate_address_p
|
| 1779 |
|
|
|
| 1780 |
|
|
#undef TARGET_DWARF_CALLING_CONVENTION
|
| 1781 |
|
|
#define TARGET_DWARF_CALLING_CONVENTION or32_dwarf_calling_convention
|
| 1782 |
|
|
|
| 1783 |
|
|
/* Trampoline stubs are yet to be written. */
|
| 1784 |
|
|
/* #define TARGET_ASM_TRAMPOLINE_TEMPLATE */
|
| 1785 |
|
|
/* #define TARGET_TRAMPOLINE_INIT */
|
| 1786 |
|
|
|
| 1787 |
|
|
/* Initialize the GCC target structure. */
|
| 1788 |
|
|
struct gcc_target targetm = TARGET_INITIALIZER;
|