1 //===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the Hexagon specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
15 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
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"
26 #define GET_SUBTARGETINFO_HEADER
27 #include "HexagonGenSubtargetInfo.inc"
29 #define Hexagon_SMALL_DATA_THRESHOLD 8
30 #define Hexagon_SLOTS 4
34 class HexagonSubtarget : public HexagonGenSubtargetInfo {
35 virtual void anchor();
37 bool UseMemOps, UseHVXOps, UseHVXDblOps;
41 enum HexagonArchEnum {
45 HexagonArchEnum HexagonArchVersion;
46 /// True if the target should use Back-Skip-Back scheduling. This is the
48 bool UseBSBScheduling;
51 std::string CPUString;
52 HexagonInstrInfo InstrInfo;
53 HexagonTargetLowering TLInfo;
54 HexagonSelectionDAGInfo TSInfo;
55 HexagonFrameLowering FrameLowering;
56 InstrItineraryData InstrItins;
57 void initializeEnvironment();
60 HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
61 const TargetMachine &TM);
63 /// getInstrItins - Return the instruction itineraries based on subtarget
65 const InstrItineraryData *getInstrItineraryData() const override {
68 const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
69 const HexagonRegisterInfo *getRegisterInfo() const override {
70 return &InstrInfo.getRegisterInfo();
72 const HexagonTargetLowering *getTargetLowering() const override {
75 const HexagonFrameLowering *getFrameLowering() const override {
76 return &FrameLowering;
78 const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
82 HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
85 /// ParseSubtargetFeatures - Parses features string setting specified
86 /// subtarget options. Definition of function is auto generated by tblgen.
87 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
89 bool useMemOps() const { return UseMemOps; }
90 bool hasV5TOps() const { return getHexagonArchVersion() >= V5; }
91 bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; }
92 bool hasV55TOps() const { return getHexagonArchVersion() >= V55; }
93 bool hasV55TOpsOnly() const { return getHexagonArchVersion() == V55; }
94 bool hasV60TOps() const { return getHexagonArchVersion() >= V60; }
95 bool hasV60TOpsOnly() const { return getHexagonArchVersion() == V60; }
96 bool modeIEEERndNear() const { return ModeIEEERndNear; }
97 bool useHVXOps() const { return UseHVXOps; }
98 bool useHVXDblOps() const { return UseHVXOps && UseHVXDblOps; }
99 bool useHVXSglOps() const { return UseHVXOps && !UseHVXDblOps; }
101 bool useBSBScheduling() const { return UseBSBScheduling; }
102 bool enableMachineScheduler() const override;
103 // Always use the TargetLowering default scheduler.
104 // FIXME: This will use the vliw scheduler which is probably just hurting
105 // compiler time and will be removed eventually anyway.
106 bool enableMachineSchedDefaultSched() const override { return false; }
108 const std::string &getCPUString () const { return CPUString; }
110 // Threshold for small data section
111 unsigned getSmallDataThreshold() const {
112 return Hexagon_SMALL_DATA_THRESHOLD;
114 const HexagonArchEnum &getHexagonArchVersion() const {
115 return HexagonArchVersion;
119 } // end namespace llvm