1 //===- AArch64InstrFormats.td - AArch64 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 AArch64 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 // AArch64 Instruction Format
25 class AArch64Inst<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 = "AArch64";
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 : AArch64Inst<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> : AArch64Inst<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";
94 let DiagnosticType = "InvalidMovImm32Shift";
96 def MovImm64ShifterOperand : AsmOperandClass {
97 let SuperClasses = [ShifterOperand];
98 let Name = "MovImm64Shifter";
99 let RenderMethod = "addShifterOperands";
100 let DiagnosticType = "InvalidMovImm64Shift";
103 // Shifter operand for arithmetic register shifted encodings.
104 class ArithmeticShifterOperand<int width> : AsmOperandClass {
105 let SuperClasses = [ShifterOperand];
106 let Name = "ArithmeticShifter" # width;
107 let PredicateMethod = "isArithmeticShifter<" # width # ">";
108 let RenderMethod = "addShifterOperands";
109 let DiagnosticType = "AddSubRegShift" # width;
112 def ArithmeticShifterOperand32 : ArithmeticShifterOperand<32>;
113 def ArithmeticShifterOperand64 : ArithmeticShifterOperand<64>;
115 // Shifter operand for logical register shifted encodings.
116 class LogicalShifterOperand<int width> : AsmOperandClass {
117 let SuperClasses = [ShifterOperand];
118 let Name = "LogicalShifter" # width;
119 let PredicateMethod = "isLogicalShifter<" # width # ">";
120 let RenderMethod = "addShifterOperands";
121 let DiagnosticType = "AddSubRegShift" # width;
124 def LogicalShifterOperand32 : LogicalShifterOperand<32>;
125 def LogicalShifterOperand64 : LogicalShifterOperand<64>;
127 // Shifter operand for logical vector 128/64-bit shifted encodings.
128 def LogicalVecShifterOperand : AsmOperandClass {
129 let SuperClasses = [ShifterOperand];
130 let Name = "LogicalVecShifter";
131 let RenderMethod = "addShifterOperands";
133 def LogicalVecHalfWordShifterOperand : AsmOperandClass {
134 let SuperClasses = [LogicalVecShifterOperand];
135 let Name = "LogicalVecHalfWordShifter";
136 let RenderMethod = "addShifterOperands";
139 // The "MSL" shifter on the vector MOVI instruction.
140 def MoveVecShifterOperand : AsmOperandClass {
141 let SuperClasses = [ShifterOperand];
142 let Name = "MoveVecShifter";
143 let RenderMethod = "addShifterOperands";
146 // Extend operand for arithmetic encodings.
147 def ExtendOperand : AsmOperandClass {
149 let DiagnosticType = "AddSubRegExtendLarge";
151 def ExtendOperand64 : AsmOperandClass {
152 let SuperClasses = [ExtendOperand];
153 let Name = "Extend64";
154 let DiagnosticType = "AddSubRegExtendSmall";
156 // 'extend' that's a lsl of a 64-bit register.
157 def ExtendOperandLSL64 : AsmOperandClass {
158 let SuperClasses = [ExtendOperand];
159 let Name = "ExtendLSL64";
160 let RenderMethod = "addExtend64Operands";
161 let DiagnosticType = "AddSubRegExtendLarge";
164 // 8-bit floating-point immediate encodings.
165 def FPImmOperand : AsmOperandClass {
167 let ParserMethod = "tryParseFPImm";
168 let DiagnosticType = "InvalidFPImm";
171 def CondCode : AsmOperandClass {
172 let Name = "CondCode";
173 let DiagnosticType = "InvalidCondCode";
176 // A 32-bit register pasrsed as 64-bit
177 def GPR32as64Operand : AsmOperandClass {
178 let Name = "GPR32as64";
180 def GPR32as64 : RegisterOperand<GPR32> {
181 let ParserMatchClass = GPR32as64Operand;
184 // 8-bit immediate for AdvSIMD where 64-bit values of the form:
185 // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
186 // are encoded as the eight bit value 'abcdefgh'.
187 def SIMDImmType10Operand : AsmOperandClass { let Name = "SIMDImmType10"; }
190 //===----------------------------------------------------------------------===//
191 // Operand Definitions.
194 // ADR[P] instruction labels.
195 def AdrpOperand : AsmOperandClass {
196 let Name = "AdrpLabel";
197 let ParserMethod = "tryParseAdrpLabel";
198 let DiagnosticType = "InvalidLabel";
200 def adrplabel : Operand<i64> {
201 let EncoderMethod = "getAdrLabelOpValue";
202 let PrintMethod = "printAdrpLabel";
203 let ParserMatchClass = AdrpOperand;
206 def AdrOperand : AsmOperandClass {
207 let Name = "AdrLabel";
208 let ParserMethod = "tryParseAdrLabel";
209 let DiagnosticType = "InvalidLabel";
211 def adrlabel : Operand<i64> {
212 let EncoderMethod = "getAdrLabelOpValue";
213 let ParserMatchClass = AdrOperand;
216 // simm9 predicate - True if the immediate is in the range [-256, 255].
217 def SImm9Operand : AsmOperandClass {
219 let DiagnosticType = "InvalidMemoryIndexedSImm9";
221 def simm9 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= -256 && Imm < 256; }]> {
222 let ParserMatchClass = SImm9Operand;
225 // simm7sN predicate - True if the immediate is a multiple of N in the range
226 // [-64 * N, 63 * N].
227 class SImm7Scaled<int Scale> : AsmOperandClass {
228 let Name = "SImm7s" # Scale;
229 let DiagnosticType = "InvalidMemoryIndexed" # Scale # "SImm7";
232 def SImm7s4Operand : SImm7Scaled<4>;
233 def SImm7s8Operand : SImm7Scaled<8>;
234 def SImm7s16Operand : SImm7Scaled<16>;
236 def simm7s4 : Operand<i32> {
237 let ParserMatchClass = SImm7s4Operand;
238 let PrintMethod = "printImmScale<4>";
241 def simm7s8 : Operand<i32> {
242 let ParserMatchClass = SImm7s8Operand;
243 let PrintMethod = "printImmScale<8>";
246 def simm7s16 : Operand<i32> {
247 let ParserMatchClass = SImm7s16Operand;
248 let PrintMethod = "printImmScale<16>";
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 = AArch64_AM::encodeLogicalImmediate(N->getZExtValue(), 32);
444 return CurDAG->getTargetConstant(enc, MVT::i32);
446 def logical_imm64_XFORM : SDNodeXForm<imm, [{
447 uint64_t enc = AArch64_AM::encodeLogicalImmediate(N->getZExtValue(), 64);
448 return CurDAG->getTargetConstant(enc, MVT::i32);
451 let DiagnosticType = "LogicalSecondSource" in {
452 def LogicalImm32Operand : AsmOperandClass {
453 let Name = "LogicalImm32";
455 def LogicalImm64Operand : AsmOperandClass {
456 let Name = "LogicalImm64";
458 def LogicalImm32NotOperand : AsmOperandClass {
459 let Name = "LogicalImm32Not";
461 def LogicalImm64NotOperand : AsmOperandClass {
462 let Name = "LogicalImm64Not";
465 def logical_imm32 : Operand<i32>, PatLeaf<(imm), [{
466 return AArch64_AM::isLogicalImmediate(N->getZExtValue(), 32);
467 }], logical_imm32_XFORM> {
468 let PrintMethod = "printLogicalImm32";
469 let ParserMatchClass = LogicalImm32Operand;
471 def logical_imm64 : Operand<i64>, PatLeaf<(imm), [{
472 return AArch64_AM::isLogicalImmediate(N->getZExtValue(), 64);
473 }], logical_imm64_XFORM> {
474 let PrintMethod = "printLogicalImm64";
475 let ParserMatchClass = LogicalImm64Operand;
477 def logical_imm32_not : Operand<i32> {
478 let ParserMatchClass = LogicalImm32NotOperand;
480 def logical_imm64_not : Operand<i64> {
481 let ParserMatchClass = LogicalImm64NotOperand;
484 // imm0_65535 predicate - True if the immediate is in the range [0,65535].
485 def Imm0_65535Operand : AsmImmRange<0, 65535>;
486 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
487 return ((uint32_t)Imm) < 65536;
489 let ParserMatchClass = Imm0_65535Operand;
490 let PrintMethod = "printHexImm";
493 // imm0_255 predicate - True if the immediate is in the range [0,255].
494 def Imm0_255Operand : AsmOperandClass { let Name = "Imm0_255"; }
495 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{
496 return ((uint32_t)Imm) < 256;
498 let ParserMatchClass = Imm0_255Operand;
499 let PrintMethod = "printHexImm";
502 // imm0_127 predicate - True if the immediate is in the range [0,127]
503 def Imm0_127Operand : AsmImmRange<0, 127>;
504 def imm0_127 : Operand<i32>, ImmLeaf<i32, [{
505 return ((uint32_t)Imm) < 128;
507 let ParserMatchClass = Imm0_127Operand;
508 let PrintMethod = "printHexImm";
511 // NOTE: These imm0_N operands have to be of type i64 because i64 is the size
512 // for all shift-amounts.
514 // imm0_63 predicate - True if the immediate is in the range [0,63]
515 def imm0_63 : Operand<i64>, ImmLeaf<i64, [{
516 return ((uint64_t)Imm) < 64;
518 let ParserMatchClass = Imm0_63Operand;
521 // imm0_31 predicate - True if the immediate is in the range [0,31]
522 def imm0_31 : Operand<i64>, ImmLeaf<i64, [{
523 return ((uint64_t)Imm) < 32;
525 let ParserMatchClass = Imm0_31Operand;
528 // imm0_15 predicate - True if the immediate is in the range [0,15]
529 def imm0_15 : Operand<i64>, ImmLeaf<i64, [{
530 return ((uint64_t)Imm) < 16;
532 let ParserMatchClass = Imm0_15Operand;
535 // imm0_7 predicate - True if the immediate is in the range [0,7]
536 def imm0_7 : Operand<i64>, ImmLeaf<i64, [{
537 return ((uint64_t)Imm) < 8;
539 let ParserMatchClass = Imm0_7Operand;
542 // imm32_0_15 predicate - True if the 32-bit immediate is in the range [0,15]
543 def imm32_0_15 : Operand<i32>, ImmLeaf<i32, [{
544 return ((uint32_t)Imm) < 16;
547 // An arithmetic shifter operand:
548 // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr
550 class arith_shift<ValueType Ty, int width> : Operand<Ty> {
551 let PrintMethod = "printShifter";
552 let ParserMatchClass = !cast<AsmOperandClass>(
553 "ArithmeticShifterOperand" # width);
556 def arith_shift32 : arith_shift<i32, 32>;
557 def arith_shift64 : arith_shift<i64, 64>;
559 class arith_shifted_reg<ValueType Ty, RegisterClass regclass, int width>
561 ComplexPattern<Ty, 2, "SelectArithShiftedRegister", []> {
562 let PrintMethod = "printShiftedRegister";
563 let MIOperandInfo = (ops regclass, !cast<Operand>("arith_shift" # width));
566 def arith_shifted_reg32 : arith_shifted_reg<i32, GPR32, 32>;
567 def arith_shifted_reg64 : arith_shifted_reg<i64, GPR64, 64>;
569 // An arithmetic shifter operand:
570 // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr, 11 = ror
572 class logical_shift<int width> : Operand<i32> {
573 let PrintMethod = "printShifter";
574 let ParserMatchClass = !cast<AsmOperandClass>(
575 "LogicalShifterOperand" # width);
578 def logical_shift32 : logical_shift<32>;
579 def logical_shift64 : logical_shift<64>;
581 class logical_shifted_reg<ValueType Ty, RegisterClass regclass, Operand shiftop>
583 ComplexPattern<Ty, 2, "SelectLogicalShiftedRegister", []> {
584 let PrintMethod = "printShiftedRegister";
585 let MIOperandInfo = (ops regclass, shiftop);
588 def logical_shifted_reg32 : logical_shifted_reg<i32, GPR32, logical_shift32>;
589 def logical_shifted_reg64 : logical_shifted_reg<i64, GPR64, logical_shift64>;
591 // A logical vector shifter operand:
592 // {7-6} - shift type: 00 = lsl
593 // {5-0} - imm6: #0, #8, #16, or #24
594 def logical_vec_shift : Operand<i32> {
595 let PrintMethod = "printShifter";
596 let EncoderMethod = "getVecShifterOpValue";
597 let ParserMatchClass = LogicalVecShifterOperand;
600 // A logical vector half-word shifter operand:
601 // {7-6} - shift type: 00 = lsl
602 // {5-0} - imm6: #0 or #8
603 def logical_vec_hw_shift : Operand<i32> {
604 let PrintMethod = "printShifter";
605 let EncoderMethod = "getVecShifterOpValue";
606 let ParserMatchClass = LogicalVecHalfWordShifterOperand;
609 // A vector move shifter operand:
610 // {0} - imm1: #8 or #16
611 def move_vec_shift : Operand<i32> {
612 let PrintMethod = "printShifter";
613 let EncoderMethod = "getMoveVecShifterOpValue";
614 let ParserMatchClass = MoveVecShifterOperand;
617 def AddSubImmOperand : AsmOperandClass {
618 let Name = "AddSubImm";
619 let ParserMethod = "tryParseAddSubImm";
620 let DiagnosticType = "AddSubSecondSource";
622 // An ADD/SUB immediate shifter operand:
624 // {7-6} - shift type: 00 = lsl
625 // {5-0} - imm6: #0 or #12
626 class addsub_shifted_imm<ValueType Ty>
627 : Operand<Ty>, ComplexPattern<Ty, 2, "SelectArithImmed", [imm]> {
628 let PrintMethod = "printAddSubImm";
629 let EncoderMethod = "getAddSubImmOpValue";
630 let ParserMatchClass = AddSubImmOperand;
631 let MIOperandInfo = (ops i32imm, i32imm);
634 def addsub_shifted_imm32 : addsub_shifted_imm<i32>;
635 def addsub_shifted_imm64 : addsub_shifted_imm<i64>;
637 class neg_addsub_shifted_imm<ValueType Ty>
638 : Operand<Ty>, ComplexPattern<Ty, 2, "SelectNegArithImmed", [imm]> {
639 let PrintMethod = "printAddSubImm";
640 let EncoderMethod = "getAddSubImmOpValue";
641 let ParserMatchClass = AddSubImmOperand;
642 let MIOperandInfo = (ops i32imm, i32imm);
645 def neg_addsub_shifted_imm32 : neg_addsub_shifted_imm<i32>;
646 def neg_addsub_shifted_imm64 : neg_addsub_shifted_imm<i64>;
648 // An extend operand:
649 // {5-3} - extend type
651 def arith_extend : Operand<i32> {
652 let PrintMethod = "printArithExtend";
653 let ParserMatchClass = ExtendOperand;
655 def arith_extend64 : Operand<i32> {
656 let PrintMethod = "printArithExtend";
657 let ParserMatchClass = ExtendOperand64;
660 // 'extend' that's a lsl of a 64-bit register.
661 def arith_extendlsl64 : Operand<i32> {
662 let PrintMethod = "printArithExtend";
663 let ParserMatchClass = ExtendOperandLSL64;
666 class arith_extended_reg32<ValueType Ty> : Operand<Ty>,
667 ComplexPattern<Ty, 2, "SelectArithExtendedRegister", []> {
668 let PrintMethod = "printExtendedRegister";
669 let MIOperandInfo = (ops GPR32, arith_extend);
672 class arith_extended_reg32to64<ValueType Ty> : Operand<Ty>,
673 ComplexPattern<Ty, 2, "SelectArithExtendedRegister", []> {
674 let PrintMethod = "printExtendedRegister";
675 let MIOperandInfo = (ops GPR32, arith_extend64);
678 // Floating-point immediate.
679 def fpimm32 : Operand<f32>,
680 PatLeaf<(f32 fpimm), [{
681 return AArch64_AM::getFP32Imm(N->getValueAPF()) != -1;
682 }], SDNodeXForm<fpimm, [{
683 APFloat InVal = N->getValueAPF();
684 uint32_t enc = AArch64_AM::getFP32Imm(InVal);
685 return CurDAG->getTargetConstant(enc, MVT::i32);
687 let ParserMatchClass = FPImmOperand;
688 let PrintMethod = "printFPImmOperand";
690 def fpimm64 : Operand<f64>,
691 PatLeaf<(f64 fpimm), [{
692 return AArch64_AM::getFP64Imm(N->getValueAPF()) != -1;
693 }], SDNodeXForm<fpimm, [{
694 APFloat InVal = N->getValueAPF();
695 uint32_t enc = AArch64_AM::getFP64Imm(InVal);
696 return CurDAG->getTargetConstant(enc, MVT::i32);
698 let ParserMatchClass = FPImmOperand;
699 let PrintMethod = "printFPImmOperand";
702 def fpimm8 : Operand<i32> {
703 let ParserMatchClass = FPImmOperand;
704 let PrintMethod = "printFPImmOperand";
707 def fpimm0 : PatLeaf<(fpimm), [{
708 return N->isExactlyValue(+0.0);
711 // Vector lane operands
712 class AsmVectorIndex<string Suffix> : AsmOperandClass {
713 let Name = "VectorIndex" # Suffix;
714 let DiagnosticType = "InvalidIndex" # Suffix;
716 def VectorIndex1Operand : AsmVectorIndex<"1">;
717 def VectorIndexBOperand : AsmVectorIndex<"B">;
718 def VectorIndexHOperand : AsmVectorIndex<"H">;
719 def VectorIndexSOperand : AsmVectorIndex<"S">;
720 def VectorIndexDOperand : AsmVectorIndex<"D">;
722 def VectorIndex1 : Operand<i64>, ImmLeaf<i64, [{
723 return ((uint64_t)Imm) == 1;
725 let ParserMatchClass = VectorIndex1Operand;
726 let PrintMethod = "printVectorIndex";
727 let MIOperandInfo = (ops i64imm);
729 def VectorIndexB : Operand<i64>, ImmLeaf<i64, [{
730 return ((uint64_t)Imm) < 16;
732 let ParserMatchClass = VectorIndexBOperand;
733 let PrintMethod = "printVectorIndex";
734 let MIOperandInfo = (ops i64imm);
736 def VectorIndexH : Operand<i64>, ImmLeaf<i64, [{
737 return ((uint64_t)Imm) < 8;
739 let ParserMatchClass = VectorIndexHOperand;
740 let PrintMethod = "printVectorIndex";
741 let MIOperandInfo = (ops i64imm);
743 def VectorIndexS : Operand<i64>, ImmLeaf<i64, [{
744 return ((uint64_t)Imm) < 4;
746 let ParserMatchClass = VectorIndexSOperand;
747 let PrintMethod = "printVectorIndex";
748 let MIOperandInfo = (ops i64imm);
750 def VectorIndexD : Operand<i64>, ImmLeaf<i64, [{
751 return ((uint64_t)Imm) < 2;
753 let ParserMatchClass = VectorIndexDOperand;
754 let PrintMethod = "printVectorIndex";
755 let MIOperandInfo = (ops i64imm);
758 // 8-bit immediate for AdvSIMD where 64-bit values of the form:
759 // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
760 // are encoded as the eight bit value 'abcdefgh'.
761 def simdimmtype10 : Operand<i32>,
762 PatLeaf<(f64 fpimm), [{
763 return AArch64_AM::isAdvSIMDModImmType10(N->getValueAPF()
766 }], SDNodeXForm<fpimm, [{
767 APFloat InVal = N->getValueAPF();
768 uint32_t enc = AArch64_AM::encodeAdvSIMDModImmType10(N->getValueAPF()
771 return CurDAG->getTargetConstant(enc, MVT::i32);
773 let ParserMatchClass = SIMDImmType10Operand;
774 let PrintMethod = "printSIMDType10Operand";
782 // Base encoding for system instruction operands.
783 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
784 class BaseSystemI<bit L, dag oops, dag iops, string asm, string operands,
785 list<dag> pattern = []>
786 : I<oops, iops, asm, operands, "", pattern> {
787 let Inst{31-22} = 0b1101010100;
791 // System instructions which do not have an Rt register.
792 class SimpleSystemI<bit L, dag iops, string asm, string operands,
793 list<dag> pattern = []>
794 : BaseSystemI<L, (outs), iops, asm, operands, pattern> {
795 let Inst{4-0} = 0b11111;
798 // System instructions which have an Rt register.
799 class RtSystemI<bit L, dag oops, dag iops, string asm, string operands>
800 : BaseSystemI<L, oops, iops, asm, operands>,
806 // Hint instructions that take both a CRm and a 3-bit immediate.
807 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
808 // model patterns with sufficiently fine granularity
809 let mayStore = 1, mayLoad = 1, hasSideEffects = 1 in
810 class HintI<string mnemonic>
811 : SimpleSystemI<0, (ins imm0_127:$imm), mnemonic#" $imm", "",
812 [(int_aarch64_hint imm0_127:$imm)]>,
815 let Inst{20-12} = 0b000110010;
816 let Inst{11-5} = imm;
819 // System instructions taking a single literal operand which encodes into
820 // CRm. op2 differentiates the opcodes.
821 def BarrierAsmOperand : AsmOperandClass {
822 let Name = "Barrier";
823 let ParserMethod = "tryParseBarrierOperand";
825 def barrier_op : Operand<i32> {
826 let PrintMethod = "printBarrierOption";
827 let ParserMatchClass = BarrierAsmOperand;
829 class CRmSystemI<Operand crmtype, bits<3> opc, string asm,
830 list<dag> pattern = []>
831 : SimpleSystemI<0, (ins crmtype:$CRm), asm, "\t$CRm", pattern>,
832 Sched<[WriteBarrier]> {
834 let Inst{20-12} = 0b000110011;
835 let Inst{11-8} = CRm;
839 // MRS/MSR system instructions. These have different operand classes because
840 // a different subset of registers can be accessed through each instruction.
841 def MRSSystemRegisterOperand : AsmOperandClass {
842 let Name = "MRSSystemRegister";
843 let ParserMethod = "tryParseSysReg";
844 let DiagnosticType = "MRS";
846 // concatenation of op0, op1, CRn, CRm, op2. 16-bit immediate.
847 def mrs_sysreg_op : Operand<i32> {
848 let ParserMatchClass = MRSSystemRegisterOperand;
849 let DecoderMethod = "DecodeMRSSystemRegister";
850 let PrintMethod = "printMRSSystemRegister";
853 def MSRSystemRegisterOperand : AsmOperandClass {
854 let Name = "MSRSystemRegister";
855 let ParserMethod = "tryParseSysReg";
856 let DiagnosticType = "MSR";
858 def msr_sysreg_op : Operand<i32> {
859 let ParserMatchClass = MSRSystemRegisterOperand;
860 let DecoderMethod = "DecodeMSRSystemRegister";
861 let PrintMethod = "printMSRSystemRegister";
864 class MRSI : RtSystemI<1, (outs GPR64:$Rt), (ins mrs_sysreg_op:$systemreg),
865 "mrs", "\t$Rt, $systemreg"> {
867 let Inst{20-5} = systemreg;
870 // FIXME: Some of these def NZCV, others don't. Best way to model that?
871 // Explicitly modeling each of the system register as a register class
872 // would do it, but feels like overkill at this point.
873 class MSRI : RtSystemI<0, (outs), (ins msr_sysreg_op:$systemreg, GPR64:$Rt),
874 "msr", "\t$systemreg, $Rt"> {
876 let Inst{20-5} = systemreg;
879 def SystemPStateFieldOperand : AsmOperandClass {
880 let Name = "SystemPStateField";
881 let ParserMethod = "tryParseSysReg";
883 def pstatefield_op : Operand<i32> {
884 let ParserMatchClass = SystemPStateFieldOperand;
885 let PrintMethod = "printSystemPStateField";
890 : SimpleSystemI<0, (ins pstatefield_op:$pstate_field, imm0_15:$imm),
891 "msr", "\t$pstate_field, $imm">,
895 let Inst{20-19} = 0b00;
896 let Inst{18-16} = pstatefield{5-3};
897 let Inst{15-12} = 0b0100;
898 let Inst{11-8} = imm;
899 let Inst{7-5} = pstatefield{2-0};
901 let DecoderMethod = "DecodeSystemPStateInstruction";
904 // SYS and SYSL generic system instructions.
905 def SysCRAsmOperand : AsmOperandClass {
907 let ParserMethod = "tryParseSysCROperand";
910 def sys_cr_op : Operand<i32> {
911 let PrintMethod = "printSysCROperand";
912 let ParserMatchClass = SysCRAsmOperand;
915 class SystemXtI<bit L, string asm>
916 : RtSystemI<L, (outs),
917 (ins imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2, GPR64:$Rt),
918 asm, "\t$op1, $Cn, $Cm, $op2, $Rt"> {
923 let Inst{20-19} = 0b01;
924 let Inst{18-16} = op1;
925 let Inst{15-12} = Cn;
930 class SystemLXtI<bit L, string asm>
931 : RtSystemI<L, (outs),
932 (ins GPR64:$Rt, imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2),
933 asm, "\t$Rt, $op1, $Cn, $Cm, $op2"> {
938 let Inst{20-19} = 0b01;
939 let Inst{18-16} = op1;
940 let Inst{15-12} = Cn;
946 // Branch (register) instructions:
954 // otherwise UNDEFINED
955 class BaseBranchReg<bits<4> opc, dag oops, dag iops, string asm,
956 string operands, list<dag> pattern>
957 : I<oops, iops, asm, operands, "", pattern>, Sched<[WriteBrReg]> {
958 let Inst{31-25} = 0b1101011;
959 let Inst{24-21} = opc;
960 let Inst{20-16} = 0b11111;
961 let Inst{15-10} = 0b000000;
962 let Inst{4-0} = 0b00000;
965 class BranchReg<bits<4> opc, string asm, list<dag> pattern>
966 : BaseBranchReg<opc, (outs), (ins GPR64:$Rn), asm, "\t$Rn", pattern> {
971 let mayLoad = 0, mayStore = 0, hasSideEffects = 1, isReturn = 1 in
972 class SpecialReturn<bits<4> opc, string asm>
973 : BaseBranchReg<opc, (outs), (ins), asm, "", []> {
974 let Inst{9-5} = 0b11111;
978 // Conditional branch instruction.
982 // 4-bit immediate. Pretty-printed as <cc>
983 def ccode : Operand<i32> {
984 let PrintMethod = "printCondCode";
985 let ParserMatchClass = CondCode;
987 def inv_ccode : Operand<i32> {
988 // AL and NV are invalid in the aliases which use inv_ccode
989 let PrintMethod = "printInverseCondCode";
990 let ParserMatchClass = CondCode;
991 let MCOperandPredicate = [{
992 return MCOp.isImm() &&
993 MCOp.getImm() != AArch64CC::AL &&
994 MCOp.getImm() != AArch64CC::NV;
998 // Conditional branch target. 19-bit immediate. The low two bits of the target
999 // offset are implied zero and so are not part of the immediate.
1000 def PCRelLabel19Operand : AsmOperandClass {
1001 let Name = "PCRelLabel19";
1002 let DiagnosticType = "InvalidLabel";
1004 def am_brcond : Operand<OtherVT> {
1005 let EncoderMethod = "getCondBranchTargetOpValue";
1006 let DecoderMethod = "DecodePCRelLabel19";
1007 let PrintMethod = "printAlignedLabel";
1008 let ParserMatchClass = PCRelLabel19Operand;
1011 class BranchCond : I<(outs), (ins ccode:$cond, am_brcond:$target),
1012 "b", ".$cond\t$target", "",
1013 [(AArch64brcond bb:$target, imm:$cond, NZCV)]>,
1016 let isTerminator = 1;
1021 let Inst{31-24} = 0b01010100;
1022 let Inst{23-5} = target;
1024 let Inst{3-0} = cond;
1028 // Compare-and-branch instructions.
1030 class BaseCmpBranch<RegisterClass regtype, bit op, string asm, SDNode node>
1031 : I<(outs), (ins regtype:$Rt, am_brcond:$target),
1032 asm, "\t$Rt, $target", "",
1033 [(node regtype:$Rt, bb:$target)]>,
1036 let isTerminator = 1;
1040 let Inst{30-25} = 0b011010;
1042 let Inst{23-5} = target;
1046 multiclass CmpBranch<bit op, string asm, SDNode node> {
1047 def W : BaseCmpBranch<GPR32, op, asm, node> {
1050 def X : BaseCmpBranch<GPR64, op, asm, node> {
1056 // Test-bit-and-branch instructions.
1058 // Test-and-branch target. 14-bit sign-extended immediate. The low two bits of
1059 // the target offset are implied zero and so are not part of the immediate.
1060 def BranchTarget14Operand : AsmOperandClass {
1061 let Name = "BranchTarget14";
1063 def am_tbrcond : Operand<OtherVT> {
1064 let EncoderMethod = "getTestBranchTargetOpValue";
1065 let PrintMethod = "printAlignedLabel";
1066 let ParserMatchClass = BranchTarget14Operand;
1069 // AsmOperand classes to emit (or not) special diagnostics
1070 def TBZImm0_31Operand : AsmOperandClass {
1071 let Name = "TBZImm0_31";
1072 let PredicateMethod = "isImm0_31";
1073 let RenderMethod = "addImm0_31Operands";
1075 def TBZImm32_63Operand : AsmOperandClass {
1076 let Name = "Imm32_63";
1077 let DiagnosticType = "InvalidImm0_63";
1080 class tbz_imm0_31<AsmOperandClass matcher> : Operand<i64>, ImmLeaf<i64, [{
1081 return (((uint32_t)Imm) < 32);
1083 let ParserMatchClass = matcher;
1086 def tbz_imm0_31_diag : tbz_imm0_31<Imm0_31Operand>;
1087 def tbz_imm0_31_nodiag : tbz_imm0_31<TBZImm0_31Operand>;
1089 def tbz_imm32_63 : Operand<i64>, ImmLeaf<i64, [{
1090 return (((uint32_t)Imm) > 31) && (((uint32_t)Imm) < 64);
1092 let ParserMatchClass = TBZImm32_63Operand;
1095 class BaseTestBranch<RegisterClass regtype, Operand immtype,
1096 bit op, string asm, SDNode node>
1097 : I<(outs), (ins regtype:$Rt, immtype:$bit_off, am_tbrcond:$target),
1098 asm, "\t$Rt, $bit_off, $target", "",
1099 [(node regtype:$Rt, immtype:$bit_off, bb:$target)]>,
1102 let isTerminator = 1;
1108 let Inst{30-25} = 0b011011;
1110 let Inst{23-19} = bit_off{4-0};
1111 let Inst{18-5} = target;
1114 let DecoderMethod = "DecodeTestAndBranch";
1117 multiclass TestBranch<bit op, string asm, SDNode node> {
1118 def W : BaseTestBranch<GPR32, tbz_imm0_31_diag, op, asm, node> {
1122 def X : BaseTestBranch<GPR64, tbz_imm32_63, op, asm, node> {
1126 // Alias X-reg with 0-31 imm to W-Reg.
1127 def : InstAlias<asm # "\t$Rd, $imm, $target",
1128 (!cast<Instruction>(NAME#"W") GPR32as64:$Rd,
1129 tbz_imm0_31_nodiag:$imm, am_tbrcond:$target), 0>;
1130 def : Pat<(node GPR64:$Rn, tbz_imm0_31_diag:$imm, bb:$target),
1131 (!cast<Instruction>(NAME#"W") (EXTRACT_SUBREG GPR64:$Rn, sub_32),
1132 tbz_imm0_31_diag:$imm, bb:$target)>;
1136 // Unconditional branch (immediate) instructions.
1138 def BranchTarget26Operand : AsmOperandClass {
1139 let Name = "BranchTarget26";
1140 let DiagnosticType = "InvalidLabel";
1142 def am_b_target : Operand<OtherVT> {
1143 let EncoderMethod = "getBranchTargetOpValue";
1144 let PrintMethod = "printAlignedLabel";
1145 let ParserMatchClass = BranchTarget26Operand;
1147 def am_bl_target : Operand<i64> {
1148 let EncoderMethod = "getBranchTargetOpValue";
1149 let PrintMethod = "printAlignedLabel";
1150 let ParserMatchClass = BranchTarget26Operand;
1153 class BImm<bit op, dag iops, string asm, list<dag> pattern>
1154 : I<(outs), iops, asm, "\t$addr", "", pattern>, Sched<[WriteBr]> {
1157 let Inst{30-26} = 0b00101;
1158 let Inst{25-0} = addr;
1160 let DecoderMethod = "DecodeUnconditionalBranch";
1163 class BranchImm<bit op, string asm, list<dag> pattern>
1164 : BImm<op, (ins am_b_target:$addr), asm, pattern>;
1165 class CallImm<bit op, string asm, list<dag> pattern>
1166 : BImm<op, (ins am_bl_target:$addr), asm, pattern>;
1169 // Basic one-operand data processing instructions.
1172 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1173 class BaseOneOperandData<bits<3> opc, RegisterClass regtype, string asm,
1174 SDPatternOperator node>
1175 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
1176 [(set regtype:$Rd, (node regtype:$Rn))]>,
1177 Sched<[WriteI, ReadI]> {
1181 let Inst{30-13} = 0b101101011000000000;
1182 let Inst{12-10} = opc;
1187 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1188 multiclass OneOperandData<bits<3> opc, string asm,
1189 SDPatternOperator node = null_frag> {
1190 def Wr : BaseOneOperandData<opc, GPR32, asm, node> {
1194 def Xr : BaseOneOperandData<opc, GPR64, asm, node> {
1199 class OneWRegData<bits<3> opc, string asm, SDPatternOperator node>
1200 : BaseOneOperandData<opc, GPR32, asm, node> {
1204 class OneXRegData<bits<3> opc, string asm, SDPatternOperator node>
1205 : BaseOneOperandData<opc, GPR64, asm, node> {
1210 // Basic two-operand data processing instructions.
1212 class BaseBaseAddSubCarry<bit isSub, RegisterClass regtype, string asm,
1214 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1215 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
1216 Sched<[WriteI, ReadI, ReadI]> {
1221 let Inst{30} = isSub;
1222 let Inst{28-21} = 0b11010000;
1223 let Inst{20-16} = Rm;
1224 let Inst{15-10} = 0;
1229 class BaseAddSubCarry<bit isSub, RegisterClass regtype, string asm,
1231 : BaseBaseAddSubCarry<isSub, regtype, asm,
1232 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm, NZCV))]>;
1234 class BaseAddSubCarrySetFlags<bit isSub, RegisterClass regtype, string asm,
1236 : BaseBaseAddSubCarry<isSub, regtype, asm,
1237 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm, NZCV)),
1242 multiclass AddSubCarry<bit isSub, string asm, string asm_setflags,
1243 SDNode OpNode, SDNode OpNode_setflags> {
1244 def Wr : BaseAddSubCarry<isSub, GPR32, asm, OpNode> {
1248 def Xr : BaseAddSubCarry<isSub, GPR64, asm, OpNode> {
1254 def SWr : BaseAddSubCarrySetFlags<isSub, GPR32, asm_setflags,
1259 def SXr : BaseAddSubCarrySetFlags<isSub, GPR64, asm_setflags,
1266 class BaseTwoOperand<bits<4> opc, RegisterClass regtype, string asm,
1267 SDPatternOperator OpNode>
1268 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1269 asm, "\t$Rd, $Rn, $Rm", "",
1270 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]> {
1274 let Inst{30-21} = 0b0011010110;
1275 let Inst{20-16} = Rm;
1276 let Inst{15-14} = 0b00;
1277 let Inst{13-10} = opc;
1282 class BaseDiv<bit isSigned, RegisterClass regtype, string asm,
1283 SDPatternOperator OpNode>
1284 : BaseTwoOperand<{0,0,1,?}, regtype, asm, OpNode> {
1285 let Inst{10} = isSigned;
1288 multiclass Div<bit isSigned, string asm, SDPatternOperator OpNode> {
1289 def Wr : BaseDiv<isSigned, GPR32, asm, OpNode>,
1290 Sched<[WriteID32, ReadID, ReadID]> {
1293 def Xr : BaseDiv<isSigned, GPR64, asm, OpNode>,
1294 Sched<[WriteID64, ReadID, ReadID]> {
1299 class BaseShift<bits<2> shift_type, RegisterClass regtype, string asm,
1300 SDPatternOperator OpNode = null_frag>
1301 : BaseTwoOperand<{1,0,?,?}, regtype, asm, OpNode>,
1302 Sched<[WriteIS, ReadI]> {
1303 let Inst{11-10} = shift_type;
1306 multiclass Shift<bits<2> shift_type, string asm, SDNode OpNode> {
1307 def Wr : BaseShift<shift_type, GPR32, asm> {
1311 def Xr : BaseShift<shift_type, GPR64, asm, OpNode> {
1315 def : Pat<(i32 (OpNode GPR32:$Rn, i64:$Rm)),
1316 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn,
1317 (EXTRACT_SUBREG i64:$Rm, sub_32))>;
1319 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (zext GPR32:$Rm)))),
1320 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1322 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (anyext GPR32:$Rm)))),
1323 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1325 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (sext GPR32:$Rm)))),
1326 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1329 class ShiftAlias<string asm, Instruction inst, RegisterClass regtype>
1330 : InstAlias<asm#" $dst, $src1, $src2",
1331 (inst regtype:$dst, regtype:$src1, regtype:$src2), 0>;
1333 class BaseMulAccum<bit isSub, bits<3> opc, RegisterClass multype,
1334 RegisterClass addtype, string asm,
1336 : I<(outs addtype:$Rd), (ins multype:$Rn, multype:$Rm, addtype:$Ra),
1337 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pattern> {
1342 let Inst{30-24} = 0b0011011;
1343 let Inst{23-21} = opc;
1344 let Inst{20-16} = Rm;
1345 let Inst{15} = isSub;
1346 let Inst{14-10} = Ra;
1351 multiclass MulAccum<bit isSub, string asm, SDNode AccNode> {
1352 // MADD/MSUB generation is decided by MachineCombiner.cpp
1353 def Wrrr : BaseMulAccum<isSub, 0b000, GPR32, GPR32, asm,
1354 [/*(set GPR32:$Rd, (AccNode GPR32:$Ra, (mul GPR32:$Rn, GPR32:$Rm)))*/]>,
1355 Sched<[WriteIM32, ReadIM, ReadIM, ReadIMA]> {
1359 def Xrrr : BaseMulAccum<isSub, 0b000, GPR64, GPR64, asm,
1360 [/*(set GPR64:$Rd, (AccNode GPR64:$Ra, (mul GPR64:$Rn, GPR64:$Rm)))*/]>,
1361 Sched<[WriteIM64, ReadIM, ReadIM, ReadIMA]> {
1366 class WideMulAccum<bit isSub, bits<3> opc, string asm,
1367 SDNode AccNode, SDNode ExtNode>
1368 : BaseMulAccum<isSub, opc, GPR32, GPR64, asm,
1369 [(set GPR64:$Rd, (AccNode GPR64:$Ra,
1370 (mul (ExtNode GPR32:$Rn), (ExtNode GPR32:$Rm))))]>,
1371 Sched<[WriteIM32, ReadIM, ReadIM, ReadIMA]> {
1375 class MulHi<bits<3> opc, string asm, SDNode OpNode>
1376 : I<(outs GPR64:$Rd), (ins GPR64:$Rn, GPR64:$Rm),
1377 asm, "\t$Rd, $Rn, $Rm", "",
1378 [(set GPR64:$Rd, (OpNode GPR64:$Rn, GPR64:$Rm))]>,
1379 Sched<[WriteIM64, ReadIM, ReadIM]> {
1383 let Inst{31-24} = 0b10011011;
1384 let Inst{23-21} = opc;
1385 let Inst{20-16} = Rm;
1390 // The Ra field of SMULH and UMULH is unused: it should be assembled as 31
1391 // (i.e. all bits 1) but is ignored by the processor.
1392 let PostEncoderMethod = "fixMulHigh";
1395 class MulAccumWAlias<string asm, Instruction inst>
1396 : InstAlias<asm#" $dst, $src1, $src2",
1397 (inst GPR32:$dst, GPR32:$src1, GPR32:$src2, WZR)>;
1398 class MulAccumXAlias<string asm, Instruction inst>
1399 : InstAlias<asm#" $dst, $src1, $src2",
1400 (inst GPR64:$dst, GPR64:$src1, GPR64:$src2, XZR)>;
1401 class WideMulAccumAlias<string asm, Instruction inst>
1402 : InstAlias<asm#" $dst, $src1, $src2",
1403 (inst GPR64:$dst, GPR32:$src1, GPR32:$src2, XZR)>;
1405 class BaseCRC32<bit sf, bits<2> sz, bit C, RegisterClass StreamReg,
1406 SDPatternOperator OpNode, string asm>
1407 : I<(outs GPR32:$Rd), (ins GPR32:$Rn, StreamReg:$Rm),
1408 asm, "\t$Rd, $Rn, $Rm", "",
1409 [(set GPR32:$Rd, (OpNode GPR32:$Rn, StreamReg:$Rm))]>,
1410 Sched<[WriteISReg, ReadI, ReadISReg]> {
1416 let Inst{30-21} = 0b0011010110;
1417 let Inst{20-16} = Rm;
1418 let Inst{15-13} = 0b010;
1420 let Inst{11-10} = sz;
1423 let Predicates = [HasCRC];
1427 // Address generation.
1430 class ADRI<bit page, string asm, Operand adr, list<dag> pattern>
1431 : I<(outs GPR64:$Xd), (ins adr:$label), asm, "\t$Xd, $label", "",
1436 let Inst{31} = page;
1437 let Inst{30-29} = label{1-0};
1438 let Inst{28-24} = 0b10000;
1439 let Inst{23-5} = label{20-2};
1442 let DecoderMethod = "DecodeAdrInstruction";
1449 def movimm32_imm : Operand<i32> {
1450 let ParserMatchClass = Imm0_65535Operand;
1451 let EncoderMethod = "getMoveWideImmOpValue";
1452 let PrintMethod = "printHexImm";
1454 def movimm32_shift : Operand<i32> {
1455 let PrintMethod = "printShifter";
1456 let ParserMatchClass = MovImm32ShifterOperand;
1458 def movimm64_shift : Operand<i32> {
1459 let PrintMethod = "printShifter";
1460 let ParserMatchClass = MovImm64ShifterOperand;
1463 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1464 class BaseMoveImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
1466 : I<(outs regtype:$Rd), (ins movimm32_imm:$imm, shifter:$shift),
1467 asm, "\t$Rd, $imm$shift", "", []>,
1472 let Inst{30-29} = opc;
1473 let Inst{28-23} = 0b100101;
1474 let Inst{22-21} = shift{5-4};
1475 let Inst{20-5} = imm;
1478 let DecoderMethod = "DecodeMoveImmInstruction";
1481 multiclass MoveImmediate<bits<2> opc, string asm> {
1482 def Wi : BaseMoveImmediate<opc, GPR32, movimm32_shift, asm> {
1486 def Xi : BaseMoveImmediate<opc, GPR64, movimm64_shift, asm> {
1491 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1492 class BaseInsertImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
1494 : I<(outs regtype:$Rd),
1495 (ins regtype:$src, movimm32_imm:$imm, shifter:$shift),
1496 asm, "\t$Rd, $imm$shift", "$src = $Rd", []>,
1497 Sched<[WriteI, ReadI]> {
1501 let Inst{30-29} = opc;
1502 let Inst{28-23} = 0b100101;
1503 let Inst{22-21} = shift{5-4};
1504 let Inst{20-5} = imm;
1507 let DecoderMethod = "DecodeMoveImmInstruction";
1510 multiclass InsertImmediate<bits<2> opc, string asm> {
1511 def Wi : BaseInsertImmediate<opc, GPR32, movimm32_shift, asm> {
1515 def Xi : BaseInsertImmediate<opc, GPR64, movimm64_shift, asm> {
1524 class BaseAddSubImm<bit isSub, bit setFlags, RegisterClass dstRegtype,
1525 RegisterClass srcRegtype, addsub_shifted_imm immtype,
1526 string asm, SDPatternOperator OpNode>
1527 : I<(outs dstRegtype:$Rd), (ins srcRegtype:$Rn, immtype:$imm),
1528 asm, "\t$Rd, $Rn, $imm", "",
1529 [(set dstRegtype:$Rd, (OpNode srcRegtype:$Rn, immtype:$imm))]>,
1530 Sched<[WriteI, ReadI]> {
1534 let Inst{30} = isSub;
1535 let Inst{29} = setFlags;
1536 let Inst{28-24} = 0b10001;
1537 let Inst{23-22} = imm{13-12}; // '00' => lsl #0, '01' => lsl #12
1538 let Inst{21-10} = imm{11-0};
1541 let DecoderMethod = "DecodeBaseAddSubImm";
1544 class BaseAddSubRegPseudo<RegisterClass regtype,
1545 SDPatternOperator OpNode>
1546 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1547 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
1548 Sched<[WriteI, ReadI, ReadI]>;
1550 class BaseAddSubSReg<bit isSub, bit setFlags, RegisterClass regtype,
1551 arith_shifted_reg shifted_regtype, string asm,
1552 SDPatternOperator OpNode>
1553 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
1554 asm, "\t$Rd, $Rn, $Rm", "",
1555 [(set regtype:$Rd, (OpNode regtype:$Rn, shifted_regtype:$Rm))]>,
1556 Sched<[WriteISReg, ReadI, ReadISReg]> {
1557 // The operands are in order to match the 'addr' MI operands, so we
1558 // don't need an encoder method and by-name matching. Just use the default
1559 // in-order handling. Since we're using by-order, make sure the names
1565 let Inst{30} = isSub;
1566 let Inst{29} = setFlags;
1567 let Inst{28-24} = 0b01011;
1568 let Inst{23-22} = shift{7-6};
1570 let Inst{20-16} = src2;
1571 let Inst{15-10} = shift{5-0};
1572 let Inst{9-5} = src1;
1573 let Inst{4-0} = dst;
1575 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
1578 class BaseAddSubEReg<bit isSub, bit setFlags, RegisterClass dstRegtype,
1579 RegisterClass src1Regtype, Operand src2Regtype,
1580 string asm, SDPatternOperator OpNode>
1581 : I<(outs dstRegtype:$R1),
1582 (ins src1Regtype:$R2, src2Regtype:$R3),
1583 asm, "\t$R1, $R2, $R3", "",
1584 [(set dstRegtype:$R1, (OpNode src1Regtype:$R2, src2Regtype:$R3))]>,
1585 Sched<[WriteIEReg, ReadI, ReadIEReg]> {
1590 let Inst{30} = isSub;
1591 let Inst{29} = setFlags;
1592 let Inst{28-24} = 0b01011;
1593 let Inst{23-21} = 0b001;
1594 let Inst{20-16} = Rm;
1595 let Inst{15-13} = ext{5-3};
1596 let Inst{12-10} = ext{2-0};
1600 let DecoderMethod = "DecodeAddSubERegInstruction";
1603 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1604 class BaseAddSubEReg64<bit isSub, bit setFlags, RegisterClass dstRegtype,
1605 RegisterClass src1Regtype, RegisterClass src2Regtype,
1606 Operand ext_op, string asm>
1607 : I<(outs dstRegtype:$Rd),
1608 (ins src1Regtype:$Rn, src2Regtype:$Rm, ext_op:$ext),
1609 asm, "\t$Rd, $Rn, $Rm$ext", "", []>,
1610 Sched<[WriteIEReg, ReadI, ReadIEReg]> {
1615 let Inst{30} = isSub;
1616 let Inst{29} = setFlags;
1617 let Inst{28-24} = 0b01011;
1618 let Inst{23-21} = 0b001;
1619 let Inst{20-16} = Rm;
1620 let Inst{15} = ext{5};
1621 let Inst{12-10} = ext{2-0};
1625 let DecoderMethod = "DecodeAddSubERegInstruction";
1628 // Aliases for register+register add/subtract.
1629 class AddSubRegAlias<string asm, Instruction inst, RegisterClass dstRegtype,
1630 RegisterClass src1Regtype, RegisterClass src2Regtype,
1632 : InstAlias<asm#" $dst, $src1, $src2",
1633 (inst dstRegtype:$dst, src1Regtype:$src1, src2Regtype:$src2,
1636 multiclass AddSub<bit isSub, string mnemonic,
1637 SDPatternOperator OpNode = null_frag> {
1638 let hasSideEffects = 0, isReMaterializable = 1, isAsCheapAsAMove = 1 in {
1639 // Add/Subtract immediate
1640 def Wri : BaseAddSubImm<isSub, 0, GPR32sp, GPR32sp, addsub_shifted_imm32,
1644 def Xri : BaseAddSubImm<isSub, 0, GPR64sp, GPR64sp, addsub_shifted_imm64,
1649 // Add/Subtract register - Only used for CodeGen
1650 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
1651 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
1653 // Add/Subtract shifted register
1654 def Wrs : BaseAddSubSReg<isSub, 0, GPR32, arith_shifted_reg32, mnemonic,
1658 def Xrs : BaseAddSubSReg<isSub, 0, GPR64, arith_shifted_reg64, mnemonic,
1664 // Add/Subtract extended register
1665 let AddedComplexity = 1, hasSideEffects = 0 in {
1666 def Wrx : BaseAddSubEReg<isSub, 0, GPR32sp, GPR32sp,
1667 arith_extended_reg32<i32>, mnemonic, OpNode> {
1670 def Xrx : BaseAddSubEReg<isSub, 0, GPR64sp, GPR64sp,
1671 arith_extended_reg32to64<i64>, mnemonic, OpNode> {
1676 def Xrx64 : BaseAddSubEReg64<isSub, 0, GPR64sp, GPR64sp, GPR64,
1677 arith_extendlsl64, mnemonic> {
1678 // UXTX and SXTX only.
1679 let Inst{14-13} = 0b11;
1683 // Register/register aliases with no shift when SP is not used.
1684 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
1685 GPR32, GPR32, GPR32, 0>;
1686 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
1687 GPR64, GPR64, GPR64, 0>;
1689 // Register/register aliases with no shift when either the destination or
1690 // first source register is SP.
1691 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1692 GPR32sponly, GPR32sp, GPR32, 16>; // UXTW #0
1693 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1694 GPR32sp, GPR32sponly, GPR32, 16>; // UXTW #0
1695 def : AddSubRegAlias<mnemonic,
1696 !cast<Instruction>(NAME#"Xrx64"),
1697 GPR64sponly, GPR64sp, GPR64, 24>; // UXTX #0
1698 def : AddSubRegAlias<mnemonic,
1699 !cast<Instruction>(NAME#"Xrx64"),
1700 GPR64sp, GPR64sponly, GPR64, 24>; // UXTX #0
1703 multiclass AddSubS<bit isSub, string mnemonic, SDNode OpNode, string cmp> {
1704 let isCompare = 1, Defs = [NZCV] in {
1705 // Add/Subtract immediate
1706 def Wri : BaseAddSubImm<isSub, 1, GPR32, GPR32sp, addsub_shifted_imm32,
1710 def Xri : BaseAddSubImm<isSub, 1, GPR64, GPR64sp, addsub_shifted_imm64,
1715 // Add/Subtract register
1716 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
1717 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
1719 // Add/Subtract shifted register
1720 def Wrs : BaseAddSubSReg<isSub, 1, GPR32, arith_shifted_reg32, mnemonic,
1724 def Xrs : BaseAddSubSReg<isSub, 1, GPR64, arith_shifted_reg64, mnemonic,
1729 // Add/Subtract extended register
1730 let AddedComplexity = 1 in {
1731 def Wrx : BaseAddSubEReg<isSub, 1, GPR32, GPR32sp,
1732 arith_extended_reg32<i32>, mnemonic, OpNode> {
1735 def Xrx : BaseAddSubEReg<isSub, 1, GPR64, GPR64sp,
1736 arith_extended_reg32<i64>, mnemonic, OpNode> {
1741 def Xrx64 : BaseAddSubEReg64<isSub, 1, GPR64, GPR64sp, GPR64,
1742 arith_extendlsl64, mnemonic> {
1743 // UXTX and SXTX only.
1744 let Inst{14-13} = 0b11;
1750 def : InstAlias<cmp#" $src, $imm", (!cast<Instruction>(NAME#"Wri")
1751 WZR, GPR32sp:$src, addsub_shifted_imm32:$imm), 5>;
1752 def : InstAlias<cmp#" $src, $imm", (!cast<Instruction>(NAME#"Xri")
1753 XZR, GPR64sp:$src, addsub_shifted_imm64:$imm), 5>;
1754 def : InstAlias<cmp#" $src1, $src2$sh", (!cast<Instruction>(NAME#"Wrx")
1755 WZR, GPR32sp:$src1, GPR32:$src2, arith_extend:$sh), 4>;
1756 def : InstAlias<cmp#" $src1, $src2$sh", (!cast<Instruction>(NAME#"Xrx")
1757 XZR, GPR64sp:$src1, GPR32:$src2, arith_extend:$sh), 4>;
1758 def : InstAlias<cmp#" $src1, $src2$sh", (!cast<Instruction>(NAME#"Xrx64")
1759 XZR, GPR64sp:$src1, GPR64:$src2, arith_extendlsl64:$sh), 4>;
1760 def : InstAlias<cmp#" $src1, $src2$sh", (!cast<Instruction>(NAME#"Wrs")
1761 WZR, GPR32:$src1, GPR32:$src2, arith_shift32:$sh), 4>;
1762 def : InstAlias<cmp#" $src1, $src2$sh", (!cast<Instruction>(NAME#"Xrs")
1763 XZR, GPR64:$src1, GPR64:$src2, arith_shift64:$sh), 4>;
1765 // Compare shorthands
1766 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Wrs")
1767 WZR, GPR32:$src1, GPR32:$src2, 0), 5>;
1768 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Xrs")
1769 XZR, GPR64:$src1, GPR64:$src2, 0), 5>;
1770 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Wrx")
1771 WZR, GPR32sponly:$src1, GPR32:$src2, 16), 5>;
1772 def : InstAlias<cmp#" $src1, $src2", (!cast<Instruction>(NAME#"Xrx64")
1773 XZR, GPR64sponly:$src1, GPR64:$src2, 24), 5>;
1775 // Register/register aliases with no shift when SP is not used.
1776 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
1777 GPR32, GPR32, GPR32, 0>;
1778 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
1779 GPR64, GPR64, GPR64, 0>;
1781 // Register/register aliases with no shift when the first source register
1783 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
1784 GPR32, GPR32sponly, GPR32, 16>; // UXTW #0
1785 def : AddSubRegAlias<mnemonic,
1786 !cast<Instruction>(NAME#"Xrx64"),
1787 GPR64, GPR64sponly, GPR64, 24>; // UXTX #0
1793 def SDTA64EXTR : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
1795 def AArch64Extr : SDNode<"AArch64ISD::EXTR", SDTA64EXTR>;
1797 class BaseExtractImm<RegisterClass regtype, Operand imm_type, string asm,
1799 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, imm_type:$imm),
1800 asm, "\t$Rd, $Rn, $Rm, $imm", "", patterns>,
1801 Sched<[WriteExtr, ReadExtrHi]> {
1807 let Inst{30-23} = 0b00100111;
1809 let Inst{20-16} = Rm;
1810 let Inst{15-10} = imm;
1815 multiclass ExtractImm<string asm> {
1816 def Wrri : BaseExtractImm<GPR32, imm0_31, asm,
1818 (AArch64Extr GPR32:$Rn, GPR32:$Rm, imm0_31:$imm))]> {
1821 // imm<5> must be zero.
1824 def Xrri : BaseExtractImm<GPR64, imm0_63, asm,
1826 (AArch64Extr GPR64:$Rn, GPR64:$Rm, imm0_63:$imm))]> {
1837 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1838 class BaseBitfieldImm<bits<2> opc,
1839 RegisterClass regtype, Operand imm_type, string asm>
1840 : I<(outs regtype:$Rd), (ins regtype:$Rn, imm_type:$immr, imm_type:$imms),
1841 asm, "\t$Rd, $Rn, $immr, $imms", "", []>,
1842 Sched<[WriteIS, ReadI]> {
1848 let Inst{30-29} = opc;
1849 let Inst{28-23} = 0b100110;
1850 let Inst{21-16} = immr;
1851 let Inst{15-10} = imms;
1856 multiclass BitfieldImm<bits<2> opc, string asm> {
1857 def Wri : BaseBitfieldImm<opc, GPR32, imm0_31, asm> {
1860 // imms<5> and immr<5> must be zero, else ReservedValue().
1864 def Xri : BaseBitfieldImm<opc, GPR64, imm0_63, asm> {
1870 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1871 class BaseBitfieldImmWith2RegArgs<bits<2> opc,
1872 RegisterClass regtype, Operand imm_type, string asm>
1873 : I<(outs regtype:$Rd), (ins regtype:$src, regtype:$Rn, imm_type:$immr,
1875 asm, "\t$Rd, $Rn, $immr, $imms", "$src = $Rd", []>,
1876 Sched<[WriteIS, ReadI]> {
1882 let Inst{30-29} = opc;
1883 let Inst{28-23} = 0b100110;
1884 let Inst{21-16} = immr;
1885 let Inst{15-10} = imms;
1890 multiclass BitfieldImmWith2RegArgs<bits<2> opc, string asm> {
1891 def Wri : BaseBitfieldImmWith2RegArgs<opc, GPR32, imm0_31, asm> {
1894 // imms<5> and immr<5> must be zero, else ReservedValue().
1898 def Xri : BaseBitfieldImmWith2RegArgs<opc, GPR64, imm0_63, asm> {
1908 // Logical (immediate)
1909 class BaseLogicalImm<bits<2> opc, RegisterClass dregtype,
1910 RegisterClass sregtype, Operand imm_type, string asm,
1912 : I<(outs dregtype:$Rd), (ins sregtype:$Rn, imm_type:$imm),
1913 asm, "\t$Rd, $Rn, $imm", "", pattern>,
1914 Sched<[WriteI, ReadI]> {
1918 let Inst{30-29} = opc;
1919 let Inst{28-23} = 0b100100;
1920 let Inst{22} = imm{12};
1921 let Inst{21-16} = imm{11-6};
1922 let Inst{15-10} = imm{5-0};
1926 let DecoderMethod = "DecodeLogicalImmInstruction";
1929 // Logical (shifted register)
1930 class BaseLogicalSReg<bits<2> opc, bit N, RegisterClass regtype,
1931 logical_shifted_reg shifted_regtype, string asm,
1933 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
1934 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
1935 Sched<[WriteISReg, ReadI, ReadISReg]> {
1936 // The operands are in order to match the 'addr' MI operands, so we
1937 // don't need an encoder method and by-name matching. Just use the default
1938 // in-order handling. Since we're using by-order, make sure the names
1944 let Inst{30-29} = opc;
1945 let Inst{28-24} = 0b01010;
1946 let Inst{23-22} = shift{7-6};
1948 let Inst{20-16} = src2;
1949 let Inst{15-10} = shift{5-0};
1950 let Inst{9-5} = src1;
1951 let Inst{4-0} = dst;
1953 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
1956 // Aliases for register+register logical instructions.
1957 class LogicalRegAlias<string asm, Instruction inst, RegisterClass regtype>
1958 : InstAlias<asm#" $dst, $src1, $src2",
1959 (inst regtype:$dst, regtype:$src1, regtype:$src2, 0)>;
1961 multiclass LogicalImm<bits<2> opc, string mnemonic, SDNode OpNode,
1963 let AddedComplexity = 6, isReMaterializable = 1, isAsCheapAsAMove = 1 in
1964 def Wri : BaseLogicalImm<opc, GPR32sp, GPR32, logical_imm32, mnemonic,
1965 [(set GPR32sp:$Rd, (OpNode GPR32:$Rn,
1966 logical_imm32:$imm))]> {
1968 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
1970 let AddedComplexity = 6, isReMaterializable = 1, isAsCheapAsAMove = 1 in
1971 def Xri : BaseLogicalImm<opc, GPR64sp, GPR64, logical_imm64, mnemonic,
1972 [(set GPR64sp:$Rd, (OpNode GPR64:$Rn,
1973 logical_imm64:$imm))]> {
1977 def : InstAlias<Alias # " $Rd, $Rn, $imm",
1978 (!cast<Instruction>(NAME # "Wri") GPR32sp:$Rd, GPR32:$Rn,
1979 logical_imm32_not:$imm), 0>;
1980 def : InstAlias<Alias # " $Rd, $Rn, $imm",
1981 (!cast<Instruction>(NAME # "Xri") GPR64sp:$Rd, GPR64:$Rn,
1982 logical_imm64_not:$imm), 0>;
1985 multiclass LogicalImmS<bits<2> opc, string mnemonic, SDNode OpNode,
1987 let isCompare = 1, Defs = [NZCV] in {
1988 def Wri : BaseLogicalImm<opc, GPR32, GPR32, logical_imm32, mnemonic,
1989 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_imm32:$imm))]> {
1991 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
1993 def Xri : BaseLogicalImm<opc, GPR64, GPR64, logical_imm64, mnemonic,
1994 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_imm64:$imm))]> {
1997 } // end Defs = [NZCV]
1999 def : InstAlias<Alias # " $Rd, $Rn, $imm",
2000 (!cast<Instruction>(NAME # "Wri") GPR32:$Rd, GPR32:$Rn,
2001 logical_imm32_not:$imm), 0>;
2002 def : InstAlias<Alias # " $Rd, $Rn, $imm",
2003 (!cast<Instruction>(NAME # "Xri") GPR64:$Rd, GPR64:$Rn,
2004 logical_imm64_not:$imm), 0>;
2007 class BaseLogicalRegPseudo<RegisterClass regtype, SDPatternOperator OpNode>
2008 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
2009 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
2010 Sched<[WriteI, ReadI, ReadI]>;
2012 // Split from LogicalImm as not all instructions have both.
2013 multiclass LogicalReg<bits<2> opc, bit N, string mnemonic,
2014 SDPatternOperator OpNode> {
2015 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2016 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
2017 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
2020 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
2021 [(set GPR32:$Rd, (OpNode GPR32:$Rn,
2022 logical_shifted_reg32:$Rm))]> {
2025 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
2026 [(set GPR64:$Rd, (OpNode GPR64:$Rn,
2027 logical_shifted_reg64:$Rm))]> {
2031 def : LogicalRegAlias<mnemonic,
2032 !cast<Instruction>(NAME#"Wrs"), GPR32>;
2033 def : LogicalRegAlias<mnemonic,
2034 !cast<Instruction>(NAME#"Xrs"), GPR64>;
2037 // Split from LogicalReg to allow setting NZCV Defs
2038 multiclass LogicalRegS<bits<2> opc, bit N, string mnemonic,
2039 SDPatternOperator OpNode = null_frag> {
2040 let Defs = [NZCV], mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
2041 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
2042 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
2044 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
2045 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_shifted_reg32:$Rm))]> {
2048 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
2049 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_shifted_reg64:$Rm))]> {
2054 def : LogicalRegAlias<mnemonic,
2055 !cast<Instruction>(NAME#"Wrs"), GPR32>;
2056 def : LogicalRegAlias<mnemonic,
2057 !cast<Instruction>(NAME#"Xrs"), GPR64>;
2061 // Conditionally set flags
2064 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2065 class BaseCondSetFlagsImm<bit op, RegisterClass regtype, string asm>
2066 : I<(outs), (ins regtype:$Rn, imm0_31:$imm, imm0_15:$nzcv, ccode:$cond),
2067 asm, "\t$Rn, $imm, $nzcv, $cond", "", []>,
2068 Sched<[WriteI, ReadI]> {
2078 let Inst{29-21} = 0b111010010;
2079 let Inst{20-16} = imm;
2080 let Inst{15-12} = cond;
2081 let Inst{11-10} = 0b10;
2084 let Inst{3-0} = nzcv;
2087 multiclass CondSetFlagsImm<bit op, string asm> {
2088 def Wi : BaseCondSetFlagsImm<op, GPR32, asm> {
2091 def Xi : BaseCondSetFlagsImm<op, GPR64, asm> {
2096 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2097 class BaseCondSetFlagsReg<bit op, RegisterClass regtype, string asm>
2098 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm0_15:$nzcv, ccode:$cond),
2099 asm, "\t$Rn, $Rm, $nzcv, $cond", "", []>,
2100 Sched<[WriteI, ReadI, ReadI]> {
2110 let Inst{29-21} = 0b111010010;
2111 let Inst{20-16} = Rm;
2112 let Inst{15-12} = cond;
2113 let Inst{11-10} = 0b00;
2116 let Inst{3-0} = nzcv;
2119 multiclass CondSetFlagsReg<bit op, string asm> {
2120 def Wr : BaseCondSetFlagsReg<op, GPR32, asm> {
2123 def Xr : BaseCondSetFlagsReg<op, GPR64, asm> {
2129 // Conditional select
2132 class BaseCondSelect<bit op, bits<2> op2, RegisterClass regtype, string asm>
2133 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
2134 asm, "\t$Rd, $Rn, $Rm, $cond", "",
2136 (AArch64csel regtype:$Rn, regtype:$Rm, (i32 imm:$cond), NZCV))]>,
2137 Sched<[WriteI, ReadI, ReadI]> {
2146 let Inst{29-21} = 0b011010100;
2147 let Inst{20-16} = Rm;
2148 let Inst{15-12} = cond;
2149 let Inst{11-10} = op2;
2154 multiclass CondSelect<bit op, bits<2> op2, string asm> {
2155 def Wr : BaseCondSelect<op, op2, GPR32, asm> {
2158 def Xr : BaseCondSelect<op, op2, GPR64, asm> {
2163 class BaseCondSelectOp<bit op, bits<2> op2, RegisterClass regtype, string asm,
2165 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
2166 asm, "\t$Rd, $Rn, $Rm, $cond", "",
2168 (AArch64csel regtype:$Rn, (frag regtype:$Rm),
2169 (i32 imm:$cond), NZCV))]>,
2170 Sched<[WriteI, ReadI, ReadI]> {
2179 let Inst{29-21} = 0b011010100;
2180 let Inst{20-16} = Rm;
2181 let Inst{15-12} = cond;
2182 let Inst{11-10} = op2;
2187 def inv_cond_XFORM : SDNodeXForm<imm, [{
2188 AArch64CC::CondCode CC = static_cast<AArch64CC::CondCode>(N->getZExtValue());
2189 return CurDAG->getTargetConstant(AArch64CC::getInvertedCondCode(CC), MVT::i32);
2192 multiclass CondSelectOp<bit op, bits<2> op2, string asm, PatFrag frag> {
2193 def Wr : BaseCondSelectOp<op, op2, GPR32, asm, frag> {
2196 def Xr : BaseCondSelectOp<op, op2, GPR64, asm, frag> {
2200 def : Pat<(AArch64csel (frag GPR32:$Rm), GPR32:$Rn, (i32 imm:$cond), NZCV),
2201 (!cast<Instruction>(NAME # Wr) GPR32:$Rn, GPR32:$Rm,
2202 (inv_cond_XFORM imm:$cond))>;
2204 def : Pat<(AArch64csel (frag GPR64:$Rm), GPR64:$Rn, (i32 imm:$cond), NZCV),
2205 (!cast<Instruction>(NAME # Xr) GPR64:$Rn, GPR64:$Rm,
2206 (inv_cond_XFORM imm:$cond))>;
2210 // Special Mask Value
2212 def maski8_or_more : Operand<i32>,
2213 ImmLeaf<i32, [{ return (Imm & 0xff) == 0xff; }]> {
2215 def maski16_or_more : Operand<i32>,
2216 ImmLeaf<i32, [{ return (Imm & 0xffff) == 0xffff; }]> {
2224 // (unsigned immediate)
2225 // Indexed for 8-bit registers. offset is in range [0,4095].
2226 def am_indexed8 : ComplexPattern<i64, 2, "SelectAddrModeIndexed8", []>;
2227 def am_indexed16 : ComplexPattern<i64, 2, "SelectAddrModeIndexed16", []>;
2228 def am_indexed32 : ComplexPattern<i64, 2, "SelectAddrModeIndexed32", []>;
2229 def am_indexed64 : ComplexPattern<i64, 2, "SelectAddrModeIndexed64", []>;
2230 def am_indexed128 : ComplexPattern<i64, 2, "SelectAddrModeIndexed128", []>;
2232 class UImm12OffsetOperand<int Scale> : AsmOperandClass {
2233 let Name = "UImm12Offset" # Scale;
2234 let RenderMethod = "addUImm12OffsetOperands<" # Scale # ">";
2235 let PredicateMethod = "isUImm12Offset<" # Scale # ">";
2236 let DiagnosticType = "InvalidMemoryIndexed" # Scale;
2239 def UImm12OffsetScale1Operand : UImm12OffsetOperand<1>;
2240 def UImm12OffsetScale2Operand : UImm12OffsetOperand<2>;
2241 def UImm12OffsetScale4Operand : UImm12OffsetOperand<4>;
2242 def UImm12OffsetScale8Operand : UImm12OffsetOperand<8>;
2243 def UImm12OffsetScale16Operand : UImm12OffsetOperand<16>;
2245 class uimm12_scaled<int Scale> : Operand<i64> {
2246 let ParserMatchClass
2247 = !cast<AsmOperandClass>("UImm12OffsetScale" # Scale # "Operand");
2249 = "getLdStUImm12OpValue<AArch64::fixup_aarch64_ldst_imm12_scale" # Scale # ">";
2250 let PrintMethod = "printUImm12Offset<" # Scale # ">";
2253 def uimm12s1 : uimm12_scaled<1>;
2254 def uimm12s2 : uimm12_scaled<2>;
2255 def uimm12s4 : uimm12_scaled<4>;
2256 def uimm12s8 : uimm12_scaled<8>;
2257 def uimm12s16 : uimm12_scaled<16>;
2259 class BaseLoadStoreUI<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2260 string asm, list<dag> pattern>
2261 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]", "", pattern> {
2267 let Inst{31-30} = sz;
2268 let Inst{29-27} = 0b111;
2270 let Inst{25-24} = 0b01;
2271 let Inst{23-22} = opc;
2272 let Inst{21-10} = offset;
2276 let DecoderMethod = "DecodeUnsignedLdStInstruction";
2279 multiclass LoadUI<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2280 Operand indextype, string asm, list<dag> pattern> {
2281 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2282 def ui : BaseLoadStoreUI<sz, V, opc, (outs regtype:$Rt),
2283 (ins GPR64sp:$Rn, indextype:$offset),
2287 def : InstAlias<asm # " $Rt, [$Rn]",
2288 (!cast<Instruction>(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>;
2291 multiclass StoreUI<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2292 Operand indextype, string asm, list<dag> pattern> {
2293 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2294 def ui : BaseLoadStoreUI<sz, V, opc, (outs),
2295 (ins regtype:$Rt, GPR64sp:$Rn, indextype:$offset),
2299 def : InstAlias<asm # " $Rt, [$Rn]",
2300 (!cast<Instruction>(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>;
2303 def PrefetchOperand : AsmOperandClass {
2304 let Name = "Prefetch";
2305 let ParserMethod = "tryParsePrefetch";
2307 def prfop : Operand<i32> {
2308 let PrintMethod = "printPrefetchOp";
2309 let ParserMatchClass = PrefetchOperand;
2312 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2313 class PrefetchUI<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2314 : BaseLoadStoreUI<sz, V, opc,
2315 (outs), (ins prfop:$Rt, GPR64sp:$Rn, uimm12s8:$offset),
2323 // Load literal address: 19-bit immediate. The low two bits of the target
2324 // offset are implied zero and so are not part of the immediate.
2325 def am_ldrlit : Operand<OtherVT> {
2326 let EncoderMethod = "getLoadLiteralOpValue";
2327 let DecoderMethod = "DecodePCRelLabel19";
2328 let PrintMethod = "printAlignedLabel";
2329 let ParserMatchClass = PCRelLabel19Operand;
2332 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2333 class LoadLiteral<bits<2> opc, bit V, RegisterClass regtype, string asm>
2334 : I<(outs regtype:$Rt), (ins am_ldrlit:$label),
2335 asm, "\t$Rt, $label", "", []>,
2339 let Inst{31-30} = opc;
2340 let Inst{29-27} = 0b011;
2342 let Inst{25-24} = 0b00;
2343 let Inst{23-5} = label;
2347 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2348 class PrefetchLiteral<bits<2> opc, bit V, string asm, list<dag> pat>
2349 : I<(outs), (ins prfop:$Rt, am_ldrlit:$label),
2350 asm, "\t$Rt, $label", "", pat>,
2354 let Inst{31-30} = opc;
2355 let Inst{29-27} = 0b011;
2357 let Inst{25-24} = 0b00;
2358 let Inst{23-5} = label;
2363 // Load/store register offset
2366 def ro_Xindexed8 : ComplexPattern<i64, 4, "SelectAddrModeXRO<8>", []>;
2367 def ro_Xindexed16 : ComplexPattern<i64, 4, "SelectAddrModeXRO<16>", []>;
2368 def ro_Xindexed32 : ComplexPattern<i64, 4, "SelectAddrModeXRO<32>", []>;
2369 def ro_Xindexed64 : ComplexPattern<i64, 4, "SelectAddrModeXRO<64>", []>;
2370 def ro_Xindexed128 : ComplexPattern<i64, 4, "SelectAddrModeXRO<128>", []>;
2372 def ro_Windexed8 : ComplexPattern<i64, 4, "SelectAddrModeWRO<8>", []>;
2373 def ro_Windexed16 : ComplexPattern<i64, 4, "SelectAddrModeWRO<16>", []>;
2374 def ro_Windexed32 : ComplexPattern<i64, 4, "SelectAddrModeWRO<32>", []>;
2375 def ro_Windexed64 : ComplexPattern<i64, 4, "SelectAddrModeWRO<64>", []>;
2376 def ro_Windexed128 : ComplexPattern<i64, 4, "SelectAddrModeWRO<128>", []>;
2378 class MemExtendOperand<string Reg, int Width> : AsmOperandClass {
2379 let Name = "Mem" # Reg # "Extend" # Width;
2380 let PredicateMethod = "isMem" # Reg # "Extend<" # Width # ">";
2381 let RenderMethod = "addMemExtendOperands";
2382 let DiagnosticType = "InvalidMemory" # Reg # "Extend" # Width;
2385 def MemWExtend8Operand : MemExtendOperand<"W", 8> {
2386 // The address "[x0, x1, lsl #0]" actually maps to the variant which performs
2387 // the trivial shift.
2388 let RenderMethod = "addMemExtend8Operands";
2390 def MemWExtend16Operand : MemExtendOperand<"W", 16>;
2391 def MemWExtend32Operand : MemExtendOperand<"W", 32>;
2392 def MemWExtend64Operand : MemExtendOperand<"W", 64>;
2393 def MemWExtend128Operand : MemExtendOperand<"W", 128>;
2395 def MemXExtend8Operand : MemExtendOperand<"X", 8> {
2396 // The address "[x0, x1, lsl #0]" actually maps to the variant which performs
2397 // the trivial shift.
2398 let RenderMethod = "addMemExtend8Operands";
2400 def MemXExtend16Operand : MemExtendOperand<"X", 16>;
2401 def MemXExtend32Operand : MemExtendOperand<"X", 32>;
2402 def MemXExtend64Operand : MemExtendOperand<"X", 64>;
2403 def MemXExtend128Operand : MemExtendOperand<"X", 128>;
2405 class ro_extend<AsmOperandClass ParserClass, string Reg, int Width>
2407 let ParserMatchClass = ParserClass;
2408 let PrintMethod = "printMemExtend<'" # Reg # "', " # Width # ">";
2409 let DecoderMethod = "DecodeMemExtend";
2410 let EncoderMethod = "getMemExtendOpValue";
2411 let MIOperandInfo = (ops i32imm:$signed, i32imm:$doshift);
2414 def ro_Wextend8 : ro_extend<MemWExtend8Operand, "w", 8>;
2415 def ro_Wextend16 : ro_extend<MemWExtend16Operand, "w", 16>;
2416 def ro_Wextend32 : ro_extend<MemWExtend32Operand, "w", 32>;
2417 def ro_Wextend64 : ro_extend<MemWExtend64Operand, "w", 64>;
2418 def ro_Wextend128 : ro_extend<MemWExtend128Operand, "w", 128>;
2420 def ro_Xextend8 : ro_extend<MemXExtend8Operand, "x", 8>;
2421 def ro_Xextend16 : ro_extend<MemXExtend16Operand, "x", 16>;
2422 def ro_Xextend32 : ro_extend<MemXExtend32Operand, "x", 32>;
2423 def ro_Xextend64 : ro_extend<MemXExtend64Operand, "x", 64>;
2424 def ro_Xextend128 : ro_extend<MemXExtend128Operand, "x", 128>;
2426 class ROAddrMode<ComplexPattern windex, ComplexPattern xindex,
2427 Operand wextend, Operand xextend> {
2428 // CodeGen-level pattern covering the entire addressing mode.
2429 ComplexPattern Wpat = windex;
2430 ComplexPattern Xpat = xindex;
2432 // Asm-level Operand covering the valid "uxtw #3" style syntax.
2433 Operand Wext = wextend;
2434 Operand Xext = xextend;
2437 def ro8 : ROAddrMode<ro_Windexed8, ro_Xindexed8, ro_Wextend8, ro_Xextend8>;
2438 def ro16 : ROAddrMode<ro_Windexed16, ro_Xindexed16, ro_Wextend16, ro_Xextend16>;
2439 def ro32 : ROAddrMode<ro_Windexed32, ro_Xindexed32, ro_Wextend32, ro_Xextend32>;
2440 def ro64 : ROAddrMode<ro_Windexed64, ro_Xindexed64, ro_Wextend64, ro_Xextend64>;
2441 def ro128 : ROAddrMode<ro_Windexed128, ro_Xindexed128, ro_Wextend128,
2444 class LoadStore8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2445 string asm, dag ins, dag outs, list<dag> pat>
2446 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
2451 let Inst{31-30} = sz;
2452 let Inst{29-27} = 0b111;
2454 let Inst{25-24} = 0b00;
2455 let Inst{23-22} = opc;
2457 let Inst{20-16} = Rm;
2458 let Inst{15} = extend{1}; // sign extend Rm?
2460 let Inst{12} = extend{0}; // do shift?
2461 let Inst{11-10} = 0b10;
2466 class ROInstAlias<string asm, RegisterClass regtype, Instruction INST>
2467 : InstAlias<asm # " $Rt, [$Rn, $Rm]",
2468 (INST regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, 0, 0)>;
2470 multiclass Load8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2471 string asm, ValueType Ty, SDPatternOperator loadop> {
2472 let AddedComplexity = 10 in
2473 def roW : LoadStore8RO<sz, V, opc, regtype, asm,
2475 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend8:$extend),
2476 [(set (Ty regtype:$Rt),
2477 (loadop (ro_Windexed8 GPR64sp:$Rn, GPR32:$Rm,
2478 ro_Wextend8:$extend)))]>,
2479 Sched<[WriteLDIdx, ReadAdrBase]> {
2483 let AddedComplexity = 10 in
2484 def roX : LoadStore8RO<sz, V, opc, regtype, asm,
2486 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend8:$extend),
2487 [(set (Ty regtype:$Rt),
2488 (loadop (ro_Xindexed8 GPR64sp:$Rn, GPR64:$Rm,
2489 ro_Xextend8:$extend)))]>,
2490 Sched<[WriteLDIdx, ReadAdrBase]> {
2494 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2497 multiclass Store8RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2498 string asm, ValueType Ty, SDPatternOperator storeop> {
2499 let AddedComplexity = 10 in
2500 def roW : LoadStore8RO<sz, V, opc, regtype, asm, (outs),
2501 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend8:$extend),
2502 [(storeop (Ty regtype:$Rt),
2503 (ro_Windexed8 GPR64sp:$Rn, GPR32:$Rm,
2504 ro_Wextend8:$extend))]>,
2505 Sched<[WriteSTIdx, ReadAdrBase]> {
2509 let AddedComplexity = 10 in
2510 def roX : LoadStore8RO<sz, V, opc, regtype, asm, (outs),
2511 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend8:$extend),
2512 [(storeop (Ty regtype:$Rt),
2513 (ro_Xindexed8 GPR64sp:$Rn, GPR64:$Rm,
2514 ro_Xextend8:$extend))]>,
2515 Sched<[WriteSTIdx, ReadAdrBase]> {
2519 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2522 class LoadStore16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2523 string asm, dag ins, dag outs, list<dag> pat>
2524 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
2529 let Inst{31-30} = sz;
2530 let Inst{29-27} = 0b111;
2532 let Inst{25-24} = 0b00;
2533 let Inst{23-22} = opc;
2535 let Inst{20-16} = Rm;
2536 let Inst{15} = extend{1}; // sign extend Rm?
2538 let Inst{12} = extend{0}; // do shift?
2539 let Inst{11-10} = 0b10;
2544 multiclass Load16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2545 string asm, ValueType Ty, SDPatternOperator loadop> {
2546 let AddedComplexity = 10 in
2547 def roW : LoadStore16RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2548 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend16:$extend),
2549 [(set (Ty regtype:$Rt),
2550 (loadop (ro_Windexed16 GPR64sp:$Rn, GPR32:$Rm,
2551 ro_Wextend16:$extend)))]>,
2552 Sched<[WriteLDIdx, ReadAdrBase]> {
2556 let AddedComplexity = 10 in
2557 def roX : LoadStore16RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2558 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend16:$extend),
2559 [(set (Ty regtype:$Rt),
2560 (loadop (ro_Xindexed16 GPR64sp:$Rn, GPR64:$Rm,
2561 ro_Xextend16:$extend)))]>,
2562 Sched<[WriteLDIdx, ReadAdrBase]> {
2566 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2569 multiclass Store16RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2570 string asm, ValueType Ty, SDPatternOperator storeop> {
2571 let AddedComplexity = 10 in
2572 def roW : LoadStore16RO<sz, V, opc, regtype, asm, (outs),
2573 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend16:$extend),
2574 [(storeop (Ty regtype:$Rt),
2575 (ro_Windexed16 GPR64sp:$Rn, GPR32:$Rm,
2576 ro_Wextend16:$extend))]>,
2577 Sched<[WriteSTIdx, ReadAdrBase]> {
2581 let AddedComplexity = 10 in
2582 def roX : LoadStore16RO<sz, V, opc, regtype, asm, (outs),
2583 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend16:$extend),
2584 [(storeop (Ty regtype:$Rt),
2585 (ro_Xindexed16 GPR64sp:$Rn, GPR64:$Rm,
2586 ro_Xextend16:$extend))]>,
2587 Sched<[WriteSTIdx, ReadAdrBase]> {
2591 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2594 class LoadStore32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2595 string asm, dag ins, dag outs, list<dag> pat>
2596 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
2601 let Inst{31-30} = sz;
2602 let Inst{29-27} = 0b111;
2604 let Inst{25-24} = 0b00;
2605 let Inst{23-22} = opc;
2607 let Inst{20-16} = Rm;
2608 let Inst{15} = extend{1}; // sign extend Rm?
2610 let Inst{12} = extend{0}; // do shift?
2611 let Inst{11-10} = 0b10;
2616 multiclass Load32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2617 string asm, ValueType Ty, SDPatternOperator loadop> {
2618 let AddedComplexity = 10 in
2619 def roW : LoadStore32RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2620 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend32:$extend),
2621 [(set (Ty regtype:$Rt),
2622 (loadop (ro_Windexed32 GPR64sp:$Rn, GPR32:$Rm,
2623 ro_Wextend32:$extend)))]>,
2624 Sched<[WriteLDIdx, ReadAdrBase]> {
2628 let AddedComplexity = 10 in
2629 def roX : LoadStore32RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2630 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend32:$extend),
2631 [(set (Ty regtype:$Rt),
2632 (loadop (ro_Xindexed32 GPR64sp:$Rn, GPR64:$Rm,
2633 ro_Xextend32:$extend)))]>,
2634 Sched<[WriteLDIdx, ReadAdrBase]> {
2638 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2641 multiclass Store32RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2642 string asm, ValueType Ty, SDPatternOperator storeop> {
2643 let AddedComplexity = 10 in
2644 def roW : LoadStore32RO<sz, V, opc, regtype, asm, (outs),
2645 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend32:$extend),
2646 [(storeop (Ty regtype:$Rt),
2647 (ro_Windexed32 GPR64sp:$Rn, GPR32:$Rm,
2648 ro_Wextend32:$extend))]>,
2649 Sched<[WriteSTIdx, ReadAdrBase]> {
2653 let AddedComplexity = 10 in
2654 def roX : LoadStore32RO<sz, V, opc, regtype, asm, (outs),
2655 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend32:$extend),
2656 [(storeop (Ty regtype:$Rt),
2657 (ro_Xindexed32 GPR64sp:$Rn, GPR64:$Rm,
2658 ro_Xextend32:$extend))]>,
2659 Sched<[WriteSTIdx, ReadAdrBase]> {
2663 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2666 class LoadStore64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2667 string asm, dag ins, dag outs, list<dag> pat>
2668 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
2673 let Inst{31-30} = sz;
2674 let Inst{29-27} = 0b111;
2676 let Inst{25-24} = 0b00;
2677 let Inst{23-22} = opc;
2679 let Inst{20-16} = Rm;
2680 let Inst{15} = extend{1}; // sign extend Rm?
2682 let Inst{12} = extend{0}; // do shift?
2683 let Inst{11-10} = 0b10;
2688 multiclass Load64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2689 string asm, ValueType Ty, SDPatternOperator loadop> {
2690 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2691 def roW : LoadStore64RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2692 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend),
2693 [(set (Ty regtype:$Rt),
2694 (loadop (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
2695 ro_Wextend64:$extend)))]>,
2696 Sched<[WriteLDIdx, ReadAdrBase]> {
2700 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2701 def roX : LoadStore64RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2702 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend),
2703 [(set (Ty regtype:$Rt),
2704 (loadop (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
2705 ro_Xextend64:$extend)))]>,
2706 Sched<[WriteLDIdx, ReadAdrBase]> {
2710 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2713 multiclass Store64RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2714 string asm, ValueType Ty, SDPatternOperator storeop> {
2715 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2716 def roW : LoadStore64RO<sz, V, opc, regtype, asm, (outs),
2717 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend),
2718 [(storeop (Ty regtype:$Rt),
2719 (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
2720 ro_Wextend64:$extend))]>,
2721 Sched<[WriteSTIdx, ReadAdrBase]> {
2725 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2726 def roX : LoadStore64RO<sz, V, opc, regtype, asm, (outs),
2727 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend),
2728 [(storeop (Ty regtype:$Rt),
2729 (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
2730 ro_Xextend64:$extend))]>,
2731 Sched<[WriteSTIdx, ReadAdrBase]> {
2735 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2738 class LoadStore128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2739 string asm, dag ins, dag outs, list<dag> pat>
2740 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
2745 let Inst{31-30} = sz;
2746 let Inst{29-27} = 0b111;
2748 let Inst{25-24} = 0b00;
2749 let Inst{23-22} = opc;
2751 let Inst{20-16} = Rm;
2752 let Inst{15} = extend{1}; // sign extend Rm?
2754 let Inst{12} = extend{0}; // do shift?
2755 let Inst{11-10} = 0b10;
2760 multiclass Load128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2761 string asm, ValueType Ty, SDPatternOperator loadop> {
2762 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2763 def roW : LoadStore128RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2764 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend),
2765 [(set (Ty regtype:$Rt),
2766 (loadop (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2767 ro_Wextend128:$extend)))]>,
2768 Sched<[WriteLDIdx, ReadAdrBase]> {
2772 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2773 def roX : LoadStore128RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
2774 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend128:$extend),
2775 [(set (Ty regtype:$Rt),
2776 (loadop (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2777 ro_Xextend128:$extend)))]>,
2778 Sched<[WriteLDIdx, ReadAdrBase]> {
2782 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2785 multiclass Store128RO<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2786 string asm, ValueType Ty, SDPatternOperator storeop> {
2787 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2788 def roW : LoadStore128RO<sz, V, opc, regtype, asm, (outs),
2789 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend),
2790 [(storeop (Ty regtype:$Rt),
2791 (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2792 ro_Wextend128:$extend))]>,
2793 Sched<[WriteSTIdx, ReadAdrBase]> {
2797 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2798 def roX : LoadStore128RO<sz, V, opc, regtype, asm, (outs),
2799 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend128:$extend),
2800 [(storeop (Ty regtype:$Rt),
2801 (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2802 ro_Xextend128:$extend))]>,
2803 Sched<[WriteSTIdx, ReadAdrBase]> {
2807 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
2810 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2811 class BasePrefetchRO<bits<2> sz, bit V, bits<2> opc, dag outs, dag ins,
2812 string asm, list<dag> pat>
2813 : I<outs, ins, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat>,
2819 let Inst{31-30} = sz;
2820 let Inst{29-27} = 0b111;
2822 let Inst{25-24} = 0b00;
2823 let Inst{23-22} = opc;
2825 let Inst{20-16} = Rm;
2826 let Inst{15} = extend{1}; // sign extend Rm?
2828 let Inst{12} = extend{0}; // do shift?
2829 let Inst{11-10} = 0b10;
2834 multiclass PrefetchRO<bits<2> sz, bit V, bits<2> opc, string asm> {
2835 def roW : BasePrefetchRO<sz, V, opc, (outs),
2836 (ins prfop:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend),
2837 asm, [(AArch64Prefetch imm:$Rt,
2838 (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
2839 ro_Wextend64:$extend))]> {
2843 def roX : BasePrefetchRO<sz, V, opc, (outs),
2844 (ins prfop:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend),
2845 asm, [(AArch64Prefetch imm:$Rt,
2846 (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
2847 ro_Xextend64:$extend))]> {
2851 def : InstAlias<"prfm $Rt, [$Rn, $Rm]",
2852 (!cast<Instruction>(NAME # "roX") prfop:$Rt,
2853 GPR64sp:$Rn, GPR64:$Rm, 0, 0)>;
2857 // Load/store unscaled immediate
2860 def am_unscaled8 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled8", []>;
2861 def am_unscaled16 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled16", []>;
2862 def am_unscaled32 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled32", []>;
2863 def am_unscaled64 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled64", []>;
2864 def am_unscaled128 :ComplexPattern<i64, 2, "SelectAddrModeUnscaled128", []>;
2866 class BaseLoadStoreUnscale<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2867 string asm, list<dag> pattern>
2868 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]", "", pattern> {
2872 let Inst{31-30} = sz;
2873 let Inst{29-27} = 0b111;
2875 let Inst{25-24} = 0b00;
2876 let Inst{23-22} = opc;
2878 let Inst{20-12} = offset;
2879 let Inst{11-10} = 0b00;
2883 let DecoderMethod = "DecodeSignedLdStInstruction";
2886 multiclass LoadUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2887 string asm, list<dag> pattern> {
2888 let AddedComplexity = 1 in // try this before LoadUI
2889 def i : BaseLoadStoreUnscale<sz, V, opc, (outs regtype:$Rt),
2890 (ins GPR64sp:$Rn, simm9:$offset), asm, pattern>,
2893 def : InstAlias<asm # " $Rt, [$Rn]",
2894 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
2897 multiclass StoreUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2898 string asm, list<dag> pattern> {
2899 let AddedComplexity = 1 in // try this before StoreUI
2900 def i : BaseLoadStoreUnscale<sz, V, opc, (outs),
2901 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
2905 def : InstAlias<asm # " $Rt, [$Rn]",
2906 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
2909 multiclass PrefetchUnscaled<bits<2> sz, bit V, bits<2> opc, string asm,
2911 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2912 def i : BaseLoadStoreUnscale<sz, V, opc, (outs),
2913 (ins prfop:$Rt, GPR64sp:$Rn, simm9:$offset),
2917 def : InstAlias<asm # " $Rt, [$Rn]",
2918 (!cast<Instruction>(NAME # "i") prfop:$Rt, GPR64sp:$Rn, 0)>;
2922 // Load/store unscaled immediate, unprivileged
2925 class BaseLoadStoreUnprivileged<bits<2> sz, bit V, bits<2> opc,
2926 dag oops, dag iops, string asm>
2927 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]", "", []> {
2931 let Inst{31-30} = sz;
2932 let Inst{29-27} = 0b111;
2934 let Inst{25-24} = 0b00;
2935 let Inst{23-22} = opc;
2937 let Inst{20-12} = offset;
2938 let Inst{11-10} = 0b10;
2942 let DecoderMethod = "DecodeSignedLdStInstruction";
2945 multiclass LoadUnprivileged<bits<2> sz, bit V, bits<2> opc,
2946 RegisterClass regtype, string asm> {
2947 let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in
2948 def i : BaseLoadStoreUnprivileged<sz, V, opc, (outs regtype:$Rt),
2949 (ins GPR64sp:$Rn, simm9:$offset), asm>,
2952 def : InstAlias<asm # " $Rt, [$Rn]",
2953 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
2956 multiclass StoreUnprivileged<bits<2> sz, bit V, bits<2> opc,
2957 RegisterClass regtype, string asm> {
2958 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
2959 def i : BaseLoadStoreUnprivileged<sz, V, opc, (outs),
2960 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
2964 def : InstAlias<asm # " $Rt, [$Rn]",
2965 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
2969 // Load/store pre-indexed
2972 class BaseLoadStorePreIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2973 string asm, string cstr, list<dag> pat>
2974 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]!", cstr, pat> {
2978 let Inst{31-30} = sz;
2979 let Inst{29-27} = 0b111;
2981 let Inst{25-24} = 0;
2982 let Inst{23-22} = opc;
2984 let Inst{20-12} = offset;
2985 let Inst{11-10} = 0b11;
2989 let DecoderMethod = "DecodeSignedLdStInstruction";
2992 let hasSideEffects = 0 in {
2993 let mayStore = 0, mayLoad = 1 in
2994 class LoadPreIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
2996 : BaseLoadStorePreIdx<sz, V, opc,
2997 (outs GPR64sp:$wback, regtype:$Rt),
2998 (ins GPR64sp:$Rn, simm9:$offset), asm,
2999 "$Rn = $wback,@earlyclobber $wback", []>,
3000 Sched<[WriteLD, WriteAdr]>;
3002 let mayStore = 1, mayLoad = 0 in
3003 class StorePreIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
3004 string asm, SDPatternOperator storeop, ValueType Ty>
3005 : BaseLoadStorePreIdx<sz, V, opc,
3006 (outs GPR64sp:$wback),
3007 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3008 asm, "$Rn = $wback,@earlyclobber $wback",
3009 [(set GPR64sp:$wback,
3010 (storeop (Ty regtype:$Rt), GPR64sp:$Rn, simm9:$offset))]>,
3011 Sched<[WriteAdr, WriteST]>;
3012 } // hasSideEffects = 0
3015 // Load/store post-indexed
3018 class BaseLoadStorePostIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
3019 string asm, string cstr, list<dag> pat>
3020 : I<oops, iops, asm, "\t$Rt, [$Rn], $offset", cstr, pat> {
3024 let Inst{31-30} = sz;
3025 let Inst{29-27} = 0b111;
3027 let Inst{25-24} = 0b00;
3028 let Inst{23-22} = opc;
3030 let Inst{20-12} = offset;
3031 let Inst{11-10} = 0b01;
3035 let DecoderMethod = "DecodeSignedLdStInstruction";
3038 let hasSideEffects = 0 in {
3039 let mayStore = 0, mayLoad = 1 in
3040 class LoadPostIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
3042 : BaseLoadStorePostIdx<sz, V, opc,
3043 (outs GPR64sp:$wback, regtype:$Rt),
3044 (ins GPR64sp:$Rn, simm9:$offset),
3045 asm, "$Rn = $wback,@earlyclobber $wback", []>,
3046 Sched<[WriteLD, WriteI]>;
3048 let mayStore = 1, mayLoad = 0 in
3049 class StorePostIdx<bits<2> sz, bit V, bits<2> opc, RegisterClass regtype,
3050 string asm, SDPatternOperator storeop, ValueType Ty>
3051 : BaseLoadStorePostIdx<sz, V, opc,
3052 (outs GPR64sp:$wback),
3053 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3054 asm, "$Rn = $wback,@earlyclobber $wback",
3055 [(set GPR64sp:$wback,
3056 (storeop (Ty regtype:$Rt), GPR64sp:$Rn, simm9:$offset))]>,
3057 Sched<[WriteAdr, WriteST, ReadAdrBase]>;
3058 } // hasSideEffects = 0
3065 // (indexed, offset)
3067 class BaseLoadStorePairOffset<bits<2> opc, bit V, bit L, dag oops, dag iops,
3069 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn, $offset]", "", []> {
3074 let Inst{31-30} = opc;
3075 let Inst{29-27} = 0b101;
3077 let Inst{25-23} = 0b010;
3079 let Inst{21-15} = offset;
3080 let Inst{14-10} = Rt2;
3084 let DecoderMethod = "DecodePairLdStInstruction";
3087 multiclass LoadPairOffset<bits<2> opc, bit V, RegisterClass regtype,
3088 Operand indextype, string asm> {
3089 let hasSideEffects = 0, mayStore = 0, mayLoad = 1 in
3090 def i : BaseLoadStorePairOffset<opc, V, 1,
3091 (outs regtype:$Rt, regtype:$Rt2),
3092 (ins GPR64sp:$Rn, indextype:$offset), asm>,
3093 Sched<[WriteLD, WriteLDHi]>;
3095 def : InstAlias<asm # " $Rt, $Rt2, [$Rn]",
3096 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3101 multiclass StorePairOffset<bits<2> opc, bit V, RegisterClass regtype,
3102 Operand indextype, string asm> {
3103 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
3104 def i : BaseLoadStorePairOffset<opc, V, 0, (outs),
3105 (ins regtype:$Rt, regtype:$Rt2,
3106 GPR64sp:$Rn, indextype:$offset),
3110 def : InstAlias<asm # " $Rt, $Rt2, [$Rn]",
3111 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3116 class BaseLoadStorePairPreIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
3118 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn, $offset]!", "$Rn = $wback,@earlyclobber $wback", []> {
3123 let Inst{31-30} = opc;
3124 let Inst{29-27} = 0b101;
3126 let Inst{25-23} = 0b011;
3128 let Inst{21-15} = offset;
3129 let Inst{14-10} = Rt2;
3133 let DecoderMethod = "DecodePairLdStInstruction";
3136 let hasSideEffects = 0 in {
3137 let mayStore = 0, mayLoad = 1 in
3138 class LoadPairPreIdx<bits<2> opc, bit V, RegisterClass regtype,
3139 Operand indextype, string asm>
3140 : BaseLoadStorePairPreIdx<opc, V, 1,
3141 (outs GPR64sp:$wback, regtype:$Rt, regtype:$Rt2),
3142 (ins GPR64sp:$Rn, indextype:$offset), asm>,
3143 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
3145 let mayStore = 1, mayLoad = 0 in
3146 class StorePairPreIdx<bits<2> opc, bit V, RegisterClass regtype,
3147 Operand indextype, string asm>
3148 : BaseLoadStorePairPreIdx<opc, V, 0, (outs GPR64sp:$wback),
3149 (ins regtype:$Rt, regtype:$Rt2,
3150 GPR64sp:$Rn, indextype:$offset),
3152 Sched<[WriteAdr, WriteSTP]>;
3153 } // hasSideEffects = 0
3157 class BaseLoadStorePairPostIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
3159 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn], $offset", "$Rn = $wback,@earlyclobber $wback", []> {
3164 let Inst{31-30} = opc;
3165 let Inst{29-27} = 0b101;
3167 let Inst{25-23} = 0b001;
3169 let Inst{21-15} = offset;
3170 let Inst{14-10} = Rt2;
3174 let DecoderMethod = "DecodePairLdStInstruction";
3177 let hasSideEffects = 0 in {
3178 let mayStore = 0, mayLoad = 1 in
3179 class LoadPairPostIdx<bits<2> opc, bit V, RegisterClass regtype,
3180 Operand idxtype, string asm>
3181 : BaseLoadStorePairPostIdx<opc, V, 1,
3182 (outs GPR64sp:$wback, regtype:$Rt, regtype:$Rt2),
3183 (ins GPR64sp:$Rn, idxtype:$offset), asm>,
3184 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
3186 let mayStore = 1, mayLoad = 0 in
3187 class StorePairPostIdx<bits<2> opc, bit V, RegisterClass regtype,
3188 Operand idxtype, string asm>
3189 : BaseLoadStorePairPostIdx<opc, V, 0, (outs),
3190 (ins GPR64sp:$wback, regtype:$Rt, regtype:$Rt2,
3191 GPR64sp:$Rn, idxtype:$offset),
3193 Sched<[WriteAdr, WriteSTP]>;
3194 } // hasSideEffects = 0
3198 class BaseLoadStorePairNoAlloc<bits<2> opc, bit V, bit L, dag oops, dag iops,
3200 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn, $offset]", "", []> {
3205 let Inst{31-30} = opc;
3206 let Inst{29-27} = 0b101;
3208 let Inst{25-23} = 0b000;
3210 let Inst{21-15} = offset;
3211 let Inst{14-10} = Rt2;
3215 let DecoderMethod = "DecodePairLdStInstruction";
3218 multiclass LoadPairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3219 Operand indextype, string asm> {
3220 let hasSideEffects = 0, mayStore = 0, mayLoad = 1 in
3221 def i : BaseLoadStorePairNoAlloc<opc, V, 1,
3222 (outs regtype:$Rt, regtype:$Rt2),
3223 (ins GPR64sp:$Rn, indextype:$offset), asm>,
3224 Sched<[WriteLD, WriteLDHi]>;
3227 def : InstAlias<asm # "\t$Rt, $Rt2, [$Rn]",
3228 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3232 multiclass StorePairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3233 Operand indextype, string asm> {
3234 let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in
3235 def i : BaseLoadStorePairNoAlloc<opc, V, 0, (outs),
3236 (ins regtype:$Rt, regtype:$Rt2,
3237 GPR64sp:$Rn, indextype:$offset),
3241 def : InstAlias<asm # "\t$Rt, $Rt2, [$Rn]",
3242 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3247 // Load/store exclusive
3250 // True exclusive operations write to and/or read from the system's exclusive
3251 // monitors, which as far as a compiler is concerned can be modelled as a
3252 // random shared memory address. Hence LoadExclusive mayStore.
3254 // Since these instructions have the undefined register bits set to 1 in
3255 // their canonical form, we need a post encoder method to set those bits
3256 // to 1 when encoding these instructions. We do this using the
3257 // fixLoadStoreExclusive function. This function has template parameters:
3259 // fixLoadStoreExclusive<int hasRs, int hasRt2>
3261 // hasRs indicates that the instruction uses the Rs field, so we won't set
3262 // it to 1 (and the same for Rt2). We don't need template parameters for
3263 // the other register fields since Rt and Rn are always used.
3265 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
3266 class BaseLoadStoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3267 dag oops, dag iops, string asm, string operands>
3268 : I<oops, iops, asm, operands, "", []> {
3269 let Inst{31-30} = sz;
3270 let Inst{29-24} = 0b001000;
3276 let DecoderMethod = "DecodeExclusiveLdStInstruction";
3279 // Neither Rs nor Rt2 operands.
3280 class LoadStoreExclusiveSimple<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3281 dag oops, dag iops, string asm, string operands>
3282 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, oops, iops, asm, operands> {
3288 let PostEncoderMethod = "fixLoadStoreExclusive<0,0>";
3291 // Simple load acquires don't set the exclusive monitor
3292 let mayLoad = 1, mayStore = 0 in
3293 class LoadAcquire<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3294 RegisterClass regtype, string asm>
3295 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
3296 (ins GPR64sp0:$Rn), asm, "\t$Rt, [$Rn]">,
3299 class LoadExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3300 RegisterClass regtype, string asm>
3301 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
3302 (ins GPR64sp0:$Rn), asm, "\t$Rt, [$Rn]">,
3305 class LoadExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3306 RegisterClass regtype, string asm>
3307 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
3308 (outs regtype:$Rt, regtype:$Rt2),
3309 (ins GPR64sp0:$Rn), asm,
3310 "\t$Rt, $Rt2, [$Rn]">,
3311 Sched<[WriteLD, WriteLDHi]> {
3315 let Inst{14-10} = Rt2;
3319 let PostEncoderMethod = "fixLoadStoreExclusive<0,1>";
3322 // Simple store release operations do not check the exclusive monitor.
3323 let mayLoad = 0, mayStore = 1 in
3324 class StoreRelease<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3325 RegisterClass regtype, string asm>
3326 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs),
3327 (ins regtype:$Rt, GPR64sp0:$Rn),
3328 asm, "\t$Rt, [$Rn]">,
3331 let mayLoad = 1, mayStore = 1 in
3332 class StoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3333 RegisterClass regtype, string asm>
3334 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, (outs GPR32:$Ws),
3335 (ins regtype:$Rt, GPR64sp0:$Rn),
3336 asm, "\t$Ws, $Rt, [$Rn]">,
3341 let Inst{20-16} = Ws;
3345 let Constraints = "@earlyclobber $Ws";
3346 let PostEncoderMethod = "fixLoadStoreExclusive<1,0>";
3349 class StoreExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3350 RegisterClass regtype, string asm>
3351 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
3353 (ins regtype:$Rt, regtype:$Rt2, GPR64sp0:$Rn),
3354 asm, "\t$Ws, $Rt, $Rt2, [$Rn]">,
3360 let Inst{20-16} = Ws;
3361 let Inst{14-10} = Rt2;
3365 let Constraints = "@earlyclobber $Ws";
3369 // Exception generation
3372 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
3373 class ExceptionGeneration<bits<3> op1, bits<2> ll, string asm>
3374 : I<(outs), (ins imm0_65535:$imm), asm, "\t$imm", "", []>,
3377 let Inst{31-24} = 0b11010100;
3378 let Inst{23-21} = op1;
3379 let Inst{20-5} = imm;
3380 let Inst{4-2} = 0b000;
3384 let Predicates = [HasFPARMv8] in {
3387 // Floating point to integer conversion
3390 class BaseFPToIntegerUnscaled<bits<2> type, bits<2> rmode, bits<3> opcode,
3391 RegisterClass srcType, RegisterClass dstType,
3392 string asm, list<dag> pattern>
3393 : I<(outs dstType:$Rd), (ins srcType:$Rn),
3394 asm, "\t$Rd, $Rn", "", pattern>,
3395 Sched<[WriteFCvt]> {
3398 let Inst{30-29} = 0b00;
3399 let Inst{28-24} = 0b11110;
3400 let Inst{23-22} = type;
3402 let Inst{20-19} = rmode;
3403 let Inst{18-16} = opcode;
3404 let Inst{15-10} = 0;
3409 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3410 class BaseFPToInteger<bits<2> type, bits<2> rmode, bits<3> opcode,
3411 RegisterClass srcType, RegisterClass dstType,
3412 Operand immType, string asm, list<dag> pattern>
3413 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
3414 asm, "\t$Rd, $Rn, $scale", "", pattern>,
3415 Sched<[WriteFCvt]> {
3419 let Inst{30-29} = 0b00;
3420 let Inst{28-24} = 0b11110;
3421 let Inst{23-22} = type;
3423 let Inst{20-19} = rmode;
3424 let Inst{18-16} = opcode;
3425 let Inst{15-10} = scale;
3430 multiclass FPToIntegerUnscaled<bits<2> rmode, bits<3> opcode, string asm,
3431 SDPatternOperator OpN> {
3432 // Unscaled single-precision to 32-bit
3433 def UWSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR32, asm,
3434 [(set GPR32:$Rd, (OpN FPR32:$Rn))]> {
3435 let Inst{31} = 0; // 32-bit GPR flag
3438 // Unscaled single-precision to 64-bit
3439 def UXSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR64, asm,
3440 [(set GPR64:$Rd, (OpN FPR32:$Rn))]> {
3441 let Inst{31} = 1; // 64-bit GPR flag
3444 // Unscaled double-precision to 32-bit
3445 def UWDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR32, asm,
3446 [(set GPR32:$Rd, (OpN (f64 FPR64:$Rn)))]> {
3447 let Inst{31} = 0; // 32-bit GPR flag
3450 // Unscaled double-precision to 64-bit
3451 def UXDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR64, asm,
3452 [(set GPR64:$Rd, (OpN (f64 FPR64:$Rn)))]> {
3453 let Inst{31} = 1; // 64-bit GPR flag
3457 multiclass FPToIntegerScaled<bits<2> rmode, bits<3> opcode, string asm,
3458 SDPatternOperator OpN> {
3459 // Scaled single-precision to 32-bit
3460 def SWSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR32,
3461 fixedpoint_f32_i32, asm,
3462 [(set GPR32:$Rd, (OpN (fmul FPR32:$Rn,
3463 fixedpoint_f32_i32:$scale)))]> {
3464 let Inst{31} = 0; // 32-bit GPR flag
3468 // Scaled single-precision to 64-bit
3469 def SXSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR64,
3470 fixedpoint_f32_i64, asm,
3471 [(set GPR64:$Rd, (OpN (fmul FPR32:$Rn,
3472 fixedpoint_f32_i64:$scale)))]> {
3473 let Inst{31} = 1; // 64-bit GPR flag
3476 // Scaled double-precision to 32-bit
3477 def SWDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR32,
3478 fixedpoint_f64_i32, asm,
3479 [(set GPR32:$Rd, (OpN (fmul FPR64:$Rn,
3480 fixedpoint_f64_i32:$scale)))]> {
3481 let Inst{31} = 0; // 32-bit GPR flag
3485 // Scaled double-precision to 64-bit
3486 def SXDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR64,
3487 fixedpoint_f64_i64, asm,
3488 [(set GPR64:$Rd, (OpN (fmul FPR64:$Rn,
3489 fixedpoint_f64_i64:$scale)))]> {
3490 let Inst{31} = 1; // 64-bit GPR flag
3495 // Integer to floating point conversion
3498 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
3499 class BaseIntegerToFP<bit isUnsigned,
3500 RegisterClass srcType, RegisterClass dstType,
3501 Operand immType, string asm, list<dag> pattern>
3502 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
3503 asm, "\t$Rd, $Rn, $scale", "", pattern>,
3504 Sched<[WriteFCvt]> {
3508 let Inst{30-23} = 0b00111100;
3509 let Inst{21-17} = 0b00001;
3510 let Inst{16} = isUnsigned;
3511 let Inst{15-10} = scale;
3516 class BaseIntegerToFPUnscaled<bit isUnsigned,
3517 RegisterClass srcType, RegisterClass dstType,
3518 ValueType dvt, string asm, SDNode node>
3519 : I<(outs dstType:$Rd), (ins srcType:$Rn),
3520 asm, "\t$Rd, $Rn", "", [(set (dvt dstType:$Rd), (node srcType:$Rn))]>,
3521 Sched<[WriteFCvt]> {
3525 let Inst{30-23} = 0b00111100;
3526 let Inst{21-17} = 0b10001;
3527 let Inst{16} = isUnsigned;
3528 let Inst{15-10} = 0b000000;
3533 multiclass IntegerToFP<bit isUnsigned, string asm, SDNode node> {
3535 def UWSri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR32, f32, asm, node> {
3536 let Inst{31} = 0; // 32-bit GPR flag
3537 let Inst{22} = 0; // 32-bit FPR flag
3540 def UWDri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR64, f64, asm, node> {
3541 let Inst{31} = 0; // 32-bit GPR flag
3542 let Inst{22} = 1; // 64-bit FPR flag
3545 def UXSri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR32, f32, asm, node> {
3546 let Inst{31} = 1; // 64-bit GPR flag
3547 let Inst{22} = 0; // 32-bit FPR flag
3550 def UXDri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR64, f64, asm, node> {
3551 let Inst{31} = 1; // 64-bit GPR flag
3552 let Inst{22} = 1; // 64-bit FPR flag
3556 def SWSri: BaseIntegerToFP<isUnsigned, GPR32, FPR32, fixedpoint_f32_i32, asm,
3558 (fdiv (node GPR32:$Rn),
3559 fixedpoint_f32_i32:$scale))]> {
3560 let Inst{31} = 0; // 32-bit GPR flag
3561 let Inst{22} = 0; // 32-bit FPR flag
3565 def SWDri: BaseIntegerToFP<isUnsigned, GPR32, FPR64, fixedpoint_f64_i32, asm,
3567 (fdiv (node GPR32:$Rn),
3568 fixedpoint_f64_i32:$scale))]> {
3569 let Inst{31} = 0; // 32-bit GPR flag
3570 let Inst{22} = 1; // 64-bit FPR flag
3574 def SXSri: BaseIntegerToFP<isUnsigned, GPR64, FPR32, fixedpoint_f32_i64, asm,
3576 (fdiv (node GPR64:$Rn),
3577 fixedpoint_f32_i64:$scale))]> {
3578 let Inst{31} = 1; // 64-bit GPR flag
3579 let Inst{22} = 0; // 32-bit FPR flag
3582 def SXDri: BaseIntegerToFP<isUnsigned, GPR64, FPR64, fixedpoint_f64_i64, asm,
3584 (fdiv (node GPR64:$Rn),
3585 fixedpoint_f64_i64:$scale))]> {
3586 let Inst{31} = 1; // 64-bit GPR flag
3587 let Inst{22} = 1; // 64-bit FPR flag
3592 // Unscaled integer <-> floating point conversion (i.e. FMOV)
3595 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3596 class BaseUnscaledConversion<bits<2> rmode, bits<3> opcode,
3597 RegisterClass srcType, RegisterClass dstType,
3599 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "",
3600 // We use COPY_TO_REGCLASS for these bitconvert operations.
3601 // copyPhysReg() expands the resultant COPY instructions after
3602 // regalloc is done. This gives greater freedom for the allocator
3603 // and related passes (coalescing, copy propagation, et. al.) to
3604 // be more effective.
3605 [/*(set (dvt dstType:$Rd), (bitconvert (svt srcType:$Rn)))*/]>,
3606 Sched<[WriteFCopy]> {
3609 let Inst{30-23} = 0b00111100;
3611 let Inst{20-19} = rmode;
3612 let Inst{18-16} = opcode;
3613 let Inst{15-10} = 0b000000;
3618 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3619 class BaseUnscaledConversionToHigh<bits<2> rmode, bits<3> opcode,
3620 RegisterClass srcType, RegisterOperand dstType, string asm,
3622 : I<(outs dstType:$Rd), (ins srcType:$Rn, VectorIndex1:$idx), asm,
3623 "{\t$Rd"#kind#"$idx, $Rn|"#kind#"\t$Rd$idx, $Rn}", "", []>,
3624 Sched<[WriteFCopy]> {
3627 let Inst{30-23} = 0b00111101;
3629 let Inst{20-19} = rmode;
3630 let Inst{18-16} = opcode;
3631 let Inst{15-10} = 0b000000;
3635 let DecoderMethod = "DecodeFMOVLaneInstruction";
3638 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3639 class BaseUnscaledConversionFromHigh<bits<2> rmode, bits<3> opcode,
3640 RegisterOperand srcType, RegisterClass dstType, string asm,
3642 : I<(outs dstType:$Rd), (ins srcType:$Rn, VectorIndex1:$idx), asm,
3643 "{\t$Rd, $Rn"#kind#"$idx|"#kind#"\t$Rd, $Rn$idx}", "", []>,
3644 Sched<[WriteFCopy]> {
3647 let Inst{30-23} = 0b00111101;
3649 let Inst{20-19} = rmode;
3650 let Inst{18-16} = opcode;
3651 let Inst{15-10} = 0b000000;
3655 let DecoderMethod = "DecodeFMOVLaneInstruction";
3660 multiclass UnscaledConversion<string asm> {
3661 def WSr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR32, asm> {
3662 let Inst{31} = 0; // 32-bit GPR flag
3663 let Inst{22} = 0; // 32-bit FPR flag
3666 def XDr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR64, asm> {
3667 let Inst{31} = 1; // 64-bit GPR flag
3668 let Inst{22} = 1; // 64-bit FPR flag
3671 def SWr : BaseUnscaledConversion<0b00, 0b110, FPR32, GPR32, asm> {
3672 let Inst{31} = 0; // 32-bit GPR flag
3673 let Inst{22} = 0; // 32-bit FPR flag
3676 def DXr : BaseUnscaledConversion<0b00, 0b110, FPR64, GPR64, asm> {
3677 let Inst{31} = 1; // 64-bit GPR flag
3678 let Inst{22} = 1; // 64-bit FPR flag
3681 def XDHighr : BaseUnscaledConversionToHigh<0b01, 0b111, GPR64, V128,
3687 def DXHighr : BaseUnscaledConversionFromHigh<0b01, 0b110, V128, GPR64,
3695 // Floating point conversion
3698 class BaseFPConversion<bits<2> type, bits<2> opcode, RegisterClass dstType,
3699 RegisterClass srcType, string asm, list<dag> pattern>
3700 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", pattern>,
3701 Sched<[WriteFCvt]> {
3704 let Inst{31-24} = 0b00011110;
3705 let Inst{23-22} = type;
3706 let Inst{21-17} = 0b10001;
3707 let Inst{16-15} = opcode;
3708 let Inst{14-10} = 0b10000;
3713 multiclass FPConversion<string asm> {
3714 // Double-precision to Half-precision
3715 def HDr : BaseFPConversion<0b01, 0b11, FPR16, FPR64, asm,
3716 [(set FPR16:$Rd, (fround FPR64:$Rn))]>;
3718 // Double-precision to Single-precision
3719 def SDr : BaseFPConversion<0b01, 0b00, FPR32, FPR64, asm,
3720 [(set FPR32:$Rd, (fround FPR64:$Rn))]>;
3722 // Half-precision to Double-precision
3723 def DHr : BaseFPConversion<0b11, 0b01, FPR64, FPR16, asm,
3724 [(set FPR64:$Rd, (fextend FPR16:$Rn))]>;
3726 // Half-precision to Single-precision
3727 def SHr : BaseFPConversion<0b11, 0b00, FPR32, FPR16, asm,
3728 [(set FPR32:$Rd, (fextend FPR16:$Rn))]>;
3730 // Single-precision to Double-precision
3731 def DSr : BaseFPConversion<0b00, 0b01, FPR64, FPR32, asm,
3732 [(set FPR64:$Rd, (fextend FPR32:$Rn))]>;
3734 // Single-precision to Half-precision
3735 def HSr : BaseFPConversion<0b00, 0b11, FPR16, FPR32, asm,
3736 [(set FPR16:$Rd, (fround FPR32:$Rn))]>;
3740 // Single operand floating point data processing
3743 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3744 class BaseSingleOperandFPData<bits<4> opcode, RegisterClass regtype,
3745 ValueType vt, string asm, SDPatternOperator node>
3746 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
3747 [(set (vt regtype:$Rd), (node (vt regtype:$Rn)))]>,
3751 let Inst{31-23} = 0b000111100;
3752 let Inst{21-19} = 0b100;
3753 let Inst{18-15} = opcode;
3754 let Inst{14-10} = 0b10000;
3759 multiclass SingleOperandFPData<bits<4> opcode, string asm,
3760 SDPatternOperator node = null_frag> {
3761 def Sr : BaseSingleOperandFPData<opcode, FPR32, f32, asm, node> {
3762 let Inst{22} = 0; // 32-bit size flag
3765 def Dr : BaseSingleOperandFPData<opcode, FPR64, f64, asm, node> {
3766 let Inst{22} = 1; // 64-bit size flag
3771 // Two operand floating point data processing
3774 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3775 class BaseTwoOperandFPData<bits<4> opcode, RegisterClass regtype,
3776 string asm, list<dag> pat>
3777 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
3778 asm, "\t$Rd, $Rn, $Rm", "", pat>,
3783 let Inst{31-23} = 0b000111100;
3785 let Inst{20-16} = Rm;
3786 let Inst{15-12} = opcode;
3787 let Inst{11-10} = 0b10;
3792 multiclass TwoOperandFPData<bits<4> opcode, string asm,
3793 SDPatternOperator node = null_frag> {
3794 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
3795 [(set (f32 FPR32:$Rd),
3796 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]> {
3797 let Inst{22} = 0; // 32-bit size flag
3800 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
3801 [(set (f64 FPR64:$Rd),
3802 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]> {
3803 let Inst{22} = 1; // 64-bit size flag
3807 multiclass TwoOperandFPDataNeg<bits<4> opcode, string asm, SDNode node> {
3808 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
3809 [(set FPR32:$Rd, (fneg (node FPR32:$Rn, (f32 FPR32:$Rm))))]> {
3810 let Inst{22} = 0; // 32-bit size flag
3813 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
3814 [(set FPR64:$Rd, (fneg (node FPR64:$Rn, (f64 FPR64:$Rm))))]> {
3815 let Inst{22} = 1; // 64-bit size flag
3821 // Three operand floating point data processing
3824 class BaseThreeOperandFPData<bit isNegated, bit isSub,
3825 RegisterClass regtype, string asm, list<dag> pat>
3826 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, regtype: $Ra),
3827 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pat>,
3828 Sched<[WriteFMul]> {
3833 let Inst{31-23} = 0b000111110;
3834 let Inst{21} = isNegated;
3835 let Inst{20-16} = Rm;
3836 let Inst{15} = isSub;
3837 let Inst{14-10} = Ra;
3842 multiclass ThreeOperandFPData<bit isNegated, bit isSub,string asm,
3843 SDPatternOperator node> {
3844 def Srrr : BaseThreeOperandFPData<isNegated, isSub, FPR32, asm,
3846 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm), (f32 FPR32:$Ra)))]> {
3847 let Inst{22} = 0; // 32-bit size flag
3850 def Drrr : BaseThreeOperandFPData<isNegated, isSub, FPR64, asm,
3852 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm), (f64 FPR64:$Ra)))]> {
3853 let Inst{22} = 1; // 64-bit size flag
3858 // Floating point data comparisons
3861 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3862 class BaseOneOperandFPComparison<bit signalAllNans,
3863 RegisterClass regtype, string asm,
3865 : I<(outs), (ins regtype:$Rn), asm, "\t$Rn, #0.0", "", pat>,
3866 Sched<[WriteFCmp]> {
3868 let Inst{31-23} = 0b000111100;
3871 let Inst{15-10} = 0b001000;
3873 let Inst{4} = signalAllNans;
3874 let Inst{3-0} = 0b1000;
3876 // Rm should be 0b00000 canonically, but we need to accept any value.
3877 let PostEncoderMethod = "fixOneOperandFPComparison";
3880 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3881 class BaseTwoOperandFPComparison<bit signalAllNans, RegisterClass regtype,
3882 string asm, list<dag> pat>
3883 : I<(outs), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rn, $Rm", "", pat>,
3884 Sched<[WriteFCmp]> {
3887 let Inst{31-23} = 0b000111100;
3889 let Inst{20-16} = Rm;
3890 let Inst{15-10} = 0b001000;
3892 let Inst{4} = signalAllNans;
3893 let Inst{3-0} = 0b0000;
3896 multiclass FPComparison<bit signalAllNans, string asm,
3897 SDPatternOperator OpNode = null_frag> {
3898 let Defs = [NZCV] in {
3899 def Srr : BaseTwoOperandFPComparison<signalAllNans, FPR32, asm,
3900 [(OpNode FPR32:$Rn, (f32 FPR32:$Rm)), (implicit NZCV)]> {
3904 def Sri : BaseOneOperandFPComparison<signalAllNans, FPR32, asm,
3905 [(OpNode (f32 FPR32:$Rn), fpimm0), (implicit NZCV)]> {
3909 def Drr : BaseTwoOperandFPComparison<signalAllNans, FPR64, asm,
3910 [(OpNode FPR64:$Rn, (f64 FPR64:$Rm)), (implicit NZCV)]> {
3914 def Dri : BaseOneOperandFPComparison<signalAllNans, FPR64, asm,
3915 [(OpNode (f64 FPR64:$Rn), fpimm0), (implicit NZCV)]> {
3922 // Floating point conditional comparisons
3925 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
3926 class BaseFPCondComparison<bit signalAllNans,
3927 RegisterClass regtype, string asm>
3928 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm0_15:$nzcv, ccode:$cond),
3929 asm, "\t$Rn, $Rm, $nzcv, $cond", "", []>,
3930 Sched<[WriteFCmp]> {
3936 let Inst{31-23} = 0b000111100;
3938 let Inst{20-16} = Rm;
3939 let Inst{15-12} = cond;
3940 let Inst{11-10} = 0b01;
3942 let Inst{4} = signalAllNans;
3943 let Inst{3-0} = nzcv;
3946 multiclass FPCondComparison<bit signalAllNans, string asm> {
3947 let Defs = [NZCV], Uses = [NZCV] in {
3948 def Srr : BaseFPCondComparison<signalAllNans, FPR32, asm> {
3952 def Drr : BaseFPCondComparison<signalAllNans, FPR64, asm> {
3955 } // Defs = [NZCV], Uses = [NZCV]
3959 // Floating point conditional select
3962 class BaseFPCondSelect<RegisterClass regtype, ValueType vt, string asm>
3963 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
3964 asm, "\t$Rd, $Rn, $Rm, $cond", "",
3966 (AArch64csel (vt regtype:$Rn), regtype:$Rm,
3967 (i32 imm:$cond), NZCV))]>,
3974 let Inst{31-23} = 0b000111100;
3976 let Inst{20-16} = Rm;
3977 let Inst{15-12} = cond;
3978 let Inst{11-10} = 0b11;
3983 multiclass FPCondSelect<string asm> {
3984 let Uses = [NZCV] in {
3985 def Srrr : BaseFPCondSelect<FPR32, f32, asm> {
3989 def Drrr : BaseFPCondSelect<FPR64, f64, asm> {
3996 // Floating move immediate
3999 class BaseFPMoveImmediate<RegisterClass regtype, Operand fpimmtype, string asm>
4000 : I<(outs regtype:$Rd), (ins fpimmtype:$imm), asm, "\t$Rd, $imm", "",
4001 [(set regtype:$Rd, fpimmtype:$imm)]>,
4002 Sched<[WriteFImm]> {
4005 let Inst{31-23} = 0b000111100;
4007 let Inst{20-13} = imm;
4008 let Inst{12-5} = 0b10000000;
4012 multiclass FPMoveImmediate<string asm> {
4013 def Si : BaseFPMoveImmediate<FPR32, fpimm32, asm> {
4017 def Di : BaseFPMoveImmediate<FPR64, fpimm64, asm> {
4021 } // end of 'let Predicates = [HasFPARMv8]'
4023 //----------------------------------------------------------------------------
4025 //----------------------------------------------------------------------------
4027 let Predicates = [HasNEON] in {
4029 //----------------------------------------------------------------------------
4030 // AdvSIMD three register vector instructions
4031 //----------------------------------------------------------------------------
4033 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4034 class BaseSIMDThreeSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4035 RegisterOperand regtype, string asm, string kind,
4037 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
4038 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
4039 "|" # kind # "\t$Rd, $Rn, $Rm|}", "", pattern>,
4047 let Inst{28-24} = 0b01110;
4048 let Inst{23-22} = size;
4050 let Inst{20-16} = Rm;
4051 let Inst{15-11} = opcode;
4057 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4058 class BaseSIMDThreeSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4059 RegisterOperand regtype, string asm, string kind,
4061 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm), asm,
4062 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
4063 "|" # kind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
4071 let Inst{28-24} = 0b01110;
4072 let Inst{23-22} = size;
4074 let Inst{20-16} = Rm;
4075 let Inst{15-11} = opcode;
4081 // All operand sizes distinguished in the encoding.
4082 multiclass SIMDThreeSameVector<bit U, bits<5> opc, string asm,
4083 SDPatternOperator OpNode> {
4084 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
4086 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4087 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
4089 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
4090 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
4092 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4093 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
4095 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4096 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
4098 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4099 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
4101 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4102 def v2i64 : BaseSIMDThreeSameVector<1, U, 0b11, opc, V128,
4104 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
4107 // As above, but D sized elements unsupported.
4108 multiclass SIMDThreeSameVectorBHS<bit U, bits<5> opc, string asm,
4109 SDPatternOperator OpNode> {
4110 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
4112 [(set V64:$Rd, (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))]>;
4113 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
4115 [(set V128:$Rd, (v16i8 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm))))]>;
4116 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
4118 [(set V64:$Rd, (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))]>;
4119 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
4121 [(set V128:$Rd, (v8i16 (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm))))]>;
4122 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
4124 [(set V64:$Rd, (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))]>;
4125 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
4127 [(set V128:$Rd, (v4i32 (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm))))]>;
4130 multiclass SIMDThreeSameVectorBHSTied<bit U, bits<5> opc, string asm,
4131 SDPatternOperator OpNode> {
4132 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, 0b00, opc, V64,
4134 [(set (v8i8 V64:$dst),
4135 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4136 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, 0b00, opc, V128,
4138 [(set (v16i8 V128:$dst),
4139 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
4140 def v4i16 : BaseSIMDThreeSameVectorTied<0, U, 0b01, opc, V64,
4142 [(set (v4i16 V64:$dst),
4143 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4144 def v8i16 : BaseSIMDThreeSameVectorTied<1, U, 0b01, opc, V128,
4146 [(set (v8i16 V128:$dst),
4147 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4148 def v2i32 : BaseSIMDThreeSameVectorTied<0, U, 0b10, opc, V64,
4150 [(set (v2i32 V64:$dst),
4151 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4152 def v4i32 : BaseSIMDThreeSameVectorTied<1, U, 0b10, opc, V128,
4154 [(set (v4i32 V128:$dst),
4155 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4158 // As above, but only B sized elements supported.
4159 multiclass SIMDThreeSameVectorB<bit U, bits<5> opc, string asm,
4160 SDPatternOperator OpNode> {
4161 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b00, opc, V64,
4163 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4164 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b00, opc, V128,
4166 [(set (v16i8 V128:$Rd),
4167 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
4170 // As above, but only S and D sized floating point elements supported.
4171 multiclass SIMDThreeSameVectorFP<bit U, bit S, bits<5> opc,
4172 string asm, SDPatternOperator OpNode> {
4173 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0}, opc, V64,
4175 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4176 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0}, opc, V128,
4178 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4179 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,1}, opc, V128,
4181 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4184 multiclass SIMDThreeSameVectorFPCmp<bit U, bit S, bits<5> opc,
4186 SDPatternOperator OpNode> {
4187 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0}, opc, V64,
4189 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4190 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0}, opc, V128,
4192 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4193 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,1}, opc, V128,
4195 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4198 multiclass SIMDThreeSameVectorFPTied<bit U, bit S, bits<5> opc,
4199 string asm, SDPatternOperator OpNode> {
4200 def v2f32 : BaseSIMDThreeSameVectorTied<0, U, {S,0}, opc, V64,
4202 [(set (v2f32 V64:$dst),
4203 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
4204 def v4f32 : BaseSIMDThreeSameVectorTied<1, U, {S,0}, opc, V128,
4206 [(set (v4f32 V128:$dst),
4207 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
4208 def v2f64 : BaseSIMDThreeSameVectorTied<1, U, {S,1}, opc, V128,
4210 [(set (v2f64 V128:$dst),
4211 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
4214 // As above, but D and B sized elements unsupported.
4215 multiclass SIMDThreeSameVectorHS<bit U, bits<5> opc, string asm,
4216 SDPatternOperator OpNode> {
4217 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b01, opc, V64,
4219 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4220 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b01, opc, V128,
4222 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4223 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b10, opc, V64,
4225 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4226 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b10, opc, V128,
4228 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4231 // Logical three vector ops share opcode bits, and only use B sized elements.
4232 multiclass SIMDLogicalThreeVector<bit U, bits<2> size, string asm,
4233 SDPatternOperator OpNode = null_frag> {
4234 def v8i8 : BaseSIMDThreeSameVector<0, U, size, 0b00011, V64,
4236 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn, V64:$Rm))]>;
4237 def v16i8 : BaseSIMDThreeSameVector<1, U, size, 0b00011, V128,
4239 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn, V128:$Rm))]>;
4241 def : Pat<(v4i16 (OpNode V64:$LHS, V64:$RHS)),
4242 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4243 def : Pat<(v2i32 (OpNode V64:$LHS, V64:$RHS)),
4244 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4245 def : Pat<(v1i64 (OpNode V64:$LHS, V64:$RHS)),
4246 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
4248 def : Pat<(v8i16 (OpNode V128:$LHS, V128:$RHS)),
4249 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4250 def : Pat<(v4i32 (OpNode V128:$LHS, V128:$RHS)),
4251 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4252 def : Pat<(v2i64 (OpNode V128:$LHS, V128:$RHS)),
4253 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
4256 multiclass SIMDLogicalThreeVectorTied<bit U, bits<2> size,
4257 string asm, SDPatternOperator OpNode> {
4258 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, size, 0b00011, V64,
4260 [(set (v8i8 V64:$dst),
4261 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4262 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, size, 0b00011, V128,
4264 [(set (v16i8 V128:$dst),
4265 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
4266 (v16i8 V128:$Rm)))]>;
4268 def : Pat<(v4i16 (OpNode (v4i16 V64:$LHS), (v4i16 V64:$MHS),
4270 (!cast<Instruction>(NAME#"v8i8")
4271 V64:$LHS, V64:$MHS, V64:$RHS)>;
4272 def : Pat<(v2i32 (OpNode (v2i32 V64:$LHS), (v2i32 V64:$MHS),
4274 (!cast<Instruction>(NAME#"v8i8")
4275 V64:$LHS, V64:$MHS, V64:$RHS)>;
4276 def : Pat<(v1i64 (OpNode (v1i64 V64:$LHS), (v1i64 V64:$MHS),
4278 (!cast<Instruction>(NAME#"v8i8")
4279 V64:$LHS, V64:$MHS, V64:$RHS)>;
4281 def : Pat<(v8i16 (OpNode (v8i16 V128:$LHS), (v8i16 V128:$MHS),
4282 (v8i16 V128:$RHS))),
4283 (!cast<Instruction>(NAME#"v16i8")
4284 V128:$LHS, V128:$MHS, V128:$RHS)>;
4285 def : Pat<(v4i32 (OpNode (v4i32 V128:$LHS), (v4i32 V128:$MHS),
4286 (v4i32 V128:$RHS))),
4287 (!cast<Instruction>(NAME#"v16i8")
4288 V128:$LHS, V128:$MHS, V128:$RHS)>;
4289 def : Pat<(v2i64 (OpNode (v2i64 V128:$LHS), (v2i64 V128:$MHS),
4290 (v2i64 V128:$RHS))),
4291 (!cast<Instruction>(NAME#"v16i8")
4292 V128:$LHS, V128:$MHS, V128:$RHS)>;
4296 //----------------------------------------------------------------------------
4297 // AdvSIMD two register vector instructions.
4298 //----------------------------------------------------------------------------
4300 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4301 class BaseSIMDTwoSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4302 RegisterOperand regtype, string asm, string dstkind,
4303 string srckind, list<dag> pattern>
4304 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
4305 "{\t$Rd" # dstkind # ", $Rn" # srckind #
4306 "|" # dstkind # "\t$Rd, $Rn}", "", pattern>,
4313 let Inst{28-24} = 0b01110;
4314 let Inst{23-22} = size;
4315 let Inst{21-17} = 0b10000;
4316 let Inst{16-12} = opcode;
4317 let Inst{11-10} = 0b10;
4322 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4323 class BaseSIMDTwoSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4324 RegisterOperand regtype, string asm, string dstkind,
4325 string srckind, list<dag> pattern>
4326 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn), asm,
4327 "{\t$Rd" # dstkind # ", $Rn" # srckind #
4328 "|" # dstkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
4335 let Inst{28-24} = 0b01110;
4336 let Inst{23-22} = size;
4337 let Inst{21-17} = 0b10000;
4338 let Inst{16-12} = opcode;
4339 let Inst{11-10} = 0b10;
4344 // Supports B, H, and S element sizes.
4345 multiclass SIMDTwoVectorBHS<bit U, bits<5> opc, string asm,
4346 SDPatternOperator OpNode> {
4347 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4349 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4350 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4351 asm, ".16b", ".16b",
4352 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4353 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4355 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4356 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4358 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4359 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4361 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4362 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4364 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4367 class BaseSIMDVectorLShiftLongBySize<bit Q, bits<2> size,
4368 RegisterOperand regtype, string asm, string dstkind,
4369 string srckind, string amount>
4370 : I<(outs V128:$Rd), (ins regtype:$Rn), asm,
4371 "{\t$Rd" # dstkind # ", $Rn" # srckind # ", #" # amount #
4372 "|" # dstkind # "\t$Rd, $Rn, #" # amount # "}", "", []>,
4378 let Inst{29-24} = 0b101110;
4379 let Inst{23-22} = size;
4380 let Inst{21-10} = 0b100001001110;
4385 multiclass SIMDVectorLShiftLongBySizeBHS {
4386 let hasSideEffects = 0 in {
4387 def v8i8 : BaseSIMDVectorLShiftLongBySize<0, 0b00, V64,
4388 "shll", ".8h", ".8b", "8">;
4389 def v16i8 : BaseSIMDVectorLShiftLongBySize<1, 0b00, V128,
4390 "shll2", ".8h", ".16b", "8">;
4391 def v4i16 : BaseSIMDVectorLShiftLongBySize<0, 0b01, V64,
4392 "shll", ".4s", ".4h", "16">;
4393 def v8i16 : BaseSIMDVectorLShiftLongBySize<1, 0b01, V128,
4394 "shll2", ".4s", ".8h", "16">;
4395 def v2i32 : BaseSIMDVectorLShiftLongBySize<0, 0b10, V64,
4396 "shll", ".2d", ".2s", "32">;
4397 def v4i32 : BaseSIMDVectorLShiftLongBySize<1, 0b10, V128,
4398 "shll2", ".2d", ".4s", "32">;
4402 // Supports all element sizes.
4403 multiclass SIMDLongTwoVector<bit U, bits<5> opc, string asm,
4404 SDPatternOperator OpNode> {
4405 def v8i8_v4i16 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4407 [(set (v4i16 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4408 def v16i8_v8i16 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4410 [(set (v8i16 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4411 def v4i16_v2i32 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4413 [(set (v2i32 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4414 def v8i16_v4i32 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4416 [(set (v4i32 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4417 def v2i32_v1i64 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4419 [(set (v1i64 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4420 def v4i32_v2i64 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4422 [(set (v2i64 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4425 multiclass SIMDLongTwoVectorTied<bit U, bits<5> opc, string asm,
4426 SDPatternOperator OpNode> {
4427 def v8i8_v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, V64,
4429 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd),
4431 def v16i8_v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, V128,
4433 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd),
4434 (v16i8 V128:$Rn)))]>;
4435 def v4i16_v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, V64,
4437 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd),
4438 (v4i16 V64:$Rn)))]>;
4439 def v8i16_v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, V128,
4441 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd),
4442 (v8i16 V128:$Rn)))]>;
4443 def v2i32_v1i64 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, V64,
4445 [(set (v1i64 V64:$dst), (OpNode (v1i64 V64:$Rd),
4446 (v2i32 V64:$Rn)))]>;
4447 def v4i32_v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, V128,
4449 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd),
4450 (v4i32 V128:$Rn)))]>;
4453 // Supports all element sizes, except 1xD.
4454 multiclass SIMDTwoVectorBHSDTied<bit U, bits<5> opc, string asm,
4455 SDPatternOperator OpNode> {
4456 def v8i8 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, V64,
4458 [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn)))]>;
4459 def v16i8 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, V128,
4460 asm, ".16b", ".16b",
4461 [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
4462 def v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, V64,
4464 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn)))]>;
4465 def v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, V128,
4467 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn)))]>;
4468 def v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, V64,
4470 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn)))]>;
4471 def v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, V128,
4473 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
4474 def v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b11, opc, V128,
4476 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn)))]>;
4479 multiclass SIMDTwoVectorBHSD<bit U, bits<5> opc, string asm,
4480 SDPatternOperator OpNode = null_frag> {
4481 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4483 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4484 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4485 asm, ".16b", ".16b",
4486 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4487 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4489 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
4490 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4492 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4493 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, V64,
4495 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4496 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, V128,
4498 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4499 def v2i64 : BaseSIMDTwoSameVector<1, U, 0b11, opc, V128,
4501 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4505 // Supports only B element sizes.
4506 multiclass SIMDTwoVectorB<bit U, bits<2> size, bits<5> opc, string asm,
4507 SDPatternOperator OpNode> {
4508 def v8i8 : BaseSIMDTwoSameVector<0, U, size, opc, V64,
4510 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
4511 def v16i8 : BaseSIMDTwoSameVector<1, U, size, opc, V128,
4512 asm, ".16b", ".16b",
4513 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
4517 // Supports only B and H element sizes.
4518 multiclass SIMDTwoVectorBH<bit U, bits<5> opc, string asm,
4519 SDPatternOperator OpNode> {
4520 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, V64,
4522 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn))]>;
4523 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, V128,
4524 asm, ".16b", ".16b",
4525 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn))]>;
4526 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, V64,
4528 [(set (v4i16 V64:$Rd), (OpNode V64:$Rn))]>;
4529 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, V128,
4531 [(set (v8i16 V128:$Rd), (OpNode V128:$Rn))]>;
4534 // Supports only S and D element sizes, uses high bit of the size field
4535 // as an extra opcode bit.
4536 multiclass SIMDTwoVectorFP<bit U, bit S, bits<5> opc, string asm,
4537 SDPatternOperator OpNode> {
4538 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4540 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
4541 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4543 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
4544 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4546 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4549 // Supports only S element size.
4550 multiclass SIMDTwoVectorS<bit U, bit S, bits<5> opc, string asm,
4551 SDPatternOperator OpNode> {
4552 def v2i32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4554 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4555 def v4i32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4557 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4561 multiclass SIMDTwoVectorFPToInt<bit U, bit S, bits<5> opc, string asm,
4562 SDPatternOperator OpNode> {
4563 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4565 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
4566 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4568 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
4569 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4571 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4574 multiclass SIMDTwoVectorIntToFP<bit U, bit S, bits<5> opc, string asm,
4575 SDPatternOperator OpNode> {
4576 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, V64,
4578 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
4579 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, V128,
4581 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4582 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, V128,
4584 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4588 class BaseSIMDMixedTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4589 RegisterOperand inreg, RegisterOperand outreg,
4590 string asm, string outkind, string inkind,
4592 : I<(outs outreg:$Rd), (ins inreg:$Rn), asm,
4593 "{\t$Rd" # outkind # ", $Rn" # inkind #
4594 "|" # outkind # "\t$Rd, $Rn}", "", pattern>,
4601 let Inst{28-24} = 0b01110;
4602 let Inst{23-22} = size;
4603 let Inst{21-17} = 0b10000;
4604 let Inst{16-12} = opcode;
4605 let Inst{11-10} = 0b10;
4610 class BaseSIMDMixedTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4611 RegisterOperand inreg, RegisterOperand outreg,
4612 string asm, string outkind, string inkind,
4614 : I<(outs outreg:$dst), (ins outreg:$Rd, inreg:$Rn), asm,
4615 "{\t$Rd" # outkind # ", $Rn" # inkind #
4616 "|" # outkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
4623 let Inst{28-24} = 0b01110;
4624 let Inst{23-22} = size;
4625 let Inst{21-17} = 0b10000;
4626 let Inst{16-12} = opcode;
4627 let Inst{11-10} = 0b10;
4632 multiclass SIMDMixedTwoVector<bit U, bits<5> opc, string asm,
4633 SDPatternOperator OpNode> {
4634 def v8i8 : BaseSIMDMixedTwoVector<0, U, 0b00, opc, V128, V64,
4636 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
4637 def v16i8 : BaseSIMDMixedTwoVectorTied<1, U, 0b00, opc, V128, V128,
4638 asm#"2", ".16b", ".8h", []>;
4639 def v4i16 : BaseSIMDMixedTwoVector<0, U, 0b01, opc, V128, V64,
4641 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
4642 def v8i16 : BaseSIMDMixedTwoVectorTied<1, U, 0b01, opc, V128, V128,
4643 asm#"2", ".8h", ".4s", []>;
4644 def v2i32 : BaseSIMDMixedTwoVector<0, U, 0b10, opc, V128, V64,
4646 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
4647 def v4i32 : BaseSIMDMixedTwoVectorTied<1, U, 0b10, opc, V128, V128,
4648 asm#"2", ".4s", ".2d", []>;
4650 def : Pat<(concat_vectors (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn))),
4651 (!cast<Instruction>(NAME # "v16i8")
4652 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4653 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn))),
4654 (!cast<Instruction>(NAME # "v8i16")
4655 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4656 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn))),
4657 (!cast<Instruction>(NAME # "v4i32")
4658 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4661 class BaseSIMDCmpTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4662 RegisterOperand regtype,
4663 string asm, string kind, string zero,
4664 ValueType dty, ValueType sty, SDNode OpNode>
4665 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
4666 "{\t$Rd" # kind # ", $Rn" # kind # ", #" # zero #
4667 "|" # kind # "\t$Rd, $Rn, #" # zero # "}", "",
4668 [(set (dty regtype:$Rd), (OpNode (sty regtype:$Rn)))]>,
4675 let Inst{28-24} = 0b01110;
4676 let Inst{23-22} = size;
4677 let Inst{21-17} = 0b10000;
4678 let Inst{16-12} = opcode;
4679 let Inst{11-10} = 0b10;
4684 // Comparisons support all element sizes, except 1xD.
4685 multiclass SIMDCmpTwoVector<bit U, bits<5> opc, string asm,
4687 def v8i8rz : BaseSIMDCmpTwoVector<0, U, 0b00, opc, V64,
4689 v8i8, v8i8, OpNode>;
4690 def v16i8rz : BaseSIMDCmpTwoVector<1, U, 0b00, opc, V128,
4692 v16i8, v16i8, OpNode>;
4693 def v4i16rz : BaseSIMDCmpTwoVector<0, U, 0b01, opc, V64,
4695 v4i16, v4i16, OpNode>;
4696 def v8i16rz : BaseSIMDCmpTwoVector<1, U, 0b01, opc, V128,
4698 v8i16, v8i16, OpNode>;
4699 def v2i32rz : BaseSIMDCmpTwoVector<0, U, 0b10, opc, V64,
4701 v2i32, v2i32, OpNode>;
4702 def v4i32rz : BaseSIMDCmpTwoVector<1, U, 0b10, opc, V128,
4704 v4i32, v4i32, OpNode>;
4705 def v2i64rz : BaseSIMDCmpTwoVector<1, U, 0b11, opc, V128,
4707 v2i64, v2i64, OpNode>;
4710 // FP Comparisons support only S and D element sizes.
4711 multiclass SIMDFPCmpTwoVector<bit U, bit S, bits<5> opc,
4712 string asm, SDNode OpNode> {
4714 def v2i32rz : BaseSIMDCmpTwoVector<0, U, {S,0}, opc, V64,
4716 v2i32, v2f32, OpNode>;
4717 def v4i32rz : BaseSIMDCmpTwoVector<1, U, {S,0}, opc, V128,
4719 v4i32, v4f32, OpNode>;
4720 def v2i64rz : BaseSIMDCmpTwoVector<1, U, {S,1}, opc, V128,
4722 v2i64, v2f64, OpNode>;
4724 def : InstAlias<asm # " $Vd.2s, $Vn.2s, #0",
4725 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
4726 def : InstAlias<asm # " $Vd.4s, $Vn.4s, #0",
4727 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
4728 def : InstAlias<asm # " $Vd.2d, $Vn.2d, #0",
4729 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
4730 def : InstAlias<asm # ".2s $Vd, $Vn, #0",
4731 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
4732 def : InstAlias<asm # ".4s $Vd, $Vn, #0",
4733 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
4734 def : InstAlias<asm # ".2d $Vd, $Vn, #0",
4735 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
4738 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4739 class BaseSIMDFPCvtTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
4740 RegisterOperand outtype, RegisterOperand intype,
4741 string asm, string VdTy, string VnTy,
4743 : I<(outs outtype:$Rd), (ins intype:$Rn), asm,
4744 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "", pattern>,
4751 let Inst{28-24} = 0b01110;
4752 let Inst{23-22} = size;
4753 let Inst{21-17} = 0b10000;
4754 let Inst{16-12} = opcode;
4755 let Inst{11-10} = 0b10;
4760 class BaseSIMDFPCvtTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
4761 RegisterOperand outtype, RegisterOperand intype,
4762 string asm, string VdTy, string VnTy,
4764 : I<(outs outtype:$dst), (ins outtype:$Rd, intype:$Rn), asm,
4765 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "$Rd = $dst", pattern>,
4772 let Inst{28-24} = 0b01110;
4773 let Inst{23-22} = size;
4774 let Inst{21-17} = 0b10000;
4775 let Inst{16-12} = opcode;
4776 let Inst{11-10} = 0b10;
4781 multiclass SIMDFPWidenTwoVector<bit U, bit S, bits<5> opc, string asm> {
4782 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V128, V64,
4783 asm, ".4s", ".4h", []>;
4784 def v8i16 : BaseSIMDFPCvtTwoVector<1, U, {S,0}, opc, V128, V128,
4785 asm#"2", ".4s", ".8h", []>;
4786 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V128, V64,
4787 asm, ".2d", ".2s", []>;
4788 def v4i32 : BaseSIMDFPCvtTwoVector<1, U, {S,1}, opc, V128, V128,
4789 asm#"2", ".2d", ".4s", []>;
4792 multiclass SIMDFPNarrowTwoVector<bit U, bit S, bits<5> opc, string asm> {
4793 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V64, V128,
4794 asm, ".4h", ".4s", []>;
4795 def v8i16 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,0}, opc, V128, V128,
4796 asm#"2", ".8h", ".4s", []>;
4797 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
4798 asm, ".2s", ".2d", []>;
4799 def v4i32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
4800 asm#"2", ".4s", ".2d", []>;
4803 multiclass SIMDFPInexactCvtTwoVector<bit U, bit S, bits<5> opc, string asm,
4805 def v2f32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
4807 [(set (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
4808 def v4f32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
4809 asm#"2", ".4s", ".2d", []>;
4811 def : Pat<(concat_vectors (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn))),
4812 (!cast<Instruction>(NAME # "v4f32")
4813 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
4816 //----------------------------------------------------------------------------
4817 // AdvSIMD three register different-size vector instructions.
4818 //----------------------------------------------------------------------------
4820 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4821 class BaseSIMDDifferentThreeVector<bit U, bits<3> size, bits<4> opcode,
4822 RegisterOperand outtype, RegisterOperand intype1,
4823 RegisterOperand intype2, string asm,
4824 string outkind, string inkind1, string inkind2,
4826 : I<(outs outtype:$Rd), (ins intype1:$Rn, intype2:$Rm), asm,
4827 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
4828 "|" # outkind # "\t$Rd, $Rn, $Rm}", "", pattern>,
4834 let Inst{30} = size{0};
4836 let Inst{28-24} = 0b01110;
4837 let Inst{23-22} = size{2-1};
4839 let Inst{20-16} = Rm;
4840 let Inst{15-12} = opcode;
4841 let Inst{11-10} = 0b00;
4846 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4847 class BaseSIMDDifferentThreeVectorTied<bit U, bits<3> size, bits<4> opcode,
4848 RegisterOperand outtype, RegisterOperand intype1,
4849 RegisterOperand intype2, string asm,
4850 string outkind, string inkind1, string inkind2,
4852 : I<(outs outtype:$dst), (ins outtype:$Rd, intype1:$Rn, intype2:$Rm), asm,
4853 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
4854 "|" # outkind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
4860 let Inst{30} = size{0};
4862 let Inst{28-24} = 0b01110;
4863 let Inst{23-22} = size{2-1};
4865 let Inst{20-16} = Rm;
4866 let Inst{15-12} = opcode;
4867 let Inst{11-10} = 0b00;
4872 // FIXME: TableGen doesn't know how to deal with expanded types that also
4873 // change the element count (in this case, placing the results in
4874 // the high elements of the result register rather than the low
4875 // elements). Until that's fixed, we can't code-gen those.
4876 multiclass SIMDNarrowThreeVectorBHS<bit U, bits<4> opc, string asm,
4878 def v8i16_v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4880 asm, ".8b", ".8h", ".8h",
4881 [(set (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
4882 def v8i16_v16i8 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
4884 asm#"2", ".16b", ".8h", ".8h",
4886 def v4i32_v4i16 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4888 asm, ".4h", ".4s", ".4s",
4889 [(set (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
4890 def v4i32_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
4892 asm#"2", ".8h", ".4s", ".4s",
4894 def v2i64_v2i32 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4896 asm, ".2s", ".2d", ".2d",
4897 [(set (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
4898 def v2i64_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
4900 asm#"2", ".4s", ".2d", ".2d",
4904 // Patterns for the '2' variants involve INSERT_SUBREG, which you can't put in
4905 // a version attached to an instruction.
4906 def : Pat<(concat_vectors (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn),
4908 (!cast<Instruction>(NAME # "v8i16_v16i8")
4909 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4910 V128:$Rn, V128:$Rm)>;
4911 def : Pat<(concat_vectors (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn),
4913 (!cast<Instruction>(NAME # "v4i32_v8i16")
4914 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4915 V128:$Rn, V128:$Rm)>;
4916 def : Pat<(concat_vectors (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn),
4918 (!cast<Instruction>(NAME # "v2i64_v4i32")
4919 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4920 V128:$Rn, V128:$Rm)>;
4923 multiclass SIMDDifferentThreeVectorBD<bit U, bits<4> opc, string asm,
4925 def v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4927 asm, ".8h", ".8b", ".8b",
4928 [(set (v8i16 V128:$Rd), (IntOp (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
4929 def v16i8 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4931 asm#"2", ".8h", ".16b", ".16b", []>;
4932 let Predicates = [HasCrypto] in {
4933 def v1i64 : BaseSIMDDifferentThreeVector<U, 0b110, opc,
4935 asm, ".1q", ".1d", ".1d", []>;
4936 def v2i64 : BaseSIMDDifferentThreeVector<U, 0b111, opc,
4938 asm#"2", ".1q", ".2d", ".2d", []>;
4941 def : Pat<(v8i16 (IntOp (v8i8 (extract_high_v16i8 V128:$Rn)),
4942 (v8i8 (extract_high_v16i8 V128:$Rm)))),
4943 (!cast<Instruction>(NAME#"v16i8") V128:$Rn, V128:$Rm)>;
4946 multiclass SIMDLongThreeVectorHS<bit U, bits<4> opc, string asm,
4947 SDPatternOperator OpNode> {
4948 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4950 asm, ".4s", ".4h", ".4h",
4951 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
4952 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4954 asm#"2", ".4s", ".8h", ".8h",
4955 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
4956 (extract_high_v8i16 V128:$Rm)))]>;
4957 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4959 asm, ".2d", ".2s", ".2s",
4960 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
4961 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4963 asm#"2", ".2d", ".4s", ".4s",
4964 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
4965 (extract_high_v4i32 V128:$Rm)))]>;
4968 multiclass SIMDLongThreeVectorBHSabdl<bit U, bits<4> opc, string asm,
4969 SDPatternOperator OpNode = null_frag> {
4970 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
4972 asm, ".8h", ".8b", ".8b",
4973 [(set (v8i16 V128:$Rd),
4974 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))))]>;
4975 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
4977 asm#"2", ".8h", ".16b", ".16b",
4978 [(set (v8i16 V128:$Rd),
4979 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
4980 (extract_high_v16i8 V128:$Rm)))))]>;
4981 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
4983 asm, ".4s", ".4h", ".4h",
4984 [(set (v4i32 V128:$Rd),
4985 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))))]>;
4986 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
4988 asm#"2", ".4s", ".8h", ".8h",
4989 [(set (v4i32 V128:$Rd),
4990 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
4991 (extract_high_v8i16 V128:$Rm)))))]>;
4992 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
4994 asm, ".2d", ".2s", ".2s",
4995 [(set (v2i64 V128:$Rd),
4996 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))))]>;
4997 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
4999 asm#"2", ".2d", ".4s", ".4s",
5000 [(set (v2i64 V128:$Rd),
5001 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
5002 (extract_high_v4i32 V128:$Rm)))))]>;
5005 multiclass SIMDLongThreeVectorTiedBHSabal<bit U, bits<4> opc,
5007 SDPatternOperator OpNode> {
5008 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
5010 asm, ".8h", ".8b", ".8b",
5011 [(set (v8i16 V128:$dst),
5012 (add (v8i16 V128:$Rd),
5013 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))))]>;
5014 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
5016 asm#"2", ".8h", ".16b", ".16b",
5017 [(set (v8i16 V128:$dst),
5018 (add (v8i16 V128:$Rd),
5019 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
5020 (extract_high_v16i8 V128:$Rm))))))]>;
5021 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
5023 asm, ".4s", ".4h", ".4h",
5024 [(set (v4i32 V128:$dst),
5025 (add (v4i32 V128:$Rd),
5026 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))))]>;
5027 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
5029 asm#"2", ".4s", ".8h", ".8h",
5030 [(set (v4i32 V128:$dst),
5031 (add (v4i32 V128:$Rd),
5032 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
5033 (extract_high_v8i16 V128:$Rm))))))]>;
5034 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
5036 asm, ".2d", ".2s", ".2s",
5037 [(set (v2i64 V128:$dst),
5038 (add (v2i64 V128:$Rd),
5039 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))))]>;
5040 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
5042 asm#"2", ".2d", ".4s", ".4s",
5043 [(set (v2i64 V128:$dst),
5044 (add (v2i64 V128:$Rd),
5045 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
5046 (extract_high_v4i32 V128:$Rm))))))]>;
5049 multiclass SIMDLongThreeVectorBHS<bit U, bits<4> opc, string asm,
5050 SDPatternOperator OpNode = null_frag> {
5051 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
5053 asm, ".8h", ".8b", ".8b",
5054 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
5055 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
5057 asm#"2", ".8h", ".16b", ".16b",
5058 [(set (v8i16 V128:$Rd), (OpNode (extract_high_v16i8 V128:$Rn),
5059 (extract_high_v16i8 V128:$Rm)))]>;
5060 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
5062 asm, ".4s", ".4h", ".4h",
5063 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
5064 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
5066 asm#"2", ".4s", ".8h", ".8h",
5067 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
5068 (extract_high_v8i16 V128:$Rm)))]>;
5069 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
5071 asm, ".2d", ".2s", ".2s",
5072 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
5073 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
5075 asm#"2", ".2d", ".4s", ".4s",
5076 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
5077 (extract_high_v4i32 V128:$Rm)))]>;
5080 multiclass SIMDLongThreeVectorTiedBHS<bit U, bits<4> opc,
5082 SDPatternOperator OpNode> {
5083 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
5085 asm, ".8h", ".8b", ".8b",
5086 [(set (v8i16 V128:$dst),
5087 (OpNode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
5088 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
5090 asm#"2", ".8h", ".16b", ".16b",
5091 [(set (v8i16 V128:$dst),
5092 (OpNode (v8i16 V128:$Rd),
5093 (extract_high_v16i8 V128:$Rn),
5094 (extract_high_v16i8 V128:$Rm)))]>;
5095 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
5097 asm, ".4s", ".4h", ".4h",
5098 [(set (v4i32 V128:$dst),
5099 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
5100 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
5102 asm#"2", ".4s", ".8h", ".8h",
5103 [(set (v4i32 V128:$dst),
5104 (OpNode (v4i32 V128:$Rd),
5105 (extract_high_v8i16 V128:$Rn),
5106 (extract_high_v8i16 V128:$Rm)))]>;
5107 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
5109 asm, ".2d", ".2s", ".2s",
5110 [(set (v2i64 V128:$dst),
5111 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
5112 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
5114 asm#"2", ".2d", ".4s", ".4s",
5115 [(set (v2i64 V128:$dst),
5116 (OpNode (v2i64 V128:$Rd),
5117 (extract_high_v4i32 V128:$Rn),
5118 (extract_high_v4i32 V128:$Rm)))]>;
5121 multiclass SIMDLongThreeVectorSQDMLXTiedHS<bit U, bits<4> opc, string asm,
5122 SDPatternOperator Accum> {
5123 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
5125 asm, ".4s", ".4h", ".4h",
5126 [(set (v4i32 V128:$dst),
5127 (Accum (v4i32 V128:$Rd),
5128 (v4i32 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn),
5129 (v4i16 V64:$Rm)))))]>;
5130 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
5132 asm#"2", ".4s", ".8h", ".8h",
5133 [(set (v4i32 V128:$dst),
5134 (Accum (v4i32 V128:$Rd),
5135 (v4i32 (int_aarch64_neon_sqdmull (extract_high_v8i16 V128:$Rn),
5136 (extract_high_v8i16 V128:$Rm)))))]>;
5137 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
5139 asm, ".2d", ".2s", ".2s",
5140 [(set (v2i64 V128:$dst),
5141 (Accum (v2i64 V128:$Rd),
5142 (v2i64 (int_aarch64_neon_sqdmull (v2i32 V64:$Rn),
5143 (v2i32 V64:$Rm)))))]>;
5144 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
5146 asm#"2", ".2d", ".4s", ".4s",
5147 [(set (v2i64 V128:$dst),
5148 (Accum (v2i64 V128:$Rd),
5149 (v2i64 (int_aarch64_neon_sqdmull (extract_high_v4i32 V128:$Rn),
5150 (extract_high_v4i32 V128:$Rm)))))]>;
5153 multiclass SIMDWideThreeVectorBHS<bit U, bits<4> opc, string asm,
5154 SDPatternOperator OpNode> {
5155 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
5157 asm, ".8h", ".8h", ".8b",
5158 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i8 V64:$Rm)))]>;
5159 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
5161 asm#"2", ".8h", ".8h", ".16b",
5162 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
5163 (extract_high_v16i8 V128:$Rm)))]>;
5164 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
5166 asm, ".4s", ".4s", ".4h",
5167 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i16 V64:$Rm)))]>;
5168 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
5170 asm#"2", ".4s", ".4s", ".8h",
5171 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
5172 (extract_high_v8i16 V128:$Rm)))]>;
5173 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
5175 asm, ".2d", ".2d", ".2s",
5176 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i32 V64:$Rm)))]>;
5177 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
5179 asm#"2", ".2d", ".2d", ".4s",
5180 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
5181 (extract_high_v4i32 V128:$Rm)))]>;
5184 //----------------------------------------------------------------------------
5185 // AdvSIMD bitwise extract from vector
5186 //----------------------------------------------------------------------------
5188 class BaseSIMDBitwiseExtract<bit size, RegisterOperand regtype, ValueType vty,
5189 string asm, string kind>
5190 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, i32imm:$imm), asm,
5191 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $imm" #
5192 "|" # kind # "\t$Rd, $Rn, $Rm, $imm}", "",
5193 [(set (vty regtype:$Rd),
5194 (AArch64ext regtype:$Rn, regtype:$Rm, (i32 imm:$imm)))]>,
5201 let Inst{30} = size;
5202 let Inst{29-21} = 0b101110000;
5203 let Inst{20-16} = Rm;
5205 let Inst{14-11} = imm;
5212 multiclass SIMDBitwiseExtract<string asm> {
5213 def v8i8 : BaseSIMDBitwiseExtract<0, V64, v8i8, asm, ".8b"> {
5216 def v16i8 : BaseSIMDBitwiseExtract<1, V128, v16i8, asm, ".16b">;
5219 //----------------------------------------------------------------------------
5220 // AdvSIMD zip vector
5221 //----------------------------------------------------------------------------
5223 class BaseSIMDZipVector<bits<3> size, bits<3> opc, RegisterOperand regtype,
5224 string asm, string kind, SDNode OpNode, ValueType valty>
5225 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
5226 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
5227 "|" # kind # "\t$Rd, $Rn, $Rm}", "",
5228 [(set (valty regtype:$Rd), (OpNode regtype:$Rn, regtype:$Rm))]>,
5234 let Inst{30} = size{0};
5235 let Inst{29-24} = 0b001110;
5236 let Inst{23-22} = size{2-1};
5238 let Inst{20-16} = Rm;
5240 let Inst{14-12} = opc;
5241 let Inst{11-10} = 0b10;
5246 multiclass SIMDZipVector<bits<3>opc, string asm,
5248 def v8i8 : BaseSIMDZipVector<0b000, opc, V64,
5249 asm, ".8b", OpNode, v8i8>;
5250 def v16i8 : BaseSIMDZipVector<0b001, opc, V128,
5251 asm, ".16b", OpNode, v16i8>;
5252 def v4i16 : BaseSIMDZipVector<0b010, opc, V64,
5253 asm, ".4h", OpNode, v4i16>;
5254 def v8i16 : BaseSIMDZipVector<0b011, opc, V128,
5255 asm, ".8h", OpNode, v8i16>;
5256 def v2i32 : BaseSIMDZipVector<0b100, opc, V64,
5257 asm, ".2s", OpNode, v2i32>;
5258 def v4i32 : BaseSIMDZipVector<0b101, opc, V128,
5259 asm, ".4s", OpNode, v4i32>;
5260 def v2i64 : BaseSIMDZipVector<0b111, opc, V128,
5261 asm, ".2d", OpNode, v2i64>;
5263 def : Pat<(v4f16 (OpNode V64:$Rn, V64:$Rm)),
5264 (!cast<Instruction>(NAME#"v4i16") V64:$Rn, V64:$Rm)>;
5265 def : Pat<(v8f16 (OpNode V128:$Rn, V128:$Rm)),
5266 (!cast<Instruction>(NAME#"v8i16") V128:$Rn, V128:$Rm)>;
5267 def : Pat<(v2f32 (OpNode V64:$Rn, V64:$Rm)),
5268 (!cast<Instruction>(NAME#"v2i32") V64:$Rn, V64:$Rm)>;
5269 def : Pat<(v4f32 (OpNode V128:$Rn, V128:$Rm)),
5270 (!cast<Instruction>(NAME#"v4i32") V128:$Rn, V128:$Rm)>;
5271 def : Pat<(v2f64 (OpNode V128:$Rn, V128:$Rm)),
5272 (!cast<Instruction>(NAME#"v2i64") V128:$Rn, V128:$Rm)>;
5275 //----------------------------------------------------------------------------
5276 // AdvSIMD three register scalar instructions
5277 //----------------------------------------------------------------------------
5279 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5280 class BaseSIMDThreeScalar<bit U, bits<2> size, bits<5> opcode,
5281 RegisterClass regtype, string asm,
5283 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
5284 "\t$Rd, $Rn, $Rm", "", pattern>,
5289 let Inst{31-30} = 0b01;
5291 let Inst{28-24} = 0b11110;
5292 let Inst{23-22} = size;
5294 let Inst{20-16} = Rm;
5295 let Inst{15-11} = opcode;
5301 multiclass SIMDThreeScalarD<bit U, bits<5> opc, string asm,
5302 SDPatternOperator OpNode> {
5303 def v1i64 : BaseSIMDThreeScalar<U, 0b11, opc, FPR64, asm,
5304 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
5307 multiclass SIMDThreeScalarBHSD<bit U, bits<5> opc, string asm,
5308 SDPatternOperator OpNode> {
5309 def v1i64 : BaseSIMDThreeScalar<U, 0b11, opc, FPR64, asm,
5310 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
5311 def v1i32 : BaseSIMDThreeScalar<U, 0b10, opc, FPR32, asm, []>;
5312 def v1i16 : BaseSIMDThreeScalar<U, 0b01, opc, FPR16, asm, []>;
5313 def v1i8 : BaseSIMDThreeScalar<U, 0b00, opc, FPR8 , asm, []>;
5315 def : Pat<(i64 (OpNode (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5316 (!cast<Instruction>(NAME#"v1i64") FPR64:$Rn, FPR64:$Rm)>;
5317 def : Pat<(i32 (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm))),
5318 (!cast<Instruction>(NAME#"v1i32") FPR32:$Rn, FPR32:$Rm)>;
5321 multiclass SIMDThreeScalarHS<bit U, bits<5> opc, string asm,
5322 SDPatternOperator OpNode> {
5323 def v1i32 : BaseSIMDThreeScalar<U, 0b10, opc, FPR32, asm,
5324 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
5325 def v1i16 : BaseSIMDThreeScalar<U, 0b01, opc, FPR16, asm, []>;
5328 multiclass SIMDThreeScalarSD<bit U, bit S, bits<5> opc, string asm,
5329 SDPatternOperator OpNode = null_frag> {
5330 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5331 def #NAME#64 : BaseSIMDThreeScalar<U, {S,1}, opc, FPR64, asm,
5332 [(set (f64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
5333 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0}, opc, FPR32, asm,
5334 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
5337 def : Pat<(v1f64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
5338 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
5341 multiclass SIMDThreeScalarFPCmp<bit U, bit S, bits<5> opc, string asm,
5342 SDPatternOperator OpNode = null_frag> {
5343 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5344 def #NAME#64 : BaseSIMDThreeScalar<U, {S,1}, opc, FPR64, asm,
5345 [(set (i64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
5346 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0}, opc, FPR32, asm,
5347 [(set (i32 FPR32:$Rd), (OpNode (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]>;
5350 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
5351 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
5354 class BaseSIMDThreeScalarMixed<bit U, bits<2> size, bits<5> opcode,
5355 dag oops, dag iops, string asm, string cstr, list<dag> pat>
5356 : I<oops, iops, asm,
5357 "\t$Rd, $Rn, $Rm", cstr, pat>,
5362 let Inst{31-30} = 0b01;
5364 let Inst{28-24} = 0b11110;
5365 let Inst{23-22} = size;
5367 let Inst{20-16} = Rm;
5368 let Inst{15-11} = opcode;
5374 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5375 multiclass SIMDThreeScalarMixedHS<bit U, bits<5> opc, string asm,
5376 SDPatternOperator OpNode = null_frag> {
5377 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
5379 (ins FPR16:$Rn, FPR16:$Rm), asm, "", []>;
5380 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
5382 (ins FPR32:$Rn, FPR32:$Rm), asm, "",
5383 [(set (i64 FPR64:$Rd), (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
5386 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5387 multiclass SIMDThreeScalarMixedTiedHS<bit U, bits<5> opc, string asm,
5388 SDPatternOperator OpNode = null_frag> {
5389 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
5391 (ins FPR32:$Rd, FPR16:$Rn, FPR16:$Rm),
5392 asm, "$Rd = $dst", []>;
5393 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
5395 (ins FPR64:$Rd, FPR32:$Rn, FPR32:$Rm),
5397 [(set (i64 FPR64:$dst),
5398 (OpNode (i64 FPR64:$Rd), (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
5401 //----------------------------------------------------------------------------
5402 // AdvSIMD two register scalar instructions
5403 //----------------------------------------------------------------------------
5405 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5406 class BaseSIMDTwoScalar<bit U, bits<2> size, bits<5> opcode,
5407 RegisterClass regtype, RegisterClass regtype2,
5408 string asm, list<dag> pat>
5409 : I<(outs regtype:$Rd), (ins regtype2:$Rn), asm,
5410 "\t$Rd, $Rn", "", pat>,
5414 let Inst{31-30} = 0b01;
5416 let Inst{28-24} = 0b11110;
5417 let Inst{23-22} = size;
5418 let Inst{21-17} = 0b10000;
5419 let Inst{16-12} = opcode;
5420 let Inst{11-10} = 0b10;
5425 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5426 class BaseSIMDTwoScalarTied<bit U, bits<2> size, bits<5> opcode,
5427 RegisterClass regtype, RegisterClass regtype2,
5428 string asm, list<dag> pat>
5429 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype2:$Rn), asm,
5430 "\t$Rd, $Rn", "$Rd = $dst", pat>,
5434 let Inst{31-30} = 0b01;
5436 let Inst{28-24} = 0b11110;
5437 let Inst{23-22} = size;
5438 let Inst{21-17} = 0b10000;
5439 let Inst{16-12} = opcode;
5440 let Inst{11-10} = 0b10;
5446 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5447 class BaseSIMDCmpTwoScalar<bit U, bits<2> size, bits<5> opcode,
5448 RegisterClass regtype, string asm, string zero>
5449 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
5450 "\t$Rd, $Rn, #" # zero, "", []>,
5454 let Inst{31-30} = 0b01;
5456 let Inst{28-24} = 0b11110;
5457 let Inst{23-22} = size;
5458 let Inst{21-17} = 0b10000;
5459 let Inst{16-12} = opcode;
5460 let Inst{11-10} = 0b10;
5465 class SIMDInexactCvtTwoScalar<bits<5> opcode, string asm>
5466 : I<(outs FPR32:$Rd), (ins FPR64:$Rn), asm, "\t$Rd, $Rn", "",
5467 [(set (f32 FPR32:$Rd), (int_aarch64_sisd_fcvtxn (f64 FPR64:$Rn)))]>,
5471 let Inst{31-17} = 0b011111100110000;
5472 let Inst{16-12} = opcode;
5473 let Inst{11-10} = 0b10;
5478 multiclass SIMDCmpTwoScalarD<bit U, bits<5> opc, string asm,
5479 SDPatternOperator OpNode> {
5480 def v1i64rz : BaseSIMDCmpTwoScalar<U, 0b11, opc, FPR64, asm, "0">;
5482 def : Pat<(v1i64 (OpNode FPR64:$Rn)),
5483 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
5486 multiclass SIMDCmpTwoScalarSD<bit U, bit S, bits<5> opc, string asm,
5487 SDPatternOperator OpNode> {
5488 def v1i64rz : BaseSIMDCmpTwoScalar<U, {S,1}, opc, FPR64, asm, "0.0">;
5489 def v1i32rz : BaseSIMDCmpTwoScalar<U, {S,0}, opc, FPR32, asm, "0.0">;
5491 def : InstAlias<asm # " $Rd, $Rn, #0",
5492 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rd, FPR64:$Rn), 0>;
5493 def : InstAlias<asm # " $Rd, $Rn, #0",
5494 (!cast<Instruction>(NAME # v1i32rz) FPR32:$Rd, FPR32:$Rn), 0>;
5496 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn))),
5497 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
5500 multiclass SIMDTwoScalarD<bit U, bits<5> opc, string asm,
5501 SDPatternOperator OpNode = null_frag> {
5502 def v1i64 : BaseSIMDTwoScalar<U, 0b11, opc, FPR64, FPR64, asm,
5503 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn)))]>;
5505 def : Pat<(i64 (OpNode (i64 FPR64:$Rn))),
5506 (!cast<Instruction>(NAME # "v1i64") FPR64:$Rn)>;
5509 multiclass SIMDTwoScalarSD<bit U, bit S, bits<5> opc, string asm> {
5510 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, opc, FPR64, FPR64, asm,[]>;
5511 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, opc, FPR32, FPR32, asm,[]>;
5514 multiclass SIMDTwoScalarCVTSD<bit U, bit S, bits<5> opc, string asm,
5515 SDPatternOperator OpNode> {
5516 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, opc, FPR64, FPR64, asm,
5517 [(set FPR64:$Rd, (OpNode (f64 FPR64:$Rn)))]>;
5518 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, opc, FPR32, FPR32, asm,
5519 [(set FPR32:$Rd, (OpNode (f32 FPR32:$Rn)))]>;
5522 multiclass SIMDTwoScalarBHSD<bit U, bits<5> opc, string asm,
5523 SDPatternOperator OpNode = null_frag> {
5524 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5525 def v1i64 : BaseSIMDTwoScalar<U, 0b11, opc, FPR64, FPR64, asm,
5526 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
5527 def v1i32 : BaseSIMDTwoScalar<U, 0b10, opc, FPR32, FPR32, asm,
5528 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
5529 def v1i16 : BaseSIMDTwoScalar<U, 0b01, opc, FPR16, FPR16, asm, []>;
5530 def v1i8 : BaseSIMDTwoScalar<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
5533 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn))),
5534 (!cast<Instruction>(NAME # v1i64) FPR64:$Rn)>;
5537 multiclass SIMDTwoScalarBHSDTied<bit U, bits<5> opc, string asm,
5539 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
5540 def v1i64 : BaseSIMDTwoScalarTied<U, 0b11, opc, FPR64, FPR64, asm,
5541 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn)))]>;
5542 def v1i32 : BaseSIMDTwoScalarTied<U, 0b10, opc, FPR32, FPR32, asm,
5543 [(set (i32 FPR32:$dst), (OpNode (i32 FPR32:$Rd), (i32 FPR32:$Rn)))]>;
5544 def v1i16 : BaseSIMDTwoScalarTied<U, 0b01, opc, FPR16, FPR16, asm, []>;
5545 def v1i8 : BaseSIMDTwoScalarTied<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
5548 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn))),
5549 (!cast<Instruction>(NAME # v1i64) FPR64:$Rd, FPR64:$Rn)>;
5554 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5555 multiclass SIMDTwoScalarMixedBHS<bit U, bits<5> opc, string asm,
5556 SDPatternOperator OpNode = null_frag> {
5557 def v1i32 : BaseSIMDTwoScalar<U, 0b10, opc, FPR32, FPR64, asm,
5558 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
5559 def v1i16 : BaseSIMDTwoScalar<U, 0b01, opc, FPR16, FPR32, asm, []>;
5560 def v1i8 : BaseSIMDTwoScalar<U, 0b00, opc, FPR8 , FPR16, asm, []>;
5563 //----------------------------------------------------------------------------
5564 // AdvSIMD scalar pairwise instructions
5565 //----------------------------------------------------------------------------
5567 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5568 class BaseSIMDPairwiseScalar<bit U, bits<2> size, bits<5> opcode,
5569 RegisterOperand regtype, RegisterOperand vectype,
5570 string asm, string kind>
5571 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
5572 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", []>,
5576 let Inst{31-30} = 0b01;
5578 let Inst{28-24} = 0b11110;
5579 let Inst{23-22} = size;
5580 let Inst{21-17} = 0b11000;
5581 let Inst{16-12} = opcode;
5582 let Inst{11-10} = 0b10;
5587 multiclass SIMDPairwiseScalarD<bit U, bits<5> opc, string asm> {
5588 def v2i64p : BaseSIMDPairwiseScalar<U, 0b11, opc, FPR64Op, V128,
5592 multiclass SIMDPairwiseScalarSD<bit U, bit S, bits<5> opc, string asm> {
5593 def v2i32p : BaseSIMDPairwiseScalar<U, {S,0}, opc, FPR32Op, V64,
5595 def v2i64p : BaseSIMDPairwiseScalar<U, {S,1}, opc, FPR64Op, V128,
5599 //----------------------------------------------------------------------------
5600 // AdvSIMD across lanes instructions
5601 //----------------------------------------------------------------------------
5603 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5604 class BaseSIMDAcrossLanes<bit Q, bit U, bits<2> size, bits<5> opcode,
5605 RegisterClass regtype, RegisterOperand vectype,
5606 string asm, string kind, list<dag> pattern>
5607 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
5608 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", pattern>,
5615 let Inst{28-24} = 0b01110;
5616 let Inst{23-22} = size;
5617 let Inst{21-17} = 0b11000;
5618 let Inst{16-12} = opcode;
5619 let Inst{11-10} = 0b10;
5624 multiclass SIMDAcrossLanesBHS<bit U, bits<5> opcode,
5626 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR8, V64,
5628 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR8, V128,
5630 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR16, V64,
5632 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR16, V128,
5634 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR32, V128,
5638 multiclass SIMDAcrossLanesHSD<bit U, bits<5> opcode, string asm> {
5639 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR16, V64,
5641 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR16, V128,
5643 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR32, V64,
5645 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR32, V128,
5647 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR64, V128,
5651 multiclass SIMDAcrossLanesS<bits<5> opcode, bit sz1, string asm,
5653 def v4i32v : BaseSIMDAcrossLanes<1, 1, {sz1, 0}, opcode, FPR32, V128,
5655 [(set FPR32:$Rd, (intOp (v4f32 V128:$Rn)))]>;
5658 //----------------------------------------------------------------------------
5659 // AdvSIMD INS/DUP instructions
5660 //----------------------------------------------------------------------------
5662 // FIXME: There has got to be a better way to factor these. ugh.
5664 class BaseSIMDInsDup<bit Q, bit op, dag outs, dag ins, string asm,
5665 string operands, string constraints, list<dag> pattern>
5666 : I<outs, ins, asm, operands, constraints, pattern>,
5673 let Inst{28-21} = 0b01110000;
5680 class SIMDDupFromMain<bit Q, bits<5> imm5, string size, ValueType vectype,
5681 RegisterOperand vecreg, RegisterClass regtype>
5682 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins regtype:$Rn), "dup",
5683 "{\t$Rd" # size # ", $Rn" #
5684 "|" # size # "\t$Rd, $Rn}", "",
5685 [(set (vectype vecreg:$Rd), (AArch64dup regtype:$Rn))]> {
5686 let Inst{20-16} = imm5;
5687 let Inst{14-11} = 0b0001;
5690 class SIMDDupFromElement<bit Q, string dstkind, string srckind,
5691 ValueType vectype, ValueType insreg,
5692 RegisterOperand vecreg, Operand idxtype,
5693 ValueType elttype, SDNode OpNode>
5694 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins V128:$Rn, idxtype:$idx), "dup",
5695 "{\t$Rd" # dstkind # ", $Rn" # srckind # "$idx" #
5696 "|" # dstkind # "\t$Rd, $Rn$idx}", "",
5697 [(set (vectype vecreg:$Rd),
5698 (OpNode (insreg V128:$Rn), idxtype:$idx))]> {
5699 let Inst{14-11} = 0b0000;
5702 class SIMDDup64FromElement
5703 : SIMDDupFromElement<1, ".2d", ".d", v2i64, v2i64, V128,
5704 VectorIndexD, i64, AArch64duplane64> {
5707 let Inst{19-16} = 0b1000;
5710 class SIMDDup32FromElement<bit Q, string size, ValueType vectype,
5711 RegisterOperand vecreg>
5712 : SIMDDupFromElement<Q, size, ".s", vectype, v4i32, vecreg,
5713 VectorIndexS, i64, AArch64duplane32> {
5715 let Inst{20-19} = idx;
5716 let Inst{18-16} = 0b100;
5719 class SIMDDup16FromElement<bit Q, string size, ValueType vectype,
5720 RegisterOperand vecreg>
5721 : SIMDDupFromElement<Q, size, ".h", vectype, v8i16, vecreg,
5722 VectorIndexH, i64, AArch64duplane16> {
5724 let Inst{20-18} = idx;
5725 let Inst{17-16} = 0b10;
5728 class SIMDDup8FromElement<bit Q, string size, ValueType vectype,
5729 RegisterOperand vecreg>
5730 : SIMDDupFromElement<Q, size, ".b", vectype, v16i8, vecreg,
5731 VectorIndexB, i64, AArch64duplane8> {
5733 let Inst{20-17} = idx;
5737 class BaseSIMDMov<bit Q, string size, bits<4> imm4, RegisterClass regtype,
5738 Operand idxtype, string asm, list<dag> pattern>
5739 : BaseSIMDInsDup<Q, 0, (outs regtype:$Rd), (ins V128:$Rn, idxtype:$idx), asm,
5740 "{\t$Rd, $Rn" # size # "$idx" #
5741 "|" # size # "\t$Rd, $Rn$idx}", "", pattern> {
5742 let Inst{14-11} = imm4;
5745 class SIMDSMov<bit Q, string size, RegisterClass regtype,
5747 : BaseSIMDMov<Q, size, 0b0101, regtype, idxtype, "smov", []>;
5748 class SIMDUMov<bit Q, string size, ValueType vectype, RegisterClass regtype,
5750 : BaseSIMDMov<Q, size, 0b0111, regtype, idxtype, "umov",
5751 [(set regtype:$Rd, (vector_extract (vectype V128:$Rn), idxtype:$idx))]>;
5753 class SIMDMovAlias<string asm, string size, Instruction inst,
5754 RegisterClass regtype, Operand idxtype>
5755 : InstAlias<asm#"{\t$dst, $src"#size#"$idx" #
5756 "|" # size # "\t$dst, $src$idx}",
5757 (inst regtype:$dst, V128:$src, idxtype:$idx)>;
5760 def vi8to32 : SIMDSMov<0, ".b", GPR32, VectorIndexB> {
5762 let Inst{20-17} = idx;
5765 def vi8to64 : SIMDSMov<1, ".b", GPR64, VectorIndexB> {
5767 let Inst{20-17} = idx;
5770 def vi16to32 : SIMDSMov<0, ".h", GPR32, VectorIndexH> {
5772 let Inst{20-18} = idx;
5773 let Inst{17-16} = 0b10;
5775 def vi16to64 : SIMDSMov<1, ".h", GPR64, VectorIndexH> {
5777 let Inst{20-18} = idx;
5778 let Inst{17-16} = 0b10;
5780 def vi32to64 : SIMDSMov<1, ".s", GPR64, VectorIndexS> {
5782 let Inst{20-19} = idx;
5783 let Inst{18-16} = 0b100;
5788 def vi8 : SIMDUMov<0, ".b", v16i8, GPR32, VectorIndexB> {
5790 let Inst{20-17} = idx;
5793 def vi16 : SIMDUMov<0, ".h", v8i16, GPR32, VectorIndexH> {
5795 let Inst{20-18} = idx;
5796 let Inst{17-16} = 0b10;
5798 def vi32 : SIMDUMov<0, ".s", v4i32, GPR32, VectorIndexS> {
5800 let Inst{20-19} = idx;
5801 let Inst{18-16} = 0b100;
5803 def vi64 : SIMDUMov<1, ".d", v2i64, GPR64, VectorIndexD> {
5806 let Inst{19-16} = 0b1000;
5808 def : SIMDMovAlias<"mov", ".s",
5809 !cast<Instruction>(NAME#"vi32"),
5810 GPR32, VectorIndexS>;
5811 def : SIMDMovAlias<"mov", ".d",
5812 !cast<Instruction>(NAME#"vi64"),
5813 GPR64, VectorIndexD>;
5816 class SIMDInsFromMain<string size, ValueType vectype,
5817 RegisterClass regtype, Operand idxtype>
5818 : BaseSIMDInsDup<1, 0, (outs V128:$dst),
5819 (ins V128:$Rd, idxtype:$idx, regtype:$Rn), "ins",
5820 "{\t$Rd" # size # "$idx, $Rn" #
5821 "|" # size # "\t$Rd$idx, $Rn}",
5824 (vector_insert (vectype V128:$Rd), regtype:$Rn, idxtype:$idx))]> {
5825 let Inst{14-11} = 0b0011;
5828 class SIMDInsFromElement<string size, ValueType vectype,
5829 ValueType elttype, Operand idxtype>
5830 : BaseSIMDInsDup<1, 1, (outs V128:$dst),
5831 (ins V128:$Rd, idxtype:$idx, V128:$Rn, idxtype:$idx2), "ins",
5832 "{\t$Rd" # size # "$idx, $Rn" # size # "$idx2" #
5833 "|" # size # "\t$Rd$idx, $Rn$idx2}",
5838 (elttype (vector_extract (vectype V128:$Rn), idxtype:$idx2)),
5841 class SIMDInsMainMovAlias<string size, Instruction inst,
5842 RegisterClass regtype, Operand idxtype>
5843 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" #
5844 "|" # size #"\t$dst$idx, $src}",
5845 (inst V128:$dst, idxtype:$idx, regtype:$src)>;
5846 class SIMDInsElementMovAlias<string size, Instruction inst,
5848 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" # size # "$idx2" #
5849 # "|" # size #" $dst$idx, $src$idx2}",
5850 (inst V128:$dst, idxtype:$idx, V128:$src, idxtype:$idx2)>;
5853 multiclass SIMDIns {
5854 def vi8gpr : SIMDInsFromMain<".b", v16i8, GPR32, VectorIndexB> {
5856 let Inst{20-17} = idx;
5859 def vi16gpr : SIMDInsFromMain<".h", v8i16, GPR32, VectorIndexH> {
5861 let Inst{20-18} = idx;
5862 let Inst{17-16} = 0b10;
5864 def vi32gpr : SIMDInsFromMain<".s", v4i32, GPR32, VectorIndexS> {
5866 let Inst{20-19} = idx;
5867 let Inst{18-16} = 0b100;
5869 def vi64gpr : SIMDInsFromMain<".d", v2i64, GPR64, VectorIndexD> {
5872 let Inst{19-16} = 0b1000;
5875 def vi8lane : SIMDInsFromElement<".b", v16i8, i32, VectorIndexB> {
5878 let Inst{20-17} = idx;
5880 let Inst{14-11} = idx2;
5882 def vi16lane : SIMDInsFromElement<".h", v8i16, i32, VectorIndexH> {
5885 let Inst{20-18} = idx;
5886 let Inst{17-16} = 0b10;
5887 let Inst{14-12} = idx2;
5890 def vi32lane : SIMDInsFromElement<".s", v4i32, i32, VectorIndexS> {
5893 let Inst{20-19} = idx;
5894 let Inst{18-16} = 0b100;
5895 let Inst{14-13} = idx2;
5896 let Inst{12-11} = 0;
5898 def vi64lane : SIMDInsFromElement<".d", v2i64, i64, VectorIndexD> {
5902 let Inst{19-16} = 0b1000;
5903 let Inst{14} = idx2;
5904 let Inst{13-11} = 0;
5907 // For all forms of the INS instruction, the "mov" mnemonic is the
5908 // preferred alias. Why they didn't just call the instruction "mov" in
5909 // the first place is a very good question indeed...
5910 def : SIMDInsMainMovAlias<".b", !cast<Instruction>(NAME#"vi8gpr"),
5911 GPR32, VectorIndexB>;
5912 def : SIMDInsMainMovAlias<".h", !cast<Instruction>(NAME#"vi16gpr"),
5913 GPR32, VectorIndexH>;
5914 def : SIMDInsMainMovAlias<".s", !cast<Instruction>(NAME#"vi32gpr"),
5915 GPR32, VectorIndexS>;
5916 def : SIMDInsMainMovAlias<".d", !cast<Instruction>(NAME#"vi64gpr"),
5917 GPR64, VectorIndexD>;
5919 def : SIMDInsElementMovAlias<".b", !cast<Instruction>(NAME#"vi8lane"),
5921 def : SIMDInsElementMovAlias<".h", !cast<Instruction>(NAME#"vi16lane"),
5923 def : SIMDInsElementMovAlias<".s", !cast<Instruction>(NAME#"vi32lane"),
5925 def : SIMDInsElementMovAlias<".d", !cast<Instruction>(NAME#"vi64lane"),
5929 //----------------------------------------------------------------------------
5931 //----------------------------------------------------------------------------
5933 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5934 class BaseSIMDTableLookup<bit Q, bits<2> len, bit op, RegisterOperand vectype,
5935 RegisterOperand listtype, string asm, string kind>
5936 : I<(outs vectype:$Vd), (ins listtype:$Vn, vectype:$Vm), asm,
5937 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "", []>,
5944 let Inst{29-21} = 0b001110000;
5945 let Inst{20-16} = Vm;
5947 let Inst{14-13} = len;
5949 let Inst{11-10} = 0b00;
5954 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
5955 class BaseSIMDTableLookupTied<bit Q, bits<2> len, bit op, RegisterOperand vectype,
5956 RegisterOperand listtype, string asm, string kind>
5957 : I<(outs vectype:$dst), (ins vectype:$Vd, listtype:$Vn, vectype:$Vm), asm,
5958 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "$Vd = $dst", []>,
5965 let Inst{29-21} = 0b001110000;
5966 let Inst{20-16} = Vm;
5968 let Inst{14-13} = len;
5970 let Inst{11-10} = 0b00;
5975 class SIMDTableLookupAlias<string asm, Instruction inst,
5976 RegisterOperand vectype, RegisterOperand listtype>
5977 : InstAlias<!strconcat(asm, "\t$dst, $lst, $index"),
5978 (inst vectype:$dst, listtype:$lst, vectype:$index), 0>;
5980 multiclass SIMDTableLookup<bit op, string asm> {
5981 def v8i8One : BaseSIMDTableLookup<0, 0b00, op, V64, VecListOne16b,
5983 def v8i8Two : BaseSIMDTableLookup<0, 0b01, op, V64, VecListTwo16b,
5985 def v8i8Three : BaseSIMDTableLookup<0, 0b10, op, V64, VecListThree16b,
5987 def v8i8Four : BaseSIMDTableLookup<0, 0b11, op, V64, VecListFour16b,
5989 def v16i8One : BaseSIMDTableLookup<1, 0b00, op, V128, VecListOne16b,
5991 def v16i8Two : BaseSIMDTableLookup<1, 0b01, op, V128, VecListTwo16b,
5993 def v16i8Three: BaseSIMDTableLookup<1, 0b10, op, V128, VecListThree16b,
5995 def v16i8Four : BaseSIMDTableLookup<1, 0b11, op, V128, VecListFour16b,
5998 def : SIMDTableLookupAlias<asm # ".8b",
5999 !cast<Instruction>(NAME#"v8i8One"),
6000 V64, VecListOne128>;
6001 def : SIMDTableLookupAlias<asm # ".8b",
6002 !cast<Instruction>(NAME#"v8i8Two"),
6003 V64, VecListTwo128>;
6004 def : SIMDTableLookupAlias<asm # ".8b",
6005 !cast<Instruction>(NAME#"v8i8Three"),
6006 V64, VecListThree128>;
6007 def : SIMDTableLookupAlias<asm # ".8b",
6008 !cast<Instruction>(NAME#"v8i8Four"),
6009 V64, VecListFour128>;
6010 def : SIMDTableLookupAlias<asm # ".16b",
6011 !cast<Instruction>(NAME#"v16i8One"),
6012 V128, VecListOne128>;
6013 def : SIMDTableLookupAlias<asm # ".16b",
6014 !cast<Instruction>(NAME#"v16i8Two"),
6015 V128, VecListTwo128>;
6016 def : SIMDTableLookupAlias<asm # ".16b",
6017 !cast<Instruction>(NAME#"v16i8Three"),
6018 V128, VecListThree128>;
6019 def : SIMDTableLookupAlias<asm # ".16b",
6020 !cast<Instruction>(NAME#"v16i8Four"),
6021 V128, VecListFour128>;
6024 multiclass SIMDTableLookupTied<bit op, string asm> {
6025 def v8i8One : BaseSIMDTableLookupTied<0, 0b00, op, V64, VecListOne16b,
6027 def v8i8Two : BaseSIMDTableLookupTied<0, 0b01, op, V64, VecListTwo16b,
6029 def v8i8Three : BaseSIMDTableLookupTied<0, 0b10, op, V64, VecListThree16b,
6031 def v8i8Four : BaseSIMDTableLookupTied<0, 0b11, op, V64, VecListFour16b,
6033 def v16i8One : BaseSIMDTableLookupTied<1, 0b00, op, V128, VecListOne16b,
6035 def v16i8Two : BaseSIMDTableLookupTied<1, 0b01, op, V128, VecListTwo16b,
6037 def v16i8Three: BaseSIMDTableLookupTied<1, 0b10, op, V128, VecListThree16b,
6039 def v16i8Four : BaseSIMDTableLookupTied<1, 0b11, op, V128, VecListFour16b,
6042 def : SIMDTableLookupAlias<asm # ".8b",
6043 !cast<Instruction>(NAME#"v8i8One"),
6044 V64, VecListOne128>;
6045 def : SIMDTableLookupAlias<asm # ".8b",
6046 !cast<Instruction>(NAME#"v8i8Two"),
6047 V64, VecListTwo128>;
6048 def : SIMDTableLookupAlias<asm # ".8b",
6049 !cast<Instruction>(NAME#"v8i8Three"),
6050 V64, VecListThree128>;
6051 def : SIMDTableLookupAlias<asm # ".8b",
6052 !cast<Instruction>(NAME#"v8i8Four"),
6053 V64, VecListFour128>;
6054 def : SIMDTableLookupAlias<asm # ".16b",
6055 !cast<Instruction>(NAME#"v16i8One"),
6056 V128, VecListOne128>;
6057 def : SIMDTableLookupAlias<asm # ".16b",
6058 !cast<Instruction>(NAME#"v16i8Two"),
6059 V128, VecListTwo128>;
6060 def : SIMDTableLookupAlias<asm # ".16b",
6061 !cast<Instruction>(NAME#"v16i8Three"),
6062 V128, VecListThree128>;
6063 def : SIMDTableLookupAlias<asm # ".16b",
6064 !cast<Instruction>(NAME#"v16i8Four"),
6065 V128, VecListFour128>;
6069 //----------------------------------------------------------------------------
6070 // AdvSIMD scalar CPY
6071 //----------------------------------------------------------------------------
6072 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6073 class BaseSIMDScalarCPY<RegisterClass regtype, RegisterOperand vectype,
6074 string kind, Operand idxtype>
6075 : I<(outs regtype:$dst), (ins vectype:$src, idxtype:$idx), "mov",
6076 "{\t$dst, $src" # kind # "$idx" #
6077 "|\t$dst, $src$idx}", "", []>,
6081 let Inst{31-21} = 0b01011110000;
6082 let Inst{15-10} = 0b000001;
6083 let Inst{9-5} = src;
6084 let Inst{4-0} = dst;
6087 class SIMDScalarCPYAlias<string asm, string size, Instruction inst,
6088 RegisterClass regtype, RegisterOperand vectype, Operand idxtype>
6089 : InstAlias<asm # "{\t$dst, $src" # size # "$index" #
6090 # "|\t$dst, $src$index}",
6091 (inst regtype:$dst, vectype:$src, idxtype:$index), 0>;
6094 multiclass SIMDScalarCPY<string asm> {
6095 def i8 : BaseSIMDScalarCPY<FPR8, V128, ".b", VectorIndexB> {
6097 let Inst{20-17} = idx;
6100 def i16 : BaseSIMDScalarCPY<FPR16, V128, ".h", VectorIndexH> {
6102 let Inst{20-18} = idx;
6103 let Inst{17-16} = 0b10;
6105 def i32 : BaseSIMDScalarCPY<FPR32, V128, ".s", VectorIndexS> {
6107 let Inst{20-19} = idx;
6108 let Inst{18-16} = 0b100;
6110 def i64 : BaseSIMDScalarCPY<FPR64, V128, ".d", VectorIndexD> {
6113 let Inst{19-16} = 0b1000;
6116 def : Pat<(v1i64 (scalar_to_vector (i64 (vector_extract (v2i64 V128:$src),
6117 VectorIndexD:$idx)))),
6118 (!cast<Instruction>(NAME # i64) V128:$src, VectorIndexD:$idx)>;
6120 // 'DUP' mnemonic aliases.
6121 def : SIMDScalarCPYAlias<"dup", ".b",
6122 !cast<Instruction>(NAME#"i8"),
6123 FPR8, V128, VectorIndexB>;
6124 def : SIMDScalarCPYAlias<"dup", ".h",
6125 !cast<Instruction>(NAME#"i16"),
6126 FPR16, V128, VectorIndexH>;
6127 def : SIMDScalarCPYAlias<"dup", ".s",
6128 !cast<Instruction>(NAME#"i32"),
6129 FPR32, V128, VectorIndexS>;
6130 def : SIMDScalarCPYAlias<"dup", ".d",
6131 !cast<Instruction>(NAME#"i64"),
6132 FPR64, V128, VectorIndexD>;
6135 //----------------------------------------------------------------------------
6136 // AdvSIMD modified immediate instructions
6137 //----------------------------------------------------------------------------
6139 class BaseSIMDModifiedImm<bit Q, bit op, dag oops, dag iops,
6140 string asm, string op_string,
6141 string cstr, list<dag> pattern>
6142 : I<oops, iops, asm, op_string, cstr, pattern>,
6149 let Inst{28-19} = 0b0111100000;
6150 let Inst{18-16} = imm8{7-5};
6151 let Inst{11-10} = 0b01;
6152 let Inst{9-5} = imm8{4-0};
6156 class BaseSIMDModifiedImmVector<bit Q, bit op, RegisterOperand vectype,
6157 Operand immtype, dag opt_shift_iop,
6158 string opt_shift, string asm, string kind,
6160 : BaseSIMDModifiedImm<Q, op, (outs vectype:$Rd),
6161 !con((ins immtype:$imm8), opt_shift_iop), asm,
6162 "{\t$Rd" # kind # ", $imm8" # opt_shift #
6163 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
6165 let DecoderMethod = "DecodeModImmInstruction";
6168 class BaseSIMDModifiedImmVectorTied<bit Q, bit op, RegisterOperand vectype,
6169 Operand immtype, dag opt_shift_iop,
6170 string opt_shift, string asm, string kind,
6172 : BaseSIMDModifiedImm<Q, op, (outs vectype:$dst),
6173 !con((ins vectype:$Rd, immtype:$imm8), opt_shift_iop),
6174 asm, "{\t$Rd" # kind # ", $imm8" # opt_shift #
6175 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
6176 "$Rd = $dst", pattern> {
6177 let DecoderMethod = "DecodeModImmTiedInstruction";
6180 class BaseSIMDModifiedImmVectorShift<bit Q, bit op, bits<2> b15_b12,
6181 RegisterOperand vectype, string asm,
6182 string kind, list<dag> pattern>
6183 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6184 (ins logical_vec_shift:$shift),
6185 "$shift", asm, kind, pattern> {
6187 let Inst{15} = b15_b12{1};
6188 let Inst{14-13} = shift;
6189 let Inst{12} = b15_b12{0};
6192 class BaseSIMDModifiedImmVectorShiftTied<bit Q, bit op, bits<2> b15_b12,
6193 RegisterOperand vectype, string asm,
6194 string kind, list<dag> pattern>
6195 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
6196 (ins logical_vec_shift:$shift),
6197 "$shift", asm, kind, pattern> {
6199 let Inst{15} = b15_b12{1};
6200 let Inst{14-13} = shift;
6201 let Inst{12} = b15_b12{0};
6205 class BaseSIMDModifiedImmVectorShiftHalf<bit Q, bit op, bits<2> b15_b12,
6206 RegisterOperand vectype, string asm,
6207 string kind, list<dag> pattern>
6208 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6209 (ins logical_vec_hw_shift:$shift),
6210 "$shift", asm, kind, pattern> {
6212 let Inst{15} = b15_b12{1};
6214 let Inst{13} = shift{0};
6215 let Inst{12} = b15_b12{0};
6218 class BaseSIMDModifiedImmVectorShiftHalfTied<bit Q, bit op, bits<2> b15_b12,
6219 RegisterOperand vectype, string asm,
6220 string kind, list<dag> pattern>
6221 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
6222 (ins logical_vec_hw_shift:$shift),
6223 "$shift", asm, kind, pattern> {
6225 let Inst{15} = b15_b12{1};
6227 let Inst{13} = shift{0};
6228 let Inst{12} = b15_b12{0};
6231 multiclass SIMDModifiedImmVectorShift<bit op, bits<2> hw_cmode, bits<2> w_cmode,
6233 def v4i16 : BaseSIMDModifiedImmVectorShiftHalf<0, op, hw_cmode, V64,
6235 def v8i16 : BaseSIMDModifiedImmVectorShiftHalf<1, op, hw_cmode, V128,
6238 def v2i32 : BaseSIMDModifiedImmVectorShift<0, op, w_cmode, V64,
6240 def v4i32 : BaseSIMDModifiedImmVectorShift<1, op, w_cmode, V128,
6244 multiclass SIMDModifiedImmVectorShiftTied<bit op, bits<2> hw_cmode,
6245 bits<2> w_cmode, string asm,
6247 def v4i16 : BaseSIMDModifiedImmVectorShiftHalfTied<0, op, hw_cmode, V64,
6249 [(set (v4i16 V64:$dst), (OpNode V64:$Rd,
6251 (i32 imm:$shift)))]>;
6252 def v8i16 : BaseSIMDModifiedImmVectorShiftHalfTied<1, op, hw_cmode, V128,
6254 [(set (v8i16 V128:$dst), (OpNode V128:$Rd,
6256 (i32 imm:$shift)))]>;
6258 def v2i32 : BaseSIMDModifiedImmVectorShiftTied<0, op, w_cmode, V64,
6260 [(set (v2i32 V64:$dst), (OpNode V64:$Rd,
6262 (i32 imm:$shift)))]>;
6263 def v4i32 : BaseSIMDModifiedImmVectorShiftTied<1, op, w_cmode, V128,
6265 [(set (v4i32 V128:$dst), (OpNode V128:$Rd,
6267 (i32 imm:$shift)))]>;
6270 class SIMDModifiedImmMoveMSL<bit Q, bit op, bits<4> cmode,
6271 RegisterOperand vectype, string asm,
6272 string kind, list<dag> pattern>
6273 : BaseSIMDModifiedImmVector<Q, op, vectype, imm0_255,
6274 (ins move_vec_shift:$shift),
6275 "$shift", asm, kind, pattern> {
6277 let Inst{15-13} = cmode{3-1};
6278 let Inst{12} = shift;
6281 class SIMDModifiedImmVectorNoShift<bit Q, bit op, bits<4> cmode,
6282 RegisterOperand vectype,
6283 Operand imm_type, string asm,
6284 string kind, list<dag> pattern>
6285 : BaseSIMDModifiedImmVector<Q, op, vectype, imm_type, (ins), "",
6286 asm, kind, pattern> {
6287 let Inst{15-12} = cmode;
6290 class SIMDModifiedImmScalarNoShift<bit Q, bit op, bits<4> cmode, string asm,
6292 : BaseSIMDModifiedImm<Q, op, (outs FPR64:$Rd), (ins simdimmtype10:$imm8), asm,
6293 "\t$Rd, $imm8", "", pattern> {
6294 let Inst{15-12} = cmode;
6295 let DecoderMethod = "DecodeModImmInstruction";
6298 //----------------------------------------------------------------------------
6299 // AdvSIMD indexed element
6300 //----------------------------------------------------------------------------
6302 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6303 class BaseSIMDIndexed<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
6304 RegisterOperand dst_reg, RegisterOperand lhs_reg,
6305 RegisterOperand rhs_reg, Operand vec_idx, string asm,
6306 string apple_kind, string dst_kind, string lhs_kind,
6307 string rhs_kind, list<dag> pattern>
6308 : I<(outs dst_reg:$Rd), (ins lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx),
6310 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
6311 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "", pattern>,
6320 let Inst{28} = Scalar;
6321 let Inst{27-24} = 0b1111;
6322 let Inst{23-22} = size;
6323 // Bit 21 must be set by the derived class.
6324 let Inst{20-16} = Rm;
6325 let Inst{15-12} = opc;
6326 // Bit 11 must be set by the derived class.
6332 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6333 class BaseSIMDIndexedTied<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
6334 RegisterOperand dst_reg, RegisterOperand lhs_reg,
6335 RegisterOperand rhs_reg, Operand vec_idx, string asm,
6336 string apple_kind, string dst_kind, string lhs_kind,
6337 string rhs_kind, list<dag> pattern>
6338 : I<(outs dst_reg:$dst),
6339 (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx), asm,
6340 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
6341 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "$Rd = $dst", pattern>,
6350 let Inst{28} = Scalar;
6351 let Inst{27-24} = 0b1111;
6352 let Inst{23-22} = size;
6353 // Bit 21 must be set by the derived class.
6354 let Inst{20-16} = Rm;
6355 let Inst{15-12} = opc;
6356 // Bit 11 must be set by the derived class.
6362 multiclass SIMDFPIndexedSD<bit U, bits<4> opc, string asm,
6363 SDPatternOperator OpNode> {
6364 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6367 asm, ".2s", ".2s", ".2s", ".s",
6368 [(set (v2f32 V64:$Rd),
6369 (OpNode (v2f32 V64:$Rn),
6370 (v2f32 (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
6372 let Inst{11} = idx{1};
6373 let Inst{21} = idx{0};
6376 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6379 asm, ".4s", ".4s", ".4s", ".s",
6380 [(set (v4f32 V128:$Rd),
6381 (OpNode (v4f32 V128:$Rn),
6382 (v4f32 (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
6384 let Inst{11} = idx{1};
6385 let Inst{21} = idx{0};
6388 def v2i64_indexed : BaseSIMDIndexed<1, U, 0, 0b11, opc,
6391 asm, ".2d", ".2d", ".2d", ".d",
6392 [(set (v2f64 V128:$Rd),
6393 (OpNode (v2f64 V128:$Rn),
6394 (v2f64 (AArch64duplane64 (v2f64 V128:$Rm), VectorIndexD:$idx))))]> {
6396 let Inst{11} = idx{0};
6400 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6401 FPR32Op, FPR32Op, V128, VectorIndexS,
6402 asm, ".s", "", "", ".s",
6403 [(set (f32 FPR32Op:$Rd),
6404 (OpNode (f32 FPR32Op:$Rn),
6405 (f32 (vector_extract (v4f32 V128:$Rm),
6406 VectorIndexS:$idx))))]> {
6408 let Inst{11} = idx{1};
6409 let Inst{21} = idx{0};
6412 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b11, opc,
6413 FPR64Op, FPR64Op, V128, VectorIndexD,
6414 asm, ".d", "", "", ".d",
6415 [(set (f64 FPR64Op:$Rd),
6416 (OpNode (f64 FPR64Op:$Rn),
6417 (f64 (vector_extract (v2f64 V128:$Rm),
6418 VectorIndexD:$idx))))]> {
6420 let Inst{11} = idx{0};
6425 multiclass SIMDFPIndexedSDTiedPatterns<string INST, SDPatternOperator OpNode> {
6426 // 2 variants for the .2s version: DUPLANE from 128-bit and DUP scalar.
6427 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
6428 (AArch64duplane32 (v4f32 V128:$Rm),
6429 VectorIndexS:$idx))),
6430 (!cast<Instruction>(INST # v2i32_indexed)
6431 V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6432 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
6433 (AArch64dup (f32 FPR32Op:$Rm)))),
6434 (!cast<Instruction>(INST # "v2i32_indexed") V64:$Rd, V64:$Rn,
6435 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
6438 // 2 variants for the .4s version: DUPLANE from 128-bit and DUP scalar.
6439 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
6440 (AArch64duplane32 (v4f32 V128:$Rm),
6441 VectorIndexS:$idx))),
6442 (!cast<Instruction>(INST # "v4i32_indexed")
6443 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6444 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
6445 (AArch64dup (f32 FPR32Op:$Rm)))),
6446 (!cast<Instruction>(INST # "v4i32_indexed") V128:$Rd, V128:$Rn,
6447 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
6449 // 2 variants for the .2d version: DUPLANE from 128-bit and DUP scalar.
6450 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
6451 (AArch64duplane64 (v2f64 V128:$Rm),
6452 VectorIndexD:$idx))),
6453 (!cast<Instruction>(INST # "v2i64_indexed")
6454 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
6455 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
6456 (AArch64dup (f64 FPR64Op:$Rm)))),
6457 (!cast<Instruction>(INST # "v2i64_indexed") V128:$Rd, V128:$Rn,
6458 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
6460 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
6461 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
6462 (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx))),
6463 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
6464 V128:$Rm, VectorIndexS:$idx)>;
6465 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
6466 (vector_extract (v2f32 V64:$Rm), VectorIndexS:$idx))),
6467 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
6468 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
6470 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
6471 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
6472 (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx))),
6473 (!cast<Instruction>(INST # "v1i64_indexed") FPR64:$Rd, FPR64:$Rn,
6474 V128:$Rm, VectorIndexD:$idx)>;
6477 multiclass SIMDFPIndexedSDTied<bit U, bits<4> opc, string asm> {
6478 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64,
6480 asm, ".2s", ".2s", ".2s", ".s", []> {
6482 let Inst{11} = idx{1};
6483 let Inst{21} = idx{0};
6486 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6489 asm, ".4s", ".4s", ".4s", ".s", []> {
6491 let Inst{11} = idx{1};
6492 let Inst{21} = idx{0};
6495 def v2i64_indexed : BaseSIMDIndexedTied<1, U, 0, 0b11, opc,
6498 asm, ".2d", ".2d", ".2d", ".d", []> {
6500 let Inst{11} = idx{0};
6505 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
6506 FPR32Op, FPR32Op, V128, VectorIndexS,
6507 asm, ".s", "", "", ".s", []> {
6509 let Inst{11} = idx{1};
6510 let Inst{21} = idx{0};
6513 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b11, opc,
6514 FPR64Op, FPR64Op, V128, VectorIndexD,
6515 asm, ".d", "", "", ".d", []> {
6517 let Inst{11} = idx{0};
6522 multiclass SIMDIndexedHS<bit U, bits<4> opc, string asm,
6523 SDPatternOperator OpNode> {
6524 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V64, V64,
6525 V128_lo, VectorIndexH,
6526 asm, ".4h", ".4h", ".4h", ".h",
6527 [(set (v4i16 V64:$Rd),
6528 (OpNode (v4i16 V64:$Rn),
6529 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6531 let Inst{11} = idx{2};
6532 let Inst{21} = idx{1};
6533 let Inst{20} = idx{0};
6536 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6538 V128_lo, VectorIndexH,
6539 asm, ".8h", ".8h", ".8h", ".h",
6540 [(set (v8i16 V128:$Rd),
6541 (OpNode (v8i16 V128:$Rn),
6542 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6544 let Inst{11} = idx{2};
6545 let Inst{21} = idx{1};
6546 let Inst{20} = idx{0};
6549 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6552 asm, ".2s", ".2s", ".2s", ".s",
6553 [(set (v2i32 V64:$Rd),
6554 (OpNode (v2i32 V64:$Rn),
6555 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6557 let Inst{11} = idx{1};
6558 let Inst{21} = idx{0};
6561 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6564 asm, ".4s", ".4s", ".4s", ".s",
6565 [(set (v4i32 V128:$Rd),
6566 (OpNode (v4i32 V128:$Rn),
6567 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6569 let Inst{11} = idx{1};
6570 let Inst{21} = idx{0};
6573 def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
6574 FPR16Op, FPR16Op, V128_lo, VectorIndexH,
6575 asm, ".h", "", "", ".h", []> {
6577 let Inst{11} = idx{2};
6578 let Inst{21} = idx{1};
6579 let Inst{20} = idx{0};
6582 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6583 FPR32Op, FPR32Op, V128, VectorIndexS,
6584 asm, ".s", "", "", ".s",
6585 [(set (i32 FPR32Op:$Rd),
6586 (OpNode FPR32Op:$Rn,
6587 (i32 (vector_extract (v4i32 V128:$Rm),
6588 VectorIndexS:$idx))))]> {
6590 let Inst{11} = idx{1};
6591 let Inst{21} = idx{0};
6595 multiclass SIMDVectorIndexedHS<bit U, bits<4> opc, string asm,
6596 SDPatternOperator OpNode> {
6597 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6599 V128_lo, VectorIndexH,
6600 asm, ".4h", ".4h", ".4h", ".h",
6601 [(set (v4i16 V64:$Rd),
6602 (OpNode (v4i16 V64:$Rn),
6603 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6605 let Inst{11} = idx{2};
6606 let Inst{21} = idx{1};
6607 let Inst{20} = idx{0};
6610 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6612 V128_lo, VectorIndexH,
6613 asm, ".8h", ".8h", ".8h", ".h",
6614 [(set (v8i16 V128:$Rd),
6615 (OpNode (v8i16 V128:$Rn),
6616 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6618 let Inst{11} = idx{2};
6619 let Inst{21} = idx{1};
6620 let Inst{20} = idx{0};
6623 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6626 asm, ".2s", ".2s", ".2s", ".s",
6627 [(set (v2i32 V64:$Rd),
6628 (OpNode (v2i32 V64:$Rn),
6629 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6631 let Inst{11} = idx{1};
6632 let Inst{21} = idx{0};
6635 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6638 asm, ".4s", ".4s", ".4s", ".s",
6639 [(set (v4i32 V128:$Rd),
6640 (OpNode (v4i32 V128:$Rn),
6641 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6643 let Inst{11} = idx{1};
6644 let Inst{21} = idx{0};
6648 multiclass SIMDVectorIndexedHSTied<bit U, bits<4> opc, string asm,
6649 SDPatternOperator OpNode> {
6650 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V64, V64,
6651 V128_lo, VectorIndexH,
6652 asm, ".4h", ".4h", ".4h", ".h",
6653 [(set (v4i16 V64:$dst),
6654 (OpNode (v4i16 V64:$Rd),(v4i16 V64:$Rn),
6655 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6657 let Inst{11} = idx{2};
6658 let Inst{21} = idx{1};
6659 let Inst{20} = idx{0};
6662 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6664 V128_lo, VectorIndexH,
6665 asm, ".8h", ".8h", ".8h", ".h",
6666 [(set (v8i16 V128:$dst),
6667 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
6668 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6670 let Inst{11} = idx{2};
6671 let Inst{21} = idx{1};
6672 let Inst{20} = idx{0};
6675 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6678 asm, ".2s", ".2s", ".2s", ".s",
6679 [(set (v2i32 V64:$dst),
6680 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
6681 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6683 let Inst{11} = idx{1};
6684 let Inst{21} = idx{0};
6687 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6690 asm, ".4s", ".4s", ".4s", ".s",
6691 [(set (v4i32 V128:$dst),
6692 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
6693 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6695 let Inst{11} = idx{1};
6696 let Inst{21} = idx{0};
6700 multiclass SIMDIndexedLongSD<bit U, bits<4> opc, string asm,
6701 SDPatternOperator OpNode> {
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 (AArch64duplane16 (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 (AArch64duplane16 (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 (AArch64duplane32 (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 (AArch64duplane32 (v4i32 V128:$Rm),
6749 VectorIndexS:$idx))))]> {
6751 let Inst{11} = idx{1};
6752 let Inst{21} = idx{0};
6755 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
6756 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
6757 asm, ".h", "", "", ".h", []> {
6759 let Inst{11} = idx{2};
6760 let Inst{21} = idx{1};
6761 let Inst{20} = idx{0};
6764 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
6765 FPR64Op, FPR32Op, V128, VectorIndexS,
6766 asm, ".s", "", "", ".s", []> {
6768 let Inst{11} = idx{1};
6769 let Inst{21} = idx{0};
6773 multiclass SIMDIndexedLongSQDMLXSDTied<bit U, bits<4> opc, string asm,
6774 SDPatternOperator Accum> {
6775 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
6777 V128_lo, VectorIndexH,
6778 asm, ".4s", ".4s", ".4h", ".h",
6779 [(set (v4i32 V128:$dst),
6780 (Accum (v4i32 V128:$Rd),
6781 (v4i32 (int_aarch64_neon_sqdmull
6783 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
6784 VectorIndexH:$idx))))))]> {
6786 let Inst{11} = idx{2};
6787 let Inst{21} = idx{1};
6788 let Inst{20} = idx{0};
6791 // FIXME: it would be nice to use the scalar (v1i32) instruction here, but an
6792 // intermediate EXTRACT_SUBREG would be untyped.
6793 def : Pat<(i32 (Accum (i32 FPR32Op:$Rd),
6794 (i32 (vector_extract (v4i32
6795 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn),
6796 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
6797 VectorIndexH:$idx)))),
6800 (!cast<Instruction>(NAME # v4i16_indexed)
6801 (SUBREG_TO_REG (i32 0), FPR32Op:$Rd, ssub), V64:$Rn,
6802 V128_lo:$Rm, VectorIndexH:$idx),
6805 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6807 V128_lo, VectorIndexH,
6808 asm#"2", ".4s", ".4s", ".8h", ".h",
6809 [(set (v4i32 V128:$dst),
6810 (Accum (v4i32 V128:$Rd),
6811 (v4i32 (int_aarch64_neon_sqdmull
6812 (extract_high_v8i16 V128:$Rn),
6814 (AArch64duplane16 (v8i16 V128_lo:$Rm),
6815 VectorIndexH:$idx))))))]> {
6817 let Inst{11} = idx{2};
6818 let Inst{21} = idx{1};
6819 let Inst{20} = idx{0};
6822 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6825 asm, ".2d", ".2d", ".2s", ".s",
6826 [(set (v2i64 V128:$dst),
6827 (Accum (v2i64 V128:$Rd),
6828 (v2i64 (int_aarch64_neon_sqdmull
6830 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm),
6831 VectorIndexS:$idx))))))]> {
6833 let Inst{11} = idx{1};
6834 let Inst{21} = idx{0};
6837 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6840 asm#"2", ".2d", ".2d", ".4s", ".s",
6841 [(set (v2i64 V128:$dst),
6842 (Accum (v2i64 V128:$Rd),
6843 (v2i64 (int_aarch64_neon_sqdmull
6844 (extract_high_v4i32 V128:$Rn),
6846 (AArch64duplane32 (v4i32 V128:$Rm),
6847 VectorIndexS:$idx))))))]> {
6849 let Inst{11} = idx{1};
6850 let Inst{21} = idx{0};
6853 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc,
6854 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
6855 asm, ".h", "", "", ".h", []> {
6857 let Inst{11} = idx{2};
6858 let Inst{21} = idx{1};
6859 let Inst{20} = idx{0};
6863 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
6864 FPR64Op, FPR32Op, V128, VectorIndexS,
6865 asm, ".s", "", "", ".s",
6866 [(set (i64 FPR64Op:$dst),
6867 (Accum (i64 FPR64Op:$Rd),
6868 (i64 (int_aarch64_neon_sqdmulls_scalar
6870 (i32 (vector_extract (v4i32 V128:$Rm),
6871 VectorIndexS:$idx))))))]> {
6874 let Inst{11} = idx{1};
6875 let Inst{21} = idx{0};
6879 multiclass SIMDVectorIndexedLongSD<bit U, bits<4> opc, string asm,
6880 SDPatternOperator OpNode> {
6881 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6882 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
6884 V128_lo, VectorIndexH,
6885 asm, ".4s", ".4s", ".4h", ".h",
6886 [(set (v4i32 V128:$Rd),
6887 (OpNode (v4i16 V64:$Rn),
6888 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6890 let Inst{11} = idx{2};
6891 let Inst{21} = idx{1};
6892 let Inst{20} = idx{0};
6895 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
6897 V128_lo, VectorIndexH,
6898 asm#"2", ".4s", ".4s", ".8h", ".h",
6899 [(set (v4i32 V128:$Rd),
6900 (OpNode (extract_high_v8i16 V128:$Rn),
6901 (extract_high_v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
6902 VectorIndexH:$idx))))]> {
6905 let Inst{11} = idx{2};
6906 let Inst{21} = idx{1};
6907 let Inst{20} = idx{0};
6910 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
6913 asm, ".2d", ".2d", ".2s", ".s",
6914 [(set (v2i64 V128:$Rd),
6915 (OpNode (v2i32 V64:$Rn),
6916 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6918 let Inst{11} = idx{1};
6919 let Inst{21} = idx{0};
6922 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
6925 asm#"2", ".2d", ".2d", ".4s", ".s",
6926 [(set (v2i64 V128:$Rd),
6927 (OpNode (extract_high_v4i32 V128:$Rn),
6928 (extract_high_v4i32 (AArch64duplane32 (v4i32 V128:$Rm),
6929 VectorIndexS:$idx))))]> {
6931 let Inst{11} = idx{1};
6932 let Inst{21} = idx{0};
6937 multiclass SIMDVectorIndexedLongSDTied<bit U, bits<4> opc, string asm,
6938 SDPatternOperator OpNode> {
6939 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6940 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
6942 V128_lo, VectorIndexH,
6943 asm, ".4s", ".4s", ".4h", ".h",
6944 [(set (v4i32 V128:$dst),
6945 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn),
6946 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
6948 let Inst{11} = idx{2};
6949 let Inst{21} = idx{1};
6950 let Inst{20} = idx{0};
6953 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
6955 V128_lo, VectorIndexH,
6956 asm#"2", ".4s", ".4s", ".8h", ".h",
6957 [(set (v4i32 V128:$dst),
6958 (OpNode (v4i32 V128:$Rd),
6959 (extract_high_v8i16 V128:$Rn),
6960 (extract_high_v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
6961 VectorIndexH:$idx))))]> {
6963 let Inst{11} = idx{2};
6964 let Inst{21} = idx{1};
6965 let Inst{20} = idx{0};
6968 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
6971 asm, ".2d", ".2d", ".2s", ".s",
6972 [(set (v2i64 V128:$dst),
6973 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn),
6974 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
6976 let Inst{11} = idx{1};
6977 let Inst{21} = idx{0};
6980 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
6983 asm#"2", ".2d", ".2d", ".4s", ".s",
6984 [(set (v2i64 V128:$dst),
6985 (OpNode (v2i64 V128:$Rd),
6986 (extract_high_v4i32 V128:$Rn),
6987 (extract_high_v4i32 (AArch64duplane32 (v4i32 V128:$Rm),
6988 VectorIndexS:$idx))))]> {
6990 let Inst{11} = idx{1};
6991 let Inst{21} = idx{0};
6996 //----------------------------------------------------------------------------
6997 // AdvSIMD scalar shift by immediate
6998 //----------------------------------------------------------------------------
7000 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7001 class BaseSIMDScalarShift<bit U, bits<5> opc, bits<7> fixed_imm,
7002 RegisterClass regtype1, RegisterClass regtype2,
7003 Operand immtype, string asm, list<dag> pattern>
7004 : I<(outs regtype1:$Rd), (ins regtype2:$Rn, immtype:$imm),
7005 asm, "\t$Rd, $Rn, $imm", "", pattern>,
7010 let Inst{31-30} = 0b01;
7012 let Inst{28-23} = 0b111110;
7013 let Inst{22-16} = fixed_imm;
7014 let Inst{15-11} = opc;
7020 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7021 class BaseSIMDScalarShiftTied<bit U, bits<5> opc, bits<7> fixed_imm,
7022 RegisterClass regtype1, RegisterClass regtype2,
7023 Operand immtype, string asm, list<dag> pattern>
7024 : I<(outs regtype1:$dst), (ins regtype1:$Rd, regtype2:$Rn, immtype:$imm),
7025 asm, "\t$Rd, $Rn, $imm", "$Rd = $dst", pattern>,
7030 let Inst{31-30} = 0b01;
7032 let Inst{28-23} = 0b111110;
7033 let Inst{22-16} = fixed_imm;
7034 let Inst{15-11} = opc;
7041 multiclass SIMDScalarRShiftSD<bit U, bits<5> opc, string asm> {
7042 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
7043 FPR32, FPR32, vecshiftR32, asm, []> {
7044 let Inst{20-16} = imm{4-0};
7047 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
7048 FPR64, FPR64, vecshiftR64, asm, []> {
7049 let Inst{21-16} = imm{5-0};
7053 multiclass SIMDScalarRShiftD<bit U, bits<5> opc, string asm,
7054 SDPatternOperator OpNode> {
7055 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
7056 FPR64, FPR64, vecshiftR64, asm,
7057 [(set (i64 FPR64:$Rd),
7058 (OpNode (i64 FPR64:$Rn), (i32 vecshiftR64:$imm)))]> {
7059 let Inst{21-16} = imm{5-0};
7062 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftR64:$imm))),
7063 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftR64:$imm)>;
7066 multiclass SIMDScalarRShiftDTied<bit U, bits<5> opc, string asm,
7067 SDPatternOperator OpNode = null_frag> {
7068 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
7069 FPR64, FPR64, vecshiftR64, asm,
7070 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn),
7071 (i32 vecshiftR64:$imm)))]> {
7072 let Inst{21-16} = imm{5-0};
7075 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
7076 (i32 vecshiftR64:$imm))),
7077 (!cast<Instruction>(NAME # "d") FPR64:$Rd, FPR64:$Rn,
7081 multiclass SIMDScalarLShiftD<bit U, bits<5> opc, string asm,
7082 SDPatternOperator OpNode> {
7083 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
7084 FPR64, FPR64, vecshiftL64, asm,
7085 [(set (v1i64 FPR64:$Rd),
7086 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
7087 let Inst{21-16} = imm{5-0};
7091 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7092 multiclass SIMDScalarLShiftDTied<bit U, bits<5> opc, string asm> {
7093 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
7094 FPR64, FPR64, vecshiftL64, asm, []> {
7095 let Inst{21-16} = imm{5-0};
7099 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7100 multiclass SIMDScalarRShiftBHS<bit U, bits<5> opc, string asm,
7101 SDPatternOperator OpNode = null_frag> {
7102 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
7103 FPR8, FPR16, vecshiftR8, asm, []> {
7104 let Inst{18-16} = imm{2-0};
7107 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
7108 FPR16, FPR32, vecshiftR16, asm, []> {
7109 let Inst{19-16} = imm{3-0};
7112 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
7113 FPR32, FPR64, vecshiftR32, asm,
7114 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn), vecshiftR32:$imm))]> {
7115 let Inst{20-16} = imm{4-0};
7119 multiclass SIMDScalarLShiftBHSD<bit U, bits<5> opc, string asm,
7120 SDPatternOperator OpNode> {
7121 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
7122 FPR8, FPR8, vecshiftL8, asm, []> {
7123 let Inst{18-16} = imm{2-0};
7126 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
7127 FPR16, FPR16, vecshiftL16, asm, []> {
7128 let Inst{19-16} = imm{3-0};
7131 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
7132 FPR32, FPR32, vecshiftL32, asm,
7133 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn), (i32 vecshiftL32:$imm)))]> {
7134 let Inst{20-16} = imm{4-0};
7137 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
7138 FPR64, FPR64, vecshiftL64, asm,
7139 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
7140 let Inst{21-16} = imm{5-0};
7143 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm))),
7144 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftL64:$imm)>;
7147 multiclass SIMDScalarRShiftBHSD<bit U, bits<5> opc, string asm> {
7148 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
7149 FPR8, FPR8, vecshiftR8, asm, []> {
7150 let Inst{18-16} = imm{2-0};
7153 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
7154 FPR16, FPR16, vecshiftR16, asm, []> {
7155 let Inst{19-16} = imm{3-0};
7158 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
7159 FPR32, FPR32, vecshiftR32, asm, []> {
7160 let Inst{20-16} = imm{4-0};
7163 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
7164 FPR64, FPR64, vecshiftR64, asm, []> {
7165 let Inst{21-16} = imm{5-0};
7169 //----------------------------------------------------------------------------
7170 // AdvSIMD vector x indexed element
7171 //----------------------------------------------------------------------------
7173 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7174 class BaseSIMDVectorShift<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
7175 RegisterOperand dst_reg, RegisterOperand src_reg,
7177 string asm, string dst_kind, string src_kind,
7179 : I<(outs dst_reg:$Rd), (ins src_reg:$Rn, immtype:$imm),
7180 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
7181 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "", pattern>,
7188 let Inst{28-23} = 0b011110;
7189 let Inst{22-16} = fixed_imm;
7190 let Inst{15-11} = opc;
7196 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7197 class BaseSIMDVectorShiftTied<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
7198 RegisterOperand vectype1, RegisterOperand vectype2,
7200 string asm, string dst_kind, string src_kind,
7202 : I<(outs vectype1:$dst), (ins vectype1:$Rd, vectype2:$Rn, immtype:$imm),
7203 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
7204 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "$Rd = $dst", pattern>,
7211 let Inst{28-23} = 0b011110;
7212 let Inst{22-16} = fixed_imm;
7213 let Inst{15-11} = opc;
7219 multiclass SIMDVectorRShiftSD<bit U, bits<5> opc, string asm,
7221 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7222 V64, V64, vecshiftR32,
7224 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (i32 imm:$imm)))]> {
7226 let Inst{20-16} = imm;
7229 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7230 V128, V128, vecshiftR32,
7232 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (i32 imm:$imm)))]> {
7234 let Inst{20-16} = imm;
7237 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7238 V128, V128, vecshiftR64,
7240 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (i32 imm:$imm)))]> {
7242 let Inst{21-16} = imm;
7246 multiclass SIMDVectorRShiftSDToFP<bit U, bits<5> opc, string asm,
7248 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7249 V64, V64, vecshiftR32,
7251 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 imm:$imm)))]> {
7253 let Inst{20-16} = imm;
7256 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7257 V128, V128, vecshiftR32,
7259 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 imm:$imm)))]> {
7261 let Inst{20-16} = imm;
7264 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7265 V128, V128, vecshiftR64,
7267 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 imm:$imm)))]> {
7269 let Inst{21-16} = imm;
7273 multiclass SIMDVectorRShiftNarrowBHS<bit U, bits<5> opc, string asm,
7274 SDPatternOperator OpNode> {
7275 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7276 V64, V128, vecshiftR16Narrow,
7278 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))]> {
7280 let Inst{18-16} = imm;
7283 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7284 V128, V128, vecshiftR16Narrow,
7285 asm#"2", ".16b", ".8h", []> {
7287 let Inst{18-16} = imm;
7288 let hasSideEffects = 0;
7291 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7292 V64, V128, vecshiftR32Narrow,
7294 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))]> {
7296 let Inst{19-16} = imm;
7299 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7300 V128, V128, vecshiftR32Narrow,
7301 asm#"2", ".8h", ".4s", []> {
7303 let Inst{19-16} = imm;
7304 let hasSideEffects = 0;
7307 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7308 V64, V128, vecshiftR64Narrow,
7310 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))]> {
7312 let Inst{20-16} = imm;
7315 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7316 V128, V128, vecshiftR64Narrow,
7317 asm#"2", ".4s", ".2d", []> {
7319 let Inst{20-16} = imm;
7320 let hasSideEffects = 0;
7323 // TableGen doesn't like patters w/ INSERT_SUBREG on the instructions
7324 // themselves, so put them here instead.
7326 // Patterns involving what's effectively an insert high and a normal
7327 // intrinsic, represented by CONCAT_VECTORS.
7328 def : Pat<(concat_vectors (v8i8 V64:$Rd),(OpNode (v8i16 V128:$Rn),
7329 vecshiftR16Narrow:$imm)),
7330 (!cast<Instruction>(NAME # "v16i8_shift")
7331 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7332 V128:$Rn, vecshiftR16Narrow:$imm)>;
7333 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn),
7334 vecshiftR32Narrow:$imm)),
7335 (!cast<Instruction>(NAME # "v8i16_shift")
7336 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7337 V128:$Rn, vecshiftR32Narrow:$imm)>;
7338 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn),
7339 vecshiftR64Narrow:$imm)),
7340 (!cast<Instruction>(NAME # "v4i32_shift")
7341 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
7342 V128:$Rn, vecshiftR64Narrow:$imm)>;
7345 multiclass SIMDVectorLShiftBHSD<bit U, bits<5> opc, string asm,
7346 SDPatternOperator OpNode> {
7347 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7348 V64, V64, vecshiftL8,
7350 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
7351 (i32 vecshiftL8:$imm)))]> {
7353 let Inst{18-16} = imm;
7356 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7357 V128, V128, vecshiftL8,
7358 asm, ".16b", ".16b",
7359 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
7360 (i32 vecshiftL8:$imm)))]> {
7362 let Inst{18-16} = imm;
7365 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7366 V64, V64, vecshiftL16,
7368 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
7369 (i32 vecshiftL16:$imm)))]> {
7371 let Inst{19-16} = imm;
7374 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7375 V128, V128, vecshiftL16,
7377 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
7378 (i32 vecshiftL16:$imm)))]> {
7380 let Inst{19-16} = imm;
7383 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7384 V64, V64, vecshiftL32,
7386 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
7387 (i32 vecshiftL32:$imm)))]> {
7389 let Inst{20-16} = imm;
7392 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7393 V128, V128, vecshiftL32,
7395 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
7396 (i32 vecshiftL32:$imm)))]> {
7398 let Inst{20-16} = imm;
7401 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7402 V128, V128, vecshiftL64,
7404 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
7405 (i32 vecshiftL64:$imm)))]> {
7407 let Inst{21-16} = imm;
7411 multiclass SIMDVectorRShiftBHSD<bit U, bits<5> opc, string asm,
7412 SDPatternOperator OpNode> {
7413 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7414 V64, V64, vecshiftR8,
7416 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
7417 (i32 vecshiftR8:$imm)))]> {
7419 let Inst{18-16} = imm;
7422 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7423 V128, V128, vecshiftR8,
7424 asm, ".16b", ".16b",
7425 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
7426 (i32 vecshiftR8:$imm)))]> {
7428 let Inst{18-16} = imm;
7431 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7432 V64, V64, vecshiftR16,
7434 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
7435 (i32 vecshiftR16:$imm)))]> {
7437 let Inst{19-16} = imm;
7440 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7441 V128, V128, vecshiftR16,
7443 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
7444 (i32 vecshiftR16:$imm)))]> {
7446 let Inst{19-16} = imm;
7449 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7450 V64, V64, vecshiftR32,
7452 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
7453 (i32 vecshiftR32:$imm)))]> {
7455 let Inst{20-16} = imm;
7458 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7459 V128, V128, vecshiftR32,
7461 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
7462 (i32 vecshiftR32:$imm)))]> {
7464 let Inst{20-16} = imm;
7467 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
7468 V128, V128, vecshiftR64,
7470 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
7471 (i32 vecshiftR64:$imm)))]> {
7473 let Inst{21-16} = imm;
7477 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
7478 multiclass SIMDVectorRShiftBHSDTied<bit U, bits<5> opc, string asm,
7479 SDPatternOperator OpNode = null_frag> {
7480 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
7481 V64, V64, vecshiftR8, asm, ".8b", ".8b",
7482 [(set (v8i8 V64:$dst),
7483 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
7484 (i32 vecshiftR8:$imm)))]> {
7486 let Inst{18-16} = imm;
7489 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7490 V128, V128, vecshiftR8, asm, ".16b", ".16b",
7491 [(set (v16i8 V128:$dst),
7492 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
7493 (i32 vecshiftR8:$imm)))]> {
7495 let Inst{18-16} = imm;
7498 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
7499 V64, V64, vecshiftR16, asm, ".4h", ".4h",
7500 [(set (v4i16 V64:$dst),
7501 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
7502 (i32 vecshiftR16:$imm)))]> {
7504 let Inst{19-16} = imm;
7507 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7508 V128, V128, vecshiftR16, asm, ".8h", ".8h",
7509 [(set (v8i16 V128:$dst),
7510 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7511 (i32 vecshiftR16:$imm)))]> {
7513 let Inst{19-16} = imm;
7516 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
7517 V64, V64, vecshiftR32, asm, ".2s", ".2s",
7518 [(set (v2i32 V64:$dst),
7519 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7520 (i32 vecshiftR32:$imm)))]> {
7522 let Inst{20-16} = imm;
7525 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7526 V128, V128, vecshiftR32, asm, ".4s", ".4s",
7527 [(set (v4i32 V128:$dst),
7528 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7529 (i32 vecshiftR32:$imm)))]> {
7531 let Inst{20-16} = imm;
7534 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
7535 V128, V128, vecshiftR64,
7536 asm, ".2d", ".2d", [(set (v2i64 V128:$dst),
7537 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
7538 (i32 vecshiftR64:$imm)))]> {
7540 let Inst{21-16} = imm;
7544 multiclass SIMDVectorLShiftBHSDTied<bit U, bits<5> opc, string asm,
7545 SDPatternOperator OpNode = null_frag> {
7546 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
7547 V64, V64, vecshiftL8,
7549 [(set (v8i8 V64:$dst),
7550 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
7551 (i32 vecshiftL8:$imm)))]> {
7553 let Inst{18-16} = imm;
7556 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
7557 V128, V128, vecshiftL8,
7558 asm, ".16b", ".16b",
7559 [(set (v16i8 V128:$dst),
7560 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
7561 (i32 vecshiftL8:$imm)))]> {
7563 let Inst{18-16} = imm;
7566 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
7567 V64, V64, vecshiftL16,
7569 [(set (v4i16 V64:$dst),
7570 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
7571 (i32 vecshiftL16:$imm)))]> {
7573 let Inst{19-16} = imm;
7576 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
7577 V128, V128, vecshiftL16,
7579 [(set (v8i16 V128:$dst),
7580 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7581 (i32 vecshiftL16:$imm)))]> {
7583 let Inst{19-16} = imm;
7586 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
7587 V64, V64, vecshiftL32,
7589 [(set (v2i32 V64:$dst),
7590 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7591 (i32 vecshiftL32:$imm)))]> {
7593 let Inst{20-16} = imm;
7596 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
7597 V128, V128, vecshiftL32,
7599 [(set (v4i32 V128:$dst),
7600 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7601 (i32 vecshiftL32:$imm)))]> {
7603 let Inst{20-16} = imm;
7606 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
7607 V128, V128, vecshiftL64,
7609 [(set (v2i64 V128:$dst),
7610 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
7611 (i32 vecshiftL64:$imm)))]> {
7613 let Inst{21-16} = imm;
7617 multiclass SIMDVectorLShiftLongBHSD<bit U, bits<5> opc, string asm,
7618 SDPatternOperator OpNode> {
7619 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
7620 V128, V64, vecshiftL8, asm, ".8h", ".8b",
7621 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), vecshiftL8:$imm))]> {
7623 let Inst{18-16} = imm;
7626 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
7627 V128, V128, vecshiftL8,
7628 asm#"2", ".8h", ".16b",
7629 [(set (v8i16 V128:$Rd),
7630 (OpNode (extract_high_v16i8 V128:$Rn), vecshiftL8:$imm))]> {
7632 let Inst{18-16} = imm;
7635 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
7636 V128, V64, vecshiftL16, asm, ".4s", ".4h",
7637 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), vecshiftL16:$imm))]> {
7639 let Inst{19-16} = imm;
7642 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
7643 V128, V128, vecshiftL16,
7644 asm#"2", ".4s", ".8h",
7645 [(set (v4i32 V128:$Rd),
7646 (OpNode (extract_high_v8i16 V128:$Rn), vecshiftL16:$imm))]> {
7649 let Inst{19-16} = imm;
7652 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
7653 V128, V64, vecshiftL32, asm, ".2d", ".2s",
7654 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), vecshiftL32:$imm))]> {
7656 let Inst{20-16} = imm;
7659 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
7660 V128, V128, vecshiftL32,
7661 asm#"2", ".2d", ".4s",
7662 [(set (v2i64 V128:$Rd),
7663 (OpNode (extract_high_v4i32 V128:$Rn), vecshiftL32:$imm))]> {
7665 let Inst{20-16} = imm;
7671 // Vector load/store
7673 // SIMD ldX/stX no-index memory references don't allow the optional
7674 // ", #0" constant and handle post-indexing explicitly, so we use
7675 // a more specialized parse method for them. Otherwise, it's the same as
7676 // the general GPR64sp handling.
7678 class BaseSIMDLdSt<bit Q, bit L, bits<4> opcode, bits<2> size,
7679 string asm, dag oops, dag iops, list<dag> pattern>
7680 : I<oops, iops, asm, "\t$Vt, [$Rn]", "", pattern> {
7685 let Inst{29-23} = 0b0011000;
7687 let Inst{21-16} = 0b000000;
7688 let Inst{15-12} = opcode;
7689 let Inst{11-10} = size;
7694 class BaseSIMDLdStPost<bit Q, bit L, bits<4> opcode, bits<2> size,
7695 string asm, dag oops, dag iops>
7696 : I<oops, iops, asm, "\t$Vt, [$Rn], $Xm", "$Rn = $wback", []> {
7702 let Inst{29-23} = 0b0011001;
7705 let Inst{20-16} = Xm;
7706 let Inst{15-12} = opcode;
7707 let Inst{11-10} = size;
7712 // The immediate form of AdvSIMD post-indexed addressing is encoded with
7713 // register post-index addressing from the zero register.
7714 multiclass SIMDLdStAliases<string asm, string layout, string Count,
7715 int Offset, int Size> {
7716 // E.g. "ld1 { v0.8b, v1.8b }, [x1], #16"
7717 // "ld1\t$Vt, [$Rn], #16"
7718 // may get mapped to
7719 // (LD1Twov8b_POST VecListTwo8b:$Vt, GPR64sp:$Rn, XZR)
7720 def : InstAlias<asm # "\t$Vt, [$Rn], #" # Offset,
7721 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7723 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
7726 // E.g. "ld1.8b { v0, v1 }, [x1], #16"
7727 // "ld1.8b\t$Vt, [$Rn], #16"
7728 // may get mapped to
7729 // (LD1Twov8b_POST VecListTwo64:$Vt, GPR64sp:$Rn, XZR)
7730 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], #" # Offset,
7731 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7733 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7736 // E.g. "ld1.8b { v0, v1 }, [x1]"
7737 // "ld1\t$Vt, [$Rn]"
7738 // may get mapped to
7739 // (LD1Twov8b VecListTwo64:$Vt, GPR64sp:$Rn)
7740 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn]",
7741 (!cast<Instruction>(NAME # Count # "v" # layout)
7742 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7745 // E.g. "ld1.8b { v0, v1 }, [x1], x2"
7746 // "ld1\t$Vt, [$Rn], $Xm"
7747 // may get mapped to
7748 // (LD1Twov8b_POST VecListTwo64:$Vt, GPR64sp:$Rn, GPR64pi8:$Xm)
7749 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], $Xm",
7750 (!cast<Instruction>(NAME # Count # "v" # layout # "_POST")
7752 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
7753 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
7756 multiclass BaseSIMDLdN<string Count, string asm, string veclist, int Offset128,
7757 int Offset64, bits<4> opcode> {
7758 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
7759 def v16b: BaseSIMDLdSt<1, 1, opcode, 0b00, asm,
7760 (outs !cast<RegisterOperand>(veclist # "16b"):$Vt),
7761 (ins GPR64sp:$Rn), []>;
7762 def v8h : BaseSIMDLdSt<1, 1, opcode, 0b01, asm,
7763 (outs !cast<RegisterOperand>(veclist # "8h"):$Vt),
7764 (ins GPR64sp:$Rn), []>;
7765 def v4s : BaseSIMDLdSt<1, 1, opcode, 0b10, asm,
7766 (outs !cast<RegisterOperand>(veclist # "4s"):$Vt),
7767 (ins GPR64sp:$Rn), []>;
7768 def v2d : BaseSIMDLdSt<1, 1, opcode, 0b11, asm,
7769 (outs !cast<RegisterOperand>(veclist # "2d"):$Vt),
7770 (ins GPR64sp:$Rn), []>;
7771 def v8b : BaseSIMDLdSt<0, 1, opcode, 0b00, asm,
7772 (outs !cast<RegisterOperand>(veclist # "8b"):$Vt),
7773 (ins GPR64sp:$Rn), []>;
7774 def v4h : BaseSIMDLdSt<0, 1, opcode, 0b01, asm,
7775 (outs !cast<RegisterOperand>(veclist # "4h"):$Vt),
7776 (ins GPR64sp:$Rn), []>;
7777 def v2s : BaseSIMDLdSt<0, 1, opcode, 0b10, asm,
7778 (outs !cast<RegisterOperand>(veclist # "2s"):$Vt),
7779 (ins GPR64sp:$Rn), []>;
7782 def v16b_POST: BaseSIMDLdStPost<1, 1, opcode, 0b00, asm,
7783 (outs GPR64sp:$wback,
7784 !cast<RegisterOperand>(veclist # "16b"):$Vt),
7786 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7787 def v8h_POST : BaseSIMDLdStPost<1, 1, opcode, 0b01, asm,
7788 (outs GPR64sp:$wback,
7789 !cast<RegisterOperand>(veclist # "8h"):$Vt),
7791 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7792 def v4s_POST : BaseSIMDLdStPost<1, 1, opcode, 0b10, asm,
7793 (outs GPR64sp:$wback,
7794 !cast<RegisterOperand>(veclist # "4s"):$Vt),
7796 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7797 def v2d_POST : BaseSIMDLdStPost<1, 1, opcode, 0b11, asm,
7798 (outs GPR64sp:$wback,
7799 !cast<RegisterOperand>(veclist # "2d"):$Vt),
7801 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7802 def v8b_POST : BaseSIMDLdStPost<0, 1, opcode, 0b00, asm,
7803 (outs GPR64sp:$wback,
7804 !cast<RegisterOperand>(veclist # "8b"):$Vt),
7806 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7807 def v4h_POST : BaseSIMDLdStPost<0, 1, opcode, 0b01, asm,
7808 (outs GPR64sp:$wback,
7809 !cast<RegisterOperand>(veclist # "4h"):$Vt),
7811 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7812 def v2s_POST : BaseSIMDLdStPost<0, 1, opcode, 0b10, asm,
7813 (outs GPR64sp:$wback,
7814 !cast<RegisterOperand>(veclist # "2s"):$Vt),
7816 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7819 defm : SIMDLdStAliases<asm, "16b", Count, Offset128, 128>;
7820 defm : SIMDLdStAliases<asm, "8h", Count, Offset128, 128>;
7821 defm : SIMDLdStAliases<asm, "4s", Count, Offset128, 128>;
7822 defm : SIMDLdStAliases<asm, "2d", Count, Offset128, 128>;
7823 defm : SIMDLdStAliases<asm, "8b", Count, Offset64, 64>;
7824 defm : SIMDLdStAliases<asm, "4h", Count, Offset64, 64>;
7825 defm : SIMDLdStAliases<asm, "2s", Count, Offset64, 64>;
7828 // Only ld1/st1 has a v1d version.
7829 multiclass BaseSIMDStN<string Count, string asm, string veclist, int Offset128,
7830 int Offset64, bits<4> opcode> {
7831 let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in {
7832 def v16b : BaseSIMDLdSt<1, 0, opcode, 0b00, asm, (outs),
7833 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
7835 def v8h : BaseSIMDLdSt<1, 0, opcode, 0b01, asm, (outs),
7836 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
7838 def v4s : BaseSIMDLdSt<1, 0, opcode, 0b10, asm, (outs),
7839 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
7841 def v2d : BaseSIMDLdSt<1, 0, opcode, 0b11, asm, (outs),
7842 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
7844 def v8b : BaseSIMDLdSt<0, 0, opcode, 0b00, asm, (outs),
7845 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
7847 def v4h : BaseSIMDLdSt<0, 0, opcode, 0b01, asm, (outs),
7848 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
7850 def v2s : BaseSIMDLdSt<0, 0, opcode, 0b10, asm, (outs),
7851 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
7854 def v16b_POST : BaseSIMDLdStPost<1, 0, opcode, 0b00, asm,
7855 (outs GPR64sp:$wback),
7856 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
7858 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7859 def v8h_POST : BaseSIMDLdStPost<1, 0, opcode, 0b01, asm,
7860 (outs GPR64sp:$wback),
7861 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
7863 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7864 def v4s_POST : BaseSIMDLdStPost<1, 0, opcode, 0b10, asm,
7865 (outs GPR64sp:$wback),
7866 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
7868 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7869 def v2d_POST : BaseSIMDLdStPost<1, 0, opcode, 0b11, asm,
7870 (outs GPR64sp:$wback),
7871 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
7873 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
7874 def v8b_POST : BaseSIMDLdStPost<0, 0, opcode, 0b00, asm,
7875 (outs GPR64sp:$wback),
7876 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
7878 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7879 def v4h_POST : BaseSIMDLdStPost<0, 0, opcode, 0b01, asm,
7880 (outs GPR64sp:$wback),
7881 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
7883 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7884 def v2s_POST : BaseSIMDLdStPost<0, 0, opcode, 0b10, asm,
7885 (outs GPR64sp:$wback),
7886 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
7888 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7891 defm : SIMDLdStAliases<asm, "16b", Count, Offset128, 128>;
7892 defm : SIMDLdStAliases<asm, "8h", Count, Offset128, 128>;
7893 defm : SIMDLdStAliases<asm, "4s", Count, Offset128, 128>;
7894 defm : SIMDLdStAliases<asm, "2d", Count, Offset128, 128>;
7895 defm : SIMDLdStAliases<asm, "8b", Count, Offset64, 64>;
7896 defm : SIMDLdStAliases<asm, "4h", Count, Offset64, 64>;
7897 defm : SIMDLdStAliases<asm, "2s", Count, Offset64, 64>;
7900 multiclass BaseSIMDLd1<string Count, string asm, string veclist,
7901 int Offset128, int Offset64, bits<4> opcode>
7902 : BaseSIMDLdN<Count, asm, veclist, Offset128, Offset64, opcode> {
7904 // LD1 instructions have extra "1d" variants.
7905 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
7906 def v1d : BaseSIMDLdSt<0, 1, opcode, 0b11, asm,
7907 (outs !cast<RegisterOperand>(veclist # "1d"):$Vt),
7908 (ins GPR64sp:$Rn), []>;
7910 def v1d_POST : BaseSIMDLdStPost<0, 1, opcode, 0b11, asm,
7911 (outs GPR64sp:$wback,
7912 !cast<RegisterOperand>(veclist # "1d"):$Vt),
7914 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7917 defm : SIMDLdStAliases<asm, "1d", Count, Offset64, 64>;
7920 multiclass BaseSIMDSt1<string Count, string asm, string veclist,
7921 int Offset128, int Offset64, bits<4> opcode>
7922 : BaseSIMDStN<Count, asm, veclist, Offset128, Offset64, opcode> {
7924 // ST1 instructions have extra "1d" variants.
7925 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
7926 def v1d : BaseSIMDLdSt<0, 0, opcode, 0b11, asm, (outs),
7927 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
7930 def v1d_POST : BaseSIMDLdStPost<0, 0, opcode, 0b11, asm,
7931 (outs GPR64sp:$wback),
7932 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
7934 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
7937 defm : SIMDLdStAliases<asm, "1d", Count, Offset64, 64>;
7940 multiclass SIMDLd1Multiple<string asm> {
7941 defm One : BaseSIMDLd1<"One", asm, "VecListOne", 16, 8, 0b0111>;
7942 defm Two : BaseSIMDLd1<"Two", asm, "VecListTwo", 32, 16, 0b1010>;
7943 defm Three : BaseSIMDLd1<"Three", asm, "VecListThree", 48, 24, 0b0110>;
7944 defm Four : BaseSIMDLd1<"Four", asm, "VecListFour", 64, 32, 0b0010>;
7947 multiclass SIMDSt1Multiple<string asm> {
7948 defm One : BaseSIMDSt1<"One", asm, "VecListOne", 16, 8, 0b0111>;
7949 defm Two : BaseSIMDSt1<"Two", asm, "VecListTwo", 32, 16, 0b1010>;
7950 defm Three : BaseSIMDSt1<"Three", asm, "VecListThree", 48, 24, 0b0110>;
7951 defm Four : BaseSIMDSt1<"Four", asm, "VecListFour", 64, 32, 0b0010>;
7954 multiclass SIMDLd2Multiple<string asm> {
7955 defm Two : BaseSIMDLdN<"Two", asm, "VecListTwo", 32, 16, 0b1000>;
7958 multiclass SIMDSt2Multiple<string asm> {
7959 defm Two : BaseSIMDStN<"Two", asm, "VecListTwo", 32, 16, 0b1000>;
7962 multiclass SIMDLd3Multiple<string asm> {
7963 defm Three : BaseSIMDLdN<"Three", asm, "VecListThree", 48, 24, 0b0100>;
7966 multiclass SIMDSt3Multiple<string asm> {
7967 defm Three : BaseSIMDStN<"Three", asm, "VecListThree", 48, 24, 0b0100>;
7970 multiclass SIMDLd4Multiple<string asm> {
7971 defm Four : BaseSIMDLdN<"Four", asm, "VecListFour", 64, 32, 0b0000>;
7974 multiclass SIMDSt4Multiple<string asm> {
7975 defm Four : BaseSIMDStN<"Four", asm, "VecListFour", 64, 32, 0b0000>;
7979 // AdvSIMD Load/store single-element
7982 class BaseSIMDLdStSingle<bit L, bit R, bits<3> opcode,
7983 string asm, string operands, string cst,
7984 dag oops, dag iops, list<dag> pattern>
7985 : I<oops, iops, asm, operands, cst, pattern> {
7989 let Inst{29-24} = 0b001101;
7992 let Inst{15-13} = opcode;
7997 class BaseSIMDLdStSingleTied<bit L, bit R, bits<3> opcode,
7998 string asm, string operands, string cst,
7999 dag oops, dag iops, list<dag> pattern>
8000 : I<oops, iops, asm, operands, "$Vt = $dst," # cst, pattern> {
8004 let Inst{29-24} = 0b001101;
8007 let Inst{15-13} = opcode;
8013 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8014 class BaseSIMDLdR<bit Q, bit R, bits<3> opcode, bit S, bits<2> size, string asm,
8016 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, [$Rn]", "",
8017 (outs listtype:$Vt), (ins GPR64sp:$Rn),
8021 let Inst{20-16} = 0b00000;
8023 let Inst{11-10} = size;
8025 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8026 class BaseSIMDLdRPost<bit Q, bit R, bits<3> opcode, bit S, bits<2> size,
8027 string asm, Operand listtype, Operand GPR64pi>
8028 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, [$Rn], $Xm",
8030 (outs GPR64sp:$wback, listtype:$Vt),
8031 (ins GPR64sp:$Rn, GPR64pi:$Xm), []> {
8035 let Inst{20-16} = Xm;
8037 let Inst{11-10} = size;
8040 multiclass SIMDLdrAliases<string asm, string layout, string Count,
8041 int Offset, int Size> {
8042 // E.g. "ld1r { v0.8b }, [x1], #1"
8043 // "ld1r.8b\t$Vt, [$Rn], #1"
8044 // may get mapped to
8045 // (LD1Rv8b_POST VecListOne8b:$Vt, GPR64sp:$Rn, XZR)
8046 def : InstAlias<asm # "\t$Vt, [$Rn], #" # Offset,
8047 (!cast<Instruction>(NAME # "v" # layout # "_POST")
8049 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
8052 // E.g. "ld1r.8b { v0 }, [x1], #1"
8053 // "ld1r.8b\t$Vt, [$Rn], #1"
8054 // may get mapped to
8055 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, XZR)
8056 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], #" # Offset,
8057 (!cast<Instruction>(NAME # "v" # layout # "_POST")
8059 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
8062 // E.g. "ld1r.8b { v0 }, [x1]"
8063 // "ld1r.8b\t$Vt, [$Rn]"
8064 // may get mapped to
8065 // (LD1Rv8b VecListOne64:$Vt, GPR64sp:$Rn)
8066 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn]",
8067 (!cast<Instruction>(NAME # "v" # layout)
8068 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
8071 // E.g. "ld1r.8b { v0 }, [x1], x2"
8072 // "ld1r.8b\t$Vt, [$Rn], $Xm"
8073 // may get mapped to
8074 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, GPR64pi1:$Xm)
8075 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], $Xm",
8076 (!cast<Instruction>(NAME # "v" # layout # "_POST")
8078 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
8079 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
8082 multiclass SIMDLdR<bit R, bits<3> opcode, bit S, string asm, string Count,
8083 int Offset1, int Offset2, int Offset4, int Offset8> {
8084 def v8b : BaseSIMDLdR<0, R, opcode, S, 0b00, asm,
8085 !cast<Operand>("VecList" # Count # "8b")>;
8086 def v16b: BaseSIMDLdR<1, R, opcode, S, 0b00, asm,
8087 !cast<Operand>("VecList" # Count #"16b")>;
8088 def v4h : BaseSIMDLdR<0, R, opcode, S, 0b01, asm,
8089 !cast<Operand>("VecList" # Count #"4h")>;
8090 def v8h : BaseSIMDLdR<1, R, opcode, S, 0b01, asm,
8091 !cast<Operand>("VecList" # Count #"8h")>;
8092 def v2s : BaseSIMDLdR<0, R, opcode, S, 0b10, asm,
8093 !cast<Operand>("VecList" # Count #"2s")>;
8094 def v4s : BaseSIMDLdR<1, R, opcode, S, 0b10, asm,
8095 !cast<Operand>("VecList" # Count #"4s")>;
8096 def v1d : BaseSIMDLdR<0, R, opcode, S, 0b11, asm,
8097 !cast<Operand>("VecList" # Count #"1d")>;
8098 def v2d : BaseSIMDLdR<1, R, opcode, S, 0b11, asm,
8099 !cast<Operand>("VecList" # Count #"2d")>;
8101 def v8b_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b00, asm,
8102 !cast<Operand>("VecList" # Count # "8b"),
8103 !cast<Operand>("GPR64pi" # Offset1)>;
8104 def v16b_POST: BaseSIMDLdRPost<1, R, opcode, S, 0b00, asm,
8105 !cast<Operand>("VecList" # Count # "16b"),
8106 !cast<Operand>("GPR64pi" # Offset1)>;
8107 def v4h_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b01, asm,
8108 !cast<Operand>("VecList" # Count # "4h"),
8109 !cast<Operand>("GPR64pi" # Offset2)>;
8110 def v8h_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b01, asm,
8111 !cast<Operand>("VecList" # Count # "8h"),
8112 !cast<Operand>("GPR64pi" # Offset2)>;
8113 def v2s_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b10, asm,
8114 !cast<Operand>("VecList" # Count # "2s"),
8115 !cast<Operand>("GPR64pi" # Offset4)>;
8116 def v4s_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b10, asm,
8117 !cast<Operand>("VecList" # Count # "4s"),
8118 !cast<Operand>("GPR64pi" # Offset4)>;
8119 def v1d_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b11, asm,
8120 !cast<Operand>("VecList" # Count # "1d"),
8121 !cast<Operand>("GPR64pi" # Offset8)>;
8122 def v2d_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b11, asm,
8123 !cast<Operand>("VecList" # Count # "2d"),
8124 !cast<Operand>("GPR64pi" # Offset8)>;
8126 defm : SIMDLdrAliases<asm, "8b", Count, Offset1, 64>;
8127 defm : SIMDLdrAliases<asm, "16b", Count, Offset1, 128>;
8128 defm : SIMDLdrAliases<asm, "4h", Count, Offset2, 64>;
8129 defm : SIMDLdrAliases<asm, "8h", Count, Offset2, 128>;
8130 defm : SIMDLdrAliases<asm, "2s", Count, Offset4, 64>;
8131 defm : SIMDLdrAliases<asm, "4s", Count, Offset4, 128>;
8132 defm : SIMDLdrAliases<asm, "1d", Count, Offset8, 64>;
8133 defm : SIMDLdrAliases<asm, "2d", Count, Offset8, 128>;
8136 class SIMDLdStSingleB<bit L, bit R, bits<3> opcode, string asm,
8137 dag oops, dag iops, list<dag> pattern>
8138 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
8140 // idx encoded in Q:S:size fields.
8142 let Inst{30} = idx{3};
8144 let Inst{20-16} = 0b00000;
8145 let Inst{12} = idx{2};
8146 let Inst{11-10} = idx{1-0};
8148 class SIMDLdStSingleBTied<bit L, bit R, bits<3> opcode, string asm,
8149 dag oops, dag iops, list<dag> pattern>
8150 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
8151 oops, iops, pattern> {
8152 // idx encoded in Q:S:size fields.
8154 let Inst{30} = idx{3};
8156 let Inst{20-16} = 0b00000;
8157 let Inst{12} = idx{2};
8158 let Inst{11-10} = idx{1-0};
8160 class SIMDLdStSingleBPost<bit L, bit R, bits<3> opcode, string asm,
8162 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8163 "$Rn = $wback", oops, iops, []> {
8164 // idx encoded in Q:S:size fields.
8167 let Inst{30} = idx{3};
8169 let Inst{20-16} = Xm;
8170 let Inst{12} = idx{2};
8171 let Inst{11-10} = idx{1-0};
8173 class SIMDLdStSingleBTiedPost<bit L, bit R, bits<3> opcode, string asm,
8175 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8176 "$Rn = $wback", oops, iops, []> {
8177 // idx encoded in Q:S:size fields.
8180 let Inst{30} = idx{3};
8182 let Inst{20-16} = Xm;
8183 let Inst{12} = idx{2};
8184 let Inst{11-10} = idx{1-0};
8187 class SIMDLdStSingleH<bit L, bit R, bits<3> opcode, bit size, string asm,
8188 dag oops, dag iops, list<dag> pattern>
8189 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
8191 // idx encoded in Q:S:size<1> fields.
8193 let Inst{30} = idx{2};
8195 let Inst{20-16} = 0b00000;
8196 let Inst{12} = idx{1};
8197 let Inst{11} = idx{0};
8198 let Inst{10} = size;
8200 class SIMDLdStSingleHTied<bit L, bit R, bits<3> opcode, bit size, string asm,
8201 dag oops, dag iops, list<dag> pattern>
8202 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
8203 oops, iops, pattern> {
8204 // idx encoded in Q:S:size<1> fields.
8206 let Inst{30} = idx{2};
8208 let Inst{20-16} = 0b00000;
8209 let Inst{12} = idx{1};
8210 let Inst{11} = idx{0};
8211 let Inst{10} = size;
8214 class SIMDLdStSingleHPost<bit L, bit R, bits<3> opcode, bit size, string asm,
8216 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8217 "$Rn = $wback", oops, iops, []> {
8218 // idx encoded in Q:S:size<1> fields.
8221 let Inst{30} = idx{2};
8223 let Inst{20-16} = Xm;
8224 let Inst{12} = idx{1};
8225 let Inst{11} = idx{0};
8226 let Inst{10} = size;
8228 class SIMDLdStSingleHTiedPost<bit L, bit R, bits<3> opcode, bit size, string asm,
8230 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8231 "$Rn = $wback", oops, iops, []> {
8232 // idx encoded in Q:S:size<1> fields.
8235 let Inst{30} = idx{2};
8237 let Inst{20-16} = Xm;
8238 let Inst{12} = idx{1};
8239 let Inst{11} = idx{0};
8240 let Inst{10} = size;
8242 class SIMDLdStSingleS<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8243 dag oops, dag iops, list<dag> pattern>
8244 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
8246 // idx encoded in Q:S fields.
8248 let Inst{30} = idx{1};
8250 let Inst{20-16} = 0b00000;
8251 let Inst{12} = idx{0};
8252 let Inst{11-10} = size;
8254 class SIMDLdStSingleSTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8255 dag oops, dag iops, list<dag> pattern>
8256 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
8257 oops, iops, pattern> {
8258 // idx encoded in Q:S fields.
8260 let Inst{30} = idx{1};
8262 let Inst{20-16} = 0b00000;
8263 let Inst{12} = idx{0};
8264 let Inst{11-10} = size;
8266 class SIMDLdStSingleSPost<bit L, bit R, bits<3> opcode, bits<2> size,
8267 string asm, dag oops, dag iops>
8268 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8269 "$Rn = $wback", oops, iops, []> {
8270 // idx encoded in Q:S fields.
8273 let Inst{30} = idx{1};
8275 let Inst{20-16} = Xm;
8276 let Inst{12} = idx{0};
8277 let Inst{11-10} = size;
8279 class SIMDLdStSingleSTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
8280 string asm, dag oops, dag iops>
8281 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8282 "$Rn = $wback", oops, iops, []> {
8283 // idx encoded in Q:S fields.
8286 let Inst{30} = idx{1};
8288 let Inst{20-16} = Xm;
8289 let Inst{12} = idx{0};
8290 let Inst{11-10} = size;
8292 class SIMDLdStSingleD<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8293 dag oops, dag iops, list<dag> pattern>
8294 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
8296 // idx encoded in Q field.
8300 let Inst{20-16} = 0b00000;
8302 let Inst{11-10} = size;
8304 class SIMDLdStSingleDTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
8305 dag oops, dag iops, list<dag> pattern>
8306 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
8307 oops, iops, pattern> {
8308 // idx encoded in Q field.
8312 let Inst{20-16} = 0b00000;
8314 let Inst{11-10} = size;
8316 class SIMDLdStSingleDPost<bit L, bit R, bits<3> opcode, bits<2> size,
8317 string asm, dag oops, dag iops>
8318 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8319 "$Rn = $wback", oops, iops, []> {
8320 // idx encoded in Q field.
8325 let Inst{20-16} = Xm;
8327 let Inst{11-10} = size;
8329 class SIMDLdStSingleDTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
8330 string asm, dag oops, dag iops>
8331 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
8332 "$Rn = $wback", oops, iops, []> {
8333 // idx encoded in Q field.
8338 let Inst{20-16} = Xm;
8340 let Inst{11-10} = size;
8343 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8344 multiclass SIMDLdSingleBTied<bit R, bits<3> opcode, string asm,
8345 RegisterOperand listtype,
8346 RegisterOperand GPR64pi> {
8347 def i8 : SIMDLdStSingleBTied<1, R, opcode, asm,
8348 (outs listtype:$dst),
8349 (ins listtype:$Vt, VectorIndexB:$idx,
8352 def i8_POST : SIMDLdStSingleBTiedPost<1, R, opcode, asm,
8353 (outs GPR64sp:$wback, listtype:$dst),
8354 (ins listtype:$Vt, VectorIndexB:$idx,
8355 GPR64sp:$Rn, GPR64pi:$Xm)>;
8357 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8358 multiclass SIMDLdSingleHTied<bit R, bits<3> opcode, bit size, string asm,
8359 RegisterOperand listtype,
8360 RegisterOperand GPR64pi> {
8361 def i16 : SIMDLdStSingleHTied<1, R, opcode, size, asm,
8362 (outs listtype:$dst),
8363 (ins listtype:$Vt, VectorIndexH:$idx,
8366 def i16_POST : SIMDLdStSingleHTiedPost<1, R, opcode, size, asm,
8367 (outs GPR64sp:$wback, listtype:$dst),
8368 (ins listtype:$Vt, VectorIndexH:$idx,
8369 GPR64sp:$Rn, GPR64pi:$Xm)>;
8371 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8372 multiclass SIMDLdSingleSTied<bit R, bits<3> opcode, bits<2> size,string asm,
8373 RegisterOperand listtype,
8374 RegisterOperand GPR64pi> {
8375 def i32 : SIMDLdStSingleSTied<1, R, opcode, size, asm,
8376 (outs listtype:$dst),
8377 (ins listtype:$Vt, VectorIndexS:$idx,
8380 def i32_POST : SIMDLdStSingleSTiedPost<1, R, opcode, size, asm,
8381 (outs GPR64sp:$wback, listtype:$dst),
8382 (ins listtype:$Vt, VectorIndexS:$idx,
8383 GPR64sp:$Rn, GPR64pi:$Xm)>;
8385 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
8386 multiclass SIMDLdSingleDTied<bit R, bits<3> opcode, bits<2> size, string asm,
8387 RegisterOperand listtype, RegisterOperand GPR64pi> {
8388 def i64 : SIMDLdStSingleDTied<1, R, opcode, size, asm,
8389 (outs listtype:$dst),
8390 (ins listtype:$Vt, VectorIndexD:$idx,
8393 def i64_POST : SIMDLdStSingleDTiedPost<1, R, opcode, size, asm,
8394 (outs GPR64sp:$wback, listtype:$dst),
8395 (ins listtype:$Vt, VectorIndexD:$idx,
8396 GPR64sp:$Rn, GPR64pi:$Xm)>;
8398 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8399 multiclass SIMDStSingleB<bit R, bits<3> opcode, string asm,
8400 RegisterOperand listtype, RegisterOperand GPR64pi> {
8401 def i8 : SIMDLdStSingleB<0, R, opcode, asm,
8402 (outs), (ins listtype:$Vt, VectorIndexB:$idx,
8405 def i8_POST : SIMDLdStSingleBPost<0, R, opcode, asm,
8406 (outs GPR64sp:$wback),
8407 (ins listtype:$Vt, VectorIndexB:$idx,
8408 GPR64sp:$Rn, GPR64pi:$Xm)>;
8410 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8411 multiclass SIMDStSingleH<bit R, bits<3> opcode, bit size, string asm,
8412 RegisterOperand listtype, RegisterOperand GPR64pi> {
8413 def i16 : SIMDLdStSingleH<0, R, opcode, size, asm,
8414 (outs), (ins listtype:$Vt, VectorIndexH:$idx,
8417 def i16_POST : SIMDLdStSingleHPost<0, R, opcode, size, asm,
8418 (outs GPR64sp:$wback),
8419 (ins listtype:$Vt, VectorIndexH:$idx,
8420 GPR64sp:$Rn, GPR64pi:$Xm)>;
8422 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8423 multiclass SIMDStSingleS<bit R, bits<3> opcode, bits<2> size,string asm,
8424 RegisterOperand listtype, RegisterOperand GPR64pi> {
8425 def i32 : SIMDLdStSingleS<0, R, opcode, size, asm,
8426 (outs), (ins listtype:$Vt, VectorIndexS:$idx,
8429 def i32_POST : SIMDLdStSingleSPost<0, R, opcode, size, asm,
8430 (outs GPR64sp:$wback),
8431 (ins listtype:$Vt, VectorIndexS:$idx,
8432 GPR64sp:$Rn, GPR64pi:$Xm)>;
8434 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
8435 multiclass SIMDStSingleD<bit R, bits<3> opcode, bits<2> size, string asm,
8436 RegisterOperand listtype, RegisterOperand GPR64pi> {
8437 def i64 : SIMDLdStSingleD<0, R, opcode, size, asm,
8438 (outs), (ins listtype:$Vt, VectorIndexD:$idx,
8441 def i64_POST : SIMDLdStSingleDPost<0, R, opcode, size, asm,
8442 (outs GPR64sp:$wback),
8443 (ins listtype:$Vt, VectorIndexD:$idx,
8444 GPR64sp:$Rn, GPR64pi:$Xm)>;
8447 multiclass SIMDLdStSingleAliases<string asm, string layout, string Type,
8448 string Count, int Offset, Operand idxtype> {
8449 // E.g. "ld1 { v0.8b }[0], [x1], #1"
8450 // "ld1\t$Vt, [$Rn], #1"
8451 // may get mapped to
8452 // (LD1Rv8b_POST VecListOne8b:$Vt, GPR64sp:$Rn, XZR)
8453 def : InstAlias<asm # "\t$Vt$idx, [$Rn], #" # Offset,
8454 (!cast<Instruction>(NAME # Type # "_POST")
8456 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
8457 idxtype:$idx, XZR), 1>;
8459 // E.g. "ld1.8b { v0 }[0], [x1], #1"
8460 // "ld1.8b\t$Vt, [$Rn], #1"
8461 // may get mapped to
8462 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, XZR)
8463 def : InstAlias<asm # "." # layout # "\t$Vt$idx, [$Rn], #" # Offset,
8464 (!cast<Instruction>(NAME # Type # "_POST")
8466 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8467 idxtype:$idx, XZR), 0>;
8469 // E.g. "ld1.8b { v0 }[0], [x1]"
8470 // "ld1.8b\t$Vt, [$Rn]"
8471 // may get mapped to
8472 // (LD1Rv8b VecListOne64:$Vt, GPR64sp:$Rn)
8473 def : InstAlias<asm # "." # layout # "\t$Vt$idx, [$Rn]",
8474 (!cast<Instruction>(NAME # Type)
8475 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8476 idxtype:$idx, GPR64sp:$Rn), 0>;
8478 // E.g. "ld1.8b { v0 }[0], [x1], x2"
8479 // "ld1.8b\t$Vt, [$Rn], $Xm"
8480 // may get mapped to
8481 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, GPR64pi1:$Xm)
8482 def : InstAlias<asm # "." # layout # "\t$Vt$idx, [$Rn], $Xm",
8483 (!cast<Instruction>(NAME # Type # "_POST")
8485 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
8487 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
8490 multiclass SIMDLdSt1SingleAliases<string asm> {
8491 defm : SIMDLdStSingleAliases<asm, "b", "i8", "One", 1, VectorIndexB>;
8492 defm : SIMDLdStSingleAliases<asm, "h", "i16", "One", 2, VectorIndexH>;
8493 defm : SIMDLdStSingleAliases<asm, "s", "i32", "One", 4, VectorIndexS>;
8494 defm : SIMDLdStSingleAliases<asm, "d", "i64", "One", 8, VectorIndexD>;
8497 multiclass SIMDLdSt2SingleAliases<string asm> {
8498 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Two", 2, VectorIndexB>;
8499 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Two", 4, VectorIndexH>;
8500 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Two", 8, VectorIndexS>;
8501 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Two", 16, VectorIndexD>;
8504 multiclass SIMDLdSt3SingleAliases<string asm> {
8505 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Three", 3, VectorIndexB>;
8506 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Three", 6, VectorIndexH>;
8507 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Three", 12, VectorIndexS>;
8508 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Three", 24, VectorIndexD>;
8511 multiclass SIMDLdSt4SingleAliases<string asm> {
8512 defm : SIMDLdStSingleAliases<asm, "b", "i8", "Four", 4, VectorIndexB>;
8513 defm : SIMDLdStSingleAliases<asm, "h", "i16", "Four", 8, VectorIndexH>;
8514 defm : SIMDLdStSingleAliases<asm, "s", "i32", "Four", 16, VectorIndexS>;
8515 defm : SIMDLdStSingleAliases<asm, "d", "i64", "Four", 32, VectorIndexD>;
8517 } // end of 'let Predicates = [HasNEON]'
8519 //----------------------------------------------------------------------------
8520 // Crypto extensions
8521 //----------------------------------------------------------------------------
8523 let Predicates = [HasCrypto] in {
8524 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8525 class AESBase<bits<4> opc, string asm, dag outs, dag ins, string cstr,
8527 : I<outs, ins, asm, "{\t$Rd.16b, $Rn.16b|.16b\t$Rd, $Rn}", cstr, pat>,
8531 let Inst{31-16} = 0b0100111000101000;
8532 let Inst{15-12} = opc;
8533 let Inst{11-10} = 0b10;
8538 class AESInst<bits<4> opc, string asm, Intrinsic OpNode>
8539 : AESBase<opc, asm, (outs V128:$Rd), (ins V128:$Rn), "",
8540 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
8542 class AESTiedInst<bits<4> opc, string asm, Intrinsic OpNode>
8543 : AESBase<opc, asm, (outs V128:$dst), (ins V128:$Rd, V128:$Rn),
8545 [(set (v16i8 V128:$dst),
8546 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
8548 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8549 class SHA3OpTiedInst<bits<3> opc, string asm, string dst_lhs_kind,
8550 dag oops, dag iops, list<dag> pat>
8551 : I<oops, iops, asm,
8552 "{\t$Rd" # dst_lhs_kind # ", $Rn" # dst_lhs_kind # ", $Rm.4s" #
8553 "|.4s\t$Rd, $Rn, $Rm}", "$Rd = $dst", pat>,
8558 let Inst{31-21} = 0b01011110000;
8559 let Inst{20-16} = Rm;
8561 let Inst{14-12} = opc;
8562 let Inst{11-10} = 0b00;
8567 class SHATiedInstQSV<bits<3> opc, string asm, Intrinsic OpNode>
8568 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
8569 (ins FPR128:$Rd, FPR32:$Rn, V128:$Rm),
8570 [(set (v4i32 FPR128:$dst),
8571 (OpNode (v4i32 FPR128:$Rd), (i32 FPR32:$Rn),
8572 (v4i32 V128:$Rm)))]>;
8574 class SHATiedInstVVV<bits<3> opc, string asm, Intrinsic OpNode>
8575 : SHA3OpTiedInst<opc, asm, ".4s", (outs V128:$dst),
8576 (ins V128:$Rd, V128:$Rn, V128:$Rm),
8577 [(set (v4i32 V128:$dst),
8578 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
8579 (v4i32 V128:$Rm)))]>;
8581 class SHATiedInstQQV<bits<3> opc, string asm, Intrinsic OpNode>
8582 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
8583 (ins FPR128:$Rd, FPR128:$Rn, V128:$Rm),
8584 [(set (v4i32 FPR128:$dst),
8585 (OpNode (v4i32 FPR128:$Rd), (v4i32 FPR128:$Rn),
8586 (v4i32 V128:$Rm)))]>;
8588 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8589 class SHA2OpInst<bits<4> opc, string asm, string kind,
8590 string cstr, dag oops, dag iops,
8592 : I<oops, iops, asm, "{\t$Rd" # kind # ", $Rn" # kind #
8593 "|" # kind # "\t$Rd, $Rn}", cstr, pat>,
8597 let Inst{31-16} = 0b0101111000101000;
8598 let Inst{15-12} = opc;
8599 let Inst{11-10} = 0b10;
8604 class SHATiedInstVV<bits<4> opc, string asm, Intrinsic OpNode>
8605 : SHA2OpInst<opc, asm, ".4s", "$Rd = $dst", (outs V128:$dst),
8606 (ins V128:$Rd, V128:$Rn),
8607 [(set (v4i32 V128:$dst),
8608 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
8610 class SHAInstSS<bits<4> opc, string asm, Intrinsic OpNode>
8611 : SHA2OpInst<opc, asm, "", "", (outs FPR32:$Rd), (ins FPR32:$Rn),
8612 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
8613 } // end of 'let Predicates = [HasCrypto]'
8615 // Allow the size specifier tokens to be upper case, not just lower.
8616 def : TokenAlias<".8B", ".8b">;
8617 def : TokenAlias<".4H", ".4h">;
8618 def : TokenAlias<".2S", ".2s">;
8619 def : TokenAlias<".1D", ".1d">;
8620 def : TokenAlias<".16B", ".16b">;
8621 def : TokenAlias<".8H", ".8h">;
8622 def : TokenAlias<".4S", ".4s">;
8623 def : TokenAlias<".2D", ".2d">;
8624 def : TokenAlias<".1Q", ".1q">;
8625 def : TokenAlias<".B", ".b">;
8626 def : TokenAlias<".H", ".h">;
8627 def : TokenAlias<".S", ".s">;
8628 def : TokenAlias<".D", ".d">;
8629 def : TokenAlias<".Q", ".q">;