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

Chris Lattner lattner at cs.uiuc.edu
Tue Mar 16 02:40:01 PST 2004


Changes in directory llvm/lib/ExecutionEngine:

ExecutionEngine.cpp updated: 1.48 -> 1.49

---
Log message:

Fix PR296: http://llvm.cs.uiuc.edu/PR296 : [execution engines] Unhandled cast constant expression


---
Diffs of the changes:  (+17 -6)

Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.48 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.49
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.48	Sat Feb 14 23:54:06 2004
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp	Tue Mar 16 02:38:56 2004
@@ -179,19 +179,30 @@
       // automatically fold, just the ones involving pointers won't.
       //
       Constant *Op = CE->getOperand(0);
+      GenericValue GV = getConstantValue(Op);
 
       // Handle cast of pointer to pointer...
       if (Op->getType()->getPrimitiveID() == C->getType()->getPrimitiveID())
-        return getConstantValue(Op);
+        return GV;
 
       // Handle a cast of pointer to any integral type...
       if (isa<PointerType>(Op->getType()) && C->getType()->isIntegral())
-        return getConstantValue(Op);
+        return GV;
         
-      // Handle cast of long to pointer...
-      if (isa<PointerType>(C->getType()) && (Op->getType() == Type::LongTy ||
-                                             Op->getType() == Type::ULongTy))
-        return getConstantValue(Op);
+      // Handle cast of integer to a pointer...
+      if (isa<PointerType>(C->getType()) && Op->getType()->isIntegral())
+        switch (Op->getType()->getPrimitiveID()) {
+        case Type::BoolTyID:    return PTOGV((void*)(uintptr_t)GV.BoolVal);
+        case Type::SByteTyID:   return PTOGV((void*)( intptr_t)GV.SByteVal);
+        case Type::UByteTyID:   return PTOGV((void*)(uintptr_t)GV.UByteVal);
+        case Type::ShortTyID:   return PTOGV((void*)( intptr_t)GV.ShortVal);
+        case Type::UShortTyID:  return PTOGV((void*)(uintptr_t)GV.UShortVal);
+        case Type::IntTyID:     return PTOGV((void*)( intptr_t)GV.IntVal);
+        case Type::UIntTyID:    return PTOGV((void*)(uintptr_t)GV.UIntVal);
+        case Type::LongTyID:    return PTOGV((void*)( intptr_t)GV.LongVal);
+        case Type::ULongTyID:   return PTOGV((void*)(uintptr_t)GV.ULongVal);
+        default: assert(0 && "Unknown integral type!");
+        }
       break;
     }
 





More information about the llvm-commits mailing list