xref: /llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.h (revision 8b04c0d26a21c724a82aa1c2ac7ab9c0b90b5f7c)
1 //===-- PPCTargetMachine.h - Define TargetMachine for PowerPC ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the PowerPC specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
16 
17 #include "PPCInstrInfo.h"
18 #include "PPCSubtarget.h"
19 #include "llvm/IR/DataLayout.h"
20 #include "llvm/Target/TargetMachine.h"
21 
22 namespace llvm {
23 
24 /// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
25 ///
26 class PPCTargetMachine : public LLVMTargetMachine {
27   std::unique_ptr<TargetLoweringObjectFile> TLOF;
28   // Calculates type size & alignment
29   const DataLayout DL;
30   PPCSubtarget Subtarget;
31 
32   mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
33 
34 public:
35   PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
36                    const TargetOptions &Options, Reloc::Model RM,
37                    CodeModel::Model CM, CodeGenOpt::Level OL);
38 
39   ~PPCTargetMachine() override;
40 
41   const DataLayout *getDataLayout() const override { return &DL; }
42   const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; }
43   const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
44 
45   // Pass Pipeline Configuration
46   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
47 
48   TargetIRAnalysis getTargetIRAnalysis() override;
49 
50   TargetLoweringObjectFile *getObjFileLowering() const override {
51     return TLOF.get();
52   }
53 };
54 
55 /// PPC32TargetMachine - PowerPC 32-bit target machine.
56 ///
57 class PPC32TargetMachine : public PPCTargetMachine {
58   virtual void anchor();
59 public:
60   PPC32TargetMachine(const Target &T, StringRef TT,
61                      StringRef CPU, StringRef FS, const TargetOptions &Options,
62                      Reloc::Model RM, CodeModel::Model CM,
63                      CodeGenOpt::Level OL);
64 };
65 
66 /// PPC64TargetMachine - PowerPC 64-bit target machine.
67 ///
68 class PPC64TargetMachine : public PPCTargetMachine {
69   virtual void anchor();
70 public:
71   PPC64TargetMachine(const Target &T, StringRef TT,
72                      StringRef CPU, StringRef FS, const TargetOptions &Options,
73                      Reloc::Model RM, CodeModel::Model CM,
74                      CodeGenOpt::Level OL);
75 };
76 
77 } // end namespace llvm
78 
79 #endif
80