@@ -3946,7 +3946,7 @@ void EmitPass::emitEvalAttribute(llvm::GenIntrinsicInst* inst)
39463946 m_encoder->Send(m_destination, payload, exDesc, messDesc, false);
39473947 m_encoder->Push();
39483948
3949- ResourceLoop (needLoop, flag, label);
3949+ ResourceLoopBackEdge (needLoop, flag, label);
39503950 }
39513951 }
39523952 break;
@@ -4368,7 +4368,7 @@ void EmitPass::emitLdInstruction(llvm::Instruction* inst)
43684368 m_encoder->Copy(m_currShader->GetNULL(), m_currShader->GetTSC());
43694369 m_encoder->Push();
43704370 }
4371- ResourceLoop (needLoop, flag, label);
4371+ ResourceLoopBackEdge (needLoop, flag, label);
43724372
43734373 {
43744374 if (m_destination->IsUniform())
@@ -7202,7 +7202,7 @@ void EmitPass::emitSampleInstruction(SampleIntrinsic* inst)
72027202 m_encoder->Copy(m_currShader->GetNULL(), m_currShader->GetTSC());
72037203 m_encoder->Push();
72047204 }
7205- ResourceLoop (needLoop, flag, label);
7205+ ResourceLoopBackEdge (needLoop, flag, label);
72067206
72077207 {
72087208 if (simd8HFRet)
@@ -7359,7 +7359,7 @@ void EmitPass::emitInfoInstruction(InfoIntrinsic* inst)
73597359 m_encoder->Info(opCode, writeMask, resource, lod, tempDest);
73607360 m_encoder->Push();
73617361
7362- ResourceLoop (needLoop, flag, label);
7362+ ResourceLoopBackEdge (needLoop, flag, label);
73637363
73647364 if (tempDest != m_destination)
73657365 {
@@ -7441,7 +7441,7 @@ void EmitPass::emitSurfaceInfo(GenIntrinsicInst* inst)
74417441 m_encoder->Push();
74427442
74437443 IGC_ASSERT(m_destination->IsUniform());
7444- ResourceLoop (needLoop, flag, label);
7444+ ResourceLoopBackEdge (needLoop, flag, label);
74457445 ResetVMask(false);
74467446}
74477447
@@ -7557,7 +7557,7 @@ void EmitPass::emitGather4Instruction(SamplerGatherIntrinsic* inst)
75577557 m_encoder->Copy(m_currShader->GetNULL(), m_currShader->GetTSC());
75587558 m_encoder->Push();
75597559 }
7560- ResourceLoop (needLoop, flag, label);
7560+ ResourceLoopBackEdge (needLoop, flag, label);
75617561
75627562 {
75637563 if (simd8HFRet)
@@ -7637,7 +7637,7 @@ void EmitPass::emitLdmsInstruction(llvm::Instruction* inst)
76377637 m_encoder->Copy(m_currShader->GetNULL(), m_currShader->GetTSC());
76387638 m_encoder->Push();
76397639 }
7640- ResourceLoop (needLoop, flag, label);
7640+ ResourceLoopBackEdge (needLoop, flag, label);
76417641
76427642 if (simd8HFRet)
76437643 {
@@ -8638,11 +8638,11 @@ void EmitPass::EmitGenIntrinsicMessage(llvm::GenIntrinsicInst* inst)
86388638 break;
86398639 case GenISAIntrinsic::GenISA_ldrawvector_indexed:
86408640 case GenISAIntrinsic::GenISA_ldraw_indexed:
8641- emitLoadRawIndexed(inst);
8641+ emitLoadRawIndexed(cast<LdRawIntrinsic>( inst) );
86428642 break;
86438643 case GenISAIntrinsic::GenISA_storerawvector_indexed:
86448644 case GenISAIntrinsic::GenISA_storeraw_indexed:
8645- emitStoreRawIndexed(inst);
8645+ emitStoreRawIndexed(cast<StoreRawIntrinsic>( inst) );
86468646 break;
86478647 case GenISAIntrinsic::GenISA_GetBufferPtr:
86488648 emitGetBufferPtr(inst);
@@ -9676,14 +9676,14 @@ void EmitPass::emitUAVSerialize()
96769676}
96779677
96789678
9679- void EmitPass::emitLoadRawIndexed(GenIntrinsicInst * inst)
9679+ void EmitPass::emitLoadRawIndexed(LdRawIntrinsic * inst)
96809680{
9681- Value* buf_ptrv = inst->getOperand(0 );
9682- Value* elem_idxv = inst->getOperand(1 );
9681+ Value* buf_ptrv = inst->getResourceValue( );
9682+ Value* elem_idxv = inst->getOffsetValue( );
96839683
96849684 ResourceDescriptor resource = GetResourceVariable(buf_ptrv);
96859685 m_currShader->isMessageTargetDataCacheDataPort = true;
9686- emitLoad3DInner(cast<LdRawIntrinsic>( inst) , resource, elem_idxv);
9686+ emitLoad3DInner(inst, resource, elem_idxv);
96879687
96889688}
96899689
@@ -9901,7 +9901,7 @@ void EmitPass::emitLoad3DInner(LdRawIntrinsic* inst, ResourceDescriptor& resourc
99019901 m_encoder->Cast(m_destination, gatherDest);
99029902 m_encoder->Push();
99039903 }
9904- ResourceLoop (needLoop, flag, label);
9904+ ResourceLoopBackEdge (needLoop, flag, label);
99059905 }
99069906}
99079907
@@ -10818,41 +10818,26 @@ void EmitPass::emitSymbolRelocation(Function& F)
1081810818 }
1081910819}
1082010820
10821- void EmitPass::emitStoreRawIndexed(GenIntrinsicInst * inst)
10821+ void EmitPass::emitStoreRawIndexed(StoreRawIntrinsic * inst)
1082210822{
10823- Value* pBufPtr = inst->getOperand(0 );
10824- Value* pElmIdx = inst->getOperand(1 );
10825- Value* pValToStore = inst->getOperand(2 );
10823+ Value* pBufPtr = inst->getResourceValue( );
10824+ Value* pOffset = inst->getOffsetValue( );
10825+ Value* pValToStore = inst->getStoreValue( );
1082610826
1082710827 m_currShader->isMessageTargetDataCacheDataPort = true;
1082810828
10829- emitStore3DInner(pValToStore, pBufPtr, pElmIdx );
10829+ emitStore3DInner(pValToStore, pBufPtr, pOffset );
1083010830
1083110831}
1083210832
1083310833void EmitPass::emitStore3D(StoreInst* inst, Value* elmIdxV)
1083410834{
10835- Value* ptrVal = inst->getPointerOperand();
10836- Value* pllElmIdx = nullptr;
10837- if (elmIdxV)
10838- {
10839- pllElmIdx = elmIdxV;
10840- }
10841- else if (isa<ConstantPointerNull>(ptrVal))
10842- {
10843- pllElmIdx = ConstantInt::get(Type::getInt32Ty(inst->getContext()), 0);
10844- }
10845- else
10846- {
10847- pllElmIdx = inst->getPointerOperand();
10848- }
10849-
1085010835 // Only support for scratch space added currently during emitStore
1085110836 Value* pllValToStore = inst->getValueOperand();
1085210837 Value* pllDstPtr = inst->getPointerOperand();
1085310838
1085410839
10855- emitStore3DInner(pllValToStore, pllDstPtr, pllElmIdx );
10840+ emitStore3DInner(pllValToStore, pllDstPtr, elmIdxV );
1085610841}
1085710842
1085810843void EmitPass::emitStore3DInner(Value* pllValToStore, Value* pllDstPtr, Value* pllElmIdx)
@@ -10955,7 +10940,7 @@ void EmitPass::emitStore3DInner(Value* pllValToStore, Value* pllDstPtr, Value* p
1095510940 m_encoder->Scatter4Scaled(storedVal, resource, ptr);
1095610941 m_encoder->Push();
1095710942 }
10958- ResourceLoop (needLoop, flag, label);
10943+ ResourceLoopBackEdge (needLoop, flag, label);
1095910944 if (!isPrivateMem)
1096010945 {
1096110946 ResetVMask(false);
@@ -13357,8 +13342,8 @@ void EmitPass::emitAtomicRaw(llvm::GenIntrinsicInst* pInsn)
1335713342 pDst);
1335813343 m_encoder->Push();
1335913344 }
13360- ResourceLoop (needLoop, flag, label);
13361- }
13345+ ResourceLoopBackEdge (needLoop, flag, label);
13346+ }
1336213347
1336313348
1336413349 }
@@ -13553,7 +13538,7 @@ void EmitPass::emitAtomicTyped(GenIntrinsicInst* pInsn)
1355313538 EU_GEN7_5_MESSAGE_TARGET_DATA_PORT_DATA_CACHE_1, exDesc, pMessDesc);
1355413539 m_encoder->Push();
1355513540 }
13556- ResourceLoop (needLoop, flag, label);
13541+ ResourceLoopBackEdge (needLoop, flag, label);
1355713542
1355813543 if (returnsImmValue)
1355913544 {
@@ -13670,7 +13655,7 @@ void EmitPass::emitTypedRead(llvm::Instruction* pInsn)
1367013655 m_encoder->Push();
1367113656 }
1367213657 }
13673- ResourceLoop (needLoop, flag, label);
13658+ ResourceLoopBackEdge (needLoop, flag, label);
1367413659
1367513660 if (m_currShader->m_SIMDSize != instWidth)
1367613661 {
@@ -13818,7 +13803,7 @@ void EmitPass::emitTypedWrite(llvm::Instruction* pInsn)
1381813803 }
1381913804 }
1382013805 }
13821- ResourceLoop (needLoop, flag, label);
13806+ ResourceLoopBackEdge (needLoop, flag, label);
1382213807 }
1382313808 ResetVMask();
1382413809 m_currShader->isMessageTargetDataCacheDataPort = true;
@@ -14329,7 +14314,7 @@ void EmitPass::emitAtomicCounter(llvm::GenIntrinsicInst* pInsn)
1432914314 }
1433014315 }
1433114316
14332- ResourceLoop (needLoop, flag, label);
14317+ ResourceLoopBackEdge (needLoop, flag, label);
1433314318 ResetVMask();
1433414319 m_currShader->isMessageTargetDataCacheDataPort = true;
1433514320}
@@ -14925,16 +14910,14 @@ void EmitPass::emitftoi(llvm::GenIntrinsicInst* inst)
1492514910 ResetRoundingMode(inst);
1492614911}
1492714912
14928- // Return true if this store will be emit as uniform store
14929- bool EmitPass::isUniformStoreOCL(llvm::StoreInst* SI)
14913+ bool EmitPass::isUniformStoreOCL(Value* ptr, Value* storeVal)
1493014914{
1493114915 if (m_currShader->GetShaderType() != ShaderType::OPENCL_SHADER ||
14932- !m_currShader->GetIsUniform(SI->getPointerOperand() ))
14916+ !m_currShader->GetIsUniform(ptr ))
1493314917 {
1493414918 return false;
1493514919 }
1493614920
14937- Value* storeVal = SI->getValueOperand();
1493814921 Type* Ty = storeVal->getType();
1493914922 VectorType* VTy = dyn_cast<VectorType>(Ty);
1494014923 uint32_t elts = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
@@ -14947,10 +14930,16 @@ bool EmitPass::isUniformStoreOCL(llvm::StoreInst* SI)
1494714930 // size must be 4 or 8. Also, note that if totalBytes = 4, elts must be 1.
1494814931 bool doUniformStore = (elts == 1 ||
1494914932 (m_currShader->GetIsUniform(storeVal) &&
14950- (totalBytes == 8 || totalBytes == 12 || totalBytes == 16)));
14933+ (totalBytes == 8 || totalBytes == 12 || totalBytes == 16)));
1495114934 return doUniformStore;
1495214935}
1495314936
14937+ // Return true if this store will be emit as uniform store
14938+ bool EmitPass::isUniformStoreOCL(llvm::StoreInst* SI)
14939+ {
14940+ return isUniformStoreOCL(SI->getPointerOperand(), SI->getValueOperand());
14941+ }
14942+
1495414943void EmitPass::emitVectorBitCast(llvm::BitCastInst* BCI)
1495514944{
1495614945 uint destMask = m_currShader->GetExtractMask(BCI);
@@ -15555,7 +15544,7 @@ void EmitPass::emitVectorLoad(LoadInst* inst, Value* offset, ConstantInt* immOff
1555515544
1555615545 ResourceDescriptor resource = GetResourceVariable(Ptr);
1555715546 CountStatelessIndirectAccess(Ptr, resource);
15558- // eOffset is in bytes as 2/19/14
15547+ // eOffset is in bytes
1555915548 // offset corresponds to Int2Ptr operand obtained during pattern matching
1556015549 CVariable* eOffset = GetSymbol(immOffset ? offset : Ptr);
1556115550 if (useA32)
@@ -16001,7 +15990,7 @@ void EmitPass::emitVectorStore(StoreInst* inst, Value* offset, ConstantInt* immO
1600115990 {
1600215991 ForceDMask(false);
1600315992 }
16004- // As 2/19/14, eOffset is in bytes !
15993+ // eOffset is in bytes
1600515994 // offset corresponds to Int2Ptr operand obtained during pattern matching
1600615995 CVariable* eOffset = GetSymbol(immOffset ? offset : Ptr);
1600715996 bool useA32 = !isA64Ptr(ptrType, m_currShader->GetContext());
@@ -17318,7 +17307,8 @@ bool EmitPass::ResourceLoopHeader(
1731817307 CVariable*& flag,
1731917308 uint& label)
1732017309{
17321- if (resource.m_surfaceType != ESURFACE_BINDLESS && resource.m_surfaceType != ESURFACE_NORMAL)
17310+ if (resource.m_surfaceType != ESURFACE_BINDLESS &&
17311+ resource.m_surfaceType != ESURFACE_NORMAL)
1732217312 {
1732317313 // Loop only needed for access with surface state
1732417314 return false;
@@ -17379,7 +17369,7 @@ bool EmitPass::ResourceLoopHeader(
1737917369 return true;
1738017370}
1738117371
17382- void EmitPass::ResourceLoop (bool needLoop, CVariable* flag, uint label)
17372+ void EmitPass::ResourceLoopBackEdge (bool needLoop, CVariable* flag, uint label)
1738317373{
1738417374 if (needLoop)
1738517375 {
0 commit comments