Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- Hexagon.td - Describe the Hexagon Target Machine --*- tablegen -*--===// |
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 | // |
Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 10 | // This is the top level entry point for the Hexagon target. |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | // Target-independent interfaces which we are implementing |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | include "llvm/Target/Target.td" |
| 19 | |
| 20 | //===----------------------------------------------------------------------===// |
| 21 | // Hexagon Subtarget features. |
Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 22 | //===----------------------------------------------------------------------===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 23 | |
Colin LeMahieu | 4fd203d | 2015-02-09 21:56:37 +0000 | [diff] [blame] | 24 | // Hexagon Architectures |
| 25 | def ArchV4: SubtargetFeature<"v4", "HexagonArchVersion", "V4", "Hexagon V4">; |
| 26 | def ArchV5: SubtargetFeature<"v5", "HexagonArchVersion", "V5", "Hexagon V5">; |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 27 | def ArchV55: SubtargetFeature<"v55", "HexagonArchVersion", "V55", "Hexagon V55">; |
| 28 | def ArchV60: SubtargetFeature<"v60", "HexagonArchVersion", "V60", "Hexagon V60">; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 29 | |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 30 | // Hexagon ISA Extensions |
| 31 | def ExtensionHVX: SubtargetFeature<"hvx", "UseHVXOps", |
| 32 | "true", "Hexagon HVX instructions">; |
Krzysztof Parzyszek | 759a7d0 | 2015-12-14 15:03:54 +0000 | [diff] [blame] | 33 | def ExtensionHVXDbl: SubtargetFeature<"hvx-double", "UseHVXDblOps", |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 34 | "true", "Hexagon HVX Double instructions">; |
| 35 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 36 | //===----------------------------------------------------------------------===// |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 37 | // Hexagon Instruction Predicate Definitions. |
| 38 | //===----------------------------------------------------------------------===// |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 39 | def HasV5T : Predicate<"HST->hasV5TOps()">; |
| 40 | def NoV5T : Predicate<"!HST->hasV5TOps()">; |
| 41 | def HasV55T : Predicate<"HST->hasV55TOps()">, |
| 42 | AssemblerPredicate<"ArchV55">; |
| 43 | def HasV60T : Predicate<"HST->hasV60TOps()">, |
| 44 | AssemblerPredicate<"ArchV60">; |
| 45 | def UseMEMOP : Predicate<"HST->useMemOps()">; |
| 46 | def IEEERndNearV5T : Predicate<"HST->modeIEEERndNear()">; |
| 47 | def UseHVXDbl : Predicate<"HST->useHVXDblOps()">, |
| 48 | AssemblerPredicate<"ExtensionHVXDbl">; |
| 49 | def UseHVXSgl : Predicate<"HST->useHVXSglOps()">; |
| 50 | |
Krzysztof Parzyszek | 4eb6d4d | 2015-11-26 16:54:33 +0000 | [diff] [blame] | 51 | def UseHVX : Predicate<"HST->useHVXSglOps() ||HST->useHVXDblOps()">, |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 52 | AssemblerPredicate<"ExtensionHVX">; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 53 | |
| 54 | //===----------------------------------------------------------------------===// |
| 55 | // Classes used for relation maps. |
| 56 | //===----------------------------------------------------------------------===// |
Colin LeMahieu | 9161d47 | 2014-12-30 18:58:47 +0000 | [diff] [blame] | 57 | |
| 58 | class ImmRegShl; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 59 | // PredRel - Filter class used to relate non-predicated instructions with their |
| 60 | // predicated forms. |
| 61 | class PredRel; |
| 62 | // PredNewRel - Filter class used to relate predicated instructions with their |
| 63 | // predicate-new forms. |
| 64 | class PredNewRel: PredRel; |
| 65 | // ImmRegRel - Filter class used to relate instructions having reg-reg form |
| 66 | // with their reg-imm counterparts. |
| 67 | class ImmRegRel; |
| 68 | // NewValueRel - Filter class used to relate regular store instructions with |
| 69 | // their new-value store form. |
| 70 | class NewValueRel: PredNewRel; |
| 71 | // NewValueRel - Filter class used to relate load/store instructions having |
| 72 | // different addressing modes with each other. |
| 73 | class AddrModeRel: NewValueRel; |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 74 | class IntrinsicsRel; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 75 | |
| 76 | //===----------------------------------------------------------------------===// |
| 77 | // Generate mapping table to relate non-predicate instructions with their |
| 78 | // predicated formats - true and false. |
| 79 | // |
| 80 | |
| 81 | def getPredOpcode : InstrMapping { |
| 82 | let FilterClass = "PredRel"; |
| 83 | // Instructions with the same BaseOpcode and isNVStore values form a row. |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 84 | let RowFields = ["BaseOpcode", "isNVStore", "PNewValue", "isNT"]; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 85 | // Instructions with the same predicate sense form a column. |
| 86 | let ColFields = ["PredSense"]; |
| 87 | // The key column is the unpredicated instructions. |
| 88 | let KeyCol = [""]; |
| 89 | // Value columns are PredSense=true and PredSense=false |
| 90 | let ValueCols = [["true"], ["false"]]; |
| 91 | } |
| 92 | |
| 93 | //===----------------------------------------------------------------------===// |
Jyotsna Verma | 84c4710 | 2013-05-06 18:49:23 +0000 | [diff] [blame] | 94 | // Generate mapping table to relate predicate-true instructions with their |
| 95 | // predicate-false forms |
| 96 | // |
| 97 | def getFalsePredOpcode : InstrMapping { |
| 98 | let FilterClass = "PredRel"; |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 99 | let RowFields = ["BaseOpcode", "PNewValue", "isNVStore", "isBrTaken", "isNT"]; |
Jyotsna Verma | 84c4710 | 2013-05-06 18:49:23 +0000 | [diff] [blame] | 100 | let ColFields = ["PredSense"]; |
| 101 | let KeyCol = ["true"]; |
| 102 | let ValueCols = [["false"]]; |
| 103 | } |
| 104 | |
| 105 | //===----------------------------------------------------------------------===// |
| 106 | // Generate mapping table to relate predicate-false instructions with their |
| 107 | // predicate-true forms |
| 108 | // |
| 109 | def getTruePredOpcode : InstrMapping { |
| 110 | let FilterClass = "PredRel"; |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 111 | let RowFields = ["BaseOpcode", "PNewValue", "isNVStore", "isBrTaken", "isNT"]; |
Jyotsna Verma | 84c4710 | 2013-05-06 18:49:23 +0000 | [diff] [blame] | 112 | let ColFields = ["PredSense"]; |
| 113 | let KeyCol = ["false"]; |
| 114 | let ValueCols = [["true"]]; |
| 115 | } |
| 116 | |
| 117 | //===----------------------------------------------------------------------===// |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 118 | // Generate mapping table to relate predicated instructions with their .new |
| 119 | // format. |
| 120 | // |
| 121 | def getPredNewOpcode : InstrMapping { |
| 122 | let FilterClass = "PredNewRel"; |
Jyotsna Verma | 5ed5181 | 2013-05-01 21:37:34 +0000 | [diff] [blame] | 123 | let RowFields = ["BaseOpcode", "PredSense", "isNVStore", "isBrTaken"]; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 124 | let ColFields = ["PNewValue"]; |
| 125 | let KeyCol = [""]; |
| 126 | let ValueCols = [["new"]]; |
| 127 | } |
| 128 | |
| 129 | //===----------------------------------------------------------------------===// |
Jyotsna Verma | 438cec5 | 2013-05-10 20:58:11 +0000 | [diff] [blame] | 130 | // Generate mapping table to relate .new predicated instructions with their old |
| 131 | // format. |
| 132 | // |
| 133 | def getPredOldOpcode : InstrMapping { |
| 134 | let FilterClass = "PredNewRel"; |
| 135 | let RowFields = ["BaseOpcode", "PredSense", "isNVStore"]; |
| 136 | let ColFields = ["PNewValue"]; |
| 137 | let KeyCol = ["new"]; |
| 138 | let ValueCols = [[""]]; |
| 139 | } |
| 140 | |
| 141 | //===----------------------------------------------------------------------===// |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 142 | // Generate mapping table to relate store instructions with their new-value |
| 143 | // format. |
| 144 | // |
| 145 | def getNewValueOpcode : InstrMapping { |
| 146 | let FilterClass = "NewValueRel"; |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 147 | let RowFields = ["BaseOpcode", "PredSense", "PNewValue", "addrMode", "isNT"]; |
Jyotsna Verma | 300f0b9 | 2013-05-10 20:27:34 +0000 | [diff] [blame] | 148 | let ColFields = ["NValueST"]; |
| 149 | let KeyCol = ["false"]; |
| 150 | let ValueCols = [["true"]]; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Jyotsna Verma | 438cec5 | 2013-05-10 20:58:11 +0000 | [diff] [blame] | 153 | //===----------------------------------------------------------------------===// |
| 154 | // Generate mapping table to relate new-value store instructions with their old |
| 155 | // format. |
| 156 | // |
| 157 | def getNonNVStore : InstrMapping { |
| 158 | let FilterClass = "NewValueRel"; |
Colin LeMahieu | 7c95871 | 2015-10-17 01:33:04 +0000 | [diff] [blame] | 159 | let RowFields = ["BaseOpcode", "PredSense", "PNewValue", "addrMode", "isNT"]; |
Jyotsna Verma | 438cec5 | 2013-05-10 20:58:11 +0000 | [diff] [blame] | 160 | let ColFields = ["NValueST"]; |
| 161 | let KeyCol = ["true"]; |
| 162 | let ValueCols = [["false"]]; |
| 163 | } |
| 164 | |
Krzysztof Parzyszek | 0257905 | 2015-10-20 19:21:05 +0000 | [diff] [blame] | 165 | def getBaseWithImmOffset : InstrMapping { |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 166 | let FilterClass = "AddrModeRel"; |
| 167 | let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore", |
Krzysztof Parzyszek | 05da79d | 2015-10-20 19:04:53 +0000 | [diff] [blame] | 168 | "isFloat"]; |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 169 | let ColFields = ["addrMode"]; |
| 170 | let KeyCol = ["Absolute"]; |
| 171 | let ValueCols = [["BaseImmOffset"]]; |
| 172 | } |
| 173 | |
| 174 | def getBaseWithRegOffset : InstrMapping { |
| 175 | let FilterClass = "AddrModeRel"; |
| 176 | let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore"]; |
| 177 | let ColFields = ["addrMode"]; |
| 178 | let KeyCol = ["BaseImmOffset"]; |
| 179 | let ValueCols = [["BaseRegOffset"]]; |
| 180 | } |
| 181 | |
| 182 | def getRegForm : InstrMapping { |
| 183 | let FilterClass = "ImmRegRel"; |
| 184 | let RowFields = ["CextOpcode", "PredSense", "PNewValue"]; |
| 185 | let ColFields = ["InputType"]; |
| 186 | let KeyCol = ["imm"]; |
| 187 | let ValueCols = [["reg"]]; |
| 188 | } |
| 189 | |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 190 | def getRegShlForm : InstrMapping { |
| 191 | let FilterClass = "ImmRegShl"; |
| 192 | let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore"]; |
| 193 | let ColFields = ["InputType"]; |
| 194 | let KeyCol = ["imm"]; |
| 195 | let ValueCols = [["reg"]]; |
| 196 | } |
| 197 | |
| 198 | def notTakenBranchPrediction : InstrMapping { |
| 199 | let FilterClass = "PredRel"; |
| 200 | let RowFields = ["BaseOpcode", "PNewValue", "PredSense", "isBranch", "isPredicated"]; |
| 201 | let ColFields = ["isBrTaken"]; |
| 202 | let KeyCol = ["true"]; |
| 203 | let ValueCols = [["false"]]; |
| 204 | } |
| 205 | |
| 206 | def takenBranchPrediction : InstrMapping { |
| 207 | let FilterClass = "PredRel"; |
| 208 | let RowFields = ["BaseOpcode", "PNewValue", "PredSense", "isBranch", "isPredicated"]; |
| 209 | let ColFields = ["isBrTaken"]; |
| 210 | let KeyCol = ["false"]; |
| 211 | let ValueCols = [["true"]]; |
| 212 | } |
| 213 | |
| 214 | def getRealHWInstr : InstrMapping { |
| 215 | let FilterClass = "IntrinsicsRel"; |
| 216 | let RowFields = ["BaseOpcode"]; |
| 217 | let ColFields = ["InstrType"]; |
| 218 | let KeyCol = ["Pseudo"]; |
| 219 | let ValueCols = [["Pseudo"], ["Real"]]; |
| 220 | } |
Jyotsna Verma | efe4f55 | 2012-12-04 04:29:16 +0000 | [diff] [blame] | 221 | //===----------------------------------------------------------------------===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 222 | // Register File, Calling Conv, Instruction Descriptions |
| 223 | //===----------------------------------------------------------------------===// |
| 224 | include "HexagonSchedule.td" |
| 225 | include "HexagonRegisterInfo.td" |
| 226 | include "HexagonCallingConv.td" |
| 227 | include "HexagonInstrInfo.td" |
| 228 | include "HexagonIntrinsics.td" |
| 229 | include "HexagonIntrinsicsDerived.td" |
| 230 | |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 231 | def HexagonInstrInfo : InstrInfo; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 232 | |
| 233 | //===----------------------------------------------------------------------===// |
| 234 | // Hexagon processors supported. |
| 235 | //===----------------------------------------------------------------------===// |
| 236 | |
Andrew Trick | 87255e3 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 237 | class Proc<string Name, SchedMachineModel Model, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 238 | list<SubtargetFeature> Features> |
Andrew Trick | 87255e3 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 239 | : ProcessorModel<Name, Model, Features>; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 240 | |
Colin LeMahieu | 4fd203d | 2015-02-09 21:56:37 +0000 | [diff] [blame] | 241 | def : Proc<"hexagonv4", HexagonModelV4, |
| 242 | [ArchV4]>; |
| 243 | def : Proc<"hexagonv5", HexagonModelV4, |
| 244 | [ArchV4, ArchV5]>; |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 245 | def : Proc<"hexagonv55", HexagonModelV55, |
| 246 | [ArchV4, ArchV5, ArchV55]>; |
| 247 | def : Proc<"hexagonv60", HexagonModelV60, |
| 248 | [ArchV4, ArchV5, ArchV55, ArchV60, ExtensionHVX]>; |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 249 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 250 | //===----------------------------------------------------------------------===// |
| 251 | // Declare the target which we are implementing |
| 252 | //===----------------------------------------------------------------------===// |
| 253 | |
Craig Topper | fd2c6a3 | 2015-12-31 08:18:23 +0000 | [diff] [blame] | 254 | def HexagonAsmParser : AsmParser { |
Krzysztof Parzyszek | adf02ae | 2016-04-21 19:49:53 +0000 | [diff] [blame^] | 255 | let ShouldEmitMatchRegisterAltName = 1; |
Craig Topper | fd2c6a3 | 2015-12-31 08:18:23 +0000 | [diff] [blame] | 256 | bit HasMnemonicFirst = 0; |
| 257 | } |
| 258 | |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 259 | def HexagonAsmParserVariant : AsmParserVariant { |
| 260 | int Variant = 0; |
| 261 | string TokenizingCharacters = "#()=:.<>!+*"; |
| 262 | } |
| 263 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 264 | def Hexagon : Target { |
| 265 | // Pull in Instruction Info: |
| 266 | let InstructionSet = HexagonInstrInfo; |
Craig Topper | fd2c6a3 | 2015-12-31 08:18:23 +0000 | [diff] [blame] | 267 | let AssemblyParsers = [HexagonAsmParser]; |
Colin LeMahieu | 7cd0892 | 2015-11-09 04:07:48 +0000 | [diff] [blame] | 268 | let AssemblyParserVariants = [HexagonAsmParserVariant]; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 269 | } |