• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 : 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   PPCSubtarget Subtarget;
33 
34   mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
35 
36 public:
37   PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
38                    StringRef FS, const TargetOptions &Options,
39                    Optional<Reloc::Model> RM, CodeModel::Model CM,
40                    CodeGenOpt::Level OL);
41 
42   ~PPCTargetMachine() override;
43 
44   const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
45 
46   // Pass Pipeline Configuration
47   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
48 
49   TargetIRAnalysis getTargetIRAnalysis() override;
50 
getObjFileLowering()51   TargetLoweringObjectFile *getObjFileLowering() const override {
52     return TLOF.get();
53   }
isELFv2ABI()54   bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
isPPC64()55   bool isPPC64() const {
56     const Triple &TT = getTargetTriple();
57     return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
58   };
59 };
60 
61 /// PowerPC 32-bit target machine.
62 ///
63 class PPC32TargetMachine : public PPCTargetMachine {
64   virtual void anchor();
65 public:
66   PPC32TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
67                      StringRef FS, const TargetOptions &Options,
68                      Optional<Reloc::Model> RM, CodeModel::Model CM,
69                      CodeGenOpt::Level OL);
70 };
71 
72 /// PowerPC 64-bit target machine.
73 ///
74 class PPC64TargetMachine : public PPCTargetMachine {
75   virtual void anchor();
76 public:
77   PPC64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
78                      StringRef FS, const TargetOptions &Options,
79                      Optional<Reloc::Model> RM, CodeModel::Model CM,
80                      CodeGenOpt::Level OL);
81 };
82 
83 } // end namespace llvm
84 
85 #endif
86