[turbofan] Use special constant type for RPO block number operands.

R=dcarney@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#25508}
This commit is contained in:
titzer 2014-11-25 21:16:31 -08:00 committed by Commit bot
parent 30b43a8aac
commit 819955b278
10 changed files with 59 additions and 17 deletions

View File

@ -77,6 +77,7 @@ class ArmOperandConverter FINAL : public InstructionOperandConverter {
case Constant::kInt64:
case Constant::kExternalReference:
case Constant::kHeapObject:
case Constant::kRpoNumber:
break;
}
UNREACHABLE();
@ -821,6 +822,9 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kHeapObject:
__ Move(dst, src.ToHeapObject());
break;
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(dcarney): loading RPO constants on arm.
break;
}
if (destination->IsStackSlot()) __ str(dst, g.ToMemOperand(destination));
} else if (src.type() == Constant::kFloat32) {

View File

@ -142,6 +142,9 @@ class Arm64OperandConverter FINAL : public InstructionOperandConverter {
return Operand(constant.ToExternalReference());
case Constant::kHeapObject:
return Operand(constant.ToHeapObject());
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(dcarney): RPO immediates on arm64.
break;
}
UNREACHABLE();
return Operand(-1);

View File

@ -25,6 +25,8 @@ class InstructionOperandConverter {
InstructionOperandConverter(CodeGenerator* gen, Instruction* instr)
: gen_(gen), instr_(instr) {}
// -- Instruction operand accesses with conversions --------------------------
Register InputRegister(int index) {
return ToRegister(instr_->InputAt(index));
}
@ -57,22 +59,31 @@ class InstructionOperandConverter {
return ToHeapObject(instr_->InputAt(index));
}
Label* InputLabel(int index) { return gen_->GetLabel(InputRpo(index)); }
Label* InputLabel(int index) { return ToLabel(instr_->InputAt(index)); }
BasicBlock::RpoNumber InputRpo(int index) {
int rpo_number = InputInt32(index);
return BasicBlock::RpoNumber::FromInt(rpo_number);
return ToRpoNumber(instr_->InputAt(index));
}
Register OutputRegister(int index = 0) {
return ToRegister(instr_->OutputAt(index));
}
Register TempRegister(int index) { return ToRegister(instr_->TempAt(index)); }
DoubleRegister OutputDoubleRegister() {
return ToDoubleRegister(instr_->Output());
}
Register TempRegister(int index) { return ToRegister(instr_->TempAt(index)); }
// -- Conversions for operands -----------------------------------------------
Label* ToLabel(InstructionOperand* op) {
return gen_->GetLabel(ToRpoNumber(op));
}
BasicBlock::RpoNumber ToRpoNumber(InstructionOperand* op) {
return ToConstant(op).ToRpoNumber();
}
Register ToRegister(InstructionOperand* op) {
DCHECK(op->IsRegister());
@ -84,19 +95,17 @@ class InstructionOperandConverter {
return DoubleRegister::FromAllocationIndex(op->index());
}
Constant ToConstant(InstructionOperand* operand) {
if (operand->IsImmediate()) {
return gen_->code()->GetImmediate(operand->index());
Constant ToConstant(InstructionOperand* op) {
if (op->IsImmediate()) {
return gen_->code()->GetImmediate(op->index());
}
return gen_->code()->GetConstant(operand->index());
return gen_->code()->GetConstant(op->index());
}
double ToDouble(InstructionOperand* operand) {
return ToConstant(operand).ToFloat64();
}
double ToDouble(InstructionOperand* op) { return ToConstant(op).ToFloat64(); }
Handle<HeapObject> ToHeapObject(InstructionOperand* operand) {
return ToConstant(operand).ToHeapObject();
Handle<HeapObject> ToHeapObject(InstructionOperand* op) {
return ToConstant(op).ToHeapObject();
}
Frame* frame() const { return gen_->frame(); }

View File

@ -69,6 +69,8 @@ class IA32OperandConverter : public InstructionOperandConverter {
return Immediate(constant.ToHeapObject());
case Constant::kInt64:
break;
case Constant::kRpoNumber:
return Immediate::CodeRelativeOffset(ToLabel(operand));
}
UNREACHABLE();
return Immediate(-1);

View File

@ -137,8 +137,8 @@ class OperandGenerator {
}
InstructionOperand* Label(BasicBlock* block) {
// TODO(bmeurer): We misuse ImmediateOperand here.
return TempImmediate(block->rpo_number());
int index = sequence()->AddImmediate(Constant(block->GetRpoNumber()));
return ImmediateOperand::Create(index, zone());
}
protected:

View File

@ -332,6 +332,8 @@ std::ostream& operator<<(std::ostream& os, const Constant& constant) {
constant.ToExternalReference().address());
case Constant::kHeapObject:
return os << Brief(*constant.ToHeapObject());
case Constant::kRpoNumber:
return os << "RPO" << constant.ToRpoNumber().ToInt();
}
UNREACHABLE();
return os;

View File

@ -692,7 +692,8 @@ class Constant FINAL {
kFloat32,
kFloat64,
kExternalReference,
kHeapObject
kHeapObject,
kRpoNumber
};
explicit Constant(int32_t v) : type_(kInt32), value_(v) {}
@ -703,6 +704,8 @@ class Constant FINAL {
: type_(kExternalReference), value_(bit_cast<intptr_t>(ref)) {}
explicit Constant(Handle<HeapObject> obj)
: type_(kHeapObject), value_(bit_cast<intptr_t>(obj)) {}
explicit Constant(BasicBlock::RpoNumber rpo)
: type_(kRpoNumber), value_(rpo.ToInt()) {}
Type type() const { return type_; }
@ -735,6 +738,11 @@ class Constant FINAL {
return bit_cast<ExternalReference>(static_cast<intptr_t>(value_));
}
BasicBlock::RpoNumber ToRpoNumber() const {
DCHECK_EQ(kRpoNumber, type());
return BasicBlock::RpoNumber::FromInt(static_cast<int>(value_));
}
Handle<HeapObject> ToHeapObject() const {
DCHECK_EQ(kHeapObject, type());
return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_));
@ -891,7 +899,6 @@ class InstructionBlock FINAL : public ZoneObject {
PhiInstructions phis_;
const BasicBlock::Id id_;
const BasicBlock::RpoNumber ao_number_; // Assembly order number.
// TODO(dcarney): probably dont't need this.
const BasicBlock::RpoNumber rpo_number_;
const BasicBlock::RpoNumber loop_header_;
const BasicBlock::RpoNumber loop_end_;

View File

@ -70,6 +70,9 @@ class MipsOperandConverter FINAL : public InstructionOperandConverter {
// TODO(plind): Maybe we should handle ExtRef & HeapObj here?
// maybe not done on arm due to const pool ??
break;
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(titzer): RPO immediates on mips?
break;
}
UNREACHABLE();
return Operand(zero_reg);
@ -796,6 +799,9 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kHeapObject:
__ li(dst, src.ToHeapObject());
break;
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(titzer): loading RPO numbers on mips.
break;
}
if (destination->IsStackSlot()) __ sw(dst, g.ToMemOperand(destination));
} else if (src.type() == Constant::kFloat32) {

View File

@ -71,6 +71,9 @@ class MipsOperandConverter FINAL : public InstructionOperandConverter {
// TODO(plind): Maybe we should handle ExtRef & HeapObj here?
// maybe not done on arm due to const pool ??
break;
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(titzer): RPO immediates on mips?
break;
}
UNREACHABLE();
return Operand(zero_reg);
@ -1071,6 +1074,9 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kHeapObject:
__ li(dst, src.ToHeapObject());
break;
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(titzer): loading RPO numbers on mips64.
break;
}
if (destination->IsStackSlot()) __ sd(dst, g.ToMemOperand(destination));
} else if (src.type() == Constant::kFloat32) {

View File

@ -919,6 +919,9 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kHeapObject:
__ Move(dst, src.ToHeapObject());
break;
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(dcarney): load of labels on x64.
break;
}
if (destination->IsStackSlot()) {
__ movq(g.ToOperand(destination), kScratchRegister);