| 1 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 |
/* Subroutines used for code generation on IBM RS/6000. |
| 3 |
Copyright (C) 1991-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Richard Kenner ([email protected]) |
| 5 |
|
| 6 |
This file is part of GCC. |
| 7 |
|
| 8 |
GCC is free software; you can redistribute it and/or modify it |
| 9 |
under the terms of the GNU General Public License as published |
| 10 |
by the Free Software Foundation; either version 3, or (at your |
| 11 |
option) any later version. |
| 12 |
|
| 13 |
GCC is distributed in the hope that it will be useful, but WITHOUT |
| 14 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 15 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 16 |
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 |
#define IN_TARGET_CODE 1 |
| 23 |
|
| 24 |
#include "config.h" |
| 25 |
#include "system.h" |
| 26 |
#include "coretypes.h" |
| 27 |
#include "backend.h" |
| 28 |
#include "rtl.h" |
| 29 |
#include "tree.h" |
| 30 |
#include "memmodel.h" |
| 31 |
#include "gimple.h" |
| 32 |
#include "cfghooks.h" |
| 33 |
#include "cfgloop.h" |
| 34 |
#include "df.h" |
| 35 |
#include "tm_p.h" |
| 36 |
#include "stringpool.h" |
| 37 |
#include "expmed.h" |
| 38 |
#include "optabs.h" |
| 39 |
#include "regs.h" |
| 40 |
#include "ira.h" |
| 41 |
#include "recog.h" |
| 42 |
#include "cgraph.h" |
| 43 |
#include "diagnostic-core.h" |
| 44 |
#include "insn-attr.h" |
| 45 |
#include "flags.h" |
| 46 |
#include "alias.h" |
| 47 |
#include "fold-const.h" |
| 48 |
#include "attribs.h" |
| 49 |
#include "stor-layout.h" |
| 50 |
#include "calls.h" |
| 51 |
#include "print-tree.h" |
| 52 |
#include "varasm.h" |
| 53 |
#include "explow.h" |
| 54 |
#include "expr.h" |
| 55 |
#include "output.h" |
| 56 |
#include "common/common-target.h" |
| 57 |
#include "langhooks.h" |
| 58 |
#include "reload.h" |
| 59 |
#include "sched-int.h" |
| 60 |
#include "gimplify.h" |
| 61 |
#include "gimple-iterator.h" |
| 62 |
#include "gimple-fold.h" |
| 63 |
#include "gimple-walk.h" |
| 64 |
#include "ssa.h" |
| 65 |
#include "tree-vectorizer.h" |
| 66 |
#include "tree-ssa-propagate.h" |
| 67 |
#include "intl.h" |
| 68 |
#include "tm-constrs.h" |
| 69 |
#include "target-globals.h" |
| 70 |
#include "builtins.h" |
| 71 |
#include "tree-vector-builder.h" |
| 72 |
#include "context.h" |
| 73 |
#include "tree-pass.h" |
| 74 |
#include "symbol-summary.h" |
| 75 |
#include "sreal.h" |
| 76 |
#include "ipa-cp.h" |
| 77 |
#include "ipa-prop.h" |
| 78 |
#include "ipa-fnsummary.h" |
| 79 |
#include "except.h" |
| 80 |
#include "case-cfn-macros.h" |
| 81 |
#include "ppc-auxv.h" |
| 82 |
#include "rs6000-internal.h" |
| 83 |
#include "opts.h" |
| 84 |
|
| 85 |
/* This file should be included last. */ |
| 86 |
#include "target-def.h" |
| 87 |
|
| 88 |
extern tree rs6000_builtin_mask_for_load (void); |
| 89 |
extern tree rs6000_builtin_md_vectorized_function (tree, tree, tree); |
| 90 |
extern tree rs6000_builtin_reciprocal (tree); |
| 91 |
|
| 92 |
/* Set -mabi=ieeelongdouble on some old targets. In the future, power server |
| 93 |
systems will also set long double to be IEEE 128-bit. AIX and Darwin |
| 94 |
explicitly redefine TARGET_IEEEQUAD and TARGET_IEEEQUAD_DEFAULT to 0, so |
| 95 |
those systems will not pick up this default. This needs to be after all |
| 96 |
of the include files, so that POWERPC_LINUX and POWERPC_FREEBSD are |
| 97 |
properly defined. */ |
| 98 |
#ifndef TARGET_IEEEQUAD_DEFAULT |
| 99 |
#if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD) |
| 100 |
#define TARGET_IEEEQUAD_DEFAULT 1 |
| 101 |
#else |
| 102 |
#define TARGET_IEEEQUAD_DEFAULT 0 |
| 103 |
#endif |
| 104 |
#endif |
| 105 |
|
| 106 |
/* Don't enable PC-relative addressing if the target does not support it. */ |
| 107 |
#ifndef PCREL_SUPPORTED_BY_OS |
| 108 |
#define PCREL_SUPPORTED_BY_OS 0 |
| 109 |
#endif |
| 110 |
|
| 111 |
#ifdef USING_ELFOS_H |
| 112 |
/* Counter for labels which are to be placed in .fixup. */ |
| 113 |
int fixuplabelno = 0; |
| 114 |
#endif |
| 115 |
|
| 116 |
/* Whether to use variant of AIX ABI for PowerPC64 Linux. */ |
| 117 |
int dot_symbols; |
| 118 |
|
| 119 |
/* Specify the machine mode that pointers have. After generation of rtl, the |
| 120 |
compiler makes no further distinction between pointers and any other objects |
| 121 |
of this machine mode. */ |
| 122 |
scalar_int_mode rs6000_pmode; |
| 123 |
|
| 124 |
/* Track use of r13 in 64bit AIX TLS. */ |
| 125 |
static bool xcoff_tls_exec_model_detected = false; |
| 126 |
|
| 127 |
/* Width in bits of a pointer. */ |
| 128 |
unsigned rs6000_pointer_size; |
| 129 |
|
| 130 |
#ifdef HAVE_AS_GNU_ATTRIBUTE |
| 131 |
# ifndef HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE |
| 132 |
# define HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE 0 |
| 133 |
# endif |
| 134 |
/* Flag whether floating point values have been passed/returned. |
| 135 |
Note that this doesn't say whether fprs are used, since the |
| 136 |
Tag_GNU_Power_ABI_FP .gnu.attributes value this flag controls |
| 137 |
should be set for soft-float values passed in gprs and ieee128 |
| 138 |
values passed in vsx registers. */ |
| 139 |
bool rs6000_passes_float = false; |
| 140 |
bool rs6000_passes_long_double = false; |
| 141 |
/* Flag whether vector values have been passed/returned. */ |
| 142 |
bool rs6000_passes_vector = false; |
| 143 |
/* Flag whether small (<= 8 byte) structures have been returned. */ |
| 144 |
bool rs6000_returns_struct = false; |
| 145 |
#endif |
| 146 |
|
| 147 |
/* Value is TRUE if register/mode pair is acceptable. */ |
| 148 |
static bool rs6000_hard_regno_mode_ok_p |
| 149 |
[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER]; |
| 150 |
|
| 151 |
/* Maximum number of registers needed for a given register class and mode. */ |
| 152 |
unsigned char rs6000_class_max_nregs[NUM_MACHINE_MODES][LIM_REG_CLASSES]; |
| 153 |
|
| 154 |
/* How many registers are needed for a given register and mode. */ |
| 155 |
unsigned char rs6000_hard_regno_nregs[NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER]; |
| 156 |
|
| 157 |
/* Map register number to register class. */ |
| 158 |
enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER]; |
| 159 |
|
| 160 |
static int dbg_cost_ctrl; |
| 161 |
|
| 162 |
/* Flag to say the TOC is initialized */ |
| 163 |
int toc_initialized, need_toc_init; |
| 164 |
char toc_label_name[10]; |
| 165 |
|
| 166 |
/* Cached value of rs6000_variable_issue. This is cached in |
| 167 |
rs6000_variable_issue hook and returned from rs6000_sched_reorder2. */ |
| 168 |
static short cached_can_issue_more; |
| 169 |
|
| 170 |
static GTY(()) section *read_only_data_section; |
| 171 |
static GTY(()) section *private_data_section; |
| 172 |
static GTY(()) section *tls_data_section; |
| 173 |
static GTY(()) section *tls_private_data_section; |
| 174 |
static GTY(()) section *read_only_private_data_section; |
| 175 |
static GTY(()) section *sdata2_section; |
| 176 |
|
| 177 |
section *toc_section = 0; |
| 178 |
|
| 179 |
/* Describe the vector unit used for modes. */ |
| 180 |
enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES]; |
| 181 |
enum rs6000_vector rs6000_vector_mem[NUM_MACHINE_MODES]; |
| 182 |
|
| 183 |
/* Register classes for various constraints that are based on the target |
| 184 |
switches. */ |
| 185 |
enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX]; |
| 186 |
|
| 187 |
/* Describe the alignment of a vector. */ |
| 188 |
int rs6000_vector_align[NUM_MACHINE_MODES]; |
| 189 |
|
| 190 |
/* What modes to automatically generate reciprocal divide estimate (fre) and |
| 191 |
reciprocal sqrt (frsqrte) for. */ |
| 192 |
unsigned char rs6000_recip_bits[MAX_MACHINE_MODE]; |
| 193 |
|
| 194 |
/* Masks to determine which reciprocal esitmate instructions to generate |
| 195 |
automatically. */ |
| 196 |
enum rs6000_recip_mask { |
| 197 |
RECIP_SF_DIV = 0x001, /* Use divide estimate */ |
| 198 |
RECIP_DF_DIV = 0x002, |
| 199 |
RECIP_V4SF_DIV = 0x004, |
| 200 |
RECIP_V2DF_DIV = 0x008, |
| 201 |
|
| 202 |
RECIP_SF_RSQRT = 0x010, /* Use reciprocal sqrt estimate. */ |
| 203 |
RECIP_DF_RSQRT = 0x020, |
| 204 |
RECIP_V4SF_RSQRT = 0x040, |
| 205 |
RECIP_V2DF_RSQRT = 0x080, |
| 206 |
|
| 207 |
/* Various combination of flags for -mrecip=xxx. */ |
| 208 |
RECIP_NONE = 0, |
| 209 |
RECIP_ALL = (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV |
| 210 |
| RECIP_V2DF_DIV | RECIP_SF_RSQRT | RECIP_DF_RSQRT |
| 211 |
| RECIP_V4SF_RSQRT | RECIP_V2DF_RSQRT), |
| 212 |
|
| 213 |
RECIP_HIGH_PRECISION = RECIP_ALL, |
| 214 |
|
| 215 |
/* On low precision machines like the power5, don't enable double precision |
| 216 |
reciprocal square root estimate, since it isn't accurate enough. */ |
| 217 |
RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT)) |
| 218 |
}; |
| 219 |
|
| 220 |
/* -mrecip options. */ |
| 221 |
static struct |
| 222 |
{ |
| 223 |
const char *string; /* option name */ |
| 224 |
unsigned int mask; /* mask bits to set */ |
| 225 |
} recip_options[] = { |
| 226 |
{ "all", RECIP_ALL }, |
| 227 |
{ "none", RECIP_NONE }, |
| 228 |
{ "div", (RECIP_SF_DIV | RECIP_DF_DIV | RECIP_V4SF_DIV |
| 229 |
| RECIP_V2DF_DIV) }, |
| 230 |
{ "divf", (RECIP_SF_DIV | RECIP_V4SF_DIV) }, |
| 231 |
{ "divd", (RECIP_DF_DIV | RECIP_V2DF_DIV) }, |
| 232 |
{ "rsqrt", (RECIP_SF_RSQRT | RECIP_DF_RSQRT | RECIP_V4SF_RSQRT |
| 233 |
| RECIP_V2DF_RSQRT) }, |
| 234 |
{ "rsqrtf", (RECIP_SF_RSQRT | RECIP_V4SF_RSQRT) }, |
| 235 |
{ "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) }, |
| 236 |
}; |
| 237 |
|
| 238 |
/* On PowerPC, we have a limited number of target clones that we care about |
| 239 |
which means we can use an array to hold the options, rather than having more |
| 240 |
elaborate data structures to identify each possible variation. Order the |
| 241 |
clones from the default to the highest ISA. */ |
| 242 |
enum { |
| 243 |
CLONE_DEFAULT = 0, /* default clone. */ |
| 244 |
CLONE_ISA_2_05, /* ISA 2.05 (power6). */ |
| 245 |
CLONE_ISA_2_06, /* ISA 2.06 (power7). */ |
| 246 |
CLONE_ISA_2_07, /* ISA 2.07 (power8). */ |
| 247 |
CLONE_ISA_3_00, /* ISA 3.0 (power9). */ |
| 248 |
CLONE_ISA_3_1, /* ISA 3.1 (power10). */ |
| 249 |
CLONE_MAX |
| 250 |
}; |
| 251 |
|
| 252 |
/* Map compiler ISA bits into HWCAP names. */ |
| 253 |
struct clone_map { |
| 254 |
HOST_WIDE_INT isa_mask; /* rs6000_isa mask */ |
| 255 |
const char *name; /* name to use in __builtin_cpu_supports. */ |
| 256 |
}; |
| 257 |
|
| 258 |
static const struct clone_map rs6000_clone_map[CLONE_MAX] = { |
| 259 |
{ 0, "" }, /* Default options. */ |
| 260 |
{ OPTION_MASK_CMPB, "arch_2_05" }, /* ISA 2.05 (power6). */ |
| 261 |
{ OPTION_MASK_POPCNTD, "arch_2_06" }, /* ISA 2.06 (power7). */ |
| 262 |
{ OPTION_MASK_P8_VECTOR, "arch_2_07" }, /* ISA 2.07 (power8). */ |
| 263 |
{ OPTION_MASK_P9_VECTOR, "arch_3_00" }, /* ISA 3.0 (power9). */ |
| 264 |
{ OPTION_MASK_POWER10, "arch_3_1" }, /* ISA 3.1 (power10). */ |
| 265 |
}; |
| 266 |
|
| 267 |
|
| 268 |
/* Newer LIBCs explicitly export this symbol to declare that they provide |
| 269 |
the AT_PLATFORM and AT_HWCAP/AT_HWCAP2 values in the TCB. We emit a |
| 270 |
reference to this symbol whenever we expand a CPU builtin, so that |
| 271 |
we never link against an old LIBC. */ |
| 272 |
const char *tcb_verification_symbol = "__parse_hwcap_and_convert_at_platform"; |
| 273 |
|
| 274 |
/* True if we have expanded a CPU builtin. */ |
| 275 |
bool cpu_builtin_p = false; |
| 276 |
|
| 277 |
/* Pointer to function (in rs6000-c.cc) that can define or undefine target |
| 278 |
macros that have changed. Languages that don't support the preprocessor |
| 279 |
don't link in rs6000-c.cc, so we can't call it directly. */ |
| 280 |
void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT); |
| 281 |
|
| 282 |
/* Simplfy register classes into simpler classifications. We assume |
| 283 |
GPR_REG_TYPE - FPR_REG_TYPE are ordered so that we can use a simple range |
| 284 |
check for standard register classes (gpr/floating/altivec/vsx) and |
| 285 |
floating/vector classes (float/altivec/vsx). */ |
| 286 |
|
| 287 |
enum rs6000_reg_type { |
| 288 |
NO_REG_TYPE, |
| 289 |
PSEUDO_REG_TYPE, |
| 290 |
GPR_REG_TYPE, |
| 291 |
VSX_REG_TYPE, |
| 292 |
ALTIVEC_REG_TYPE, |
| 293 |
FPR_REG_TYPE, |
| 294 |
SPR_REG_TYPE, |
| 295 |
CR_REG_TYPE |
| 296 |
}; |
| 297 |
|
| 298 |
/* Map register class to register type. */ |
| 299 |
static enum rs6000_reg_type reg_class_to_reg_type[N_REG_CLASSES]; |
| 300 |
|
| 301 |
/* First/last register type for the 'normal' register types (i.e. general |
| 302 |
purpose, floating point, altivec, and VSX registers). */ |
| 303 |
#define IS_STD_REG_TYPE(RTYPE) IN_RANGE(RTYPE, GPR_REG_TYPE, FPR_REG_TYPE) |
| 304 |
|
| 305 |
#define IS_FP_VECT_REG_TYPE(RTYPE) IN_RANGE(RTYPE, VSX_REG_TYPE, FPR_REG_TYPE) |
| 306 |
|
| 307 |
|
| 308 |
/* Register classes we care about in secondary reload or go if legitimate |
| 309 |
address. We only need to worry about GPR, FPR, and Altivec registers here, |
| 310 |
along an ANY field that is the OR of the 3 register classes. */ |
| 311 |
|
| 312 |
enum rs6000_reload_reg_type { |
| 313 |
RELOAD_REG_GPR, /* General purpose registers. */ |
| 314 |
RELOAD_REG_FPR, /* Traditional floating point regs. */ |
| 315 |
RELOAD_REG_VMX, /* Altivec (VMX) registers. */ |
| 316 |
RELOAD_REG_ANY, /* OR of GPR, FPR, Altivec masks. */ |
| 317 |
N_RELOAD_REG |
| 318 |
}; |
| 319 |
|
| 320 |
/* For setting up register classes, loop through the 3 register classes mapping |
| 321 |
into real registers, and skip the ANY class, which is just an OR of the |
| 322 |
bits. */ |
| 323 |
#define FIRST_RELOAD_REG_CLASS RELOAD_REG_GPR |
| 324 |
#define LAST_RELOAD_REG_CLASS RELOAD_REG_VMX |
| 325 |
|
| 326 |
/* Map reload register type to a register in the register class. */ |
| 327 |
struct reload_reg_map_type { |
| 328 |
const char *name; /* Register class name. */ |
| 329 |
int reg; /* Register in the register class. */ |
| 330 |
}; |
| 331 |
|
| 332 |
static const struct reload_reg_map_type reload_reg_map[N_RELOAD_REG] = { |
| 333 |
{ "Gpr", FIRST_GPR_REGNO }, /* RELOAD_REG_GPR. */ |
| 334 |
{ "Fpr", FIRST_FPR_REGNO }, /* RELOAD_REG_FPR. */ |
| 335 |
{ "VMX", FIRST_ALTIVEC_REGNO }, /* RELOAD_REG_VMX. */ |
| 336 |
{ "Any", -1 }, /* RELOAD_REG_ANY. */ |
| 337 |
}; |
| 338 |
|
| 339 |
/* Mask bits for each register class, indexed per mode. Historically the |
| 340 |
compiler has been more restrictive which types can do PRE_MODIFY instead of |
| 341 |
PRE_INC and PRE_DEC, so keep track of sepaate bits for these two. */ |
| 342 |
typedef unsigned char addr_mask_type; |
| 343 |
|
| 344 |
#define RELOAD_REG_VALID 0x01 /* Mode valid in register.. */ |
| 345 |
#define RELOAD_REG_MULTIPLE 0x02 /* Mode takes multiple registers. */ |
| 346 |
#define RELOAD_REG_INDEXED 0x04 /* Reg+reg addressing. */ |
| 347 |
#define RELOAD_REG_OFFSET 0x08 /* Reg+offset addressing. */ |
| 348 |
#define RELOAD_REG_PRE_INCDEC 0x10 /* PRE_INC/PRE_DEC valid. */ |
| 349 |
#define RELOAD_REG_PRE_MODIFY 0x20 /* PRE_MODIFY valid. */ |
| 350 |
#define RELOAD_REG_AND_M16 0x40 /* AND -16 addressing. */ |
| 351 |
#define RELOAD_REG_QUAD_OFFSET 0x80 /* quad offset is limited. */ |
| 352 |
|
| 353 |
/* Register type masks based on the type, of valid addressing modes. */ |
| 354 |
struct rs6000_reg_addr { |
| 355 |
enum insn_code reload_load; /* INSN to reload for loading. */ |
| 356 |
enum insn_code reload_store; /* INSN to reload for storing. */ |
| 357 |
enum insn_code reload_fpr_gpr; /* INSN to move from FPR to GPR. */ |
| 358 |
enum insn_code reload_gpr_vsx; /* INSN to move from GPR to VSX. */ |
| 359 |
enum insn_code reload_vsx_gpr; /* INSN to move from VSX to GPR. */ |
| 360 |
addr_mask_type addr_mask[(int)N_RELOAD_REG]; /* Valid address masks. */ |
| 361 |
bool scalar_in_vmx_p; /* Scalar value can go in VMX. */ |
| 362 |
}; |
| 363 |
|
| 364 |
static struct rs6000_reg_addr reg_addr[NUM_MACHINE_MODES]; |
| 365 |
|
| 366 |
/* Helper function to say whether a mode supports PRE_INC or PRE_DEC. */ |
| 367 |
static inline bool |
| 368 |
mode_supports_pre_incdec_p (machine_mode mode) |
| 369 |
{ |
| 370 |
return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_PRE_INCDEC) |
| 371 |
!= 0); |
| 372 |
} |
| 373 |
|
| 374 |
/* Helper function to say whether a mode supports PRE_MODIFY. */ |
| 375 |
static inline bool |
| 376 |
mode_supports_pre_modify_p (machine_mode mode) |
| 377 |
{ |
| 378 |
return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_PRE_MODIFY) |
| 379 |
!= 0); |
| 380 |
} |
| 381 |
|
| 382 |
/* Return true if we have D-form addressing in altivec registers. */ |
| 383 |
static inline bool |
| 384 |
mode_supports_vmx_dform (machine_mode mode) |
| 385 |
{ |
| 386 |
return ((reg_addr[mode].addr_mask[RELOAD_REG_VMX] & RELOAD_REG_OFFSET) != 0); |
| 387 |
} |
| 388 |
|
| 389 |
/* Return true if we have D-form addressing in VSX registers. This addressing |
| 390 |
is more limited than normal d-form addressing in that the offset must be |
| 391 |
aligned on a 16-byte boundary. */ |
| 392 |
static inline bool |
| 393 |
mode_supports_dq_form (machine_mode mode) |
| 394 |
{ |
| 395 |
return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_QUAD_OFFSET) |
| 396 |
!= 0); |
| 397 |
} |
| 398 |
|
| 399 |
/* Given that there exists at least one variable that is set (produced) |
| 400 |
by OUT_INSN and read (consumed) by IN_INSN, return true iff |
| 401 |
IN_INSN represents one or more memory store operations and none of |
| 402 |
the variables set by OUT_INSN is used by IN_INSN as the address of a |
| 403 |
store operation. If either IN_INSN or OUT_INSN does not represent |
| 404 |
a "single" RTL SET expression (as loosely defined by the |
| 405 |
implementation of the single_set function) or a PARALLEL with only |
| 406 |
SETs, CLOBBERs, and USEs inside, this function returns false. |
| 407 |
|
| 408 |
This rs6000-specific version of store_data_bypass_p checks for |
| 409 |
certain conditions that result in assertion failures (and internal |
| 410 |
compiler errors) in the generic store_data_bypass_p function and |
| 411 |
returns false rather than calling store_data_bypass_p if one of the |
| 412 |
problematic conditions is detected. */ |
| 413 |
|
| 414 |
int |
| 415 |
rs6000_store_data_bypass_p (rtx_insn *out_insn, rtx_insn *in_insn) |
| 416 |
{ |
| 417 |
rtx out_set, in_set; |
| 418 |
rtx out_pat, in_pat; |
| 419 |
rtx out_exp, in_exp; |
| 420 |
int i, j; |
| 421 |
|
| 422 |
in_set = single_set (in_insn); |
| 423 |
if (in_set) |
| 424 |
{ |
| 425 |
if (MEM_P (SET_DEST (in_set))) |
| 426 |
{ |
| 427 |
out_set = single_set (out_insn); |
| 428 |
if (!out_set) |
| 429 |
{ |
| 430 |
out_pat = PATTERN (out_insn); |
| 431 |
if (GET_CODE (out_pat) == PARALLEL) |
| 432 |
{ |
| 433 |
for (i = 0; i < XVECLEN (out_pat, 0); i++) |
| 434 |
{ |
| 435 |
out_exp = XVECEXP (out_pat, 0, i); |
| 436 |
if ((GET_CODE (out_exp) == CLOBBER) |
| 437 |
|| (GET_CODE (out_exp) == USE)) |
| 438 |
continue; |
| 439 |
else if (GET_CODE (out_exp) != SET) |
| 440 |
return false; |
| 441 |
} |
| 442 |
} |
| 443 |
} |
| 444 |
} |
| 445 |
} |
| 446 |
else |
| 447 |
{ |
| 448 |
in_pat = PATTERN (in_insn); |
| 449 |
if (GET_CODE (in_pat) != PARALLEL) |
| 450 |
return false; |
| 451 |
|
| 452 |
for (i = 0; i < XVECLEN (in_pat, 0); i++) |
| 453 |
{ |
| 454 |
in_exp = XVECEXP (in_pat, 0, i); |
| 455 |
if ((GET_CODE (in_exp) == CLOBBER) || (GET_CODE (in_exp) == USE)) |
| 456 |
continue; |
| 457 |
else if (GET_CODE (in_exp) != SET) |
| 458 |
return false; |
| 459 |
|
| 460 |
if (MEM_P (SET_DEST (in_exp))) |
| 461 |
{ |
| 462 |
out_set = single_set (out_insn); |
| 463 |
if (!out_set) |
| 464 |
{ |
| 465 |
out_pat = PATTERN (out_insn); |
| 466 |
if (GET_CODE (out_pat) != PARALLEL) |
| 467 |
return false; |
| 468 |
for (j = 0; j < XVECLEN (out_pat, 0); j++) |
| 469 |
{ |
| 470 |
out_exp = XVECEXP (out_pat, 0, j); |
| 471 |
if ((GET_CODE (out_exp) == CLOBBER) |
| 472 |
|| (GET_CODE (out_exp) == USE)) |
| 473 |
continue; |
| 474 |
else if (GET_CODE (out_exp) != SET) |
| 475 |
return false; |
| 476 |
} |
| 477 |
} |
| 478 |
} |
| 479 |
} |
| 480 |
} |
| 481 |
return store_data_bypass_p (out_insn, in_insn); |
| 482 |
} |
| 483 |
|
| 484 |
|
| 485 |
/* Processor costs (relative to an add) */ |
| 486 |
|
| 487 |
const struct processor_costs *rs6000_cost; |
| 488 |
|
| 489 |
/* Instruction size costs on 32bit processors. */ |
| 490 |
static const |
| 491 |
struct processor_costs size32_cost = { |
| 492 |
COSTS_N_INSNS (1), /* mulsi */ |
| 493 |
COSTS_N_INSNS (1), /* mulsi_const */ |
| 494 |
COSTS_N_INSNS (1), /* mulsi_const9 */ |
| 495 |
COSTS_N_INSNS (1), /* muldi */ |
| 496 |
COSTS_N_INSNS (1), /* divsi */ |
| 497 |
COSTS_N_INSNS (1), /* divdi */ |
| 498 |
COSTS_N_INSNS (1), /* fp */ |
| 499 |
COSTS_N_INSNS (1), /* dmul */ |
| 500 |
COSTS_N_INSNS (1), /* sdiv */ |
| 501 |
COSTS_N_INSNS (1), /* ddiv */ |
| 502 |
32, /* cache line size */ |
| 503 |
0, /* l1 cache */ |
| 504 |
0, /* l2 cache */ |
| 505 |
0, /* streams */ |
| 506 |
0, /* SF->DF convert */ |
| 507 |
}; |
| 508 |
|
| 509 |
/* Instruction size costs on 64bit processors. */ |
| 510 |
static const |
| 511 |
struct processor_costs size64_cost = { |
| 512 |
COSTS_N_INSNS (1), /* mulsi */ |
| 513 |
COSTS_N_INSNS (1), /* mulsi_const */ |
| 514 |
COSTS_N_INSNS (1), /* mulsi_const9 */ |
| 515 |
COSTS_N_INSNS (1), /* muldi */ |
| 516 |
COSTS_N_INSNS (1), /* divsi */ |
| 517 |
COSTS_N_INSNS (1), /* divdi */ |
| 518 |
COSTS_N_INSNS (1), /* fp */ |
| 519 |
COSTS_N_INSNS (1), /* dmul */ |
| 520 |
COSTS_N_INSNS (1), /* sdiv */ |
| 521 |
COSTS_N_INSNS (1), /* ddiv */ |
| 522 |
128, /* cache line size */ |
| 523 |
0, /* l1 cache */ |
| 524 |
0, /* l2 cache */ |
| 525 |
0, /* streams */ |
| 526 |
0, /* SF->DF convert */ |
| 527 |
}; |
| 528 |
|
| 529 |
/* Instruction costs on RS64A processors. */ |
| 530 |
static const |
| 531 |
struct processor_costs rs64a_cost = { |
| 532 |
COSTS_N_INSNS (20), /* mulsi */ |
| 533 |
COSTS_N_INSNS (12), /* mulsi_const */ |
| 534 |
COSTS_N_INSNS (8), /* mulsi_const9 */ |
| 535 |
COSTS_N_INSNS (34), /* muldi */ |
| 536 |
COSTS_N_INSNS (65), /* divsi */ |
| 537 |
COSTS_N_INSNS (67), /* divdi */ |
| 538 |
COSTS_N_INSNS (4), /* fp */ |
| 539 |
COSTS_N_INSNS (4), /* dmul */ |
| 540 |
COSTS_N_INSNS (31), /* sdiv */ |
| 541 |
COSTS_N_INSNS (31), /* ddiv */ |
| 542 |
128, /* cache line size */ |
| 543 |
128, /* l1 cache */ |
| 544 |
2048, /* l2 cache */ |
| 545 |
1, /* streams */ |
| 546 |
0, /* SF->DF convert */ |
| 547 |
}; |
| 548 |
|
| 549 |
/* Instruction costs on MPCCORE processors. */ |
| 550 |
static const |
| 551 |
struct processor_costs mpccore_cost = { |
| 552 |
COSTS_N_INSNS (2), /* mulsi */ |
| 553 |
COSTS_N_INSNS (2), /* mulsi_const */ |
| 554 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 555 |
COSTS_N_INSNS (2), /* muldi */ |
| 556 |
COSTS_N_INSNS (6), /* divsi */ |
| 557 |
COSTS_N_INSNS (6), /* divdi */ |
| 558 |
COSTS_N_INSNS (4), /* fp */ |
| 559 |
COSTS_N_INSNS (5), /* dmul */ |
| 560 |
COSTS_N_INSNS (10), /* sdiv */ |
| 561 |
COSTS_N_INSNS (17), /* ddiv */ |
| 562 |
32, /* cache line size */ |
| 563 |
4, /* l1 cache */ |
| 564 |
16, /* l2 cache */ |
| 565 |
1, /* streams */ |
| 566 |
0, /* SF->DF convert */ |
| 567 |
}; |
| 568 |
|
| 569 |
/* Instruction costs on PPC403 processors. */ |
| 570 |
static const |
| 571 |
struct processor_costs ppc403_cost = { |
| 572 |
COSTS_N_INSNS (4), /* mulsi */ |
| 573 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 574 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 575 |
COSTS_N_INSNS (4), /* muldi */ |
| 576 |
COSTS_N_INSNS (33), /* divsi */ |
| 577 |
COSTS_N_INSNS (33), /* divdi */ |
| 578 |
COSTS_N_INSNS (11), /* fp */ |
| 579 |
COSTS_N_INSNS (11), /* dmul */ |
| 580 |
COSTS_N_INSNS (11), /* sdiv */ |
| 581 |
COSTS_N_INSNS (11), /* ddiv */ |
| 582 |
32, /* cache line size */ |
| 583 |
4, /* l1 cache */ |
| 584 |
16, /* l2 cache */ |
| 585 |
1, /* streams */ |
| 586 |
0, /* SF->DF convert */ |
| 587 |
}; |
| 588 |
|
| 589 |
/* Instruction costs on PPC405 processors. */ |
| 590 |
static const |
| 591 |
struct processor_costs ppc405_cost = { |
| 592 |
COSTS_N_INSNS (5), /* mulsi */ |
| 593 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 594 |
COSTS_N_INSNS (3), /* mulsi_const9 */ |
| 595 |
COSTS_N_INSNS (5), /* muldi */ |
| 596 |
COSTS_N_INSNS (35), /* divsi */ |
| 597 |
COSTS_N_INSNS (35), /* divdi */ |
| 598 |
COSTS_N_INSNS (11), /* fp */ |
| 599 |
COSTS_N_INSNS (11), /* dmul */ |
| 600 |
COSTS_N_INSNS (11), /* sdiv */ |
| 601 |
COSTS_N_INSNS (11), /* ddiv */ |
| 602 |
32, /* cache line size */ |
| 603 |
16, /* l1 cache */ |
| 604 |
128, /* l2 cache */ |
| 605 |
1, /* streams */ |
| 606 |
0, /* SF->DF convert */ |
| 607 |
}; |
| 608 |
|
| 609 |
/* Instruction costs on PPC440 processors. */ |
| 610 |
static const |
| 611 |
struct processor_costs ppc440_cost = { |
| 612 |
COSTS_N_INSNS (3), /* mulsi */ |
| 613 |
COSTS_N_INSNS (2), /* mulsi_const */ |
| 614 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 615 |
COSTS_N_INSNS (3), /* muldi */ |
| 616 |
COSTS_N_INSNS (34), /* divsi */ |
| 617 |
COSTS_N_INSNS (34), /* divdi */ |
| 618 |
COSTS_N_INSNS (5), /* fp */ |
| 619 |
COSTS_N_INSNS (5), /* dmul */ |
| 620 |
COSTS_N_INSNS (19), /* sdiv */ |
| 621 |
COSTS_N_INSNS (33), /* ddiv */ |
| 622 |
32, /* cache line size */ |
| 623 |
32, /* l1 cache */ |
| 624 |
256, /* l2 cache */ |
| 625 |
1, /* streams */ |
| 626 |
0, /* SF->DF convert */ |
| 627 |
}; |
| 628 |
|
| 629 |
/* Instruction costs on PPC476 processors. */ |
| 630 |
static const |
| 631 |
struct processor_costs ppc476_cost = { |
| 632 |
COSTS_N_INSNS (4), /* mulsi */ |
| 633 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 634 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 635 |
COSTS_N_INSNS (4), /* muldi */ |
| 636 |
COSTS_N_INSNS (11), /* divsi */ |
| 637 |
COSTS_N_INSNS (11), /* divdi */ |
| 638 |
COSTS_N_INSNS (6), /* fp */ |
| 639 |
COSTS_N_INSNS (6), /* dmul */ |
| 640 |
COSTS_N_INSNS (19), /* sdiv */ |
| 641 |
COSTS_N_INSNS (33), /* ddiv */ |
| 642 |
32, /* l1 cache line size */ |
| 643 |
32, /* l1 cache */ |
| 644 |
512, /* l2 cache */ |
| 645 |
1, /* streams */ |
| 646 |
0, /* SF->DF convert */ |
| 647 |
}; |
| 648 |
|
| 649 |
/* Instruction costs on PPC601 processors. */ |
| 650 |
static const |
| 651 |
struct processor_costs ppc601_cost = { |
| 652 |
COSTS_N_INSNS (5), /* mulsi */ |
| 653 |
COSTS_N_INSNS (5), /* mulsi_const */ |
| 654 |
COSTS_N_INSNS (5), /* mulsi_const9 */ |
| 655 |
COSTS_N_INSNS (5), /* muldi */ |
| 656 |
COSTS_N_INSNS (36), /* divsi */ |
| 657 |
COSTS_N_INSNS (36), /* divdi */ |
| 658 |
COSTS_N_INSNS (4), /* fp */ |
| 659 |
COSTS_N_INSNS (5), /* dmul */ |
| 660 |
COSTS_N_INSNS (17), /* sdiv */ |
| 661 |
COSTS_N_INSNS (31), /* ddiv */ |
| 662 |
32, /* cache line size */ |
| 663 |
32, /* l1 cache */ |
| 664 |
256, /* l2 cache */ |
| 665 |
1, /* streams */ |
| 666 |
0, /* SF->DF convert */ |
| 667 |
}; |
| 668 |
|
| 669 |
/* Instruction costs on PPC603 processors. */ |
| 670 |
static const |
| 671 |
struct processor_costs ppc603_cost = { |
| 672 |
COSTS_N_INSNS (5), /* mulsi */ |
| 673 |
COSTS_N_INSNS (3), /* mulsi_const */ |
| 674 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 675 |
COSTS_N_INSNS (5), /* muldi */ |
| 676 |
COSTS_N_INSNS (37), /* divsi */ |
| 677 |
COSTS_N_INSNS (37), /* divdi */ |
| 678 |
COSTS_N_INSNS (3), /* fp */ |
| 679 |
COSTS_N_INSNS (4), /* dmul */ |
| 680 |
COSTS_N_INSNS (18), /* sdiv */ |
| 681 |
COSTS_N_INSNS (33), /* ddiv */ |
| 682 |
32, /* cache line size */ |
| 683 |
8, /* l1 cache */ |
| 684 |
64, /* l2 cache */ |
| 685 |
1, /* streams */ |
| 686 |
0, /* SF->DF convert */ |
| 687 |
}; |
| 688 |
|
| 689 |
/* Instruction costs on PPC604 processors. */ |
| 690 |
static const |
| 691 |
struct processor_costs ppc604_cost = { |
| 692 |
COSTS_N_INSNS (4), /* mulsi */ |
| 693 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 694 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 695 |
COSTS_N_INSNS (4), /* muldi */ |
| 696 |
COSTS_N_INSNS (20), /* divsi */ |
| 697 |
COSTS_N_INSNS (20), /* divdi */ |
| 698 |
COSTS_N_INSNS (3), /* fp */ |
| 699 |
COSTS_N_INSNS (3), /* dmul */ |
| 700 |
COSTS_N_INSNS (18), /* sdiv */ |
| 701 |
COSTS_N_INSNS (32), /* ddiv */ |
| 702 |
32, /* cache line size */ |
| 703 |
16, /* l1 cache */ |
| 704 |
512, /* l2 cache */ |
| 705 |
1, /* streams */ |
| 706 |
0, /* SF->DF convert */ |
| 707 |
}; |
| 708 |
|
| 709 |
/* Instruction costs on PPC604e processors. */ |
| 710 |
static const |
| 711 |
struct processor_costs ppc604e_cost = { |
| 712 |
COSTS_N_INSNS (2), /* mulsi */ |
| 713 |
COSTS_N_INSNS (2), /* mulsi_const */ |
| 714 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 715 |
COSTS_N_INSNS (2), /* muldi */ |
| 716 |
COSTS_N_INSNS (20), /* divsi */ |
| 717 |
COSTS_N_INSNS (20), /* divdi */ |
| 718 |
COSTS_N_INSNS (3), /* fp */ |
| 719 |
COSTS_N_INSNS (3), /* dmul */ |
| 720 |
COSTS_N_INSNS (18), /* sdiv */ |
| 721 |
COSTS_N_INSNS (32), /* ddiv */ |
| 722 |
32, /* cache line size */ |
| 723 |
32, /* l1 cache */ |
| 724 |
1024, /* l2 cache */ |
| 725 |
1, /* streams */ |
| 726 |
0, /* SF->DF convert */ |
| 727 |
}; |
| 728 |
|
| 729 |
/* Instruction costs on PPC620 processors. */ |
| 730 |
static const |
| 731 |
struct processor_costs ppc620_cost = { |
| 732 |
COSTS_N_INSNS (5), /* mulsi */ |
| 733 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 734 |
COSTS_N_INSNS (3), /* mulsi_const9 */ |
| 735 |
COSTS_N_INSNS (7), /* muldi */ |
| 736 |
COSTS_N_INSNS (21), /* divsi */ |
| 737 |
COSTS_N_INSNS (37), /* divdi */ |
| 738 |
COSTS_N_INSNS (3), /* fp */ |
| 739 |
COSTS_N_INSNS (3), /* dmul */ |
| 740 |
COSTS_N_INSNS (18), /* sdiv */ |
| 741 |
COSTS_N_INSNS (32), /* ddiv */ |
| 742 |
128, /* cache line size */ |
| 743 |
32, /* l1 cache */ |
| 744 |
1024, /* l2 cache */ |
| 745 |
1, /* streams */ |
| 746 |
0, /* SF->DF convert */ |
| 747 |
}; |
| 748 |
|
| 749 |
/* Instruction costs on PPC630 processors. */ |
| 750 |
static const |
| 751 |
struct processor_costs ppc630_cost = { |
| 752 |
COSTS_N_INSNS (5), /* mulsi */ |
| 753 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 754 |
COSTS_N_INSNS (3), /* mulsi_const9 */ |
| 755 |
COSTS_N_INSNS (7), /* muldi */ |
| 756 |
COSTS_N_INSNS (21), /* divsi */ |
| 757 |
COSTS_N_INSNS (37), /* divdi */ |
| 758 |
COSTS_N_INSNS (3), /* fp */ |
| 759 |
COSTS_N_INSNS (3), /* dmul */ |
| 760 |
COSTS_N_INSNS (17), /* sdiv */ |
| 761 |
COSTS_N_INSNS (21), /* ddiv */ |
| 762 |
128, /* cache line size */ |
| 763 |
64, /* l1 cache */ |
| 764 |
1024, /* l2 cache */ |
| 765 |
1, /* streams */ |
| 766 |
0, /* SF->DF convert */ |
| 767 |
}; |
| 768 |
|
| 769 |
/* Instruction costs on Cell processor. */ |
| 770 |
/* COSTS_N_INSNS (1) ~ one add. */ |
| 771 |
static const |
| 772 |
struct processor_costs ppccell_cost = { |
| 773 |
COSTS_N_INSNS (9/2)+2, /* mulsi */ |
| 774 |
COSTS_N_INSNS (6/2), /* mulsi_const */ |
| 775 |
COSTS_N_INSNS (6/2), /* mulsi_const9 */ |
| 776 |
COSTS_N_INSNS (15/2)+2, /* muldi */ |
| 777 |
COSTS_N_INSNS (38/2), /* divsi */ |
| 778 |
COSTS_N_INSNS (70/2), /* divdi */ |
| 779 |
COSTS_N_INSNS (10/2), /* fp */ |
| 780 |
COSTS_N_INSNS (10/2), /* dmul */ |
| 781 |
COSTS_N_INSNS (74/2), /* sdiv */ |
| 782 |
COSTS_N_INSNS (74/2), /* ddiv */ |
| 783 |
128, /* cache line size */ |
| 784 |
32, /* l1 cache */ |
| 785 |
512, /* l2 cache */ |
| 786 |
6, /* streams */ |
| 787 |
0, /* SF->DF convert */ |
| 788 |
}; |
| 789 |
|
| 790 |
/* Instruction costs on PPC750 and PPC7400 processors. */ |
| 791 |
static const |
| 792 |
struct processor_costs ppc750_cost = { |
| 793 |
COSTS_N_INSNS (5), /* mulsi */ |
| 794 |
COSTS_N_INSNS (3), /* mulsi_const */ |
| 795 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 796 |
COSTS_N_INSNS (5), /* muldi */ |
| 797 |
COSTS_N_INSNS (17), /* divsi */ |
| 798 |
COSTS_N_INSNS (17), /* divdi */ |
| 799 |
COSTS_N_INSNS (3), /* fp */ |
| 800 |
COSTS_N_INSNS (3), /* dmul */ |
| 801 |
COSTS_N_INSNS (17), /* sdiv */ |
| 802 |
COSTS_N_INSNS (31), /* ddiv */ |
| 803 |
32, /* cache line size */ |
| 804 |
32, /* l1 cache */ |
| 805 |
512, /* l2 cache */ |
| 806 |
1, /* streams */ |
| 807 |
0, /* SF->DF convert */ |
| 808 |
}; |
| 809 |
|
| 810 |
/* Instruction costs on PPC7450 processors. */ |
| 811 |
static const |
| 812 |
struct processor_costs ppc7450_cost = { |
| 813 |
COSTS_N_INSNS (4), /* mulsi */ |
| 814 |
COSTS_N_INSNS (3), /* mulsi_const */ |
| 815 |
COSTS_N_INSNS (3), /* mulsi_const9 */ |
| 816 |
COSTS_N_INSNS (4), /* muldi */ |
| 817 |
COSTS_N_INSNS (23), /* divsi */ |
| 818 |
COSTS_N_INSNS (23), /* divdi */ |
| 819 |
COSTS_N_INSNS (5), /* fp */ |
| 820 |
COSTS_N_INSNS (5), /* dmul */ |
| 821 |
COSTS_N_INSNS (21), /* sdiv */ |
| 822 |
COSTS_N_INSNS (35), /* ddiv */ |
| 823 |
32, /* cache line size */ |
| 824 |
32, /* l1 cache */ |
| 825 |
1024, /* l2 cache */ |
| 826 |
1, /* streams */ |
| 827 |
0, /* SF->DF convert */ |
| 828 |
}; |
| 829 |
|
| 830 |
/* Instruction costs on PPC8540 processors. */ |
| 831 |
static const |
| 832 |
struct processor_costs ppc8540_cost = { |
| 833 |
COSTS_N_INSNS (4), /* mulsi */ |
| 834 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 835 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 836 |
COSTS_N_INSNS (4), /* muldi */ |
| 837 |
COSTS_N_INSNS (19), /* divsi */ |
| 838 |
COSTS_N_INSNS (19), /* divdi */ |
| 839 |
COSTS_N_INSNS (4), /* fp */ |
| 840 |
COSTS_N_INSNS (4), /* dmul */ |
| 841 |
COSTS_N_INSNS (29), /* sdiv */ |
| 842 |
COSTS_N_INSNS (29), /* ddiv */ |
| 843 |
32, /* cache line size */ |
| 844 |
32, /* l1 cache */ |
| 845 |
256, /* l2 cache */ |
| 846 |
1, /* prefetch streams /*/ |
| 847 |
0, /* SF->DF convert */ |
| 848 |
}; |
| 849 |
|
| 850 |
/* Instruction costs on E300C2 and E300C3 cores. */ |
| 851 |
static const |
| 852 |
struct processor_costs ppce300c2c3_cost = { |
| 853 |
COSTS_N_INSNS (4), /* mulsi */ |
| 854 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 855 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 856 |
COSTS_N_INSNS (4), /* muldi */ |
| 857 |
COSTS_N_INSNS (19), /* divsi */ |
| 858 |
COSTS_N_INSNS (19), /* divdi */ |
| 859 |
COSTS_N_INSNS (3), /* fp */ |
| 860 |
COSTS_N_INSNS (4), /* dmul */ |
| 861 |
COSTS_N_INSNS (18), /* sdiv */ |
| 862 |
COSTS_N_INSNS (33), /* ddiv */ |
| 863 |
32, |
| 864 |
16, /* l1 cache */ |
| 865 |
16, /* l2 cache */ |
| 866 |
1, /* prefetch streams /*/ |
| 867 |
0, /* SF->DF convert */ |
| 868 |
}; |
| 869 |
|
| 870 |
/* Instruction costs on PPCE500MC processors. */ |
| 871 |
static const |
| 872 |
struct processor_costs ppce500mc_cost = { |
| 873 |
COSTS_N_INSNS (4), /* mulsi */ |
| 874 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 875 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 876 |
COSTS_N_INSNS (4), /* muldi */ |
| 877 |
COSTS_N_INSNS (14), /* divsi */ |
| 878 |
COSTS_N_INSNS (14), /* divdi */ |
| 879 |
COSTS_N_INSNS (8), /* fp */ |
| 880 |
COSTS_N_INSNS (10), /* dmul */ |
| 881 |
COSTS_N_INSNS (36), /* sdiv */ |
| 882 |
COSTS_N_INSNS (66), /* ddiv */ |
| 883 |
64, /* cache line size */ |
| 884 |
32, /* l1 cache */ |
| 885 |
128, /* l2 cache */ |
| 886 |
1, /* prefetch streams /*/ |
| 887 |
0, /* SF->DF convert */ |
| 888 |
}; |
| 889 |
|
| 890 |
/* Instruction costs on PPCE500MC64 processors. */ |
| 891 |
static const |
| 892 |
struct processor_costs ppce500mc64_cost = { |
| 893 |
COSTS_N_INSNS (4), /* mulsi */ |
| 894 |
COSTS_N_INSNS (4), /* mulsi_const */ |
| 895 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 896 |
COSTS_N_INSNS (4), /* muldi */ |
| 897 |
COSTS_N_INSNS (14), /* divsi */ |
| 898 |
COSTS_N_INSNS (14), /* divdi */ |
| 899 |
COSTS_N_INSNS (4), /* fp */ |
| 900 |
COSTS_N_INSNS (10), /* dmul */ |
| 901 |
COSTS_N_INSNS (36), /* sdiv */ |
| 902 |
COSTS_N_INSNS (66), /* ddiv */ |
| 903 |
64, /* cache line size */ |
| 904 |
32, /* l1 cache */ |
| 905 |
128, /* l2 cache */ |
| 906 |
1, /* prefetch streams /*/ |
| 907 |
0, /* SF->DF convert */ |
| 908 |
}; |
| 909 |
|
| 910 |
/* Instruction costs on PPCE5500 processors. */ |
| 911 |
static const |
| 912 |
struct processor_costs ppce5500_cost = { |
| 913 |
COSTS_N_INSNS (5), /* mulsi */ |
| 914 |
COSTS_N_INSNS (5), /* mulsi_const */ |
| 915 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 916 |
COSTS_N_INSNS (5), /* muldi */ |
| 917 |
COSTS_N_INSNS (14), /* divsi */ |
| 918 |
COSTS_N_INSNS (14), /* divdi */ |
| 919 |
COSTS_N_INSNS (7), /* fp */ |
| 920 |
COSTS_N_INSNS (10), /* dmul */ |
| 921 |
COSTS_N_INSNS (36), /* sdiv */ |
| 922 |
COSTS_N_INSNS (66), /* ddiv */ |
| 923 |
64, /* cache line size */ |
| 924 |
32, /* l1 cache */ |
| 925 |
128, /* l2 cache */ |
| 926 |
1, /* prefetch streams /*/ |
| 927 |
0, /* SF->DF convert */ |
| 928 |
}; |
| 929 |
|
| 930 |
/* Instruction costs on PPCE6500 processors. */ |
| 931 |
static const |
| 932 |
struct processor_costs ppce6500_cost = { |
| 933 |
COSTS_N_INSNS (5), /* mulsi */ |
| 934 |
COSTS_N_INSNS (5), /* mulsi_const */ |
| 935 |
COSTS_N_INSNS (4), /* mulsi_const9 */ |
| 936 |
COSTS_N_INSNS (5), /* muldi */ |
| 937 |
COSTS_N_INSNS (14), /* divsi */ |
| 938 |
COSTS_N_INSNS (14), /* divdi */ |
| 939 |
COSTS_N_INSNS (7), /* fp */ |
| 940 |
COSTS_N_INSNS (10), /* dmul */ |
| 941 |
COSTS_N_INSNS (36), /* sdiv */ |
| 942 |
COSTS_N_INSNS (66), /* ddiv */ |
| 943 |
64, /* cache line size */ |
| 944 |
32, /* l1 cache */ |
| 945 |
128, /* l2 cache */ |
| 946 |
1, /* prefetch streams /*/ |
| 947 |
0, /* SF->DF convert */ |
| 948 |
}; |
| 949 |
|
| 950 |
/* Instruction costs on AppliedMicro Titan processors. */ |
| 951 |
static const |
| 952 |
struct processor_costs titan_cost = { |
| 953 |
COSTS_N_INSNS (5), /* mulsi */ |
| 954 |
COSTS_N_INSNS (5), /* mulsi_const */ |
| 955 |
COSTS_N_INSNS (5), /* mulsi_const9 */ |
| 956 |
COSTS_N_INSNS (5), /* muldi */ |
| 957 |
COSTS_N_INSNS (18), /* divsi */ |
| 958 |
COSTS_N_INSNS (18), /* divdi */ |
| 959 |
COSTS_N_INSNS (10), /* fp */ |
| 960 |
COSTS_N_INSNS (10), /* dmul */ |
| 961 |
COSTS_N_INSNS (46), /* sdiv */ |
| 962 |
COSTS_N_INSNS (72), /* ddiv */ |
| 963 |
32, /* cache line size */ |
| 964 |
32, /* l1 cache */ |
| 965 |
512, /* l2 cache */ |
| 966 |
1, /* prefetch streams /*/ |
| 967 |
0, /* SF->DF convert */ |
| 968 |
}; |
| 969 |
|
| 970 |
/* Instruction costs on POWER4 and POWER5 processors. */ |
| 971 |
static const |
| 972 |
struct processor_costs power4_cost = { |
| 973 |
COSTS_N_INSNS (3), /* mulsi */ |
| 974 |
COSTS_N_INSNS (2), /* mulsi_const */ |
| 975 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 976 |
COSTS_N_INSNS (4), /* muldi */ |
| 977 |
COSTS_N_INSNS (18), /* divsi */ |
| 978 |
COSTS_N_INSNS (34), /* divdi */ |
| 979 |
COSTS_N_INSNS (3), /* fp */ |
| 980 |
COSTS_N_INSNS (3), /* dmul */ |
| 981 |
COSTS_N_INSNS (17), /* sdiv */ |
| 982 |
COSTS_N_INSNS (17), /* ddiv */ |
| 983 |
128, /* cache line size */ |
| 984 |
32, /* l1 cache */ |
| 985 |
1024, /* l2 cache */ |
| 986 |
8, /* prefetch streams /*/ |
| 987 |
0, /* SF->DF convert */ |
| 988 |
}; |
| 989 |
|
| 990 |
/* Instruction costs on POWER6 processors. */ |
| 991 |
static const |
| 992 |
struct processor_costs power6_cost = { |
| 993 |
COSTS_N_INSNS (8), /* mulsi */ |
| 994 |
COSTS_N_INSNS (8), /* mulsi_const */ |
| 995 |
COSTS_N_INSNS (8), /* mulsi_const9 */ |
| 996 |
COSTS_N_INSNS (8), /* muldi */ |
| 997 |
COSTS_N_INSNS (22), /* divsi */ |
| 998 |
COSTS_N_INSNS (28), /* divdi */ |
| 999 |
COSTS_N_INSNS (3), /* fp */ |
| 1000 |
COSTS_N_INSNS (3), /* dmul */ |
| 1001 |
COSTS_N_INSNS (13), /* sdiv */ |
| 1002 |
COSTS_N_INSNS (16), /* ddiv */ |
| 1003 |
128, /* cache line size */ |
| 1004 |
64, /* l1 cache */ |
| 1005 |
2048, /* l2 cache */ |
| 1006 |
16, /* prefetch streams */ |
| 1007 |
0, /* SF->DF convert */ |
| 1008 |
}; |
| 1009 |
|
| 1010 |
/* Instruction costs on POWER7 processors. */ |
| 1011 |
static const |
| 1012 |
struct processor_costs power7_cost = { |
| 1013 |
COSTS_N_INSNS (2), /* mulsi */ |
| 1014 |
COSTS_N_INSNS (2), /* mulsi_const */ |
| 1015 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 1016 |
COSTS_N_INSNS (2), /* muldi */ |
| 1017 |
COSTS_N_INSNS (18), /* divsi */ |
| 1018 |
COSTS_N_INSNS (34), /* divdi */ |
| 1019 |
COSTS_N_INSNS (3), /* fp */ |
| 1020 |
COSTS_N_INSNS (3), /* dmul */ |
| 1021 |
COSTS_N_INSNS (13), /* sdiv */ |
| 1022 |
COSTS_N_INSNS (16), /* ddiv */ |
| 1023 |
128, /* cache line size */ |
| 1024 |
32, /* l1 cache */ |
| 1025 |
256, /* l2 cache */ |
| 1026 |
12, /* prefetch streams */ |
| 1027 |
COSTS_N_INSNS (3), /* SF->DF convert */ |
| 1028 |
}; |
| 1029 |
|
| 1030 |
/* Instruction costs on POWER8 processors. */ |
| 1031 |
static const |
| 1032 |
struct processor_costs power8_cost = { |
| 1033 |
COSTS_N_INSNS (3), /* mulsi */ |
| 1034 |
COSTS_N_INSNS (3), /* mulsi_const */ |
| 1035 |
COSTS_N_INSNS (3), /* mulsi_const9 */ |
| 1036 |
COSTS_N_INSNS (3), /* muldi */ |
| 1037 |
COSTS_N_INSNS (19), /* divsi */ |
| 1038 |
COSTS_N_INSNS (35), /* divdi */ |
| 1039 |
COSTS_N_INSNS (3), /* fp */ |
| 1040 |
COSTS_N_INSNS (3), /* dmul */ |
| 1041 |
COSTS_N_INSNS (14), /* sdiv */ |
| 1042 |
COSTS_N_INSNS (17), /* ddiv */ |
| 1043 |
128, /* cache line size */ |
| 1044 |
32, /* l1 cache */ |
| 1045 |
512, /* l2 cache */ |
| 1046 |
12, /* prefetch streams */ |
| 1047 |
COSTS_N_INSNS (3), /* SF->DF convert */ |
| 1048 |
}; |
| 1049 |
|
| 1050 |
/* Instruction costs on POWER9 processors. */ |
| 1051 |
static const |
| 1052 |
struct processor_costs power9_cost = { |
| 1053 |
COSTS_N_INSNS (3), /* mulsi */ |
| 1054 |
COSTS_N_INSNS (3), /* mulsi_const */ |
| 1055 |
COSTS_N_INSNS (3), /* mulsi_const9 */ |
| 1056 |
COSTS_N_INSNS (3), /* muldi */ |
| 1057 |
COSTS_N_INSNS (8), /* divsi */ |
| 1058 |
COSTS_N_INSNS (12), /* divdi */ |
| 1059 |
COSTS_N_INSNS (3), /* fp */ |
| 1060 |
COSTS_N_INSNS (3), /* dmul */ |
| 1061 |
COSTS_N_INSNS (13), /* sdiv */ |
| 1062 |
COSTS_N_INSNS (18), /* ddiv */ |
| 1063 |
128, /* cache line size */ |
| 1064 |
32, /* l1 cache */ |
| 1065 |
512, /* l2 cache */ |
| 1066 |
8, /* prefetch streams */ |
| 1067 |
COSTS_N_INSNS (3), /* SF->DF convert */ |
| 1068 |
}; |
| 1069 |
|
| 1070 |
/* Instruction costs on Power10/Power11 processors. */ |
| 1071 |
static const |
| 1072 |
struct processor_costs power10_cost = { |
| 1073 |
COSTS_N_INSNS (2), /* mulsi */ |
| 1074 |
COSTS_N_INSNS (2), /* mulsi_const */ |
| 1075 |
COSTS_N_INSNS (2), /* mulsi_const9 */ |
| 1076 |
COSTS_N_INSNS (2), /* muldi */ |
| 1077 |
COSTS_N_INSNS (6), /* divsi */ |
| 1078 |
COSTS_N_INSNS (6), /* divdi */ |
| 1079 |
COSTS_N_INSNS (2), /* fp */ |
| 1080 |
COSTS_N_INSNS (2), /* dmul */ |
| 1081 |
COSTS_N_INSNS (11), /* sdiv */ |
| 1082 |
COSTS_N_INSNS (13), /* ddiv */ |
| 1083 |
128, /* cache line size */ |
| 1084 |
32, /* l1 cache */ |
| 1085 |
512, /* l2 cache */ |
| 1086 |
16, /* prefetch streams */ |
| 1087 |
COSTS_N_INSNS (2), /* SF->DF convert */ |
| 1088 |
}; |
| 1089 |
|
| 1090 |
/* Instruction costs on POWER A2 processors. */ |
| 1091 |
static const |
| 1092 |
struct processor_costs ppca2_cost = { |
| 1093 |
COSTS_N_INSNS (16), /* mulsi */ |
| 1094 |
COSTS_N_INSNS (16), /* mulsi_const */ |
| 1095 |
COSTS_N_INSNS (16), /* mulsi_const9 */ |
| 1096 |
COSTS_N_INSNS (16), /* muldi */ |
| 1097 |
COSTS_N_INSNS (22), /* divsi */ |
| 1098 |
COSTS_N_INSNS (28), /* divdi */ |
| 1099 |
COSTS_N_INSNS (3), /* fp */ |
| 1100 |
COSTS_N_INSNS (3), /* dmul */ |
| 1101 |
COSTS_N_INSNS (59), /* sdiv */ |
| 1102 |
COSTS_N_INSNS (72), /* ddiv */ |
| 1103 |
64, |
| 1104 |
16, /* l1 cache */ |
| 1105 |
2048, /* l2 cache */ |
| 1106 |
16, /* prefetch streams */ |
| 1107 |
0, /* SF->DF convert */ |
| 1108 |
}; |
| 1109 |
|
| 1110 |
/* Support for -mveclibabi=<xxx> to control which vector library to use. */ |
| 1111 |
static tree (*rs6000_veclib_handler) (combined_fn, tree, tree); |
| 1112 |
|
| 1113 |
|
| 1114 |
static bool rs6000_debug_legitimate_address_p (machine_mode, rtx, bool, |
| 1115 |
code_helper = ERROR_MARK); |
| 1116 |
static tree rs6000_handle_longcall_attribute (tree *, tree, tree, int, bool *); |
| 1117 |
static tree rs6000_handle_altivec_attribute (tree *, tree, tree, int, bool *); |
| 1118 |
static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *); |
| 1119 |
static tree rs6000_builtin_vectorized_libmass (combined_fn, tree, tree); |
| 1120 |
static void rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, int * = nullptr); |
| 1121 |
static int rs6000_memory_move_cost (machine_mode, reg_class_t, bool); |
| 1122 |
static bool rs6000_debug_rtx_costs (rtx, machine_mode, int, int, int *, bool); |
| 1123 |
static int rs6000_debug_address_cost (rtx, machine_mode, addr_space_t, |
| 1124 |
bool); |
| 1125 |
static int rs6000_debug_adjust_cost (rtx_insn *, int, rtx_insn *, int, |
| 1126 |
unsigned int); |
| 1127 |
static bool is_microcoded_insn (rtx_insn *); |
| 1128 |
static bool is_nonpipeline_insn (rtx_insn *); |
| 1129 |
static bool is_cracked_insn (rtx_insn *); |
| 1130 |
static bool is_load_insn (rtx, rtx *); |
| 1131 |
static bool is_store_insn (rtx, rtx *); |
| 1132 |
static bool set_to_load_agen (rtx_insn *,rtx_insn *); |
| 1133 |
static bool insn_terminates_group_p (rtx_insn *, enum group_termination); |
| 1134 |
static bool insn_must_be_first_in_group (rtx_insn *); |
| 1135 |
static bool insn_must_be_last_in_group (rtx_insn *); |
| 1136 |
bool easy_vector_constant (rtx, machine_mode); |
| 1137 |
static rtx rs6000_debug_legitimize_address (rtx, rtx, machine_mode); |
| 1138 |
static rtx rs6000_legitimize_tls_address (rtx, enum tls_model); |
| 1139 |
#if TARGET_MACHO |
| 1140 |
static tree get_prev_label (tree); |
| 1141 |
#endif |
| 1142 |
static bool rs6000_mode_dependent_address (const_rtx); |
| 1143 |
static bool rs6000_debug_mode_dependent_address (const_rtx); |
| 1144 |
static bool rs6000_offsettable_memref_p (rtx, machine_mode, bool); |
| 1145 |
static enum reg_class rs6000_secondary_reload_class (enum reg_class, |
| 1146 |
machine_mode, rtx); |
| 1147 |
static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class, |
| 1148 |
machine_mode, |
| 1149 |
rtx); |
| 1150 |
static enum reg_class rs6000_preferred_reload_class (rtx, enum reg_class); |
| 1151 |
static enum reg_class rs6000_debug_preferred_reload_class (rtx, |
| 1152 |
enum reg_class); |
| 1153 |
static bool rs6000_debug_secondary_memory_needed (machine_mode, |
| 1154 |
reg_class_t, |
| 1155 |
reg_class_t); |
| 1156 |
static bool rs6000_debug_can_change_mode_class (machine_mode, |
| 1157 |
machine_mode, |
| 1158 |
reg_class_t); |
| 1159 |
|
| 1160 |
static bool (*rs6000_mode_dependent_address_ptr) (const_rtx) |
| 1161 |
= rs6000_mode_dependent_address; |
| 1162 |
|
| 1163 |
enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class, |
| 1164 |
machine_mode, rtx) |
| 1165 |
= rs6000_secondary_reload_class; |
| 1166 |
|
| 1167 |
enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class) |
| 1168 |
= rs6000_preferred_reload_class; |
| 1169 |
|
| 1170 |
const int INSN_NOT_AVAILABLE = -1; |
| 1171 |
|
| 1172 |
static void rs6000_print_isa_options (FILE *, int, const char *, |
| 1173 |
HOST_WIDE_INT); |
| 1174 |
static HOST_WIDE_INT rs6000_disable_incompatible_switches (void); |
| 1175 |
|
| 1176 |
static enum rs6000_reg_type register_to_reg_type (rtx, bool *); |
| 1177 |
static bool rs6000_secondary_reload_move (enum rs6000_reg_type, |
| 1178 |
enum rs6000_reg_type, |
| 1179 |
machine_mode, |
| 1180 |
secondary_reload_info *, |
| 1181 |
bool); |
| 1182 |
rtl_opt_pass *make_pass_analyze_swaps (gcc::context*); |
| 1183 |
|
| 1184 |
/* Hash table stuff for keeping track of TOC entries. */ |
| 1185 |
|
| 1186 |
struct GTY((for_user)) toc_hash_struct |
| 1187 |
{ |
| 1188 |
/* `key' will satisfy CONSTANT_P; in fact, it will satisfy |
| 1189 |
ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */ |
| 1190 |
rtx key; |
| 1191 |
machine_mode key_mode; |
| 1192 |
int labelno; |
| 1193 |
}; |
| 1194 |
|
| 1195 |
struct toc_hasher : ggc_ptr_hash<toc_hash_struct> |
| 1196 |
{ |
| 1197 |
static hashval_t hash (toc_hash_struct *); |
| 1198 |
static bool equal (toc_hash_struct *, toc_hash_struct *); |
| 1199 |
}; |
| 1200 |
|
| 1201 |
static GTY (()) hash_table<toc_hasher> *toc_hash_table; |
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
/* Default register names. */ |
| 1206 |
char rs6000_reg_names[][8] = |
| 1207 |
{ |
| 1208 |
/* GPRs */ |
| 1209 |
"0", "1", "2", "3", "4", "5", "6", "7", |
| 1210 |
"8", "9", "10", "11", "12", "13", "14", "15", |
| 1211 |
"16", "17", "18", "19", "20", "21", "22", "23", |
| 1212 |
"24", "25", "26", "27", "28", "29", "30", "31", |
| 1213 |
/* FPRs */ |
| 1214 |
"0", "1", "2", "3", "4", "5", "6", "7", |
| 1215 |
"8", "9", "10", "11", "12", "13", "14", "15", |
| 1216 |
"16", "17", "18", "19", "20", "21", "22", "23", |
| 1217 |
"24", "25", "26", "27", "28", "29", "30", "31", |
| 1218 |
/* VRs */ |
| 1219 |
"0", "1", "2", "3", "4", "5", "6", "7", |
| 1220 |
"8", "9", "10", "11", "12", "13", "14", "15", |
| 1221 |
"16", "17", "18", "19", "20", "21", "22", "23", |
| 1222 |
"24", "25", "26", "27", "28", "29", "30", "31", |
| 1223 |
/* lr ctr ca ap */ |
| 1224 |
"lr", "ctr", "ca", "ap", |
| 1225 |
/* cr0..cr7 */ |
| 1226 |
"0", "1", "2", "3", "4", "5", "6", "7", |
| 1227 |
/* vrsave vscr sfp */ |
| 1228 |
"vrsave", "vscr", "sfp", |
| 1229 |
}; |
| 1230 |
|
| 1231 |
#ifdef TARGET_REGNAMES |
| 1232 |
static const char alt_reg_names[][8] = |
| 1233 |
{ |
| 1234 |
/* GPRs */ |
| 1235 |
"%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", |
| 1236 |
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", |
| 1237 |
"%r16", "%r17", "%r18", "%r19", "%r20", "%r21", "%r22", "%r23", |
| 1238 |
"%r24", "%r25", "%r26", "%r27", "%r28", "%r29", "%r30", "%r31", |
| 1239 |
/* FPRs */ |
| 1240 |
"%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", |
| 1241 |
"%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", |
| 1242 |
"%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", |
| 1243 |
"%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", |
| 1244 |
/* VRs */ |
| 1245 |
"%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7", |
| 1246 |
"%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15", |
| 1247 |
"%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23", |
| 1248 |
"%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31", |
| 1249 |
/* lr ctr ca ap */ |
| 1250 |
"lr", "ctr", "ca", "ap", |
| 1251 |
/* cr0..cr7 */ |
| 1252 |
"%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5", "%cr6", "%cr7", |
| 1253 |
/* vrsave vscr sfp */ |
| 1254 |
"vrsave", "vscr", "sfp", |
| 1255 |
}; |
| 1256 |
#endif |
| 1257 |
|
| 1258 |
/* Table of valid machine attributes. */ |
| 1259 |
|
| 1260 |
static const attribute_spec rs6000_gnu_attributes[] = |
| 1261 |
{ |
| 1262 |
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, |
| 1263 |
affects_type_identity, handler, exclude } */ |
| 1264 |
{ "altivec", 1, 1, false, true, false, false, |
| 1265 |
rs6000_handle_altivec_attribute, NULL }, |
| 1266 |
{ "longcall", 0, 0, false, true, true, false, |
| 1267 |
rs6000_handle_longcall_attribute, NULL }, |
| 1268 |
{ "shortcall", 0, 0, false, true, true, false, |
| 1269 |
rs6000_handle_longcall_attribute, NULL }, |
| 1270 |
{ "ms_struct", 0, 0, false, false, false, false, |
| 1271 |
rs6000_handle_struct_attribute, NULL }, |
| 1272 |
{ "gcc_struct", 0, 0, false, false, false, false, |
| 1273 |
rs6000_handle_struct_attribute, NULL }, |
| 1274 |
#ifdef SUBTARGET_ATTRIBUTE_TABLE |
| 1275 |
SUBTARGET_ATTRIBUTE_TABLE, |
| 1276 |
#endif |
| 1277 |
}; |
| 1278 |
|
| 1279 |
static const scoped_attribute_specs rs6000_gnu_attribute_table = |
| 1280 |
{ |
| 1281 |
"gnu", { rs6000_gnu_attributes } |
| 1282 |
}; |
| 1283 |
|
| 1284 |
static const scoped_attribute_specs *const rs6000_attribute_table[] = |
| 1285 |
{ |
| 1286 |
&rs6000_gnu_attribute_table |
| 1287 |
}; |
| 1288 |
|
| 1289 |
#ifndef TARGET_PROFILE_KERNEL |
| 1290 |
#define TARGET_PROFILE_KERNEL 0 |
| 1291 |
#endif |
| 1292 |
|
| 1293 |
/* Initialize the GCC target structure. */ |
| 1294 |
#undef TARGET_ATTRIBUTE_TABLE |
| 1295 |
#define TARGET_ATTRIBUTE_TABLE rs6000_attribute_table |
| 1296 |
#undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES |
| 1297 |
#define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES rs6000_set_default_type_attributes |
| 1298 |
#undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P |
| 1299 |
#define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P rs6000_attribute_takes_identifier_p |
| 1300 |
|
| 1301 |
#undef TARGET_ASM_ALIGNED_DI_OP |
| 1302 |
#define TARGET_ASM_ALIGNED_DI_OP DOUBLE_INT_ASM_OP |
| 1303 |
|
| 1304 |
/* Default unaligned ops are only provided for ELF. Find the ops needed |
| 1305 |
for non-ELF systems. */ |
| 1306 |
#ifndef OBJECT_FORMAT_ELF |
| 1307 |
#if TARGET_XCOFF |
| 1308 |
/* For XCOFF. rs6000_assemble_integer will handle unaligned DIs on |
| 1309 |
64-bit targets. */ |
| 1310 |
#undef TARGET_ASM_UNALIGNED_HI_OP |
| 1311 |
#define TARGET_ASM_UNALIGNED_HI_OP "\t.vbyte\t2," |
| 1312 |
#undef TARGET_ASM_UNALIGNED_SI_OP |
| 1313 |
#define TARGET_ASM_UNALIGNED_SI_OP "\t.vbyte\t4," |
| 1314 |
#undef TARGET_ASM_UNALIGNED_DI_OP |
| 1315 |
#define TARGET_ASM_UNALIGNED_DI_OP "\t.vbyte\t8," |
| 1316 |
#else |
| 1317 |
/* For Darwin. */ |
| 1318 |
#undef TARGET_ASM_UNALIGNED_HI_OP |
| 1319 |
#define TARGET_ASM_UNALIGNED_HI_OP "\t.short\t" |
| 1320 |
#undef TARGET_ASM_UNALIGNED_SI_OP |
| 1321 |
#define TARGET_ASM_UNALIGNED_SI_OP "\t.long\t" |
| 1322 |
#undef TARGET_ASM_UNALIGNED_DI_OP |
| 1323 |
#define TARGET_ASM_UNALIGNED_DI_OP "\t.quad\t" |
| 1324 |
#undef TARGET_ASM_ALIGNED_DI_OP |
| 1325 |
#define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t" |
| 1326 |
#endif |
| 1327 |
#endif |
| 1328 |
|
| 1329 |
/* This hook deals with fixups for relocatable code and DI-mode objects |
| 1330 |
in 64-bit code. */ |
| 1331 |
#undef TARGET_ASM_INTEGER |
| 1332 |
#define TARGET_ASM_INTEGER rs6000_assemble_integer |
| 1333 |
|
| 1334 |
#if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO |
| 1335 |
#undef TARGET_ASM_ASSEMBLE_VISIBILITY |
| 1336 |
#define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility |
| 1337 |
#endif |
| 1338 |
|
| 1339 |
#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY |
| 1340 |
#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY \ |
| 1341 |
rs6000_print_patchable_function_entry |
| 1342 |
|
| 1343 |
#undef TARGET_SET_UP_BY_PROLOGUE |
| 1344 |
#define TARGET_SET_UP_BY_PROLOGUE rs6000_set_up_by_prologue |
| 1345 |
|
| 1346 |
#undef TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS |
| 1347 |
#define TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS rs6000_get_separate_components |
| 1348 |
#undef TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB |
| 1349 |
#define TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB rs6000_components_for_bb |
| 1350 |
#undef TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS |
| 1351 |
#define TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS rs6000_disqualify_components |
| 1352 |
#undef TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS |
| 1353 |
#define TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS rs6000_emit_prologue_components |
| 1354 |
#undef TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS |
| 1355 |
#define TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS rs6000_emit_epilogue_components |
| 1356 |
#undef TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS |
| 1357 |
#define TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS rs6000_set_handled_components |
| 1358 |
|
| 1359 |
#undef TARGET_EXTRA_LIVE_ON_ENTRY |
| 1360 |
#define TARGET_EXTRA_LIVE_ON_ENTRY rs6000_live_on_entry |
| 1361 |
|
| 1362 |
#undef TARGET_INTERNAL_ARG_POINTER |
| 1363 |
#define TARGET_INTERNAL_ARG_POINTER rs6000_internal_arg_pointer |
| 1364 |
|
| 1365 |
#undef TARGET_HAVE_TLS |
| 1366 |
#define TARGET_HAVE_TLS HAVE_AS_TLS |
| 1367 |
|
| 1368 |
#undef TARGET_CANNOT_FORCE_CONST_MEM |
| 1369 |
#define TARGET_CANNOT_FORCE_CONST_MEM rs6000_cannot_force_const_mem |
| 1370 |
|
| 1371 |
#undef TARGET_DELEGITIMIZE_ADDRESS |
| 1372 |
#define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address |
| 1373 |
|
| 1374 |
#undef TARGET_CONST_NOT_OK_FOR_DEBUG_P |
| 1375 |
#define TARGET_CONST_NOT_OK_FOR_DEBUG_P rs6000_const_not_ok_for_debug_p |
| 1376 |
|
| 1377 |
#undef TARGET_LEGITIMATE_COMBINED_INSN |
| 1378 |
#define TARGET_LEGITIMATE_COMBINED_INSN rs6000_legitimate_combined_insn |
| 1379 |
|
| 1380 |
#undef TARGET_ASM_FUNCTION_PROLOGUE |
| 1381 |
#define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue |
| 1382 |
#undef TARGET_ASM_FUNCTION_EPILOGUE |
| 1383 |
#define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue |
| 1384 |
|
| 1385 |
#undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA |
| 1386 |
#define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA rs6000_output_addr_const_extra |
| 1387 |
|
| 1388 |
#undef TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC |
| 1389 |
#define TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC rs6000_gen_pic_addr_diff_vec |
| 1390 |
|
| 1391 |
#undef TARGET_LEGITIMIZE_ADDRESS |
| 1392 |
#define TARGET_LEGITIMIZE_ADDRESS rs6000_legitimize_address |
| 1393 |
|
| 1394 |
#undef TARGET_SCHED_VARIABLE_ISSUE |
| 1395 |
#define TARGET_SCHED_VARIABLE_ISSUE rs6000_variable_issue |
| 1396 |
|
| 1397 |
#undef TARGET_SCHED_ISSUE_RATE |
| 1398 |
#define TARGET_SCHED_ISSUE_RATE rs6000_issue_rate |
| 1399 |
#undef TARGET_SCHED_ADJUST_COST |
| 1400 |
#define TARGET_SCHED_ADJUST_COST rs6000_adjust_cost |
| 1401 |
#undef TARGET_SCHED_ADJUST_PRIORITY |
| 1402 |
#define TARGET_SCHED_ADJUST_PRIORITY rs6000_adjust_priority |
| 1403 |
#undef TARGET_SCHED_IS_COSTLY_DEPENDENCE |
| 1404 |
#define TARGET_SCHED_IS_COSTLY_DEPENDENCE rs6000_is_costly_dependence |
| 1405 |
#undef TARGET_SCHED_INIT |
| 1406 |
#define TARGET_SCHED_INIT rs6000_sched_init |
| 1407 |
#undef TARGET_SCHED_FINISH |
| 1408 |
#define TARGET_SCHED_FINISH rs6000_sched_finish |
| 1409 |
#undef TARGET_SCHED_REORDER |
| 1410 |
#define TARGET_SCHED_REORDER rs6000_sched_reorder |
| 1411 |
#undef TARGET_SCHED_REORDER2 |
| 1412 |
#define TARGET_SCHED_REORDER2 rs6000_sched_reorder2 |
| 1413 |
|
| 1414 |
#undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD |
| 1415 |
#define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD rs6000_use_sched_lookahead |
| 1416 |
|
| 1417 |
#undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD |
| 1418 |
#define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD rs6000_use_sched_lookahead_guard |
| 1419 |
|
| 1420 |
#undef TARGET_SCHED_ALLOC_SCHED_CONTEXT |
| 1421 |
#define TARGET_SCHED_ALLOC_SCHED_CONTEXT rs6000_alloc_sched_context |
| 1422 |
#undef TARGET_SCHED_INIT_SCHED_CONTEXT |
| 1423 |
#define TARGET_SCHED_INIT_SCHED_CONTEXT rs6000_init_sched_context |
| 1424 |
#undef TARGET_SCHED_SET_SCHED_CONTEXT |
| 1425 |
#define TARGET_SCHED_SET_SCHED_CONTEXT rs6000_set_sched_context |
| 1426 |
#undef TARGET_SCHED_FREE_SCHED_CONTEXT |
| 1427 |
#define TARGET_SCHED_FREE_SCHED_CONTEXT rs6000_free_sched_context |
| 1428 |
|
| 1429 |
#undef TARGET_SCHED_CAN_SPECULATE_INSN |
| 1430 |
#define TARGET_SCHED_CAN_SPECULATE_INSN rs6000_sched_can_speculate_insn |
| 1431 |
|
| 1432 |
#undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD |
| 1433 |
#define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load |
| 1434 |
#undef TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT |
| 1435 |
#define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \ |
| 1436 |
rs6000_builtin_support_vector_misalignment |
| 1437 |
#undef TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE |
| 1438 |
#define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable |
| 1439 |
#undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST |
| 1440 |
#define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \ |
| 1441 |
rs6000_builtin_vectorization_cost |
| 1442 |
#undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE |
| 1443 |
#define TARGET_VECTORIZE_PREFERRED_SIMD_MODE \ |
| 1444 |
rs6000_preferred_simd_mode |
| 1445 |
#undef TARGET_VECTORIZE_CREATE_COSTS |
| 1446 |
#define TARGET_VECTORIZE_CREATE_COSTS rs6000_vectorize_create_costs |
| 1447 |
|
| 1448 |
#undef TARGET_LOOP_UNROLL_ADJUST |
| 1449 |
#define TARGET_LOOP_UNROLL_ADJUST rs6000_loop_unroll_adjust |
| 1450 |
|
| 1451 |
#undef TARGET_INIT_BUILTINS |
| 1452 |
#define TARGET_INIT_BUILTINS rs6000_init_builtins |
| 1453 |
#undef TARGET_BUILTIN_DECL |
| 1454 |
#define TARGET_BUILTIN_DECL rs6000_builtin_decl |
| 1455 |
|
| 1456 |
#undef TARGET_FOLD_BUILTIN |
| 1457 |
#define TARGET_FOLD_BUILTIN rs6000_fold_builtin |
| 1458 |
#undef TARGET_GIMPLE_FOLD_BUILTIN |
| 1459 |
#define TARGET_GIMPLE_FOLD_BUILTIN rs6000_gimple_fold_builtin |
| 1460 |
|
| 1461 |
#undef TARGET_EXPAND_BUILTIN |
| 1462 |
#define TARGET_EXPAND_BUILTIN rs6000_expand_builtin |
| 1463 |
|
| 1464 |
#undef TARGET_MANGLE_TYPE |
| 1465 |
#define TARGET_MANGLE_TYPE rs6000_mangle_type |
| 1466 |
|
| 1467 |
#undef TARGET_INIT_LIBFUNCS |
| 1468 |
#define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs |
| 1469 |
|
| 1470 |
#if TARGET_MACHO |
| 1471 |
#undef TARGET_BINDS_LOCAL_P |
| 1472 |
#define TARGET_BINDS_LOCAL_P darwin_binds_local_p |
| 1473 |
#endif |
| 1474 |
|
| 1475 |
#undef TARGET_MS_BITFIELD_LAYOUT_P |
| 1476 |
#define TARGET_MS_BITFIELD_LAYOUT_P rs6000_ms_bitfield_layout_p |
| 1477 |
|
| 1478 |
#undef TARGET_ASM_OUTPUT_MI_THUNK |
| 1479 |
#define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk |
| 1480 |
|
| 1481 |
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK |
| 1482 |
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true |
| 1483 |
|
| 1484 |
#undef TARGET_FUNCTION_OK_FOR_SIBCALL |
| 1485 |
#define TARGET_FUNCTION_OK_FOR_SIBCALL rs6000_function_ok_for_sibcall |
| 1486 |
|
| 1487 |
#undef TARGET_REGISTER_MOVE_COST |
| 1488 |
#define TARGET_REGISTER_MOVE_COST rs6000_register_move_cost |
| 1489 |
#undef TARGET_MEMORY_MOVE_COST |
| 1490 |
#define TARGET_MEMORY_MOVE_COST rs6000_memory_move_cost |
| 1491 |
#undef TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS |
| 1492 |
#define TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS \ |
| 1493 |
rs6000_ira_change_pseudo_allocno_class |
| 1494 |
#undef TARGET_CANNOT_COPY_INSN_P |
| 1495 |
#define TARGET_CANNOT_COPY_INSN_P rs6000_cannot_copy_insn_p |
| 1496 |
#undef TARGET_RTX_COSTS |
| 1497 |
#define TARGET_RTX_COSTS rs6000_rtx_costs |
| 1498 |
#undef TARGET_ADDRESS_COST |
| 1499 |
#define TARGET_ADDRESS_COST hook_int_rtx_mode_as_bool_0 |
| 1500 |
#undef TARGET_INSN_COST |
| 1501 |
#define TARGET_INSN_COST rs6000_insn_cost |
| 1502 |
|
| 1503 |
#undef TARGET_INIT_DWARF_REG_SIZES_EXTRA |
| 1504 |
#define TARGET_INIT_DWARF_REG_SIZES_EXTRA rs6000_init_dwarf_reg_sizes_extra |
| 1505 |
|
| 1506 |
#undef TARGET_PROMOTE_FUNCTION_MODE |
| 1507 |
#define TARGET_PROMOTE_FUNCTION_MODE rs6000_promote_function_mode |
| 1508 |
|
| 1509 |
#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE |
| 1510 |
#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE rs6000_override_options_after_change |
| 1511 |
|
| 1512 |
#undef TARGET_RETURN_IN_MEMORY |
| 1513 |
#define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory |
| 1514 |
|
| 1515 |
#undef TARGET_RETURN_IN_MSB |
| 1516 |
#define TARGET_RETURN_IN_MSB rs6000_return_in_msb |
| 1517 |
|
| 1518 |
#undef TARGET_SETUP_INCOMING_VARARGS |
| 1519 |
#define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs |
| 1520 |
|
| 1521 |
/* Always strict argument naming on rs6000. */ |
| 1522 |
#undef TARGET_STRICT_ARGUMENT_NAMING |
| 1523 |
#define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true |
| 1524 |
#undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED |
| 1525 |
#define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true |
| 1526 |
#undef TARGET_SPLIT_COMPLEX_ARG |
| 1527 |
#define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true |
| 1528 |
#undef TARGET_MUST_PASS_IN_STACK |
| 1529 |
#define TARGET_MUST_PASS_IN_STACK rs6000_must_pass_in_stack |
| 1530 |
#undef TARGET_PASS_BY_REFERENCE |
| 1531 |
#define TARGET_PASS_BY_REFERENCE rs6000_pass_by_reference |
| 1532 |
#undef TARGET_ARG_PARTIAL_BYTES |
| 1533 |
#define TARGET_ARG_PARTIAL_BYTES rs6000_arg_partial_bytes |
| 1534 |
#undef TARGET_FUNCTION_ARG_ADVANCE |
| 1535 |
#define TARGET_FUNCTION_ARG_ADVANCE rs6000_function_arg_advance |
| 1536 |
#undef TARGET_FUNCTION_ARG |
| 1537 |
#define TARGET_FUNCTION_ARG rs6000_function_arg |
| 1538 |
#undef TARGET_FUNCTION_ARG_PADDING |
| 1539 |
#define TARGET_FUNCTION_ARG_PADDING rs6000_function_arg_padding |
| 1540 |
#undef TARGET_FUNCTION_ARG_BOUNDARY |
| 1541 |
#define TARGET_FUNCTION_ARG_BOUNDARY rs6000_function_arg_boundary |
| 1542 |
|
| 1543 |
#undef TARGET_BUILD_BUILTIN_VA_LIST |
| 1544 |
#define TARGET_BUILD_BUILTIN_VA_LIST rs6000_build_builtin_va_list |
| 1545 |
|
| 1546 |
#undef TARGET_EXPAND_BUILTIN_VA_START |
| 1547 |
#define TARGET_EXPAND_BUILTIN_VA_START rs6000_va_start |
| 1548 |
|
| 1549 |
#undef TARGET_GIMPLIFY_VA_ARG_EXPR |
| 1550 |
#define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg |
| 1551 |
|
| 1552 |
#undef TARGET_EH_RETURN_FILTER_MODE |
| 1553 |
#define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode |
| 1554 |
|
| 1555 |
#undef TARGET_TRANSLATE_MODE_ATTRIBUTE |
| 1556 |
#define TARGET_TRANSLATE_MODE_ATTRIBUTE rs6000_translate_mode_attribute |
| 1557 |
|
| 1558 |
#undef TARGET_SCALAR_MODE_SUPPORTED_P |
| 1559 |
#define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p |
| 1560 |
|
| 1561 |
#undef TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P |
| 1562 |
#define TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P \ |
| 1563 |
rs6000_libgcc_floating_mode_supported_p |
| 1564 |
|
| 1565 |
#undef TARGET_VECTOR_MODE_SUPPORTED_P |
| 1566 |
#define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p |
| 1567 |
|
| 1568 |
#undef TARGET_FLOATN_MODE |
| 1569 |
#define TARGET_FLOATN_MODE rs6000_floatn_mode |
| 1570 |
|
| 1571 |
#undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN |
| 1572 |
#define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn |
| 1573 |
|
| 1574 |
#undef TARGET_MD_ASM_ADJUST |
| 1575 |
#define TARGET_MD_ASM_ADJUST rs6000_md_asm_adjust |
| 1576 |
|
| 1577 |
#undef TARGET_OPTION_OVERRIDE |
| 1578 |
#define TARGET_OPTION_OVERRIDE rs6000_option_override |
| 1579 |
|
| 1580 |
#undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION |
| 1581 |
#define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \ |
| 1582 |
rs6000_builtin_vectorized_function |
| 1583 |
|
| 1584 |
#undef TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION |
| 1585 |
#define TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION \ |
| 1586 |
rs6000_builtin_md_vectorized_function |
| 1587 |
|
| 1588 |
#undef TARGET_STACK_PROTECT_GUARD |
| 1589 |
#define TARGET_STACK_PROTECT_GUARD rs6000_init_stack_protect_guard |
| 1590 |
|
| 1591 |
#if !TARGET_MACHO |
| 1592 |
#undef TARGET_STACK_PROTECT_FAIL |
| 1593 |
#define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail |
| 1594 |
#endif |
| 1595 |
|
| 1596 |
#ifdef HAVE_AS_TLS |
| 1597 |
#undef TARGET_ASM_OUTPUT_DWARF_DTPREL |
| 1598 |
#define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel |
| 1599 |
#endif |
| 1600 |
|
| 1601 |
/* Use a 32-bit anchor range. This leads to sequences like: |
| 1602 |
|
| 1603 |
addis tmp,anchor,high |
| 1604 |
add dest,tmp,low |
| 1605 |
|
| 1606 |
where tmp itself acts as an anchor, and can be shared between |
| 1607 |
accesses to the same 64k page. */ |
| 1608 |
#undef TARGET_MIN_ANCHOR_OFFSET |
| 1609 |
#define TARGET_MIN_ANCHOR_OFFSET -0x7fffffff - 1 |
| 1610 |
#undef TARGET_MAX_ANCHOR_OFFSET |
| 1611 |
#define TARGET_MAX_ANCHOR_OFFSET 0x7fffffff |
| 1612 |
#undef TARGET_USE_BLOCKS_FOR_CONSTANT_P |
| 1613 |
#define TARGET_USE_BLOCKS_FOR_CONSTANT_P rs6000_use_blocks_for_constant_p |
| 1614 |
#undef TARGET_USE_BLOCKS_FOR_DECL_P |
| 1615 |
#define TARGET_USE_BLOCKS_FOR_DECL_P rs6000_use_blocks_for_decl_p |
| 1616 |
|
| 1617 |
#undef TARGET_BUILTIN_RECIPROCAL |
| 1618 |
#define TARGET_BUILTIN_RECIPROCAL rs6000_builtin_reciprocal |
| 1619 |
|
| 1620 |
#undef TARGET_SECONDARY_RELOAD |
| 1621 |
#define TARGET_SECONDARY_RELOAD rs6000_secondary_reload |
| 1622 |
#undef TARGET_SECONDARY_MEMORY_NEEDED |
| 1623 |
#define TARGET_SECONDARY_MEMORY_NEEDED rs6000_secondary_memory_needed |
| 1624 |
#undef TARGET_SECONDARY_MEMORY_NEEDED_MODE |
| 1625 |
#define TARGET_SECONDARY_MEMORY_NEEDED_MODE rs6000_secondary_memory_needed_mode |
| 1626 |
|
| 1627 |
#undef TARGET_LEGITIMATE_ADDRESS_P |
| 1628 |
#define TARGET_LEGITIMATE_ADDRESS_P rs6000_legitimate_address_p |
| 1629 |
|
| 1630 |
#undef TARGET_MODE_DEPENDENT_ADDRESS_P |
| 1631 |
#define TARGET_MODE_DEPENDENT_ADDRESS_P rs6000_mode_dependent_address_p |
| 1632 |
|
| 1633 |
#undef TARGET_COMPUTE_PRESSURE_CLASSES |
| 1634 |
#define TARGET_COMPUTE_PRESSURE_CLASSES rs6000_compute_pressure_classes |
| 1635 |
|
| 1636 |
#undef TARGET_CAN_ELIMINATE |
| 1637 |
#define TARGET_CAN_ELIMINATE rs6000_can_eliminate |
| 1638 |
|
| 1639 |
#undef TARGET_CONDITIONAL_REGISTER_USAGE |
| 1640 |
#define TARGET_CONDITIONAL_REGISTER_USAGE rs6000_conditional_register_usage |
| 1641 |
|
| 1642 |
#undef TARGET_SCHED_REASSOCIATION_WIDTH |
| 1643 |
#define TARGET_SCHED_REASSOCIATION_WIDTH rs6000_reassociation_width |
| 1644 |
|
| 1645 |
#undef TARGET_TRAMPOLINE_INIT |
| 1646 |
#define TARGET_TRAMPOLINE_INIT rs6000_trampoline_init |
| 1647 |
|
| 1648 |
#undef TARGET_FUNCTION_VALUE |
| 1649 |
#define TARGET_FUNCTION_VALUE rs6000_function_value |
| 1650 |
|
| 1651 |
#undef TARGET_OPTION_VALID_ATTRIBUTE_P |
| 1652 |
#define TARGET_OPTION_VALID_ATTRIBUTE_P rs6000_valid_attribute_p |
| 1653 |
|
| 1654 |
#undef TARGET_OPTION_SAVE |
| 1655 |
#define TARGET_OPTION_SAVE rs6000_function_specific_save |
| 1656 |
|
| 1657 |
#undef TARGET_OPTION_RESTORE |
| 1658 |
#define TARGET_OPTION_RESTORE rs6000_function_specific_restore |
| 1659 |
|
| 1660 |
#undef TARGET_OPTION_PRINT |
| 1661 |
#define TARGET_OPTION_PRINT rs6000_function_specific_print |
| 1662 |
|
| 1663 |
#undef TARGET_CAN_INLINE_P |
| 1664 |
#define TARGET_CAN_INLINE_P rs6000_can_inline_p |
| 1665 |
|
| 1666 |
#undef TARGET_SET_CURRENT_FUNCTION |
| 1667 |
#define TARGET_SET_CURRENT_FUNCTION rs6000_set_current_function |
| 1668 |
|
| 1669 |
#undef TARGET_LEGITIMATE_CONSTANT_P |
| 1670 |
#define TARGET_LEGITIMATE_CONSTANT_P rs6000_legitimate_constant_p |
| 1671 |
|
| 1672 |
#undef TARGET_VECTORIZE_VEC_PERM_CONST |
| 1673 |
#define TARGET_VECTORIZE_VEC_PERM_CONST rs6000_vectorize_vec_perm_const |
| 1674 |
|
| 1675 |
#undef TARGET_CAN_USE_DOLOOP_P |
| 1676 |
#define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost |
| 1677 |
|
| 1678 |
#undef TARGET_PREDICT_DOLOOP_P |
| 1679 |
#define TARGET_PREDICT_DOLOOP_P rs6000_predict_doloop_p |
| 1680 |
|
| 1681 |
#undef TARGET_HAVE_COUNT_REG_DECR_P |
| 1682 |
#define TARGET_HAVE_COUNT_REG_DECR_P true |
| 1683 |
|
| 1684 |
/* 1000000000 is infinite cost in IVOPTs. */ |
| 1685 |
#undef TARGET_DOLOOP_COST_FOR_GENERIC |
| 1686 |
#define TARGET_DOLOOP_COST_FOR_GENERIC 1000000000 |
| 1687 |
|
| 1688 |
#undef TARGET_DOLOOP_COST_FOR_ADDRESS |
| 1689 |
#define TARGET_DOLOOP_COST_FOR_ADDRESS 1000000000 |
| 1690 |
|
| 1691 |
#undef TARGET_PREFERRED_DOLOOP_MODE |
| 1692 |
#define TARGET_PREFERRED_DOLOOP_MODE rs6000_preferred_doloop_mode |
| 1693 |
|
| 1694 |
#undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV |
| 1695 |
#define TARGET_ATOMIC_ASSIGN_EXPAND_FENV rs6000_atomic_assign_expand_fenv |
| 1696 |
|
| 1697 |
#undef TARGET_LIBGCC_CMP_RETURN_MODE |
| 1698 |
#define TARGET_LIBGCC_CMP_RETURN_MODE rs6000_abi_word_mode |
| 1699 |
#undef TARGET_LIBGCC_SHIFT_COUNT_MODE |
| 1700 |
#define TARGET_LIBGCC_SHIFT_COUNT_MODE rs6000_abi_word_mode |
| 1701 |
#undef TARGET_UNWIND_WORD_MODE |
| 1702 |
#define TARGET_UNWIND_WORD_MODE rs6000_abi_word_mode |
| 1703 |
|
| 1704 |
#undef TARGET_OFFLOAD_OPTIONS |
| 1705 |
#define TARGET_OFFLOAD_OPTIONS rs6000_offload_options |
| 1706 |
|
| 1707 |
#undef TARGET_C_MODE_FOR_SUFFIX |
| 1708 |
#define TARGET_C_MODE_FOR_SUFFIX rs6000_c_mode_for_suffix |
| 1709 |
|
| 1710 |
#undef TARGET_C_MODE_FOR_FLOATING_TYPE |
| 1711 |
#define TARGET_C_MODE_FOR_FLOATING_TYPE rs6000_c_mode_for_floating_type |
| 1712 |
|
| 1713 |
#undef TARGET_INVALID_BINARY_OP |
| 1714 |
#define TARGET_INVALID_BINARY_OP rs6000_invalid_binary_op |
| 1715 |
|
| 1716 |
#undef TARGET_OPTAB_SUPPORTED_P |
| 1717 |
#define TARGET_OPTAB_SUPPORTED_P rs6000_optab_supported_p |
| 1718 |
|
| 1719 |
#undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS |
| 1720 |
#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 1 |
| 1721 |
|
| 1722 |
#undef TARGET_COMPARE_VERSION_PRIORITY |
| 1723 |
#define TARGET_COMPARE_VERSION_PRIORITY rs6000_compare_version_priority |
| 1724 |
|
| 1725 |
#undef TARGET_GENERATE_VERSION_DISPATCHER_BODY |
| 1726 |
#define TARGET_GENERATE_VERSION_DISPATCHER_BODY \ |
| 1727 |
rs6000_generate_version_dispatcher_body |
| 1728 |
|
| 1729 |
#undef TARGET_GET_FUNCTION_VERSIONS_DISPATCHER |
| 1730 |
#define TARGET_GET_FUNCTION_VERSIONS_DISPATCHER \ |
| 1731 |
rs6000_get_function_versions_dispatcher |
| 1732 |
|
| 1733 |
#undef TARGET_OPTION_FUNCTION_VERSIONS |
| 1734 |
#define TARGET_OPTION_FUNCTION_VERSIONS common_function_versions |
| 1735 |
|
| 1736 |
#undef TARGET_HARD_REGNO_NREGS |
| 1737 |
#define TARGET_HARD_REGNO_NREGS rs6000_hard_regno_nregs_hook |
| 1738 |
#undef TARGET_HARD_REGNO_MODE_OK |
| 1739 |
#define TARGET_HARD_REGNO_MODE_OK rs6000_hard_regno_mode_ok |
| 1740 |
|
| 1741 |
#undef TARGET_MODES_TIEABLE_P |
| 1742 |
#define TARGET_MODES_TIEABLE_P rs6000_modes_tieable_p |
| 1743 |
|
| 1744 |
#undef TARGET_HARD_REGNO_CALL_PART_CLOBBERED |
| 1745 |
#define TARGET_HARD_REGNO_CALL_PART_CLOBBERED \ |
| 1746 |
rs6000_hard_regno_call_part_clobbered |
| 1747 |
|
| 1748 |
#undef TARGET_SLOW_UNALIGNED_ACCESS |
| 1749 |
#define TARGET_SLOW_UNALIGNED_ACCESS rs6000_slow_unaligned_access |
| 1750 |
|
| 1751 |
#undef TARGET_CAN_CHANGE_MODE_CLASS |
| 1752 |
#define TARGET_CAN_CHANGE_MODE_CLASS rs6000_can_change_mode_class |
| 1753 |
|
| 1754 |
#undef TARGET_REDZONE_CLOBBER |
| 1755 |
#define TARGET_REDZONE_CLOBBER rs6000_redzone_clobber |
| 1756 |
|
| 1757 |
#undef TARGET_CONSTANT_ALIGNMENT |
| 1758 |
#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment |
| 1759 |
|
| 1760 |
#undef TARGET_STARTING_FRAME_OFFSET |
| 1761 |
#define TARGET_STARTING_FRAME_OFFSET rs6000_starting_frame_offset |
| 1762 |
|
| 1763 |
#undef TARGET_SETJMP_PRESERVES_NONVOLATILE_REGS_P |
| 1764 |
#define TARGET_SETJMP_PRESERVES_NONVOLATILE_REGS_P hook_bool_void_true |
| 1765 |
|
| 1766 |
#undef TARGET_MANGLE_DECL_ASSEMBLER_NAME |
| 1767 |
#define TARGET_MANGLE_DECL_ASSEMBLER_NAME rs6000_mangle_decl_assembler_name |
| 1768 |
|
| 1769 |
#undef TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P |
| 1770 |
#define TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P \ |
| 1771 |
rs6000_cannot_substitute_mem_equiv_p |
| 1772 |
|
| 1773 |
#undef TARGET_INVALID_CONVERSION |
| 1774 |
#define TARGET_INVALID_CONVERSION rs6000_invalid_conversion |
| 1775 |
|
| 1776 |
#undef TARGET_NEED_IPA_FN_TARGET_INFO |
| 1777 |
#define TARGET_NEED_IPA_FN_TARGET_INFO rs6000_need_ipa_fn_target_info |
| 1778 |
|
| 1779 |
#undef TARGET_UPDATE_IPA_FN_TARGET_INFO |
| 1780 |
#define TARGET_UPDATE_IPA_FN_TARGET_INFO rs6000_update_ipa_fn_target_info |
| 1781 |
|
| 1782 |
#undef TARGET_CONST_ANCHOR |
| 1783 |
#define TARGET_CONST_ANCHOR 0x8000 |
| 1784 |
|
| 1785 |
#undef TARGET_OVERLAP_OP_BY_PIECES_P |
| 1786 |
#define TARGET_OVERLAP_OP_BY_PIECES_P hook_bool_void_true |
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
/* Processor table. */ |
| 1791 |
struct rs6000_ptt |
| 1792 |
{ |
| 1793 |
const char *const name; /* Canonical processor name. */ |
| 1794 |
const enum processor_type processor; /* Processor type enum value. */ |
| 1795 |
const HOST_WIDE_INT target_enable; /* Target flags to enable. */ |
| 1796 |
}; |
| 1797 |
|
| 1798 |
static struct rs6000_ptt const processor_target_table[] = |
| 1799 |
{ |
| 1800 |
#define RS6000_CPU(NAME, CPU, FLAGS) { NAME, CPU, FLAGS }, |
| 1801 |
#include "rs6000-cpus.def" |
| 1802 |
#undef RS6000_CPU |
| 1803 |
}; |
| 1804 |
|
| 1805 |
/* Look up a processor name for -mcpu=xxx and -mtune=xxx. Return -1 if the |
| 1806 |
name is invalid. */ |
| 1807 |
|
| 1808 |
static int |
| 1809 |
rs6000_cpu_name_lookup (const char *name) |
| 1810 |
{ |
| 1811 |
size_t i; |
| 1812 |
|
| 1813 |
if (name != NULL) |
| 1814 |
{ |
| 1815 |
for (i = 0; i < ARRAY_SIZE (processor_target_table); i++) |
| 1816 |
if (! strcmp (name, processor_target_table[i].name)) |
| 1817 |
return (int)i; |
| 1818 |
} |
| 1819 |
|
| 1820 |
return -1; |
| 1821 |
} |
| 1822 |
|
| 1823 |
|
| 1824 |
/* Return number of consecutive hard regs needed starting at reg REGNO |
| 1825 |
to hold something of mode MODE. |
| 1826 |
This is ordinarily the length in words of a value of mode MODE |
| 1827 |
but can be less for certain modes in special long registers. |
| 1828 |
|
| 1829 |
POWER and PowerPC GPRs hold 32 bits worth; |
| 1830 |
PowerPC64 GPRs and FPRs point register holds 64 bits worth. */ |
| 1831 |
|
| 1832 |
static int |
| 1833 |
rs6000_hard_regno_nregs_internal (int regno, machine_mode mode) |
| 1834 |
{ |
| 1835 |
unsigned HOST_WIDE_INT reg_size; |
| 1836 |
|
| 1837 |
/* 128-bit floating point usually takes 2 registers, unless it is IEEE |
| 1838 |
128-bit floating point that can go in vector registers, which has VSX |
| 1839 |
memory addressing. */ |
| 1840 |
if (FP_REGNO_P (regno)) |
| 1841 |
reg_size = (VECTOR_MEM_VSX_P (mode) || VECTOR_ALIGNMENT_P (mode) |
| 1842 |
? UNITS_PER_VSX_WORD |
| 1843 |
: UNITS_PER_FP_WORD); |
| 1844 |
|
| 1845 |
else if (ALTIVEC_REGNO_P (regno)) |
| 1846 |
reg_size = UNITS_PER_ALTIVEC_WORD; |
| 1847 |
|
| 1848 |
else |
| 1849 |
reg_size = UNITS_PER_WORD; |
| 1850 |
|
| 1851 |
return (GET_MODE_SIZE (mode) + reg_size - 1) / reg_size; |
| 1852 |
} |
| 1853 |
|
| 1854 |
/* Value is 1 if hard register REGNO can hold a value of machine-mode |
| 1855 |
MODE. */ |
| 1856 |
static int |
| 1857 |
rs6000_hard_regno_mode_ok_uncached (int regno, machine_mode mode) |
| 1858 |
{ |
| 1859 |
int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1; |
| 1860 |
|
| 1861 |
if (COMPLEX_MODE_P (mode)) |
| 1862 |
mode = GET_MODE_INNER (mode); |
| 1863 |
|
| 1864 |
/* Vector pair modes need even/odd VSX register pairs. Only allow vector |
| 1865 |
registers. */ |
| 1866 |
if (mode == OOmode) |
| 1867 |
return (TARGET_MMA && VSX_REGNO_P (regno) && (regno & 1) == 0); |
| 1868 |
|
| 1869 |
/* MMA accumulator modes need FPR registers divisible by 4. */ |
| 1870 |
if (mode == XOmode) |
| 1871 |
return (TARGET_MMA && FP_REGNO_P (regno) && (regno & 3) == 0); |
| 1872 |
|
| 1873 |
/* PTImode can only go in GPRs. Quad word memory operations require even/odd |
| 1874 |
register combinations, and use PTImode where we need to deal with quad |
| 1875 |
word memory operations. Don't allow quad words in the argument or frame |
| 1876 |
pointer registers, just registers 0..31. */ |
| 1877 |
if (mode == PTImode) |
| 1878 |
return (IN_RANGE (regno, FIRST_GPR_REGNO, LAST_GPR_REGNO) |
| 1879 |
&& IN_RANGE (last_regno, FIRST_GPR_REGNO, LAST_GPR_REGNO) |
| 1880 |
&& ((regno & 1) == 0)); |
| 1881 |
|
| 1882 |
/* VSX registers that overlap the FPR registers are larger than for non-VSX |
| 1883 |
implementations. Don't allow an item to be split between a FP register |
| 1884 |
and an Altivec register. Allow TImode in all VSX registers if the user |
| 1885 |
asked for it. */ |
| 1886 |
if (TARGET_VSX && VSX_REGNO_P (regno) |
| 1887 |
&& (VECTOR_MEM_VSX_P (mode) |
| 1888 |
|| VECTOR_ALIGNMENT_P (mode) |
| 1889 |
|| reg_addr[mode].scalar_in_vmx_p |
| 1890 |
|| mode == TImode |
| 1891 |
|| (TARGET_VADDUQM && mode == V1TImode))) |
| 1892 |
{ |
| 1893 |
if (FP_REGNO_P (regno)) |
| 1894 |
return FP_REGNO_P (last_regno); |
| 1895 |
|
| 1896 |
if (ALTIVEC_REGNO_P (regno)) |
| 1897 |
{ |
| 1898 |
if (GET_MODE_SIZE (mode) < 16 && !reg_addr[mode].scalar_in_vmx_p) |
| 1899 |
return 0; |
| 1900 |
|
| 1901 |
return ALTIVEC_REGNO_P (last_regno); |
| 1902 |
} |
| 1903 |
} |
| 1904 |
|
| 1905 |
/* The GPRs can hold any mode, but values bigger than one register |
| 1906 |
cannot go past R31. */ |
| 1907 |
if (INT_REGNO_P (regno)) |
| 1908 |
return INT_REGNO_P (last_regno); |
| 1909 |
|
| 1910 |
/* The float registers (except for VSX vector modes) can only hold floating |
| 1911 |
modes and DImode. */ |
| 1912 |
if (FP_REGNO_P (regno)) |
| 1913 |
{ |
| 1914 |
if (VECTOR_ALIGNMENT_P (mode)) |
| 1915 |
return false; |
| 1916 |
|
| 1917 |
if (SCALAR_FLOAT_MODE_P (mode) |
| 1918 |
&& (mode != TDmode || (regno % 2) == 0) |
| 1919 |
&& FP_REGNO_P (last_regno)) |
| 1920 |
return 1; |
| 1921 |
|
| 1922 |
if (GET_MODE_CLASS (mode) == MODE_INT) |
| 1923 |
{ |
| 1924 |
if(GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD) |
| 1925 |
return 1; |
| 1926 |
|
| 1927 |
if (TARGET_POPCNTD && mode == SImode) |
| 1928 |
return 1; |
| 1929 |
|
| 1930 |
if (TARGET_P9_VECTOR && (mode == QImode || mode == HImode)) |
| 1931 |
return 1; |
| 1932 |
} |
| 1933 |
|
| 1934 |
return 0; |
| 1935 |
} |
| 1936 |
|
| 1937 |
/* The CR register can only hold CC modes. */ |
| 1938 |
if (CR_REGNO_P (regno)) |
| 1939 |
return GET_MODE_CLASS (mode) == MODE_CC; |
| 1940 |
|
| 1941 |
if (CA_REGNO_P (regno)) |
| 1942 |
return mode == Pmode || mode == SImode; |
| 1943 |
|
| 1944 |
/* AltiVec only in AldyVec registers. */ |
| 1945 |
if (ALTIVEC_REGNO_P (regno)) |
| 1946 |
return (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode) |
| 1947 |
|| mode == V1TImode); |
| 1948 |
|
| 1949 |
/* We cannot put non-VSX TImode or PTImode anywhere except general register |
| 1950 |
and it must be able to fit within the register set. */ |
| 1951 |
|
| 1952 |
return GET_MODE_SIZE (mode) <= UNITS_PER_WORD; |
| 1953 |
} |
| 1954 |
|
| 1955 |
/* Implement TARGET_HARD_REGNO_NREGS. */ |
| 1956 |
|
| 1957 |
static unsigned int |
| 1958 |
rs6000_hard_regno_nregs_hook (unsigned int regno, machine_mode mode) |
| 1959 |
{ |
| 1960 |
return rs6000_hard_regno_nregs[mode][regno]; |
| 1961 |
} |
| 1962 |
|
| 1963 |
/* Implement TARGET_HARD_REGNO_MODE_OK. */ |
| 1964 |
|
| 1965 |
static bool |
| 1966 |
rs6000_hard_regno_mode_ok (unsigned int regno, machine_mode mode) |
| 1967 |
{ |
| 1968 |
return rs6000_hard_regno_mode_ok_p[mode][regno]; |
| 1969 |
} |
| 1970 |
|
| 1971 |
/* Implement TARGET_MODES_TIEABLE_P. |
| 1972 |
|
| 1973 |
PTImode cannot tie with other modes because PTImode is restricted to even |
| 1974 |
GPR registers, and TImode can go in any GPR as well as VSX registers (PR |
| 1975 |
57744). |
| 1976 |
|
| 1977 |
Similarly, don't allow OOmode (vector pair, restricted to even VSX |
| 1978 |
registers) or XOmode (vector quad, restricted to FPR registers divisible |
| 1979 |
by 4) to tie with other modes. |
| 1980 |
|
| 1981 |
Altivec/VSX vector tests were moved ahead of scalar float mode, so that IEEE |
| 1982 |
128-bit floating point on VSX systems ties with other vectors. */ |
| 1983 |
|
| 1984 |
static bool |
| 1985 |
rs6000_modes_tieable_p (machine_mode mode1, machine_mode mode2) |
| 1986 |
{ |
| 1987 |
if (mode1 == PTImode || mode1 == OOmode || mode1 == XOmode |
| 1988 |
|| mode2 == PTImode || mode2 == OOmode || mode2 == XOmode) |
| 1989 |
return mode1 == mode2; |
| 1990 |
|
| 1991 |
if (ALTIVEC_OR_VSX_VECTOR_MODE (mode1)) |
| 1992 |
return ALTIVEC_OR_VSX_VECTOR_MODE (mode2); |
| 1993 |
if (ALTIVEC_OR_VSX_VECTOR_MODE (mode2)) |
| 1994 |
return false; |
| 1995 |
|
| 1996 |
if (SCALAR_FLOAT_MODE_P (mode1)) |
| 1997 |
return SCALAR_FLOAT_MODE_P (mode2); |
| 1998 |
if (SCALAR_FLOAT_MODE_P (mode2)) |
| 1999 |
return false; |
| 2000 |
|
| 2001 |
if (GET_MODE_CLASS (mode1) == MODE_CC) |
| 2002 |
return GET_MODE_CLASS (mode2) == MODE_CC; |
| 2003 |
if (GET_MODE_CLASS (mode2) == MODE_CC) |
| 2004 |
return false; |
| 2005 |
|
| 2006 |
return true; |
| 2007 |
} |
| 2008 |
|
| 2009 |
/* Implement TARGET_HARD_REGNO_CALL_PART_CLOBBERED. */ |
| 2010 |
|
| 2011 |
static bool |
| 2012 |
rs6000_hard_regno_call_part_clobbered (unsigned int, unsigned int regno, |
| 2013 |
machine_mode mode) |
| 2014 |
{ |
| 2015 |
if (TARGET_32BIT |
| 2016 |
&& TARGET_POWERPC64 |
| 2017 |
&& GET_MODE_SIZE (mode) > 4 |
| 2018 |
&& INT_REGNO_P (regno)) |
| 2019 |
return true; |
| 2020 |
|
| 2021 |
if (TARGET_VSX |
| 2022 |
&& FP_REGNO_P (regno) |
| 2023 |
&& GET_MODE_SIZE (mode) > 8 |
| 2024 |
&& !FLOAT128_2REG_P (mode)) |
| 2025 |
return true; |
| 2026 |
|
| 2027 |
return false; |
| 2028 |
} |
| 2029 |
|
| 2030 |
/* Print interesting facts about registers. */ |
| 2031 |
static void |
| 2032 |
rs6000_debug_reg_print (int first_regno, int last_regno, const char *reg_name) |
| 2033 |
{ |
| 2034 |
int r, m; |
| 2035 |
|
| 2036 |
for (r = first_regno; r <= last_regno; ++r) |
| 2037 |
{ |
| 2038 |
const char *comma = ""; |
| 2039 |
int len; |
| 2040 |
|
| 2041 |
if (first_regno == last_regno) |
| 2042 |
fprintf (stderr, "%s:\t", reg_name); |
| 2043 |
else |
| 2044 |
fprintf (stderr, "%s%d:\t", reg_name, r - first_regno); |
| 2045 |
|
| 2046 |
len = 8; |
| 2047 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 2048 |
if (rs6000_hard_regno_mode_ok_p[m][r] && rs6000_hard_regno_nregs[m][r]) |
| 2049 |
{ |
| 2050 |
if (len > 70) |
| 2051 |
{ |
| 2052 |
fprintf (stderr, ",\n\t"); |
| 2053 |
len = 8; |
| 2054 |
comma = ""; |
| 2055 |
} |
| 2056 |
|
| 2057 |
if (rs6000_hard_regno_nregs[m][r] > 1) |
| 2058 |
len += fprintf (stderr, "%s%s/%d", comma, GET_MODE_NAME (m), |
| 2059 |
rs6000_hard_regno_nregs[m][r]); |
| 2060 |
else |
| 2061 |
len += fprintf (stderr, "%s%s", comma, GET_MODE_NAME (m)); |
| 2062 |
|
| 2063 |
comma = ", "; |
| 2064 |
} |
| 2065 |
|
| 2066 |
if (call_used_or_fixed_reg_p (r)) |
| 2067 |
{ |
| 2068 |
if (len > 70) |
| 2069 |
{ |
| 2070 |
fprintf (stderr, ",\n\t"); |
| 2071 |
len = 8; |
| 2072 |
comma = ""; |
| 2073 |
} |
| 2074 |
|
| 2075 |
len += fprintf (stderr, "%s%s", comma, "call-used"); |
| 2076 |
comma = ", "; |
| 2077 |
} |
| 2078 |
|
| 2079 |
if (fixed_regs[r]) |
| 2080 |
{ |
| 2081 |
if (len > 70) |
| 2082 |
{ |
| 2083 |
fprintf (stderr, ",\n\t"); |
| 2084 |
len = 8; |
| 2085 |
comma = ""; |
| 2086 |
} |
| 2087 |
|
| 2088 |
len += fprintf (stderr, "%s%s", comma, "fixed"); |
| 2089 |
comma = ", "; |
| 2090 |
} |
| 2091 |
|
| 2092 |
if (len > 70) |
| 2093 |
{ |
| 2094 |
fprintf (stderr, ",\n\t"); |
| 2095 |
comma = ""; |
| 2096 |
} |
| 2097 |
|
| 2098 |
len += fprintf (stderr, "%sreg-class = %s", comma, |
| 2099 |
reg_class_names[(int)rs6000_regno_regclass[r]]); |
| 2100 |
comma = ", "; |
| 2101 |
|
| 2102 |
if (len > 70) |
| 2103 |
{ |
| 2104 |
fprintf (stderr, ",\n\t"); |
| 2105 |
comma = ""; |
| 2106 |
} |
| 2107 |
|
| 2108 |
fprintf (stderr, "%sregno = %d\n", comma, r); |
| 2109 |
} |
| 2110 |
} |
| 2111 |
|
| 2112 |
static const char * |
| 2113 |
rs6000_debug_vector_unit (enum rs6000_vector v) |
| 2114 |
{ |
| 2115 |
const char *ret; |
| 2116 |
|
| 2117 |
switch (v) |
| 2118 |
{ |
| 2119 |
case VECTOR_NONE: ret = "none"; break; |
| 2120 |
case VECTOR_ALTIVEC: ret = "altivec"; break; |
| 2121 |
case VECTOR_VSX: ret = "vsx"; break; |
| 2122 |
case VECTOR_P8_VECTOR: ret = "p8_vector"; break; |
| 2123 |
default: ret = "unknown"; break; |
| 2124 |
} |
| 2125 |
|
| 2126 |
return ret; |
| 2127 |
} |
| 2128 |
|
| 2129 |
/* Inner function printing just the address mask for a particular reload |
| 2130 |
register class. */ |
| 2131 |
DEBUG_FUNCTION char * |
| 2132 |
rs6000_debug_addr_mask (addr_mask_type mask, bool keep_spaces) |
| 2133 |
{ |
| 2134 |
static char ret[8]; |
| 2135 |
char *p = ret; |
| 2136 |
|
| 2137 |
if ((mask & RELOAD_REG_VALID) != 0) |
| 2138 |
*p++ = 'v'; |
| 2139 |
else if (keep_spaces) |
| 2140 |
*p++ = ' '; |
| 2141 |
|
| 2142 |
if ((mask & RELOAD_REG_MULTIPLE) != 0) |
| 2143 |
*p++ = 'm'; |
| 2144 |
else if (keep_spaces) |
| 2145 |
*p++ = ' '; |
| 2146 |
|
| 2147 |
if ((mask & RELOAD_REG_INDEXED) != 0) |
| 2148 |
*p++ = 'i'; |
| 2149 |
else if (keep_spaces) |
| 2150 |
*p++ = ' '; |
| 2151 |
|
| 2152 |
if ((mask & RELOAD_REG_QUAD_OFFSET) != 0) |
| 2153 |
*p++ = 'O'; |
| 2154 |
else if ((mask & RELOAD_REG_OFFSET) != 0) |
| 2155 |
*p++ = 'o'; |
| 2156 |
else if (keep_spaces) |
| 2157 |
*p++ = ' '; |
| 2158 |
|
| 2159 |
if ((mask & RELOAD_REG_PRE_INCDEC) != 0) |
| 2160 |
*p++ = '+'; |
| 2161 |
else if (keep_spaces) |
| 2162 |
*p++ = ' '; |
| 2163 |
|
| 2164 |
if ((mask & RELOAD_REG_PRE_MODIFY) != 0) |
| 2165 |
*p++ = '+'; |
| 2166 |
else if (keep_spaces) |
| 2167 |
*p++ = ' '; |
| 2168 |
|
| 2169 |
if ((mask & RELOAD_REG_AND_M16) != 0) |
| 2170 |
*p++ = '&'; |
| 2171 |
else if (keep_spaces) |
| 2172 |
*p++ = ' '; |
| 2173 |
|
| 2174 |
*p = '\0'; |
| 2175 |
|
| 2176 |
return ret; |
| 2177 |
} |
| 2178 |
|
| 2179 |
/* Print the address masks in a human readble fashion. */ |
| 2180 |
DEBUG_FUNCTION void |
| 2181 |
rs6000_debug_print_mode (ssize_t m) |
| 2182 |
{ |
| 2183 |
ssize_t rc; |
| 2184 |
int spaces = 0; |
| 2185 |
|
| 2186 |
fprintf (stderr, "Mode: %-5s", GET_MODE_NAME (m)); |
| 2187 |
for (rc = 0; rc < N_RELOAD_REG; rc++) |
| 2188 |
fprintf (stderr, " %s: %s", reload_reg_map[rc].name, |
| 2189 |
rs6000_debug_addr_mask (reg_addr[m].addr_mask[rc], true)); |
| 2190 |
|
| 2191 |
if ((reg_addr[m].reload_store != CODE_FOR_nothing) |
| 2192 |
|| (reg_addr[m].reload_load != CODE_FOR_nothing)) |
| 2193 |
{ |
| 2194 |
fprintf (stderr, "%*s Reload=%c%c", spaces, "", |
| 2195 |
(reg_addr[m].reload_store != CODE_FOR_nothing) ? 's' : '*', |
| 2196 |
(reg_addr[m].reload_load != CODE_FOR_nothing) ? 'l' : '*'); |
| 2197 |
spaces = 0; |
| 2198 |
} |
| 2199 |
else |
| 2200 |
spaces += strlen (" Reload=sl"); |
| 2201 |
|
| 2202 |
if (reg_addr[m].scalar_in_vmx_p) |
| 2203 |
{ |
| 2204 |
fprintf (stderr, "%*s Upper=y", spaces, ""); |
| 2205 |
spaces = 0; |
| 2206 |
} |
| 2207 |
else |
| 2208 |
spaces += strlen (" Upper=y"); |
| 2209 |
|
| 2210 |
if (rs6000_vector_unit[m] != VECTOR_NONE |
| 2211 |
|| rs6000_vector_mem[m] != VECTOR_NONE) |
| 2212 |
{ |
| 2213 |
fprintf (stderr, "%*s vector: arith=%-10s mem=%s", |
| 2214 |
spaces, "", |
| 2215 |
rs6000_debug_vector_unit (rs6000_vector_unit[m]), |
| 2216 |
rs6000_debug_vector_unit (rs6000_vector_mem[m])); |
| 2217 |
} |
| 2218 |
|
| 2219 |
fputs ("\n", stderr); |
| 2220 |
} |
| 2221 |
|
| 2222 |
#define DEBUG_FMT_ID "%-32s= " |
| 2223 |
#define DEBUG_FMT_D DEBUG_FMT_ID "%d\n" |
| 2224 |
#define DEBUG_FMT_WX DEBUG_FMT_ID "%#.12" HOST_WIDE_INT_PRINT "x: " |
| 2225 |
#define DEBUG_FMT_S DEBUG_FMT_ID "%s\n" |
| 2226 |
|
| 2227 |
/* Print various interesting information with -mdebug=reg. */ |
| 2228 |
static void |
| 2229 |
rs6000_debug_reg_global (void) |
| 2230 |
{ |
| 2231 |
static const char *const tf[2] = { "false", "true" }; |
| 2232 |
const char *nl = (const char *)0; |
| 2233 |
int m; |
| 2234 |
size_t m1, m2, v; |
| 2235 |
char costly_num[20]; |
| 2236 |
char nop_num[20]; |
| 2237 |
char flags_buffer[40]; |
| 2238 |
const char *costly_str; |
| 2239 |
const char *nop_str; |
| 2240 |
const char *trace_str; |
| 2241 |
const char *abi_str; |
| 2242 |
const char *cmodel_str; |
| 2243 |
struct cl_target_option cl_opts; |
| 2244 |
|
| 2245 |
/* Modes we want tieable information on. */ |
| 2246 |
static const machine_mode print_tieable_modes[] = { |
| 2247 |
QImode, |
| 2248 |
HImode, |
| 2249 |
SImode, |
| 2250 |
DImode, |
| 2251 |
TImode, |
| 2252 |
PTImode, |
| 2253 |
SFmode, |
| 2254 |
DFmode, |
| 2255 |
TFmode, |
| 2256 |
IFmode, |
| 2257 |
KFmode, |
| 2258 |
SDmode, |
| 2259 |
DDmode, |
| 2260 |
TDmode, |
| 2261 |
V2SImode, |
| 2262 |
V2SFmode, |
| 2263 |
V16QImode, |
| 2264 |
V8HImode, |
| 2265 |
V4SImode, |
| 2266 |
V2DImode, |
| 2267 |
V1TImode, |
| 2268 |
V32QImode, |
| 2269 |
V16HImode, |
| 2270 |
V8SImode, |
| 2271 |
V4DImode, |
| 2272 |
V2TImode, |
| 2273 |
V4SFmode, |
| 2274 |
V2DFmode, |
| 2275 |
V8SFmode, |
| 2276 |
V4DFmode, |
| 2277 |
OOmode, |
| 2278 |
XOmode, |
| 2279 |
CCmode, |
| 2280 |
CCUNSmode, |
| 2281 |
CCEQmode, |
| 2282 |
CCFPmode, |
| 2283 |
}; |
| 2284 |
|
| 2285 |
/* Virtual regs we are interested in. */ |
| 2286 |
const static struct { |
| 2287 |
int regno; /* register number. */ |
| 2288 |
const char *name; /* register name. */ |
| 2289 |
} virtual_regs[] = { |
| 2290 |
{ STACK_POINTER_REGNUM, "stack pointer:" }, |
| 2291 |
{ TOC_REGNUM, "toc: " }, |
| 2292 |
{ STATIC_CHAIN_REGNUM, "static chain: " }, |
| 2293 |
{ RS6000_PIC_OFFSET_TABLE_REGNUM, "pic offset: " }, |
| 2294 |
{ HARD_FRAME_POINTER_REGNUM, "hard frame: " }, |
| 2295 |
{ ARG_POINTER_REGNUM, "arg pointer: " }, |
| 2296 |
{ FRAME_POINTER_REGNUM, "frame pointer:" }, |
| 2297 |
{ FIRST_PSEUDO_REGISTER, "first pseudo: " }, |
| 2298 |
{ FIRST_VIRTUAL_REGISTER, "first virtual:" }, |
| 2299 |
{ VIRTUAL_INCOMING_ARGS_REGNUM, "incoming_args:" }, |
| 2300 |
{ VIRTUAL_STACK_VARS_REGNUM, "stack_vars: " }, |
| 2301 |
{ VIRTUAL_STACK_DYNAMIC_REGNUM, "stack_dynamic:" }, |
| 2302 |
{ VIRTUAL_OUTGOING_ARGS_REGNUM, "outgoing_args:" }, |
| 2303 |
{ VIRTUAL_CFA_REGNUM, "cfa (frame): " }, |
| 2304 |
{ VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM, "stack boundry:" }, |
| 2305 |
{ LAST_VIRTUAL_REGISTER, "last virtual: " }, |
| 2306 |
}; |
| 2307 |
|
| 2308 |
fputs ("\nHard register information:\n", stderr); |
| 2309 |
rs6000_debug_reg_print (FIRST_GPR_REGNO, LAST_GPR_REGNO, "gr"); |
| 2310 |
rs6000_debug_reg_print (FIRST_FPR_REGNO, LAST_FPR_REGNO, "fp"); |
| 2311 |
rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO, |
| 2312 |
LAST_ALTIVEC_REGNO, |
| 2313 |
"vs"); |
| 2314 |
rs6000_debug_reg_print (LR_REGNO, LR_REGNO, "lr"); |
| 2315 |
rs6000_debug_reg_print (CTR_REGNO, CTR_REGNO, "ctr"); |
| 2316 |
rs6000_debug_reg_print (CR0_REGNO, CR7_REGNO, "cr"); |
| 2317 |
rs6000_debug_reg_print (CA_REGNO, CA_REGNO, "ca"); |
| 2318 |
rs6000_debug_reg_print (VRSAVE_REGNO, VRSAVE_REGNO, "vrsave"); |
| 2319 |
rs6000_debug_reg_print (VSCR_REGNO, VSCR_REGNO, "vscr"); |
| 2320 |
|
| 2321 |
fputs ("\nVirtual/stack/frame registers:\n", stderr); |
| 2322 |
for (v = 0; v < ARRAY_SIZE (virtual_regs); v++) |
| 2323 |
fprintf (stderr, "%s regno = %3d\n", virtual_regs[v].name, virtual_regs[v].regno); |
| 2324 |
|
| 2325 |
fprintf (stderr, |
| 2326 |
"\n" |
| 2327 |
"d reg_class = %s\n" |
| 2328 |
"v reg_class = %s\n" |
| 2329 |
"wa reg_class = %s\n" |
| 2330 |
"we reg_class = %s\n" |
| 2331 |
"wr reg_class = %s\n" |
| 2332 |
"wx reg_class = %s\n" |
| 2333 |
"wA reg_class = %s\n" |
| 2334 |
"\n", |
| 2335 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]], |
| 2336 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]], |
| 2337 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]], |
| 2338 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_we]], |
| 2339 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wr]], |
| 2340 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wx]], |
| 2341 |
reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wA]]); |
| 2342 |
|
| 2343 |
nl = "\n"; |
| 2344 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 2345 |
rs6000_debug_print_mode (m); |
| 2346 |
|
| 2347 |
fputs ("\n", stderr); |
| 2348 |
|
| 2349 |
for (m1 = 0; m1 < ARRAY_SIZE (print_tieable_modes); m1++) |
| 2350 |
{ |
| 2351 |
machine_mode mode1 = print_tieable_modes[m1]; |
| 2352 |
bool first_time = true; |
| 2353 |
|
| 2354 |
nl = (const char *)0; |
| 2355 |
for (m2 = 0; m2 < ARRAY_SIZE (print_tieable_modes); m2++) |
| 2356 |
{ |
| 2357 |
machine_mode mode2 = print_tieable_modes[m2]; |
| 2358 |
if (mode1 != mode2 && rs6000_modes_tieable_p (mode1, mode2)) |
| 2359 |
{ |
| 2360 |
if (first_time) |
| 2361 |
{ |
| 2362 |
fprintf (stderr, "Tieable modes %s:", GET_MODE_NAME (mode1)); |
| 2363 |
nl = "\n"; |
| 2364 |
first_time = false; |
| 2365 |
} |
| 2366 |
|
| 2367 |
fprintf (stderr, " %s", GET_MODE_NAME (mode2)); |
| 2368 |
} |
| 2369 |
} |
| 2370 |
|
| 2371 |
if (!first_time) |
| 2372 |
fputs ("\n", stderr); |
| 2373 |
} |
| 2374 |
|
| 2375 |
if (nl) |
| 2376 |
fputs (nl, stderr); |
| 2377 |
|
| 2378 |
if (rs6000_recip_control) |
| 2379 |
{ |
| 2380 |
fprintf (stderr, "\nReciprocal mask = 0x%x\n", rs6000_recip_control); |
| 2381 |
|
| 2382 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 2383 |
if (rs6000_recip_bits[m]) |
| 2384 |
{ |
| 2385 |
fprintf (stderr, |
| 2386 |
"Reciprocal estimate mode: %-5s divide: %s rsqrt: %s\n", |
| 2387 |
GET_MODE_NAME (m), |
| 2388 |
(RS6000_RECIP_AUTO_RE_P (m) |
| 2389 |
? "auto" |
| 2390 |
: (RS6000_RECIP_HAVE_RE_P (m) ? "have" : "none")), |
| 2391 |
(RS6000_RECIP_AUTO_RSQRTE_P (m) |
| 2392 |
? "auto" |
| 2393 |
: (RS6000_RECIP_HAVE_RSQRTE_P (m) ? "have" : "none"))); |
| 2394 |
} |
| 2395 |
|
| 2396 |
fputs ("\n", stderr); |
| 2397 |
} |
| 2398 |
|
| 2399 |
if (rs6000_cpu_index >= 0) |
| 2400 |
{ |
| 2401 |
const char *name = processor_target_table[rs6000_cpu_index].name; |
| 2402 |
HOST_WIDE_INT flags |
| 2403 |
= processor_target_table[rs6000_cpu_index].target_enable; |
| 2404 |
|
| 2405 |
sprintf (flags_buffer, "-mcpu=%s flags", name); |
| 2406 |
rs6000_print_isa_options (stderr, 0, flags_buffer, flags); |
| 2407 |
} |
| 2408 |
else |
| 2409 |
fprintf (stderr, DEBUG_FMT_S, "cpu", "<none>"); |
| 2410 |
|
| 2411 |
if (rs6000_tune_index >= 0) |
| 2412 |
{ |
| 2413 |
const char *name = processor_target_table[rs6000_tune_index].name; |
| 2414 |
HOST_WIDE_INT flags |
| 2415 |
= processor_target_table[rs6000_tune_index].target_enable; |
| 2416 |
|
| 2417 |
sprintf (flags_buffer, "-mtune=%s flags", name); |
| 2418 |
rs6000_print_isa_options (stderr, 0, flags_buffer, flags); |
| 2419 |
} |
| 2420 |
else |
| 2421 |
fprintf (stderr, DEBUG_FMT_S, "tune", "<none>"); |
| 2422 |
|
| 2423 |
cl_target_option_save (&cl_opts, &global_options, &global_options_set); |
| 2424 |
rs6000_print_isa_options (stderr, 0, "rs6000_isa_flags", |
| 2425 |
rs6000_isa_flags); |
| 2426 |
|
| 2427 |
rs6000_print_isa_options (stderr, 0, "rs6000_isa_flags_explicit", |
| 2428 |
rs6000_isa_flags_explicit); |
| 2429 |
|
| 2430 |
rs6000_print_isa_options (stderr, 0, "TARGET_DEFAULT", TARGET_DEFAULT); |
| 2431 |
|
| 2432 |
fprintf (stderr, DEBUG_FMT_S, "--with-cpu default", |
| 2433 |
OPTION_TARGET_CPU_DEFAULT ? OPTION_TARGET_CPU_DEFAULT : "<none>"); |
| 2434 |
|
| 2435 |
switch (rs6000_sched_costly_dep) |
| 2436 |
{ |
| 2437 |
case max_dep_latency: |
| 2438 |
costly_str = "max_dep_latency"; |
| 2439 |
break; |
| 2440 |
|
| 2441 |
case no_dep_costly: |
| 2442 |
costly_str = "no_dep_costly"; |
| 2443 |
break; |
| 2444 |
|
| 2445 |
case all_deps_costly: |
| 2446 |
costly_str = "all_deps_costly"; |
| 2447 |
break; |
| 2448 |
|
| 2449 |
case true_store_to_load_dep_costly: |
| 2450 |
costly_str = "true_store_to_load_dep_costly"; |
| 2451 |
break; |
| 2452 |
|
| 2453 |
case store_to_load_dep_costly: |
| 2454 |
costly_str = "store_to_load_dep_costly"; |
| 2455 |
break; |
| 2456 |
|
| 2457 |
default: |
| 2458 |
costly_str = costly_num; |
| 2459 |
sprintf (costly_num, "%d", (int)rs6000_sched_costly_dep); |
| 2460 |
break; |
| 2461 |
} |
| 2462 |
|
| 2463 |
fprintf (stderr, DEBUG_FMT_S, "sched_costly_dep", costly_str); |
| 2464 |
|
| 2465 |
switch (rs6000_sched_insert_nops) |
| 2466 |
{ |
| 2467 |
case sched_finish_regroup_exact: |
| 2468 |
nop_str = "sched_finish_regroup_exact"; |
| 2469 |
break; |
| 2470 |
|
| 2471 |
case sched_finish_pad_groups: |
| 2472 |
nop_str = "sched_finish_pad_groups"; |
| 2473 |
break; |
| 2474 |
|
| 2475 |
case sched_finish_none: |
| 2476 |
nop_str = "sched_finish_none"; |
| 2477 |
break; |
| 2478 |
|
| 2479 |
default: |
| 2480 |
nop_str = nop_num; |
| 2481 |
sprintf (nop_num, "%d", (int)rs6000_sched_insert_nops); |
| 2482 |
break; |
| 2483 |
} |
| 2484 |
|
| 2485 |
fprintf (stderr, DEBUG_FMT_S, "sched_insert_nops", nop_str); |
| 2486 |
|
| 2487 |
switch (rs6000_sdata) |
| 2488 |
{ |
| 2489 |
default: |
| 2490 |
case SDATA_NONE: |
| 2491 |
break; |
| 2492 |
|
| 2493 |
case SDATA_DATA: |
| 2494 |
fprintf (stderr, DEBUG_FMT_S, "sdata", "data"); |
| 2495 |
break; |
| 2496 |
|
| 2497 |
case SDATA_SYSV: |
| 2498 |
fprintf (stderr, DEBUG_FMT_S, "sdata", "sysv"); |
| 2499 |
break; |
| 2500 |
|
| 2501 |
case SDATA_EABI: |
| 2502 |
fprintf (stderr, DEBUG_FMT_S, "sdata", "eabi"); |
| 2503 |
break; |
| 2504 |
|
| 2505 |
} |
| 2506 |
|
| 2507 |
switch (rs6000_traceback) |
| 2508 |
{ |
| 2509 |
case traceback_default: trace_str = "default"; break; |
| 2510 |
case traceback_none: trace_str = "none"; break; |
| 2511 |
case traceback_part: trace_str = "part"; break; |
| 2512 |
case traceback_full: trace_str = "full"; break; |
| 2513 |
default: trace_str = "unknown"; break; |
| 2514 |
} |
| 2515 |
|
| 2516 |
fprintf (stderr, DEBUG_FMT_S, "traceback", trace_str); |
| 2517 |
|
| 2518 |
switch (rs6000_current_cmodel) |
| 2519 |
{ |
| 2520 |
case CMODEL_SMALL: cmodel_str = "small"; break; |
| 2521 |
case CMODEL_MEDIUM: cmodel_str = "medium"; break; |
| 2522 |
case CMODEL_LARGE: cmodel_str = "large"; break; |
| 2523 |
default: cmodel_str = "unknown"; break; |
| 2524 |
} |
| 2525 |
|
| 2526 |
fprintf (stderr, DEBUG_FMT_S, "cmodel", cmodel_str); |
| 2527 |
|
| 2528 |
switch (rs6000_current_abi) |
| 2529 |
{ |
| 2530 |
case ABI_NONE: abi_str = "none"; break; |
| 2531 |
case ABI_AIX: abi_str = "aix"; break; |
| 2532 |
case ABI_ELFv2: abi_str = "ELFv2"; break; |
| 2533 |
case ABI_V4: abi_str = "V4"; break; |
| 2534 |
case ABI_DARWIN: abi_str = "darwin"; break; |
| 2535 |
default: abi_str = "unknown"; break; |
| 2536 |
} |
| 2537 |
|
| 2538 |
fprintf (stderr, DEBUG_FMT_S, "abi", abi_str); |
| 2539 |
|
| 2540 |
if (rs6000_altivec_abi) |
| 2541 |
fprintf (stderr, DEBUG_FMT_S, "altivec_abi", "true"); |
| 2542 |
|
| 2543 |
if (rs6000_aix_extabi) |
| 2544 |
fprintf (stderr, DEBUG_FMT_S, "AIX vec-extabi", "true"); |
| 2545 |
|
| 2546 |
if (rs6000_darwin64_abi) |
| 2547 |
fprintf (stderr, DEBUG_FMT_S, "darwin64_abi", "true"); |
| 2548 |
|
| 2549 |
fprintf (stderr, DEBUG_FMT_S, "soft_float", |
| 2550 |
(TARGET_SOFT_FLOAT ? "true" : "false")); |
| 2551 |
|
| 2552 |
if (TARGET_LINK_STACK) |
| 2553 |
fprintf (stderr, DEBUG_FMT_S, "link_stack", "true"); |
| 2554 |
|
| 2555 |
if (TARGET_P8_FUSION) |
| 2556 |
{ |
| 2557 |
char options[80]; |
| 2558 |
|
| 2559 |
strcpy (options, "power8"); |
| 2560 |
if (TARGET_P8_FUSION_SIGN) |
| 2561 |
strcat (options, ", sign"); |
| 2562 |
|
| 2563 |
fprintf (stderr, DEBUG_FMT_S, "fusion", options); |
| 2564 |
} |
| 2565 |
|
| 2566 |
fprintf (stderr, DEBUG_FMT_S, "plt-format", |
| 2567 |
TARGET_SECURE_PLT ? "secure" : "bss"); |
| 2568 |
fprintf (stderr, DEBUG_FMT_S, "struct-return", |
| 2569 |
aix_struct_return ? "aix" : "sysv"); |
| 2570 |
fprintf (stderr, DEBUG_FMT_S, "always_hint", tf[!!rs6000_always_hint]); |
| 2571 |
fprintf (stderr, DEBUG_FMT_S, "sched_groups", tf[!!rs6000_sched_groups]); |
| 2572 |
fprintf (stderr, DEBUG_FMT_S, "align_branch", |
| 2573 |
tf[!!rs6000_align_branch_targets]); |
| 2574 |
fprintf (stderr, DEBUG_FMT_D, "tls_size", rs6000_tls_size); |
| 2575 |
fprintf (stderr, DEBUG_FMT_D, "long_double_size", |
| 2576 |
rs6000_long_double_type_size); |
| 2577 |
if (rs6000_long_double_type_size > 64) |
| 2578 |
{ |
| 2579 |
fprintf (stderr, DEBUG_FMT_S, "long double type", |
| 2580 |
TARGET_IEEEQUAD ? "IEEE" : "IBM"); |
| 2581 |
fprintf (stderr, DEBUG_FMT_S, "default long double type", |
| 2582 |
TARGET_IEEEQUAD_DEFAULT ? "IEEE" : "IBM"); |
| 2583 |
} |
| 2584 |
fprintf (stderr, DEBUG_FMT_D, "sched_restricted_insns_priority", |
| 2585 |
(int)rs6000_sched_restricted_insns_priority); |
| 2586 |
fprintf (stderr, DEBUG_FMT_D, "Number of standard builtins", |
| 2587 |
(int)END_BUILTINS); |
| 2588 |
|
| 2589 |
fprintf (stderr, DEBUG_FMT_D, "Enable float128 on VSX", |
| 2590 |
(int)TARGET_FLOAT128_ENABLE_TYPE); |
| 2591 |
|
| 2592 |
if (TARGET_VSX) |
| 2593 |
fprintf (stderr, DEBUG_FMT_D, "VSX easy 64-bit scalar element", |
| 2594 |
(int)VECTOR_ELEMENT_SCALAR_64BIT); |
| 2595 |
|
| 2596 |
if (TARGET_DIRECT_MOVE_128) |
| 2597 |
fprintf (stderr, DEBUG_FMT_D, "VSX easy 64-bit mfvsrld element", |
| 2598 |
(int)VECTOR_ELEMENT_MFVSRLD_64BIT); |
| 2599 |
} |
| 2600 |
|
| 2601 |
|
| 2602 |
/* Update the addr mask bits in reg_addr to help secondary reload and go if |
| 2603 |
legitimate address support to figure out the appropriate addressing to |
| 2604 |
use. */ |
| 2605 |
|
| 2606 |
static void |
| 2607 |
rs6000_setup_reg_addr_masks (void) |
| 2608 |
{ |
| 2609 |
ssize_t rc, reg, m, nregs; |
| 2610 |
addr_mask_type any_addr_mask, addr_mask; |
| 2611 |
|
| 2612 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 2613 |
{ |
| 2614 |
machine_mode m2 = (machine_mode) m; |
| 2615 |
bool complex_p = false; |
| 2616 |
bool small_int_p = (m2 == QImode || m2 == HImode || m2 == SImode); |
| 2617 |
size_t msize; |
| 2618 |
|
| 2619 |
if (COMPLEX_MODE_P (m2)) |
| 2620 |
{ |
| 2621 |
complex_p = true; |
| 2622 |
m2 = GET_MODE_INNER (m2); |
| 2623 |
} |
| 2624 |
|
| 2625 |
msize = GET_MODE_SIZE (m2); |
| 2626 |
|
| 2627 |
/* SDmode is special in that we want to access it only via REG+REG |
| 2628 |
addressing on power7 and above, since we want to use the LFIWZX and |
| 2629 |
STFIWZX instructions to load it. */ |
| 2630 |
bool indexed_only_p = (m == SDmode && TARGET_NO_SDMODE_STACK); |
| 2631 |
|
| 2632 |
any_addr_mask = 0; |
| 2633 |
for (rc = FIRST_RELOAD_REG_CLASS; rc <= LAST_RELOAD_REG_CLASS; rc++) |
| 2634 |
{ |
| 2635 |
addr_mask = 0; |
| 2636 |
reg = reload_reg_map[rc].reg; |
| 2637 |
|
| 2638 |
/* Can mode values go in the GPR/FPR/Altivec registers? */ |
| 2639 |
if (reg >= 0 && rs6000_hard_regno_mode_ok_p[m][reg]) |
| 2640 |
{ |
| 2641 |
bool small_int_vsx_p = (small_int_p |
| 2642 |
&& (rc == RELOAD_REG_FPR |
| 2643 |
|| rc == RELOAD_REG_VMX)); |
| 2644 |
|
| 2645 |
nregs = rs6000_hard_regno_nregs[m][reg]; |
| 2646 |
addr_mask |= RELOAD_REG_VALID; |
| 2647 |
|
| 2648 |
/* Indicate if the mode takes more than 1 physical register. If |
| 2649 |
it takes a single register, indicate it can do REG+REG |
| 2650 |
addressing. Small integers in VSX registers can only do |
| 2651 |
REG+REG addressing. */ |
| 2652 |
if (small_int_vsx_p) |
| 2653 |
addr_mask |= RELOAD_REG_INDEXED; |
| 2654 |
else if (nregs > 1 || m == BLKmode || complex_p) |
| 2655 |
addr_mask |= RELOAD_REG_MULTIPLE; |
| 2656 |
else |
| 2657 |
addr_mask |= RELOAD_REG_INDEXED; |
| 2658 |
|
| 2659 |
/* Figure out if we can do PRE_INC, PRE_DEC, or PRE_MODIFY |
| 2660 |
addressing. If we allow scalars into Altivec registers, |
| 2661 |
don't allow PRE_INC, PRE_DEC, or PRE_MODIFY. |
| 2662 |
|
| 2663 |
For VSX systems, we don't allow update addressing for |
| 2664 |
DFmode/SFmode if those registers can go in both the |
| 2665 |
traditional floating point registers and Altivec registers. |
| 2666 |
The load/store instructions for the Altivec registers do not |
| 2667 |
have update forms. If we allowed update addressing, it seems |
| 2668 |
to break IV-OPT code using floating point if the index type is |
| 2669 |
int instead of long (PR target/81550 and target/84042). */ |
| 2670 |
|
| 2671 |
if (TARGET_UPDATE |
| 2672 |
&& (rc == RELOAD_REG_GPR || rc == RELOAD_REG_FPR) |
| 2673 |
&& msize <= 8 |
| 2674 |
&& !VECTOR_MODE_P (m2) |
| 2675 |
&& !VECTOR_ALIGNMENT_P (m2) |
| 2676 |
&& !complex_p |
| 2677 |
&& (m != E_DFmode || !TARGET_VSX) |
| 2678 |
&& (m != E_SFmode || !TARGET_P8_VECTOR) |
| 2679 |
&& !small_int_vsx_p) |
| 2680 |
{ |
| 2681 |
addr_mask |= RELOAD_REG_PRE_INCDEC; |
| 2682 |
|
| 2683 |
/* PRE_MODIFY is more restricted than PRE_INC/PRE_DEC in that |
| 2684 |
we don't allow PRE_MODIFY for some multi-register |
| 2685 |
operations. */ |
| 2686 |
switch (m) |
| 2687 |
{ |
| 2688 |
default: |
| 2689 |
addr_mask |= RELOAD_REG_PRE_MODIFY; |
| 2690 |
break; |
| 2691 |
|
| 2692 |
case E_DImode: |
| 2693 |
if (TARGET_POWERPC64) |
| 2694 |
addr_mask |= RELOAD_REG_PRE_MODIFY; |
| 2695 |
break; |
| 2696 |
|
| 2697 |
case E_DFmode: |
| 2698 |
case E_DDmode: |
| 2699 |
if (TARGET_HARD_FLOAT) |
| 2700 |
addr_mask |= RELOAD_REG_PRE_MODIFY; |
| 2701 |
break; |
| 2702 |
} |
| 2703 |
} |
| 2704 |
} |
| 2705 |
|
| 2706 |
/* GPR and FPR registers can do REG+OFFSET addressing, except |
| 2707 |
possibly for SDmode. ISA 3.0 (i.e. power9) adds D-form addressing |
| 2708 |
for 64-bit scalars and 32-bit SFmode to altivec registers. */ |
| 2709 |
if ((addr_mask != 0) && !indexed_only_p |
| 2710 |
&& msize <= 8 |
| 2711 |
&& (rc == RELOAD_REG_GPR |
| 2712 |
|| ((msize == 8 || m2 == SFmode) |
| 2713 |
&& (rc == RELOAD_REG_FPR |
| 2714 |
|| (rc == RELOAD_REG_VMX && TARGET_P9_VECTOR))))) |
| 2715 |
addr_mask |= RELOAD_REG_OFFSET; |
| 2716 |
|
| 2717 |
/* VSX registers can do REG+OFFSET addresssing if ISA 3.0 |
| 2718 |
instructions are enabled. The offset for 128-bit VSX registers is |
| 2719 |
only 12-bits. While GPRs can handle the full offset range, VSX |
| 2720 |
registers can only handle the restricted range. */ |
| 2721 |
else if ((addr_mask != 0) && !indexed_only_p |
| 2722 |
&& msize == 16 && TARGET_P9_VECTOR |
| 2723 |
&& (ALTIVEC_OR_VSX_VECTOR_MODE (m2) |
| 2724 |
|| (m2 == TImode && TARGET_VSX))) |
| 2725 |
{ |
| 2726 |
addr_mask |= RELOAD_REG_OFFSET; |
| 2727 |
if (rc == RELOAD_REG_FPR || rc == RELOAD_REG_VMX) |
| 2728 |
addr_mask |= RELOAD_REG_QUAD_OFFSET; |
| 2729 |
} |
| 2730 |
|
| 2731 |
/* Vector pairs can do both indexed and offset loads if the |
| 2732 |
instructions are enabled, otherwise they can only do offset loads |
| 2733 |
since it will be broken into two vector moves. Vector quads can |
| 2734 |
only do offset loads. */ |
| 2735 |
else if ((addr_mask != 0) && TARGET_MMA |
| 2736 |
&& (m2 == OOmode || m2 == XOmode)) |
| 2737 |
{ |
| 2738 |
addr_mask |= RELOAD_REG_OFFSET; |
| 2739 |
if (rc == RELOAD_REG_FPR || rc == RELOAD_REG_VMX) |
| 2740 |
{ |
| 2741 |
addr_mask |= RELOAD_REG_QUAD_OFFSET; |
| 2742 |
if (m2 == OOmode) |
| 2743 |
addr_mask |= RELOAD_REG_INDEXED; |
| 2744 |
} |
| 2745 |
} |
| 2746 |
|
| 2747 |
/* VMX registers can do (REG & -16) and ((REG+REG) & -16) |
| 2748 |
addressing on 128-bit types. */ |
| 2749 |
if (rc == RELOAD_REG_VMX && msize == 16 |
| 2750 |
&& (addr_mask & RELOAD_REG_VALID) != 0) |
| 2751 |
addr_mask |= RELOAD_REG_AND_M16; |
| 2752 |
|
| 2753 |
reg_addr[m].addr_mask[rc] = addr_mask; |
| 2754 |
any_addr_mask |= addr_mask; |
| 2755 |
} |
| 2756 |
|
| 2757 |
reg_addr[m].addr_mask[RELOAD_REG_ANY] = any_addr_mask; |
| 2758 |
} |
| 2759 |
} |
| 2760 |
|
| 2761 |
|
| 2762 |
/* Initialize the various global tables that are based on register size. */ |
| 2763 |
static void |
| 2764 |
rs6000_init_hard_regno_mode_ok (bool global_init_p) |
| 2765 |
{ |
| 2766 |
ssize_t r, m, c; |
| 2767 |
int align64; |
| 2768 |
int align32; |
| 2769 |
|
| 2770 |
/* Precalculate REGNO_REG_CLASS. */ |
| 2771 |
rs6000_regno_regclass[0] = GENERAL_REGS; |
| 2772 |
for (r = 1; r < 32; ++r) |
| 2773 |
rs6000_regno_regclass[r] = BASE_REGS; |
| 2774 |
|
| 2775 |
for (r = 32; r < 64; ++r) |
| 2776 |
rs6000_regno_regclass[r] = FLOAT_REGS; |
| 2777 |
|
| 2778 |
for (r = 64; HARD_REGISTER_NUM_P (r); ++r) |
| 2779 |
rs6000_regno_regclass[r] = NO_REGS; |
| 2780 |
|
| 2781 |
for (r = FIRST_ALTIVEC_REGNO; r <= LAST_ALTIVEC_REGNO; ++r) |
| 2782 |
rs6000_regno_regclass[r] = ALTIVEC_REGS; |
| 2783 |
|
| 2784 |
rs6000_regno_regclass[CR0_REGNO] = CR0_REGS; |
| 2785 |
for (r = CR1_REGNO; r <= CR7_REGNO; ++r) |
| 2786 |
rs6000_regno_regclass[r] = CR_REGS; |
| 2787 |
|
| 2788 |
rs6000_regno_regclass[LR_REGNO] = LINK_REGS; |
| 2789 |
rs6000_regno_regclass[CTR_REGNO] = CTR_REGS; |
| 2790 |
rs6000_regno_regclass[CA_REGNO] = NO_REGS; |
| 2791 |
rs6000_regno_regclass[VRSAVE_REGNO] = VRSAVE_REGS; |
| 2792 |
rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS; |
| 2793 |
rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS; |
| 2794 |
rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS; |
| 2795 |
|
| 2796 |
/* Precalculate register class to simpler reload register class. We don't |
| 2797 |
need all of the register classes that are combinations of different |
| 2798 |
classes, just the simple ones that have constraint letters. */ |
| 2799 |
for (c = 0; c < N_REG_CLASSES; c++) |
| 2800 |
reg_class_to_reg_type[c] = NO_REG_TYPE; |
| 2801 |
|
| 2802 |
reg_class_to_reg_type[(int)GENERAL_REGS] = GPR_REG_TYPE; |
| 2803 |
reg_class_to_reg_type[(int)BASE_REGS] = GPR_REG_TYPE; |
| 2804 |
reg_class_to_reg_type[(int)VSX_REGS] = VSX_REG_TYPE; |
| 2805 |
reg_class_to_reg_type[(int)VRSAVE_REGS] = SPR_REG_TYPE; |
| 2806 |
reg_class_to_reg_type[(int)VSCR_REGS] = SPR_REG_TYPE; |
| 2807 |
reg_class_to_reg_type[(int)LINK_REGS] = SPR_REG_TYPE; |
| 2808 |
reg_class_to_reg_type[(int)CTR_REGS] = SPR_REG_TYPE; |
| 2809 |
reg_class_to_reg_type[(int)LINK_OR_CTR_REGS] = SPR_REG_TYPE; |
| 2810 |
reg_class_to_reg_type[(int)CR_REGS] = CR_REG_TYPE; |
| 2811 |
reg_class_to_reg_type[(int)CR0_REGS] = CR_REG_TYPE; |
| 2812 |
|
| 2813 |
if (TARGET_VSX) |
| 2814 |
{ |
| 2815 |
reg_class_to_reg_type[(int)FLOAT_REGS] = VSX_REG_TYPE; |
| 2816 |
reg_class_to_reg_type[(int)ALTIVEC_REGS] = VSX_REG_TYPE; |
| 2817 |
} |
| 2818 |
else |
| 2819 |
{ |
| 2820 |
reg_class_to_reg_type[(int)FLOAT_REGS] = FPR_REG_TYPE; |
| 2821 |
reg_class_to_reg_type[(int)ALTIVEC_REGS] = ALTIVEC_REG_TYPE; |
| 2822 |
} |
| 2823 |
|
| 2824 |
/* Precalculate the valid memory formats as well as the vector information, |
| 2825 |
this must be set up before the rs6000_hard_regno_nregs_internal calls |
| 2826 |
below. */ |
| 2827 |
gcc_assert ((int)VECTOR_NONE == 0); |
| 2828 |
memset ((void *) &rs6000_vector_unit[0], '\0', sizeof (rs6000_vector_unit)); |
| 2829 |
memset ((void *) &rs6000_vector_mem[0], '\0', sizeof (rs6000_vector_mem)); |
| 2830 |
|
| 2831 |
gcc_assert ((int)CODE_FOR_nothing == 0); |
| 2832 |
memset ((void *) ®_addr[0], '\0', sizeof (reg_addr)); |
| 2833 |
|
| 2834 |
gcc_assert ((int)NO_REGS == 0); |
| 2835 |
memset ((void *) &rs6000_constraints[0], '\0', sizeof (rs6000_constraints)); |
| 2836 |
|
| 2837 |
/* The VSX hardware allows native alignment for vectors, but control whether the compiler |
| 2838 |
believes it can use native alignment or still uses 128-bit alignment. */ |
| 2839 |
if (TARGET_VSX && !TARGET_VSX_ALIGN_128) |
| 2840 |
{ |
| 2841 |
align64 = 64; |
| 2842 |
align32 = 32; |
| 2843 |
} |
| 2844 |
else |
| 2845 |
{ |
| 2846 |
align64 = 128; |
| 2847 |
align32 = 128; |
| 2848 |
} |
| 2849 |
|
| 2850 |
/* KF mode (IEEE 128-bit in VSX registers). We do not have arithmetic, so |
| 2851 |
only set the memory modes. Include TFmode if -mabi=ieeelongdouble. */ |
| 2852 |
if (TARGET_FLOAT128_TYPE) |
| 2853 |
{ |
| 2854 |
rs6000_vector_mem[KFmode] = VECTOR_VSX; |
| 2855 |
rs6000_vector_align[KFmode] = 128; |
| 2856 |
|
| 2857 |
if (FLOAT128_IEEE_P (TFmode)) |
| 2858 |
{ |
| 2859 |
rs6000_vector_mem[TFmode] = VECTOR_VSX; |
| 2860 |
rs6000_vector_align[TFmode] = 128; |
| 2861 |
} |
| 2862 |
} |
| 2863 |
|
| 2864 |
/* V2DF mode, VSX only. */ |
| 2865 |
if (TARGET_VSX) |
| 2866 |
{ |
| 2867 |
rs6000_vector_unit[V2DFmode] = VECTOR_VSX; |
| 2868 |
rs6000_vector_mem[V2DFmode] = VECTOR_VSX; |
| 2869 |
rs6000_vector_align[V2DFmode] = align64; |
| 2870 |
} |
| 2871 |
|
| 2872 |
/* V4SF mode, either VSX or Altivec. */ |
| 2873 |
if (TARGET_VSX) |
| 2874 |
{ |
| 2875 |
rs6000_vector_unit[V4SFmode] = VECTOR_VSX; |
| 2876 |
rs6000_vector_mem[V4SFmode] = VECTOR_VSX; |
| 2877 |
rs6000_vector_align[V4SFmode] = align32; |
| 2878 |
} |
| 2879 |
else if (TARGET_ALTIVEC) |
| 2880 |
{ |
| 2881 |
rs6000_vector_unit[V4SFmode] = VECTOR_ALTIVEC; |
| 2882 |
rs6000_vector_mem[V4SFmode] = VECTOR_ALTIVEC; |
| 2883 |
rs6000_vector_align[V4SFmode] = align32; |
| 2884 |
} |
| 2885 |
|
| 2886 |
/* V16QImode, V8HImode, V4SImode are Altivec only, but possibly do VSX loads |
| 2887 |
and stores. */ |
| 2888 |
if (TARGET_ALTIVEC) |
| 2889 |
{ |
| 2890 |
rs6000_vector_unit[V4SImode] = VECTOR_ALTIVEC; |
| 2891 |
rs6000_vector_unit[V8HImode] = VECTOR_ALTIVEC; |
| 2892 |
rs6000_vector_unit[V16QImode] = VECTOR_ALTIVEC; |
| 2893 |
rs6000_vector_align[V4SImode] = align32; |
| 2894 |
rs6000_vector_align[V8HImode] = align32; |
| 2895 |
rs6000_vector_align[V16QImode] = align32; |
| 2896 |
|
| 2897 |
if (TARGET_VSX) |
| 2898 |
{ |
| 2899 |
rs6000_vector_mem[V4SImode] = VECTOR_VSX; |
| 2900 |
rs6000_vector_mem[V8HImode] = VECTOR_VSX; |
| 2901 |
rs6000_vector_mem[V16QImode] = VECTOR_VSX; |
| 2902 |
} |
| 2903 |
else |
| 2904 |
{ |
| 2905 |
rs6000_vector_mem[V4SImode] = VECTOR_ALTIVEC; |
| 2906 |
rs6000_vector_mem[V8HImode] = VECTOR_ALTIVEC; |
| 2907 |
rs6000_vector_mem[V16QImode] = VECTOR_ALTIVEC; |
| 2908 |
} |
| 2909 |
} |
| 2910 |
|
| 2911 |
/* V2DImode, full mode depends on ISA 2.07 vector mode. Allow under VSX to |
| 2912 |
do insert/splat/extract. Altivec doesn't have 64-bit integer support. */ |
| 2913 |
if (TARGET_VSX) |
| 2914 |
{ |
| 2915 |
rs6000_vector_mem[V2DImode] = VECTOR_VSX; |
| 2916 |
rs6000_vector_unit[V2DImode] |
| 2917 |
= (TARGET_P8_VECTOR) ? VECTOR_P8_VECTOR : VECTOR_NONE; |
| 2918 |
rs6000_vector_align[V2DImode] = align64; |
| 2919 |
|
| 2920 |
rs6000_vector_mem[V1TImode] = VECTOR_VSX; |
| 2921 |
rs6000_vector_unit[V1TImode] |
| 2922 |
= (TARGET_P8_VECTOR) ? VECTOR_P8_VECTOR : VECTOR_NONE; |
| 2923 |
rs6000_vector_align[V1TImode] = 128; |
| 2924 |
} |
| 2925 |
|
| 2926 |
/* DFmode, see if we want to use the VSX unit. Memory is handled |
| 2927 |
differently, so don't set rs6000_vector_mem. */ |
| 2928 |
if (TARGET_VSX) |
| 2929 |
{ |
| 2930 |
rs6000_vector_unit[DFmode] = VECTOR_VSX; |
| 2931 |
rs6000_vector_align[DFmode] = 64; |
| 2932 |
} |
| 2933 |
|
| 2934 |
/* SFmode, see if we want to use the VSX unit. */ |
| 2935 |
if (TARGET_P8_VECTOR) |
| 2936 |
{ |
| 2937 |
rs6000_vector_unit[SFmode] = VECTOR_VSX; |
| 2938 |
rs6000_vector_align[SFmode] = 32; |
| 2939 |
} |
| 2940 |
|
| 2941 |
/* Allow TImode in VSX register and set the VSX memory macros. */ |
| 2942 |
if (TARGET_VSX) |
| 2943 |
{ |
| 2944 |
rs6000_vector_mem[TImode] = VECTOR_VSX; |
| 2945 |
rs6000_vector_align[TImode] = align64; |
| 2946 |
} |
| 2947 |
|
| 2948 |
/* Add support for vector pairs and vector quad registers. */ |
| 2949 |
if (TARGET_MMA) |
| 2950 |
{ |
| 2951 |
rs6000_vector_unit[OOmode] = VECTOR_NONE; |
| 2952 |
rs6000_vector_mem[OOmode] = VECTOR_VSX; |
| 2953 |
rs6000_vector_align[OOmode] = 256; |
| 2954 |
|
| 2955 |
rs6000_vector_unit[XOmode] = VECTOR_NONE; |
| 2956 |
rs6000_vector_mem[XOmode] = VECTOR_VSX; |
| 2957 |
rs6000_vector_align[XOmode] = 512; |
| 2958 |
} |
| 2959 |
|
| 2960 |
/* Register class constraints for the constraints that depend on compile |
| 2961 |
switches. When the VSX code was added, different constraints were added |
| 2962 |
based on the type (DFmode, V2DFmode, V4SFmode). For the vector types, all |
| 2963 |
of the VSX registers are used. The register classes for scalar floating |
| 2964 |
point types is set, based on whether we allow that type into the upper |
| 2965 |
(Altivec) registers. GCC has register classes to target the Altivec |
| 2966 |
registers for load/store operations, to select using a VSX memory |
| 2967 |
operation instead of the traditional floating point operation. The |
| 2968 |
constraints are: |
| 2969 |
|
| 2970 |
d - Register class to use with traditional DFmode instructions. |
| 2971 |
v - Altivec register. |
| 2972 |
wa - Any VSX register. |
| 2973 |
wc - Reserved to represent individual CR bits (used in LLVM). |
| 2974 |
wn - always NO_REGS. |
| 2975 |
wr - GPR if 64-bit mode is permitted. |
| 2976 |
wx - Float register if we can do 32-bit int stores. */ |
| 2977 |
|
| 2978 |
if (TARGET_HARD_FLOAT) |
| 2979 |
rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS; |
| 2980 |
if (TARGET_ALTIVEC) |
| 2981 |
rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS; |
| 2982 |
if (TARGET_VSX) |
| 2983 |
rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS; |
| 2984 |
|
| 2985 |
if (TARGET_POWERPC64) |
| 2986 |
{ |
| 2987 |
rs6000_constraints[RS6000_CONSTRAINT_wr] = GENERAL_REGS; |
| 2988 |
rs6000_constraints[RS6000_CONSTRAINT_wA] = BASE_REGS; |
| 2989 |
} |
| 2990 |
|
| 2991 |
if (TARGET_STFIWX) |
| 2992 |
rs6000_constraints[RS6000_CONSTRAINT_wx] = FLOAT_REGS; /* DImode */ |
| 2993 |
|
| 2994 |
/* Support for new direct moves (ISA 3.0 + 64bit). */ |
| 2995 |
if (TARGET_DIRECT_MOVE_128) |
| 2996 |
rs6000_constraints[RS6000_CONSTRAINT_we] = VSX_REGS; |
| 2997 |
|
| 2998 |
/* Set up the reload helper and direct move functions. */ |
| 2999 |
if (TARGET_VSX || TARGET_ALTIVEC) |
| 3000 |
{ |
| 3001 |
if (TARGET_64BIT) |
| 3002 |
{ |
| 3003 |
reg_addr[V16QImode].reload_store = CODE_FOR_reload_v16qi_di_store; |
| 3004 |
reg_addr[V16QImode].reload_load = CODE_FOR_reload_v16qi_di_load; |
| 3005 |
reg_addr[V8HImode].reload_store = CODE_FOR_reload_v8hi_di_store; |
| 3006 |
reg_addr[V8HImode].reload_load = CODE_FOR_reload_v8hi_di_load; |
| 3007 |
reg_addr[V4SImode].reload_store = CODE_FOR_reload_v4si_di_store; |
| 3008 |
reg_addr[V4SImode].reload_load = CODE_FOR_reload_v4si_di_load; |
| 3009 |
reg_addr[V2DImode].reload_store = CODE_FOR_reload_v2di_di_store; |
| 3010 |
reg_addr[V2DImode].reload_load = CODE_FOR_reload_v2di_di_load; |
| 3011 |
reg_addr[V1TImode].reload_store = CODE_FOR_reload_v1ti_di_store; |
| 3012 |
reg_addr[V1TImode].reload_load = CODE_FOR_reload_v1ti_di_load; |
| 3013 |
reg_addr[V4SFmode].reload_store = CODE_FOR_reload_v4sf_di_store; |
| 3014 |
reg_addr[V4SFmode].reload_load = CODE_FOR_reload_v4sf_di_load; |
| 3015 |
reg_addr[V2DFmode].reload_store = CODE_FOR_reload_v2df_di_store; |
| 3016 |
reg_addr[V2DFmode].reload_load = CODE_FOR_reload_v2df_di_load; |
| 3017 |
reg_addr[DFmode].reload_store = CODE_FOR_reload_df_di_store; |
| 3018 |
reg_addr[DFmode].reload_load = CODE_FOR_reload_df_di_load; |
| 3019 |
reg_addr[DDmode].reload_store = CODE_FOR_reload_dd_di_store; |
| 3020 |
reg_addr[DDmode].reload_load = CODE_FOR_reload_dd_di_load; |
| 3021 |
reg_addr[SFmode].reload_store = CODE_FOR_reload_sf_di_store; |
| 3022 |
reg_addr[SFmode].reload_load = CODE_FOR_reload_sf_di_load; |
| 3023 |
|
| 3024 |
if (FLOAT128_VECTOR_P (KFmode)) |
| 3025 |
{ |
| 3026 |
reg_addr[KFmode].reload_store = CODE_FOR_reload_kf_di_store; |
| 3027 |
reg_addr[KFmode].reload_load = CODE_FOR_reload_kf_di_load; |
| 3028 |
} |
| 3029 |
|
| 3030 |
if (FLOAT128_VECTOR_P (TFmode)) |
| 3031 |
{ |
| 3032 |
reg_addr[TFmode].reload_store = CODE_FOR_reload_tf_di_store; |
| 3033 |
reg_addr[TFmode].reload_load = CODE_FOR_reload_tf_di_load; |
| 3034 |
} |
| 3035 |
|
| 3036 |
/* Only provide a reload handler for SDmode if lfiwzx/stfiwx are |
| 3037 |
available. */ |
| 3038 |
if (TARGET_NO_SDMODE_STACK) |
| 3039 |
{ |
| 3040 |
reg_addr[SDmode].reload_store = CODE_FOR_reload_sd_di_store; |
| 3041 |
reg_addr[SDmode].reload_load = CODE_FOR_reload_sd_di_load; |
| 3042 |
} |
| 3043 |
|
| 3044 |
if (TARGET_VSX) |
| 3045 |
{ |
| 3046 |
reg_addr[TImode].reload_store = CODE_FOR_reload_ti_di_store; |
| 3047 |
reg_addr[TImode].reload_load = CODE_FOR_reload_ti_di_load; |
| 3048 |
} |
| 3049 |
|
| 3050 |
if (TARGET_DIRECT_MOVE && !TARGET_DIRECT_MOVE_128) |
| 3051 |
{ |
| 3052 |
reg_addr[TImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxti; |
| 3053 |
reg_addr[V1TImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv1ti; |
| 3054 |
reg_addr[V2DFmode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv2df; |
| 3055 |
reg_addr[V2DImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv2di; |
| 3056 |
reg_addr[V4SFmode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv4sf; |
| 3057 |
reg_addr[V4SImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv4si; |
| 3058 |
reg_addr[V8HImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv8hi; |
| 3059 |
reg_addr[V16QImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv16qi; |
| 3060 |
reg_addr[SFmode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxsf; |
| 3061 |
|
| 3062 |
reg_addr[TImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprti; |
| 3063 |
reg_addr[V1TImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv1ti; |
| 3064 |
reg_addr[V2DFmode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv2df; |
| 3065 |
reg_addr[V2DImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv2di; |
| 3066 |
reg_addr[V4SFmode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv4sf; |
| 3067 |
reg_addr[V4SImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv4si; |
| 3068 |
reg_addr[V8HImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv8hi; |
| 3069 |
reg_addr[V16QImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv16qi; |
| 3070 |
reg_addr[SFmode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprsf; |
| 3071 |
|
| 3072 |
if (FLOAT128_VECTOR_P (KFmode)) |
| 3073 |
{ |
| 3074 |
reg_addr[KFmode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxkf; |
| 3075 |
reg_addr[KFmode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprkf; |
| 3076 |
} |
| 3077 |
|
| 3078 |
if (FLOAT128_VECTOR_P (TFmode)) |
| 3079 |
{ |
| 3080 |
reg_addr[TFmode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxtf; |
| 3081 |
reg_addr[TFmode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprtf; |
| 3082 |
} |
| 3083 |
|
| 3084 |
if (TARGET_MMA) |
| 3085 |
{ |
| 3086 |
reg_addr[OOmode].reload_store = CODE_FOR_reload_oo_di_store; |
| 3087 |
reg_addr[OOmode].reload_load = CODE_FOR_reload_oo_di_load; |
| 3088 |
reg_addr[XOmode].reload_store = CODE_FOR_reload_xo_di_store; |
| 3089 |
reg_addr[XOmode].reload_load = CODE_FOR_reload_xo_di_load; |
| 3090 |
} |
| 3091 |
} |
| 3092 |
} |
| 3093 |
else |
| 3094 |
{ |
| 3095 |
reg_addr[V16QImode].reload_store = CODE_FOR_reload_v16qi_si_store; |
| 3096 |
reg_addr[V16QImode].reload_load = CODE_FOR_reload_v16qi_si_load; |
| 3097 |
reg_addr[V8HImode].reload_store = CODE_FOR_reload_v8hi_si_store; |
| 3098 |
reg_addr[V8HImode].reload_load = CODE_FOR_reload_v8hi_si_load; |
| 3099 |
reg_addr[V4SImode].reload_store = CODE_FOR_reload_v4si_si_store; |
| 3100 |
reg_addr[V4SImode].reload_load = CODE_FOR_reload_v4si_si_load; |
| 3101 |
reg_addr[V2DImode].reload_store = CODE_FOR_reload_v2di_si_store; |
| 3102 |
reg_addr[V2DImode].reload_load = CODE_FOR_reload_v2di_si_load; |
| 3103 |
reg_addr[V1TImode].reload_store = CODE_FOR_reload_v1ti_si_store; |
| 3104 |
reg_addr[V1TImode].reload_load = CODE_FOR_reload_v1ti_si_load; |
| 3105 |
reg_addr[V4SFmode].reload_store = CODE_FOR_reload_v4sf_si_store; |
| 3106 |
reg_addr[V4SFmode].reload_load = CODE_FOR_reload_v4sf_si_load; |
| 3107 |
reg_addr[V2DFmode].reload_store = CODE_FOR_reload_v2df_si_store; |
| 3108 |
reg_addr[V2DFmode].reload_load = CODE_FOR_reload_v2df_si_load; |
| 3109 |
reg_addr[DFmode].reload_store = CODE_FOR_reload_df_si_store; |
| 3110 |
reg_addr[DFmode].reload_load = CODE_FOR_reload_df_si_load; |
| 3111 |
reg_addr[DDmode].reload_store = CODE_FOR_reload_dd_si_store; |
| 3112 |
reg_addr[DDmode].reload_load = CODE_FOR_reload_dd_si_load; |
| 3113 |
reg_addr[SFmode].reload_store = CODE_FOR_reload_sf_si_store; |
| 3114 |
reg_addr[SFmode].reload_load = CODE_FOR_reload_sf_si_load; |
| 3115 |
|
| 3116 |
if (FLOAT128_VECTOR_P (KFmode)) |
| 3117 |
{ |
| 3118 |
reg_addr[KFmode].reload_store = CODE_FOR_reload_kf_si_store; |
| 3119 |
reg_addr[KFmode].reload_load = CODE_FOR_reload_kf_si_load; |
| 3120 |
} |
| 3121 |
|
| 3122 |
if (FLOAT128_IEEE_P (TFmode)) |
| 3123 |
{ |
| 3124 |
reg_addr[TFmode].reload_store = CODE_FOR_reload_tf_si_store; |
| 3125 |
reg_addr[TFmode].reload_load = CODE_FOR_reload_tf_si_load; |
| 3126 |
} |
| 3127 |
|
| 3128 |
/* Only provide a reload handler for SDmode if lfiwzx/stfiwx are |
| 3129 |
available. */ |
| 3130 |
if (TARGET_NO_SDMODE_STACK) |
| 3131 |
{ |
| 3132 |
reg_addr[SDmode].reload_store = CODE_FOR_reload_sd_si_store; |
| 3133 |
reg_addr[SDmode].reload_load = CODE_FOR_reload_sd_si_load; |
| 3134 |
} |
| 3135 |
|
| 3136 |
if (TARGET_VSX) |
| 3137 |
{ |
| 3138 |
reg_addr[TImode].reload_store = CODE_FOR_reload_ti_si_store; |
| 3139 |
reg_addr[TImode].reload_load = CODE_FOR_reload_ti_si_load; |
| 3140 |
} |
| 3141 |
|
| 3142 |
if (TARGET_DIRECT_MOVE) |
| 3143 |
{ |
| 3144 |
reg_addr[DImode].reload_fpr_gpr = CODE_FOR_reload_fpr_from_gprdi; |
| 3145 |
reg_addr[DDmode].reload_fpr_gpr = CODE_FOR_reload_fpr_from_gprdd; |
| 3146 |
reg_addr[DFmode].reload_fpr_gpr = CODE_FOR_reload_fpr_from_gprdf; |
| 3147 |
} |
| 3148 |
} |
| 3149 |
|
| 3150 |
reg_addr[DFmode].scalar_in_vmx_p = true; |
| 3151 |
reg_addr[DImode].scalar_in_vmx_p = true; |
| 3152 |
|
| 3153 |
if (TARGET_P8_VECTOR) |
| 3154 |
{ |
| 3155 |
reg_addr[SFmode].scalar_in_vmx_p = true; |
| 3156 |
reg_addr[SImode].scalar_in_vmx_p = true; |
| 3157 |
|
| 3158 |
if (TARGET_P9_VECTOR) |
| 3159 |
{ |
| 3160 |
reg_addr[HImode].scalar_in_vmx_p = true; |
| 3161 |
reg_addr[QImode].scalar_in_vmx_p = true; |
| 3162 |
} |
| 3163 |
} |
| 3164 |
} |
| 3165 |
|
| 3166 |
/* Precalculate HARD_REGNO_NREGS. */ |
| 3167 |
for (r = 0; HARD_REGISTER_NUM_P (r); ++r) |
| 3168 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 3169 |
rs6000_hard_regno_nregs[m][r] |
| 3170 |
= rs6000_hard_regno_nregs_internal (r, (machine_mode) m); |
| 3171 |
|
| 3172 |
/* Precalculate TARGET_HARD_REGNO_MODE_OK. */ |
| 3173 |
for (r = 0; HARD_REGISTER_NUM_P (r); ++r) |
| 3174 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 3175 |
rs6000_hard_regno_mode_ok_p[m][r] |
| 3176 |
= rs6000_hard_regno_mode_ok_uncached (r, (machine_mode) m); |
| 3177 |
|
| 3178 |
/* Precalculate CLASS_MAX_NREGS sizes. */ |
| 3179 |
for (c = 0; c < LIM_REG_CLASSES; ++c) |
| 3180 |
{ |
| 3181 |
int reg_size; |
| 3182 |
|
| 3183 |
if (TARGET_VSX && VSX_REG_CLASS_P (c)) |
| 3184 |
reg_size = UNITS_PER_VSX_WORD; |
| 3185 |
|
| 3186 |
else if (c == ALTIVEC_REGS) |
| 3187 |
reg_size = UNITS_PER_ALTIVEC_WORD; |
| 3188 |
|
| 3189 |
else if (c == FLOAT_REGS) |
| 3190 |
reg_size = UNITS_PER_FP_WORD; |
| 3191 |
|
| 3192 |
else |
| 3193 |
reg_size = UNITS_PER_WORD; |
| 3194 |
|
| 3195 |
for (m = 0; m < NUM_MACHINE_MODES; ++m) |
| 3196 |
{ |
| 3197 |
machine_mode m2 = (machine_mode)m; |
| 3198 |
int reg_size2 = reg_size; |
| 3199 |
|
| 3200 |
/* TDmode & IBM 128-bit floating point always takes 2 registers, even |
| 3201 |
in VSX. */ |
| 3202 |
if (TARGET_VSX && VSX_REG_CLASS_P (c) && FLOAT128_2REG_P (m)) |
| 3203 |
reg_size2 = UNITS_PER_FP_WORD; |
| 3204 |
|
| 3205 |
rs6000_class_max_nregs[m][c] |
| 3206 |
= (GET_MODE_SIZE (m2) + reg_size2 - 1) / reg_size2; |
| 3207 |
} |
| 3208 |
} |
| 3209 |
|
| 3210 |
/* Calculate which modes to automatically generate code to use a the |
| 3211 |
reciprocal divide and square root instructions. In the future, possibly |
| 3212 |
automatically generate the instructions even if the user did not specify |
| 3213 |
-mrecip. The older machines double precision reciprocal sqrt estimate is |
| 3214 |
not accurate enough. */ |
| 3215 |
memset (rs6000_recip_bits, 0, sizeof (rs6000_recip_bits)); |
| 3216 |
if (TARGET_FRES) |
| 3217 |
rs6000_recip_bits[SFmode] = RS6000_RECIP_MASK_HAVE_RE; |
| 3218 |
if (TARGET_FRE) |
| 3219 |
rs6000_recip_bits[DFmode] = RS6000_RECIP_MASK_HAVE_RE; |
| 3220 |
if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)) |
| 3221 |
rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE; |
| 3222 |
if (VECTOR_UNIT_VSX_P (V2DFmode)) |
| 3223 |
rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE; |
| 3224 |
|
| 3225 |
if (TARGET_FRSQRTES) |
| 3226 |
rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; |
| 3227 |
if (TARGET_FRSQRTE) |
| 3228 |
rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; |
| 3229 |
if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)) |
| 3230 |
rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; |
| 3231 |
if (VECTOR_UNIT_VSX_P (V2DFmode)) |
| 3232 |
rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; |
| 3233 |
|
| 3234 |
if (rs6000_recip_control) |
| 3235 |
{ |
| 3236 |
if (!flag_finite_math_only) |
| 3237 |
warning (0, "%qs requires %qs or %qs", "-mrecip", "-ffinite-math", |
| 3238 |
"-ffast-math"); |
| 3239 |
if (flag_trapping_math) |
| 3240 |
warning (0, "%qs requires %qs or %qs", "-mrecip", |
| 3241 |
"-fno-trapping-math", "-ffast-math"); |
| 3242 |
if (!flag_reciprocal_math) |
| 3243 |
warning (0, "%qs requires %qs or %qs", "-mrecip", "-freciprocal-math", |
| 3244 |
"-ffast-math"); |
| 3245 |
if (flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math) |
| 3246 |
{ |
| 3247 |
if (RS6000_RECIP_HAVE_RE_P (SFmode) |
| 3248 |
&& (rs6000_recip_control & RECIP_SF_DIV) != 0) |
| 3249 |
rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RE; |
| 3250 |
|
| 3251 |
if (RS6000_RECIP_HAVE_RE_P (DFmode) |
| 3252 |
&& (rs6000_recip_control & RECIP_DF_DIV) != 0) |
| 3253 |
rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RE; |
| 3254 |
|
| 3255 |
if (RS6000_RECIP_HAVE_RE_P (V4SFmode) |
| 3256 |
&& (rs6000_recip_control & RECIP_V4SF_DIV) != 0) |
| 3257 |
rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE; |
| 3258 |
|
| 3259 |
if (RS6000_RECIP_HAVE_RE_P (V2DFmode) |
| 3260 |
&& (rs6000_recip_control & RECIP_V2DF_DIV) != 0) |
| 3261 |
rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE; |
| 3262 |
|
| 3263 |
if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode) |
| 3264 |
&& (rs6000_recip_control & RECIP_SF_RSQRT) != 0) |
| 3265 |
rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; |
| 3266 |
|
| 3267 |
if (RS6000_RECIP_HAVE_RSQRTE_P (DFmode) |
| 3268 |
&& (rs6000_recip_control & RECIP_DF_RSQRT) != 0) |
| 3269 |
rs6000_recip_bits[DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; |
| 3270 |
|
| 3271 |
if (RS6000_RECIP_HAVE_RSQRTE_P (V4SFmode) |
| 3272 |
&& (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0) |
| 3273 |
rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; |
| 3274 |
|
| 3275 |
if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode) |
| 3276 |
&& (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0) |
| 3277 |
rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; |
| 3278 |
} |
| 3279 |
} |
| 3280 |
|
| 3281 |
/* Update the addr mask bits in reg_addr to help secondary reload and go if |
| 3282 |
legitimate address support to figure out the appropriate addressing to |
| 3283 |
use. */ |
| 3284 |
rs6000_setup_reg_addr_masks (); |
| 3285 |
|
| 3286 |
if (global_init_p || TARGET_DEBUG_TARGET) |
| 3287 |
{ |
| 3288 |
if (TARGET_DEBUG_REG) |
| 3289 |
rs6000_debug_reg_global (); |
| 3290 |
|
| 3291 |
if (TARGET_DEBUG_COST || TARGET_DEBUG_REG) |
| 3292 |
fprintf (stderr, |
| 3293 |
"SImode variable mult cost = %d\n" |
| 3294 |
"SImode constant mult cost = %d\n" |
| 3295 |
"SImode short constant mult cost = %d\n" |
| 3296 |
"DImode multipliciation cost = %d\n" |
| 3297 |
"SImode division cost = %d\n" |
| 3298 |
"DImode division cost = %d\n" |
| 3299 |
"Simple fp operation cost = %d\n" |
| 3300 |
"DFmode multiplication cost = %d\n" |
| 3301 |
"SFmode division cost = %d\n" |
| 3302 |
"DFmode division cost = %d\n" |
| 3303 |
"cache line size = %d\n" |
| 3304 |
"l1 cache size = %d\n" |
| 3305 |
"l2 cache size = %d\n" |
| 3306 |
"simultaneous prefetches = %d\n" |
| 3307 |
"\n", |
| 3308 |
rs6000_cost->mulsi, |
| 3309 |
rs6000_cost->mulsi_const, |
| 3310 |
rs6000_cost->mulsi_const9, |
| 3311 |
rs6000_cost->muldi, |
| 3312 |
rs6000_cost->divsi, |
| 3313 |
rs6000_cost->divdi, |
| 3314 |
rs6000_cost->fp, |
| 3315 |
rs6000_cost->dmul, |
| 3316 |
rs6000_cost->sdiv, |
| 3317 |
rs6000_cost->ddiv, |
| 3318 |
rs6000_cost->cache_line_size, |
| 3319 |
rs6000_cost->l1_cache_size, |
| 3320 |
rs6000_cost->l2_cache_size, |
| 3321 |
rs6000_cost->simultaneous_prefetches); |
| 3322 |
} |
| 3323 |
} |
| 3324 |
|
| 3325 |
#if TARGET_MACHO |
| 3326 |
/* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */ |
| 3327 |
|
| 3328 |
static void |
| 3329 |
darwin_rs6000_override_options (void) |
| 3330 |
{ |
| 3331 |
/* The Darwin ABI always includes AltiVec, can't be (validly) turned |
| 3332 |
off. */ |
| 3333 |
rs6000_altivec_abi = 1; |
| 3334 |
TARGET_ALTIVEC_VRSAVE = 1; |
| 3335 |
rs6000_current_abi = ABI_DARWIN; |
| 3336 |
|
| 3337 |
if (DEFAULT_ABI == ABI_DARWIN |
| 3338 |
&& TARGET_64BIT) |
| 3339 |
darwin_one_byte_bool = 1; |
| 3340 |
|
| 3341 |
if (TARGET_64BIT && ! TARGET_POWERPC64) |
| 3342 |
{ |
| 3343 |
rs6000_isa_flags |= OPTION_MASK_POWERPC64; |
| 3344 |
warning (0, "%qs requires PowerPC64 architecture, enabling", "-m64"); |
| 3345 |
} |
| 3346 |
|
| 3347 |
/* The linkers [ld64] that support 64Bit do not need the JBSR longcall |
| 3348 |
optimisation, and will not work with the most generic case (where the |
| 3349 |
symbol is undefined external, but there is no symbl stub). */ |
| 3350 |
if (TARGET_64BIT) |
| 3351 |
rs6000_default_long_calls = 0; |
| 3352 |
|
| 3353 |
/* ld_classic is (so far) still used for kernel (static) code, and supports |
| 3354 |
the JBSR longcall / branch islands. */ |
| 3355 |
if (flag_mkernel) |
| 3356 |
{ |
| 3357 |
rs6000_default_long_calls = 1; |
| 3358 |
|
| 3359 |
/* Allow a kext author to do -mkernel -mhard-float. */ |
| 3360 |
if (! (rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT)) |
| 3361 |
rs6000_isa_flags |= OPTION_MASK_SOFT_FLOAT; |
| 3362 |
} |
| 3363 |
|
| 3364 |
/* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes |
| 3365 |
Altivec. */ |
| 3366 |
if (!flag_mkernel && !flag_apple_kext |
| 3367 |
&& TARGET_64BIT |
| 3368 |
&& ! (rs6000_isa_flags_explicit & OPTION_MASK_ALTIVEC)) |
| 3369 |
rs6000_isa_flags |= OPTION_MASK_ALTIVEC; |
| 3370 |
|
| 3371 |
/* Unless the user (not the configurer) has explicitly overridden |
| 3372 |
it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to |
| 3373 |
G4 unless targeting the kernel. */ |
| 3374 |
if (!flag_mkernel |
| 3375 |
&& !flag_apple_kext |
| 3376 |
&& strverscmp (darwin_macosx_version_min, "10.5") >= 0 |
| 3377 |
&& ! (rs6000_isa_flags_explicit & OPTION_MASK_ALTIVEC) |
| 3378 |
&& ! OPTION_SET_P (rs6000_cpu_index)) |
| 3379 |
{ |
| 3380 |
rs6000_isa_flags |= OPTION_MASK_ALTIVEC; |
| 3381 |
} |
| 3382 |
} |
| 3383 |
#endif |
| 3384 |
|
| 3385 |
/* If not otherwise specified by a target, make 'long double' equivalent to |
| 3386 |
'double'. */ |
| 3387 |
|
| 3388 |
#ifndef RS6000_DEFAULT_LONG_DOUBLE_SIZE |
| 3389 |
#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64 |
| 3390 |
#endif |
| 3391 |
|
| 3392 |
/* Implement TARGET_MD_ASM_ADJUST. All asm statements are considered |
| 3393 |
to clobber the XER[CA] bit because clobbering that bit without telling |
| 3394 |
the compiler worked just fine with versions of GCC before GCC 5, and |
| 3395 |
breaking a lot of older code in ways that are hard to track down is |
| 3396 |
not such a great idea. */ |
| 3397 |
|
| 3398 |
static rtx_insn * |
| 3399 |
rs6000_md_asm_adjust (vec<rtx> & /*outputs*/, vec<rtx> & /*inputs*/, |
| 3400 |
vec<machine_mode> & /*input_modes*/, |
| 3401 |
vec<const char *> & /*constraints*/, |
| 3402 |
vec<rtx> &/*uses*/, vec<rtx> &clobbers, |
| 3403 |
HARD_REG_SET &clobbered_regs, location_t /*loc*/) |
| 3404 |
{ |
| 3405 |
clobbers.safe_push (gen_rtx_REG (SImode, CA_REGNO)); |
| 3406 |
SET_HARD_REG_BIT (clobbered_regs, CA_REGNO); |
| 3407 |
return NULL; |
| 3408 |
} |
| 3409 |
|
| 3410 |
/* This target function is similar to the hook TARGET_OPTION_OVERRIDE |
| 3411 |
but is called when the optimize level is changed via an attribute or |
| 3412 |
pragma or when it is reset at the end of the code affected by the |
| 3413 |
attribute or pragma. It is not called at the beginning of compilation |
| 3414 |
when TARGET_OPTION_OVERRIDE is called so if you want to perform these |
| 3415 |
actions then, you should have TARGET_OPTION_OVERRIDE call |
| 3416 |
TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE. */ |
| 3417 |
|
| 3418 |
static void |
| 3419 |
rs6000_override_options_after_change (void) |
| 3420 |
{ |
| 3421 |
/* Explicit -funroll-loops turns -munroll-only-small-loops off, and |
| 3422 |
turns -frename-registers on. */ |
| 3423 |
if ((OPTION_SET_P (flag_unroll_loops) && flag_unroll_loops) |
| 3424 |
|| (OPTION_SET_P (flag_unroll_all_loops) |
| 3425 |
&& flag_unroll_all_loops)) |
| 3426 |
{ |
| 3427 |
if (!OPTION_SET_P (unroll_only_small_loops)) |
| 3428 |
unroll_only_small_loops = 0; |
| 3429 |
if (!OPTION_SET_P (flag_rename_registers)) |
| 3430 |
flag_rename_registers = 1; |
| 3431 |
if (!OPTION_SET_P (flag_cunroll_grow_size)) |
| 3432 |
flag_cunroll_grow_size = 1; |
| 3433 |
} |
| 3434 |
else if (!OPTION_SET_P (flag_cunroll_grow_size)) |
| 3435 |
flag_cunroll_grow_size = flag_peel_loops || optimize >= 3; |
| 3436 |
|
| 3437 |
/* One of the late-combine passes runs after register allocation |
| 3438 |
and can match define_insn_and_splits that were previously used |
| 3439 |
only before register allocation. Some of those define_insn_and_splits |
| 3440 |
use gen_reg_rtx unconditionally. Disable late-combine by default |
| 3441 |
until the define_insn_and_splits are fixed. */ |
| 3442 |
if (!OPTION_SET_P (flag_late_combine_instructions)) |
| 3443 |
flag_late_combine_instructions = 0; |
| 3444 |
} |
| 3445 |
|
| 3446 |
#ifdef TARGET_USES_LINUX64_OPT |
| 3447 |
static void |
| 3448 |
rs6000_linux64_override_options () |
| 3449 |
{ |
| 3450 |
if (!OPTION_SET_P (rs6000_alignment_flags)) |
| 3451 |
rs6000_alignment_flags = MASK_ALIGN_NATURAL; |
| 3452 |
if (rs6000_isa_flags & OPTION_MASK_64BIT) |
| 3453 |
{ |
| 3454 |
if (DEFAULT_ABI != ABI_AIX) |
| 3455 |
{ |
| 3456 |
rs6000_current_abi = ABI_AIX; |
| 3457 |
error (INVALID_64BIT, "call"); |
| 3458 |
} |
| 3459 |
dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); |
| 3460 |
if (ELFv2_ABI_CHECK) |
| 3461 |
{ |
| 3462 |
rs6000_current_abi = ABI_ELFv2; |
| 3463 |
if (dot_symbols) |
| 3464 |
error ("%<-mcall-aixdesc%> incompatible with %<-mabi=elfv2%>"); |
| 3465 |
} |
| 3466 |
if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) |
| 3467 |
{ |
| 3468 |
rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; |
| 3469 |
error (INVALID_64BIT, "relocatable"); |
| 3470 |
} |
| 3471 |
if (rs6000_isa_flags & OPTION_MASK_EABI) |
| 3472 |
{ |
| 3473 |
rs6000_isa_flags &= ~OPTION_MASK_EABI; |
| 3474 |
error (INVALID_64BIT, "eabi"); |
| 3475 |
} |
| 3476 |
if (TARGET_PROTOTYPE) |
| 3477 |
{ |
| 3478 |
target_prototype = 0; |
| 3479 |
error (INVALID_64BIT, "prototype"); |
| 3480 |
} |
| 3481 |
if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) |
| 3482 |
{ |
| 3483 |
rs6000_isa_flags |= OPTION_MASK_POWERPC64; |
| 3484 |
error ("%<-m64%> requires a PowerPC64 cpu"); |
| 3485 |
} |
| 3486 |
if (!OPTION_SET_P (rs6000_current_cmodel)) |
| 3487 |
SET_CMODEL (CMODEL_MEDIUM); |
| 3488 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_MINIMAL_TOC) != 0) |
| 3489 |
{ |
| 3490 |
if (OPTION_SET_P (rs6000_current_cmodel) |
| 3491 |
&& rs6000_current_cmodel != CMODEL_SMALL) |
| 3492 |
error ("%<-mcmodel%> incompatible with other toc options"); |
| 3493 |
if (TARGET_MINIMAL_TOC) |
| 3494 |
SET_CMODEL (CMODEL_SMALL); |
| 3495 |
else if (TARGET_PCREL |
| 3496 |
|| (PCREL_SUPPORTED_BY_OS |
| 3497 |
&& (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0)) |
| 3498 |
/* Ignore -mno-minimal-toc. */ |
| 3499 |
; |
| 3500 |
else |
| 3501 |
SET_CMODEL (CMODEL_SMALL); |
| 3502 |
} |
| 3503 |
if (rs6000_current_cmodel != CMODEL_SMALL) |
| 3504 |
{ |
| 3505 |
if (!OPTION_SET_P (TARGET_NO_FP_IN_TOC)) |
| 3506 |
TARGET_NO_FP_IN_TOC = rs6000_current_cmodel == CMODEL_MEDIUM; |
| 3507 |
if (!OPTION_SET_P (TARGET_NO_SUM_IN_TOC)) |
| 3508 |
TARGET_NO_SUM_IN_TOC = 0; |
| 3509 |
} |
| 3510 |
if (TARGET_PLTSEQ && DEFAULT_ABI != ABI_ELFv2) |
| 3511 |
{ |
| 3512 |
if (OPTION_SET_P (rs6000_pltseq)) |
| 3513 |
warning (0, "%qs unsupported for this ABI", |
| 3514 |
"-mpltseq"); |
| 3515 |
rs6000_pltseq = false; |
| 3516 |
} |
| 3517 |
} |
| 3518 |
else if (TARGET_64BIT) |
| 3519 |
error (INVALID_32BIT, "32"); |
| 3520 |
else |
| 3521 |
{ |
| 3522 |
if (TARGET_PROFILE_KERNEL) |
| 3523 |
{ |
| 3524 |
profile_kernel = 0; |
| 3525 |
error (INVALID_32BIT, "profile-kernel"); |
| 3526 |
} |
| 3527 |
if (OPTION_SET_P (rs6000_current_cmodel)) |
| 3528 |
{ |
| 3529 |
SET_CMODEL (CMODEL_SMALL); |
| 3530 |
error (INVALID_32BIT, "cmodel"); |
| 3531 |
} |
| 3532 |
} |
| 3533 |
} |
| 3534 |
#endif |
| 3535 |
|
| 3536 |
/* Return true if we are using GLIBC, and it supports IEEE 128-bit long double. |
| 3537 |
This support is only in little endian GLIBC 2.32 or newer. */ |
| 3538 |
static bool |
| 3539 |
glibc_supports_ieee_128bit (void) |
| 3540 |
{ |
| 3541 |
#ifdef OPTION_GLIBC |
| 3542 |
if (OPTION_GLIBC && !BYTES_BIG_ENDIAN |
| 3543 |
&& ((TARGET_GLIBC_MAJOR * 1000) + TARGET_GLIBC_MINOR) >= 2032) |
| 3544 |
return true; |
| 3545 |
#endif /* OPTION_GLIBC. */ |
| 3546 |
|
| 3547 |
return false; |
| 3548 |
} |
| 3549 |
|
| 3550 |
/* Override command line options. |
| 3551 |
|
| 3552 |
Combine build-specific configuration information with options |
| 3553 |
specified on the command line to set various state variables which |
| 3554 |
influence code generation, optimization, and expansion of built-in |
| 3555 |
functions. Assure that command-line configuration preferences are |
| 3556 |
compatible with each other and with the build configuration; issue |
| 3557 |
warnings while adjusting configuration or error messages while |
| 3558 |
rejecting configuration. |
| 3559 |
|
| 3560 |
Upon entry to this function: |
| 3561 |
|
| 3562 |
This function is called once at the beginning of |
| 3563 |
compilation, and then again at the start and end of compiling |
| 3564 |
each section of code that has a different configuration, as |
| 3565 |
indicated, for example, by adding the |
| 3566 |
|
| 3567 |
__attribute__((__target__("cpu=power9"))) |
| 3568 |
|
| 3569 |
qualifier to a function definition or, for example, by bracketing |
| 3570 |
code between |
| 3571 |
|
| 3572 |
#pragma GCC target("altivec") |
| 3573 |
|
| 3574 |
and |
| 3575 |
|
| 3576 |
#pragma GCC reset_options |
| 3577 |
|
| 3578 |
directives. Parameter global_init_p is true for the initial |
| 3579 |
invocation, which initializes global variables, and false for all |
| 3580 |
subsequent invocations. |
| 3581 |
|
| 3582 |
|
| 3583 |
Various global state information is assumed to be valid. This |
| 3584 |
includes OPTION_TARGET_CPU_DEFAULT, representing the name of the |
| 3585 |
default CPU specified at build configure time, TARGET_DEFAULT, |
| 3586 |
representing the default set of option flags for the default |
| 3587 |
target, and OPTION_SET_P (rs6000_isa_flags), representing |
| 3588 |
which options were requested on the command line. |
| 3589 |
|
| 3590 |
Upon return from this function: |
| 3591 |
|
| 3592 |
rs6000_isa_flags_explicit has a non-zero bit for each flag that |
| 3593 |
was set by name on the command line. Additionally, if certain |
| 3594 |
attributes are automatically enabled or disabled by this function |
| 3595 |
in order to assure compatibility between options and |
| 3596 |
configuration, the flags associated with those attributes are |
| 3597 |
also set. By setting these "explicit bits", we avoid the risk |
| 3598 |
that other code might accidentally overwrite these particular |
| 3599 |
attributes with "default values". |
| 3600 |
|
| 3601 |
The various bits of rs6000_isa_flags are set to indicate the |
| 3602 |
target options that have been selected for the most current |
| 3603 |
compilation efforts. This has the effect of also turning on the |
| 3604 |
associated TARGET_XXX values since these are macros which are |
| 3605 |
generally defined to test the corresponding bit of the |
| 3606 |
rs6000_isa_flags variable. |
| 3607 |
|
| 3608 |
Various other global variables and fields of global structures |
| 3609 |
(over 50 in all) are initialized to reflect the desired options |
| 3610 |
for the most current compilation efforts. */ |
| 3611 |
|
| 3612 |
static bool |
| 3613 |
rs6000_option_override_internal (bool global_init_p) |
| 3614 |
{ |
| 3615 |
bool ret = true; |
| 3616 |
|
| 3617 |
HOST_WIDE_INT set_masks; |
| 3618 |
HOST_WIDE_INT ignore_masks; |
| 3619 |
int cpu_index = -1; |
| 3620 |
int tune_index; |
| 3621 |
struct cl_target_option *main_target_opt |
| 3622 |
= ((global_init_p || target_option_default_node == NULL) |
| 3623 |
? NULL : TREE_TARGET_OPTION (target_option_default_node)); |
| 3624 |
|
| 3625 |
/* Print defaults. */ |
| 3626 |
if ((TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) && global_init_p) |
| 3627 |
rs6000_print_isa_options (stderr, 0, "TARGET_DEFAULT", TARGET_DEFAULT); |
| 3628 |
|
| 3629 |
/* Remember the explicit arguments. */ |
| 3630 |
if (global_init_p) |
| 3631 |
rs6000_isa_flags_explicit = OPTION_SET_P (rs6000_isa_flags); |
| 3632 |
|
| 3633 |
/* On 64-bit Darwin, power alignment is ABI-incompatible with some C |
| 3634 |
library functions, so warn about it. The flag may be useful for |
| 3635 |
performance studies from time to time though, so don't disable it |
| 3636 |
entirely. */ |
| 3637 |
if (OPTION_SET_P (rs6000_alignment_flags) |
| 3638 |
&& rs6000_alignment_flags == MASK_ALIGN_POWER |
| 3639 |
&& DEFAULT_ABI == ABI_DARWIN |
| 3640 |
&& TARGET_64BIT) |
| 3641 |
warning (0, "%qs is not supported for 64-bit Darwin;" |
| 3642 |
" it is incompatible with the installed C and C++ libraries", |
| 3643 |
"-malign-power"); |
| 3644 |
|
| 3645 |
/* Numerous experiment shows that IRA based loop pressure |
| 3646 |
calculation works better for RTL loop invariant motion on targets |
| 3647 |
with enough (>= 32) registers. It is an expensive optimization. |
| 3648 |
So it is on only for peak performance. */ |
| 3649 |
if (optimize >= 3 && global_init_p |
| 3650 |
&& !OPTION_SET_P (flag_ira_loop_pressure)) |
| 3651 |
flag_ira_loop_pressure = 1; |
| 3652 |
|
| 3653 |
/* -fsanitize=address needs to turn on -fasynchronous-unwind-tables in order |
| 3654 |
for tracebacks to be complete but not if any -fasynchronous-unwind-tables |
| 3655 |
options were already specified. */ |
| 3656 |
if (flag_sanitize & SANITIZE_USER_ADDRESS |
| 3657 |
&& !OPTION_SET_P (flag_asynchronous_unwind_tables)) |
| 3658 |
flag_asynchronous_unwind_tables = 1; |
| 3659 |
|
| 3660 |
/* -fvariable-expansion-in-unroller is a win for POWER whenever the |
| 3661 |
loop unroller is active. It is only checked during unrolling, so |
| 3662 |
we can just set it on by default. */ |
| 3663 |
if (!OPTION_SET_P (flag_variable_expansion_in_unroller)) |
| 3664 |
flag_variable_expansion_in_unroller = 1; |
| 3665 |
|
| 3666 |
/* Set the pointer size. */ |
| 3667 |
if (TARGET_64BIT) |
| 3668 |
{ |
| 3669 |
rs6000_pmode = DImode; |
| 3670 |
rs6000_pointer_size = 64; |
| 3671 |
} |
| 3672 |
else |
| 3673 |
{ |
| 3674 |
rs6000_pmode = SImode; |
| 3675 |
rs6000_pointer_size = 32; |
| 3676 |
} |
| 3677 |
|
| 3678 |
/* Some OSs don't support saving Altivec registers. On those OSs, we don't |
| 3679 |
touch the OPTION_MASK_ALTIVEC settings; if the user wants it, the user |
| 3680 |
must explicitly specify it and we won't interfere with the user's |
| 3681 |
specification. */ |
| 3682 |
|
| 3683 |
set_masks = POWERPC_MASKS; |
| 3684 |
#ifdef OS_MISSING_ALTIVEC |
| 3685 |
if (OS_MISSING_ALTIVEC) |
| 3686 |
set_masks &= ~(OPTION_MASK_ALTIVEC | OPTION_MASK_VSX |
| 3687 |
| OTHER_VSX_VECTOR_MASKS); |
| 3688 |
#endif |
| 3689 |
|
| 3690 |
/* Don't override by the processor default if given explicitly. */ |
| 3691 |
set_masks &= ~rs6000_isa_flags_explicit; |
| 3692 |
|
| 3693 |
/* Without option powerpc64 specified explicitly, we need to ensure |
| 3694 |
powerpc64 always enabled for 64 bit here, otherwise some following |
| 3695 |
checks can use unexpected TARGET_POWERPC64 value. */ |
| 3696 |
if (!(rs6000_isa_flags_explicit & OPTION_MASK_POWERPC64) |
| 3697 |
&& TARGET_64BIT) |
| 3698 |
{ |
| 3699 |
rs6000_isa_flags |= OPTION_MASK_POWERPC64; |
| 3700 |
/* Need to stop powerpc64 from being unset in later processing, |
| 3701 |
so clear it in set_masks. But as PR108240 shows, to keep it |
| 3702 |
consistent with before, we want to make this only if 64 bit |
| 3703 |
is enabled explicitly. This is a hack, revisit this later. */ |
| 3704 |
if (rs6000_isa_flags_explicit & OPTION_MASK_64BIT) |
| 3705 |
set_masks &= ~OPTION_MASK_POWERPC64; |
| 3706 |
} |
| 3707 |
|
| 3708 |
/* Process the -mcpu=<xxx> and -mtune=<xxx> argument. If the user changed |
| 3709 |
the cpu in a target attribute or pragma, but did not specify a tuning |
| 3710 |
option, use the cpu for the tuning option rather than the option specified |
| 3711 |
with -mtune on the command line. Process a '--with-cpu' configuration |
| 3712 |
request as an implicit --cpu. */ |
| 3713 |
if (rs6000_cpu_index >= 0) |
| 3714 |
cpu_index = rs6000_cpu_index; |
| 3715 |
else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index >= 0) |
| 3716 |
cpu_index = main_target_opt->x_rs6000_cpu_index; |
| 3717 |
else if (OPTION_TARGET_CPU_DEFAULT) |
| 3718 |
cpu_index = rs6000_cpu_name_lookup (OPTION_TARGET_CPU_DEFAULT); |
| 3719 |
|
| 3720 |
/* If we have a cpu, either through an explicit -mcpu=<xxx> or if the |
| 3721 |
compiler was configured with --with-cpu=<xxx>, replace all of the ISA bits |
| 3722 |
with those from the cpu, except for options that were explicitly set. If |
| 3723 |
we don't have a cpu, do not override the target bits set in |
| 3724 |
TARGET_DEFAULT. */ |
| 3725 |
if (cpu_index >= 0) |
| 3726 |
{ |
| 3727 |
rs6000_cpu_index = cpu_index; |
| 3728 |
rs6000_isa_flags &= ~set_masks; |
| 3729 |
rs6000_isa_flags |= (processor_target_table[cpu_index].target_enable |
| 3730 |
& set_masks); |
| 3731 |
} |
| 3732 |
else |
| 3733 |
{ |
| 3734 |
/* If no -mcpu=<xxx>, inherit any default options that were cleared via |
| 3735 |
POWERPC_MASKS. Originally, TARGET_DEFAULT was used to initialize |
| 3736 |
target_flags via the TARGET_DEFAULT_TARGET_FLAGS hook. When we switched |
| 3737 |
to using rs6000_isa_flags, we need to do the initialization here. |
| 3738 |
|
| 3739 |
If there is a TARGET_DEFAULT, use that. Otherwise fall back to using |
| 3740 |
-mcpu=powerpc, -mcpu=powerpc64, or -mcpu=powerpc64le defaults. */ |
| 3741 |
HOST_WIDE_INT flags; |
| 3742 |
if (TARGET_DEFAULT) |
| 3743 |
flags = TARGET_DEFAULT; |
| 3744 |
else |
| 3745 |
{ |
| 3746 |
/* PowerPC 64-bit LE requires at least ISA 2.07. */ |
| 3747 |
const char *default_cpu = (!TARGET_POWERPC64 |
| 3748 |
? "powerpc" |
| 3749 |
: (BYTES_BIG_ENDIAN |
| 3750 |
? "powerpc64" |
| 3751 |
: "powerpc64le")); |
| 3752 |
int default_cpu_index = rs6000_cpu_name_lookup (default_cpu); |
| 3753 |
flags = processor_target_table[default_cpu_index].target_enable; |
| 3754 |
} |
| 3755 |
rs6000_isa_flags |= (flags & ~rs6000_isa_flags_explicit); |
| 3756 |
} |
| 3757 |
|
| 3758 |
/* Don't expect powerpc64 enabled on those OSes with OS_MISSING_POWERPC64, |
| 3759 |
since they do not save and restore the high half of the GPRs correctly |
| 3760 |
in all cases. If the user explicitly specifies it, we won't interfere |
| 3761 |
with the user's specification. */ |
| 3762 |
#ifdef OS_MISSING_POWERPC64 |
| 3763 |
if (OS_MISSING_POWERPC64 |
| 3764 |
&& TARGET_32BIT |
| 3765 |
&& TARGET_POWERPC64 |
| 3766 |
&& !(rs6000_isa_flags_explicit & OPTION_MASK_POWERPC64)) |
| 3767 |
rs6000_isa_flags &= ~OPTION_MASK_POWERPC64; |
| 3768 |
#endif |
| 3769 |
|
| 3770 |
if (rs6000_tune_index >= 0) |
| 3771 |
tune_index = rs6000_tune_index; |
| 3772 |
else if (cpu_index >= 0) |
| 3773 |
rs6000_tune_index = tune_index = cpu_index; |
| 3774 |
else |
| 3775 |
{ |
| 3776 |
size_t i; |
| 3777 |
enum processor_type tune_proc |
| 3778 |
= (TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT); |
| 3779 |
|
| 3780 |
tune_index = -1; |
| 3781 |
for (i = 0; i < ARRAY_SIZE (processor_target_table); i++) |
| 3782 |
if (processor_target_table[i].processor == tune_proc) |
| 3783 |
{ |
| 3784 |
tune_index = i; |
| 3785 |
break; |
| 3786 |
} |
| 3787 |
} |
| 3788 |
|
| 3789 |
if (cpu_index >= 0) |
| 3790 |
rs6000_cpu = processor_target_table[cpu_index].processor; |
| 3791 |
else |
| 3792 |
rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT; |
| 3793 |
|
| 3794 |
gcc_assert (tune_index >= 0); |
| 3795 |
rs6000_tune = processor_target_table[tune_index].processor; |
| 3796 |
|
| 3797 |
if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3 |
| 3798 |
|| rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64 |
| 3799 |
|| rs6000_cpu == PROCESSOR_PPCE5500) |
| 3800 |
{ |
| 3801 |
if (TARGET_ALTIVEC) |
| 3802 |
error ("AltiVec not supported in this target"); |
| 3803 |
} |
| 3804 |
|
| 3805 |
/* If we are optimizing big endian systems for space, use the load/store |
| 3806 |
multiple instructions. */ |
| 3807 |
if (BYTES_BIG_ENDIAN && optimize_size) |
| 3808 |
rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_MULTIPLE; |
| 3809 |
|
| 3810 |
/* Don't allow -mmultiple on little endian systems unless the cpu is a 750, |
| 3811 |
because the hardware doesn't support the instructions used in little |
| 3812 |
endian mode, and causes an alignment trap. The 750 does not cause an |
| 3813 |
alignment trap (except when the target is unaligned). */ |
| 3814 |
|
| 3815 |
if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750 && TARGET_MULTIPLE) |
| 3816 |
{ |
| 3817 |
rs6000_isa_flags &= ~OPTION_MASK_MULTIPLE; |
| 3818 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_MULTIPLE) != 0) |
| 3819 |
warning (0, "%qs is not supported on little endian systems", |
| 3820 |
"-mmultiple"); |
| 3821 |
} |
| 3822 |
|
| 3823 |
/* If little-endian, default to -mstrict-align on older processors. */ |
| 3824 |
if (!BYTES_BIG_ENDIAN |
| 3825 |
&& !(processor_target_table[tune_index].target_enable |
| 3826 |
& OPTION_MASK_POWER8)) |
| 3827 |
rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_STRICT_ALIGN; |
| 3828 |
|
| 3829 |
/* Add some warnings for VSX. */ |
| 3830 |
if (TARGET_VSX) |
| 3831 |
{ |
| 3832 |
bool explicit_vsx_p = rs6000_isa_flags_explicit & OPTION_MASK_VSX; |
| 3833 |
if (!TARGET_HARD_FLOAT) |
| 3834 |
{ |
| 3835 |
if (explicit_vsx_p) |
| 3836 |
{ |
| 3837 |
if (rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT) |
| 3838 |
error ("%<-mvsx%> and %<-msoft-float%> are incompatible"); |
| 3839 |
else |
| 3840 |
warning (0, N_("%<-mvsx%> requires hardware floating-point")); |
| 3841 |
} |
| 3842 |
rs6000_isa_flags &= ~OPTION_MASK_VSX; |
| 3843 |
rs6000_isa_flags_explicit |= OPTION_MASK_VSX; |
| 3844 |
} |
| 3845 |
else if (TARGET_AVOID_XFORM > 0) |
| 3846 |
{ |
| 3847 |
if (explicit_vsx_p && OPTION_SET_P (TARGET_AVOID_XFORM)) |
| 3848 |
error ("%<-mvsx%> and %<-mavoid-indexed-addresses%>" |
| 3849 |
" are incompatible"); |
| 3850 |
else |
| 3851 |
warning (0, N_("%<-mvsx%> needs indexed addressing")); |
| 3852 |
rs6000_isa_flags &= ~OPTION_MASK_VSX; |
| 3853 |
rs6000_isa_flags_explicit |= OPTION_MASK_VSX; |
| 3854 |
} |
| 3855 |
else if (!TARGET_ALTIVEC |
| 3856 |
&& (rs6000_isa_flags_explicit & OPTION_MASK_ALTIVEC)) |
| 3857 |
{ |
| 3858 |
if (explicit_vsx_p) |
| 3859 |
error ("%<-mvsx%> and %<-mno-altivec%> are incompatible"); |
| 3860 |
else |
| 3861 |
warning (0, N_("%<-mno-altivec%> disables vsx")); |
| 3862 |
rs6000_isa_flags &= ~OPTION_MASK_VSX; |
| 3863 |
rs6000_isa_flags_explicit |= OPTION_MASK_VSX; |
| 3864 |
} |
| 3865 |
} |
| 3866 |
|
| 3867 |
/* If hard-float/altivec/vsx were explicitly turned off then don't allow |
| 3868 |
the -mcpu setting to enable options that conflict. */ |
| 3869 |
if ((!TARGET_HARD_FLOAT || !TARGET_ALTIVEC || !TARGET_VSX) |
| 3870 |
&& (rs6000_isa_flags_explicit & (OPTION_MASK_SOFT_FLOAT |
| 3871 |
| OPTION_MASK_ALTIVEC |
| 3872 |
| OPTION_MASK_VSX)) != 0) |
| 3873 |
rs6000_isa_flags &= ~((OPTION_MASK_P8_VECTOR | OPTION_MASK_CRYPTO) |
| 3874 |
& ~rs6000_isa_flags_explicit); |
| 3875 |
|
| 3876 |
if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) |
| 3877 |
rs6000_print_isa_options (stderr, 0, "before defaults", rs6000_isa_flags); |
| 3878 |
|
| 3879 |
#ifdef XCOFF_DEBUGGING_INFO |
| 3880 |
/* For AIX default to 64-bit DWARF. */ |
| 3881 |
if (!OPTION_SET_P (dwarf_offset_size)) |
| 3882 |
dwarf_offset_size = POINTER_SIZE_UNITS; |
| 3883 |
#endif |
| 3884 |
|
| 3885 |
/* Handle explicit -mno-{altivec,vsx} and turn off all of |
| 3886 |
the options that depend on those flags. */ |
| 3887 |
ignore_masks = rs6000_disable_incompatible_switches (); |
| 3888 |
|
| 3889 |
/* For the newer switches (vsx, dfp, etc.) set some of the older options, |
| 3890 |
unless the user explicitly used the -mno-<option> to disable the code. */ |
| 3891 |
if (TARGET_P9_VECTOR || TARGET_MODULO || TARGET_P9_MISC) |
| 3892 |
rs6000_isa_flags |= (ISA_3_0_MASKS_SERVER & ~ignore_masks); |
| 3893 |
else if (TARGET_P9_MINMAX) |
| 3894 |
{ |
| 3895 |
if (cpu_index >= 0) |
| 3896 |
{ |
| 3897 |
if (cpu_index == PROCESSOR_POWER9) |
| 3898 |
{ |
| 3899 |
/* legacy behavior: allow -mcpu=power9 with certain |
| 3900 |
capabilities explicitly disabled. */ |
| 3901 |
rs6000_isa_flags |= (ISA_3_0_MASKS_SERVER & ~ignore_masks); |
| 3902 |
} |
| 3903 |
else |
| 3904 |
error ("power9 target option is incompatible with %<%s=<xxx>%> " |
| 3905 |
"for <xxx> less than power9", "-mcpu"); |
| 3906 |
} |
| 3907 |
else if ((ISA_3_0_MASKS_SERVER & rs6000_isa_flags_explicit) |
| 3908 |
!= (ISA_3_0_MASKS_SERVER & rs6000_isa_flags |
| 3909 |
& rs6000_isa_flags_explicit)) |
| 3910 |
/* Enforce that none of the ISA_3_0_MASKS_SERVER flags |
| 3911 |
were explicitly cleared. */ |
| 3912 |
error ("%qs incompatible with explicitly disabled options", |
| 3913 |
"-mpower9-minmax"); |
| 3914 |
else |
| 3915 |
rs6000_isa_flags |= ISA_3_0_MASKS_SERVER; |
| 3916 |
} |
| 3917 |
else if (TARGET_P8_VECTOR || TARGET_POWER8 || TARGET_CRYPTO) |
| 3918 |
rs6000_isa_flags |= (ISA_2_7_MASKS_SERVER & ~ignore_masks); |
| 3919 |
else if (TARGET_VSX) |
| 3920 |
rs6000_isa_flags |= (ISA_2_6_MASKS_SERVER & ~ignore_masks); |
| 3921 |
else if (TARGET_POPCNTD) |
| 3922 |
rs6000_isa_flags |= (ISA_2_6_MASKS_EMBEDDED & ~ignore_masks); |
| 3923 |
else if (TARGET_DFP) |
| 3924 |
rs6000_isa_flags |= (ISA_2_5_MASKS_SERVER & ~ignore_masks); |
| 3925 |
else if (TARGET_CMPB) |
| 3926 |
rs6000_isa_flags |= (ISA_2_5_MASKS_EMBEDDED & ~ignore_masks); |
| 3927 |
else if (TARGET_FPRND) |
| 3928 |
rs6000_isa_flags |= (ISA_2_4_MASKS & ~ignore_masks); |
| 3929 |
else if (TARGET_POPCNTB) |
| 3930 |
rs6000_isa_flags |= (ISA_2_2_MASKS & ~ignore_masks); |
| 3931 |
else if (TARGET_ALTIVEC) |
| 3932 |
rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); |
| 3933 |
|
| 3934 |
/* Disable VSX and Altivec silently if the user switched cpus to power7 in a |
| 3935 |
target attribute or pragma which automatically enables both options, |
| 3936 |
unless the altivec ABI was set. This is set by default for 64-bit, but |
| 3937 |
not for 32-bit. Don't move this before the above code using ignore_masks, |
| 3938 |
since it can reset the cleared VSX/ALTIVEC flag again. */ |
| 3939 |
if (main_target_opt && !main_target_opt->x_rs6000_altivec_abi) |
| 3940 |
{ |
| 3941 |
rs6000_isa_flags &= ~(OPTION_MASK_VSX & ~rs6000_isa_flags_explicit); |
| 3942 |
/* Don't mask off ALTIVEC if it is enabled by an explicit VSX. */ |
| 3943 |
if (!TARGET_VSX) |
| 3944 |
rs6000_isa_flags &= ~(OPTION_MASK_ALTIVEC & ~rs6000_isa_flags_explicit); |
| 3945 |
} |
| 3946 |
|
| 3947 |
if (TARGET_CRYPTO && !TARGET_ALTIVEC) |
| 3948 |
{ |
| 3949 |
if (rs6000_isa_flags_explicit & OPTION_MASK_CRYPTO) |
| 3950 |
error ("%qs requires %qs", "-mcrypto", "-maltivec"); |
| 3951 |
rs6000_isa_flags &= ~OPTION_MASK_CRYPTO; |
| 3952 |
} |
| 3953 |
|
| 3954 |
if (!TARGET_FPRND && TARGET_VSX) |
| 3955 |
{ |
| 3956 |
if (rs6000_isa_flags_explicit & OPTION_MASK_FPRND) |
| 3957 |
/* TARGET_VSX = 1 implies Power 7 and newer */ |
| 3958 |
error ("%qs requires %qs", "-mvsx", "-mfprnd"); |
| 3959 |
rs6000_isa_flags &= ~OPTION_MASK_FPRND; |
| 3960 |
} |
| 3961 |
|
| 3962 |
/* Assert !TARGET_VSX if !TARGET_ALTIVEC and make some adjustments |
| 3963 |
based on either !TARGET_VSX or !TARGET_ALTIVEC concise. */ |
| 3964 |
gcc_assert (TARGET_ALTIVEC || !TARGET_VSX); |
| 3965 |
|
| 3966 |
if (TARGET_P8_VECTOR && !TARGET_VSX) |
| 3967 |
rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR; |
| 3968 |
|
| 3969 |
if (TARGET_DFP && !TARGET_HARD_FLOAT) |
| 3970 |
{ |
| 3971 |
if (rs6000_isa_flags_explicit & OPTION_MASK_DFP) |
| 3972 |
error ("%qs requires %qs", "-mhard-dfp", "-mhard-float"); |
| 3973 |
rs6000_isa_flags &= ~OPTION_MASK_DFP; |
| 3974 |
} |
| 3975 |
|
| 3976 |
/* The quad memory instructions only works in 64-bit mode. In 32-bit mode, |
| 3977 |
silently turn off quad memory mode. */ |
| 3978 |
if ((TARGET_QUAD_MEMORY || TARGET_QUAD_MEMORY_ATOMIC) && !TARGET_POWERPC64) |
| 3979 |
{ |
| 3980 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY) != 0) |
| 3981 |
warning (0, N_("%<-mquad-memory%> requires 64-bit mode")); |
| 3982 |
|
| 3983 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY_ATOMIC) != 0) |
| 3984 |
warning (0, N_("%<-mquad-memory-atomic%> requires 64-bit mode")); |
| 3985 |
|
| 3986 |
rs6000_isa_flags &= ~(OPTION_MASK_QUAD_MEMORY |
| 3987 |
| OPTION_MASK_QUAD_MEMORY_ATOMIC); |
| 3988 |
} |
| 3989 |
|
| 3990 |
/* Non-atomic quad memory load/store are disabled for little endian, since |
| 3991 |
the words are reversed, but atomic operations can still be done by |
| 3992 |
swapping the words. */ |
| 3993 |
if (TARGET_QUAD_MEMORY && !WORDS_BIG_ENDIAN) |
| 3994 |
{ |
| 3995 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY) != 0) |
| 3996 |
warning (0, N_("%<-mquad-memory%> is not available in little endian " |
| 3997 |
"mode")); |
| 3998 |
|
| 3999 |
rs6000_isa_flags &= ~OPTION_MASK_QUAD_MEMORY; |
| 4000 |
} |
| 4001 |
|
| 4002 |
/* Assume if the user asked for normal quad memory instructions, they want |
| 4003 |
the atomic versions as well, unless they explicity told us not to use quad |
| 4004 |
word atomic instructions. */ |
| 4005 |
if (TARGET_QUAD_MEMORY |
| 4006 |
&& !TARGET_QUAD_MEMORY_ATOMIC |
| 4007 |
&& ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY_ATOMIC) == 0)) |
| 4008 |
rs6000_isa_flags |= OPTION_MASK_QUAD_MEMORY_ATOMIC; |
| 4009 |
|
| 4010 |
/* If we can shrink-wrap the TOC register save separately, then use |
| 4011 |
-msave-toc-indirect unless explicitly disabled. */ |
| 4012 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT) == 0 |
| 4013 |
&& flag_shrink_wrap_separate |
| 4014 |
&& optimize_function_for_speed_p (cfun)) |
| 4015 |
rs6000_isa_flags |= OPTION_MASK_SAVE_TOC_INDIRECT; |
| 4016 |
|
| 4017 |
/* Enable power8 fusion if we are tuning for power8, even if we aren't |
| 4018 |
generating power8 instructions. Power9 does not optimize power8 fusion |
| 4019 |
cases. */ |
| 4020 |
if (!(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION)) |
| 4021 |
{ |
| 4022 |
if (processor_target_table[tune_index].processor == PROCESSOR_POWER8) |
| 4023 |
rs6000_isa_flags |= OPTION_MASK_P8_FUSION; |
| 4024 |
else |
| 4025 |
rs6000_isa_flags &= ~OPTION_MASK_P8_FUSION; |
| 4026 |
} |
| 4027 |
|
| 4028 |
/* Setting additional fusion flags turns on base fusion. */ |
| 4029 |
if (!TARGET_P8_FUSION && TARGET_P8_FUSION_SIGN) |
| 4030 |
{ |
| 4031 |
if (rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION) |
| 4032 |
{ |
| 4033 |
if (TARGET_P8_FUSION_SIGN) |
| 4034 |
error ("%qs requires %qs", "-mpower8-fusion-sign", |
| 4035 |
"-mpower8-fusion"); |
| 4036 |
|
| 4037 |
rs6000_isa_flags &= ~OPTION_MASK_P8_FUSION; |
| 4038 |
} |
| 4039 |
else |
| 4040 |
rs6000_isa_flags |= OPTION_MASK_P8_FUSION; |
| 4041 |
} |
| 4042 |
|
| 4043 |
/* Power8 does not fuse sign extended loads with the addis. If we are |
| 4044 |
optimizing at high levels for speed, convert a sign extended load into a |
| 4045 |
zero extending load, and an explicit sign extension. */ |
| 4046 |
if (TARGET_P8_FUSION |
| 4047 |
&& !(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION_SIGN) |
| 4048 |
&& optimize_function_for_speed_p (cfun) |
| 4049 |
&& optimize >= 3) |
| 4050 |
rs6000_isa_flags |= OPTION_MASK_P8_FUSION_SIGN; |
| 4051 |
|
| 4052 |
/* ISA 3.0 vector instructions include ISA 2.07. */ |
| 4053 |
if (TARGET_P9_VECTOR && !TARGET_P8_VECTOR) |
| 4054 |
rs6000_isa_flags &= ~OPTION_MASK_P9_VECTOR; |
| 4055 |
|
| 4056 |
/* Set -mallow-movmisalign to explicitly on if we have full ISA 2.07 |
| 4057 |
support. If we only have ISA 2.06 support, and the user did not specify |
| 4058 |
the switch, leave it set to -1 so the movmisalign patterns are enabled, |
| 4059 |
but we don't enable the full vectorization support */ |
| 4060 |
if (TARGET_ALLOW_MOVMISALIGN == -1 && TARGET_P8_VECTOR) |
| 4061 |
TARGET_ALLOW_MOVMISALIGN = 1; |
| 4062 |
|
| 4063 |
else if (TARGET_ALLOW_MOVMISALIGN && !TARGET_VSX) |
| 4064 |
{ |
| 4065 |
if (TARGET_ALLOW_MOVMISALIGN > 0 |
| 4066 |
&& OPTION_SET_P (TARGET_ALLOW_MOVMISALIGN)) |
| 4067 |
error ("%qs requires %qs", "-mallow-movmisalign", "-mvsx"); |
| 4068 |
|
| 4069 |
TARGET_ALLOW_MOVMISALIGN = 0; |
| 4070 |
} |
| 4071 |
|
| 4072 |
/* Determine when unaligned vector accesses are permitted, and when |
| 4073 |
they are preferred over masked Altivec loads. Note that if |
| 4074 |
TARGET_ALLOW_MOVMISALIGN has been disabled by the user, then |
| 4075 |
TARGET_EFFICIENT_UNALIGNED_VSX must be as well. The converse is |
| 4076 |
not true. */ |
| 4077 |
if (TARGET_EFFICIENT_UNALIGNED_VSX) |
| 4078 |
{ |
| 4079 |
if (!TARGET_VSX) |
| 4080 |
{ |
| 4081 |
if (rs6000_isa_flags_explicit & OPTION_MASK_EFFICIENT_UNALIGNED_VSX) |
| 4082 |
error ("%qs requires %qs", "-mefficient-unaligned-vsx", "-mvsx"); |
| 4083 |
|
| 4084 |
rs6000_isa_flags &= ~OPTION_MASK_EFFICIENT_UNALIGNED_VSX; |
| 4085 |
} |
| 4086 |
|
| 4087 |
else if (!TARGET_ALLOW_MOVMISALIGN) |
| 4088 |
{ |
| 4089 |
if (rs6000_isa_flags_explicit & OPTION_MASK_EFFICIENT_UNALIGNED_VSX) |
| 4090 |
error ("%qs requires %qs", "-munefficient-unaligned-vsx", |
| 4091 |
"-mallow-movmisalign"); |
| 4092 |
|
| 4093 |
rs6000_isa_flags &= ~OPTION_MASK_EFFICIENT_UNALIGNED_VSX; |
| 4094 |
} |
| 4095 |
} |
| 4096 |
|
| 4097 |
if (!(rs6000_isa_flags_explicit & OPTION_MASK_BLOCK_OPS_UNALIGNED_VSX)) |
| 4098 |
{ |
| 4099 |
if (TARGET_EFFICIENT_UNALIGNED_VSX) |
| 4100 |
rs6000_isa_flags |= OPTION_MASK_BLOCK_OPS_UNALIGNED_VSX; |
| 4101 |
else |
| 4102 |
rs6000_isa_flags &= ~OPTION_MASK_BLOCK_OPS_UNALIGNED_VSX; |
| 4103 |
} |
| 4104 |
|
| 4105 |
/* Use long double size to select the appropriate long double. We use |
| 4106 |
TYPE_PRECISION to differentiate the 3 different long double types. We map |
| 4107 |
128 into the precision used for TFmode. */ |
| 4108 |
int default_long_double_size = (RS6000_DEFAULT_LONG_DOUBLE_SIZE == 64 |
| 4109 |
? 64 |
| 4110 |
: 128); |
| 4111 |
|
| 4112 |
/* Set long double size before the IEEE 128-bit tests. */ |
| 4113 |
if (!OPTION_SET_P (rs6000_long_double_type_size)) |
| 4114 |
{ |
| 4115 |
if (main_target_opt != NULL |
| 4116 |
&& (main_target_opt->x_rs6000_long_double_type_size |
| 4117 |
!= default_long_double_size)) |
| 4118 |
error ("target attribute or pragma changes %<long double%> size"); |
| 4119 |
else |
| 4120 |
rs6000_long_double_type_size = default_long_double_size; |
| 4121 |
} |
| 4122 |
|
| 4123 |
/* Set -mabi=ieeelongdouble on some old targets. In the future, power server |
| 4124 |
systems will also set long double to be IEEE 128-bit. AIX and Darwin |
| 4125 |
explicitly redefine TARGET_IEEEQUAD and TARGET_IEEEQUAD_DEFAULT to 0, so |
| 4126 |
those systems will not pick up this default. Warn if the user changes the |
| 4127 |
default unless -Wno-psabi. */ |
| 4128 |
if (!OPTION_SET_P (rs6000_ieeequad)) |
| 4129 |
rs6000_ieeequad = TARGET_IEEEQUAD_DEFAULT; |
| 4130 |
|
| 4131 |
else if (TARGET_LONG_DOUBLE_128) |
| 4132 |
{ |
| 4133 |
if (global_options.x_rs6000_ieeequad |
| 4134 |
&& (!TARGET_POPCNTD || !TARGET_VSX)) |
| 4135 |
error ("%qs requires full ISA 2.06 support", "-mabi=ieeelongdouble"); |
| 4136 |
|
| 4137 |
if (rs6000_ieeequad != TARGET_IEEEQUAD_DEFAULT) |
| 4138 |
{ |
| 4139 |
/* Determine if the user can change the default long double type at |
| 4140 |
compilation time. You need GLIBC 2.32 or newer to be able to |
| 4141 |
change the long double type. Only issue one warning. */ |
| 4142 |
static bool warned_change_long_double; |
| 4143 |
|
| 4144 |
if (!warned_change_long_double && !glibc_supports_ieee_128bit ()) |
| 4145 |
{ |
| 4146 |
warned_change_long_double = true; |
| 4147 |
if (TARGET_IEEEQUAD) |
| 4148 |
warning (OPT_Wpsabi, "Using IEEE extended precision " |
| 4149 |
"%<long double%>"); |
| 4150 |
else |
| 4151 |
warning (OPT_Wpsabi, "Using IBM extended precision " |
| 4152 |
"%<long double%>"); |
| 4153 |
} |
| 4154 |
} |
| 4155 |
} |
| 4156 |
|
| 4157 |
/* Enable the default support for IEEE 128-bit floating point on Linux VSX |
| 4158 |
sytems. In GCC 7, we would enable the IEEE 128-bit floating point |
| 4159 |
infrastructure (-mfloat128-type) but not enable the actual __float128 type |
| 4160 |
unless the user used the explicit -mfloat128. In GCC 8, we enable both |
| 4161 |
the keyword as well as the type. */ |
| 4162 |
TARGET_FLOAT128_TYPE = TARGET_FLOAT128_ENABLE_TYPE && TARGET_VSX; |
| 4163 |
|
| 4164 |
/* IEEE 128-bit floating point requires VSX support. */ |
| 4165 |
if (TARGET_FLOAT128_KEYWORD) |
| 4166 |
{ |
| 4167 |
if (!TARGET_VSX) |
| 4168 |
{ |
| 4169 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_KEYWORD) != 0) |
| 4170 |
error ("%qs requires VSX support", "-mfloat128"); |
| 4171 |
|
| 4172 |
TARGET_FLOAT128_TYPE = 0; |
| 4173 |
rs6000_isa_flags &= ~(OPTION_MASK_FLOAT128_KEYWORD |
| 4174 |
| OPTION_MASK_FLOAT128_HW); |
| 4175 |
} |
| 4176 |
else if (!TARGET_FLOAT128_TYPE) |
| 4177 |
{ |
| 4178 |
TARGET_FLOAT128_TYPE = 1; |
| 4179 |
warning (0, "The %<-mfloat128%> option may not be fully supported"); |
| 4180 |
} |
| 4181 |
} |
| 4182 |
|
| 4183 |
/* Enable the __float128 keyword under Linux by default. */ |
| 4184 |
if (TARGET_FLOAT128_TYPE && !TARGET_FLOAT128_KEYWORD |
| 4185 |
&& (rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_KEYWORD) == 0) |
| 4186 |
rs6000_isa_flags |= OPTION_MASK_FLOAT128_KEYWORD; |
| 4187 |
|
| 4188 |
/* If we have are supporting the float128 type and full ISA 3.0 support, |
| 4189 |
enable -mfloat128-hardware by default. However, don't enable the |
| 4190 |
__float128 keyword if it was explicitly turned off. 64-bit mode is needed |
| 4191 |
because sometimes the compiler wants to put things in an integer |
| 4192 |
container, and if we don't have __int128 support, it is impossible. */ |
| 4193 |
if (TARGET_FLOAT128_TYPE && !TARGET_FLOAT128_HW && TARGET_64BIT |
| 4194 |
&& TARGET_P9_VECTOR |
| 4195 |
&& !(rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW)) |
| 4196 |
rs6000_isa_flags |= OPTION_MASK_FLOAT128_HW; |
| 4197 |
|
| 4198 |
if (TARGET_FLOAT128_HW && (!TARGET_P9_VECTOR)) |
| 4199 |
{ |
| 4200 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW) != 0) |
| 4201 |
error ("%qs requires full ISA 3.0 support", "%<-mfloat128-hardware%>"); |
| 4202 |
|
| 4203 |
rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; |
| 4204 |
} |
| 4205 |
|
| 4206 |
if (TARGET_FLOAT128_HW && !TARGET_64BIT) |
| 4207 |
{ |
| 4208 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_FLOAT128_HW) != 0) |
| 4209 |
error ("%qs requires %qs", "%<-mfloat128-hardware%>", "-m64"); |
| 4210 |
|
| 4211 |
rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW; |
| 4212 |
} |
| 4213 |
|
| 4214 |
/* Enable -mprefixed by default on power10 systems. */ |
| 4215 |
if (TARGET_POWER10 && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0) |
| 4216 |
rs6000_isa_flags |= OPTION_MASK_PREFIXED; |
| 4217 |
|
| 4218 |
/* -mprefixed requires -mcpu=power10 (or later). */ |
| 4219 |
else if (TARGET_PREFIXED && !TARGET_POWER10) |
| 4220 |
{ |
| 4221 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) != 0) |
| 4222 |
error ("%qs requires %qs", "-mprefixed", "-mcpu=power10"); |
| 4223 |
|
| 4224 |
rs6000_isa_flags &= ~OPTION_MASK_PREFIXED; |
| 4225 |
} |
| 4226 |
|
| 4227 |
/* -mpcrel requires prefixed load/store addressing. */ |
| 4228 |
if (TARGET_PCREL && !TARGET_PREFIXED) |
| 4229 |
{ |
| 4230 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) |
| 4231 |
error ("%qs requires %qs", "-mpcrel", "-mprefixed"); |
| 4232 |
|
| 4233 |
rs6000_isa_flags &= ~OPTION_MASK_PCREL; |
| 4234 |
} |
| 4235 |
|
| 4236 |
/* Print the options after updating the defaults. */ |
| 4237 |
if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) |
| 4238 |
rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags); |
| 4239 |
|
| 4240 |
/* E500mc does "better" if we inline more aggressively. Respect the |
| 4241 |
user's opinion, though. */ |
| 4242 |
if (rs6000_block_move_inline_limit == 0 |
| 4243 |
&& (rs6000_tune == PROCESSOR_PPCE500MC |
| 4244 |
|| rs6000_tune == PROCESSOR_PPCE500MC64 |
| 4245 |
|| rs6000_tune == PROCESSOR_PPCE5500 |
| 4246 |
|| rs6000_tune == PROCESSOR_PPCE6500)) |
| 4247 |
rs6000_block_move_inline_limit = 128; |
| 4248 |
|
| 4249 |
/* store_one_arg depends on expand_block_move to handle at least the |
| 4250 |
size of reg_parm_stack_space. */ |
| 4251 |
if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32)) |
| 4252 |
rs6000_block_move_inline_limit = (TARGET_POWERPC64 ? 64 : 32); |
| 4253 |
|
| 4254 |
if (global_init_p) |
| 4255 |
{ |
| 4256 |
/* If the appropriate debug option is enabled, replace the target hooks |
| 4257 |
with debug versions that call the real version and then prints |
| 4258 |
debugging information. */ |
| 4259 |
if (TARGET_DEBUG_COST) |
| 4260 |
{ |
| 4261 |
targetm.rtx_costs = rs6000_debug_rtx_costs; |
| 4262 |
targetm.address_cost = rs6000_debug_address_cost; |
| 4263 |
targetm.sched.adjust_cost = rs6000_debug_adjust_cost; |
| 4264 |
} |
| 4265 |
|
| 4266 |
if (TARGET_DEBUG_ADDR) |
| 4267 |
{ |
| 4268 |
targetm.legitimate_address_p = rs6000_debug_legitimate_address_p; |
| 4269 |
targetm.legitimize_address = rs6000_debug_legitimize_address; |
| 4270 |
rs6000_secondary_reload_class_ptr |
| 4271 |
= rs6000_debug_secondary_reload_class; |
| 4272 |
targetm.secondary_memory_needed |
| 4273 |
= rs6000_debug_secondary_memory_needed; |
| 4274 |
targetm.can_change_mode_class |
| 4275 |
= rs6000_debug_can_change_mode_class; |
| 4276 |
rs6000_preferred_reload_class_ptr |
| 4277 |
= rs6000_debug_preferred_reload_class; |
| 4278 |
rs6000_mode_dependent_address_ptr |
| 4279 |
= rs6000_debug_mode_dependent_address; |
| 4280 |
} |
| 4281 |
|
| 4282 |
if (rs6000_veclibabi_name) |
| 4283 |
{ |
| 4284 |
if (strcmp (rs6000_veclibabi_name, "mass") == 0) |
| 4285 |
rs6000_veclib_handler = rs6000_builtin_vectorized_libmass; |
| 4286 |
else |
| 4287 |
{ |
| 4288 |
error ("unknown vectorization library ABI type in " |
| 4289 |
"%<-mveclibabi=%s%>", rs6000_veclibabi_name); |
| 4290 |
ret = false; |
| 4291 |
} |
| 4292 |
} |
| 4293 |
} |
| 4294 |
|
| 4295 |
/* Enable Altivec ABI for AIX -maltivec. */ |
| 4296 |
if (TARGET_XCOFF |
| 4297 |
&& (TARGET_ALTIVEC || TARGET_VSX) |
| 4298 |
&& !OPTION_SET_P (rs6000_altivec_abi)) |
| 4299 |
{ |
| 4300 |
if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi) |
| 4301 |
error ("target attribute or pragma changes AltiVec ABI"); |
| 4302 |
else |
| 4303 |
rs6000_altivec_abi = 1; |
| 4304 |
} |
| 4305 |
|
| 4306 |
/* The AltiVec ABI is the default for PowerPC-64 GNU/Linux. For |
| 4307 |
PowerPC-32 GNU/Linux, -maltivec implies the AltiVec ABI. It can |
| 4308 |
be explicitly overridden in either case. */ |
| 4309 |
if (TARGET_ELF) |
| 4310 |
{ |
| 4311 |
if (!OPTION_SET_P (rs6000_altivec_abi) |
| 4312 |
&& (TARGET_64BIT || TARGET_ALTIVEC || TARGET_VSX)) |
| 4313 |
{ |
| 4314 |
if (main_target_opt != NULL && |
| 4315 |
!main_target_opt->x_rs6000_altivec_abi) |
| 4316 |
error ("target attribute or pragma changes AltiVec ABI"); |
| 4317 |
else |
| 4318 |
rs6000_altivec_abi = 1; |
| 4319 |
} |
| 4320 |
} |
| 4321 |
|
| 4322 |
/* Set the Darwin64 ABI as default for 64-bit Darwin. |
| 4323 |
So far, the only darwin64 targets are also MACH-O. */ |
| 4324 |
if (TARGET_MACHO |
| 4325 |
&& DEFAULT_ABI == ABI_DARWIN |
| 4326 |
&& TARGET_64BIT) |
| 4327 |
{ |
| 4328 |
if (main_target_opt != NULL && !main_target_opt->x_rs6000_darwin64_abi) |
| 4329 |
error ("target attribute or pragma changes darwin64 ABI"); |
| 4330 |
else |
| 4331 |
{ |
| 4332 |
rs6000_darwin64_abi = 1; |
| 4333 |
/* Default to natural alignment, for better performance. */ |
| 4334 |
rs6000_alignment_flags = MASK_ALIGN_NATURAL; |
| 4335 |
} |
| 4336 |
} |
| 4337 |
|
| 4338 |
/* Place FP constants in the constant pool instead of TOC |
| 4339 |
if section anchors enabled. */ |
| 4340 |
if (flag_section_anchors |
| 4341 |
&& !OPTION_SET_P (TARGET_NO_FP_IN_TOC)) |
| 4342 |
TARGET_NO_FP_IN_TOC = 1; |
| 4343 |
|
| 4344 |
if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) |
| 4345 |
rs6000_print_isa_options (stderr, 0, "before subtarget", rs6000_isa_flags); |
| 4346 |
|
| 4347 |
#ifdef SUBTARGET_OVERRIDE_OPTIONS |
| 4348 |
SUBTARGET_OVERRIDE_OPTIONS; |
| 4349 |
#endif |
| 4350 |
#ifdef SUBSUBTARGET_OVERRIDE_OPTIONS |
| 4351 |
SUBSUBTARGET_OVERRIDE_OPTIONS; |
| 4352 |
#endif |
| 4353 |
#ifdef SUB3TARGET_OVERRIDE_OPTIONS |
| 4354 |
SUB3TARGET_OVERRIDE_OPTIONS; |
| 4355 |
#endif |
| 4356 |
|
| 4357 |
/* If the ABI has support for PC-relative relocations, enable it by default. |
| 4358 |
This test depends on the sub-target tests above setting the code model to |
| 4359 |
medium for ELF v2 systems. */ |
| 4360 |
if (PCREL_SUPPORTED_BY_OS |
| 4361 |
&& (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0) |
| 4362 |
rs6000_isa_flags |= OPTION_MASK_PCREL; |
| 4363 |
|
| 4364 |
/* -mpcrel requires -mcmodel=medium, but we can't check TARGET_CMODEL until |
| 4365 |
after the subtarget override options are done. */ |
| 4366 |
else if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM) |
| 4367 |
{ |
| 4368 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0) |
| 4369 |
error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium"); |
| 4370 |
|
| 4371 |
rs6000_isa_flags &= ~OPTION_MASK_PCREL; |
| 4372 |
} |
| 4373 |
|
| 4374 |
/* Enable -mmma by default on power10 systems. */ |
| 4375 |
if (TARGET_POWER10 && (rs6000_isa_flags_explicit & OPTION_MASK_MMA) == 0) |
| 4376 |
rs6000_isa_flags |= OPTION_MASK_MMA; |
| 4377 |
|
| 4378 |
/* Turn off vector pair/mma options on non-power10 systems. */ |
| 4379 |
else if (!TARGET_POWER10 && TARGET_MMA) |
| 4380 |
{ |
| 4381 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_MMA) != 0) |
| 4382 |
error ("%qs requires %qs", "-mmma", "-mcpu=power10"); |
| 4383 |
|
| 4384 |
rs6000_isa_flags &= ~OPTION_MASK_MMA; |
| 4385 |
} |
| 4386 |
|
| 4387 |
/* Enable power10 fusion if we are tuning for power10, even if we aren't |
| 4388 |
generating power10 instructions. */ |
| 4389 |
if (!(rs6000_isa_flags_explicit & OPTION_MASK_P10_FUSION)) |
| 4390 |
{ |
| 4391 |
if (rs6000_tune == PROCESSOR_POWER10 |
| 4392 |
|| rs6000_tune == PROCESSOR_POWER11) |
| 4393 |
rs6000_isa_flags |= OPTION_MASK_P10_FUSION; |
| 4394 |
else |
| 4395 |
rs6000_isa_flags &= ~OPTION_MASK_P10_FUSION; |
| 4396 |
} |
| 4397 |
|
| 4398 |
/* MMA requires SIMD support as ISA 3.1 claims and our implementation |
| 4399 |
such as "*movoo" uses vector pair access which use VSX registers. |
| 4400 |
So make MMA require VSX support here. */ |
| 4401 |
if (TARGET_MMA && !TARGET_VSX) |
| 4402 |
{ |
| 4403 |
if ((rs6000_isa_flags_explicit & OPTION_MASK_MMA) != 0) |
| 4404 |
error ("%qs requires %qs", "-mmma", "-mvsx"); |
| 4405 |
rs6000_isa_flags &= ~OPTION_MASK_MMA; |
| 4406 |
} |
| 4407 |
|
| 4408 |
if (!TARGET_PCREL && TARGET_PCREL_OPT) |
| 4409 |
rs6000_isa_flags &= ~OPTION_MASK_PCREL_OPT; |
| 4410 |
|
| 4411 |
if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) |
| 4412 |
rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags); |
| 4413 |
|
| 4414 |
rs6000_always_hint = (rs6000_tune != PROCESSOR_POWER4 |
| 4415 |
&& rs6000_tune != PROCESSOR_POWER5 |
| 4416 |
&& rs6000_tune != PROCESSOR_POWER6 |
| 4417 |
&& rs6000_tune != PROCESSOR_POWER7 |
| 4418 |
&& rs6000_tune != PROCESSOR_POWER8 |
| 4419 |
&& rs6000_tune != PROCESSOR_POWER9 |
| 4420 |
&& rs6000_tune != PROCESSOR_POWER10 |
| 4421 |
&& rs6000_tune != PROCESSOR_POWER11 |
| 4422 |
&& rs6000_tune != PROCESSOR_PPCA2 |
| 4423 |
&& rs6000_tune != PROCESSOR_CELL |
| 4424 |
&& rs6000_tune != PROCESSOR_PPC476); |
| 4425 |
rs6000_sched_groups = (rs6000_tune == PROCESSOR_POWER4 |
| 4426 |
|| rs6000_tune == PROCESSOR_POWER5 |
| 4427 |
|| rs6000_tune == PROCESSOR_POWER7 |
| 4428 |
|| rs6000_tune == PROCESSOR_POWER8); |
| 4429 |
rs6000_align_branch_targets = (rs6000_tune == PROCESSOR_POWER4 |
| 4430 |
|| rs6000_tune == PROCESSOR_POWER5 |
| 4431 |
|| rs6000_tune == PROCESSOR_POWER6 |
| 4432 |
|| rs6000_tune == PROCESSOR_POWER7 |
| 4433 |
|| rs6000_tune == PROCESSOR_POWER8 |
| 4434 |
|| rs6000_tune == PROCESSOR_POWER9 |
| 4435 |
|| rs6000_tune == PROCESSOR_POWER10 |
| 4436 |
|| rs6000_tune == PROCESSOR_POWER11 |
| 4437 |
|| rs6000_tune == PROCESSOR_PPCE500MC |
| 4438 |
|| rs6000_tune == PROCESSOR_PPCE500MC64 |
| 4439 |
|| rs6000_tune == PROCESSOR_PPCE5500 |
| 4440 |
|| rs6000_tune == PROCESSOR_PPCE6500); |
| 4441 |
|
| 4442 |
/* Allow debug switches to override the above settings. These are set to -1 |
| 4443 |
in rs6000.opt to indicate the user hasn't directly set the switch. */ |
| 4444 |
if (TARGET_ALWAYS_HINT >= 0) |
| 4445 |
rs6000_always_hint = TARGET_ALWAYS_HINT; |
| 4446 |
|
| 4447 |
if (TARGET_SCHED_GROUPS >= 0) |
| 4448 |
rs6000_sched_groups = TARGET_SCHED_GROUPS; |
| 4449 |
|
| 4450 |
if (TARGET_ALIGN_BRANCH_TARGETS >= 0) |
| 4451 |
rs6000_align_branch_targets = TARGET_ALIGN_BRANCH_TARGETS; |
| 4452 |
|
| 4453 |
rs6000_sched_restricted_insns_priority |
| 4454 |
= (rs6000_sched_groups ? 1 : 0); |
| 4455 |
|
| 4456 |
/* Handle -msched-costly-dep option. */ |
| 4457 |
rs6000_sched_costly_dep |
| 4458 |
= (rs6000_sched_groups ? true_store_to_load_dep_costly : no_dep_costly); |
| 4459 |
|
| 4460 |
if (rs6000_sched_costly_dep_str) |
| 4461 |
{ |
| 4462 |
if (! strcmp (rs6000_sched_costly_dep_str, "no")) |
| 4463 |
rs6000_sched_costly_dep = no_dep_costly; |
| 4464 |
else if (! strcmp (rs6000_sched_costly_dep_str, "all")) |
| 4465 |
rs6000_sched_costly_dep = all_deps_costly; |
| 4466 |
else if (! strcmp (rs6000_sched_costly_dep_str, "true_store_to_load")) |
| 4467 |
rs6000_sched_costly_dep = true_store_to_load_dep_costly; |
| 4468 |
else if (! strcmp (rs6000_sched_costly_dep_str, "store_to_load")) |
| 4469 |
rs6000_sched_costly_dep = store_to_load_dep_costly; |
| 4470 |
else |
| 4471 |
rs6000_sched_costly_dep = ((enum rs6000_dependence_cost) |
| 4472 |
atoi (rs6000_sched_costly_dep_str)); |
| 4473 |
} |
| 4474 |
|
| 4475 |
/* Handle -minsert-sched-nops option. */ |
| 4476 |
rs6000_sched_insert_nops |
| 4477 |
= (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none); |
| 4478 |
|
| 4479 |
if (rs6000_sched_insert_nops_str) |
| 4480 |
{ |
| 4481 |
if (! strcmp (rs6000_sched_insert_nops_str, "no")) |
| 4482 |
rs6000_sched_insert_nops = sched_finish_none; |
| 4483 |
else if (! strcmp (rs6000_sched_insert_nops_str, "pad")) |
| 4484 |
rs6000_sched_insert_nops = sched_finish_pad_groups; |
| 4485 |
else if (! strcmp (rs6000_sched_insert_nops_str, "regroup_exact")) |
| 4486 |
rs6000_sched_insert_nops = sched_finish_regroup_exact; |
| 4487 |
else |
| 4488 |
rs6000_sched_insert_nops = ((enum rs6000_nop_insertion) |
| 4489 |
atoi (rs6000_sched_insert_nops_str)); |
| 4490 |
} |
| 4491 |
|
| 4492 |
/* Handle stack protector */ |
| 4493 |
if (!OPTION_SET_P (rs6000_stack_protector_guard)) |
| 4494 |
#ifdef TARGET_THREAD_SSP_OFFSET |
| 4495 |
rs6000_stack_protector_guard = SSP_TLS; |
| 4496 |
#else |
| 4497 |
rs6000_stack_protector_guard = SSP_GLOBAL; |
| 4498 |
#endif |
| 4499 |
|
| 4500 |
#ifdef TARGET_THREAD_SSP_OFFSET |
| 4501 |
rs6000_stack_protector_guard_offset = TARGET_THREAD_SSP_OFFSET; |
| 4502 |
rs6000_stack_protector_guard_reg = TARGET_64BIT ? 13 : 2; |
| 4503 |
#endif |
| 4504 |
|
| 4505 |
if (OPTION_SET_P (rs6000_stack_protector_guard_offset_str)) |
| 4506 |
{ |
| 4507 |
char *endp; |
| 4508 |
const char *str = rs6000_stack_protector_guard_offset_str; |
| 4509 |
|
| 4510 |
errno = 0; |
| 4511 |
long offset = strtol (str, &endp, 0); |
| 4512 |
if (!*str || *endp || errno) |
| 4513 |
error ("%qs is not a valid number in %qs", str, |
| 4514 |
"-mstack-protector-guard-offset="); |
| 4515 |
|
| 4516 |
if (!IN_RANGE (offset, -0x8000, 0x7fff) |
| 4517 |
|| (TARGET_64BIT && (offset & 3))) |
| 4518 |
error ("%qs is not a valid offset in %qs", str, |
| 4519 |
"-mstack-protector-guard-offset="); |
| 4520 |
|
| 4521 |
rs6000_stack_protector_guard_offset = offset; |
| 4522 |
} |
| 4523 |
|
| 4524 |
if (OPTION_SET_P (rs6000_stack_protector_guard_reg_str)) |
| 4525 |
{ |
| 4526 |
const char *str = rs6000_stack_protector_guard_reg_str; |
| 4527 |
int reg = decode_reg_name (str); |
| 4528 |
|
| 4529 |
if (!IN_RANGE (reg, 1, 31)) |
| 4530 |
error ("%qs is not a valid base register in %qs", str, |
| 4531 |
"-mstack-protector-guard-reg="); |
| 4532 |
|
| 4533 |
rs6000_stack_protector_guard_reg = reg; |
| 4534 |
} |
| 4535 |
|
| 4536 |
if (rs6000_stack_protector_guard == SSP_TLS |
| 4537 |
&& !IN_RANGE (rs6000_stack_protector_guard_reg, 1, 31)) |
| 4538 |
error ("%qs needs a valid base register", "-mstack-protector-guard=tls"); |
| 4539 |
|
| 4540 |
if (global_init_p) |
| 4541 |
{ |
| 4542 |
#ifdef TARGET_REGNAMES |
| 4543 |
/* If the user desires alternate register names, copy in the |
| 4544 |
alternate names now. */ |
| 4545 |
if (TARGET_REGNAMES) |
| 4546 |
memcpy (rs6000_reg_names, alt_reg_names, sizeof (rs6000_reg_names)); |
| 4547 |
#endif |
| 4548 |
|
| 4549 |
/* Set aix_struct_return last, after the ABI is determined. |
| 4550 |
If -maix-struct-return or -msvr4-struct-return was explicitly |
| 4551 |
used, don't override with the ABI default. */ |
| 4552 |
if (!OPTION_SET_P (aix_struct_return)) |
| 4553 |
aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET); |
| 4554 |
|
| 4555 |
#if 0 |
| 4556 |
/* IBM XL compiler defaults to unsigned bitfields. */ |
| 4557 |
if (TARGET_XL_COMPAT) |
| 4558 |
flag_signed_bitfields = 0; |
| 4559 |
#endif |
| 4560 |
|
| 4561 |
if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD) |
| 4562 |
REAL_MODE_FORMAT (TFmode) = &ibm_extended_format; |
| 4563 |
|
| 4564 |
ASM_GENERATE_INTERNAL_LABEL (toc_label_name, "LCTOC", 1); |
| 4565 |
|
| 4566 |
/* We can only guarantee the availability of DI pseudo-ops when |
| 4567 |
assembling for 64-bit targets. */ |
| 4568 |
if (!TARGET_64BIT) |
| 4569 |
{ |
| 4570 |
targetm.asm_out.aligned_op.di = NULL; |
| 4571 |
targetm.asm_out.unaligned_op.di = NULL; |
| 4572 |
} |
| 4573 |
|
| 4574 |
|
| 4575 |
/* Set branch target alignment, if not optimizing for size. */ |
| 4576 |
if (!optimize_size) |
| 4577 |
{ |
| 4578 |
/* Cell wants to be aligned 8byte for dual issue. Titan wants to be |
| 4579 |
aligned 8byte to avoid misprediction by the branch predictor. */ |
| 4580 |
if (rs6000_tune == PROCESSOR_TITAN |
| 4581 |
|| rs6000_tune == PROCESSOR_CELL) |
| 4582 |
{ |
| 4583 |
if (flag_align_functions && !str_align_functions) |
| 4584 |
str_align_functions = "8"; |
| 4585 |
if (flag_align_jumps && !str_align_jumps) |
| 4586 |
str_align_jumps = "8"; |
| 4587 |
if (flag_align_loops && !str_align_loops) |
| 4588 |
str_align_loops = "8"; |
| 4589 |
} |
| 4590 |
if (rs6000_align_branch_targets) |
| 4591 |
{ |
| 4592 |
if (flag_align_functions && !str_align_functions) |
| 4593 |
str_align_functions = "16"; |
| 4594 |
if (flag_align_jumps && !str_align_jumps) |
| 4595 |
str_align_jumps = "16"; |
| 4596 |
if (flag_align_loops && !str_align_loops) |
| 4597 |
{ |
| 4598 |
can_override_loop_align = 1; |
| 4599 |
str_align_loops = "16"; |
| 4600 |
} |
| 4601 |
} |
| 4602 |
} |
| 4603 |
|
| 4604 |
/* Arrange to save and restore machine status around nested functions. */ |
| 4605 |
init_machine_status = rs6000_init_machine_status; |
| 4606 |
|
| 4607 |
/* We should always be splitting complex arguments, but we can't break |
| 4608 |
Linux and Darwin ABIs at the moment. For now, only AIX is fixed. */ |
| 4609 |
if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) |
| 4610 |
targetm.calls.split_complex_arg = NULL; |
| 4611 |
|
| 4612 |
/* The AIX and ELFv1 ABIs define standard function descriptors. */ |
| 4613 |
if (DEFAULT_ABI == ABI_AIX) |
| 4614 |
targetm.calls.custom_function_descriptors = 0; |
| 4615 |
} |
| 4616 |
|
| 4617 |
/* Initialize rs6000_cost with the appropriate target costs. */ |
| 4618 |
if (optimize_size) |
| 4619 |
rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost; |
| 4620 |
else |
| 4621 |
switch (rs6000_tune) |
| 4622 |
{ |
| 4623 |
case PROCESSOR_RS64A: |
| 4624 |
rs6000_cost = &rs64a_cost; |
| 4625 |
break; |
| 4626 |
|
| 4627 |
case PROCESSOR_MPCCORE: |
| 4628 |
rs6000_cost = &mpccore_cost; |
| 4629 |
break; |
| 4630 |
|
| 4631 |
case PROCESSOR_PPC403: |
| 4632 |
rs6000_cost = &ppc403_cost; |
| 4633 |
break; |
| 4634 |
|
| 4635 |
case PROCESSOR_PPC405: |
| 4636 |
rs6000_cost = &ppc405_cost; |
| 4637 |
break; |
| 4638 |
|
| 4639 |
case PROCESSOR_PPC440: |
| 4640 |
rs6000_cost = &ppc440_cost; |
| 4641 |
break; |
| 4642 |
|
| 4643 |
case PROCESSOR_PPC476: |
| 4644 |
rs6000_cost = &ppc476_cost; |
| 4645 |
break; |
| 4646 |
|
| 4647 |
case PROCESSOR_PPC601: |
| 4648 |
rs6000_cost = &ppc601_cost; |
| 4649 |
break; |
| 4650 |
|
| 4651 |
case PROCESSOR_PPC603: |
| 4652 |
rs6000_cost = &ppc603_cost; |
| 4653 |
break; |
| 4654 |
|
| 4655 |
case PROCESSOR_PPC604: |
| 4656 |
rs6000_cost = &ppc604_cost; |
| 4657 |
break; |
| 4658 |
|
| 4659 |
case PROCESSOR_PPC604e: |
| 4660 |
rs6000_cost = &ppc604e_cost; |
| 4661 |
break; |
| 4662 |
|
| 4663 |
case PROCESSOR_PPC620: |
| 4664 |
rs6000_cost = &ppc620_cost; |
| 4665 |
break; |
| 4666 |
|
| 4667 |
case PROCESSOR_PPC630: |
| 4668 |
rs6000_cost = &ppc630_cost; |
| 4669 |
break; |
| 4670 |
|
| 4671 |
case PROCESSOR_CELL: |
| 4672 |
rs6000_cost = &ppccell_cost; |
| 4673 |
break; |
| 4674 |
|
| 4675 |
case PROCESSOR_PPC750: |
| 4676 |
case PROCESSOR_PPC7400: |
| 4677 |
rs6000_cost = &ppc750_cost; |
| 4678 |
break; |
| 4679 |
|
| 4680 |
case PROCESSOR_PPC7450: |
| 4681 |
rs6000_cost = &ppc7450_cost; |
| 4682 |
break; |
| 4683 |
|
| 4684 |
case PROCESSOR_PPC8540: |
| 4685 |
case PROCESSOR_PPC8548: |
| 4686 |
rs6000_cost = &ppc8540_cost; |
| 4687 |
break; |
| 4688 |
|
| 4689 |
case PROCESSOR_PPCE300C2: |
| 4690 |
case PROCESSOR_PPCE300C3: |
| 4691 |
rs6000_cost = &ppce300c2c3_cost; |
| 4692 |
break; |
| 4693 |
|
| 4694 |
case PROCESSOR_PPCE500MC: |
| 4695 |
rs6000_cost = &ppce500mc_cost; |
| 4696 |
break; |
| 4697 |
|
| 4698 |
case PROCESSOR_PPCE500MC64: |
| 4699 |
rs6000_cost = &ppce500mc64_cost; |
| 4700 |
break; |
| 4701 |
|
| 4702 |
case PROCESSOR_PPCE5500: |
| 4703 |
rs6000_cost = &ppce5500_cost; |
| 4704 |
break; |
| 4705 |
|
| 4706 |
case PROCESSOR_PPCE6500: |
| 4707 |
rs6000_cost = &ppce6500_cost; |
| 4708 |
break; |
| 4709 |
|
| 4710 |
case PROCESSOR_TITAN: |
| 4711 |
rs6000_cost = &titan_cost; |
| 4712 |
break; |
| 4713 |
|
| 4714 |
case PROCESSOR_POWER4: |
| 4715 |
case PROCESSOR_POWER5: |
| 4716 |
rs6000_cost = &power4_cost; |
| 4717 |
break; |
| 4718 |
|
| 4719 |
case PROCESSOR_POWER6: |
| 4720 |
rs6000_cost = &power6_cost; |
| 4721 |
break; |
| 4722 |
|
| 4723 |
case PROCESSOR_POWER7: |
| 4724 |
rs6000_cost = &power7_cost; |
| 4725 |
break; |
| 4726 |
|
| 4727 |
case PROCESSOR_POWER8: |
| 4728 |
rs6000_cost = &power8_cost; |
| 4729 |
break; |
| 4730 |
|
| 4731 |
case PROCESSOR_POWER9: |
| 4732 |
rs6000_cost = &power9_cost; |
| 4733 |
break; |
| 4734 |
|
| 4735 |
case PROCESSOR_POWER10: |
| 4736 |
case PROCESSOR_POWER11: |
| 4737 |
rs6000_cost = &power10_cost; |
| 4738 |
break; |
| 4739 |
|
| 4740 |
case PROCESSOR_PPCA2: |
| 4741 |
rs6000_cost = &ppca2_cost; |
| 4742 |
break; |
| 4743 |
|
| 4744 |
default: |
| 4745 |
gcc_unreachable (); |
| 4746 |
} |
| 4747 |
|
| 4748 |
if (global_init_p) |
| 4749 |
{ |
| 4750 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4751 |
param_simultaneous_prefetches, |
| 4752 |
rs6000_cost->simultaneous_prefetches); |
| 4753 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4754 |
param_l1_cache_size, |
| 4755 |
rs6000_cost->l1_cache_size); |
| 4756 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4757 |
param_l1_cache_line_size, |
| 4758 |
rs6000_cost->cache_line_size); |
| 4759 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4760 |
param_l2_cache_size, |
| 4761 |
rs6000_cost->l2_cache_size); |
| 4762 |
|
| 4763 |
/* Increase loop peeling limits based on performance analysis. */ |
| 4764 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4765 |
param_max_peeled_insns, 400); |
| 4766 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4767 |
param_max_completely_peeled_insns, 400); |
| 4768 |
|
| 4769 |
/* The lxvl/stxvl instructions don't perform well before Power10. */ |
| 4770 |
if (TARGET_POWER10) |
| 4771 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4772 |
param_vect_partial_vector_usage, 1); |
| 4773 |
else |
| 4774 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4775 |
param_vect_partial_vector_usage, 0); |
| 4776 |
|
| 4777 |
/* Use the 'model' -fsched-pressure algorithm by default. */ |
| 4778 |
SET_OPTION_IF_UNSET (&global_options, &global_options_set, |
| 4779 |
param_sched_pressure_algorithm, |
| 4780 |
SCHED_PRESSURE_MODEL); |
| 4781 |
|
| 4782 |
/* If using typedef char *va_list, signal that |
| 4783 |
__builtin_va_start (&ap, 0) can be optimized to |
| 4784 |
ap = __builtin_next_arg (0). */ |
| 4785 |
if (DEFAULT_ABI != ABI_V4) |
| 4786 |
targetm.expand_builtin_va_start = NULL; |
| 4787 |
} |
| 4788 |
|
| 4789 |
rs6000_override_options_after_change (); |
| 4790 |
|
| 4791 |
/* If not explicitly specified via option, decide whether to generate indexed |
| 4792 |
load/store instructions. A value of -1 indicates that the |
| 4793 |
initial value of this variable has not been overwritten. During |
| 4794 |
compilation, TARGET_AVOID_XFORM is either 0 or 1. */ |
| 4795 |
if (TARGET_AVOID_XFORM == -1) |
| 4796 |
/* Avoid indexed addressing when targeting Power6 in order to avoid the |
| 4797 |
DERAT mispredict penalty. However the LVE and STVE altivec instructions |
| 4798 |
need indexed accesses and the type used is the scalar type of the element |
| 4799 |
being loaded or stored. */ |
| 4800 |
TARGET_AVOID_XFORM = (rs6000_tune == PROCESSOR_POWER6 && TARGET_CMPB |
| 4801 |
&& !TARGET_ALTIVEC); |
| 4802 |
|
| 4803 |
/* Set the -mrecip options. */ |
| 4804 |
if (rs6000_recip_name) |
| 4805 |
{ |
| 4806 |
char *p = ASTRDUP (rs6000_recip_name); |
| 4807 |
char *q; |
| 4808 |
unsigned int mask, i; |
| 4809 |
bool invert; |
| 4810 |
|
| 4811 |
while ((q = strtok (p, ",")) != NULL) |
| 4812 |
{ |
| 4813 |
p = NULL; |
| 4814 |
if (*q == '!') |
| 4815 |
{ |
| 4816 |
invert = true; |
| 4817 |
q++; |
| 4818 |
} |
| 4819 |
else |
| 4820 |
invert = false; |
| 4821 |
|
| 4822 |
if (!strcmp (q, "default")) |
| 4823 |
mask = ((TARGET_RECIP_PRECISION) |
| 4824 |
? RECIP_HIGH_PRECISION : RECIP_LOW_PRECISION); |
| 4825 |
else |
| 4826 |
{ |
| 4827 |
for (i = 0; i < ARRAY_SIZE (recip_options); i++) |
| 4828 |
if (!strcmp (q, recip_options[i].string)) |
| 4829 |
{ |
| 4830 |
mask = recip_options[i].mask; |
| 4831 |
break; |
| 4832 |
} |
| 4833 |
|
| 4834 |
if (i == ARRAY_SIZE (recip_options)) |
| 4835 |
{ |
| 4836 |
error ("unknown option for %<%s=%s%>", "-mrecip", q); |
| 4837 |
invert = false; |
| 4838 |
mask = 0; |
| 4839 |
ret = false; |
| 4840 |
} |
| 4841 |
} |
| 4842 |
|
| 4843 |
if (invert) |
| 4844 |
rs6000_recip_control &= ~mask; |
| 4845 |
else |
| 4846 |
rs6000_recip_control |= mask; |
| 4847 |
} |
| 4848 |
} |
| 4849 |
|
| 4850 |
/* We only support ROP protection on certain targets. */ |
| 4851 |
if (rs6000_rop_protect) |
| 4852 |
{ |
| 4853 |
/* Disallow CPU targets we don't support. */ |
| 4854 |
if (!TARGET_POWER8) |
| 4855 |
error ("%<-mrop-protect%> requires %<-mcpu=power8%> or later"); |
| 4856 |
|
| 4857 |
/* Disallow ABI targets we don't support. */ |
| 4858 |
if (DEFAULT_ABI != ABI_ELFv2) |
| 4859 |
error ("%<-mrop-protect%> requires the ELFv2 ABI"); |
| 4860 |
} |
| 4861 |
|
| 4862 |
/* Initialize all of the registers. */ |
| 4863 |
rs6000_init_hard_regno_mode_ok (global_init_p); |
| 4864 |
|
| 4865 |
/* Save the initial options in case the user does function specific options */ |
| 4866 |
if (global_init_p) |
| 4867 |
target_option_default_node = target_option_current_node |
| 4868 |
= build_target_option_node (&global_options, &global_options_set); |
| 4869 |
|
| 4870 |
/* If not explicitly specified via option, decide whether to generate the |
| 4871 |
extra blr's required to preserve the link stack on some cpus (eg, 476). */ |
| 4872 |
if (TARGET_LINK_STACK == -1) |
| 4873 |
SET_TARGET_LINK_STACK (rs6000_tune == PROCESSOR_PPC476 && flag_pic); |
| 4874 |
|
| 4875 |
/* Deprecate use of -mno-speculate-indirect-jumps. */ |
| 4876 |
if (!rs6000_speculate_indirect_jumps) |
| 4877 |
warning (0, "%qs is deprecated and not recommended in any circumstances", |
| 4878 |
"-mno-speculate-indirect-jumps"); |
| 4879 |
|
| 4880 |
return ret; |
| 4881 |
} |
| 4882 |
|
| 4883 |
/* Implement TARGET_OPTION_OVERRIDE. On the RS/6000 this is used to |
| 4884 |
define the target cpu type. */ |
| 4885 |
|
| 4886 |
static void |
| 4887 |
rs6000_option_override (void) |
| 4888 |
{ |
| 4889 |
(void) rs6000_option_override_internal (true); |
| 4890 |
} |
| 4891 |
|
| 4892 |
|
| 4893 |
/* Implement LOOP_ALIGN. */ |
| 4894 |
align_flags |
| 4895 |
rs6000_loop_align (rtx label) |
| 4896 |
{ |
| 4897 |
basic_block bb; |
| 4898 |
int ninsns; |
| 4899 |
|
| 4900 |
/* Don't override loop alignment if -falign-loops was specified. */ |
| 4901 |
if (!can_override_loop_align) |
| 4902 |
return align_loops; |
| 4903 |
|
| 4904 |
bb = BLOCK_FOR_INSN (label); |
| 4905 |
ninsns = num_loop_insns(bb->loop_father); |
| 4906 |
|
| 4907 |
/* Align small loops to 32 bytes to fit in an icache sector, otherwise return default. */ |
| 4908 |
if (ninsns > 4 && ninsns <= 8 |
| 4909 |
&& (rs6000_tune == PROCESSOR_POWER4 |
| 4910 |
|| rs6000_tune == PROCESSOR_POWER5 |
| 4911 |
|| rs6000_tune == PROCESSOR_POWER6 |
| 4912 |
|| rs6000_tune == PROCESSOR_POWER7 |
| 4913 |
|| rs6000_tune == PROCESSOR_POWER8)) |
| 4914 |
return align_flags (5); |
| 4915 |
else |
| 4916 |
return align_loops; |
| 4917 |
} |
| 4918 |
|
| 4919 |
/* Return true iff, data reference of TYPE can reach vector alignment (16) |
| 4920 |
after applying N number of iterations. This routine does not determine |
| 4921 |
how may iterations are required to reach desired alignment. */ |
| 4922 |
|
| 4923 |
static bool |
| 4924 |
rs6000_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed) |
| 4925 |
{ |
| 4926 |
if (is_packed) |
| 4927 |
return false; |
| 4928 |
|
| 4929 |
if (TARGET_32BIT) |
| 4930 |
{ |
| 4931 |
if (rs6000_alignment_flags == MASK_ALIGN_NATURAL) |
| 4932 |
return true; |
| 4933 |
|
| 4934 |
if (rs6000_alignment_flags == MASK_ALIGN_POWER) |
| 4935 |
return true; |
| 4936 |
|
| 4937 |
return false; |
| 4938 |
} |
| 4939 |
else |
| 4940 |
{ |
| 4941 |
if (TARGET_MACHO) |
| 4942 |
return false; |
| 4943 |
|
| 4944 |
/* Assuming that all other types are naturally aligned. CHECKME! */ |
| 4945 |
return true; |
| 4946 |
} |
| 4947 |
} |
| 4948 |
|
| 4949 |
/* Return true if the vector misalignment factor is supported by the |
| 4950 |
target. */ |
| 4951 |
static bool |
| 4952 |
rs6000_builtin_support_vector_misalignment (machine_mode mode, |
| 4953 |
const_tree type, |
| 4954 |
int misalignment, |
| 4955 |
bool is_packed) |
| 4956 |
{ |
| 4957 |
if (TARGET_VSX) |
| 4958 |
{ |
| 4959 |
if (TARGET_EFFICIENT_UNALIGNED_VSX) |
| 4960 |
return true; |
| 4961 |
|
| 4962 |
/* Return if movmisalign pattern is not supported for this mode. */ |
| 4963 |
if (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing) |
| 4964 |
return false; |
| 4965 |
|
| 4966 |
if (misalignment == -1) |
| 4967 |
{ |
| 4968 |
/* Misalignment factor is unknown at compile time but we know |
| 4969 |
it's word aligned. */ |
| 4970 |
if (rs6000_vector_alignment_reachable (type, is_packed)) |
| 4971 |
{ |
| 4972 |
int element_size = TREE_INT_CST_LOW (TYPE_SIZE (type)); |
| 4973 |
|
| 4974 |
if (element_size == 64 || element_size == 32) |
| 4975 |
return true; |
| 4976 |
} |
| 4977 |
|
| 4978 |
return false; |
| 4979 |
} |
| 4980 |
|
| 4981 |
/* VSX supports word-aligned vector. */ |
| 4982 |
if (misalignment % 4 == 0) |
| 4983 |
return true; |
| 4984 |
} |
| 4985 |
return false; |
| 4986 |
} |
| 4987 |
|
| 4988 |
/* Implement targetm.vectorize.builtin_vectorization_cost. */ |
| 4989 |
static int |
| 4990 |
rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, |
| 4991 |
tree vectype, int misalign) |
| 4992 |
{ |
| 4993 |
unsigned elements; |
| 4994 |
tree elem_type; |
| 4995 |
|
| 4996 |
switch (type_of_cost) |
| 4997 |
{ |
| 4998 |
case scalar_stmt: |
| 4999 |
case scalar_store: |
| 5000 |
case vector_stmt: |
| 5001 |
case vector_store: |
| 5002 |
case vec_to_scalar: |
| 5003 |
case scalar_to_vec: |
| 5004 |
case cond_branch_not_taken: |
| 5005 |
return 1; |
| 5006 |
case scalar_load: |
| 5007 |
case vector_load: |
| 5008 |
/* Like rs6000_insn_cost, make load insns cost a bit more. */ |
| 5009 |
return 2; |
| 5010 |
|
| 5011 |
case vec_perm: |
| 5012 |
/* Power7 has only one permute unit, make it a bit expensive. */ |
| 5013 |
if (TARGET_VSX && rs6000_tune == PROCESSOR_POWER7) |
| 5014 |
return 3; |
| 5015 |
else |
| 5016 |
return 1; |
| 5017 |
|
| 5018 |
case vec_promote_demote: |
| 5019 |
/* Power7 has only one permute/pack unit, make it a bit expensive. */ |
| 5020 |
if (TARGET_VSX && rs6000_tune == PROCESSOR_POWER7) |
| 5021 |
return 4; |
| 5022 |
else |
| 5023 |
return 1; |
| 5024 |
|
| 5025 |
case cond_branch_taken: |
| 5026 |
return 3; |
| 5027 |
|
| 5028 |
case unaligned_load: |
| 5029 |
case vector_gather_load: |
| 5030 |
/* Like rs6000_insn_cost, make load insns cost a bit more. */ |
| 5031 |
if (TARGET_EFFICIENT_UNALIGNED_VSX) |
| 5032 |
return 2; |
| 5033 |
|
| 5034 |
if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) |
| 5035 |
{ |
| 5036 |
elements = TYPE_VECTOR_SUBPARTS (vectype); |
| 5037 |
/* See PR102767, consider V1TI to keep consistency. */ |
| 5038 |
if (elements == 2 || elements == 1) |
| 5039 |
/* Double word aligned. */ |
| 5040 |
return 4; |
| 5041 |
|
| 5042 |
if (elements == 4) |
| 5043 |
{ |
| 5044 |
switch (misalign) |
| 5045 |
{ |
| 5046 |
case 8: |
| 5047 |
/* Double word aligned. */ |
| 5048 |
return 4; |
| 5049 |
|
| 5050 |
case -1: |
| 5051 |
/* Unknown misalignment. */ |
| 5052 |
case 4: |
| 5053 |
case 12: |
| 5054 |
/* Word aligned. */ |
| 5055 |
return 33; |
| 5056 |
|
| 5057 |
default: |
| 5058 |
gcc_unreachable (); |
| 5059 |
} |
| 5060 |
} |
| 5061 |
} |
| 5062 |
|
| 5063 |
if (TARGET_ALTIVEC) |
| 5064 |
/* Misaligned loads are not supported. */ |
| 5065 |
gcc_unreachable (); |
| 5066 |
|
| 5067 |
/* Like rs6000_insn_cost, make load insns cost a bit more. */ |
| 5068 |
return 4; |
| 5069 |
|
| 5070 |
case unaligned_store: |
| 5071 |
case vector_scatter_store: |
| 5072 |
if (TARGET_EFFICIENT_UNALIGNED_VSX) |
| 5073 |
return 1; |
| 5074 |
|
| 5075 |
if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) |
| 5076 |
{ |
| 5077 |
elements = TYPE_VECTOR_SUBPARTS (vectype); |
| 5078 |
/* See PR102767, consider V1TI to keep consistency. */ |
| 5079 |
if (elements == 2 || elements == 1) |
| 5080 |
/* Double word aligned. */ |
| 5081 |
return 2; |
| 5082 |
|
| 5083 |
if (elements == 4) |
| 5084 |
{ |
| 5085 |
switch (misalign) |
| 5086 |
{ |
| 5087 |
case 8: |
| 5088 |
/* Double word aligned. */ |
| 5089 |
return 2; |
| 5090 |
|
| 5091 |
case -1: |
| 5092 |
/* Unknown misalignment. */ |
| 5093 |
case 4: |
| 5094 |
case 12: |
| 5095 |
/* Word aligned. */ |
| 5096 |
return 23; |
| 5097 |
|
| 5098 |
default: |
| 5099 |
gcc_unreachable (); |
| 5100 |
} |
| 5101 |
} |
| 5102 |
} |
| 5103 |
|
| 5104 |
if (TARGET_ALTIVEC) |
| 5105 |
/* Misaligned stores are not supported. */ |
| 5106 |
gcc_unreachable (); |
| 5107 |
|
| 5108 |
return 2; |
| 5109 |
|
| 5110 |
case vec_construct: |
| 5111 |
/* This is a rough approximation assuming non-constant elements |
| 5112 |
constructed into a vector via element insertion. FIXME: |
| 5113 |
vec_construct is not granular enough for uniformly good |
| 5114 |
decisions. If the initialization is a splat, this is |
| 5115 |
cheaper than we estimate. Improve this someday. */ |
| 5116 |
elem_type = TREE_TYPE (vectype); |
| 5117 |
/* 32-bit vectors loaded into registers are stored as double |
| 5118 |
precision, so we need 2 permutes, 2 converts, and 1 merge |
| 5119 |
to construct a vector of short floats from them. */ |
| 5120 |
if (SCALAR_FLOAT_TYPE_P (elem_type) |
| 5121 |
&& TYPE_PRECISION (elem_type) == 32) |
| 5122 |
return 5; |
| 5123 |
/* On POWER9, integer vector types are built up in GPRs and then |
| 5124 |
use a direct move (2 cycles). For POWER8 this is even worse, |
| 5125 |
as we need two direct moves and a merge, and the direct moves |
| 5126 |
are five cycles. */ |
| 5127 |
else if (INTEGRAL_TYPE_P (elem_type)) |
| 5128 |
{ |
| 5129 |
if (TARGET_P9_VECTOR) |
| 5130 |
return TYPE_VECTOR_SUBPARTS (vectype) - 1 + 2; |
| 5131 |
else |
| 5132 |
return TYPE_VECTOR_SUBPARTS (vectype) - 1 + 5; |
| 5133 |
} |
| 5134 |
else |
| 5135 |
/* V2DFmode doesn't need a direct move. */ |
| 5136 |
return 2; |
| 5137 |
|
| 5138 |
default: |
| 5139 |
gcc_unreachable (); |
| 5140 |
} |
| 5141 |
} |
| 5142 |
|
| 5143 |
/* Implement targetm.vectorize.preferred_simd_mode. */ |
| 5144 |
|
| 5145 |
static machine_mode |
| 5146 |
rs6000_preferred_simd_mode (scalar_mode mode) |
| 5147 |
{ |
| 5148 |
opt_machine_mode vmode = mode_for_vector (mode, 16 / GET_MODE_SIZE (mode)); |
| 5149 |
|
| 5150 |
if (vmode.exists () && !VECTOR_MEM_NONE_P (vmode.require ())) |
| 5151 |
return vmode.require (); |
| 5152 |
|
| 5153 |
return word_mode; |
| 5154 |
} |
| 5155 |
|
| 5156 |
class rs6000_cost_data : public vector_costs |
| 5157 |
{ |
| 5158 |
public: |
| 5159 |
using vector_costs::vector_costs; |
| 5160 |
|
| 5161 |
unsigned int add_stmt_cost (int count, vect_cost_for_stmt kind, |
| 5162 |
stmt_vec_info stmt_info, slp_tree, tree vectype, |
| 5163 |
int misalign, |
| 5164 |
vect_cost_model_location where) override; |
| 5165 |
void finish_cost (const vector_costs *) override; |
| 5166 |
|
| 5167 |
protected: |
| 5168 |
void update_target_cost_per_stmt (vect_cost_for_stmt, stmt_vec_info, |
| 5169 |
vect_cost_model_location, unsigned int); |
| 5170 |
void density_test (loop_vec_info); |
| 5171 |
void adjust_vect_cost_per_loop (loop_vec_info); |
| 5172 |
unsigned int determine_suggested_unroll_factor (loop_vec_info); |
| 5173 |
|
| 5174 |
/* Total number of vectorized stmts (loop only). */ |
| 5175 |
unsigned m_nstmts = 0; |
| 5176 |
/* Total number of loads (loop only). */ |
| 5177 |
unsigned m_nloads = 0; |
| 5178 |
/* Total number of stores (loop only). */ |
| 5179 |
unsigned m_nstores = 0; |
| 5180 |
/* Reduction factor for suggesting unroll factor (loop only). */ |
| 5181 |
unsigned m_reduc_factor = 0; |
| 5182 |
/* Possible extra penalized cost on vector construction (loop only). */ |
| 5183 |
unsigned m_extra_ctor_cost = 0; |
| 5184 |
/* For each vectorized loop, this var holds TRUE iff a non-memory vector |
| 5185 |
instruction is needed by the vectorization. */ |
| 5186 |
bool m_vect_nonmem = false; |
| 5187 |
/* If this loop gets vectorized with emulated gather load. */ |
| 5188 |
bool m_gather_load = false; |
| 5189 |
}; |
| 5190 |
|
| 5191 |
/* Test for likely overcommitment of vector hardware resources. If a |
| 5192 |
loop iteration is relatively large, and too large a percentage of |
| 5193 |
instructions in the loop are vectorized, the cost model may not |
| 5194 |
adequately reflect delays from unavailable vector resources. |
| 5195 |
Penalize the loop body cost for this case. */ |
| 5196 |
|
| 5197 |
void |
| 5198 |
rs6000_cost_data::density_test (loop_vec_info loop_vinfo) |
| 5199 |
{ |
| 5200 |
/* This density test only cares about the cost of vector version of the |
| 5201 |
loop, so immediately return if we are passed costing for the scalar |
| 5202 |
version (namely computing single scalar iteration cost). */ |
| 5203 |
if (m_costing_for_scalar) |
| 5204 |
return; |
| 5205 |
|
| 5206 |
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); |
| 5207 |
basic_block *bbs = get_loop_body (loop); |
| 5208 |
int nbbs = loop->num_nodes; |
| 5209 |
int vec_cost = m_costs[vect_body], not_vec_cost = 0; |
| 5210 |
|
| 5211 |
for (int i = 0; i < nbbs; i++) |
| 5212 |
{ |
| 5213 |
basic_block bb = bbs[i]; |
| 5214 |
gimple_stmt_iterator gsi; |
| 5215 |
|
| 5216 |
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) |
| 5217 |
{ |
| 5218 |
gimple *stmt = gsi_stmt (gsi); |
| 5219 |
if (is_gimple_debug (stmt)) |
| 5220 |
continue; |
| 5221 |
|
| 5222 |
stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (stmt); |
| 5223 |
|
| 5224 |
if (!STMT_VINFO_RELEVANT_P (stmt_info) |
| 5225 |
&& !STMT_VINFO_IN_PATTERN_P (stmt_info)) |
| 5226 |
not_vec_cost++; |
| 5227 |
} |
| 5228 |
} |
| 5229 |
|
| 5230 |
free (bbs); |
| 5231 |
int density_pct = (vec_cost * 100) / (vec_cost + not_vec_cost); |
| 5232 |
|
| 5233 |
if (density_pct > rs6000_density_pct_threshold |
| 5234 |
&& vec_cost + not_vec_cost > rs6000_density_size_threshold) |
| 5235 |
{ |
| 5236 |
m_costs[vect_body] = vec_cost * (100 + rs6000_density_penalty) / 100; |
| 5237 |
if (dump_enabled_p ()) |
| 5238 |
dump_printf_loc (MSG_NOTE, vect_location, |
| 5239 |
"density %d%%, cost %d exceeds threshold, penalizing " |
| 5240 |
"loop body cost by %u%%\n", density_pct, |
| 5241 |
vec_cost + not_vec_cost, rs6000_density_penalty); |
| 5242 |
} |
| 5243 |
|
| 5244 |
/* Check whether we need to penalize the body cost to account |
| 5245 |
for excess strided or elementwise loads. */ |
| 5246 |
if (m_extra_ctor_cost > 0) |
| 5247 |
{ |
| 5248 |
gcc_assert (m_nloads <= m_nstmts); |
| 5249 |
unsigned int load_pct = (m_nloads * 100) / m_nstmts; |
| 5250 |
|
| 5251 |
/* It's likely to be bounded by latency and execution resources |
| 5252 |
from many scalar loads which are strided or elementwise loads |
| 5253 |
into a vector if both conditions below are found: |
| 5254 |
1. there are many loads, it's easy to result in a long wait |
| 5255 |
for load units; |
| 5256 |
2. load has a big proportion of all vectorized statements, |
| 5257 |
it's not easy to schedule other statements to spread among |
| 5258 |
the loads. |
| 5259 |
One typical case is the innermost loop of the hotspot of SPEC2017 |
| 5260 |
503.bwaves_r without loop interchange. */ |
| 5261 |
if (m_nloads > (unsigned int) rs6000_density_load_num_threshold |
| 5262 |
&& load_pct > (unsigned int) rs6000_density_load_pct_threshold) |
| 5263 |
{ |
| 5264 |
m_costs[vect_body] += m_extra_ctor_cost; |
| 5265 |
if (dump_enabled_p ()) |
| 5266 |
dump_printf_loc (MSG_NOTE, vect_location, |
| 5267 |
"Found %u loads and " |
| 5268 |
"load pct. %u%% exceed " |
| 5269 |
"the threshold, " |
| 5270 |
"penalizing loop body " |
| 5271 |
"cost by extra cost %u " |
| 5272 |
"for ctor.\n", |
| 5273 |
m_nloads, load_pct, |
| 5274 |
m_extra_ctor_cost); |
| 5275 |
} |
| 5276 |
} |
| 5277 |
} |
| 5278 |
|
| 5279 |
/* Implement targetm.vectorize.create_costs. */ |
| 5280 |
|
| 5281 |
static vector_costs * |
| 5282 |
rs6000_vectorize_create_costs (vec_info *vinfo, bool costing_for_scalar) |
| 5283 |
{ |
| 5284 |
return new rs6000_cost_data (vinfo, costing_for_scalar); |
| 5285 |
} |
| 5286 |
|
| 5287 |
/* Adjust vectorization cost after calling rs6000_builtin_vectorization_cost. |
| 5288 |
For some statement, we would like to further fine-grain tweak the cost on |
| 5289 |
top of rs6000_builtin_vectorization_cost handling which doesn't have any |
| 5290 |
information on statement operation codes etc. One typical case here is |
| 5291 |
COND_EXPR, it takes the same cost to simple FXU instruction when evaluating |
| 5292 |
for scalar cost, but it should be priced more whatever transformed to either |
| 5293 |
compare + branch or compare + isel instructions. */ |
| 5294 |
|
| 5295 |
static unsigned |
| 5296 |
rs6000_adjust_vect_cost_per_stmt (enum vect_cost_for_stmt kind, |
| 5297 |
struct _stmt_vec_info *stmt_info) |
| 5298 |
{ |
| 5299 |
if (kind == scalar_stmt && stmt_info && stmt_info->stmt |
| 5300 |
&& gimple_code (stmt_info->stmt) == GIMPLE_ASSIGN) |
| 5301 |
{ |
| 5302 |
tree_code subcode = gimple_assign_rhs_code (stmt_info->stmt); |
| 5303 |
if (subcode == COND_EXPR) |
| 5304 |
return 2; |
| 5305 |
} |
| 5306 |
|
| 5307 |
return 0; |
| 5308 |
} |
| 5309 |
|
| 5310 |
/* Helper function for add_stmt_cost. Check each statement cost |
| 5311 |
entry, gather information and update the target_cost fields |
| 5312 |
accordingly. */ |
| 5313 |
void |
| 5314 |
rs6000_cost_data::update_target_cost_per_stmt (vect_cost_for_stmt kind, |
| 5315 |
stmt_vec_info stmt_info, |
| 5316 |
vect_cost_model_location where, |
| 5317 |
unsigned int orig_count) |
| 5318 |
{ |
| 5319 |
|
| 5320 |
/* Check whether we're doing something other than just a copy loop. |
| 5321 |
Not all such loops may be profitably vectorized; see |
| 5322 |
rs6000_finish_cost. */ |
| 5323 |
if (kind == vec_to_scalar |
| 5324 |
|| kind == vec_perm |
| 5325 |
|| kind == vec_promote_demote |
| 5326 |
|| kind == vec_construct |
| 5327 |
|| kind == scalar_to_vec |
| 5328 |
|| (where == vect_body && kind == vector_stmt)) |
| 5329 |
m_vect_nonmem = true; |
| 5330 |
|
| 5331 |
/* Gather some information when we are costing the vectorized instruction |
| 5332 |
for the statements located in a loop body. */ |
| 5333 |
if (!m_costing_for_scalar |
| 5334 |
&& is_a<loop_vec_info> (m_vinfo) |
| 5335 |
&& where == vect_body) |
| 5336 |
{ |
| 5337 |
m_nstmts += orig_count; |
| 5338 |
|
| 5339 |
if (kind == scalar_load |
| 5340 |
|| kind == vector_load |
| 5341 |
|| kind == unaligned_load |
| 5342 |
|| kind == vector_gather_load) |
| 5343 |
{ |
| 5344 |
m_nloads += orig_count; |
| 5345 |
if (stmt_info && STMT_VINFO_GATHER_SCATTER_P (stmt_info)) |
| 5346 |
m_gather_load = true; |
| 5347 |
} |
| 5348 |
else if (kind == scalar_store |
| 5349 |
|| kind == vector_store |
| 5350 |
|| kind == unaligned_store |
| 5351 |
|| kind == vector_scatter_store) |
| 5352 |
m_nstores += orig_count; |
| 5353 |
else if ((kind == scalar_stmt |
| 5354 |
|| kind == vector_stmt |
| 5355 |
|| kind == vec_to_scalar) |
| 5356 |
&& stmt_info |
| 5357 |
&& vect_is_reduction (stmt_info)) |
| 5358 |
{ |
| 5359 |
/* Loop body contains normal int or fp operations and epilogue |
| 5360 |
contains vector reduction. For simplicity, we assume int |
| 5361 |
operation takes one cycle and fp operation takes one more. */ |
| 5362 |
tree lhs = gimple_get_lhs (stmt_info->stmt); |
| 5363 |
bool is_float = FLOAT_TYPE_P (TREE_TYPE (lhs)); |
| 5364 |
unsigned int basic_cost = is_float ? 2 : 1; |
| 5365 |
m_reduc_factor = MAX (basic_cost * orig_count, m_reduc_factor); |
| 5366 |
} |
| 5367 |
|
| 5368 |
/* Power processors do not currently have instructions for strided |
| 5369 |
and elementwise loads, and instead we must generate multiple |
| 5370 |
scalar loads. This leads to undercounting of the cost. We |
| 5371 |
account for this by scaling the construction cost by the number |
| 5372 |
of elements involved, and saving this as extra cost that we may |
| 5373 |
or may not need to apply. When finalizing the cost of the loop, |
| 5374 |
the extra penalty is applied when the load density heuristics |
| 5375 |
are satisfied. */ |
| 5376 |
if (kind == vec_construct && stmt_info |
| 5377 |
&& STMT_VINFO_TYPE (stmt_info) == load_vec_info_type |
| 5378 |
&& (STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) == VMAT_ELEMENTWISE |
| 5379 |
|| STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) == VMAT_STRIDED_SLP)) |
| 5380 |
{ |
| 5381 |
tree vectype = STMT_VINFO_VECTYPE (stmt_info); |
| 5382 |
unsigned int nunits = vect_nunits_for_cost (vectype); |
| 5383 |
/* As PR103702 shows, it's possible that vectorizer wants to do |
| 5384 |
costings for only one unit here, it's no need to do any |
| 5385 |
penalization for it, so simply early return here. */ |
| 5386 |
if (nunits == 1) |
| 5387 |
return; |
| 5388 |
/* i386 port adopts nunits * stmt_cost as the penalized cost |
| 5389 |
for this kind of penalization, we used to follow it but |
| 5390 |
found it could result in an unreliable body cost especially |
| 5391 |
for V16QI/V8HI modes. To make it better, we choose this |
| 5392 |
new heuristic: for each scalar load, we use 2 as penalized |
| 5393 |
cost for the case with 2 nunits and use 1 for the other |
| 5394 |
cases. It's without much supporting theory, mainly |
| 5395 |
concluded from the broad performance evaluations on Power8, |
| 5396 |
Power9 and Power10. One possibly related point is that: |
| 5397 |
vector construction for more units would use more insns, |
| 5398 |
it has more chances to schedule them better (even run in |
| 5399 |
parallelly when enough available units at that time), so |
| 5400 |
it seems reasonable not to penalize that much for them. */ |
| 5401 |
unsigned int adjusted_cost = (nunits == 2) ? 2 : 1; |
| 5402 |
unsigned int extra_cost = nunits * adjusted_cost; |
| 5403 |
m_extra_ctor_cost += extra_cost; |
| 5404 |
} |
| 5405 |
} |
| 5406 |
} |
| 5407 |
|
| 5408 |
unsigned |
| 5409 |
rs6000_cost_data::add_stmt_cost (int count, vect_cost_for_stmt kind, |
| 5410 |
stmt_vec_info stmt_info, slp_tree, |
| 5411 |
tree vectype, int misalign, |
| 5412 |
vect_cost_model_location where) |
| 5413 |
{ |
| 5414 |
unsigned retval = 0; |
| 5415 |
|
| 5416 |
if (flag_vect_cost_model) |
| 5417 |
{ |
| 5418 |
int stmt_cost = rs6000_builtin_vectorization_cost (kind, vectype, |
| 5419 |
misalign); |
| 5420 |
stmt_cost += rs6000_adjust_vect_cost_per_stmt (kind, stmt_info); |
| 5421 |
/* Statements in an inner loop relative to the loop being |
| 5422 |
vectorized are weighted more heavily. The value here is |
| 5423 |
arbitrary and could potentially be improved with analysis. */ |
| 5424 |
unsigned int orig_count = count; |
| 5425 |
retval = adjust_cost_for_freq (stmt_info, where, count * stmt_cost); |
| 5426 |
m_costs[where] += retval; |
| 5427 |
|
| 5428 |
update_target_cost_per_stmt (kind, stmt_info, where, orig_count); |
| 5429 |
} |
| 5430 |
|
| 5431 |
return retval; |
| 5432 |
} |
| 5433 |
|
| 5434 |
/* For some target specific vectorization cost which can't be handled per stmt, |
| 5435 |
we check the requisite conditions and adjust the vectorization cost |
| 5436 |
accordingly if satisfied. One typical example is to model shift cost for |
| 5437 |
vector with length by counting number of required lengths under condition |
| 5438 |
LOOP_VINFO_FULLY_WITH_LENGTH_P. */ |
| 5439 |
|
| 5440 |
void |
| 5441 |
rs6000_cost_data::adjust_vect_cost_per_loop (loop_vec_info loop_vinfo) |
| 5442 |
{ |
| 5443 |
if (LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo)) |
| 5444 |
{ |
| 5445 |
rgroup_controls *rgc; |
| 5446 |
unsigned int num_vectors_m1; |
| 5447 |
unsigned int shift_cnt = 0; |
| 5448 |
FOR_EACH_VEC_ELT (LOOP_VINFO_LENS (loop_vinfo), num_vectors_m1, rgc) |
| 5449 |
if (rgc->type) |
| 5450 |
/* Each length needs one shift to fill into bits 0-7. */ |
| 5451 |
shift_cnt += num_vectors_m1 + 1; |
| 5452 |
|
| 5453 |
add_stmt_cost (shift_cnt, scalar_stmt, NULL, NULL, |
| 5454 |
NULL_TREE, 0, vect_body); |
| 5455 |
} |
| 5456 |
} |
| 5457 |
|
| 5458 |
/* Determine suggested unroll factor by considering some below factors: |
| 5459 |
|
| 5460 |
- unroll option/pragma which can disable unrolling for this loop; |
| 5461 |
- simple hardware resource model for non memory vector insns; |
| 5462 |
- aggressive heuristics when iteration count is unknown: |
| 5463 |
- reduction case to break cross iteration dependency; |
| 5464 |
- emulated gather load; |
| 5465 |
- estimated iteration count when iteration count is unknown; |
| 5466 |
*/ |
| 5467 |
|
| 5468 |
|
| 5469 |
unsigned int |
| 5470 |
rs6000_cost_data::determine_suggested_unroll_factor (loop_vec_info loop_vinfo) |
| 5471 |
{ |
| 5472 |
class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); |
| 5473 |
|
| 5474 |
/* Don't unroll if it's specified explicitly not to be unrolled. */ |
| 5475 |
if (loop->unroll == 1 |
| 5476 |
|| (OPTION_SET_P (flag_unroll_loops) && !flag_unroll_loops) |
| 5477 |
|| (OPTION_SET_P (flag_unroll_all_loops) && !flag_unroll_all_loops)) |
| 5478 |
return 1; |
| 5479 |
|
| 5480 |
unsigned int nstmts_nonldst = m_nstmts - m_nloads - m_nstores; |
| 5481 |
/* Don't unroll if no vector instructions excepting for memory access. */ |
| 5482 |
if (nstmts_nonldst == 0) |
| 5483 |
return 1; |
| 5484 |
|
| 5485 |
/* Consider breaking cross iteration dependency for reduction. */ |
| 5486 |
unsigned int reduc_factor = m_reduc_factor > 1 ? m_reduc_factor : 1; |
| 5487 |
|
| 5488 |
/* Use this simple hardware resource model that how many non ld/st |
| 5489 |
vector instructions can be issued per cycle. */ |
| 5490 |
unsigned int issue_width = rs6000_vect_unroll_issue; |
| 5491 |
unsigned int uf = CEIL (reduc_factor * issue_width, nstmts_nonldst); |
| 5492 |
uf = MIN ((unsigned int) rs6000_vect_unroll_limit, uf); |
| 5493 |
/* Make sure it is power of 2. */ |
| 5494 |
uf = 1 << ceil_log2 (uf); |
| 5495 |
|
| 5496 |
/* If the iteration count is known, the costing would be exact enough, |
| 5497 |
don't worry it could be worse. */ |
| 5498 |
if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)) |
| 5499 |
return uf; |
| 5500 |
|
| 5501 |
/* Inspired by SPEC2017 parest_r, we want to aggressively unroll the |
| 5502 |
loop if either condition is satisfied: |
| 5503 |
- reduction factor exceeds the threshold; |
| 5504 |
- emulated gather load adopted. */ |
| 5505 |
if (reduc_factor > (unsigned int) rs6000_vect_unroll_reduc_threshold |
| 5506 |
|| m_gather_load) |
| 5507 |
return uf; |
| 5508 |
|
| 5509 |
/* Check if we can conclude it's good to unroll from the estimated |
| 5510 |
iteration count. */ |
| 5511 |
HOST_WIDE_INT est_niter = get_estimated_loop_iterations_int (loop); |
| 5512 |
unsigned int vf = vect_vf_for_cost (loop_vinfo); |
| 5513 |
unsigned int unrolled_vf = vf * uf; |
| 5514 |
if (est_niter == -1 || est_niter < unrolled_vf) |
| 5515 |
/* When the estimated iteration of this loop is unknown, it's possible |
| 5516 |
that we are able to vectorize this loop with the original VF but fail |
| 5517 |
to vectorize it with the unrolled VF any more if the actual iteration |
| 5518 |
count is in between. */ |
| 5519 |
return 1; |
| 5520 |
else |
| 5521 |
{ |
| 5522 |
unsigned int epil_niter_unr = est_niter % unrolled_vf; |
| 5523 |
unsigned int epil_niter = est_niter % vf; |
| 5524 |
/* Even if we have partial vector support, it can be still inefficent |
| 5525 |
to calculate the length when the iteration count is unknown, so |
| 5526 |
only expect it's good to unroll when the epilogue iteration count |
| 5527 |
is not bigger than VF (only one time length calculation). */ |
| 5528 |
if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) |
| 5529 |
&& epil_niter_unr <= vf) |
| 5530 |
return uf; |
| 5531 |
/* Without partial vector support, conservatively unroll this when |
| 5532 |
the epilogue iteration count is less than the original one |
| 5533 |
(epilogue execution time wouldn't be longer than before). */ |
| 5534 |
else if (!LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) |
| 5535 |
&& epil_niter_unr <= epil_niter) |
| 5536 |
return uf; |
| 5537 |
} |
| 5538 |
|
| 5539 |
return 1; |
| 5540 |
} |
| 5541 |
|
| 5542 |
void |
| 5543 |
rs6000_cost_data::finish_cost (const vector_costs *scalar_costs) |
| 5544 |
{ |
| 5545 |
if (loop_vec_info loop_vinfo = dyn_cast<loop_vec_info> (m_vinfo)) |
| 5546 |
{ |
| 5547 |
adjust_vect_cost_per_loop (loop_vinfo); |
| 5548 |
density_test (loop_vinfo); |
| 5549 |
|
| 5550 |
/* Don't vectorize minimum-vectorization-factor, simple copy loops |
| 5551 |
that require versioning for any reason. The vectorization is at |
| 5552 |
best a wash inside the loop, and the versioning checks make |
| 5553 |
profitability highly unlikely and potentially quite harmful. */ |
| 5554 |
if (!m_vect_nonmem |
| 5555 |
&& LOOP_VINFO_VECT_FACTOR (loop_vinfo) == 2 |
| 5556 |
&& LOOP_REQUIRES_VERSIONING (loop_vinfo)) |
| 5557 |
m_costs[vect_body] += 10000; |
| 5558 |
|
| 5559 |
m_suggested_unroll_factor |
| 5560 |
= determine_suggested_unroll_factor (loop_vinfo); |
| 5561 |
} |
| 5562 |
|
| 5563 |
vector_costs::finish_cost (scalar_costs); |
| 5564 |
} |
| 5565 |
|
| 5566 |
/* Implement targetm.loop_unroll_adjust. */ |
| 5567 |
|
| 5568 |
static unsigned |
| 5569 |
rs6000_loop_unroll_adjust (unsigned nunroll, struct loop *loop) |
| 5570 |
{ |
| 5571 |
if (unroll_only_small_loops) |
| 5572 |
{ |
| 5573 |
/* TODO: These are hardcoded values right now. We probably should use |
| 5574 |
a PARAM here. */ |
| 5575 |
if (loop->ninsns <= 6) |
| 5576 |
return MIN (4, nunroll); |
| 5577 |
if (loop->ninsns <= 10) |
| 5578 |
return MIN (2, nunroll); |
| 5579 |
|
| 5580 |
return 0; |
| 5581 |
} |
| 5582 |
|
| 5583 |
return nunroll; |
| 5584 |
} |
| 5585 |
|
| 5586 |
/* Returns a function decl for a vectorized version of the builtin function |
| 5587 |
with builtin function code FN and the result vector type TYPE, or NULL_TREE |
| 5588 |
if it is not available. |
| 5589 |
|
| 5590 |
Implement targetm.vectorize.builtin_vectorized_function. */ |
| 5591 |
|
| 5592 |
static tree |
| 5593 |
rs6000_builtin_vectorized_function (unsigned int fn, tree type_out, |
| 5594 |
tree type_in) |
| 5595 |
{ |
| 5596 |
machine_mode in_mode, out_mode; |
| 5597 |
int in_n, out_n; |
| 5598 |
|
| 5599 |
if (TARGET_DEBUG_BUILTIN) |
| 5600 |
fprintf (stderr, "rs6000_builtin_vectorized_function (%s, %s, %s)\n", |
| 5601 |
combined_fn_name (combined_fn (fn)), |
| 5602 |
GET_MODE_NAME (TYPE_MODE (type_out)), |
| 5603 |
GET_MODE_NAME (TYPE_MODE (type_in))); |
| 5604 |
|
| 5605 |
/* TODO: Should this be gcc_assert? */ |
| 5606 |
if (TREE_CODE (type_out) != VECTOR_TYPE |
| 5607 |
|| TREE_CODE (type_in) != VECTOR_TYPE) |
| 5608 |
return NULL_TREE; |
| 5609 |
|
| 5610 |
out_mode = TYPE_MODE (TREE_TYPE (type_out)); |
| 5611 |
out_n = TYPE_VECTOR_SUBPARTS (type_out); |
| 5612 |
in_mode = TYPE_MODE (TREE_TYPE (type_in)); |
| 5613 |
in_n = TYPE_VECTOR_SUBPARTS (type_in); |
| 5614 |
|
| 5615 |
switch (fn) |
| 5616 |
{ |
| 5617 |
CASE_CFN_COPYSIGN: |
| 5618 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5619 |
&& out_mode == DFmode && out_n == 2 |
| 5620 |
&& in_mode == DFmode && in_n == 2) |
| 5621 |
return rs6000_builtin_decls[RS6000_BIF_CPSGNDP]; |
| 5622 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5623 |
&& out_mode == SFmode && out_n == 4 |
| 5624 |
&& in_mode == SFmode && in_n == 4) |
| 5625 |
return rs6000_builtin_decls[RS6000_BIF_CPSGNSP]; |
| 5626 |
if (VECTOR_UNIT_ALTIVEC_P (V4SFmode) |
| 5627 |
&& out_mode == SFmode && out_n == 4 |
| 5628 |
&& in_mode == SFmode && in_n == 4) |
| 5629 |
return rs6000_builtin_decls[RS6000_BIF_COPYSIGN_V4SF]; |
| 5630 |
break; |
| 5631 |
CASE_CFN_CEIL: |
| 5632 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5633 |
&& out_mode == DFmode && out_n == 2 |
| 5634 |
&& in_mode == DFmode && in_n == 2) |
| 5635 |
return rs6000_builtin_decls[RS6000_BIF_XVRDPIP]; |
| 5636 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5637 |
&& out_mode == SFmode && out_n == 4 |
| 5638 |
&& in_mode == SFmode && in_n == 4) |
| 5639 |
return rs6000_builtin_decls[RS6000_BIF_XVRSPIP]; |
| 5640 |
if (VECTOR_UNIT_ALTIVEC_P (V4SFmode) |
| 5641 |
&& out_mode == SFmode && out_n == 4 |
| 5642 |
&& in_mode == SFmode && in_n == 4) |
| 5643 |
return rs6000_builtin_decls[RS6000_BIF_VRFIP]; |
| 5644 |
break; |
| 5645 |
CASE_CFN_FLOOR: |
| 5646 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5647 |
&& out_mode == DFmode && out_n == 2 |
| 5648 |
&& in_mode == DFmode && in_n == 2) |
| 5649 |
return rs6000_builtin_decls[RS6000_BIF_XVRDPIM]; |
| 5650 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5651 |
&& out_mode == SFmode && out_n == 4 |
| 5652 |
&& in_mode == SFmode && in_n == 4) |
| 5653 |
return rs6000_builtin_decls[RS6000_BIF_XVRSPIM]; |
| 5654 |
if (VECTOR_UNIT_ALTIVEC_P (V4SFmode) |
| 5655 |
&& out_mode == SFmode && out_n == 4 |
| 5656 |
&& in_mode == SFmode && in_n == 4) |
| 5657 |
return rs6000_builtin_decls[RS6000_BIF_VRFIM]; |
| 5658 |
break; |
| 5659 |
CASE_CFN_FMA: |
| 5660 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5661 |
&& out_mode == DFmode && out_n == 2 |
| 5662 |
&& in_mode == DFmode && in_n == 2) |
| 5663 |
return rs6000_builtin_decls[RS6000_BIF_XVMADDDP]; |
| 5664 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5665 |
&& out_mode == SFmode && out_n == 4 |
| 5666 |
&& in_mode == SFmode && in_n == 4) |
| 5667 |
return rs6000_builtin_decls[RS6000_BIF_XVMADDSP]; |
| 5668 |
if (VECTOR_UNIT_ALTIVEC_P (V4SFmode) |
| 5669 |
&& out_mode == SFmode && out_n == 4 |
| 5670 |
&& in_mode == SFmode && in_n == 4) |
| 5671 |
return rs6000_builtin_decls[RS6000_BIF_VMADDFP]; |
| 5672 |
break; |
| 5673 |
CASE_CFN_TRUNC: |
| 5674 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5675 |
&& out_mode == DFmode && out_n == 2 |
| 5676 |
&& in_mode == DFmode && in_n == 2) |
| 5677 |
return rs6000_builtin_decls[RS6000_BIF_XVRDPIZ]; |
| 5678 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5679 |
&& out_mode == SFmode && out_n == 4 |
| 5680 |
&& in_mode == SFmode && in_n == 4) |
| 5681 |
return rs6000_builtin_decls[RS6000_BIF_XVRSPIZ]; |
| 5682 |
if (VECTOR_UNIT_ALTIVEC_P (V4SFmode) |
| 5683 |
&& out_mode == SFmode && out_n == 4 |
| 5684 |
&& in_mode == SFmode && in_n == 4) |
| 5685 |
return rs6000_builtin_decls[RS6000_BIF_VRFIZ]; |
| 5686 |
break; |
| 5687 |
CASE_CFN_NEARBYINT: |
| 5688 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5689 |
&& flag_unsafe_math_optimizations |
| 5690 |
&& out_mode == DFmode && out_n == 2 |
| 5691 |
&& in_mode == DFmode && in_n == 2) |
| 5692 |
return rs6000_builtin_decls[RS6000_BIF_XVRDPI]; |
| 5693 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5694 |
&& flag_unsafe_math_optimizations |
| 5695 |
&& out_mode == SFmode && out_n == 4 |
| 5696 |
&& in_mode == SFmode && in_n == 4) |
| 5697 |
return rs6000_builtin_decls[RS6000_BIF_XVRSPI]; |
| 5698 |
break; |
| 5699 |
CASE_CFN_RINT: |
| 5700 |
if (VECTOR_UNIT_VSX_P (V2DFmode) |
| 5701 |
&& !flag_trapping_math |
| 5702 |
&& out_mode == DFmode && out_n == 2 |
| 5703 |
&& in_mode == DFmode && in_n == 2) |
| 5704 |
return rs6000_builtin_decls[RS6000_BIF_XVRDPIC]; |
| 5705 |
if (VECTOR_UNIT_VSX_P (V4SFmode) |
| 5706 |
&& !flag_trapping_math |
| 5707 |
&& out_mode == SFmode && out_n == 4 |
| 5708 |
&& in_mode == SFmode && in_n == 4) |
| 5709 |
return rs6000_builtin_decls[RS6000_BIF_XVRSPIC]; |
| 5710 |
break; |
| 5711 |
default: |
| 5712 |
break; |
| 5713 |
} |
| 5714 |
|
| 5715 |
/* Generate calls to libmass if appropriate. */ |
| 5716 |
if (rs6000_veclib_handler) |
| 5717 |
return rs6000_veclib_handler (combined_fn (fn), type_out, type_in); |
| 5718 |
|
| 5719 |
return NULL_TREE; |
| 5720 |
} |
| 5721 |
|
| 5722 |
/* Handler for the Mathematical Acceleration Subsystem (mass) interface to a |
| 5723 |
library with vectorized intrinsics. */ |
| 5724 |
|
| 5725 |
static tree |
| 5726 |
rs6000_builtin_vectorized_libmass (combined_fn fn, tree type_out, |
| 5727 |
tree type_in) |
| 5728 |
{ |
| 5729 |
char name[32]; |
| 5730 |
const char *suffix = NULL; |
| 5731 |
tree fntype, new_fndecl, bdecl = NULL_TREE; |
| 5732 |
int n_args = 1; |
| 5733 |
const char *bname; |
| 5734 |
machine_mode el_mode, in_mode; |
| 5735 |
int n, in_n; |
| 5736 |
|
| 5737 |
/* Libmass is suitable for unsafe math only as it does not correctly support |
| 5738 |
parts of IEEE with the required precision such as denormals. Only support |
| 5739 |
it if we have VSX to use the simd d2 or f4 functions. |
| 5740 |
XXX: Add variable length support. */ |
| 5741 |
if (!flag_unsafe_math_optimizations || !TARGET_VSX) |
| 5742 |
return NULL_TREE; |
| 5743 |
|
| 5744 |
el_mode = TYPE_MODE (TREE_TYPE (type_out)); |
| 5745 |
n = TYPE_VECTOR_SUBPARTS (type_out); |
| 5746 |
in_mode = TYPE_MODE (TREE_TYPE (type_in)); |
| 5747 |
in_n = TYPE_VECTOR_SUBPARTS (type_in); |
| 5748 |
if (el_mode != in_mode |
| 5749 |
|| n != in_n) |
| 5750 |
return NULL_TREE; |
| 5751 |
|
| 5752 |
switch (fn) |
| 5753 |
{ |
| 5754 |
CASE_CFN_ATAN2: |
| 5755 |
CASE_CFN_HYPOT: |
| 5756 |
CASE_CFN_POW: |
| 5757 |
n_args = 2; |
| 5758 |
gcc_fallthrough (); |
| 5759 |
|
| 5760 |
CASE_CFN_ACOS: |
| 5761 |
CASE_CFN_ACOSH: |
| 5762 |
CASE_CFN_ASIN: |
| 5763 |
CASE_CFN_ASINH: |
| 5764 |
CASE_CFN_ATAN: |
| 5765 |
CASE_CFN_ATANH: |
| 5766 |
CASE_CFN_CBRT: |
| 5767 |
CASE_CFN_COS: |
| 5768 |
CASE_CFN_COSH: |
| 5769 |
CASE_CFN_ERF: |
| 5770 |
CASE_CFN_ERFC: |
| 5771 |
CASE_CFN_EXP2: |
| 5772 |
CASE_CFN_EXP: |
| 5773 |
CASE_CFN_EXPM1: |
| 5774 |
CASE_CFN_LGAMMA: |
| 5775 |
CASE_CFN_LOG10: |
| 5776 |
CASE_CFN_LOG1P: |
| 5777 |
CASE_CFN_LOG2: |
| 5778 |
CASE_CFN_LOG: |
| 5779 |
CASE_CFN_SIN: |
| 5780 |
CASE_CFN_SINH: |
| 5781 |
CASE_CFN_SQRT: |
| 5782 |
CASE_CFN_TAN: |
| 5783 |
CASE_CFN_TANH: |
| 5784 |
if (el_mode == DFmode && n == 2) |
| 5785 |
{ |
| 5786 |
bdecl = mathfn_built_in (double_type_node, fn); |
| 5787 |
suffix = "d2"; /* pow -> powd2 */ |
| 5788 |
} |
| 5789 |
else if (el_mode == SFmode && n == 4) |
| 5790 |
{ |
| 5791 |
bdecl = mathfn_built_in (float_type_node, fn); |
| 5792 |
suffix = "4"; /* powf -> powf4 */ |
| 5793 |
} |
| 5794 |
else |
| 5795 |
return NULL_TREE; |
| 5796 |
if (!bdecl) |
| 5797 |
return NULL_TREE; |
| 5798 |
break; |
| 5799 |
|
| 5800 |
default: |
| 5801 |
return NULL_TREE; |
| 5802 |
} |
| 5803 |
|
| 5804 |
gcc_assert (suffix != NULL); |
| 5805 |
bname = IDENTIFIER_POINTER (DECL_NAME (bdecl)); |
| 5806 |
if (!bname) |
| 5807 |
return NULL_TREE; |
| 5808 |
|
| 5809 |
strcpy (name, bname + strlen ("__builtin_")); |
| 5810 |
strcat (name, suffix); |
| 5811 |
|
| 5812 |
if (n_args == 1) |
| 5813 |
fntype = build_function_type_list (type_out, type_in, NULL); |
| 5814 |
else if (n_args == 2) |
| 5815 |
fntype = build_function_type_list (type_out, type_in, type_in, NULL); |
| 5816 |
else |
| 5817 |
gcc_unreachable (); |
| 5818 |
|
| 5819 |
/* Build a function declaration for the vectorized function. */ |
| 5820 |
new_fndecl = build_decl (BUILTINS_LOCATION, |
| 5821 |
FUNCTION_DECL, get_identifier (name), fntype); |
| 5822 |
TREE_PUBLIC (new_fndecl) = 1; |
| 5823 |
DECL_EXTERNAL (new_fndecl) = 1; |
| 5824 |
DECL_IS_NOVOPS (new_fndecl) = 1; |
| 5825 |
TREE_READONLY (new_fndecl) = 1; |
| 5826 |
|
| 5827 |
return new_fndecl; |
| 5828 |
} |
| 5829 |
|
| 5830 |
|
| 5831 |
/* Default CPU string for rs6000*_file_start functions. */ |
| 5832 |
static const char *rs6000_default_cpu; |
| 5833 |
|
| 5834 |
#ifdef USING_ELFOS_H |
| 5835 |
const char *rs6000_machine; |
| 5836 |
|
| 5837 |
const char * |
| 5838 |
rs6000_machine_from_flags (void) |
| 5839 |
{ |
| 5840 |
/* e300 and e500 */ |
| 5841 |
if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3) |
| 5842 |
return "e300"; |
| 5843 |
if (rs6000_cpu == PROCESSOR_PPC8540 || rs6000_cpu == PROCESSOR_PPC8548) |
| 5844 |
return "e500"; |
| 5845 |
if (rs6000_cpu == PROCESSOR_PPCE500MC) |
| 5846 |
return "e500mc"; |
| 5847 |
if (rs6000_cpu == PROCESSOR_PPCE500MC64) |
| 5848 |
return "e500mc64"; |
| 5849 |
if (rs6000_cpu == PROCESSOR_PPCE5500) |
| 5850 |
return "e5500"; |
| 5851 |
if (rs6000_cpu == PROCESSOR_PPCE6500) |
| 5852 |
return "e6500"; |
| 5853 |
|
| 5854 |
/* 400 series */ |
| 5855 |
if (rs6000_cpu == PROCESSOR_PPC403) |
| 5856 |
return "\"403\""; |
| 5857 |
if (rs6000_cpu == PROCESSOR_PPC405) |
| 5858 |
return "\"405\""; |
| 5859 |
if (rs6000_cpu == PROCESSOR_PPC440) |
| 5860 |
return "\"440\""; |
| 5861 |
if (rs6000_cpu == PROCESSOR_PPC476) |
| 5862 |
return "\"476\""; |
| 5863 |
|
| 5864 |
/* A2 */ |
| 5865 |
if (rs6000_cpu == PROCESSOR_PPCA2) |
| 5866 |
return "a2"; |
| 5867 |
|
| 5868 |
/* Cell BE */ |
| 5869 |
if (rs6000_cpu == PROCESSOR_CELL) |
| 5870 |
return "cell"; |
| 5871 |
|
| 5872 |
/* Titan */ |
| 5873 |
if (rs6000_cpu == PROCESSOR_TITAN) |
| 5874 |
return "titan"; |
| 5875 |
|
| 5876 |
/* 500 series and 800 series */ |
| 5877 |
if (rs6000_cpu == PROCESSOR_MPCCORE) |
| 5878 |
return "\"821\""; |
| 5879 |
|
| 5880 |
#if 0 |
| 5881 |
/* This (and ppc64 below) are disabled here (for now at least) because |
| 5882 |
PROCESSOR_POWERPC, PROCESSOR_POWERPC64, and PROCESSOR_COMMON |
| 5883 |
are #define'd as some of these. Untangling that is a job for later. */ |
| 5884 |
|
| 5885 |
/* 600 series and 700 series, "classic" */ |
| 5886 |
if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603 |
| 5887 |
|| rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e |
| 5888 |
|| rs6000_cpu == PROCESSOR_PPC750) |
| 5889 |
return "ppc"; |
| 5890 |
#endif |
| 5891 |
|
| 5892 |
/* Classic with AltiVec, "G4" */ |
| 5893 |
if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450) |
| 5894 |
return "\"7450\""; |
| 5895 |
|
| 5896 |
#if 0 |
| 5897 |
/* The older 64-bit CPUs */ |
| 5898 |
if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630 |
| 5899 |
|| rs6000_cpu == PROCESSOR_RS64A) |
| 5900 |
return "ppc64"; |
| 5901 |
#endif |
| 5902 |
|
| 5903 |
HOST_WIDE_INT flags = rs6000_isa_flags; |
| 5904 |
|
| 5905 |
/* Disable the flags that should never influence the .machine selection. */ |
| 5906 |
flags &= ~(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT | OPTION_MASK_ISEL |
| 5907 |
| OPTION_MASK_ALTIVEC); |
| 5908 |
|
| 5909 |
if ((flags & (POWER11_MASKS_SERVER & ~ISA_3_1_MASKS_SERVER)) != 0) |
| 5910 |
return "power11"; |
| 5911 |
if ((flags & (ISA_3_1_MASKS_SERVER & ~ISA_3_0_MASKS_SERVER)) != 0) |
| 5912 |
return "power10"; |
| 5913 |
if ((flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0) |
| 5914 |
return "power9"; |
| 5915 |
if ((flags & (ISA_2_7_MASKS_SERVER & ~ISA_2_6_MASKS_SERVER)) != 0) |
| 5916 |
return "power8"; |
| 5917 |
if ((flags & (ISA_2_6_MASKS_SERVER & ~ISA_2_5_MASKS_SERVER)) != 0) |
| 5918 |
return "power7"; |
| 5919 |
if ((flags & (ISA_2_5_MASKS_SERVER & ~ISA_2_4_MASKS)) != 0) |
| 5920 |
return "power6"; |
| 5921 |
if ((flags & (ISA_2_4_MASKS & ~ISA_2_1_MASKS)) != 0) |
| 5922 |
return "power5"; |
| 5923 |
if ((flags & ISA_2_1_MASKS) != 0) |
| 5924 |
return "power4"; |
| 5925 |
if ((flags & OPTION_MASK_POWERPC64) != 0) |
| 5926 |
return "ppc64"; |
| 5927 |
return "ppc"; |
| 5928 |
} |
| 5929 |
|
| 5930 |
void |
| 5931 |
emit_asm_machine (void) |
| 5932 |
{ |
| 5933 |
fprintf (asm_out_file, "\t.machine %s\n", rs6000_machine); |
| 5934 |
if (TARGET_ALTIVEC) |
| 5935 |
fprintf (asm_out_file, "\t.machine altivec\n"); |
| 5936 |
} |
| 5937 |
#endif |
| 5938 |
|
| 5939 |
/* Do anything needed at the start of the asm file. */ |
| 5940 |
|
| 5941 |
static void |
| 5942 |
rs6000_file_start (void) |
| 5943 |
{ |
| 5944 |
char buffer[80]; |
| 5945 |
const char *start = buffer; |
| 5946 |
FILE *file = asm_out_file; |
| 5947 |
|
| 5948 |
rs6000_default_cpu = TARGET_CPU_DEFAULT; |
| 5949 |
|
| 5950 |
default_file_start (); |
| 5951 |
|
| 5952 |
if (flag_verbose_asm) |
| 5953 |
{ |
| 5954 |
sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START); |
| 5955 |
|
| 5956 |
if (rs6000_default_cpu != 0 && rs6000_default_cpu[0] != '\0') |
| 5957 |
{ |
| 5958 |
fprintf (file, "%s --with-cpu=%s", start, rs6000_default_cpu); |
| 5959 |
start = ""; |
| 5960 |
} |
| 5961 |
|
| 5962 |
if (OPTION_SET_P (rs6000_cpu_index)) |
| 5963 |
{ |
| 5964 |
fprintf (file, "%s -mcpu=%s", start, |
| 5965 |
processor_target_table[rs6000_cpu_index].name); |
| 5966 |
start = ""; |
| 5967 |
} |
| 5968 |
|
| 5969 |
if (OPTION_SET_P (rs6000_tune_index)) |
| 5970 |
{ |
| 5971 |
fprintf (file, "%s -mtune=%s", start, |
| 5972 |
processor_target_table[rs6000_tune_index].name); |
| 5973 |
start = ""; |
| 5974 |
} |
| 5975 |
|
| 5976 |
if (PPC405_ERRATUM77) |
| 5977 |
{ |
| 5978 |
fprintf (file, "%s PPC405CR_ERRATUM77", start); |
| 5979 |
start = ""; |
| 5980 |
} |
| 5981 |
|
| 5982 |
#ifdef USING_ELFOS_H |
| 5983 |
switch (rs6000_sdata) |
| 5984 |
{ |
| 5985 |
case SDATA_NONE: fprintf (file, "%s -msdata=none", start); start = ""; break; |
| 5986 |
case SDATA_DATA: fprintf (file, "%s -msdata=data", start); start = ""; break; |
| 5987 |
case SDATA_SYSV: fprintf (file, "%s -msdata=sysv", start); start = ""; break; |
| 5988 |
case SDATA_EABI: fprintf (file, "%s -msdata=eabi", start); start = ""; break; |
| 5989 |
} |
| 5990 |
|
| 5991 |
if (rs6000_sdata && g_switch_value) |
| 5992 |
{ |
| 5993 |
fprintf (file, "%s -G %d", start, |
| 5994 |
g_switch_value); |
| 5995 |
start = ""; |
| 5996 |
} |
| 5997 |
#endif |
| 5998 |
|
| 5999 |
if (*start == '\0') |
| 6000 |
putc ('\n', file); |
| 6001 |
} |
| 6002 |
|
| 6003 |
#ifdef USING_ELFOS_H |
| 6004 |
rs6000_machine = rs6000_machine_from_flags (); |
| 6005 |
emit_asm_machine (); |
| 6006 |
#endif |
| 6007 |
|
| 6008 |
if (DEFAULT_ABI == ABI_ELFv2) |
| 6009 |
fprintf (file, "\t.abiversion 2\n"); |
| 6010 |
} |
| 6011 |
|
| 6012 |
|
| 6013 |
/* Return nonzero if this function is known to have a null epilogue. */ |
| 6014 |
|
| 6015 |
int |
| 6016 |
direct_return (void) |
| 6017 |
{ |
| 6018 |
if (reload_completed) |
| 6019 |
{ |
| 6020 |
rs6000_stack_t *info = rs6000_stack_info (); |
| 6021 |
|
| 6022 |
if (info->first_gp_reg_save == 32 |
| 6023 |
&& info->first_fp_reg_save == 64 |
| 6024 |
&& info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1 |
| 6025 |
&& ! info->lr_save_p |
| 6026 |
&& ! info->cr_save_p |
| 6027 |
&& info->vrsave_size == 0 |
| 6028 |
&& ! info->push_p) |
| 6029 |
return 1; |
| 6030 |
} |
| 6031 |
|
| 6032 |
return 0; |
| 6033 |
} |
| 6034 |
|
| 6035 |
/* Helper for num_insns_constant. Calculate number of instructions to |
| 6036 |
load VALUE to a single gpr using combinations of addi, addis, ori, |
| 6037 |
oris, sldi and rldimi instructions. */ |
| 6038 |
|
| 6039 |
static int |
| 6040 |
num_insns_constant_gpr (HOST_WIDE_INT value) |
| 6041 |
{ |
| 6042 |
/* signed constant loadable with addi */ |
| 6043 |
if (SIGNED_INTEGER_16BIT_P (value)) |
| 6044 |
return 1; |
| 6045 |
|
| 6046 |
/* constant loadable with addis */ |
| 6047 |
else if ((value & 0xffff) == 0 |
| 6048 |
&& (value >> 31 == -1 || value >> 31 == 0)) |
| 6049 |
return 1; |
| 6050 |
|
| 6051 |
/* PADDI can support up to 34 bit signed integers. */ |
| 6052 |
else if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (value)) |
| 6053 |
return 1; |
| 6054 |
|
| 6055 |
else if (TARGET_POWERPC64) |
| 6056 |
{ |
| 6057 |
int num_insns = 0; |
| 6058 |
rs6000_emit_set_long_const (nullptr, value, &num_insns); |
| 6059 |
return num_insns; |
| 6060 |
} |
| 6061 |
|
| 6062 |
else |
| 6063 |
return 2; |
| 6064 |
} |
| 6065 |
|
| 6066 |
/* Helper for num_insns_constant. Allow constants formed by the |
| 6067 |
num_insns_constant_gpr sequences, plus li -1, rldicl/rldicr/rlwinm, |
| 6068 |
and handle modes that require multiple gprs. */ |
| 6069 |
|
| 6070 |
static int |
| 6071 |
num_insns_constant_multi (HOST_WIDE_INT value, machine_mode mode) |
| 6072 |
{ |
| 6073 |
int nregs = (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD; |
| 6074 |
int total = 0; |
| 6075 |
while (nregs-- > 0) |
| 6076 |
{ |
| 6077 |
HOST_WIDE_INT low = sext_hwi (value, BITS_PER_WORD); |
| 6078 |
int insns = num_insns_constant_gpr (low); |
| 6079 |
if (insns > 2 |
| 6080 |
/* We won't get more than 2 from num_insns_constant_gpr |
| 6081 |
except when TARGET_POWERPC64 and mode is DImode or |
| 6082 |
wider, so the register mode must be DImode. */ |
| 6083 |
&& rs6000_is_valid_and_mask (GEN_INT (low), DImode)) |
| 6084 |
insns = 2; |
| 6085 |
total += insns; |
| 6086 |
/* If BITS_PER_WORD is the number of bits in HOST_WIDE_INT, doing |
| 6087 |
it all at once would be UB. */ |
| 6088 |
value >>= (BITS_PER_WORD - 1); |
| 6089 |
value >>= 1; |
| 6090 |
} |
| 6091 |
return total; |
| 6092 |
} |
| 6093 |
|
| 6094 |
/* Return the number of instructions it takes to form a constant in as |
| 6095 |
many gprs are needed for MODE. */ |
| 6096 |
|
| 6097 |
int |
| 6098 |
num_insns_constant (rtx op, machine_mode mode) |
| 6099 |
{ |
| 6100 |
HOST_WIDE_INT val; |
| 6101 |
|
| 6102 |
switch (GET_CODE (op)) |
| 6103 |
{ |
| 6104 |
case CONST_INT: |
| 6105 |
val = INTVAL (op); |
| 6106 |
break; |
| 6107 |
|
| 6108 |
case CONST_WIDE_INT: |
| 6109 |
{ |
| 6110 |
int insns = 0; |
| 6111 |
for (int i = 0; i < CONST_WIDE_INT_NUNITS (op); i++) |
| 6112 |
insns += num_insns_constant_multi (CONST_WIDE_INT_ELT (op, i), |
| 6113 |
DImode); |
| 6114 |
return insns; |
| 6115 |
} |
| 6116 |
|
| 6117 |
case CONST_DOUBLE: |
| 6118 |
{ |
| 6119 |
const struct real_value *rv = CONST_DOUBLE_REAL_VALUE (op); |
| 6120 |
|
| 6121 |
if (mode == SFmode || mode == SDmode) |
| 6122 |
{ |
| 6123 |
long l; |
| 6124 |
|
| 6125 |
if (mode == SDmode) |
| 6126 |
REAL_VALUE_TO_TARGET_DECIMAL32 (*rv, l); |
| 6127 |
else |
| 6128 |
REAL_VALUE_TO_TARGET_SINGLE (*rv, l); |
| 6129 |
/* See the first define_split in rs6000.md handling a |
| 6130 |
const_double_operand. */ |
| 6131 |
val = l; |
| 6132 |
mode = SImode; |
| 6133 |
} |
| 6134 |
else if (mode == DFmode || mode == DDmode) |
| 6135 |
{ |
| 6136 |
long l[2]; |
| 6137 |
|
| 6138 |
if (mode == DDmode) |
| 6139 |
REAL_VALUE_TO_TARGET_DECIMAL64 (*rv, l); |
| 6140 |
else |
| 6141 |
REAL_VALUE_TO_TARGET_DOUBLE (*rv, l); |
| 6142 |
|
| 6143 |
/* See the second (32-bit) and third (64-bit) define_split |
| 6144 |
in rs6000.md handling a const_double_operand. */ |
| 6145 |
val = (unsigned HOST_WIDE_INT) l[WORDS_BIG_ENDIAN ? 0 : 1] << 32; |
| 6146 |
val |= l[WORDS_BIG_ENDIAN ? 1 : 0] & 0xffffffffUL; |
| 6147 |
mode = DImode; |
| 6148 |
} |
| 6149 |
else if (mode == TFmode || mode == TDmode |
| 6150 |
|| mode == KFmode || mode == IFmode) |
| 6151 |
{ |
| 6152 |
long l[4]; |
| 6153 |
int insns; |
| 6154 |
|
| 6155 |
if (mode == TDmode) |
| 6156 |
REAL_VALUE_TO_TARGET_DECIMAL128 (*rv, l); |
| 6157 |
else |
| 6158 |
REAL_VALUE_TO_TARGET_LONG_DOUBLE (*rv, l); |
| 6159 |
|
| 6160 |
val = (unsigned HOST_WIDE_INT) l[WORDS_BIG_ENDIAN ? 0 : 3] << 32; |
| 6161 |
val |= l[WORDS_BIG_ENDIAN ? 1 : 2] & 0xffffffffUL; |
| 6162 |
insns = num_insns_constant_multi (val, DImode); |
| 6163 |
val = (unsigned HOST_WIDE_INT) l[WORDS_BIG_ENDIAN ? 2 : 1] << 32; |
| 6164 |
val |= l[WORDS_BIG_ENDIAN ? 3 : 0] & 0xffffffffUL; |
| 6165 |
insns += num_insns_constant_multi (val, DImode); |
| 6166 |
return insns; |
| 6167 |
} |
| 6168 |
else |
| 6169 |
gcc_unreachable (); |
| 6170 |
} |
| 6171 |
break; |
| 6172 |
|
| 6173 |
default: |
| 6174 |
gcc_unreachable (); |
| 6175 |
} |
| 6176 |
|
| 6177 |
return num_insns_constant_multi (val, mode); |
| 6178 |
} |
| 6179 |
|
| 6180 |
/* Interpret element ELT of the CONST_VECTOR OP as an integer value. |
| 6181 |
If the mode of OP is MODE_VECTOR_INT, this simply returns the |
| 6182 |
corresponding element of the vector, but for V4SFmode, the |
| 6183 |
corresponding "float" is interpreted as an SImode integer. */ |
| 6184 |
|
| 6185 |
HOST_WIDE_INT |
| 6186 |
const_vector_elt_as_int (rtx op, unsigned int elt) |
| 6187 |
{ |
| 6188 |
rtx tmp; |
| 6189 |
|
| 6190 |
/* We can't handle V2DImode and V2DFmode vector constants here yet. */ |
| 6191 |
gcc_assert (GET_MODE (op) != V2DImode |
| 6192 |
&& GET_MODE (op) != V2DFmode); |
| 6193 |
|
| 6194 |
tmp = CONST_VECTOR_ELT (op, elt); |
| 6195 |
if (GET_MODE (op) == V4SFmode) |
| 6196 |
tmp = gen_lowpart (SImode, tmp); |
| 6197 |
return INTVAL (tmp); |
| 6198 |
} |
| 6199 |
|
| 6200 |
/* Return true if OP can be synthesized with a particular vspltisb, vspltish |
| 6201 |
or vspltisw instruction. OP is a CONST_VECTOR. Which instruction is used |
| 6202 |
depends on STEP and COPIES, one of which will be 1. If COPIES > 1, |
| 6203 |
all items are set to the same value and contain COPIES replicas of the |
| 6204 |
vsplt's operand; if STEP > 1, one in STEP elements is set to the vsplt's |
| 6205 |
operand and the others are set to the value of the operand's msb. */ |
| 6206 |
|
| 6207 |
static bool |
| 6208 |
vspltis_constant (rtx op, unsigned step, unsigned copies) |
| 6209 |
{ |
| 6210 |
machine_mode mode = GET_MODE (op); |
| 6211 |
machine_mode inner = GET_MODE_INNER (mode); |
| 6212 |
|
| 6213 |
unsigned i; |
| 6214 |
unsigned nunits; |
| 6215 |
unsigned bitsize; |
| 6216 |
unsigned mask; |
| 6217 |
|
| 6218 |
HOST_WIDE_INT val; |
| 6219 |
HOST_WIDE_INT splat_val; |
| 6220 |
HOST_WIDE_INT msb_val; |
| 6221 |
|
| 6222 |
if (mode == V2DImode || mode == V2DFmode || mode == V1TImode) |
| 6223 |
return false; |
| 6224 |
|
| 6225 |
nunits = GET_MODE_NUNITS (mode); |
| 6226 |
bitsize = GET_MODE_BITSIZE (inner); |
| 6227 |
mask = GET_MODE_MASK (inner); |
| 6228 |
|
| 6229 |
val = const_vector_elt_as_int (op, BYTES_BIG_ENDIAN ? nunits - 1 : 0); |
| 6230 |
splat_val = val; |
| 6231 |
msb_val = val >= 0 ? 0 : -1; |
| 6232 |
|
| 6233 |
if (val == 0 && step > 1) |
| 6234 |
{ |
| 6235 |
/* Special case for loading most significant bit with step > 1. |
| 6236 |
In that case, match 0s in all but step-1s elements, where match |
| 6237 |
EASY_VECTOR_MSB. */ |
| 6238 |
for (i = 1; i < nunits; ++i) |
| 6239 |
{ |
| 6240 |
unsigned elt = BYTES_BIG_ENDIAN ? nunits - 1 - i : i; |
| 6241 |
HOST_WIDE_INT elt_val = const_vector_elt_as_int (op, elt); |
| 6242 |
if ((i & (step - 1)) == step - 1) |
| 6243 |
{ |
| 6244 |
if (!EASY_VECTOR_MSB (elt_val, inner)) |
| 6245 |
break; |
| 6246 |
} |
| 6247 |
else if (elt_val) |
| 6248 |
break; |
| 6249 |
} |
| 6250 |
if (i == nunits) |
| 6251 |
return true; |
| 6252 |
} |
| 6253 |
|
| 6254 |
/* Construct the value to be splatted, if possible. If not, return 0. */ |
| 6255 |
for (i = 2; i <= copies; i *= 2) |
| 6256 |
{ |
| 6257 |
HOST_WIDE_INT small_val; |
| 6258 |
bitsize /= 2; |
| 6259 |
small_val = splat_val >> bitsize; |
| 6260 |
mask >>= bitsize; |
| 6261 |
if (splat_val != ((HOST_WIDE_INT) |
| 6262 |
((unsigned HOST_WIDE_INT) small_val << bitsize) |
| 6263 |
| (small_val & mask))) |
| 6264 |
return false; |
| 6265 |
splat_val = small_val; |
| 6266 |
inner = smallest_int_mode_for_size (bitsize).require (); |
| 6267 |
} |
| 6268 |
|
| 6269 |
/* Check if SPLAT_VAL can really be the operand of a vspltis[bhw]. */ |
| 6270 |
if (EASY_VECTOR_15 (splat_val)) |
| 6271 |
; |
| 6272 |
|
| 6273 |
/* Also check if we can splat, and then add the result to itself. Do so if |
| 6274 |
the value is positive, of if the splat instruction is using OP's mode; |
| 6275 |
for splat_val < 0, the splat and the add should use the same mode. */ |
| 6276 |
else if (EASY_VECTOR_15_ADD_SELF (splat_val) |
| 6277 |
&& (splat_val >= 0 || (step == 1 && copies == 1))) |
| 6278 |
; |
| 6279 |
|
| 6280 |
/* Also check if are loading up the most significant bit which can be done by |
| 6281 |
loading up -1 and shifting the value left by -1. Only do this for |
| 6282 |
step 1 here, for larger steps it is done earlier. */ |
| 6283 |
else if (EASY_VECTOR_MSB (splat_val, inner) && step == 1) |
| 6284 |
; |
| 6285 |
|
| 6286 |
else |
| 6287 |
return false; |
| 6288 |
|
| 6289 |
/* Check if VAL is present in every STEP-th element, and the |
| 6290 |
other elements are filled with its most significant bit. */ |
| 6291 |
for (i = 1; i < nunits; ++i) |
| 6292 |
{ |
| 6293 |
HOST_WIDE_INT desired_val; |
| 6294 |
unsigned elt = BYTES_BIG_ENDIAN ? nunits - 1 - i : i; |
| 6295 |
if ((i & (step - 1)) == 0) |
| 6296 |
desired_val = val; |
| 6297 |
else |
| 6298 |
desired_val = msb_val; |
| 6299 |
|
| 6300 |
if (desired_val != const_vector_elt_as_int (op, elt)) |
| 6301 |
return false; |
| 6302 |
} |
| 6303 |
|
| 6304 |
return true; |
| 6305 |
} |
| 6306 |
|
| 6307 |
/* Like vsplitis_constant, but allow the value to be shifted left with a VSLDOI |
| 6308 |
instruction, filling in the bottom elements with 0 or -1. |
| 6309 |
|
| 6310 |
Return 0 if the constant cannot be generated with VSLDOI. Return positive |
| 6311 |
for the number of zeroes to shift in, or negative for the number of 0xff |
| 6312 |
bytes to shift in. |
| 6313 |
|
| 6314 |
OP is a CONST_VECTOR. */ |
| 6315 |
|
| 6316 |
int |
| 6317 |
vspltis_shifted (rtx op) |
| 6318 |
{ |
| 6319 |
machine_mode mode = GET_MODE (op); |
| 6320 |
machine_mode inner = GET_MODE_INNER (mode); |
| 6321 |
|
| 6322 |
unsigned i, j; |
| 6323 |
unsigned nunits; |
| 6324 |
unsigned mask; |
| 6325 |
|
| 6326 |
HOST_WIDE_INT val; |
| 6327 |
|
| 6328 |
if (mode != V16QImode && mode != V8HImode && mode != V4SImode) |
| 6329 |
return false; |
| 6330 |
|
| 6331 |
/* We need to create pseudo registers to do the shift, so don't recognize |
| 6332 |
shift vector constants after reload. Don't match it even before RA |
| 6333 |
after split1 is done, because there won't be further splitting pass |
| 6334 |
before RA to do the splitting. */ |
| 6335 |
if (!can_create_pseudo_p () |
| 6336 |
|| (cfun->curr_properties & PROP_rtl_split_insns)) |
| 6337 |
return false; |
| 6338 |
|
| 6339 |
nunits = GET_MODE_NUNITS (mode); |
| 6340 |
mask = GET_MODE_MASK (inner); |
| 6341 |
|
| 6342 |
val = const_vector_elt_as_int (op, BYTES_BIG_ENDIAN ? 0 : nunits - 1); |
| 6343 |
|
| 6344 |
/* Check if the value can really be the operand of a vspltis[bhw]. */ |
| 6345 |
if (EASY_VECTOR_15 (val)) |
| 6346 |
; |
| 6347 |
|
| 6348 |
/* Also check if we are loading up the most significant bit which can be done |
| 6349 |
by loading up -1 and shifting the value left by -1. */ |
| 6350 |
else if (EASY_VECTOR_MSB (val, inner)) |
| 6351 |
; |
| 6352 |
|
| 6353 |
else |
| 6354 |
return 0; |
| 6355 |
|
| 6356 |
/* Check if VAL is present in every STEP-th element until we find elements |
| 6357 |
that are 0 or all 1 bits. */ |
| 6358 |
for (i = 1; i < nunits; ++i) |
| 6359 |
{ |
| 6360 |
unsigned elt = BYTES_BIG_ENDIAN ? i : nunits - 1 - i; |
| 6361 |
HOST_WIDE_INT elt_val = const_vector_elt_as_int (op, elt); |
| 6362 |
|
| 6363 |
/* If the value isn't the splat value, check for the remaining elements |
| 6364 |
being 0/-1. */ |
| 6365 |
if (val != elt_val) |
| 6366 |
{ |
| 6367 |
if (elt_val == 0) |
| 6368 |
{ |
| 6369 |
for (j = i+1; j < nunits; ++j) |
| 6370 |
{ |
| 6371 |
unsigned elt2 = BYTES_BIG_ENDIAN ? j : nunits - 1 - j; |
| 6372 |
if (const_vector_elt_as_int (op, elt2) != 0) |
| 6373 |
return 0; |
| 6374 |
} |
| 6375 |
|
| 6376 |
return (nunits - i) * GET_MODE_SIZE (inner); |
| 6377 |
} |
| 6378 |
|
| 6379 |
else if ((elt_val & mask) == mask) |
| 6380 |
{ |
| 6381 |
for (j = i+1; j < nunits; ++j) |
| 6382 |
{ |
| 6383 |
unsigned elt2 = BYTES_BIG_ENDIAN ? j : nunits - 1 - j; |
| 6384 |
if ((const_vector_elt_as_int (op, elt2) & mask) != mask) |
| 6385 |
return 0; |
| 6386 |
} |
| 6387 |
|
| 6388 |
return -((nunits - i) * GET_MODE_SIZE (inner)); |
| 6389 |
} |
| 6390 |
|
| 6391 |
else |
| 6392 |
return 0; |
| 6393 |
} |
| 6394 |
} |
| 6395 |
|
| 6396 |
/* If all elements are equal, we don't need to do VSLDOI. */ |
| 6397 |
return 0; |
| 6398 |
} |
| 6399 |
|
| 6400 |
|
| 6401 |
/* Return non-zero (element mode byte size) if OP is of the given MODE |
| 6402 |
and can be synthesized with a vspltisb, vspltish or vspltisw. */ |
| 6403 |
|
| 6404 |
int |
| 6405 |
easy_altivec_constant (rtx op, machine_mode mode) |
| 6406 |
{ |
| 6407 |
unsigned step, copies; |
| 6408 |
|
| 6409 |
if (mode == VOIDmode) |
| 6410 |
mode = GET_MODE (op); |
| 6411 |
else if (mode != GET_MODE (op)) |
| 6412 |
return 0; |
| 6413 |
|
| 6414 |
/* V2DI/V2DF was added with VSX. Only allow 0 and all 1's as easy |
| 6415 |
constants. */ |
| 6416 |
if (mode == V2DFmode) |
| 6417 |
return zero_constant (op, mode) ? 8 : 0; |
| 6418 |
|
| 6419 |
else if (mode == V2DImode) |
| 6420 |
{ |
| 6421 |
if (!CONST_INT_P (CONST_VECTOR_ELT (op, 0)) |
| 6422 |
|| !CONST_INT_P (CONST_VECTOR_ELT (op, 1))) |
| 6423 |
return 0; |
| 6424 |
|
| 6425 |
if (zero_constant (op, mode)) |
| 6426 |
return 8; |
| 6427 |
|
| 6428 |
if (INTVAL (CONST_VECTOR_ELT (op, 0)) == -1 |
| 6429 |
&& INTVAL (CONST_VECTOR_ELT (op, 1)) == -1) |
| 6430 |
return 8; |
| 6431 |
|
| 6432 |
return 0; |
| 6433 |
} |
| 6434 |
|
| 6435 |
/* V1TImode is a special container for TImode. Ignore for now. */ |
| 6436 |
else if (mode == V1TImode) |
| 6437 |
return 0; |
| 6438 |
|
| 6439 |
/* Start with a vspltisw. */ |
| 6440 |
step = GET_MODE_NUNITS (mode) / 4; |
| 6441 |
copies = 1; |
| 6442 |
|
| 6443 |
if (vspltis_constant (op, step, copies)) |
| 6444 |
return 4; |
| 6445 |
|
| 6446 |
/* Then try with a vspltish. */ |
| 6447 |
if (step == 1) |
| 6448 |
copies <<= 1; |
| 6449 |
else |
| 6450 |
step >>= 1; |
| 6451 |
|
| 6452 |
if (vspltis_constant (op, step, copies)) |
| 6453 |
return 2; |
| 6454 |
|
| 6455 |
/* And finally a vspltisb. */ |
| 6456 |
if (step == 1) |
| 6457 |
copies <<= 1; |
| 6458 |
else |
| 6459 |
step >>= 1; |
| 6460 |
|
| 6461 |
if (vspltis_constant (op, step, copies)) |
| 6462 |
return 1; |
| 6463 |
|
| 6464 |
if (vspltis_shifted (op) != 0) |
| 6465 |
return GET_MODE_SIZE (GET_MODE_INNER (mode)); |
| 6466 |
|
| 6467 |
return 0; |
| 6468 |
} |
| 6469 |
|
| 6470 |
/* Generate a VEC_DUPLICATE representing a vspltis[bhw] instruction whose |
| 6471 |
result is OP. Abort if it is not possible. */ |
| 6472 |
|
| 6473 |
rtx |
| 6474 |
gen_easy_altivec_constant (rtx op) |
| 6475 |
{ |
| 6476 |
machine_mode mode = GET_MODE (op); |
| 6477 |
int nunits = GET_MODE_NUNITS (mode); |
| 6478 |
rtx val = CONST_VECTOR_ELT (op, BYTES_BIG_ENDIAN ? nunits - 1 : 0); |
| 6479 |
unsigned step = nunits / 4; |
| 6480 |
unsigned copies = 1; |
| 6481 |
|
| 6482 |
/* Start with a vspltisw. */ |
| 6483 |
if (vspltis_constant (op, step, copies)) |
| 6484 |
return gen_rtx_VEC_DUPLICATE (V4SImode, gen_lowpart (SImode, val)); |
| 6485 |
|
| 6486 |
/* Then try with a vspltish. */ |
| 6487 |
if (step == 1) |
| 6488 |
copies <<= 1; |
| 6489 |
else |
| 6490 |
step >>= 1; |
| 6491 |
|
| 6492 |
if (vspltis_constant (op, step, copies)) |
| 6493 |
return gen_rtx_VEC_DUPLICATE (V8HImode, gen_lowpart (HImode, val)); |
| 6494 |
|
| 6495 |
/* And finally a vspltisb. */ |
| 6496 |
if (step == 1) |
| 6497 |
copies <<= 1; |
| 6498 |
else |
| 6499 |
step >>= 1; |
| 6500 |
|
| 6501 |
if (vspltis_constant (op, step, copies)) |
| 6502 |
return gen_rtx_VEC_DUPLICATE (V16QImode, gen_lowpart (QImode, val)); |
| 6503 |
|
| 6504 |
gcc_unreachable (); |
| 6505 |
} |
| 6506 |
|
| 6507 |
/* Return true if OP is of the given MODE and can be synthesized with ISA 3.0 |
| 6508 |
instructions (xxspltib, vupkhsb/vextsb2w/vextb2d). |
| 6509 |
|
| 6510 |
Return the number of instructions needed (1 or 2) into the address pointed |
| 6511 |
via NUM_INSNS_PTR. |
| 6512 |
|
| 6513 |
Return the constant that is being split via CONSTANT_PTR. */ |
| 6514 |
|
| 6515 |
bool |
| 6516 |
xxspltib_constant_p (rtx op, |
| 6517 |
machine_mode mode, |
| 6518 |
int *num_insns_ptr, |
| 6519 |
int *constant_ptr) |
| 6520 |
{ |
| 6521 |
size_t nunits = GET_MODE_NUNITS (mode); |
| 6522 |
size_t i; |
| 6523 |
HOST_WIDE_INT value; |
| 6524 |
rtx element; |
| 6525 |
|
| 6526 |
/* Set the returned values to out of bound values. */ |
| 6527 |
*num_insns_ptr = -1; |
| 6528 |
*constant_ptr = 256; |
| 6529 |
|
| 6530 |
if (!TARGET_P9_VECTOR) |
| 6531 |
return false; |
| 6532 |
|
| 6533 |
if (mode == VOIDmode) |
| 6534 |
mode = GET_MODE (op); |
| 6535 |
|
| 6536 |
else if (mode != GET_MODE (op) && GET_MODE (op) != VOIDmode) |
| 6537 |
return false; |
| 6538 |
|
| 6539 |
/* Handle (vec_duplicate <constant>). */ |
| 6540 |
if (GET_CODE (op) == VEC_DUPLICATE) |
| 6541 |
{ |
| 6542 |
if (mode != V16QImode && mode != V8HImode && mode != V4SImode |
| 6543 |
&& mode != V2DImode) |
| 6544 |
return false; |
| 6545 |
|
| 6546 |
element = XEXP (op, 0); |
| 6547 |
if (!CONST_INT_P (element)) |
| 6548 |
return false; |
| 6549 |
|
| 6550 |
value = INTVAL (element); |
| 6551 |
if (!IN_RANGE (value, -128, 127)) |
| 6552 |
return false; |
| 6553 |
} |
| 6554 |
|
| 6555 |
/* Handle (const_vector [...]). */ |
| 6556 |
else if (GET_CODE (op) == CONST_VECTOR) |
| 6557 |
{ |
| 6558 |
if (mode != V16QImode && mode != V8HImode && mode != V4SImode |
| 6559 |
&& mode != V2DImode) |
| 6560 |
return false; |
| 6561 |
|
| 6562 |
element = CONST_VECTOR_ELT (op, 0); |
| 6563 |
if (!CONST_INT_P (element)) |
| 6564 |
return false; |
| 6565 |
|
| 6566 |
value = INTVAL (element); |
| 6567 |
if (!IN_RANGE (value, -128, 127)) |
| 6568 |
return false; |
| 6569 |
|
| 6570 |
for (i = 1; i < nunits; i++) |
| 6571 |
{ |
| 6572 |
element = CONST_VECTOR_ELT (op, i); |
| 6573 |
if (!CONST_INT_P (element)) |
| 6574 |
return false; |
| 6575 |
|
| 6576 |
if (value != INTVAL (element)) |
| 6577 |
return false; |
| 6578 |
} |
| 6579 |
} |
| 6580 |
|
| 6581 |
/* Handle integer constants being loaded into the upper part of the VSX |
| 6582 |
register as a scalar. If the value isn't 0/-1, only allow it if the mode |
| 6583 |
can go in Altivec registers. Prefer VSPLTISW/VUPKHSW over XXSPLITIB. */ |
| 6584 |
else if (CONST_INT_P (op)) |
| 6585 |
{ |
| 6586 |
if (!SCALAR_INT_MODE_P (mode)) |
| 6587 |
return false; |
| 6588 |
|
| 6589 |
value = INTVAL (op); |
| 6590 |
if (!IN_RANGE (value, -128, 127)) |
| 6591 |
return false; |
| 6592 |
|
| 6593 |
if (!IN_RANGE (value, -1, 0)) |
| 6594 |
{ |
| 6595 |
if (!(reg_addr[mode].addr_mask[RELOAD_REG_VMX] & RELOAD_REG_VALID)) |
| 6596 |
return false; |
| 6597 |
|
| 6598 |
if (EASY_VECTOR_15 (value)) |
| 6599 |
return false; |
| 6600 |
} |
| 6601 |
} |
| 6602 |
|
| 6603 |
else |
| 6604 |
return false; |
| 6605 |
|
| 6606 |
/* See if we could generate vspltisw/vspltish directly instead of xxspltib + |
| 6607 |
sign extend. Special case 0/-1 to allow getting any VSX register instead |
| 6608 |
of an Altivec register. */ |
| 6609 |
if ((mode == V4SImode || mode == V8HImode) && !IN_RANGE (value, -1, 0) |
| 6610 |
&& EASY_VECTOR_15 (value)) |
| 6611 |
return false; |
| 6612 |
|
| 6613 |
/* Return # of instructions and the constant byte for XXSPLTIB. */ |
| 6614 |
if (mode == V16QImode) |
| 6615 |
*num_insns_ptr = 1; |
| 6616 |
|
| 6617 |
else if (IN_RANGE (value, -1, 0)) |
| 6618 |
*num_insns_ptr = 1; |
| 6619 |
|
| 6620 |
/* Do not generate XXSPLTIB and a sign extend operation if we can generate a |
| 6621 |
single XXSPLTIW or XXSPLTIDP instruction. */ |
| 6622 |
else if (vsx_prefixed_constant (op, mode)) |
| 6623 |
return false; |
| 6624 |
|
| 6625 |
/* Return XXSPLITB followed by a sign extend operation to convert the |
| 6626 |
constant to V8HImode or V4SImode. */ |
| 6627 |
else |
| 6628 |
*num_insns_ptr = 2; |
| 6629 |
|
| 6630 |
*constant_ptr = (int) value; |
| 6631 |
return true; |
| 6632 |
} |
| 6633 |
|
| 6634 |
/* Return true if OP mode is V2DI and can be synthesized with ISA 2.07 |
| 6635 |
instructions vupkhsw and vspltisw. |
| 6636 |
|
| 6637 |
Return the constant that is being split via CONSTANT_PTR. */ |
| 6638 |
|
| 6639 |
bool |
| 6640 |
vspltisw_vupkhsw_constant_p (rtx op, machine_mode mode, int *constant_ptr) |
| 6641 |
{ |
| 6642 |
HOST_WIDE_INT value; |
| 6643 |
rtx elt; |
| 6644 |
|
| 6645 |
if (!TARGET_P8_VECTOR) |
| 6646 |
return false; |
| 6647 |
|
| 6648 |
if (mode != V2DImode) |
| 6649 |
return false; |
| 6650 |
|
| 6651 |
if (!const_vec_duplicate_p (op, &elt)) |
| 6652 |
return false; |
| 6653 |
|
| 6654 |
value = INTVAL (elt); |
| 6655 |
if (value == 0 || value == 1 |
| 6656 |
|| !EASY_VECTOR_15 (value)) |
| 6657 |
return false; |
| 6658 |
|
| 6659 |
if (constant_ptr) |
| 6660 |
*constant_ptr = (int) value; |
| 6661 |
return true; |
| 6662 |
} |
| 6663 |
|
| 6664 |
const char * |
| 6665 |
output_vec_const_move (rtx *operands) |
| 6666 |
{ |
| 6667 |
int shift; |
| 6668 |
machine_mode mode; |
| 6669 |
rtx dest, vec; |
| 6670 |
|
| 6671 |
dest = operands[0]; |
| 6672 |
vec = operands[1]; |
| 6673 |
mode = GET_MODE (dest); |
| 6674 |
|
| 6675 |
if (TARGET_VSX) |
| 6676 |
{ |
| 6677 |
bool dest_vmx_p = ALTIVEC_REGNO_P (REGNO (dest)); |
| 6678 |
int xxspltib_value = 256; |
| 6679 |
int num_insns = -1; |
| 6680 |
|
| 6681 |
if (zero_constant (vec, mode)) |
| 6682 |
{ |
| 6683 |
if (TARGET_P9_VECTOR) |
| 6684 |
return "xxspltib %x0,0"; |
| 6685 |
|
| 6686 |
else if (dest_vmx_p) |
| 6687 |
return "vspltisw %0,0"; |
| 6688 |
|
| 6689 |
else |
| 6690 |
return "xxlxor %x0,%x0,%x0"; |
| 6691 |
} |
| 6692 |
|
| 6693 |
if (all_ones_constant (vec, mode)) |
| 6694 |
{ |
| 6695 |
if (TARGET_P9_VECTOR) |
| 6696 |
return "xxspltib %x0,255"; |
| 6697 |
|
| 6698 |
else if (dest_vmx_p) |
| 6699 |
return "vspltisw %0,-1"; |
| 6700 |
|
| 6701 |
else if (TARGET_P8_VECTOR) |
| 6702 |
return "xxlorc %x0,%x0,%x0"; |
| 6703 |
|
| 6704 |
else |
| 6705 |
gcc_unreachable (); |
| 6706 |
} |
| 6707 |
|
| 6708 |
vec_const_128bit_type vsx_const; |
| 6709 |
if (TARGET_POWER10 && vec_const_128bit_to_bytes (vec, mode, &vsx_const)) |
| 6710 |
{ |
| 6711 |
unsigned imm = constant_generates_lxvkq (&vsx_const); |
| 6712 |
if (imm) |
| 6713 |
{ |
| 6714 |
operands[2] = GEN_INT (imm); |
| 6715 |
return "lxvkq %x0,%2"; |
| 6716 |
} |
| 6717 |
|
| 6718 |
imm = constant_generates_xxspltiw (&vsx_const); |
| 6719 |
if (imm) |
| 6720 |
{ |
| 6721 |
operands[2] = GEN_INT (imm); |
| 6722 |
return "xxspltiw %x0,%2"; |
| 6723 |
} |
| 6724 |
|
| 6725 |
imm = constant_generates_xxspltidp (&vsx_const); |
| 6726 |
if (imm) |
| 6727 |
{ |
| 6728 |
operands[2] = GEN_INT (imm); |
| 6729 |
return "xxspltidp %x0,%2"; |
| 6730 |
} |
| 6731 |
} |
| 6732 |
|
| 6733 |
if (TARGET_P9_VECTOR |
| 6734 |
&& xxspltib_constant_p (vec, mode, &num_insns, &xxspltib_value)) |
| 6735 |
{ |
| 6736 |
if (num_insns == 1) |
| 6737 |
{ |
| 6738 |
operands[2] = GEN_INT (xxspltib_value & 0xff); |
| 6739 |
return "xxspltib %x0,%2"; |
| 6740 |
} |
| 6741 |
|
| 6742 |
return "#"; |
| 6743 |
} |
| 6744 |
} |
| 6745 |
|
| 6746 |
if (TARGET_ALTIVEC) |
| 6747 |
{ |
| 6748 |
rtx splat_vec; |
| 6749 |
|
| 6750 |
gcc_assert (ALTIVEC_REGNO_P (REGNO (dest))); |
| 6751 |
if (zero_constant (vec, mode)) |
| 6752 |
return "vspltisw %0,0"; |
| 6753 |
|
| 6754 |
if (all_ones_constant (vec, mode)) |
| 6755 |
return "vspltisw %0,-1"; |
| 6756 |
|
| 6757 |
/* Do we need to construct a value using VSLDOI? */ |
| 6758 |
shift = vspltis_shifted (vec); |
| 6759 |
if (shift != 0) |
| 6760 |
return "#"; |
| 6761 |
|
| 6762 |
splat_vec = gen_easy_altivec_constant (vec); |
| 6763 |
gcc_assert (GET_CODE (splat_vec) == VEC_DUPLICATE); |
| 6764 |
operands[1] = XEXP (splat_vec, 0); |
| 6765 |
if (!EASY_VECTOR_15 (INTVAL (operands[1]))) |
| 6766 |
return "#"; |
| 6767 |
|
| 6768 |
switch (GET_MODE (splat_vec)) |
| 6769 |
{ |
| 6770 |
case E_V4SImode: |
| 6771 |
return "vspltisw %0,%1"; |
| 6772 |
|
| 6773 |
case E_V8HImode: |
| 6774 |
return "vspltish %0,%1"; |
| 6775 |
|
| 6776 |
case E_V16QImode: |
| 6777 |
return "vspltisb %0,%1"; |
| 6778 |
|
| 6779 |
default: |
| 6780 |
gcc_unreachable (); |
| 6781 |
} |
| 6782 |
} |
| 6783 |
|
| 6784 |
gcc_unreachable (); |
| 6785 |
} |
| 6786 |
|
| 6787 |
/* Initialize vector TARGET to VALS. */ |
| 6788 |
|
| 6789 |
void |
| 6790 |
rs6000_expand_vector_init (rtx target, rtx vals) |
| 6791 |
{ |
| 6792 |
machine_mode mode = GET_MODE (target); |
| 6793 |
machine_mode inner_mode = GET_MODE_INNER (mode); |
| 6794 |
unsigned int n_elts = GET_MODE_NUNITS (mode); |
| 6795 |
int n_var = 0, one_var = -1; |
| 6796 |
bool all_same = true, all_const_zero = true; |
| 6797 |
rtx x, mem; |
| 6798 |
unsigned int i; |
| 6799 |
|
| 6800 |
for (i = 0; i < n_elts; ++i) |
| 6801 |
{ |
| 6802 |
x = XVECEXP (vals, 0, i); |
| 6803 |
if (!(CONST_SCALAR_INT_P (x) || CONST_DOUBLE_P (x) || CONST_FIXED_P (x))) |
| 6804 |
++n_var, one_var = i; |
| 6805 |
else if (x != CONST0_RTX (inner_mode)) |
| 6806 |
all_const_zero = false; |
| 6807 |
|
| 6808 |
if (i > 0 && !rtx_equal_p (x, XVECEXP (vals, 0, 0))) |
| 6809 |
all_same = false; |
| 6810 |
} |
| 6811 |
|
| 6812 |
if (n_var == 0) |
| 6813 |
{ |
| 6814 |
rtx const_vec = gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)); |
| 6815 |
bool int_vector_p = (GET_MODE_CLASS (mode) == MODE_VECTOR_INT); |
| 6816 |
if ((int_vector_p || TARGET_VSX) && all_const_zero) |
| 6817 |
{ |
| 6818 |
/* Zero register. */ |
| 6819 |
emit_move_insn (target, CONST0_RTX (mode)); |
| 6820 |
return; |
| 6821 |
} |
| 6822 |
else if (int_vector_p && easy_vector_constant (const_vec, mode)) |
| 6823 |
{ |
| 6824 |
/* Splat immediate. */ |
| 6825 |
emit_insn (gen_rtx_SET (target, const_vec)); |
| 6826 |
return; |
| 6827 |
} |
| 6828 |
else |
| 6829 |
{ |
| 6830 |
/* Load from constant pool. */ |
| 6831 |
emit_move_insn (target, const_vec); |
| 6832 |
return; |
| 6833 |
} |
| 6834 |
} |
| 6835 |
|
| 6836 |
/* Double word values on VSX can use xxpermdi or lxvdsx. */ |
| 6837 |
if (VECTOR_MEM_VSX_P (mode) && (mode == V2DFmode || mode == V2DImode)) |
| 6838 |
{ |
| 6839 |
rtx op[2]; |
| 6840 |
size_t i; |
| 6841 |
size_t num_elements = all_same ? 1 : 2; |
| 6842 |
for (i = 0; i < num_elements; i++) |
| 6843 |
{ |
| 6844 |
op[i] = XVECEXP (vals, 0, i); |
| 6845 |
/* Just in case there is a SUBREG with a smaller mode, do a |
| 6846 |
conversion. */ |
| 6847 |
if (GET_MODE (op[i]) != inner_mode) |
| 6848 |
{ |
| 6849 |
rtx tmp = gen_reg_rtx (inner_mode); |
| 6850 |
convert_move (tmp, op[i], 0); |
| 6851 |
op[i] = tmp; |
| 6852 |
} |
| 6853 |
/* Allow load with splat double word. */ |
| 6854 |
else if (MEM_P (op[i])) |
| 6855 |
{ |
| 6856 |
if (!all_same) |
| 6857 |
op[i] = force_reg (inner_mode, op[i]); |
| 6858 |
} |
| 6859 |
else if (!REG_P (op[i])) |
| 6860 |
op[i] = force_reg (inner_mode, op[i]); |
| 6861 |
} |
| 6862 |
|
| 6863 |
if (all_same) |
| 6864 |
{ |
| 6865 |
if (mode == V2DFmode) |
| 6866 |
emit_insn (gen_vsx_splat_v2df (target, op[0])); |
| 6867 |
else |
| 6868 |
emit_insn (gen_vsx_splat_v2di (target, op[0])); |
| 6869 |
} |
| 6870 |
else |
| 6871 |
{ |
| 6872 |
if (mode == V2DFmode) |
| 6873 |
emit_insn (gen_vsx_concat_v2df (target, op[0], op[1])); |
| 6874 |
else |
| 6875 |
emit_insn (gen_vsx_concat_v2di (target, op[0], op[1])); |
| 6876 |
} |
| 6877 |
return; |
| 6878 |
} |
| 6879 |
|
| 6880 |
/* Special case initializing vector int if we are on 64-bit systems with |
| 6881 |
direct move or we have the ISA 3.0 instructions. */ |
| 6882 |
if (mode == V4SImode && VECTOR_MEM_VSX_P (V4SImode) |
| 6883 |
&& TARGET_DIRECT_MOVE_64BIT) |
| 6884 |
{ |
| 6885 |
if (all_same) |
| 6886 |
{ |
| 6887 |
rtx element0 = XVECEXP (vals, 0, 0); |
| 6888 |
if (MEM_P (element0)) |
| 6889 |
element0 = rs6000_force_indexed_or_indirect_mem (element0); |
| 6890 |
else |
| 6891 |
element0 = force_reg (SImode, element0); |
| 6892 |
|
| 6893 |
if (TARGET_P9_VECTOR) |
| 6894 |
emit_insn (gen_vsx_splat_v4si (target, element0)); |
| 6895 |
else |
| 6896 |
{ |
| 6897 |
rtx tmp = gen_reg_rtx (DImode); |
| 6898 |
emit_insn (gen_zero_extendsidi2 (tmp, element0)); |
| 6899 |
emit_insn (gen_vsx_splat_v4si_di (target, tmp)); |
| 6900 |
} |
| 6901 |
return; |
| 6902 |
} |
| 6903 |
else |
| 6904 |
{ |
| 6905 |
rtx elements[4]; |
| 6906 |
size_t i; |
| 6907 |
|
| 6908 |
for (i = 0; i < 4; i++) |
| 6909 |
elements[i] = force_reg (SImode, XVECEXP (vals, 0, i)); |
| 6910 |
|
| 6911 |
emit_insn (gen_vsx_init_v4si (target, elements[0], elements[1], |
| 6912 |
elements[2], elements[3])); |
| 6913 |
return; |
| 6914 |
} |
| 6915 |
} |
| 6916 |
|
| 6917 |
/* With single precision floating point on VSX, know that internally single |
| 6918 |
precision is actually represented as a double, and either make 2 V2DF |
| 6919 |
vectors, and convert these vectors to single precision, or do one |
| 6920 |
conversion, and splat the result to the other elements. */ |
| 6921 |
if (mode == V4SFmode && VECTOR_MEM_VSX_P (V4SFmode)) |
| 6922 |
{ |
| 6923 |
if (all_same) |
| 6924 |
{ |
| 6925 |
rtx element0 = XVECEXP (vals, 0, 0); |
| 6926 |
|
| 6927 |
if (TARGET_P9_VECTOR) |
| 6928 |
{ |
| 6929 |
if (MEM_P (element0)) |
| 6930 |
element0 = rs6000_force_indexed_or_indirect_mem (element0); |
| 6931 |
|
| 6932 |
emit_insn (gen_vsx_splat_v4sf (target, element0)); |
| 6933 |
} |
| 6934 |
|
| 6935 |
else |
| 6936 |
{ |
| 6937 |
rtx freg = gen_reg_rtx (V4SFmode); |
| 6938 |
rtx sreg = force_reg (SFmode, element0); |
| 6939 |
rtx cvt = (TARGET_XSCVDPSPN |
| 6940 |
? gen_vsx_xscvdpspn_scalar (freg, sreg) |
| 6941 |
: gen_vsx_xscvdpsp_scalar (freg, sreg)); |
| 6942 |
|
| 6943 |
emit_insn (cvt); |
| 6944 |
emit_insn (gen_vsx_xxspltw_v4sf_direct (target, freg, |
| 6945 |
const0_rtx)); |
| 6946 |
} |
| 6947 |
} |
| 6948 |
else |
| 6949 |
{ |
| 6950 |
if (TARGET_P8_VECTOR && TARGET_POWERPC64) |
| 6951 |
{ |
| 6952 |
rtx tmp_sf[4]; |
| 6953 |
rtx tmp_si[4]; |
| 6954 |
rtx tmp_di[4]; |
| 6955 |
rtx mrg_di[4]; |
| 6956 |
for (i = 0; i < 4; i++) |
| 6957 |
{ |
| 6958 |
tmp_si[i] = gen_reg_rtx (SImode); |
| 6959 |
tmp_di[i] = gen_reg_rtx (DImode); |
| 6960 |
mrg_di[i] = gen_reg_rtx (DImode); |
| 6961 |
tmp_sf[i] = force_reg (SFmode, XVECEXP (vals, 0, i)); |
| 6962 |
emit_insn (gen_movsi_from_sf (tmp_si[i], tmp_sf[i])); |
| 6963 |
emit_insn (gen_zero_extendsidi2 (tmp_di[i], tmp_si[i])); |
| 6964 |
} |
| 6965 |
|
| 6966 |
if (!BYTES_BIG_ENDIAN) |
| 6967 |
{ |
| 6968 |
std::swap (tmp_di[0], tmp_di[1]); |
| 6969 |
std::swap (tmp_di[2], tmp_di[3]); |
| 6970 |
} |
| 6971 |
|
| 6972 |
emit_insn (gen_ashldi3 (mrg_di[0], tmp_di[0], GEN_INT (32))); |
| 6973 |
emit_insn (gen_iordi3 (mrg_di[1], mrg_di[0], tmp_di[1])); |
| 6974 |
emit_insn (gen_ashldi3 (mrg_di[2], tmp_di[2], GEN_INT (32))); |
| 6975 |
emit_insn (gen_iordi3 (mrg_di[3], mrg_di[2], tmp_di[3])); |
| 6976 |
|
| 6977 |
rtx tmp_v2di = gen_reg_rtx (V2DImode); |
| 6978 |
emit_insn (gen_vsx_concat_v2di (tmp_v2di, mrg_di[1], mrg_di[3])); |
| 6979 |
emit_move_insn (target, gen_lowpart (V4SFmode, tmp_v2di)); |
| 6980 |
} |
| 6981 |
else |
| 6982 |
{ |
| 6983 |
rtx dbl_even = gen_reg_rtx (V2DFmode); |
| 6984 |
rtx dbl_odd = gen_reg_rtx (V2DFmode); |
| 6985 |
rtx flt_even = gen_reg_rtx (V4SFmode); |
| 6986 |
rtx flt_odd = gen_reg_rtx (V4SFmode); |
| 6987 |
rtx op0 = force_reg (SFmode, XVECEXP (vals, 0, 0)); |
| 6988 |
rtx op1 = force_reg (SFmode, XVECEXP (vals, 0, 1)); |
| 6989 |
rtx op2 = force_reg (SFmode, XVECEXP (vals, 0, 2)); |
| 6990 |
rtx op3 = force_reg (SFmode, XVECEXP (vals, 0, 3)); |
| 6991 |
|
| 6992 |
emit_insn (gen_vsx_concat_v2sf (dbl_even, op0, op1)); |
| 6993 |
emit_insn (gen_vsx_concat_v2sf (dbl_odd, op2, op3)); |
| 6994 |
emit_insn (gen_vsx_xvcvdpsp (flt_even, dbl_even)); |
| 6995 |
emit_insn (gen_vsx_xvcvdpsp (flt_odd, dbl_odd)); |
| 6996 |
rs6000_expand_extract_even (target, flt_even, flt_odd); |
| 6997 |
} |
| 6998 |
} |
| 6999 |
return; |
| 7000 |
} |
| 7001 |
|
| 7002 |
/* Special case initializing vector short/char that are splats if we are on |
| 7003 |
64-bit systems with direct move. */ |
| 7004 |
if (all_same && TARGET_DIRECT_MOVE_64BIT |
| 7005 |
&& (mode == V16QImode || mode == V8HImode)) |
| 7006 |
{ |
| 7007 |
rtx op0 = XVECEXP (vals, 0, 0); |
| 7008 |
rtx di_tmp = gen_reg_rtx (DImode); |
| 7009 |
|
| 7010 |
if (!REG_P (op0)) |
| 7011 |
op0 = force_reg (GET_MODE_INNER (mode), op0); |
| 7012 |
|
| 7013 |
if (mode == V16QImode) |
| 7014 |
{ |
| 7015 |
emit_insn (gen_zero_extendqidi2 (di_tmp, op0)); |
| 7016 |
emit_insn (gen_vsx_vspltb_di (target, di_tmp)); |
| 7017 |
return; |
| 7018 |
} |
| 7019 |
|
| 7020 |
if (mode == V8HImode) |
| 7021 |
{ |
| 7022 |
emit_insn (gen_zero_extendhidi2 (di_tmp, op0)); |
| 7023 |
emit_insn (gen_vsx_vsplth_di (target, di_tmp)); |
| 7024 |
return; |
| 7025 |
} |
| 7026 |
} |
| 7027 |
|
| 7028 |
/* Store value to stack temp. Load vector element. Splat. However, splat |
| 7029 |
of 64-bit items is not supported on Altivec. */ |
| 7030 |
if (all_same && GET_MODE_SIZE (inner_mode) <= 4) |
| 7031 |
{ |
| 7032 |
mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode)); |
| 7033 |
emit_move_insn (adjust_address_nv (mem, inner_mode, 0), |
| 7034 |
XVECEXP (vals, 0, 0)); |
| 7035 |
x = gen_rtx_UNSPEC (VOIDmode, |
| 7036 |
gen_rtvec (1, const0_rtx), UNSPEC_LVE); |
| 7037 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, |
| 7038 |
gen_rtvec (2, |
| 7039 |
gen_rtx_SET (target, mem), |
| 7040 |
x))); |
| 7041 |
x = gen_rtx_VEC_SELECT (inner_mode, target, |
| 7042 |
gen_rtx_PARALLEL (VOIDmode, |
| 7043 |
gen_rtvec (1, const0_rtx))); |
| 7044 |
emit_insn (gen_rtx_SET (target, gen_rtx_VEC_DUPLICATE (mode, x))); |
| 7045 |
return; |
| 7046 |
} |
| 7047 |
|
| 7048 |
/* One field is non-constant. Load constant then overwrite |
| 7049 |
varying field. */ |
| 7050 |
if (n_var == 1) |
| 7051 |
{ |
| 7052 |
rtx copy = copy_rtx (vals); |
| 7053 |
|
| 7054 |
/* Load constant part of vector, substitute neighboring value for |
| 7055 |
varying element. */ |
| 7056 |
XVECEXP (copy, 0, one_var) = XVECEXP (vals, 0, (one_var + 1) % n_elts); |
| 7057 |
rs6000_expand_vector_init (target, copy); |
| 7058 |
|
| 7059 |
/* Insert variable. */ |
| 7060 |
rs6000_expand_vector_set (target, XVECEXP (vals, 0, one_var), |
| 7061 |
GEN_INT (one_var)); |
| 7062 |
return; |
| 7063 |
} |
| 7064 |
|
| 7065 |
if (TARGET_DIRECT_MOVE && (mode == V16QImode || mode == V8HImode)) |
| 7066 |
{ |
| 7067 |
rtx op[16]; |
| 7068 |
/* Force the values into word_mode registers. */ |
| 7069 |
for (i = 0; i < n_elts; i++) |
| 7070 |
{ |
| 7071 |
rtx tmp = force_reg (inner_mode, XVECEXP (vals, 0, i)); |
| 7072 |
machine_mode tmode = TARGET_POWERPC64 ? DImode : SImode; |
| 7073 |
op[i] = simplify_gen_subreg (tmode, tmp, inner_mode, 0); |
| 7074 |
} |
| 7075 |
|
| 7076 |
/* Take unsigned char big endianness on 64bit as example for below |
| 7077 |
construction, the input values are: A, B, C, D, ..., O, P. */ |
| 7078 |
|
| 7079 |
if (TARGET_DIRECT_MOVE_128) |
| 7080 |
{ |
| 7081 |
/* Move to VSX register with vec_concat, each has 2 values. |
| 7082 |
eg: vr1[0] = { xxxxxxxA, xxxxxxxB }; |
| 7083 |
vr1[1] = { xxxxxxxC, xxxxxxxD }; |
| 7084 |
... |
| 7085 |
vr1[7] = { xxxxxxxO, xxxxxxxP }; */ |
| 7086 |
rtx vr1[8]; |
| 7087 |
for (i = 0; i < n_elts / 2; i++) |
| 7088 |
{ |
| 7089 |
vr1[i] = gen_reg_rtx (V2DImode); |
| 7090 |
emit_insn (gen_vsx_concat_v2di (vr1[i], op[i * 2], |
| 7091 |
op[i * 2 + 1])); |
| 7092 |
} |
| 7093 |
|
| 7094 |
/* Pack vectors with 2 values into vectors with 4 values. |
| 7095 |
eg: vr2[0] = { xxxAxxxB, xxxCxxxD }; |
| 7096 |
vr2[1] = { xxxExxxF, xxxGxxxH }; |
| 7097 |
vr2[1] = { xxxIxxxJ, xxxKxxxL }; |
| 7098 |
vr2[3] = { xxxMxxxN, xxxOxxxP }; */ |
| 7099 |
rtx vr2[4]; |
| 7100 |
for (i = 0; i < n_elts / 4; i++) |
| 7101 |
{ |
| 7102 |
vr2[i] = gen_reg_rtx (V4SImode); |
| 7103 |
emit_insn (gen_altivec_vpkudum (vr2[i], vr1[i * 2], |
| 7104 |
vr1[i * 2 + 1])); |
| 7105 |
} |
| 7106 |
|
| 7107 |
/* Pack vectors with 4 values into vectors with 8 values. |
| 7108 |
eg: vr3[0] = { xAxBxCxD, xExFxGxH }; |
| 7109 |
vr3[1] = { xIxJxKxL, xMxNxOxP }; */ |
| 7110 |
rtx vr3[2]; |
| 7111 |
for (i = 0; i < n_elts / 8; i++) |
| 7112 |
{ |
| 7113 |
vr3[i] = gen_reg_rtx (V8HImode); |
| 7114 |
emit_insn (gen_altivec_vpkuwum (vr3[i], vr2[i * 2], |
| 7115 |
vr2[i * 2 + 1])); |
| 7116 |
} |
| 7117 |
|
| 7118 |
/* If it's V8HImode, it's done and return it. */ |
| 7119 |
if (mode == V8HImode) |
| 7120 |
{ |
| 7121 |
emit_insn (gen_rtx_SET (target, vr3[0])); |
| 7122 |
return; |
| 7123 |
} |
| 7124 |
|
| 7125 |
/* Pack vectors with 8 values into 16 values. */ |
| 7126 |
rtx res = gen_reg_rtx (V16QImode); |
| 7127 |
emit_insn (gen_altivec_vpkuhum (res, vr3[0], vr3[1])); |
| 7128 |
emit_insn (gen_rtx_SET (target, res)); |
| 7129 |
} |
| 7130 |
else |
| 7131 |
{ |
| 7132 |
rtx (*merge_v16qi) (rtx, rtx, rtx) = NULL; |
| 7133 |
rtx (*merge_v8hi) (rtx, rtx, rtx) = NULL; |
| 7134 |
rtx (*merge_v4si) (rtx, rtx, rtx) = NULL; |
| 7135 |
rtx perm_idx; |
| 7136 |
|
| 7137 |
/* Set up some common gen routines and values. */ |
| 7138 |
if (BYTES_BIG_ENDIAN) |
| 7139 |
{ |
| 7140 |
if (mode == V16QImode) |
| 7141 |
{ |
| 7142 |
merge_v16qi = gen_altivec_vmrghb; |
| 7143 |
merge_v8hi = gen_altivec_vmrglh; |
| 7144 |
} |
| 7145 |
else |
| 7146 |
merge_v8hi = gen_altivec_vmrghh; |
| 7147 |
|
| 7148 |
merge_v4si = gen_altivec_vmrglw; |
| 7149 |
perm_idx = GEN_INT (3); |
| 7150 |
} |
| 7151 |
else |
| 7152 |
{ |
| 7153 |
if (mode == V16QImode) |
| 7154 |
{ |
| 7155 |
merge_v16qi = gen_altivec_vmrglb; |
| 7156 |
merge_v8hi = gen_altivec_vmrghh; |
| 7157 |
} |
| 7158 |
else |
| 7159 |
merge_v8hi = gen_altivec_vmrglh; |
| 7160 |
|
| 7161 |
merge_v4si = gen_altivec_vmrghw; |
| 7162 |
perm_idx = GEN_INT (0); |
| 7163 |
} |
| 7164 |
|
| 7165 |
/* Move to VSX register with direct move. |
| 7166 |
eg: vr_qi[0] = { xxxxxxxA, xxxxxxxx }; |
| 7167 |
vr_qi[1] = { xxxxxxxB, xxxxxxxx }; |
| 7168 |
... |
| 7169 |
vr_qi[15] = { xxxxxxxP, xxxxxxxx }; */ |
| 7170 |
rtx vr_qi[16]; |
| 7171 |
for (i = 0; i < n_elts; i++) |
| 7172 |
{ |
| 7173 |
vr_qi[i] = gen_reg_rtx (V16QImode); |
| 7174 |
if (TARGET_POWERPC64) |
| 7175 |
emit_insn (gen_p8_mtvsrd_v16qidi2 (vr_qi[i], op[i])); |
| 7176 |
else |
| 7177 |
emit_insn (gen_p8_mtvsrwz_v16qisi2 (vr_qi[i], op[i])); |
| 7178 |
} |
| 7179 |
|
| 7180 |
/* Merge/move to vector short. |
| 7181 |
eg: vr_hi[0] = { xxxxxxxx, xxxxxxAB }; |
| 7182 |
vr_hi[1] = { xxxxxxxx, xxxxxxCD }; |
| 7183 |
... |
| 7184 |
vr_hi[7] = { xxxxxxxx, xxxxxxOP }; */ |
| 7185 |
rtx vr_hi[8]; |
| 7186 |
for (i = 0; i < 8; i++) |
| 7187 |
{ |
| 7188 |
rtx tmp = vr_qi[i]; |
| 7189 |
if (mode == V16QImode) |
| 7190 |
{ |
| 7191 |
tmp = gen_reg_rtx (V16QImode); |
| 7192 |
emit_insn (merge_v16qi (tmp, vr_qi[2 * i], vr_qi[2 * i + 1])); |
| 7193 |
} |
| 7194 |
vr_hi[i] = gen_reg_rtx (V8HImode); |
| 7195 |
emit_move_insn (vr_hi[i], gen_lowpart (V8HImode, tmp)); |
| 7196 |
} |
| 7197 |
|
| 7198 |
/* Merge vector short to vector int. |
| 7199 |
eg: vr_si[0] = { xxxxxxxx, xxxxABCD }; |
| 7200 |
vr_si[1] = { xxxxxxxx, xxxxEFGH }; |
| 7201 |
... |
| 7202 |
vr_si[3] = { xxxxxxxx, xxxxMNOP }; */ |
| 7203 |
rtx vr_si[4]; |
| 7204 |
for (i = 0; i < 4; i++) |
| 7205 |
{ |
| 7206 |
rtx tmp = gen_reg_rtx (V8HImode); |
| 7207 |
emit_insn (merge_v8hi (tmp, vr_hi[2 * i], vr_hi[2 * i + 1])); |
| 7208 |
vr_si[i] = gen_reg_rtx (V4SImode); |
| 7209 |
emit_move_insn (vr_si[i], gen_lowpart (V4SImode, tmp)); |
| 7210 |
} |
| 7211 |
|
| 7212 |
/* Merge vector int to vector long. |
| 7213 |
eg: vr_di[0] = { xxxxxxxx, ABCDEFGH }; |
| 7214 |
vr_di[1] = { xxxxxxxx, IJKLMNOP }; */ |
| 7215 |
rtx vr_di[2]; |
| 7216 |
for (i = 0; i < 2; i++) |
| 7217 |
{ |
| 7218 |
rtx tmp = gen_reg_rtx (V4SImode); |
| 7219 |
emit_insn (merge_v4si (tmp, vr_si[2 * i], vr_si[2 * i + 1])); |
| 7220 |
vr_di[i] = gen_reg_rtx (V2DImode); |
| 7221 |
emit_move_insn (vr_di[i], gen_lowpart (V2DImode, tmp)); |
| 7222 |
} |
| 7223 |
|
| 7224 |
rtx res = gen_reg_rtx (V2DImode); |
| 7225 |
emit_insn (gen_vsx_xxpermdi_v2di (res, vr_di[0], vr_di[1], perm_idx)); |
| 7226 |
emit_insn (gen_rtx_SET (target, gen_lowpart (mode, res))); |
| 7227 |
} |
| 7228 |
|
| 7229 |
return; |
| 7230 |
} |
| 7231 |
|
| 7232 |
/* Construct the vector in memory one field at a time |
| 7233 |
and load the whole vector. */ |
| 7234 |
mem = assign_stack_temp (mode, GET_MODE_SIZE (mode)); |
| 7235 |
for (i = 0; i < n_elts; i++) |
| 7236 |
emit_move_insn (adjust_address_nv (mem, inner_mode, |
| 7237 |
i * GET_MODE_SIZE (inner_mode)), |
| 7238 |
XVECEXP (vals, 0, i)); |
| 7239 |
emit_move_insn (target, mem); |
| 7240 |
} |
| 7241 |
|
| 7242 |
/* Insert VAL into IDX of TARGET, VAL size is same of the vector element, IDX |
| 7243 |
is variable and also counts by vector element size for p9 and above. */ |
| 7244 |
|
| 7245 |
static void |
| 7246 |
rs6000_expand_vector_set_var_p9 (rtx target, rtx val, rtx idx) |
| 7247 |
{ |
| 7248 |
machine_mode mode = GET_MODE (target); |
| 7249 |
|
| 7250 |
gcc_assert (VECTOR_MEM_VSX_P (mode) && !CONST_INT_P (idx)); |
| 7251 |
|
| 7252 |
machine_mode inner_mode = GET_MODE (val); |
| 7253 |
|
| 7254 |
int width = GET_MODE_SIZE (inner_mode); |
| 7255 |
|
| 7256 |
gcc_assert (width >= 1 && width <= 8); |
| 7257 |
|
| 7258 |
int shift = exact_log2 (width); |
| 7259 |
|
| 7260 |
machine_mode idx_mode = GET_MODE (idx); |
| 7261 |
|
| 7262 |
machine_mode shift_mode; |
| 7263 |
/* Gen function pointers for shifting left and generation of permutation |
| 7264 |
control vectors. */ |
| 7265 |
rtx (*gen_ashl) (rtx, rtx, rtx); |
| 7266 |
rtx (*gen_pcvr1) (rtx, rtx); |
| 7267 |
rtx (*gen_pcvr2) (rtx, rtx); |
| 7268 |
|
| 7269 |
if (TARGET_POWERPC64) |
| 7270 |
{ |
| 7271 |
shift_mode = DImode; |
| 7272 |
gen_ashl = gen_ashldi3; |
| 7273 |
gen_pcvr1 = BYTES_BIG_ENDIAN ? gen_altivec_lvsl_reg_di |
| 7274 |
: gen_altivec_lvsr_reg_di; |
| 7275 |
gen_pcvr2 = BYTES_BIG_ENDIAN ? gen_altivec_lvsr_reg_di |
| 7276 |
: gen_altivec_lvsl_reg_di; |
| 7277 |
} |
| 7278 |
else |
| 7279 |
{ |
| 7280 |
shift_mode = SImode; |
| 7281 |
gen_ashl = gen_ashlsi3; |
| 7282 |
gen_pcvr1 = BYTES_BIG_ENDIAN ? gen_altivec_lvsl_reg_si |
| 7283 |
: gen_altivec_lvsr_reg_si; |
| 7284 |
gen_pcvr2 = BYTES_BIG_ENDIAN ? gen_altivec_lvsr_reg_si |
| 7285 |
: gen_altivec_lvsl_reg_si; |
| 7286 |
} |
| 7287 |
/* Generate the IDX for permute shift, width is the vector element size. |
| 7288 |
idx = idx * width. */ |
| 7289 |
rtx tmp = gen_reg_rtx (shift_mode); |
| 7290 |
idx = convert_modes (shift_mode, idx_mode, idx, 1); |
| 7291 |
|
| 7292 |
emit_insn (gen_ashl (tmp, idx, GEN_INT (shift))); |
| 7293 |
|
| 7294 |
/* Generate one permutation control vector used for rotating the element |
| 7295 |
at to-insert position to element zero in target vector. lvsl is |
| 7296 |
used for big endianness while lvsr is used for little endianness: |
| 7297 |
lvs[lr] v1,0,idx. */ |
| 7298 |
rtx pcvr1 = gen_reg_rtx (V16QImode); |
| 7299 |
emit_insn (gen_pcvr1 (pcvr1, tmp)); |
| 7300 |
|
| 7301 |
rtx sub_target = simplify_gen_subreg (V16QImode, target, mode, 0); |
| 7302 |
rtx perm1 = gen_altivec_vperm_v8hiv16qi (sub_target, sub_target, sub_target, |
| 7303 |
pcvr1); |
| 7304 |
emit_insn (perm1); |
| 7305 |
|
| 7306 |
/* Insert val into element 0 of target vector. */ |
| 7307 |
rs6000_expand_vector_set (target, val, const0_rtx); |
| 7308 |
|
| 7309 |
/* Rotate back with a reversed permutation control vector generated from: |
| 7310 |
lvs[rl] v2,0,idx. */ |
| 7311 |
rtx pcvr2 = gen_reg_rtx (V16QImode); |
| 7312 |
emit_insn (gen_pcvr2 (pcvr2, tmp)); |
| 7313 |
|
| 7314 |
rtx perm2 = gen_altivec_vperm_v8hiv16qi (sub_target, sub_target, sub_target, |
| 7315 |
pcvr2); |
| 7316 |
emit_insn (perm2); |
| 7317 |
} |
| 7318 |
|
| 7319 |
/* Insert VAL into IDX of TARGET, VAL size is same of the vector element, IDX |
| 7320 |
is variable and also counts by vector element size for p7 & p8. */ |
| 7321 |
|
| 7322 |
static void |
| 7323 |
rs6000_expand_vector_set_var_p7 (rtx target, rtx val, rtx idx) |
| 7324 |
{ |
| 7325 |
machine_mode mode = GET_MODE (target); |
| 7326 |
|
| 7327 |
gcc_assert (VECTOR_MEM_VSX_P (mode) && !CONST_INT_P (idx)); |
| 7328 |
|
| 7329 |
machine_mode inner_mode = GET_MODE (val); |
| 7330 |
HOST_WIDE_INT mode_mask = GET_MODE_MASK (inner_mode); |
| 7331 |
|
| 7332 |
int width = GET_MODE_SIZE (inner_mode); |
| 7333 |
gcc_assert (width >= 1 && width <= 4); |
| 7334 |
|
| 7335 |
int shift = exact_log2 (width); |
| 7336 |
|
| 7337 |
machine_mode idx_mode = GET_MODE (idx); |
| 7338 |
|
| 7339 |
machine_mode shift_mode; |
| 7340 |
rtx (*gen_ashl)(rtx, rtx, rtx); |
| 7341 |
rtx (*gen_add)(rtx, rtx, rtx); |
| 7342 |
rtx (*gen_sub)(rtx, rtx, rtx); |
| 7343 |
rtx (*gen_lvsl)(rtx, rtx); |
| 7344 |
|
| 7345 |
if (TARGET_POWERPC64) |
| 7346 |
{ |
| 7347 |
shift_mode = DImode; |
| 7348 |
gen_ashl = gen_ashldi3; |
| 7349 |
gen_add = gen_adddi3; |
| 7350 |
gen_sub = gen_subdi3; |
| 7351 |
gen_lvsl = gen_altivec_lvsl_reg_di; |
| 7352 |
} |
| 7353 |
else |
| 7354 |
{ |
| 7355 |
shift_mode = SImode; |
| 7356 |
gen_ashl = gen_ashlsi3; |
| 7357 |
gen_add = gen_addsi3; |
| 7358 |
gen_sub = gen_subsi3; |
| 7359 |
gen_lvsl = gen_altivec_lvsl_reg_si; |
| 7360 |
} |
| 7361 |
|
| 7362 |
/* idx = idx * width. */ |
| 7363 |
rtx tmp = gen_reg_rtx (shift_mode); |
| 7364 |
idx = convert_modes (shift_mode, idx_mode, idx, 1); |
| 7365 |
|
| 7366 |
emit_insn (gen_ashl (tmp, idx, GEN_INT (shift))); |
| 7367 |
|
| 7368 |
/* For LE: idx = idx + 8. */ |
| 7369 |
if (!BYTES_BIG_ENDIAN) |
| 7370 |
emit_insn (gen_add (tmp, tmp, GEN_INT (8))); |
| 7371 |
else |
| 7372 |
emit_insn (gen_sub (tmp, GEN_INT (24 - width), tmp)); |
| 7373 |
|
| 7374 |
/* lxv vs33, mask. |
| 7375 |
DImode: 0xffffffffffffffff0000000000000000 |
| 7376 |
SImode: 0x00000000ffffffff0000000000000000 |
| 7377 |
HImode: 0x000000000000ffff0000000000000000. |
| 7378 |
QImode: 0x00000000000000ff0000000000000000. */ |
| 7379 |
rtx mask = gen_reg_rtx (V16QImode); |
| 7380 |
rtx mask_v2di = gen_reg_rtx (V2DImode); |
| 7381 |
rtvec v = rtvec_alloc (2); |
| 7382 |
if (!BYTES_BIG_ENDIAN) |
| 7383 |
{ |
| 7384 |
RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (DImode, 0); |
| 7385 |
RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (DImode, mode_mask); |
| 7386 |
} |
| 7387 |
else |
| 7388 |
{ |
| 7389 |
RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (DImode, mode_mask); |
| 7390 |
RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (DImode, 0); |
| 7391 |
} |
| 7392 |
emit_insn (gen_vec_initv2didi (mask_v2di, gen_rtx_PARALLEL (V2DImode, v))); |
| 7393 |
rtx sub_mask = simplify_gen_subreg (V16QImode, mask_v2di, V2DImode, 0); |
| 7394 |
emit_insn (gen_rtx_SET (mask, sub_mask)); |
| 7395 |
|
| 7396 |
/* mtvsrd[wz] f0,tmp_val. */ |
| 7397 |
rtx tmp_val = gen_reg_rtx (SImode); |
| 7398 |
if (inner_mode == E_SFmode) |
| 7399 |
if (TARGET_DIRECT_MOVE_64BIT) |
| 7400 |
emit_insn (gen_movsi_from_sf (tmp_val, val)); |
| 7401 |
else |
| 7402 |
{ |
| 7403 |
rtx stack = rs6000_allocate_stack_temp (SFmode, false, true); |
| 7404 |
emit_insn (gen_movsf_hardfloat (stack, val)); |
| 7405 |
rtx stack2 = copy_rtx (stack); |
| 7406 |
PUT_MODE (stack2, SImode); |
| 7407 |
emit_move_insn (tmp_val, stack2); |
| 7408 |
} |
| 7409 |
else |
| 7410 |
tmp_val = force_reg (SImode, val); |
| 7411 |
|
| 7412 |
rtx val_v16qi = gen_reg_rtx (V16QImode); |
| 7413 |
rtx val_v2di = gen_reg_rtx (V2DImode); |
| 7414 |
rtvec vec_val = rtvec_alloc (2); |
| 7415 |
if (!BYTES_BIG_ENDIAN) |
| 7416 |
{ |
| 7417 |
RTVEC_ELT (vec_val, 0) = gen_rtx_CONST_INT (DImode, 0); |
| 7418 |
RTVEC_ELT (vec_val, 1) = tmp_val; |
| 7419 |
} |
| 7420 |
else |
| 7421 |
{ |
| 7422 |
RTVEC_ELT (vec_val, 0) = tmp_val; |
| 7423 |
RTVEC_ELT (vec_val, 1) = gen_rtx_CONST_INT (DImode, 0); |
| 7424 |
} |
| 7425 |
emit_insn ( |
| 7426 |
gen_vec_initv2didi (val_v2di, gen_rtx_PARALLEL (V2DImode, vec_val))); |
| 7427 |
rtx sub_val = simplify_gen_subreg (V16QImode, val_v2di, V2DImode, 0); |
| 7428 |
emit_insn (gen_rtx_SET (val_v16qi, sub_val)); |
| 7429 |
|
| 7430 |
/* lvsl 13,0,idx. */ |
| 7431 |
rtx pcv = gen_reg_rtx (V16QImode); |
| 7432 |
emit_insn (gen_lvsl (pcv, tmp)); |
| 7433 |
|
| 7434 |
/* vperm 1,1,1,13. */ |
| 7435 |
/* vperm 0,0,0,13. */ |
| 7436 |
rtx val_perm = gen_reg_rtx (V16QImode); |
| 7437 |
rtx mask_perm = gen_reg_rtx (V16QImode); |
| 7438 |
emit_insn (gen_altivec_vperm_v8hiv16qi (val_perm, val_v16qi, val_v16qi, pcv)); |
| 7439 |
emit_insn (gen_altivec_vperm_v8hiv16qi (mask_perm, mask, mask, pcv)); |
| 7440 |
|
| 7441 |
rtx target_v16qi = simplify_gen_subreg (V16QImode, target, mode, 0); |
| 7442 |
|
| 7443 |
/* xxsel 34,34,32,33. */ |
| 7444 |
emit_insn ( |
| 7445 |
gen_vector_select_v16qi (target_v16qi, target_v16qi, val_perm, mask_perm)); |
| 7446 |
} |
| 7447 |
|
| 7448 |
/* Set field ELT_RTX of TARGET to VAL. */ |
| 7449 |
|
| 7450 |
void |
| 7451 |
rs6000_expand_vector_set (rtx target, rtx val, rtx elt_rtx) |
| 7452 |
{ |
| 7453 |
machine_mode mode = GET_MODE (target); |
| 7454 |
machine_mode inner_mode = GET_MODE_INNER (mode); |
| 7455 |
rtx reg = gen_reg_rtx (mode); |
| 7456 |
rtx mask, mem, x; |
| 7457 |
int width = GET_MODE_SIZE (inner_mode); |
| 7458 |
int i; |
| 7459 |
|
| 7460 |
val = force_reg (GET_MODE (val), val); |
| 7461 |
|
| 7462 |
if (VECTOR_MEM_VSX_P (mode)) |
| 7463 |
{ |
| 7464 |
if (!CONST_INT_P (elt_rtx)) |
| 7465 |
{ |
| 7466 |
/* For V2DI/V2DF, could leverage the P9 version to generate xxpermdi |
| 7467 |
when elt_rtx is variable. */ |
| 7468 |
if ((TARGET_P9_VECTOR && TARGET_POWERPC64) || width == 8) |
| 7469 |
{ |
| 7470 |
rs6000_expand_vector_set_var_p9 (target, val, elt_rtx); |
| 7471 |
return; |
| 7472 |
} |
| 7473 |
else if (TARGET_VSX) |
| 7474 |
{ |
| 7475 |
rs6000_expand_vector_set_var_p7 (target, val, elt_rtx); |
| 7476 |
return; |
| 7477 |
} |
| 7478 |
else |
| 7479 |
gcc_assert (CONST_INT_P (elt_rtx)); |
| 7480 |
} |
| 7481 |
|
| 7482 |
rtx insn = NULL_RTX; |
| 7483 |
|
| 7484 |
if (mode == V2DFmode) |
| 7485 |
insn = gen_vsx_set_v2df (target, target, val, elt_rtx); |
| 7486 |
|
| 7487 |
else if (mode == V2DImode) |
| 7488 |
insn = gen_vsx_set_v2di (target, target, val, elt_rtx); |
| 7489 |
|
| 7490 |
else if (TARGET_P9_VECTOR && TARGET_POWERPC64) |
| 7491 |
{ |
| 7492 |
if (mode == V4SImode) |
| 7493 |
insn = gen_vsx_set_v4si_p9 (target, target, val, elt_rtx); |
| 7494 |
else if (mode == V8HImode) |
| 7495 |
insn = gen_vsx_set_v8hi_p9 (target, target, val, elt_rtx); |
| 7496 |
else if (mode == V16QImode) |
| 7497 |
insn = gen_vsx_set_v16qi_p9 (target, target, val, elt_rtx); |
| 7498 |
else if (mode == V4SFmode) |
| 7499 |
insn = gen_vsx_set_v4sf_p9 (target, target, val, elt_rtx); |
| 7500 |
} |
| 7501 |
|
| 7502 |
if (insn) |
| 7503 |
{ |
| 7504 |
emit_insn (insn); |
| 7505 |
return; |
| 7506 |
} |
| 7507 |
} |
| 7508 |
|
| 7509 |
/* Simplify setting single element vectors like V1TImode. */ |
| 7510 |
if (GET_MODE_SIZE (mode) == GET_MODE_SIZE (inner_mode) |
| 7511 |
&& INTVAL (elt_rtx) == 0) |
| 7512 |
{ |
| 7513 |
emit_move_insn (target, gen_lowpart (mode, val)); |
| 7514 |
return; |
| 7515 |
} |
| 7516 |
|
| 7517 |
/* Load single variable value. */ |
| 7518 |
mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode)); |
| 7519 |
emit_move_insn (adjust_address_nv (mem, inner_mode, 0), val); |
| 7520 |
x = gen_rtx_UNSPEC (VOIDmode, |
| 7521 |
gen_rtvec (1, const0_rtx), UNSPEC_LVE); |
| 7522 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, |
| 7523 |
gen_rtvec (2, |
| 7524 |
gen_rtx_SET (reg, mem), |
| 7525 |
x))); |
| 7526 |
|
| 7527 |
/* Linear sequence. */ |
| 7528 |
mask = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16)); |
| 7529 |
for (i = 0; i < 16; ++i) |
| 7530 |
XVECEXP (mask, 0, i) = GEN_INT (i); |
| 7531 |
|
| 7532 |
/* Set permute mask to insert element into target. */ |
| 7533 |
for (i = 0; i < width; ++i) |
| 7534 |
XVECEXP (mask, 0, INTVAL (elt_rtx) * width + i) = GEN_INT (i + 0x10); |
| 7535 |
x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0)); |
| 7536 |
|
| 7537 |
if (BYTES_BIG_ENDIAN) |
| 7538 |
x = gen_rtx_UNSPEC (mode, |
| 7539 |
gen_rtvec (3, target, reg, |
| 7540 |
force_reg (V16QImode, x)), |
| 7541 |
UNSPEC_VPERM); |
| 7542 |
else |
| 7543 |
{ |
| 7544 |
if (TARGET_P9_VECTOR) |
| 7545 |
x = gen_rtx_UNSPEC (mode, |
| 7546 |
gen_rtvec (3, reg, target, |
| 7547 |
force_reg (V16QImode, x)), |
| 7548 |
UNSPEC_VPERMR); |
| 7549 |
else |
| 7550 |
{ |
| 7551 |
/* Invert selector. We prefer to generate VNAND on P8 so |
| 7552 |
that future fusion opportunities can kick in, but must |
| 7553 |
generate VNOR elsewhere. */ |
| 7554 |
rtx notx = gen_rtx_NOT (V16QImode, force_reg (V16QImode, x)); |
| 7555 |
rtx iorx = (TARGET_P8_VECTOR |
| 7556 |
? gen_rtx_IOR (V16QImode, notx, notx) |
| 7557 |
: gen_rtx_AND (V16QImode, notx, notx)); |
| 7558 |
rtx tmp = gen_reg_rtx (V16QImode); |
| 7559 |
emit_insn (gen_rtx_SET (tmp, iorx)); |
| 7560 |
|
| 7561 |
/* Permute with operands reversed and adjusted selector. */ |
| 7562 |
x = gen_rtx_UNSPEC (mode, gen_rtvec (3, reg, target, tmp), |
| 7563 |
UNSPEC_VPERM); |
| 7564 |
} |
| 7565 |
} |
| 7566 |
|
| 7567 |
emit_insn (gen_rtx_SET (target, x)); |
| 7568 |
} |
| 7569 |
|
| 7570 |
/* Extract field ELT from VEC into TARGET. */ |
| 7571 |
|
| 7572 |
void |
| 7573 |
rs6000_expand_vector_extract (rtx target, rtx vec, rtx elt) |
| 7574 |
{ |
| 7575 |
machine_mode mode = GET_MODE (vec); |
| 7576 |
machine_mode inner_mode = GET_MODE_INNER (mode); |
| 7577 |
rtx mem; |
| 7578 |
|
| 7579 |
if (VECTOR_MEM_VSX_P (mode) && CONST_INT_P (elt)) |
| 7580 |
{ |
| 7581 |
switch (mode) |
| 7582 |
{ |
| 7583 |
default: |
| 7584 |
break; |
| 7585 |
case E_V1TImode: |
| 7586 |
emit_move_insn (target, gen_lowpart (TImode, vec)); |
| 7587 |
break; |
| 7588 |
case E_V2DFmode: |
| 7589 |
emit_insn (gen_vsx_extract_v2df (target, vec, elt)); |
| 7590 |
return; |
| 7591 |
case E_V2DImode: |
| 7592 |
emit_insn (gen_vsx_extract_v2di (target, vec, elt)); |
| 7593 |
return; |
| 7594 |
case E_V4SFmode: |
| 7595 |
emit_insn (gen_vsx_extract_v4sf (target, vec, elt)); |
| 7596 |
return; |
| 7597 |
case E_V16QImode: |
| 7598 |
if (TARGET_DIRECT_MOVE_64BIT) |
| 7599 |
{ |
| 7600 |
emit_insn (gen_vsx_extract_v16qi (target, vec, elt)); |
| 7601 |
return; |
| 7602 |
} |
| 7603 |
else |
| 7604 |
break; |
| 7605 |
case E_V8HImode: |
| 7606 |
if (TARGET_DIRECT_MOVE_64BIT) |
| 7607 |
{ |
| 7608 |
emit_insn (gen_vsx_extract_v8hi (target, vec, elt)); |
| 7609 |
return; |
| 7610 |
} |
| 7611 |
else |
| 7612 |
break; |
| 7613 |
case E_V4SImode: |
| 7614 |
if (TARGET_DIRECT_MOVE_64BIT) |
| 7615 |
{ |
| 7616 |
emit_insn (gen_vsx_extract_v4si (target, vec, elt)); |
| 7617 |
return; |
| 7618 |
} |
| 7619 |
break; |
| 7620 |
} |
| 7621 |
} |
| 7622 |
else if (VECTOR_MEM_VSX_P (mode) && !CONST_INT_P (elt) |
| 7623 |
&& TARGET_DIRECT_MOVE_64BIT) |
| 7624 |
{ |
| 7625 |
if (GET_MODE (elt) != DImode) |
| 7626 |
{ |
| 7627 |
rtx tmp = gen_reg_rtx (DImode); |
| 7628 |
convert_move (tmp, elt, 0); |
| 7629 |
elt = tmp; |
| 7630 |
} |
| 7631 |
else if (!REG_P (elt)) |
| 7632 |
elt = force_reg (DImode, elt); |
| 7633 |
|
| 7634 |
switch (mode) |
| 7635 |
{ |
| 7636 |
case E_V1TImode: |
| 7637 |
emit_move_insn (target, gen_lowpart (TImode, vec)); |
| 7638 |
return; |
| 7639 |
|
| 7640 |
case E_V2DFmode: |
| 7641 |
emit_insn (gen_vsx_extract_v2df_var (target, vec, elt)); |
| 7642 |
return; |
| 7643 |
|
| 7644 |
case E_V2DImode: |
| 7645 |
emit_insn (gen_vsx_extract_v2di_var (target, vec, elt)); |
| 7646 |
return; |
| 7647 |
|
| 7648 |
case E_V4SFmode: |
| 7649 |
emit_insn (gen_vsx_extract_v4sf_var (target, vec, elt)); |
| 7650 |
return; |
| 7651 |
|
| 7652 |
case E_V4SImode: |
| 7653 |
emit_insn (gen_vsx_extract_v4si_var (target, vec, elt)); |
| 7654 |
return; |
| 7655 |
|
| 7656 |
case E_V8HImode: |
| 7657 |
emit_insn (gen_vsx_extract_v8hi_var (target, vec, elt)); |
| 7658 |
return; |
| 7659 |
|
| 7660 |
case E_V16QImode: |
| 7661 |
emit_insn (gen_vsx_extract_v16qi_var (target, vec, elt)); |
| 7662 |
return; |
| 7663 |
|
| 7664 |
default: |
| 7665 |
gcc_unreachable (); |
| 7666 |
} |
| 7667 |
} |
| 7668 |
|
| 7669 |
/* Allocate mode-sized buffer. */ |
| 7670 |
mem = assign_stack_temp (mode, GET_MODE_SIZE (mode)); |
| 7671 |
|
| 7672 |
emit_move_insn (mem, vec); |
| 7673 |
if (CONST_INT_P (elt)) |
| 7674 |
{ |
| 7675 |
int modulo_elt = INTVAL (elt) % GET_MODE_NUNITS (mode); |
| 7676 |
|
| 7677 |
/* Add offset to field within buffer matching vector element. */ |
| 7678 |
mem = adjust_address_nv (mem, inner_mode, |
| 7679 |
modulo_elt * GET_MODE_SIZE (inner_mode)); |
| 7680 |
emit_move_insn (target, adjust_address_nv (mem, inner_mode, 0)); |
| 7681 |
} |
| 7682 |
else |
| 7683 |
{ |
| 7684 |
unsigned int ele_size = GET_MODE_SIZE (inner_mode); |
| 7685 |
rtx num_ele_m1 = GEN_INT (GET_MODE_NUNITS (mode) - 1); |
| 7686 |
|
| 7687 |
elt = gen_rtx_AND (Pmode, elt, num_ele_m1); |
| 7688 |
if (ele_size > 1) |
| 7689 |
elt = gen_rtx_MULT (Pmode, elt, GEN_INT (ele_size)); |
| 7690 |
rtx new_addr = gen_rtx_PLUS (Pmode, XEXP (mem, 0), elt); |
| 7691 |
new_addr = change_address (mem, inner_mode, new_addr); |
| 7692 |
emit_move_insn (target, new_addr); |
| 7693 |
} |
| 7694 |
} |
| 7695 |
|
| 7696 |
/* Return the offset within a memory object (MEM) of a vector type to a given |
| 7697 |
element within the vector (ELEMENT) with an element size (SCALAR_SIZE). If |
| 7698 |
the element is constant, we return a constant integer. |
| 7699 |
|
| 7700 |
Otherwise, we use a base register temporary to calculate the offset after |
| 7701 |
masking it to fit within the bounds of the vector and scaling it. The |
| 7702 |
masking is required by the 64-bit ELF version 2 ABI for the vec_extract |
| 7703 |
built-in function. */ |
| 7704 |
|
| 7705 |
static rtx |
| 7706 |
get_vector_offset (rtx mem, rtx element, rtx base_tmp, unsigned scalar_size) |
| 7707 |
{ |
| 7708 |
if (CONST_INT_P (element)) |
| 7709 |
return GEN_INT (INTVAL (element) * scalar_size); |
| 7710 |
|
| 7711 |
/* All insns should use the 'Q' constraint (address is a single register) if |
| 7712 |
the element number is not a constant. */ |
| 7713 |
gcc_assert (satisfies_constraint_Q (mem)); |
| 7714 |
|
| 7715 |
/* Mask the element to make sure the element number is between 0 and the |
| 7716 |
maximum number of elements - 1 so that we don't generate an address |
| 7717 |
outside the vector. */ |
| 7718 |
rtx num_ele_m1 = GEN_INT (GET_MODE_NUNITS (GET_MODE (mem)) - 1); |
| 7719 |
rtx and_op = gen_rtx_AND (Pmode, element, num_ele_m1); |
| 7720 |
emit_insn (gen_rtx_SET (base_tmp, and_op)); |
| 7721 |
|
| 7722 |
/* Shift the element to get the byte offset from the element number. */ |
| 7723 |
int shift = exact_log2 (scalar_size); |
| 7724 |
gcc_assert (shift >= 0); |
| 7725 |
|
| 7726 |
if (shift > 0) |
| 7727 |
{ |
| 7728 |
rtx shift_op = gen_rtx_ASHIFT (Pmode, base_tmp, GEN_INT (shift)); |
| 7729 |
emit_insn (gen_rtx_SET (base_tmp, shift_op)); |
| 7730 |
} |
| 7731 |
|
| 7732 |
return base_tmp; |
| 7733 |
} |
| 7734 |
|
| 7735 |
/* Helper function update PC-relative addresses when we are adjusting a memory |
| 7736 |
address (ADDR) to a vector to point to a scalar field within the vector with |
| 7737 |
a constant offset (ELEMENT_OFFSET). If the address is not valid, we can |
| 7738 |
use the base register temporary (BASE_TMP) to form the address. */ |
| 7739 |
|
| 7740 |
static rtx |
| 7741 |
adjust_vec_address_pcrel (rtx addr, rtx element_offset, rtx base_tmp) |
| 7742 |
{ |
| 7743 |
rtx new_addr = NULL; |
| 7744 |
|
| 7745 |
gcc_assert (CONST_INT_P (element_offset)); |
| 7746 |
|
| 7747 |
if (GET_CODE (addr) == CONST) |
| 7748 |
addr = XEXP (addr, 0); |
| 7749 |
|
| 7750 |
if (GET_CODE (addr) == PLUS) |
| 7751 |
{ |
| 7752 |
rtx op0 = XEXP (addr, 0); |
| 7753 |
rtx op1 = XEXP (addr, 1); |
| 7754 |
|
| 7755 |
if (CONST_INT_P (op1)) |
| 7756 |
{ |
| 7757 |
HOST_WIDE_INT offset |
| 7758 |
= INTVAL (XEXP (addr, 1)) + INTVAL (element_offset); |
| 7759 |
|
| 7760 |
if (offset == 0) |
| 7761 |
new_addr = op0; |
| 7762 |
|
| 7763 |
else |
| 7764 |
{ |
| 7765 |
rtx plus = gen_rtx_PLUS (Pmode, op0, GEN_INT (offset)); |
| 7766 |
new_addr = gen_rtx_CONST (Pmode, plus); |
| 7767 |
} |
| 7768 |
} |
| 7769 |
|
| 7770 |
else |
| 7771 |
{ |
| 7772 |
emit_move_insn (base_tmp, addr); |
| 7773 |
new_addr = gen_rtx_PLUS (Pmode, base_tmp, element_offset); |
| 7774 |
} |
| 7775 |
} |
| 7776 |
|
| 7777 |
else if (SYMBOL_REF_P (addr) || LABEL_REF_P (addr)) |
| 7778 |
{ |
| 7779 |
rtx plus = gen_rtx_PLUS (Pmode, addr, element_offset); |
| 7780 |
new_addr = gen_rtx_CONST (Pmode, plus); |
| 7781 |
} |
| 7782 |
|
| 7783 |
else |
| 7784 |
gcc_unreachable (); |
| 7785 |
|
| 7786 |
return new_addr; |
| 7787 |
} |
| 7788 |
|
| 7789 |
/* Adjust a memory address (MEM) of a vector type to point to a scalar field |
| 7790 |
within the vector (ELEMENT) with a mode (SCALAR_MODE). Use a base register |
| 7791 |
temporary (BASE_TMP) to fixup the address. Return the new memory address |
| 7792 |
that is valid for reads or writes to a given register (SCALAR_REG). |
| 7793 |
|
| 7794 |
This function is expected to be called after reload is completed when we are |
| 7795 |
splitting insns. The temporary BASE_TMP might be set multiple times with |
| 7796 |
this code. */ |
| 7797 |
|
| 7798 |
rtx |
| 7799 |
rs6000_adjust_vec_address (rtx scalar_reg, |
| 7800 |
rtx mem, |
| 7801 |
rtx element, |
| 7802 |
rtx base_tmp, |
| 7803 |
machine_mode scalar_mode) |
| 7804 |
{ |
| 7805 |
unsigned scalar_size = GET_MODE_SIZE (scalar_mode); |
| 7806 |
rtx addr = XEXP (mem, 0); |
| 7807 |
rtx new_addr; |
| 7808 |
|
| 7809 |
gcc_assert (!reg_mentioned_p (base_tmp, addr)); |
| 7810 |
gcc_assert (!reg_mentioned_p (base_tmp, element)); |
| 7811 |
|
| 7812 |
/* Vector addresses should not have PRE_INC, PRE_DEC, or PRE_MODIFY. */ |
| 7813 |
gcc_assert (GET_RTX_CLASS (GET_CODE (addr)) != RTX_AUTOINC); |
| 7814 |
|
| 7815 |
/* Calculate what we need to add to the address to get the element |
| 7816 |
address. */ |
| 7817 |
rtx element_offset = get_vector_offset (mem, element, base_tmp, scalar_size); |
| 7818 |
|
| 7819 |
/* Create the new address pointing to the element within the vector. If we |
| 7820 |
are adding 0, we don't have to change the address. */ |
| 7821 |
if (element_offset == const0_rtx) |
| 7822 |
new_addr = addr; |
| 7823 |
|
| 7824 |
/* A simple indirect address can be converted into a reg + offset |
| 7825 |
address. */ |
| 7826 |
else if (REG_P (addr) || SUBREG_P (addr)) |
| 7827 |
new_addr = gen_rtx_PLUS (Pmode, addr, element_offset); |
| 7828 |
|
| 7829 |
/* For references to local static variables, fold a constant offset into the |
| 7830 |
address. */ |
| 7831 |
else if (pcrel_local_address (addr, Pmode) && CONST_INT_P (element_offset)) |
| 7832 |
new_addr = adjust_vec_address_pcrel (addr, element_offset, base_tmp); |
| 7833 |
|
| 7834 |
/* Optimize D-FORM addresses with constant offset with a constant element, to |
| 7835 |
include the element offset in the address directly. */ |
| 7836 |
else if (GET_CODE (addr) == PLUS) |
| 7837 |
{ |
| 7838 |
rtx op0 = XEXP (addr, 0); |
| 7839 |
rtx op1 = XEXP (addr, 1); |
| 7840 |
|
| 7841 |
gcc_assert (REG_P (op0) || SUBREG_P (op0)); |
| 7842 |
if (CONST_INT_P (op1) && CONST_INT_P (element_offset)) |
| 7843 |
{ |
| 7844 |
/* op0 should never be r0, because r0+offset is not valid. But it |
| 7845 |
doesn't hurt to make sure it is not r0. */ |
| 7846 |
gcc_assert (reg_or_subregno (op0) != 0); |
| 7847 |
|
| 7848 |
/* D-FORM address with constant element number. */ |
| 7849 |
HOST_WIDE_INT offset = INTVAL (op1) + INTVAL (element_offset); |
| 7850 |
rtx offset_rtx = GEN_INT (offset); |
| 7851 |
new_addr = gen_rtx_PLUS (Pmode, op0, offset_rtx); |
| 7852 |
} |
| 7853 |
else |
| 7854 |
{ |
| 7855 |
/* If we don't have a D-FORM address with a constant element number, |
| 7856 |
add the two elements in the current address. Then add the offset. |
| 7857 |
|
| 7858 |
Previously, we tried to add the offset to OP1 and change the |
| 7859 |
address to an X-FORM format adding OP0 and BASE_TMP, but it became |
| 7860 |
complicated because we had to verify that op1 was not GPR0 and we |
| 7861 |
had a constant element offset (due to the way ADDI is defined). |
| 7862 |
By doing the add of OP0 and OP1 first, and then adding in the |
| 7863 |
offset, it has the benefit that if D-FORM instructions are |
| 7864 |
allowed, the offset is part of the memory access to the vector |
| 7865 |
element. */ |
| 7866 |
emit_insn (gen_rtx_SET (base_tmp, gen_rtx_PLUS (Pmode, op0, op1))); |
| 7867 |
new_addr = gen_rtx_PLUS (Pmode, base_tmp, element_offset); |
| 7868 |
} |
| 7869 |
} |
| 7870 |
|
| 7871 |
else |
| 7872 |
{ |
| 7873 |
emit_move_insn (base_tmp, addr); |
| 7874 |
new_addr = gen_rtx_PLUS (Pmode, base_tmp, element_offset); |
| 7875 |
} |
| 7876 |
|
| 7877 |
/* If the address isn't valid, move the address into the temporary base |
| 7878 |
register. Some reasons it could not be valid include: |
| 7879 |
|
| 7880 |
The address offset overflowed the 16 or 34 bit offset size; |
| 7881 |
We need to use a DS-FORM load, and the bottom 2 bits are non-zero; |
| 7882 |
We need to use a DQ-FORM load, and the bottom 4 bits are non-zero; |
| 7883 |
Only X_FORM loads can be done, and the address is D_FORM. */ |
| 7884 |
|
| 7885 |
enum insn_form iform |
| 7886 |
= address_to_insn_form (new_addr, scalar_mode, |
| 7887 |
reg_to_non_prefixed (scalar_reg, scalar_mode)); |
| 7888 |
|
| 7889 |
if (iform == INSN_FORM_BAD) |
| 7890 |
{ |
| 7891 |
emit_move_insn (base_tmp, new_addr); |
| 7892 |
new_addr = base_tmp; |
| 7893 |
} |
| 7894 |
|
| 7895 |
return change_address (mem, scalar_mode, new_addr); |
| 7896 |
} |
| 7897 |
|
| 7898 |
/* Split a variable vec_extract operation into the component instructions. */ |
| 7899 |
|
| 7900 |
void |
| 7901 |
rs6000_split_vec_extract_var (rtx dest, rtx src, rtx element, rtx tmp_gpr, |
| 7902 |
rtx tmp_altivec) |
| 7903 |
{ |
| 7904 |
machine_mode mode = GET_MODE (src); |
| 7905 |
machine_mode scalar_mode = GET_MODE_INNER (GET_MODE (src)); |
| 7906 |
unsigned scalar_size = GET_MODE_SIZE (scalar_mode); |
| 7907 |
int byte_shift = exact_log2 (scalar_size); |
| 7908 |
|
| 7909 |
gcc_assert (byte_shift >= 0); |
| 7910 |
|
| 7911 |
/* If we are given a memory address, optimize to load just the element. We |
| 7912 |
don't have to adjust the vector element number on little endian |
| 7913 |
systems. */ |
| 7914 |
if (MEM_P (src)) |
| 7915 |
{ |
| 7916 |
emit_move_insn (dest, |
| 7917 |
rs6000_adjust_vec_address (dest, src, element, tmp_gpr, |
| 7918 |
scalar_mode)); |
| 7919 |
return; |
| 7920 |
} |
| 7921 |
|
| 7922 |
else if (REG_P (src) || SUBREG_P (src)) |
| 7923 |
{ |
| 7924 |
int num_elements = GET_MODE_NUNITS (mode); |
| 7925 |
int bits_in_element = mode_to_bits (GET_MODE_INNER (mode)); |
| 7926 |
int bit_shift = 7 - exact_log2 (num_elements); |
| 7927 |
rtx element2; |
| 7928 |
unsigned int dest_regno = reg_or_subregno (dest); |
| 7929 |
unsigned int src_regno = reg_or_subregno (src); |
| 7930 |
unsigned int element_regno = reg_or_subregno (element); |
| 7931 |
|
| 7932 |
gcc_assert (REG_P (tmp_gpr)); |
| 7933 |
|
| 7934 |
/* See if we want to generate VEXTU{B,H,W}{L,R}X if the destination is in |
| 7935 |
a general purpose register. */ |
| 7936 |
if (TARGET_P9_VECTOR |
| 7937 |
&& (mode == V16QImode || mode == V8HImode || mode == V4SImode) |
| 7938 |
&& INT_REGNO_P (dest_regno) |
| 7939 |
&& ALTIVEC_REGNO_P (src_regno) |
| 7940 |
&& INT_REGNO_P (element_regno)) |
| 7941 |
{ |
| 7942 |
rtx dest_si = gen_rtx_REG (SImode, dest_regno); |
| 7943 |
rtx element_si = gen_rtx_REG (SImode, element_regno); |
| 7944 |
|
| 7945 |
if (mode == V16QImode) |
| 7946 |
emit_insn (BYTES_BIG_ENDIAN |
| 7947 |
? gen_vextublx (dest_si, element_si, src) |
| 7948 |
: gen_vextubrx (dest_si, element_si, src)); |
| 7949 |
|
| 7950 |
else if (mode == V8HImode) |
| 7951 |
{ |
| 7952 |
rtx tmp_gpr_si = gen_rtx_REG (SImode, REGNO (tmp_gpr)); |
| 7953 |
emit_insn (gen_ashlsi3 (tmp_gpr_si, element_si, const1_rtx)); |
| 7954 |
emit_insn (BYTES_BIG_ENDIAN |
| 7955 |
? gen_vextuhlx (dest_si, tmp_gpr_si, src) |
| 7956 |
: gen_vextuhrx (dest_si, tmp_gpr_si, src)); |
| 7957 |
} |
| 7958 |
|
| 7959 |
|
| 7960 |
else |
| 7961 |
{ |
| 7962 |
rtx tmp_gpr_si = gen_rtx_REG (SImode, REGNO (tmp_gpr)); |
| 7963 |
emit_insn (gen_ashlsi3 (tmp_gpr_si, element_si, const2_rtx)); |
| 7964 |
emit_insn (BYTES_BIG_ENDIAN |
| 7965 |
? gen_vextuwlx (dest_si, tmp_gpr_si, src) |
| 7966 |
: gen_vextuwrx (dest_si, tmp_gpr_si, src)); |
| 7967 |
} |
| 7968 |
|
| 7969 |
return; |
| 7970 |
} |
| 7971 |
|
| 7972 |
|
| 7973 |
gcc_assert (REG_P (tmp_altivec)); |
| 7974 |
|
| 7975 |
/* For little endian, adjust element ordering. For V2DI/V2DF, we can use |
| 7976 |
an XOR, otherwise we need to subtract. The shift amount is so VSLO |
| 7977 |
will shift the element into the upper position (adding 3 to convert a |
| 7978 |
byte shift into a bit shift). */ |
| 7979 |
if (scalar_size == 8) |
| 7980 |
{ |
| 7981 |
if (!BYTES_BIG_ENDIAN) |
| 7982 |
{ |
| 7983 |
emit_insn (gen_xordi3 (tmp_gpr, element, const1_rtx)); |
| 7984 |
element2 = tmp_gpr; |
| 7985 |
} |
| 7986 |
else |
| 7987 |
element2 = element; |
| 7988 |
|
| 7989 |
/* Generate RLDIC directly to shift left 6 bits and retrieve 1 |
| 7990 |
bit. */ |
| 7991 |
emit_insn (gen_rtx_SET (tmp_gpr, |
| 7992 |
gen_rtx_AND (DImode, |
| 7993 |
gen_rtx_ASHIFT (DImode, |
| 7994 |
element2, |
| 7995 |
GEN_INT (6)), |
| 7996 |
GEN_INT (64)))); |
| 7997 |
} |
| 7998 |
else |
| 7999 |
{ |
| 8000 |
if (!BYTES_BIG_ENDIAN) |
| 8001 |
{ |
| 8002 |
rtx num_ele_m1 = GEN_INT (num_elements - 1); |
| 8003 |
|
| 8004 |
emit_insn (gen_anddi3 (tmp_gpr, element, num_ele_m1)); |
| 8005 |
emit_insn (gen_subdi3 (tmp_gpr, num_ele_m1, tmp_gpr)); |
| 8006 |
element2 = tmp_gpr; |
| 8007 |
} |
| 8008 |
else |
| 8009 |
element2 = element; |
| 8010 |
|
| 8011 |
emit_insn (gen_ashldi3 (tmp_gpr, element2, GEN_INT (bit_shift))); |
| 8012 |
} |
| 8013 |
|
| 8014 |
/* Get the value into the lower byte of the Altivec register where VSLO |
| 8015 |
expects it. */ |
| 8016 |
if (TARGET_P9_VECTOR) |
| 8017 |
emit_insn (gen_vsx_splat_v2di (tmp_altivec, tmp_gpr)); |
| 8018 |
else if (can_create_pseudo_p ()) |
| 8019 |
emit_insn (gen_vsx_concat_v2di (tmp_altivec, tmp_gpr, tmp_gpr)); |
| 8020 |
else |
| 8021 |
{ |
| 8022 |
rtx tmp_di = gen_rtx_REG (DImode, REGNO (tmp_altivec)); |
| 8023 |
emit_move_insn (tmp_di, tmp_gpr); |
| 8024 |
emit_insn (gen_vsx_concat_v2di (tmp_altivec, tmp_di, tmp_di)); |
| 8025 |
} |
| 8026 |
|
| 8027 |
/* Do the VSLO to get the value into the final location. */ |
| 8028 |
switch (mode) |
| 8029 |
{ |
| 8030 |
case E_V2DFmode: |
| 8031 |
emit_insn (gen_vsx_vslo_v2df (dest, src, tmp_altivec)); |
| 8032 |
return; |
| 8033 |
|
| 8034 |
case E_V2DImode: |
| 8035 |
emit_insn (gen_vsx_vslo_v2di (dest, src, tmp_altivec)); |
| 8036 |
return; |
| 8037 |
|
| 8038 |
case E_V4SFmode: |
| 8039 |
{ |
| 8040 |
rtx tmp_altivec_di = gen_rtx_REG (DImode, REGNO (tmp_altivec)); |
| 8041 |
rtx tmp_altivec_v4sf = gen_rtx_REG (V4SFmode, REGNO (tmp_altivec)); |
| 8042 |
rtx src_v2di = gen_rtx_REG (V2DImode, REGNO (src)); |
| 8043 |
emit_insn (gen_vsx_vslo_v2di (tmp_altivec_di, src_v2di, |
| 8044 |
tmp_altivec)); |
| 8045 |
|
| 8046 |
emit_insn (gen_vsx_xscvspdp_scalar2 (dest, tmp_altivec_v4sf)); |
| 8047 |
return; |
| 8048 |
} |
| 8049 |
|
| 8050 |
case E_V4SImode: |
| 8051 |
case E_V8HImode: |
| 8052 |
case E_V16QImode: |
| 8053 |
{ |
| 8054 |
rtx tmp_altivec_di = gen_rtx_REG (DImode, REGNO (tmp_altivec)); |
| 8055 |
rtx src_v2di = gen_rtx_REG (V2DImode, REGNO (src)); |
| 8056 |
rtx tmp_gpr_di = gen_rtx_REG (DImode, REGNO (dest)); |
| 8057 |
emit_insn (gen_vsx_vslo_v2di (tmp_altivec_di, src_v2di, |
| 8058 |
tmp_altivec)); |
| 8059 |
emit_move_insn (tmp_gpr_di, tmp_altivec_di); |
| 8060 |
emit_insn (gen_lshrdi3 (tmp_gpr_di, tmp_gpr_di, |
| 8061 |
GEN_INT (64 - bits_in_element))); |
| 8062 |
return; |
| 8063 |
} |
| 8064 |
|
| 8065 |
default: |
| 8066 |
gcc_unreachable (); |
| 8067 |
} |
| 8068 |
|
| 8069 |
return; |
| 8070 |
} |
| 8071 |
else |
| 8072 |
gcc_unreachable (); |
| 8073 |
} |
| 8074 |
|
| 8075 |
/* Return alignment of TYPE. Existing alignment is ALIGN. HOW |
| 8076 |
selects whether the alignment is abi mandated, optional, or |
| 8077 |
both abi and optional alignment. */ |
| 8078 |
|
| 8079 |
unsigned int |
| 8080 |
rs6000_data_alignment (tree type, unsigned int align, enum data_align how) |
| 8081 |
{ |
| 8082 |
if (how != align_opt) |
| 8083 |
{ |
| 8084 |
if (VECTOR_TYPE_P (type) && align < 128) |
| 8085 |
align = 128; |
| 8086 |
} |
| 8087 |
|
| 8088 |
if (how != align_abi) |
| 8089 |
{ |
| 8090 |
if (TREE_CODE (type) == ARRAY_TYPE |
| 8091 |
&& TYPE_MODE (TREE_TYPE (type)) == QImode) |
| 8092 |
{ |
| 8093 |
if (align < BITS_PER_WORD) |
| 8094 |
align = BITS_PER_WORD; |
| 8095 |
} |
| 8096 |
} |
| 8097 |
|
| 8098 |
return align; |
| 8099 |
} |
| 8100 |
|
| 8101 |
/* Implement TARGET_SLOW_UNALIGNED_ACCESS. Altivec vector memory |
| 8102 |
instructions simply ignore the low bits; VSX memory instructions |
| 8103 |
are aligned to 4 or 8 bytes. */ |
| 8104 |
|
| 8105 |
static bool |
| 8106 |
rs6000_slow_unaligned_access (machine_mode mode, unsigned int align) |
| 8107 |
{ |
| 8108 |
return (STRICT_ALIGNMENT |
| 8109 |
|| (!TARGET_EFFICIENT_UNALIGNED_VSX |
| 8110 |
&& ((SCALAR_FLOAT_MODE_NOT_VECTOR_P (mode) && align < 32) |
| 8111 |
|| ((VECTOR_MODE_P (mode) || VECTOR_ALIGNMENT_P (mode)) |
| 8112 |
&& (int) align < VECTOR_ALIGN (mode))))); |
| 8113 |
} |
| 8114 |
|
| 8115 |
/* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ |
| 8116 |
|
| 8117 |
unsigned int |
| 8118 |
rs6000_special_adjust_field_align (tree type, unsigned int computed) |
| 8119 |
{ |
| 8120 |
if (computed <= 32 || TYPE_PACKED (type)) |
| 8121 |
return computed; |
| 8122 |
|
| 8123 |
/* Strip initial arrays. */ |
| 8124 |
while (TREE_CODE (type) == ARRAY_TYPE) |
| 8125 |
type = TREE_TYPE (type); |
| 8126 |
|
| 8127 |
/* If RECORD or UNION, recursively find the first field. */ |
| 8128 |
while (AGGREGATE_TYPE_P (type)) |
| 8129 |
{ |
| 8130 |
tree field = TYPE_FIELDS (type); |
| 8131 |
|
| 8132 |
/* Skip all non field decls */ |
| 8133 |
while (field != NULL |
| 8134 |
&& (TREE_CODE (field) != FIELD_DECL |
| 8135 |
|| DECL_FIELD_ABI_IGNORED (field))) |
| 8136 |
field = DECL_CHAIN (field); |
| 8137 |
|
| 8138 |
if (! field) |
| 8139 |
break; |
| 8140 |
|
| 8141 |
/* A packed field does not contribute any extra alignment. */ |
| 8142 |
if (DECL_PACKED (field)) |
| 8143 |
return computed; |
| 8144 |
|
| 8145 |
type = TREE_TYPE (field); |
| 8146 |
|
| 8147 |
/* Strip arrays. */ |
| 8148 |
while (TREE_CODE (type) == ARRAY_TYPE) |
| 8149 |
type = TREE_TYPE (type); |
| 8150 |
} |
| 8151 |
|
| 8152 |
if (! AGGREGATE_TYPE_P (type) && type != error_mark_node |
| 8153 |
&& (TYPE_MODE (type) == DFmode || TYPE_MODE (type) == DCmode)) |
| 8154 |
computed = MIN (computed, 32); |
| 8155 |
|
| 8156 |
return computed; |
| 8157 |
} |
| 8158 |
|
| 8159 |
/* AIX increases natural record alignment to doubleword if the innermost first |
| 8160 |
field is an FP double while the FP fields remain word aligned. |
| 8161 |
Only called if TYPE initially is a RECORD or UNION. */ |
| 8162 |
|
| 8163 |
unsigned int |
| 8164 |
rs6000_special_round_type_align (tree type, unsigned int computed, |
| 8165 |
unsigned int specified) |
| 8166 |
{ |
| 8167 |
unsigned int align = MAX (computed, specified); |
| 8168 |
|
| 8169 |
if (TYPE_PACKED (type) || align >= 64) |
| 8170 |
return align; |
| 8171 |
|
| 8172 |
/* If RECORD or UNION, recursively find the first field. */ |
| 8173 |
do |
| 8174 |
{ |
| 8175 |
tree field = TYPE_FIELDS (type); |
| 8176 |
|
| 8177 |
/* Skip all non field decls */ |
| 8178 |
while (field != NULL |
| 8179 |
&& (TREE_CODE (field) != FIELD_DECL |
| 8180 |
|| DECL_FIELD_ABI_IGNORED (field))) |
| 8181 |
field = DECL_CHAIN (field); |
| 8182 |
|
| 8183 |
if (! field) |
| 8184 |
break; |
| 8185 |
|
| 8186 |
/* A packed field does not contribute any extra alignment. */ |
| 8187 |
if (DECL_PACKED (field)) |
| 8188 |
return align; |
| 8189 |
|
| 8190 |
type = TREE_TYPE (field); |
| 8191 |
|
| 8192 |
/* Strip arrays. */ |
| 8193 |
while (TREE_CODE (type) == ARRAY_TYPE) |
| 8194 |
type = TREE_TYPE (type); |
| 8195 |
} while (AGGREGATE_TYPE_P (type)); |
| 8196 |
|
| 8197 |
if (! AGGREGATE_TYPE_P (type) && type != error_mark_node |
| 8198 |
&& (TYPE_MODE (type) == DFmode || TYPE_MODE (type) == DCmode)) |
| 8199 |
align = MAX (align, 64); |
| 8200 |
|
| 8201 |
return align; |
| 8202 |
} |
| 8203 |
|
| 8204 |
/* Darwin increases record alignment to the natural alignment of |
| 8205 |
the first field. */ |
| 8206 |
|
| 8207 |
unsigned int |
| 8208 |
darwin_rs6000_special_round_type_align (tree type, unsigned int computed, |
| 8209 |
unsigned int specified) |
| 8210 |
{ |
| 8211 |
unsigned int align = MAX (computed, specified); |
| 8212 |
|
| 8213 |
if (TYPE_PACKED (type)) |
| 8214 |
return align; |
| 8215 |
|
| 8216 |
/* Find the first field, looking down into aggregates. */ |
| 8217 |
do { |
| 8218 |
tree field = TYPE_FIELDS (type); |
| 8219 |
/* Skip all non field decls */ |
| 8220 |
while (field != NULL |
| 8221 |
&& (TREE_CODE (field) != FIELD_DECL |
| 8222 |
|| DECL_FIELD_ABI_IGNORED (field))) |
| 8223 |
field = DECL_CHAIN (field); |
| 8224 |
if (! field) |
| 8225 |
break; |
| 8226 |
/* A packed field does not contribute any extra alignment. */ |
| 8227 |
if (DECL_PACKED (field)) |
| 8228 |
return align; |
| 8229 |
type = TREE_TYPE (field); |
| 8230 |
while (TREE_CODE (type) == ARRAY_TYPE) |
| 8231 |
type = TREE_TYPE (type); |
| 8232 |
} while (AGGREGATE_TYPE_P (type)); |
| 8233 |
|
| 8234 |
if (type != error_mark_node && ! AGGREGATE_TYPE_P (type) |
| 8235 |
&& ! TYPE_PACKED (type) && maximum_field_alignment == 0) |
| 8236 |
align = MAX (align, TYPE_ALIGN (type)); |
| 8237 |
|
| 8238 |
return align; |
| 8239 |
} |
| 8240 |
|
| 8241 |
/* Return 1 for an operand in small memory on V.4/eabi. */ |
| 8242 |
|
| 8243 |
int |
| 8244 |
small_data_operand (rtx op ATTRIBUTE_UNUSED, |
| 8245 |
machine_mode mode ATTRIBUTE_UNUSED) |
| 8246 |
{ |
| 8247 |
#if TARGET_ELF |
| 8248 |
rtx sym_ref; |
| 8249 |
|
| 8250 |
if (rs6000_sdata == SDATA_NONE || rs6000_sdata == SDATA_DATA) |
| 8251 |
return 0; |
| 8252 |
|
| 8253 |
if (DEFAULT_ABI != ABI_V4) |
| 8254 |
return 0; |
| 8255 |
|
| 8256 |
if (SYMBOL_REF_P (op)) |
| 8257 |
sym_ref = op; |
| 8258 |
|
| 8259 |
else if (GET_CODE (op) != CONST |
| 8260 |
|| GET_CODE (XEXP (op, 0)) != PLUS |
| 8261 |
|| !SYMBOL_REF_P (XEXP (XEXP (op, 0), 0)) |
| 8262 |
|| !CONST_INT_P (XEXP (XEXP (op, 0), 1))) |
| 8263 |
return 0; |
| 8264 |
|
| 8265 |
else |
| 8266 |
{ |
| 8267 |
rtx sum = XEXP (op, 0); |
| 8268 |
HOST_WIDE_INT summand; |
| 8269 |
|
| 8270 |
/* We have to be careful here, because it is the referenced address |
| 8271 |
that must be 32k from _SDA_BASE_, not just the symbol. */ |
| 8272 |
summand = INTVAL (XEXP (sum, 1)); |
| 8273 |
if (summand < 0 || summand > g_switch_value) |
| 8274 |
return 0; |
| 8275 |
|
| 8276 |
sym_ref = XEXP (sum, 0); |
| 8277 |
} |
| 8278 |
|
| 8279 |
return SYMBOL_REF_SMALL_P (sym_ref); |
| 8280 |
#else |
| 8281 |
return 0; |
| 8282 |
#endif |
| 8283 |
} |
| 8284 |
|
| 8285 |
/* Return true if either operand is a general purpose register. */ |
| 8286 |
|
| 8287 |
bool |
| 8288 |
gpr_or_gpr_p (rtx op0, rtx op1) |
| 8289 |
{ |
| 8290 |
return ((REG_P (op0) && INT_REGNO_P (REGNO (op0))) |
| 8291 |
|| (REG_P (op1) && INT_REGNO_P (REGNO (op1)))); |
| 8292 |
} |
| 8293 |
|
| 8294 |
/* Return true if this is a move direct operation between GPR registers and |
| 8295 |
floating point/VSX registers. */ |
| 8296 |
|
| 8297 |
bool |
| 8298 |
direct_move_p (rtx op0, rtx op1) |
| 8299 |
{ |
| 8300 |
if (!REG_P (op0) || !REG_P (op1)) |
| 8301 |
return false; |
| 8302 |
|
| 8303 |
if (!TARGET_DIRECT_MOVE) |
| 8304 |
return false; |
| 8305 |
|
| 8306 |
int regno0 = REGNO (op0); |
| 8307 |
int regno1 = REGNO (op1); |
| 8308 |
if (!HARD_REGISTER_NUM_P (regno0) || !HARD_REGISTER_NUM_P (regno1)) |
| 8309 |
return false; |
| 8310 |
|
| 8311 |
if (INT_REGNO_P (regno0) && VSX_REGNO_P (regno1)) |
| 8312 |
return true; |
| 8313 |
|
| 8314 |
if (VSX_REGNO_P (regno0) && INT_REGNO_P (regno1)) |
| 8315 |
return true; |
| 8316 |
|
| 8317 |
return false; |
| 8318 |
} |
| 8319 |
|
| 8320 |
/* Return true if the ADDR is an acceptable address for a quad memory |
| 8321 |
operation of mode MODE (either LQ/STQ for general purpose registers, or |
| 8322 |
LXV/STXV for vector registers under ISA 3.0. GPR_P is true if this address |
| 8323 |
is intended for LQ/STQ. If it is false, the address is intended for the ISA |
| 8324 |
3.0 LXV/STXV instruction. */ |
| 8325 |
|
| 8326 |
bool |
| 8327 |
quad_address_p (rtx addr, machine_mode mode, bool strict) |
| 8328 |
{ |
| 8329 |
rtx op0, op1; |
| 8330 |
|
| 8331 |
if (GET_MODE_SIZE (mode) < 16) |
| 8332 |
return false; |
| 8333 |
|
| 8334 |
if (legitimate_indirect_address_p (addr, strict)) |
| 8335 |
return true; |
| 8336 |
|
| 8337 |
if (VECTOR_MODE_P (mode) && !mode_supports_dq_form (mode)) |
| 8338 |
return false; |
| 8339 |
|
| 8340 |
/* Is this a valid prefixed address? If the bottom four bits of the offset |
| 8341 |
are non-zero, we could use a prefixed instruction (which does not have the |
| 8342 |
DQ-form constraint that the traditional instruction had) instead of |
| 8343 |
forcing the unaligned offset to a GPR. */ |
| 8344 |
if (address_is_prefixed (addr, mode, NON_PREFIXED_DQ)) |
| 8345 |
return true; |
| 8346 |
|
| 8347 |
if (GET_CODE (addr) != PLUS) |
| 8348 |
return false; |
| 8349 |
|
| 8350 |
op0 = XEXP (addr, 0); |
| 8351 |
if (!REG_P (op0) || !INT_REG_OK_FOR_BASE_P (op0, strict)) |
| 8352 |
return false; |
| 8353 |
|
| 8354 |
op1 = XEXP (addr, 1); |
| 8355 |
if (!CONST_INT_P (op1)) |
| 8356 |
return false; |
| 8357 |
|
| 8358 |
return quad_address_offset_p (INTVAL (op1)); |
| 8359 |
} |
| 8360 |
|
| 8361 |
/* Return true if this is a load or store quad operation. This function does |
| 8362 |
not handle the atomic quad memory instructions. */ |
| 8363 |
|
| 8364 |
bool |
| 8365 |
quad_load_store_p (rtx op0, rtx op1) |
| 8366 |
{ |
| 8367 |
bool ret; |
| 8368 |
|
| 8369 |
if (!TARGET_QUAD_MEMORY) |
| 8370 |
ret = false; |
| 8371 |
|
| 8372 |
else if (REG_P (op0) && MEM_P (op1)) |
| 8373 |
ret = (quad_int_reg_operand (op0, GET_MODE (op0)) |
| 8374 |
&& quad_memory_operand (op1, GET_MODE (op1)) |
| 8375 |
&& !reg_overlap_mentioned_p (op0, op1)); |
| 8376 |
|
| 8377 |
else if (MEM_P (op0) && REG_P (op1)) |
| 8378 |
ret = (quad_memory_operand (op0, GET_MODE (op0)) |
| 8379 |
&& quad_int_reg_operand (op1, GET_MODE (op1))); |
| 8380 |
|
| 8381 |
else |
| 8382 |
ret = false; |
| 8383 |
|
| 8384 |
if (TARGET_DEBUG_ADDR) |
| 8385 |
{ |
| 8386 |
fprintf (stderr, "\n========== quad_load_store, return %s\n", |
| 8387 |
ret ? "true" : "false"); |
| 8388 |
debug_rtx (gen_rtx_SET (op0, op1)); |
| 8389 |
} |
| 8390 |
|
| 8391 |
return ret; |
| 8392 |
} |
| 8393 |
|
| 8394 |
/* Given an address, return a constant offset term if one exists. */ |
| 8395 |
|
| 8396 |
static rtx |
| 8397 |
address_offset (rtx op) |
| 8398 |
{ |
| 8399 |
if (GET_CODE (op) == PRE_INC |
| 8400 |
|| GET_CODE (op) == PRE_DEC) |
| 8401 |
op = XEXP (op, 0); |
| 8402 |
else if (GET_CODE (op) == PRE_MODIFY |
| 8403 |
|| GET_CODE (op) == LO_SUM) |
| 8404 |
op = XEXP (op, 1); |
| 8405 |
|
| 8406 |
if (GET_CODE (op) == CONST) |
| 8407 |
op = XEXP (op, 0); |
| 8408 |
|
| 8409 |
if (GET_CODE (op) == PLUS) |
| 8410 |
op = XEXP (op, 1); |
| 8411 |
|
| 8412 |
if (CONST_INT_P (op)) |
| 8413 |
return op; |
| 8414 |
|
| 8415 |
return NULL_RTX; |
| 8416 |
} |
| 8417 |
|
| 8418 |
/* This tests that a lo_sum {constant, symbol, symbol+offset} is valid for |
| 8419 |
the mode. If we can't find (or don't know) the alignment of the symbol |
| 8420 |
we assume (optimistically) that it's sufficiently aligned [??? maybe we |
| 8421 |
should be pessimistic]. Offsets are validated in the same way as for |
| 8422 |
reg + offset. */ |
| 8423 |
static bool |
| 8424 |
darwin_rs6000_legitimate_lo_sum_const_p (rtx x, machine_mode mode) |
| 8425 |
{ |
| 8426 |
/* We should not get here with this. */ |
| 8427 |
gcc_checking_assert (! mode_supports_dq_form (mode)); |
| 8428 |
|
| 8429 |
if (GET_CODE (x) == CONST) |
| 8430 |
x = XEXP (x, 0); |
| 8431 |
|
| 8432 |
/* If we are building PIC code, then any symbol must be wrapped in an |
| 8433 |
UNSPEC_MACHOPIC_OFFSET so that it will get the picbase subtracted. */ |
| 8434 |
bool machopic_offs_p = false; |
| 8435 |
if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_MACHOPIC_OFFSET) |
| 8436 |
{ |
| 8437 |
x = XVECEXP (x, 0, 0); |
| 8438 |
machopic_offs_p = true; |
| 8439 |
} |
| 8440 |
|
| 8441 |
rtx sym = NULL_RTX; |
| 8442 |
unsigned HOST_WIDE_INT offset = 0; |
| 8443 |
|
| 8444 |
if (GET_CODE (x) == PLUS) |
| 8445 |
{ |
| 8446 |
sym = XEXP (x, 0); |
| 8447 |
if (! SYMBOL_REF_P (sym)) |
| 8448 |
return false; |
| 8449 |
if (!CONST_INT_P (XEXP (x, 1))) |
| 8450 |
return false; |
| 8451 |
offset = INTVAL (XEXP (x, 1)); |
| 8452 |
} |
| 8453 |
else if (SYMBOL_REF_P (x)) |
| 8454 |
sym = x; |
| 8455 |
else if (CONST_INT_P (x)) |
| 8456 |
offset = INTVAL (x); |
| 8457 |
else if (GET_CODE (x) == LABEL_REF) |
| 8458 |
offset = 0; // We assume code labels are Pmode aligned |
| 8459 |
else |
| 8460 |
return false; // not sure what we have here. |
| 8461 |
|
| 8462 |
/* If we don't know the alignment of the thing to which the symbol refers, |
| 8463 |
we assume optimistically it is "enough". |
| 8464 |
??? maybe we should be pessimistic instead. */ |
| 8465 |
unsigned align = 0; |
| 8466 |
|
| 8467 |
if (sym) |
| 8468 |
{ |
| 8469 |
tree decl = SYMBOL_REF_DECL (sym); |
| 8470 |
/* As noted above, PIC code cannot use a bare SYMBOL_REF. */ |
| 8471 |
if (TARGET_MACHO && flag_pic && !machopic_offs_p) |
| 8472 |
return false; |
| 8473 |
#if TARGET_MACHO |
| 8474 |
if (MACHO_SYMBOL_INDIRECTION_P (sym)) |
| 8475 |
/* The decl in an indirection symbol is the original one, which might |
| 8476 |
be less aligned than the indirection. Our indirections are always |
| 8477 |
pointer-aligned. */ |
| 8478 |
; |
| 8479 |
else |
| 8480 |
#endif |
| 8481 |
if (decl && DECL_ALIGN (decl)) |
| 8482 |
align = DECL_ALIGN_UNIT (decl); |
| 8483 |
} |
| 8484 |
|
| 8485 |
unsigned int extra = 0; |
| 8486 |
switch (mode) |
| 8487 |
{ |
| 8488 |
case E_DFmode: |
| 8489 |
case E_DDmode: |
| 8490 |
case E_DImode: |
| 8491 |
/* If we are using VSX scalar loads, restrict ourselves to reg+reg |
| 8492 |
addressing. */ |
| 8493 |
if (VECTOR_MEM_VSX_P (mode)) |
| 8494 |
return false; |
| 8495 |
|
| 8496 |
if (!TARGET_POWERPC64) |
| 8497 |
extra = 4; |
| 8498 |
else if ((offset & 3) || (align & 3)) |
| 8499 |
return false; |
| 8500 |
break; |
| 8501 |
|
| 8502 |
case E_TFmode: |
| 8503 |
case E_IFmode: |
| 8504 |
case E_KFmode: |
| 8505 |
case E_TDmode: |
| 8506 |
case E_TImode: |
| 8507 |
case E_PTImode: |
| 8508 |
extra = 8; |
| 8509 |
if (!TARGET_POWERPC64) |
| 8510 |
extra = 12; |
| 8511 |
else if ((offset & 3) || (align & 3)) |
| 8512 |
return false; |
| 8513 |
break; |
| 8514 |
|
| 8515 |
default: |
| 8516 |
break; |
| 8517 |
} |
| 8518 |
|
| 8519 |
/* We only care if the access(es) would cause a change to the high part. */ |
| 8520 |
offset = sext_hwi (offset, 16); |
| 8521 |
return SIGNED_16BIT_OFFSET_EXTRA_P (offset, extra); |
| 8522 |
} |
| 8523 |
|
| 8524 |
/* Return true if the MEM operand is a memory operand suitable for use |
| 8525 |
with a (full width, possibly multiple) gpr load/store. On |
| 8526 |
powerpc64 this means the offset must be divisible by 4. |
| 8527 |
Implements 'Y' constraint. |
| 8528 |
|
| 8529 |
Accept direct, indexed, offset, lo_sum and tocref. Since this is |
| 8530 |
a constraint function we know the operand has satisfied a suitable |
| 8531 |
memory predicate. |
| 8532 |
|
| 8533 |
Offsetting a lo_sum should not be allowed, except where we know by |
| 8534 |
alignment that a 32k boundary is not crossed. Note that by |
| 8535 |
"offsetting" here we mean a further offset to access parts of the |
| 8536 |
MEM. It's fine to have a lo_sum where the inner address is offset |
| 8537 |
from a sym, since the same sym+offset will appear in the high part |
| 8538 |
of the address calculation. */ |
| 8539 |
|
| 8540 |
bool |
| 8541 |
mem_operand_gpr (rtx op, machine_mode mode) |
| 8542 |
{ |
| 8543 |
unsigned HOST_WIDE_INT offset; |
| 8544 |
int extra; |
| 8545 |
rtx addr = XEXP (op, 0); |
| 8546 |
|
| 8547 |
/* PR85755: Allow PRE_INC and PRE_DEC addresses. */ |
| 8548 |
if (TARGET_UPDATE |
| 8549 |
&& (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC) |
| 8550 |
&& mode_supports_pre_incdec_p (mode) |
| 8551 |
&& legitimate_indirect_address_p (XEXP (addr, 0), false)) |
| 8552 |
return true; |
| 8553 |
|
| 8554 |
/* Allow prefixed instructions if supported. If the bottom two bits of the |
| 8555 |
offset are non-zero, we could use a prefixed instruction (which does not |
| 8556 |
have the DS-form constraint that the traditional instruction had) instead |
| 8557 |
of forcing the unaligned offset to a GPR. */ |
| 8558 |
if (address_is_prefixed (addr, mode, NON_PREFIXED_DS)) |
| 8559 |
return true; |
| 8560 |
|
| 8561 |
/* We need to look through Mach-O PIC unspecs to determine if a lo_sum is |
| 8562 |
really OK. Doing this early avoids teaching all the other machinery |
| 8563 |
about them. */ |
| 8564 |
if (TARGET_MACHO && GET_CODE (addr) == LO_SUM) |
| 8565 |
return darwin_rs6000_legitimate_lo_sum_const_p (XEXP (addr, 1), mode); |
| 8566 |
|
| 8567 |
/* Only allow offsettable addresses. See PRs 83969 and 84279. */ |
| 8568 |
if (!rs6000_offsettable_memref_p (op, mode, false)) |
| 8569 |
return false; |
| 8570 |
|
| 8571 |
op = address_offset (addr); |
| 8572 |
if (op == NULL_RTX) |
| 8573 |
return true; |
| 8574 |
|
| 8575 |
offset = INTVAL (op); |
| 8576 |
if (TARGET_POWERPC64 && (offset & 3) != 0) |
| 8577 |
return false; |
| 8578 |
|
| 8579 |
extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD; |
| 8580 |
if (extra < 0) |
| 8581 |
extra = 0; |
| 8582 |
|
| 8583 |
if (GET_CODE (addr) == LO_SUM) |
| 8584 |
/* For lo_sum addresses, we must allow any offset except one that |
| 8585 |
causes a wrap, so test only the low 16 bits. */ |
| 8586 |
offset = sext_hwi (offset, 16); |
| 8587 |
|
| 8588 |
return SIGNED_16BIT_OFFSET_EXTRA_P (offset, extra); |
| 8589 |
} |
| 8590 |
|
| 8591 |
/* As above, but for DS-FORM VSX insns. Unlike mem_operand_gpr, |
| 8592 |
enforce an offset divisible by 4 even for 32-bit. */ |
| 8593 |
|
| 8594 |
bool |
| 8595 |
mem_operand_ds_form (rtx op, machine_mode mode) |
| 8596 |
{ |
| 8597 |
unsigned HOST_WIDE_INT offset; |
| 8598 |
int extra; |
| 8599 |
rtx addr = XEXP (op, 0); |
| 8600 |
|
| 8601 |
/* Allow prefixed instructions if supported. If the bottom two bits of the |
| 8602 |
offset are non-zero, we could use a prefixed instruction (which does not |
| 8603 |
have the DS-form constraint that the traditional instruction had) instead |
| 8604 |
of forcing the unaligned offset to a GPR. */ |
| 8605 |
if (address_is_prefixed (addr, mode, NON_PREFIXED_DS)) |
| 8606 |
return true; |
| 8607 |
|
| 8608 |
if (!offsettable_address_p (false, mode, addr)) |
| 8609 |
return false; |
| 8610 |
|
| 8611 |
op = address_offset (addr); |
| 8612 |
if (op == NULL_RTX) |
| 8613 |
return true; |
| 8614 |
|
| 8615 |
offset = INTVAL (op); |
| 8616 |
if ((offset & 3) != 0) |
| 8617 |
return false; |
| 8618 |
|
| 8619 |
extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD; |
| 8620 |
if (extra < 0) |
| 8621 |
extra = 0; |
| 8622 |
|
| 8623 |
if (GET_CODE (addr) == LO_SUM) |
| 8624 |
/* For lo_sum addresses, we must allow any offset except one that |
| 8625 |
causes a wrap, so test only the low 16 bits. */ |
| 8626 |
offset = sext_hwi (offset, 16); |
| 8627 |
|
| 8628 |
return SIGNED_16BIT_OFFSET_EXTRA_P (offset, extra); |
| 8629 |
} |
| 8630 |
|
| 8631 |
/* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address_p. */ |
| 8632 |
|
| 8633 |
static bool |
| 8634 |
reg_offset_addressing_ok_p (machine_mode mode) |
| 8635 |
{ |
| 8636 |
switch (mode) |
| 8637 |
{ |
| 8638 |
case E_V16QImode: |
| 8639 |
case E_V8HImode: |
| 8640 |
case E_V4SFmode: |
| 8641 |
case E_V4SImode: |
| 8642 |
case E_V2DFmode: |
| 8643 |
case E_V2DImode: |
| 8644 |
case E_V1TImode: |
| 8645 |
case E_TImode: |
| 8646 |
case E_TFmode: |
| 8647 |
case E_KFmode: |
| 8648 |
/* AltiVec/VSX vector modes. Only reg+reg addressing was valid until the |
| 8649 |
ISA 3.0 vector d-form addressing mode was added. While TImode is not |
| 8650 |
a vector mode, if we want to use the VSX registers to move it around, |
| 8651 |
we need to restrict ourselves to reg+reg addressing. Similarly for |
| 8652 |
IEEE 128-bit floating point that is passed in a single vector |
| 8653 |
register. */ |
| 8654 |
if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)) |
| 8655 |
return mode_supports_dq_form (mode); |
| 8656 |
break; |
| 8657 |
|
| 8658 |
/* The vector pair/quad types support offset addressing if the |
| 8659 |
underlying vectors support offset addressing. */ |
| 8660 |
case E_OOmode: |
| 8661 |
case E_XOmode: |
| 8662 |
return TARGET_MMA; |
| 8663 |
|
| 8664 |
case E_SDmode: |
| 8665 |
/* If we can do direct load/stores of SDmode, restrict it to reg+reg |
| 8666 |
addressing for the LFIWZX and STFIWX instructions. */ |
| 8667 |
if (TARGET_NO_SDMODE_STACK) |
| 8668 |
return false; |
| 8669 |
break; |
| 8670 |
|
| 8671 |
default: |
| 8672 |
break; |
| 8673 |
} |
| 8674 |
|
| 8675 |
return true; |
| 8676 |
} |
| 8677 |
|
| 8678 |
static bool |
| 8679 |
virtual_stack_registers_memory_p (rtx op) |
| 8680 |
{ |
| 8681 |
int regnum; |
| 8682 |
|
| 8683 |
if (REG_P (op)) |
| 8684 |
regnum = REGNO (op); |
| 8685 |
|
| 8686 |
else if (GET_CODE (op) == PLUS |
| 8687 |
&& REG_P (XEXP (op, 0)) |
| 8688 |
&& CONST_INT_P (XEXP (op, 1))) |
| 8689 |
regnum = REGNO (XEXP (op, 0)); |
| 8690 |
|
| 8691 |
else |
| 8692 |
return false; |
| 8693 |
|
| 8694 |
return (regnum >= FIRST_VIRTUAL_REGISTER |
| 8695 |
&& regnum <= LAST_VIRTUAL_POINTER_REGISTER); |
| 8696 |
} |
| 8697 |
|
| 8698 |
/* Return true if a MODE sized memory accesses to OP plus OFFSET |
| 8699 |
is known to not straddle a 32k boundary. This function is used |
| 8700 |
to determine whether -mcmodel=medium code can use TOC pointer |
| 8701 |
relative addressing for OP. This means the alignment of the TOC |
| 8702 |
pointer must also be taken into account, and unfortunately that is |
| 8703 |
only 8 bytes. */ |
| 8704 |
|
| 8705 |
#ifndef POWERPC64_TOC_POINTER_ALIGNMENT |
| 8706 |
#define POWERPC64_TOC_POINTER_ALIGNMENT 8 |
| 8707 |
#endif |
| 8708 |
|
| 8709 |
static bool |
| 8710 |
offsettable_ok_by_alignment (rtx op, HOST_WIDE_INT offset, |
| 8711 |
machine_mode mode) |
| 8712 |
{ |
| 8713 |
tree decl; |
| 8714 |
unsigned HOST_WIDE_INT dsize, dalign, lsb, mask; |
| 8715 |
|
| 8716 |
if (!SYMBOL_REF_P (op)) |
| 8717 |
return false; |
| 8718 |
|
| 8719 |
/* ISA 3.0 vector d-form addressing is restricted, don't allow |
| 8720 |
SYMBOL_REF. */ |
| 8721 |
if (mode_supports_dq_form (mode)) |
| 8722 |
return false; |
| 8723 |
|
| 8724 |
dsize = GET_MODE_SIZE (mode); |
| 8725 |
decl = SYMBOL_REF_DECL (op); |
| 8726 |
if (!decl) |
| 8727 |
{ |
| 8728 |
if (dsize == 0) |
| 8729 |
return false; |
| 8730 |
|
| 8731 |
/* -fsection-anchors loses the original SYMBOL_REF_DECL when |
| 8732 |
replacing memory addresses with an anchor plus offset. We |
| 8733 |
could find the decl by rummaging around in the block->objects |
| 8734 |
VEC for the given offset but that seems like too much work. */ |
| 8735 |
dalign = BITS_PER_UNIT; |
| 8736 |
if (SYMBOL_REF_HAS_BLOCK_INFO_P (op) |
| 8737 |
&& SYMBOL_REF_ANCHOR_P (op) |
| 8738 |
&& SYMBOL_REF_BLOCK (op) != NULL) |
| 8739 |
{ |
| 8740 |
struct object_block *block = SYMBOL_REF_BLOCK (op); |
| 8741 |
|
| 8742 |
dalign = block->alignment; |
| 8743 |
offset += SYMBOL_REF_BLOCK_OFFSET (op); |
| 8744 |
} |
| 8745 |
else if (CONSTANT_POOL_ADDRESS_P (op)) |
| 8746 |
{ |
| 8747 |
/* It would be nice to have get_pool_align().. */ |
| 8748 |
machine_mode cmode = get_pool_mode (op); |
| 8749 |
|
| 8750 |
dalign = GET_MODE_ALIGNMENT (cmode); |
| 8751 |
} |
| 8752 |
} |
| 8753 |
else if (DECL_P (decl)) |
| 8754 |
{ |
| 8755 |
dalign = DECL_ALIGN (decl); |
| 8756 |
|
| 8757 |
if (dsize == 0) |
| 8758 |
{ |
| 8759 |
/* Allow BLKmode when the entire object is known to not |
| 8760 |
cross a 32k boundary. */ |
| 8761 |
if (!DECL_SIZE_UNIT (decl)) |
| 8762 |
return false; |
| 8763 |
|
| 8764 |
if (!tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))) |
| 8765 |
return false; |
| 8766 |
|
| 8767 |
dsize = tree_to_uhwi (DECL_SIZE_UNIT (decl)); |
| 8768 |
if (dsize > 32768) |
| 8769 |
return false; |
| 8770 |
|
| 8771 |
dalign /= BITS_PER_UNIT; |
| 8772 |
if (dalign > POWERPC64_TOC_POINTER_ALIGNMENT) |
| 8773 |
dalign = POWERPC64_TOC_POINTER_ALIGNMENT; |
| 8774 |
return dalign >= dsize; |
| 8775 |
} |
| 8776 |
} |
| 8777 |
else |
| 8778 |
gcc_unreachable (); |
| 8779 |
|
| 8780 |
/* Find how many bits of the alignment we know for this access. */ |
| 8781 |
dalign /= BITS_PER_UNIT; |
| 8782 |
if (dalign > POWERPC64_TOC_POINTER_ALIGNMENT) |
| 8783 |
dalign = POWERPC64_TOC_POINTER_ALIGNMENT; |
| 8784 |
mask = dalign - 1; |
| 8785 |
lsb = offset & -offset; |
| 8786 |
mask &= lsb - 1; |
| 8787 |
dalign = mask + 1; |
| 8788 |
|
| 8789 |
return dalign >= dsize; |
| 8790 |
} |
| 8791 |
|
| 8792 |
static bool |
| 8793 |
constant_pool_expr_p (rtx op) |
| 8794 |
{ |
| 8795 |
rtx base, offset; |
| 8796 |
|
| 8797 |
split_const (op, &base, &offset); |
| 8798 |
return (SYMBOL_REF_P (base) |
| 8799 |
&& CONSTANT_POOL_ADDRESS_P (base) |
| 8800 |
&& ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (base), Pmode)); |
| 8801 |
} |
| 8802 |
|
| 8803 |
/* Create a TOC reference for symbol_ref SYMBOL. If LARGETOC_REG is non-null, |
| 8804 |
use that as the register to put the HIGH value into if register allocation |
| 8805 |
is already done. */ |
| 8806 |
|
| 8807 |
rtx |
| 8808 |
create_TOC_reference (rtx symbol, rtx largetoc_reg) |
| 8809 |
{ |
| 8810 |
rtx tocrel, tocreg, hi; |
| 8811 |
|
| 8812 |
gcc_assert (TARGET_TOC); |
| 8813 |
|
| 8814 |
if (TARGET_DEBUG_ADDR) |
| 8815 |
{ |
| 8816 |
if (SYMBOL_REF_P (symbol)) |
| 8817 |
fprintf (stderr, "\ncreate_TOC_reference, (symbol_ref %s)\n", |
| 8818 |
XSTR (symbol, 0)); |
| 8819 |
else |
| 8820 |
{ |
| 8821 |
fprintf (stderr, "\ncreate_TOC_reference, code %s:\n", |
| 8822 |
GET_RTX_NAME (GET_CODE (symbol))); |
| 8823 |
debug_rtx (symbol); |
| 8824 |
} |
| 8825 |
} |
| 8826 |
|
| 8827 |
if (!can_create_pseudo_p ()) |
| 8828 |
df_set_regs_ever_live (TOC_REGISTER, true); |
| 8829 |
|
| 8830 |
tocreg = gen_rtx_REG (Pmode, TOC_REGISTER); |
| 8831 |
tocrel = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, symbol, tocreg), UNSPEC_TOCREL); |
| 8832 |
if (TARGET_CMODEL == CMODEL_SMALL || can_create_pseudo_p ()) |
| 8833 |
return tocrel; |
| 8834 |
|
| 8835 |
hi = gen_rtx_HIGH (Pmode, copy_rtx (tocrel)); |
| 8836 |
if (largetoc_reg != NULL) |
| 8837 |
{ |
| 8838 |
emit_move_insn (largetoc_reg, hi); |
| 8839 |
hi = largetoc_reg; |
| 8840 |
} |
| 8841 |
return gen_rtx_LO_SUM (Pmode, hi, tocrel); |
| 8842 |
} |
| 8843 |
|
| 8844 |
/* These are only used to pass through from print_operand/print_operand_address |
| 8845 |
to rs6000_output_addr_const_extra over the intervening function |
| 8846 |
output_addr_const which is not target code. */ |
| 8847 |
static const_rtx tocrel_base_oac, tocrel_offset_oac; |
| 8848 |
|
| 8849 |
/* Return true if OP is a toc pointer relative address (the output |
| 8850 |
of create_TOC_reference). If STRICT, do not match non-split |
| 8851 |
-mcmodel=large/medium toc pointer relative addresses. If the pointers |
| 8852 |
are non-NULL, place base and offset pieces in TOCREL_BASE_RET and |
| 8853 |
TOCREL_OFFSET_RET respectively. */ |
| 8854 |
|
| 8855 |
bool |
| 8856 |
toc_relative_expr_p (const_rtx op, bool strict, const_rtx *tocrel_base_ret, |
| 8857 |
const_rtx *tocrel_offset_ret) |
| 8858 |
{ |
| 8859 |
if (!TARGET_TOC) |
| 8860 |
return false; |
| 8861 |
|
| 8862 |
if (TARGET_CMODEL != CMODEL_SMALL) |
| 8863 |
{ |
| 8864 |
/* When strict ensure we have everything tidy. */ |
| 8865 |
if (strict |
| 8866 |
&& !(GET_CODE (op) == LO_SUM |
| 8867 |
&& REG_P (XEXP (op, 0)) |
| 8868 |
&& INT_REG_OK_FOR_BASE_P (XEXP (op, 0), strict))) |
| 8869 |
return false; |
| 8870 |
|
| 8871 |
/* When not strict, allow non-split TOC addresses and also allow |
| 8872 |
(lo_sum (high ..)) TOC addresses created during reload. */ |
| 8873 |
if (GET_CODE (op) == LO_SUM) |
| 8874 |
op = XEXP (op, 1); |
| 8875 |
} |
| 8876 |
|
| 8877 |
const_rtx tocrel_base = op; |
| 8878 |
const_rtx tocrel_offset = const0_rtx; |
| 8879 |
|
| 8880 |
if (GET_CODE (op) == PLUS && add_cint_operand (XEXP (op, 1), GET_MODE (op))) |
| 8881 |
{ |
| 8882 |
tocrel_base = XEXP (op, 0); |
| 8883 |
tocrel_offset = XEXP (op, 1); |
| 8884 |
} |
| 8885 |
|
| 8886 |
if (tocrel_base_ret) |
| 8887 |
*tocrel_base_ret = tocrel_base; |
| 8888 |
if (tocrel_offset_ret) |
| 8889 |
*tocrel_offset_ret = tocrel_offset; |
| 8890 |
|
| 8891 |
return (GET_CODE (tocrel_base) == UNSPEC |
| 8892 |
&& XINT (tocrel_base, 1) == UNSPEC_TOCREL |
| 8893 |
&& REG_P (XVECEXP (tocrel_base, 0, 1)) |
| 8894 |
&& REGNO (XVECEXP (tocrel_base, 0, 1)) == TOC_REGISTER); |
| 8895 |
} |
| 8896 |
|
| 8897 |
/* Return true if X is a constant pool address, and also for cmodel=medium |
| 8898 |
if X is a toc-relative address known to be offsettable within MODE. */ |
| 8899 |
|
| 8900 |
bool |
| 8901 |
legitimate_constant_pool_address_p (const_rtx x, machine_mode mode, |
| 8902 |
bool strict) |
| 8903 |
{ |
| 8904 |
const_rtx tocrel_base, tocrel_offset; |
| 8905 |
return (toc_relative_expr_p (x, strict, &tocrel_base, &tocrel_offset) |
| 8906 |
&& (TARGET_CMODEL != CMODEL_MEDIUM |
| 8907 |
|| constant_pool_expr_p (XVECEXP (tocrel_base, 0, 0)) |
| 8908 |
|| mode == QImode |
| 8909 |
|| offsettable_ok_by_alignment (XVECEXP (tocrel_base, 0, 0), |
| 8910 |
INTVAL (tocrel_offset), mode))); |
| 8911 |
} |
| 8912 |
|
| 8913 |
static bool |
| 8914 |
legitimate_small_data_p (machine_mode mode, rtx x) |
| 8915 |
{ |
| 8916 |
return (DEFAULT_ABI == ABI_V4 |
| 8917 |
&& !flag_pic && !TARGET_TOC |
| 8918 |
&& (SYMBOL_REF_P (x) || GET_CODE (x) == CONST) |
| 8919 |
&& small_data_operand (x, mode)); |
| 8920 |
} |
| 8921 |
|
| 8922 |
bool |
| 8923 |
rs6000_legitimate_offset_address_p (machine_mode mode, rtx x, |
| 8924 |
bool strict, bool worst_case) |
| 8925 |
{ |
| 8926 |
unsigned HOST_WIDE_INT offset; |
| 8927 |
unsigned int extra; |
| 8928 |
|
| 8929 |
if (GET_CODE (x) != PLUS) |
| 8930 |
return false; |
| 8931 |
if (!REG_P (XEXP (x, 0))) |
| 8932 |
return false; |
| 8933 |
if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict)) |
| 8934 |
return false; |
| 8935 |
if (mode_supports_dq_form (mode)) |
| 8936 |
return quad_address_p (x, mode, strict); |
| 8937 |
if (!reg_offset_addressing_ok_p (mode)) |
| 8938 |
return virtual_stack_registers_memory_p (x); |
| 8939 |
if (legitimate_constant_pool_address_p (x, mode, strict || lra_in_progress)) |
| 8940 |
return true; |
| 8941 |
if (!CONST_INT_P (XEXP (x, 1))) |
| 8942 |
return false; |
| 8943 |
|
| 8944 |
offset = INTVAL (XEXP (x, 1)); |
| 8945 |
extra = 0; |
| 8946 |
switch (mode) |
| 8947 |
{ |
| 8948 |
case E_DFmode: |
| 8949 |
case E_DDmode: |
| 8950 |
case E_DImode: |
| 8951 |
/* If we are using VSX scalar loads, restrict ourselves to reg+reg |
| 8952 |
addressing. */ |
| 8953 |
if (VECTOR_MEM_VSX_P (mode)) |
| 8954 |
return false; |
| 8955 |
|
| 8956 |
if (!worst_case) |
| 8957 |
break; |
| 8958 |
if (!TARGET_POWERPC64) |
| 8959 |
extra = 4; |
| 8960 |
else if (offset & 3) |
| 8961 |
return false; |
| 8962 |
break; |
| 8963 |
|
| 8964 |
case E_TFmode: |
| 8965 |
case E_IFmode: |
| 8966 |
case E_KFmode: |
| 8967 |
case E_TDmode: |
| 8968 |
case E_TImode: |
| 8969 |
case E_PTImode: |
| 8970 |
extra = 8; |
| 8971 |
if (!worst_case) |
| 8972 |
break; |
| 8973 |
if (!TARGET_POWERPC64) |
| 8974 |
extra = 12; |
| 8975 |
else if (offset & 3) |
| 8976 |
return false; |
| 8977 |
break; |
| 8978 |
|
| 8979 |
default: |
| 8980 |
break; |
| 8981 |
} |
| 8982 |
|
| 8983 |
if (TARGET_PREFIXED) |
| 8984 |
return SIGNED_34BIT_OFFSET_EXTRA_P (offset, extra); |
| 8985 |
else |
| 8986 |
return SIGNED_16BIT_OFFSET_EXTRA_P (offset, extra); |
| 8987 |
} |
| 8988 |
|
| 8989 |
bool |
| 8990 |
legitimate_indexed_address_p (rtx x, int strict) |
| 8991 |
{ |
| 8992 |
rtx op0, op1; |
| 8993 |
|
| 8994 |
if (GET_CODE (x) != PLUS) |
| 8995 |
return false; |
| 8996 |
|
| 8997 |
op0 = XEXP (x, 0); |
| 8998 |
op1 = XEXP (x, 1); |
| 8999 |
|
| 9000 |
return (REG_P (op0) && REG_P (op1) |
| 9001 |
&& ((INT_REG_OK_FOR_BASE_P (op0, strict) |
| 9002 |
&& INT_REG_OK_FOR_INDEX_P (op1, strict)) |
| 9003 |
|| (INT_REG_OK_FOR_BASE_P (op1, strict) |
| 9004 |
&& INT_REG_OK_FOR_INDEX_P (op0, strict)))); |
| 9005 |
} |
| 9006 |
|
| 9007 |
bool |
| 9008 |
avoiding_indexed_address_p (machine_mode mode) |
| 9009 |
{ |
| 9010 |
unsigned int msize = GET_MODE_SIZE (mode); |
| 9011 |
|
| 9012 |
/* Avoid indexed addressing for modes that have non-indexed load/store |
| 9013 |
instruction forms. On power10, vector pairs have an indexed |
| 9014 |
form, but vector quads don't. */ |
| 9015 |
if (msize > 16) |
| 9016 |
return msize != 32; |
| 9017 |
|
| 9018 |
return (TARGET_AVOID_XFORM && VECTOR_MEM_NONE_P (mode)); |
| 9019 |
} |
| 9020 |
|
| 9021 |
bool |
| 9022 |
legitimate_indirect_address_p (rtx x, int strict) |
| 9023 |
{ |
| 9024 |
return REG_P (x) && INT_REG_OK_FOR_BASE_P (x, strict); |
| 9025 |
} |
| 9026 |
|
| 9027 |
bool |
| 9028 |
macho_lo_sum_memory_operand (rtx x, machine_mode mode) |
| 9029 |
{ |
| 9030 |
if (!TARGET_MACHO || !flag_pic |
| 9031 |
|| mode != SImode || !MEM_P (x)) |
| 9032 |
return false; |
| 9033 |
x = XEXP (x, 0); |
| 9034 |
|
| 9035 |
if (GET_CODE (x) != LO_SUM) |
| 9036 |
return false; |
| 9037 |
if (!REG_P (XEXP (x, 0))) |
| 9038 |
return false; |
| 9039 |
if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 0)) |
| 9040 |
return false; |
| 9041 |
x = XEXP (x, 1); |
| 9042 |
|
| 9043 |
return CONSTANT_P (x); |
| 9044 |
} |
| 9045 |
|
| 9046 |
static bool |
| 9047 |
legitimate_lo_sum_address_p (machine_mode mode, rtx x, int strict) |
| 9048 |
{ |
| 9049 |
if (GET_CODE (x) != LO_SUM) |
| 9050 |
return false; |
| 9051 |
if (!REG_P (XEXP (x, 0))) |
| 9052 |
return false; |
| 9053 |
if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict)) |
| 9054 |
return false; |
| 9055 |
/* quad word addresses are restricted, and we can't use LO_SUM. */ |
| 9056 |
if (mode_supports_dq_form (mode)) |
| 9057 |
return false; |
| 9058 |
x = XEXP (x, 1); |
| 9059 |
|
| 9060 |
if (TARGET_ELF) |
| 9061 |
{ |
| 9062 |
bool large_toc_ok; |
| 9063 |
|
| 9064 |
if (DEFAULT_ABI == ABI_V4 && flag_pic) |
| 9065 |
return false; |
| 9066 |
/* LRA doesn't use LEGITIMIZE_RELOAD_ADDRESS as it usually calls |
| 9067 |
push_reload from reload pass code. LEGITIMIZE_RELOAD_ADDRESS |
| 9068 |
recognizes some LO_SUM addresses as valid although this |
| 9069 |
function says opposite. In most cases, LRA through different |
| 9070 |
transformations can generate correct code for address reloads. |
| 9071 |
It cannot manage only some LO_SUM cases. So we need to add |
| 9072 |
code here saying that some addresses are still valid. */ |
| 9073 |
large_toc_ok = (lra_in_progress && TARGET_CMODEL != CMODEL_SMALL |
| 9074 |
&& small_toc_ref (x, VOIDmode)); |
| 9075 |
if (TARGET_TOC && ! large_toc_ok) |
| 9076 |
return false; |
| 9077 |
if (GET_MODE_NUNITS (mode) != 1) |
| 9078 |
return false; |
| 9079 |
if (GET_MODE_SIZE (mode) > UNITS_PER_WORD |
| 9080 |
&& !(/* ??? Assume floating point reg based on mode? */ |
| 9081 |
TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode))) |
| 9082 |
return false; |
| 9083 |
|
| 9084 |
return CONSTANT_P (x) || large_toc_ok; |
| 9085 |
} |
| 9086 |
else if (TARGET_MACHO) |
| 9087 |
{ |
| 9088 |
if (GET_MODE_NUNITS (mode) != 1) |
| 9089 |
return false; |
| 9090 |
if (GET_MODE_SIZE (mode) > UNITS_PER_WORD |
| 9091 |
&& !(/* see above */ |
| 9092 |
TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode))) |
| 9093 |
return false; |
| 9094 |
#if TARGET_MACHO |
| 9095 |
if (MACHO_DYNAMIC_NO_PIC_P || !flag_pic) |
| 9096 |
return CONSTANT_P (x); |
| 9097 |
#endif |
| 9098 |
/* Macho-O PIC code from here. */ |
| 9099 |
if (GET_CODE (x) == CONST) |
| 9100 |
x = XEXP (x, 0); |
| 9101 |
|
| 9102 |
/* SYMBOL_REFs need to be wrapped in an UNSPEC_MACHOPIC_OFFSET. */ |
| 9103 |
if (SYMBOL_REF_P (x)) |
| 9104 |
return false; |
| 9105 |
|
| 9106 |
/* So this is OK if the wrapped object is const. */ |
| 9107 |
if (GET_CODE (x) == UNSPEC |
| 9108 |
&& XINT (x, 1) == UNSPEC_MACHOPIC_OFFSET) |
| 9109 |
return CONSTANT_P (XVECEXP (x, 0, 0)); |
| 9110 |
return CONSTANT_P (x); |
| 9111 |
} |
| 9112 |
return false; |
| 9113 |
} |
| 9114 |
|
| 9115 |
|
| 9116 |
/* Try machine-dependent ways of modifying an illegitimate address |
| 9117 |
to be legitimate. If we find one, return the new, valid address. |
| 9118 |
This is used from only one place: `memory_address' in explow.cc. |
| 9119 |
|
| 9120 |
OLDX is the address as it was before break_out_memory_refs was |
| 9121 |
called. In some cases it is useful to look at this to decide what |
| 9122 |
needs to be done. |
| 9123 |
|
| 9124 |
It is always safe for this function to do nothing. It exists to |
| 9125 |
recognize opportunities to optimize the output. |
| 9126 |
|
| 9127 |
On RS/6000, first check for the sum of a register with a constant |
| 9128 |
integer that is out of range. If so, generate code to add the |
| 9129 |
constant with the low-order 16 bits masked to the register and force |
| 9130 |
this result into another register (this can be done with `cau'). |
| 9131 |
Then generate an address of REG+(CONST&0xffff), allowing for the |
| 9132 |
possibility of bit 16 being a one. |
| 9133 |
|
| 9134 |
Then check for the sum of a register and something not constant, try to |
| 9135 |
load the other things into a register and return the sum. */ |
| 9136 |
|
| 9137 |
static rtx |
| 9138 |
rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, |
| 9139 |
machine_mode mode) |
| 9140 |
{ |
| 9141 |
unsigned int extra; |
| 9142 |
|
| 9143 |
if (!reg_offset_addressing_ok_p (mode) |
| 9144 |
|| mode_supports_dq_form (mode)) |
| 9145 |
{ |
| 9146 |
if (virtual_stack_registers_memory_p (x)) |
| 9147 |
return x; |
| 9148 |
|
| 9149 |
/* In theory we should not be seeing addresses of the form reg+0, |
| 9150 |
but just in case it is generated, optimize it away. */ |
| 9151 |
if (GET_CODE (x) == PLUS && XEXP (x, 1) == const0_rtx) |
| 9152 |
return force_reg (Pmode, XEXP (x, 0)); |
| 9153 |
|
| 9154 |
/* For TImode with load/store quad, restrict addresses to just a single |
| 9155 |
pointer, so it works with both GPRs and VSX registers. */ |
| 9156 |
/* Make sure both operands are registers. */ |
| 9157 |
else if (GET_CODE (x) == PLUS |
| 9158 |
&& (mode != TImode || !TARGET_VSX)) |
| 9159 |
return gen_rtx_PLUS (Pmode, |
| 9160 |
force_reg (Pmode, XEXP (x, 0)), |
| 9161 |
force_reg (Pmode, XEXP (x, 1))); |
| 9162 |
else |
| 9163 |
return force_reg (Pmode, x); |
| 9164 |
} |
| 9165 |
if (SYMBOL_REF_P (x) && !TARGET_MACHO) |
| 9166 |
{ |
| 9167 |
enum tls_model model = SYMBOL_REF_TLS_MODEL (x); |
| 9168 |
if (model != 0) |
| 9169 |
return rs6000_legitimize_tls_address (x, model); |
| 9170 |
} |
| 9171 |
|
| 9172 |
extra = 0; |
| 9173 |
switch (mode) |
| 9174 |
{ |
| 9175 |
case E_TFmode: |
| 9176 |
case E_TDmode: |
| 9177 |
case E_TImode: |
| 9178 |
case E_PTImode: |
| 9179 |
case E_IFmode: |
| 9180 |
case E_KFmode: |
| 9181 |
/* As in legitimate_offset_address_p we do not assume |
| 9182 |
worst-case. The mode here is just a hint as to the registers |
| 9183 |
used. A TImode is usually in gprs, but may actually be in |
| 9184 |
fprs. Leave worst-case scenario for reload to handle via |
| 9185 |
insn constraints. PTImode is only GPRs. */ |
| 9186 |
extra = 8; |
| 9187 |
break; |
| 9188 |
default: |
| 9189 |
break; |
| 9190 |
} |
| 9191 |
|
| 9192 |
if (GET_CODE (x) == PLUS |
| 9193 |
&& REG_P (XEXP (x, 0)) |
| 9194 |
&& CONST_INT_P (XEXP (x, 1)) |
| 9195 |
&& ((unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) |
| 9196 |
>= 0x10000 - extra)) |
| 9197 |
{ |
| 9198 |
HOST_WIDE_INT high_int, low_int; |
| 9199 |
rtx sum; |
| 9200 |
low_int = sext_hwi (INTVAL (XEXP (x, 1)), 16); |
| 9201 |
if (low_int >= 0x8000 - extra) |
| 9202 |
low_int = 0; |
| 9203 |
high_int = INTVAL (XEXP (x, 1)) - low_int; |
| 9204 |
sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (x, 0), |
| 9205 |
gen_int_mode (high_int, Pmode)), 0); |
| 9206 |
return plus_constant (Pmode, sum, low_int); |
| 9207 |
} |
| 9208 |
else if (GET_CODE (x) == PLUS |
| 9209 |
&& REG_P (XEXP (x, 0)) |
| 9210 |
&& !CONST_INT_P (XEXP (x, 1)) |
| 9211 |
&& GET_MODE_NUNITS (mode) == 1 |
| 9212 |
&& (GET_MODE_SIZE (mode) <= UNITS_PER_WORD |
| 9213 |
|| (/* ??? Assume floating point reg based on mode? */ |
| 9214 |
TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode))) |
| 9215 |
&& !avoiding_indexed_address_p (mode)) |
| 9216 |
{ |
| 9217 |
return gen_rtx_PLUS (Pmode, XEXP (x, 0), |
| 9218 |
force_reg (Pmode, force_operand (XEXP (x, 1), 0))); |
| 9219 |
} |
| 9220 |
else if ((TARGET_ELF |
| 9221 |
#if TARGET_MACHO |
| 9222 |
|| !MACHO_DYNAMIC_NO_PIC_P |
| 9223 |
#endif |
| 9224 |
) |
| 9225 |
&& TARGET_32BIT |
| 9226 |
&& TARGET_NO_TOC_OR_PCREL |
| 9227 |
&& !flag_pic |
| 9228 |
&& !CONST_INT_P (x) |
| 9229 |
&& !CONST_WIDE_INT_P (x) |
| 9230 |
&& !CONST_DOUBLE_P (x) |
| 9231 |
&& CONSTANT_P (x) |
| 9232 |
&& GET_MODE_NUNITS (mode) == 1 |
| 9233 |
&& (GET_MODE_SIZE (mode) <= UNITS_PER_WORD |
| 9234 |
|| (/* ??? Assume floating point reg based on mode? */ |
| 9235 |
TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode)))) |
| 9236 |
{ |
| 9237 |
rtx reg = gen_reg_rtx (Pmode); |
| 9238 |
if (TARGET_ELF) |
| 9239 |
emit_insn (gen_elf_high (reg, x)); |
| 9240 |
else |
| 9241 |
emit_insn (gen_macho_high (Pmode, reg, x)); |
| 9242 |
return gen_rtx_LO_SUM (Pmode, reg, x); |
| 9243 |
} |
| 9244 |
else if (TARGET_TOC |
| 9245 |
&& SYMBOL_REF_P (x) |
| 9246 |
&& constant_pool_expr_p (x) |
| 9247 |
&& ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode)) |
| 9248 |
return create_TOC_reference (x, NULL_RTX); |
| 9249 |
else |
| 9250 |
return x; |
| 9251 |
} |
| 9252 |
|
| 9253 |
/* Debug version of rs6000_legitimize_address. */ |
| 9254 |
static rtx |
| 9255 |
rs6000_debug_legitimize_address (rtx x, rtx oldx, machine_mode mode) |
| 9256 |
{ |
| 9257 |
rtx ret; |
| 9258 |
rtx_insn *insns; |
| 9259 |
|
| 9260 |
start_sequence (); |
| 9261 |
ret = rs6000_legitimize_address (x, oldx, mode); |
| 9262 |
insns = get_insns (); |
| 9263 |
end_sequence (); |
| 9264 |
|
| 9265 |
if (ret != x) |
| 9266 |
{ |
| 9267 |
fprintf (stderr, |
| 9268 |
"\nrs6000_legitimize_address: mode %s, old code %s, " |
| 9269 |
"new code %s, modified\n", |
| 9270 |
GET_MODE_NAME (mode), GET_RTX_NAME (GET_CODE (x)), |
| 9271 |
GET_RTX_NAME (GET_CODE (ret))); |
| 9272 |
|
| 9273 |
fprintf (stderr, "Original address:\n"); |
| 9274 |
debug_rtx (x); |
| 9275 |
|
| 9276 |
fprintf (stderr, "oldx:\n"); |
| 9277 |
debug_rtx (oldx); |
| 9278 |
|
| 9279 |
fprintf (stderr, "New address:\n"); |
| 9280 |
debug_rtx (ret); |
| 9281 |
|
| 9282 |
if (insns) |
| 9283 |
{ |
| 9284 |
fprintf (stderr, "Insns added:\n"); |
| 9285 |
debug_rtx_list (insns, 20); |
| 9286 |
} |
| 9287 |
} |
| 9288 |
else |
| 9289 |
{ |
| 9290 |
fprintf (stderr, |
| 9291 |
"\nrs6000_legitimize_address: mode %s, code %s, no change:\n", |
| 9292 |
GET_MODE_NAME (mode), GET_RTX_NAME (GET_CODE (x))); |
| 9293 |
|
| 9294 |
debug_rtx (x); |
| 9295 |
} |
| 9296 |
|
| 9297 |
if (insns) |
| 9298 |
emit_insn (insns); |
| 9299 |
|
| 9300 |
return ret; |
| 9301 |
} |
| 9302 |
|
| 9303 |
/* This is called from dwarf2out.cc via TARGET_ASM_OUTPUT_DWARF_DTPREL. |
| 9304 |
We need to emit DTP-relative relocations. */ |
| 9305 |
|
| 9306 |
static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED; |
| 9307 |
static void |
| 9308 |
rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x) |
| 9309 |
{ |
| 9310 |
switch (size) |
| 9311 |
{ |
| 9312 |
case 4: |
| 9313 |
fputs ("\t.long\t", file); |
| 9314 |
break; |
| 9315 |
case 8: |
| 9316 |
fputs (DOUBLE_INT_ASM_OP, file); |
| 9317 |
break; |
| 9318 |
default: |
| 9319 |
gcc_unreachable (); |
| 9320 |
} |
| 9321 |
output_addr_const (file, x); |
| 9322 |
if (TARGET_ELF) |
| 9323 |
fputs ("@dtprel+0x8000", file); |
| 9324 |
} |
| 9325 |
|
| 9326 |
/* Return true if X is a symbol that refers to real (rather than emulated) |
| 9327 |
TLS. */ |
| 9328 |
|
| 9329 |
static bool |
| 9330 |
rs6000_real_tls_symbol_ref_p (rtx x) |
| 9331 |
{ |
| 9332 |
return (SYMBOL_REF_P (x) |
| 9333 |
&& SYMBOL_REF_TLS_MODEL (x) >= TLS_MODEL_REAL); |
| 9334 |
} |
| 9335 |
|
| 9336 |
/* In the name of slightly smaller debug output, and to cater to |
| 9337 |
general assembler lossage, recognize various UNSPEC sequences |
| 9338 |
and turn them back into a direct symbol reference. */ |
| 9339 |
|
| 9340 |
static rtx |
| 9341 |
rs6000_delegitimize_address (rtx orig_x) |
| 9342 |
{ |
| 9343 |
rtx x, y, offset; |
| 9344 |
|
| 9345 |
/* UNSPEC_FUSION_GPR is created by the peephole2 for power8 fusion. It |
| 9346 |
encodes loading up the high part of the address of a TOC reference along |
| 9347 |
with a load of a GPR using the same base register used for the load. We |
| 9348 |
return the original SYMBOL_REF. |
| 9349 |
|
| 9350 |
(set (reg:INT1 <reg> |
| 9351 |
(unspec:INT1 [<combined-address>] UNSPEC_FUSION_GPR))) |
| 9352 |
|
| 9353 |
UNSPEC_PCREL_OPT_LD_ADDR is used by the power10 PCREL_OPT pass. These |
| 9354 |
UNSPECs include the external SYMBOL_REF along with the value being loaded. |
| 9355 |
We return the original SYMBOL_REF. |
| 9356 |
|
| 9357 |
(parallel [(set (reg:DI <base-reg>) |
| 9358 |
(unspec:DI [(symbol_ref <symbol>) |
| 9359 |
(const_int <marker>)] |
| 9360 |
UNSPEC_PCREL_OPT_LD_ADDR)) |
| 9361 |
(set (reg:DI <load-reg>) |
| 9362 |
(unspec:DI [(const_int 0)] |
| 9363 |
UNSPEC_PCREL_OPT_LD_DATA))]) |
| 9364 |
|
| 9365 |
UNSPEC_PCREL_OPT_LD_SAME_REG is an alternative that is used if the |
| 9366 |
GPR being loaded is the same as the GPR used to hold the external address. |
| 9367 |
|
| 9368 |
(set (reg:DI <base-reg>) |
| 9369 |
(unspec:DI [(symbol_ref <symbol>) |
| 9370 |
(const_int <marker>)] |
| 9371 |
UNSPEC_PCREL_OPT_LD_SAME_REG)) |
| 9372 |
|
| 9373 |
UNSPEC_PCREL_OPT_ST_ADDR is used by the power10 PCREL_OPT pass. This |
| 9374 |
UNSPEC include the external SYMBOL_REF along with the value being loaded. |
| 9375 |
We return the original SYMBOL_REF. |
| 9376 |
|
| 9377 |
(parallel [(set (reg:DI <base-reg>) |
| 9378 |
(unspec:DI [(symbol_ref <symbol>) |
| 9379 |
(const_int <marker>)] |
| 9380 |
UNSPEC_PCREL_OPT_ST_ADDR)) |
| 9381 |
(use (reg <store-reg>))]) */ |
| 9382 |
|
| 9383 |
if (GET_CODE (orig_x) == UNSPEC) |
| 9384 |
switch (XINT (orig_x, 1)) |
| 9385 |
{ |
| 9386 |
case UNSPEC_FUSION_GPR: |
| 9387 |
case UNSPEC_PCREL_OPT_LD_ADDR: |
| 9388 |
case UNSPEC_PCREL_OPT_LD_SAME_REG: |
| 9389 |
case UNSPEC_PCREL_OPT_ST_ADDR: |
| 9390 |
orig_x = XVECEXP (orig_x, 0, 0); |
| 9391 |
break; |
| 9392 |
|
| 9393 |
default: |
| 9394 |
break; |
| 9395 |
} |
| 9396 |
|
| 9397 |
orig_x = delegitimize_mem_from_attrs (orig_x); |
| 9398 |
|
| 9399 |
x = orig_x; |
| 9400 |
if (MEM_P (x)) |
| 9401 |
x = XEXP (x, 0); |
| 9402 |
|
| 9403 |
y = x; |
| 9404 |
if (TARGET_CMODEL != CMODEL_SMALL && GET_CODE (y) == LO_SUM) |
| 9405 |
y = XEXP (y, 1); |
| 9406 |
|
| 9407 |
offset = NULL_RTX; |
| 9408 |
if (GET_CODE (y) == PLUS |
| 9409 |
&& GET_MODE (y) == Pmode |
| 9410 |
&& CONST_INT_P (XEXP (y, 1))) |
| 9411 |
{ |
| 9412 |
offset = XEXP (y, 1); |
| 9413 |
y = XEXP (y, 0); |
| 9414 |
} |
| 9415 |
|
| 9416 |
if (GET_CODE (y) == UNSPEC && XINT (y, 1) == UNSPEC_TOCREL) |
| 9417 |
{ |
| 9418 |
y = XVECEXP (y, 0, 0); |
| 9419 |
|
| 9420 |
#ifdef HAVE_AS_TLS |
| 9421 |
/* Do not associate thread-local symbols with the original |
| 9422 |
constant pool symbol. */ |
| 9423 |
if (TARGET_XCOFF |
| 9424 |
&& SYMBOL_REF_P (y) |
| 9425 |
&& CONSTANT_POOL_ADDRESS_P (y) |
| 9426 |
&& rs6000_real_tls_symbol_ref_p (get_pool_constant (y))) |
| 9427 |
return orig_x; |
| 9428 |
#endif |
| 9429 |
|
| 9430 |
if (offset != NULL_RTX) |
| 9431 |
y = gen_rtx_PLUS (Pmode, y, offset); |
| 9432 |
if (!MEM_P (orig_x)) |
| 9433 |
return y; |
| 9434 |
else |
| 9435 |
return replace_equiv_address_nv (orig_x, y); |
| 9436 |
} |
| 9437 |
|
| 9438 |
if (TARGET_MACHO |
| 9439 |
&& GET_CODE (orig_x) == LO_SUM |
| 9440 |
&& GET_CODE (XEXP (orig_x, 1)) == CONST) |
| 9441 |
{ |
| 9442 |
y = XEXP (XEXP (orig_x, 1), 0); |
| 9443 |
if (GET_CODE (y) == UNSPEC && XINT (y, 1) == UNSPEC_MACHOPIC_OFFSET) |
| 9444 |
return XVECEXP (y, 0, 0); |
| 9445 |
} |
| 9446 |
|
| 9447 |
return orig_x; |
| 9448 |
} |
| 9449 |
|
| 9450 |
/* Return true if X shouldn't be emitted into the debug info. |
| 9451 |
The linker doesn't like .toc section references from |
| 9452 |
.debug_* sections, so reject .toc section symbols. */ |
| 9453 |
|
| 9454 |
static bool |
| 9455 |
rs6000_const_not_ok_for_debug_p (rtx x) |
| 9456 |
{ |
| 9457 |
if (GET_CODE (x) == UNSPEC) |
| 9458 |
return true; |
| 9459 |
if (SYMBOL_REF_P (x) |
| 9460 |
&& CONSTANT_POOL_ADDRESS_P (x)) |
| 9461 |
{ |
| 9462 |
rtx c = get_pool_constant (x); |
| 9463 |
machine_mode cmode = get_pool_mode (x); |
| 9464 |
if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (c, cmode)) |
| 9465 |
return true; |
| 9466 |
} |
| 9467 |
|
| 9468 |
return false; |
| 9469 |
} |
| 9470 |
|
| 9471 |
/* Implement the TARGET_LEGITIMATE_COMBINED_INSN hook. */ |
| 9472 |
|
| 9473 |
static bool |
| 9474 |
rs6000_legitimate_combined_insn (rtx_insn *insn) |
| 9475 |
{ |
| 9476 |
int icode = INSN_CODE (insn); |
| 9477 |
|
| 9478 |
/* Reject creating doloop insns. Combine should not be allowed |
| 9479 |
to create these for a number of reasons: |
| 9480 |
1) In a nested loop, if combine creates one of these in an |
| 9481 |
outer loop and the register allocator happens to allocate ctr |
| 9482 |
to the outer loop insn, then the inner loop can't use ctr. |
| 9483 |
Inner loops ought to be more highly optimized. |
| 9484 |
2) Combine often wants to create one of these from what was |
| 9485 |
originally a three insn sequence, first combining the three |
| 9486 |
insns to two, then to ctrsi/ctrdi. When ctrsi/ctrdi is not |
| 9487 |
allocated ctr, the splitter takes use back to the three insn |
| 9488 |
sequence. It's better to stop combine at the two insn |
| 9489 |
sequence. |
| 9490 |
3) Faced with not being able to allocate ctr for ctrsi/crtdi |
| 9491 |
insns, the register allocator sometimes uses floating point |
| 9492 |
or vector registers for the pseudo. Since ctrsi/ctrdi is a |
| 9493 |
jump insn and output reloads are not implemented for jumps, |
| 9494 |
the ctrsi/ctrdi splitters need to handle all possible cases. |
| 9495 |
That's a pain, and it gets to be seriously difficult when a |
| 9496 |
splitter that runs after reload needs memory to transfer from |
| 9497 |
a gpr to fpr. See PR70098 and PR71763 which are not fixed |
| 9498 |
for the difficult case. It's better to not create problems |
| 9499 |
in the first place. */ |
| 9500 |
if (icode != CODE_FOR_nothing |
| 9501 |
&& (icode == CODE_FOR_bdz_si |
| 9502 |
|| icode == CODE_FOR_bdz_di |
| 9503 |
|| icode == CODE_FOR_bdnz_si |
| 9504 |
|| icode == CODE_FOR_bdnz_di |
| 9505 |
|| icode == CODE_FOR_bdztf_si |
| 9506 |
|| icode == CODE_FOR_bdztf_di |
| 9507 |
|| icode == CODE_FOR_bdnztf_si |
| 9508 |
|| icode == CODE_FOR_bdnztf_di)) |
| 9509 |
return false; |
| 9510 |
|
| 9511 |
return true; |
| 9512 |
} |
| 9513 |
|
| 9514 |
/* Construct the SYMBOL_REF for the tls_get_addr function. */ |
| 9515 |
|
| 9516 |
static GTY(()) rtx rs6000_tls_symbol; |
| 9517 |
static rtx |
| 9518 |
rs6000_tls_get_addr (void) |
| 9519 |
{ |
| 9520 |
if (!rs6000_tls_symbol) |
| 9521 |
rs6000_tls_symbol = init_one_libfunc ("__tls_get_addr"); |
| 9522 |
|
| 9523 |
return rs6000_tls_symbol; |
| 9524 |
} |
| 9525 |
|
| 9526 |
/* Construct the SYMBOL_REF for TLS GOT references. */ |
| 9527 |
|
| 9528 |
static GTY(()) rtx rs6000_got_symbol; |
| 9529 |
rtx |
| 9530 |
rs6000_got_sym (void) |
| 9531 |
{ |
| 9532 |
if (!rs6000_got_symbol) |
| 9533 |
{ |
| 9534 |
rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_"); |
| 9535 |
SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_LOCAL; |
| 9536 |
SYMBOL_REF_FLAGS (rs6000_got_symbol) |= SYMBOL_FLAG_EXTERNAL; |
| 9537 |
} |
| 9538 |
|
| 9539 |
return rs6000_got_symbol; |
| 9540 |
} |
| 9541 |
|
| 9542 |
/* AIX Thread-Local Address support. */ |
| 9543 |
|
| 9544 |
static rtx |
| 9545 |
rs6000_legitimize_tls_address_aix (rtx addr, enum tls_model model) |
| 9546 |
{ |
| 9547 |
rtx sym, mem, tocref, tlsreg, tmpreg, dest; |
| 9548 |
const char *name; |
| 9549 |
char *tlsname; |
| 9550 |
|
| 9551 |
/* Place addr into TOC constant pool. */ |
| 9552 |
sym = force_const_mem (GET_MODE (addr), addr); |
| 9553 |
|
| 9554 |
/* Output the TOC entry and create the MEM referencing the value. */ |
| 9555 |
if (constant_pool_expr_p (XEXP (sym, 0)) |
| 9556 |
&& ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (XEXP (sym, 0)), Pmode)) |
| 9557 |
{ |
| 9558 |
tocref = create_TOC_reference (XEXP (sym, 0), NULL_RTX); |
| 9559 |
mem = gen_const_mem (Pmode, tocref); |
| 9560 |
set_mem_alias_set (mem, get_TOC_alias_set ()); |
| 9561 |
} |
| 9562 |
else |
| 9563 |
return sym; |
| 9564 |
|
| 9565 |
/* Use global-dynamic for local-dynamic. */ |
| 9566 |
if (model == TLS_MODEL_GLOBAL_DYNAMIC |
| 9567 |
|| model == TLS_MODEL_LOCAL_DYNAMIC) |
| 9568 |
{ |
| 9569 |
/* Create new TOC reference for @m symbol. */ |
| 9570 |
name = XSTR (XVECEXP (XEXP (mem, 0), 0, 0), 0); |
| 9571 |
tlsname = XALLOCAVEC (char, strlen (name) + 1); |
| 9572 |
strcpy (tlsname, "*LCM"); |
| 9573 |
strcat (tlsname, name + 3); |
| 9574 |
rtx modaddr = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tlsname)); |
| 9575 |
SYMBOL_REF_FLAGS (modaddr) |= SYMBOL_FLAG_LOCAL; |
| 9576 |
tocref = create_TOC_reference (modaddr, NULL_RTX); |
| 9577 |
rtx modmem = gen_const_mem (Pmode, tocref); |
| 9578 |
set_mem_alias_set (modmem, get_TOC_alias_set ()); |
| 9579 |
|
| 9580 |
rtx modreg = gen_reg_rtx (Pmode); |
| 9581 |
emit_insn (gen_rtx_SET (modreg, modmem)); |
| 9582 |
|
| 9583 |
tmpreg = gen_reg_rtx (Pmode); |
| 9584 |
emit_insn (gen_rtx_SET (tmpreg, mem)); |
| 9585 |
|
| 9586 |
dest = gen_reg_rtx (Pmode); |
| 9587 |
if (TARGET_32BIT) |
| 9588 |
emit_insn (gen_tls_get_addrsi (dest, modreg, tmpreg)); |
| 9589 |
else |
| 9590 |
emit_insn (gen_tls_get_addrdi (dest, modreg, tmpreg)); |
| 9591 |
return dest; |
| 9592 |
} |
| 9593 |
/* Obtain TLS pointer: 32 bit call or 64 bit GPR 13. */ |
| 9594 |
else if (TARGET_32BIT) |
| 9595 |
{ |
| 9596 |
tlsreg = gen_reg_rtx (SImode); |
| 9597 |
emit_insn (gen_tls_get_tpointer (tlsreg)); |
| 9598 |
} |
| 9599 |
else |
| 9600 |
{ |
| 9601 |
tlsreg = gen_rtx_REG (DImode, 13); |
| 9602 |
xcoff_tls_exec_model_detected = true; |
| 9603 |
} |
| 9604 |
|
| 9605 |
/* Load the TOC value into temporary register. */ |
| 9606 |
tmpreg = gen_reg_rtx (Pmode); |
| 9607 |
emit_insn (gen_rtx_SET (tmpreg, mem)); |
| 9608 |
set_unique_reg_note (get_last_insn (), REG_EQUAL, |
| 9609 |
gen_rtx_MINUS (Pmode, addr, tlsreg)); |
| 9610 |
|
| 9611 |
/* Add TOC symbol value to TLS pointer. */ |
| 9612 |
dest = force_reg (Pmode, gen_rtx_PLUS (Pmode, tmpreg, tlsreg)); |
| 9613 |
|
| 9614 |
return dest; |
| 9615 |
} |
| 9616 |
|
| 9617 |
/* Passes the tls arg value for global dynamic and local dynamic |
| 9618 |
emit_library_call_value in rs6000_legitimize_tls_address to |
| 9619 |
rs6000_call_aix and rs6000_call_sysv. This is used to emit the |
| 9620 |
marker relocs put on __tls_get_addr calls. */ |
| 9621 |
static rtx global_tlsarg; |
| 9622 |
|
| 9623 |
/* ADDR contains a thread-local SYMBOL_REF. Generate code to compute |
| 9624 |
this (thread-local) address. */ |
| 9625 |
|
| 9626 |
static rtx |
| 9627 |
rs6000_legitimize_tls_address (rtx addr, enum tls_model model) |
| 9628 |
{ |
| 9629 |
rtx dest, insn; |
| 9630 |
|
| 9631 |
if (TARGET_XCOFF) |
| 9632 |
return rs6000_legitimize_tls_address_aix (addr, model); |
| 9633 |
|
| 9634 |
dest = gen_reg_rtx (Pmode); |
| 9635 |
if (model == TLS_MODEL_LOCAL_EXEC |
| 9636 |
&& (rs6000_tls_size == 16 || rs6000_pcrel_p ())) |
| 9637 |
{ |
| 9638 |
rtx tlsreg; |
| 9639 |
|
| 9640 |
if (TARGET_64BIT) |
| 9641 |
{ |
| 9642 |
tlsreg = gen_rtx_REG (Pmode, 13); |
| 9643 |
insn = gen_tls_tprel_64 (dest, tlsreg, addr); |
| 9644 |
} |
| 9645 |
else |
| 9646 |
{ |
| 9647 |
tlsreg = gen_rtx_REG (Pmode, 2); |
| 9648 |
insn = gen_tls_tprel_32 (dest, tlsreg, addr); |
| 9649 |
} |
| 9650 |
emit_insn (insn); |
| 9651 |
} |
| 9652 |
else if (model == TLS_MODEL_LOCAL_EXEC && rs6000_tls_size == 32) |
| 9653 |
{ |
| 9654 |
rtx tlsreg, tmp; |
| 9655 |
|
| 9656 |
tmp = gen_reg_rtx (Pmode); |
| 9657 |
if (TARGET_64BIT) |
| 9658 |
{ |
| 9659 |
tlsreg = gen_rtx_REG (Pmode, 13); |
| 9660 |
insn = gen_tls_tprel_ha_64 (tmp, tlsreg, addr); |
| 9661 |
} |
| 9662 |
else |
| 9663 |
{ |
| 9664 |
tlsreg = gen_rtx_REG (Pmode, 2); |
| 9665 |
insn = gen_tls_tprel_ha_32 (tmp, tlsreg, addr); |
| 9666 |
} |
| 9667 |
emit_insn (insn); |
| 9668 |
if (TARGET_64BIT) |
| 9669 |
insn = gen_tls_tprel_lo_64 (dest, tmp, addr); |
| 9670 |
else |
| 9671 |
insn = gen_tls_tprel_lo_32 (dest, tmp, addr); |
| 9672 |
emit_insn (insn); |
| 9673 |
} |
| 9674 |
else |
| 9675 |
{ |
| 9676 |
rtx got, tga, tmp1, tmp2; |
| 9677 |
|
| 9678 |
/* We currently use relocations like @got@tlsgd for tls, which |
| 9679 |
means the linker will handle allocation of tls entries, placing |
| 9680 |
them in the .got section. So use a pointer to the .got section, |
| 9681 |
not one to secondary TOC sections used by 64-bit -mminimal-toc, |
| 9682 |
or to secondary GOT sections used by 32-bit -fPIC. */ |
| 9683 |
if (rs6000_pcrel_p ()) |
| 9684 |
got = const0_rtx; |
| 9685 |
else if (TARGET_64BIT) |
| 9686 |
got = gen_rtx_REG (Pmode, 2); |
| 9687 |
else |
| 9688 |
{ |
| 9689 |
if (flag_pic == 1) |
| 9690 |
got = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM); |
| 9691 |
else |
| 9692 |
{ |
| 9693 |
rtx gsym = rs6000_got_sym (); |
| 9694 |
got = gen_reg_rtx (Pmode); |
| 9695 |
if (flag_pic == 0) |
| 9696 |
rs6000_emit_move (got, gsym, Pmode); |
| 9697 |
else |
| 9698 |
{ |
| 9699 |
rtx mem, lab; |
| 9700 |
|
| 9701 |
tmp1 = gen_reg_rtx (Pmode); |
| 9702 |
tmp2 = gen_reg_rtx (Pmode); |
| 9703 |
mem = gen_const_mem (Pmode, tmp1); |
| 9704 |
lab = gen_label_rtx (); |
| 9705 |
emit_insn (gen_load_toc_v4_PIC_1b (gsym, lab)); |
| 9706 |
emit_move_insn (tmp1, gen_rtx_REG (Pmode, LR_REGNO)); |
| 9707 |
if (TARGET_LINK_STACK) |
| 9708 |
emit_insn (gen_addsi3 (tmp1, tmp1, GEN_INT (4))); |
| 9709 |
emit_move_insn (tmp2, mem); |
| 9710 |
rtx_insn *last = emit_insn (gen_addsi3 (got, tmp1, tmp2)); |
| 9711 |
set_unique_reg_note (last, REG_EQUAL, gsym); |
| 9712 |
} |
| 9713 |
} |
| 9714 |
} |
| 9715 |
|
| 9716 |
if (model == TLS_MODEL_GLOBAL_DYNAMIC) |
| 9717 |
{ |
| 9718 |
rtx arg = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, addr, got), |
| 9719 |
UNSPEC_TLSGD); |
| 9720 |
tga = rs6000_tls_get_addr (); |
| 9721 |
rtx argreg = gen_rtx_REG (Pmode, 3); |
| 9722 |
emit_insn (gen_rtx_SET (argreg, arg)); |
| 9723 |
global_tlsarg = arg; |
| 9724 |
emit_library_call_value (tga, dest, LCT_CONST, Pmode, argreg, Pmode); |
| 9725 |
global_tlsarg = NULL_RTX; |
| 9726 |
|
| 9727 |
/* Make a note so that the result of this call can be CSEd. */ |
| 9728 |
rtvec vec = gen_rtvec (1, copy_rtx (arg)); |
| 9729 |
rtx uns = gen_rtx_UNSPEC (Pmode, vec, UNSPEC_TLS_GET_ADDR); |
| 9730 |
set_unique_reg_note (get_last_insn (), REG_EQUAL, uns); |
| 9731 |
} |
| 9732 |
else if (model == TLS_MODEL_LOCAL_DYNAMIC) |
| 9733 |
{ |
| 9734 |
rtx arg = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, got), UNSPEC_TLSLD); |
| 9735 |
tga = rs6000_tls_get_addr (); |
| 9736 |
tmp1 = gen_reg_rtx (Pmode); |
| 9737 |
rtx argreg = gen_rtx_REG (Pmode, 3); |
| 9738 |
emit_insn (gen_rtx_SET (argreg, arg)); |
| 9739 |
global_tlsarg = arg; |
| 9740 |
emit_library_call_value (tga, tmp1, LCT_CONST, Pmode, argreg, Pmode); |
| 9741 |
global_tlsarg = NULL_RTX; |
| 9742 |
|
| 9743 |
/* Make a note so that the result of this call can be CSEd. */ |
| 9744 |
rtvec vec = gen_rtvec (1, copy_rtx (arg)); |
| 9745 |
rtx uns = gen_rtx_UNSPEC (Pmode, vec, UNSPEC_TLS_GET_ADDR); |
| 9746 |
set_unique_reg_note (get_last_insn (), REG_EQUAL, uns); |
| 9747 |
|
| 9748 |
if (rs6000_tls_size == 16 || rs6000_pcrel_p ()) |
| 9749 |
{ |
| 9750 |
if (TARGET_64BIT) |
| 9751 |
insn = gen_tls_dtprel_64 (dest, tmp1, addr); |
| 9752 |
else |
| 9753 |
insn = gen_tls_dtprel_32 (dest, tmp1, addr); |
| 9754 |
} |
| 9755 |
else if (rs6000_tls_size == 32) |
| 9756 |
{ |
| 9757 |
tmp2 = gen_reg_rtx (Pmode); |
| 9758 |
if (TARGET_64BIT) |
| 9759 |
insn = gen_tls_dtprel_ha_64 (tmp2, tmp1, addr); |
| 9760 |
else |
| 9761 |
insn = gen_tls_dtprel_ha_32 (tmp2, tmp1, addr); |
| 9762 |
emit_insn (insn); |
| 9763 |
if (TARGET_64BIT) |
| 9764 |
insn = gen_tls_dtprel_lo_64 (dest, tmp2, addr); |
| 9765 |
else |
| 9766 |
insn = gen_tls_dtprel_lo_32 (dest, tmp2, addr); |
| 9767 |
} |
| 9768 |
else |
| 9769 |
{ |
| 9770 |
tmp2 = gen_reg_rtx (Pmode); |
| 9771 |
if (TARGET_64BIT) |
| 9772 |
insn = gen_tls_got_dtprel_64 (tmp2, got, addr); |
| 9773 |
else |
| 9774 |
insn = gen_tls_got_dtprel_32 (tmp2, got, addr); |
| 9775 |
emit_insn (insn); |
| 9776 |
insn = gen_rtx_SET (dest, gen_rtx_PLUS (Pmode, tmp2, tmp1)); |
| 9777 |
} |
| 9778 |
emit_insn (insn); |
| 9779 |
} |
| 9780 |
else |
| 9781 |
{ |
| 9782 |
/* IE, or 64-bit offset LE. */ |
| 9783 |
tmp2 = gen_reg_rtx (Pmode); |
| 9784 |
if (TARGET_64BIT) |
| 9785 |
insn = gen_tls_got_tprel_64 (tmp2, got, addr); |
| 9786 |
else |
| 9787 |
insn = gen_tls_got_tprel_32 (tmp2, got, addr); |
| 9788 |
emit_insn (insn); |
| 9789 |
if (rs6000_pcrel_p ()) |
| 9790 |
{ |
| 9791 |
if (TARGET_64BIT) |
| 9792 |
insn = gen_tls_tls_pcrel_64 (dest, tmp2, addr); |
| 9793 |
else |
| 9794 |
insn = gen_tls_tls_pcrel_32 (dest, tmp2, addr); |
| 9795 |
} |
| 9796 |
else if (TARGET_64BIT) |
| 9797 |
insn = gen_tls_tls_64 (dest, tmp2, addr); |
| 9798 |
else |
| 9799 |
insn = gen_tls_tls_32 (dest, tmp2, addr); |
| 9800 |
emit_insn (insn); |
| 9801 |
} |
| 9802 |
} |
| 9803 |
|
| 9804 |
return dest; |
| 9805 |
} |
| 9806 |
|
| 9807 |
/* Only create the global variable for the stack protect guard if we are using |
| 9808 |
the global flavor of that guard. */ |
| 9809 |
static tree |
| 9810 |
rs6000_init_stack_protect_guard (void) |
| 9811 |
{ |
| 9812 |
if (rs6000_stack_protector_guard == SSP_GLOBAL) |
| 9813 |
return default_stack_protect_guard (); |
| 9814 |
|
| 9815 |
return NULL_TREE; |
| 9816 |
} |
| 9817 |
|
| 9818 |
/* Implement TARGET_CANNOT_FORCE_CONST_MEM. */ |
| 9819 |
|
| 9820 |
static bool |
| 9821 |
rs6000_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x) |
| 9822 |
{ |
| 9823 |
/* If GET_CODE (x) is HIGH, the 'X' represets the high part of a symbol_ref. |
| 9824 |
It can not be put into a constant pool. e.g. |
| 9825 |
(high:DI (unspec:DI [(symbol_ref/u:DI ("*.LC0")..) |
| 9826 |
(high:DI (symbol_ref:DI ("var")..)). */ |
| 9827 |
if (GET_CODE (x) == HIGH) |
| 9828 |
return true; |
| 9829 |
|
| 9830 |
/* A TLS symbol in the TOC cannot contain a sum. */ |
| 9831 |
if (GET_CODE (x) == CONST |
| 9832 |
&& GET_CODE (XEXP (x, 0)) == PLUS |
| 9833 |
&& SYMBOL_REF_P (XEXP (XEXP (x, 0), 0)) |
| 9834 |
&& SYMBOL_REF_TLS_MODEL (XEXP (XEXP (x, 0), 0)) != 0) |
| 9835 |
return true; |
| 9836 |
|
| 9837 |
/* Allow AIX TOC TLS symbols in the constant pool, |
| 9838 |
but not ELF TLS symbols. */ |
| 9839 |
return TARGET_ELF && tls_referenced_p (x); |
| 9840 |
} |
| 9841 |
|
| 9842 |
/* Return true iff the given SYMBOL_REF refers to a constant pool entry |
| 9843 |
that we have put in the TOC, or for cmodel=medium, if the SYMBOL_REF |
| 9844 |
can be addressed relative to the toc pointer. */ |
| 9845 |
|
| 9846 |
static bool |
| 9847 |
use_toc_relative_ref (rtx sym, machine_mode mode) |
| 9848 |
{ |
| 9849 |
return ((constant_pool_expr_p (sym) |
| 9850 |
&& ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (sym), |
| 9851 |
get_pool_mode (sym))) |
| 9852 |
|| (TARGET_CMODEL == CMODEL_MEDIUM |
| 9853 |
&& SYMBOL_REF_LOCAL_P (sym) |
| 9854 |
&& GET_MODE_SIZE (mode) <= POWERPC64_TOC_POINTER_ALIGNMENT)); |
| 9855 |
} |
| 9856 |
|
| 9857 |
/* TARGET_LEGITIMATE_ADDRESS_P recognizes an RTL expression |
| 9858 |
that is a valid memory address for an instruction. |
| 9859 |
The MODE argument is the machine mode for the MEM expression |
| 9860 |
that wants to use this address. |
| 9861 |
|
| 9862 |
On the RS/6000, there are four valid address: a SYMBOL_REF that |
| 9863 |
refers to a constant pool entry of an address (or the sum of it |
| 9864 |
plus a constant), a short (16-bit signed) constant plus a register, |
| 9865 |
the sum of two registers, or a register indirect, possibly with an |
| 9866 |
auto-increment. For DFmode, DDmode and DImode with a constant plus |
| 9867 |
register, we must ensure that both words are addressable or PowerPC64 |
| 9868 |
with offset word aligned. |
| 9869 |
|
| 9870 |
For modes spanning multiple registers (DFmode and DDmode in 32-bit GPRs, |
| 9871 |
32-bit DImode, TImode, TFmode, TDmode), indexed addressing cannot be used |
| 9872 |
because adjacent memory cells are accessed by adding word-sized offsets |
| 9873 |
during assembly output. */ |
| 9874 |
static bool |
| 9875 |
rs6000_legitimate_address_p (machine_mode mode, rtx x, bool reg_ok_strict, |
| 9876 |
code_helper ch = ERROR_MARK) |
| 9877 |
{ |
| 9878 |
bool reg_offset_p = reg_offset_addressing_ok_p (mode); |
| 9879 |
bool quad_offset_p = mode_supports_dq_form (mode); |
| 9880 |
|
| 9881 |
if (TARGET_ELF && RS6000_SYMBOL_REF_TLS_P (x)) |
| 9882 |
return 0; |
| 9883 |
|
| 9884 |
/* lxvl and stxvl doesn't support any addressing modes with PLUS. */ |
| 9885 |
if (ch.is_internal_fn () |
| 9886 |
&& (ch == IFN_LEN_LOAD || ch == IFN_LEN_STORE) |
| 9887 |
&& GET_CODE (x) == PLUS) |
| 9888 |
return 0; |
| 9889 |
|
| 9890 |
/* Handle unaligned altivec lvx/stvx type addresses. */ |
| 9891 |
if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode) |
| 9892 |
&& GET_CODE (x) == AND |
| 9893 |
&& CONST_INT_P (XEXP (x, 1)) |
| 9894 |
&& INTVAL (XEXP (x, 1)) == -16) |
| 9895 |
{ |
| 9896 |
x = XEXP (x, 0); |
| 9897 |
return (legitimate_indirect_address_p (x, reg_ok_strict) |
| 9898 |
|| legitimate_indexed_address_p (x, reg_ok_strict) |
| 9899 |
|| virtual_stack_registers_memory_p (x)); |
| 9900 |
} |
| 9901 |
|
| 9902 |
if (legitimate_indirect_address_p (x, reg_ok_strict)) |
| 9903 |
return 1; |
| 9904 |
if (TARGET_UPDATE |
| 9905 |
&& (GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC) |
| 9906 |
&& mode_supports_pre_incdec_p (mode) |
| 9907 |
&& legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict)) |
| 9908 |
return 1; |
| 9909 |
|
| 9910 |
/* Handle prefixed addresses (PC-relative or 34-bit offset). */ |
| 9911 |
if (address_is_prefixed (x, mode, NON_PREFIXED_DEFAULT)) |
| 9912 |
return 1; |
| 9913 |
|
| 9914 |
/* Handle restricted vector d-form offsets in ISA 3.0. */ |
| 9915 |
if (quad_offset_p) |
| 9916 |
{ |
| 9917 |
if (quad_address_p (x, mode, reg_ok_strict)) |
| 9918 |
return 1; |
| 9919 |
} |
| 9920 |
else if (virtual_stack_registers_memory_p (x)) |
| 9921 |
return 1; |
| 9922 |
|
| 9923 |
else if (reg_offset_p) |
| 9924 |
{ |
| 9925 |
if (legitimate_small_data_p (mode, x)) |
| 9926 |
return 1; |
| 9927 |
if (legitimate_constant_pool_address_p (x, mode, |
| 9928 |
reg_ok_strict || lra_in_progress)) |
| 9929 |
return 1; |
| 9930 |
} |
| 9931 |
|
| 9932 |
/* For TImode, if we have TImode in VSX registers, only allow register |
| 9933 |
indirect addresses. This will allow the values to go in either GPRs |
| 9934 |
or VSX registers without reloading. The vector types would tend to |
| 9935 |
go into VSX registers, so we allow REG+REG, while TImode seems |
| 9936 |
somewhat split, in that some uses are GPR based, and some VSX based. */ |
| 9937 |
/* FIXME: We could loosen this by changing the following to |
| 9938 |
if (mode == TImode && TARGET_QUAD_MEMORY && TARGET_VSX) |
| 9939 |
but currently we cannot allow REG+REG addressing for TImode. See |
| 9940 |
PR72827 for complete details on how this ends up hoodwinking DSE. */ |
| 9941 |
if (mode == TImode && TARGET_VSX) |
| 9942 |
return 0; |
| 9943 |
/* If not REG_OK_STRICT (before reload) let pass any stack offset. */ |
| 9944 |
if (! reg_ok_strict |
| 9945 |
&& reg_offset_p |
| 9946 |
&& GET_CODE (x) == PLUS |
| 9947 |
&& REG_P (XEXP (x, 0)) |
| 9948 |
&& (XEXP (x, 0) == virtual_stack_vars_rtx |
| 9949 |
|| XEXP (x, 0) == arg_pointer_rtx) |
| 9950 |
&& CONST_INT_P (XEXP (x, 1))) |
| 9951 |
return 1; |
| 9952 |
if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict, false)) |
| 9953 |
return 1; |
| 9954 |
if (!FLOAT128_2REG_P (mode) |
| 9955 |
&& (TARGET_HARD_FLOAT |
| 9956 |
|| TARGET_POWERPC64 |
| 9957 |
|| (mode != DFmode && mode != DDmode)) |
| 9958 |
&& (TARGET_POWERPC64 || mode != DImode) |
| 9959 |
&& (mode != TImode || VECTOR_MEM_VSX_P (TImode)) |
| 9960 |
&& mode != PTImode |
| 9961 |
&& !avoiding_indexed_address_p (mode) |
| 9962 |
&& legitimate_indexed_address_p (x, reg_ok_strict)) |
| 9963 |
return 1; |
| 9964 |
if (TARGET_UPDATE && GET_CODE (x) == PRE_MODIFY |
| 9965 |
&& mode_supports_pre_modify_p (mode) |
| 9966 |
&& legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict) |
| 9967 |
&& (rs6000_legitimate_offset_address_p (mode, XEXP (x, 1), |
| 9968 |
reg_ok_strict, false) |
| 9969 |
|| (!avoiding_indexed_address_p (mode) |
| 9970 |
&& legitimate_indexed_address_p (XEXP (x, 1), reg_ok_strict))) |
| 9971 |
&& rtx_equal_p (XEXP (XEXP (x, 1), 0), XEXP (x, 0))) |
| 9972 |
{ |
| 9973 |
/* There is no prefixed version of the load/store with update. */ |
| 9974 |
rtx addr = XEXP (x, 1); |
| 9975 |
return !address_is_prefixed (addr, mode, NON_PREFIXED_DEFAULT); |
| 9976 |
} |
| 9977 |
if (reg_offset_p && !quad_offset_p |
| 9978 |
&& legitimate_lo_sum_address_p (mode, x, reg_ok_strict)) |
| 9979 |
return 1; |
| 9980 |
return 0; |
| 9981 |
} |
| 9982 |
|
| 9983 |
/* Debug version of rs6000_legitimate_address_p. */ |
| 9984 |
static bool |
| 9985 |
rs6000_debug_legitimate_address_p (machine_mode mode, rtx x, bool reg_ok_strict, |
| 9986 |
code_helper ch) |
| 9987 |
{ |
| 9988 |
bool ret = rs6000_legitimate_address_p (mode, x, reg_ok_strict, ch); |
| 9989 |
fprintf (stderr, |
| 9990 |
"\nrs6000_legitimate_address_p: return = %s, mode = %s, " |
| 9991 |
"strict = %d, reload = %s, code = %s\n", |
| 9992 |
ret ? "true" : "false", |
| 9993 |
GET_MODE_NAME (mode), |
| 9994 |
reg_ok_strict, |
| 9995 |
(reload_completed ? "after" : "before"), |
| 9996 |
GET_RTX_NAME (GET_CODE (x))); |
| 9997 |
debug_rtx (x); |
| 9998 |
|
| 9999 |
return ret; |
| 10000 |
} |
| 10001 |
|
| 10002 |
/* Implement TARGET_MODE_DEPENDENT_ADDRESS_P. */ |
| 10003 |
|
| 10004 |
static bool |
| 10005 |
rs6000_mode_dependent_address_p (const_rtx addr, |
| 10006 |
addr_space_t as ATTRIBUTE_UNUSED) |
| 10007 |
{ |
| 10008 |
return rs6000_mode_dependent_address_ptr (addr); |
| 10009 |
} |
| 10010 |
|
| 10011 |
/* Go to LABEL if ADDR (a legitimate address expression) |
| 10012 |
has an effect that depends on the machine mode it is used for. |
| 10013 |
|
| 10014 |
On the RS/6000 this is true of all integral offsets (since AltiVec |
| 10015 |
and VSX modes don't allow them) or is a pre-increment or decrement. |
| 10016 |
|
| 10017 |
??? Except that due to conceptual problems in offsettable_address_p |
| 10018 |
we can't really report the problems of integral offsets. So leave |
| 10019 |
this assuming that the adjustable offset must be valid for the |
| 10020 |
sub-words of a TFmode operand, which is what we had before. */ |
| 10021 |
|
| 10022 |
static bool |
| 10023 |
rs6000_mode_dependent_address (const_rtx addr) |
| 10024 |
{ |
| 10025 |
switch (GET_CODE (addr)) |
| 10026 |
{ |
| 10027 |
case PLUS: |
| 10028 |
/* Any offset from virtual_stack_vars_rtx and arg_pointer_rtx |
| 10029 |
is considered a legitimate address before reload, so there |
| 10030 |
are no offset restrictions in that case. Note that this |
| 10031 |
condition is safe in strict mode because any address involving |
| 10032 |
virtual_stack_vars_rtx or arg_pointer_rtx would already have |
| 10033 |
been rejected as illegitimate. */ |
| 10034 |
if (XEXP (addr, 0) != virtual_stack_vars_rtx |
| 10035 |
&& XEXP (addr, 0) != arg_pointer_rtx |
| 10036 |
&& CONST_INT_P (XEXP (addr, 1))) |
| 10037 |
{ |
| 10038 |
HOST_WIDE_INT val = INTVAL (XEXP (addr, 1)); |
| 10039 |
HOST_WIDE_INT extra = TARGET_POWERPC64 ? 8 : 12; |
| 10040 |
if (TARGET_PREFIXED) |
| 10041 |
return !SIGNED_34BIT_OFFSET_EXTRA_P (val, extra); |
| 10042 |
else |
| 10043 |
return !SIGNED_16BIT_OFFSET_EXTRA_P (val, extra); |
| 10044 |
} |
| 10045 |
break; |
| 10046 |
|
| 10047 |
case LO_SUM: |
| 10048 |
/* Anything in the constant pool is sufficiently aligned that |
| 10049 |
all bytes have the same high part address. */ |
| 10050 |
return !legitimate_constant_pool_address_p (addr, QImode, false); |
| 10051 |
|
| 10052 |
/* Auto-increment cases are now treated generically in recog.cc. */ |
| 10053 |
case PRE_MODIFY: |
| 10054 |
return TARGET_UPDATE; |
| 10055 |
|
| 10056 |
/* AND is only allowed in Altivec loads. */ |
| 10057 |
case AND: |
| 10058 |
return true; |
| 10059 |
|
| 10060 |
default: |
| 10061 |
break; |
| 10062 |
} |
| 10063 |
|
| 10064 |
return false; |
| 10065 |
} |
| 10066 |
|
| 10067 |
/* Debug version of rs6000_mode_dependent_address. */ |
| 10068 |
static bool |
| 10069 |
rs6000_debug_mode_dependent_address (const_rtx addr) |
| 10070 |
{ |
| 10071 |
bool ret = rs6000_mode_dependent_address (addr); |
| 10072 |
|
| 10073 |
fprintf (stderr, "\nrs6000_mode_dependent_address: ret = %s\n", |
| 10074 |
ret ? "true" : "false"); |
| 10075 |
debug_rtx (addr); |
| 10076 |
|
| 10077 |
return ret; |
| 10078 |
} |
| 10079 |
|
| 10080 |
/* Implement FIND_BASE_TERM. */ |
| 10081 |
|
| 10082 |
rtx |
| 10083 |
rs6000_find_base_term (rtx op) |
| 10084 |
{ |
| 10085 |
rtx base; |
| 10086 |
|
| 10087 |
base = op; |
| 10088 |
if (GET_CODE (base) == CONST) |
| 10089 |
base = XEXP (base, 0); |
| 10090 |
if (GET_CODE (base) == PLUS) |
| 10091 |
base = XEXP (base, 0); |
| 10092 |
if (GET_CODE (base) == UNSPEC) |
| 10093 |
switch (XINT (base, 1)) |
| 10094 |
{ |
| 10095 |
case UNSPEC_TOCREL: |
| 10096 |
case UNSPEC_MACHOPIC_OFFSET: |
| 10097 |
/* OP represents SYM [+ OFFSET] - ANCHOR. SYM is the base term |
| 10098 |
for aliasing purposes. */ |
| 10099 |
return XVECEXP (base, 0, 0); |
| 10100 |
} |
| 10101 |
|
| 10102 |
return op; |
| 10103 |
} |
| 10104 |
|
| 10105 |
/* More elaborate version of recog's offsettable_memref_p predicate |
| 10106 |
that works around the ??? note of rs6000_mode_dependent_address. |
| 10107 |
In particular it accepts |
| 10108 |
|
| 10109 |
(mem:DI (plus:SI (reg/f:SI 31 31) (const_int 32760 [0x7ff8]))) |
| 10110 |
|
| 10111 |
in 32-bit mode, that the recog predicate rejects. */ |
| 10112 |
|
| 10113 |
static bool |
| 10114 |
rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode, bool strict) |
| 10115 |
{ |
| 10116 |
bool worst_case; |
| 10117 |
|
| 10118 |
if (!MEM_P (op)) |
| 10119 |
return false; |
| 10120 |
|
| 10121 |
/* First mimic offsettable_memref_p. */ |
| 10122 |
if (offsettable_address_p (strict, GET_MODE (op), XEXP (op, 0))) |
| 10123 |
return true; |
| 10124 |
|
| 10125 |
/* offsettable_address_p invokes rs6000_mode_dependent_address, but |
| 10126 |
the latter predicate knows nothing about the mode of the memory |
| 10127 |
reference and, therefore, assumes that it is the largest supported |
| 10128 |
mode (TFmode). As a consequence, legitimate offsettable memory |
| 10129 |
references are rejected. rs6000_legitimate_offset_address_p contains |
| 10130 |
the correct logic for the PLUS case of rs6000_mode_dependent_address, |
| 10131 |
at least with a little bit of help here given that we know the |
| 10132 |
actual registers used. */ |
| 10133 |
worst_case = ((TARGET_POWERPC64 && GET_MODE_CLASS (reg_mode) == MODE_INT) |
| 10134 |
|| GET_MODE_SIZE (reg_mode) == 4); |
| 10135 |
return rs6000_legitimate_offset_address_p (GET_MODE (op), XEXP (op, 0), |
| 10136 |
strict, worst_case); |
| 10137 |
} |
| 10138 |
|
| 10139 |
/* Determine the reassociation width to be used in reassociate_bb. |
| 10140 |
This takes into account how many parallel operations we |
| 10141 |
can actually do of a given type, and also the latency. |
| 10142 |
P8: |
| 10143 |
int add/sub 6/cycle |
| 10144 |
mul 2/cycle |
| 10145 |
vect add/sub/mul 2/cycle |
| 10146 |
fp add/sub/mul 2/cycle |
| 10147 |
dfp 1/cycle |
| 10148 |
*/ |
| 10149 |
|
| 10150 |
static int |
| 10151 |
rs6000_reassociation_width (unsigned int opc ATTRIBUTE_UNUSED, |
| 10152 |
machine_mode mode) |
| 10153 |
{ |
| 10154 |
switch (rs6000_tune) |
| 10155 |
{ |
| 10156 |
case PROCESSOR_POWER8: |
| 10157 |
case PROCESSOR_POWER9: |
| 10158 |
case PROCESSOR_POWER10: |
| 10159 |
case PROCESSOR_POWER11: |
| 10160 |
if (DECIMAL_FLOAT_MODE_P (mode)) |
| 10161 |
return 1; |
| 10162 |
if (VECTOR_MODE_P (mode)) |
| 10163 |
return 4; |
| 10164 |
if (INTEGRAL_MODE_P (mode)) |
| 10165 |
return 1; |
| 10166 |
if (FLOAT_MODE_P (mode)) |
| 10167 |
return 4; |
| 10168 |
break; |
| 10169 |
default: |
| 10170 |
break; |
| 10171 |
} |
| 10172 |
return 1; |
| 10173 |
} |
| 10174 |
|
| 10175 |
/* Change register usage conditional on target flags. */ |
| 10176 |
static void |
| 10177 |
rs6000_conditional_register_usage (void) |
| 10178 |
{ |
| 10179 |
int i; |
| 10180 |
|
| 10181 |
if (TARGET_DEBUG_TARGET) |
| 10182 |
fprintf (stderr, "rs6000_conditional_register_usage called\n"); |
| 10183 |
|
| 10184 |
/* 64-bit AIX and Linux reserve GPR13 for thread-private data. */ |
| 10185 |
if (TARGET_64BIT) |
| 10186 |
fixed_regs[13] = call_used_regs[13] = 1; |
| 10187 |
|
| 10188 |
/* Conditionally disable FPRs. */ |
| 10189 |
if (TARGET_SOFT_FLOAT) |
| 10190 |
for (i = 32; i < 64; i++) |
| 10191 |
fixed_regs[i] = call_used_regs[i] = 1; |
| 10192 |
|
| 10193 |
/* For non PC-relative code, GPR2 is unavailable for register allocation. */ |
| 10194 |
if (FIXED_R2 && !rs6000_pcrel_p ()) |
| 10195 |
fixed_regs[2] = 1; |
| 10196 |
|
| 10197 |
/* The TOC register is not killed across calls in a way that is |
| 10198 |
visible to the compiler. */ |
| 10199 |
if (fixed_regs[2] && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)) |
| 10200 |
call_used_regs[2] = 0; |
| 10201 |
|
| 10202 |
if (DEFAULT_ABI == ABI_V4 && flag_pic == 2) |
| 10203 |
fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1; |
| 10204 |
|
| 10205 |
if (DEFAULT_ABI == ABI_V4 && flag_pic == 1) |
| 10206 |
fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] |
| 10207 |
= call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1; |
| 10208 |
|
| 10209 |
if (DEFAULT_ABI == ABI_DARWIN && flag_pic) |
| 10210 |
fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] |
| 10211 |
= call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1; |
| 10212 |
|
| 10213 |
if (TARGET_TOC && TARGET_MINIMAL_TOC) |
| 10214 |
fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1; |
| 10215 |
|
| 10216 |
if (!TARGET_ALTIVEC && !TARGET_VSX) |
| 10217 |
{ |
| 10218 |
for (i = FIRST_ALTIVEC_REGNO; i <= LAST_ALTIVEC_REGNO; ++i) |
| 10219 |
fixed_regs[i] = call_used_regs[i] = 1; |
| 10220 |
call_used_regs[VRSAVE_REGNO] = 1; |
| 10221 |
} |
| 10222 |
|
| 10223 |
if (TARGET_ALTIVEC || TARGET_VSX) |
| 10224 |
global_regs[VSCR_REGNO] = 1; |
| 10225 |
|
| 10226 |
if (TARGET_ALTIVEC_ABI) |
| 10227 |
{ |
| 10228 |
for (i = FIRST_ALTIVEC_REGNO; i < FIRST_ALTIVEC_REGNO + 20; ++i) |
| 10229 |
call_used_regs[i] = 1; |
| 10230 |
|
| 10231 |
/* AIX reserves VR20:31 in non-extended ABI mode. */ |
| 10232 |
if (TARGET_XCOFF && !rs6000_aix_extabi) |
| 10233 |
for (i = FIRST_ALTIVEC_REGNO + 20; i < FIRST_ALTIVEC_REGNO + 32; ++i) |
| 10234 |
fixed_regs[i] = call_used_regs[i] = 1; |
| 10235 |
} |
| 10236 |
} |
| 10237 |
|
| 10238 |
|
| 10239 |
/* Output insns to set DEST equal to the constant SOURCE as a series of |
| 10240 |
lis, ori and shl instructions and return TRUE. */ |
| 10241 |
|
| 10242 |
bool |
| 10243 |
rs6000_emit_set_const (rtx dest, rtx source) |
| 10244 |
{ |
| 10245 |
machine_mode mode = GET_MODE (dest); |
| 10246 |
rtx temp, set; |
| 10247 |
rtx_insn *insn; |
| 10248 |
HOST_WIDE_INT c; |
| 10249 |
|
| 10250 |
gcc_checking_assert (CONST_INT_P (source)); |
| 10251 |
c = INTVAL (source); |
| 10252 |
switch (mode) |
| 10253 |
{ |
| 10254 |
case E_QImode: |
| 10255 |
case E_HImode: |
| 10256 |
emit_insn (gen_rtx_SET (dest, source)); |
| 10257 |
return true; |
| 10258 |
|
| 10259 |
case E_SImode: |
| 10260 |
temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (SImode); |
| 10261 |
|
| 10262 |
emit_insn (gen_rtx_SET (temp, GEN_INT (c & ~(HOST_WIDE_INT) 0xffff))); |
| 10263 |
emit_insn (gen_rtx_SET (dest, |
| 10264 |
gen_rtx_IOR (SImode, temp, |
| 10265 |
GEN_INT (c & 0xffff)))); |
| 10266 |
break; |
| 10267 |
|
| 10268 |
case E_DImode: |
| 10269 |
if (!TARGET_POWERPC64) |
| 10270 |
{ |
| 10271 |
rtx hi, lo; |
| 10272 |
|
| 10273 |
hi = operand_subword_force (dest, WORDS_BIG_ENDIAN == 0, DImode); |
| 10274 |
lo = operand_subword_force (dest, WORDS_BIG_ENDIAN != 0, DImode); |
| 10275 |
emit_move_insn (hi, GEN_INT (c >> 32)); |
| 10276 |
c = sext_hwi (c, 32); |
| 10277 |
emit_move_insn (lo, GEN_INT (c)); |
| 10278 |
} |
| 10279 |
else |
| 10280 |
rs6000_emit_set_long_const (dest, c); |
| 10281 |
break; |
| 10282 |
|
| 10283 |
default: |
| 10284 |
gcc_unreachable (); |
| 10285 |
} |
| 10286 |
|
| 10287 |
insn = get_last_insn (); |
| 10288 |
set = single_set (insn); |
| 10289 |
if (! CONSTANT_P (SET_SRC (set))) |
| 10290 |
set_unique_reg_note (insn, REG_EQUAL, GEN_INT (c)); |
| 10291 |
|
| 10292 |
return true; |
| 10293 |
} |
| 10294 |
|
| 10295 |
/* Check if C can be rotated to a negative value which 'lis' instruction is |
| 10296 |
able to load: 1..1xx0..0. If so, set *ROT to the number by which C is |
| 10297 |
rotated, and return true. Return false otherwise. */ |
| 10298 |
|
| 10299 |
static bool |
| 10300 |
can_be_rotated_to_negative_lis (HOST_WIDE_INT c, int *rot) |
| 10301 |
{ |
| 10302 |
/* case a. 1..1xxx0..01..1: up to 15 x's, at least 16 0's. */ |
| 10303 |
int leading_ones = clz_hwi (~c); |
| 10304 |
int tailing_ones = ctz_hwi (~c); |
| 10305 |
int middle_zeros = ctz_hwi (c >> tailing_ones); |
| 10306 |
if (middle_zeros >= 16 && leading_ones + tailing_ones >= 33) |
| 10307 |
{ |
| 10308 |
*rot = HOST_BITS_PER_WIDE_INT - tailing_ones; |
| 10309 |
return true; |
| 10310 |
} |
| 10311 |
|
| 10312 |
/* case b. xx0..01..1xx: some of 15 x's (and some of 16 0's) are |
| 10313 |
rotated over the highest bit. */ |
| 10314 |
int pos_one = clz_hwi ((c << 16) >> 16); |
| 10315 |
middle_zeros = ctz_hwi (c >> (HOST_BITS_PER_WIDE_INT - pos_one)); |
| 10316 |
int middle_ones = clz_hwi (~(c << pos_one)); |
| 10317 |
if (middle_zeros >= 16 && middle_ones >= 33) |
| 10318 |
{ |
| 10319 |
*rot = pos_one; |
| 10320 |
return true; |
| 10321 |
} |
| 10322 |
|
| 10323 |
return false; |
| 10324 |
} |
| 10325 |
|
| 10326 |
/* Check if value C can be built by 2 instructions: one is 'li or lis', |
| 10327 |
another is rotldi. |
| 10328 |
|
| 10329 |
If so, *SHIFT is set to the shift operand of rotldi(rldicl), and *MASK |
| 10330 |
is set to the mask operand of rotldi(rldicl), and return true. |
| 10331 |
Return false otherwise. */ |
| 10332 |
|
| 10333 |
static bool |
| 10334 |
can_be_built_by_li_lis_and_rotldi (HOST_WIDE_INT c, int *shift, |
| 10335 |
HOST_WIDE_INT *mask) |
| 10336 |
{ |
| 10337 |
/* If C or ~C contains at least 49 successive zeros, then C can be rotated |
| 10338 |
to/from a positive or negative value that 'li' is able to load. */ |
| 10339 |
int n; |
| 10340 |
if (can_be_rotated_to_lowbits (c, 15, &n) |
| 10341 |
|| can_be_rotated_to_lowbits (~c, 15, &n) |
| 10342 |
|| can_be_rotated_to_negative_lis (c, &n)) |
| 10343 |
{ |
| 10344 |
*mask = HOST_WIDE_INT_M1; |
| 10345 |
*shift = HOST_BITS_PER_WIDE_INT - n; |
| 10346 |
return true; |
| 10347 |
} |
| 10348 |
|
| 10349 |
return false; |
| 10350 |
} |
| 10351 |
|
| 10352 |
/* Check if value C can be built by 2 instructions: one is 'li or lis', |
| 10353 |
another is rldicl. |
| 10354 |
|
| 10355 |
If so, *SHIFT is set to the shift operand of rldicl, and *MASK is set to |
| 10356 |
the mask operand of rldicl, and return true. |
| 10357 |
Return false otherwise. */ |
| 10358 |
|
| 10359 |
static bool |
| 10360 |
can_be_built_by_li_lis_and_rldicl (HOST_WIDE_INT c, int *shift, |
| 10361 |
HOST_WIDE_INT *mask) |
| 10362 |
{ |
| 10363 |
/* Leading zeros may be cleaned by rldicl with a mask. Change leading zeros |
| 10364 |
to ones and then recheck it. */ |
| 10365 |
int lz = clz_hwi (c); |
| 10366 |
|
| 10367 |
/* If lz == 0, the left shift is undefined. */ |
| 10368 |
if (!lz) |
| 10369 |
return false; |
| 10370 |
|
| 10371 |
HOST_WIDE_INT unmask_c |
| 10372 |
= c | (HOST_WIDE_INT_M1U << (HOST_BITS_PER_WIDE_INT - lz)); |
| 10373 |
int n; |
| 10374 |
if (can_be_rotated_to_lowbits (~unmask_c, 15, &n) |
| 10375 |
|| can_be_rotated_to_negative_lis (unmask_c, &n)) |
| 10376 |
{ |
| 10377 |
*mask = HOST_WIDE_INT_M1U >> lz; |
| 10378 |
*shift = n == 0 ? 0 : HOST_BITS_PER_WIDE_INT - n; |
| 10379 |
return true; |
| 10380 |
} |
| 10381 |
|
| 10382 |
return false; |
| 10383 |
} |
| 10384 |
|
| 10385 |
/* Check if value C can be built by 2 instructions: one is 'li or lis', |
| 10386 |
another is rldicr. |
| 10387 |
|
| 10388 |
If so, *SHIFT is set to the shift operand of rldicr, and *MASK is set to |
| 10389 |
the mask operand of rldicr, and return true. |
| 10390 |
Return false otherwise. */ |
| 10391 |
|
| 10392 |
static bool |
| 10393 |
can_be_built_by_li_lis_and_rldicr (HOST_WIDE_INT c, int *shift, |
| 10394 |
HOST_WIDE_INT *mask) |
| 10395 |
{ |
| 10396 |
/* Tailing zeros may be cleaned by rldicr with a mask. Change tailing zeros |
| 10397 |
to ones and then recheck it. */ |
| 10398 |
int tz = ctz_hwi (c); |
| 10399 |
|
| 10400 |
/* If tz == HOST_BITS_PER_WIDE_INT, the left shift is undefined. */ |
| 10401 |
if (tz >= HOST_BITS_PER_WIDE_INT) |
| 10402 |
return false; |
| 10403 |
|
| 10404 |
HOST_WIDE_INT unmask_c = c | ((HOST_WIDE_INT_1U << tz) - 1); |
| 10405 |
int n; |
| 10406 |
if (can_be_rotated_to_lowbits (~unmask_c, 15, &n) |
| 10407 |
|| can_be_rotated_to_negative_lis (unmask_c, &n)) |
| 10408 |
{ |
| 10409 |
*mask = HOST_WIDE_INT_M1U << tz; |
| 10410 |
*shift = HOST_BITS_PER_WIDE_INT - n; |
| 10411 |
return true; |
| 10412 |
} |
| 10413 |
|
| 10414 |
return false; |
| 10415 |
} |
| 10416 |
|
| 10417 |
/* Check if value C can be built by 2 instructions: one is 'li', another is |
| 10418 |
rldic. |
| 10419 |
|
| 10420 |
If so, *SHIFT is set to the 'shift' operand of rldic; and *MASK is set |
| 10421 |
to the mask value about the 'mb' operand of rldic; and return true. |
| 10422 |
Return false otherwise. */ |
| 10423 |
|
| 10424 |
static bool |
| 10425 |
can_be_built_by_li_and_rldic (HOST_WIDE_INT c, int *shift, HOST_WIDE_INT *mask) |
| 10426 |
{ |
| 10427 |
/* There are 49 successive ones in the negative value of 'li'. */ |
| 10428 |
int ones = 49; |
| 10429 |
|
| 10430 |
/* 1..1xx1..1: negative value of li --> 0..01..1xx0..0: |
| 10431 |
right bits are shifted as 0's, and left 1's(and x's) are cleaned. */ |
| 10432 |
int tz = ctz_hwi (c); |
| 10433 |
int lz = clz_hwi (c); |
| 10434 |
|
| 10435 |
/* If lz == HOST_BITS_PER_WIDE_INT, the left shift is undefined. */ |
| 10436 |
if (lz >= HOST_BITS_PER_WIDE_INT) |
| 10437 |
return false; |
| 10438 |
|
| 10439 |
int middle_ones = clz_hwi (~(c << lz)); |
| 10440 |
if (tz + lz + middle_ones >= ones |
| 10441 |
&& (tz - lz) < HOST_BITS_PER_WIDE_INT |
| 10442 |
&& tz < HOST_BITS_PER_WIDE_INT) |
| 10443 |
{ |
| 10444 |
*mask = ((1LL << (HOST_BITS_PER_WIDE_INT - tz - lz)) - 1LL) << tz; |
| 10445 |
*shift = tz; |
| 10446 |
return true; |
| 10447 |
} |
| 10448 |
|
| 10449 |
/* 1..1xx1..1 --> 1..1xx0..01..1: some 1's(following x's) are cleaned. */ |
| 10450 |
int leading_ones = clz_hwi (~c); |
| 10451 |
int tailing_ones = ctz_hwi (~c); |
| 10452 |
int middle_zeros = ctz_hwi (c >> tailing_ones); |
| 10453 |
if (leading_ones + tailing_ones + middle_zeros >= ones |
| 10454 |
&& middle_zeros < HOST_BITS_PER_WIDE_INT) |
| 10455 |
{ |
| 10456 |
*mask = ~(((1ULL << middle_zeros) - 1ULL) << tailing_ones); |
| 10457 |
*shift = tailing_ones + middle_zeros; |
| 10458 |
return true; |
| 10459 |
} |
| 10460 |
|
| 10461 |
/* xx1..1xx: --> xx0..01..1xx: some 1's(following x's) are cleaned. */ |
| 10462 |
/* Get the position for the first bit of successive 1. |
| 10463 |
The 24th bit would be in successive 0 or 1. */ |
| 10464 |
HOST_WIDE_INT low_mask = (HOST_WIDE_INT_1U << 24) - HOST_WIDE_INT_1U; |
| 10465 |
int pos_first_1 = ((c & (low_mask + 1)) == 0) |
| 10466 |
? clz_hwi (c & low_mask) |
| 10467 |
: HOST_BITS_PER_WIDE_INT - ctz_hwi (~(c | low_mask)); |
| 10468 |
|
| 10469 |
/* Make sure the left and right shifts are defined. */ |
| 10470 |
if (!IN_RANGE (pos_first_1, 1, HOST_BITS_PER_WIDE_INT-1)) |
| 10471 |
return false; |
| 10472 |
|
| 10473 |
middle_ones = clz_hwi (~c << pos_first_1); |
| 10474 |
middle_zeros = ctz_hwi (c >> (HOST_BITS_PER_WIDE_INT - pos_first_1)); |
| 10475 |
if (pos_first_1 < HOST_BITS_PER_WIDE_INT |
| 10476 |
&& middle_ones + middle_zeros < HOST_BITS_PER_WIDE_INT |
| 10477 |
&& middle_ones + middle_zeros >= ones) |
| 10478 |
{ |
| 10479 |
*mask = ~(((1ULL << middle_zeros) - 1LL) |
| 10480 |
<< (HOST_BITS_PER_WIDE_INT - pos_first_1)); |
| 10481 |
*shift = HOST_BITS_PER_WIDE_INT - pos_first_1 + middle_zeros; |
| 10482 |
return true; |
| 10483 |
} |
| 10484 |
|
| 10485 |
return false; |
| 10486 |
} |
| 10487 |
|
| 10488 |
/* Subroutine of rs6000_emit_set_const, handling PowerPC64 DImode. |
| 10489 |
Output insns to set DEST equal to the constant C as a series of |
| 10490 |
lis, ori and shl instructions. If NUM_INSNS is not NULL, then |
| 10491 |
only increase *NUM_INSNS as the number of insns, and do not emit |
| 10492 |
any insns. */ |
| 10493 |
|
| 10494 |
static void |
| 10495 |
rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c, int *num_insns) |
| 10496 |
{ |
| 10497 |
HOST_WIDE_INT ud1, ud2, ud3, ud4; |
| 10498 |
|
| 10499 |
ud1 = c & 0xffff; |
| 10500 |
ud2 = (c >> 16) & 0xffff; |
| 10501 |
ud3 = (c >> 32) & 0xffff; |
| 10502 |
ud4 = (c >> 48) & 0xffff; |
| 10503 |
|
| 10504 |
/* This lambda is used to emit one insn or just increase the insn count. |
| 10505 |
When counting the insn number, no need to emit the insn. */ |
| 10506 |
auto count_or_emit_insn = [&num_insns] (rtx dest_or_insn, rtx src = nullptr) { |
| 10507 |
if (num_insns) |
| 10508 |
{ |
| 10509 |
(*num_insns)++; |
| 10510 |
return; |
| 10511 |
} |
| 10512 |
|
| 10513 |
if (src) |
| 10514 |
emit_move_insn (dest_or_insn, src); |
| 10515 |
else |
| 10516 |
emit_insn (dest_or_insn); |
| 10517 |
}; |
| 10518 |
|
| 10519 |
if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (c)) |
| 10520 |
{ |
| 10521 |
/* li/lis/pli */ |
| 10522 |
count_or_emit_insn (dest, GEN_INT (c)); |
| 10523 |
return; |
| 10524 |
} |
| 10525 |
|
| 10526 |
if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) |
| 10527 |
|| (ud4 == 0 && ud3 == 0 && ud2 == 0 && !(ud1 & 0x8000))) |
| 10528 |
{ |
| 10529 |
/* li */ |
| 10530 |
count_or_emit_insn (dest, GEN_INT (sext_hwi (ud1, 16))); |
| 10531 |
return; |
| 10532 |
} |
| 10533 |
|
| 10534 |
rtx temp |
| 10535 |
= (num_insns || !can_create_pseudo_p ()) ? dest : gen_reg_rtx (DImode); |
| 10536 |
|
| 10537 |
if ((ud4 == 0xffff && ud3 == 0xffff && (ud2 & 0x8000)) |
| 10538 |
|| (ud4 == 0 && ud3 == 0 && !(ud2 & 0x8000))) |
| 10539 |
{ |
| 10540 |
/* lis[; ori] */ |
| 10541 |
count_or_emit_insn (ud1 != 0 ? temp : dest, |
| 10542 |
GEN_INT (sext_hwi (ud2 << 16, 32))); |
| 10543 |
if (ud1 != 0) |
| 10544 |
count_or_emit_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1))); |
| 10545 |
return; |
| 10546 |
} |
| 10547 |
|
| 10548 |
if (ud4 == 0xffff && ud3 == 0xffff && !(ud2 & 0x8000) && ud1 == 0) |
| 10549 |
{ |
| 10550 |
/* lis; xoris */ |
| 10551 |
count_or_emit_insn (temp, GEN_INT (sext_hwi ((ud2 | 0x8000) << 16, 32))); |
| 10552 |
count_or_emit_insn (dest, |
| 10553 |
gen_rtx_XOR (DImode, temp, GEN_INT (0x80000000))); |
| 10554 |
return; |
| 10555 |
} |
| 10556 |
|
| 10557 |
if (ud4 == 0xffff && ud3 == 0xffff && (ud1 & 0x8000)) |
| 10558 |
{ |
| 10559 |
/* li; xoris */ |
| 10560 |
count_or_emit_insn (temp, GEN_INT (sext_hwi (ud1, 16))); |
| 10561 |
count_or_emit_insn (dest, gen_rtx_XOR (DImode, temp, |
| 10562 |
GEN_INT ((ud2 ^ 0xffff) << 16))); |
| 10563 |
return; |
| 10564 |
} |
| 10565 |
|
| 10566 |
int shift; |
| 10567 |
HOST_WIDE_INT mask; |
| 10568 |
if (can_be_built_by_li_lis_and_rotldi (c, &shift, &mask) |
| 10569 |
|| can_be_built_by_li_lis_and_rldicl (c, &shift, &mask) |
| 10570 |
|| can_be_built_by_li_lis_and_rldicr (c, &shift, &mask) |
| 10571 |
|| can_be_built_by_li_and_rldic (c, &shift, &mask)) |
| 10572 |
{ |
| 10573 |
/* li/lis; rldicX */ |
| 10574 |
unsigned HOST_WIDE_INT imm = (c | ~mask); |
| 10575 |
imm = (imm >> shift) | (imm << (HOST_BITS_PER_WIDE_INT - shift)); |
| 10576 |
|
| 10577 |
count_or_emit_insn (temp, GEN_INT (imm)); |
| 10578 |
if (shift != 0) |
| 10579 |
temp = gen_rtx_ROTATE (DImode, temp, GEN_INT (shift)); |
| 10580 |
if (mask != HOST_WIDE_INT_M1) |
| 10581 |
temp = gen_rtx_AND (DImode, temp, GEN_INT (mask)); |
| 10582 |
count_or_emit_insn (dest, temp); |
| 10583 |
|
| 10584 |
return; |
| 10585 |
} |
| 10586 |
|
| 10587 |
if (ud3 == 0 && ud4 == 0) |
| 10588 |
{ |
| 10589 |
gcc_assert ((ud2 & 0x8000) && ud1 != 0); |
| 10590 |
if (!(ud1 & 0x8000)) |
| 10591 |
{ |
| 10592 |
/* li; oris */ |
| 10593 |
count_or_emit_insn (temp, GEN_INT (ud1)); |
| 10594 |
count_or_emit_insn (dest, |
| 10595 |
gen_rtx_IOR (DImode, temp, GEN_INT (ud2 << 16))); |
| 10596 |
return; |
| 10597 |
} |
| 10598 |
|
| 10599 |
/* lis; ori; rldicl */ |
| 10600 |
count_or_emit_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32))); |
| 10601 |
count_or_emit_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1))); |
| 10602 |
count_or_emit_insn (dest, |
| 10603 |
gen_rtx_AND (DImode, temp, GEN_INT (0xffffffff))); |
| 10604 |
return; |
| 10605 |
} |
| 10606 |
|
| 10607 |
if (ud1 == ud3 && ud2 == ud4) |
| 10608 |
{ |
| 10609 |
/* load low 32bits first, e.g. "lis; ori", then "rldimi". */ |
| 10610 |
HOST_WIDE_INT num = (ud2 << 16) | ud1; |
| 10611 |
rs6000_emit_set_long_const (temp, sext_hwi (num, 32), num_insns); |
| 10612 |
|
| 10613 |
rtx rldimi = gen_rotldi3_insert_3 (dest, temp, GEN_INT (32), temp, |
| 10614 |
GEN_INT (0xffffffff)); |
| 10615 |
count_or_emit_insn (rldimi); |
| 10616 |
return; |
| 10617 |
} |
| 10618 |
|
| 10619 |
if ((ud4 == 0xffff && (ud3 & 0x8000)) || (ud4 == 0 && !(ud3 & 0x8000))) |
| 10620 |
{ |
| 10621 |
/* li; [ori;] rldicl [;oir]. */ |
| 10622 |
count_or_emit_insn (temp, GEN_INT (sext_hwi (ud3 << 16, 32))); |
| 10623 |
if (ud2 != 0) |
| 10624 |
count_or_emit_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud2))); |
| 10625 |
count_or_emit_insn (ud1 != 0 ? temp : dest, |
| 10626 |
gen_rtx_ASHIFT (DImode, temp, GEN_INT (16))); |
| 10627 |
if (ud1 != 0) |
| 10628 |
count_or_emit_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1))); |
| 10629 |
return; |
| 10630 |
} |
| 10631 |
|
| 10632 |
if (TARGET_PREFIXED) |
| 10633 |
{ |
| 10634 |
if (can_create_pseudo_p ()) |
| 10635 |
{ |
| 10636 |
/* pli A,L; pli B,H; rldimi A,B,32,0. */ |
| 10637 |
rtx temp1 = num_insns ? nullptr : gen_reg_rtx (DImode); |
| 10638 |
count_or_emit_insn (temp, GEN_INT ((ud4 << 16) | ud3)); |
| 10639 |
count_or_emit_insn (temp1, GEN_INT ((ud2 << 16) | ud1)); |
| 10640 |
rtx rldimi = gen_rotldi3_insert_3 (dest, temp, GEN_INT (32), temp1, |
| 10641 |
GEN_INT (0xffffffff)); |
| 10642 |
count_or_emit_insn (rldimi); |
| 10643 |
return; |
| 10644 |
} |
| 10645 |
|
| 10646 |
/* pli A,H; sldi A,32; paddi A,A,L. */ |
| 10647 |
count_or_emit_insn (dest, GEN_INT ((ud4 << 16) | ud3)); |
| 10648 |
count_or_emit_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (32))); |
| 10649 |
|
| 10650 |
bool can_use_paddi = dest ? REGNO (dest) != FIRST_GPR_REGNO : false; |
| 10651 |
/* Use paddi for the low 32 bits. */ |
| 10652 |
if (ud2 != 0 && ud1 != 0 && can_use_paddi) |
| 10653 |
count_or_emit_insn (dest, gen_rtx_PLUS (DImode, dest, |
| 10654 |
GEN_INT ((ud2 << 16) | ud1))); |
| 10655 |
/* Use oris, ori for low 32 bits. */ |
| 10656 |
if (ud2 != 0 && (ud1 == 0 || !can_use_paddi)) |
| 10657 |
count_or_emit_insn (dest, |
| 10658 |
gen_rtx_IOR (DImode, dest, GEN_INT (ud2 << 16))); |
| 10659 |
if (ud1 != 0 && (ud2 == 0 || !can_use_paddi)) |
| 10660 |
count_or_emit_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1))); |
| 10661 |
return; |
| 10662 |
} |
| 10663 |
|
| 10664 |
if (can_create_pseudo_p ()) |
| 10665 |
{ |
| 10666 |
/* lis HIGH,UD4 ; ori HIGH,UD3 ; |
| 10667 |
lis LOW,UD2 ; ori LOW,UD1 ; rldimi LOW,HIGH,32,0. */ |
| 10668 |
rtx high = num_insns ? nullptr : gen_reg_rtx (DImode); |
| 10669 |
rtx low = num_insns ? nullptr : gen_reg_rtx (DImode); |
| 10670 |
HOST_WIDE_INT num = (ud2 << 16) | ud1; |
| 10671 |
rs6000_emit_set_long_const (low, sext_hwi (num, 32), num_insns); |
| 10672 |
num = (ud4 << 16) | ud3; |
| 10673 |
rs6000_emit_set_long_const (high, sext_hwi (num, 32), num_insns); |
| 10674 |
|
| 10675 |
rtx rldimi = gen_rotldi3_insert_3 (dest, high, GEN_INT (32), low, |
| 10676 |
GEN_INT (0xffffffff)); |
| 10677 |
count_or_emit_insn (rldimi); |
| 10678 |
return; |
| 10679 |
} |
| 10680 |
|
| 10681 |
/* lis DEST,UD4 ; ori DEST,UD3 ; rotl DEST,32 ; |
| 10682 |
oris DEST,UD2 ; ori DEST,UD1. */ |
| 10683 |
count_or_emit_insn (dest, GEN_INT (sext_hwi (ud4 << 16, 32))); |
| 10684 |
if (ud3 != 0) |
| 10685 |
count_or_emit_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud3))); |
| 10686 |
|
| 10687 |
count_or_emit_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (32))); |
| 10688 |
if (ud2 != 0) |
| 10689 |
count_or_emit_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud2 << 16))); |
| 10690 |
if (ud1 != 0) |
| 10691 |
count_or_emit_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1))); |
| 10692 |
|
| 10693 |
return; |
| 10694 |
} |
| 10695 |
|
| 10696 |
/* Helper for the following. Get rid of [r+r] memory refs |
| 10697 |
in cases where it won't work (TImode, TFmode, TDmode, PTImode). */ |
| 10698 |
|
| 10699 |
static void |
| 10700 |
rs6000_eliminate_indexed_memrefs (rtx operands[2]) |
| 10701 |
{ |
| 10702 |
if (MEM_P (operands[0]) |
| 10703 |
&& !REG_P (XEXP (operands[0], 0)) |
| 10704 |
&& ! legitimate_constant_pool_address_p (XEXP (operands[0], 0), |
| 10705 |
GET_MODE (operands[0]), false)) |
| 10706 |
operands[0] |
| 10707 |
= replace_equiv_address (operands[0], |
| 10708 |
copy_addr_to_reg (XEXP (operands[0], 0))); |
| 10709 |
|
| 10710 |
if (MEM_P (operands[1]) |
| 10711 |
&& !REG_P (XEXP (operands[1], 0)) |
| 10712 |
&& ! legitimate_constant_pool_address_p (XEXP (operands[1], 0), |
| 10713 |
GET_MODE (operands[1]), false)) |
| 10714 |
operands[1] |
| 10715 |
= replace_equiv_address (operands[1], |
| 10716 |
copy_addr_to_reg (XEXP (operands[1], 0))); |
| 10717 |
} |
| 10718 |
|
| 10719 |
/* Generate a vector of constants to permute MODE for a little-endian |
| 10720 |
storage operation by swapping the two halves of a vector. */ |
| 10721 |
static rtvec |
| 10722 |
rs6000_const_vec (machine_mode mode) |
| 10723 |
{ |
| 10724 |
int i, subparts; |
| 10725 |
rtvec v; |
| 10726 |
|
| 10727 |
switch (mode) |
| 10728 |
{ |
| 10729 |
case E_V1TImode: |
| 10730 |
subparts = 1; |
| 10731 |
break; |
| 10732 |
case E_V2DFmode: |
| 10733 |
case E_V2DImode: |
| 10734 |
subparts = 2; |
| 10735 |
break; |
| 10736 |
case E_V4SFmode: |
| 10737 |
case E_V4SImode: |
| 10738 |
subparts = 4; |
| 10739 |
break; |
| 10740 |
case E_V8HImode: |
| 10741 |
subparts = 8; |
| 10742 |
break; |
| 10743 |
case E_V16QImode: |
| 10744 |
subparts = 16; |
| 10745 |
break; |
| 10746 |
default: |
| 10747 |
gcc_unreachable(); |
| 10748 |
} |
| 10749 |
|
| 10750 |
v = rtvec_alloc (subparts); |
| 10751 |
|
| 10752 |
for (i = 0; i < subparts / 2; ++i) |
| 10753 |
RTVEC_ELT (v, i) = gen_rtx_CONST_INT (DImode, i + subparts / 2); |
| 10754 |
for (i = subparts / 2; i < subparts; ++i) |
| 10755 |
RTVEC_ELT (v, i) = gen_rtx_CONST_INT (DImode, i - subparts / 2); |
| 10756 |
|
| 10757 |
return v; |
| 10758 |
} |
| 10759 |
|
| 10760 |
/* Emit an lxvd2x, stxvd2x, or xxpermdi instruction for a VSX load or |
| 10761 |
store operation. */ |
| 10762 |
void |
| 10763 |
rs6000_emit_le_vsx_permute (rtx dest, rtx source, machine_mode mode) |
| 10764 |
{ |
| 10765 |
gcc_assert (!altivec_indexed_or_indirect_operand (dest, mode)); |
| 10766 |
gcc_assert (!altivec_indexed_or_indirect_operand (source, mode)); |
| 10767 |
|
| 10768 |
/* Scalar permutations are easier to express in integer modes rather than |
| 10769 |
floating-point modes, so cast them here. We use V1TImode instead |
| 10770 |
of TImode to ensure that the values don't go through GPRs. */ |
| 10771 |
if (FLOAT128_VECTOR_P (mode)) |
| 10772 |
{ |
| 10773 |
dest = gen_lowpart (V1TImode, dest); |
| 10774 |
source = gen_lowpart (V1TImode, source); |
| 10775 |
mode = V1TImode; |
| 10776 |
} |
| 10777 |
|
| 10778 |
/* Use ROTATE instead of VEC_SELECT if the mode contains only a single |
| 10779 |
scalar. */ |
| 10780 |
if (mode == TImode || mode == V1TImode) |
| 10781 |
emit_insn (gen_rtx_SET (dest, gen_rtx_ROTATE (mode, source, |
| 10782 |
GEN_INT (64)))); |
| 10783 |
else |
| 10784 |
{ |
| 10785 |
rtx par = gen_rtx_PARALLEL (VOIDmode, rs6000_const_vec (mode)); |
| 10786 |
emit_insn (gen_rtx_SET (dest, gen_rtx_VEC_SELECT (mode, source, par))); |
| 10787 |
} |
| 10788 |
} |
| 10789 |
|
| 10790 |
/* Emit a little-endian load from vector memory location SOURCE to VSX |
| 10791 |
register DEST in mode MODE. The load is done with two permuting |
| 10792 |
insn's that represent an lxvd2x and xxpermdi. */ |
| 10793 |
void |
| 10794 |
rs6000_emit_le_vsx_load (rtx dest, rtx source, machine_mode mode) |
| 10795 |
{ |
| 10796 |
/* Use V2DImode to do swaps of types with 128-bit scalare parts (TImode, |
| 10797 |
V1TImode). */ |
| 10798 |
if (mode == TImode || mode == V1TImode) |
| 10799 |
{ |
| 10800 |
mode = V2DImode; |
| 10801 |
dest = gen_lowpart (V2DImode, dest); |
| 10802 |
source = adjust_address (source, V2DImode, 0); |
| 10803 |
} |
| 10804 |
|
| 10805 |
rtx tmp = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (dest) : dest; |
| 10806 |
rs6000_emit_le_vsx_permute (tmp, source, mode); |
| 10807 |
rs6000_emit_le_vsx_permute (dest, tmp, mode); |
| 10808 |
} |
| 10809 |
|
| 10810 |
/* Emit a little-endian store to vector memory location DEST from VSX |
| 10811 |
register SOURCE in mode MODE. The store is done with two permuting |
| 10812 |
insn's that represent an xxpermdi and an stxvd2x. */ |
| 10813 |
void |
| 10814 |
rs6000_emit_le_vsx_store (rtx dest, rtx source, machine_mode mode) |
| 10815 |
{ |
| 10816 |
/* This should never be called after LRA. */ |
| 10817 |
gcc_assert (can_create_pseudo_p ()); |
| 10818 |
|
| 10819 |
/* Use V2DImode to do swaps of types with 128-bit scalar parts (TImode, |
| 10820 |
V1TImode). */ |
| 10821 |
if (mode == TImode || mode == V1TImode) |
| 10822 |
{ |
| 10823 |
mode = V2DImode; |
| 10824 |
dest = adjust_address (dest, V2DImode, 0); |
| 10825 |
source = gen_lowpart (V2DImode, source); |
| 10826 |
} |
| 10827 |
|
| 10828 |
rtx tmp = gen_reg_rtx_and_attrs (source); |
| 10829 |
rs6000_emit_le_vsx_permute (tmp, source, mode); |
| 10830 |
rs6000_emit_le_vsx_permute (dest, tmp, mode); |
| 10831 |
} |
| 10832 |
|
| 10833 |
/* Emit a sequence representing a little-endian VSX load or store, |
| 10834 |
moving data from SOURCE to DEST in mode MODE. This is done |
| 10835 |
separately from rs6000_emit_move to ensure it is called only |
| 10836 |
during expand. LE VSX loads and stores introduced later are |
| 10837 |
handled with a split. The expand-time RTL generation allows |
| 10838 |
us to optimize away redundant pairs of register-permutes. */ |
| 10839 |
void |
| 10840 |
rs6000_emit_le_vsx_move (rtx dest, rtx source, machine_mode mode) |
| 10841 |
{ |
| 10842 |
gcc_assert (!BYTES_BIG_ENDIAN |
| 10843 |
&& VECTOR_MEM_VSX_P (mode) |
| 10844 |
&& !TARGET_P9_VECTOR |
| 10845 |
&& !gpr_or_gpr_p (dest, source) |
| 10846 |
&& (MEM_P (source) ^ MEM_P (dest))); |
| 10847 |
|
| 10848 |
if (MEM_P (source)) |
| 10849 |
{ |
| 10850 |
gcc_assert (REG_P (dest) || SUBREG_P (dest)); |
| 10851 |
rs6000_emit_le_vsx_load (dest, source, mode); |
| 10852 |
} |
| 10853 |
else |
| 10854 |
{ |
| 10855 |
if (!REG_P (source)) |
| 10856 |
source = force_reg (mode, source); |
| 10857 |
rs6000_emit_le_vsx_store (dest, source, mode); |
| 10858 |
} |
| 10859 |
} |
| 10860 |
|
| 10861 |
/* Return whether a SFmode or SImode move can be done without converting one |
| 10862 |
mode to another. This arrises when we have: |
| 10863 |
|
| 10864 |
(SUBREG:SF (REG:SI ...)) |
| 10865 |
(SUBREG:SI (REG:SF ...)) |
| 10866 |
|
| 10867 |
and one of the values is in a floating point/vector register, where SFmode |
| 10868 |
scalars are stored in DFmode format. */ |
| 10869 |
|
| 10870 |
bool |
| 10871 |
valid_sf_si_move (rtx dest, rtx src, machine_mode mode) |
| 10872 |
{ |
| 10873 |
if (TARGET_ALLOW_SF_SUBREG) |
| 10874 |
return true; |
| 10875 |
|
| 10876 |
if (mode != SFmode && GET_MODE_CLASS (mode) != MODE_INT) |
| 10877 |
return true; |
| 10878 |
|
| 10879 |
if (!SUBREG_P (src) || !sf_subreg_operand (src, mode)) |
| 10880 |
return true; |
| 10881 |
|
| 10882 |
/*. Allow (set (SUBREG:SI (REG:SF)) (SUBREG:SI (REG:SF))). */ |
| 10883 |
if (SUBREG_P (dest)) |
| 10884 |
{ |
| 10885 |
rtx dest_subreg = SUBREG_REG (dest); |
| 10886 |
rtx src_subreg = SUBREG_REG (src); |
| 10887 |
return GET_MODE (dest_subreg) == GET_MODE (src_subreg); |
| 10888 |
} |
| 10889 |
|
| 10890 |
return false; |
| 10891 |
} |
| 10892 |
|
| 10893 |
|
| 10894 |
/* Helper function to change moves with: |
| 10895 |
|
| 10896 |
(SUBREG:SF (REG:SI)) and |
| 10897 |
(SUBREG:SI (REG:SF)) |
| 10898 |
|
| 10899 |
into separate UNSPEC insns. In the PowerPC architecture, scalar SFmode |
| 10900 |
values are stored as DFmode values in the VSX registers. We need to convert |
| 10901 |
the bits before we can use a direct move or operate on the bits in the |
| 10902 |
vector register as an integer type. |
| 10903 |
|
| 10904 |
Skip things like (set (SUBREG:SI (...) (SUBREG:SI (...)). */ |
| 10905 |
|
| 10906 |
static bool |
| 10907 |
rs6000_emit_move_si_sf_subreg (rtx dest, rtx source, machine_mode mode) |
| 10908 |
{ |
| 10909 |
if (TARGET_DIRECT_MOVE_64BIT && !reload_completed |
| 10910 |
&& (!SUBREG_P (dest) || !sf_subreg_operand (dest, mode)) |
| 10911 |
&& SUBREG_P (source) && sf_subreg_operand (source, mode)) |
| 10912 |
{ |
| 10913 |
rtx inner_source = SUBREG_REG (source); |
| 10914 |
machine_mode inner_mode = GET_MODE (inner_source); |
| 10915 |
|
| 10916 |
if (mode == SImode && inner_mode == SFmode) |
| 10917 |
{ |
| 10918 |
emit_insn (gen_movsi_from_sf (dest, inner_source)); |
| 10919 |
return true; |
| 10920 |
} |
| 10921 |
|
| 10922 |
if (mode == SFmode && inner_mode == SImode) |
| 10923 |
{ |
| 10924 |
emit_insn (gen_movsf_from_si (dest, inner_source)); |
| 10925 |
return true; |
| 10926 |
} |
| 10927 |
} |
| 10928 |
|
| 10929 |
return false; |
| 10930 |
} |
| 10931 |
|
| 10932 |
/* Emit a move from SOURCE to DEST in mode MODE. */ |
| 10933 |
void |
| 10934 |
rs6000_emit_move (rtx dest, rtx source, machine_mode mode) |
| 10935 |
{ |
| 10936 |
rtx operands[2]; |
| 10937 |
operands[0] = dest; |
| 10938 |
operands[1] = source; |
| 10939 |
|
| 10940 |
if (TARGET_DEBUG_ADDR) |
| 10941 |
{ |
| 10942 |
fprintf (stderr, |
| 10943 |
"\nrs6000_emit_move: mode = %s, lra_in_progress = %d, " |
| 10944 |
"reload_completed = %d, can_create_pseudos = %d.\ndest:\n", |
| 10945 |
GET_MODE_NAME (mode), |
| 10946 |
lra_in_progress, |
| 10947 |
reload_completed, |
| 10948 |
can_create_pseudo_p ()); |
| 10949 |
debug_rtx (dest); |
| 10950 |
fprintf (stderr, "source:\n"); |
| 10951 |
debug_rtx (source); |
| 10952 |
} |
| 10953 |
|
| 10954 |
/* Check that we get CONST_WIDE_INT only when we should. */ |
| 10955 |
if (CONST_WIDE_INT_P (operands[1]) |
| 10956 |
&& GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) |
| 10957 |
gcc_unreachable (); |
| 10958 |
|
| 10959 |
#ifdef HAVE_AS_GNU_ATTRIBUTE |
| 10960 |
/* If we use a long double type, set the flags in .gnu_attribute that say |
| 10961 |
what the long double type is. This is to allow the linker's warning |
| 10962 |
message for the wrong long double to be useful, even if the function does |
| 10963 |
not do a call (for example, doing a 128-bit add on power9 if the long |
| 10964 |
double type is IEEE 128-bit. Do not set this if __ibm128 or __floa128 are |
| 10965 |
used if they aren't the default long dobule type. */ |
| 10966 |
if (rs6000_gnu_attr && (HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE || TARGET_64BIT)) |
| 10967 |
{ |
| 10968 |
if (TARGET_LONG_DOUBLE_128 && (mode == TFmode || mode == TCmode)) |
| 10969 |
rs6000_passes_float = rs6000_passes_long_double = true; |
| 10970 |
|
| 10971 |
else if (!TARGET_LONG_DOUBLE_128 && (mode == DFmode || mode == DCmode)) |
| 10972 |
rs6000_passes_float = rs6000_passes_long_double = true; |
| 10973 |
} |
| 10974 |
#endif |
| 10975 |
|
| 10976 |
/* See if we need to special case SImode/SFmode SUBREG moves. */ |
| 10977 |
if ((mode == SImode || mode == SFmode) && SUBREG_P (source) |
| 10978 |
&& rs6000_emit_move_si_sf_subreg (dest, source, mode)) |
| 10979 |
return; |
| 10980 |
|
| 10981 |
/* Check if GCC is setting up a block move that will end up using FP |
| 10982 |
registers as temporaries. We must make sure this is acceptable. */ |
| 10983 |
if (MEM_P (operands[0]) |
| 10984 |
&& MEM_P (operands[1]) |
| 10985 |
&& mode == DImode |
| 10986 |
&& (rs6000_slow_unaligned_access (DImode, MEM_ALIGN (operands[0])) |
| 10987 |
|| rs6000_slow_unaligned_access (DImode, MEM_ALIGN (operands[1]))) |
| 10988 |
&& ! (rs6000_slow_unaligned_access (SImode, |
| 10989 |
(MEM_ALIGN (operands[0]) > 32 |
| 10990 |
? 32 : MEM_ALIGN (operands[0]))) |
| 10991 |
|| rs6000_slow_unaligned_access (SImode, |
| 10992 |
(MEM_ALIGN (operands[1]) > 32 |
| 10993 |
? 32 : MEM_ALIGN (operands[1])))) |
| 10994 |
&& ! MEM_VOLATILE_P (operands [0]) |
| 10995 |
&& ! MEM_VOLATILE_P (operands [1])) |
| 10996 |
{ |
| 10997 |
emit_move_insn (adjust_address (operands[0], SImode, 0), |
| 10998 |
adjust_address (operands[1], SImode, 0)); |
| 10999 |
emit_move_insn (adjust_address (copy_rtx (operands[0]), SImode, 4), |
| 11000 |
adjust_address (copy_rtx (operands[1]), SImode, 4)); |
| 11001 |
return; |
| 11002 |
} |
| 11003 |
|
| 11004 |
if (can_create_pseudo_p () && MEM_P (operands[0]) |
| 11005 |
&& !gpc_reg_operand (operands[1], mode)) |
| 11006 |
operands[1] = force_reg (mode, operands[1]); |
| 11007 |
|
| 11008 |
/* Recognize the case where operand[1] is a reference to thread-local |
| 11009 |
data and load its address to a register. */ |
| 11010 |
if (tls_referenced_p (operands[1])) |
| 11011 |
{ |
| 11012 |
enum tls_model model; |
| 11013 |
rtx tmp = operands[1]; |
| 11014 |
rtx addend = NULL; |
| 11015 |
|
| 11016 |
if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS) |
| 11017 |
{ |
| 11018 |
addend = XEXP (XEXP (tmp, 0), 1); |
| 11019 |
tmp = XEXP (XEXP (tmp, 0), 0); |
| 11020 |
} |
| 11021 |
|
| 11022 |
gcc_assert (SYMBOL_REF_P (tmp)); |
| 11023 |
model = SYMBOL_REF_TLS_MODEL (tmp); |
| 11024 |
gcc_assert (model != 0); |
| 11025 |
|
| 11026 |
tmp = rs6000_legitimize_tls_address (tmp, model); |
| 11027 |
if (addend) |
| 11028 |
{ |
| 11029 |
tmp = gen_rtx_PLUS (mode, tmp, addend); |
| 11030 |
tmp = force_operand (tmp, operands[0]); |
| 11031 |
} |
| 11032 |
operands[1] = tmp; |
| 11033 |
} |
| 11034 |
|
| 11035 |
/* 128-bit constant floating-point values on Darwin should really be loaded |
| 11036 |
as two parts. However, this premature splitting is a problem when DFmode |
| 11037 |
values can go into Altivec registers. */ |
| 11038 |
if (TARGET_MACHO && CONST_DOUBLE_P (operands[1]) && FLOAT128_IBM_P (mode) |
| 11039 |
&& !reg_addr[DFmode].scalar_in_vmx_p) |
| 11040 |
{ |
| 11041 |
rs6000_emit_move (simplify_gen_subreg (DFmode, operands[0], mode, 0), |
| 11042 |
simplify_gen_subreg (DFmode, operands[1], mode, 0), |
| 11043 |
DFmode); |
| 11044 |
rs6000_emit_move (simplify_gen_subreg (DFmode, operands[0], mode, |
| 11045 |
GET_MODE_SIZE (DFmode)), |
| 11046 |
simplify_gen_subreg (DFmode, operands[1], mode, |
| 11047 |
GET_MODE_SIZE (DFmode)), |
| 11048 |
DFmode); |
| 11049 |
return; |
| 11050 |
} |
| 11051 |
|
| 11052 |
/* Transform (p0:DD, (SUBREG:DD p1:SD)) to ((SUBREG:SD p0:DD), |
| 11053 |
p1:SD) if p1 is not of floating point class and p0 is spilled as |
| 11054 |
we can have no analogous movsd_store for this. */ |
| 11055 |
if (lra_in_progress && mode == DDmode |
| 11056 |
&& REG_P (operands[0]) && !HARD_REGISTER_P (operands[0]) |
| 11057 |
&& reg_preferred_class (REGNO (operands[0])) == NO_REGS |
| 11058 |
&& SUBREG_P (operands[1]) && REG_P (SUBREG_REG (operands[1])) |
| 11059 |
&& GET_MODE (SUBREG_REG (operands[1])) == SDmode) |
| 11060 |
{ |
| 11061 |
enum reg_class cl; |
| 11062 |
int regno = REGNO (SUBREG_REG (operands[1])); |
| 11063 |
|
| 11064 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 11065 |
{ |
| 11066 |
cl = reg_preferred_class (regno); |
| 11067 |
regno = reg_renumber[regno]; |
| 11068 |
if (regno < 0) |
| 11069 |
regno = cl == NO_REGS ? -1 : ira_class_hard_regs[cl][1]; |
| 11070 |
} |
| 11071 |
if (regno >= 0 && ! FP_REGNO_P (regno)) |
| 11072 |
{ |
| 11073 |
mode = SDmode; |
| 11074 |
operands[0] = gen_lowpart_SUBREG (SDmode, operands[0]); |
| 11075 |
operands[1] = SUBREG_REG (operands[1]); |
| 11076 |
} |
| 11077 |
} |
| 11078 |
if (lra_in_progress |
| 11079 |
&& mode == SDmode |
| 11080 |
&& REG_P (operands[0]) && !HARD_REGISTER_P (operands[0]) |
| 11081 |
&& reg_preferred_class (REGNO (operands[0])) == NO_REGS |
| 11082 |
&& (REG_P (operands[1]) |
| 11083 |
|| (SUBREG_P (operands[1]) && REG_P (SUBREG_REG (operands[1]))))) |
| 11084 |
{ |
| 11085 |
int regno = reg_or_subregno (operands[1]); |
| 11086 |
enum reg_class cl; |
| 11087 |
|
| 11088 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 11089 |
{ |
| 11090 |
cl = reg_preferred_class (regno); |
| 11091 |
gcc_assert (cl != NO_REGS); |
| 11092 |
regno = reg_renumber[regno]; |
| 11093 |
if (regno < 0) |
| 11094 |
regno = ira_class_hard_regs[cl][0]; |
| 11095 |
} |
| 11096 |
if (FP_REGNO_P (regno)) |
| 11097 |
{ |
| 11098 |
if (GET_MODE (operands[0]) != DDmode) |
| 11099 |
operands[0] = gen_rtx_SUBREG (DDmode, operands[0], 0); |
| 11100 |
emit_insn (gen_movsd_store (operands[0], operands[1])); |
| 11101 |
} |
| 11102 |
else if (INT_REGNO_P (regno)) |
| 11103 |
emit_insn (gen_movsd_hardfloat (operands[0], operands[1])); |
| 11104 |
else |
| 11105 |
gcc_unreachable(); |
| 11106 |
return; |
| 11107 |
} |
| 11108 |
/* Transform ((SUBREG:DD p0:SD), p1:DD) to (p0:SD, (SUBREG:SD |
| 11109 |
p:DD)) if p0 is not of floating point class and p1 is spilled as |
| 11110 |
we can have no analogous movsd_load for this. */ |
| 11111 |
if (lra_in_progress && mode == DDmode |
| 11112 |
&& SUBREG_P (operands[0]) && REG_P (SUBREG_REG (operands[0])) |
| 11113 |
&& GET_MODE (SUBREG_REG (operands[0])) == SDmode |
| 11114 |
&& REG_P (operands[1]) && !HARD_REGISTER_P (operands[1]) |
| 11115 |
&& reg_preferred_class (REGNO (operands[1])) == NO_REGS) |
| 11116 |
{ |
| 11117 |
enum reg_class cl; |
| 11118 |
int regno = REGNO (SUBREG_REG (operands[0])); |
| 11119 |
|
| 11120 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 11121 |
{ |
| 11122 |
cl = reg_preferred_class (regno); |
| 11123 |
regno = reg_renumber[regno]; |
| 11124 |
if (regno < 0) |
| 11125 |
regno = cl == NO_REGS ? -1 : ira_class_hard_regs[cl][0]; |
| 11126 |
} |
| 11127 |
if (regno >= 0 && ! FP_REGNO_P (regno)) |
| 11128 |
{ |
| 11129 |
mode = SDmode; |
| 11130 |
operands[0] = SUBREG_REG (operands[0]); |
| 11131 |
operands[1] = gen_lowpart_SUBREG (SDmode, operands[1]); |
| 11132 |
} |
| 11133 |
} |
| 11134 |
if (lra_in_progress |
| 11135 |
&& mode == SDmode |
| 11136 |
&& (REG_P (operands[0]) |
| 11137 |
|| (SUBREG_P (operands[0]) && REG_P (SUBREG_REG (operands[0])))) |
| 11138 |
&& REG_P (operands[1]) && !HARD_REGISTER_P (operands[1]) |
| 11139 |
&& reg_preferred_class (REGNO (operands[1])) == NO_REGS) |
| 11140 |
{ |
| 11141 |
int regno = reg_or_subregno (operands[0]); |
| 11142 |
enum reg_class cl; |
| 11143 |
|
| 11144 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 11145 |
{ |
| 11146 |
cl = reg_preferred_class (regno); |
| 11147 |
gcc_assert (cl != NO_REGS); |
| 11148 |
regno = reg_renumber[regno]; |
| 11149 |
if (regno < 0) |
| 11150 |
regno = ira_class_hard_regs[cl][0]; |
| 11151 |
} |
| 11152 |
if (FP_REGNO_P (regno)) |
| 11153 |
{ |
| 11154 |
if (GET_MODE (operands[1]) != DDmode) |
| 11155 |
operands[1] = gen_rtx_SUBREG (DDmode, operands[1], 0); |
| 11156 |
emit_insn (gen_movsd_load (operands[0], operands[1])); |
| 11157 |
} |
| 11158 |
else if (INT_REGNO_P (regno)) |
| 11159 |
emit_insn (gen_movsd_hardfloat (operands[0], operands[1])); |
| 11160 |
else |
| 11161 |
gcc_unreachable(); |
| 11162 |
return; |
| 11163 |
} |
| 11164 |
|
| 11165 |
/* FIXME: In the long term, this switch statement should go away |
| 11166 |
and be replaced by a sequence of tests based on things like |
| 11167 |
mode == Pmode. */ |
| 11168 |
switch (mode) |
| 11169 |
{ |
| 11170 |
case E_HImode: |
| 11171 |
case E_QImode: |
| 11172 |
if (CONSTANT_P (operands[1]) |
| 11173 |
&& !CONST_INT_P (operands[1])) |
| 11174 |
operands[1] = force_const_mem (mode, operands[1]); |
| 11175 |
break; |
| 11176 |
|
| 11177 |
case E_TFmode: |
| 11178 |
case E_TDmode: |
| 11179 |
case E_IFmode: |
| 11180 |
case E_KFmode: |
| 11181 |
if (FLOAT128_2REG_P (mode)) |
| 11182 |
rs6000_eliminate_indexed_memrefs (operands); |
| 11183 |
/* fall through */ |
| 11184 |
|
| 11185 |
case E_DFmode: |
| 11186 |
case E_DDmode: |
| 11187 |
case E_SFmode: |
| 11188 |
case E_SDmode: |
| 11189 |
if (CONSTANT_P (operands[1]) |
| 11190 |
&& ! easy_fp_constant (operands[1], mode)) |
| 11191 |
operands[1] = force_const_mem (mode, operands[1]); |
| 11192 |
break; |
| 11193 |
|
| 11194 |
case E_V16QImode: |
| 11195 |
case E_V8HImode: |
| 11196 |
case E_V4SFmode: |
| 11197 |
case E_V4SImode: |
| 11198 |
case E_V2DFmode: |
| 11199 |
case E_V2DImode: |
| 11200 |
case E_V1TImode: |
| 11201 |
if (CONSTANT_P (operands[1]) |
| 11202 |
&& !easy_vector_constant (operands[1], mode)) |
| 11203 |
operands[1] = force_const_mem (mode, operands[1]); |
| 11204 |
break; |
| 11205 |
|
| 11206 |
case E_OOmode: |
| 11207 |
case E_XOmode: |
| 11208 |
if (CONST_INT_P (operands[1]) && INTVAL (operands[1]) != 0) |
| 11209 |
error ("%qs is an opaque type, and you cannot set it to other values", |
| 11210 |
(mode == OOmode) ? "__vector_pair" : "__vector_quad"); |
| 11211 |
break; |
| 11212 |
|
| 11213 |
case E_SImode: |
| 11214 |
case E_DImode: |
| 11215 |
/* Use default pattern for address of ELF small data */ |
| 11216 |
if (TARGET_ELF |
| 11217 |
&& mode == Pmode |
| 11218 |
&& DEFAULT_ABI == ABI_V4 |
| 11219 |
&& (SYMBOL_REF_P (operands[1]) |
| 11220 |
|| GET_CODE (operands[1]) == CONST) |
| 11221 |
&& small_data_operand (operands[1], mode)) |
| 11222 |
{ |
| 11223 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 11224 |
return; |
| 11225 |
} |
| 11226 |
|
| 11227 |
/* Use the default pattern for loading up PC-relative addresses. */ |
| 11228 |
if (TARGET_PCREL && mode == Pmode |
| 11229 |
&& pcrel_local_or_external_address (operands[1], Pmode)) |
| 11230 |
{ |
| 11231 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 11232 |
return; |
| 11233 |
} |
| 11234 |
|
| 11235 |
if (DEFAULT_ABI == ABI_V4 |
| 11236 |
&& mode == Pmode && mode == SImode |
| 11237 |
&& flag_pic == 1 && got_operand (operands[1], mode)) |
| 11238 |
{ |
| 11239 |
emit_insn (gen_movsi_got (operands[0], operands[1])); |
| 11240 |
return; |
| 11241 |
} |
| 11242 |
|
| 11243 |
if ((TARGET_ELF || DEFAULT_ABI == ABI_DARWIN) |
| 11244 |
&& TARGET_NO_TOC_OR_PCREL |
| 11245 |
&& ! flag_pic |
| 11246 |
&& mode == Pmode |
| 11247 |
&& CONSTANT_P (operands[1]) |
| 11248 |
&& GET_CODE (operands[1]) != HIGH |
| 11249 |
&& !CONST_INT_P (operands[1])) |
| 11250 |
{ |
| 11251 |
rtx target = (!can_create_pseudo_p () |
| 11252 |
? operands[0] |
| 11253 |
: gen_reg_rtx (mode)); |
| 11254 |
|
| 11255 |
/* If this is a function address on -mcall-aixdesc, |
| 11256 |
convert it to the address of the descriptor. */ |
| 11257 |
if (DEFAULT_ABI == ABI_AIX |
| 11258 |
&& SYMBOL_REF_P (operands[1]) |
| 11259 |
&& XSTR (operands[1], 0)[0] == '.') |
| 11260 |
{ |
| 11261 |
const char *name = XSTR (operands[1], 0); |
| 11262 |
rtx new_ref; |
| 11263 |
while (*name == '.') |
| 11264 |
name++; |
| 11265 |
new_ref = gen_rtx_SYMBOL_REF (Pmode, name); |
| 11266 |
CONSTANT_POOL_ADDRESS_P (new_ref) |
| 11267 |
= CONSTANT_POOL_ADDRESS_P (operands[1]); |
| 11268 |
SYMBOL_REF_FLAGS (new_ref) = SYMBOL_REF_FLAGS (operands[1]); |
| 11269 |
SYMBOL_REF_USED (new_ref) = SYMBOL_REF_USED (operands[1]); |
| 11270 |
SYMBOL_REF_DATA (new_ref) = SYMBOL_REF_DATA (operands[1]); |
| 11271 |
operands[1] = new_ref; |
| 11272 |
} |
| 11273 |
|
| 11274 |
if (DEFAULT_ABI == ABI_DARWIN) |
| 11275 |
{ |
| 11276 |
#if TARGET_MACHO |
| 11277 |
/* This is not PIC code, but could require the subset of |
| 11278 |
indirections used by mdynamic-no-pic. */ |
| 11279 |
if (MACHO_DYNAMIC_NO_PIC_P) |
| 11280 |
{ |
| 11281 |
/* Take care of any required data indirection. */ |
| 11282 |
operands[1] = rs6000_machopic_legitimize_pic_address ( |
| 11283 |
operands[1], mode, operands[0]); |
| 11284 |
if (operands[0] != operands[1]) |
| 11285 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 11286 |
return; |
| 11287 |
} |
| 11288 |
#endif |
| 11289 |
emit_insn (gen_macho_high (Pmode, target, operands[1])); |
| 11290 |
emit_insn (gen_macho_low (Pmode, operands[0], |
| 11291 |
target, operands[1])); |
| 11292 |
return; |
| 11293 |
} |
| 11294 |
|
| 11295 |
emit_insn (gen_elf_high (target, operands[1])); |
| 11296 |
emit_insn (gen_elf_low (operands[0], target, operands[1])); |
| 11297 |
return; |
| 11298 |
} |
| 11299 |
|
| 11300 |
/* If this is a SYMBOL_REF that refers to a constant pool entry, |
| 11301 |
and we have put it in the TOC, we just need to make a TOC-relative |
| 11302 |
reference to it. */ |
| 11303 |
if (TARGET_TOC |
| 11304 |
&& SYMBOL_REF_P (operands[1]) |
| 11305 |
&& use_toc_relative_ref (operands[1], mode)) |
| 11306 |
operands[1] = create_TOC_reference (operands[1], operands[0]); |
| 11307 |
else if (mode == Pmode |
| 11308 |
&& CONSTANT_P (operands[1]) |
| 11309 |
&& GET_CODE (operands[1]) != HIGH |
| 11310 |
&& ((REG_P (operands[0]) |
| 11311 |
&& FP_REGNO_P (REGNO (operands[0]))) |
| 11312 |
|| !CONST_INT_P (operands[1]) |
| 11313 |
|| (num_insns_constant (operands[1], mode) |
| 11314 |
> (TARGET_CMODEL != CMODEL_SMALL ? 3 : 2))) |
| 11315 |
&& !toc_relative_expr_p (operands[1], false, NULL, NULL) |
| 11316 |
&& (TARGET_CMODEL == CMODEL_SMALL |
| 11317 |
|| can_create_pseudo_p () |
| 11318 |
|| (REG_P (operands[0]) |
| 11319 |
&& INT_REG_OK_FOR_BASE_P (operands[0], true)))) |
| 11320 |
{ |
| 11321 |
|
| 11322 |
#if TARGET_MACHO |
| 11323 |
/* Darwin uses a special PIC legitimizer. */ |
| 11324 |
if (DEFAULT_ABI == ABI_DARWIN && MACHOPIC_INDIRECT) |
| 11325 |
{ |
| 11326 |
operands[1] = |
| 11327 |
rs6000_machopic_legitimize_pic_address (operands[1], mode, |
| 11328 |
operands[0]); |
| 11329 |
if (operands[0] != operands[1]) |
| 11330 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 11331 |
return; |
| 11332 |
} |
| 11333 |
#endif |
| 11334 |
|
| 11335 |
/* If we are to limit the number of things we put in the TOC and |
| 11336 |
this is a symbol plus a constant we can add in one insn, |
| 11337 |
just put the symbol in the TOC and add the constant. */ |
| 11338 |
if (GET_CODE (operands[1]) == CONST |
| 11339 |
&& TARGET_NO_SUM_IN_TOC |
| 11340 |
&& GET_CODE (XEXP (operands[1], 0)) == PLUS |
| 11341 |
&& add_operand (XEXP (XEXP (operands[1], 0), 1), mode) |
| 11342 |
&& (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF |
| 11343 |
|| SYMBOL_REF_P (XEXP (XEXP (operands[1], 0), 0))) |
| 11344 |
&& ! side_effects_p (operands[0])) |
| 11345 |
{ |
| 11346 |
rtx sym = |
| 11347 |
force_const_mem (mode, XEXP (XEXP (operands[1], 0), 0)); |
| 11348 |
rtx other = XEXP (XEXP (operands[1], 0), 1); |
| 11349 |
|
| 11350 |
sym = force_reg (mode, sym); |
| 11351 |
emit_insn (gen_add3_insn (operands[0], sym, other)); |
| 11352 |
return; |
| 11353 |
} |
| 11354 |
|
| 11355 |
operands[1] = force_const_mem (mode, operands[1]); |
| 11356 |
|
| 11357 |
if (TARGET_TOC |
| 11358 |
&& SYMBOL_REF_P (XEXP (operands[1], 0)) |
| 11359 |
&& use_toc_relative_ref (XEXP (operands[1], 0), mode)) |
| 11360 |
{ |
| 11361 |
rtx tocref = create_TOC_reference (XEXP (operands[1], 0), |
| 11362 |
operands[0]); |
| 11363 |
operands[1] = gen_const_mem (mode, tocref); |
| 11364 |
set_mem_alias_set (operands[1], get_TOC_alias_set ()); |
| 11365 |
} |
| 11366 |
} |
| 11367 |
break; |
| 11368 |
|
| 11369 |
case E_TImode: |
| 11370 |
if (!VECTOR_MEM_VSX_P (TImode)) |
| 11371 |
rs6000_eliminate_indexed_memrefs (operands); |
| 11372 |
break; |
| 11373 |
|
| 11374 |
case E_PTImode: |
| 11375 |
rs6000_eliminate_indexed_memrefs (operands); |
| 11376 |
break; |
| 11377 |
|
| 11378 |
default: |
| 11379 |
fatal_insn ("bad move", gen_rtx_SET (dest, source)); |
| 11380 |
} |
| 11381 |
|
| 11382 |
/* Above, we may have called force_const_mem which may have returned |
| 11383 |
an invalid address. If we can, fix this up; otherwise, reload will |
| 11384 |
have to deal with it. */ |
| 11385 |
if (MEM_P (operands[1])) |
| 11386 |
operands[1] = validize_mem (operands[1]); |
| 11387 |
|
| 11388 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 11389 |
} |
| 11390 |
|
| 11391 |
|
| 11392 |
/* Set up AIX/Darwin/64-bit Linux quad floating point routines. */ |
| 11393 |
static void |
| 11394 |
init_float128_ibm (machine_mode mode) |
| 11395 |
{ |
| 11396 |
if (!TARGET_XL_COMPAT) |
| 11397 |
{ |
| 11398 |
set_optab_libfunc (add_optab, mode, "__gcc_qadd"); |
| 11399 |
set_optab_libfunc (sub_optab, mode, "__gcc_qsub"); |
| 11400 |
set_optab_libfunc (smul_optab, mode, "__gcc_qmul"); |
| 11401 |
set_optab_libfunc (sdiv_optab, mode, "__gcc_qdiv"); |
| 11402 |
|
| 11403 |
if (!TARGET_HARD_FLOAT) |
| 11404 |
{ |
| 11405 |
set_optab_libfunc (neg_optab, mode, "__gcc_qneg"); |
| 11406 |
set_optab_libfunc (eq_optab, mode, "__gcc_qeq"); |
| 11407 |
set_optab_libfunc (ne_optab, mode, "__gcc_qne"); |
| 11408 |
set_optab_libfunc (gt_optab, mode, "__gcc_qgt"); |
| 11409 |
set_optab_libfunc (ge_optab, mode, "__gcc_qge"); |
| 11410 |
set_optab_libfunc (lt_optab, mode, "__gcc_qlt"); |
| 11411 |
set_optab_libfunc (le_optab, mode, "__gcc_qle"); |
| 11412 |
set_optab_libfunc (unord_optab, mode, "__gcc_qunord"); |
| 11413 |
|
| 11414 |
set_conv_libfunc (sext_optab, mode, SFmode, "__gcc_stoq"); |
| 11415 |
set_conv_libfunc (sext_optab, mode, DFmode, "__gcc_dtoq"); |
| 11416 |
set_conv_libfunc (trunc_optab, SFmode, mode, "__gcc_qtos"); |
| 11417 |
set_conv_libfunc (trunc_optab, DFmode, mode, "__gcc_qtod"); |
| 11418 |
set_conv_libfunc (sfix_optab, SImode, mode, "__gcc_qtoi"); |
| 11419 |
set_conv_libfunc (ufix_optab, SImode, mode, "__gcc_qtou"); |
| 11420 |
set_conv_libfunc (sfloat_optab, mode, SImode, "__gcc_itoq"); |
| 11421 |
set_conv_libfunc (ufloat_optab, mode, SImode, "__gcc_utoq"); |
| 11422 |
} |
| 11423 |
} |
| 11424 |
else |
| 11425 |
{ |
| 11426 |
set_optab_libfunc (add_optab, mode, "_xlqadd"); |
| 11427 |
set_optab_libfunc (sub_optab, mode, "_xlqsub"); |
| 11428 |
set_optab_libfunc (smul_optab, mode, "_xlqmul"); |
| 11429 |
set_optab_libfunc (sdiv_optab, mode, "_xlqdiv"); |
| 11430 |
} |
| 11431 |
|
| 11432 |
/* Add various conversions for IFmode to use the traditional TFmode |
| 11433 |
names. */ |
| 11434 |
if (mode == IFmode) |
| 11435 |
{ |
| 11436 |
set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdtf"); |
| 11437 |
set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddtf"); |
| 11438 |
set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctdtf"); |
| 11439 |
set_conv_libfunc (trunc_optab, SDmode, mode, "__dpd_trunctfsd"); |
| 11440 |
set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd"); |
| 11441 |
set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtftd"); |
| 11442 |
|
| 11443 |
set_conv_libfunc (sfix_optab, DImode, mode, "__fixtfdi"); |
| 11444 |
set_conv_libfunc (ufix_optab, DImode, mode, "__fixunstfdi"); |
| 11445 |
|
| 11446 |
set_conv_libfunc (sfloat_optab, mode, DImode, "__floatditf"); |
| 11447 |
set_conv_libfunc (ufloat_optab, mode, DImode, "__floatunditf"); |
| 11448 |
|
| 11449 |
if (TARGET_POWERPC64) |
| 11450 |
{ |
| 11451 |
set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti"); |
| 11452 |
set_conv_libfunc (ufix_optab, TImode, mode, "__fixunstfti"); |
| 11453 |
set_conv_libfunc (sfloat_optab, mode, TImode, "__floattitf"); |
| 11454 |
set_conv_libfunc (ufloat_optab, mode, TImode, "__floatuntitf"); |
| 11455 |
} |
| 11456 |
} |
| 11457 |
} |
| 11458 |
|
| 11459 |
/* Set up IEEE 128-bit floating point routines. Use different names if the |
| 11460 |
arguments can be passed in a vector register. The historical PowerPC |
| 11461 |
implementation of IEEE 128-bit floating point used _q_<op> for the names, so |
| 11462 |
continue to use that if we aren't using vector registers to pass IEEE |
| 11463 |
128-bit floating point. */ |
| 11464 |
|
| 11465 |
static void |
| 11466 |
init_float128_ieee (machine_mode mode) |
| 11467 |
{ |
| 11468 |
if (FLOAT128_VECTOR_P (mode)) |
| 11469 |
{ |
| 11470 |
set_optab_libfunc (add_optab, mode, "__addkf3"); |
| 11471 |
set_optab_libfunc (sub_optab, mode, "__subkf3"); |
| 11472 |
set_optab_libfunc (neg_optab, mode, "__negkf2"); |
| 11473 |
set_optab_libfunc (smul_optab, mode, "__mulkf3"); |
| 11474 |
set_optab_libfunc (sdiv_optab, mode, "__divkf3"); |
| 11475 |
set_optab_libfunc (sqrt_optab, mode, "__sqrtkf2"); |
| 11476 |
set_optab_libfunc (abs_optab, mode, "__abskf2"); |
| 11477 |
set_optab_libfunc (powi_optab, mode, "__powikf2"); |
| 11478 |
|
| 11479 |
set_optab_libfunc (eq_optab, mode, "__eqkf2"); |
| 11480 |
set_optab_libfunc (ne_optab, mode, "__nekf2"); |
| 11481 |
set_optab_libfunc (gt_optab, mode, "__gtkf2"); |
| 11482 |
set_optab_libfunc (ge_optab, mode, "__gekf2"); |
| 11483 |
set_optab_libfunc (lt_optab, mode, "__ltkf2"); |
| 11484 |
set_optab_libfunc (le_optab, mode, "__lekf2"); |
| 11485 |
set_optab_libfunc (unord_optab, mode, "__unordkf2"); |
| 11486 |
|
| 11487 |
set_conv_libfunc (sext_optab, mode, SFmode, "__extendsfkf2"); |
| 11488 |
set_conv_libfunc (sext_optab, mode, DFmode, "__extenddfkf2"); |
| 11489 |
set_conv_libfunc (trunc_optab, SFmode, mode, "__trunckfsf2"); |
| 11490 |
set_conv_libfunc (trunc_optab, DFmode, mode, "__trunckfdf2"); |
| 11491 |
|
| 11492 |
set_conv_libfunc (trunc_optab, mode, IFmode, "__trunctfkf2"); |
| 11493 |
if (mode != TFmode && FLOAT128_IBM_P (TFmode)) |
| 11494 |
set_conv_libfunc (trunc_optab, mode, TFmode, "__trunctfkf2"); |
| 11495 |
|
| 11496 |
set_conv_libfunc (sext_optab, IFmode, mode, "__extendkftf2"); |
| 11497 |
if (mode != TFmode && FLOAT128_IBM_P (TFmode)) |
| 11498 |
set_conv_libfunc (sext_optab, TFmode, mode, "__extendkftf2"); |
| 11499 |
|
| 11500 |
set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdkf"); |
| 11501 |
set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddkf"); |
| 11502 |
set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctdkf"); |
| 11503 |
set_conv_libfunc (trunc_optab, SDmode, mode, "__dpd_trunckfsd"); |
| 11504 |
set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunckfdd"); |
| 11505 |
set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendkftd"); |
| 11506 |
|
| 11507 |
set_conv_libfunc (sfix_optab, SImode, mode, "__fixkfsi"); |
| 11508 |
set_conv_libfunc (ufix_optab, SImode, mode, "__fixunskfsi"); |
| 11509 |
set_conv_libfunc (sfix_optab, DImode, mode, "__fixkfdi"); |
| 11510 |
set_conv_libfunc (ufix_optab, DImode, mode, "__fixunskfdi"); |
| 11511 |
|
| 11512 |
set_conv_libfunc (sfloat_optab, mode, SImode, "__floatsikf"); |
| 11513 |
set_conv_libfunc (ufloat_optab, mode, SImode, "__floatunsikf"); |
| 11514 |
set_conv_libfunc (sfloat_optab, mode, DImode, "__floatdikf"); |
| 11515 |
set_conv_libfunc (ufloat_optab, mode, DImode, "__floatundikf"); |
| 11516 |
|
| 11517 |
if (TARGET_POWERPC64) |
| 11518 |
{ |
| 11519 |
set_conv_libfunc (sfix_optab, TImode, mode, "__fixkfti_sw"); |
| 11520 |
set_conv_libfunc (ufix_optab, TImode, mode, "__fixunskfti_sw"); |
| 11521 |
set_conv_libfunc (sfloat_optab, mode, TImode, "__floattikf_sw"); |
| 11522 |
set_conv_libfunc (ufloat_optab, mode, TImode, "__floatuntikf_sw"); |
| 11523 |
} |
| 11524 |
} |
| 11525 |
|
| 11526 |
else |
| 11527 |
{ |
| 11528 |
set_optab_libfunc (add_optab, mode, "_q_add"); |
| 11529 |
set_optab_libfunc (sub_optab, mode, "_q_sub"); |
| 11530 |
set_optab_libfunc (neg_optab, mode, "_q_neg"); |
| 11531 |
set_optab_libfunc (smul_optab, mode, "_q_mul"); |
| 11532 |
set_optab_libfunc (sdiv_optab, mode, "_q_div"); |
| 11533 |
if (TARGET_PPC_GPOPT) |
| 11534 |
set_optab_libfunc (sqrt_optab, mode, "_q_sqrt"); |
| 11535 |
|
| 11536 |
set_optab_libfunc (eq_optab, mode, "_q_feq"); |
| 11537 |
set_optab_libfunc (ne_optab, mode, "_q_fne"); |
| 11538 |
set_optab_libfunc (gt_optab, mode, "_q_fgt"); |
| 11539 |
set_optab_libfunc (ge_optab, mode, "_q_fge"); |
| 11540 |
set_optab_libfunc (lt_optab, mode, "_q_flt"); |
| 11541 |
set_optab_libfunc (le_optab, mode, "_q_fle"); |
| 11542 |
|
| 11543 |
set_conv_libfunc (sext_optab, mode, SFmode, "_q_stoq"); |
| 11544 |
set_conv_libfunc (sext_optab, mode, DFmode, "_q_dtoq"); |
| 11545 |
set_conv_libfunc (trunc_optab, SFmode, mode, "_q_qtos"); |
| 11546 |
set_conv_libfunc (trunc_optab, DFmode, mode, "_q_qtod"); |
| 11547 |
set_conv_libfunc (sfix_optab, SImode, mode, "_q_qtoi"); |
| 11548 |
set_conv_libfunc (ufix_optab, SImode, mode, "_q_qtou"); |
| 11549 |
set_conv_libfunc (sfloat_optab, mode, SImode, "_q_itoq"); |
| 11550 |
set_conv_libfunc (ufloat_optab, mode, SImode, "_q_utoq"); |
| 11551 |
} |
| 11552 |
} |
| 11553 |
|
| 11554 |
static void |
| 11555 |
rs6000_init_libfuncs (void) |
| 11556 |
{ |
| 11557 |
/* __float128 support. */ |
| 11558 |
if (TARGET_FLOAT128_TYPE) |
| 11559 |
{ |
| 11560 |
init_float128_ibm (IFmode); |
| 11561 |
init_float128_ieee (KFmode); |
| 11562 |
} |
| 11563 |
|
| 11564 |
/* AIX/Darwin/64-bit Linux quad floating point routines. */ |
| 11565 |
if (TARGET_LONG_DOUBLE_128) |
| 11566 |
{ |
| 11567 |
if (!TARGET_IEEEQUAD) |
| 11568 |
init_float128_ibm (TFmode); |
| 11569 |
|
| 11570 |
/* IEEE 128-bit including 32-bit SVR4 quad floating point routines. */ |
| 11571 |
else |
| 11572 |
init_float128_ieee (TFmode); |
| 11573 |
} |
| 11574 |
} |
| 11575 |
|
| 11576 |
/* Emit a potentially record-form instruction, setting DST from SRC. |
| 11577 |
If DOT is 0, that is all; otherwise, set CCREG to the result of the |
| 11578 |
signed comparison of DST with zero. If DOT is 1, the generated RTL |
| 11579 |
doesn't care about the DST result; if DOT is 2, it does. If CCREG |
| 11580 |
is CR0 do a single dot insn (as a PARALLEL); otherwise, do a SET and |
| 11581 |
a separate COMPARE. */ |
| 11582 |
|
| 11583 |
void |
| 11584 |
rs6000_emit_dot_insn (rtx dst, rtx src, int dot, rtx ccreg) |
| 11585 |
{ |
| 11586 |
if (dot == 0) |
| 11587 |
{ |
| 11588 |
emit_move_insn (dst, src); |
| 11589 |
return; |
| 11590 |
} |
| 11591 |
|
| 11592 |
if (cc_reg_not_cr0_operand (ccreg, CCmode)) |
| 11593 |
{ |
| 11594 |
emit_move_insn (dst, src); |
| 11595 |
emit_move_insn (ccreg, gen_rtx_COMPARE (CCmode, dst, const0_rtx)); |
| 11596 |
return; |
| 11597 |
} |
| 11598 |
|
| 11599 |
rtx ccset = gen_rtx_SET (ccreg, gen_rtx_COMPARE (CCmode, src, const0_rtx)); |
| 11600 |
if (dot == 1) |
| 11601 |
{ |
| 11602 |
rtx clobber = gen_rtx_CLOBBER (VOIDmode, dst); |
| 11603 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, ccset, clobber))); |
| 11604 |
} |
| 11605 |
else |
| 11606 |
{ |
| 11607 |
rtx set = gen_rtx_SET (dst, src); |
| 11608 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, ccset, set))); |
| 11609 |
} |
| 11610 |
} |
| 11611 |
|
| 11612 |
|
| 11613 |
/* A validation routine: say whether CODE, a condition code, and MODE |
| 11614 |
match. The other alternatives either don't make sense or should |
| 11615 |
never be generated. */ |
| 11616 |
|
| 11617 |
void |
| 11618 |
validate_condition_mode (enum rtx_code code, machine_mode mode) |
| 11619 |
{ |
| 11620 |
gcc_assert ((GET_RTX_CLASS (code) == RTX_COMPARE |
| 11621 |
|| GET_RTX_CLASS (code) == RTX_COMM_COMPARE) |
| 11622 |
&& GET_MODE_CLASS (mode) == MODE_CC); |
| 11623 |
|
| 11624 |
/* These don't make sense. */ |
| 11625 |
gcc_assert ((code != GT && code != LT && code != GE && code != LE) |
| 11626 |
|| mode != CCUNSmode); |
| 11627 |
|
| 11628 |
gcc_assert ((code != GTU && code != LTU && code != GEU && code != LEU) |
| 11629 |
|| mode == CCUNSmode); |
| 11630 |
|
| 11631 |
gcc_assert (mode == CCFPmode |
| 11632 |
|| (code != ORDERED && code != UNORDERED |
| 11633 |
&& code != UNEQ && code != LTGT |
| 11634 |
&& code != UNGT && code != UNLT |
| 11635 |
&& code != UNGE && code != UNLE)); |
| 11636 |
|
| 11637 |
/* These are invalid; the information is not there. */ |
| 11638 |
gcc_assert (mode != CCEQmode || code == EQ || code == NE); |
| 11639 |
} |
| 11640 |
|
| 11641 |
|
| 11642 |
/* Return whether MASK (a CONST_INT) is a valid mask for any rlwinm, |
| 11643 |
rldicl, rldicr, or rldic instruction in mode MODE. If so, if E is |
| 11644 |
not zero, store there the bit offset (counted from the right) where |
| 11645 |
the single stretch of 1 bits begins; and similarly for B, the bit |
| 11646 |
offset where it ends. */ |
| 11647 |
|
| 11648 |
bool |
| 11649 |
rs6000_is_valid_mask (rtx mask, int *b, int *e, machine_mode mode) |
| 11650 |
{ |
| 11651 |
unsigned HOST_WIDE_INT val = INTVAL (mask); |
| 11652 |
unsigned HOST_WIDE_INT bit; |
| 11653 |
int nb, ne; |
| 11654 |
int n = GET_MODE_PRECISION (mode); |
| 11655 |
|
| 11656 |
if (mode != DImode && mode != SImode) |
| 11657 |
return false; |
| 11658 |
|
| 11659 |
if (INTVAL (mask) >= 0) |
| 11660 |
{ |
| 11661 |
bit = val & -val; |
| 11662 |
ne = exact_log2 (bit); |
| 11663 |
nb = exact_log2 (val + bit); |
| 11664 |
} |
| 11665 |
else if (val + 1 == 0) |
| 11666 |
{ |
| 11667 |
nb = n; |
| 11668 |
ne = 0; |
| 11669 |
} |
| 11670 |
else if (val & 1) |
| 11671 |
{ |
| 11672 |
val = ~val; |
| 11673 |
bit = val & -val; |
| 11674 |
nb = exact_log2 (bit); |
| 11675 |
ne = exact_log2 (val + bit); |
| 11676 |
} |
| 11677 |
else |
| 11678 |
{ |
| 11679 |
bit = val & -val; |
| 11680 |
ne = exact_log2 (bit); |
| 11681 |
if (val + bit == 0) |
| 11682 |
nb = n; |
| 11683 |
else |
| 11684 |
nb = 0; |
| 11685 |
} |
| 11686 |
|
| 11687 |
nb--; |
| 11688 |
|
| 11689 |
if (nb < 0 || ne < 0 || nb >= n || ne >= n) |
| 11690 |
return false; |
| 11691 |
|
| 11692 |
if (b) |
| 11693 |
*b = nb; |
| 11694 |
if (e) |
| 11695 |
*e = ne; |
| 11696 |
|
| 11697 |
return true; |
| 11698 |
} |
| 11699 |
|
| 11700 |
bool |
| 11701 |
rs6000_is_valid_rotate_dot_mask (rtx mask, machine_mode mode) |
| 11702 |
{ |
| 11703 |
int nb, ne; |
| 11704 |
if (rs6000_is_valid_mask (mask, &nb, &ne, mode) && nb >= ne && ne > 0) |
| 11705 |
{ |
| 11706 |
if (TARGET_64BIT) |
| 11707 |
return true; |
| 11708 |
/* *rotldi3_mask_dot requires for -m32 -mpowerpc64 that the mask is |
| 11709 |
<= 0x7fffffff. */ |
| 11710 |
return (UINTVAL (mask) << (63 - nb)) <= 0x7fffffff; |
| 11711 |
} |
| 11712 |
|
| 11713 |
return false; |
| 11714 |
} |
| 11715 |
|
| 11716 |
/* Return whether MASK (a CONST_INT) is a valid mask for any rlwinm, rldicl, |
| 11717 |
or rldicr instruction, to implement an AND with it in mode MODE. */ |
| 11718 |
|
| 11719 |
bool |
| 11720 |
rs6000_is_valid_and_mask (rtx mask, machine_mode mode) |
| 11721 |
{ |
| 11722 |
int nb, ne; |
| 11723 |
|
| 11724 |
if (!rs6000_is_valid_mask (mask, &nb, &ne, mode)) |
| 11725 |
return false; |
| 11726 |
|
| 11727 |
/* For DImode, we need a rldicl, rldicr, or a rlwinm with mask that |
| 11728 |
does not wrap. */ |
| 11729 |
if (mode == DImode) |
| 11730 |
return (ne == 0 || nb == 63 || (nb < 32 && ne <= nb)); |
| 11731 |
|
| 11732 |
/* For SImode, rlwinm can do everything. */ |
| 11733 |
if (mode == SImode) |
| 11734 |
return (nb < 32 && ne < 32); |
| 11735 |
|
| 11736 |
return false; |
| 11737 |
} |
| 11738 |
|
| 11739 |
/* Return the instruction template for an AND with mask in mode MODE, with |
| 11740 |
operands OPERANDS. If DOT is true, make it a record-form instruction. */ |
| 11741 |
|
| 11742 |
const char * |
| 11743 |
rs6000_insn_for_and_mask (machine_mode mode, rtx *operands, bool dot) |
| 11744 |
{ |
| 11745 |
int nb, ne; |
| 11746 |
|
| 11747 |
if (!rs6000_is_valid_mask (operands[2], &nb, &ne, mode)) |
| 11748 |
gcc_unreachable (); |
| 11749 |
|
| 11750 |
if (mode == DImode && ne == 0) |
| 11751 |
{ |
| 11752 |
operands[3] = GEN_INT (63 - nb); |
| 11753 |
if (dot) |
| 11754 |
return "rldicl. %0,%1,0,%3"; |
| 11755 |
return "rldicl %0,%1,0,%3"; |
| 11756 |
} |
| 11757 |
|
| 11758 |
if (mode == DImode && nb == 63) |
| 11759 |
{ |
| 11760 |
operands[3] = GEN_INT (63 - ne); |
| 11761 |
if (dot) |
| 11762 |
return "rldicr. %0,%1,0,%3"; |
| 11763 |
return "rldicr %0,%1,0,%3"; |
| 11764 |
} |
| 11765 |
|
| 11766 |
if (nb < 32 && ne < 32) |
| 11767 |
{ |
| 11768 |
operands[3] = GEN_INT (31 - nb); |
| 11769 |
operands[4] = GEN_INT (31 - ne); |
| 11770 |
if (dot) |
| 11771 |
return "rlwinm. %0,%1,0,%3,%4"; |
| 11772 |
return "rlwinm %0,%1,0,%3,%4"; |
| 11773 |
} |
| 11774 |
|
| 11775 |
gcc_unreachable (); |
| 11776 |
} |
| 11777 |
|
| 11778 |
/* Return whether MASK (a CONST_INT) is a valid mask for any rlw[i]nm, |
| 11779 |
rld[i]cl, rld[i]cr, or rld[i]c instruction, to implement an AND with |
| 11780 |
shift SHIFT (a ROTATE, ASHIFT, or LSHIFTRT) in mode MODE. */ |
| 11781 |
|
| 11782 |
bool |
| 11783 |
rs6000_is_valid_shift_mask (rtx mask, rtx shift, machine_mode mode) |
| 11784 |
{ |
| 11785 |
int nb, ne; |
| 11786 |
|
| 11787 |
if (!rs6000_is_valid_mask (mask, &nb, &ne, mode)) |
| 11788 |
return false; |
| 11789 |
|
| 11790 |
int n = GET_MODE_PRECISION (mode); |
| 11791 |
int sh = -1; |
| 11792 |
|
| 11793 |
if (CONST_INT_P (XEXP (shift, 1))) |
| 11794 |
{ |
| 11795 |
sh = INTVAL (XEXP (shift, 1)); |
| 11796 |
if (sh < 0 || sh >= n) |
| 11797 |
return false; |
| 11798 |
} |
| 11799 |
|
| 11800 |
rtx_code code = GET_CODE (shift); |
| 11801 |
|
| 11802 |
/* Convert any shift by 0 to a rotate, to simplify below code. */ |
| 11803 |
if (sh == 0) |
| 11804 |
code = ROTATE; |
| 11805 |
|
| 11806 |
/* Convert rotate to simple shift if we can, to make analysis simpler. */ |
| 11807 |
if (code == ROTATE && sh >= 0 && nb >= ne && ne >= sh) |
| 11808 |
code = ASHIFT; |
| 11809 |
if (code == ROTATE && sh >= 0 && nb >= ne && nb < sh) |
| 11810 |
{ |
| 11811 |
code = LSHIFTRT; |
| 11812 |
sh = n - sh; |
| 11813 |
} |
| 11814 |
|
| 11815 |
/* DImode rotates need rld*. */ |
| 11816 |
if (mode == DImode && code == ROTATE) |
| 11817 |
return (nb == 63 || ne == 0 || ne == sh); |
| 11818 |
|
| 11819 |
/* SImode rotates need rlw*. */ |
| 11820 |
if (mode == SImode && code == ROTATE) |
| 11821 |
return (nb < 32 && ne < 32 && sh < 32); |
| 11822 |
|
| 11823 |
/* Wrap-around masks are only okay for rotates. */ |
| 11824 |
if (ne > nb) |
| 11825 |
return false; |
| 11826 |
|
| 11827 |
/* Variable shifts are only okay for rotates. */ |
| 11828 |
if (sh < 0) |
| 11829 |
return false; |
| 11830 |
|
| 11831 |
/* Don't allow ASHIFT if the mask is wrong for that. */ |
| 11832 |
if (code == ASHIFT && ne < sh) |
| 11833 |
return false; |
| 11834 |
|
| 11835 |
/* If we can do it with an rlw*, we can do it. Don't allow LSHIFTRT |
| 11836 |
if the mask is wrong for that. */ |
| 11837 |
if (nb < 32 && ne < 32 && sh < 32 |
| 11838 |
&& !(code == LSHIFTRT && nb >= 32 - sh)) |
| 11839 |
return true; |
| 11840 |
|
| 11841 |
/* If we can do it with an rld*, we can do it. Don't allow LSHIFTRT |
| 11842 |
if the mask is wrong for that. */ |
| 11843 |
if (code == LSHIFTRT) |
| 11844 |
sh = 64 - sh; |
| 11845 |
if (nb == 63 || ne == 0 || ne == sh) |
| 11846 |
return !(code == LSHIFTRT && nb >= sh); |
| 11847 |
|
| 11848 |
return false; |
| 11849 |
} |
| 11850 |
|
| 11851 |
/* Return the instruction template for a shift with mask in mode MODE, with |
| 11852 |
operands OPERANDS. If DOT is true, make it a record-form instruction. */ |
| 11853 |
|
| 11854 |
const char * |
| 11855 |
rs6000_insn_for_shift_mask (machine_mode mode, rtx *operands, bool dot) |
| 11856 |
{ |
| 11857 |
int nb, ne; |
| 11858 |
|
| 11859 |
if (!rs6000_is_valid_mask (operands[3], &nb, &ne, mode)) |
| 11860 |
gcc_unreachable (); |
| 11861 |
|
| 11862 |
if (mode == DImode && ne == 0) |
| 11863 |
{ |
| 11864 |
if (GET_CODE (operands[4]) == LSHIFTRT && INTVAL (operands[2])) |
| 11865 |
operands[2] = GEN_INT (64 - INTVAL (operands[2])); |
| 11866 |
operands[3] = GEN_INT (63 - nb); |
| 11867 |
if (dot) |
| 11868 |
return "rld%I2cl. %0,%1,%2,%3"; |
| 11869 |
return "rld%I2cl %0,%1,%2,%3"; |
| 11870 |
} |
| 11871 |
|
| 11872 |
if (mode == DImode && nb == 63) |
| 11873 |
{ |
| 11874 |
operands[3] = GEN_INT (63 - ne); |
| 11875 |
if (dot) |
| 11876 |
return "rld%I2cr. %0,%1,%2,%3"; |
| 11877 |
return "rld%I2cr %0,%1,%2,%3"; |
| 11878 |
} |
| 11879 |
|
| 11880 |
if (mode == DImode |
| 11881 |
&& GET_CODE (operands[4]) != LSHIFTRT |
| 11882 |
&& CONST_INT_P (operands[2]) |
| 11883 |
&& ne == INTVAL (operands[2])) |
| 11884 |
{ |
| 11885 |
operands[3] = GEN_INT (63 - nb); |
| 11886 |
if (dot) |
| 11887 |
return "rld%I2c. %0,%1,%2,%3"; |
| 11888 |
return "rld%I2c %0,%1,%2,%3"; |
| 11889 |
} |
| 11890 |
|
| 11891 |
if (nb < 32 && ne < 32) |
| 11892 |
{ |
| 11893 |
if (GET_CODE (operands[4]) == LSHIFTRT && INTVAL (operands[2])) |
| 11894 |
operands[2] = GEN_INT (32 - INTVAL (operands[2])); |
| 11895 |
operands[3] = GEN_INT (31 - nb); |
| 11896 |
operands[4] = GEN_INT (31 - ne); |
| 11897 |
/* This insn can also be a 64-bit rotate with mask that really makes |
| 11898 |
it just a shift right (with mask); the %h below are to adjust for |
| 11899 |
that situation (shift count is >= 32 in that case). */ |
| 11900 |
if (dot) |
| 11901 |
return "rlw%I2nm. %0,%1,%h2,%3,%4"; |
| 11902 |
return "rlw%I2nm %0,%1,%h2,%3,%4"; |
| 11903 |
} |
| 11904 |
|
| 11905 |
gcc_unreachable (); |
| 11906 |
} |
| 11907 |
|
| 11908 |
/* Return whether MASK (a CONST_INT) is a valid mask for any rlwimi or |
| 11909 |
rldimi instruction, to implement an insert with shift SHIFT (a ROTATE, |
| 11910 |
ASHIFT, or LSHIFTRT) in mode MODE. */ |
| 11911 |
|
| 11912 |
bool |
| 11913 |
rs6000_is_valid_insert_mask (rtx mask, rtx shift, machine_mode mode) |
| 11914 |
{ |
| 11915 |
int nb, ne; |
| 11916 |
|
| 11917 |
if (!rs6000_is_valid_mask (mask, &nb, &ne, mode)) |
| 11918 |
return false; |
| 11919 |
|
| 11920 |
int n = GET_MODE_PRECISION (mode); |
| 11921 |
|
| 11922 |
int sh = INTVAL (XEXP (shift, 1)); |
| 11923 |
if (sh < 0 || sh >= n) |
| 11924 |
return false; |
| 11925 |
|
| 11926 |
rtx_code code = GET_CODE (shift); |
| 11927 |
|
| 11928 |
/* Convert any shift by 0 to a rotate, to simplify below code. */ |
| 11929 |
if (sh == 0) |
| 11930 |
code = ROTATE; |
| 11931 |
|
| 11932 |
/* Convert rotate to simple shift if we can, to make analysis simpler. */ |
| 11933 |
if (code == ROTATE && sh >= 0 && nb >= ne && ne >= sh) |
| 11934 |
code = ASHIFT; |
| 11935 |
if (code == ROTATE && sh >= 0 && nb >= ne && nb < sh) |
| 11936 |
{ |
| 11937 |
code = LSHIFTRT; |
| 11938 |
sh = n - sh; |
| 11939 |
} |
| 11940 |
|
| 11941 |
/* DImode rotates need rldimi. */ |
| 11942 |
if (mode == DImode && code == ROTATE) |
| 11943 |
return (ne == sh); |
| 11944 |
|
| 11945 |
/* SImode rotates need rlwimi. */ |
| 11946 |
if (mode == SImode && code == ROTATE) |
| 11947 |
return (nb < 32 && ne < 32 && sh < 32); |
| 11948 |
|
| 11949 |
/* Wrap-around masks are only okay for rotates. */ |
| 11950 |
if (ne > nb) |
| 11951 |
return false; |
| 11952 |
|
| 11953 |
/* Don't allow ASHIFT if the mask is wrong for that. */ |
| 11954 |
if (code == ASHIFT && ne < sh) |
| 11955 |
return false; |
| 11956 |
|
| 11957 |
/* If we can do it with an rlwimi, we can do it. Don't allow LSHIFTRT |
| 11958 |
if the mask is wrong for that. */ |
| 11959 |
if (nb < 32 && ne < 32 && sh < 32 |
| 11960 |
&& !(code == LSHIFTRT && nb >= 32 - sh)) |
| 11961 |
return true; |
| 11962 |
|
| 11963 |
/* If we can do it with an rldimi, we can do it. Don't allow LSHIFTRT |
| 11964 |
if the mask is wrong for that. */ |
| 11965 |
if (code == LSHIFTRT) |
| 11966 |
sh = 64 - sh; |
| 11967 |
if (ne == sh) |
| 11968 |
return !(code == LSHIFTRT && nb >= sh); |
| 11969 |
|
| 11970 |
return false; |
| 11971 |
} |
| 11972 |
|
| 11973 |
/* Return the instruction template for an insert with mask in mode MODE, with |
| 11974 |
operands OPERANDS. If DOT is true, make it a record-form instruction. */ |
| 11975 |
|
| 11976 |
const char * |
| 11977 |
rs6000_insn_for_insert_mask (machine_mode mode, rtx *operands, bool dot) |
| 11978 |
{ |
| 11979 |
int nb, ne; |
| 11980 |
|
| 11981 |
if (!rs6000_is_valid_mask (operands[3], &nb, &ne, mode)) |
| 11982 |
gcc_unreachable (); |
| 11983 |
|
| 11984 |
/* Prefer rldimi because rlwimi is cracked. */ |
| 11985 |
if (TARGET_POWERPC64 |
| 11986 |
&& (!dot || mode == DImode) |
| 11987 |
&& GET_CODE (operands[4]) != LSHIFTRT |
| 11988 |
&& ne == INTVAL (operands[2])) |
| 11989 |
{ |
| 11990 |
operands[3] = GEN_INT (63 - nb); |
| 11991 |
if (dot) |
| 11992 |
return "rldimi. %0,%1,%2,%3"; |
| 11993 |
return "rldimi %0,%1,%2,%3"; |
| 11994 |
} |
| 11995 |
|
| 11996 |
if (nb < 32 && ne < 32) |
| 11997 |
{ |
| 11998 |
if (GET_CODE (operands[4]) == LSHIFTRT && INTVAL (operands[2])) |
| 11999 |
operands[2] = GEN_INT (32 - INTVAL (operands[2])); |
| 12000 |
operands[3] = GEN_INT (31 - nb); |
| 12001 |
operands[4] = GEN_INT (31 - ne); |
| 12002 |
if (dot) |
| 12003 |
return "rlwimi. %0,%1,%2,%3,%4"; |
| 12004 |
return "rlwimi %0,%1,%2,%3,%4"; |
| 12005 |
} |
| 12006 |
|
| 12007 |
gcc_unreachable (); |
| 12008 |
} |
| 12009 |
|
| 12010 |
/* Return whether an AND with C (a CONST_INT) in mode MODE can be done |
| 12011 |
using two machine instructions. */ |
| 12012 |
|
| 12013 |
bool |
| 12014 |
rs6000_is_valid_2insn_and (rtx c, machine_mode mode) |
| 12015 |
{ |
| 12016 |
/* There are two kinds of AND we can handle with two insns: |
| 12017 |
1) those we can do with two rl* insn; |
| 12018 |
2) ori[s];xori[s]. |
| 12019 |
|
| 12020 |
We do not handle that last case yet. */ |
| 12021 |
|
| 12022 |
/* If there is just one stretch of ones, we can do it. */ |
| 12023 |
if (rs6000_is_valid_mask (c, NULL, NULL, mode)) |
| 12024 |
return true; |
| 12025 |
|
| 12026 |
/* Otherwise, fill in the lowest "hole"; if we can do the result with |
| 12027 |
one insn, we can do the whole thing with two. */ |
| 12028 |
unsigned HOST_WIDE_INT val = INTVAL (c); |
| 12029 |
unsigned HOST_WIDE_INT bit1 = val & -val; |
| 12030 |
unsigned HOST_WIDE_INT bit2 = (val + bit1) & ~val; |
| 12031 |
unsigned HOST_WIDE_INT val1 = (val + bit1) & val; |
| 12032 |
unsigned HOST_WIDE_INT bit3 = val1 & -val1; |
| 12033 |
return rs6000_is_valid_and_mask (GEN_INT (val + bit3 - bit2), mode); |
| 12034 |
} |
| 12035 |
|
| 12036 |
/* Emit the two insns to do an AND in mode MODE, with operands OPERANDS. |
| 12037 |
If EXPAND is true, split rotate-and-mask instructions we generate to |
| 12038 |
their constituent parts as well (this is used during expand); if DOT |
| 12039 |
is 1, make the last insn a record-form instruction clobbering the |
| 12040 |
destination GPR and setting the CC reg (from operands[3]); if 2, set |
| 12041 |
that GPR as well as the CC reg. */ |
| 12042 |
|
| 12043 |
void |
| 12044 |
rs6000_emit_2insn_and (machine_mode mode, rtx *operands, bool expand, int dot) |
| 12045 |
{ |
| 12046 |
gcc_assert (!(expand && dot)); |
| 12047 |
|
| 12048 |
unsigned HOST_WIDE_INT val = INTVAL (operands[2]); |
| 12049 |
|
| 12050 |
/* If it is one stretch of ones, it is DImode; shift left, mask, then |
| 12051 |
shift right. This generates better code than doing the masks without |
| 12052 |
shifts, or shifting first right and then left. */ |
| 12053 |
int nb, ne; |
| 12054 |
if (rs6000_is_valid_mask (operands[2], &nb, &ne, mode) && nb >= ne) |
| 12055 |
{ |
| 12056 |
gcc_assert (mode == DImode); |
| 12057 |
|
| 12058 |
int shift = 63 - nb; |
| 12059 |
if (expand) |
| 12060 |
{ |
| 12061 |
rtx tmp1 = gen_reg_rtx (DImode); |
| 12062 |
rtx tmp2 = gen_reg_rtx (DImode); |
| 12063 |
emit_insn (gen_ashldi3 (tmp1, operands[1], GEN_INT (shift))); |
| 12064 |
emit_insn (gen_anddi3 (tmp2, tmp1, GEN_INT (val << shift))); |
| 12065 |
emit_insn (gen_lshrdi3 (operands[0], tmp2, GEN_INT (shift))); |
| 12066 |
} |
| 12067 |
else |
| 12068 |
{ |
| 12069 |
rtx tmp = gen_rtx_ASHIFT (mode, operands[1], GEN_INT (shift)); |
| 12070 |
tmp = gen_rtx_AND (mode, tmp, GEN_INT (val << shift)); |
| 12071 |
emit_move_insn (operands[0], tmp); |
| 12072 |
tmp = gen_rtx_LSHIFTRT (mode, operands[0], GEN_INT (shift)); |
| 12073 |
rs6000_emit_dot_insn (operands[0], tmp, dot, dot ? operands[3] : 0); |
| 12074 |
} |
| 12075 |
return; |
| 12076 |
} |
| 12077 |
|
| 12078 |
/* Otherwise, make a mask2 that cuts out the lowest "hole", and a mask1 |
| 12079 |
that does the rest. */ |
| 12080 |
unsigned HOST_WIDE_INT bit1 = val & -val; |
| 12081 |
unsigned HOST_WIDE_INT bit2 = (val + bit1) & ~val; |
| 12082 |
unsigned HOST_WIDE_INT val1 = (val + bit1) & val; |
| 12083 |
unsigned HOST_WIDE_INT bit3 = val1 & -val1; |
| 12084 |
|
| 12085 |
unsigned HOST_WIDE_INT mask1 = -bit3 + bit2 - 1; |
| 12086 |
unsigned HOST_WIDE_INT mask2 = val + bit3 - bit2; |
| 12087 |
|
| 12088 |
gcc_assert (rs6000_is_valid_and_mask (GEN_INT (mask2), mode)); |
| 12089 |
|
| 12090 |
/* Two "no-rotate"-and-mask instructions, for SImode. */ |
| 12091 |
if (rs6000_is_valid_and_mask (GEN_INT (mask1), mode)) |
| 12092 |
{ |
| 12093 |
gcc_assert (mode == SImode); |
| 12094 |
|
| 12095 |
rtx reg = expand ? gen_reg_rtx (mode) : operands[0]; |
| 12096 |
rtx tmp = gen_rtx_AND (mode, operands[1], GEN_INT (mask1)); |
| 12097 |
emit_move_insn (reg, tmp); |
| 12098 |
tmp = gen_rtx_AND (mode, reg, GEN_INT (mask2)); |
| 12099 |
rs6000_emit_dot_insn (operands[0], tmp, dot, dot ? operands[3] : 0); |
| 12100 |
return; |
| 12101 |
} |
| 12102 |
|
| 12103 |
gcc_assert (mode == DImode); |
| 12104 |
|
| 12105 |
/* Two "no-rotate"-and-mask instructions, for DImode: both are rlwinm |
| 12106 |
insns; we have to do the first in SImode, because it wraps. */ |
| 12107 |
if (mask2 <= 0xffffffff |
| 12108 |
&& rs6000_is_valid_and_mask (GEN_INT (mask1), SImode)) |
| 12109 |
{ |
| 12110 |
rtx reg = expand ? gen_reg_rtx (mode) : operands[0]; |
| 12111 |
rtx tmp = gen_rtx_AND (SImode, gen_lowpart (SImode, operands[1]), |
| 12112 |
GEN_INT (mask1)); |
| 12113 |
rtx reg_low = gen_lowpart (SImode, reg); |
| 12114 |
emit_move_insn (reg_low, tmp); |
| 12115 |
tmp = gen_rtx_AND (mode, reg, GEN_INT (mask2)); |
| 12116 |
rs6000_emit_dot_insn (operands[0], tmp, dot, dot ? operands[3] : 0); |
| 12117 |
return; |
| 12118 |
} |
| 12119 |
|
| 12120 |
/* Two rld* insns: rotate, clear the hole in the middle (which now is |
| 12121 |
at the top end), rotate back and clear the other hole. */ |
| 12122 |
int right = exact_log2 (bit3); |
| 12123 |
int left = 64 - right; |
| 12124 |
|
| 12125 |
/* Rotate the mask too. */ |
| 12126 |
mask1 = (mask1 >> right) | ((bit2 - 1) << left); |
| 12127 |
|
| 12128 |
if (expand) |
| 12129 |
{ |
| 12130 |
rtx tmp1 = gen_reg_rtx (DImode); |
| 12131 |
rtx tmp2 = gen_reg_rtx (DImode); |
| 12132 |
rtx tmp3 = gen_reg_rtx (DImode); |
| 12133 |
emit_insn (gen_rotldi3 (tmp1, operands[1], GEN_INT (left))); |
| 12134 |
emit_insn (gen_anddi3 (tmp2, tmp1, GEN_INT (mask1))); |
| 12135 |
emit_insn (gen_rotldi3 (tmp3, tmp2, GEN_INT (right))); |
| 12136 |
emit_insn (gen_anddi3 (operands[0], tmp3, GEN_INT (mask2))); |
| 12137 |
} |
| 12138 |
else |
| 12139 |
{ |
| 12140 |
rtx tmp = gen_rtx_ROTATE (mode, operands[1], GEN_INT (left)); |
| 12141 |
tmp = gen_rtx_AND (mode, tmp, GEN_INT (mask1)); |
| 12142 |
emit_move_insn (operands[0], tmp); |
| 12143 |
tmp = gen_rtx_ROTATE (mode, operands[0], GEN_INT (right)); |
| 12144 |
tmp = gen_rtx_AND (mode, tmp, GEN_INT (mask2)); |
| 12145 |
rs6000_emit_dot_insn (operands[0], tmp, dot, dot ? operands[3] : 0); |
| 12146 |
} |
| 12147 |
} |
| 12148 |
|
| 12149 |
/* Return 1 if REGNO (reg1) == REGNO (reg2) - 1 making them candidates |
| 12150 |
for lfq and stfq insns iff the registers are hard registers. */ |
| 12151 |
|
| 12152 |
int |
| 12153 |
registers_ok_for_quad_peep (rtx reg1, rtx reg2) |
| 12154 |
{ |
| 12155 |
/* We might have been passed a SUBREG. */ |
| 12156 |
if (!REG_P (reg1) || !REG_P (reg2)) |
| 12157 |
return 0; |
| 12158 |
|
| 12159 |
/* We might have been passed non floating point registers. */ |
| 12160 |
if (!FP_REGNO_P (REGNO (reg1)) |
| 12161 |
|| !FP_REGNO_P (REGNO (reg2))) |
| 12162 |
return 0; |
| 12163 |
|
| 12164 |
return (REGNO (reg1) == REGNO (reg2) - 1); |
| 12165 |
} |
| 12166 |
|
| 12167 |
/* Return 1 if addr1 and addr2 are suitable for lfq or stfq insn. |
| 12168 |
addr1 and addr2 must be in consecutive memory locations |
| 12169 |
(addr2 == addr1 + 8). */ |
| 12170 |
|
| 12171 |
int |
| 12172 |
mems_ok_for_quad_peep (rtx mem1, rtx mem2) |
| 12173 |
{ |
| 12174 |
rtx addr1, addr2; |
| 12175 |
unsigned int reg1, reg2; |
| 12176 |
int offset1, offset2; |
| 12177 |
|
| 12178 |
/* The mems cannot be volatile. */ |
| 12179 |
if (MEM_VOLATILE_P (mem1) || MEM_VOLATILE_P (mem2)) |
| 12180 |
return 0; |
| 12181 |
|
| 12182 |
addr1 = XEXP (mem1, 0); |
| 12183 |
addr2 = XEXP (mem2, 0); |
| 12184 |
|
| 12185 |
/* Extract an offset (if used) from the first addr. */ |
| 12186 |
if (GET_CODE (addr1) == PLUS) |
| 12187 |
{ |
| 12188 |
/* If not a REG, return zero. */ |
| 12189 |
if (!REG_P (XEXP (addr1, 0))) |
| 12190 |
return 0; |
| 12191 |
else |
| 12192 |
{ |
| 12193 |
reg1 = REGNO (XEXP (addr1, 0)); |
| 12194 |
/* The offset must be constant! */ |
| 12195 |
if (!CONST_INT_P (XEXP (addr1, 1))) |
| 12196 |
return 0; |
| 12197 |
offset1 = INTVAL (XEXP (addr1, 1)); |
| 12198 |
} |
| 12199 |
} |
| 12200 |
else if (!REG_P (addr1)) |
| 12201 |
return 0; |
| 12202 |
else |
| 12203 |
{ |
| 12204 |
reg1 = REGNO (addr1); |
| 12205 |
/* This was a simple (mem (reg)) expression. Offset is 0. */ |
| 12206 |
offset1 = 0; |
| 12207 |
} |
| 12208 |
|
| 12209 |
/* And now for the second addr. */ |
| 12210 |
if (GET_CODE (addr2) == PLUS) |
| 12211 |
{ |
| 12212 |
/* If not a REG, return zero. */ |
| 12213 |
if (!REG_P (XEXP (addr2, 0))) |
| 12214 |
return 0; |
| 12215 |
else |
| 12216 |
{ |
| 12217 |
reg2 = REGNO (XEXP (addr2, 0)); |
| 12218 |
/* The offset must be constant. */ |
| 12219 |
if (!CONST_INT_P (XEXP (addr2, 1))) |
| 12220 |
return 0; |
| 12221 |
offset2 = INTVAL (XEXP (addr2, 1)); |
| 12222 |
} |
| 12223 |
} |
| 12224 |
else if (!REG_P (addr2)) |
| 12225 |
return 0; |
| 12226 |
else |
| 12227 |
{ |
| 12228 |
reg2 = REGNO (addr2); |
| 12229 |
/* This was a simple (mem (reg)) expression. Offset is 0. */ |
| 12230 |
offset2 = 0; |
| 12231 |
} |
| 12232 |
|
| 12233 |
/* Both of these must have the same base register. */ |
| 12234 |
if (reg1 != reg2) |
| 12235 |
return 0; |
| 12236 |
|
| 12237 |
/* The offset for the second addr must be 8 more than the first addr. */ |
| 12238 |
if (offset2 != offset1 + 8) |
| 12239 |
return 0; |
| 12240 |
|
| 12241 |
/* All the tests passed. addr1 and addr2 are valid for lfq or stfq |
| 12242 |
instructions. */ |
| 12243 |
return 1; |
| 12244 |
} |
| 12245 |
|
| 12246 |
/* Implement TARGET_SECONDARY_RELOAD_NEEDED_MODE. For SDmode values we |
| 12247 |
need to use DDmode, in all other cases we can use the same mode. */ |
| 12248 |
static machine_mode |
| 12249 |
rs6000_secondary_memory_needed_mode (machine_mode mode) |
| 12250 |
{ |
| 12251 |
if (lra_in_progress && mode == SDmode) |
| 12252 |
return DDmode; |
| 12253 |
return mode; |
| 12254 |
} |
| 12255 |
|
| 12256 |
/* Classify a register type. Because the FMRGOW/FMRGEW instructions only work |
| 12257 |
on traditional floating point registers, and the VMRGOW/VMRGEW instructions |
| 12258 |
only work on the traditional altivec registers, note if an altivec register |
| 12259 |
was chosen. */ |
| 12260 |
|
| 12261 |
static enum rs6000_reg_type |
| 12262 |
register_to_reg_type (rtx reg, bool *is_altivec) |
| 12263 |
{ |
| 12264 |
HOST_WIDE_INT regno; |
| 12265 |
enum reg_class rclass; |
| 12266 |
|
| 12267 |
if (SUBREG_P (reg)) |
| 12268 |
reg = SUBREG_REG (reg); |
| 12269 |
|
| 12270 |
if (!REG_P (reg)) |
| 12271 |
return NO_REG_TYPE; |
| 12272 |
|
| 12273 |
regno = REGNO (reg); |
| 12274 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 12275 |
{ |
| 12276 |
if (!lra_in_progress && !reload_completed) |
| 12277 |
return PSEUDO_REG_TYPE; |
| 12278 |
|
| 12279 |
regno = true_regnum (reg); |
| 12280 |
if (regno < 0 || !HARD_REGISTER_NUM_P (regno)) |
| 12281 |
return PSEUDO_REG_TYPE; |
| 12282 |
} |
| 12283 |
|
| 12284 |
gcc_assert (regno >= 0); |
| 12285 |
|
| 12286 |
if (is_altivec && ALTIVEC_REGNO_P (regno)) |
| 12287 |
*is_altivec = true; |
| 12288 |
|
| 12289 |
rclass = rs6000_regno_regclass[regno]; |
| 12290 |
return reg_class_to_reg_type[(int)rclass]; |
| 12291 |
} |
| 12292 |
|
| 12293 |
/* Helper function to return the cost of adding a TOC entry address. */ |
| 12294 |
|
| 12295 |
static inline int |
| 12296 |
rs6000_secondary_reload_toc_costs (addr_mask_type addr_mask) |
| 12297 |
{ |
| 12298 |
int ret; |
| 12299 |
|
| 12300 |
if (TARGET_CMODEL != CMODEL_SMALL) |
| 12301 |
ret = ((addr_mask & RELOAD_REG_OFFSET) == 0) ? 1 : 2; |
| 12302 |
|
| 12303 |
else |
| 12304 |
ret = (TARGET_MINIMAL_TOC) ? 6 : 3; |
| 12305 |
|
| 12306 |
return ret; |
| 12307 |
} |
| 12308 |
|
| 12309 |
/* Helper function for rs6000_secondary_reload to determine whether the memory |
| 12310 |
address (ADDR) with a given register class (RCLASS) and machine mode (MODE) |
| 12311 |
needs reloading. Return negative if the memory is not handled by the memory |
| 12312 |
helper functions and to try a different reload method, 0 if no additional |
| 12313 |
instructions are need, and positive to give the extra cost for the |
| 12314 |
memory. */ |
| 12315 |
|
| 12316 |
static int |
| 12317 |
rs6000_secondary_reload_memory (rtx addr, |
| 12318 |
enum reg_class rclass, |
| 12319 |
machine_mode mode) |
| 12320 |
{ |
| 12321 |
int extra_cost = 0; |
| 12322 |
rtx reg, and_arg, plus_arg0, plus_arg1; |
| 12323 |
addr_mask_type addr_mask; |
| 12324 |
const char *type = NULL; |
| 12325 |
const char *fail_msg = NULL; |
| 12326 |
|
| 12327 |
if (GPR_REG_CLASS_P (rclass)) |
| 12328 |
addr_mask = reg_addr[mode].addr_mask[RELOAD_REG_GPR]; |
| 12329 |
|
| 12330 |
else if (rclass == FLOAT_REGS) |
| 12331 |
addr_mask = reg_addr[mode].addr_mask[RELOAD_REG_FPR]; |
| 12332 |
|
| 12333 |
else if (rclass == ALTIVEC_REGS) |
| 12334 |
addr_mask = reg_addr[mode].addr_mask[RELOAD_REG_VMX]; |
| 12335 |
|
| 12336 |
/* For the combined VSX_REGS, turn off Altivec AND -16. */ |
| 12337 |
else if (rclass == VSX_REGS) |
| 12338 |
addr_mask = (reg_addr[mode].addr_mask[RELOAD_REG_VMX] |
| 12339 |
& ~RELOAD_REG_AND_M16); |
| 12340 |
|
| 12341 |
/* If the register allocator hasn't made up its mind yet on the register |
| 12342 |
class to use, settle on defaults to use. */ |
| 12343 |
else if (rclass == NO_REGS) |
| 12344 |
{ |
| 12345 |
addr_mask = (reg_addr[mode].addr_mask[RELOAD_REG_ANY] |
| 12346 |
& ~RELOAD_REG_AND_M16); |
| 12347 |
|
| 12348 |
if ((addr_mask & RELOAD_REG_MULTIPLE) != 0) |
| 12349 |
addr_mask &= ~(RELOAD_REG_INDEXED |
| 12350 |
| RELOAD_REG_PRE_INCDEC |
| 12351 |
| RELOAD_REG_PRE_MODIFY); |
| 12352 |
} |
| 12353 |
|
| 12354 |
else |
| 12355 |
addr_mask = 0; |
| 12356 |
|
| 12357 |
/* If the register isn't valid in this register class, just return now. */ |
| 12358 |
if ((addr_mask & RELOAD_REG_VALID) == 0) |
| 12359 |
{ |
| 12360 |
if (TARGET_DEBUG_ADDR) |
| 12361 |
{ |
| 12362 |
fprintf (stderr, |
| 12363 |
"rs6000_secondary_reload_memory: mode = %s, class = %s, " |
| 12364 |
"not valid in class\n", |
| 12365 |
GET_MODE_NAME (mode), reg_class_names[rclass]); |
| 12366 |
debug_rtx (addr); |
| 12367 |
} |
| 12368 |
|
| 12369 |
return -1; |
| 12370 |
} |
| 12371 |
|
| 12372 |
switch (GET_CODE (addr)) |
| 12373 |
{ |
| 12374 |
/* Does the register class supports auto update forms for this mode? We |
| 12375 |
don't need a scratch register, since the powerpc only supports |
| 12376 |
PRE_INC, PRE_DEC, and PRE_MODIFY. */ |
| 12377 |
case PRE_INC: |
| 12378 |
case PRE_DEC: |
| 12379 |
reg = XEXP (addr, 0); |
| 12380 |
if (!base_reg_operand (addr, GET_MODE (reg))) |
| 12381 |
{ |
| 12382 |
fail_msg = "no base register #1"; |
| 12383 |
extra_cost = -1; |
| 12384 |
} |
| 12385 |
|
| 12386 |
else if ((addr_mask & RELOAD_REG_PRE_INCDEC) == 0) |
| 12387 |
{ |
| 12388 |
extra_cost = 1; |
| 12389 |
type = "update"; |
| 12390 |
} |
| 12391 |
break; |
| 12392 |
|
| 12393 |
case PRE_MODIFY: |
| 12394 |
reg = XEXP (addr, 0); |
| 12395 |
plus_arg1 = XEXP (addr, 1); |
| 12396 |
if (!base_reg_operand (reg, GET_MODE (reg)) |
| 12397 |
|| GET_CODE (plus_arg1) != PLUS |
| 12398 |
|| !rtx_equal_p (reg, XEXP (plus_arg1, 0))) |
| 12399 |
{ |
| 12400 |
fail_msg = "bad PRE_MODIFY"; |
| 12401 |
extra_cost = -1; |
| 12402 |
} |
| 12403 |
|
| 12404 |
else if ((addr_mask & RELOAD_REG_PRE_MODIFY) == 0) |
| 12405 |
{ |
| 12406 |
extra_cost = 1; |
| 12407 |
type = "update"; |
| 12408 |
} |
| 12409 |
break; |
| 12410 |
|
| 12411 |
/* Do we need to simulate AND -16 to clear the bottom address bits used |
| 12412 |
in VMX load/stores? Only allow the AND for vector sizes. */ |
| 12413 |
case AND: |
| 12414 |
and_arg = XEXP (addr, 0); |
| 12415 |
if (GET_MODE_SIZE (mode) != 16 |
| 12416 |
|| !CONST_INT_P (XEXP (addr, 1)) |
| 12417 |
|| INTVAL (XEXP (addr, 1)) != -16) |
| 12418 |
{ |
| 12419 |
fail_msg = "bad Altivec AND #1"; |
| 12420 |
extra_cost = -1; |
| 12421 |
} |
| 12422 |
|
| 12423 |
if (rclass != ALTIVEC_REGS) |
| 12424 |
{ |
| 12425 |
if (legitimate_indirect_address_p (and_arg, false)) |
| 12426 |
extra_cost = 1; |
| 12427 |
|
| 12428 |
else if (legitimate_indexed_address_p (and_arg, false)) |
| 12429 |
extra_cost = 2; |
| 12430 |
|
| 12431 |
else |
| 12432 |
{ |
| 12433 |
fail_msg = "bad Altivec AND #2"; |
| 12434 |
extra_cost = -1; |
| 12435 |
} |
| 12436 |
|
| 12437 |
type = "and"; |
| 12438 |
} |
| 12439 |
break; |
| 12440 |
|
| 12441 |
/* If this is an indirect address, make sure it is a base register. */ |
| 12442 |
case REG: |
| 12443 |
case SUBREG: |
| 12444 |
if (!legitimate_indirect_address_p (addr, false)) |
| 12445 |
{ |
| 12446 |
extra_cost = 1; |
| 12447 |
type = "move"; |
| 12448 |
} |
| 12449 |
break; |
| 12450 |
|
| 12451 |
/* If this is an indexed address, make sure the register class can handle |
| 12452 |
indexed addresses for this mode. */ |
| 12453 |
case PLUS: |
| 12454 |
plus_arg0 = XEXP (addr, 0); |
| 12455 |
plus_arg1 = XEXP (addr, 1); |
| 12456 |
|
| 12457 |
/* (plus (plus (reg) (constant)) (constant)) is generated during |
| 12458 |
push_reload processing, so handle it now. */ |
| 12459 |
if (GET_CODE (plus_arg0) == PLUS && CONST_INT_P (plus_arg1)) |
| 12460 |
{ |
| 12461 |
if ((addr_mask & RELOAD_REG_OFFSET) == 0) |
| 12462 |
{ |
| 12463 |
extra_cost = 1; |
| 12464 |
type = "offset"; |
| 12465 |
} |
| 12466 |
} |
| 12467 |
|
| 12468 |
/* (plus (plus (reg) (constant)) (reg)) is also generated during |
| 12469 |
push_reload processing, so handle it now. */ |
| 12470 |
else if (GET_CODE (plus_arg0) == PLUS && REG_P (plus_arg1)) |
| 12471 |
{ |
| 12472 |
if ((addr_mask & RELOAD_REG_INDEXED) == 0) |
| 12473 |
{ |
| 12474 |
extra_cost = 1; |
| 12475 |
type = "indexed #2"; |
| 12476 |
} |
| 12477 |
} |
| 12478 |
|
| 12479 |
else if (!base_reg_operand (plus_arg0, GET_MODE (plus_arg0))) |
| 12480 |
{ |
| 12481 |
fail_msg = "no base register #2"; |
| 12482 |
extra_cost = -1; |
| 12483 |
} |
| 12484 |
|
| 12485 |
else if (int_reg_operand (plus_arg1, GET_MODE (plus_arg1))) |
| 12486 |
{ |
| 12487 |
if ((addr_mask & RELOAD_REG_INDEXED) == 0 |
| 12488 |
|| !legitimate_indexed_address_p (addr, false)) |
| 12489 |
{ |
| 12490 |
extra_cost = 1; |
| 12491 |
type = "indexed"; |
| 12492 |
} |
| 12493 |
} |
| 12494 |
|
| 12495 |
else if ((addr_mask & RELOAD_REG_QUAD_OFFSET) != 0 |
| 12496 |
&& CONST_INT_P (plus_arg1)) |
| 12497 |
{ |
| 12498 |
if (!quad_address_offset_p (INTVAL (plus_arg1))) |
| 12499 |
{ |
| 12500 |
extra_cost = 1; |
| 12501 |
type = "vector d-form offset"; |
| 12502 |
} |
| 12503 |
} |
| 12504 |
|
| 12505 |
/* Make sure the register class can handle offset addresses. */ |
| 12506 |
else if (rs6000_legitimate_offset_address_p (mode, addr, false, true)) |
| 12507 |
{ |
| 12508 |
if ((addr_mask & RELOAD_REG_OFFSET) == 0) |
| 12509 |
{ |
| 12510 |
extra_cost = 1; |
| 12511 |
type = "offset #2"; |
| 12512 |
} |
| 12513 |
} |
| 12514 |
|
| 12515 |
else |
| 12516 |
{ |
| 12517 |
fail_msg = "bad PLUS"; |
| 12518 |
extra_cost = -1; |
| 12519 |
} |
| 12520 |
|
| 12521 |
break; |
| 12522 |
|
| 12523 |
case LO_SUM: |
| 12524 |
/* Quad offsets are restricted and can't handle normal addresses. */ |
| 12525 |
if ((addr_mask & RELOAD_REG_QUAD_OFFSET) != 0) |
| 12526 |
{ |
| 12527 |
extra_cost = -1; |
| 12528 |
type = "vector d-form lo_sum"; |
| 12529 |
} |
| 12530 |
|
| 12531 |
else if (!legitimate_lo_sum_address_p (mode, addr, false)) |
| 12532 |
{ |
| 12533 |
fail_msg = "bad LO_SUM"; |
| 12534 |
extra_cost = -1; |
| 12535 |
} |
| 12536 |
|
| 12537 |
if ((addr_mask & RELOAD_REG_OFFSET) == 0) |
| 12538 |
{ |
| 12539 |
extra_cost = 1; |
| 12540 |
type = "lo_sum"; |
| 12541 |
} |
| 12542 |
break; |
| 12543 |
|
| 12544 |
/* Static addresses need to create a TOC entry. */ |
| 12545 |
case CONST: |
| 12546 |
case SYMBOL_REF: |
| 12547 |
case LABEL_REF: |
| 12548 |
if ((addr_mask & RELOAD_REG_QUAD_OFFSET) != 0) |
| 12549 |
{ |
| 12550 |
extra_cost = -1; |
| 12551 |
type = "vector d-form lo_sum #2"; |
| 12552 |
} |
| 12553 |
|
| 12554 |
else |
| 12555 |
{ |
| 12556 |
type = "address"; |
| 12557 |
extra_cost = rs6000_secondary_reload_toc_costs (addr_mask); |
| 12558 |
} |
| 12559 |
break; |
| 12560 |
|
| 12561 |
/* TOC references look like offsetable memory. */ |
| 12562 |
case UNSPEC: |
| 12563 |
if (TARGET_CMODEL == CMODEL_SMALL || XINT (addr, 1) != UNSPEC_TOCREL) |
| 12564 |
{ |
| 12565 |
fail_msg = "bad UNSPEC"; |
| 12566 |
extra_cost = -1; |
| 12567 |
} |
| 12568 |
|
| 12569 |
else if ((addr_mask & RELOAD_REG_QUAD_OFFSET) != 0) |
| 12570 |
{ |
| 12571 |
extra_cost = -1; |
| 12572 |
type = "vector d-form lo_sum #3"; |
| 12573 |
} |
| 12574 |
|
| 12575 |
else if ((addr_mask & RELOAD_REG_OFFSET) == 0) |
| 12576 |
{ |
| 12577 |
extra_cost = 1; |
| 12578 |
type = "toc reference"; |
| 12579 |
} |
| 12580 |
break; |
| 12581 |
|
| 12582 |
default: |
| 12583 |
{ |
| 12584 |
fail_msg = "bad address"; |
| 12585 |
extra_cost = -1; |
| 12586 |
} |
| 12587 |
} |
| 12588 |
|
| 12589 |
if (TARGET_DEBUG_ADDR /* && extra_cost != 0 */) |
| 12590 |
{ |
| 12591 |
if (extra_cost < 0) |
| 12592 |
fprintf (stderr, |
| 12593 |
"rs6000_secondary_reload_memory error: mode = %s, " |
| 12594 |
"class = %s, addr_mask = '%s', %s\n", |
| 12595 |
GET_MODE_NAME (mode), |
| 12596 |
reg_class_names[rclass], |
| 12597 |
rs6000_debug_addr_mask (addr_mask, false), |
| 12598 |
(fail_msg != NULL) ? fail_msg : "<bad address>"); |
| 12599 |
|
| 12600 |
else |
| 12601 |
fprintf (stderr, |
| 12602 |
"rs6000_secondary_reload_memory: mode = %s, class = %s, " |
| 12603 |
"addr_mask = '%s', extra cost = %d, %s\n", |
| 12604 |
GET_MODE_NAME (mode), |
| 12605 |
reg_class_names[rclass], |
| 12606 |
rs6000_debug_addr_mask (addr_mask, false), |
| 12607 |
extra_cost, |
| 12608 |
(type) ? type : "<none>"); |
| 12609 |
|
| 12610 |
debug_rtx (addr); |
| 12611 |
} |
| 12612 |
|
| 12613 |
return extra_cost; |
| 12614 |
} |
| 12615 |
|
| 12616 |
/* Helper function for rs6000_secondary_reload to return true if a move to a |
| 12617 |
different register classe is really a simple move. */ |
| 12618 |
|
| 12619 |
static bool |
| 12620 |
rs6000_secondary_reload_simple_move (enum rs6000_reg_type to_type, |
| 12621 |
enum rs6000_reg_type from_type, |
| 12622 |
machine_mode mode) |
| 12623 |
{ |
| 12624 |
int size = GET_MODE_SIZE (mode); |
| 12625 |
|
| 12626 |
/* Add support for various direct moves available. In this function, we only |
| 12627 |
look at cases where we don't need any extra registers, and one or more |
| 12628 |
simple move insns are issued. Originally small integers are not allowed |
| 12629 |
in FPR/VSX registers. Single precision binary floating is not a simple |
| 12630 |
move because we need to convert to the single precision memory layout. |
| 12631 |
The 4-byte SDmode can be moved. TDmode values are disallowed since they |
| 12632 |
need special direct move handling, which we do not support yet. */ |
| 12633 |
if (TARGET_DIRECT_MOVE |
| 12634 |
&& ((to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE) |
| 12635 |
|| (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE))) |
| 12636 |
{ |
| 12637 |
if (TARGET_POWERPC64) |
| 12638 |
{ |
| 12639 |
/* ISA 2.07: MTVSRD or MVFVSRD. */ |
| 12640 |
if (size == 8) |
| 12641 |
return true; |
| 12642 |
|
| 12643 |
/* ISA 3.0: MTVSRDD or MFVSRD + MFVSRLD. */ |
| 12644 |
if (size == 16 && TARGET_P9_VECTOR && mode != TDmode) |
| 12645 |
return true; |
| 12646 |
} |
| 12647 |
|
| 12648 |
/* ISA 2.07: MTVSRWZ or MFVSRWZ. */ |
| 12649 |
if (TARGET_P8_VECTOR) |
| 12650 |
{ |
| 12651 |
if (mode == SImode) |
| 12652 |
return true; |
| 12653 |
|
| 12654 |
if (TARGET_P9_VECTOR && (mode == HImode || mode == QImode)) |
| 12655 |
return true; |
| 12656 |
} |
| 12657 |
|
| 12658 |
/* ISA 2.07: MTVSRWZ or MFVSRWZ. */ |
| 12659 |
if (mode == SDmode) |
| 12660 |
return true; |
| 12661 |
} |
| 12662 |
|
| 12663 |
/* Move to/from SPR. */ |
| 12664 |
else if ((size == 4 || (TARGET_POWERPC64 && size == 8)) |
| 12665 |
&& ((to_type == GPR_REG_TYPE && from_type == SPR_REG_TYPE) |
| 12666 |
|| (to_type == SPR_REG_TYPE && from_type == GPR_REG_TYPE))) |
| 12667 |
return true; |
| 12668 |
|
| 12669 |
return false; |
| 12670 |
} |
| 12671 |
|
| 12672 |
/* Direct move helper function for rs6000_secondary_reload, handle all of the |
| 12673 |
special direct moves that involve allocating an extra register, return the |
| 12674 |
insn code of the helper function if there is such a function or |
| 12675 |
CODE_FOR_nothing if not. */ |
| 12676 |
|
| 12677 |
static bool |
| 12678 |
rs6000_secondary_reload_direct_move (enum rs6000_reg_type to_type, |
| 12679 |
enum rs6000_reg_type from_type, |
| 12680 |
machine_mode mode, |
| 12681 |
secondary_reload_info *sri, |
| 12682 |
bool altivec_p) |
| 12683 |
{ |
| 12684 |
bool ret = false; |
| 12685 |
enum insn_code icode = CODE_FOR_nothing; |
| 12686 |
int cost = 0; |
| 12687 |
int size = GET_MODE_SIZE (mode); |
| 12688 |
|
| 12689 |
if (TARGET_POWERPC64 && size == 16) |
| 12690 |
{ |
| 12691 |
/* Handle moving 128-bit values from GPRs to VSX point registers on |
| 12692 |
ISA 2.07 (power8, power9) when running in 64-bit mode using |
| 12693 |
XXPERMDI to glue the two 64-bit values back together. */ |
| 12694 |
if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE) |
| 12695 |
{ |
| 12696 |
cost = 3; /* 2 mtvsrd's, 1 xxpermdi. */ |
| 12697 |
icode = reg_addr[mode].reload_vsx_gpr; |
| 12698 |
} |
| 12699 |
|
| 12700 |
/* Handle moving 128-bit values from VSX point registers to GPRs on |
| 12701 |
ISA 2.07 when running in 64-bit mode using XXPERMDI to get access to the |
| 12702 |
bottom 64-bit value. */ |
| 12703 |
else if (to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE) |
| 12704 |
{ |
| 12705 |
cost = 3; /* 2 mfvsrd's, 1 xxpermdi. */ |
| 12706 |
icode = reg_addr[mode].reload_gpr_vsx; |
| 12707 |
} |
| 12708 |
} |
| 12709 |
|
| 12710 |
else if (TARGET_POWERPC64 && mode == SFmode) |
| 12711 |
{ |
| 12712 |
if (to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE) |
| 12713 |
{ |
| 12714 |
cost = 3; /* xscvdpspn, mfvsrd, and. */ |
| 12715 |
icode = reg_addr[mode].reload_gpr_vsx; |
| 12716 |
} |
| 12717 |
|
| 12718 |
else if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE) |
| 12719 |
{ |
| 12720 |
cost = 2; /* mtvsrz, xscvspdpn. */ |
| 12721 |
icode = reg_addr[mode].reload_vsx_gpr; |
| 12722 |
} |
| 12723 |
} |
| 12724 |
|
| 12725 |
else if (!TARGET_POWERPC64 && size == 8) |
| 12726 |
{ |
| 12727 |
/* Handle moving 64-bit values from GPRs to floating point registers on |
| 12728 |
ISA 2.07 when running in 32-bit mode using FMRGOW to glue the two |
| 12729 |
32-bit values back together. Altivec register classes must be handled |
| 12730 |
specially since a different instruction is used, and the secondary |
| 12731 |
reload support requires a single instruction class in the scratch |
| 12732 |
register constraint. However, right now TFmode is not allowed in |
| 12733 |
Altivec registers, so the pattern will never match. */ |
| 12734 |
if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE && !altivec_p) |
| 12735 |
{ |
| 12736 |
cost = 3; /* 2 mtvsrwz's, 1 fmrgow. */ |
| 12737 |
icode = reg_addr[mode].reload_fpr_gpr; |
| 12738 |
} |
| 12739 |
} |
| 12740 |
|
| 12741 |
if (icode != CODE_FOR_nothing) |
| 12742 |
{ |
| 12743 |
ret = true; |
| 12744 |
if (sri) |
| 12745 |
{ |
| 12746 |
sri->icode = icode; |
| 12747 |
sri->extra_cost = cost; |
| 12748 |
} |
| 12749 |
} |
| 12750 |
|
| 12751 |
return ret; |
| 12752 |
} |
| 12753 |
|
| 12754 |
/* Return whether a move between two register classes can be done either |
| 12755 |
directly (simple move) or via a pattern that uses a single extra temporary |
| 12756 |
(using ISA 2.07's direct move in this case. */ |
| 12757 |
|
| 12758 |
static bool |
| 12759 |
rs6000_secondary_reload_move (enum rs6000_reg_type to_type, |
| 12760 |
enum rs6000_reg_type from_type, |
| 12761 |
machine_mode mode, |
| 12762 |
secondary_reload_info *sri, |
| 12763 |
bool altivec_p) |
| 12764 |
{ |
| 12765 |
/* Fall back to load/store reloads if either type is not a register. */ |
| 12766 |
if (to_type == NO_REG_TYPE || from_type == NO_REG_TYPE) |
| 12767 |
return false; |
| 12768 |
|
| 12769 |
/* If we haven't allocated registers yet, assume the move can be done for the |
| 12770 |
standard register types. */ |
| 12771 |
if ((to_type == PSEUDO_REG_TYPE && from_type == PSEUDO_REG_TYPE) |
| 12772 |
|| (to_type == PSEUDO_REG_TYPE && IS_STD_REG_TYPE (from_type)) |
| 12773 |
|| (from_type == PSEUDO_REG_TYPE && IS_STD_REG_TYPE (to_type))) |
| 12774 |
return true; |
| 12775 |
|
| 12776 |
/* Moves to the same set of registers is a simple move for non-specialized |
| 12777 |
registers. */ |
| 12778 |
if (to_type == from_type && IS_STD_REG_TYPE (to_type)) |
| 12779 |
return true; |
| 12780 |
|
| 12781 |
/* Check whether a simple move can be done directly. */ |
| 12782 |
if (rs6000_secondary_reload_simple_move (to_type, from_type, mode)) |
| 12783 |
{ |
| 12784 |
if (sri) |
| 12785 |
{ |
| 12786 |
sri->icode = CODE_FOR_nothing; |
| 12787 |
sri->extra_cost = 0; |
| 12788 |
} |
| 12789 |
return true; |
| 12790 |
} |
| 12791 |
|
| 12792 |
/* Now check if we can do it in a few steps. */ |
| 12793 |
return rs6000_secondary_reload_direct_move (to_type, from_type, mode, sri, |
| 12794 |
altivec_p); |
| 12795 |
} |
| 12796 |
|
| 12797 |
/* Inform reload about cases where moving X with a mode MODE to a register in |
| 12798 |
RCLASS requires an extra scratch or immediate register. Return the class |
| 12799 |
needed for the immediate register. |
| 12800 |
|
| 12801 |
For VSX and Altivec, we may need a register to convert sp+offset into |
| 12802 |
reg+sp. |
| 12803 |
|
| 12804 |
For misaligned 64-bit gpr loads and stores we need a register to |
| 12805 |
convert an offset address to indirect. */ |
| 12806 |
|
| 12807 |
static reg_class_t |
| 12808 |
rs6000_secondary_reload (bool in_p, |
| 12809 |
rtx x, |
| 12810 |
reg_class_t rclass_i, |
| 12811 |
machine_mode mode, |
| 12812 |
secondary_reload_info *sri) |
| 12813 |
{ |
| 12814 |
enum reg_class rclass = (enum reg_class) rclass_i; |
| 12815 |
reg_class_t ret = ALL_REGS; |
| 12816 |
enum insn_code icode; |
| 12817 |
bool default_p = false; |
| 12818 |
bool done_p = false; |
| 12819 |
|
| 12820 |
/* Allow subreg of memory before/during reload. */ |
| 12821 |
bool memory_p = (MEM_P (x) |
| 12822 |
|| (!reload_completed && SUBREG_P (x) |
| 12823 |
&& MEM_P (SUBREG_REG (x)))); |
| 12824 |
|
| 12825 |
sri->icode = CODE_FOR_nothing; |
| 12826 |
sri->t_icode = CODE_FOR_nothing; |
| 12827 |
sri->extra_cost = 0; |
| 12828 |
icode = ((in_p) |
| 12829 |
? reg_addr[mode].reload_load |
| 12830 |
: reg_addr[mode].reload_store); |
| 12831 |
|
| 12832 |
if (REG_P (x) || register_operand (x, mode)) |
| 12833 |
{ |
| 12834 |
enum rs6000_reg_type to_type = reg_class_to_reg_type[(int)rclass]; |
| 12835 |
bool altivec_p = (rclass == ALTIVEC_REGS); |
| 12836 |
enum rs6000_reg_type from_type = register_to_reg_type (x, &altivec_p); |
| 12837 |
|
| 12838 |
if (!in_p) |
| 12839 |
std::swap (to_type, from_type); |
| 12840 |
|
| 12841 |
/* Can we do a direct move of some sort? */ |
| 12842 |
if (rs6000_secondary_reload_move (to_type, from_type, mode, sri, |
| 12843 |
altivec_p)) |
| 12844 |
{ |
| 12845 |
icode = (enum insn_code)sri->icode; |
| 12846 |
default_p = false; |
| 12847 |
done_p = true; |
| 12848 |
ret = NO_REGS; |
| 12849 |
} |
| 12850 |
} |
| 12851 |
|
| 12852 |
/* Make sure 0.0 is not reloaded or forced into memory. */ |
| 12853 |
if (x == CONST0_RTX (mode) && VSX_REG_CLASS_P (rclass)) |
| 12854 |
{ |
| 12855 |
ret = NO_REGS; |
| 12856 |
default_p = false; |
| 12857 |
done_p = true; |
| 12858 |
} |
| 12859 |
|
| 12860 |
/* If this is a scalar floating point value and we want to load it into the |
| 12861 |
traditional Altivec registers, do it via a move via a traditional floating |
| 12862 |
point register, unless we have D-form addressing. Also make sure that |
| 12863 |
non-zero constants use a FPR. */ |
| 12864 |
if (!done_p && reg_addr[mode].scalar_in_vmx_p |
| 12865 |
&& !mode_supports_vmx_dform (mode) |
| 12866 |
&& (rclass == VSX_REGS || rclass == ALTIVEC_REGS) |
| 12867 |
&& (memory_p || CONST_DOUBLE_P (x))) |
| 12868 |
{ |
| 12869 |
ret = FLOAT_REGS; |
| 12870 |
default_p = false; |
| 12871 |
done_p = true; |
| 12872 |
} |
| 12873 |
|
| 12874 |
/* Handle reload of load/stores if we have reload helper functions. */ |
| 12875 |
if (!done_p && icode != CODE_FOR_nothing && memory_p) |
| 12876 |
{ |
| 12877 |
int extra_cost = rs6000_secondary_reload_memory (XEXP (x, 0), rclass, |
| 12878 |
mode); |
| 12879 |
|
| 12880 |
if (extra_cost >= 0) |
| 12881 |
{ |
| 12882 |
done_p = true; |
| 12883 |
ret = NO_REGS; |
| 12884 |
if (extra_cost > 0) |
| 12885 |
{ |
| 12886 |
sri->extra_cost = extra_cost; |
| 12887 |
sri->icode = icode; |
| 12888 |
} |
| 12889 |
} |
| 12890 |
} |
| 12891 |
|
| 12892 |
/* Handle unaligned loads and stores of integer registers. */ |
| 12893 |
if (!done_p && TARGET_POWERPC64 |
| 12894 |
&& reg_class_to_reg_type[(int)rclass] == GPR_REG_TYPE |
| 12895 |
&& memory_p |
| 12896 |
&& GET_MODE_SIZE (GET_MODE (x)) >= UNITS_PER_WORD) |
| 12897 |
{ |
| 12898 |
rtx addr = XEXP (x, 0); |
| 12899 |
rtx off = address_offset (addr); |
| 12900 |
|
| 12901 |
if (off != NULL_RTX) |
| 12902 |
{ |
| 12903 |
unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD; |
| 12904 |
unsigned HOST_WIDE_INT offset = INTVAL (off); |
| 12905 |
|
| 12906 |
/* We need a secondary reload when our legitimate_address_p |
| 12907 |
says the address is good (as otherwise the entire address |
| 12908 |
will be reloaded), and the offset is not a multiple of |
| 12909 |
four or we have an address wrap. Address wrap will only |
| 12910 |
occur for LO_SUMs since legitimate_offset_address_p |
| 12911 |
rejects addresses for 16-byte mems that will wrap. */ |
| 12912 |
if (GET_CODE (addr) == LO_SUM |
| 12913 |
? (1 /* legitimate_address_p allows any offset for lo_sum */ |
| 12914 |
&& ((offset & 3) != 0 |
| 12915 |
|| ((offset & 0xffff) ^ 0x8000) >= 0x10000 - extra)) |
| 12916 |
: (offset + 0x8000 < 0x10000 - extra /* legitimate_address_p */ |
| 12917 |
&& (offset & 3) != 0)) |
| 12918 |
{ |
| 12919 |
/* -m32 -mpowerpc64 needs to use a 32-bit scratch register. */ |
| 12920 |
if (in_p) |
| 12921 |
sri->icode = ((TARGET_32BIT) ? CODE_FOR_reload_si_load |
| 12922 |
: CODE_FOR_reload_di_load); |
| 12923 |
else |
| 12924 |
sri->icode = ((TARGET_32BIT) ? CODE_FOR_reload_si_store |
| 12925 |
: CODE_FOR_reload_di_store); |
| 12926 |
sri->extra_cost = 2; |
| 12927 |
ret = NO_REGS; |
| 12928 |
done_p = true; |
| 12929 |
} |
| 12930 |
else |
| 12931 |
default_p = true; |
| 12932 |
} |
| 12933 |
else |
| 12934 |
default_p = true; |
| 12935 |
} |
| 12936 |
|
| 12937 |
if (!done_p && !TARGET_POWERPC64 |
| 12938 |
&& reg_class_to_reg_type[(int)rclass] == GPR_REG_TYPE |
| 12939 |
&& memory_p |
| 12940 |
&& GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD) |
| 12941 |
{ |
| 12942 |
rtx addr = XEXP (x, 0); |
| 12943 |
rtx off = address_offset (addr); |
| 12944 |
|
| 12945 |
if (off != NULL_RTX) |
| 12946 |
{ |
| 12947 |
unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD; |
| 12948 |
unsigned HOST_WIDE_INT offset = INTVAL (off); |
| 12949 |
|
| 12950 |
/* We need a secondary reload when our legitimate_address_p |
| 12951 |
says the address is good (as otherwise the entire address |
| 12952 |
will be reloaded), and we have a wrap. |
| 12953 |
|
| 12954 |
legitimate_lo_sum_address_p allows LO_SUM addresses to |
| 12955 |
have any offset so test for wrap in the low 16 bits. |
| 12956 |
|
| 12957 |
legitimate_offset_address_p checks for the range |
| 12958 |
[-0x8000,0x7fff] for mode size of 8 and [-0x8000,0x7ff7] |
| 12959 |
for mode size of 16. We wrap at [0x7ffc,0x7fff] and |
| 12960 |
[0x7ff4,0x7fff] respectively, so test for the |
| 12961 |
intersection of these ranges, [0x7ffc,0x7fff] and |
| 12962 |
[0x7ff4,0x7ff7] respectively. |
| 12963 |
|
| 12964 |
Note that the address we see here may have been |
| 12965 |
manipulated by legitimize_reload_address. */ |
| 12966 |
if (GET_CODE (addr) == LO_SUM |
| 12967 |
? ((offset & 0xffff) ^ 0x8000) >= 0x10000 - extra |
| 12968 |
: offset - (0x8000 - extra) < UNITS_PER_WORD) |
| 12969 |
{ |
| 12970 |
if (in_p) |
| 12971 |
sri->icode = CODE_FOR_reload_si_load; |
| 12972 |
else |
| 12973 |
sri->icode = CODE_FOR_reload_si_store; |
| 12974 |
sri->extra_cost = 2; |
| 12975 |
ret = NO_REGS; |
| 12976 |
done_p = true; |
| 12977 |
} |
| 12978 |
else |
| 12979 |
default_p = true; |
| 12980 |
} |
| 12981 |
else |
| 12982 |
default_p = true; |
| 12983 |
} |
| 12984 |
|
| 12985 |
if (!done_p) |
| 12986 |
default_p = true; |
| 12987 |
|
| 12988 |
if (default_p) |
| 12989 |
ret = default_secondary_reload (in_p, x, rclass, mode, sri); |
| 12990 |
|
| 12991 |
gcc_assert (ret != ALL_REGS); |
| 12992 |
|
| 12993 |
if (TARGET_DEBUG_ADDR) |
| 12994 |
{ |
| 12995 |
fprintf (stderr, |
| 12996 |
"\nrs6000_secondary_reload, return %s, in_p = %s, rclass = %s, " |
| 12997 |
"mode = %s", |
| 12998 |
reg_class_names[ret], |
| 12999 |
in_p ? "true" : "false", |
| 13000 |
reg_class_names[rclass], |
| 13001 |
GET_MODE_NAME (mode)); |
| 13002 |
|
| 13003 |
if (reload_completed) |
| 13004 |
fputs (", after reload", stderr); |
| 13005 |
|
| 13006 |
if (!done_p) |
| 13007 |
fputs (", done_p not set", stderr); |
| 13008 |
|
| 13009 |
if (default_p) |
| 13010 |
fputs (", default secondary reload", stderr); |
| 13011 |
|
| 13012 |
if (sri->icode != CODE_FOR_nothing) |
| 13013 |
fprintf (stderr, ", reload func = %s, extra cost = %d", |
| 13014 |
insn_data[sri->icode].name, sri->extra_cost); |
| 13015 |
|
| 13016 |
else if (sri->extra_cost > 0) |
| 13017 |
fprintf (stderr, ", extra cost = %d", sri->extra_cost); |
| 13018 |
|
| 13019 |
fputs ("\n", stderr); |
| 13020 |
debug_rtx (x); |
| 13021 |
} |
| 13022 |
|
| 13023 |
return ret; |
| 13024 |
} |
| 13025 |
|
| 13026 |
/* Better tracing for rs6000_secondary_reload_inner. */ |
| 13027 |
|
| 13028 |
static void |
| 13029 |
rs6000_secondary_reload_trace (int line, rtx reg, rtx mem, rtx scratch, |
| 13030 |
bool store_p) |
| 13031 |
{ |
| 13032 |
rtx set, clobber; |
| 13033 |
|
| 13034 |
gcc_assert (reg != NULL_RTX && mem != NULL_RTX && scratch != NULL_RTX); |
| 13035 |
|
| 13036 |
fprintf (stderr, "rs6000_secondary_reload_inner:%d, type = %s\n", line, |
| 13037 |
store_p ? "store" : "load"); |
| 13038 |
|
| 13039 |
if (store_p) |
| 13040 |
set = gen_rtx_SET (mem, reg); |
| 13041 |
else |
| 13042 |
set = gen_rtx_SET (reg, mem); |
| 13043 |
|
| 13044 |
clobber = gen_rtx_CLOBBER (VOIDmode, scratch); |
| 13045 |
debug_rtx (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set, clobber))); |
| 13046 |
} |
| 13047 |
|
| 13048 |
static void rs6000_secondary_reload_fail (int, rtx, rtx, rtx, bool) |
| 13049 |
ATTRIBUTE_NORETURN; |
| 13050 |
|
| 13051 |
static void |
| 13052 |
rs6000_secondary_reload_fail (int line, rtx reg, rtx mem, rtx scratch, |
| 13053 |
bool store_p) |
| 13054 |
{ |
| 13055 |
rs6000_secondary_reload_trace (line, reg, mem, scratch, store_p); |
| 13056 |
gcc_unreachable (); |
| 13057 |
} |
| 13058 |
|
| 13059 |
/* Fixup reload addresses for values in GPR, FPR, and VMX registers that have |
| 13060 |
reload helper functions. These were identified in |
| 13061 |
rs6000_secondary_reload_memory, and if reload decided to use the secondary |
| 13062 |
reload, it calls the insns: |
| 13063 |
reload_<RELOAD:mode>_<P:mptrsize>_store |
| 13064 |
reload_<RELOAD:mode>_<P:mptrsize>_load |
| 13065 |
|
| 13066 |
which in turn calls this function, to do whatever is necessary to create |
| 13067 |
valid addresses. */ |
| 13068 |
|
| 13069 |
void |
| 13070 |
rs6000_secondary_reload_inner (rtx reg, rtx mem, rtx scratch, bool store_p) |
| 13071 |
{ |
| 13072 |
int regno = true_regnum (reg); |
| 13073 |
machine_mode mode = GET_MODE (reg); |
| 13074 |
addr_mask_type addr_mask; |
| 13075 |
rtx addr; |
| 13076 |
rtx new_addr; |
| 13077 |
rtx op_reg, op0, op1; |
| 13078 |
rtx and_op; |
| 13079 |
rtx cc_clobber; |
| 13080 |
rtvec rv; |
| 13081 |
|
| 13082 |
if (regno < 0 || !HARD_REGISTER_NUM_P (regno) || !MEM_P (mem) |
| 13083 |
|| !base_reg_operand (scratch, GET_MODE (scratch))) |
| 13084 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13085 |
|
| 13086 |
if (IN_RANGE (regno, FIRST_GPR_REGNO, LAST_GPR_REGNO)) |
| 13087 |
addr_mask = reg_addr[mode].addr_mask[RELOAD_REG_GPR]; |
| 13088 |
|
| 13089 |
else if (IN_RANGE (regno, FIRST_FPR_REGNO, LAST_FPR_REGNO)) |
| 13090 |
addr_mask = reg_addr[mode].addr_mask[RELOAD_REG_FPR]; |
| 13091 |
|
| 13092 |
else if (IN_RANGE (regno, FIRST_ALTIVEC_REGNO, LAST_ALTIVEC_REGNO)) |
| 13093 |
addr_mask = reg_addr[mode].addr_mask[RELOAD_REG_VMX]; |
| 13094 |
|
| 13095 |
else |
| 13096 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13097 |
|
| 13098 |
/* Make sure the mode is valid in this register class. */ |
| 13099 |
if ((addr_mask & RELOAD_REG_VALID) == 0) |
| 13100 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13101 |
|
| 13102 |
if (TARGET_DEBUG_ADDR) |
| 13103 |
rs6000_secondary_reload_trace (__LINE__, reg, mem, scratch, store_p); |
| 13104 |
|
| 13105 |
new_addr = addr = XEXP (mem, 0); |
| 13106 |
switch (GET_CODE (addr)) |
| 13107 |
{ |
| 13108 |
/* Does the register class support auto update forms for this mode? If |
| 13109 |
not, do the update now. We don't need a scratch register, since the |
| 13110 |
powerpc only supports PRE_INC, PRE_DEC, and PRE_MODIFY. */ |
| 13111 |
case PRE_INC: |
| 13112 |
case PRE_DEC: |
| 13113 |
op_reg = XEXP (addr, 0); |
| 13114 |
if (!base_reg_operand (op_reg, Pmode)) |
| 13115 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13116 |
|
| 13117 |
if ((addr_mask & RELOAD_REG_PRE_INCDEC) == 0) |
| 13118 |
{ |
| 13119 |
int delta = GET_MODE_SIZE (mode); |
| 13120 |
if (GET_CODE (addr) == PRE_DEC) |
| 13121 |
delta = -delta; |
| 13122 |
emit_insn (gen_add2_insn (op_reg, GEN_INT (delta))); |
| 13123 |
new_addr = op_reg; |
| 13124 |
} |
| 13125 |
break; |
| 13126 |
|
| 13127 |
case PRE_MODIFY: |
| 13128 |
op0 = XEXP (addr, 0); |
| 13129 |
op1 = XEXP (addr, 1); |
| 13130 |
if (!base_reg_operand (op0, Pmode) |
| 13131 |
|| GET_CODE (op1) != PLUS |
| 13132 |
|| !rtx_equal_p (op0, XEXP (op1, 0))) |
| 13133 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13134 |
|
| 13135 |
if ((addr_mask & RELOAD_REG_PRE_MODIFY) == 0) |
| 13136 |
{ |
| 13137 |
emit_insn (gen_rtx_SET (op0, op1)); |
| 13138 |
new_addr = reg; |
| 13139 |
} |
| 13140 |
break; |
| 13141 |
|
| 13142 |
/* Do we need to simulate AND -16 to clear the bottom address bits used |
| 13143 |
in VMX load/stores? */ |
| 13144 |
case AND: |
| 13145 |
op0 = XEXP (addr, 0); |
| 13146 |
op1 = XEXP (addr, 1); |
| 13147 |
if ((addr_mask & RELOAD_REG_AND_M16) == 0) |
| 13148 |
{ |
| 13149 |
if (REG_P (op0) || SUBREG_P (op0)) |
| 13150 |
op_reg = op0; |
| 13151 |
|
| 13152 |
else if (GET_CODE (op1) == PLUS) |
| 13153 |
{ |
| 13154 |
emit_insn (gen_rtx_SET (scratch, op1)); |
| 13155 |
op_reg = scratch; |
| 13156 |
} |
| 13157 |
|
| 13158 |
else |
| 13159 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13160 |
|
| 13161 |
and_op = gen_rtx_AND (GET_MODE (scratch), op_reg, op1); |
| 13162 |
cc_clobber = gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (CCmode)); |
| 13163 |
rv = gen_rtvec (2, gen_rtx_SET (scratch, and_op), cc_clobber); |
| 13164 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, rv)); |
| 13165 |
new_addr = scratch; |
| 13166 |
} |
| 13167 |
break; |
| 13168 |
|
| 13169 |
/* If this is an indirect address, make sure it is a base register. */ |
| 13170 |
case REG: |
| 13171 |
case SUBREG: |
| 13172 |
if (!base_reg_operand (addr, GET_MODE (addr))) |
| 13173 |
{ |
| 13174 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13175 |
new_addr = scratch; |
| 13176 |
} |
| 13177 |
break; |
| 13178 |
|
| 13179 |
/* If this is an indexed address, make sure the register class can handle |
| 13180 |
indexed addresses for this mode. */ |
| 13181 |
case PLUS: |
| 13182 |
op0 = XEXP (addr, 0); |
| 13183 |
op1 = XEXP (addr, 1); |
| 13184 |
if (!base_reg_operand (op0, Pmode)) |
| 13185 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13186 |
|
| 13187 |
else if (int_reg_operand (op1, Pmode)) |
| 13188 |
{ |
| 13189 |
if ((addr_mask & RELOAD_REG_INDEXED) == 0) |
| 13190 |
{ |
| 13191 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13192 |
new_addr = scratch; |
| 13193 |
} |
| 13194 |
} |
| 13195 |
|
| 13196 |
else if (mode_supports_dq_form (mode) && CONST_INT_P (op1)) |
| 13197 |
{ |
| 13198 |
if (((addr_mask & RELOAD_REG_QUAD_OFFSET) == 0) |
| 13199 |
|| !quad_address_p (addr, mode, false)) |
| 13200 |
{ |
| 13201 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13202 |
new_addr = scratch; |
| 13203 |
} |
| 13204 |
} |
| 13205 |
|
| 13206 |
/* Make sure the register class can handle offset addresses. */ |
| 13207 |
else if (rs6000_legitimate_offset_address_p (mode, addr, false, true)) |
| 13208 |
{ |
| 13209 |
if ((addr_mask & RELOAD_REG_OFFSET) == 0) |
| 13210 |
{ |
| 13211 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13212 |
new_addr = scratch; |
| 13213 |
} |
| 13214 |
} |
| 13215 |
|
| 13216 |
else |
| 13217 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13218 |
|
| 13219 |
break; |
| 13220 |
|
| 13221 |
case LO_SUM: |
| 13222 |
op0 = XEXP (addr, 0); |
| 13223 |
op1 = XEXP (addr, 1); |
| 13224 |
if (!base_reg_operand (op0, Pmode)) |
| 13225 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13226 |
|
| 13227 |
else if (int_reg_operand (op1, Pmode)) |
| 13228 |
{ |
| 13229 |
if ((addr_mask & RELOAD_REG_INDEXED) == 0) |
| 13230 |
{ |
| 13231 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13232 |
new_addr = scratch; |
| 13233 |
} |
| 13234 |
} |
| 13235 |
|
| 13236 |
/* Quad offsets are restricted and can't handle normal addresses. */ |
| 13237 |
else if (mode_supports_dq_form (mode)) |
| 13238 |
{ |
| 13239 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13240 |
new_addr = scratch; |
| 13241 |
} |
| 13242 |
|
| 13243 |
/* Make sure the register class can handle offset addresses. */ |
| 13244 |
else if (legitimate_lo_sum_address_p (mode, addr, false)) |
| 13245 |
{ |
| 13246 |
if ((addr_mask & RELOAD_REG_OFFSET) == 0) |
| 13247 |
{ |
| 13248 |
emit_insn (gen_rtx_SET (scratch, addr)); |
| 13249 |
new_addr = scratch; |
| 13250 |
} |
| 13251 |
} |
| 13252 |
|
| 13253 |
else |
| 13254 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13255 |
|
| 13256 |
break; |
| 13257 |
|
| 13258 |
case SYMBOL_REF: |
| 13259 |
case CONST: |
| 13260 |
case LABEL_REF: |
| 13261 |
rs6000_emit_move (scratch, addr, Pmode); |
| 13262 |
new_addr = scratch; |
| 13263 |
break; |
| 13264 |
|
| 13265 |
default: |
| 13266 |
rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p); |
| 13267 |
} |
| 13268 |
|
| 13269 |
/* Adjust the address if it changed. */ |
| 13270 |
if (addr != new_addr) |
| 13271 |
{ |
| 13272 |
mem = replace_equiv_address_nv (mem, new_addr); |
| 13273 |
if (TARGET_DEBUG_ADDR) |
| 13274 |
fprintf (stderr, "\nrs6000_secondary_reload_inner, mem adjusted.\n"); |
| 13275 |
} |
| 13276 |
|
| 13277 |
/* Now create the move. */ |
| 13278 |
if (store_p) |
| 13279 |
emit_insn (gen_rtx_SET (mem, reg)); |
| 13280 |
else |
| 13281 |
emit_insn (gen_rtx_SET (reg, mem)); |
| 13282 |
|
| 13283 |
return; |
| 13284 |
} |
| 13285 |
|
| 13286 |
/* Convert reloads involving 64-bit gprs and misaligned offset |
| 13287 |
addressing, or multiple 32-bit gprs and offsets that are too large, |
| 13288 |
to use indirect addressing. */ |
| 13289 |
|
| 13290 |
void |
| 13291 |
rs6000_secondary_reload_gpr (rtx reg, rtx mem, rtx scratch, bool store_p) |
| 13292 |
{ |
| 13293 |
int regno = true_regnum (reg); |
| 13294 |
enum reg_class rclass; |
| 13295 |
rtx addr; |
| 13296 |
rtx scratch_or_premodify = scratch; |
| 13297 |
|
| 13298 |
if (TARGET_DEBUG_ADDR) |
| 13299 |
{ |
| 13300 |
fprintf (stderr, "\nrs6000_secondary_reload_gpr, type = %s\n", |
| 13301 |
store_p ? "store" : "load"); |
| 13302 |
fprintf (stderr, "reg:\n"); |
| 13303 |
debug_rtx (reg); |
| 13304 |
fprintf (stderr, "mem:\n"); |
| 13305 |
debug_rtx (mem); |
| 13306 |
fprintf (stderr, "scratch:\n"); |
| 13307 |
debug_rtx (scratch); |
| 13308 |
} |
| 13309 |
|
| 13310 |
gcc_assert (regno >= 0 && HARD_REGISTER_NUM_P (regno)); |
| 13311 |
gcc_assert (MEM_P (mem)); |
| 13312 |
rclass = REGNO_REG_CLASS (regno); |
| 13313 |
gcc_assert (rclass == GENERAL_REGS || rclass == BASE_REGS); |
| 13314 |
addr = XEXP (mem, 0); |
| 13315 |
|
| 13316 |
if (GET_CODE (addr) == PRE_MODIFY) |
| 13317 |
{ |
| 13318 |
gcc_assert (REG_P (XEXP (addr, 0)) |
| 13319 |
&& GET_CODE (XEXP (addr, 1)) == PLUS |
| 13320 |
&& XEXP (XEXP (addr, 1), 0) == XEXP (addr, 0)); |
| 13321 |
scratch_or_premodify = XEXP (addr, 0); |
| 13322 |
addr = XEXP (addr, 1); |
| 13323 |
} |
| 13324 |
gcc_assert (GET_CODE (addr) == PLUS || GET_CODE (addr) == LO_SUM); |
| 13325 |
|
| 13326 |
rs6000_emit_move (scratch_or_premodify, addr, Pmode); |
| 13327 |
|
| 13328 |
mem = replace_equiv_address_nv (mem, scratch_or_premodify); |
| 13329 |
|
| 13330 |
/* Now create the move. */ |
| 13331 |
if (store_p) |
| 13332 |
emit_insn (gen_rtx_SET (mem, reg)); |
| 13333 |
else |
| 13334 |
emit_insn (gen_rtx_SET (reg, mem)); |
| 13335 |
|
| 13336 |
return; |
| 13337 |
} |
| 13338 |
|
| 13339 |
/* Given an rtx X being reloaded into a reg required to be |
| 13340 |
in class CLASS, return the class of reg to actually use. |
| 13341 |
In general this is just CLASS; but on some machines |
| 13342 |
in some cases it is preferable to use a more restrictive class. |
| 13343 |
|
| 13344 |
On the RS/6000, we have to return NO_REGS when we want to reload a |
| 13345 |
floating-point CONST_DOUBLE to force it to be copied to memory. |
| 13346 |
|
| 13347 |
We also don't want to reload integer values into floating-point |
| 13348 |
registers if we can at all help it. In fact, this can |
| 13349 |
cause reload to die, if it tries to generate a reload of CTR |
| 13350 |
into a FP register and discovers it doesn't have the memory location |
| 13351 |
required. |
| 13352 |
|
| 13353 |
??? Would it be a good idea to have reload do the converse, that is |
| 13354 |
try to reload floating modes into FP registers if possible? |
| 13355 |
*/ |
| 13356 |
|
| 13357 |
static enum reg_class |
| 13358 |
rs6000_preferred_reload_class (rtx x, enum reg_class rclass) |
| 13359 |
{ |
| 13360 |
machine_mode mode = GET_MODE (x); |
| 13361 |
bool is_constant = CONSTANT_P (x); |
| 13362 |
|
| 13363 |
/* If a mode can't go in FPR/ALTIVEC/VSX registers, don't return a preferred |
| 13364 |
reload class for it. */ |
| 13365 |
if ((rclass == ALTIVEC_REGS || rclass == VSX_REGS) |
| 13366 |
&& (reg_addr[mode].addr_mask[RELOAD_REG_VMX] & RELOAD_REG_VALID) == 0) |
| 13367 |
return NO_REGS; |
| 13368 |
|
| 13369 |
if ((rclass == FLOAT_REGS || rclass == VSX_REGS) |
| 13370 |
&& (reg_addr[mode].addr_mask[RELOAD_REG_FPR] & RELOAD_REG_VALID) == 0) |
| 13371 |
return NO_REGS; |
| 13372 |
|
| 13373 |
/* For VSX, see if we should prefer FLOAT_REGS or ALTIVEC_REGS. Do not allow |
| 13374 |
the reloading of address expressions using PLUS into floating point |
| 13375 |
registers. */ |
| 13376 |
if (TARGET_VSX && VSX_REG_CLASS_P (rclass) && GET_CODE (x) != PLUS) |
| 13377 |
{ |
| 13378 |
if (is_constant) |
| 13379 |
{ |
| 13380 |
/* Zero is always allowed in all VSX registers. */ |
| 13381 |
if (x == CONST0_RTX (mode)) |
| 13382 |
return rclass; |
| 13383 |
|
| 13384 |
/* If this is a vector constant that can be formed with a few Altivec |
| 13385 |
instructions, we want altivec registers. */ |
| 13386 |
if (GET_CODE (x) == CONST_VECTOR && easy_vector_constant (x, mode)) |
| 13387 |
return ALTIVEC_REGS; |
| 13388 |
|
| 13389 |
/* If this is an integer constant that can easily be loaded into |
| 13390 |
vector registers, allow it. */ |
| 13391 |
if (CONST_INT_P (x)) |
| 13392 |
{ |
| 13393 |
HOST_WIDE_INT value = INTVAL (x); |
| 13394 |
|
| 13395 |
/* ISA 2.07 can generate -1 in all registers with XXLORC. ISA |
| 13396 |
2.06 can generate it in the Altivec registers with |
| 13397 |
VSPLTI<x>. */ |
| 13398 |
if (value == -1) |
| 13399 |
{ |
| 13400 |
if (TARGET_P8_VECTOR) |
| 13401 |
return rclass; |
| 13402 |
else if (rclass == ALTIVEC_REGS || rclass == VSX_REGS) |
| 13403 |
return ALTIVEC_REGS; |
| 13404 |
else |
| 13405 |
return NO_REGS; |
| 13406 |
} |
| 13407 |
|
| 13408 |
/* ISA 3.0 can load -128..127 using the XXSPLTIB instruction and |
| 13409 |
a sign extend in the Altivec registers. */ |
| 13410 |
if (IN_RANGE (value, -128, 127) && TARGET_P9_VECTOR |
| 13411 |
&& (rclass == ALTIVEC_REGS || rclass == VSX_REGS)) |
| 13412 |
return ALTIVEC_REGS; |
| 13413 |
} |
| 13414 |
|
| 13415 |
/* Force constant to memory. */ |
| 13416 |
return NO_REGS; |
| 13417 |
} |
| 13418 |
|
| 13419 |
/* D-form addressing can easily reload the value. */ |
| 13420 |
if (mode_supports_vmx_dform (mode) |
| 13421 |
|| mode_supports_dq_form (mode)) |
| 13422 |
return rclass; |
| 13423 |
|
| 13424 |
/* If this is a scalar floating point value and we don't have D-form |
| 13425 |
addressing, prefer the traditional floating point registers so that we |
| 13426 |
can use D-form (register+offset) addressing. */ |
| 13427 |
if (rclass == VSX_REGS |
| 13428 |
&& (mode == SFmode || GET_MODE_SIZE (mode) == 8)) |
| 13429 |
return FLOAT_REGS; |
| 13430 |
|
| 13431 |
/* Prefer the Altivec registers if Altivec is handling the vector |
| 13432 |
operations (i.e. V16QI, V8HI, and V4SI), or if we prefer Altivec |
| 13433 |
loads. */ |
| 13434 |
if (VECTOR_UNIT_ALTIVEC_P (mode) || VECTOR_MEM_ALTIVEC_P (mode) |
| 13435 |
|| mode == V1TImode) |
| 13436 |
return ALTIVEC_REGS; |
| 13437 |
|
| 13438 |
return rclass; |
| 13439 |
} |
| 13440 |
|
| 13441 |
if (is_constant || GET_CODE (x) == PLUS) |
| 13442 |
{ |
| 13443 |
if (reg_class_subset_p (GENERAL_REGS, rclass)) |
| 13444 |
return GENERAL_REGS; |
| 13445 |
if (reg_class_subset_p (BASE_REGS, rclass)) |
| 13446 |
return BASE_REGS; |
| 13447 |
return NO_REGS; |
| 13448 |
} |
| 13449 |
|
| 13450 |
/* For the vector pair and vector quad modes, prefer their natural register |
| 13451 |
(VSX or FPR) rather than GPR registers. For other integer types, prefer |
| 13452 |
the GPR registers. */ |
| 13453 |
if (rclass == GEN_OR_FLOAT_REGS) |
| 13454 |
{ |
| 13455 |
if (mode == OOmode) |
| 13456 |
return VSX_REGS; |
| 13457 |
|
| 13458 |
if (mode == XOmode) |
| 13459 |
return FLOAT_REGS; |
| 13460 |
|
| 13461 |
if (GET_MODE_CLASS (mode) == MODE_INT) |
| 13462 |
return GENERAL_REGS; |
| 13463 |
} |
| 13464 |
|
| 13465 |
return rclass; |
| 13466 |
} |
| 13467 |
|
| 13468 |
/* Debug version of rs6000_preferred_reload_class. */ |
| 13469 |
static enum reg_class |
| 13470 |
rs6000_debug_preferred_reload_class (rtx x, enum reg_class rclass) |
| 13471 |
{ |
| 13472 |
enum reg_class ret = rs6000_preferred_reload_class (x, rclass); |
| 13473 |
|
| 13474 |
fprintf (stderr, |
| 13475 |
"\nrs6000_preferred_reload_class, return %s, rclass = %s, " |
| 13476 |
"mode = %s, x:\n", |
| 13477 |
reg_class_names[ret], reg_class_names[rclass], |
| 13478 |
GET_MODE_NAME (GET_MODE (x))); |
| 13479 |
debug_rtx (x); |
| 13480 |
|
| 13481 |
return ret; |
| 13482 |
} |
| 13483 |
|
| 13484 |
/* If we are copying between FP or AltiVec registers and anything else, we need |
| 13485 |
a memory location. The exception is when we are targeting ppc64 and the |
| 13486 |
move to/from fpr to gpr instructions are available. Also, under VSX, you |
| 13487 |
can copy vector registers from the FP register set to the Altivec register |
| 13488 |
set and vice versa. */ |
| 13489 |
|
| 13490 |
static bool |
| 13491 |
rs6000_secondary_memory_needed (machine_mode mode, |
| 13492 |
reg_class_t from_class, |
| 13493 |
reg_class_t to_class) |
| 13494 |
{ |
| 13495 |
enum rs6000_reg_type from_type, to_type; |
| 13496 |
bool altivec_p = ((from_class == ALTIVEC_REGS) |
| 13497 |
|| (to_class == ALTIVEC_REGS)); |
| 13498 |
|
| 13499 |
/* If a simple/direct move is available, we don't need secondary memory */ |
| 13500 |
from_type = reg_class_to_reg_type[(int)from_class]; |
| 13501 |
to_type = reg_class_to_reg_type[(int)to_class]; |
| 13502 |
|
| 13503 |
if (rs6000_secondary_reload_move (to_type, from_type, mode, |
| 13504 |
(secondary_reload_info *)0, altivec_p)) |
| 13505 |
return false; |
| 13506 |
|
| 13507 |
/* If we have a floating point or vector register class, we need to use |
| 13508 |
memory to transfer the data. */ |
| 13509 |
if (IS_FP_VECT_REG_TYPE (from_type) || IS_FP_VECT_REG_TYPE (to_type)) |
| 13510 |
return true; |
| 13511 |
|
| 13512 |
return false; |
| 13513 |
} |
| 13514 |
|
| 13515 |
/* Debug version of rs6000_secondary_memory_needed. */ |
| 13516 |
static bool |
| 13517 |
rs6000_debug_secondary_memory_needed (machine_mode mode, |
| 13518 |
reg_class_t from_class, |
| 13519 |
reg_class_t to_class) |
| 13520 |
{ |
| 13521 |
bool ret = rs6000_secondary_memory_needed (mode, from_class, to_class); |
| 13522 |
|
| 13523 |
fprintf (stderr, |
| 13524 |
"rs6000_secondary_memory_needed, return: %s, from_class = %s, " |
| 13525 |
"to_class = %s, mode = %s\n", |
| 13526 |
ret ? "true" : "false", |
| 13527 |
reg_class_names[from_class], |
| 13528 |
reg_class_names[to_class], |
| 13529 |
GET_MODE_NAME (mode)); |
| 13530 |
|
| 13531 |
return ret; |
| 13532 |
} |
| 13533 |
|
| 13534 |
/* Return the register class of a scratch register needed to copy IN into |
| 13535 |
or out of a register in RCLASS in MODE. If it can be done directly, |
| 13536 |
NO_REGS is returned. */ |
| 13537 |
|
| 13538 |
static enum reg_class |
| 13539 |
rs6000_secondary_reload_class (enum reg_class rclass, machine_mode mode, |
| 13540 |
rtx in) |
| 13541 |
{ |
| 13542 |
int regno; |
| 13543 |
|
| 13544 |
if (TARGET_ELF || (DEFAULT_ABI == ABI_DARWIN |
| 13545 |
#if TARGET_MACHO |
| 13546 |
&& MACHOPIC_INDIRECT |
| 13547 |
#endif |
| 13548 |
)) |
| 13549 |
{ |
| 13550 |
/* We cannot copy a symbolic operand directly into anything |
| 13551 |
other than BASE_REGS for TARGET_ELF. So indicate that a |
| 13552 |
register from BASE_REGS is needed as an intermediate |
| 13553 |
register. |
| 13554 |
|
| 13555 |
On Darwin, pic addresses require a load from memory, which |
| 13556 |
needs a base register. */ |
| 13557 |
if (rclass != BASE_REGS |
| 13558 |
&& (SYMBOL_REF_P (in) |
| 13559 |
|| GET_CODE (in) == HIGH |
| 13560 |
|| GET_CODE (in) == LABEL_REF |
| 13561 |
|| GET_CODE (in) == CONST)) |
| 13562 |
return BASE_REGS; |
| 13563 |
} |
| 13564 |
|
| 13565 |
if (REG_P (in)) |
| 13566 |
{ |
| 13567 |
regno = REGNO (in); |
| 13568 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 13569 |
{ |
| 13570 |
regno = true_regnum (in); |
| 13571 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 13572 |
regno = -1; |
| 13573 |
} |
| 13574 |
} |
| 13575 |
else if (SUBREG_P (in)) |
| 13576 |
{ |
| 13577 |
regno = true_regnum (in); |
| 13578 |
if (!HARD_REGISTER_NUM_P (regno)) |
| 13579 |
regno = -1; |
| 13580 |
} |
| 13581 |
else |
| 13582 |
regno = -1; |
| 13583 |
|
| 13584 |
/* If we have VSX register moves, prefer moving scalar values between |
| 13585 |
Altivec registers and GPR by going via an FPR (and then via memory) |
| 13586 |
instead of reloading the secondary memory address for Altivec moves. */ |
| 13587 |
if (TARGET_VSX |
| 13588 |
&& GET_MODE_SIZE (mode) < 16 |
| 13589 |
&& !mode_supports_vmx_dform (mode) |
| 13590 |
&& (((rclass == GENERAL_REGS || rclass == BASE_REGS) |
| 13591 |
&& (regno >= 0 && ALTIVEC_REGNO_P (regno))) |
| 13592 |
|| ((rclass == VSX_REGS || rclass == ALTIVEC_REGS) |
| 13593 |
&& (regno >= 0 && INT_REGNO_P (regno))))) |
| 13594 |
return FLOAT_REGS; |
| 13595 |
|
| 13596 |
/* We can place anything into GENERAL_REGS and can put GENERAL_REGS |
| 13597 |
into anything. */ |
| 13598 |
if (rclass == GENERAL_REGS || rclass == BASE_REGS |
| 13599 |
|| (regno >= 0 && INT_REGNO_P (regno))) |
| 13600 |
return NO_REGS; |
| 13601 |
|
| 13602 |
/* Constants, memory, and VSX registers can go into VSX registers (both the |
| 13603 |
traditional floating point and the altivec registers). */ |
| 13604 |
if (rclass == VSX_REGS |
| 13605 |
&& (regno == -1 || VSX_REGNO_P (regno))) |
| 13606 |
return NO_REGS; |
| 13607 |
|
| 13608 |
/* Constants, memory, and FP registers can go into FP registers. */ |
| 13609 |
if ((regno == -1 || FP_REGNO_P (regno)) |
| 13610 |
&& (rclass == FLOAT_REGS || rclass == GEN_OR_FLOAT_REGS)) |
| 13611 |
return (mode != SDmode || lra_in_progress) ? NO_REGS : GENERAL_REGS; |
| 13612 |
|
| 13613 |
/* Memory, and AltiVec registers can go into AltiVec registers. */ |
| 13614 |
if ((regno == -1 || ALTIVEC_REGNO_P (regno)) |
| 13615 |
&& rclass == ALTIVEC_REGS) |
| 13616 |
return NO_REGS; |
| 13617 |
|
| 13618 |
/* We can copy among the CR registers. */ |
| 13619 |
if ((rclass == CR_REGS || rclass == CR0_REGS) |
| 13620 |
&& regno >= 0 && CR_REGNO_P (regno)) |
| 13621 |
return NO_REGS; |
| 13622 |
|
| 13623 |
/* Otherwise, we need GENERAL_REGS. */ |
| 13624 |
return GENERAL_REGS; |
| 13625 |
} |
| 13626 |
|
| 13627 |
/* Debug version of rs6000_secondary_reload_class. */ |
| 13628 |
static enum reg_class |
| 13629 |
rs6000_debug_secondary_reload_class (enum reg_class rclass, |
| 13630 |
machine_mode mode, rtx in) |
| 13631 |
{ |
| 13632 |
enum reg_class ret = rs6000_secondary_reload_class (rclass, mode, in); |
| 13633 |
fprintf (stderr, |
| 13634 |
"\nrs6000_secondary_reload_class, return %s, rclass = %s, " |
| 13635 |
"mode = %s, input rtx:\n", |
| 13636 |
reg_class_names[ret], reg_class_names[rclass], |
| 13637 |
GET_MODE_NAME (mode)); |
| 13638 |
debug_rtx (in); |
| 13639 |
|
| 13640 |
return ret; |
| 13641 |
} |
| 13642 |
|
| 13643 |
/* Implement TARGET_CAN_CHANGE_MODE_CLASS. */ |
| 13644 |
|
| 13645 |
static bool |
| 13646 |
rs6000_can_change_mode_class (machine_mode from, |
| 13647 |
machine_mode to, |
| 13648 |
reg_class_t rclass) |
| 13649 |
{ |
| 13650 |
unsigned from_size = GET_MODE_SIZE (from); |
| 13651 |
unsigned to_size = GET_MODE_SIZE (to); |
| 13652 |
|
| 13653 |
if (from_size != to_size) |
| 13654 |
{ |
| 13655 |
enum reg_class xclass = (TARGET_VSX) ? VSX_REGS : FLOAT_REGS; |
| 13656 |
|
| 13657 |
if (reg_classes_intersect_p (xclass, rclass)) |
| 13658 |
{ |
| 13659 |
unsigned to_nregs = hard_regno_nregs (FIRST_FPR_REGNO, to); |
| 13660 |
unsigned from_nregs = hard_regno_nregs (FIRST_FPR_REGNO, from); |
| 13661 |
bool to_float128_vector_p = FLOAT128_VECTOR_P (to); |
| 13662 |
bool from_float128_vector_p = FLOAT128_VECTOR_P (from); |
| 13663 |
|
| 13664 |
/* Don't allow 64-bit types to overlap with 128-bit types that take a |
| 13665 |
single register under VSX because the scalar part of the register |
| 13666 |
is in the upper 64-bits, and not the lower 64-bits. Types like |
| 13667 |
TFmode/TDmode that take 2 scalar register can overlap. 128-bit |
| 13668 |
IEEE floating point can't overlap, and neither can small |
| 13669 |
values. */ |
| 13670 |
|
| 13671 |
if (to_float128_vector_p && from_float128_vector_p) |
| 13672 |
return true; |
| 13673 |
|
| 13674 |
else if (to_float128_vector_p || from_float128_vector_p) |
| 13675 |
return false; |
| 13676 |
|
| 13677 |
/* TDmode in floating-mode registers must always go into a register |
| 13678 |
pair with the most significant word in the even-numbered register |
| 13679 |
to match ISA requirements. In little-endian mode, this does not |
| 13680 |
match subreg numbering, so we cannot allow subregs. */ |
| 13681 |
if (!BYTES_BIG_ENDIAN && (to == TDmode || from == TDmode)) |
| 13682 |
return false; |
| 13683 |
|
| 13684 |
/* Allow SD<->DD changes, since SDmode values are stored in |
| 13685 |
the low half of the DDmode, just like target-independent |
| 13686 |
code expects. We need to allow at least SD->DD since |
| 13687 |
rs6000_secondary_memory_needed_mode asks for that change |
| 13688 |
to be made for SD reloads. */ |
| 13689 |
if ((to == DDmode && from == SDmode) |
| 13690 |
|| (to == SDmode && from == DDmode)) |
| 13691 |
return true; |
| 13692 |
|
| 13693 |
if (from_size < 8 || to_size < 8) |
| 13694 |
return false; |
| 13695 |
|
| 13696 |
if (from_size == 8 && (8 * to_nregs) != to_size) |
| 13697 |
return false; |
| 13698 |
|
| 13699 |
if (to_size == 8 && (8 * from_nregs) != from_size) |
| 13700 |
return false; |
| 13701 |
|
| 13702 |
return true; |
| 13703 |
} |
| 13704 |
else |
| 13705 |
return true; |
| 13706 |
} |
| 13707 |
|
| 13708 |
/* Since the VSX register set includes traditional floating point registers |
| 13709 |
and altivec registers, just check for the size being different instead of |
| 13710 |
trying to check whether the modes are vector modes. Otherwise it won't |
| 13711 |
allow say DF and DI to change classes. For types like TFmode and TDmode |
| 13712 |
that take 2 64-bit registers, rather than a single 128-bit register, don't |
| 13713 |
allow subregs of those types to other 128 bit types. */ |
| 13714 |
if (TARGET_VSX && VSX_REG_CLASS_P (rclass)) |
| 13715 |
{ |
| 13716 |
unsigned num_regs = (from_size + 15) / 16; |
| 13717 |
if (hard_regno_nregs (FIRST_FPR_REGNO, to) > num_regs |
| 13718 |
|| hard_regno_nregs (FIRST_FPR_REGNO, from) > num_regs) |
| 13719 |
return false; |
| 13720 |
|
| 13721 |
return (from_size == 8 || from_size == 16); |
| 13722 |
} |
| 13723 |
|
| 13724 |
if (TARGET_ALTIVEC && rclass == ALTIVEC_REGS |
| 13725 |
&& (ALTIVEC_VECTOR_MODE (from) + ALTIVEC_VECTOR_MODE (to)) == 1) |
| 13726 |
return false; |
| 13727 |
|
| 13728 |
return true; |
| 13729 |
} |
| 13730 |
|
| 13731 |
/* Implement TARGET_REDZONE_CLOBBER. */ |
| 13732 |
|
| 13733 |
static rtx |
| 13734 |
rs6000_redzone_clobber () |
| 13735 |
{ |
| 13736 |
cfun->machine->asm_redzone_clobber_seen = true; |
| 13737 |
if (DEFAULT_ABI != ABI_V4) |
| 13738 |
{ |
| 13739 |
int red_zone_size = TARGET_32BIT ? 220 : 288; |
| 13740 |
rtx base = plus_constant (Pmode, stack_pointer_rtx, |
| 13741 |
GEN_INT (-red_zone_size)); |
| 13742 |
rtx mem = gen_rtx_MEM (BLKmode, base); |
| 13743 |
set_mem_size (mem, red_zone_size); |
| 13744 |
return mem; |
| 13745 |
} |
| 13746 |
return NULL_RTX; |
| 13747 |
} |
| 13748 |
|
| 13749 |
/* Debug version of rs6000_can_change_mode_class. */ |
| 13750 |
static bool |
| 13751 |
rs6000_debug_can_change_mode_class (machine_mode from, |
| 13752 |
machine_mode to, |
| 13753 |
reg_class_t rclass) |
| 13754 |
{ |
| 13755 |
bool ret = rs6000_can_change_mode_class (from, to, rclass); |
| 13756 |
|
| 13757 |
fprintf (stderr, |
| 13758 |
"rs6000_can_change_mode_class, return %s, from = %s, " |
| 13759 |
"to = %s, rclass = %s\n", |
| 13760 |
ret ? "true" : "false", |
| 13761 |
GET_MODE_NAME (from), GET_MODE_NAME (to), |
| 13762 |
reg_class_names[rclass]); |
| 13763 |
|
| 13764 |
return ret; |
| 13765 |
} |
| 13766 |
|
| 13767 |
/* Return a string to do a move operation of 128 bits of data. */ |
| 13768 |
|
| 13769 |
const char * |
| 13770 |
rs6000_output_move_128bit (rtx operands[]) |
| 13771 |
{ |
| 13772 |
rtx dest = operands[0]; |
| 13773 |
rtx src = operands[1]; |
| 13774 |
machine_mode mode = GET_MODE (dest); |
| 13775 |
int dest_regno; |
| 13776 |
int src_regno; |
| 13777 |
bool dest_gpr_p, dest_fp_p, dest_vmx_p, dest_vsx_p; |
| 13778 |
bool src_gpr_p, src_fp_p, src_vmx_p, src_vsx_p; |
| 13779 |
|
| 13780 |
if (REG_P (dest)) |
| 13781 |
{ |
| 13782 |
dest_regno = REGNO (dest); |
| 13783 |
dest_gpr_p = INT_REGNO_P (dest_regno); |
| 13784 |
dest_fp_p = FP_REGNO_P (dest_regno); |
| 13785 |
dest_vmx_p = ALTIVEC_REGNO_P (dest_regno); |
| 13786 |
dest_vsx_p = dest_fp_p | dest_vmx_p; |
| 13787 |
} |
| 13788 |
else |
| 13789 |
{ |
| 13790 |
dest_regno = -1; |
| 13791 |
dest_gpr_p = dest_fp_p = dest_vmx_p = dest_vsx_p = false; |
| 13792 |
} |
| 13793 |
|
| 13794 |
if (REG_P (src)) |
| 13795 |
{ |
| 13796 |
src_regno = REGNO (src); |
| 13797 |
src_gpr_p = INT_REGNO_P (src_regno); |
| 13798 |
src_fp_p = FP_REGNO_P (src_regno); |
| 13799 |
src_vmx_p = ALTIVEC_REGNO_P (src_regno); |
| 13800 |
src_vsx_p = src_fp_p | src_vmx_p; |
| 13801 |
} |
| 13802 |
else |
| 13803 |
{ |
| 13804 |
src_regno = -1; |
| 13805 |
src_gpr_p = src_fp_p = src_vmx_p = src_vsx_p = false; |
| 13806 |
} |
| 13807 |
|
| 13808 |
/* Register moves. */ |
| 13809 |
if (dest_regno >= 0 && src_regno >= 0) |
| 13810 |
{ |
| 13811 |
if (dest_gpr_p) |
| 13812 |
{ |
| 13813 |
if (src_gpr_p) |
| 13814 |
return "#"; |
| 13815 |
|
| 13816 |
if (TARGET_DIRECT_MOVE_128 && src_vsx_p) |
| 13817 |
return (WORDS_BIG_ENDIAN |
| 13818 |
? "mfvsrd %0,%x1\n\tmfvsrld %L0,%x1" |
| 13819 |
: "mfvsrd %L0,%x1\n\tmfvsrld %0,%x1"); |
| 13820 |
|
| 13821 |
else if (TARGET_DIRECT_MOVE && src_vsx_p) |
| 13822 |
return "#"; |
| 13823 |
} |
| 13824 |
|
| 13825 |
else if (TARGET_VSX && dest_vsx_p) |
| 13826 |
{ |
| 13827 |
if (src_vsx_p) |
| 13828 |
return "xxlor %x0,%x1,%x1"; |
| 13829 |
|
| 13830 |
else if (TARGET_DIRECT_MOVE_128 && src_gpr_p) |
| 13831 |
return (WORDS_BIG_ENDIAN |
| 13832 |
? "mtvsrdd %x0,%1,%L1" |
| 13833 |
: "mtvsrdd %x0,%L1,%1"); |
| 13834 |
|
| 13835 |
else if (TARGET_DIRECT_MOVE && src_gpr_p) |
| 13836 |
return "#"; |
| 13837 |
} |
| 13838 |
|
| 13839 |
else if (TARGET_ALTIVEC && dest_vmx_p && src_vmx_p) |
| 13840 |
return "vor %0,%1,%1"; |
| 13841 |
|
| 13842 |
else if (dest_fp_p && src_fp_p) |
| 13843 |
return "#"; |
| 13844 |
} |
| 13845 |
|
| 13846 |
/* Loads. */ |
| 13847 |
else if (dest_regno >= 0 && MEM_P (src)) |
| 13848 |
{ |
| 13849 |
if (dest_gpr_p) |
| 13850 |
{ |
| 13851 |
if (TARGET_QUAD_MEMORY && quad_load_store_p (dest, src)) |
| 13852 |
return "lq %0,%1"; |
| 13853 |
else |
| 13854 |
return "#"; |
| 13855 |
} |
| 13856 |
|
| 13857 |
else if (TARGET_ALTIVEC && dest_vmx_p |
| 13858 |
&& altivec_indexed_or_indirect_operand (src, mode)) |
| 13859 |
return "lvx %0,%y1"; |
| 13860 |
|
| 13861 |
else if (TARGET_VSX && dest_vsx_p) |
| 13862 |
{ |
| 13863 |
if (mode_supports_dq_form (mode) |
| 13864 |
&& quad_address_p (XEXP (src, 0), mode, true)) |
| 13865 |
return "lxv %x0,%1"; |
| 13866 |
|
| 13867 |
else if (TARGET_P9_VECTOR) |
| 13868 |
return "lxvx %x0,%y1"; |
| 13869 |
|
| 13870 |
else if (mode == V16QImode || mode == V8HImode || mode == V4SImode) |
| 13871 |
return "lxvw4x %x0,%y1"; |
| 13872 |
|
| 13873 |
else |
| 13874 |
return "lxvd2x %x0,%y1"; |
| 13875 |
} |
| 13876 |
|
| 13877 |
else if (TARGET_ALTIVEC && dest_vmx_p) |
| 13878 |
return "lvx %0,%y1"; |
| 13879 |
|
| 13880 |
else if (dest_fp_p) |
| 13881 |
return "#"; |
| 13882 |
} |
| 13883 |
|
| 13884 |
/* Stores. */ |
| 13885 |
else if (src_regno >= 0 && MEM_P (dest)) |
| 13886 |
{ |
| 13887 |
if (src_gpr_p) |
| 13888 |
{ |
| 13889 |
if (TARGET_QUAD_MEMORY && quad_load_store_p (dest, src)) |
| 13890 |
return "stq %1,%0"; |
| 13891 |
else |
| 13892 |
return "#"; |
| 13893 |
} |
| 13894 |
|
| 13895 |
else if (TARGET_ALTIVEC && src_vmx_p |
| 13896 |
&& altivec_indexed_or_indirect_operand (dest, mode)) |
| 13897 |
return "stvx %1,%y0"; |
| 13898 |
|
| 13899 |
else if (TARGET_VSX && src_vsx_p) |
| 13900 |
{ |
| 13901 |
if (mode_supports_dq_form (mode) |
| 13902 |
&& quad_address_p (XEXP (dest, 0), mode, true)) |
| 13903 |
return "stxv %x1,%0"; |
| 13904 |
|
| 13905 |
else if (TARGET_P9_VECTOR) |
| 13906 |
return "stxvx %x1,%y0"; |
| 13907 |
|
| 13908 |
else if (mode == V16QImode || mode == V8HImode || mode == V4SImode) |
| 13909 |
return "stxvw4x %x1,%y0"; |
| 13910 |
|
| 13911 |
else |
| 13912 |
return "stxvd2x %x1,%y0"; |
| 13913 |
} |
| 13914 |
|
| 13915 |
else if (TARGET_ALTIVEC && src_vmx_p) |
| 13916 |
return "stvx %1,%y0"; |
| 13917 |
|
| 13918 |
else if (src_fp_p) |
| 13919 |
return "#"; |
| 13920 |
} |
| 13921 |
|
| 13922 |
/* Constants. */ |
| 13923 |
else if (dest_regno >= 0 |
| 13924 |
&& (CONST_INT_P (src) |
| 13925 |
|| CONST_WIDE_INT_P (src) |
| 13926 |
|| CONST_DOUBLE_P (src) |
| 13927 |
|| GET_CODE (src) == CONST_VECTOR)) |
| 13928 |
{ |
| 13929 |
if (dest_gpr_p) |
| 13930 |
return "#"; |
| 13931 |
|
| 13932 |
else if ((dest_vmx_p && TARGET_ALTIVEC) |
| 13933 |
|| (dest_vsx_p && TARGET_VSX)) |
| 13934 |
return output_vec_const_move (operands); |
| 13935 |
} |
| 13936 |
|
| 13937 |
fatal_insn ("Bad 128-bit move", gen_rtx_SET (dest, src)); |
| 13938 |
} |
| 13939 |
|
| 13940 |
/* Validate a 128-bit move. */ |
| 13941 |
bool |
| 13942 |
rs6000_move_128bit_ok_p (rtx operands[]) |
| 13943 |
{ |
| 13944 |
machine_mode mode = GET_MODE (operands[0]); |
| 13945 |
return (gpc_reg_operand (operands[0], mode) |
| 13946 |
|| gpc_reg_operand (operands[1], mode)); |
| 13947 |
} |
| 13948 |
|
| 13949 |
/* Return true if a 128-bit move needs to be split. */ |
| 13950 |
bool |
| 13951 |
rs6000_split_128bit_ok_p (rtx operands[]) |
| 13952 |
{ |
| 13953 |
if (!reload_completed) |
| 13954 |
return false; |
| 13955 |
|
| 13956 |
if (!gpr_or_gpr_p (operands[0], operands[1])) |
| 13957 |
return false; |
| 13958 |
|
| 13959 |
if (quad_load_store_p (operands[0], operands[1])) |
| 13960 |
return false; |
| 13961 |
|
| 13962 |
return true; |
| 13963 |
} |
| 13964 |
|
| 13965 |
|
| 13966 |
/* Given a comparison operation, return the bit number in CCR to test. We |
| 13967 |
know this is a valid comparison. |
| 13968 |
|
| 13969 |
SCC_P is 1 if this is for an scc. That means that %D will have been |
| 13970 |
used instead of %C, so the bits will be in different places. |
| 13971 |
|
| 13972 |
Return -1 if OP isn't a valid comparison for some reason. */ |
| 13973 |
|
| 13974 |
int |
| 13975 |
ccr_bit (rtx op, int scc_p) |
| 13976 |
{ |
| 13977 |
enum rtx_code code = GET_CODE (op); |
| 13978 |
machine_mode cc_mode; |
| 13979 |
int cc_regnum; |
| 13980 |
int base_bit; |
| 13981 |
rtx reg; |
| 13982 |
|
| 13983 |
if (!COMPARISON_P (op)) |
| 13984 |
return -1; |
| 13985 |
|
| 13986 |
reg = XEXP (op, 0); |
| 13987 |
|
| 13988 |
if (!REG_P (reg) || !CR_REGNO_P (REGNO (reg))) |
| 13989 |
return -1; |
| 13990 |
|
| 13991 |
cc_mode = GET_MODE (reg); |
| 13992 |
cc_regnum = REGNO (reg); |
| 13993 |
base_bit = 4 * (cc_regnum - CR0_REGNO); |
| 13994 |
|
| 13995 |
validate_condition_mode (code, cc_mode); |
| 13996 |
|
| 13997 |
/* When generating a sCOND operation, only positive conditions are |
| 13998 |
allowed. */ |
| 13999 |
if (scc_p) |
| 14000 |
switch (code) |
| 14001 |
{ |
| 14002 |
case EQ: |
| 14003 |
case GT: |
| 14004 |
case LT: |
| 14005 |
case UNORDERED: |
| 14006 |
case GTU: |
| 14007 |
case LTU: |
| 14008 |
break; |
| 14009 |
default: |
| 14010 |
return -1; |
| 14011 |
} |
| 14012 |
|
| 14013 |
switch (code) |
| 14014 |
{ |
| 14015 |
case NE: |
| 14016 |
return scc_p ? base_bit + 3 : base_bit + 2; |
| 14017 |
case EQ: |
| 14018 |
return base_bit + 2; |
| 14019 |
case GT: case GTU: case UNLE: |
| 14020 |
return base_bit + 1; |
| 14021 |
case LT: case LTU: case UNGE: |
| 14022 |
return base_bit; |
| 14023 |
case ORDERED: case UNORDERED: |
| 14024 |
return base_bit + 3; |
| 14025 |
|
| 14026 |
case GE: case GEU: |
| 14027 |
/* If scc, we will have done a cror to put the bit in the |
| 14028 |
unordered position. So test that bit. For integer, this is ! LT |
| 14029 |
unless this is an scc insn. */ |
| 14030 |
return scc_p ? base_bit + 3 : base_bit; |
| 14031 |
|
| 14032 |
case LE: case LEU: |
| 14033 |
return scc_p ? base_bit + 3 : base_bit + 1; |
| 14034 |
|
| 14035 |
default: |
| 14036 |
return -1; |
| 14037 |
} |
| 14038 |
} |
| 14039 |
|
| 14040 |
/* Return the GOT register. */ |
| 14041 |
|
| 14042 |
rtx |
| 14043 |
rs6000_got_register (rtx value ATTRIBUTE_UNUSED) |
| 14044 |
{ |
| 14045 |
/* The second flow pass currently (June 1999) can't update |
| 14046 |
regs_ever_live without disturbing other parts of the compiler, so |
| 14047 |
update it here to make the prolog/epilogue code happy. */ |
| 14048 |
if (!can_create_pseudo_p () |
| 14049 |
&& !df_regs_ever_live_p (RS6000_PIC_OFFSET_TABLE_REGNUM)) |
| 14050 |
df_set_regs_ever_live (RS6000_PIC_OFFSET_TABLE_REGNUM, true); |
| 14051 |
|
| 14052 |
crtl->uses_pic_offset_table = 1; |
| 14053 |
|
| 14054 |
return pic_offset_table_rtx; |
| 14055 |
} |
| 14056 |
|
| 14057 |
#define INT_P(X) (CONST_INT_P (X) && GET_MODE (X) == VOIDmode) |
| 14058 |
|
| 14059 |
/* Write out a function code label. */ |
| 14060 |
|
| 14061 |
void |
| 14062 |
rs6000_output_function_entry (FILE *file, const char *fname) |
| 14063 |
{ |
| 14064 |
if (fname[0] != '.') |
| 14065 |
{ |
| 14066 |
switch (DEFAULT_ABI) |
| 14067 |
{ |
| 14068 |
default: |
| 14069 |
gcc_unreachable (); |
| 14070 |
|
| 14071 |
case ABI_AIX: |
| 14072 |
if (DOT_SYMBOLS) |
| 14073 |
putc ('.', file); |
| 14074 |
else |
| 14075 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "L."); |
| 14076 |
break; |
| 14077 |
|
| 14078 |
case ABI_ELFv2: |
| 14079 |
case ABI_V4: |
| 14080 |
case ABI_DARWIN: |
| 14081 |
break; |
| 14082 |
} |
| 14083 |
} |
| 14084 |
|
| 14085 |
RS6000_OUTPUT_BASENAME (file, fname); |
| 14086 |
} |
| 14087 |
|
| 14088 |
/* Print an operand. Recognize special options, documented below. */ |
| 14089 |
|
| 14090 |
#if TARGET_ELF |
| 14091 |
/* Access to .sdata2 through r2 (see -msdata=eabi in invoke.texi) is |
| 14092 |
only introduced by the linker, when applying the sda21 |
| 14093 |
relocation. */ |
| 14094 |
#define SMALL_DATA_RELOC ((rs6000_sdata == SDATA_EABI) ? "sda21" : "sdarel") |
| 14095 |
#define SMALL_DATA_REG ((rs6000_sdata == SDATA_EABI) ? 0 : 13) |
| 14096 |
#else |
| 14097 |
#define SMALL_DATA_RELOC "sda21" |
| 14098 |
#define SMALL_DATA_REG 0 |
| 14099 |
#endif |
| 14100 |
|
| 14101 |
void |
| 14102 |
print_operand (FILE *file, rtx x, int code) |
| 14103 |
{ |
| 14104 |
int i; |
| 14105 |
unsigned HOST_WIDE_INT uval; |
| 14106 |
|
| 14107 |
switch (code) |
| 14108 |
{ |
| 14109 |
/* %a is output_address. */ |
| 14110 |
|
| 14111 |
/* %c is output_addr_const if a CONSTANT_ADDRESS_P, otherwise |
| 14112 |
output_operand. */ |
| 14113 |
|
| 14114 |
case 'A': |
| 14115 |
/* Write the MMA accumulator number associated with VSX register X. */ |
| 14116 |
if (!REG_P (x) || !FP_REGNO_P (REGNO (x)) || (REGNO (x) % 4) != 0) |
| 14117 |
output_operand_lossage ("invalid %%A value"); |
| 14118 |
else |
| 14119 |
fprintf (file, "%d", (REGNO (x) - FIRST_FPR_REGNO) / 4); |
| 14120 |
return; |
| 14121 |
|
| 14122 |
case 'D': |
| 14123 |
/* Like 'J' but get to the GT bit only. */ |
| 14124 |
if (!REG_P (x) || !CR_REGNO_P (REGNO (x))) |
| 14125 |
{ |
| 14126 |
output_operand_lossage ("invalid %%D value"); |
| 14127 |
return; |
| 14128 |
} |
| 14129 |
|
| 14130 |
/* Bit 1 is GT bit. */ |
| 14131 |
i = 4 * (REGNO (x) - CR0_REGNO) + 1; |
| 14132 |
|
| 14133 |
/* Add one for shift count in rlinm for scc. */ |
| 14134 |
fprintf (file, "%d", i + 1); |
| 14135 |
return; |
| 14136 |
|
| 14137 |
case 'e': |
| 14138 |
/* If the low 16 bits are 0, but some other bit is set, write 's'. */ |
| 14139 |
if (! INT_P (x)) |
| 14140 |
{ |
| 14141 |
output_operand_lossage ("invalid %%e value"); |
| 14142 |
return; |
| 14143 |
} |
| 14144 |
|
| 14145 |
uval = INTVAL (x); |
| 14146 |
if ((uval & 0xffff) == 0 && uval != 0) |
| 14147 |
putc ('s', file); |
| 14148 |
return; |
| 14149 |
|
| 14150 |
case 'E': |
| 14151 |
/* X is a CR register. Print the number of the EQ bit of the CR */ |
| 14152 |
if (!REG_P (x) || !CR_REGNO_P (REGNO (x))) |
| 14153 |
output_operand_lossage ("invalid %%E value"); |
| 14154 |
else |
| 14155 |
fprintf (file, "%d", 4 * (REGNO (x) - CR0_REGNO) + 2); |
| 14156 |
return; |
| 14157 |
|
| 14158 |
case 'f': |
| 14159 |
/* X is a CR register. Print the shift count needed to move it |
| 14160 |
to the high-order four bits. */ |
| 14161 |
if (!REG_P (x) || !CR_REGNO_P (REGNO (x))) |
| 14162 |
output_operand_lossage ("invalid %%f value"); |
| 14163 |
else |
| 14164 |
fprintf (file, "%d", 4 * (REGNO (x) - CR0_REGNO)); |
| 14165 |
return; |
| 14166 |
|
| 14167 |
case 'F': |
| 14168 |
/* Similar, but print the count for the rotate in the opposite |
| 14169 |
direction. */ |
| 14170 |
if (!REG_P (x) || !CR_REGNO_P (REGNO (x))) |
| 14171 |
output_operand_lossage ("invalid %%F value"); |
| 14172 |
else |
| 14173 |
fprintf (file, "%d", 32 - 4 * (REGNO (x) - CR0_REGNO)); |
| 14174 |
return; |
| 14175 |
|
| 14176 |
case 'G': |
| 14177 |
/* X is a constant integer. If it is negative, print "m", |
| 14178 |
otherwise print "z". This is to make an aze or ame insn. */ |
| 14179 |
if (!CONST_INT_P (x)) |
| 14180 |
output_operand_lossage ("invalid %%G value"); |
| 14181 |
else if (INTVAL (x) >= 0) |
| 14182 |
putc ('z', file); |
| 14183 |
else |
| 14184 |
putc ('m', file); |
| 14185 |
return; |
| 14186 |
|
| 14187 |
case 'h': |
| 14188 |
/* If constant, output low-order five bits. Otherwise, write |
| 14189 |
normally. */ |
| 14190 |
if (INT_P (x)) |
| 14191 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) & 31); |
| 14192 |
else |
| 14193 |
print_operand (file, x, 0); |
| 14194 |
return; |
| 14195 |
|
| 14196 |
case 'H': |
| 14197 |
/* If constant, output low-order six bits. Otherwise, write |
| 14198 |
normally. */ |
| 14199 |
if (INT_P (x)) |
| 14200 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) & 63); |
| 14201 |
else |
| 14202 |
print_operand (file, x, 0); |
| 14203 |
return; |
| 14204 |
|
| 14205 |
case 'I': |
| 14206 |
/* Print `i' if this is a constant, else nothing. */ |
| 14207 |
if (INT_P (x)) |
| 14208 |
putc ('i', file); |
| 14209 |
return; |
| 14210 |
|
| 14211 |
case 'j': |
| 14212 |
/* Write the bit number in CCR for jump. */ |
| 14213 |
i = ccr_bit (x, 0); |
| 14214 |
if (i == -1) |
| 14215 |
output_operand_lossage ("invalid %%j code"); |
| 14216 |
else |
| 14217 |
fprintf (file, "%d", i); |
| 14218 |
return; |
| 14219 |
|
| 14220 |
case 'J': |
| 14221 |
/* Similar, but add one for shift count in rlinm for scc and pass |
| 14222 |
scc flag to `ccr_bit'. */ |
| 14223 |
i = ccr_bit (x, 1); |
| 14224 |
if (i == -1) |
| 14225 |
output_operand_lossage ("invalid %%J code"); |
| 14226 |
else |
| 14227 |
/* If we want bit 31, write a shift count of zero, not 32. */ |
| 14228 |
fprintf (file, "%d", i == 31 ? 0 : i + 1); |
| 14229 |
return; |
| 14230 |
|
| 14231 |
case 'k': |
| 14232 |
/* X must be a constant. Write the 1's complement of the |
| 14233 |
constant. */ |
| 14234 |
if (! INT_P (x)) |
| 14235 |
output_operand_lossage ("invalid %%k value"); |
| 14236 |
else |
| 14237 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC, ~ INTVAL (x)); |
| 14238 |
return; |
| 14239 |
|
| 14240 |
case 'K': |
| 14241 |
/* X must be a symbolic constant on ELF. Write an |
| 14242 |
expression suitable for an 'addi' that adds in the low 16 |
| 14243 |
bits of the MEM. */ |
| 14244 |
if (GET_CODE (x) == CONST) |
| 14245 |
{ |
| 14246 |
if (GET_CODE (XEXP (x, 0)) != PLUS |
| 14247 |
|| (!SYMBOL_REF_P (XEXP (XEXP (x, 0), 0)) |
| 14248 |
&& GET_CODE (XEXP (XEXP (x, 0), 0)) != LABEL_REF) |
| 14249 |
|| !CONST_INT_P (XEXP (XEXP (x, 0), 1))) |
| 14250 |
output_operand_lossage ("invalid %%K value"); |
| 14251 |
} |
| 14252 |
print_operand_address (file, x); |
| 14253 |
fputs ("@l", file); |
| 14254 |
return; |
| 14255 |
|
| 14256 |
/* %l is output_asm_label. */ |
| 14257 |
|
| 14258 |
case 'L': |
| 14259 |
/* Write second word of DImode or DFmode reference. Works on register |
| 14260 |
or non-indexed memory only. */ |
| 14261 |
if (REG_P (x)) |
| 14262 |
fputs (reg_names[REGNO (x) + 1], file); |
| 14263 |
else if (MEM_P (x)) |
| 14264 |
{ |
| 14265 |
machine_mode mode = GET_MODE (x); |
| 14266 |
/* Handle possible auto-increment. Since it is pre-increment and |
| 14267 |
we have already done it, we can just use an offset of word. */ |
| 14268 |
if (GET_CODE (XEXP (x, 0)) == PRE_INC |
| 14269 |
|| GET_CODE (XEXP (x, 0)) == PRE_DEC) |
| 14270 |
output_address (mode, plus_constant (Pmode, XEXP (XEXP (x, 0), 0), |
| 14271 |
UNITS_PER_WORD)); |
| 14272 |
else if (GET_CODE (XEXP (x, 0)) == PRE_MODIFY) |
| 14273 |
output_address (mode, plus_constant (Pmode, XEXP (XEXP (x, 0), 0), |
| 14274 |
UNITS_PER_WORD)); |
| 14275 |
else |
| 14276 |
output_address (mode, XEXP (adjust_address_nv (x, SImode, |
| 14277 |
UNITS_PER_WORD), |
| 14278 |
0)); |
| 14279 |
|
| 14280 |
if (small_data_operand (x, GET_MODE (x))) |
| 14281 |
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC, |
| 14282 |
reg_names[SMALL_DATA_REG]); |
| 14283 |
} |
| 14284 |
return; |
| 14285 |
|
| 14286 |
case 'N': /* Unused */ |
| 14287 |
/* Write the number of elements in the vector times 4. */ |
| 14288 |
if (GET_CODE (x) != PARALLEL) |
| 14289 |
output_operand_lossage ("invalid %%N value"); |
| 14290 |
else |
| 14291 |
fprintf (file, "%d", XVECLEN (x, 0) * 4); |
| 14292 |
return; |
| 14293 |
|
| 14294 |
case 'O': /* Unused */ |
| 14295 |
/* Similar, but subtract 1 first. */ |
| 14296 |
if (GET_CODE (x) != PARALLEL) |
| 14297 |
output_operand_lossage ("invalid %%O value"); |
| 14298 |
else |
| 14299 |
fprintf (file, "%d", (XVECLEN (x, 0) - 1) * 4); |
| 14300 |
return; |
| 14301 |
|
| 14302 |
case 'p': |
| 14303 |
/* X is a CONST_INT that is a power of two. Output the logarithm. */ |
| 14304 |
if (! INT_P (x) |
| 14305 |
|| INTVAL (x) < 0 |
| 14306 |
|| (i = exact_log2 (INTVAL (x))) < 0) |
| 14307 |
output_operand_lossage ("invalid %%p value"); |
| 14308 |
else |
| 14309 |
fprintf (file, "%d", i); |
| 14310 |
return; |
| 14311 |
|
| 14312 |
case 'P': |
| 14313 |
/* The operand must be an indirect memory reference. The result |
| 14314 |
is the register name. */ |
| 14315 |
if (!MEM_P (x) || !REG_P (XEXP (x, 0)) |
| 14316 |
|| REGNO (XEXP (x, 0)) >= 32) |
| 14317 |
output_operand_lossage ("invalid %%P value"); |
| 14318 |
else |
| 14319 |
fputs (reg_names[REGNO (XEXP (x, 0))], file); |
| 14320 |
return; |
| 14321 |
|
| 14322 |
case 'q': |
| 14323 |
/* This outputs the logical code corresponding to a boolean |
| 14324 |
expression. The expression may have one or both operands |
| 14325 |
negated (if one, only the first one). For condition register |
| 14326 |
logical operations, it will also treat the negated |
| 14327 |
CR codes as NOTs, but not handle NOTs of them. */ |
| 14328 |
{ |
| 14329 |
const char *const *t = 0; |
| 14330 |
const char *s; |
| 14331 |
enum rtx_code code = GET_CODE (x); |
| 14332 |
static const char * const tbl[3][3] = { |
| 14333 |
{ "and", "andc", "nor" }, |
| 14334 |
{ "or", "orc", "nand" }, |
| 14335 |
{ "xor", "eqv", "xor" } }; |
| 14336 |
|
| 14337 |
if (code == AND) |
| 14338 |
t = tbl[0]; |
| 14339 |
else if (code == IOR) |
| 14340 |
t = tbl[1]; |
| 14341 |
else if (code == XOR) |
| 14342 |
t = tbl[2]; |
| 14343 |
else |
| 14344 |
output_operand_lossage ("invalid %%q value"); |
| 14345 |
|
| 14346 |
if (GET_CODE (XEXP (x, 0)) != NOT) |
| 14347 |
s = t[0]; |
| 14348 |
else |
| 14349 |
{ |
| 14350 |
if (GET_CODE (XEXP (x, 1)) == NOT) |
| 14351 |
s = t[2]; |
| 14352 |
else |
| 14353 |
s = t[1]; |
| 14354 |
} |
| 14355 |
|
| 14356 |
fputs (s, file); |
| 14357 |
} |
| 14358 |
return; |
| 14359 |
|
| 14360 |
case 'Q': |
| 14361 |
if (! TARGET_MFCRF) |
| 14362 |
return; |
| 14363 |
fputc (',', file); |
| 14364 |
/* FALLTHRU */ |
| 14365 |
|
| 14366 |
case 'R': |
| 14367 |
/* X is a CR register. Print the mask for `mtcrf'. */ |
| 14368 |
if (!REG_P (x) || !CR_REGNO_P (REGNO (x))) |
| 14369 |
output_operand_lossage ("invalid %%R value"); |
| 14370 |
else |
| 14371 |
fprintf (file, "%d", 128 >> (REGNO (x) - CR0_REGNO)); |
| 14372 |
return; |
| 14373 |
|
| 14374 |
case 's': |
| 14375 |
/* Low 5 bits of 32 - value */ |
| 14376 |
if (! INT_P (x)) |
| 14377 |
output_operand_lossage ("invalid %%s value"); |
| 14378 |
else |
| 14379 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC, (32 - INTVAL (x)) & 31); |
| 14380 |
return; |
| 14381 |
|
| 14382 |
case 't': |
| 14383 |
/* Like 'J' but get to the OVERFLOW/UNORDERED bit. */ |
| 14384 |
if (!REG_P (x) || !CR_REGNO_P (REGNO (x))) |
| 14385 |
{ |
| 14386 |
output_operand_lossage ("invalid %%t value"); |
| 14387 |
return; |
| 14388 |
} |
| 14389 |
|
| 14390 |
/* Bit 3 is OV bit. */ |
| 14391 |
i = 4 * (REGNO (x) - CR0_REGNO) + 3; |
| 14392 |
|
| 14393 |
/* If we want bit 31, write a shift count of zero, not 32. */ |
| 14394 |
fprintf (file, "%d", i == 31 ? 0 : i + 1); |
| 14395 |
return; |
| 14396 |
|
| 14397 |
case 'T': |
| 14398 |
/* Print the symbolic name of a branch target register. */ |
| 14399 |
if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_PLTSEQ) |
| 14400 |
x = XVECEXP (x, 0, 0); |
| 14401 |
if (!REG_P (x) || (REGNO (x) != LR_REGNO |
| 14402 |
&& REGNO (x) != CTR_REGNO)) |
| 14403 |
output_operand_lossage ("invalid %%T value"); |
| 14404 |
else if (REGNO (x) == LR_REGNO) |
| 14405 |
fputs ("lr", file); |
| 14406 |
else |
| 14407 |
fputs ("ctr", file); |
| 14408 |
return; |
| 14409 |
|
| 14410 |
case 'u': |
| 14411 |
/* High-order or low-order 16 bits of constant, whichever is non-zero, |
| 14412 |
for use in unsigned operand. */ |
| 14413 |
if (! INT_P (x)) |
| 14414 |
{ |
| 14415 |
output_operand_lossage ("invalid %%u value"); |
| 14416 |
return; |
| 14417 |
} |
| 14418 |
|
| 14419 |
uval = INTVAL (x); |
| 14420 |
if ((uval & 0xffff) == 0) |
| 14421 |
uval >>= 16; |
| 14422 |
|
| 14423 |
fprintf (file, HOST_WIDE_INT_PRINT_HEX, uval & 0xffff); |
| 14424 |
return; |
| 14425 |
|
| 14426 |
case 'v': |
| 14427 |
/* High-order 16 bits of constant for use in signed operand. */ |
| 14428 |
if (! INT_P (x)) |
| 14429 |
output_operand_lossage ("invalid %%v value"); |
| 14430 |
else |
| 14431 |
fprintf (file, HOST_WIDE_INT_PRINT_HEX, |
| 14432 |
(INTVAL (x) >> 16) & 0xffff); |
| 14433 |
return; |
| 14434 |
|
| 14435 |
case 'U': |
| 14436 |
/* Print `u' if this has an auto-increment or auto-decrement. */ |
| 14437 |
if (MEM_P (x) |
| 14438 |
&& (GET_CODE (XEXP (x, 0)) == PRE_INC |
| 14439 |
|| GET_CODE (XEXP (x, 0)) == PRE_DEC |
| 14440 |
|| GET_CODE (XEXP (x, 0)) == PRE_MODIFY)) |
| 14441 |
putc ('u', file); |
| 14442 |
return; |
| 14443 |
|
| 14444 |
case 'V': |
| 14445 |
/* Print the trap code for this operand. */ |
| 14446 |
switch (GET_CODE (x)) |
| 14447 |
{ |
| 14448 |
case EQ: |
| 14449 |
fputs ("eq", file); /* 4 */ |
| 14450 |
break; |
| 14451 |
case NE: |
| 14452 |
fputs ("ne", file); /* 24 */ |
| 14453 |
break; |
| 14454 |
case LT: |
| 14455 |
fputs ("lt", file); /* 16 */ |
| 14456 |
break; |
| 14457 |
case LE: |
| 14458 |
fputs ("le", file); /* 20 */ |
| 14459 |
break; |
| 14460 |
case GT: |
| 14461 |
fputs ("gt", file); /* 8 */ |
| 14462 |
break; |
| 14463 |
case GE: |
| 14464 |
fputs ("ge", file); /* 12 */ |
| 14465 |
break; |
| 14466 |
case LTU: |
| 14467 |
fputs ("llt", file); /* 2 */ |
| 14468 |
break; |
| 14469 |
case LEU: |
| 14470 |
fputs ("lle", file); /* 6 */ |
| 14471 |
break; |
| 14472 |
case GTU: |
| 14473 |
fputs ("lgt", file); /* 1 */ |
| 14474 |
break; |
| 14475 |
case GEU: |
| 14476 |
fputs ("lge", file); /* 5 */ |
| 14477 |
break; |
| 14478 |
default: |
| 14479 |
output_operand_lossage ("invalid %%V value"); |
| 14480 |
} |
| 14481 |
break; |
| 14482 |
|
| 14483 |
case 'w': |
| 14484 |
/* If constant, low-order 16 bits of constant, signed. Otherwise, write |
| 14485 |
normally. */ |
| 14486 |
if (INT_P (x)) |
| 14487 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC, sext_hwi (INTVAL (x), 16)); |
| 14488 |
else |
| 14489 |
print_operand (file, x, 0); |
| 14490 |
return; |
| 14491 |
|
| 14492 |
case 'x': |
| 14493 |
/* X is a FPR or Altivec register used in a VSX context. */ |
| 14494 |
if (!REG_P (x) || !VSX_REGNO_P (REGNO (x))) |
| 14495 |
output_operand_lossage ("invalid %%x value"); |
| 14496 |
else |
| 14497 |
{ |
| 14498 |
int reg = REGNO (x); |
| 14499 |
int vsx_reg = (FP_REGNO_P (reg) |
| 14500 |
? reg - 32 |
| 14501 |
: reg - FIRST_ALTIVEC_REGNO + 32); |
| 14502 |
|
| 14503 |
#ifdef TARGET_REGNAMES |
| 14504 |
if (TARGET_REGNAMES) |
| 14505 |
fprintf (file, "%%vs%d", vsx_reg); |
| 14506 |
else |
| 14507 |
#endif |
| 14508 |
fprintf (file, "%d", vsx_reg); |
| 14509 |
} |
| 14510 |
return; |
| 14511 |
|
| 14512 |
case 'X': |
| 14513 |
if (MEM_P (x) |
| 14514 |
&& (legitimate_indexed_address_p (XEXP (x, 0), 0) |
| 14515 |
|| (GET_CODE (XEXP (x, 0)) == PRE_MODIFY |
| 14516 |
&& legitimate_indexed_address_p (XEXP (XEXP (x, 0), 1), 0)))) |
| 14517 |
putc ('x', file); |
| 14518 |
return; |
| 14519 |
|
| 14520 |
case 'Y': |
| 14521 |
/* Like 'L', for third word of TImode/PTImode */ |
| 14522 |
if (REG_P (x)) |
| 14523 |
fputs (reg_names[REGNO (x) + 2], file); |
| 14524 |
else if (MEM_P (x)) |
| 14525 |
{ |
| 14526 |
machine_mode mode = GET_MODE (x); |
| 14527 |
if (GET_CODE (XEXP (x, 0)) == PRE_INC |
| 14528 |
|| GET_CODE (XEXP (x, 0)) == PRE_DEC) |
| 14529 |
output_address (mode, plus_constant (Pmode, |
| 14530 |
XEXP (XEXP (x, 0), 0), 8)); |
| 14531 |
else if (GET_CODE (XEXP (x, 0)) == PRE_MODIFY) |
| 14532 |
output_address (mode, plus_constant (Pmode, |
| 14533 |
XEXP (XEXP (x, 0), 0), 8)); |
| 14534 |
else |
| 14535 |
output_address (mode, XEXP (adjust_address_nv (x, SImode, 8), 0)); |
| 14536 |
if (small_data_operand (x, GET_MODE (x))) |
| 14537 |
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC, |
| 14538 |
reg_names[SMALL_DATA_REG]); |
| 14539 |
} |
| 14540 |
return; |
| 14541 |
|
| 14542 |
case 'z': |
| 14543 |
if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_PLTSEQ) |
| 14544 |
x = XVECEXP (x, 0, 1); |
| 14545 |
/* X is a SYMBOL_REF. Write out the name preceded by a |
| 14546 |
period and without any trailing data in brackets. Used for function |
| 14547 |
names. If we are configured for System V (or the embedded ABI) on |
| 14548 |
the PowerPC, do not emit the period, since those systems do not use |
| 14549 |
TOCs and the like. */ |
| 14550 |
if (!SYMBOL_REF_P (x)) |
| 14551 |
{ |
| 14552 |
output_operand_lossage ("invalid %%z value"); |
| 14553 |
return; |
| 14554 |
} |
| 14555 |
|
| 14556 |
/* For macho, check to see if we need a stub. */ |
| 14557 |
if (TARGET_MACHO) |
| 14558 |
{ |
| 14559 |
const char *name = XSTR (x, 0); |
| 14560 |
#if TARGET_MACHO |
| 14561 |
if (darwin_symbol_stubs |
| 14562 |
&& MACHOPIC_INDIRECT |
| 14563 |
&& machopic_classify_symbol (x) == MACHOPIC_UNDEFINED_FUNCTION) |
| 14564 |
name = machopic_indirection_name (x, /*stub_p=*/true); |
| 14565 |
#endif |
| 14566 |
assemble_name (file, name); |
| 14567 |
} |
| 14568 |
else if (!DOT_SYMBOLS) |
| 14569 |
assemble_name (file, XSTR (x, 0)); |
| 14570 |
else |
| 14571 |
rs6000_output_function_entry (file, XSTR (x, 0)); |
| 14572 |
return; |
| 14573 |
|
| 14574 |
case 'Z': |
| 14575 |
/* Like 'L', for last word of TImode/PTImode. */ |
| 14576 |
if (REG_P (x)) |
| 14577 |
fputs (reg_names[REGNO (x) + 3], file); |
| 14578 |
else if (MEM_P (x)) |
| 14579 |
{ |
| 14580 |
machine_mode mode = GET_MODE (x); |
| 14581 |
if (GET_CODE (XEXP (x, 0)) == PRE_INC |
| 14582 |
|| GET_CODE (XEXP (x, 0)) == PRE_DEC) |
| 14583 |
output_address (mode, plus_constant (Pmode, |
| 14584 |
XEXP (XEXP (x, 0), 0), 12)); |
| 14585 |
else if (GET_CODE (XEXP (x, 0)) == PRE_MODIFY) |
| 14586 |
output_address (mode, plus_constant (Pmode, |
| 14587 |
XEXP (XEXP (x, 0), 0), 12)); |
| 14588 |
else |
| 14589 |
output_address (mode, XEXP (adjust_address_nv (x, SImode, 12), 0)); |
| 14590 |
if (small_data_operand (x, GET_MODE (x))) |
| 14591 |
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC, |
| 14592 |
reg_names[SMALL_DATA_REG]); |
| 14593 |
} |
| 14594 |
return; |
| 14595 |
|
| 14596 |
/* Print AltiVec memory operand. */ |
| 14597 |
case 'y': |
| 14598 |
{ |
| 14599 |
rtx tmp; |
| 14600 |
|
| 14601 |
gcc_assert (MEM_P (x)); |
| 14602 |
|
| 14603 |
tmp = XEXP (x, 0); |
| 14604 |
|
| 14605 |
if (VECTOR_MEM_ALTIVEC_OR_VSX_P (GET_MODE (x)) |
| 14606 |
&& GET_CODE (tmp) == AND |
| 14607 |
&& CONST_INT_P (XEXP (tmp, 1)) |
| 14608 |
&& INTVAL (XEXP (tmp, 1)) == -16) |
| 14609 |
tmp = XEXP (tmp, 0); |
| 14610 |
else if (VECTOR_MEM_VSX_P (GET_MODE (x)) |
| 14611 |
&& GET_CODE (tmp) == PRE_MODIFY) |
| 14612 |
tmp = XEXP (tmp, 1); |
| 14613 |
if (REG_P (tmp)) |
| 14614 |
fprintf (file, "0,%s", reg_names[REGNO (tmp)]); |
| 14615 |
else |
| 14616 |
{ |
| 14617 |
if (GET_CODE (tmp) != PLUS |
| 14618 |
|| !REG_P (XEXP (tmp, 0)) |
| 14619 |
|| !REG_P (XEXP (tmp, 1))) |
| 14620 |
{ |
| 14621 |
output_operand_lossage ("invalid %%y value, try using the 'Z' constraint"); |
| 14622 |
break; |
| 14623 |
} |
| 14624 |
|
| 14625 |
if (REGNO (XEXP (tmp, 0)) == 0) |
| 14626 |
fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (tmp, 1)) ], |
| 14627 |
reg_names[ REGNO (XEXP (tmp, 0)) ]); |
| 14628 |
else |
| 14629 |
fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (tmp, 0)) ], |
| 14630 |
reg_names[ REGNO (XEXP (tmp, 1)) ]); |
| 14631 |
} |
| 14632 |
break; |
| 14633 |
} |
| 14634 |
|
| 14635 |
case 0: |
| 14636 |
if (REG_P (x)) |
| 14637 |
fprintf (file, "%s", reg_names[REGNO (x)]); |
| 14638 |
else if (MEM_P (x)) |
| 14639 |
{ |
| 14640 |
/* We need to handle PRE_INC and PRE_DEC here, since we need to |
| 14641 |
know the width from the mode. */ |
| 14642 |
if (GET_CODE (XEXP (x, 0)) == PRE_INC) |
| 14643 |
fprintf (file, "%d(%s)", GET_MODE_SIZE (GET_MODE (x)), |
| 14644 |
reg_names[REGNO (XEXP (XEXP (x, 0), 0))]); |
| 14645 |
else if (GET_CODE (XEXP (x, 0)) == PRE_DEC) |
| 14646 |
fprintf (file, "%d(%s)", - GET_MODE_SIZE (GET_MODE (x)), |
| 14647 |
reg_names[REGNO (XEXP (XEXP (x, 0), 0))]); |
| 14648 |
else if (GET_CODE (XEXP (x, 0)) == PRE_MODIFY) |
| 14649 |
output_address (GET_MODE (x), XEXP (XEXP (x, 0), 1)); |
| 14650 |
else |
| 14651 |
output_address (GET_MODE (x), XEXP (x, 0)); |
| 14652 |
} |
| 14653 |
else if (toc_relative_expr_p (x, false, |
| 14654 |
&tocrel_base_oac, &tocrel_offset_oac)) |
| 14655 |
/* This hack along with a corresponding hack in |
| 14656 |
rs6000_output_addr_const_extra arranges to output addends |
| 14657 |
where the assembler expects to find them. eg. |
| 14658 |
(plus (unspec [(symbol_ref ("x")) (reg 2)] tocrel) 4) |
| 14659 |
without this hack would be output as "x@toc+4". We |
| 14660 |
want "x+4@toc". */ |
| 14661 |
output_addr_const (file, CONST_CAST_RTX (tocrel_base_oac)); |
| 14662 |
else if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TLSGD) |
| 14663 |
output_addr_const (file, XVECEXP (x, 0, 0)); |
| 14664 |
else if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_PLTSEQ) |
| 14665 |
output_addr_const (file, XVECEXP (x, 0, 1)); |
| 14666 |
else |
| 14667 |
output_addr_const (file, x); |
| 14668 |
return; |
| 14669 |
|
| 14670 |
case '&': |
| 14671 |
if (const char *name = get_some_local_dynamic_name ()) |
| 14672 |
assemble_name (file, name); |
| 14673 |
else |
| 14674 |
output_operand_lossage ("'%%&' used without any " |
| 14675 |
"local dynamic TLS references"); |
| 14676 |
return; |
| 14677 |
|
| 14678 |
default: |
| 14679 |
output_operand_lossage ("invalid %%xn code"); |
| 14680 |
} |
| 14681 |
} |
| 14682 |
|
| 14683 |
/* Print the address of an operand. */ |
| 14684 |
|
| 14685 |
void |
| 14686 |
print_operand_address (FILE *file, rtx x) |
| 14687 |
{ |
| 14688 |
if (REG_P (x)) |
| 14689 |
fprintf (file, "0(%s)", reg_names[ REGNO (x) ]); |
| 14690 |
|
| 14691 |
/* Is it a PC-relative address? */ |
| 14692 |
else if (TARGET_PCREL && pcrel_local_or_external_address (x, VOIDmode)) |
| 14693 |
{ |
| 14694 |
HOST_WIDE_INT offset; |
| 14695 |
|
| 14696 |
if (GET_CODE (x) == CONST) |
| 14697 |
x = XEXP (x, 0); |
| 14698 |
|
| 14699 |
if (GET_CODE (x) == PLUS) |
| 14700 |
{ |
| 14701 |
offset = INTVAL (XEXP (x, 1)); |
| 14702 |
x = XEXP (x, 0); |
| 14703 |
} |
| 14704 |
else |
| 14705 |
offset = 0; |
| 14706 |
|
| 14707 |
output_addr_const (file, x); |
| 14708 |
|
| 14709 |
if (offset) |
| 14710 |
fprintf (file, "%+" PRId64, offset); |
| 14711 |
|
| 14712 |
if (SYMBOL_REF_P (x) && !SYMBOL_REF_LOCAL_P (x)) |
| 14713 |
fprintf (file, "@got"); |
| 14714 |
|
| 14715 |
fprintf (file, "@pcrel"); |
| 14716 |
} |
| 14717 |
else if (SYMBOL_REF_P (x) || GET_CODE (x) == CONST |
| 14718 |
|| GET_CODE (x) == LABEL_REF) |
| 14719 |
{ |
| 14720 |
output_addr_const (file, x); |
| 14721 |
if (small_data_operand (x, GET_MODE (x))) |
| 14722 |
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC, |
| 14723 |
reg_names[SMALL_DATA_REG]); |
| 14724 |
else |
| 14725 |
{ |
| 14726 |
/* Do not support getting address directly from TOC, emit error. |
| 14727 |
No more work is needed for !TARGET_TOC. */ |
| 14728 |
if (TARGET_TOC) |
| 14729 |
output_operand_lossage ("%%a requires an address of memory"); |
| 14730 |
} |
| 14731 |
} |
| 14732 |
else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0)) |
| 14733 |
&& REG_P (XEXP (x, 1))) |
| 14734 |
{ |
| 14735 |
if (REGNO (XEXP (x, 0)) == 0) |
| 14736 |
fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (x, 1)) ], |
| 14737 |
reg_names[ REGNO (XEXP (x, 0)) ]); |
| 14738 |
else |
| 14739 |
fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (x, 0)) ], |
| 14740 |
reg_names[ REGNO (XEXP (x, 1)) ]); |
| 14741 |
} |
| 14742 |
else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0)) |
| 14743 |
&& CONST_INT_P (XEXP (x, 1))) |
| 14744 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC "(%s)", |
| 14745 |
INTVAL (XEXP (x, 1)), reg_names[ REGNO (XEXP (x, 0)) ]); |
| 14746 |
#if TARGET_MACHO |
| 14747 |
else if (GET_CODE (x) == LO_SUM && REG_P (XEXP (x, 0)) |
| 14748 |
&& CONSTANT_P (XEXP (x, 1))) |
| 14749 |
{ |
| 14750 |
fprintf (file, "lo16("); |
| 14751 |
output_addr_const (file, XEXP (x, 1)); |
| 14752 |
fprintf (file, ")(%s)", reg_names[ REGNO (XEXP (x, 0)) ]); |
| 14753 |
} |
| 14754 |
#endif |
| 14755 |
#if TARGET_ELF |
| 14756 |
else if (GET_CODE (x) == LO_SUM && REG_P (XEXP (x, 0)) |
| 14757 |
&& CONSTANT_P (XEXP (x, 1))) |
| 14758 |
{ |
| 14759 |
output_addr_const (file, XEXP (x, 1)); |
| 14760 |
fprintf (file, "@l(%s)", reg_names[ REGNO (XEXP (x, 0)) ]); |
| 14761 |
} |
| 14762 |
#endif |
| 14763 |
else if (toc_relative_expr_p (x, false, &tocrel_base_oac, &tocrel_offset_oac)) |
| 14764 |
{ |
| 14765 |
/* This hack along with a corresponding hack in |
| 14766 |
rs6000_output_addr_const_extra arranges to output addends |
| 14767 |
where the assembler expects to find them. eg. |
| 14768 |
(lo_sum (reg 9) |
| 14769 |
. (plus (unspec [(symbol_ref ("x")) (reg 2)] tocrel) 8)) |
| 14770 |
without this hack would be output as "x@toc+8@l(9)". We |
| 14771 |
want "x+8@toc@l(9)". */ |
| 14772 |
output_addr_const (file, CONST_CAST_RTX (tocrel_base_oac)); |
| 14773 |
if (GET_CODE (x) == LO_SUM) |
| 14774 |
fprintf (file, "@l(%s)", reg_names[REGNO (XEXP (x, 0))]); |
| 14775 |
else |
| 14776 |
fprintf (file, "(%s)", reg_names[REGNO (XVECEXP (tocrel_base_oac, 0, 1))]); |
| 14777 |
} |
| 14778 |
else |
| 14779 |
output_addr_const (file, x); |
| 14780 |
} |
| 14781 |
|
| 14782 |
/* Implement TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */ |
| 14783 |
|
| 14784 |
bool |
| 14785 |
rs6000_output_addr_const_extra (FILE *file, rtx x) |
| 14786 |
{ |
| 14787 |
if (GET_CODE (x) == UNSPEC) |
| 14788 |
switch (XINT (x, 1)) |
| 14789 |
{ |
| 14790 |
case UNSPEC_TOCREL: |
| 14791 |
gcc_checking_assert (SYMBOL_REF_P (XVECEXP (x, 0, 0)) |
| 14792 |
&& REG_P (XVECEXP (x, 0, 1)) |
| 14793 |
&& REGNO (XVECEXP (x, 0, 1)) == TOC_REGISTER); |
| 14794 |
output_addr_const (file, XVECEXP (x, 0, 0)); |
| 14795 |
if (x == tocrel_base_oac && tocrel_offset_oac != const0_rtx) |
| 14796 |
{ |
| 14797 |
if (INTVAL (tocrel_offset_oac) >= 0) |
| 14798 |
fprintf (file, "+"); |
| 14799 |
output_addr_const (file, CONST_CAST_RTX (tocrel_offset_oac)); |
| 14800 |
} |
| 14801 |
if (!TARGET_AIX || (TARGET_ELF && TARGET_MINIMAL_TOC)) |
| 14802 |
{ |
| 14803 |
putc ('-', file); |
| 14804 |
assemble_name (file, toc_label_name); |
| 14805 |
need_toc_init = 1; |
| 14806 |
} |
| 14807 |
else if (TARGET_ELF) |
| 14808 |
fputs ("@toc", file); |
| 14809 |
return true; |
| 14810 |
|
| 14811 |
#if TARGET_MACHO |
| 14812 |
case UNSPEC_MACHOPIC_OFFSET: |
| 14813 |
output_addr_const (file, XVECEXP (x, 0, 0)); |
| 14814 |
putc ('-', file); |
| 14815 |
machopic_output_function_base_name (file); |
| 14816 |
return true; |
| 14817 |
#endif |
| 14818 |
} |
| 14819 |
return false; |
| 14820 |
} |
| 14821 |
|
| 14822 |
/* Target hook for assembling integer objects. The PowerPC version has |
| 14823 |
to handle fixup entries for relocatable code if RELOCATABLE_NEEDS_FIXUP |
| 14824 |
is defined. It also needs to handle DI-mode objects on 64-bit |
| 14825 |
targets. */ |
| 14826 |
|
| 14827 |
static bool |
| 14828 |
rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p) |
| 14829 |
{ |
| 14830 |
#ifdef RELOCATABLE_NEEDS_FIXUP |
| 14831 |
/* Special handling for SI values. */ |
| 14832 |
if (RELOCATABLE_NEEDS_FIXUP && size == 4 && aligned_p) |
| 14833 |
{ |
| 14834 |
static int recurse = 0; |
| 14835 |
|
| 14836 |
/* For -mrelocatable, we mark all addresses that need to be fixed up in |
| 14837 |
the .fixup section. Since the TOC section is already relocated, we |
| 14838 |
don't need to mark it here. We used to skip the text section, but it |
| 14839 |
should never be valid for relocated addresses to be placed in the text |
| 14840 |
section. */ |
| 14841 |
if (DEFAULT_ABI == ABI_V4 |
| 14842 |
&& (TARGET_RELOCATABLE || flag_pic > 1) |
| 14843 |
&& in_section != toc_section |
| 14844 |
&& !recurse |
| 14845 |
&& !CONST_SCALAR_INT_P (x) |
| 14846 |
&& CONSTANT_P (x)) |
| 14847 |
{ |
| 14848 |
char buf[256]; |
| 14849 |
|
| 14850 |
recurse = 1; |
| 14851 |
ASM_GENERATE_INTERNAL_LABEL (buf, "LCP", fixuplabelno); |
| 14852 |
fixuplabelno++; |
| 14853 |
ASM_OUTPUT_LABEL (asm_out_file, buf); |
| 14854 |
fprintf (asm_out_file, "\t.long\t("); |
| 14855 |
output_addr_const (asm_out_file, x); |
| 14856 |
fprintf (asm_out_file, ")@fixup\n"); |
| 14857 |
fprintf (asm_out_file, "\t.section\t\".fixup\",\"aw\"\n"); |
| 14858 |
ASM_OUTPUT_ALIGN (asm_out_file, 2); |
| 14859 |
fprintf (asm_out_file, "\t.long\t"); |
| 14860 |
assemble_name (asm_out_file, buf); |
| 14861 |
fprintf (asm_out_file, "\n\t.previous\n"); |
| 14862 |
recurse = 0; |
| 14863 |
return true; |
| 14864 |
} |
| 14865 |
/* Remove initial .'s to turn a -mcall-aixdesc function |
| 14866 |
address into the address of the descriptor, not the function |
| 14867 |
itself. */ |
| 14868 |
else if (SYMBOL_REF_P (x) |
| 14869 |
&& XSTR (x, 0)[0] == '.' |
| 14870 |
&& DEFAULT_ABI == ABI_AIX) |
| 14871 |
{ |
| 14872 |
const char *name = XSTR (x, 0); |
| 14873 |
while (*name == '.') |
| 14874 |
name++; |
| 14875 |
|
| 14876 |
fprintf (asm_out_file, "\t.long\t%s\n", name); |
| 14877 |
return true; |
| 14878 |
} |
| 14879 |
} |
| 14880 |
#endif /* RELOCATABLE_NEEDS_FIXUP */ |
| 14881 |
return default_assemble_integer (x, size, aligned_p); |
| 14882 |
} |
| 14883 |
|
| 14884 |
/* Return a template string for assembly to emit when making an |
| 14885 |
external call. FUNOP is the call mem argument operand number. */ |
| 14886 |
|
| 14887 |
static const char * |
| 14888 |
rs6000_call_template_1 (rtx *operands, unsigned int funop, bool sibcall) |
| 14889 |
{ |
| 14890 |
/* -Wformat-overflow workaround, without which gcc thinks that %u |
| 14891 |
might produce 10 digits. */ |
| 14892 |
gcc_assert (funop <= MAX_RECOG_OPERANDS); |
| 14893 |
|
| 14894 |
char arg[12]; |
| 14895 |
arg[0] = 0; |
| 14896 |
if (GET_CODE (operands[funop + 1]) == UNSPEC) |
| 14897 |
{ |
| 14898 |
if (XINT (operands[funop + 1], 1) == UNSPEC_TLSGD) |
| 14899 |
sprintf (arg, "(%%%u@tlsgd)", funop + 1); |
| 14900 |
else if (XINT (operands[funop + 1], 1) == UNSPEC_TLSLD) |
| 14901 |
sprintf (arg, "(%%&@tlsld)"); |
| 14902 |
} |
| 14903 |
|
| 14904 |
/* The magic 32768 offset here corresponds to the offset of |
| 14905 |
r30 in .got2, as given by LCTOC1. See sysv4.h:toc_section. */ |
| 14906 |
char z[11]; |
| 14907 |
sprintf (z, "%%z%u%s", funop, |
| 14908 |
(DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT && flag_pic == 2 |
| 14909 |
? "+32768" : "")); |
| 14910 |
|
| 14911 |
static char str[32]; /* 1 spare */ |
| 14912 |
if (rs6000_pcrel_p ()) |
| 14913 |
sprintf (str, "b%s %s@notoc%s", sibcall ? "" : "l", z, arg); |
| 14914 |
else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) |
| 14915 |
sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg, |
| 14916 |
sibcall ? "" : "\n\tnop"); |
| 14917 |
else if (DEFAULT_ABI == ABI_V4) |
| 14918 |
sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg, |
| 14919 |
flag_pic ? "@plt" : ""); |
| 14920 |
#if TARGET_MACHO |
| 14921 |
/* If/when we remove the mlongcall opt, we can share the AIX/ELGv2 case. */ |
| 14922 |
else if (DEFAULT_ABI == ABI_DARWIN) |
| 14923 |
{ |
| 14924 |
/* The cookie is in operand func+2. */ |
| 14925 |
gcc_checking_assert (GET_CODE (operands[funop + 2]) == CONST_INT); |
| 14926 |
int cookie = INTVAL (operands[funop + 2]); |
| 14927 |
if (cookie & CALL_LONG) |
| 14928 |
{ |
| 14929 |
tree funname = get_identifier (XSTR (operands[funop], 0)); |
| 14930 |
tree labelname = get_prev_label (funname); |
| 14931 |
gcc_checking_assert (labelname && !sibcall); |
| 14932 |
|
| 14933 |
/* "jbsr foo, L42" is Mach-O for "Link as 'bl foo' if a 'bl' |
| 14934 |
instruction will reach 'foo', otherwise link as 'bl L42'". |
| 14935 |
"L42" should be a 'branch island', that will do a far jump to |
| 14936 |
'foo'. Branch islands are generated in |
| 14937 |
macho_branch_islands(). */ |
| 14938 |
sprintf (str, "jbsr %%z%u,%.10s", funop, |
| 14939 |
IDENTIFIER_POINTER (labelname)); |
| 14940 |
} |
| 14941 |
else |
| 14942 |
/* Same as AIX or ELFv2, except to keep backwards compat, no nop |
| 14943 |
after the call. */ |
| 14944 |
sprintf (str, "b%s %s%s", sibcall ? "" : "l", z, arg); |
| 14945 |
} |
| 14946 |
#endif |
| 14947 |
else |
| 14948 |
gcc_unreachable (); |
| 14949 |
return str; |
| 14950 |
} |
| 14951 |
|
| 14952 |
const char * |
| 14953 |
rs6000_call_template (rtx *operands, unsigned int funop) |
| 14954 |
{ |
| 14955 |
return rs6000_call_template_1 (operands, funop, false); |
| 14956 |
} |
| 14957 |
|
| 14958 |
const char * |
| 14959 |
rs6000_sibcall_template (rtx *operands, unsigned int funop) |
| 14960 |
{ |
| 14961 |
return rs6000_call_template_1 (operands, funop, true); |
| 14962 |
} |
| 14963 |
|
| 14964 |
/* As above, for indirect calls. */ |
| 14965 |
|
| 14966 |
static const char * |
| 14967 |
rs6000_indirect_call_template_1 (rtx *operands, unsigned int funop, |
| 14968 |
bool sibcall) |
| 14969 |
{ |
| 14970 |
/* -Wformat-overflow workaround, without which gcc thinks that %u |
| 14971 |
might produce 10 digits. Note that -Wformat-overflow will not |
| 14972 |
currently warn here for str[], so do not rely on a warning to |
| 14973 |
ensure str[] is correctly sized. */ |
| 14974 |
gcc_assert (funop <= MAX_RECOG_OPERANDS); |
| 14975 |
|
| 14976 |
/* Currently, funop is either 0 or 1. The maximum string is always |
| 14977 |
a !speculate 64-bit __tls_get_addr call. |
| 14978 |
|
| 14979 |
ABI_ELFv2, pcrel: |
| 14980 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 14981 |
. 35 .reloc .,R_PPC64_PLTSEQ_NOTOC,%z1\n\t |
| 14982 |
. 9 crset 2\n\t |
| 14983 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 14984 |
. 36 .reloc .,R_PPC64_PLTCALL_NOTOC,%z1\n\t |
| 14985 |
. 8 beq%T1l- |
| 14986 |
.--- |
| 14987 |
.142 |
| 14988 |
|
| 14989 |
ABI_AIX: |
| 14990 |
. 9 ld 2,%3\n\t |
| 14991 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 14992 |
. 29 .reloc .,R_PPC64_PLTSEQ,%z1\n\t |
| 14993 |
. 9 crset 2\n\t |
| 14994 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 14995 |
. 30 .reloc .,R_PPC64_PLTCALL,%z1\n\t |
| 14996 |
. 10 beq%T1l-\n\t |
| 14997 |
. 10 ld 2,%4(1) |
| 14998 |
.--- |
| 14999 |
.151 |
| 15000 |
|
| 15001 |
ABI_ELFv2: |
| 15002 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 15003 |
. 29 .reloc .,R_PPC64_PLTSEQ,%z1\n\t |
| 15004 |
. 9 crset 2\n\t |
| 15005 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 15006 |
. 30 .reloc .,R_PPC64_PLTCALL,%z1\n\t |
| 15007 |
. 10 beq%T1l-\n\t |
| 15008 |
. 10 ld 2,%3(1) |
| 15009 |
.--- |
| 15010 |
.142 |
| 15011 |
|
| 15012 |
ABI_V4: |
| 15013 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 15014 |
. 35 .reloc .,R_PPC64_PLTSEQ,%z1+32768\n\t |
| 15015 |
. 9 crset 2\n\t |
| 15016 |
. 27 .reloc .,R_PPC64_TLSGD,%2\n\t |
| 15017 |
. 36 .reloc .,R_PPC64_PLTCALL,%z1+32768\n\t |
| 15018 |
. 8 beq%T1l- |
| 15019 |
.--- |
| 15020 |
.141 */ |
| 15021 |
static char str[160]; /* 8 spare */ |
| 15022 |
char *s = str; |
| 15023 |
const char *ptrload = TARGET_64BIT ? "d" : "wz"; |
| 15024 |
|
| 15025 |
if (DEFAULT_ABI == ABI_AIX) |
| 15026 |
s += sprintf (s, |
| 15027 |
"l%s 2,%%%u\n\t", |
| 15028 |
ptrload, funop + 3); |
| 15029 |
|
| 15030 |
/* We don't need the extra code to stop indirect call speculation if |
| 15031 |
calling via LR. */ |
| 15032 |
bool speculate = (TARGET_MACHO |
| 15033 |
|| rs6000_speculate_indirect_jumps |
| 15034 |
|| (REG_P (operands[funop]) |
| 15035 |
&& REGNO (operands[funop]) == LR_REGNO)); |
| 15036 |
|
| 15037 |
if (TARGET_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC) |
| 15038 |
{ |
| 15039 |
const char *rel64 = TARGET_64BIT ? "64" : ""; |
| 15040 |
char tls[29]; |
| 15041 |
tls[0] = 0; |
| 15042 |
if (GET_CODE (operands[funop + 1]) == UNSPEC) |
| 15043 |
{ |
| 15044 |
if (XINT (operands[funop + 1], 1) == UNSPEC_TLSGD) |
| 15045 |
sprintf (tls, ".reloc .,R_PPC%s_TLSGD,%%%u\n\t", |
| 15046 |
rel64, funop + 1); |
| 15047 |
else if (XINT (operands[funop + 1], 1) == UNSPEC_TLSLD) |
| 15048 |
sprintf (tls, ".reloc .,R_PPC%s_TLSLD,%%&\n\t", |
| 15049 |
rel64); |
| 15050 |
} |
| 15051 |
|
| 15052 |
const char *notoc = rs6000_pcrel_p () ? "_NOTOC" : ""; |
| 15053 |
const char *addend = (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT |
| 15054 |
&& flag_pic == 2 ? "+32768" : ""); |
| 15055 |
if (!speculate) |
| 15056 |
{ |
| 15057 |
s += sprintf (s, |
| 15058 |
"%s.reloc .,R_PPC%s_PLTSEQ%s,%%z%u%s\n\t", |
| 15059 |
tls, rel64, notoc, funop, addend); |
| 15060 |
s += sprintf (s, "crset 2\n\t"); |
| 15061 |
} |
| 15062 |
s += sprintf (s, |
| 15063 |
"%s.reloc .,R_PPC%s_PLTCALL%s,%%z%u%s\n\t", |
| 15064 |
tls, rel64, notoc, funop, addend); |
| 15065 |
} |
| 15066 |
else if (!speculate) |
| 15067 |
s += sprintf (s, "crset 2\n\t"); |
| 15068 |
|
| 15069 |
if (rs6000_pcrel_p ()) |
| 15070 |
{ |
| 15071 |
if (speculate) |
| 15072 |
sprintf (s, "b%%T%ul", funop); |
| 15073 |
else |
| 15074 |
sprintf (s, "beq%%T%ul-", funop); |
| 15075 |
} |
| 15076 |
else if (DEFAULT_ABI == ABI_AIX) |
| 15077 |
{ |
| 15078 |
if (speculate) |
| 15079 |
sprintf (s, |
| 15080 |
"b%%T%ul\n\t" |
| 15081 |
"l%s 2,%%%u(1)", |
| 15082 |
funop, ptrload, funop + 4); |
| 15083 |
else |
| 15084 |
sprintf (s, |
| 15085 |
"beq%%T%ul-\n\t" |
| 15086 |
"l%s 2,%%%u(1)", |
| 15087 |
funop, ptrload, funop + 4); |
| 15088 |
} |
| 15089 |
else if (DEFAULT_ABI == ABI_ELFv2) |
| 15090 |
{ |
| 15091 |
if (speculate) |
| 15092 |
sprintf (s, |
| 15093 |
"b%%T%ul\n\t" |
| 15094 |
"l%s 2,%%%u(1)", |
| 15095 |
funop, ptrload, funop + 3); |
| 15096 |
else |
| 15097 |
sprintf (s, |
| 15098 |
"beq%%T%ul-\n\t" |
| 15099 |
"l%s 2,%%%u(1)", |
| 15100 |
funop, ptrload, funop + 3); |
| 15101 |
} |
| 15102 |
else |
| 15103 |
{ |
| 15104 |
if (speculate) |
| 15105 |
sprintf (s, |
| 15106 |
"b%%T%u%s", |
| 15107 |
funop, sibcall ? "" : "l"); |
| 15108 |
else |
| 15109 |
sprintf (s, |
| 15110 |
"beq%%T%u%s-%s", |
| 15111 |
funop, sibcall ? "" : "l", sibcall ? "\n\tb $" : ""); |
| 15112 |
} |
| 15113 |
return str; |
| 15114 |
} |
| 15115 |
|
| 15116 |
const char * |
| 15117 |
rs6000_indirect_call_template (rtx *operands, unsigned int funop) |
| 15118 |
{ |
| 15119 |
return rs6000_indirect_call_template_1 (operands, funop, false); |
| 15120 |
} |
| 15121 |
|
| 15122 |
const char * |
| 15123 |
rs6000_indirect_sibcall_template (rtx *operands, unsigned int funop) |
| 15124 |
{ |
| 15125 |
return rs6000_indirect_call_template_1 (operands, funop, true); |
| 15126 |
} |
| 15127 |
|
| 15128 |
#if HAVE_AS_PLTSEQ |
| 15129 |
/* Output indirect call insns. WHICH identifies the type of sequence. */ |
| 15130 |
const char * |
| 15131 |
rs6000_pltseq_template (rtx *operands, int which) |
| 15132 |
{ |
| 15133 |
const char *rel64 = TARGET_64BIT ? "64" : ""; |
| 15134 |
char tls[30]; |
| 15135 |
tls[0] = 0; |
| 15136 |
if (GET_CODE (operands[3]) == UNSPEC) |
| 15137 |
{ |
| 15138 |
char off = which == RS6000_PLTSEQ_PLT_PCREL34 ? '8' : '4'; |
| 15139 |
if (XINT (operands[3], 1) == UNSPEC_TLSGD) |
| 15140 |
sprintf (tls, ".reloc .-%c,R_PPC%s_TLSGD,%%3\n\t", |
| 15141 |
off, rel64); |
| 15142 |
else if (XINT (operands[3], 1) == UNSPEC_TLSLD) |
| 15143 |
sprintf (tls, ".reloc .-%c,R_PPC%s_TLSLD,%%&\n\t", |
| 15144 |
off, rel64); |
| 15145 |
} |
| 15146 |
|
| 15147 |
gcc_assert (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4); |
| 15148 |
static char str[96]; /* 10 spare */ |
| 15149 |
char off = WORDS_BIG_ENDIAN ? '2' : '4'; |
| 15150 |
const char *addend = (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT |
| 15151 |
&& flag_pic == 2 ? "+32768" : ""); |
| 15152 |
switch (which) |
| 15153 |
{ |
| 15154 |
case RS6000_PLTSEQ_TOCSAVE: |
| 15155 |
sprintf (str, |
| 15156 |
"st%s\n\t" |
| 15157 |
"%s.reloc .-4,R_PPC%s_PLTSEQ,%%z2", |
| 15158 |
TARGET_64BIT ? "d 2,24(1)" : "w 2,12(1)", |
| 15159 |
tls, rel64); |
| 15160 |
break; |
| 15161 |
case RS6000_PLTSEQ_PLT16_HA: |
| 15162 |
if (DEFAULT_ABI == ABI_V4 && !flag_pic) |
| 15163 |
sprintf (str, |
| 15164 |
"lis %%0,0\n\t" |
| 15165 |
"%s.reloc .-%c,R_PPC%s_PLT16_HA,%%z2", |
| 15166 |
tls, off, rel64); |
| 15167 |
else |
| 15168 |
sprintf (str, |
| 15169 |
"addis %%0,%%1,0\n\t" |
| 15170 |
"%s.reloc .-%c,R_PPC%s_PLT16_HA,%%z2%s", |
| 15171 |
tls, off, rel64, addend); |
| 15172 |
break; |
| 15173 |
case RS6000_PLTSEQ_PLT16_LO: |
| 15174 |
sprintf (str, |
| 15175 |
"l%s %%0,0(%%1)\n\t" |
| 15176 |
"%s.reloc .-%c,R_PPC%s_PLT16_LO%s,%%z2%s", |
| 15177 |
TARGET_64BIT ? "d" : "wz", |
| 15178 |
tls, off, rel64, TARGET_64BIT ? "_DS" : "", addend); |
| 15179 |
break; |
| 15180 |
case RS6000_PLTSEQ_MTCTR: |
| 15181 |
sprintf (str, |
| 15182 |
"mtctr %%1\n\t" |
| 15183 |
"%s.reloc .-4,R_PPC%s_PLTSEQ,%%z2%s", |
| 15184 |
tls, rel64, addend); |
| 15185 |
break; |
| 15186 |
case RS6000_PLTSEQ_PLT_PCREL34: |
| 15187 |
sprintf (str, |
| 15188 |
"pl%s %%0,0(0),1\n\t" |
| 15189 |
"%s.reloc .-8,R_PPC%s_PLT_PCREL34_NOTOC,%%z2", |
| 15190 |
TARGET_64BIT ? "d" : "wz", |
| 15191 |
tls, rel64); |
| 15192 |
break; |
| 15193 |
default: |
| 15194 |
gcc_unreachable (); |
| 15195 |
} |
| 15196 |
return str; |
| 15197 |
} |
| 15198 |
#endif |
| 15199 |
|
| 15200 |
#if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO |
| 15201 |
/* Emit an assembler directive to set symbol visibility for DECL to |
| 15202 |
VISIBILITY_TYPE. */ |
| 15203 |
|
| 15204 |
static void |
| 15205 |
rs6000_assemble_visibility (tree decl, int vis) |
| 15206 |
{ |
| 15207 |
if (TARGET_XCOFF) |
| 15208 |
return; |
| 15209 |
|
| 15210 |
/* Functions need to have their entry point symbol visibility set as |
| 15211 |
well as their descriptor symbol visibility. */ |
| 15212 |
if (DEFAULT_ABI == ABI_AIX |
| 15213 |
&& DOT_SYMBOLS |
| 15214 |
&& TREE_CODE (decl) == FUNCTION_DECL) |
| 15215 |
{ |
| 15216 |
static const char * const visibility_types[] = { |
| 15217 |
NULL, "protected", "hidden", "internal" |
| 15218 |
}; |
| 15219 |
|
| 15220 |
const char *name, *type; |
| 15221 |
|
| 15222 |
name = ((* targetm.strip_name_encoding) |
| 15223 |
(IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)))); |
| 15224 |
type = visibility_types[vis]; |
| 15225 |
|
| 15226 |
fprintf (asm_out_file, "\t.%s\t%s\n", type, name); |
| 15227 |
fprintf (asm_out_file, "\t.%s\t.%s\n", type, name); |
| 15228 |
} |
| 15229 |
else |
| 15230 |
default_assemble_visibility (decl, vis); |
| 15231 |
} |
| 15232 |
#endif |
| 15233 |
|
| 15234 |
/* Write PATCH_AREA_SIZE NOPs into the asm outfile FILE around a function |
| 15235 |
entry. If RECORD_P is true and the target supports named sections, |
| 15236 |
the location of the NOPs will be recorded in a special object section |
| 15237 |
called "__patchable_function_entries". This routine may be called |
| 15238 |
twice per function to put NOPs before and after the function |
| 15239 |
entry. */ |
| 15240 |
|
| 15241 |
void |
| 15242 |
rs6000_print_patchable_function_entry (FILE *file, |
| 15243 |
unsigned HOST_WIDE_INT patch_area_size, |
| 15244 |
bool record_p) |
| 15245 |
{ |
| 15246 |
bool global_entry_needed_p = rs6000_global_entry_point_prologue_needed_p (); |
| 15247 |
/* For a function which needs global entry point, we will emit the |
| 15248 |
patchable area when it isn't split before and after local entry point |
| 15249 |
under the control of cfun->machine->global_entry_emitted, see the |
| 15250 |
handling in function rs6000_output_function_prologue. */ |
| 15251 |
if (!TARGET_SPLIT_PATCH_NOPS |
| 15252 |
&& (!global_entry_needed_p || cfun->machine->global_entry_emitted)) |
| 15253 |
default_print_patchable_function_entry (file, patch_area_size, record_p); |
| 15254 |
|
| 15255 |
/* For split patch nops we emit the before nops (from generic code) |
| 15256 |
in front of the global entry point and after the local entry point, |
| 15257 |
under the control of cfun->machine->stop_patch_area_print, see |
| 15258 |
rs6000_output_function_prologue and rs6000_elf_declare_function_name. */ |
| 15259 |
if (TARGET_SPLIT_PATCH_NOPS) |
| 15260 |
{ |
| 15261 |
if (!cfun->machine->stop_patch_area_print) |
| 15262 |
default_print_patchable_function_entry (file, patch_area_size, |
| 15263 |
record_p); |
| 15264 |
else |
| 15265 |
gcc_assert (global_entry_needed_p); |
| 15266 |
} |
| 15267 |
} |
| 15268 |
|
| 15269 |
enum rtx_code |
| 15270 |
rs6000_reverse_condition (machine_mode mode, enum rtx_code code) |
| 15271 |
{ |
| 15272 |
/* Reversal of FP compares takes care -- an ordered compare |
| 15273 |
becomes an unordered compare and vice versa. */ |
| 15274 |
if (mode == CCFPmode |
| 15275 |
&& (!flag_finite_math_only |
| 15276 |
|| code == UNLT || code == UNLE || code == UNGT || code == UNGE |
| 15277 |
|| code == UNEQ || code == LTGT)) |
| 15278 |
return reverse_condition_maybe_unordered (code); |
| 15279 |
else |
| 15280 |
return reverse_condition (code); |
| 15281 |
} |
| 15282 |
|
| 15283 |
/* Check if C (as 64bit integer) can be rotated to a constant which constains |
| 15284 |
nonzero bits at the LOWBITS low bits only. |
| 15285 |
|
| 15286 |
Return true if C can be rotated to such constant. If so, *ROT is written |
| 15287 |
to the number by which C is rotated. |
| 15288 |
Return false otherwise. */ |
| 15289 |
|
| 15290 |
bool |
| 15291 |
can_be_rotated_to_lowbits (unsigned HOST_WIDE_INT c, int lowbits, int *rot) |
| 15292 |
{ |
| 15293 |
int clz = HOST_BITS_PER_WIDE_INT - lowbits; |
| 15294 |
|
| 15295 |
/* case a. 0..0xxx: already at least clz zeros. */ |
| 15296 |
int lz = clz_hwi (c); |
| 15297 |
if (lz >= clz) |
| 15298 |
{ |
| 15299 |
*rot = 0; |
| 15300 |
return true; |
| 15301 |
} |
| 15302 |
|
| 15303 |
/* case b. 0..0xxx0..0: at least clz zeros. */ |
| 15304 |
int tz = ctz_hwi (c); |
| 15305 |
if (lz + tz >= clz) |
| 15306 |
{ |
| 15307 |
*rot = HOST_BITS_PER_WIDE_INT - tz; |
| 15308 |
return true; |
| 15309 |
} |
| 15310 |
|
| 15311 |
/* case c. xx10.....0xx: rotate 'clz - 1' bits first, then check case b. |
| 15312 |
^bit -> Vbit, , then zeros are at head or tail. |
| 15313 |
00...00xxx100, 'clz - 1' >= 'bits of xxxx'. */ |
| 15314 |
const int rot_bits = lowbits + 1; |
| 15315 |
unsigned HOST_WIDE_INT rc = (c >> rot_bits) | (c << (clz - 1)); |
| 15316 |
tz = ctz_hwi (rc); |
| 15317 |
if (clz_hwi (rc) + tz >= clz) |
| 15318 |
{ |
| 15319 |
*rot = HOST_BITS_PER_WIDE_INT - (tz + rot_bits); |
| 15320 |
return true; |
| 15321 |
} |
| 15322 |
|
| 15323 |
return false; |
| 15324 |
} |
| 15325 |
|
| 15326 |
/* Check if C (as 64bit integer) can be rotated to a positive 16bits constant |
| 15327 |
which contains 48bits leading zeros and 16bits of any value. */ |
| 15328 |
|
| 15329 |
bool |
| 15330 |
can_be_rotated_to_positive_16bits (HOST_WIDE_INT c) |
| 15331 |
{ |
| 15332 |
int rot = 0; |
| 15333 |
bool res = can_be_rotated_to_lowbits (c, 16, &rot); |
| 15334 |
return res && rot > 0; |
| 15335 |
} |
| 15336 |
|
| 15337 |
/* Check if C (as 64bit integer) can be rotated to a negative 15bits constant |
| 15338 |
which contains 49bits leading ones and 15bits of any value. */ |
| 15339 |
|
| 15340 |
bool |
| 15341 |
can_be_rotated_to_negative_15bits (HOST_WIDE_INT c) |
| 15342 |
{ |
| 15343 |
int rot = 0; |
| 15344 |
bool res = can_be_rotated_to_lowbits (~c, 15, &rot); |
| 15345 |
return res && rot > 0; |
| 15346 |
} |
| 15347 |
|
| 15348 |
/* Generate a compare for CODE. Return a brand-new rtx that |
| 15349 |
represents the result of the compare. */ |
| 15350 |
|
| 15351 |
static rtx |
| 15352 |
rs6000_generate_compare (rtx cmp, machine_mode mode) |
| 15353 |
{ |
| 15354 |
machine_mode comp_mode; |
| 15355 |
rtx compare_result; |
| 15356 |
enum rtx_code code = GET_CODE (cmp); |
| 15357 |
rtx op0 = XEXP (cmp, 0); |
| 15358 |
rtx op1 = XEXP (cmp, 1); |
| 15359 |
|
| 15360 |
if (!TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)) |
| 15361 |
comp_mode = CCmode; |
| 15362 |
else if (FLOAT_MODE_P (mode)) |
| 15363 |
comp_mode = CCFPmode; |
| 15364 |
else if (code == GTU || code == LTU |
| 15365 |
|| code == GEU || code == LEU) |
| 15366 |
comp_mode = CCUNSmode; |
| 15367 |
else if ((code == EQ || code == NE) |
| 15368 |
&& unsigned_reg_p (op0) |
| 15369 |
&& (unsigned_reg_p (op1) |
| 15370 |
|| (CONST_INT_P (op1) && INTVAL (op1) != 0))) |
| 15371 |
/* These are unsigned values, perhaps there will be a later |
| 15372 |
ordering compare that can be shared with this one. */ |
| 15373 |
comp_mode = CCUNSmode; |
| 15374 |
else |
| 15375 |
comp_mode = CCmode; |
| 15376 |
|
| 15377 |
/* If we have an unsigned compare, make sure we don't have a signed value as |
| 15378 |
an immediate. */ |
| 15379 |
if (comp_mode == CCUNSmode && CONST_INT_P (op1) |
| 15380 |
&& INTVAL (op1) < 0) |
| 15381 |
{ |
| 15382 |
op0 = copy_rtx_if_shared (op0); |
| 15383 |
op1 = force_reg (GET_MODE (op0), op1); |
| 15384 |
cmp = gen_rtx_fmt_ee (code, GET_MODE (cmp), op0, op1); |
| 15385 |
} |
| 15386 |
|
| 15387 |
/* First, the compare. */ |
| 15388 |
compare_result = gen_reg_rtx (comp_mode); |
| 15389 |
|
| 15390 |
/* IEEE 128-bit support in VSX registers when we do not have hardware |
| 15391 |
support. */ |
| 15392 |
if (!TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)) |
| 15393 |
{ |
| 15394 |
rtx libfunc = NULL_RTX; |
| 15395 |
bool check_nan = false; |
| 15396 |
rtx dest; |
| 15397 |
|
| 15398 |
switch (code) |
| 15399 |
{ |
| 15400 |
case EQ: |
| 15401 |
case NE: |
| 15402 |
libfunc = optab_libfunc (eq_optab, mode); |
| 15403 |
break; |
| 15404 |
|
| 15405 |
case GT: |
| 15406 |
case GE: |
| 15407 |
libfunc = optab_libfunc (ge_optab, mode); |
| 15408 |
break; |
| 15409 |
|
| 15410 |
case LT: |
| 15411 |
case LE: |
| 15412 |
libfunc = optab_libfunc (le_optab, mode); |
| 15413 |
break; |
| 15414 |
|
| 15415 |
case UNORDERED: |
| 15416 |
case ORDERED: |
| 15417 |
libfunc = optab_libfunc (unord_optab, mode); |
| 15418 |
code = (code == UNORDERED) ? NE : EQ; |
| 15419 |
break; |
| 15420 |
|
| 15421 |
case UNGE: |
| 15422 |
case UNGT: |
| 15423 |
check_nan = true; |
| 15424 |
libfunc = optab_libfunc (ge_optab, mode); |
| 15425 |
code = (code == UNGE) ? GE : GT; |
| 15426 |
break; |
| 15427 |
|
| 15428 |
case UNLE: |
| 15429 |
case UNLT: |
| 15430 |
check_nan = true; |
| 15431 |
libfunc = optab_libfunc (le_optab, mode); |
| 15432 |
code = (code == UNLE) ? LE : LT; |
| 15433 |
break; |
| 15434 |
|
| 15435 |
case UNEQ: |
| 15436 |
case LTGT: |
| 15437 |
check_nan = true; |
| 15438 |
libfunc = optab_libfunc (eq_optab, mode); |
| 15439 |
code = (code = UNEQ) ? EQ : NE; |
| 15440 |
break; |
| 15441 |
|
| 15442 |
default: |
| 15443 |
gcc_unreachable (); |
| 15444 |
} |
| 15445 |
|
| 15446 |
gcc_assert (libfunc); |
| 15447 |
|
| 15448 |
if (!check_nan) |
| 15449 |
dest = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, |
| 15450 |
SImode, op0, mode, op1, mode); |
| 15451 |
|
| 15452 |
/* The library signals an exception for signalling NaNs, so we need to |
| 15453 |
handle isgreater, etc. by first checking isordered. */ |
| 15454 |
else |
| 15455 |
{ |
| 15456 |
rtx ne_rtx, normal_dest, unord_dest; |
| 15457 |
rtx unord_func = optab_libfunc (unord_optab, mode); |
| 15458 |
rtx join_label = gen_label_rtx (); |
| 15459 |
rtx join_ref = gen_rtx_LABEL_REF (VOIDmode, join_label); |
| 15460 |
rtx unord_cmp = gen_reg_rtx (comp_mode); |
| 15461 |
|
| 15462 |
|
| 15463 |
/* Test for either value being a NaN. */ |
| 15464 |
gcc_assert (unord_func); |
| 15465 |
unord_dest = emit_library_call_value (unord_func, NULL_RTX, LCT_CONST, |
| 15466 |
SImode, op0, mode, op1, mode); |
| 15467 |
|
| 15468 |
/* Set value (0) if either value is a NaN, and jump to the join |
| 15469 |
label. */ |
| 15470 |
dest = gen_reg_rtx (SImode); |
| 15471 |
emit_move_insn (dest, const1_rtx); |
| 15472 |
emit_insn (gen_rtx_SET (unord_cmp, |
| 15473 |
gen_rtx_COMPARE (comp_mode, unord_dest, |
| 15474 |
const0_rtx))); |
| 15475 |
|
| 15476 |
ne_rtx = gen_rtx_NE (comp_mode, unord_cmp, const0_rtx); |
| 15477 |
emit_jump_insn (gen_rtx_SET (pc_rtx, |
| 15478 |
gen_rtx_IF_THEN_ELSE (VOIDmode, ne_rtx, |
| 15479 |
join_ref, |
| 15480 |
pc_rtx))); |
| 15481 |
|
| 15482 |
/* Do the normal comparison, knowing that the values are not |
| 15483 |
NaNs. */ |
| 15484 |
normal_dest = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, |
| 15485 |
SImode, op0, mode, op1, mode); |
| 15486 |
|
| 15487 |
emit_insn (gen_cstoresi4 (dest, |
| 15488 |
gen_rtx_fmt_ee (code, SImode, normal_dest, |
| 15489 |
const0_rtx), |
| 15490 |
normal_dest, const0_rtx)); |
| 15491 |
|
| 15492 |
/* Join NaN and non-Nan paths. Compare dest against 0. */ |
| 15493 |
emit_label (join_label); |
| 15494 |
code = NE; |
| 15495 |
} |
| 15496 |
|
| 15497 |
emit_insn (gen_rtx_SET (compare_result, |
| 15498 |
gen_rtx_COMPARE (comp_mode, dest, const0_rtx))); |
| 15499 |
} |
| 15500 |
|
| 15501 |
else |
| 15502 |
{ |
| 15503 |
/* Generate XLC-compatible TFmode compare as PARALLEL with extra |
| 15504 |
CLOBBERs to match cmptf_internal2 pattern. */ |
| 15505 |
if (comp_mode == CCFPmode && TARGET_XL_COMPAT |
| 15506 |
&& FLOAT128_IBM_P (GET_MODE (op0)) |
| 15507 |
&& TARGET_HARD_FLOAT) |
| 15508 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, |
| 15509 |
gen_rtvec (10, |
| 15510 |
gen_rtx_SET (compare_result, |
| 15511 |
gen_rtx_COMPARE (comp_mode, op0, op1)), |
| 15512 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15513 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15514 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15515 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15516 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15517 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15518 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15519 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (DFmode)), |
| 15520 |
gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (Pmode))))); |
| 15521 |
else if (GET_CODE (op1) == UNSPEC |
| 15522 |
&& XINT (op1, 1) == UNSPEC_SP_TEST) |
| 15523 |
{ |
| 15524 |
rtx op1b = XVECEXP (op1, 0, 0); |
| 15525 |
comp_mode = CCEQmode; |
| 15526 |
compare_result = gen_reg_rtx (CCEQmode); |
| 15527 |
if (TARGET_64BIT) |
| 15528 |
emit_insn (gen_stack_protect_testdi (compare_result, op0, op1b)); |
| 15529 |
else |
| 15530 |
emit_insn (gen_stack_protect_testsi (compare_result, op0, op1b)); |
| 15531 |
} |
| 15532 |
else if (mode == V16QImode) |
| 15533 |
{ |
| 15534 |
gcc_assert (code == EQ || code == NE); |
| 15535 |
|
| 15536 |
rtx result_vector = gen_reg_rtx (V16QImode); |
| 15537 |
rtx cc_bit = gen_reg_rtx (SImode); |
| 15538 |
emit_insn (gen_altivec_vcmpequb_p (result_vector, op0, op1)); |
| 15539 |
emit_insn (gen_cr6_test_for_lt (cc_bit)); |
| 15540 |
emit_insn (gen_rtx_SET (compare_result, |
| 15541 |
gen_rtx_COMPARE (comp_mode, cc_bit, |
| 15542 |
const1_rtx))); |
| 15543 |
} |
| 15544 |
else |
| 15545 |
emit_insn (gen_rtx_SET (compare_result, |
| 15546 |
gen_rtx_COMPARE (comp_mode, op0, op1))); |
| 15547 |
} |
| 15548 |
|
| 15549 |
validate_condition_mode (code, GET_MODE (compare_result)); |
| 15550 |
|
| 15551 |
return gen_rtx_fmt_ee (code, VOIDmode, compare_result, const0_rtx); |
| 15552 |
} |
| 15553 |
|
| 15554 |
|
| 15555 |
/* Return the diagnostic message string if the binary operation OP is |
| 15556 |
not permitted on TYPE1 and TYPE2, NULL otherwise. */ |
| 15557 |
|
| 15558 |
static const char* |
| 15559 |
rs6000_invalid_binary_op (int op ATTRIBUTE_UNUSED, |
| 15560 |
const_tree type1, |
| 15561 |
const_tree type2) |
| 15562 |
{ |
| 15563 |
machine_mode mode1 = TYPE_MODE (type1); |
| 15564 |
machine_mode mode2 = TYPE_MODE (type2); |
| 15565 |
|
| 15566 |
/* For complex modes, use the inner type. */ |
| 15567 |
if (COMPLEX_MODE_P (mode1)) |
| 15568 |
mode1 = GET_MODE_INNER (mode1); |
| 15569 |
|
| 15570 |
if (COMPLEX_MODE_P (mode2)) |
| 15571 |
mode2 = GET_MODE_INNER (mode2); |
| 15572 |
|
| 15573 |
/* Don't allow IEEE 754R 128-bit binary floating point and IBM extended |
| 15574 |
double to intermix unless -mfloat128-convert. */ |
| 15575 |
if (mode1 == mode2) |
| 15576 |
return NULL; |
| 15577 |
|
| 15578 |
if (!TARGET_FLOAT128_CVT) |
| 15579 |
{ |
| 15580 |
if ((FLOAT128_IEEE_P (mode1) && FLOAT128_IBM_P (mode2)) |
| 15581 |
|| (FLOAT128_IBM_P (mode1) && FLOAT128_IEEE_P (mode2))) |
| 15582 |
return N_("Invalid mixing of IEEE 128-bit and IBM 128-bit floating " |
| 15583 |
"point types"); |
| 15584 |
} |
| 15585 |
|
| 15586 |
return NULL; |
| 15587 |
} |
| 15588 |
|
| 15589 |
|
| 15590 |
/* Expand floating point conversion to/from __float128 and __ibm128. */ |
| 15591 |
|
| 15592 |
void |
| 15593 |
rs6000_expand_float128_convert (rtx dest, rtx src, bool unsigned_p) |
| 15594 |
{ |
| 15595 |
machine_mode dest_mode = GET_MODE (dest); |
| 15596 |
machine_mode src_mode = GET_MODE (src); |
| 15597 |
convert_optab cvt = unknown_optab; |
| 15598 |
bool do_move = false; |
| 15599 |
rtx libfunc = NULL_RTX; |
| 15600 |
rtx dest2; |
| 15601 |
typedef rtx (*rtx_2func_t) (rtx, rtx); |
| 15602 |
rtx_2func_t hw_convert = (rtx_2func_t)0; |
| 15603 |
size_t kf_or_tf; |
| 15604 |
|
| 15605 |
struct hw_conv_t { |
| 15606 |
rtx_2func_t from_df; |
| 15607 |
rtx_2func_t from_sf; |
| 15608 |
rtx_2func_t from_si_sign; |
| 15609 |
rtx_2func_t from_si_uns; |
| 15610 |
rtx_2func_t from_di_sign; |
| 15611 |
rtx_2func_t from_di_uns; |
| 15612 |
rtx_2func_t to_df; |
| 15613 |
rtx_2func_t to_sf; |
| 15614 |
rtx_2func_t to_si_sign; |
| 15615 |
rtx_2func_t to_si_uns; |
| 15616 |
rtx_2func_t to_di_sign; |
| 15617 |
rtx_2func_t to_di_uns; |
| 15618 |
} hw_conversions[2] = { |
| 15619 |
/* convertions to/from KFmode */ |
| 15620 |
{ |
| 15621 |
gen_extenddfkf2_hw, /* KFmode <- DFmode. */ |
| 15622 |
gen_extendsfkf2_hw, /* KFmode <- SFmode. */ |
| 15623 |
gen_float_kfsi2_hw, /* KFmode <- SImode (signed). */ |
| 15624 |
gen_floatuns_kfsi2_hw, /* KFmode <- SImode (unsigned). */ |
| 15625 |
gen_float_kfdi2_hw, /* KFmode <- DImode (signed). */ |
| 15626 |
gen_floatuns_kfdi2_hw, /* KFmode <- DImode (unsigned). */ |
| 15627 |
gen_trunckfdf2_hw, /* DFmode <- KFmode. */ |
| 15628 |
gen_trunckfsf2_hw, /* SFmode <- KFmode. */ |
| 15629 |
gen_fix_kfsi2_hw, /* SImode <- KFmode (signed). */ |
| 15630 |
gen_fixuns_kfsi2_hw, /* SImode <- KFmode (unsigned). */ |
| 15631 |
gen_fix_kfdi2_hw, /* DImode <- KFmode (signed). */ |
| 15632 |
gen_fixuns_kfdi2_hw, /* DImode <- KFmode (unsigned). */ |
| 15633 |
}, |
| 15634 |
|
| 15635 |
/* convertions to/from TFmode */ |
| 15636 |
{ |
| 15637 |
gen_extenddftf2_hw, /* TFmode <- DFmode. */ |
| 15638 |
gen_extendsftf2_hw, /* TFmode <- SFmode. */ |
| 15639 |
gen_float_tfsi2_hw, /* TFmode <- SImode (signed). */ |
| 15640 |
gen_floatuns_tfsi2_hw, /* TFmode <- SImode (unsigned). */ |
| 15641 |
gen_float_tfdi2_hw, /* TFmode <- DImode (signed). */ |
| 15642 |
gen_floatuns_tfdi2_hw, /* TFmode <- DImode (unsigned). */ |
| 15643 |
gen_trunctfdf2_hw, /* DFmode <- TFmode. */ |
| 15644 |
gen_trunctfsf2_hw, /* SFmode <- TFmode. */ |
| 15645 |
gen_fix_tfsi2_hw, /* SImode <- TFmode (signed). */ |
| 15646 |
gen_fixuns_tfsi2_hw, /* SImode <- TFmode (unsigned). */ |
| 15647 |
gen_fix_tfdi2_hw, /* DImode <- TFmode (signed). */ |
| 15648 |
gen_fixuns_tfdi2_hw, /* DImode <- TFmode (unsigned). */ |
| 15649 |
}, |
| 15650 |
}; |
| 15651 |
|
| 15652 |
if (dest_mode == src_mode) |
| 15653 |
gcc_unreachable (); |
| 15654 |
|
| 15655 |
/* Eliminate memory operations. */ |
| 15656 |
if (MEM_P (src)) |
| 15657 |
src = force_reg (src_mode, src); |
| 15658 |
|
| 15659 |
if (MEM_P (dest)) |
| 15660 |
{ |
| 15661 |
rtx tmp = gen_reg_rtx (dest_mode); |
| 15662 |
rs6000_expand_float128_convert (tmp, src, unsigned_p); |
| 15663 |
rs6000_emit_move (dest, tmp, dest_mode); |
| 15664 |
return; |
| 15665 |
} |
| 15666 |
|
| 15667 |
/* Convert to IEEE 128-bit floating point. */ |
| 15668 |
if (FLOAT128_IEEE_P (dest_mode)) |
| 15669 |
{ |
| 15670 |
if (dest_mode == KFmode) |
| 15671 |
kf_or_tf = 0; |
| 15672 |
else if (dest_mode == TFmode) |
| 15673 |
kf_or_tf = 1; |
| 15674 |
else |
| 15675 |
gcc_unreachable (); |
| 15676 |
|
| 15677 |
switch (src_mode) |
| 15678 |
{ |
| 15679 |
case E_DFmode: |
| 15680 |
cvt = sext_optab; |
| 15681 |
hw_convert = hw_conversions[kf_or_tf].from_df; |
| 15682 |
break; |
| 15683 |
|
| 15684 |
case E_SFmode: |
| 15685 |
cvt = sext_optab; |
| 15686 |
hw_convert = hw_conversions[kf_or_tf].from_sf; |
| 15687 |
break; |
| 15688 |
|
| 15689 |
case E_KFmode: |
| 15690 |
case E_IFmode: |
| 15691 |
case E_TFmode: |
| 15692 |
if (FLOAT128_IBM_P (src_mode)) |
| 15693 |
cvt = trunc_optab; |
| 15694 |
else |
| 15695 |
do_move = true; |
| 15696 |
break; |
| 15697 |
|
| 15698 |
case E_SImode: |
| 15699 |
if (unsigned_p) |
| 15700 |
{ |
| 15701 |
cvt = ufloat_optab; |
| 15702 |
hw_convert = hw_conversions[kf_or_tf].from_si_uns; |
| 15703 |
} |
| 15704 |
else |
| 15705 |
{ |
| 15706 |
cvt = sfloat_optab; |
| 15707 |
hw_convert = hw_conversions[kf_or_tf].from_si_sign; |
| 15708 |
} |
| 15709 |
break; |
| 15710 |
|
| 15711 |
case E_DImode: |
| 15712 |
if (unsigned_p) |
| 15713 |
{ |
| 15714 |
cvt = ufloat_optab; |
| 15715 |
hw_convert = hw_conversions[kf_or_tf].from_di_uns; |
| 15716 |
} |
| 15717 |
else |
| 15718 |
{ |
| 15719 |
cvt = sfloat_optab; |
| 15720 |
hw_convert = hw_conversions[kf_or_tf].from_di_sign; |
| 15721 |
} |
| 15722 |
break; |
| 15723 |
|
| 15724 |
default: |
| 15725 |
gcc_unreachable (); |
| 15726 |
} |
| 15727 |
} |
| 15728 |
|
| 15729 |
/* Convert from IEEE 128-bit floating point. */ |
| 15730 |
else if (FLOAT128_IEEE_P (src_mode)) |
| 15731 |
{ |
| 15732 |
if (src_mode == KFmode) |
| 15733 |
kf_or_tf = 0; |
| 15734 |
else if (src_mode == TFmode) |
| 15735 |
kf_or_tf = 1; |
| 15736 |
else |
| 15737 |
gcc_unreachable (); |
| 15738 |
|
| 15739 |
switch (dest_mode) |
| 15740 |
{ |
| 15741 |
case E_DFmode: |
| 15742 |
cvt = trunc_optab; |
| 15743 |
hw_convert = hw_conversions[kf_or_tf].to_df; |
| 15744 |
break; |
| 15745 |
|
| 15746 |
case E_SFmode: |
| 15747 |
cvt = trunc_optab; |
| 15748 |
hw_convert = hw_conversions[kf_or_tf].to_sf; |
| 15749 |
break; |
| 15750 |
|
| 15751 |
case E_KFmode: |
| 15752 |
case E_IFmode: |
| 15753 |
case E_TFmode: |
| 15754 |
if (FLOAT128_IBM_P (dest_mode)) |
| 15755 |
cvt = sext_optab; |
| 15756 |
else |
| 15757 |
do_move = true; |
| 15758 |
break; |
| 15759 |
|
| 15760 |
case E_SImode: |
| 15761 |
if (unsigned_p) |
| 15762 |
{ |
| 15763 |
cvt = ufix_optab; |
| 15764 |
hw_convert = hw_conversions[kf_or_tf].to_si_uns; |
| 15765 |
} |
| 15766 |
else |
| 15767 |
{ |
| 15768 |
cvt = sfix_optab; |
| 15769 |
hw_convert = hw_conversions[kf_or_tf].to_si_sign; |
| 15770 |
} |
| 15771 |
break; |
| 15772 |
|
| 15773 |
case E_DImode: |
| 15774 |
if (unsigned_p) |
| 15775 |
{ |
| 15776 |
cvt = ufix_optab; |
| 15777 |
hw_convert = hw_conversions[kf_or_tf].to_di_uns; |
| 15778 |
} |
| 15779 |
else |
| 15780 |
{ |
| 15781 |
cvt = sfix_optab; |
| 15782 |
hw_convert = hw_conversions[kf_or_tf].to_di_sign; |
| 15783 |
} |
| 15784 |
break; |
| 15785 |
|
| 15786 |
default: |
| 15787 |
gcc_unreachable (); |
| 15788 |
} |
| 15789 |
} |
| 15790 |
|
| 15791 |
/* Both IBM format. */ |
| 15792 |
else if (FLOAT128_IBM_P (dest_mode) && FLOAT128_IBM_P (src_mode)) |
| 15793 |
do_move = true; |
| 15794 |
|
| 15795 |
else |
| 15796 |
gcc_unreachable (); |
| 15797 |
|
| 15798 |
/* Handle conversion between TFmode/KFmode/IFmode. */ |
| 15799 |
if (do_move) |
| 15800 |
emit_insn (gen_rtx_SET (dest, gen_rtx_FLOAT_EXTEND (dest_mode, src))); |
| 15801 |
|
| 15802 |
/* Handle conversion if we have hardware support. */ |
| 15803 |
else if (TARGET_FLOAT128_HW && hw_convert) |
| 15804 |
emit_insn ((hw_convert) (dest, src)); |
| 15805 |
|
| 15806 |
/* Call an external function to do the conversion. */ |
| 15807 |
else if (cvt != unknown_optab) |
| 15808 |
{ |
| 15809 |
libfunc = convert_optab_libfunc (cvt, dest_mode, src_mode); |
| 15810 |
gcc_assert (libfunc != NULL_RTX); |
| 15811 |
|
| 15812 |
dest2 = emit_library_call_value (libfunc, dest, LCT_CONST, dest_mode, |
| 15813 |
src, src_mode); |
| 15814 |
|
| 15815 |
gcc_assert (dest2 != NULL_RTX); |
| 15816 |
if (!rtx_equal_p (dest, dest2)) |
| 15817 |
emit_move_insn (dest, dest2); |
| 15818 |
} |
| 15819 |
|
| 15820 |
else |
| 15821 |
gcc_unreachable (); |
| 15822 |
|
| 15823 |
return; |
| 15824 |
} |
| 15825 |
|
| 15826 |
|
| 15827 |
/* Emit RTL that sets a register to zero if OP1 and OP2 are equal. SCRATCH |
| 15828 |
can be used as that dest register. Return the dest register. */ |
| 15829 |
|
| 15830 |
rtx |
| 15831 |
rs6000_emit_eqne (machine_mode mode, rtx op1, rtx op2, rtx scratch) |
| 15832 |
{ |
| 15833 |
if (op2 == const0_rtx) |
| 15834 |
return op1; |
| 15835 |
|
| 15836 |
if (GET_CODE (scratch) == SCRATCH) |
| 15837 |
scratch = gen_reg_rtx (mode); |
| 15838 |
|
| 15839 |
if (logical_operand (op2, mode)) |
| 15840 |
emit_insn (gen_rtx_SET (scratch, gen_rtx_XOR (mode, op1, op2))); |
| 15841 |
else |
| 15842 |
emit_insn (gen_rtx_SET (scratch, |
| 15843 |
gen_rtx_PLUS (mode, op1, negate_rtx (mode, op2)))); |
| 15844 |
|
| 15845 |
return scratch; |
| 15846 |
} |
| 15847 |
|
| 15848 |
/* Emit code doing a cror of two CR bits, for FP comparisons with a CODE that |
| 15849 |
requires this. The result is mode MODE. */ |
| 15850 |
rtx |
| 15851 |
rs6000_emit_fp_cror (rtx_code code, machine_mode mode, rtx x) |
| 15852 |
{ |
| 15853 |
rtx cond[2]; |
| 15854 |
int n = 0; |
| 15855 |
if (code == LTGT || code == LE || code == UNLT) |
| 15856 |
cond[n++] = gen_rtx_fmt_ee (LT, mode, x, const0_rtx); |
| 15857 |
if (code == LTGT || code == GE || code == UNGT) |
| 15858 |
cond[n++] = gen_rtx_fmt_ee (GT, mode, x, const0_rtx); |
| 15859 |
if (code == LE || code == GE || code == UNEQ) |
| 15860 |
cond[n++] = gen_rtx_fmt_ee (EQ, mode, x, const0_rtx); |
| 15861 |
if (code == UNLT || code == UNGT || code == UNEQ) |
| 15862 |
cond[n++] = gen_rtx_fmt_ee (UNORDERED, mode, x, const0_rtx); |
| 15863 |
|
| 15864 |
gcc_assert (n == 2); |
| 15865 |
|
| 15866 |
rtx cc = gen_reg_rtx (CCEQmode); |
| 15867 |
rtx logical = gen_rtx_IOR (mode, cond[0], cond[1]); |
| 15868 |
emit_insn (gen_cceq_ior_compare (mode, cc, logical, cond[0], x, cond[1], x)); |
| 15869 |
|
| 15870 |
return cc; |
| 15871 |
} |
| 15872 |
|
| 15873 |
void |
| 15874 |
rs6000_emit_sCOND (machine_mode mode, rtx operands[]) |
| 15875 |
{ |
| 15876 |
rtx condition_rtx = rs6000_generate_compare (operands[1], mode); |
| 15877 |
rtx_code cond_code = GET_CODE (condition_rtx); |
| 15878 |
|
| 15879 |
if (FLOAT_MODE_P (mode) && HONOR_NANS (mode) |
| 15880 |
&& !(FLOAT128_VECTOR_P (mode) && !TARGET_FLOAT128_HW)) |
| 15881 |
; |
| 15882 |
else if (cond_code == NE |
| 15883 |
|| cond_code == GE || cond_code == LE |
| 15884 |
|| cond_code == GEU || cond_code == LEU |
| 15885 |
|| cond_code == ORDERED || cond_code == UNGE || cond_code == UNLE) |
| 15886 |
{ |
| 15887 |
rtx not_result = gen_reg_rtx (CCEQmode); |
| 15888 |
rtx not_op, rev_cond_rtx; |
| 15889 |
machine_mode cc_mode; |
| 15890 |
|
| 15891 |
cc_mode = GET_MODE (XEXP (condition_rtx, 0)); |
| 15892 |
|
| 15893 |
rev_cond_rtx = gen_rtx_fmt_ee (rs6000_reverse_condition (cc_mode, cond_code), |
| 15894 |
SImode, XEXP (condition_rtx, 0), const0_rtx); |
| 15895 |
not_op = gen_rtx_COMPARE (CCEQmode, rev_cond_rtx, const0_rtx); |
| 15896 |
emit_insn (gen_rtx_SET (not_result, not_op)); |
| 15897 |
condition_rtx = gen_rtx_EQ (VOIDmode, not_result, const0_rtx); |
| 15898 |
} |
| 15899 |
|
| 15900 |
machine_mode op_mode = GET_MODE (XEXP (operands[1], 0)); |
| 15901 |
if (op_mode == VOIDmode) |
| 15902 |
op_mode = GET_MODE (XEXP (operands[1], 1)); |
| 15903 |
|
| 15904 |
if (TARGET_POWERPC64 && (op_mode == DImode || FLOAT_MODE_P (mode))) |
| 15905 |
{ |
| 15906 |
PUT_MODE (condition_rtx, DImode); |
| 15907 |
convert_move (operands[0], condition_rtx, 0); |
| 15908 |
} |
| 15909 |
else |
| 15910 |
{ |
| 15911 |
PUT_MODE (condition_rtx, SImode); |
| 15912 |
emit_insn (gen_rtx_SET (operands[0], condition_rtx)); |
| 15913 |
} |
| 15914 |
} |
| 15915 |
|
| 15916 |
/* Emit a branch of kind CODE to location LOC. */ |
| 15917 |
|
| 15918 |
void |
| 15919 |
rs6000_emit_cbranch (machine_mode mode, rtx operands[]) |
| 15920 |
{ |
| 15921 |
rtx condition_rtx = rs6000_generate_compare (operands[0], mode); |
| 15922 |
rtx loc_ref = gen_rtx_LABEL_REF (VOIDmode, operands[3]); |
| 15923 |
rtx ite = gen_rtx_IF_THEN_ELSE (VOIDmode, condition_rtx, loc_ref, pc_rtx); |
| 15924 |
emit_jump_insn (gen_rtx_SET (pc_rtx, ite)); |
| 15925 |
} |
| 15926 |
|
| 15927 |
/* Return the string to output a conditional branch to LABEL, which is |
| 15928 |
the operand template of the label, or NULL if the branch is really a |
| 15929 |
conditional return. |
| 15930 |
|
| 15931 |
OP is the conditional expression. XEXP (OP, 0) is assumed to be a |
| 15932 |
condition code register and its mode specifies what kind of |
| 15933 |
comparison we made. |
| 15934 |
|
| 15935 |
REVERSED is nonzero if we should reverse the sense of the comparison. |
| 15936 |
|
| 15937 |
INSN is the insn. */ |
| 15938 |
|
| 15939 |
char * |
| 15940 |
output_cbranch (rtx op, const char *label, int reversed, rtx_insn *insn) |
| 15941 |
{ |
| 15942 |
static char string[64]; |
| 15943 |
enum rtx_code code = GET_CODE (op); |
| 15944 |
rtx cc_reg = XEXP (op, 0); |
| 15945 |
machine_mode mode = GET_MODE (cc_reg); |
| 15946 |
int cc_regno = REGNO (cc_reg) - CR0_REGNO; |
| 15947 |
int need_longbranch = label != NULL && get_attr_length (insn) == 8; |
| 15948 |
int really_reversed = reversed ^ need_longbranch; |
| 15949 |
char *s = string; |
| 15950 |
const char *ccode; |
| 15951 |
const char *pred; |
| 15952 |
rtx note; |
| 15953 |
|
| 15954 |
validate_condition_mode (code, mode); |
| 15955 |
|
| 15956 |
/* Work out which way this really branches. We could use |
| 15957 |
reverse_condition_maybe_unordered here always but this |
| 15958 |
makes the resulting assembler clearer. */ |
| 15959 |
if (really_reversed) |
| 15960 |
{ |
| 15961 |
/* Reversal of FP compares takes care -- an ordered compare |
| 15962 |
becomes an unordered compare and vice versa. */ |
| 15963 |
if (mode == CCFPmode) |
| 15964 |
code = reverse_condition_maybe_unordered (code); |
| 15965 |
else |
| 15966 |
code = reverse_condition (code); |
| 15967 |
} |
| 15968 |
|
| 15969 |
switch (code) |
| 15970 |
{ |
| 15971 |
/* Not all of these are actually distinct opcodes, but |
| 15972 |
we distinguish them for clarity of the resulting assembler. */ |
| 15973 |
case NE: case LTGT: |
| 15974 |
ccode = "ne"; break; |
| 15975 |
case EQ: case UNEQ: |
| 15976 |
ccode = "eq"; break; |
| 15977 |
case GE: case GEU: |
| 15978 |
ccode = "ge"; break; |
| 15979 |
case GT: case GTU: case UNGT: |
| 15980 |
ccode = "gt"; break; |
| 15981 |
case LE: case LEU: |
| 15982 |
ccode = "le"; break; |
| 15983 |
case LT: case LTU: case UNLT: |
| 15984 |
ccode = "lt"; break; |
| 15985 |
case UNORDERED: ccode = "un"; break; |
| 15986 |
case ORDERED: ccode = "nu"; break; |
| 15987 |
case UNGE: ccode = "nl"; break; |
| 15988 |
case UNLE: ccode = "ng"; break; |
| 15989 |
default: |
| 15990 |
gcc_unreachable (); |
| 15991 |
} |
| 15992 |
|
| 15993 |
/* Maybe we have a guess as to how likely the branch is. */ |
| 15994 |
pred = ""; |
| 15995 |
note = find_reg_note (insn, REG_BR_PROB, NULL_RTX); |
| 15996 |
if (note != NULL_RTX) |
| 15997 |
{ |
| 15998 |
/* PROB is the difference from 50%. */ |
| 15999 |
int prob = profile_probability::from_reg_br_prob_note (XINT (note, 0)) |
| 16000 |
.to_reg_br_prob_base () - REG_BR_PROB_BASE / 2; |
| 16001 |
|
| 16002 |
/* Only hint for highly probable/improbable branches on newer cpus when |
| 16003 |
we have real profile data, as static prediction overrides processor |
| 16004 |
dynamic prediction. For older cpus we may as well always hint, but |
| 16005 |
assume not taken for branches that are very close to 50% as a |
| 16006 |
mispredicted taken branch is more expensive than a |
| 16007 |
mispredicted not-taken branch. */ |
| 16008 |
if (rs6000_always_hint |
| 16009 |
|| (abs (prob) > REG_BR_PROB_BASE / 100 * 48 |
| 16010 |
&& (profile_status_for_fn (cfun) != PROFILE_GUESSED) |
| 16011 |
&& br_prob_note_reliable_p (note))) |
| 16012 |
{ |
| 16013 |
if (abs (prob) > REG_BR_PROB_BASE / 20 |
| 16014 |
&& ((prob > 0) ^ need_longbranch)) |
| 16015 |
pred = "+"; |
| 16016 |
else |
| 16017 |
pred = "-"; |
| 16018 |
} |
| 16019 |
} |
| 16020 |
|
| 16021 |
if (label == NULL) |
| 16022 |
s += sprintf (s, "b%slr%s ", ccode, pred); |
| 16023 |
else |
| 16024 |
s += sprintf (s, "b%s%s ", ccode, pred); |
| 16025 |
|
| 16026 |
/* We need to escape any '%' characters in the reg_names string. |
| 16027 |
Assume they'd only be the first character.... */ |
| 16028 |
if (reg_names[cc_regno + CR0_REGNO][0] == '%') |
| 16029 |
*s++ = '%'; |
| 16030 |
s += sprintf (s, "%s", reg_names[cc_regno + CR0_REGNO]); |
| 16031 |
|
| 16032 |
if (label != NULL) |
| 16033 |
{ |
| 16034 |
/* If the branch distance was too far, we may have to use an |
| 16035 |
unconditional branch to go the distance. */ |
| 16036 |
if (need_longbranch) |
| 16037 |
s += sprintf (s, ",$+8\n\tb %s", label); |
| 16038 |
else |
| 16039 |
s += sprintf (s, ",%s", label); |
| 16040 |
} |
| 16041 |
|
| 16042 |
return string; |
| 16043 |
} |
| 16044 |
|
| 16045 |
/* Emit vector compare for operands OP0 and OP1 using code RCODE. |
| 16046 |
DMODE is expected destination mode. */ |
| 16047 |
|
| 16048 |
static rtx |
| 16049 |
rs6000_emit_vector_compare (enum rtx_code rcode, |
| 16050 |
rtx op0, rtx op1, |
| 16051 |
machine_mode dmode) |
| 16052 |
{ |
| 16053 |
gcc_assert (VECTOR_UNIT_ALTIVEC_OR_VSX_P (dmode)); |
| 16054 |
gcc_assert (GET_MODE (op0) == GET_MODE (op1)); |
| 16055 |
rtx mask = gen_reg_rtx (dmode); |
| 16056 |
|
| 16057 |
/* In vector.md, we support all kinds of vector float point |
| 16058 |
comparison operators in a comparison rtl pattern, we can |
| 16059 |
just emit the comparison rtx insn directly here. Besides, |
| 16060 |
we should have a centralized place to handle the possibility |
| 16061 |
of raising invalid exception. */ |
| 16062 |
if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT) |
| 16063 |
{ |
| 16064 |
emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1))); |
| 16065 |
return mask; |
| 16066 |
} |
| 16067 |
|
| 16068 |
bool swap_operands = false; |
| 16069 |
bool need_invert = false; |
| 16070 |
enum rtx_code code = rcode; |
| 16071 |
|
| 16072 |
switch (rcode) |
| 16073 |
{ |
| 16074 |
case EQ: |
| 16075 |
case GT: |
| 16076 |
case GTU: |
| 16077 |
/* Emit directly with native hardware insn. */ |
| 16078 |
break; |
| 16079 |
case LT: |
| 16080 |
case LTU: |
| 16081 |
/* lt{,u}(a,b) = gt{,u}(b,a) */ |
| 16082 |
code = swap_condition (rcode); |
| 16083 |
swap_operands = true; |
| 16084 |
break; |
| 16085 |
case NE: |
| 16086 |
case LE: |
| 16087 |
case LEU: |
| 16088 |
/* ne(a,b) = ~eq(a,b); le{,u}(a,b) = ~gt{,u}(a,b) */ |
| 16089 |
code = reverse_condition (rcode); |
| 16090 |
need_invert = true; |
| 16091 |
break; |
| 16092 |
case GE: |
| 16093 |
/* ge(a,b) = ~gt(b,a) */ |
| 16094 |
code = GT; |
| 16095 |
swap_operands = true; |
| 16096 |
need_invert = true; |
| 16097 |
break; |
| 16098 |
case GEU: |
| 16099 |
/* geu(a,b) = ~gtu(b,a) */ |
| 16100 |
code = GTU; |
| 16101 |
swap_operands = true; |
| 16102 |
need_invert = true; |
| 16103 |
break; |
| 16104 |
default: |
| 16105 |
gcc_unreachable (); |
| 16106 |
break; |
| 16107 |
} |
| 16108 |
|
| 16109 |
if (swap_operands) |
| 16110 |
std::swap (op0, op1); |
| 16111 |
|
| 16112 |
emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1))); |
| 16113 |
|
| 16114 |
if (need_invert) |
| 16115 |
{ |
| 16116 |
enum insn_code nor_code = optab_handler (one_cmpl_optab, dmode); |
| 16117 |
gcc_assert (nor_code != CODE_FOR_nothing); |
| 16118 |
emit_insn (GEN_FCN (nor_code) (mask, mask)); |
| 16119 |
} |
| 16120 |
|
| 16121 |
return mask; |
| 16122 |
} |
| 16123 |
|
| 16124 |
/* Emit vector conditional expression. DEST is destination. OP_TRUE and |
| 16125 |
OP_FALSE are two VEC_COND_EXPR operands. CC_OP0 and CC_OP1 are the two |
| 16126 |
operands for the relation operation COND. */ |
| 16127 |
|
| 16128 |
static int |
| 16129 |
rs6000_emit_vector_cond_expr (rtx dest, rtx op_true, rtx op_false, |
| 16130 |
rtx cond, rtx cc_op0, rtx cc_op1) |
| 16131 |
{ |
| 16132 |
machine_mode dest_mode = GET_MODE (dest); |
| 16133 |
machine_mode mask_mode = GET_MODE (cc_op0); |
| 16134 |
enum rtx_code rcode = GET_CODE (cond); |
| 16135 |
rtx mask; |
| 16136 |
bool invert_move = false; |
| 16137 |
|
| 16138 |
if (VECTOR_UNIT_NONE_P (dest_mode)) |
| 16139 |
return 0; |
| 16140 |
|
| 16141 |
gcc_assert (GET_MODE_SIZE (dest_mode) == GET_MODE_SIZE (mask_mode) |
| 16142 |
&& GET_MODE_NUNITS (dest_mode) == GET_MODE_NUNITS (mask_mode)); |
| 16143 |
|
| 16144 |
switch (rcode) |
| 16145 |
{ |
| 16146 |
/* Swap operands if we can, and fall back to doing the operation as |
| 16147 |
specified, and doing a NOR to invert the test. */ |
| 16148 |
case NE: |
| 16149 |
case UNLE: |
| 16150 |
case UNLT: |
| 16151 |
case UNGE: |
| 16152 |
case UNGT: |
| 16153 |
/* Invert condition and try again. |
| 16154 |
e.g., A = (B != C) ? D : E becomes A = (B == C) ? E : D. */ |
| 16155 |
invert_move = true; |
| 16156 |
rcode = reverse_condition_maybe_unordered (rcode); |
| 16157 |
if (rcode == UNKNOWN) |
| 16158 |
return 0; |
| 16159 |
break; |
| 16160 |
|
| 16161 |
case GE: |
| 16162 |
case LE: |
| 16163 |
if (GET_MODE_CLASS (mask_mode) == MODE_VECTOR_INT) |
| 16164 |
{ |
| 16165 |
/* Invert condition to avoid compound test. */ |
| 16166 |
invert_move = true; |
| 16167 |
rcode = reverse_condition (rcode); |
| 16168 |
} |
| 16169 |
break; |
| 16170 |
|
| 16171 |
case GTU: |
| 16172 |
case GEU: |
| 16173 |
case LTU: |
| 16174 |
case LEU: |
| 16175 |
|
| 16176 |
/* Invert condition to avoid compound test if necessary. */ |
| 16177 |
if (rcode == GEU || rcode == LEU) |
| 16178 |
{ |
| 16179 |
invert_move = true; |
| 16180 |
rcode = reverse_condition (rcode); |
| 16181 |
} |
| 16182 |
break; |
| 16183 |
|
| 16184 |
default: |
| 16185 |
break; |
| 16186 |
} |
| 16187 |
|
| 16188 |
/* Get the vector mask for the given relational operations. */ |
| 16189 |
mask = rs6000_emit_vector_compare (rcode, cc_op0, cc_op1, mask_mode); |
| 16190 |
|
| 16191 |
if (!mask) |
| 16192 |
return 0; |
| 16193 |
|
| 16194 |
if (mask_mode != dest_mode) |
| 16195 |
mask = simplify_gen_subreg (dest_mode, mask, mask_mode, 0); |
| 16196 |
|
| 16197 |
if (invert_move) |
| 16198 |
std::swap (op_true, op_false); |
| 16199 |
|
| 16200 |
/* Optimize vec1 == vec2, to know the mask generates -1/0. */ |
| 16201 |
if (GET_MODE_CLASS (dest_mode) == MODE_VECTOR_INT |
| 16202 |
&& (GET_CODE (op_true) == CONST_VECTOR |
| 16203 |
|| GET_CODE (op_false) == CONST_VECTOR)) |
| 16204 |
{ |
| 16205 |
rtx constant_0 = CONST0_RTX (dest_mode); |
| 16206 |
rtx constant_m1 = CONSTM1_RTX (dest_mode); |
| 16207 |
|
| 16208 |
if (op_true == constant_m1 && op_false == constant_0) |
| 16209 |
{ |
| 16210 |
emit_move_insn (dest, mask); |
| 16211 |
return 1; |
| 16212 |
} |
| 16213 |
|
| 16214 |
else if (op_true == constant_0 && op_false == constant_m1) |
| 16215 |
{ |
| 16216 |
emit_insn (gen_rtx_SET (dest, gen_rtx_NOT (dest_mode, mask))); |
| 16217 |
return 1; |
| 16218 |
} |
| 16219 |
|
| 16220 |
/* If we can't use the vector comparison directly, perhaps we can use |
| 16221 |
the mask for the true or false fields, instead of loading up a |
| 16222 |
constant. */ |
| 16223 |
if (op_true == constant_m1) |
| 16224 |
op_true = mask; |
| 16225 |
|
| 16226 |
if (op_false == constant_0) |
| 16227 |
op_false = mask; |
| 16228 |
} |
| 16229 |
|
| 16230 |
if (!REG_P (op_true) && !SUBREG_P (op_true)) |
| 16231 |
op_true = force_reg (dest_mode, op_true); |
| 16232 |
|
| 16233 |
if (!REG_P (op_false) && !SUBREG_P (op_false)) |
| 16234 |
op_false = force_reg (dest_mode, op_false); |
| 16235 |
|
| 16236 |
rtx tmp = gen_rtx_IOR (dest_mode, |
| 16237 |
gen_rtx_AND (dest_mode, gen_rtx_NOT (dest_mode, mask), |
| 16238 |
op_false), |
| 16239 |
gen_rtx_AND (dest_mode, mask, op_true)); |
| 16240 |
emit_insn (gen_rtx_SET (dest, tmp)); |
| 16241 |
return 1; |
| 16242 |
} |
| 16243 |
|
| 16244 |
/* Possibly emit the xsmaxc{dp,qp} and xsminc{dp,qp} instructions to emit a |
| 16245 |
maximum or minimum with "C" semantics. |
| 16246 |
|
| 16247 |
Unless you use -ffast-math, you can't use these instructions to replace |
| 16248 |
conditions that implicitly reverse the condition because the comparison |
| 16249 |
might generate a NaN or signed zer0. |
| 16250 |
|
| 16251 |
I.e. the following can be replaced all of the time |
| 16252 |
ret = (op1 > op2) ? op1 : op2 ; generate xsmaxcdp |
| 16253 |
ret = (op1 >= op2) ? op1 : op2 ; generate xsmaxcdp |
| 16254 |
ret = (op1 < op2) ? op1 : op2; ; generate xsmincdp |
| 16255 |
ret = (op1 <= op2) ? op1 : op2; ; generate xsmincdp |
| 16256 |
|
| 16257 |
The following can be replaced only if -ffast-math is used: |
| 16258 |
ret = (op1 < op2) ? op2 : op1 ; generate xsmaxcdp |
| 16259 |
ret = (op1 <= op2) ? op2 : op1 ; generate xsmaxcdp |
| 16260 |
ret = (op1 > op2) ? op2 : op1; ; generate xsmincdp |
| 16261 |
ret = (op1 >= op2) ? op2 : op1; ; generate xsmincdp |
| 16262 |
|
| 16263 |
Move TRUE_COND to DEST if OP of the operands of the last comparison is |
| 16264 |
nonzero/true, FALSE_COND if it is zero/false. |
| 16265 |
|
| 16266 |
Return false if we can't generate the appropriate minimum or maximum, and |
| 16267 |
true if we can did the minimum or maximum. */ |
| 16268 |
|
| 16269 |
static bool |
| 16270 |
rs6000_maybe_emit_maxc_minc (rtx dest, rtx op, rtx true_cond, rtx false_cond) |
| 16271 |
{ |
| 16272 |
enum rtx_code code = GET_CODE (op); |
| 16273 |
rtx op0 = XEXP (op, 0); |
| 16274 |
rtx op1 = XEXP (op, 1); |
| 16275 |
machine_mode compare_mode = GET_MODE (op0); |
| 16276 |
machine_mode result_mode = GET_MODE (dest); |
| 16277 |
|
| 16278 |
if (result_mode != compare_mode) |
| 16279 |
return false; |
| 16280 |
|
| 16281 |
/* See the comments of this function, it simply expects GE/GT/LE/LT in |
| 16282 |
the checks, but for the reversible equivalent UNLT/UNLE/UNGT/UNGE, |
| 16283 |
we need to do the reversions first to make the following checks |
| 16284 |
support fewer cases, like: |
| 16285 |
|
| 16286 |
(a UNLT b) ? op1 : op2 => (a >= b) ? op2 : op1; |
| 16287 |
(a UNLE b) ? op1 : op2 => (a > b) ? op2 : op1; |
| 16288 |
(a UNGT b) ? op1 : op2 => (a <= b) ? op2 : op1; |
| 16289 |
(a UNGE b) ? op1 : op2 => (a < b) ? op2 : op1; |
| 16290 |
|
| 16291 |
By the way, if we see these UNLT/UNLE/UNGT/UNGE it's guaranteed |
| 16292 |
that we have 4-way condition codes (LT/GT/EQ/UN), so we do not |
| 16293 |
have to check for fast-math or the like. */ |
| 16294 |
if (code == UNGE || code == UNGT || code == UNLE || code == UNLT) |
| 16295 |
{ |
| 16296 |
code = reverse_condition_maybe_unordered (code); |
| 16297 |
std::swap (true_cond, false_cond); |
| 16298 |
} |
| 16299 |
|
| 16300 |
bool max_p; |
| 16301 |
if (code == GE || code == GT) |
| 16302 |
max_p = true; |
| 16303 |
else if (code == LE || code == LT) |
| 16304 |
max_p = false; |
| 16305 |
else |
| 16306 |
return false; |
| 16307 |
|
| 16308 |
if (rtx_equal_p (op0, true_cond) && rtx_equal_p (op1, false_cond)) |
| 16309 |
; |
| 16310 |
|
| 16311 |
/* Only when NaNs and signed-zeros are not in effect, smax could be |
| 16312 |
used for `op0 < op1 ? op1 : op0`, and smin could be used for |
| 16313 |
`op0 > op1 ? op1 : op0`. */ |
| 16314 |
else if (rtx_equal_p (op1, true_cond) && rtx_equal_p (op0, false_cond) |
| 16315 |
&& !HONOR_NANS (compare_mode) && !HONOR_SIGNED_ZEROS (compare_mode)) |
| 16316 |
max_p = !max_p; |
| 16317 |
|
| 16318 |
else |
| 16319 |
return false; |
| 16320 |
|
| 16321 |
rs6000_emit_minmax (dest, max_p ? SMAX : SMIN, op0, op1); |
| 16322 |
return true; |
| 16323 |
} |
| 16324 |
|
| 16325 |
/* Possibly emit a floating point conditional move by generating a compare that |
| 16326 |
sets a mask instruction and a XXSEL select instruction. |
| 16327 |
|
| 16328 |
Move TRUE_COND to DEST if OP of the operands of the last comparison is |
| 16329 |
nonzero/true, FALSE_COND if it is zero/false. |
| 16330 |
|
| 16331 |
Return false if the operation cannot be generated, and true if we could |
| 16332 |
generate the instruction. */ |
| 16333 |
|
| 16334 |
static bool |
| 16335 |
rs6000_maybe_emit_fp_cmove (rtx dest, rtx op, rtx true_cond, rtx false_cond) |
| 16336 |
{ |
| 16337 |
enum rtx_code code = GET_CODE (op); |
| 16338 |
rtx op0 = XEXP (op, 0); |
| 16339 |
rtx op1 = XEXP (op, 1); |
| 16340 |
machine_mode compare_mode = GET_MODE (op0); |
| 16341 |
machine_mode result_mode = GET_MODE (dest); |
| 16342 |
rtx compare_rtx; |
| 16343 |
rtx cmove_rtx; |
| 16344 |
rtx clobber_rtx; |
| 16345 |
|
| 16346 |
if (!can_create_pseudo_p ()) |
| 16347 |
return 0; |
| 16348 |
|
| 16349 |
/* We allow the comparison to be either SFmode/DFmode and the true/false |
| 16350 |
condition to be either SFmode/DFmode. I.e. we allow: |
| 16351 |
|
| 16352 |
float a, b; |
| 16353 |
double c, d, r; |
| 16354 |
|
| 16355 |
r = (a == b) ? c : d; |
| 16356 |
|
| 16357 |
and: |
| 16358 |
|
| 16359 |
double a, b; |
| 16360 |
float c, d, r; |
| 16361 |
|
| 16362 |
r = (a == b) ? c : d; |
| 16363 |
|
| 16364 |
but we don't allow intermixing the IEEE 128-bit floating point types with |
| 16365 |
the 32/64-bit scalar types. */ |
| 16366 |
|
| 16367 |
if (!(compare_mode == result_mode |
| 16368 |
|| (compare_mode == SFmode && result_mode == DFmode) |
| 16369 |
|| (compare_mode == DFmode && result_mode == SFmode))) |
| 16370 |
return false; |
| 16371 |
|
| 16372 |
switch (code) |
| 16373 |
{ |
| 16374 |
case EQ: |
| 16375 |
case GE: |
| 16376 |
case GT: |
| 16377 |
break; |
| 16378 |
|
| 16379 |
case NE: |
| 16380 |
case LT: |
| 16381 |
case LE: |
| 16382 |
code = swap_condition (code); |
| 16383 |
std::swap (op0, op1); |
| 16384 |
break; |
| 16385 |
|
| 16386 |
default: |
| 16387 |
return false; |
| 16388 |
} |
| 16389 |
|
| 16390 |
/* Generate: [(parallel [(set (dest) |
| 16391 |
(if_then_else (op (cmp1) (cmp2)) |
| 16392 |
(true) |
| 16393 |
(false))) |
| 16394 |
(clobber (scratch))])]. */ |
| 16395 |
|
| 16396 |
compare_rtx = gen_rtx_fmt_ee (code, CCFPmode, op0, op1); |
| 16397 |
cmove_rtx = gen_rtx_SET (dest, |
| 16398 |
gen_rtx_IF_THEN_ELSE (result_mode, |
| 16399 |
compare_rtx, |
| 16400 |
true_cond, |
| 16401 |
false_cond)); |
| 16402 |
|
| 16403 |
clobber_rtx = gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (V2DImode)); |
| 16404 |
emit_insn (gen_rtx_PARALLEL (VOIDmode, |
| 16405 |
gen_rtvec (2, cmove_rtx, clobber_rtx))); |
| 16406 |
|
| 16407 |
return true; |
| 16408 |
} |
| 16409 |
|
| 16410 |
/* Helper function to return true if the target has instructions to do a |
| 16411 |
compare and set mask instruction that can be used with XXSEL to implement a |
| 16412 |
conditional move. It is also assumed that such a target also supports the |
| 16413 |
"C" minimum and maximum instructions. */ |
| 16414 |
|
| 16415 |
static bool |
| 16416 |
have_compare_and_set_mask (machine_mode mode) |
| 16417 |
{ |
| 16418 |
switch (mode) |
| 16419 |
{ |
| 16420 |
case E_SFmode: |
| 16421 |
case E_DFmode: |
| 16422 |
return TARGET_P9_MINMAX; |
| 16423 |
|
| 16424 |
case E_KFmode: |
| 16425 |
case E_TFmode: |
| 16426 |
return TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode); |
| 16427 |
|
| 16428 |
default: |
| 16429 |
break; |
| 16430 |
} |
| 16431 |
|
| 16432 |
return false; |
| 16433 |
} |
| 16434 |
|
| 16435 |
/* Emit a conditional move: move TRUE_COND to DEST if OP of the |
| 16436 |
operands of the last comparison is nonzero/true, FALSE_COND if it |
| 16437 |
is zero/false. Return 0 if the hardware has no such operation. */ |
| 16438 |
|
| 16439 |
bool |
| 16440 |
rs6000_emit_cmove (rtx dest, rtx op, rtx true_cond, rtx false_cond) |
| 16441 |
{ |
| 16442 |
enum rtx_code code = GET_CODE (op); |
| 16443 |
rtx op0 = XEXP (op, 0); |
| 16444 |
rtx op1 = XEXP (op, 1); |
| 16445 |
machine_mode compare_mode = GET_MODE (op0); |
| 16446 |
machine_mode result_mode = GET_MODE (dest); |
| 16447 |
rtx temp; |
| 16448 |
bool is_against_zero; |
| 16449 |
|
| 16450 |
/* These modes should always match. */ |
| 16451 |
if (GET_MODE (op1) != compare_mode |
| 16452 |
/* In the isel case however, we can use a compare immediate, so |
| 16453 |
op1 may be a small constant. */ |
| 16454 |
&& (!TARGET_ISEL || !short_cint_operand (op1, VOIDmode))) |
| 16455 |
return false; |
| 16456 |
if (GET_MODE (true_cond) != result_mode) |
| 16457 |
return false; |
| 16458 |
if (GET_MODE (false_cond) != result_mode) |
| 16459 |
return false; |
| 16460 |
|
| 16461 |
/* See if we can use the "C" minimum, "C" maximum, and compare and set mask |
| 16462 |
instructions. */ |
| 16463 |
if (have_compare_and_set_mask (compare_mode) |
| 16464 |
&& have_compare_and_set_mask (result_mode)) |
| 16465 |
{ |
| 16466 |
if (rs6000_maybe_emit_maxc_minc (dest, op, true_cond, false_cond)) |
| 16467 |
return true; |
| 16468 |
|
| 16469 |
if (rs6000_maybe_emit_fp_cmove (dest, op, true_cond, false_cond)) |
| 16470 |
return true; |
| 16471 |
} |
| 16472 |
|
| 16473 |
/* Don't allow using floating point comparisons for integer results for |
| 16474 |
now. */ |
| 16475 |
if (FLOAT_MODE_P (compare_mode) && !FLOAT_MODE_P (result_mode)) |
| 16476 |
return false; |
| 16477 |
|
| 16478 |
/* First, work out if the hardware can do this at all, or |
| 16479 |
if it's too slow.... */ |
| 16480 |
if (!FLOAT_MODE_P (compare_mode)) |
| 16481 |
{ |
| 16482 |
if (TARGET_ISEL) |
| 16483 |
return rs6000_emit_int_cmove (dest, op, true_cond, false_cond); |
| 16484 |
return false; |
| 16485 |
} |
| 16486 |
|
| 16487 |
is_against_zero = op1 == CONST0_RTX (compare_mode); |
| 16488 |
|
| 16489 |
/* A floating-point subtract might overflow, underflow, or produce |
| 16490 |
an inexact result, thus changing the floating-point flags, so it |
| 16491 |
can't be generated if we care about that. It's safe if one side |
| 16492 |
of the construct is zero, since then no subtract will be |
| 16493 |
generated. */ |
| 16494 |
if (SCALAR_FLOAT_MODE_P (compare_mode) |
| 16495 |
&& flag_trapping_math && ! is_against_zero) |
| 16496 |
return false; |
| 16497 |
|
| 16498 |
/* Eliminate half of the comparisons by switching operands, this |
| 16499 |
makes the remaining code simpler. */ |
| 16500 |
if (code == UNLT || code == UNGT || code == UNORDERED || code == NE |
| 16501 |
|| code == LTGT || code == LT || code == UNLE) |
| 16502 |
{ |
| 16503 |
code = reverse_condition_maybe_unordered (code); |
| 16504 |
temp = true_cond; |
| 16505 |
true_cond = false_cond; |
| 16506 |
false_cond = temp; |
| 16507 |
} |
| 16508 |
|
| 16509 |
/* UNEQ and LTGT take four instructions for a comparison with zero, |
| 16510 |
it'll probably be faster to use a branch here too. */ |
| 16511 |
if (code == UNEQ && HONOR_NANS (compare_mode)) |
| 16512 |
return false; |
| 16513 |
|
| 16514 |
/* We're going to try to implement comparisons by performing |
| 16515 |
a subtract, then comparing against zero. Unfortunately, |
| 16516 |
Inf - Inf is NaN which is not zero, and so if we don't |
| 16517 |
know that the operand is finite and the comparison |
| 16518 |
would treat EQ different to UNORDERED, we can't do it. */ |
| 16519 |
if (HONOR_INFINITIES (compare_mode) |
| 16520 |
&& code != GT && code != UNGE |
| 16521 |
&& (!CONST_DOUBLE_P (op1) |
| 16522 |
|| real_isinf (CONST_DOUBLE_REAL_VALUE (op1))) |
| 16523 |
/* Constructs of the form (a OP b ? a : b) are safe. */ |
| 16524 |
&& ((! rtx_equal_p (op0, false_cond) && ! rtx_equal_p (op1, false_cond)) |
| 16525 |
|| (! rtx_equal_p (op0, true_cond) |
| 16526 |
&& ! rtx_equal_p (op1, true_cond)))) |
| 16527 |
return false; |
| 16528 |
|
| 16529 |
/* At this point we know we can use fsel. */ |
| 16530 |
|
| 16531 |
/* Don't allow compare_mode other than SFmode or DFmode, for others there |
| 16532 |
is no fsel instruction. */ |
| 16533 |
if (compare_mode != SFmode && compare_mode != DFmode) |
| 16534 |
return false; |
| 16535 |
|
| 16536 |
/* Reduce the comparison to a comparison against zero. */ |
| 16537 |
if (! is_against_zero) |
| 16538 |
{ |
| 16539 |
temp = gen_reg_rtx (compare_mode); |
| 16540 |
emit_insn (gen_rtx_SET (temp, gen_rtx_MINUS (compare_mode, op0, op1))); |
| 16541 |
op0 = temp; |
| 16542 |
op1 = CONST0_RTX (compare_mode); |
| 16543 |
} |
| 16544 |
|
| 16545 |
/* If we don't care about NaNs we can reduce some of the comparisons |
| 16546 |
down to faster ones. */ |
| 16547 |
if (! HONOR_NANS (compare_mode)) |
| 16548 |
switch (code) |
| 16549 |
{ |
| 16550 |
case GT: |
| 16551 |
code = LE; |
| 16552 |
temp = true_cond; |
| 16553 |
true_cond = false_cond; |
| 16554 |
false_cond = temp; |
| 16555 |
break; |
| 16556 |
case UNGE: |
| 16557 |
code = GE; |
| 16558 |
break; |
| 16559 |
case UNEQ: |
| 16560 |
code = EQ; |
| 16561 |
break; |
| 16562 |
default: |
| 16563 |
break; |
| 16564 |
} |
| 16565 |
|
| 16566 |
/* Now, reduce everything down to a GE. */ |
| 16567 |
switch (code) |
| 16568 |
{ |
| 16569 |
case GE: |
| 16570 |
break; |
| 16571 |
|
| 16572 |
case LE: |
| 16573 |
temp = gen_reg_rtx (compare_mode); |
| 16574 |
emit_insn (gen_rtx_SET (temp, gen_rtx_NEG (compare_mode, op0))); |
| 16575 |
op0 = temp; |
| 16576 |
break; |
| 16577 |
|
| 16578 |
case ORDERED: |
| 16579 |
temp = gen_reg_rtx (compare_mode); |
| 16580 |
emit_insn (gen_rtx_SET (temp, gen_rtx_ABS (compare_mode, op0))); |
| 16581 |
op0 = temp; |
| 16582 |
break; |
| 16583 |
|
| 16584 |
case EQ: |
| 16585 |
temp = gen_reg_rtx (compare_mode); |
| 16586 |
emit_insn (gen_rtx_SET (temp, |
| 16587 |
gen_rtx_NEG (compare_mode, |
| 16588 |
gen_rtx_ABS (compare_mode, op0)))); |
| 16589 |
op0 = temp; |
| 16590 |
break; |
| 16591 |
|
| 16592 |
case UNGE: |
| 16593 |
/* a UNGE 0 <-> (a GE 0 || -a UNLT 0) */ |
| 16594 |
temp = gen_reg_rtx (result_mode); |
| 16595 |
emit_insn (gen_rtx_SET (temp, |
| 16596 |
gen_rtx_IF_THEN_ELSE (result_mode, |
| 16597 |
gen_rtx_GE (VOIDmode, |
| 16598 |
op0, op1), |
| 16599 |
true_cond, false_cond))); |
| 16600 |
false_cond = true_cond; |
| 16601 |
true_cond = temp; |
| 16602 |
|
| 16603 |
temp = gen_reg_rtx (compare_mode); |
| 16604 |
emit_insn (gen_rtx_SET (temp, gen_rtx_NEG (compare_mode, op0))); |
| 16605 |
op0 = temp; |
| 16606 |
break; |
| 16607 |
|
| 16608 |
case GT: |
| 16609 |
/* a GT 0 <-> (a GE 0 && -a UNLT 0) */ |
| 16610 |
temp = gen_reg_rtx (result_mode); |
| 16611 |
emit_insn (gen_rtx_SET (temp, |
| 16612 |
gen_rtx_IF_THEN_ELSE (result_mode, |
| 16613 |
gen_rtx_GE (VOIDmode, |
| 16614 |
op0, op1), |
| 16615 |
true_cond, false_cond))); |
| 16616 |
true_cond = false_cond; |
| 16617 |
false_cond = temp; |
| 16618 |
|
| 16619 |
temp = gen_reg_rtx (compare_mode); |
| 16620 |
emit_insn (gen_rtx_SET (temp, gen_rtx_NEG (compare_mode, op0))); |
| 16621 |
op0 = temp; |
| 16622 |
break; |
| 16623 |
|
| 16624 |
default: |
| 16625 |
gcc_unreachable (); |
| 16626 |
} |
| 16627 |
|
| 16628 |
emit_insn (gen_rtx_SET (dest, |
| 16629 |
gen_rtx_IF_THEN_ELSE (result_mode, |
| 16630 |
gen_rtx_GE (VOIDmode, |
| 16631 |
op0, op1), |
| 16632 |
true_cond, false_cond))); |
| 16633 |
return true; |
| 16634 |
} |
| 16635 |
|
| 16636 |
/* Same as above, but for ints (isel). */ |
| 16637 |
|
| 16638 |
bool |
| 16639 |
rs6000_emit_int_cmove (rtx dest, rtx op, rtx true_cond, rtx false_cond) |
| 16640 |
{ |
| 16641 |
rtx condition_rtx, cr; |
| 16642 |
machine_mode mode = GET_MODE (dest); |
| 16643 |
enum rtx_code cond_code; |
| 16644 |
rtx (*isel_func) (rtx, rtx, rtx, rtx, rtx); |
| 16645 |
bool signedp; |
| 16646 |
|
| 16647 |
if (mode != SImode && (!TARGET_POWERPC64 || mode != DImode)) |
| 16648 |
return false; |
| 16649 |
|
| 16650 |
/* PR104335: We now need to expect CC-mode "comparisons" |
| 16651 |
coming from ifcvt. The following code expects proper |
| 16652 |
comparisons so better abort here. */ |
| 16653 |
if (GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC) |
| 16654 |
return false; |
| 16655 |
|
| 16656 |
/* We still have to do the compare, because isel doesn't do a |
| 16657 |
compare, it just looks at the CRx bits set by a previous compare |
| 16658 |
instruction. */ |
| 16659 |
condition_rtx = rs6000_generate_compare (op, mode); |
| 16660 |
cond_code = GET_CODE (condition_rtx); |
| 16661 |
cr = XEXP (condition_rtx, 0); |
| 16662 |
signedp = GET_MODE (cr) == CCmode; |
| 16663 |
|
| 16664 |
isel_func = (mode == SImode |
| 16665 |
? (signedp ? gen_isel_cc_si : gen_isel_ccuns_si) |
| 16666 |
: (signedp ? gen_isel_cc_di : gen_isel_ccuns_di)); |
| 16667 |
|
| 16668 |
switch (cond_code) |
| 16669 |
{ |
| 16670 |
case LT: case GT: case LTU: case GTU: case EQ: |
| 16671 |
/* isel handles these directly. */ |
| 16672 |
break; |
| 16673 |
|
| 16674 |
default: |
| 16675 |
/* We need to swap the sense of the comparison. */ |
| 16676 |
{ |
| 16677 |
std::swap (false_cond, true_cond); |
| 16678 |
PUT_CODE (condition_rtx, reverse_condition (cond_code)); |
| 16679 |
} |
| 16680 |
break; |
| 16681 |
} |
| 16682 |
|
| 16683 |
false_cond = force_reg (mode, false_cond); |
| 16684 |
if (true_cond != const0_rtx) |
| 16685 |
true_cond = force_reg (mode, true_cond); |
| 16686 |
|
| 16687 |
emit_insn (isel_func (dest, condition_rtx, true_cond, false_cond, cr)); |
| 16688 |
|
| 16689 |
return true; |
| 16690 |
} |
| 16691 |
|
| 16692 |
void |
| 16693 |
rs6000_emit_minmax (rtx dest, enum rtx_code code, rtx op0, rtx op1) |
| 16694 |
{ |
| 16695 |
machine_mode mode = GET_MODE (op0); |
| 16696 |
enum rtx_code c; |
| 16697 |
rtx target; |
| 16698 |
|
| 16699 |
/* VSX/altivec have direct min/max insns. */ |
| 16700 |
if ((code == SMAX || code == SMIN) |
| 16701 |
&& (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode) |
| 16702 |
|| (mode == SFmode && VECTOR_UNIT_VSX_P (DFmode)) |
| 16703 |
|| (TARGET_POWER10 && TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)))) |
| 16704 |
{ |
| 16705 |
emit_insn (gen_rtx_SET (dest, gen_rtx_fmt_ee (code, mode, op0, op1))); |
| 16706 |
return; |
| 16707 |
} |
| 16708 |
|
| 16709 |
if (code == SMAX || code == SMIN) |
| 16710 |
c = GE; |
| 16711 |
else |
| 16712 |
c = GEU; |
| 16713 |
|
| 16714 |
if (code == SMAX || code == UMAX) |
| 16715 |
target = emit_conditional_move (dest, { c, op0, op1, mode }, |
| 16716 |
op0, op1, mode, 0); |
| 16717 |
else |
| 16718 |
target = emit_conditional_move (dest, { c, op0, op1, mode }, |
| 16719 |
op1, op0, mode, 0); |
| 16720 |
gcc_assert (target); |
| 16721 |
if (target != dest) |
| 16722 |
emit_move_insn (dest, target); |
| 16723 |
} |
| 16724 |
|
| 16725 |
/* A subroutine of the atomic operation splitters. Jump to LABEL if |
| 16726 |
COND is true. Mark the jump as unlikely to be taken. */ |
| 16727 |
|
| 16728 |
static void |
| 16729 |
emit_unlikely_jump (rtx cond, rtx label) |
| 16730 |
{ |
| 16731 |
rtx x = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label, pc_rtx); |
| 16732 |
rtx_insn *insn = emit_jump_insn (gen_rtx_SET (pc_rtx, x)); |
| 16733 |
add_reg_br_prob_note (insn, profile_probability::very_unlikely ()); |
| 16734 |
} |
| 16735 |
|
| 16736 |
/* A subroutine of the atomic operation splitters. Emit a load-locked |
| 16737 |
instruction in MODE. For QI/HImode, possibly use a pattern than includes |
| 16738 |
the zero_extend operation. */ |
| 16739 |
|
| 16740 |
static void |
| 16741 |
emit_load_locked (machine_mode mode, rtx reg, rtx mem) |
| 16742 |
{ |
| 16743 |
rtx (*fn) (rtx, rtx) = NULL; |
| 16744 |
|
| 16745 |
switch (mode) |
| 16746 |
{ |
| 16747 |
case E_QImode: |
| 16748 |
fn = gen_load_lockedqi; |
| 16749 |
break; |
| 16750 |
case E_HImode: |
| 16751 |
fn = gen_load_lockedhi; |
| 16752 |
break; |
| 16753 |
case E_SImode: |
| 16754 |
if (GET_MODE (mem) == QImode) |
| 16755 |
fn = gen_load_lockedqi_si; |
| 16756 |
else if (GET_MODE (mem) == HImode) |
| 16757 |
fn = gen_load_lockedhi_si; |
| 16758 |
else |
| 16759 |
fn = gen_load_lockedsi; |
| 16760 |
break; |
| 16761 |
case E_DImode: |
| 16762 |
fn = gen_load_lockeddi; |
| 16763 |
break; |
| 16764 |
case E_TImode: |
| 16765 |
fn = gen_load_lockedti; |
| 16766 |
break; |
| 16767 |
default: |
| 16768 |
gcc_unreachable (); |
| 16769 |
} |
| 16770 |
emit_insn (fn (reg, mem)); |
| 16771 |
} |
| 16772 |
|
| 16773 |
/* A subroutine of the atomic operation splitters. Emit a store-conditional |
| 16774 |
instruction in MODE. */ |
| 16775 |
|
| 16776 |
static void |
| 16777 |
emit_store_conditional (machine_mode mode, rtx res, rtx mem, rtx val) |
| 16778 |
{ |
| 16779 |
rtx (*fn) (rtx, rtx, rtx) = NULL; |
| 16780 |
|
| 16781 |
switch (mode) |
| 16782 |
{ |
| 16783 |
case E_QImode: |
| 16784 |
fn = gen_store_conditionalqi; |
| 16785 |
break; |
| 16786 |
case E_HImode: |
| 16787 |
fn = gen_store_conditionalhi; |
| 16788 |
break; |
| 16789 |
case E_SImode: |
| 16790 |
fn = gen_store_conditionalsi; |
| 16791 |
break; |
| 16792 |
case E_DImode: |
| 16793 |
fn = gen_store_conditionaldi; |
| 16794 |
break; |
| 16795 |
case E_TImode: |
| 16796 |
fn = gen_store_conditionalti; |
| 16797 |
break; |
| 16798 |
default: |
| 16799 |
gcc_unreachable (); |
| 16800 |
} |
| 16801 |
|
| 16802 |
/* Emit sync before stwcx. to address PPC405 Erratum. */ |
| 16803 |
if (PPC405_ERRATUM77) |
| 16804 |
emit_insn (gen_hwsync ()); |
| 16805 |
|
| 16806 |
emit_insn (fn (res, mem, val)); |
| 16807 |
} |
| 16808 |
|
| 16809 |
/* Expand barriers before and after a load_locked/store_cond sequence. */ |
| 16810 |
|
| 16811 |
static rtx |
| 16812 |
rs6000_pre_atomic_barrier (rtx mem, enum memmodel model) |
| 16813 |
{ |
| 16814 |
rtx addr = XEXP (mem, 0); |
| 16815 |
|
| 16816 |
if (!legitimate_indirect_address_p (addr, reload_completed) |
| 16817 |
&& !legitimate_indexed_address_p (addr, reload_completed)) |
| 16818 |
{ |
| 16819 |
addr = force_reg (Pmode, addr); |
| 16820 |
mem = replace_equiv_address_nv (mem, addr); |
| 16821 |
} |
| 16822 |
|
| 16823 |
switch (model) |
| 16824 |
{ |
| 16825 |
case MEMMODEL_RELAXED: |
| 16826 |
case MEMMODEL_CONSUME: |
| 16827 |
case MEMMODEL_ACQUIRE: |
| 16828 |
break; |
| 16829 |
case MEMMODEL_RELEASE: |
| 16830 |
case MEMMODEL_ACQ_REL: |
| 16831 |
emit_insn (gen_lwsync ()); |
| 16832 |
break; |
| 16833 |
case MEMMODEL_SEQ_CST: |
| 16834 |
emit_insn (gen_hwsync ()); |
| 16835 |
break; |
| 16836 |
default: |
| 16837 |
gcc_unreachable (); |
| 16838 |
} |
| 16839 |
return mem; |
| 16840 |
} |
| 16841 |
|
| 16842 |
static void |
| 16843 |
rs6000_post_atomic_barrier (enum memmodel model) |
| 16844 |
{ |
| 16845 |
switch (model) |
| 16846 |
{ |
| 16847 |
case MEMMODEL_RELAXED: |
| 16848 |
case MEMMODEL_CONSUME: |
| 16849 |
case MEMMODEL_RELEASE: |
| 16850 |
break; |
| 16851 |
case MEMMODEL_ACQUIRE: |
| 16852 |
case MEMMODEL_ACQ_REL: |
| 16853 |
case MEMMODEL_SEQ_CST: |
| 16854 |
emit_insn (gen_isync ()); |
| 16855 |
break; |
| 16856 |
default: |
| 16857 |
gcc_unreachable (); |
| 16858 |
} |
| 16859 |
} |
| 16860 |
|
| 16861 |
/* A subroutine of the various atomic expanders. For sub-word operations, |
| 16862 |
we must adjust things to operate on SImode. Given the original MEM, |
| 16863 |
return a new aligned memory. Also build and return the quantities by |
| 16864 |
which to shift and mask. */ |
| 16865 |
|
| 16866 |
static rtx |
| 16867 |
rs6000_adjust_atomic_subword (rtx orig_mem, rtx *pshift, rtx *pmask) |
| 16868 |
{ |
| 16869 |
rtx addr, align, shift, mask, mem; |
| 16870 |
HOST_WIDE_INT shift_mask; |
| 16871 |
machine_mode mode = GET_MODE (orig_mem); |
| 16872 |
|
| 16873 |
/* For smaller modes, we have to implement this via SImode. */ |
| 16874 |
shift_mask = (mode == QImode ? 0x18 : 0x10); |
| 16875 |
|
| 16876 |
addr = XEXP (orig_mem, 0); |
| 16877 |
addr = force_reg (GET_MODE (addr), addr); |
| 16878 |
|
| 16879 |
/* Aligned memory containing subword. Generate a new memory. We |
| 16880 |
do not want any of the existing MEM_ATTR data, as we're now |
| 16881 |
accessing memory outside the original object. */ |
| 16882 |
align = expand_simple_binop (Pmode, AND, addr, GEN_INT (-4), |
| 16883 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 16884 |
mem = gen_rtx_MEM (SImode, align); |
| 16885 |
MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (orig_mem); |
| 16886 |
if (MEM_ALIAS_SET (orig_mem) == ALIAS_SET_MEMORY_BARRIER) |
| 16887 |
set_mem_alias_set (mem, ALIAS_SET_MEMORY_BARRIER); |
| 16888 |
|
| 16889 |
/* Shift amount for subword relative to aligned word. */ |
| 16890 |
shift = gen_reg_rtx (SImode); |
| 16891 |
addr = gen_lowpart (SImode, addr); |
| 16892 |
rtx tmp = gen_reg_rtx (SImode); |
| 16893 |
emit_insn (gen_ashlsi3 (tmp, addr, GEN_INT (3))); |
| 16894 |
emit_insn (gen_andsi3 (shift, tmp, GEN_INT (shift_mask))); |
| 16895 |
if (BYTES_BIG_ENDIAN) |
| 16896 |
shift = expand_simple_binop (SImode, XOR, shift, GEN_INT (shift_mask), |
| 16897 |
shift, 1, OPTAB_LIB_WIDEN); |
| 16898 |
*pshift = shift; |
| 16899 |
|
| 16900 |
/* Mask for insertion. */ |
| 16901 |
mask = expand_simple_binop (SImode, ASHIFT, GEN_INT (GET_MODE_MASK (mode)), |
| 16902 |
shift, NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 16903 |
*pmask = mask; |
| 16904 |
|
| 16905 |
return mem; |
| 16906 |
} |
| 16907 |
|
| 16908 |
/* A subroutine of the various atomic expanders. For sub-word operands, |
| 16909 |
combine OLDVAL and NEWVAL via MASK. Returns a new pseduo. */ |
| 16910 |
|
| 16911 |
static rtx |
| 16912 |
rs6000_mask_atomic_subword (rtx oldval, rtx newval, rtx mask) |
| 16913 |
{ |
| 16914 |
rtx x; |
| 16915 |
|
| 16916 |
x = gen_reg_rtx (SImode); |
| 16917 |
emit_insn (gen_rtx_SET (x, gen_rtx_AND (SImode, |
| 16918 |
gen_rtx_NOT (SImode, mask), |
| 16919 |
oldval))); |
| 16920 |
|
| 16921 |
x = expand_simple_binop (SImode, IOR, newval, x, x, 1, OPTAB_LIB_WIDEN); |
| 16922 |
|
| 16923 |
return x; |
| 16924 |
} |
| 16925 |
|
| 16926 |
/* A subroutine of the various atomic expanders. For sub-word operands, |
| 16927 |
extract WIDE to NARROW via SHIFT. */ |
| 16928 |
|
| 16929 |
static void |
| 16930 |
rs6000_finish_atomic_subword (rtx narrow, rtx wide, rtx shift) |
| 16931 |
{ |
| 16932 |
wide = expand_simple_binop (SImode, LSHIFTRT, wide, shift, |
| 16933 |
wide, 1, OPTAB_LIB_WIDEN); |
| 16934 |
emit_move_insn (narrow, gen_lowpart (GET_MODE (narrow), wide)); |
| 16935 |
} |
| 16936 |
|
| 16937 |
/* Expand an atomic compare and swap operation. */ |
| 16938 |
|
| 16939 |
void |
| 16940 |
rs6000_expand_atomic_compare_and_swap (rtx operands[]) |
| 16941 |
{ |
| 16942 |
rtx boolval, retval, mem, oldval, newval, cond; |
| 16943 |
rtx label1, label2, x, mask, shift; |
| 16944 |
machine_mode mode, orig_mode; |
| 16945 |
enum memmodel mod_s, mod_f; |
| 16946 |
bool is_weak; |
| 16947 |
|
| 16948 |
boolval = operands[0]; |
| 16949 |
retval = operands[1]; |
| 16950 |
mem = operands[2]; |
| 16951 |
oldval = operands[3]; |
| 16952 |
newval = operands[4]; |
| 16953 |
is_weak = (INTVAL (operands[5]) != 0); |
| 16954 |
mod_s = memmodel_base (INTVAL (operands[6])); |
| 16955 |
mod_f = memmodel_base (INTVAL (operands[7])); |
| 16956 |
orig_mode = mode = GET_MODE (mem); |
| 16957 |
|
| 16958 |
mask = shift = NULL_RTX; |
| 16959 |
if (mode == QImode || mode == HImode) |
| 16960 |
{ |
| 16961 |
/* Before power8, we didn't have access to lbarx/lharx, so generate a |
| 16962 |
lwarx and shift/mask operations. With power8, we need to do the |
| 16963 |
comparison in SImode, but the store is still done in QI/HImode. */ |
| 16964 |
oldval = convert_modes (SImode, mode, oldval, 1); |
| 16965 |
|
| 16966 |
if (!TARGET_SYNC_HI_QI) |
| 16967 |
{ |
| 16968 |
mem = rs6000_adjust_atomic_subword (mem, &shift, &mask); |
| 16969 |
|
| 16970 |
/* Shift and mask OLDVAL into position with the word. */ |
| 16971 |
oldval = expand_simple_binop (SImode, ASHIFT, oldval, shift, |
| 16972 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 16973 |
|
| 16974 |
/* Shift and mask NEWVAL into position within the word. */ |
| 16975 |
newval = convert_modes (SImode, mode, newval, 1); |
| 16976 |
newval = expand_simple_binop (SImode, ASHIFT, newval, shift, |
| 16977 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 16978 |
} |
| 16979 |
|
| 16980 |
/* Prepare to adjust the return value. */ |
| 16981 |
retval = gen_reg_rtx (SImode); |
| 16982 |
mode = SImode; |
| 16983 |
} |
| 16984 |
else if (reg_overlap_mentioned_p (retval, oldval)) |
| 16985 |
oldval = copy_to_reg (oldval); |
| 16986 |
|
| 16987 |
if (mode != TImode && !reg_or_short_operand (oldval, mode)) |
| 16988 |
oldval = copy_to_mode_reg (mode, oldval); |
| 16989 |
|
| 16990 |
if (reg_overlap_mentioned_p (retval, newval)) |
| 16991 |
newval = copy_to_reg (newval); |
| 16992 |
|
| 16993 |
mem = rs6000_pre_atomic_barrier (mem, mod_s); |
| 16994 |
|
| 16995 |
label1 = NULL_RTX; |
| 16996 |
if (!is_weak) |
| 16997 |
{ |
| 16998 |
label1 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); |
| 16999 |
emit_label (XEXP (label1, 0)); |
| 17000 |
} |
| 17001 |
label2 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); |
| 17002 |
|
| 17003 |
emit_load_locked (mode, retval, mem); |
| 17004 |
|
| 17005 |
x = retval; |
| 17006 |
if (mask) |
| 17007 |
x = expand_simple_binop (SImode, AND, retval, mask, |
| 17008 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 17009 |
|
| 17010 |
cond = gen_reg_rtx (CCmode); |
| 17011 |
/* If we have TImode, synthesize a comparison. */ |
| 17012 |
if (mode != TImode) |
| 17013 |
x = gen_rtx_COMPARE (CCmode, x, oldval); |
| 17014 |
else |
| 17015 |
{ |
| 17016 |
rtx xor1_result = gen_reg_rtx (DImode); |
| 17017 |
rtx xor2_result = gen_reg_rtx (DImode); |
| 17018 |
rtx or_result = gen_reg_rtx (DImode); |
| 17019 |
rtx new_word0 = simplify_gen_subreg (DImode, x, TImode, 0); |
| 17020 |
rtx new_word1 = simplify_gen_subreg (DImode, x, TImode, 8); |
| 17021 |
rtx old_word0 = simplify_gen_subreg (DImode, oldval, TImode, 0); |
| 17022 |
rtx old_word1 = simplify_gen_subreg (DImode, oldval, TImode, 8); |
| 17023 |
|
| 17024 |
emit_insn (gen_xordi3 (xor1_result, new_word0, old_word0)); |
| 17025 |
emit_insn (gen_xordi3 (xor2_result, new_word1, old_word1)); |
| 17026 |
emit_insn (gen_iordi3 (or_result, xor1_result, xor2_result)); |
| 17027 |
x = gen_rtx_COMPARE (CCmode, or_result, const0_rtx); |
| 17028 |
} |
| 17029 |
|
| 17030 |
emit_insn (gen_rtx_SET (cond, x)); |
| 17031 |
|
| 17032 |
x = gen_rtx_NE (VOIDmode, cond, const0_rtx); |
| 17033 |
emit_unlikely_jump (x, label2); |
| 17034 |
|
| 17035 |
x = newval; |
| 17036 |
if (mask) |
| 17037 |
x = rs6000_mask_atomic_subword (retval, newval, mask); |
| 17038 |
|
| 17039 |
emit_store_conditional (orig_mode, cond, mem, x); |
| 17040 |
|
| 17041 |
if (!is_weak) |
| 17042 |
{ |
| 17043 |
x = gen_rtx_NE (VOIDmode, cond, const0_rtx); |
| 17044 |
emit_unlikely_jump (x, label1); |
| 17045 |
} |
| 17046 |
|
| 17047 |
if (!is_mm_relaxed (mod_f)) |
| 17048 |
emit_label (XEXP (label2, 0)); |
| 17049 |
|
| 17050 |
rs6000_post_atomic_barrier (mod_s); |
| 17051 |
|
| 17052 |
if (is_mm_relaxed (mod_f)) |
| 17053 |
emit_label (XEXP (label2, 0)); |
| 17054 |
|
| 17055 |
if (shift) |
| 17056 |
rs6000_finish_atomic_subword (operands[1], retval, shift); |
| 17057 |
else if (mode != GET_MODE (operands[1])) |
| 17058 |
convert_move (operands[1], retval, 1); |
| 17059 |
|
| 17060 |
/* In all cases, CR0 contains EQ on success, and NE on failure. */ |
| 17061 |
x = gen_rtx_EQ (SImode, cond, const0_rtx); |
| 17062 |
emit_insn (gen_rtx_SET (boolval, x)); |
| 17063 |
} |
| 17064 |
|
| 17065 |
/* Expand an atomic exchange operation. */ |
| 17066 |
|
| 17067 |
void |
| 17068 |
rs6000_expand_atomic_exchange (rtx operands[]) |
| 17069 |
{ |
| 17070 |
rtx retval, mem, val, cond; |
| 17071 |
machine_mode mode; |
| 17072 |
enum memmodel model; |
| 17073 |
rtx label, x, mask, shift; |
| 17074 |
|
| 17075 |
retval = operands[0]; |
| 17076 |
mem = operands[1]; |
| 17077 |
val = operands[2]; |
| 17078 |
model = memmodel_base (INTVAL (operands[3])); |
| 17079 |
mode = GET_MODE (mem); |
| 17080 |
|
| 17081 |
mask = shift = NULL_RTX; |
| 17082 |
if (!TARGET_SYNC_HI_QI && (mode == QImode || mode == HImode)) |
| 17083 |
{ |
| 17084 |
mem = rs6000_adjust_atomic_subword (mem, &shift, &mask); |
| 17085 |
|
| 17086 |
/* Shift and mask VAL into position with the word. */ |
| 17087 |
val = convert_modes (SImode, mode, val, 1); |
| 17088 |
val = expand_simple_binop (SImode, ASHIFT, val, shift, |
| 17089 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 17090 |
|
| 17091 |
/* Prepare to adjust the return value. */ |
| 17092 |
retval = gen_reg_rtx (SImode); |
| 17093 |
mode = SImode; |
| 17094 |
} |
| 17095 |
|
| 17096 |
mem = rs6000_pre_atomic_barrier (mem, model); |
| 17097 |
|
| 17098 |
label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); |
| 17099 |
emit_label (XEXP (label, 0)); |
| 17100 |
|
| 17101 |
emit_load_locked (mode, retval, mem); |
| 17102 |
|
| 17103 |
x = val; |
| 17104 |
if (mask) |
| 17105 |
x = rs6000_mask_atomic_subword (retval, val, mask); |
| 17106 |
|
| 17107 |
cond = gen_reg_rtx (CCmode); |
| 17108 |
emit_store_conditional (mode, cond, mem, x); |
| 17109 |
|
| 17110 |
x = gen_rtx_NE (VOIDmode, cond, const0_rtx); |
| 17111 |
emit_unlikely_jump (x, label); |
| 17112 |
|
| 17113 |
rs6000_post_atomic_barrier (model); |
| 17114 |
|
| 17115 |
if (shift) |
| 17116 |
rs6000_finish_atomic_subword (operands[0], retval, shift); |
| 17117 |
} |
| 17118 |
|
| 17119 |
/* Expand an atomic fetch-and-operate pattern. CODE is the binary operation |
| 17120 |
to perform. MEM is the memory on which to operate. VAL is the second |
| 17121 |
operand of the binary operator. BEFORE and AFTER are optional locations to |
| 17122 |
return the value of MEM either before of after the operation. MODEL_RTX |
| 17123 |
is a CONST_INT containing the memory model to use. */ |
| 17124 |
|
| 17125 |
void |
| 17126 |
rs6000_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, |
| 17127 |
rtx orig_before, rtx orig_after, rtx model_rtx) |
| 17128 |
{ |
| 17129 |
enum memmodel model = memmodel_base (INTVAL (model_rtx)); |
| 17130 |
machine_mode mode = GET_MODE (mem); |
| 17131 |
machine_mode store_mode = mode; |
| 17132 |
rtx label, x, cond, mask, shift; |
| 17133 |
rtx before = orig_before, after = orig_after; |
| 17134 |
|
| 17135 |
mask = shift = NULL_RTX; |
| 17136 |
/* On power8, we want to use SImode for the operation. On previous systems, |
| 17137 |
use the operation in a subword and shift/mask to get the proper byte or |
| 17138 |
halfword. */ |
| 17139 |
if (mode == QImode || mode == HImode) |
| 17140 |
{ |
| 17141 |
if (TARGET_SYNC_HI_QI) |
| 17142 |
{ |
| 17143 |
val = convert_modes (SImode, mode, val, 1); |
| 17144 |
|
| 17145 |
/* Prepare to adjust the return value. */ |
| 17146 |
before = gen_reg_rtx (SImode); |
| 17147 |
if (after) |
| 17148 |
after = gen_reg_rtx (SImode); |
| 17149 |
mode = SImode; |
| 17150 |
} |
| 17151 |
else |
| 17152 |
{ |
| 17153 |
mem = rs6000_adjust_atomic_subword (mem, &shift, &mask); |
| 17154 |
|
| 17155 |
/* Shift and mask VAL into position with the word. */ |
| 17156 |
val = convert_modes (SImode, mode, val, 1); |
| 17157 |
val = expand_simple_binop (SImode, ASHIFT, val, shift, |
| 17158 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 17159 |
|
| 17160 |
switch (code) |
| 17161 |
{ |
| 17162 |
case IOR: |
| 17163 |
case XOR: |
| 17164 |
/* We've already zero-extended VAL. That is sufficient to |
| 17165 |
make certain that it does not affect other bits. */ |
| 17166 |
mask = NULL; |
| 17167 |
break; |
| 17168 |
|
| 17169 |
case AND: |
| 17170 |
/* If we make certain that all of the other bits in VAL are |
| 17171 |
set, that will be sufficient to not affect other bits. */ |
| 17172 |
x = gen_rtx_NOT (SImode, mask); |
| 17173 |
x = gen_rtx_IOR (SImode, x, val); |
| 17174 |
emit_insn (gen_rtx_SET (val, x)); |
| 17175 |
mask = NULL; |
| 17176 |
break; |
| 17177 |
|
| 17178 |
case NOT: |
| 17179 |
case PLUS: |
| 17180 |
case MINUS: |
| 17181 |
/* These will all affect bits outside the field and need |
| 17182 |
adjustment via MASK within the loop. */ |
| 17183 |
break; |
| 17184 |
|
| 17185 |
default: |
| 17186 |
gcc_unreachable (); |
| 17187 |
} |
| 17188 |
|
| 17189 |
/* Prepare to adjust the return value. */ |
| 17190 |
before = gen_reg_rtx (SImode); |
| 17191 |
if (after) |
| 17192 |
after = gen_reg_rtx (SImode); |
| 17193 |
store_mode = mode = SImode; |
| 17194 |
} |
| 17195 |
} |
| 17196 |
|
| 17197 |
mem = rs6000_pre_atomic_barrier (mem, model); |
| 17198 |
|
| 17199 |
label = gen_label_rtx (); |
| 17200 |
emit_label (label); |
| 17201 |
label = gen_rtx_LABEL_REF (VOIDmode, label); |
| 17202 |
|
| 17203 |
if (before == NULL_RTX) |
| 17204 |
before = gen_reg_rtx (mode); |
| 17205 |
|
| 17206 |
emit_load_locked (mode, before, mem); |
| 17207 |
|
| 17208 |
if (code == NOT) |
| 17209 |
{ |
| 17210 |
x = expand_simple_binop (mode, AND, before, val, |
| 17211 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 17212 |
after = expand_simple_unop (mode, NOT, x, after, 1); |
| 17213 |
} |
| 17214 |
else |
| 17215 |
{ |
| 17216 |
after = expand_simple_binop (mode, code, before, val, |
| 17217 |
after, 1, OPTAB_LIB_WIDEN); |
| 17218 |
} |
| 17219 |
|
| 17220 |
x = after; |
| 17221 |
if (mask) |
| 17222 |
{ |
| 17223 |
x = expand_simple_binop (SImode, AND, after, mask, |
| 17224 |
NULL_RTX, 1, OPTAB_LIB_WIDEN); |
| 17225 |
x = rs6000_mask_atomic_subword (before, x, mask); |
| 17226 |
} |
| 17227 |
else if (store_mode != mode) |
| 17228 |
x = convert_modes (store_mode, mode, x, 1); |
| 17229 |
|
| 17230 |
cond = gen_reg_rtx (CCmode); |
| 17231 |
emit_store_conditional (store_mode, cond, mem, x); |
| 17232 |
|
| 17233 |
x = gen_rtx_NE (VOIDmode, cond, const0_rtx); |
| 17234 |
emit_unlikely_jump (x, label); |
| 17235 |
|
| 17236 |
rs6000_post_atomic_barrier (model); |
| 17237 |
|
| 17238 |
if (shift) |
| 17239 |
{ |
| 17240 |
/* QImode/HImode on machines without lbarx/lharx where we do a lwarx and |
| 17241 |
then do the calcuations in a SImode register. */ |
| 17242 |
if (orig_before) |
| 17243 |
rs6000_finish_atomic_subword (orig_before, before, shift); |
| 17244 |
if (orig_after) |
| 17245 |
rs6000_finish_atomic_subword (orig_after, after, shift); |
| 17246 |
} |
| 17247 |
else if (store_mode != mode) |
| 17248 |
{ |
| 17249 |
/* QImode/HImode on machines with lbarx/lharx where we do the native |
| 17250 |
operation and then do the calcuations in a SImode register. */ |
| 17251 |
if (orig_before) |
| 17252 |
convert_move (orig_before, before, 1); |
| 17253 |
if (orig_after) |
| 17254 |
convert_move (orig_after, after, 1); |
| 17255 |
} |
| 17256 |
else if (orig_after && after != orig_after) |
| 17257 |
emit_move_insn (orig_after, after); |
| 17258 |
} |
| 17259 |
|
| 17260 |
static GTY(()) alias_set_type TOC_alias_set = -1; |
| 17261 |
|
| 17262 |
alias_set_type |
| 17263 |
get_TOC_alias_set (void) |
| 17264 |
{ |
| 17265 |
if (TOC_alias_set == -1) |
| 17266 |
TOC_alias_set = new_alias_set (); |
| 17267 |
return TOC_alias_set; |
| 17268 |
} |
| 17269 |
|
| 17270 |
/* The mode the ABI uses for a word. This is not the same as word_mode |
| 17271 |
for -m32 -mpowerpc64. This is used to implement various target hooks. */ |
| 17272 |
|
| 17273 |
static scalar_int_mode |
| 17274 |
rs6000_abi_word_mode (void) |
| 17275 |
{ |
| 17276 |
return TARGET_32BIT ? SImode : DImode; |
| 17277 |
} |
| 17278 |
|
| 17279 |
/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ |
| 17280 |
static char * |
| 17281 |
rs6000_offload_options (void) |
| 17282 |
{ |
| 17283 |
if (TARGET_64BIT) |
| 17284 |
return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-m64"); |
| 17285 |
else |
| 17286 |
return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-m32"); |
| 17287 |
} |
| 17288 |
|
| 17289 |
|
| 17290 |
/* A quick summary of the various types of 'constant-pool tables' |
| 17291 |
under PowerPC: |
| 17292 |
|
| 17293 |
Target Flags Name One table per |
| 17294 |
AIX (none) AIX TOC object file |
| 17295 |
AIX -mfull-toc AIX TOC object file |
| 17296 |
AIX -mminimal-toc AIX minimal TOC translation unit |
| 17297 |
SVR4/EABI (none) SVR4 SDATA object file |
| 17298 |
SVR4/EABI -fpic SVR4 pic object file |
| 17299 |
SVR4/EABI -fPIC SVR4 PIC translation unit |
| 17300 |
SVR4/EABI -mrelocatable EABI TOC function |
| 17301 |
SVR4/EABI -maix AIX TOC object file |
| 17302 |
SVR4/EABI -maix -mminimal-toc |
| 17303 |
AIX minimal TOC translation unit |
| 17304 |
|
| 17305 |
Name Reg. Set by entries contains: |
| 17306 |
made by addrs? fp? sum? |
| 17307 |
|
| 17308 |
AIX TOC 2 crt0 as Y option option |
| 17309 |
AIX minimal TOC 30 prolog gcc Y Y option |
| 17310 |
SVR4 SDATA 13 crt0 gcc N Y N |
| 17311 |
SVR4 pic 30 prolog ld Y not yet N |
| 17312 |
SVR4 PIC 30 prolog gcc Y option option |
| 17313 |
EABI TOC 30 prolog gcc Y option option |
| 17314 |
|
| 17315 |
*/ |
| 17316 |
|
| 17317 |
/* Hash functions for the hash table. */ |
| 17318 |
|
| 17319 |
static unsigned |
| 17320 |
rs6000_hash_constant (rtx k) |
| 17321 |
{ |
| 17322 |
enum rtx_code code = GET_CODE (k); |
| 17323 |
machine_mode mode = GET_MODE (k); |
| 17324 |
unsigned result = (code << 3) ^ mode; |
| 17325 |
const char *format; |
| 17326 |
int flen, fidx; |
| 17327 |
|
| 17328 |
format = GET_RTX_FORMAT (code); |
| 17329 |
flen = strlen (format); |
| 17330 |
fidx = 0; |
| 17331 |
|
| 17332 |
switch (code) |
| 17333 |
{ |
| 17334 |
case LABEL_REF: |
| 17335 |
return result * 1231 + (unsigned) INSN_UID (XEXP (k, 0)); |
| 17336 |
|
| 17337 |
case CONST_WIDE_INT: |
| 17338 |
{ |
| 17339 |
int i; |
| 17340 |
flen = CONST_WIDE_INT_NUNITS (k); |
| 17341 |
for (i = 0; i < flen; i++) |
| 17342 |
result = result * 613 + CONST_WIDE_INT_ELT (k, i); |
| 17343 |
return result; |
| 17344 |
} |
| 17345 |
|
| 17346 |
case CONST_DOUBLE: |
| 17347 |
return real_hash (CONST_DOUBLE_REAL_VALUE (k)) * result; |
| 17348 |
|
| 17349 |
case CODE_LABEL: |
| 17350 |
fidx = 3; |
| 17351 |
break; |
| 17352 |
|
| 17353 |
default: |
| 17354 |
break; |
| 17355 |
} |
| 17356 |
|
| 17357 |
for (; fidx < flen; fidx++) |
| 17358 |
switch (format[fidx]) |
| 17359 |
{ |
| 17360 |
case 's': |
| 17361 |
{ |
| 17362 |
unsigned i, len; |
| 17363 |
const char *str = XSTR (k, fidx); |
| 17364 |
len = strlen (str); |
| 17365 |
result = result * 613 + len; |
| 17366 |
for (i = 0; i < len; i++) |
| 17367 |
result = result * 613 + (unsigned) str[i]; |
| 17368 |
break; |
| 17369 |
} |
| 17370 |
case 'u': |
| 17371 |
case 'e': |
| 17372 |
result = result * 1231 + rs6000_hash_constant (XEXP (k, fidx)); |
| 17373 |
break; |
| 17374 |
case 'i': |
| 17375 |
case 'n': |
| 17376 |
result = result * 613 + (unsigned) XINT (k, fidx); |
| 17377 |
break; |
| 17378 |
case 'w': |
| 17379 |
case 'L': |
| 17380 |
{ |
| 17381 |
const HOST_WIDE_INT val |
| 17382 |
= (format[fidx] == 'L' ? XLOC (k, fidx) : XWINT (k, fidx)); |
| 17383 |
if (sizeof (unsigned) >= sizeof (HOST_WIDE_INT)) |
| 17384 |
result = result * 613 + (unsigned) val; |
| 17385 |
else |
| 17386 |
{ |
| 17387 |
size_t i; |
| 17388 |
for (i = 0; i < sizeof (HOST_WIDE_INT) / sizeof (unsigned); i++) |
| 17389 |
result = result * 613 + (unsigned) (val |
| 17390 |
>> CHAR_BIT * i); |
| 17391 |
} |
| 17392 |
break; |
| 17393 |
} |
| 17394 |
case '0': |
| 17395 |
break; |
| 17396 |
default: |
| 17397 |
gcc_unreachable (); |
| 17398 |
} |
| 17399 |
|
| 17400 |
return result; |
| 17401 |
} |
| 17402 |
|
| 17403 |
hashval_t |
| 17404 |
toc_hasher::hash (toc_hash_struct *thc) |
| 17405 |
{ |
| 17406 |
return rs6000_hash_constant (thc->key) ^ thc->key_mode; |
| 17407 |
} |
| 17408 |
|
| 17409 |
/* Compare H1 and H2 for equivalence. */ |
| 17410 |
|
| 17411 |
bool |
| 17412 |
toc_hasher::equal (toc_hash_struct *h1, toc_hash_struct *h2) |
| 17413 |
{ |
| 17414 |
rtx r1 = h1->key; |
| 17415 |
rtx r2 = h2->key; |
| 17416 |
|
| 17417 |
if (h1->key_mode != h2->key_mode) |
| 17418 |
return 0; |
| 17419 |
|
| 17420 |
return rtx_equal_p (r1, r2); |
| 17421 |
} |
| 17422 |
|
| 17423 |
/* These are the names given by the C++ front-end to vtables, and |
| 17424 |
vtable-like objects. Ideally, this logic should not be here; |
| 17425 |
instead, there should be some programmatic way of inquiring as |
| 17426 |
to whether or not an object is a vtable. */ |
| 17427 |
|
| 17428 |
#define VTABLE_NAME_P(NAME) \ |
| 17429 |
(startswith (name, "_vt.") \ |
| 17430 |
|| startswith (name, "_ZTV") \ |
| 17431 |
|| startswith (name, "_ZTT") \ |
| 17432 |
|| startswith (name, "_ZTI") \ |
| 17433 |
|| startswith (name, "_ZTC")) |
| 17434 |
|
| 17435 |
#ifdef NO_DOLLAR_IN_LABEL |
| 17436 |
/* Return a GGC-allocated character string translating dollar signs in |
| 17437 |
input NAME to underscores. Used by XCOFF ASM_OUTPUT_LABELREF. */ |
| 17438 |
|
| 17439 |
const char * |
| 17440 |
rs6000_xcoff_strip_dollar (const char *name) |
| 17441 |
{ |
| 17442 |
char *strip, *p; |
| 17443 |
const char *q; |
| 17444 |
size_t len; |
| 17445 |
|
| 17446 |
q = (const char *) strchr (name, '$'); |
| 17447 |
|
| 17448 |
if (q == 0 || q == name) |
| 17449 |
return name; |
| 17450 |
|
| 17451 |
len = strlen (name); |
| 17452 |
strip = XALLOCAVEC (char, len + 1); |
| 17453 |
strcpy (strip, name); |
| 17454 |
p = strip + (q - name); |
| 17455 |
while (p) |
| 17456 |
{ |
| 17457 |
*p = '_'; |
| 17458 |
p = strchr (p + 1, '$'); |
| 17459 |
} |
| 17460 |
|
| 17461 |
return ggc_alloc_string (strip, len); |
| 17462 |
} |
| 17463 |
#endif |
| 17464 |
|
| 17465 |
void |
| 17466 |
rs6000_output_symbol_ref (FILE *file, rtx x) |
| 17467 |
{ |
| 17468 |
const char *name = XSTR (x, 0); |
| 17469 |
|
| 17470 |
/* Currently C++ toc references to vtables can be emitted before it |
| 17471 |
is decided whether the vtable is public or private. If this is |
| 17472 |
the case, then the linker will eventually complain that there is |
| 17473 |
a reference to an unknown section. Thus, for vtables only, |
| 17474 |
we emit the TOC reference to reference the identifier and not the |
| 17475 |
symbol. */ |
| 17476 |
if (VTABLE_NAME_P (name)) |
| 17477 |
{ |
| 17478 |
RS6000_OUTPUT_BASENAME (file, name); |
| 17479 |
} |
| 17480 |
else |
| 17481 |
assemble_name (file, name); |
| 17482 |
} |
| 17483 |
|
| 17484 |
/* Output a TOC entry. We derive the entry name from what is being |
| 17485 |
written. */ |
| 17486 |
|
| 17487 |
void |
| 17488 |
output_toc (FILE *file, rtx x, int labelno, machine_mode mode) |
| 17489 |
{ |
| 17490 |
char buf[256]; |
| 17491 |
const char *name = buf; |
| 17492 |
rtx base = x; |
| 17493 |
HOST_WIDE_INT offset = 0; |
| 17494 |
|
| 17495 |
gcc_assert (!TARGET_NO_TOC_OR_PCREL); |
| 17496 |
|
| 17497 |
/* When the linker won't eliminate them, don't output duplicate |
| 17498 |
TOC entries (this happens on AIX if there is any kind of TOC, |
| 17499 |
and on SVR4 under -fPIC or -mrelocatable). Don't do this for |
| 17500 |
CODE_LABELs. */ |
| 17501 |
if (TARGET_TOC && GET_CODE (x) != LABEL_REF) |
| 17502 |
{ |
| 17503 |
struct toc_hash_struct *h; |
| 17504 |
|
| 17505 |
/* Create toc_hash_table. This can't be done at TARGET_OPTION_OVERRIDE |
| 17506 |
time because GGC is not initialized at that point. */ |
| 17507 |
if (toc_hash_table == NULL) |
| 17508 |
toc_hash_table = hash_table<toc_hasher>::create_ggc (1021); |
| 17509 |
|
| 17510 |
h = ggc_alloc<toc_hash_struct> (); |
| 17511 |
h->key = x; |
| 17512 |
h->key_mode = mode; |
| 17513 |
h->labelno = labelno; |
| 17514 |
|
| 17515 |
toc_hash_struct **found = toc_hash_table->find_slot (h, INSERT); |
| 17516 |
if (*found == NULL) |
| 17517 |
*found = h; |
| 17518 |
else /* This is indeed a duplicate. |
| 17519 |
Set this label equal to that label. */ |
| 17520 |
{ |
| 17521 |
fputs ("\t.set ", file); |
| 17522 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LC"); |
| 17523 |
fprintf (file, "%d,", labelno); |
| 17524 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LC"); |
| 17525 |
fprintf (file, "%d\n", ((*found)->labelno)); |
| 17526 |
|
| 17527 |
#ifdef HAVE_AS_TLS |
| 17528 |
if (TARGET_XCOFF && SYMBOL_REF_P (x) |
| 17529 |
&& (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_GLOBAL_DYNAMIC |
| 17530 |
|| SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC)) |
| 17531 |
{ |
| 17532 |
fputs ("\t.set ", file); |
| 17533 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LCM"); |
| 17534 |
fprintf (file, "%d,", labelno); |
| 17535 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LCM"); |
| 17536 |
fprintf (file, "%d\n", ((*found)->labelno)); |
| 17537 |
} |
| 17538 |
#endif |
| 17539 |
return; |
| 17540 |
} |
| 17541 |
} |
| 17542 |
|
| 17543 |
/* If we're going to put a double constant in the TOC, make sure it's |
| 17544 |
aligned properly when strict alignment is on. */ |
| 17545 |
if ((CONST_DOUBLE_P (x) || CONST_WIDE_INT_P (x)) |
| 17546 |
&& STRICT_ALIGNMENT |
| 17547 |
&& GET_MODE_BITSIZE (mode) >= 64 |
| 17548 |
&& ! (TARGET_NO_FP_IN_TOC && ! TARGET_MINIMAL_TOC)) { |
| 17549 |
ASM_OUTPUT_ALIGN (file, 3); |
| 17550 |
} |
| 17551 |
|
| 17552 |
(*targetm.asm_out.internal_label) (file, "LC", labelno); |
| 17553 |
|
| 17554 |
/* Handle FP constants specially. Note that if we have a minimal |
| 17555 |
TOC, things we put here aren't actually in the TOC, so we can allow |
| 17556 |
FP constants. */ |
| 17557 |
if (CONST_DOUBLE_P (x) |
| 17558 |
&& (GET_MODE (x) == TFmode || GET_MODE (x) == TDmode |
| 17559 |
|| GET_MODE (x) == IFmode || GET_MODE (x) == KFmode)) |
| 17560 |
{ |
| 17561 |
long k[4]; |
| 17562 |
|
| 17563 |
if (DECIMAL_FLOAT_MODE_P (GET_MODE (x))) |
| 17564 |
REAL_VALUE_TO_TARGET_DECIMAL128 (*CONST_DOUBLE_REAL_VALUE (x), k); |
| 17565 |
else |
| 17566 |
real_to_target (k, CONST_DOUBLE_REAL_VALUE (x), GET_MODE (x)); |
| 17567 |
|
| 17568 |
if (TARGET_64BIT) |
| 17569 |
{ |
| 17570 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17571 |
fputs (DOUBLE_INT_ASM_OP, file); |
| 17572 |
else |
| 17573 |
fprintf (file, "\t.tc FT_%lx_%lx_%lx_%lx[TC],", |
| 17574 |
k[0] & 0xffffffff, k[1] & 0xffffffff, |
| 17575 |
k[2] & 0xffffffff, k[3] & 0xffffffff); |
| 17576 |
fprintf (file, "0x%lx%08lx,0x%lx%08lx\n", |
| 17577 |
k[WORDS_BIG_ENDIAN ? 0 : 1] & 0xffffffff, |
| 17578 |
k[WORDS_BIG_ENDIAN ? 1 : 0] & 0xffffffff, |
| 17579 |
k[WORDS_BIG_ENDIAN ? 2 : 3] & 0xffffffff, |
| 17580 |
k[WORDS_BIG_ENDIAN ? 3 : 2] & 0xffffffff); |
| 17581 |
return; |
| 17582 |
} |
| 17583 |
else |
| 17584 |
{ |
| 17585 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17586 |
fputs ("\t.long ", file); |
| 17587 |
else |
| 17588 |
fprintf (file, "\t.tc FT_%lx_%lx_%lx_%lx[TC],", |
| 17589 |
k[0] & 0xffffffff, k[1] & 0xffffffff, |
| 17590 |
k[2] & 0xffffffff, k[3] & 0xffffffff); |
| 17591 |
fprintf (file, "0x%lx,0x%lx,0x%lx,0x%lx\n", |
| 17592 |
k[0] & 0xffffffff, k[1] & 0xffffffff, |
| 17593 |
k[2] & 0xffffffff, k[3] & 0xffffffff); |
| 17594 |
return; |
| 17595 |
} |
| 17596 |
} |
| 17597 |
else if (CONST_DOUBLE_P (x) |
| 17598 |
&& (GET_MODE (x) == DFmode || GET_MODE (x) == DDmode)) |
| 17599 |
{ |
| 17600 |
long k[2]; |
| 17601 |
|
| 17602 |
if (DECIMAL_FLOAT_MODE_P (GET_MODE (x))) |
| 17603 |
REAL_VALUE_TO_TARGET_DECIMAL64 (*CONST_DOUBLE_REAL_VALUE (x), k); |
| 17604 |
else |
| 17605 |
REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), k); |
| 17606 |
|
| 17607 |
if (TARGET_64BIT) |
| 17608 |
{ |
| 17609 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17610 |
fputs (DOUBLE_INT_ASM_OP, file); |
| 17611 |
else |
| 17612 |
fprintf (file, "\t.tc FD_%lx_%lx[TC],", |
| 17613 |
k[0] & 0xffffffff, k[1] & 0xffffffff); |
| 17614 |
fprintf (file, "0x%lx%08lx\n", |
| 17615 |
k[WORDS_BIG_ENDIAN ? 0 : 1] & 0xffffffff, |
| 17616 |
k[WORDS_BIG_ENDIAN ? 1 : 0] & 0xffffffff); |
| 17617 |
return; |
| 17618 |
} |
| 17619 |
else |
| 17620 |
{ |
| 17621 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17622 |
fputs ("\t.long ", file); |
| 17623 |
else |
| 17624 |
fprintf (file, "\t.tc FD_%lx_%lx[TC],", |
| 17625 |
k[0] & 0xffffffff, k[1] & 0xffffffff); |
| 17626 |
fprintf (file, "0x%lx,0x%lx\n", |
| 17627 |
k[0] & 0xffffffff, k[1] & 0xffffffff); |
| 17628 |
return; |
| 17629 |
} |
| 17630 |
} |
| 17631 |
else if (CONST_DOUBLE_P (x) |
| 17632 |
&& (GET_MODE (x) == SFmode || GET_MODE (x) == SDmode)) |
| 17633 |
{ |
| 17634 |
long l; |
| 17635 |
|
| 17636 |
if (DECIMAL_FLOAT_MODE_P (GET_MODE (x))) |
| 17637 |
REAL_VALUE_TO_TARGET_DECIMAL32 (*CONST_DOUBLE_REAL_VALUE (x), l); |
| 17638 |
else |
| 17639 |
REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l); |
| 17640 |
|
| 17641 |
if (TARGET_64BIT) |
| 17642 |
{ |
| 17643 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17644 |
fputs (DOUBLE_INT_ASM_OP, file); |
| 17645 |
else |
| 17646 |
fprintf (file, "\t.tc FS_%lx[TC],", l & 0xffffffff); |
| 17647 |
if (WORDS_BIG_ENDIAN) |
| 17648 |
fprintf (file, "0x%lx00000000\n", l & 0xffffffff); |
| 17649 |
else |
| 17650 |
fprintf (file, "0x%lx\n", l & 0xffffffff); |
| 17651 |
return; |
| 17652 |
} |
| 17653 |
else |
| 17654 |
{ |
| 17655 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17656 |
fputs ("\t.long ", file); |
| 17657 |
else |
| 17658 |
fprintf (file, "\t.tc FS_%lx[TC],", l & 0xffffffff); |
| 17659 |
fprintf (file, "0x%lx\n", l & 0xffffffff); |
| 17660 |
return; |
| 17661 |
} |
| 17662 |
} |
| 17663 |
else if (GET_MODE (x) == VOIDmode && CONST_INT_P (x)) |
| 17664 |
{ |
| 17665 |
unsigned HOST_WIDE_INT low; |
| 17666 |
HOST_WIDE_INT high; |
| 17667 |
|
| 17668 |
low = INTVAL (x) & 0xffffffff; |
| 17669 |
high = (HOST_WIDE_INT) INTVAL (x) >> 32; |
| 17670 |
|
| 17671 |
/* TOC entries are always Pmode-sized, so when big-endian |
| 17672 |
smaller integer constants in the TOC need to be padded. |
| 17673 |
(This is still a win over putting the constants in |
| 17674 |
a separate constant pool, because then we'd have |
| 17675 |
to have both a TOC entry _and_ the actual constant.) |
| 17676 |
|
| 17677 |
For a 32-bit target, CONST_INT values are loaded and shifted |
| 17678 |
entirely within `low' and can be stored in one TOC entry. */ |
| 17679 |
|
| 17680 |
/* It would be easy to make this work, but it doesn't now. */ |
| 17681 |
gcc_assert (!TARGET_64BIT || POINTER_SIZE >= GET_MODE_BITSIZE (mode)); |
| 17682 |
|
| 17683 |
if (WORDS_BIG_ENDIAN && POINTER_SIZE > GET_MODE_BITSIZE (mode)) |
| 17684 |
{ |
| 17685 |
low |= high << 32; |
| 17686 |
low <<= POINTER_SIZE - GET_MODE_BITSIZE (mode); |
| 17687 |
high = (HOST_WIDE_INT) low >> 32; |
| 17688 |
low &= 0xffffffff; |
| 17689 |
} |
| 17690 |
|
| 17691 |
if (TARGET_64BIT) |
| 17692 |
{ |
| 17693 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17694 |
fputs (DOUBLE_INT_ASM_OP, file); |
| 17695 |
else |
| 17696 |
fprintf (file, "\t.tc ID_%lx_%lx[TC],", |
| 17697 |
(long) high & 0xffffffff, (long) low & 0xffffffff); |
| 17698 |
fprintf (file, "0x%lx%08lx\n", |
| 17699 |
(long) high & 0xffffffff, (long) low & 0xffffffff); |
| 17700 |
return; |
| 17701 |
} |
| 17702 |
else |
| 17703 |
{ |
| 17704 |
if (POINTER_SIZE < GET_MODE_BITSIZE (mode)) |
| 17705 |
{ |
| 17706 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17707 |
fputs ("\t.long ", file); |
| 17708 |
else |
| 17709 |
fprintf (file, "\t.tc ID_%lx_%lx[TC],", |
| 17710 |
(long) high & 0xffffffff, (long) low & 0xffffffff); |
| 17711 |
fprintf (file, "0x%lx,0x%lx\n", |
| 17712 |
(long) high & 0xffffffff, (long) low & 0xffffffff); |
| 17713 |
} |
| 17714 |
else |
| 17715 |
{ |
| 17716 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17717 |
fputs ("\t.long ", file); |
| 17718 |
else |
| 17719 |
fprintf (file, "\t.tc IS_%lx[TC],", (long) low & 0xffffffff); |
| 17720 |
fprintf (file, "0x%lx\n", (long) low & 0xffffffff); |
| 17721 |
} |
| 17722 |
return; |
| 17723 |
} |
| 17724 |
} |
| 17725 |
|
| 17726 |
if (GET_CODE (x) == CONST) |
| 17727 |
{ |
| 17728 |
gcc_assert (GET_CODE (XEXP (x, 0)) == PLUS |
| 17729 |
&& CONST_INT_P (XEXP (XEXP (x, 0), 1))); |
| 17730 |
|
| 17731 |
base = XEXP (XEXP (x, 0), 0); |
| 17732 |
offset = INTVAL (XEXP (XEXP (x, 0), 1)); |
| 17733 |
} |
| 17734 |
|
| 17735 |
switch (GET_CODE (base)) |
| 17736 |
{ |
| 17737 |
case SYMBOL_REF: |
| 17738 |
name = XSTR (base, 0); |
| 17739 |
break; |
| 17740 |
|
| 17741 |
case LABEL_REF: |
| 17742 |
ASM_GENERATE_INTERNAL_LABEL (buf, "L", |
| 17743 |
CODE_LABEL_NUMBER (XEXP (base, 0))); |
| 17744 |
break; |
| 17745 |
|
| 17746 |
case CODE_LABEL: |
| 17747 |
ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (base)); |
| 17748 |
break; |
| 17749 |
|
| 17750 |
default: |
| 17751 |
gcc_unreachable (); |
| 17752 |
} |
| 17753 |
|
| 17754 |
if (TARGET_ELF || TARGET_MINIMAL_TOC) |
| 17755 |
fputs (TARGET_32BIT ? "\t.long " : DOUBLE_INT_ASM_OP, file); |
| 17756 |
else |
| 17757 |
{ |
| 17758 |
fputs ("\t.tc ", file); |
| 17759 |
RS6000_OUTPUT_BASENAME (file, name); |
| 17760 |
|
| 17761 |
if (offset < 0) |
| 17762 |
fprintf (file, ".N" HOST_WIDE_INT_PRINT_UNSIGNED, - offset); |
| 17763 |
else if (offset) |
| 17764 |
fprintf (file, ".P" HOST_WIDE_INT_PRINT_UNSIGNED, offset); |
| 17765 |
|
| 17766 |
/* Mark large TOC symbols on AIX with [TE] so they are mapped |
| 17767 |
after other TOC symbols, reducing overflow of small TOC access |
| 17768 |
to [TC] symbols. */ |
| 17769 |
fputs (TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL |
| 17770 |
? "[TE]," : "[TC],", file); |
| 17771 |
} |
| 17772 |
|
| 17773 |
/* Currently C++ toc references to vtables can be emitted before it |
| 17774 |
is decided whether the vtable is public or private. If this is |
| 17775 |
the case, then the linker will eventually complain that there is |
| 17776 |
a TOC reference to an unknown section. Thus, for vtables only, |
| 17777 |
we emit the TOC reference to reference the symbol and not the |
| 17778 |
section. */ |
| 17779 |
if (VTABLE_NAME_P (name)) |
| 17780 |
{ |
| 17781 |
RS6000_OUTPUT_BASENAME (file, name); |
| 17782 |
if (offset < 0) |
| 17783 |
fprintf (file, HOST_WIDE_INT_PRINT_DEC, offset); |
| 17784 |
else if (offset > 0) |
| 17785 |
fprintf (file, "+" HOST_WIDE_INT_PRINT_DEC, offset); |
| 17786 |
} |
| 17787 |
else |
| 17788 |
output_addr_const (file, x); |
| 17789 |
|
| 17790 |
#if HAVE_AS_TLS |
| 17791 |
if (TARGET_XCOFF && SYMBOL_REF_P (base)) |
| 17792 |
{ |
| 17793 |
switch (SYMBOL_REF_TLS_MODEL (base)) |
| 17794 |
{ |
| 17795 |
case 0: |
| 17796 |
break; |
| 17797 |
case TLS_MODEL_LOCAL_EXEC: |
| 17798 |
fputs ("@le", file); |
| 17799 |
break; |
| 17800 |
case TLS_MODEL_INITIAL_EXEC: |
| 17801 |
fputs ("@ie", file); |
| 17802 |
break; |
| 17803 |
/* Use global-dynamic for local-dynamic. */ |
| 17804 |
case TLS_MODEL_GLOBAL_DYNAMIC: |
| 17805 |
case TLS_MODEL_LOCAL_DYNAMIC: |
| 17806 |
putc ('\n', file); |
| 17807 |
(*targetm.asm_out.internal_label) (file, "LCM", labelno); |
| 17808 |
fputs ("\t.tc .", file); |
| 17809 |
RS6000_OUTPUT_BASENAME (file, name); |
| 17810 |
fputs ("[TC],", file); |
| 17811 |
output_addr_const (file, x); |
| 17812 |
fputs ("@m", file); |
| 17813 |
break; |
| 17814 |
default: |
| 17815 |
gcc_unreachable (); |
| 17816 |
} |
| 17817 |
} |
| 17818 |
#endif |
| 17819 |
|
| 17820 |
putc ('\n', file); |
| 17821 |
} |
| 17822 |
|
| 17823 |
/* Output an assembler pseudo-op to write an ASCII string of N characters |
| 17824 |
starting at P to FILE. |
| 17825 |
|
| 17826 |
On the RS/6000, we have to do this using the .byte operation and |
| 17827 |
write out special characters outside the quoted string. |
| 17828 |
Also, the assembler is broken; very long strings are truncated, |
| 17829 |
so we must artificially break them up early. */ |
| 17830 |
|
| 17831 |
void |
| 17832 |
output_ascii (FILE *file, const char *p, int n) |
| 17833 |
{ |
| 17834 |
char c; |
| 17835 |
int i, count_string; |
| 17836 |
const char *for_string = "\t.byte \""; |
| 17837 |
const char *for_decimal = "\t.byte "; |
| 17838 |
const char *to_close = NULL; |
| 17839 |
|
| 17840 |
count_string = 0; |
| 17841 |
for (i = 0; i < n; i++) |
| 17842 |
{ |
| 17843 |
c = *p++; |
| 17844 |
if (c >= ' ' && c < 0177) |
| 17845 |
{ |
| 17846 |
if (for_string) |
| 17847 |
fputs (for_string, file); |
| 17848 |
putc (c, file); |
| 17849 |
|
| 17850 |
/* Write two quotes to get one. */ |
| 17851 |
if (c == '"') |
| 17852 |
{ |
| 17853 |
putc (c, file); |
| 17854 |
++count_string; |
| 17855 |
} |
| 17856 |
|
| 17857 |
for_string = NULL; |
| 17858 |
for_decimal = "\"\n\t.byte "; |
| 17859 |
to_close = "\"\n"; |
| 17860 |
++count_string; |
| 17861 |
|
| 17862 |
if (count_string >= 512) |
| 17863 |
{ |
| 17864 |
fputs (to_close, file); |
| 17865 |
|
| 17866 |
for_string = "\t.byte \""; |
| 17867 |
for_decimal = "\t.byte "; |
| 17868 |
to_close = NULL; |
| 17869 |
count_string = 0; |
| 17870 |
} |
| 17871 |
} |
| 17872 |
else |
| 17873 |
{ |
| 17874 |
if (for_decimal) |
| 17875 |
fputs (for_decimal, file); |
| 17876 |
fprintf (file, "%d", c); |
| 17877 |
|
| 17878 |
for_string = "\n\t.byte \""; |
| 17879 |
for_decimal = ", "; |
| 17880 |
to_close = "\n"; |
| 17881 |
count_string = 0; |
| 17882 |
} |
| 17883 |
} |
| 17884 |
|
| 17885 |
/* Now close the string if we have written one. Then end the line. */ |
| 17886 |
if (to_close) |
| 17887 |
fputs (to_close, file); |
| 17888 |
} |
| 17889 |
|
| 17890 |
/* Generate a unique section name for FILENAME for a section type |
| 17891 |
represented by SECTION_DESC. Output goes into BUF. |
| 17892 |
|
| 17893 |
SECTION_DESC can be any string, as long as it is different for each |
| 17894 |
possible section type. |
| 17895 |
|
| 17896 |
We name the section in the same manner as xlc. The name begins with an |
| 17897 |
underscore followed by the filename (after stripping any leading directory |
| 17898 |
names) with the last period replaced by the string SECTION_DESC. If |
| 17899 |
FILENAME does not contain a period, SECTION_DESC is appended to the end of |
| 17900 |
the name. */ |
| 17901 |
|
| 17902 |
void |
| 17903 |
rs6000_gen_section_name (char **buf, const char *filename, |
| 17904 |
const char *section_desc) |
| 17905 |
{ |
| 17906 |
const char *q, *after_last_slash, *last_period = 0; |
| 17907 |
char *p; |
| 17908 |
int len; |
| 17909 |
|
| 17910 |
after_last_slash = filename; |
| 17911 |
for (q = filename; *q; q++) |
| 17912 |
{ |
| 17913 |
if (*q == '/') |
| 17914 |
after_last_slash = q + 1; |
| 17915 |
else if (*q == '.') |
| 17916 |
last_period = q; |
| 17917 |
} |
| 17918 |
|
| 17919 |
len = strlen (after_last_slash) + strlen (section_desc) + 2; |
| 17920 |
*buf = (char *) xmalloc (len); |
| 17921 |
|
| 17922 |
p = *buf; |
| 17923 |
*p++ = '_'; |
| 17924 |
|
| 17925 |
for (q = after_last_slash; *q; q++) |
| 17926 |
{ |
| 17927 |
if (q == last_period) |
| 17928 |
{ |
| 17929 |
strcpy (p, section_desc); |
| 17930 |
p += strlen (section_desc); |
| 17931 |
break; |
| 17932 |
} |
| 17933 |
|
| 17934 |
else if (ISALNUM (*q)) |
| 17935 |
*p++ = *q; |
| 17936 |
} |
| 17937 |
|
| 17938 |
if (last_period == 0) |
| 17939 |
strcpy (p, section_desc); |
| 17940 |
else |
| 17941 |
*p = '\0'; |
| 17942 |
} |
| 17943 |
|
| 17944 |
/* Emit profile function. */ |
| 17945 |
|
| 17946 |
void |
| 17947 |
output_profile_hook (int labelno ATTRIBUTE_UNUSED) |
| 17948 |
{ |
| 17949 |
/* Non-standard profiling for kernels, which just saves LR then calls |
| 17950 |
_mcount without worrying about arg saves. The idea is to change |
| 17951 |
the function prologue as little as possible as it isn't easy to |
| 17952 |
account for arg save/restore code added just for _mcount. */ |
| 17953 |
if (TARGET_PROFILE_KERNEL) |
| 17954 |
return; |
| 17955 |
|
| 17956 |
if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) |
| 17957 |
{ |
| 17958 |
#ifndef NO_PROFILE_COUNTERS |
| 17959 |
# define NO_PROFILE_COUNTERS 0 |
| 17960 |
#endif |
| 17961 |
if (NO_PROFILE_COUNTERS) |
| 17962 |
emit_library_call (init_one_libfunc (RS6000_MCOUNT), |
| 17963 |
LCT_NORMAL, VOIDmode); |
| 17964 |
else |
| 17965 |
{ |
| 17966 |
char buf[30]; |
| 17967 |
const char *label_name; |
| 17968 |
rtx fun; |
| 17969 |
|
| 17970 |
ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno); |
| 17971 |
label_name = ggc_strdup ((*targetm.strip_name_encoding) (buf)); |
| 17972 |
fun = gen_rtx_SYMBOL_REF (Pmode, label_name); |
| 17973 |
|
| 17974 |
emit_library_call (init_one_libfunc (RS6000_MCOUNT), |
| 17975 |
LCT_NORMAL, VOIDmode, fun, Pmode); |
| 17976 |
} |
| 17977 |
} |
| 17978 |
else if (DEFAULT_ABI == ABI_DARWIN) |
| 17979 |
{ |
| 17980 |
const char *mcount_name = RS6000_MCOUNT; |
| 17981 |
int caller_addr_regno = LR_REGNO; |
| 17982 |
|
| 17983 |
/* Be conservative and always set this, at least for now. */ |
| 17984 |
crtl->uses_pic_offset_table = 1; |
| 17985 |
|
| 17986 |
#if TARGET_MACHO |
| 17987 |
/* For PIC code, set up a stub and collect the caller's address |
| 17988 |
from r0, which is where the prologue puts it. */ |
| 17989 |
if (MACHOPIC_INDIRECT |
| 17990 |
&& crtl->uses_pic_offset_table) |
| 17991 |
caller_addr_regno = 0; |
| 17992 |
#endif |
| 17993 |
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, mcount_name), |
| 17994 |
LCT_NORMAL, VOIDmode, |
| 17995 |
gen_rtx_REG (Pmode, caller_addr_regno), Pmode); |
| 17996 |
} |
| 17997 |
} |
| 17998 |
|
| 17999 |
/* Write function profiler code. */ |
| 18000 |
|
| 18001 |
void |
| 18002 |
output_function_profiler (FILE *file, int labelno) |
| 18003 |
{ |
| 18004 |
char buf[100]; |
| 18005 |
|
| 18006 |
switch (DEFAULT_ABI) |
| 18007 |
{ |
| 18008 |
default: |
| 18009 |
gcc_unreachable (); |
| 18010 |
|
| 18011 |
case ABI_V4: |
| 18012 |
if (!TARGET_32BIT) |
| 18013 |
{ |
| 18014 |
warning (0, "no profiling of 64-bit code for this ABI"); |
| 18015 |
return; |
| 18016 |
} |
| 18017 |
ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno); |
| 18018 |
fprintf (file, "\tmflr %s\n", reg_names[0]); |
| 18019 |
if (NO_PROFILE_COUNTERS) |
| 18020 |
{ |
| 18021 |
asm_fprintf (file, "\tstw %s,4(%s)\n", |
| 18022 |
reg_names[0], reg_names[1]); |
| 18023 |
} |
| 18024 |
else if (TARGET_SECURE_PLT && flag_pic) |
| 18025 |
{ |
| 18026 |
if (TARGET_LINK_STACK) |
| 18027 |
{ |
| 18028 |
char name[32]; |
| 18029 |
get_ppc476_thunk_name (name); |
| 18030 |
asm_fprintf (file, "\tbl %s\n", name); |
| 18031 |
} |
| 18032 |
else |
| 18033 |
asm_fprintf (file, "\tbcl 20,31,1f\n1:\n"); |
| 18034 |
asm_fprintf (file, "\tstw %s,4(%s)\n", |
| 18035 |
reg_names[0], reg_names[1]); |
| 18036 |
asm_fprintf (file, "\tmflr %s\n", reg_names[12]); |
| 18037 |
asm_fprintf (file, "\taddis %s,%s,", |
| 18038 |
reg_names[12], reg_names[12]); |
| 18039 |
assemble_name (file, buf); |
| 18040 |
asm_fprintf (file, "-1b@ha\n\tla %s,", reg_names[0]); |
| 18041 |
assemble_name (file, buf); |
| 18042 |
asm_fprintf (file, "-1b@l(%s)\n", reg_names[12]); |
| 18043 |
} |
| 18044 |
else if (flag_pic == 1) |
| 18045 |
{ |
| 18046 |
fputs ("\tbl _GLOBAL_OFFSET_TABLE_@local-4\n", file); |
| 18047 |
asm_fprintf (file, "\tstw %s,4(%s)\n", |
| 18048 |
reg_names[0], reg_names[1]); |
| 18049 |
asm_fprintf (file, "\tmflr %s\n", reg_names[12]); |
| 18050 |
asm_fprintf (file, "\tlwz %s,", reg_names[0]); |
| 18051 |
assemble_name (file, buf); |
| 18052 |
asm_fprintf (file, "@got(%s)\n", reg_names[12]); |
| 18053 |
} |
| 18054 |
else if (flag_pic > 1) |
| 18055 |
{ |
| 18056 |
asm_fprintf (file, "\tstw %s,4(%s)\n", |
| 18057 |
reg_names[0], reg_names[1]); |
| 18058 |
/* Now, we need to get the address of the label. */ |
| 18059 |
if (TARGET_LINK_STACK) |
| 18060 |
{ |
| 18061 |
char name[32]; |
| 18062 |
get_ppc476_thunk_name (name); |
| 18063 |
asm_fprintf (file, "\tbl %s\n\tb 1f\n\t.long ", name); |
| 18064 |
assemble_name (file, buf); |
| 18065 |
fputs ("-.\n1:", file); |
| 18066 |
asm_fprintf (file, "\tmflr %s\n", reg_names[11]); |
| 18067 |
asm_fprintf (file, "\taddi %s,%s,4\n", |
| 18068 |
reg_names[11], reg_names[11]); |
| 18069 |
} |
| 18070 |
else |
| 18071 |
{ |
| 18072 |
fputs ("\tbcl 20,31,1f\n\t.long ", file); |
| 18073 |
assemble_name (file, buf); |
| 18074 |
fputs ("-.\n1:", file); |
| 18075 |
asm_fprintf (file, "\tmflr %s\n", reg_names[11]); |
| 18076 |
} |
| 18077 |
asm_fprintf (file, "\tlwz %s,0(%s)\n", |
| 18078 |
reg_names[0], reg_names[11]); |
| 18079 |
asm_fprintf (file, "\tadd %s,%s,%s\n", |
| 18080 |
reg_names[0], reg_names[0], reg_names[11]); |
| 18081 |
} |
| 18082 |
else |
| 18083 |
{ |
| 18084 |
asm_fprintf (file, "\tlis %s,", reg_names[12]); |
| 18085 |
assemble_name (file, buf); |
| 18086 |
fputs ("@ha\n", file); |
| 18087 |
asm_fprintf (file, "\tstw %s,4(%s)\n", |
| 18088 |
reg_names[0], reg_names[1]); |
| 18089 |
asm_fprintf (file, "\tla %s,", reg_names[0]); |
| 18090 |
assemble_name (file, buf); |
| 18091 |
asm_fprintf (file, "@l(%s)\n", reg_names[12]); |
| 18092 |
} |
| 18093 |
|
| 18094 |
/* ABI_V4 saves the static chain reg with ASM_OUTPUT_REG_PUSH. */ |
| 18095 |
fprintf (file, "\tbl %s%s\n", |
| 18096 |
RS6000_MCOUNT, flag_pic ? "@plt" : ""); |
| 18097 |
break; |
| 18098 |
|
| 18099 |
case ABI_AIX: |
| 18100 |
case ABI_ELFv2: |
| 18101 |
case ABI_DARWIN: |
| 18102 |
/* Don't do anything, done in output_profile_hook (). */ |
| 18103 |
break; |
| 18104 |
} |
| 18105 |
} |
| 18106 |
|
| 18107 |
|
| 18108 |
|
| 18109 |
/* The following variable value is the last issued insn. */ |
| 18110 |
|
| 18111 |
static rtx_insn *last_scheduled_insn; |
| 18112 |
|
| 18113 |
/* The following variable helps to balance issuing of load and |
| 18114 |
store instructions */ |
| 18115 |
|
| 18116 |
static int load_store_pendulum; |
| 18117 |
|
| 18118 |
/* The following variable helps pair divide insns during scheduling. */ |
| 18119 |
static int divide_cnt; |
| 18120 |
/* The following variable helps pair and alternate vector and vector load |
| 18121 |
insns during scheduling. */ |
| 18122 |
static int vec_pairing; |
| 18123 |
|
| 18124 |
|
| 18125 |
/* Power4 load update and store update instructions are cracked into a |
| 18126 |
load or store and an integer insn which are executed in the same cycle. |
| 18127 |
Branches have their own dispatch slot which does not count against the |
| 18128 |
GCC issue rate, but it changes the program flow so there are no other |
| 18129 |
instructions to issue in this cycle. */ |
| 18130 |
|
| 18131 |
static int |
| 18132 |
rs6000_variable_issue_1 (rtx_insn *insn, int more) |
| 18133 |
{ |
| 18134 |
last_scheduled_insn = insn; |
| 18135 |
if (GET_CODE (PATTERN (insn)) == USE |
| 18136 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 18137 |
{ |
| 18138 |
cached_can_issue_more = more; |
| 18139 |
return cached_can_issue_more; |
| 18140 |
} |
| 18141 |
|
| 18142 |
if (insn_terminates_group_p (insn, current_group)) |
| 18143 |
{ |
| 18144 |
cached_can_issue_more = 0; |
| 18145 |
return cached_can_issue_more; |
| 18146 |
} |
| 18147 |
|
| 18148 |
/* If no reservation, but reach here */ |
| 18149 |
if (recog_memoized (insn) < 0) |
| 18150 |
return more; |
| 18151 |
|
| 18152 |
if (rs6000_sched_groups) |
| 18153 |
{ |
| 18154 |
if (is_microcoded_insn (insn)) |
| 18155 |
cached_can_issue_more = 0; |
| 18156 |
else if (is_cracked_insn (insn)) |
| 18157 |
cached_can_issue_more = more > 2 ? more - 2 : 0; |
| 18158 |
else |
| 18159 |
cached_can_issue_more = more - 1; |
| 18160 |
|
| 18161 |
return cached_can_issue_more; |
| 18162 |
} |
| 18163 |
|
| 18164 |
if (rs6000_tune == PROCESSOR_CELL && is_nonpipeline_insn (insn)) |
| 18165 |
return 0; |
| 18166 |
|
| 18167 |
cached_can_issue_more = more - 1; |
| 18168 |
return cached_can_issue_more; |
| 18169 |
} |
| 18170 |
|
| 18171 |
static int |
| 18172 |
rs6000_variable_issue (FILE *stream, int verbose, rtx_insn *insn, int more) |
| 18173 |
{ |
| 18174 |
int r = rs6000_variable_issue_1 (insn, more); |
| 18175 |
if (verbose) |
| 18176 |
fprintf (stream, "// rs6000_variable_issue (more = %d) = %d\n", more, r); |
| 18177 |
return r; |
| 18178 |
} |
| 18179 |
|
| 18180 |
/* Adjust the cost of a scheduling dependency. Return the new cost of |
| 18181 |
a dependency LINK or INSN on DEP_INSN. COST is the current cost. */ |
| 18182 |
|
| 18183 |
static int |
| 18184 |
rs6000_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost, |
| 18185 |
unsigned int) |
| 18186 |
{ |
| 18187 |
enum attr_type attr_type; |
| 18188 |
|
| 18189 |
if (recog_memoized (insn) < 0 || recog_memoized (dep_insn) < 0) |
| 18190 |
return cost; |
| 18191 |
|
| 18192 |
switch (dep_type) |
| 18193 |
{ |
| 18194 |
case REG_DEP_TRUE: |
| 18195 |
{ |
| 18196 |
/* Data dependency; DEP_INSN writes a register that INSN reads |
| 18197 |
some cycles later. */ |
| 18198 |
|
| 18199 |
/* Separate a load from a narrower, dependent store. */ |
| 18200 |
if ((rs6000_sched_groups || rs6000_tune == PROCESSOR_POWER9 |
| 18201 |
|| rs6000_tune == PROCESSOR_POWER10 |
| 18202 |
|| rs6000_tune == PROCESSOR_POWER11) |
| 18203 |
&& GET_CODE (PATTERN (insn)) == SET |
| 18204 |
&& GET_CODE (PATTERN (dep_insn)) == SET |
| 18205 |
&& MEM_P (XEXP (PATTERN (insn), 1)) |
| 18206 |
&& MEM_P (XEXP (PATTERN (dep_insn), 0)) |
| 18207 |
&& (GET_MODE_SIZE (GET_MODE (XEXP (PATTERN (insn), 1))) |
| 18208 |
> GET_MODE_SIZE (GET_MODE (XEXP (PATTERN (dep_insn), 0))))) |
| 18209 |
return cost + 14; |
| 18210 |
|
| 18211 |
attr_type = get_attr_type (insn); |
| 18212 |
|
| 18213 |
switch (attr_type) |
| 18214 |
{ |
| 18215 |
case TYPE_JMPREG: |
| 18216 |
/* Tell the first scheduling pass about the latency between |
| 18217 |
a mtctr and bctr (and mtlr and br/blr). The first |
| 18218 |
scheduling pass will not know about this latency since |
| 18219 |
the mtctr instruction, which has the latency associated |
| 18220 |
to it, will be generated by reload. */ |
| 18221 |
return 4; |
| 18222 |
case TYPE_BRANCH: |
| 18223 |
/* Leave some extra cycles between a compare and its |
| 18224 |
dependent branch, to inhibit expensive mispredicts. */ |
| 18225 |
if ((rs6000_tune == PROCESSOR_PPC603 |
| 18226 |
|| rs6000_tune == PROCESSOR_PPC604 |
| 18227 |
|| rs6000_tune == PROCESSOR_PPC604e |
| 18228 |
|| rs6000_tune == PROCESSOR_PPC620 |
| 18229 |
|| rs6000_tune == PROCESSOR_PPC630 |
| 18230 |
|| rs6000_tune == PROCESSOR_PPC750 |
| 18231 |
|| rs6000_tune == PROCESSOR_PPC7400 |
| 18232 |
|| rs6000_tune == PROCESSOR_PPC7450 |
| 18233 |
|| rs6000_tune == PROCESSOR_PPCE5500 |
| 18234 |
|| rs6000_tune == PROCESSOR_PPCE6500 |
| 18235 |
|| rs6000_tune == PROCESSOR_POWER4 |
| 18236 |
|| rs6000_tune == PROCESSOR_POWER5 |
| 18237 |
|| rs6000_tune == PROCESSOR_POWER7 |
| 18238 |
|| rs6000_tune == PROCESSOR_POWER8 |
| 18239 |
|| rs6000_tune == PROCESSOR_POWER9 |
| 18240 |
|| rs6000_tune == PROCESSOR_POWER10 |
| 18241 |
|| rs6000_tune == PROCESSOR_POWER11 |
| 18242 |
|| rs6000_tune == PROCESSOR_CELL) |
| 18243 |
&& recog_memoized (dep_insn) |
| 18244 |
&& (INSN_CODE (dep_insn) >= 0)) |
| 18245 |
|
| 18246 |
switch (get_attr_type (dep_insn)) |
| 18247 |
{ |
| 18248 |
case TYPE_CMP: |
| 18249 |
case TYPE_FPCOMPARE: |
| 18250 |
case TYPE_CR_LOGICAL: |
| 18251 |
return cost + 2; |
| 18252 |
case TYPE_EXTS: |
| 18253 |
case TYPE_MUL: |
| 18254 |
if (get_attr_dot (dep_insn) == DOT_YES) |
| 18255 |
return cost + 2; |
| 18256 |
else |
| 18257 |
break; |
| 18258 |
case TYPE_SHIFT: |
| 18259 |
if (get_attr_dot (dep_insn) == DOT_YES |
| 18260 |
&& get_attr_var_shift (dep_insn) == VAR_SHIFT_NO) |
| 18261 |
return cost + 2; |
| 18262 |
else |
| 18263 |
break; |
| 18264 |
default: |
| 18265 |
break; |
| 18266 |
} |
| 18267 |
break; |
| 18268 |
|
| 18269 |
case TYPE_STORE: |
| 18270 |
case TYPE_FPSTORE: |
| 18271 |
if ((rs6000_tune == PROCESSOR_POWER6) |
| 18272 |
&& recog_memoized (dep_insn) |
| 18273 |
&& (INSN_CODE (dep_insn) >= 0)) |
| 18274 |
{ |
| 18275 |
|
| 18276 |
if (GET_CODE (PATTERN (insn)) != SET) |
| 18277 |
/* If this happens, we have to extend this to schedule |
| 18278 |
optimally. Return default for now. */ |
| 18279 |
return cost; |
| 18280 |
|
| 18281 |
/* Adjust the cost for the case where the value written |
| 18282 |
by a fixed point operation is used as the address |
| 18283 |
gen value on a store. */ |
| 18284 |
switch (get_attr_type (dep_insn)) |
| 18285 |
{ |
| 18286 |
case TYPE_LOAD: |
| 18287 |
case TYPE_CNTLZ: |
| 18288 |
{ |
| 18289 |
if (! rs6000_store_data_bypass_p (dep_insn, insn)) |
| 18290 |
return get_attr_sign_extend (dep_insn) |
| 18291 |
== SIGN_EXTEND_YES ? 6 : 4; |
| 18292 |
break; |
| 18293 |
} |
| 18294 |
case TYPE_SHIFT: |
| 18295 |
{ |
| 18296 |
if (! rs6000_store_data_bypass_p (dep_insn, insn)) |
| 18297 |
return get_attr_var_shift (dep_insn) == VAR_SHIFT_YES ? |
| 18298 |
6 : 3; |
| 18299 |
break; |
| 18300 |
} |
| 18301 |
case TYPE_INTEGER: |
| 18302 |
case TYPE_ADD: |
| 18303 |
case TYPE_LOGICAL: |
| 18304 |
case TYPE_EXTS: |
| 18305 |
case TYPE_INSERT: |
| 18306 |
{ |
| 18307 |
if (! rs6000_store_data_bypass_p (dep_insn, insn)) |
| 18308 |
return 3; |
| 18309 |
break; |
| 18310 |
} |
| 18311 |
case TYPE_STORE: |
| 18312 |
case TYPE_FPLOAD: |
| 18313 |
case TYPE_FPSTORE: |
| 18314 |
{ |
| 18315 |
if (get_attr_update (dep_insn) == UPDATE_YES |
| 18316 |
&& ! rs6000_store_data_bypass_p (dep_insn, insn)) |
| 18317 |
return 3; |
| 18318 |
break; |
| 18319 |
} |
| 18320 |
case TYPE_MUL: |
| 18321 |
{ |
| 18322 |
if (! rs6000_store_data_bypass_p (dep_insn, insn)) |
| 18323 |
return 17; |
| 18324 |
break; |
| 18325 |
} |
| 18326 |
case TYPE_DIV: |
| 18327 |
{ |
| 18328 |
if (! rs6000_store_data_bypass_p (dep_insn, insn)) |
| 18329 |
return get_attr_size (dep_insn) == SIZE_32 ? 45 : 57; |
| 18330 |
break; |
| 18331 |
} |
| 18332 |
default: |
| 18333 |
break; |
| 18334 |
} |
| 18335 |
} |
| 18336 |
break; |
| 18337 |
|
| 18338 |
case TYPE_LOAD: |
| 18339 |
if ((rs6000_tune == PROCESSOR_POWER6) |
| 18340 |
&& recog_memoized (dep_insn) |
| 18341 |
&& (INSN_CODE (dep_insn) >= 0)) |
| 18342 |
{ |
| 18343 |
|
| 18344 |
/* Adjust the cost for the case where the value written |
| 18345 |
by a fixed point instruction is used within the address |
| 18346 |
gen portion of a subsequent load(u)(x) */ |
| 18347 |
switch (get_attr_type (dep_insn)) |
| 18348 |
{ |
| 18349 |
case TYPE_LOAD: |
| 18350 |
case TYPE_CNTLZ: |
| 18351 |
{ |
| 18352 |
if (set_to_load_agen (dep_insn, insn)) |
| 18353 |
return get_attr_sign_extend (dep_insn) |
| 18354 |
== SIGN_EXTEND_YES ? 6 : 4; |
| 18355 |
break; |
| 18356 |
} |
| 18357 |
case TYPE_SHIFT: |
| 18358 |
{ |
| 18359 |
if (set_to_load_agen (dep_insn, insn)) |
| 18360 |
return get_attr_var_shift (dep_insn) == VAR_SHIFT_YES ? |
| 18361 |
6 : 3; |
| 18362 |
break; |
| 18363 |
} |
| 18364 |
case TYPE_INTEGER: |
| 18365 |
case TYPE_ADD: |
| 18366 |
case TYPE_LOGICAL: |
| 18367 |
case TYPE_EXTS: |
| 18368 |
case TYPE_INSERT: |
| 18369 |
{ |
| 18370 |
if (set_to_load_agen (dep_insn, insn)) |
| 18371 |
return 3; |
| 18372 |
break; |
| 18373 |
} |
| 18374 |
case TYPE_STORE: |
| 18375 |
case TYPE_FPLOAD: |
| 18376 |
case TYPE_FPSTORE: |
| 18377 |
{ |
| 18378 |
if (get_attr_update (dep_insn) == UPDATE_YES |
| 18379 |
&& set_to_load_agen (dep_insn, insn)) |
| 18380 |
return 3; |
| 18381 |
break; |
| 18382 |
} |
| 18383 |
case TYPE_MUL: |
| 18384 |
{ |
| 18385 |
if (set_to_load_agen (dep_insn, insn)) |
| 18386 |
return 17; |
| 18387 |
break; |
| 18388 |
} |
| 18389 |
case TYPE_DIV: |
| 18390 |
{ |
| 18391 |
if (set_to_load_agen (dep_insn, insn)) |
| 18392 |
return get_attr_size (dep_insn) == SIZE_32 ? 45 : 57; |
| 18393 |
break; |
| 18394 |
} |
| 18395 |
default: |
| 18396 |
break; |
| 18397 |
} |
| 18398 |
} |
| 18399 |
break; |
| 18400 |
|
| 18401 |
default: |
| 18402 |
break; |
| 18403 |
} |
| 18404 |
|
| 18405 |
/* Fall out to return default cost. */ |
| 18406 |
} |
| 18407 |
break; |
| 18408 |
|
| 18409 |
case REG_DEP_OUTPUT: |
| 18410 |
/* Output dependency; DEP_INSN writes a register that INSN writes some |
| 18411 |
cycles later. */ |
| 18412 |
if ((rs6000_tune == PROCESSOR_POWER6) |
| 18413 |
&& recog_memoized (dep_insn) |
| 18414 |
&& (INSN_CODE (dep_insn) >= 0)) |
| 18415 |
{ |
| 18416 |
attr_type = get_attr_type (insn); |
| 18417 |
|
| 18418 |
switch (attr_type) |
| 18419 |
{ |
| 18420 |
case TYPE_FP: |
| 18421 |
case TYPE_FPSIMPLE: |
| 18422 |
if (get_attr_type (dep_insn) == TYPE_FP |
| 18423 |
|| get_attr_type (dep_insn) == TYPE_FPSIMPLE) |
| 18424 |
return 1; |
| 18425 |
break; |
| 18426 |
default: |
| 18427 |
break; |
| 18428 |
} |
| 18429 |
} |
| 18430 |
/* Fall through, no cost for output dependency. */ |
| 18431 |
/* FALLTHRU */ |
| 18432 |
|
| 18433 |
case REG_DEP_ANTI: |
| 18434 |
/* Anti dependency; DEP_INSN reads a register that INSN writes some |
| 18435 |
cycles later. */ |
| 18436 |
return 0; |
| 18437 |
|
| 18438 |
default: |
| 18439 |
gcc_unreachable (); |
| 18440 |
} |
| 18441 |
|
| 18442 |
return cost; |
| 18443 |
} |
| 18444 |
|
| 18445 |
/* Debug version of rs6000_adjust_cost. */ |
| 18446 |
|
| 18447 |
static int |
| 18448 |
rs6000_debug_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, |
| 18449 |
int cost, unsigned int dw) |
| 18450 |
{ |
| 18451 |
int ret = rs6000_adjust_cost (insn, dep_type, dep_insn, cost, dw); |
| 18452 |
|
| 18453 |
if (ret != cost) |
| 18454 |
{ |
| 18455 |
const char *dep; |
| 18456 |
|
| 18457 |
switch (dep_type) |
| 18458 |
{ |
| 18459 |
default: dep = "unknown depencency"; break; |
| 18460 |
case REG_DEP_TRUE: dep = "data dependency"; break; |
| 18461 |
case REG_DEP_OUTPUT: dep = "output dependency"; break; |
| 18462 |
case REG_DEP_ANTI: dep = "anti depencency"; break; |
| 18463 |
} |
| 18464 |
|
| 18465 |
fprintf (stderr, |
| 18466 |
"\nrs6000_adjust_cost, final cost = %d, orig cost = %d, " |
| 18467 |
"%s, insn:\n", ret, cost, dep); |
| 18468 |
|
| 18469 |
debug_rtx (insn); |
| 18470 |
} |
| 18471 |
|
| 18472 |
return ret; |
| 18473 |
} |
| 18474 |
|
| 18475 |
/* The function returns a true if INSN is microcoded. |
| 18476 |
Return false otherwise. */ |
| 18477 |
|
| 18478 |
static bool |
| 18479 |
is_microcoded_insn (rtx_insn *insn) |
| 18480 |
{ |
| 18481 |
if (!insn || !NONDEBUG_INSN_P (insn) |
| 18482 |
|| GET_CODE (PATTERN (insn)) == USE |
| 18483 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 18484 |
return false; |
| 18485 |
|
| 18486 |
if (rs6000_tune == PROCESSOR_CELL) |
| 18487 |
return get_attr_cell_micro (insn) == CELL_MICRO_ALWAYS; |
| 18488 |
|
| 18489 |
if (rs6000_sched_groups |
| 18490 |
&& (rs6000_tune == PROCESSOR_POWER4 || rs6000_tune == PROCESSOR_POWER5)) |
| 18491 |
{ |
| 18492 |
enum attr_type type = get_attr_type (insn); |
| 18493 |
if ((type == TYPE_LOAD |
| 18494 |
&& get_attr_update (insn) == UPDATE_YES |
| 18495 |
&& get_attr_sign_extend (insn) == SIGN_EXTEND_YES) |
| 18496 |
|| ((type == TYPE_LOAD || type == TYPE_STORE) |
| 18497 |
&& get_attr_update (insn) == UPDATE_YES |
| 18498 |
&& get_attr_indexed (insn) == INDEXED_YES) |
| 18499 |
|| type == TYPE_MFCR) |
| 18500 |
return true; |
| 18501 |
} |
| 18502 |
|
| 18503 |
return false; |
| 18504 |
} |
| 18505 |
|
| 18506 |
/* The function returns true if INSN is cracked into 2 instructions |
| 18507 |
by the processor (and therefore occupies 2 issue slots). */ |
| 18508 |
|
| 18509 |
static bool |
| 18510 |
is_cracked_insn (rtx_insn *insn) |
| 18511 |
{ |
| 18512 |
if (!insn || !NONDEBUG_INSN_P (insn) |
| 18513 |
|| GET_CODE (PATTERN (insn)) == USE |
| 18514 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 18515 |
return false; |
| 18516 |
|
| 18517 |
if (rs6000_sched_groups |
| 18518 |
&& (rs6000_tune == PROCESSOR_POWER4 || rs6000_tune == PROCESSOR_POWER5)) |
| 18519 |
{ |
| 18520 |
enum attr_type type = get_attr_type (insn); |
| 18521 |
if ((type == TYPE_LOAD |
| 18522 |
&& get_attr_sign_extend (insn) == SIGN_EXTEND_YES |
| 18523 |
&& get_attr_update (insn) == UPDATE_NO) |
| 18524 |
|| (type == TYPE_LOAD |
| 18525 |
&& get_attr_sign_extend (insn) == SIGN_EXTEND_NO |
| 18526 |
&& get_attr_update (insn) == UPDATE_YES |
| 18527 |
&& get_attr_indexed (insn) == INDEXED_NO) |
| 18528 |
|| (type == TYPE_STORE |
| 18529 |
&& get_attr_update (insn) == UPDATE_YES |
| 18530 |
&& get_attr_indexed (insn) == INDEXED_NO) |
| 18531 |
|| ((type == TYPE_FPLOAD || type == TYPE_FPSTORE) |
| 18532 |
&& get_attr_update (insn) == UPDATE_YES) |
| 18533 |
|| (type == TYPE_CR_LOGICAL |
| 18534 |
&& get_attr_cr_logical_3op (insn) == CR_LOGICAL_3OP_YES) |
| 18535 |
|| (type == TYPE_EXTS |
| 18536 |
&& get_attr_dot (insn) == DOT_YES) |
| 18537 |
|| (type == TYPE_SHIFT |
| 18538 |
&& get_attr_dot (insn) == DOT_YES |
| 18539 |
&& get_attr_var_shift (insn) == VAR_SHIFT_NO) |
| 18540 |
|| (type == TYPE_MUL |
| 18541 |
&& get_attr_dot (insn) == DOT_YES) |
| 18542 |
|| type == TYPE_DIV |
| 18543 |
|| (type == TYPE_INSERT |
| 18544 |
&& get_attr_size (insn) == SIZE_32)) |
| 18545 |
return true; |
| 18546 |
} |
| 18547 |
|
| 18548 |
return false; |
| 18549 |
} |
| 18550 |
|
| 18551 |
/* The function returns true if INSN can be issued only from |
| 18552 |
the branch slot. */ |
| 18553 |
|
| 18554 |
static bool |
| 18555 |
is_branch_slot_insn (rtx_insn *insn) |
| 18556 |
{ |
| 18557 |
if (!insn || !NONDEBUG_INSN_P (insn) |
| 18558 |
|| GET_CODE (PATTERN (insn)) == USE |
| 18559 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 18560 |
return false; |
| 18561 |
|
| 18562 |
if (rs6000_sched_groups) |
| 18563 |
{ |
| 18564 |
enum attr_type type = get_attr_type (insn); |
| 18565 |
if (type == TYPE_BRANCH || type == TYPE_JMPREG) |
| 18566 |
return true; |
| 18567 |
return false; |
| 18568 |
} |
| 18569 |
|
| 18570 |
return false; |
| 18571 |
} |
| 18572 |
|
| 18573 |
/* The function returns true if out_inst sets a value that is |
| 18574 |
used in the address generation computation of in_insn */ |
| 18575 |
static bool |
| 18576 |
set_to_load_agen (rtx_insn *out_insn, rtx_insn *in_insn) |
| 18577 |
{ |
| 18578 |
rtx out_set, in_set; |
| 18579 |
|
| 18580 |
/* For performance reasons, only handle the simple case where |
| 18581 |
both loads are a single_set. */ |
| 18582 |
out_set = single_set (out_insn); |
| 18583 |
if (out_set) |
| 18584 |
{ |
| 18585 |
in_set = single_set (in_insn); |
| 18586 |
if (in_set) |
| 18587 |
return reg_mentioned_p (SET_DEST (out_set), SET_SRC (in_set)); |
| 18588 |
} |
| 18589 |
|
| 18590 |
return false; |
| 18591 |
} |
| 18592 |
|
| 18593 |
/* Try to determine base/offset/size parts of the given MEM. |
| 18594 |
Return true if successful, false if all the values couldn't |
| 18595 |
be determined. |
| 18596 |
|
| 18597 |
This function only looks for REG or REG+CONST address forms. |
| 18598 |
REG+REG address form will return false. */ |
| 18599 |
|
| 18600 |
static bool |
| 18601 |
get_memref_parts (rtx mem, rtx *base, HOST_WIDE_INT *offset, |
| 18602 |
HOST_WIDE_INT *size) |
| 18603 |
{ |
| 18604 |
rtx addr_rtx; |
| 18605 |
if (MEM_SIZE_KNOWN_P (mem)) |
| 18606 |
*size = MEM_SIZE (mem); |
| 18607 |
else |
| 18608 |
return false; |
| 18609 |
|
| 18610 |
addr_rtx = (XEXP (mem, 0)); |
| 18611 |
if (GET_CODE (addr_rtx) == PRE_MODIFY) |
| 18612 |
addr_rtx = XEXP (addr_rtx, 1); |
| 18613 |
|
| 18614 |
*offset = 0; |
| 18615 |
while (GET_CODE (addr_rtx) == PLUS |
| 18616 |
&& CONST_INT_P (XEXP (addr_rtx, 1))) |
| 18617 |
{ |
| 18618 |
*offset += INTVAL (XEXP (addr_rtx, 1)); |
| 18619 |
addr_rtx = XEXP (addr_rtx, 0); |
| 18620 |
} |
| 18621 |
if (!REG_P (addr_rtx)) |
| 18622 |
return false; |
| 18623 |
|
| 18624 |
*base = addr_rtx; |
| 18625 |
return true; |
| 18626 |
} |
| 18627 |
|
| 18628 |
/* If the target storage locations of arguments MEM1 and MEM2 are |
| 18629 |
adjacent, then return the argument that has the lower address. |
| 18630 |
Otherwise, return NULL_RTX. */ |
| 18631 |
|
| 18632 |
static rtx |
| 18633 |
adjacent_mem_locations (rtx mem1, rtx mem2) |
| 18634 |
{ |
| 18635 |
rtx reg1, reg2; |
| 18636 |
HOST_WIDE_INT off1, size1, off2, size2; |
| 18637 |
|
| 18638 |
if (MEM_P (mem1) |
| 18639 |
&& MEM_P (mem2) |
| 18640 |
&& get_memref_parts (mem1, ®1, &off1, &size1) |
| 18641 |
&& get_memref_parts (mem2, ®2, &off2, &size2) |
| 18642 |
&& REGNO (reg1) == REGNO (reg2)) |
| 18643 |
{ |
| 18644 |
if (off1 + size1 == off2) |
| 18645 |
return mem1; |
| 18646 |
else if (off2 + size2 == off1) |
| 18647 |
return mem2; |
| 18648 |
} |
| 18649 |
|
| 18650 |
return NULL_RTX; |
| 18651 |
} |
| 18652 |
|
| 18653 |
/* This function returns true if it can be determined that the two MEM |
| 18654 |
locations overlap by at least 1 byte based on base reg/offset/size. */ |
| 18655 |
|
| 18656 |
static bool |
| 18657 |
mem_locations_overlap (rtx mem1, rtx mem2) |
| 18658 |
{ |
| 18659 |
rtx reg1, reg2; |
| 18660 |
HOST_WIDE_INT off1, size1, off2, size2; |
| 18661 |
|
| 18662 |
if (get_memref_parts (mem1, ®1, &off1, &size1) |
| 18663 |
&& get_memref_parts (mem2, ®2, &off2, &size2)) |
| 18664 |
return ((REGNO (reg1) == REGNO (reg2)) |
| 18665 |
&& (((off1 <= off2) && (off1 + size1 > off2)) |
| 18666 |
|| ((off2 <= off1) && (off2 + size2 > off1)))); |
| 18667 |
|
| 18668 |
return false; |
| 18669 |
} |
| 18670 |
|
| 18671 |
/* A C statement (sans semicolon) to update the integer scheduling |
| 18672 |
priority INSN_PRIORITY (INSN). Increase the priority to execute the |
| 18673 |
INSN earlier, reduce the priority to execute INSN later. Do not |
| 18674 |
define this macro if you do not need to adjust the scheduling |
| 18675 |
priorities of insns. */ |
| 18676 |
|
| 18677 |
static int |
| 18678 |
rs6000_adjust_priority (rtx_insn *insn ATTRIBUTE_UNUSED, int priority) |
| 18679 |
{ |
| 18680 |
rtx load_mem, str_mem; |
| 18681 |
/* On machines (like the 750) which have asymmetric integer units, |
| 18682 |
where one integer unit can do multiply and divides and the other |
| 18683 |
can't, reduce the priority of multiply/divide so it is scheduled |
| 18684 |
before other integer operations. */ |
| 18685 |
|
| 18686 |
#if 0 |
| 18687 |
if (! INSN_P (insn)) |
| 18688 |
return priority; |
| 18689 |
|
| 18690 |
if (GET_CODE (PATTERN (insn)) == USE) |
| 18691 |
return priority; |
| 18692 |
|
| 18693 |
switch (rs6000_tune) { |
| 18694 |
case PROCESSOR_PPC750: |
| 18695 |
switch (get_attr_type (insn)) |
| 18696 |
{ |
| 18697 |
default: |
| 18698 |
break; |
| 18699 |
|
| 18700 |
case TYPE_MUL: |
| 18701 |
case TYPE_DIV: |
| 18702 |
fprintf (stderr, "priority was %#x (%d) before adjustment\n", |
| 18703 |
priority, priority); |
| 18704 |
if (priority >= 0 && priority < 0x01000000) |
| 18705 |
priority >>= 3; |
| 18706 |
break; |
| 18707 |
} |
| 18708 |
} |
| 18709 |
#endif |
| 18710 |
|
| 18711 |
if (insn_must_be_first_in_group (insn) |
| 18712 |
&& reload_completed |
| 18713 |
&& current_sched_info->sched_max_insns_priority |
| 18714 |
&& rs6000_sched_restricted_insns_priority) |
| 18715 |
{ |
| 18716 |
|
| 18717 |
/* Prioritize insns that can be dispatched only in the first |
| 18718 |
dispatch slot. */ |
| 18719 |
if (rs6000_sched_restricted_insns_priority == 1) |
| 18720 |
/* Attach highest priority to insn. This means that in |
| 18721 |
haifa-sched.cc:ready_sort(), dispatch-slot restriction considerations |
| 18722 |
precede 'priority' (critical path) considerations. */ |
| 18723 |
return current_sched_info->sched_max_insns_priority; |
| 18724 |
else if (rs6000_sched_restricted_insns_priority == 2) |
| 18725 |
/* Increase priority of insn by a minimal amount. This means that in |
| 18726 |
haifa-sched.cc:ready_sort(), only 'priority' (critical path) |
| 18727 |
considerations precede dispatch-slot restriction considerations. */ |
| 18728 |
return (priority + 1); |
| 18729 |
} |
| 18730 |
|
| 18731 |
if (rs6000_tune == PROCESSOR_POWER6 |
| 18732 |
&& ((load_store_pendulum == -2 && is_load_insn (insn, &load_mem)) |
| 18733 |
|| (load_store_pendulum == 2 && is_store_insn (insn, &str_mem)))) |
| 18734 |
/* Attach highest priority to insn if the scheduler has just issued two |
| 18735 |
stores and this instruction is a load, or two loads and this instruction |
| 18736 |
is a store. Power6 wants loads and stores scheduled alternately |
| 18737 |
when possible */ |
| 18738 |
return current_sched_info->sched_max_insns_priority; |
| 18739 |
|
| 18740 |
return priority; |
| 18741 |
} |
| 18742 |
|
| 18743 |
/* Return true if the instruction is nonpipelined on the Cell. */ |
| 18744 |
static bool |
| 18745 |
is_nonpipeline_insn (rtx_insn *insn) |
| 18746 |
{ |
| 18747 |
enum attr_type type; |
| 18748 |
if (!insn || !NONDEBUG_INSN_P (insn) |
| 18749 |
|| GET_CODE (PATTERN (insn)) == USE |
| 18750 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 18751 |
return false; |
| 18752 |
|
| 18753 |
type = get_attr_type (insn); |
| 18754 |
if (type == TYPE_MUL |
| 18755 |
|| type == TYPE_DIV |
| 18756 |
|| type == TYPE_SDIV |
| 18757 |
|| type == TYPE_DDIV |
| 18758 |
|| type == TYPE_SSQRT |
| 18759 |
|| type == TYPE_DSQRT |
| 18760 |
|| type == TYPE_MFCR |
| 18761 |
|| type == TYPE_MFCRF |
| 18762 |
|| type == TYPE_MFJMPR) |
| 18763 |
{ |
| 18764 |
return true; |
| 18765 |
} |
| 18766 |
return false; |
| 18767 |
} |
| 18768 |
|
| 18769 |
|
| 18770 |
/* Return how many instructions the machine can issue per cycle. */ |
| 18771 |
|
| 18772 |
static int |
| 18773 |
rs6000_issue_rate (void) |
| 18774 |
{ |
| 18775 |
/* Unless scheduling for register pressure, use issue rate of 1 for |
| 18776 |
first scheduling pass to decrease degradation. */ |
| 18777 |
if (!reload_completed && !flag_sched_pressure) |
| 18778 |
return 1; |
| 18779 |
|
| 18780 |
switch (rs6000_tune) { |
| 18781 |
case PROCESSOR_RS64A: |
| 18782 |
case PROCESSOR_PPC601: /* ? */ |
| 18783 |
case PROCESSOR_PPC7450: |
| 18784 |
return 3; |
| 18785 |
case PROCESSOR_PPC440: |
| 18786 |
case PROCESSOR_PPC603: |
| 18787 |
case PROCESSOR_PPC750: |
| 18788 |
case PROCESSOR_PPC7400: |
| 18789 |
case PROCESSOR_PPC8540: |
| 18790 |
case PROCESSOR_PPC8548: |
| 18791 |
case PROCESSOR_CELL: |
| 18792 |
case PROCESSOR_PPCE300C2: |
| 18793 |
case PROCESSOR_PPCE300C3: |
| 18794 |
case PROCESSOR_PPCE500MC: |
| 18795 |
case PROCESSOR_PPCE500MC64: |
| 18796 |
case PROCESSOR_PPCE5500: |
| 18797 |
case PROCESSOR_PPCE6500: |
| 18798 |
case PROCESSOR_TITAN: |
| 18799 |
return 2; |
| 18800 |
case PROCESSOR_PPC476: |
| 18801 |
case PROCESSOR_PPC604: |
| 18802 |
case PROCESSOR_PPC604e: |
| 18803 |
case PROCESSOR_PPC620: |
| 18804 |
case PROCESSOR_PPC630: |
| 18805 |
return 4; |
| 18806 |
case PROCESSOR_POWER4: |
| 18807 |
case PROCESSOR_POWER5: |
| 18808 |
case PROCESSOR_POWER6: |
| 18809 |
case PROCESSOR_POWER7: |
| 18810 |
return 5; |
| 18811 |
case PROCESSOR_POWER8: |
| 18812 |
return 7; |
| 18813 |
case PROCESSOR_POWER9: |
| 18814 |
return 6; |
| 18815 |
case PROCESSOR_POWER10: |
| 18816 |
case PROCESSOR_POWER11: |
| 18817 |
return 8; |
| 18818 |
default: |
| 18819 |
return 1; |
| 18820 |
} |
| 18821 |
} |
| 18822 |
|
| 18823 |
/* Return how many instructions to look ahead for better insn |
| 18824 |
scheduling. */ |
| 18825 |
|
| 18826 |
static int |
| 18827 |
rs6000_use_sched_lookahead (void) |
| 18828 |
{ |
| 18829 |
switch (rs6000_tune) |
| 18830 |
{ |
| 18831 |
case PROCESSOR_PPC8540: |
| 18832 |
case PROCESSOR_PPC8548: |
| 18833 |
return 4; |
| 18834 |
|
| 18835 |
case PROCESSOR_CELL: |
| 18836 |
return (reload_completed ? 8 : 0); |
| 18837 |
|
| 18838 |
default: |
| 18839 |
return 0; |
| 18840 |
} |
| 18841 |
} |
| 18842 |
|
| 18843 |
/* We are choosing insn from the ready queue. Return zero if INSN can be |
| 18844 |
chosen. */ |
| 18845 |
static int |
| 18846 |
rs6000_use_sched_lookahead_guard (rtx_insn *insn, int ready_index) |
| 18847 |
{ |
| 18848 |
if (ready_index == 0) |
| 18849 |
return 0; |
| 18850 |
|
| 18851 |
if (rs6000_tune != PROCESSOR_CELL) |
| 18852 |
return 0; |
| 18853 |
|
| 18854 |
gcc_assert (insn != NULL_RTX && INSN_P (insn)); |
| 18855 |
|
| 18856 |
if (!reload_completed |
| 18857 |
|| is_nonpipeline_insn (insn) |
| 18858 |
|| is_microcoded_insn (insn)) |
| 18859 |
return 1; |
| 18860 |
|
| 18861 |
return 0; |
| 18862 |
} |
| 18863 |
|
| 18864 |
/* Determine if PAT refers to memory. If so, set MEM_REF to the MEM rtx |
| 18865 |
and return true. */ |
| 18866 |
|
| 18867 |
static bool |
| 18868 |
find_mem_ref (rtx pat, rtx *mem_ref) |
| 18869 |
{ |
| 18870 |
const char * fmt; |
| 18871 |
int i, j; |
| 18872 |
|
| 18873 |
/* stack_tie does not produce any real memory traffic. */ |
| 18874 |
if (tie_operand (pat, VOIDmode)) |
| 18875 |
return false; |
| 18876 |
|
| 18877 |
if (MEM_P (pat)) |
| 18878 |
{ |
| 18879 |
*mem_ref = pat; |
| 18880 |
return true; |
| 18881 |
} |
| 18882 |
|
| 18883 |
/* Recursively process the pattern. */ |
| 18884 |
fmt = GET_RTX_FORMAT (GET_CODE (pat)); |
| 18885 |
|
| 18886 |
for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--) |
| 18887 |
{ |
| 18888 |
if (fmt[i] == 'e') |
| 18889 |
{ |
| 18890 |
if (find_mem_ref (XEXP (pat, i), mem_ref)) |
| 18891 |
return true; |
| 18892 |
} |
| 18893 |
else if (fmt[i] == 'E') |
| 18894 |
for (j = XVECLEN (pat, i) - 1; j >= 0; j--) |
| 18895 |
{ |
| 18896 |
if (find_mem_ref (XVECEXP (pat, i, j), mem_ref)) |
| 18897 |
return true; |
| 18898 |
} |
| 18899 |
} |
| 18900 |
|
| 18901 |
return false; |
| 18902 |
} |
| 18903 |
|
| 18904 |
/* Determine if PAT is a PATTERN of a load insn. */ |
| 18905 |
|
| 18906 |
static bool |
| 18907 |
is_load_insn1 (rtx pat, rtx *load_mem) |
| 18908 |
{ |
| 18909 |
if (!pat || pat == NULL_RTX) |
| 18910 |
return false; |
| 18911 |
|
| 18912 |
if (GET_CODE (pat) == SET) |
| 18913 |
{ |
| 18914 |
if (REG_P (SET_DEST (pat))) |
| 18915 |
return find_mem_ref (SET_SRC (pat), load_mem); |
| 18916 |
else |
| 18917 |
return false; |
| 18918 |
} |
| 18919 |
|
| 18920 |
if (GET_CODE (pat) == PARALLEL) |
| 18921 |
{ |
| 18922 |
int i; |
| 18923 |
|
| 18924 |
for (i = 0; i < XVECLEN (pat, 0); i++) |
| 18925 |
if (is_load_insn1 (XVECEXP (pat, 0, i), load_mem)) |
| 18926 |
return true; |
| 18927 |
} |
| 18928 |
|
| 18929 |
return false; |
| 18930 |
} |
| 18931 |
|
| 18932 |
/* Determine if INSN loads from memory. */ |
| 18933 |
|
| 18934 |
static bool |
| 18935 |
is_load_insn (rtx insn, rtx *load_mem) |
| 18936 |
{ |
| 18937 |
if (!insn || !INSN_P (insn)) |
| 18938 |
return false; |
| 18939 |
|
| 18940 |
if (CALL_P (insn)) |
| 18941 |
return false; |
| 18942 |
|
| 18943 |
return is_load_insn1 (PATTERN (insn), load_mem); |
| 18944 |
} |
| 18945 |
|
| 18946 |
/* Determine if PAT is a PATTERN of a store insn. */ |
| 18947 |
|
| 18948 |
static bool |
| 18949 |
is_store_insn1 (rtx pat, rtx *str_mem) |
| 18950 |
{ |
| 18951 |
if (!pat || pat == NULL_RTX) |
| 18952 |
return false; |
| 18953 |
|
| 18954 |
if (GET_CODE (pat) == SET) |
| 18955 |
{ |
| 18956 |
if (REG_P (SET_SRC (pat)) || SUBREG_P (SET_SRC (pat))) |
| 18957 |
return find_mem_ref (SET_DEST (pat), str_mem); |
| 18958 |
else |
| 18959 |
return false; |
| 18960 |
} |
| 18961 |
|
| 18962 |
if (GET_CODE (pat) == PARALLEL) |
| 18963 |
{ |
| 18964 |
int i; |
| 18965 |
|
| 18966 |
for (i = 0; i < XVECLEN (pat, 0); i++) |
| 18967 |
if (is_store_insn1 (XVECEXP (pat, 0, i), str_mem)) |
| 18968 |
return true; |
| 18969 |
} |
| 18970 |
|
| 18971 |
return false; |
| 18972 |
} |
| 18973 |
|
| 18974 |
/* Determine if INSN stores to memory. */ |
| 18975 |
|
| 18976 |
static bool |
| 18977 |
is_store_insn (rtx insn, rtx *str_mem) |
| 18978 |
{ |
| 18979 |
if (!insn || !INSN_P (insn)) |
| 18980 |
return false; |
| 18981 |
|
| 18982 |
return is_store_insn1 (PATTERN (insn), str_mem); |
| 18983 |
} |
| 18984 |
|
| 18985 |
/* Return whether TYPE is a Power9 pairable vector instruction type. */ |
| 18986 |
|
| 18987 |
static bool |
| 18988 |
is_power9_pairable_vec_type (enum attr_type type) |
| 18989 |
{ |
| 18990 |
switch (type) |
| 18991 |
{ |
| 18992 |
case TYPE_VECSIMPLE: |
| 18993 |
case TYPE_VECCOMPLEX: |
| 18994 |
case TYPE_VECDIV: |
| 18995 |
case TYPE_VECCMP: |
| 18996 |
case TYPE_VECPERM: |
| 18997 |
case TYPE_VECFLOAT: |
| 18998 |
case TYPE_VECFDIV: |
| 18999 |
case TYPE_VECDOUBLE: |
| 19000 |
return true; |
| 19001 |
default: |
| 19002 |
break; |
| 19003 |
} |
| 19004 |
return false; |
| 19005 |
} |
| 19006 |
|
| 19007 |
/* Returns whether the dependence between INSN and NEXT is considered |
| 19008 |
costly by the given target. */ |
| 19009 |
|
| 19010 |
static bool |
| 19011 |
rs6000_is_costly_dependence (dep_t dep, int cost, int distance) |
| 19012 |
{ |
| 19013 |
rtx insn; |
| 19014 |
rtx next; |
| 19015 |
rtx load_mem, str_mem; |
| 19016 |
|
| 19017 |
/* If the flag is not enabled - no dependence is considered costly; |
| 19018 |
allow all dependent insns in the same group. |
| 19019 |
This is the most aggressive option. */ |
| 19020 |
if (rs6000_sched_costly_dep == no_dep_costly) |
| 19021 |
return false; |
| 19022 |
|
| 19023 |
/* If the flag is set to 1 - a dependence is always considered costly; |
| 19024 |
do not allow dependent instructions in the same group. |
| 19025 |
This is the most conservative option. */ |
| 19026 |
if (rs6000_sched_costly_dep == all_deps_costly) |
| 19027 |
return true; |
| 19028 |
|
| 19029 |
insn = DEP_PRO (dep); |
| 19030 |
next = DEP_CON (dep); |
| 19031 |
|
| 19032 |
if (rs6000_sched_costly_dep == store_to_load_dep_costly |
| 19033 |
&& is_load_insn (next, &load_mem) |
| 19034 |
&& is_store_insn (insn, &str_mem)) |
| 19035 |
/* Prevent load after store in the same group. */ |
| 19036 |
return true; |
| 19037 |
|
| 19038 |
if (rs6000_sched_costly_dep == true_store_to_load_dep_costly |
| 19039 |
&& is_load_insn (next, &load_mem) |
| 19040 |
&& is_store_insn (insn, &str_mem) |
| 19041 |
&& DEP_TYPE (dep) == REG_DEP_TRUE |
| 19042 |
&& mem_locations_overlap(str_mem, load_mem)) |
| 19043 |
/* Prevent load after store in the same group if it is a true |
| 19044 |
dependence. */ |
| 19045 |
return true; |
| 19046 |
|
| 19047 |
/* The flag is set to X; dependences with latency >= X are considered costly, |
| 19048 |
and will not be scheduled in the same group. */ |
| 19049 |
if (rs6000_sched_costly_dep <= max_dep_latency |
| 19050 |
&& ((cost - distance) >= (int)rs6000_sched_costly_dep)) |
| 19051 |
return true; |
| 19052 |
|
| 19053 |
return false; |
| 19054 |
} |
| 19055 |
|
| 19056 |
/* Return the next insn after INSN that is found before TAIL is reached, |
| 19057 |
skipping any "non-active" insns - insns that will not actually occupy |
| 19058 |
an issue slot. Return NULL_RTX if such an insn is not found. */ |
| 19059 |
|
| 19060 |
static rtx_insn * |
| 19061 |
get_next_active_insn (rtx_insn *insn, rtx_insn *tail) |
| 19062 |
{ |
| 19063 |
if (insn == NULL_RTX || insn == tail) |
| 19064 |
return NULL; |
| 19065 |
|
| 19066 |
while (1) |
| 19067 |
{ |
| 19068 |
insn = NEXT_INSN (insn); |
| 19069 |
if (insn == NULL_RTX || insn == tail) |
| 19070 |
return NULL; |
| 19071 |
|
| 19072 |
if (CALL_P (insn) |
| 19073 |
|| JUMP_P (insn) || JUMP_TABLE_DATA_P (insn) |
| 19074 |
|| (NONJUMP_INSN_P (insn) |
| 19075 |
&& GET_CODE (PATTERN (insn)) != USE |
| 19076 |
&& GET_CODE (PATTERN (insn)) != CLOBBER |
| 19077 |
&& INSN_CODE (insn) != CODE_FOR_stack_tie)) |
| 19078 |
break; |
| 19079 |
} |
| 19080 |
return insn; |
| 19081 |
} |
| 19082 |
|
| 19083 |
/* Move instruction at POS to the end of the READY list. */ |
| 19084 |
|
| 19085 |
static void |
| 19086 |
move_to_end_of_ready (rtx_insn **ready, int pos, int lastpos) |
| 19087 |
{ |
| 19088 |
rtx_insn *tmp; |
| 19089 |
int i; |
| 19090 |
|
| 19091 |
tmp = ready[pos]; |
| 19092 |
for (i = pos; i < lastpos; i++) |
| 19093 |
ready[i] = ready[i + 1]; |
| 19094 |
ready[lastpos] = tmp; |
| 19095 |
} |
| 19096 |
|
| 19097 |
/* Do Power6 specific sched_reorder2 reordering of ready list. */ |
| 19098 |
|
| 19099 |
static int |
| 19100 |
power6_sched_reorder2 (rtx_insn **ready, int lastpos) |
| 19101 |
{ |
| 19102 |
/* For Power6, we need to handle some special cases to try and keep the |
| 19103 |
store queue from overflowing and triggering expensive flushes. |
| 19104 |
|
| 19105 |
This code monitors how load and store instructions are being issued |
| 19106 |
and skews the ready list one way or the other to increase the likelihood |
| 19107 |
that a desired instruction is issued at the proper time. |
| 19108 |
|
| 19109 |
A couple of things are done. First, we maintain a "load_store_pendulum" |
| 19110 |
to track the current state of load/store issue. |
| 19111 |
|
| 19112 |
- If the pendulum is at zero, then no loads or stores have been |
| 19113 |
issued in the current cycle so we do nothing. |
| 19114 |
|
| 19115 |
- If the pendulum is 1, then a single load has been issued in this |
| 19116 |
cycle and we attempt to locate another load in the ready list to |
| 19117 |
issue with it. |
| 19118 |
|
| 19119 |
- If the pendulum is -2, then two stores have already been |
| 19120 |
issued in this cycle, so we increase the priority of the first load |
| 19121 |
in the ready list to increase it's likelihood of being chosen first |
| 19122 |
in the next cycle. |
| 19123 |
|
| 19124 |
- If the pendulum is -1, then a single store has been issued in this |
| 19125 |
cycle and we attempt to locate another store in the ready list to |
| 19126 |
issue with it, preferring a store to an adjacent memory location to |
| 19127 |
facilitate store pairing in the store queue. |
| 19128 |
|
| 19129 |
- If the pendulum is 2, then two loads have already been |
| 19130 |
issued in this cycle, so we increase the priority of the first store |
| 19131 |
in the ready list to increase it's likelihood of being chosen first |
| 19132 |
in the next cycle. |
| 19133 |
|
| 19134 |
- If the pendulum < -2 or > 2, then do nothing. |
| 19135 |
|
| 19136 |
Note: This code covers the most common scenarios. There exist non |
| 19137 |
load/store instructions which make use of the LSU and which |
| 19138 |
would need to be accounted for to strictly model the behavior |
| 19139 |
of the machine. Those instructions are currently unaccounted |
| 19140 |
for to help minimize compile time overhead of this code. |
| 19141 |
*/ |
| 19142 |
int pos; |
| 19143 |
rtx load_mem, str_mem; |
| 19144 |
|
| 19145 |
if (is_store_insn (last_scheduled_insn, &str_mem)) |
| 19146 |
/* Issuing a store, swing the load_store_pendulum to the left */ |
| 19147 |
load_store_pendulum--; |
| 19148 |
else if (is_load_insn (last_scheduled_insn, &load_mem)) |
| 19149 |
/* Issuing a load, swing the load_store_pendulum to the right */ |
| 19150 |
load_store_pendulum++; |
| 19151 |
else |
| 19152 |
return cached_can_issue_more; |
| 19153 |
|
| 19154 |
/* If the pendulum is balanced, or there is only one instruction on |
| 19155 |
the ready list, then all is well, so return. */ |
| 19156 |
if ((load_store_pendulum == 0) || (lastpos <= 0)) |
| 19157 |
return cached_can_issue_more; |
| 19158 |
|
| 19159 |
if (load_store_pendulum == 1) |
| 19160 |
{ |
| 19161 |
/* A load has been issued in this cycle. Scan the ready list |
| 19162 |
for another load to issue with it */ |
| 19163 |
pos = lastpos; |
| 19164 |
|
| 19165 |
while (pos >= 0) |
| 19166 |
{ |
| 19167 |
if (is_load_insn (ready[pos], &load_mem)) |
| 19168 |
{ |
| 19169 |
/* Found a load. Move it to the head of the ready list, |
| 19170 |
and adjust it's priority so that it is more likely to |
| 19171 |
stay there */ |
| 19172 |
move_to_end_of_ready (ready, pos, lastpos); |
| 19173 |
|
| 19174 |
if (!sel_sched_p () |
| 19175 |
&& INSN_PRIORITY_KNOWN (ready[lastpos])) |
| 19176 |
INSN_PRIORITY (ready[lastpos])++; |
| 19177 |
break; |
| 19178 |
} |
| 19179 |
pos--; |
| 19180 |
} |
| 19181 |
} |
| 19182 |
else if (load_store_pendulum == -2) |
| 19183 |
{ |
| 19184 |
/* Two stores have been issued in this cycle. Increase the |
| 19185 |
priority of the first load in the ready list to favor it for |
| 19186 |
issuing in the next cycle. */ |
| 19187 |
pos = lastpos; |
| 19188 |
|
| 19189 |
while (pos >= 0) |
| 19190 |
{ |
| 19191 |
if (is_load_insn (ready[pos], &load_mem) |
| 19192 |
&& !sel_sched_p () |
| 19193 |
&& INSN_PRIORITY_KNOWN (ready[pos])) |
| 19194 |
{ |
| 19195 |
INSN_PRIORITY (ready[pos])++; |
| 19196 |
|
| 19197 |
/* Adjust the pendulum to account for the fact that a load |
| 19198 |
was found and increased in priority. This is to prevent |
| 19199 |
increasing the priority of multiple loads */ |
| 19200 |
load_store_pendulum--; |
| 19201 |
|
| 19202 |
break; |
| 19203 |
} |
| 19204 |
pos--; |
| 19205 |
} |
| 19206 |
} |
| 19207 |
else if (load_store_pendulum == -1) |
| 19208 |
{ |
| 19209 |
/* A store has been issued in this cycle. Scan the ready list for |
| 19210 |
another store to issue with it, preferring a store to an adjacent |
| 19211 |
memory location */ |
| 19212 |
int first_store_pos = -1; |
| 19213 |
|
| 19214 |
pos = lastpos; |
| 19215 |
|
| 19216 |
while (pos >= 0) |
| 19217 |
{ |
| 19218 |
if (is_store_insn (ready[pos], &str_mem)) |
| 19219 |
{ |
| 19220 |
rtx str_mem2; |
| 19221 |
/* Maintain the index of the first store found on the |
| 19222 |
list */ |
| 19223 |
if (first_store_pos == -1) |
| 19224 |
first_store_pos = pos; |
| 19225 |
|
| 19226 |
if (is_store_insn (last_scheduled_insn, &str_mem2) |
| 19227 |
&& adjacent_mem_locations (str_mem, str_mem2)) |
| 19228 |
{ |
| 19229 |
/* Found an adjacent store. Move it to the head of the |
| 19230 |
ready list, and adjust it's priority so that it is |
| 19231 |
more likely to stay there */ |
| 19232 |
move_to_end_of_ready (ready, pos, lastpos); |
| 19233 |
|
| 19234 |
if (!sel_sched_p () |
| 19235 |
&& INSN_PRIORITY_KNOWN (ready[lastpos])) |
| 19236 |
INSN_PRIORITY (ready[lastpos])++; |
| 19237 |
|
| 19238 |
first_store_pos = -1; |
| 19239 |
|
| 19240 |
break; |
| 19241 |
}; |
| 19242 |
} |
| 19243 |
pos--; |
| 19244 |
} |
| 19245 |
|
| 19246 |
if (first_store_pos >= 0) |
| 19247 |
{ |
| 19248 |
/* An adjacent store wasn't found, but a non-adjacent store was, |
| 19249 |
so move the non-adjacent store to the front of the ready |
| 19250 |
list, and adjust its priority so that it is more likely to |
| 19251 |
stay there. */ |
| 19252 |
move_to_end_of_ready (ready, first_store_pos, lastpos); |
| 19253 |
if (!sel_sched_p () |
| 19254 |
&& INSN_PRIORITY_KNOWN (ready[lastpos])) |
| 19255 |
INSN_PRIORITY (ready[lastpos])++; |
| 19256 |
} |
| 19257 |
} |
| 19258 |
else if (load_store_pendulum == 2) |
| 19259 |
{ |
| 19260 |
/* Two loads have been issued in this cycle. Increase the priority |
| 19261 |
of the first store in the ready list to favor it for issuing in |
| 19262 |
the next cycle. */ |
| 19263 |
pos = lastpos; |
| 19264 |
|
| 19265 |
while (pos >= 0) |
| 19266 |
{ |
| 19267 |
if (is_store_insn (ready[pos], &str_mem) |
| 19268 |
&& !sel_sched_p () |
| 19269 |
&& INSN_PRIORITY_KNOWN (ready[pos])) |
| 19270 |
{ |
| 19271 |
INSN_PRIORITY (ready[pos])++; |
| 19272 |
|
| 19273 |
/* Adjust the pendulum to account for the fact that a store |
| 19274 |
was found and increased in priority. This is to prevent |
| 19275 |
increasing the priority of multiple stores */ |
| 19276 |
load_store_pendulum++; |
| 19277 |
|
| 19278 |
break; |
| 19279 |
} |
| 19280 |
pos--; |
| 19281 |
} |
| 19282 |
} |
| 19283 |
|
| 19284 |
return cached_can_issue_more; |
| 19285 |
} |
| 19286 |
|
| 19287 |
/* Do Power9 specific sched_reorder2 reordering of ready list. */ |
| 19288 |
|
| 19289 |
static int |
| 19290 |
power9_sched_reorder2 (rtx_insn **ready, int lastpos) |
| 19291 |
{ |
| 19292 |
int pos; |
| 19293 |
enum attr_type type, type2; |
| 19294 |
|
| 19295 |
type = get_attr_type (last_scheduled_insn); |
| 19296 |
|
| 19297 |
/* Try to issue fixed point divides back-to-back in pairs so they will be |
| 19298 |
routed to separate execution units and execute in parallel. */ |
| 19299 |
if (type == TYPE_DIV && divide_cnt == 0) |
| 19300 |
{ |
| 19301 |
/* First divide has been scheduled. */ |
| 19302 |
divide_cnt = 1; |
| 19303 |
|
| 19304 |
/* Scan the ready list looking for another divide, if found move it |
| 19305 |
to the end of the list so it is chosen next. */ |
| 19306 |
pos = lastpos; |
| 19307 |
while (pos >= 0) |
| 19308 |
{ |
| 19309 |
if (recog_memoized (ready[pos]) >= 0 |
| 19310 |
&& get_attr_type (ready[pos]) == TYPE_DIV) |
| 19311 |
{ |
| 19312 |
move_to_end_of_ready (ready, pos, lastpos); |
| 19313 |
break; |
| 19314 |
} |
| 19315 |
pos--; |
| 19316 |
} |
| 19317 |
} |
| 19318 |
else |
| 19319 |
{ |
| 19320 |
/* Last insn was the 2nd divide or not a divide, reset the counter. */ |
| 19321 |
divide_cnt = 0; |
| 19322 |
|
| 19323 |
/* The best dispatch throughput for vector and vector load insns can be |
| 19324 |
achieved by interleaving a vector and vector load such that they'll |
| 19325 |
dispatch to the same superslice. If this pairing cannot be achieved |
| 19326 |
then it is best to pair vector insns together and vector load insns |
| 19327 |
together. |
| 19328 |
|
| 19329 |
To aid in this pairing, vec_pairing maintains the current state with |
| 19330 |
the following values: |
| 19331 |
|
| 19332 |
0 : Initial state, no vecload/vector pairing has been started. |
| 19333 |
|
| 19334 |
1 : A vecload or vector insn has been issued and a candidate for |
| 19335 |
pairing has been found and moved to the end of the ready |
| 19336 |
list. */ |
| 19337 |
if (type == TYPE_VECLOAD) |
| 19338 |
{ |
| 19339 |
/* Issued a vecload. */ |
| 19340 |
if (vec_pairing == 0) |
| 19341 |
{ |
| 19342 |
int vecload_pos = -1; |
| 19343 |
/* We issued a single vecload, look for a vector insn to pair it |
| 19344 |
with. If one isn't found, try to pair another vecload. */ |
| 19345 |
pos = lastpos; |
| 19346 |
while (pos >= 0) |
| 19347 |
{ |
| 19348 |
if (recog_memoized (ready[pos]) >= 0) |
| 19349 |
{ |
| 19350 |
type2 = get_attr_type (ready[pos]); |
| 19351 |
if (is_power9_pairable_vec_type (type2)) |
| 19352 |
{ |
| 19353 |
/* Found a vector insn to pair with, move it to the |
| 19354 |
end of the ready list so it is scheduled next. */ |
| 19355 |
move_to_end_of_ready (ready, pos, lastpos); |
| 19356 |
vec_pairing = 1; |
| 19357 |
return cached_can_issue_more; |
| 19358 |
} |
| 19359 |
else if (type2 == TYPE_VECLOAD && vecload_pos == -1) |
| 19360 |
/* Remember position of first vecload seen. */ |
| 19361 |
vecload_pos = pos; |
| 19362 |
} |
| 19363 |
pos--; |
| 19364 |
} |
| 19365 |
if (vecload_pos >= 0) |
| 19366 |
{ |
| 19367 |
/* Didn't find a vector to pair with but did find a vecload, |
| 19368 |
move it to the end of the ready list. */ |
| 19369 |
move_to_end_of_ready (ready, vecload_pos, lastpos); |
| 19370 |
vec_pairing = 1; |
| 19371 |
return cached_can_issue_more; |
| 19372 |
} |
| 19373 |
} |
| 19374 |
} |
| 19375 |
else if (is_power9_pairable_vec_type (type)) |
| 19376 |
{ |
| 19377 |
/* Issued a vector operation. */ |
| 19378 |
if (vec_pairing == 0) |
| 19379 |
{ |
| 19380 |
int vec_pos = -1; |
| 19381 |
/* We issued a single vector insn, look for a vecload to pair it |
| 19382 |
with. If one isn't found, try to pair another vector. */ |
| 19383 |
pos = lastpos; |
| 19384 |
while (pos >= 0) |
| 19385 |
{ |
| 19386 |
if (recog_memoized (ready[pos]) >= 0) |
| 19387 |
{ |
| 19388 |
type2 = get_attr_type (ready[pos]); |
| 19389 |
if (type2 == TYPE_VECLOAD) |
| 19390 |
{ |
| 19391 |
/* Found a vecload insn to pair with, move it to the |
| 19392 |
end of the ready list so it is scheduled next. */ |
| 19393 |
move_to_end_of_ready (ready, pos, lastpos); |
| 19394 |
vec_pairing = 1; |
| 19395 |
return cached_can_issue_more; |
| 19396 |
} |
| 19397 |
else if (is_power9_pairable_vec_type (type2) |
| 19398 |
&& vec_pos == -1) |
| 19399 |
/* Remember position of first vector insn seen. */ |
| 19400 |
vec_pos = pos; |
| 19401 |
} |
| 19402 |
pos--; |
| 19403 |
} |
| 19404 |
if (vec_pos >= 0) |
| 19405 |
{ |
| 19406 |
/* Didn't find a vecload to pair with but did find a vector |
| 19407 |
insn, move it to the end of the ready list. */ |
| 19408 |
move_to_end_of_ready (ready, vec_pos, lastpos); |
| 19409 |
vec_pairing = 1; |
| 19410 |
return cached_can_issue_more; |
| 19411 |
} |
| 19412 |
} |
| 19413 |
} |
| 19414 |
|
| 19415 |
/* We've either finished a vec/vecload pair, couldn't find an insn to |
| 19416 |
continue the current pair, or the last insn had nothing to do with |
| 19417 |
with pairing. In any case, reset the state. */ |
| 19418 |
vec_pairing = 0; |
| 19419 |
} |
| 19420 |
|
| 19421 |
return cached_can_issue_more; |
| 19422 |
} |
| 19423 |
|
| 19424 |
/* Determine if INSN is a store to memory that can be fused with a similar |
| 19425 |
adjacent store. */ |
| 19426 |
|
| 19427 |
static bool |
| 19428 |
is_fusable_store (rtx_insn *insn, rtx *str_mem) |
| 19429 |
{ |
| 19430 |
/* Insn must be a non-prefixed base+disp form store. */ |
| 19431 |
if (is_store_insn (insn, str_mem) |
| 19432 |
&& get_attr_prefixed (insn) == PREFIXED_NO |
| 19433 |
&& get_attr_update (insn) == UPDATE_NO |
| 19434 |
&& get_attr_indexed (insn) == INDEXED_NO) |
| 19435 |
{ |
| 19436 |
/* Further restrictions by mode and size. */ |
| 19437 |
if (!MEM_SIZE_KNOWN_P (*str_mem)) |
| 19438 |
return false; |
| 19439 |
|
| 19440 |
machine_mode mode = GET_MODE (*str_mem); |
| 19441 |
HOST_WIDE_INT size = MEM_SIZE (*str_mem); |
| 19442 |
|
| 19443 |
if (INTEGRAL_MODE_P (mode)) |
| 19444 |
/* Must be word or dword size. */ |
| 19445 |
return (size == 4 || size == 8); |
| 19446 |
else if (FLOAT_MODE_P (mode)) |
| 19447 |
/* Must be dword size. */ |
| 19448 |
return (size == 8); |
| 19449 |
} |
| 19450 |
|
| 19451 |
return false; |
| 19452 |
} |
| 19453 |
|
| 19454 |
/* Do Power10 specific reordering of the ready list. */ |
| 19455 |
|
| 19456 |
static int |
| 19457 |
power10_sched_reorder (rtx_insn **ready, int lastpos) |
| 19458 |
{ |
| 19459 |
rtx mem1; |
| 19460 |
|
| 19461 |
/* Do store fusion during sched2 only. */ |
| 19462 |
if (!reload_completed) |
| 19463 |
return cached_can_issue_more; |
| 19464 |
|
| 19465 |
/* If the prior insn finished off a store fusion pair then simply |
| 19466 |
reset the counter and return, nothing more to do. */ |
| 19467 |
if (load_store_pendulum != 0) |
| 19468 |
{ |
| 19469 |
load_store_pendulum = 0; |
| 19470 |
return cached_can_issue_more; |
| 19471 |
} |
| 19472 |
|
| 19473 |
/* Try to pair certain store insns to adjacent memory locations |
| 19474 |
so that the hardware will fuse them to a single operation. */ |
| 19475 |
if (TARGET_P10_FUSION && is_fusable_store (last_scheduled_insn, &mem1)) |
| 19476 |
{ |
| 19477 |
|
| 19478 |
/* A fusable store was just scheduled. Scan the ready list for another |
| 19479 |
store that it can fuse with. */ |
| 19480 |
int pos = lastpos; |
| 19481 |
while (pos >= 0) |
| 19482 |
{ |
| 19483 |
rtx mem2; |
| 19484 |
/* GPR stores can be ascending or descending offsets, FPR/VSR stores |
| 19485 |
must be ascending only. */ |
| 19486 |
if (is_fusable_store (ready[pos], &mem2) |
| 19487 |
&& ((INTEGRAL_MODE_P (GET_MODE (mem1)) |
| 19488 |
&& adjacent_mem_locations (mem1, mem2)) |
| 19489 |
|| (FLOAT_MODE_P (GET_MODE (mem1)) |
| 19490 |
&& (adjacent_mem_locations (mem1, mem2) == mem1)))) |
| 19491 |
{ |
| 19492 |
/* Found a fusable store. Move it to the end of the ready list |
| 19493 |
so it is scheduled next. */ |
| 19494 |
move_to_end_of_ready (ready, pos, lastpos); |
| 19495 |
|
| 19496 |
load_store_pendulum = -1; |
| 19497 |
break; |
| 19498 |
} |
| 19499 |
pos--; |
| 19500 |
} |
| 19501 |
} |
| 19502 |
|
| 19503 |
return cached_can_issue_more; |
| 19504 |
} |
| 19505 |
|
| 19506 |
/* We are about to begin issuing insns for this clock cycle. */ |
| 19507 |
|
| 19508 |
static int |
| 19509 |
rs6000_sched_reorder (FILE *dump ATTRIBUTE_UNUSED, int sched_verbose, |
| 19510 |
rtx_insn **ready ATTRIBUTE_UNUSED, |
| 19511 |
int *pn_ready ATTRIBUTE_UNUSED, |
| 19512 |
int clock_var ATTRIBUTE_UNUSED) |
| 19513 |
{ |
| 19514 |
int n_ready = *pn_ready; |
| 19515 |
|
| 19516 |
if (sched_verbose) |
| 19517 |
fprintf (dump, "// rs6000_sched_reorder :\n"); |
| 19518 |
|
| 19519 |
/* Reorder the ready list, if the second to last ready insn |
| 19520 |
is a nonepipeline insn. */ |
| 19521 |
if (rs6000_tune == PROCESSOR_CELL && n_ready > 1) |
| 19522 |
{ |
| 19523 |
if (is_nonpipeline_insn (ready[n_ready - 1]) |
| 19524 |
&& (recog_memoized (ready[n_ready - 2]) > 0)) |
| 19525 |
/* Simply swap first two insns. */ |
| 19526 |
std::swap (ready[n_ready - 1], ready[n_ready - 2]); |
| 19527 |
} |
| 19528 |
|
| 19529 |
if (rs6000_tune == PROCESSOR_POWER6) |
| 19530 |
load_store_pendulum = 0; |
| 19531 |
|
| 19532 |
/* Do Power10/Power11 dependent reordering. */ |
| 19533 |
if (last_scheduled_insn |
| 19534 |
&& (rs6000_tune == PROCESSOR_POWER10 |
| 19535 |
|| rs6000_tune == PROCESSOR_POWER11)) |
| 19536 |
power10_sched_reorder (ready, n_ready - 1); |
| 19537 |
|
| 19538 |
return rs6000_issue_rate (); |
| 19539 |
} |
| 19540 |
|
| 19541 |
/* Like rs6000_sched_reorder, but called after issuing each insn. */ |
| 19542 |
|
| 19543 |
static int |
| 19544 |
rs6000_sched_reorder2 (FILE *dump, int sched_verbose, rtx_insn **ready, |
| 19545 |
int *pn_ready, int clock_var ATTRIBUTE_UNUSED) |
| 19546 |
{ |
| 19547 |
if (sched_verbose) |
| 19548 |
fprintf (dump, "// rs6000_sched_reorder2 :\n"); |
| 19549 |
|
| 19550 |
/* Do Power6 dependent reordering if necessary. */ |
| 19551 |
if (rs6000_tune == PROCESSOR_POWER6 && last_scheduled_insn) |
| 19552 |
return power6_sched_reorder2 (ready, *pn_ready - 1); |
| 19553 |
|
| 19554 |
/* Do Power9 dependent reordering if necessary. */ |
| 19555 |
if (rs6000_tune == PROCESSOR_POWER9 && last_scheduled_insn |
| 19556 |
&& recog_memoized (last_scheduled_insn) >= 0) |
| 19557 |
return power9_sched_reorder2 (ready, *pn_ready - 1); |
| 19558 |
|
| 19559 |
/* Do Power10/Power11 dependent reordering. */ |
| 19560 |
if (last_scheduled_insn |
| 19561 |
&& (rs6000_tune == PROCESSOR_POWER10 |
| 19562 |
|| rs6000_tune == PROCESSOR_POWER11)) |
| 19563 |
return power10_sched_reorder (ready, *pn_ready - 1); |
| 19564 |
|
| 19565 |
return cached_can_issue_more; |
| 19566 |
} |
| 19567 |
|
| 19568 |
/* Return whether the presence of INSN causes a dispatch group termination |
| 19569 |
of group WHICH_GROUP. |
| 19570 |
|
| 19571 |
If WHICH_GROUP == current_group, this function will return true if INSN |
| 19572 |
causes the termination of the current group (i.e, the dispatch group to |
| 19573 |
which INSN belongs). This means that INSN will be the last insn in the |
| 19574 |
group it belongs to. |
| 19575 |
|
| 19576 |
If WHICH_GROUP == previous_group, this function will return true if INSN |
| 19577 |
causes the termination of the previous group (i.e, the dispatch group that |
| 19578 |
precedes the group to which INSN belongs). This means that INSN will be |
| 19579 |
the first insn in the group it belongs to). */ |
| 19580 |
|
| 19581 |
static bool |
| 19582 |
insn_terminates_group_p (rtx_insn *insn, enum group_termination which_group) |
| 19583 |
{ |
| 19584 |
bool first, last; |
| 19585 |
|
| 19586 |
if (! insn) |
| 19587 |
return false; |
| 19588 |
|
| 19589 |
first = insn_must_be_first_in_group (insn); |
| 19590 |
last = insn_must_be_last_in_group (insn); |
| 19591 |
|
| 19592 |
if (first && last) |
| 19593 |
return true; |
| 19594 |
|
| 19595 |
if (which_group == current_group) |
| 19596 |
return last; |
| 19597 |
else if (which_group == previous_group) |
| 19598 |
return first; |
| 19599 |
|
| 19600 |
return false; |
| 19601 |
} |
| 19602 |
|
| 19603 |
|
| 19604 |
static bool |
| 19605 |
insn_must_be_first_in_group (rtx_insn *insn) |
| 19606 |
{ |
| 19607 |
enum attr_type type; |
| 19608 |
|
| 19609 |
if (!insn |
| 19610 |
|| NOTE_P (insn) |
| 19611 |
|| DEBUG_INSN_P (insn) |
| 19612 |
|| GET_CODE (PATTERN (insn)) == USE |
| 19613 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 19614 |
return false; |
| 19615 |
|
| 19616 |
switch (rs6000_tune) |
| 19617 |
{ |
| 19618 |
case PROCESSOR_POWER5: |
| 19619 |
if (is_cracked_insn (insn)) |
| 19620 |
return true; |
| 19621 |
/* FALLTHRU */ |
| 19622 |
case PROCESSOR_POWER4: |
| 19623 |
if (is_microcoded_insn (insn)) |
| 19624 |
return true; |
| 19625 |
|
| 19626 |
if (!rs6000_sched_groups) |
| 19627 |
return false; |
| 19628 |
|
| 19629 |
type = get_attr_type (insn); |
| 19630 |
|
| 19631 |
switch (type) |
| 19632 |
{ |
| 19633 |
case TYPE_MFCR: |
| 19634 |
case TYPE_MFCRF: |
| 19635 |
case TYPE_MTCR: |
| 19636 |
case TYPE_CR_LOGICAL: |
| 19637 |
case TYPE_MTJMPR: |
| 19638 |
case TYPE_MFJMPR: |
| 19639 |
case TYPE_DIV: |
| 19640 |
case TYPE_LOAD_L: |
| 19641 |
case TYPE_STORE_C: |
| 19642 |
case TYPE_ISYNC: |
| 19643 |
case TYPE_SYNC: |
| 19644 |
return true; |
| 19645 |
default: |
| 19646 |
break; |
| 19647 |
} |
| 19648 |
break; |
| 19649 |
case PROCESSOR_POWER6: |
| 19650 |
type = get_attr_type (insn); |
| 19651 |
|
| 19652 |
switch (type) |
| 19653 |
{ |
| 19654 |
case TYPE_EXTS: |
| 19655 |
case TYPE_CNTLZ: |
| 19656 |
case TYPE_TRAP: |
| 19657 |
case TYPE_MUL: |
| 19658 |
case TYPE_INSERT: |
| 19659 |
case TYPE_FPCOMPARE: |
| 19660 |
case TYPE_MFCR: |
| 19661 |
case TYPE_MTCR: |
| 19662 |
case TYPE_MFJMPR: |
| 19663 |
case TYPE_MTJMPR: |
| 19664 |
case TYPE_ISYNC: |
| 19665 |
case TYPE_SYNC: |
| 19666 |
case TYPE_LOAD_L: |
| 19667 |
case TYPE_STORE_C: |
| 19668 |
return true; |
| 19669 |
case TYPE_SHIFT: |
| 19670 |
if (get_attr_dot (insn) == DOT_NO |
| 19671 |
|| get_attr_var_shift (insn) == VAR_SHIFT_NO) |
| 19672 |
return true; |
| 19673 |
else |
| 19674 |
break; |
| 19675 |
case TYPE_DIV: |
| 19676 |
if (get_attr_size (insn) == SIZE_32) |
| 19677 |
return true; |
| 19678 |
else |
| 19679 |
break; |
| 19680 |
case TYPE_LOAD: |
| 19681 |
case TYPE_STORE: |
| 19682 |
case TYPE_FPLOAD: |
| 19683 |
case TYPE_FPSTORE: |
| 19684 |
if (get_attr_update (insn) == UPDATE_YES) |
| 19685 |
return true; |
| 19686 |
else |
| 19687 |
break; |
| 19688 |
default: |
| 19689 |
break; |
| 19690 |
} |
| 19691 |
break; |
| 19692 |
case PROCESSOR_POWER7: |
| 19693 |
type = get_attr_type (insn); |
| 19694 |
|
| 19695 |
switch (type) |
| 19696 |
{ |
| 19697 |
case TYPE_CR_LOGICAL: |
| 19698 |
case TYPE_MFCR: |
| 19699 |
case TYPE_MFCRF: |
| 19700 |
case TYPE_MTCR: |
| 19701 |
case TYPE_DIV: |
| 19702 |
case TYPE_ISYNC: |
| 19703 |
case TYPE_LOAD_L: |
| 19704 |
case TYPE_STORE_C: |
| 19705 |
case TYPE_MFJMPR: |
| 19706 |
case TYPE_MTJMPR: |
| 19707 |
return true; |
| 19708 |
case TYPE_MUL: |
| 19709 |
case TYPE_SHIFT: |
| 19710 |
case TYPE_EXTS: |
| 19711 |
if (get_attr_dot (insn) == DOT_YES) |
| 19712 |
return true; |
| 19713 |
else |
| 19714 |
break; |
| 19715 |
case TYPE_LOAD: |
| 19716 |
if (get_attr_sign_extend (insn) == SIGN_EXTEND_YES |
| 19717 |
|| get_attr_update (insn) == UPDATE_YES) |
| 19718 |
return true; |
| 19719 |
else |
| 19720 |
break; |
| 19721 |
case TYPE_STORE: |
| 19722 |
case TYPE_FPLOAD: |
| 19723 |
case TYPE_FPSTORE: |
| 19724 |
if (get_attr_update (insn) == UPDATE_YES) |
| 19725 |
return true; |
| 19726 |
else |
| 19727 |
break; |
| 19728 |
default: |
| 19729 |
break; |
| 19730 |
} |
| 19731 |
break; |
| 19732 |
case PROCESSOR_POWER8: |
| 19733 |
type = get_attr_type (insn); |
| 19734 |
|
| 19735 |
switch (type) |
| 19736 |
{ |
| 19737 |
case TYPE_CR_LOGICAL: |
| 19738 |
case TYPE_MFCR: |
| 19739 |
case TYPE_MFCRF: |
| 19740 |
case TYPE_MTCR: |
| 19741 |
case TYPE_SYNC: |
| 19742 |
case TYPE_ISYNC: |
| 19743 |
case TYPE_LOAD_L: |
| 19744 |
case TYPE_STORE_C: |
| 19745 |
case TYPE_VECSTORE: |
| 19746 |
case TYPE_MFJMPR: |
| 19747 |
case TYPE_MTJMPR: |
| 19748 |
return true; |
| 19749 |
case TYPE_SHIFT: |
| 19750 |
case TYPE_EXTS: |
| 19751 |
case TYPE_MUL: |
| 19752 |
if (get_attr_dot (insn) == DOT_YES) |
| 19753 |
return true; |
| 19754 |
else |
| 19755 |
break; |
| 19756 |
case TYPE_LOAD: |
| 19757 |
if (get_attr_sign_extend (insn) == SIGN_EXTEND_YES |
| 19758 |
|| get_attr_update (insn) == UPDATE_YES) |
| 19759 |
return true; |
| 19760 |
else |
| 19761 |
break; |
| 19762 |
case TYPE_STORE: |
| 19763 |
if (get_attr_update (insn) == UPDATE_YES |
| 19764 |
&& get_attr_indexed (insn) == INDEXED_YES) |
| 19765 |
return true; |
| 19766 |
else |
| 19767 |
break; |
| 19768 |
default: |
| 19769 |
break; |
| 19770 |
} |
| 19771 |
break; |
| 19772 |
default: |
| 19773 |
break; |
| 19774 |
} |
| 19775 |
|
| 19776 |
return false; |
| 19777 |
} |
| 19778 |
|
| 19779 |
static bool |
| 19780 |
insn_must_be_last_in_group (rtx_insn *insn) |
| 19781 |
{ |
| 19782 |
enum attr_type type; |
| 19783 |
|
| 19784 |
if (!insn |
| 19785 |
|| NOTE_P (insn) |
| 19786 |
|| DEBUG_INSN_P (insn) |
| 19787 |
|| GET_CODE (PATTERN (insn)) == USE |
| 19788 |
|| GET_CODE (PATTERN (insn)) == CLOBBER) |
| 19789 |
return false; |
| 19790 |
|
| 19791 |
switch (rs6000_tune) { |
| 19792 |
case PROCESSOR_POWER4: |
| 19793 |
case PROCESSOR_POWER5: |
| 19794 |
if (is_microcoded_insn (insn)) |
| 19795 |
return true; |
| 19796 |
|
| 19797 |
if (is_branch_slot_insn (insn)) |
| 19798 |
return true; |
| 19799 |
|
| 19800 |
break; |
| 19801 |
case PROCESSOR_POWER6: |
| 19802 |
type = get_attr_type (insn); |
| 19803 |
|
| 19804 |
switch (type) |
| 19805 |
{ |
| 19806 |
case TYPE_EXTS: |
| 19807 |
case TYPE_CNTLZ: |
| 19808 |
case TYPE_TRAP: |
| 19809 |
case TYPE_MUL: |
| 19810 |
case TYPE_FPCOMPARE: |
| 19811 |
case TYPE_MFCR: |
| 19812 |
case TYPE_MTCR: |
| 19813 |
case TYPE_MFJMPR: |
| 19814 |
case TYPE_MTJMPR: |
| 19815 |
case TYPE_ISYNC: |
| 19816 |
case TYPE_SYNC: |
| 19817 |
case TYPE_LOAD_L: |
| 19818 |
case TYPE_STORE_C: |
| 19819 |
return true; |
| 19820 |
case TYPE_SHIFT: |
| 19821 |
if (get_attr_dot (insn) == DOT_NO |
| 19822 |
|| get_attr_var_shift (insn) == VAR_SHIFT_NO) |
| 19823 |
return true; |
| 19824 |
else |
| 19825 |
break; |
| 19826 |
case TYPE_DIV: |
| 19827 |
if (get_attr_size (insn) == SIZE_32) |
| 19828 |
return true; |
| 19829 |
else |
| 19830 |
break; |
| 19831 |
default: |
| 19832 |
break; |
| 19833 |
} |
| 19834 |
break; |
| 19835 |
case PROCESSOR_POWER7: |
| 19836 |
type = get_attr_type (insn); |
| 19837 |
|
| 19838 |
switch (type) |
| 19839 |
{ |
| 19840 |
case TYPE_ISYNC: |
| 19841 |
case TYPE_SYNC: |
| 19842 |
case TYPE_LOAD_L: |
| 19843 |
case TYPE_STORE_C: |
| 19844 |
return true; |
| 19845 |
case TYPE_LOAD: |
| 19846 |
if (get_attr_sign_extend (insn) == SIGN_EXTEND_YES |
| 19847 |
&& get_attr_update (insn) == UPDATE_YES) |
| 19848 |
return true; |
| 19849 |
else |
| 19850 |
break; |
| 19851 |
case TYPE_STORE: |
| 19852 |
if (get_attr_update (insn) == UPDATE_YES |
| 19853 |
&& get_attr_indexed (insn) == INDEXED_YES) |
| 19854 |
return true; |
| 19855 |
else |
| 19856 |
break; |
| 19857 |
default: |
| 19858 |
break; |
| 19859 |
} |
| 19860 |
break; |
| 19861 |
case PROCESSOR_POWER8: |
| 19862 |
type = get_attr_type (insn); |
| 19863 |
|
| 19864 |
switch (type) |
| 19865 |
{ |
| 19866 |
case TYPE_MFCR: |
| 19867 |
case TYPE_MTCR: |
| 19868 |
case TYPE_ISYNC: |
| 19869 |
case TYPE_SYNC: |
| 19870 |
case TYPE_LOAD_L: |
| 19871 |
case TYPE_STORE_C: |
| 19872 |
return true; |
| 19873 |
case TYPE_LOAD: |
| 19874 |
if (get_attr_sign_extend (insn) == SIGN_EXTEND_YES |
| 19875 |
&& get_attr_update (insn) == UPDATE_YES) |
| 19876 |
return true; |
| 19877 |
else |
| 19878 |
break; |
| 19879 |
case TYPE_STORE: |
| 19880 |
if (get_attr_update (insn) == UPDATE_YES |
| 19881 |
&& get_attr_indexed (insn) == INDEXED_YES) |
| 19882 |
return true; |
| 19883 |
else |
| 19884 |
break; |
| 19885 |
default: |
| 19886 |
break; |
| 19887 |
} |
| 19888 |
break; |
| 19889 |
default: |
| 19890 |
break; |
| 19891 |
} |
| 19892 |
|
| 19893 |
return false; |
| 19894 |
} |
| 19895 |
|
| 19896 |
/* Return true if it is recommended to keep NEXT_INSN "far" (in a separate |
| 19897 |
dispatch group) from the insns in GROUP_INSNS. Return false otherwise. */ |
| 19898 |
|
| 19899 |
static bool |
| 19900 |
is_costly_group (rtx *group_insns, rtx next_insn) |
| 19901 |
{ |
| 19902 |
int i; |
| 19903 |
int issue_rate = rs6000_issue_rate (); |
| 19904 |
|
| 19905 |
for (i = 0; i < issue_rate; i++) |
| 19906 |
{ |
| 19907 |
sd_iterator_def sd_it; |
| 19908 |
dep_t dep; |
| 19909 |
rtx insn = group_insns[i]; |
| 19910 |
|
| 19911 |
if (!insn) |
| 19912 |
continue; |
| 19913 |
|
| 19914 |
FOR_EACH_DEP (insn, SD_LIST_RES_FORW, sd_it, dep) |
| 19915 |
{ |
| 19916 |
rtx next = DEP_CON (dep); |
| 19917 |
|
| 19918 |
if (next == next_insn |
| 19919 |
&& rs6000_is_costly_dependence (dep, dep_cost (dep), 0)) |
| 19920 |
return true; |
| 19921 |
} |
| 19922 |
} |
| 19923 |
|
| 19924 |
return false; |
| 19925 |
} |
| 19926 |
|
| 19927 |
/* Utility of the function redefine_groups. |
| 19928 |
Check if it is too costly to schedule NEXT_INSN together with GROUP_INSNS |
| 19929 |
in the same dispatch group. If so, insert nops before NEXT_INSN, in order |
| 19930 |
to keep it "far" (in a separate group) from GROUP_INSNS, following |
| 19931 |
one of the following schemes, depending on the value of the flag |
| 19932 |
-minsert_sched_nops = X: |
| 19933 |
(1) X == sched_finish_regroup_exact: insert exactly as many nops as needed |
| 19934 |
in order to force NEXT_INSN into a separate group. |
| 19935 |
(2) X < sched_finish_regroup_exact: insert exactly X nops. |
| 19936 |
GROUP_END, CAN_ISSUE_MORE and GROUP_COUNT record the state after nop |
| 19937 |
insertion (has a group just ended, how many vacant issue slots remain in the |
| 19938 |
last group, and how many dispatch groups were encountered so far). */ |
| 19939 |
|
| 19940 |
static int |
| 19941 |
force_new_group (int sched_verbose, FILE *dump, rtx *group_insns, |
| 19942 |
rtx_insn *next_insn, bool *group_end, int can_issue_more, |
| 19943 |
int *group_count) |
| 19944 |
{ |
| 19945 |
rtx nop; |
| 19946 |
bool force; |
| 19947 |
int issue_rate = rs6000_issue_rate (); |
| 19948 |
bool end = *group_end; |
| 19949 |
int i; |
| 19950 |
|
| 19951 |
if (next_insn == NULL_RTX || DEBUG_INSN_P (next_insn)) |
| 19952 |
return can_issue_more; |
| 19953 |
|
| 19954 |
if (rs6000_sched_insert_nops > sched_finish_regroup_exact) |
| 19955 |
return can_issue_more; |
| 19956 |
|
| 19957 |
force = is_costly_group (group_insns, next_insn); |
| 19958 |
if (!force) |
| 19959 |
return can_issue_more; |
| 19960 |
|
| 19961 |
if (sched_verbose > 6) |
| 19962 |
fprintf (dump,"force: group count = %d, can_issue_more = %d\n", |
| 19963 |
*group_count ,can_issue_more); |
| 19964 |
|
| 19965 |
if (rs6000_sched_insert_nops == sched_finish_regroup_exact) |
| 19966 |
{ |
| 19967 |
if (*group_end) |
| 19968 |
can_issue_more = 0; |
| 19969 |
|
| 19970 |
/* Since only a branch can be issued in the last issue_slot, it is |
| 19971 |
sufficient to insert 'can_issue_more - 1' nops if next_insn is not |
| 19972 |
a branch. If next_insn is a branch, we insert 'can_issue_more' nops; |
| 19973 |
in this case the last nop will start a new group and the branch |
| 19974 |
will be forced to the new group. */ |
| 19975 |
if (can_issue_more && !is_branch_slot_insn (next_insn)) |
| 19976 |
can_issue_more--; |
| 19977 |
|
| 19978 |
/* Do we have a special group ending nop? */ |
| 19979 |
if (rs6000_tune == PROCESSOR_POWER6 || rs6000_tune == PROCESSOR_POWER7 |
| 19980 |
|| rs6000_tune == PROCESSOR_POWER8) |
| 19981 |
{ |
| 19982 |
nop = gen_group_ending_nop (); |
| 19983 |
emit_insn_before (nop, next_insn); |
| 19984 |
can_issue_more = 0; |
| 19985 |
} |
| 19986 |
else |
| 19987 |
while (can_issue_more > 0) |
| 19988 |
{ |
| 19989 |
nop = gen_nop (); |
| 19990 |
emit_insn_before (nop, next_insn); |
| 19991 |
can_issue_more--; |
| 19992 |
} |
| 19993 |
|
| 19994 |
*group_end = true; |
| 19995 |
return 0; |
| 19996 |
} |
| 19997 |
|
| 19998 |
if (rs6000_sched_insert_nops < sched_finish_regroup_exact) |
| 19999 |
{ |
| 20000 |
int n_nops = rs6000_sched_insert_nops; |
| 20001 |
|
| 20002 |
/* Nops can't be issued from the branch slot, so the effective |
| 20003 |
issue_rate for nops is 'issue_rate - 1'. */ |
| 20004 |
if (can_issue_more == 0) |
| 20005 |
can_issue_more = issue_rate; |
| 20006 |
can_issue_more--; |
| 20007 |
if (can_issue_more == 0) |
| 20008 |
{ |
| 20009 |
can_issue_more = issue_rate - 1; |
| 20010 |
(*group_count)++; |
| 20011 |
end = true; |
| 20012 |
for (i = 0; i < issue_rate; i++) |
| 20013 |
{ |
| 20014 |
group_insns[i] = 0; |
| 20015 |
} |
| 20016 |
} |
| 20017 |
|
| 20018 |
while (n_nops > 0) |
| 20019 |
{ |
| 20020 |
nop = gen_nop (); |
| 20021 |
emit_insn_before (nop, next_insn); |
| 20022 |
if (can_issue_more == issue_rate - 1) /* new group begins */ |
| 20023 |
end = false; |
| 20024 |
can_issue_more--; |
| 20025 |
if (can_issue_more == 0) |
| 20026 |
{ |
| 20027 |
can_issue_more = issue_rate - 1; |
| 20028 |
(*group_count)++; |
| 20029 |
end = true; |
| 20030 |
for (i = 0; i < issue_rate; i++) |
| 20031 |
{ |
| 20032 |
group_insns[i] = 0; |
| 20033 |
} |
| 20034 |
} |
| 20035 |
n_nops--; |
| 20036 |
} |
| 20037 |
|
| 20038 |
/* Scale back relative to 'issue_rate' (instead of 'issue_rate - 1'). */ |
| 20039 |
can_issue_more++; |
| 20040 |
|
| 20041 |
/* Is next_insn going to start a new group? */ |
| 20042 |
*group_end |
| 20043 |
= (end |
| 20044 |
|| (can_issue_more == 1 && !is_branch_slot_insn (next_insn)) |
| 20045 |
|| (can_issue_more <= 2 && is_cracked_insn (next_insn)) |
| 20046 |
|| (can_issue_more < issue_rate && |
| 20047 |
insn_terminates_group_p (next_insn, previous_group))); |
| 20048 |
if (*group_end && end) |
| 20049 |
(*group_count)--; |
| 20050 |
|
| 20051 |
if (sched_verbose > 6) |
| 20052 |
fprintf (dump, "done force: group count = %d, can_issue_more = %d\n", |
| 20053 |
*group_count, can_issue_more); |
| 20054 |
return can_issue_more; |
| 20055 |
} |
| 20056 |
|
| 20057 |
return can_issue_more; |
| 20058 |
} |
| 20059 |
|
| 20060 |
/* This function tries to synch the dispatch groups that the compiler "sees" |
| 20061 |
with the dispatch groups that the processor dispatcher is expected to |
| 20062 |
form in practice. It tries to achieve this synchronization by forcing the |
| 20063 |
estimated processor grouping on the compiler (as opposed to the function |
| 20064 |
'pad_goups' which tries to force the scheduler's grouping on the processor). |
| 20065 |
|
| 20066 |
The function scans the insn sequence between PREV_HEAD_INSN and TAIL and |
| 20067 |
examines the (estimated) dispatch groups that will be formed by the processor |
| 20068 |
dispatcher. It marks these group boundaries to reflect the estimated |
| 20069 |
processor grouping, overriding the grouping that the scheduler had marked. |
| 20070 |
Depending on the value of the flag '-minsert-sched-nops' this function can |
| 20071 |
force certain insns into separate groups or force a certain distance between |
| 20072 |
them by inserting nops, for example, if there exists a "costly dependence" |
| 20073 |
between the insns. |
| 20074 |
|
| 20075 |
The function estimates the group boundaries that the processor will form as |
| 20076 |
follows: It keeps track of how many vacant issue slots are available after |
| 20077 |
each insn. A subsequent insn will start a new group if one of the following |
| 20078 |
4 cases applies: |
| 20079 |
- no more vacant issue slots remain in the current dispatch group. |
| 20080 |
- only the last issue slot, which is the branch slot, is vacant, but the next |
| 20081 |
insn is not a branch. |
| 20082 |
- only the last 2 or less issue slots, including the branch slot, are vacant, |
| 20083 |
which means that a cracked insn (which occupies two issue slots) can't be |
| 20084 |
issued in this group. |
| 20085 |
- less than 'issue_rate' slots are vacant, and the next insn always needs to |
| 20086 |
start a new group. */ |
| 20087 |
|
| 20088 |
static int |
| 20089 |
redefine_groups (FILE *dump, int sched_verbose, rtx_insn *prev_head_insn, |
| 20090 |
rtx_insn *tail) |
| 20091 |
{ |
| 20092 |
rtx_insn *insn, *next_insn; |
| 20093 |
int issue_rate; |
| 20094 |
int can_issue_more; |
| 20095 |
int slot, i; |
| 20096 |
bool group_end; |
| 20097 |
int group_count = 0; |
| 20098 |
rtx *group_insns; |
| 20099 |
|
| 20100 |
/* Initialize. */ |
| 20101 |
issue_rate = rs6000_issue_rate (); |
| 20102 |
group_insns = XALLOCAVEC (rtx, issue_rate); |
| 20103 |
for (i = 0; i < issue_rate; i++) |
| 20104 |
{ |
| 20105 |
group_insns[i] = 0; |
| 20106 |
} |
| 20107 |
can_issue_more = issue_rate; |
| 20108 |
slot = 0; |
| 20109 |
insn = get_next_active_insn (prev_head_insn, tail); |
| 20110 |
group_end = false; |
| 20111 |
|
| 20112 |
while (insn != NULL_RTX) |
| 20113 |
{ |
| 20114 |
slot = (issue_rate - can_issue_more); |
| 20115 |
group_insns[slot] = insn; |
| 20116 |
can_issue_more = |
| 20117 |
rs6000_variable_issue (dump, sched_verbose, insn, can_issue_more); |
| 20118 |
if (insn_terminates_group_p (insn, current_group)) |
| 20119 |
can_issue_more = 0; |
| 20120 |
|
| 20121 |
next_insn = get_next_active_insn (insn, tail); |
| 20122 |
if (next_insn == NULL_RTX) |
| 20123 |
return group_count + 1; |
| 20124 |
|
| 20125 |
/* Is next_insn going to start a new group? */ |
| 20126 |
group_end |
| 20127 |
= (can_issue_more == 0 |
| 20128 |
|| (can_issue_more == 1 && !is_branch_slot_insn (next_insn)) |
| 20129 |
|| (can_issue_more <= 2 && is_cracked_insn (next_insn)) |
| 20130 |
|| (can_issue_more < issue_rate && |
| 20131 |
insn_terminates_group_p (next_insn, previous_group))); |
| 20132 |
|
| 20133 |
can_issue_more = force_new_group (sched_verbose, dump, group_insns, |
| 20134 |
next_insn, &group_end, can_issue_more, |
| 20135 |
&group_count); |
| 20136 |
|
| 20137 |
if (group_end) |
| 20138 |
{ |
| 20139 |
group_count++; |
| 20140 |
can_issue_more = 0; |
| 20141 |
for (i = 0; i < issue_rate; i++) |
| 20142 |
{ |
| 20143 |
group_insns[i] = 0; |
| 20144 |
} |
| 20145 |
} |
| 20146 |
|
| 20147 |
if (GET_MODE (next_insn) == TImode && can_issue_more) |
| 20148 |
PUT_MODE (next_insn, VOIDmode); |
| 20149 |
else if (!can_issue_more && GET_MODE (next_insn) != TImode) |
| 20150 |
PUT_MODE (next_insn, TImode); |
| 20151 |
|
| 20152 |
insn = next_insn; |
| 20153 |
if (can_issue_more == 0) |
| 20154 |
can_issue_more = issue_rate; |
| 20155 |
} /* while */ |
| 20156 |
|
| 20157 |
return group_count; |
| 20158 |
} |
| 20159 |
|
| 20160 |
/* Scan the insn sequence between PREV_HEAD_INSN and TAIL and examine the |
| 20161 |
dispatch group boundaries that the scheduler had marked. Pad with nops |
| 20162 |
any dispatch groups which have vacant issue slots, in order to force the |
| 20163 |
scheduler's grouping on the processor dispatcher. The function |
| 20164 |
returns the number of dispatch groups found. */ |
| 20165 |
|
| 20166 |
static int |
| 20167 |
pad_groups (FILE *dump, int sched_verbose, rtx_insn *prev_head_insn, |
| 20168 |
rtx_insn *tail) |
| 20169 |
{ |
| 20170 |
rtx_insn *insn, *next_insn; |
| 20171 |
rtx nop; |
| 20172 |
int issue_rate; |
| 20173 |
int can_issue_more; |
| 20174 |
int group_end; |
| 20175 |
int group_count = 0; |
| 20176 |
|
| 20177 |
/* Initialize issue_rate. */ |
| 20178 |
issue_rate = rs6000_issue_rate (); |
| 20179 |
can_issue_more = issue_rate; |
| 20180 |
|
| 20181 |
insn = get_next_active_insn (prev_head_insn, tail); |
| 20182 |
next_insn = get_next_active_insn (insn, tail); |
| 20183 |
|
| 20184 |
while (insn != NULL_RTX) |
| 20185 |
{ |
| 20186 |
can_issue_more = |
| 20187 |
rs6000_variable_issue (dump, sched_verbose, insn, can_issue_more); |
| 20188 |
|
| 20189 |
group_end = (next_insn == NULL_RTX || GET_MODE (next_insn) == TImode); |
| 20190 |
|
| 20191 |
if (next_insn == NULL_RTX) |
| 20192 |
break; |
| 20193 |
|
| 20194 |
if (group_end) |
| 20195 |
{ |
| 20196 |
/* If the scheduler had marked group termination at this location |
| 20197 |
(between insn and next_insn), and neither insn nor next_insn will |
| 20198 |
force group termination, pad the group with nops to force group |
| 20199 |
termination. */ |
| 20200 |
if (can_issue_more |
| 20201 |
&& (rs6000_sched_insert_nops == sched_finish_pad_groups) |
| 20202 |
&& !insn_terminates_group_p (insn, current_group) |
| 20203 |
&& !insn_terminates_group_p (next_insn, previous_group)) |
| 20204 |
{ |
| 20205 |
if (!is_branch_slot_insn (next_insn)) |
| 20206 |
can_issue_more--; |
| 20207 |
|
| 20208 |
while (can_issue_more) |
| 20209 |
{ |
| 20210 |
nop = gen_nop (); |
| 20211 |
emit_insn_before (nop, next_insn); |
| 20212 |
can_issue_more--; |
| 20213 |
} |
| 20214 |
} |
| 20215 |
|
| 20216 |
can_issue_more = issue_rate; |
| 20217 |
group_count++; |
| 20218 |
} |
| 20219 |
|
| 20220 |
insn = next_insn; |
| 20221 |
next_insn = get_next_active_insn (insn, tail); |
| 20222 |
} |
| 20223 |
|
| 20224 |
return group_count; |
| 20225 |
} |
| 20226 |
|
| 20227 |
/* We're beginning a new block. Initialize data structures as necessary. */ |
| 20228 |
|
| 20229 |
static void |
| 20230 |
rs6000_sched_init (FILE *dump ATTRIBUTE_UNUSED, |
| 20231 |
int sched_verbose ATTRIBUTE_UNUSED, |
| 20232 |
int max_ready ATTRIBUTE_UNUSED) |
| 20233 |
{ |
| 20234 |
last_scheduled_insn = NULL; |
| 20235 |
load_store_pendulum = 0; |
| 20236 |
divide_cnt = 0; |
| 20237 |
vec_pairing = 0; |
| 20238 |
} |
| 20239 |
|
| 20240 |
/* The following function is called at the end of scheduling BB. |
| 20241 |
After reload, it inserts nops at insn group bundling. */ |
| 20242 |
|
| 20243 |
static void |
| 20244 |
rs6000_sched_finish (FILE *dump, int sched_verbose) |
| 20245 |
{ |
| 20246 |
int n_groups; |
| 20247 |
|
| 20248 |
if (sched_verbose) |
| 20249 |
fprintf (dump, "=== Finishing schedule.\n"); |
| 20250 |
|
| 20251 |
if (reload_completed && rs6000_sched_groups) |
| 20252 |
{ |
| 20253 |
/* Do not run sched_finish hook when selective scheduling enabled. */ |
| 20254 |
if (sel_sched_p ()) |
| 20255 |
return; |
| 20256 |
|
| 20257 |
if (rs6000_sched_insert_nops == sched_finish_none) |
| 20258 |
return; |
| 20259 |
|
| 20260 |
if (rs6000_sched_insert_nops == sched_finish_pad_groups) |
| 20261 |
n_groups = pad_groups (dump, sched_verbose, |
| 20262 |
current_sched_info->prev_head, |
| 20263 |
current_sched_info->next_tail); |
| 20264 |
else |
| 20265 |
n_groups = redefine_groups (dump, sched_verbose, |
| 20266 |
current_sched_info->prev_head, |
| 20267 |
current_sched_info->next_tail); |
| 20268 |
|
| 20269 |
if (sched_verbose >= 6) |
| 20270 |
{ |
| 20271 |
fprintf (dump, "ngroups = %d\n", n_groups); |
| 20272 |
print_rtl (dump, current_sched_info->prev_head); |
| 20273 |
fprintf (dump, "Done finish_sched\n"); |
| 20274 |
} |
| 20275 |
} |
| 20276 |
} |
| 20277 |
|
| 20278 |
struct rs6000_sched_context |
| 20279 |
{ |
| 20280 |
short cached_can_issue_more; |
| 20281 |
rtx_insn *last_scheduled_insn; |
| 20282 |
int load_store_pendulum; |
| 20283 |
int divide_cnt; |
| 20284 |
int vec_pairing; |
| 20285 |
}; |
| 20286 |
|
| 20287 |
typedef struct rs6000_sched_context rs6000_sched_context_def; |
| 20288 |
typedef rs6000_sched_context_def *rs6000_sched_context_t; |
| 20289 |
|
| 20290 |
/* Allocate store for new scheduling context. */ |
| 20291 |
static void * |
| 20292 |
rs6000_alloc_sched_context (void) |
| 20293 |
{ |
| 20294 |
return xmalloc (sizeof (rs6000_sched_context_def)); |
| 20295 |
} |
| 20296 |
|
| 20297 |
/* If CLEAN_P is true then initializes _SC with clean data, |
| 20298 |
and from the global context otherwise. */ |
| 20299 |
static void |
| 20300 |
rs6000_init_sched_context (void *_sc, bool clean_p) |
| 20301 |
{ |
| 20302 |
rs6000_sched_context_t sc = (rs6000_sched_context_t) _sc; |
| 20303 |
|
| 20304 |
if (clean_p) |
| 20305 |
{ |
| 20306 |
sc->cached_can_issue_more = 0; |
| 20307 |
sc->last_scheduled_insn = NULL; |
| 20308 |
sc->load_store_pendulum = 0; |
| 20309 |
sc->divide_cnt = 0; |
| 20310 |
sc->vec_pairing = 0; |
| 20311 |
} |
| 20312 |
else |
| 20313 |
{ |
| 20314 |
sc->cached_can_issue_more = cached_can_issue_more; |
| 20315 |
sc->last_scheduled_insn = last_scheduled_insn; |
| 20316 |
sc->load_store_pendulum = load_store_pendulum; |
| 20317 |
sc->divide_cnt = divide_cnt; |
| 20318 |
sc->vec_pairing = vec_pairing; |
| 20319 |
} |
| 20320 |
} |
| 20321 |
|
| 20322 |
/* Sets the global scheduling context to the one pointed to by _SC. */ |
| 20323 |
static void |
| 20324 |
rs6000_set_sched_context (void *_sc) |
| 20325 |
{ |
| 20326 |
rs6000_sched_context_t sc = (rs6000_sched_context_t) _sc; |
| 20327 |
|
| 20328 |
gcc_assert (sc != NULL); |
| 20329 |
|
| 20330 |
cached_can_issue_more = sc->cached_can_issue_more; |
| 20331 |
last_scheduled_insn = sc->last_scheduled_insn; |
| 20332 |
load_store_pendulum = sc->load_store_pendulum; |
| 20333 |
divide_cnt = sc->divide_cnt; |
| 20334 |
vec_pairing = sc->vec_pairing; |
| 20335 |
} |
| 20336 |
|
| 20337 |
/* Free _SC. */ |
| 20338 |
static void |
| 20339 |
rs6000_free_sched_context (void *_sc) |
| 20340 |
{ |
| 20341 |
gcc_assert (_sc != NULL); |
| 20342 |
|
| 20343 |
free (_sc); |
| 20344 |
} |
| 20345 |
|
| 20346 |
static bool |
| 20347 |
rs6000_sched_can_speculate_insn (rtx_insn *insn) |
| 20348 |
{ |
| 20349 |
switch (get_attr_type (insn)) |
| 20350 |
{ |
| 20351 |
case TYPE_DIV: |
| 20352 |
case TYPE_SDIV: |
| 20353 |
case TYPE_DDIV: |
| 20354 |
case TYPE_VECDIV: |
| 20355 |
case TYPE_SSQRT: |
| 20356 |
case TYPE_DSQRT: |
| 20357 |
return false; |
| 20358 |
|
| 20359 |
default: |
| 20360 |
return true; |
| 20361 |
} |
| 20362 |
} |
| 20363 |
|
| 20364 |
/* Length in units of the trampoline for entering a nested function. */ |
| 20365 |
|
| 20366 |
int |
| 20367 |
rs6000_trampoline_size (void) |
| 20368 |
{ |
| 20369 |
int ret = 0; |
| 20370 |
|
| 20371 |
switch (DEFAULT_ABI) |
| 20372 |
{ |
| 20373 |
default: |
| 20374 |
gcc_unreachable (); |
| 20375 |
|
| 20376 |
case ABI_AIX: |
| 20377 |
ret = (TARGET_32BIT) ? 12 : 24; |
| 20378 |
break; |
| 20379 |
|
| 20380 |
case ABI_ELFv2: |
| 20381 |
gcc_assert (!TARGET_32BIT); |
| 20382 |
ret = 32; |
| 20383 |
break; |
| 20384 |
|
| 20385 |
case ABI_DARWIN: |
| 20386 |
case ABI_V4: |
| 20387 |
ret = (TARGET_32BIT) ? 40 : 48; |
| 20388 |
break; |
| 20389 |
} |
| 20390 |
|
| 20391 |
return ret; |
| 20392 |
} |
| 20393 |
|
| 20394 |
/* Emit RTL insns to initialize the variable parts of a trampoline. |
| 20395 |
FNADDR is an RTX for the address of the function's pure code. |
| 20396 |
CXT is an RTX for the static chain value for the function. */ |
| 20397 |
|
| 20398 |
static void |
| 20399 |
rs6000_trampoline_init (rtx m_tramp, tree fndecl, rtx cxt) |
| 20400 |
{ |
| 20401 |
int regsize = (TARGET_32BIT) ? 4 : 8; |
| 20402 |
rtx fnaddr = XEXP (DECL_RTL (fndecl), 0); |
| 20403 |
rtx ctx_reg = force_reg (Pmode, cxt); |
| 20404 |
rtx addr = force_reg (Pmode, XEXP (m_tramp, 0)); |
| 20405 |
|
| 20406 |
switch (DEFAULT_ABI) |
| 20407 |
{ |
| 20408 |
default: |
| 20409 |
gcc_unreachable (); |
| 20410 |
|
| 20411 |
/* Under AIX, just build the 3 word function descriptor */ |
| 20412 |
case ABI_AIX: |
| 20413 |
{ |
| 20414 |
rtx fnmem, fn_reg, toc_reg; |
| 20415 |
|
| 20416 |
if (!TARGET_POINTERS_TO_NESTED_FUNCTIONS) |
| 20417 |
error ("you cannot take the address of a nested function if you use " |
| 20418 |
"the %qs option", "-mno-pointers-to-nested-functions"); |
| 20419 |
|
| 20420 |
fnmem = gen_const_mem (Pmode, force_reg (Pmode, fnaddr)); |
| 20421 |
fn_reg = gen_reg_rtx (Pmode); |
| 20422 |
toc_reg = gen_reg_rtx (Pmode); |
| 20423 |
|
| 20424 |
/* Macro to shorten the code expansions below. */ |
| 20425 |
# define MEM_PLUS(MEM, OFFSET) adjust_address (MEM, Pmode, OFFSET) |
| 20426 |
|
| 20427 |
m_tramp = replace_equiv_address (m_tramp, addr); |
| 20428 |
|
| 20429 |
emit_move_insn (fn_reg, MEM_PLUS (fnmem, 0)); |
| 20430 |
emit_move_insn (toc_reg, MEM_PLUS (fnmem, regsize)); |
| 20431 |
emit_move_insn (MEM_PLUS (m_tramp, 0), fn_reg); |
| 20432 |
emit_move_insn (MEM_PLUS (m_tramp, regsize), toc_reg); |
| 20433 |
emit_move_insn (MEM_PLUS (m_tramp, 2*regsize), ctx_reg); |
| 20434 |
|
| 20435 |
# undef MEM_PLUS |
| 20436 |
} |
| 20437 |
break; |
| 20438 |
|
| 20439 |
/* Under V.4/eabi/darwin, __trampoline_setup does the real work. */ |
| 20440 |
case ABI_ELFv2: |
| 20441 |
case ABI_DARWIN: |
| 20442 |
case ABI_V4: |
| 20443 |
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__trampoline_setup"), |
| 20444 |
LCT_NORMAL, VOIDmode, |
| 20445 |
addr, Pmode, |
| 20446 |
GEN_INT (rs6000_trampoline_size ()), SImode, |
| 20447 |
fnaddr, Pmode, |
| 20448 |
ctx_reg, Pmode); |
| 20449 |
break; |
| 20450 |
} |
| 20451 |
} |
| 20452 |
|
| 20453 |
|
| 20454 |
/* Returns TRUE iff the target attribute indicated by ATTR_ID takes a plain |
| 20455 |
identifier as an argument, so the front end shouldn't look it up. */ |
| 20456 |
|
| 20457 |
static bool |
| 20458 |
rs6000_attribute_takes_identifier_p (const_tree attr_id) |
| 20459 |
{ |
| 20460 |
return is_attribute_p ("altivec", attr_id); |
| 20461 |
} |
| 20462 |
|
| 20463 |
/* Handle the "altivec" attribute. The attribute may have |
| 20464 |
arguments as follows: |
| 20465 |
|
| 20466 |
__attribute__((altivec(vector__))) |
| 20467 |
__attribute__((altivec(pixel__))) (always followed by 'unsigned short') |
| 20468 |
__attribute__((altivec(bool__))) (always followed by 'unsigned') |
| 20469 |
|
| 20470 |
and may appear more than once (e.g., 'vector bool char') in a |
| 20471 |
given declaration. */ |
| 20472 |
|
| 20473 |
static tree |
| 20474 |
rs6000_handle_altivec_attribute (tree *node, |
| 20475 |
tree name ATTRIBUTE_UNUSED, |
| 20476 |
tree args, |
| 20477 |
int flags ATTRIBUTE_UNUSED, |
| 20478 |
bool *no_add_attrs) |
| 20479 |
{ |
| 20480 |
tree type = *node, result = NULL_TREE; |
| 20481 |
machine_mode mode; |
| 20482 |
int unsigned_p; |
| 20483 |
char altivec_type |
| 20484 |
= ((args && TREE_CODE (args) == TREE_LIST && TREE_VALUE (args) |
| 20485 |
&& TREE_CODE (TREE_VALUE (args)) == IDENTIFIER_NODE) |
| 20486 |
? *IDENTIFIER_POINTER (TREE_VALUE (args)) |
| 20487 |
: '?'); |
| 20488 |
|
| 20489 |
while (POINTER_TYPE_P (type) |
| 20490 |
|| TREE_CODE (type) == FUNCTION_TYPE |
| 20491 |
|| TREE_CODE (type) == METHOD_TYPE |
| 20492 |
|| TREE_CODE (type) == ARRAY_TYPE) |
| 20493 |
type = TREE_TYPE (type); |
| 20494 |
|
| 20495 |
mode = TYPE_MODE (type); |
| 20496 |
|
| 20497 |
/* Check for invalid AltiVec type qualifiers. */ |
| 20498 |
if (type == long_double_type_node) |
| 20499 |
error ("use of %<long double%> in AltiVec types is invalid"); |
| 20500 |
else if (type == boolean_type_node) |
| 20501 |
error ("use of boolean types in AltiVec types is invalid"); |
| 20502 |
else if (TREE_CODE (type) == COMPLEX_TYPE) |
| 20503 |
error ("use of %<complex%> in AltiVec types is invalid"); |
| 20504 |
else if (DECIMAL_FLOAT_MODE_P (mode)) |
| 20505 |
error ("use of decimal floating-point types in AltiVec types is invalid"); |
| 20506 |
else if (!TARGET_VSX) |
| 20507 |
{ |
| 20508 |
if (type == long_unsigned_type_node || type == long_integer_type_node) |
| 20509 |
{ |
| 20510 |
if (TARGET_64BIT) |
| 20511 |
error ("use of %<long%> in AltiVec types is invalid for " |
| 20512 |
"64-bit code without %qs", "-mvsx"); |
| 20513 |
else if (rs6000_warn_altivec_long) |
| 20514 |
warning (0, "use of %<long%> in AltiVec types is deprecated; " |
| 20515 |
"use %<int%>"); |
| 20516 |
} |
| 20517 |
else if (type == long_long_unsigned_type_node |
| 20518 |
|| type == long_long_integer_type_node) |
| 20519 |
error ("use of %<long long%> in AltiVec types is invalid without %qs", |
| 20520 |
"-mvsx"); |
| 20521 |
else if (type == double_type_node) |
| 20522 |
error ("use of %<double%> in AltiVec types is invalid without %qs", |
| 20523 |
"-mvsx"); |
| 20524 |
} |
| 20525 |
|
| 20526 |
switch (altivec_type) |
| 20527 |
{ |
| 20528 |
case 'v': |
| 20529 |
unsigned_p = TYPE_UNSIGNED (type); |
| 20530 |
switch (mode) |
| 20531 |
{ |
| 20532 |
case E_TImode: |
| 20533 |
result = (unsigned_p ? unsigned_V1TI_type_node : V1TI_type_node); |
| 20534 |
break; |
| 20535 |
case E_DImode: |
| 20536 |
result = (unsigned_p ? unsigned_V2DI_type_node : V2DI_type_node); |
| 20537 |
break; |
| 20538 |
case E_SImode: |
| 20539 |
result = (unsigned_p ? unsigned_V4SI_type_node : V4SI_type_node); |
| 20540 |
break; |
| 20541 |
case E_HImode: |
| 20542 |
result = (unsigned_p ? unsigned_V8HI_type_node : V8HI_type_node); |
| 20543 |
break; |
| 20544 |
case E_QImode: |
| 20545 |
result = (unsigned_p ? unsigned_V16QI_type_node : V16QI_type_node); |
| 20546 |
break; |
| 20547 |
case E_SFmode: result = V4SF_type_node; break; |
| 20548 |
case E_DFmode: result = V2DF_type_node; break; |
| 20549 |
/* If the user says 'vector int bool', we may be handed the 'bool' |
| 20550 |
attribute _before_ the 'vector' attribute, and so select the |
| 20551 |
proper type in the 'b' case below. */ |
| 20552 |
case E_V4SImode: case E_V8HImode: case E_V16QImode: case E_V4SFmode: |
| 20553 |
case E_V2DImode: case E_V2DFmode: |
| 20554 |
result = type; |
| 20555 |
default: break; |
| 20556 |
} |
| 20557 |
break; |
| 20558 |
case 'b': |
| 20559 |
switch (mode) |
| 20560 |
{ |
| 20561 |
case E_TImode: case E_V1TImode: result = bool_V1TI_type_node; break; |
| 20562 |
case E_DImode: case E_V2DImode: result = bool_V2DI_type_node; break; |
| 20563 |
case E_SImode: case E_V4SImode: result = bool_V4SI_type_node; break; |
| 20564 |
case E_HImode: case E_V8HImode: result = bool_V8HI_type_node; break; |
| 20565 |
case E_QImode: case E_V16QImode: result = bool_V16QI_type_node; |
| 20566 |
default: break; |
| 20567 |
} |
| 20568 |
break; |
| 20569 |
case 'p': |
| 20570 |
switch (mode) |
| 20571 |
{ |
| 20572 |
case E_V8HImode: result = pixel_V8HI_type_node; |
| 20573 |
default: break; |
| 20574 |
} |
| 20575 |
default: break; |
| 20576 |
} |
| 20577 |
|
| 20578 |
/* Propagate qualifiers attached to the element type |
| 20579 |
onto the vector type. */ |
| 20580 |
if (result && result != type && TYPE_QUALS (type)) |
| 20581 |
result = build_qualified_type (result, TYPE_QUALS (type)); |
| 20582 |
|
| 20583 |
*no_add_attrs = true; /* No need to hang on to the attribute. */ |
| 20584 |
|
| 20585 |
if (result) |
| 20586 |
*node = lang_hooks.types.reconstruct_complex_type (*node, result); |
| 20587 |
|
| 20588 |
return NULL_TREE; |
| 20589 |
} |
| 20590 |
|
| 20591 |
/* AltiVec defines five built-in scalar types that serve as vector |
| 20592 |
elements; we must teach the compiler how to mangle them. The 128-bit |
| 20593 |
floating point mangling is target-specific as well. MMA defines |
| 20594 |
two built-in types to be used as opaque vector types. */ |
| 20595 |
|
| 20596 |
static const char * |
| 20597 |
rs6000_mangle_type (const_tree type) |
| 20598 |
{ |
| 20599 |
type = TYPE_MAIN_VARIANT (type); |
| 20600 |
|
| 20601 |
if (TREE_CODE (type) != VOID_TYPE && TREE_CODE (type) != BOOLEAN_TYPE |
| 20602 |
&& TREE_CODE (type) != INTEGER_TYPE && TREE_CODE (type) != REAL_TYPE |
| 20603 |
&& TREE_CODE (type) != OPAQUE_TYPE) |
| 20604 |
return NULL; |
| 20605 |
|
| 20606 |
if (type == bool_char_type_node) return "U6__boolc"; |
| 20607 |
if (type == bool_short_type_node) return "U6__bools"; |
| 20608 |
if (type == pixel_type_node) return "u7__pixel"; |
| 20609 |
if (type == bool_int_type_node) return "U6__booli"; |
| 20610 |
if (type == bool_long_long_type_node) return "U6__boolx"; |
| 20611 |
|
| 20612 |
if (type == float128_type_node || type == float64x_type_node) |
| 20613 |
return NULL; |
| 20614 |
|
| 20615 |
if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IBM_P (TYPE_MODE (type))) |
| 20616 |
return "g"; |
| 20617 |
if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IEEE_P (TYPE_MODE (type))) |
| 20618 |
return "u9__ieee128"; |
| 20619 |
|
| 20620 |
if (type == vector_pair_type_node) |
| 20621 |
return "u13__vector_pair"; |
| 20622 |
if (type == vector_quad_type_node) |
| 20623 |
return "u13__vector_quad"; |
| 20624 |
|
| 20625 |
/* For all other types, use the default mangling. */ |
| 20626 |
return NULL; |
| 20627 |
} |
| 20628 |
|
| 20629 |
/* Handle a "longcall" or "shortcall" attribute; arguments as in |
| 20630 |
struct attribute_spec.handler. */ |
| 20631 |
|
| 20632 |
static tree |
| 20633 |
rs6000_handle_longcall_attribute (tree *node, tree name, |
| 20634 |
tree args ATTRIBUTE_UNUSED, |
| 20635 |
int flags ATTRIBUTE_UNUSED, |
| 20636 |
bool *no_add_attrs) |
| 20637 |
{ |
| 20638 |
if (TREE_CODE (*node) != FUNCTION_TYPE |
| 20639 |
&& TREE_CODE (*node) != FIELD_DECL |
| 20640 |
&& TREE_CODE (*node) != TYPE_DECL) |
| 20641 |
{ |
| 20642 |
warning (OPT_Wattributes, "%qE attribute only applies to functions", |
| 20643 |
name); |
| 20644 |
*no_add_attrs = true; |
| 20645 |
} |
| 20646 |
|
| 20647 |
return NULL_TREE; |
| 20648 |
} |
| 20649 |
|
| 20650 |
/* Set longcall attributes on all functions declared when |
| 20651 |
rs6000_default_long_calls is true. */ |
| 20652 |
static void |
| 20653 |
rs6000_set_default_type_attributes (tree type) |
| 20654 |
{ |
| 20655 |
if (rs6000_default_long_calls |
| 20656 |
&& FUNC_OR_METHOD_TYPE_P (type)) |
| 20657 |
TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("longcall"), |
| 20658 |
NULL_TREE, |
| 20659 |
TYPE_ATTRIBUTES (type)); |
| 20660 |
|
| 20661 |
#if TARGET_MACHO |
| 20662 |
darwin_set_default_type_attributes (type); |
| 20663 |
#endif |
| 20664 |
} |
| 20665 |
|
| 20666 |
/* Return a reference suitable for calling a function with the |
| 20667 |
longcall attribute. */ |
| 20668 |
|
| 20669 |
static rtx |
| 20670 |
rs6000_longcall_ref (rtx call_ref, rtx arg) |
| 20671 |
{ |
| 20672 |
/* System V adds '.' to the internal name, so skip them. */ |
| 20673 |
const char *call_name = XSTR (call_ref, 0); |
| 20674 |
if (*call_name == '.') |
| 20675 |
{ |
| 20676 |
while (*call_name == '.') |
| 20677 |
call_name++; |
| 20678 |
|
| 20679 |
tree node = get_identifier (call_name); |
| 20680 |
call_ref = gen_rtx_SYMBOL_REF (VOIDmode, IDENTIFIER_POINTER (node)); |
| 20681 |
} |
| 20682 |
|
| 20683 |
if (TARGET_PLTSEQ) |
| 20684 |
{ |
| 20685 |
rtx base = const0_rtx; |
| 20686 |
int regno = 12; |
| 20687 |
if (rs6000_pcrel_p ()) |
| 20688 |
{ |
| 20689 |
rtx reg = gen_rtx_REG (Pmode, regno); |
| 20690 |
rtx u = gen_rtx_UNSPEC_VOLATILE (Pmode, |
| 20691 |
gen_rtvec (3, base, call_ref, arg), |
| 20692 |
UNSPECV_PLT_PCREL); |
| 20693 |
emit_insn (gen_rtx_SET (reg, u)); |
| 20694 |
return reg; |
| 20695 |
} |
| 20696 |
|
| 20697 |
if (DEFAULT_ABI == ABI_ELFv2) |
| 20698 |
base = gen_rtx_REG (Pmode, TOC_REGISTER); |
| 20699 |
else |
| 20700 |
{ |
| 20701 |
if (flag_pic) |
| 20702 |
base = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM); |
| 20703 |
regno = 11; |
| 20704 |
} |
| 20705 |
/* Reg must match that used by linker PLT stubs. For ELFv2, r12 |
| 20706 |
may be used by a function global entry point. For SysV4, r11 |
| 20707 |
is used by __glink_PLTresolve lazy resolver entry. */ |
| 20708 |
rtx reg = gen_rtx_REG (Pmode, regno); |
| 20709 |
rtx hi = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, base, call_ref, arg), |
| 20710 |
UNSPEC_PLT16_HA); |
| 20711 |
rtx lo = gen_rtx_UNSPEC_VOLATILE (Pmode, |
| 20712 |
gen_rtvec (3, reg, call_ref, arg), |
| 20713 |
UNSPECV_PLT16_LO); |
| 20714 |
emit_insn (gen_rtx_SET (reg, hi)); |
| 20715 |
emit_insn (gen_rtx_SET (reg, lo)); |
| 20716 |
return reg; |
| 20717 |
} |
| 20718 |
|
| 20719 |
return force_reg (Pmode, call_ref); |
| 20720 |
} |
| 20721 |
|
| 20722 |
#ifndef TARGET_USE_MS_BITFIELD_LAYOUT |
| 20723 |
#define TARGET_USE_MS_BITFIELD_LAYOUT 0 |
| 20724 |
#endif |
| 20725 |
|
| 20726 |
/* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in |
| 20727 |
struct attribute_spec.handler. */ |
| 20728 |
static tree |
| 20729 |
rs6000_handle_struct_attribute (tree *node, tree name, |
| 20730 |
tree args ATTRIBUTE_UNUSED, |
| 20731 |
int flags ATTRIBUTE_UNUSED, bool *no_add_attrs) |
| 20732 |
{ |
| 20733 |
tree *type = NULL; |
| 20734 |
if (DECL_P (*node)) |
| 20735 |
{ |
| 20736 |
if (TREE_CODE (*node) == TYPE_DECL) |
| 20737 |
type = &TREE_TYPE (*node); |
| 20738 |
} |
| 20739 |
else |
| 20740 |
type = node; |
| 20741 |
|
| 20742 |
if (!(type && (TREE_CODE (*type) == RECORD_TYPE |
| 20743 |
|| TREE_CODE (*type) == UNION_TYPE))) |
| 20744 |
{ |
| 20745 |
warning (OPT_Wattributes, "%qE attribute ignored", name); |
| 20746 |
*no_add_attrs = true; |
| 20747 |
} |
| 20748 |
|
| 20749 |
else if ((is_attribute_p ("ms_struct", name) |
| 20750 |
&& lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type))) |
| 20751 |
|| ((is_attribute_p ("gcc_struct", name) |
| 20752 |
&& lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type))))) |
| 20753 |
{ |
| 20754 |
warning (OPT_Wattributes, "%qE incompatible attribute ignored", |
| 20755 |
name); |
| 20756 |
*no_add_attrs = true; |
| 20757 |
} |
| 20758 |
|
| 20759 |
return NULL_TREE; |
| 20760 |
} |
| 20761 |
|
| 20762 |
static bool |
| 20763 |
rs6000_ms_bitfield_layout_p (const_tree record_type) |
| 20764 |
{ |
| 20765 |
return (TARGET_USE_MS_BITFIELD_LAYOUT && |
| 20766 |
!lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (record_type))) |
| 20767 |
|| lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (record_type)); |
| 20768 |
} |
| 20769 |
|
| 20770 |
#ifdef USING_ELFOS_H |
| 20771 |
|
| 20772 |
/* A get_unnamed_section callback, used for switching to toc_section. */ |
| 20773 |
|
| 20774 |
static void |
| 20775 |
rs6000_elf_output_toc_section_asm_op (const char *data ATTRIBUTE_UNUSED) |
| 20776 |
{ |
| 20777 |
if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) |
| 20778 |
&& TARGET_MINIMAL_TOC) |
| 20779 |
{ |
| 20780 |
if (!toc_initialized) |
| 20781 |
{ |
| 20782 |
fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP); |
| 20783 |
ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2); |
| 20784 |
(*targetm.asm_out.internal_label) (asm_out_file, "LCTOC", 0); |
| 20785 |
fprintf (asm_out_file, "\t.tc "); |
| 20786 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); |
| 20787 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); |
| 20788 |
fprintf (asm_out_file, "\n"); |
| 20789 |
|
| 20790 |
fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); |
| 20791 |
ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2); |
| 20792 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); |
| 20793 |
fprintf (asm_out_file, " = .+32768\n"); |
| 20794 |
toc_initialized = 1; |
| 20795 |
} |
| 20796 |
else |
| 20797 |
fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); |
| 20798 |
} |
| 20799 |
else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) |
| 20800 |
{ |
| 20801 |
fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP); |
| 20802 |
if (!toc_initialized) |
| 20803 |
{ |
| 20804 |
ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2); |
| 20805 |
toc_initialized = 1; |
| 20806 |
} |
| 20807 |
} |
| 20808 |
else |
| 20809 |
{ |
| 20810 |
fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); |
| 20811 |
if (!toc_initialized) |
| 20812 |
{ |
| 20813 |
ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2); |
| 20814 |
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); |
| 20815 |
fprintf (asm_out_file, " = .+32768\n"); |
| 20816 |
toc_initialized = 1; |
| 20817 |
} |
| 20818 |
} |
| 20819 |
} |
| 20820 |
|
| 20821 |
/* Implement TARGET_ASM_INIT_SECTIONS. */ |
| 20822 |
|
| 20823 |
static void |
| 20824 |
rs6000_elf_asm_init_sections (void) |
| 20825 |
{ |
| 20826 |
toc_section |
| 20827 |
= get_unnamed_section (0, rs6000_elf_output_toc_section_asm_op, NULL); |
| 20828 |
|
| 20829 |
sdata2_section |
| 20830 |
= get_unnamed_section (SECTION_WRITE, output_section_asm_op, |
| 20831 |
SDATA2_SECTION_ASM_OP); |
| 20832 |
} |
| 20833 |
|
| 20834 |
/* Implement TARGET_SELECT_RTX_SECTION. */ |
| 20835 |
|
| 20836 |
static section * |
| 20837 |
rs6000_elf_select_rtx_section (machine_mode mode, rtx x, |
| 20838 |
unsigned HOST_WIDE_INT align) |
| 20839 |
{ |
| 20840 |
if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode)) |
| 20841 |
return toc_section; |
| 20842 |
else |
| 20843 |
return default_elf_select_rtx_section (mode, x, align); |
| 20844 |
} |
| 20845 |
|
| 20846 |
/* For a SYMBOL_REF, set generic flags and then perform some |
| 20847 |
target-specific processing. |
| 20848 |
|
| 20849 |
When the AIX ABI is requested on a non-AIX system, replace the |
| 20850 |
function name with the real name (with a leading .) rather than the |
| 20851 |
function descriptor name. This saves a lot of overriding code to |
| 20852 |
read the prefixes. */ |
| 20853 |
|
| 20854 |
static void rs6000_elf_encode_section_info (tree, rtx, int) ATTRIBUTE_UNUSED; |
| 20855 |
static void |
| 20856 |
rs6000_elf_encode_section_info (tree decl, rtx rtl, int first) |
| 20857 |
{ |
| 20858 |
default_encode_section_info (decl, rtl, first); |
| 20859 |
|
| 20860 |
if (first |
| 20861 |
&& TREE_CODE (decl) == FUNCTION_DECL |
| 20862 |
&& !TARGET_AIX |
| 20863 |
&& DEFAULT_ABI == ABI_AIX) |
| 20864 |
{ |
| 20865 |
rtx sym_ref = XEXP (rtl, 0); |
| 20866 |
size_t len = strlen (XSTR (sym_ref, 0)); |
| 20867 |
char *str = XALLOCAVEC (char, len + 2); |
| 20868 |
str[0] = '.'; |
| 20869 |
memcpy (str + 1, XSTR (sym_ref, 0), len + 1); |
| 20870 |
XSTR (sym_ref, 0) = ggc_alloc_string (str, len + 1); |
| 20871 |
} |
| 20872 |
} |
| 20873 |
|
| 20874 |
static inline bool |
| 20875 |
compare_section_name (const char *section, const char *templ) |
| 20876 |
{ |
| 20877 |
int len; |
| 20878 |
|
| 20879 |
len = strlen (templ); |
| 20880 |
return (strncmp (section, templ, len) == 0 |
| 20881 |
&& (section[len] == 0 || section[len] == '.')); |
| 20882 |
} |
| 20883 |
|
| 20884 |
bool |
| 20885 |
rs6000_elf_in_small_data_p (const_tree decl) |
| 20886 |
{ |
| 20887 |
if (rs6000_sdata == SDATA_NONE) |
| 20888 |
return false; |
| 20889 |
|
| 20890 |
/* We want to merge strings, so we never consider them small data. */ |
| 20891 |
if (TREE_CODE (decl) == STRING_CST) |
| 20892 |
return false; |
| 20893 |
|
| 20894 |
/* Functions are never in the small data area. */ |
| 20895 |
if (TREE_CODE (decl) == FUNCTION_DECL) |
| 20896 |
return false; |
| 20897 |
|
| 20898 |
if (VAR_P (decl) && DECL_SECTION_NAME (decl)) |
| 20899 |
{ |
| 20900 |
const char *section = DECL_SECTION_NAME (decl); |
| 20901 |
if (compare_section_name (section, ".sdata") |
| 20902 |
|| compare_section_name (section, ".sdata2") |
| 20903 |
|| compare_section_name (section, ".gnu.linkonce.s") |
| 20904 |
|| compare_section_name (section, ".sbss") |
| 20905 |
|| compare_section_name (section, ".sbss2") |
| 20906 |
|| compare_section_name (section, ".gnu.linkonce.sb") |
| 20907 |
|| strcmp (section, ".PPC.EMB.sdata0") == 0 |
| 20908 |
|| strcmp (section, ".PPC.EMB.sbss0") == 0) |
| 20909 |
return true; |
| 20910 |
} |
| 20911 |
else |
| 20912 |
{ |
| 20913 |
/* If we are told not to put readonly data in sdata, then don't. */ |
| 20914 |
if (TREE_READONLY (decl) && rs6000_sdata != SDATA_EABI |
| 20915 |
&& !rs6000_readonly_in_sdata) |
| 20916 |
return false; |
| 20917 |
|
| 20918 |
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); |
| 20919 |
|
| 20920 |
if (size > 0 |
| 20921 |
&& size <= g_switch_value |
| 20922 |
/* If it's not public, and we're not going to reference it there, |
| 20923 |
there's no need to put it in the small data section. */ |
| 20924 |
&& (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl))) |
| 20925 |
return true; |
| 20926 |
} |
| 20927 |
|
| 20928 |
return false; |
| 20929 |
} |
| 20930 |
|
| 20931 |
#endif /* USING_ELFOS_H */ |
| 20932 |
|
| 20933 |
/* Implement TARGET_USE_BLOCKS_FOR_CONSTANT_P. */ |
| 20934 |
|
| 20935 |
static bool |
| 20936 |
rs6000_use_blocks_for_constant_p (machine_mode mode, const_rtx x) |
| 20937 |
{ |
| 20938 |
return !ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode); |
| 20939 |
} |
| 20940 |
|
| 20941 |
/* Do not place thread-local symbols refs in the object blocks. */ |
| 20942 |
|
| 20943 |
static bool |
| 20944 |
rs6000_use_blocks_for_decl_p (const_tree decl) |
| 20945 |
{ |
| 20946 |
return !DECL_THREAD_LOCAL_P (decl); |
| 20947 |
} |
| 20948 |
|
| 20949 |
/* Return a REG that occurs in ADDR with coefficient 1. |
| 20950 |
ADDR can be effectively incremented by incrementing REG. |
| 20951 |
|
| 20952 |
r0 is special and we must not select it as an address |
| 20953 |
register by this routine since our caller will try to |
| 20954 |
increment the returned register via an "la" instruction. */ |
| 20955 |
|
| 20956 |
rtx |
| 20957 |
find_addr_reg (rtx addr) |
| 20958 |
{ |
| 20959 |
while (GET_CODE (addr) == PLUS) |
| 20960 |
{ |
| 20961 |
if (REG_P (XEXP (addr, 0)) |
| 20962 |
&& REGNO (XEXP (addr, 0)) != 0) |
| 20963 |
addr = XEXP (addr, 0); |
| 20964 |
else if (REG_P (XEXP (addr, 1)) |
| 20965 |
&& REGNO (XEXP (addr, 1)) != 0) |
| 20966 |
addr = XEXP (addr, 1); |
| 20967 |
else if (CONSTANT_P (XEXP (addr, 0))) |
| 20968 |
addr = XEXP (addr, 1); |
| 20969 |
else if (CONSTANT_P (XEXP (addr, 1))) |
| 20970 |
addr = XEXP (addr, 0); |
| 20971 |
else |
| 20972 |
gcc_unreachable (); |
| 20973 |
} |
| 20974 |
gcc_assert (REG_P (addr) && REGNO (addr) != 0); |
| 20975 |
return addr; |
| 20976 |
} |
| 20977 |
|
| 20978 |
void |
| 20979 |
rs6000_fatal_bad_address (rtx op) |
| 20980 |
{ |
| 20981 |
fatal_insn ("bad address", op); |
| 20982 |
} |
| 20983 |
|
| 20984 |
#if TARGET_MACHO |
| 20985 |
|
| 20986 |
vec<branch_island, va_gc> *branch_islands; |
| 20987 |
|
| 20988 |
/* Remember to generate a branch island for far calls to the given |
| 20989 |
function. */ |
| 20990 |
|
| 20991 |
static void |
| 20992 |
add_compiler_branch_island (tree label_name, tree function_name, |
| 20993 |
int line_number) |
| 20994 |
{ |
| 20995 |
branch_island bi = {function_name, label_name, line_number}; |
| 20996 |
vec_safe_push (branch_islands, bi); |
| 20997 |
} |
| 20998 |
|
| 20999 |
/* NO_PREVIOUS_DEF checks in the link list whether the function name is |
| 21000 |
already there or not. */ |
| 21001 |
|
| 21002 |
static int |
| 21003 |
no_previous_def (tree function_name) |
| 21004 |
{ |
| 21005 |
branch_island *bi; |
| 21006 |
unsigned ix; |
| 21007 |
|
| 21008 |
FOR_EACH_VEC_SAFE_ELT (branch_islands, ix, bi) |
| 21009 |
if (function_name == bi->function_name) |
| 21010 |
return 0; |
| 21011 |
return 1; |
| 21012 |
} |
| 21013 |
|
| 21014 |
/* GET_PREV_LABEL gets the label name from the previous definition of |
| 21015 |
the function. */ |
| 21016 |
|
| 21017 |
static tree |
| 21018 |
get_prev_label (tree function_name) |
| 21019 |
{ |
| 21020 |
branch_island *bi; |
| 21021 |
unsigned ix; |
| 21022 |
|
| 21023 |
FOR_EACH_VEC_SAFE_ELT (branch_islands, ix, bi) |
| 21024 |
if (function_name == bi->function_name) |
| 21025 |
return bi->label_name; |
| 21026 |
return NULL_TREE; |
| 21027 |
} |
| 21028 |
|
| 21029 |
/* Generate external symbol indirection stubs (PIC and non-PIC). */ |
| 21030 |
|
| 21031 |
void |
| 21032 |
machopic_output_stub (FILE *file, const char *symb, const char *stub) |
| 21033 |
{ |
| 21034 |
unsigned int length; |
| 21035 |
char *symbol_name, *lazy_ptr_name; |
| 21036 |
char *local_label_0; |
| 21037 |
static unsigned label = 0; |
| 21038 |
|
| 21039 |
/* Lose our funky encoding stuff so it doesn't contaminate the stub. */ |
| 21040 |
symb = (*targetm.strip_name_encoding) (symb); |
| 21041 |
|
| 21042 |
length = strlen (symb); |
| 21043 |
symbol_name = XALLOCAVEC (char, length + 32); |
| 21044 |
GEN_SYMBOL_NAME_FOR_SYMBOL (symbol_name, symb, length); |
| 21045 |
|
| 21046 |
lazy_ptr_name = XALLOCAVEC (char, length + 32); |
| 21047 |
GEN_LAZY_PTR_NAME_FOR_SYMBOL (lazy_ptr_name, symb, length); |
| 21048 |
|
| 21049 |
if (MACHOPIC_PURE) |
| 21050 |
{ |
| 21051 |
switch_to_section (darwin_sections[machopic_picsymbol_stub1_section]); |
| 21052 |
fprintf (file, "\t.align 5\n"); |
| 21053 |
|
| 21054 |
fprintf (file, "%s:\n", stub); |
| 21055 |
fprintf (file, "\t.indirect_symbol %s\n", symbol_name); |
| 21056 |
|
| 21057 |
label++; |
| 21058 |
local_label_0 = XALLOCAVEC (char, 16); |
| 21059 |
sprintf (local_label_0, "L%u$spb", label); |
| 21060 |
|
| 21061 |
fprintf (file, "\tmflr r0\n"); |
| 21062 |
fprintf (file, "\tbcl 20,31,%s\n", local_label_0); |
| 21063 |
fprintf (file, "%s:\n\tmflr r11\n", local_label_0); |
| 21064 |
fprintf (file, "\taddis r11,r11,ha16(%s-%s)\n", |
| 21065 |
lazy_ptr_name, local_label_0); |
| 21066 |
fprintf (file, "\tmtlr r0\n"); |
| 21067 |
fprintf (file, "\t%s r12,lo16(%s-%s)(r11)\n", |
| 21068 |
(TARGET_64BIT ? "ldu" : "lwzu"), |
| 21069 |
lazy_ptr_name, local_label_0); |
| 21070 |
fprintf (file, "\tmtctr r12\n"); |
| 21071 |
fprintf (file, "\tbctr\n"); |
| 21072 |
} |
| 21073 |
else /* mdynamic-no-pic or mkernel. */ |
| 21074 |
{ |
| 21075 |
switch_to_section (darwin_sections[machopic_symbol_stub1_section]); |
| 21076 |
fprintf (file, "\t.align 4\n"); |
| 21077 |
|
| 21078 |
fprintf (file, "%s:\n", stub); |
| 21079 |
fprintf (file, "\t.indirect_symbol %s\n", symbol_name); |
| 21080 |
|
| 21081 |
fprintf (file, "\tlis r11,ha16(%s)\n", lazy_ptr_name); |
| 21082 |
fprintf (file, "\t%s r12,lo16(%s)(r11)\n", |
| 21083 |
(TARGET_64BIT ? "ldu" : "lwzu"), |
| 21084 |
lazy_ptr_name); |
| 21085 |
fprintf (file, "\tmtctr r12\n"); |
| 21086 |
fprintf (file, "\tbctr\n"); |
| 21087 |
} |
| 21088 |
|
| 21089 |
switch_to_section (darwin_sections[machopic_lazy_symbol_ptr_section]); |
| 21090 |
fprintf (file, "%s:\n", lazy_ptr_name); |
| 21091 |
fprintf (file, "\t.indirect_symbol %s\n", symbol_name); |
| 21092 |
fprintf (file, "%sdyld_stub_binding_helper\n", |
| 21093 |
(TARGET_64BIT ? DOUBLE_INT_ASM_OP : "\t.long\t")); |
| 21094 |
} |
| 21095 |
|
| 21096 |
/* Legitimize PIC addresses. If the address is already |
| 21097 |
position-independent, we return ORIG. Newly generated |
| 21098 |
position-independent addresses go into a reg. This is REG if non |
| 21099 |
zero, otherwise we allocate register(s) as necessary. */ |
| 21100 |
|
| 21101 |
#define SMALL_INT(X) ((UINTVAL (X) + 0x8000) < 0x10000) |
| 21102 |
|
| 21103 |
rtx |
| 21104 |
rs6000_machopic_legitimize_pic_address (rtx orig, machine_mode mode, |
| 21105 |
rtx reg) |
| 21106 |
{ |
| 21107 |
rtx base, offset; |
| 21108 |
|
| 21109 |
if (reg == NULL && !reload_completed) |
| 21110 |
reg = gen_reg_rtx (Pmode); |
| 21111 |
|
| 21112 |
if (GET_CODE (orig) == CONST) |
| 21113 |
{ |
| 21114 |
rtx reg_temp; |
| 21115 |
|
| 21116 |
if (GET_CODE (XEXP (orig, 0)) == PLUS |
| 21117 |
&& XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx) |
| 21118 |
return orig; |
| 21119 |
|
| 21120 |
gcc_assert (GET_CODE (XEXP (orig, 0)) == PLUS); |
| 21121 |
|
| 21122 |
/* Use a different reg for the intermediate value, as |
| 21123 |
it will be marked UNCHANGING. */ |
| 21124 |
reg_temp = !can_create_pseudo_p () ? reg : gen_reg_rtx (Pmode); |
| 21125 |
base = rs6000_machopic_legitimize_pic_address (XEXP (XEXP (orig, 0), 0), |
| 21126 |
Pmode, reg_temp); |
| 21127 |
offset = |
| 21128 |
rs6000_machopic_legitimize_pic_address (XEXP (XEXP (orig, 0), 1), |
| 21129 |
Pmode, reg); |
| 21130 |
|
| 21131 |
if (CONST_INT_P (offset)) |
| 21132 |
{ |
| 21133 |
if (SMALL_INT (offset)) |
| 21134 |
return plus_constant (Pmode, base, INTVAL (offset)); |
| 21135 |
else if (!reload_completed) |
| 21136 |
offset = force_reg (Pmode, offset); |
| 21137 |
else |
| 21138 |
{ |
| 21139 |
rtx mem = force_const_mem (Pmode, orig); |
| 21140 |
return machopic_legitimize_pic_address (mem, Pmode, reg); |
| 21141 |
} |
| 21142 |
} |
| 21143 |
return gen_rtx_PLUS (Pmode, base, offset); |
| 21144 |
} |
| 21145 |
|
| 21146 |
/* Fall back on generic machopic code. */ |
| 21147 |
return machopic_legitimize_pic_address (orig, mode, reg); |
| 21148 |
} |
| 21149 |
|
| 21150 |
/* Output a .machine directive for the Darwin assembler, and call |
| 21151 |
the generic start_file routine. */ |
| 21152 |
|
| 21153 |
static void |
| 21154 |
rs6000_darwin_file_start (void) |
| 21155 |
{ |
| 21156 |
static const struct |
| 21157 |
{ |
| 21158 |
const char *arg; |
| 21159 |
const char *name; |
| 21160 |
HOST_WIDE_INT if_set; |
| 21161 |
} mapping[] = { |
| 21162 |
{ "ppc64", "ppc64", MASK_64BIT }, |
| 21163 |
{ "970", "ppc970", OPTION_MASK_PPC_GPOPT | OPTION_MASK_MFCRF \ |
| 21164 |
| MASK_POWERPC64 }, |
| 21165 |
{ "power4", "ppc970", 0 }, |
| 21166 |
{ "G5", "ppc970", 0 }, |
| 21167 |
{ "7450", "ppc7450", 0 }, |
| 21168 |
{ "7400", "ppc7400", OPTION_MASK_ALTIVEC }, |
| 21169 |
{ "G4", "ppc7400", 0 }, |
| 21170 |
{ "750", "ppc750", 0 }, |
| 21171 |
{ "740", "ppc750", 0 }, |
| 21172 |
{ "G3", "ppc750", 0 }, |
| 21173 |
{ "604e", "ppc604e", 0 }, |
| 21174 |
{ "604", "ppc604", 0 }, |
| 21175 |
{ "603e", "ppc603", 0 }, |
| 21176 |
{ "603", "ppc603", 0 }, |
| 21177 |
{ "601", "ppc601", 0 }, |
| 21178 |
{ NULL, "ppc", 0 } }; |
| 21179 |
const char *cpu_id = ""; |
| 21180 |
size_t i; |
| 21181 |
|
| 21182 |
rs6000_file_start (); |
| 21183 |
darwin_file_start (); |
| 21184 |
|
| 21185 |
/* Determine the argument to -mcpu=. Default to G3 if not specified. */ |
| 21186 |
|
| 21187 |
if (rs6000_default_cpu != 0 && rs6000_default_cpu[0] != '\0') |
| 21188 |
cpu_id = rs6000_default_cpu; |
| 21189 |
|
| 21190 |
if (OPTION_SET_P (rs6000_cpu_index)) |
| 21191 |
cpu_id = processor_target_table[rs6000_cpu_index].name; |
| 21192 |
|
| 21193 |
/* Look through the mapping array. Pick the first name that either |
| 21194 |
matches the argument, has a bit set in IF_SET that is also set |
| 21195 |
in the target flags, or has a NULL name. */ |
| 21196 |
|
| 21197 |
i = 0; |
| 21198 |
while (mapping[i].arg != NULL |
| 21199 |
&& strcmp (mapping[i].arg, cpu_id) != 0 |
| 21200 |
&& (mapping[i].if_set & rs6000_isa_flags) == 0) |
| 21201 |
i++; |
| 21202 |
|
| 21203 |
fprintf (asm_out_file, "\t.machine %s\n", mapping[i].name); |
| 21204 |
} |
| 21205 |
|
| 21206 |
#endif /* TARGET_MACHO */ |
| 21207 |
|
| 21208 |
#if TARGET_ELF |
| 21209 |
static int |
| 21210 |
rs6000_elf_reloc_rw_mask (void) |
| 21211 |
{ |
| 21212 |
if (flag_pic) |
| 21213 |
return 3; |
| 21214 |
else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) |
| 21215 |
return 2; |
| 21216 |
else |
| 21217 |
return 0; |
| 21218 |
} |
| 21219 |
|
| 21220 |
/* Record an element in the table of global constructors. SYMBOL is |
| 21221 |
a SYMBOL_REF of the function to be called; PRIORITY is a number |
| 21222 |
between 0 and MAX_INIT_PRIORITY. |
| 21223 |
|
| 21224 |
This differs from default_named_section_asm_out_constructor in |
| 21225 |
that we have special handling for -mrelocatable. */ |
| 21226 |
|
| 21227 |
static void rs6000_elf_asm_out_constructor (rtx, int) ATTRIBUTE_UNUSED; |
| 21228 |
static void |
| 21229 |
rs6000_elf_asm_out_constructor (rtx symbol, int priority) |
| 21230 |
{ |
| 21231 |
const char *section = ".ctors"; |
| 21232 |
char buf[18]; |
| 21233 |
|
| 21234 |
if (priority != DEFAULT_INIT_PRIORITY) |
| 21235 |
{ |
| 21236 |
sprintf (buf, ".ctors.%.5u", |
| 21237 |
/* Invert the numbering so the linker puts us in the proper |
| 21238 |
order; constructors are run from right to left, and the |
| 21239 |
linker sorts in increasing order. */ |
| 21240 |
MAX_INIT_PRIORITY - priority); |
| 21241 |
section = buf; |
| 21242 |
} |
| 21243 |
|
| 21244 |
switch_to_section (get_section (section, SECTION_WRITE, NULL)); |
| 21245 |
assemble_align (POINTER_SIZE); |
| 21246 |
|
| 21247 |
if (DEFAULT_ABI == ABI_V4 |
| 21248 |
&& (TARGET_RELOCATABLE || flag_pic > 1)) |
| 21249 |
{ |
| 21250 |
fputs ("\t.long (", asm_out_file); |
| 21251 |
output_addr_const (asm_out_file, symbol); |
| 21252 |
fputs (")@fixup\n", asm_out_file); |
| 21253 |
} |
| 21254 |
else |
| 21255 |
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); |
| 21256 |
} |
| 21257 |
|
| 21258 |
static void rs6000_elf_asm_out_destructor (rtx, int) ATTRIBUTE_UNUSED; |
| 21259 |
static void |
| 21260 |
rs6000_elf_asm_out_destructor (rtx symbol, int priority) |
| 21261 |
{ |
| 21262 |
const char *section = ".dtors"; |
| 21263 |
char buf[18]; |
| 21264 |
|
| 21265 |
if (priority != DEFAULT_INIT_PRIORITY) |
| 21266 |
{ |
| 21267 |
sprintf (buf, ".dtors.%.5u", |
| 21268 |
/* Invert the numbering so the linker puts us in the proper |
| 21269 |
order; constructors are run from right to left, and the |
| 21270 |
linker sorts in increasing order. */ |
| 21271 |
MAX_INIT_PRIORITY - priority); |
| 21272 |
section = buf; |
| 21273 |
} |
| 21274 |
|
| 21275 |
switch_to_section (get_section (section, SECTION_WRITE, NULL)); |
| 21276 |
assemble_align (POINTER_SIZE); |
| 21277 |
|
| 21278 |
if (DEFAULT_ABI == ABI_V4 |
| 21279 |
&& (TARGET_RELOCATABLE || flag_pic > 1)) |
| 21280 |
{ |
| 21281 |
fputs ("\t.long (", asm_out_file); |
| 21282 |
output_addr_const (asm_out_file, symbol); |
| 21283 |
fputs (")@fixup\n", asm_out_file); |
| 21284 |
} |
| 21285 |
else |
| 21286 |
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); |
| 21287 |
} |
| 21288 |
|
| 21289 |
void |
| 21290 |
rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl) |
| 21291 |
{ |
| 21292 |
if (TARGET_64BIT && DEFAULT_ABI != ABI_ELFv2) |
| 21293 |
{ |
| 21294 |
fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", file); |
| 21295 |
ASM_OUTPUT_LABEL (file, name); |
| 21296 |
fputs (DOUBLE_INT_ASM_OP, file); |
| 21297 |
rs6000_output_function_entry (file, name); |
| 21298 |
fputs (",.TOC.@tocbase,0\n\t.previous\n", file); |
| 21299 |
if (DOT_SYMBOLS) |
| 21300 |
{ |
| 21301 |
fputs ("\t.size\t", file); |
| 21302 |
assemble_name (file, name); |
| 21303 |
fputs (",24\n\t.type\t.", file); |
| 21304 |
assemble_name (file, name); |
| 21305 |
fputs (",@function\n", file); |
| 21306 |
if (TREE_PUBLIC (decl) && ! DECL_WEAK (decl)) |
| 21307 |
{ |
| 21308 |
fputs ("\t.globl\t.", file); |
| 21309 |
assemble_name (file, name); |
| 21310 |
putc ('\n', file); |
| 21311 |
} |
| 21312 |
} |
| 21313 |
else |
| 21314 |
ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function"); |
| 21315 |
ASM_DECLARE_RESULT (file, DECL_RESULT (decl)); |
| 21316 |
rs6000_output_function_entry (file, name); |
| 21317 |
fputs (":\n", file); |
| 21318 |
assemble_function_label_final (); |
| 21319 |
return; |
| 21320 |
} |
| 21321 |
|
| 21322 |
int uses_toc; |
| 21323 |
if (DEFAULT_ABI == ABI_V4 |
| 21324 |
&& (TARGET_RELOCATABLE || flag_pic > 1) |
| 21325 |
&& !TARGET_SECURE_PLT |
| 21326 |
&& (!constant_pool_empty_p () || crtl->profile) |
| 21327 |
&& (uses_toc = uses_TOC ())) |
| 21328 |
{ |
| 21329 |
char buf[256]; |
| 21330 |
|
| 21331 |
if (uses_toc == 2) |
| 21332 |
switch_to_other_text_partition (); |
| 21333 |
(*targetm.asm_out.internal_label) (file, "LCL", rs6000_pic_labelno); |
| 21334 |
|
| 21335 |
fprintf (file, "\t.long "); |
| 21336 |
assemble_name (file, toc_label_name); |
| 21337 |
need_toc_init = 1; |
| 21338 |
putc ('-', file); |
| 21339 |
ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno); |
| 21340 |
assemble_name (file, buf); |
| 21341 |
putc ('\n', file); |
| 21342 |
if (uses_toc == 2) |
| 21343 |
switch_to_other_text_partition (); |
| 21344 |
} |
| 21345 |
|
| 21346 |
ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function"); |
| 21347 |
ASM_DECLARE_RESULT (file, DECL_RESULT (decl)); |
| 21348 |
|
| 21349 |
if (TARGET_CMODEL == CMODEL_LARGE |
| 21350 |
&& rs6000_global_entry_point_prologue_needed_p ()) |
| 21351 |
{ |
| 21352 |
char buf[256]; |
| 21353 |
|
| 21354 |
(*targetm.asm_out.internal_label) (file, "LCL", rs6000_pic_labelno); |
| 21355 |
|
| 21356 |
fprintf (file, "\t.quad .TOC.-"); |
| 21357 |
ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno); |
| 21358 |
assemble_name (file, buf); |
| 21359 |
putc ('\n', file); |
| 21360 |
} |
| 21361 |
|
| 21362 |
if (DEFAULT_ABI == ABI_AIX) |
| 21363 |
{ |
| 21364 |
const char *desc_name, *orig_name; |
| 21365 |
|
| 21366 |
orig_name = (*targetm.strip_name_encoding) (name); |
| 21367 |
desc_name = orig_name; |
| 21368 |
while (*desc_name == '.') |
| 21369 |
desc_name++; |
| 21370 |
|
| 21371 |
if (TREE_PUBLIC (decl)) |
| 21372 |
fprintf (file, "\t.globl %s\n", desc_name); |
| 21373 |
|
| 21374 |
fprintf (file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); |
| 21375 |
fprintf (file, "%s:\n", desc_name); |
| 21376 |
fprintf (file, "\t.long %s\n", orig_name); |
| 21377 |
fputs ("\t.long _GLOBAL_OFFSET_TABLE_\n", file); |
| 21378 |
fputs ("\t.long 0\n", file); |
| 21379 |
fprintf (file, "\t.previous\n"); |
| 21380 |
} |
| 21381 |
ASM_OUTPUT_FUNCTION_LABEL (file, name, decl); |
| 21382 |
/* At this time, the "before" NOPs have been already emitted. |
| 21383 |
For split nops stop generic code from printing the "after" NOPs and |
| 21384 |
emit them just after local entry ourself later. */ |
| 21385 |
if (rs6000_global_entry_point_prologue_needed_p ()) |
| 21386 |
cfun->machine->stop_patch_area_print = true; |
| 21387 |
} |
| 21388 |
|
| 21389 |
static void rs6000_elf_file_end (void) ATTRIBUTE_UNUSED; |
| 21390 |
static void |
| 21391 |
rs6000_elf_file_end (void) |
| 21392 |
{ |
| 21393 |
#ifdef HAVE_AS_GNU_ATTRIBUTE |
| 21394 |
/* ??? The value emitted depends on options active at file end. |
| 21395 |
Assume anyone using #pragma or attributes that might change |
| 21396 |
options knows what they are doing. */ |
| 21397 |
if ((TARGET_64BIT || DEFAULT_ABI == ABI_V4) |
| 21398 |
&& rs6000_passes_float) |
| 21399 |
{ |
| 21400 |
int fp; |
| 21401 |
|
| 21402 |
if (TARGET_HARD_FLOAT) |
| 21403 |
fp = 1; |
| 21404 |
else |
| 21405 |
fp = 2; |
| 21406 |
if (rs6000_passes_long_double) |
| 21407 |
{ |
| 21408 |
if (!TARGET_LONG_DOUBLE_128) |
| 21409 |
fp |= 2 * 4; |
| 21410 |
else if (TARGET_IEEEQUAD) |
| 21411 |
fp |= 3 * 4; |
| 21412 |
else |
| 21413 |
fp |= 1 * 4; |
| 21414 |
} |
| 21415 |
fprintf (asm_out_file, "\t.gnu_attribute 4, %d\n", fp); |
| 21416 |
} |
| 21417 |
if (TARGET_32BIT && DEFAULT_ABI == ABI_V4) |
| 21418 |
{ |
| 21419 |
if (rs6000_passes_vector) |
| 21420 |
fprintf (asm_out_file, "\t.gnu_attribute 8, %d\n", |
| 21421 |
(TARGET_ALTIVEC_ABI ? 2 : 1)); |
| 21422 |
if (rs6000_returns_struct) |
| 21423 |
fprintf (asm_out_file, "\t.gnu_attribute 12, %d\n", |
| 21424 |
aix_struct_return ? 2 : 1); |
| 21425 |
} |
| 21426 |
#endif |
| 21427 |
#if defined (POWERPC_LINUX) || defined (POWERPC_FREEBSD) |
| 21428 |
if (TARGET_32BIT || DEFAULT_ABI == ABI_ELFv2) |
| 21429 |
file_end_indicate_exec_stack (); |
| 21430 |
#endif |
| 21431 |
|
| 21432 |
if (flag_split_stack) |
| 21433 |
file_end_indicate_split_stack (); |
| 21434 |
|
| 21435 |
if (cpu_builtin_p) |
| 21436 |
{ |
| 21437 |
/* We have expanded a CPU builtin, so we need to emit a reference to |
| 21438 |
the special symbol that LIBC uses to declare it supports the |
| 21439 |
AT_PLATFORM and AT_HWCAP/AT_HWCAP2 in the TCB feature. */ |
| 21440 |
switch_to_section (data_section); |
| 21441 |
fprintf (asm_out_file, "\t.align %u\n", TARGET_32BIT ? 2 : 3); |
| 21442 |
fprintf (asm_out_file, "\t%s %s\n", |
| 21443 |
TARGET_32BIT ? ".long" : ".quad", tcb_verification_symbol); |
| 21444 |
} |
| 21445 |
} |
| 21446 |
#endif |
| 21447 |
|
| 21448 |
#if TARGET_XCOFF |
| 21449 |
|
| 21450 |
#ifndef HAVE_XCOFF_DWARF_EXTRAS |
| 21451 |
#define HAVE_XCOFF_DWARF_EXTRAS 0 |
| 21452 |
#endif |
| 21453 |
|
| 21454 |
|
| 21455 |
/* Names of bss and data sections. These should be unique names for each |
| 21456 |
compilation unit. */ |
| 21457 |
|
| 21458 |
char *xcoff_bss_section_name; |
| 21459 |
char *xcoff_private_data_section_name; |
| 21460 |
char *xcoff_private_rodata_section_name; |
| 21461 |
char *xcoff_tls_data_section_name; |
| 21462 |
char *xcoff_read_only_section_name; |
| 21463 |
|
| 21464 |
static enum unwind_info_type |
| 21465 |
rs6000_xcoff_debug_unwind_info (void) |
| 21466 |
{ |
| 21467 |
return UI_NONE; |
| 21468 |
} |
| 21469 |
|
| 21470 |
static void |
| 21471 |
rs6000_xcoff_asm_output_anchor (rtx symbol) |
| 21472 |
{ |
| 21473 |
char buffer[100]; |
| 21474 |
|
| 21475 |
sprintf (buffer, "$ + " HOST_WIDE_INT_PRINT_DEC, |
| 21476 |
SYMBOL_REF_BLOCK_OFFSET (symbol)); |
| 21477 |
fprintf (asm_out_file, "%s", SET_ASM_OP); |
| 21478 |
RS6000_OUTPUT_BASENAME (asm_out_file, XSTR (symbol, 0)); |
| 21479 |
fprintf (asm_out_file, ","); |
| 21480 |
RS6000_OUTPUT_BASENAME (asm_out_file, buffer); |
| 21481 |
fprintf (asm_out_file, "\n"); |
| 21482 |
} |
| 21483 |
|
| 21484 |
static void |
| 21485 |
rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name) |
| 21486 |
{ |
| 21487 |
fputs (GLOBAL_ASM_OP, stream); |
| 21488 |
RS6000_OUTPUT_BASENAME (stream, name); |
| 21489 |
putc ('\n', stream); |
| 21490 |
} |
| 21491 |
|
| 21492 |
/* A get_unnamed_decl callback, used for read-only sections. PTR |
| 21493 |
points to the section string variable. */ |
| 21494 |
|
| 21495 |
static void |
| 21496 |
rs6000_xcoff_output_readonly_section_asm_op (const char *directive) |
| 21497 |
{ |
| 21498 |
fprintf (asm_out_file, "\t.csect %s[RO],%s\n", |
| 21499 |
directive |
| 21500 |
? xcoff_private_rodata_section_name |
| 21501 |
: xcoff_read_only_section_name, |
| 21502 |
XCOFF_CSECT_DEFAULT_ALIGNMENT_STR); |
| 21503 |
} |
| 21504 |
|
| 21505 |
/* Likewise for read-write sections. */ |
| 21506 |
|
| 21507 |
static void |
| 21508 |
rs6000_xcoff_output_readwrite_section_asm_op (const char *) |
| 21509 |
{ |
| 21510 |
fprintf (asm_out_file, "\t.csect %s[RW],%s\n", |
| 21511 |
xcoff_private_data_section_name, |
| 21512 |
XCOFF_CSECT_DEFAULT_ALIGNMENT_STR); |
| 21513 |
} |
| 21514 |
|
| 21515 |
static void |
| 21516 |
rs6000_xcoff_output_tls_section_asm_op (const char *directive) |
| 21517 |
{ |
| 21518 |
fprintf (asm_out_file, "\t.csect %s[TL],%s\n", |
| 21519 |
directive |
| 21520 |
? xcoff_private_data_section_name |
| 21521 |
: xcoff_tls_data_section_name, |
| 21522 |
XCOFF_CSECT_DEFAULT_ALIGNMENT_STR); |
| 21523 |
} |
| 21524 |
|
| 21525 |
/* A get_unnamed_section callback, used for switching to toc_section. */ |
| 21526 |
|
| 21527 |
static void |
| 21528 |
rs6000_xcoff_output_toc_section_asm_op (const char *data ATTRIBUTE_UNUSED) |
| 21529 |
{ |
| 21530 |
if (TARGET_MINIMAL_TOC) |
| 21531 |
{ |
| 21532 |
/* toc_section is always selected at least once from |
| 21533 |
rs6000_xcoff_file_start, so this is guaranteed to |
| 21534 |
always be defined once and only once in each file. */ |
| 21535 |
if (!toc_initialized) |
| 21536 |
{ |
| 21537 |
fputs ("\t.toc\nLCTOC..1:\n", asm_out_file); |
| 21538 |
fputs ("\t.tc toc_table[TC],toc_table[RW]\n", asm_out_file); |
| 21539 |
toc_initialized = 1; |
| 21540 |
} |
| 21541 |
fprintf (asm_out_file, "\t.csect toc_table[RW]%s\n", |
| 21542 |
(TARGET_32BIT ? "" : ",3")); |
| 21543 |
} |
| 21544 |
else |
| 21545 |
fputs ("\t.toc\n", asm_out_file); |
| 21546 |
} |
| 21547 |
|
| 21548 |
/* Implement TARGET_ASM_INIT_SECTIONS. */ |
| 21549 |
|
| 21550 |
static void |
| 21551 |
rs6000_xcoff_asm_init_sections (void) |
| 21552 |
{ |
| 21553 |
read_only_data_section |
| 21554 |
= get_unnamed_section (0, rs6000_xcoff_output_readonly_section_asm_op, |
| 21555 |
NULL); |
| 21556 |
|
| 21557 |
private_data_section |
| 21558 |
= get_unnamed_section (SECTION_WRITE, |
| 21559 |
rs6000_xcoff_output_readwrite_section_asm_op, |
| 21560 |
NULL); |
| 21561 |
|
| 21562 |
read_only_private_data_section |
| 21563 |
= get_unnamed_section (0, rs6000_xcoff_output_readonly_section_asm_op, |
| 21564 |
""); |
| 21565 |
|
| 21566 |
tls_data_section |
| 21567 |
= get_unnamed_section (SECTION_TLS, |
| 21568 |
rs6000_xcoff_output_tls_section_asm_op, |
| 21569 |
NULL); |
| 21570 |
|
| 21571 |
tls_private_data_section |
| 21572 |
= get_unnamed_section (SECTION_TLS, |
| 21573 |
rs6000_xcoff_output_tls_section_asm_op, |
| 21574 |
""); |
| 21575 |
|
| 21576 |
toc_section |
| 21577 |
= get_unnamed_section (0, rs6000_xcoff_output_toc_section_asm_op, NULL); |
| 21578 |
|
| 21579 |
readonly_data_section = read_only_data_section; |
| 21580 |
} |
| 21581 |
|
| 21582 |
static int |
| 21583 |
rs6000_xcoff_reloc_rw_mask (void) |
| 21584 |
{ |
| 21585 |
return 3; |
| 21586 |
} |
| 21587 |
|
| 21588 |
static void |
| 21589 |
rs6000_xcoff_asm_named_section (const char *name, unsigned int flags, |
| 21590 |
tree decl ATTRIBUTE_UNUSED) |
| 21591 |
{ |
| 21592 |
int smclass; |
| 21593 |
static const char * const suffix[7] |
| 21594 |
= { "PR", "RO", "RW", "BS", "TL", "UL", "XO" }; |
| 21595 |
|
| 21596 |
if (flags & SECTION_EXCLUDE) |
| 21597 |
smclass = 6; |
| 21598 |
else if (flags & SECTION_DEBUG) |
| 21599 |
{ |
| 21600 |
fprintf (asm_out_file, "\t.dwsect %s\n", name); |
| 21601 |
return; |
| 21602 |
} |
| 21603 |
else if (flags & SECTION_CODE) |
| 21604 |
smclass = 0; |
| 21605 |
else if (flags & SECTION_TLS) |
| 21606 |
{ |
| 21607 |
if (flags & SECTION_BSS) |
| 21608 |
smclass = 5; |
| 21609 |
else |
| 21610 |
smclass = 4; |
| 21611 |
} |
| 21612 |
else if (flags & SECTION_WRITE) |
| 21613 |
{ |
| 21614 |
if (flags & SECTION_BSS) |
| 21615 |
smclass = 3; |
| 21616 |
else |
| 21617 |
smclass = 2; |
| 21618 |
} |
| 21619 |
else |
| 21620 |
smclass = 1; |
| 21621 |
|
| 21622 |
fprintf (asm_out_file, "\t.csect %s%s[%s],%u\n", |
| 21623 |
(flags & SECTION_CODE) ? "." : "", |
| 21624 |
name, suffix[smclass], flags & SECTION_ENTSIZE); |
| 21625 |
} |
| 21626 |
|
| 21627 |
#define IN_NAMED_SECTION(DECL) \ |
| 21628 |
((TREE_CODE (DECL) == FUNCTION_DECL || VAR_P (DECL)) \ |
| 21629 |
&& DECL_SECTION_NAME (DECL) != NULL) |
| 21630 |
|
| 21631 |
static section * |
| 21632 |
rs6000_xcoff_select_section (tree decl, int reloc, |
| 21633 |
unsigned HOST_WIDE_INT align) |
| 21634 |
{ |
| 21635 |
/* Place variables with alignment stricter than BIGGEST_ALIGNMENT into |
| 21636 |
named section. */ |
| 21637 |
if (align > BIGGEST_ALIGNMENT && VAR_OR_FUNCTION_DECL_P (decl)) |
| 21638 |
{ |
| 21639 |
resolve_unique_section (decl, reloc, true); |
| 21640 |
if (IN_NAMED_SECTION (decl)) |
| 21641 |
return get_named_section (decl, NULL, reloc); |
| 21642 |
} |
| 21643 |
|
| 21644 |
if (decl_readonly_section (decl, reloc)) |
| 21645 |
{ |
| 21646 |
if (TREE_PUBLIC (decl)) |
| 21647 |
return read_only_data_section; |
| 21648 |
else |
| 21649 |
return read_only_private_data_section; |
| 21650 |
} |
| 21651 |
else |
| 21652 |
{ |
| 21653 |
#if HAVE_AS_TLS |
| 21654 |
if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) |
| 21655 |
{ |
| 21656 |
if (bss_initializer_p (decl)) |
| 21657 |
return tls_comm_section; |
| 21658 |
else if (TREE_PUBLIC (decl)) |
| 21659 |
return tls_data_section; |
| 21660 |
else |
| 21661 |
return tls_private_data_section; |
| 21662 |
} |
| 21663 |
else |
| 21664 |
#endif |
| 21665 |
if (TREE_PUBLIC (decl)) |
| 21666 |
return data_section; |
| 21667 |
else |
| 21668 |
return private_data_section; |
| 21669 |
} |
| 21670 |
} |
| 21671 |
|
| 21672 |
static void |
| 21673 |
rs6000_xcoff_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED) |
| 21674 |
{ |
| 21675 |
const char *name; |
| 21676 |
|
| 21677 |
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); |
| 21678 |
name = (*targetm.strip_name_encoding) (name); |
| 21679 |
set_decl_section_name (decl, name); |
| 21680 |
} |
| 21681 |
|
| 21682 |
/* Select section for constant in constant pool. |
| 21683 |
|
| 21684 |
On RS/6000, all constants are in the private read-only data area. |
| 21685 |
However, if this is being placed in the TOC it must be output as a |
| 21686 |
toc entry. */ |
| 21687 |
|
| 21688 |
static section * |
| 21689 |
rs6000_xcoff_select_rtx_section (machine_mode mode, rtx x, |
| 21690 |
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) |
| 21691 |
{ |
| 21692 |
if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode)) |
| 21693 |
return toc_section; |
| 21694 |
else |
| 21695 |
return read_only_private_data_section; |
| 21696 |
} |
| 21697 |
|
| 21698 |
/* Remove any trailing [DS] or the like from the symbol name. */ |
| 21699 |
|
| 21700 |
static const char * |
| 21701 |
rs6000_xcoff_strip_name_encoding (const char *name) |
| 21702 |
{ |
| 21703 |
size_t len; |
| 21704 |
if (*name == '*') |
| 21705 |
name++; |
| 21706 |
len = strlen (name); |
| 21707 |
if (name[len - 1] == ']') |
| 21708 |
return ggc_alloc_string (name, len - 4); |
| 21709 |
else |
| 21710 |
return name; |
| 21711 |
} |
| 21712 |
|
| 21713 |
/* Section attributes. AIX is always PIC. */ |
| 21714 |
|
| 21715 |
static unsigned int |
| 21716 |
rs6000_xcoff_section_type_flags (tree decl, const char *name, int reloc) |
| 21717 |
{ |
| 21718 |
unsigned int align; |
| 21719 |
unsigned int flags = default_section_type_flags (decl, name, reloc); |
| 21720 |
|
| 21721 |
if (decl && DECL_P (decl) && VAR_P (decl) && bss_initializer_p (decl)) |
| 21722 |
flags |= SECTION_BSS; |
| 21723 |
|
| 21724 |
/* Align to at least UNIT size. */ |
| 21725 |
if (!decl || !DECL_P (decl)) |
| 21726 |
align = MIN_UNITS_PER_WORD; |
| 21727 |
/* Align code CSECT to at least 32 bytes. */ |
| 21728 |
else if ((flags & SECTION_CODE) != 0) |
| 21729 |
align = MAX ((DECL_ALIGN (decl) / BITS_PER_UNIT), 32); |
| 21730 |
else |
| 21731 |
/* Increase alignment of large objects if not already stricter. */ |
| 21732 |
align = MAX ((DECL_ALIGN (decl) / BITS_PER_UNIT), |
| 21733 |
int_size_in_bytes (TREE_TYPE (decl)) > MIN_UNITS_PER_WORD |
| 21734 |
? UNITS_PER_FP_WORD : MIN_UNITS_PER_WORD); |
| 21735 |
|
| 21736 |
return flags | (exact_log2 (align) & SECTION_ENTSIZE); |
| 21737 |
} |
| 21738 |
|
| 21739 |
/* Output at beginning of assembler file. |
| 21740 |
|
| 21741 |
Initialize the section names for the RS/6000 at this point. |
| 21742 |
|
| 21743 |
Specify filename, including full path, to assembler. |
| 21744 |
|
| 21745 |
We want to go into the TOC section so at least one .toc will be emitted. |
| 21746 |
Also, in order to output proper .bs/.es pairs, we need at least one static |
| 21747 |
[RW] section emitted. |
| 21748 |
|
| 21749 |
Finally, declare mcount when profiling to make the assembler happy. */ |
| 21750 |
|
| 21751 |
static void |
| 21752 |
rs6000_xcoff_file_start (void) |
| 21753 |
{ |
| 21754 |
rs6000_gen_section_name (&xcoff_bss_section_name, |
| 21755 |
main_input_filename, ".bss_"); |
| 21756 |
rs6000_gen_section_name (&xcoff_private_data_section_name, |
| 21757 |
main_input_filename, ".rw_"); |
| 21758 |
rs6000_gen_section_name (&xcoff_private_rodata_section_name, |
| 21759 |
main_input_filename, ".rop_"); |
| 21760 |
rs6000_gen_section_name (&xcoff_read_only_section_name, |
| 21761 |
main_input_filename, ".ro_"); |
| 21762 |
rs6000_gen_section_name (&xcoff_tls_data_section_name, |
| 21763 |
main_input_filename, ".tls_"); |
| 21764 |
|
| 21765 |
fputs ("\t.file\t", asm_out_file); |
| 21766 |
output_quoted_string (asm_out_file, main_input_filename); |
| 21767 |
fputc ('\n', asm_out_file); |
| 21768 |
if (write_symbols != NO_DEBUG) |
| 21769 |
switch_to_section (private_data_section); |
| 21770 |
switch_to_section (toc_section); |
| 21771 |
switch_to_section (text_section); |
| 21772 |
if (profile_flag) |
| 21773 |
fprintf (asm_out_file, "\t.extern %s\n", RS6000_MCOUNT); |
| 21774 |
rs6000_file_start (); |
| 21775 |
} |
| 21776 |
|
| 21777 |
/* Output at end of assembler file. |
| 21778 |
On the RS/6000, referencing data should automatically pull in text. */ |
| 21779 |
|
| 21780 |
static void |
| 21781 |
rs6000_xcoff_file_end (void) |
| 21782 |
{ |
| 21783 |
switch_to_section (text_section); |
| 21784 |
if (xcoff_tls_exec_model_detected) |
| 21785 |
{ |
| 21786 |
/* Add a .ref to __tls_get_addr to force libpthread dependency. */ |
| 21787 |
fputs ("\t.extern __tls_get_addr\n\t.ref __tls_get_addr\n", asm_out_file); |
| 21788 |
} |
| 21789 |
fputs ("_section_.text:\n", asm_out_file); |
| 21790 |
switch_to_section (data_section); |
| 21791 |
fputs (TARGET_32BIT |
| 21792 |
? "\t.long _section_.text\n" : "\t.llong _section_.text\n", |
| 21793 |
asm_out_file); |
| 21794 |
|
| 21795 |
} |
| 21796 |
|
| 21797 |
struct declare_alias_data |
| 21798 |
{ |
| 21799 |
FILE *file; |
| 21800 |
bool function_descriptor; |
| 21801 |
}; |
| 21802 |
|
| 21803 |
/* Declare alias N. A helper function for for_node_and_aliases. */ |
| 21804 |
|
| 21805 |
static bool |
| 21806 |
rs6000_declare_alias (struct symtab_node *n, void *d) |
| 21807 |
{ |
| 21808 |
struct declare_alias_data *data = (struct declare_alias_data *)d; |
| 21809 |
/* Main symbol is output specially, because varasm machinery does part of |
| 21810 |
the job for us - we do not need to declare .globl/lglobs and such. */ |
| 21811 |
if (!n->alias || n->weakref) |
| 21812 |
return false; |
| 21813 |
|
| 21814 |
if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (n->decl))) |
| 21815 |
return false; |
| 21816 |
|
| 21817 |
/* Prevent assemble_alias from trying to use .set pseudo operation |
| 21818 |
that does not behave as expected by the middle-end. */ |
| 21819 |
TREE_ASM_WRITTEN (n->decl) = true; |
| 21820 |
|
| 21821 |
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (n->decl)); |
| 21822 |
char *buffer = (char *) alloca (strlen (name) + 2); |
| 21823 |
char *p; |
| 21824 |
int dollar_inside = 0; |
| 21825 |
|
| 21826 |
strcpy (buffer, name); |
| 21827 |
p = strchr (buffer, '$'); |
| 21828 |
while (p) { |
| 21829 |
*p = '_'; |
| 21830 |
dollar_inside++; |
| 21831 |
p = strchr (p + 1, '$'); |
| 21832 |
} |
| 21833 |
if (TREE_PUBLIC (n->decl)) |
| 21834 |
{ |
| 21835 |
if (!RS6000_WEAK || !DECL_WEAK (n->decl)) |
| 21836 |
{ |
| 21837 |
if (dollar_inside) { |
| 21838 |
if (data->function_descriptor) |
| 21839 |
fprintf(data->file, "\t.rename .%s,\".%s\"\n", buffer, name); |
| 21840 |
fprintf(data->file, "\t.rename %s,\"%s\"\n", buffer, name); |
| 21841 |
} |
| 21842 |
if (data->function_descriptor) |
| 21843 |
{ |
| 21844 |
fputs ("\t.globl .", data->file); |
| 21845 |
RS6000_OUTPUT_BASENAME (data->file, buffer); |
| 21846 |
putc ('\n', data->file); |
| 21847 |
} |
| 21848 |
fputs ("\t.globl ", data->file); |
| 21849 |
assemble_name (data->file, buffer); |
| 21850 |
putc ('\n', data->file); |
| 21851 |
} |
| 21852 |
#ifdef ASM_WEAKEN_DECL |
| 21853 |
else if (DECL_WEAK (n->decl) && !data->function_descriptor) |
| 21854 |
ASM_WEAKEN_DECL (data->file, n->decl, name, NULL); |
| 21855 |
#endif |
| 21856 |
} |
| 21857 |
else |
| 21858 |
{ |
| 21859 |
if (dollar_inside) |
| 21860 |
{ |
| 21861 |
if (data->function_descriptor) |
| 21862 |
fprintf(data->file, "\t.rename .%s,\".%s\"\n", buffer, name); |
| 21863 |
fprintf(data->file, "\t.rename %s,\"%s\"\n", buffer, name); |
| 21864 |
} |
| 21865 |
if (data->function_descriptor) |
| 21866 |
{ |
| 21867 |
fputs ("\t.lglobl .", data->file); |
| 21868 |
RS6000_OUTPUT_BASENAME (data->file, buffer); |
| 21869 |
putc ('\n', data->file); |
| 21870 |
} |
| 21871 |
fputs ("\t.lglobl ", data->file); |
| 21872 |
assemble_name (data->file, buffer); |
| 21873 |
putc ('\n', data->file); |
| 21874 |
} |
| 21875 |
if (data->function_descriptor) |
| 21876 |
putc ('.', data->file); |
| 21877 |
ASM_OUTPUT_LABEL (data->file, buffer); |
| 21878 |
return false; |
| 21879 |
} |
| 21880 |
|
| 21881 |
|
| 21882 |
#ifdef HAVE_GAS_HIDDEN |
| 21883 |
/* Helper function to calculate visibility of a DECL |
| 21884 |
and return the value as a const string. */ |
| 21885 |
|
| 21886 |
static const char * |
| 21887 |
rs6000_xcoff_visibility (tree decl) |
| 21888 |
{ |
| 21889 |
static const char * const visibility_types[] = { |
| 21890 |
"", ",protected", ",hidden", ",internal" |
| 21891 |
}; |
| 21892 |
|
| 21893 |
enum symbol_visibility vis = DECL_VISIBILITY (decl); |
| 21894 |
return visibility_types[vis]; |
| 21895 |
} |
| 21896 |
#endif |
| 21897 |
|
| 21898 |
|
| 21899 |
/* This macro produces the initial definition of a function name. |
| 21900 |
On the RS/6000, we need to place an extra '.' in the function name and |
| 21901 |
output the function descriptor. |
| 21902 |
Dollar signs are converted to underscores. |
| 21903 |
|
| 21904 |
The csect for the function will have already been created when |
| 21905 |
text_section was selected. We do have to go back to that csect, however. |
| 21906 |
|
| 21907 |
The third and fourth parameters to the .function pseudo-op (16 and 044) |
| 21908 |
are placeholders which no longer have any use. |
| 21909 |
|
| 21910 |
Because AIX assembler's .set command has unexpected semantics, we output |
| 21911 |
all aliases as alternative labels in front of the definition. */ |
| 21912 |
|
| 21913 |
void |
| 21914 |
rs6000_xcoff_declare_function_name (FILE *file, const char *name, tree decl) |
| 21915 |
{ |
| 21916 |
char *buffer = (char *) alloca (strlen (name) + 1); |
| 21917 |
char *p; |
| 21918 |
int dollar_inside = 0; |
| 21919 |
struct declare_alias_data data = {file, false}; |
| 21920 |
|
| 21921 |
strcpy (buffer, name); |
| 21922 |
p = strchr (buffer, '$'); |
| 21923 |
while (p) { |
| 21924 |
*p = '_'; |
| 21925 |
dollar_inside++; |
| 21926 |
p = strchr (p + 1, '$'); |
| 21927 |
} |
| 21928 |
if (TREE_PUBLIC (decl)) |
| 21929 |
{ |
| 21930 |
if (!RS6000_WEAK || !DECL_WEAK (decl)) |
| 21931 |
{ |
| 21932 |
if (dollar_inside) { |
| 21933 |
fprintf(file, "\t.rename .%s,\".%s\"\n", buffer, name); |
| 21934 |
fprintf(file, "\t.rename %s,\"%s\"\n", buffer, name); |
| 21935 |
} |
| 21936 |
fputs ("\t.globl .", file); |
| 21937 |
RS6000_OUTPUT_BASENAME (file, buffer); |
| 21938 |
#ifdef HAVE_GAS_HIDDEN |
| 21939 |
fputs (rs6000_xcoff_visibility (decl), file); |
| 21940 |
#endif |
| 21941 |
putc ('\n', file); |
| 21942 |
} |
| 21943 |
} |
| 21944 |
else |
| 21945 |
{ |
| 21946 |
if (dollar_inside) { |
| 21947 |
fprintf(file, "\t.rename .%s,\".%s\"\n", buffer, name); |
| 21948 |
fprintf(file, "\t.rename %s,\"%s\"\n", buffer, name); |
| 21949 |
} |
| 21950 |
fputs ("\t.lglobl .", file); |
| 21951 |
RS6000_OUTPUT_BASENAME (file, buffer); |
| 21952 |
putc ('\n', file); |
| 21953 |
} |
| 21954 |
|
| 21955 |
fputs ("\t.csect ", file); |
| 21956 |
assemble_name (file, buffer); |
| 21957 |
fputs (TARGET_32BIT ? "\n" : ",3\n", file); |
| 21958 |
|
| 21959 |
ASM_OUTPUT_FUNCTION_LABEL (file, buffer, decl); |
| 21960 |
|
| 21961 |
symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, |
| 21962 |
&data, true); |
| 21963 |
fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", file); |
| 21964 |
RS6000_OUTPUT_BASENAME (file, buffer); |
| 21965 |
fputs (", TOC[tc0], 0\n", file); |
| 21966 |
|
| 21967 |
in_section = NULL; |
| 21968 |
switch_to_section (function_section (decl)); |
| 21969 |
putc ('.', file); |
| 21970 |
ASM_OUTPUT_LABEL (file, buffer); |
| 21971 |
|
| 21972 |
data.function_descriptor = true; |
| 21973 |
symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, |
| 21974 |
&data, true); |
| 21975 |
if (!DECL_IGNORED_P (decl)) |
| 21976 |
{ |
| 21977 |
if (dwarf_debuginfo_p ()) |
| 21978 |
{ |
| 21979 |
name = (*targetm.strip_name_encoding) (name); |
| 21980 |
fprintf (file, "\t.function .%s,.%s,2,0\n", name, name); |
| 21981 |
} |
| 21982 |
} |
| 21983 |
return; |
| 21984 |
} |
| 21985 |
|
| 21986 |
|
| 21987 |
/* Output assembly language to globalize a symbol from a DECL, |
| 21988 |
possibly with visibility. */ |
| 21989 |
|
| 21990 |
void |
| 21991 |
rs6000_xcoff_asm_globalize_decl_name (FILE *stream, tree decl) |
| 21992 |
{ |
| 21993 |
const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0); |
| 21994 |
fputs (GLOBAL_ASM_OP, stream); |
| 21995 |
assemble_name (stream, name); |
| 21996 |
#ifdef HAVE_GAS_HIDDEN |
| 21997 |
fputs (rs6000_xcoff_visibility (decl), stream); |
| 21998 |
#endif |
| 21999 |
putc ('\n', stream); |
| 22000 |
} |
| 22001 |
|
| 22002 |
/* Output assembly language to define a symbol as COMMON from a DECL, |
| 22003 |
possibly with visibility. */ |
| 22004 |
|
| 22005 |
void |
| 22006 |
rs6000_xcoff_asm_output_aligned_decl_common (FILE *stream, |
| 22007 |
tree decl ATTRIBUTE_UNUSED, |
| 22008 |
const char *name, |
| 22009 |
unsigned HOST_WIDE_INT size, |
| 22010 |
unsigned int align) |
| 22011 |
{ |
| 22012 |
unsigned int align2 = 2; |
| 22013 |
|
| 22014 |
if (align == 0) |
| 22015 |
align = DATA_ABI_ALIGNMENT (TREE_TYPE (decl), DECL_ALIGN (decl)); |
| 22016 |
|
| 22017 |
if (align > 32) |
| 22018 |
align2 = floor_log2 (align / BITS_PER_UNIT); |
| 22019 |
else if (size > 4) |
| 22020 |
align2 = 3; |
| 22021 |
|
| 22022 |
if (! DECL_COMMON (decl)) |
| 22023 |
{ |
| 22024 |
/* Forget section. */ |
| 22025 |
in_section = NULL; |
| 22026 |
|
| 22027 |
/* Globalize TLS BSS. */ |
| 22028 |
if (TREE_PUBLIC (decl) && DECL_THREAD_LOCAL_P (decl)) |
| 22029 |
{ |
| 22030 |
fputs (GLOBAL_ASM_OP, stream); |
| 22031 |
assemble_name (stream, name); |
| 22032 |
fputc ('\n', stream); |
| 22033 |
} |
| 22034 |
|
| 22035 |
/* Switch to section and skip space. */ |
| 22036 |
fputs ("\t.csect ", stream); |
| 22037 |
assemble_name (stream, name); |
| 22038 |
fprintf (stream, ",%u\n", align2); |
| 22039 |
ASM_DECLARE_OBJECT_NAME (stream, name, decl); |
| 22040 |
ASM_OUTPUT_SKIP (stream, size ? size : 1); |
| 22041 |
return; |
| 22042 |
} |
| 22043 |
|
| 22044 |
if (TREE_PUBLIC (decl)) |
| 22045 |
{ |
| 22046 |
fprintf (stream, |
| 22047 |
"\t.comm %s," HOST_WIDE_INT_PRINT_UNSIGNED ",%u" , |
| 22048 |
name, size, align2); |
| 22049 |
|
| 22050 |
#ifdef HAVE_GAS_HIDDEN |
| 22051 |
if (decl != NULL) |
| 22052 |
fputs (rs6000_xcoff_visibility (decl), stream); |
| 22053 |
#endif |
| 22054 |
putc ('\n', stream); |
| 22055 |
} |
| 22056 |
else |
| 22057 |
fprintf (stream, |
| 22058 |
"\t.lcomm %s," HOST_WIDE_INT_PRINT_UNSIGNED ",%s,%u\n", |
| 22059 |
(*targetm.strip_name_encoding) (name), size, name, align2); |
| 22060 |
} |
| 22061 |
|
| 22062 |
/* This macro produces the initial definition of a object (variable) name. |
| 22063 |
Because AIX assembler's .set command has unexpected semantics, we output |
| 22064 |
all aliases as alternative labels in front of the definition. */ |
| 22065 |
|
| 22066 |
void |
| 22067 |
rs6000_xcoff_declare_object_name (FILE *file, const char *name, tree decl) |
| 22068 |
{ |
| 22069 |
struct declare_alias_data data = {file, false}; |
| 22070 |
ASM_OUTPUT_LABEL (file, name); |
| 22071 |
symtab_node::get_create (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, |
| 22072 |
&data, true); |
| 22073 |
} |
| 22074 |
|
| 22075 |
/* Overide the default 'SYMBOL-.' syntax with AIX compatible 'SYMBOL-$'. */ |
| 22076 |
|
| 22077 |
void |
| 22078 |
rs6000_asm_output_dwarf_pcrel (FILE *file, int size, const char *label) |
| 22079 |
{ |
| 22080 |
fputs (integer_asm_op (size, FALSE), file); |
| 22081 |
assemble_name (file, label); |
| 22082 |
fputs ("-$", file); |
| 22083 |
} |
| 22084 |
|
| 22085 |
/* Output a symbol offset relative to the dbase for the current object. |
| 22086 |
We use __gcc_unwind_dbase as an arbitrary base for dbase and assume |
| 22087 |
signed offsets. |
| 22088 |
|
| 22089 |
__gcc_unwind_dbase is embedded in all executables/libraries through |
| 22090 |
libgcc/config/rs6000/crtdbase.S. */ |
| 22091 |
|
| 22092 |
void |
| 22093 |
rs6000_asm_output_dwarf_datarel (FILE *file, int size, const char *label) |
| 22094 |
{ |
| 22095 |
fputs (integer_asm_op (size, FALSE), file); |
| 22096 |
assemble_name (file, label); |
| 22097 |
fputs("-__gcc_unwind_dbase", file); |
| 22098 |
} |
| 22099 |
|
| 22100 |
#ifdef HAVE_AS_TLS |
| 22101 |
static void |
| 22102 |
rs6000_xcoff_encode_section_info (tree decl, rtx rtl, int first) |
| 22103 |
{ |
| 22104 |
rtx symbol; |
| 22105 |
int flags; |
| 22106 |
const char *symname; |
| 22107 |
|
| 22108 |
default_encode_section_info (decl, rtl, first); |
| 22109 |
|
| 22110 |
/* Careful not to prod global register variables. */ |
| 22111 |
if (!MEM_P (rtl)) |
| 22112 |
return; |
| 22113 |
symbol = XEXP (rtl, 0); |
| 22114 |
if (!SYMBOL_REF_P (symbol)) |
| 22115 |
return; |
| 22116 |
|
| 22117 |
flags = SYMBOL_REF_FLAGS (symbol); |
| 22118 |
|
| 22119 |
if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl)) |
| 22120 |
flags &= ~SYMBOL_FLAG_HAS_BLOCK_INFO; |
| 22121 |
|
| 22122 |
SYMBOL_REF_FLAGS (symbol) = flags; |
| 22123 |
|
| 22124 |
symname = XSTR (symbol, 0); |
| 22125 |
|
| 22126 |
/* Append CSECT mapping class, unless the symbol already is qualified. |
| 22127 |
Aliases are implemented as labels, so the symbol name should not add |
| 22128 |
a mapping class. */ |
| 22129 |
if (decl |
| 22130 |
&& DECL_P (decl) |
| 22131 |
&& VAR_OR_FUNCTION_DECL_P (decl) |
| 22132 |
&& (symtab_node::get (decl) == NULL |
| 22133 |
|| symtab_node::get (decl)->alias == 0) |
| 22134 |
&& symname[strlen (symname) - 1] != ']') |
| 22135 |
{ |
| 22136 |
const char *smclass = NULL; |
| 22137 |
|
| 22138 |
if (TREE_CODE (decl) == FUNCTION_DECL) |
| 22139 |
smclass = "[DS]"; |
| 22140 |
else if (DECL_THREAD_LOCAL_P (decl)) |
| 22141 |
{ |
| 22142 |
if (bss_initializer_p (decl)) |
| 22143 |
smclass = "[UL]"; |
| 22144 |
else if (flag_data_sections) |
| 22145 |
smclass = "[TL]"; |
| 22146 |
} |
| 22147 |
else if (DECL_EXTERNAL (decl)) |
| 22148 |
smclass = "[UA]"; |
| 22149 |
else if (bss_initializer_p (decl)) |
| 22150 |
smclass = "[BS]"; |
| 22151 |
else if (flag_data_sections) |
| 22152 |
{ |
| 22153 |
/* This must exactly match the logic of select section. */ |
| 22154 |
if (decl_readonly_section (decl, compute_reloc_for_var (decl))) |
| 22155 |
smclass = "[RO]"; |
| 22156 |
else |
| 22157 |
smclass = "[RW]"; |
| 22158 |
} |
| 22159 |
|
| 22160 |
if (smclass != NULL) |
| 22161 |
{ |
| 22162 |
char *newname = XALLOCAVEC (char, strlen (symname) + 5); |
| 22163 |
|
| 22164 |
strcpy (newname, symname); |
| 22165 |
strcat (newname, smclass); |
| 22166 |
XSTR (symbol, 0) = ggc_strdup (newname); |
| 22167 |
} |
| 22168 |
} |
| 22169 |
} |
| 22170 |
#endif /* HAVE_AS_TLS */ |
| 22171 |
#endif /* TARGET_XCOFF */ |
| 22172 |
|
| 22173 |
void |
| 22174 |
rs6000_asm_weaken_decl (FILE *stream, tree decl, |
| 22175 |
const char *name, const char *val) |
| 22176 |
{ |
| 22177 |
fputs ("\t.weak\t", stream); |
| 22178 |
assemble_name (stream, name); |
| 22179 |
if (decl && TREE_CODE (decl) == FUNCTION_DECL |
| 22180 |
&& DEFAULT_ABI == ABI_AIX && DOT_SYMBOLS) |
| 22181 |
{ |
| 22182 |
#if TARGET_XCOFF && HAVE_GAS_HIDDEN |
| 22183 |
if (TARGET_XCOFF) |
| 22184 |
fputs (rs6000_xcoff_visibility (decl), stream); |
| 22185 |
#endif |
| 22186 |
fputs ("\n\t.weak\t.", stream); |
| 22187 |
RS6000_OUTPUT_BASENAME (stream, name); |
| 22188 |
} |
| 22189 |
#if TARGET_XCOFF && HAVE_GAS_HIDDEN |
| 22190 |
if (TARGET_XCOFF) |
| 22191 |
fputs (rs6000_xcoff_visibility (decl), stream); |
| 22192 |
#endif |
| 22193 |
fputc ('\n', stream); |
| 22194 |
|
| 22195 |
if (val) |
| 22196 |
{ |
| 22197 |
#ifdef ASM_OUTPUT_DEF |
| 22198 |
ASM_OUTPUT_DEF (stream, name, val); |
| 22199 |
#endif |
| 22200 |
if (decl && TREE_CODE (decl) == FUNCTION_DECL |
| 22201 |
&& DEFAULT_ABI == ABI_AIX && DOT_SYMBOLS) |
| 22202 |
{ |
| 22203 |
fputs ("\t.set\t.", stream); |
| 22204 |
RS6000_OUTPUT_BASENAME (stream, name); |
| 22205 |
fputs (",.", stream); |
| 22206 |
RS6000_OUTPUT_BASENAME (stream, val); |
| 22207 |
fputc ('\n', stream); |
| 22208 |
} |
| 22209 |
} |
| 22210 |
} |
| 22211 |
|
| 22212 |
|
| 22213 |
/* Return true if INSN should not be copied. */ |
| 22214 |
|
| 22215 |
static bool |
| 22216 |
rs6000_cannot_copy_insn_p (rtx_insn *insn) |
| 22217 |
{ |
| 22218 |
return recog_memoized (insn) >= 0 |
| 22219 |
&& get_attr_cannot_copy (insn); |
| 22220 |
} |
| 22221 |
|
| 22222 |
/* Compute a (partial) cost for rtx X. Return true if the complete |
| 22223 |
cost has been computed, and false if subexpressions should be |
| 22224 |
scanned. In either case, *TOTAL contains the cost result. */ |
| 22225 |
|
| 22226 |
static bool |
| 22227 |
rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, |
| 22228 |
int opno ATTRIBUTE_UNUSED, int *total, bool speed) |
| 22229 |
{ |
| 22230 |
int code = GET_CODE (x); |
| 22231 |
|
| 22232 |
switch (code) |
| 22233 |
{ |
| 22234 |
/* On the RS/6000, if it is valid in the insn, it is free. */ |
| 22235 |
case CONST_INT: |
| 22236 |
if (((outer_code == SET |
| 22237 |
|| outer_code == PLUS |
| 22238 |
|| outer_code == MINUS) |
| 22239 |
&& (satisfies_constraint_I (x) |
| 22240 |
|| satisfies_constraint_L (x))) |
| 22241 |
|| (outer_code == AND |
| 22242 |
&& (satisfies_constraint_K (x) |
| 22243 |
|| (mode == SImode |
| 22244 |
? satisfies_constraint_L (x) |
| 22245 |
: satisfies_constraint_J (x)))) |
| 22246 |
|| ((outer_code == IOR || outer_code == XOR) |
| 22247 |
&& (satisfies_constraint_K (x) |
| 22248 |
|| (mode == SImode |
| 22249 |
? satisfies_constraint_L (x) |
| 22250 |
: satisfies_constraint_J (x)))) |
| 22251 |
|| outer_code == ASHIFT |
| 22252 |
|| outer_code == ASHIFTRT |
| 22253 |
|| outer_code == LSHIFTRT |
| 22254 |
|| outer_code == ROTATE |
| 22255 |
|| outer_code == ROTATERT |
| 22256 |
|| outer_code == ZERO_EXTRACT |
| 22257 |
|| (outer_code == MULT |
| 22258 |
&& satisfies_constraint_I (x)) |
| 22259 |
|| ((outer_code == DIV || outer_code == UDIV |
| 22260 |
|| outer_code == MOD || outer_code == UMOD) |
| 22261 |
&& exact_log2 (INTVAL (x)) >= 0) |
| 22262 |
|| (outer_code == COMPARE |
| 22263 |
&& (satisfies_constraint_I (x) |
| 22264 |
|| satisfies_constraint_K (x))) |
| 22265 |
|| ((outer_code == EQ || outer_code == NE) |
| 22266 |
&& (satisfies_constraint_I (x) |
| 22267 |
|| satisfies_constraint_K (x) |
| 22268 |
|| (mode == SImode |
| 22269 |
? satisfies_constraint_L (x) |
| 22270 |
: satisfies_constraint_J (x)))) |
| 22271 |
|| (outer_code == GTU |
| 22272 |
&& satisfies_constraint_I (x)) |
| 22273 |
|| (outer_code == LTU |
| 22274 |
&& satisfies_constraint_P (x))) |
| 22275 |
{ |
| 22276 |
*total = 0; |
| 22277 |
return true; |
| 22278 |
} |
| 22279 |
else if ((outer_code == PLUS |
| 22280 |
&& reg_or_add_cint_operand (x, mode)) |
| 22281 |
|| (outer_code == MINUS |
| 22282 |
&& reg_or_sub_cint_operand (x, mode)) |
| 22283 |
|| ((outer_code == SET |
| 22284 |
|| outer_code == IOR |
| 22285 |
|| outer_code == XOR) |
| 22286 |
&& (INTVAL (x) |
| 22287 |
& ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0)) |
| 22288 |
{ |
| 22289 |
*total = COSTS_N_INSNS (1); |
| 22290 |
return true; |
| 22291 |
} |
| 22292 |
/* FALLTHRU */ |
| 22293 |
|
| 22294 |
case CONST_DOUBLE: |
| 22295 |
case CONST_WIDE_INT: |
| 22296 |
case CONST: |
| 22297 |
case HIGH: |
| 22298 |
case SYMBOL_REF: |
| 22299 |
*total = !speed ? COSTS_N_INSNS (1) + 1 : COSTS_N_INSNS (2); |
| 22300 |
return true; |
| 22301 |
|
| 22302 |
case MEM: |
| 22303 |
/* When optimizing for size, MEM should be slightly more expensive |
| 22304 |
than generating address, e.g., (plus (reg) (const)). |
| 22305 |
L1 cache latency is about two instructions. */ |
| 22306 |
*total = !speed ? COSTS_N_INSNS (1) + 1 : COSTS_N_INSNS (2); |
| 22307 |
if (rs6000_slow_unaligned_access (mode, MEM_ALIGN (x))) |
| 22308 |
*total += COSTS_N_INSNS (100); |
| 22309 |
return true; |
| 22310 |
|
| 22311 |
case LABEL_REF: |
| 22312 |
*total = 0; |
| 22313 |
return true; |
| 22314 |
|
| 22315 |
case PLUS: |
| 22316 |
case MINUS: |
| 22317 |
if (FLOAT_MODE_P (mode)) |
| 22318 |
*total = rs6000_cost->fp; |
| 22319 |
else |
| 22320 |
*total = COSTS_N_INSNS (1); |
| 22321 |
return false; |
| 22322 |
|
| 22323 |
case MULT: |
| 22324 |
if (CONST_INT_P (XEXP (x, 1)) |
| 22325 |
&& satisfies_constraint_I (XEXP (x, 1))) |
| 22326 |
{ |
| 22327 |
if (INTVAL (XEXP (x, 1)) >= -256 |
| 22328 |
&& INTVAL (XEXP (x, 1)) <= 255) |
| 22329 |
*total = rs6000_cost->mulsi_const9; |
| 22330 |
else |
| 22331 |
*total = rs6000_cost->mulsi_const; |
| 22332 |
} |
| 22333 |
else if (mode == SFmode) |
| 22334 |
*total = rs6000_cost->fp; |
| 22335 |
else if (FLOAT_MODE_P (mode)) |
| 22336 |
*total = rs6000_cost->dmul; |
| 22337 |
else if (mode == DImode) |
| 22338 |
*total = rs6000_cost->muldi; |
| 22339 |
else |
| 22340 |
*total = rs6000_cost->mulsi; |
| 22341 |
return false; |
| 22342 |
|
| 22343 |
case FMA: |
| 22344 |
if (mode == SFmode) |
| 22345 |
*total = rs6000_cost->fp; |
| 22346 |
else |
| 22347 |
*total = rs6000_cost->dmul; |
| 22348 |
break; |
| 22349 |
|
| 22350 |
case DIV: |
| 22351 |
case MOD: |
| 22352 |
if (FLOAT_MODE_P (mode)) |
| 22353 |
{ |
| 22354 |
*total = mode == DFmode ? rs6000_cost->ddiv |
| 22355 |
: rs6000_cost->sdiv; |
| 22356 |
return false; |
| 22357 |
} |
| 22358 |
/* FALLTHRU */ |
| 22359 |
|
| 22360 |
case UDIV: |
| 22361 |
case UMOD: |
| 22362 |
if (CONST_INT_P (XEXP (x, 1)) |
| 22363 |
&& exact_log2 (INTVAL (XEXP (x, 1))) >= 0) |
| 22364 |
{ |
| 22365 |
if (code == DIV || code == MOD) |
| 22366 |
/* Shift, addze */ |
| 22367 |
*total = COSTS_N_INSNS (2); |
| 22368 |
else |
| 22369 |
/* Shift */ |
| 22370 |
*total = COSTS_N_INSNS (1); |
| 22371 |
} |
| 22372 |
else |
| 22373 |
{ |
| 22374 |
if (GET_MODE (XEXP (x, 1)) == DImode) |
| 22375 |
*total = rs6000_cost->divdi; |
| 22376 |
else |
| 22377 |
*total = rs6000_cost->divsi; |
| 22378 |
} |
| 22379 |
/* Add in shift and subtract for MOD unless we have a mod instruction. */ |
| 22380 |
if ((!TARGET_MODULO |
| 22381 |
|| (RS6000_DISABLE_SCALAR_MODULO && SCALAR_INT_MODE_P (mode))) |
| 22382 |
&& (code == MOD || code == UMOD)) |
| 22383 |
*total += COSTS_N_INSNS (2); |
| 22384 |
return false; |
| 22385 |
|
| 22386 |
case CTZ: |
| 22387 |
*total = COSTS_N_INSNS (TARGET_CTZ ? 1 : 4); |
| 22388 |
return false; |
| 22389 |
|
| 22390 |
case FFS: |
| 22391 |
*total = COSTS_N_INSNS (4); |
| 22392 |
return false; |
| 22393 |
|
| 22394 |
case POPCOUNT: |
| 22395 |
*total = COSTS_N_INSNS (TARGET_POPCNTD ? 1 : 6); |
| 22396 |
return false; |
| 22397 |
|
| 22398 |
case PARITY: |
| 22399 |
*total = COSTS_N_INSNS (TARGET_CMPB ? 2 : 6); |
| 22400 |
return false; |
| 22401 |
|
| 22402 |
case NOT: |
| 22403 |
if (outer_code == AND || outer_code == IOR || outer_code == XOR) |
| 22404 |
*total = 0; |
| 22405 |
else |
| 22406 |
*total = COSTS_N_INSNS (1); |
| 22407 |
return false; |
| 22408 |
|
| 22409 |
case AND: |
| 22410 |
if (CONST_INT_P (XEXP (x, 1))) |
| 22411 |
{ |
| 22412 |
rtx left = XEXP (x, 0); |
| 22413 |
rtx_code left_code = GET_CODE (left); |
| 22414 |
|
| 22415 |
/* rotate-and-mask: 1 insn. */ |
| 22416 |
if ((left_code == ROTATE |
| 22417 |
|| left_code == ASHIFT |
| 22418 |
|| left_code == LSHIFTRT) |
| 22419 |
&& rs6000_is_valid_shift_mask (XEXP (x, 1), left, mode)) |
| 22420 |
{ |
| 22421 |
*total = rtx_cost (XEXP (left, 0), mode, left_code, 0, speed); |
| 22422 |
if (!CONST_INT_P (XEXP (left, 1))) |
| 22423 |
*total += rtx_cost (XEXP (left, 1), SImode, left_code, 1, speed); |
| 22424 |
*total += COSTS_N_INSNS (1); |
| 22425 |
return true; |
| 22426 |
} |
| 22427 |
|
| 22428 |
/* rotate-and-mask (no rotate), andi., andis.: 1 insn. */ |
| 22429 |
HOST_WIDE_INT val = INTVAL (XEXP (x, 1)); |
| 22430 |
if (rs6000_is_valid_and_mask (XEXP (x, 1), mode) |
| 22431 |
|| (val & 0xffff) == val |
| 22432 |
|| (val & 0xffff0000) == val |
| 22433 |
|| ((val & 0xffff) == 0 && mode == SImode)) |
| 22434 |
{ |
| 22435 |
*total = rtx_cost (left, mode, AND, 0, speed); |
| 22436 |
*total += COSTS_N_INSNS (1); |
| 22437 |
return true; |
| 22438 |
} |
| 22439 |
|
| 22440 |
/* 2 insns. */ |
| 22441 |
if (rs6000_is_valid_2insn_and (XEXP (x, 1), mode)) |
| 22442 |
{ |
| 22443 |
*total = rtx_cost (left, mode, AND, 0, speed); |
| 22444 |
*total += COSTS_N_INSNS (2); |
| 22445 |
return true; |
| 22446 |
} |
| 22447 |
} |
| 22448 |
|
| 22449 |
*total = COSTS_N_INSNS (1); |
| 22450 |
return false; |
| 22451 |
|
| 22452 |
case IOR: |
| 22453 |
/* FIXME */ |
| 22454 |
*total = COSTS_N_INSNS (1); |
| 22455 |
return true; |
| 22456 |
|
| 22457 |
case CLZ: |
| 22458 |
case XOR: |
| 22459 |
case ZERO_EXTRACT: |
| 22460 |
*total = COSTS_N_INSNS (1); |
| 22461 |
return false; |
| 22462 |
|
| 22463 |
case ASHIFT: |
| 22464 |
/* The EXTSWSLI instruction is a combined instruction. Don't count both |
| 22465 |
the sign extend and shift separately within the insn. */ |
| 22466 |
if (TARGET_EXTSWSLI && mode == DImode |
| 22467 |
&& GET_CODE (XEXP (x, 0)) == SIGN_EXTEND |
| 22468 |
&& GET_MODE (XEXP (XEXP (x, 0), 0)) == SImode) |
| 22469 |
{ |
| 22470 |
*total = 0; |
| 22471 |
return false; |
| 22472 |
} |
| 22473 |
/* fall through */ |
| 22474 |
|
| 22475 |
case ASHIFTRT: |
| 22476 |
case LSHIFTRT: |
| 22477 |
case ROTATE: |
| 22478 |
case ROTATERT: |
| 22479 |
/* Handle mul_highpart. */ |
| 22480 |
if (outer_code == TRUNCATE |
| 22481 |
&& GET_CODE (XEXP (x, 0)) == MULT) |
| 22482 |
{ |
| 22483 |
if (mode == DImode) |
| 22484 |
*total = rs6000_cost->muldi; |
| 22485 |
else |
| 22486 |
*total = rs6000_cost->mulsi; |
| 22487 |
return true; |
| 22488 |
} |
| 22489 |
else if (outer_code == AND) |
| 22490 |
*total = 0; |
| 22491 |
else |
| 22492 |
*total = COSTS_N_INSNS (1); |
| 22493 |
return false; |
| 22494 |
|
| 22495 |
case SIGN_EXTEND: |
| 22496 |
case ZERO_EXTEND: |
| 22497 |
if (MEM_P (XEXP (x, 0))) |
| 22498 |
*total = 0; |
| 22499 |
else |
| 22500 |
*total = COSTS_N_INSNS (1); |
| 22501 |
return false; |
| 22502 |
|
| 22503 |
case COMPARE: |
| 22504 |
case NEG: |
| 22505 |
case ABS: |
| 22506 |
if (!FLOAT_MODE_P (mode)) |
| 22507 |
{ |
| 22508 |
*total = COSTS_N_INSNS (1); |
| 22509 |
return false; |
| 22510 |
} |
| 22511 |
/* FALLTHRU */ |
| 22512 |
|
| 22513 |
case FLOAT: |
| 22514 |
case UNSIGNED_FLOAT: |
| 22515 |
case FIX: |
| 22516 |
case UNSIGNED_FIX: |
| 22517 |
case FLOAT_TRUNCATE: |
| 22518 |
*total = rs6000_cost->fp; |
| 22519 |
return false; |
| 22520 |
|
| 22521 |
case FLOAT_EXTEND: |
| 22522 |
if (mode == DFmode) |
| 22523 |
*total = rs6000_cost->sfdf_convert; |
| 22524 |
else |
| 22525 |
*total = rs6000_cost->fp; |
| 22526 |
return false; |
| 22527 |
|
| 22528 |
case CALL: |
| 22529 |
case IF_THEN_ELSE: |
| 22530 |
if (!speed) |
| 22531 |
{ |
| 22532 |
*total = COSTS_N_INSNS (1); |
| 22533 |
return true; |
| 22534 |
} |
| 22535 |
else if (FLOAT_MODE_P (mode) && TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT) |
| 22536 |
{ |
| 22537 |
*total = rs6000_cost->fp; |
| 22538 |
return false; |
| 22539 |
} |
| 22540 |
break; |
| 22541 |
|
| 22542 |
case NE: |
| 22543 |
case EQ: |
| 22544 |
case GTU: |
| 22545 |
case LTU: |
| 22546 |
/* Carry bit requires mode == Pmode. |
| 22547 |
NEG or PLUS already counted so only add one. */ |
| 22548 |
if (mode == Pmode |
| 22549 |
&& (outer_code == NEG || outer_code == PLUS)) |
| 22550 |
{ |
| 22551 |
*total = COSTS_N_INSNS (1); |
| 22552 |
return true; |
| 22553 |
} |
| 22554 |
/* FALLTHRU */ |
| 22555 |
|
| 22556 |
case GT: |
| 22557 |
case LT: |
| 22558 |
case UNORDERED: |
| 22559 |
if (outer_code == SET) |
| 22560 |
{ |
| 22561 |
if (XEXP (x, 1) == const0_rtx) |
| 22562 |
{ |
| 22563 |
*total = COSTS_N_INSNS (2); |
| 22564 |
return true; |
| 22565 |
} |
| 22566 |
else |
| 22567 |
{ |
| 22568 |
*total = COSTS_N_INSNS (3); |
| 22569 |
return false; |
| 22570 |
} |
| 22571 |
} |
| 22572 |
/* CC COMPARE. */ |
| 22573 |
if (outer_code == COMPARE) |
| 22574 |
{ |
| 22575 |
*total = 0; |
| 22576 |
return true; |
| 22577 |
} |
| 22578 |
break; |
| 22579 |
|
| 22580 |
case UNSPEC: |
| 22581 |
if (XINT (x, 1) == UNSPECV_MMA_XXSETACCZ) |
| 22582 |
{ |
| 22583 |
*total = 0; |
| 22584 |
return true; |
| 22585 |
} |
| 22586 |
break; |
| 22587 |
|
| 22588 |
default: |
| 22589 |
break; |
| 22590 |
} |
| 22591 |
|
| 22592 |
return false; |
| 22593 |
} |
| 22594 |
|
| 22595 |
/* Debug form of r6000_rtx_costs that is selected if -mdebug=cost. */ |
| 22596 |
|
| 22597 |
static bool |
| 22598 |
rs6000_debug_rtx_costs (rtx x, machine_mode mode, int outer_code, |
| 22599 |
int opno, int *total, bool speed) |
| 22600 |
{ |
| 22601 |
bool ret = rs6000_rtx_costs (x, mode, outer_code, opno, total, speed); |
| 22602 |
|
| 22603 |
fprintf (stderr, |
| 22604 |
"\nrs6000_rtx_costs, return = %s, mode = %s, outer_code = %s, " |
| 22605 |
"opno = %d, total = %d, speed = %s, x:\n", |
| 22606 |
ret ? "complete" : "scan inner", |
| 22607 |
GET_MODE_NAME (mode), |
| 22608 |
GET_RTX_NAME (outer_code), |
| 22609 |
opno, |
| 22610 |
*total, |
| 22611 |
speed ? "true" : "false"); |
| 22612 |
|
| 22613 |
debug_rtx (x); |
| 22614 |
|
| 22615 |
return ret; |
| 22616 |
} |
| 22617 |
|
| 22618 |
static int |
| 22619 |
rs6000_insn_cost (rtx_insn *insn, bool speed) |
| 22620 |
{ |
| 22621 |
if (recog_memoized (insn) < 0) |
| 22622 |
return 0; |
| 22623 |
|
| 22624 |
/* If we are optimizing for size, just use the length. */ |
| 22625 |
if (!speed) |
| 22626 |
return get_attr_length (insn); |
| 22627 |
|
| 22628 |
/* Use the cost if provided. */ |
| 22629 |
int cost = get_attr_cost (insn); |
| 22630 |
if (cost > 0) |
| 22631 |
return cost; |
| 22632 |
|
| 22633 |
/* If the insn tells us how many insns there are, use that. Otherwise use |
| 22634 |
the length/4. Adjust the insn length to remove the extra size that |
| 22635 |
prefixed instructions take. */ |
| 22636 |
int n = get_attr_num_insns (insn); |
| 22637 |
if (n == 0) |
| 22638 |
{ |
| 22639 |
int length = get_attr_length (insn); |
| 22640 |
if (get_attr_prefixed (insn) == PREFIXED_YES) |
| 22641 |
{ |
| 22642 |
int adjust = 0; |
| 22643 |
ADJUST_INSN_LENGTH (insn, adjust); |
| 22644 |
length -= adjust; |
| 22645 |
} |
| 22646 |
|
| 22647 |
n = length / 4; |
| 22648 |
} |
| 22649 |
|
| 22650 |
enum attr_type type = get_attr_type (insn); |
| 22651 |
|
| 22652 |
switch (type) |
| 22653 |
{ |
| 22654 |
case TYPE_LOAD: |
| 22655 |
case TYPE_FPLOAD: |
| 22656 |
case TYPE_VECLOAD: |
| 22657 |
cost = COSTS_N_INSNS (n + 1); |
| 22658 |
break; |
| 22659 |
|
| 22660 |
case TYPE_MUL: |
| 22661 |
switch (get_attr_size (insn)) |
| 22662 |
{ |
| 22663 |
case SIZE_8: |
| 22664 |
cost = COSTS_N_INSNS (n - 1) + rs6000_cost->mulsi_const9; |
| 22665 |
break; |
| 22666 |
case SIZE_16: |
| 22667 |
cost = COSTS_N_INSNS (n - 1) + rs6000_cost->mulsi_const; |
| 22668 |
break; |
| 22669 |
case SIZE_32: |
| 22670 |
cost = COSTS_N_INSNS (n - 1) + rs6000_cost->mulsi; |
| 22671 |
break; |
| 22672 |
case SIZE_64: |
| 22673 |
cost = COSTS_N_INSNS (n - 1) + rs6000_cost->muldi; |
| 22674 |
break; |
| 22675 |
default: |
| 22676 |
gcc_unreachable (); |
| 22677 |
} |
| 22678 |
break; |
| 22679 |
case TYPE_DIV: |
| 22680 |
switch (get_attr_size (insn)) |
| 22681 |
{ |
| 22682 |
case SIZE_32: |
| 22683 |
cost = COSTS_N_INSNS (n - 1) + rs6000_cost->divsi; |
| 22684 |
break; |
| 22685 |
case SIZE_64: |
| 22686 |
cost = COSTS_N_INSNS (n - 1) + rs6000_cost->divdi; |
| 22687 |
break; |
| 22688 |
default: |
| 22689 |
gcc_unreachable (); |
| 22690 |
} |
| 22691 |
break; |
| 22692 |
|
| 22693 |
case TYPE_FP: |
| 22694 |
cost = n * rs6000_cost->fp; |
| 22695 |
break; |
| 22696 |
case TYPE_DMUL: |
| 22697 |
cost = n * rs6000_cost->dmul; |
| 22698 |
break; |
| 22699 |
case TYPE_SDIV: |
| 22700 |
cost = n * rs6000_cost->sdiv; |
| 22701 |
break; |
| 22702 |
case TYPE_DDIV: |
| 22703 |
cost = n * rs6000_cost->ddiv; |
| 22704 |
break; |
| 22705 |
|
| 22706 |
case TYPE_SYNC: |
| 22707 |
case TYPE_LOAD_L: |
| 22708 |
case TYPE_MFCR: |
| 22709 |
case TYPE_MFCRF: |
| 22710 |
cost = COSTS_N_INSNS (n + 2); |
| 22711 |
break; |
| 22712 |
|
| 22713 |
default: |
| 22714 |
cost = COSTS_N_INSNS (n); |
| 22715 |
} |
| 22716 |
|
| 22717 |
return cost; |
| 22718 |
} |
| 22719 |
|
| 22720 |
/* Debug form of ADDRESS_COST that is selected if -mdebug=cost. */ |
| 22721 |
|
| 22722 |
static int |
| 22723 |
rs6000_debug_address_cost (rtx x, machine_mode mode, |
| 22724 |
addr_space_t as, bool speed) |
| 22725 |
{ |
| 22726 |
int ret = TARGET_ADDRESS_COST (x, mode, as, speed); |
| 22727 |
|
| 22728 |
fprintf (stderr, "\nrs6000_address_cost, return = %d, speed = %s, x:\n", |
| 22729 |
ret, speed ? "true" : "false"); |
| 22730 |
debug_rtx (x); |
| 22731 |
|
| 22732 |
return ret; |
| 22733 |
} |
| 22734 |
|
| 22735 |
|
| 22736 |
/* A C expression returning the cost of moving data from a register of class |
| 22737 |
CLASS1 to one of CLASS2. */ |
| 22738 |
|
| 22739 |
static int |
| 22740 |
rs6000_register_move_cost (machine_mode mode, |
| 22741 |
reg_class_t from, reg_class_t to) |
| 22742 |
{ |
| 22743 |
int ret; |
| 22744 |
reg_class_t rclass; |
| 22745 |
|
| 22746 |
if (TARGET_DEBUG_COST) |
| 22747 |
dbg_cost_ctrl++; |
| 22748 |
|
| 22749 |
/* If we have VSX, we can easily move between FPR or Altivec registers, |
| 22750 |
otherwise we can only easily move within classes. |
| 22751 |
Do this first so we give best-case answers for union classes |
| 22752 |
containing both gprs and vsx regs. */ |
| 22753 |
HARD_REG_SET to_vsx, from_vsx; |
| 22754 |
to_vsx = reg_class_contents[to] & reg_class_contents[VSX_REGS]; |
| 22755 |
from_vsx = reg_class_contents[from] & reg_class_contents[VSX_REGS]; |
| 22756 |
if (!hard_reg_set_empty_p (to_vsx) |
| 22757 |
&& !hard_reg_set_empty_p (from_vsx) |
| 22758 |
&& (TARGET_VSX |
| 22759 |
|| hard_reg_set_intersect_p (to_vsx, from_vsx))) |
| 22760 |
{ |
| 22761 |
int reg = FIRST_FPR_REGNO; |
| 22762 |
if (TARGET_VSX |
| 22763 |
|| (TEST_HARD_REG_BIT (to_vsx, FIRST_ALTIVEC_REGNO) |
| 22764 |
&& TEST_HARD_REG_BIT (from_vsx, FIRST_ALTIVEC_REGNO))) |
| 22765 |
reg = FIRST_ALTIVEC_REGNO; |
| 22766 |
ret = 2 * hard_regno_nregs (reg, mode); |
| 22767 |
} |
| 22768 |
|
| 22769 |
/* Moves from/to GENERAL_REGS. */ |
| 22770 |
else if ((rclass = from, reg_classes_intersect_p (to, GENERAL_REGS)) |
| 22771 |
|| (rclass = to, reg_classes_intersect_p (from, GENERAL_REGS))) |
| 22772 |
{ |
| 22773 |
if (rclass == FLOAT_REGS || rclass == ALTIVEC_REGS || rclass == VSX_REGS) |
| 22774 |
{ |
| 22775 |
if (TARGET_DIRECT_MOVE) |
| 22776 |
{ |
| 22777 |
/* Keep the cost for direct moves above that for within |
| 22778 |
a register class even if the actual processor cost is |
| 22779 |
comparable. We do this because a direct move insn |
| 22780 |
can't be a nop, whereas with ideal register |
| 22781 |
allocation a move within the same class might turn |
| 22782 |
out to be a nop. */ |
| 22783 |
if (rs6000_tune == PROCESSOR_POWER9 |
| 22784 |
|| rs6000_tune == PROCESSOR_POWER10 |
| 22785 |
|| rs6000_tune == PROCESSOR_POWER11) |
| 22786 |
ret = 3 * hard_regno_nregs (FIRST_GPR_REGNO, mode); |
| 22787 |
else |
| 22788 |
ret = 4 * hard_regno_nregs (FIRST_GPR_REGNO, mode); |
| 22789 |
/* SFmode requires a conversion when moving between gprs |
| 22790 |
and vsx. */ |
| 22791 |
if (mode == SFmode) |
| 22792 |
ret += 2; |
| 22793 |
} |
| 22794 |
else |
| 22795 |
ret = (rs6000_memory_move_cost (mode, rclass, false) |
| 22796 |
+ rs6000_memory_move_cost (mode, GENERAL_REGS, false)); |
| 22797 |
} |
| 22798 |
|
| 22799 |
/* It's more expensive to move CR_REGS than CR0_REGS because of the |
| 22800 |
shift. */ |
| 22801 |
else if (rclass == CR_REGS) |
| 22802 |
ret = 4; |
| 22803 |
|
| 22804 |
/* For those processors that have slow LR/CTR moves, make them more |
| 22805 |
expensive than memory in order to bias spills to memory .*/ |
| 22806 |
else if ((rs6000_tune == PROCESSOR_POWER6 |
| 22807 |
|| rs6000_tune == PROCESSOR_POWER7 |
| 22808 |
|| rs6000_tune == PROCESSOR_POWER8 |
| 22809 |
|| rs6000_tune == PROCESSOR_POWER9) |
| 22810 |
&& reg_class_subset_p (rclass, SPECIAL_REGS)) |
| 22811 |
ret = 6 * hard_regno_nregs (FIRST_GPR_REGNO, mode); |
| 22812 |
|
| 22813 |
else |
| 22814 |
/* A move will cost one instruction per GPR moved. */ |
| 22815 |
ret = 2 * hard_regno_nregs (FIRST_GPR_REGNO, mode); |
| 22816 |
} |
| 22817 |
|
| 22818 |
/* Everything else has to go through GENERAL_REGS. */ |
| 22819 |
else |
| 22820 |
ret = (rs6000_register_move_cost (mode, GENERAL_REGS, to) |
| 22821 |
+ rs6000_register_move_cost (mode, from, GENERAL_REGS)); |
| 22822 |
|
| 22823 |
if (TARGET_DEBUG_COST) |
| 22824 |
{ |
| 22825 |
if (dbg_cost_ctrl == 1) |
| 22826 |
fprintf (stderr, |
| 22827 |
"rs6000_register_move_cost: ret=%d, mode=%s, from=%s, to=%s\n", |
| 22828 |
ret, GET_MODE_NAME (mode), reg_class_names[from], |
| 22829 |
reg_class_names[to]); |
| 22830 |
dbg_cost_ctrl--; |
| 22831 |
} |
| 22832 |
|
| 22833 |
return ret; |
| 22834 |
} |
| 22835 |
|
| 22836 |
/* A C expressions returning the cost of moving data of MODE from a register to |
| 22837 |
or from memory. */ |
| 22838 |
|
| 22839 |
static int |
| 22840 |
rs6000_memory_move_cost (machine_mode mode, reg_class_t rclass, |
| 22841 |
bool in ATTRIBUTE_UNUSED) |
| 22842 |
{ |
| 22843 |
int ret; |
| 22844 |
|
| 22845 |
if (TARGET_DEBUG_COST) |
| 22846 |
dbg_cost_ctrl++; |
| 22847 |
|
| 22848 |
if (reg_classes_intersect_p (rclass, GENERAL_REGS)) |
| 22849 |
ret = 4 * hard_regno_nregs (0, mode); |
| 22850 |
else if ((reg_classes_intersect_p (rclass, FLOAT_REGS) |
| 22851 |
|| reg_classes_intersect_p (rclass, VSX_REGS))) |
| 22852 |
ret = 4 * hard_regno_nregs (32, mode); |
| 22853 |
else if (reg_classes_intersect_p (rclass, ALTIVEC_REGS)) |
| 22854 |
ret = 4 * hard_regno_nregs (FIRST_ALTIVEC_REGNO, mode); |
| 22855 |
else |
| 22856 |
ret = 4 + rs6000_register_move_cost (mode, rclass, GENERAL_REGS); |
| 22857 |
|
| 22858 |
if (TARGET_DEBUG_COST) |
| 22859 |
{ |
| 22860 |
if (dbg_cost_ctrl == 1) |
| 22861 |
fprintf (stderr, |
| 22862 |
"rs6000_memory_move_cost: ret=%d, mode=%s, rclass=%s, in=%d\n", |
| 22863 |
ret, GET_MODE_NAME (mode), reg_class_names[rclass], in); |
| 22864 |
dbg_cost_ctrl--; |
| 22865 |
} |
| 22866 |
|
| 22867 |
return ret; |
| 22868 |
} |
| 22869 |
|
| 22870 |
/* Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS. |
| 22871 |
|
| 22872 |
The register allocator chooses GEN_OR_VSX_REGS for the allocno |
| 22873 |
class if GENERAL_REGS and VSX_REGS cost is lower than the memory |
| 22874 |
cost. This happens a lot when TARGET_DIRECT_MOVE makes the register |
| 22875 |
move cost between GENERAL_REGS and VSX_REGS low. |
| 22876 |
|
| 22877 |
It might seem reasonable to use a union class. After all, if usage |
| 22878 |
of vsr is low and gpr high, it might make sense to spill gpr to vsr |
| 22879 |
rather than memory. However, in cases where register pressure of |
| 22880 |
both is high, like the cactus_adm spec test, allowing |
| 22881 |
GEN_OR_VSX_REGS as the allocno class results in bad decisions in |
| 22882 |
the first scheduling pass. This is partly due to an allocno of |
| 22883 |
GEN_OR_VSX_REGS wrongly contributing to the GENERAL_REGS pressure |
| 22884 |
class, which gives too high a pressure for GENERAL_REGS and too low |
| 22885 |
for VSX_REGS. So, force a choice of the subclass here. |
| 22886 |
|
| 22887 |
The best class is also the union if GENERAL_REGS and VSX_REGS have |
| 22888 |
the same cost. In that case we do use GEN_OR_VSX_REGS as the |
| 22889 |
allocno class, since trying to narrow down the class by regno mode |
| 22890 |
is prone to error. For example, SImode is allowed in VSX regs and |
| 22891 |
in some cases (eg. gcc.target/powerpc/p9-xxbr-3.c do_bswap32_vect) |
| 22892 |
it would be wrong to choose an allocno of GENERAL_REGS based on |
| 22893 |
SImode. */ |
| 22894 |
|
| 22895 |
static reg_class_t |
| 22896 |
rs6000_ira_change_pseudo_allocno_class (int regno ATTRIBUTE_UNUSED, |
| 22897 |
reg_class_t allocno_class, |
| 22898 |
reg_class_t best_class) |
| 22899 |
{ |
| 22900 |
switch (allocno_class) |
| 22901 |
{ |
| 22902 |
case GEN_OR_VSX_REGS: |
| 22903 |
/* best_class must be a subset of allocno_class. */ |
| 22904 |
gcc_checking_assert (best_class == GEN_OR_VSX_REGS |
| 22905 |
|| best_class == GEN_OR_FLOAT_REGS |
| 22906 |
|| best_class == VSX_REGS |
| 22907 |
|| best_class == ALTIVEC_REGS |
| 22908 |
|| best_class == FLOAT_REGS |
| 22909 |
|| best_class == GENERAL_REGS |
| 22910 |
|| best_class == BASE_REGS); |
| 22911 |
/* Use best_class but choose wider classes when copying from the |
| 22912 |
wider class to best_class is cheap. This mimics IRA choice |
| 22913 |
of allocno class. */ |
| 22914 |
if (best_class == BASE_REGS) |
| 22915 |
return GENERAL_REGS; |
| 22916 |
if (TARGET_VSX && best_class == FLOAT_REGS) |
| 22917 |
return VSX_REGS; |
| 22918 |
return best_class; |
| 22919 |
|
| 22920 |
case VSX_REGS: |
| 22921 |
if (best_class == ALTIVEC_REGS) |
| 22922 |
return ALTIVEC_REGS; |
| 22923 |
|
| 22924 |
default: |
| 22925 |
break; |
| 22926 |
} |
| 22927 |
|
| 22928 |
return allocno_class; |
| 22929 |
} |
| 22930 |
|
| 22931 |
/* Load up a constant. If the mode is a vector mode, splat the value across |
| 22932 |
all of the vector elements. */ |
| 22933 |
|
| 22934 |
static rtx |
| 22935 |
rs6000_load_constant_and_splat (machine_mode mode, REAL_VALUE_TYPE dconst) |
| 22936 |
{ |
| 22937 |
rtx reg; |
| 22938 |
|
| 22939 |
if (mode == SFmode || mode == DFmode) |
| 22940 |
{ |
| 22941 |
rtx d = const_double_from_real_value (dconst, mode); |
| 22942 |
reg = force_reg (mode, d); |
| 22943 |
} |
| 22944 |
else if (mode == V4SFmode) |
| 22945 |
{ |
| 22946 |
rtx d = const_double_from_real_value (dconst, SFmode); |
| 22947 |
rtvec v = gen_rtvec (4, d, d, d, d); |
| 22948 |
reg = gen_reg_rtx (mode); |
| 22949 |
rs6000_expand_vector_init (reg, gen_rtx_PARALLEL (mode, v)); |
| 22950 |
} |
| 22951 |
else if (mode == V2DFmode) |
| 22952 |
{ |
| 22953 |
rtx d = const_double_from_real_value (dconst, DFmode); |
| 22954 |
rtvec v = gen_rtvec (2, d, d); |
| 22955 |
reg = gen_reg_rtx (mode); |
| 22956 |
rs6000_expand_vector_init (reg, gen_rtx_PARALLEL (mode, v)); |
| 22957 |
} |
| 22958 |
else |
| 22959 |
gcc_unreachable (); |
| 22960 |
|
| 22961 |
return reg; |
| 22962 |
} |
| 22963 |
|
| 22964 |
/* Generate an FMA instruction. */ |
| 22965 |
|
| 22966 |
static void |
| 22967 |
rs6000_emit_madd (rtx target, rtx m1, rtx m2, rtx a) |
| 22968 |
{ |
| 22969 |
machine_mode mode = GET_MODE (target); |
| 22970 |
rtx dst; |
| 22971 |
|
| 22972 |
dst = expand_ternary_op (mode, fma_optab, m1, m2, a, target, 0); |
| 22973 |
gcc_assert (dst != NULL); |
| 22974 |
|
| 22975 |
if (dst != target) |
| 22976 |
emit_move_insn (target, dst); |
| 22977 |
} |
| 22978 |
|
| 22979 |
/* Generate a FNMSUB instruction: dst = -fma(m1, m2, -a). */ |
| 22980 |
|
| 22981 |
static void |
| 22982 |
rs6000_emit_nmsub (rtx dst, rtx m1, rtx m2, rtx a) |
| 22983 |
{ |
| 22984 |
machine_mode mode = GET_MODE (dst); |
| 22985 |
rtx r; |
| 22986 |
|
| 22987 |
/* This is a tad more complicated, since the fnma_optab is for |
| 22988 |
a different expression: fma(-m1, m2, a), which is the same |
| 22989 |
thing except in the case of signed zeros. |
| 22990 |
|
| 22991 |
Fortunately we know that if FMA is supported that FNMSUB is |
| 22992 |
also supported in the ISA. Just expand it directly. */ |
| 22993 |
|
| 22994 |
gcc_assert (optab_handler (fma_optab, mode) != CODE_FOR_nothing); |
| 22995 |
|
| 22996 |
r = gen_rtx_NEG (mode, a); |
| 22997 |
r = gen_rtx_FMA (mode, m1, m2, r); |
| 22998 |
r = gen_rtx_NEG (mode, r); |
| 22999 |
emit_insn (gen_rtx_SET (dst, r)); |
| 23000 |
} |
| 23001 |
|
| 23002 |
/* Newton-Raphson approximation of floating point divide DST = N/D. If NOTE_P, |
| 23003 |
add a reg_note saying that this was a division. Support both scalar and |
| 23004 |
vector divide. Assumes no trapping math and finite arguments. */ |
| 23005 |
|
| 23006 |
void |
| 23007 |
rs6000_emit_swdiv (rtx dst, rtx n, rtx d, bool note_p) |
| 23008 |
{ |
| 23009 |
machine_mode mode = GET_MODE (dst); |
| 23010 |
rtx one, x0, e0, x1, xprev, eprev, xnext, enext, u, v; |
| 23011 |
int i; |
| 23012 |
|
| 23013 |
/* Low precision estimates guarantee 5 bits of accuracy. High |
| 23014 |
precision estimates guarantee 14 bits of accuracy. SFmode |
| 23015 |
requires 23 bits of accuracy. DFmode requires 52 bits of |
| 23016 |
accuracy. Each pass at least doubles the accuracy, leading |
| 23017 |
to the following. */ |
| 23018 |
int passes = (TARGET_RECIP_PRECISION) ? 1 : 3; |
| 23019 |
if (mode == DFmode || mode == V2DFmode) |
| 23020 |
passes++; |
| 23021 |
|
| 23022 |
enum insn_code code = optab_handler (smul_optab, mode); |
| 23023 |
insn_gen_fn gen_mul = GEN_FCN (code); |
| 23024 |
|
| 23025 |
gcc_assert (code != CODE_FOR_nothing); |
| 23026 |
|
| 23027 |
one = rs6000_load_constant_and_splat (mode, dconst1); |
| 23028 |
|
| 23029 |
/* x0 = 1./d estimate */ |
| 23030 |
x0 = gen_reg_rtx (mode); |
| 23031 |
emit_insn (gen_rtx_SET (x0, gen_rtx_UNSPEC (mode, gen_rtvec (1, d), |
| 23032 |
UNSPEC_FRES))); |
| 23033 |
|
| 23034 |
/* Each iteration but the last calculates x_(i+1) = x_i * (2 - d * x_i). */ |
| 23035 |
if (passes > 1) { |
| 23036 |
|
| 23037 |
/* e0 = 1. - d * x0 */ |
| 23038 |
e0 = gen_reg_rtx (mode); |
| 23039 |
rs6000_emit_nmsub (e0, d, x0, one); |
| 23040 |
|
| 23041 |
/* x1 = x0 + e0 * x0 */ |
| 23042 |
x1 = gen_reg_rtx (mode); |
| 23043 |
rs6000_emit_madd (x1, e0, x0, x0); |
| 23044 |
|
| 23045 |
for (i = 0, xprev = x1, eprev = e0; i < passes - 2; |
| 23046 |
++i, xprev = xnext, eprev = enext) { |
| 23047 |
|
| 23048 |
/* enext = eprev * eprev */ |
| 23049 |
enext = gen_reg_rtx (mode); |
| 23050 |
emit_insn (gen_mul (enext, eprev, eprev)); |
| 23051 |
|
| 23052 |
/* xnext = xprev + enext * xprev */ |
| 23053 |
xnext = gen_reg_rtx (mode); |
| 23054 |
rs6000_emit_madd (xnext, enext, xprev, xprev); |
| 23055 |
} |
| 23056 |
|
| 23057 |
} else |
| 23058 |
xprev = x0; |
| 23059 |
|
| 23060 |
/* The last iteration calculates x_(i+1) = n * x_i * (2 - d * x_i). */ |
| 23061 |
|
| 23062 |
/* u = n * xprev */ |
| 23063 |
u = gen_reg_rtx (mode); |
| 23064 |
emit_insn (gen_mul (u, n, xprev)); |
| 23065 |
|
| 23066 |
/* v = n - (d * u) */ |
| 23067 |
v = gen_reg_rtx (mode); |
| 23068 |
rs6000_emit_nmsub (v, d, u, n); |
| 23069 |
|
| 23070 |
/* dst = (v * xprev) + u */ |
| 23071 |
rs6000_emit_madd (dst, v, xprev, u); |
| 23072 |
|
| 23073 |
if (note_p) |
| 23074 |
add_reg_note (get_last_insn (), REG_EQUAL, gen_rtx_DIV (mode, n, d)); |
| 23075 |
} |
| 23076 |
|
| 23077 |
/* Goldschmidt's Algorithm for single/double-precision floating point |
| 23078 |
sqrt and rsqrt. Assumes no trapping math and finite arguments. */ |
| 23079 |
|
| 23080 |
void |
| 23081 |
rs6000_emit_swsqrt (rtx dst, rtx src, bool recip) |
| 23082 |
{ |
| 23083 |
machine_mode mode = GET_MODE (src); |
| 23084 |
rtx e = gen_reg_rtx (mode); |
| 23085 |
rtx g = gen_reg_rtx (mode); |
| 23086 |
rtx h = gen_reg_rtx (mode); |
| 23087 |
|
| 23088 |
/* Low precision estimates guarantee 5 bits of accuracy. High |
| 23089 |
precision estimates guarantee 14 bits of accuracy. SFmode |
| 23090 |
requires 23 bits of accuracy. DFmode requires 52 bits of |
| 23091 |
accuracy. Each pass at least doubles the accuracy, leading |
| 23092 |
to the following. */ |
| 23093 |
int passes = (TARGET_RECIP_PRECISION) ? 1 : 3; |
| 23094 |
if (mode == DFmode || mode == V2DFmode) |
| 23095 |
passes++; |
| 23096 |
|
| 23097 |
int i; |
| 23098 |
rtx mhalf; |
| 23099 |
enum insn_code code = optab_handler (smul_optab, mode); |
| 23100 |
insn_gen_fn gen_mul = GEN_FCN (code); |
| 23101 |
|
| 23102 |
gcc_assert (code != CODE_FOR_nothing); |
| 23103 |
|
| 23104 |
mhalf = rs6000_load_constant_and_splat (mode, dconsthalf); |
| 23105 |
|
| 23106 |
/* e = rsqrt estimate */ |
| 23107 |
emit_insn (gen_rtx_SET (e, gen_rtx_UNSPEC (mode, gen_rtvec (1, src), |
| 23108 |
UNSPEC_RSQRT))); |
| 23109 |
|
| 23110 |
/* If (src == 0.0) filter infinity to prevent NaN for sqrt(0.0). */ |
| 23111 |
if (!recip) |
| 23112 |
{ |
| 23113 |
rtx zero = force_reg (mode, CONST0_RTX (mode)); |
| 23114 |
|
| 23115 |
if (mode == SFmode) |
| 23116 |
{ |
| 23117 |
rtx target = emit_conditional_move (e, { GT, src, zero, mode }, |
| 23118 |
e, zero, mode, 0); |
| 23119 |
if (target != e) |
| 23120 |
emit_move_insn (e, target); |
| 23121 |
} |
| 23122 |
else |
| 23123 |
{ |
| 23124 |
rtx cond = gen_rtx_GT (VOIDmode, e, zero); |
| 23125 |
rs6000_emit_vector_cond_expr (e, e, zero, cond, src, zero); |
| 23126 |
} |
| 23127 |
} |
| 23128 |
|
| 23129 |
/* g = sqrt estimate. */ |
| 23130 |
emit_insn (gen_mul (g, e, src)); |
| 23131 |
/* h = 1/(2*sqrt) estimate. */ |
| 23132 |
emit_insn (gen_mul (h, e, mhalf)); |
| 23133 |
|
| 23134 |
if (recip) |
| 23135 |
{ |
| 23136 |
if (passes == 1) |
| 23137 |
{ |
| 23138 |
rtx t = gen_reg_rtx (mode); |
| 23139 |
rs6000_emit_nmsub (t, g, h, mhalf); |
| 23140 |
/* Apply correction directly to 1/rsqrt estimate. */ |
| 23141 |
rs6000_emit_madd (dst, e, t, e); |
| 23142 |
} |
| 23143 |
else |
| 23144 |
{ |
| 23145 |
for (i = 0; i < passes; i++) |
| 23146 |
{ |
| 23147 |
rtx t1 = gen_reg_rtx (mode); |
| 23148 |
rtx g1 = gen_reg_rtx (mode); |
| 23149 |
rtx h1 = gen_reg_rtx (mode); |
| 23150 |
|
| 23151 |
rs6000_emit_nmsub (t1, g, h, mhalf); |
| 23152 |
rs6000_emit_madd (g1, g, t1, g); |
| 23153 |
rs6000_emit_madd (h1, h, t1, h); |
| 23154 |
|
| 23155 |
g = g1; |
| 23156 |
h = h1; |
| 23157 |
} |
| 23158 |
/* Multiply by 2 for 1/rsqrt. */ |
| 23159 |
emit_insn (gen_add3_insn (dst, h, h)); |
| 23160 |
} |
| 23161 |
} |
| 23162 |
else |
| 23163 |
{ |
| 23164 |
rtx t = gen_reg_rtx (mode); |
| 23165 |
rs6000_emit_nmsub (t, g, h, mhalf); |
| 23166 |
rs6000_emit_madd (dst, g, t, g); |
| 23167 |
} |
| 23168 |
|
| 23169 |
return; |
| 23170 |
} |
| 23171 |
|
| 23172 |
/* Emit popcount intrinsic on TARGET_POPCNTB (Power5) and TARGET_POPCNTD |
| 23173 |
(Power7) targets. DST is the target, and SRC is the argument operand. */ |
| 23174 |
|
| 23175 |
void |
| 23176 |
rs6000_emit_popcount (rtx dst, rtx src) |
| 23177 |
{ |
| 23178 |
machine_mode mode = GET_MODE (dst); |
| 23179 |
rtx tmp1, tmp2; |
| 23180 |
|
| 23181 |
/* Use the PPC ISA 2.06 popcnt{w,d} instruction if we can. */ |
| 23182 |
if (TARGET_POPCNTD) |
| 23183 |
{ |
| 23184 |
if (mode == SImode) |
| 23185 |
emit_insn (gen_popcntdsi2 (dst, src)); |
| 23186 |
else |
| 23187 |
emit_insn (gen_popcntddi2 (dst, src)); |
| 23188 |
return; |
| 23189 |
} |
| 23190 |
|
| 23191 |
tmp1 = gen_reg_rtx (mode); |
| 23192 |
|
| 23193 |
if (mode == SImode) |
| 23194 |
{ |
| 23195 |
emit_insn (gen_popcntbsi2 (tmp1, src)); |
| 23196 |
tmp2 = expand_mult (SImode, tmp1, GEN_INT (0x01010101), |
| 23197 |
NULL_RTX, 0); |
| 23198 |
tmp2 = force_reg (SImode, tmp2); |
| 23199 |
emit_insn (gen_lshrsi3 (dst, tmp2, GEN_INT (24))); |
| 23200 |
} |
| 23201 |
else |
| 23202 |
{ |
| 23203 |
emit_insn (gen_popcntbdi2 (tmp1, src)); |
| 23204 |
tmp2 = expand_mult (DImode, tmp1, |
| 23205 |
GEN_INT ((HOST_WIDE_INT) |
| 23206 |
0x01010101 << 32 | 0x01010101), |
| 23207 |
NULL_RTX, 0); |
| 23208 |
tmp2 = force_reg (DImode, tmp2); |
| 23209 |
emit_insn (gen_lshrdi3 (dst, tmp2, GEN_INT (56))); |
| 23210 |
} |
| 23211 |
} |
| 23212 |
|
| 23213 |
|
| 23214 |
/* Emit parity intrinsic on TARGET_POPCNTB targets. DST is the |
| 23215 |
target, and SRC is the argument operand. */ |
| 23216 |
|
| 23217 |
void |
| 23218 |
rs6000_emit_parity (rtx dst, rtx src) |
| 23219 |
{ |
| 23220 |
machine_mode mode = GET_MODE (dst); |
| 23221 |
rtx tmp; |
| 23222 |
|
| 23223 |
tmp = gen_reg_rtx (mode); |
| 23224 |
|
| 23225 |
/* Use the PPC ISA 2.05 prtyw/prtyd instruction if we can. */ |
| 23226 |
if (TARGET_CMPB) |
| 23227 |
{ |
| 23228 |
if (mode == SImode) |
| 23229 |
{ |
| 23230 |
emit_insn (gen_popcntbsi2 (tmp, src)); |
| 23231 |
emit_insn (gen_paritysi2_cmpb (dst, tmp)); |
| 23232 |
} |
| 23233 |
else |
| 23234 |
{ |
| 23235 |
emit_insn (gen_popcntbdi2 (tmp, src)); |
| 23236 |
emit_insn (gen_paritydi2_cmpb (dst, tmp)); |
| 23237 |
} |
| 23238 |
return; |
| 23239 |
} |
| 23240 |
|
| 23241 |
if (mode == SImode) |
| 23242 |
{ |
| 23243 |
/* Is mult+shift >= shift+xor+shift+xor? */ |
| 23244 |
if (rs6000_cost->mulsi_const >= COSTS_N_INSNS (3)) |
| 23245 |
{ |
| 23246 |
rtx tmp1, tmp2, tmp3, tmp4; |
| 23247 |
|
| 23248 |
tmp1 = gen_reg_rtx (SImode); |
| 23249 |
emit_insn (gen_popcntbsi2 (tmp1, src)); |
| 23250 |
|
| 23251 |
tmp2 = gen_reg_rtx (SImode); |
| 23252 |
emit_insn (gen_lshrsi3 (tmp2, tmp1, GEN_INT (16))); |
| 23253 |
tmp3 = gen_reg_rtx (SImode); |
| 23254 |
emit_insn (gen_xorsi3 (tmp3, tmp1, tmp2)); |
| 23255 |
|
| 23256 |
tmp4 = gen_reg_rtx (SImode); |
| 23257 |
emit_insn (gen_lshrsi3 (tmp4, tmp3, GEN_INT (8))); |
| 23258 |
emit_insn (gen_xorsi3 (tmp, tmp3, tmp4)); |
| 23259 |
} |
| 23260 |
else |
| 23261 |
rs6000_emit_popcount (tmp, src); |
| 23262 |
emit_insn (gen_andsi3 (dst, tmp, const1_rtx)); |
| 23263 |
} |
| 23264 |
else |
| 23265 |
{ |
| 23266 |
/* Is mult+shift >= shift+xor+shift+xor+shift+xor? */ |
| 23267 |
if (rs6000_cost->muldi >= COSTS_N_INSNS (5)) |
| 23268 |
{ |
| 23269 |
rtx tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; |
| 23270 |
|
| 23271 |
tmp1 = gen_reg_rtx (DImode); |
| 23272 |
emit_insn (gen_popcntbdi2 (tmp1, src)); |
| 23273 |
|
| 23274 |
tmp2 = gen_reg_rtx (DImode); |
| 23275 |
emit_insn (gen_lshrdi3 (tmp2, tmp1, GEN_INT (32))); |
| 23276 |
tmp3 = gen_reg_rtx (DImode); |
| 23277 |
emit_insn (gen_xordi3 (tmp3, tmp1, tmp2)); |
| 23278 |
|
| 23279 |
tmp4 = gen_reg_rtx (DImode); |
| 23280 |
emit_insn (gen_lshrdi3 (tmp4, tmp3, GEN_INT (16))); |
| 23281 |
tmp5 = gen_reg_rtx (DImode); |
| 23282 |
emit_insn (gen_xordi3 (tmp5, tmp3, tmp4)); |
| 23283 |
|
| 23284 |
tmp6 = gen_reg_rtx (DImode); |
| 23285 |
emit_insn (gen_lshrdi3 (tmp6, tmp5, GEN_INT (8))); |
| 23286 |
emit_insn (gen_xordi3 (tmp, tmp5, tmp6)); |
| 23287 |
} |
| 23288 |
else |
| 23289 |
rs6000_emit_popcount (tmp, src); |
| 23290 |
emit_insn (gen_anddi3 (dst, tmp, const1_rtx)); |
| 23291 |
} |
| 23292 |
} |
| 23293 |
|
| 23294 |
/* Expand an Altivec constant permutation for little endian mode. |
| 23295 |
OP0 and OP1 are the input vectors and TARGET is the output vector. |
| 23296 |
SEL specifies the constant permutation vector. |
| 23297 |
|
| 23298 |
There are two issues: First, the two input operands must be |
| 23299 |
swapped so that together they form a double-wide array in LE |
| 23300 |
order. Second, the vperm instruction has surprising behavior |
| 23301 |
in LE mode: it interprets the elements of the source vectors |
| 23302 |
in BE mode ("left to right") and interprets the elements of |
| 23303 |
the destination vector in LE mode ("right to left"). To |
| 23304 |
correct for this, we must subtract each element of the permute |
| 23305 |
control vector from 31. |
| 23306 |
|
| 23307 |
For example, suppose we want to concatenate vr10 = {0, 1, 2, 3} |
| 23308 |
with vr11 = {4, 5, 6, 7} and extract {0, 2, 4, 6} using a vperm. |
| 23309 |
We place {0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27} in vr12 to |
| 23310 |
serve as the permute control vector. Then, in BE mode, |
| 23311 |
|
| 23312 |
vperm 9,10,11,12 |
| 23313 |
|
| 23314 |
places the desired result in vr9. However, in LE mode the |
| 23315 |
vector contents will be |
| 23316 |
|
| 23317 |
vr10 = 00000003 00000002 00000001 00000000 |
| 23318 |
vr11 = 00000007 00000006 00000005 00000004 |
| 23319 |
|
| 23320 |
The result of the vperm using the same permute control vector is |
| 23321 |
|
| 23322 |
vr9 = 05000000 07000000 01000000 03000000 |
| 23323 |
|
| 23324 |
That is, the leftmost 4 bytes of vr10 are interpreted as the |
| 23325 |
source for the rightmost 4 bytes of vr9, and so on. |
| 23326 |
|
| 23327 |
If we change the permute control vector to |
| 23328 |
|
| 23329 |
vr12 = {31,20,29,28,23,22,21,20,15,14,13,12,7,6,5,4} |
| 23330 |
|
| 23331 |
and issue |
| 23332 |
|
| 23333 |
vperm 9,11,10,12 |
| 23334 |
|
| 23335 |
we get the desired |
| 23336 |
|
| 23337 |
vr9 = 00000006 00000004 00000002 00000000. */ |
| 23338 |
|
| 23339 |
static void |
| 23340 |
altivec_expand_vec_perm_const_le (rtx target, rtx op0, rtx op1, |
| 23341 |
const vec_perm_indices &sel) |
| 23342 |
{ |
| 23343 |
unsigned int i; |
| 23344 |
rtx perm[16]; |
| 23345 |
rtx constv, unspec; |
| 23346 |
|
| 23347 |
/* Unpack and adjust the constant selector. */ |
| 23348 |
for (i = 0; i < 16; ++i) |
| 23349 |
{ |
| 23350 |
unsigned int elt = 31 - (sel[i] & 31); |
| 23351 |
perm[i] = GEN_INT (elt); |
| 23352 |
} |
| 23353 |
|
| 23354 |
/* Expand to a permute, swapping the inputs and using the |
| 23355 |
adjusted selector. */ |
| 23356 |
if (!REG_P (op0)) |
| 23357 |
op0 = force_reg (V16QImode, op0); |
| 23358 |
if (!REG_P (op1)) |
| 23359 |
op1 = force_reg (V16QImode, op1); |
| 23360 |
|
| 23361 |
constv = gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v (16, perm)); |
| 23362 |
constv = force_reg (V16QImode, constv); |
| 23363 |
unspec = gen_rtx_UNSPEC (V16QImode, gen_rtvec (3, op1, op0, constv), |
| 23364 |
UNSPEC_VPERM); |
| 23365 |
if (!REG_P (target)) |
| 23366 |
{ |
| 23367 |
rtx tmp = gen_reg_rtx (V16QImode); |
| 23368 |
emit_move_insn (tmp, unspec); |
| 23369 |
unspec = tmp; |
| 23370 |
} |
| 23371 |
|
| 23372 |
emit_move_insn (target, unspec); |
| 23373 |
} |
| 23374 |
|
| 23375 |
/* Similarly to altivec_expand_vec_perm_const_le, we must adjust the |
| 23376 |
permute control vector. But here it's not a constant, so we must |
| 23377 |
generate a vector NAND or NOR to do the adjustment. */ |
| 23378 |
|
| 23379 |
void |
| 23380 |
altivec_expand_vec_perm_le (rtx operands[4]) |
| 23381 |
{ |
| 23382 |
rtx notx, iorx, unspec; |
| 23383 |
rtx target = operands[0]; |
| 23384 |
rtx op0 = operands[1]; |
| 23385 |
rtx op1 = operands[2]; |
| 23386 |
rtx sel = operands[3]; |
| 23387 |
rtx tmp = target; |
| 23388 |
rtx norreg = gen_reg_rtx (V16QImode); |
| 23389 |
machine_mode mode = GET_MODE (target); |
| 23390 |
|
| 23391 |
/* Get everything in regs so the pattern matches. */ |
| 23392 |
if (!REG_P (op0)) |
| 23393 |
op0 = force_reg (mode, op0); |
| 23394 |
if (!REG_P (op1)) |
| 23395 |
op1 = force_reg (mode, op1); |
| 23396 |
if (!REG_P (sel)) |
| 23397 |
sel = force_reg (V16QImode, sel); |
| 23398 |
if (!REG_P (target)) |
| 23399 |
tmp = gen_reg_rtx (mode); |
| 23400 |
|
| 23401 |
if (TARGET_P9_VECTOR) |
| 23402 |
{ |
| 23403 |
unspec = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op0, sel), |
| 23404 |
UNSPEC_VPERMR); |
| 23405 |
} |
| 23406 |
else |
| 23407 |
{ |
| 23408 |
/* Invert the selector with a VNAND if available, else a VNOR. |
| 23409 |
The VNAND is preferred for future fusion opportunities. */ |
| 23410 |
notx = gen_rtx_NOT (V16QImode, sel); |
| 23411 |
iorx = (TARGET_P8_VECTOR |
| 23412 |
? gen_rtx_IOR (V16QImode, notx, notx) |
| 23413 |
: gen_rtx_AND (V16QImode, notx, notx)); |
| 23414 |
emit_insn (gen_rtx_SET (norreg, iorx)); |
| 23415 |
|
| 23416 |
/* Permute with operands reversed and adjusted selector. */ |
| 23417 |
unspec = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op0, norreg), |
| 23418 |
UNSPEC_VPERM); |
| 23419 |
} |
| 23420 |
|
| 23421 |
/* Copy into target, possibly by way of a register. */ |
| 23422 |
if (!REG_P (target)) |
| 23423 |
{ |
| 23424 |
emit_move_insn (tmp, unspec); |
| 23425 |
unspec = tmp; |
| 23426 |
} |
| 23427 |
|
| 23428 |
emit_move_insn (target, unspec); |
| 23429 |
} |
| 23430 |
|
| 23431 |
/* Expand an Altivec constant permutation. Return true if we match |
| 23432 |
an efficient implementation; false to fall back to VPERM. |
| 23433 |
|
| 23434 |
OP0 and OP1 are the input vectors and TARGET is the output vector. |
| 23435 |
SEL specifies the constant permutation vector. */ |
| 23436 |
|
| 23437 |
static bool |
| 23438 |
altivec_expand_vec_perm_const (rtx target, rtx op0, rtx op1, |
| 23439 |
const vec_perm_indices &sel) |
| 23440 |
{ |
| 23441 |
struct altivec_perm_insn { |
| 23442 |
HOST_WIDE_INT mask; |
| 23443 |
enum insn_code impl; |
| 23444 |
unsigned char perm[16]; |
| 23445 |
}; |
| 23446 |
static const struct altivec_perm_insn patterns[] = { |
| 23447 |
{OPTION_MASK_ALTIVEC, |
| 23448 |
CODE_FOR_altivec_vpkuhum_direct, |
| 23449 |
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}}, |
| 23450 |
{OPTION_MASK_ALTIVEC, |
| 23451 |
CODE_FOR_altivec_vpkuwum_direct, |
| 23452 |
{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}}, |
| 23453 |
{OPTION_MASK_ALTIVEC, |
| 23454 |
BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrghb_direct_be |
| 23455 |
: CODE_FOR_altivec_vmrglb_direct_le, |
| 23456 |
{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}, |
| 23457 |
{OPTION_MASK_ALTIVEC, |
| 23458 |
BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrghh_direct_be |
| 23459 |
: CODE_FOR_altivec_vmrglh_direct_le, |
| 23460 |
{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}}, |
| 23461 |
{OPTION_MASK_ALTIVEC, |
| 23462 |
BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrghw_direct_v4si_be |
| 23463 |
: CODE_FOR_altivec_vmrglw_direct_v4si_le, |
| 23464 |
{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}}, |
| 23465 |
{OPTION_MASK_ALTIVEC, |
| 23466 |
BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrglb_direct_be |
| 23467 |
: CODE_FOR_altivec_vmrghb_direct_le, |
| 23468 |
{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}}, |
| 23469 |
{OPTION_MASK_ALTIVEC, |
| 23470 |
BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrglh_direct_be |
| 23471 |
: CODE_FOR_altivec_vmrghh_direct_le, |
| 23472 |
{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}}, |
| 23473 |
{OPTION_MASK_ALTIVEC, |
| 23474 |
BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrglw_direct_v4si_be |
| 23475 |
: CODE_FOR_altivec_vmrghw_direct_v4si_le, |
| 23476 |
{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}}, |
| 23477 |
{OPTION_MASK_P8_VECTOR, |
| 23478 |
BYTES_BIG_ENDIAN ? CODE_FOR_p8_vmrgew_v4sf_direct |
| 23479 |
: CODE_FOR_p8_vmrgow_v4sf_direct, |
| 23480 |
{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}}, |
| 23481 |
{OPTION_MASK_P8_VECTOR, |
| 23482 |
BYTES_BIG_ENDIAN ? CODE_FOR_p8_vmrgow_v4sf_direct |
| 23483 |
: CODE_FOR_p8_vmrgew_v4sf_direct, |
| 23484 |
{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}}, |
| 23485 |
{OPTION_MASK_VSX, CODE_FOR_vsx_xxpermdi_v16qi, |
| 23486 |
{0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23}}, |
| 23487 |
{OPTION_MASK_VSX, CODE_FOR_vsx_xxpermdi_v16qi, |
| 23488 |
{8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}}, |
| 23489 |
{OPTION_MASK_VSX, CODE_FOR_vsx_xxpermdi_v16qi, |
| 23490 |
{0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31}}, |
| 23491 |
{OPTION_MASK_VSX, CODE_FOR_vsx_xxpermdi_v16qi, |
| 23492 |
{8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31}}}; |
| 23493 |
|
| 23494 |
unsigned int i, j, elt, which; |
| 23495 |
unsigned char perm[16]; |
| 23496 |
rtx x; |
| 23497 |
bool one_vec; |
| 23498 |
|
| 23499 |
/* Unpack the constant selector. */ |
| 23500 |
for (i = which = 0; i < 16; ++i) |
| 23501 |
{ |
| 23502 |
elt = sel[i] & 31; |
| 23503 |
which |= (elt < 16 ? 1 : 2); |
| 23504 |
perm[i] = elt; |
| 23505 |
} |
| 23506 |
|
| 23507 |
/* Simplify the constant selector based on operands. */ |
| 23508 |
switch (which) |
| 23509 |
{ |
| 23510 |
default: |
| 23511 |
gcc_unreachable (); |
| 23512 |
|
| 23513 |
case 3: |
| 23514 |
one_vec = false; |
| 23515 |
if (!rtx_equal_p (op0, op1)) |
| 23516 |
break; |
| 23517 |
/* FALLTHRU */ |
| 23518 |
|
| 23519 |
case 2: |
| 23520 |
for (i = 0; i < 16; ++i) |
| 23521 |
perm[i] &= 15; |
| 23522 |
op0 = op1; |
| 23523 |
one_vec = true; |
| 23524 |
break; |
| 23525 |
|
| 23526 |
case 1: |
| 23527 |
op1 = op0; |
| 23528 |
one_vec = true; |
| 23529 |
break; |
| 23530 |
} |
| 23531 |
|
| 23532 |
/* Look for splat patterns. */ |
| 23533 |
if (one_vec) |
| 23534 |
{ |
| 23535 |
elt = perm[0]; |
| 23536 |
|
| 23537 |
for (i = 0; i < 16; ++i) |
| 23538 |
if (perm[i] != elt) |
| 23539 |
break; |
| 23540 |
if (i == 16) |
| 23541 |
{ |
| 23542 |
if (!BYTES_BIG_ENDIAN) |
| 23543 |
elt = 15 - elt; |
| 23544 |
emit_insn (gen_altivec_vspltb_direct (target, op0, GEN_INT (elt))); |
| 23545 |
return true; |
| 23546 |
} |
| 23547 |
|
| 23548 |
if (elt % 2 == 0) |
| 23549 |
{ |
| 23550 |
for (i = 0; i < 16; i += 2) |
| 23551 |
if (perm[i] != elt || perm[i + 1] != elt + 1) |
| 23552 |
break; |
| 23553 |
if (i == 16) |
| 23554 |
{ |
| 23555 |
int field = BYTES_BIG_ENDIAN ? elt / 2 : 7 - elt / 2; |
| 23556 |
x = gen_reg_rtx (V8HImode); |
| 23557 |
emit_insn (gen_altivec_vsplth_direct (x, gen_lowpart (V8HImode, op0), |
| 23558 |
GEN_INT (field))); |
| 23559 |
emit_move_insn (target, gen_lowpart (V16QImode, x)); |
| 23560 |
return true; |
| 23561 |
} |
| 23562 |
} |
| 23563 |
|
| 23564 |
if (elt % 4 == 0) |
| 23565 |
{ |
| 23566 |
for (i = 0; i < 16; i += 4) |
| 23567 |
if (perm[i] != elt |
| 23568 |
|| perm[i + 1] != elt + 1 |
| 23569 |
|| perm[i + 2] != elt + 2 |
| 23570 |
|| perm[i + 3] != elt + 3) |
| 23571 |
break; |
| 23572 |
if (i == 16) |
| 23573 |
{ |
| 23574 |
int field = BYTES_BIG_ENDIAN ? elt / 4 : 3 - elt / 4; |
| 23575 |
x = gen_reg_rtx (V4SImode); |
| 23576 |
emit_insn (gen_altivec_vspltw_direct (x, gen_lowpart (V4SImode, op0), |
| 23577 |
GEN_INT (field))); |
| 23578 |
emit_move_insn (target, gen_lowpart (V16QImode, x)); |
| 23579 |
return true; |
| 23580 |
} |
| 23581 |
} |
| 23582 |
} |
| 23583 |
|
| 23584 |
/* Look for merge and pack patterns. */ |
| 23585 |
for (j = 0; j < ARRAY_SIZE (patterns); ++j) |
| 23586 |
{ |
| 23587 |
bool swapped; |
| 23588 |
|
| 23589 |
if ((patterns[j].mask & rs6000_isa_flags) == 0) |
| 23590 |
continue; |
| 23591 |
|
| 23592 |
elt = patterns[j].perm[0]; |
| 23593 |
if (perm[0] == elt) |
| 23594 |
swapped = false; |
| 23595 |
else if (perm[0] == elt + 16) |
| 23596 |
swapped = true; |
| 23597 |
else |
| 23598 |
continue; |
| 23599 |
for (i = 1; i < 16; ++i) |
| 23600 |
{ |
| 23601 |
elt = patterns[j].perm[i]; |
| 23602 |
if (swapped) |
| 23603 |
elt = (elt >= 16 ? elt - 16 : elt + 16); |
| 23604 |
else if (one_vec && elt >= 16) |
| 23605 |
elt -= 16; |
| 23606 |
if (perm[i] != elt) |
| 23607 |
break; |
| 23608 |
} |
| 23609 |
if (i == 16) |
| 23610 |
{ |
| 23611 |
enum insn_code icode = patterns[j].impl; |
| 23612 |
machine_mode omode = insn_data[icode].operand[0].mode; |
| 23613 |
machine_mode imode = insn_data[icode].operand[1].mode; |
| 23614 |
|
| 23615 |
rtx perm_idx = GEN_INT (0); |
| 23616 |
if (icode == CODE_FOR_vsx_xxpermdi_v16qi) |
| 23617 |
{ |
| 23618 |
int perm_val = 0; |
| 23619 |
if (one_vec) |
| 23620 |
{ |
| 23621 |
if (perm[0] == 8) |
| 23622 |
perm_val |= 2; |
| 23623 |
if (perm[8] == 8) |
| 23624 |
perm_val |= 1; |
| 23625 |
} |
| 23626 |
else |
| 23627 |
{ |
| 23628 |
if (perm[0] != 0) |
| 23629 |
perm_val |= 2; |
| 23630 |
if (perm[8] != 16) |
| 23631 |
perm_val |= 1; |
| 23632 |
} |
| 23633 |
perm_idx = GEN_INT (perm_val); |
| 23634 |
} |
| 23635 |
|
| 23636 |
/* For little-endian, don't use vpkuwum and vpkuhum if the |
| 23637 |
underlying vector type is not V4SI and V8HI, respectively. |
| 23638 |
For example, using vpkuwum with a V8HI picks up the even |
| 23639 |
halfwords (BE numbering) when the even halfwords (LE |
| 23640 |
numbering) are what we need. */ |
| 23641 |
if (!BYTES_BIG_ENDIAN |
| 23642 |
&& icode == CODE_FOR_altivec_vpkuwum_direct |
| 23643 |
&& ((REG_P (op0) |
| 23644 |
&& GET_MODE (op0) != V4SImode) |
| 23645 |
|| (SUBREG_P (op0) |
| 23646 |
&& GET_MODE (XEXP (op0, 0)) != V4SImode))) |
| 23647 |
continue; |
| 23648 |
if (!BYTES_BIG_ENDIAN |
| 23649 |
&& icode == CODE_FOR_altivec_vpkuhum_direct |
| 23650 |
&& ((REG_P (op0) |
| 23651 |
&& GET_MODE (op0) != V8HImode) |
| 23652 |
|| (SUBREG_P (op0) |
| 23653 |
&& GET_MODE (XEXP (op0, 0)) != V8HImode))) |
| 23654 |
continue; |
| 23655 |
|
| 23656 |
/* For little-endian, the two input operands must be swapped |
| 23657 |
(or swapped back) to ensure proper right-to-left numbering |
| 23658 |
from 0 to 2N-1. */ |
| 23659 |
if (swapped == BYTES_BIG_ENDIAN |
| 23660 |
&& icode != CODE_FOR_vsx_xxpermdi_v16qi) |
| 23661 |
std::swap (op0, op1); |
| 23662 |
if (imode != V16QImode) |
| 23663 |
{ |
| 23664 |
op0 = gen_lowpart (imode, op0); |
| 23665 |
op1 = gen_lowpart (imode, op1); |
| 23666 |
} |
| 23667 |
if (omode == V16QImode) |
| 23668 |
x = target; |
| 23669 |
else |
| 23670 |
x = gen_reg_rtx (omode); |
| 23671 |
if (icode == CODE_FOR_vsx_xxpermdi_v16qi) |
| 23672 |
emit_insn (GEN_FCN (icode) (x, op0, op1, perm_idx)); |
| 23673 |
else |
| 23674 |
emit_insn (GEN_FCN (icode) (x, op0, op1)); |
| 23675 |
if (omode != V16QImode) |
| 23676 |
emit_move_insn (target, gen_lowpart (V16QImode, x)); |
| 23677 |
return true; |
| 23678 |
} |
| 23679 |
} |
| 23680 |
|
| 23681 |
if (!BYTES_BIG_ENDIAN) |
| 23682 |
{ |
| 23683 |
altivec_expand_vec_perm_const_le (target, op0, op1, sel); |
| 23684 |
return true; |
| 23685 |
} |
| 23686 |
|
| 23687 |
return false; |
| 23688 |
} |
| 23689 |
|
| 23690 |
/* Expand a VSX Permute Doubleword constant permutation. |
| 23691 |
Return true if we match an efficient implementation. */ |
| 23692 |
|
| 23693 |
static bool |
| 23694 |
rs6000_expand_vec_perm_const_1 (rtx target, rtx op0, rtx op1, |
| 23695 |
unsigned char perm0, unsigned char perm1) |
| 23696 |
{ |
| 23697 |
rtx x; |
| 23698 |
|
| 23699 |
/* If both selectors come from the same operand, fold to single op. */ |
| 23700 |
if ((perm0 & 2) == (perm1 & 2)) |
| 23701 |
{ |
| 23702 |
if (perm0 & 2) |
| 23703 |
op0 = op1; |
| 23704 |
else |
| 23705 |
op1 = op0; |
| 23706 |
} |
| 23707 |
/* If both operands are equal, fold to simpler permutation. */ |
| 23708 |
if (rtx_equal_p (op0, op1)) |
| 23709 |
{ |
| 23710 |
perm0 = perm0 & 1; |
| 23711 |
perm1 = (perm1 & 1) + 2; |
| 23712 |
} |
| 23713 |
/* If the first selector comes from the second operand, swap. */ |
| 23714 |
else if (perm0 & 2) |
| 23715 |
{ |
| 23716 |
if (perm1 & 2) |
| 23717 |
return false; |
| 23718 |
perm0 -= 2; |
| 23719 |
perm1 += 2; |
| 23720 |
std::swap (op0, op1); |
| 23721 |
} |
| 23722 |
/* If the second selector does not come from the second operand, fail. */ |
| 23723 |
else if ((perm1 & 2) == 0) |
| 23724 |
return false; |
| 23725 |
|
| 23726 |
/* Success! */ |
| 23727 |
if (target != NULL) |
| 23728 |
{ |
| 23729 |
machine_mode vmode, dmode; |
| 23730 |
rtvec v; |
| 23731 |
|
| 23732 |
vmode = GET_MODE (target); |
| 23733 |
gcc_assert (GET_MODE_NUNITS (vmode) == 2); |
| 23734 |
dmode = mode_for_vector (GET_MODE_INNER (vmode), 4).require (); |
| 23735 |
x = gen_rtx_VEC_CONCAT (dmode, op0, op1); |
| 23736 |
v = gen_rtvec (2, GEN_INT (perm0), GEN_INT (perm1)); |
| 23737 |
x = gen_rtx_VEC_SELECT (vmode, x, gen_rtx_PARALLEL (VOIDmode, v)); |
| 23738 |
emit_insn (gen_rtx_SET (target, x)); |
| 23739 |
} |
| 23740 |
return true; |
| 23741 |
} |
| 23742 |
|
| 23743 |
/* Implement TARGET_VECTORIZE_VEC_PERM_CONST. */ |
| 23744 |
|
| 23745 |
static bool |
| 23746 |
rs6000_vectorize_vec_perm_const (machine_mode vmode, machine_mode op_mode, |
| 23747 |
rtx target, rtx op0, rtx op1, |
| 23748 |
const vec_perm_indices &sel) |
| 23749 |
{ |
| 23750 |
if (vmode != op_mode) |
| 23751 |
return false; |
| 23752 |
|
| 23753 |
bool testing_p = !target; |
| 23754 |
|
| 23755 |
/* AltiVec (and thus VSX) can handle arbitrary permutations. */ |
| 23756 |
if (TARGET_ALTIVEC && testing_p) |
| 23757 |
return true; |
| 23758 |
|
| 23759 |
if (op0) |
| 23760 |
{ |
| 23761 |
rtx nop0 = force_reg (vmode, op0); |
| 23762 |
if (op0 == op1) |
| 23763 |
op1 = nop0; |
| 23764 |
op0 = nop0; |
| 23765 |
} |
| 23766 |
if (op1) |
| 23767 |
op1 = force_reg (vmode, op1); |
| 23768 |
|
| 23769 |
/* Check for ps_merge* or xxpermdi insns. */ |
| 23770 |
if ((vmode == V2DFmode || vmode == V2DImode) && VECTOR_MEM_VSX_P (vmode)) |
| 23771 |
{ |
| 23772 |
if (testing_p) |
| 23773 |
{ |
| 23774 |
op0 = gen_raw_REG (vmode, LAST_VIRTUAL_REGISTER + 1); |
| 23775 |
op1 = gen_raw_REG (vmode, LAST_VIRTUAL_REGISTER + 2); |
| 23776 |
} |
| 23777 |
if (rs6000_expand_vec_perm_const_1 (target, op0, op1, sel[0], sel[1])) |
| 23778 |
return true; |
| 23779 |
} |
| 23780 |
|
| 23781 |
if (TARGET_ALTIVEC) |
| 23782 |
{ |
| 23783 |
/* Force the target-independent code to lower to V16QImode. */ |
| 23784 |
if (vmode != V16QImode) |
| 23785 |
return false; |
| 23786 |
if (altivec_expand_vec_perm_const (target, op0, op1, sel)) |
| 23787 |
return true; |
| 23788 |
} |
| 23789 |
|
| 23790 |
return false; |
| 23791 |
} |
| 23792 |
|
| 23793 |
/* A subroutine for rs6000_expand_extract_even & rs6000_expand_interleave. |
| 23794 |
OP0 and OP1 are the input vectors and TARGET is the output vector. |
| 23795 |
PERM specifies the constant permutation vector. */ |
| 23796 |
|
| 23797 |
static void |
| 23798 |
rs6000_do_expand_vec_perm (rtx target, rtx op0, rtx op1, |
| 23799 |
machine_mode vmode, const vec_perm_builder &perm) |
| 23800 |
{ |
| 23801 |
rtx x = expand_vec_perm_const (vmode, op0, op1, perm, BLKmode, target); |
| 23802 |
if (x != target) |
| 23803 |
emit_move_insn (target, x); |
| 23804 |
} |
| 23805 |
|
| 23806 |
/* Expand an extract even operation. */ |
| 23807 |
|
| 23808 |
void |
| 23809 |
rs6000_expand_extract_even (rtx target, rtx op0, rtx op1) |
| 23810 |
{ |
| 23811 |
machine_mode vmode = GET_MODE (target); |
| 23812 |
unsigned i, nelt = GET_MODE_NUNITS (vmode); |
| 23813 |
vec_perm_builder perm (nelt, nelt, 1); |
| 23814 |
|
| 23815 |
for (i = 0; i < nelt; i++) |
| 23816 |
perm.quick_push (i * 2); |
| 23817 |
|
| 23818 |
rs6000_do_expand_vec_perm (target, op0, op1, vmode, perm); |
| 23819 |
} |
| 23820 |
|
| 23821 |
/* Expand a vector interleave operation. */ |
| 23822 |
|
| 23823 |
void |
| 23824 |
rs6000_expand_interleave (rtx target, rtx op0, rtx op1, bool highp) |
| 23825 |
{ |
| 23826 |
machine_mode vmode = GET_MODE (target); |
| 23827 |
unsigned i, high, nelt = GET_MODE_NUNITS (vmode); |
| 23828 |
vec_perm_builder perm (nelt, nelt, 1); |
| 23829 |
|
| 23830 |
high = (highp ? 0 : nelt / 2); |
| 23831 |
for (i = 0; i < nelt / 2; i++) |
| 23832 |
{ |
| 23833 |
perm.quick_push (i + high); |
| 23834 |
perm.quick_push (i + nelt + high); |
| 23835 |
} |
| 23836 |
|
| 23837 |
rs6000_do_expand_vec_perm (target, op0, op1, vmode, perm); |
| 23838 |
} |
| 23839 |
|
| 23840 |
/* Scale a V2DF vector SRC by two to the SCALE and place in TGT. */ |
| 23841 |
void |
| 23842 |
rs6000_scale_v2df (rtx tgt, rtx src, int scale) |
| 23843 |
{ |
| 23844 |
HOST_WIDE_INT hwi_scale (scale); |
| 23845 |
REAL_VALUE_TYPE r_pow; |
| 23846 |
rtvec v = rtvec_alloc (2); |
| 23847 |
rtx elt; |
| 23848 |
rtx scale_vec = gen_reg_rtx (V2DFmode); |
| 23849 |
(void)real_powi (&r_pow, DFmode, &dconst2, hwi_scale); |
| 23850 |
elt = const_double_from_real_value (r_pow, DFmode); |
| 23851 |
RTVEC_ELT (v, 0) = elt; |
| 23852 |
RTVEC_ELT (v, 1) = elt; |
| 23853 |
rs6000_expand_vector_init (scale_vec, gen_rtx_PARALLEL (V2DFmode, v)); |
| 23854 |
emit_insn (gen_mulv2df3 (tgt, src, scale_vec)); |
| 23855 |
} |
| 23856 |
|
| 23857 |
/* Return an RTX representing where to find the function value of a |
| 23858 |
function returning MODE. */ |
| 23859 |
static rtx |
| 23860 |
rs6000_complex_function_value (machine_mode mode) |
| 23861 |
{ |
| 23862 |
unsigned int regno; |
| 23863 |
rtx r1, r2; |
| 23864 |
machine_mode inner = GET_MODE_INNER (mode); |
| 23865 |
unsigned int inner_bytes = GET_MODE_UNIT_SIZE (mode); |
| 23866 |
|
| 23867 |
if (TARGET_FLOAT128_TYPE |
| 23868 |
&& (mode == KCmode |
| 23869 |
|| (mode == TCmode && TARGET_IEEEQUAD))) |
| 23870 |
regno = ALTIVEC_ARG_RETURN; |
| 23871 |
|
| 23872 |
else if (FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT) |
| 23873 |
regno = FP_ARG_RETURN; |
| 23874 |
|
| 23875 |
else |
| 23876 |
{ |
| 23877 |
regno = GP_ARG_RETURN; |
| 23878 |
|
| 23879 |
/* 32-bit is OK since it'll go in r3/r4. */ |
| 23880 |
if (TARGET_32BIT && inner_bytes >= 4) |
| 23881 |
return gen_rtx_REG (mode, regno); |
| 23882 |
} |
| 23883 |
|
| 23884 |
if (inner_bytes >= 8) |
| 23885 |
return gen_rtx_REG (mode, regno); |
| 23886 |
|
| 23887 |
r1 = gen_rtx_EXPR_LIST (inner, gen_rtx_REG (inner, regno), |
| 23888 |
const0_rtx); |
| 23889 |
r2 = gen_rtx_EXPR_LIST (inner, gen_rtx_REG (inner, regno + 1), |
| 23890 |
GEN_INT (inner_bytes)); |
| 23891 |
return gen_rtx_PARALLEL (mode, gen_rtvec (2, r1, r2)); |
| 23892 |
} |
| 23893 |
|
| 23894 |
/* Return an rtx describing a return value of MODE as a PARALLEL |
| 23895 |
in N_ELTS registers, each of mode ELT_MODE, starting at REGNO, |
| 23896 |
stride REG_STRIDE. */ |
| 23897 |
|
| 23898 |
static rtx |
| 23899 |
rs6000_parallel_return (machine_mode mode, |
| 23900 |
int n_elts, machine_mode elt_mode, |
| 23901 |
unsigned int regno, unsigned int reg_stride) |
| 23902 |
{ |
| 23903 |
rtx par = gen_rtx_PARALLEL (mode, rtvec_alloc (n_elts)); |
| 23904 |
|
| 23905 |
int i; |
| 23906 |
for (i = 0; i < n_elts; i++) |
| 23907 |
{ |
| 23908 |
rtx r = gen_rtx_REG (elt_mode, regno); |
| 23909 |
rtx off = GEN_INT (i * GET_MODE_SIZE (elt_mode)); |
| 23910 |
XVECEXP (par, 0, i) = gen_rtx_EXPR_LIST (VOIDmode, r, off); |
| 23911 |
regno += reg_stride; |
| 23912 |
} |
| 23913 |
|
| 23914 |
return par; |
| 23915 |
} |
| 23916 |
|
| 23917 |
/* Target hook for TARGET_FUNCTION_VALUE. |
| 23918 |
|
| 23919 |
An integer value is in r3 and a floating-point value is in fp1, |
| 23920 |
unless -msoft-float. */ |
| 23921 |
|
| 23922 |
static rtx |
| 23923 |
rs6000_function_value (const_tree valtype, |
| 23924 |
const_tree fn_decl_or_type ATTRIBUTE_UNUSED, |
| 23925 |
bool outgoing ATTRIBUTE_UNUSED) |
| 23926 |
{ |
| 23927 |
machine_mode mode; |
| 23928 |
unsigned int regno; |
| 23929 |
machine_mode elt_mode; |
| 23930 |
int n_elts; |
| 23931 |
|
| 23932 |
/* Special handling for structs in darwin64. */ |
| 23933 |
if (TARGET_MACHO |
| 23934 |
&& rs6000_darwin64_struct_check_p (TYPE_MODE (valtype), valtype)) |
| 23935 |
{ |
| 23936 |
CUMULATIVE_ARGS valcum; |
| 23937 |
rtx valret; |
| 23938 |
|
| 23939 |
valcum.words = 0; |
| 23940 |
valcum.fregno = FP_ARG_MIN_REG; |
| 23941 |
valcum.vregno = ALTIVEC_ARG_MIN_REG; |
| 23942 |
/* Do a trial code generation as if this were going to be passed as |
| 23943 |
an argument; if any part goes in memory, we return NULL. */ |
| 23944 |
valret = rs6000_darwin64_record_arg (&valcum, valtype, true, /* retval= */ true); |
| 23945 |
if (valret) |
| 23946 |
return valret; |
| 23947 |
/* Otherwise fall through to standard ABI rules. */ |
| 23948 |
} |
| 23949 |
|
| 23950 |
mode = TYPE_MODE (valtype); |
| 23951 |
|
| 23952 |
/* The ELFv2 ABI returns homogeneous VFP aggregates in registers. */ |
| 23953 |
if (rs6000_discover_homogeneous_aggregate (mode, valtype, &elt_mode, &n_elts)) |
| 23954 |
{ |
| 23955 |
int first_reg, n_regs; |
| 23956 |
|
| 23957 |
if (SCALAR_FLOAT_MODE_NOT_VECTOR_P (elt_mode)) |
| 23958 |
{ |
| 23959 |
/* _Decimal128 must use even/odd register pairs. */ |
| 23960 |
first_reg = (elt_mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN; |
| 23961 |
n_regs = (GET_MODE_SIZE (elt_mode) + 7) >> 3; |
| 23962 |
} |
| 23963 |
else |
| 23964 |
{ |
| 23965 |
first_reg = ALTIVEC_ARG_RETURN; |
| 23966 |
n_regs = 1; |
| 23967 |
} |
| 23968 |
|
| 23969 |
return rs6000_parallel_return (mode, n_elts, elt_mode, first_reg, n_regs); |
| 23970 |
} |
| 23971 |
|
| 23972 |
/* Some return value types need be split in -mpowerpc64, 32bit ABI. */ |
| 23973 |
if (TARGET_32BIT && TARGET_POWERPC64) |
| 23974 |
switch (mode) |
| 23975 |
{ |
| 23976 |
default: |
| 23977 |
break; |
| 23978 |
case E_DImode: |
| 23979 |
case E_SCmode: |
| 23980 |
case E_DCmode: |
| 23981 |
case E_TCmode: |
| 23982 |
int count = GET_MODE_SIZE (mode) / 4; |
| 23983 |
return rs6000_parallel_return (mode, count, SImode, GP_ARG_RETURN, 1); |
| 23984 |
} |
| 23985 |
|
| 23986 |
if ((INTEGRAL_TYPE_P (valtype) |
| 23987 |
&& GET_MODE_BITSIZE (mode) < (TARGET_32BIT ? 32 : 64)) |
| 23988 |
|| POINTER_TYPE_P (valtype)) |
| 23989 |
mode = TARGET_32BIT ? SImode : DImode; |
| 23990 |
|
| 23991 |
if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT) |
| 23992 |
/* _Decimal128 must use an even/odd register pair. */ |
| 23993 |
regno = (mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN; |
| 23994 |
else if (SCALAR_FLOAT_TYPE_P (valtype) && TARGET_HARD_FLOAT |
| 23995 |
&& !FLOAT128_VECTOR_P (mode)) |
| 23996 |
regno = FP_ARG_RETURN; |
| 23997 |
else if (TREE_CODE (valtype) == COMPLEX_TYPE |
| 23998 |
&& targetm.calls.split_complex_arg) |
| 23999 |
return rs6000_complex_function_value (mode); |
| 24000 |
/* VSX is a superset of Altivec and adds V2DImode/V2DFmode. Since the same |
| 24001 |
return register is used in both cases, and we won't see V2DImode/V2DFmode |
| 24002 |
for pure altivec, combine the two cases. */ |
| 24003 |
else if ((VECTOR_TYPE_P (valtype) || VECTOR_ALIGNMENT_P (mode)) |
| 24004 |
&& TARGET_ALTIVEC && TARGET_ALTIVEC_ABI |
| 24005 |
&& ALTIVEC_OR_VSX_VECTOR_MODE (mode)) |
| 24006 |
regno = ALTIVEC_ARG_RETURN; |
| 24007 |
else |
| 24008 |
regno = GP_ARG_RETURN; |
| 24009 |
|
| 24010 |
return gen_rtx_REG (mode, regno); |
| 24011 |
} |
| 24012 |
|
| 24013 |
/* Define how to find the value returned by a library function |
| 24014 |
assuming the value has mode MODE. */ |
| 24015 |
rtx |
| 24016 |
rs6000_libcall_value (machine_mode mode) |
| 24017 |
{ |
| 24018 |
unsigned int regno; |
| 24019 |
|
| 24020 |
/* Long long return value need be split in -mpowerpc64, 32bit ABI. */ |
| 24021 |
if (TARGET_32BIT && TARGET_POWERPC64 && mode == DImode) |
| 24022 |
return rs6000_parallel_return (mode, 2, SImode, GP_ARG_RETURN, 1); |
| 24023 |
|
| 24024 |
if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT) |
| 24025 |
/* _Decimal128 must use an even/odd register pair. */ |
| 24026 |
regno = (mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN; |
| 24027 |
else if (SCALAR_FLOAT_MODE_NOT_VECTOR_P (mode) && TARGET_HARD_FLOAT) |
| 24028 |
regno = FP_ARG_RETURN; |
| 24029 |
/* VSX is a superset of Altivec and adds V2DImode/V2DFmode. Since the same |
| 24030 |
return register is used in both cases, and we won't see V2DImode/V2DFmode |
| 24031 |
for pure altivec, combine the two cases. */ |
| 24032 |
else if (ALTIVEC_OR_VSX_VECTOR_MODE (mode) |
| 24033 |
&& TARGET_ALTIVEC && TARGET_ALTIVEC_ABI) |
| 24034 |
regno = ALTIVEC_ARG_RETURN; |
| 24035 |
else if (COMPLEX_MODE_P (mode) && targetm.calls.split_complex_arg) |
| 24036 |
return rs6000_complex_function_value (mode); |
| 24037 |
else |
| 24038 |
regno = GP_ARG_RETURN; |
| 24039 |
|
| 24040 |
return gen_rtx_REG (mode, regno); |
| 24041 |
} |
| 24042 |
|
| 24043 |
/* Compute register pressure classes. We implement the target hook to avoid |
| 24044 |
IRA picking something like GEN_OR_FLOAT_REGS as a pressure class, which can |
| 24045 |
lead to incorrect estimates of number of available registers and therefor |
| 24046 |
increased register pressure/spill. */ |
| 24047 |
static int |
| 24048 |
rs6000_compute_pressure_classes (enum reg_class *pressure_classes) |
| 24049 |
{ |
| 24050 |
int n; |
| 24051 |
|
| 24052 |
n = 0; |
| 24053 |
pressure_classes[n++] = GENERAL_REGS; |
| 24054 |
if (TARGET_ALTIVEC) |
| 24055 |
pressure_classes[n++] = ALTIVEC_REGS; |
| 24056 |
if (TARGET_VSX) |
| 24057 |
pressure_classes[n++] = VSX_REGS; |
| 24058 |
else |
| 24059 |
{ |
| 24060 |
if (TARGET_HARD_FLOAT) |
| 24061 |
pressure_classes[n++] = FLOAT_REGS; |
| 24062 |
} |
| 24063 |
pressure_classes[n++] = CR_REGS; |
| 24064 |
pressure_classes[n++] = SPECIAL_REGS; |
| 24065 |
|
| 24066 |
return n; |
| 24067 |
} |
| 24068 |
|
| 24069 |
/* Given FROM and TO register numbers, say whether this elimination is allowed. |
| 24070 |
Frame pointer elimination is automatically handled. |
| 24071 |
|
| 24072 |
For the RS/6000, if frame pointer elimination is being done, we would like |
| 24073 |
to convert ap into fp, not sp. |
| 24074 |
|
| 24075 |
We need r30 if -mminimal-toc was specified, and there are constant pool |
| 24076 |
references. */ |
| 24077 |
|
| 24078 |
static bool |
| 24079 |
rs6000_can_eliminate (const int from, const int to) |
| 24080 |
{ |
| 24081 |
return (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM |
| 24082 |
? ! frame_pointer_needed |
| 24083 |
: from == RS6000_PIC_OFFSET_TABLE_REGNUM |
| 24084 |
? ! TARGET_MINIMAL_TOC || TARGET_NO_TOC_OR_PCREL |
| 24085 |
|| constant_pool_empty_p () |
| 24086 |
: true); |
| 24087 |
} |
| 24088 |
|
| 24089 |
/* Define the offset between two registers, FROM to be eliminated and its |
| 24090 |
replacement TO, at the start of a routine. */ |
| 24091 |
HOST_WIDE_INT |
| 24092 |
rs6000_initial_elimination_offset (int from, int to) |
| 24093 |
{ |
| 24094 |
rs6000_stack_t *info = rs6000_stack_info (); |
| 24095 |
HOST_WIDE_INT offset; |
| 24096 |
|
| 24097 |
if (from == HARD_FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM) |
| 24098 |
offset = info->push_p ? 0 : -info->total_size; |
| 24099 |
else if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM) |
| 24100 |
{ |
| 24101 |
offset = info->push_p ? 0 : -info->total_size; |
| 24102 |
if (FRAME_GROWS_DOWNWARD) |
| 24103 |
offset += info->fixed_size + info->vars_size + info->parm_size; |
| 24104 |
} |
| 24105 |
else if (from == FRAME_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM) |
| 24106 |
offset = FRAME_GROWS_DOWNWARD |
| 24107 |
? info->fixed_size + info->vars_size + info->parm_size |
| 24108 |
: 0; |
| 24109 |
else if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM) |
| 24110 |
offset = info->total_size; |
| 24111 |
else if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM) |
| 24112 |
offset = info->push_p ? info->total_size : 0; |
| 24113 |
else if (from == RS6000_PIC_OFFSET_TABLE_REGNUM) |
| 24114 |
offset = 0; |
| 24115 |
else |
| 24116 |
gcc_unreachable (); |
| 24117 |
|
| 24118 |
return offset; |
| 24119 |
} |
| 24120 |
|
| 24121 |
/* Fill in sizes of registers used by unwinder. */ |
| 24122 |
|
| 24123 |
static void |
| 24124 |
rs6000_init_dwarf_reg_sizes_extra (tree address) |
| 24125 |
{ |
| 24126 |
if (TARGET_MACHO && ! TARGET_ALTIVEC) |
| 24127 |
{ |
| 24128 |
int i; |
| 24129 |
machine_mode mode = TYPE_MODE (char_type_node); |
| 24130 |
rtx addr = expand_expr (address, NULL_RTX, VOIDmode, EXPAND_NORMAL); |
| 24131 |
rtx mem = gen_rtx_MEM (BLKmode, addr); |
| 24132 |
rtx value = gen_int_mode (16, mode); |
| 24133 |
|
| 24134 |
/* On Darwin, libgcc may be built to run on both G3 and G4/5. |
| 24135 |
The unwinder still needs to know the size of Altivec registers. */ |
| 24136 |
|
| 24137 |
for (i = FIRST_ALTIVEC_REGNO; i < LAST_ALTIVEC_REGNO+1; i++) |
| 24138 |
{ |
| 24139 |
int column = DWARF_REG_TO_UNWIND_COLUMN |
| 24140 |
(DWARF2_FRAME_REG_OUT (DWARF_FRAME_REGNUM (i), true)); |
| 24141 |
HOST_WIDE_INT offset = column * GET_MODE_SIZE (mode); |
| 24142 |
|
| 24143 |
emit_move_insn (adjust_address (mem, mode, offset), value); |
| 24144 |
} |
| 24145 |
} |
| 24146 |
} |
| 24147 |
|
| 24148 |
/* Map internal gcc register numbers to debug format register numbers. |
| 24149 |
FORMAT specifies the type of debug register number to use: |
| 24150 |
0 -- debug information, except for frame-related sections |
| 24151 |
1 -- DWARF .debug_frame section |
| 24152 |
2 -- DWARF .eh_frame section */ |
| 24153 |
|
| 24154 |
unsigned int |
| 24155 |
rs6000_debugger_regno (unsigned int regno, unsigned int format) |
| 24156 |
{ |
| 24157 |
/* On some platforms, we use the standard DWARF register |
| 24158 |
numbering for .debug_info and .debug_frame. */ |
| 24159 |
if ((format == 0 && dwarf_debuginfo_p ()) || format == 1) |
| 24160 |
{ |
| 24161 |
#ifdef RS6000_USE_DWARF_NUMBERING |
| 24162 |
if (regno <= 31) |
| 24163 |
return regno; |
| 24164 |
if (FP_REGNO_P (regno)) |
| 24165 |
return regno - FIRST_FPR_REGNO + 32; |
| 24166 |
if (ALTIVEC_REGNO_P (regno)) |
| 24167 |
return regno - FIRST_ALTIVEC_REGNO + 1124; |
| 24168 |
if (regno == LR_REGNO) |
| 24169 |
return 108; |
| 24170 |
if (regno == CTR_REGNO) |
| 24171 |
return 109; |
| 24172 |
if (regno == CA_REGNO) |
| 24173 |
return 101; /* XER */ |
| 24174 |
/* Special handling for CR for .debug_frame: rs6000_emit_prologue has |
| 24175 |
translated any combination of CR2, CR3, CR4 saves to a save of CR2. |
| 24176 |
The actual code emitted saves the whole of CR, so we map CR2_REGNO |
| 24177 |
to the DWARF reg for CR. */ |
| 24178 |
if (format == 1 && regno == CR2_REGNO) |
| 24179 |
return 64; |
| 24180 |
if (CR_REGNO_P (regno)) |
| 24181 |
return regno - CR0_REGNO + 86; |
| 24182 |
if (regno == VRSAVE_REGNO) |
| 24183 |
return 356; |
| 24184 |
if (regno == VSCR_REGNO) |
| 24185 |
return 67; |
| 24186 |
|
| 24187 |
/* These do not make much sense. */ |
| 24188 |
if (regno == FRAME_POINTER_REGNUM) |
| 24189 |
return 111; |
| 24190 |
if (regno == ARG_POINTER_REGNUM) |
| 24191 |
return 67; |
| 24192 |
if (regno == 64) |
| 24193 |
return 100; |
| 24194 |
|
| 24195 |
gcc_unreachable (); |
| 24196 |
#endif |
| 24197 |
} |
| 24198 |
|
| 24199 |
/* We use the GCC 7 (and before) internal number for non-DWARF debug |
| 24200 |
information, and also for .eh_frame. */ |
| 24201 |
/* Translate the regnos to their numbers in GCC 7 (and before). */ |
| 24202 |
if (regno <= 31) |
| 24203 |
return regno; |
| 24204 |
if (FP_REGNO_P (regno)) |
| 24205 |
return regno - FIRST_FPR_REGNO + 32; |
| 24206 |
if (ALTIVEC_REGNO_P (regno)) |
| 24207 |
return regno - FIRST_ALTIVEC_REGNO + 77; |
| 24208 |
if (regno == LR_REGNO) |
| 24209 |
return 65; |
| 24210 |
if (regno == CTR_REGNO) |
| 24211 |
return 66; |
| 24212 |
if (regno == CA_REGNO) |
| 24213 |
return 76; /* XER */ |
| 24214 |
if (CR_REGNO_P (regno)) |
| 24215 |
return regno - CR0_REGNO + 68; |
| 24216 |
if (regno == VRSAVE_REGNO) |
| 24217 |
return 109; |
| 24218 |
if (regno == VSCR_REGNO) |
| 24219 |
return 110; |
| 24220 |
|
| 24221 |
if (regno == FRAME_POINTER_REGNUM) |
| 24222 |
return 111; |
| 24223 |
if (regno == ARG_POINTER_REGNUM) |
| 24224 |
return 67; |
| 24225 |
if (regno == 64) |
| 24226 |
return 64; |
| 24227 |
|
| 24228 |
gcc_unreachable (); |
| 24229 |
} |
| 24230 |
|
| 24231 |
/* target hook eh_return_filter_mode */ |
| 24232 |
static scalar_int_mode |
| 24233 |
rs6000_eh_return_filter_mode (void) |
| 24234 |
{ |
| 24235 |
return TARGET_32BIT ? SImode : word_mode; |
| 24236 |
} |
| 24237 |
|
| 24238 |
/* Target hook for translate_mode_attribute. */ |
| 24239 |
static machine_mode |
| 24240 |
rs6000_translate_mode_attribute (machine_mode mode) |
| 24241 |
{ |
| 24242 |
if ((FLOAT128_IEEE_P (mode) |
| 24243 |
&& ieee128_float_type_node == long_double_type_node) |
| 24244 |
|| (FLOAT128_IBM_P (mode) |
| 24245 |
&& ibm128_float_type_node == long_double_type_node)) |
| 24246 |
return COMPLEX_MODE_P (mode) ? E_TCmode : E_TFmode; |
| 24247 |
return mode; |
| 24248 |
} |
| 24249 |
|
| 24250 |
/* Target hook for scalar_mode_supported_p. */ |
| 24251 |
static bool |
| 24252 |
rs6000_scalar_mode_supported_p (scalar_mode mode) |
| 24253 |
{ |
| 24254 |
/* -m32 does not support TImode. This is the default, from |
| 24255 |
default_scalar_mode_supported_p. For -m32 -mpowerpc64 we want the |
| 24256 |
same ABI as for -m32. But default_scalar_mode_supported_p allows |
| 24257 |
integer modes of precision 2 * BITS_PER_WORD, which matches TImode |
| 24258 |
for -mpowerpc64. */ |
| 24259 |
if (TARGET_32BIT && mode == TImode) |
| 24260 |
return false; |
| 24261 |
|
| 24262 |
if (DECIMAL_FLOAT_MODE_P (mode)) |
| 24263 |
return default_decimal_float_supported_p (); |
| 24264 |
else if (TARGET_FLOAT128_TYPE && (mode == KFmode || mode == IFmode)) |
| 24265 |
return true; |
| 24266 |
else |
| 24267 |
return default_scalar_mode_supported_p (mode); |
| 24268 |
} |
| 24269 |
|
| 24270 |
/* Target hook for libgcc_floating_mode_supported_p. */ |
| 24271 |
|
| 24272 |
static bool |
| 24273 |
rs6000_libgcc_floating_mode_supported_p (scalar_float_mode mode) |
| 24274 |
{ |
| 24275 |
switch (mode) |
| 24276 |
{ |
| 24277 |
case E_SFmode: |
| 24278 |
case E_DFmode: |
| 24279 |
case E_TFmode: |
| 24280 |
return true; |
| 24281 |
|
| 24282 |
/* We only return true for KFmode if IEEE 128-bit types are supported, and |
| 24283 |
if long double does not use the IEEE 128-bit format. If long double |
| 24284 |
uses the IEEE 128-bit format, it will use TFmode and not KFmode. |
| 24285 |
Because the code will not use KFmode in that case, there will be aborts |
| 24286 |
because it can't find KFmode in the Floatn types. */ |
| 24287 |
case E_KFmode: |
| 24288 |
return TARGET_FLOAT128_TYPE && !TARGET_IEEEQUAD; |
| 24289 |
|
| 24290 |
default: |
| 24291 |
return false; |
| 24292 |
} |
| 24293 |
} |
| 24294 |
|
| 24295 |
/* Target hook for vector_mode_supported_p. */ |
| 24296 |
static bool |
| 24297 |
rs6000_vector_mode_supported_p (machine_mode mode) |
| 24298 |
{ |
| 24299 |
/* There is no vector form for IEEE 128-bit. If we return true for IEEE |
| 24300 |
128-bit, the compiler might try to widen IEEE 128-bit to IBM |
| 24301 |
double-double. */ |
| 24302 |
if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode) && !FLOAT128_IEEE_P (mode)) |
| 24303 |
return true; |
| 24304 |
|
| 24305 |
else |
| 24306 |
return false; |
| 24307 |
} |
| 24308 |
|
| 24309 |
/* Target hook for floatn_mode. */ |
| 24310 |
static opt_scalar_float_mode |
| 24311 |
rs6000_floatn_mode (int n, bool extended) |
| 24312 |
{ |
| 24313 |
if (extended) |
| 24314 |
{ |
| 24315 |
switch (n) |
| 24316 |
{ |
| 24317 |
case 32: |
| 24318 |
return DFmode; |
| 24319 |
|
| 24320 |
case 64: |
| 24321 |
if (TARGET_FLOAT128_TYPE) |
| 24322 |
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; |
| 24323 |
else |
| 24324 |
return opt_scalar_float_mode (); |
| 24325 |
|
| 24326 |
case 128: |
| 24327 |
return opt_scalar_float_mode (); |
| 24328 |
|
| 24329 |
default: |
| 24330 |
/* Those are the only valid _FloatNx types. */ |
| 24331 |
gcc_unreachable (); |
| 24332 |
} |
| 24333 |
} |
| 24334 |
else |
| 24335 |
{ |
| 24336 |
switch (n) |
| 24337 |
{ |
| 24338 |
case 32: |
| 24339 |
return SFmode; |
| 24340 |
|
| 24341 |
case 64: |
| 24342 |
return DFmode; |
| 24343 |
|
| 24344 |
case 128: |
| 24345 |
if (TARGET_FLOAT128_TYPE) |
| 24346 |
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; |
| 24347 |
else |
| 24348 |
return opt_scalar_float_mode (); |
| 24349 |
|
| 24350 |
default: |
| 24351 |
return opt_scalar_float_mode (); |
| 24352 |
} |
| 24353 |
} |
| 24354 |
|
| 24355 |
} |
| 24356 |
|
| 24357 |
/* Target hook for c_mode_for_suffix. */ |
| 24358 |
static machine_mode |
| 24359 |
rs6000_c_mode_for_suffix (char suffix) |
| 24360 |
{ |
| 24361 |
if (TARGET_FLOAT128_TYPE) |
| 24362 |
{ |
| 24363 |
if (suffix == 'q' || suffix == 'Q') |
| 24364 |
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; |
| 24365 |
|
| 24366 |
/* At the moment, we are not defining a suffix for IBM extended double. |
| 24367 |
If/when the default for -mabi=ieeelongdouble is changed, and we want |
| 24368 |
to support __ibm128 constants in legacy library code, we may need to |
| 24369 |
re-evalaute this decision. Currently, c-lex.cc only supports 'w' and |
| 24370 |
'q' as machine dependent suffixes. The x86_64 port uses 'w' for |
| 24371 |
__float80 constants. */ |
| 24372 |
} |
| 24373 |
|
| 24374 |
return VOIDmode; |
| 24375 |
} |
| 24376 |
|
| 24377 |
/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE. Return TFmode for |
| 24378 |
TI_LONG_DOUBLE_TYPE which is for long double type, go with the default |
| 24379 |
one for the others. */ |
| 24380 |
|
| 24381 |
static machine_mode |
| 24382 |
rs6000_c_mode_for_floating_type (enum tree_index ti) |
| 24383 |
{ |
| 24384 |
if (ti == TI_LONG_DOUBLE_TYPE) |
| 24385 |
return rs6000_long_double_type_size == 128 ? TFmode : DFmode; |
| 24386 |
return default_mode_for_floating_type (ti); |
| 24387 |
} |
| 24388 |
|
| 24389 |
/* Target hook for invalid_arg_for_unprototyped_fn. */ |
| 24390 |
static const char * |
| 24391 |
invalid_arg_for_unprototyped_fn (const_tree typelist, const_tree funcdecl, const_tree val) |
| 24392 |
{ |
| 24393 |
return (!rs6000_darwin64_abi |
| 24394 |
&& typelist == 0 |
| 24395 |
&& VECTOR_TYPE_P (TREE_TYPE (val)) |
| 24396 |
&& (funcdecl == NULL_TREE |
| 24397 |
|| (TREE_CODE (funcdecl) == FUNCTION_DECL |
| 24398 |
&& DECL_BUILT_IN_CLASS (funcdecl) != BUILT_IN_MD |
| 24399 |
&& !fndecl_built_in_p (funcdecl, BUILT_IN_CLASSIFY_TYPE)))) |
| 24400 |
? N_("AltiVec argument passed to unprototyped function") |
| 24401 |
: NULL; |
| 24402 |
} |
| 24403 |
|
| 24404 |
/* For TARGET_SECURE_PLT 32-bit PIC code we can save PIC register |
| 24405 |
setup by using __stack_chk_fail_local hidden function instead of |
| 24406 |
calling __stack_chk_fail directly. Otherwise it is better to call |
| 24407 |
__stack_chk_fail directly. */ |
| 24408 |
|
| 24409 |
static tree ATTRIBUTE_UNUSED |
| 24410 |
rs6000_stack_protect_fail (void) |
| 24411 |
{ |
| 24412 |
return (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT && flag_pic) |
| 24413 |
? default_hidden_stack_protect_fail () |
| 24414 |
: default_external_stack_protect_fail (); |
| 24415 |
} |
| 24416 |
|
| 24417 |
/* Implement the TARGET_ASAN_SHADOW_OFFSET hook. */ |
| 24418 |
|
| 24419 |
#if TARGET_ELF |
| 24420 |
static unsigned HOST_WIDE_INT |
| 24421 |
rs6000_asan_shadow_offset (void) |
| 24422 |
{ |
| 24423 |
return (unsigned HOST_WIDE_INT) 1 << (TARGET_64BIT ? 41 : 29); |
| 24424 |
} |
| 24425 |
#endif |
| 24426 |
|
| 24427 |
/* Mask options that we want to support inside of attribute((target)) and |
| 24428 |
#pragma GCC target operations. Note, we do not include things like |
| 24429 |
64/32-bit, endianness, hard/soft floating point, etc. that would have |
| 24430 |
different calling sequences. */ |
| 24431 |
|
| 24432 |
struct rs6000_opt_mask { |
| 24433 |
const char *name; /* option name */ |
| 24434 |
HOST_WIDE_INT mask; /* mask to set */ |
| 24435 |
bool invert; /* invert sense of mask */ |
| 24436 |
bool valid_target; /* option is a target option */ |
| 24437 |
}; |
| 24438 |
|
| 24439 |
static struct rs6000_opt_mask const rs6000_opt_masks[] = |
| 24440 |
{ |
| 24441 |
{ "altivec", OPTION_MASK_ALTIVEC, false, true }, |
| 24442 |
{ "block-ops-unaligned-vsx", OPTION_MASK_BLOCK_OPS_UNALIGNED_VSX, |
| 24443 |
false, true }, |
| 24444 |
{ "block-ops-vector-pair", OPTION_MASK_BLOCK_OPS_VECTOR_PAIR, |
| 24445 |
false, true }, |
| 24446 |
{ "cmpb", OPTION_MASK_CMPB, false, true }, |
| 24447 |
{ "crypto", OPTION_MASK_CRYPTO, false, true }, |
| 24448 |
{ "direct-move", 0, false, true }, |
| 24449 |
{ "dlmzb", OPTION_MASK_DLMZB, false, true }, |
| 24450 |
{ "efficient-unaligned-vsx", OPTION_MASK_EFFICIENT_UNALIGNED_VSX, |
| 24451 |
false, true }, |
| 24452 |
{ "float128", OPTION_MASK_FLOAT128_KEYWORD, false, true }, |
| 24453 |
{ "float128-hardware", OPTION_MASK_FLOAT128_HW, false, true }, |
| 24454 |
{ "fprnd", OPTION_MASK_FPRND, false, true }, |
| 24455 |
{ "power10", OPTION_MASK_POWER10, false, true }, |
| 24456 |
{ "power11", OPTION_MASK_POWER11, false, false }, |
| 24457 |
{ "hard-dfp", OPTION_MASK_DFP, false, true }, |
| 24458 |
{ "htm", OPTION_MASK_HTM, false, true }, |
| 24459 |
{ "isel", OPTION_MASK_ISEL, false, true }, |
| 24460 |
{ "mfcrf", OPTION_MASK_MFCRF, false, true }, |
| 24461 |
{ "mfpgpr", 0, false, true }, |
| 24462 |
{ "mma", OPTION_MASK_MMA, false, true }, |
| 24463 |
{ "modulo", OPTION_MASK_MODULO, false, true }, |
| 24464 |
{ "mulhw", OPTION_MASK_MULHW, false, true }, |
| 24465 |
{ "multiple", OPTION_MASK_MULTIPLE, false, true }, |
| 24466 |
{ "pcrel", OPTION_MASK_PCREL, false, true }, |
| 24467 |
{ "pcrel-opt", OPTION_MASK_PCREL_OPT, false, true }, |
| 24468 |
{ "popcntb", OPTION_MASK_POPCNTB, false, true }, |
| 24469 |
{ "popcntd", OPTION_MASK_POPCNTD, false, true }, |
| 24470 |
{ "power8-fusion", OPTION_MASK_P8_FUSION, false, true }, |
| 24471 |
{ "power8-fusion-sign", OPTION_MASK_P8_FUSION_SIGN, false, true }, |
| 24472 |
{ "power8-vector", OPTION_MASK_P8_VECTOR, false, true }, |
| 24473 |
{ "power9-minmax", OPTION_MASK_P9_MINMAX, false, true }, |
| 24474 |
{ "power9-misc", OPTION_MASK_P9_MISC, false, true }, |
| 24475 |
{ "power9-vector", OPTION_MASK_P9_VECTOR, false, true }, |
| 24476 |
{ "power10-fusion", OPTION_MASK_P10_FUSION, false, true }, |
| 24477 |
{ "powerpc-gfxopt", OPTION_MASK_PPC_GFXOPT, false, true }, |
| 24478 |
{ "powerpc-gpopt", OPTION_MASK_PPC_GPOPT, false, true }, |
| 24479 |
{ "prefixed", OPTION_MASK_PREFIXED, false, true }, |
| 24480 |
{ "quad-memory", OPTION_MASK_QUAD_MEMORY, false, true }, |
| 24481 |
{ "quad-memory-atomic", OPTION_MASK_QUAD_MEMORY_ATOMIC, false, true }, |
| 24482 |
{ "recip-precision", OPTION_MASK_RECIP_PRECISION, false, true }, |
| 24483 |
{ "save-toc-indirect", OPTION_MASK_SAVE_TOC_INDIRECT, false, true }, |
| 24484 |
{ "string", 0, false, true }, |
| 24485 |
{ "update", OPTION_MASK_NO_UPDATE, true , true }, |
| 24486 |
{ "vsx", OPTION_MASK_VSX, false, true }, |
| 24487 |
#ifdef OPTION_MASK_64BIT |
| 24488 |
#if TARGET_AIX_OS |
| 24489 |
{ "aix64", OPTION_MASK_64BIT, false, false }, |
| 24490 |
{ "aix32", OPTION_MASK_64BIT, true, false }, |
| 24491 |
#else |
| 24492 |
{ "64", OPTION_MASK_64BIT, false, false }, |
| 24493 |
{ "32", OPTION_MASK_64BIT, true, false }, |
| 24494 |
#endif |
| 24495 |
#endif |
| 24496 |
#ifdef OPTION_MASK_EABI |
| 24497 |
{ "eabi", OPTION_MASK_EABI, false, false }, |
| 24498 |
#endif |
| 24499 |
#ifdef OPTION_MASK_LITTLE_ENDIAN |
| 24500 |
{ "little", OPTION_MASK_LITTLE_ENDIAN, false, false }, |
| 24501 |
{ "big", OPTION_MASK_LITTLE_ENDIAN, true, false }, |
| 24502 |
#endif |
| 24503 |
#ifdef OPTION_MASK_RELOCATABLE |
| 24504 |
{ "relocatable", OPTION_MASK_RELOCATABLE, false, false }, |
| 24505 |
#endif |
| 24506 |
#ifdef OPTION_MASK_STRICT_ALIGN |
| 24507 |
{ "strict-align", OPTION_MASK_STRICT_ALIGN, false, false }, |
| 24508 |
#endif |
| 24509 |
{ "soft-float", OPTION_MASK_SOFT_FLOAT, false, false }, |
| 24510 |
{ "string", 0, false, false }, |
| 24511 |
}; |
| 24512 |
|
| 24513 |
/* Option variables that we want to support inside attribute((target)) and |
| 24514 |
#pragma GCC target operations. */ |
| 24515 |
|
| 24516 |
struct rs6000_opt_var { |
| 24517 |
const char *name; /* option name */ |
| 24518 |
size_t global_offset; /* offset of the option in global_options. */ |
| 24519 |
size_t target_offset; /* offset of the option in target options. */ |
| 24520 |
}; |
| 24521 |
|
| 24522 |
static struct rs6000_opt_var const rs6000_opt_vars[] = |
| 24523 |
{ |
| 24524 |
{ "friz", |
| 24525 |
offsetof (struct gcc_options, x_TARGET_FRIZ), |
| 24526 |
offsetof (struct cl_target_option, x_TARGET_FRIZ), }, |
| 24527 |
{ "avoid-indexed-addresses", |
| 24528 |
offsetof (struct gcc_options, x_TARGET_AVOID_XFORM), |
| 24529 |
offsetof (struct cl_target_option, x_TARGET_AVOID_XFORM) }, |
| 24530 |
{ "longcall", |
| 24531 |
offsetof (struct gcc_options, x_rs6000_default_long_calls), |
| 24532 |
offsetof (struct cl_target_option, x_rs6000_default_long_calls), }, |
| 24533 |
{ "optimize-swaps", |
| 24534 |
offsetof (struct gcc_options, x_rs6000_optimize_swaps), |
| 24535 |
offsetof (struct cl_target_option, x_rs6000_optimize_swaps), }, |
| 24536 |
{ "allow-movmisalign", |
| 24537 |
offsetof (struct gcc_options, x_TARGET_ALLOW_MOVMISALIGN), |
| 24538 |
offsetof (struct cl_target_option, x_TARGET_ALLOW_MOVMISALIGN), }, |
| 24539 |
{ "sched-groups", |
| 24540 |
offsetof (struct gcc_options, x_TARGET_SCHED_GROUPS), |
| 24541 |
offsetof (struct cl_target_option, x_TARGET_SCHED_GROUPS), }, |
| 24542 |
{ "always-hint", |
| 24543 |
offsetof (struct gcc_options, x_TARGET_ALWAYS_HINT), |
| 24544 |
offsetof (struct cl_target_option, x_TARGET_ALWAYS_HINT), }, |
| 24545 |
{ "align-branch-targets", |
| 24546 |
offsetof (struct gcc_options, x_TARGET_ALIGN_BRANCH_TARGETS), |
| 24547 |
offsetof (struct cl_target_option, x_TARGET_ALIGN_BRANCH_TARGETS), }, |
| 24548 |
{ "sched-prolog", |
| 24549 |
offsetof (struct gcc_options, x_TARGET_SCHED_PROLOG), |
| 24550 |
offsetof (struct cl_target_option, x_TARGET_SCHED_PROLOG), }, |
| 24551 |
{ "sched-epilog", |
| 24552 |
offsetof (struct gcc_options, x_TARGET_SCHED_PROLOG), |
| 24553 |
offsetof (struct cl_target_option, x_TARGET_SCHED_PROLOG), }, |
| 24554 |
{ "speculate-indirect-jumps", |
| 24555 |
offsetof (struct gcc_options, x_rs6000_speculate_indirect_jumps), |
| 24556 |
offsetof (struct cl_target_option, x_rs6000_speculate_indirect_jumps), }, |
| 24557 |
}; |
| 24558 |
|
| 24559 |
/* Inner function to handle attribute((target("..."))) and #pragma GCC target |
| 24560 |
parsing. Return true if there were no errors. */ |
| 24561 |
|
| 24562 |
static bool |
| 24563 |
rs6000_inner_target_options (tree args, bool attr_p) |
| 24564 |
{ |
| 24565 |
bool ret = true; |
| 24566 |
|
| 24567 |
if (args == NULL_TREE) |
| 24568 |
; |
| 24569 |
|
| 24570 |
else if (TREE_CODE (args) == STRING_CST) |
| 24571 |
{ |
| 24572 |
char *p = ASTRDUP (TREE_STRING_POINTER (args)); |
| 24573 |
char *q; |
| 24574 |
|
| 24575 |
while ((q = strtok (p, ",")) != NULL) |
| 24576 |
{ |
| 24577 |
bool error_p = false; |
| 24578 |
bool not_valid_p = false; |
| 24579 |
const char *cpu_opt = NULL; |
| 24580 |
|
| 24581 |
p = NULL; |
| 24582 |
if (startswith (q, "cpu=")) |
| 24583 |
{ |
| 24584 |
int cpu_index = rs6000_cpu_name_lookup (q+4); |
| 24585 |
if (cpu_index >= 0) |
| 24586 |
rs6000_cpu_index = cpu_index; |
| 24587 |
else |
| 24588 |
{ |
| 24589 |
error_p = true; |
| 24590 |
cpu_opt = q+4; |
| 24591 |
} |
| 24592 |
} |
| 24593 |
else if (startswith (q, "tune=")) |
| 24594 |
{ |
| 24595 |
int tune_index = rs6000_cpu_name_lookup (q+5); |
| 24596 |
if (tune_index >= 0) |
| 24597 |
rs6000_tune_index = tune_index; |
| 24598 |
else |
| 24599 |
{ |
| 24600 |
error_p = true; |
| 24601 |
cpu_opt = q+5; |
| 24602 |
} |
| 24603 |
} |
| 24604 |
else |
| 24605 |
{ |
| 24606 |
size_t i; |
| 24607 |
bool invert = false; |
| 24608 |
char *r = q; |
| 24609 |
|
| 24610 |
error_p = true; |
| 24611 |
if (startswith (r, "no-")) |
| 24612 |
{ |
| 24613 |
invert = true; |
| 24614 |
r += 3; |
| 24615 |
} |
| 24616 |
|
| 24617 |
for (i = 0; i < ARRAY_SIZE (rs6000_opt_masks); i++) |
| 24618 |
if (strcmp (r, rs6000_opt_masks[i].name) == 0) |
| 24619 |
{ |
| 24620 |
HOST_WIDE_INT mask = rs6000_opt_masks[i].mask; |
| 24621 |
|
| 24622 |
if (!rs6000_opt_masks[i].valid_target) |
| 24623 |
not_valid_p = true; |
| 24624 |
else |
| 24625 |
{ |
| 24626 |
error_p = false; |
| 24627 |
rs6000_isa_flags_explicit |= mask; |
| 24628 |
|
| 24629 |
/* VSX needs altivec, so -mvsx automagically sets |
| 24630 |
altivec and disables -mavoid-indexed-addresses. */ |
| 24631 |
if (!invert) |
| 24632 |
{ |
| 24633 |
if (mask == OPTION_MASK_VSX) |
| 24634 |
{ |
| 24635 |
if (!(rs6000_isa_flags_explicit |
| 24636 |
& OPTION_MASK_ALTIVEC)) |
| 24637 |
mask |= OPTION_MASK_ALTIVEC; |
| 24638 |
if (!OPTION_SET_P (TARGET_AVOID_XFORM)) |
| 24639 |
TARGET_AVOID_XFORM = 0; |
| 24640 |
} |
| 24641 |
} |
| 24642 |
|
| 24643 |
if (rs6000_opt_masks[i].invert) |
| 24644 |
invert = !invert; |
| 24645 |
|
| 24646 |
if (invert) |
| 24647 |
rs6000_isa_flags &= ~mask; |
| 24648 |
else |
| 24649 |
rs6000_isa_flags |= mask; |
| 24650 |
} |
| 24651 |
break; |
| 24652 |
} |
| 24653 |
|
| 24654 |
if (error_p && !not_valid_p) |
| 24655 |
{ |
| 24656 |
for (i = 0; i < ARRAY_SIZE (rs6000_opt_vars); i++) |
| 24657 |
if (strcmp (r, rs6000_opt_vars[i].name) == 0) |
| 24658 |
{ |
| 24659 |
size_t j = rs6000_opt_vars[i].global_offset; |
| 24660 |
*((int *) ((char *) &global_options + j)) = !invert; |
| 24661 |
*((int *) ((char *) &global_options_set + j)) = 1; |
| 24662 |
error_p = false; |
| 24663 |
not_valid_p = false; |
| 24664 |
break; |
| 24665 |
} |
| 24666 |
} |
| 24667 |
} |
| 24668 |
|
| 24669 |
if (error_p) |
| 24670 |
{ |
| 24671 |
const char *eprefix, *esuffix; |
| 24672 |
|
| 24673 |
ret = false; |
| 24674 |
if (attr_p) |
| 24675 |
{ |
| 24676 |
eprefix = "__attribute__((__target__("; |
| 24677 |
esuffix = ")))"; |
| 24678 |
} |
| 24679 |
else |
| 24680 |
{ |
| 24681 |
eprefix = "#pragma GCC target "; |
| 24682 |
esuffix = ""; |
| 24683 |
} |
| 24684 |
|
| 24685 |
if (cpu_opt) |
| 24686 |
error ("invalid cpu %qs for %s%qs%s", cpu_opt, eprefix, |
| 24687 |
q, esuffix); |
| 24688 |
else if (not_valid_p) |
| 24689 |
error ("%s%qs%s is not allowed", eprefix, q, esuffix); |
| 24690 |
else |
| 24691 |
error ("%s%qs%s is invalid", eprefix, q, esuffix); |
| 24692 |
} |
| 24693 |
} |
| 24694 |
} |
| 24695 |
|
| 24696 |
else if (TREE_CODE (args) == TREE_LIST) |
| 24697 |
{ |
| 24698 |
do |
| 24699 |
{ |
| 24700 |
tree value = TREE_VALUE (args); |
| 24701 |
if (value) |
| 24702 |
{ |
| 24703 |
bool ret2 = rs6000_inner_target_options (value, attr_p); |
| 24704 |
if (!ret2) |
| 24705 |
ret = false; |
| 24706 |
} |
| 24707 |
args = TREE_CHAIN (args); |
| 24708 |
} |
| 24709 |
while (args != NULL_TREE); |
| 24710 |
} |
| 24711 |
|
| 24712 |
else |
| 24713 |
{ |
| 24714 |
error ("attribute %<target%> argument not a string"); |
| 24715 |
return false; |
| 24716 |
} |
| 24717 |
|
| 24718 |
return ret; |
| 24719 |
} |
| 24720 |
|
| 24721 |
/* Print out the target options as a list for -mdebug=target. */ |
| 24722 |
|
| 24723 |
static void |
| 24724 |
rs6000_debug_target_options (tree args, const char *prefix) |
| 24725 |
{ |
| 24726 |
if (args == NULL_TREE) |
| 24727 |
fprintf (stderr, "%s<NULL>", prefix); |
| 24728 |
|
| 24729 |
else if (TREE_CODE (args) == STRING_CST) |
| 24730 |
{ |
| 24731 |
char *p = ASTRDUP (TREE_STRING_POINTER (args)); |
| 24732 |
char *q; |
| 24733 |
|
| 24734 |
while ((q = strtok (p, ",")) != NULL) |
| 24735 |
{ |
| 24736 |
p = NULL; |
| 24737 |
fprintf (stderr, "%s\"%s\"", prefix, q); |
| 24738 |
prefix = ", "; |
| 24739 |
} |
| 24740 |
} |
| 24741 |
|
| 24742 |
else if (TREE_CODE (args) == TREE_LIST) |
| 24743 |
{ |
| 24744 |
do |
| 24745 |
{ |
| 24746 |
tree value = TREE_VALUE (args); |
| 24747 |
if (value) |
| 24748 |
{ |
| 24749 |
rs6000_debug_target_options (value, prefix); |
| 24750 |
prefix = ", "; |
| 24751 |
} |
| 24752 |
args = TREE_CHAIN (args); |
| 24753 |
} |
| 24754 |
while (args != NULL_TREE); |
| 24755 |
} |
| 24756 |
|
| 24757 |
else |
| 24758 |
gcc_unreachable (); |
| 24759 |
|
| 24760 |
return; |
| 24761 |
} |
| 24762 |
|
| 24763 |
|
| 24764 |
/* Hook to validate attribute((target("..."))). */ |
| 24765 |
|
| 24766 |
static bool |
| 24767 |
rs6000_valid_attribute_p (tree fndecl, |
| 24768 |
tree ARG_UNUSED (name), |
| 24769 |
tree args, |
| 24770 |
int flags) |
| 24771 |
{ |
| 24772 |
struct cl_target_option cur_target; |
| 24773 |
bool ret; |
| 24774 |
tree old_optimize; |
| 24775 |
tree new_target, new_optimize; |
| 24776 |
tree func_optimize; |
| 24777 |
|
| 24778 |
gcc_assert ((fndecl != NULL_TREE) && (args != NULL_TREE)); |
| 24779 |
|
| 24780 |
if (TARGET_DEBUG_TARGET) |
| 24781 |
{ |
| 24782 |
tree tname = DECL_NAME (fndecl); |
| 24783 |
fprintf (stderr, "\n==================== rs6000_valid_attribute_p:\n"); |
| 24784 |
if (tname) |
| 24785 |
fprintf (stderr, "function: %.*s\n", |
| 24786 |
(int) IDENTIFIER_LENGTH (tname), |
| 24787 |
IDENTIFIER_POINTER (tname)); |
| 24788 |
else |
| 24789 |
fprintf (stderr, "function: unknown\n"); |
| 24790 |
|
| 24791 |
fprintf (stderr, "args:"); |
| 24792 |
rs6000_debug_target_options (args, " "); |
| 24793 |
fprintf (stderr, "\n"); |
| 24794 |
|
| 24795 |
if (flags) |
| 24796 |
fprintf (stderr, "flags: 0x%x\n", flags); |
| 24797 |
|
| 24798 |
fprintf (stderr, "--------------------\n"); |
| 24799 |
} |
| 24800 |
|
| 24801 |
/* attribute((target("default"))) does nothing, beyond |
| 24802 |
affecting multi-versioning. */ |
| 24803 |
if (TREE_VALUE (args) |
| 24804 |
&& TREE_CODE (TREE_VALUE (args)) == STRING_CST |
| 24805 |
&& TREE_CHAIN (args) == NULL_TREE |
| 24806 |
&& strcmp (TREE_STRING_POINTER (TREE_VALUE (args)), "default") == 0) |
| 24807 |
return true; |
| 24808 |
|
| 24809 |
old_optimize = build_optimization_node (&global_options, |
| 24810 |
&global_options_set); |
| 24811 |
func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl); |
| 24812 |
|
| 24813 |
/* If the function changed the optimization levels as well as setting target |
| 24814 |
options, start with the optimizations specified. */ |
| 24815 |
if (func_optimize && func_optimize != old_optimize) |
| 24816 |
cl_optimization_restore (&global_options, &global_options_set, |
| 24817 |
TREE_OPTIMIZATION (func_optimize)); |
| 24818 |
|
| 24819 |
/* The target attributes may also change some optimization flags, so update |
| 24820 |
the optimization options if necessary. */ |
| 24821 |
cl_target_option_save (&cur_target, &global_options, &global_options_set); |
| 24822 |
rs6000_cpu_index = rs6000_tune_index = -1; |
| 24823 |
ret = rs6000_inner_target_options (args, true); |
| 24824 |
|
| 24825 |
/* Set up any additional state. */ |
| 24826 |
if (ret) |
| 24827 |
{ |
| 24828 |
ret = rs6000_option_override_internal (false); |
| 24829 |
new_target = build_target_option_node (&global_options, |
| 24830 |
&global_options_set); |
| 24831 |
} |
| 24832 |
else |
| 24833 |
new_target = NULL; |
| 24834 |
|
| 24835 |
new_optimize = build_optimization_node (&global_options, |
| 24836 |
&global_options_set); |
| 24837 |
|
| 24838 |
if (!new_target) |
| 24839 |
ret = false; |
| 24840 |
|
| 24841 |
else if (fndecl) |
| 24842 |
{ |
| 24843 |
DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_target; |
| 24844 |
|
| 24845 |
if (old_optimize != new_optimize) |
| 24846 |
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize; |
| 24847 |
} |
| 24848 |
|
| 24849 |
cl_target_option_restore (&global_options, &global_options_set, &cur_target); |
| 24850 |
|
| 24851 |
if (old_optimize != new_optimize) |
| 24852 |
cl_optimization_restore (&global_options, &global_options_set, |
| 24853 |
TREE_OPTIMIZATION (old_optimize)); |
| 24854 |
|
| 24855 |
return ret; |
| 24856 |
} |
| 24857 |
|
| 24858 |
|
| 24859 |
/* Hook to validate the current #pragma GCC target and set the state, and |
| 24860 |
update the macros based on what was changed. If ARGS is NULL, then |
| 24861 |
POP_TARGET is used to reset the options. */ |
| 24862 |
|
| 24863 |
bool |
| 24864 |
rs6000_pragma_target_parse (tree args, tree pop_target) |
| 24865 |
{ |
| 24866 |
tree prev_tree = build_target_option_node (&global_options, |
| 24867 |
&global_options_set); |
| 24868 |
tree cur_tree; |
| 24869 |
struct cl_target_option *prev_opt, *cur_opt; |
| 24870 |
HOST_WIDE_INT prev_flags, cur_flags, diff_flags; |
| 24871 |
|
| 24872 |
if (TARGET_DEBUG_TARGET) |
| 24873 |
{ |
| 24874 |
fprintf (stderr, "\n==================== rs6000_pragma_target_parse\n"); |
| 24875 |
fprintf (stderr, "args:"); |
| 24876 |
rs6000_debug_target_options (args, " "); |
| 24877 |
fprintf (stderr, "\n"); |
| 24878 |
|
| 24879 |
if (pop_target) |
| 24880 |
{ |
| 24881 |
fprintf (stderr, "pop_target:\n"); |
| 24882 |
debug_tree (pop_target); |
| 24883 |
} |
| 24884 |
else |
| 24885 |
fprintf (stderr, "pop_target: <NULL>\n"); |
| 24886 |
|
| 24887 |
fprintf (stderr, "--------------------\n"); |
| 24888 |
} |
| 24889 |
|
| 24890 |
if (! args) |
| 24891 |
{ |
| 24892 |
cur_tree = ((pop_target) |
| 24893 |
? pop_target |
| 24894 |
: target_option_default_node); |
| 24895 |
cl_target_option_restore (&global_options, &global_options_set, |
| 24896 |
TREE_TARGET_OPTION (cur_tree)); |
| 24897 |
} |
| 24898 |
else |
| 24899 |
{ |
| 24900 |
rs6000_cpu_index = rs6000_tune_index = -1; |
| 24901 |
if (!rs6000_inner_target_options (args, false) |
| 24902 |
|| !rs6000_option_override_internal (false) |
| 24903 |
|| (cur_tree = build_target_option_node (&global_options, |
| 24904 |
&global_options_set)) |
| 24905 |
== NULL_TREE) |
| 24906 |
{ |
| 24907 |
if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET) |
| 24908 |
fprintf (stderr, "invalid pragma\n"); |
| 24909 |
|
| 24910 |
return false; |
| 24911 |
} |
| 24912 |
} |
| 24913 |
|
| 24914 |
target_option_current_node = cur_tree; |
| 24915 |
rs6000_activate_target_options (target_option_current_node); |
| 24916 |
|
| 24917 |
/* If we have the preprocessor linked in (i.e. C or C++ languages), possibly |
| 24918 |
change the macros that are defined. */ |
| 24919 |
if (rs6000_target_modify_macros_ptr) |
| 24920 |
{ |
| 24921 |
prev_opt = TREE_TARGET_OPTION (prev_tree); |
| 24922 |
prev_flags = prev_opt->x_rs6000_isa_flags; |
| 24923 |
|
| 24924 |
cur_opt = TREE_TARGET_OPTION (cur_tree); |
| 24925 |
cur_flags = cur_opt->x_rs6000_isa_flags; |
| 24926 |
|
| 24927 |
diff_flags = (prev_flags ^ cur_flags); |
| 24928 |
|
| 24929 |
if (diff_flags != 0) |
| 24930 |
{ |
| 24931 |
/* Delete old macros. */ |
| 24932 |
rs6000_target_modify_macros_ptr (false, |
| 24933 |
prev_flags & diff_flags); |
| 24934 |
|
| 24935 |
/* Define new macros. */ |
| 24936 |
rs6000_target_modify_macros_ptr (true, |
| 24937 |
cur_flags & diff_flags); |
| 24938 |
} |
| 24939 |
} |
| 24940 |
|
| 24941 |
return true; |
| 24942 |
} |
| 24943 |
|
| 24944 |
|
| 24945 |
/* Remember the last target of rs6000_set_current_function. */ |
| 24946 |
static GTY(()) tree rs6000_previous_fndecl; |
| 24947 |
|
| 24948 |
/* Restore target's globals from NEW_TREE and invalidate the |
| 24949 |
rs6000_previous_fndecl cache. */ |
| 24950 |
|
| 24951 |
void |
| 24952 |
rs6000_activate_target_options (tree new_tree) |
| 24953 |
{ |
| 24954 |
cl_target_option_restore (&global_options, &global_options_set, |
| 24955 |
TREE_TARGET_OPTION (new_tree)); |
| 24956 |
if (TREE_TARGET_GLOBALS (new_tree)) |
| 24957 |
restore_target_globals (TREE_TARGET_GLOBALS (new_tree)); |
| 24958 |
else if (new_tree == target_option_default_node) |
| 24959 |
restore_target_globals (&default_target_globals); |
| 24960 |
else |
| 24961 |
TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts (); |
| 24962 |
rs6000_previous_fndecl = NULL_TREE; |
| 24963 |
} |
| 24964 |
|
| 24965 |
/* Establish appropriate back-end context for processing the function |
| 24966 |
FNDECL. The argument might be NULL to indicate processing at top |
| 24967 |
level, outside of any function scope. */ |
| 24968 |
static void |
| 24969 |
rs6000_set_current_function (tree fndecl) |
| 24970 |
{ |
| 24971 |
if (TARGET_DEBUG_TARGET) |
| 24972 |
{ |
| 24973 |
fprintf (stderr, "\n==================== rs6000_set_current_function"); |
| 24974 |
|
| 24975 |
if (fndecl) |
| 24976 |
fprintf (stderr, ", fndecl %s (%p)", |
| 24977 |
(DECL_NAME (fndecl) |
| 24978 |
? IDENTIFIER_POINTER (DECL_NAME (fndecl)) |
| 24979 |
: "<unknown>"), (void *)fndecl); |
| 24980 |
|
| 24981 |
if (rs6000_previous_fndecl) |
| 24982 |
fprintf (stderr, ", prev_fndecl (%p)", (void *)rs6000_previous_fndecl); |
| 24983 |
|
| 24984 |
fprintf (stderr, "\n"); |
| 24985 |
} |
| 24986 |
|
| 24987 |
/* Only change the context if the function changes. This hook is called |
| 24988 |
several times in the course of compiling a function, and we don't want to |
| 24989 |
slow things down too much or call target_reinit when it isn't safe. */ |
| 24990 |
if (fndecl == rs6000_previous_fndecl) |
| 24991 |
return; |
| 24992 |
|
| 24993 |
tree old_tree; |
| 24994 |
if (rs6000_previous_fndecl == NULL_TREE) |
| 24995 |
old_tree = target_option_current_node; |
| 24996 |
else if (DECL_FUNCTION_SPECIFIC_TARGET (rs6000_previous_fndecl)) |
| 24997 |
old_tree = DECL_FUNCTION_SPECIFIC_TARGET (rs6000_previous_fndecl); |
| 24998 |
else |
| 24999 |
old_tree = target_option_default_node; |
| 25000 |
|
| 25001 |
tree new_tree; |
| 25002 |
if (fndecl == NULL_TREE) |
| 25003 |
{ |
| 25004 |
if (old_tree != target_option_current_node) |
| 25005 |
new_tree = target_option_current_node; |
| 25006 |
else |
| 25007 |
new_tree = NULL_TREE; |
| 25008 |
} |
| 25009 |
else |
| 25010 |
{ |
| 25011 |
new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); |
| 25012 |
if (new_tree == NULL_TREE) |
| 25013 |
new_tree = target_option_default_node; |
| 25014 |
} |
| 25015 |
|
| 25016 |
if (TARGET_DEBUG_TARGET) |
| 25017 |
{ |
| 25018 |
if (new_tree) |
| 25019 |
{ |
| 25020 |
fprintf (stderr, "\nnew fndecl target specific options:\n"); |
| 25021 |
debug_tree (new_tree); |
| 25022 |
} |
| 25023 |
|
| 25024 |
if (old_tree) |
| 25025 |
{ |
| 25026 |
fprintf (stderr, "\nold fndecl target specific options:\n"); |
| 25027 |
debug_tree (old_tree); |
| 25028 |
} |
| 25029 |
|
| 25030 |
if (old_tree != NULL_TREE || new_tree != NULL_TREE) |
| 25031 |
fprintf (stderr, "--------------------\n"); |
| 25032 |
} |
| 25033 |
|
| 25034 |
if (new_tree && old_tree != new_tree) |
| 25035 |
rs6000_activate_target_options (new_tree); |
| 25036 |
|
| 25037 |
if (fndecl) |
| 25038 |
rs6000_previous_fndecl = fndecl; |
| 25039 |
} |
| 25040 |
|
| 25041 |
|
| 25042 |
/* Save the current options */ |
| 25043 |
|
| 25044 |
static void |
| 25045 |
rs6000_function_specific_save (struct cl_target_option *ptr, |
| 25046 |
struct gcc_options *opts, |
| 25047 |
struct gcc_options */* opts_set */) |
| 25048 |
{ |
| 25049 |
ptr->x_rs6000_isa_flags = opts->x_rs6000_isa_flags; |
| 25050 |
ptr->x_rs6000_isa_flags_explicit = opts->x_rs6000_isa_flags_explicit; |
| 25051 |
} |
| 25052 |
|
| 25053 |
/* Restore the current options */ |
| 25054 |
|
| 25055 |
static void |
| 25056 |
rs6000_function_specific_restore (struct gcc_options *opts, |
| 25057 |
struct gcc_options */* opts_set */, |
| 25058 |
struct cl_target_option *ptr) |
| 25059 |
|
| 25060 |
{ |
| 25061 |
opts->x_rs6000_isa_flags = ptr->x_rs6000_isa_flags; |
| 25062 |
opts->x_rs6000_isa_flags_explicit = ptr->x_rs6000_isa_flags_explicit; |
| 25063 |
(void) rs6000_option_override_internal (false); |
| 25064 |
} |
| 25065 |
|
| 25066 |
/* Print the current options */ |
| 25067 |
|
| 25068 |
static void |
| 25069 |
rs6000_function_specific_print (FILE *file, int indent, |
| 25070 |
struct cl_target_option *ptr) |
| 25071 |
{ |
| 25072 |
rs6000_print_isa_options (file, indent, "Isa options set", |
| 25073 |
ptr->x_rs6000_isa_flags); |
| 25074 |
|
| 25075 |
rs6000_print_isa_options (file, indent, "Isa options explicit", |
| 25076 |
ptr->x_rs6000_isa_flags_explicit); |
| 25077 |
} |
| 25078 |
|
| 25079 |
/* Helper function to print the current isa or misc options on a line. */ |
| 25080 |
|
| 25081 |
static void |
| 25082 |
rs6000_print_options_internal (FILE *file, |
| 25083 |
int indent, |
| 25084 |
const char *string, |
| 25085 |
HOST_WIDE_INT flags, |
| 25086 |
const char *prefix, |
| 25087 |
const struct rs6000_opt_mask *opts, |
| 25088 |
size_t num_elements) |
| 25089 |
{ |
| 25090 |
size_t i; |
| 25091 |
size_t start_column = 0; |
| 25092 |
size_t cur_column; |
| 25093 |
size_t max_column = 120; |
| 25094 |
size_t prefix_len = strlen (prefix); |
| 25095 |
size_t comma_len = 0; |
| 25096 |
const char *comma = ""; |
| 25097 |
|
| 25098 |
if (indent) |
| 25099 |
start_column += fprintf (file, "%*s", indent, ""); |
| 25100 |
|
| 25101 |
if (!flags) |
| 25102 |
{ |
| 25103 |
fprintf (stderr, DEBUG_FMT_S, string, "<none>"); |
| 25104 |
return; |
| 25105 |
} |
| 25106 |
|
| 25107 |
start_column += fprintf (stderr, DEBUG_FMT_WX, string, flags); |
| 25108 |
|
| 25109 |
/* Print the various mask options. */ |
| 25110 |
cur_column = start_column; |
| 25111 |
for (i = 0; i < num_elements; i++) |
| 25112 |
{ |
| 25113 |
bool invert = opts[i].invert; |
| 25114 |
const char *name = opts[i].name; |
| 25115 |
const char *no_str = ""; |
| 25116 |
HOST_WIDE_INT mask = opts[i].mask; |
| 25117 |
size_t len = comma_len + prefix_len + strlen (name); |
| 25118 |
|
| 25119 |
if (!invert) |
| 25120 |
{ |
| 25121 |
if ((flags & mask) == 0) |
| 25122 |
{ |
| 25123 |
no_str = "no-"; |
| 25124 |
len += strlen ("no-"); |
| 25125 |
} |
| 25126 |
|
| 25127 |
flags &= ~mask; |
| 25128 |
} |
| 25129 |
|
| 25130 |
else |
| 25131 |
{ |
| 25132 |
if ((flags & mask) != 0) |
| 25133 |
{ |
| 25134 |
no_str = "no-"; |
| 25135 |
len += strlen ("no-"); |
| 25136 |
} |
| 25137 |
|
| 25138 |
flags |= mask; |
| 25139 |
} |
| 25140 |
|
| 25141 |
cur_column += len; |
| 25142 |
if (cur_column > max_column) |
| 25143 |
{ |
| 25144 |
fprintf (stderr, ", \\\n%*s", (int)start_column, ""); |
| 25145 |
cur_column = start_column + len; |
| 25146 |
comma = ""; |
| 25147 |
} |
| 25148 |
|
| 25149 |
fprintf (file, "%s%s%s%s", comma, prefix, no_str, name); |
| 25150 |
comma = ", "; |
| 25151 |
comma_len = strlen (", "); |
| 25152 |
} |
| 25153 |
|
| 25154 |
fputs ("\n", file); |
| 25155 |
} |
| 25156 |
|
| 25157 |
/* Helper function to print the current isa options on a line. */ |
| 25158 |
|
| 25159 |
static void |
| 25160 |
rs6000_print_isa_options (FILE *file, int indent, const char *string, |
| 25161 |
HOST_WIDE_INT flags) |
| 25162 |
{ |
| 25163 |
rs6000_print_options_internal (file, indent, string, flags, "-m", |
| 25164 |
&rs6000_opt_masks[0], |
| 25165 |
ARRAY_SIZE (rs6000_opt_masks)); |
| 25166 |
} |
| 25167 |
|
| 25168 |
/* If the user used -mno-vsx, we need turn off all of the implicit ISA 2.06, |
| 25169 |
2.07, and 3.0 options that relate to the vector unit (-mdirect-move, |
| 25170 |
-mupper-regs-df, etc.). |
| 25171 |
|
| 25172 |
This function does not handle explicit options such as the user specifying |
| 25173 |
-mdirect-move. These are handled in rs6000_option_override_internal, and |
| 25174 |
the appropriate error is given if needed. |
| 25175 |
|
| 25176 |
We return a mask of all of the implicit options that should not be enabled |
| 25177 |
by default. */ |
| 25178 |
|
| 25179 |
static HOST_WIDE_INT |
| 25180 |
rs6000_disable_incompatible_switches (void) |
| 25181 |
{ |
| 25182 |
HOST_WIDE_INT ignore_masks = rs6000_isa_flags_explicit; |
| 25183 |
size_t i, j; |
| 25184 |
|
| 25185 |
static const struct { |
| 25186 |
const HOST_WIDE_INT no_flag; /* flag explicitly turned off. */ |
| 25187 |
const HOST_WIDE_INT dep_flags; /* flags that depend on this option. */ |
| 25188 |
const char *const name; /* name of the switch. */ |
| 25189 |
} flags[] = { |
| 25190 |
{ OPTION_MASK_VSX, OTHER_VSX_VECTOR_MASKS, "vsx" }, |
| 25191 |
{ OPTION_MASK_ALTIVEC, OTHER_ALTIVEC_MASKS, "altivec" }, |
| 25192 |
}; |
| 25193 |
|
| 25194 |
for (i = 0; i < ARRAY_SIZE (flags); i++) |
| 25195 |
{ |
| 25196 |
HOST_WIDE_INT no_flag = flags[i].no_flag; |
| 25197 |
|
| 25198 |
if ((rs6000_isa_flags & no_flag) == 0 |
| 25199 |
&& (rs6000_isa_flags_explicit & no_flag) != 0) |
| 25200 |
{ |
| 25201 |
HOST_WIDE_INT dep_flags = flags[i].dep_flags; |
| 25202 |
HOST_WIDE_INT set_flags = (rs6000_isa_flags_explicit |
| 25203 |
& rs6000_isa_flags |
| 25204 |
& dep_flags); |
| 25205 |
|
| 25206 |
if (set_flags) |
| 25207 |
{ |
| 25208 |
for (j = 0; j < ARRAY_SIZE (rs6000_opt_masks); j++) |
| 25209 |
if ((set_flags & rs6000_opt_masks[j].mask) != 0) |
| 25210 |
{ |
| 25211 |
set_flags &= ~rs6000_opt_masks[j].mask; |
| 25212 |
error ("%<-mno-%s%> turns off %<-m%s%>", |
| 25213 |
flags[i].name, |
| 25214 |
rs6000_opt_masks[j].name); |
| 25215 |
} |
| 25216 |
|
| 25217 |
gcc_assert (!set_flags); |
| 25218 |
} |
| 25219 |
|
| 25220 |
rs6000_isa_flags &= ~dep_flags; |
| 25221 |
ignore_masks |= no_flag | dep_flags; |
| 25222 |
} |
| 25223 |
} |
| 25224 |
|
| 25225 |
return ignore_masks; |
| 25226 |
} |
| 25227 |
|
| 25228 |
|
| 25229 |
/* Helper function for printing the function name when debugging. */ |
| 25230 |
|
| 25231 |
static const char * |
| 25232 |
get_decl_name (tree fn) |
| 25233 |
{ |
| 25234 |
tree name; |
| 25235 |
|
| 25236 |
if (!fn) |
| 25237 |
return "<null>"; |
| 25238 |
|
| 25239 |
name = DECL_NAME (fn); |
| 25240 |
if (!name) |
| 25241 |
return "<no-name>"; |
| 25242 |
|
| 25243 |
return IDENTIFIER_POINTER (name); |
| 25244 |
} |
| 25245 |
|
| 25246 |
/* Return the clone id of the target we are compiling code for in a target |
| 25247 |
clone. The clone id is ordered from 0 (default) to CLONE_MAX-1 and gives |
| 25248 |
the priority list for the target clones (ordered from lowest to |
| 25249 |
highest). */ |
| 25250 |
|
| 25251 |
static int |
| 25252 |
rs6000_clone_priority (tree fndecl) |
| 25253 |
{ |
| 25254 |
tree fn_opts = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); |
| 25255 |
HOST_WIDE_INT isa_masks; |
| 25256 |
int ret = CLONE_DEFAULT; |
| 25257 |
tree attrs = lookup_attribute ("target", DECL_ATTRIBUTES (fndecl)); |
| 25258 |
const char *attrs_str = NULL; |
| 25259 |
|
| 25260 |
attrs = TREE_VALUE (TREE_VALUE (attrs)); |
| 25261 |
attrs_str = TREE_STRING_POINTER (attrs); |
| 25262 |
|
| 25263 |
/* Return priority zero for default function. Return the ISA needed for the |
| 25264 |
function if it is not the default. */ |
| 25265 |
if (strcmp (attrs_str, "default") != 0) |
| 25266 |
{ |
| 25267 |
if (fn_opts == NULL_TREE) |
| 25268 |
fn_opts = target_option_default_node; |
| 25269 |
|
| 25270 |
if (!fn_opts || !TREE_TARGET_OPTION (fn_opts)) |
| 25271 |
isa_masks = rs6000_isa_flags; |
| 25272 |
else |
| 25273 |
isa_masks = TREE_TARGET_OPTION (fn_opts)->x_rs6000_isa_flags; |
| 25274 |
|
| 25275 |
for (ret = CLONE_MAX - 1; ret != 0; ret--) |
| 25276 |
if ((rs6000_clone_map[ret].isa_mask & isa_masks) != 0) |
| 25277 |
break; |
| 25278 |
} |
| 25279 |
|
| 25280 |
if (TARGET_DEBUG_TARGET) |
| 25281 |
fprintf (stderr, "rs6000_get_function_version_priority (%s) => %d\n", |
| 25282 |
get_decl_name (fndecl), ret); |
| 25283 |
|
| 25284 |
return ret; |
| 25285 |
} |
| 25286 |
|
| 25287 |
/* This compares the priority of target features in function DECL1 and DECL2. |
| 25288 |
It returns positive value if DECL1 is higher priority, negative value if |
| 25289 |
DECL2 is higher priority and 0 if they are the same. Note, priorities are |
| 25290 |
ordered from lowest (CLONE_DEFAULT) to highest (currently CLONE_ISA_3_0). */ |
| 25291 |
|
| 25292 |
static int |
| 25293 |
rs6000_compare_version_priority (tree decl1, tree decl2) |
| 25294 |
{ |
| 25295 |
int priority1 = rs6000_clone_priority (decl1); |
| 25296 |
int priority2 = rs6000_clone_priority (decl2); |
| 25297 |
int ret = priority1 - priority2; |
| 25298 |
|
| 25299 |
if (TARGET_DEBUG_TARGET) |
| 25300 |
fprintf (stderr, "rs6000_compare_version_priority (%s, %s) => %d\n", |
| 25301 |
get_decl_name (decl1), get_decl_name (decl2), ret); |
| 25302 |
|
| 25303 |
return ret; |
| 25304 |
} |
| 25305 |
|
| 25306 |
/* Make a dispatcher declaration for the multi-versioned function DECL. |
| 25307 |
Calls to DECL function will be replaced with calls to the dispatcher |
| 25308 |
by the front-end. Returns the decl of the dispatcher function. */ |
| 25309 |
|
| 25310 |
static tree |
| 25311 |
rs6000_get_function_versions_dispatcher (void *decl) |
| 25312 |
{ |
| 25313 |
tree fn = (tree) decl; |
| 25314 |
struct cgraph_node *node = NULL; |
| 25315 |
struct cgraph_node *default_node = NULL; |
| 25316 |
struct cgraph_function_version_info *node_v = NULL; |
| 25317 |
struct cgraph_function_version_info *first_v = NULL; |
| 25318 |
|
| 25319 |
tree dispatch_decl = NULL; |
| 25320 |
|
| 25321 |
struct cgraph_function_version_info *default_version_info = NULL; |
| 25322 |
gcc_assert (fn != NULL && DECL_FUNCTION_VERSIONED (fn)); |
| 25323 |
|
| 25324 |
if (TARGET_DEBUG_TARGET) |
| 25325 |
fprintf (stderr, "rs6000_get_function_versions_dispatcher (%s)\n", |
| 25326 |
get_decl_name (fn)); |
| 25327 |
|
| 25328 |
node = cgraph_node::get (fn); |
| 25329 |
gcc_assert (node != NULL); |
| 25330 |
|
| 25331 |
node_v = node->function_version (); |
| 25332 |
gcc_assert (node_v != NULL); |
| 25333 |
|
| 25334 |
if (node_v->dispatcher_resolver != NULL) |
| 25335 |
return node_v->dispatcher_resolver; |
| 25336 |
|
| 25337 |
/* Find the default version and make it the first node. */ |
| 25338 |
first_v = node_v; |
| 25339 |
/* Go to the beginning of the chain. */ |
| 25340 |
while (first_v->prev != NULL) |
| 25341 |
first_v = first_v->prev; |
| 25342 |
|
| 25343 |
default_version_info = first_v; |
| 25344 |
while (default_version_info != NULL) |
| 25345 |
{ |
| 25346 |
const tree decl2 = default_version_info->this_node->decl; |
| 25347 |
if (is_function_default_version (decl2)) |
| 25348 |
break; |
| 25349 |
default_version_info = default_version_info->next; |
| 25350 |
} |
| 25351 |
|
| 25352 |
/* If there is no default node, just return NULL. */ |
| 25353 |
if (default_version_info == NULL) |
| 25354 |
return NULL; |
| 25355 |
|
| 25356 |
/* Make default info the first node. */ |
| 25357 |
if (first_v != default_version_info) |
| 25358 |
{ |
| 25359 |
default_version_info->prev->next = default_version_info->next; |
| 25360 |
if (default_version_info->next) |
| 25361 |
default_version_info->next->prev = default_version_info->prev; |
| 25362 |
first_v->prev = default_version_info; |
| 25363 |
default_version_info->next = first_v; |
| 25364 |
default_version_info->prev = NULL; |
| 25365 |
} |
| 25366 |
|
| 25367 |
default_node = default_version_info->this_node; |
| 25368 |
|
| 25369 |
#ifndef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB |
| 25370 |
error_at (DECL_SOURCE_LOCATION (default_node->decl), |
| 25371 |
"%<target_clones%> attribute needs GLIBC (2.23 and newer) that " |
| 25372 |
"exports hardware capability bits"); |
| 25373 |
#else |
| 25374 |
|
| 25375 |
if (targetm.has_ifunc_p ()) |
| 25376 |
{ |
| 25377 |
struct cgraph_function_version_info *it_v = NULL; |
| 25378 |
struct cgraph_node *dispatcher_node = NULL; |
| 25379 |
struct cgraph_function_version_info *dispatcher_version_info = NULL; |
| 25380 |
|
| 25381 |
/* Right now, the dispatching is done via ifunc. */ |
| 25382 |
dispatch_decl = make_dispatcher_decl (default_node->decl); |
| 25383 |
TREE_NOTHROW (dispatch_decl) = TREE_NOTHROW (fn); |
| 25384 |
|
| 25385 |
dispatcher_node = cgraph_node::get_create (dispatch_decl); |
| 25386 |
gcc_assert (dispatcher_node != NULL); |
| 25387 |
dispatcher_node->dispatcher_function = 1; |
| 25388 |
dispatcher_version_info |
| 25389 |
= dispatcher_node->insert_new_function_version (); |
| 25390 |
dispatcher_version_info->next = default_version_info; |
| 25391 |
dispatcher_node->definition = 1; |
| 25392 |
|
| 25393 |
/* Set the dispatcher for all the versions. */ |
| 25394 |
it_v = default_version_info; |
| 25395 |
while (it_v != NULL) |
| 25396 |
{ |
| 25397 |
it_v->dispatcher_resolver = dispatch_decl; |
| 25398 |
it_v = it_v->next; |
| 25399 |
} |
| 25400 |
} |
| 25401 |
else |
| 25402 |
{ |
| 25403 |
error_at (DECL_SOURCE_LOCATION (default_node->decl), |
| 25404 |
"multiversioning needs %<ifunc%> which is not supported " |
| 25405 |
"on this target"); |
| 25406 |
} |
| 25407 |
#endif |
| 25408 |
|
| 25409 |
return dispatch_decl; |
| 25410 |
} |
| 25411 |
|
| 25412 |
/* Make the resolver function decl to dispatch the versions of a multi- |
| 25413 |
versioned function, DEFAULT_DECL. Create an empty basic block in the |
| 25414 |
resolver and store the pointer in EMPTY_BB. Return the decl of the resolver |
| 25415 |
function. */ |
| 25416 |
|
| 25417 |
static tree |
| 25418 |
make_resolver_func (const tree default_decl, |
| 25419 |
const tree dispatch_decl, |
| 25420 |
basic_block *empty_bb) |
| 25421 |
{ |
| 25422 |
/* Make the resolver function static. The resolver function returns |
| 25423 |
void *. */ |
| 25424 |
tree decl_name = clone_function_name (default_decl, "resolver"); |
| 25425 |
const char *resolver_name = IDENTIFIER_POINTER (decl_name); |
| 25426 |
tree type = build_function_type_list (ptr_type_node, NULL_TREE); |
| 25427 |
tree decl = build_fn_decl (resolver_name, type); |
| 25428 |
SET_DECL_ASSEMBLER_NAME (decl, decl_name); |
| 25429 |
|
| 25430 |
DECL_NAME (decl) = decl_name; |
| 25431 |
TREE_USED (decl) = 1; |
| 25432 |
DECL_ARTIFICIAL (decl) = 1; |
| 25433 |
DECL_IGNORED_P (decl) = 0; |
| 25434 |
TREE_PUBLIC (decl) = 0; |
| 25435 |
DECL_UNINLINABLE (decl) = 1; |
| 25436 |
|
| 25437 |
/* Resolver is not external, body is generated. */ |
| 25438 |
DECL_EXTERNAL (decl) = 0; |
| 25439 |
DECL_EXTERNAL (dispatch_decl) = 0; |
| 25440 |
|
| 25441 |
DECL_CONTEXT (decl) = NULL_TREE; |
| 25442 |
DECL_INITIAL (decl) = make_node (BLOCK); |
| 25443 |
DECL_STATIC_CONSTRUCTOR (decl) = 0; |
| 25444 |
|
| 25445 |
if (DECL_COMDAT_GROUP (default_decl) |
| 25446 |
|| TREE_PUBLIC (default_decl)) |
| 25447 |
{ |
| 25448 |
/* In this case, each translation unit with a call to this |
| 25449 |
versioned function will put out a resolver. Ensure it |
| 25450 |
is comdat to keep just one copy. */ |
| 25451 |
DECL_COMDAT (decl) = 1; |
| 25452 |
make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); |
| 25453 |
} |
| 25454 |
else |
| 25455 |
TREE_PUBLIC (dispatch_decl) = 0; |
| 25456 |
|
| 25457 |
/* Build result decl and add to function_decl. */ |
| 25458 |
tree t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node); |
| 25459 |
DECL_CONTEXT (t) = decl; |
| 25460 |
DECL_ARTIFICIAL (t) = 1; |
| 25461 |
DECL_IGNORED_P (t) = 1; |
| 25462 |
DECL_RESULT (decl) = t; |
| 25463 |
|
| 25464 |
gimplify_function_tree (decl); |
| 25465 |
push_cfun (DECL_STRUCT_FUNCTION (decl)); |
| 25466 |
*empty_bb = init_lowered_empty_function (decl, false, |
| 25467 |
profile_count::uninitialized ()); |
| 25468 |
|
| 25469 |
cgraph_node::add_new_function (decl, true); |
| 25470 |
symtab->call_cgraph_insertion_hooks (cgraph_node::get_create (decl)); |
| 25471 |
|
| 25472 |
pop_cfun (); |
| 25473 |
|
| 25474 |
/* Mark dispatch_decl as "ifunc" with resolver as resolver_name. */ |
| 25475 |
DECL_ATTRIBUTES (dispatch_decl) |
| 25476 |
= make_attribute ("ifunc", resolver_name, DECL_ATTRIBUTES (dispatch_decl)); |
| 25477 |
|
| 25478 |
cgraph_node::create_same_body_alias (dispatch_decl, decl); |
| 25479 |
|
| 25480 |
return decl; |
| 25481 |
} |
| 25482 |
|
| 25483 |
/* This adds a condition to the basic_block NEW_BB in function FUNCTION_DECL to |
| 25484 |
return a pointer to VERSION_DECL if we are running on a machine that |
| 25485 |
supports the index CLONE_ISA hardware architecture bits. This function will |
| 25486 |
be called during version dispatch to decide which function version to |
| 25487 |
execute. It returns the basic block at the end, to which more conditions |
| 25488 |
can be added. */ |
| 25489 |
|
| 25490 |
static basic_block |
| 25491 |
add_condition_to_bb (tree function_decl, tree version_decl, |
| 25492 |
int clone_isa, basic_block new_bb) |
| 25493 |
{ |
| 25494 |
push_cfun (DECL_STRUCT_FUNCTION (function_decl)); |
| 25495 |
|
| 25496 |
gcc_assert (new_bb != NULL); |
| 25497 |
gimple_seq gseq = bb_seq (new_bb); |
| 25498 |
|
| 25499 |
|
| 25500 |
tree convert_expr = build1 (CONVERT_EXPR, ptr_type_node, |
| 25501 |
build_fold_addr_expr (version_decl)); |
| 25502 |
tree result_var = create_tmp_var (ptr_type_node); |
| 25503 |
gimple *convert_stmt = gimple_build_assign (result_var, convert_expr); |
| 25504 |
gimple *return_stmt = gimple_build_return (result_var); |
| 25505 |
|
| 25506 |
if (clone_isa == CLONE_DEFAULT) |
| 25507 |
{ |
| 25508 |
gimple_seq_add_stmt (&gseq, convert_stmt); |
| 25509 |
gimple_seq_add_stmt (&gseq, return_stmt); |
| 25510 |
set_bb_seq (new_bb, gseq); |
| 25511 |
gimple_set_bb (convert_stmt, new_bb); |
| 25512 |
gimple_set_bb (return_stmt, new_bb); |
| 25513 |
pop_cfun (); |
| 25514 |
return new_bb; |
| 25515 |
} |
| 25516 |
|
| 25517 |
tree bool_zero = build_int_cst (bool_int_type_node, 0); |
| 25518 |
tree cond_var = create_tmp_var (bool_int_type_node); |
| 25519 |
tree predicate_decl = rs6000_builtin_decls[(int) RS6000_BIF_CPU_SUPPORTS]; |
| 25520 |
const char *arg_str = rs6000_clone_map[clone_isa].name; |
| 25521 |
tree predicate_arg = build_string_literal (strlen (arg_str) + 1, arg_str); |
| 25522 |
gimple *call_cond_stmt = gimple_build_call (predicate_decl, 1, predicate_arg); |
| 25523 |
gimple_call_set_lhs (call_cond_stmt, cond_var); |
| 25524 |
|
| 25525 |
gimple_set_block (call_cond_stmt, DECL_INITIAL (function_decl)); |
| 25526 |
gimple_set_bb (call_cond_stmt, new_bb); |
| 25527 |
gimple_seq_add_stmt (&gseq, call_cond_stmt); |
| 25528 |
|
| 25529 |
gimple *if_else_stmt = gimple_build_cond (NE_EXPR, cond_var, bool_zero, |
| 25530 |
NULL_TREE, NULL_TREE); |
| 25531 |
gimple_set_block (if_else_stmt, DECL_INITIAL (function_decl)); |
| 25532 |
gimple_set_bb (if_else_stmt, new_bb); |
| 25533 |
gimple_seq_add_stmt (&gseq, if_else_stmt); |
| 25534 |
|
| 25535 |
gimple_seq_add_stmt (&gseq, convert_stmt); |
| 25536 |
gimple_seq_add_stmt (&gseq, return_stmt); |
| 25537 |
set_bb_seq (new_bb, gseq); |
| 25538 |
|
| 25539 |
basic_block bb1 = new_bb; |
| 25540 |
edge e12 = split_block (bb1, if_else_stmt); |
| 25541 |
basic_block bb2 = e12->dest; |
| 25542 |
e12->flags &= ~EDGE_FALLTHRU; |
| 25543 |
e12->flags |= EDGE_TRUE_VALUE; |
| 25544 |
|
| 25545 |
edge e23 = split_block (bb2, return_stmt); |
| 25546 |
gimple_set_bb (convert_stmt, bb2); |
| 25547 |
gimple_set_bb (return_stmt, bb2); |
| 25548 |
|
| 25549 |
basic_block bb3 = e23->dest; |
| 25550 |
make_edge (bb1, bb3, EDGE_FALSE_VALUE); |
| 25551 |
|
| 25552 |
remove_edge (e23); |
| 25553 |
make_edge (bb2, EXIT_BLOCK_PTR_FOR_FN (cfun), 0); |
| 25554 |
|
| 25555 |
pop_cfun (); |
| 25556 |
return bb3; |
| 25557 |
} |
| 25558 |
|
| 25559 |
/* This function generates the dispatch function for multi-versioned functions. |
| 25560 |
DISPATCH_DECL is the function which will contain the dispatch logic. |
| 25561 |
FNDECLS are the function choices for dispatch, and is a tree chain. |
| 25562 |
EMPTY_BB is the basic block pointer in DISPATCH_DECL in which the dispatch |
| 25563 |
code is generated. */ |
| 25564 |
|
| 25565 |
static int |
| 25566 |
dispatch_function_versions (tree dispatch_decl, |
| 25567 |
void *fndecls_p, |
| 25568 |
basic_block *empty_bb) |
| 25569 |
{ |
| 25570 |
int ix; |
| 25571 |
tree ele; |
| 25572 |
vec<tree> *fndecls; |
| 25573 |
tree clones[CLONE_MAX]; |
| 25574 |
|
| 25575 |
if (TARGET_DEBUG_TARGET) |
| 25576 |
fputs ("dispatch_function_versions, top\n", stderr); |
| 25577 |
|
| 25578 |
gcc_assert (dispatch_decl != NULL |
| 25579 |
&& fndecls_p != NULL |
| 25580 |
&& empty_bb != NULL); |
| 25581 |
|
| 25582 |
/* fndecls_p is actually a vector. */ |
| 25583 |
fndecls = static_cast<vec<tree> *> (fndecls_p); |
| 25584 |
|
| 25585 |
/* At least one more version other than the default. */ |
| 25586 |
gcc_assert (fndecls->length () >= 2); |
| 25587 |
|
| 25588 |
/* The first version in the vector is the default decl. */ |
| 25589 |
memset ((void *) clones, '\0', sizeof (clones)); |
| 25590 |
clones[CLONE_DEFAULT] = (*fndecls)[0]; |
| 25591 |
|
| 25592 |
/* On the PowerPC, we do not need to call __builtin_cpu_init, which is a NOP |
| 25593 |
on the PowerPC (on the x86_64, it is not a NOP). The builtin function |
| 25594 |
__builtin_cpu_support ensures that the TOC fields are setup by requiring a |
| 25595 |
recent glibc. If we ever need to call __builtin_cpu_init, we would need |
| 25596 |
to insert the code here to do the call. */ |
| 25597 |
|
| 25598 |
for (ix = 1; fndecls->iterate (ix, &ele); ++ix) |
| 25599 |
{ |
| 25600 |
int priority = rs6000_clone_priority (ele); |
| 25601 |
if (!clones[priority]) |
| 25602 |
clones[priority] = ele; |
| 25603 |
} |
| 25604 |
|
| 25605 |
for (ix = CLONE_MAX - 1; ix >= 0; ix--) |
| 25606 |
if (clones[ix]) |
| 25607 |
{ |
| 25608 |
if (TARGET_DEBUG_TARGET) |
| 25609 |
fprintf (stderr, "dispatch_function_versions, clone %d, %s\n", |
| 25610 |
ix, get_decl_name (clones[ix])); |
| 25611 |
|
| 25612 |
*empty_bb = add_condition_to_bb (dispatch_decl, clones[ix], ix, |
| 25613 |
*empty_bb); |
| 25614 |
} |
| 25615 |
|
| 25616 |
return 0; |
| 25617 |
} |
| 25618 |
|
| 25619 |
/* Generate the dispatching code body to dispatch multi-versioned function |
| 25620 |
DECL. The target hook is called to process the "target" attributes and |
| 25621 |
provide the code to dispatch the right function at run-time. NODE points |
| 25622 |
to the dispatcher decl whose body will be created. */ |
| 25623 |
|
| 25624 |
static tree |
| 25625 |
rs6000_generate_version_dispatcher_body (void *node_p) |
| 25626 |
{ |
| 25627 |
tree resolver; |
| 25628 |
basic_block empty_bb; |
| 25629 |
struct cgraph_node *node = (cgraph_node *) node_p; |
| 25630 |
struct cgraph_function_version_info *ninfo = node->function_version (); |
| 25631 |
|
| 25632 |
if (ninfo->dispatcher_resolver) |
| 25633 |
return ninfo->dispatcher_resolver; |
| 25634 |
|
| 25635 |
/* node is going to be an alias, so remove the finalized bit. */ |
| 25636 |
node->definition = false; |
| 25637 |
|
| 25638 |
/* The first version in the chain corresponds to the default version. */ |
| 25639 |
ninfo->dispatcher_resolver = resolver |
| 25640 |
= make_resolver_func (ninfo->next->this_node->decl, node->decl, &empty_bb); |
| 25641 |
|
| 25642 |
if (TARGET_DEBUG_TARGET) |
| 25643 |
fprintf (stderr, "rs6000_get_function_versions_dispatcher, %s\n", |
| 25644 |
get_decl_name (resolver)); |
| 25645 |
|
| 25646 |
push_cfun (DECL_STRUCT_FUNCTION (resolver)); |
| 25647 |
auto_vec<tree, 2> fn_ver_vec; |
| 25648 |
|
| 25649 |
for (struct cgraph_function_version_info *vinfo = ninfo->next; |
| 25650 |
vinfo; |
| 25651 |
vinfo = vinfo->next) |
| 25652 |
{ |
| 25653 |
struct cgraph_node *version = vinfo->this_node; |
| 25654 |
/* Check for virtual functions here again, as by this time it should |
| 25655 |
have been determined if this function needs a vtable index or |
| 25656 |
not. This happens for methods in derived classes that override |
| 25657 |
virtual methods in base classes but are not explicitly marked as |
| 25658 |
virtual. */ |
| 25659 |
if (DECL_VINDEX (version->decl)) |
| 25660 |
sorry ("Virtual function multiversioning not supported"); |
| 25661 |
|
| 25662 |
fn_ver_vec.safe_push (version->decl); |
| 25663 |
} |
| 25664 |
|
| 25665 |
dispatch_function_versions (resolver, &fn_ver_vec, &empty_bb); |
| 25666 |
cgraph_edge::rebuild_edges (); |
| 25667 |
pop_cfun (); |
| 25668 |
return resolver; |
| 25669 |
} |
| 25670 |
|
| 25671 |
/* Hook to decide if we need to scan function gimple statements to |
| 25672 |
collect target specific information for inlining, and update the |
| 25673 |
corresponding RS6000_FN_TARGET_INFO_* bit in INFO if we are able |
| 25674 |
to predict which ISA feature is used at this time. Return true |
| 25675 |
if we need to scan, otherwise return false. */ |
| 25676 |
|
| 25677 |
static bool |
| 25678 |
rs6000_need_ipa_fn_target_info (const_tree decl, |
| 25679 |
unsigned int &info ATTRIBUTE_UNUSED) |
| 25680 |
{ |
| 25681 |
tree target = DECL_FUNCTION_SPECIFIC_TARGET (decl); |
| 25682 |
if (!target) |
| 25683 |
target = target_option_default_node; |
| 25684 |
struct cl_target_option *opts = TREE_TARGET_OPTION (target); |
| 25685 |
|
| 25686 |
/* See PR102059, we only handle HTM for now, so will only do |
| 25687 |
the consequent scannings when HTM feature enabled. */ |
| 25688 |
if (opts->x_rs6000_isa_flags & OPTION_MASK_HTM) |
| 25689 |
return true; |
| 25690 |
|
| 25691 |
return false; |
| 25692 |
} |
| 25693 |
|
| 25694 |
/* Hook to update target specific information INFO for inlining by |
| 25695 |
checking the given STMT. Return false if we don't need to scan |
| 25696 |
any more, otherwise return true. */ |
| 25697 |
|
| 25698 |
static bool |
| 25699 |
rs6000_update_ipa_fn_target_info (unsigned int &info, const gimple *stmt) |
| 25700 |
{ |
| 25701 |
#ifndef HAVE_AS_POWER10_HTM |
| 25702 |
/* Assume inline asm can use any instruction features. */ |
| 25703 |
if (gimple_code (stmt) == GIMPLE_ASM) |
| 25704 |
{ |
| 25705 |
const char *asm_str = gimple_asm_string (as_a<const gasm *> (stmt)); |
| 25706 |
/* Ignore empty inline asm string. */ |
| 25707 |
if (strlen (asm_str) > 0) |
| 25708 |
/* Should set any bits we concerned, for now OPTION_MASK_HTM is |
| 25709 |
the only bit we care about. */ |
| 25710 |
info |= RS6000_FN_TARGET_INFO_HTM; |
| 25711 |
return false; |
| 25712 |
} |
| 25713 |
#endif |
| 25714 |
|
| 25715 |
if (gimple_code (stmt) == GIMPLE_CALL) |
| 25716 |
{ |
| 25717 |
tree fndecl = gimple_call_fndecl (stmt); |
| 25718 |
if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_MD)) |
| 25719 |
{ |
| 25720 |
enum rs6000_gen_builtins fcode |
| 25721 |
= (enum rs6000_gen_builtins) DECL_MD_FUNCTION_CODE (fndecl); |
| 25722 |
/* HTM bifs definitely exploit HTM insns. */ |
| 25723 |
if (bif_is_htm (rs6000_builtin_info[fcode])) |
| 25724 |
{ |
| 25725 |
info |= RS6000_FN_TARGET_INFO_HTM; |
| 25726 |
return false; |
| 25727 |
} |
| 25728 |
} |
| 25729 |
} |
| 25730 |
|
| 25731 |
return true; |
| 25732 |
} |
| 25733 |
|
| 25734 |
/* Hook to determine if one function can safely inline another. */ |
| 25735 |
|
| 25736 |
static bool |
| 25737 |
rs6000_can_inline_p (tree caller, tree callee) |
| 25738 |
{ |
| 25739 |
bool ret = false; |
| 25740 |
tree caller_tree = DECL_FUNCTION_SPECIFIC_TARGET (caller); |
| 25741 |
tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (callee); |
| 25742 |
|
| 25743 |
/* If the caller/callee has option attributes, then use them. |
| 25744 |
Otherwise, use the command line options. */ |
| 25745 |
if (!callee_tree) |
| 25746 |
callee_tree = target_option_default_node; |
| 25747 |
if (!caller_tree) |
| 25748 |
caller_tree = target_option_default_node; |
| 25749 |
|
| 25750 |
struct cl_target_option *callee_opts = TREE_TARGET_OPTION (callee_tree); |
| 25751 |
struct cl_target_option *caller_opts = TREE_TARGET_OPTION (caller_tree); |
| 25752 |
|
| 25753 |
HOST_WIDE_INT callee_isa = callee_opts->x_rs6000_isa_flags; |
| 25754 |
HOST_WIDE_INT caller_isa = caller_opts->x_rs6000_isa_flags; |
| 25755 |
HOST_WIDE_INT explicit_isa = callee_opts->x_rs6000_isa_flags_explicit; |
| 25756 |
|
| 25757 |
cgraph_node *callee_node = cgraph_node::get (callee); |
| 25758 |
if (ipa_fn_summaries && ipa_fn_summaries->get (callee_node) != NULL) |
| 25759 |
{ |
| 25760 |
unsigned int info = ipa_fn_summaries->get (callee_node)->target_info; |
| 25761 |
if ((info & RS6000_FN_TARGET_INFO_HTM) == 0) |
| 25762 |
{ |
| 25763 |
callee_isa &= ~OPTION_MASK_HTM; |
| 25764 |
explicit_isa &= ~OPTION_MASK_HTM; |
| 25765 |
} |
| 25766 |
} |
| 25767 |
|
| 25768 |
/* Ignore -mpower8-fusion, -mpower10-fusion and -msave-toc-indirect options |
| 25769 |
for inlining purposes. */ |
| 25770 |
HOST_WIDE_INT ignored_isas = (OPTION_MASK_P8_FUSION |
| 25771 |
| OPTION_MASK_P10_FUSION |
| 25772 |
| OPTION_MASK_SAVE_TOC_INDIRECT); |
| 25773 |
callee_isa &= ~ignored_isas; |
| 25774 |
explicit_isa &= ~ignored_isas; |
| 25775 |
|
| 25776 |
/* The callee's options must be a subset of the caller's options, i.e. |
| 25777 |
a vsx function may inline an altivec function, but a no-vsx function |
| 25778 |
must not inline a vsx function. However, for those options that the |
| 25779 |
callee has explicitly enabled or disabled, then we must enforce that |
| 25780 |
the callee's and caller's options match exactly; see PR70010. */ |
| 25781 |
if (((caller_isa & callee_isa) == callee_isa) |
| 25782 |
&& (caller_isa & explicit_isa) == (callee_isa & explicit_isa)) |
| 25783 |
ret = true; |
| 25784 |
|
| 25785 |
if (TARGET_DEBUG_TARGET) |
| 25786 |
fprintf (stderr, "rs6000_can_inline_p:, caller %s, callee %s, %s inline\n", |
| 25787 |
get_decl_name (caller), get_decl_name (callee), |
| 25788 |
(ret ? "can" : "cannot")); |
| 25789 |
|
| 25790 |
return ret; |
| 25791 |
} |
| 25792 |
|
| 25793 |
/* Allocate a stack temp and fixup the address so it meets the particular |
| 25794 |
memory requirements (either offetable or REG+REG addressing). */ |
| 25795 |
|
| 25796 |
rtx |
| 25797 |
rs6000_allocate_stack_temp (machine_mode mode, |
| 25798 |
bool offsettable_p, |
| 25799 |
bool reg_reg_p) |
| 25800 |
{ |
| 25801 |
rtx stack = assign_stack_temp (mode, GET_MODE_SIZE (mode)); |
| 25802 |
rtx addr = XEXP (stack, 0); |
| 25803 |
int strict_p = reload_completed; |
| 25804 |
|
| 25805 |
if (!legitimate_indirect_address_p (addr, strict_p)) |
| 25806 |
{ |
| 25807 |
if (offsettable_p |
| 25808 |
&& !rs6000_legitimate_offset_address_p (mode, addr, strict_p, true)) |
| 25809 |
stack = replace_equiv_address (stack, copy_addr_to_reg (addr)); |
| 25810 |
|
| 25811 |
else if (reg_reg_p && !legitimate_indexed_address_p (addr, strict_p)) |
| 25812 |
stack = replace_equiv_address (stack, copy_addr_to_reg (addr)); |
| 25813 |
} |
| 25814 |
|
| 25815 |
return stack; |
| 25816 |
} |
| 25817 |
|
| 25818 |
/* Given a memory reference, if it is not a reg or reg+reg addressing, |
| 25819 |
convert to such a form to deal with memory reference instructions |
| 25820 |
like STFIWX and LDBRX that only take reg+reg addressing. */ |
| 25821 |
|
| 25822 |
rtx |
| 25823 |
rs6000_force_indexed_or_indirect_mem (rtx x) |
| 25824 |
{ |
| 25825 |
machine_mode mode = GET_MODE (x); |
| 25826 |
|
| 25827 |
gcc_assert (MEM_P (x)); |
| 25828 |
if (can_create_pseudo_p () && !indexed_or_indirect_operand (x, mode)) |
| 25829 |
{ |
| 25830 |
rtx addr = XEXP (x, 0); |
| 25831 |
if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC) |
| 25832 |
{ |
| 25833 |
rtx reg = XEXP (addr, 0); |
| 25834 |
HOST_WIDE_INT size = GET_MODE_SIZE (GET_MODE (x)); |
| 25835 |
rtx size_rtx = GEN_INT ((GET_CODE (addr) == PRE_DEC) ? -size : size); |
| 25836 |
gcc_assert (REG_P (reg)); |
| 25837 |
emit_insn (gen_add3_insn (reg, reg, size_rtx)); |
| 25838 |
addr = reg; |
| 25839 |
} |
| 25840 |
else if (GET_CODE (addr) == PRE_MODIFY) |
| 25841 |
{ |
| 25842 |
rtx reg = XEXP (addr, 0); |
| 25843 |
rtx expr = XEXP (addr, 1); |
| 25844 |
gcc_assert (REG_P (reg)); |
| 25845 |
gcc_assert (GET_CODE (expr) == PLUS); |
| 25846 |
emit_insn (gen_add3_insn (reg, XEXP (expr, 0), XEXP (expr, 1))); |
| 25847 |
addr = reg; |
| 25848 |
} |
| 25849 |
|
| 25850 |
if (GET_CODE (addr) == PLUS) |
| 25851 |
{ |
| 25852 |
rtx op0 = XEXP (addr, 0); |
| 25853 |
rtx op1 = XEXP (addr, 1); |
| 25854 |
op0 = force_reg (Pmode, op0); |
| 25855 |
op1 = force_reg (Pmode, op1); |
| 25856 |
x = replace_equiv_address (x, gen_rtx_PLUS (Pmode, op0, op1)); |
| 25857 |
} |
| 25858 |
else |
| 25859 |
x = replace_equiv_address (x, force_reg (Pmode, addr)); |
| 25860 |
} |
| 25861 |
|
| 25862 |
return x; |
| 25863 |
} |
| 25864 |
|
| 25865 |
/* Implement TARGET_LEGITIMATE_CONSTANT_P. |
| 25866 |
|
| 25867 |
On the RS/6000, all integer constants are acceptable, most won't be valid |
| 25868 |
for particular insns, though. Only easy FP constants are acceptable. */ |
| 25869 |
|
| 25870 |
static bool |
| 25871 |
rs6000_legitimate_constant_p (machine_mode mode, rtx x) |
| 25872 |
{ |
| 25873 |
if (TARGET_ELF && tls_referenced_p (x)) |
| 25874 |
return false; |
| 25875 |
|
| 25876 |
if (CONST_DOUBLE_P (x)) |
| 25877 |
return easy_fp_constant (x, mode); |
| 25878 |
|
| 25879 |
if (GET_CODE (x) == CONST_VECTOR) |
| 25880 |
return easy_vector_constant (x, mode); |
| 25881 |
|
| 25882 |
return true; |
| 25883 |
} |
| 25884 |
|
| 25885 |
#if TARGET_AIX_OS |
| 25886 |
/* Implement TARGET_PRECOMPUTE_TLS_P. |
| 25887 |
|
| 25888 |
On the AIX, TLS symbols are in the TOC, which is maintained in the |
| 25889 |
constant pool. AIX TOC TLS symbols need to be pre-computed, but |
| 25890 |
must be considered legitimate constants. */ |
| 25891 |
|
| 25892 |
static bool |
| 25893 |
rs6000_aix_precompute_tls_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x) |
| 25894 |
{ |
| 25895 |
return tls_referenced_p (x); |
| 25896 |
} |
| 25897 |
#endif |
| 25898 |
|
| 25899 |
|
| 25900 |
/* Return TRUE iff the sequence ending in LAST sets the static chain. */ |
| 25901 |
|
| 25902 |
static bool |
| 25903 |
chain_already_loaded (rtx_insn *last) |
| 25904 |
{ |
| 25905 |
for (; last != NULL; last = PREV_INSN (last)) |
| 25906 |
{ |
| 25907 |
if (NONJUMP_INSN_P (last)) |
| 25908 |
{ |
| 25909 |
rtx patt = PATTERN (last); |
| 25910 |
|
| 25911 |
if (GET_CODE (patt) == SET) |
| 25912 |
{ |
| 25913 |
rtx lhs = XEXP (patt, 0); |
| 25914 |
|
| 25915 |
if (REG_P (lhs) && REGNO (lhs) == STATIC_CHAIN_REGNUM) |
| 25916 |
return true; |
| 25917 |
} |
| 25918 |
} |
| 25919 |
} |
| 25920 |
return false; |
| 25921 |
} |
| 25922 |
|
| 25923 |
/* Expand code to perform a call under the AIX or ELFv2 ABI. */ |
| 25924 |
|
| 25925 |
void |
| 25926 |
rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) |
| 25927 |
{ |
| 25928 |
rtx func = func_desc; |
| 25929 |
rtx toc_reg = gen_rtx_REG (Pmode, TOC_REGNUM); |
| 25930 |
rtx toc_load = NULL_RTX; |
| 25931 |
rtx toc_restore = NULL_RTX; |
| 25932 |
rtx func_addr; |
| 25933 |
rtx abi_reg = NULL_RTX; |
| 25934 |
rtx call[5]; |
| 25935 |
int n_call; |
| 25936 |
rtx insn; |
| 25937 |
bool is_pltseq_longcall; |
| 25938 |
|
| 25939 |
if (global_tlsarg) |
| 25940 |
tlsarg = global_tlsarg; |
| 25941 |
|
| 25942 |
/* Handle longcall attributes. */ |
| 25943 |
is_pltseq_longcall = false; |
| 25944 |
if ((INTVAL (cookie) & CALL_LONG) != 0 |
| 25945 |
&& GET_CODE (func_desc) == SYMBOL_REF) |
| 25946 |
{ |
| 25947 |
func = rs6000_longcall_ref (func_desc, tlsarg); |
| 25948 |
if (TARGET_PLTSEQ) |
| 25949 |
is_pltseq_longcall = true; |
| 25950 |
} |
| 25951 |
|
| 25952 |
/* Handle indirect calls. */ |
| 25953 |
if (!SYMBOL_REF_P (func) |
| 25954 |
|| (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (func))) |
| 25955 |
{ |
| 25956 |
if (!rs6000_pcrel_p ()) |
| 25957 |
{ |
| 25958 |
/* Save the TOC into its reserved slot before the call, |
| 25959 |
and prepare to restore it after the call. */ |
| 25960 |
rtx stack_toc_offset = GEN_INT (RS6000_TOC_SAVE_SLOT); |
| 25961 |
rtx stack_toc_unspec = gen_rtx_UNSPEC (Pmode, |
| 25962 |
gen_rtvec (1, stack_toc_offset), |
| 25963 |
UNSPEC_TOCSLOT); |
| 25964 |
toc_restore = gen_rtx_SET (toc_reg, stack_toc_unspec); |
| 25965 |
|
| 25966 |
/* Can we optimize saving the TOC in the prologue or |
| 25967 |
do we need to do it at every call? */ |
| 25968 |
if (TARGET_SAVE_TOC_INDIRECT && !cfun->calls_alloca) |
| 25969 |
cfun->machine->save_toc_in_prologue = true; |
| 25970 |
else |
| 25971 |
{ |
| 25972 |
rtx stack_ptr = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM); |
| 25973 |
rtx stack_toc_mem = gen_frame_mem (Pmode, |
| 25974 |
gen_rtx_PLUS (Pmode, stack_ptr, |
| 25975 |
stack_toc_offset)); |
| 25976 |
MEM_VOLATILE_P (stack_toc_mem) = 1; |
| 25977 |
if (is_pltseq_longcall) |
| 25978 |
{ |
| 25979 |
rtvec v = gen_rtvec (3, toc_reg, func_desc, tlsarg); |
| 25980 |
rtx mark_toc_reg = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 25981 |
emit_insn (gen_rtx_SET (stack_toc_mem, mark_toc_reg)); |
| 25982 |
} |
| 25983 |
else |
| 25984 |
emit_move_insn (stack_toc_mem, toc_reg); |
| 25985 |
} |
| 25986 |
} |
| 25987 |
|
| 25988 |
if (DEFAULT_ABI == ABI_ELFv2) |
| 25989 |
{ |
| 25990 |
/* A function pointer in the ELFv2 ABI is just a plain address, but |
| 25991 |
the ABI requires it to be loaded into r12 before the call. */ |
| 25992 |
func_addr = gen_rtx_REG (Pmode, 12); |
| 25993 |
emit_move_insn (func_addr, func); |
| 25994 |
abi_reg = func_addr; |
| 25995 |
/* Indirect calls via CTR are strongly preferred over indirect |
| 25996 |
calls via LR, so move the address there. Needed to mark |
| 25997 |
this insn for linker plt sequence editing too. */ |
| 25998 |
func_addr = gen_rtx_REG (Pmode, CTR_REGNO); |
| 25999 |
if (is_pltseq_longcall) |
| 26000 |
{ |
| 26001 |
rtvec v = gen_rtvec (3, abi_reg, func_desc, tlsarg); |
| 26002 |
rtx mark_func = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 26003 |
emit_insn (gen_rtx_SET (func_addr, mark_func)); |
| 26004 |
v = gen_rtvec (2, func_addr, func_desc); |
| 26005 |
func_addr = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 26006 |
} |
| 26007 |
else |
| 26008 |
emit_move_insn (func_addr, abi_reg); |
| 26009 |
} |
| 26010 |
else |
| 26011 |
{ |
| 26012 |
/* A function pointer under AIX is a pointer to a data area whose |
| 26013 |
first word contains the actual address of the function, whose |
| 26014 |
second word contains a pointer to its TOC, and whose third word |
| 26015 |
contains a value to place in the static chain register (r11). |
| 26016 |
Note that if we load the static chain, our "trampoline" need |
| 26017 |
not have any executable code. */ |
| 26018 |
|
| 26019 |
/* Load up address of the actual function. */ |
| 26020 |
func = force_reg (Pmode, func); |
| 26021 |
func_addr = gen_reg_rtx (Pmode); |
| 26022 |
emit_move_insn (func_addr, gen_rtx_MEM (Pmode, func)); |
| 26023 |
|
| 26024 |
/* Indirect calls via CTR are strongly preferred over indirect |
| 26025 |
calls via LR, so move the address there. */ |
| 26026 |
rtx ctr_reg = gen_rtx_REG (Pmode, CTR_REGNO); |
| 26027 |
emit_move_insn (ctr_reg, func_addr); |
| 26028 |
func_addr = ctr_reg; |
| 26029 |
|
| 26030 |
/* Prepare to load the TOC of the called function. Note that the |
| 26031 |
TOC load must happen immediately before the actual call so |
| 26032 |
that unwinding the TOC registers works correctly. See the |
| 26033 |
comment in frob_update_context. */ |
| 26034 |
rtx func_toc_offset = GEN_INT (GET_MODE_SIZE (Pmode)); |
| 26035 |
rtx func_toc_mem = gen_rtx_MEM (Pmode, |
| 26036 |
gen_rtx_PLUS (Pmode, func, |
| 26037 |
func_toc_offset)); |
| 26038 |
toc_load = gen_rtx_USE (VOIDmode, func_toc_mem); |
| 26039 |
|
| 26040 |
/* If we have a static chain, load it up. But, if the call was |
| 26041 |
originally direct, the 3rd word has not been written since no |
| 26042 |
trampoline has been built, so we ought not to load it, lest we |
| 26043 |
override a static chain value. */ |
| 26044 |
if (!(GET_CODE (func_desc) == SYMBOL_REF |
| 26045 |
&& SYMBOL_REF_FUNCTION_P (func_desc)) |
| 26046 |
&& TARGET_POINTERS_TO_NESTED_FUNCTIONS |
| 26047 |
&& !chain_already_loaded (get_current_sequence ()->next->last)) |
| 26048 |
{ |
| 26049 |
rtx sc_reg = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM); |
| 26050 |
rtx func_sc_offset = GEN_INT (2 * GET_MODE_SIZE (Pmode)); |
| 26051 |
rtx func_sc_mem = gen_rtx_MEM (Pmode, |
| 26052 |
gen_rtx_PLUS (Pmode, func, |
| 26053 |
func_sc_offset)); |
| 26054 |
emit_move_insn (sc_reg, func_sc_mem); |
| 26055 |
abi_reg = sc_reg; |
| 26056 |
} |
| 26057 |
} |
| 26058 |
} |
| 26059 |
else |
| 26060 |
{ |
| 26061 |
/* No TOC register needed for calls from PC-relative callers. */ |
| 26062 |
if (!rs6000_pcrel_p ()) |
| 26063 |
/* Direct calls use the TOC: for local calls, the callee will |
| 26064 |
assume the TOC register is set; for non-local calls, the |
| 26065 |
PLT stub needs the TOC register. */ |
| 26066 |
abi_reg = toc_reg; |
| 26067 |
func_addr = func; |
| 26068 |
} |
| 26069 |
|
| 26070 |
/* Create the call. */ |
| 26071 |
call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_addr), tlsarg); |
| 26072 |
if (value != NULL_RTX) |
| 26073 |
call[0] = gen_rtx_SET (value, call[0]); |
| 26074 |
call[1] = gen_rtx_USE (VOIDmode, cookie); |
| 26075 |
n_call = 2; |
| 26076 |
|
| 26077 |
if (toc_load) |
| 26078 |
call[n_call++] = toc_load; |
| 26079 |
if (toc_restore) |
| 26080 |
call[n_call++] = toc_restore; |
| 26081 |
|
| 26082 |
call[n_call++] = gen_hard_reg_clobber (Pmode, LR_REGNO); |
| 26083 |
|
| 26084 |
insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (n_call, call)); |
| 26085 |
insn = emit_call_insn (insn); |
| 26086 |
|
| 26087 |
/* Mention all registers defined by the ABI to hold information |
| 26088 |
as uses in CALL_INSN_FUNCTION_USAGE. */ |
| 26089 |
if (abi_reg) |
| 26090 |
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), abi_reg); |
| 26091 |
} |
| 26092 |
|
| 26093 |
/* Expand code to perform a sibling call under the AIX or ELFv2 ABI. */ |
| 26094 |
|
| 26095 |
void |
| 26096 |
rs6000_sibcall_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) |
| 26097 |
{ |
| 26098 |
rtx call[2]; |
| 26099 |
rtx insn; |
| 26100 |
rtx r12 = NULL_RTX; |
| 26101 |
rtx func_addr = func_desc; |
| 26102 |
|
| 26103 |
if (global_tlsarg) |
| 26104 |
tlsarg = global_tlsarg; |
| 26105 |
|
| 26106 |
/* Handle longcall attributes. */ |
| 26107 |
if (INTVAL (cookie) & CALL_LONG && SYMBOL_REF_P (func_desc)) |
| 26108 |
{ |
| 26109 |
/* PCREL can do a sibling call to a longcall function |
| 26110 |
because we don't need to restore the TOC register. */ |
| 26111 |
gcc_assert (rs6000_pcrel_p ()); |
| 26112 |
func_desc = rs6000_longcall_ref (func_desc, tlsarg); |
| 26113 |
} |
| 26114 |
else |
| 26115 |
gcc_assert (INTVAL (cookie) == 0); |
| 26116 |
|
| 26117 |
/* For ELFv2, r12 and CTR need to hold the function address |
| 26118 |
for an indirect call. */ |
| 26119 |
if (GET_CODE (func_desc) != SYMBOL_REF && DEFAULT_ABI == ABI_ELFv2) |
| 26120 |
{ |
| 26121 |
r12 = gen_rtx_REG (Pmode, 12); |
| 26122 |
emit_move_insn (r12, func_desc); |
| 26123 |
func_addr = gen_rtx_REG (Pmode, CTR_REGNO); |
| 26124 |
emit_move_insn (func_addr, r12); |
| 26125 |
} |
| 26126 |
|
| 26127 |
/* Create the call. */ |
| 26128 |
call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_addr), tlsarg); |
| 26129 |
if (value != NULL_RTX) |
| 26130 |
call[0] = gen_rtx_SET (value, call[0]); |
| 26131 |
|
| 26132 |
call[1] = simple_return_rtx; |
| 26133 |
|
| 26134 |
insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (2, call)); |
| 26135 |
insn = emit_call_insn (insn); |
| 26136 |
|
| 26137 |
/* Note use of the TOC register. */ |
| 26138 |
if (!rs6000_pcrel_p ()) |
| 26139 |
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), |
| 26140 |
gen_rtx_REG (Pmode, TOC_REGNUM)); |
| 26141 |
|
| 26142 |
/* Note use of r12. */ |
| 26143 |
if (r12) |
| 26144 |
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), r12); |
| 26145 |
} |
| 26146 |
|
| 26147 |
/* Expand code to perform a call under the SYSV4 ABI. */ |
| 26148 |
|
| 26149 |
void |
| 26150 |
rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) |
| 26151 |
{ |
| 26152 |
rtx func = func_desc; |
| 26153 |
rtx func_addr; |
| 26154 |
rtx call[4]; |
| 26155 |
rtx insn; |
| 26156 |
rtx abi_reg = NULL_RTX; |
| 26157 |
int n; |
| 26158 |
|
| 26159 |
if (global_tlsarg) |
| 26160 |
tlsarg = global_tlsarg; |
| 26161 |
|
| 26162 |
/* Handle longcall attributes. */ |
| 26163 |
if ((INTVAL (cookie) & CALL_LONG) != 0 |
| 26164 |
&& GET_CODE (func_desc) == SYMBOL_REF) |
| 26165 |
{ |
| 26166 |
func = rs6000_longcall_ref (func_desc, tlsarg); |
| 26167 |
/* If the longcall was implemented as an inline PLT call using |
| 26168 |
PLT unspecs then func will be REG:r11. If not, func will be |
| 26169 |
a pseudo reg. The inline PLT call sequence supports lazy |
| 26170 |
linking (and longcalls to functions in dlopen'd libraries). |
| 26171 |
The other style of longcalls don't. The lazy linking entry |
| 26172 |
to the dynamic symbol resolver requires r11 be the function |
| 26173 |
address (as it is for linker generated PLT stubs). Ensure |
| 26174 |
r11 stays valid to the bctrl by marking r11 used by the call. */ |
| 26175 |
if (TARGET_PLTSEQ) |
| 26176 |
abi_reg = func; |
| 26177 |
} |
| 26178 |
|
| 26179 |
/* Handle indirect calls. */ |
| 26180 |
if (GET_CODE (func) != SYMBOL_REF) |
| 26181 |
{ |
| 26182 |
func = force_reg (Pmode, func); |
| 26183 |
|
| 26184 |
/* Indirect calls via CTR are strongly preferred over indirect |
| 26185 |
calls via LR, so move the address there. That can't be left |
| 26186 |
to reload because we want to mark every instruction in an |
| 26187 |
inline PLT call sequence with a reloc, enabling the linker to |
| 26188 |
edit the sequence back to a direct call when that makes sense. */ |
| 26189 |
func_addr = gen_rtx_REG (Pmode, CTR_REGNO); |
| 26190 |
if (abi_reg) |
| 26191 |
{ |
| 26192 |
rtvec v = gen_rtvec (3, func, func_desc, tlsarg); |
| 26193 |
rtx mark_func = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 26194 |
emit_insn (gen_rtx_SET (func_addr, mark_func)); |
| 26195 |
v = gen_rtvec (2, func_addr, func_desc); |
| 26196 |
func_addr = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 26197 |
} |
| 26198 |
else |
| 26199 |
emit_move_insn (func_addr, func); |
| 26200 |
} |
| 26201 |
else |
| 26202 |
func_addr = func; |
| 26203 |
|
| 26204 |
/* Create the call. */ |
| 26205 |
call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_addr), tlsarg); |
| 26206 |
if (value != NULL_RTX) |
| 26207 |
call[0] = gen_rtx_SET (value, call[0]); |
| 26208 |
|
| 26209 |
call[1] = gen_rtx_USE (VOIDmode, cookie); |
| 26210 |
n = 2; |
| 26211 |
if (TARGET_SECURE_PLT |
| 26212 |
&& flag_pic |
| 26213 |
&& GET_CODE (func_addr) == SYMBOL_REF |
| 26214 |
&& !SYMBOL_REF_LOCAL_P (func_addr)) |
| 26215 |
call[n++] = gen_rtx_USE (VOIDmode, pic_offset_table_rtx); |
| 26216 |
|
| 26217 |
call[n++] = gen_hard_reg_clobber (Pmode, LR_REGNO); |
| 26218 |
|
| 26219 |
insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (n, call)); |
| 26220 |
insn = emit_call_insn (insn); |
| 26221 |
if (abi_reg) |
| 26222 |
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), abi_reg); |
| 26223 |
} |
| 26224 |
|
| 26225 |
/* Expand code to perform a sibling call under the SysV4 ABI. */ |
| 26226 |
|
| 26227 |
void |
| 26228 |
rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) |
| 26229 |
{ |
| 26230 |
rtx func = func_desc; |
| 26231 |
rtx func_addr; |
| 26232 |
rtx call[3]; |
| 26233 |
rtx insn; |
| 26234 |
rtx abi_reg = NULL_RTX; |
| 26235 |
|
| 26236 |
if (global_tlsarg) |
| 26237 |
tlsarg = global_tlsarg; |
| 26238 |
|
| 26239 |
/* Handle longcall attributes. */ |
| 26240 |
if ((INTVAL (cookie) & CALL_LONG) != 0 |
| 26241 |
&& GET_CODE (func_desc) == SYMBOL_REF) |
| 26242 |
{ |
| 26243 |
func = rs6000_longcall_ref (func_desc, tlsarg); |
| 26244 |
/* If the longcall was implemented as an inline PLT call using |
| 26245 |
PLT unspecs then func will be REG:r11. If not, func will be |
| 26246 |
a pseudo reg. The inline PLT call sequence supports lazy |
| 26247 |
linking (and longcalls to functions in dlopen'd libraries). |
| 26248 |
The other style of longcalls don't. The lazy linking entry |
| 26249 |
to the dynamic symbol resolver requires r11 be the function |
| 26250 |
address (as it is for linker generated PLT stubs). Ensure |
| 26251 |
r11 stays valid to the bctr by marking r11 used by the call. */ |
| 26252 |
if (TARGET_PLTSEQ) |
| 26253 |
abi_reg = func; |
| 26254 |
} |
| 26255 |
|
| 26256 |
/* Handle indirect calls. */ |
| 26257 |
if (GET_CODE (func) != SYMBOL_REF) |
| 26258 |
{ |
| 26259 |
func = force_reg (Pmode, func); |
| 26260 |
|
| 26261 |
/* Indirect sibcalls must go via CTR. That can't be left to |
| 26262 |
reload because we want to mark every instruction in an inline |
| 26263 |
PLT call sequence with a reloc, enabling the linker to edit |
| 26264 |
the sequence back to a direct call when that makes sense. */ |
| 26265 |
func_addr = gen_rtx_REG (Pmode, CTR_REGNO); |
| 26266 |
if (abi_reg) |
| 26267 |
{ |
| 26268 |
rtvec v = gen_rtvec (3, func, func_desc, tlsarg); |
| 26269 |
rtx mark_func = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 26270 |
emit_insn (gen_rtx_SET (func_addr, mark_func)); |
| 26271 |
v = gen_rtvec (2, func_addr, func_desc); |
| 26272 |
func_addr = gen_rtx_UNSPEC (Pmode, v, UNSPEC_PLTSEQ); |
| 26273 |
} |
| 26274 |
else |
| 26275 |
emit_move_insn (func_addr, func); |
| 26276 |
} |
| 26277 |
else |
| 26278 |
func_addr = func; |
| 26279 |
|
| 26280 |
/* Create the call. */ |
| 26281 |
call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_addr), tlsarg); |
| 26282 |
if (value != NULL_RTX) |
| 26283 |
call[0] = gen_rtx_SET (value, call[0]); |
| 26284 |
|
| 26285 |
call[1] = gen_rtx_USE (VOIDmode, cookie); |
| 26286 |
call[2] = simple_return_rtx; |
| 26287 |
|
| 26288 |
insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (3, call)); |
| 26289 |
insn = emit_call_insn (insn); |
| 26290 |
if (abi_reg) |
| 26291 |
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), abi_reg); |
| 26292 |
} |
| 26293 |
|
| 26294 |
#if TARGET_MACHO |
| 26295 |
|
| 26296 |
/* Expand code to perform a call under the Darwin ABI. |
| 26297 |
Modulo handling of mlongcall, this is much the same as sysv. |
| 26298 |
if/when the longcall optimisation is removed, we could drop this |
| 26299 |
code and use the sysv case (taking care to avoid the tls stuff). |
| 26300 |
|
| 26301 |
We can use this for sibcalls too, if needed. */ |
| 26302 |
|
| 26303 |
void |
| 26304 |
rs6000_call_darwin_1 (rtx value, rtx func_desc, rtx tlsarg, |
| 26305 |
rtx cookie, bool sibcall) |
| 26306 |
{ |
| 26307 |
rtx func = func_desc; |
| 26308 |
rtx func_addr; |
| 26309 |
rtx call[3]; |
| 26310 |
rtx insn; |
| 26311 |
int cookie_val = INTVAL (cookie); |
| 26312 |
bool make_island = false; |
| 26313 |
|
| 26314 |
/* Handle longcall attributes, there are two cases for Darwin: |
| 26315 |
1) Newer linkers are capable of synthesising any branch islands needed. |
| 26316 |
2) We need a helper branch island synthesised by the compiler. |
| 26317 |
The second case has mostly been retired and we don't use it for m64. |
| 26318 |
In fact, it's is an optimisation, we could just indirect as sysv does.. |
| 26319 |
... however, backwards compatibility for now. |
| 26320 |
If we're going to use this, then we need to keep the CALL_LONG bit set, |
| 26321 |
so that we can pick up the special insn form later. */ |
| 26322 |
if ((cookie_val & CALL_LONG) != 0 |
| 26323 |
&& GET_CODE (func_desc) == SYMBOL_REF) |
| 26324 |
{ |
| 26325 |
/* FIXME: the longcall opt should not hang off this flag, it is most |
| 26326 |
likely incorrect for kernel-mode code-generation. */ |
| 26327 |
if (darwin_symbol_stubs && TARGET_32BIT) |
| 26328 |
make_island = true; /* Do nothing yet, retain the CALL_LONG flag. */ |
| 26329 |
else |
| 26330 |
{ |
| 26331 |
/* The linker is capable of doing this, but the user explicitly |
| 26332 |
asked for -mlongcall, so we'll do the 'normal' version. */ |
| 26333 |
func = rs6000_longcall_ref (func_desc, NULL_RTX); |
| 26334 |
cookie_val &= ~CALL_LONG; /* Handled, zap it. */ |
| 26335 |
} |
| 26336 |
} |
| 26337 |
|
| 26338 |
/* Handle indirect calls. */ |
| 26339 |
if (GET_CODE (func) != SYMBOL_REF) |
| 26340 |
{ |
| 26341 |
func = force_reg (Pmode, func); |
| 26342 |
|
| 26343 |
/* Indirect calls via CTR are strongly preferred over indirect |
| 26344 |
calls via LR, and are required for indirect sibcalls, so move |
| 26345 |
the address there. */ |
| 26346 |
func_addr = gen_rtx_REG (Pmode, CTR_REGNO); |
| 26347 |
emit_move_insn (func_addr, func); |
| 26348 |
} |
| 26349 |
else |
| 26350 |
func_addr = func; |
| 26351 |
|
| 26352 |
/* Create the call. */ |
| 26353 |
call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_addr), tlsarg); |
| 26354 |
if (value != NULL_RTX) |
| 26355 |
call[0] = gen_rtx_SET (value, call[0]); |
| 26356 |
|
| 26357 |
call[1] = gen_rtx_USE (VOIDmode, GEN_INT (cookie_val)); |
| 26358 |
|
| 26359 |
if (sibcall) |
| 26360 |
call[2] = simple_return_rtx; |
| 26361 |
else |
| 26362 |
call[2] = gen_hard_reg_clobber (Pmode, LR_REGNO); |
| 26363 |
|
| 26364 |
insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (3, call)); |
| 26365 |
insn = emit_call_insn (insn); |
| 26366 |
/* Now we have the debug info in the insn, we can set up the branch island |
| 26367 |
if we're using one. */ |
| 26368 |
if (make_island) |
| 26369 |
{ |
| 26370 |
tree funname = get_identifier (XSTR (func_desc, 0)); |
| 26371 |
|
| 26372 |
if (no_previous_def (funname)) |
| 26373 |
{ |
| 26374 |
rtx label_rtx = gen_label_rtx (); |
| 26375 |
char *label_buf, temp_buf[256]; |
| 26376 |
ASM_GENERATE_INTERNAL_LABEL (temp_buf, "L", |
| 26377 |
CODE_LABEL_NUMBER (label_rtx)); |
| 26378 |
label_buf = temp_buf[0] == '*' ? temp_buf + 1 : temp_buf; |
| 26379 |
tree labelname = get_identifier (label_buf); |
| 26380 |
add_compiler_branch_island (labelname, funname, |
| 26381 |
insn_line ((const rtx_insn*)insn)); |
| 26382 |
} |
| 26383 |
} |
| 26384 |
} |
| 26385 |
#endif |
| 26386 |
|
| 26387 |
void |
| 26388 |
rs6000_call_darwin (rtx value ATTRIBUTE_UNUSED, rtx func_desc ATTRIBUTE_UNUSED, |
| 26389 |
rtx tlsarg ATTRIBUTE_UNUSED, rtx cookie ATTRIBUTE_UNUSED) |
| 26390 |
{ |
| 26391 |
#if TARGET_MACHO |
| 26392 |
rs6000_call_darwin_1 (value, func_desc, tlsarg, cookie, false); |
| 26393 |
#else |
| 26394 |
gcc_unreachable(); |
| 26395 |
#endif |
| 26396 |
} |
| 26397 |
|
| 26398 |
|
| 26399 |
void |
| 26400 |
rs6000_sibcall_darwin (rtx value ATTRIBUTE_UNUSED, rtx func_desc ATTRIBUTE_UNUSED, |
| 26401 |
rtx tlsarg ATTRIBUTE_UNUSED, rtx cookie ATTRIBUTE_UNUSED) |
| 26402 |
{ |
| 26403 |
#if TARGET_MACHO |
| 26404 |
rs6000_call_darwin_1 (value, func_desc, tlsarg, cookie, true); |
| 26405 |
#else |
| 26406 |
gcc_unreachable(); |
| 26407 |
#endif |
| 26408 |
} |
| 26409 |
|
| 26410 |
/* Return whether we should generate PC-relative code for FNDECL. */ |
| 26411 |
bool |
| 26412 |
rs6000_fndecl_pcrel_p (const_tree fndecl) |
| 26413 |
{ |
| 26414 |
if (DEFAULT_ABI != ABI_ELFv2) |
| 26415 |
return false; |
| 26416 |
|
| 26417 |
struct cl_target_option *opts = target_opts_for_fn (fndecl); |
| 26418 |
|
| 26419 |
return ((opts->x_rs6000_isa_flags & OPTION_MASK_PCREL) != 0 |
| 26420 |
&& TARGET_CMODEL == CMODEL_MEDIUM); |
| 26421 |
} |
| 26422 |
|
| 26423 |
/* Return whether we should generate PC-relative code for *FN. */ |
| 26424 |
bool |
| 26425 |
rs6000_function_pcrel_p (struct function *fn) |
| 26426 |
{ |
| 26427 |
if (DEFAULT_ABI != ABI_ELFv2) |
| 26428 |
return false; |
| 26429 |
|
| 26430 |
/* Optimize usual case. */ |
| 26431 |
if (fn == cfun) |
| 26432 |
return ((rs6000_isa_flags & OPTION_MASK_PCREL) != 0 |
| 26433 |
&& TARGET_CMODEL == CMODEL_MEDIUM); |
| 26434 |
|
| 26435 |
return rs6000_fndecl_pcrel_p (fn->decl); |
| 26436 |
} |
| 26437 |
|
| 26438 |
/* Return whether we should generate PC-relative code for the current |
| 26439 |
function. */ |
| 26440 |
bool |
| 26441 |
rs6000_pcrel_p () |
| 26442 |
{ |
| 26443 |
return (DEFAULT_ABI == ABI_ELFv2 |
| 26444 |
&& (rs6000_isa_flags & OPTION_MASK_PCREL) != 0 |
| 26445 |
&& TARGET_CMODEL == CMODEL_MEDIUM); |
| 26446 |
} |
| 26447 |
|
| 26448 |
|
| 26449 |
/* Given an address (ADDR), a mode (MODE), and what the format of the |
| 26450 |
non-prefixed address (NON_PREFIXED_FORMAT) is, return the instruction format |
| 26451 |
for the address. */ |
| 26452 |
|
| 26453 |
enum insn_form |
| 26454 |
address_to_insn_form (rtx addr, |
| 26455 |
machine_mode mode, |
| 26456 |
enum non_prefixed_form non_prefixed_format) |
| 26457 |
{ |
| 26458 |
/* Single register is easy. */ |
| 26459 |
if (REG_P (addr) || SUBREG_P (addr)) |
| 26460 |
return INSN_FORM_BASE_REG; |
| 26461 |
|
| 26462 |
/* If the non prefixed instruction format doesn't support offset addressing, |
| 26463 |
make sure only indexed addressing is allowed. |
| 26464 |
|
| 26465 |
We special case SDmode so that the register allocator does not try to move |
| 26466 |
SDmode through GPR registers, but instead uses the 32-bit integer load and |
| 26467 |
store instructions for the floating point registers. */ |
| 26468 |
if (non_prefixed_format == NON_PREFIXED_X || (mode == SDmode && TARGET_DFP)) |
| 26469 |
{ |
| 26470 |
if (GET_CODE (addr) != PLUS) |
| 26471 |
return INSN_FORM_BAD; |
| 26472 |
|
| 26473 |
rtx op0 = XEXP (addr, 0); |
| 26474 |
rtx op1 = XEXP (addr, 1); |
| 26475 |
if (!REG_P (op0) && !SUBREG_P (op0)) |
| 26476 |
return INSN_FORM_BAD; |
| 26477 |
|
| 26478 |
if (!REG_P (op1) && !SUBREG_P (op1)) |
| 26479 |
return INSN_FORM_BAD; |
| 26480 |
|
| 26481 |
return INSN_FORM_X; |
| 26482 |
} |
| 26483 |
|
| 26484 |
/* Deal with update forms. */ |
| 26485 |
if (GET_RTX_CLASS (GET_CODE (addr)) == RTX_AUTOINC) |
| 26486 |
return INSN_FORM_UPDATE; |
| 26487 |
|
| 26488 |
/* Handle PC-relative symbols and labels. Check for both local and |
| 26489 |
external symbols. Assume labels are always local. TLS symbols |
| 26490 |
are not PC-relative for rs6000. */ |
| 26491 |
if (TARGET_PCREL) |
| 26492 |
{ |
| 26493 |
if (LABEL_REF_P (addr)) |
| 26494 |
return INSN_FORM_PCREL_LOCAL; |
| 26495 |
|
| 26496 |
if (SYMBOL_REF_P (addr) && !SYMBOL_REF_TLS_MODEL (addr)) |
| 26497 |
{ |
| 26498 |
if (!SYMBOL_REF_LOCAL_P (addr)) |
| 26499 |
return INSN_FORM_PCREL_EXTERNAL; |
| 26500 |
else |
| 26501 |
return INSN_FORM_PCREL_LOCAL; |
| 26502 |
} |
| 26503 |
} |
| 26504 |
|
| 26505 |
if (GET_CODE (addr) == CONST) |
| 26506 |
addr = XEXP (addr, 0); |
| 26507 |
|
| 26508 |
/* Recognize LO_SUM addresses used with TOC and 32-bit addressing. */ |
| 26509 |
if (GET_CODE (addr) == LO_SUM) |
| 26510 |
return INSN_FORM_LO_SUM; |
| 26511 |
|
| 26512 |
/* Everything below must be an offset address of some form. */ |
| 26513 |
if (GET_CODE (addr) != PLUS) |
| 26514 |
return INSN_FORM_BAD; |
| 26515 |
|
| 26516 |
rtx op0 = XEXP (addr, 0); |
| 26517 |
rtx op1 = XEXP (addr, 1); |
| 26518 |
|
| 26519 |
/* Check for indexed addresses. */ |
| 26520 |
if (REG_P (op1) || SUBREG_P (op1)) |
| 26521 |
{ |
| 26522 |
if (REG_P (op0) || SUBREG_P (op0)) |
| 26523 |
return INSN_FORM_X; |
| 26524 |
|
| 26525 |
return INSN_FORM_BAD; |
| 26526 |
} |
| 26527 |
|
| 26528 |
if (!CONST_INT_P (op1)) |
| 26529 |
return INSN_FORM_BAD; |
| 26530 |
|
| 26531 |
HOST_WIDE_INT offset = INTVAL (op1); |
| 26532 |
if (!SIGNED_INTEGER_34BIT_P (offset)) |
| 26533 |
return INSN_FORM_BAD; |
| 26534 |
|
| 26535 |
/* Check for local and external PC-relative addresses. Labels are always |
| 26536 |
local. TLS symbols are not PC-relative for rs6000. */ |
| 26537 |
if (TARGET_PCREL) |
| 26538 |
{ |
| 26539 |
if (LABEL_REF_P (op0)) |
| 26540 |
return INSN_FORM_PCREL_LOCAL; |
| 26541 |
|
| 26542 |
if (SYMBOL_REF_P (op0) && !SYMBOL_REF_TLS_MODEL (op0)) |
| 26543 |
{ |
| 26544 |
if (!SYMBOL_REF_LOCAL_P (op0)) |
| 26545 |
return INSN_FORM_PCREL_EXTERNAL; |
| 26546 |
else |
| 26547 |
return INSN_FORM_PCREL_LOCAL; |
| 26548 |
} |
| 26549 |
} |
| 26550 |
|
| 26551 |
/* If it isn't PC-relative, the address must use a base register. */ |
| 26552 |
if (!REG_P (op0) && !SUBREG_P (op0)) |
| 26553 |
return INSN_FORM_BAD; |
| 26554 |
|
| 26555 |
/* Large offsets must be prefixed. */ |
| 26556 |
if (!SIGNED_INTEGER_16BIT_P (offset)) |
| 26557 |
{ |
| 26558 |
if (TARGET_PREFIXED) |
| 26559 |
return INSN_FORM_PREFIXED_NUMERIC; |
| 26560 |
|
| 26561 |
return INSN_FORM_BAD; |
| 26562 |
} |
| 26563 |
|
| 26564 |
/* We have a 16-bit offset, see what default instruction format to use. */ |
| 26565 |
if (non_prefixed_format == NON_PREFIXED_DEFAULT) |
| 26566 |
{ |
| 26567 |
unsigned size = GET_MODE_SIZE (mode); |
| 26568 |
|
| 26569 |
/* On 64-bit systems, assume 64-bit integers need to use DS form |
| 26570 |
addresses (for LD/STD). VSX vectors need to use DQ form addresses |
| 26571 |
(for LXV and STXV). TImode is problematical in that its normal usage |
| 26572 |
is expected to be GPRs where it wants a DS instruction format, but if |
| 26573 |
it goes into the vector registers, it wants a DQ instruction |
| 26574 |
format. */ |
| 26575 |
if (TARGET_POWERPC64 && size >= 8 && GET_MODE_CLASS (mode) == MODE_INT) |
| 26576 |
non_prefixed_format = NON_PREFIXED_DS; |
| 26577 |
|
| 26578 |
else if (TARGET_VSX && size >= 16 |
| 26579 |
&& (VECTOR_MODE_P (mode) || VECTOR_ALIGNMENT_P (mode))) |
| 26580 |
non_prefixed_format = NON_PREFIXED_DQ; |
| 26581 |
|
| 26582 |
else |
| 26583 |
non_prefixed_format = NON_PREFIXED_D; |
| 26584 |
} |
| 26585 |
|
| 26586 |
/* Classify the D/DS/DQ-form addresses. */ |
| 26587 |
switch (non_prefixed_format) |
| 26588 |
{ |
| 26589 |
/* Instruction format D, all 16 bits are valid. */ |
| 26590 |
case NON_PREFIXED_D: |
| 26591 |
return INSN_FORM_D; |
| 26592 |
|
| 26593 |
/* Instruction format DS, bottom 2 bits must be 0. */ |
| 26594 |
case NON_PREFIXED_DS: |
| 26595 |
if ((offset & 3) == 0) |
| 26596 |
return INSN_FORM_DS; |
| 26597 |
|
| 26598 |
else if (TARGET_PREFIXED) |
| 26599 |
return INSN_FORM_PREFIXED_NUMERIC; |
| 26600 |
|
| 26601 |
else |
| 26602 |
return INSN_FORM_BAD; |
| 26603 |
|
| 26604 |
/* Instruction format DQ, bottom 4 bits must be 0. */ |
| 26605 |
case NON_PREFIXED_DQ: |
| 26606 |
if ((offset & 15) == 0) |
| 26607 |
return INSN_FORM_DQ; |
| 26608 |
|
| 26609 |
else if (TARGET_PREFIXED) |
| 26610 |
return INSN_FORM_PREFIXED_NUMERIC; |
| 26611 |
|
| 26612 |
else |
| 26613 |
return INSN_FORM_BAD; |
| 26614 |
|
| 26615 |
default: |
| 26616 |
break; |
| 26617 |
} |
| 26618 |
|
| 26619 |
return INSN_FORM_BAD; |
| 26620 |
} |
| 26621 |
|
| 26622 |
/* Given address rtx ADDR for a load of MODE, is this legitimate for a |
| 26623 |
non-prefixed D-form or X-form instruction? NON_PREFIXED_FORMAT is |
| 26624 |
given NON_PREFIXED_D or NON_PREFIXED_DS to indicate whether we want |
| 26625 |
a D-form or DS-form instruction. X-form and base_reg are always |
| 26626 |
allowed. */ |
| 26627 |
bool |
| 26628 |
address_is_non_pfx_d_or_x (rtx addr, machine_mode mode, |
| 26629 |
enum non_prefixed_form non_prefixed_format) |
| 26630 |
{ |
| 26631 |
enum insn_form result_form; |
| 26632 |
|
| 26633 |
result_form = address_to_insn_form (addr, mode, non_prefixed_format); |
| 26634 |
|
| 26635 |
switch (non_prefixed_format) |
| 26636 |
{ |
| 26637 |
case NON_PREFIXED_D: |
| 26638 |
switch (result_form) |
| 26639 |
{ |
| 26640 |
case INSN_FORM_X: |
| 26641 |
case INSN_FORM_D: |
| 26642 |
case INSN_FORM_DS: |
| 26643 |
case INSN_FORM_BASE_REG: |
| 26644 |
return true; |
| 26645 |
default: |
| 26646 |
return false; |
| 26647 |
} |
| 26648 |
break; |
| 26649 |
case NON_PREFIXED_DS: |
| 26650 |
switch (result_form) |
| 26651 |
{ |
| 26652 |
case INSN_FORM_X: |
| 26653 |
case INSN_FORM_DS: |
| 26654 |
case INSN_FORM_BASE_REG: |
| 26655 |
return true; |
| 26656 |
default: |
| 26657 |
return false; |
| 26658 |
} |
| 26659 |
break; |
| 26660 |
default: |
| 26661 |
break; |
| 26662 |
} |
| 26663 |
return false; |
| 26664 |
} |
| 26665 |
|
| 26666 |
/* Return true if an REG with a given MODE is loaded from or stored into a MEM |
| 26667 |
location uses a non-prefixed D/DS/DQ-form address. This is used to validate |
| 26668 |
the load or store with the PCREL_OPT optimization to make sure it is an |
| 26669 |
instruction that can be optimized. |
| 26670 |
|
| 26671 |
We need to specify the MODE separately from the REG to allow for loads that |
| 26672 |
include zero/sign/float extension. */ |
| 26673 |
|
| 26674 |
bool |
| 26675 |
pcrel_opt_valid_mem_p (rtx reg, machine_mode mode, rtx mem) |
| 26676 |
{ |
| 26677 |
/* If the instruction is indexed only like LFIWAX/LXSIWAX we cannot do the |
| 26678 |
PCREL_OPT optimization. */ |
| 26679 |
enum non_prefixed_form non_prefixed = reg_to_non_prefixed (reg, mode); |
| 26680 |
if (non_prefixed == NON_PREFIXED_X) |
| 26681 |
return false; |
| 26682 |
|
| 26683 |
/* Check if this is a non-prefixed D/DS/DQ-form instruction. */ |
| 26684 |
rtx addr = XEXP (mem, 0); |
| 26685 |
enum insn_form iform = address_to_insn_form (addr, mode, non_prefixed); |
| 26686 |
return (iform == INSN_FORM_BASE_REG |
| 26687 |
|| iform == INSN_FORM_D |
| 26688 |
|| iform == INSN_FORM_DS |
| 26689 |
|| iform == INSN_FORM_DQ); |
| 26690 |
} |
| 26691 |
|
| 26692 |
/* Helper function to see if we're potentially looking at lfs/stfs. |
| 26693 |
- PARALLEL containing a SET and a CLOBBER |
| 26694 |
- stfs: |
| 26695 |
- SET is from UNSPEC_SI_FROM_SF to MEM:SI |
| 26696 |
- CLOBBER is a V4SF |
| 26697 |
- lfs: |
| 26698 |
- SET is from UNSPEC_SF_FROM_SI to REG:SF |
| 26699 |
- CLOBBER is a DI |
| 26700 |
*/ |
| 26701 |
|
| 26702 |
static bool |
| 26703 |
is_lfs_stfs_insn (rtx_insn *insn) |
| 26704 |
{ |
| 26705 |
rtx pattern = PATTERN (insn); |
| 26706 |
if (GET_CODE (pattern) != PARALLEL) |
| 26707 |
return false; |
| 26708 |
|
| 26709 |
/* This should be a parallel with exactly one set and one clobber. */ |
| 26710 |
if (XVECLEN (pattern, 0) != 2) |
| 26711 |
return false; |
| 26712 |
|
| 26713 |
rtx set = XVECEXP (pattern, 0, 0); |
| 26714 |
if (GET_CODE (set) != SET) |
| 26715 |
return false; |
| 26716 |
|
| 26717 |
rtx clobber = XVECEXP (pattern, 0, 1); |
| 26718 |
if (GET_CODE (clobber) != CLOBBER) |
| 26719 |
return false; |
| 26720 |
|
| 26721 |
/* All we care is that the destination of the SET is a mem:SI, |
| 26722 |
the source should be an UNSPEC_SI_FROM_SF, and the clobber |
| 26723 |
should be a scratch:V4SF. */ |
| 26724 |
|
| 26725 |
rtx dest = SET_DEST (set); |
| 26726 |
rtx src = SET_SRC (set); |
| 26727 |
rtx scratch = SET_DEST (clobber); |
| 26728 |
|
| 26729 |
if (GET_CODE (src) != UNSPEC) |
| 26730 |
return false; |
| 26731 |
|
| 26732 |
/* stfs case. */ |
| 26733 |
if (XINT (src, 1) == UNSPEC_SI_FROM_SF |
| 26734 |
&& GET_CODE (dest) == MEM && GET_MODE (dest) == SImode |
| 26735 |
&& GET_CODE (scratch) == SCRATCH && GET_MODE (scratch) == V4SFmode) |
| 26736 |
return true; |
| 26737 |
|
| 26738 |
/* lfs case. */ |
| 26739 |
if (XINT (src, 1) == UNSPEC_SF_FROM_SI |
| 26740 |
&& GET_CODE (dest) == REG && GET_MODE (dest) == SFmode |
| 26741 |
&& GET_CODE (scratch) == SCRATCH && GET_MODE (scratch) == DImode) |
| 26742 |
return true; |
| 26743 |
|
| 26744 |
return false; |
| 26745 |
} |
| 26746 |
|
| 26747 |
/* Helper function to take a REG and a MODE and turn it into the non-prefixed |
| 26748 |
instruction format (D/DS/DQ) used for offset memory. */ |
| 26749 |
|
| 26750 |
enum non_prefixed_form |
| 26751 |
reg_to_non_prefixed (rtx reg, machine_mode mode) |
| 26752 |
{ |
| 26753 |
/* If it isn't a register, use the defaults. */ |
| 26754 |
if (!REG_P (reg) && !SUBREG_P (reg)) |
| 26755 |
return NON_PREFIXED_DEFAULT; |
| 26756 |
|
| 26757 |
unsigned int r = reg_or_subregno (reg); |
| 26758 |
|
| 26759 |
/* If we have a pseudo, use the default instruction format. */ |
| 26760 |
if (!HARD_REGISTER_NUM_P (r)) |
| 26761 |
return NON_PREFIXED_DEFAULT; |
| 26762 |
|
| 26763 |
unsigned size = GET_MODE_SIZE (mode); |
| 26764 |
|
| 26765 |
/* FPR registers use D-mode for scalars, and DQ-mode for vectors, IEEE |
| 26766 |
128-bit floating point, and 128-bit integers. Before power9, only indexed |
| 26767 |
addressing was available for vectors. */ |
| 26768 |
if (FP_REGNO_P (r)) |
| 26769 |
{ |
| 26770 |
if (mode == SFmode || size == 8 || FLOAT128_2REG_P (mode)) |
| 26771 |
return NON_PREFIXED_D; |
| 26772 |
|
| 26773 |
else if (size < 8) |
| 26774 |
return NON_PREFIXED_X; |
| 26775 |
|
| 26776 |
else if (TARGET_VSX && size >= 16 |
| 26777 |
&& (VECTOR_MODE_P (mode) |
| 26778 |
|| VECTOR_ALIGNMENT_P (mode) |
| 26779 |
|| mode == TImode || mode == CTImode)) |
| 26780 |
return (TARGET_P9_VECTOR) ? NON_PREFIXED_DQ : NON_PREFIXED_X; |
| 26781 |
|
| 26782 |
else |
| 26783 |
return NON_PREFIXED_DEFAULT; |
| 26784 |
} |
| 26785 |
|
| 26786 |
/* Altivec registers use DS-mode for scalars, and DQ-mode for vectors, IEEE |
| 26787 |
128-bit floating point, and 128-bit integers. Before power9, only indexed |
| 26788 |
addressing was available. */ |
| 26789 |
else if (ALTIVEC_REGNO_P (r)) |
| 26790 |
{ |
| 26791 |
if (!TARGET_P9_VECTOR) |
| 26792 |
return NON_PREFIXED_X; |
| 26793 |
|
| 26794 |
if (mode == SFmode || size == 8 || FLOAT128_2REG_P (mode)) |
| 26795 |
return NON_PREFIXED_DS; |
| 26796 |
|
| 26797 |
else if (size < 8) |
| 26798 |
return NON_PREFIXED_X; |
| 26799 |
|
| 26800 |
else if (TARGET_VSX && size >= 16 |
| 26801 |
&& (VECTOR_MODE_P (mode) |
| 26802 |
|| VECTOR_ALIGNMENT_P (mode) |
| 26803 |
|| mode == TImode || mode == CTImode)) |
| 26804 |
return NON_PREFIXED_DQ; |
| 26805 |
|
| 26806 |
else |
| 26807 |
return NON_PREFIXED_DEFAULT; |
| 26808 |
} |
| 26809 |
|
| 26810 |
/* GPR registers use DS-mode for 64-bit items on 64-bit systems, and D-mode |
| 26811 |
otherwise. Assume that any other register, such as LR, CRs, etc. will go |
| 26812 |
through the GPR registers for memory operations. */ |
| 26813 |
else if (TARGET_POWERPC64 && size >= 8) |
| 26814 |
return NON_PREFIXED_DS; |
| 26815 |
|
| 26816 |
return NON_PREFIXED_D; |
| 26817 |
} |
| 26818 |
|
| 26819 |
|
| 26820 |
/* Whether a load instruction is a prefixed instruction. This is called from |
| 26821 |
the prefixed attribute processing. */ |
| 26822 |
|
| 26823 |
bool |
| 26824 |
prefixed_load_p (rtx_insn *insn) |
| 26825 |
{ |
| 26826 |
/* Validate the insn to make sure it is a normal load insn. */ |
| 26827 |
extract_insn_cached (insn); |
| 26828 |
if (recog_data.n_operands < 2) |
| 26829 |
return false; |
| 26830 |
|
| 26831 |
rtx reg = recog_data.operand[0]; |
| 26832 |
rtx mem = recog_data.operand[1]; |
| 26833 |
|
| 26834 |
if (!REG_P (reg) && !SUBREG_P (reg)) |
| 26835 |
return false; |
| 26836 |
|
| 26837 |
if (!MEM_P (mem)) |
| 26838 |
return false; |
| 26839 |
|
| 26840 |
/* Prefixed load instructions do not support update or indexed forms. */ |
| 26841 |
if (get_attr_indexed (insn) == INDEXED_YES |
| 26842 |
|| get_attr_update (insn) == UPDATE_YES) |
| 26843 |
return false; |
| 26844 |
|
| 26845 |
/* LWA uses the DS format instead of the D format that LWZ uses. */ |
| 26846 |
enum non_prefixed_form non_prefixed; |
| 26847 |
machine_mode reg_mode = GET_MODE (reg); |
| 26848 |
machine_mode mem_mode = GET_MODE (mem); |
| 26849 |
|
| 26850 |
if (mem_mode == SImode && reg_mode == DImode |
| 26851 |
&& get_attr_sign_extend (insn) == SIGN_EXTEND_YES) |
| 26852 |
non_prefixed = NON_PREFIXED_DS; |
| 26853 |
|
| 26854 |
else |
| 26855 |
non_prefixed = reg_to_non_prefixed (reg, mem_mode); |
| 26856 |
|
| 26857 |
if (non_prefixed == NON_PREFIXED_X && is_lfs_stfs_insn (insn)) |
| 26858 |
return address_is_prefixed (XEXP (mem, 0), mem_mode, NON_PREFIXED_DEFAULT); |
| 26859 |
else |
| 26860 |
return address_is_prefixed (XEXP (mem, 0), mem_mode, non_prefixed); |
| 26861 |
} |
| 26862 |
|
| 26863 |
/* Whether a store instruction is a prefixed instruction. This is called from |
| 26864 |
the prefixed attribute processing. */ |
| 26865 |
|
| 26866 |
bool |
| 26867 |
prefixed_store_p (rtx_insn *insn) |
| 26868 |
{ |
| 26869 |
/* Validate the insn to make sure it is a normal store insn. */ |
| 26870 |
extract_insn_cached (insn); |
| 26871 |
if (recog_data.n_operands < 2) |
| 26872 |
return false; |
| 26873 |
|
| 26874 |
rtx mem = recog_data.operand[0]; |
| 26875 |
rtx reg = recog_data.operand[1]; |
| 26876 |
|
| 26877 |
if (!REG_P (reg) && !SUBREG_P (reg)) |
| 26878 |
return false; |
| 26879 |
|
| 26880 |
if (!MEM_P (mem)) |
| 26881 |
return false; |
| 26882 |
|
| 26883 |
/* Prefixed store instructions do not support update or indexed forms. */ |
| 26884 |
if (get_attr_indexed (insn) == INDEXED_YES |
| 26885 |
|| get_attr_update (insn) == UPDATE_YES) |
| 26886 |
return false; |
| 26887 |
|
| 26888 |
machine_mode mem_mode = GET_MODE (mem); |
| 26889 |
rtx addr = XEXP (mem, 0); |
| 26890 |
enum non_prefixed_form non_prefixed = reg_to_non_prefixed (reg, mem_mode); |
| 26891 |
|
| 26892 |
/* Need to make sure we aren't looking at a stfs which doesn't look |
| 26893 |
like the other things reg_to_non_prefixed/address_is_prefixed |
| 26894 |
looks for. */ |
| 26895 |
if (non_prefixed == NON_PREFIXED_X && is_lfs_stfs_insn (insn)) |
| 26896 |
return address_is_prefixed (addr, mem_mode, NON_PREFIXED_DEFAULT); |
| 26897 |
else |
| 26898 |
return address_is_prefixed (addr, mem_mode, non_prefixed); |
| 26899 |
} |
| 26900 |
|
| 26901 |
/* Whether a load immediate or add instruction is a prefixed instruction. This |
| 26902 |
is called from the prefixed attribute processing. */ |
| 26903 |
|
| 26904 |
bool |
| 26905 |
prefixed_paddi_p (rtx_insn *insn) |
| 26906 |
{ |
| 26907 |
rtx set = single_set (insn); |
| 26908 |
if (!set) |
| 26909 |
return false; |
| 26910 |
|
| 26911 |
rtx dest = SET_DEST (set); |
| 26912 |
rtx src = SET_SRC (set); |
| 26913 |
|
| 26914 |
if (!REG_P (dest) && !SUBREG_P (dest)) |
| 26915 |
return false; |
| 26916 |
|
| 26917 |
/* Is this a load immediate that can't be done with a simple ADDI or |
| 26918 |
ADDIS? */ |
| 26919 |
if (CONST_INT_P (src)) |
| 26920 |
return (satisfies_constraint_eI (src) |
| 26921 |
&& !satisfies_constraint_I (src) |
| 26922 |
&& !satisfies_constraint_L (src)); |
| 26923 |
|
| 26924 |
/* Is this a PADDI instruction that can't be done with a simple ADDI or |
| 26925 |
ADDIS? */ |
| 26926 |
if (GET_CODE (src) == PLUS) |
| 26927 |
{ |
| 26928 |
rtx op1 = XEXP (src, 1); |
| 26929 |
|
| 26930 |
return (CONST_INT_P (op1) |
| 26931 |
&& satisfies_constraint_eI (op1) |
| 26932 |
&& !satisfies_constraint_I (op1) |
| 26933 |
&& !satisfies_constraint_L (op1)); |
| 26934 |
} |
| 26935 |
|
| 26936 |
/* If not, is it a load of a PC-relative address? */ |
| 26937 |
if (!TARGET_PCREL || GET_MODE (dest) != Pmode) |
| 26938 |
return false; |
| 26939 |
|
| 26940 |
if (!SYMBOL_REF_P (src) && !LABEL_REF_P (src) && GET_CODE (src) != CONST) |
| 26941 |
return false; |
| 26942 |
|
| 26943 |
enum insn_form iform = address_to_insn_form (src, Pmode, |
| 26944 |
NON_PREFIXED_DEFAULT); |
| 26945 |
|
| 26946 |
return (iform == INSN_FORM_PCREL_EXTERNAL || iform == INSN_FORM_PCREL_LOCAL); |
| 26947 |
} |
| 26948 |
|
| 26949 |
/* Whether the next instruction needs a 'p' prefix issued before the |
| 26950 |
instruction is printed out. */ |
| 26951 |
static bool prepend_p_to_next_insn; |
| 26952 |
|
| 26953 |
/* Define FINAL_PRESCAN_INSN if some processing needs to be done before |
| 26954 |
outputting the assembler code. On the PowerPC, we remember if the current |
| 26955 |
insn is a prefixed insn where we need to emit a 'p' before the insn. |
| 26956 |
|
| 26957 |
In addition, if the insn is part of a PC-relative reference to an external |
| 26958 |
label optimization, this is recorded also. */ |
| 26959 |
void |
| 26960 |
rs6000_final_prescan_insn (rtx_insn *insn, rtx [], int) |
| 26961 |
{ |
| 26962 |
prepend_p_to_next_insn = (get_attr_maybe_prefixed (insn) |
| 26963 |
== MAYBE_PREFIXED_YES |
| 26964 |
&& get_attr_prefixed (insn) == PREFIXED_YES); |
| 26965 |
return; |
| 26966 |
} |
| 26967 |
|
| 26968 |
/* Define ASM_OUTPUT_OPCODE to do anything special before emitting an opcode. |
| 26969 |
We use it to emit a 'p' for prefixed insns that is set in |
| 26970 |
FINAL_PRESCAN_INSN. */ |
| 26971 |
void |
| 26972 |
rs6000_asm_output_opcode (FILE *stream) |
| 26973 |
{ |
| 26974 |
if (prepend_p_to_next_insn) |
| 26975 |
{ |
| 26976 |
fprintf (stream, "p"); |
| 26977 |
|
| 26978 |
/* Reset the flag in the case where there are separate insn lines in the |
| 26979 |
sequence, so the 'p' is only emitted for the first line. This shows up |
| 26980 |
when we are doing the PCREL_OPT optimization, in that the label created |
| 26981 |
with %r<n> would have a leading 'p' printed. */ |
| 26982 |
prepend_p_to_next_insn = false; |
| 26983 |
} |
| 26984 |
|
| 26985 |
return; |
| 26986 |
} |
| 26987 |
|
| 26988 |
/* Emit the relocation to tie the next instruction to a previous instruction |
| 26989 |
that loads up an external address. This is used to do the PCREL_OPT |
| 26990 |
optimization. Note, the label is generated after the PLD of the got |
| 26991 |
pc-relative address to allow for the assembler to insert NOPs before the PLD |
| 26992 |
instruction. The operand is a constant integer that is the label |
| 26993 |
number. */ |
| 26994 |
|
| 26995 |
void |
| 26996 |
output_pcrel_opt_reloc (rtx label_num) |
| 26997 |
{ |
| 26998 |
rtx operands[1] = { label_num }; |
| 26999 |
output_asm_insn (".reloc .Lpcrel%0-8,R_PPC64_PCREL_OPT,.-(.Lpcrel%0-8)", |
| 27000 |
operands); |
| 27001 |
} |
| 27002 |
|
| 27003 |
/* Adjust the length of an INSN. LENGTH is the currently-computed length and |
| 27004 |
should be adjusted to reflect any required changes. This macro is used when |
| 27005 |
there is some systematic length adjustment required that would be difficult |
| 27006 |
to express in the length attribute. |
| 27007 |
|
| 27008 |
In the PowerPC, we use this to adjust the length of an instruction if one or |
| 27009 |
more prefixed instructions are generated, using the attribute |
| 27010 |
num_prefixed_insns. A prefixed instruction is 8 bytes instead of 4, but the |
| 27011 |
hardware requires that a prefied instruciton does not cross a 64-byte |
| 27012 |
boundary. This means the compiler has to assume the length of the first |
| 27013 |
prefixed instruction is 12 bytes instead of 8 bytes. Since the length is |
| 27014 |
already set for the non-prefixed instruction, we just need to udpate for the |
| 27015 |
difference. */ |
| 27016 |
|
| 27017 |
int |
| 27018 |
rs6000_adjust_insn_length (rtx_insn *insn, int length) |
| 27019 |
{ |
| 27020 |
if (TARGET_PREFIXED && NONJUMP_INSN_P (insn)) |
| 27021 |
{ |
| 27022 |
rtx pattern = PATTERN (insn); |
| 27023 |
if (GET_CODE (pattern) != USE && GET_CODE (pattern) != CLOBBER |
| 27024 |
&& get_attr_prefixed (insn) == PREFIXED_YES) |
| 27025 |
{ |
| 27026 |
int num_prefixed = get_attr_max_prefixed_insns (insn); |
| 27027 |
length += 4 * (num_prefixed + 1); |
| 27028 |
} |
| 27029 |
} |
| 27030 |
|
| 27031 |
return length; |
| 27032 |
} |
| 27033 |
|
| 27034 |
|
| 27035 |
#ifdef HAVE_GAS_HIDDEN |
| 27036 |
# define USE_HIDDEN_LINKONCE 1 |
| 27037 |
#else |
| 27038 |
# define USE_HIDDEN_LINKONCE 0 |
| 27039 |
#endif |
| 27040 |
|
| 27041 |
/* Fills in the label name that should be used for a 476 link stack thunk. */ |
| 27042 |
|
| 27043 |
void |
| 27044 |
get_ppc476_thunk_name (char name[32]) |
| 27045 |
{ |
| 27046 |
gcc_assert (TARGET_LINK_STACK); |
| 27047 |
|
| 27048 |
if (USE_HIDDEN_LINKONCE) |
| 27049 |
sprintf (name, "__ppc476.get_thunk"); |
| 27050 |
else |
| 27051 |
ASM_GENERATE_INTERNAL_LABEL (name, "LPPC476_", 0); |
| 27052 |
} |
| 27053 |
|
| 27054 |
/* This function emits the simple thunk routine that is used to preserve |
| 27055 |
the link stack on the 476 cpu. */ |
| 27056 |
|
| 27057 |
static void rs6000_code_end (void) ATTRIBUTE_UNUSED; |
| 27058 |
static void |
| 27059 |
rs6000_code_end (void) |
| 27060 |
{ |
| 27061 |
char name[32]; |
| 27062 |
tree decl; |
| 27063 |
|
| 27064 |
if (!TARGET_LINK_STACK) |
| 27065 |
return; |
| 27066 |
|
| 27067 |
get_ppc476_thunk_name (name); |
| 27068 |
|
| 27069 |
decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, get_identifier (name), |
| 27070 |
build_function_type_list (void_type_node, NULL_TREE)); |
| 27071 |
DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL, |
| 27072 |
NULL_TREE, void_type_node); |
| 27073 |
TREE_PUBLIC (decl) = 1; |
| 27074 |
TREE_STATIC (decl) = 1; |
| 27075 |
|
| 27076 |
#if RS6000_WEAK |
| 27077 |
if (USE_HIDDEN_LINKONCE && !TARGET_XCOFF) |
| 27078 |
{ |
| 27079 |
cgraph_node::create (decl)->set_comdat_group (DECL_ASSEMBLER_NAME (decl)); |
| 27080 |
targetm.asm_out.unique_section (decl, 0); |
| 27081 |
switch_to_section (get_named_section (decl, NULL, 0)); |
| 27082 |
DECL_WEAK (decl) = 1; |
| 27083 |
ASM_WEAKEN_DECL (asm_out_file, decl, name, 0); |
| 27084 |
targetm.asm_out.globalize_label (asm_out_file, name); |
| 27085 |
targetm.asm_out.assemble_visibility (decl, VISIBILITY_HIDDEN); |
| 27086 |
ASM_DECLARE_FUNCTION_NAME (asm_out_file, name, decl); |
| 27087 |
} |
| 27088 |
else |
| 27089 |
#endif |
| 27090 |
{ |
| 27091 |
switch_to_section (text_section); |
| 27092 |
ASM_OUTPUT_LABEL (asm_out_file, name); |
| 27093 |
} |
| 27094 |
|
| 27095 |
DECL_INITIAL (decl) = make_node (BLOCK); |
| 27096 |
current_function_decl = decl; |
| 27097 |
allocate_struct_function (decl, false); |
| 27098 |
init_function_start (decl); |
| 27099 |
first_function_block_is_cold = false; |
| 27100 |
/* Make sure unwind info is emitted for the thunk if needed. */ |
| 27101 |
final_start_function (emit_barrier (), asm_out_file, 1); |
| 27102 |
|
| 27103 |
fputs ("\tblr\n", asm_out_file); |
| 27104 |
|
| 27105 |
final_end_function (); |
| 27106 |
init_insn_lengths (); |
| 27107 |
free_after_compilation (cfun); |
| 27108 |
set_cfun (NULL); |
| 27109 |
current_function_decl = NULL; |
| 27110 |
} |
| 27111 |
|
| 27112 |
/* Add r30 to hard reg set if the prologue sets it up and it is not |
| 27113 |
pic_offset_table_rtx. */ |
| 27114 |
|
| 27115 |
static void |
| 27116 |
rs6000_set_up_by_prologue (struct hard_reg_set_container *set) |
| 27117 |
{ |
| 27118 |
if (!TARGET_SINGLE_PIC_BASE |
| 27119 |
&& TARGET_TOC |
| 27120 |
&& TARGET_MINIMAL_TOC |
| 27121 |
&& !constant_pool_empty_p ()) |
| 27122 |
add_to_hard_reg_set (&set->set, Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM); |
| 27123 |
if (cfun->machine->split_stack_argp_used) |
| 27124 |
add_to_hard_reg_set (&set->set, Pmode, 12); |
| 27125 |
|
| 27126 |
/* Make sure the hard reg set doesn't include r2, which was possibly added |
| 27127 |
via PIC_OFFSET_TABLE_REGNUM. */ |
| 27128 |
if (TARGET_TOC) |
| 27129 |
remove_from_hard_reg_set (&set->set, Pmode, TOC_REGNUM); |
| 27130 |
} |
| 27131 |
|
| 27132 |
|
| 27133 |
/* Helper function for rs6000_split_logical to emit a logical instruction after |
| 27134 |
spliting the operation to single GPR registers. |
| 27135 |
|
| 27136 |
DEST is the destination register. |
| 27137 |
OP1 and OP2 are the input source registers. |
| 27138 |
CODE is the base operation (AND, IOR, XOR, NOT). |
| 27139 |
MODE is the machine mode. |
| 27140 |
If COMPLEMENT_FINAL_P is true, wrap the whole operation with NOT. |
| 27141 |
If COMPLEMENT_OP1_P is true, wrap operand1 with NOT. |
| 27142 |
If COMPLEMENT_OP2_P is true, wrap operand2 with NOT. */ |
| 27143 |
|
| 27144 |
static void |
| 27145 |
rs6000_split_logical_inner (rtx dest, |
| 27146 |
rtx op1, |
| 27147 |
rtx op2, |
| 27148 |
enum rtx_code code, |
| 27149 |
machine_mode mode, |
| 27150 |
bool complement_final_p, |
| 27151 |
bool complement_op1_p, |
| 27152 |
bool complement_op2_p) |
| 27153 |
{ |
| 27154 |
rtx bool_rtx; |
| 27155 |
|
| 27156 |
/* Optimize AND of 0/0xffffffff and IOR/XOR of 0. */ |
| 27157 |
if (op2 && CONST_INT_P (op2) |
| 27158 |
&& (mode == SImode || (mode == DImode && TARGET_POWERPC64)) |
| 27159 |
&& !complement_final_p && !complement_op1_p && !complement_op2_p) |
| 27160 |
{ |
| 27161 |
HOST_WIDE_INT mask = GET_MODE_MASK (mode); |
| 27162 |
HOST_WIDE_INT value = INTVAL (op2) & mask; |
| 27163 |
|
| 27164 |
/* Optimize AND of 0 to just set 0. Optimize AND of -1 to be a move. */ |
| 27165 |
if (code == AND) |
| 27166 |
{ |
| 27167 |
if (value == 0) |
| 27168 |
{ |
| 27169 |
emit_insn (gen_rtx_SET (dest, const0_rtx)); |
| 27170 |
return; |
| 27171 |
} |
| 27172 |
|
| 27173 |
else if (value == mask) |
| 27174 |
{ |
| 27175 |
if (!rtx_equal_p (dest, op1)) |
| 27176 |
emit_insn (gen_rtx_SET (dest, op1)); |
| 27177 |
return; |
| 27178 |
} |
| 27179 |
} |
| 27180 |
|
| 27181 |
/* Optimize IOR/XOR of 0 to be a simple move. Split large operations |
| 27182 |
into separate ORI/ORIS or XORI/XORIS instrucitons. */ |
| 27183 |
else if (code == IOR || code == XOR) |
| 27184 |
{ |
| 27185 |
if (value == 0) |
| 27186 |
{ |
| 27187 |
if (!rtx_equal_p (dest, op1)) |
| 27188 |
emit_insn (gen_rtx_SET (dest, op1)); |
| 27189 |
return; |
| 27190 |
} |
| 27191 |
} |
| 27192 |
} |
| 27193 |
|
| 27194 |
if (code == AND && mode == SImode |
| 27195 |
&& !complement_final_p && !complement_op1_p && !complement_op2_p) |
| 27196 |
{ |
| 27197 |
emit_insn (gen_andsi3 (dest, op1, op2)); |
| 27198 |
return; |
| 27199 |
} |
| 27200 |
|
| 27201 |
if (complement_op1_p) |
| 27202 |
op1 = gen_rtx_NOT (mode, op1); |
| 27203 |
|
| 27204 |
if (complement_op2_p) |
| 27205 |
op2 = gen_rtx_NOT (mode, op2); |
| 27206 |
|
| 27207 |
/* For canonical RTL, if only one arm is inverted it is the first. */ |
| 27208 |
if (!complement_op1_p && complement_op2_p) |
| 27209 |
std::swap (op1, op2); |
| 27210 |
|
| 27211 |
bool_rtx = ((code == NOT) |
| 27212 |
? gen_rtx_NOT (mode, op1) |
| 27213 |
: gen_rtx_fmt_ee (code, mode, op1, op2)); |
| 27214 |
|
| 27215 |
if (complement_final_p) |
| 27216 |
bool_rtx = gen_rtx_NOT (mode, bool_rtx); |
| 27217 |
|
| 27218 |
emit_insn (gen_rtx_SET (dest, bool_rtx)); |
| 27219 |
} |
| 27220 |
|
| 27221 |
/* Split a DImode AND/IOR/XOR with a constant on a 32-bit system. These |
| 27222 |
operations are split immediately during RTL generation to allow for more |
| 27223 |
optimizations of the AND/IOR/XOR. |
| 27224 |
|
| 27225 |
OPERANDS is an array containing the destination and two input operands. |
| 27226 |
CODE is the base operation (AND, IOR, XOR, NOT). |
| 27227 |
MODE is the machine mode. |
| 27228 |
If COMPLEMENT_FINAL_P is true, wrap the whole operation with NOT. |
| 27229 |
If COMPLEMENT_OP1_P is true, wrap operand1 with NOT. |
| 27230 |
If COMPLEMENT_OP2_P is true, wrap operand2 with NOT. |
| 27231 |
CLOBBER_REG is either NULL or a scratch register of type CC to allow |
| 27232 |
formation of the AND instructions. */ |
| 27233 |
|
| 27234 |
static void |
| 27235 |
rs6000_split_logical_di (rtx operands[3], |
| 27236 |
enum rtx_code code, |
| 27237 |
bool complement_final_p, |
| 27238 |
bool complement_op1_p, |
| 27239 |
bool complement_op2_p) |
| 27240 |
{ |
| 27241 |
const HOST_WIDE_INT lower_32bits = HOST_WIDE_INT_C(0xffffffff); |
| 27242 |
const HOST_WIDE_INT upper_32bits = ~ lower_32bits; |
| 27243 |
const HOST_WIDE_INT sign_bit = HOST_WIDE_INT_C(0x80000000); |
| 27244 |
enum hi_lo { hi = 0, lo = 1 }; |
| 27245 |
rtx op0_hi_lo[2], op1_hi_lo[2], op2_hi_lo[2]; |
| 27246 |
size_t i; |
| 27247 |
|
| 27248 |
op0_hi_lo[hi] = gen_highpart (SImode, operands[0]); |
| 27249 |
op1_hi_lo[hi] = gen_highpart (SImode, operands[1]); |
| 27250 |
op0_hi_lo[lo] = gen_lowpart (SImode, operands[0]); |
| 27251 |
op1_hi_lo[lo] = gen_lowpart (SImode, operands[1]); |
| 27252 |
|
| 27253 |
if (code == NOT) |
| 27254 |
op2_hi_lo[hi] = op2_hi_lo[lo] = NULL_RTX; |
| 27255 |
else |
| 27256 |
{ |
| 27257 |
if (!CONST_INT_P (operands[2])) |
| 27258 |
{ |
| 27259 |
op2_hi_lo[hi] = gen_highpart_mode (SImode, DImode, operands[2]); |
| 27260 |
op2_hi_lo[lo] = gen_lowpart (SImode, operands[2]); |
| 27261 |
} |
| 27262 |
else |
| 27263 |
{ |
| 27264 |
HOST_WIDE_INT value = INTVAL (operands[2]); |
| 27265 |
HOST_WIDE_INT value_hi_lo[2]; |
| 27266 |
|
| 27267 |
gcc_assert (!complement_final_p); |
| 27268 |
gcc_assert (!complement_op1_p); |
| 27269 |
gcc_assert (!complement_op2_p); |
| 27270 |
|
| 27271 |
value_hi_lo[hi] = value >> 32; |
| 27272 |
value_hi_lo[lo] = value & lower_32bits; |
| 27273 |
|
| 27274 |
for (i = 0; i < 2; i++) |
| 27275 |
{ |
| 27276 |
HOST_WIDE_INT sub_value = value_hi_lo[i]; |
| 27277 |
|
| 27278 |
if (sub_value & sign_bit) |
| 27279 |
sub_value |= upper_32bits; |
| 27280 |
|
| 27281 |
op2_hi_lo[i] = GEN_INT (sub_value); |
| 27282 |
|
| 27283 |
/* If this is an AND instruction, check to see if we need to load |
| 27284 |
the value in a register. */ |
| 27285 |
if (code == AND && sub_value != -1 && sub_value != 0 |
| 27286 |
&& !and_operand (op2_hi_lo[i], SImode)) |
| 27287 |
op2_hi_lo[i] = force_reg (SImode, op2_hi_lo[i]); |
| 27288 |
} |
| 27289 |
} |
| 27290 |
} |
| 27291 |
|
| 27292 |
for (i = 0; i < 2; i++) |
| 27293 |
{ |
| 27294 |
/* Split large IOR/XOR operations. */ |
| 27295 |
if ((code == IOR || code == XOR) |
| 27296 |
&& CONST_INT_P (op2_hi_lo[i]) |
| 27297 |
&& !complement_final_p |
| 27298 |
&& !complement_op1_p |
| 27299 |
&& !complement_op2_p |
| 27300 |
&& !logical_const_operand (op2_hi_lo[i], SImode)) |
| 27301 |
{ |
| 27302 |
HOST_WIDE_INT value = INTVAL (op2_hi_lo[i]); |
| 27303 |
HOST_WIDE_INT hi_16bits = value & HOST_WIDE_INT_C(0xffff0000); |
| 27304 |
HOST_WIDE_INT lo_16bits = value & HOST_WIDE_INT_C(0x0000ffff); |
| 27305 |
rtx tmp = gen_reg_rtx (SImode); |
| 27306 |
|
| 27307 |
/* Make sure the constant is sign extended. */ |
| 27308 |
if ((hi_16bits & sign_bit) != 0) |
| 27309 |
hi_16bits |= upper_32bits; |
| 27310 |
|
| 27311 |
rs6000_split_logical_inner (tmp, op1_hi_lo[i], GEN_INT (hi_16bits), |
| 27312 |
code, SImode, false, false, false); |
| 27313 |
|
| 27314 |
rs6000_split_logical_inner (op0_hi_lo[i], tmp, GEN_INT (lo_16bits), |
| 27315 |
code, SImode, false, false, false); |
| 27316 |
} |
| 27317 |
else |
| 27318 |
rs6000_split_logical_inner (op0_hi_lo[i], op1_hi_lo[i], op2_hi_lo[i], |
| 27319 |
code, SImode, complement_final_p, |
| 27320 |
complement_op1_p, complement_op2_p); |
| 27321 |
} |
| 27322 |
|
| 27323 |
return; |
| 27324 |
} |
| 27325 |
|
| 27326 |
/* Split the insns that make up boolean operations operating on multiple GPR |
| 27327 |
registers. The boolean MD patterns ensure that the inputs either are |
| 27328 |
exactly the same as the output registers, or there is no overlap. |
| 27329 |
|
| 27330 |
OPERANDS is an array containing the destination and two input operands. |
| 27331 |
CODE is the base operation (AND, IOR, XOR, NOT). |
| 27332 |
If COMPLEMENT_FINAL_P is true, wrap the whole operation with NOT. |
| 27333 |
If COMPLEMENT_OP1_P is true, wrap operand1 with NOT. |
| 27334 |
If COMPLEMENT_OP2_P is true, wrap operand2 with NOT. */ |
| 27335 |
|
| 27336 |
void |
| 27337 |
rs6000_split_logical (rtx operands[3], |
| 27338 |
enum rtx_code code, |
| 27339 |
bool complement_final_p, |
| 27340 |
bool complement_op1_p, |
| 27341 |
bool complement_op2_p) |
| 27342 |
{ |
| 27343 |
machine_mode mode = GET_MODE (operands[0]); |
| 27344 |
machine_mode sub_mode; |
| 27345 |
rtx op0, op1, op2; |
| 27346 |
int sub_size, regno0, regno1, nregs, i; |
| 27347 |
|
| 27348 |
/* If this is DImode, use the specialized version that can run before |
| 27349 |
register allocation. */ |
| 27350 |
if (mode == DImode && !TARGET_POWERPC64) |
| 27351 |
{ |
| 27352 |
rs6000_split_logical_di (operands, code, complement_final_p, |
| 27353 |
complement_op1_p, complement_op2_p); |
| 27354 |
return; |
| 27355 |
} |
| 27356 |
|
| 27357 |
op0 = operands[0]; |
| 27358 |
op1 = operands[1]; |
| 27359 |
op2 = (code == NOT) ? NULL_RTX : operands[2]; |
| 27360 |
sub_mode = (TARGET_POWERPC64) ? DImode : SImode; |
| 27361 |
sub_size = GET_MODE_SIZE (sub_mode); |
| 27362 |
regno0 = REGNO (op0); |
| 27363 |
regno1 = REGNO (op1); |
| 27364 |
|
| 27365 |
gcc_assert (reload_completed); |
| 27366 |
gcc_assert (IN_RANGE (regno0, FIRST_GPR_REGNO, LAST_GPR_REGNO)); |
| 27367 |
gcc_assert (IN_RANGE (regno1, FIRST_GPR_REGNO, LAST_GPR_REGNO)); |
| 27368 |
|
| 27369 |
nregs = rs6000_hard_regno_nregs[(int)mode][regno0]; |
| 27370 |
gcc_assert (nregs > 1); |
| 27371 |
|
| 27372 |
if (op2 && REG_P (op2)) |
| 27373 |
gcc_assert (IN_RANGE (REGNO (op2), FIRST_GPR_REGNO, LAST_GPR_REGNO)); |
| 27374 |
|
| 27375 |
for (i = 0; i < nregs; i++) |
| 27376 |
{ |
| 27377 |
int offset = i * sub_size; |
| 27378 |
rtx sub_op0 = simplify_subreg (sub_mode, op0, mode, offset); |
| 27379 |
rtx sub_op1 = simplify_subreg (sub_mode, op1, mode, offset); |
| 27380 |
rtx sub_op2 = ((code == NOT) |
| 27381 |
? NULL_RTX |
| 27382 |
: simplify_subreg (sub_mode, op2, mode, offset)); |
| 27383 |
|
| 27384 |
rs6000_split_logical_inner (sub_op0, sub_op1, sub_op2, code, sub_mode, |
| 27385 |
complement_final_p, complement_op1_p, |
| 27386 |
complement_op2_p); |
| 27387 |
} |
| 27388 |
|
| 27389 |
return; |
| 27390 |
} |
| 27391 |
|
| 27392 |
/* Emit instructions to move SRC to DST. Called by splitters for |
| 27393 |
multi-register moves. It will emit at most one instruction for |
| 27394 |
each register that is accessed; that is, it won't emit li/lis pairs |
| 27395 |
(or equivalent for 64-bit code). One of SRC or DST must be a hard |
| 27396 |
register. */ |
| 27397 |
|
| 27398 |
void |
| 27399 |
rs6000_split_multireg_move (rtx dst, rtx src) |
| 27400 |
{ |
| 27401 |
/* The register number of the first register being moved. */ |
| 27402 |
int reg; |
| 27403 |
/* The mode that is to be moved. */ |
| 27404 |
machine_mode mode; |
| 27405 |
/* The mode that the move is being done in, and its size. */ |
| 27406 |
machine_mode reg_mode; |
| 27407 |
int reg_mode_size; |
| 27408 |
/* The number of registers that will be moved. */ |
| 27409 |
int nregs; |
| 27410 |
|
| 27411 |
reg = REG_P (dst) ? REGNO (dst) : REGNO (src); |
| 27412 |
mode = GET_MODE (dst); |
| 27413 |
nregs = hard_regno_nregs (reg, mode); |
| 27414 |
|
| 27415 |
/* If we have a vector quad register for MMA, and this is a load or store, |
| 27416 |
see if we can use vector paired load/stores. */ |
| 27417 |
if (mode == XOmode && TARGET_MMA |
| 27418 |
&& (MEM_P (dst) || MEM_P (src))) |
| 27419 |
{ |
| 27420 |
reg_mode = OOmode; |
| 27421 |
nregs /= 2; |
| 27422 |
} |
| 27423 |
/* If we have a vector pair/quad mode, split it into two/four separate |
| 27424 |
vectors. */ |
| 27425 |
else if (mode == OOmode || mode == XOmode) |
| 27426 |
reg_mode = V1TImode; |
| 27427 |
else if (FP_REGNO_P (reg)) |
| 27428 |
reg_mode = DECIMAL_FLOAT_MODE_P (mode) ? DDmode : |
| 27429 |
(TARGET_HARD_FLOAT ? DFmode : SFmode); |
| 27430 |
else if (ALTIVEC_REGNO_P (reg)) |
| 27431 |
reg_mode = V16QImode; |
| 27432 |
else |
| 27433 |
reg_mode = word_mode; |
| 27434 |
reg_mode_size = GET_MODE_SIZE (reg_mode); |
| 27435 |
|
| 27436 |
gcc_assert (reg_mode_size * nregs == GET_MODE_SIZE (mode)); |
| 27437 |
|
| 27438 |
/* TDmode residing in FP registers is special, since the ISA requires that |
| 27439 |
the lower-numbered word of a register pair is always the most significant |
| 27440 |
word, even in little-endian mode. This does not match the usual subreg |
| 27441 |
semantics, so we cannnot use simplify_gen_subreg in those cases. Access |
| 27442 |
the appropriate constituent registers "by hand" in little-endian mode. |
| 27443 |
|
| 27444 |
Note we do not need to check for destructive overlap here since TDmode |
| 27445 |
can only reside in even/odd register pairs. */ |
| 27446 |
if (FP_REGNO_P (reg) && DECIMAL_FLOAT_MODE_P (mode) && !BYTES_BIG_ENDIAN) |
| 27447 |
{ |
| 27448 |
rtx p_src, p_dst; |
| 27449 |
int i; |
| 27450 |
|
| 27451 |
for (i = 0; i < nregs; i++) |
| 27452 |
{ |
| 27453 |
if (REG_P (src) && FP_REGNO_P (REGNO (src))) |
| 27454 |
p_src = gen_rtx_REG (reg_mode, REGNO (src) + nregs - 1 - i); |
| 27455 |
else |
| 27456 |
p_src = simplify_gen_subreg (reg_mode, src, mode, |
| 27457 |
i * reg_mode_size); |
| 27458 |
|
| 27459 |
if (REG_P (dst) && FP_REGNO_P (REGNO (dst))) |
| 27460 |
p_dst = gen_rtx_REG (reg_mode, REGNO (dst) + nregs - 1 - i); |
| 27461 |
else |
| 27462 |
p_dst = simplify_gen_subreg (reg_mode, dst, mode, |
| 27463 |
i * reg_mode_size); |
| 27464 |
|
| 27465 |
emit_insn (gen_rtx_SET (p_dst, p_src)); |
| 27466 |
} |
| 27467 |
|
| 27468 |
return; |
| 27469 |
} |
| 27470 |
|
| 27471 |
/* The __vector_pair and __vector_quad modes are multi-register |
| 27472 |
modes, so if we have to load or store the registers, we have to be |
| 27473 |
careful to properly swap them if we're in little endian mode |
| 27474 |
below. This means the last register gets the first memory |
| 27475 |
location. We also need to be careful of using the right register |
| 27476 |
numbers if we are splitting XO to OO. */ |
| 27477 |
if (mode == OOmode || mode == XOmode) |
| 27478 |
{ |
| 27479 |
nregs = hard_regno_nregs (reg, mode); |
| 27480 |
int reg_mode_nregs = hard_regno_nregs (reg, reg_mode); |
| 27481 |
if (MEM_P (dst)) |
| 27482 |
{ |
| 27483 |
unsigned offset = 0; |
| 27484 |
unsigned size = GET_MODE_SIZE (reg_mode); |
| 27485 |
|
| 27486 |
/* If we are reading an accumulator register, we have to |
| 27487 |
deprime it before we can access it. */ |
| 27488 |
if (TARGET_MMA |
| 27489 |
&& GET_MODE (src) == XOmode && FP_REGNO_P (REGNO (src))) |
| 27490 |
emit_insn (gen_mma_xxmfacc (src, src)); |
| 27491 |
|
| 27492 |
for (int i = 0; i < nregs; i += reg_mode_nregs) |
| 27493 |
{ |
| 27494 |
unsigned subreg |
| 27495 |
= WORDS_BIG_ENDIAN ? i : (nregs - reg_mode_nregs - i); |
| 27496 |
rtx dst2 = adjust_address (dst, reg_mode, offset); |
| 27497 |
rtx src2 = gen_rtx_REG (reg_mode, reg + subreg); |
| 27498 |
offset += size; |
| 27499 |
emit_insn (gen_rtx_SET (dst2, src2)); |
| 27500 |
} |
| 27501 |
|
| 27502 |
return; |
| 27503 |
} |
| 27504 |
|
| 27505 |
if (MEM_P (src)) |
| 27506 |
{ |
| 27507 |
unsigned offset = 0; |
| 27508 |
unsigned size = GET_MODE_SIZE (reg_mode); |
| 27509 |
|
| 27510 |
for (int i = 0; i < nregs; i += reg_mode_nregs) |
| 27511 |
{ |
| 27512 |
unsigned subreg |
| 27513 |
= WORDS_BIG_ENDIAN ? i : (nregs - reg_mode_nregs - i); |
| 27514 |
rtx dst2 = gen_rtx_REG (reg_mode, reg + subreg); |
| 27515 |
rtx src2 = adjust_address (src, reg_mode, offset); |
| 27516 |
offset += size; |
| 27517 |
emit_insn (gen_rtx_SET (dst2, src2)); |
| 27518 |
} |
| 27519 |
|
| 27520 |
/* If we are writing an accumulator register, we have to |
| 27521 |
prime it after we've written it. */ |
| 27522 |
if (TARGET_MMA |
| 27523 |
&& GET_MODE (dst) == XOmode && FP_REGNO_P (REGNO (dst))) |
| 27524 |
emit_insn (gen_mma_xxmtacc (dst, dst)); |
| 27525 |
|
| 27526 |
return; |
| 27527 |
} |
| 27528 |
|
| 27529 |
if (GET_CODE (src) == UNSPEC |
| 27530 |
|| GET_CODE (src) == UNSPEC_VOLATILE) |
| 27531 |
{ |
| 27532 |
gcc_assert (XINT (src, 1) == UNSPEC_VSX_ASSEMBLE |
| 27533 |
|| XINT (src, 1) == UNSPECV_MMA_ASSEMBLE); |
| 27534 |
gcc_assert (REG_P (dst)); |
| 27535 |
if (GET_MODE (src) == XOmode) |
| 27536 |
gcc_assert (FP_REGNO_P (REGNO (dst))); |
| 27537 |
if (GET_MODE (src) == OOmode) |
| 27538 |
gcc_assert (VSX_REGNO_P (REGNO (dst))); |
| 27539 |
|
| 27540 |
int nvecs = XVECLEN (src, 0); |
| 27541 |
for (int i = 0; i < nvecs; i++) |
| 27542 |
{ |
| 27543 |
rtx op; |
| 27544 |
int regno = reg + i; |
| 27545 |
|
| 27546 |
if (WORDS_BIG_ENDIAN) |
| 27547 |
{ |
| 27548 |
op = XVECEXP (src, 0, i); |
| 27549 |
|
| 27550 |
/* If we are loading an even VSX register and the memory location |
| 27551 |
is adjacent to the next register's memory location (if any), |
| 27552 |
then we can load them both with one LXVP instruction. */ |
| 27553 |
if ((regno & 1) == 0) |
| 27554 |
{ |
| 27555 |
rtx op2 = XVECEXP (src, 0, i + 1); |
| 27556 |
if (adjacent_mem_locations (op, op2) == op) |
| 27557 |
{ |
| 27558 |
op = adjust_address (op, OOmode, 0); |
| 27559 |
/* Skip the next register, since we're going to |
| 27560 |
load it together with this register. */ |
| 27561 |
i++; |
| 27562 |
} |
| 27563 |
} |
| 27564 |
} |
| 27565 |
else |
| 27566 |
{ |
| 27567 |
op = XVECEXP (src, 0, nvecs - i - 1); |
| 27568 |
|
| 27569 |
/* If we are loading an even VSX register and the memory location |
| 27570 |
is adjacent to the next register's memory location (if any), |
| 27571 |
then we can load them both with one LXVP instruction. */ |
| 27572 |
if ((regno & 1) == 0) |
| 27573 |
{ |
| 27574 |
rtx op2 = XVECEXP (src, 0, nvecs - i - 2); |
| 27575 |
if (adjacent_mem_locations (op2, op) == op2) |
| 27576 |
{ |
| 27577 |
op = adjust_address (op2, OOmode, 0); |
| 27578 |
/* Skip the next register, since we're going to |
| 27579 |
load it together with this register. */ |
| 27580 |
i++; |
| 27581 |
} |
| 27582 |
} |
| 27583 |
} |
| 27584 |
|
| 27585 |
rtx dst_i = gen_rtx_REG (GET_MODE (op), regno); |
| 27586 |
emit_insn (gen_rtx_SET (dst_i, op)); |
| 27587 |
} |
| 27588 |
|
| 27589 |
/* We are writing an accumulator register, so we have to |
| 27590 |
prime it after we've written it. */ |
| 27591 |
if (GET_MODE (src) == XOmode) |
| 27592 |
emit_insn (gen_mma_xxmtacc (dst, dst)); |
| 27593 |
|
| 27594 |
return; |
| 27595 |
} |
| 27596 |
|
| 27597 |
/* Register -> register moves can use common code. */ |
| 27598 |
} |
| 27599 |
|
| 27600 |
if (REG_P (src) && REG_P (dst) && (REGNO (src) < REGNO (dst))) |
| 27601 |
{ |
| 27602 |
/* If we are reading an accumulator register, we have to |
| 27603 |
deprime it before we can access it. */ |
| 27604 |
if (TARGET_MMA |
| 27605 |
&& GET_MODE (src) == XOmode && FP_REGNO_P (REGNO (src))) |
| 27606 |
emit_insn (gen_mma_xxmfacc (src, src)); |
| 27607 |
|
| 27608 |
/* Move register range backwards, if we might have destructive |
| 27609 |
overlap. */ |
| 27610 |
int i; |
| 27611 |
/* XO/OO are opaque so cannot use subregs. */ |
| 27612 |
if (mode == OOmode || mode == XOmode ) |
| 27613 |
{ |
| 27614 |
for (i = nregs - 1; i >= 0; i--) |
| 27615 |
{ |
| 27616 |
rtx dst_i = gen_rtx_REG (reg_mode, REGNO (dst) + i); |
| 27617 |
rtx src_i = gen_rtx_REG (reg_mode, REGNO (src) + i); |
| 27618 |
emit_insn (gen_rtx_SET (dst_i, src_i)); |
| 27619 |
} |
| 27620 |
} |
| 27621 |
else |
| 27622 |
{ |
| 27623 |
for (i = nregs - 1; i >= 0; i--) |
| 27624 |
emit_insn (gen_rtx_SET (simplify_gen_subreg (reg_mode, dst, mode, |
| 27625 |
i * reg_mode_size), |
| 27626 |
simplify_gen_subreg (reg_mode, src, mode, |
| 27627 |
i * reg_mode_size))); |
| 27628 |
} |
| 27629 |
|
| 27630 |
/* If we are writing an accumulator register, we have to |
| 27631 |
prime it after we've written it. */ |
| 27632 |
if (TARGET_MMA |
| 27633 |
&& GET_MODE (dst) == XOmode && FP_REGNO_P (REGNO (dst))) |
| 27634 |
emit_insn (gen_mma_xxmtacc (dst, dst)); |
| 27635 |
} |
| 27636 |
else |
| 27637 |
{ |
| 27638 |
int i; |
| 27639 |
int j = -1; |
| 27640 |
bool used_update = false; |
| 27641 |
rtx restore_basereg = NULL_RTX; |
| 27642 |
|
| 27643 |
if (MEM_P (src) && INT_REGNO_P (reg)) |
| 27644 |
{ |
| 27645 |
rtx breg; |
| 27646 |
|
| 27647 |
if (GET_CODE (XEXP (src, 0)) == PRE_INC |
| 27648 |
|| GET_CODE (XEXP (src, 0)) == PRE_DEC) |
| 27649 |
{ |
| 27650 |
rtx delta_rtx; |
| 27651 |
breg = XEXP (XEXP (src, 0), 0); |
| 27652 |
delta_rtx = (GET_CODE (XEXP (src, 0)) == PRE_INC |
| 27653 |
? GEN_INT (GET_MODE_SIZE (GET_MODE (src))) |
| 27654 |
: GEN_INT (-GET_MODE_SIZE (GET_MODE (src)))); |
| 27655 |
emit_insn (gen_add3_insn (breg, breg, delta_rtx)); |
| 27656 |
src = replace_equiv_address (src, breg); |
| 27657 |
} |
| 27658 |
else if (! rs6000_offsettable_memref_p (src, reg_mode, true)) |
| 27659 |
{ |
| 27660 |
if (GET_CODE (XEXP (src, 0)) == PRE_MODIFY) |
| 27661 |
{ |
| 27662 |
rtx basereg = XEXP (XEXP (src, 0), 0); |
| 27663 |
if (TARGET_UPDATE) |
| 27664 |
{ |
| 27665 |
rtx ndst = simplify_gen_subreg (reg_mode, dst, mode, 0); |
| 27666 |
emit_insn (gen_rtx_SET (ndst, |
| 27667 |
gen_rtx_MEM (reg_mode, |
| 27668 |
XEXP (src, 0)))); |
| 27669 |
used_update = true; |
| 27670 |
} |
| 27671 |
else |
| 27672 |
emit_insn (gen_rtx_SET (basereg, |
| 27673 |
XEXP (XEXP (src, 0), 1))); |
| 27674 |
src = replace_equiv_address (src, basereg); |
| 27675 |
} |
| 27676 |
else |
| 27677 |
{ |
| 27678 |
rtx basereg = gen_rtx_REG (Pmode, reg); |
| 27679 |
emit_insn (gen_rtx_SET (basereg, XEXP (src, 0))); |
| 27680 |
src = replace_equiv_address (src, basereg); |
| 27681 |
} |
| 27682 |
} |
| 27683 |
|
| 27684 |
breg = XEXP (src, 0); |
| 27685 |
if (GET_CODE (breg) == PLUS || GET_CODE (breg) == LO_SUM) |
| 27686 |
breg = XEXP (breg, 0); |
| 27687 |
|
| 27688 |
/* If the base register we are using to address memory is |
| 27689 |
also a destination reg, then change that register last. */ |
| 27690 |
if (REG_P (breg) |
| 27691 |
&& REGNO (breg) >= REGNO (dst) |
| 27692 |
&& REGNO (breg) < REGNO (dst) + nregs) |
| 27693 |
j = REGNO (breg) - REGNO (dst); |
| 27694 |
} |
| 27695 |
else if (MEM_P (dst) && INT_REGNO_P (reg)) |
| 27696 |
{ |
| 27697 |
rtx breg; |
| 27698 |
|
| 27699 |
if (GET_CODE (XEXP (dst, 0)) == PRE_INC |
| 27700 |
|| GET_CODE (XEXP (dst, 0)) == PRE_DEC) |
| 27701 |
{ |
| 27702 |
rtx delta_rtx; |
| 27703 |
breg = XEXP (XEXP (dst, 0), 0); |
| 27704 |
delta_rtx = (GET_CODE (XEXP (dst, 0)) == PRE_INC |
| 27705 |
? GEN_INT (GET_MODE_SIZE (GET_MODE (dst))) |
| 27706 |
: GEN_INT (-GET_MODE_SIZE (GET_MODE (dst)))); |
| 27707 |
|
| 27708 |
/* We have to update the breg before doing the store. |
| 27709 |
Use store with update, if available. */ |
| 27710 |
|
| 27711 |
if (TARGET_UPDATE) |
| 27712 |
{ |
| 27713 |
rtx nsrc = simplify_gen_subreg (reg_mode, src, mode, 0); |
| 27714 |
emit_insn (TARGET_32BIT |
| 27715 |
? (TARGET_POWERPC64 |
| 27716 |
? gen_movdi_si_update (breg, breg, delta_rtx, nsrc) |
| 27717 |
: gen_movsi_si_update (breg, breg, delta_rtx, nsrc)) |
| 27718 |
: gen_movdi_di_update (breg, breg, delta_rtx, nsrc)); |
| 27719 |
used_update = true; |
| 27720 |
} |
| 27721 |
else |
| 27722 |
emit_insn (gen_add3_insn (breg, breg, delta_rtx)); |
| 27723 |
dst = replace_equiv_address (dst, breg); |
| 27724 |
} |
| 27725 |
else if (!rs6000_offsettable_memref_p (dst, reg_mode, true) |
| 27726 |
&& GET_CODE (XEXP (dst, 0)) != LO_SUM) |
| 27727 |
{ |
| 27728 |
if (GET_CODE (XEXP (dst, 0)) == PRE_MODIFY) |
| 27729 |
{ |
| 27730 |
rtx basereg = XEXP (XEXP (dst, 0), 0); |
| 27731 |
if (TARGET_UPDATE) |
| 27732 |
{ |
| 27733 |
rtx nsrc = simplify_gen_subreg (reg_mode, src, mode, 0); |
| 27734 |
emit_insn (gen_rtx_SET (gen_rtx_MEM (reg_mode, |
| 27735 |
XEXP (dst, 0)), |
| 27736 |
nsrc)); |
| 27737 |
used_update = true; |
| 27738 |
} |
| 27739 |
else |
| 27740 |
emit_insn (gen_rtx_SET (basereg, |
| 27741 |
XEXP (XEXP (dst, 0), 1))); |
| 27742 |
dst = replace_equiv_address (dst, basereg); |
| 27743 |
} |
| 27744 |
else |
| 27745 |
{ |
| 27746 |
rtx basereg = XEXP (XEXP (dst, 0), 0); |
| 27747 |
rtx offsetreg = XEXP (XEXP (dst, 0), 1); |
| 27748 |
gcc_assert (GET_CODE (XEXP (dst, 0)) == PLUS |
| 27749 |
&& REG_P (basereg) |
| 27750 |
&& REG_P (offsetreg) |
| 27751 |
&& REGNO (basereg) != REGNO (offsetreg)); |
| 27752 |
if (REGNO (basereg) == 0) |
| 27753 |
{ |
| 27754 |
rtx tmp = offsetreg; |
| 27755 |
offsetreg = basereg; |
| 27756 |
basereg = tmp; |
| 27757 |
} |
| 27758 |
emit_insn (gen_add3_insn (basereg, basereg, offsetreg)); |
| 27759 |
restore_basereg = gen_sub3_insn (basereg, basereg, offsetreg); |
| 27760 |
dst = replace_equiv_address (dst, basereg); |
| 27761 |
} |
| 27762 |
} |
| 27763 |
else if (GET_CODE (XEXP (dst, 0)) != LO_SUM) |
| 27764 |
gcc_assert (rs6000_offsettable_memref_p (dst, reg_mode, true)); |
| 27765 |
} |
| 27766 |
|
| 27767 |
/* If we are reading an accumulator register, we have to |
| 27768 |
deprime it before we can access it. */ |
| 27769 |
if (TARGET_MMA && REG_P (src) |
| 27770 |
&& GET_MODE (src) == XOmode && FP_REGNO_P (REGNO (src))) |
| 27771 |
emit_insn (gen_mma_xxmfacc (src, src)); |
| 27772 |
|
| 27773 |
for (i = 0; i < nregs; i++) |
| 27774 |
{ |
| 27775 |
/* Calculate index to next subword. */ |
| 27776 |
++j; |
| 27777 |
if (j == nregs) |
| 27778 |
j = 0; |
| 27779 |
|
| 27780 |
/* If compiler already emitted move of first word by |
| 27781 |
store with update, no need to do anything. */ |
| 27782 |
if (j == 0 && used_update) |
| 27783 |
continue; |
| 27784 |
|
| 27785 |
/* XO/OO are opaque so cannot use subregs. */ |
| 27786 |
if (mode == OOmode || mode == XOmode ) |
| 27787 |
{ |
| 27788 |
rtx dst_i = gen_rtx_REG (reg_mode, REGNO (dst) + j); |
| 27789 |
rtx src_i = gen_rtx_REG (reg_mode, REGNO (src) + j); |
| 27790 |
emit_insn (gen_rtx_SET (dst_i, src_i)); |
| 27791 |
} |
| 27792 |
else |
| 27793 |
emit_insn (gen_rtx_SET (simplify_gen_subreg (reg_mode, dst, mode, |
| 27794 |
j * reg_mode_size), |
| 27795 |
simplify_gen_subreg (reg_mode, src, mode, |
| 27796 |
j * reg_mode_size))); |
| 27797 |
} |
| 27798 |
|
| 27799 |
/* If we are writing an accumulator register, we have to |
| 27800 |
prime it after we've written it. */ |
| 27801 |
if (TARGET_MMA && REG_P (dst) |
| 27802 |
&& GET_MODE (dst) == XOmode && FP_REGNO_P (REGNO (dst))) |
| 27803 |
emit_insn (gen_mma_xxmtacc (dst, dst)); |
| 27804 |
|
| 27805 |
if (restore_basereg != NULL_RTX) |
| 27806 |
emit_insn (restore_basereg); |
| 27807 |
} |
| 27808 |
} |
| 27809 |
|
| 27810 |
/* Return true if the peephole2 can combine a load involving a combination of |
| 27811 |
an addis instruction and a load with an offset that can be fused together on |
| 27812 |
a power8. */ |
| 27813 |
|
| 27814 |
bool |
| 27815 |
fusion_gpr_load_p (rtx addis_reg, /* register set via addis. */ |
| 27816 |
rtx addis_value, /* addis value. */ |
| 27817 |
rtx target, /* target register that is loaded. */ |
| 27818 |
rtx mem) /* bottom part of the memory addr. */ |
| 27819 |
{ |
| 27820 |
rtx addr; |
| 27821 |
rtx base_reg; |
| 27822 |
|
| 27823 |
/* Validate arguments. */ |
| 27824 |
if (!base_reg_operand (addis_reg, GET_MODE (addis_reg))) |
| 27825 |
return false; |
| 27826 |
|
| 27827 |
if (!base_reg_operand (target, GET_MODE (target))) |
| 27828 |
return false; |
| 27829 |
|
| 27830 |
if (!fusion_gpr_addis (addis_value, GET_MODE (addis_value))) |
| 27831 |
return false; |
| 27832 |
|
| 27833 |
/* Allow sign/zero extension. */ |
| 27834 |
if (GET_CODE (mem) == ZERO_EXTEND |
| 27835 |
|| (GET_CODE (mem) == SIGN_EXTEND && TARGET_P8_FUSION_SIGN)) |
| 27836 |
mem = XEXP (mem, 0); |
| 27837 |
|
| 27838 |
if (!MEM_P (mem)) |
| 27839 |
return false; |
| 27840 |
|
| 27841 |
if (!fusion_gpr_mem_load (mem, GET_MODE (mem))) |
| 27842 |
return false; |
| 27843 |
|
| 27844 |
addr = XEXP (mem, 0); /* either PLUS or LO_SUM. */ |
| 27845 |
if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM) |
| 27846 |
return false; |
| 27847 |
|
| 27848 |
/* Validate that the register used to load the high value is either the |
| 27849 |
register being loaded, or we can safely replace its use. |
| 27850 |
|
| 27851 |
This function is only called from the peephole2 pass and we assume that |
| 27852 |
there are 2 instructions in the peephole (addis and load), so we want to |
| 27853 |
check if the target register was not used in the memory address and the |
| 27854 |
register to hold the addis result is dead after the peephole. */ |
| 27855 |
if (REGNO (addis_reg) != REGNO (target)) |
| 27856 |
{ |
| 27857 |
if (reg_mentioned_p (target, mem)) |
| 27858 |
return false; |
| 27859 |
|
| 27860 |
if (!peep2_reg_dead_p (2, addis_reg)) |
| 27861 |
return false; |
| 27862 |
|
| 27863 |
/* If the target register being loaded is the stack pointer, we must |
| 27864 |
avoid loading any other value into it, even temporarily. */ |
| 27865 |
if (REG_P (target) && REGNO (target) == STACK_POINTER_REGNUM) |
| 27866 |
return false; |
| 27867 |
} |
| 27868 |
|
| 27869 |
base_reg = XEXP (addr, 0); |
| 27870 |
return REGNO (addis_reg) == REGNO (base_reg); |
| 27871 |
} |
| 27872 |
|
| 27873 |
/* During the peephole2 pass, adjust and expand the insns for a load fusion |
| 27874 |
sequence. We adjust the addis register to use the target register. If the |
| 27875 |
load sign extends, we adjust the code to do the zero extending load, and an |
| 27876 |
explicit sign extension later since the fusion only covers zero extending |
| 27877 |
loads. |
| 27878 |
|
| 27879 |
The operands are: |
| 27880 |
operands[0] register set with addis (to be replaced with target) |
| 27881 |
operands[1] value set via addis |
| 27882 |
operands[2] target register being loaded |
| 27883 |
operands[3] D-form memory reference using operands[0]. */ |
| 27884 |
|
| 27885 |
void |
| 27886 |
expand_fusion_gpr_load (rtx *operands) |
| 27887 |
{ |
| 27888 |
rtx addis_value = operands[1]; |
| 27889 |
rtx target = operands[2]; |
| 27890 |
rtx orig_mem = operands[3]; |
| 27891 |
rtx new_addr, new_mem, orig_addr, offset; |
| 27892 |
enum rtx_code plus_or_lo_sum; |
| 27893 |
machine_mode target_mode = GET_MODE (target); |
| 27894 |
machine_mode extend_mode = target_mode; |
| 27895 |
machine_mode ptr_mode = Pmode; |
| 27896 |
enum rtx_code extend = UNKNOWN; |
| 27897 |
|
| 27898 |
if (GET_CODE (orig_mem) == ZERO_EXTEND |
| 27899 |
|| (TARGET_P8_FUSION_SIGN && GET_CODE (orig_mem) == SIGN_EXTEND)) |
| 27900 |
{ |
| 27901 |
extend = GET_CODE (orig_mem); |
| 27902 |
orig_mem = XEXP (orig_mem, 0); |
| 27903 |
target_mode = GET_MODE (orig_mem); |
| 27904 |
} |
| 27905 |
|
| 27906 |
gcc_assert (MEM_P (orig_mem)); |
| 27907 |
|
| 27908 |
orig_addr = XEXP (orig_mem, 0); |
| 27909 |
plus_or_lo_sum = GET_CODE (orig_addr); |
| 27910 |
gcc_assert (plus_or_lo_sum == PLUS || plus_or_lo_sum == LO_SUM); |
| 27911 |
|
| 27912 |
offset = XEXP (orig_addr, 1); |
| 27913 |
new_addr = gen_rtx_fmt_ee (plus_or_lo_sum, ptr_mode, addis_value, offset); |
| 27914 |
new_mem = replace_equiv_address_nv (orig_mem, new_addr, false); |
| 27915 |
|
| 27916 |
if (extend != UNKNOWN) |
| 27917 |
new_mem = gen_rtx_fmt_e (ZERO_EXTEND, extend_mode, new_mem); |
| 27918 |
|
| 27919 |
new_mem = gen_rtx_UNSPEC (extend_mode, gen_rtvec (1, new_mem), |
| 27920 |
UNSPEC_FUSION_GPR); |
| 27921 |
emit_insn (gen_rtx_SET (target, new_mem)); |
| 27922 |
|
| 27923 |
if (extend == SIGN_EXTEND) |
| 27924 |
{ |
| 27925 |
int sub_off = ((BYTES_BIG_ENDIAN) |
| 27926 |
? GET_MODE_SIZE (extend_mode) - GET_MODE_SIZE (target_mode) |
| 27927 |
: 0); |
| 27928 |
rtx sign_reg |
| 27929 |
= simplify_subreg (target_mode, target, extend_mode, sub_off); |
| 27930 |
|
| 27931 |
emit_insn (gen_rtx_SET (target, |
| 27932 |
gen_rtx_SIGN_EXTEND (extend_mode, sign_reg))); |
| 27933 |
} |
| 27934 |
|
| 27935 |
return; |
| 27936 |
} |
| 27937 |
|
| 27938 |
/* Emit the addis instruction that will be part of a fused instruction |
| 27939 |
sequence. */ |
| 27940 |
|
| 27941 |
void |
| 27942 |
emit_fusion_addis (rtx target, rtx addis_value) |
| 27943 |
{ |
| 27944 |
rtx fuse_ops[10]; |
| 27945 |
const char *addis_str = NULL; |
| 27946 |
|
| 27947 |
/* Emit the addis instruction. */ |
| 27948 |
fuse_ops[0] = target; |
| 27949 |
if (satisfies_constraint_L (addis_value)) |
| 27950 |
{ |
| 27951 |
fuse_ops[1] = addis_value; |
| 27952 |
addis_str = "lis %0,%v1"; |
| 27953 |
} |
| 27954 |
|
| 27955 |
else if (GET_CODE (addis_value) == PLUS) |
| 27956 |
{ |
| 27957 |
rtx op0 = XEXP (addis_value, 0); |
| 27958 |
rtx op1 = XEXP (addis_value, 1); |
| 27959 |
|
| 27960 |
if (REG_P (op0) && CONST_INT_P (op1) |
| 27961 |
&& satisfies_constraint_L (op1)) |
| 27962 |
{ |
| 27963 |
fuse_ops[1] = op0; |
| 27964 |
fuse_ops[2] = op1; |
| 27965 |
addis_str = "addis %0,%1,%v2"; |
| 27966 |
} |
| 27967 |
} |
| 27968 |
|
| 27969 |
else if (GET_CODE (addis_value) == HIGH) |
| 27970 |
{ |
| 27971 |
rtx value = XEXP (addis_value, 0); |
| 27972 |
if (GET_CODE (value) == UNSPEC && XINT (value, 1) == UNSPEC_TOCREL) |
| 27973 |
{ |
| 27974 |
fuse_ops[1] = XVECEXP (value, 0, 0); /* symbol ref. */ |
| 27975 |
fuse_ops[2] = XVECEXP (value, 0, 1); /* TOC register. */ |
| 27976 |
if (TARGET_ELF) |
| 27977 |
addis_str = "addis %0,%2,%1@toc@ha"; |
| 27978 |
|
| 27979 |
else if (TARGET_XCOFF) |
| 27980 |
addis_str = "addis %0,%1@u(%2)"; |
| 27981 |
|
| 27982 |
else |
| 27983 |
gcc_unreachable (); |
| 27984 |
} |
| 27985 |
|
| 27986 |
else if (GET_CODE (value) == PLUS) |
| 27987 |
{ |
| 27988 |
rtx op0 = XEXP (value, 0); |
| 27989 |
rtx op1 = XEXP (value, 1); |
| 27990 |
|
| 27991 |
if (GET_CODE (op0) == UNSPEC |
| 27992 |
&& XINT (op0, 1) == UNSPEC_TOCREL |
| 27993 |
&& CONST_INT_P (op1)) |
| 27994 |
{ |
| 27995 |
fuse_ops[1] = XVECEXP (op0, 0, 0); /* symbol ref. */ |
| 27996 |
fuse_ops[2] = XVECEXP (op0, 0, 1); /* TOC register. */ |
| 27997 |
fuse_ops[3] = op1; |
| 27998 |
if (TARGET_ELF) |
| 27999 |
addis_str = "addis %0,%2,%1+%3@toc@ha"; |
| 28000 |
|
| 28001 |
else if (TARGET_XCOFF) |
| 28002 |
addis_str = "addis %0,%1+%3@u(%2)"; |
| 28003 |
|
| 28004 |
else |
| 28005 |
gcc_unreachable (); |
| 28006 |
} |
| 28007 |
} |
| 28008 |
|
| 28009 |
else if (satisfies_constraint_L (value)) |
| 28010 |
{ |
| 28011 |
fuse_ops[1] = value; |
| 28012 |
addis_str = "lis %0,%v1"; |
| 28013 |
} |
| 28014 |
|
| 28015 |
else if (TARGET_ELF && !TARGET_POWERPC64 && CONSTANT_P (value)) |
| 28016 |
{ |
| 28017 |
fuse_ops[1] = value; |
| 28018 |
addis_str = "lis %0,%1@ha"; |
| 28019 |
} |
| 28020 |
} |
| 28021 |
|
| 28022 |
if (!addis_str) |
| 28023 |
fatal_insn ("Could not generate addis value for fusion", addis_value); |
| 28024 |
|
| 28025 |
output_asm_insn (addis_str, fuse_ops); |
| 28026 |
} |
| 28027 |
|
| 28028 |
/* Emit a D-form load or store instruction that is the second instruction |
| 28029 |
of a fusion sequence. */ |
| 28030 |
|
| 28031 |
static void |
| 28032 |
emit_fusion_load (rtx load_reg, rtx addis_reg, rtx offset, const char *insn_str) |
| 28033 |
{ |
| 28034 |
rtx fuse_ops[10]; |
| 28035 |
char insn_template[80]; |
| 28036 |
|
| 28037 |
fuse_ops[0] = load_reg; |
| 28038 |
fuse_ops[1] = addis_reg; |
| 28039 |
|
| 28040 |
if (CONST_INT_P (offset) && satisfies_constraint_I (offset)) |
| 28041 |
{ |
| 28042 |
sprintf (insn_template, "%s %%0,%%2(%%1)", insn_str); |
| 28043 |
fuse_ops[2] = offset; |
| 28044 |
output_asm_insn (insn_template, fuse_ops); |
| 28045 |
} |
| 28046 |
|
| 28047 |
else if (GET_CODE (offset) == UNSPEC |
| 28048 |
&& XINT (offset, 1) == UNSPEC_TOCREL) |
| 28049 |
{ |
| 28050 |
if (TARGET_ELF) |
| 28051 |
sprintf (insn_template, "%s %%0,%%2@toc@l(%%1)", insn_str); |
| 28052 |
|
| 28053 |
else if (TARGET_XCOFF) |
| 28054 |
sprintf (insn_template, "%s %%0,%%2@l(%%1)", insn_str); |
| 28055 |
|
| 28056 |
else |
| 28057 |
gcc_unreachable (); |
| 28058 |
|
| 28059 |
fuse_ops[2] = XVECEXP (offset, 0, 0); |
| 28060 |
output_asm_insn (insn_template, fuse_ops); |
| 28061 |
} |
| 28062 |
|
| 28063 |
else if (GET_CODE (offset) == PLUS |
| 28064 |
&& GET_CODE (XEXP (offset, 0)) == UNSPEC |
| 28065 |
&& XINT (XEXP (offset, 0), 1) == UNSPEC_TOCREL |
| 28066 |
&& CONST_INT_P (XEXP (offset, 1))) |
| 28067 |
{ |
| 28068 |
rtx tocrel_unspec = XEXP (offset, 0); |
| 28069 |
if (TARGET_ELF) |
| 28070 |
sprintf (insn_template, "%s %%0,%%2+%%3@toc@l(%%1)", insn_str); |
| 28071 |
|
| 28072 |
else if (TARGET_XCOFF) |
| 28073 |
sprintf (insn_template, "%s %%0,%%2+%%3@l(%%1)", insn_str); |
| 28074 |
|
| 28075 |
else |
| 28076 |
gcc_unreachable (); |
| 28077 |
|
| 28078 |
fuse_ops[2] = XVECEXP (tocrel_unspec, 0, 0); |
| 28079 |
fuse_ops[3] = XEXP (offset, 1); |
| 28080 |
output_asm_insn (insn_template, fuse_ops); |
| 28081 |
} |
| 28082 |
|
| 28083 |
else if (TARGET_ELF && !TARGET_POWERPC64 && CONSTANT_P (offset)) |
| 28084 |
{ |
| 28085 |
sprintf (insn_template, "%s %%0,%%2@l(%%1)", insn_str); |
| 28086 |
|
| 28087 |
fuse_ops[2] = offset; |
| 28088 |
output_asm_insn (insn_template, fuse_ops); |
| 28089 |
} |
| 28090 |
|
| 28091 |
else |
| 28092 |
fatal_insn ("Unable to generate load/store offset for fusion", offset); |
| 28093 |
|
| 28094 |
return; |
| 28095 |
} |
| 28096 |
|
| 28097 |
/* Given an address, convert it into the addis and load offset parts. Addresses |
| 28098 |
created during the peephole2 process look like: |
| 28099 |
(lo_sum (high (unspec [(sym)] UNSPEC_TOCREL)) |
| 28100 |
(unspec [(...)] UNSPEC_TOCREL)) */ |
| 28101 |
|
| 28102 |
static void |
| 28103 |
fusion_split_address (rtx addr, rtx *p_hi, rtx *p_lo) |
| 28104 |
{ |
| 28105 |
rtx hi, lo; |
| 28106 |
|
| 28107 |
if (GET_CODE (addr) == PLUS || GET_CODE (addr) == LO_SUM) |
| 28108 |
{ |
| 28109 |
hi = XEXP (addr, 0); |
| 28110 |
lo = XEXP (addr, 1); |
| 28111 |
} |
| 28112 |
else |
| 28113 |
gcc_unreachable (); |
| 28114 |
|
| 28115 |
*p_hi = hi; |
| 28116 |
*p_lo = lo; |
| 28117 |
} |
| 28118 |
|
| 28119 |
/* Return a string to fuse an addis instruction with a gpr load to the same |
| 28120 |
register that we loaded up the addis instruction. The address that is used |
| 28121 |
is the logical address that was formed during peephole2: |
| 28122 |
(lo_sum (high) (low-part)) |
| 28123 |
|
| 28124 |
The code is complicated, so we call output_asm_insn directly, and just |
| 28125 |
return "". */ |
| 28126 |
|
| 28127 |
const char * |
| 28128 |
emit_fusion_gpr_load (rtx target, rtx mem) |
| 28129 |
{ |
| 28130 |
rtx addis_value; |
| 28131 |
rtx addr; |
| 28132 |
rtx load_offset; |
| 28133 |
const char *load_str = NULL; |
| 28134 |
machine_mode mode; |
| 28135 |
|
| 28136 |
if (GET_CODE (mem) == ZERO_EXTEND) |
| 28137 |
mem = XEXP (mem, 0); |
| 28138 |
|
| 28139 |
gcc_assert (REG_P (target) && MEM_P (mem)); |
| 28140 |
|
| 28141 |
addr = XEXP (mem, 0); |
| 28142 |
fusion_split_address (addr, &addis_value, &load_offset); |
| 28143 |
|
| 28144 |
/* Now emit the load instruction to the same register. */ |
| 28145 |
mode = GET_MODE (mem); |
| 28146 |
switch (mode) |
| 28147 |
{ |
| 28148 |
case E_QImode: |
| 28149 |
load_str = "lbz"; |
| 28150 |
break; |
| 28151 |
|
| 28152 |
case E_HImode: |
| 28153 |
load_str = "lhz"; |
| 28154 |
break; |
| 28155 |
|
| 28156 |
case E_SImode: |
| 28157 |
case E_SFmode: |
| 28158 |
load_str = "lwz"; |
| 28159 |
break; |
| 28160 |
|
| 28161 |
case E_DImode: |
| 28162 |
case E_DFmode: |
| 28163 |
gcc_assert (TARGET_POWERPC64); |
| 28164 |
load_str = "ld"; |
| 28165 |
break; |
| 28166 |
|
| 28167 |
default: |
| 28168 |
fatal_insn ("Bad GPR fusion", gen_rtx_SET (target, mem)); |
| 28169 |
} |
| 28170 |
|
| 28171 |
/* Emit the addis instruction. */ |
| 28172 |
emit_fusion_addis (target, addis_value); |
| 28173 |
|
| 28174 |
/* Emit the D-form load instruction. */ |
| 28175 |
emit_fusion_load (target, target, load_offset, load_str); |
| 28176 |
|
| 28177 |
return ""; |
| 28178 |
} |
| 28179 |
|
| 28180 |
/* This is not inside an #ifdef RS6000_GLIBC_ATOMIC_FENV because gengtype |
| 28181 |
ignores it then. */ |
| 28182 |
static GTY(()) tree atomic_hold_decl; |
| 28183 |
static GTY(()) tree atomic_clear_decl; |
| 28184 |
static GTY(()) tree atomic_update_decl; |
| 28185 |
|
| 28186 |
/* Implement TARGET_ATOMIC_ASSIGN_EXPAND_FENV hook. */ |
| 28187 |
static void |
| 28188 |
rs6000_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) |
| 28189 |
{ |
| 28190 |
if (!TARGET_HARD_FLOAT) |
| 28191 |
{ |
| 28192 |
#ifdef RS6000_GLIBC_ATOMIC_FENV |
| 28193 |
if (atomic_hold_decl == NULL_TREE) |
| 28194 |
{ |
| 28195 |
atomic_hold_decl |
| 28196 |
= build_decl (BUILTINS_LOCATION, FUNCTION_DECL, |
| 28197 |
get_identifier ("__atomic_feholdexcept"), |
| 28198 |
build_function_type_list (void_type_node, |
| 28199 |
double_ptr_type_node, |
| 28200 |
NULL_TREE)); |
| 28201 |
TREE_PUBLIC (atomic_hold_decl) = 1; |
| 28202 |
DECL_EXTERNAL (atomic_hold_decl) = 1; |
| 28203 |
} |
| 28204 |
|
| 28205 |
if (atomic_clear_decl == NULL_TREE) |
| 28206 |
{ |
| 28207 |
atomic_clear_decl |
| 28208 |
= build_decl (BUILTINS_LOCATION, FUNCTION_DECL, |
| 28209 |
get_identifier ("__atomic_feclearexcept"), |
| 28210 |
build_function_type_list (void_type_node, |
| 28211 |
NULL_TREE)); |
| 28212 |
TREE_PUBLIC (atomic_clear_decl) = 1; |
| 28213 |
DECL_EXTERNAL (atomic_clear_decl) = 1; |
| 28214 |
} |
| 28215 |
|
| 28216 |
tree const_double = build_qualified_type (double_type_node, |
| 28217 |
TYPE_QUAL_CONST); |
| 28218 |
tree const_double_ptr = build_pointer_type (const_double); |
| 28219 |
if (atomic_update_decl == NULL_TREE) |
| 28220 |
{ |
| 28221 |
atomic_update_decl |
| 28222 |
= build_decl (BUILTINS_LOCATION, FUNCTION_DECL, |
| 28223 |
get_identifier ("__atomic_feupdateenv"), |
| 28224 |
build_function_type_list (void_type_node, |
| 28225 |
const_double_ptr, |
| 28226 |
NULL_TREE)); |
| 28227 |
TREE_PUBLIC (atomic_update_decl) = 1; |
| 28228 |
DECL_EXTERNAL (atomic_update_decl) = 1; |
| 28229 |
} |
| 28230 |
|
| 28231 |
tree fenv_var = create_tmp_var_raw (double_type_node); |
| 28232 |
TREE_ADDRESSABLE (fenv_var) = 1; |
| 28233 |
tree fenv_addr = build1 (ADDR_EXPR, double_ptr_type_node, |
| 28234 |
build4 (TARGET_EXPR, double_type_node, fenv_var, |
| 28235 |
void_node, NULL_TREE, NULL_TREE)); |
| 28236 |
|
| 28237 |
*hold = build_call_expr (atomic_hold_decl, 1, fenv_addr); |
| 28238 |
*clear = build_call_expr (atomic_clear_decl, 0); |
| 28239 |
*update = build_call_expr (atomic_update_decl, 1, |
| 28240 |
fold_convert (const_double_ptr, fenv_addr)); |
| 28241 |
#endif |
| 28242 |
return; |
| 28243 |
} |
| 28244 |
|
| 28245 |
tree mffs = rs6000_builtin_decls[RS6000_BIF_MFFS]; |
| 28246 |
tree mtfsf = rs6000_builtin_decls[RS6000_BIF_MTFSF]; |
| 28247 |
tree call_mffs = build_call_expr (mffs, 0); |
| 28248 |
|
| 28249 |
/* Generates the equivalent of feholdexcept (&fenv_var) |
| 28250 |
|
| 28251 |
*fenv_var = __builtin_mffs (); |
| 28252 |
double fenv_hold; |
| 28253 |
*(uint64_t*)&fenv_hold = *(uint64_t*)fenv_var & 0xffffffff00000007LL; |
| 28254 |
__builtin_mtfsf (0xff, fenv_hold); */ |
| 28255 |
|
| 28256 |
/* Mask to clear everything except for the rounding modes and non-IEEE |
| 28257 |
arithmetic flag. */ |
| 28258 |
const unsigned HOST_WIDE_INT hold_exception_mask |
| 28259 |
= HOST_WIDE_INT_C (0xffffffff00000007); |
| 28260 |
|
| 28261 |
tree fenv_var = create_tmp_var_raw (double_type_node); |
| 28262 |
|
| 28263 |
tree hold_mffs = build4 (TARGET_EXPR, double_type_node, fenv_var, call_mffs, |
| 28264 |
NULL_TREE, NULL_TREE); |
| 28265 |
|
| 28266 |
tree fenv_llu = build1 (VIEW_CONVERT_EXPR, uint64_type_node, fenv_var); |
| 28267 |
tree fenv_llu_and = build2 (BIT_AND_EXPR, uint64_type_node, fenv_llu, |
| 28268 |
build_int_cst (uint64_type_node, |
| 28269 |
hold_exception_mask)); |
| 28270 |
|
| 28271 |
tree fenv_hold_mtfsf = build1 (VIEW_CONVERT_EXPR, double_type_node, |
| 28272 |
fenv_llu_and); |
| 28273 |
|
| 28274 |
tree hold_mtfsf = build_call_expr (mtfsf, 2, |
| 28275 |
build_int_cst (unsigned_type_node, 0xff), |
| 28276 |
fenv_hold_mtfsf); |
| 28277 |
|
| 28278 |
*hold = build2 (COMPOUND_EXPR, void_type_node, hold_mffs, hold_mtfsf); |
| 28279 |
|
| 28280 |
/* Generates the equivalent of feclearexcept (FE_ALL_EXCEPT): |
| 28281 |
|
| 28282 |
double fenv_clear = __builtin_mffs (); |
| 28283 |
*(uint64_t)&fenv_clear &= 0xffffffff00000000LL; |
| 28284 |
__builtin_mtfsf (0xff, fenv_clear); */ |
| 28285 |
|
| 28286 |
/* Mask to clear everything except for the rounding modes and non-IEEE |
| 28287 |
arithmetic flag. */ |
| 28288 |
const unsigned HOST_WIDE_INT clear_exception_mask |
| 28289 |
= HOST_WIDE_INT_C (0xffffffff00000000); |
| 28290 |
|
| 28291 |
tree fenv_clear = create_tmp_var_raw (double_type_node); |
| 28292 |
|
| 28293 |
tree clear_mffs = build4 (TARGET_EXPR, double_type_node, fenv_clear, |
| 28294 |
call_mffs, NULL_TREE, NULL_TREE); |
| 28295 |
|
| 28296 |
tree fenv_clean_llu = build1 (VIEW_CONVERT_EXPR, uint64_type_node, fenv_clear); |
| 28297 |
tree fenv_clear_llu_and = build2 (BIT_AND_EXPR, uint64_type_node, |
| 28298 |
fenv_clean_llu, |
| 28299 |
build_int_cst (uint64_type_node, |
| 28300 |
clear_exception_mask)); |
| 28301 |
|
| 28302 |
tree fenv_clear_mtfsf = build1 (VIEW_CONVERT_EXPR, double_type_node, |
| 28303 |
fenv_clear_llu_and); |
| 28304 |
|
| 28305 |
tree clear_mtfsf = build_call_expr (mtfsf, 2, |
| 28306 |
build_int_cst (unsigned_type_node, 0xff), |
| 28307 |
fenv_clear_mtfsf); |
| 28308 |
|
| 28309 |
*clear = build2 (COMPOUND_EXPR, void_type_node, clear_mffs, clear_mtfsf); |
| 28310 |
|
| 28311 |
/* Generates the equivalent of feupdateenv (&fenv_var) |
| 28312 |
|
| 28313 |
double old_fenv = __builtin_mffs (); |
| 28314 |
double fenv_update; |
| 28315 |
*(uint64_t*)&fenv_update = (*(uint64_t*)&old & 0xffffffff1fffff00LL) | |
| 28316 |
(*(uint64_t*)fenv_var 0x1ff80fff); |
| 28317 |
__builtin_mtfsf (0xff, fenv_update); */ |
| 28318 |
|
| 28319 |
const unsigned HOST_WIDE_INT update_exception_mask |
| 28320 |
= HOST_WIDE_INT_C (0xffffffff1fffff00); |
| 28321 |
const unsigned HOST_WIDE_INT new_exception_mask |
| 28322 |
= HOST_WIDE_INT_C (0x1ff80fff); |
| 28323 |
|
| 28324 |
tree old_fenv = create_tmp_var_raw (double_type_node); |
| 28325 |
tree update_mffs = build4 (TARGET_EXPR, double_type_node, old_fenv, |
| 28326 |
call_mffs, NULL_TREE, NULL_TREE); |
| 28327 |
|
| 28328 |
tree old_llu = build1 (VIEW_CONVERT_EXPR, uint64_type_node, old_fenv); |
| 28329 |
tree old_llu_and = build2 (BIT_AND_EXPR, uint64_type_node, old_llu, |
| 28330 |
build_int_cst (uint64_type_node, |
| 28331 |
update_exception_mask)); |
| 28332 |
|
| 28333 |
tree new_llu_and = build2 (BIT_AND_EXPR, uint64_type_node, fenv_llu, |
| 28334 |
build_int_cst (uint64_type_node, |
| 28335 |
new_exception_mask)); |
| 28336 |
|
| 28337 |
tree new_llu_mask = build2 (BIT_IOR_EXPR, uint64_type_node, |
| 28338 |
old_llu_and, new_llu_and); |
| 28339 |
|
| 28340 |
tree fenv_update_mtfsf = build1 (VIEW_CONVERT_EXPR, double_type_node, |
| 28341 |
new_llu_mask); |
| 28342 |
|
| 28343 |
tree update_mtfsf = build_call_expr (mtfsf, 2, |
| 28344 |
build_int_cst (unsigned_type_node, 0xff), |
| 28345 |
fenv_update_mtfsf); |
| 28346 |
|
| 28347 |
*update = build2 (COMPOUND_EXPR, void_type_node, update_mffs, update_mtfsf); |
| 28348 |
} |
| 28349 |
|
| 28350 |
void |
| 28351 |
rs6000_generate_float2_double_code (rtx dst, rtx src1, rtx src2) |
| 28352 |
{ |
| 28353 |
rtx rtx_tmp0, rtx_tmp1, rtx_tmp2, rtx_tmp3; |
| 28354 |
|
| 28355 |
rtx_tmp0 = gen_reg_rtx (V2DFmode); |
| 28356 |
rtx_tmp1 = gen_reg_rtx (V2DFmode); |
| 28357 |
|
| 28358 |
/* The destination of the vmrgew instruction layout is: |
| 28359 |
rtx_tmp2[0] rtx_tmp3[0] rtx_tmp2[1] rtx_tmp3[0]. |
| 28360 |
Setup rtx_tmp0 and rtx_tmp1 to ensure the order of the elements after the |
| 28361 |
vmrgew instruction will be correct. */ |
| 28362 |
if (BYTES_BIG_ENDIAN) |
| 28363 |
{ |
| 28364 |
emit_insn (gen_vsx_xxpermdi_v2df_be (rtx_tmp0, src1, src2, |
| 28365 |
GEN_INT (0))); |
| 28366 |
emit_insn (gen_vsx_xxpermdi_v2df_be (rtx_tmp1, src1, src2, |
| 28367 |
GEN_INT (3))); |
| 28368 |
} |
| 28369 |
else |
| 28370 |
{ |
| 28371 |
emit_insn (gen_vsx_xxpermdi_v2df (rtx_tmp0, src1, src2, GEN_INT (3))); |
| 28372 |
emit_insn (gen_vsx_xxpermdi_v2df (rtx_tmp1, src1, src2, GEN_INT (0))); |
| 28373 |
} |
| 28374 |
|
| 28375 |
rtx_tmp2 = gen_reg_rtx (V4SFmode); |
| 28376 |
rtx_tmp3 = gen_reg_rtx (V4SFmode); |
| 28377 |
|
| 28378 |
emit_insn (gen_vsx_xvcvdpsp (rtx_tmp2, rtx_tmp0)); |
| 28379 |
emit_insn (gen_vsx_xvcvdpsp (rtx_tmp3, rtx_tmp1)); |
| 28380 |
|
| 28381 |
if (BYTES_BIG_ENDIAN) |
| 28382 |
emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp2, rtx_tmp3)); |
| 28383 |
else |
| 28384 |
emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp3, rtx_tmp2)); |
| 28385 |
} |
| 28386 |
|
| 28387 |
void |
| 28388 |
rs6000_generate_float2_code (bool signed_convert, rtx dst, rtx src1, rtx src2) |
| 28389 |
{ |
| 28390 |
rtx rtx_tmp0, rtx_tmp1, rtx_tmp2, rtx_tmp3; |
| 28391 |
|
| 28392 |
rtx_tmp0 = gen_reg_rtx (V2DImode); |
| 28393 |
rtx_tmp1 = gen_reg_rtx (V2DImode); |
| 28394 |
|
| 28395 |
/* The destination of the vmrgew instruction layout is: |
| 28396 |
rtx_tmp2[0] rtx_tmp3[0] rtx_tmp2[1] rtx_tmp3[0]. |
| 28397 |
Setup rtx_tmp0 and rtx_tmp1 to ensure the order of the elements after the |
| 28398 |
vmrgew instruction will be correct. */ |
| 28399 |
if (BYTES_BIG_ENDIAN) |
| 28400 |
{ |
| 28401 |
emit_insn (gen_vsx_xxpermdi_v2di_be (rtx_tmp0, src1, src2, GEN_INT (0))); |
| 28402 |
emit_insn (gen_vsx_xxpermdi_v2di_be (rtx_tmp1, src1, src2, GEN_INT (3))); |
| 28403 |
} |
| 28404 |
else |
| 28405 |
{ |
| 28406 |
emit_insn (gen_vsx_xxpermdi_v2di (rtx_tmp0, src1, src2, GEN_INT (3))); |
| 28407 |
emit_insn (gen_vsx_xxpermdi_v2di (rtx_tmp1, src1, src2, GEN_INT (0))); |
| 28408 |
} |
| 28409 |
|
| 28410 |
rtx_tmp2 = gen_reg_rtx (V4SFmode); |
| 28411 |
rtx_tmp3 = gen_reg_rtx (V4SFmode); |
| 28412 |
|
| 28413 |
if (signed_convert) |
| 28414 |
{ |
| 28415 |
emit_insn (gen_vsx_xvcvsxdsp (rtx_tmp2, rtx_tmp0)); |
| 28416 |
emit_insn (gen_vsx_xvcvsxdsp (rtx_tmp3, rtx_tmp1)); |
| 28417 |
} |
| 28418 |
else |
| 28419 |
{ |
| 28420 |
emit_insn (gen_vsx_xvcvuxdsp (rtx_tmp2, rtx_tmp0)); |
| 28421 |
emit_insn (gen_vsx_xvcvuxdsp (rtx_tmp3, rtx_tmp1)); |
| 28422 |
} |
| 28423 |
|
| 28424 |
if (BYTES_BIG_ENDIAN) |
| 28425 |
emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp2, rtx_tmp3)); |
| 28426 |
else |
| 28427 |
emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp3, rtx_tmp2)); |
| 28428 |
} |
| 28429 |
|
| 28430 |
void |
| 28431 |
rs6000_generate_vsigned2_code (bool signed_convert, rtx dst, rtx src1, |
| 28432 |
rtx src2) |
| 28433 |
{ |
| 28434 |
rtx rtx_tmp0, rtx_tmp1, rtx_tmp2, rtx_tmp3; |
| 28435 |
|
| 28436 |
rtx_tmp0 = gen_reg_rtx (V2DFmode); |
| 28437 |
rtx_tmp1 = gen_reg_rtx (V2DFmode); |
| 28438 |
|
| 28439 |
emit_insn (gen_vsx_xxpermdi_v2df (rtx_tmp0, src1, src2, GEN_INT (0))); |
| 28440 |
emit_insn (gen_vsx_xxpermdi_v2df (rtx_tmp1, src1, src2, GEN_INT (3))); |
| 28441 |
|
| 28442 |
rtx_tmp2 = gen_reg_rtx (V4SImode); |
| 28443 |
rtx_tmp3 = gen_reg_rtx (V4SImode); |
| 28444 |
|
| 28445 |
if (signed_convert) |
| 28446 |
{ |
| 28447 |
emit_insn (gen_vsx_xvcvdpsxws (rtx_tmp2, rtx_tmp0)); |
| 28448 |
emit_insn (gen_vsx_xvcvdpsxws (rtx_tmp3, rtx_tmp1)); |
| 28449 |
} |
| 28450 |
else |
| 28451 |
{ |
| 28452 |
emit_insn (gen_vsx_xvcvdpuxws (rtx_tmp2, rtx_tmp0)); |
| 28453 |
emit_insn (gen_vsx_xvcvdpuxws (rtx_tmp3, rtx_tmp1)); |
| 28454 |
} |
| 28455 |
|
| 28456 |
emit_insn (gen_p8_vmrgew_v4si (dst, rtx_tmp2, rtx_tmp3)); |
| 28457 |
} |
| 28458 |
|
| 28459 |
/* Implement the TARGET_OPTAB_SUPPORTED_P hook. */ |
| 28460 |
|
| 28461 |
static bool |
| 28462 |
rs6000_optab_supported_p (int op, machine_mode mode1, machine_mode, |
| 28463 |
optimization_type opt_type) |
| 28464 |
{ |
| 28465 |
switch (op) |
| 28466 |
{ |
| 28467 |
case rsqrt_optab: |
| 28468 |
return (opt_type == OPTIMIZE_FOR_SPEED |
| 28469 |
&& RS6000_RECIP_AUTO_RSQRTE_P (mode1)); |
| 28470 |
|
| 28471 |
default: |
| 28472 |
return true; |
| 28473 |
} |
| 28474 |
} |
| 28475 |
|
| 28476 |
/* Implement TARGET_CONSTANT_ALIGNMENT. */ |
| 28477 |
|
| 28478 |
static HOST_WIDE_INT |
| 28479 |
rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align) |
| 28480 |
{ |
| 28481 |
if (TREE_CODE (exp) == STRING_CST |
| 28482 |
&& (STRICT_ALIGNMENT || !optimize_size)) |
| 28483 |
return MAX (align, BITS_PER_WORD); |
| 28484 |
return align; |
| 28485 |
} |
| 28486 |
|
| 28487 |
/* Implement TARGET_STARTING_FRAME_OFFSET. */ |
| 28488 |
|
| 28489 |
static HOST_WIDE_INT |
| 28490 |
rs6000_starting_frame_offset (void) |
| 28491 |
{ |
| 28492 |
if (FRAME_GROWS_DOWNWARD) |
| 28493 |
return 0; |
| 28494 |
return RS6000_STARTING_FRAME_OFFSET; |
| 28495 |
} |
| 28496 |
|
| 28497 |
/* Internal function to return the built-in function id for the complex |
| 28498 |
multiply operation for a given mode. */ |
| 28499 |
|
| 28500 |
static inline built_in_function |
| 28501 |
complex_multiply_builtin_code (machine_mode mode) |
| 28502 |
{ |
| 28503 |
gcc_assert (IN_RANGE (mode, MIN_MODE_COMPLEX_FLOAT, MAX_MODE_COMPLEX_FLOAT)); |
| 28504 |
int func = BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT; |
| 28505 |
return (built_in_function) func; |
| 28506 |
} |
| 28507 |
|
| 28508 |
/* Internal function to return the built-in function id for the complex divide |
| 28509 |
operation for a given mode. */ |
| 28510 |
|
| 28511 |
static inline built_in_function |
| 28512 |
complex_divide_builtin_code (machine_mode mode) |
| 28513 |
{ |
| 28514 |
gcc_assert (IN_RANGE (mode, MIN_MODE_COMPLEX_FLOAT, MAX_MODE_COMPLEX_FLOAT)); |
| 28515 |
int func = BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT; |
| 28516 |
return (built_in_function) func; |
| 28517 |
} |
| 28518 |
|
| 28519 |
/* On 64-bit Linux and Freebsd systems, possibly switch the long double library |
| 28520 |
function names from <foo>l to <foo>f128 if the default long double type is |
| 28521 |
IEEE 128-bit. Typically, with the C and C++ languages, the standard math.h |
| 28522 |
include file switches the names on systems that support long double as IEEE |
| 28523 |
128-bit, but that doesn't work if the user uses __builtin_<foo>l directly. |
| 28524 |
In the future, glibc will export names like __ieee128_sinf128 and we can |
| 28525 |
switch to using those instead of using sinf128, which pollutes the user's |
| 28526 |
namespace. |
| 28527 |
|
| 28528 |
This will switch the names for Fortran math functions as well (which doesn't |
| 28529 |
use math.h). However, Fortran needs other changes to the compiler and |
| 28530 |
library before you can switch the real*16 type at compile time. |
| 28531 |
|
| 28532 |
We use the TARGET_MANGLE_DECL_ASSEMBLER_NAME hook to change this name. We |
| 28533 |
only do this transformation if the __float128 type is enabled. This |
| 28534 |
prevents us from doing the transformation on older 32-bit ports that might |
| 28535 |
have enabled using IEEE 128-bit floating point as the default long double |
| 28536 |
type. |
| 28537 |
|
| 28538 |
We also use the TARGET_MANGLE_DECL_ASSEMBLER_NAME hook to change the |
| 28539 |
function names used for complex multiply and divide to the appropriate |
| 28540 |
names. */ |
| 28541 |
|
| 28542 |
static tree |
| 28543 |
rs6000_mangle_decl_assembler_name (tree decl, tree id) |
| 28544 |
{ |
| 28545 |
/* Handle complex multiply/divide. For IEEE 128-bit, use __mulkc3 or |
| 28546 |
__divkc3 and for IBM 128-bit use __multc3 and __divtc3. */ |
| 28547 |
if (TARGET_FLOAT128_TYPE |
| 28548 |
&& TREE_CODE (decl) == FUNCTION_DECL |
| 28549 |
&& DECL_IS_UNDECLARED_BUILTIN (decl) |
| 28550 |
&& DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) |
| 28551 |
{ |
| 28552 |
built_in_function id = DECL_FUNCTION_CODE (decl); |
| 28553 |
const char *newname = NULL; |
| 28554 |
|
| 28555 |
if (id == complex_multiply_builtin_code (KCmode)) |
| 28556 |
newname = "__mulkc3"; |
| 28557 |
|
| 28558 |
else if (id == complex_multiply_builtin_code (ICmode)) |
| 28559 |
newname = "__multc3"; |
| 28560 |
|
| 28561 |
else if (id == complex_multiply_builtin_code (TCmode)) |
| 28562 |
newname = (TARGET_IEEEQUAD) ? "__mulkc3" : "__multc3"; |
| 28563 |
|
| 28564 |
else if (id == complex_divide_builtin_code (KCmode)) |
| 28565 |
newname = "__divkc3"; |
| 28566 |
|
| 28567 |
else if (id == complex_divide_builtin_code (ICmode)) |
| 28568 |
newname = "__divtc3"; |
| 28569 |
|
| 28570 |
else if (id == complex_divide_builtin_code (TCmode)) |
| 28571 |
newname = (TARGET_IEEEQUAD) ? "__divkc3" : "__divtc3"; |
| 28572 |
|
| 28573 |
if (newname) |
| 28574 |
{ |
| 28575 |
if (TARGET_DEBUG_BUILTIN) |
| 28576 |
fprintf (stderr, "Map complex mul/div => %s\n", newname); |
| 28577 |
|
| 28578 |
return get_identifier (newname); |
| 28579 |
} |
| 28580 |
} |
| 28581 |
|
| 28582 |
/* Map long double built-in functions if long double is IEEE 128-bit. */ |
| 28583 |
if (TARGET_FLOAT128_TYPE && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128 |
| 28584 |
&& TREE_CODE (decl) == FUNCTION_DECL |
| 28585 |
&& DECL_IS_UNDECLARED_BUILTIN (decl) |
| 28586 |
&& DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) |
| 28587 |
{ |
| 28588 |
size_t len = IDENTIFIER_LENGTH (id); |
| 28589 |
const char *name = IDENTIFIER_POINTER (id); |
| 28590 |
char *newname = NULL; |
| 28591 |
|
| 28592 |
/* See if it is one of the built-in functions with an unusual name. */ |
| 28593 |
switch (DECL_FUNCTION_CODE (decl)) |
| 28594 |
{ |
| 28595 |
case BUILT_IN_DREML: |
| 28596 |
newname = xstrdup ("__remainderieee128"); |
| 28597 |
break; |
| 28598 |
|
| 28599 |
case BUILT_IN_GAMMAL: |
| 28600 |
newname = xstrdup ("__lgammaieee128"); |
| 28601 |
break; |
| 28602 |
|
| 28603 |
case BUILT_IN_GAMMAL_R: |
| 28604 |
case BUILT_IN_LGAMMAL_R: |
| 28605 |
newname = xstrdup ("__lgammaieee128_r"); |
| 28606 |
break; |
| 28607 |
|
| 28608 |
case BUILT_IN_NEXTTOWARD: |
| 28609 |
newname = xstrdup ("__nexttoward_to_ieee128"); |
| 28610 |
break; |
| 28611 |
|
| 28612 |
case BUILT_IN_NEXTTOWARDF: |
| 28613 |
newname = xstrdup ("__nexttowardf_to_ieee128"); |
| 28614 |
break; |
| 28615 |
|
| 28616 |
case BUILT_IN_NEXTTOWARDL: |
| 28617 |
newname = xstrdup ("__nexttowardieee128"); |
| 28618 |
break; |
| 28619 |
|
| 28620 |
case BUILT_IN_POW10L: |
| 28621 |
newname = xstrdup ("__exp10ieee128"); |
| 28622 |
break; |
| 28623 |
|
| 28624 |
case BUILT_IN_SCALBL: |
| 28625 |
newname = xstrdup ("__scalbieee128"); |
| 28626 |
break; |
| 28627 |
|
| 28628 |
case BUILT_IN_SIGNIFICANDL: |
| 28629 |
newname = xstrdup ("__significandieee128"); |
| 28630 |
break; |
| 28631 |
|
| 28632 |
case BUILT_IN_SINCOSL: |
| 28633 |
newname = xstrdup ("__sincosieee128"); |
| 28634 |
break; |
| 28635 |
|
| 28636 |
default: |
| 28637 |
break; |
| 28638 |
} |
| 28639 |
|
| 28640 |
/* Update the __builtin_*printf and __builtin_*scanf functions. */ |
| 28641 |
if (!newname) |
| 28642 |
{ |
| 28643 |
size_t printf_len = strlen ("printf"); |
| 28644 |
size_t scanf_len = strlen ("scanf"); |
| 28645 |
size_t printf_chk_len = strlen ("printf_chk"); |
| 28646 |
|
| 28647 |
if (len >= printf_len |
| 28648 |
&& strcmp (name + len - printf_len, "printf") == 0) |
| 28649 |
newname = xasprintf ("__%sieee128", name); |
| 28650 |
|
| 28651 |
else if (len >= scanf_len |
| 28652 |
&& strcmp (name + len - scanf_len, "scanf") == 0) |
| 28653 |
newname = xasprintf ("__isoc99_%sieee128", name); |
| 28654 |
|
| 28655 |
else if (len >= printf_chk_len |
| 28656 |
&& strcmp (name + len - printf_chk_len, "printf_chk") == 0) |
| 28657 |
newname = xasprintf ("%sieee128", name); |
| 28658 |
|
| 28659 |
else if (name[len - 1] == 'l') |
| 28660 |
{ |
| 28661 |
bool uses_ieee128_p = false; |
| 28662 |
tree type = TREE_TYPE (decl); |
| 28663 |
machine_mode ret_mode = TYPE_MODE (type); |
| 28664 |
|
| 28665 |
/* See if the function returns a IEEE 128-bit floating point type or |
| 28666 |
complex type. */ |
| 28667 |
if (ret_mode == TFmode || ret_mode == TCmode) |
| 28668 |
uses_ieee128_p = true; |
| 28669 |
else |
| 28670 |
{ |
| 28671 |
function_args_iterator args_iter; |
| 28672 |
tree arg; |
| 28673 |
|
| 28674 |
/* See if the function passes a IEEE 128-bit floating point type |
| 28675 |
or complex type. */ |
| 28676 |
FOREACH_FUNCTION_ARGS (type, arg, args_iter) |
| 28677 |
{ |
| 28678 |
machine_mode arg_mode = TYPE_MODE (arg); |
| 28679 |
if (arg_mode == TFmode || arg_mode == TCmode) |
| 28680 |
{ |
| 28681 |
uses_ieee128_p = true; |
| 28682 |
break; |
| 28683 |
} |
| 28684 |
} |
| 28685 |
} |
| 28686 |
|
| 28687 |
/* If we passed or returned an IEEE 128-bit floating point type, |
| 28688 |
change the name. Use __<name>ieee128, instead of <name>l. */ |
| 28689 |
if (uses_ieee128_p) |
| 28690 |
newname = xasprintf ("__%.*sieee128", (int)(len - 1), name); |
| 28691 |
} |
| 28692 |
} |
| 28693 |
|
| 28694 |
if (newname) |
| 28695 |
{ |
| 28696 |
if (TARGET_DEBUG_BUILTIN) |
| 28697 |
fprintf (stderr, "Map %s => %s\n", name, newname); |
| 28698 |
|
| 28699 |
id = get_identifier (newname); |
| 28700 |
free (newname); |
| 28701 |
} |
| 28702 |
} |
| 28703 |
|
| 28704 |
return id; |
| 28705 |
} |
| 28706 |
|
| 28707 |
/* Predict whether the given loop in gimple will be transformed in the RTL |
| 28708 |
doloop_optimize pass. */ |
| 28709 |
|
| 28710 |
static bool |
| 28711 |
rs6000_predict_doloop_p (struct loop *loop) |
| 28712 |
{ |
| 28713 |
gcc_assert (loop); |
| 28714 |
|
| 28715 |
/* On rs6000, targetm.can_use_doloop_p is actually |
| 28716 |
can_use_doloop_if_innermost. Just ensure the loop is innermost. */ |
| 28717 |
if (loop->inner != NULL) |
| 28718 |
{ |
| 28719 |
if (dump_file && (dump_flags & TDF_DETAILS)) |
| 28720 |
fprintf (dump_file, "Predict doloop failure due to" |
| 28721 |
" loop nesting.\n"); |
| 28722 |
return false; |
| 28723 |
} |
| 28724 |
|
| 28725 |
return true; |
| 28726 |
} |
| 28727 |
|
| 28728 |
/* Implement TARGET_PREFERRED_DOLOOP_MODE. */ |
| 28729 |
|
| 28730 |
static machine_mode |
| 28731 |
rs6000_preferred_doloop_mode (machine_mode) |
| 28732 |
{ |
| 28733 |
return word_mode; |
| 28734 |
} |
| 28735 |
|
| 28736 |
/* Implement TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P. */ |
| 28737 |
|
| 28738 |
static bool |
| 28739 |
rs6000_cannot_substitute_mem_equiv_p (rtx mem) |
| 28740 |
{ |
| 28741 |
gcc_assert (MEM_P (mem)); |
| 28742 |
|
| 28743 |
/* curr_insn_transform()'s handling of subregs cannot handle altivec AND: |
| 28744 |
type addresses, so don't allow MEMs with those address types to be |
| 28745 |
substituted as an equivalent expression. See PR93974 for details. */ |
| 28746 |
if (GET_CODE (XEXP (mem, 0)) == AND) |
| 28747 |
return true; |
| 28748 |
|
| 28749 |
return false; |
| 28750 |
} |
| 28751 |
|
| 28752 |
/* Implement TARGET_INVALID_CONVERSION. */ |
| 28753 |
|
| 28754 |
static const char * |
| 28755 |
rs6000_invalid_conversion (const_tree fromtype, const_tree totype) |
| 28756 |
{ |
| 28757 |
/* Make sure we're working with the canonical types. */ |
| 28758 |
if (TYPE_CANONICAL (fromtype) != NULL_TREE) |
| 28759 |
fromtype = TYPE_CANONICAL (fromtype); |
| 28760 |
if (TYPE_CANONICAL (totype) != NULL_TREE) |
| 28761 |
totype = TYPE_CANONICAL (totype); |
| 28762 |
|
| 28763 |
machine_mode frommode = TYPE_MODE (fromtype); |
| 28764 |
machine_mode tomode = TYPE_MODE (totype); |
| 28765 |
|
| 28766 |
if (frommode != tomode) |
| 28767 |
{ |
| 28768 |
/* Do not allow conversions to/from XOmode and OOmode types. */ |
| 28769 |
if (frommode == XOmode) |
| 28770 |
return N_("invalid conversion from type %<__vector_quad%>"); |
| 28771 |
if (tomode == XOmode) |
| 28772 |
return N_("invalid conversion to type %<__vector_quad%>"); |
| 28773 |
if (frommode == OOmode) |
| 28774 |
return N_("invalid conversion from type %<__vector_pair%>"); |
| 28775 |
if (tomode == OOmode) |
| 28776 |
return N_("invalid conversion to type %<__vector_pair%>"); |
| 28777 |
} |
| 28778 |
|
| 28779 |
/* Conversion allowed. */ |
| 28780 |
return NULL; |
| 28781 |
} |
| 28782 |
|
| 28783 |
/* Convert a SFmode constant to the integer bit pattern. */ |
| 28784 |
|
| 28785 |
long |
| 28786 |
rs6000_const_f32_to_i32 (rtx operand) |
| 28787 |
{ |
| 28788 |
long value; |
| 28789 |
const struct real_value *rv = CONST_DOUBLE_REAL_VALUE (operand); |
| 28790 |
|
| 28791 |
gcc_assert (GET_MODE (operand) == SFmode); |
| 28792 |
REAL_VALUE_TO_TARGET_SINGLE (*rv, value); |
| 28793 |
return value; |
| 28794 |
} |
| 28795 |
|
| 28796 |
void |
| 28797 |
rs6000_emit_xxspltidp_v2df (rtx dst, long value) |
| 28798 |
{ |
| 28799 |
if (((value & 0x7F800000) == 0) && ((value & 0x7FFFFF) != 0)) |
| 28800 |
inform (input_location, |
| 28801 |
"the result for the xxspltidp instruction " |
| 28802 |
"is undefined for subnormal input values"); |
| 28803 |
emit_insn( gen_xxspltidp_v2df_inst (dst, GEN_INT (value))); |
| 28804 |
} |
| 28805 |
|
| 28806 |
/* Implement TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC. */ |
| 28807 |
|
| 28808 |
static bool |
| 28809 |
rs6000_gen_pic_addr_diff_vec (void) |
| 28810 |
{ |
| 28811 |
return rs6000_relative_jumptables; |
| 28812 |
} |
| 28813 |
|
| 28814 |
void |
| 28815 |
rs6000_output_addr_vec_elt (FILE *file, int value) |
| 28816 |
{ |
| 28817 |
const char *directive = TARGET_64BIT ? DOUBLE_INT_ASM_OP : "\t.long\t"; |
| 28818 |
char buf[100]; |
| 28819 |
|
| 28820 |
fprintf (file, "%s", directive); |
| 28821 |
ASM_GENERATE_INTERNAL_LABEL (buf, "L", value); |
| 28822 |
assemble_name (file, buf); |
| 28823 |
fprintf (file, "\n"); |
| 28824 |
} |
| 28825 |
|
| 28826 |
|
| 28827 |
/* Copy an integer constant to the vector constant structure. */ |
| 28828 |
|
| 28829 |
static void |
| 28830 |
constant_int_to_128bit_vector (rtx op, |
| 28831 |
machine_mode mode, |
| 28832 |
size_t byte_num, |
| 28833 |
vec_const_128bit_type *info) |
| 28834 |
{ |
| 28835 |
unsigned HOST_WIDE_INT uvalue = UINTVAL (op); |
| 28836 |
unsigned bitsize = GET_MODE_BITSIZE (mode); |
| 28837 |
|
| 28838 |
for (int shift = bitsize - 8; shift >= 0; shift -= 8) |
| 28839 |
info->bytes[byte_num++] = (uvalue >> shift) & 0xff; |
| 28840 |
} |
| 28841 |
|
| 28842 |
/* Copy a floating point constant to the vector constant structure. */ |
| 28843 |
|
| 28844 |
static void |
| 28845 |
constant_fp_to_128bit_vector (rtx op, |
| 28846 |
machine_mode mode, |
| 28847 |
size_t byte_num, |
| 28848 |
vec_const_128bit_type *info) |
| 28849 |
{ |
| 28850 |
unsigned bitsize = GET_MODE_BITSIZE (mode); |
| 28851 |
unsigned num_words = bitsize / 32; |
| 28852 |
const REAL_VALUE_TYPE *rtype = CONST_DOUBLE_REAL_VALUE (op); |
| 28853 |
long real_words[VECTOR_128BIT_WORDS]; |
| 28854 |
|
| 28855 |
/* Make sure we don't overflow the real_words array and that it is |
| 28856 |
filled completely. */ |
| 28857 |
gcc_assert (num_words <= VECTOR_128BIT_WORDS && (bitsize % 32) == 0); |
| 28858 |
|
| 28859 |
real_to_target (real_words, rtype, mode); |
| 28860 |
|
| 28861 |
/* Iterate over each 32-bit word in the floating point constant. The |
| 28862 |
real_to_target function puts out words in target endian fashion. We need |
| 28863 |
to arrange the order so that the bytes are written in big endian order. */ |
| 28864 |
for (unsigned num = 0; num < num_words; num++) |
| 28865 |
{ |
| 28866 |
unsigned endian_num = (BYTES_BIG_ENDIAN |
| 28867 |
? num |
| 28868 |
: num_words - 1 - num); |
| 28869 |
|
| 28870 |
unsigned uvalue = real_words[endian_num]; |
| 28871 |
for (int shift = 32 - 8; shift >= 0; shift -= 8) |
| 28872 |
info->bytes[byte_num++] = (uvalue >> shift) & 0xff; |
| 28873 |
} |
| 28874 |
|
| 28875 |
/* Mark that this constant involves floating point. */ |
| 28876 |
info->fp_constant_p = true; |
| 28877 |
} |
| 28878 |
|
| 28879 |
/* Convert a vector constant OP with mode MODE to a vector 128-bit constant |
| 28880 |
structure INFO. |
| 28881 |
|
| 28882 |
Break out the constant out to bytes, half words, words, and double words. |
| 28883 |
Return true if we have successfully converted the constant. |
| 28884 |
|
| 28885 |
We handle CONST_INT, CONST_DOUBLE, CONST_VECTOR, and VEC_DUPLICATE of |
| 28886 |
constants. Integer and floating point scalar constants are splatted to fill |
| 28887 |
out the vector. */ |
| 28888 |
|
| 28889 |
bool |
| 28890 |
vec_const_128bit_to_bytes (rtx op, |
| 28891 |
machine_mode mode, |
| 28892 |
vec_const_128bit_type *info) |
| 28893 |
{ |
| 28894 |
/* Initialize the constant structure. */ |
| 28895 |
memset ((void *)info, 0, sizeof (vec_const_128bit_type)); |
| 28896 |
|
| 28897 |
/* Assume CONST_INTs are DImode. */ |
| 28898 |
if (mode == VOIDmode) |
| 28899 |
mode = CONST_INT_P (op) ? DImode : GET_MODE (op); |
| 28900 |
|
| 28901 |
if (mode == VOIDmode) |
| 28902 |
return false; |
| 28903 |
|
| 28904 |
unsigned size = GET_MODE_SIZE (mode); |
| 28905 |
bool splat_p = false; |
| 28906 |
|
| 28907 |
if (size > VECTOR_128BIT_BYTES) |
| 28908 |
return false; |
| 28909 |
|
| 28910 |
/* Set up the bits. */ |
| 28911 |
switch (GET_CODE (op)) |
| 28912 |
{ |
| 28913 |
/* Integer constants, default to double word. */ |
| 28914 |
case CONST_INT: |
| 28915 |
{ |
| 28916 |
constant_int_to_128bit_vector (op, mode, 0, info); |
| 28917 |
splat_p = true; |
| 28918 |
break; |
| 28919 |
} |
| 28920 |
|
| 28921 |
/* Floating point constants. */ |
| 28922 |
case CONST_DOUBLE: |
| 28923 |
{ |
| 28924 |
/* Fail if the floating point constant is the wrong mode. */ |
| 28925 |
if (GET_MODE (op) != mode) |
| 28926 |
return false; |
| 28927 |
|
| 28928 |
/* SFmode stored as scalars are stored in DFmode format. */ |
| 28929 |
if (mode == SFmode) |
| 28930 |
{ |
| 28931 |
mode = DFmode; |
| 28932 |
size = GET_MODE_SIZE (DFmode); |
| 28933 |
} |
| 28934 |
|
| 28935 |
constant_fp_to_128bit_vector (op, mode, 0, info); |
| 28936 |
splat_p = true; |
| 28937 |
break; |
| 28938 |
} |
| 28939 |
|
| 28940 |
/* Vector constants, iterate over each element. On little endian |
| 28941 |
systems, we have to reverse the element numbers. */ |
| 28942 |
case CONST_VECTOR: |
| 28943 |
{ |
| 28944 |
/* Fail if the vector constant is the wrong mode or size. */ |
| 28945 |
if (GET_MODE (op) != mode |
| 28946 |
|| GET_MODE_SIZE (mode) != VECTOR_128BIT_BYTES) |
| 28947 |
return false; |
| 28948 |
|
| 28949 |
machine_mode ele_mode = GET_MODE_INNER (mode); |
| 28950 |
size_t ele_size = GET_MODE_SIZE (ele_mode); |
| 28951 |
size_t nunits = GET_MODE_NUNITS (mode); |
| 28952 |
|
| 28953 |
for (size_t num = 0; num < nunits; num++) |
| 28954 |
{ |
| 28955 |
rtx ele = CONST_VECTOR_ELT (op, num); |
| 28956 |
size_t byte_num = (BYTES_BIG_ENDIAN |
| 28957 |
? num |
| 28958 |
: nunits - 1 - num) * ele_size; |
| 28959 |
|
| 28960 |
if (CONST_INT_P (ele)) |
| 28961 |
constant_int_to_128bit_vector (ele, ele_mode, byte_num, info); |
| 28962 |
else if (CONST_DOUBLE_P (ele)) |
| 28963 |
constant_fp_to_128bit_vector (ele, ele_mode, byte_num, info); |
| 28964 |
else |
| 28965 |
return false; |
| 28966 |
} |
| 28967 |
|
| 28968 |
break; |
| 28969 |
} |
| 28970 |
|
| 28971 |
/* Treat VEC_DUPLICATE of a constant just like a vector constant. |
| 28972 |
Since we are duplicating the element, we don't have to worry about |
| 28973 |
endian issues. */ |
| 28974 |
case VEC_DUPLICATE: |
| 28975 |
{ |
| 28976 |
/* Fail if the vector duplicate is the wrong mode or size. */ |
| 28977 |
if (GET_MODE (op) != mode |
| 28978 |
|| GET_MODE_SIZE (mode) != VECTOR_128BIT_BYTES) |
| 28979 |
return false; |
| 28980 |
|
| 28981 |
machine_mode ele_mode = GET_MODE_INNER (mode); |
| 28982 |
size_t ele_size = GET_MODE_SIZE (ele_mode); |
| 28983 |
rtx ele = XEXP (op, 0); |
| 28984 |
size_t nunits = GET_MODE_NUNITS (mode); |
| 28985 |
|
| 28986 |
if (!CONST_INT_P (ele) && !CONST_DOUBLE_P (ele)) |
| 28987 |
return false; |
| 28988 |
|
| 28989 |
for (size_t num = 0; num < nunits; num++) |
| 28990 |
{ |
| 28991 |
size_t byte_num = num * ele_size; |
| 28992 |
|
| 28993 |
if (CONST_INT_P (ele)) |
| 28994 |
constant_int_to_128bit_vector (ele, ele_mode, byte_num, info); |
| 28995 |
else |
| 28996 |
constant_fp_to_128bit_vector (ele, ele_mode, byte_num, info); |
| 28997 |
} |
| 28998 |
|
| 28999 |
break; |
| 29000 |
} |
| 29001 |
|
| 29002 |
/* Any thing else, just return failure. */ |
| 29003 |
default: |
| 29004 |
return false; |
| 29005 |
} |
| 29006 |
|
| 29007 |
/* Splat the constant to fill 128 bits if desired. */ |
| 29008 |
if (splat_p && size < VECTOR_128BIT_BYTES) |
| 29009 |
{ |
| 29010 |
if ((VECTOR_128BIT_BYTES % size) != 0) |
| 29011 |
return false; |
| 29012 |
|
| 29013 |
for (size_t offset = size; |
| 29014 |
offset < VECTOR_128BIT_BYTES; |
| 29015 |
offset += size) |
| 29016 |
memcpy ((void *) &info->bytes[offset], |
| 29017 |
(void *) &info->bytes[0], |
| 29018 |
size); |
| 29019 |
} |
| 29020 |
|
| 29021 |
/* Remember original size. */ |
| 29022 |
info->original_size = size; |
| 29023 |
|
| 29024 |
/* Determine if the bytes are all the same. */ |
| 29025 |
unsigned char first_byte = info->bytes[0]; |
| 29026 |
info->all_bytes_same = true; |
| 29027 |
for (size_t i = 1; i < VECTOR_128BIT_BYTES; i++) |
| 29028 |
if (first_byte != info->bytes[i]) |
| 29029 |
{ |
| 29030 |
info->all_bytes_same = false; |
| 29031 |
break; |
| 29032 |
} |
| 29033 |
|
| 29034 |
/* Pack half words together & determine if all of the half words are the |
| 29035 |
same. */ |
| 29036 |
for (size_t i = 0; i < VECTOR_128BIT_HALF_WORDS; i++) |
| 29037 |
info->half_words[i] = ((info->bytes[i * 2] << 8) |
| 29038 |
| info->bytes[(i * 2) + 1]); |
| 29039 |
|
| 29040 |
unsigned short first_hword = info->half_words[0]; |
| 29041 |
info->all_half_words_same = true; |
| 29042 |
for (size_t i = 1; i < VECTOR_128BIT_HALF_WORDS; i++) |
| 29043 |
if (first_hword != info->half_words[i]) |
| 29044 |
{ |
| 29045 |
info->all_half_words_same = false; |
| 29046 |
break; |
| 29047 |
} |
| 29048 |
|
| 29049 |
/* Pack words together & determine if all of the words are the same. */ |
| 29050 |
for (size_t i = 0; i < VECTOR_128BIT_WORDS; i++) |
| 29051 |
info->words[i] = ((info->bytes[i * 4] << 24) |
| 29052 |
| (info->bytes[(i * 4) + 1] << 16) |
| 29053 |
| (info->bytes[(i * 4) + 2] << 8) |
| 29054 |
| info->bytes[(i * 4) + 3]); |
| 29055 |
|
| 29056 |
info->all_words_same |
| 29057 |
= (info->words[0] == info->words[1] |
| 29058 |
&& info->words[0] == info->words[2] |
| 29059 |
&& info->words[0] == info->words[3]); |
| 29060 |
|
| 29061 |
/* Pack double words together & determine if all of the double words are the |
| 29062 |
same. */ |
| 29063 |
for (size_t i = 0; i < VECTOR_128BIT_DOUBLE_WORDS; i++) |
| 29064 |
{ |
| 29065 |
unsigned HOST_WIDE_INT d_word = 0; |
| 29066 |
for (size_t j = 0; j < 8; j++) |
| 29067 |
d_word = (d_word << 8) | info->bytes[(i * 8) + j]; |
| 29068 |
|
| 29069 |
info->double_words[i] = d_word; |
| 29070 |
} |
| 29071 |
|
| 29072 |
info->all_double_words_same |
| 29073 |
= (info->double_words[0] == info->double_words[1]); |
| 29074 |
|
| 29075 |
return true; |
| 29076 |
} |
| 29077 |
|
| 29078 |
/* Determine if an IEEE 128-bit constant can be loaded with LXVKQ. Return zero |
| 29079 |
if the LXVKQ instruction cannot be used. Otherwise return the immediate |
| 29080 |
value to be used with the LXVKQ instruction. */ |
| 29081 |
|
| 29082 |
unsigned |
| 29083 |
constant_generates_lxvkq (vec_const_128bit_type *vsx_const) |
| 29084 |
{ |
| 29085 |
/* Is the instruction supported with power10 code generation, IEEE 128-bit |
| 29086 |
floating point hardware and VSX registers are available. */ |
| 29087 |
if (!TARGET_IEEE128_CONSTANT || !TARGET_FLOAT128_HW || !TARGET_POWER10 |
| 29088 |
|| !TARGET_VSX) |
| 29089 |
return 0; |
| 29090 |
|
| 29091 |
/* All of the constants that are generated by LXVKQ have the bottom 3 words |
| 29092 |
that are 0. */ |
| 29093 |
if (vsx_const->words[1] != 0 |
| 29094 |
|| vsx_const->words[2] != 0 |
| 29095 |
|| vsx_const->words[3] != 0) |
| 29096 |
return 0; |
| 29097 |
|
| 29098 |
/* See if we have a match for the first word. */ |
| 29099 |
switch (vsx_const->words[0]) |
| 29100 |
{ |
| 29101 |
case 0x3FFF0000U: return 1; /* IEEE 128-bit +1.0. */ |
| 29102 |
case 0x40000000U: return 2; /* IEEE 128-bit +2.0. */ |
| 29103 |
case 0x40008000U: return 3; /* IEEE 128-bit +3.0. */ |
| 29104 |
case 0x40010000U: return 4; /* IEEE 128-bit +4.0. */ |
| 29105 |
case 0x40014000U: return 5; /* IEEE 128-bit +5.0. */ |
| 29106 |
case 0x40018000U: return 6; /* IEEE 128-bit +6.0. */ |
| 29107 |
case 0x4001C000U: return 7; /* IEEE 128-bit +7.0. */ |
| 29108 |
case 0x7FFF0000U: return 8; /* IEEE 128-bit +Infinity. */ |
| 29109 |
case 0x7FFF8000U: return 9; /* IEEE 128-bit quiet NaN. */ |
| 29110 |
case 0x80000000U: return 16; /* IEEE 128-bit -0.0. */ |
| 29111 |
case 0xBFFF0000U: return 17; /* IEEE 128-bit -1.0. */ |
| 29112 |
case 0xC0000000U: return 18; /* IEEE 128-bit -2.0. */ |
| 29113 |
case 0xC0008000U: return 19; /* IEEE 128-bit -3.0. */ |
| 29114 |
case 0xC0010000U: return 20; /* IEEE 128-bit -4.0. */ |
| 29115 |
case 0xC0014000U: return 21; /* IEEE 128-bit -5.0. */ |
| 29116 |
case 0xC0018000U: return 22; /* IEEE 128-bit -6.0. */ |
| 29117 |
case 0xC001C000U: return 23; /* IEEE 128-bit -7.0. */ |
| 29118 |
case 0xFFFF0000U: return 24; /* IEEE 128-bit -Infinity. */ |
| 29119 |
|
| 29120 |
/* anything else cannot be loaded. */ |
| 29121 |
default: |
| 29122 |
break; |
| 29123 |
} |
| 29124 |
|
| 29125 |
return 0; |
| 29126 |
} |
| 29127 |
|
| 29128 |
/* Determine if a vector constant can be loaded with XXSPLTIW. Return zero if |
| 29129 |
the XXSPLTIW instruction cannot be used. Otherwise return the immediate |
| 29130 |
value to be used with the XXSPLTIW instruction. */ |
| 29131 |
|
| 29132 |
unsigned |
| 29133 |
constant_generates_xxspltiw (vec_const_128bit_type *vsx_const) |
| 29134 |
{ |
| 29135 |
if (!TARGET_SPLAT_WORD_CONSTANT || !TARGET_PREFIXED || !TARGET_VSX) |
| 29136 |
return 0; |
| 29137 |
|
| 29138 |
if (!vsx_const->all_words_same) |
| 29139 |
return 0; |
| 29140 |
|
| 29141 |
/* If we can use XXSPLTIB, don't generate XXSPLTIW. */ |
| 29142 |
if (vsx_const->all_bytes_same) |
| 29143 |
return 0; |
| 29144 |
|
| 29145 |
/* See if we can use VSPLTISH or VSPLTISW. */ |
| 29146 |
if (vsx_const->all_half_words_same) |
| 29147 |
{ |
| 29148 |
short sign_h_word = vsx_const->half_words[0]; |
| 29149 |
if (EASY_VECTOR_15 (sign_h_word)) |
| 29150 |
return 0; |
| 29151 |
} |
| 29152 |
|
| 29153 |
int sign_word = vsx_const->words[0]; |
| 29154 |
if (EASY_VECTOR_15 (sign_word)) |
| 29155 |
return 0; |
| 29156 |
|
| 29157 |
return vsx_const->words[0]; |
| 29158 |
} |
| 29159 |
|
| 29160 |
/* Determine if a vector constant can be loaded with XXSPLTIDP. Return zero if |
| 29161 |
the XXSPLTIDP instruction cannot be used. Otherwise return the immediate |
| 29162 |
value to be used with the XXSPLTIDP instruction. */ |
| 29163 |
|
| 29164 |
unsigned |
| 29165 |
constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) |
| 29166 |
{ |
| 29167 |
if (!TARGET_SPLAT_FLOAT_CONSTANT || !TARGET_PREFIXED || !TARGET_VSX) |
| 29168 |
return 0; |
| 29169 |
|
| 29170 |
/* Reject if the two 64-bit segments are not the same. */ |
| 29171 |
if (!vsx_const->all_double_words_same) |
| 29172 |
return 0; |
| 29173 |
|
| 29174 |
/* If the bytes, half words, or words are all the same, don't use XXSPLTIDP. |
| 29175 |
Use a simpler instruction (XXSPLTIB, VSPLTISB, VSPLTISH, or VSPLTISW). */ |
| 29176 |
if (vsx_const->all_bytes_same |
| 29177 |
|| vsx_const->all_half_words_same |
| 29178 |
|| vsx_const->all_words_same) |
| 29179 |
return 0; |
| 29180 |
|
| 29181 |
unsigned HOST_WIDE_INT value = vsx_const->double_words[0]; |
| 29182 |
|
| 29183 |
/* Avoid values that look like DFmode NaN's, except for the normal NaN bit |
| 29184 |
pattern and the signalling NaN bit pattern. Recognize infinity and |
| 29185 |
negative infinity. */ |
| 29186 |
|
| 29187 |
/* Bit representation of DFmode normal quiet NaN. */ |
| 29188 |
#define RS6000_CONST_DF_NAN HOST_WIDE_INT_UC (0x7ff8000000000000) |
| 29189 |
|
| 29190 |
/* Bit representation of DFmode normal signaling NaN. */ |
| 29191 |
#define RS6000_CONST_DF_NANS HOST_WIDE_INT_UC (0x7ff4000000000000) |
| 29192 |
|
| 29193 |
/* Bit representation of DFmode positive infinity. */ |
| 29194 |
#define RS6000_CONST_DF_INF HOST_WIDE_INT_UC (0x7ff0000000000000) |
| 29195 |
|
| 29196 |
/* Bit representation of DFmode negative infinity. */ |
| 29197 |
#define RS6000_CONST_DF_NEG_INF HOST_WIDE_INT_UC (0xfff0000000000000) |
| 29198 |
|
| 29199 |
if (value != RS6000_CONST_DF_NAN |
| 29200 |
&& value != RS6000_CONST_DF_NANS |
| 29201 |
&& value != RS6000_CONST_DF_INF |
| 29202 |
&& value != RS6000_CONST_DF_NEG_INF) |
| 29203 |
{ |
| 29204 |
/* The IEEE 754 64-bit floating format has 1 bit for sign, 11 bits for |
| 29205 |
the exponent, and 52 bits for the mantissa (not counting the hidden |
| 29206 |
bit used for normal numbers). NaN values have the exponent set to all |
| 29207 |
1 bits, and the mantissa non-zero (mantissa == 0 is infinity). */ |
| 29208 |
|
| 29209 |
int df_exponent = (value >> 52) & 0x7ff; |
| 29210 |
unsigned HOST_WIDE_INT |
| 29211 |
df_mantissa = value & ((HOST_WIDE_INT_1U << 52) - HOST_WIDE_INT_1U); |
| 29212 |
|
| 29213 |
if (df_exponent == 0x7ff && df_mantissa != 0) /* other NaNs. */ |
| 29214 |
return 0; |
| 29215 |
|
| 29216 |
/* Avoid values that are DFmode subnormal values. Subnormal numbers have |
| 29217 |
the exponent all 0 bits, and the mantissa non-zero. If the value is |
| 29218 |
subnormal, then the hidden bit in the mantissa is not set. */ |
| 29219 |
if (df_exponent == 0 && df_mantissa != 0) /* subnormal. */ |
| 29220 |
return 0; |
| 29221 |
} |
| 29222 |
|
| 29223 |
/* Change the representation to DFmode constant. */ |
| 29224 |
long df_words[2] = { vsx_const->words[0], vsx_const->words[1] }; |
| 29225 |
|
| 29226 |
/* real_from_target takes the target words in target order. */ |
| 29227 |
if (!BYTES_BIG_ENDIAN) |
| 29228 |
std::swap (df_words[0], df_words[1]); |
| 29229 |
|
| 29230 |
REAL_VALUE_TYPE rv_type; |
| 29231 |
real_from_target (&rv_type, df_words, DFmode); |
| 29232 |
|
| 29233 |
const REAL_VALUE_TYPE *rv = &rv_type; |
| 29234 |
|
| 29235 |
/* Validate that the number can be stored as a SFmode value. */ |
| 29236 |
if (!exact_real_truncate (SFmode, rv)) |
| 29237 |
return 0; |
| 29238 |
|
| 29239 |
/* Validate that the number is not a SFmode subnormal value (exponent is 0, |
| 29240 |
mantissa field is non-zero) which is undefined for the XXSPLTIDP |
| 29241 |
instruction. */ |
| 29242 |
long sf_value; |
| 29243 |
real_to_target (&sf_value, rv, SFmode); |
| 29244 |
|
| 29245 |
/* IEEE 754 32-bit values have 1 bit for the sign, 8 bits for the exponent, |
| 29246 |
and 23 bits for the mantissa. Subnormal numbers have the exponent all |
| 29247 |
0 bits, and the mantissa non-zero. */ |
| 29248 |
long sf_exponent = (sf_value >> 23) & 0xFF; |
| 29249 |
long sf_mantissa = sf_value & 0x7FFFFF; |
| 29250 |
|
| 29251 |
if (sf_exponent == 0 && sf_mantissa != 0) |
| 29252 |
return 0; |
| 29253 |
|
| 29254 |
/* Return the immediate to be used. */ |
| 29255 |
return sf_value; |
| 29256 |
} |
| 29257 |
|
| 29258 |
/* Now we have only two opaque types, they are __vector_quad and |
| 29259 |
__vector_pair built-in types. They are target specific and |
| 29260 |
only available when MMA is supported. With MMA supported, it |
| 29261 |
simply returns true, otherwise it checks if the given gimple |
| 29262 |
STMT is an assignment, asm or call stmt and uses either of |
| 29263 |
these two opaque types unexpectedly, if yes, it would raise |
| 29264 |
an error message and returns true, otherwise it returns false. */ |
| 29265 |
|
| 29266 |
bool |
| 29267 |
rs6000_opaque_type_invalid_use_p (gimple *stmt) |
| 29268 |
{ |
| 29269 |
if (TARGET_MMA) |
| 29270 |
return false; |
| 29271 |
|
| 29272 |
/* If the given TYPE is one MMA opaque type, emit the corresponding |
| 29273 |
error messages and return true, otherwise return false. */ |
| 29274 |
auto check_and_error_invalid_use = [](tree type) |
| 29275 |
{ |
| 29276 |
tree mv = TYPE_MAIN_VARIANT (type); |
| 29277 |
if (mv == vector_quad_type_node) |
| 29278 |
{ |
| 29279 |
error ("type %<__vector_quad%> requires the %qs option", "-mmma"); |
| 29280 |
return true; |
| 29281 |
} |
| 29282 |
else if (mv == vector_pair_type_node) |
| 29283 |
{ |
| 29284 |
error ("type %<__vector_pair%> requires the %qs option", "-mmma"); |
| 29285 |
return true; |
| 29286 |
} |
| 29287 |
return false; |
| 29288 |
}; |
| 29289 |
|
| 29290 |
if (stmt) |
| 29291 |
{ |
| 29292 |
/* The usage of MMA opaque types is very limited for now, |
| 29293 |
to check with gassign, gasm and gcall is enough so far. */ |
| 29294 |
if (gassign *ga = dyn_cast<gassign *> (stmt)) |
| 29295 |
{ |
| 29296 |
tree lhs = gimple_assign_lhs (ga); |
| 29297 |
tree type = TREE_TYPE (lhs); |
| 29298 |
if (check_and_error_invalid_use (type)) |
| 29299 |
return true; |
| 29300 |
} |
| 29301 |
else if (gasm *gs = dyn_cast<gasm *> (stmt)) |
| 29302 |
{ |
| 29303 |
unsigned ninputs = gimple_asm_ninputs (gs); |
| 29304 |
for (unsigned i = 0; i < ninputs; i++) |
| 29305 |
{ |
| 29306 |
tree op = gimple_asm_input_op (gs, i); |
| 29307 |
tree val = TREE_VALUE (op); |
| 29308 |
tree type = TREE_TYPE (val); |
| 29309 |
if (check_and_error_invalid_use (type)) |
| 29310 |
return true; |
| 29311 |
} |
| 29312 |
unsigned noutputs = gimple_asm_noutputs (gs); |
| 29313 |
for (unsigned i = 0; i < noutputs; i++) |
| 29314 |
{ |
| 29315 |
tree op = gimple_asm_output_op (gs, i); |
| 29316 |
tree val = TREE_VALUE (op); |
| 29317 |
tree type = TREE_TYPE (val); |
| 29318 |
if (check_and_error_invalid_use (type)) |
| 29319 |
return true; |
| 29320 |
} |
| 29321 |
} |
| 29322 |
else if (gcall *gc = dyn_cast<gcall *> (stmt)) |
| 29323 |
{ |
| 29324 |
unsigned nargs = gimple_call_num_args (gc); |
| 29325 |
for (unsigned i = 0; i < nargs; i++) |
| 29326 |
{ |
| 29327 |
tree arg = gimple_call_arg (gc, i); |
| 29328 |
tree type = TREE_TYPE (arg); |
| 29329 |
if (check_and_error_invalid_use (type)) |
| 29330 |
return true; |
| 29331 |
} |
| 29332 |
} |
| 29333 |
} |
| 29334 |
|
| 29335 |
return false; |
| 29336 |
} |
| 29337 |
|
| 29338 |
#undef TARGET_DOCUMENTATION_NAME |
| 29339 |
#define TARGET_DOCUMENTATION_NAME "PowerPC" |
| 29340 |
|
| 29341 |
struct gcc_target targetm = TARGET_INITIALIZER; |
| 29342 |
|
| 29343 |
#include "gt-rs6000.h" |