Commit e2f3003f authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Enforce that C calls do not use floating point params.

Passing floating point params to/from C has never quite worked correctly,
but we've never enforced the restriction early in the CallDescriptor
creation process because of unittests. Fix unittests to make their own
simple call descriptors and not rely on the C ones.

R=bmeurer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#33993}
parent b065c216
......@@ -136,20 +136,19 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, const MachineSignature* msig, bool set_initialize_root_flag) {
LocationSignature::Builder locations(zone, msig->return_count(),
msig->parameter_count());
#if 0 // TODO(titzer): instruction selector tests break here.
// Check the types of the signature.
// Currently no floating point parameters or returns are allowed because
// on x87 and ia32, the FP top of stack is involved.
for (size_t i = 0; i < msig->return_count(); i++) {
MachineType type = RepresentationOf(msig->GetReturn(i));
CHECK(type != kRepFloat32 && type != kRepFloat64);
MachineRepresentation rep = msig->GetReturn(i).representation();
CHECK_NE(MachineRepresentation::kFloat32, rep);
CHECK_NE(MachineRepresentation::kFloat64, rep);
}
for (size_t i = 0; i < msig->parameter_count(); i++) {
MachineType type = RepresentationOf(msig->GetParam(i));
CHECK(type != kRepFloat32 && type != kRepFloat64);
MachineRepresentation rep = msig->GetParam(i).representation();
CHECK_NE(MachineRepresentation::kFloat32, rep);
CHECK_NE(MachineRepresentation::kFloat64, rep);
}
#endif
#ifdef UNSUPPORTED_C_LINKAGE
// This method should not be called on unknown architectures.
......
......@@ -92,7 +92,7 @@ class InstructionSelectorTest : public TestWithContext,
CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type) {
MachineSignature::Builder builder(zone, 1, 0);
builder.AddReturn(return_type);
return Linkage::GetSimplifiedCDescriptor(zone, builder.Build());
return MakeSimpleCallDescriptor(zone, builder.Build());
}
CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type,
......@@ -100,7 +100,7 @@ class InstructionSelectorTest : public TestWithContext,
MachineSignature::Builder builder(zone, 1, 1);
builder.AddReturn(return_type);
builder.AddParam(parameter0_type);
return Linkage::GetSimplifiedCDescriptor(zone, builder.Build());
return MakeSimpleCallDescriptor(zone, builder.Build());
}
CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type,
......@@ -110,7 +110,7 @@ class InstructionSelectorTest : public TestWithContext,
builder.AddReturn(return_type);
builder.AddParam(parameter0_type);
builder.AddParam(parameter1_type);
return Linkage::GetSimplifiedCDescriptor(zone, builder.Build());
return MakeSimpleCallDescriptor(zone, builder.Build());
}
CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type,
......@@ -122,11 +122,48 @@ class InstructionSelectorTest : public TestWithContext,
builder.AddParam(parameter0_type);
builder.AddParam(parameter1_type);
builder.AddParam(parameter2_type);
return Linkage::GetSimplifiedCDescriptor(zone, builder.Build());
return MakeSimpleCallDescriptor(zone, builder.Build());
}
private:
InstructionSelectorTest* test_;
// Create a simple call descriptor for testing.
CallDescriptor* MakeSimpleCallDescriptor(Zone* zone,
MachineSignature* msig) {
LocationSignature::Builder locations(zone, msig->return_count(),
msig->parameter_count());
// Add return location(s).
const int return_count = static_cast<int>(msig->return_count());
for (int i = 0; i < return_count; i++) {
locations.AddReturn(LinkageLocation::ForCallerFrameSlot(-1 - i));
}
// Just put all parameters on the stack.
const int parameter_count = static_cast<int>(msig->parameter_count());
for (int i = 0; i < parameter_count; i++) {
locations.AddParam(LinkageLocation::ForCallerFrameSlot(-1 - i));
}
const RegList kCalleeSaveRegisters = 0;
const RegList kCalleeSaveFPRegisters = 0;
MachineType target_type = MachineType::Pointer();
LinkageLocation target_loc = LinkageLocation::ForAnyRegister();
return new (zone) CallDescriptor( // --
CallDescriptor::kCallAddress, // kind
target_type, // target MachineType
target_loc, // target location
msig, // machine_sig
locations.Build(), // location_sig
0, // stack_parameter_count
Operator::kNoProperties, // properties
kCalleeSaveRegisters, // callee-saved registers
kCalleeSaveFPRegisters, // callee-saved fp regs
CallDescriptor::kNoFlags, // flags
"iselect-test-call");
}
};
class Stream final {
......
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