Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions llvm/include/llvm/Passes/TargetPassRegistry.inc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ if (PIC) {
return true; \
}

#define ADD_ANALYSIS_PASS(NAME, CREATE_PASS) \
if (Name == "invalidate<" NAME ">") { \
PM.addPass(InvalidateAnalysisPass< \
std::remove_reference_t<decltype(CREATE_PASS)>>()); \
return true; \
} \
if (Name == "require<" NAME ">") { \
PM.addPass( \
RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
MachineFunction>()); \
return true; \
}

PB.registerPipelineParsingCallback([=](StringRef Name, ModulePassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
#define MODULE_PASS(NAME, CREATE_PASS) ADD_PASS(NAME, CREATE_PASS)
Expand Down Expand Up @@ -151,6 +164,16 @@ PB.registerPipelineParsingCallback([=](StringRef Name, FunctionPassManager &PM,
return false;
});

PB.registerPipelineParsingCallback([=](StringRef Name,
MachineFunctionPassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
ADD_ANALYSIS_PASS(NAME, CREATE_PASS)
#include GET_PASS_REGISTRY
#undef MACHINE_FUNCTION_ANALYSIS
return false;
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implementation is for machine function analysis only, target like DirectX has some IR analyses, so it is worth to support other IR kinds.
Maybe we could introduce something like <IRUnit>PassManager::IRUnitT to simplifiy it, but this is out of scope for this pr.

#undef ADD_PASS
#undef ADD_PASS_WITH_PARAMS

Expand Down
13 changes: 13 additions & 0 deletions llvm/test/CodeGen/AMDGPU/new-pm-machine-analysis.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# RUN: llc -mtriple=amdgcn \
# RUN: "-passes=require<amdgpu-resource-usage>,invalidate<amdgpu-resource-usage>" \
Comment thread
macurtis-amd marked this conversation as resolved.
# RUN: --print-pipeline-passes --filetype=null %s | FileCheck %s

# CHECK: machine-function(require<amdgpu-resource-usage>,invalidate<amdgpu-resource-usage>)
---
name: test
body: |
bb.0:
S_NOP 0
...