Introduce two more template parameter for Lithium instructions for input and temp operands.

Each LInstruction is now a subclass of LTemplateInstruction<R, I, T>

where R is number of outputs, I number of inputs and T number of temps.

This change only actually uses the parameter I for input operands. 
Since the parameter T for temps is 0, it incurs no extra cost. 

A separate change will introduce using the temps parameter.

Review URL: http://codereview.chromium.org/6215002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6275 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7c468e53
......@@ -5788,7 +5788,6 @@ void HPhase::End() const {
#ifdef DEBUG
if (graph_ != NULL) graph_->Verify();
if (chunk_ != NULL) chunk_->Verify();
if (allocator_ != NULL) allocator_->Verify();
#endif
}
......
......@@ -67,9 +67,9 @@ void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index,
void LInstruction::PrintTo(StringStream* stream) {
stream->Add("%s ", this->Mnemonic());
if (HasResult()) {
LTemplateInstruction<1>::cast(this)->result()->PrintTo(stream);
stream->Add(" ");
PrintOutputOperandTo(stream);
}
PrintDataTo(stream);
if (HasEnvironment()) {
......@@ -84,6 +84,24 @@ void LInstruction::PrintTo(StringStream* stream) {
}
template<int R, int I, int T>
void LTemplateInstruction<R, I, T>::PrintDataTo(StringStream* stream) {
for (int i = 0; i < I; i++) {
stream->Add(i == 0 ? "= " : " ");
inputs_.at(i)->PrintTo(stream);
}
}
template<int R, int I, int T>
void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream* stream) {
if (this->HasResult()) {
this->result()->PrintTo(stream);
stream->Add(" ");
}
}
void LLabel::PrintDataTo(StringStream* stream) {
LGap::PrintDataTo(stream);
LLabel* rep = replacement();
......@@ -143,15 +161,6 @@ const char* LArithmeticT::Mnemonic() const {
}
void LBinaryOperation::PrintDataTo(StringStream* stream) {
stream->Add("= ");
left()->PrintTo(stream);
stream->Add(" ");
right()->PrintTo(stream);
}
void LGoto::PrintDataTo(StringStream* stream) {
stream->Add("B%d", block_id());
}
......@@ -267,7 +276,8 @@ void LCallKnownGlobal::PrintDataTo(StringStream* stream) {
void LCallNew::PrintDataTo(StringStream* stream) {
LUnaryOperation<1>::PrintDataTo(stream);
stream->Add("= ");
input()->PrintTo(stream);
stream->Add(" #%d / ", arity());
}
......@@ -279,13 +289,6 @@ void LClassOfTest::PrintDataTo(StringStream* stream) {
}
template <int R>
void LUnaryOperation<R>::PrintDataTo(StringStream* stream) {
stream->Add("= ");
input()->PrintTo(stream);
}
void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
arguments()->PrintTo(stream);
......@@ -297,11 +300,6 @@ void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
}
void LChunk::Verify() const {
// TODO(twuerthinger): Implement verification for chunk.
}
int LChunk::GetNextSpillIndex(bool is_double) {
// Skip a slot if for a double-width slot.
if (is_double) spill_slot_count_++;
......@@ -573,35 +571,54 @@ LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) {
}
LInstruction* LChunkBuilder::Define(LTemplateInstruction<1>* instr) {
template<int I, int T>
LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr,
LUnallocated* result) {
allocator_->RecordDefinition(current_instruction_, result);
instr->set_result(result);
return instr;
}
template<int I, int T>
LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr) {
return Define(instr, new LUnallocated(LUnallocated::NONE));
}
LInstruction* LChunkBuilder::DefineAsRegister(LTemplateInstruction<1>* instr) {
template<int I, int T>
LInstruction* LChunkBuilder::DefineAsRegister(
LTemplateInstruction<1, I, T>* instr) {
return Define(instr, new LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
}
LInstruction* LChunkBuilder::DefineAsSpilled(LTemplateInstruction<1>* instr,
int index) {
template<int I, int T>
LInstruction* LChunkBuilder::DefineAsSpilled(
LTemplateInstruction<1, I, T>* instr,
int index) {
return Define(instr, new LUnallocated(LUnallocated::FIXED_SLOT, index));
}
LInstruction* LChunkBuilder::DefineSameAsFirst(LTemplateInstruction<1>* instr) {
template<int I, int T>
LInstruction* LChunkBuilder::DefineSameAsFirst(
LTemplateInstruction<1, I, T>* instr) {
return Define(instr, new LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT));
}
LInstruction* LChunkBuilder::DefineFixed(LTemplateInstruction<1>* instr,
template<int I, int T>
LInstruction* LChunkBuilder::DefineFixed(LTemplateInstruction<1, I, T>* instr,
Register reg) {
return Define(instr, ToUnallocated(reg));
}
LInstruction* LChunkBuilder::DefineFixedDouble(LTemplateInstruction<1>* instr,
XMMRegister reg) {
template<int I, int T>
LInstruction* LChunkBuilder::DefineFixedDouble(
LTemplateInstruction<1, I, T>* instr,
XMMRegister reg) {
return Define(instr, ToUnallocated(reg));
}
......@@ -669,14 +686,6 @@ LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
}
LInstruction* LChunkBuilder::Define(LTemplateInstruction<1>* instr,
LUnallocated* result) {
allocator_->RecordDefinition(current_instruction_, result);
instr->set_result(result);
return instr;
}
LUnallocated* LChunkBuilder::TempRegister() {
LUnallocated* operand = new LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
allocator_->RecordTemporary(operand);
......@@ -1279,7 +1288,9 @@ LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) {
LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) {
ASSERT(instr->value()->representation().IsInteger32());
ASSERT(instr->representation().IsInteger32());
return DefineSameAsFirst(new LBitNotI(UseRegisterAtStart(instr->value())));
LOperand* input = UseRegisterAtStart(instr->value());
LBitNotI* result = new LBitNotI(input);
return DefineSameAsFirst(result);
}
......
This diff is collapsed.
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