Commit 76ea8f2f authored by jacob.bramley's avatar jacob.bramley Committed by Commit bot

[arm] Simplify run-time CPU selection.

This replaces the target-selection options (such as "--enable-vfp3")
with a simpler, absolute "--arm-arch" option. This eliminates inferences
and avoids surprising behaviour in impossible situations (such as
"--enable-vfp3 --no-enable-armv7").

The available options are:
    --arm-arch=armv6          ARMv6 + VFPv2
    --arm-arch=armv7          ARMv7 + VFPv3-D32 + NEON
    --arm-arch=armv7+sudiv    ARMv7 + VFPv4-D32 + NEON + SUDIV
    --arm-arch=armv8          ARMv8 (+ all of the above)

For now, the default setting is "armv8", which results in behaviour very
similar to the existing defaults.

BUG=v8:5077

Review-Url: https://codereview.chromium.org/2223433002
Cr-Commit-Position: refs/heads/master@{#39004}
parent 0c3789fb
This diff is collapsed.
......@@ -1279,18 +1279,16 @@ void Decoder::DecodeType3(Instruction* instr) {
break;
}
}
if (FLAG_enable_sudiv) {
if (instr->Bits(5, 4) == 0x1) {
if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
if (instr->Bit(21) == 0x1) {
// UDIV (in V8 notation matching ARM ISA format) rn = rm/rs
Format(instr, "udiv'cond'b 'rn, 'rm, 'rs");
} else {
// SDIV (in V8 notation matching ARM ISA format) rn = rm/rs
Format(instr, "sdiv'cond'b 'rn, 'rm, 'rs");
}
break;
if (instr->Bits(5, 4) == 0x1) {
if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
if (instr->Bit(21) == 0x1) {
// UDIV (in V8 notation matching ARM ISA format) rn = rm/rs
Format(instr, "udiv'cond'b 'rn, 'rm, 'rs");
} else {
// SDIV (in V8 notation matching ARM ISA format) rn = rm/rs
Format(instr, "sdiv'cond'b 'rn, 'rm, 'rs");
}
break;
}
}
Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
......
......@@ -2886,26 +2886,24 @@ void Simulator::DecodeType3(Instruction* instr) {
return;
}
}
if (FLAG_enable_sudiv) {
if (instr->Bits(5, 4) == 0x1) {
if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
// (s/u)div (in V8 notation matching ARM ISA format) rn = rm/rs
// Format(instr, "'(s/u)div'cond'b 'rn, 'rm, 'rs);
int rm = instr->RmValue();
int32_t rm_val = get_register(rm);
int rs = instr->RsValue();
int32_t rs_val = get_register(rs);
int32_t ret_val = 0;
// udiv
if (instr->Bit(21) == 0x1) {
ret_val = bit_cast<int32_t>(base::bits::UnsignedDiv32(
bit_cast<uint32_t>(rm_val), bit_cast<uint32_t>(rs_val)));
} else {
ret_val = base::bits::SignedDiv32(rm_val, rs_val);
}
set_register(rn, ret_val);
return;
if (instr->Bits(5, 4) == 0x1) {
if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
// (s/u)div (in V8 notation matching ARM ISA format) rn = rm/rs
// Format(instr, "'(s/u)div'cond'b 'rn, 'rm, 'rs);
int rm = instr->RmValue();
int32_t rm_val = get_register(rm);
int rs = instr->RsValue();
int32_t rs_val = get_register(rs);
int32_t ret_val = 0;
// udiv
if (instr->Bit(21) == 0x1) {
ret_val = bit_cast<int32_t>(base::bits::UnsignedDiv32(
bit_cast<uint32_t>(rm_val), bit_cast<uint32_t>(rs_val)));
} else {
ret_val = base::bits::SignedDiv32(rm_val, rs_val);
}
set_register(rn, ret_val);
return;
}
}
// Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
......
......@@ -55,13 +55,21 @@
defined(__ARM_ARCH_7R__) || \
defined(__ARM_ARCH_7__)
# define CAN_USE_ARMV7_INSTRUCTIONS 1
#ifdef __ARM_ARCH_EXT_IDIV__
#define CAN_USE_SUDIV 1
#endif
# ifndef CAN_USE_VFP3_INSTRUCTIONS
# define CAN_USE_VFP3_INSTRUCTIONS
#define CAN_USE_VFP3_INSTRUCTIONS 1
# endif
#endif
#if defined(__ARM_ARCH_8A__)
#define CAN_USE_ARMV7_INSTRUCTIONS 1
#define CAN_USE_SUDIV 1
# define CAN_USE_ARMV8_INSTRUCTIONS 1
#ifndef CAN_USE_VFP3_INSTRUCTIONS
#define CAN_USE_VFP3_INSTRUCTIONS 1
#endif
#endif
......
......@@ -119,31 +119,27 @@ struct MaybeBoolFlag {
#else
#define DEBUG_BOOL false
#endif
#if (defined CAN_USE_VFP3_INSTRUCTIONS) || !(defined ARM_TEST_NO_FEATURE_PROBE)
#define ENABLE_VFP3_DEFAULT true
#else
#define ENABLE_VFP3_DEFAULT false
#endif
#if (defined CAN_USE_ARMV7_INSTRUCTIONS) || !(defined ARM_TEST_NO_FEATURE_PROBE)
#define ENABLE_ARMV7_DEFAULT true
#else
#define ENABLE_ARMV7_DEFAULT false
#endif
#if (defined CAN_USE_ARMV8_INSTRUCTIONS) || !(defined ARM_TEST_NO_FEATURE_PROBE)
#define ENABLE_ARMV8_DEFAULT true
#else
#define ENABLE_ARMV8_DEFAULT false
#endif
#if (defined CAN_USE_VFP32DREGS) || !(defined ARM_TEST_NO_FEATURE_PROBE)
#define ENABLE_32DREGS_DEFAULT true
#else
#define ENABLE_32DREGS_DEFAULT false
#endif
#if (defined CAN_USE_NEON) || !(defined ARM_TEST_NO_FEATURE_PROBE)
# define ENABLE_NEON_DEFAULT true
// Supported ARM configurations are:
// "armv6": ARMv6 + VFPv2
// "armv7": ARMv7 + VFPv3-D32 + NEON
// "armv7+sudiv": ARMv7 + VFPv4-D32 + NEON + SUDIV
// "armv8": ARMv8 (including all of the above)
#if !defined(ARM_TEST_NO_FEATURE_PROBE) || \
(defined(CAN_USE_ARMV8_INSTRUCTIONS) && \
defined(CAN_USE_ARMV7_INSTRUCTIONS) && defined(CAN_USE_SUDIV) && \
defined(CAN_USE_NEON) && defined(CAN_USE_VFP3_INSTRUCTIONS))
#define ARM_ARCH_DEFAULT "armv8"
#elif defined(CAN_USE_ARMV7_INSTRUCTIONS) && defined(CAN_USE_SUDIV) && \
defined(CAN_USE_NEON) && defined(CAN_USE_VFP3_INSTRUCTIONS)
#define ARM_ARCH_DEFAULT "armv7+sudiv"
#elif defined(CAN_USE_ARMV7_INSTRUCTIONS) && defined(CAN_USE_NEON) && \
defined(CAN_USE_VFP3_INSTRUCTIONS)
#define ARM_ARCH_DEFAULT "armv7"
#else
# define ENABLE_NEON_DEFAULT false
#define ARM_ARCH_DEFAULT "armv6"
#endif
#ifdef V8_OS_WIN
# define ENABLE_LOG_COLOUR false
#else
......@@ -561,36 +557,30 @@ DEFINE_BOOL(enable_bmi2, true, "enable use of BMI2 instructions if available")
DEFINE_BOOL(enable_lzcnt, true, "enable use of LZCNT instruction if available")
DEFINE_BOOL(enable_popcnt, true,
"enable use of POPCNT instruction if available")
DEFINE_BOOL(enable_vfp3, ENABLE_VFP3_DEFAULT,
"enable use of VFP3 instructions if available")
DEFINE_BOOL(enable_armv7, ENABLE_ARMV7_DEFAULT,
"enable use of ARMv7 instructions if available (ARM only)")
DEFINE_BOOL(enable_armv8, ENABLE_ARMV8_DEFAULT,
"enable use of ARMv8 instructions if available (ARM 32-bit only)")
DEFINE_BOOL(enable_neon, ENABLE_NEON_DEFAULT,
"enable use of NEON instructions if available (ARM only)")
DEFINE_BOOL(enable_sudiv, true,
"enable use of SDIV and UDIV instructions if available (ARM only)")
DEFINE_STRING(arm_arch, ARM_ARCH_DEFAULT,
"generate instructions for the selected ARM architecture if "
"available: armv6, armv7, armv7+sudiv or armv8")
DEFINE_BOOL(enable_movw_movt, false,
"enable loading 32-bit constant by means of movw/movt "
"instruction pairs (ARM only)")
DEFINE_BOOL(enable_32dregs, ENABLE_32DREGS_DEFAULT,
"enable use of d16-d31 registers on ARM - this requires VFP3")
"prefer to load 32-bit constants using movw/movt instruction pairs "
"(ARM only)")
DEFINE_BOOL(enable_vldr_imm, false,
"enable use of constant pools for double immediate (ARM only)")
DEFINE_BOOL(force_long_branches, false,
"force all emitted branches to be in long mode (MIPS/PPC only)")
DEFINE_STRING(mcpu, "auto", "enable optimization for specific cpu")
// Deprecated ARM flags (replaced by arm_arch).
DEFINE_MAYBE_BOOL(enable_armv7, "deprecated (use --arm_arch instead)")
DEFINE_MAYBE_BOOL(enable_vfp3, "deprecated (use --arm_arch instead)")
DEFINE_MAYBE_BOOL(enable_32dregs, "deprecated (use --arm_arch instead)")
DEFINE_MAYBE_BOOL(enable_neon, "deprecated (use --arm_arch instead)")
DEFINE_MAYBE_BOOL(enable_sudiv, "deprecated (use --arm_arch instead)")
DEFINE_MAYBE_BOOL(enable_armv8, "deprecated (use --arm_arch instead)")
// regexp-macro-assembler-*.cc
DEFINE_BOOL(enable_regexp_unaligned_accesses, true,
"enable unaligned accesses for the regexp engine")
DEFINE_IMPLICATION(enable_armv8, enable_vfp3)
DEFINE_IMPLICATION(enable_armv8, enable_neon)
DEFINE_IMPLICATION(enable_armv8, enable_32dregs)
DEFINE_IMPLICATION(enable_armv8, enable_sudiv)
// bootstrapper.cc
DEFINE_STRING(expose_natives_as, NULL, "expose natives in global object")
DEFINE_STRING(expose_debug_as, NULL, "expose debug in global object")
......
......@@ -732,13 +732,12 @@ enum CpuFeature {
POPCNT,
ATOM,
// ARM
VFP3,
ARMv7,
ARMv8,
SUDIV,
// - Standard configurations. The baseline is ARMv6+VFPv2.
ARMv7, // ARMv7-A + VFPv3-D32 + NEON
ARMv7_SUDIV, // ARMv7-A + VFPv4-D32 + NEON + SUDIV
ARMv8, // ARMv8-A (+ all of the above)
// - Additional tuning flags.
MOVW_MOVT_IMMEDIATE_LOADS,
VFP32DREGS,
NEON,
// MIPS, MIPS64
FPU,
FP64FPU,
......@@ -758,7 +757,13 @@ enum CpuFeature {
// PPC/S390
UNALIGNED_ACCESSES,
NUMBER_OF_CPU_FEATURES
NUMBER_OF_CPU_FEATURES,
// ARM feature aliases (based on the standard configurations above).
VFP3 = ARMv7,
NEON = ARMv7,
VFP32DREGS = ARMv7,
SUDIV = ARMv7_SUDIV
};
// Defines hints about receiver values based on structural knowledge.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment