1 //===- ARM64InstrFormats.td - ARM64 Instruction Formats ------*- tblgen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // Describe ARM64 instructions format here
14 // Format specifies the encoding used by the instruction. This is part of the
15 // ad-hoc solution used to emit machine instruction encodings by our machine
17 class Format<bits<2> val> {
21 def PseudoFrm : Format<0>;
22 def NormalFrm : Format<1>; // Do we need any others?
24 // ARM64 Instruction Format
25 class ARM64Inst<Format f, string cstr> : Instruction {
26 field bits<32> Inst; // Instruction encoding.
27 // Mask of bits that cause an encoding to be UNPREDICTABLE.
28 // If a bit is set, then if the corresponding bit in the
29 // target encoding differs from its value in the "Inst" field,
30 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
31 field bits<32> Unpredictable = 0;
32 // SoftFail is the generic name for this field, but we alias it so
33 // as to make it more obvious what it means in ARM-land.
34 field bits<32> SoftFail = Unpredictable;
35 let Namespace = "ARM64";
37 bits<2> Form = F.Value;
39 let Constraints = cstr;
42 // Pseudo instructions (don't have encoding information)
43 class Pseudo<dag oops, dag iops, list<dag> pattern, string cstr = "">
44 : ARM64Inst<PseudoFrm, cstr> {
45 dag OutOperandList = oops;
46 dag InOperandList = iops;
47 let Pattern = pattern;
48 let isCodeGenOnly = 1;
51 // Real instructions (have encoding information)
52 class EncodedI<string cstr, list<dag> pattern> : ARM64Inst<NormalFrm, cstr> {
53 let Pattern = pattern;
57 // Normal instructions
58 class I<dag oops, dag iops, string asm, string operands, string cstr,
60 : EncodedI<cstr, pattern> {
61 dag OutOperandList = oops;
62 dag InOperandList = iops;
63 let AsmString = !strconcat(asm, operands);
66 class TriOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$MHS, node:$RHS), res>;
67 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
68 class UnOpFrag<dag res> : PatFrag<(ops node:$LHS), res>;
70 // Helper fragment for an extract of the high portion of a 128-bit vector.
71 def extract_high_v16i8 :
72 UnOpFrag<(extract_subvector (v16i8 node:$LHS), (i64 8))>;
73 def extract_high_v8i16 :
74 UnOpFrag<(extract_subvector (v8i16 node:$LHS), (i64 4))>;
75 def extract_high_v4i32 :
76 UnOpFrag<(extract_subvector (v4i32 node:$LHS), (i64 2))>;
77 def extract_high_v2i64 :
78 UnOpFrag<(extract_subvector (v2i64 node:$LHS), (i64 1))>;
80 //===----------------------------------------------------------------------===//
81 // Asm Operand Classes.
84 // Shifter operand for arithmetic shifted encodings.
85 def ShifterOperand : AsmOperandClass {
89 // Shifter operand for mov immediate encodings.
90 def MovImm32ShifterOperand : AsmOperandClass {
91 let SuperClasses = [ShifterOperand];
92 let Name = "MovImm32Shifter";
93 let RenderMethod = "addShifterOperands";
95 def MovImm64ShifterOperand : AsmOperandClass {
96 let SuperClasses = [ShifterOperand];
97 let Name = "MovImm64Shifter";
98 let RenderMethod = "addShifterOperands";
101 // Shifter operand for arithmetic register shifted encodings.
102 class ArithmeticShifterOperand<int width> : AsmOperandClass {
103 let SuperClasses = [ShifterOperand];
104 let Name = "ArithmeticShifter" # width;
105 let PredicateMethod = "isArithmeticShifter<" # width # ">";
106 let RenderMethod = "addShifterOperands";
107 let DiagnosticType = "AddSubRegShift" # width;
110 def ArithmeticShifterOperand32 : ArithmeticShifterOperand<32>;
111 def ArithmeticShifterOperand64 : ArithmeticShifterOperand<64>;
113 // Shifter operand for logical register shifted encodings.
114 class LogicalShifterOperand<int width> : AsmOperandClass {
115 let SuperClasses = [ShifterOperand];
116 let Name = "LogicalShifter" # width;
117 let PredicateMethod = "isLogicalShifter<" # width # ">";
118 let RenderMethod = "addShifterOperands";
119 let DiagnosticType = "AddSubRegShift" # width;
122 def LogicalShifterOperand32 : LogicalShifterOperand<32>;
123 def LogicalShifterOperand64 : LogicalShifterOperand<64>;
125 // Shifter operand for logical vector 128/64-bit shifted encodings.
126 def LogicalVecShifterOperand : AsmOperandClass {
127 let SuperClasses = [ShifterOperand];
128 let Name = "LogicalVecShifter";
129 let RenderMethod = "addShifterOperands";
131 def LogicalVecHalfWordShifterOperand : AsmOperandClass {
132 let SuperClasses = [LogicalVecShifterOperand];
133 let Name = "LogicalVecHalfWordShifter";
134 let RenderMethod = "addShifterOperands";
137 // The "MSL" shifter on the vector MOVI instruction.
138 def MoveVecShifterOperand : AsmOperandClass {
139 let SuperClasses = [ShifterOperand];
140 let Name = "MoveVecShifter";
141 let RenderMethod = "addShifterOperands";
144 // Extend operand for arithmetic encodings.
145 def ExtendOperand : AsmOperandClass {
147 let DiagnosticType = "AddSubRegExtendLarge";
149 def ExtendOperand64 : AsmOperandClass {
150 let SuperClasses = [ExtendOperand];
151 let Name = "Extend64";
152 let DiagnosticType = "AddSubRegExtendSmall";
154 // 'extend' that's a lsl of a 64-bit register.
155 def ExtendOperandLSL64 : AsmOperandClass {
156 let SuperClasses = [ExtendOperand];
157 let Name = "ExtendLSL64";
158 let RenderMethod = "addExtend64Operands";
159 let DiagnosticType = "AddSubRegExtendLarge";
162 // 8-bit floating-point immediate encodings.
163 def FPImmOperand : AsmOperandClass {
165 let ParserMethod = "tryParseFPImm";
168 // 8-bit immediate for AdvSIMD where 64-bit values of the form:
169 // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
170 // are encoded as the eight bit value 'abcdefgh'.
171 def SIMDImmType10Operand : AsmOperandClass { let Name = "SIMDImmType10"; }
174 //===----------------------------------------------------------------------===//
175 // Operand Definitions.
178 // ADR[P] instruction labels.
179 def AdrpOperand : AsmOperandClass {
180 let Name = "AdrpLabel";
181 let ParserMethod = "tryParseAdrpLabel";
182 let DiagnosticType = "InvalidLabel";
184 def adrplabel : Operand<i64> {
185 let EncoderMethod = "getAdrLabelOpValue";
186 let PrintMethod = "printAdrpLabel";
187 let ParserMatchClass = AdrpOperand;
190 def AdrOperand : AsmOperandClass {
191 let Name = "AdrLabel";
192 let ParserMethod = "tryParseAdrLabel";
193 let DiagnosticType = "InvalidLabel";
195 def adrlabel : Operand<i64> {
196 let EncoderMethod = "getAdrLabelOpValue";
197 let ParserMatchClass = AdrOperand;
200 // simm9 predicate - True if the immediate is in the range [-256, 255].
201 def SImm9Operand : AsmOperandClass {
203 let DiagnosticType = "InvalidMemoryIndexedSImm9";
205 def simm9 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= -256 && Imm < 256; }]> {
206 let ParserMatchClass = SImm9Operand;
209 // simm7s4 predicate - True if the immediate is a multiple of 4 in the range
211 def SImm7s4Operand : AsmOperandClass {
212 let Name = "SImm7s4";
213 let DiagnosticType = "InvalidMemoryIndexed32SImm7";
215 def simm7s4 : Operand<i32> {
216 let ParserMatchClass = SImm7s4Operand;
217 let PrintMethod = "printImmScale<4>";
220 // simm7s8 predicate - True if the immediate is a multiple of 8 in the range
222 def SImm7s8Operand : AsmOperandClass {
223 let Name = "SImm7s8";
224 let DiagnosticType = "InvalidMemoryIndexed64SImm7";
226 def simm7s8 : Operand<i32> {
227 let ParserMatchClass = SImm7s8Operand;
228 let PrintMethod = "printImmScale<8>";
231 // simm7s16 predicate - True if the immediate is a multiple of 16 in the range
233 def SImm7s16Operand : AsmOperandClass {
234 let Name = "SImm7s16";
235 let DiagnosticType = "InvalidMemoryIndexed64SImm7";
237 def simm7s16 : Operand<i32> {
238 let ParserMatchClass = SImm7s16Operand;
239 let PrintMethod = "printImmScale<16>";
242 // imm0_65535 predicate - True if the immediate is in the range [0,65535].
243 def Imm0_65535Operand : AsmOperandClass { let Name = "Imm0_65535"; }
244 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
245 return ((uint32_t)Imm) < 65536;
247 let ParserMatchClass = Imm0_65535Operand;
248 let PrintMethod = "printHexImm";
251 class AsmImmRange<int Low, int High> : AsmOperandClass {
252 let Name = "Imm" # Low # "_" # High;
253 let DiagnosticType = "InvalidImm" # Low # "_" # High;
256 def Imm1_8Operand : AsmImmRange<1, 8>;
257 def Imm1_16Operand : AsmImmRange<1, 16>;
258 def Imm1_32Operand : AsmImmRange<1, 32>;
259 def Imm1_64Operand : AsmImmRange<1, 64>;
261 def MovZSymbolG3AsmOperand : AsmOperandClass {
262 let Name = "MovZSymbolG3";
263 let RenderMethod = "addImmOperands";
266 def movz_symbol_g3 : Operand<i32> {
267 let ParserMatchClass = MovZSymbolG3AsmOperand;
270 def MovZSymbolG2AsmOperand : AsmOperandClass {
271 let Name = "MovZSymbolG2";
272 let RenderMethod = "addImmOperands";
275 def movz_symbol_g2 : Operand<i32> {
276 let ParserMatchClass = MovZSymbolG2AsmOperand;
279 def MovZSymbolG1AsmOperand : AsmOperandClass {
280 let Name = "MovZSymbolG1";
281 let RenderMethod = "addImmOperands";
284 def movz_symbol_g1 : Operand<i32> {
285 let ParserMatchClass = MovZSymbolG1AsmOperand;
288 def MovZSymbolG0AsmOperand : AsmOperandClass {
289 let Name = "MovZSymbolG0";
290 let RenderMethod = "addImmOperands";
293 def movz_symbol_g0 : Operand<i32> {
294 let ParserMatchClass = MovZSymbolG0AsmOperand;
297 def MovKSymbolG3AsmOperand : AsmOperandClass {
298 let Name = "MovKSymbolG3";
299 let RenderMethod = "addImmOperands";
302 def movk_symbol_g3 : Operand<i32> {
303 let ParserMatchClass = MovKSymbolG3AsmOperand;
306 def MovKSymbolG2AsmOperand : AsmOperandClass {
307 let Name = "MovKSymbolG2";
308 let RenderMethod = "addImmOperands";
311 def movk_symbol_g2 : Operand<i32> {
312 let ParserMatchClass = MovKSymbolG2AsmOperand;
315 def MovKSymbolG1AsmOperand : AsmOperandClass {
316 let Name = "MovKSymbolG1";
317 let RenderMethod = "addImmOperands";
320 def movk_symbol_g1 : Operand<i32> {
321 let ParserMatchClass = MovKSymbolG1AsmOperand;
324 def MovKSymbolG0AsmOperand : AsmOperandClass {
325 let Name = "MovKSymbolG0";
326 let RenderMethod = "addImmOperands";
329 def movk_symbol_g0 : Operand<i32> {
330 let ParserMatchClass = MovKSymbolG0AsmOperand;
333 class fixedpoint_i32<ValueType FloatVT>
335 ComplexPattern<FloatVT, 1, "SelectCVTFixedPosOperand<32>", [fpimm, ld]> {
336 let EncoderMethod = "getFixedPointScaleOpValue";
337 let DecoderMethod = "DecodeFixedPointScaleImm32";
338 let ParserMatchClass = Imm1_32Operand;
341 class fixedpoint_i64<ValueType FloatVT>
343 ComplexPattern<FloatVT, 1, "SelectCVTFixedPosOperand<64>", [fpimm, ld]> {
344 let EncoderMethod = "getFixedPointScaleOpValue";
345 let DecoderMethod = "DecodeFixedPointScaleImm64";
346 let ParserMatchClass = Imm1_64Operand;
349 def fixedpoint_f32_i32 : fixedpoint_i32<f32>;
350 def fixedpoint_f64_i32 : fixedpoint_i32<f64>;
352 def fixedpoint_f32_i64 : fixedpoint_i64<f32>;
353 def fixedpoint_f64_i64 : fixedpoint_i64<f64>;
355 def vecshiftR8 : Operand<i32>, ImmLeaf<i32, [{
356 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 9);
358 let EncoderMethod = "getVecShiftR8OpValue";
359 let DecoderMethod = "DecodeVecShiftR8Imm";
360 let ParserMatchClass = Imm1_8Operand;
362 def vecshiftR16 : Operand<i32>, ImmLeaf<i32, [{
363 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
365 let EncoderMethod = "getVecShiftR16OpValue";
366 let DecoderMethod = "DecodeVecShiftR16Imm";
367 let ParserMatchClass = Imm1_16Operand;
369 def vecshiftR16Narrow : Operand<i32>, ImmLeaf<i32, [{
370 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 9);
372 let EncoderMethod = "getVecShiftR16OpValue";
373 let DecoderMethod = "DecodeVecShiftR16ImmNarrow";
374 let ParserMatchClass = Imm1_8Operand;
376 def vecshiftR32 : Operand<i32>, ImmLeaf<i32, [{
377 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 33);
379 let EncoderMethod = "getVecShiftR32OpValue";
380 let DecoderMethod = "DecodeVecShiftR32Imm";
381 let ParserMatchClass = Imm1_32Operand;
383 def vecshiftR32Narrow : Operand<i32>, ImmLeaf<i32, [{
384 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
386 let EncoderMethod = "getVecShiftR32OpValue";
387 let DecoderMethod = "DecodeVecShiftR32ImmNarrow";
388 let ParserMatchClass = Imm1_16Operand;
390 def vecshiftR64 : Operand<i32>, ImmLeaf<i32, [{
391 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 65);
393 let EncoderMethod = "getVecShiftR64OpValue";
394 let DecoderMethod = "DecodeVecShiftR64Imm";
395 let ParserMatchClass = Imm1_64Operand;
397 def vecshiftR64Narrow : Operand<i32>, ImmLeaf<i32, [{
398 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 33);
400 let EncoderMethod = "getVecShiftR64OpValue";
401 let DecoderMethod = "DecodeVecShiftR64ImmNarrow";
402 let ParserMatchClass = Imm1_32Operand;
405 def Imm0_7Operand : AsmImmRange<0, 7>;
406 def Imm0_15Operand : AsmImmRange<0, 15>;
407 def Imm0_31Operand : AsmImmRange<0, 31>;
408 def Imm0_63Operand : AsmImmRange<0, 63>;
410 def vecshiftL8 : Operand<i32>, ImmLeaf<i32, [{
411 return (((uint32_t)Imm) < 8);
413 let EncoderMethod = "getVecShiftL8OpValue";
414 let DecoderMethod = "DecodeVecShiftL8Imm";
415 let ParserMatchClass = Imm0_7Operand;
417 def vecshiftL16 : Operand<i32>, ImmLeaf<i32, [{
418 return (((uint32_t)Imm) < 16);
420 let EncoderMethod = "getVecShiftL16OpValue";
421 let DecoderMethod = "DecodeVecShiftL16Imm";
422 let ParserMatchClass = Imm0_15Operand;
424 def vecshiftL32 : Operand<i32>, ImmLeaf<i32, [{
425 return (((uint32_t)Imm) < 32);
427 let EncoderMethod = "getVecShiftL32OpValue";
428 let DecoderMethod = "DecodeVecShiftL32Imm";
429 let ParserMatchClass = Imm0_31Operand;
431 def vecshiftL64 : Operand<i32>, ImmLeaf<i32, [{
432 return (((uint32_t)Imm) < 64);
434 let EncoderMethod = "getVecShiftL64OpValue";
435 let DecoderMethod = "DecodeVecShiftL64Imm";
436 let ParserMatchClass = Imm0_63Operand;
440 // Crazy immediate formats used by 32-bit and 64-bit logical immediate
441 // instructions for splatting repeating bit patterns across the immediate.
442 def logical_imm32_XFORM : SDNodeXForm<imm, [{
443 uint64_t enc = ARM64_AM::encodeLogicalImmediate(N->getZExtValue(), 32);
444 return CurDAG->getTargetConstant(enc, MVT::i32);
446 def logical_imm64_XFORM : SDNodeXForm<imm, [{
447 uint64_t enc = ARM64_AM::encodeLogicalImmediate(N->getZExtValue(), 64);
448 return CurDAG->getTargetConstant(enc, MVT::i32);
451 def LogicalImm32Operand : AsmOperandClass {
452 let Name = "LogicalImm32";
453 let DiagnosticType = "LogicalSecondSource";
455 def LogicalImm64Operand : AsmOperandClass {
456 let Name = "LogicalImm64";
457 let DiagnosticType = "LogicalSecondSource";
459 def logical_imm32 : Operand<i32>, PatLeaf<(imm), [{
460 return ARM64_AM::isLogicalImmediate(N->getZExtValue(), 32);
461 }], logical_imm32_XFORM> {
462 let PrintMethod = "printLogicalImm32";
463 let ParserMatchClass = LogicalImm32Operand;
465 def logical_imm64 : Operand<i64>, PatLeaf<(imm), [{
466 return ARM64_AM::isLogicalImmediate(N->getZExtValue(), 64);
467 }], logical_imm64_XFORM> {
468 let PrintMethod = "printLogicalImm64";
469 let ParserMatchClass = LogicalImm64Operand;
472 // imm0_255 predicate - True if the immediate is in the range [0,255].
473 def Imm0_255Operand : AsmOperandClass { let Name = "Imm0_255"; }
474 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{
475 return ((uint32_t)Imm) < 256;
477 let ParserMatchClass = Imm0_255Operand;
478 let PrintMethod = "printHexImm";
481 // imm0_127 predicate - True if the immediate is in the range [0,127]
482 def Imm0_127Operand : AsmOperandClass { let Name = "Imm0_127"; }
483 def imm0_127 : Operand<i32>, ImmLeaf<i32, [{
484 return ((uint32_t)Imm) < 128;
486 let ParserMatchClass = Imm0_127Operand;
487 let PrintMethod = "printHexImm";
490 // NOTE: These imm0_N operands have to be of type i64 because i64 is the size
491 // for all shift-amounts.
493 // imm0_63 predicate - True if the immediate is in the range [0,63]
494 def imm0_63 : Operand<i64>, ImmLeaf<i64, [{
495 return ((uint64_t)Imm) < 64;
497 let ParserMatchClass = Imm0_63Operand;
500 // imm0_31 predicate - True if the immediate is in the range [0,31]
501 def imm0_31 : Operand<i64>, ImmLeaf<i64, [{
502 return ((uint64_t)Imm) < 32;
504 let ParserMatchClass = Imm0_31Operand;
507 // imm0_15 predicate - True if the immediate is in the range [0,15]
508 def imm0_15 : Operand<i64>, ImmLeaf<i64, [{
509 return ((uint64_t)Imm) < 16;
511 let ParserMatchClass = Imm0_15Operand;
514 // imm0_7 predicate - True if the immediate is in the range [0,7]
515 def imm0_7 : Operand<i64>, ImmLeaf<i64, [{
516 return ((uint64_t)Imm) < 8;
518 let ParserMatchClass = Imm0_7Operand;
521 // An arithmetic shifter operand:
522 // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr
524 class arith_shift<ValueType Ty, int width> : Operand<Ty> {
525 let PrintMethod = "printShifter";
526 let ParserMatchClass = !cast<AsmOperandClass>(
527 "ArithmeticShifterOperand" # width);
530 def arith_shift32 : arith_shift<i32, 32>;
531 def arith_shift64 : arith_shift<i64, 64>;
533 class arith_shifted_reg<ValueType Ty, RegisterClass regclass, int width>
535 ComplexPattern<Ty, 2, "SelectArithShiftedRegister", []> {
536 let PrintMethod = "printShiftedRegister";
537 let MIOperandInfo = (ops regclass, !cast<Operand>("arith_shift" # width));
540 def arith_shifted_reg32 : arith_shifted_reg<i32, GPR32, 32>;
541 def arith_shifted_reg64 : arith_shifted_reg<i64, GPR64, 64>;
543 // An arithmetic shifter operand:
544 // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr, 11 = ror
546 class logical_shift<int width> : Operand<i32> {
547 let PrintMethod = "printShifter";
548 let ParserMatchClass = !cast<AsmOperandClass>(
549 "LogicalShifterOperand" # width);
552 def logical_shift32 : logical_shift<32>;
553 def logical_shift64 : logical_shift<64>;
555 class logical_shifted_reg<ValueType Ty, RegisterClass regclass, Operand shiftop>
557 ComplexPattern<Ty, 2, "SelectLogicalShiftedRegister", []> {
558 let PrintMethod = "printShiftedRegister";
559 let MIOperandInfo = (ops regclass, shiftop);
562 def logical_shifted_reg32 : logical_shifted_reg<i32, GPR32, logical_shift32>;
563 def logical_shifted_reg64 : logical_shifted_reg<i64, GPR64, logical_shift64>;
565 // A logical vector shifter operand:
566 // {7-6} - shift type: 00 = lsl
567 // {5-0} - imm6: #0, #8, #16, or #24
568 def logical_vec_shift : Operand<i32> {
569 let PrintMethod = "printShifter";
570 let EncoderMethod = "getVecShifterOpValue";
571 let ParserMatchClass = LogicalVecShifterOperand;
574 // A logical vector half-word shifter operand:
575 // {7-6} - shift type: 00 = lsl
576 // {5-0} - imm6: #0 or #8
577 def logical_vec_hw_shift : Operand<i32> {
578 let PrintMethod = "printShifter";
579 let EncoderMethod = "getVecShifterOpValue";
580 let ParserMatchClass = LogicalVecHalfWordShifterOperand;
583 // A vector move shifter operand:
584 // {0} - imm1: #8 or #16
585 def move_vec_shift : Operand<i32> {
586 let PrintMethod = "printShifter";
587 let EncoderMethod = "getMoveVecShifterOpValue";
588 let ParserMatchClass = MoveVecShifterOperand;
591 def AddSubImmOperand : AsmOperandClass {
592 let Name = "AddSubImm";
593 let ParserMethod = "tryParseAddSubImm";
594 let DiagnosticType = "AddSubSecondSource";
596 // An ADD/SUB immediate shifter operand:
598 // {7-6} - shift type: 00 = lsl
599 // {5-0} - imm6: #0 or #12
600 class addsub_shifted_imm<ValueType Ty>
601 : Operand<Ty>, ComplexPattern<Ty, 2, "SelectArithImmed", [imm]> {
602 let PrintMethod = "printAddSubImm";
603 let EncoderMethod = "getAddSubImmOpValue";
604 let ParserMatchClass = AddSubImmOperand;
605 let MIOperandInfo = (ops i32imm, i32imm);
608 def addsub_shifted_imm32 : addsub_shifted_imm<i32>;
609 def addsub_shifted_imm64 : addsub_shifted_imm<i64>;
611 class neg_addsub_shifted_imm<ValueType Ty>
612 : Operand<Ty>, ComplexPattern<Ty, 2, "SelectNegArithImmed", [imm]> {
613 let PrintMethod = "printAddSubImm";
614 let EncoderMethod = "getAddSubImmOpValue";
615 let ParserMatchClass = AddSubImmOperand;
616 let MIOperandInfo = (ops i32imm, i32imm);
619 def neg_addsub_shifted_imm32 : neg_addsub_shifted_imm<i32>;
620 def neg_addsub_shifted_imm64 : neg_addsub_shifted_imm<i64>;
622 // An extend operand:
623 // {5-3} - extend type
625 def arith_extend : Operand<i32> {
626 let PrintMethod = "printExtend";
627 let ParserMatchClass = ExtendOperand;
629 def arith_extend64 : Operand<i32> {
630 let PrintMethod = "printExtend";
631 let ParserMatchClass = ExtendOperand64;
634 // 'extend' that's a lsl of a 64-bit register.
635 def arith_extendlsl64 : Operand<i32> {
636 let PrintMethod = "printExtend";
637 let ParserMatchClass = ExtendOperandLSL64;
640 class arith_extended_reg32<ValueType Ty> : Operand<Ty>,
641 ComplexPattern<Ty, 2, "SelectArithExtendedRegister", []> {
642 let PrintMethod = "printExtendedRegister";
643 let MIOperandInfo = (ops GPR32, arith_extend);
646 class arith_extended_reg32to64<ValueType Ty> : Operand<Ty>,
647 ComplexPattern<Ty, 2, "SelectArithExtendedRegister", []> {
648 let PrintMethod = "printExtendedRegister";
649 let MIOperandInfo = (ops GPR32, arith_extend64);
652 // Floating-point immediate.
653 def fpimm32 : Operand<f32>,
654 PatLeaf<(f32 fpimm), [{
655 return ARM64_AM::getFP32Imm(N->getValueAPF()) != -1;
656 }], SDNodeXForm<fpimm, [{
657 APFloat InVal = N->getValueAPF();
658 uint32_t enc = ARM64_AM::getFP32Imm(InVal);
659 return CurDAG->getTargetConstant(enc, MVT::i32);
661 let ParserMatchClass = FPImmOperand;
662 let PrintMethod = "printFPImmOperand";
664 def fpimm64 : Operand<f64>,
665 PatLeaf<(f64 fpimm), [{
666 return ARM64_AM::getFP64Imm(N->getValueAPF()) != -1;
667 }], SDNodeXForm<fpimm, [{
668 APFloat InVal = N->getValueAPF();
669 uint32_t enc = ARM64_AM::getFP64Imm(InVal);
670 return CurDAG->getTargetConstant(enc, MVT::i32);
672 let ParserMatchClass = FPImmOperand;
673 let PrintMethod = "printFPImmOperand";
676 def fpimm8 : Operand<i32> {
677 let ParserMatchClass = FPImmOperand;
678 let PrintMethod = "printFPImmOperand";
681 def fpimm0 : PatLeaf<(fpimm), [{
682 return N->isExactlyValue(+0.0);
685 // 8-bit immediate for AdvSIMD where 64-bit values of the form:
686 // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
687 // are encoded as the eight bit value 'abcdefgh'.
688 def simdimmtype10 : Operand<i32>,
689 PatLeaf<(f64 fpimm), [{
690 return ARM64_AM::isAdvSIMDModImmType10(N->getValueAPF()
693 }], SDNodeXForm<fpimm, [{
694 APFloat InVal = N->getValueAPF();
695 uint32_t enc = ARM64_AM::encodeAdvSIMDModImmType10(N->getValueAPF()
698 return CurDAG->getTargetConstant(enc, MVT::i32);
700 let ParserMatchClass = SIMDImmType10Operand;
701 let PrintMethod = "printSIMDType10Operand";
709 // Base encoding for system instruction operands.
710 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
711 class BaseSystemI<bit L, dag oops, dag iops, string asm, string operands>
712 : I<oops, iops, asm, operands, "", []> {
713 let Inst{31-22} = 0b1101010100;
717 // System instructions which do not have an Rt register.
718 class SimpleSystemI<bit L, dag iops, string asm, string operands>
719 : BaseSystemI<L, (outs), iops, asm, operands> {
720 let Inst{4-0} = 0b11111;
723 // System instructions which have an Rt register.
724 class RtSystemI<bit L, dag oops, dag iops, string asm, string operands>
725 : BaseSystemI<L, oops, iops, asm, operands>,
731 // Hint instructions that take both a CRm and a 3-bit immediate.
732 class HintI<string mnemonic>
733 : SimpleSystemI<0, (ins imm0_127:$imm), mnemonic#" $imm", "">,
736 let Inst{20-12} = 0b000110010;
737 let Inst{11-5} = imm;
740 // System instructions taking a single literal operand which encodes into
741 // CRm. op2 differentiates the opcodes.
742 def BarrierAsmOperand : AsmOperandClass {
743 let Name = "Barrier";
744 let ParserMethod = "tryParseBarrierOperand";
746 def barrier_op : Operand<i32> {
747 let PrintMethod = "printBarrierOption";
748 let ParserMatchClass = BarrierAsmOperand;
750 class CRmSystemI<Operand crmtype, bits<3> opc, string asm>
751 : SimpleSystemI<0, (ins crmtype:$CRm), asm, "\t$CRm">,
752 Sched<[WriteBarrier]> {
754 let Inst{20-12} = 0b000110011;
755 let Inst{11-8} = CRm;
759 // MRS/MSR system instructions. These have different operand classes because
760 // a different subset of registers can be accessed through each instruction.
761 def MRSSystemRegisterOperand : AsmOperandClass {
762 let Name = "MRSSystemRegister";
763 let ParserMethod = "tryParseSysReg";
764 let DiagnosticType = "MRS";
766 // concatenation of 1, op0, op1, CRn, CRm, op2. 16-bit immediate.
767 def mrs_sysreg_op : Operand<i32> {
768 let ParserMatchClass = MRSSystemRegisterOperand;
769 let DecoderMethod = "DecodeMRSSystemRegister";
770 let PrintMethod = "printMRSSystemRegister";
773 def MSRSystemRegisterOperand : AsmOperandClass {
774 let Name = "MSRSystemRegister";
775 let ParserMethod = "tryParseSysReg";
776 let DiagnosticType = "MSR";
778 def msr_sysreg_op : Operand<i32> {
779 let ParserMatchClass = MSRSystemRegisterOperand;
780 let DecoderMethod = "DecodeMSRSystemRegister";
781 let PrintMethod = "printMSRSystemRegister";
784 class MRSI : RtSystemI<1, (outs GPR64:$Rt), (ins mrs_sysreg_op:$systemreg),
785 "mrs", "\t$Rt, $systemreg"> {
788 let Inst{19-5} = systemreg;
791 // FIXME: Some of these def NZCV, others don't. Best way to model that?
792 // Explicitly modeling each of the system register as a register class
793 // would do it, but feels like overkill at this point.
794 class MSRI : RtSystemI<0, (outs), (ins msr_sysreg_op:$systemreg, GPR64:$Rt),
795 "msr", "\t$systemreg, $Rt"> {
798 let Inst{19-5} = systemreg;
801 def SystemPStateFieldOperand : AsmOperandClass {
802 let Name = "SystemPStateField";
803 let ParserMethod = "tryParseSysReg";
805 def pstatefield_op : Operand<i32> {
806 let ParserMatchClass = SystemPStateFieldOperand;
807 let PrintMethod = "printSystemPStateField";
812 : SimpleSystemI<0, (ins pstatefield_op:$pstate_field, imm0_15:$imm),
813 "msr", "\t$pstate_field, $imm">,
817 let Inst{20-19} = 0b00;
818 let Inst{18-16} = pstatefield{5-3};
819 let Inst{15-12} = 0b0100;
820 let Inst{11-8} = imm;
821 let Inst{7-5} = pstatefield{2-0};
823 let DecoderMethod = "DecodeSystemPStateInstruction";
826 // SYS and SYSL generic system instructions.
827 def SysCRAsmOperand : AsmOperandClass {
829 let ParserMethod = "tryParseSysCROperand";
832 def sys_cr_op : Operand<i32> {
833 let PrintMethod = "printSysCROperand";
834 let ParserMatchClass = SysCRAsmOperand;
837 class SystemXtI<bit L, string asm>
838 : RtSystemI<L, (outs),
839 (ins imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2, GPR64:$Rt),
840 asm, "\t$op1, $Cn, $Cm, $op2, $Rt"> {
845 let Inst{20-19} = 0b01;
846 let Inst{18-16} = op1;
847 let Inst{15-12} = Cn;
852 class SystemLXtI<bit L, string asm>
853 : RtSystemI<L, (outs),
854 (ins GPR64:$Rt, imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2),
855 asm, "\t$Rt, $op1, $Cn, $Cm, $op2"> {
860 let Inst{20-19} = 0b01;
861 let Inst{18-16} = op1;
862 let Inst{15-12} = Cn;
868 // Branch (register) instructions:
876 // otherwise UNDEFINED
877 class BaseBranchReg<bits<4> opc, dag oops, dag iops, string asm,
878 string operands, list<dag> pattern>
879 : I<oops, iops, asm, operands, "", pattern>, Sched<[WriteBrReg]> {
880 let Inst{31-25} = 0b1101011;
881 let Inst{24-21} = opc;
882 let Inst{20-16} = 0b11111;
883 let Inst{15-10} = 0b000000;
884 let Inst{4-0} = 0b00000;
887 class BranchReg<bits<4> opc, string asm, list<dag> pattern>
888 : BaseBranchReg<opc, (outs), (ins GPR64:$Rn), asm, "\t$Rn", pattern> {
893 let mayLoad = 0, mayStore = 0, hasSideEffects = 1, isReturn = 1 in
894 class SpecialReturn<bits<4> opc, string asm>
895 : BaseBranchReg<opc, (outs), (ins), asm, "", []> {
896 let Inst{9-5} = 0b11111;
900 // Conditional branch instruction.
902 // Branch condition code.
903 // 4-bit immediate. Pretty-printed as .<cc>
904 def dotCcode : Operand<i32> {
905 let PrintMethod = "printDotCondCode";
908 // Conditional branch target. 19-bit immediate. The low two bits of the target
909 // offset are implied zero and so are not part of the immediate.
910 def PCRelLabel19Operand : AsmOperandClass {
911 let Name = "PCRelLabel19";
913 def am_brcond : Operand<OtherVT> {
914 let EncoderMethod = "getCondBranchTargetOpValue";
915 let DecoderMethod = "DecodePCRelLabel19";
916 let PrintMethod = "printAlignedLabel";
917 let ParserMatchClass = PCRelLabel19Operand;
920 class BranchCond : I<(outs), (ins dotCcode:$cond, am_brcond:$target),
921 "b", "$cond\t$target", "",
922 [(ARM64brcond bb:$target, imm:$cond, NZCV)]>,
925 let isTerminator = 1;
930 let Inst{31-24} = 0b01010100;
931 let Inst{23-5} = target;
933 let Inst{3-0} = cond;
937 // Compare-and-branch instructions.
939 class BaseCmpBranch<RegisterClass regtype, bit op, string asm, SDNode node>
940 : I<(outs), (ins regtype:$Rt, am_brcond:$target),
941 asm, "\t$Rt, $target", "",
942 [(node regtype:$Rt, bb:$target)]>,
945 let isTerminator = 1;
949 let Inst{30-25} = 0b011010;
951 let Inst{23-5} = target;
955 multiclass CmpBranch<bit op, string asm, SDNode node> {
956 def W : BaseCmpBranch<GPR32, op, asm, node> {
959 def X : BaseCmpBranch<GPR64, op, asm, node> {
965 // Test-bit-and-branch instructions.
967 // Test-and-branch target. 14-bit sign-extended immediate. The low two bits of
968 // the target offset are implied zero and so are not part of the immediate.
969 def BranchTarget14Operand : AsmOperandClass {
970 let Name = "BranchTarget14";
972 def am_tbrcond : Operand<OtherVT> {
973 let EncoderMethod = "getTestBranchTargetOpValue";
974 let PrintMethod = "printAlignedLabel";
975 let ParserMatchClass = BranchTarget14Operand;
978 class TestBranch<bit op, string asm, SDNode node>
979 : I<(outs), (ins GPR64:$Rt, imm0_63:$bit_off, am_tbrcond:$target),
980 asm, "\t$Rt, $bit_off, $target", "",
981 [(node GPR64:$Rt, imm0_63:$bit_off, bb:$target)]>,
984 let isTerminator = 1;
990 let Inst{31} = bit_off{5};
991 let Inst{30-25} = 0b011011;
993 let Inst{23-19} = bit_off{4-0};
994 let Inst{18-5} = target;
997 let DecoderMethod = "DecodeTestAndBranch";
1001 // Unconditional branch (immediate) instructions.
1003 def BranchTarget26Operand : AsmOperandClass {
1004 let Name = "BranchTarget26";
1006 def am_b_target : Operand<OtherVT> {
1007 let EncoderMethod = "getBranchTargetOpValue";
1008 let PrintMethod = "printAlignedLabel";
1009 let ParserMatchClass = BranchTarget26Operand;
1011 def am_bl_target : Operand<i64> {
1012 let EncoderMethod = "getBranchTargetOpValue";
1013 let PrintMethod = "printAlignedLabel";
1014 let ParserMatchClass = BranchTarget26Operand;
1017 class BImm<bit op, dag iops, string asm, list<dag> pattern>
1018 : I<(outs), iops, asm, "\t$addr", "", pattern>, Sched<[WriteBr]> {
1021 let Inst{30-26} = 0b00101;
1022 let Inst{25-0} = addr;
1024 let DecoderMethod = "DecodeUnconditionalBranch";
1027 class BranchImm<bit op, string asm, list<dag> pattern>
1028 : BImm<op, (ins am_b_target:$addr), asm, pattern>;
1029 class CallImm<bit op, string asm, list<dag> pattern>
1030 : BImm<op, (ins am_bl_target:$addr), asm, pattern>;
1033 // Basic one-operand data processing instructions.
1036 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1037 class BaseOneOperandData<bits<3> opc, RegisterClass regtype, string asm,
1038 SDPatternOperator node>
1039 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
1040 [(set regtype:$Rd, (node regtype:$Rn))]>,
1045 let Inst{30-13} = 0b101101011000000000;
1046 let Inst{12-10} = opc;
1051 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1052 multiclass OneOperandData<bits<3> opc, string asm,
1053 SDPatternOperator node = null_frag> {
1054 def Wr : BaseOneOperandData<opc, GPR32, asm, node> {
1058 def Xr : BaseOneOperandData<opc, GPR64, asm, node> {
1063 class OneWRegData<bits<3> opc, string asm, SDPatternOperator node>
1064 : BaseOneOperandData<opc, GPR32, asm, node> {
1068 class OneXRegData<bits<3> opc, string asm, SDPatternOperator node>
1069 : BaseOneOperandData<opc, GPR64, asm, node> {
1074 // Basic two-operand data processing instructions.
1076 class BaseBaseAddSubCarry<bit isSub, RegisterClass regtype, string asm,
1078 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1079 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
1085 let Inst{30} = isSub;
1086 let Inst{28-21} = 0b11010000;
1087 let Inst{20-16} = Rm;
1088 let Inst{15-10} = 0;
1093 class BaseAddSubCarry<bit isSub, RegisterClass regtype, string asm,
1095 : BaseBaseAddSubCarry<isSub, regtype, asm,
1096 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm, NZCV))]>;
1098 class BaseAddSubCarrySetFlags<bit isSub, RegisterClass regtype, string asm,
1100 : BaseBaseAddSubCarry<isSub, regtype, asm,
1101 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm, NZCV)),
1106 multiclass AddSubCarry<bit isSub, string asm, string asm_setflags,
1107 SDNode OpNode, SDNode OpNode_setflags> {
1108 def Wr : BaseAddSubCarry<isSub, GPR32, asm, OpNode> {
1112 def Xr : BaseAddSubCarry<isSub, GPR64, asm, OpNode> {
1118 def SWr : BaseAddSubCarrySetFlags<isSub, GPR32, asm_setflags,
1123 def SXr : BaseAddSubCarrySetFlags<isSub, GPR64, asm_setflags,
1130 class BaseTwoOperand<bits<4> opc, RegisterClass regtype, string asm,
1131 SDPatternOperator OpNode>
1132 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1133 asm, "\t$Rd, $Rn, $Rm", "",
1134 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]> {
1138 let Inst{30-21} = 0b0011010110;
1139 let Inst{20-16} = Rm;
1140 let Inst{15-14} = 0b00;
1141 let Inst{13-10} = opc;
1146 class BaseDiv<bit isSigned, RegisterClass regtype, string asm,
1147 SDPatternOperator OpNode>
1148 : BaseTwoOperand<{0,0,1,?}, regtype, asm, OpNode> {
1149 let Inst{10} = isSigned;
1152 multiclass Div<bit isSigned, string asm, SDPatternOperator OpNode> {
1153 def Wr : BaseDiv<isSigned, GPR32, asm, OpNode>,
1154 Sched<[WriteID32]> {
1157 def Xr : BaseDiv<isSigned, GPR64, asm, OpNode>,
1158 Sched<[WriteID64]> {
1163 class BaseShift<bits<2> shift_type, RegisterClass regtype, string asm,
1164 SDPatternOperator OpNode = null_frag>
1165 : BaseTwoOperand<{1,0,?,?}, regtype, asm, OpNode>,
1167 let Inst{11-10} = shift_type;
1170 multiclass Shift<bits<2> shift_type, string asm, SDNode OpNode> {
1171 def Wr : BaseShift<shift_type, GPR32, asm> {
1175 def Xr : BaseShift<shift_type, GPR64, asm, OpNode> {
1179 def : Pat<(i32 (OpNode GPR32:$Rn, i64:$Rm)),
1180 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn,
1181 (EXTRACT_SUBREG i64:$Rm, sub_32))>;
1183 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (zext GPR32:$Rm)))),
1184 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1186 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (anyext GPR32:$Rm)))),
1187 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1189 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (sext GPR32:$Rm)))),
1190 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1193 class ShiftAlias<string asm, Instruction inst, RegisterClass regtype>
1194 : InstAlias<asm#" $dst, $src1, $src2",
1195 (inst regtype:$dst, regtype:$src1, regtype:$src2)>;
1197 class BaseMulAccum<bit isSub, bits<3> opc, RegisterClass multype,
1198 RegisterClass addtype, string asm,
1200 : I<(outs addtype:$Rd), (ins multype:$Rn, multype:$Rm, addtype:$Ra),
1201 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pattern> {
1206 let Inst{30-24} = 0b0011011;
1207 let Inst{23-21} = opc;
1208 let Inst{20-16} = Rm;
1209 let Inst{15} = isSub;
1210 let Inst{14-10} = Ra;
1215 multiclass MulAccum<bit isSub, string asm, SDNode AccNode> {
1216 def Wrrr : BaseMulAccum<isSub, 0b000, GPR32, GPR32, asm,
1217 [(set GPR32:$Rd, (AccNode GPR32:$Ra, (mul GPR32:$Rn, GPR32:$Rm)))]>,
1218 Sched<[WriteIM32]> {
1222 def Xrrr : BaseMulAccum<isSub, 0b000, GPR64, GPR64, asm,
1223 [(set GPR64:$Rd, (AccNode GPR64:$Ra, (mul GPR64:$Rn, GPR64:$Rm)))]>,
1224 Sched<[WriteIM64]> {
1229 class WideMulAccum<bit isSub, bits<3> opc, string asm,
1230 SDNode AccNode, SDNode ExtNode>
1231 : BaseMulAccum<isSub, opc, GPR32, GPR64, asm,
1232 [(set GPR64:$Rd, (AccNode GPR64:$Ra,
1233 (mul (ExtNode GPR32:$Rn), (ExtNode GPR32:$Rm))))]>,
1234 Sched<[WriteIM32]> {
1238 class MulHi<bits<3> opc, string asm, SDNode OpNode>
1239 : I<(outs GPR64:$Rd), (ins GPR64:$Rn, GPR64:$Rm),
1240 asm, "\t$Rd, $Rn, $Rm", "",
1241 [(set GPR64:$Rd, (OpNode GPR64:$Rn, GPR64:$Rm))]>,
1242 Sched<[WriteIM64]> {
1246 let Inst{31-24} = 0b10011011;
1247 let Inst{23-21} = opc;
1248 let Inst{20-16} = Rm;
1253 // The Ra field of SMULH and UMULH is unused: it should be assembled as 31
1254 // (i.e. all bits 1) but is ignored by the processor.
1255 let PostEncoderMethod = "fixMulHigh";
1258 class MulAccumWAlias<string asm, Instruction inst>
1259 : InstAlias<asm#" $dst, $src1, $src2",
1260 (inst GPR32:$dst, GPR32:$src1, GPR32:$src2, WZR)>;
1261 class MulAccumXAlias<string asm, Instruction inst>
1262 : InstAlias<asm#" $dst, $src1, $src2",
1263 (inst GPR64:$dst, GPR64:$src1, GPR64:$src2, XZR)>;
1264 class WideMulAccumAlias<string asm, Instruction inst>
1265 : InstAlias<asm#" $dst, $src1, $src2",
1266 (inst GPR64:$dst, GPR32:$src1, GPR32:$src2, XZR)>;
1268 class BaseCRC32<bit sf, bits<2> sz, bit C, RegisterClass StreamReg,
1269 SDPatternOperator OpNode, string asm>
1270 : I<(outs GPR32:$Rd), (ins GPR32:$Rn, StreamReg:$Rm),
1271 asm, "\t$Rd, $Rn, $Rm", "",
1272 [(set GPR32:$Rd, (OpNode GPR32:$Rn, StreamReg:$Rm))]>,
1273 Sched<[WriteISReg]> {
1279 let Inst{30-21} = 0b0011010110;
1280 let Inst{20-16} = Rm;
1281 let Inst{15-13} = 0b010;
1283 let Inst{11-10} = sz;
1286 let Predicates = [HasCRC];
1290 // Address generation.
1293 class ADRI<bit page, string asm, Operand adr, list<dag> pattern>
1294 : I<(outs GPR64:$Xd), (ins adr:$label), asm, "\t$Xd, $label", "",
1299 let Inst{31} = page;
1300 let Inst{30-29} = label{1-0};
1301 let Inst{28-24} = 0b10000;
1302 let Inst{23-5} = label{20-2};
1305 let DecoderMethod = "DecodeAdrInstruction";
1312 def movimm32_imm : Operand<i32> {
1313 let ParserMatchClass = Imm0_65535Operand;
1314 let EncoderMethod = "getMoveWideImmOpValue";
1315 let PrintMethod = "printHexImm";
1317 def movimm32_shift : Operand<i32> {
1318 let PrintMethod = "printShifter";
1319 let ParserMatchClass = MovImm32ShifterOperand;
1321 def movimm64_shift : Operand<i32> {
1322 let PrintMethod = "printShifter";
1323 let ParserMatchClass = MovImm64ShifterOperand;
1326 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1327 class BaseMoveImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
1329 : I<(outs regtype:$Rd), (ins movimm32_imm:$imm, shifter:$shift),
1330 asm, "\t$Rd, $imm$shift", "", []>,
1335 let Inst{30-29} = opc;
1336 let Inst{28-23} = 0b100101;
1337 let Inst{22-21} = shift{5-4};
1338 let Inst{20-5} = imm;
1341 let DecoderMethod = "DecodeMoveImmInstruction";
1344 multiclass MoveImmediate<bits<2> opc, string asm> {
1345 def Wi : BaseMoveImmediate<opc, GPR32, movimm32_shift, asm> {
1349 def Xi : BaseMoveImmediate<opc, GPR64, movimm64_shift, asm> {
1354 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1355 class BaseInsertImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
1357 : I<(outs regtype:$Rd),
1358 (ins regtype:$src, movimm32_imm:$imm, shifter:$shift),
1359 asm, "\t$Rd, $imm$shift", "$src = $Rd", []>,
1364 let Inst{30-29} = opc;
1365 let Inst{28-23} = 0b100101;
1366 let Inst{22-21} = shift{5-4};
1367 let Inst{20-5} = imm;
1370 let DecoderMethod = "DecodeMoveImmInstruction";
1373 multiclass InsertImmediate<bits<2> opc, string asm> {
1374 def Wi : BaseInsertImmediate<opc, GPR32, movimm32_shift, asm> {
1378 def Xi : BaseInsertImmediate<opc, GPR64, movimm64_shift, asm> {
1387 class BaseAddSubImm<bit isSub, bit setFlags, RegisterClass dstRegtype,
1388 RegisterClass srcRegtype, addsub_shifted_imm immtype,
1389 string asm, SDPatternOperator OpNode>
1390 : I<(outs dstRegtype:$Rd), (ins srcRegtype:$Rn, immtype:$imm),
1391 asm, "\t$Rd, $Rn, $imm", "",
1392 [(set dstRegtype:$Rd, (OpNode srcRegtype:$Rn, immtype:$imm))]>,
1397 let Inst{30} = isSub;
1398 let Inst{29} = setFlags;
1399 let Inst{28-24} = 0b10001;
1400 let Inst{23-22} = imm{13-12}; // '00' => lsl #0, '01' => lsl #12
1401 let Inst{21-10} = imm{11-0};
1404 let DecoderMethod = "DecodeBaseAddSubImm";
1407 class BaseAddSubRegPseudo<RegisterClass regtype,
1408 SDPatternOperator OpNode>
1409 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1410 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
1413 class BaseAddSubSReg<bit isSub, bit setFlags, RegisterClass regtype,
1414 arith_shifted_reg shifted_regtype, string asm,
1415 SDPatternOperator OpNode>
1416 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
1417 asm, "\t$Rd, $Rn, $Rm", "",
1418 [(set regtype:$Rd, (OpNode regtype:$Rn, shifted_regtype:$Rm))]>,
1419 Sched<[WriteISReg]> {
1420 // The operands are in order to match the 'addr' MI operands, so we
1421 // don't need an encoder method and by-name matching. Just use the default
1422 // in-order handling. Since we're using by-order, make sure the names
1428 let Inst{30} = isSub;
1429 let Inst{29} = setFlags;
1430 let Inst{28-24} = 0b01011;
1431 let Inst{23-22} = shift{7-6};
1433 let Inst{20-16} = src2;
1434 let Inst{15-10} = shift{5-0};
1435 let Inst{9-5} = src1;
1436 let Inst{4-0} = dst;
1438 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
1441 class BaseAddSubEReg<bit isSub, bit setFlags, RegisterClass dstRegtype,
1442 RegisterClass src1Regtype, Operand src2Regtype,
1443 string asm, SDPatternOperator OpNode>
1444 : I<(outs dstRegtype:$R1),
1445 (ins src1Regtype:$R2, src2Regtype:$R3),
1446 asm, "\t$R1, $R2, $R3", "",
1447 [(set dstRegtype:$R1, (OpNode src1Regtype:$R2, src2Regtype:$R3))]>,
1448 Sched<[WriteIEReg]> {
1453 let Inst{30} = isSub;
1454 let Inst{29} = setFlags;
1455 let Inst{28-24} = 0b01011;
1456 let Inst{23-21} = 0b001;
1457 let Inst{20-16} = Rm;
1458 let Inst{15-13} = ext{5-3};
1459 let Inst{12-10} = ext{2-0};
1463 let DecoderMethod = "DecodeAddSubERegInstruction";
1466 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1467 class BaseAddSubEReg64<bit isSub, bit setFlags, RegisterClass dstRegtype,
1468 RegisterClass src1Regtype, RegisterClass src2Regtype,
1469 Operand ext_op, string asm>
1470 : I<(outs dstRegtype:$Rd),
1471 (ins src1Regtype:$Rn, src2Regtype:$Rm, ext_op:$ext),
1472 asm, "\t$Rd, $Rn, $Rm$ext", "", []>,
1473 Sched<[WriteIEReg]> {
1478 let Inst{30} = isSub;
1479 let Inst{29} = setFlags;
1480 let Inst{28-24} = 0b01011;
1481 let Inst{23-21} = 0b001;
1482 let Inst{20-16} = Rm;
1483 let Inst{15} = ext{5};
1484 let Inst{12-10} = ext{2-0};
1488 let DecoderMethod = "DecodeAddSubERegInstruction";
1491 // Aliases for register+register add/subtract.
1492 class AddSubRegAlias<string asm, Instruction inst, RegisterClass dstRegtype,
1493 RegisterClass src1Regtype, RegisterClass src2Regtype,
1495 : InstAlias<asm#" $dst, $src1, $src2",
1496 (inst dstRegtype:$dst, src1Regtype:$src1, src2Regtype:$src2,
1499 multiclass AddSub<bit isSub, string mnemonic,
1500 SDPatternOperator OpNode = null_frag> {
1501 let hasSideEffects = 0 in {
1502 // Add/Subtract immediate
1503 def Wri : BaseAddSubImm<isSub, 0, GPR32sp, GPR32sp, addsub_shifted_imm32,
1507 def Xri : BaseAddSubImm<isSub, 0, GPR64sp, GPR64sp, addsub_shifted_imm64,
1512 // Add/Subtract register - Only used for CodeGen
1513 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
1514 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
1516 // Add/Subtract shifted register
1517 def Wrs : BaseAddSubSReg<isSub, 0, GPR32, arith_shifted_reg32, mnemonic,
1521 def Xrs : BaseAddSubSReg<isSub, 0, GPR64, arith_shifted_reg64, mnemonic,
1527 // Add/Subtract extended register
1528 let AddedComplexity = 1, hasSideEffects = 0 in {
1529 def Wrx : BaseAddSubEReg<isSub, 0, GPR32sp, GPR32sp,
1530 arith_extended_reg32<i32>, mnemonic, OpNode> {
1533 def Xrx : BaseAddSubEReg<isSub, 0, GPR64sp, GPR64sp,
1534 arith_extended_reg32to64<i64>, mnemonic, OpNode> {
1539 def Xrx64 : BaseAddSubEReg64<isSub, 0, GPR64sp, GPR64sp, GPR64,
1540 arith_extendlsl64, mnemonic> {
1541 // UXTX and SXTX only.
1542 let Inst{14-13} = 0b11;
1546 // Register/register aliases with no shift when SP is not used.
1547 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
1548 GPR32, GPR32, GPR32, 0>;
1549 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
1550 GPR64, GPR64, GPR64, 0>;
1552 // Register/register aliases with no shift when either the destination or
1553 // first source register is SP. This relies on the shifted register aliases
1554 // above matching first in the case when SP is not used.
1555 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1556 GPR32sp, GPR32sp, GPR32, 16>; // UXTW #0
1557 def : AddSubRegAlias<mnemonic,
1558 !cast<Instruction>(NAME#"Xrx64"),
1559 GPR64sp, GPR64sp, GPR64, 24>; // UXTX #0
1562 multiclass AddSubS<bit isSub, string mnemonic, SDNode OpNode, string cmp> {
1563 let isCompare = 1, Defs = [NZCV] in {
1564 // Add/Subtract immediate
1565 def Wri : BaseAddSubImm<isSub, 1, GPR32, GPR32sp, addsub_shifted_imm32,
1569 def Xri : BaseAddSubImm<isSub, 1, GPR64, GPR64sp, addsub_shifted_imm64,
1574 // Add/Subtract register
1575 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
1576 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
1578 // Add/Subtract shifted register
1579 def Wrs : BaseAddSubSReg<isSub, 1, GPR32, arith_shifted_reg32, mnemonic,
1583 def Xrs : BaseAddSubSReg<isSub, 1, GPR64, arith_shifted_reg64, mnemonic,
1588 // Add/Subtract extended register
1589 let AddedComplexity = 1 in {
1590 def Wrx : BaseAddSubEReg<isSub, 1, GPR32, GPR32sp,
1591 arith_extended_reg32<i32>, mnemonic, OpNode> {
1594 def Xrx : BaseAddSubEReg<isSub, 1, GPR64, GPR64sp,
1595 arith_extended_reg32<i64>, mnemonic, OpNode> {
1600 def Xrx64 : BaseAddSubEReg64<isSub, 1, GPR64, GPR64sp, GPR64,
1601 arith_extendlsl64, mnemonic> {
1602 // UXTX and SXTX only.
1603 let Inst{14-13} = 0b11;
1609 def : InstAlias<cmp#" $src, $imm", (!cast<Instruction>(NAME#"Wri")
1610 WZR, GPR32sp:$src, addsub_shifted_imm32:$imm)>;
1611 def : InstAlias<cmp#" $src, $imm", (!cast<Instruction>(NAME#"Xri")
1612 XZR, GPR64sp:$src, addsub_shifted_imm64:$imm)>;
1613 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Wrx")
1614 WZR, GPR32sp:$src1, GPR32:$src2, arith_extend:$sh)>;
1615 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Xrx")
1616 XZR, GPR64sp:$src1, GPR32:$src2, arith_extend:$sh)>;
1617 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Xrx64")
1618 XZR, GPR64sp:$src1, GPR64:$src2, arith_extendlsl64:$sh)>;
1619 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Wrs")
1620 WZR, GPR32:$src1, GPR32:$src2, arith_shift32:$sh)>;
1621 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Xrs")
1622 XZR, GPR64:$src1, GPR64:$src2, arith_shift64:$sh)>;
1624 // Compare shorthands
1625 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Wrs")
1626 WZR, GPR32:$src1, GPR32:$src2, 0)>;
1627 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Xrs")
1628 XZR, GPR64:$src1, GPR64:$src2, 0)>;
1630 // Register/register aliases with no shift when SP is not used.
1631 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
1632 GPR32, GPR32, GPR32, 0>;
1633 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
1634 GPR64, GPR64, GPR64, 0>;
1636 // Register/register aliases with no shift when the first source register
1637 // is SP. This relies on the shifted register aliases above matching first
1638 // in the case when SP is not used.
1639 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1640 GPR32, GPR32sp, GPR32, 16>; // UXTW #0
1641 def : AddSubRegAlias<mnemonic,
1642 !cast<Instruction>(NAME#"Xrx64"),
1643 GPR64, GPR64sp, GPR64, 24>; // UXTX #0
1649 def SDTA64EXTR : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
1651 def ARM64Extr : SDNode<"ARM64ISD::EXTR", SDTA64EXTR>;
1653 class BaseExtractImm<RegisterClass regtype, Operand imm_type, string asm,
1655 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, imm_type:$imm),
1656 asm, "\t$Rd, $Rn, $Rm, $imm", "", patterns>,
1657 Sched<[WriteExtr, ReadExtrHi]> {
1663 let Inst{30-23} = 0b00100111;
1665 let Inst{20-16} = Rm;
1666 let Inst{15-10} = imm;
1671 multiclass ExtractImm<string asm> {
1672 def Wrri : BaseExtractImm<GPR32, imm0_31, asm,
1674 (ARM64Extr GPR32:$Rn, GPR32:$Rm, imm0_31:$imm))]> {
1677 // imm<5> must be zero.
1680 def Xrri : BaseExtractImm<GPR64, imm0_63, asm,
1682 (ARM64Extr GPR64:$Rn, GPR64:$Rm, imm0_63:$imm))]> {
1693 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1694 class BaseBitfieldImm<bits<2> opc,
1695 RegisterClass regtype, Operand imm_type, string asm>
1696 : I<(outs regtype:$Rd), (ins regtype:$Rn, imm_type:$immr, imm_type:$imms),
1697 asm, "\t$Rd, $Rn, $immr, $imms", "", []>,
1704 let Inst{30-29} = opc;
1705 let Inst{28-23} = 0b100110;
1706 let Inst{21-16} = immr;
1707 let Inst{15-10} = imms;
1712 multiclass BitfieldImm<bits<2> opc, string asm> {
1713 def Wri : BaseBitfieldImm<opc, GPR32, imm0_31, asm> {
1716 // imms<5> and immr<5> must be zero, else ReservedValue().
1720 def Xri : BaseBitfieldImm<opc, GPR64, imm0_63, asm> {
1726 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1727 class BaseBitfieldImmWith2RegArgs<bits<2> opc,
1728 RegisterClass regtype, Operand imm_type, string asm>
1729 : I<(outs regtype:$Rd), (ins regtype:$src, regtype:$Rn, imm_type:$immr,
1731 asm, "\t$Rd, $Rn, $immr, $imms", "$src = $Rd", []>,
1738 let Inst{30-29} = opc;
1739 let Inst{28-23} = 0b100110;
1740 let Inst{21-16} = immr;
1741 let Inst{15-10} = imms;
1746 multiclass BitfieldImmWith2RegArgs<bits<2> opc, string asm> {
1747 def Wri : BaseBitfieldImmWith2RegArgs<opc, GPR32, imm0_31, asm> {
1750 // imms<5> and immr<5> must be zero, else ReservedValue().
1754 def Xri : BaseBitfieldImmWith2RegArgs<opc, GPR64, imm0_63, asm> {
1764 // Logical (immediate)
1765 class BaseLogicalImm<bits<2> opc, RegisterClass dregtype,
1766 RegisterClass sregtype, Operand imm_type, string asm,
1768 : I<(outs dregtype:$Rd), (ins sregtype:$Rn, imm_type:$imm),
1769 asm, "\t$Rd, $Rn, $imm", "", pattern>,
1774 let Inst{30-29} = opc;
1775 let Inst{28-23} = 0b100100;
1776 let Inst{22} = imm{12};
1777 let Inst{21-16} = imm{11-6};
1778 let Inst{15-10} = imm{5-0};
1782 let DecoderMethod = "DecodeLogicalImmInstruction";
1785 // Logical (shifted register)
1786 class BaseLogicalSReg<bits<2> opc, bit N, RegisterClass regtype,
1787 logical_shifted_reg shifted_regtype, string asm,
1789 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
1790 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
1791 Sched<[WriteISReg]> {
1792 // The operands are in order to match the 'addr' MI operands, so we
1793 // don't need an encoder method and by-name matching. Just use the default
1794 // in-order handling. Since we're using by-order, make sure the names
1800 let Inst{30-29} = opc;
1801 let Inst{28-24} = 0b01010;
1802 let Inst{23-22} = shift{7-6};
1804 let Inst{20-16} = src2;
1805 let Inst{15-10} = shift{5-0};
1806 let Inst{9-5} = src1;
1807 let Inst{4-0} = dst;
1809 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
1812 // Aliases for register+register logical instructions.
1813 class LogicalRegAlias<string asm, Instruction inst, RegisterClass regtype>
1814 : InstAlias<asm#" $dst, $src1, $src2",
1815 (inst regtype:$dst, regtype:$src1, regtype:$src2, 0)>;
1817 let AddedComplexity = 6 in
1818 multiclass LogicalImm<bits<2> opc, string mnemonic, SDNode OpNode> {
1819 def Wri : BaseLogicalImm<opc, GPR32sp, GPR32, logical_imm32, mnemonic,
1820 [(set GPR32sp:$Rd, (OpNode GPR32:$Rn,
1821 logical_imm32:$imm))]> {
1823 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
1825 def Xri : BaseLogicalImm<opc, GPR64sp, GPR64, logical_imm64, mnemonic,
1826 [(set GPR64sp:$Rd, (OpNode GPR64:$Rn,
1827 logical_imm64:$imm))]> {
1832 multiclass LogicalImmS<bits<2> opc, string mnemonic, SDNode OpNode> {
1833 let isCompare = 1, Defs = [NZCV] in {
1834 def Wri : BaseLogicalImm<opc, GPR32, GPR32, logical_imm32, mnemonic,
1835 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_imm32:$imm))]> {
1837 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
1839 def Xri : BaseLogicalImm<opc, GPR64, GPR64, logical_imm64, mnemonic,
1840 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_imm64:$imm))]> {
1843 } // end Defs = [NZCV]
1846 class BaseLogicalRegPseudo<RegisterClass regtype, SDPatternOperator OpNode>
1847 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1848 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
1851 // Split from LogicalImm as not all instructions have both.
1852 multiclass LogicalReg<bits<2> opc, bit N, string mnemonic,
1853 SDPatternOperator OpNode> {
1854 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
1855 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
1857 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
1858 [(set GPR32:$Rd, (OpNode GPR32:$Rn,
1859 logical_shifted_reg32:$Rm))]> {
1862 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
1863 [(set GPR64:$Rd, (OpNode GPR64:$Rn,
1864 logical_shifted_reg64:$Rm))]> {
1868 def : LogicalRegAlias<mnemonic,
1869 !cast<Instruction>(NAME#"Wrs"), GPR32>;
1870 def : LogicalRegAlias<mnemonic,
1871 !cast<Instruction>(NAME#"Xrs"), GPR64>;
1874 // Split from LogicalReg to allow setting NZCV Defs
1875 multiclass LogicalRegS<bits<2> opc, bit N, string mnemonic,
1876 SDPatternOperator OpNode = null_frag> {
1877 let Defs = [NZCV], mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
1878 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
1879 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
1881 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
1882 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_shifted_reg32:$Rm))]> {
1885 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
1886 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_shifted_reg64:$Rm))]> {
1891 def : LogicalRegAlias<mnemonic,
1892 !cast<Instruction>(NAME#"Wrs"), GPR32>;
1893 def : LogicalRegAlias<mnemonic,
1894 !cast<Instruction>(NAME#"Xrs"), GPR64>;
1898 // Conditionally set flags
1902 // 4-bit immediate. Pretty-printed as <cc>
1903 def ccode : Operand<i32> {
1904 let PrintMethod = "printCondCode";
1907 def inv_ccode : Operand<i32> {
1908 let PrintMethod = "printInverseCondCode";
1911 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1912 class BaseCondSetFlagsImm<bit op, RegisterClass regtype, string asm>
1913 : I<(outs), (ins regtype:$Rn, imm0_31:$imm, imm0_15:$nzcv, ccode:$cond),
1914 asm, "\t$Rn, $imm, $nzcv, $cond", "", []>,
1925 let Inst{29-21} = 0b111010010;
1926 let Inst{20-16} = imm;
1927 let Inst{15-12} = cond;
1928 let Inst{11-10} = 0b10;
1931 let Inst{3-0} = nzcv;
1934 multiclass CondSetFlagsImm<bit op, string asm> {
1935 def Wi : BaseCondSetFlagsImm<op, GPR32, asm> {
1938 def Xi : BaseCondSetFlagsImm<op, GPR64, asm> {
1943 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1944 class BaseCondSetFlagsReg<bit op, RegisterClass regtype, string asm>
1945 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm0_15:$nzcv, ccode:$cond),
1946 asm, "\t$Rn, $Rm, $nzcv, $cond", "", []>,
1957 let Inst{29-21} = 0b111010010;
1958 let Inst{20-16} = Rm;
1959 let Inst{15-12} = cond;
1960 let Inst{11-10} = 0b00;
1963 let Inst{3-0} = nzcv;
1966 multiclass CondSetFlagsReg<bit op, string asm> {
1967 def Wr : BaseCondSetFlagsReg<op, GPR32, asm> {
1970 def Xr : BaseCondSetFlagsReg<op, GPR64, asm> {
1976 // Conditional select
1979 class BaseCondSelect<bit op, bits<2> op2, RegisterClass regtype, string asm>
1980 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
1981 asm, "\t$Rd, $Rn, $Rm, $cond", "",
1983 (ARM64csel regtype:$Rn, regtype:$Rm, (i32 imm:$cond), NZCV))]>,
1993 let Inst{29-21} = 0b011010100;
1994 let Inst{20-16} = Rm;
1995 let Inst{15-12} = cond;
1996 let Inst{11-10} = op2;
2001 multiclass CondSelect<bit op, bits<2> op2, string asm> {
2002 def Wr : BaseCondSelect<op, op2, GPR32, asm> {
2005 def Xr : BaseCondSelect<op, op2, GPR64, asm> {
2010 class BaseCondSelectOp<bit op, bits<2> op2, RegisterClass regtype, string asm,
2012 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
2013 asm, "\t$Rd, $Rn, $Rm, $cond", "",
2015 (ARM64csel regtype:$Rn, (frag regtype:$Rm),
2016 (i32 imm:$cond), NZCV))]>,
2026 let Inst{29-21} = 0b011010100;
2027 let Inst{20-16} = Rm;
2028 let Inst{15-12} = cond;
2029 let Inst{11-10} = op2;
2034 def inv_cond_XFORM : SDNodeXForm<imm, [{
2035 ARM64CC::CondCode CC = static_cast<ARM64CC::CondCode>(N->getZExtValue());
2036 return CurDAG->getTargetConstant(ARM64CC::getInvertedCondCode(CC), MVT::i32);
2039 multiclass CondSelectOp<bit op, bits<2> op2, string asm, PatFrag frag> {
2040 def Wr : BaseCondSelectOp<op, op2, GPR32, asm, frag> {
2043 def Xr : BaseCondSelectOp<op, op2, GPR64, asm, frag> {
2047 def : Pat<(ARM64csel (frag GPR32:$Rm), GPR32:$Rn, (i32 imm:$cond), NZCV),
2048 (!cast<Instruction>(NAME # Wr) GPR32:$Rn, GPR32:$Rm,
2049 (inv_cond_XFORM imm:$cond))>;
2051 def : Pat<(ARM64csel (frag GPR64:$Rm), GPR64:$Rn, (i32 imm:$cond), NZCV),
2052 (!cast<Instruction>(NAME # Xr) GPR64:$Rn, GPR64:$Rm,
2053 (inv_cond_XFORM imm:$cond))>;
2057 // Special Mask Value
2059 def maski8_or_more : Operand<i32>,
2060 ImmLeaf<i32, [{ return (Imm & 0xff) == 0xff; }]> {
2062 def maski16_or_more : Operand<i32>,
2063 ImmLeaf<i32, [{ return (Imm & 0xffff) == 0xffff; }]> {
2071 // (unsigned immediate)
2072 // Indexed for 8-bit registers. offset is in range [0,4095].
2073 def MemoryIndexed8Operand : AsmOperandClass {
2074 let Name = "MemoryIndexed8";
2075 let DiagnosticType = "InvalidMemoryIndexed8";
2077 def am_indexed8 : Operand<i64>,
2078 ComplexPattern<i64, 2, "SelectAddrModeIndexed8", []> {
2079 let PrintMethod = "printAMIndexed<8>";
2081 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale1>";
2082 let ParserMatchClass = MemoryIndexed8Operand;
2083 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2086 // Indexed for 16-bit registers. offset is multiple of 2 in range [0,8190],
2087 // stored as immval/2 (the 12-bit literal that encodes directly into the insn).
2088 def MemoryIndexed16Operand : AsmOperandClass {
2089 let Name = "MemoryIndexed16";
2090 let DiagnosticType = "InvalidMemoryIndexed16";
2092 def am_indexed16 : Operand<i64>,
2093 ComplexPattern<i64, 2, "SelectAddrModeIndexed16", []> {
2094 let PrintMethod = "printAMIndexed<16>";
2096 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale2>";
2097 let ParserMatchClass = MemoryIndexed16Operand;
2098 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2101 // Indexed for 32-bit registers. offset is multiple of 4 in range [0,16380],
2102 // stored as immval/4 (the 12-bit literal that encodes directly into the insn).
2103 def MemoryIndexed32Operand : AsmOperandClass {
2104 let Name = "MemoryIndexed32";
2105 let DiagnosticType = "InvalidMemoryIndexed32";
2107 def am_indexed32 : Operand<i64>,
2108 ComplexPattern<i64, 2, "SelectAddrModeIndexed32", []> {
2109 let PrintMethod = "printAMIndexed<32>";
2111 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale4>";
2112 let ParserMatchClass = MemoryIndexed32Operand;
2113 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2116 // Indexed for 64-bit registers. offset is multiple of 8 in range [0,32760],
2117 // stored as immval/8 (the 12-bit literal that encodes directly into the insn).
2118 def MemoryIndexed64Operand : AsmOperandClass {
2119 let Name = "MemoryIndexed64";
2120 let DiagnosticType = "InvalidMemoryIndexed64";
2122 def am_indexed64 : Operand<i64>,
2123 ComplexPattern<i64, 2, "SelectAddrModeIndexed64", []> {
2124 let PrintMethod = "printAMIndexed<64>";
2126 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale8>";
2127 let ParserMatchClass = MemoryIndexed64Operand;
2128 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2131 // Indexed for 128-bit registers. offset is multiple of 16 in range [0,65520],
2132 // stored as immval/16 (the 12-bit literal that encodes directly into the insn).
2133 def MemoryIndexed128Operand : AsmOperandClass {
2134 let Name = "MemoryIndexed128";
2135 let DiagnosticType = "InvalidMemoryIndexed128";
2137 def am_indexed128 : Operand<i64>,
2138 ComplexPattern<i64, 2, "SelectAddrModeIndexed128", []> {
2139 let PrintMethod = "printAMIndexed<128>";
2141 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale16>";
2142 let ParserMatchClass = MemoryIndexed128Operand;
2143 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2147 def MemoryNoIndexOperand : AsmOperandClass { let Name = "MemoryNoIndex"; }
2148 def am_noindex : Operand<i64>,
2149 ComplexPattern<i64, 1, "SelectAddrModeNoIndex", []> {
2150 let PrintMethod = "printAMNoIndex";
2151 let ParserMatchClass = MemoryNoIndexOperand;
2152 let MIOperandInfo = (ops GPR64sp:$base);
2155 class BaseLoadStoreUI<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2156 string asm, list<dag> pattern>
2157 : I<oops, iops, asm, "\t$Rt, $addr", "", pattern> {
2161 bits<5> base = addr{4-0};
2162 bits<12> offset = addr{16-5};
2164 let Inst{31-30} = sz;
2165 let Inst{29-27} = 0b111;
2167 let Inst{25-24} = 0b01;
2168 let Inst{23-22} = opc;
2169 let Inst{21-10} = offset;
2170 let Inst{9-5} = base;
2171 let Inst{4-0} = dst;
2173 let DecoderMethod = "DecodeUnsignedLdStInstruction";
2176 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2177 class LoadUI<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2178 Operand indextype, string asm, list<dag> pattern>
2179 : BaseLoadStoreUI<sz, V, opc,
2180 (outs regtype:$Rt), (ins indextype:$addr), asm, pattern>,
2183 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2184 class StoreUI<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2185 Operand indextype, string asm, list<dag> pattern>
2186 : BaseLoadStoreUI<sz, V, opc,
2187 (outs), (ins regtype:$Rt, indextype:$addr), asm, pattern>,
2190 def PrefetchOperand : AsmOperandClass {
2191 let Name = "Prefetch";
2192 let ParserMethod = "tryParsePrefetch";
2194 def prfop : Operand<i32> {
2195 let PrintMethod = "printPrefetchOp";
2196 let ParserMatchClass = PrefetchOperand;
2199 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2200 class PrefetchUI<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2201 : BaseLoadStoreUI<sz, V, opc,
2202 (outs), (ins prfop:$Rt, am_indexed64:$addr), asm, pat>,
2209 // Load literal address: 19-bit immediate. The low two bits of the target
2210 // offset are implied zero and so are not part of the immediate.
2211 def am_ldrlit : Operand<OtherVT> {
2212 let EncoderMethod = "getLoadLiteralOpValue";
2213 let DecoderMethod = "DecodePCRelLabel19";
2214 let PrintMethod = "printAlignedLabel";
2215 let ParserMatchClass = PCRelLabel19Operand;
2218 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2219 class LoadLiteral<bits<2> opc, bit V, RegisterClass regtype, string asm>
2220 : I<(outs regtype:$Rt), (ins am_ldrlit:$label),
2221 asm, "\t$Rt, $label", "", []>,
2225 let Inst{31-30} = opc;
2226 let Inst{29-27} = 0b011;
2228 let Inst{25-24} = 0b00;
2229 let Inst{23-5} = label;
2233 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2234 class PrefetchLiteral<bits<2> opc, bit V, string asm, list<dag> pat>
2235 : I<(outs), (ins prfop:$Rt, am_ldrlit:$label),
2236 asm, "\t$Rt, $label", "", pat>,
2240 let Inst{31-30} = opc;
2241 let Inst{29-27} = 0b011;
2243 let Inst{25-24} = 0b00;
2244 let Inst{23-5} = label;
2249 // Load/store register offset
2252 class MemROAsmOperand<int sz> : AsmOperandClass {
2253 let Name = "MemoryRegisterOffset"#sz;
2256 def MemROAsmOperand8 : MemROAsmOperand<8>;
2257 def MemROAsmOperand16 : MemROAsmOperand<16>;
2258 def MemROAsmOperand32 : MemROAsmOperand<32>;
2259 def MemROAsmOperand64 : MemROAsmOperand<64>;
2260 def MemROAsmOperand128 : MemROAsmOperand<128>;
2262 class ro_indexed<int sz> : Operand<i64> { // ComplexPattern<...>
2263 let PrintMethod = "printMemoryRegOffset<" # sz # ">";
2264 let MIOperandInfo = (ops GPR64sp:$base, GPR64:$offset, i32imm:$extend);
2267 def ro_indexed8 : ro_indexed<8>, ComplexPattern<i64, 3, "SelectAddrModeRO8", []> {
2268 let ParserMatchClass = MemROAsmOperand8;
2271 def ro_indexed16 : ro_indexed<16>, ComplexPattern<i64, 3, "SelectAddrModeRO16", []> {
2272 let ParserMatchClass = MemROAsmOperand16;
2275 def ro_indexed32 : ro_indexed<32>, ComplexPattern<i64, 3, "SelectAddrModeRO32", []> {
2276 let ParserMatchClass = MemROAsmOperand32;
2279 def ro_indexed64 : ro_indexed<64>, ComplexPattern<i64, 3, "SelectAddrModeRO64", []> {
2280 let ParserMatchClass = MemROAsmOperand64;
2283 def ro_indexed128 : ro_indexed<128>, ComplexPattern<i64, 3, "SelectAddrModeRO128", []> {
2284 let ParserMatchClass = MemROAsmOperand128;
2287 class LoadStore8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2288 string asm, dag ins, dag outs, list<dag> pat>
2289 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2290 // The operands are in order to match the 'addr' MI operands, so we
2291 // don't need an encoder method and by-name matching. Just use the default
2292 // in-order handling. Since we're using by-order, make sure the names
2298 let Inst{31-30} = sz;
2299 let Inst{29-27} = 0b111;
2301 let Inst{25-24} = 0b00;
2302 let Inst{23-22} = opc;
2304 let Inst{20-16} = offset;
2305 let Inst{15-13} = extend{3-1};
2307 let Inst{12} = extend{0};
2308 let Inst{11-10} = 0b10;
2309 let Inst{9-5} = base;
2310 let Inst{4-0} = dst;
2312 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2315 class Load8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2316 string asm, list<dag> pat>
2317 : LoadStore8RO<sz, V, opc, regtype, asm,
2318 (outs regtype:$Rt), (ins ro_indexed8:$addr), pat>,
2319 Sched<[WriteLDIdx, ReadAdrBase]>;
2321 class Store8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2322 string asm, list<dag> pat>
2323 : LoadStore8RO<sz, V, opc, regtype, asm,
2324 (outs), (ins regtype:$Rt, ro_indexed8:$addr), pat>,
2325 Sched<[WriteSTIdx, ReadAdrBase]>;
2327 class LoadStore16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2328 string asm, dag ins, dag outs, list<dag> pat>
2329 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2330 // The operands are in order to match the 'addr' MI operands, so we
2331 // don't need an encoder method and by-name matching. Just use the default
2332 // in-order handling. Since we're using by-order, make sure the names
2338 let Inst{31-30} = sz;
2339 let Inst{29-27} = 0b111;
2341 let Inst{25-24} = 0b00;
2342 let Inst{23-22} = opc;
2344 let Inst{20-16} = offset;
2345 let Inst{15-13} = extend{3-1};
2347 let Inst{12} = extend{0};
2348 let Inst{11-10} = 0b10;
2349 let Inst{9-5} = base;
2350 let Inst{4-0} = dst;
2352 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2355 class Load16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2356 string asm, list<dag> pat>
2357 : LoadStore16RO<sz, V, opc, regtype, asm,
2358 (outs regtype:$Rt), (ins ro_indexed16:$addr), pat>,
2359 Sched<[WriteLDIdx, ReadAdrBase]>;
2361 class Store16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2362 string asm, list<dag> pat>
2363 : LoadStore16RO<sz, V, opc, regtype, asm,
2364 (outs), (ins regtype:$Rt, ro_indexed16:$addr), pat>,
2365 Sched<[WriteSTIdx, ReadAdrBase]>;
2367 class LoadStore32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2368 string asm, dag ins, dag outs, list<dag> pat>
2369 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2370 // The operands are in order to match the 'addr' MI operands, so we
2371 // don't need an encoder method and by-name matching. Just use the default
2372 // in-order handling. Since we're using by-order, make sure the names
2378 let Inst{31-30} = sz;
2379 let Inst{29-27} = 0b111;
2381 let Inst{25-24} = 0b00;
2382 let Inst{23-22} = opc;
2384 let Inst{20-16} = offset;
2385 let Inst{15-13} = extend{3-1};
2387 let Inst{12} = extend{0};
2388 let Inst{11-10} = 0b10;
2389 let Inst{9-5} = base;
2390 let Inst{4-0} = dst;
2392 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2395 class Load32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2396 string asm, list<dag> pat>
2397 : LoadStore32RO<sz, V, opc, regtype, asm,
2398 (outs regtype:$Rt), (ins ro_indexed32:$addr), pat>,
2399 Sched<[WriteLDIdx, ReadAdrBase]>;
2401 class Store32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2402 string asm, list<dag> pat>
2403 : LoadStore32RO<sz, V, opc, regtype, asm,
2404 (outs), (ins regtype:$Rt, ro_indexed32:$addr), pat>,
2405 Sched<[WriteSTIdx, ReadAdrBase]>;
2407 class LoadStore64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2408 string asm, dag ins, dag outs, list<dag> pat>
2409 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2410 // The operands are in order to match the 'addr' MI operands, so we
2411 // don't need an encoder method and by-name matching. Just use the default
2412 // in-order handling. Since we're using by-order, make sure the names
2418 let Inst{31-30} = sz;
2419 let Inst{29-27} = 0b111;
2421 let Inst{25-24} = 0b00;
2422 let Inst{23-22} = opc;
2424 let Inst{20-16} = offset;
2425 let Inst{15-13} = extend{3-1};
2427 let Inst{12} = extend{0};
2428 let Inst{11-10} = 0b10;
2429 let Inst{9-5} = base;
2430 let Inst{4-0} = dst;
2432 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2435 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2436 class Load64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2437 string asm, list<dag> pat>
2438 : LoadStore64RO<sz, V, opc, regtype, asm,
2439 (outs regtype:$Rt), (ins ro_indexed64:$addr), pat>,
2440 Sched<[WriteLDIdx, ReadAdrBase]>;
2442 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2443 class Store64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2444 string asm, list<dag> pat>
2445 : LoadStore64RO<sz, V, opc, regtype, asm,
2446 (outs), (ins regtype:$Rt, ro_indexed64:$addr), pat>,
2447 Sched<[WriteSTIdx, ReadAdrBase]>;
2450 class LoadStore128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2451 string asm, dag ins, dag outs, list<dag> pat>
2452 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2453 // The operands are in order to match the 'addr' MI operands, so we
2454 // don't need an encoder method and by-name matching. Just use the default
2455 // in-order handling. Since we're using by-order, make sure the names
2461 let Inst{31-30} = sz;
2462 let Inst{29-27} = 0b111;
2464 let Inst{25-24} = 0b00;
2465 let Inst{23-22} = opc;
2467 let Inst{20-16} = offset;
2468 let Inst{15-13} = extend{3-1};
2470 let Inst{12} = extend{0};
2471 let Inst{11-10} = 0b10;
2472 let Inst{9-5} = base;
2473 let Inst{4-0} = dst;
2475 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2478 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2479 class Load128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2480 string asm, list<dag> pat>
2481 : LoadStore128RO<sz, V, opc, regtype, asm,
2482 (outs regtype:$Rt), (ins ro_indexed128:$addr), pat>,
2483 Sched<[WriteLDIdx, ReadAdrBase]>;
2485 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2486 class Store128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2487 string asm, list<dag> pat>
2488 : LoadStore128RO<sz, V, opc, regtype, asm,
2489 (outs), (ins regtype:$Rt, ro_indexed128:$addr), pat>,
2490 Sched<[WriteSTIdx, ReadAdrBase]>;
2492 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2493 class PrefetchRO<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2494 : I<(outs), (ins prfop:$Rt, ro_indexed64:$addr), asm,
2495 "\t$Rt, $addr", "", pat>,
2497 // The operands are in order to match the 'addr' MI operands, so we
2498 // don't need an encoder method and by-name matching. Just use the default
2499 // in-order handling. Since we're using by-order, make sure the names
2505 let Inst{31-30} = sz;
2506 let Inst{29-27} = 0b111;
2508 let Inst{25-24} = 0b00;
2509 let Inst{23-22} = opc;
2511 let Inst{20-16} = offset;
2512 let Inst{15-13} = extend{3-1};
2514 let Inst{12} = extend{0};
2515 let Inst{11-10} = 0b10;
2516 let Inst{9-5} = base;
2517 let Inst{4-0} = dst;
2519 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2523 // Load/store unscaled immediate
2526 def MemoryUnscaledOperand : AsmOperandClass {
2527 let Name = "MemoryUnscaled";
2528 let DiagnosticType = "InvalidMemoryIndexedSImm9";
2530 class am_unscaled_operand : Operand<i64> {
2531 let PrintMethod = "printAMIndexed<8>";
2532 let ParserMatchClass = MemoryUnscaledOperand;
2533 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2535 class am_unscaled_wb_operand : Operand<i64> {
2536 let PrintMethod = "printAMIndexedWB<8>";
2537 let ParserMatchClass = MemoryUnscaledOperand;
2538 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2540 def am_unscaled : am_unscaled_operand;
2541 def am_unscaled_wb: am_unscaled_wb_operand;
2542 def am_unscaled8 : am_unscaled_operand,
2543 ComplexPattern<i64, 2, "SelectAddrModeUnscaled8", []>;
2544 def am_unscaled16 : am_unscaled_operand,
2545 ComplexPattern<i64, 2, "SelectAddrModeUnscaled16", []>;
2546 def am_unscaled32 : am_unscaled_operand,
2547 ComplexPattern<i64, 2, "SelectAddrModeUnscaled32", []>;
2548 def am_unscaled64 : am_unscaled_operand,
2549 ComplexPattern<i64, 2, "SelectAddrModeUnscaled64", []>;
2550 def am_unscaled128 : am_unscaled_operand,
2551 ComplexPattern<i64, 2, "SelectAddrModeUnscaled128", []>;
2553 class BaseLoadStoreUnscale<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2554 string asm, list<dag> pattern>
2555 : I<oops, iops, asm, "\t$Rt, $addr", "", pattern> {
2556 // The operands are in order to match the 'addr' MI operands, so we
2557 // don't need an encoder method and by-name matching. Just use the default
2558 // in-order handling. Since we're using by-order, make sure the names
2563 let Inst{31-30} = sz;
2564 let Inst{29-27} = 0b111;
2566 let Inst{25-24} = 0b00;
2567 let Inst{23-22} = opc;
2569 let Inst{20-12} = offset;
2570 let Inst{11-10} = 0b00;
2571 let Inst{9-5} = base;
2572 let Inst{4-0} = dst;
2574 let DecoderMethod = "DecodeSignedLdStInstruction";
2577 let AddedComplexity = 1 in // try this before LoadUI
2578 class LoadUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2579 Operand amtype, string asm, list<dag> pattern>
2580 : BaseLoadStoreUnscale<sz, V, opc, (outs regtype:$Rt),
2581 (ins amtype:$addr), asm, pattern>,
2584 let AddedComplexity = 1 in // try this before StoreUI
2585 class StoreUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2586 Operand amtype, string asm, list<dag> pattern>
2587 : BaseLoadStoreUnscale<sz, V, opc, (outs),
2588 (ins regtype:$Rt, amtype:$addr), asm, pattern>,
2591 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2592 class PrefetchUnscaled<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2593 : BaseLoadStoreUnscale<sz, V, opc, (outs),
2594 (ins prfop:$Rt, am_unscaled:$addr), asm, pat>,
2598 // Load/store unscaled immediate, unprivileged
2601 class BaseLoadStoreUnprivileged<bits<2> sz, bit V, bits<2> opc,
2602 dag oops, dag iops, string asm>
2603 : I<oops, iops, asm, "\t$Rt, $addr", "", []> {
2604 // The operands are in order to match the 'addr' MI operands, so we
2605 // don't need an encoder method and by-name matching. Just use the default
2606 // in-order handling. Since we're using by-order, make sure the names
2611 let Inst{31-30} = sz;
2612 let Inst{29-27} = 0b111;
2614 let Inst{25-24} = 0b00;
2615 let Inst{23-22} = opc;
2617 let Inst{20-12} = offset;
2618 let Inst{11-10} = 0b10;
2619 let Inst{9-5} = base;
2620 let Inst{4-0} = dst;
2622 let DecoderMethod = "DecodeSignedLdStInstruction";
2625 let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in {
2626 class LoadUnprivileged<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2628 : BaseLoadStoreUnprivileged<sz, V, opc,
2629 (outs regtype:$Rt), (ins am_unscaled:$addr), asm>,
2633 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
2634 class StoreUnprivileged<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2636 : BaseLoadStoreUnprivileged<sz, V, opc,
2637 (outs), (ins regtype:$Rt, am_unscaled:$addr), asm>,
2642 // Load/store pre-indexed
2645 class BaseLoadStorePreIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2646 string asm, string cstr>
2647 : I<oops, iops, asm, "\t$Rt, $addr!", cstr, []> {
2648 // The operands are in order to match the 'addr' MI operands, so we
2649 // don't need an encoder method and by-name matching. Just use the default
2650 // in-order handling.
2654 let Inst{31-30} = sz;
2655 let Inst{29-27} = 0b111;
2657 let Inst{25-24} = 0;
2658 let Inst{23-22} = opc;
2660 let Inst{20-12} = offset;
2661 let Inst{11-10} = 0b11;
2662 let Inst{9-5} = base;
2663 let Inst{4-0} = dst;
2665 let DecoderMethod = "DecodeSignedLdStInstruction";
2668 let hasSideEffects = 0 in {
2669 let mayStore = 0, mayLoad = 1 in
2670 // FIXME: Modeling the write-back of these instructions for isel is tricky.
2671 // we need the complex addressing mode for the memory reference, but
2672 // we also need the write-back specified as a tied operand to the
2673 // base register. That combination does not play nicely with
2674 // the asm matcher and friends.
2675 class LoadPreIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2677 : BaseLoadStorePreIdx<sz, V, opc,
2678 (outs regtype:$Rt/*, GPR64sp:$wback*/),
2679 (ins am_unscaled_wb:$addr), asm, ""/*"$addr.base = $wback"*/>,
2680 Sched<[WriteLD, WriteAdr]>;
2682 let mayStore = 1, mayLoad = 0 in
2683 class StorePreIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2685 : BaseLoadStorePreIdx<sz, V, opc,
2686 (outs/* GPR64sp:$wback*/),
2687 (ins regtype:$Rt, am_unscaled_wb:$addr),
2688 asm, ""/*"$addr.base = $wback"*/>,
2689 Sched<[WriteAdr, WriteST]>;
2690 } // hasSideEffects = 0
2692 // ISel pseudo-instructions which have the tied operands. When the MC lowering
2693 // logic finally gets smart enough to strip off tied operands that are just
2694 // for isel convenience, we can get rid of these pseudos and just reference
2695 // the real instructions directly.
2697 // Ironically, also because of the writeback operands, we can't put the
2698 // matcher pattern directly on the instruction, but need to define it
2701 // Loads aren't matched with patterns here at all, but rather in C++
2703 let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in {
2704 class LoadPreIdxPseudo<RegisterClass regtype>
2705 : Pseudo<(outs regtype:$Rt, GPR64sp:$wback),
2706 (ins am_noindex:$addr, simm9:$offset), [],
2707 "$addr.base = $wback,@earlyclobber $wback">,
2708 Sched<[WriteLD, WriteAdr]>;
2709 class LoadPostIdxPseudo<RegisterClass regtype>
2710 : Pseudo<(outs regtype:$Rt, GPR64sp:$wback),
2711 (ins am_noindex:$addr, simm9:$offset), [],
2712 "$addr.base = $wback,@earlyclobber $wback">,
2713 Sched<[WriteLD, WriteI]>;
2715 multiclass StorePreIdxPseudo<RegisterClass regtype, ValueType Ty,
2716 SDPatternOperator OpNode> {
2717 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
2718 def _isel: Pseudo<(outs GPR64sp:$wback),
2719 (ins regtype:$Rt, am_noindex:$addr, simm9:$offset), [],
2720 "$addr.base = $wback,@earlyclobber $wback">,
2721 Sched<[WriteAdr, WriteST]>;
2723 def : Pat<(OpNode (Ty regtype:$Rt), am_noindex:$addr, simm9:$offset),
2724 (!cast<Instruction>(NAME#_isel) regtype:$Rt, am_noindex:$addr,
2729 // Load/store post-indexed
2732 // (pre-index) load/stores.
2733 class BaseLoadStorePostIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2734 string asm, string cstr>
2735 : I<oops, iops, asm, "\t$Rt, $addr, $idx", cstr, []> {
2736 // The operands are in order to match the 'addr' MI operands, so we
2737 // don't need an encoder method and by-name matching. Just use the default
2738 // in-order handling.
2742 let Inst{31-30} = sz;
2743 let Inst{29-27} = 0b111;
2745 let Inst{25-24} = 0b00;
2746 let Inst{23-22} = opc;
2748 let Inst{20-12} = offset;
2749 let Inst{11-10} = 0b01;
2750 let Inst{9-5} = base;
2751 let Inst{4-0} = dst;
2753 let DecoderMethod = "DecodeSignedLdStInstruction";
2756 let hasSideEffects = 0 in {
2757 let mayStore = 0, mayLoad = 1 in
2758 // FIXME: Modeling the write-back of these instructions for isel is tricky.
2759 // we need the complex addressing mode for the memory reference, but
2760 // we also need the write-back specified as a tied operand to the
2761 // base register. That combination does not play nicely with
2762 // the asm matcher and friends.
2763 class LoadPostIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2765 : BaseLoadStorePostIdx<sz, V, opc,
2766 (outs regtype:$Rt/*, GPR64sp:$wback*/),
2767 (ins am_noindex:$addr, simm9:$idx),
2768 asm, ""/*"$addr.base = $wback"*/>,
2769 Sched<[WriteLD, WriteI]>;
2771 let mayStore = 1, mayLoad = 0 in
2772 class StorePostIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2774 : BaseLoadStorePostIdx<sz, V, opc,
2775 (outs/* GPR64sp:$wback*/),
2776 (ins regtype:$Rt, am_noindex:$addr, simm9:$idx),
2777 asm, ""/*"$addr.base = $wback"*/>,
2778 Sched<[WriteAdr, WriteST, ReadAdrBase]>;
2779 } // hasSideEffects = 0
2781 // ISel pseudo-instructions which have the tied operands. When the MC lowering
2782 // logic finally gets smart enough to strip off tied operands that are just
2783 // for isel convenience, we can get rid of these pseudos and just reference
2784 // the real instructions directly.
2786 // Ironically, also because of the writeback operands, we can't put the
2787 // matcher pattern directly on the instruction, but need to define it
2789 multiclass StorePostIdxPseudo<RegisterClass regtype, ValueType Ty,
2790 SDPatternOperator OpNode, Instruction Insn> {
2791 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
2792 def _isel: Pseudo<(outs GPR64sp:$wback),
2793 (ins regtype:$Rt, am_noindex:$addr, simm9:$idx), [],
2794 "$addr.base = $wback,@earlyclobber $wback">,
2795 PseudoInstExpansion<(Insn regtype:$Rt, am_noindex:$addr, simm9:$idx)>,
2796 Sched<[WriteAdr, WriteST, ReadAdrBase]>;
2798 def : Pat<(OpNode (Ty regtype:$Rt), am_noindex:$addr, simm9:$idx),
2799 (!cast<Instruction>(NAME#_isel) regtype:$Rt, am_noindex:$addr,
2807 // (indexed, offset)
2809 class BaseLoadStorePairOffset<bits<2> opc, bit V, bit L, dag oops, dag iops,
2811 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr", "", []> {
2812 // The operands are in order to match the 'addr' MI operands, so we
2813 // don't need an encoder method and by-name matching. Just use the default
2814 // in-order handling. Since we're using by-order, make sure the names
2820 let Inst{31-30} = opc;
2821 let Inst{29-27} = 0b101;
2823 let Inst{25-23} = 0b010;
2825 let Inst{21-15} = offset;
2826 let Inst{14-10} = dst2;
2827 let Inst{9-5} = base;
2828 let Inst{4-0} = dst;
2830 let DecoderMethod = "DecodePairLdStInstruction";
2833 let hasSideEffects = 0 in {
2834 let mayStore = 0, mayLoad = 1 in
2835 class LoadPairOffset<bits<2> opc, bit V, RegisterClass regtype,
2836 Operand indextype, string asm>
2837 : BaseLoadStorePairOffset<opc, V, 1,
2838 (outs regtype:$Rt, regtype:$Rt2),
2839 (ins indextype:$addr), asm>,
2840 Sched<[WriteLD, WriteLDHi]>;
2842 let mayLoad = 0, mayStore = 1 in
2843 class StorePairOffset<bits<2> opc, bit V, RegisterClass regtype,
2844 Operand indextype, string asm>
2845 : BaseLoadStorePairOffset<opc, V, 0, (outs),
2846 (ins regtype:$Rt, regtype:$Rt2, indextype:$addr),
2849 } // hasSideEffects = 0
2853 def MemoryIndexed32SImm7 : AsmOperandClass {
2854 let Name = "MemoryIndexed32SImm7";
2855 let DiagnosticType = "InvalidMemoryIndexed32SImm7";
2857 def am_indexed32simm7 : Operand<i32> { // ComplexPattern<...>
2858 let PrintMethod = "printAMIndexed<32>";
2859 let ParserMatchClass = MemoryIndexed32SImm7;
2860 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2862 def am_indexed32simm7_wb : Operand<i32> { // ComplexPattern<...>
2863 let PrintMethod = "printAMIndexedWB<32>";
2864 let ParserMatchClass = MemoryIndexed32SImm7;
2865 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2868 def MemoryIndexed64SImm7 : AsmOperandClass {
2869 let Name = "MemoryIndexed64SImm7";
2870 let DiagnosticType = "InvalidMemoryIndexed64SImm7";
2872 def am_indexed64simm7 : Operand<i32> { // ComplexPattern<...>
2873 let PrintMethod = "printAMIndexed<64>";
2874 let ParserMatchClass = MemoryIndexed64SImm7;
2875 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2877 def am_indexed64simm7_wb : Operand<i32> { // ComplexPattern<...>
2878 let PrintMethod = "printAMIndexedWB<64>";
2879 let ParserMatchClass = MemoryIndexed64SImm7;
2880 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2883 def MemoryIndexed128SImm7 : AsmOperandClass {
2884 let Name = "MemoryIndexed128SImm7";
2885 let DiagnosticType = "InvalidMemoryIndexed128SImm7";
2887 def am_indexed128simm7 : Operand<i32> { // ComplexPattern<...>
2888 let PrintMethod = "printAMIndexed<128>";
2889 let ParserMatchClass = MemoryIndexed128SImm7;
2890 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2892 def am_indexed128simm7_wb : Operand<i32> { // ComplexPattern<...>
2893 let PrintMethod = "printAMIndexedWB<128>";
2894 let ParserMatchClass = MemoryIndexed128SImm7;
2895 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2898 class BaseLoadStorePairPreIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
2900 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr!", "", []> {
2901 // The operands are in order to match the 'addr' MI operands, so we
2902 // don't need an encoder method and by-name matching. Just use the default
2903 // in-order handling. Since we're using by-order, make sure the names
2909 let Inst{31-30} = opc;
2910 let Inst{29-27} = 0b101;
2912 let Inst{25-23} = 0b011;
2914 let Inst{21-15} = offset;
2915 let Inst{14-10} = dst2;
2916 let Inst{9-5} = base;
2917 let Inst{4-0} = dst;
2919 let DecoderMethod = "DecodePairLdStInstruction";
2922 let hasSideEffects = 0 in {
2923 let mayStore = 0, mayLoad = 1 in
2924 class LoadPairPreIdx<bits<2> opc, bit V, RegisterClass regtype,
2925 Operand addrmode, string asm>
2926 : BaseLoadStorePairPreIdx<opc, V, 1,
2927 (outs regtype:$Rt, regtype:$Rt2),
2928 (ins addrmode:$addr), asm>,
2929 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
2931 let mayStore = 1, mayLoad = 0 in
2932 class StorePairPreIdx<bits<2> opc, bit V, RegisterClass regtype,
2933 Operand addrmode, string asm>
2934 : BaseLoadStorePairPreIdx<opc, V, 0, (outs),
2935 (ins regtype:$Rt, regtype:$Rt2, addrmode:$addr),
2937 Sched<[WriteAdr, WriteSTP]>;
2938 } // hasSideEffects = 0
2942 class BaseLoadStorePairPostIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
2944 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr, $idx", "", []> {
2945 // The operands are in order to match the 'addr' MI operands, so we
2946 // don't need an encoder method and by-name matching. Just use the default
2947 // in-order handling. Since we're using by-order, make sure the names
2953 let Inst{31-30} = opc;
2954 let Inst{29-27} = 0b101;
2956 let Inst{25-23} = 0b001;
2958 let Inst{21-15} = offset;
2959 let Inst{14-10} = dst2;
2960 let Inst{9-5} = base;
2961 let Inst{4-0} = dst;
2963 let DecoderMethod = "DecodePairLdStInstruction";
2966 let hasSideEffects = 0 in {
2967 let mayStore = 0, mayLoad = 1 in
2968 class LoadPairPostIdx<bits<2> opc, bit V, RegisterClass regtype,
2969 Operand idxtype, string asm>
2970 : BaseLoadStorePairPostIdx<opc, V, 1,
2971 (outs regtype:$Rt, regtype:$Rt2),
2972 (ins am_noindex:$addr, idxtype:$idx), asm>,
2973 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
2975 let mayStore = 1, mayLoad = 0 in
2976 class StorePairPostIdx<bits<2> opc, bit V, RegisterClass regtype,
2977 Operand idxtype, string asm>
2978 : BaseLoadStorePairPostIdx<opc, V, 0, (outs),
2979 (ins regtype:$Rt, regtype:$Rt2,
2980 am_noindex:$addr, idxtype:$idx),
2982 Sched<[WriteAdr, WriteSTP]>;
2983 } // hasSideEffects = 0
2987 class BaseLoadStorePairNoAlloc<bits<2> opc, bit V, bit L, dag oops, dag iops,
2989 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr", "", []> {
2990 // The operands are in order to match the 'addr' MI operands, so we
2991 // don't need an encoder method and by-name matching. Just use the default
2992 // in-order handling. Since we're using by-order, make sure the names
2998 let Inst{31-30} = opc;
2999 let Inst{29-27} = 0b101;
3001 let Inst{25-23} = 0b000;
3003 let Inst{21-15} = offset;
3004 let Inst{14-10} = dst2;
3005 let Inst{9-5} = base;
3006 let Inst{4-0} = dst;
3008 let DecoderMethod = "DecodePairLdStInstruction";
3011 let hasSideEffects = 0 in {
3012 let mayStore = 0, mayLoad = 1 in
3013 class LoadPairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3014 Operand indextype, string asm>
3015 : BaseLoadStorePairNoAlloc<opc, V, 1,
3016 (outs regtype:$Rt, regtype:$Rt2),
3017 (ins indextype:$addr), asm>,
3018 Sched<[WriteLD, WriteLDHi]>;
3020 let mayStore = 1, mayLoad = 0 in
3021 class StorePairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3022 Operand indextype, string asm>
3023 : BaseLoadStorePairNoAlloc<opc, V, 0, (outs),
3024 (ins regtype:$Rt, regtype:$Rt2, indextype:$addr),
3027 } // hasSideEffects = 0
3030 // Load/store exclusive
3033 // True exclusive operations write to and/or read from the system's exclusive
3034 // monitors, which as far as a compiler is concerned can be modelled as a
3035 // random shared memory address. Hence LoadExclusive mayStore.
3037 // Since these instructions have the undefined register bits set to 1 in
3038 // their canonical form, we need a post encoder method to set those bits
3039 // to 1 when encoding these instructions. We do this using the
3040 // fixLoadStoreExclusive function. This function has template parameters:
3042 // fixLoadStoreExclusive<int hasRs, int hasRt2>
3044 // hasRs indicates that the instruction uses the Rs field, so we won't set
3045 // it to 1 (and the same for Rt2). We don't need template parameters for
3046 // the other register fields since Rt and Rn are always used.
3048 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
3049 class BaseLoadStoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3050 dag oops, dag iops, string asm, string operands>
3051 : I<oops, iops, asm, operands, "", []> {
3052 let Inst{31-30} = sz;
3053 let Inst{29-24} = 0b001000;
3059 let DecoderMethod = "DecodeExclusiveLdStInstruction";
3062 // Neither Rs nor Rt2 operands.
3063 class LoadStoreExclusiveSimple<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3064 dag oops, dag iops, string asm, string operands>
3065 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, oops, iops, asm, operands> {
3068 let Inst{9-5} = base;
3069 let Inst{4-0} = reg;
3071 let PostEncoderMethod = "fixLoadStoreExclusive<0,0>";
3074 // Simple load acquires don't set the exclusive monitor
3075 let mayLoad = 1, mayStore = 0 in
3076 class LoadAcquire<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3077 RegisterClass regtype, string asm>
3078 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
3079 (ins am_noindex:$addr), asm, "\t$Rt, $addr">,
3082 class LoadExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3083 RegisterClass regtype, string asm>
3084 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
3085 (ins am_noindex:$addr), asm, "\t$Rt, $addr">,
3088 class LoadExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3089 RegisterClass regtype, string asm>
3090 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
3091 (outs regtype:$Rt, regtype:$Rt2),
3092 (ins am_noindex:$addr), asm,
3093 "\t$Rt, $Rt2, $addr">,
3094 Sched<[WriteLD, WriteLDHi]> {
3098 let Inst{14-10} = dst2;
3099 let Inst{9-5} = base;
3100 let Inst{4-0} = dst1;
3102 let PostEncoderMethod = "fixLoadStoreExclusive<0,1>";
3105 // Simple store release operations do not check the exclusive monitor.
3106 let mayLoad = 0, mayStore = 1 in
3107 class StoreRelease<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3108 RegisterClass regtype, string asm>
3109 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs),
3110 (ins regtype:$Rt, am_noindex:$addr),
3111 asm, "\t$Rt, $addr">,
3114 let mayLoad = 1, mayStore = 1 in
3115 class StoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3116 RegisterClass regtype, string asm>
3117 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, (outs GPR32:$Ws),
3118 (ins regtype:$Rt, am_noindex:$addr),
3119 asm, "\t$Ws, $Rt, $addr">,
3124 let Inst{20-16} = status;
3125 let Inst{9-5} = base;
3126 let Inst{4-0} = reg;
3128 let Constraints = "@earlyclobber $Ws";
3129 let PostEncoderMethod = "fixLoadStoreExclusive<1,0>";
3132 class StoreExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3133 RegisterClass regtype, string asm>
3134 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
3136 (ins regtype:$Rt, regtype:$Rt2, am_noindex:$addr),
3137 asm, "\t$Ws, $Rt, $Rt2, $addr">,
3143 let Inst{20-16} = status;
3144 let Inst{14-10} = dst2;
3145 let Inst{9-5} = base;
3146 let Inst{4-0} = dst1;
3148 let Constraints = "@earlyclobber $Ws";
3152 // Exception generation
3155 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
3156 class ExceptionGeneration<bits<3> op1, bits<2> ll, string asm>
3157 : I<(outs), (ins imm0_65535:$imm), asm, "\t$imm", "", []>,
3160 let Inst{31-24} = 0b11010100;
3161 let Inst{23-21} = op1;
3162 let Inst{20-5} = imm;
3163 let Inst{4-2} = 0b000;
3167 let Predicates = [HasFPARMv8] in {
3170 // Floating point to integer conversion
3173 class BaseFPToIntegerUnscaled<bits<2> type, bits<2> rmode, bits<3> opcode,
3174 RegisterClass srcType, RegisterClass dstType,
3175 string asm, list<dag> pattern>
3176 : I<(outs dstType:$Rd), (ins srcType:$Rn),
3177 asm, "\t$Rd, $Rn", "", pattern>,
3178 Sched<[WriteFCvt]> {
3181 let Inst{30-29} = 0b00;
3182 let Inst{28-24} = 0b11110;
3183 let Inst{23-22} = type;
3185 let Inst{20-19} = rmode;
3186 let Inst{18-16} = opcode;
3187 let Inst{15-10} = 0;
3192 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3193 class BaseFPToInteger<bits<2> type, bits<2> rmode, bits<3> opcode,
3194 RegisterClass srcType, RegisterClass dstType,
3195 Operand immType, string asm, list<dag> pattern>
3196 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
3197 asm, "\t$Rd, $Rn, $scale", "", pattern>,
3198 Sched<[WriteFCvt]> {
3202 let Inst{30-29} = 0b00;
3203 let Inst{28-24} = 0b11110;
3204 let Inst{23-22} = type;
3206 let Inst{20-19} = rmode;
3207 let Inst{18-16} = opcode;
3208 let Inst{15-10} = scale;
3213 multiclass FPToIntegerUnscaled<bits<2> rmode, bits<3> opcode, string asm,
3214 SDPatternOperator OpN> {
3215 // Unscaled single-precision to 32-bit
3216 def UWSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR32, asm,
3217 [(set GPR32:$Rd, (OpN FPR32:$Rn))]> {
3218 let Inst{31} = 0; // 32-bit GPR flag
3221 // Unscaled single-precision to 64-bit
3222 def UXSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR64, asm,
3223 [(set GPR64:$Rd, (OpN FPR32:$Rn))]> {
3224 let Inst{31} = 1; // 64-bit GPR flag
3227 // Unscaled double-precision to 32-bit
3228 def UWDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR32, asm,
3229 [(set GPR32:$Rd, (OpN (f64 FPR64:$Rn)))]> {
3230 let Inst{31} = 0; // 32-bit GPR flag
3233 // Unscaled double-precision to 64-bit
3234 def UXDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR64, asm,
3235 [(set GPR64:$Rd, (OpN (f64 FPR64:$Rn)))]> {
3236 let Inst{31} = 1; // 64-bit GPR flag
3240 multiclass FPToIntegerScaled<bits<2> rmode, bits<3> opcode, string asm,
3241 SDPatternOperator OpN> {
3242 // Scaled single-precision to 32-bit
3243 def SWSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR32,
3244 fixedpoint_f32_i32, asm,
3245 [(set GPR32:$Rd, (OpN (fmul FPR32:$Rn,
3246 fixedpoint_f32_i32:$scale)))]> {
3247 let Inst{31} = 0; // 32-bit GPR flag
3251 // Scaled single-precision to 64-bit
3252 def SXSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR64,
3253 fixedpoint_f32_i64, asm,
3254 [(set GPR64:$Rd, (OpN (fmul FPR32:$Rn,
3255 fixedpoint_f32_i64:$scale)))]> {
3256 let Inst{31} = 1; // 64-bit GPR flag
3259 // Scaled double-precision to 32-bit
3260 def SWDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR32,
3261 fixedpoint_f64_i32, asm,
3262 [(set GPR32:$Rd, (OpN (fmul FPR64:$Rn,
3263 fixedpoint_f64_i32:$scale)))]> {
3264 let Inst{31} = 0; // 32-bit GPR flag
3268 // Scaled double-precision to 64-bit
3269 def SXDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR64,
3270 fixedpoint_f64_i64, asm,
3271 [(set GPR64:$Rd, (OpN (fmul FPR64:$Rn,
3272 fixedpoint_f64_i64:$scale)))]> {
3273 let Inst{31} = 1; // 64-bit GPR flag
3278 // Integer to floating point conversion
3281 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
3282 class BaseIntegerToFP<bit isUnsigned,
3283 RegisterClass srcType, RegisterClass dstType,
3284 Operand immType, string asm, list<dag> pattern>
3285 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
3286 asm, "\t$Rd, $Rn, $scale", "", pattern>,
3287 Sched<[WriteFCvt]> {
3291 let Inst{30-23} = 0b00111100;
3292 let Inst{21-17} = 0b00001;
3293 let Inst{16} = isUnsigned;
3294 let Inst{15-10} = scale;
3299 class BaseIntegerToFPUnscaled<bit isUnsigned,
3300 RegisterClass srcType, RegisterClass dstType,
3301 ValueType dvt, string asm, SDNode node>
3302 : I<(outs dstType:$Rd), (ins srcType:$Rn),
3303 asm, "\t$Rd, $Rn", "", [(set (dvt dstType:$Rd), (node srcType:$Rn))]>,
3304 Sched<[WriteFCvt]> {
3308 let Inst{30-23} = 0b00111100;
3309 let Inst{21-17} = 0b10001;
3310 let Inst{16} = isUnsigned;
3311 let Inst{15-10} = 0b000000;
3316 multiclass IntegerToFP<bit isUnsigned, string asm, SDNode node> {
3318 def UWSri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR32, f32, asm, node> {
3319 let Inst{31} = 0; // 32-bit GPR flag
3320 let Inst{22} = 0; // 32-bit FPR flag
3323 def UWDri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR64, f64, asm, node> {
3324 let Inst{31} = 0; // 32-bit GPR flag
3325 let Inst{22} = 1; // 64-bit FPR flag
3328 def UXSri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR32, f32, asm, node> {
3329 let Inst{31} = 1; // 64-bit GPR flag
3330 let Inst{22} = 0; // 32-bit FPR flag
3333 def UXDri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR64, f64, asm, node> {
3334 let Inst{31} = 1; // 64-bit GPR flag
3335 let Inst{22} = 1; // 64-bit FPR flag
3339 def SWSri: BaseIntegerToFP<isUnsigned, GPR32, FPR32, fixedpoint_f32_i32, asm,
3341 (fdiv (node GPR32:$Rn),
3342 fixedpoint_f32_i32:$scale))]> {
3343 let Inst{31} = 0; // 32-bit GPR flag
3344 let Inst{22} = 0; // 32-bit FPR flag
3348 def SWDri: BaseIntegerToFP<isUnsigned, GPR32, FPR64, fixedpoint_f64_i32, asm,
3350 (fdiv (node GPR32:$Rn),
3351 fixedpoint_f64_i32:$scale))]> {
3352 let Inst{31} = 0; // 32-bit GPR flag
3353 let Inst{22} = 1; // 64-bit FPR flag
3357 def SXSri: BaseIntegerToFP<isUnsigned, GPR64, FPR32, fixedpoint_f32_i64, asm,
3359 (fdiv (node GPR64:$Rn),
3360 fixedpoint_f32_i64:$scale))]> {
3361 let Inst{31} = 1; // 64-bit GPR flag
3362 let Inst{22} = 0; // 32-bit FPR flag
3365 def SXDri: BaseIntegerToFP<isUnsigned, GPR64, FPR64, fixedpoint_f64_i64, asm,
3367 (fdiv (node GPR64:$Rn),
3368 fixedpoint_f64_i64:$scale))]> {
3369 let Inst{31} = 1; // 64-bit GPR flag
3370 let Inst{22} = 1; // 64-bit FPR flag
3375 // Unscaled integer <-> floating point conversion (i.e. FMOV)
3378 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3379 class BaseUnscaledConversion<bits<2> rmode, bits<3> opcode,
3380 RegisterClass srcType, RegisterClass dstType,
3382 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "",
3383 // We use COPY_TO_REGCLASS for these bitconvert operations.
3384 // copyPhysReg() expands the resultant COPY instructions after
3385 // regalloc is done. This gives greater freedom for the allocator
3386 // and related passes (coalescing, copy propagation, et. al.) to
3387 // be more effective.
3388 [/*(set (dvt dstType:$Rd), (bitconvert (svt srcType:$Rn)))*/]>,
3389 Sched<[WriteFCopy]> {
3392 let Inst{30-23} = 0b00111100;
3394 let Inst{20-19} = rmode;
3395 let Inst{18-16} = opcode;
3396 let Inst{15-10} = 0b000000;
3401 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3402 class BaseUnscaledConversionToHigh<bits<2> rmode, bits<3> opcode,
3403 RegisterClass srcType, RegisterOperand dstType, string asm,
3405 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm,
3406 "{\t$Rd"#kind#"[1], $Rn|"#kind#"\t$Rd[1], $Rn}", "", []>,
3407 Sched<[WriteFCopy]> {
3410 let Inst{30-23} = 0b00111101;
3412 let Inst{20-19} = rmode;
3413 let Inst{18-16} = opcode;
3414 let Inst{15-10} = 0b000000;
3419 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3420 class BaseUnscaledConversionFromHigh<bits<2> rmode, bits<3> opcode,
3421 RegisterOperand srcType, RegisterClass dstType, string asm,
3423 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm,
3424 "{\t$Rd, $Rn"#kind#"[1]|"#kind#"\t$Rd, $Rn[1]}", "", []>,
3425 Sched<[WriteFCopy]> {
3428 let Inst{30-23} = 0b00111101;
3430 let Inst{20-19} = rmode;
3431 let Inst{18-16} = opcode;
3432 let Inst{15-10} = 0b000000;
3439 multiclass UnscaledConversion<string asm> {
3440 def WSr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR32, asm> {
3441 let Inst{31} = 0; // 32-bit GPR flag
3442 let Inst{22} = 0; // 32-bit FPR flag
3445 def XDr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR64, asm> {
3446 let Inst{31} = 1; // 64-bit GPR flag
3447 let Inst{22} = 1; // 64-bit FPR flag
3450 def SWr : BaseUnscaledConversion<0b00, 0b110, FPR32, GPR32, asm> {
3451 let Inst{31} = 0; // 32-bit GPR flag
3452 let Inst{22} = 0; // 32-bit FPR flag
3455 def DXr : BaseUnscaledConversion<0b00, 0b110, FPR64, GPR64, asm> {
3456 let Inst{31} = 1; // 64-bit GPR flag
3457 let Inst{22} = 1; // 64-bit FPR flag
3460 def XDHighr : BaseUnscaledConversionToHigh<0b01, 0b111, GPR64, V128,
3466 def DXHighr : BaseUnscaledConversionFromHigh<0b01, 0b110, V128, GPR64,
3474 // Floating point conversion
3477 class BaseFPConversion<bits<2> type, bits<2> opcode, RegisterClass dstType,
3478 RegisterClass srcType, string asm, list<dag> pattern>
3479 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", pattern>,
3480 Sched<[WriteFCvt]> {
3483 let Inst{31-24} = 0b00011110;
3484 let Inst{23-22} = type;
3485 let Inst{21-17} = 0b10001;
3486 let Inst{16-15} = opcode;
3487 let Inst{14-10} = 0b10000;
3492 multiclass FPConversion<string asm> {
3493 // Double-precision to Half-precision
3494 def HDr : BaseFPConversion<0b01, 0b11, FPR16, FPR64, asm,
3495 [(set FPR16:$Rd, (fround FPR64:$Rn))]>;
3497 // Double-precision to Single-precision
3498 def SDr : BaseFPConversion<0b01, 0b00, FPR32, FPR64, asm,
3499 [(set FPR32:$Rd, (fround FPR64:$Rn))]>;
3501 // Half-precision to Double-precision
3502 def DHr : BaseFPConversion<0b11, 0b01, FPR64, FPR16, asm,
3503 [(set FPR64:$Rd, (fextend FPR16:$Rn))]>;
3505 // Half-precision to Single-precision
3506 def SHr : BaseFPConversion<0b11, 0b00, FPR32, FPR16, asm,
3507 [(set FPR32:$Rd, (fextend FPR16:$Rn))]>;
3509 // Single-precision to Double-precision
3510 def DSr : BaseFPConversion<0b00, 0b01, FPR64, FPR32, asm,
3511 [(set FPR64:$Rd, (fextend FPR32:$Rn))]>;
3513 // Single-precision to Half-precision
3514 def HSr : BaseFPConversion<0b00, 0b11, FPR16, FPR32, asm,
3515 [(set FPR16:$Rd, (fround FPR32:$Rn))]>;
3519 // Single operand floating point data processing
3522 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3523 class BaseSingleOperandFPData<bits<4> opcode, RegisterClass regtype,
3524 ValueType vt, string asm, SDPatternOperator node>
3525 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
3526 [(set (vt regtype:$Rd), (node (vt regtype:$Rn)))]>,
3530 let Inst{31-23} = 0b000111100;
3531 let Inst{21-19} = 0b100;
3532 let Inst{18-15} = opcode;
3533 let Inst{14-10} = 0b10000;
3538 multiclass SingleOperandFPData<bits<4> opcode, string asm,
3539 SDPatternOperator node = null_frag> {
3540 def Sr : BaseSingleOperandFPData<opcode, FPR32, f32, asm, node> {
3541 let Inst{22} = 0; // 32-bit size flag
3544 def Dr : BaseSingleOperandFPData<opcode, FPR64, f64, asm, node> {
3545 let Inst{22} = 1; // 64-bit size flag
3550 // Two operand floating point data processing
3553 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3554 class BaseTwoOperandFPData<bits<4> opcode, RegisterClass regtype,
3555 string asm, list<dag> pat>
3556 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
3557 asm, "\t$Rd, $Rn, $Rm", "", pat>,
3562 let Inst{31-23} = 0b000111100;
3564 let Inst{20-16} = Rm;
3565 let Inst{15-12} = opcode;
3566 let Inst{11-10} = 0b10;
3571 multiclass TwoOperandFPData<bits<4> opcode, string asm,
3572 SDPatternOperator node = null_frag> {
3573 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
3574 [(set (f32 FPR32:$Rd),
3575 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]> {
3576 let Inst{22} = 0; // 32-bit size flag
3579 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
3580 [(set (f64 FPR64:$Rd),
3581 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]> {
3582 let Inst{22} = 1; // 64-bit size flag
3586 multiclass TwoOperandFPDataNeg<bits<4> opcode, string asm, SDNode node> {
3587 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
3588 [(set FPR32:$Rd, (fneg (node FPR32:$Rn, (f32 FPR32:$Rm))))]> {
3589 let Inst{22} = 0; // 32-bit size flag
3592 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
3593 [(set FPR64:$Rd, (fneg (node FPR64:$Rn, (f64 FPR64:$Rm))))]> {
3594 let Inst{22} = 1; // 64-bit size flag
3600 // Three operand floating point data processing
3603 class BaseThreeOperandFPData<bit isNegated, bit isSub,
3604 RegisterClass regtype, string asm, list<dag> pat>
3605 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, regtype: $Ra),
3606 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pat>,
3607 Sched<[WriteFMul]> {
3612 let Inst{31-23} = 0b000111110;
3613 let Inst{21} = isNegated;
3614 let Inst{20-16} = Rm;
3615 let Inst{15} = isSub;
3616 let Inst{14-10} = Ra;
3621 multiclass ThreeOperandFPData<bit isNegated, bit isSub,string asm,
3622 SDPatternOperator node> {
3623 def Srrr : BaseThreeOperandFPData<isNegated, isSub, FPR32, asm,
3625 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm), (f32 FPR32:$Ra)))]> {
3626 let Inst{22} = 0; // 32-bit size flag
3629 def Drrr : BaseThreeOperandFPData<isNegated, isSub, FPR64, asm,
3631 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm), (f64 FPR64:$Ra)))]> {
3632 let Inst{22} = 1; // 64-bit size flag
3637 // Floating point data comparisons
3640 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3641 class BaseOneOperandFPComparison<bit signalAllNans,
3642 RegisterClass regtype, string asm,
3644 : I<(outs), (ins regtype:$Rn), asm, "\t$Rn, #0.0", "", pat>,
3645 Sched<[WriteFCmp]> {
3647 let Inst{31-23} = 0b000111100;
3650 let Inst{15-10} = 0b001000;
3652 let Inst{4} = signalAllNans;
3653 let Inst{3-0} = 0b1000;
3655 // Rm should be 0b00000 canonically, but we need to accept any value.
3656 let PostEncoderMethod = "fixOneOperandFPComparison";
3659 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3660 class BaseTwoOperandFPComparison<bit signalAllNans, RegisterClass regtype,
3661 string asm, list<dag> pat>
3662 : I<(outs), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rn, $Rm", "", pat>,
3663 Sched<[WriteFCmp]> {
3666 let Inst{31-23} = 0b000111100;
3668 let Inst{20-16} = Rm;
3669 let Inst{15-10} = 0b001000;
3671 let Inst{4} = signalAllNans;
3672 let Inst{3-0} = 0b0000;
3675 multiclass FPComparison<bit signalAllNans, string asm,
3676 SDPatternOperator OpNode = null_frag> {
3677 let Defs = [NZCV] in {
3678 def Srr : BaseTwoOperandFPComparison<signalAllNans, FPR32, asm,
3679 [(OpNode FPR32:$Rn, (f32 FPR32:$Rm)), (implicit NZCV)]> {
3683 def Sri : BaseOneOperandFPComparison<signalAllNans, FPR32, asm,
3684 [(OpNode (f32 FPR32:$Rn), fpimm0), (implicit NZCV)]> {
3688 def Drr : BaseTwoOperandFPComparison<signalAllNans, FPR64, asm,
3689 [(OpNode FPR64:$Rn, (f64 FPR64:$Rm)), (implicit NZCV)]> {
3693 def Dri : BaseOneOperandFPComparison<signalAllNans, FPR64, asm,
3694 [(OpNode (f64 FPR64:$Rn), fpimm0), (implicit NZCV)]> {
3701 // Floating point conditional comparisons
3704 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3705 class BaseFPCondComparison<bit signalAllNans,
3706 RegisterClass regtype, string asm>
3707 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm0_15:$nzcv, ccode:$cond),
3708 asm, "\t$Rn, $Rm, $nzcv, $cond", "", []>,
3709 Sched<[WriteFCmp]> {
3715 let Inst{31-23} = 0b000111100;
3717 let Inst{20-16} = Rm;
3718 let Inst{15-12} = cond;
3719 let Inst{11-10} = 0b01;
3721 let Inst{4} = signalAllNans;
3722 let Inst{3-0} = nzcv;
3725 multiclass FPCondComparison<bit signalAllNans, string asm> {
3726 let Defs = [NZCV], Uses = [NZCV] in {
3727 def Srr : BaseFPCondComparison<signalAllNans, FPR32, asm> {
3731 def Drr : BaseFPCondComparison<signalAllNans, FPR64, asm> {
3734 } // Defs = [NZCV], Uses = [NZCV]
3738 // Floating point conditional select
3741 class BaseFPCondSelect<RegisterClass regtype, ValueType vt, string asm>
3742 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
3743 asm, "\t$Rd, $Rn, $Rm, $cond", "",
3745 (ARM64csel (vt regtype:$Rn), regtype:$Rm,
3746 (i32 imm:$cond), NZCV))]>,
3753 let Inst{31-23} = 0b000111100;
3755 let Inst{20-16} = Rm;
3756 let Inst{15-12} = cond;
3757 let Inst{11-10} = 0b11;
3762 multiclass FPCondSelect<string asm> {
3763 let Uses = [NZCV] in {
3764 def Srrr : BaseFPCondSelect<FPR32, f32, asm> {
3768 def Drrr : BaseFPCondSelect<FPR64, f64, asm> {
3775 // Floating move immediate
3778 class BaseFPMoveImmediate<RegisterClass regtype, Operand fpimmtype, string asm>
3779 : I<(outs regtype:$Rd), (ins fpimmtype:$imm), asm, "\t$Rd, $imm", "",
3780 [(set regtype:$Rd, fpimmtype:$imm)]>,
3781 Sched<[WriteFImm]> {
3784 let Inst{31-23} = 0b000111100;
3786 let Inst{20-13} = imm;
3787 let Inst{12-5} = 0b10000000;
3791 multiclass FPMoveImmediate<string asm> {
3792 def Si : BaseFPMoveImmediate<FPR32, fpimm32, asm> {
3796 def Di : BaseFPMoveImmediate<FPR64, fpimm64, asm> {
3800 } // end of 'let Predicates = [HasFPARMv8]'
3802 //----------------------------------------------------------------------------
3804 //----------------------------------------------------------------------------
3806 class AsmVectorIndex<string Suffix> : AsmOperandClass {
3807 let Name = "VectorIndex" # Suffix;
3808 let DiagnosticType = "InvalidIndex" # Suffix;
3810 def VectorIndexBOperand : AsmVectorIndex<"B">;
3811 def VectorIndexHOperand : AsmVectorIndex<"H">;
3812 def VectorIndexSOperand : AsmVectorIndex<"S">;
3813 def VectorIndexDOperand : AsmVectorIndex<"D">;
3815 def VectorIndexB : Operand<i64>, ImmLeaf<i64, [{
3816 return ((uint64_t)Imm) < 16;
3818 let ParserMatchClass = VectorIndexBOperand;
3819 let PrintMethod = "printVectorIndex";
3820 let MIOperandInfo = (ops i64imm);
3822 def VectorIndexH : Operand<i64>, ImmLeaf<i64, [{
3823 return ((uint64_t)Imm) < 8;
3825 let ParserMatchClass = VectorIndexHOperand;
3826 let PrintMethod = "printVectorIndex";
3827 let MIOperandInfo = (ops i64imm);
3829 def VectorIndexS : Operand<i64>, ImmLeaf<i64, [{
3830 return ((uint64_t)Imm) < 4;
3832 let ParserMatchClass = VectorIndexSOperand;
3833 let PrintMethod = "printVectorIndex";
3834 let MIOperandInfo = (ops i64imm);
3836 def VectorIndexD : Operand<i64>, ImmLeaf<i64, [{
3837 return ((uint64_t)Imm) < 2;
3839 let ParserMatchClass = VectorIndexDOperand;
3840 let PrintMethod = "printVectorIndex";
3841 let MIOperandInfo = (ops i64imm);
3844 def MemorySIMDNoIndexOperand : AsmOperandClass {
3845 let Name = "MemorySIMDNoIndex";
3846 let ParserMethod = "tryParseNoIndexMemory";
3848 def am_simdnoindex : Operand<i64>,
3849 ComplexPattern<i64, 1, "SelectAddrModeNoIndex", []> {
3850 let PrintMethod = "printAMNoIndex";
3851 let ParserMatchClass = MemorySIMDNoIndexOperand;
3852 let MIOperandInfo = (ops GPR64sp:$base);
3853 let DecoderMethod = "DecodeGPR64spRegisterClass";
3856 let Predicates = [HasNEON] in {
3858 //----------------------------------------------------------------------------
3859 // AdvSIMD three register vector instructions
3860 //----------------------------------------------------------------------------
3862 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3863 class BaseSIMDThreeSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
3864 RegisterOperand regtype, string asm, string kind,
3866 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
3867 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
3868 "|" # kind # "\t$Rd, $Rn, $Rm|}", "", pattern>,
3876 let Inst{28-24} = 0b01110;
3877 let Inst{23-22} = size;
3879 let Inst{20-16} = Rm;
3880 let Inst{15-11} = opcode;
3886 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3887 class BaseSIMDThreeSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
3888 RegisterOperand regtype, string asm, string kind,
3890 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm), asm,
3891 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
3892 "|" # kind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
3900 let Inst{28-24} = 0b01110;
3901 let Inst{23-22} = size;
3903 let Inst{20-16} = Rm;
3904 let Inst{15-11} = opcode;
3910 // All operand sizes distinguished in the encoding.
3911 multiclass SIMDThreeSameVector<bit U, bits<5> opc, string asm,
3912 SDPatternOperator OpNode> {
3913 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
3915 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
3916 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
3918 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
3919 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
3921 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
3922 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
3924 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
3925 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
3927 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
3928 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
3930 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
3931 def v2i64 : BaseSIMDThreeSameVector<1, U, 0b11, opc, V128,
3933 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
3936 // As above, but D sized elements unsupported.
3937 multiclass SIMDThreeSameVectorBHS<bit U, bits<5> opc, string asm,
3938 SDPatternOperator OpNode> {
3939 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
3941 [(set V64:$Rd, (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))]>;
3942 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
3944 [(set V128:$Rd, (v16i8 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm))))]>;
3945 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
3947 [(set V64:$Rd, (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))]>;
3948 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
3950 [(set V128:$Rd, (v8i16 (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm))))]>;
3951 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
3953 [(set V64:$Rd, (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))]>;
3954 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
3956 [(set V128:$Rd, (v4i32 (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm))))]>;
3959 multiclass SIMDThreeSameVectorBHSTied<bit U, bits<5> opc, string asm,
3960 SDPatternOperator OpNode> {
3961 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, 0b00, opc, V64,
3963 [(set (v8i8 V64:$dst),
3964 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
3965 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, 0b00, opc, V128,
3967 [(set (v16i8 V128:$dst),
3968 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
3969 def v4i16 : BaseSIMDThreeSameVectorTied<0, U, 0b01, opc, V64,
3971 [(set (v4i16 V64:$dst),
3972 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
3973 def v8i16 : BaseSIMDThreeSameVectorTied<1, U, 0b01, opc, V128,
3975 [(set (v8i16 V128:$dst),
3976 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
3977 def v2i32 : BaseSIMDThreeSameVectorTied<0, U, 0b10, opc, V64,
3979 [(set (v2i32 V64:$dst),
3980 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
3981 def v4i32 : BaseSIMDThreeSameVectorTied<1, U, 0b10, opc, V128,
3983 [(set (v4i32 V128:$dst),
3984 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
3987 // As above, but only B sized elements supported.
3988 multiclass SIMDThreeSameVectorB<bit U, bits<5> opc, string asm,
3989 SDPatternOperator OpNode> {
3990 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
3992 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
3993 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
3995 [(set (v16i8 V128:$Rd),
3996 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
3999 // As above, but only S and D sized floating point elements supported.
4000 multiclass SIMDThreeSameVectorFP<bit U, bit S, bits<5> opc,
4001 string asm, SDPatternOperator OpNode> {
4002 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0}, opc, V64,
4004 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4005 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0}, opc, V128,
4007 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4008 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,1}, opc, V128,
4010 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4013 multiclass SIMDThreeSameVectorFPCmp<bit U, bit S, bits<5> opc,
4015 SDPatternOperator OpNode> {
4016 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0}, opc, V64,
4018 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4019 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0}, opc, V128,
4021 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4022 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,1}, opc, V128,
4024 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4027 multiclass SIMDThreeSameVectorFPTied<bit U, bit S, bits<5> opc,
4028 string asm, SDPatternOperator OpNode> {
4029 def v2f32 : BaseSIMDThreeSameVectorTied<0, U, {S,0}, opc, V64,
4031 [(set (v2f32 V64:$dst),
4032 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4033 def v4f32 : BaseSIMDThreeSameVectorTied<1, U, {S,0}, opc, V128,
4035 [(set (v4f32 V128:$dst),
4036 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4037 def v2f64 : BaseSIMDThreeSameVectorTied<1, U, {S,1}, opc, V128,
4039 [(set (v2f64 V128:$dst),
4040 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4043 // As above, but D and B sized elements unsupported.
4044 multiclass SIMDThreeSameVectorHS<bit U, bits<5> opc, string asm,
4045 SDPatternOperator OpNode> {
4046 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
4048 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4049 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
4051 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4052 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
4054 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4055 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
4057 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4060 // Logical three vector ops share opcode bits, and only use B sized elements.
4061 multiclass SIMDLogicalThreeVector<bit U, bits<2> size, string asm,
4062 SDPatternOperator OpNode = null_frag> {
4063 def v8i8 : BaseSIMDThreeSameVector<0, U, size, 0b00011, V64,
4065 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn, V64:$Rm))]>;
4066 def v16i8 : BaseSIMDThreeSameVector<1, U, size, 0b00011, V128,
4068 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn, V128:$Rm))]>;
4070 def : Pat<(v4i16 (OpNode V64:$LHS, V64:$RHS)),
4071 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4072 def : Pat<(v2i32 (OpNode V64:$LHS, V64:$RHS)),
4073 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4074 def : Pat<(v1i64 (OpNode V64:$LHS, V64:$RHS)),
4075 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4077 def : Pat<(v8i16 (OpNode V128:$LHS, V128:$RHS)),
4078 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4079 def : Pat<(v4i32 (OpNode V128:$LHS, V128:$RHS)),
4080 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4081 def : Pat<(v2i64 (OpNode V128:$LHS, V128:$RHS)),
4082 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4085 multiclass SIMDLogicalThreeVectorTied<bit U, bits<2> size,
4086 string asm, SDPatternOperator OpNode> {
4087 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, size, 0b00011, V64,
4089 [(set (v8i8 V64:$dst),
4090 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4091 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, size, 0b00011, V128,
4093 [(set (v16i8 V128:$dst),
4094 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
4095 (v16i8 V128:$Rm)))]>;
4097 def : Pat<(v4i16 (OpNode (v4i16 V64:$LHS), (v4i16 V64:$MHS),
4099 (!cast<Instruction>(NAME#"v8i8")
4100 V64:$LHS, V64:$MHS, V64:$RHS)>;
4101 def : Pat<(v2i32 (OpNode (v2i32 V64:$LHS), (v2i32 V64:$MHS),
4103 (!cast<Instruction>(NAME#"v8i8")
4104 V64:$LHS, V64:$MHS, V64:$RHS)>;
4105 def : Pat<(v1i64 (OpNode (v1i64 V64:$LHS), (v1i64 V64:$MHS),
4107 (!cast<Instruction>(NAME#"v8i8")
4108 V64:$LHS, V64:$MHS, V64:$RHS)>;
4110 def : Pat<(v8i16 (OpNode (v8i16 V128:$LHS), (v8i16 V128:$MHS),
4111 (v8i16 V128:$RHS))),
4112 (!cast<Instruction>(NAME#"v16i8")
4113 V128:$LHS, V128:$MHS, V128:$RHS)>;
4114 def : Pat<(v4i32 (OpNode (v4i32 V128:$LHS), (v4i32 V128:$MHS),
4115 (v4i32 V128:$RHS))),
4116 (!cast<Instruction>(NAME#"v16i8")
4117 V128:$LHS, V128:$MHS, V128:$RHS)>;
4118 def : Pat<(v2i64 (OpNode (v2i64 V128:$LHS), (v2i64 V128:$MHS),
4119 (v2i64 V128:$RHS))),
4120 (!cast<Instruction>(NAME#"v16i8")
4121 V128:$LHS, V128:$MHS, V128:$RHS)>;
4125 //----------------------------------------------------------------------------
4126 // AdvSIMD two register vector instructions.
4127 //----------------------------------------------------------------------------
4129 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4130 class BaseSIMDTwoSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4131 RegisterOperand regtype, string asm, string dstkind,
4132 string srckind, list<dag> pattern>
4133 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
4134 "{\t$Rd" # dstkind # ", $Rn" # srckind #
4135 "|" # dstkind # "\t$Rd, $Rn}", "", pattern>,
4142 let Inst{28-24} = 0b01110;
4143 let Inst{23-22} = size;
4144 let Inst{21-17} = 0b10000;
4145 let Inst{16-12} = opcode;
4146 let Inst{11-10} = 0b10;
4151 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4152 class BaseSIMDTwoSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4153 RegisterOperand regtype, string asm, string dstkind,
4154 string srckind, list<dag> pattern>
4155 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn), asm,
4156 "{\t$Rd" # dstkind # ", $Rn" # srckind #
4157 "|" # dstkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
4164 let Inst{28-24} = 0b01110;
4165 let Inst{23-22} = size;
4166 let Inst{21-17} = 0b10000;
4167 let Inst{16-12} = opcode;
4168 let Inst{11-10} = 0b10;
4173 // Supports B, H, and S element sizes.
4174 multiclass SIMDTwoVectorBHS<bit U, bits<5> opc, string asm,
4175 SDPatternOperator OpNode> {
4176 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4178 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4179 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4180 asm, ".16b", ".16b",
4181 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4182 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4184 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4185 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4187 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4188 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4190 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4191 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4193 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4196 class BaseSIMDVectorLShiftLongBySize<bit Q, bits<2> size,
4197 RegisterOperand regtype, string asm, string dstkind,
4198 string srckind, string amount>
4199 : I<(outs V128:$Rd), (ins regtype:$Rn), asm,
4200 "{\t$Rd" # dstkind # ", $Rn" # srckind # ", #" # amount #
4201 "|" # dstkind # "\t$Rd, $Rn, #" # amount # "}", "", []>,
4207 let Inst{29-24} = 0b101110;
4208 let Inst{23-22} = size;
4209 let Inst{21-10} = 0b100001001110;
4214 multiclass SIMDVectorLShiftLongBySizeBHS {
4215 let neverHasSideEffects = 1 in {
4216 def v8i8 : BaseSIMDVectorLShiftLongBySize<0, 0b00, V64,
4217 "shll", ".8h", ".8b", "8">;
4218 def v16i8 : BaseSIMDVectorLShiftLongBySize<1, 0b00, V128,
4219 "shll2", ".8h", ".16b", "8">;
4220 def v4i16 : BaseSIMDVectorLShiftLongBySize<0, 0b01, V64,
4221 "shll", ".4s", ".4h", "16">;
4222 def v8i16 : BaseSIMDVectorLShiftLongBySize<1, 0b01, V128,
4223 "shll2", ".4s", ".8h", "16">;
4224 def v2i32 : BaseSIMDVectorLShiftLongBySize<0, 0b10, V64,
4225 "shll", ".2d", ".2s", "32">;
4226 def v4i32 : BaseSIMDVectorLShiftLongBySize<1, 0b10, V128,
4227 "shll2", ".2d", ".4s", "32">;
4231 // Supports all element sizes.
4232 multiclass SIMDLongTwoVector<bit U, bits<5> opc, string asm,
4233 SDPatternOperator OpNode> {
4234 def v8i8_v4i16 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4236 [(set (v4i16 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4237 def v16i8_v8i16 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4239 [(set (v8i16 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4240 def v4i16_v2i32 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4242 [(set (v2i32 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4243 def v8i16_v4i32 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4245 [(set (v4i32 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4246 def v2i32_v1i64 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4248 [(set (v1i64 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4249 def v4i32_v2i64 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4251 [(set (v2i64 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4254 multiclass SIMDLongTwoVectorTied<bit U, bits<5> opc, string asm,
4255 SDPatternOperator OpNode> {
4256 def v8i8_v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, V64,
4258 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd),
4260 def v16i8_v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, V128,
4262 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd),
4263 (v16i8 V128:$Rn)))]>;
4264 def v4i16_v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, V64,
4266 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd),
4267 (v4i16 V64:$Rn)))]>;
4268 def v8i16_v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, V128,
4270 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd),
4271 (v8i16 V128:$Rn)))]>;
4272 def v2i32_v1i64 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, V64,
4274 [(set (v1i64 V64:$dst), (OpNode (v1i64 V64:$Rd),
4275 (v2i32 V64:$Rn)))]>;
4276 def v4i32_v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, V128,
4278 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd),
4279 (v4i32 V128:$Rn)))]>;
4282 // Supports all element sizes, except 1xD.
4283 multiclass SIMDTwoVectorBHSDTied<bit U, bits<5> opc, string asm,
4284 SDPatternOperator OpNode> {
4285 def v8i8 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, V64,
4287 [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn)))]>;
4288 def v16i8 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, V128,
4289 asm, ".16b", ".16b",
4290 [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
4291 def v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, V64,
4293 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn)))]>;
4294 def v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, V128,
4296 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn)))]>;
4297 def v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, V64,
4299 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn)))]>;
4300 def v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, V128,
4302 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
4303 def v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b11, opc, V128,
4305 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn)))]>;
4308 multiclass SIMDTwoVectorBHSD<bit U, bits<5> opc, string asm,
4309 SDPatternOperator OpNode = null_frag> {
4310 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4312 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4313 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4314 asm, ".16b", ".16b",
4315 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4316 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4318 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4319 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4321 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4322 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4324 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4325 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4327 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4328 def v2i64 : BaseSIMDTwoSameVector<1, U, 0b11, opc, V128,
4330 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4334 // Supports only B element sizes.
4335 multiclass SIMDTwoVectorB<bit U, bits<2> size, bits<5> opc, string asm,
4336 SDPatternOperator OpNode> {
4337 def v8i8 : BaseSIMDTwoSameVector<0, U, size, opc, V64,
4339 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4340 def v16i8 : BaseSIMDTwoSameVector<1, U, size, opc, V128,
4341 asm, ".16b", ".16b",
4342 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4346 // Supports only B and H element sizes.
4347 multiclass SIMDTwoVectorBH<bit U, bits<5> opc, string asm,
4348 SDPatternOperator OpNode> {
4349 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4351 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn))]>;
4352 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4353 asm, ".16b", ".16b",
4354 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn))]>;
4355 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4357 [(set (v4i16 V64:$Rd), (OpNode V64:$Rn))]>;
4358 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4360 [(set (v8i16 V128:$Rd), (OpNode V128:$Rn))]>;
4363 // Supports only S and D element sizes, uses high bit of the size field
4364 // as an extra opcode bit.
4365 multiclass SIMDTwoVectorFP<bit U, bit S, bits<5> opc, string asm,
4366 SDPatternOperator OpNode> {
4367 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4369 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
4370 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4372 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
4373 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4375 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4378 // Supports only S element size.
4379 multiclass SIMDTwoVectorS<bit U, bit S, bits<5> opc, string asm,
4380 SDPatternOperator OpNode> {
4381 def v2i32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4383 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4384 def v4i32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4386 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4390 multiclass SIMDTwoVectorFPToInt<bit U, bit S, bits<5> opc, string asm,
4391 SDPatternOperator OpNode> {
4392 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4394 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
4395 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4397 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
4398 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4400 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4403 multiclass SIMDTwoVectorIntToFP<bit U, bit S, bits<5> opc, string asm,
4404 SDPatternOperator OpNode> {
4405 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4407 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4408 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4410 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4411 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4413 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4417 class BaseSIMDMixedTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4418 RegisterOperand inreg, RegisterOperand outreg,
4419 string asm, string outkind, string inkind,
4421 : I<(outs outreg:$Rd), (ins inreg:$Rn), asm,
4422 "{\t$Rd" # outkind # ", $Rn" # inkind #
4423 "|" # outkind # "\t$Rd, $Rn}", "", pattern>,
4430 let Inst{28-24} = 0b01110;
4431 let Inst{23-22} = size;
4432 let Inst{21-17} = 0b10000;
4433 let Inst{16-12} = opcode;
4434 let Inst{11-10} = 0b10;
4439 class BaseSIMDMixedTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4440 RegisterOperand inreg, RegisterOperand outreg,
4441 string asm, string outkind, string inkind,
4443 : I<(outs outreg:$dst), (ins outreg:$Rd, inreg:$Rn), asm,
4444 "{\t$Rd" # outkind # ", $Rn" # inkind #
4445 "|" # outkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
4452 let Inst{28-24} = 0b01110;
4453 let Inst{23-22} = size;
4454 let Inst{21-17} = 0b10000;
4455 let Inst{16-12} = opcode;
4456 let Inst{11-10} = 0b10;
4461 multiclass SIMDMixedTwoVector<bit U, bits<5> opc, string asm,
4462 SDPatternOperator OpNode> {
4463 def v8i8 : BaseSIMDMixedTwoVector<0, U, 0b00, opc, V128, V64,
4465 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4466 def v16i8 : BaseSIMDMixedTwoVectorTied<1, U, 0b00, opc, V128, V128,
4467 asm#"2", ".16b", ".8h", []>;
4468 def v4i16 : BaseSIMDMixedTwoVector<0, U, 0b01, opc, V128, V64,
4470 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4471 def v8i16 : BaseSIMDMixedTwoVectorTied<1, U, 0b01, opc, V128, V128,
4472 asm#"2", ".8h", ".4s", []>;
4473 def v2i32 : BaseSIMDMixedTwoVector<0, U, 0b10, opc, V128, V64,
4475 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4476 def v4i32 : BaseSIMDMixedTwoVectorTied<1, U, 0b10, opc, V128, V128,
4477 asm#"2", ".4s", ".2d", []>;
4479 def : Pat<(concat_vectors (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn))),
4480 (!cast<Instruction>(NAME # "v16i8")
4481 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4482 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn))),
4483 (!cast<Instruction>(NAME # "v8i16")
4484 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4485 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn))),
4486 (!cast<Instruction>(NAME # "v4i32")
4487 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4490 class BaseSIMDCmpTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4491 RegisterOperand regtype,
4492 string asm, string kind, string zero,
4493 ValueType dty, ValueType sty, SDNode OpNode>
4494 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
4495 "{\t$Rd" # kind # ", $Rn" # kind # ", #" # zero #
4496 "|" # kind # "\t$Rd, $Rn, #" # zero # "}", "",
4497 [(set (dty regtype:$Rd), (OpNode (sty regtype:$Rn)))]>,
4504 let Inst{28-24} = 0b01110;
4505 let Inst{23-22} = size;
4506 let Inst{21-17} = 0b10000;
4507 let Inst{16-12} = opcode;
4508 let Inst{11-10} = 0b10;
4513 // Comparisons support all element sizes, except 1xD.
4514 multiclass SIMDCmpTwoVector<bit U, bits<5> opc, string asm,
4516 def v8i8rz : BaseSIMDCmpTwoVector<0, U, 0b00, opc, V64,
4518 v8i8, v8i8, OpNode>;
4519 def v16i8rz : BaseSIMDCmpTwoVector<1, U, 0b00, opc, V128,
4521 v16i8, v16i8, OpNode>;
4522 def v4i16rz : BaseSIMDCmpTwoVector<0, U, 0b01, opc, V64,
4524 v4i16, v4i16, OpNode>;
4525 def v8i16rz : BaseSIMDCmpTwoVector<1, U, 0b01, opc, V128,
4527 v8i16, v8i16, OpNode>;
4528 def v2i32rz : BaseSIMDCmpTwoVector<0, U, 0b10, opc, V64,
4530 v2i32, v2i32, OpNode>;
4531 def v4i32rz : BaseSIMDCmpTwoVector<1, U, 0b10, opc, V128,
4533 v4i32, v4i32, OpNode>;
4534 def v2i64rz : BaseSIMDCmpTwoVector<1, U, 0b11, opc, V128,
4536 v2i64, v2i64, OpNode>;
4539 // FP Comparisons support only S and D element sizes.
4540 multiclass SIMDFPCmpTwoVector<bit U, bit S, bits<5> opc,
4541 string asm, SDNode OpNode> {
4543 def v2i32rz : BaseSIMDCmpTwoVector<0, U, {S,0}, opc, V64,
4545 v2i32, v2f32, OpNode>;
4546 def v4i32rz : BaseSIMDCmpTwoVector<1, U, {S,0}, opc, V128,
4548 v4i32, v4f32, OpNode>;
4549 def v2i64rz : BaseSIMDCmpTwoVector<1, U, {S,1}, opc, V128,
4551 v2i64, v2f64, OpNode>;
4553 def : InstAlias<asm # " $Vd.2s, $Vn.2s, #0",
4554 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
4555 def : InstAlias<asm # " $Vd.4s, $Vn.4s, #0",
4556 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
4557 def : InstAlias<asm # " $Vd.2d, $Vn.2d, #0",
4558 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
4559 def : InstAlias<asm # ".2s $Vd, $Vn, #0",
4560 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
4561 def : InstAlias<asm # ".4s $Vd, $Vn, #0",
4562 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
4563 def : InstAlias<asm # ".2d $Vd, $Vn, #0",
4564 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
4567 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4568 class BaseSIMDFPCvtTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4569 RegisterOperand outtype, RegisterOperand intype,
4570 string asm, string VdTy, string VnTy,
4572 : I<(outs outtype:$Rd), (ins intype:$Rn), asm,
4573 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "", pattern>,
4580 let Inst{28-24} = 0b01110;
4581 let Inst{23-22} = size;
4582 let Inst{21-17} = 0b10000;
4583 let Inst{16-12} = opcode;
4584 let Inst{11-10} = 0b10;
4589 class BaseSIMDFPCvtTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4590 RegisterOperand outtype, RegisterOperand intype,
4591 string asm, string VdTy, string VnTy,
4593 : I<(outs outtype:$dst), (ins outtype:$Rd, intype:$Rn), asm,
4594 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "$Rd = $dst", pattern>,
4601 let Inst{28-24} = 0b01110;
4602 let Inst{23-22} = size;
4603 let Inst{21-17} = 0b10000;
4604 let Inst{16-12} = opcode;
4605 let Inst{11-10} = 0b10;
4610 multiclass SIMDFPWidenTwoVector<bit U, bit S, bits<5> opc, string asm> {
4611 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V128, V64,
4612 asm, ".4s", ".4h", []>;
4613 def v8i16 : BaseSIMDFPCvtTwoVector<1, U, {S,0}, opc, V128, V128,
4614 asm#"2", ".4s", ".8h", []>;
4615 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V128, V64,
4616 asm, ".2d", ".2s", []>;
4617 def v4i32 : BaseSIMDFPCvtTwoVector<1, U, {S,1}, opc, V128, V128,
4618 asm#"2", ".2d", ".4s", []>;
4621 multiclass SIMDFPNarrowTwoVector<bit U, bit S, bits<5> opc, string asm> {
4622 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V64, V128,
4623 asm, ".4h", ".4s", []>;
4624 def v8i16 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,0}, opc, V128, V128,
4625 asm#"2", ".8h", ".4s", []>;
4626 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
4627 asm, ".2s", ".2d", []>;
4628 def v4i32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
4629 asm#"2", ".4s", ".2d", []>;
4632 multiclass SIMDFPInexactCvtTwoVector<bit U, bit S, bits<5> opc, string asm,
4634 def v2f32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
4636 [(set (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4637 def v4f32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
4638 asm#"2", ".4s", ".2d", []>;
4640 def : Pat<(concat_vectors (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn))),
4641 (!cast<Instruction>(NAME # "v4f32")
4642 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4645 //----------------------------------------------------------------------------
4646 // AdvSIMD three register different-size vector instructions.
4647 //----------------------------------------------------------------------------
4649 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4650 class BaseSIMDDifferentThreeVector<bit U, bits<3> size, bits<4> opcode,
4651 RegisterOperand outtype, RegisterOperand intype1,
4652 RegisterOperand intype2, string asm,
4653 string outkind, string inkind1, string inkind2,
4655 : I<(outs outtype:$Rd), (ins intype1:$Rn, intype2:$Rm), asm,
4656 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
4657 "|" # outkind # "\t$Rd, $Rn, $Rm}", "", pattern>,
4663 let Inst{30} = size{0};
4665 let Inst{28-24} = 0b01110;
4666 let Inst{23-22} = size{2-1};
4668 let Inst{20-16} = Rm;
4669 let Inst{15-12} = opcode;
4670 let Inst{11-10} = 0b00;
4675 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4676 class BaseSIMDDifferentThreeVectorTied<bit U, bits<3> size, bits<4> opcode,
4677 RegisterOperand outtype, RegisterOperand intype1,
4678 RegisterOperand intype2, string asm,
4679 string outkind, string inkind1, string inkind2,
4681 : I<(outs outtype:$dst), (ins outtype:$Rd, intype1:$Rn, intype2:$Rm), asm,
4682 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
4683 "|" # outkind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
4689 let Inst{30} = size{0};
4691 let Inst{28-24} = 0b01110;
4692 let Inst{23-22} = size{2-1};
4694 let Inst{20-16} = Rm;
4695 let Inst{15-12} = opcode;
4696 let Inst{11-10} = 0b00;
4701 // FIXME: TableGen doesn't know how to deal with expanded types that also
4702 // change the element count (in this case, placing the results in
4703 // the high elements of the result register rather than the low
4704 // elements). Until that's fixed, we can't code-gen those.
4705 multiclass SIMDNarrowThreeVectorBHS<bit U, bits<4> opc, string asm,
4707 def v8i16_v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4709 asm, ".8b", ".8h", ".8h",
4710 [(set (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4711 def v8i16_v16i8 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4713 asm#"2", ".16b", ".8h", ".8h",
4715 def v4i32_v4i16 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4717 asm, ".4h", ".4s", ".4s",
4718 [(set (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4719 def v4i32_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4721 asm#"2", ".8h", ".4s", ".4s",
4723 def v2i64_v2i32 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4725 asm, ".2s", ".2d", ".2d",
4726 [(set (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
4727 def v2i64_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4729 asm#"2", ".4s", ".2d", ".2d",
4733 // Patterns for the '2' variants involve INSERT_SUBREG, which you can't put in
4734 // a version attached to an instruction.
4735 def : Pat<(concat_vectors (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn),
4737 (!cast<Instruction>(NAME # "v8i16_v16i8")
4738 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4739 V128:$Rn, V128:$Rm)>;
4740 def : Pat<(concat_vectors (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn),
4742 (!cast<Instruction>(NAME # "v4i32_v8i16")
4743 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4744 V128:$Rn, V128:$Rm)>;
4745 def : Pat<(concat_vectors (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn),
4747 (!cast<Instruction>(NAME # "v2i64_v4i32")
4748 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4749 V128:$Rn, V128:$Rm)>;
4752 multiclass SIMDDifferentThreeVectorBD<bit U, bits<4> opc, string asm,
4754 def v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4756 asm, ".8h", ".8b", ".8b",
4757 [(set (v8i16 V128:$Rd), (IntOp (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4758 def v16i8 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4760 asm#"2", ".8h", ".16b", ".16b", []>;
4761 let Predicates = [HasCrypto] in {
4762 def v1i64 : BaseSIMDDifferentThreeVector<U, 0b110, opc,
4764 asm, ".1q", ".1d", ".1d", []>;
4765 def v2i64 : BaseSIMDDifferentThreeVector<U, 0b111, opc,
4767 asm#"2", ".1q", ".2d", ".2d", []>;
4770 def : Pat<(v8i16 (IntOp (v8i8 (extract_high_v16i8 V128:$Rn)),
4771 (v8i8 (extract_high_v16i8 V128:$Rm)))),
4772 (!cast<Instruction>(NAME#"v16i8") V128:$Rn, V128:$Rm)>;
4775 multiclass SIMDLongThreeVectorHS<bit U, bits<4> opc, string asm,
4776 SDPatternOperator OpNode> {
4777 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4779 asm, ".4s", ".4h", ".4h",
4780 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4781 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4783 asm#"2", ".4s", ".8h", ".8h",
4784 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
4785 (extract_high_v8i16 V128:$Rm)))]>;
4786 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4788 asm, ".2d", ".2s", ".2s",
4789 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4790 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4792 asm#"2", ".2d", ".4s", ".4s",
4793 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
4794 (extract_high_v4i32 V128:$Rm)))]>;
4797 multiclass SIMDLongThreeVectorBHSabdl<bit U, bits<4> opc, string asm,
4798 SDPatternOperator OpNode = null_frag> {
4799 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4801 asm, ".8h", ".8b", ".8b",
4802 [(set (v8i16 V128:$Rd),
4803 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))))]>;
4804 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4806 asm#"2", ".8h", ".16b", ".16b",
4807 [(set (v8i16 V128:$Rd),
4808 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
4809 (extract_high_v16i8 V128:$Rm)))))]>;
4810 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4812 asm, ".4s", ".4h", ".4h",
4813 [(set (v4i32 V128:$Rd),
4814 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))))]>;
4815 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4817 asm#"2", ".4s", ".8h", ".8h",
4818 [(set (v4i32 V128:$Rd),
4819 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
4820 (extract_high_v8i16 V128:$Rm)))))]>;
4821 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4823 asm, ".2d", ".2s", ".2s",
4824 [(set (v2i64 V128:$Rd),
4825 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))))]>;
4826 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4828 asm#"2", ".2d", ".4s", ".4s",
4829 [(set (v2i64 V128:$Rd),
4830 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
4831 (extract_high_v4i32 V128:$Rm)))))]>;
4834 multiclass SIMDLongThreeVectorTiedBHSabal<bit U, bits<4> opc,
4836 SDPatternOperator OpNode> {
4837 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
4839 asm, ".8h", ".8b", ".8b",
4840 [(set (v8i16 V128:$dst),
4841 (add (v8i16 V128:$Rd),
4842 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))))]>;
4843 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4845 asm#"2", ".8h", ".16b", ".16b",
4846 [(set (v8i16 V128:$dst),
4847 (add (v8i16 V128:$Rd),
4848 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
4849 (extract_high_v16i8 V128:$Rm))))))]>;
4850 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
4852 asm, ".4s", ".4h", ".4h",
4853 [(set (v4i32 V128:$dst),
4854 (add (v4i32 V128:$Rd),
4855 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))))]>;
4856 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4858 asm#"2", ".4s", ".8h", ".8h",
4859 [(set (v4i32 V128:$dst),
4860 (add (v4i32 V128:$Rd),
4861 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
4862 (extract_high_v8i16 V128:$Rm))))))]>;
4863 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
4865 asm, ".2d", ".2s", ".2s",
4866 [(set (v2i64 V128:$dst),
4867 (add (v2i64 V128:$Rd),
4868 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))))]>;
4869 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4871 asm#"2", ".2d", ".4s", ".4s",
4872 [(set (v2i64 V128:$dst),
4873 (add (v2i64 V128:$Rd),
4874 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
4875 (extract_high_v4i32 V128:$Rm))))))]>;
4878 multiclass SIMDLongThreeVectorBHS<bit U, bits<4> opc, string asm,
4879 SDPatternOperator OpNode = null_frag> {
4880 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4882 asm, ".8h", ".8b", ".8b",
4883 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4884 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4886 asm#"2", ".8h", ".16b", ".16b",
4887 [(set (v8i16 V128:$Rd), (OpNode (extract_high_v16i8 V128:$Rn),
4888 (extract_high_v16i8 V128:$Rm)))]>;
4889 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4891 asm, ".4s", ".4h", ".4h",
4892 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4893 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4895 asm#"2", ".4s", ".8h", ".8h",
4896 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
4897 (extract_high_v8i16 V128:$Rm)))]>;
4898 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4900 asm, ".2d", ".2s", ".2s",
4901 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4902 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4904 asm#"2", ".2d", ".4s", ".4s",
4905 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
4906 (extract_high_v4i32 V128:$Rm)))]>;
4909 multiclass SIMDLongThreeVectorTiedBHS<bit U, bits<4> opc,
4911 SDPatternOperator OpNode> {
4912 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
4914 asm, ".8h", ".8b", ".8b",
4915 [(set (v8i16 V128:$dst),
4916 (OpNode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4917 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4919 asm#"2", ".8h", ".16b", ".16b",
4920 [(set (v8i16 V128:$dst),
4921 (OpNode (v8i16 V128:$Rd),
4922 (extract_high_v16i8 V128:$Rn),
4923 (extract_high_v16i8 V128:$Rm)))]>;
4924 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
4926 asm, ".4s", ".4h", ".4h",
4927 [(set (v4i32 V128:$dst),
4928 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4929 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4931 asm#"2", ".4s", ".8h", ".8h",
4932 [(set (v4i32 V128:$dst),
4933 (OpNode (v4i32 V128:$Rd),
4934 (extract_high_v8i16 V128:$Rn),
4935 (extract_high_v8i16 V128:$Rm)))]>;
4936 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
4938 asm, ".2d", ".2s", ".2s",
4939 [(set (v2i64 V128:$dst),
4940 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4941 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4943 asm#"2", ".2d", ".4s", ".4s",
4944 [(set (v2i64 V128:$dst),
4945 (OpNode (v2i64 V128:$Rd),
4946 (extract_high_v4i32 V128:$Rn),
4947 (extract_high_v4i32 V128:$Rm)))]>;
4950 multiclass SIMDLongThreeVectorSQDMLXTiedHS<bit U, bits<4> opc, string asm,
4951 SDPatternOperator Accum> {
4952 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
4954 asm, ".4s", ".4h", ".4h",
4955 [(set (v4i32 V128:$dst),
4956 (Accum (v4i32 V128:$Rd),
4957 (v4i32 (int_arm64_neon_sqdmull (v4i16 V64:$Rn),
4958 (v4i16 V64:$Rm)))))]>;
4959 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4961 asm#"2", ".4s", ".8h", ".8h",
4962 [(set (v4i32 V128:$dst),
4963 (Accum (v4i32 V128:$Rd),
4964 (v4i32 (int_arm64_neon_sqdmull (extract_high_v8i16 V128:$Rn),
4965 (extract_high_v8i16 V128:$Rm)))))]>;
4966 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
4968 asm, ".2d", ".2s", ".2s",
4969 [(set (v2i64 V128:$dst),
4970 (Accum (v2i64 V128:$Rd),
4971 (v2i64 (int_arm64_neon_sqdmull (v2i32 V64:$Rn),
4972 (v2i32 V64:$Rm)))))]>;
4973 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4975 asm#"2", ".2d", ".4s", ".4s",
4976 [(set (v2i64 V128:$dst),
4977 (Accum (v2i64 V128:$Rd),
4978 (v2i64 (int_arm64_neon_sqdmull (extract_high_v4i32 V128:$Rn),
4979 (extract_high_v4i32 V128:$Rm)))))]>;
4982 multiclass SIMDWideThreeVectorBHS<bit U, bits<4> opc, string asm,
4983 SDPatternOperator OpNode> {
4984 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4986 asm, ".8h", ".8h", ".8b",
4987 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i8 V64:$Rm)))]>;
4988 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4990 asm#"2", ".8h", ".8h", ".16b",
4991 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
4992 (extract_high_v16i8 V128:$Rm)))]>;
4993 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4995 asm, ".4s", ".4s", ".4h",
4996 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i16 V64:$Rm)))]>;
4997 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4999 asm#"2", ".4s", ".4s", ".8h",
5000 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
5001 (extract_high_v8i16 V128:$Rm)))]>;
5002 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
5004 asm, ".2d", ".2d", ".2s",
5005 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i32 V64:$Rm)))]>;
5006 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
5008 asm#"2", ".2d", ".2d", ".4s",
5009 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
5010 (extract_high_v4i32 V128:$Rm)))]>;
5013 //----------------------------------------------------------------------------
5014 // AdvSIMD bitwise extract from vector
5015 //----------------------------------------------------------------------------
5017 class BaseSIMDBitwiseExtract<bit size, RegisterOperand regtype, ValueType vty,
5018 string asm, string kind>
5019 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, i32imm:$imm), asm,
5020 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $imm" #
5021 "|" # kind # "\t$Rd, $Rn, $Rm, $imm}", "",
5022 [(set (vty regtype:$Rd),
5023 (ARM64ext regtype:$Rn, regtype:$Rm, (i32 imm:$imm)))]>,
5030 let Inst{30} = size;
5031 let Inst{29-21} = 0b101110000;
5032 let Inst{20-16} = Rm;
5034 let Inst{14-11} = imm;
5041 multiclass SIMDBitwiseExtract<string asm> {
5042 def v8i8 : BaseSIMDBitwiseExtract<0, V64, v8i8, asm, ".8b"> {
5045 def v16i8 : BaseSIMDBitwiseExtract<1, V128, v16i8, asm, ".16b">;
5048 //----------------------------------------------------------------------------
5049 // AdvSIMD zip vector
5050 //----------------------------------------------------------------------------
5052 class BaseSIMDZipVector<bits<3> size, bits<3> opc, RegisterOperand regtype,
5053 string asm, string kind, SDNode OpNode, ValueType valty>
5054 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
5055 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
5056 "|" # kind # "\t$Rd, $Rn, $Rm}", "",
5057 [(set (valty regtype:$Rd), (OpNode regtype:$Rn, regtype:$Rm))]>,
5063 let Inst{30} = size{0};
5064 let Inst{29-24} = 0b001110;
5065 let Inst{23-22} = size{2-1};
5067 let Inst{20-16} = Rm;
5069 let Inst{14-12} = opc;
5070 let Inst{11-10} = 0b10;
5075 multiclass SIMDZipVector<bits<3>opc, string asm,
5077 def v8i8 : BaseSIMDZipVector<0b000, opc, V64,
5078 asm, ".8b", OpNode, v8i8>;
5079 def v16i8 : BaseSIMDZipVector<0b001, opc, V128,
5080 asm, ".16b", OpNode, v16i8>;
5081 def v4i16 : BaseSIMDZipVector<0b010, opc, V64,
5082 asm, ".4h", OpNode, v4i16>;
5083 def v8i16 : BaseSIMDZipVector<0b011, opc, V128,
5084 asm, ".8h", OpNode, v8i16>;
5085 def v2i32 : BaseSIMDZipVector<0b100, opc, V64,
5086 asm, ".2s", OpNode, v2i32>;
5087 def v4i32 : BaseSIMDZipVector<0b101, opc, V128,
5088 asm, ".4s", OpNode, v4i32>;
5089 def v2i64 : BaseSIMDZipVector<0b111, opc, V128,
5090 asm, ".2d", OpNode, v2i64>;
5092 def : Pat<(v2f32 (OpNode V64:$Rn, V64:$Rm)),
5093 (!cast<Instruction>(NAME#"v2i32") V64:$Rn, V64:$Rm)>;
5094 def : Pat<(v4f32 (OpNode V128:$Rn, V128:$Rm)),
5095 (!cast<Instruction>(NAME#"v4i32") V128:$Rn, V128:$Rm)>;
5096 def : Pat<(v2f64 (OpNode V128:$Rn, V128:$Rm)),
5097 (!cast<Instruction>(NAME#"v2i64") V128:$Rn, V128:$Rm)>;
5100 //----------------------------------------------------------------------------
5101 // AdvSIMD three register scalar instructions
5102 //----------------------------------------------------------------------------
5104 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5105 class BaseSIMDThreeScalar<bit U, bits<2> size, bits<5> opcode,
5106 RegisterClass regtype, string asm,
5108 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
5109 "\t$Rd, $Rn, $Rm", "", pattern>,
5114 let Inst{31-30} = 0b01;
5116 let Inst{28-24} = 0b11110;
5117 let Inst{23-22} = size;
5119 let Inst{20-16} = Rm;
5120 let Inst{15-11} = opcode;
5126 multiclass SIMDThreeScalarD<bit U, bits<5> opc, string asm,
5127 SDPatternOperator OpNode> {
5128 def v1i64 : BaseSIMDThreeScalar<U, 0b11, opc, FPR64, asm,
5129 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
5132 multiclass SIMDThreeScalarBHSD<bit U, bits<5> opc, string asm,
5133 SDPatternOperator OpNode> {
5134 def v1i64 : BaseSIMDThreeScalar<U, 0b11, opc, FPR64, asm,
5135 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
5136 def v1i32 : BaseSIMDThreeScalar<U, 0b10, opc, FPR32, asm, []>;
5137 def v1i16 : BaseSIMDThreeScalar<U, 0b01, opc, FPR16, asm, []>;
5138 def v1i8 : BaseSIMDThreeScalar<U, 0b00, opc, FPR8 , asm, []>;
5140 def : Pat<(i64 (OpNode (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5141 (!cast<Instruction>(NAME#"v1i64") FPR64:$Rn, FPR64:$Rm)>;
5142 def : Pat<(i32 (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm))),
5143 (!cast<Instruction>(NAME#"v1i32") FPR32:$Rn, FPR32:$Rm)>;
5146 multiclass SIMDThreeScalarHS<bit U, bits<5> opc, string asm,
5147 SDPatternOperator OpNode> {
5148 def v1i32 : BaseSIMDThreeScalar<U, 0b10, opc, FPR32, asm,
5149 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
5150 def v1i16 : BaseSIMDThreeScalar<U, 0b01, opc, FPR16, asm, []>;
5153 multiclass SIMDThreeScalarSD<bit U, bit S, bits<5> opc, string asm,
5154 SDPatternOperator OpNode = null_frag> {
5155 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5156 def #NAME#64 : BaseSIMDThreeScalar<U, {S,1}, opc, FPR64, asm,
5157 [(set (f64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
5158 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0}, opc, FPR32, asm,
5159 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
5162 def : Pat<(v1f64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
5163 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
5166 multiclass SIMDThreeScalarFPCmp<bit U, bit S, bits<5> opc, string asm,
5167 SDPatternOperator OpNode = null_frag> {
5168 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5169 def #NAME#64 : BaseSIMDThreeScalar<U, {S,1}, opc, FPR64, asm,
5170 [(set (i64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
5171 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0}, opc, FPR32, asm,
5172 [(set (i32 FPR32:$Rd), (OpNode (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]>;
5175 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
5176 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
5179 class BaseSIMDThreeScalarMixed<bit U, bits<2> size, bits<5> opcode,
5180 dag oops, dag iops, string asm, string cstr, list<dag> pat>
5181 : I<oops, iops, asm,
5182 "\t$Rd, $Rn, $Rm", cstr, pat>,
5187 let Inst{31-30} = 0b01;
5189 let Inst{28-24} = 0b11110;
5190 let Inst{23-22} = size;
5192 let Inst{20-16} = Rm;
5193 let Inst{15-11} = opcode;
5199 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5200 multiclass SIMDThreeScalarMixedHS<bit U, bits<5> opc, string asm,
5201 SDPatternOperator OpNode = null_frag> {
5202 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
5204 (ins FPR16:$Rn, FPR16:$Rm), asm, "", []>;
5205 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
5207 (ins FPR32:$Rn, FPR32:$Rm), asm, "",
5208 [(set (i64 FPR64:$Rd), (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
5211 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5212 multiclass SIMDThreeScalarMixedTiedHS<bit U, bits<5> opc, string asm,
5213 SDPatternOperator OpNode = null_frag> {
5214 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
5216 (ins FPR32:$Rd, FPR16:$Rn, FPR16:$Rm),
5217 asm, "$Rd = $dst", []>;
5218 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
5220 (ins FPR64:$Rd, FPR32:$Rn, FPR32:$Rm),
5222 [(set (i64 FPR64:$dst),
5223 (OpNode (i64 FPR64:$Rd), (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
5226 //----------------------------------------------------------------------------
5227 // AdvSIMD two register scalar instructions
5228 //----------------------------------------------------------------------------
5230 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5231 class BaseSIMDTwoScalar<bit U, bits<2> size, bits<5> opcode,
5232 RegisterClass regtype, RegisterClass regtype2,
5233 string asm, list<dag> pat>
5234 : I<(outs regtype:$Rd), (ins regtype2:$Rn), asm,
5235 "\t$Rd, $Rn", "", pat>,
5239 let Inst{31-30} = 0b01;
5241 let Inst{28-24} = 0b11110;
5242 let Inst{23-22} = size;
5243 let Inst{21-17} = 0b10000;
5244 let Inst{16-12} = opcode;
5245 let Inst{11-10} = 0b10;
5250 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5251 class BaseSIMDTwoScalarTied<bit U, bits<2> size, bits<5> opcode,
5252 RegisterClass regtype, RegisterClass regtype2,
5253 string asm, list<dag> pat>
5254 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype2:$Rn), asm,
5255 "\t$Rd, $Rn", "$Rd = $dst", pat>,
5259 let Inst{31-30} = 0b01;
5261 let Inst{28-24} = 0b11110;
5262 let Inst{23-22} = size;
5263 let Inst{21-17} = 0b10000;
5264 let Inst{16-12} = opcode;
5265 let Inst{11-10} = 0b10;
5271 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5272 class BaseSIMDCmpTwoScalar<bit U, bits<2> size, bits<5> opcode,
5273 RegisterClass regtype, string asm, string zero>
5274 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
5275 "\t$Rd, $Rn, #" # zero, "", []>,
5279 let Inst{31-30} = 0b01;
5281 let Inst{28-24} = 0b11110;
5282 let Inst{23-22} = size;
5283 let Inst{21-17} = 0b10000;
5284 let Inst{16-12} = opcode;
5285 let Inst{11-10} = 0b10;
5290 class SIMDInexactCvtTwoScalar<bits<5> opcode, string asm>
5291 : I<(outs FPR32:$Rd), (ins FPR64:$Rn), asm, "\t$Rd, $Rn", "",
5292 [(set (f32 FPR32:$Rd), (int_arm64_sisd_fcvtxn (f64 FPR64:$Rn)))]>,
5296 let Inst{31-17} = 0b011111100110000;
5297 let Inst{16-12} = opcode;
5298 let Inst{11-10} = 0b10;
5303 multiclass SIMDCmpTwoScalarD<bit U, bits<5> opc, string asm,
5304 SDPatternOperator OpNode> {
5305 def v1i64rz : BaseSIMDCmpTwoScalar<U, 0b11, opc, FPR64, asm, "0">;
5307 def : Pat<(v1i64 (OpNode FPR64:$Rn)),
5308 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
5311 multiclass SIMDCmpTwoScalarSD<bit U, bit S, bits<5> opc, string asm,
5312 SDPatternOperator OpNode> {
5313 def v1i64rz : BaseSIMDCmpTwoScalar<U, {S,1}, opc, FPR64, asm, "0.0">;
5314 def v1i32rz : BaseSIMDCmpTwoScalar<U, {S,0}, opc, FPR32, asm, "0.0">;
5316 def : InstAlias<asm # " $Rd, $Rn, #0",
5317 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rd, FPR64:$Rn)>;
5318 def : InstAlias<asm # " $Rd, $Rn, #0",
5319 (!cast<Instruction>(NAME # v1i32rz) FPR32:$Rd, FPR32:$Rn)>;
5321 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn))),
5322 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
5325 multiclass SIMDTwoScalarD<bit U, bits<5> opc, string asm,
5326 SDPatternOperator OpNode = null_frag> {
5327 def v1i64 : BaseSIMDTwoScalar<U, 0b11, opc, FPR64, FPR64, asm,
5328 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn)))]>;
5330 def : Pat<(i64 (OpNode (i64 FPR64:$Rn))),
5331 (!cast<Instruction>(NAME # "v1i64") FPR64:$Rn)>;
5334 multiclass SIMDTwoScalarSD<bit U, bit S, bits<5> opc, string asm> {
5335 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, opc, FPR64, FPR64, asm,[]>;
5336 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, opc, FPR32, FPR32, asm,[]>;
5339 multiclass SIMDTwoScalarCVTSD<bit U, bit S, bits<5> opc, string asm,
5340 SDPatternOperator OpNode> {
5341 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, opc, FPR64, FPR64, asm,
5342 [(set FPR64:$Rd, (OpNode (f64 FPR64:$Rn)))]>;
5343 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, opc, FPR32, FPR32, asm,
5344 [(set FPR32:$Rd, (OpNode (f32 FPR32:$Rn)))]>;
5347 multiclass SIMDTwoScalarBHSD<bit U, bits<5> opc, string asm,
5348 SDPatternOperator OpNode = null_frag> {
5349 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5350 def v1i64 : BaseSIMDTwoScalar<U, 0b11, opc, FPR64, FPR64, asm,
5351 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
5352 def v1i32 : BaseSIMDTwoScalar<U, 0b10, opc, FPR32, FPR32, asm,
5353 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
5354 def v1i16 : BaseSIMDTwoScalar<U, 0b01, opc, FPR16, FPR16, asm, []>;
5355 def v1i8 : BaseSIMDTwoScalar<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
5358 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn))),
5359 (!cast<Instruction>(NAME # v1i64) FPR64:$Rn)>;
5362 multiclass SIMDTwoScalarBHSDTied<bit U, bits<5> opc, string asm,
5364 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5365 def v1i64 : BaseSIMDTwoScalarTied<U, 0b11, opc, FPR64, FPR64, asm,
5366 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn)))]>;
5367 def v1i32 : BaseSIMDTwoScalarTied<U, 0b10, opc, FPR32, FPR32, asm,
5368 [(set (i32 FPR32:$dst), (OpNode (i32 FPR32:$Rd), (i32 FPR32:$Rn)))]>;
5369 def v1i16 : BaseSIMDTwoScalarTied<U, 0b01, opc, FPR16, FPR16, asm, []>;
5370 def v1i8 : BaseSIMDTwoScalarTied<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
5373 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn))),
5374 (!cast<Instruction>(NAME # v1i64) FPR64:$Rd, FPR64:$Rn)>;
5379 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5380 multiclass SIMDTwoScalarMixedBHS<bit U, bits<5> opc, string asm,
5381 SDPatternOperator OpNode = null_frag> {
5382 def v1i32 : BaseSIMDTwoScalar<U, 0b10, opc, FPR32, FPR64, asm,
5383 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
5384 def v1i16 : BaseSIMDTwoScalar<U, 0b01, opc, FPR16, FPR32, asm, []>;
5385 def v1i8 : BaseSIMDTwoScalar<U, 0b00, opc, FPR8 , FPR16, asm, []>;
5388 //----------------------------------------------------------------------------
5389 // AdvSIMD scalar pairwise instructions
5390 //----------------------------------------------------------------------------
5392 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5393 class BaseSIMDPairwiseScalar<bit U, bits<2> size, bits<5> opcode,
5394 RegisterOperand regtype, RegisterOperand vectype,
5395 string asm, string kind>
5396 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
5397 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", []>,
5401 let Inst{31-30} = 0b01;
5403 let Inst{28-24} = 0b11110;
5404 let Inst{23-22} = size;
5405 let Inst{21-17} = 0b11000;
5406 let Inst{16-12} = opcode;
5407 let Inst{11-10} = 0b10;
5412 multiclass SIMDPairwiseScalarD<bit U, bits<5> opc, string asm> {
5413 def v2i64p : BaseSIMDPairwiseScalar<U, 0b11, opc, FPR64Op, V128,
5417 multiclass SIMDPairwiseScalarSD<bit U, bit S, bits<5> opc, string asm> {
5418 def v2i32p : BaseSIMDPairwiseScalar<U, {S,0}, opc, FPR32Op, V64,
5420 def v2i64p : BaseSIMDPairwiseScalar<U, {S,1}, opc, FPR64Op, V128,
5424 //----------------------------------------------------------------------------
5425 // AdvSIMD across lanes instructions
5426 //----------------------------------------------------------------------------
5428 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5429 class BaseSIMDAcrossLanes<bit Q, bit U, bits<2> size, bits<5> opcode,
5430 RegisterClass regtype, RegisterOperand vectype,
5431 string asm, string kind, list<dag> pattern>
5432 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
5433 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", pattern>,
5440 let Inst{28-24} = 0b01110;
5441 let Inst{23-22} = size;
5442 let Inst{21-17} = 0b11000;
5443 let Inst{16-12} = opcode;
5444 let Inst{11-10} = 0b10;
5449 multiclass SIMDAcrossLanesBHS<bit U, bits<5> opcode,
5451 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR8, V64,
5453 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR8, V128,
5455 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR16, V64,
5457 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR16, V128,
5459 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR32, V128,
5463 multiclass SIMDAcrossLanesHSD<bit U, bits<5> opcode, string asm> {
5464 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR16, V64,
5466 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR16, V128,
5468 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR32, V64,
5470 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR32, V128,
5472 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR64, V128,
5476 multiclass SIMDAcrossLanesS<bits<5> opcode, bit sz1, string asm,
5478 def v4i32v : BaseSIMDAcrossLanes<1, 1, {sz1, 0}, opcode, FPR32, V128,
5480 [(set FPR32:$Rd, (intOp (v4f32 V128:$Rn)))]>;
5483 //----------------------------------------------------------------------------
5484 // AdvSIMD INS/DUP instructions
5485 //----------------------------------------------------------------------------
5487 // FIXME: There has got to be a better way to factor these. ugh.
5489 class BaseSIMDInsDup<bit Q, bit op, dag outs, dag ins, string asm,
5490 string operands, string constraints, list<dag> pattern>
5491 : I<outs, ins, asm, operands, constraints, pattern>,
5498 let Inst{28-21} = 0b01110000;
5505 class SIMDDupFromMain<bit Q, bits<5> imm5, string size, ValueType vectype,
5506 RegisterOperand vecreg, RegisterClass regtype>
5507 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins regtype:$Rn), "dup",
5508 "{\t$Rd" # size # ", $Rn" #
5509 "|" # size # "\t$Rd, $Rn}", "",
5510 [(set (vectype vecreg:$Rd), (ARM64dup regtype:$Rn))]> {
5511 let Inst{20-16} = imm5;
5512 let Inst{14-11} = 0b0001;
5515 class SIMDDupFromElement<bit Q, string dstkind, string srckind,
5516 ValueType vectype, ValueType insreg,
5517 RegisterOperand vecreg, Operand idxtype,
5518 ValueType elttype, SDNode OpNode>
5519 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins V128:$Rn, idxtype:$idx), "dup",
5520 "{\t$Rd" # dstkind # ", $Rn" # srckind # "$idx" #
5521 "|" # dstkind # "\t$Rd, $Rn$idx}", "",
5522 [(set (vectype vecreg:$Rd),
5523 (OpNode (insreg V128:$Rn), idxtype:$idx))]> {
5524 let Inst{14-11} = 0b0000;
5527 class SIMDDup64FromElement
5528 : SIMDDupFromElement<1, ".2d", ".d", v2i64, v2i64, V128,
5529 VectorIndexD, i64, ARM64duplane64> {
5532 let Inst{19-16} = 0b1000;
5535 class SIMDDup32FromElement<bit Q, string size, ValueType vectype,
5536 RegisterOperand vecreg>
5537 : SIMDDupFromElement<Q, size, ".s", vectype, v4i32, vecreg,
5538 VectorIndexS, i64, ARM64duplane32> {
5540 let Inst{20-19} = idx;
5541 let Inst{18-16} = 0b100;
5544 class SIMDDup16FromElement<bit Q, string size, ValueType vectype,
5545 RegisterOperand vecreg>
5546 : SIMDDupFromElement<Q, size, ".h", vectype, v8i16, vecreg,
5547 VectorIndexH, i64, ARM64duplane16> {
5549 let Inst{20-18} = idx;
5550 let Inst{17-16} = 0b10;
5553 class SIMDDup8FromElement<bit Q, string size, ValueType vectype,
5554 RegisterOperand vecreg>
5555 : SIMDDupFromElement<Q, size, ".b", vectype, v16i8, vecreg,
5556 VectorIndexB, i64, ARM64duplane8> {
5558 let Inst{20-17} = idx;
5562 class BaseSIMDMov<bit Q, string size, bits<4> imm4, RegisterClass regtype,
5563 Operand idxtype, string asm, list<dag> pattern>
5564 : BaseSIMDInsDup<Q, 0, (outs regtype:$Rd), (ins V128:$Rn, idxtype:$idx), asm,
5565 "{\t$Rd, $Rn" # size # "$idx" #
5566 "|" # size # "\t$Rd, $Rn$idx}", "", pattern> {
5567 let Inst{14-11} = imm4;
5570 class SIMDSMov<bit Q, string size, RegisterClass regtype,
5572 : BaseSIMDMov<Q, size, 0b0101, regtype, idxtype, "smov", []>;
5573 class SIMDUMov<bit Q, string size, ValueType vectype, RegisterClass regtype,
5575 : BaseSIMDMov<Q, size, 0b0111, regtype, idxtype, "umov",
5576 [(set regtype:$Rd, (vector_extract (vectype V128:$Rn), idxtype:$idx))]>;
5578 // FIXME: these aliases should be canonical, but TableGen can't handle the
5579 // alternate syntaxes.
5580 class SIMDMovAlias<string asm, string size, Instruction inst,
5581 RegisterClass regtype, Operand idxtype>
5582 : InstAlias<asm#"{\t$dst, $src"#size#"$idx" #
5583 "|" # size # "\t$dst, $src$idx}",
5584 (inst regtype:$dst, V128:$src, idxtype:$idx), 0>;
5587 def vi8to32 : SIMDSMov<0, ".b", GPR32, VectorIndexB> {
5589 let Inst{20-17} = idx;
5592 def vi8to64 : SIMDSMov<1, ".b", GPR64, VectorIndexB> {
5594 let Inst{20-17} = idx;
5597 def vi16to32 : SIMDSMov<0, ".h", GPR32, VectorIndexH> {
5599 let Inst{20-18} = idx;
5600 let Inst{17-16} = 0b10;
5602 def vi16to64 : SIMDSMov<1, ".h", GPR64, VectorIndexH> {
5604 let Inst{20-18} = idx;
5605 let Inst{17-16} = 0b10;
5607 def vi32to64 : SIMDSMov<1, ".s", GPR64, VectorIndexS> {
5609 let Inst{20-19} = idx;
5610 let Inst{18-16} = 0b100;
5615 def vi8 : SIMDUMov<0, ".b", v16i8, GPR32, VectorIndexB> {
5617 let Inst{20-17} = idx;
5620 def vi16 : SIMDUMov<0, ".h", v8i16, GPR32, VectorIndexH> {
5622 let Inst{20-18} = idx;
5623 let Inst{17-16} = 0b10;
5625 def vi32 : SIMDUMov<0, ".s", v4i32, GPR32, VectorIndexS> {
5627 let Inst{20-19} = idx;
5628 let Inst{18-16} = 0b100;
5630 def vi64 : SIMDUMov<1, ".d", v2i64, GPR64, VectorIndexD> {
5633 let Inst{19-16} = 0b1000;
5635 def : SIMDMovAlias<"mov", ".s",
5636 !cast<Instruction>(NAME#"vi32"),
5637 GPR32, VectorIndexS>;
5638 def : SIMDMovAlias<"mov", ".d",
5639 !cast<Instruction>(NAME#"vi64"),
5640 GPR64, VectorIndexD>;
5643 class SIMDInsFromMain<string size, ValueType vectype,
5644 RegisterClass regtype, Operand idxtype>
5645 : BaseSIMDInsDup<1, 0, (outs V128:$dst),
5646 (ins V128:$Rd, idxtype:$idx, regtype:$Rn), "ins",
5647 "{\t$Rd" # size # "$idx, $Rn" #
5648 "|" # size # "\t$Rd$idx, $Rn}",
5651 (vector_insert (vectype V128:$Rd), regtype:$Rn, idxtype:$idx))]> {
5652 let Inst{14-11} = 0b0011;
5655 class SIMDInsFromElement<string size, ValueType vectype,
5656 ValueType elttype, Operand idxtype>
5657 : BaseSIMDInsDup<1, 1, (outs V128:$dst),
5658 (ins V128:$Rd, idxtype:$idx, V128:$Rn, idxtype:$idx2), "ins",
5659 "{\t$Rd" # size # "$idx, $Rn" # size # "$idx2" #
5660 "|" # size # "\t$Rd$idx, $Rn$idx2}",
5665 (elttype (vector_extract (vectype V128:$Rn), idxtype:$idx2)),
5668 // FIXME: the MOVs should be canonical, but TableGen's alias printing can't cope
5669 // with syntax variants.
5670 class SIMDInsMainMovAlias<string size, Instruction inst,
5671 RegisterClass regtype, Operand idxtype>
5672 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" #
5673 "|" # size #"\t$dst$idx, $src}",
5674 (inst V128:$dst, idxtype:$idx, regtype:$src), 0>;
5675 class SIMDInsElementMovAlias<string size, Instruction inst,
5677 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" # size # "$idx2" #
5678 # "|" # size #" $dst$idx, $src$idx2}",
5679 (inst V128:$dst, idxtype:$idx, V128:$src, idxtype:$idx2), 0>;
5682 multiclass SIMDIns {
5683 def vi8gpr : SIMDInsFromMain<".b", v16i8, GPR32, VectorIndexB> {
5685 let Inst{20-17} = idx;
5688 def vi16gpr : SIMDInsFromMain<".h", v8i16, GPR32, VectorIndexH> {
5690 let Inst{20-18} = idx;
5691 let Inst{17-16} = 0b10;
5693 def vi32gpr : SIMDInsFromMain<".s", v4i32, GPR32, VectorIndexS> {
5695 let Inst{20-19} = idx;
5696 let Inst{18-16} = 0b100;
5698 def vi64gpr : SIMDInsFromMain<".d", v2i64, GPR64, VectorIndexD> {
5701 let Inst{19-16} = 0b1000;
5704 def vi8lane : SIMDInsFromElement<".b", v16i8, i32, VectorIndexB> {
5707 let Inst{20-17} = idx;
5709 let Inst{14-11} = idx2;
5711 def vi16lane : SIMDInsFromElement<".h", v8i16, i32, VectorIndexH> {
5714 let Inst{20-18} = idx;
5715 let Inst{17-16} = 0b10;
5716 let Inst{14-12} = idx2;
5719 def vi32lane : SIMDInsFromElement<".s", v4i32, i32, VectorIndexS> {
5722 let Inst{20-19} = idx;
5723 let Inst{18-16} = 0b100;
5724 let Inst{14-13} = idx2;
5725 let Inst{12-11} = 0;
5727 def vi64lane : SIMDInsFromElement<".d", v2i64, i64, VectorIndexD> {
5731 let Inst{19-16} = 0b1000;
5732 let Inst{14} = idx2;
5733 let Inst{13-11} = 0;
5736 // For all forms of the INS instruction, the "mov" mnemonic is the
5737 // preferred alias. Why they didn't just call the instruction "mov" in
5738 // the first place is a very good question indeed...
5739 def : SIMDInsMainMovAlias<".b", !cast<Instruction>(NAME#"vi8gpr"),
5740 GPR32, VectorIndexB>;
5741 def : SIMDInsMainMovAlias<".h", !cast<Instruction>(NAME#"vi16gpr"),
5742 GPR32, VectorIndexH>;
5743 def : SIMDInsMainMovAlias<".s", !cast<Instruction>(NAME#"vi32gpr"),
5744 GPR32, VectorIndexS>;
5745 def : SIMDInsMainMovAlias<".d", !cast<Instruction>(NAME#"vi64gpr"),
5746 GPR64, VectorIndexD>;
5748 def : SIMDInsElementMovAlias<".b", !cast<Instruction>(NAME#"vi8lane"),
5750 def : SIMDInsElementMovAlias<".h", !cast<Instruction>(NAME#"vi16lane"),
5752 def : SIMDInsElementMovAlias<".s", !cast<Instruction>(NAME#"vi32lane"),
5754 def : SIMDInsElementMovAlias<".d", !cast<Instruction>(NAME#"vi64lane"),
5758 //----------------------------------------------------------------------------
5760 //----------------------------------------------------------------------------
5762 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5763 class BaseSIMDTableLookup<bit Q, bits<2> len, bit op, RegisterOperand vectype,
5764 RegisterOperand listtype, string asm, string kind>
5765 : I<(outs vectype:$Vd), (ins listtype:$Vn, vectype:$Vm), asm,
5766 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "", []>,
5773 let Inst{29-21} = 0b001110000;
5774 let Inst{20-16} = Vm;
5776 let Inst{14-13} = len;
5778 let Inst{11-10} = 0b00;
5783 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5784 class BaseSIMDTableLookupTied<bit Q, bits<2> len, bit op, RegisterOperand vectype,
5785 RegisterOperand listtype, string asm, string kind>
5786 : I<(outs vectype:$dst), (ins vectype:$Vd, listtype:$Vn, vectype:$Vm), asm,
5787 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "$Vd = $dst", []>,
5794 let Inst{29-21} = 0b001110000;
5795 let Inst{20-16} = Vm;
5797 let Inst{14-13} = len;
5799 let Inst{11-10} = 0b00;
5804 class SIMDTableLookupAlias<string asm, Instruction inst,
5805 RegisterOperand vectype, RegisterOperand listtype>
5806 : InstAlias<!strconcat(asm, "\t$dst, $lst, $index"),
5807 (inst vectype:$dst, listtype:$lst, vectype:$index), 0>;
5809 multiclass SIMDTableLookup<bit op, string asm> {
5810 def v8i8One : BaseSIMDTableLookup<0, 0b00, op, V64, VecListOne16b,
5812 def v8i8Two : BaseSIMDTableLookup<0, 0b01, op, V64, VecListTwo16b,
5814 def v8i8Three : BaseSIMDTableLookup<0, 0b10, op, V64, VecListThree16b,
5816 def v8i8Four : BaseSIMDTableLookup<0, 0b11, op, V64, VecListFour16b,
5818 def v16i8One : BaseSIMDTableLookup<1, 0b00, op, V128, VecListOne16b,
5820 def v16i8Two : BaseSIMDTableLookup<1, 0b01, op, V128, VecListTwo16b,
5822 def v16i8Three: BaseSIMDTableLookup<1, 0b10, op, V128, VecListThree16b,
5824 def v16i8Four : BaseSIMDTableLookup<1, 0b11, op, V128, VecListFour16b,
5827 def : SIMDTableLookupAlias<asm # ".8b",
5828 !cast<Instruction>(NAME#"v8i8One"),
5829 V64, VecListOne128>;
5830 def : SIMDTableLookupAlias<asm # ".8b",
5831 !cast<Instruction>(NAME#"v8i8Two"),
5832 V64, VecListTwo128>;
5833 def : SIMDTableLookupAlias<asm # ".8b",
5834 !cast<Instruction>(NAME#"v8i8Three"),
5835 V64, VecListThree128>;
5836 def : SIMDTableLookupAlias<asm # ".8b",
5837 !cast<Instruction>(NAME#"v8i8Four"),
5838 V64, VecListFour128>;
5839 def : SIMDTableLookupAlias<asm # ".16b",
5840 !cast<Instruction>(NAME#"v16i8One"),
5841 V128, VecListOne128>;
5842 def : SIMDTableLookupAlias<asm # ".16b",
5843 !cast<Instruction>(NAME#"v16i8Two"),
5844 V128, VecListTwo128>;
5845 def : SIMDTableLookupAlias<asm # ".16b",
5846 !cast<Instruction>(NAME#"v16i8Three"),
5847 V128, VecListThree128>;
5848 def : SIMDTableLookupAlias<asm # ".16b",
5849 !cast<Instruction>(NAME#"v16i8Four"),
5850 V128, VecListFour128>;
5853 multiclass SIMDTableLookupTied<bit op, string asm> {
5854 def v8i8One : BaseSIMDTableLookupTied<0, 0b00, op, V64, VecListOne16b,
5856 def v8i8Two : BaseSIMDTableLookupTied<0, 0b01, op, V64, VecListTwo16b,
5858 def v8i8Three : BaseSIMDTableLookupTied<0, 0b10, op, V64, VecListThree16b,
5860 def v8i8Four : BaseSIMDTableLookupTied<0, 0b11, op, V64, VecListFour16b,
5862 def v16i8One : BaseSIMDTableLookupTied<1, 0b00, op, V128, VecListOne16b,
5864 def v16i8Two : BaseSIMDTableLookupTied<1, 0b01, op, V128, VecListTwo16b,
5866 def v16i8Three: BaseSIMDTableLookupTied<1, 0b10, op, V128, VecListThree16b,
5868 def v16i8Four : BaseSIMDTableLookupTied<1, 0b11, op, V128, VecListFour16b,
5871 def : SIMDTableLookupAlias<asm # ".8b",
5872 !cast<Instruction>(NAME#"v8i8One"),
5873 V64, VecListOne128>;
5874 def : SIMDTableLookupAlias<asm # ".8b",
5875 !cast<Instruction>(NAME#"v8i8Two"),
5876 V64, VecListTwo128>;
5877 def : SIMDTableLookupAlias<asm # ".8b",
5878 !cast<Instruction>(NAME#"v8i8Three"),
5879 V64, VecListThree128>;
5880 def : SIMDTableLookupAlias<asm # ".8b",
5881 !cast<Instruction>(NAME#"v8i8Four"),
5882 V64, VecListFour128>;
5883 def : SIMDTableLookupAlias<asm # ".16b",
5884 !cast<Instruction>(NAME#"v16i8One"),
5885 V128, VecListOne128>;
5886 def : SIMDTableLookupAlias<asm # ".16b",
5887 !cast<Instruction>(NAME#"v16i8Two"),
5888 V128, VecListTwo128>;
5889 def : SIMDTableLookupAlias<asm # ".16b",
5890 !cast<Instruction>(NAME#"v16i8Three"),
5891 V128, VecListThree128>;
5892 def : SIMDTableLookupAlias<asm # ".16b",
5893 !cast<Instruction>(NAME#"v16i8Four"),
5894 V128, VecListFour128>;
5898 //----------------------------------------------------------------------------
5899 // AdvSIMD scalar CPY
5900 //----------------------------------------------------------------------------
5901 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5902 class BaseSIMDScalarCPY<RegisterClass regtype, RegisterOperand vectype,
5903 string kind, Operand idxtype>
5904 : I<(outs regtype:$dst), (ins vectype:$src, idxtype:$idx), "mov",
5905 "{\t$dst, $src" # kind # "$idx" #
5906 "|\t$dst, $src$idx}", "", []>,
5910 let Inst{31-21} = 0b01011110000;
5911 let Inst{15-10} = 0b000001;
5912 let Inst{9-5} = src;
5913 let Inst{4-0} = dst;
5916 class SIMDScalarCPYAlias<string asm, string size, Instruction inst,
5917 RegisterClass regtype, RegisterOperand vectype, Operand idxtype>
5918 : InstAlias<asm # "{\t$dst, $src" # size # "$index" #
5919 # "|\t$dst, $src$index}",
5920 (inst regtype:$dst, vectype:$src, idxtype:$index), 0>;
5923 multiclass SIMDScalarCPY<string asm> {
5924 def i8 : BaseSIMDScalarCPY<FPR8, V128, ".b", VectorIndexB> {
5926 let Inst{20-17} = idx;
5929 def i16 : BaseSIMDScalarCPY<FPR16, V128, ".h", VectorIndexH> {
5931 let Inst{20-18} = idx;
5932 let Inst{17-16} = 0b10;
5934 def i32 : BaseSIMDScalarCPY<FPR32, V128, ".s", VectorIndexS> {
5936 let Inst{20-19} = idx;
5937 let Inst{18-16} = 0b100;
5939 def i64 : BaseSIMDScalarCPY<FPR64, V128, ".d", VectorIndexD> {
5942 let Inst{19-16} = 0b1000;
5945 def : Pat<(v1i64 (scalar_to_vector (i64 (vector_extract (v2i64 V128:$src),
5946 VectorIndexD:$idx)))),
5947 (!cast<Instruction>(NAME # i64) V128:$src, VectorIndexD:$idx)>;
5949 // 'DUP' mnemonic aliases.
5950 def : SIMDScalarCPYAlias<"dup", ".b",
5951 !cast<Instruction>(NAME#"i8"),
5952 FPR8, V128, VectorIndexB>;
5953 def : SIMDScalarCPYAlias<"dup", ".h",
5954 !cast<Instruction>(NAME#"i16"),
5955 FPR16, V128, VectorIndexH>;
5956 def : SIMDScalarCPYAlias<"dup", ".s",
5957 !cast<Instruction>(NAME#"i32"),
5958 FPR32, V128, VectorIndexS>;
5959 def : SIMDScalarCPYAlias<"dup", ".d",
5960 !cast<Instruction>(NAME#"i64"),
5961 FPR64, V128, VectorIndexD>;
5964 //----------------------------------------------------------------------------
5965 // AdvSIMD modified immediate instructions
5966 //----------------------------------------------------------------------------
5968 class BaseSIMDModifiedImm<bit Q, bit op, dag oops, dag iops,
5969 string asm, string op_string,
5970 string cstr, list<dag> pattern>
5971 : I<oops, iops, asm, op_string, cstr, pattern>,
5978 let Inst{28-19} = 0b0111100000;
5979 let Inst{18-16} = imm8{7-5};
5980 let Inst{11-10} = 0b01;
5981 let Inst{9-5} = imm8{4-0};
5985 class BaseSIMDModifiedImmVector<bit Q, bit op, RegisterOperand vectype,
5986 Operand immtype, dag opt_shift_iop,
5987 string opt_shift, string asm, string kind,
5989 : BaseSIMDModifiedImm<Q, op, (outs vectype:$Rd),
5990 !con((ins immtype:$imm8), opt_shift_iop), asm,
5991 "{\t$Rd" # kind # ", $imm8" # opt_shift #
5992 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
5994 let DecoderMethod = "DecodeModImmInstruction";
5997 class BaseSIMDModifiedImmVectorTied<bit Q, bit op, RegisterOperand vectype,
5998 Operand immtype, dag opt_shift_iop,
5999 string opt_shift, string asm, string kind,
6001 : BaseSIMDModifiedImm<Q, op, (outs vectype:$dst),
6002 !con((ins vectype:$Rd, immtype:$imm8), opt_shift_iop),
6003 asm, "{\t$Rd" # kind # ", $imm8" # opt_shift #
6004 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
6005 "$Rd = $dst", pattern> {
6006 let DecoderMethod = "DecodeModImmTiedInstruction";
6009 class BaseSIMDModifiedImmVectorShift<bit Q, bit op, bits<2> b15_b12,
6010 RegisterOperand vectype, string asm,
6011 string kind, list<dag> pattern>
6012 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6013 (ins logical_vec_shift:$shift),
6014 "$shift", asm, kind, pattern> {
6016 let Inst{15} = b15_b12{1};
6017 let Inst{14-13} = shift;
6018 let Inst{12} = b15_b12{0};
6021 class BaseSIMDModifiedImmVectorShiftTied<bit Q, bit op, bits<2> b15_b12,
6022 RegisterOperand vectype, string asm,
6023 string kind, list<dag> pattern>
6024 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
6025 (ins logical_vec_shift:$shift),
6026 "$shift", asm, kind, pattern> {
6028 let Inst{15} = b15_b12{1};
6029 let Inst{14-13} = shift;
6030 let Inst{12} = b15_b12{0};
6034 class BaseSIMDModifiedImmVectorShiftHalf<bit Q, bit op, bits<2> b15_b12,
6035 RegisterOperand vectype, string asm,
6036 string kind, list<dag> pattern>
6037 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6038 (ins logical_vec_hw_shift:$shift),
6039 "$shift", asm, kind, pattern> {
6041 let Inst{15} = b15_b12{1};
6043 let Inst{13} = shift{0};
6044 let Inst{12} = b15_b12{0};
6047 class BaseSIMDModifiedImmVectorShiftHalfTied<bit Q, bit op, bits<2> b15_b12,
6048 RegisterOperand vectype, string asm,
6049 string kind, list<dag> pattern>
6050 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
6051 (ins logical_vec_hw_shift:$shift),
6052 "$shift", asm, kind, pattern> {
6054 let Inst{15} = b15_b12{1};
6056 let Inst{13} = shift{0};
6057 let Inst{12} = b15_b12{0};
6060 multiclass SIMDModifiedImmVectorShift<bit op, bits<2> hw_cmode, bits<2> w_cmode,
6062 def v4i16 : BaseSIMDModifiedImmVectorShiftHalf<0, op, hw_cmode, V64,
6064 def v8i16 : BaseSIMDModifiedImmVectorShiftHalf<1, op, hw_cmode, V128,
6067 def v2i32 : BaseSIMDModifiedImmVectorShift<0, op, w_cmode, V64,
6069 def v4i32 : BaseSIMDModifiedImmVectorShift<1, op, w_cmode, V128,
6073 multiclass SIMDModifiedImmVectorShiftTied<bit op, bits<2> hw_cmode,
6074 bits<2> w_cmode, string asm,
6076 def v4i16 : BaseSIMDModifiedImmVectorShiftHalfTied<0, op, hw_cmode, V64,
6078 [(set (v4i16 V64:$dst), (OpNode V64:$Rd,
6080 (i32 imm:$shift)))]>;
6081 def v8i16 : BaseSIMDModifiedImmVectorShiftHalfTied<1, op, hw_cmode, V128,
6083 [(set (v8i16 V128:$dst), (OpNode V128:$Rd,
6085 (i32 imm:$shift)))]>;
6087 def v2i32 : BaseSIMDModifiedImmVectorShiftTied<0, op, w_cmode, V64,
6089 [(set (v2i32 V64:$dst), (OpNode V64:$Rd,
6091 (i32 imm:$shift)))]>;
6092 def v4i32 : BaseSIMDModifiedImmVectorShiftTied<1, op, w_cmode, V128,
6094 [(set (v4i32 V128:$dst), (OpNode V128:$Rd,
6096 (i32 imm:$shift)))]>;
6099 class SIMDModifiedImmMoveMSL<bit Q, bit op, bits<4> cmode,
6100 RegisterOperand vectype, string asm,
6101 string kind, list<dag> pattern>
6102 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6103 (ins move_vec_shift:$shift),
6104 "$shift", asm, kind, pattern> {
6106 let Inst{15-13} = cmode{3-1};
6107 let Inst{12} = shift;
6110 class SIMDModifiedImmVectorNoShift<bit Q, bit op, bits<4> cmode,
6111 RegisterOperand vectype,
6112 Operand imm_type, string asm,
6113 string kind, list<dag> pattern>
6114 : BaseSIMDModifiedImmVector<Q, op, vectype, imm_type, (ins), "",
6115 asm, kind, pattern> {
6116 let Inst{15-12} = cmode;
6119 class SIMDModifiedImmScalarNoShift<bit Q, bit op, bits<4> cmode, string asm,
6121 : BaseSIMDModifiedImm<Q, op, (outs FPR64:$Rd), (ins simdimmtype10:$imm8), asm,
6122 "\t$Rd, $imm8", "", pattern> {
6123 let Inst{15-12} = cmode;
6124 let DecoderMethod = "DecodeModImmInstruction";
6127 //----------------------------------------------------------------------------
6128 // AdvSIMD indexed element
6129 //----------------------------------------------------------------------------
6131 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6132 class BaseSIMDIndexed<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
6133 RegisterOperand dst_reg, RegisterOperand lhs_reg,
6134 RegisterOperand rhs_reg, Operand vec_idx, string asm,
6135 string apple_kind, string dst_kind, string lhs_kind,
6136 string rhs_kind, list<dag> pattern>
6137 : I<(outs dst_reg:$Rd), (ins lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx),
6139 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
6140 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "", pattern>,
6149 let Inst{28} = Scalar;
6150 let Inst{27-24} = 0b1111;
6151 let Inst{23-22} = size;
6152 // Bit 21 must be set by the derived class.
6153 let Inst{20-16} = Rm;
6154 let Inst{15-12} = opc;
6155 // Bit 11 must be set by the derived class.
6161 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6162 class BaseSIMDIndexedTied<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
6163 RegisterOperand dst_reg, RegisterOperand lhs_reg,
6164 RegisterOperand rhs_reg, Operand vec_idx, string asm,
6165 string apple_kind, string dst_kind, string lhs_kind,
6166 string rhs_kind, list<dag> pattern>
6167 : I<(outs dst_reg:$dst),
6168 (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx), asm,
6169 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
6170 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "$Rd = $dst", pattern>,
6179 let Inst{28} = Scalar;
6180 let Inst{27-24} = 0b1111;
6181 let Inst{23-22} = size;
6182 // Bit 21 must be set by the derived class.
6183 let Inst{20-16} = Rm;
6184 let Inst{15-12} = opc;
6185 // Bit 11 must be set by the derived class.
6191 multiclass SIMDFPIndexedSD<bit U, bits<4> opc, string asm,
6192 SDPatternOperator OpNode> {
6193 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6196 asm, ".2s", ".2s", ".2s", ".s",
6197 [(set (v2f32 V64:$Rd),
6198 (OpNode (v2f32 V64:$Rn),
6199 (v2f32 (ARM64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
6201 let Inst{11} = idx{1};
6202 let Inst{21} = idx{0};
6205 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6208 asm, ".4s", ".4s", ".4s", ".s",
6209 [(set (v4f32 V128:$Rd),
6210 (OpNode (v4f32 V128:$Rn),
6211 (v4f32 (ARM64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
6213 let Inst{11} = idx{1};
6214 let Inst{21} = idx{0};
6217 def v2i64_indexed : BaseSIMDIndexed<1, U, 0, 0b11, opc,
6220 asm, ".2d", ".2d", ".2d", ".d",
6221 [(set (v2f64 V128:$Rd),
6222 (OpNode (v2f64 V128:$Rn),
6223 (v2f64 (ARM64duplane64 (v2f64 V128:$Rm), VectorIndexD:$idx))))]> {
6225 let Inst{11} = idx{0};
6229 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6230 FPR32Op, FPR32Op, V128, VectorIndexS,
6231 asm, ".s", "", "", ".s",
6232 [(set (f32 FPR32Op:$Rd),
6233 (OpNode (f32 FPR32Op:$Rn),
6234 (f32 (vector_extract (v4f32 V128:$Rm),
6235 VectorIndexS:$idx))))]> {
6237 let Inst{11} = idx{1};
6238 let Inst{21} = idx{0};
6241 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b11, opc,
6242 FPR64Op, FPR64Op, V128, VectorIndexD,
6243 asm, ".d", "", "", ".d",
6244 [(set (f64 FPR64Op:$Rd),
6245 (OpNode (f64 FPR64Op:$Rn),
6246 (f64 (vector_extract (v2f64 V128:$Rm),
6247 VectorIndexD:$idx))))]> {
6249 let Inst{11} = idx{0};
6254 multiclass SIMDFPIndexedSDTiedPatterns<string INST, SDPatternOperator OpNode> {
6255 // 2 variants for the .2s version: DUPLANE from 128-bit and DUP scalar.
6256 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
6257 (ARM64duplane32 (v4f32 V128:$Rm),
6258 VectorIndexS:$idx))),
6259 (!cast<Instruction>(INST # v2i32_indexed)
6260 V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6261 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
6262 (ARM64dup (f32 FPR32Op:$Rm)))),
6263 (!cast<Instruction>(INST # "v2i32_indexed") V64:$Rd, V64:$Rn,
6264 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
6267 // 2 variants for the .4s version: DUPLANE from 128-bit and DUP scalar.
6268 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
6269 (ARM64duplane32 (v4f32 V128:$Rm),
6270 VectorIndexS:$idx))),
6271 (!cast<Instruction>(INST # "v4i32_indexed")
6272 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6273 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
6274 (ARM64dup (f32 FPR32Op:$Rm)))),
6275 (!cast<Instruction>(INST # "v4i32_indexed") V128:$Rd, V128:$Rn,
6276 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
6278 // 2 variants for the .2d version: DUPLANE from 128-bit and DUP scalar.
6279 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
6280 (ARM64duplane64 (v2f64 V128:$Rm),
6281 VectorIndexD:$idx))),
6282 (!cast<Instruction>(INST # "v2i64_indexed")
6283 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6284 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
6285 (ARM64dup (f64 FPR64Op:$Rm)))),
6286 (!cast<Instruction>(INST # "v2i64_indexed") V128:$Rd, V128:$Rn,
6287 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
6289 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
6290 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
6291 (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx))),
6292 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
6293 V128:$Rm, VectorIndexS:$idx)>;
6294 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
6295 (vector_extract (v2f32 V64:$Rm), VectorIndexS:$idx))),
6296 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
6297 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
6299 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
6300 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
6301 (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx))),
6302 (!cast<Instruction>(INST # "v1i64_indexed") FPR64:$Rd, FPR64:$Rn,
6303 V128:$Rm, VectorIndexD:$idx)>;
6306 multiclass SIMDFPIndexedSDTied<bit U, bits<4> opc, string asm> {
6307 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64,
6309 asm, ".2s", ".2s", ".2s", ".s", []> {
6311 let Inst{11} = idx{1};
6312 let Inst{21} = idx{0};
6315 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6318 asm, ".4s", ".4s", ".4s", ".s", []> {
6320 let Inst{11} = idx{1};
6321 let Inst{21} = idx{0};
6324 def v2i64_indexed : BaseSIMDIndexedTied<1, U, 0, 0b11, opc,
6327 asm, ".2d", ".2d", ".2d", ".d", []> {
6329 let Inst{11} = idx{0};
6334 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
6335 FPR32Op, FPR32Op, V128, VectorIndexS,
6336 asm, ".s", "", "", ".s", []> {
6338 let Inst{11} = idx{1};
6339 let Inst{21} = idx{0};
6342 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b11, opc,
6343 FPR64Op, FPR64Op, V128, VectorIndexD,
6344 asm, ".d", "", "", ".d", []> {
6346 let Inst{11} = idx{0};
6351 multiclass SIMDIndexedHS<bit U, bits<4> opc, string asm,
6352 SDPatternOperator OpNode> {
6353 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V64, V64,
6354 V128_lo, VectorIndexH,
6355 asm, ".4h", ".4h", ".4h", ".h",
6356 [(set (v4i16 V64:$Rd),
6357 (OpNode (v4i16 V64:$Rn),
6358 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6360 let Inst{11} = idx{2};
6361 let Inst{21} = idx{1};
6362 let Inst{20} = idx{0};
6365 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6367 V128_lo, VectorIndexH,
6368 asm, ".8h", ".8h", ".8h", ".h",
6369 [(set (v8i16 V128:$Rd),
6370 (OpNode (v8i16 V128:$Rn),
6371 (v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6373 let Inst{11} = idx{2};
6374 let Inst{21} = idx{1};
6375 let Inst{20} = idx{0};
6378 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6381 asm, ".2s", ".2s", ".2s", ".s",
6382 [(set (v2i32 V64:$Rd),
6383 (OpNode (v2i32 V64:$Rn),
6384 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6386 let Inst{11} = idx{1};
6387 let Inst{21} = idx{0};
6390 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6393 asm, ".4s", ".4s", ".4s", ".s",
6394 [(set (v4i32 V128:$Rd),
6395 (OpNode (v4i32 V128:$Rn),
6396 (v4i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6398 let Inst{11} = idx{1};
6399 let Inst{21} = idx{0};
6402 def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
6403 FPR16Op, FPR16Op, V128_lo, VectorIndexH,
6404 asm, ".h", "", "", ".h", []> {
6406 let Inst{11} = idx{2};
6407 let Inst{21} = idx{1};
6408 let Inst{20} = idx{0};
6411 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6412 FPR32Op, FPR32Op, V128, VectorIndexS,
6413 asm, ".s", "", "", ".s",
6414 [(set (i32 FPR32Op:$Rd),
6415 (OpNode FPR32Op:$Rn,
6416 (i32 (vector_extract (v4i32 V128:$Rm),
6417 VectorIndexS:$idx))))]> {
6419 let Inst{11} = idx{1};
6420 let Inst{21} = idx{0};
6424 multiclass SIMDVectorIndexedHS<bit U, bits<4> opc, string asm,
6425 SDPatternOperator OpNode> {
6426 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6428 V128_lo, VectorIndexH,
6429 asm, ".4h", ".4h", ".4h", ".h",
6430 [(set (v4i16 V64:$Rd),
6431 (OpNode (v4i16 V64:$Rn),
6432 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6434 let Inst{11} = idx{2};
6435 let Inst{21} = idx{1};
6436 let Inst{20} = idx{0};
6439 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6441 V128_lo, VectorIndexH,
6442 asm, ".8h", ".8h", ".8h", ".h",
6443 [(set (v8i16 V128:$Rd),
6444 (OpNode (v8i16 V128:$Rn),
6445 (v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6447 let Inst{11} = idx{2};
6448 let Inst{21} = idx{1};
6449 let Inst{20} = idx{0};
6452 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6455 asm, ".2s", ".2s", ".2s", ".s",
6456 [(set (v2i32 V64:$Rd),
6457 (OpNode (v2i32 V64:$Rn),
6458 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6460 let Inst{11} = idx{1};
6461 let Inst{21} = idx{0};
6464 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6467 asm, ".4s", ".4s", ".4s", ".s",
6468 [(set (v4i32 V128:$Rd),
6469 (OpNode (v4i32 V128:$Rn),
6470 (v4i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6472 let Inst{11} = idx{1};
6473 let Inst{21} = idx{0};
6477 multiclass SIMDVectorIndexedHSTied<bit U, bits<4> opc, string asm,
6478 SDPatternOperator OpNode> {
6479 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V64, V64,
6480 V128_lo, VectorIndexH,
6481 asm, ".4h", ".4h", ".4h", ".h",
6482 [(set (v4i16 V64:$dst),
6483 (OpNode (v4i16 V64:$Rd),(v4i16 V64:$Rn),
6484 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6486 let Inst{11} = idx{2};
6487 let Inst{21} = idx{1};
6488 let Inst{20} = idx{0};
6491 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6493 V128_lo, VectorIndexH,
6494 asm, ".8h", ".8h", ".8h", ".h",
6495 [(set (v8i16 V128:$dst),
6496 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
6497 (v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6499 let Inst{11} = idx{2};
6500 let Inst{21} = idx{1};
6501 let Inst{20} = idx{0};
6504 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6507 asm, ".2s", ".2s", ".2s", ".s",
6508 [(set (v2i32 V64:$dst),
6509 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
6510 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6512 let Inst{11} = idx{1};
6513 let Inst{21} = idx{0};
6516 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6519 asm, ".4s", ".4s", ".4s", ".s",
6520 [(set (v4i32 V128:$dst),
6521 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
6522 (v4i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6524 let Inst{11} = idx{1};
6525 let Inst{21} = idx{0};
6529 multiclass SIMDIndexedLongSD<bit U, bits<4> opc, string asm,
6530 SDPatternOperator OpNode> {
6531 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6533 V128_lo, VectorIndexH,
6534 asm, ".4s", ".4s", ".4h", ".h",
6535 [(set (v4i32 V128:$Rd),
6536 (OpNode (v4i16 V64:$Rn),
6537 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6539 let Inst{11} = idx{2};
6540 let Inst{21} = idx{1};
6541 let Inst{20} = idx{0};
6544 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6546 V128_lo, VectorIndexH,
6547 asm#"2", ".4s", ".4s", ".8h", ".h",
6548 [(set (v4i32 V128:$Rd),
6549 (OpNode (extract_high_v8i16 V128:$Rn),
6550 (extract_high_v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6551 VectorIndexH:$idx))))]> {
6554 let Inst{11} = idx{2};
6555 let Inst{21} = idx{1};
6556 let Inst{20} = idx{0};
6559 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6562 asm, ".2d", ".2d", ".2s", ".s",
6563 [(set (v2i64 V128:$Rd),
6564 (OpNode (v2i32 V64:$Rn),
6565 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6567 let Inst{11} = idx{1};
6568 let Inst{21} = idx{0};
6571 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6574 asm#"2", ".2d", ".2d", ".4s", ".s",
6575 [(set (v2i64 V128:$Rd),
6576 (OpNode (extract_high_v4i32 V128:$Rn),
6577 (extract_high_v4i32 (ARM64duplane32 (v4i32 V128:$Rm),
6578 VectorIndexS:$idx))))]> {
6580 let Inst{11} = idx{1};
6581 let Inst{21} = idx{0};
6584 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
6585 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
6586 asm, ".h", "", "", ".h", []> {
6588 let Inst{11} = idx{2};
6589 let Inst{21} = idx{1};
6590 let Inst{20} = idx{0};
6593 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6594 FPR64Op, FPR32Op, V128, VectorIndexS,
6595 asm, ".s", "", "", ".s", []> {
6597 let Inst{11} = idx{1};
6598 let Inst{21} = idx{0};
6602 multiclass SIMDIndexedLongSQDMLXSDTied<bit U, bits<4> opc, string asm,
6603 SDPatternOperator Accum> {
6604 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
6606 V128_lo, VectorIndexH,
6607 asm, ".4s", ".4s", ".4h", ".h",
6608 [(set (v4i32 V128:$dst),
6609 (Accum (v4i32 V128:$Rd),
6610 (v4i32 (int_arm64_neon_sqdmull
6612 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6613 VectorIndexH:$idx))))))]> {
6615 let Inst{11} = idx{2};
6616 let Inst{21} = idx{1};
6617 let Inst{20} = idx{0};
6620 // FIXME: it would be nice to use the scalar (v1i32) instruction here, but an
6621 // intermediate EXTRACT_SUBREG would be untyped.
6622 def : Pat<(i32 (Accum (i32 FPR32Op:$Rd),
6623 (i32 (vector_extract (v4i32
6624 (int_arm64_neon_sqdmull (v4i16 V64:$Rn),
6625 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6626 VectorIndexH:$idx)))),
6629 (!cast<Instruction>(NAME # v4i16_indexed)
6630 (SUBREG_TO_REG (i32 0), FPR32Op:$Rd, ssub), V64:$Rn,
6631 V128_lo:$Rm, VectorIndexH:$idx),
6634 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6636 V128_lo, VectorIndexH,
6637 asm#"2", ".4s", ".4s", ".8h", ".h",
6638 [(set (v4i32 V128:$dst),
6639 (Accum (v4i32 V128:$Rd),
6640 (v4i32 (int_arm64_neon_sqdmull
6641 (extract_high_v8i16 V128:$Rn),
6643 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6644 VectorIndexH:$idx))))))]> {
6646 let Inst{11} = idx{2};
6647 let Inst{21} = idx{1};
6648 let Inst{20} = idx{0};
6651 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6654 asm, ".2d", ".2d", ".2s", ".s",
6655 [(set (v2i64 V128:$dst),
6656 (Accum (v2i64 V128:$Rd),
6657 (v2i64 (int_arm64_neon_sqdmull
6659 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm),
6660 VectorIndexS:$idx))))))]> {
6662 let Inst{11} = idx{1};
6663 let Inst{21} = idx{0};
6666 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6669 asm#"2", ".2d", ".2d", ".4s", ".s",
6670 [(set (v2i64 V128:$dst),
6671 (Accum (v2i64 V128:$Rd),
6672 (v2i64 (int_arm64_neon_sqdmull
6673 (extract_high_v4i32 V128:$Rn),
6675 (ARM64duplane32 (v4i32 V128:$Rm),
6676 VectorIndexS:$idx))))))]> {
6678 let Inst{11} = idx{1};
6679 let Inst{21} = idx{0};
6682 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc,
6683 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
6684 asm, ".h", "", "", ".h", []> {
6686 let Inst{11} = idx{2};
6687 let Inst{21} = idx{1};
6688 let Inst{20} = idx{0};
6692 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
6693 FPR64Op, FPR32Op, V128, VectorIndexS,
6694 asm, ".s", "", "", ".s",
6695 [(set (i64 FPR64Op:$dst),
6696 (Accum (i64 FPR64Op:$Rd),
6697 (i64 (int_arm64_neon_sqdmulls_scalar
6699 (i32 (vector_extract (v4i32 V128:$Rm),
6700 VectorIndexS:$idx))))))]> {
6703 let Inst{11} = idx{1};
6704 let Inst{21} = idx{0};
6708 multiclass SIMDVectorIndexedLongSD<bit U, bits<4> opc, string asm,
6709 SDPatternOperator OpNode> {
6710 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6711 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6713 V128_lo, VectorIndexH,
6714 asm, ".4s", ".4s", ".4h", ".h",
6715 [(set (v4i32 V128:$Rd),
6716 (OpNode (v4i16 V64:$Rn),
6717 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6719 let Inst{11} = idx{2};
6720 let Inst{21} = idx{1};
6721 let Inst{20} = idx{0};
6724 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6726 V128_lo, VectorIndexH,
6727 asm#"2", ".4s", ".4s", ".8h", ".h",
6728 [(set (v4i32 V128:$Rd),
6729 (OpNode (extract_high_v8i16 V128:$Rn),
6730 (extract_high_v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6731 VectorIndexH:$idx))))]> {
6734 let Inst{11} = idx{2};
6735 let Inst{21} = idx{1};
6736 let Inst{20} = idx{0};
6739 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6742 asm, ".2d", ".2d", ".2s", ".s",
6743 [(set (v2i64 V128:$Rd),
6744 (OpNode (v2i32 V64:$Rn),
6745 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6747 let Inst{11} = idx{1};
6748 let Inst{21} = idx{0};
6751 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6754 asm#"2", ".2d", ".2d", ".4s", ".s",
6755 [(set (v2i64 V128:$Rd),
6756 (OpNode (extract_high_v4i32 V128:$Rn),
6757 (extract_high_v4i32 (ARM64duplane32 (v4i32 V128:$Rm),
6758 VectorIndexS:$idx))))]> {
6760 let Inst{11} = idx{1};
6761 let Inst{21} = idx{0};
6766 multiclass SIMDVectorIndexedLongSDTied<bit U, bits<4> opc, string asm,
6767 SDPatternOperator OpNode> {
6768 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6769 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
6771 V128_lo, VectorIndexH,
6772 asm, ".4s", ".4s", ".4h", ".h",
6773 [(set (v4i32 V128:$dst),
6774 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn),
6775 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6777 let Inst{11} = idx{2};
6778 let Inst{21} = idx{1};
6779 let Inst{20} = idx{0};
6782 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6784 V128_lo, VectorIndexH,
6785 asm#"2", ".4s", ".4s", ".8h", ".h",
6786 [(set (v4i32 V128:$dst),
6787 (OpNode (v4i32 V128:$Rd),
6788 (extract_high_v8i16 V128:$Rn),
6789 (extract_high_v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6790 VectorIndexH:$idx))))]> {
6792 let Inst{11} = idx{2};
6793 let Inst{21} = idx{1};
6794 let Inst{20} = idx{0};
6797 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6800 asm, ".2d", ".2d", ".2s", ".s",
6801 [(set (v2i64 V128:$dst),
6802 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn),
6803 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6805 let Inst{11} = idx{1};
6806 let Inst{21} = idx{0};
6809 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6812 asm#"2", ".2d", ".2d", ".4s", ".s",
6813 [(set (v2i64 V128:$dst),
6814 (OpNode (v2i64 V128:$Rd),
6815 (extract_high_v4i32 V128:$Rn),
6816 (extract_high_v4i32 (ARM64duplane32 (v4i32 V128:$Rm),
6817 VectorIndexS:$idx))))]> {
6819 let Inst{11} = idx{1};
6820 let Inst{21} = idx{0};
6825 //----------------------------------------------------------------------------
6826 // AdvSIMD scalar shift by immediate
6827 //----------------------------------------------------------------------------
6829 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6830 class BaseSIMDScalarShift<bit U, bits<5> opc, bits<7> fixed_imm,
6831 RegisterClass regtype1, RegisterClass regtype2,
6832 Operand immtype, string asm, list<dag> pattern>
6833 : I<(outs regtype1:$Rd), (ins regtype2:$Rn, immtype:$imm),
6834 asm, "\t$Rd, $Rn, $imm", "", pattern>,
6839 let Inst{31-30} = 0b01;
6841 let Inst{28-23} = 0b111110;
6842 let Inst{22-16} = fixed_imm;
6843 let Inst{15-11} = opc;
6849 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6850 class BaseSIMDScalarShiftTied<bit U, bits<5> opc, bits<7> fixed_imm,
6851 RegisterClass regtype1, RegisterClass regtype2,
6852 Operand immtype, string asm, list<dag> pattern>
6853 : I<(outs regtype1:$dst), (ins regtype1:$Rd, regtype2:$Rn, immtype:$imm),
6854 asm, "\t$Rd, $Rn, $imm", "$Rd = $dst", pattern>,
6859 let Inst{31-30} = 0b01;
6861 let Inst{28-23} = 0b111110;
6862 let Inst{22-16} = fixed_imm;
6863 let Inst{15-11} = opc;
6870 multiclass SIMDScalarRShiftSD<bit U, bits<5> opc, string asm> {
6871 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6872 FPR32, FPR32, vecshiftR32, asm, []> {
6873 let Inst{20-16} = imm{4-0};
6876 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6877 FPR64, FPR64, vecshiftR64, asm, []> {
6878 let Inst{21-16} = imm{5-0};
6882 multiclass SIMDScalarRShiftD<bit U, bits<5> opc, string asm,
6883 SDPatternOperator OpNode> {
6884 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6885 FPR64, FPR64, vecshiftR64, asm,
6886 [(set (i64 FPR64:$Rd),
6887 (OpNode (i64 FPR64:$Rn), (i32 vecshiftR64:$imm)))]> {
6888 let Inst{21-16} = imm{5-0};
6891 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftR64:$imm))),
6892 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftR64:$imm)>;
6895 multiclass SIMDScalarRShiftDTied<bit U, bits<5> opc, string asm,
6896 SDPatternOperator OpNode = null_frag> {
6897 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
6898 FPR64, FPR64, vecshiftR64, asm,
6899 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn),
6900 (i32 vecshiftR64:$imm)))]> {
6901 let Inst{21-16} = imm{5-0};
6904 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
6905 (i32 vecshiftR64:$imm))),
6906 (!cast<Instruction>(NAME # "d") FPR64:$Rd, FPR64:$Rn,
6910 multiclass SIMDScalarLShiftD<bit U, bits<5> opc, string asm,
6911 SDPatternOperator OpNode> {
6912 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6913 FPR64, FPR64, vecshiftL64, asm,
6914 [(set (v1i64 FPR64:$Rd),
6915 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
6916 let Inst{21-16} = imm{5-0};
6920 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6921 multiclass SIMDScalarLShiftDTied<bit U, bits<5> opc, string asm> {
6922 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
6923 FPR64, FPR64, vecshiftL64, asm, []> {
6924 let Inst{21-16} = imm{5-0};
6928 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6929 multiclass SIMDScalarRShiftBHS<bit U, bits<5> opc, string asm,
6930 SDPatternOperator OpNode = null_frag> {
6931 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
6932 FPR8, FPR16, vecshiftR8, asm, []> {
6933 let Inst{18-16} = imm{2-0};
6936 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
6937 FPR16, FPR32, vecshiftR16, asm, []> {
6938 let Inst{19-16} = imm{3-0};
6941 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6942 FPR32, FPR64, vecshiftR32, asm,
6943 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn), vecshiftR32:$imm))]> {
6944 let Inst{20-16} = imm{4-0};
6948 multiclass SIMDScalarLShiftBHSD<bit U, bits<5> opc, string asm,
6949 SDPatternOperator OpNode> {
6950 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
6951 FPR8, FPR8, vecshiftL8, asm, []> {
6952 let Inst{18-16} = imm{2-0};
6955 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
6956 FPR16, FPR16, vecshiftL16, asm, []> {
6957 let Inst{19-16} = imm{3-0};
6960 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6961 FPR32, FPR32, vecshiftL32, asm,
6962 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn), (i32 vecshiftL32:$imm)))]> {
6963 let Inst{20-16} = imm{4-0};
6966 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6967 FPR64, FPR64, vecshiftL64, asm,
6968 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
6969 let Inst{21-16} = imm{5-0};
6972 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm))),
6973 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftL64:$imm)>;
6976 multiclass SIMDScalarRShiftBHSD<bit U, bits<5> opc, string asm> {
6977 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
6978 FPR8, FPR8, vecshiftR8, asm, []> {
6979 let Inst{18-16} = imm{2-0};
6982 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
6983 FPR16, FPR16, vecshiftR16, asm, []> {
6984 let Inst{19-16} = imm{3-0};
6987 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6988 FPR32, FPR32, vecshiftR32, asm, []> {
6989 let Inst{20-16} = imm{4-0};
6992 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6993 FPR64, FPR64, vecshiftR64, asm, []> {
6994 let Inst{21-16} = imm{5-0};
6998 //----------------------------------------------------------------------------
6999 // AdvSIMD vector x indexed element
7000 //----------------------------------------------------------------------------
7002 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7003 class BaseSIMDVectorShift<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
7004 RegisterOperand dst_reg, RegisterOperand src_reg,
7006 string asm, string dst_kind, string src_kind,
7008 : I<(outs dst_reg:$Rd), (ins src_reg:$Rn, immtype:$imm),
7009 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
7010 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "", pattern>,
7017 let Inst{28-23} = 0b011110;
7018 let Inst{22-16} = fixed_imm;
7019 let Inst{15-11} = opc;
7025 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7026 class BaseSIMDVectorShiftTied<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
7027 RegisterOperand vectype1, RegisterOperand vectype2,
7029 string asm, string dst_kind, string src_kind,
7031 : I<(outs vectype1:$dst), (ins vectype1:$Rd, vectype2:$Rn, immtype:$imm),
7032 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
7033 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "$Rd = $dst", pattern>,
7040 let Inst{28-23} = 0b011110;
7041 let Inst{22-16} = fixed_imm;
7042 let Inst{15-11} = opc;
7048 multiclass SIMDVectorRShiftSD<bit U, bits<5> opc, string asm,
7050 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7051 V64, V64, vecshiftR32,
7053 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (i32 imm:$imm)))]> {
7055 let Inst{20-16} = imm;
7058 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7059 V128, V128, vecshiftR32,
7061 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (i32 imm:$imm)))]> {
7063 let Inst{20-16} = imm;
7066 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7067 V128, V128, vecshiftR64,
7069 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (i32 imm:$imm)))]> {
7071 let Inst{21-16} = imm;
7075 multiclass SIMDVectorRShiftSDToFP<bit U, bits<5> opc, string asm,
7077 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7078 V64, V64, vecshiftR32,
7080 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 imm:$imm)))]> {
7082 let Inst{20-16} = imm;
7085 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7086 V128, V128, vecshiftR32,
7088 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 imm:$imm)))]> {
7090 let Inst{20-16} = imm;
7093 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7094 V128, V128, vecshiftR64,
7096 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 imm:$imm)))]> {
7098 let Inst{21-16} = imm;
7102 multiclass SIMDVectorRShiftNarrowBHS<bit U, bits<5> opc, string asm,
7103 SDPatternOperator OpNode> {
7104 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7105 V64, V128, vecshiftR16Narrow,
7107 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))]> {
7109 let Inst{18-16} = imm;
7112 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7113 V128, V128, vecshiftR16Narrow,
7114 asm#"2", ".16b", ".8h", []> {
7116 let Inst{18-16} = imm;
7117 let hasSideEffects = 0;
7120 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7121 V64, V128, vecshiftR32Narrow,
7123 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))]> {
7125 let Inst{19-16} = imm;
7128 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7129 V128, V128, vecshiftR32Narrow,
7130 asm#"2", ".8h", ".4s", []> {
7132 let Inst{19-16} = imm;
7133 let hasSideEffects = 0;
7136 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7137 V64, V128, vecshiftR64Narrow,
7139 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))]> {
7141 let Inst{20-16} = imm;
7144 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7145 V128, V128, vecshiftR64Narrow,
7146 asm#"2", ".4s", ".2d", []> {
7148 let Inst{20-16} = imm;
7149 let hasSideEffects = 0;
7152 // TableGen doesn't like patters w/ INSERT_SUBREG on the instructions
7153 // themselves, so put them here instead.
7155 // Patterns involving what's effectively an insert high and a normal
7156 // intrinsic, represented by CONCAT_VECTORS.
7157 def : Pat<(concat_vectors (v8i8 V64:$Rd),(OpNode (v8i16 V128:$Rn),
7158 vecshiftR16Narrow:$imm)),
7159 (!cast<Instruction>(NAME # "v16i8_shift")
7160 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7161 V128:$Rn, vecshiftR16Narrow:$imm)>;
7162 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn),
7163 vecshiftR32Narrow:$imm)),
7164 (!cast<Instruction>(NAME # "v8i16_shift")
7165 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7166 V128:$Rn, vecshiftR32Narrow:$imm)>;
7167 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn),
7168 vecshiftR64Narrow:$imm)),
7169 (!cast<Instruction>(NAME # "v4i32_shift")
7170 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7171 V128:$Rn, vecshiftR64Narrow:$imm)>;
7174 multiclass SIMDVectorLShiftBHSD<bit U, bits<5> opc, string asm,
7175 SDPatternOperator OpNode> {
7176 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7177 V64, V64, vecshiftL8,
7179 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
7180 (i32 vecshiftL8:$imm)))]> {
7182 let Inst{18-16} = imm;
7185 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7186 V128, V128, vecshiftL8,
7187 asm, ".16b", ".16b",
7188 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
7189 (i32 vecshiftL8:$imm)))]> {
7191 let Inst{18-16} = imm;
7194 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7195 V64, V64, vecshiftL16,
7197 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
7198 (i32 vecshiftL16:$imm)))]> {
7200 let Inst{19-16} = imm;
7203 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7204 V128, V128, vecshiftL16,
7206 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
7207 (i32 vecshiftL16:$imm)))]> {
7209 let Inst{19-16} = imm;
7212 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7213 V64, V64, vecshiftL32,
7215 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
7216 (i32 vecshiftL32:$imm)))]> {
7218 let Inst{20-16} = imm;
7221 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7222 V128, V128, vecshiftL32,
7224 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
7225 (i32 vecshiftL32:$imm)))]> {
7227 let Inst{20-16} = imm;
7230 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7231 V128, V128, vecshiftL64,
7233 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
7234 (i32 vecshiftL64:$imm)))]> {
7236 let Inst{21-16} = imm;
7240 multiclass SIMDVectorRShiftBHSD<bit U, bits<5> opc, string asm,
7241 SDPatternOperator OpNode> {
7242 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7243 V64, V64, vecshiftR8,
7245 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
7246 (i32 vecshiftR8:$imm)))]> {
7248 let Inst{18-16} = imm;
7251 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7252 V128, V128, vecshiftR8,
7253 asm, ".16b", ".16b",
7254 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
7255 (i32 vecshiftR8:$imm)))]> {
7257 let Inst{18-16} = imm;
7260 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7261 V64, V64, vecshiftR16,
7263 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
7264 (i32 vecshiftR16:$imm)))]> {
7266 let Inst{19-16} = imm;
7269 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7270 V128, V128, vecshiftR16,
7272 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
7273 (i32 vecshiftR16:$imm)))]> {
7275 let Inst{19-16} = imm;
7278 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7279 V64, V64, vecshiftR32,
7281 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
7282 (i32 vecshiftR32:$imm)))]> {
7284 let Inst{20-16} = imm;
7287 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7288 V128, V128, vecshiftR32,
7290 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
7291 (i32 vecshiftR32:$imm)))]> {
7293 let Inst{20-16} = imm;
7296 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7297 V128, V128, vecshiftR64,
7299 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
7300 (i32 vecshiftR64:$imm)))]> {
7302 let Inst{21-16} = imm;
7306 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
7307 multiclass SIMDVectorRShiftBHSDTied<bit U, bits<5> opc, string asm,
7308 SDPatternOperator OpNode = null_frag> {
7309 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
7310 V64, V64, vecshiftR8, asm, ".8b", ".8b",
7311 [(set (v8i8 V64:$dst),
7312 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
7313 (i32 vecshiftR8:$imm)))]> {
7315 let Inst{18-16} = imm;
7318 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7319 V128, V128, vecshiftR8, asm, ".16b", ".16b",
7320 [(set (v16i8 V128:$dst),
7321 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
7322 (i32 vecshiftR8:$imm)))]> {
7324 let Inst{18-16} = imm;
7327 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
7328 V64, V64, vecshiftR16, asm, ".4h", ".4h",
7329 [(set (v4i16 V64:$dst),
7330 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
7331 (i32 vecshiftR16:$imm)))]> {
7333 let Inst{19-16} = imm;
7336 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7337 V128, V128, vecshiftR16, asm, ".8h", ".8h",
7338 [(set (v8i16 V128:$dst),
7339 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7340 (i32 vecshiftR16:$imm)))]> {
7342 let Inst{19-16} = imm;
7345 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
7346 V64, V64, vecshiftR32, asm, ".2s", ".2s",
7347 [(set (v2i32 V64:$dst),
7348 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7349 (i32 vecshiftR32:$imm)))]> {
7351 let Inst{20-16} = imm;
7354 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7355 V128, V128, vecshiftR32, asm, ".4s", ".4s",
7356 [(set (v4i32 V128:$dst),
7357 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7358 (i32 vecshiftR32:$imm)))]> {
7360 let Inst{20-16} = imm;
7363 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
7364 V128, V128, vecshiftR64,
7365 asm, ".2d", ".2d", [(set (v2i64 V128:$dst),
7366 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
7367 (i32 vecshiftR64:$imm)))]> {
7369 let Inst{21-16} = imm;
7373 multiclass SIMDVectorLShiftBHSDTied<bit U, bits<5> opc, string asm,
7374 SDPatternOperator OpNode = null_frag> {
7375 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
7376 V64, V64, vecshiftL8,
7378 [(set (v8i8 V64:$dst),
7379 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
7380 (i32 vecshiftL8:$imm)))]> {
7382 let Inst{18-16} = imm;
7385 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7386 V128, V128, vecshiftL8,
7387 asm, ".16b", ".16b",
7388 [(set (v16i8 V128:$dst),
7389 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
7390 (i32 vecshiftL8:$imm)))]> {
7392 let Inst{18-16} = imm;
7395 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
7396 V64, V64, vecshiftL16,
7398 [(set (v4i16 V64:$dst),
7399 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
7400 (i32 vecshiftL16:$imm)))]> {
7402 let Inst{19-16} = imm;
7405 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7406 V128, V128, vecshiftL16,
7408 [(set (v8i16 V128:$dst),
7409 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7410 (i32 vecshiftL16:$imm)))]> {
7412 let Inst{19-16} = imm;
7415 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
7416 V64, V64, vecshiftL32,
7418 [(set (v2i32 V64:$dst),
7419 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7420 (i32 vecshiftL32:$imm)))]> {
7422 let Inst{20-16} = imm;
7425 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7426 V128, V128, vecshiftL32,
7428 [(set (v4i32 V128:$dst),
7429 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7430 (i32 vecshiftL32:$imm)))]> {
7432 let Inst{20-16} = imm;
7435 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
7436 V128, V128, vecshiftL64,
7438 [(set (v2i64 V128:$dst),
7439 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
7440 (i32 vecshiftL64:$imm)))]> {
7442 let Inst{21-16} = imm;
7446 multiclass SIMDVectorLShiftLongBHSD<bit U, bits<5> opc, string asm,
7447 SDPatternOperator OpNode> {
7448 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7449 V128, V64, vecshiftL8, asm, ".8h", ".8b",
7450 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), vecshiftL8:$imm))]> {
7452 let Inst{18-16} = imm;
7455 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7456 V128, V128, vecshiftL8,
7457 asm#"2", ".8h", ".16b",
7458 [(set (v8i16 V128:$Rd),
7459 (OpNode (extract_high_v16i8 V128:$Rn), vecshiftL8:$imm))]> {
7461 let Inst{18-16} = imm;
7464 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7465 V128, V64, vecshiftL16, asm, ".4s", ".4h",
7466 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), vecshiftL16:$imm))]> {
7468 let Inst{19-16} = imm;
7471 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7472 V128, V128, vecshiftL16,
7473 asm#"2", ".4s", ".8h",
7474 [(set (v4i32 V128:$Rd),
7475 (OpNode (extract_high_v8i16 V128:$Rn), vecshiftL16:$imm))]> {
7478 let Inst{19-16} = imm;
7481 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7482 V128, V64, vecshiftL32, asm, ".2d", ".2s",
7483 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), vecshiftL32:$imm))]> {
7485 let Inst{20-16} = imm;
7488 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7489 V128, V128, vecshiftL32,
7490 asm#"2", ".2d", ".4s",
7491 [(set (v2i64 V128:$Rd),
7492 (OpNode (extract_high_v4i32 V128:$Rn), vecshiftL32:$imm))]> {
7494 let Inst{20-16} = imm;
7500 // Vector load/store
7502 // SIMD ldX/stX no-index memory references don't allow the optional
7503 // ", #0" constant and handle post-indexing explicitly, so we use
7504 // a more specialized parse method for them. Otherwise, it's the same as
7505 // the general am_noindex handling.
7507 class BaseSIMDLdSt<bit Q, bit L, bits<4> opcode, bits<2> size,
7508 string asm, dag oops, dag iops, list<dag> pattern>
7509 : I<oops, iops, asm, "\t$Vt, $vaddr", "", pattern> {
7514 let Inst{29-23} = 0b0011000;
7516 let Inst{21-16} = 0b000000;
7517 let Inst{15-12} = opcode;
7518 let Inst{11-10} = size;
7519 let Inst{9-5} = vaddr;
7523 class BaseSIMDLdStPost<bit Q, bit L, bits<4> opcode, bits<2> size,
7524 string asm, dag oops, dag iops>
7525 : I<oops, iops, asm, "\t$Vt, $vaddr, $Xm", "$vaddr = $wback", []> {
7531 let Inst{29-23} = 0b0011001;
7534 let Inst{20-16} = Xm;
7535 let Inst{15-12} = opcode;
7536 let Inst{11-10} = size;
7537 let Inst{9-5} = vaddr;
7541 // The immediate form of AdvSIMD post-indexed addressing is encoded with
7542 // register post-index addressing from the zero register.
7543 multiclass SIMDLdStAliases<string asm, string layout, string Count,
7544 int Offset, int Size> {
7545 // E.g. "ld1 { v0.8b, v1.8b }, [x1], #16"
7546 // "ld1\t$Vt, $vaddr, #16"
7547 // may get mapped to
7548 // (LD1Twov8b_POST VecListTwo8b:$Vt, am_simdnoindex:$vaddr, XZR)
7549 def : InstAlias<asm # "\t$Vt, $vaddr, #" # Offset,
7550 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7551 am_simdnoindex:$vaddr,
7552 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
7555 // E.g. "ld1.8b { v0, v1 }, [x1], #16"
7556 // "ld1.8b\t$Vt, $vaddr, #16"
7557 // may get mapped to
7558 // (LD1Twov8b_POST VecListTwo64:$Vt, am_simdnoindex:$vaddr, XZR)
7559 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, #" # Offset,
7560 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7561 am_simdnoindex:$vaddr,
7562 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7565 // E.g. "ld1.8b { v0, v1 }, [x1]"
7566 // "ld1\t$Vt, $vaddr"
7567 // may get mapped to
7568 // (LD1Twov8b VecListTwo64:$Vt, am_simdnoindex:$vaddr)
7569 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr",
7570 (!cast<Instruction>(NAME # Count # "v" # layout)
7571 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7572 am_simdnoindex:$vaddr), 0>;
7574 // E.g. "ld1.8b { v0, v1 }, [x1], x2"
7575 // "ld1\t$Vt, $vaddr, $Xm"
7576 // may get mapped to
7577 // (LD1Twov8b_POST VecListTwo64:$Vt, am_simdnoindex:$vaddr, GPR64pi8:$Xm)
7578 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, $Xm",
7579 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7580 am_simdnoindex:$vaddr,
7581 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7582 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
7585 multiclass BaseSIMDLdN<string Count, string asm, string veclist, int Offset128,
7586 int Offset64, bits<4> opcode> {
7587 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
7588 def v16b: BaseSIMDLdSt<1, 1, opcode, 0b00, asm,
7589 (outs !cast<RegisterOperand>(veclist # "16b"):$Vt),
7590 (ins am_simdnoindex:$vaddr), []>;
7591 def v8h : BaseSIMDLdSt<1, 1, opcode, 0b01, asm,
7592 (outs !cast<RegisterOperand>(veclist # "8h"):$Vt),
7593 (ins am_simdnoindex:$vaddr), []>;
7594 def v4s : BaseSIMDLdSt<1, 1, opcode, 0b10, asm,
7595 (outs !cast<RegisterOperand>(veclist # "4s"):$Vt),
7596 (ins am_simdnoindex:$vaddr), []>;
7597 def v2d : BaseSIMDLdSt<1, 1, opcode, 0b11, asm,
7598 (outs !cast<RegisterOperand>(veclist # "2d"):$Vt),
7599 (ins am_simdnoindex:$vaddr), []>;
7600 def v8b : BaseSIMDLdSt<0, 1, opcode, 0b00, asm,
7601 (outs !cast<RegisterOperand>(veclist # "8b"):$Vt),
7602 (ins am_simdnoindex:$vaddr), []>;
7603 def v4h : BaseSIMDLdSt<0, 1, opcode, 0b01, asm,
7604 (outs !cast<RegisterOperand>(veclist # "4h"):$Vt),
7605 (ins am_simdnoindex:$vaddr), []>;
7606 def v2s : BaseSIMDLdSt<0, 1, opcode, 0b10, asm,
7607 (outs !cast<RegisterOperand>(veclist # "2s"):$Vt),
7608 (ins am_simdnoindex:$vaddr), []>;
7611 def v16b_POST: BaseSIMDLdStPost<1, 1, opcode, 0b00, asm,
7612 (outs am_simdnoindex:$wback,
7613 !cast<RegisterOperand>(veclist # "16b"):$Vt),
7614 (ins am_simdnoindex:$vaddr,
7615 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7616 def v8h_POST : BaseSIMDLdStPost<1, 1, opcode, 0b01, asm,
7617 (outs am_simdnoindex:$wback,
7618 !cast<RegisterOperand>(veclist # "8h"):$Vt),
7619 (ins am_simdnoindex:$vaddr,
7620 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7621 def v4s_POST : BaseSIMDLdStPost<1, 1, opcode, 0b10, asm,
7622 (outs am_simdnoindex:$wback,
7623 !cast<RegisterOperand>(veclist # "4s"):$Vt),
7624 (ins am_simdnoindex:$vaddr,
7625 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7626 def v2d_POST : BaseSIMDLdStPost<1, 1, opcode, 0b11, asm,
7627 (outs am_simdnoindex:$wback,
7628 !cast<RegisterOperand>(veclist # "2d"):$Vt),
7629 (ins am_simdnoindex:$vaddr,
7630 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7631 def v8b_POST : BaseSIMDLdStPost<0, 1, opcode, 0b00, asm,
7632 (outs am_simdnoindex:$wback,
7633 !cast<RegisterOperand>(veclist # "8b"):$Vt),
7634 (ins am_simdnoindex:$vaddr,
7635 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7636 def v4h_POST : BaseSIMDLdStPost<0, 1, opcode, 0b01, asm,
7637 (outs am_simdnoindex:$wback,
7638 !cast<RegisterOperand>(veclist # "4h"):$Vt),
7639 (ins am_simdnoindex:$vaddr,
7640 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7641 def v2s_POST : BaseSIMDLdStPost<0, 1, opcode, 0b10, asm,
7642 (outs am_simdnoindex:$wback,
7643 !cast<RegisterOperand>(veclist # "2s"):$Vt),
7644 (ins am_simdnoindex:$vaddr,
7645 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7648 defm : SIMDLdStAliases<asm, "16b", Count, Offset128, 128>;
7649 defm : SIMDLdStAliases<asm, "8h", Count, Offset128, 128>;
7650 defm : SIMDLdStAliases<asm, "4s", Count, Offset128, 128>;
7651 defm : SIMDLdStAliases<asm, "2d", Count, Offset128, 128>;
7652 defm : SIMDLdStAliases<asm, "8b", Count, Offset64, 64>;
7653 defm : SIMDLdStAliases<asm, "4h", Count, Offset64, 64>;
7654 defm : SIMDLdStAliases<asm, "2s", Count, Offset64, 64>;
7657 // Only ld1/st1 has a v1d version.
7658 multiclass BaseSIMDStN<string Count, string asm, string veclist, int Offset128,
7659 int Offset64, bits<4> opcode> {
7660 let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in {
7661 def v16b : BaseSIMDLdSt<1, 0, opcode, 0b00, asm, (outs),
7662 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
7663 am_simdnoindex:$vaddr), []>;
7664 def v8h : BaseSIMDLdSt<1, 0, opcode, 0b01, asm, (outs),
7665 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
7666 am_simdnoindex:$vaddr), []>;
7667 def v4s : BaseSIMDLdSt<1, 0, opcode, 0b10, asm, (outs),
7668 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
7669 am_simdnoindex:$vaddr), []>;
7670 def v2d : BaseSIMDLdSt<1, 0, opcode, 0b11, asm, (outs),
7671 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
7672 am_simdnoindex:$vaddr), []>;
7673 def v8b : BaseSIMDLdSt<0, 0, opcode, 0b00, asm, (outs),
7674 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
7675 am_simdnoindex:$vaddr), []>;
7676 def v4h : BaseSIMDLdSt<0, 0, opcode, 0b01, asm, (outs),
7677 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
7678 am_simdnoindex:$vaddr), []>;
7679 def v2s : BaseSIMDLdSt<0, 0, opcode, 0b10, asm, (outs),
7680 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
7681 am_simdnoindex:$vaddr), []>;
7683 def v16b_POST : BaseSIMDLdStPost<1, 0, opcode, 0b00, asm,
7684 (outs am_simdnoindex:$wback),
7685 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
7686 am_simdnoindex:$vaddr,
7687 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7688 def v8h_POST : BaseSIMDLdStPost<1, 0, opcode, 0b01, asm,
7689 (outs am_simdnoindex:$wback),
7690 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
7691 am_simdnoindex:$vaddr,
7692 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7693 def v4s_POST : BaseSIMDLdStPost<1, 0, opcode, 0b10, asm,
7694 (outs am_simdnoindex:$wback),
7695 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
7696 am_simdnoindex:$vaddr,
7697 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7698 def v2d_POST : BaseSIMDLdStPost<1, 0, opcode, 0b11, asm,
7699 (outs am_simdnoindex:$wback),
7700 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
7701 am_simdnoindex:$vaddr,
7702 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7703 def v8b_POST : BaseSIMDLdStPost<0, 0, opcode, 0b00, asm,
7704 (outs am_simdnoindex:$wback),
7705 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
7706 am_simdnoindex:$vaddr,
7707 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7708 def v4h_POST : BaseSIMDLdStPost<0, 0, opcode, 0b01, asm,
7709 (outs am_simdnoindex:$wback),
7710 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
7711 am_simdnoindex:$vaddr,
7712 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7713 def v2s_POST : BaseSIMDLdStPost<0, 0, opcode, 0b10, asm,
7714 (outs am_simdnoindex:$wback),
7715 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
7716 am_simdnoindex:$vaddr,
7717 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7720 defm : SIMDLdStAliases<asm, "16b", Count, Offset128, 128>;
7721 defm : SIMDLdStAliases<asm, "8h", Count, Offset128, 128>;
7722 defm : SIMDLdStAliases<asm, "4s", Count, Offset128, 128>;
7723 defm : SIMDLdStAliases<asm, "2d", Count, Offset128, 128>;
7724 defm : SIMDLdStAliases<asm, "8b", Count, Offset64, 64>;
7725 defm : SIMDLdStAliases<asm, "4h", Count, Offset64, 64>;
7726 defm : SIMDLdStAliases<asm, "2s", Count, Offset64, 64>;
7729 multiclass BaseSIMDLd1<string Count, string asm, string veclist,
7730 int Offset128, int Offset64, bits<4> opcode>
7731 : BaseSIMDLdN<Count, asm, veclist, Offset128, Offset64, opcode> {
7733 // LD1 instructions have extra "1d" variants.
7734 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
7735 def v1d : BaseSIMDLdSt<0, 1, opcode, 0b11, asm,
7736 (outs !cast<RegisterOperand>(veclist # "1d"):$Vt),
7737 (ins am_simdnoindex:$vaddr), []>;
7739 def v1d_POST : BaseSIMDLdStPost<0, 1, opcode, 0b11, asm,
7740 (outs am_simdnoindex:$wback,
7741 !cast<RegisterOperand>(veclist # "1d"):$Vt),
7742 (ins am_simdnoindex:$vaddr,
7743 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7746 defm : SIMDLdStAliases<asm, "1d", Count, Offset64, 64>;
7749 multiclass BaseSIMDSt1<string Count, string asm, string veclist,
7750 int Offset128, int Offset64, bits<4> opcode>
7751 : BaseSIMDStN<Count, asm, veclist, Offset128, Offset64, opcode> {
7753 // ST1 instructions have extra "1d" variants.
7754 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
7755 def v1d : BaseSIMDLdSt<0, 0, opcode, 0b11, asm, (outs),
7756 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
7757 am_simdnoindex:$vaddr), []>;
7759 def v1d_POST : BaseSIMDLdStPost<0, 0, opcode, 0b11, asm,
7760 (outs am_simdnoindex:$wback),
7761 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
7762 am_simdnoindex:$vaddr,
7763 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7766 defm : SIMDLdStAliases<asm, "1d", Count, Offset64, 64>;
7769 multiclass SIMDLd1Multiple<string asm> {
7770 defm One : BaseSIMDLd1<"One", asm, "VecListOne", 16, 8, 0b0111>;
7771 defm Two : BaseSIMDLd1<"Two", asm, "VecListTwo", 32, 16, 0b1010>;
7772 defm Three : BaseSIMDLd1<"Three", asm, "VecListThree", 48, 24, 0b0110>;
7773 defm Four : BaseSIMDLd1<"Four", asm, "VecListFour", 64, 32, 0b0010>;
7776 multiclass SIMDSt1Multiple<string asm> {
7777 defm One : BaseSIMDSt1<"One", asm, "VecListOne", 16, 8, 0b0111>;
7778 defm Two : BaseSIMDSt1<"Two", asm, "VecListTwo", 32, 16, 0b1010>;
7779 defm Three : BaseSIMDSt1<"Three", asm, "VecListThree", 48, 24, 0b0110>;
7780 defm Four : BaseSIMDSt1<"Four", asm, "VecListFour", 64, 32, 0b0010>;
7783 multiclass SIMDLd2Multiple<string asm> {
7784 defm Two : BaseSIMDLdN<"Two", asm, "VecListTwo", 32, 16, 0b1000>;
7787 multiclass SIMDSt2Multiple<string asm> {
7788 defm Two : BaseSIMDStN<"Two", asm, "VecListTwo", 32, 16, 0b1000>;
7791 multiclass SIMDLd3Multiple<string asm> {
7792 defm Three : BaseSIMDLdN<"Three", asm, "VecListThree", 48, 24, 0b0100>;
7795 multiclass SIMDSt3Multiple<string asm> {
7796 defm Three : BaseSIMDStN<"Three", asm, "VecListThree", 48, 24, 0b0100>;
7799 multiclass SIMDLd4Multiple<string asm> {
7800 defm Four : BaseSIMDLdN<"Four", asm, "VecListFour", 64, 32, 0b0000>;
7803 multiclass SIMDSt4Multiple<string asm> {
7804 defm Four : BaseSIMDStN<"Four", asm, "VecListFour", 64, 32, 0b0000>;
7808 // AdvSIMD Load/store single-element
7811 class BaseSIMDLdStSingle<bit L, bit R, bits<3> opcode,
7812 string asm, string operands, string cst,
7813 dag oops, dag iops, list<dag> pattern>
7814 : I<oops, iops, asm, operands, cst, pattern> {
7818 let Inst{29-24} = 0b001101;
7821 let Inst{15-13} = opcode;
7822 let Inst{9-5} = vaddr;
7826 class BaseSIMDLdStSingleTied<bit L, bit R, bits<3> opcode,
7827 string asm, string operands, string cst,
7828 dag oops, dag iops, list<dag> pattern>
7829 : I<oops, iops, asm, operands, "$Vt = $dst," # cst, pattern> {
7833 let Inst{29-24} = 0b001101;
7836 let Inst{15-13} = opcode;
7837 let Inst{9-5} = vaddr;
7842 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
7843 class BaseSIMDLdR<bit Q, bit R, bits<3> opcode, bit S, bits<2> size, string asm,
7845 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, $vaddr", "",
7846 (outs listtype:$Vt), (ins am_simdnoindex:$vaddr),
7850 let Inst{20-16} = 0b00000;
7852 let Inst{11-10} = size;
7854 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
7855 class BaseSIMDLdRPost<bit Q, bit R, bits<3> opcode, bit S, bits<2> size,
7856 string asm, Operand listtype, Operand GPR64pi>
7857 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, $vaddr, $Xm",
7859 (outs am_simdnoindex:$wback, listtype:$Vt),
7860 (ins am_simdnoindex:$vaddr, GPR64pi:$Xm), []> {
7864 let Inst{20-16} = Xm;
7866 let Inst{11-10} = size;
7869 multiclass SIMDLdrAliases<string asm, string layout, string Count,
7870 int Offset, int Size> {
7871 // E.g. "ld1r { v0.8b }, [x1], #1"
7872 // "ld1r.8b\t$Vt, $vaddr, #1"
7873 // may get mapped to
7874 // (LD1Rv8b_POST VecListOne8b:$Vt, am_simdnoindex:$vaddr, XZR)
7875 def : InstAlias<asm # "\t$Vt, $vaddr, #" # Offset,
7876 (!cast<Instruction>(NAME # "v" # layout # "_POST")
7877 am_simdnoindex:$vaddr,
7878 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
7881 // E.g. "ld1r.8b { v0 }, [x1], #1"
7882 // "ld1r.8b\t$Vt, $vaddr, #1"
7883 // may get mapped to
7884 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, XZR)
7885 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, #" # Offset,
7886 (!cast<Instruction>(NAME # "v" # layout # "_POST")
7887 am_simdnoindex:$vaddr,
7888 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7891 // E.g. "ld1r.8b { v0 }, [x1]"
7892 // "ld1r.8b\t$Vt, $vaddr"
7893 // may get mapped to
7894 // (LD1Rv8b VecListOne64:$Vt, am_simdnoindex:$vaddr)
7895 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr",
7896 (!cast<Instruction>(NAME # "v" # layout)
7897 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7898 am_simdnoindex:$vaddr), 0>;
7900 // E.g. "ld1r.8b { v0 }, [x1], x2"
7901 // "ld1r.8b\t$Vt, $vaddr, $Xm"
7902 // may get mapped to
7903 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, GPR64pi1:$Xm)
7904 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, $Xm",
7905 (!cast<Instruction>(NAME # "v" # layout # "_POST")
7906 am_simdnoindex:$vaddr,
7907 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7908 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
7911 multiclass SIMDLdR<bit R, bits<3> opcode, bit S, string asm, string Count,
7912 int Offset1, int Offset2, int Offset4, int Offset8> {
7913 def v8b : BaseSIMDLdR<0, R, opcode, S, 0b00, asm,
7914 !cast<Operand>("VecList" # Count # "8b")>;
7915 def v16b: BaseSIMDLdR<1, R, opcode, S, 0b00, asm,
7916 !cast<Operand>("VecList" # Count #"16b")>;
7917 def v4h : BaseSIMDLdR<0, R, opcode, S, 0b01, asm,
7918 !cast<Operand>("VecList" # Count #"4h")>;
7919 def v8h : BaseSIMDLdR<1, R, opcode, S, 0b01, asm,
7920 !cast<Operand>("VecList" # Count #"8h")>;
7921 def v2s : BaseSIMDLdR<0, R, opcode, S, 0b10, asm,
7922 !cast<Operand>("VecList" # Count #"2s")>;
7923 def v4s : BaseSIMDLdR<1, R, opcode, S, 0b10, asm,
7924 !cast<Operand>("VecList" # Count #"4s")>;
7925 def v1d : BaseSIMDLdR<0, R, opcode, S, 0b11, asm,
7926 !cast<Operand>("VecList" # Count #"1d")>;
7927 def v2d : BaseSIMDLdR<1, R, opcode, S, 0b11, asm,
7928 !cast<Operand>("VecList" # Count #"2d")>;
7930 def v8b_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b00, asm,
7931 !cast<Operand>("VecList" # Count # "8b"),
7932 !cast<Operand>("GPR64pi" # Offset1)>;
7933 def v16b_POST: BaseSIMDLdRPost<1, R, opcode, S, 0b00, asm,
7934 !cast<Operand>("VecList" # Count # "16b"),
7935 !cast<Operand>("GPR64pi" # Offset1)>;
7936 def v4h_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b01, asm,
7937 !cast<Operand>("VecList" # Count # "4h"),
7938 !cast<Operand>("GPR64pi" # Offset2)>;
7939 def v8h_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b01, asm,
7940 !cast<Operand>("VecList" # Count # "8h"),
7941 !cast<Operand>("GPR64pi" # Offset2)>;
7942 def v2s_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b10, asm,
7943 !cast<Operand>("VecList" # Count # "2s"),
7944 !cast<Operand>("GPR64pi" # Offset4)>;
7945 def v4s_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b10, asm,
7946 !cast<Operand>("VecList" # Count # "4s"),
7947 !cast<Operand>("GPR64pi" # Offset4)>;
7948 def v1d_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b11, asm,
7949 !cast<Operand>("VecList" # Count # "1d"),
7950 !cast<Operand>("GPR64pi" # Offset8)>;
7951 def v2d_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b11, asm,
7952 !cast<Operand>("VecList" # Count # "2d"),
7953 !cast<Operand>("GPR64pi" # Offset8)>;
7955 defm : SIMDLdrAliases<asm, "8b", Count, Offset1, 64>;
7956 defm : SIMDLdrAliases<asm, "16b", Count, Offset1, 128>;
7957 defm : SIMDLdrAliases<asm, "4h", Count, Offset2, 64>;
7958 defm : SIMDLdrAliases<asm, "8h", Count, Offset2, 128>;
7959 defm : SIMDLdrAliases<asm, "2s", Count, Offset4, 64>;
7960 defm : SIMDLdrAliases<asm, "4s", Count, Offset4, 128>;
7961 defm : SIMDLdrAliases<asm, "1d", Count, Offset8, 64>;
7962 defm : SIMDLdrAliases<asm, "2d", Count, Offset8, 128>;
7965 class SIMDLdStSingleB<bit L, bit R, bits<3> opcode, string asm,
7966 dag oops, dag iops, list<dag> pattern>
7967 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
7969 // idx encoded in Q:S:size fields.
7971 let Inst{30} = idx{3};
7973 let Inst{20-16} = 0b00000;
7974 let Inst{12} = idx{2};
7975 let Inst{11-10} = idx{1-0};
7977 class SIMDLdStSingleBTied<bit L, bit R, bits<3> opcode, string asm,
7978 dag oops, dag iops, list<dag> pattern>
7979 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
7980 oops, iops, pattern> {
7981 // idx encoded in Q:S:size fields.
7983 let Inst{30} = idx{3};
7985 let Inst{20-16} = 0b00000;
7986 let Inst{12} = idx{2};
7987 let Inst{11-10} = idx{1-0};
7989 class SIMDLdStSingleBPost<bit L, bit R, bits<3> opcode, string asm,
7991 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
7992 "$vaddr = $wback", oops, iops, []> {
7993 // idx encoded in Q:S:size fields.
7996 let Inst{30} = idx{3};
7998 let Inst{20-16} = Xm;
7999 let Inst{12} = idx{2};
8000 let Inst{11-10} = idx{1-0};
8002 class SIMDLdStSingleBTiedPost<bit L, bit R, bits<3> opcode, string asm,
8004 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8005 "$vaddr = $wback", oops, iops, []> {
8006 // idx encoded in Q:S:size fields.
8009 let Inst{30} = idx{3};
8011 let Inst{20-16} = Xm;
8012 let Inst{12} = idx{2};
8013 let Inst{11-10} = idx{1-0};
8016 class SIMDLdStSingleH<bit L, bit R, bits<3> opcode, bit size, string asm,
8017 dag oops, dag iops, list<dag> pattern>
8018 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
8020 // idx encoded in Q:S:size<1> fields.
8022 let Inst{30} = idx{2};
8024 let Inst{20-16} = 0b00000;
8025 let Inst{12} = idx{1};
8026 let Inst{11} = idx{0};
8027 let Inst{10} = size;
8029 class SIMDLdStSingleHTied<bit L, bit R, bits<3> opcode, bit size, string asm,
8030 dag oops, dag iops, list<dag> pattern>
8031 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
8032 oops, iops, pattern> {
8033 // idx encoded in Q:S:size<1> fields.
8035 let Inst{30} = idx{2};
8037 let Inst{20-16} = 0b00000;
8038 let Inst{12} = idx{1};
8039 let Inst{11} = idx{0};
8040 let Inst{10} = size;
8043 class SIMDLdStSingleHPost<bit L, bit R, bits<3> opcode, bit size, string asm,
8045 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8046 "$vaddr = $wback", oops, iops, []> {
8047 // idx encoded in Q:S:size<1> fields.
8050 let Inst{30} = idx{2};
8052 let Inst{20-16} = Xm;
8053 let Inst{12} = idx{1};
8054 let Inst{11} = idx{0};
8055 let Inst{10} = size;
8057 class SIMDLdStSingleHTiedPost<bit L, bit R, bits<3> opcode, bit size, string asm,
8059 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8060 "$vaddr = $wback", oops, iops, []> {
8061 // idx encoded in Q:S:size<1> fields.
8064 let Inst{30} = idx{2};
8066 let Inst{20-16} = Xm;
8067 let Inst{12} = idx{1};
8068 let Inst{11} = idx{0};
8069 let Inst{10} = size;
8071 class SIMDLdStSingleS<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8072 dag oops, dag iops, list<dag> pattern>
8073 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
8075 // idx encoded in Q:S fields.
8077 let Inst{30} = idx{1};
8079 let Inst{20-16} = 0b00000;
8080 let Inst{12} = idx{0};
8081 let Inst{11-10} = size;
8083 class SIMDLdStSingleSTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8084 dag oops, dag iops, list<dag> pattern>
8085 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
8086 oops, iops, pattern> {
8087 // idx encoded in Q:S fields.
8089 let Inst{30} = idx{1};
8091 let Inst{20-16} = 0b00000;
8092 let Inst{12} = idx{0};
8093 let Inst{11-10} = size;
8095 class SIMDLdStSingleSPost<bit L, bit R, bits<3> opcode, bits<2> size,
8096 string asm, dag oops, dag iops>
8097 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8098 "$vaddr = $wback", oops, iops, []> {
8099 // idx encoded in Q:S fields.
8102 let Inst{30} = idx{1};
8104 let Inst{20-16} = Xm;
8105 let Inst{12} = idx{0};
8106 let Inst{11-10} = size;
8108 class SIMDLdStSingleSTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
8109 string asm, dag oops, dag iops>
8110 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8111 "$vaddr = $wback", oops, iops, []> {
8112 // idx encoded in Q:S fields.
8115 let Inst{30} = idx{1};
8117 let Inst{20-16} = Xm;
8118 let Inst{12} = idx{0};
8119 let Inst{11-10} = size;
8121 class SIMDLdStSingleD<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8122 dag oops, dag iops, list<dag> pattern>
8123 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
8125 // idx encoded in Q field.
8129 let Inst{20-16} = 0b00000;
8131 let Inst{11-10} = size;
8133 class SIMDLdStSingleDTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8134 dag oops, dag iops, list<dag> pattern>
8135 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
8136 oops, iops, pattern> {
8137 // idx encoded in Q field.
8141 let Inst{20-16} = 0b00000;
8143 let Inst{11-10} = size;
8145 class SIMDLdStSingleDPost<bit L, bit R, bits<3> opcode, bits<2> size,
8146 string asm, dag oops, dag iops>
8147 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8148 "$vaddr = $wback", oops, iops, []> {
8149 // idx encoded in Q field.
8154 let Inst{20-16} = Xm;
8156 let Inst{11-10} = size;
8158 class SIMDLdStSingleDTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
8159 string asm, dag oops, dag iops>
8160 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8161 "$vaddr = $wback", oops, iops, []> {
8162 // idx encoded in Q field.
8167 let Inst{20-16} = Xm;
8169 let Inst{11-10} = size;
8172 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8173 multiclass SIMDLdSingleBTied<bit R, bits<3> opcode, string asm,
8174 RegisterOperand listtype,
8175 RegisterOperand GPR64pi> {
8176 def i8 : SIMDLdStSingleBTied<1, R, opcode, asm,
8177 (outs listtype:$dst),
8178 (ins listtype:$Vt, VectorIndexB:$idx,
8179 am_simdnoindex:$vaddr), []>;
8181 def i8_POST : SIMDLdStSingleBTiedPost<1, R, opcode, asm,
8182 (outs am_simdnoindex:$wback, listtype:$dst),
8183 (ins listtype:$Vt, VectorIndexB:$idx,
8184 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8186 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8187 multiclass SIMDLdSingleHTied<bit R, bits<3> opcode, bit size, string asm,
8188 RegisterOperand listtype,
8189 RegisterOperand GPR64pi> {
8190 def i16 : SIMDLdStSingleHTied<1, R, opcode, size, asm,
8191 (outs listtype:$dst),
8192 (ins listtype:$Vt, VectorIndexH:$idx,
8193 am_simdnoindex:$vaddr), []>;
8195 def i16_POST : SIMDLdStSingleHTiedPost<1, R, opcode, size, asm,
8196 (outs am_simdnoindex:$wback, listtype:$dst),
8197 (ins listtype:$Vt, VectorIndexH:$idx,
8198 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8200 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8201 multiclass SIMDLdSingleSTied<bit R, bits<3> opcode, bits<2> size,string asm,
8202 RegisterOperand listtype,
8203 RegisterOperand GPR64pi> {
8204 def i32 : SIMDLdStSingleSTied<1, R, opcode, size, asm,
8205 (outs listtype:$dst),
8206 (ins listtype:$Vt, VectorIndexS:$idx,
8207 am_simdnoindex:$vaddr), []>;
8209 def i32_POST : SIMDLdStSingleSTiedPost<1, R, opcode, size, asm,
8210 (outs am_simdnoindex:$wback, listtype:$dst),
8211 (ins listtype:$Vt, VectorIndexS:$idx,
8212 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8214 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8215 multiclass SIMDLdSingleDTied<bit R, bits<3> opcode, bits<2> size, string asm,
8216 RegisterOperand listtype, RegisterOperand GPR64pi> {
8217 def i64 : SIMDLdStSingleDTied<1, R, opcode, size, asm,
8218 (outs listtype:$dst),
8219 (ins listtype:$Vt, VectorIndexD:$idx,
8220 am_simdnoindex:$vaddr), []>;
8222 def i64_POST : SIMDLdStSingleDTiedPost<1, R, opcode, size, asm,
8223 (outs am_simdnoindex:$wback, listtype:$dst),
8224 (ins listtype:$Vt, VectorIndexD:$idx,
8225 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8227 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8228 multiclass SIMDStSingleB<bit R, bits<3> opcode, string asm,
8229 RegisterOperand listtype, RegisterOperand GPR64pi> {
8230 def i8 : SIMDLdStSingleB<0, R, opcode, asm,
8231 (outs), (ins listtype:$Vt, VectorIndexB:$idx,
8232 am_simdnoindex:$vaddr), []>;
8234 def i8_POST : SIMDLdStSingleBPost<0, R, opcode, asm,
8235 (outs am_simdnoindex:$wback),
8236 (ins listtype:$Vt, VectorIndexB:$idx,
8237 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8239 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8240 multiclass SIMDStSingleH<bit R, bits<3> opcode, bit size, string asm,
8241 RegisterOperand listtype, RegisterOperand GPR64pi> {
8242 def i16 : SIMDLdStSingleH<0, R, opcode, size, asm,
8243 (outs), (ins listtype:$Vt, VectorIndexH:$idx,
8244 am_simdnoindex:$vaddr), []>;
8246 def i16_POST : SIMDLdStSingleHPost<0, R, opcode, size, asm,
8247 (outs am_simdnoindex:$wback),
8248 (ins listtype:$Vt, VectorIndexH:$idx,
8249 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8251 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8252 multiclass SIMDStSingleS<bit R, bits<3> opcode, bits<2> size,string asm,
8253 RegisterOperand listtype, RegisterOperand GPR64pi> {
8254 def i32 : SIMDLdStSingleS<0, R, opcode, size, asm,
8255 (outs), (ins listtype:$Vt, VectorIndexS:$idx,
8256 am_simdnoindex:$vaddr), []>;
8258 def i32_POST : SIMDLdStSingleSPost<0, R, opcode, size, asm,
8259 (outs am_simdnoindex:$wback),
8260 (ins listtype:$Vt, VectorIndexS:$idx,
8261 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8263 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8264 multiclass SIMDStSingleD<bit R, bits<3> opcode, bits<2> size, string asm,
8265 RegisterOperand listtype, RegisterOperand GPR64pi> {
8266 def i64 : SIMDLdStSingleD<0, R, opcode, size, asm,
8267 (outs), (ins listtype:$Vt, VectorIndexD:$idx,
8268 am_simdnoindex:$vaddr), []>;
8270 def i64_POST : SIMDLdStSingleDPost<0, R, opcode, size, asm,
8271 (outs am_simdnoindex:$wback),
8272 (ins listtype:$Vt, VectorIndexD:$idx,
8273 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8276 multiclass SIMDLdStSingleAliases<string asm, string layout, string Type,
8277 string Count, int Offset, Operand idxtype> {
8278 // E.g. "ld1 { v0.8b }[0], [x1], #1"
8279 // "ld1\t$Vt, $vaddr, #1"
8280 // may get mapped to
8281 // (LD1Rv8b_POST VecListOne8b:$Vt, am_simdnoindex:$vaddr, XZR)
8282 def : InstAlias<asm # "\t$Vt$idx, $vaddr, #" # Offset,
8283 (!cast<Instruction>(NAME # Type # "_POST")
8284 am_simdnoindex:$vaddr,
8285 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
8286 idxtype:$idx, XZR), 1>;
8288 // E.g. "ld1.8b { v0 }[0], [x1], #1"
8289 // "ld1.8b\t$Vt, $vaddr, #1"
8290 // may get mapped to
8291 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, XZR)
8292 def : InstAlias<asm # "." # layout # "\t$Vt$idx, $vaddr, #" # Offset,
8293 (!cast<Instruction>(NAME # Type # "_POST")
8294 am_simdnoindex:$vaddr,
8295 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8296 idxtype:$idx, XZR), 0>;
8298 // E.g. "ld1.8b { v0 }[0], [x1]"
8299 // "ld1.8b\t$Vt, $vaddr"
8300 // may get mapped to
8301 // (LD1Rv8b VecListOne64:$Vt, am_simdnoindex:$vaddr)
8302 def : InstAlias<asm # "." # layout # "\t$Vt$idx, $vaddr",
8303 (!cast<Instruction>(NAME # Type)
8304 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8305 idxtype:$idx, am_simdnoindex:$vaddr), 0>;
8307 // E.g. "ld1.8b { v0 }[0], [x1], x2"
8308 // "ld1.8b\t$Vt, $vaddr, $Xm"
8309 // may get mapped to
8310 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, GPR64pi1:$Xm)
8311 def : InstAlias<asm # "." # layout # "\t$Vt$idx, $vaddr, $Xm",
8312 (!cast<Instruction>(NAME # Type # "_POST")
8313 am_simdnoindex:$vaddr,
8314 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8316 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
8319 multiclass SIMDLdSt1SingleAliases<string asm> {
8320 defm : SIMDLdStSingleAliases<asm, "b", "i8", "One", 1, VectorIndexB>;
8321 defm : SIMDLdStSingleAliases<asm, "h", "i16", "One", 2, VectorIndexH>;
8322 defm : SIMDLdStSingleAliases<asm, "s", "i32", "One", 4, VectorIndexS>;
8323 defm : SIMDLdStSingleAliases<asm, "d", "i64", "One", 8, VectorIndexD>;
8326 multiclass SIMDLdSt2SingleAliases<string asm> {
8327 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Two", 2, VectorIndexB>;
8328 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Two", 4, VectorIndexH>;
8329 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Two", 8, VectorIndexS>;
8330 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Two", 16, VectorIndexD>;
8333 multiclass SIMDLdSt3SingleAliases<string asm> {
8334 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Three", 3, VectorIndexB>;
8335 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Three", 6, VectorIndexH>;
8336 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Three", 12, VectorIndexS>;
8337 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Three", 24, VectorIndexD>;
8340 multiclass SIMDLdSt4SingleAliases<string asm> {
8341 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Four", 4, VectorIndexB>;
8342 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Four", 8, VectorIndexH>;
8343 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Four", 16, VectorIndexS>;
8344 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Four", 32, VectorIndexD>;
8346 } // end of 'let Predicates = [HasNEON]'
8348 //----------------------------------------------------------------------------
8349 // Crypto extensions
8350 //----------------------------------------------------------------------------
8352 let Predicates = [HasCrypto] in {
8353 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8354 class AESBase<bits<4> opc, string asm, dag outs, dag ins, string cstr,
8356 : I<outs, ins, asm, "{\t$Rd.16b, $Rn.16b|.16b\t$Rd, $Rn}", cstr, pat>,
8360 let Inst{31-16} = 0b0100111000101000;
8361 let Inst{15-12} = opc;
8362 let Inst{11-10} = 0b10;
8367 class AESInst<bits<4> opc, string asm, Intrinsic OpNode>
8368 : AESBase<opc, asm, (outs V128:$Rd), (ins V128:$Rn), "",
8369 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
8371 class AESTiedInst<bits<4> opc, string asm, Intrinsic OpNode>
8372 : AESBase<opc, asm, (outs V128:$dst), (ins V128:$Rd, V128:$Rn),
8374 [(set (v16i8 V128:$dst),
8375 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
8377 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8378 class SHA3OpTiedInst<bits<3> opc, string asm, string dst_lhs_kind,
8379 dag oops, dag iops, list<dag> pat>
8380 : I<oops, iops, asm,
8381 "{\t$Rd" # dst_lhs_kind # ", $Rn" # dst_lhs_kind # ", $Rm.4s" #
8382 "|.4s\t$Rd, $Rn, $Rm}", "$Rd = $dst", pat>,
8387 let Inst{31-21} = 0b01011110000;
8388 let Inst{20-16} = Rm;
8390 let Inst{14-12} = opc;
8391 let Inst{11-10} = 0b00;
8396 class SHATiedInstQSV<bits<3> opc, string asm, Intrinsic OpNode>
8397 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
8398 (ins FPR128:$Rd, FPR32:$Rn, V128:$Rm),
8399 [(set (v4i32 FPR128:$dst),
8400 (OpNode (v4i32 FPR128:$Rd), (i32 FPR32:$Rn),
8401 (v4i32 V128:$Rm)))]>;
8403 class SHATiedInstVVV<bits<3> opc, string asm, Intrinsic OpNode>
8404 : SHA3OpTiedInst<opc, asm, ".4s", (outs V128:$dst),
8405 (ins V128:$Rd, V128:$Rn, V128:$Rm),
8406 [(set (v4i32 V128:$dst),
8407 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
8408 (v4i32 V128:$Rm)))]>;
8410 class SHATiedInstQQV<bits<3> opc, string asm, Intrinsic OpNode>
8411 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
8412 (ins FPR128:$Rd, FPR128:$Rn, V128:$Rm),
8413 [(set (v4i32 FPR128:$dst),
8414 (OpNode (v4i32 FPR128:$Rd), (v4i32 FPR128:$Rn),
8415 (v4i32 V128:$Rm)))]>;
8417 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8418 class SHA2OpInst<bits<4> opc, string asm, string kind,
8419 string cstr, dag oops, dag iops,
8421 : I<oops, iops, asm, "{\t$Rd" # kind # ", $Rn" # kind #
8422 "|" # kind # "\t$Rd, $Rn}", cstr, pat>,
8426 let Inst{31-16} = 0b0101111000101000;
8427 let Inst{15-12} = opc;
8428 let Inst{11-10} = 0b10;
8433 class SHATiedInstVV<bits<4> opc, string asm, Intrinsic OpNode>
8434 : SHA2OpInst<opc, asm, ".4s", "$Rd = $dst", (outs V128:$dst),
8435 (ins V128:$Rd, V128:$Rn),
8436 [(set (v4i32 V128:$dst),
8437 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
8439 class SHAInstSS<bits<4> opc, string asm, Intrinsic OpNode>
8440 : SHA2OpInst<opc, asm, "", "", (outs FPR32:$Rd), (ins FPR32:$Rn),
8441 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
8442 } // end of 'let Predicates = [HasCrypto]'
8444 // Allow the size specifier tokens to be upper case, not just lower.
8445 def : TokenAlias<".8B", ".8b">;
8446 def : TokenAlias<".4H", ".4h">;
8447 def : TokenAlias<".2S", ".2s">;
8448 def : TokenAlias<".1D", ".1d">;
8449 def : TokenAlias<".16B", ".16b">;
8450 def : TokenAlias<".8H", ".8h">;
8451 def : TokenAlias<".4S", ".4s">;
8452 def : TokenAlias<".2D", ".2d">;
8453 def : TokenAlias<".1Q", ".1q">;
8454 def : TokenAlias<".B", ".b">;
8455 def : TokenAlias<".H", ".h">;
8456 def : TokenAlias<".S", ".s">;
8457 def : TokenAlias<".D", ".d">;
8458 def : TokenAlias<".Q", ".q">;