diff options
author | Tim Rowley <[email protected]> | 2017-04-11 17:25:11 -0500 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-04-28 19:55:02 -0500 |
commit | 42d804b2a3d72a447f065b57a9f4af24bc7bef6c (patch) | |
tree | 215c6af601c5ec5631e3323ee214bc1125115fea /src/gallium/drivers/swr/rasterizer | |
parent | a373f1f27a82b91d6753c94d23cec2ac9f21f7b3 (diff) |
swr/rast: add additional jit utility functions
Not used yet.
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/rasterizer')
4 files changed, 76 insertions, 1 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp index 3b86895de0b..6a33ec265fc 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp @@ -47,6 +47,7 @@ namespace SwrJit mVoidTy = Type::getVoidTy(pJitMgr->mContext); mFP16Ty = Type::getHalfTy(pJitMgr->mContext); mFP32Ty = Type::getFloatTy(pJitMgr->mContext); + mFP32PtrTy = PointerType::get(mFP32Ty, 0); mDoubleTy = Type::getDoubleTy(pJitMgr->mContext); mInt1Ty = Type::getInt1Ty(pJitMgr->mContext); mInt8Ty = Type::getInt8Ty(pJitMgr->mContext); diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.h b/src/gallium/drivers/swr/rasterizer/jitter/builder.h index 703f332fff4..8210e49b185 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder.h +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.h @@ -56,6 +56,7 @@ namespace SwrJit Type* mIntPtrTy; Type* mFP16Ty; Type* mFP32Ty; + Type* mFP32PtrTy; Type* mDoubleTy; Type* mInt8PtrTy; Type* mInt16PtrTy; diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp index 09b69c726df..fbb49486892 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp @@ -277,6 +277,22 @@ namespace SwrJit return GEPA(ptr, indices); } + Value *Builder::IN_BOUNDS_GEP(Value* ptr, const std::initializer_list<Value*> &indexList) + { + std::vector<Value*> indices; + for (auto i : indexList) + indices.push_back(i); + return IN_BOUNDS_GEP(ptr, indices); + } + + Value *Builder::IN_BOUNDS_GEP(Value* ptr, const std::initializer_list<uint32_t> &indexList) + { + std::vector<Value*> indices; + for (auto i : indexList) + indices.push_back(C(i)); + return IN_BOUNDS_GEP(ptr, indices); + } + LoadInst *Builder::LOAD(Value *basePtr, const std::initializer_list<uint32_t> &indices, const llvm::Twine& name) { std::vector<Value*> valIndices; @@ -1377,7 +1393,17 @@ namespace SwrJit IRB()->SetInsertPoint(&pFunc->getEntryBlock(), pFunc->getEntryBlock().begin()); Value* pAlloca = ALLOCA(pType); - IRB()->restoreIP(saveIP); + if (saveIP.isSet()) IRB()->restoreIP(saveIP); + return pAlloca; + } + + Value* Builder::CreateEntryAlloca(Function* pFunc, Type* pType, Value* pArraySize) + { + auto saveIP = IRB()->saveIP(); + IRB()->SetInsertPoint(&pFunc->getEntryBlock(), + pFunc->getEntryBlock().begin()); + Value* pAlloca = ALLOCA(pType, pArraySize); + if (saveIP.isSet()) IRB()->restoreIP(saveIP); return pAlloca; } @@ -1649,4 +1675,45 @@ namespace SwrJit } } + + uint32_t Builder::GetTypeSize(Type* pType) + { + if (pType->isStructTy()) + { + uint32_t numElems = pType->getStructNumElements(); + Type* pElemTy = pType->getStructElementType(0); + return numElems * GetTypeSize(pElemTy); + } + + if (pType->isArrayTy()) + { + uint32_t numElems = pType->getArrayNumElements(); + Type* pElemTy = pType->getArrayElementType(); + return numElems * GetTypeSize(pElemTy); + } + + if (pType->isIntegerTy()) + { + uint32_t bitSize = pType->getIntegerBitWidth(); + return bitSize / 8; + } + + if (pType->isFloatTy()) + { + return 4; + } + + if (pType->isHalfTy()) + { + return 2; + } + + if (pType->isDoubleTy()) + { + return 8; + } + + SWR_ASSERT(false, "Unimplemented type."); + return 0; + } } diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.h b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.h index aea39c5b777..662574d638f 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.h +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.h @@ -68,6 +68,9 @@ int32_t S_IMMED(Value* i); Value *GEP(Value* ptr, const std::initializer_list<Value*> &indexList); Value *GEP(Value* ptr, const std::initializer_list<uint32_t> &indexList); +Value *IN_BOUNDS_GEP(Value* ptr, const std::initializer_list<Value*> &indexList); +Value *IN_BOUNDS_GEP(Value* ptr, const std::initializer_list<uint32_t> &indexList); + CallInst *CALL(Value *Callee, const std::initializer_list<Value*> &args); CallInst *CALL(Value *Callee) { return CALLA(Callee); } CallInst *CALL(Value *Callee, Value* arg); @@ -159,8 +162,11 @@ void RDTSC_START(Value* pBucketMgr, Value* pId); void RDTSC_STOP(Value* pBucketMgr, Value* pId); Value* CreateEntryAlloca(Function* pFunc, Type* pType); +Value* CreateEntryAlloca(Function* pFunc, Type* pType, Value* pArraySize); // Static stack allocations for scatter operations Value* pScatterStackSrc{ nullptr }; Value* pScatterStackOffsets{ nullptr }; + +uint32_t GetTypeSize(Type* pType); |