Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AArch64][NPM] Chalk out the CodeGenPassBuilder for NPM #128471

Merged
merged 1 commit into from
Feb 25, 2025
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
32 changes: 32 additions & 0 deletions llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Pass.h"
#include "llvm/Passes/CodeGenPassBuilder.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
Expand Down Expand Up @@ -562,8 +563,39 @@ class AArch64PassConfig : public TargetPassConfig {
std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
};

class AArch64CodeGenPassBuilder
: public CodeGenPassBuilder<AArch64CodeGenPassBuilder,
AArch64TargetMachine> {
using Base =
CodeGenPassBuilder<AArch64CodeGenPassBuilder, AArch64TargetMachine>;

public:
AArch64CodeGenPassBuilder(AArch64TargetMachine &TM,
const CGPassBuilderOption &Opts,
PassInstrumentationCallbacks *PIC)
: CodeGenPassBuilder(TM, Opts, PIC) {}
void addPreISel(AddIRPass &) const {
// TODO: Add pre-isel passes
}
void addAsmPrinter(AddMachinePass &addPass, CreateMCStreamer) const {
// TODO: Add asm printer passes
}
Error addInstSelector(AddMachinePass &) const {
// TODO: Add instruction selector passes
return Error::success();
}
};

} // end anonymous namespace

Error AArch64TargetMachine::buildCodeGenPipeline(
ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
CodeGenFileType FileType, const CGPassBuilderOption &Opts,
PassInstrumentationCallbacks *PIC) {
AArch64CodeGenPassBuilder Builder(*this, Opts, PIC);
return Builder.buildPipeline(MPM, Out, DwoOut, FileType);
}

void AArch64TargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {

PB.registerLateLoopOptimizationsEPCallback(
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/AArch64/AArch64TargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class AArch64TargetMachine : public CodeGenTargetMachineImpl {
// Pass Pipeline Configuration
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;

Error buildCodeGenPipeline(ModulePassManager &MPM, raw_pwrite_stream &Out,
raw_pwrite_stream *DwoOut,
CodeGenFileType FileType,
const CGPassBuilderOption &Opts,
PassInstrumentationCallbacks *PIC) override;

void registerPassBuilderCallbacks(PassBuilder &PB) override;

TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
# RUN: llc -start-before=machine-latecleanup -stop-after=machine-latecleanup \
# RUN: -o - %s | FileCheck %s

# RUN: llc -enable-new-pm -passes=machine-latecleanup \
# RUN: -o - %s | FileCheck %s
--- |
; ModuleID = 'reduced5.ll'
source_filename = "reduced5.ll"
Expand Down
Loading