Changes in directory llvm/lib/ExecutionEngine/JIT:
JIT.cpp updated: 1.88 -> 1.89 --- Log message: For PR1064: http://llvm.org/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. --- Diffs of the changes: (+31 -17) JIT.cpp | 48 +++++++++++++++++++++++++++++++----------------- 1 files changed, 31 insertions(+), 17 deletions(-) Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.88 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.89 --- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.88 Thu Jan 11 22:24:45 2007 +++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Fri Jan 12 01:05:13 2007 @@ -142,22 +142,25 @@ 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 @@ 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: _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits