Skip to content

Commit 630c408

Browse files
MaciejKalinskiigcbot
authored andcommitted
Minor refactoring and cleanup
* refactoring: intrinsic classes like `RTWriteIntrinsic` cleaned up and updated * refactoring: intrinsic classes used instead of intrinsic ids, e.g. in checks * obsolete code removed * typo fixed: RTWritIntrinsic -> RTWriteIntrinsic
1 parent fd4ff60 commit 630c408

12 files changed

+262
-229
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,6 @@ namespace IGC
22712271
VISA_EMask_Ctrl emask = ConvertMaskToVisaType(m_encoderState.m_mask, m_encoderState.m_noMask);
22722272
VISA_Exec_Size execSize = visaExecSize(m_encoderState.m_simdSize);
22732273
VISA_PredOpnd* predOpnd = GetFlagOperand(m_encoderState.m_flag);
2274-
VISA_StateOpndHandle* surfOpnd = GetVISASurfaceOpnd(ESURFACE_NORMAL, bindingTableIndex);
22752274

22762275
vISA_RT_CONTROLS cntrls;
22772276
uint8_t numMsgSpecificOpnds = 0;
@@ -2354,35 +2353,37 @@ namespace IGC
23542353
//vISA will decide whether to use it or not.
23552354
VISA_RawOpnd* r1RegOpnd = GetRawSource(r1Reg);
23562355

2357-
2358-
if (CPSCounter)
2359-
{
2360-
V(vKernel->AppendVISA3dRTWriteCPS(
2361-
predOpnd,
2362-
emask,
2363-
execSize,
2364-
RTIndexOpnd,
2365-
cntrls,
2366-
surfOpnd,
2367-
r1RegOpnd,
2368-
sampleIndexOpnd,
2369-
cpsCounterOpnd,
2370-
numMsgSpecificOpnds,
2371-
srcOpnd));
2372-
}
2373-
else
23742356
{
2375-
V(vKernel->AppendVISA3dRTWrite(
2376-
predOpnd,
2377-
emask,
2378-
execSize,
2379-
RTIndexOpnd,
2380-
cntrls,
2381-
surfOpnd,
2382-
r1RegOpnd,
2383-
sampleIndexOpnd,
2384-
numMsgSpecificOpnds,
2385-
srcOpnd));
2357+
VISA_StateOpndHandle* surfOpnd = GetVISASurfaceOpnd(ESURFACE_NORMAL, bindingTableIndex);
2358+
if (CPSCounter)
2359+
{
2360+
V(vKernel->AppendVISA3dRTWriteCPS(
2361+
predOpnd,
2362+
emask,
2363+
execSize,
2364+
RTIndexOpnd,
2365+
cntrls,
2366+
surfOpnd,
2367+
r1RegOpnd,
2368+
sampleIndexOpnd,
2369+
cpsCounterOpnd,
2370+
numMsgSpecificOpnds,
2371+
srcOpnd));
2372+
}
2373+
else
2374+
{
2375+
V(vKernel->AppendVISA3dRTWrite(
2376+
predOpnd,
2377+
emask,
2378+
execSize,
2379+
RTIndexOpnd,
2380+
cntrls,
2381+
surfOpnd,
2382+
r1RegOpnd,
2383+
sampleIndexOpnd,
2384+
numMsgSpecificOpnds,
2385+
srcOpnd));
2386+
}
23862387
}
23872388
}
23882389

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -205,33 +205,6 @@ void CShader::EOTURBWrite()
205205
encoder.Push();
206206
}
207207

208-
void CShader::EOTRenderTarget(CVariable* r1, bool isPerCoarse)
209-
{
210-
CVariable* src[4] = { nullptr, nullptr, nullptr, nullptr };
211-
bool isUndefined[4] = { true, true, true, true };
212-
CVariable* const nullSurfaceBti = ImmToVariable(m_pBtiLayout->GetNullSurfaceIdx(), ISA_TYPE_D);
213-
CVariable* const blendStateIndex = ImmToVariable(0, ISA_TYPE_D);
214-
SetBindingTableEntryCountAndBitmap(true, BUFFER_TYPE_UNKNOWN, 0, m_pBtiLayout->GetNullSurfaceIdx());
215-
encoder.RenderTargetWrite(
216-
src,
217-
isUndefined,
218-
true, // lastRenderTarget,
219-
true, // Null RT
220-
false, // perSample,
221-
isPerCoarse, // coarseMode,
222-
false, // isHeaderMaskFromCe0,
223-
nullSurfaceBti,
224-
blendStateIndex,
225-
nullptr, // source0Alpha,
226-
nullptr, // oMaskOpnd,
227-
nullptr, // outputDepthOpnd,
228-
nullptr, // stencilOpnd,
229-
nullptr, // cpscounter,
230-
nullptr, // sampleIndex,
231-
r1);
232-
encoder.Push();
233-
}
234-
235208
// Creates a URB Fence message.
236209
// If return value is not a nullptr, the returned variable is a send message
237210
// writeback variable that must be read in order to wait for URB Fence
@@ -283,6 +256,35 @@ void CShader::EOTGateway(CVariable* payload)
283256
encoder.Push();
284257
}
285258

