blob: 602e27b932b56bb396b88b50f7d4f90a6185322d [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- Hexagon.td - Describe the Hexagon Target Machine --*- tablegen -*--===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +00002//
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 Liub22310f2012-02-18 12:03:15 +000010// This is the top level entry point for the Hexagon target.
Tony Linthicum1213a7a2011-12-12 21:14:40 +000011//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Target-independent interfaces which we are implementing
16//===----------------------------------------------------------------------===//
17
18include "llvm/Target/Target.td"
19
20//===----------------------------------------------------------------------===//
21// Hexagon Subtarget features.
Jia Liub22310f2012-02-18 12:03:15 +000022//===----------------------------------------------------------------------===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +000023
Colin LeMahieu4fd203d2015-02-09 21:56:37 +000024// Hexagon Architectures
25def ArchV4: SubtargetFeature<"v4", "HexagonArchVersion", "V4", "Hexagon V4">;
26def ArchV5: SubtargetFeature<"v5", "HexagonArchVersion", "V5", "Hexagon V5">;
Colin LeMahieu7c958712015-10-17 01:33:04 +000027def ArchV55: SubtargetFeature<"v55", "HexagonArchVersion", "V55", "Hexagon V55">;
28def ArchV60: SubtargetFeature<"v60", "HexagonArchVersion", "V60", "Hexagon V60">;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000029
Colin LeMahieu7c958712015-10-17 01:33:04 +000030// Hexagon ISA Extensions
31def ExtensionHVX: SubtargetFeature<"hvx", "UseHVXOps",
32 "true", "Hexagon HVX instructions">;
Krzysztof Parzyszek759a7d02015-12-14 15:03:54 +000033def ExtensionHVXDbl: SubtargetFeature<"hvx-double", "UseHVXDblOps",
Colin LeMahieu7cd08922015-11-09 04:07:48 +000034 "true", "Hexagon HVX Double instructions">;
35
Tony Linthicum1213a7a2011-12-12 21:14:40 +000036//===----------------------------------------------------------------------===//
Jyotsna Vermaefe4f552012-12-04 04:29:16 +000037// Hexagon Instruction Predicate Definitions.
38//===----------------------------------------------------------------------===//
Colin LeMahieu7c958712015-10-17 01:33:04 +000039def HasV5T : Predicate<"HST->hasV5TOps()">;
40def NoV5T : Predicate<"!HST->hasV5TOps()">;
41def HasV55T : Predicate<"HST->hasV55TOps()">,
42 AssemblerPredicate<"ArchV55">;
43def HasV60T : Predicate<"HST->hasV60TOps()">,
44 AssemblerPredicate<"ArchV60">;
45def UseMEMOP : Predicate<"HST->useMemOps()">;
46def IEEERndNearV5T : Predicate<"HST->modeIEEERndNear()">;
47def UseHVXDbl : Predicate<"HST->useHVXDblOps()">,
48 AssemblerPredicate<"ExtensionHVXDbl">;
49def UseHVXSgl : Predicate<"HST->useHVXSglOps()">;
50
Krzysztof Parzyszek4eb6d4d2015-11-26 16:54:33 +000051def UseHVX : Predicate<"HST->useHVXSglOps() ||HST->useHVXDblOps()">,
Colin LeMahieu7c958712015-10-17 01:33:04 +000052 AssemblerPredicate<"ExtensionHVX">;
Jyotsna Vermaefe4f552012-12-04 04:29:16 +000053
54//===----------------------------------------------------------------------===//
55// Classes used for relation maps.
56//===----------------------------------------------------------------------===//
Colin LeMahieu9161d472014-12-30 18:58:47 +000057
58class ImmRegShl;
Jyotsna Vermaefe4f552012-12-04 04:29:16 +000059// PredRel - Filter class used to relate non-predicated instructions with their
60// predicated forms.
61class PredRel;
62// PredNewRel - Filter class used to relate predicated instructions with their
63// predicate-new forms.
64class PredNewRel: PredRel;
65// ImmRegRel - Filter class used to relate instructions having reg-reg form
66// with their reg-imm counterparts.
67class ImmRegRel;
68// NewValueRel - Filter class used to relate regular store instructions with
69// their new-value store form.
70class NewValueRel: PredNewRel;
71// NewValueRel - Filter class used to relate load/store instructions having
72// different addressing modes with each other.
73class AddrModeRel: NewValueRel;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000074class IntrinsicsRel;
Jyotsna Vermaefe4f552012-12-04 04:29:16 +000075
76//===----------------------------------------------------------------------===//
77// Generate mapping table to relate non-predicate instructions with their
78// predicated formats - true and false.
79//
80
81def getPredOpcode : InstrMapping {
82 let FilterClass = "PredRel";
83 // Instructions with the same BaseOpcode and isNVStore values form a row.
Colin LeMahieu7c958712015-10-17 01:33:04 +000084 let RowFields = ["BaseOpcode", "isNVStore", "PNewValue", "isNT"];
Jyotsna Vermaefe4f552012-12-04 04:29:16 +000085 // 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 Verma84c47102013-05-06 18:49:23 +000094// Generate mapping table to relate predicate-true instructions with their
95// predicate-false forms
96//
97def getFalsePredOpcode : InstrMapping {
98 let FilterClass = "PredRel";
Colin LeMahieu7c958712015-10-17 01:33:04 +000099 let RowFields = ["BaseOpcode", "PNewValue", "isNVStore", "isBrTaken", "isNT"];
Jyotsna Verma84c47102013-05-06 18:49:23 +0000100 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//
109def getTruePredOpcode : InstrMapping {
110 let FilterClass = "PredRel";
Colin LeMahieu7c958712015-10-17 01:33:04 +0000111 let RowFields = ["BaseOpcode", "PNewValue", "isNVStore", "isBrTaken", "isNT"];
Jyotsna Verma84c47102013-05-06 18:49:23 +0000112 let ColFields = ["PredSense"];
113 let KeyCol = ["false"];
114 let ValueCols = [["true"]];
115}
116
117//===----------------------------------------------------------------------===//
Jyotsna Vermaefe4f552012-12-04 04:29:16 +0000118// Generate mapping table to relate predicated instructions with their .new
119// format.
120//
121def getPredNewOpcode : InstrMapping {
122 let FilterClass = "PredNewRel";
Jyotsna Verma5ed51812013-05-01 21:37:34 +0000123 let RowFields = ["BaseOpcode", "PredSense", "isNVStore", "isBrTaken"];
Jyotsna Vermaefe4f552012-12-04 04:29:16 +0000124 let ColFields = ["PNewValue"];
125 let KeyCol = [""];
126 let ValueCols = [["new"]];
127}
128
129//===----------------------------------------------------------------------===//
Jyotsna Verma438cec52013-05-10 20:58:11 +0000130// Generate mapping table to relate .new predicated instructions with their old
131// format.
132//
133def 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 Vermaefe4f552012-12-04 04:29:16 +0000142// Generate mapping table to relate store instructions with their new-value
143// format.
144//
145def getNewValueOpcode : InstrMapping {
146 let FilterClass = "NewValueRel";
Colin LeMahieu7c958712015-10-17 01:33:04 +0000147 let RowFields = ["BaseOpcode", "PredSense", "PNewValue", "addrMode", "isNT"];
Jyotsna Verma300f0b92013-05-10 20:27:34 +0000148 let ColFields = ["NValueST"];
149 let KeyCol = ["false"];
150 let ValueCols = [["true"]];
Jyotsna Vermaefe4f552012-12-04 04:29:16 +0000151}
152
Jyotsna Verma438cec52013-05-10 20:58:11 +0000153//===----------------------------------------------------------------------===//
154// Generate mapping table to relate new-value store instructions with their old
155// format.
156//
157def getNonNVStore : InstrMapping {
158 let FilterClass = "NewValueRel";
Colin LeMahieu7c958712015-10-17 01:33:04 +0000159 let RowFields = ["BaseOpcode", "PredSense", "PNewValue", "addrMode", "isNT"];
Jyotsna Verma438cec52013-05-10 20:58:11 +0000160 let ColFields = ["NValueST"];
161 let KeyCol = ["true"];
162 let ValueCols = [["false"]];
163}
164
Krzysztof Parzyszek02579052015-10-20 19:21:05 +0000165def getBaseWithImmOffset : InstrMapping {
Jyotsna Vermaefe4f552012-12-04 04:29:16 +0000166 let FilterClass = "AddrModeRel";
167 let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore",
Krzysztof Parzyszek05da79d2015-10-20 19:04:53 +0000168 "isFloat"];
Jyotsna Vermaefe4f552012-12-04 04:29:16 +0000169 let ColFields = ["addrMode"];
170 let KeyCol = ["Absolute"];
171 let ValueCols = [["BaseImmOffset"]];
172}
173
174def 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
182def 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 Parzyszekb9a1c3a2015-11-24 14:55:26 +0000190def 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
198def 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
206def 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
214def 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 Vermaefe4f552012-12-04 04:29:16 +0000221//===----------------------------------------------------------------------===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000222// Register File, Calling Conv, Instruction Descriptions
223//===----------------------------------------------------------------------===//
224include "HexagonSchedule.td"
225include "HexagonRegisterInfo.td"
226include "HexagonCallingConv.td"
227include "HexagonInstrInfo.td"
228include "HexagonIntrinsics.td"
229include "HexagonIntrinsicsDerived.td"
230
Evandro Menezes5cee6212012-04-12 17:55:53 +0000231def HexagonInstrInfo : InstrInfo;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000232
233//===----------------------------------------------------------------------===//
234// Hexagon processors supported.
235//===----------------------------------------------------------------------===//
236
Andrew Trick87255e32012-07-07 04:00:00 +0000237class Proc<string Name, SchedMachineModel Model,
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000238 list<SubtargetFeature> Features>
Andrew Trick87255e32012-07-07 04:00:00 +0000239 : ProcessorModel<Name, Model, Features>;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000240
Colin LeMahieu4fd203d2015-02-09 21:56:37 +0000241def : Proc<"hexagonv4", HexagonModelV4,
242 [ArchV4]>;
243def : Proc<"hexagonv5", HexagonModelV4,
244 [ArchV4, ArchV5]>;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000245def : Proc<"hexagonv55", HexagonModelV55,
246 [ArchV4, ArchV5, ArchV55]>;
247def : Proc<"hexagonv60", HexagonModelV60,
248 [ArchV4, ArchV5, ArchV55, ArchV60, ExtensionHVX]>;
Sirish Pande69295b82012-05-10 20:20:25 +0000249
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000250//===----------------------------------------------------------------------===//
251// Declare the target which we are implementing
252//===----------------------------------------------------------------------===//
253
Craig Topperfd2c6a32015-12-31 08:18:23 +0000254def HexagonAsmParser : AsmParser {
Krzysztof Parzyszekadf02ae2016-04-21 19:49:53 +0000255 let ShouldEmitMatchRegisterAltName = 1;
Craig Topperfd2c6a32015-12-31 08:18:23 +0000256 bit HasMnemonicFirst = 0;
257}
258
Colin LeMahieu7cd08922015-11-09 04:07:48 +0000259def HexagonAsmParserVariant : AsmParserVariant {
260 int Variant = 0;
261 string TokenizingCharacters = "#()=:.<>!+*";
262}
263
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000264def Hexagon : Target {
265 // Pull in Instruction Info:
266 let InstructionSet = HexagonInstrInfo;
Craig Topperfd2c6a32015-12-31 08:18:23 +0000267 let AssemblyParsers = [HexagonAsmParser];
Colin LeMahieu7cd08922015-11-09 04:07:48 +0000268 let AssemblyParserVariants = [HexagonAsmParserVariant];
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000269}