[Hexagon] Add missing include of <cctype>
[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, UseHVXOps, UseHVXDblOps;
38   bool ModeIEEERndNear;
39
40 public:
41   enum HexagonArchEnum {
42     V4, V5, V55, V60
43   };
44
45   HexagonArchEnum HexagonArchVersion;
46   /// True if the target should use Back-Skip-Back scheduling. This is the
47   /// default for V60.
48   bool UseBSBScheduling;
49
50 private:
51   std::string CPUString;
52   HexagonInstrInfo InstrInfo;
53   HexagonTargetLowering TLInfo;
54   HexagonSelectionDAGInfo TSInfo;
55   HexagonFrameLowering FrameLowering;
56   InstrItineraryData InstrItins;
57
58 public:
59   HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
60                    const TargetMachine &TM);
61
62   /// getInstrItins - Return the instruction itineraries based on subtarget
63   /// selection.
64   const InstrItineraryData *getInstrItineraryData() const override {
65     return &InstrItins;
66   }
67   const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
68   const HexagonRegisterInfo *getRegisterInfo() const override {
69     return &InstrInfo.getRegisterInfo();
70   }
71   const HexagonTargetLowering *getTargetLowering() const override {
72     return &TLInfo;
73   }
74   const HexagonFrameLowering *getFrameLowering() const override {
75     return &FrameLowering;
76   }
77   const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
78     return &TSInfo;
79   }
80
81   HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
82                                                     StringRef FS);
83
84   /// ParseSubtargetFeatures - Parses features string setting specified
85   /// subtarget options.  Definition of function is auto generated by tblgen.
86   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
87
88   bool useMemOps() const { return UseMemOps; }
89   bool hasV5TOps() const { return getHexagonArchVersion() >= V5; }
90   bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; }
91   bool hasV60TOps() const { return getHexagonArchVersion() >= V60; }
92   bool hasV60TOpsOnly() const { return getHexagonArchVersion() == V60; }
93   bool modeIEEERndNear() const { return ModeIEEERndNear; }
94   bool useHVXDblOps() const { return UseHVXDblOps; }
95   bool useHVXSglOps() const { return UseHVXOps && !UseHVXDblOps; }
96
97   bool useBSBScheduling() const { return UseBSBScheduling; }
98   bool enableMachineScheduler() const override;
99   // Always use the TargetLowering default scheduler.
100   // FIXME: This will use the vliw scheduler which is probably just hurting
101   // compiler time and will be removed eventually anyway.
102   bool enableMachineSchedDefaultSched() const override { return false; }
103
104   const std::string &getCPUString () const { return CPUString; }
105
106   // Threshold for small data section
107   unsigned getSmallDataThreshold() const {
108     return Hexagon_SMALL_DATA_THRESHOLD;
109   }
110   const HexagonArchEnum &getHexagonArchVersion() const {
111     return  HexagonArchVersion;
112   }
113 };
114
115 } // end namespace llvm
116
117 #endif