Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
Instruction *InsertBefore)
- : User(ty, Value::InstructionVal, Name),
- Parent(0),
- iType(it) {
+ : User(ty, Value::InstructionVal + it, Name), Parent(0) {
init();
// If requested, insert this instruction into a basic block...
Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
BasicBlock *InsertAtEnd)
- : User(ty, Value::InstructionVal, Name),
- Parent(0),
- iType(it) {
+ : User(ty, Value::InstructionVal + it, Name), Parent(0) {
init();
// append this instruction into the basic block
InsertAtEnd->getInstList().push_back(this);
}
+void Instruction::setOpcode(unsigned opc) {
+ setValueType(Value::InstructionVal + opc);
+}
+
void Instruction::setParent(BasicBlock *P) {
if (getParent()) {
if (!P) LeakDetector::addGarbageObject(this);
if (isCommutative())
; // If the instruction is commutative, it is safe to swap the operands
else if (SetCondInst *SCI = dyn_cast<SetCondInst>(this))
- iType = SCI->getSwappedCondition();
+ /// FIXME: SetCC instructions shouldn't all have different opcodes.
+ setOpcode(SCI->getSwappedCondition());
else
return true; // Can't commute operands