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