| Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- C++ -*-===// |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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 | |
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H |
| 15 | #define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 16 | |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 17 | #include "HexagonFrameLowering.h" |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 18 | #include "HexagonISelLowering.h" |
| Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 19 | #include "HexagonInstrInfo.h" |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 20 | #include "HexagonSelectionDAGInfo.h" |
| 21 | #include "llvm/IR/DataLayout.h" |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetMachine.h" |
| Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetSubtargetInfo.h" |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 24 | #include <string> |
| 25 | |
| 26 | #define GET_SUBTARGETINFO_HEADER |
| 27 | #include "HexagonGenSubtargetInfo.inc" |
| 28 | |
| 29 | #define Hexagon_SMALL_DATA_THRESHOLD 8 |
| Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 30 | #define Hexagon_SLOTS 4 |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 31 | |
| 32 | namespace llvm { |
| 33 | |
| 34 | class HexagonSubtarget : public HexagonGenSubtargetInfo { |
| Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 35 | virtual void anchor(); |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 36 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 37 | bool UseMemOps; |
| Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 38 | bool ModeIEEERndNear; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 39 | |
| 40 | public: |
| 41 | enum HexagonArchEnum { |
| Colin LeMahieu | 4fd203d | 2015-02-09 21:56:37 +0000 | [diff] [blame] | 42 | V4, V5 |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | HexagonArchEnum HexagonArchVersion; |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 46 | private: |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 47 | std::string CPUString; |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 48 | HexagonInstrInfo InstrInfo; |
| 49 | HexagonTargetLowering TLInfo; |
| 50 | HexagonSelectionDAGInfo TSInfo; |
| 51 | HexagonFrameLowering FrameLowering; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 52 | InstrItineraryData InstrItins; |
| 53 | |
| 54 | public: |
| Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 55 | HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 56 | const TargetMachine &TM); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 57 | |
| Robin Morisset | d18cda6 | 2014-08-15 22:17:28 +0000 | [diff] [blame] | 58 | /// getInstrItins - Return the instruction itineraries based on subtarget |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 59 | /// selection. |
| Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 60 | const InstrItineraryData *getInstrItineraryData() const override { |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 61 | return &InstrItins; |
| 62 | } |
| 63 | const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; } |
| Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 64 | const HexagonRegisterInfo *getRegisterInfo() const override { |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 65 | return &InstrInfo.getRegisterInfo(); |
| 66 | } |
| Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 67 | const HexagonTargetLowering *getTargetLowering() const override { |
| 68 | return &TLInfo; |
| 69 | } |
| 70 | const HexagonFrameLowering *getFrameLowering() const override { |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 71 | return &FrameLowering; |
| 72 | } |
| Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 73 | const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override { |
| 74 | return &TSInfo; |
| 75 | } |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 76 | |
| Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 77 | HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU, |
| 78 | StringRef FS); |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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 | |
| Colin LeMahieu | 4fd203d | 2015-02-09 21:56:37 +0000 | [diff] [blame] | 84 | bool useMemOps() const { return UseMemOps; } |
| 85 | bool hasV5TOps() const { return getHexagonArchVersion() >= V5; } |
| 86 | bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; } |
| 87 | bool modeIEEERndNear() const { return ModeIEEERndNear; } |
| Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 88 | bool enableMachineScheduler() const override; |
| 89 | // Always use the TargetLowering default scheduler. |
| 90 | // FIXME: This will use the vliw scheduler which is probably just hurting |
| 91 | // compiler time and will be removed eventually anyway. |
| 92 | bool enableMachineSchedDefaultSched() const override { return false; } |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 93 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 94 | const std::string &getCPUString () const { return CPUString; } |
| 95 | |
| 96 | // Threshold for small data section |
| 97 | unsigned getSmallDataThreshold() const { |
| 98 | return Hexagon_SMALL_DATA_THRESHOLD; |
| 99 | } |
| 100 | const HexagonArchEnum &getHexagonArchVersion() const { |
| 101 | return HexagonArchVersion; |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | } // end namespace llvm |
| 106 | |
| 107 | #endif |