@@ -111,12 +111,14 @@ Value* GetBufferOperand(Instruction* inst)
111
111
case GenISAIntrinsic::GenISA_ldrawvector_indexed:
112
112
case GenISAIntrinsic::GenISA_storeraw_indexed:
113
113
case GenISAIntrinsic::GenISA_ldraw_indexed:
114
- pBuffer = intr->getOperand (0 );
115
- break ;
116
114
case GenISAIntrinsic::GenISA_intatomicraw:
115
+ case GenISAIntrinsic::GenISA_intatomictyped:
116
+ case GenISAIntrinsic::GenISA_icmpxchgatomictyped:
117
117
case GenISAIntrinsic::GenISA_floatatomicraw:
118
118
case GenISAIntrinsic::GenISA_icmpxchgatomicraw:
119
119
case GenISAIntrinsic::GenISA_fcmpxchgatomicraw:
120
+ pBuffer = intr->getOperand (0 );
121
+ break ;
120
122
case GenISAIntrinsic::GenISA_intatomicrawA64:
121
123
case GenISAIntrinsic::GenISA_floatatomicrawA64:
122
124
case GenISAIntrinsic::GenISA_icmpxchgatomicrawA64:
@@ -151,6 +153,8 @@ Type* GetBufferAccessType(Instruction *inst)
151
153
case GenISAIntrinsic::GenISA_ldrawvector_indexed:
152
154
case GenISAIntrinsic::GenISA_ldraw_indexed:
153
155
case GenISAIntrinsic::GenISA_intatomicraw:
156
+ case GenISAIntrinsic::GenISA_intatomictyped:
157
+ case GenISAIntrinsic::GenISA_icmpxchgatomictyped:
154
158
case GenISAIntrinsic::GenISA_floatatomicraw:
155
159
case GenISAIntrinsic::GenISA_icmpxchgatomicraw:
156
160
case GenISAIntrinsic::GenISA_fcmpxchgatomicraw:
@@ -531,6 +535,8 @@ void PromoteResourceToDirectAS::PromoteBufferToDirectAS(Instruction* inst, Value
531
535
{
532
536
case GenISAIntrinsic::GenISA_intatomicraw:
533
537
case GenISAIntrinsic::GenISA_floatatomicraw:
538
+ case GenISAIntrinsic::GenISA_intatomictyped:
539
+ case GenISAIntrinsic::GenISA_icmpxchgatomictyped:
534
540
case GenISAIntrinsic::GenISA_icmpxchgatomicraw:
535
541
case GenISAIntrinsic::GenISA_fcmpxchgatomicraw:
536
542
is64BitPtr = false ;
@@ -569,14 +575,14 @@ void PromoteResourceToDirectAS::PromoteBufferToDirectAS(Instruction* inst, Value
569
575
}
570
576
else
571
577
{
578
+ bufferAddress = pIntr->getArgOperand (1 );
572
579
if (!isa<ConstantPointerNull>(pBuffer))
573
580
{
581
+ assert (isa<ConstantInt>(bufferAddress) && cast<ConstantInt>(bufferAddress)->getZExtValue () == 0 );
582
+ assert (pIntr->getIntrinsicID () != GenISAIntrinsic::GenISA_intatomictyped &&
583
+ pIntr->getIntrinsicID () != GenISAIntrinsic::GenISA_icmpxchgatomictyped);
574
584
bufferAddress = builder.CreatePtrToInt (pBuffer, builder.getInt32Ty ());
575
585
}
576
- else
577
- {
578
- bufferAddress = builder.getInt32 (0 );
579
- }
580
586
}
581
587
582
588
args.push_back (sourcePointer);
@@ -613,30 +619,30 @@ void PromoteResourceToDirectAS::PromoteBufferToDirectAS(Instruction* inst, Value
613
619
614
620
void PromoteResourceToDirectAS::GetAccessInstToSrcPointerMap (Instruction* inst, Value* resourcePtr)
615
621
{
616
- unsigned addrSpace = resourcePtr->getType ()->getPointerAddressSpace ();
622
+ unsigned addrSpace = resourcePtr->getType ()->getPointerAddressSpace ();
617
623
618
- if (addrSpace != 1 && addrSpace != 2 )
619
- {
620
- // Only try to promote stateless buffer pointers ( as(1) or as(2) )
624
+ if (addrSpace != 1 && addrSpace != 2 )
625
+ {
626
+ // Only try to promote stateless buffer pointers ( as(1) or as(2) )
621
627
return ;
622
- }
628
+ }
623
629
624
- if (!isa<LoadInst>(inst) && !isa<StoreInst>(inst))
625
- {
626
- // Do we need to support other instructions besides load/store?
627
- return ;
628
- }
630
+ if (!isa<LoadInst>(inst) && !isa<StoreInst>(inst))
631
+ {
632
+ // Do we need to support other instructions besides load/store?
633
+ return ;
634
+ }
629
635
630
- Value* srcPtr = IGC::TracePointerSource (resourcePtr);
636
+ Value* srcPtr = IGC::TracePointerSource (resourcePtr);
631
637
632
- if (!srcPtr ||
633
- !srcPtr->getType ()->isPointerTy () ||
634
- !isa<Argument>(srcPtr))
635
- {
636
- // Cannot trace the resource pointer back to it's source, cannot promote
638
+ if (!srcPtr ||
639
+ !srcPtr->getType ()->isPointerTy () ||
640
+ !isa<Argument>(srcPtr))
641
+ {
642
+ // Cannot trace the resource pointer back to it's source, cannot promote
637
643
assert (0 && " Stateless buffer pointer not tracable, cannot promote stateless to bindless" );
638
- return ;
639
- }
644
+ return ;
645
+ }
640
646
641
647
m_AccessToSrcPtrMap[inst] = srcPtr;
642
648
return ;
@@ -720,11 +726,11 @@ void PromoteResourceToDirectAS::visitInstruction(Instruction &I)
720
726
if (isStatelessToBindlessPromotion (m_pCodeGenContext))
721
727
{
722
728
GetAccessInstToSrcPointerMap (&I, bufptr);
723
- }
724
- else
725
- {
726
- PromoteBufferToDirectAS (&I, bufptr);
727
- }
729
+ }
730
+ else
731
+ {
732
+ PromoteBufferToDirectAS (&I, bufptr);
733
+ }
728
734
resourceAccessed = true ;
729
735
}
730
736
}
0 commit comments