Demystified floating point ABI function names.

This unifies the names used for floating point ABI abstraction across
ARM and MIPS and makes them more comprehensible. Note that in the
underlying implementation, ARM doesn't care about the argument/result
distinction, while MIPS does, but we want to abstract from that, too.

Nuked an unused related function on the way.

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/136613003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18567 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 53e29e5f
......@@ -1351,13 +1351,13 @@ void MathPowStub::Generate(MacroAssembler* masm) {
{
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch);
__ SetCallCDoubleArguments(double_base, double_exponent);
__ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(
ExternalReference::power_double_double_function(masm->isolate()),
0, 2);
}
__ pop(lr);
__ GetCFunctionDoubleResult(double_result);
__ MovFromFloatResult(double_result);
__ jmp(&done);
__ bind(&int_exponent_convert);
......@@ -1425,13 +1425,13 @@ void MathPowStub::Generate(MacroAssembler* masm) {
{
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch);
__ SetCallCDoubleArguments(double_base, double_exponent);
__ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(
ExternalReference::power_double_double_function(masm->isolate()),
0, 2);
}
__ pop(lr);
__ GetCFunctionDoubleResult(double_result);
__ MovFromFloatResult(double_result);
__ bind(&done);
__ IncrementCounter(counters->math_pow(), 1, scratch, scratch2);
......
......@@ -357,9 +357,9 @@ UnaryMathFunction CreateSqrtFunction() {
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
__ GetCFunctionDoubleResult(d0);
__ MovFromFloatParameter(d0);
__ vsqrt(d0, d0);
__ SetCallCDoubleArguments(d0);
__ MovToFloatResult(d0);
__ Ret();
CodeDesc desc;
......
......@@ -2128,12 +2128,12 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
break;
case Token::MOD: {
__ PrepareCallCFunction(0, 2, scratch0());
__ SetCallCDoubleArguments(left, right);
__ MovToFloatParameters(left, right);
__ CallCFunction(
ExternalReference::mod_two_doubles_operation(isolate()),
0, 2);
// Move the result in the double result register.
__ GetCFunctionDoubleResult(result);
__ MovFromFloatResult(result);
break;
}
default:
......@@ -3934,10 +3934,10 @@ void LCodeGen::DoMathExp(LMathExp* instr) {
void LCodeGen::DoMathLog(LMathLog* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ SetCallCDoubleArguments(ToDoubleRegister(instr->value()));
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
__ CallCFunction(ExternalReference::math_log_double_function(isolate()),
0, 1);
__ GetCFunctionDoubleResult(ToDoubleRegister(instr->result()));
__ MovFromFloatResult(ToDoubleRegister(instr->result()));
}
......
......@@ -1081,7 +1081,7 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles,
}
void MacroAssembler::GetCFunctionDoubleResult(const DwVfpRegister dst) {
void MacroAssembler::MovFromFloatResult(const DwVfpRegister dst) {
if (use_eabi_hardfloat()) {
Move(dst, d0);
} else {
......@@ -1090,6 +1090,12 @@ void MacroAssembler::GetCFunctionDoubleResult(const DwVfpRegister dst) {
}
// On ARM this is just a synonym to make the purpose clear.
void MacroAssembler::MovFromFloatParameter(DwVfpRegister dst) {
MovFromFloatResult(dst);
}
void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) {
// This macro takes the dst register to make the code more readable
// at the call sites. However, the dst register has to be r5 to
......@@ -3540,33 +3546,27 @@ void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
}
void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg) {
ASSERT(dreg.is(d0));
void MacroAssembler::MovToFloatParameter(DwVfpRegister src) {
ASSERT(src.is(d0));
if (!use_eabi_hardfloat()) {
vmov(r0, r1, dreg);
vmov(r0, r1, src);
}
}
void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg1,
DwVfpRegister dreg2) {
ASSERT(dreg1.is(d0));
ASSERT(dreg2.is(d1));
if (!use_eabi_hardfloat()) {
vmov(r0, r1, dreg1);
vmov(r2, r3, dreg2);
}
// On ARM this is just a synonym to make the purpose clear.
void MacroAssembler::MovToFloatResult(DwVfpRegister src) {
MovToFloatParameter(src);
}
void MacroAssembler::SetCallCDoubleArguments(DwVfpRegister dreg,
Register reg) {
ASSERT(dreg.is(d0));
if (use_eabi_hardfloat()) {
Move(r0, reg);
} else {
Move(r2, reg);
vmov(r0, r1, dreg);
void MacroAssembler::MovToFloatParameters(DwVfpRegister src1,
DwVfpRegister src2) {
ASSERT(src1.is(d0));
ASSERT(src2.is(d1));
if (!use_eabi_hardfloat()) {
vmov(r0, r1, src1);
vmov(r2, r3, src2);
}
}
......
......@@ -1125,9 +1125,9 @@ class MacroAssembler: public Assembler {
// whether soft or hard floating point ABI is used. These functions
// abstract parameter passing for the three different ways we call
// C functions from generated code.
void SetCallCDoubleArguments(DwVfpRegister dreg);
void SetCallCDoubleArguments(DwVfpRegister dreg1, DwVfpRegister dreg2);
void SetCallCDoubleArguments(DwVfpRegister dreg, Register reg);
void MovToFloatParameter(DwVfpRegister src);
void MovToFloatParameters(DwVfpRegister src1, DwVfpRegister src2);
void MovToFloatResult(DwVfpRegister src);
// Calls a C function and cleans up the space for arguments allocated
// by PrepareCallCFunction. The called function is not allowed to trigger a
......@@ -1143,7 +1143,8 @@ class MacroAssembler: public Assembler {
int num_reg_arguments,
int num_double_arguments);
void GetCFunctionDoubleResult(const DwVfpRegister dst);
void MovFromFloatParameter(DwVfpRegister dst);
void MovFromFloatResult(DwVfpRegister dst);
// Calls an API function. Allocates HandleScope, extracts returned value
// from handle and propagates exceptions. Restores context. stack_space
......
......@@ -1425,13 +1425,13 @@ void MathPowStub::Generate(MacroAssembler* masm) {
{
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch2);
__ SetCallCDoubleArguments(double_base, double_exponent);
__ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(
ExternalReference::power_double_double_function(masm->isolate()),
0, 2);
}
__ pop(ra);
__ GetCFunctionDoubleResult(double_result);
__ MovFromFloatResult(double_result);
__ jmp(&done);
__ bind(&int_exponent_convert);
......@@ -1509,13 +1509,13 @@ void MathPowStub::Generate(MacroAssembler* masm) {
{
AllowExternalCallThatCantCauseGC scope(masm);
__ PrepareCallCFunction(0, 2, scratch);
__ SetCallCDoubleArguments(double_base, double_exponent);
__ MovToFloatParameters(double_base, double_exponent);
__ CallCFunction(
ExternalReference::power_double_double_function(masm->isolate()),
0, 2);
}
__ pop(ra);
__ GetCFunctionDoubleResult(double_result);
__ MovFromFloatResult(double_result);
__ bind(&done);
__ IncrementCounter(counters->math_pow(), 1, scratch, scratch2);
......
......@@ -535,9 +535,9 @@ UnaryMathFunction CreateSqrtFunction() {
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
__ GetFromCDoubleArguments(f12);
__ MovFromFloatParameter(f12);
__ sqrt_d(f0, f12);
__ SetForCDoubleResult(f0);
__ MovToFloatResult(f0);
__ Ret();
CodeDesc desc;
......
......@@ -1936,12 +1936,12 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
__ MultiPush(saved_regs);
__ PrepareCallCFunction(0, 2, scratch0());
__ SetCallCDoubleArguments(left, right);
__ MovToFloatParameters(left, right);
__ CallCFunction(
ExternalReference::mod_two_doubles_operation(isolate()),
0, 2);
// Move the result in the double result register.
__ GetCFunctionDoubleResult(result);
__ MovFromFloatResult(result);
// Restore saved register.
__ MultiPop(saved_regs);
......@@ -3856,10 +3856,10 @@ void LCodeGen::DoMathExp(LMathExp* instr) {
void LCodeGen::DoMathLog(LMathLog* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ SetCallCDoubleArguments(ToDoubleRegister(instr->value()));
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
__ CallCFunction(ExternalReference::math_log_double_function(isolate()),
0, 1);
__ GetCFunctionDoubleResult(ToDoubleRegister(instr->result()));
__ MovFromFloatResult(ToDoubleRegister(instr->result()));
}
......
......@@ -3517,7 +3517,7 @@ void MacroAssembler::CheckMap(Register obj,
}
void MacroAssembler::GetCFunctionDoubleResult(const DoubleRegister dst) {
void MacroAssembler::MovFromFloatResult(DoubleRegister dst) {
if (IsMipsSoftFloatABI) {
Move(dst, v0, v1);
} else {
......@@ -3526,7 +3526,7 @@ void MacroAssembler::GetCFunctionDoubleResult(const DoubleRegister dst) {
}
void MacroAssembler::GetFromCDoubleArguments(const DoubleRegister dst) {
void MacroAssembler::MovFromFloatParameter(DoubleRegister dst) {
if (IsMipsSoftFloatABI) {
Move(dst, a0, a1);
} else {
......@@ -3535,50 +3535,38 @@ void MacroAssembler::GetFromCDoubleArguments(const DoubleRegister dst) {
}
void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg) {
void MacroAssembler::MovToFloatParameter(DoubleRegister src) {
if (!IsMipsSoftFloatABI) {
Move(f12, dreg);
Move(f12, src);
} else {
Move(a0, a1, dreg);
Move(a0, a1, src);
}
}
void MacroAssembler::SetForCDoubleResult(DoubleRegister dreg) {
void MacroAssembler::MovToFloatResult(DoubleRegister src) {
if (!IsMipsSoftFloatABI) {
Move(f0, dreg);
Move(f0, src);
} else {
Move(v0, v1, dreg);
Move(v0, v1, src);
}
}
void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg1,
DoubleRegister dreg2) {
void MacroAssembler::MovToFloatParameters(DoubleRegister src1,
DoubleRegister src2) {
if (!IsMipsSoftFloatABI) {
if (dreg2.is(f12)) {
ASSERT(!dreg1.is(f14));
Move(f14, dreg2);
Move(f12, dreg1);
if (src2.is(f12)) {
ASSERT(!src1.is(f14));
Move(f14, src2);
Move(f12, src1);
} else {
Move(f12, dreg1);
Move(f14, dreg2);
Move(f12, src1);
Move(f14, src2);
}
} else {
Move(a0, a1, dreg1);
Move(a2, a3, dreg2);
}
}
void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg,
Register reg) {
if (!IsMipsSoftFloatABI) {
Move(f12, dreg);
Move(a2, reg);
} else {
Move(a2, reg);
Move(a0, a1, dreg);
Move(a0, a1, src1);
Move(a2, a3, src2);
}
}
......
......@@ -1277,17 +1277,16 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
void CallCFunction(Register function,
int num_reg_arguments,
int num_double_arguments);
void GetCFunctionDoubleResult(const DoubleRegister dst);
void GetFromCDoubleArguments(const DoubleRegister dst);
void MovFromFloatResult(DoubleRegister dst);
void MovFromFloatParameter(DoubleRegister dst);
// There are two ways of passing double arguments on MIPS, depending on
// whether soft or hard floating point ABI is used. These functions
// abstract parameter passing for the three different ways we call
// C functions from generated code.
void SetCallCDoubleArguments(DoubleRegister dreg);
void SetCallCDoubleArguments(DoubleRegister dreg1, DoubleRegister dreg2);
void SetCallCDoubleArguments(DoubleRegister dreg, Register reg);
void SetForCDoubleResult(DoubleRegister dreg);
void MovToFloatParameter(DoubleRegister src);
void MovToFloatParameters(DoubleRegister src1, DoubleRegister src2);
void MovToFloatResult(DoubleRegister src);
// Calls an API function. Allocates HandleScope, extracts returned value
// from handle and propagates exceptions. Restores context. stack_space
......
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