diff options
author | Matin Raayai <30674652+matinraayai@users.noreply.github.com> | 2024-11-14 21:30:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-14 13:30:05 -0800 |
commit | bb3f5e1fed7c6ba733b7f273e93f5d3930976185 (patch) | |
tree | af92c80fb891c44540b7a2a62dfd2859ef26bff5 /llvm/lib/CodeGen/MachineModuleInfo.cpp | |
parent | 5d16fbc275d57b88866a2606453ead6a024ffee0 (diff) | |
download | llvm-bb3f5e1fed7c6ba733b7f273e93f5d3930976185.zip llvm-bb3f5e1fed7c6ba733b7f273e93f5d3930976185.tar.gz llvm-bb3f5e1fed7c6ba733b7f273e93f5d3930976185.tar.bz2 |
Overhaul the TargetMachine and LLVMTargetMachine Classes (#111234)
Following discussions in #110443, and the following earlier discussions
in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html,
https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this
PR attempts to overhaul the `TargetMachine` and `LLVMTargetMachine`
interface classes. More specifically:
1. Makes `TargetMachine` the only class implemented under
`TargetMachine.h` in the `Target` library.
2. `TargetMachine` contains target-specific interface functions that
relate to IR/CodeGen/MC constructs, whereas before (at least on paper)
it was supposed to have only IR/MC constructs. Any Target that doesn't
want to use the independent code generator simply does not implement
them, and returns either `false` or `nullptr`.
3. Renames `LLVMTargetMachine` to `CodeGenCommonTMImpl`. This renaming
aims to make the purpose of `LLVMTargetMachine` clearer. Its interface
was moved under the CodeGen library, to further emphasis its usage in
Targets that use CodeGen directly.
4. Makes `TargetMachine` the only interface used across LLVM and its
projects. With these changes, `CodeGenCommonTMImpl` is simply a set of
shared function implementations of `TargetMachine`, and CodeGen users
don't need to static cast to `LLVMTargetMachine` every time they need a
CodeGen-specific feature of the `TargetMachine`.
5. More importantly, does not change any requirements regarding library
linking.
cc @arsenm @aeubanks
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index c664959..6167e99 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -48,7 +48,7 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI) TheModule = MMI.TheModule; } -MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM) +MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM) : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(), TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(), nullptr, &TM->Options.MCOptions, false) { @@ -56,7 +56,7 @@ MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM) initialize(); } -MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM, +MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM, MCContext *ExtContext) : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(), TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(), @@ -151,13 +151,13 @@ FunctionPass *llvm::createFreeMachineFunctionPass() { } MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass( - const LLVMTargetMachine *TM) + const TargetMachine *TM) : ImmutablePass(ID), MMI(TM) { initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry()); } MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass( - const LLVMTargetMachine *TM, MCContext *ExtContext) + const TargetMachine *TM, MCContext *ExtContext) : ImmutablePass(ID), MMI(TM, ExtContext) { initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry()); } |