Move DataLayout back to the TargetMachine from TargetSubtargetInfo
[oota-llvm.git] / lib / Target / Hexagon / HexagonSubtarget.h
1 //===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- 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 Hexagon specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
15 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
16
17 #include "HexagonFrameLowering.h"
18 #include "HexagonISelLowering.h"
19 #include "HexagonInstrInfo.h"
20 #include "HexagonSelectionDAGInfo.h"
21 #include "llvm/IR/DataLayout.h"
22 #include "llvm/Target/TargetMachine.h"
23 #include "llvm/Target/TargetSubtargetInfo.h"
24 #include <string>
25
26 #define GET_SUBTARGETINFO_HEADER
27 #include "HexagonGenSubtargetInfo.inc"
28
29 #define Hexagon_SMALL_DATA_THRESHOLD 8
30 #define Hexagon_SLOTS 4
31
32 namespace llvm {
33
34 class HexagonSubtarget : public HexagonGenSubtargetInfo {
35   virtual void anchor();
36
37   bool UseMemOps;
38   bool ModeIEEERndNear;
39
40 public:
41   enum HexagonArchEnum {
42     V1, V2, V3, V4, V5
43   };
44
45   HexagonArchEnum HexagonArchVersion;
46 private:
47   std::string CPUString;
48   HexagonInstrInfo InstrInfo;
49   HexagonTargetLowering TLInfo;
50   HexagonSelectionDAGInfo TSInfo;
51   HexagonFrameLowering FrameLowering;
52   InstrItineraryData InstrItins;
53
54 public:
55   HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
56                    const TargetMachine &TM);
57
58   /// getInstrItins - Return the instruction itineraries based on subtarget
59   /// selection.
60   const InstrItineraryData *getInstrItineraryData() const override {
61     return &InstrItins;
62   }
63   const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
64   const HexagonRegisterInfo *getRegisterInfo() const override {
65     return &InstrInfo.getRegisterInfo();
66   }
67   const HexagonTargetLowering *getTargetLowering() const override {
68     return &TLInfo;
69   }
70   const HexagonFrameLowering *getFrameLowering() const override {
71     return &FrameLowering;
72   }
73   const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
74     return &TSInfo;
75   }
76
77   HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
78                                                     StringRef FS);
79
80   /// ParseSubtargetFeatures - Parses features string setting specified
81   /// subtarget options.  Definition of function is auto generated by tblgen.
82   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
83
84   bool hasV2TOps () const { return HexagonArchVersion >= V2; }
85   bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
86   bool hasV3TOps () const { return HexagonArchVersion >= V3; }
87   bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
88   bool hasV4TOps () const { return HexagonArchVersion >= V4; }
89   bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
90   bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
91   bool hasV5TOps () const { return HexagonArchVersion >= V5; }
92   bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
93   bool modeIEEERndNear () const { return ModeIEEERndNear; }
94
95   bool isSubtargetV2() const { return HexagonArchVersion == V2;}
96   const std::string &getCPUString () const { return CPUString; }
97
98   // Threshold for small data section
99   unsigned getSmallDataThreshold() const {
100     return Hexagon_SMALL_DATA_THRESHOLD;
101   }
102   const HexagonArchEnum &getHexagonArchVersion() const {
103     return  HexagonArchVersion;
104   }
105 };
106
107 } // end namespace llvm
108
109 #endif