xref: /llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.h (revision 4e332c7cf1b32cc2227d1d70c917c6838774efbe)
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 /// Common code between 32-bit and 64-bit PowerPC targets.
25 ///
26 class PPCTargetMachine final : public LLVMTargetMachine {
27 public:
28   enum PPCABI { PPC_ABI_UNKNOWN, PPC_ABI_ELFv1, PPC_ABI_ELFv2 };
29 private:
30   std::unique_ptr<TargetLoweringObjectFile> TLOF;
31   PPCABI TargetABI;
32 
33   mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
34 
35 public:
36   PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
37                    StringRef FS, const TargetOptions &Options,
38                    Optional<Reloc::Model> RM, CodeModel::Model CM,
39                    CodeGenOpt::Level OL);
40 
41   ~PPCTargetMachine() override;
42 
43   const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
44   // The no argument getSubtargetImpl, while it exists on some targets, is
45   // deprecated and should not be used.
46   const PPCSubtarget *getSubtargetImpl() const = delete;
47 
48   // Pass Pipeline Configuration
49   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
50 
51   TargetIRAnalysis getTargetIRAnalysis() override;
52 
53   TargetLoweringObjectFile *getObjFileLowering() const override {
54     return TLOF.get();
55   }
56   bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
57   bool isPPC64() const {
58     const Triple &TT = getTargetTriple();
59     return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
60   };
61 
62   bool isMachineVerifierClean() const override {
63     return false;
64   }
65 };
66 } // end namespace llvm
67 
68 #endif
69