259+
260+
void CShader::EOTRenderTarget(CVariable* r1,
261+
bool isPerCoarse)
262+
{
263+
CVariable* src[4] = { nullptr, nullptr, nullptr, nullptr };
264+
bool isUndefined[4] = { true, true, true, true };
265+
CVariable* const nullSurfaceBti = ImmToVariable(m_pBtiLayout->GetNullSurfaceIdx(), ISA_TYPE_D);
266+
CVariable* const blendStateIndex = ImmToVariable(0, ISA_TYPE_D);
267+
SetBindingTableEntryCountAndBitmap(true, BUFFER_TYPE_UNKNOWN, 0, m_pBtiLayout->GetNullSurfaceIdx());
268+
encoder.RenderTargetWrite(
269+
src,
270+
isUndefined,
271+
true, // lastRenderTarget,
272+
true, // Null RT
273+
false, // perSample,
274+
isPerCoarse, // coarseMode,
275+
false, // isHeaderMaskFromCe0,
276+
nullSurfaceBti,
277+
blendStateIndex,
278+
nullptr, // source0Alpha,
279+
nullptr, // oMaskOpnd,
280+
nullptr, // outputDepthOpnd,
281+
nullptr, // stencilOpnd,
282+
nullptr, // cpscounter,
283+
nullptr, // sampleIndex,
284+
r1);
285+
encoder.Push();
286+
}
287+
286288
void CShader::AddEpilogue(llvm::ReturnInst* ret)
287289
{
288290
encoder.EOT();

IGC/Compiler/CISACodeGen/CoalescingEngine.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@ namespace IGC
176176

177177
if (GenIntrinsicInst * intrinsic = llvm::dyn_cast<llvm::GenIntrinsicInst>(DefMI))
178178
{
179-
GenISAIntrinsic::ID IID = intrinsic->getIntrinsicID();
180179
if ((isURBWriteIntrinsic(intrinsic) && !(IGC_IS_FLAG_ENABLED(DisablePayloadCoalescing_URB))) ||
181-
(IID == GenISAIntrinsic::GenISA_RTWrite && !(IGC_IS_FLAG_ENABLED(DisablePayloadCoalescing_RT))))
180+
(llvm::isa<llvm::RTWriteIntrinsic>(intrinsic) && !(IGC_IS_FLAG_ENABLED(DisablePayloadCoalescing_RT))))
182181
{
183182
ProcessTuple(DefMI);
184183
}
@@ -450,15 +449,15 @@ namespace IGC
450449
if (ccTuple->HasNonHomogeneousElements())
451450
{
452451
// Finding a supremum instruction for a homogeneous part is implemented
453-
// only for render target write instructions (RTWritIntrinsic).
452+
// only for render target write instructions (RTWriteIntrinsic).
454453
// An only other possible combination for non-homogeneous instructions comprises
455-
// RTWritIntrinsic and RTDualBlendSourceIntrinsic.
454+
// RTWriteIntrinsic and RTDualBlendSourceIntrinsic.
456455
// In some cases there is an opportunity to coalesce their payloads but there exists
457456
// a danger that they are compiled in different SIMD modes so there is a safe assumption
458457
// that they cannot be coalesced.
459-
// A comparison of the payload of RTWritIntrinsic and RTDualBlendSourceIntrinsic:
458+
// A comparison of the payload of RTWriteIntrinsic and RTDualBlendSourceIntrinsic:
460459
// +----------------------------+----------------------------+
461-
// | RTWritIntrinsic | RTDualBlendSourceIntrinsic |
460+
// | RTWriteIntrinsic | RTDualBlendSourceIntrinsic |
462461
// +----------------------------+----------------------------+
463462
// | src0 Alpha (optional) | src0 Alpha (unavailable)* |
464463
// +----------------------------+----------------------------+
@@ -488,8 +487,8 @@ namespace IGC
488487
// * RTDualBlendSourceIntrinsic doesn't have such an argument but it is defined in its payload.
489488
if (offsetDiff == 0 &&
490489
ccTuple->GetNumElements() == numOperands &&
491-
llvm::isa<llvm::RTWritIntrinsic>(ccTuple->GetRoot()) &&
492-
llvm::isa<llvm::RTWritIntrinsic>(tupleGeneratingInstruction))
490+
llvm::isa<llvm::RTWriteIntrinsic>(ccTuple->GetRoot()) &&
491+
llvm::isa<llvm::RTWriteIntrinsic>(tupleGeneratingInstruction))
493492
{
494493
if (m_PayloadMapping.HasNonHomogeneousPayloadElements(tupleGeneratingInstruction))
495494
{
@@ -1408,11 +1407,10 @@ namespace IGC
14081407

14091408
bool CoalescingEngine::MatchSingleInstruction(llvm::GenIntrinsicInst* inst)
14101409
{
1411-
GenISAIntrinsic::ID IID = inst->getIntrinsicID();
14121410
if (isSampleInstruction(inst) ||
14131411
isLdInstruction(inst) ||
14141412
isURBWriteIntrinsic(inst) ||
1415-
IID == GenISAIntrinsic::GenISA_RTWrite)
1413+
llvm::isa<llvm::RTWriteIntrinsic>(inst))
14161414
{
14171415
uint numOperands = inst->getNumOperands();
14181416
for (uint i = 0; i < numOperands; i++)

0 commit comments

Comments
 (0)