@@ -5859,108 +5859,82 @@ void EmitPass::emitDualBlendRT(llvm::RTDualBlendSourceIntrinsic* inst, bool from
5859
5859
}
5860
5860
}
5861
5861
5862
- void EmitPass::emitURBRead(llvm::GenIntrinsicInst* inst)
5862
+ // Common emitter for URBRead and URBReadOutput, used also in associated pattern match pass.
5863
+ // The offsets are calculated in the caller.
5864
+ void EmitPass::emitURBReadCommon(llvm::GenIntrinsicInst* inst, const QuadEltUnit globalOffset, llvm::Value* const perSlotOffset)
5863
5865
{
5864
- CVariable* pPerSlotOffset = nullptr;
5865
- CVariable* pVertexIndex = GetSymbol(inst->getOperand(0));
5866
-
5867
- QuadEltUnit globalOffset(0);
5868
- if (ConstantInt* offset = dyn_cast<ConstantInt>(inst->getOperand(1)))
5869
- {
5870
- globalOffset = QuadEltUnit(int_cast<unsigned>(offset->getZExtValue()));
5871
- }
5872
- else
5873
- {
5874
- pPerSlotOffset = m_currShader->GetSymbol(inst->getOperand(1));
5875
- }
5876
- const EltUnit payloadSize((pPerSlotOffset != nullptr) ? 2 : 1);
5877
- CVariable* pPayload =
5878
- m_currShader->GetNewVariable(payloadSize.Count() * numLanes(m_SimdMode), ISA_TYPE_UD, EALIGN_GRF);
5879
-
5880
5866
TODO("Have VISA define the URBRead interface instead of using a raw send");
5881
- Unit<Element> messageLength = payloadSize;
5882
- Unit<Element> responseLength(m_destination->GetNumberElement() / numLanes(m_SimdMode));
5883
5867
5884
- m_encoder->Copy(pPayload, m_currShader->GetURBInputHandle(pVertexIndex));
5885
- m_encoder->Push();
5868
+ const EltUnit payloadSize(perSlotOffset ? 2 : 1);
5869
+ CVariable* const payload = m_currShader->GetNewVariable(
5870
+ payloadSize.Count() * numLanes(m_SimdMode), ISA_TYPE_UD, EALIGN_GRF);
5871
+ const Unit<Element> messageLength = payloadSize;
5872
+ const Unit<Element> responseLength(m_destination->GetNumberElement() / numLanes(m_SimdMode));
5886
5873
5887
- if (pPerSlotOffset != nullptr)
5874
+ // Get the register with URBHandles and update certain per-opcode data.
5875
+ switch (inst->getIntrinsicID())
5888
5876
{
5889
- m_encoder->SetDstSubVar(1);
5890
- m_encoder->Copy(pPayload, pPerSlotOffset);
5891
- m_encoder->Push();
5892
- }
5893
-
5894
- uint desc = UrbMessage(
5895
- messageLength.Count(),
5896
- responseLength.Count(),
5897
- false,
5898
- pPerSlotOffset != nullptr,
5899
- false,
5900
- globalOffset.Count(),
5901
- EU_GEN8_URB_OPCODE_SIMD8_READ);
5902
-
5903
- uint exDesc = EU_MESSAGE_TARGET_URB;
5904
- CVariable* pMessDesc = m_currShader->ImmToVariable(desc, ISA_TYPE_UD);
5905
-
5906
- m_encoder->Send(m_destination, pPayload, exDesc, pMessDesc);
5907
- m_encoder->Push();
5908
-
5909
- // mark input to be pulled
5910
- m_currShader->isInputsPulled = true;
5911
- }
5912
-
5913
- void EmitPass::emitURBReadOutput(llvm::GenIntrinsicInst* inst)
5914
- {
5915
- CVariable* pPerSlotOffset = nullptr;
5916
- QuadEltUnit globalOffset(0);
5917
- if (ConstantInt* offset = dyn_cast<ConstantInt>(inst->getOperand(0)))
5877
+ case GenISAIntrinsic::GenISA_URBRead:
5918
5878
{
5919
- globalOffset = QuadEltUnit(int_cast<unsigned>(offset->getZExtValue()));
5879
+ CVariable* const pVertexIndex = GetSymbol(inst->getOperand(0));
5880
+ m_encoder->Copy(payload, m_currShader->GetURBInputHandle(pVertexIndex));
5881
+ m_encoder->Push();
5882
+ // Mark input to be pulled.
5883
+ m_currShader->isInputsPulled = true;
5884
+ break;
5920
5885
}
5921
- else
5922
- {
5923
- pPerSlotOffset = m_currShader->GetSymbol(inst->getOperand(0));
5886
+ case GenISAIntrinsic::GenISA_URBReadOutput:
5887
+ m_encoder->Copy(payload, m_currShader->GetURBOutputHandle());
5888
+ m_encoder->Push();
5889
+ break;
5890
+ default:
5891
+ assert(0);
5924
5892
}
5925
5893
5926
- const bool hasPerSlotOffsets = pPerSlotOffset != nullptr;
5927
- // Payload size is just URB handles (1 GRF) or URB handles and per-slot offsets (2 GRFs).
5928
- const Unit<Element> payloadSize(hasPerSlotOffsets ? 2 : 1);
5929
-
5930
- CVariable* pPayload =
5931
- m_currShader->GetNewVariable(payloadSize.Count() * numLanes(m_SimdMode), ISA_TYPE_UD, EALIGN_GRF);
5932
-
5933
- // get the register with URBHandles
5934
- m_encoder->Copy(pPayload, m_currShader->GetURBOutputHandle());
5935
- m_encoder->Push();
5936
-
5937
- // If we have runtime value in per-slot offsets, we need to copy per-slot offsets to payload
5938
- if (hasPerSlotOffsets)
5894
+ if (perSlotOffset)
5939
5895
{
5940
5896
m_encoder->SetDstSubVar(1);
5941
- m_encoder->Copy(pPayload, pPerSlotOffset );
5897
+ m_encoder->Copy(payload, m_currShader->GetSymbol(perSlotOffset) );
5942
5898
m_encoder->Push();
5943
5899
}
5944
5900
5945
5901
constexpr bool eot = false;
5946
- const Unit<Element> messageLength = payloadSize;
5947
- const Unit<Element> responseLength(m_destination->GetNumberElement() / numLanes(m_SimdMode));
5902
+ constexpr bool channelMaskPresent = false;
5948
5903
const uint desc = UrbMessage(
5949
5904
messageLength.Count(),
5950
5905
responseLength.Count(),
5951
5906
eot,
5952
- hasPerSlotOffsets ,
5953
- false ,
5907
+ perSlotOffset != nullptr ,
5908
+ channelMaskPresent ,
5954
5909
globalOffset.Count(),
5955
5910
EU_GEN8_URB_OPCODE_SIMD8_READ);
5956
5911
5957
- const uint exDesc = EU_MESSAGE_TARGET_URB | (eot ? 1 << 5 : 0) ;
5958
- CVariable* pMessDesc = m_currShader->ImmToVariable(desc, ISA_TYPE_UD);
5912
+ constexpr uint exDesc = EU_MESSAGE_TARGET_URB;
5913
+ CVariable* const pMessDesc = m_currShader->ImmToVariable(desc, ISA_TYPE_UD);
5959
5914
5960
- m_encoder->Send(m_destination, pPayload , exDesc, pMessDesc);
5915
+ m_encoder->Send(m_destination, payload , exDesc, pMessDesc);
5961
5916
m_encoder->Push();
5962
5917
}
5963
5918
5919
+ // Emitter for URBRead and URBReadOutput.
5920
+ void EmitPass::emitURBRead(llvm::GenIntrinsicInst* inst)
5921
+ {
5922
+ llvm::Value* offset = nullptr;
5923
+ switch (inst->getIntrinsicID())
5924
+ {
5925
+ case GenISAIntrinsic::GenISA_URBRead:
5926
+ offset = inst->getOperand(1);
5927
+ break;
5928
+ case GenISAIntrinsic::GenISA_URBReadOutput:
5929
+ offset = inst->getOperand(0);
5930
+ break;
5931
+ default:
5932
+ assert(0);
5933
+ }
5934
+ assert(!isa<ConstantInt>(offset) && "Constant offsets are expected to be handled elsewhere.");
5935
+ emitURBReadCommon(inst, QuadEltUnit(0), offset);
5936
+ }
5937
+
5964
5938
void EmitPass::emitURBWrite(llvm::GenIntrinsicInst* inst)
5965
5939
{
5966
5940
// input: GenISA_URBWrite(%offset, %mask, %data0, ..., %data7)
@@ -7228,10 +7202,8 @@ void EmitPass::EmitGenIntrinsicMessage(llvm::GenIntrinsicInst* inst)
7228
7202
emitURBWrite(inst);
7229
7203
break;
7230
7204
case GenISAIntrinsic::GenISA_URBRead:
7231
- emitURBRead(inst);
7232
- break;
7233
7205
case GenISAIntrinsic::GenISA_URBReadOutput:
7234
- emitURBReadOutput (inst);
7206
+ emitURBRead (inst);
7235
7207
break;
7236
7208
case GenISAIntrinsic::GenISA_cycleCounter:
7237
7209
emitcycleCounter(inst);
0 commit comments