Skip to content
Open
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
11 changes: 9 additions & 2 deletions llvm/lib/Target/NVPTX/NVPTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FunctionPass *createNVPTXTagInvariantLoadsPass();
FunctionPass *createNVPTXIRPeepholePass();
MachineFunctionPass *createNVPTXPeephole();
MachineFunctionPass *createNVPTXProxyRegErasurePass();
MachineFunctionPass *createNVPTXForwardParamsPass();
MachineFunctionPass *createNVPTXForwardParamsLegacyPass();
MachineFunctionPass *createNVPTXAddressFolderPass();

void initializeNVVMReflectLegacyPassPass(PassRegistry &);
Expand All @@ -77,7 +77,7 @@ void initializeNVPTXLowerUnreachablePass(PassRegistry &);
void initializeNVPTXLowerArgsLegacyPassPass(PassRegistry &);
void initializeNVPTXPromoteParamAlignLegacyPassPass(PassRegistry &);
void initializeNVPTXProxyRegErasurePass(PassRegistry &);
void initializeNVPTXForwardParamsPassPass(PassRegistry &);
void initializeNVPTXForwardParamsLegacyPassPass(PassRegistry &);
void initializeNVPTXAddressFolderPassPass(PassRegistry &);
void initializeNVVMIntrRangePass(PassRegistry &);
void initializeNVVMReflectPass(PassRegistry &);
Expand Down Expand Up @@ -143,6 +143,13 @@ class NVPTXISelDAGToDAGPass : public SelectionDAGISelPass {
NVPTXISelDAGToDAGPass(NVPTXTargetMachine &TM, CodeGenOptLevel OptLevel);
};

class NVPTXForwardParamsPass
: public RequiredPassInfoMixin<NVPTXForwardParamsPass> {
public:
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
};

namespace NVPTX {
enum DrvInterface {
NVCL,
Expand Down
24 changes: 15 additions & 9 deletions llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,33 @@ static bool forwardDeviceParams(MachineFunction &MF) {
/// ----------------------------------------------------------------------------

namespace {
struct NVPTXForwardParamsPass : public MachineFunctionPass {
struct NVPTXForwardParamsLegacyPass : public MachineFunctionPass {

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.

In other portings I've been dropping the Pass suffix at the end so that the initialize* functions don't have the PassPass wording, although it probably doesn't matter too much given all of that should be going away eventually anyways.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree "PassPass" is a bit weird but looking at llvm/include/llvm/InitializePasses.h I see a lot of occurrences of both forms. I'm going to leave as is since hopefully we'll be removing these soon.

static char ID;
NVPTXForwardParamsPass() : MachineFunctionPass(ID) {}
NVPTXForwardParamsLegacyPass() : MachineFunctionPass(ID) {}

bool runOnMachineFunction(MachineFunction &MF) override;
bool runOnMachineFunction(MachineFunction &MF) override {
return forwardDeviceParams(MF);
}

void getAnalysisUsage(AnalysisUsage &AU) const override {
MachineFunctionPass::getAnalysisUsage(AU);
}
};
} // namespace

char NVPTXForwardParamsPass::ID = 0;
char NVPTXForwardParamsLegacyPass::ID = 0;

INITIALIZE_PASS(NVPTXForwardParamsPass, "nvptx-forward-params",
INITIALIZE_PASS(NVPTXForwardParamsLegacyPass, "nvptx-forward-params",
"NVPTX Forward Params", false, false)

bool NVPTXForwardParamsPass::runOnMachineFunction(MachineFunction &MF) {
return forwardDeviceParams(MF);
MachineFunctionPass *llvm::createNVPTXForwardParamsLegacyPass() {
return new NVPTXForwardParamsLegacyPass();
}

MachineFunctionPass *llvm::createNVPTXForwardParamsPass() {
return new NVPTXForwardParamsPass();
PreservedAnalyses
NVPTXForwardParamsPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
if (!forwardDeviceParams(MF))
return PreservedAnalyses::all();
return getMachineFunctionPassPreservedAnalyses().preserveSet<CFGAnalyses>();
}
1 change: 1 addition & 0 deletions llvm/lib/Target/NVPTX/NVPTXPassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ FUNCTION_PASS("nvptx-ir-peephole", NVPTXIRPeepholePass())
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
#endif
MACHINE_FUNCTION_PASS("nvptx-isel", NVPTXISelDAGToDAGPass(*this, getOptLevel()))
MACHINE_FUNCTION_PASS("nvptx-forward-params", NVPTXForwardParamsPass())
#undef MACHINE_FUNCTION_PASS
4 changes: 2 additions & 2 deletions llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTarget() {
initializeNVPTXCtorDtorLoweringLegacyPass(PR);
initializeNVPTXLowerAggrCopiesPass(PR);
initializeNVPTXProxyRegErasurePass(PR);
initializeNVPTXForwardParamsPassPass(PR);
initializeNVPTXForwardParamsLegacyPassPass(PR);
initializeNVPTXAddressFolderPassPass(PR);
initializeNVPTXDAGToDAGISelLegacyPass(PR);
initializeNVPTXAAWrapperPassPass(PR);
Expand Down Expand Up @@ -410,7 +410,7 @@ bool NVPTXPassConfig::addInstSelector() {
}

void NVPTXPassConfig::addPreRegAlloc() {
addPass(createNVPTXForwardParamsPass());
addPass(createNVPTXForwardParamsLegacyPass());
if (getOptLevel() != CodeGenOptLevel::None)
addPass(createNVPTXAddressFolderPass());
// Remove Proxy Register pseudo instructions used to keep `callseq_end` alive.
Expand Down