Added explicit types for llvm::GetElementPtrInst::Create()
This commit is contained in:
25
ctx.cpp
25
ctx.cpp
@@ -1582,7 +1582,12 @@ lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
|
|||||||
sConstant, var_name.c_str());
|
sConstant, var_name.c_str());
|
||||||
llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) };
|
llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) };
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock);
|
return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
return llvm::GetElementPtrInst::Create(PTYPE(sPtr),
|
||||||
|
sPtr, arrayRef, "sptr", bblock);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2346,9 +2351,16 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
|
|||||||
// uniform, so just emit the regular LLVM GEP instruction
|
// uniform, so just emit the regular LLVM GEP instruction
|
||||||
llvm::Value *ind[1] = { index };
|
llvm::Value *ind[1] = { index };
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&ind[0], &ind[1]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&ind[0], &ind[1]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
llvm::Instruction *inst =
|
llvm::Instruction *inst =
|
||||||
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
||||||
name ? name : "gep", bblock);
|
name ? name : "gep", bblock);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
llvm::Instruction *inst =
|
||||||
|
llvm::GetElementPtrInst::Create(PTYPE(basePtr),
|
||||||
|
basePtr, arrayRef,
|
||||||
|
name ? name : "gep", bblock);
|
||||||
|
#endif
|
||||||
AddDebugPos(inst);
|
AddDebugPos(inst);
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
@@ -2406,9 +2418,16 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
|
|||||||
// uniform, so just emit the regular LLVM GEP instruction
|
// uniform, so just emit the regular LLVM GEP instruction
|
||||||
llvm::Value *indices[2] = { index0, index1 };
|
llvm::Value *indices[2] = { index0, index1 };
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
llvm::Instruction *inst =
|
llvm::Instruction *inst =
|
||||||
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
||||||
name ? name : "gep", bblock);
|
name ? name : "gep", bblock);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
llvm::Instruction *inst =
|
||||||
|
llvm::GetElementPtrInst::Create(PTYPE(basePtr),
|
||||||
|
basePtr, arrayRef,
|
||||||
|
name ? name : "gep", bblock);
|
||||||
|
#endif
|
||||||
AddDebugPos(inst);
|
AddDebugPos(inst);
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
@@ -2500,9 +2519,15 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
// If the pointer is uniform, we can use the regular LLVM GEP.
|
// If the pointer is uniform, we can use the regular LLVM GEP.
|
||||||
llvm::Value *offsets[2] = { LLVMInt32(0), LLVMInt32(elementNum) };
|
llvm::Value *offsets[2] = { LLVMInt32(0), LLVMInt32(elementNum) };
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&offsets[0], &offsets[2]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&offsets[0], &offsets[2]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
resultPtr =
|
resultPtr =
|
||||||
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
|
||||||
name ? name : "struct_offset", bblock);
|
name ? name : "struct_offset", bblock);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
resultPtr =
|
||||||
|
llvm::GetElementPtrInst::Create(PTYPE(basePtr), basePtr, arrayRef,
|
||||||
|
name ? name : "struct_offset", bblock);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Otherwise do the math to find the offset and add it to the given
|
// Otherwise do the math to find the offset and add it to the given
|
||||||
|
|||||||
16
ispc.cpp
16
ispc.cpp
@@ -1191,10 +1191,16 @@ Target::SizeOf(llvm::Type *type,
|
|||||||
llvm::PointerType *ptrType = llvm::PointerType::get(type, 0);
|
llvm::PointerType *ptrType = llvm::PointerType::get(type, 0);
|
||||||
llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType);
|
llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType);
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
llvm::Instruction *gep =
|
llvm::Instruction *gep =
|
||||||
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep",
|
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep",
|
||||||
insertAtEnd);
|
insertAtEnd);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
llvm::Instruction *gep =
|
||||||
|
llvm::GetElementPtrInst::Create(PTYPE(voidPtr), voidPtr,
|
||||||
|
arrayRef, "sizeof_gep",
|
||||||
|
insertAtEnd);
|
||||||
|
#endif
|
||||||
if (m_is32Bit || g->opt.force32BitAddressing)
|
if (m_is32Bit || g->opt.force32BitAddressing)
|
||||||
return new llvm::PtrToIntInst(gep, LLVMTypes::Int32Type,
|
return new llvm::PtrToIntInst(gep, LLVMTypes::Int32Type,
|
||||||
"sizeof_int", insertAtEnd);
|
"sizeof_int", insertAtEnd);
|
||||||
@@ -1223,10 +1229,16 @@ Target::StructOffset(llvm::Type *type, int element,
|
|||||||
llvm::PointerType *ptrType = llvm::PointerType::get(type, 0);
|
llvm::PointerType *ptrType = llvm::PointerType::get(type, 0);
|
||||||
llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType);
|
llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType);
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
llvm::Instruction *gep =
|
llvm::Instruction *gep =
|
||||||
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep",
|
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep",
|
||||||
insertAtEnd);
|
insertAtEnd);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
llvm::Instruction *gep =
|
||||||
|
llvm::GetElementPtrInst::Create(PTYPE(voidPtr), voidPtr,
|
||||||
|
arrayRef, "offset_gep",
|
||||||
|
insertAtEnd);
|
||||||
|
#endif
|
||||||
if (m_is32Bit || g->opt.force32BitAddressing)
|
if (m_is32Bit || g->opt.force32BitAddressing)
|
||||||
return new llvm::PtrToIntInst(gep, LLVMTypes::Int32Type,
|
return new llvm::PtrToIntInst(gep, LLVMTypes::Int32Type,
|
||||||
"offset_int", insertAtEnd);
|
"offset_int", insertAtEnd);
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#include <llvm/IR/Constants.h>
|
#include <llvm/IR/Constants.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PTYPE(p) (llvm::cast<llvm::SequentialType>((p)->getType()->getScalarType())->getElementType())
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class PHINode;
|
class PHINode;
|
||||||
class InsertElementInst;
|
class InsertElementInst;
|
||||||
|
|||||||
5
opt.cpp
5
opt.cpp
@@ -330,8 +330,13 @@ lGEPInst(llvm::Value *ptr, llvm::Value *offset, const char *name,
|
|||||||
llvm::Instruction *insertBefore) {
|
llvm::Instruction *insertBefore) {
|
||||||
llvm::Value *index[1] = { offset };
|
llvm::Value *index[1] = { offset };
|
||||||
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
|
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
|
||||||
|
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||||
return llvm::GetElementPtrInst::Create(ptr, arrayRef, name,
|
return llvm::GetElementPtrInst::Create(ptr, arrayRef, name,
|
||||||
insertBefore);
|
insertBefore);
|
||||||
|
#else // LLVM 3.7++
|
||||||
|
return llvm::GetElementPtrInst::Create(PTYPE(ptr), ptr, arrayRef,
|
||||||
|
name, insertBefore);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user