aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine/JIT
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-12 07:05:14 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-12 07:05:14 +0000
commita54b7cbd452b3adb2f51346140d996b29c2cdb30 (patch)
tree00514e24a3fab3804f1a99557ebd343382d0dc27 /lib/ExecutionEngine/JIT
parented3098989580ecaee7fc89de548afb4c811bea31 (diff)
downloadexternal_llvm-a54b7cbd452b3adb2f51346140d996b29c2cdb30.zip
external_llvm-a54b7cbd452b3adb2f51346140d996b29c2cdb30.tar.gz
external_llvm-a54b7cbd452b3adb2f51346140d996b29c2cdb30.tar.bz2
For PR1064:
Implement the arbitrary bit-width integer feature. The feature allows integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 16, 32, and 64 bit integers. This change does several things: 1. Introduces a new Derived Type, IntegerType, to represent the number of bits in an integer. The Type classes SubclassData field is used to store the number of bits. This allows 2^23 bits in an integer type. 2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and 64-bit integers. These are replaced with just IntegerType which is not a primitive any more. 3. Adjust the rest of LLVM to account for this change. Note that while this incremental change lays the foundation for arbitrary bit-width integers, LLVM has not yet been converted to actually deal with them in any significant way. Most optimization passes, for example, will still only deal with the byte-width integer types. Future increments will rectify this situation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33113 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT')
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 13ee719..7fd62cc 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -142,22 +142,25 @@ GenericValue JIT::runFunction(Function *F,
GenericValue rv;
switch (RetTy->getTypeID()) {
default: assert(0 && "Unknown return type for function call!");
- case Type::Int1TyID:
- rv.Int1Val = ((bool(*)())(intptr_t)FPtr)();
- return rv;
- case Type::Int8TyID:
- rv.Int8Val = ((char(*)())(intptr_t)FPtr)();
- return rv;
- case Type::Int16TyID:
- rv.Int16Val = ((short(*)())(intptr_t)FPtr)();
+ case Type::IntegerTyID: {
+ unsigned BitWidth = cast<IntegerType>(RetTy)->getBitWidth();
+ if (BitWidth == 1)
+ rv.Int1Val = ((bool(*)())(intptr_t)FPtr)();
+ else if (BitWidth <= 8)
+ rv.Int8Val = ((char(*)())(intptr_t)FPtr)();
+ else if (BitWidth <= 16)
+ rv.Int16Val = ((short(*)())(intptr_t)FPtr)();
+ else if (BitWidth <= 32)
+ rv.Int32Val = ((int(*)())(intptr_t)FPtr)();
+ else if (BitWidth <= 64)
+ rv.Int64Val = ((int64_t(*)())(intptr_t)FPtr)();
+ else
+ assert(0 && "Integer types > 64 bits not supported");
return rv;
+ }
case Type::VoidTyID:
- case Type::Int32TyID:
rv.Int32Val = ((int(*)())(intptr_t)FPtr)();
return rv;
- case Type::Int64TyID:
- rv.Int64Val = ((int64_t(*)())(intptr_t)FPtr)();
- return rv;
case Type::FloatTyID:
rv.FloatVal = ((float(*)())(intptr_t)FPtr)();
return rv;
@@ -191,11 +194,22 @@ GenericValue JIT::runFunction(Function *F,
const GenericValue &AV = ArgValues[i];
switch (ArgTy->getTypeID()) {
default: assert(0 && "Unknown argument type for function call!");
- case Type::Int1TyID: C = ConstantInt::get(ArgTy, AV.Int1Val); break;
- case Type::Int8TyID: C = ConstantInt::get(ArgTy, AV.Int8Val); break;
- case Type::Int16TyID: C = ConstantInt::get(ArgTy, AV.Int16Val); break;
- case Type::Int32TyID: C = ConstantInt::get(ArgTy, AV.Int32Val); break;
- case Type::Int64TyID: C = ConstantInt::get(ArgTy, AV.Int64Val); break;
+ case Type::IntegerTyID: {
+ unsigned BitWidth = cast<IntegerType>(ArgTy)->getBitWidth();
+ if (BitWidth == 1)
+ C = ConstantInt::get(ArgTy, AV.Int1Val);
+ else if (BitWidth <= 8)
+ C = ConstantInt::get(ArgTy, AV.Int8Val);
+ else if (BitWidth <= 16)
+ C = ConstantInt::get(ArgTy, AV.Int16Val);
+ else if (BitWidth <= 32)
+ C = ConstantInt::get(ArgTy, AV.Int32Val);
+ else if (BitWidth <= 64)
+ C = ConstantInt::get(ArgTy, AV.Int64Val);
+ else
+ assert(0 && "Integer types > 64 bits not supported");
+ break;
+ }
case Type::FloatTyID: C = ConstantFP ::get(ArgTy, AV.FloatVal); break;
case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, AV.DoubleVal); break;
case Type::PointerTyID: