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 void initializeEnvironment(); 58 59 public: 60 HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, 61 const TargetMachine &TM); 62 63 /// getInstrItins - Return the instruction itineraries based on subtarget 64 /// selection. getInstrItineraryData()65 const InstrItineraryData *getInstrItineraryData() const override { 66 return &InstrItins; 67 } getInstrInfo()68 const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; } getRegisterInfo()69 const HexagonRegisterInfo *getRegisterInfo() const override { 70 return &InstrInfo.getRegisterInfo(); 71 } getTargetLowering()72 const HexagonTargetLowering *getTargetLowering() const override { 73 return &TLInfo; 74 } getFrameLowering()75 const HexagonFrameLowering *getFrameLowering() const override { 76 return &FrameLowering; 77 } getSelectionDAGInfo()78 const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override { 79 return &TSInfo; 80 } 81 82 HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU, 83 StringRef FS); 84 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); 88 useMemOps()89 bool useMemOps() const { return UseMemOps; } hasV5TOps()90 bool hasV5TOps() const { return getHexagonArchVersion() >= V5; } hasV5TOpsOnly()91 bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; } hasV55TOps()92 bool hasV55TOps() const { return getHexagonArchVersion() >= V55; } hasV55TOpsOnly()93 bool hasV55TOpsOnly() const { return getHexagonArchVersion() == V55; } hasV60TOps()94 bool hasV60TOps() const { return getHexagonArchVersion() >= V60; } hasV60TOpsOnly()95 bool hasV60TOpsOnly() const { return getHexagonArchVersion() == V60; } modeIEEERndNear()96 bool modeIEEERndNear() const { return ModeIEEERndNear; } useHVXOps()97 bool useHVXOps() const { return UseHVXOps; } useHVXDblOps()98 bool useHVXDblOps() const { return UseHVXOps && UseHVXDblOps; } useHVXSglOps()99 bool useHVXSglOps() const { return UseHVXOps && !UseHVXDblOps; } 100 useBSBScheduling()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. enableMachineSchedDefaultSched()106 bool enableMachineSchedDefaultSched() const override { return false; } 107 getCPUString()108 const std::string &getCPUString () const { return CPUString; } 109 110 // Threshold for small data section getSmallDataThreshold()111 unsigned getSmallDataThreshold() const { 112 return Hexagon_SMALL_DATA_THRESHOLD; 113 } getHexagonArchVersion()114 const HexagonArchEnum &getHexagonArchVersion() const { 115 return HexagonArchVersion; 116 } 117 }; 118 119 } // end namespace llvm 120 121 #endif 122