[NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen pipeline
authorYuanfang Chen <yuanfang.chen@sony.com>
Tue, 29 Dec 2020 00:56:11 +0000 (16:56 -0800)
committerYuanfang Chen <yuanfang.chen@sony.com>
Tue, 29 Dec 2020 01:36:36 +0000 (17:36 -0800)
commit4646de5d75cfce3da4ddeffb6eb8e66e38238800
treed8e59b76fcdb51504a3f2ebaa7ac4ee6694d4c68
parentf782d5ea86f6fc82b51a0de688bf292f39cc4814
[NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen pipeline

Following up on D67687.
Please refer to the RFC here http://lists.llvm.org/pipermail/llvm-dev/2020-July/143309.html

`CodeGenPassBuilder` is the NPM counterpart of `TargetPassConfig` with below differences.
- Debugging features (MIR print/verify, disable pass, start/stop-before/after, etc.) living in `TargetPassConfig` are moved to use PassInstrument as much as possible. (Implementation also lives in `TargetPassConfig.cpp`)
- `TargetPassConfig` is a polymorphic base (virtual inheritance) to build the target-dependent pipeline whereas `CodeGenPassBuilder` is the CRTP base/helper to implement the target-dependent pipeline. The motivation is flexibility for targets to customize the pipeline, inlining opportunity, and fits the overall NPM value semantics design.
- `TargetPassConfig` is a legacy immutable pass to declare hooks for targets to customize some target-independent codegen layer behavior. This is partially ported to TargetMachine::options. The rest, such as `createMachineScheduler/createPostMachineScheduler`, are left out for now. They should be implemented in LLVMTargetMachine in the future.

Reviewed By: arsenm, aeubanks

Differential Revision: https://reviews.llvm.org/D83608
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h [new file with mode: 0644]
llvm/include/llvm/CodeGen/MachinePassRegistry.def [new file with mode: 0644]
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/Target/CGPassBuilderOption.h [new file with mode: 0644]
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGenPassBuilder.cpp [new file with mode: 0644]
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp