From 47cdb0ac2773c13bcd33388a8e7b351e67efaedf Mon Sep 17 00:00:00 2001 From: Jan Zielinski Date: Tue, 23 Jul 2019 12:18:03 +0200 Subject: [PATCH] swr/rasterizer: small formatting changes Reviewed-by: Alok Hota --- .../drivers/swr/rasterizer/jitter/JitManager.cpp | 19 +++++---- .../drivers/swr/rasterizer/jitter/JitManager.h | 2 + .../drivers/swr/rasterizer/jitter/fetch_jit.cpp | 49 ++++++++++++++++------ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp index a549721..fc8dc46 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp @@ -64,7 +64,7 @@ JitManager::JitManager(uint32_t simdWidth, const char* arch, const char* core) : mArch(arch) { mpCurrentModule = nullptr; - mpExec = nullptr; + mpExec = nullptr; InitializeNativeTarget(); InitializeNativeTargetAsmPrinter(); @@ -452,7 +452,9 @@ std::string JitManager::GetOutputDir() ////////////////////////////////////////////////////////////////////////// /// @brief Dump function to file. -void JitManager::DumpToFile(Module* M, const char* fileName, llvm::AssemblyAnnotationWriter* annotater) +void JitManager::DumpToFile(Module* M, + const char* fileName, + llvm::AssemblyAnnotationWriter* annotater) { if (KNOB_DUMP_SHADER_IR) { @@ -669,7 +671,6 @@ void JitCache::CalcModuleCacheDir() mModuleCacheDir = moduleDir; } - /// notifyObjectCompiled - Provides a pointer to compiled code for Module M. void JitCache::notifyObjectCompiled(const llvm::Module* M, llvm::MemoryBufferRef Obj) { @@ -805,25 +806,25 @@ std::unique_ptr JitCache::getObject(const llvm::Module* M) return pBuf; } -void InterleaveAssemblyAnnotater::emitInstructionAnnot(const llvm::Instruction *pInst, llvm::formatted_raw_ostream &OS) +void InterleaveAssemblyAnnotater::emitInstructionAnnot(const llvm::Instruction* pInst, + llvm::formatted_raw_ostream& OS) { auto dbgLoc = pInst->getDebugLoc(); - if(dbgLoc) + if (dbgLoc) { unsigned int line = dbgLoc.getLine(); - if(line != mCurrentLineNo) + if (line != mCurrentLineNo) { - if(line > 0 && line <= mAssembly.size()) + if (line > 0 && line <= mAssembly.size()) { // HACK: here we assume that OS is a formatted_raw_ostream(ods()) // and modify the color accordingly. We can't do the color // modification on OS because formatted_raw_ostream strips // the color information. The only way to fix this behavior // is to patch LLVM. - OS << "\n; " << line << ": " << mAssembly[line-1] << "\n"; + OS << "\n; " << line << ": " << mAssembly[line - 1] << "\n"; } mCurrentLineNo = line; } } } - diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h index bb7ca8b..d96d22e 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h +++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h @@ -110,6 +110,8 @@ public: /// available. std::unique_ptr getObject(const llvm::Module* M) override; + const char* GetModuleCacheDir() { return mModuleCacheDir.c_str(); } + private: std::string mCpu; llvm::SmallString mCacheDir; diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp index a1bb518..5a09653 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp @@ -202,7 +202,10 @@ Function* FetchJit::Create(const FETCH_COMPILE_STATE& fetchState) break; case R32_UINT: (fetchState.bDisableIndexOOBCheck) - ? vIndices = LOAD(indices, "", PointerType::get(mSimdInt32Ty, 0), JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH) + ? vIndices = LOAD(indices, + "", + PointerType::get(mSimdInt32Ty, 0), + JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH) : vIndices = GetSimdValid32bitIndices(indices, pLastIndex); break; // incoming type is already 32bit int default: @@ -378,7 +381,8 @@ void FetchJit::CreateGatherOddFormats( Value* pGather; if (info.bpp == 32) { - pGather = GATHERDD(VIMMED1(0), xpBase, pOffsets, pMask, 1, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); + pGather = + GATHERDD(VIMMED1(0), xpBase, pOffsets, pMask, 1, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); } else { @@ -399,7 +403,8 @@ void FetchJit::CreateGatherOddFormats( BasicBlock* pCurrentBB = IRB()->GetInsertBlock(); BasicBlock* pMaskedLoadBlock = BasicBlock::Create(JM()->mContext, "MaskedLaneLoad", pCurrentBB->getParent()); - BasicBlock* pEndLoadBB = BasicBlock::Create(JM()->mContext, "AfterMaskedLoad", pCurrentBB->getParent()); + BasicBlock* pEndLoadBB = + BasicBlock::Create(JM()->mContext, "AfterMaskedLoad", pCurrentBB->getParent()); COND_BR(mask, pMaskedLoadBlock, pEndLoadBB); @@ -409,7 +414,7 @@ void FetchJit::CreateGatherOddFormats( { case 8: { - Value* pDst = BITCAST(GEP(pDstMem, C(lane)), PointerType::get(mInt8Ty, 0)); + Value* pDst = BITCAST(GEP(pDstMem, C(lane)), PointerType::get(mInt8Ty, 0)); Value* xpSrc = ADD(xpBase, Z_EXT(index, xpBase->getType())); STORE(LOAD(xpSrc, "", mInt8PtrTy, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH), pDst); break; @@ -417,7 +422,7 @@ void FetchJit::CreateGatherOddFormats( case 16: { - Value* pDst = BITCAST(GEP(pDstMem, C(lane)), PointerType::get(mInt16Ty, 0)); + Value* pDst = BITCAST(GEP(pDstMem, C(lane)), PointerType::get(mInt16Ty, 0)); Value* xpSrc = ADD(xpBase, Z_EXT(index, xpBase->getType())); STORE(LOAD(xpSrc, "", mInt16PtrTy, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH), pDst); break; @@ -427,12 +432,12 @@ void FetchJit::CreateGatherOddFormats( case 24: { // First 16-bits of data - Value* pDst = BITCAST(GEP(pDstMem, C(lane)), PointerType::get(mInt16Ty, 0)); + Value* pDst = BITCAST(GEP(pDstMem, C(lane)), PointerType::get(mInt16Ty, 0)); Value* xpSrc = ADD(xpBase, Z_EXT(index, xpBase->getType())); STORE(LOAD(xpSrc, "", mInt16PtrTy, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH), pDst); // Last 8-bits of data - pDst = BITCAST(GEP(pDst, C(1)), PointerType::get(mInt8Ty, 0)); + pDst = BITCAST(GEP(pDst, C(1)), PointerType::get(mInt8Ty, 0)); xpSrc = ADD(xpSrc, C(2)); STORE(LOAD(xpSrc, "", mInt8PtrTy, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH), pDst); break; @@ -947,8 +952,12 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE& fetchState, // if we have at least one component to fetch if (compMask) { - Value* vGatherResult = GATHERDD( - gatherSrc, pStreamBaseGFX, vOffsets, vGatherMask, 1, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); + Value* vGatherResult = GATHERDD(gatherSrc, + pStreamBaseGFX, + vOffsets, + vGatherMask, + 1, + JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); // e.g. result of an 8x32bit integer gather for 8bit components // 256i - 0 1 2 3 4 5 6 7 // xyzw xyzw xyzw xyzw xyzw xyzw xyzw xyzw @@ -977,7 +986,12 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE& fetchState, // if we have at least one component out of x or y to fetch if (isComponentEnabled(compMask, 0) || isComponentEnabled(compMask, 1)) { - vGatherResult[0] = GATHERDD(gatherSrc, pStreamBaseGFX, vOffsets, vGatherMask, 1, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); + vGatherResult[0] = GATHERDD(gatherSrc, + pStreamBaseGFX, + vOffsets, + vGatherMask, + 1, + JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); // e.g. result of first 8x32bit integer gather for 16bit components // 256i - 0 1 2 3 4 5 6 7 // xyxy xyxy xyxy xyxy xyxy xyxy xyxy xyxy @@ -990,7 +1004,12 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE& fetchState, // offset base to the next components(zw) in the vertex to gather pStreamBaseGFX = ADD(pStreamBaseGFX, C((int64_t)4)); - vGatherResult[1] = GATHERDD(gatherSrc, pStreamBaseGFX, vOffsets, vGatherMask, 1, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); + vGatherResult[1] = GATHERDD(gatherSrc, + pStreamBaseGFX, + vOffsets, + vGatherMask, + 1, + JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); // e.g. result of second 8x32bit integer gather for 16bit components // 256i - 0 1 2 3 4 5 6 7 // zwzw zwzw zwzw zwzw zwzw zwzw zwzw zwzw @@ -1026,8 +1045,12 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE& fetchState, // if we need to gather the component if (compCtrl[i] == StoreSrc) { - Value* pGather = - GATHERDD(gatherSrc, pStreamBaseGFX, vOffsets, vGatherMask, 1, JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); + Value* pGather = GATHERDD(gatherSrc, + pStreamBaseGFX, + vOffsets, + vGatherMask, + 1, + JIT_MEM_CLIENT::GFX_MEM_CLIENT_FETCH); if (conversionType == CONVERT_USCALED) { -- 2.7.4