Changes from review:
- Move DisableScheduling flag into TargetOption.h
- Move SDNodeOrdering into its own header file. Give it a minimal interface that
doesn't conflate construction with storage.
- Move assigning the ordering into the SelectionDAGBuilder.
This isn't used yet, so there should be no functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91727 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 0775485..be0d6af 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -583,8 +583,10 @@
}
void SelectionDAGBuilder::visit(unsigned Opcode, User &I) {
- // Tell the DAG that we're processing a new instruction.
- DAG.NewInst();
+ // We're processing a new instruction.
+ ++SDNodeOrder;
+
+ SDNode *PrevNode = DAG.getRoot().getNode();
// Note: this doesn't use InstVisitor, because it has to work with
// ConstantExpr's in addition to instructions.
@@ -592,9 +594,12 @@
default: llvm_unreachable("Unknown instruction type encountered!");
// Build the switch statement using the Instruction.def file.
#define HANDLE_INST(NUM, OPCODE, CLASS) \
- case Instruction::OPCODE:return visit##OPCODE((CLASS&)I);
+ case Instruction::OPCODE: visit##OPCODE((CLASS&)I); break;
#include "llvm/Instruction.def"
}
+
+ if (DisableScheduling && DAG.getRoot().getNode() != PrevNode)
+ DAG.AssignOrdering(DAG.getRoot().getNode(), SDNodeOrder);
}
SDValue SelectionDAGBuilder::getValue(const Value *V) {