Commit 5f8cd123 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC: refactor setting cpu features

PPC features on V8 are currently only enabled by checking the cpu
type (i.e if >= powerX then set a feature as available).
This CL bypasses the feature list and simply checks if the cpu
type is >= a specific type required by certain instructions.

Specific feature checks (such as FPU) can always be added back to the
list if needed.

Change-Id: Ic7d1f1375c28da507f96f93f879859ef3dbfe512
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3048971
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75923}
parent b973e235
...@@ -2831,7 +2831,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm, ...@@ -2831,7 +2831,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ lbz(scratch, MemOperand(scratch, 0)); __ lbz(scratch, MemOperand(scratch, 0));
__ cmpi(scratch, Operand::Zero()); __ cmpi(scratch, Operand::Zero());
if (CpuFeatures::IsSupported(ISELECT)) { if (CpuFeatures::IsSupported(PPC_7_PLUS)) {
__ Move(scratch, thunk_ref); __ Move(scratch, thunk_ref);
__ isel(eq, scratch, function_address, scratch); __ isel(eq, scratch, function_address, scratch);
} else { } else {
......
...@@ -52,13 +52,11 @@ enum CpuFeature { ...@@ -52,13 +52,11 @@ enum CpuFeature {
MIPS_SIMD, // MSA instructions MIPS_SIMD, // MSA instructions
#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
FPU, PPC_6_PLUS,
FPR_GPR_MOV, PPC_7_PLUS,
LWSYNC, PPC_8_PLUS,
ISELECT, PPC_9_PLUS,
VSX, PPC_10_PLUS,
MODULO,
SIMD,
#elif V8_TARGET_ARCH_S390X #elif V8_TARGET_ARCH_S390X
FPU, FPU,
......
...@@ -56,7 +56,7 @@ static unsigned CpuFeaturesImpliedByCompiler() { ...@@ -56,7 +56,7 @@ static unsigned CpuFeaturesImpliedByCompiler() {
bool CpuFeatures::SupportsWasmSimd128() { bool CpuFeatures::SupportsWasmSimd128() {
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
return CpuFeatures::IsSupported(SIMD); return CpuFeatures::IsSupported(PPC_9_PLUS);
#else #else
return false; return false;
#endif // V8_ENABLE_WEBASSEMBLY #endif // V8_ENABLE_WEBASSEMBLY
...@@ -69,65 +69,33 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { ...@@ -69,65 +69,33 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
// Only use statically determined features for cross compile (snapshot). // Only use statically determined features for cross compile (snapshot).
if (cross_compile) return; if (cross_compile) return;
// Detect whether frim instruction is supported (POWER5+) // Probe for additional features at runtime.
// For now we will just check for processors we know do not #ifdef USE_SIMULATOR
// support it // Simulator
#ifndef USE_SIMULATOR supported_ |= (1u << PPC_10_PLUS);
// Probe for additional features at runtime. #else
base::CPU cpu; base::CPU cpu;
if (cpu.part() == base::CPU::kPPCPower9 || if (cpu.part() == base::CPU::kPPCPower10) {
cpu.part() == base::CPU::kPPCPower10) { supported_ |= (1u << PPC_10_PLUS);
supported_ |= (1u << MODULO); } else if (cpu.part() == base::CPU::kPPCPower9) {
} supported_ |= (1u << PPC_9_PLUS);
#if V8_TARGET_ARCH_PPC64 } else if (cpu.part() == base::CPU::kPPCPower8) {
if (cpu.part() == base::CPU::kPPCPower8 || supported_ |= (1u << PPC_8_PLUS);
cpu.part() == base::CPU::kPPCPower9 || } else if (cpu.part() == base::CPU::kPPCPower7) {
cpu.part() == base::CPU::kPPCPower10) { supported_ |= (1u << PPC_7_PLUS);
supported_ |= (1u << FPR_GPR_MOV); } else if (cpu.part() == base::CPU::kPPCPower6) {
} supported_ |= (1u << PPC_6_PLUS);
// V8 PPC Simd implementations need P9 at a minimum.
if (cpu.part() == base::CPU::kPPCPower9 ||
cpu.part() == base::CPU::kPPCPower10) {
supported_ |= (1u << SIMD);
}
#endif
if (cpu.part() == base::CPU::kPPCPower6 ||
cpu.part() == base::CPU::kPPCPower7 ||
cpu.part() == base::CPU::kPPCPower8 ||
cpu.part() == base::CPU::kPPCPower9 ||
cpu.part() == base::CPU::kPPCPower10) {
supported_ |= (1u << LWSYNC);
}
if (cpu.part() == base::CPU::kPPCPower7 ||
cpu.part() == base::CPU::kPPCPower8 ||
cpu.part() == base::CPU::kPPCPower9 ||
cpu.part() == base::CPU::kPPCPower10) {
supported_ |= (1u << ISELECT);
supported_ |= (1u << VSX);
} }
#if V8_OS_LINUX #if V8_OS_LINUX
if (!(cpu.part() == base::CPU::kPPCG5 || cpu.part() == base::CPU::kPPCG4)) {
// Assume support
supported_ |= (1u << FPU);
}
if (cpu.icache_line_size() != base::CPU::kUnknownCacheLineSize) { if (cpu.icache_line_size() != base::CPU::kUnknownCacheLineSize) {
icache_line_size_ = cpu.icache_line_size(); icache_line_size_ = cpu.icache_line_size();
} }
#elif V8_OS_AIX
// Assume support FP support and default cache line size
supported_ |= (1u << FPU);
#endif
#else // Simulator
supported_ |= (1u << FPU);
supported_ |= (1u << LWSYNC);
supported_ |= (1u << ISELECT);
supported_ |= (1u << VSX);
supported_ |= (1u << MODULO);
supported_ |= (1u << SIMD);
#if V8_TARGET_ARCH_PPC64
supported_ |= (1u << FPR_GPR_MOV);
#endif #endif
#endif #endif
if (supported_ & (1u << PPC_10_PLUS)) supported_ |= (1u << PPC_9_PLUS);
if (supported_ & (1u << PPC_9_PLUS)) supported_ |= (1u << PPC_8_PLUS);
if (supported_ & (1u << PPC_8_PLUS)) supported_ |= (1u << PPC_7_PLUS);
if (supported_ & (1u << PPC_7_PLUS)) supported_ |= (1u << PPC_6_PLUS);
// Set a static value on whether Simd is supported. // Set a static value on whether Simd is supported.
// This variable is only used for certain archs to query SupportWasmSimd128() // This variable is only used for certain archs to query SupportWasmSimd128()
...@@ -149,12 +117,11 @@ void CpuFeatures::PrintTarget() { ...@@ -149,12 +117,11 @@ void CpuFeatures::PrintTarget() {
} }
void CpuFeatures::PrintFeatures() { void CpuFeatures::PrintFeatures() {
printf("FPU=%d\n", CpuFeatures::IsSupported(FPU)); printf("PPC_6_PLUS=%d\n", CpuFeatures::IsSupported(PPC_6_PLUS));
printf("FPR_GPR_MOV=%d\n", CpuFeatures::IsSupported(FPR_GPR_MOV)); printf("PPC_7_PLUS=%d\n", CpuFeatures::IsSupported(PPC_7_PLUS));
printf("LWSYNC=%d\n", CpuFeatures::IsSupported(LWSYNC)); printf("PPC_8_PLUS=%d\n", CpuFeatures::IsSupported(PPC_8_PLUS));
printf("ISELECT=%d\n", CpuFeatures::IsSupported(ISELECT)); printf("PPC_9_PLUS=%d\n", CpuFeatures::IsSupported(PPC_9_PLUS));
printf("VSX=%d\n", CpuFeatures::IsSupported(VSX)); printf("PPC_10_PLUS=%d\n", CpuFeatures::IsSupported(PPC_10_PLUS));
printf("MODULO=%d\n", CpuFeatures::IsSupported(MODULO));
} }
Register ToRegister(int num) { Register ToRegister(int num) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "src/codegen/cpu-features.h" #include "src/codegen/cpu-features.h"
#define INSTR_AND_DATA_CACHE_COHERENCY LWSYNC #define INSTR_AND_DATA_CACHE_COHERENCY PPC_6_PLUS
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -2450,7 +2450,7 @@ void TurboAssembler::LoadDoubleLiteral(DoubleRegister result, ...@@ -2450,7 +2450,7 @@ void TurboAssembler::LoadDoubleLiteral(DoubleRegister result,
litVal.dval = value.AsUint64(); litVal.dval = value.AsUint64();
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mov(scratch, Operand(litVal.ival)); mov(scratch, Operand(litVal.ival));
mtfprd(result, scratch); mtfprd(result, scratch);
return; return;
...@@ -2476,7 +2476,7 @@ void TurboAssembler::MovIntToDouble(DoubleRegister dst, Register src, ...@@ -2476,7 +2476,7 @@ void TurboAssembler::MovIntToDouble(DoubleRegister dst, Register src,
Register scratch) { Register scratch) {
// sign-extend src to 64-bit // sign-extend src to 64-bit
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mtfprwa(dst, src); mtfprwa(dst, src);
return; return;
} }
...@@ -2501,7 +2501,7 @@ void TurboAssembler::MovUnsignedIntToDouble(DoubleRegister dst, Register src, ...@@ -2501,7 +2501,7 @@ void TurboAssembler::MovUnsignedIntToDouble(DoubleRegister dst, Register src,
Register scratch) { Register scratch) {
// zero-extend src to 64-bit // zero-extend src to 64-bit
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mtfprwz(dst, src); mtfprwz(dst, src);
return; return;
} }
...@@ -2528,7 +2528,7 @@ void TurboAssembler::MovInt64ToDouble(DoubleRegister dst, ...@@ -2528,7 +2528,7 @@ void TurboAssembler::MovInt64ToDouble(DoubleRegister dst,
#endif #endif
Register src) { Register src) {
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mtfprd(dst, src); mtfprd(dst, src);
return; return;
} }
...@@ -2551,7 +2551,7 @@ void TurboAssembler::MovInt64ComponentsToDouble(DoubleRegister dst, ...@@ -2551,7 +2551,7 @@ void TurboAssembler::MovInt64ComponentsToDouble(DoubleRegister dst,
Register src_hi, Register src_hi,
Register src_lo, Register src_lo,
Register scratch) { Register scratch) {
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
ShiftLeftU64(scratch, src_hi, Operand(32)); ShiftLeftU64(scratch, src_hi, Operand(32));
rldimi(scratch, src_lo, 0, 32); rldimi(scratch, src_lo, 0, 32);
mtfprd(dst, scratch); mtfprd(dst, scratch);
...@@ -2570,7 +2570,7 @@ void TurboAssembler::MovInt64ComponentsToDouble(DoubleRegister dst, ...@@ -2570,7 +2570,7 @@ void TurboAssembler::MovInt64ComponentsToDouble(DoubleRegister dst,
void TurboAssembler::InsertDoubleLow(DoubleRegister dst, Register src, void TurboAssembler::InsertDoubleLow(DoubleRegister dst, Register src,
Register scratch) { Register scratch) {
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mffprd(scratch, dst); mffprd(scratch, dst);
rldimi(scratch, src, 0, 32); rldimi(scratch, src, 0, 32);
mtfprd(dst, scratch); mtfprd(dst, scratch);
...@@ -2589,7 +2589,7 @@ void TurboAssembler::InsertDoubleLow(DoubleRegister dst, Register src, ...@@ -2589,7 +2589,7 @@ void TurboAssembler::InsertDoubleLow(DoubleRegister dst, Register src,
void TurboAssembler::InsertDoubleHigh(DoubleRegister dst, Register src, void TurboAssembler::InsertDoubleHigh(DoubleRegister dst, Register src,
Register scratch) { Register scratch) {
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mffprd(scratch, dst); mffprd(scratch, dst);
rldimi(scratch, src, 32, 0); rldimi(scratch, src, 32, 0);
mtfprd(dst, scratch); mtfprd(dst, scratch);
...@@ -2607,7 +2607,7 @@ void TurboAssembler::InsertDoubleHigh(DoubleRegister dst, Register src, ...@@ -2607,7 +2607,7 @@ void TurboAssembler::InsertDoubleHigh(DoubleRegister dst, Register src,
void TurboAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) { void TurboAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) {
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mffprwz(dst, src); mffprwz(dst, src);
return; return;
} }
...@@ -2622,7 +2622,7 @@ void TurboAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) { ...@@ -2622,7 +2622,7 @@ void TurboAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) {
void TurboAssembler::MovDoubleHighToInt(Register dst, DoubleRegister src) { void TurboAssembler::MovDoubleHighToInt(Register dst, DoubleRegister src) {
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mffprd(dst, src); mffprd(dst, src);
srdi(dst, dst, Operand(32)); srdi(dst, dst, Operand(32));
return; return;
...@@ -2642,7 +2642,7 @@ void TurboAssembler::MovDoubleToInt64( ...@@ -2642,7 +2642,7 @@ void TurboAssembler::MovDoubleToInt64(
#endif #endif
Register dst, DoubleRegister src) { Register dst, DoubleRegister src) {
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { if (CpuFeatures::IsSupported(PPC_8_PLUS)) {
mffprd(dst, src); mffprd(dst, src);
return; return;
} }
......
...@@ -1487,7 +1487,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1487,7 +1487,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
ASSEMBLE_FLOAT_BINOP_RC(fdiv, MiscField::decode(instr->opcode())); ASSEMBLE_FLOAT_BINOP_RC(fdiv, MiscField::decode(instr->opcode()));
break; break;
case kPPC_Mod32: case kPPC_Mod32:
if (CpuFeatures::IsSupported(MODULO)) { if (CpuFeatures::IsSupported(PPC_9_PLUS)) {
__ modsw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); __ modsw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else { } else {
ASSEMBLE_MODULO(divw, mullw); ASSEMBLE_MODULO(divw, mullw);
...@@ -1495,7 +1495,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1495,7 +1495,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
case kPPC_Mod64: case kPPC_Mod64:
if (CpuFeatures::IsSupported(MODULO)) { if (CpuFeatures::IsSupported(PPC_9_PLUS)) {
__ modsd(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); __ modsd(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else { } else {
ASSEMBLE_MODULO(divd, mulld); ASSEMBLE_MODULO(divd, mulld);
...@@ -1503,7 +1503,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1503,7 +1503,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
#endif #endif
case kPPC_ModU32: case kPPC_ModU32:
if (CpuFeatures::IsSupported(MODULO)) { if (CpuFeatures::IsSupported(PPC_9_PLUS)) {
__ moduw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); __ moduw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else { } else {
ASSEMBLE_MODULO(divwu, mullw); ASSEMBLE_MODULO(divwu, mullw);
...@@ -1511,7 +1511,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1511,7 +1511,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
case kPPC_ModU64: case kPPC_ModU64:
if (CpuFeatures::IsSupported(MODULO)) { if (CpuFeatures::IsSupported(PPC_9_PLUS)) {
__ modud(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); __ modud(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else { } else {
ASSEMBLE_MODULO(divdu, mulld); ASSEMBLE_MODULO(divdu, mulld);
...@@ -1868,7 +1868,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1868,7 +1868,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
cr, static_cast<CRBit>(VXCVI % CRWIDTH)); cr, static_cast<CRBit>(VXCVI % CRWIDTH));
__ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7 __ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7
// Handle conversion failures (such as overflow). // Handle conversion failures (such as overflow).
if (CpuFeatures::IsSupported(ISELECT)) { if (CpuFeatures::IsSupported(PPC_7_PLUS)) {
if (check_conversion) { if (check_conversion) {
__ li(i.OutputRegister(1), Operand(1)); __ li(i.OutputRegister(1), Operand(1));
__ isel(i.OutputRegister(1), r0, i.OutputRegister(1), crbit); __ isel(i.OutputRegister(1), r0, i.OutputRegister(1), crbit);
...@@ -1905,7 +1905,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1905,7 +1905,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
int crbit = v8::internal::Assembler::encode_crbit( int crbit = v8::internal::Assembler::encode_crbit(
cr, static_cast<CRBit>(VXCVI % CRWIDTH)); cr, static_cast<CRBit>(VXCVI % CRWIDTH));
__ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7 __ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7
if (CpuFeatures::IsSupported(ISELECT)) { if (CpuFeatures::IsSupported(PPC_7_PLUS)) {
__ li(i.OutputRegister(1), Operand(1)); __ li(i.OutputRegister(1), Operand(1));
__ isel(i.OutputRegister(1), r0, i.OutputRegister(1), crbit); __ isel(i.OutputRegister(1), r0, i.OutputRegister(1), crbit);
} else { } else {
...@@ -3885,7 +3885,7 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, ...@@ -3885,7 +3885,7 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
// Unnecessary for eq/lt & ne/ge since only FU bit will be set. // Unnecessary for eq/lt & ne/ge since only FU bit will be set.
} }
if (CpuFeatures::IsSupported(ISELECT)) { if (CpuFeatures::IsSupported(PPC_7_PLUS)) {
switch (cond) { switch (cond) {
case eq: case eq:
case lt: case lt:
......
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