Debian Codegraph @

suite/synctools/tablegen/ARM/ARMInstrFormats.td

raw
1 //===-- ARMInstrFormats.td - ARM Instruction Formats -------*- 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 //===----------------------------------------------------------------------===//
11 //
12 // ARM Instruction Format Definitions.
13 //
14
15 // Format specifies the encoding used by the instruction. This is part of the
16 // ad-hoc solution used to emit machine instruction encodings by our machine
17 // code emitter.
18 class Format<bits<6> val> {
19 bits<6> Value = val;
20 }
21
22 def Pseudo : Format<0>;
23 def MulFrm : Format<1>;
24 def BrFrm : Format<2>;
25 def BrMiscFrm : Format<3>;
26
27 def DPFrm : Format<4>;
28 def DPSoRegRegFrm : Format<5>;
29
30 def LdFrm : Format<6>;
31 def StFrm : Format<7>;
32 def LdMiscFrm : Format<8>;
33 def StMiscFrm : Format<9>;
34 def LdStMulFrm : Format<10>;
35
36 def LdStExFrm : Format<11>;
37
38 def ArithMiscFrm : Format<12>;
39 def SatFrm : Format<13>;
40 def ExtFrm : Format<14>;
41
42 def VFPUnaryFrm : Format<15>;
43 def VFPBinaryFrm : Format<16>;
44 def VFPConv1Frm : Format<17>;
45 def VFPConv2Frm : Format<18>;
46 def VFPConv3Frm : Format<19>;
47 def VFPConv4Frm : Format<20>;
48 def VFPConv5Frm : Format<21>;
49 def VFPLdStFrm : Format<22>;
50 def VFPLdStMulFrm : Format<23>;
51 def VFPMiscFrm : Format<24>;
52
53 def ThumbFrm : Format<25>;
54 def MiscFrm : Format<26>;
55
56 def NGetLnFrm : Format<27>;
57 def NSetLnFrm : Format<28>;
58 def NDupFrm : Format<29>;
59 def NLdStFrm : Format<30>;
60 def N1RegModImmFrm: Format<31>;
61 def N2RegFrm : Format<32>;
62 def NVCVTFrm : Format<33>;
63 def NVDupLnFrm : Format<34>;
64 def N2RegVShLFrm : Format<35>;
65 def N2RegVShRFrm : Format<36>;
66 def N3RegFrm : Format<37>;
67 def N3RegVShFrm : Format<38>;
68 def NVExtFrm : Format<39>;
69 def NVMulSLFrm : Format<40>;
70 def NVTBLFrm : Format<41>;
71 def DPSoRegImmFrm : Format<42>;
72 def N3RegCplxFrm : Format<43>;
73
74 // Misc flags.
75
76 // The instruction has an Rn register operand.
77 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
78 // it doesn't have a Rn operand.
79 class UnaryDP { bit isUnaryDataProc = 1; }
80
81 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
82 // a 16-bit Thumb instruction if certain conditions are met.
83 class Xform16Bit { bit canXformTo16Bit = 1; }
84
85 //===----------------------------------------------------------------------===//
86 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
87 //
88
89 // FIXME: Once the JIT is MC-ized, these can go away.
90 // Addressing mode.
91 class AddrMode<bits<5> val> {
92 bits<5> Value = val;
93 }
94 def AddrModeNone : AddrMode<0>;
95 def AddrMode1 : AddrMode<1>;
96 def AddrMode2 : AddrMode<2>;
97 def AddrMode3 : AddrMode<3>;
98 def AddrMode4 : AddrMode<4>;
99 def AddrMode5 : AddrMode<5>;
100 def AddrMode6 : AddrMode<6>;
101 def AddrModeT1_1 : AddrMode<7>;
102 def AddrModeT1_2 : AddrMode<8>;
103 def AddrModeT1_4 : AddrMode<9>;
104 def AddrModeT1_s : AddrMode<10>;
105 def AddrModeT2_i12 : AddrMode<11>;
106 def AddrModeT2_i8 : AddrMode<12>;
107 def AddrModeT2_so : AddrMode<13>;
108 def AddrModeT2_pc : AddrMode<14>;
109 def AddrModeT2_i8s4 : AddrMode<15>;
110 def AddrMode_i12 : AddrMode<16>;
111 def AddrMode5FP16 : AddrMode<17>;
112 def AddrModeT2_ldrex : AddrMode<18>;
113
114 // Load / store index mode.
115 class IndexMode<bits<2> val> {
116 bits<2> Value = val;
117 }
118 def IndexModeNone : IndexMode<0>;
119 def IndexModePre : IndexMode<1>;
120 def IndexModePost : IndexMode<2>;
121 def IndexModeUpd : IndexMode<3>;
122
123 // Instruction execution domain.
124 class Domain<bits<3> val> {
125 bits<3> Value = val;
126 }
127 def GenericDomain : Domain<0>;
128 def VFPDomain : Domain<1>; // Instructions in VFP domain only
129 def NeonDomain : Domain<2>; // Instructions in Neon domain only
130 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
131 def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
132
133 //===----------------------------------------------------------------------===//
134 // ARM special operands.
135 //
136
137 // ARM imod and iflag operands, used only by the CPS instruction.
138 def imod_op : Operand<i32> {
139 let PrintMethod = "printCPSIMod";
140 }
141
142 def ProcIFlagsOperand : AsmOperandClass {
143 let Name = "ProcIFlags";
144 let ParserMethod = "parseProcIFlagsOperand";
145 }
146 def iflags_op : Operand<i32> {
147 let PrintMethod = "printCPSIFlag";
148 let ParserMatchClass = ProcIFlagsOperand;
149 }
150
151 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
152 // register whose default is 0 (no register).
153 def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
154 def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
155 (ops (i32 14), (i32 zero_reg))> {
156 let PrintMethod = "printPredicateOperand";
157 let ParserMatchClass = CondCodeOperand;
158 let DecoderMethod = "DecodePredicateOperand";
159 }
160
161 // Selectable predicate operand for CMOV instructions. We can't use a normal
162 // predicate because the default values interfere with instruction selection. In
163 // all other respects it is identical though: pseudo-instruction expansion
164 // relies on the MachineOperands being compatible.
165 def cmovpred : Operand<i32>, PredicateOp,
166 ComplexPattern<i32, 2, "SelectCMOVPred"> {
167 let MIOperandInfo = (ops i32imm, i32imm);
168 let PrintMethod = "printPredicateOperand";
169 }
170
171 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
172 def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
173 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
174 let EncoderMethod = "getCCOutOpValue";
175 let PrintMethod = "printSBitModifierOperand";
176 let ParserMatchClass = CCOutOperand;
177 let DecoderMethod = "DecodeCCOutOperand";
178 }
179
180 // Same as cc_out except it defaults to setting CPSR.
181 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
182 let EncoderMethod = "getCCOutOpValue";
183 let PrintMethod = "printSBitModifierOperand";
184 let ParserMatchClass = CCOutOperand;
185 let DecoderMethod = "DecodeCCOutOperand";
186 }
187
188 // ARM special operands for disassembly only.
189 //
190 def SetEndAsmOperand : ImmAsmOperand<0,1> {
191 let Name = "SetEndImm";
192 let ParserMethod = "parseSetEndImm";
193 }
194 def setend_op : Operand<i32> {
195 let PrintMethod = "printSetendOperand";
196 let ParserMatchClass = SetEndAsmOperand;
197 }
198
199 def MSRMaskOperand : AsmOperandClass {
200 let Name = "MSRMask";
201 let ParserMethod = "parseMSRMaskOperand";
202 }
203 def msr_mask : Operand<i32> {
204 let PrintMethod = "printMSRMaskOperand";
205 let DecoderMethod = "DecodeMSRMask";
206 let ParserMatchClass = MSRMaskOperand;
207 }
208
209 def BankedRegOperand : AsmOperandClass {
210 let Name = "BankedReg";
211 let ParserMethod = "parseBankedRegOperand";
212 }
213 def banked_reg : Operand<i32> {
214 let PrintMethod = "printBankedRegOperand";
215 let DecoderMethod = "DecodeBankedReg";
216 let ParserMatchClass = BankedRegOperand;
217 }
218
219 // Shift Right Immediate - A shift right immediate is encoded differently from
220 // other shift immediates. The imm6 field is encoded like so:
221 //
222 // Offset Encoding
223 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
224 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
225 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
226 // 64 64 - <imm> is encoded in imm6<5:0>
227 def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
228 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
229 let EncoderMethod = "getShiftRight8Imm";
230 let DecoderMethod = "DecodeShiftRight8Imm";
231 let ParserMatchClass = shr_imm8_asm_operand;
232 }
233 def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
234 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
235 let EncoderMethod = "getShiftRight16Imm";
236 let DecoderMethod = "DecodeShiftRight16Imm";
237 let ParserMatchClass = shr_imm16_asm_operand;
238 }
239 def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
240 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
241 let EncoderMethod = "getShiftRight32Imm";
242 let DecoderMethod = "DecodeShiftRight32Imm";
243 let ParserMatchClass = shr_imm32_asm_operand;
244 }
245 def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
246 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
247 let EncoderMethod = "getShiftRight64Imm";
248 let DecoderMethod = "DecodeShiftRight64Imm";
249 let ParserMatchClass = shr_imm64_asm_operand;
250 }
251
252
253 // ARM Assembler operand for ldr Rd, =expression which generates an offset
254 // to a constant pool entry or a MOV depending on the value of expression
255 def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
256 def const_pool_asm_imm : Operand<i32> {
257 let ParserMatchClass = const_pool_asm_operand;
258 }
259
260
261 //===----------------------------------------------------------------------===//
262 // ARM Assembler alias templates.
263 //
264 // Note: When EmitPriority == 1, the alias will be used for printing
265 class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
266 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
267 class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
268 : InstAlias<Asm, Result, EmitPriority>,
269 Requires<[IsARM,UseNegativeImmediates]>;
270 class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
271 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
272 class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
273 : InstAlias<Asm, Result, EmitPriority>,
274 Requires<[IsThumb,UseNegativeImmediates]>;
275 class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
276 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
277 class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
278 : InstAlias<Asm, Result, EmitPriority>,
279 Requires<[IsThumb2,UseNegativeImmediates]>;
280 class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
281 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
282 class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
283 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
284 class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
285 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
286 class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
287 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
288
289
290 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
291 Requires<[HasVFP2]>;
292 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
293 Requires<[HasNEON]>;
294
295 //===----------------------------------------------------------------------===//
296 // ARM Instruction templates.
297 //
298
299
300 class InstTemplate<AddrMode am, int sz, IndexMode im,
301 Format f, Domain d, string cstr, InstrItinClass itin>
302 : Instruction {
303 let Namespace = "ARM";
304
305 AddrMode AM = am;
306 int Size = sz;
307 IndexMode IM = im;
308 bits<2> IndexModeBits = IM.Value;
309 Format F = f;
310 bits<6> Form = F.Value;
311 Domain D = d;
312 bit isUnaryDataProc = 0;
313 bit canXformTo16Bit = 0;
314 // The instruction is a 16-bit flag setting Thumb instruction. Used
315 // by the parser to determine whether to require the 'S' suffix on the
316 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
317 bit thumbArithFlagSetting = 0;
318
319 // If this is a pseudo instruction, mark it isCodeGenOnly.
320 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
321
322 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
323 let TSFlags{4-0} = AM.Value;
324 let TSFlags{6-5} = IndexModeBits;
325 let TSFlags{12-7} = Form;
326 let TSFlags{13} = isUnaryDataProc;
327 let TSFlags{14} = canXformTo16Bit;
328 let TSFlags{17-15} = D.Value;
329 let TSFlags{18} = thumbArithFlagSetting;
330
331 let Constraints = cstr;
332 let Itinerary = itin;
333 }
334
335 class Encoding {
336 field bits<32> Inst;
337 // Mask of bits that cause an encoding to be UNPREDICTABLE.
338 // If a bit is set, then if the corresponding bit in the
339 // target encoding differs from its value in the "Inst" field,
340 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
341 field bits<32> Unpredictable = 0;
342 // SoftFail is the generic name for this field, but we alias it so
343 // as to make it more obvious what it means in ARM-land.
344 field bits<32> SoftFail = Unpredictable;
345 }
346
347 class InstARM<AddrMode am, int sz, IndexMode im,
348 Format f, Domain d, string cstr, InstrItinClass itin>
349 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
350 let DecoderNamespace = "ARM";
351 }
352
353 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
354 // on by adding flavors to specific instructions.
355 class InstThumb<AddrMode am, int sz, IndexMode im,
356 Format f, Domain d, string cstr, InstrItinClass itin>
357 : InstTemplate<am, sz, im, f, d, cstr, itin> {
358 let DecoderNamespace = "Thumb";
359 }
360
361 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
362 // These are aliases that require C++ handling to convert to the target
363 // instruction, while InstAliases can be handled directly by tblgen.
364 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
365 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
366 "", NoItinerary> {
367 let OutOperandList = oops;
368 let InOperandList = iops;
369 let Pattern = [];
370 let isCodeGenOnly = 0; // So we get asm matcher for it.
371 let AsmString = asm;
372 let isPseudo = 1;
373 }
374
375 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
376 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
377 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
378 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
379 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
380 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
381 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
382 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
383 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
384 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
385
386 // Pseudo instructions for the code generator.
387 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
388 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
389 GenericDomain, "", itin> {
390 let OutOperandList = oops;
391 let InOperandList = iops;
392 let Pattern = pattern;
393 let isCodeGenOnly = 1;
394 let isPseudo = 1;
395 }
396
397 // PseudoInst that's ARM-mode only.
398 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
399 list<dag> pattern>
400 : PseudoInst<oops, iops, itin, pattern> {
401 let Size = sz;
402 list<Predicate> Predicates = [IsARM];
403 }
404
405 // PseudoInst that's Thumb-mode only.
406 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
407 list<dag> pattern>
408 : PseudoInst<oops, iops, itin, pattern> {
409 let Size = sz;
410 list<Predicate> Predicates = [IsThumb];
411 }
412
413 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
414 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
415 list<dag> pattern>
416 : PseudoInst<oops, iops, itin, pattern> {
417 let Size = sz;
418 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
419 }
420
421 // PseudoInst that's Thumb2-mode only.
422 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
423 list<dag> pattern>
424 : PseudoInst<oops, iops, itin, pattern> {
425 let Size = sz;
426 list<Predicate> Predicates = [IsThumb2];
427 }
428
429 class ARMPseudoExpand<dag oops, dag iops, int sz,
430 InstrItinClass itin, list<dag> pattern,
431 dag Result>
432 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
433 PseudoInstExpansion<Result>;
434
435 class tPseudoExpand<dag oops, dag iops, int sz,
436 InstrItinClass itin, list<dag> pattern,
437 dag Result>
438 : tPseudoInst<oops, iops, sz, itin, pattern>,
439 PseudoInstExpansion<Result>;
440
441 class t2PseudoExpand<dag oops, dag iops, int sz,
442 InstrItinClass itin, list<dag> pattern,
443 dag Result>
444 : t2PseudoInst<oops, iops, sz, itin, pattern>,
445 PseudoInstExpansion<Result>;
446
447 // Almost all ARM instructions are predicable.
448 class I<dag oops, dag iops, AddrMode am, int sz,
449 IndexMode im, Format f, InstrItinClass itin,
450 string opc, string asm, string cstr,
451 list<dag> pattern>
452 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
453 bits<4> p;
454 let Inst{31-28} = p;
455 let OutOperandList = oops;
456 let InOperandList = !con(iops, (ins pred:$p));
457 let AsmString = !strconcat(opc, "${p}", asm);
458 let Pattern = pattern;
459 list<Predicate> Predicates = [IsARM];
460 }
461
462 // A few are not predicable
463 class InoP<dag oops, dag iops, AddrMode am, int sz,
464 IndexMode im, Format f, InstrItinClass itin,
465 string opc, string asm, string cstr,
466 list<dag> pattern>
467 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
468 let OutOperandList = oops;
469 let InOperandList = iops;
470 let AsmString = !strconcat(opc, asm);
471 let Pattern = pattern;
472 let isPredicable = 0;
473 list<Predicate> Predicates = [IsARM];
474 }
475
476 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
477 // operand since by default it's a zero register. It will become an implicit def
478 // once it's "flipped".
479 class sI<dag oops, dag iops, AddrMode am, int sz,
480 IndexMode im, Format f, InstrItinClass itin,
481 string opc, string asm, string cstr,
482 list<dag> pattern>
483 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
484 bits<4> p; // Predicate operand
485 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
486 let Inst{31-28} = p;
487 let Inst{20} = s;
488
489 let OutOperandList = oops;
490 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
491 let AsmString = !strconcat(opc, "${s}${p}", asm);
492 let Pattern = pattern;
493 list<Predicate> Predicates = [IsARM];
494 }
495
496 // Special cases
497 class XI<dag oops, dag iops, AddrMode am, int sz,
498 IndexMode im, Format f, InstrItinClass itin,
499 string asm, string cstr, list<dag> pattern>
500 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
501 let OutOperandList = oops;
502 let InOperandList = iops;
503 let AsmString = asm;
504 let Pattern = pattern;
505 list<Predicate> Predicates = [IsARM];
506 }
507
508 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
509 string opc, string asm, list<dag> pattern>
510 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
511 opc, asm, "", pattern>;
512 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
513 string opc, string asm, list<dag> pattern>
514 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
515 opc, asm, "", pattern>;
516 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
517 string asm, list<dag> pattern>
518 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
519 asm, "", pattern>;
520 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
521 string asm, list<dag> pattern>
522 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
523 asm, "", pattern>;
524 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
525 string opc, string asm, list<dag> pattern>
526 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
527 opc, asm, "", pattern>;
528
529 // Ctrl flow instructions
530 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
531 string opc, string asm, list<dag> pattern>
532 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
533 opc, asm, "", pattern> {
534 let Inst{27-24} = opcod;
535 }
536 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
537 string asm, list<dag> pattern>
538 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
539 asm, "", pattern> {
540 let Inst{27-24} = opcod;
541 }
542
543 // BR_JT instructions
544 class JTI<dag oops, dag iops, InstrItinClass itin,
545 string asm, list<dag> pattern>
546 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
547 asm, "", pattern>;
548
549 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
550 string opc, string asm, list<dag> pattern>
551 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
552 opc, asm, "", pattern> {
553 bits<4> Rt;
554 bits<4> addr;
555 let Inst{27-23} = 0b00011;
556 let Inst{22-21} = opcod;
557 let Inst{20} = 1;
558 let Inst{19-16} = addr;
559 let Inst{15-12} = Rt;
560 let Inst{11-10} = 0b11;
561 let Inst{9-8} = opcod2;
562 let Inst{7-0} = 0b10011111;
563 }
564 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
565 string opc, string asm, list<dag> pattern>
566 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
567 opc, asm, "", pattern> {
568 bits<4> Rt;
569 bits<4> addr;
570 let Inst{27-23} = 0b00011;
571 let Inst{22-21} = opcod;
572 let Inst{20} = 0;
573 let Inst{19-16} = addr;
574 let Inst{11-10} = 0b11;
575 let Inst{9-8} = opcod2;
576 let Inst{7-4} = 0b1001;
577 let Inst{3-0} = Rt;
578 }
579 // Atomic load/store instructions
580 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
581 string opc, string asm, list<dag> pattern>
582 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
583
584 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
585 string opc, string asm, list<dag> pattern>
586 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
587 bits<4> Rd;
588 let Inst{15-12} = Rd;
589 }
590
591 // Exclusive load/store instructions
592
593 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
594 string opc, string asm, list<dag> pattern>
595 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
596 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
597
598 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
599 string opc, string asm, list<dag> pattern>
600 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
601 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
602 bits<4> Rd;
603 let Inst{15-12} = Rd;
604 }
605
606 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
607 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
608 bits<4> Rt;
609 bits<4> Rt2;
610 bits<4> addr;
611 let Inst{27-23} = 0b00010;
612 let Inst{22} = b;
613 let Inst{21-20} = 0b00;
614 let Inst{19-16} = addr;
615 let Inst{15-12} = Rt;
616 let Inst{11-4} = 0b00001001;
617 let Inst{3-0} = Rt2;
618
619 let Unpredictable{11-8} = 0b1111;
620 let DecoderMethod = "DecodeSwap";
621 }
622 // Acquire/Release load/store instructions
623 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
624 string opc, string asm, list<dag> pattern>
625 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
626 Requires<[IsARM, HasAcquireRelease]>;
627
628 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
629 string opc, string asm, list<dag> pattern>
630 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
631 Requires<[IsARM, HasAcquireRelease]> {
632 let Inst{15-12} = 0b1111;
633 }
634
635 // addrmode1 instructions
636 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
637 string opc, string asm, list<dag> pattern>
638 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
639 opc, asm, "", pattern> {
640 let Inst{24-21} = opcod;
641 let Inst{27-26} = 0b00;
642 }
643 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
644 string opc, string asm, list<dag> pattern>
645 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
646 opc, asm, "", pattern> {
647 let Inst{24-21} = opcod;
648 let Inst{27-26} = 0b00;
649 }
650 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
651 string asm, list<dag> pattern>
652 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
653 asm, "", pattern> {
654 let Inst{24-21} = opcod;
655 let Inst{27-26} = 0b00;
656 }
657
658 // loads
659
660 // LDR/LDRB/STR/STRB/...
661 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
662 Format f, InstrItinClass itin, string opc, string asm,
663 list<dag> pattern>
664 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
665 "", pattern> {
666 let Inst{27-25} = op;
667 let Inst{24} = 1; // 24 == P
668 // 23 == U
669 let Inst{22} = isByte;
670 let Inst{21} = 0; // 21 == W
671 let Inst{20} = isLd;
672 }
673 // Indexed load/stores
674 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
675 IndexMode im, Format f, InstrItinClass itin, string opc,
676 string asm, string cstr, list<dag> pattern>
677 : I<oops, iops, AddrMode2, 4, im, f, itin,
678 opc, asm, cstr, pattern> {
679 bits<4> Rt;
680 let Inst{27-26} = 0b01;
681 let Inst{24} = isPre; // P bit
682 let Inst{22} = isByte; // B bit
683 let Inst{21} = isPre; // W bit
684 let Inst{20} = isLd; // L bit
685 let Inst{15-12} = Rt;
686 }
687 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
688 IndexMode im, Format f, InstrItinClass itin, string opc,
689 string asm, string cstr, list<dag> pattern>
690 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
691 pattern> {
692 // AM2 store w/ two operands: (GPR, am2offset)
693 // {12} isAdd
694 // {11-0} imm12/Rm
695 bits<14> offset;
696 bits<4> Rn;
697 let Inst{25} = 1;
698 let Inst{23} = offset{12};
699 let Inst{19-16} = Rn;
700 let Inst{11-5} = offset{11-5};
701 let Inst{4} = 0;
702 let Inst{3-0} = offset{3-0};
703 }
704
705 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
706 IndexMode im, Format f, InstrItinClass itin, string opc,
707 string asm, string cstr, list<dag> pattern>
708 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
709 pattern> {
710 // AM2 store w/ two operands: (GPR, am2offset)
711 // {12} isAdd
712 // {11-0} imm12/Rm
713 bits<14> offset;
714 bits<4> Rn;
715 let Inst{25} = 0;
716 let Inst{23} = offset{12};
717 let Inst{19-16} = Rn;
718 let Inst{11-0} = offset{11-0};
719 }
720
721
722 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
723 // but for now use this class for STRT and STRBT.
724 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
725 IndexMode im, Format f, InstrItinClass itin, string opc,
726 string asm, string cstr, list<dag> pattern>
727 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
728 pattern> {
729 // AM2 store w/ two operands: (GPR, am2offset)
730 // {17-14} Rn
731 // {13} 1 == Rm, 0 == imm12
732 // {12} isAdd
733 // {11-0} imm12/Rm
734 bits<18> addr;
735 let Inst{25} = addr{13};
736 let Inst{23} = addr{12};
737 let Inst{19-16} = addr{17-14};
738 let Inst{11-0} = addr{11-0};
739 }
740
741 // addrmode3 instructions
742 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
743 InstrItinClass itin, string opc, string asm, list<dag> pattern>
744 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
745 opc, asm, "", pattern> {
746 bits<14> addr;
747 bits<4> Rt;
748 let Inst{27-25} = 0b000;
749 let Inst{24} = 1; // P bit
750 let Inst{23} = addr{8}; // U bit
751 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
752 let Inst{21} = 0; // W bit
753 let Inst{20} = op20; // L bit
754 let Inst{19-16} = addr{12-9}; // Rn
755 let Inst{15-12} = Rt; // Rt
756 let Inst{11-8} = addr{7-4}; // imm7_4/zero
757 let Inst{7-4} = op;
758 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
759
760 let DecoderMethod = "DecodeAddrMode3Instruction";
761 }
762
763 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
764 IndexMode im, Format f, InstrItinClass itin, string opc,
765 string asm, string cstr, list<dag> pattern>
766 : I<oops, iops, AddrMode3, 4, im, f, itin,
767 opc, asm, cstr, pattern> {
768 bits<4> Rt;
769 let Inst{27-25} = 0b000;
770 let Inst{24} = isPre; // P bit
771 let Inst{21} = isPre; // W bit
772 let Inst{20} = op20; // L bit
773 let Inst{15-12} = Rt; // Rt
774 let Inst{7-4} = op;
775 }
776
777 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
778 // but for now use this class for LDRSBT, LDRHT, LDSHT.
779 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
780 IndexMode im, Format f, InstrItinClass itin, string opc,
781 string asm, string cstr, list<dag> pattern>
782 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
783 // {13} 1 == imm8, 0 == Rm
784 // {12-9} Rn
785 // {8} isAdd
786 // {7-4} imm7_4/zero
787 // {3-0} imm3_0/Rm
788 bits<4> addr;
789 bits<4> Rt;
790 let Inst{27-25} = 0b000;
791 let Inst{24} = 0; // P bit
792 let Inst{21} = 1;
793 let Inst{20} = isLoad; // L bit
794 let Inst{19-16} = addr; // Rn
795 let Inst{15-12} = Rt; // Rt
796 let Inst{7-4} = op;
797 }
798
799 // stores
800 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
801 string opc, string asm, list<dag> pattern>
802 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
803 opc, asm, "", pattern> {
804 bits<14> addr;
805 bits<4> Rt;
806 let Inst{27-25} = 0b000;
807 let Inst{24} = 1; // P bit
808 let Inst{23} = addr{8}; // U bit
809 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
810 let Inst{21} = 0; // W bit
811 let Inst{20} = 0; // L bit
812 let Inst{19-16} = addr{12-9}; // Rn
813 let Inst{15-12} = Rt; // Rt
814 let Inst{11-8} = addr{7-4}; // imm7_4/zero
815 let Inst{7-4} = op;
816 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
817 let DecoderMethod = "DecodeAddrMode3Instruction";
818 }
819
820 // addrmode4 instructions
821 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
822 string asm, string cstr, list<dag> pattern>
823 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
824 bits<4> p;
825 bits<16> regs;
826 bits<4> Rn;
827 let Inst{31-28} = p;
828 let Inst{27-25} = 0b100;
829 let Inst{22} = 0; // S bit
830 let Inst{19-16} = Rn;
831 let Inst{15-0} = regs;
832 }
833
834 // Unsigned multiply, multiply-accumulate instructions.
835 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
836 string opc, string asm, list<dag> pattern>
837 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
838 opc, asm, "", pattern> {
839 let Inst{7-4} = 0b1001;
840 let Inst{20} = 0; // S bit
841 let Inst{27-21} = opcod;
842 }
843 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
844 string opc, string asm, list<dag> pattern>
845 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
846 opc, asm, "", pattern> {
847 let Inst{7-4} = 0b1001;
848 let Inst{27-21} = opcod;
849 }
850
851 // Most significant word multiply
852 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
853 InstrItinClass itin, string opc, string asm, list<dag> pattern>
854 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
855 opc, asm, "", pattern> {
856 bits<4> Rd;
857 bits<4> Rn;
858 bits<4> Rm;
859 let Inst{7-4} = opc7_4;
860 let Inst{20} = 1;
861 let Inst{27-21} = opcod;
862 let Inst{19-16} = Rd;
863 let Inst{11-8} = Rm;
864 let Inst{3-0} = Rn;
865 }
866 // MSW multiple w/ Ra operand
867 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
868 InstrItinClass itin, string opc, string asm, list<dag> pattern>
869 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
870 bits<4> Ra;
871 let Inst{15-12} = Ra;
872 }
873
874 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
875 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
876 InstrItinClass itin, string opc, string asm, list<dag> pattern>
877 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
878 opc, asm, "", pattern> {
879 bits<4> Rn;
880 bits<4> Rm;
881 let Inst{4} = 0;
882 let Inst{7} = 1;
883 let Inst{20} = 0;
884 let Inst{27-21} = opcod;
885 let Inst{6-5} = bit6_5;
886 let Inst{11-8} = Rm;
887 let Inst{3-0} = Rn;
888 }
889 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
890 InstrItinClass itin, string opc, string asm, list<dag> pattern>
891 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
892 bits<4> Rd;
893 let Inst{19-16} = Rd;
894 }
895
896 // AMulxyI with Ra operand
897 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
898 InstrItinClass itin, string opc, string asm, list<dag> pattern>
899 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
900 bits<4> Ra;
901 let Inst{15-12} = Ra;
902 }
903 // SMLAL*
904 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
905 InstrItinClass itin, string opc, string asm, list<dag> pattern>
906 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
907 bits<4> RdLo;
908 bits<4> RdHi;
909 let Inst{19-16} = RdHi;
910 let Inst{15-12} = RdLo;
911 }
912
913 // Extend instructions.
914 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
915 string opc, string asm, list<dag> pattern>
916 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
917 opc, asm, "", pattern> {
918 // All AExtI instructions have Rd and Rm register operands.
919 bits<4> Rd;
920 bits<4> Rm;
921 let Inst{15-12} = Rd;
922 let Inst{3-0} = Rm;
923 let Inst{7-4} = 0b0111;
924 let Inst{9-8} = 0b00;
925 let Inst{27-20} = opcod;
926
927 let Unpredictable{9-8} = 0b11;
928 }
929
930 // Misc Arithmetic instructions.
931 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
932 InstrItinClass itin, string opc, string asm, list<dag> pattern>
933 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
934 opc, asm, "", pattern> {
935 bits<4> Rd;
936 bits<4> Rm;
937 let Inst{27-20} = opcod;
938 let Inst{19-16} = 0b1111;
939 let Inst{15-12} = Rd;
940 let Inst{11-8} = 0b1111;
941 let Inst{7-4} = opc7_4;
942 let Inst{3-0} = Rm;
943 }
944
945 // Division instructions.
946 class ADivA1I<bits<3> opcod, dag oops, dag iops,
947 InstrItinClass itin, string opc, string asm, list<dag> pattern>
948 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
949 opc, asm, "", pattern> {
950 bits<4> Rd;
951 bits<4> Rn;
952 bits<4> Rm;
953 let Inst{27-23} = 0b01110;
954 let Inst{22-20} = opcod;
955 let Inst{19-16} = Rd;
956 let Inst{15-12} = 0b1111;
957 let Inst{11-8} = Rm;
958 let Inst{7-4} = 0b0001;
959 let Inst{3-0} = Rn;
960 }
961
962 // PKH instructions
963 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
964 let Name = "PKHLSLImm";
965 let ParserMethod = "parsePKHLSLImm";
966 }
967 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
968 let PrintMethod = "printPKHLSLShiftImm";
969 let ParserMatchClass = PKHLSLAsmOperand;
970 }
971 def PKHASRAsmOperand : AsmOperandClass {
972 let Name = "PKHASRImm";
973 let ParserMethod = "parsePKHASRImm";
974 }
975 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
976 let PrintMethod = "printPKHASRShiftImm";
977 let ParserMatchClass = PKHASRAsmOperand;
978 }
979
980 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
981 string opc, string asm, list<dag> pattern>
982 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
983 opc, asm, "", pattern> {
984 bits<4> Rd;
985 bits<4> Rn;
986 bits<4> Rm;
987 bits<5> sh;
988 let Inst{27-20} = opcod;
989 let Inst{19-16} = Rn;
990 let Inst{15-12} = Rd;
991 let Inst{11-7} = sh;
992 let Inst{6} = tb;
993 let Inst{5-4} = 0b01;
994 let Inst{3-0} = Rm;
995 }
996
997 //===----------------------------------------------------------------------===//
998
999 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1000 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1001 list<Predicate> Predicates = [IsARM];
1002 }
1003 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1004 list<Predicate> Predicates = [IsARM, HasV5T];
1005 }
1006 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1007 list<Predicate> Predicates = [IsARM, HasV5TE];
1008 }
1009 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1010 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1011 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1012 }
1013 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1014 list<Predicate> Predicates = [IsARM, HasV6];
1015 }
1016 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1017 list<Predicate> Predicates = [HasVFP2];
1018 }
1019 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1020 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1021 }
1022 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1023 list<Predicate> Predicates = [IsThumb2, HasDSP];
1024 }
1025 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1026 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1027 }
1028 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1029 list<Predicate> Predicates = [HasFP16];
1030 }
1031 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1032 list<Predicate> Predicates = [HasFullFP16];
1033 }
1034 //===----------------------------------------------------------------------===//
1035 // Thumb Instruction Format Definitions.
1036 //
1037
1038 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1039 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1040 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1041 let OutOperandList = oops;
1042 let InOperandList = iops;
1043 let AsmString = asm;
1044 let Pattern = pattern;
1045 list<Predicate> Predicates = [IsThumb];
1046 }
1047
1048 // TI - Thumb instruction.
1049 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1050 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1051
1052 // Two-address instructions
1053 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1054 list<dag> pattern>
1055 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1056 pattern>;
1057
1058 // tBL, tBX 32-bit instructions
1059 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1060 dag oops, dag iops, InstrItinClass itin, string asm,
1061 list<dag> pattern>
1062 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1063 Encoding {
1064 let Inst{31-27} = opcod1;
1065 let Inst{15-14} = opcod2;
1066 let Inst{12} = opcod3;
1067 }
1068
1069 // BR_JT instructions
1070 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1071 list<dag> pattern>
1072 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1073
1074 // Thumb1 only
1075 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1076 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1077 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1078 let OutOperandList = oops;
1079 let InOperandList = iops;
1080 let AsmString = asm;
1081 let Pattern = pattern;
1082 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1083 }
1084
1085 class T1I<dag oops, dag iops, InstrItinClass itin,
1086 string asm, list<dag> pattern>
1087 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1088 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1089 string asm, list<dag> pattern>
1090 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1091
1092 // Two-address instructions
1093 class T1It<dag oops, dag iops, InstrItinClass itin,
1094 string asm, string cstr, list<dag> pattern>
1095 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1096 asm, cstr, pattern>;
1097
1098 // Thumb1 instruction that can either be predicated or set CPSR.
1099 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1100 InstrItinClass itin,
1101 string opc, string asm, string cstr, list<dag> pattern>
1102 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1103 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1104 let InOperandList = !con(iops, (ins pred:$p));
1105 let AsmString = !strconcat(opc, "${s}${p}", asm);
1106 let Pattern = pattern;
1107 let thumbArithFlagSetting = 1;
1108 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1109 let DecoderNamespace = "ThumbSBit";
1110 }
1111
1112 class T1sI<dag oops, dag iops, InstrItinClass itin,
1113 string opc, string asm, list<dag> pattern>
1114 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1115
1116 // Two-address instructions
1117 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1118 string opc, string asm, list<dag> pattern>
1119 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1120 "$Rn = $Rdn", pattern>;
1121
1122 // Thumb1 instruction that can be predicated.
1123 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1124 InstrItinClass itin,
1125 string opc, string asm, string cstr, list<dag> pattern>
1126 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1127 let OutOperandList = oops;
1128 let InOperandList = !con(iops, (ins pred:$p));
1129 let AsmString = !strconcat(opc, "${p}", asm);
1130 let Pattern = pattern;
1131 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1132 }
1133
1134 class T1pI<dag oops, dag iops, InstrItinClass itin,
1135 string opc, string asm, list<dag> pattern>
1136 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1137
1138 // Two-address instructions
1139 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1140 string opc, string asm, list<dag> pattern>
1141 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1142 "$Rn = $Rdn", pattern>;
1143
1144 class T1pIs<dag oops, dag iops,
1145 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1146 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1147
1148 class Encoding16 : Encoding {
1149 let Inst{31-16} = 0x0000;
1150 }
1151
1152 // A6.2 16-bit Thumb instruction encoding
1153 class T1Encoding<bits<6> opcode> : Encoding16 {
1154 let Inst{15-10} = opcode;
1155 }
1156
1157 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1158 class T1General<bits<5> opcode> : Encoding16 {
1159 let Inst{15-14} = 0b00;
1160 let Inst{13-9} = opcode;
1161 }
1162
1163 // A6.2.2 Data-processing encoding.
1164 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1165 let Inst{15-10} = 0b010000;
1166 let Inst{9-6} = opcode;
1167 }
1168
1169 // A6.2.3 Special data instructions and branch and exchange encoding.
1170 class T1Special<bits<4> opcode> : Encoding16 {
1171 let Inst{15-10} = 0b010001;
1172 let Inst{9-6} = opcode;
1173 }
1174
1175 // A6.2.4 Load/store single data item encoding.
1176 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1177 let Inst{15-12} = opA;
1178 let Inst{11-9} = opB;
1179 }
1180 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1181
1182 class T1BranchCond<bits<4> opcode> : Encoding16 {
1183 let Inst{15-12} = opcode;
1184 }
1185
1186 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1187 // following bits are used for "opA" (see A6.2.4):
1188 //
1189 // 0b0110 => Immediate, 4 bytes
1190 // 0b1000 => Immediate, 2 bytes
1191 // 0b0111 => Immediate, 1 byte
1192 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1193 InstrItinClass itin, string opc, string asm,
1194 list<dag> pattern>
1195 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1196 T1LoadStore<0b0101, opcode> {
1197 bits<3> Rt;
1198 bits<8> addr;
1199 let Inst{8-6} = addr{5-3}; // Rm
1200 let Inst{5-3} = addr{2-0}; // Rn
1201 let Inst{2-0} = Rt;
1202 }
1203 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1204 InstrItinClass itin, string opc, string asm,
1205 list<dag> pattern>
1206 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1207 T1LoadStore<opA, {opB,?,?}> {
1208 bits<3> Rt;
1209 bits<8> addr;
1210 let Inst{10-6} = addr{7-3}; // imm5
1211 let Inst{5-3} = addr{2-0}; // Rn
1212 let Inst{2-0} = Rt;
1213 }
1214
1215 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1216 class T1Misc<bits<7> opcode> : Encoding16 {
1217 let Inst{15-12} = 0b1011;
1218 let Inst{11-5} = opcode;
1219 }
1220
1221 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1222 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1223 InstrItinClass itin,
1224 string opc, string asm, string cstr, list<dag> pattern>
1225 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1226 let OutOperandList = oops;
1227 let InOperandList = !con(iops, (ins pred:$p));
1228 let AsmString = !strconcat(opc, "${p}", asm);
1229 let Pattern = pattern;
1230 list<Predicate> Predicates = [IsThumb2];
1231 let DecoderNamespace = "Thumb2";
1232 }
1233
1234 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1235 // input operand since by default it's a zero register. It will become an
1236 // implicit def once it's "flipped".
1237 //
1238 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1239 // more consistent.
1240 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1241 InstrItinClass itin,
1242 string opc, string asm, string cstr, list<dag> pattern>
1243 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1244 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1245 let Inst{20} = s;
1246
1247 let OutOperandList = oops;
1248 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1249 let AsmString = !strconcat(opc, "${s}${p}", asm);
1250 let Pattern = pattern;
1251 list<Predicate> Predicates = [IsThumb2];
1252 let DecoderNamespace = "Thumb2";
1253 }
1254
1255 // Special cases
1256 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1257 InstrItinClass itin,
1258 string asm, string cstr, list<dag> pattern>
1259 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1260 let OutOperandList = oops;
1261 let InOperandList = iops;
1262 let AsmString = asm;
1263 let Pattern = pattern;
1264 list<Predicate> Predicates = [IsThumb2];
1265 let DecoderNamespace = "Thumb2";
1266 }
1267
1268 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1269 InstrItinClass itin,
1270 string asm, string cstr, list<dag> pattern>
1271 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1272 let OutOperandList = oops;
1273 let InOperandList = iops;
1274 let AsmString = asm;
1275 let Pattern = pattern;
1276 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1277 let DecoderNamespace = "Thumb";
1278 }
1279
1280 class T2I<dag oops, dag iops, InstrItinClass itin,
1281 string opc, string asm, list<dag> pattern>
1282 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1283 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1284 string opc, string asm, list<dag> pattern>
1285 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1286 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1287 string opc, string asm, list<dag> pattern>
1288 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1289 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1290 string opc, string asm, list<dag> pattern>
1291 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1292 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1293 string opc, string asm, list<dag> pattern>
1294 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1295 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1296 string opc, string asm, string cstr, list<dag> pattern>
1297 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1298 pattern> {
1299 bits<4> Rt;
1300 bits<4> Rt2;
1301 bits<13> addr;
1302 let Inst{31-25} = 0b1110100;
1303 let Inst{24} = P;
1304 let Inst{23} = addr{8};
1305 let Inst{22} = 1;
1306 let Inst{21} = W;
1307 let Inst{20} = isLoad;
1308 let Inst{19-16} = addr{12-9};
1309 let Inst{15-12} = Rt{3-0};
1310 let Inst{11-8} = Rt2{3-0};
1311 let Inst{7-0} = addr{7-0};
1312 }
1313 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1314 InstrItinClass itin, string opc, string asm, string cstr,
1315 list<dag> pattern>
1316 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1317 pattern> {
1318 bits<4> Rt;
1319 bits<4> Rt2;
1320 bits<4> addr;
1321 bits<9> imm;
1322 let Inst{31-25} = 0b1110100;
1323 let Inst{24} = P;
1324 let Inst{23} = imm{8};
1325 let Inst{22} = 1;
1326 let Inst{21} = W;
1327 let Inst{20} = isLoad;
1328 let Inst{19-16} = addr;
1329 let Inst{15-12} = Rt{3-0};
1330 let Inst{11-8} = Rt2{3-0};
1331 let Inst{7-0} = imm{7-0};
1332 }
1333
1334 class T2sI<dag oops, dag iops, InstrItinClass itin,
1335 string opc, string asm, list<dag> pattern>
1336 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1337
1338 class T2XI<dag oops, dag iops, InstrItinClass itin,
1339 string asm, list<dag> pattern>
1340 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1341 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1342 string asm, list<dag> pattern>
1343 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1344
1345 // Move to/from coprocessor instructions
1346 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1347 list<dag> pattern>
1348 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1349 let Inst{31-28} = opc;
1350 }
1351
1352 // Two-address instructions
1353 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1354 string asm, string cstr, list<dag> pattern>
1355 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1356
1357 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1358 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1359 dag oops, dag iops,
1360 AddrMode am, IndexMode im, InstrItinClass itin,
1361 string opc, string asm, string cstr, list<dag> pattern>
1362 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1363 let OutOperandList = oops;
1364 let InOperandList = !con(iops, (ins pred:$p));
1365 let AsmString = !strconcat(opc, "${p}", asm);
1366 let Pattern = pattern;
1367 list<Predicate> Predicates = [IsThumb2];
1368 let DecoderNamespace = "Thumb2";
1369
1370 bits<4> Rt;
1371 bits<13> addr;
1372 let Inst{31-27} = 0b11111;
1373 let Inst{26-25} = 0b00;
1374 let Inst{24} = signed;
1375 let Inst{23} = 0;
1376 let Inst{22-21} = opcod;
1377 let Inst{20} = load;
1378 let Inst{19-16} = addr{12-9};
1379 let Inst{15-12} = Rt{3-0};
1380 let Inst{11} = 1;
1381 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1382 let Inst{10} = pre; // The P bit.
1383 let Inst{9} = addr{8}; // Sign bit
1384 let Inst{8} = 1; // The W bit.
1385 let Inst{7-0} = addr{7-0};
1386
1387 let DecoderMethod = "DecodeT2LdStPre";
1388 }
1389
1390 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1391 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1392 dag oops, dag iops,
1393 AddrMode am, IndexMode im, InstrItinClass itin,
1394 string opc, string asm, string cstr, list<dag> pattern>
1395 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1396 let OutOperandList = oops;
1397 let InOperandList = !con(iops, (ins pred:$p));
1398 let AsmString = !strconcat(opc, "${p}", asm);
1399 let Pattern = pattern;
1400 list<Predicate> Predicates = [IsThumb2];
1401 let DecoderNamespace = "Thumb2";
1402
1403 bits<4> Rt;
1404 bits<4> Rn;
1405 bits<9> offset;
1406 let Inst{31-27} = 0b11111;
1407 let Inst{26-25} = 0b00;
1408 let Inst{24} = signed;
1409 let Inst{23} = 0;
1410 let Inst{22-21} = opcod;
1411 let Inst{20} = load;
1412 let Inst{19-16} = Rn;
1413 let Inst{15-12} = Rt{3-0};
1414 let Inst{11} = 1;
1415 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1416 let Inst{10} = pre; // The P bit.
1417 let Inst{9} = offset{8}; // Sign bit
1418 let Inst{8} = 1; // The W bit.
1419 let Inst{7-0} = offset{7-0};
1420
1421 let DecoderMethod = "DecodeT2LdStPre";
1422 }
1423
1424 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1425 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1426 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1427 }
1428
1429 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1430 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1431 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1432 }
1433
1434 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1435 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1436 list<Predicate> Predicates = [IsThumb2];
1437 }
1438
1439 //===----------------------------------------------------------------------===//
1440
1441 //===----------------------------------------------------------------------===//
1442 // ARM VFP Instruction templates.
1443 //
1444
1445 // Almost all VFP instructions are predicable.
1446 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1447 IndexMode im, Format f, InstrItinClass itin,
1448 string opc, string asm, string cstr, list<dag> pattern>
1449 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1450 bits<4> p;
1451 let Inst{31-28} = p;
1452 let OutOperandList = oops;
1453 let InOperandList = !con(iops, (ins pred:$p));
1454 let AsmString = !strconcat(opc, "${p}", asm);
1455 let Pattern = pattern;
1456 let PostEncoderMethod = "VFPThumb2PostEncoder";
1457 let DecoderNamespace = "VFP";
1458 list<Predicate> Predicates = [HasVFP2];
1459 }
1460
1461 // Special cases
1462 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1463 IndexMode im, Format f, InstrItinClass itin,
1464 string asm, string cstr, list<dag> pattern>
1465 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1466 bits<4> p;
1467 let Inst{31-28} = p;
1468 let OutOperandList = oops;
1469 let InOperandList = iops;
1470 let AsmString = asm;
1471 let Pattern = pattern;
1472 let PostEncoderMethod = "VFPThumb2PostEncoder";
1473 let DecoderNamespace = "VFP";
1474 list<Predicate> Predicates = [HasVFP2];
1475 }
1476
1477 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1478 string opc, string asm, list<dag> pattern>
1479 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1480 opc, asm, "", pattern> {
1481 let PostEncoderMethod = "VFPThumb2PostEncoder";
1482 }
1483
1484 // ARM VFP addrmode5 loads and stores
1485 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1486 InstrItinClass itin,
1487 string opc, string asm, list<dag> pattern>
1488 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1489 VFPLdStFrm, itin, opc, asm, "", pattern> {
1490 // Instruction operands.
1491 bits<5> Dd;
1492 bits<13> addr;
1493
1494 // Encode instruction operands.
1495 let Inst{23} = addr{8}; // U (add = (U == '1'))
1496 let Inst{22} = Dd{4};
1497 let Inst{19-16} = addr{12-9}; // Rn
1498 let Inst{15-12} = Dd{3-0};
1499 let Inst{7-0} = addr{7-0}; // imm8
1500
1501 let Inst{27-24} = opcod1;
1502 let Inst{21-20} = opcod2;
1503 let Inst{11-9} = 0b101;
1504 let Inst{8} = 1; // Double precision
1505
1506 // Loads & stores operate on both NEON and VFP pipelines.
1507 let D = VFPNeonDomain;
1508 }
1509
1510 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1511 InstrItinClass itin,
1512 string opc, string asm, list<dag> pattern>
1513 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1514 VFPLdStFrm, itin, opc, asm, "", pattern> {
1515 // Instruction operands.
1516 bits<5> Sd;
1517 bits<13> addr;
1518
1519 // Encode instruction operands.
1520 let Inst{23} = addr{8}; // U (add = (U == '1'))
1521 let Inst{22} = Sd{0};
1522 let Inst{19-16} = addr{12-9}; // Rn
1523 let Inst{15-12} = Sd{4-1};
1524 let Inst{7-0} = addr{7-0}; // imm8
1525
1526 let Inst{27-24} = opcod1;
1527 let Inst{21-20} = opcod2;
1528 let Inst{11-9} = 0b101;
1529 let Inst{8} = 0; // Single precision
1530
1531 // Loads & stores operate on both NEON and VFP pipelines.
1532 let D = VFPNeonDomain;
1533 }
1534
1535 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1536 InstrItinClass itin,
1537 string opc, string asm, list<dag> pattern>
1538 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1539 VFPLdStFrm, itin, opc, asm, "", pattern> {
1540 list<Predicate> Predicates = [HasFullFP16];
1541
1542 // Instruction operands.
1543 bits<5> Sd;
1544 bits<13> addr;
1545
1546 // Encode instruction operands.
1547 let Inst{23} = addr{8}; // U (add = (U == '1'))
1548 let Inst{22} = Sd{0};
1549 let Inst{19-16} = addr{12-9}; // Rn
1550 let Inst{15-12} = Sd{4-1};
1551 let Inst{7-0} = addr{7-0}; // imm8
1552
1553 let Inst{27-24} = opcod1;
1554 let Inst{21-20} = opcod2;
1555 let Inst{11-8} = 0b1001; // Half precision
1556
1557 // Loads & stores operate on both NEON and VFP pipelines.
1558 let D = VFPNeonDomain;
1559 }
1560
1561 // VFP Load / store multiple pseudo instructions.
1562 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1563 list<dag> pattern>
1564 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1565 cstr, itin> {
1566 let OutOperandList = oops;
1567 let InOperandList = !con(iops, (ins pred:$p));
1568 let Pattern = pattern;
1569 list<Predicate> Predicates = [HasVFP2];
1570 }
1571
1572 // Load / store multiple
1573
1574 // Unknown precision
1575 class AXXI4<dag oops, dag iops, IndexMode im,
1576 string asm, string cstr, list<dag> pattern>
1577 : VFPXI<oops, iops, AddrMode4, 4, im,
1578 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1579 // Instruction operands.
1580 bits<4> Rn;
1581 bits<13> regs;
1582
1583 // Encode instruction operands.
1584 let Inst{19-16} = Rn;
1585 let Inst{22} = 0;
1586 let Inst{15-12} = regs{11-8};
1587 let Inst{7-1} = regs{7-1};
1588
1589 let Inst{27-25} = 0b110;
1590 let Inst{11-8} = 0b1011;
1591 let Inst{0} = 1;
1592 }
1593
1594 // Double precision
1595 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1596 string asm, string cstr, list<dag> pattern>
1597 : VFPXI<oops, iops, AddrMode4, 4, im,
1598 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1599 // Instruction operands.
1600 bits<4> Rn;
1601 bits<13> regs;
1602
1603 // Encode instruction operands.
1604 let Inst{19-16} = Rn;
1605 let Inst{22} = regs{12};
1606 let Inst{15-12} = regs{11-8};
1607 let Inst{7-1} = regs{7-1};
1608
1609 let Inst{27-25} = 0b110;
1610 let Inst{11-9} = 0b101;
1611 let Inst{8} = 1; // Double precision
1612 let Inst{0} = 0;
1613 }
1614
1615 // Single Precision
1616 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1617 string asm, string cstr, list<dag> pattern>
1618 : VFPXI<oops, iops, AddrMode4, 4, im,
1619 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1620 // Instruction operands.
1621 bits<4> Rn;
1622 bits<13> regs;
1623
1624 // Encode instruction operands.
1625 let Inst{19-16} = Rn;
1626 let Inst{22} = regs{8};
1627 let Inst{15-12} = regs{12-9};
1628 let Inst{7-0} = regs{7-0};
1629
1630 let Inst{27-25} = 0b110;
1631 let Inst{11-9} = 0b101;
1632 let Inst{8} = 0; // Single precision
1633 }
1634
1635 // Double precision, unary
1636 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1637 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1638 string asm, list<dag> pattern>
1639 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1640 // Instruction operands.
1641 bits<5> Dd;
1642 bits<5> Dm;
1643
1644 // Encode instruction operands.
1645 let Inst{3-0} = Dm{3-0};
1646 let Inst{5} = Dm{4};
1647 let Inst{15-12} = Dd{3-0};
1648 let Inst{22} = Dd{4};
1649
1650 let Inst{27-23} = opcod1;
1651 let Inst{21-20} = opcod2;
1652 let Inst{19-16} = opcod3;
1653 let Inst{11-9} = 0b101;
1654 let Inst{8} = 1; // Double precision
1655 let Inst{7-6} = opcod4;
1656 let Inst{4} = opcod5;
1657
1658 let Predicates = [HasVFP2, HasDPVFP];
1659 }
1660
1661 // Double precision, unary, not-predicated
1662 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1663 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1664 string asm, list<dag> pattern>
1665 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1666 // Instruction operands.
1667 bits<5> Dd;
1668 bits<5> Dm;
1669
1670 let Inst{31-28} = 0b1111;
1671
1672 // Encode instruction operands.
1673 let Inst{3-0} = Dm{3-0};
1674 let Inst{5} = Dm{4};
1675 let Inst{15-12} = Dd{3-0};
1676 let Inst{22} = Dd{4};
1677
1678 let Inst{27-23} = opcod1;
1679 let Inst{21-20} = opcod2;
1680 let Inst{19-16} = opcod3;
1681 let Inst{11-9} = 0b101;
1682 let Inst{8} = 1; // Double precision
1683 let Inst{7-6} = opcod4;
1684 let Inst{4} = opcod5;
1685 }
1686
1687 // Double precision, binary
1688 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1689 dag iops, InstrItinClass itin, string opc, string asm,
1690 list<dag> pattern>
1691 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1692 // Instruction operands.
1693 bits<5> Dd;
1694 bits<5> Dn;
1695 bits<5> Dm;
1696
1697 // Encode instruction operands.
1698 let Inst{3-0} = Dm{3-0};
1699 let Inst{5} = Dm{4};
1700 let Inst{19-16} = Dn{3-0};
1701 let Inst{7} = Dn{4};
1702 let Inst{15-12} = Dd{3-0};
1703 let Inst{22} = Dd{4};
1704
1705 let Inst{27-23} = opcod1;
1706 let Inst{21-20} = opcod2;
1707 let Inst{11-9} = 0b101;
1708 let Inst{8} = 1; // Double precision
1709 let Inst{6} = op6;
1710 let Inst{4} = op4;
1711
1712 let Predicates = [HasVFP2, HasDPVFP];
1713 }
1714
1715 // FP, binary, not predicated
1716 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1717 InstrItinClass itin, string asm, list<dag> pattern>
1718 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1719 asm, "", pattern>
1720 {
1721 // Instruction operands.
1722 bits<5> Dd;
1723 bits<5> Dn;
1724 bits<5> Dm;
1725
1726 let Inst{31-28} = 0b1111;
1727
1728 // Encode instruction operands.
1729 let Inst{3-0} = Dm{3-0};
1730 let Inst{5} = Dm{4};
1731 let Inst{19-16} = Dn{3-0};
1732 let Inst{7} = Dn{4};
1733 let Inst{15-12} = Dd{3-0};
1734 let Inst{22} = Dd{4};
1735
1736 let Inst{27-23} = opcod1;
1737 let Inst{21-20} = opcod2;
1738 let Inst{11-9} = 0b101;
1739 let Inst{8} = 1; // double precision
1740 let Inst{6} = opcod3;
1741 let Inst{4} = 0;
1742
1743 let Predicates = [HasVFP2, HasDPVFP];
1744 }
1745
1746 // Single precision, unary, predicated
1747 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1748 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1749 string asm, list<dag> pattern>
1750 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1751 // Instruction operands.
1752 bits<5> Sd;
1753 bits<5> Sm;
1754
1755 // Encode instruction operands.
1756 let Inst{3-0} = Sm{4-1};
1757 let Inst{5} = Sm{0};
1758 let Inst{15-12} = Sd{4-1};
1759 let Inst{22} = Sd{0};
1760
1761 let Inst{27-23} = opcod1;
1762 let Inst{21-20} = opcod2;
1763 let Inst{19-16} = opcod3;
1764 let Inst{11-9} = 0b101;
1765 let Inst{8} = 0; // Single precision
1766 let Inst{7-6} = opcod4;
1767 let Inst{4} = opcod5;
1768 }
1769
1770 // Single precision, unary, non-predicated
1771 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1772 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1773 string asm, list<dag> pattern>
1774 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1775 VFPUnaryFrm, itin, asm, "", pattern> {
1776 // Instruction operands.
1777 bits<5> Sd;
1778 bits<5> Sm;
1779
1780 let Inst{31-28} = 0b1111;
1781
1782 // Encode instruction operands.
1783 let Inst{3-0} = Sm{4-1};
1784 let Inst{5} = Sm{0};
1785 let Inst{15-12} = Sd{4-1};
1786 let Inst{22} = Sd{0};
1787
1788 let Inst{27-23} = opcod1;
1789 let Inst{21-20} = opcod2;
1790 let Inst{19-16} = opcod3;
1791 let Inst{11-9} = 0b101;
1792 let Inst{8} = 0; // Single precision
1793 let Inst{7-6} = opcod4;
1794 let Inst{4} = opcod5;
1795 }
1796
1797 // Single precision unary, if no NEON. Same as ASuI except not available if
1798 // NEON is enabled.
1799 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1800 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1801 string asm, list<dag> pattern>
1802 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1803 pattern> {
1804 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1805 }
1806
1807 // Single precision, binary
1808 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1809 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1810 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1811 // Instruction operands.
1812 bits<5> Sd;
1813 bits<5> Sn;
1814 bits<5> Sm;
1815
1816 // Encode instruction operands.
1817 let Inst{3-0} = Sm{4-1};
1818 let Inst{5} = Sm{0};
1819 let Inst{19-16} = Sn{4-1};
1820 let Inst{7} = Sn{0};
1821 let Inst{15-12} = Sd{4-1};
1822 let Inst{22} = Sd{0};
1823
1824 let Inst{27-23} = opcod1;
1825 let Inst{21-20} = opcod2;
1826 let Inst{11-9} = 0b101;
1827 let Inst{8} = 0; // Single precision
1828 let Inst{6} = op6;
1829 let Inst{4} = op4;
1830 }
1831
1832 // Single precision, binary, not predicated
1833 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1834 InstrItinClass itin, string asm, list<dag> pattern>
1835 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1836 VFPBinaryFrm, itin, asm, "", pattern>
1837 {
1838 // Instruction operands.
1839 bits<5> Sd;
1840 bits<5> Sn;
1841 bits<5> Sm;
1842
1843 let Inst{31-28} = 0b1111;
1844
1845 // Encode instruction operands.
1846 let Inst{3-0} = Sm{4-1};
1847 let Inst{5} = Sm{0};
1848 let Inst{19-16} = Sn{4-1};
1849 let Inst{7} = Sn{0};
1850 let Inst{15-12} = Sd{4-1};
1851 let Inst{22} = Sd{0};
1852
1853 let Inst{27-23} = opcod1;
1854 let Inst{21-20} = opcod2;
1855 let Inst{11-9} = 0b101;
1856 let Inst{8} = 0; // Single precision
1857 let Inst{6} = opcod3;
1858 let Inst{4} = 0;
1859 }
1860
1861 // Single precision binary, if no NEON. Same as ASbI except not available if
1862 // NEON is enabled.
1863 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1864 dag iops, InstrItinClass itin, string opc, string asm,
1865 list<dag> pattern>
1866 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1867 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1868
1869 // Instruction operands.
1870 bits<5> Sd;
1871 bits<5> Sn;
1872 bits<5> Sm;
1873
1874 // Encode instruction operands.
1875 let Inst{3-0} = Sm{4-1};
1876 let Inst{5} = Sm{0};
1877 let Inst{19-16} = Sn{4-1};
1878 let Inst{7} = Sn{0};
1879 let Inst{15-12} = Sd{4-1};
1880 let Inst{22} = Sd{0};
1881 }
1882
1883 // Half precision, unary, predicated
1884 class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1885 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1886 string asm, list<dag> pattern>
1887 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1888 list<Predicate> Predicates = [HasFullFP16];
1889
1890 // Instruction operands.
1891 bits<5> Sd;
1892 bits<5> Sm;
1893
1894 // Encode instruction operands.
1895 let Inst{3-0} = Sm{4-1};
1896 let Inst{5} = Sm{0};
1897 let Inst{15-12} = Sd{4-1};
1898 let Inst{22} = Sd{0};
1899
1900 let Inst{27-23} = opcod1;
1901 let Inst{21-20} = opcod2;
1902 let Inst{19-16} = opcod3;
1903 let Inst{11-8} = 0b1001; // Half precision
1904 let Inst{7-6} = opcod4;
1905 let Inst{4} = opcod5;
1906 }
1907
1908 // Half precision, unary, non-predicated
1909 class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1910 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1911 string asm, list<dag> pattern>
1912 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1913 VFPUnaryFrm, itin, asm, "", pattern> {
1914 list<Predicate> Predicates = [HasFullFP16];
1915
1916 // Instruction operands.
1917 bits<5> Sd;
1918 bits<5> Sm;
1919
1920 let Inst{31-28} = 0b1111;
1921
1922 // Encode instruction operands.
1923 let Inst{3-0} = Sm{4-1};
1924 let Inst{5} = Sm{0};
1925 let Inst{15-12} = Sd{4-1};
1926 let Inst{22} = Sd{0};
1927
1928 let Inst{27-23} = opcod1;
1929 let Inst{21-20} = opcod2;
1930 let Inst{19-16} = opcod3;
1931 let Inst{11-8} = 0b1001; // Half precision
1932 let Inst{7-6} = opcod4;
1933 let Inst{4} = opcod5;
1934 }
1935
1936 // Half precision, binary
1937 class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1938 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1939 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1940 list<Predicate> Predicates = [HasFullFP16];
1941
1942 // Instruction operands.
1943 bits<5> Sd;
1944 bits<5> Sn;
1945 bits<5> Sm;
1946
1947 // Encode instruction operands.
1948 let Inst{3-0} = Sm{4-1};
1949 let Inst{5} = Sm{0};
1950 let Inst{19-16} = Sn{4-1};
1951 let Inst{7} = Sn{0};
1952 let Inst{15-12} = Sd{4-1};
1953 let Inst{22} = Sd{0};
1954
1955 let Inst{27-23} = opcod1;
1956 let Inst{21-20} = opcod2;
1957 let Inst{11-8} = 0b1001; // Half precision
1958 let Inst{6} = op6;
1959 let Inst{4} = op4;
1960 }
1961
1962 // Half precision, binary, not predicated
1963 class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1964 InstrItinClass itin, string asm, list<dag> pattern>
1965 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1966 VFPBinaryFrm, itin, asm, "", pattern> {
1967 list<Predicate> Predicates = [HasFullFP16];
1968
1969 // Instruction operands.
1970 bits<5> Sd;
1971 bits<5> Sn;
1972 bits<5> Sm;
1973
1974 let Inst{31-28} = 0b1111;
1975
1976 // Encode instruction operands.
1977 let Inst{3-0} = Sm{4-1};
1978 let Inst{5} = Sm{0};
1979 let Inst{19-16} = Sn{4-1};
1980 let Inst{7} = Sn{0};
1981 let Inst{15-12} = Sd{4-1};
1982 let Inst{22} = Sd{0};
1983
1984 let Inst{27-23} = opcod1;
1985 let Inst{21-20} = opcod2;
1986 let Inst{11-8} = 0b1001; // Half precision
1987 let Inst{6} = opcod3;
1988 let Inst{4} = 0;
1989 }
1990
1991 // VFP conversion instructions
1992 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1993 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1994 list<dag> pattern>
1995 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1996 let Inst{27-23} = opcod1;
1997 let Inst{21-20} = opcod2;
1998 let Inst{19-16} = opcod3;
1999 let Inst{11-8} = opcod4;
2000 let Inst{6} = 1;
2001 let Inst{4} = 0;
2002 }
2003
2004 // VFP conversion between floating-point and fixed-point
2005 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2006 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2007 list<dag> pattern>
2008 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2009 bits<5> fbits;
2010 // size (fixed-point number): sx == 0 ? 16 : 32
2011 let Inst{7} = op5; // sx
2012 let Inst{5} = fbits{0};
2013 let Inst{3-0} = fbits{4-1};
2014 }
2015
2016 // VFP conversion instructions, if no NEON
2017 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2018 dag oops, dag iops, InstrItinClass itin,
2019 string opc, string asm, list<dag> pattern>
2020 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2021 pattern> {
2022 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2023 }
2024
2025 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2026 InstrItinClass itin,
2027 string opc, string asm, list<dag> pattern>
2028 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
2029 let Inst{27-20} = opcod1;
2030 let Inst{11-8} = opcod2;
2031 let Inst{4} = 1;
2032 }
2033
2034 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2035 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2036 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
2037
2038 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2039 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2040 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2041
2042 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2043 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2044 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
2045
2046 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2047 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2048 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
2049
2050 //===----------------------------------------------------------------------===//
2051
2052 //===----------------------------------------------------------------------===//
2053 // ARM NEON Instruction templates.
2054 //
2055
2056 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2057 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2058 list<dag> pattern>
2059 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2060 let OutOperandList = oops;
2061 let InOperandList = !con(iops, (ins pred:$p));
2062 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2063 let Pattern = pattern;
2064 list<Predicate> Predicates = [HasNEON];
2065 let DecoderNamespace = "NEON";
2066 }
2067
2068 // Same as NeonI except it does not have a "data type" specifier.
2069 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2070 InstrItinClass itin, string opc, string asm, string cstr,
2071 list<dag> pattern>
2072 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2073 let OutOperandList = oops;
2074 let InOperandList = !con(iops, (ins pred:$p));
2075 let AsmString = !strconcat(opc, "${p}", "\t", asm);
2076 let Pattern = pattern;
2077 list<Predicate> Predicates = [HasNEON];
2078 let DecoderNamespace = "NEON";
2079 }
2080
2081 // Same as NeonI except it is not predicated
2082 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2083 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2084 list<dag> pattern>
2085 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2086 let OutOperandList = oops;
2087 let InOperandList = iops;
2088 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2089 let Pattern = pattern;
2090 list<Predicate> Predicates = [HasNEON];
2091 let DecoderNamespace = "NEON";
2092
2093 let Inst{31-28} = 0b1111;
2094 }
2095
2096 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2097 dag oops, dag iops, InstrItinClass itin,
2098 string opc, string dt, string asm, string cstr, list<dag> pattern>
2099 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2100 cstr, pattern> {
2101 let Inst{31-24} = 0b11110100;
2102 let Inst{23} = op23;
2103 let Inst{21-20} = op21_20;
2104 let Inst{11-8} = op11_8;
2105 let Inst{7-4} = op7_4;
2106
2107 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2108 let DecoderNamespace = "NEONLoadStore";
2109
2110 bits<5> Vd;
2111 bits<6> Rn;
2112 bits<4> Rm;
2113
2114 let Inst{22} = Vd{4};
2115 let Inst{15-12} = Vd{3-0};
2116 let Inst{19-16} = Rn{3-0};
2117 let Inst{3-0} = Rm{3-0};
2118 }
2119
2120 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2121 dag oops, dag iops, InstrItinClass itin,
2122 string opc, string dt, string asm, string cstr, list<dag> pattern>
2123 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2124 dt, asm, cstr, pattern> {
2125 bits<3> lane;
2126 }
2127
2128 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2129 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2130 itin> {
2131 let OutOperandList = oops;
2132 let InOperandList = !con(iops, (ins pred:$p));
2133 list<Predicate> Predicates = [HasNEON];
2134 }
2135
2136 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2137 list<dag> pattern>
2138 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2139 itin> {
2140 let OutOperandList = oops;
2141 let InOperandList = !con(iops, (ins pred:$p));
2142 let Pattern = pattern;
2143 list<Predicate> Predicates = [HasNEON];
2144 }
2145
2146 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2147 string opc, string dt, string asm, string cstr, list<dag> pattern>
2148 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2149 pattern> {
2150 let Inst{31-25} = 0b1111001;
2151 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2152 let DecoderNamespace = "NEONData";
2153 }
2154
2155 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2156 string opc, string asm, string cstr, list<dag> pattern>
2157 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2158 cstr, pattern> {
2159 let Inst{31-25} = 0b1111001;
2160 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2161 let DecoderNamespace = "NEONData";
2162 }
2163
2164 // NEON "one register and a modified immediate" format.
2165 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2166 bit op5, bit op4,
2167 dag oops, dag iops, InstrItinClass itin,
2168 string opc, string dt, string asm, string cstr,
2169 list<dag> pattern>
2170 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2171 let Inst{23} = op23;
2172 let Inst{21-19} = op21_19;
2173 let Inst{11-8} = op11_8;
2174 let Inst{7} = op7;
2175 let Inst{6} = op6;
2176 let Inst{5} = op5;
2177 let Inst{4} = op4;
2178
2179 // Instruction operands.
2180 bits<5> Vd;
2181 bits<13> SIMM;
2182
2183 let Inst{15-12} = Vd{3-0};
2184 let Inst{22} = Vd{4};
2185 let Inst{24} = SIMM{7};
2186 let Inst{18-16} = SIMM{6-4};
2187 let Inst{3-0} = SIMM{3-0};
2188 let DecoderMethod = "DecodeNEONModImmInstruction";
2189 }
2190
2191 // NEON 2 vector register format.
2192 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2193 bits<5> op11_7, bit op6, bit op4,
2194 dag oops, dag iops, InstrItinClass itin,
2195 string opc, string dt, string asm, string cstr, list<dag> pattern>
2196 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2197 let Inst{24-23} = op24_23;
2198 let Inst{21-20} = op21_20;
2199 let Inst{19-18} = op19_18;
2200 let Inst{17-16} = op17_16;
2201 let Inst{11-7} = op11_7;
2202 let Inst{6} = op6;
2203 let Inst{4} = op4;
2204
2205 // Instruction operands.
2206 bits<5> Vd;
2207 bits<5> Vm;
2208
2209 let Inst{15-12} = Vd{3-0};
2210 let Inst{22} = Vd{4};
2211 let Inst{3-0} = Vm{3-0};
2212 let Inst{5} = Vm{4};
2213 }
2214
2215 // Same as N2V but not predicated.
2216 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2217 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2218 string Dt, list<dag> pattern>
2219 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2220 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2221 bits<5> Vd;
2222 bits<5> Vm;
2223
2224 // Encode instruction operands
2225 let Inst{22} = Vd{4};
2226 let Inst{15-12} = Vd{3-0};
2227 let Inst{5} = Vm{4};
2228 let Inst{3-0} = Vm{3-0};
2229
2230 // Encode constant bits
2231 let Inst{27-23} = 0b00111;
2232 let Inst{21-20} = 0b11;
2233 let Inst{19-18} = op19_18;
2234 let Inst{17-16} = op17_16;
2235 let Inst{11} = 0;
2236 let Inst{10-8} = op10_8;
2237 let Inst{7} = op7;
2238 let Inst{6} = op6;
2239 let Inst{4} = 0;
2240
2241 let DecoderNamespace = "NEON";
2242 }
2243
2244 // Same as N2V except it doesn't have a datatype suffix.
2245 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2246 bits<5> op11_7, bit op6, bit op4,
2247 dag oops, dag iops, InstrItinClass itin,
2248 string opc, string asm, string cstr, list<dag> pattern>
2249 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2250 let Inst{24-23} = op24_23;
2251 let Inst{21-20} = op21_20;
2252 let Inst{19-18} = op19_18;
2253 let Inst{17-16} = op17_16;
2254 let Inst{11-7} = op11_7;
2255 let Inst{6} = op6;
2256 let Inst{4} = op4;
2257
2258 // Instruction operands.
2259 bits<5> Vd;
2260 bits<5> Vm;
2261
2262 let Inst{15-12} = Vd{3-0};
2263 let Inst{22} = Vd{4};
2264 let Inst{3-0} = Vm{3-0};
2265 let Inst{5} = Vm{4};
2266 }
2267
2268 // NEON 2 vector register with immediate.
2269 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2270 dag oops, dag iops, Format f, InstrItinClass itin,
2271 string opc, string dt, string asm, string cstr, list<dag> pattern>
2272 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2273 let Inst{24} = op24;
2274 let Inst{23} = op23;
2275 let Inst{11-8} = op11_8;
2276 let Inst{7} = op7;
2277 let Inst{6} = op6;
2278 let Inst{4} = op4;
2279
2280 // Instruction operands.
2281 bits<5> Vd;
2282 bits<5> Vm;
2283 bits<6> SIMM;
2284
2285 let Inst{15-12} = Vd{3-0};
2286 let Inst{22} = Vd{4};
2287 let Inst{3-0} = Vm{3-0};
2288 let Inst{5} = Vm{4};
2289 let Inst{21-16} = SIMM{5-0};
2290 }
2291
2292 // NEON 3 vector register format.
2293
2294 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2295 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2296 string opc, string dt, string asm, string cstr,
2297 list<dag> pattern>
2298 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2299 let Inst{24} = op24;
2300 let Inst{23} = op23;
2301 let Inst{21-20} = op21_20;
2302 let Inst{11-8} = op11_8;
2303 let Inst{6} = op6;
2304 let Inst{4} = op4;
2305 }
2306
2307 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2308 dag oops, dag iops, Format f, InstrItinClass itin,
2309 string opc, string dt, string asm, string cstr, list<dag> pattern>
2310 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2311 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2312 // Instruction operands.
2313 bits<5> Vd;
2314 bits<5> Vn;
2315 bits<5> Vm;
2316
2317 let Inst{15-12} = Vd{3-0};
2318 let Inst{22} = Vd{4};
2319 let Inst{19-16} = Vn{3-0};
2320 let Inst{7} = Vn{4};
2321 let Inst{3-0} = Vm{3-0};
2322 let Inst{5} = Vm{4};
2323 }
2324
2325 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2326 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2327 string OpcodeStr, string Dt, list<dag> pattern>
2328 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2329 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2330 bits<5> Vd;
2331 bits<5> Vn;
2332 bits<5> Vm;
2333
2334 // Encode instruction operands
2335 let Inst{22} = Vd{4};
2336 let Inst{15-12} = Vd{3-0};
2337 let Inst{19-16} = Vn{3-0};
2338 let Inst{7} = Vn{4};
2339 let Inst{5} = Vm{4};
2340 let Inst{3-0} = Vm{3-0};
2341
2342 // Encode constant bits
2343 let Inst{27-23} = op27_23;
2344 let Inst{21-20} = op21_20;
2345 let Inst{11-8} = op11_8;
2346 let Inst{6} = op6;
2347 let Inst{4} = op4;
2348 }
2349
2350 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2351 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2352 string opc, string dt, string asm, string cstr,
2353 list<dag> pattern>
2354 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2355 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2356
2357 // Instruction operands.
2358 bits<5> Vd;
2359 bits<5> Vn;
2360 bits<5> Vm;
2361 bit lane;
2362
2363 let Inst{15-12} = Vd{3-0};
2364 let Inst{22} = Vd{4};
2365 let Inst{19-16} = Vn{3-0};
2366 let Inst{7} = Vn{4};
2367 let Inst{3-0} = Vm{3-0};
2368 let Inst{5} = lane;
2369 }
2370
2371 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2372 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2373 string opc, string dt, string asm, string cstr,
2374 list<dag> pattern>
2375 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2376 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2377
2378 // Instruction operands.
2379 bits<5> Vd;
2380 bits<5> Vn;
2381 bits<5> Vm;
2382 bits<2> lane;
2383
2384 let Inst{15-12} = Vd{3-0};
2385 let Inst{22} = Vd{4};
2386 let Inst{19-16} = Vn{3-0};
2387 let Inst{7} = Vn{4};
2388 let Inst{2-0} = Vm{2-0};
2389 let Inst{5} = lane{1};
2390 let Inst{3} = lane{0};
2391 }
2392
2393 // Same as N3V except it doesn't have a data type suffix.
2394 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2395 bit op4,
2396 dag oops, dag iops, Format f, InstrItinClass itin,
2397 string opc, string asm, string cstr, list<dag> pattern>
2398 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2399 let Inst{24} = op24;
2400 let Inst{23} = op23;
2401 let Inst{21-20} = op21_20;
2402 let Inst{11-8} = op11_8;
2403 let Inst{6} = op6;
2404 let Inst{4} = op4;
2405
2406 // Instruction operands.
2407 bits<5> Vd;
2408 bits<5> Vn;
2409 bits<5> Vm;
2410
2411 let Inst{15-12} = Vd{3-0};
2412 let Inst{22} = Vd{4};
2413 let Inst{19-16} = Vn{3-0};
2414 let Inst{7} = Vn{4};
2415 let Inst{3-0} = Vm{3-0};
2416 let Inst{5} = Vm{4};
2417 }
2418
2419 // NEON VMOVs between scalar and core registers.
2420 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2421 dag oops, dag iops, Format f, InstrItinClass itin,
2422 string opc, string dt, string asm, list<dag> pattern>
2423 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2424 "", itin> {
2425 let Inst{27-20} = opcod1;
2426 let Inst{11-8} = opcod2;
2427 let Inst{6-5} = opcod3;
2428 let Inst{4} = 1;
2429 // A8.6.303, A8.6.328, A8.6.329
2430 let Inst{3-0} = 0b0000;
2431
2432 let OutOperandList = oops;
2433 let InOperandList = !con(iops, (ins pred:$p));
2434 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2435 let Pattern = pattern;
2436 list<Predicate> Predicates = [HasNEON];
2437
2438 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2439 let DecoderNamespace = "NEONDup";
2440
2441 bits<5> V;
2442 bits<4> R;
2443 bits<4> p;
2444 bits<4> lane;
2445
2446 let Inst{31-28} = p{3-0};
2447 let Inst{7} = V{4};
2448 let Inst{19-16} = V{3-0};
2449 let Inst{15-12} = R{3-0};
2450 }
2451 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2452 dag oops, dag iops, InstrItinClass itin,
2453 string opc, string dt, string asm, list<dag> pattern>
2454 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2455 opc, dt, asm, pattern>;
2456 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2457 dag oops, dag iops, InstrItinClass itin,
2458 string opc, string dt, string asm, list<dag> pattern>
2459 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2460 opc, dt, asm, pattern>;
2461 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2462 dag oops, dag iops, InstrItinClass itin,
2463 string opc, string dt, string asm, list<dag> pattern>
2464 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2465 opc, dt, asm, pattern>;
2466
2467 // Vector Duplicate Lane (from scalar to all elements)
2468 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2469 InstrItinClass itin, string opc, string dt, string asm,
2470 list<dag> pattern>
2471 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2472 let Inst{24-23} = 0b11;
2473 let Inst{21-20} = 0b11;
2474 let Inst{19-16} = op19_16;
2475 let Inst{11-7} = 0b11000;
2476 let Inst{6} = op6;
2477 let Inst{4} = 0;
2478
2479 bits<5> Vd;
2480 bits<5> Vm;
2481
2482 let Inst{22} = Vd{4};
2483 let Inst{15-12} = Vd{3-0};
2484 let Inst{5} = Vm{4};
2485 let Inst{3-0} = Vm{3-0};
2486 }
2487
2488 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2489 // for single-precision FP.
2490 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2491 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2492 }
2493
2494 // VFP/NEON Instruction aliases for type suffices.
2495 // Note: When EmitPriority == 1, the alias will be used for printing
2496 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2497 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasVFP2]>;
2498
2499 // Note: When EmitPriority == 1, the alias will be used for printing
2500 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2501 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2502 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2503 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2504 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2505 }
2506
2507 // Note: When EmitPriority == 1, the alias will be used for printing
2508 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2509 let Predicates = [HasNEON] in {
2510 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2511 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2512 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2513 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2514 }
2515 }
2516
2517 // The same alias classes using AsmPseudo instead, for the more complex
2518 // stuff in NEON that InstAlias can't quite handle.
2519 // Note that we can't use anonymous defm references here like we can
2520 // above, as we care about the ultimate instruction enum names generated, unlike
2521 // for instalias defs.
2522 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2523 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2524
2525 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2526 // encoding space, introduced in ARMv8.3-A.
2527 class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2528 dag oops, dag iops, InstrItinClass itin,
2529 string opc, string dt, string asm, string cstr, list<dag> pattern>
2530 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2531 dt, asm, cstr, pattern> {
2532 bits<5> Vd;
2533 bits<5> Vn;
2534 bits<5> Vm;
2535
2536 let DecoderNamespace = "VFPV8";
2537 // These have the same encodings in ARM and Thumb2
2538 let PostEncoderMethod = "";
2539
2540 let Inst{31-25} = 0b1111110;
2541 let Inst{24-23} = op24_23;
2542 let Inst{22} = Vd{4};
2543 let Inst{21-20} = op21_20;
2544 let Inst{19-16} = Vn{3-0};
2545 let Inst{15-12} = Vd{3-0};
2546 let Inst{11-8} = 0b1000;
2547 let Inst{7} = Vn{4};
2548 let Inst{6} = op6;
2549 let Inst{5} = Vm{4};
2550 let Inst{4} = op4;
2551 let Inst{3-0} = Vm{3-0};
2552 }
2553
2554 // Extension of NEON 2-vector-and-scalar data processing instructions in
2555 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2556 class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2557 dag oops, dag iops, InstrItinClass itin,
2558 string opc, string dt, string asm, string cstr, list<dag> pattern>
2559 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2560 dt, asm, cstr, pattern> {
2561 bits<5> Vd;
2562 bits<5> Vn;
2563 bits<5> Vm;
2564
2565 let DecoderNamespace = "VFPV8";
2566 // These have the same encodings in ARM and Thumb2
2567 let PostEncoderMethod = "";
2568
2569 let Inst{31-24} = 0b11111110;
2570 let Inst{23} = op23;
2571 let Inst{22} = Vd{4};
2572 let Inst{21-20} = op21_20;
2573 let Inst{19-16} = Vn{3-0};
2574 let Inst{15-12} = Vd{3-0};
2575 let Inst{11-8} = 0b1000;
2576 let Inst{7} = Vn{4};
2577 let Inst{6} = op6;
2578 // Bit 5 set by sub-classes
2579 let Inst{4} = op4;
2580 let Inst{3-0} = Vm{3-0};
2581 }
2582
2583 // Operand types for complex instructions
2584 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2585 : AsmOperandClass {
2586 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2587 let DiagnosticString = "complex rotation must be " # Diag;
2588 let Name = "ComplexRotation" # Type;
2589 }
2590 def complexrotateop : Operand<i32> {
2591 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2592 let PrintMethod = "printComplexRotationOp<90, 0>";
2593 }
2594 def complexrotateopodd : Operand<i32> {
2595 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2596 let PrintMethod = "printComplexRotationOp<180, 90>";
2597 }
2598
2599 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2600 def : TokenAlias<".s8", ".i8">;
2601 def : TokenAlias<".u8", ".i8">;
2602 def : TokenAlias<".s16", ".i16">;
2603 def : TokenAlias<".u16", ".i16">;
2604 def : TokenAlias<".s32", ".i32">;
2605 def : TokenAlias<".u32", ".i32">;
2606 def : TokenAlias<".s64", ".i64">;
2607 def : TokenAlias<".u64", ".i64">;
2608
2609 def : TokenAlias<".i8", ".8">;
2610 def : TokenAlias<".i16", ".16">;
2611 def : TokenAlias<".i32", ".32">;
2612 def : TokenAlias<".i64", ".64">;
2613
2614 def : TokenAlias<".p8", ".8">;
2615 def : TokenAlias<".p16", ".16">;
2616
2617 def : TokenAlias<".f32", ".32">;
2618 def : TokenAlias<".f64", ".64">;
2619 def : TokenAlias<".f", ".f32">;
2620 def : TokenAlias<".d", ".f64">;