Fold iType into Value::VTy
authorChris Lattner <sabre@nondot.org>
Sun, 27 Jun 2004 18:38:48 +0000 (18:38 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 27 Jun 2004 18:38:48 +0000 (18:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14435 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Instruction.cpp
lib/VMCore/iOperators.cpp

index 5ddf28435406b563a55e6b4ff141d3d44eb40c08..1350f05b9b10f37d44f354b5a36bf093ad39e874 100644 (file)
@@ -25,9 +25,7 @@ void Instruction::init()
 
 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...
@@ -40,9 +38,7 @@ Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
 
 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
@@ -50,6 +46,10 @@ Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
   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);
index afbeb9707cbef5d6180a17055b7e9b3e8583d68e..c33d79739142d5890d20f20f56c2870b9ba5dcdf 100644 (file)
@@ -173,7 +173,8 @@ bool BinaryOperator::swapOperands() {
   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