[Mesa-dev] [PATCH v2 02/17] swr/rast: add additional jit utility functions
Tim Rowley
timothy.o.rowley at intel.com
Wed Apr 26 18:33:03 UTC 2017
Not used yet.
---
.../drivers/swr/rasterizer/jitter/builder.cpp | 1 +
.../drivers/swr/rasterizer/jitter/builder.h | 1 +
.../drivers/swr/rasterizer/jitter/builder_misc.cpp | 69 +++++++++++++++++++++-
.../drivers/swr/rasterizer/jitter/builder_misc.h | 6 ++
4 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp
index 3b86895..6a33ec2 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 703f332..8210e49 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 09b69c7..fbb4948 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 aea39c5..662574d 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);
--
2.7.4
More information about the mesa-dev
mailing list