Commit 7b9cb2eb authored by dcarney's avatar dcarney Committed by Commit bot

[turbofan] remove control field from instruction

R=titzer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#25866}
parent 70b5eb47
......@@ -238,9 +238,8 @@ void VisitBinop(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(outputs), output_count);
DCHECK_NE(kMode_None, AddressingModeField::decode(opcode));
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -578,9 +577,8 @@ static inline void VisitShift(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(outputs), output_count);
DCHECK_NE(kMode_None, AddressingModeField::decode(opcode));
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -1077,7 +1075,7 @@ void VisitFloat64Compare(InstructionSelector* selector, Node* node,
selector->Emit(cont->Encode(kArmVcmpF64), nullptr,
g.UseRegister(m.left().node()),
g.UseRegister(m.right().node()), g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->false_block()));
} else {
DCHECK(cont->IsSet());
selector->Emit(
......@@ -1124,9 +1122,8 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count);
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -1231,8 +1228,7 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
InstructionOperand* const value_operand = g.UseRegister(value);
if (cont->IsBranch()) {
selector->Emit(opcode, nullptr, value_operand, value_operand,
g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->true_block()), g.Label(cont->false_block()));
} else {
selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand,
value_operand);
......
......@@ -219,9 +219,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count);
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -1163,7 +1162,7 @@ static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->false_block()));
} else {
DCHECK(cont->IsSet());
selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
......@@ -1351,8 +1350,7 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
g.UseRegister(m.left().node()),
g.TempImmediate(
base::bits::CountTrailingZeros32(m.right().Value())),
g.Label(cont.true_block()),
g.Label(cont.false_block()))->MarkAsControl();
g.Label(cont.true_block()), g.Label(cont.false_block()));
return;
}
return VisitWordCompare(this, value, kArm64Tst32, &cont, true,
......@@ -1369,8 +1367,7 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
g.UseRegister(m.left().node()),
g.TempImmediate(
base::bits::CountTrailingZeros64(m.right().Value())),
g.Label(cont.true_block()),
g.Label(cont.false_block()))->MarkAsControl();
g.Label(cont.true_block()), g.Label(cont.false_block()));
return;
}
return VisitWordCompare(this, value, kArm64Tst, &cont, true,
......@@ -1383,8 +1380,7 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
// Branch could not be combined with a compare, compare against 0 and branch.
Emit(cont.Encode(kArm64CompareAndBranch32), NULL, g.UseRegister(value),
g.Label(cont.true_block()),
g.Label(cont.false_block()))->MarkAsControl();
g.Label(cont.true_block()), g.Label(cont.false_block()));
}
......
......@@ -374,9 +374,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count);
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -776,8 +775,7 @@ void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
IA32OperandGenerator g(selector);
if (cont->IsBranch()) {
selector->Emit(cont->Encode(opcode), NULL, left, right,
g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->true_block()), g.Label(cont->false_block()));
} else {
DCHECK(cont->IsSet());
// TODO(titzer): Needs byte register.
......
......@@ -1002,7 +1002,7 @@ void InstructionSelector::VisitConstant(Node* node) {
void InstructionSelector::VisitGoto(BasicBlock* target) {
// jump to the next block.
OperandGenerator g(this);
Emit(kArchJmp, NULL, g.Label(target))->MarkAsControl();
Emit(kArchJmp, NULL, g.Label(target));
}
......
......@@ -454,7 +454,7 @@ class Instruction : public ZoneObject {
return FlagsConditionField::decode(opcode());
}
// TODO(titzer): make control and call into flags.
// TODO(titzer): make call into a flag.
static Instruction* New(Zone* zone, InstructionCode opcode) {
return New(zone, opcode, 0, NULL, 0, NULL, 0, NULL);
}
......@@ -476,17 +476,10 @@ class Instruction : public ZoneObject {
opcode, output_count, outputs, input_count, inputs, temp_count, temps);
}
// TODO(titzer): another holdover from lithium days; register allocator
// should not need to know about control instructions.
Instruction* MarkAsControl() {
bit_field_ = IsControlField::update(bit_field_, true);
return this;
}
Instruction* MarkAsCall() {
bit_field_ = IsCallField::update(bit_field_, true);
return this;
}
bool IsControl() const { return IsControlField::decode(bit_field_); }
bool IsCall() const { return IsCallField::decode(bit_field_); }
bool NeedsPointerMap() const { return IsCall(); }
bool HasPointerMap() const { return pointer_map_ != NULL; }
......@@ -528,8 +521,7 @@ class Instruction : public ZoneObject {
explicit Instruction(InstructionCode opcode)
: opcode_(opcode),
bit_field_(OutputCountField::encode(0) | InputCountField::encode(0) |
TempCountField::encode(0) | IsCallField::encode(false) |
IsControlField::encode(false)),
TempCountField::encode(0) | IsCallField::encode(false)),
pointer_map_(NULL) {}
Instruction(InstructionCode opcode, size_t output_count,
......@@ -540,7 +532,7 @@ class Instruction : public ZoneObject {
bit_field_(OutputCountField::encode(output_count) |
InputCountField::encode(input_count) |
TempCountField::encode(temp_count) |
IsCallField::encode(false) | IsControlField::encode(false)),
IsCallField::encode(false)),
pointer_map_(NULL) {
for (size_t i = 0; i < output_count; ++i) {
operands_[i] = outputs[i];
......@@ -558,7 +550,6 @@ class Instruction : public ZoneObject {
typedef BitField<size_t, 8, 16> InputCountField;
typedef BitField<size_t, 24, 6> TempCountField;
typedef BitField<bool, 30, 1> IsCallField;
typedef BitField<bool, 31, 1> IsControlField;
InstructionCode opcode_;
uint32_t bit_field_;
......
......@@ -105,9 +105,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count);
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -586,7 +585,7 @@ static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->false_block()));
} else {
DCHECK(cont->IsSet());
// TODO(plind): Revisit and test this path.
......@@ -715,8 +714,7 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
InstructionOperand* const value_operand = g.UseRegister(value);
if (cont->IsBranch()) {
selector->Emit(opcode, nullptr, value_operand, g.TempImmediate(0),
g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->true_block()), g.Label(cont->false_block()));
} else {
selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand,
g.TempImmediate(0));
......
......@@ -146,9 +146,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count);
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -777,7 +776,7 @@ static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->false_block()));
} else {
DCHECK(cont->IsSet());
selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
......@@ -840,8 +839,7 @@ void EmitWordCompareZero(InstructionSelector* selector, InstructionCode opcode,
InstructionOperand* const value_operand = g.UseRegister(value);
if (cont->IsBranch()) {
selector->Emit(opcode, nullptr, value_operand, g.TempImmediate(0),
g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->true_block()), g.Label(cont->false_block()));
} else {
selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand,
g.TempImmediate(0));
......
......@@ -2389,9 +2389,11 @@ LiveRange* RegisterAllocator::SplitRangeAt(LiveRange* range,
if (pos.Value() <= range->Start().Value()) return range;
// We can't properly connect liveranges if split occured at the end
// of control instruction.
// a block.
DCHECK(pos.IsInstructionStart() ||
!InstructionAt(pos.InstructionIndex())->IsControl());
code()
->GetInstructionBlock(pos.InstructionIndex())
->last_instruction_index() != pos.InstructionIndex());
int vreg = GetVirtualRegister();
if (!AllocationOk()) return nullptr;
......
......@@ -351,9 +351,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count);
Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
outputs, input_count, inputs);
if (cont->IsBranch()) instr->MarkAsControl();
selector->Emit(cont->Encode(opcode), output_count, outputs, input_count,
inputs);
}
......@@ -977,7 +976,7 @@ static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()),
g.Label(cont->false_block()))->MarkAsControl();
g.Label(cont->false_block()));
} else {
DCHECK(cont->IsSet());
selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
......
......@@ -208,7 +208,7 @@ TEST(InstructionIsGapAt) {
R.allocCode();
TestInstr* i0 = TestInstr::New(R.zone(), 100);
TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
TestInstr* g = TestInstr::New(R.zone(), 103);
R.code->StartBlock(b0->GetRpoNumber());
R.code->AddInstruction(i0);
R.code->AddInstruction(g);
......@@ -231,14 +231,14 @@ TEST(InstructionIsGapAt2) {
R.allocCode();
TestInstr* i0 = TestInstr::New(R.zone(), 100);
TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
TestInstr* g = TestInstr::New(R.zone(), 103);
R.code->StartBlock(b0->GetRpoNumber());
R.code->AddInstruction(i0);
R.code->AddInstruction(g);
R.code->EndBlock(b0->GetRpoNumber());
TestInstr* i1 = TestInstr::New(R.zone(), 102);
TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl();
TestInstr* g1 = TestInstr::New(R.zone(), 104);
R.code->StartBlock(b1->GetRpoNumber());
R.code->AddInstruction(i1);
R.code->AddInstruction(g1);
......@@ -259,7 +259,7 @@ TEST(InstructionAddGapMove) {
R.allocCode();
TestInstr* i0 = TestInstr::New(R.zone(), 100);
TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
TestInstr* g = TestInstr::New(R.zone(), 103);
R.code->StartBlock(b0->GetRpoNumber());
R.code->AddInstruction(i0);
R.code->AddInstruction(g);
......
......@@ -32,8 +32,8 @@ class TestCode : public HandleAndZoneScope {
int Jump(int target) {
Start();
InstructionOperand* ops[] = {UseRpo(target)};
sequence_.AddInstruction(Instruction::New(main_zone(), kArchJmp, 0, NULL, 1,
ops, 0, NULL)->MarkAsControl());
sequence_.AddInstruction(
Instruction::New(main_zone(), kArchJmp, 0, NULL, 1, ops, 0, NULL));
int pos = static_cast<int>(sequence_.instructions().size() - 1);
End();
return pos;
......@@ -47,8 +47,8 @@ class TestCode : public HandleAndZoneScope {
InstructionOperand* ops[] = {UseRpo(ttarget), UseRpo(ftarget)};
InstructionCode code = 119 | FlagsModeField::encode(kFlags_branch) |
FlagsConditionField::encode(kEqual);
sequence_.AddInstruction(Instruction::New(main_zone(), code, 0, NULL, 2,
ops, 0, NULL)->MarkAsControl());
sequence_.AddInstruction(
Instruction::New(main_zone(), code, 0, NULL, 2, ops, 0, NULL));
int pos = static_cast<int>(sequence_.instructions().size() - 1);
End();
return pos;
......
......@@ -260,22 +260,20 @@ int InstructionSequenceTest::EmitBranch(TestOperand input_op) {
ConvertInputOp(Imm()), ConvertInputOp(Imm())};
InstructionCode opcode = kArchJmp | FlagsModeField::encode(kFlags_branch) |
FlagsConditionField::encode(kEqual);
auto instruction =
NewInstruction(opcode, 0, nullptr, 4, inputs)->MarkAsControl();
auto instruction = NewInstruction(opcode, 0, nullptr, 4, inputs);
return AddInstruction(NewIndex(), instruction);
}
int InstructionSequenceTest::EmitFallThrough() {
auto instruction = NewInstruction(kArchNop, 0, nullptr)->MarkAsControl();
auto instruction = NewInstruction(kArchNop, 0, nullptr);
return AddInstruction(NewIndex(), instruction);
}
int InstructionSequenceTest::EmitJump() {
InstructionOperand* inputs[1]{ConvertInputOp(Imm())};
auto instruction =
NewInstruction(kArchJmp, 0, nullptr, 1, inputs)->MarkAsControl();
auto instruction = NewInstruction(kArchJmp, 0, nullptr, 1, inputs);
return AddInstruction(NewIndex(), instruction);
}
......
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