Skip to content

Commit fe025b4

Browse files
committed
[AArch64] Add AArch64PassRegistry.def
1 parent 5f77461 commit fe025b4

File tree

5 files changed

+67
-9
lines changed

5 files changed

+67
-9
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//===-- AArch64CodeGenPassBuilder.cpp -----------------------------*- C++ -*-=//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
/// \file
9+
/// This file contains AArch64 CodeGen pipeline builder.
10+
/// TODO: Port CodeGen passes to new pass manager.
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "AArch64LoopIdiomTransform.h"
14+
#include "AArch64TargetMachine.h"
15+
#include "llvm/Passes/CodeGenPassBuilder.h"
16+
#include "llvm/Passes/PassBuilder.h"
17+
18+
void AArch64TargetMachine::registerPassBuilderCallbacks(
19+
PassBuilder &PB, bool PopulateClassToPassNames) {
20+
if (PopulateClassToPassNames) {
21+
auto *PIC = PB.getPassInstrumentationCallbacks();
22+
#define LOOP_PASS(NAME, CREATE_PASS) \
23+
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
24+
#include "AArch64PassRegistry.def"
25+
}
26+
27+
PB.registerPipelineParsingCallback(
28+
[](StringRef Name, LoopPassManager &LPM,
29+
ArrayRef<PassBuilder::PipelineElement>) {
30+
#define LOOP_PASS(NAME, CREATE_PASS) \
31+
if (Name == NAME) { \
32+
LPM.addPass(CREATE_PASS); \
33+
return true; \
34+
}
35+
#include "AArch64PassRegistry.def"
36+
return false;
37+
});
38+
39+
PB.registerLateLoopOptimizationsEPCallback(
40+
[=](LoopPassManager &LPM, OptimizationLevel Level) {
41+
LPM.addPass(AArch64LoopIdiomTransformPass());
42+
});
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===- AArch64PassRegistry.def - Registry of AArch64 passes -----*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file is used as the registry of passes that are part of the
10+
// AArch64 backend.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
// NOTE: NO INCLUDE GUARD DESIRED!
15+
16+
#ifndef LOOP_PASS
17+
#define LOOP_PASS(NAME, CREATE_PASS)
18+
#endif
19+
LOOP_PASS("aarch64-lit", AArch64LoopIdiomTransformPass())
20+
#undef LOOP_PASS

llvm/lib/Target/AArch64/AArch64TargetMachine.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "AArch64TargetMachine.h"
1313
#include "AArch64.h"
14-
#include "AArch64LoopIdiomTransform.h"
1514
#include "AArch64MachineFunctionInfo.h"
1615
#include "AArch64MachineScheduler.h"
1716
#include "AArch64MacroFusion.h"
@@ -545,14 +544,6 @@ class AArch64PassConfig : public TargetPassConfig {
545544

546545
} // end anonymous namespace
547546

548-
void AArch64TargetMachine::registerPassBuilderCallbacks(
549-
PassBuilder &PB, bool PopulateClassToPassNames) {
550-
PB.registerLateLoopOptimizationsEPCallback(
551-
[=](LoopPassManager &LPM, OptimizationLevel Level) {
552-
LPM.addPass(AArch64LoopIdiomTransformPass());
553-
});
554-
}
555-
556547
TargetTransformInfo
557548
AArch64TargetMachine::getTargetTransformInfo(const Function &F) const {
558549
return TargetTransformInfo(AArch64TTIImpl(this, F));

llvm/lib/Target/AArch64/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ add_llvm_target(AArch64CodeGen
4747
AArch64BranchTargets.cpp
4848
AArch64CallingConvention.cpp
4949
AArch64CleanupLocalDynamicTLSPass.cpp
50+
AArch64CodeGenPassBuilder.cpp
5051
AArch64CollectLOH.cpp
5152
AArch64CondBrTuning.cpp
5253
AArch64ConditionalCompares.cpp

llvm/test/Transforms/LoopIdiom/AArch64/byte-compare-index.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
; RUN: opt -aarch64-lit -aarch64-lit-verify -verify-dom-info -mtriple aarch64-unknown-linux-gnu -mattr=+sve -S < %s | FileCheck %s
33
; RUN: opt -aarch64-lit -simplifycfg -mtriple aarch64-unknown-linux-gnu -mattr=+sve -S < %s | FileCheck %s --check-prefix=LOOP-DEL
44
; RUN: opt -aarch64-lit -mtriple aarch64-unknown-linux-gnu -S < %s | FileCheck %s --check-prefix=NO-TRANSFORM
5+
; RUN: opt -p aarch64-lit -aarch64-lit-verify -verify-dom-info -mtriple aarch64-unknown-linux-gnu -mattr=+sve -S < %s | FileCheck %s
6+
; RUN: opt -p aarch64-lit -simplifycfg -mtriple aarch64-unknown-linux-gnu -mattr=+sve -S < %s | FileCheck %s --check-prefix=LOOP-DEL
7+
; RUN: opt -p aarch64-lit -mtriple aarch64-unknown-linux-gnu -S < %s | FileCheck %s --check-prefix=NO-TRANSFORM
58

69
define i32 @compare_bytes_simple(ptr %a, ptr %b, i32 %len, i32 %extra, i32 %n) {
710
; CHECK-LABEL: define i32 @compare_bytes_simple(

0 commit comments

Comments
 (0)