Skip to content

Commit

Permalink
[H2BLB][TPC] Add the simple cst prop pass
Browse files Browse the repository at this point in the history
Customize the addition of IR passes in our implementation of TargetPassConfig.

This commit adds our custom simple constant propagation pass after all the
standard IR passes.
  • Loading branch information
qcolombet committed Jul 15, 2024
1 parent 69a6145 commit 5103e71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/lib/Target/H2BLB/H2BLBTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/MC/TargetRegistry.h" // For RegisterTargetMachine.
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CodeGen.h" // For CodeGenOptLevel.
#include "llvm/Support/Compiler.h" // For LLVM_EXTERNAL_VISIBILITY.
#include <memory>

Expand Down Expand Up @@ -109,3 +110,10 @@ bool H2BLBPassConfig::addInstSelector() {
// TODO: We need to hook up the DAG selector here.
return false;
}

void H2BLBPassConfig::addIRPasses() {
// Add the regular IR passes before putting our passes.
TargetPassConfig::addIRPasses();
if (getOptLevel() != CodeGenOptLevel::None)
addPass(createH2BLBSimpleConstantPropagationPassForLegacyPM());
}
1 change: 1 addition & 0 deletions llvm/lib/Target/H2BLB/H2BLBTargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class H2BLBPassConfig : public TargetPassConfig {
H2BLBPassConfig(LLVMTargetMachine &TM, PassManagerBase &PM);

bool addInstSelector() override;
void addIRPasses() override;
};

} // end namespace llvm
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/CodeGen/H2BLB/llc-pipeline.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; RUN: llc -O0 -mtriple h2blb %s -debug-pass=Structure --stop-before=peephole-opt -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0
; RUN: llc -O1 -mtriple h2blb %s -debug-pass=Structure --stop-before=peephole-opt -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-Opt
; RUN: llc -O2 -mtriple h2blb %s -debug-pass=Structure --stop-before=peephole-opt -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-Opt
; RUN: llc -O3 -mtriple h2blb %s -debug-pass=Structure --stop-before=peephole-opt -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-Opt

; Check that the H2BLB custom codegen pipeline includes the target specific
; simple constant propagation pass, but only when the optimizations are enabled.

; CHECK-O0-NOT: H2BLB simple constant propagation
; CHECK-Opt: H2BLB simple constant propagation

0 comments on commit 5103e71

Please sign in to comment.