c0631c4bbbdf6823d1dadf4018858acac1214b76
[oota-llvm.git] / lib / Target / Hexagon / Hexagon.td
1 //===-- Hexagon.td - Describe the Hexagon Target Machine --*- tablegen -*--===//
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 is the top level entry point for the Hexagon target.
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.
22 //===----------------------------------------------------------------------===//
23
24 // Hexagon Architectures
25 def ArchV4:  SubtargetFeature<"v4",  "HexagonArchVersion", "V4",  "Hexagon V4">;
26 def ArchV5:  SubtargetFeature<"v5",  "HexagonArchVersion", "V5",  "Hexagon V5">;
27 def ArchV55: SubtargetFeature<"v55", "HexagonArchVersion", "V55", "Hexagon V55">;
28 def ArchV60: SubtargetFeature<"v60", "HexagonArchVersion", "V60", "Hexagon V60">;
29
30 // Hexagon ISA Extensions
31 def ExtensionHVX: SubtargetFeature<"hvx", "UseHVXOps",
32                                    "true", "Hexagon HVX instructions">;
33 //===----------------------------------------------------------------------===//
34 // Hexagon Instruction Predicate Definitions.
35 //===----------------------------------------------------------------------===//
36 def HasV5T             : Predicate<"HST->hasV5TOps()">;
37 def NoV5T              : Predicate<"!HST->hasV5TOps()">;
38 def HasV55T            : Predicate<"HST->hasV55TOps()">,
39                          AssemblerPredicate<"ArchV55">;
40 def HasV60T            : Predicate<"HST->hasV60TOps()">,
41                          AssemblerPredicate<"ArchV60">;
42 def UseMEMOP           : Predicate<"HST->useMemOps()">;
43 def IEEERndNearV5T     : Predicate<"HST->modeIEEERndNear()">;
44 def UseHVXDbl          : Predicate<"HST->useHVXDblOps()">,
45                          AssemblerPredicate<"ExtensionHVXDbl">;
46 def UseHVXSgl          : Predicate<"HST->useHVXSglOps()">;
47
48 def UseHVX             : Predicate<"HST->useHVXOps()">,
49                          AssemblerPredicate<"ExtensionHVX">;
50
51 //===----------------------------------------------------------------------===//
52 // Classes used for relation maps.
53 //===----------------------------------------------------------------------===//
54
55 class ImmRegShl;
56 // PredRel - Filter class used to relate non-predicated instructions with their
57 // predicated forms.
58 class PredRel;
59 // PredNewRel - Filter class used to relate predicated instructions with their
60 // predicate-new forms.
61 class PredNewRel: PredRel;
62 // ImmRegRel - Filter class used to relate instructions having reg-reg form
63 // with their reg-imm counterparts.
64 class ImmRegRel;
65 // NewValueRel - Filter class used to relate regular store instructions with
66 // their new-value store form.
67 class NewValueRel: PredNewRel;
68 // NewValueRel - Filter class used to relate load/store instructions having
69 // different addressing modes with each other.
70 class AddrModeRel: NewValueRel;
71
72 //===----------------------------------------------------------------------===//
73 // Generate mapping table to relate non-predicate instructions with their
74 // predicated formats - true and false.
75 //
76
77 def getPredOpcode : InstrMapping {
78   let FilterClass = "PredRel";
79   // Instructions with the same BaseOpcode and isNVStore values form a row.
80   let RowFields = ["BaseOpcode", "isNVStore", "PNewValue", "isNT"];
81   // Instructions with the same predicate sense form a column.
82   let ColFields = ["PredSense"];
83   // The key column is the unpredicated instructions.
84   let KeyCol = [""];
85   // Value columns are PredSense=true and PredSense=false
86   let ValueCols = [["true"], ["false"]];
87 }
88
89 //===----------------------------------------------------------------------===//
90 // Generate mapping table to relate predicate-true instructions with their
91 // predicate-false forms
92 //
93 def getFalsePredOpcode : InstrMapping {
94   let FilterClass = "PredRel";
95   let RowFields = ["BaseOpcode", "PNewValue", "isNVStore", "isBrTaken", "isNT"];
96   let ColFields = ["PredSense"];
97   let KeyCol = ["true"];
98   let ValueCols = [["false"]];
99 }
100
101 //===----------------------------------------------------------------------===//
102 // Generate mapping table to relate predicate-false instructions with their
103 // predicate-true forms
104 //
105 def getTruePredOpcode : InstrMapping {
106   let FilterClass = "PredRel";
107   let RowFields = ["BaseOpcode", "PNewValue", "isNVStore", "isBrTaken", "isNT"];
108   let ColFields = ["PredSense"];
109   let KeyCol = ["false"];
110   let ValueCols = [["true"]];
111 }
112
113 //===----------------------------------------------------------------------===//
114 // Generate mapping table to relate predicated instructions with their .new
115 // format.
116 //
117 def getPredNewOpcode : InstrMapping {
118   let FilterClass = "PredNewRel";
119   let RowFields = ["BaseOpcode", "PredSense", "isNVStore", "isBrTaken"];
120   let ColFields = ["PNewValue"];
121   let KeyCol = [""];
122   let ValueCols = [["new"]];
123 }
124
125 //===----------------------------------------------------------------------===//
126 // Generate mapping table to relate .new predicated instructions with their old
127 // format.
128 //
129 def getPredOldOpcode : InstrMapping {
130   let FilterClass = "PredNewRel";
131   let RowFields = ["BaseOpcode", "PredSense", "isNVStore"];
132   let ColFields = ["PNewValue"];
133   let KeyCol = ["new"];
134   let ValueCols = [[""]];
135 }
136
137 //===----------------------------------------------------------------------===//
138 // Generate mapping table to relate store instructions with their new-value
139 // format.
140 //
141 def getNewValueOpcode : InstrMapping {
142   let FilterClass = "NewValueRel";
143   let RowFields = ["BaseOpcode", "PredSense", "PNewValue", "addrMode", "isNT"];
144   let ColFields = ["NValueST"];
145   let KeyCol = ["false"];
146   let ValueCols = [["true"]];
147 }
148
149 //===----------------------------------------------------------------------===//
150 // Generate mapping table to relate new-value store instructions with their old
151 // format.
152 //
153 def getNonNVStore : InstrMapping {
154   let FilterClass = "NewValueRel";
155   let RowFields = ["BaseOpcode", "PredSense", "PNewValue", "addrMode", "isNT"];
156   let ColFields = ["NValueST"];
157   let KeyCol = ["true"];
158   let ValueCols = [["false"]];
159 }
160
161 def getBaseWithImmOffset : InstrMapping {
162   let FilterClass = "AddrModeRel";
163   let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore",
164                    "isFloat"];
165   let ColFields = ["addrMode"];
166   let KeyCol = ["Absolute"];
167   let ValueCols = [["BaseImmOffset"]];
168 }
169
170 def getBaseWithRegOffset : InstrMapping {
171   let FilterClass = "AddrModeRel";
172   let RowFields = ["CextOpcode", "PredSense", "PNewValue", "isNVStore"];
173   let ColFields = ["addrMode"];
174   let KeyCol = ["BaseImmOffset"];
175   let ValueCols = [["BaseRegOffset"]];
176 }
177
178 def getRegForm : InstrMapping {
179   let FilterClass = "ImmRegRel";
180   let RowFields = ["CextOpcode", "PredSense", "PNewValue"];
181   let ColFields = ["InputType"];
182   let KeyCol = ["imm"];
183   let ValueCols = [["reg"]];
184 }
185
186 //===----------------------------------------------------------------------===//
187 // Register File, Calling Conv, Instruction Descriptions
188 //===----------------------------------------------------------------------===//
189 include "HexagonSchedule.td"
190 include "HexagonRegisterInfo.td"
191 include "HexagonCallingConv.td"
192 include "HexagonInstrInfo.td"
193 include "HexagonIntrinsics.td"
194 include "HexagonIntrinsicsDerived.td"
195
196 def HexagonInstrInfo : InstrInfo;
197
198 //===----------------------------------------------------------------------===//
199 // Hexagon processors supported.
200 //===----------------------------------------------------------------------===//
201
202 class Proc<string Name, SchedMachineModel Model,
203            list<SubtargetFeature> Features>
204  : ProcessorModel<Name, Model, Features>;
205
206 def : Proc<"hexagonv4",  HexagonModelV4,
207            [ArchV4]>;
208 def : Proc<"hexagonv5",  HexagonModelV4,
209            [ArchV4, ArchV5]>;
210
211 //===----------------------------------------------------------------------===//
212 // Declare the target which we are implementing
213 //===----------------------------------------------------------------------===//
214
215 def Hexagon : Target {
216   // Pull in Instruction Info:
217   let InstructionSet = HexagonInstrInfo;
218 }