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" |
| 18 | #include "HexagonInstrInfo.h" |
| 19 | #include "HexagonISelLowering.h" |
| 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 { |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 42 | V1, V2, V3, 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 | const DataLayout DL; // Calculates type size & alignment. |
| 49 | HexagonInstrInfo InstrInfo; |
| 50 | HexagonTargetLowering TLInfo; |
| 51 | HexagonSelectionDAGInfo TSInfo; |
| 52 | HexagonFrameLowering FrameLowering; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 53 | InstrItineraryData InstrItins; |
| 54 | |
| 55 | public: |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 56 | HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS, |
| 57 | const TargetMachine &TM); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 58 | |
Robin Morisset | d18cda6 | 2014-08-15 22:17:28 +0000 | [diff] [blame] | 59 | /// getInstrItins - Return the instruction itineraries based on subtarget |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 60 | /// selection. |
Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 61 | const InstrItineraryData *getInstrItineraryData() const override { |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 62 | return &InstrItins; |
| 63 | } |
| 64 | const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; } |
Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 65 | const HexagonRegisterInfo *getRegisterInfo() const override { |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 66 | return &InstrInfo.getRegisterInfo(); |
| 67 | } |
Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 68 | const HexagonTargetLowering *getTargetLowering() const override { |
| 69 | return &TLInfo; |
| 70 | } |
| 71 | const HexagonFrameLowering *getFrameLowering() const override { |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 72 | return &FrameLowering; |
| 73 | } |
Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 74 | const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override { |
| 75 | return &TSInfo; |
| 76 | } |
| 77 | const DataLayout *getDataLayout() const override { return &DL; } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 78 | |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 79 | HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU, |
| 80 | StringRef FS); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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; } |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 91 | bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 92 | bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; } |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 93 | bool hasV5TOps () const { return HexagonArchVersion >= V5; } |
| 94 | bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; } |
| 95 | bool modeIEEERndNear () const { return ModeIEEERndNear; } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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 |