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

Reid Spencer reid at x10sys.com
Fri Mar 2 22:18:20 PST 2007



Changes in directory llvm/lib/ExecutionEngine:

ExecutionEngine.cpp updated: 1.107 -> 1.108
---
Log message:

Implement loading and storing of APInt values from memory.


---
Diffs of the changes:  (+16 -8)

 ExecutionEngine.cpp |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)


Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.107 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.108
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.107	Wed Feb 14 20:26:10 2007
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp	Sat Mar  3 00:18:03 2007
@@ -425,7 +425,7 @@
     else if (BitWidth <= 64)
       Result.Int64Val = (uint64_t )cast<ConstantInt>(C)->getZExtValue();
     else
-      assert(0 && "Integers with > 64-bits not implemented");
+      Result.APIntVal = const_cast<APInt*>(&cast<ConstantInt>(C)->getValue());
     break;
   }
 
@@ -481,8 +481,12 @@
         Ptr->Untyped[5] = (unsigned char)(TmpVal.Int64Val >> 40);
         Ptr->Untyped[6] = (unsigned char)(TmpVal.Int64Val >> 48);
         Ptr->Untyped[7] = (unsigned char)(TmpVal.Int64Val >> 56);
-      } else
-        assert(0 && "Integer types > 64 bits not supported");
+      } else {
+        uint64_t *Dest = (uint64_t*)Ptr;
+        const uint64_t *Src = Val.APIntVal->getRawData();
+        for (uint32_t i = 0; i < Val.APIntVal->getNumWords(); ++i)
+          Dest[i] = Src[i];
+      }
       break;
     }
 Store4BytesLittleEndian:
@@ -537,8 +541,12 @@
         Ptr->Untyped[2] = (unsigned char)(TmpVal.Int64Val >> 40);
         Ptr->Untyped[1] = (unsigned char)(TmpVal.Int64Val >> 48);
         Ptr->Untyped[0] = (unsigned char)(TmpVal.Int64Val >> 56);
-      } else
-        assert(0 && "Integer types > 64 bits not supported");
+      } else {
+        uint64_t *Dest = (uint64_t*)Ptr;
+        const uint64_t *Src = Val.APIntVal->getRawData();
+        for (uint32_t i = 0; i < Val.APIntVal->getNumWords(); ++i)
+          Dest[i] = Src[i];
+      }
       break;
     }
     Store4BytesBigEndian:
@@ -597,7 +605,7 @@
                           ((uint64_t)Ptr->Untyped[6] << 48) |
                           ((uint64_t)Ptr->Untyped[7] << 56);
       } else
-        assert(0 && "Integer types > 64 bits not supported");
+        Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
       break;
     }
     Load4BytesLittleEndian:
@@ -628,7 +636,7 @@
   } else {
     switch (Ty->getTypeID()) {
     case Type::IntegerTyID: {
-      unsigned BitWidth = cast<IntegerType>(Ty)->getBitWidth();
+      uint32_t BitWidth = cast<IntegerType>(Ty)->getBitWidth();
       if (BitWidth <= 8)
         Result.Int8Val  = Ptr->Untyped[0];
       else if (BitWidth <= 16) {
@@ -649,7 +657,7 @@
                           ((uint64_t)Ptr->Untyped[1] << 48) |
                           ((uint64_t)Ptr->Untyped[0] << 56);
       } else
-        assert(0 && "Integer types > 64 bits not supported");
+        Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
       break;
     }
     Load4BytesBigEndian:






More information about the llvm-commits mailing list