Implicit = 0x4,
Kill = 0x8,
Dead = 0x10,
- EarlyClobber = 0x20,
+ Undef = 0x20,
+ EarlyClobber = 0x40,
ImplicitDefine = Implicit | Define,
ImplicitKill = Implicit | Kill
};
class MachineInstrBuilder {
MachineInstr *MI;
public:
+ MachineInstrBuilder() : MI(0) {}
explicit MachineInstrBuilder(MachineInstr *mi) : MI(mi) {}
/// Allow automatic conversion to the machine instruction we are working on.
flags & RegState::Implicit,
flags & RegState::Kill,
flags & RegState::Dead,
- SubReg,
- flags & RegState::EarlyClobber));
+ flags & RegState::Undef,
+ flags & RegState::EarlyClobber,
+ SubReg));
return *this;
}
return *this;
}
+ const MachineInstrBuilder &addMetadata(MDNode *N,
+ int64_t Offset = 0,
+ unsigned char TargetFlags = 0) const {
+ MI->addOperand(MachineOperand::CreateMDNode(N, Offset, TargetFlags));
+ return *this;
+ }
+
const MachineInstrBuilder &addExternalSymbol(const char *FnName,
- int64_t Offset = 0,
unsigned char TargetFlags = 0) const {
- MI->addOperand(MachineOperand::CreateES(FnName, Offset, TargetFlags));
+ MI->addOperand(MachineOperand::CreateES(FnName, TargetFlags));
return *this;
}
}
const MachineInstrBuilder &addOperand(const MachineOperand &MO) const {
- if (MO.isReg())
- return addReg(MO.getReg(),
- (MO.isDef() ? RegState::Define : 0) |
- (MO.isImplicit() ? RegState::Implicit : 0) |
- (MO.isKill() ? RegState::Kill : 0) |
- (MO.isDead() ? RegState::Dead : 0) |
- (MO.isEarlyClobber() ? RegState::EarlyClobber : 0),
- MO.getSubReg());
- if (MO.isImm())
- return addImm(MO.getImm());
- if (MO.isFI())
- return addFrameIndex(MO.getIndex());
- if (MO.isGlobal())
- return addGlobalAddress(MO.getGlobal(), MO.getOffset(),
- MO.getTargetFlags());
- if (MO.isCPI())
- return addConstantPoolIndex(MO.getIndex(), MO.getOffset(),
- MO.getTargetFlags());
- if (MO.isSymbol())
- return addExternalSymbol(MO.getSymbolName(), MO.getOffset(),
- MO.getTargetFlags());
- if (MO.isJTI())
- return addJumpTableIndex(MO.getIndex(),
- MO.getTargetFlags());
-
- assert(0 && "Unknown operand for MachineInstrBuilder::AddOperand!");
+ MI->addOperand(MO);
return *this;
}
};
inline unsigned getDeadRegState(bool B) {
return B ? RegState::Dead : 0;
}
+inline unsigned getUndefRegState(bool B) {
+ return B ? RegState::Undef : 0;
+}
} // End llvm namespace