[ARM] Minor refactoring. NFC.
[oota-llvm.git] / lib / Target / ARM / ARMTargetMachine.h
1 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- 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 ARM specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
16
17 #include "ARMInstrInfo.h"
18 #include "ARMSubtarget.h"
19 #include "llvm/IR/DataLayout.h"
20 #include "llvm/Target/TargetMachine.h"
21
22 namespace llvm {
23
24 class ARMBaseTargetMachine : public LLVMTargetMachine {
25 public:
26   enum ARMABI {
27     ARM_ABI_UNKNOWN,
28     ARM_ABI_APCS,
29     ARM_ABI_AAPCS // ARM EABI
30   } TargetABI;
31
32 protected:
33   std::unique_ptr<TargetLoweringObjectFile> TLOF;
34   ARMSubtarget        Subtarget;
35   bool isLittle;
36   mutable StringMap<std::unique_ptr<ARMSubtarget>> SubtargetMap;
37
38 public:
39   ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
40                        StringRef FS, const TargetOptions &Options,
41                        Reloc::Model RM, CodeModel::Model CM,
42                        CodeGenOpt::Level OL, bool isLittle);
43   ~ARMBaseTargetMachine() override;
44
45   const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
46   const ARMSubtarget *getSubtargetImpl(const Function &F) const override;
47   bool isLittleEndian() const { return isLittle; }
48
49   /// \brief Get the TargetIRAnalysis for this target.
50   TargetIRAnalysis getTargetIRAnalysis() override;
51
52   // Pass Pipeline Configuration
53   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
54
55   TargetLoweringObjectFile *getObjFileLowering() const override {
56     return TLOF.get();
57   }
58 };
59
60 /// ARMTargetMachine - ARM target machine.
61 ///
62 class ARMTargetMachine : public ARMBaseTargetMachine {
63   virtual void anchor();
64  public:
65    ARMTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
66                     StringRef FS, const TargetOptions &Options, Reloc::Model RM,
67                     CodeModel::Model CM, CodeGenOpt::Level OL, bool isLittle);
68 };
69
70 /// ARMLETargetMachine - ARM little endian target machine.
71 ///
72 class ARMLETargetMachine : public ARMTargetMachine {
73   void anchor() override;
74 public:
75   ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
76                      StringRef FS, const TargetOptions &Options,
77                      Reloc::Model RM, CodeModel::Model CM,
78                      CodeGenOpt::Level OL);
79 };
80
81 /// ARMBETargetMachine - ARM big endian target machine.
82 ///
83 class ARMBETargetMachine : public ARMTargetMachine {
84   void anchor() override;
85 public:
86   ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
87                      StringRef FS, const TargetOptions &Options,
88                      Reloc::Model RM, CodeModel::Model CM,
89                      CodeGenOpt::Level OL);
90 };
91
92 /// ThumbTargetMachine - Thumb target machine.
93 /// Due to the way architectures are handled, this represents both
94 ///   Thumb-1 and Thumb-2.
95 ///
96 class ThumbTargetMachine : public ARMBaseTargetMachine {
97   virtual void anchor();
98 public:
99   ThumbTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
100                      StringRef FS, const TargetOptions &Options,
101                      Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL,
102                      bool isLittle);
103 };
104
105 /// ThumbLETargetMachine - Thumb little endian target machine.
106 ///
107 class ThumbLETargetMachine : public ThumbTargetMachine {
108   void anchor() override;
109 public:
110   ThumbLETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
111                        StringRef FS, const TargetOptions &Options,
112                        Reloc::Model RM, CodeModel::Model CM,
113                        CodeGenOpt::Level OL);
114 };
115
116 /// ThumbBETargetMachine - Thumb big endian target machine.
117 ///
118 class ThumbBETargetMachine : public ThumbTargetMachine {
119   void anchor() override;
120 public:
121   ThumbBETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
122                        StringRef FS, const TargetOptions &Options,
123                        Reloc::Model RM, CodeModel::Model CM,
124                        CodeGenOpt::Level OL);
125 };
126
127 } // end namespace llvm
128
129 #endif