[llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Jul 11 03:02:01 PDT 2004


Changes in directory llvm/lib/ExecutionEngine:

ExecutionEngine.cpp updated: 1.53 -> 1.54

---
Log message:

Make add constantexprs work with all types, fixing the regressions from last night


---
Diffs of the changes:  (+28 -4)

Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.53 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.54
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.53	Wed Jul  7 16:01:38 2004
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp	Sun Jul 11 03:01:11 2004
@@ -208,14 +208,38 @@
     }
 
     case Instruction::Add:
-      if (CE->getOperand(0)->getType() == Type::LongTy ||
-          CE->getOperand(0)->getType() == Type::ULongTy)
+      switch (CE->getOperand(0)->getType()->getTypeID()) {
+      default: assert(0 && "Bad add type!"); abort();
+      case Type::LongTyID:
+      case Type::ULongTyID:
         Result.LongVal = getConstantValue(CE->getOperand(0)).LongVal +
                          getConstantValue(CE->getOperand(1)).LongVal;
-      else
         break;
+      case Type::IntTyID:
+      case Type::UIntTyID:
+        Result.IntVal = getConstantValue(CE->getOperand(0)).IntVal +
+                        getConstantValue(CE->getOperand(1)).IntVal;
+        break;
+      case Type::ShortTyID:
+      case Type::UShortTyID:
+        Result.ShortVal = getConstantValue(CE->getOperand(0)).ShortVal +
+                          getConstantValue(CE->getOperand(1)).ShortVal;
+        break;
+      case Type::SByteTyID:
+      case Type::UByteTyID:
+        Result.SByteVal = getConstantValue(CE->getOperand(0)).SByteVal +
+                          getConstantValue(CE->getOperand(1)).SByteVal;
+        break;
+      case Type::FloatTyID:
+        Result.FloatVal = getConstantValue(CE->getOperand(0)).FloatVal +
+                          getConstantValue(CE->getOperand(1)).FloatVal;
+        break;
+      case Type::DoubleTyID:
+        Result.DoubleVal = getConstantValue(CE->getOperand(0)).DoubleVal +
+                           getConstantValue(CE->getOperand(1)).DoubleVal;
+        break;
+      }
       return Result;
-
     default:
       break;
     }





More information about the llvm-commits mailing list