aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/CodeGen/MachineInstr.h4
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h5
-rw-r--r--lib/CodeGen/MachineInstr.cpp12
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAG.cpp11
4 files changed, 22 insertions, 10 deletions
diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h
index 06d8f3acbf..d3769a2651 100644
--- a/include/llvm/CodeGen/MachineInstr.h
+++ b/include/llvm/CodeGen/MachineInstr.h
@@ -413,6 +413,10 @@ public:
Op.offset = 0;
}
+ /// addImplicitDefUseOperands - Add all implicit def and use operands to
+ /// this instruction.
+ void addImplicitDefUseOperands();
+
//===--------------------------------------------------------------------===//
// Accessors used to modify instructions in place.
//
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index 4da557cbb3..a9e7ffd4d5 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -77,6 +77,11 @@ public:
MI->addExternalSymbolOperand(FnName);
return *this;
}
+
+ const MachineInstrBuilder &addImplicitDefsUses() const {
+ MI->addImplicitDefUseOperands();
+ return *this;
+ }
};
/// BuildMI - Builder interface. Specify how to create the initial instruction
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index ba75e73623..65c164a4ee 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -125,6 +125,18 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
}
}
+/// addImplicitDefUseOperands - Add all implicit def and use operands to
+/// this instruction.
+void MachineInstr::addImplicitDefUseOperands() {
+ const TargetInstrDescriptor &TID = TargetInstrDescriptors[Opcode];
+ if (TID.ImplicitDefs)
+ for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs)
+ addRegOperand(*ImpDefs, true, true);
+ if (TID.ImplicitUses)
+ for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses)
+ addRegOperand(*ImpUses, false, true);
+}
+
void MachineInstr::dump() const {
std::cerr << " " << *this;
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index 307b2b9b70..cafe3b6ffe 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -442,16 +442,7 @@ void ScheduleDAG::EmitNode(SDNode *Node,
}
// Emit implicit def / use operands.
- if (II.ImplicitDefs) {
- for (const unsigned *ImplicitDefs = II.ImplicitDefs;
- *ImplicitDefs; ++ImplicitDefs)
- MI->addRegOperand(*ImplicitDefs, true, true);
- }
- if (II.ImplicitUses) {
- for (const unsigned *ImplicitUses = II.ImplicitUses;
- *ImplicitUses; ++ImplicitUses)
- MI->addRegOperand(*ImplicitUses, false, true);
- }
+ MI->addImplicitDefUseOperands();
// Now that we have emitted all operands, emit this instruction itself.
if ((II.Flags & M_USES_CUSTOM_DAG_SCHED_INSERTION) == 0) {