Skip to content

Commit 056a711

Browse files
hliao2igcbot
authored andcommitted
Refactor vector process
Now, it depends on CShader only instead of the emitter.
1 parent c5f0503 commit 056a711

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

IGC/Compiler/CISACodeGen/VectorProcess.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,18 +650,18 @@ void VectorMessage::getInfo(Type* Ty, uint32_t Align, bool useA32,
650650
{
651651
VectorType* VTy = dyn_cast<VectorType>(Ty);
652652
Type* eTy = VTy ? cast<VectorType>(VTy)->getElementType() : Ty;
653-
unsigned eltSize = m_emitter->GetScalarTypeSizeInRegister(eTy);
653+
unsigned eltSize = Shader->GetScalarTypeSizeInRegister(eTy);
654654
unsigned nElts = VTy ? (unsigned)cast<IGCLLVM::FixedVectorType>(VTy)->getNumElements() : 1;
655655
// total bytes
656656
const unsigned TBytes = nElts * eltSize;
657657

658658
// Per-channel Max Bytes (MB) that can be read/written by a single send inst
659659
unsigned MB;
660-
SIMDMode SM = m_emitter->m_currShader->m_SIMDSize;
660+
SIMDMode SM = Shader->m_SIMDSize;
661661
bool has_8B_A64_BS =
662-
m_emitter->m_currShader->m_Platform->has8ByteA64ByteScatteredMessage();
662+
Shader->m_Platform->has8ByteA64ByteScatteredMessage();
663663
bool has_8DW_A64_SM =
664-
m_emitter->m_currShader->m_Platform->has8DWA64ScatteredMessage();
664+
Shader->m_Platform->has8DWA64ScatteredMessage();
665665

666666
//
667667
// Set up default message and the data type of the message
@@ -770,12 +770,11 @@ void VectorMessage::getInfo(Type* Ty, uint32_t Align, bool useA32,
770770
void VectorMessage::getLSCInfo(llvm::Type* Ty, uint32_t Align, CodeGenContext* ctx, bool useA32, bool transpose)
771771
{
772772
IGC_ASSERT(nullptr != ctx);
773-
IGC_ASSERT(nullptr != m_emitter);
774-
IGC_ASSERT(nullptr != m_emitter->m_currShader);
773+
IGC_ASSERT(nullptr != Shader);
775774

776775
IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
777776
Type* eTy = VTy ? VTy->getContainedType(0) : Ty;
778-
unsigned eltSize = m_emitter->GetScalarTypeSizeInRegister(eTy);
777+
unsigned eltSize = Shader->GetScalarTypeSizeInRegister(eTy);
779778
unsigned nElts = VTy ? (unsigned)VTy->getNumElements() : 1;
780779
// total bytes
781780
const unsigned TBytes = nElts * eltSize;
@@ -788,7 +787,7 @@ void VectorMessage::getLSCInfo(llvm::Type* Ty, uint32_t Align, CodeGenContext* c
788787
uint16_t blkInBytes = (uint16_t)CEncoder::GetCISADataTypeSize(dataType);
789788

790789
// Per-channel Max Bytes (MB) that can be read/written by a single send inst
791-
const unsigned int numLanesForSIMDSize = numLanes(m_emitter->m_currShader->m_SIMDSize);
790+
const unsigned int numLanesForSIMDSize = numLanes(Shader->m_SIMDSize);
792791
IGC_ASSERT(numLanesForSIMDSize);
793792
unsigned int MB = (8 * ctx->platform.getGRFSize()) / numLanesForSIMDSize;
794793
if (Align < 4 || (eltSize == 8 && Align < 8)) {
@@ -863,3 +862,4 @@ void VectorMessage::getLSCInfo(llvm::Type* Ty, uint32_t Align, CodeGenContext* c
863862
IGC_ASSERT_MESSAGE(numInsts <= (sizeof(insts) / sizeof(*insts)), "Vector's size is too big, increase MAX_VECMESSAGEINFO_LEN to fix it!");
864863
}
865864

865+
VectorMessage::VectorMessage(EmitPass* emitter) : Shader(emitter->m_currShader) {}

IGC/Compiler/CISACodeGen/VectorProcess.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ namespace IGC
7878
} insts[VECMESSAGEINFO_MAX_LEN];
7979
uint16_t numInsts;
8080

81-
VectorMessage(EmitPass* emitter) : m_emitter(emitter) {}
81+
VectorMessage(EmitPass* emitter);
82+
VectorMessage(CShader* shader) : Shader(shader) {}
8283
void getInfo(llvm::Type* Ty, uint32_t Align, bool useA32,
8384
bool forceByteScatteredRW = false);
8485

8586

8687
void getLSCInfo(llvm::Type* Ty, uint32_t Align, CodeGenContext* ctx, bool useA32, bool transpose);
8788

8889
private:
89-
const EmitPass* m_emitter;
90+
const CShader *Shader;
9091

9192
VectorMessage(const VectorMessage&); // not implemented
9293
void operator=(const VectorMessage&); // not implemented

0 commit comments

Comments
 (0)