Skip to content

Commit d12bb9f

Browse files
vsemenov368igcbot
authored andcommitted
Clean up
.
1 parent 19e0d6e commit d12bb9f

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPromoteStatefulToBindless.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SPDX-License-Identifier: MIT
3636
/// samplers can be easily added here.
3737

3838
#include "GenX.h"
39+
#include "GenXSubtarget.h"
3940
#include "GenXTargetMachine.h"
4041

4142
#include "vc/Support/BackendConfig.h"
@@ -46,16 +47,20 @@ SPDX-License-Identifier: MIT
4647
#include "llvm/GenXIntrinsics/GenXIntrinsics.h"
4748
#include "llvm/GenXIntrinsics/GenXMetadata.h"
4849

50+
#include "visa_igc_common_header.h"
51+
4952
#include "Probe/Assertion.h"
5053

5154
#include <llvm/ADT/SmallVector.h>
5255
#include <llvm/ADT/StringRef.h>
5356
#include <llvm/ADT/Twine.h>
57+
#include <llvm/CodeGen/TargetPassConfig.h>
5458
#include <llvm/IR/Function.h>
5559
#include <llvm/IR/GlobalVariable.h>
5660
#include <llvm/IR/IRBuilder.h>
5761
#include <llvm/IR/InstIterator.h>
5862
#include <llvm/IR/Module.h>
63+
#include <llvm/InitializePasses.h>
5964
#include <llvm/Pass.h>
6065
#include <llvm/Support/ErrorHandling.h>
6166

