[AMDGPU][NPM] Port SIModeRegister to NPM (#129014)
This commit is contained in:
parent
82d111e820
commit
6c87ec4f4d
@ -352,6 +352,12 @@ public:
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
||||
};
|
||||
|
||||
class SIModeRegisterPass : public PassInfoMixin<SIModeRegisterPass> {
|
||||
public:
|
||||
SIModeRegisterPass() {}
|
||||
PreservedAnalyses run(MachineFunction &F, MachineFunctionAnalysisManager &AM);
|
||||
};
|
||||
|
||||
FunctionPass *createAMDGPUAnnotateUniformValuesLegacy();
|
||||
|
||||
ModulePass *createAMDGPUPrintfRuntimeBinding();
|
||||
@ -419,7 +425,7 @@ extern char &SIAnnotateControlFlowLegacyPassID;
|
||||
void initializeSIMemoryLegalizerPass(PassRegistry&);
|
||||
extern char &SIMemoryLegalizerID;
|
||||
|
||||
void initializeSIModeRegisterPass(PassRegistry&);
|
||||
void initializeSIModeRegisterLegacyPass(PassRegistry &);
|
||||
extern char &SIModeRegisterID;
|
||||
|
||||
void initializeAMDGPUInsertDelayAluLegacyPass(PassRegistry &);
|
||||
|
@ -112,6 +112,7 @@ MACHINE_FUNCTION_PASS("si-load-store-opt", SILoadStoreOptimizerPass())
|
||||
MACHINE_FUNCTION_PASS("si-lower-control-flow", SILowerControlFlowPass())
|
||||
MACHINE_FUNCTION_PASS("si-lower-sgpr-spills", SILowerSGPRSpillsPass())
|
||||
MACHINE_FUNCTION_PASS("si-lower-wwm-copies", SILowerWWMCopiesPass())
|
||||
MACHINE_FUNCTION_PASS("si-mode-register", SIModeRegisterPass())
|
||||
MACHINE_FUNCTION_PASS("si-opt-vgpr-liverange", SIOptimizeVGPRLiveRangePass())
|
||||
MACHINE_FUNCTION_PASS("si-optimize-exec-masking", SIOptimizeExecMaskingPass())
|
||||
MACHINE_FUNCTION_PASS("si-optimize-exec-masking-pre-ra", SIOptimizeExecMaskingPreRAPass())
|
||||
@ -131,7 +132,6 @@ DUMMY_MACHINE_FUNCTION_PASS("si-insert-hard-clauses", SIInsertHardClausesPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("si-insert-waitcnts", SIInsertWaitcntsPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("si-late-branch-lowering", SILateBranchLoweringPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("si-memory-legalizer", SIMemoryLegalizerPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("si-mode-register", SIModeRegisterPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("si-pre-emit-peephole", SIPreEmitPeepholePass())
|
||||
// TODO: Move amdgpu-preload-kern-arg-prolog to MACHINE_FUNCTION_PASS since it
|
||||
// already exists.
|
||||
|
@ -536,7 +536,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
|
||||
initializeAMDGPUInsertDelayAluLegacyPass(*PR);
|
||||
initializeSIInsertHardClausesPass(*PR);
|
||||
initializeSIInsertWaitcntsPass(*PR);
|
||||
initializeSIModeRegisterPass(*PR);
|
||||
initializeSIModeRegisterLegacyPass(*PR);
|
||||
initializeSIWholeQuadModeLegacyPass(*PR);
|
||||
initializeSILowerControlFlowLegacyPass(*PR);
|
||||
initializeSIPreEmitPeepholePass(*PR);
|
||||
|
@ -107,10 +107,8 @@ public:
|
||||
|
||||
namespace {
|
||||
|
||||
class SIModeRegister : public MachineFunctionPass {
|
||||
class SIModeRegister {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
std::vector<std::unique_ptr<BlockData>> BlockInfo;
|
||||
std::queue<MachineBasicBlock *> Phase2List;
|
||||
|
||||
@ -125,15 +123,7 @@ public:
|
||||
|
||||
bool Changed = false;
|
||||
|
||||
public:
|
||||
SIModeRegister() : MachineFunctionPass(ID) {}
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesCFG();
|
||||
MachineFunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
bool run(MachineFunction &MF);
|
||||
|
||||
void processBlockPhase1(MachineBasicBlock &MBB, const SIInstrInfo *TII);
|
||||
|
||||
@ -146,16 +136,32 @@ public:
|
||||
void insertSetreg(MachineBasicBlock &MBB, MachineInstr *I,
|
||||
const SIInstrInfo *TII, Status InstrMode);
|
||||
};
|
||||
|
||||
class SIModeRegisterLegacy : public MachineFunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
SIModeRegisterLegacy() : MachineFunctionPass(ID) {}
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesCFG();
|
||||
MachineFunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
};
|
||||
} // End anonymous namespace.
|
||||
|
||||
INITIALIZE_PASS(SIModeRegister, DEBUG_TYPE,
|
||||
INITIALIZE_PASS(SIModeRegisterLegacy, DEBUG_TYPE,
|
||||
"Insert required mode register values", false, false)
|
||||
|
||||
char SIModeRegister::ID = 0;
|
||||
char SIModeRegisterLegacy::ID = 0;
|
||||
|
||||
char &llvm::SIModeRegisterID = SIModeRegister::ID;
|
||||
char &llvm::SIModeRegisterID = SIModeRegisterLegacy::ID;
|
||||
|
||||
FunctionPass *llvm::createSIModeRegisterPass() { return new SIModeRegister(); }
|
||||
FunctionPass *llvm::createSIModeRegisterPass() {
|
||||
return new SIModeRegisterLegacy();
|
||||
}
|
||||
|
||||
// Determine the Mode register setting required for this instruction.
|
||||
// Instructions which don't use the Mode register return a null Status.
|
||||
@ -422,7 +428,20 @@ void SIModeRegister::processBlockPhase3(MachineBasicBlock &MBB,
|
||||
}
|
||||
}
|
||||
|
||||
bool SIModeRegister::runOnMachineFunction(MachineFunction &MF) {
|
||||
bool SIModeRegisterLegacy::runOnMachineFunction(MachineFunction &MF) {
|
||||
return SIModeRegister().run(MF);
|
||||
}
|
||||
|
||||
PreservedAnalyses SIModeRegisterPass::run(MachineFunction &MF,
|
||||
MachineFunctionAnalysisManager &AM) {
|
||||
if (!SIModeRegister().run(MF))
|
||||
return PreservedAnalyses::all();
|
||||
auto PA = getMachineFunctionPassPreservedAnalyses();
|
||||
PA.preserveSet<CFGAnalyses>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
bool SIModeRegister::run(MachineFunction &MF) {
|
||||
// Constrained FP intrinsics are used to support non-default rounding modes.
|
||||
// strictfp attribute is required to mark functions with strict FP semantics
|
||||
// having constrained FP intrinsics. This pass fixes up operations that uses
|
||||
|
@ -1,5 +1,6 @@
|
||||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
|
||||
# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=-real-true16 -run-pass si-mode-register %s -o - | FileCheck %s --check-prefixes=GFX11
|
||||
# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=-real-true16 -passes si-mode-register %s -o - | FileCheck %s --check-prefixes=GFX11
|
||||
|
||||
---
|
||||
name: ftrunc_tonearest
|
||||
|
@ -1,4 +1,5 @@
|
||||
# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -run-pass si-mode-register %s -o - | FileCheck %s
|
||||
# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -passes=si-mode-register %s -o - | FileCheck %s
|
||||
|
||||
---
|
||||
# check that the mode is changed to rtz from default rtn for interp f16
|
||||
|
Loading…
x
Reference in New Issue
Block a user