Skip to content

Commit

Permalink
[PATCH] [V8] Add support for using armv6 vfp2 instructions
Browse files Browse the repository at this point in the history
This is needed when building for armv6 with the
hardfloat ABI.
  • Loading branch information
Andy Nichols authored and adammw committed Aug 3, 2012
1 parent 585388b commit 3a42578
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
15 changes: 9 additions & 6 deletions deps/v8/src/arm/assembler-arm.cc
Expand Up @@ -52,17 +52,20 @@ unsigned CpuFeatures::found_by_runtime_probing_ = 0;


// Get the CPU features enabled by the build. For cross compilation the
// preprocessor symbols CAN_USE_ARMV7_INSTRUCTIONS and CAN_USE_VFP_INSTRUCTIONS
// preprocessor symbols CAN_USE_ARMV7_INSTRUCTIONS and CAN_USE_VFP3_INSTRUCTIONS
// can be defined to enable ARMv7 and VFPv3 instructions when building the
// snapshot.
static uint64_t CpuFeaturesImpliedByCompiler() {
uint64_t answer = 0;
#ifdef CAN_USE_ARMV7_INSTRUCTIONS
answer |= 1u << ARMv7;
#endif // def CAN_USE_ARMV7_INSTRUCTIONS
#ifdef CAN_USE_VFP_INSTRUCTIONS
answer |= 1u << VFP3 | 1u << ARMv7;
#endif // def CAN_USE_VFP_INSTRUCTIONS
#ifdef CAN_USE_VFP3_INSTRUCTIONS
answer |= 1u << VFP3 | 1u << VFP2 | 1u << ARMv7;
#endif // def CAN_USE_VFP3_INSTRUCTIONS
#ifdef CAN_USE_VFP2_INSTRUCTIONS
answer |= 1u << VFP2;
#endif // def CAN_USE_VFP2_INSTRUCTIONS

#ifdef __arm__
// If the compiler is allowed to use VFP then we can use VFP too in our code
Expand Down Expand Up @@ -1742,7 +1745,7 @@ void Assembler::vstr(const DwVfpRegister src,
// Instruction details available in ARM DDI 0406A, A8-786.
// cond(31-28) | 1101(27-24)| U000(23-20) | | Rbase(19-16) |
// Vsrc(15-12) | 1011(11-8) | (offset/4)
ASSERT(CpuFeatures::IsEnabled(VFP3));
ASSERT(CpuFeatures::IsEnabled(VFP3) || CpuFeatures::IsEnabled(VFP2));
int u = 1;
if (offset < 0) {
offset = -offset;
Expand Down Expand Up @@ -2028,7 +2031,7 @@ void Assembler::vmov(const DwVfpRegister dst,
// Instruction details available in ARM DDI 0406A, A8-646.
// cond(31-28) | 1100(27-24)| 010(23-21) | op=0(20) | Rt2(19-16) |
// Rt(15-12) | 1011(11-8) | 00(7-6) | M(5) | 1(4) | Vm
ASSERT(CpuFeatures::IsEnabled(VFP3));
ASSERT(CpuFeatures::IsEnabled(VFP3) || CpuFeatures::IsEnabled(VFP2));
ASSERT(!src1.is(pc) && !src2.is(pc));
emit(cond | 0xC*B24 | B22 | src2.code()*B16 |
src1.code()*B12 | 0xB*B8 | B4 | dst.code());
Expand Down
8 changes: 4 additions & 4 deletions deps/v8/src/arm/code-stubs-arm.cc
Expand Up @@ -978,7 +978,7 @@ void FloatingPointHelper::CallCCodeForDoubleOperation(
__ push(lr);
__ PrepareCallCFunction(0, 2, scratch);
if (masm->use_eabi_hardfloat()) {
CpuFeatures::Scope scope(VFP3);
CpuFeatures::Scope scope(VFP2);
__ vmov(d0, r0, r1);
__ vmov(d1, r2, r3);
}
Expand All @@ -990,7 +990,7 @@ void FloatingPointHelper::CallCCodeForDoubleOperation(
// Store answer in the overwritable heap number. Double returned in
// registers r0 and r1 or in d0.
if (masm->use_eabi_hardfloat()) {
CpuFeatures::Scope scope(VFP3);
CpuFeatures::Scope scope(VFP2);
__ vstr(d0,
FieldMemOperand(heap_number_result, HeapNumber::kValueOffset));
} else {
Expand Down Expand Up @@ -1362,7 +1362,7 @@ static void EmitTwoNonNanDoubleComparison(MacroAssembler* masm,
__ push(lr);
__ PrepareCallCFunction(0, 2, r5);
if (masm->use_eabi_hardfloat()) {
CpuFeatures::Scope scope(VFP3);
CpuFeatures::Scope scope(VFP2);
__ vmov(d0, r0, r1);
__ vmov(d1, r2, r3);
}
Expand Down Expand Up @@ -3389,7 +3389,7 @@ void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm,

__ push(lr);
__ PrepareCallCFunction(0, 1, scratch);
if (masm->use_eabi_hardfloat()) {
if (masm->use_eabi_hardfloat() && CpuFeatures::IsSupported(VFP3)) {
__ vmov(d0, d2);
} else {
__ vmov(r0, r1, d2);
Expand Down
8 changes: 4 additions & 4 deletions deps/v8/src/arm/macro-assembler-arm.cc
Expand Up @@ -930,7 +930,7 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles,
}

void MacroAssembler::GetCFunctionDoubleResult(const DoubleRegister dst) {
if (use_eabi_hardfloat()) {
if (use_eabi_hardfloat() && CpuFeatures::IsSupported(VFP3)) {
Move(dst, d0);
} else {
vmov(dst, r0, r1);
Expand Down Expand Up @@ -3332,7 +3332,7 @@ void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,


void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg) {
if (use_eabi_hardfloat()) {
if (use_eabi_hardfloat() && CpuFeatures::IsSupported(VFP3)) {
Move(d0, dreg);
} else {
vmov(r0, r1, dreg);
Expand All @@ -3342,7 +3342,7 @@ void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg) {

void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg1,
DoubleRegister dreg2) {
if (use_eabi_hardfloat()) {
if (use_eabi_hardfloat() && CpuFeatures::IsSupported(VFP3)) {
if (dreg2.is(d0)) {
ASSERT(!dreg1.is(d1));
Move(d1, dreg2);
Expand All @@ -3360,7 +3360,7 @@ void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg1,

void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg,
Register reg) {
if (use_eabi_hardfloat()) {
if (use_eabi_hardfloat() && CpuFeatures::IsSupported(VFP3)) {
Move(d0, dreg);
Move(r0, reg);
} else {
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/v8globals.h
Expand Up @@ -442,6 +442,7 @@ enum CpuFeature { SSE4_1 = 32 + 19, // x86
CPUID = 10, // x86
VFP3 = 1, // ARM
ARMv7 = 2, // ARM
VFP2 = 4, // ARM
SAHF = 0, // x86
FPU = 1}; // MIPS

Expand Down

0 comments on commit 3a42578

Please sign in to comment.