@@ -69,10 +74,12 @@ class PromoteToBindless {
6974
Module &M;
7075
const GenXBackendConfig &BC;
7176
GlobalVariable *BSS = nullptr;
77+
const GenXSubtarget &ST;
7278

7379
public:
74-
PromoteToBindless(Module &InM, const GenXBackendConfig &InBC)
75-
: M{InM}, BC{InBC} {}
80+
PromoteToBindless(Module &InM, const GenXBackendConfig &InBC,
81+
const GenXSubtarget &InST)
82+
: M{InM}, BC{InBC}, ST(InST) {}
7683

7784
bool run();
7885

@@ -97,6 +104,7 @@ class GenXPromoteStatefulToBindless final : public ModulePass {
97104
GenXPromoteStatefulToBindless() : ModulePass(ID) {}
98105

99106
void getAnalysisUsage(AnalysisUsage &AU) const override {
107+
AU.addRequired<TargetPassConfig>();
100108
AU.addRequired<GenXBackendConfig>();
101109
}
102110

@@ -114,6 +122,7 @@ INITIALIZE_PASS_BEGIN(GenXPromoteStatefulToBindless,
114122
"GenXPromoteStatefulToBindless",
115123
"GenXPromoteStatefulToBindless", false, false);
116124
INITIALIZE_PASS_DEPENDENCY(GenXBackendConfig)
125+
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
117126
INITIALIZE_PASS_END(GenXPromoteStatefulToBindless,
118127
"GenXPromoteStatefulToBindless",
119128
"GenXPromoteStatefulToBindless", false, false);
@@ -128,7 +137,11 @@ ModulePass *createGenXPromoteStatefulToBindlessPass() {
128137
bool GenXPromoteStatefulToBindless::runOnModule(Module &M) {
129138
auto &BC = getAnalysis<GenXBackendConfig>();
130139

131-
PromoteToBindless PTM{M, BC};
140+
const GenXSubtarget &ST = getAnalysis<TargetPassConfig>()
141+
.getTM<GenXTargetMachine>()
142+
.getGenXSubtarget();
143+
144+
PromoteToBindless PTM{M, BC, ST};
132145

133146
return PTM.run();
134147
}
@@ -441,7 +454,9 @@ PromoteToBindless::createBindlessSurfaceDataportIntrinsicChain(CallInst &CI) {
441454

442455
// Get bindless version of given bti lsc intrinsic.
443456
static vc::InternalIntrinsic::ID
444-
getBindlessLscIntrinsicID(vc::InternalIntrinsic::ID IID) {
457+
getBindlessLscIntrinsicID(vc::InternalIntrinsic::ID IID,
458+
const GenXSubtarget &ST) {
459+
445460
#define MAP(INTR) \
446461
case vc::InternalIntrinsic::INTR##_bti: \
447462
return vc::InternalIntrinsic::INTR##_bss
@@ -468,15 +483,18 @@ getBindlessLscIntrinsicID(vc::InternalIntrinsic::ID IID) {
468483
// intrinsics. Lsc intrinsics have special addressing mode operand so
469484
// there is no need to use %bss variable and SSO goes directly to lsc
470485
// instruction.
471-
static CallInst *createBindlessLscIntrinsic(CallInst &CI) {
486+
static CallInst *createBindlessLscIntrinsic(CallInst &CI,
487+
const GenXSubtarget &ST) {
472488
const auto ID = vc::InternalIntrinsic::getInternalIntrinsicID(&CI);
473-
const auto NewId = getBindlessLscIntrinsicID(ID);
489+
const auto NewId = getBindlessLscIntrinsicID(ID, ST);
474490

475-
auto *Decl = vc::getInternalDeclarationForIdFromArgs(CI.getType(), CI.args(),
491+
SmallVector<Value *, 16> Args{CI.args()};
492+
IRBuilder<> IRB{&CI};
493+
494+
495+
auto *Decl = vc::getInternalDeclarationForIdFromArgs(CI.getType(), Args,
476496
NewId, *CI.getModule());
477497

478-
IRBuilder<> IRB{&CI};
479-
SmallVector<Value *, 16> Args{CI.args()};
480498
return IRB.CreateCall(Decl->getFunctionType(), Decl, Args, CI.getName());
481499
}
482500

@@ -521,7 +539,7 @@ void PromoteToBindless::rewriteBufferIntrinsic(CallInst &CI) {
521539
case vc::InternalIntrinsic::lsc_prefetch_quad_bti:
522540
case vc::InternalIntrinsic::lsc_store_bti:
523541
case vc::InternalIntrinsic::lsc_store_quad_bti:
524-
BindlessCI = createBindlessLscIntrinsic(CI);
542+
BindlessCI = createBindlessLscIntrinsic(CI, ST);
525543
break;
526544
}
527545

IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,8 @@ void GenXTargetMachine::adjustPassManager(PassManagerBuilder &PMBuilder) {
973973
PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, AddCMABI);
974974

975975
// BTI assignment.
976-
auto AddBTIAssign = [](const PassManagerBuilder &Builder,
977-
PassManagerBase &PM) {
976+
auto AddBTIAssign = [this](const PassManagerBuilder &Builder,
977+
PassManagerBase &PM) {
978978
PM.add(createGenXBTIAssignmentPass());
979979
};
980980
PMBuilder.addExtension(PassManagerBuilder::EP_ModuleOptimizerEarly,

IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXBTIAssignment.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ SPDX-License-Identifier: MIT
3030

3131
#include "llvmWrapper/ADT/StringRef.h"
3232

33-
#include <llvm/Support/CommandLine.h>
3433
#include <llvm/ADT/StringRef.h>
3534
#include <llvm/IR/Function.h>
3635
#include <llvm/IR/IRBuilder.h>
3736
#include <llvm/IR/Metadata.h>
3837
#include <llvm/IR/Module.h>
3938
#include <llvm/Pass.h>
39+
#include <llvm/Support/CommandLine.h>
4040

4141
#include <tuple>
4242
#include <utility>
@@ -51,11 +51,14 @@ static cl::opt<bool> EnforceBTIZeroReservation(
5151
namespace {
5252
class BTIAssignment final {
5353
Module &M;
54-
const GenXBackendConfig &BC;
54+
const bool emitDebuggableKernels;
55+
const bool useBindlessBuffers;
5556

5657
public:
57-
BTIAssignment(Module &InM, const GenXBackendConfig &InBC)
58-
: M(InM), BC(InBC) {}
58+
BTIAssignment(Module &InM, bool InEmitDebuggableKernels,
59+
bool InUseBindlessBuffers)
60+
: M(InM), emitDebuggableKernels(InEmitDebuggableKernels),
61+
useBindlessBuffers(InUseBindlessBuffers) {}
5962

6063
bool run();
6164

@@ -79,6 +82,7 @@ class BTIAssignment final {
7982
};
8083

8184
class GenXBTIAssignment final : public ModulePass {
85+
8286
public:
8387
static char ID;
8488

@@ -111,7 +115,11 @@ ModulePass *createGenXBTIAssignmentPass() {
111115

112116
bool GenXBTIAssignment::runOnModule(Module &M) {
113117
auto &BC = getAnalysis<GenXBackendConfig>();
114-
BTIAssignment BA(M, BC);
118+
bool emitDebuggableKernels = BC.emitDebuggableKernelsForLegacyPath();
119+
bool useBindlessBuffers = BC.useBindlessBuffers();
120+
121+
122+
BTIAssignment BA(M, emitDebuggableKernels, useBindlessBuffers);
115123

116124
return BA.run();
117125
}
@@ -212,7 +220,7 @@ std::vector<int> BTIAssignment::computeBTIndices(
212220
int SurfaceID = 0;
213221
int SamplerID = 0;
214222

215-
if (BC.emitDebuggableKernelsForLegacyPath() || EnforceBTIZeroReservation) {
223+
if (emitDebuggableKernels || EnforceBTIZeroReservation) {
216224
// NOTE: at the current moment we don't use BTI=0, since it is reserved
217225
// for kernel debugging purposes (SIP uses BTI=0 in order to handle
218226
// breakpoints).
@@ -253,7 +261,7 @@ bool BTIAssignment::rewriteArguments(
253261
continue;
254262

255263
// For bindless resource argument is ExBSO.
256-
if (BC.useBindlessBuffers() && vc::isDescBufferType(Desc))
264+
if (useBindlessBuffers && vc::isDescBufferType(Desc))
257265
continue;
258266

259267
IGC_ASSERT_MESSAGE(BTI >= 0, "unassigned BTI");

IGC/VectorCompiler/test/PromoteToBindless/dataport_reserved_surfaces.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
; RUN: %opt %use_old_pass_manager% -GenXPromoteStatefulToBindless -vc-use-bindless-buffers -march=genx64 -mcpu=Gen9 -S < %s | FileCheck %s
1212

13+
target triple = "spir64-unknown-unknown"
14+
1315
declare <8 x i32> @llvm.genx.oword.ld.v8i32(i32, i32, i32)
1416

1517
declare void @sink.v8i32(<8 x i32>)

0 commit comments

Comments
 (0)