diff options
author | Dan Gohman <gohman@apple.com> | 2009-02-18 05:45:50 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-02-18 05:45:50 +0000 |
commit | 97357614b5957cc167c261d3be54713802715d9a (patch) | |
tree | 55bb4f2595bc761d36928114f203a2c29526a600 /include/llvm/CodeGen/MachineInstrBuilder.h | |
parent | 865f006bb45a609e1cb6acb653af3fe5442ee4dc (diff) |
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.h | 27 |
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 |