[cleanup] Re-sort all the #include lines in LLVM using
[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   const DataLayout DL;       // Calculates type size & alignment.
49   HexagonInstrInfo InstrInfo;
50   HexagonTargetLowering TLInfo;
51   HexagonSelectionDAGInfo TSInfo;
52   HexagonFrameLowering FrameLowering;
53   InstrItineraryData InstrItins;
54
55 public:
56   HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
57                    const TargetMachine &TM);
58
59   /// getInstrItins - Return the instruction itineraries based on subtarget
60   /// selection.
61   const InstrItineraryData *getInstrItineraryData() const override {
62     return &InstrItins;
63   }
64   const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
65   const HexagonRegisterInfo *getRegisterInfo() const override {
66     return &InstrInfo.getRegisterInfo();
67   }
68   const HexagonTargetLowering *getTargetLowering() const override {
69     return &TLInfo;
70   }
71   const HexagonFrameLowering *getFrameLowering() const override {
72     return &FrameLowering;
73   }
74   const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
75     return &TSInfo;
76   }
77   const DataLayout *getDataLayout() const override { return &DL; }
78
79   HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
80                                                     StringRef FS);
81
82   /// ParseSubtargetFeatures - Parses features string setting specified
83   /// subtarget options.  Definition of function is auto generated by tblgen.
84   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
85
86   bool hasV2TOps () const { return HexagonArchVersion >= V2; }
87   bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
88   bool hasV3TOps () const { return HexagonArchVersion >= V3; }
89   bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
90   bool hasV4TOps () const { return HexagonArchVersion >= V4; }
91   bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
92   bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
93   bool hasV5TOps () const { return HexagonArchVersion >= V5; }
94   bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
95   bool modeIEEERndNear () const { return ModeIEEERndNear; }
96
97   bool isSubtargetV2() const { return HexagonArchVersion == V2;}
98   const std::string &getCPUString () const { return CPUString; }
99
100   // Threshold for small data section
101   unsigned getSmallDataThreshold() const {
102     return Hexagon_SMALL_DATA_THRESHOLD;
103   }
104   const HexagonArchEnum &getHexagonArchVersion() const {
105     return  HexagonArchVersion;
106   }
107 };
108
109 } // end namespace llvm
110
111 #endif