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