Skip to content

Commit fa877fe

Browse files
committed
use X86PassRegistry
1 parent 607d900 commit fa877fe

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,22 @@ void X86TargetMachine::registerPassBuilderCallbacks(
5353
PassBuilder &PB, bool PopulateClassToPassNames) {
5454
if (PopulateClassToPassNames) {
5555
auto *PIC = PB.getPassInstrumentationCallbacks();
56-
PIC->addClassToPassName(X86ISelDAGToDAGPass::name(), "x86-isel");
56+
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
57+
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
58+
#include "X86PassRegistry.def"
5759
}
60+
61+
PB.registerPipelineParsingCallback(
62+
[this](StringRef Name, MachineFunctionPassManager &MFPM,
63+
ArrayRef<PassBuilder::PipelineElement>) {
64+
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
65+
if (Name == NAME) { \
66+
MFPM.addPass(CREATE_PASS); \
67+
return true; \
68+
}
69+
#include "X86PassRegistry.def"
70+
return false;
71+
});
5872
}
5973

6074
Error X86TargetMachine::buildCodeGenPipeline(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===- X86PassRegistry.def - Registry of X86 specific 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 X86 backend.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// NOTE: NO INCLUDE GUARD DESIRED!
14+
15+
#ifndef MACHINE_FUNCTION_PASS
16+
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
17+
#endif
18+
MACHINE_FUNCTION_PASS(X86ISelDAGToDAGPass, X86ISelDAGToDAGPass(*this))
19+
#undef MACHINE_FUNCTION_PASS

0 commit comments

Comments
 (0)