@@ -21700,10 +21700,30 @@ void EmitPass::emitsrnd(llvm::GenIntrinsicInst* GII)
2170021700 }
2170121701}
2170221702
21703- static LSC_CACHE_OPTS translateLSCCacheControlsEnum(
21704- LSC_L1_L3_CC l1l3cc, bool isLoad
21705- )
21703+ bool EmitPass::isSupportedLSCCacheControlsEnum(LSC_L1_L3_CC l1l3cc, bool isLoad) const
21704+ {
21705+ if (isLoad)
21706+ {
21707+ switch (l1l3cc)
21708+ {
21709+ default: break;
21710+ case LSC_L1UC_L3CC:
21711+ case LSC_L1C_L3CC:
21712+ case LSC_L1IAR_L3IAR:
21713+ return (m_pCtx->platform.isCoreChildOf(IGFX_XE2_LPG_CORE));
21714+ }
21715+ }
21716+ return true;
21717+ }
21718+
21719+ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsEnum(
21720+ LSC_L1_L3_CC l1l3cc, bool isLoad, const Value* warningContextValue) const
2170621721{
21722+ if (!isSupportedLSCCacheControlsEnum(l1l3cc, isLoad)) {
21723+ m_pCtx->EmitWarning("Unsupported cache controls configuration requested. Applying default configuration.", warningContextValue);
21724+ l1l3cc = LSC_L1DEF_L3DEF;
21725+ }
21726+
2170721727 LSC_CACHE_OPTS cacheOpts {LSC_CACHING_DEFAULT, LSC_CACHING_DEFAULT};
2170821728 switch (l1l3cc)
2170921729 {
@@ -21775,15 +21795,13 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromValue(
2177521795{
2177621796 return translateLSCCacheControlsEnum(
2177721797 static_cast<LSC_L1_L3_CC>(cast<ConstantInt>(value)->getSExtValue()),
21778- isLoad
21779- );
21798+ isLoad, value);
2178021799}
2178121800
21782- static Optional<LSC_CACHE_OPTS>
21783- setCacheOptionsForConstantBufferLoads(Instruction& inst, LSC_L1_L3_CC Ctrl
21784- )
21801+ Optional<LSC_CACHE_OPTS>
21802+ EmitPass::cacheOptionsForConstantBufferLoads(Instruction* inst, LSC_L1_L3_CC Ctrl) const
2178521803{
21786- if (const Value* resourcePointer = GetBufferOperand(& inst))
21804+ if (const Value* resourcePointer = GetBufferOperand(inst))
2178721805 {
2178821806 uint addressSpace = resourcePointer->getType()->getPointerAddressSpace();
2178921807 BufferType bufferType = GetBufferType(addressSpace);
@@ -21792,37 +21810,34 @@ setCacheOptionsForConstantBufferLoads(Instruction& inst, LSC_L1_L3_CC Ctrl
2179221810 (bufferType == BINDLESS_CONSTANT_BUFFER) ||
2179321811 (bufferType == SSH_BINDLESS_CONSTANT_BUFFER))
2179421812 {
21795- return translateLSCCacheControlsEnum(Ctrl, true
21796- );
21813+ return translateLSCCacheControlsEnum(Ctrl, true, inst);
2179721814 }
2179821815 }
2179921816 return None;
2180021817}
2180121818
2180221819Optional<LSC_CACHE_OPTS>
21803- EmitPass::setCacheOptionsForConstantBufferLoads (Instruction& inst) const
21820+ EmitPass::cacheOptionsForConstantBufferLoads (Instruction* inst) const
2180421821{
2180521822 Optional<LSC_CACHE_OPTS> cacheOpts;
2180621823 if (IGC_IS_FLAG_DISABLED(DisableSystemMemoryCachingInGPUForConstantBuffers) &&
2180721824 m_currShader->m_Platform->isCoreChildOf(IGFX_XE2_LPG_CORE))
2180821825 {
21809- if (auto Opts = ::setCacheOptionsForConstantBufferLoads(inst, LSC_L1C_L3CC
21810- ))
21826+ if (auto Opts = cacheOptionsForConstantBufferLoads(inst, LSC_L1C_L3CC))
2181121827 cacheOpts = *Opts;
2181221828 }
2181321829 if (m_pCtx->type == ShaderType::RAYTRACING_SHADER &&
2181421830 IGC_IS_FLAG_ENABLED(ForceRTConstantBufferCacheCtrl))
2181521831 {
2181621832 auto Ctrl = (LSC_L1_L3_CC)IGC_GET_FLAG_VALUE(RTConstantBufferCacheCtrl);
21817- if (auto Opts = ::setCacheOptionsForConstantBufferLoads(inst, Ctrl
21818- ))
21833+ if (auto Opts = cacheOptionsForConstantBufferLoads(inst, Ctrl))
2181921834 cacheOpts = *Opts;
2182021835 }
2182121836 return cacheOpts;
2182221837}
2182321838
21824- static bool tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool isTGM
21825- )
21839+ bool EmitPass:: tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool isTGM,
21840+ const Value* warningContextValue) const
2182621841{
2182721842 uint32_t l1l3CacheVal = 0;
2182821843
@@ -21841,9 +21856,7 @@ static bool tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool is
2184121856
2184221857 if (l1l3CacheVal != 0)
2184321858 {
21844- cacheOpts = translateLSCCacheControlsEnum(
21845- static_cast<LSC_L1_L3_CC>(l1l3CacheVal), isLoad
21846- );
21859+ cacheOpts = translateLSCCacheControlsEnum(static_cast<LSC_L1_L3_CC>(l1l3CacheVal), isLoad, warningContextValue);
2184721860 }
2184821861 return l1l3CacheVal != 0;
2184921862}
@@ -21871,8 +21884,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
2187121884 {
2187221885 if (m_pCtx->platform.supportsNonDefaultLSCCacheSetting())
2187321886 {
21874- if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM
21875- ))
21887+ if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM, inst))
2187621888 {
2187721889 // global override cache settings have highest priority
2187821890 return cacheOpts;
@@ -21898,14 +21910,12 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
2189821910 if (isLoad && m_pCtx->getModuleMetaData()->compOpt.LoadCacheDefault != -1)
2189921911 { // load
2190021912 LSC_L1_L3_CC L1L3Val = static_cast<LSC_L1_L3_CC>(m_pCtx->getModuleMetaData()->compOpt.LoadCacheDefault);
21901- cacheOpts = translateLSCCacheControlsEnum(L1L3Val, true
21902- );
21913+ cacheOpts = translateLSCCacheControlsEnum(L1L3Val, true, inst);
2190321914 }
2190421915 else if (!isLoad && m_pCtx->getModuleMetaData()->compOpt.StoreCacheDefault != -1)
2190521916 { // store
2190621917 LSC_L1_L3_CC L1L3Val = static_cast<LSC_L1_L3_CC>(m_pCtx->getModuleMetaData()->compOpt.StoreCacheDefault);
21907- cacheOpts = translateLSCCacheControlsEnum(L1L3Val, false
21908- );
21918+ cacheOpts = translateLSCCacheControlsEnum(L1L3Val, false, inst);
2190921919 }
2191021920 }
2191121921
@@ -21928,8 +21938,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
2192821938 }
2192921939 }
2193021940
21931- if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM
21932- ))
21941+ if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM, inst))
2193321942 {
2193421943 // global override cache settings have highest priority
2193521944 return cacheOpts;
@@ -21960,7 +21969,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
2196021969
2196121970 if (inst && isLoad)
2196221971 {
21963- if (auto Opts = setCacheOptionsForConstantBufferLoads(* inst))
21972+ if (auto Opts = cacheOptionsForConstantBufferLoads( inst))
2196421973 cacheOpts = *Opts;
2196521974 }
2196621975
@@ -22169,7 +22178,7 @@ void EmitPass::emitLscIntrinsicLoad(llvm::GenIntrinsicInst* inst)
2216922178 LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromValue(inst->getOperand(4), true);
2217022179 LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
2217122180
22172- if (auto Opts = setCacheOptionsForConstantBufferLoads(* inst))
22181+ if (auto Opts = cacheOptionsForConstantBufferLoads( inst))
2217322182 cacheOpts = *Opts;
2217422183
2217522184 emitLscIntrinsicFragments(m_destination, dataSize, dataElems, immOffset,
@@ -23163,8 +23172,7 @@ LSC_CACHE_OPTS EmitPass::getDefaultRaytracingCachePolicy(bool isLoad) const
2316323172 LSC_L1IAR_WB_L3C_WB;
2316423173 }
2316523174
23166- return translateLSCCacheControlsEnum(Opts, isLoad
23167- );
23175+ return translateLSCCacheControlsEnum(Opts, isLoad, nullptr);
2316823176}
2316923177
2317023178void EmitPass::emitAsyncStackID(llvm::GenIntrinsicInst *I)
0 commit comments