Reviewers: ulan,
Description:
ARM: Add support for temp double registers in Crankshaft.
BUG=none
TEST=none
Please review this at https://codereview.chromium.org/18773003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/lithium-arm.h
M src/arm/lithium-arm.cc
M src/lithium-allocator.cc
M src/lithium.h
M src/lithium.cc
Index: src/arm/lithium-arm.cc
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index
309f96addb8cf528733535c1567062484dc9b8f4..5260c12411eafe852e581e6376d6a55c96a6640d
100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -653,6 +653,19 @@ LUnallocated* LChunkBuilder::TempRegister() {
}
+LUnallocated* LChunkBuilder::TempDoubleRegister() {
+ LUnallocated* operand =
+ new(zone()) LUnallocated(LUnallocated::TEMP_DOUBLE_REGISTER);
+ int vreg = allocator_->GetVirtualRegister();
+ if (!allocator_->AllocationOk()) {
+ Abort("Out of virtual registers while trying to allocate temp
register.");
+ vreg = 0;
+ }
+ operand->set_virtual_register(vreg);
+ return operand;
+}
+
+
LOperand* LChunkBuilder::FixedTemp(Register reg) {
LUnallocated* operand = ToUnallocated(reg);
ASSERT(operand->HasFixedPolicy());
@@ -1155,7 +1168,7 @@ LInstruction*
LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
LOperand* input = UseRegister(instr->value());
- LOperand* temp = FixedTemp(d3);
+ LOperand* temp = TempDoubleRegister();
LMathRound* result = new(zone()) LMathRound(input, temp);
return AssignEnvironment(DefineAsRegister(result));
}
@@ -1202,7 +1215,7 @@ LInstruction*
LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
LOperand* input = UseTempRegister(instr->value());
LOperand* temp1 = TempRegister();
LOperand* temp2 = TempRegister();
- LOperand* double_temp = FixedTemp(d3); // Chosen by fair dice roll.
+ LOperand* double_temp = TempDoubleRegister();
LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1,
temp2);
return DefineAsRegister(result);
}
@@ -1217,7 +1230,7 @@ LInstruction*
LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
LOperand* input = UseFixedDouble(instr->value(), d2);
- LOperand* temp = FixedTemp(d3);
+ LOperand* temp = TempDoubleRegister();
LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp);
return DefineFixedDouble(result, d2);
}
@@ -1342,7 +1355,8 @@ LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
}
LOperand* dividend = UseRegister(instr->left());
LOperand* divisor = UseRegister(instr->right());
- LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL :
FixedTemp(d4);
+ LOperand* temp =
+ CpuFeatures::IsSupported(SUDIV) ? NULL : TempDoubleRegister();
LDivI* div = new(zone()) LDivI(dividend, divisor, temp);
return AssignEnvironment(DefineAsRegister(div));
} else {
@@ -1455,8 +1469,8 @@ LInstruction* LChunkBuilder::DoMod(HMod* instr) {
} else {
LModI* mod = new(zone()) LModI(UseRegister(left),
UseRegister(right),
- FixedTemp(d10),
- FixedTemp(d11));
+ TempDoubleRegister(),
+ TempDoubleRegister());
LInstruction* result = DefineAsRegister(mod);
return (right->CanBeZero() ||
(left->CanBeNegative() &&
@@ -1918,7 +1932,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr)
{
LOperand* temp1 = TempRegister();
LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister()
: NULL;
- LOperand* temp3 = FixedTemp(d11);
+ LOperand* temp3 = TempDoubleRegister();
res = DefineSameAsFirst(new(zone()) LTaggedToI(value,
temp1,
temp2,
@@ -2042,14 +2056,14 @@ LInstruction*
LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
Representation input_rep = value->representation();
LOperand* reg = UseRegister(value);
if (input_rep.IsDouble()) {
- return DefineAsRegister(new(zone()) LClampDToUint8(reg,
FixedTemp(d11)));
+ return DefineAsRegister(
+ new(zone()) LClampDToUint8(reg, TempDoubleRegister()));
} else if (input_rep.IsInteger32()) {
return DefineAsRegister(new(zone()) LClampIToUint8(reg));
} else {
ASSERT(input_rep.IsSmiOrTagged());
- // Register allocator doesn't (yet) support allocation of double
- // temps. Reserve d1 explicitly.
- LClampTToUint8* result = new(zone()) LClampTToUint8(reg,
FixedTemp(d11));
+ LClampTToUint8* result =
+ new(zone()) LClampTToUint8(reg, TempDoubleRegister());
return AssignEnvironment(DefineAsRegister(result));
}
}
Index: src/arm/lithium-arm.h
diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h
index
b91288d9401952009c37043ab4ae844fbb91e87c..74d2e48a18ceda4c4b593e345f4ecb8446855afd
100644
--- a/src/arm/lithium-arm.h
+++ b/src/arm/lithium-arm.h
@@ -2760,6 +2760,7 @@ class LChunkBuilder BASE_EMBEDDED {
// Temporary operand that must be in a register.
MUST_USE_RESULT LUnallocated* TempRegister();
+ MUST_USE_RESULT LUnallocated* TempDoubleRegister();
MUST_USE_RESULT LOperand* FixedTemp(Register reg);
MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
Index: src/lithium-allocator.cc
diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc
index
2e2f802558c4a02606033a353e8356f51775b892..3c193cc899bde74df99f5bf48e588abcfc548547
100644
--- a/src/lithium-allocator.cc
+++ b/src/lithium-allocator.cc
@@ -67,7 +67,8 @@ UsePosition::UsePosition(LifetimePosition pos,
register_beneficial_(true) {
if (operand_ != NULL && operand_->IsUnallocated()) {
LUnallocated* unalloc = LUnallocated::cast(operand_);
- requires_reg_ = unalloc->HasRegisterPolicy();
+ requires_reg_ = unalloc->HasRegisterPolicy() ||
+ unalloc->HasTempDoubleRegisterPolicy();
register_beneficial_ = !unalloc->HasAnyPolicy();
}
ASSERT(pos_.IsValid());
@@ -1021,6 +1022,14 @@ void LAllocator::ProcessInstructions(HBasicBlock*
block, BitVector* live) {
}
Use(block_start_position, curr_position.InstructionEnd(), temp,
NULL);
Define(curr_position, temp, NULL);
+ if (temp->IsUnallocated()) {
+ LUnallocated* temp_unalloc = LUnallocated::cast(temp);
+ if (temp_unalloc->HasTempDoubleRegisterPolicy()) {
+ double_artificial_registers_.Add(
+ temp_unalloc->virtual_register() -
first_artificial_register_,
+ zone());
+ }
+ }
}
}
}
@@ -1111,7 +1120,6 @@ bool LAllocator::Allocate(LChunk* chunk) {
void LAllocator::MeetRegisterConstraints() {
LAllocatorPhase phase("L_Register constraints", this);
- first_artificial_register_ = next_virtual_register_;
const ZoneList<HBasicBlock*>* blocks = graph_->blocks();
for (int i = 0; i < blocks->length(); ++i) {
HBasicBlock* block = blocks->at(i);
Index: src/lithium.cc
diff --git a/src/lithium.cc b/src/lithium.cc
index
3df8d6cc298662bcf8294d77d10c349470442912..a3aeb5b02499bd18b66d2c2ffcf58e513fb38715
100644
--- a/src/lithium.cc
+++ b/src/lithium.cc
@@ -82,6 +82,9 @@ void LOperand::PrintTo(StringStream* stream) {
case LUnallocated::MUST_HAVE_REGISTER:
stream->Add("(R)");
break;
+ case LUnallocated::TEMP_DOUBLE_REGISTER:
+ stream->Add("(D)");
+ break;
case LUnallocated::WRITABLE_REGISTER:
stream->Add("(WR)");
break;
Index: src/lithium.h
diff --git a/src/lithium.h b/src/lithium.h
index
1e0784eb98da891e9cde48919d91706cce13ac39..446ca1a8e1de1d8e47650fa18579388ee82b4a69
100644
--- a/src/lithium.h
+++ b/src/lithium.h
@@ -103,6 +103,7 @@ class LUnallocated: public LOperand {
FIXED_REGISTER,
FIXED_DOUBLE_REGISTER,
MUST_HAVE_REGISTER,
+ TEMP_DOUBLE_REGISTER,
WRITABLE_REGISTER,
SAME_AS_FIRST_INPUT
};
@@ -212,6 +213,10 @@ class LUnallocated: public LOperand {
extended_policy() == WRITABLE_REGISTER ||
extended_policy() == MUST_HAVE_REGISTER);
}
+ bool HasTempDoubleRegisterPolicy() const {
+ return basic_policy() == EXTENDED_POLICY &&
+ extended_policy() == TEMP_DOUBLE_REGISTER;
+ }
bool HasSameAsInputPolicy() const {
return basic_policy() == EXTENDED_POLICY &&
extended_policy() == SAME_AS_FIRST_INPUT;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.