Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NewPM][CodeGen][llc] Add NPM support (#70922)
Add new pass manager support to `llc`. Users can use `--passes=pass1,pass2...` to run mir passes, and use `--enable-new-pm` to run default codegen pipeline. This patch is taken from [D83612](https://reviews.llvm.org/D83612), the original author is @yuanfang-chen. --------- Co-authored-by: Yuanfang Chen <455423+yuanfang-chen@users.noreply.github.com>
- Loading branch information
1 parent
c663c8b
commit 7e50f00
Showing
17 changed files
with
411 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//===-- X86CodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// \file | ||
/// This file contains X86 CodeGen pipeline builder. | ||
/// TODO: Port CodeGen passes to new pass manager. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "X86TargetMachine.h" | ||
|
||
#include "llvm/CodeGen/CodeGenPassBuilder.h" | ||
#include "llvm/MC/MCStreamer.h" | ||
|
||
using namespace llvm; | ||
|
||
namespace { | ||
|
||
class X86CodeGenPassBuilder : public CodeGenPassBuilder<X86CodeGenPassBuilder> { | ||
public: | ||
explicit X86CodeGenPassBuilder(LLVMTargetMachine &TM, | ||
CGPassBuilderOption Opts, | ||
PassInstrumentationCallbacks *PIC) | ||
: CodeGenPassBuilder(TM, Opts, PIC) {} | ||
void addPreISel(AddIRPass &addPass) const; | ||
void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const; | ||
Error addInstSelector(AddMachinePass &) const; | ||
}; | ||
|
||
void X86CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const { | ||
// TODO: Add passes pre instruction selection. | ||
} | ||
|
||
void X86CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass, | ||
CreateMCStreamer) const { | ||
// TODO: Add AsmPrinter. | ||
} | ||
|
||
Error X86CodeGenPassBuilder::addInstSelector(AddMachinePass &) const { | ||
// TODO: Add instruction selector. | ||
return Error::success(); | ||
} | ||
|
||
} // namespace | ||
|
||
Error X86TargetMachine::buildCodeGenPipeline( | ||
ModulePassManager &MPM, MachineFunctionPassManager &MFPM, | ||
MachineFunctionAnalysisManager &, raw_pwrite_stream &Out, | ||
raw_pwrite_stream *DwoOut, CodeGenFileType FileType, | ||
CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) { | ||
auto CGPB = X86CodeGenPassBuilder(*this, Opt, PIC); | ||
return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
if not "X86" in config.root.targets: | ||
config.unsupported = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
; RUN: not llc -mtriple=x86_64-pc-linux-gnu -passes=foo -start-before=mergeicmps -stop-after=gc-lowering -filetype=null %s 2>&1 | FileCheck %s | ||
|
||
; CHECK: warning: --passes cannot be used with start-before and stop-after. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
; RUN: llc -mtriple=x86_64-pc-linux-gnu -enable-new-pm -print-pipeline-passes -filetype=null %s | FileCheck %s | ||
|
||
; CHECK: require<profile-summary>,require<collector-metadata> | ||
; CHECK: MachineSanitizerBinaryMetadata,FreeMachineFunctionPass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
; RUN: llc -mtriple=x86_64-pc-linux-gnu -enable-new-pm -print-pipeline-passes -start-before=mergeicmps -stop-after=gc-lowering -filetype=null %s | FileCheck --match-full-lines %s | ||
|
||
; CHECK: IR pipeline: function(mergeicmps,expand-memcmp,gc-lowering) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.