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;
1325 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1326 class BaseMoveImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
1328 : I<(outs regtype:$Rd), (ins movimm32_imm:$imm, shifter:$shift),
1329 asm, "\t$Rd, $imm$shift", "", []>,
1334 let Inst{30-29} = opc;
1335 let Inst{28-23} = 0b100101;
1336 let Inst{22-21} = shift{5-4};
1337 let Inst{20-5} = imm;
1340 let DecoderMethod = "DecodeMoveImmInstruction";
1343 multiclass MoveImmediate<bits<2> opc, string asm> {
1344 def Wi : BaseMoveImmediate<opc, GPR32, movimm32_shift, asm> {
1348 def Xi : BaseMoveImmediate<opc, GPR64, movimm64_shift, asm> {
1353 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1354 class BaseInsertImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
1356 : I<(outs regtype:$Rd),
1357 (ins regtype:$src, movimm32_imm:$imm, shifter:$shift),
1358 asm, "\t$Rd, $imm$shift", "$src = $Rd", []>,
1363 let Inst{30-29} = opc;
1364 let Inst{28-23} = 0b100101;
1365 let Inst{22-21} = shift{5-4};
1366 let Inst{20-5} = imm;
1369 let DecoderMethod = "DecodeMoveImmInstruction";
1372 multiclass InsertImmediate<bits<2> opc, string asm> {
1373 def Wi : BaseInsertImmediate<opc, GPR32, movimm32_shift, asm> {
1377 def Xi : BaseInsertImmediate<opc, GPR64, movimm64_shift, asm> {
1386 class BaseAddSubImm<bit isSub, bit setFlags, RegisterClass dstRegtype,
1387 RegisterClass srcRegtype, addsub_shifted_imm immtype,
1388 string asm, SDPatternOperator OpNode>
1389 : I<(outs dstRegtype:$Rd), (ins srcRegtype:$Rn, immtype:$imm),
1390 asm, "\t$Rd, $Rn, $imm", "",
1391 [(set dstRegtype:$Rd, (OpNode srcRegtype:$Rn, immtype:$imm))]>,
1396 let Inst{30} = isSub;
1397 let Inst{29} = setFlags;
1398 let Inst{28-24} = 0b10001;
1399 let Inst{23-22} = imm{13-12}; // '00' => lsl #0, '01' => lsl #12
1400 let Inst{21-10} = imm{11-0};
1403 let DecoderMethod = "DecodeBaseAddSubImm";
1406 class BaseAddSubRegPseudo<RegisterClass regtype,
1407 SDPatternOperator OpNode>
1408 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1409 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
1412 class BaseAddSubSReg<bit isSub, bit setFlags, RegisterClass regtype,
1413 arith_shifted_reg shifted_regtype, string asm,
1414 SDPatternOperator OpNode>
1415 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
1416 asm, "\t$Rd, $Rn, $Rm", "",
1417 [(set regtype:$Rd, (OpNode regtype:$Rn, shifted_regtype:$Rm))]>,
1418 Sched<[WriteISReg]> {
1419 // The operands are in order to match the 'addr' MI operands, so we
1420 // don't need an encoder method and by-name matching. Just use the default
1421 // in-order handling. Since we're using by-order, make sure the names
1427 let Inst{30} = isSub;
1428 let Inst{29} = setFlags;
1429 let Inst{28-24} = 0b01011;
1430 let Inst{23-22} = shift{7-6};
1432 let Inst{20-16} = src2;
1433 let Inst{15-10} = shift{5-0};
1434 let Inst{9-5} = src1;
1435 let Inst{4-0} = dst;
1437 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
1440 class BaseAddSubEReg<bit isSub, bit setFlags, RegisterClass dstRegtype,
1441 RegisterClass src1Regtype, Operand src2Regtype,
1442 string asm, SDPatternOperator OpNode>
1443 : I<(outs dstRegtype:$R1),
1444 (ins src1Regtype:$R2, src2Regtype:$R3),
1445 asm, "\t$R1, $R2, $R3", "",
1446 [(set dstRegtype:$R1, (OpNode src1Regtype:$R2, src2Regtype:$R3))]>,
1447 Sched<[WriteIEReg]> {
1452 let Inst{30} = isSub;
1453 let Inst{29} = setFlags;
1454 let Inst{28-24} = 0b01011;
1455 let Inst{23-21} = 0b001;
1456 let Inst{20-16} = Rm;
1457 let Inst{15-13} = ext{5-3};
1458 let Inst{12-10} = ext{2-0};
1462 let DecoderMethod = "DecodeAddSubERegInstruction";
1465 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1466 class BaseAddSubEReg64<bit isSub, bit setFlags, RegisterClass dstRegtype,
1467 RegisterClass src1Regtype, RegisterClass src2Regtype,
1468 Operand ext_op, string asm>
1469 : I<(outs dstRegtype:$Rd),
1470 (ins src1Regtype:$Rn, src2Regtype:$Rm, ext_op:$ext),
1471 asm, "\t$Rd, $Rn, $Rm$ext", "", []>,
1472 Sched<[WriteIEReg]> {
1477 let Inst{30} = isSub;
1478 let Inst{29} = setFlags;
1479 let Inst{28-24} = 0b01011;
1480 let Inst{23-21} = 0b001;
1481 let Inst{20-16} = Rm;
1482 let Inst{15} = ext{5};
1483 let Inst{12-10} = ext{2-0};
1487 let DecoderMethod = "DecodeAddSubERegInstruction";
1490 // Aliases for register+register add/subtract.
1491 class AddSubRegAlias<string asm, Instruction inst, RegisterClass dstRegtype,
1492 RegisterClass src1Regtype, RegisterClass src2Regtype,
1494 : InstAlias<asm#" $dst, $src1, $src2",
1495 (inst dstRegtype:$dst, src1Regtype:$src1, src2Regtype:$src2,
1498 multiclass AddSub<bit isSub, string mnemonic,
1499 SDPatternOperator OpNode = null_frag> {
1500 let hasSideEffects = 0 in {
1501 // Add/Subtract immediate
1502 def Wri : BaseAddSubImm<isSub, 0, GPR32sp, GPR32sp, addsub_shifted_imm32,
1506 def Xri : BaseAddSubImm<isSub, 0, GPR64sp, GPR64sp, addsub_shifted_imm64,
1511 // Add/Subtract register - Only used for CodeGen
1512 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
1513 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
1515 // Add/Subtract shifted register
1516 def Wrs : BaseAddSubSReg<isSub, 0, GPR32, arith_shifted_reg32, mnemonic,
1520 def Xrs : BaseAddSubSReg<isSub, 0, GPR64, arith_shifted_reg64, mnemonic,
1526 // Add/Subtract extended register
1527 let AddedComplexity = 1, hasSideEffects = 0 in {
1528 def Wrx : BaseAddSubEReg<isSub, 0, GPR32sp, GPR32sp,
1529 arith_extended_reg32<i32>, mnemonic, OpNode> {
1532 def Xrx : BaseAddSubEReg<isSub, 0, GPR64sp, GPR64sp,
1533 arith_extended_reg32to64<i64>, mnemonic, OpNode> {
1538 def Xrx64 : BaseAddSubEReg64<isSub, 0, GPR64sp, GPR64sp, GPR64,
1539 arith_extendlsl64, mnemonic> {
1540 // UXTX and SXTX only.
1541 let Inst{14-13} = 0b11;
1545 // Register/register aliases with no shift when SP is not used.
1546 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
1547 GPR32, GPR32, GPR32, 0>;
1548 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
1549 GPR64, GPR64, GPR64, 0>;
1551 // Register/register aliases with no shift when either the destination or
1552 // first source register is SP. This relies on the shifted register aliases
1553 // above matching first in the case when SP is not used.
1554 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1555 GPR32sp, GPR32sp, GPR32, 16>; // UXTW #0
1556 def : AddSubRegAlias<mnemonic,
1557 !cast<Instruction>(NAME#"Xrx64"),
1558 GPR64sp, GPR64sp, GPR64, 24>; // UXTX #0
1561 multiclass AddSubS<bit isSub, string mnemonic, SDNode OpNode, string cmp> {
1562 let isCompare = 1, Defs = [NZCV] in {
1563 // Add/Subtract immediate
1564 def Wri : BaseAddSubImm<isSub, 1, GPR32, GPR32sp, addsub_shifted_imm32,
1568 def Xri : BaseAddSubImm<isSub, 1, GPR64, GPR64sp, addsub_shifted_imm64,
1573 // Add/Subtract register
1574 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
1575 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
1577 // Add/Subtract shifted register
1578 def Wrs : BaseAddSubSReg<isSub, 1, GPR32, arith_shifted_reg32, mnemonic,
1582 def Xrs : BaseAddSubSReg<isSub, 1, GPR64, arith_shifted_reg64, mnemonic,
1587 // Add/Subtract extended register
1588 let AddedComplexity = 1 in {
1589 def Wrx : BaseAddSubEReg<isSub, 1, GPR32, GPR32sp,
1590 arith_extended_reg32<i32>, mnemonic, OpNode> {
1593 def Xrx : BaseAddSubEReg<isSub, 1, GPR64, GPR64sp,
1594 arith_extended_reg32<i64>, mnemonic, OpNode> {
1599 def Xrx64 : BaseAddSubEReg64<isSub, 1, GPR64, GPR64sp, GPR64,
1600 arith_extendlsl64, mnemonic> {
1601 // UXTX and SXTX only.
1602 let Inst{14-13} = 0b11;
1608 def : InstAlias<cmp#" $src, $imm", (!cast<Instruction>(NAME#"Wri")
1609 WZR, GPR32sp:$src, addsub_shifted_imm32:$imm)>;
1610 def : InstAlias<cmp#" $src, $imm", (!cast<Instruction>(NAME#"Xri")
1611 XZR, GPR64sp:$src, addsub_shifted_imm64:$imm)>;
1612 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Wrx")
1613 WZR, GPR32sp:$src1, GPR32:$src2, arith_extend:$sh)>;
1614 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Xrx")
1615 XZR, GPR64sp:$src1, GPR32:$src2, arith_extend:$sh)>;
1616 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Xrx64")
1617 XZR, GPR64sp:$src1, GPR64:$src2, arith_extendlsl64:$sh)>;
1618 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Wrs")
1619 WZR, GPR32:$src1, GPR32:$src2, arith_shift32:$sh)>;
1620 def : InstAlias<cmp#" $src1, $src2, $sh", (!cast<Instruction>(NAME#"Xrs")
1621 XZR, GPR64:$src1, GPR64:$src2, arith_shift64:$sh)>;
1623 // Compare shorthands
1624 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Wrs")
1625 WZR, GPR32:$src1, GPR32:$src2, 0)>;
1626 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Xrs")
1627 XZR, GPR64:$src1, GPR64:$src2, 0)>;
1629 // Register/register aliases with no shift when SP is not used.
1630 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
1631 GPR32, GPR32, GPR32, 0>;
1632 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
1633 GPR64, GPR64, GPR64, 0>;
1635 // Register/register aliases with no shift when the first source register
1636 // is SP. This relies on the shifted register aliases above matching first
1637 // in the case when SP is not used.
1638 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1639 GPR32, GPR32sp, GPR32, 16>; // UXTW #0
1640 def : AddSubRegAlias<mnemonic,
1641 !cast<Instruction>(NAME#"Xrx64"),
1642 GPR64, GPR64sp, GPR64, 24>; // UXTX #0
1648 def SDTA64EXTR : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
1650 def ARM64Extr : SDNode<"ARM64ISD::EXTR", SDTA64EXTR>;
1652 class BaseExtractImm<RegisterClass regtype, Operand imm_type, string asm,
1654 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, imm_type:$imm),
1655 asm, "\t$Rd, $Rn, $Rm, $imm", "", patterns>,
1656 Sched<[WriteExtr, ReadExtrHi]> {
1662 let Inst{30-23} = 0b00100111;
1664 let Inst{20-16} = Rm;
1665 let Inst{15-10} = imm;
1670 multiclass ExtractImm<string asm> {
1671 def Wrri : BaseExtractImm<GPR32, imm0_31, asm,
1673 (ARM64Extr GPR32:$Rn, GPR32:$Rm, imm0_31:$imm))]> {
1676 // imm<5> must be zero.
1679 def Xrri : BaseExtractImm<GPR64, imm0_63, asm,
1681 (ARM64Extr GPR64:$Rn, GPR64:$Rm, imm0_63:$imm))]> {
1692 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1693 class BaseBitfieldImm<bits<2> opc,
1694 RegisterClass regtype, Operand imm_type, string asm>
1695 : I<(outs regtype:$Rd), (ins regtype:$Rn, imm_type:$immr, imm_type:$imms),
1696 asm, "\t$Rd, $Rn, $immr, $imms", "", []>,
1703 let Inst{30-29} = opc;
1704 let Inst{28-23} = 0b100110;
1705 let Inst{21-16} = immr;
1706 let Inst{15-10} = imms;
1711 multiclass BitfieldImm<bits<2> opc, string asm> {
1712 def Wri : BaseBitfieldImm<opc, GPR32, imm0_31, asm> {
1715 // imms<5> and immr<5> must be zero, else ReservedValue().
1719 def Xri : BaseBitfieldImm<opc, GPR64, imm0_63, asm> {
1725 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1726 class BaseBitfieldImmWith2RegArgs<bits<2> opc,
1727 RegisterClass regtype, Operand imm_type, string asm>
1728 : I<(outs regtype:$Rd), (ins regtype:$src, regtype:$Rn, imm_type:$immr,
1730 asm, "\t$Rd, $Rn, $immr, $imms", "$src = $Rd", []>,
1737 let Inst{30-29} = opc;
1738 let Inst{28-23} = 0b100110;
1739 let Inst{21-16} = immr;
1740 let Inst{15-10} = imms;
1745 multiclass BitfieldImmWith2RegArgs<bits<2> opc, string asm> {
1746 def Wri : BaseBitfieldImmWith2RegArgs<opc, GPR32, imm0_31, asm> {
1749 // imms<5> and immr<5> must be zero, else ReservedValue().
1753 def Xri : BaseBitfieldImmWith2RegArgs<opc, GPR64, imm0_63, asm> {
1763 // Logical (immediate)
1764 class BaseLogicalImm<bits<2> opc, RegisterClass dregtype,
1765 RegisterClass sregtype, Operand imm_type, string asm,
1767 : I<(outs dregtype:$Rd), (ins sregtype:$Rn, imm_type:$imm),
1768 asm, "\t$Rd, $Rn, $imm", "", pattern>,
1773 let Inst{30-29} = opc;
1774 let Inst{28-23} = 0b100100;
1775 let Inst{22} = imm{12};
1776 let Inst{21-16} = imm{11-6};
1777 let Inst{15-10} = imm{5-0};
1781 let DecoderMethod = "DecodeLogicalImmInstruction";
1784 // Logical (shifted register)
1785 class BaseLogicalSReg<bits<2> opc, bit N, RegisterClass regtype,
1786 logical_shifted_reg shifted_regtype, string asm,
1788 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
1789 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
1790 Sched<[WriteISReg]> {
1791 // The operands are in order to match the 'addr' MI operands, so we
1792 // don't need an encoder method and by-name matching. Just use the default
1793 // in-order handling. Since we're using by-order, make sure the names
1799 let Inst{30-29} = opc;
1800 let Inst{28-24} = 0b01010;
1801 let Inst{23-22} = shift{7-6};
1803 let Inst{20-16} = src2;
1804 let Inst{15-10} = shift{5-0};
1805 let Inst{9-5} = src1;
1806 let Inst{4-0} = dst;
1808 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
1811 // Aliases for register+register logical instructions.
1812 class LogicalRegAlias<string asm, Instruction inst, RegisterClass regtype>
1813 : InstAlias<asm#" $dst, $src1, $src2",
1814 (inst regtype:$dst, regtype:$src1, regtype:$src2, 0)>;
1816 let AddedComplexity = 6 in
1817 multiclass LogicalImm<bits<2> opc, string mnemonic, SDNode OpNode> {
1818 def Wri : BaseLogicalImm<opc, GPR32sp, GPR32, logical_imm32, mnemonic,
1819 [(set GPR32sp:$Rd, (OpNode GPR32:$Rn,
1820 logical_imm32:$imm))]> {
1822 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
1824 def Xri : BaseLogicalImm<opc, GPR64sp, GPR64, logical_imm64, mnemonic,
1825 [(set GPR64sp:$Rd, (OpNode GPR64:$Rn,
1826 logical_imm64:$imm))]> {
1831 multiclass LogicalImmS<bits<2> opc, string mnemonic, SDNode OpNode> {
1832 let isCompare = 1, Defs = [NZCV] in {
1833 def Wri : BaseLogicalImm<opc, GPR32, GPR32, logical_imm32, mnemonic,
1834 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_imm32:$imm))]> {
1836 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
1838 def Xri : BaseLogicalImm<opc, GPR64, GPR64, logical_imm64, mnemonic,
1839 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_imm64:$imm))]> {
1842 } // end Defs = [NZCV]
1845 class BaseLogicalRegPseudo<RegisterClass regtype, SDPatternOperator OpNode>
1846 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1847 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
1850 // Split from LogicalImm as not all instructions have both.
1851 multiclass LogicalReg<bits<2> opc, bit N, string mnemonic,
1852 SDPatternOperator OpNode> {
1853 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
1854 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
1856 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
1857 [(set GPR32:$Rd, (OpNode GPR32:$Rn,
1858 logical_shifted_reg32:$Rm))]> {
1861 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
1862 [(set GPR64:$Rd, (OpNode GPR64:$Rn,
1863 logical_shifted_reg64:$Rm))]> {
1867 def : LogicalRegAlias<mnemonic,
1868 !cast<Instruction>(NAME#"Wrs"), GPR32>;
1869 def : LogicalRegAlias<mnemonic,
1870 !cast<Instruction>(NAME#"Xrs"), GPR64>;
1873 // Split from LogicalReg to allow setting NZCV Defs
1874 multiclass LogicalRegS<bits<2> opc, bit N, string mnemonic,
1875 SDPatternOperator OpNode = null_frag> {
1876 let Defs = [NZCV], mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
1877 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
1878 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
1880 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
1881 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_shifted_reg32:$Rm))]> {
1884 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
1885 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_shifted_reg64:$Rm))]> {
1890 def : LogicalRegAlias<mnemonic,
1891 !cast<Instruction>(NAME#"Wrs"), GPR32>;
1892 def : LogicalRegAlias<mnemonic,
1893 !cast<Instruction>(NAME#"Xrs"), GPR64>;
1897 // Conditionally set flags
1901 // 4-bit immediate. Pretty-printed as <cc>
1902 def ccode : Operand<i32> {
1903 let PrintMethod = "printCondCode";
1906 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1907 class BaseCondSetFlagsImm<bit op, RegisterClass regtype, string asm>
1908 : I<(outs), (ins regtype:$Rn, imm0_31:$imm, imm0_15:$nzcv, ccode:$cond),
1909 asm, "\t$Rn, $imm, $nzcv, $cond", "", []>,
1920 let Inst{29-21} = 0b111010010;
1921 let Inst{20-16} = imm;
1922 let Inst{15-12} = cond;
1923 let Inst{11-10} = 0b10;
1926 let Inst{3-0} = nzcv;
1929 multiclass CondSetFlagsImm<bit op, string asm> {
1930 def Wi : BaseCondSetFlagsImm<op, GPR32, asm> {
1933 def Xi : BaseCondSetFlagsImm<op, GPR64, asm> {
1938 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1939 class BaseCondSetFlagsReg<bit op, RegisterClass regtype, string asm>
1940 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm0_15:$nzcv, ccode:$cond),
1941 asm, "\t$Rn, $Rm, $nzcv, $cond", "", []>,
1952 let Inst{29-21} = 0b111010010;
1953 let Inst{20-16} = Rm;
1954 let Inst{15-12} = cond;
1955 let Inst{11-10} = 0b00;
1958 let Inst{3-0} = nzcv;
1961 multiclass CondSetFlagsReg<bit op, string asm> {
1962 def Wr : BaseCondSetFlagsReg<op, GPR32, asm> {
1965 def Xr : BaseCondSetFlagsReg<op, GPR64, asm> {
1971 // Conditional select
1974 class BaseCondSelect<bit op, bits<2> op2, RegisterClass regtype, string asm>
1975 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
1976 asm, "\t$Rd, $Rn, $Rm, $cond", "",
1978 (ARM64csel regtype:$Rn, regtype:$Rm, (i32 imm:$cond), NZCV))]>,
1988 let Inst{29-21} = 0b011010100;
1989 let Inst{20-16} = Rm;
1990 let Inst{15-12} = cond;
1991 let Inst{11-10} = op2;
1996 multiclass CondSelect<bit op, bits<2> op2, string asm> {
1997 def Wr : BaseCondSelect<op, op2, GPR32, asm> {
2000 def Xr : BaseCondSelect<op, op2, GPR64, asm> {
2005 class BaseCondSelectOp<bit op, bits<2> op2, RegisterClass regtype, string asm,
2007 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
2008 asm, "\t$Rd, $Rn, $Rm, $cond", "",
2010 (ARM64csel regtype:$Rn, (frag regtype:$Rm),
2011 (i32 imm:$cond), NZCV))]>,
2021 let Inst{29-21} = 0b011010100;
2022 let Inst{20-16} = Rm;
2023 let Inst{15-12} = cond;
2024 let Inst{11-10} = op2;
2029 def inv_cond_XFORM : SDNodeXForm<imm, [{
2030 ARM64CC::CondCode CC = static_cast<ARM64CC::CondCode>(N->getZExtValue());
2031 return CurDAG->getTargetConstant(ARM64CC::getInvertedCondCode(CC), MVT::i32);
2034 multiclass CondSelectOp<bit op, bits<2> op2, string asm, PatFrag frag> {
2035 def Wr : BaseCondSelectOp<op, op2, GPR32, asm, frag> {
2038 def Xr : BaseCondSelectOp<op, op2, GPR64, asm, frag> {
2042 def : Pat<(ARM64csel (frag GPR32:$Rm), GPR32:$Rn, (i32 imm:$cond), NZCV),
2043 (!cast<Instruction>(NAME # Wr) GPR32:$Rn, GPR32:$Rm,
2044 (inv_cond_XFORM imm:$cond))>;
2046 def : Pat<(ARM64csel (frag GPR64:$Rm), GPR64:$Rn, (i32 imm:$cond), NZCV),
2047 (!cast<Instruction>(NAME # Xr) GPR64:$Rn, GPR64:$Rm,
2048 (inv_cond_XFORM imm:$cond))>;
2052 // Special Mask Value
2054 def maski8_or_more : Operand<i32>,
2055 ImmLeaf<i32, [{ return (Imm & 0xff) == 0xff; }]> {
2057 def maski16_or_more : Operand<i32>,
2058 ImmLeaf<i32, [{ return (Imm & 0xffff) == 0xffff; }]> {
2066 // (unsigned immediate)
2067 // Indexed for 8-bit registers. offset is in range [0,4095].
2068 def MemoryIndexed8Operand : AsmOperandClass {
2069 let Name = "MemoryIndexed8";
2070 let DiagnosticType = "InvalidMemoryIndexed8";
2072 def am_indexed8 : Operand<i64>,
2073 ComplexPattern<i64, 2, "SelectAddrModeIndexed8", []> {
2074 let PrintMethod = "printAMIndexed<8>";
2076 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale1>";
2077 let ParserMatchClass = MemoryIndexed8Operand;
2078 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2081 // Indexed for 16-bit registers. offset is multiple of 2 in range [0,8190],
2082 // stored as immval/2 (the 12-bit literal that encodes directly into the insn).
2083 def MemoryIndexed16Operand : AsmOperandClass {
2084 let Name = "MemoryIndexed16";
2085 let DiagnosticType = "InvalidMemoryIndexed16";
2087 def am_indexed16 : Operand<i64>,
2088 ComplexPattern<i64, 2, "SelectAddrModeIndexed16", []> {
2089 let PrintMethod = "printAMIndexed<16>";
2091 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale2>";
2092 let ParserMatchClass = MemoryIndexed16Operand;
2093 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2096 // Indexed for 32-bit registers. offset is multiple of 4 in range [0,16380],
2097 // stored as immval/4 (the 12-bit literal that encodes directly into the insn).
2098 def MemoryIndexed32Operand : AsmOperandClass {
2099 let Name = "MemoryIndexed32";
2100 let DiagnosticType = "InvalidMemoryIndexed32";
2102 def am_indexed32 : Operand<i64>,
2103 ComplexPattern<i64, 2, "SelectAddrModeIndexed32", []> {
2104 let PrintMethod = "printAMIndexed<32>";
2106 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale4>";
2107 let ParserMatchClass = MemoryIndexed32Operand;
2108 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2111 // Indexed for 64-bit registers. offset is multiple of 8 in range [0,32760],
2112 // stored as immval/8 (the 12-bit literal that encodes directly into the insn).
2113 def MemoryIndexed64Operand : AsmOperandClass {
2114 let Name = "MemoryIndexed64";
2115 let DiagnosticType = "InvalidMemoryIndexed64";
2117 def am_indexed64 : Operand<i64>,
2118 ComplexPattern<i64, 2, "SelectAddrModeIndexed64", []> {
2119 let PrintMethod = "printAMIndexed<64>";
2121 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale8>";
2122 let ParserMatchClass = MemoryIndexed64Operand;
2123 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2126 // Indexed for 128-bit registers. offset is multiple of 16 in range [0,65520],
2127 // stored as immval/16 (the 12-bit literal that encodes directly into the insn).
2128 def MemoryIndexed128Operand : AsmOperandClass {
2129 let Name = "MemoryIndexed128";
2130 let DiagnosticType = "InvalidMemoryIndexed128";
2132 def am_indexed128 : Operand<i64>,
2133 ComplexPattern<i64, 2, "SelectAddrModeIndexed128", []> {
2134 let PrintMethod = "printAMIndexed<128>";
2136 = "getAMIndexed8OpValue<ARM64::fixup_arm64_ldst_imm12_scale16>";
2137 let ParserMatchClass = MemoryIndexed128Operand;
2138 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2142 def MemoryNoIndexOperand : AsmOperandClass { let Name = "MemoryNoIndex"; }
2143 def am_noindex : Operand<i64>,
2144 ComplexPattern<i64, 1, "SelectAddrModeNoIndex", []> {
2145 let PrintMethod = "printAMNoIndex";
2146 let ParserMatchClass = MemoryNoIndexOperand;
2147 let MIOperandInfo = (ops GPR64sp:$base);
2150 class BaseLoadStoreUI<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2151 string asm, list<dag> pattern>
2152 : I<oops, iops, asm, "\t$Rt, $addr", "", pattern> {
2156 bits<5> base = addr{4-0};
2157 bits<12> offset = addr{16-5};
2159 let Inst{31-30} = sz;
2160 let Inst{29-27} = 0b111;
2162 let Inst{25-24} = 0b01;
2163 let Inst{23-22} = opc;
2164 let Inst{21-10} = offset;
2165 let Inst{9-5} = base;
2166 let Inst{4-0} = dst;
2168 let DecoderMethod = "DecodeUnsignedLdStInstruction";
2171 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2172 class LoadUI<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2173 Operand indextype, string asm, list<dag> pattern>
2174 : BaseLoadStoreUI<sz, V, opc,
2175 (outs regtype:$Rt), (ins indextype:$addr), asm, pattern>,
2178 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2179 class StoreUI<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2180 Operand indextype, string asm, list<dag> pattern>
2181 : BaseLoadStoreUI<sz, V, opc,
2182 (outs), (ins regtype:$Rt, indextype:$addr), asm, pattern>,
2185 def PrefetchOperand : AsmOperandClass {
2186 let Name = "Prefetch";
2187 let ParserMethod = "tryParsePrefetch";
2189 def prfop : Operand<i32> {
2190 let PrintMethod = "printPrefetchOp";
2191 let ParserMatchClass = PrefetchOperand;
2194 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2195 class PrefetchUI<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2196 : BaseLoadStoreUI<sz, V, opc,
2197 (outs), (ins prfop:$Rt, am_indexed64:$addr), asm, pat>,
2204 // Load literal address: 19-bit immediate. The low two bits of the target
2205 // offset are implied zero and so are not part of the immediate.
2206 def am_ldrlit : Operand<OtherVT> {
2207 let EncoderMethod = "getLoadLiteralOpValue";
2208 let DecoderMethod = "DecodePCRelLabel19";
2209 let PrintMethod = "printAlignedLabel";
2210 let ParserMatchClass = PCRelLabel19Operand;
2213 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2214 class LoadLiteral<bits<2> opc, bit V, RegisterClass regtype, string asm>
2215 : I<(outs regtype:$Rt), (ins am_ldrlit:$label),
2216 asm, "\t$Rt, $label", "", []>,
2220 let Inst{31-30} = opc;
2221 let Inst{29-27} = 0b011;
2223 let Inst{25-24} = 0b00;
2224 let Inst{23-5} = label;
2228 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2229 class PrefetchLiteral<bits<2> opc, bit V, string asm, list<dag> pat>
2230 : I<(outs), (ins prfop:$Rt, am_ldrlit:$label),
2231 asm, "\t$Rt, $label", "", pat>,
2235 let Inst{31-30} = opc;
2236 let Inst{29-27} = 0b011;
2238 let Inst{25-24} = 0b00;
2239 let Inst{23-5} = label;
2244 // Load/store register offset
2247 class MemROAsmOperand<int sz> : AsmOperandClass {
2248 let Name = "MemoryRegisterOffset"#sz;
2251 def MemROAsmOperand8 : MemROAsmOperand<8>;
2252 def MemROAsmOperand16 : MemROAsmOperand<16>;
2253 def MemROAsmOperand32 : MemROAsmOperand<32>;
2254 def MemROAsmOperand64 : MemROAsmOperand<64>;
2255 def MemROAsmOperand128 : MemROAsmOperand<128>;
2257 class ro_indexed<int sz> : Operand<i64> { // ComplexPattern<...>
2258 let PrintMethod = "printMemoryRegOffset<" # sz # ">";
2259 let MIOperandInfo = (ops GPR64sp:$base, GPR64:$offset, i32imm:$extend);
2262 def ro_indexed8 : ro_indexed<8>, ComplexPattern<i64, 3, "SelectAddrModeRO8", []> {
2263 let ParserMatchClass = MemROAsmOperand8;
2266 def ro_indexed16 : ro_indexed<16>, ComplexPattern<i64, 3, "SelectAddrModeRO16", []> {
2267 let ParserMatchClass = MemROAsmOperand16;
2270 def ro_indexed32 : ro_indexed<32>, ComplexPattern<i64, 3, "SelectAddrModeRO32", []> {
2271 let ParserMatchClass = MemROAsmOperand32;
2274 def ro_indexed64 : ro_indexed<64>, ComplexPattern<i64, 3, "SelectAddrModeRO64", []> {
2275 let ParserMatchClass = MemROAsmOperand64;
2278 def ro_indexed128 : ro_indexed<128>, ComplexPattern<i64, 3, "SelectAddrModeRO128", []> {
2279 let ParserMatchClass = MemROAsmOperand128;
2282 class LoadStore8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2283 string asm, dag ins, dag outs, list<dag> pat>
2284 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2285 // The operands are in order to match the 'addr' MI operands, so we
2286 // don't need an encoder method and by-name matching. Just use the default
2287 // in-order handling. Since we're using by-order, make sure the names
2293 let Inst{31-30} = sz;
2294 let Inst{29-27} = 0b111;
2296 let Inst{25-24} = 0b00;
2297 let Inst{23-22} = opc;
2299 let Inst{20-16} = offset;
2300 let Inst{15-13} = extend{3-1};
2302 let Inst{12} = extend{0};
2303 let Inst{11-10} = 0b10;
2304 let Inst{9-5} = base;
2305 let Inst{4-0} = dst;
2307 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2310 class Load8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2311 string asm, list<dag> pat>
2312 : LoadStore8RO<sz, V, opc, regtype, asm,
2313 (outs regtype:$Rt), (ins ro_indexed8:$addr), pat>,
2314 Sched<[WriteLDIdx, ReadAdrBase]>;
2316 class Store8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2317 string asm, list<dag> pat>
2318 : LoadStore8RO<sz, V, opc, regtype, asm,
2319 (outs), (ins regtype:$Rt, ro_indexed8:$addr), pat>,
2320 Sched<[WriteSTIdx, ReadAdrBase]>;
2322 class LoadStore16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2323 string asm, dag ins, dag outs, list<dag> pat>
2324 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2325 // The operands are in order to match the 'addr' MI operands, so we
2326 // don't need an encoder method and by-name matching. Just use the default
2327 // in-order handling. Since we're using by-order, make sure the names
2333 let Inst{31-30} = sz;
2334 let Inst{29-27} = 0b111;
2336 let Inst{25-24} = 0b00;
2337 let Inst{23-22} = opc;
2339 let Inst{20-16} = offset;
2340 let Inst{15-13} = extend{3-1};
2342 let Inst{12} = extend{0};
2343 let Inst{11-10} = 0b10;
2344 let Inst{9-5} = base;
2345 let Inst{4-0} = dst;
2347 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2350 class Load16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2351 string asm, list<dag> pat>
2352 : LoadStore16RO<sz, V, opc, regtype, asm,
2353 (outs regtype:$Rt), (ins ro_indexed16:$addr), pat>,
2354 Sched<[WriteLDIdx, ReadAdrBase]>;
2356 class Store16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2357 string asm, list<dag> pat>
2358 : LoadStore16RO<sz, V, opc, regtype, asm,
2359 (outs), (ins regtype:$Rt, ro_indexed16:$addr), pat>,
2360 Sched<[WriteSTIdx, ReadAdrBase]>;
2362 class LoadStore32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2363 string asm, dag ins, dag outs, list<dag> pat>
2364 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2365 // The operands are in order to match the 'addr' MI operands, so we
2366 // don't need an encoder method and by-name matching. Just use the default
2367 // in-order handling. Since we're using by-order, make sure the names
2373 let Inst{31-30} = sz;
2374 let Inst{29-27} = 0b111;
2376 let Inst{25-24} = 0b00;
2377 let Inst{23-22} = opc;
2379 let Inst{20-16} = offset;
2380 let Inst{15-13} = extend{3-1};
2382 let Inst{12} = extend{0};
2383 let Inst{11-10} = 0b10;
2384 let Inst{9-5} = base;
2385 let Inst{4-0} = dst;
2387 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2390 class Load32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2391 string asm, list<dag> pat>
2392 : LoadStore32RO<sz, V, opc, regtype, asm,
2393 (outs regtype:$Rt), (ins ro_indexed32:$addr), pat>,
2394 Sched<[WriteLDIdx, ReadAdrBase]>;
2396 class Store32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2397 string asm, list<dag> pat>
2398 : LoadStore32RO<sz, V, opc, regtype, asm,
2399 (outs), (ins regtype:$Rt, ro_indexed32:$addr), pat>,
2400 Sched<[WriteSTIdx, ReadAdrBase]>;
2402 class LoadStore64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2403 string asm, dag ins, dag outs, list<dag> pat>
2404 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2405 // The operands are in order to match the 'addr' MI operands, so we
2406 // don't need an encoder method and by-name matching. Just use the default
2407 // in-order handling. Since we're using by-order, make sure the names
2413 let Inst{31-30} = sz;
2414 let Inst{29-27} = 0b111;
2416 let Inst{25-24} = 0b00;
2417 let Inst{23-22} = opc;
2419 let Inst{20-16} = offset;
2420 let Inst{15-13} = extend{3-1};
2422 let Inst{12} = extend{0};
2423 let Inst{11-10} = 0b10;
2424 let Inst{9-5} = base;
2425 let Inst{4-0} = dst;
2427 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2430 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2431 class Load64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2432 string asm, list<dag> pat>
2433 : LoadStore64RO<sz, V, opc, regtype, asm,
2434 (outs regtype:$Rt), (ins ro_indexed64:$addr), pat>,
2435 Sched<[WriteLDIdx, ReadAdrBase]>;
2437 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2438 class Store64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2439 string asm, list<dag> pat>
2440 : LoadStore64RO<sz, V, opc, regtype, asm,
2441 (outs), (ins regtype:$Rt, ro_indexed64:$addr), pat>,
2442 Sched<[WriteSTIdx, ReadAdrBase]>;
2445 class LoadStore128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2446 string asm, dag ins, dag outs, list<dag> pat>
2447 : I<ins, outs, asm, "\t$Rt, $addr", "", pat> {
2448 // The operands are in order to match the 'addr' MI operands, so we
2449 // don't need an encoder method and by-name matching. Just use the default
2450 // in-order handling. Since we're using by-order, make sure the names
2456 let Inst{31-30} = sz;
2457 let Inst{29-27} = 0b111;
2459 let Inst{25-24} = 0b00;
2460 let Inst{23-22} = opc;
2462 let Inst{20-16} = offset;
2463 let Inst{15-13} = extend{3-1};
2465 let Inst{12} = extend{0};
2466 let Inst{11-10} = 0b10;
2467 let Inst{9-5} = base;
2468 let Inst{4-0} = dst;
2470 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2473 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2474 class Load128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2475 string asm, list<dag> pat>
2476 : LoadStore128RO<sz, V, opc, regtype, asm,
2477 (outs regtype:$Rt), (ins ro_indexed128:$addr), pat>,
2478 Sched<[WriteLDIdx, ReadAdrBase]>;
2480 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2481 class Store128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2482 string asm, list<dag> pat>
2483 : LoadStore128RO<sz, V, opc, regtype, asm,
2484 (outs), (ins regtype:$Rt, ro_indexed128:$addr), pat>,
2485 Sched<[WriteSTIdx, ReadAdrBase]>;
2487 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2488 class PrefetchRO<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2489 : I<(outs), (ins prfop:$Rt, ro_indexed64:$addr), asm,
2490 "\t$Rt, $addr", "", pat>,
2492 // The operands are in order to match the 'addr' MI operands, so we
2493 // don't need an encoder method and by-name matching. Just use the default
2494 // in-order handling. Since we're using by-order, make sure the names
2500 let Inst{31-30} = sz;
2501 let Inst{29-27} = 0b111;
2503 let Inst{25-24} = 0b00;
2504 let Inst{23-22} = opc;
2506 let Inst{20-16} = offset;
2507 let Inst{15-13} = extend{3-1};
2509 let Inst{12} = extend{0};
2510 let Inst{11-10} = 0b10;
2511 let Inst{9-5} = base;
2512 let Inst{4-0} = dst;
2514 let DecoderMethod = "DecodeRegOffsetLdStInstruction";
2518 // Load/store unscaled immediate
2521 def MemoryUnscaledOperand : AsmOperandClass {
2522 let Name = "MemoryUnscaled";
2523 let DiagnosticType = "InvalidMemoryIndexedSImm9";
2525 class am_unscaled_operand : Operand<i64> {
2526 let PrintMethod = "printAMIndexed<8>";
2527 let ParserMatchClass = MemoryUnscaledOperand;
2528 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2530 class am_unscaled_wb_operand : Operand<i64> {
2531 let PrintMethod = "printAMIndexedWB<8>";
2532 let ParserMatchClass = MemoryUnscaledOperand;
2533 let MIOperandInfo = (ops GPR64sp:$base, i64imm:$offset);
2535 def am_unscaled : am_unscaled_operand;
2536 def am_unscaled_wb: am_unscaled_wb_operand;
2537 def am_unscaled8 : am_unscaled_operand,
2538 ComplexPattern<i64, 2, "SelectAddrModeUnscaled8", []>;
2539 def am_unscaled16 : am_unscaled_operand,
2540 ComplexPattern<i64, 2, "SelectAddrModeUnscaled16", []>;
2541 def am_unscaled32 : am_unscaled_operand,
2542 ComplexPattern<i64, 2, "SelectAddrModeUnscaled32", []>;
2543 def am_unscaled64 : am_unscaled_operand,
2544 ComplexPattern<i64, 2, "SelectAddrModeUnscaled64", []>;
2545 def am_unscaled128 : am_unscaled_operand,
2546 ComplexPattern<i64, 2, "SelectAddrModeUnscaled128", []>;
2548 class BaseLoadStoreUnscale<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2549 string asm, list<dag> pattern>
2550 : I<oops, iops, asm, "\t$Rt, $addr", "", pattern> {
2551 // The operands are in order to match the 'addr' MI operands, so we
2552 // don't need an encoder method and by-name matching. Just use the default
2553 // in-order handling. Since we're using by-order, make sure the names
2558 let Inst{31-30} = sz;
2559 let Inst{29-27} = 0b111;
2561 let Inst{25-24} = 0b00;
2562 let Inst{23-22} = opc;
2564 let Inst{20-12} = offset;
2565 let Inst{11-10} = 0b00;
2566 let Inst{9-5} = base;
2567 let Inst{4-0} = dst;
2569 let DecoderMethod = "DecodeSignedLdStInstruction";
2572 let AddedComplexity = 1 in // try this before LoadUI
2573 class LoadUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2574 Operand amtype, string asm, list<dag> pattern>
2575 : BaseLoadStoreUnscale<sz, V, opc, (outs regtype:$Rt),
2576 (ins amtype:$addr), asm, pattern>,
2579 let AddedComplexity = 1 in // try this before StoreUI
2580 class StoreUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2581 Operand amtype, string asm, list<dag> pattern>
2582 : BaseLoadStoreUnscale<sz, V, opc, (outs),
2583 (ins regtype:$Rt, amtype:$addr), asm, pattern>,
2586 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2587 class PrefetchUnscaled<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2588 : BaseLoadStoreUnscale<sz, V, opc, (outs),
2589 (ins prfop:$Rt, am_unscaled:$addr), asm, pat>,
2593 // Load/store unscaled immediate, unprivileged
2596 class BaseLoadStoreUnprivileged<bits<2> sz, bit V, bits<2> opc,
2597 dag oops, dag iops, string asm>
2598 : I<oops, iops, asm, "\t$Rt, $addr", "", []> {
2599 // The operands are in order to match the 'addr' MI operands, so we
2600 // don't need an encoder method and by-name matching. Just use the default
2601 // in-order handling. Since we're using by-order, make sure the names
2606 let Inst{31-30} = sz;
2607 let Inst{29-27} = 0b111;
2609 let Inst{25-24} = 0b00;
2610 let Inst{23-22} = opc;
2612 let Inst{20-12} = offset;
2613 let Inst{11-10} = 0b10;
2614 let Inst{9-5} = base;
2615 let Inst{4-0} = dst;
2617 let DecoderMethod = "DecodeSignedLdStInstruction";
2620 let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in {
2621 class LoadUnprivileged<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2623 : BaseLoadStoreUnprivileged<sz, V, opc,
2624 (outs regtype:$Rt), (ins am_unscaled:$addr), asm>,
2628 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
2629 class StoreUnprivileged<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2631 : BaseLoadStoreUnprivileged<sz, V, opc,
2632 (outs), (ins regtype:$Rt, am_unscaled:$addr), asm>,
2637 // Load/store pre-indexed
2640 class BaseLoadStorePreIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2641 string asm, string cstr>
2642 : I<oops, iops, asm, "\t$Rt, $addr!", cstr, []> {
2643 // The operands are in order to match the 'addr' MI operands, so we
2644 // don't need an encoder method and by-name matching. Just use the default
2645 // in-order handling.
2649 let Inst{31-30} = sz;
2650 let Inst{29-27} = 0b111;
2652 let Inst{25-24} = 0;
2653 let Inst{23-22} = opc;
2655 let Inst{20-12} = offset;
2656 let Inst{11-10} = 0b11;
2657 let Inst{9-5} = base;
2658 let Inst{4-0} = dst;
2660 let DecoderMethod = "DecodeSignedLdStInstruction";
2663 let hasSideEffects = 0 in {
2664 let mayStore = 0, mayLoad = 1 in
2665 // FIXME: Modeling the write-back of these instructions for isel is tricky.
2666 // we need the complex addressing mode for the memory reference, but
2667 // we also need the write-back specified as a tied operand to the
2668 // base register. That combination does not play nicely with
2669 // the asm matcher and friends.
2670 class LoadPreIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2672 : BaseLoadStorePreIdx<sz, V, opc,
2673 (outs regtype:$Rt/*, GPR64sp:$wback*/),
2674 (ins am_unscaled_wb:$addr), asm, ""/*"$addr.base = $wback"*/>,
2675 Sched<[WriteLD, WriteAdr]>;
2677 let mayStore = 1, mayLoad = 0 in
2678 class StorePreIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2680 : BaseLoadStorePreIdx<sz, V, opc,
2681 (outs/* GPR64sp:$wback*/),
2682 (ins regtype:$Rt, am_unscaled_wb:$addr),
2683 asm, ""/*"$addr.base = $wback"*/>,
2684 Sched<[WriteAdr, WriteST]>;
2685 } // hasSideEffects = 0
2687 // ISel pseudo-instructions which have the tied operands. When the MC lowering
2688 // logic finally gets smart enough to strip off tied operands that are just
2689 // for isel convenience, we can get rid of these pseudos and just reference
2690 // the real instructions directly.
2692 // Ironically, also because of the writeback operands, we can't put the
2693 // matcher pattern directly on the instruction, but need to define it
2696 // Loads aren't matched with patterns here at all, but rather in C++
2698 let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in {
2699 class LoadPreIdxPseudo<RegisterClass regtype>
2700 : Pseudo<(outs regtype:$Rt, GPR64sp:$wback),
2701 (ins am_noindex:$addr, simm9:$offset), [],
2702 "$addr.base = $wback,@earlyclobber $wback">,
2703 Sched<[WriteLD, WriteAdr]>;
2704 class LoadPostIdxPseudo<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, WriteI]>;
2710 multiclass StorePreIdxPseudo<RegisterClass regtype, ValueType Ty,
2711 SDPatternOperator OpNode> {
2712 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
2713 def _isel: Pseudo<(outs GPR64sp:$wback),
2714 (ins regtype:$Rt, am_noindex:$addr, simm9:$offset), [],
2715 "$addr.base = $wback,@earlyclobber $wback">,
2716 Sched<[WriteAdr, WriteST]>;
2718 def : Pat<(OpNode (Ty regtype:$Rt), am_noindex:$addr, simm9:$offset),
2719 (!cast<Instruction>(NAME#_isel) regtype:$Rt, am_noindex:$addr,
2724 // Load/store post-indexed
2727 // (pre-index) load/stores.
2728 class BaseLoadStorePostIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2729 string asm, string cstr>
2730 : I<oops, iops, asm, "\t$Rt, $addr, $idx", cstr, []> {
2731 // The operands are in order to match the 'addr' MI operands, so we
2732 // don't need an encoder method and by-name matching. Just use the default
2733 // in-order handling.
2737 let Inst{31-30} = sz;
2738 let Inst{29-27} = 0b111;
2740 let Inst{25-24} = 0b00;
2741 let Inst{23-22} = opc;
2743 let Inst{20-12} = offset;
2744 let Inst{11-10} = 0b01;
2745 let Inst{9-5} = base;
2746 let Inst{4-0} = dst;
2748 let DecoderMethod = "DecodeSignedLdStInstruction";
2751 let hasSideEffects = 0 in {
2752 let mayStore = 0, mayLoad = 1 in
2753 // FIXME: Modeling the write-back of these instructions for isel is tricky.
2754 // we need the complex addressing mode for the memory reference, but
2755 // we also need the write-back specified as a tied operand to the
2756 // base register. That combination does not play nicely with
2757 // the asm matcher and friends.
2758 class LoadPostIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2760 : BaseLoadStorePostIdx<sz, V, opc,
2761 (outs regtype:$Rt/*, GPR64sp:$wback*/),
2762 (ins am_noindex:$addr, simm9:$idx),
2763 asm, ""/*"$addr.base = $wback"*/>,
2764 Sched<[WriteLD, WriteI]>;
2766 let mayStore = 1, mayLoad = 0 in
2767 class StorePostIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2769 : BaseLoadStorePostIdx<sz, V, opc,
2770 (outs/* GPR64sp:$wback*/),
2771 (ins regtype:$Rt, am_noindex:$addr, simm9:$idx),
2772 asm, ""/*"$addr.base = $wback"*/>,
2773 Sched<[WriteAdr, WriteST, ReadAdrBase]>;
2774 } // hasSideEffects = 0
2776 // ISel pseudo-instructions which have the tied operands. When the MC lowering
2777 // logic finally gets smart enough to strip off tied operands that are just
2778 // for isel convenience, we can get rid of these pseudos and just reference
2779 // the real instructions directly.
2781 // Ironically, also because of the writeback operands, we can't put the
2782 // matcher pattern directly on the instruction, but need to define it
2784 multiclass StorePostIdxPseudo<RegisterClass regtype, ValueType Ty,
2785 SDPatternOperator OpNode, Instruction Insn> {
2786 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
2787 def _isel: Pseudo<(outs GPR64sp:$wback),
2788 (ins regtype:$Rt, am_noindex:$addr, simm9:$idx), [],
2789 "$addr.base = $wback,@earlyclobber $wback">,
2790 PseudoInstExpansion<(Insn regtype:$Rt, am_noindex:$addr, simm9:$idx)>,
2791 Sched<[WriteAdr, WriteST, ReadAdrBase]>;
2793 def : Pat<(OpNode (Ty regtype:$Rt), am_noindex:$addr, simm9:$idx),
2794 (!cast<Instruction>(NAME#_isel) regtype:$Rt, am_noindex:$addr,
2802 // (indexed, offset)
2804 class BaseLoadStorePairOffset<bits<2> opc, bit V, bit L, dag oops, dag iops,
2806 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr", "", []> {
2807 // The operands are in order to match the 'addr' MI operands, so we
2808 // don't need an encoder method and by-name matching. Just use the default
2809 // in-order handling. Since we're using by-order, make sure the names
2815 let Inst{31-30} = opc;
2816 let Inst{29-27} = 0b101;
2818 let Inst{25-23} = 0b010;
2820 let Inst{21-15} = offset;
2821 let Inst{14-10} = dst2;
2822 let Inst{9-5} = base;
2823 let Inst{4-0} = dst;
2825 let DecoderMethod = "DecodePairLdStInstruction";
2828 let hasSideEffects = 0 in {
2829 let mayStore = 0, mayLoad = 1 in
2830 class LoadPairOffset<bits<2> opc, bit V, RegisterClass regtype,
2831 Operand indextype, string asm>
2832 : BaseLoadStorePairOffset<opc, V, 1,
2833 (outs regtype:$Rt, regtype:$Rt2),
2834 (ins indextype:$addr), asm>,
2835 Sched<[WriteLD, WriteLDHi]>;
2837 let mayLoad = 0, mayStore = 1 in
2838 class StorePairOffset<bits<2> opc, bit V, RegisterClass regtype,
2839 Operand indextype, string asm>
2840 : BaseLoadStorePairOffset<opc, V, 0, (outs),
2841 (ins regtype:$Rt, regtype:$Rt2, indextype:$addr),
2844 } // hasSideEffects = 0
2848 def MemoryIndexed32SImm7 : AsmOperandClass {
2849 let Name = "MemoryIndexed32SImm7";
2850 let DiagnosticType = "InvalidMemoryIndexed32SImm7";
2852 def am_indexed32simm7 : Operand<i32> { // ComplexPattern<...>
2853 let PrintMethod = "printAMIndexed<32>";
2854 let ParserMatchClass = MemoryIndexed32SImm7;
2855 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2857 def am_indexed32simm7_wb : Operand<i32> { // ComplexPattern<...>
2858 let PrintMethod = "printAMIndexedWB<32>";
2859 let ParserMatchClass = MemoryIndexed32SImm7;
2860 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2863 def MemoryIndexed64SImm7 : AsmOperandClass {
2864 let Name = "MemoryIndexed64SImm7";
2865 let DiagnosticType = "InvalidMemoryIndexed64SImm7";
2867 def am_indexed64simm7 : Operand<i32> { // ComplexPattern<...>
2868 let PrintMethod = "printAMIndexed<64>";
2869 let ParserMatchClass = MemoryIndexed64SImm7;
2870 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2872 def am_indexed64simm7_wb : Operand<i32> { // ComplexPattern<...>
2873 let PrintMethod = "printAMIndexedWB<64>";
2874 let ParserMatchClass = MemoryIndexed64SImm7;
2875 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2878 def MemoryIndexed128SImm7 : AsmOperandClass {
2879 let Name = "MemoryIndexed128SImm7";
2880 let DiagnosticType = "InvalidMemoryIndexed128SImm7";
2882 def am_indexed128simm7 : Operand<i32> { // ComplexPattern<...>
2883 let PrintMethod = "printAMIndexed<128>";
2884 let ParserMatchClass = MemoryIndexed128SImm7;
2885 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2887 def am_indexed128simm7_wb : Operand<i32> { // ComplexPattern<...>
2888 let PrintMethod = "printAMIndexedWB<128>";
2889 let ParserMatchClass = MemoryIndexed128SImm7;
2890 let MIOperandInfo = (ops GPR64sp:$base, i32imm:$offset);
2893 class BaseLoadStorePairPreIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
2895 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr!", "", []> {
2896 // The operands are in order to match the 'addr' MI operands, so we
2897 // don't need an encoder method and by-name matching. Just use the default
2898 // in-order handling. Since we're using by-order, make sure the names
2904 let Inst{31-30} = opc;
2905 let Inst{29-27} = 0b101;
2907 let Inst{25-23} = 0b011;
2909 let Inst{21-15} = offset;
2910 let Inst{14-10} = dst2;
2911 let Inst{9-5} = base;
2912 let Inst{4-0} = dst;
2914 let DecoderMethod = "DecodePairLdStInstruction";
2917 let hasSideEffects = 0 in {
2918 let mayStore = 0, mayLoad = 1 in
2919 class LoadPairPreIdx<bits<2> opc, bit V, RegisterClass regtype,
2920 Operand addrmode, string asm>
2921 : BaseLoadStorePairPreIdx<opc, V, 1,
2922 (outs regtype:$Rt, regtype:$Rt2),
2923 (ins addrmode:$addr), asm>,
2924 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
2926 let mayStore = 1, mayLoad = 0 in
2927 class StorePairPreIdx<bits<2> opc, bit V, RegisterClass regtype,
2928 Operand addrmode, string asm>
2929 : BaseLoadStorePairPreIdx<opc, V, 0, (outs),
2930 (ins regtype:$Rt, regtype:$Rt2, addrmode:$addr),
2932 Sched<[WriteAdr, WriteSTP]>;
2933 } // hasSideEffects = 0
2937 class BaseLoadStorePairPostIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
2939 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr, $idx", "", []> {
2940 // The operands are in order to match the 'addr' MI operands, so we
2941 // don't need an encoder method and by-name matching. Just use the default
2942 // in-order handling. Since we're using by-order, make sure the names
2948 let Inst{31-30} = opc;
2949 let Inst{29-27} = 0b101;
2951 let Inst{25-23} = 0b001;
2953 let Inst{21-15} = offset;
2954 let Inst{14-10} = dst2;
2955 let Inst{9-5} = base;
2956 let Inst{4-0} = dst;
2958 let DecoderMethod = "DecodePairLdStInstruction";
2961 let hasSideEffects = 0 in {
2962 let mayStore = 0, mayLoad = 1 in
2963 class LoadPairPostIdx<bits<2> opc, bit V, RegisterClass regtype,
2964 Operand idxtype, string asm>
2965 : BaseLoadStorePairPostIdx<opc, V, 1,
2966 (outs regtype:$Rt, regtype:$Rt2),
2967 (ins am_noindex:$addr, idxtype:$idx), asm>,
2968 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
2970 let mayStore = 1, mayLoad = 0 in
2971 class StorePairPostIdx<bits<2> opc, bit V, RegisterClass regtype,
2972 Operand idxtype, string asm>
2973 : BaseLoadStorePairPostIdx<opc, V, 0, (outs),
2974 (ins regtype:$Rt, regtype:$Rt2,
2975 am_noindex:$addr, idxtype:$idx),
2977 Sched<[WriteAdr, WriteSTP]>;
2978 } // hasSideEffects = 0
2982 class BaseLoadStorePairNoAlloc<bits<2> opc, bit V, bit L, dag oops, dag iops,
2984 : I<oops, iops, asm, "\t$Rt, $Rt2, $addr", "", []> {
2985 // The operands are in order to match the 'addr' MI operands, so we
2986 // don't need an encoder method and by-name matching. Just use the default
2987 // in-order handling. Since we're using by-order, make sure the names
2993 let Inst{31-30} = opc;
2994 let Inst{29-27} = 0b101;
2996 let Inst{25-23} = 0b000;
2998 let Inst{21-15} = offset;
2999 let Inst{14-10} = dst2;
3000 let Inst{9-5} = base;
3001 let Inst{4-0} = dst;
3003 let DecoderMethod = "DecodePairLdStInstruction";
3006 let hasSideEffects = 0 in {
3007 let mayStore = 0, mayLoad = 1 in
3008 class LoadPairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3009 Operand indextype, string asm>
3010 : BaseLoadStorePairNoAlloc<opc, V, 1,
3011 (outs regtype:$Rt, regtype:$Rt2),
3012 (ins indextype:$addr), asm>,
3013 Sched<[WriteLD, WriteLDHi]>;
3015 let mayStore = 1, mayLoad = 0 in
3016 class StorePairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3017 Operand indextype, string asm>
3018 : BaseLoadStorePairNoAlloc<opc, V, 0, (outs),
3019 (ins regtype:$Rt, regtype:$Rt2, indextype:$addr),
3022 } // hasSideEffects = 0
3025 // Load/store exclusive
3028 // True exclusive operations write to and/or read from the system's exclusive
3029 // monitors, which as far as a compiler is concerned can be modelled as a
3030 // random shared memory address. Hence LoadExclusive mayStore.
3032 // Since these instructions have the undefined register bits set to 1 in
3033 // their canonical form, we need a post encoder method to set those bits
3034 // to 1 when encoding these instructions. We do this using the
3035 // fixLoadStoreExclusive function. This function has template parameters:
3037 // fixLoadStoreExclusive<int hasRs, int hasRt2>
3039 // hasRs indicates that the instruction uses the Rs field, so we won't set
3040 // it to 1 (and the same for Rt2). We don't need template parameters for
3041 // the other register fields since Rt and Rn are always used.
3043 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
3044 class BaseLoadStoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3045 dag oops, dag iops, string asm, string operands>
3046 : I<oops, iops, asm, operands, "", []> {
3047 let Inst{31-30} = sz;
3048 let Inst{29-24} = 0b001000;
3054 let DecoderMethod = "DecodeExclusiveLdStInstruction";
3057 // Neither Rs nor Rt2 operands.
3058 class LoadStoreExclusiveSimple<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3059 dag oops, dag iops, string asm, string operands>
3060 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, oops, iops, asm, operands> {
3063 let Inst{9-5} = base;
3064 let Inst{4-0} = reg;
3066 let PostEncoderMethod = "fixLoadStoreExclusive<0,0>";
3069 // Simple load acquires don't set the exclusive monitor
3070 let mayLoad = 1, mayStore = 0 in
3071 class LoadAcquire<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3072 RegisterClass regtype, string asm>
3073 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
3074 (ins am_noindex:$addr), asm, "\t$Rt, $addr">,
3077 class LoadExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3078 RegisterClass regtype, string asm>
3079 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
3080 (ins am_noindex:$addr), asm, "\t$Rt, $addr">,
3083 class LoadExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3084 RegisterClass regtype, string asm>
3085 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
3086 (outs regtype:$Rt, regtype:$Rt2),
3087 (ins am_noindex:$addr), asm,
3088 "\t$Rt, $Rt2, $addr">,
3089 Sched<[WriteLD, WriteLDHi]> {
3093 let Inst{14-10} = dst2;
3094 let Inst{9-5} = base;
3095 let Inst{4-0} = dst1;
3097 let PostEncoderMethod = "fixLoadStoreExclusive<0,1>";
3100 // Simple store release operations do not check the exclusive monitor.
3101 let mayLoad = 0, mayStore = 1 in
3102 class StoreRelease<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3103 RegisterClass regtype, string asm>
3104 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs),
3105 (ins regtype:$Rt, am_noindex:$addr),
3106 asm, "\t$Rt, $addr">,
3109 let mayLoad = 1, mayStore = 1 in
3110 class StoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3111 RegisterClass regtype, string asm>
3112 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, (outs GPR32:$Ws),
3113 (ins regtype:$Rt, am_noindex:$addr),
3114 asm, "\t$Ws, $Rt, $addr">,
3119 let Inst{20-16} = status;
3120 let Inst{9-5} = base;
3121 let Inst{4-0} = reg;
3123 let Constraints = "@earlyclobber $Ws";
3124 let PostEncoderMethod = "fixLoadStoreExclusive<1,0>";
3127 class StoreExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3128 RegisterClass regtype, string asm>
3129 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
3131 (ins regtype:$Rt, regtype:$Rt2, am_noindex:$addr),
3132 asm, "\t$Ws, $Rt, $Rt2, $addr">,
3138 let Inst{20-16} = status;
3139 let Inst{14-10} = dst2;
3140 let Inst{9-5} = base;
3141 let Inst{4-0} = dst1;
3143 let Constraints = "@earlyclobber $Ws";
3147 // Exception generation
3150 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
3151 class ExceptionGeneration<bits<3> op1, bits<2> ll, string asm>
3152 : I<(outs), (ins imm0_65535:$imm), asm, "\t$imm", "", []>,
3155 let Inst{31-24} = 0b11010100;
3156 let Inst{23-21} = op1;
3157 let Inst{20-5} = imm;
3158 let Inst{4-2} = 0b000;
3162 let Predicates = [HasFPARMv8] in {
3165 // Floating point to integer conversion
3168 class BaseFPToIntegerUnscaled<bits<2> type, bits<2> rmode, bits<3> opcode,
3169 RegisterClass srcType, RegisterClass dstType,
3170 string asm, list<dag> pattern>
3171 : I<(outs dstType:$Rd), (ins srcType:$Rn),
3172 asm, "\t$Rd, $Rn", "", pattern>,
3173 Sched<[WriteFCvt]> {
3176 let Inst{30-29} = 0b00;
3177 let Inst{28-24} = 0b11110;
3178 let Inst{23-22} = type;
3180 let Inst{20-19} = rmode;
3181 let Inst{18-16} = opcode;
3182 let Inst{15-10} = 0;
3187 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3188 class BaseFPToInteger<bits<2> type, bits<2> rmode, bits<3> opcode,
3189 RegisterClass srcType, RegisterClass dstType,
3190 Operand immType, string asm, list<dag> pattern>
3191 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
3192 asm, "\t$Rd, $Rn, $scale", "", pattern>,
3193 Sched<[WriteFCvt]> {
3197 let Inst{30-29} = 0b00;
3198 let Inst{28-24} = 0b11110;
3199 let Inst{23-22} = type;
3201 let Inst{20-19} = rmode;
3202 let Inst{18-16} = opcode;
3203 let Inst{15-10} = scale;
3208 multiclass FPToIntegerUnscaled<bits<2> rmode, bits<3> opcode, string asm,
3209 SDPatternOperator OpN> {
3210 // Unscaled single-precision to 32-bit
3211 def UWSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR32, asm,
3212 [(set GPR32:$Rd, (OpN FPR32:$Rn))]> {
3213 let Inst{31} = 0; // 32-bit GPR flag
3216 // Unscaled single-precision to 64-bit
3217 def UXSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR64, asm,
3218 [(set GPR64:$Rd, (OpN FPR32:$Rn))]> {
3219 let Inst{31} = 1; // 64-bit GPR flag
3222 // Unscaled double-precision to 32-bit
3223 def UWDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR32, asm,
3224 [(set GPR32:$Rd, (OpN (f64 FPR64:$Rn)))]> {
3225 let Inst{31} = 0; // 32-bit GPR flag
3228 // Unscaled double-precision to 64-bit
3229 def UXDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR64, asm,
3230 [(set GPR64:$Rd, (OpN (f64 FPR64:$Rn)))]> {
3231 let Inst{31} = 1; // 64-bit GPR flag
3235 multiclass FPToIntegerScaled<bits<2> rmode, bits<3> opcode, string asm,
3236 SDPatternOperator OpN> {
3237 // Scaled single-precision to 32-bit
3238 def SWSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR32,
3239 fixedpoint_f32_i32, asm,
3240 [(set GPR32:$Rd, (OpN (fmul FPR32:$Rn,
3241 fixedpoint_f32_i32:$scale)))]> {
3242 let Inst{31} = 0; // 32-bit GPR flag
3246 // Scaled single-precision to 64-bit
3247 def SXSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR64,
3248 fixedpoint_f32_i64, asm,
3249 [(set GPR64:$Rd, (OpN (fmul FPR32:$Rn,
3250 fixedpoint_f32_i64:$scale)))]> {
3251 let Inst{31} = 1; // 64-bit GPR flag
3254 // Scaled double-precision to 32-bit
3255 def SWDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR32,
3256 fixedpoint_f64_i32, asm,
3257 [(set GPR32:$Rd, (OpN (fmul FPR64:$Rn,
3258 fixedpoint_f64_i32:$scale)))]> {
3259 let Inst{31} = 0; // 32-bit GPR flag
3263 // Scaled double-precision to 64-bit
3264 def SXDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR64,
3265 fixedpoint_f64_i64, asm,
3266 [(set GPR64:$Rd, (OpN (fmul FPR64:$Rn,
3267 fixedpoint_f64_i64:$scale)))]> {
3268 let Inst{31} = 1; // 64-bit GPR flag
3273 // Integer to floating point conversion
3276 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
3277 class BaseIntegerToFP<bit isUnsigned,
3278 RegisterClass srcType, RegisterClass dstType,
3279 Operand immType, string asm, list<dag> pattern>
3280 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
3281 asm, "\t$Rd, $Rn, $scale", "", pattern>,
3282 Sched<[WriteFCvt]> {
3286 let Inst{30-23} = 0b00111100;
3287 let Inst{21-17} = 0b00001;
3288 let Inst{16} = isUnsigned;
3289 let Inst{15-10} = scale;
3294 class BaseIntegerToFPUnscaled<bit isUnsigned,
3295 RegisterClass srcType, RegisterClass dstType,
3296 ValueType dvt, string asm, SDNode node>
3297 : I<(outs dstType:$Rd), (ins srcType:$Rn),
3298 asm, "\t$Rd, $Rn", "", [(set (dvt dstType:$Rd), (node srcType:$Rn))]>,
3299 Sched<[WriteFCvt]> {
3303 let Inst{30-23} = 0b00111100;
3304 let Inst{21-17} = 0b10001;
3305 let Inst{16} = isUnsigned;
3306 let Inst{15-10} = 0b000000;
3311 multiclass IntegerToFP<bit isUnsigned, string asm, SDNode node> {
3313 def UWSri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR32, f32, asm, node> {
3314 let Inst{31} = 0; // 32-bit GPR flag
3315 let Inst{22} = 0; // 32-bit FPR flag
3318 def UWDri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR64, f64, asm, node> {
3319 let Inst{31} = 0; // 32-bit GPR flag
3320 let Inst{22} = 1; // 64-bit FPR flag
3323 def UXSri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR32, f32, asm, node> {
3324 let Inst{31} = 1; // 64-bit GPR flag
3325 let Inst{22} = 0; // 32-bit FPR flag
3328 def UXDri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR64, f64, asm, node> {
3329 let Inst{31} = 1; // 64-bit GPR flag
3330 let Inst{22} = 1; // 64-bit FPR flag
3334 def SWSri: BaseIntegerToFP<isUnsigned, GPR32, FPR32, fixedpoint_f32_i32, asm,
3336 (fdiv (node GPR32:$Rn),
3337 fixedpoint_f32_i32:$scale))]> {
3338 let Inst{31} = 0; // 32-bit GPR flag
3339 let Inst{22} = 0; // 32-bit FPR flag
3343 def SWDri: BaseIntegerToFP<isUnsigned, GPR32, FPR64, fixedpoint_f64_i32, asm,
3345 (fdiv (node GPR32:$Rn),
3346 fixedpoint_f64_i32:$scale))]> {
3347 let Inst{31} = 0; // 32-bit GPR flag
3348 let Inst{22} = 1; // 64-bit FPR flag
3352 def SXSri: BaseIntegerToFP<isUnsigned, GPR64, FPR32, fixedpoint_f32_i64, asm,
3354 (fdiv (node GPR64:$Rn),
3355 fixedpoint_f32_i64:$scale))]> {
3356 let Inst{31} = 1; // 64-bit GPR flag
3357 let Inst{22} = 0; // 32-bit FPR flag
3360 def SXDri: BaseIntegerToFP<isUnsigned, GPR64, FPR64, fixedpoint_f64_i64, asm,
3362 (fdiv (node GPR64:$Rn),
3363 fixedpoint_f64_i64:$scale))]> {
3364 let Inst{31} = 1; // 64-bit GPR flag
3365 let Inst{22} = 1; // 64-bit FPR flag
3370 // Unscaled integer <-> floating point conversion (i.e. FMOV)
3373 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3374 class BaseUnscaledConversion<bits<2> rmode, bits<3> opcode,
3375 RegisterClass srcType, RegisterClass dstType,
3377 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "",
3378 // We use COPY_TO_REGCLASS for these bitconvert operations.
3379 // copyPhysReg() expands the resultant COPY instructions after
3380 // regalloc is done. This gives greater freedom for the allocator
3381 // and related passes (coalescing, copy propagation, et. al.) to
3382 // be more effective.
3383 [/*(set (dvt dstType:$Rd), (bitconvert (svt srcType:$Rn)))*/]>,
3384 Sched<[WriteFCopy]> {
3387 let Inst{30-23} = 0b00111100;
3389 let Inst{20-19} = rmode;
3390 let Inst{18-16} = opcode;
3391 let Inst{15-10} = 0b000000;
3396 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3397 class BaseUnscaledConversionToHigh<bits<2> rmode, bits<3> opcode,
3398 RegisterClass srcType, RegisterOperand dstType, string asm,
3400 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm,
3401 "{\t$Rd"#kind#"[1], $Rn|"#kind#"\t$Rd[1], $Rn}", "", []>,
3402 Sched<[WriteFCopy]> {
3405 let Inst{30-23} = 0b00111101;
3407 let Inst{20-19} = rmode;
3408 let Inst{18-16} = opcode;
3409 let Inst{15-10} = 0b000000;
3414 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3415 class BaseUnscaledConversionFromHigh<bits<2> rmode, bits<3> opcode,
3416 RegisterOperand srcType, RegisterClass dstType, string asm,
3418 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm,
3419 "{\t$Rd, $Rn"#kind#"[1]|"#kind#"\t$Rd, $Rn[1]}", "", []>,
3420 Sched<[WriteFCopy]> {
3423 let Inst{30-23} = 0b00111101;
3425 let Inst{20-19} = rmode;
3426 let Inst{18-16} = opcode;
3427 let Inst{15-10} = 0b000000;
3434 multiclass UnscaledConversion<string asm> {
3435 def WSr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR32, asm> {
3436 let Inst{31} = 0; // 32-bit GPR flag
3437 let Inst{22} = 0; // 32-bit FPR flag
3440 def XDr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR64, asm> {
3441 let Inst{31} = 1; // 64-bit GPR flag
3442 let Inst{22} = 1; // 64-bit FPR flag
3445 def SWr : BaseUnscaledConversion<0b00, 0b110, FPR32, GPR32, asm> {
3446 let Inst{31} = 0; // 32-bit GPR flag
3447 let Inst{22} = 0; // 32-bit FPR flag
3450 def DXr : BaseUnscaledConversion<0b00, 0b110, FPR64, GPR64, asm> {
3451 let Inst{31} = 1; // 64-bit GPR flag
3452 let Inst{22} = 1; // 64-bit FPR flag
3455 def XDHighr : BaseUnscaledConversionToHigh<0b01, 0b111, GPR64, V128,
3461 def DXHighr : BaseUnscaledConversionFromHigh<0b01, 0b110, V128, GPR64,
3469 // Floating point conversion
3472 class BaseFPConversion<bits<2> type, bits<2> opcode, RegisterClass dstType,
3473 RegisterClass srcType, string asm, list<dag> pattern>
3474 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", pattern>,
3475 Sched<[WriteFCvt]> {
3478 let Inst{31-24} = 0b00011110;
3479 let Inst{23-22} = type;
3480 let Inst{21-17} = 0b10001;
3481 let Inst{16-15} = opcode;
3482 let Inst{14-10} = 0b10000;
3487 multiclass FPConversion<string asm> {
3488 // Double-precision to Half-precision
3489 def HDr : BaseFPConversion<0b01, 0b11, FPR16, FPR64, asm,
3490 [(set FPR16:$Rd, (fround FPR64:$Rn))]>;
3492 // Double-precision to Single-precision
3493 def SDr : BaseFPConversion<0b01, 0b00, FPR32, FPR64, asm,
3494 [(set FPR32:$Rd, (fround FPR64:$Rn))]>;
3496 // Half-precision to Double-precision
3497 def DHr : BaseFPConversion<0b11, 0b01, FPR64, FPR16, asm,
3498 [(set FPR64:$Rd, (fextend FPR16:$Rn))]>;
3500 // Half-precision to Single-precision
3501 def SHr : BaseFPConversion<0b11, 0b00, FPR32, FPR16, asm,
3502 [(set FPR32:$Rd, (fextend FPR16:$Rn))]>;
3504 // Single-precision to Double-precision
3505 def DSr : BaseFPConversion<0b00, 0b01, FPR64, FPR32, asm,
3506 [(set FPR64:$Rd, (fextend FPR32:$Rn))]>;
3508 // Single-precision to Half-precision
3509 def HSr : BaseFPConversion<0b00, 0b11, FPR16, FPR32, asm,
3510 [(set FPR16:$Rd, (fround FPR32:$Rn))]>;
3514 // Single operand floating point data processing
3517 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3518 class BaseSingleOperandFPData<bits<4> opcode, RegisterClass regtype,
3519 ValueType vt, string asm, SDPatternOperator node>
3520 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
3521 [(set (vt regtype:$Rd), (node (vt regtype:$Rn)))]>,
3525 let Inst{31-23} = 0b000111100;
3526 let Inst{21-19} = 0b100;
3527 let Inst{18-15} = opcode;
3528 let Inst{14-10} = 0b10000;
3533 multiclass SingleOperandFPData<bits<4> opcode, string asm,
3534 SDPatternOperator node = null_frag> {
3535 def Sr : BaseSingleOperandFPData<opcode, FPR32, f32, asm, node> {
3536 let Inst{22} = 0; // 32-bit size flag
3539 def Dr : BaseSingleOperandFPData<opcode, FPR64, f64, asm, node> {
3540 let Inst{22} = 1; // 64-bit size flag
3545 // Two operand floating point data processing
3548 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3549 class BaseTwoOperandFPData<bits<4> opcode, RegisterClass regtype,
3550 string asm, list<dag> pat>
3551 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
3552 asm, "\t$Rd, $Rn, $Rm", "", pat>,
3557 let Inst{31-23} = 0b000111100;
3559 let Inst{20-16} = Rm;
3560 let Inst{15-12} = opcode;
3561 let Inst{11-10} = 0b10;
3566 multiclass TwoOperandFPData<bits<4> opcode, string asm,
3567 SDPatternOperator node = null_frag> {
3568 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
3569 [(set (f32 FPR32:$Rd),
3570 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]> {
3571 let Inst{22} = 0; // 32-bit size flag
3574 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
3575 [(set (f64 FPR64:$Rd),
3576 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]> {
3577 let Inst{22} = 1; // 64-bit size flag
3581 multiclass TwoOperandFPDataNeg<bits<4> opcode, string asm, SDNode node> {
3582 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
3583 [(set FPR32:$Rd, (fneg (node FPR32:$Rn, (f32 FPR32:$Rm))))]> {
3584 let Inst{22} = 0; // 32-bit size flag
3587 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
3588 [(set FPR64:$Rd, (fneg (node FPR64:$Rn, (f64 FPR64:$Rm))))]> {
3589 let Inst{22} = 1; // 64-bit size flag
3595 // Three operand floating point data processing
3598 class BaseThreeOperandFPData<bit isNegated, bit isSub,
3599 RegisterClass regtype, string asm, list<dag> pat>
3600 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, regtype: $Ra),
3601 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pat>,
3602 Sched<[WriteFMul]> {
3607 let Inst{31-23} = 0b000111110;
3608 let Inst{21} = isNegated;
3609 let Inst{20-16} = Rm;
3610 let Inst{15} = isSub;
3611 let Inst{14-10} = Ra;
3616 multiclass ThreeOperandFPData<bit isNegated, bit isSub,string asm,
3617 SDPatternOperator node> {
3618 def Srrr : BaseThreeOperandFPData<isNegated, isSub, FPR32, asm,
3620 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm), (f32 FPR32:$Ra)))]> {
3621 let Inst{22} = 0; // 32-bit size flag
3624 def Drrr : BaseThreeOperandFPData<isNegated, isSub, FPR64, asm,
3626 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm), (f64 FPR64:$Ra)))]> {
3627 let Inst{22} = 1; // 64-bit size flag
3632 // Floating point data comparisons
3635 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3636 class BaseOneOperandFPComparison<bit signalAllNans,
3637 RegisterClass regtype, string asm,
3639 : I<(outs), (ins regtype:$Rn), asm, "\t$Rn, #0.0", "", pat>,
3640 Sched<[WriteFCmp]> {
3642 let Inst{31-23} = 0b000111100;
3645 let Inst{15-10} = 0b001000;
3647 let Inst{4} = signalAllNans;
3648 let Inst{3-0} = 0b1000;
3650 // Rm should be 0b00000 canonically, but we need to accept any value.
3651 let PostEncoderMethod = "fixOneOperandFPComparison";
3654 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3655 class BaseTwoOperandFPComparison<bit signalAllNans, RegisterClass regtype,
3656 string asm, list<dag> pat>
3657 : I<(outs), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rn, $Rm", "", pat>,
3658 Sched<[WriteFCmp]> {
3661 let Inst{31-23} = 0b000111100;
3663 let Inst{20-16} = Rm;
3664 let Inst{15-10} = 0b001000;
3666 let Inst{4} = signalAllNans;
3667 let Inst{3-0} = 0b0000;
3670 multiclass FPComparison<bit signalAllNans, string asm,
3671 SDPatternOperator OpNode = null_frag> {
3672 let Defs = [NZCV] in {
3673 def Srr : BaseTwoOperandFPComparison<signalAllNans, FPR32, asm,
3674 [(OpNode FPR32:$Rn, (f32 FPR32:$Rm)), (implicit NZCV)]> {
3678 def Sri : BaseOneOperandFPComparison<signalAllNans, FPR32, asm,
3679 [(OpNode (f32 FPR32:$Rn), fpimm0), (implicit NZCV)]> {
3683 def Drr : BaseTwoOperandFPComparison<signalAllNans, FPR64, asm,
3684 [(OpNode FPR64:$Rn, (f64 FPR64:$Rm)), (implicit NZCV)]> {
3688 def Dri : BaseOneOperandFPComparison<signalAllNans, FPR64, asm,
3689 [(OpNode (f64 FPR64:$Rn), fpimm0), (implicit NZCV)]> {
3696 // Floating point conditional comparisons
3699 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3700 class BaseFPCondComparison<bit signalAllNans,
3701 RegisterClass regtype, string asm>
3702 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm0_15:$nzcv, ccode:$cond),
3703 asm, "\t$Rn, $Rm, $nzcv, $cond", "", []>,
3704 Sched<[WriteFCmp]> {
3710 let Inst{31-23} = 0b000111100;
3712 let Inst{20-16} = Rm;
3713 let Inst{15-12} = cond;
3714 let Inst{11-10} = 0b01;
3716 let Inst{4} = signalAllNans;
3717 let Inst{3-0} = nzcv;
3720 multiclass FPCondComparison<bit signalAllNans, string asm> {
3721 let Defs = [NZCV], Uses = [NZCV] in {
3722 def Srr : BaseFPCondComparison<signalAllNans, FPR32, asm> {
3726 def Drr : BaseFPCondComparison<signalAllNans, FPR64, asm> {
3729 } // Defs = [NZCV], Uses = [NZCV]
3733 // Floating point conditional select
3736 class BaseFPCondSelect<RegisterClass regtype, ValueType vt, string asm>
3737 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
3738 asm, "\t$Rd, $Rn, $Rm, $cond", "",
3740 (ARM64csel (vt regtype:$Rn), regtype:$Rm,
3741 (i32 imm:$cond), NZCV))]>,
3748 let Inst{31-23} = 0b000111100;
3750 let Inst{20-16} = Rm;
3751 let Inst{15-12} = cond;
3752 let Inst{11-10} = 0b11;
3757 multiclass FPCondSelect<string asm> {
3758 let Uses = [NZCV] in {
3759 def Srrr : BaseFPCondSelect<FPR32, f32, asm> {
3763 def Drrr : BaseFPCondSelect<FPR64, f64, asm> {
3770 // Floating move immediate
3773 class BaseFPMoveImmediate<RegisterClass regtype, Operand fpimmtype, string asm>
3774 : I<(outs regtype:$Rd), (ins fpimmtype:$imm), asm, "\t$Rd, $imm", "",
3775 [(set regtype:$Rd, fpimmtype:$imm)]>,
3776 Sched<[WriteFImm]> {
3779 let Inst{31-23} = 0b000111100;
3781 let Inst{20-13} = imm;
3782 let Inst{12-5} = 0b10000000;
3786 multiclass FPMoveImmediate<string asm> {
3787 def Si : BaseFPMoveImmediate<FPR32, fpimm32, asm> {
3791 def Di : BaseFPMoveImmediate<FPR64, fpimm64, asm> {
3795 } // end of 'let Predicates = [HasFPARMv8]'
3797 //----------------------------------------------------------------------------
3799 //----------------------------------------------------------------------------
3801 class AsmVectorIndex<string Suffix> : AsmOperandClass {
3802 let Name = "VectorIndex" # Suffix;
3803 let DiagnosticType = "InvalidIndex" # Suffix;
3805 def VectorIndexBOperand : AsmVectorIndex<"B">;
3806 def VectorIndexHOperand : AsmVectorIndex<"H">;
3807 def VectorIndexSOperand : AsmVectorIndex<"S">;
3808 def VectorIndexDOperand : AsmVectorIndex<"D">;
3810 def VectorIndexB : Operand<i64>, ImmLeaf<i64, [{
3811 return ((uint64_t)Imm) < 16;
3813 let ParserMatchClass = VectorIndexBOperand;
3814 let PrintMethod = "printVectorIndex";
3815 let MIOperandInfo = (ops i64imm);
3817 def VectorIndexH : Operand<i64>, ImmLeaf<i64, [{
3818 return ((uint64_t)Imm) < 8;
3820 let ParserMatchClass = VectorIndexHOperand;
3821 let PrintMethod = "printVectorIndex";
3822 let MIOperandInfo = (ops i64imm);
3824 def VectorIndexS : Operand<i64>, ImmLeaf<i64, [{
3825 return ((uint64_t)Imm) < 4;
3827 let ParserMatchClass = VectorIndexSOperand;
3828 let PrintMethod = "printVectorIndex";
3829 let MIOperandInfo = (ops i64imm);
3831 def VectorIndexD : Operand<i64>, ImmLeaf<i64, [{
3832 return ((uint64_t)Imm) < 2;
3834 let ParserMatchClass = VectorIndexDOperand;
3835 let PrintMethod = "printVectorIndex";
3836 let MIOperandInfo = (ops i64imm);
3839 def MemorySIMDNoIndexOperand : AsmOperandClass {
3840 let Name = "MemorySIMDNoIndex";
3841 let ParserMethod = "tryParseNoIndexMemory";
3843 def am_simdnoindex : Operand<i64>,
3844 ComplexPattern<i64, 1, "SelectAddrModeNoIndex", []> {
3845 let PrintMethod = "printAMNoIndex";
3846 let ParserMatchClass = MemorySIMDNoIndexOperand;
3847 let MIOperandInfo = (ops GPR64sp:$base);
3848 let DecoderMethod = "DecodeGPR64spRegisterClass";
3851 let Predicates = [HasNEON] in {
3853 //----------------------------------------------------------------------------
3854 // AdvSIMD three register vector instructions
3855 //----------------------------------------------------------------------------
3857 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3858 class BaseSIMDThreeSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
3859 RegisterOperand regtype, string asm, string kind,
3861 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
3862 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
3863 "|" # kind # "\t$Rd, $Rn, $Rm|}", "", pattern>,
3871 let Inst{28-24} = 0b01110;
3872 let Inst{23-22} = size;
3874 let Inst{20-16} = Rm;
3875 let Inst{15-11} = opcode;
3881 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3882 class BaseSIMDThreeSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
3883 RegisterOperand regtype, string asm, string kind,
3885 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm), asm,
3886 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
3887 "|" # kind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
3895 let Inst{28-24} = 0b01110;
3896 let Inst{23-22} = size;
3898 let Inst{20-16} = Rm;
3899 let Inst{15-11} = opcode;
3905 // All operand sizes distinguished in the encoding.
3906 multiclass SIMDThreeSameVector<bit U, bits<5> opc, string asm,
3907 SDPatternOperator OpNode> {
3908 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
3910 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
3911 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
3913 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
3914 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
3916 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
3917 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
3919 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
3920 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
3922 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
3923 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
3925 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
3926 def v2i64 : BaseSIMDThreeSameVector<1, U, 0b11, opc, V128,
3928 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
3931 // As above, but D sized elements unsupported.
3932 multiclass SIMDThreeSameVectorBHS<bit U, bits<5> opc, string asm,
3933 SDPatternOperator OpNode> {
3934 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
3936 [(set V64:$Rd, (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))]>;
3937 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
3939 [(set V128:$Rd, (v16i8 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm))))]>;
3940 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
3942 [(set V64:$Rd, (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))]>;
3943 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
3945 [(set V128:$Rd, (v8i16 (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm))))]>;
3946 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
3948 [(set V64:$Rd, (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))]>;
3949 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
3951 [(set V128:$Rd, (v4i32 (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm))))]>;
3954 multiclass SIMDThreeSameVectorBHSTied<bit U, bits<5> opc, string asm,
3955 SDPatternOperator OpNode> {
3956 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, 0b00, opc, V64,
3958 [(set (v8i8 V64:$dst),
3959 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
3960 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, 0b00, opc, V128,
3962 [(set (v16i8 V128:$dst),
3963 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
3964 def v4i16 : BaseSIMDThreeSameVectorTied<0, U, 0b01, opc, V64,
3966 [(set (v4i16 V64:$dst),
3967 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
3968 def v8i16 : BaseSIMDThreeSameVectorTied<1, U, 0b01, opc, V128,
3970 [(set (v8i16 V128:$dst),
3971 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
3972 def v2i32 : BaseSIMDThreeSameVectorTied<0, U, 0b10, opc, V64,
3974 [(set (v2i32 V64:$dst),
3975 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
3976 def v4i32 : BaseSIMDThreeSameVectorTied<1, U, 0b10, opc, V128,
3978 [(set (v4i32 V128:$dst),
3979 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
3982 // As above, but only B sized elements supported.
3983 multiclass SIMDThreeSameVectorB<bit U, bits<5> opc, string asm,
3984 SDPatternOperator OpNode> {
3985 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
3987 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
3988 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
3990 [(set (v16i8 V128:$Rd),
3991 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
3994 // As above, but only S and D sized floating point elements supported.
3995 multiclass SIMDThreeSameVectorFP<bit U, bit S, bits<5> opc,
3996 string asm, SDPatternOperator OpNode> {
3997 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0}, opc, V64,
3999 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4000 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0}, opc, V128,
4002 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4003 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,1}, opc, V128,
4005 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4008 multiclass SIMDThreeSameVectorFPCmp<bit U, bit S, bits<5> opc,
4010 SDPatternOperator OpNode> {
4011 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0}, opc, V64,
4013 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4014 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0}, opc, V128,
4016 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4017 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,1}, opc, V128,
4019 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4022 multiclass SIMDThreeSameVectorFPTied<bit U, bit S, bits<5> opc,
4023 string asm, SDPatternOperator OpNode> {
4024 def v2f32 : BaseSIMDThreeSameVectorTied<0, U, {S,0}, opc, V64,
4026 [(set (v2f32 V64:$dst),
4027 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4028 def v4f32 : BaseSIMDThreeSameVectorTied<1, U, {S,0}, opc, V128,
4030 [(set (v4f32 V128:$dst),
4031 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4032 def v2f64 : BaseSIMDThreeSameVectorTied<1, U, {S,1}, opc, V128,
4034 [(set (v2f64 V128:$dst),
4035 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4038 // As above, but D and B sized elements unsupported.
4039 multiclass SIMDThreeSameVectorHS<bit U, bits<5> opc, string asm,
4040 SDPatternOperator OpNode> {
4041 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
4043 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4044 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
4046 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4047 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
4049 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4050 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
4052 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4055 // Logical three vector ops share opcode bits, and only use B sized elements.
4056 multiclass SIMDLogicalThreeVector<bit U, bits<2> size, string asm,
4057 SDPatternOperator OpNode = null_frag> {
4058 def v8i8 : BaseSIMDThreeSameVector<0, U, size, 0b00011, V64,
4060 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn, V64:$Rm))]>;
4061 def v16i8 : BaseSIMDThreeSameVector<1, U, size, 0b00011, V128,
4063 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn, V128:$Rm))]>;
4065 def : Pat<(v4i16 (OpNode V64:$LHS, V64:$RHS)),
4066 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4067 def : Pat<(v2i32 (OpNode V64:$LHS, V64:$RHS)),
4068 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4069 def : Pat<(v1i64 (OpNode V64:$LHS, V64:$RHS)),
4070 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4072 def : Pat<(v8i16 (OpNode V128:$LHS, V128:$RHS)),
4073 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4074 def : Pat<(v4i32 (OpNode V128:$LHS, V128:$RHS)),
4075 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4076 def : Pat<(v2i64 (OpNode V128:$LHS, V128:$RHS)),
4077 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4080 multiclass SIMDLogicalThreeVectorTied<bit U, bits<2> size,
4081 string asm, SDPatternOperator OpNode> {
4082 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, size, 0b00011, V64,
4084 [(set (v8i8 V64:$dst),
4085 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4086 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, size, 0b00011, V128,
4088 [(set (v16i8 V128:$dst),
4089 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
4090 (v16i8 V128:$Rm)))]>;
4092 def : Pat<(v4i16 (OpNode (v4i16 V64:$LHS), (v4i16 V64:$MHS),
4094 (!cast<Instruction>(NAME#"v8i8")
4095 V64:$LHS, V64:$MHS, V64:$RHS)>;
4096 def : Pat<(v2i32 (OpNode (v2i32 V64:$LHS), (v2i32 V64:$MHS),
4098 (!cast<Instruction>(NAME#"v8i8")
4099 V64:$LHS, V64:$MHS, V64:$RHS)>;
4100 def : Pat<(v1i64 (OpNode (v1i64 V64:$LHS), (v1i64 V64:$MHS),
4102 (!cast<Instruction>(NAME#"v8i8")
4103 V64:$LHS, V64:$MHS, V64:$RHS)>;
4105 def : Pat<(v8i16 (OpNode (v8i16 V128:$LHS), (v8i16 V128:$MHS),
4106 (v8i16 V128:$RHS))),
4107 (!cast<Instruction>(NAME#"v16i8")
4108 V128:$LHS, V128:$MHS, V128:$RHS)>;
4109 def : Pat<(v4i32 (OpNode (v4i32 V128:$LHS), (v4i32 V128:$MHS),
4110 (v4i32 V128:$RHS))),
4111 (!cast<Instruction>(NAME#"v16i8")
4112 V128:$LHS, V128:$MHS, V128:$RHS)>;
4113 def : Pat<(v2i64 (OpNode (v2i64 V128:$LHS), (v2i64 V128:$MHS),
4114 (v2i64 V128:$RHS))),
4115 (!cast<Instruction>(NAME#"v16i8")
4116 V128:$LHS, V128:$MHS, V128:$RHS)>;
4120 //----------------------------------------------------------------------------
4121 // AdvSIMD two register vector instructions.
4122 //----------------------------------------------------------------------------
4124 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4125 class BaseSIMDTwoSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4126 RegisterOperand regtype, string asm, string dstkind,
4127 string srckind, list<dag> pattern>
4128 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
4129 "{\t$Rd" # dstkind # ", $Rn" # srckind #
4130 "|" # dstkind # "\t$Rd, $Rn}", "", pattern>,
4137 let Inst{28-24} = 0b01110;
4138 let Inst{23-22} = size;
4139 let Inst{21-17} = 0b10000;
4140 let Inst{16-12} = opcode;
4141 let Inst{11-10} = 0b10;
4146 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4147 class BaseSIMDTwoSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4148 RegisterOperand regtype, string asm, string dstkind,
4149 string srckind, list<dag> pattern>
4150 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn), asm,
4151 "{\t$Rd" # dstkind # ", $Rn" # srckind #
4152 "|" # dstkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
4159 let Inst{28-24} = 0b01110;
4160 let Inst{23-22} = size;
4161 let Inst{21-17} = 0b10000;
4162 let Inst{16-12} = opcode;
4163 let Inst{11-10} = 0b10;
4168 // Supports B, H, and S element sizes.
4169 multiclass SIMDTwoVectorBHS<bit U, bits<5> opc, string asm,
4170 SDPatternOperator OpNode> {
4171 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4173 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4174 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4175 asm, ".16b", ".16b",
4176 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4177 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4179 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4180 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4182 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4183 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4185 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4186 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4188 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4191 class BaseSIMDVectorLShiftLongBySize<bit Q, bits<2> size,
4192 RegisterOperand regtype, string asm, string dstkind,
4193 string srckind, string amount>
4194 : I<(outs V128:$Rd), (ins regtype:$Rn), asm,
4195 "{\t$Rd" # dstkind # ", $Rn" # srckind # ", #" # amount #
4196 "|" # dstkind # "\t$Rd, $Rn, #" # amount # "}", "", []>,
4202 let Inst{29-24} = 0b101110;
4203 let Inst{23-22} = size;
4204 let Inst{21-10} = 0b100001001110;
4209 multiclass SIMDVectorLShiftLongBySizeBHS {
4210 let neverHasSideEffects = 1 in {
4211 def v8i8 : BaseSIMDVectorLShiftLongBySize<0, 0b00, V64,
4212 "shll", ".8h", ".8b", "8">;
4213 def v16i8 : BaseSIMDVectorLShiftLongBySize<1, 0b00, V128,
4214 "shll2", ".8h", ".16b", "8">;
4215 def v4i16 : BaseSIMDVectorLShiftLongBySize<0, 0b01, V64,
4216 "shll", ".4s", ".4h", "16">;
4217 def v8i16 : BaseSIMDVectorLShiftLongBySize<1, 0b01, V128,
4218 "shll2", ".4s", ".8h", "16">;
4219 def v2i32 : BaseSIMDVectorLShiftLongBySize<0, 0b10, V64,
4220 "shll", ".2d", ".2s", "32">;
4221 def v4i32 : BaseSIMDVectorLShiftLongBySize<1, 0b10, V128,
4222 "shll2", ".2d", ".4s", "32">;
4226 // Supports all element sizes.
4227 multiclass SIMDLongTwoVector<bit U, bits<5> opc, string asm,
4228 SDPatternOperator OpNode> {
4229 def v8i8_v4i16 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4231 [(set (v4i16 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4232 def v16i8_v8i16 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4234 [(set (v8i16 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4235 def v4i16_v2i32 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4237 [(set (v2i32 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4238 def v8i16_v4i32 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4240 [(set (v4i32 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4241 def v2i32_v1i64 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4243 [(set (v1i64 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4244 def v4i32_v2i64 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4246 [(set (v2i64 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4249 multiclass SIMDLongTwoVectorTied<bit U, bits<5> opc, string asm,
4250 SDPatternOperator OpNode> {
4251 def v8i8_v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, V64,
4253 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd),
4255 def v16i8_v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, V128,
4257 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd),
4258 (v16i8 V128:$Rn)))]>;
4259 def v4i16_v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, V64,
4261 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd),
4262 (v4i16 V64:$Rn)))]>;
4263 def v8i16_v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, V128,
4265 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd),
4266 (v8i16 V128:$Rn)))]>;
4267 def v2i32_v1i64 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, V64,
4269 [(set (v1i64 V64:$dst), (OpNode (v1i64 V64:$Rd),
4270 (v2i32 V64:$Rn)))]>;
4271 def v4i32_v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, V128,
4273 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd),
4274 (v4i32 V128:$Rn)))]>;
4277 // Supports all element sizes, except 1xD.
4278 multiclass SIMDTwoVectorBHSDTied<bit U, bits<5> opc, string asm,
4279 SDPatternOperator OpNode> {
4280 def v8i8 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, V64,
4282 [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn)))]>;
4283 def v16i8 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, V128,
4284 asm, ".16b", ".16b",
4285 [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
4286 def v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, V64,
4288 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn)))]>;
4289 def v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, V128,
4291 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn)))]>;
4292 def v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, V64,
4294 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn)))]>;
4295 def v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, V128,
4297 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
4298 def v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b11, opc, V128,
4300 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn)))]>;
4303 multiclass SIMDTwoVectorBHSD<bit U, bits<5> opc, string asm,
4304 SDPatternOperator OpNode = null_frag> {
4305 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4307 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4308 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4309 asm, ".16b", ".16b",
4310 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4311 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4313 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4314 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4316 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4317 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4319 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4320 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4322 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4323 def v2i64 : BaseSIMDTwoSameVector<1, U, 0b11, opc, V128,
4325 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4329 // Supports only B element sizes.
4330 multiclass SIMDTwoVectorB<bit U, bits<2> size, bits<5> opc, string asm,
4331 SDPatternOperator OpNode> {
4332 def v8i8 : BaseSIMDTwoSameVector<0, U, size, opc, V64,
4334 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4335 def v16i8 : BaseSIMDTwoSameVector<1, U, size, opc, V128,
4336 asm, ".16b", ".16b",
4337 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4341 // Supports only B and H element sizes.
4342 multiclass SIMDTwoVectorBH<bit U, bits<5> opc, string asm,
4343 SDPatternOperator OpNode> {
4344 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4346 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn))]>;
4347 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4348 asm, ".16b", ".16b",
4349 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn))]>;
4350 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4352 [(set (v4i16 V64:$Rd), (OpNode V64:$Rn))]>;
4353 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4355 [(set (v8i16 V128:$Rd), (OpNode V128:$Rn))]>;
4358 // Supports only S and D element sizes, uses high bit of the size field
4359 // as an extra opcode bit.
4360 multiclass SIMDTwoVectorFP<bit U, bit S, bits<5> opc, string asm,
4361 SDPatternOperator OpNode> {
4362 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4364 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
4365 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4367 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
4368 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4370 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4373 // Supports only S element size.
4374 multiclass SIMDTwoVectorS<bit U, bit S, bits<5> opc, string asm,
4375 SDPatternOperator OpNode> {
4376 def v2i32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4378 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4379 def v4i32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4381 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4385 multiclass SIMDTwoVectorFPToInt<bit U, bit S, bits<5> opc, string asm,
4386 SDPatternOperator OpNode> {
4387 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4389 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
4390 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4392 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
4393 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4395 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4398 multiclass SIMDTwoVectorIntToFP<bit U, bit S, bits<5> opc, string asm,
4399 SDPatternOperator OpNode> {
4400 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4402 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4403 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4405 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4406 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4408 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4412 class BaseSIMDMixedTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4413 RegisterOperand inreg, RegisterOperand outreg,
4414 string asm, string outkind, string inkind,
4416 : I<(outs outreg:$Rd), (ins inreg:$Rn), asm,
4417 "{\t$Rd" # outkind # ", $Rn" # inkind #
4418 "|" # outkind # "\t$Rd, $Rn}", "", pattern>,
4425 let Inst{28-24} = 0b01110;
4426 let Inst{23-22} = size;
4427 let Inst{21-17} = 0b10000;
4428 let Inst{16-12} = opcode;
4429 let Inst{11-10} = 0b10;
4434 class BaseSIMDMixedTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4435 RegisterOperand inreg, RegisterOperand outreg,
4436 string asm, string outkind, string inkind,
4438 : I<(outs outreg:$dst), (ins outreg:$Rd, inreg:$Rn), asm,
4439 "{\t$Rd" # outkind # ", $Rn" # inkind #
4440 "|" # outkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
4447 let Inst{28-24} = 0b01110;
4448 let Inst{23-22} = size;
4449 let Inst{21-17} = 0b10000;
4450 let Inst{16-12} = opcode;
4451 let Inst{11-10} = 0b10;
4456 multiclass SIMDMixedTwoVector<bit U, bits<5> opc, string asm,
4457 SDPatternOperator OpNode> {
4458 def v8i8 : BaseSIMDMixedTwoVector<0, U, 0b00, opc, V128, V64,
4460 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4461 def v16i8 : BaseSIMDMixedTwoVectorTied<1, U, 0b00, opc, V128, V128,
4462 asm#"2", ".16b", ".8h", []>;
4463 def v4i16 : BaseSIMDMixedTwoVector<0, U, 0b01, opc, V128, V64,
4465 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4466 def v8i16 : BaseSIMDMixedTwoVectorTied<1, U, 0b01, opc, V128, V128,
4467 asm#"2", ".8h", ".4s", []>;
4468 def v2i32 : BaseSIMDMixedTwoVector<0, U, 0b10, opc, V128, V64,
4470 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4471 def v4i32 : BaseSIMDMixedTwoVectorTied<1, U, 0b10, opc, V128, V128,
4472 asm#"2", ".4s", ".2d", []>;
4474 def : Pat<(concat_vectors (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn))),
4475 (!cast<Instruction>(NAME # "v16i8")
4476 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4477 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn))),
4478 (!cast<Instruction>(NAME # "v8i16")
4479 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4480 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn))),
4481 (!cast<Instruction>(NAME # "v4i32")
4482 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4485 class BaseSIMDCmpTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4486 RegisterOperand regtype,
4487 string asm, string kind, string zero,
4488 ValueType dty, ValueType sty, SDNode OpNode>
4489 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
4490 "{\t$Rd" # kind # ", $Rn" # kind # ", #" # zero #
4491 "|" # kind # "\t$Rd, $Rn, #" # zero # "}", "",
4492 [(set (dty regtype:$Rd), (OpNode (sty regtype:$Rn)))]>,
4499 let Inst{28-24} = 0b01110;
4500 let Inst{23-22} = size;
4501 let Inst{21-17} = 0b10000;
4502 let Inst{16-12} = opcode;
4503 let Inst{11-10} = 0b10;
4508 // Comparisons support all element sizes, except 1xD.
4509 multiclass SIMDCmpTwoVector<bit U, bits<5> opc, string asm,
4511 def v8i8rz : BaseSIMDCmpTwoVector<0, U, 0b00, opc, V64,
4513 v8i8, v8i8, OpNode>;
4514 def v16i8rz : BaseSIMDCmpTwoVector<1, U, 0b00, opc, V128,
4516 v16i8, v16i8, OpNode>;
4517 def v4i16rz : BaseSIMDCmpTwoVector<0, U, 0b01, opc, V64,
4519 v4i16, v4i16, OpNode>;
4520 def v8i16rz : BaseSIMDCmpTwoVector<1, U, 0b01, opc, V128,
4522 v8i16, v8i16, OpNode>;
4523 def v2i32rz : BaseSIMDCmpTwoVector<0, U, 0b10, opc, V64,
4525 v2i32, v2i32, OpNode>;
4526 def v4i32rz : BaseSIMDCmpTwoVector<1, U, 0b10, opc, V128,
4528 v4i32, v4i32, OpNode>;
4529 def v2i64rz : BaseSIMDCmpTwoVector<1, U, 0b11, opc, V128,
4531 v2i64, v2i64, OpNode>;
4534 // FP Comparisons support only S and D element sizes.
4535 multiclass SIMDFPCmpTwoVector<bit U, bit S, bits<5> opc,
4536 string asm, SDNode OpNode> {
4538 def v2i32rz : BaseSIMDCmpTwoVector<0, U, {S,0}, opc, V64,
4540 v2i32, v2f32, OpNode>;
4541 def v4i32rz : BaseSIMDCmpTwoVector<1, U, {S,0}, opc, V128,
4543 v4i32, v4f32, OpNode>;
4544 def v2i64rz : BaseSIMDCmpTwoVector<1, U, {S,1}, opc, V128,
4546 v2i64, v2f64, OpNode>;
4548 def : InstAlias<asm # " $Vd.2s, $Vn.2s, #0",
4549 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
4550 def : InstAlias<asm # " $Vd.4s, $Vn.4s, #0",
4551 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
4552 def : InstAlias<asm # " $Vd.2d, $Vn.2d, #0",
4553 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
4554 def : InstAlias<asm # ".2s $Vd, $Vn, #0",
4555 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
4556 def : InstAlias<asm # ".4s $Vd, $Vn, #0",
4557 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
4558 def : InstAlias<asm # ".2d $Vd, $Vn, #0",
4559 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
4562 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4563 class BaseSIMDFPCvtTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4564 RegisterOperand outtype, RegisterOperand intype,
4565 string asm, string VdTy, string VnTy,
4567 : I<(outs outtype:$Rd), (ins intype:$Rn), asm,
4568 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "", pattern>,
4575 let Inst{28-24} = 0b01110;
4576 let Inst{23-22} = size;
4577 let Inst{21-17} = 0b10000;
4578 let Inst{16-12} = opcode;
4579 let Inst{11-10} = 0b10;
4584 class BaseSIMDFPCvtTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4585 RegisterOperand outtype, RegisterOperand intype,
4586 string asm, string VdTy, string VnTy,
4588 : I<(outs outtype:$dst), (ins outtype:$Rd, intype:$Rn), asm,
4589 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "$Rd = $dst", pattern>,
4596 let Inst{28-24} = 0b01110;
4597 let Inst{23-22} = size;
4598 let Inst{21-17} = 0b10000;
4599 let Inst{16-12} = opcode;
4600 let Inst{11-10} = 0b10;
4605 multiclass SIMDFPWidenTwoVector<bit U, bit S, bits<5> opc, string asm> {
4606 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V128, V64,
4607 asm, ".4s", ".4h", []>;
4608 def v8i16 : BaseSIMDFPCvtTwoVector<1, U, {S,0}, opc, V128, V128,
4609 asm#"2", ".4s", ".8h", []>;
4610 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V128, V64,
4611 asm, ".2d", ".2s", []>;
4612 def v4i32 : BaseSIMDFPCvtTwoVector<1, U, {S,1}, opc, V128, V128,
4613 asm#"2", ".2d", ".4s", []>;
4616 multiclass SIMDFPNarrowTwoVector<bit U, bit S, bits<5> opc, string asm> {
4617 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V64, V128,
4618 asm, ".4h", ".4s", []>;
4619 def v8i16 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,0}, opc, V128, V128,
4620 asm#"2", ".8h", ".4s", []>;
4621 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
4622 asm, ".2s", ".2d", []>;
4623 def v4i32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
4624 asm#"2", ".4s", ".2d", []>;
4627 multiclass SIMDFPInexactCvtTwoVector<bit U, bit S, bits<5> opc, string asm,
4629 def v2f32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
4631 [(set (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4632 def v4f32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
4633 asm#"2", ".4s", ".2d", []>;
4635 def : Pat<(concat_vectors (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn))),
4636 (!cast<Instruction>(NAME # "v4f32")
4637 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4640 //----------------------------------------------------------------------------
4641 // AdvSIMD three register different-size vector instructions.
4642 //----------------------------------------------------------------------------
4644 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4645 class BaseSIMDDifferentThreeVector<bit U, bits<3> size, bits<4> opcode,
4646 RegisterOperand outtype, RegisterOperand intype1,
4647 RegisterOperand intype2, string asm,
4648 string outkind, string inkind1, string inkind2,
4650 : I<(outs outtype:$Rd), (ins intype1:$Rn, intype2:$Rm), asm,
4651 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
4652 "|" # outkind # "\t$Rd, $Rn, $Rm}", "", pattern>,
4658 let Inst{30} = size{0};
4660 let Inst{28-24} = 0b01110;
4661 let Inst{23-22} = size{2-1};
4663 let Inst{20-16} = Rm;
4664 let Inst{15-12} = opcode;
4665 let Inst{11-10} = 0b00;
4670 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4671 class BaseSIMDDifferentThreeVectorTied<bit U, bits<3> size, bits<4> opcode,
4672 RegisterOperand outtype, RegisterOperand intype1,
4673 RegisterOperand intype2, string asm,
4674 string outkind, string inkind1, string inkind2,
4676 : I<(outs outtype:$dst), (ins outtype:$Rd, intype1:$Rn, intype2:$Rm), asm,
4677 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
4678 "|" # outkind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
4684 let Inst{30} = size{0};
4686 let Inst{28-24} = 0b01110;
4687 let Inst{23-22} = size{2-1};
4689 let Inst{20-16} = Rm;
4690 let Inst{15-12} = opcode;
4691 let Inst{11-10} = 0b00;
4696 // FIXME: TableGen doesn't know how to deal with expanded types that also
4697 // change the element count (in this case, placing the results in
4698 // the high elements of the result register rather than the low
4699 // elements). Until that's fixed, we can't code-gen those.
4700 multiclass SIMDNarrowThreeVectorBHS<bit U, bits<4> opc, string asm,
4702 def v8i16_v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4704 asm, ".8b", ".8h", ".8h",
4705 [(set (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4706 def v8i16_v16i8 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4708 asm#"2", ".16b", ".8h", ".8h",
4710 def v4i32_v4i16 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4712 asm, ".4h", ".4s", ".4s",
4713 [(set (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4714 def v4i32_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4716 asm#"2", ".8h", ".4s", ".4s",
4718 def v2i64_v2i32 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4720 asm, ".2s", ".2d", ".2d",
4721 [(set (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
4722 def v2i64_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4724 asm#"2", ".4s", ".2d", ".2d",
4728 // Patterns for the '2' variants involve INSERT_SUBREG, which you can't put in
4729 // a version attached to an instruction.
4730 def : Pat<(concat_vectors (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn),
4732 (!cast<Instruction>(NAME # "v8i16_v16i8")
4733 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4734 V128:$Rn, V128:$Rm)>;
4735 def : Pat<(concat_vectors (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn),
4737 (!cast<Instruction>(NAME # "v4i32_v8i16")
4738 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4739 V128:$Rn, V128:$Rm)>;
4740 def : Pat<(concat_vectors (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn),
4742 (!cast<Instruction>(NAME # "v2i64_v4i32")
4743 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4744 V128:$Rn, V128:$Rm)>;
4747 multiclass SIMDDifferentThreeVectorBD<bit U, bits<4> opc, string asm,
4749 def v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4751 asm, ".8h", ".8b", ".8b",
4752 [(set (v8i16 V128:$Rd), (IntOp (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4753 def v16i8 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4755 asm#"2", ".8h", ".16b", ".16b", []>;
4756 let Predicates = [HasCrypto] in {
4757 def v1i64 : BaseSIMDDifferentThreeVector<U, 0b110, opc,
4759 asm, ".1q", ".1d", ".1d", []>;
4760 def v2i64 : BaseSIMDDifferentThreeVector<U, 0b111, opc,
4762 asm#"2", ".1q", ".2d", ".2d", []>;
4765 def : Pat<(v8i16 (IntOp (v8i8 (extract_high_v16i8 V128:$Rn)),
4766 (v8i8 (extract_high_v16i8 V128:$Rm)))),
4767 (!cast<Instruction>(NAME#"v16i8") V128:$Rn, V128:$Rm)>;
4770 multiclass SIMDLongThreeVectorHS<bit U, bits<4> opc, string asm,
4771 SDPatternOperator OpNode> {
4772 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4774 asm, ".4s", ".4h", ".4h",
4775 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4776 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4778 asm#"2", ".4s", ".8h", ".8h",
4779 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
4780 (extract_high_v8i16 V128:$Rm)))]>;
4781 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4783 asm, ".2d", ".2s", ".2s",
4784 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4785 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4787 asm#"2", ".2d", ".4s", ".4s",
4788 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
4789 (extract_high_v4i32 V128:$Rm)))]>;
4792 multiclass SIMDLongThreeVectorBHSabdl<bit U, bits<4> opc, string asm,
4793 SDPatternOperator OpNode = null_frag> {
4794 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4796 asm, ".8h", ".8b", ".8b",
4797 [(set (v8i16 V128:$Rd),
4798 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))))]>;
4799 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4801 asm#"2", ".8h", ".16b", ".16b",
4802 [(set (v8i16 V128:$Rd),
4803 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
4804 (extract_high_v16i8 V128:$Rm)))))]>;
4805 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4807 asm, ".4s", ".4h", ".4h",
4808 [(set (v4i32 V128:$Rd),
4809 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))))]>;
4810 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4812 asm#"2", ".4s", ".8h", ".8h",
4813 [(set (v4i32 V128:$Rd),
4814 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
4815 (extract_high_v8i16 V128:$Rm)))))]>;
4816 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4818 asm, ".2d", ".2s", ".2s",
4819 [(set (v2i64 V128:$Rd),
4820 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))))]>;
4821 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4823 asm#"2", ".2d", ".4s", ".4s",
4824 [(set (v2i64 V128:$Rd),
4825 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
4826 (extract_high_v4i32 V128:$Rm)))))]>;
4829 multiclass SIMDLongThreeVectorTiedBHSabal<bit U, bits<4> opc,
4831 SDPatternOperator OpNode> {
4832 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
4834 asm, ".8h", ".8b", ".8b",
4835 [(set (v8i16 V128:$dst),
4836 (add (v8i16 V128:$Rd),
4837 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))))]>;
4838 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4840 asm#"2", ".8h", ".16b", ".16b",
4841 [(set (v8i16 V128:$dst),
4842 (add (v8i16 V128:$Rd),
4843 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
4844 (extract_high_v16i8 V128:$Rm))))))]>;
4845 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
4847 asm, ".4s", ".4h", ".4h",
4848 [(set (v4i32 V128:$dst),
4849 (add (v4i32 V128:$Rd),
4850 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))))]>;
4851 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4853 asm#"2", ".4s", ".8h", ".8h",
4854 [(set (v4i32 V128:$dst),
4855 (add (v4i32 V128:$Rd),
4856 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
4857 (extract_high_v8i16 V128:$Rm))))))]>;
4858 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
4860 asm, ".2d", ".2s", ".2s",
4861 [(set (v2i64 V128:$dst),
4862 (add (v2i64 V128:$Rd),
4863 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))))]>;
4864 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4866 asm#"2", ".2d", ".4s", ".4s",
4867 [(set (v2i64 V128:$dst),
4868 (add (v2i64 V128:$Rd),
4869 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
4870 (extract_high_v4i32 V128:$Rm))))))]>;
4873 multiclass SIMDLongThreeVectorBHS<bit U, bits<4> opc, string asm,
4874 SDPatternOperator OpNode = null_frag> {
4875 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4877 asm, ".8h", ".8b", ".8b",
4878 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4879 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4881 asm#"2", ".8h", ".16b", ".16b",
4882 [(set (v8i16 V128:$Rd), (OpNode (extract_high_v16i8 V128:$Rn),
4883 (extract_high_v16i8 V128:$Rm)))]>;
4884 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4886 asm, ".4s", ".4h", ".4h",
4887 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4888 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4890 asm#"2", ".4s", ".8h", ".8h",
4891 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
4892 (extract_high_v8i16 V128:$Rm)))]>;
4893 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4895 asm, ".2d", ".2s", ".2s",
4896 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4897 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4899 asm#"2", ".2d", ".4s", ".4s",
4900 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
4901 (extract_high_v4i32 V128:$Rm)))]>;
4904 multiclass SIMDLongThreeVectorTiedBHS<bit U, bits<4> opc,
4906 SDPatternOperator OpNode> {
4907 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
4909 asm, ".8h", ".8b", ".8b",
4910 [(set (v8i16 V128:$dst),
4911 (OpNode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4912 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4914 asm#"2", ".8h", ".16b", ".16b",
4915 [(set (v8i16 V128:$dst),
4916 (OpNode (v8i16 V128:$Rd),
4917 (extract_high_v16i8 V128:$Rn),
4918 (extract_high_v16i8 V128:$Rm)))]>;
4919 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
4921 asm, ".4s", ".4h", ".4h",
4922 [(set (v4i32 V128:$dst),
4923 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4924 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4926 asm#"2", ".4s", ".8h", ".8h",
4927 [(set (v4i32 V128:$dst),
4928 (OpNode (v4i32 V128:$Rd),
4929 (extract_high_v8i16 V128:$Rn),
4930 (extract_high_v8i16 V128:$Rm)))]>;
4931 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
4933 asm, ".2d", ".2s", ".2s",
4934 [(set (v2i64 V128:$dst),
4935 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4936 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4938 asm#"2", ".2d", ".4s", ".4s",
4939 [(set (v2i64 V128:$dst),
4940 (OpNode (v2i64 V128:$Rd),
4941 (extract_high_v4i32 V128:$Rn),
4942 (extract_high_v4i32 V128:$Rm)))]>;
4945 multiclass SIMDLongThreeVectorSQDMLXTiedHS<bit U, bits<4> opc, string asm,
4946 SDPatternOperator Accum> {
4947 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
4949 asm, ".4s", ".4h", ".4h",
4950 [(set (v4i32 V128:$dst),
4951 (Accum (v4i32 V128:$Rd),
4952 (v4i32 (int_arm64_neon_sqdmull (v4i16 V64:$Rn),
4953 (v4i16 V64:$Rm)))))]>;
4954 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4956 asm#"2", ".4s", ".8h", ".8h",
4957 [(set (v4i32 V128:$dst),
4958 (Accum (v4i32 V128:$Rd),
4959 (v4i32 (int_arm64_neon_sqdmull (extract_high_v8i16 V128:$Rn),
4960 (extract_high_v8i16 V128:$Rm)))))]>;
4961 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
4963 asm, ".2d", ".2s", ".2s",
4964 [(set (v2i64 V128:$dst),
4965 (Accum (v2i64 V128:$Rd),
4966 (v2i64 (int_arm64_neon_sqdmull (v2i32 V64:$Rn),
4967 (v2i32 V64:$Rm)))))]>;
4968 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4970 asm#"2", ".2d", ".4s", ".4s",
4971 [(set (v2i64 V128:$dst),
4972 (Accum (v2i64 V128:$Rd),
4973 (v2i64 (int_arm64_neon_sqdmull (extract_high_v4i32 V128:$Rn),
4974 (extract_high_v4i32 V128:$Rm)))))]>;
4977 multiclass SIMDWideThreeVectorBHS<bit U, bits<4> opc, string asm,
4978 SDPatternOperator OpNode> {
4979 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4981 asm, ".8h", ".8h", ".8b",
4982 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i8 V64:$Rm)))]>;
4983 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4985 asm#"2", ".8h", ".8h", ".16b",
4986 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
4987 (extract_high_v16i8 V128:$Rm)))]>;
4988 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4990 asm, ".4s", ".4s", ".4h",
4991 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i16 V64:$Rm)))]>;
4992 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4994 asm#"2", ".4s", ".4s", ".8h",
4995 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
4996 (extract_high_v8i16 V128:$Rm)))]>;
4997 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4999 asm, ".2d", ".2d", ".2s",
5000 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i32 V64:$Rm)))]>;
5001 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
5003 asm#"2", ".2d", ".2d", ".4s",
5004 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
5005 (extract_high_v4i32 V128:$Rm)))]>;
5008 //----------------------------------------------------------------------------
5009 // AdvSIMD bitwise extract from vector
5010 //----------------------------------------------------------------------------
5012 class BaseSIMDBitwiseExtract<bit size, RegisterOperand regtype, ValueType vty,
5013 string asm, string kind>
5014 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, i32imm:$imm), asm,
5015 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $imm" #
5016 "|" # kind # "\t$Rd, $Rn, $Rm, $imm}", "",
5017 [(set (vty regtype:$Rd),
5018 (ARM64ext regtype:$Rn, regtype:$Rm, (i32 imm:$imm)))]>,
5025 let Inst{30} = size;
5026 let Inst{29-21} = 0b101110000;
5027 let Inst{20-16} = Rm;
5029 let Inst{14-11} = imm;
5036 multiclass SIMDBitwiseExtract<string asm> {
5037 def v8i8 : BaseSIMDBitwiseExtract<0, V64, v8i8, asm, ".8b"> {
5040 def v16i8 : BaseSIMDBitwiseExtract<1, V128, v16i8, asm, ".16b">;
5043 //----------------------------------------------------------------------------
5044 // AdvSIMD zip vector
5045 //----------------------------------------------------------------------------
5047 class BaseSIMDZipVector<bits<3> size, bits<3> opc, RegisterOperand regtype,
5048 string asm, string kind, SDNode OpNode, ValueType valty>
5049 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
5050 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
5051 "|" # kind # "\t$Rd, $Rn, $Rm}", "",
5052 [(set (valty regtype:$Rd), (OpNode regtype:$Rn, regtype:$Rm))]>,
5058 let Inst{30} = size{0};
5059 let Inst{29-24} = 0b001110;
5060 let Inst{23-22} = size{2-1};
5062 let Inst{20-16} = Rm;
5064 let Inst{14-12} = opc;
5065 let Inst{11-10} = 0b10;
5070 multiclass SIMDZipVector<bits<3>opc, string asm,
5072 def v8i8 : BaseSIMDZipVector<0b000, opc, V64,
5073 asm, ".8b", OpNode, v8i8>;
5074 def v16i8 : BaseSIMDZipVector<0b001, opc, V128,
5075 asm, ".16b", OpNode, v16i8>;
5076 def v4i16 : BaseSIMDZipVector<0b010, opc, V64,
5077 asm, ".4h", OpNode, v4i16>;
5078 def v8i16 : BaseSIMDZipVector<0b011, opc, V128,
5079 asm, ".8h", OpNode, v8i16>;
5080 def v2i32 : BaseSIMDZipVector<0b100, opc, V64,
5081 asm, ".2s", OpNode, v2i32>;
5082 def v4i32 : BaseSIMDZipVector<0b101, opc, V128,
5083 asm, ".4s", OpNode, v4i32>;
5084 def v2i64 : BaseSIMDZipVector<0b111, opc, V128,
5085 asm, ".2d", OpNode, v2i64>;
5087 def : Pat<(v2f32 (OpNode V64:$Rn, V64:$Rm)),
5088 (!cast<Instruction>(NAME#"v2i32") V64:$Rn, V64:$Rm)>;
5089 def : Pat<(v4f32 (OpNode V128:$Rn, V128:$Rm)),
5090 (!cast<Instruction>(NAME#"v4i32") V128:$Rn, V128:$Rm)>;
5091 def : Pat<(v2f64 (OpNode V128:$Rn, V128:$Rm)),
5092 (!cast<Instruction>(NAME#"v2i64") V128:$Rn, V128:$Rm)>;
5095 //----------------------------------------------------------------------------
5096 // AdvSIMD three register scalar instructions
5097 //----------------------------------------------------------------------------
5099 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5100 class BaseSIMDThreeScalar<bit U, bits<2> size, bits<5> opcode,
5101 RegisterClass regtype, string asm,
5103 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
5104 "\t$Rd, $Rn, $Rm", "", pattern>,
5109 let Inst{31-30} = 0b01;
5111 let Inst{28-24} = 0b11110;
5112 let Inst{23-22} = size;
5114 let Inst{20-16} = Rm;
5115 let Inst{15-11} = opcode;
5121 multiclass SIMDThreeScalarD<bit U, bits<5> opc, string asm,
5122 SDPatternOperator OpNode> {
5123 def v1i64 : BaseSIMDThreeScalar<U, 0b11, opc, FPR64, asm,
5124 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
5127 multiclass SIMDThreeScalarBHSD<bit U, bits<5> opc, string asm,
5128 SDPatternOperator OpNode> {
5129 def v1i64 : BaseSIMDThreeScalar<U, 0b11, opc, FPR64, asm,
5130 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
5131 def v1i32 : BaseSIMDThreeScalar<U, 0b10, opc, FPR32, asm, []>;
5132 def v1i16 : BaseSIMDThreeScalar<U, 0b01, opc, FPR16, asm, []>;
5133 def v1i8 : BaseSIMDThreeScalar<U, 0b00, opc, FPR8 , asm, []>;
5135 def : Pat<(i64 (OpNode (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5136 (!cast<Instruction>(NAME#"v1i64") FPR64:$Rn, FPR64:$Rm)>;
5137 def : Pat<(i32 (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm))),
5138 (!cast<Instruction>(NAME#"v1i32") FPR32:$Rn, FPR32:$Rm)>;
5141 multiclass SIMDThreeScalarHS<bit U, bits<5> opc, string asm,
5142 SDPatternOperator OpNode> {
5143 def v1i32 : BaseSIMDThreeScalar<U, 0b10, opc, FPR32, asm,
5144 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
5145 def v1i16 : BaseSIMDThreeScalar<U, 0b01, opc, FPR16, asm, []>;
5148 multiclass SIMDThreeScalarSD<bit U, bit S, bits<5> opc, string asm,
5149 SDPatternOperator OpNode = null_frag> {
5150 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5151 def #NAME#64 : BaseSIMDThreeScalar<U, {S,1}, opc, FPR64, asm,
5152 [(set (f64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
5153 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0}, opc, FPR32, asm,
5154 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
5157 def : Pat<(v1f64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
5158 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
5161 multiclass SIMDThreeScalarFPCmp<bit U, bit S, bits<5> opc, string asm,
5162 SDPatternOperator OpNode = null_frag> {
5163 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5164 def #NAME#64 : BaseSIMDThreeScalar<U, {S,1}, opc, FPR64, asm,
5165 [(set (i64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
5166 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0}, opc, FPR32, asm,
5167 [(set (i32 FPR32:$Rd), (OpNode (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]>;
5170 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
5171 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
5174 class BaseSIMDThreeScalarMixed<bit U, bits<2> size, bits<5> opcode,
5175 dag oops, dag iops, string asm, string cstr, list<dag> pat>
5176 : I<oops, iops, asm,
5177 "\t$Rd, $Rn, $Rm", cstr, pat>,
5182 let Inst{31-30} = 0b01;
5184 let Inst{28-24} = 0b11110;
5185 let Inst{23-22} = size;
5187 let Inst{20-16} = Rm;
5188 let Inst{15-11} = opcode;
5194 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5195 multiclass SIMDThreeScalarMixedHS<bit U, bits<5> opc, string asm,
5196 SDPatternOperator OpNode = null_frag> {
5197 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
5199 (ins FPR16:$Rn, FPR16:$Rm), asm, "", []>;
5200 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
5202 (ins FPR32:$Rn, FPR32:$Rm), asm, "",
5203 [(set (i64 FPR64:$Rd), (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
5206 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5207 multiclass SIMDThreeScalarMixedTiedHS<bit U, bits<5> opc, string asm,
5208 SDPatternOperator OpNode = null_frag> {
5209 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
5211 (ins FPR32:$Rd, FPR16:$Rn, FPR16:$Rm),
5212 asm, "$Rd = $dst", []>;
5213 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
5215 (ins FPR64:$Rd, FPR32:$Rn, FPR32:$Rm),
5217 [(set (i64 FPR64:$dst),
5218 (OpNode (i64 FPR64:$Rd), (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
5221 //----------------------------------------------------------------------------
5222 // AdvSIMD two register scalar instructions
5223 //----------------------------------------------------------------------------
5225 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5226 class BaseSIMDTwoScalar<bit U, bits<2> size, bits<5> opcode,
5227 RegisterClass regtype, RegisterClass regtype2,
5228 string asm, list<dag> pat>
5229 : I<(outs regtype:$Rd), (ins regtype2:$Rn), asm,
5230 "\t$Rd, $Rn", "", pat>,
5234 let Inst{31-30} = 0b01;
5236 let Inst{28-24} = 0b11110;
5237 let Inst{23-22} = size;
5238 let Inst{21-17} = 0b10000;
5239 let Inst{16-12} = opcode;
5240 let Inst{11-10} = 0b10;
5245 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5246 class BaseSIMDTwoScalarTied<bit U, bits<2> size, bits<5> opcode,
5247 RegisterClass regtype, RegisterClass regtype2,
5248 string asm, list<dag> pat>
5249 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype2:$Rn), asm,
5250 "\t$Rd, $Rn", "$Rd = $dst", pat>,
5254 let Inst{31-30} = 0b01;
5256 let Inst{28-24} = 0b11110;
5257 let Inst{23-22} = size;
5258 let Inst{21-17} = 0b10000;
5259 let Inst{16-12} = opcode;
5260 let Inst{11-10} = 0b10;
5266 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5267 class BaseSIMDCmpTwoScalar<bit U, bits<2> size, bits<5> opcode,
5268 RegisterClass regtype, string asm, string zero>
5269 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
5270 "\t$Rd, $Rn, #" # zero, "", []>,
5274 let Inst{31-30} = 0b01;
5276 let Inst{28-24} = 0b11110;
5277 let Inst{23-22} = size;
5278 let Inst{21-17} = 0b10000;
5279 let Inst{16-12} = opcode;
5280 let Inst{11-10} = 0b10;
5285 class SIMDInexactCvtTwoScalar<bits<5> opcode, string asm>
5286 : I<(outs FPR32:$Rd), (ins FPR64:$Rn), asm, "\t$Rd, $Rn", "",
5287 [(set (f32 FPR32:$Rd), (int_arm64_sisd_fcvtxn (f64 FPR64:$Rn)))]>,
5291 let Inst{31-17} = 0b011111100110000;
5292 let Inst{16-12} = opcode;
5293 let Inst{11-10} = 0b10;
5298 multiclass SIMDCmpTwoScalarD<bit U, bits<5> opc, string asm,
5299 SDPatternOperator OpNode> {
5300 def v1i64rz : BaseSIMDCmpTwoScalar<U, 0b11, opc, FPR64, asm, "0">;
5302 def : Pat<(v1i64 (OpNode FPR64:$Rn)),
5303 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
5306 multiclass SIMDCmpTwoScalarSD<bit U, bit S, bits<5> opc, string asm,
5307 SDPatternOperator OpNode> {
5308 def v1i64rz : BaseSIMDCmpTwoScalar<U, {S,1}, opc, FPR64, asm, "0.0">;
5309 def v1i32rz : BaseSIMDCmpTwoScalar<U, {S,0}, opc, FPR32, asm, "0.0">;
5311 def : InstAlias<asm # " $Rd, $Rn, #0",
5312 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rd, FPR64:$Rn)>;
5313 def : InstAlias<asm # " $Rd, $Rn, #0",
5314 (!cast<Instruction>(NAME # v1i32rz) FPR32:$Rd, FPR32:$Rn)>;
5316 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn))),
5317 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
5320 multiclass SIMDTwoScalarD<bit U, bits<5> opc, string asm,
5321 SDPatternOperator OpNode = null_frag> {
5322 def v1i64 : BaseSIMDTwoScalar<U, 0b11, opc, FPR64, FPR64, asm,
5323 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn)))]>;
5325 def : Pat<(i64 (OpNode (i64 FPR64:$Rn))),
5326 (!cast<Instruction>(NAME # "v1i64") FPR64:$Rn)>;
5329 multiclass SIMDTwoScalarSD<bit U, bit S, bits<5> opc, string asm> {
5330 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, opc, FPR64, FPR64, asm,[]>;
5331 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, opc, FPR32, FPR32, asm,[]>;
5334 multiclass SIMDTwoScalarCVTSD<bit U, bit S, bits<5> opc, string asm,
5335 SDPatternOperator OpNode> {
5336 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, opc, FPR64, FPR64, asm,
5337 [(set FPR64:$Rd, (OpNode (f64 FPR64:$Rn)))]>;
5338 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, opc, FPR32, FPR32, asm,
5339 [(set FPR32:$Rd, (OpNode (f32 FPR32:$Rn)))]>;
5342 multiclass SIMDTwoScalarBHSD<bit U, bits<5> opc, string asm,
5343 SDPatternOperator OpNode = null_frag> {
5344 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5345 def v1i64 : BaseSIMDTwoScalar<U, 0b11, opc, FPR64, FPR64, asm,
5346 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
5347 def v1i32 : BaseSIMDTwoScalar<U, 0b10, opc, FPR32, FPR32, asm,
5348 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
5349 def v1i16 : BaseSIMDTwoScalar<U, 0b01, opc, FPR16, FPR16, asm, []>;
5350 def v1i8 : BaseSIMDTwoScalar<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
5353 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn))),
5354 (!cast<Instruction>(NAME # v1i64) FPR64:$Rn)>;
5357 multiclass SIMDTwoScalarBHSDTied<bit U, bits<5> opc, string asm,
5359 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5360 def v1i64 : BaseSIMDTwoScalarTied<U, 0b11, opc, FPR64, FPR64, asm,
5361 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn)))]>;
5362 def v1i32 : BaseSIMDTwoScalarTied<U, 0b10, opc, FPR32, FPR32, asm,
5363 [(set (i32 FPR32:$dst), (OpNode (i32 FPR32:$Rd), (i32 FPR32:$Rn)))]>;
5364 def v1i16 : BaseSIMDTwoScalarTied<U, 0b01, opc, FPR16, FPR16, asm, []>;
5365 def v1i8 : BaseSIMDTwoScalarTied<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
5368 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn))),
5369 (!cast<Instruction>(NAME # v1i64) FPR64:$Rd, FPR64:$Rn)>;
5374 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5375 multiclass SIMDTwoScalarMixedBHS<bit U, bits<5> opc, string asm,
5376 SDPatternOperator OpNode = null_frag> {
5377 def v1i32 : BaseSIMDTwoScalar<U, 0b10, opc, FPR32, FPR64, asm,
5378 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
5379 def v1i16 : BaseSIMDTwoScalar<U, 0b01, opc, FPR16, FPR32, asm, []>;
5380 def v1i8 : BaseSIMDTwoScalar<U, 0b00, opc, FPR8 , FPR16, asm, []>;
5383 //----------------------------------------------------------------------------
5384 // AdvSIMD scalar pairwise instructions
5385 //----------------------------------------------------------------------------
5387 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5388 class BaseSIMDPairwiseScalar<bit U, bits<2> size, bits<5> opcode,
5389 RegisterOperand regtype, RegisterOperand vectype,
5390 string asm, string kind>
5391 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
5392 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", []>,
5396 let Inst{31-30} = 0b01;
5398 let Inst{28-24} = 0b11110;
5399 let Inst{23-22} = size;
5400 let Inst{21-17} = 0b11000;
5401 let Inst{16-12} = opcode;
5402 let Inst{11-10} = 0b10;
5407 multiclass SIMDPairwiseScalarD<bit U, bits<5> opc, string asm> {
5408 def v2i64p : BaseSIMDPairwiseScalar<U, 0b11, opc, FPR64Op, V128,
5412 multiclass SIMDPairwiseScalarSD<bit U, bit S, bits<5> opc, string asm> {
5413 def v2i32p : BaseSIMDPairwiseScalar<U, {S,0}, opc, FPR32Op, V64,
5415 def v2i64p : BaseSIMDPairwiseScalar<U, {S,1}, opc, FPR64Op, V128,
5419 //----------------------------------------------------------------------------
5420 // AdvSIMD across lanes instructions
5421 //----------------------------------------------------------------------------
5423 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5424 class BaseSIMDAcrossLanes<bit Q, bit U, bits<2> size, bits<5> opcode,
5425 RegisterClass regtype, RegisterOperand vectype,
5426 string asm, string kind, list<dag> pattern>
5427 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
5428 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", pattern>,
5435 let Inst{28-24} = 0b01110;
5436 let Inst{23-22} = size;
5437 let Inst{21-17} = 0b11000;
5438 let Inst{16-12} = opcode;
5439 let Inst{11-10} = 0b10;
5444 multiclass SIMDAcrossLanesBHS<bit U, bits<5> opcode,
5446 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR8, V64,
5448 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR8, V128,
5450 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR16, V64,
5452 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR16, V128,
5454 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR32, V128,
5458 multiclass SIMDAcrossLanesHSD<bit U, bits<5> opcode, string asm> {
5459 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR16, V64,
5461 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR16, V128,
5463 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR32, V64,
5465 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR32, V128,
5467 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR64, V128,
5471 multiclass SIMDAcrossLanesS<bits<5> opcode, bit sz1, string asm,
5473 def v4i32v : BaseSIMDAcrossLanes<1, 1, {sz1, 0}, opcode, FPR32, V128,
5475 [(set FPR32:$Rd, (intOp (v4f32 V128:$Rn)))]>;
5478 //----------------------------------------------------------------------------
5479 // AdvSIMD INS/DUP instructions
5480 //----------------------------------------------------------------------------
5482 // FIXME: There has got to be a better way to factor these. ugh.
5484 class BaseSIMDInsDup<bit Q, bit op, dag outs, dag ins, string asm,
5485 string operands, string constraints, list<dag> pattern>
5486 : I<outs, ins, asm, operands, constraints, pattern>,
5493 let Inst{28-21} = 0b01110000;
5500 class SIMDDupFromMain<bit Q, bits<5> imm5, string size, ValueType vectype,
5501 RegisterOperand vecreg, RegisterClass regtype>
5502 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins regtype:$Rn), "dup",
5503 "{\t$Rd" # size # ", $Rn" #
5504 "|" # size # "\t$Rd, $Rn}", "",
5505 [(set (vectype vecreg:$Rd), (ARM64dup regtype:$Rn))]> {
5506 let Inst{20-16} = imm5;
5507 let Inst{14-11} = 0b0001;
5510 class SIMDDupFromElement<bit Q, string dstkind, string srckind,
5511 ValueType vectype, ValueType insreg,
5512 RegisterOperand vecreg, Operand idxtype,
5513 ValueType elttype, SDNode OpNode>
5514 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins V128:$Rn, idxtype:$idx), "dup",
5515 "{\t$Rd" # dstkind # ", $Rn" # srckind # "$idx" #
5516 "|" # dstkind # "\t$Rd, $Rn$idx}", "",
5517 [(set (vectype vecreg:$Rd),
5518 (OpNode (insreg V128:$Rn), idxtype:$idx))]> {
5519 let Inst{14-11} = 0b0000;
5522 class SIMDDup64FromElement
5523 : SIMDDupFromElement<1, ".2d", ".d", v2i64, v2i64, V128,
5524 VectorIndexD, i64, ARM64duplane64> {
5527 let Inst{19-16} = 0b1000;
5530 class SIMDDup32FromElement<bit Q, string size, ValueType vectype,
5531 RegisterOperand vecreg>
5532 : SIMDDupFromElement<Q, size, ".s", vectype, v4i32, vecreg,
5533 VectorIndexS, i64, ARM64duplane32> {
5535 let Inst{20-19} = idx;
5536 let Inst{18-16} = 0b100;
5539 class SIMDDup16FromElement<bit Q, string size, ValueType vectype,
5540 RegisterOperand vecreg>
5541 : SIMDDupFromElement<Q, size, ".h", vectype, v8i16, vecreg,
5542 VectorIndexH, i64, ARM64duplane16> {
5544 let Inst{20-18} = idx;
5545 let Inst{17-16} = 0b10;
5548 class SIMDDup8FromElement<bit Q, string size, ValueType vectype,
5549 RegisterOperand vecreg>
5550 : SIMDDupFromElement<Q, size, ".b", vectype, v16i8, vecreg,
5551 VectorIndexB, i64, ARM64duplane8> {
5553 let Inst{20-17} = idx;
5557 class BaseSIMDMov<bit Q, string size, bits<4> imm4, RegisterClass regtype,
5558 Operand idxtype, string asm, list<dag> pattern>
5559 : BaseSIMDInsDup<Q, 0, (outs regtype:$Rd), (ins V128:$Rn, idxtype:$idx), asm,
5560 "{\t$Rd, $Rn" # size # "$idx" #
5561 "|" # size # "\t$Rd, $Rn$idx}", "", pattern> {
5562 let Inst{14-11} = imm4;
5565 class SIMDSMov<bit Q, string size, RegisterClass regtype,
5567 : BaseSIMDMov<Q, size, 0b0101, regtype, idxtype, "smov", []>;
5568 class SIMDUMov<bit Q, string size, ValueType vectype, RegisterClass regtype,
5570 : BaseSIMDMov<Q, size, 0b0111, regtype, idxtype, "umov",
5571 [(set regtype:$Rd, (vector_extract (vectype V128:$Rn), idxtype:$idx))]>;
5573 class SIMDMovAlias<string asm, string size, Instruction inst,
5574 RegisterClass regtype, Operand idxtype>
5575 : InstAlias<asm#"{\t$dst, $src"#size#"$idx" #
5576 "|" # size # "\t$dst, $src$idx}",
5577 (inst regtype:$dst, V128:$src, idxtype:$idx)>;
5580 def vi8to32 : SIMDSMov<0, ".b", GPR32, VectorIndexB> {
5582 let Inst{20-17} = idx;
5585 def vi8to64 : SIMDSMov<1, ".b", GPR64, VectorIndexB> {
5587 let Inst{20-17} = idx;
5590 def vi16to32 : SIMDSMov<0, ".h", GPR32, VectorIndexH> {
5592 let Inst{20-18} = idx;
5593 let Inst{17-16} = 0b10;
5595 def vi16to64 : SIMDSMov<1, ".h", GPR64, VectorIndexH> {
5597 let Inst{20-18} = idx;
5598 let Inst{17-16} = 0b10;
5600 def vi32to64 : SIMDSMov<1, ".s", GPR64, VectorIndexS> {
5602 let Inst{20-19} = idx;
5603 let Inst{18-16} = 0b100;
5608 def vi8 : SIMDUMov<0, ".b", v16i8, GPR32, VectorIndexB> {
5610 let Inst{20-17} = idx;
5613 def vi16 : SIMDUMov<0, ".h", v8i16, GPR32, VectorIndexH> {
5615 let Inst{20-18} = idx;
5616 let Inst{17-16} = 0b10;
5618 def vi32 : SIMDUMov<0, ".s", v4i32, GPR32, VectorIndexS> {
5620 let Inst{20-19} = idx;
5621 let Inst{18-16} = 0b100;
5623 def vi64 : SIMDUMov<1, ".d", v2i64, GPR64, VectorIndexD> {
5626 let Inst{19-16} = 0b1000;
5628 def : SIMDMovAlias<"mov", ".s",
5629 !cast<Instruction>(NAME#"vi32"),
5630 GPR32, VectorIndexS>;
5631 def : SIMDMovAlias<"mov", ".d",
5632 !cast<Instruction>(NAME#"vi64"),
5633 GPR64, VectorIndexD>;
5636 class SIMDInsFromMain<string size, ValueType vectype,
5637 RegisterClass regtype, Operand idxtype>
5638 : BaseSIMDInsDup<1, 0, (outs V128:$dst),
5639 (ins V128:$Rd, idxtype:$idx, regtype:$Rn), "ins",
5640 "{\t$Rd" # size # "$idx, $Rn" #
5641 "|" # size # "\t$Rd$idx, $Rn}",
5644 (vector_insert (vectype V128:$Rd), regtype:$Rn, idxtype:$idx))]> {
5645 let Inst{14-11} = 0b0011;
5648 class SIMDInsFromElement<string size, ValueType vectype,
5649 ValueType elttype, Operand idxtype>
5650 : BaseSIMDInsDup<1, 1, (outs V128:$dst),
5651 (ins V128:$Rd, idxtype:$idx, V128:$Rn, idxtype:$idx2), "ins",
5652 "{\t$Rd" # size # "$idx, $Rn" # size # "$idx2" #
5653 "|" # size # "\t$Rd$idx, $Rn$idx2}",
5658 (elttype (vector_extract (vectype V128:$Rn), idxtype:$idx2)),
5661 class SIMDInsMainMovAlias<string size, Instruction inst,
5662 RegisterClass regtype, Operand idxtype>
5663 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" #
5664 "|" # size #"\t$dst$idx, $src}",
5665 (inst V128:$dst, idxtype:$idx, regtype:$src)>;
5666 class SIMDInsElementMovAlias<string size, Instruction inst,
5668 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" # size # "$idx2" #
5669 # "|" # size #" $dst$idx, $src$idx2}",
5670 (inst V128:$dst, idxtype:$idx, V128:$src, idxtype:$idx2)>;
5673 multiclass SIMDIns {
5674 def vi8gpr : SIMDInsFromMain<".b", v16i8, GPR32, VectorIndexB> {
5676 let Inst{20-17} = idx;
5679 def vi16gpr : SIMDInsFromMain<".h", v8i16, GPR32, VectorIndexH> {
5681 let Inst{20-18} = idx;
5682 let Inst{17-16} = 0b10;
5684 def vi32gpr : SIMDInsFromMain<".s", v4i32, GPR32, VectorIndexS> {
5686 let Inst{20-19} = idx;
5687 let Inst{18-16} = 0b100;
5689 def vi64gpr : SIMDInsFromMain<".d", v2i64, GPR64, VectorIndexD> {
5692 let Inst{19-16} = 0b1000;
5695 def vi8lane : SIMDInsFromElement<".b", v16i8, i32, VectorIndexB> {
5698 let Inst{20-17} = idx;
5700 let Inst{14-11} = idx2;
5702 def vi16lane : SIMDInsFromElement<".h", v8i16, i32, VectorIndexH> {
5705 let Inst{20-18} = idx;
5706 let Inst{17-16} = 0b10;
5707 let Inst{14-12} = idx2;
5710 def vi32lane : SIMDInsFromElement<".s", v4i32, i32, VectorIndexS> {
5713 let Inst{20-19} = idx;
5714 let Inst{18-16} = 0b100;
5715 let Inst{14-13} = idx2;
5716 let Inst{12-11} = 0;
5718 def vi64lane : SIMDInsFromElement<".d", v2i64, i64, VectorIndexD> {
5722 let Inst{19-16} = 0b1000;
5723 let Inst{14} = idx2;
5724 let Inst{13-11} = 0;
5727 // For all forms of the INS instruction, the "mov" mnemonic is the
5728 // preferred alias. Why they didn't just call the instruction "mov" in
5729 // the first place is a very good question indeed...
5730 def : SIMDInsMainMovAlias<".b", !cast<Instruction>(NAME#"vi8gpr"),
5731 GPR32, VectorIndexB>;
5732 def : SIMDInsMainMovAlias<".h", !cast<Instruction>(NAME#"vi16gpr"),
5733 GPR32, VectorIndexH>;
5734 def : SIMDInsMainMovAlias<".s", !cast<Instruction>(NAME#"vi32gpr"),
5735 GPR32, VectorIndexS>;
5736 def : SIMDInsMainMovAlias<".d", !cast<Instruction>(NAME#"vi64gpr"),
5737 GPR64, VectorIndexD>;
5739 def : SIMDInsElementMovAlias<".b", !cast<Instruction>(NAME#"vi8lane"),
5741 def : SIMDInsElementMovAlias<".h", !cast<Instruction>(NAME#"vi16lane"),
5743 def : SIMDInsElementMovAlias<".s", !cast<Instruction>(NAME#"vi32lane"),
5745 def : SIMDInsElementMovAlias<".d", !cast<Instruction>(NAME#"vi64lane"),
5749 //----------------------------------------------------------------------------
5751 //----------------------------------------------------------------------------
5753 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5754 class BaseSIMDTableLookup<bit Q, bits<2> len, bit op, RegisterOperand vectype,
5755 RegisterOperand listtype, string asm, string kind>
5756 : I<(outs vectype:$Vd), (ins listtype:$Vn, vectype:$Vm), asm,
5757 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "", []>,
5764 let Inst{29-21} = 0b001110000;
5765 let Inst{20-16} = Vm;
5767 let Inst{14-13} = len;
5769 let Inst{11-10} = 0b00;
5774 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5775 class BaseSIMDTableLookupTied<bit Q, bits<2> len, bit op, RegisterOperand vectype,
5776 RegisterOperand listtype, string asm, string kind>
5777 : I<(outs vectype:$dst), (ins vectype:$Vd, listtype:$Vn, vectype:$Vm), asm,
5778 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "$Vd = $dst", []>,
5785 let Inst{29-21} = 0b001110000;
5786 let Inst{20-16} = Vm;
5788 let Inst{14-13} = len;
5790 let Inst{11-10} = 0b00;
5795 class SIMDTableLookupAlias<string asm, Instruction inst,
5796 RegisterOperand vectype, RegisterOperand listtype>
5797 : InstAlias<!strconcat(asm, "\t$dst, $lst, $index"),
5798 (inst vectype:$dst, listtype:$lst, vectype:$index), 0>;
5800 multiclass SIMDTableLookup<bit op, string asm> {
5801 def v8i8One : BaseSIMDTableLookup<0, 0b00, op, V64, VecListOne16b,
5803 def v8i8Two : BaseSIMDTableLookup<0, 0b01, op, V64, VecListTwo16b,
5805 def v8i8Three : BaseSIMDTableLookup<0, 0b10, op, V64, VecListThree16b,
5807 def v8i8Four : BaseSIMDTableLookup<0, 0b11, op, V64, VecListFour16b,
5809 def v16i8One : BaseSIMDTableLookup<1, 0b00, op, V128, VecListOne16b,
5811 def v16i8Two : BaseSIMDTableLookup<1, 0b01, op, V128, VecListTwo16b,
5813 def v16i8Three: BaseSIMDTableLookup<1, 0b10, op, V128, VecListThree16b,
5815 def v16i8Four : BaseSIMDTableLookup<1, 0b11, op, V128, VecListFour16b,
5818 def : SIMDTableLookupAlias<asm # ".8b",
5819 !cast<Instruction>(NAME#"v8i8One"),
5820 V64, VecListOne128>;
5821 def : SIMDTableLookupAlias<asm # ".8b",
5822 !cast<Instruction>(NAME#"v8i8Two"),
5823 V64, VecListTwo128>;
5824 def : SIMDTableLookupAlias<asm # ".8b",
5825 !cast<Instruction>(NAME#"v8i8Three"),
5826 V64, VecListThree128>;
5827 def : SIMDTableLookupAlias<asm # ".8b",
5828 !cast<Instruction>(NAME#"v8i8Four"),
5829 V64, VecListFour128>;
5830 def : SIMDTableLookupAlias<asm # ".16b",
5831 !cast<Instruction>(NAME#"v16i8One"),
5832 V128, VecListOne128>;
5833 def : SIMDTableLookupAlias<asm # ".16b",
5834 !cast<Instruction>(NAME#"v16i8Two"),
5835 V128, VecListTwo128>;
5836 def : SIMDTableLookupAlias<asm # ".16b",
5837 !cast<Instruction>(NAME#"v16i8Three"),
5838 V128, VecListThree128>;
5839 def : SIMDTableLookupAlias<asm # ".16b",
5840 !cast<Instruction>(NAME#"v16i8Four"),
5841 V128, VecListFour128>;
5844 multiclass SIMDTableLookupTied<bit op, string asm> {
5845 def v8i8One : BaseSIMDTableLookupTied<0, 0b00, op, V64, VecListOne16b,
5847 def v8i8Two : BaseSIMDTableLookupTied<0, 0b01, op, V64, VecListTwo16b,
5849 def v8i8Three : BaseSIMDTableLookupTied<0, 0b10, op, V64, VecListThree16b,
5851 def v8i8Four : BaseSIMDTableLookupTied<0, 0b11, op, V64, VecListFour16b,
5853 def v16i8One : BaseSIMDTableLookupTied<1, 0b00, op, V128, VecListOne16b,
5855 def v16i8Two : BaseSIMDTableLookupTied<1, 0b01, op, V128, VecListTwo16b,
5857 def v16i8Three: BaseSIMDTableLookupTied<1, 0b10, op, V128, VecListThree16b,
5859 def v16i8Four : BaseSIMDTableLookupTied<1, 0b11, op, V128, VecListFour16b,
5862 def : SIMDTableLookupAlias<asm # ".8b",
5863 !cast<Instruction>(NAME#"v8i8One"),
5864 V64, VecListOne128>;
5865 def : SIMDTableLookupAlias<asm # ".8b",
5866 !cast<Instruction>(NAME#"v8i8Two"),
5867 V64, VecListTwo128>;
5868 def : SIMDTableLookupAlias<asm # ".8b",
5869 !cast<Instruction>(NAME#"v8i8Three"),
5870 V64, VecListThree128>;
5871 def : SIMDTableLookupAlias<asm # ".8b",
5872 !cast<Instruction>(NAME#"v8i8Four"),
5873 V64, VecListFour128>;
5874 def : SIMDTableLookupAlias<asm # ".16b",
5875 !cast<Instruction>(NAME#"v16i8One"),
5876 V128, VecListOne128>;
5877 def : SIMDTableLookupAlias<asm # ".16b",
5878 !cast<Instruction>(NAME#"v16i8Two"),
5879 V128, VecListTwo128>;
5880 def : SIMDTableLookupAlias<asm # ".16b",
5881 !cast<Instruction>(NAME#"v16i8Three"),
5882 V128, VecListThree128>;
5883 def : SIMDTableLookupAlias<asm # ".16b",
5884 !cast<Instruction>(NAME#"v16i8Four"),
5885 V128, VecListFour128>;
5889 //----------------------------------------------------------------------------
5890 // AdvSIMD scalar CPY
5891 //----------------------------------------------------------------------------
5892 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5893 class BaseSIMDScalarCPY<RegisterClass regtype, RegisterOperand vectype,
5894 string kind, Operand idxtype>
5895 : I<(outs regtype:$dst), (ins vectype:$src, idxtype:$idx), "mov",
5896 "{\t$dst, $src" # kind # "$idx" #
5897 "|\t$dst, $src$idx}", "", []>,
5901 let Inst{31-21} = 0b01011110000;
5902 let Inst{15-10} = 0b000001;
5903 let Inst{9-5} = src;
5904 let Inst{4-0} = dst;
5907 class SIMDScalarCPYAlias<string asm, string size, Instruction inst,
5908 RegisterClass regtype, RegisterOperand vectype, Operand idxtype>
5909 : InstAlias<asm # "{\t$dst, $src" # size # "$index" #
5910 # "|\t$dst, $src$index}",
5911 (inst regtype:$dst, vectype:$src, idxtype:$index)>;
5914 multiclass SIMDScalarCPY<string asm> {
5915 def i8 : BaseSIMDScalarCPY<FPR8, V128, ".b", VectorIndexB> {
5917 let Inst{20-17} = idx;
5920 def i16 : BaseSIMDScalarCPY<FPR16, V128, ".h", VectorIndexH> {
5922 let Inst{20-18} = idx;
5923 let Inst{17-16} = 0b10;
5925 def i32 : BaseSIMDScalarCPY<FPR32, V128, ".s", VectorIndexS> {
5927 let Inst{20-19} = idx;
5928 let Inst{18-16} = 0b100;
5930 def i64 : BaseSIMDScalarCPY<FPR64, V128, ".d", VectorIndexD> {
5933 let Inst{19-16} = 0b1000;
5936 def : Pat<(v1i64 (scalar_to_vector (i64 (vector_extract (v2i64 V128:$src),
5937 VectorIndexD:$idx)))),
5938 (!cast<Instruction>(NAME # i64) V128:$src, VectorIndexD:$idx)>;
5940 // 'DUP' mnemonic aliases.
5941 def : SIMDScalarCPYAlias<"dup", ".b",
5942 !cast<Instruction>(NAME#"i8"),
5943 FPR8, V128, VectorIndexB>;
5944 def : SIMDScalarCPYAlias<"dup", ".h",
5945 !cast<Instruction>(NAME#"i16"),
5946 FPR16, V128, VectorIndexH>;
5947 def : SIMDScalarCPYAlias<"dup", ".s",
5948 !cast<Instruction>(NAME#"i32"),
5949 FPR32, V128, VectorIndexS>;
5950 def : SIMDScalarCPYAlias<"dup", ".d",
5951 !cast<Instruction>(NAME#"i64"),
5952 FPR64, V128, VectorIndexD>;
5955 //----------------------------------------------------------------------------
5956 // AdvSIMD modified immediate instructions
5957 //----------------------------------------------------------------------------
5959 class BaseSIMDModifiedImm<bit Q, bit op, dag oops, dag iops,
5960 string asm, string op_string,
5961 string cstr, list<dag> pattern>
5962 : I<oops, iops, asm, op_string, cstr, pattern>,
5969 let Inst{28-19} = 0b0111100000;
5970 let Inst{18-16} = imm8{7-5};
5971 let Inst{11-10} = 0b01;
5972 let Inst{9-5} = imm8{4-0};
5976 class BaseSIMDModifiedImmVector<bit Q, bit op, RegisterOperand vectype,
5977 Operand immtype, dag opt_shift_iop,
5978 string opt_shift, string asm, string kind,
5980 : BaseSIMDModifiedImm<Q, op, (outs vectype:$Rd),
5981 !con((ins immtype:$imm8), opt_shift_iop), asm,
5982 "{\t$Rd" # kind # ", $imm8" # opt_shift #
5983 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
5985 let DecoderMethod = "DecodeModImmInstruction";
5988 class BaseSIMDModifiedImmVectorTied<bit Q, bit op, RegisterOperand vectype,
5989 Operand immtype, dag opt_shift_iop,
5990 string opt_shift, string asm, string kind,
5992 : BaseSIMDModifiedImm<Q, op, (outs vectype:$dst),
5993 !con((ins vectype:$Rd, immtype:$imm8), opt_shift_iop),
5994 asm, "{\t$Rd" # kind # ", $imm8" # opt_shift #
5995 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
5996 "$Rd = $dst", pattern> {
5997 let DecoderMethod = "DecodeModImmTiedInstruction";
6000 class BaseSIMDModifiedImmVectorShift<bit Q, bit op, bits<2> b15_b12,
6001 RegisterOperand vectype, string asm,
6002 string kind, list<dag> pattern>
6003 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6004 (ins logical_vec_shift:$shift),
6005 "$shift", asm, kind, pattern> {
6007 let Inst{15} = b15_b12{1};
6008 let Inst{14-13} = shift;
6009 let Inst{12} = b15_b12{0};
6012 class BaseSIMDModifiedImmVectorShiftTied<bit Q, bit op, bits<2> b15_b12,
6013 RegisterOperand vectype, string asm,
6014 string kind, list<dag> pattern>
6015 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
6016 (ins logical_vec_shift:$shift),
6017 "$shift", asm, kind, pattern> {
6019 let Inst{15} = b15_b12{1};
6020 let Inst{14-13} = shift;
6021 let Inst{12} = b15_b12{0};
6025 class BaseSIMDModifiedImmVectorShiftHalf<bit Q, bit op, bits<2> b15_b12,
6026 RegisterOperand vectype, string asm,
6027 string kind, list<dag> pattern>
6028 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6029 (ins logical_vec_hw_shift:$shift),
6030 "$shift", asm, kind, pattern> {
6032 let Inst{15} = b15_b12{1};
6034 let Inst{13} = shift{0};
6035 let Inst{12} = b15_b12{0};
6038 class BaseSIMDModifiedImmVectorShiftHalfTied<bit Q, bit op, bits<2> b15_b12,
6039 RegisterOperand vectype, string asm,
6040 string kind, list<dag> pattern>
6041 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
6042 (ins logical_vec_hw_shift:$shift),
6043 "$shift", asm, kind, pattern> {
6045 let Inst{15} = b15_b12{1};
6047 let Inst{13} = shift{0};
6048 let Inst{12} = b15_b12{0};
6051 multiclass SIMDModifiedImmVectorShift<bit op, bits<2> hw_cmode, bits<2> w_cmode,
6053 def v4i16 : BaseSIMDModifiedImmVectorShiftHalf<0, op, hw_cmode, V64,
6055 def v8i16 : BaseSIMDModifiedImmVectorShiftHalf<1, op, hw_cmode, V128,
6058 def v2i32 : BaseSIMDModifiedImmVectorShift<0, op, w_cmode, V64,
6060 def v4i32 : BaseSIMDModifiedImmVectorShift<1, op, w_cmode, V128,
6064 multiclass SIMDModifiedImmVectorShiftTied<bit op, bits<2> hw_cmode,
6065 bits<2> w_cmode, string asm,
6067 def v4i16 : BaseSIMDModifiedImmVectorShiftHalfTied<0, op, hw_cmode, V64,
6069 [(set (v4i16 V64:$dst), (OpNode V64:$Rd,
6071 (i32 imm:$shift)))]>;
6072 def v8i16 : BaseSIMDModifiedImmVectorShiftHalfTied<1, op, hw_cmode, V128,
6074 [(set (v8i16 V128:$dst), (OpNode V128:$Rd,
6076 (i32 imm:$shift)))]>;
6078 def v2i32 : BaseSIMDModifiedImmVectorShiftTied<0, op, w_cmode, V64,
6080 [(set (v2i32 V64:$dst), (OpNode V64:$Rd,
6082 (i32 imm:$shift)))]>;
6083 def v4i32 : BaseSIMDModifiedImmVectorShiftTied<1, op, w_cmode, V128,
6085 [(set (v4i32 V128:$dst), (OpNode V128:$Rd,
6087 (i32 imm:$shift)))]>;
6090 class SIMDModifiedImmMoveMSL<bit Q, bit op, bits<4> cmode,
6091 RegisterOperand vectype, string asm,
6092 string kind, list<dag> pattern>
6093 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6094 (ins move_vec_shift:$shift),
6095 "$shift", asm, kind, pattern> {
6097 let Inst{15-13} = cmode{3-1};
6098 let Inst{12} = shift;
6101 class SIMDModifiedImmVectorNoShift<bit Q, bit op, bits<4> cmode,
6102 RegisterOperand vectype,
6103 Operand imm_type, string asm,
6104 string kind, list<dag> pattern>
6105 : BaseSIMDModifiedImmVector<Q, op, vectype, imm_type, (ins), "",
6106 asm, kind, pattern> {
6107 let Inst{15-12} = cmode;
6110 class SIMDModifiedImmScalarNoShift<bit Q, bit op, bits<4> cmode, string asm,
6112 : BaseSIMDModifiedImm<Q, op, (outs FPR64:$Rd), (ins simdimmtype10:$imm8), asm,
6113 "\t$Rd, $imm8", "", pattern> {
6114 let Inst{15-12} = cmode;
6115 let DecoderMethod = "DecodeModImmInstruction";
6118 //----------------------------------------------------------------------------
6119 // AdvSIMD indexed element
6120 //----------------------------------------------------------------------------
6122 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6123 class BaseSIMDIndexed<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
6124 RegisterOperand dst_reg, RegisterOperand lhs_reg,
6125 RegisterOperand rhs_reg, Operand vec_idx, string asm,
6126 string apple_kind, string dst_kind, string lhs_kind,
6127 string rhs_kind, list<dag> pattern>
6128 : I<(outs dst_reg:$Rd), (ins lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx),
6130 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
6131 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "", pattern>,
6140 let Inst{28} = Scalar;
6141 let Inst{27-24} = 0b1111;
6142 let Inst{23-22} = size;
6143 // Bit 21 must be set by the derived class.
6144 let Inst{20-16} = Rm;
6145 let Inst{15-12} = opc;
6146 // Bit 11 must be set by the derived class.
6152 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6153 class BaseSIMDIndexedTied<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
6154 RegisterOperand dst_reg, RegisterOperand lhs_reg,
6155 RegisterOperand rhs_reg, Operand vec_idx, string asm,
6156 string apple_kind, string dst_kind, string lhs_kind,
6157 string rhs_kind, list<dag> pattern>
6158 : I<(outs dst_reg:$dst),
6159 (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx), asm,
6160 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
6161 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "$Rd = $dst", pattern>,
6170 let Inst{28} = Scalar;
6171 let Inst{27-24} = 0b1111;
6172 let Inst{23-22} = size;
6173 // Bit 21 must be set by the derived class.
6174 let Inst{20-16} = Rm;
6175 let Inst{15-12} = opc;
6176 // Bit 11 must be set by the derived class.
6182 multiclass SIMDFPIndexedSD<bit U, bits<4> opc, string asm,
6183 SDPatternOperator OpNode> {
6184 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6187 asm, ".2s", ".2s", ".2s", ".s",
6188 [(set (v2f32 V64:$Rd),
6189 (OpNode (v2f32 V64:$Rn),
6190 (v2f32 (ARM64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
6192 let Inst{11} = idx{1};
6193 let Inst{21} = idx{0};
6196 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6199 asm, ".4s", ".4s", ".4s", ".s",
6200 [(set (v4f32 V128:$Rd),
6201 (OpNode (v4f32 V128:$Rn),
6202 (v4f32 (ARM64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
6204 let Inst{11} = idx{1};
6205 let Inst{21} = idx{0};
6208 def v2i64_indexed : BaseSIMDIndexed<1, U, 0, 0b11, opc,
6211 asm, ".2d", ".2d", ".2d", ".d",
6212 [(set (v2f64 V128:$Rd),
6213 (OpNode (v2f64 V128:$Rn),
6214 (v2f64 (ARM64duplane64 (v2f64 V128:$Rm), VectorIndexD:$idx))))]> {
6216 let Inst{11} = idx{0};
6220 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6221 FPR32Op, FPR32Op, V128, VectorIndexS,
6222 asm, ".s", "", "", ".s",
6223 [(set (f32 FPR32Op:$Rd),
6224 (OpNode (f32 FPR32Op:$Rn),
6225 (f32 (vector_extract (v4f32 V128:$Rm),
6226 VectorIndexS:$idx))))]> {
6228 let Inst{11} = idx{1};
6229 let Inst{21} = idx{0};
6232 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b11, opc,
6233 FPR64Op, FPR64Op, V128, VectorIndexD,
6234 asm, ".d", "", "", ".d",
6235 [(set (f64 FPR64Op:$Rd),
6236 (OpNode (f64 FPR64Op:$Rn),
6237 (f64 (vector_extract (v2f64 V128:$Rm),
6238 VectorIndexD:$idx))))]> {
6240 let Inst{11} = idx{0};
6245 multiclass SIMDFPIndexedSDTiedPatterns<string INST, SDPatternOperator OpNode> {
6246 // 2 variants for the .2s version: DUPLANE from 128-bit and DUP scalar.
6247 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
6248 (ARM64duplane32 (v4f32 V128:$Rm),
6249 VectorIndexS:$idx))),
6250 (!cast<Instruction>(INST # v2i32_indexed)
6251 V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6252 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
6253 (ARM64dup (f32 FPR32Op:$Rm)))),
6254 (!cast<Instruction>(INST # "v2i32_indexed") V64:$Rd, V64:$Rn,
6255 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
6258 // 2 variants for the .4s version: DUPLANE from 128-bit and DUP scalar.
6259 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
6260 (ARM64duplane32 (v4f32 V128:$Rm),
6261 VectorIndexS:$idx))),
6262 (!cast<Instruction>(INST # "v4i32_indexed")
6263 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6264 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
6265 (ARM64dup (f32 FPR32Op:$Rm)))),
6266 (!cast<Instruction>(INST # "v4i32_indexed") V128:$Rd, V128:$Rn,
6267 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
6269 // 2 variants for the .2d version: DUPLANE from 128-bit and DUP scalar.
6270 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
6271 (ARM64duplane64 (v2f64 V128:$Rm),
6272 VectorIndexD:$idx))),
6273 (!cast<Instruction>(INST # "v2i64_indexed")
6274 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6275 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
6276 (ARM64dup (f64 FPR64Op:$Rm)))),
6277 (!cast<Instruction>(INST # "v2i64_indexed") V128:$Rd, V128:$Rn,
6278 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
6280 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
6281 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
6282 (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx))),
6283 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
6284 V128:$Rm, VectorIndexS:$idx)>;
6285 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
6286 (vector_extract (v2f32 V64:$Rm), VectorIndexS:$idx))),
6287 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
6288 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
6290 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
6291 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
6292 (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx))),
6293 (!cast<Instruction>(INST # "v1i64_indexed") FPR64:$Rd, FPR64:$Rn,
6294 V128:$Rm, VectorIndexD:$idx)>;
6297 multiclass SIMDFPIndexedSDTied<bit U, bits<4> opc, string asm> {
6298 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64,
6300 asm, ".2s", ".2s", ".2s", ".s", []> {
6302 let Inst{11} = idx{1};
6303 let Inst{21} = idx{0};
6306 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6309 asm, ".4s", ".4s", ".4s", ".s", []> {
6311 let Inst{11} = idx{1};
6312 let Inst{21} = idx{0};
6315 def v2i64_indexed : BaseSIMDIndexedTied<1, U, 0, 0b11, opc,
6318 asm, ".2d", ".2d", ".2d", ".d", []> {
6320 let Inst{11} = idx{0};
6325 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
6326 FPR32Op, FPR32Op, V128, VectorIndexS,
6327 asm, ".s", "", "", ".s", []> {
6329 let Inst{11} = idx{1};
6330 let Inst{21} = idx{0};
6333 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b11, opc,
6334 FPR64Op, FPR64Op, V128, VectorIndexD,
6335 asm, ".d", "", "", ".d", []> {
6337 let Inst{11} = idx{0};
6342 multiclass SIMDIndexedHS<bit U, bits<4> opc, string asm,
6343 SDPatternOperator OpNode> {
6344 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V64, V64,
6345 V128_lo, VectorIndexH,
6346 asm, ".4h", ".4h", ".4h", ".h",
6347 [(set (v4i16 V64:$Rd),
6348 (OpNode (v4i16 V64:$Rn),
6349 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6351 let Inst{11} = idx{2};
6352 let Inst{21} = idx{1};
6353 let Inst{20} = idx{0};
6356 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6358 V128_lo, VectorIndexH,
6359 asm, ".8h", ".8h", ".8h", ".h",
6360 [(set (v8i16 V128:$Rd),
6361 (OpNode (v8i16 V128:$Rn),
6362 (v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6364 let Inst{11} = idx{2};
6365 let Inst{21} = idx{1};
6366 let Inst{20} = idx{0};
6369 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6372 asm, ".2s", ".2s", ".2s", ".s",
6373 [(set (v2i32 V64:$Rd),
6374 (OpNode (v2i32 V64:$Rn),
6375 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6377 let Inst{11} = idx{1};
6378 let Inst{21} = idx{0};
6381 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6384 asm, ".4s", ".4s", ".4s", ".s",
6385 [(set (v4i32 V128:$Rd),
6386 (OpNode (v4i32 V128:$Rn),
6387 (v4i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6389 let Inst{11} = idx{1};
6390 let Inst{21} = idx{0};
6393 def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
6394 FPR16Op, FPR16Op, V128_lo, VectorIndexH,
6395 asm, ".h", "", "", ".h", []> {
6397 let Inst{11} = idx{2};
6398 let Inst{21} = idx{1};
6399 let Inst{20} = idx{0};
6402 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6403 FPR32Op, FPR32Op, V128, VectorIndexS,
6404 asm, ".s", "", "", ".s",
6405 [(set (i32 FPR32Op:$Rd),
6406 (OpNode FPR32Op:$Rn,
6407 (i32 (vector_extract (v4i32 V128:$Rm),
6408 VectorIndexS:$idx))))]> {
6410 let Inst{11} = idx{1};
6411 let Inst{21} = idx{0};
6415 multiclass SIMDVectorIndexedHS<bit U, bits<4> opc, string asm,
6416 SDPatternOperator OpNode> {
6417 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6419 V128_lo, VectorIndexH,
6420 asm, ".4h", ".4h", ".4h", ".h",
6421 [(set (v4i16 V64:$Rd),
6422 (OpNode (v4i16 V64:$Rn),
6423 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6425 let Inst{11} = idx{2};
6426 let Inst{21} = idx{1};
6427 let Inst{20} = idx{0};
6430 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6432 V128_lo, VectorIndexH,
6433 asm, ".8h", ".8h", ".8h", ".h",
6434 [(set (v8i16 V128:$Rd),
6435 (OpNode (v8i16 V128:$Rn),
6436 (v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6438 let Inst{11} = idx{2};
6439 let Inst{21} = idx{1};
6440 let Inst{20} = idx{0};
6443 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6446 asm, ".2s", ".2s", ".2s", ".s",
6447 [(set (v2i32 V64:$Rd),
6448 (OpNode (v2i32 V64:$Rn),
6449 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6451 let Inst{11} = idx{1};
6452 let Inst{21} = idx{0};
6455 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6458 asm, ".4s", ".4s", ".4s", ".s",
6459 [(set (v4i32 V128:$Rd),
6460 (OpNode (v4i32 V128:$Rn),
6461 (v4i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6463 let Inst{11} = idx{1};
6464 let Inst{21} = idx{0};
6468 multiclass SIMDVectorIndexedHSTied<bit U, bits<4> opc, string asm,
6469 SDPatternOperator OpNode> {
6470 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V64, V64,
6471 V128_lo, VectorIndexH,
6472 asm, ".4h", ".4h", ".4h", ".h",
6473 [(set (v4i16 V64:$dst),
6474 (OpNode (v4i16 V64:$Rd),(v4i16 V64:$Rn),
6475 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6477 let Inst{11} = idx{2};
6478 let Inst{21} = idx{1};
6479 let Inst{20} = idx{0};
6482 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6484 V128_lo, VectorIndexH,
6485 asm, ".8h", ".8h", ".8h", ".h",
6486 [(set (v8i16 V128:$dst),
6487 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
6488 (v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6490 let Inst{11} = idx{2};
6491 let Inst{21} = idx{1};
6492 let Inst{20} = idx{0};
6495 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6498 asm, ".2s", ".2s", ".2s", ".s",
6499 [(set (v2i32 V64:$dst),
6500 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
6501 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6503 let Inst{11} = idx{1};
6504 let Inst{21} = idx{0};
6507 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6510 asm, ".4s", ".4s", ".4s", ".s",
6511 [(set (v4i32 V128:$dst),
6512 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
6513 (v4i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6515 let Inst{11} = idx{1};
6516 let Inst{21} = idx{0};
6520 multiclass SIMDIndexedLongSD<bit U, bits<4> opc, string asm,
6521 SDPatternOperator OpNode> {
6522 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6524 V128_lo, VectorIndexH,
6525 asm, ".4s", ".4s", ".4h", ".h",
6526 [(set (v4i32 V128:$Rd),
6527 (OpNode (v4i16 V64:$Rn),
6528 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6530 let Inst{11} = idx{2};
6531 let Inst{21} = idx{1};
6532 let Inst{20} = idx{0};
6535 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6537 V128_lo, VectorIndexH,
6538 asm#"2", ".4s", ".4s", ".8h", ".h",
6539 [(set (v4i32 V128:$Rd),
6540 (OpNode (extract_high_v8i16 V128:$Rn),
6541 (extract_high_v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6542 VectorIndexH:$idx))))]> {
6545 let Inst{11} = idx{2};
6546 let Inst{21} = idx{1};
6547 let Inst{20} = idx{0};
6550 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6553 asm, ".2d", ".2d", ".2s", ".s",
6554 [(set (v2i64 V128:$Rd),
6555 (OpNode (v2i32 V64:$Rn),
6556 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6558 let Inst{11} = idx{1};
6559 let Inst{21} = idx{0};
6562 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6565 asm#"2", ".2d", ".2d", ".4s", ".s",
6566 [(set (v2i64 V128:$Rd),
6567 (OpNode (extract_high_v4i32 V128:$Rn),
6568 (extract_high_v4i32 (ARM64duplane32 (v4i32 V128:$Rm),
6569 VectorIndexS:$idx))))]> {
6571 let Inst{11} = idx{1};
6572 let Inst{21} = idx{0};
6575 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
6576 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
6577 asm, ".h", "", "", ".h", []> {
6579 let Inst{11} = idx{2};
6580 let Inst{21} = idx{1};
6581 let Inst{20} = idx{0};
6584 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6585 FPR64Op, FPR32Op, V128, VectorIndexS,
6586 asm, ".s", "", "", ".s", []> {
6588 let Inst{11} = idx{1};
6589 let Inst{21} = idx{0};
6593 multiclass SIMDIndexedLongSQDMLXSDTied<bit U, bits<4> opc, string asm,
6594 SDPatternOperator Accum> {
6595 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
6597 V128_lo, VectorIndexH,
6598 asm, ".4s", ".4s", ".4h", ".h",
6599 [(set (v4i32 V128:$dst),
6600 (Accum (v4i32 V128:$Rd),
6601 (v4i32 (int_arm64_neon_sqdmull
6603 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6604 VectorIndexH:$idx))))))]> {
6606 let Inst{11} = idx{2};
6607 let Inst{21} = idx{1};
6608 let Inst{20} = idx{0};
6611 // FIXME: it would be nice to use the scalar (v1i32) instruction here, but an
6612 // intermediate EXTRACT_SUBREG would be untyped.
6613 def : Pat<(i32 (Accum (i32 FPR32Op:$Rd),
6614 (i32 (vector_extract (v4i32
6615 (int_arm64_neon_sqdmull (v4i16 V64:$Rn),
6616 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6617 VectorIndexH:$idx)))),
6620 (!cast<Instruction>(NAME # v4i16_indexed)
6621 (SUBREG_TO_REG (i32 0), FPR32Op:$Rd, ssub), V64:$Rn,
6622 V128_lo:$Rm, VectorIndexH:$idx),
6625 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6627 V128_lo, VectorIndexH,
6628 asm#"2", ".4s", ".4s", ".8h", ".h",
6629 [(set (v4i32 V128:$dst),
6630 (Accum (v4i32 V128:$Rd),
6631 (v4i32 (int_arm64_neon_sqdmull
6632 (extract_high_v8i16 V128:$Rn),
6634 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6635 VectorIndexH:$idx))))))]> {
6637 let Inst{11} = idx{2};
6638 let Inst{21} = idx{1};
6639 let Inst{20} = idx{0};
6642 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6645 asm, ".2d", ".2d", ".2s", ".s",
6646 [(set (v2i64 V128:$dst),
6647 (Accum (v2i64 V128:$Rd),
6648 (v2i64 (int_arm64_neon_sqdmull
6650 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm),
6651 VectorIndexS:$idx))))))]> {
6653 let Inst{11} = idx{1};
6654 let Inst{21} = idx{0};
6657 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6660 asm#"2", ".2d", ".2d", ".4s", ".s",
6661 [(set (v2i64 V128:$dst),
6662 (Accum (v2i64 V128:$Rd),
6663 (v2i64 (int_arm64_neon_sqdmull
6664 (extract_high_v4i32 V128:$Rn),
6666 (ARM64duplane32 (v4i32 V128:$Rm),
6667 VectorIndexS:$idx))))))]> {
6669 let Inst{11} = idx{1};
6670 let Inst{21} = idx{0};
6673 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc,
6674 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
6675 asm, ".h", "", "", ".h", []> {
6677 let Inst{11} = idx{2};
6678 let Inst{21} = idx{1};
6679 let Inst{20} = idx{0};
6683 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
6684 FPR64Op, FPR32Op, V128, VectorIndexS,
6685 asm, ".s", "", "", ".s",
6686 [(set (i64 FPR64Op:$dst),
6687 (Accum (i64 FPR64Op:$Rd),
6688 (i64 (int_arm64_neon_sqdmulls_scalar
6690 (i32 (vector_extract (v4i32 V128:$Rm),
6691 VectorIndexS:$idx))))))]> {
6694 let Inst{11} = idx{1};
6695 let Inst{21} = idx{0};
6699 multiclass SIMDVectorIndexedLongSD<bit U, bits<4> opc, string asm,
6700 SDPatternOperator OpNode> {
6701 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6702 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6704 V128_lo, VectorIndexH,
6705 asm, ".4s", ".4s", ".4h", ".h",
6706 [(set (v4i32 V128:$Rd),
6707 (OpNode (v4i16 V64:$Rn),
6708 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6710 let Inst{11} = idx{2};
6711 let Inst{21} = idx{1};
6712 let Inst{20} = idx{0};
6715 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6717 V128_lo, VectorIndexH,
6718 asm#"2", ".4s", ".4s", ".8h", ".h",
6719 [(set (v4i32 V128:$Rd),
6720 (OpNode (extract_high_v8i16 V128:$Rn),
6721 (extract_high_v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6722 VectorIndexH:$idx))))]> {
6725 let Inst{11} = idx{2};
6726 let Inst{21} = idx{1};
6727 let Inst{20} = idx{0};
6730 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6733 asm, ".2d", ".2d", ".2s", ".s",
6734 [(set (v2i64 V128:$Rd),
6735 (OpNode (v2i32 V64:$Rn),
6736 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6738 let Inst{11} = idx{1};
6739 let Inst{21} = idx{0};
6742 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6745 asm#"2", ".2d", ".2d", ".4s", ".s",
6746 [(set (v2i64 V128:$Rd),
6747 (OpNode (extract_high_v4i32 V128:$Rn),
6748 (extract_high_v4i32 (ARM64duplane32 (v4i32 V128:$Rm),
6749 VectorIndexS:$idx))))]> {
6751 let Inst{11} = idx{1};
6752 let Inst{21} = idx{0};
6757 multiclass SIMDVectorIndexedLongSDTied<bit U, bits<4> opc, string asm,
6758 SDPatternOperator OpNode> {
6759 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6760 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
6762 V128_lo, VectorIndexH,
6763 asm, ".4s", ".4s", ".4h", ".h",
6764 [(set (v4i32 V128:$dst),
6765 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn),
6766 (v4i16 (ARM64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6768 let Inst{11} = idx{2};
6769 let Inst{21} = idx{1};
6770 let Inst{20} = idx{0};
6773 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6775 V128_lo, VectorIndexH,
6776 asm#"2", ".4s", ".4s", ".8h", ".h",
6777 [(set (v4i32 V128:$dst),
6778 (OpNode (v4i32 V128:$Rd),
6779 (extract_high_v8i16 V128:$Rn),
6780 (extract_high_v8i16 (ARM64duplane16 (v8i16 V128_lo:$Rm),
6781 VectorIndexH:$idx))))]> {
6783 let Inst{11} = idx{2};
6784 let Inst{21} = idx{1};
6785 let Inst{20} = idx{0};
6788 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6791 asm, ".2d", ".2d", ".2s", ".s",
6792 [(set (v2i64 V128:$dst),
6793 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn),
6794 (v2i32 (ARM64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6796 let Inst{11} = idx{1};
6797 let Inst{21} = idx{0};
6800 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6803 asm#"2", ".2d", ".2d", ".4s", ".s",
6804 [(set (v2i64 V128:$dst),
6805 (OpNode (v2i64 V128:$Rd),
6806 (extract_high_v4i32 V128:$Rn),
6807 (extract_high_v4i32 (ARM64duplane32 (v4i32 V128:$Rm),
6808 VectorIndexS:$idx))))]> {
6810 let Inst{11} = idx{1};
6811 let Inst{21} = idx{0};
6816 //----------------------------------------------------------------------------
6817 // AdvSIMD scalar shift by immediate
6818 //----------------------------------------------------------------------------
6820 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6821 class BaseSIMDScalarShift<bit U, bits<5> opc, bits<7> fixed_imm,
6822 RegisterClass regtype1, RegisterClass regtype2,
6823 Operand immtype, string asm, list<dag> pattern>
6824 : I<(outs regtype1:$Rd), (ins regtype2:$Rn, immtype:$imm),
6825 asm, "\t$Rd, $Rn, $imm", "", pattern>,
6830 let Inst{31-30} = 0b01;
6832 let Inst{28-23} = 0b111110;
6833 let Inst{22-16} = fixed_imm;
6834 let Inst{15-11} = opc;
6840 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6841 class BaseSIMDScalarShiftTied<bit U, bits<5> opc, bits<7> fixed_imm,
6842 RegisterClass regtype1, RegisterClass regtype2,
6843 Operand immtype, string asm, list<dag> pattern>
6844 : I<(outs regtype1:$dst), (ins regtype1:$Rd, regtype2:$Rn, immtype:$imm),
6845 asm, "\t$Rd, $Rn, $imm", "$Rd = $dst", pattern>,
6850 let Inst{31-30} = 0b01;
6852 let Inst{28-23} = 0b111110;
6853 let Inst{22-16} = fixed_imm;
6854 let Inst{15-11} = opc;
6861 multiclass SIMDScalarRShiftSD<bit U, bits<5> opc, string asm> {
6862 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6863 FPR32, FPR32, vecshiftR32, asm, []> {
6864 let Inst{20-16} = imm{4-0};
6867 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6868 FPR64, FPR64, vecshiftR64, asm, []> {
6869 let Inst{21-16} = imm{5-0};
6873 multiclass SIMDScalarRShiftD<bit U, bits<5> opc, string asm,
6874 SDPatternOperator OpNode> {
6875 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6876 FPR64, FPR64, vecshiftR64, asm,
6877 [(set (i64 FPR64:$Rd),
6878 (OpNode (i64 FPR64:$Rn), (i32 vecshiftR64:$imm)))]> {
6879 let Inst{21-16} = imm{5-0};
6882 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftR64:$imm))),
6883 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftR64:$imm)>;
6886 multiclass SIMDScalarRShiftDTied<bit U, bits<5> opc, string asm,
6887 SDPatternOperator OpNode = null_frag> {
6888 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
6889 FPR64, FPR64, vecshiftR64, asm,
6890 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn),
6891 (i32 vecshiftR64:$imm)))]> {
6892 let Inst{21-16} = imm{5-0};
6895 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
6896 (i32 vecshiftR64:$imm))),
6897 (!cast<Instruction>(NAME # "d") FPR64:$Rd, FPR64:$Rn,
6901 multiclass SIMDScalarLShiftD<bit U, bits<5> opc, string asm,
6902 SDPatternOperator OpNode> {
6903 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6904 FPR64, FPR64, vecshiftL64, asm,
6905 [(set (v1i64 FPR64:$Rd),
6906 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
6907 let Inst{21-16} = imm{5-0};
6911 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6912 multiclass SIMDScalarLShiftDTied<bit U, bits<5> opc, string asm> {
6913 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
6914 FPR64, FPR64, vecshiftL64, asm, []> {
6915 let Inst{21-16} = imm{5-0};
6919 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6920 multiclass SIMDScalarRShiftBHS<bit U, bits<5> opc, string asm,
6921 SDPatternOperator OpNode = null_frag> {
6922 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
6923 FPR8, FPR16, vecshiftR8, asm, []> {
6924 let Inst{18-16} = imm{2-0};
6927 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
6928 FPR16, FPR32, vecshiftR16, asm, []> {
6929 let Inst{19-16} = imm{3-0};
6932 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6933 FPR32, FPR64, vecshiftR32, asm,
6934 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn), vecshiftR32:$imm))]> {
6935 let Inst{20-16} = imm{4-0};
6939 multiclass SIMDScalarLShiftBHSD<bit U, bits<5> opc, string asm,
6940 SDPatternOperator OpNode> {
6941 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
6942 FPR8, FPR8, vecshiftL8, asm, []> {
6943 let Inst{18-16} = imm{2-0};
6946 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
6947 FPR16, FPR16, vecshiftL16, asm, []> {
6948 let Inst{19-16} = imm{3-0};
6951 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6952 FPR32, FPR32, vecshiftL32, asm,
6953 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn), (i32 vecshiftL32:$imm)))]> {
6954 let Inst{20-16} = imm{4-0};
6957 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6958 FPR64, FPR64, vecshiftL64, asm,
6959 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
6960 let Inst{21-16} = imm{5-0};
6963 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm))),
6964 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftL64:$imm)>;
6967 multiclass SIMDScalarRShiftBHSD<bit U, bits<5> opc, string asm> {
6968 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
6969 FPR8, FPR8, vecshiftR8, asm, []> {
6970 let Inst{18-16} = imm{2-0};
6973 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
6974 FPR16, FPR16, vecshiftR16, asm, []> {
6975 let Inst{19-16} = imm{3-0};
6978 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
6979 FPR32, FPR32, vecshiftR32, asm, []> {
6980 let Inst{20-16} = imm{4-0};
6983 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
6984 FPR64, FPR64, vecshiftR64, asm, []> {
6985 let Inst{21-16} = imm{5-0};
6989 //----------------------------------------------------------------------------
6990 // AdvSIMD vector x indexed element
6991 //----------------------------------------------------------------------------
6993 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6994 class BaseSIMDVectorShift<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
6995 RegisterOperand dst_reg, RegisterOperand src_reg,
6997 string asm, string dst_kind, string src_kind,
6999 : I<(outs dst_reg:$Rd), (ins src_reg:$Rn, immtype:$imm),
7000 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
7001 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "", pattern>,
7008 let Inst{28-23} = 0b011110;
7009 let Inst{22-16} = fixed_imm;
7010 let Inst{15-11} = opc;
7016 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7017 class BaseSIMDVectorShiftTied<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
7018 RegisterOperand vectype1, RegisterOperand vectype2,
7020 string asm, string dst_kind, string src_kind,
7022 : I<(outs vectype1:$dst), (ins vectype1:$Rd, vectype2:$Rn, immtype:$imm),
7023 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
7024 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "$Rd = $dst", pattern>,
7031 let Inst{28-23} = 0b011110;
7032 let Inst{22-16} = fixed_imm;
7033 let Inst{15-11} = opc;
7039 multiclass SIMDVectorRShiftSD<bit U, bits<5> opc, string asm,
7041 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7042 V64, V64, vecshiftR32,
7044 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (i32 imm:$imm)))]> {
7046 let Inst{20-16} = imm;
7049 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7050 V128, V128, vecshiftR32,
7052 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (i32 imm:$imm)))]> {
7054 let Inst{20-16} = imm;
7057 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7058 V128, V128, vecshiftR64,
7060 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (i32 imm:$imm)))]> {
7062 let Inst{21-16} = imm;
7066 multiclass SIMDVectorRShiftSDToFP<bit U, bits<5> opc, string asm,
7068 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7069 V64, V64, vecshiftR32,
7071 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 imm:$imm)))]> {
7073 let Inst{20-16} = imm;
7076 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7077 V128, V128, vecshiftR32,
7079 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 imm:$imm)))]> {
7081 let Inst{20-16} = imm;
7084 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7085 V128, V128, vecshiftR64,
7087 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 imm:$imm)))]> {
7089 let Inst{21-16} = imm;
7093 multiclass SIMDVectorRShiftNarrowBHS<bit U, bits<5> opc, string asm,
7094 SDPatternOperator OpNode> {
7095 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7096 V64, V128, vecshiftR16Narrow,
7098 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))]> {
7100 let Inst{18-16} = imm;
7103 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7104 V128, V128, vecshiftR16Narrow,
7105 asm#"2", ".16b", ".8h", []> {
7107 let Inst{18-16} = imm;
7108 let hasSideEffects = 0;
7111 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7112 V64, V128, vecshiftR32Narrow,
7114 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))]> {
7116 let Inst{19-16} = imm;
7119 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7120 V128, V128, vecshiftR32Narrow,
7121 asm#"2", ".8h", ".4s", []> {
7123 let Inst{19-16} = imm;
7124 let hasSideEffects = 0;
7127 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7128 V64, V128, vecshiftR64Narrow,
7130 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))]> {
7132 let Inst{20-16} = imm;
7135 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7136 V128, V128, vecshiftR64Narrow,
7137 asm#"2", ".4s", ".2d", []> {
7139 let Inst{20-16} = imm;
7140 let hasSideEffects = 0;
7143 // TableGen doesn't like patters w/ INSERT_SUBREG on the instructions
7144 // themselves, so put them here instead.
7146 // Patterns involving what's effectively an insert high and a normal
7147 // intrinsic, represented by CONCAT_VECTORS.
7148 def : Pat<(concat_vectors (v8i8 V64:$Rd),(OpNode (v8i16 V128:$Rn),
7149 vecshiftR16Narrow:$imm)),
7150 (!cast<Instruction>(NAME # "v16i8_shift")
7151 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7152 V128:$Rn, vecshiftR16Narrow:$imm)>;
7153 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn),
7154 vecshiftR32Narrow:$imm)),
7155 (!cast<Instruction>(NAME # "v8i16_shift")
7156 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7157 V128:$Rn, vecshiftR32Narrow:$imm)>;
7158 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn),
7159 vecshiftR64Narrow:$imm)),
7160 (!cast<Instruction>(NAME # "v4i32_shift")
7161 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7162 V128:$Rn, vecshiftR64Narrow:$imm)>;
7165 multiclass SIMDVectorLShiftBHSD<bit U, bits<5> opc, string asm,
7166 SDPatternOperator OpNode> {
7167 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7168 V64, V64, vecshiftL8,
7170 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
7171 (i32 vecshiftL8:$imm)))]> {
7173 let Inst{18-16} = imm;
7176 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7177 V128, V128, vecshiftL8,
7178 asm, ".16b", ".16b",
7179 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
7180 (i32 vecshiftL8:$imm)))]> {
7182 let Inst{18-16} = imm;
7185 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7186 V64, V64, vecshiftL16,
7188 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
7189 (i32 vecshiftL16:$imm)))]> {
7191 let Inst{19-16} = imm;
7194 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7195 V128, V128, vecshiftL16,
7197 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
7198 (i32 vecshiftL16:$imm)))]> {
7200 let Inst{19-16} = imm;
7203 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7204 V64, V64, vecshiftL32,
7206 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
7207 (i32 vecshiftL32:$imm)))]> {
7209 let Inst{20-16} = imm;
7212 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7213 V128, V128, vecshiftL32,
7215 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
7216 (i32 vecshiftL32:$imm)))]> {
7218 let Inst{20-16} = imm;
7221 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7222 V128, V128, vecshiftL64,
7224 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
7225 (i32 vecshiftL64:$imm)))]> {
7227 let Inst{21-16} = imm;
7231 multiclass SIMDVectorRShiftBHSD<bit U, bits<5> opc, string asm,
7232 SDPatternOperator OpNode> {
7233 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7234 V64, V64, vecshiftR8,
7236 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
7237 (i32 vecshiftR8:$imm)))]> {
7239 let Inst{18-16} = imm;
7242 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7243 V128, V128, vecshiftR8,
7244 asm, ".16b", ".16b",
7245 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
7246 (i32 vecshiftR8:$imm)))]> {
7248 let Inst{18-16} = imm;
7251 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7252 V64, V64, vecshiftR16,
7254 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
7255 (i32 vecshiftR16:$imm)))]> {
7257 let Inst{19-16} = imm;
7260 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7261 V128, V128, vecshiftR16,
7263 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
7264 (i32 vecshiftR16:$imm)))]> {
7266 let Inst{19-16} = imm;
7269 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7270 V64, V64, vecshiftR32,
7272 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
7273 (i32 vecshiftR32:$imm)))]> {
7275 let Inst{20-16} = imm;
7278 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7279 V128, V128, vecshiftR32,
7281 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
7282 (i32 vecshiftR32:$imm)))]> {
7284 let Inst{20-16} = imm;
7287 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7288 V128, V128, vecshiftR64,
7290 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
7291 (i32 vecshiftR64:$imm)))]> {
7293 let Inst{21-16} = imm;
7297 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
7298 multiclass SIMDVectorRShiftBHSDTied<bit U, bits<5> opc, string asm,
7299 SDPatternOperator OpNode = null_frag> {
7300 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
7301 V64, V64, vecshiftR8, asm, ".8b", ".8b",
7302 [(set (v8i8 V64:$dst),
7303 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
7304 (i32 vecshiftR8:$imm)))]> {
7306 let Inst{18-16} = imm;
7309 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7310 V128, V128, vecshiftR8, asm, ".16b", ".16b",
7311 [(set (v16i8 V128:$dst),
7312 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
7313 (i32 vecshiftR8:$imm)))]> {
7315 let Inst{18-16} = imm;
7318 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
7319 V64, V64, vecshiftR16, asm, ".4h", ".4h",
7320 [(set (v4i16 V64:$dst),
7321 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
7322 (i32 vecshiftR16:$imm)))]> {
7324 let Inst{19-16} = imm;
7327 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7328 V128, V128, vecshiftR16, asm, ".8h", ".8h",
7329 [(set (v8i16 V128:$dst),
7330 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7331 (i32 vecshiftR16:$imm)))]> {
7333 let Inst{19-16} = imm;
7336 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
7337 V64, V64, vecshiftR32, asm, ".2s", ".2s",
7338 [(set (v2i32 V64:$dst),
7339 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7340 (i32 vecshiftR32:$imm)))]> {
7342 let Inst{20-16} = imm;
7345 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7346 V128, V128, vecshiftR32, asm, ".4s", ".4s",
7347 [(set (v4i32 V128:$dst),
7348 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7349 (i32 vecshiftR32:$imm)))]> {
7351 let Inst{20-16} = imm;
7354 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
7355 V128, V128, vecshiftR64,
7356 asm, ".2d", ".2d", [(set (v2i64 V128:$dst),
7357 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
7358 (i32 vecshiftR64:$imm)))]> {
7360 let Inst{21-16} = imm;
7364 multiclass SIMDVectorLShiftBHSDTied<bit U, bits<5> opc, string asm,
7365 SDPatternOperator OpNode = null_frag> {
7366 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
7367 V64, V64, vecshiftL8,
7369 [(set (v8i8 V64:$dst),
7370 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
7371 (i32 vecshiftL8:$imm)))]> {
7373 let Inst{18-16} = imm;
7376 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7377 V128, V128, vecshiftL8,
7378 asm, ".16b", ".16b",
7379 [(set (v16i8 V128:$dst),
7380 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
7381 (i32 vecshiftL8:$imm)))]> {
7383 let Inst{18-16} = imm;
7386 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
7387 V64, V64, vecshiftL16,
7389 [(set (v4i16 V64:$dst),
7390 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
7391 (i32 vecshiftL16:$imm)))]> {
7393 let Inst{19-16} = imm;
7396 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7397 V128, V128, vecshiftL16,
7399 [(set (v8i16 V128:$dst),
7400 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7401 (i32 vecshiftL16:$imm)))]> {
7403 let Inst{19-16} = imm;
7406 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
7407 V64, V64, vecshiftL32,
7409 [(set (v2i32 V64:$dst),
7410 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7411 (i32 vecshiftL32:$imm)))]> {
7413 let Inst{20-16} = imm;
7416 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7417 V128, V128, vecshiftL32,
7419 [(set (v4i32 V128:$dst),
7420 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7421 (i32 vecshiftL32:$imm)))]> {
7423 let Inst{20-16} = imm;
7426 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
7427 V128, V128, vecshiftL64,
7429 [(set (v2i64 V128:$dst),
7430 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
7431 (i32 vecshiftL64:$imm)))]> {
7433 let Inst{21-16} = imm;
7437 multiclass SIMDVectorLShiftLongBHSD<bit U, bits<5> opc, string asm,
7438 SDPatternOperator OpNode> {
7439 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7440 V128, V64, vecshiftL8, asm, ".8h", ".8b",
7441 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), vecshiftL8:$imm))]> {
7443 let Inst{18-16} = imm;
7446 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7447 V128, V128, vecshiftL8,
7448 asm#"2", ".8h", ".16b",
7449 [(set (v8i16 V128:$Rd),
7450 (OpNode (extract_high_v16i8 V128:$Rn), vecshiftL8:$imm))]> {
7452 let Inst{18-16} = imm;
7455 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7456 V128, V64, vecshiftL16, asm, ".4s", ".4h",
7457 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), vecshiftL16:$imm))]> {
7459 let Inst{19-16} = imm;
7462 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7463 V128, V128, vecshiftL16,
7464 asm#"2", ".4s", ".8h",
7465 [(set (v4i32 V128:$Rd),
7466 (OpNode (extract_high_v8i16 V128:$Rn), vecshiftL16:$imm))]> {
7469 let Inst{19-16} = imm;
7472 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7473 V128, V64, vecshiftL32, asm, ".2d", ".2s",
7474 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), vecshiftL32:$imm))]> {
7476 let Inst{20-16} = imm;
7479 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7480 V128, V128, vecshiftL32,
7481 asm#"2", ".2d", ".4s",
7482 [(set (v2i64 V128:$Rd),
7483 (OpNode (extract_high_v4i32 V128:$Rn), vecshiftL32:$imm))]> {
7485 let Inst{20-16} = imm;
7491 // Vector load/store
7493 // SIMD ldX/stX no-index memory references don't allow the optional
7494 // ", #0" constant and handle post-indexing explicitly, so we use
7495 // a more specialized parse method for them. Otherwise, it's the same as
7496 // the general am_noindex handling.
7498 class BaseSIMDLdSt<bit Q, bit L, bits<4> opcode, bits<2> size,
7499 string asm, dag oops, dag iops, list<dag> pattern>
7500 : I<oops, iops, asm, "\t$Vt, $vaddr", "", pattern> {
7505 let Inst{29-23} = 0b0011000;
7507 let Inst{21-16} = 0b000000;
7508 let Inst{15-12} = opcode;
7509 let Inst{11-10} = size;
7510 let Inst{9-5} = vaddr;
7514 class BaseSIMDLdStPost<bit Q, bit L, bits<4> opcode, bits<2> size,
7515 string asm, dag oops, dag iops>
7516 : I<oops, iops, asm, "\t$Vt, $vaddr, $Xm", "$vaddr = $wback", []> {
7522 let Inst{29-23} = 0b0011001;
7525 let Inst{20-16} = Xm;
7526 let Inst{15-12} = opcode;
7527 let Inst{11-10} = size;
7528 let Inst{9-5} = vaddr;
7532 // The immediate form of AdvSIMD post-indexed addressing is encoded with
7533 // register post-index addressing from the zero register.
7534 multiclass SIMDLdStAliases<string asm, string layout, string Count,
7535 int Offset, int Size> {
7536 // E.g. "ld1 { v0.8b, v1.8b }, [x1], #16"
7537 // "ld1\t$Vt, $vaddr, #16"
7538 // may get mapped to
7539 // (LD1Twov8b_POST VecListTwo8b:$Vt, am_simdnoindex:$vaddr, XZR)
7540 def : InstAlias<asm # "\t$Vt, $vaddr, #" # Offset,
7541 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7542 am_simdnoindex:$vaddr,
7543 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
7546 // E.g. "ld1.8b { v0, v1 }, [x1], #16"
7547 // "ld1.8b\t$Vt, $vaddr, #16"
7548 // may get mapped to
7549 // (LD1Twov8b_POST VecListTwo64:$Vt, am_simdnoindex:$vaddr, XZR)
7550 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, #" # Offset,
7551 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7552 am_simdnoindex:$vaddr,
7553 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7556 // E.g. "ld1.8b { v0, v1 }, [x1]"
7557 // "ld1\t$Vt, $vaddr"
7558 // may get mapped to
7559 // (LD1Twov8b VecListTwo64:$Vt, am_simdnoindex:$vaddr)
7560 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr",
7561 (!cast<Instruction>(NAME # Count # "v" # layout)
7562 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7563 am_simdnoindex:$vaddr), 0>;
7565 // E.g. "ld1.8b { v0, v1 }, [x1], x2"
7566 // "ld1\t$Vt, $vaddr, $Xm"
7567 // may get mapped to
7568 // (LD1Twov8b_POST VecListTwo64:$Vt, am_simdnoindex:$vaddr, GPR64pi8:$Xm)
7569 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, $Xm",
7570 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7571 am_simdnoindex:$vaddr,
7572 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7573 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
7576 multiclass BaseSIMDLdN<string Count, string asm, string veclist, int Offset128,
7577 int Offset64, bits<4> opcode> {
7578 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
7579 def v16b: BaseSIMDLdSt<1, 1, opcode, 0b00, asm,
7580 (outs !cast<RegisterOperand>(veclist # "16b"):$Vt),
7581 (ins am_simdnoindex:$vaddr), []>;
7582 def v8h : BaseSIMDLdSt<1, 1, opcode, 0b01, asm,
7583 (outs !cast<RegisterOperand>(veclist # "8h"):$Vt),
7584 (ins am_simdnoindex:$vaddr), []>;
7585 def v4s : BaseSIMDLdSt<1, 1, opcode, 0b10, asm,
7586 (outs !cast<RegisterOperand>(veclist # "4s"):$Vt),
7587 (ins am_simdnoindex:$vaddr), []>;
7588 def v2d : BaseSIMDLdSt<1, 1, opcode, 0b11, asm,
7589 (outs !cast<RegisterOperand>(veclist # "2d"):$Vt),
7590 (ins am_simdnoindex:$vaddr), []>;
7591 def v8b : BaseSIMDLdSt<0, 1, opcode, 0b00, asm,
7592 (outs !cast<RegisterOperand>(veclist # "8b"):$Vt),
7593 (ins am_simdnoindex:$vaddr), []>;
7594 def v4h : BaseSIMDLdSt<0, 1, opcode, 0b01, asm,
7595 (outs !cast<RegisterOperand>(veclist # "4h"):$Vt),
7596 (ins am_simdnoindex:$vaddr), []>;
7597 def v2s : BaseSIMDLdSt<0, 1, opcode, 0b10, asm,
7598 (outs !cast<RegisterOperand>(veclist # "2s"):$Vt),
7599 (ins am_simdnoindex:$vaddr), []>;
7602 def v16b_POST: BaseSIMDLdStPost<1, 1, opcode, 0b00, asm,
7603 (outs am_simdnoindex:$wback,
7604 !cast<RegisterOperand>(veclist # "16b"):$Vt),
7605 (ins am_simdnoindex:$vaddr,
7606 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7607 def v8h_POST : BaseSIMDLdStPost<1, 1, opcode, 0b01, asm,
7608 (outs am_simdnoindex:$wback,
7609 !cast<RegisterOperand>(veclist # "8h"):$Vt),
7610 (ins am_simdnoindex:$vaddr,
7611 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7612 def v4s_POST : BaseSIMDLdStPost<1, 1, opcode, 0b10, asm,
7613 (outs am_simdnoindex:$wback,
7614 !cast<RegisterOperand>(veclist # "4s"):$Vt),
7615 (ins am_simdnoindex:$vaddr,
7616 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7617 def v2d_POST : BaseSIMDLdStPost<1, 1, opcode, 0b11, asm,
7618 (outs am_simdnoindex:$wback,
7619 !cast<RegisterOperand>(veclist # "2d"):$Vt),
7620 (ins am_simdnoindex:$vaddr,
7621 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7622 def v8b_POST : BaseSIMDLdStPost<0, 1, opcode, 0b00, asm,
7623 (outs am_simdnoindex:$wback,
7624 !cast<RegisterOperand>(veclist # "8b"):$Vt),
7625 (ins am_simdnoindex:$vaddr,
7626 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7627 def v4h_POST : BaseSIMDLdStPost<0, 1, opcode, 0b01, asm,
7628 (outs am_simdnoindex:$wback,
7629 !cast<RegisterOperand>(veclist # "4h"):$Vt),
7630 (ins am_simdnoindex:$vaddr,
7631 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7632 def v2s_POST : BaseSIMDLdStPost<0, 1, opcode, 0b10, asm,
7633 (outs am_simdnoindex:$wback,
7634 !cast<RegisterOperand>(veclist # "2s"):$Vt),
7635 (ins am_simdnoindex:$vaddr,
7636 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7639 defm : SIMDLdStAliases<asm, "16b", Count, Offset128, 128>;
7640 defm : SIMDLdStAliases<asm, "8h", Count, Offset128, 128>;
7641 defm : SIMDLdStAliases<asm, "4s", Count, Offset128, 128>;
7642 defm : SIMDLdStAliases<asm, "2d", Count, Offset128, 128>;
7643 defm : SIMDLdStAliases<asm, "8b", Count, Offset64, 64>;
7644 defm : SIMDLdStAliases<asm, "4h", Count, Offset64, 64>;
7645 defm : SIMDLdStAliases<asm, "2s", Count, Offset64, 64>;
7648 // Only ld1/st1 has a v1d version.
7649 multiclass BaseSIMDStN<string Count, string asm, string veclist, int Offset128,
7650 int Offset64, bits<4> opcode> {
7651 let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in {
7652 def v16b : BaseSIMDLdSt<1, 0, opcode, 0b00, asm, (outs),
7653 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
7654 am_simdnoindex:$vaddr), []>;
7655 def v8h : BaseSIMDLdSt<1, 0, opcode, 0b01, asm, (outs),
7656 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
7657 am_simdnoindex:$vaddr), []>;
7658 def v4s : BaseSIMDLdSt<1, 0, opcode, 0b10, asm, (outs),
7659 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
7660 am_simdnoindex:$vaddr), []>;
7661 def v2d : BaseSIMDLdSt<1, 0, opcode, 0b11, asm, (outs),
7662 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
7663 am_simdnoindex:$vaddr), []>;
7664 def v8b : BaseSIMDLdSt<0, 0, opcode, 0b00, asm, (outs),
7665 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
7666 am_simdnoindex:$vaddr), []>;
7667 def v4h : BaseSIMDLdSt<0, 0, opcode, 0b01, asm, (outs),
7668 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
7669 am_simdnoindex:$vaddr), []>;
7670 def v2s : BaseSIMDLdSt<0, 0, opcode, 0b10, asm, (outs),
7671 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
7672 am_simdnoindex:$vaddr), []>;
7674 def v16b_POST : BaseSIMDLdStPost<1, 0, opcode, 0b00, asm,
7675 (outs am_simdnoindex:$wback),
7676 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
7677 am_simdnoindex:$vaddr,
7678 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7679 def v8h_POST : BaseSIMDLdStPost<1, 0, opcode, 0b01, asm,
7680 (outs am_simdnoindex:$wback),
7681 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
7682 am_simdnoindex:$vaddr,
7683 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7684 def v4s_POST : BaseSIMDLdStPost<1, 0, opcode, 0b10, asm,
7685 (outs am_simdnoindex:$wback),
7686 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
7687 am_simdnoindex:$vaddr,
7688 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7689 def v2d_POST : BaseSIMDLdStPost<1, 0, opcode, 0b11, asm,
7690 (outs am_simdnoindex:$wback),
7691 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
7692 am_simdnoindex:$vaddr,
7693 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7694 def v8b_POST : BaseSIMDLdStPost<0, 0, opcode, 0b00, asm,
7695 (outs am_simdnoindex:$wback),
7696 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
7697 am_simdnoindex:$vaddr,
7698 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7699 def v4h_POST : BaseSIMDLdStPost<0, 0, opcode, 0b01, asm,
7700 (outs am_simdnoindex:$wback),
7701 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
7702 am_simdnoindex:$vaddr,
7703 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7704 def v2s_POST : BaseSIMDLdStPost<0, 0, opcode, 0b10, asm,
7705 (outs am_simdnoindex:$wback),
7706 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
7707 am_simdnoindex:$vaddr,
7708 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7711 defm : SIMDLdStAliases<asm, "16b", Count, Offset128, 128>;
7712 defm : SIMDLdStAliases<asm, "8h", Count, Offset128, 128>;
7713 defm : SIMDLdStAliases<asm, "4s", Count, Offset128, 128>;
7714 defm : SIMDLdStAliases<asm, "2d", Count, Offset128, 128>;
7715 defm : SIMDLdStAliases<asm, "8b", Count, Offset64, 64>;
7716 defm : SIMDLdStAliases<asm, "4h", Count, Offset64, 64>;
7717 defm : SIMDLdStAliases<asm, "2s", Count, Offset64, 64>;
7720 multiclass BaseSIMDLd1<string Count, string asm, string veclist,
7721 int Offset128, int Offset64, bits<4> opcode>
7722 : BaseSIMDLdN<Count, asm, veclist, Offset128, Offset64, opcode> {
7724 // LD1 instructions have extra "1d" variants.
7725 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
7726 def v1d : BaseSIMDLdSt<0, 1, opcode, 0b11, asm,
7727 (outs !cast<RegisterOperand>(veclist # "1d"):$Vt),
7728 (ins am_simdnoindex:$vaddr), []>;
7730 def v1d_POST : BaseSIMDLdStPost<0, 1, opcode, 0b11, asm,
7731 (outs am_simdnoindex:$wback,
7732 !cast<RegisterOperand>(veclist # "1d"):$Vt),
7733 (ins am_simdnoindex:$vaddr,
7734 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7737 defm : SIMDLdStAliases<asm, "1d", Count, Offset64, 64>;
7740 multiclass BaseSIMDSt1<string Count, string asm, string veclist,
7741 int Offset128, int Offset64, bits<4> opcode>
7742 : BaseSIMDStN<Count, asm, veclist, Offset128, Offset64, opcode> {
7744 // ST1 instructions have extra "1d" variants.
7745 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
7746 def v1d : BaseSIMDLdSt<0, 0, opcode, 0b11, asm, (outs),
7747 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
7748 am_simdnoindex:$vaddr), []>;
7750 def v1d_POST : BaseSIMDLdStPost<0, 0, opcode, 0b11, asm,
7751 (outs am_simdnoindex:$wback),
7752 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
7753 am_simdnoindex:$vaddr,
7754 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7757 defm : SIMDLdStAliases<asm, "1d", Count, Offset64, 64>;
7760 multiclass SIMDLd1Multiple<string asm> {
7761 defm One : BaseSIMDLd1<"One", asm, "VecListOne", 16, 8, 0b0111>;
7762 defm Two : BaseSIMDLd1<"Two", asm, "VecListTwo", 32, 16, 0b1010>;
7763 defm Three : BaseSIMDLd1<"Three", asm, "VecListThree", 48, 24, 0b0110>;
7764 defm Four : BaseSIMDLd1<"Four", asm, "VecListFour", 64, 32, 0b0010>;
7767 multiclass SIMDSt1Multiple<string asm> {
7768 defm One : BaseSIMDSt1<"One", asm, "VecListOne", 16, 8, 0b0111>;
7769 defm Two : BaseSIMDSt1<"Two", asm, "VecListTwo", 32, 16, 0b1010>;
7770 defm Three : BaseSIMDSt1<"Three", asm, "VecListThree", 48, 24, 0b0110>;
7771 defm Four : BaseSIMDSt1<"Four", asm, "VecListFour", 64, 32, 0b0010>;
7774 multiclass SIMDLd2Multiple<string asm> {
7775 defm Two : BaseSIMDLdN<"Two", asm, "VecListTwo", 32, 16, 0b1000>;
7778 multiclass SIMDSt2Multiple<string asm> {
7779 defm Two : BaseSIMDStN<"Two", asm, "VecListTwo", 32, 16, 0b1000>;
7782 multiclass SIMDLd3Multiple<string asm> {
7783 defm Three : BaseSIMDLdN<"Three", asm, "VecListThree", 48, 24, 0b0100>;
7786 multiclass SIMDSt3Multiple<string asm> {
7787 defm Three : BaseSIMDStN<"Three", asm, "VecListThree", 48, 24, 0b0100>;
7790 multiclass SIMDLd4Multiple<string asm> {
7791 defm Four : BaseSIMDLdN<"Four", asm, "VecListFour", 64, 32, 0b0000>;
7794 multiclass SIMDSt4Multiple<string asm> {
7795 defm Four : BaseSIMDStN<"Four", asm, "VecListFour", 64, 32, 0b0000>;
7799 // AdvSIMD Load/store single-element
7802 class BaseSIMDLdStSingle<bit L, bit R, bits<3> opcode,
7803 string asm, string operands, string cst,
7804 dag oops, dag iops, list<dag> pattern>
7805 : I<oops, iops, asm, operands, cst, pattern> {
7809 let Inst{29-24} = 0b001101;
7812 let Inst{15-13} = opcode;
7813 let Inst{9-5} = vaddr;
7817 class BaseSIMDLdStSingleTied<bit L, bit R, bits<3> opcode,
7818 string asm, string operands, string cst,
7819 dag oops, dag iops, list<dag> pattern>
7820 : I<oops, iops, asm, operands, "$Vt = $dst," # cst, pattern> {
7824 let Inst{29-24} = 0b001101;
7827 let Inst{15-13} = opcode;
7828 let Inst{9-5} = vaddr;
7833 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
7834 class BaseSIMDLdR<bit Q, bit R, bits<3> opcode, bit S, bits<2> size, string asm,
7836 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, $vaddr", "",
7837 (outs listtype:$Vt), (ins am_simdnoindex:$vaddr),
7841 let Inst{20-16} = 0b00000;
7843 let Inst{11-10} = size;
7845 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
7846 class BaseSIMDLdRPost<bit Q, bit R, bits<3> opcode, bit S, bits<2> size,
7847 string asm, Operand listtype, Operand GPR64pi>
7848 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, $vaddr, $Xm",
7850 (outs am_simdnoindex:$wback, listtype:$Vt),
7851 (ins am_simdnoindex:$vaddr, GPR64pi:$Xm), []> {
7855 let Inst{20-16} = Xm;
7857 let Inst{11-10} = size;
7860 multiclass SIMDLdrAliases<string asm, string layout, string Count,
7861 int Offset, int Size> {
7862 // E.g. "ld1r { v0.8b }, [x1], #1"
7863 // "ld1r.8b\t$Vt, $vaddr, #1"
7864 // may get mapped to
7865 // (LD1Rv8b_POST VecListOne8b:$Vt, am_simdnoindex:$vaddr, XZR)
7866 def : InstAlias<asm # "\t$Vt, $vaddr, #" # Offset,
7867 (!cast<Instruction>(NAME # "v" # layout # "_POST")
7868 am_simdnoindex:$vaddr,
7869 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
7872 // E.g. "ld1r.8b { v0 }, [x1], #1"
7873 // "ld1r.8b\t$Vt, $vaddr, #1"
7874 // may get mapped to
7875 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, XZR)
7876 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, #" # Offset,
7877 (!cast<Instruction>(NAME # "v" # layout # "_POST")
7878 am_simdnoindex:$vaddr,
7879 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7882 // E.g. "ld1r.8b { v0 }, [x1]"
7883 // "ld1r.8b\t$Vt, $vaddr"
7884 // may get mapped to
7885 // (LD1Rv8b VecListOne64:$Vt, am_simdnoindex:$vaddr)
7886 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr",
7887 (!cast<Instruction>(NAME # "v" # layout)
7888 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7889 am_simdnoindex:$vaddr), 0>;
7891 // E.g. "ld1r.8b { v0 }, [x1], x2"
7892 // "ld1r.8b\t$Vt, $vaddr, $Xm"
7893 // may get mapped to
7894 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, GPR64pi1:$Xm)
7895 def : InstAlias<asm # "." # layout # "\t$Vt, $vaddr, $Xm",
7896 (!cast<Instruction>(NAME # "v" # layout # "_POST")
7897 am_simdnoindex:$vaddr,
7898 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7899 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
7902 multiclass SIMDLdR<bit R, bits<3> opcode, bit S, string asm, string Count,
7903 int Offset1, int Offset2, int Offset4, int Offset8> {
7904 def v8b : BaseSIMDLdR<0, R, opcode, S, 0b00, asm,
7905 !cast<Operand>("VecList" # Count # "8b")>;
7906 def v16b: BaseSIMDLdR<1, R, opcode, S, 0b00, asm,
7907 !cast<Operand>("VecList" # Count #"16b")>;
7908 def v4h : BaseSIMDLdR<0, R, opcode, S, 0b01, asm,
7909 !cast<Operand>("VecList" # Count #"4h")>;
7910 def v8h : BaseSIMDLdR<1, R, opcode, S, 0b01, asm,
7911 !cast<Operand>("VecList" # Count #"8h")>;
7912 def v2s : BaseSIMDLdR<0, R, opcode, S, 0b10, asm,
7913 !cast<Operand>("VecList" # Count #"2s")>;
7914 def v4s : BaseSIMDLdR<1, R, opcode, S, 0b10, asm,
7915 !cast<Operand>("VecList" # Count #"4s")>;
7916 def v1d : BaseSIMDLdR<0, R, opcode, S, 0b11, asm,
7917 !cast<Operand>("VecList" # Count #"1d")>;
7918 def v2d : BaseSIMDLdR<1, R, opcode, S, 0b11, asm,
7919 !cast<Operand>("VecList" # Count #"2d")>;
7921 def v8b_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b00, asm,
7922 !cast<Operand>("VecList" # Count # "8b"),
7923 !cast<Operand>("GPR64pi" # Offset1)>;
7924 def v16b_POST: BaseSIMDLdRPost<1, R, opcode, S, 0b00, asm,
7925 !cast<Operand>("VecList" # Count # "16b"),
7926 !cast<Operand>("GPR64pi" # Offset1)>;
7927 def v4h_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b01, asm,
7928 !cast<Operand>("VecList" # Count # "4h"),
7929 !cast<Operand>("GPR64pi" # Offset2)>;
7930 def v8h_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b01, asm,
7931 !cast<Operand>("VecList" # Count # "8h"),
7932 !cast<Operand>("GPR64pi" # Offset2)>;
7933 def v2s_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b10, asm,
7934 !cast<Operand>("VecList" # Count # "2s"),
7935 !cast<Operand>("GPR64pi" # Offset4)>;
7936 def v4s_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b10, asm,
7937 !cast<Operand>("VecList" # Count # "4s"),
7938 !cast<Operand>("GPR64pi" # Offset4)>;
7939 def v1d_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b11, asm,
7940 !cast<Operand>("VecList" # Count # "1d"),
7941 !cast<Operand>("GPR64pi" # Offset8)>;
7942 def v2d_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b11, asm,
7943 !cast<Operand>("VecList" # Count # "2d"),
7944 !cast<Operand>("GPR64pi" # Offset8)>;
7946 defm : SIMDLdrAliases<asm, "8b", Count, Offset1, 64>;
7947 defm : SIMDLdrAliases<asm, "16b", Count, Offset1, 128>;
7948 defm : SIMDLdrAliases<asm, "4h", Count, Offset2, 64>;
7949 defm : SIMDLdrAliases<asm, "8h", Count, Offset2, 128>;
7950 defm : SIMDLdrAliases<asm, "2s", Count, Offset4, 64>;
7951 defm : SIMDLdrAliases<asm, "4s", Count, Offset4, 128>;
7952 defm : SIMDLdrAliases<asm, "1d", Count, Offset8, 64>;
7953 defm : SIMDLdrAliases<asm, "2d", Count, Offset8, 128>;
7956 class SIMDLdStSingleB<bit L, bit R, bits<3> opcode, string asm,
7957 dag oops, dag iops, list<dag> pattern>
7958 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
7960 // idx encoded in Q:S:size fields.
7962 let Inst{30} = idx{3};
7964 let Inst{20-16} = 0b00000;
7965 let Inst{12} = idx{2};
7966 let Inst{11-10} = idx{1-0};
7968 class SIMDLdStSingleBTied<bit L, bit R, bits<3> opcode, string asm,
7969 dag oops, dag iops, list<dag> pattern>
7970 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
7971 oops, iops, pattern> {
7972 // idx encoded in Q:S:size fields.
7974 let Inst{30} = idx{3};
7976 let Inst{20-16} = 0b00000;
7977 let Inst{12} = idx{2};
7978 let Inst{11-10} = idx{1-0};
7980 class SIMDLdStSingleBPost<bit L, bit R, bits<3> opcode, string asm,
7982 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
7983 "$vaddr = $wback", oops, iops, []> {
7984 // idx encoded in Q:S:size fields.
7987 let Inst{30} = idx{3};
7989 let Inst{20-16} = Xm;
7990 let Inst{12} = idx{2};
7991 let Inst{11-10} = idx{1-0};
7993 class SIMDLdStSingleBTiedPost<bit L, bit R, bits<3> opcode, string asm,
7995 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
7996 "$vaddr = $wback", oops, iops, []> {
7997 // idx encoded in Q:S:size fields.
8000 let Inst{30} = idx{3};
8002 let Inst{20-16} = Xm;
8003 let Inst{12} = idx{2};
8004 let Inst{11-10} = idx{1-0};
8007 class SIMDLdStSingleH<bit L, bit R, bits<3> opcode, bit size, string asm,
8008 dag oops, dag iops, list<dag> pattern>
8009 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
8011 // idx encoded in Q:S:size<1> fields.
8013 let Inst{30} = idx{2};
8015 let Inst{20-16} = 0b00000;
8016 let Inst{12} = idx{1};
8017 let Inst{11} = idx{0};
8018 let Inst{10} = size;
8020 class SIMDLdStSingleHTied<bit L, bit R, bits<3> opcode, bit size, string asm,
8021 dag oops, dag iops, list<dag> pattern>
8022 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
8023 oops, iops, pattern> {
8024 // idx encoded in Q:S:size<1> fields.
8026 let Inst{30} = idx{2};
8028 let Inst{20-16} = 0b00000;
8029 let Inst{12} = idx{1};
8030 let Inst{11} = idx{0};
8031 let Inst{10} = size;
8034 class SIMDLdStSingleHPost<bit L, bit R, bits<3> opcode, bit size, string asm,
8036 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8037 "$vaddr = $wback", oops, iops, []> {
8038 // idx encoded in Q:S:size<1> fields.
8041 let Inst{30} = idx{2};
8043 let Inst{20-16} = Xm;
8044 let Inst{12} = idx{1};
8045 let Inst{11} = idx{0};
8046 let Inst{10} = size;
8048 class SIMDLdStSingleHTiedPost<bit L, bit R, bits<3> opcode, bit size, string asm,
8050 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8051 "$vaddr = $wback", oops, iops, []> {
8052 // idx encoded in Q:S:size<1> fields.
8055 let Inst{30} = idx{2};
8057 let Inst{20-16} = Xm;
8058 let Inst{12} = idx{1};
8059 let Inst{11} = idx{0};
8060 let Inst{10} = size;
8062 class SIMDLdStSingleS<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8063 dag oops, dag iops, list<dag> pattern>
8064 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
8066 // idx encoded in Q:S fields.
8068 let Inst{30} = idx{1};
8070 let Inst{20-16} = 0b00000;
8071 let Inst{12} = idx{0};
8072 let Inst{11-10} = size;
8074 class SIMDLdStSingleSTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8075 dag oops, dag iops, list<dag> pattern>
8076 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
8077 oops, iops, pattern> {
8078 // idx encoded in Q:S fields.
8080 let Inst{30} = idx{1};
8082 let Inst{20-16} = 0b00000;
8083 let Inst{12} = idx{0};
8084 let Inst{11-10} = size;
8086 class SIMDLdStSingleSPost<bit L, bit R, bits<3> opcode, bits<2> size,
8087 string asm, dag oops, dag iops>
8088 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8089 "$vaddr = $wback", oops, iops, []> {
8090 // idx encoded in Q:S fields.
8093 let Inst{30} = idx{1};
8095 let Inst{20-16} = Xm;
8096 let Inst{12} = idx{0};
8097 let Inst{11-10} = size;
8099 class SIMDLdStSingleSTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
8100 string asm, dag oops, dag iops>
8101 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8102 "$vaddr = $wback", oops, iops, []> {
8103 // idx encoded in Q:S fields.
8106 let Inst{30} = idx{1};
8108 let Inst{20-16} = Xm;
8109 let Inst{12} = idx{0};
8110 let Inst{11-10} = size;
8112 class SIMDLdStSingleD<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8113 dag oops, dag iops, list<dag> pattern>
8114 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "", oops, iops,
8116 // idx encoded in Q field.
8120 let Inst{20-16} = 0b00000;
8122 let Inst{11-10} = size;
8124 class SIMDLdStSingleDTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8125 dag oops, dag iops, list<dag> pattern>
8126 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr", "",
8127 oops, iops, pattern> {
8128 // idx encoded in Q field.
8132 let Inst{20-16} = 0b00000;
8134 let Inst{11-10} = size;
8136 class SIMDLdStSingleDPost<bit L, bit R, bits<3> opcode, bits<2> size,
8137 string asm, dag oops, dag iops>
8138 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8139 "$vaddr = $wback", oops, iops, []> {
8140 // idx encoded in Q field.
8145 let Inst{20-16} = Xm;
8147 let Inst{11-10} = size;
8149 class SIMDLdStSingleDTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
8150 string asm, dag oops, dag iops>
8151 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, $vaddr, $Xm",
8152 "$vaddr = $wback", oops, iops, []> {
8153 // idx encoded in Q field.
8158 let Inst{20-16} = Xm;
8160 let Inst{11-10} = size;
8163 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8164 multiclass SIMDLdSingleBTied<bit R, bits<3> opcode, string asm,
8165 RegisterOperand listtype,
8166 RegisterOperand GPR64pi> {
8167 def i8 : SIMDLdStSingleBTied<1, R, opcode, asm,
8168 (outs listtype:$dst),
8169 (ins listtype:$Vt, VectorIndexB:$idx,
8170 am_simdnoindex:$vaddr), []>;
8172 def i8_POST : SIMDLdStSingleBTiedPost<1, R, opcode, asm,
8173 (outs am_simdnoindex:$wback, listtype:$dst),
8174 (ins listtype:$Vt, VectorIndexB:$idx,
8175 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8177 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8178 multiclass SIMDLdSingleHTied<bit R, bits<3> opcode, bit size, string asm,
8179 RegisterOperand listtype,
8180 RegisterOperand GPR64pi> {
8181 def i16 : SIMDLdStSingleHTied<1, R, opcode, size, asm,
8182 (outs listtype:$dst),
8183 (ins listtype:$Vt, VectorIndexH:$idx,
8184 am_simdnoindex:$vaddr), []>;
8186 def i16_POST : SIMDLdStSingleHTiedPost<1, R, opcode, size, asm,
8187 (outs am_simdnoindex:$wback, listtype:$dst),
8188 (ins listtype:$Vt, VectorIndexH:$idx,
8189 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8191 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8192 multiclass SIMDLdSingleSTied<bit R, bits<3> opcode, bits<2> size,string asm,
8193 RegisterOperand listtype,
8194 RegisterOperand GPR64pi> {
8195 def i32 : SIMDLdStSingleSTied<1, R, opcode, size, asm,
8196 (outs listtype:$dst),
8197 (ins listtype:$Vt, VectorIndexS:$idx,
8198 am_simdnoindex:$vaddr), []>;
8200 def i32_POST : SIMDLdStSingleSTiedPost<1, R, opcode, size, asm,
8201 (outs am_simdnoindex:$wback, listtype:$dst),
8202 (ins listtype:$Vt, VectorIndexS:$idx,
8203 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8205 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8206 multiclass SIMDLdSingleDTied<bit R, bits<3> opcode, bits<2> size, string asm,
8207 RegisterOperand listtype, RegisterOperand GPR64pi> {
8208 def i64 : SIMDLdStSingleDTied<1, R, opcode, size, asm,
8209 (outs listtype:$dst),
8210 (ins listtype:$Vt, VectorIndexD:$idx,
8211 am_simdnoindex:$vaddr), []>;
8213 def i64_POST : SIMDLdStSingleDTiedPost<1, R, opcode, size, asm,
8214 (outs am_simdnoindex:$wback, listtype:$dst),
8215 (ins listtype:$Vt, VectorIndexD:$idx,
8216 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8218 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8219 multiclass SIMDStSingleB<bit R, bits<3> opcode, string asm,
8220 RegisterOperand listtype, RegisterOperand GPR64pi> {
8221 def i8 : SIMDLdStSingleB<0, R, opcode, asm,
8222 (outs), (ins listtype:$Vt, VectorIndexB:$idx,
8223 am_simdnoindex:$vaddr), []>;
8225 def i8_POST : SIMDLdStSingleBPost<0, R, opcode, asm,
8226 (outs am_simdnoindex:$wback),
8227 (ins listtype:$Vt, VectorIndexB:$idx,
8228 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8230 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8231 multiclass SIMDStSingleH<bit R, bits<3> opcode, bit size, string asm,
8232 RegisterOperand listtype, RegisterOperand GPR64pi> {
8233 def i16 : SIMDLdStSingleH<0, R, opcode, size, asm,
8234 (outs), (ins listtype:$Vt, VectorIndexH:$idx,
8235 am_simdnoindex:$vaddr), []>;
8237 def i16_POST : SIMDLdStSingleHPost<0, R, opcode, size, asm,
8238 (outs am_simdnoindex:$wback),
8239 (ins listtype:$Vt, VectorIndexH:$idx,
8240 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8242 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8243 multiclass SIMDStSingleS<bit R, bits<3> opcode, bits<2> size,string asm,
8244 RegisterOperand listtype, RegisterOperand GPR64pi> {
8245 def i32 : SIMDLdStSingleS<0, R, opcode, size, asm,
8246 (outs), (ins listtype:$Vt, VectorIndexS:$idx,
8247 am_simdnoindex:$vaddr), []>;
8249 def i32_POST : SIMDLdStSingleSPost<0, R, opcode, size, asm,
8250 (outs am_simdnoindex:$wback),
8251 (ins listtype:$Vt, VectorIndexS:$idx,
8252 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8254 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8255 multiclass SIMDStSingleD<bit R, bits<3> opcode, bits<2> size, string asm,
8256 RegisterOperand listtype, RegisterOperand GPR64pi> {
8257 def i64 : SIMDLdStSingleD<0, R, opcode, size, asm,
8258 (outs), (ins listtype:$Vt, VectorIndexD:$idx,
8259 am_simdnoindex:$vaddr), []>;
8261 def i64_POST : SIMDLdStSingleDPost<0, R, opcode, size, asm,
8262 (outs am_simdnoindex:$wback),
8263 (ins listtype:$Vt, VectorIndexD:$idx,
8264 am_simdnoindex:$vaddr, GPR64pi:$Xm)>;
8267 multiclass SIMDLdStSingleAliases<string asm, string layout, string Type,
8268 string Count, int Offset, Operand idxtype> {
8269 // E.g. "ld1 { v0.8b }[0], [x1], #1"
8270 // "ld1\t$Vt, $vaddr, #1"
8271 // may get mapped to
8272 // (LD1Rv8b_POST VecListOne8b:$Vt, am_simdnoindex:$vaddr, XZR)
8273 def : InstAlias<asm # "\t$Vt$idx, $vaddr, #" # Offset,
8274 (!cast<Instruction>(NAME # Type # "_POST")
8275 am_simdnoindex:$vaddr,
8276 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
8277 idxtype:$idx, XZR), 1>;
8279 // E.g. "ld1.8b { v0 }[0], [x1], #1"
8280 // "ld1.8b\t$Vt, $vaddr, #1"
8281 // may get mapped to
8282 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, XZR)
8283 def : InstAlias<asm # "." # layout # "\t$Vt$idx, $vaddr, #" # Offset,
8284 (!cast<Instruction>(NAME # Type # "_POST")
8285 am_simdnoindex:$vaddr,
8286 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8287 idxtype:$idx, XZR), 0>;
8289 // E.g. "ld1.8b { v0 }[0], [x1]"
8290 // "ld1.8b\t$Vt, $vaddr"
8291 // may get mapped to
8292 // (LD1Rv8b VecListOne64:$Vt, am_simdnoindex:$vaddr)
8293 def : InstAlias<asm # "." # layout # "\t$Vt$idx, $vaddr",
8294 (!cast<Instruction>(NAME # Type)
8295 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8296 idxtype:$idx, am_simdnoindex:$vaddr), 0>;
8298 // E.g. "ld1.8b { v0 }[0], [x1], x2"
8299 // "ld1.8b\t$Vt, $vaddr, $Xm"
8300 // may get mapped to
8301 // (LD1Rv8b_POST VecListOne64:$Vt, am_simdnoindex:$vaddr, GPR64pi1:$Xm)
8302 def : InstAlias<asm # "." # layout # "\t$Vt$idx, $vaddr, $Xm",
8303 (!cast<Instruction>(NAME # Type # "_POST")
8304 am_simdnoindex:$vaddr,
8305 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8307 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
8310 multiclass SIMDLdSt1SingleAliases<string asm> {
8311 defm : SIMDLdStSingleAliases<asm, "b", "i8", "One", 1, VectorIndexB>;
8312 defm : SIMDLdStSingleAliases<asm, "h", "i16", "One", 2, VectorIndexH>;
8313 defm : SIMDLdStSingleAliases<asm, "s", "i32", "One", 4, VectorIndexS>;
8314 defm : SIMDLdStSingleAliases<asm, "d", "i64", "One", 8, VectorIndexD>;
8317 multiclass SIMDLdSt2SingleAliases<string asm> {
8318 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Two", 2, VectorIndexB>;
8319 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Two", 4, VectorIndexH>;
8320 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Two", 8, VectorIndexS>;
8321 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Two", 16, VectorIndexD>;
8324 multiclass SIMDLdSt3SingleAliases<string asm> {
8325 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Three", 3, VectorIndexB>;
8326 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Three", 6, VectorIndexH>;
8327 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Three", 12, VectorIndexS>;
8328 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Three", 24, VectorIndexD>;
8331 multiclass SIMDLdSt4SingleAliases<string asm> {
8332 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Four", 4, VectorIndexB>;
8333 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Four", 8, VectorIndexH>;
8334 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Four", 16, VectorIndexS>;
8335 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Four", 32, VectorIndexD>;
8337 } // end of 'let Predicates = [HasNEON]'
8339 //----------------------------------------------------------------------------
8340 // Crypto extensions
8341 //----------------------------------------------------------------------------
8343 let Predicates = [HasCrypto] in {
8344 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8345 class AESBase<bits<4> opc, string asm, dag outs, dag ins, string cstr,
8347 : I<outs, ins, asm, "{\t$Rd.16b, $Rn.16b|.16b\t$Rd, $Rn}", cstr, pat>,
8351 let Inst{31-16} = 0b0100111000101000;
8352 let Inst{15-12} = opc;
8353 let Inst{11-10} = 0b10;
8358 class AESInst<bits<4> opc, string asm, Intrinsic OpNode>
8359 : AESBase<opc, asm, (outs V128:$Rd), (ins V128:$Rn), "",
8360 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
8362 class AESTiedInst<bits<4> opc, string asm, Intrinsic OpNode>
8363 : AESBase<opc, asm, (outs V128:$dst), (ins V128:$Rd, V128:$Rn),
8365 [(set (v16i8 V128:$dst),
8366 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
8368 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8369 class SHA3OpTiedInst<bits<3> opc, string asm, string dst_lhs_kind,
8370 dag oops, dag iops, list<dag> pat>
8371 : I<oops, iops, asm,
8372 "{\t$Rd" # dst_lhs_kind # ", $Rn" # dst_lhs_kind # ", $Rm.4s" #
8373 "|.4s\t$Rd, $Rn, $Rm}", "$Rd = $dst", pat>,
8378 let Inst{31-21} = 0b01011110000;
8379 let Inst{20-16} = Rm;
8381 let Inst{14-12} = opc;
8382 let Inst{11-10} = 0b00;
8387 class SHATiedInstQSV<bits<3> opc, string asm, Intrinsic OpNode>
8388 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
8389 (ins FPR128:$Rd, FPR32:$Rn, V128:$Rm),
8390 [(set (v4i32 FPR128:$dst),
8391 (OpNode (v4i32 FPR128:$Rd), (i32 FPR32:$Rn),
8392 (v4i32 V128:$Rm)))]>;
8394 class SHATiedInstVVV<bits<3> opc, string asm, Intrinsic OpNode>
8395 : SHA3OpTiedInst<opc, asm, ".4s", (outs V128:$dst),
8396 (ins V128:$Rd, V128:$Rn, V128:$Rm),
8397 [(set (v4i32 V128:$dst),
8398 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
8399 (v4i32 V128:$Rm)))]>;
8401 class SHATiedInstQQV<bits<3> opc, string asm, Intrinsic OpNode>
8402 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
8403 (ins FPR128:$Rd, FPR128:$Rn, V128:$Rm),
8404 [(set (v4i32 FPR128:$dst),
8405 (OpNode (v4i32 FPR128:$Rd), (v4i32 FPR128:$Rn),
8406 (v4i32 V128:$Rm)))]>;
8408 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8409 class SHA2OpInst<bits<4> opc, string asm, string kind,
8410 string cstr, dag oops, dag iops,
8412 : I<oops, iops, asm, "{\t$Rd" # kind # ", $Rn" # kind #
8413 "|" # kind # "\t$Rd, $Rn}", cstr, pat>,
8417 let Inst{31-16} = 0b0101111000101000;
8418 let Inst{15-12} = opc;
8419 let Inst{11-10} = 0b10;
8424 class SHATiedInstVV<bits<4> opc, string asm, Intrinsic OpNode>
8425 : SHA2OpInst<opc, asm, ".4s", "$Rd = $dst", (outs V128:$dst),
8426 (ins V128:$Rd, V128:$Rn),
8427 [(set (v4i32 V128:$dst),
8428 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
8430 class SHAInstSS<bits<4> opc, string asm, Intrinsic OpNode>
8431 : SHA2OpInst<opc, asm, "", "", (outs FPR32:$Rd), (ins FPR32:$Rn),
8432 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
8433 } // end of 'let Predicates = [HasCrypto]'
8435 // Allow the size specifier tokens to be upper case, not just lower.
8436 def : TokenAlias<".8B", ".8b">;
8437 def : TokenAlias<".4H", ".4h">;
8438 def : TokenAlias<".2S", ".2s">;
8439 def : TokenAlias<".1D", ".1d">;
8440 def : TokenAlias<".16B", ".16b">;
8441 def : TokenAlias<".8H", ".8h">;
8442 def : TokenAlias<".4S", ".4s">;
8443 def : TokenAlias<".2D", ".2d">;
8444 def : TokenAlias<".1Q", ".1q">;
8445 def : TokenAlias<".B", ".b">;
8446 def : TokenAlias<".H", ".h">;
8447 def : TokenAlias<".S", ".s">;
8448 def : TokenAlias<".D", ".d">;
8449 def : TokenAlias<".Q", ".q">;