Improvements to the routine that maps from LLVM types to ispc types.
This commit is contained in:
21
builtins.cpp
21
builtins.cpp
@@ -99,11 +99,17 @@ lLLVMTypeToISPCType(const llvm::Type *t, bool intAsUnsigned) {
|
|||||||
else if (t == LLVMTypes::Int32PointerType)
|
else if (t == LLVMTypes::Int32PointerType)
|
||||||
return new ReferenceType(intAsUnsigned ? AtomicType::UniformUInt32 :
|
return new ReferenceType(intAsUnsigned ? AtomicType::UniformUInt32 :
|
||||||
AtomicType::UniformInt32, false);
|
AtomicType::UniformInt32, false);
|
||||||
|
else if (t == LLVMTypes::Int64PointerType)
|
||||||
|
return new ReferenceType(intAsUnsigned ? AtomicType::UniformUInt64 :
|
||||||
|
AtomicType::UniformInt64, false);
|
||||||
else if (t == LLVMTypes::FloatPointerType)
|
else if (t == LLVMTypes::FloatPointerType)
|
||||||
return new ReferenceType(AtomicType::UniformFloat, false);
|
return new ReferenceType(AtomicType::UniformFloat, false);
|
||||||
else if (t == LLVMTypes::Int32VectorPointerType)
|
else if (t == LLVMTypes::Int32VectorPointerType)
|
||||||
return new ReferenceType(intAsUnsigned ? AtomicType::VaryingUInt32 :
|
return new ReferenceType(intAsUnsigned ? AtomicType::VaryingUInt32 :
|
||||||
AtomicType::VaryingInt32, false);
|
AtomicType::VaryingInt32, false);
|
||||||
|
else if (t == LLVMTypes::Int64VectorPointerType)
|
||||||
|
return new ReferenceType(intAsUnsigned ? AtomicType::VaryingUInt64 :
|
||||||
|
AtomicType::VaryingInt64, false);
|
||||||
else if (t == LLVMTypes::FloatVectorPointerType)
|
else if (t == LLVMTypes::FloatVectorPointerType)
|
||||||
return new ReferenceType(AtomicType::VaryingFloat, false);
|
return new ReferenceType(AtomicType::VaryingFloat, false);
|
||||||
else if (llvm::isa<const llvm::PointerType>(t)) {
|
else if (llvm::isa<const llvm::PointerType>(t)) {
|
||||||
@@ -113,16 +119,15 @@ lLLVMTypeToISPCType(const llvm::Type *t, bool intAsUnsigned) {
|
|||||||
// create the equivalent ispc type. Note that it has to be a
|
// create the equivalent ispc type. Note that it has to be a
|
||||||
// reference to an array, since ispc passes arrays to functions by
|
// reference to an array, since ispc passes arrays to functions by
|
||||||
// reference.
|
// reference.
|
||||||
//
|
|
||||||
// FIXME: generalize this to do more than uniform int32s (that's
|
|
||||||
// all that's necessary for the stdlib currently.)
|
|
||||||
const llvm::ArrayType *at =
|
const llvm::ArrayType *at =
|
||||||
llvm::dyn_cast<const llvm::ArrayType>(pt->getElementType());
|
llvm::dyn_cast<const llvm::ArrayType>(pt->getElementType());
|
||||||
if (at && at->getNumElements() == 0 &&
|
if (at != NULL) {
|
||||||
at->getElementType() == LLVMTypes::Int32Type) {
|
const Type *eltType = lLLVMTypeToISPCType(at->getElementType(),
|
||||||
const Type *eltType = intAsUnsigned ? AtomicType::UniformUInt32 :
|
intAsUnsigned);
|
||||||
AtomicType::UniformInt32;
|
if (eltType == NULL)
|
||||||
return new ReferenceType(new ArrayType(eltType, 0), false);
|
return NULL;
|
||||||
|
return new ReferenceType(new ArrayType(eltType, at->getNumElements()),
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user