@@ -13,12 +13,15 @@ SPDX-License-Identifier: MIT
1313#include " GenISAIntrinsics/GenIntrinsicInst.h"
1414#include " IGC/Compiler/CodeGenPublic.h"
1515#include " Probe/Assertion.h"
16+ #include " Compiler/CISACodeGen/helper.h"
1617#include " Compiler/IGCPassSupport.h"
1718#include " SynchronizationObjectCoalescing.hpp"
19+ #include " visa_igc_common_header.h"
1820#include < memory>
1921#include < utility>
2022#include < map>
2123
24+ using namespace llvm ;
2225namespace IGC
2326{
2427
@@ -48,6 +51,30 @@ struct ExplanationEntry
4851};
4952#endif // _DEBUG
5053
54+ // //////////////////////////////////////////////////////////////////////////////
55+ enum InstructionMask : uint32_t
56+ {
57+ None = 0x0 ,
58+ AtomicOperation = 0x1 ,
59+ TypedReadOperation = 0x2 ,
60+ TypedWriteOperation = 0x4 ,
61+ OutputUrbReadOperation = 0x8 ,
62+ UrbWriteOperation = 0x10 ,
63+ BufferReadOperation = 0x20 ,
64+ BufferWriteOperation = 0x40 ,
65+ SharedMemoryReadOperation = 0x80 ,
66+ SharedMemoryWriteOperation = 0x100
67+ };
68+ inline constexpr InstructionMask operator |(InstructionMask a, InstructionMask b)
69+ {
70+ return InstructionMask (uint32_t (a) | uint32_t (b));
71+ }
72+ inline constexpr InstructionMask& operator |=(InstructionMask& a, InstructionMask b)
73+ {
74+ a = a | b;
75+ return a;
76+ }
77+
5178// //////////////////////////////////////////////////////////////////////
5279// / @brief Synchronization objects prevents from hazardous situations in kernels.
5380// / They cannot be removed if one of hazards is possible:
@@ -187,22 +214,6 @@ class SynchronizationObjectCoalescingAnalysis : public llvm::FunctionPass
187214 void dump (bool onlyMemoryInstructionMask = true ) const ;
188215#endif // _DEBUG
189216private:
190-
191- // //////////////////////////////////////////////////////////////////////
192- enum InstructionMask : uint32_t
193- {
194- None = 0x0 ,
195- AtomicOperation = 0x1 ,
196- TypedReadOperation = 0x2 ,
197- TypedWriteOperation = 0x4 ,
198- OutputUrbReadOperation = 0x8 ,
199- UrbWriteOperation = 0x10 ,
200- BufferReadOperation = 0x20 ,
201- BufferWriteOperation = 0x40 ,
202- SharedMemoryReadOperation = 0x80 ,
203- SharedMemoryWriteOperation = 0x100
204- };
205-
206217 static constexpr InstructionMask sc_MemoryWriteInstructionMask = static_cast <InstructionMask>(
207218 AtomicOperation |
208219 TypedWriteOperation |
@@ -372,6 +383,7 @@ class SynchronizationObjectCoalescingAnalysis : public llvm::FunctionPass
372383 // //////////////////////////////////////////////////////////////////////
373384 bool IsUntypedMemoryFenceOperationForGlobalAccess (const llvm::Instruction* pInst) const ;
374385
386+
375387 // //////////////////////////////////////////////////////////////////////
376388 static bool IsFenceOperation (const llvm::Instruction* pInst);
377389
@@ -402,6 +414,7 @@ class SynchronizationObjectCoalescingAnalysis : public llvm::FunctionPass
402414#endif // _DEBUG
403415};
404416
417+
405418char SynchronizationObjectCoalescingAnalysis::ID = 0 ;
406419
407420// //////////////////////////////////////////////////////////////////////////
@@ -593,7 +606,7 @@ void SynchronizationObjectCoalescingAnalysis::FindRedundancies()
593606// //////////////////////////////////////////////////////////////////////
594607// / @brief Provides write memory instructions mask which are synchronized
595608// / by the instruction.
596- IGC::SynchronizationObjectCoalescingAnalysis:: InstructionMask SynchronizationObjectCoalescingAnalysis::GetDefaultWriteMemoryInstructionMask (const llvm::Instruction* pSourceInst) const
609+ InstructionMask SynchronizationObjectCoalescingAnalysis::GetDefaultWriteMemoryInstructionMask (const llvm::Instruction* pSourceInst) const
597610{
598611 InstructionMask result = InstructionMask::None;
599612 if (IsUntypedMemoryFenceOperation (pSourceInst))
@@ -647,7 +660,7 @@ IGC::SynchronizationObjectCoalescingAnalysis::InstructionMask SynchronizationObj
647660// //////////////////////////////////////////////////////////////////////
648661// / @brief Provides default memory instruction mask which is used for
649662// / graph searching.
650- IGC::SynchronizationObjectCoalescingAnalysis:: InstructionMask SynchronizationObjectCoalescingAnalysis::GetDefaultMemoryInstructionMask (
663+ InstructionMask SynchronizationObjectCoalescingAnalysis::GetDefaultMemoryInstructionMask (
651664 const llvm::Instruction* pSourceInst) const
652665{
653666 // All the rules stems from assumptions in the main comment of this analysis (the paragraph about a strict redundancy).
@@ -982,7 +995,7 @@ void SynchronizationObjectCoalescingAnalysis::GetAllUnsynchronizedMemoryInstruct
982995// / a substitute is not crossed by another substitute.
983996// / @param pSourceInst the source synchronization instruction
984997// / @param forwardDirection the direction of searching
985- SynchronizationObjectCoalescingAnalysis:: InstructionMask SynchronizationObjectCoalescingAnalysis::GetInstructionMask (
998+ InstructionMask SynchronizationObjectCoalescingAnalysis::GetInstructionMask (
986999 const llvm::Instruction* pSourceInst,
9871000 bool forwardDirection) const
9881001{
@@ -1126,7 +1139,7 @@ SynchronizationObjectCoalescingAnalysis::SynchronizationCaseMask Synchronization
11261139// / memory instructions (in the next synchronization block delineated by
11271140// / thread group barriers)
11281141// / @param pSourceInst the source synchronization instruction
1129- IGC::SynchronizationObjectCoalescingAnalysis:: InstructionMask SynchronizationObjectCoalescingAnalysis::GetUnsynchronizedForwardInstructionMask (
1142+ InstructionMask SynchronizationObjectCoalescingAnalysis::GetUnsynchronizedForwardInstructionMask (
11301143 const llvm::Instruction* pSourceInst) const
11311144{
11321145 std::vector<const llvm::Instruction*> boundaryInstructions;
@@ -1143,7 +1156,7 @@ IGC::SynchronizationObjectCoalescingAnalysis::InstructionMask SynchronizationObj
11431156// / a substitute is not crossed by another substitute.
11441157// / @param pSourceInst the source synchronization instruction
11451158// / @param forwardDirection the direction of searching
1146- SynchronizationObjectCoalescingAnalysis:: InstructionMask SynchronizationObjectCoalescingAnalysis::GetInstructionMask (
1159+ InstructionMask SynchronizationObjectCoalescingAnalysis::GetInstructionMask (
11471160 const std::vector<const llvm::Instruction*>& input) const
11481161{
11491162 InstructionMask result = InstructionMask::None;
@@ -1554,6 +1567,7 @@ bool SynchronizationObjectCoalescingAnalysis::IsThreadBarrierOperation(const llv
15541567
15551568 return false ;
15561569}
1570+
15571571// //////////////////////////////////////////////////////////////////////
15581572bool SynchronizationObjectCoalescingAnalysis::IsUntypedMemoryFenceOperation (const llvm::Instruction* pInst)
15591573{
@@ -1569,7 +1583,6 @@ bool SynchronizationObjectCoalescingAnalysis::IsUntypedMemoryFenceOperation(cons
15691583 break ;
15701584 }
15711585 }
1572-
15731586 return false ;
15741587}
15751588
@@ -1600,7 +1613,7 @@ bool SynchronizationObjectCoalescingAnalysis::IsUntypedMemoryFenceOperationForGl
16001613}
16011614
16021615// //////////////////////////////////////////////////////////////////////
1603- SynchronizationObjectCoalescingAnalysis:: InstructionMask SynchronizationObjectCoalescingAnalysis::GetInstructionMask (const llvm::Instruction* pInst) const
1616+ InstructionMask SynchronizationObjectCoalescingAnalysis::GetInstructionMask (const llvm::Instruction* pInst) const
16041617{
16051618 if (IsAtomicOperation (pInst))
16061619 {
0 commit comments