ad MachineInstrBuilder support for target flags on operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-06-25 01:16:22 +00:00
parent 4b950ec072
commit 9a96c425db
2 changed files with 38 additions and 19 deletions

View File

@ -74,8 +74,9 @@ public:
return *this;
}
const MachineInstrBuilder &addMBB(MachineBasicBlock *MBB) const {
MI->addOperand(MachineOperand::CreateMBB(MBB));
const MachineInstrBuilder &addMBB(MachineBasicBlock *MBB,
unsigned char TargetFlags = 0) const {
MI->addOperand(MachineOperand::CreateMBB(MBB, TargetFlags));
return *this;
}
@ -85,25 +86,29 @@ public:
}
const MachineInstrBuilder &addConstantPoolIndex(unsigned Idx,
int Offset = 0) const {
MI->addOperand(MachineOperand::CreateCPI(Idx, Offset));
int Offset = 0,
unsigned char TargetFlags = 0) const {
MI->addOperand(MachineOperand::CreateCPI(Idx, Offset, TargetFlags));
return *this;
}
const MachineInstrBuilder &addJumpTableIndex(unsigned Idx) const {
MI->addOperand(MachineOperand::CreateJTI(Idx));
const MachineInstrBuilder &addJumpTableIndex(unsigned Idx,
unsigned char TargetFlags = 0) const {
MI->addOperand(MachineOperand::CreateJTI(Idx, TargetFlags));
return *this;
}
const MachineInstrBuilder &addGlobalAddress(GlobalValue *GV,
int64_t Offset = 0) const {
MI->addOperand(MachineOperand::CreateGA(GV, Offset));
int64_t Offset = 0,
unsigned char TargetFlags = 0) const {
MI->addOperand(MachineOperand::CreateGA(GV, Offset, TargetFlags));
return *this;
}
const MachineInstrBuilder &addExternalSymbol(const char *FnName,
int64_t Offset = 0) const {
MI->addOperand(MachineOperand::CreateES(FnName, Offset));
int64_t Offset = 0,
unsigned char TargetFlags = 0) const {
MI->addOperand(MachineOperand::CreateES(FnName, Offset, TargetFlags));
return *this;
}
@ -126,13 +131,17 @@ public:
if (MO.isFI())
return addFrameIndex(MO.getIndex());
if (MO.isGlobal())
return addGlobalAddress(MO.getGlobal(), MO.getOffset());
return addGlobalAddress(MO.getGlobal(), MO.getOffset(),
MO.getTargetFlags());
if (MO.isCPI())
return addConstantPoolIndex(MO.getIndex(), MO.getOffset());
return addConstantPoolIndex(MO.getIndex(), MO.getOffset(),
MO.getTargetFlags());
if (MO.isSymbol())
return addExternalSymbol(MO.getSymbolName());
return addExternalSymbol(MO.getSymbolName(), MO.getOffset(),
MO.getTargetFlags());
if (MO.isJTI())
return addJumpTableIndex(MO.getIndex());
return addJumpTableIndex(MO.getIndex(),
MO.getTargetFlags());
assert(0 && "Unknown operand for MachineInstrBuilder::AddOperand!");
return *this;

View File

@ -371,9 +371,11 @@ public:
Op.SubReg = SubReg;
return Op;
}
static MachineOperand CreateMBB(MachineBasicBlock *MBB) {
static MachineOperand CreateMBB(MachineBasicBlock *MBB,
unsigned char TargetFlags = 0) {
MachineOperand Op(MachineOperand::MO_MachineBasicBlock);
Op.setMBB(MBB);
Op.setTargetFlags(TargetFlags);
return Op;
}
static MachineOperand CreateFI(unsigned Idx) {
@ -381,27 +383,35 @@ public:
Op.setIndex(Idx);
return Op;
}
static MachineOperand CreateCPI(unsigned Idx, int Offset) {
static MachineOperand CreateCPI(unsigned Idx, int Offset,
unsigned char TargetFlags = 0) {
MachineOperand Op(MachineOperand::MO_ConstantPoolIndex);
Op.setIndex(Idx);
Op.setOffset(Offset);
Op.setTargetFlags(TargetFlags);
return Op;
}
static MachineOperand CreateJTI(unsigned Idx) {
static MachineOperand CreateJTI(unsigned Idx,
unsigned char TargetFlags = 0) {
MachineOperand Op(MachineOperand::MO_JumpTableIndex);
Op.setIndex(Idx);
Op.setTargetFlags(TargetFlags);
return Op;
}
static MachineOperand CreateGA(GlobalValue *GV, int64_t Offset) {
static MachineOperand CreateGA(GlobalValue *GV, int64_t Offset,
unsigned char TargetFlags = 0) {
MachineOperand Op(MachineOperand::MO_GlobalAddress);
Op.Contents.OffsetedInfo.Val.GV = GV;
Op.setOffset(Offset);
Op.setTargetFlags(TargetFlags);
return Op;
}
static MachineOperand CreateES(const char *SymName, int64_t Offset = 0) {
static MachineOperand CreateES(const char *SymName, int64_t Offset = 0,
unsigned char TargetFlags = 0) {
MachineOperand Op(MachineOperand::MO_ExternalSymbol);
Op.Contents.OffsetedInfo.Val.SymbolName = SymName;
Op.setOffset(Offset);
Op.setTargetFlags(TargetFlags);
return Op;
}
const MachineOperand &operator=(const MachineOperand &MO) {