summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineInstrBuilder.h
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-02-18 05:45:50 +0000
committerDan Gohman <gohman@apple.com>2009-02-18 05:45:50 +0000
commit97357614b5957cc167c261d3be54713802715d9a (patch)
tree55bb4f2595bc761d36928114f203a2c29526a600 /include/llvm/CodeGen/MachineInstrBuilder.h
parent865f006bb45a609e1cb6acb653af3fe5442ee4dc (diff)
downloadllvm-97357614b5957cc167c261d3be54713802715d9a.tar.gz
llvm-97357614b5957cc167c261d3be54713802715d9a.tar.bz2
llvm-97357614b5957cc167c261d3be54713802715d9a.tar.xz
Factor out the code to add a MachineOperand to a MachineInstrBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64891 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineInstrBuilder.h')
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index d3a45aca52..de27bc74ee 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -38,9 +38,10 @@ public:
const
MachineInstrBuilder &addReg(unsigned RegNo, bool isDef = false,
bool isImp = false, bool isKill = false,
- bool isDead = false, unsigned SubReg = 0) const {
+ bool isDead = false, unsigned SubReg = 0,
+ bool isEarlyClobber = false) const {
MI->addOperand(MachineOperand::CreateReg(RegNo, isDef, isImp, isKill,
- isDead, SubReg));
+ isDead, SubReg, isEarlyClobber));
return *this;
}
@@ -93,6 +94,28 @@ public:
MI->addMemOperand(*MI->getParent()->getParent(), MMO);
return *this;
}
+
+ const MachineInstrBuilder &addOperand(const MachineOperand &MO) const {
+ if (MO.isReg())
+ return addReg(MO.getReg(), MO.isDef(), MO.isImplicit(),
+ MO.isKill(), MO.isDead(), MO.getSubReg(),
+ MO.isEarlyClobber());
+ if (MO.isImm())
+ return addImm(MO.getImm());
+ if (MO.isFI())
+ return addFrameIndex(MO.getIndex());
+ if (MO.isGlobal())
+ return addGlobalAddress(MO.getGlobal(), MO.getOffset());
+ if (MO.isCPI())
+ return addConstantPoolIndex(MO.getIndex(), MO.getOffset());
+ if (MO.isSymbol())
+ return addExternalSymbol(MO.getSymbolName());
+ if (MO.isJTI())
+ return addJumpTableIndex(MO.getIndex());
+
+ assert(0 && "Unknown operand for MachineInstrBuilder::AddOperand!");
+ return *this;
+ }
};
/// BuildMI - Builder interface. Specify how to create the initial instruction