Commit 65ba1cde authored by baptiste.afsa's avatar baptiste.afsa Committed by Commit bot

[turbofan] Allow tests to enable/disable instruction scheduling.

Some instruction selection tests rely on the instructions to be emitted
in a specific order.

R=jarin@chromium.org, bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/2276003002
Cr-Commit-Position: refs/heads/master@{#38886}
parent 4671660f
...@@ -22,7 +22,8 @@ InstructionSelector::InstructionSelector( ...@@ -22,7 +22,8 @@ InstructionSelector::InstructionSelector(
Zone* zone, size_t node_count, Linkage* linkage, Zone* zone, size_t node_count, Linkage* linkage,
InstructionSequence* sequence, Schedule* schedule, InstructionSequence* sequence, Schedule* schedule,
SourcePositionTable* source_positions, Frame* frame, SourcePositionTable* source_positions, Frame* frame,
SourcePositionMode source_position_mode, Features features) SourcePositionMode source_position_mode, Features features,
EnableScheduling enable_scheduling)
: zone_(zone), : zone_(zone),
linkage_(linkage), linkage_(linkage),
sequence_(sequence), sequence_(sequence),
...@@ -38,6 +39,7 @@ InstructionSelector::InstructionSelector( ...@@ -38,6 +39,7 @@ InstructionSelector::InstructionSelector(
virtual_registers_(node_count, virtual_registers_(node_count,
InstructionOperand::kInvalidVirtualRegister, zone), InstructionOperand::kInvalidVirtualRegister, zone),
scheduler_(nullptr), scheduler_(nullptr),
enable_scheduling_(enable_scheduling),
frame_(frame) { frame_(frame) {
instructions_.reserve(node_count); instructions_.reserve(node_count);
} }
...@@ -65,8 +67,7 @@ void InstructionSelector::SelectInstructions() { ...@@ -65,8 +67,7 @@ void InstructionSelector::SelectInstructions() {
} }
// Schedule the selected instructions. // Schedule the selected instructions.
if (FLAG_turbo_instruction_scheduling && if (UseInstructionScheduling()) {
InstructionScheduler::SchedulerSupported()) {
scheduler_ = new (zone()) InstructionScheduler(zone(), sequence()); scheduler_ = new (zone()) InstructionScheduler(zone(), sequence());
} }
...@@ -88,8 +89,7 @@ void InstructionSelector::SelectInstructions() { ...@@ -88,8 +89,7 @@ void InstructionSelector::SelectInstructions() {
} }
void InstructionSelector::StartBlock(RpoNumber rpo) { void InstructionSelector::StartBlock(RpoNumber rpo) {
if (FLAG_turbo_instruction_scheduling && if (UseInstructionScheduling()) {
InstructionScheduler::SchedulerSupported()) {
DCHECK_NOT_NULL(scheduler_); DCHECK_NOT_NULL(scheduler_);
scheduler_->StartBlock(rpo); scheduler_->StartBlock(rpo);
} else { } else {
...@@ -99,8 +99,7 @@ void InstructionSelector::StartBlock(RpoNumber rpo) { ...@@ -99,8 +99,7 @@ void InstructionSelector::StartBlock(RpoNumber rpo) {
void InstructionSelector::EndBlock(RpoNumber rpo) { void InstructionSelector::EndBlock(RpoNumber rpo) {
if (FLAG_turbo_instruction_scheduling && if (UseInstructionScheduling()) {
InstructionScheduler::SchedulerSupported()) {
DCHECK_NOT_NULL(scheduler_); DCHECK_NOT_NULL(scheduler_);
scheduler_->EndBlock(rpo); scheduler_->EndBlock(rpo);
} else { } else {
...@@ -110,8 +109,7 @@ void InstructionSelector::EndBlock(RpoNumber rpo) { ...@@ -110,8 +109,7 @@ void InstructionSelector::EndBlock(RpoNumber rpo) {
void InstructionSelector::AddInstruction(Instruction* instr) { void InstructionSelector::AddInstruction(Instruction* instr) {
if (FLAG_turbo_instruction_scheduling && if (UseInstructionScheduling()) {
InstructionScheduler::SchedulerSupported()) {
DCHECK_NOT_NULL(scheduler_); DCHECK_NOT_NULL(scheduler_);
scheduler_->AddInstruction(instr); scheduler_->AddInstruction(instr);
} else { } else {
......
...@@ -48,13 +48,17 @@ class InstructionSelector final { ...@@ -48,13 +48,17 @@ class InstructionSelector final {
class Features; class Features;
enum SourcePositionMode { kCallSourcePositions, kAllSourcePositions }; enum SourcePositionMode { kCallSourcePositions, kAllSourcePositions };
enum EnableScheduling { kDisableScheduling, kEnableScheduling };
InstructionSelector( InstructionSelector(
Zone* zone, size_t node_count, Linkage* linkage, Zone* zone, size_t node_count, Linkage* linkage,
InstructionSequence* sequence, Schedule* schedule, InstructionSequence* sequence, Schedule* schedule,
SourcePositionTable* source_positions, Frame* frame, SourcePositionTable* source_positions, Frame* frame,
SourcePositionMode source_position_mode = kCallSourcePositions, SourcePositionMode source_position_mode = kCallSourcePositions,
Features features = SupportedFeatures()); Features features = SupportedFeatures(),
EnableScheduling enable_scheduling = FLAG_turbo_instruction_scheduling
? kEnableScheduling
: kDisableScheduling);
// Visit code for the entire graph with the included schedule. // Visit code for the entire graph with the included schedule.
void SelectInstructions(); void SelectInstructions();
...@@ -199,6 +203,11 @@ class InstructionSelector final { ...@@ -199,6 +203,11 @@ class InstructionSelector final {
private: private:
friend class OperandGenerator; friend class OperandGenerator;
bool UseInstructionScheduling() const {
return (enable_scheduling_ == kEnableScheduling) &&
InstructionScheduler::SchedulerSupported();
}
void EmitTableSwitch(const SwitchInfo& sw, InstructionOperand& index_operand); void EmitTableSwitch(const SwitchInfo& sw, InstructionOperand& index_operand);
void EmitLookupSwitch(const SwitchInfo& sw, void EmitLookupSwitch(const SwitchInfo& sw,
InstructionOperand& value_operand); InstructionOperand& value_operand);
...@@ -333,6 +342,7 @@ class InstructionSelector final { ...@@ -333,6 +342,7 @@ class InstructionSelector final {
IntVector effect_level_; IntVector effect_level_;
IntVector virtual_registers_; IntVector virtual_registers_;
InstructionScheduler* scheduler_; InstructionScheduler* scheduler_;
EnableScheduling enable_scheduling_;
Frame* frame_; Frame* frame_;
}; };
......
...@@ -41,7 +41,8 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( ...@@ -41,7 +41,8 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
SourcePositionTable source_position_table(graph()); SourcePositionTable source_position_table(graph());
InstructionSelector selector(test_->zone(), node_count, &linkage, &sequence, InstructionSelector selector(test_->zone(), node_count, &linkage, &sequence,
schedule, &source_position_table, nullptr, schedule, &source_position_table, nullptr,
source_position_mode, features); source_position_mode, features,
InstructionSelector::kDisableScheduling);
selector.SelectInstructions(); selector.SelectInstructions();
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
OFStream out(stdout); OFStream out(stdout);
......
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