1 //===- AArch64InstrFormats.td - AArch64 Instruction Formats --*- tblgen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
10 // Describe AArch64 instructions format here
13 // Format specifies the encoding used by the instruction. This is part of the
14 // ad-hoc solution used to emit machine instruction encodings by our machine
16 class Format<bits<2> val> {
20 def PseudoFrm : Format<0>;
21 def NormalFrm : Format<1>; // Do we need any others?
23 // AArch64 Instruction Format
24 class AArch64Inst<Format f, string cstr> : Instruction {
25 field bits<32> Inst; // Instruction encoding.
26 // Mask of bits that cause an encoding to be UNPREDICTABLE.
27 // If a bit is set, then if the corresponding bit in the
28 // target encoding differs from its value in the "Inst" field,
29 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
30 field bits<32> Unpredictable = 0;
31 // SoftFail is the generic name for this field, but we alias it so
32 // as to make it more obvious what it means in ARM-land.
33 field bits<32> SoftFail = Unpredictable;
34 let Namespace = "AArch64";
36 bits<2> Form = F.Value;
38 let Constraints = cstr;
41 class InstSubst<string Asm, dag Result, bit EmitPriority = 0>
42 : InstAlias<Asm, Result, EmitPriority>, Requires<[UseNegativeImmediates]>;
44 // Pseudo instructions (don't have encoding information)
45 class Pseudo<dag oops, dag iops, list<dag> pattern, string cstr = "">
46 : AArch64Inst<PseudoFrm, cstr> {
47 dag OutOperandList = oops;
48 dag InOperandList = iops;
49 let Pattern = pattern;
50 let isCodeGenOnly = 1;
53 // Real instructions (have encoding information)
54 class EncodedI<string cstr, list<dag> pattern> : AArch64Inst<NormalFrm, cstr> {
55 let Pattern = pattern;
59 // Enum describing whether an instruction is
60 // destructive in its first source operand.
61 class DestructiveInstTypeEnum<bits<1> val> {
64 def NotDestructive : DestructiveInstTypeEnum<0>;
65 def Destructive : DestructiveInstTypeEnum<1>;
67 // Normal instructions
68 class I<dag oops, dag iops, string asm, string operands, string cstr,
70 : EncodedI<cstr, pattern> {
71 dag OutOperandList = oops;
72 dag InOperandList = iops;
73 let AsmString = !strconcat(asm, operands);
75 // Destructive operations (SVE)
76 DestructiveInstTypeEnum DestructiveInstType = NotDestructive;
77 ElementSizeEnum ElementSize = ElementSizeB;
79 let TSFlags{3} = DestructiveInstType.Value;
80 let TSFlags{2-0} = ElementSize.Value;
83 class TriOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$MHS, node:$RHS), res>;
84 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
85 class UnOpFrag<dag res> : PatFrag<(ops node:$LHS), res>;
87 // Helper fragment for an extract of the high portion of a 128-bit vector.
88 def extract_high_v16i8 :
89 UnOpFrag<(extract_subvector (v16i8 node:$LHS), (i64 8))>;
90 def extract_high_v8i16 :
91 UnOpFrag<(extract_subvector (v8i16 node:$LHS), (i64 4))>;
92 def extract_high_v4i32 :
93 UnOpFrag<(extract_subvector (v4i32 node:$LHS), (i64 2))>;
94 def extract_high_v2i64 :
95 UnOpFrag<(extract_subvector (v2i64 node:$LHS), (i64 1))>;
97 //===----------------------------------------------------------------------===//
98 // Asm Operand Classes.
101 // Shifter operand for arithmetic shifted encodings.
102 def ShifterOperand : AsmOperandClass {
103 let Name = "Shifter";
106 // Shifter operand for mov immediate encodings.
107 def MovImm32ShifterOperand : AsmOperandClass {
108 let SuperClasses = [ShifterOperand];
109 let Name = "MovImm32Shifter";
110 let RenderMethod = "addShifterOperands";
111 let DiagnosticType = "InvalidMovImm32Shift";
113 def MovImm64ShifterOperand : AsmOperandClass {
114 let SuperClasses = [ShifterOperand];
115 let Name = "MovImm64Shifter";
116 let RenderMethod = "addShifterOperands";
117 let DiagnosticType = "InvalidMovImm64Shift";
120 // Shifter operand for arithmetic register shifted encodings.
121 class ArithmeticShifterOperand<int width> : AsmOperandClass {
122 let SuperClasses = [ShifterOperand];
123 let Name = "ArithmeticShifter" # width;
124 let PredicateMethod = "isArithmeticShifter<" # width # ">";
125 let RenderMethod = "addShifterOperands";
126 let DiagnosticType = "AddSubRegShift" # width;
129 def ArithmeticShifterOperand32 : ArithmeticShifterOperand<32>;
130 def ArithmeticShifterOperand64 : ArithmeticShifterOperand<64>;
132 // Shifter operand for logical register shifted encodings.
133 class LogicalShifterOperand<int width> : AsmOperandClass {
134 let SuperClasses = [ShifterOperand];
135 let Name = "LogicalShifter" # width;
136 let PredicateMethod = "isLogicalShifter<" # width # ">";
137 let RenderMethod = "addShifterOperands";
138 let DiagnosticType = "AddSubRegShift" # width;
141 def LogicalShifterOperand32 : LogicalShifterOperand<32>;
142 def LogicalShifterOperand64 : LogicalShifterOperand<64>;
144 // Shifter operand for logical vector 128/64-bit shifted encodings.
145 def LogicalVecShifterOperand : AsmOperandClass {
146 let SuperClasses = [ShifterOperand];
147 let Name = "LogicalVecShifter";
148 let RenderMethod = "addShifterOperands";
150 def LogicalVecHalfWordShifterOperand : AsmOperandClass {
151 let SuperClasses = [LogicalVecShifterOperand];
152 let Name = "LogicalVecHalfWordShifter";
153 let RenderMethod = "addShifterOperands";
156 // The "MSL" shifter on the vector MOVI instruction.
157 def MoveVecShifterOperand : AsmOperandClass {
158 let SuperClasses = [ShifterOperand];
159 let Name = "MoveVecShifter";
160 let RenderMethod = "addShifterOperands";
163 // Extend operand for arithmetic encodings.
164 def ExtendOperand : AsmOperandClass {
166 let DiagnosticType = "AddSubRegExtendLarge";
168 def ExtendOperand64 : AsmOperandClass {
169 let SuperClasses = [ExtendOperand];
170 let Name = "Extend64";
171 let DiagnosticType = "AddSubRegExtendSmall";
173 // 'extend' that's a lsl of a 64-bit register.
174 def ExtendOperandLSL64 : AsmOperandClass {
175 let SuperClasses = [ExtendOperand];
176 let Name = "ExtendLSL64";
177 let RenderMethod = "addExtend64Operands";
178 let DiagnosticType = "AddSubRegExtendLarge";
181 // 8-bit floating-point immediate encodings.
182 def FPImmOperand : AsmOperandClass {
184 let ParserMethod = "tryParseFPImm<true>";
185 let DiagnosticType = "InvalidFPImm";
188 def CondCode : AsmOperandClass {
189 let Name = "CondCode";
190 let DiagnosticType = "InvalidCondCode";
193 // A 32-bit register pasrsed as 64-bit
194 def GPR32as64Operand : AsmOperandClass {
195 let Name = "GPR32as64";
197 "tryParseGPROperand<false, RegConstraintEqualityTy::EqualsSubReg>";
199 def GPR32as64 : RegisterOperand<GPR32> {
200 let ParserMatchClass = GPR32as64Operand;
203 // A 64-bit register pasrsed as 32-bit
204 def GPR64as32Operand : AsmOperandClass {
205 let Name = "GPR64as32";
207 "tryParseGPROperand<false, RegConstraintEqualityTy::EqualsSuperReg>";
209 def GPR64as32 : RegisterOperand<GPR64, "printGPR64as32"> {
210 let ParserMatchClass = GPR64as32Operand;
213 // 8-bit immediate for AdvSIMD where 64-bit values of the form:
214 // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
215 // are encoded as the eight bit value 'abcdefgh'.
216 def SIMDImmType10Operand : AsmOperandClass { let Name = "SIMDImmType10"; }
218 class UImmScaledMemoryIndexed<int Width, int Scale> : AsmOperandClass {
219 let Name = "UImm" # Width # "s" # Scale;
220 let DiagnosticType = "InvalidMemoryIndexed" # Scale # "UImm" # Width;
221 let RenderMethod = "addImmScaledOperands<" # Scale # ">";
222 let PredicateMethod = "isUImmScaled<" # Width # ", " # Scale # ">";
225 class SImmScaledMemoryIndexed<int Width, int Scale> : AsmOperandClass {
226 let Name = "SImm" # Width # "s" # Scale;
227 let DiagnosticType = "InvalidMemoryIndexed" # Scale # "SImm" # Width;
228 let RenderMethod = "addImmScaledOperands<" # Scale # ">";
229 let PredicateMethod = "isSImmScaled<" # Width # ", " # Scale # ">";
232 //===----------------------------------------------------------------------===//
233 // Operand Definitions.
236 // ADR[P] instruction labels.
237 def AdrpOperand : AsmOperandClass {
238 let Name = "AdrpLabel";
239 let ParserMethod = "tryParseAdrpLabel";
240 let DiagnosticType = "InvalidLabel";
242 def adrplabel : Operand<i64> {
243 let EncoderMethod = "getAdrLabelOpValue";
244 let PrintMethod = "printAdrpLabel";
245 let ParserMatchClass = AdrpOperand;
248 def AdrOperand : AsmOperandClass {
249 let Name = "AdrLabel";
250 let ParserMethod = "tryParseAdrLabel";
251 let DiagnosticType = "InvalidLabel";
253 def adrlabel : Operand<i64> {
254 let EncoderMethod = "getAdrLabelOpValue";
255 let ParserMatchClass = AdrOperand;
258 class SImmOperand<int width> : AsmOperandClass {
259 let Name = "SImm" # width;
260 let DiagnosticType = "InvalidMemoryIndexedSImm" # width;
261 let RenderMethod = "addImmOperands";
262 let PredicateMethod = "isSImm<" # width # ">";
266 class AsmImmRange<int Low, int High> : AsmOperandClass {
267 let Name = "Imm" # Low # "_" # High;
268 let DiagnosticType = "InvalidImm" # Low # "_" # High;
269 let RenderMethod = "addImmOperands";
270 let PredicateMethod = "isImmInRange<" # Low # "," # High # ">";
273 // Authenticated loads for v8.3 can have scaled 10-bit immediate offsets.
274 def SImm10s8Operand : SImmScaledMemoryIndexed<10, 8>;
275 def simm10Scaled : Operand<i64> {
276 let ParserMatchClass = SImm10s8Operand;
277 let DecoderMethod = "DecodeSImm<10>";
278 let PrintMethod = "printImmScale<8>";
281 def simm9s16 : Operand<i64> {
282 let ParserMatchClass = SImmScaledMemoryIndexed<9, 16>;
283 let DecoderMethod = "DecodeSImm<9>";
284 let PrintMethod = "printImmScale<16>";
287 // uimm6 predicate - True if the immediate is in the range [0, 63].
288 def UImm6Operand : AsmOperandClass {
290 let DiagnosticType = "InvalidImm0_63";
293 def uimm6 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= 0 && Imm < 64; }]> {
294 let ParserMatchClass = UImm6Operand;
297 def uimm16 : Operand<i16>, ImmLeaf<i16, [{return Imm >= 0 && Imm < 65536;}]>{
298 let ParserMatchClass = AsmImmRange<0, 65535>;
301 def SImm9Operand : SImmOperand<9>;
302 def simm9 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= -256 && Imm < 256; }]> {
303 let ParserMatchClass = SImm9Operand;
304 let DecoderMethod = "DecodeSImm<9>";
307 def SImm8Operand : SImmOperand<8>;
308 def simm8 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= -128 && Imm < 127; }]> {
309 let ParserMatchClass = SImm8Operand;
310 let DecoderMethod = "DecodeSImm<8>";
313 def SImm6Operand : SImmOperand<6>;
314 def simm6_32b : Operand<i32>, ImmLeaf<i32, [{ return Imm >= -32 && Imm < 32; }]> {
315 let ParserMatchClass = SImm6Operand;
316 let DecoderMethod = "DecodeSImm<6>";
319 def SImm5Operand : SImmOperand<5>;
320 def simm5_64b : Operand<i64>, ImmLeaf<i64, [{ return Imm >= -16 && Imm < 16; }]> {
321 let ParserMatchClass = SImm5Operand;
322 let DecoderMethod = "DecodeSImm<5>";
325 def simm5_32b : Operand<i32>, ImmLeaf<i32, [{ return Imm >= -16 && Imm < 16; }]> {
326 let ParserMatchClass = SImm5Operand;
327 let DecoderMethod = "DecodeSImm<5>";
330 // simm7sN predicate - True if the immediate is a multiple of N in the range
331 // [-64 * N, 63 * N].
333 def SImm7s4Operand : SImmScaledMemoryIndexed<7, 4>;
334 def SImm7s8Operand : SImmScaledMemoryIndexed<7, 8>;
335 def SImm7s16Operand : SImmScaledMemoryIndexed<7, 16>;
337 def simm7s4 : Operand<i32> {
338 let ParserMatchClass = SImm7s4Operand;
339 let PrintMethod = "printImmScale<4>";
342 def simm7s8 : Operand<i32> {
343 let ParserMatchClass = SImm7s8Operand;
344 let PrintMethod = "printImmScale<8>";
347 def simm7s16 : Operand<i32> {
348 let ParserMatchClass = SImm7s16Operand;
349 let PrintMethod = "printImmScale<16>";
352 def am_indexed7s8 : ComplexPattern<i64, 2, "SelectAddrModeIndexed7S8", []>;
353 def am_indexed7s16 : ComplexPattern<i64, 2, "SelectAddrModeIndexed7S16", []>;
354 def am_indexed7s32 : ComplexPattern<i64, 2, "SelectAddrModeIndexed7S32", []>;
355 def am_indexed7s64 : ComplexPattern<i64, 2, "SelectAddrModeIndexed7S64", []>;
356 def am_indexed7s128 : ComplexPattern<i64, 2, "SelectAddrModeIndexed7S128", []>;
358 def am_indexedu6s128 : ComplexPattern<i64, 2, "SelectAddrModeIndexedU6S128", []>;
359 def am_indexeds9s128 : ComplexPattern<i64, 2, "SelectAddrModeIndexedS9S128", []>;
361 // uimm5sN predicate - True if the immediate is a multiple of N in the range
363 def UImm5s2Operand : UImmScaledMemoryIndexed<5, 2>;
364 def UImm5s4Operand : UImmScaledMemoryIndexed<5, 4>;
365 def UImm5s8Operand : UImmScaledMemoryIndexed<5, 8>;
367 def uimm5s2 : Operand<i64>, ImmLeaf<i64,
368 [{ return Imm >= 0 && Imm < (32*2) && ((Imm % 2) == 0); }]> {
369 let ParserMatchClass = UImm5s2Operand;
370 let PrintMethod = "printImmScale<2>";
372 def uimm5s4 : Operand<i64>, ImmLeaf<i64,
373 [{ return Imm >= 0 && Imm < (32*4) && ((Imm % 4) == 0); }]> {
374 let ParserMatchClass = UImm5s4Operand;
375 let PrintMethod = "printImmScale<4>";
377 def uimm5s8 : Operand<i64>, ImmLeaf<i64,
378 [{ return Imm >= 0 && Imm < (32*8) && ((Imm % 8) == 0); }]> {
379 let ParserMatchClass = UImm5s8Operand;
380 let PrintMethod = "printImmScale<8>";
383 // uimm6sN predicate - True if the immediate is a multiple of N in the range
385 def UImm6s1Operand : UImmScaledMemoryIndexed<6, 1>;
386 def UImm6s2Operand : UImmScaledMemoryIndexed<6, 2>;
387 def UImm6s4Operand : UImmScaledMemoryIndexed<6, 4>;
388 def UImm6s8Operand : UImmScaledMemoryIndexed<6, 8>;
389 def UImm6s16Operand : UImmScaledMemoryIndexed<6, 16>;
391 def uimm6s1 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= 0 && Imm < 64; }]> {
392 let ParserMatchClass = UImm6s1Operand;
394 def uimm6s2 : Operand<i64>, ImmLeaf<i64,
395 [{ return Imm >= 0 && Imm < (64*2) && ((Imm % 2) == 0); }]> {
396 let PrintMethod = "printImmScale<2>";
397 let ParserMatchClass = UImm6s2Operand;
399 def uimm6s4 : Operand<i64>, ImmLeaf<i64,
400 [{ return Imm >= 0 && Imm < (64*4) && ((Imm % 4) == 0); }]> {
401 let PrintMethod = "printImmScale<4>";
402 let ParserMatchClass = UImm6s4Operand;
404 def uimm6s8 : Operand<i64>, ImmLeaf<i64,
405 [{ return Imm >= 0 && Imm < (64*8) && ((Imm % 8) == 0); }]> {
406 let PrintMethod = "printImmScale<8>";
407 let ParserMatchClass = UImm6s8Operand;
409 def uimm6s16 : Operand<i64>, ImmLeaf<i64,
410 [{ return Imm >= 0 && Imm < (64*16) && ((Imm % 16) == 0); }]> {
411 let PrintMethod = "printImmScale<16>";
412 let ParserMatchClass = UImm6s16Operand;
415 // simm6sN predicate - True if the immediate is a multiple of N in the range
416 // [-32 * N, 31 * N].
417 def SImm6s1Operand : SImmScaledMemoryIndexed<6, 1>;
418 def simm6s1 : Operand<i64>, ImmLeaf<i64, [{ return Imm >= -32 && Imm < 32; }]> {
419 let ParserMatchClass = SImm6s1Operand;
420 let DecoderMethod = "DecodeSImm<6>";
423 // simm4sN predicate - True if the immediate is a multiple of N in the range
425 def SImm4s1Operand : SImmScaledMemoryIndexed<4, 1>;
426 def SImm4s2Operand : SImmScaledMemoryIndexed<4, 2>;
427 def SImm4s3Operand : SImmScaledMemoryIndexed<4, 3>;
428 def SImm4s4Operand : SImmScaledMemoryIndexed<4, 4>;
429 def SImm4s16Operand : SImmScaledMemoryIndexed<4, 16>;
431 def simm4s1 : Operand<i64>, ImmLeaf<i64,
432 [{ return Imm >=-8 && Imm <= 7; }]> {
433 let ParserMatchClass = SImm4s1Operand;
434 let DecoderMethod = "DecodeSImm<4>";
437 def simm4s2 : Operand<i64>, ImmLeaf<i64,
438 [{ return Imm >=-16 && Imm <= 14 && (Imm % 2) == 0x0; }]> {
439 let PrintMethod = "printImmScale<2>";
440 let ParserMatchClass = SImm4s2Operand;
441 let DecoderMethod = "DecodeSImm<4>";
444 def simm4s3 : Operand<i64>, ImmLeaf<i64,
445 [{ return Imm >=-24 && Imm <= 21 && (Imm % 3) == 0x0; }]> {
446 let PrintMethod = "printImmScale<3>";
447 let ParserMatchClass = SImm4s3Operand;
448 let DecoderMethod = "DecodeSImm<4>";
451 def simm4s4 : Operand<i64>, ImmLeaf<i64,
452 [{ return Imm >=-32 && Imm <= 28 && (Imm % 4) == 0x0; }]> {
453 let PrintMethod = "printImmScale<4>";
454 let ParserMatchClass = SImm4s4Operand;
455 let DecoderMethod = "DecodeSImm<4>";
457 def simm4s16 : Operand<i64>, ImmLeaf<i64,
458 [{ return Imm >=-128 && Imm <= 112 && (Imm % 16) == 0x0; }]> {
459 let PrintMethod = "printImmScale<16>";
460 let ParserMatchClass = SImm4s16Operand;
461 let DecoderMethod = "DecodeSImm<4>";
464 def Imm1_8Operand : AsmImmRange<1, 8>;
465 def Imm1_16Operand : AsmImmRange<1, 16>;
466 def Imm1_32Operand : AsmImmRange<1, 32>;
467 def Imm1_64Operand : AsmImmRange<1, 64>;
469 class BranchTarget<int N> : AsmOperandClass {
470 let Name = "BranchTarget" # N;
471 let DiagnosticType = "InvalidLabel";
472 let PredicateMethod = "isBranchTarget<" # N # ">";
475 class PCRelLabel<int N> : BranchTarget<N> {
476 let Name = "PCRelLabel" # N;
479 def BranchTarget14Operand : BranchTarget<14>;
480 def BranchTarget26Operand : BranchTarget<26>;
481 def PCRelLabel19Operand : PCRelLabel<19>;
483 def MovWSymbolG3AsmOperand : AsmOperandClass {
484 let Name = "MovWSymbolG3";
485 let RenderMethod = "addImmOperands";
488 def movw_symbol_g3 : Operand<i32> {
489 let ParserMatchClass = MovWSymbolG3AsmOperand;
492 def MovWSymbolG2AsmOperand : AsmOperandClass {
493 let Name = "MovWSymbolG2";
494 let RenderMethod = "addImmOperands";
497 def movw_symbol_g2 : Operand<i32> {
498 let ParserMatchClass = MovWSymbolG2AsmOperand;
501 def MovWSymbolG1AsmOperand : AsmOperandClass {
502 let Name = "MovWSymbolG1";
503 let RenderMethod = "addImmOperands";
506 def movw_symbol_g1 : Operand<i32> {
507 let ParserMatchClass = MovWSymbolG1AsmOperand;
510 def MovWSymbolG0AsmOperand : AsmOperandClass {
511 let Name = "MovWSymbolG0";
512 let RenderMethod = "addImmOperands";
515 def movw_symbol_g0 : Operand<i32> {
516 let ParserMatchClass = MovWSymbolG0AsmOperand;
519 class fixedpoint_i32<ValueType FloatVT>
521 ComplexPattern<FloatVT, 1, "SelectCVTFixedPosOperand<32>", [fpimm, ld]> {
522 let EncoderMethod = "getFixedPointScaleOpValue";
523 let DecoderMethod = "DecodeFixedPointScaleImm32";
524 let ParserMatchClass = Imm1_32Operand;
527 class fixedpoint_i64<ValueType FloatVT>
529 ComplexPattern<FloatVT, 1, "SelectCVTFixedPosOperand<64>", [fpimm, ld]> {
530 let EncoderMethod = "getFixedPointScaleOpValue";
531 let DecoderMethod = "DecodeFixedPointScaleImm64";
532 let ParserMatchClass = Imm1_64Operand;
535 def fixedpoint_f16_i32 : fixedpoint_i32<f16>;
536 def fixedpoint_f32_i32 : fixedpoint_i32<f32>;
537 def fixedpoint_f64_i32 : fixedpoint_i32<f64>;
539 def fixedpoint_f16_i64 : fixedpoint_i64<f16>;
540 def fixedpoint_f32_i64 : fixedpoint_i64<f32>;
541 def fixedpoint_f64_i64 : fixedpoint_i64<f64>;
543 def vecshiftR8 : Operand<i32>, ImmLeaf<i32, [{
544 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 9);
546 let EncoderMethod = "getVecShiftR8OpValue";
547 let DecoderMethod = "DecodeVecShiftR8Imm";
548 let ParserMatchClass = Imm1_8Operand;
550 def vecshiftR16 : Operand<i32>, ImmLeaf<i32, [{
551 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
553 let EncoderMethod = "getVecShiftR16OpValue";
554 let DecoderMethod = "DecodeVecShiftR16Imm";
555 let ParserMatchClass = Imm1_16Operand;
557 def vecshiftR16Narrow : Operand<i32>, ImmLeaf<i32, [{
558 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 9);
560 let EncoderMethod = "getVecShiftR16OpValue";
561 let DecoderMethod = "DecodeVecShiftR16ImmNarrow";
562 let ParserMatchClass = Imm1_8Operand;
564 def vecshiftR32 : Operand<i32>, ImmLeaf<i32, [{
565 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 33);
567 let EncoderMethod = "getVecShiftR32OpValue";
568 let DecoderMethod = "DecodeVecShiftR32Imm";
569 let ParserMatchClass = Imm1_32Operand;
571 def vecshiftR32Narrow : Operand<i32>, ImmLeaf<i32, [{
572 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
574 let EncoderMethod = "getVecShiftR32OpValue";
575 let DecoderMethod = "DecodeVecShiftR32ImmNarrow";
576 let ParserMatchClass = Imm1_16Operand;
578 def vecshiftR64 : Operand<i32>, ImmLeaf<i32, [{
579 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 65);
581 let EncoderMethod = "getVecShiftR64OpValue";
582 let DecoderMethod = "DecodeVecShiftR64Imm";
583 let ParserMatchClass = Imm1_64Operand;
585 def vecshiftR64Narrow : Operand<i32>, ImmLeaf<i32, [{
586 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 33);
588 let EncoderMethod = "getVecShiftR64OpValue";
589 let DecoderMethod = "DecodeVecShiftR64ImmNarrow";
590 let ParserMatchClass = Imm1_32Operand;
593 def Imm0_1Operand : AsmImmRange<0, 1>;
594 def Imm0_7Operand : AsmImmRange<0, 7>;
595 def Imm0_15Operand : AsmImmRange<0, 15>;
596 def Imm0_31Operand : AsmImmRange<0, 31>;
597 def Imm0_63Operand : AsmImmRange<0, 63>;
599 def vecshiftL8 : Operand<i32>, ImmLeaf<i32, [{
600 return (((uint32_t)Imm) < 8);
602 let EncoderMethod = "getVecShiftL8OpValue";
603 let DecoderMethod = "DecodeVecShiftL8Imm";
604 let ParserMatchClass = Imm0_7Operand;
606 def vecshiftL16 : Operand<i32>, ImmLeaf<i32, [{
607 return (((uint32_t)Imm) < 16);
609 let EncoderMethod = "getVecShiftL16OpValue";
610 let DecoderMethod = "DecodeVecShiftL16Imm";
611 let ParserMatchClass = Imm0_15Operand;
613 def vecshiftL32 : Operand<i32>, ImmLeaf<i32, [{
614 return (((uint32_t)Imm) < 32);
616 let EncoderMethod = "getVecShiftL32OpValue";
617 let DecoderMethod = "DecodeVecShiftL32Imm";
618 let ParserMatchClass = Imm0_31Operand;
620 def vecshiftL64 : Operand<i32>, ImmLeaf<i32, [{
621 return (((uint32_t)Imm) < 64);
623 let EncoderMethod = "getVecShiftL64OpValue";
624 let DecoderMethod = "DecodeVecShiftL64Imm";
625 let ParserMatchClass = Imm0_63Operand;
629 // Crazy immediate formats used by 32-bit and 64-bit logical immediate
630 // instructions for splatting repeating bit patterns across the immediate.
631 def logical_imm32_XFORM : SDNodeXForm<imm, [{
632 uint64_t enc = AArch64_AM::encodeLogicalImmediate(N->getZExtValue(), 32);
633 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
635 def logical_imm64_XFORM : SDNodeXForm<imm, [{
636 uint64_t enc = AArch64_AM::encodeLogicalImmediate(N->getZExtValue(), 64);
637 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
640 def gi_logical_imm32_XFORM : GICustomOperandRenderer<"renderLogicalImm32">,
641 GISDNodeXFormEquiv<logical_imm32_XFORM>;
642 def gi_logical_imm64_XFORM : GICustomOperandRenderer<"renderLogicalImm64">,
643 GISDNodeXFormEquiv<logical_imm64_XFORM>;
645 let DiagnosticType = "LogicalSecondSource" in {
646 def LogicalImm32Operand : AsmOperandClass {
647 let Name = "LogicalImm32";
648 let PredicateMethod = "isLogicalImm<int32_t>";
649 let RenderMethod = "addLogicalImmOperands<int32_t>";
651 def LogicalImm64Operand : AsmOperandClass {
652 let Name = "LogicalImm64";
653 let PredicateMethod = "isLogicalImm<int64_t>";
654 let RenderMethod = "addLogicalImmOperands<int64_t>";
656 def LogicalImm32NotOperand : AsmOperandClass {
657 let Name = "LogicalImm32Not";
658 let PredicateMethod = "isLogicalImm<int32_t>";
659 let RenderMethod = "addLogicalImmNotOperands<int32_t>";
661 def LogicalImm64NotOperand : AsmOperandClass {
662 let Name = "LogicalImm64Not";
663 let PredicateMethod = "isLogicalImm<int64_t>";
664 let RenderMethod = "addLogicalImmNotOperands<int64_t>";
667 def logical_imm32 : Operand<i32>, IntImmLeaf<i32, [{
668 return AArch64_AM::isLogicalImmediate(Imm.getZExtValue(), 32);
669 }], logical_imm32_XFORM> {
670 let PrintMethod = "printLogicalImm<int32_t>";
671 let ParserMatchClass = LogicalImm32Operand;
673 def logical_imm64 : Operand<i64>, IntImmLeaf<i64, [{
674 return AArch64_AM::isLogicalImmediate(Imm.getZExtValue(), 64);
675 }], logical_imm64_XFORM> {
676 let PrintMethod = "printLogicalImm<int64_t>";
677 let ParserMatchClass = LogicalImm64Operand;
679 def logical_imm32_not : Operand<i32> {
680 let ParserMatchClass = LogicalImm32NotOperand;
682 def logical_imm64_not : Operand<i64> {
683 let ParserMatchClass = LogicalImm64NotOperand;
686 // iXX_imm0_65535 predicates - True if the immediate is in the range [0,65535].
687 let ParserMatchClass = AsmImmRange<0, 65535>, PrintMethod = "printImmHex" in {
688 def i32_imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
689 return ((uint32_t)Imm) < 65536;
692 def i64_imm0_65535 : Operand<i64>, ImmLeaf<i64, [{
693 return ((uint64_t)Imm) < 65536;
697 // imm0_255 predicate - True if the immediate is in the range [0,255].
698 def Imm0_255Operand : AsmImmRange<0,255>;
700 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{
701 return ((uint32_t)Imm) < 256;
703 let ParserMatchClass = Imm0_255Operand;
704 let PrintMethod = "printImm";
707 // imm0_127 predicate - True if the immediate is in the range [0,127]
708 def Imm0_127Operand : AsmImmRange<0, 127>;
709 def imm0_127 : Operand<i32>, ImmLeaf<i32, [{
710 return ((uint32_t)Imm) < 128;
712 let ParserMatchClass = Imm0_127Operand;
713 let PrintMethod = "printImm";
716 // NOTE: These imm0_N operands have to be of type i64 because i64 is the size
717 // for all shift-amounts.
719 // imm0_63 predicate - True if the immediate is in the range [0,63]
720 def imm0_63 : Operand<i64>, ImmLeaf<i64, [{
721 return ((uint64_t)Imm) < 64;
723 let ParserMatchClass = Imm0_63Operand;
726 // imm0_31 predicate - True if the immediate is in the range [0,31]
727 def imm0_31 : Operand<i64>, ImmLeaf<i64, [{
728 return ((uint64_t)Imm) < 32;
730 let ParserMatchClass = Imm0_31Operand;
733 // True if the 32-bit immediate is in the range [0,31]
734 def imm32_0_31 : Operand<i32>, ImmLeaf<i32, [{
735 return ((uint64_t)Imm) < 32;
737 let ParserMatchClass = Imm0_31Operand;
740 // imm0_1 predicate - True if the immediate is in the range [0,1]
741 def imm0_1 : Operand<i64>, ImmLeaf<i64, [{
742 return ((uint64_t)Imm) < 2;
744 let ParserMatchClass = Imm0_1Operand;
747 // imm0_15 predicate - True if the immediate is in the range [0,15]
748 def imm0_15 : Operand<i64>, ImmLeaf<i64, [{
749 return ((uint64_t)Imm) < 16;
751 let ParserMatchClass = Imm0_15Operand;
754 // imm0_7 predicate - True if the immediate is in the range [0,7]
755 def imm0_7 : Operand<i64>, ImmLeaf<i64, [{
756 return ((uint64_t)Imm) < 8;
758 let ParserMatchClass = Imm0_7Operand;
761 // imm32_0_15 predicate - True if the 32-bit immediate is in the range [0,15]
762 def imm32_0_15 : Operand<i32>, ImmLeaf<i32, [{
763 return ((uint32_t)Imm) < 16;
765 let ParserMatchClass = Imm0_15Operand;
768 // An arithmetic shifter operand:
769 // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr
771 class arith_shift<ValueType Ty, int width> : Operand<Ty> {
772 let PrintMethod = "printShifter";
773 let ParserMatchClass = !cast<AsmOperandClass>(
774 "ArithmeticShifterOperand" # width);
777 def arith_shift32 : arith_shift<i32, 32>;
778 def arith_shift64 : arith_shift<i64, 64>;
780 class arith_shifted_reg<ValueType Ty, RegisterClass regclass, int width>
782 ComplexPattern<Ty, 2, "SelectArithShiftedRegister", []> {
783 let PrintMethod = "printShiftedRegister";
784 let MIOperandInfo = (ops regclass, !cast<Operand>("arith_shift" # width));
787 def arith_shifted_reg32 : arith_shifted_reg<i32, GPR32, 32>;
788 def arith_shifted_reg64 : arith_shifted_reg<i64, GPR64, 64>;
790 def gi_arith_shifted_reg32 :
791 GIComplexOperandMatcher<s32, "selectArithShiftedRegister">,
792 GIComplexPatternEquiv<arith_shifted_reg32>;
794 def gi_arith_shifted_reg64 :
795 GIComplexOperandMatcher<s64, "selectArithShiftedRegister">,
796 GIComplexPatternEquiv<arith_shifted_reg64>;
798 // An arithmetic shifter operand:
799 // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr, 11 = ror
801 class logical_shift<int width> : Operand<i32> {
802 let PrintMethod = "printShifter";
803 let ParserMatchClass = !cast<AsmOperandClass>(
804 "LogicalShifterOperand" # width);
807 def logical_shift32 : logical_shift<32>;
808 def logical_shift64 : logical_shift<64>;
810 class logical_shifted_reg<ValueType Ty, RegisterClass regclass, Operand shiftop>
812 ComplexPattern<Ty, 2, "SelectLogicalShiftedRegister", []> {
813 let PrintMethod = "printShiftedRegister";
814 let MIOperandInfo = (ops regclass, shiftop);
817 def logical_shifted_reg32 : logical_shifted_reg<i32, GPR32, logical_shift32>;
818 def logical_shifted_reg64 : logical_shifted_reg<i64, GPR64, logical_shift64>;
820 def gi_logical_shifted_reg32 :
821 GIComplexOperandMatcher<s32, "selectLogicalShiftedRegister">,
822 GIComplexPatternEquiv<logical_shifted_reg32>;
824 def gi_logical_shifted_reg64 :
825 GIComplexOperandMatcher<s64, "selectLogicalShiftedRegister">,
826 GIComplexPatternEquiv<logical_shifted_reg64>;
828 // A logical vector shifter operand:
829 // {7-6} - shift type: 00 = lsl
830 // {5-0} - imm6: #0, #8, #16, or #24
831 def logical_vec_shift : Operand<i32> {
832 let PrintMethod = "printShifter";
833 let EncoderMethod = "getVecShifterOpValue";
834 let ParserMatchClass = LogicalVecShifterOperand;
837 // A logical vector half-word shifter operand:
838 // {7-6} - shift type: 00 = lsl
839 // {5-0} - imm6: #0 or #8
840 def logical_vec_hw_shift : Operand<i32> {
841 let PrintMethod = "printShifter";
842 let EncoderMethod = "getVecShifterOpValue";
843 let ParserMatchClass = LogicalVecHalfWordShifterOperand;
846 // A vector move shifter operand:
847 // {0} - imm1: #8 or #16
848 def move_vec_shift : Operand<i32> {
849 let PrintMethod = "printShifter";
850 let EncoderMethod = "getMoveVecShifterOpValue";
851 let ParserMatchClass = MoveVecShifterOperand;
854 let DiagnosticType = "AddSubSecondSource" in {
855 def AddSubImmOperand : AsmOperandClass {
856 let Name = "AddSubImm";
857 let ParserMethod = "tryParseImmWithOptionalShift";
858 let RenderMethod = "addImmWithOptionalShiftOperands<12>";
860 def AddSubImmNegOperand : AsmOperandClass {
861 let Name = "AddSubImmNeg";
862 let ParserMethod = "tryParseImmWithOptionalShift";
863 let RenderMethod = "addImmNegWithOptionalShiftOperands<12>";
866 // An ADD/SUB immediate shifter operand:
868 // {7-6} - shift type: 00 = lsl
869 // {5-0} - imm6: #0 or #12
870 class addsub_shifted_imm<ValueType Ty>
871 : Operand<Ty>, ComplexPattern<Ty, 2, "SelectArithImmed", [imm]> {
872 let PrintMethod = "printAddSubImm";
873 let EncoderMethod = "getAddSubImmOpValue";
874 let ParserMatchClass = AddSubImmOperand;
875 let MIOperandInfo = (ops i32imm, i32imm);
878 class addsub_shifted_imm_neg<ValueType Ty>
880 let EncoderMethod = "getAddSubImmOpValue";
881 let ParserMatchClass = AddSubImmNegOperand;
882 let MIOperandInfo = (ops i32imm, i32imm);
885 def addsub_shifted_imm32 : addsub_shifted_imm<i32>;
886 def addsub_shifted_imm64 : addsub_shifted_imm<i64>;
887 def addsub_shifted_imm32_neg : addsub_shifted_imm_neg<i32>;
888 def addsub_shifted_imm64_neg : addsub_shifted_imm_neg<i64>;
890 def gi_addsub_shifted_imm32 :
891 GIComplexOperandMatcher<s32, "selectArithImmed">,
892 GIComplexPatternEquiv<addsub_shifted_imm32>;
894 def gi_addsub_shifted_imm64 :
895 GIComplexOperandMatcher<s64, "selectArithImmed">,
896 GIComplexPatternEquiv<addsub_shifted_imm64>;
898 class neg_addsub_shifted_imm<ValueType Ty>
899 : Operand<Ty>, ComplexPattern<Ty, 2, "SelectNegArithImmed", [imm]> {
900 let PrintMethod = "printAddSubImm";
901 let EncoderMethod = "getAddSubImmOpValue";
902 let ParserMatchClass = AddSubImmOperand;
903 let MIOperandInfo = (ops i32imm, i32imm);
906 def neg_addsub_shifted_imm32 : neg_addsub_shifted_imm<i32>;
907 def neg_addsub_shifted_imm64 : neg_addsub_shifted_imm<i64>;
909 def gi_neg_addsub_shifted_imm32 :
910 GIComplexOperandMatcher<s32, "selectNegArithImmed">,
911 GIComplexPatternEquiv<neg_addsub_shifted_imm32>;
913 def gi_neg_addsub_shifted_imm64 :
914 GIComplexOperandMatcher<s64, "selectNegArithImmed">,
915 GIComplexPatternEquiv<neg_addsub_shifted_imm64>;
917 // An extend operand:
918 // {5-3} - extend type
920 def arith_extend : Operand<i32> {
921 let PrintMethod = "printArithExtend";
922 let ParserMatchClass = ExtendOperand;
924 def arith_extend64 : Operand<i32> {
925 let PrintMethod = "printArithExtend";
926 let ParserMatchClass = ExtendOperand64;
929 // 'extend' that's a lsl of a 64-bit register.
930 def arith_extendlsl64 : Operand<i32> {
931 let PrintMethod = "printArithExtend";
932 let ParserMatchClass = ExtendOperandLSL64;
935 class arith_extended_reg32<ValueType Ty> : Operand<Ty>,
936 ComplexPattern<Ty, 2, "SelectArithExtendedRegister", []> {
937 let PrintMethod = "printExtendedRegister";
938 let MIOperandInfo = (ops GPR32, arith_extend);
941 class arith_extended_reg32to64<ValueType Ty> : Operand<Ty>,
942 ComplexPattern<Ty, 2, "SelectArithExtendedRegister", []> {
943 let PrintMethod = "printExtendedRegister";
944 let MIOperandInfo = (ops GPR32, arith_extend64);
947 def arith_extended_reg32_i32 : arith_extended_reg32<i32>;
948 def gi_arith_extended_reg32_i32 :
949 GIComplexOperandMatcher<s32, "selectArithExtendedRegister">,
950 GIComplexPatternEquiv<arith_extended_reg32_i32>;
952 def arith_extended_reg32_i64 : arith_extended_reg32<i64>;
953 def gi_arith_extended_reg32_i64 :
954 GIComplexOperandMatcher<s64, "selectArithExtendedRegister">,
955 GIComplexPatternEquiv<arith_extended_reg32_i64>;
957 def arith_extended_reg32to64_i64 : arith_extended_reg32to64<i64>;
958 def gi_arith_extended_reg32to64_i64 :
959 GIComplexOperandMatcher<s64, "selectArithExtendedRegister">,
960 GIComplexPatternEquiv<arith_extended_reg32to64_i64>;
962 // Floating-point immediate.
963 def fpimm16 : Operand<f16>,
965 return AArch64_AM::getFP16Imm(Imm) != -1;
966 }], SDNodeXForm<fpimm, [{
967 APFloat InVal = N->getValueAPF();
968 uint32_t enc = AArch64_AM::getFP16Imm(InVal);
969 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
971 let ParserMatchClass = FPImmOperand;
972 let PrintMethod = "printFPImmOperand";
974 def fpimm32 : Operand<f32>,
976 return AArch64_AM::getFP32Imm(Imm) != -1;
977 }], SDNodeXForm<fpimm, [{
978 APFloat InVal = N->getValueAPF();
979 uint32_t enc = AArch64_AM::getFP32Imm(InVal);
980 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
982 let ParserMatchClass = FPImmOperand;
983 let PrintMethod = "printFPImmOperand";
985 def fpimm64 : Operand<f64>,
987 return AArch64_AM::getFP64Imm(Imm) != -1;
988 }], SDNodeXForm<fpimm, [{
989 APFloat InVal = N->getValueAPF();
990 uint32_t enc = AArch64_AM::getFP64Imm(InVal);
991 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
993 let ParserMatchClass = FPImmOperand;
994 let PrintMethod = "printFPImmOperand";
997 def fpimm8 : Operand<i32> {
998 let ParserMatchClass = FPImmOperand;
999 let PrintMethod = "printFPImmOperand";
1002 def fpimm0 : FPImmLeaf<fAny, [{
1003 return Imm.isExactlyValue(+0.0);
1006 // Vector lane operands
1007 class AsmVectorIndex<int Min, int Max, string NamePrefix=""> : AsmOperandClass {
1008 let Name = NamePrefix # "IndexRange" # Min # "_" # Max;
1009 let DiagnosticType = "Invalid" # Name;
1010 let PredicateMethod = "isVectorIndex<" # Min # ", " # Max # ">";
1011 let RenderMethod = "addVectorIndexOperands";
1014 class AsmVectorIndexOpnd<AsmOperandClass mc, code pred>
1015 : Operand<i64>, ImmLeaf<i64, pred> {
1016 let ParserMatchClass = mc;
1017 let PrintMethod = "printVectorIndex";
1020 def VectorIndex1Operand : AsmVectorIndex<1, 1>;
1021 def VectorIndexBOperand : AsmVectorIndex<0, 15>;
1022 def VectorIndexHOperand : AsmVectorIndex<0, 7>;
1023 def VectorIndexSOperand : AsmVectorIndex<0, 3>;
1024 def VectorIndexDOperand : AsmVectorIndex<0, 1>;
1026 def VectorIndex1 : AsmVectorIndexOpnd<VectorIndex1Operand, [{ return ((uint64_t)Imm) == 1; }]>;
1027 def VectorIndexB : AsmVectorIndexOpnd<VectorIndexBOperand, [{ return ((uint64_t)Imm) < 16; }]>;
1028 def VectorIndexH : AsmVectorIndexOpnd<VectorIndexHOperand, [{ return ((uint64_t)Imm) < 8; }]>;
1029 def VectorIndexS : AsmVectorIndexOpnd<VectorIndexSOperand, [{ return ((uint64_t)Imm) < 4; }]>;
1030 def VectorIndexD : AsmVectorIndexOpnd<VectorIndexDOperand, [{ return ((uint64_t)Imm) < 2; }]>;
1032 def SVEVectorIndexExtDupBOperand : AsmVectorIndex<0, 63, "SVE">;
1033 def SVEVectorIndexExtDupHOperand : AsmVectorIndex<0, 31, "SVE">;
1034 def SVEVectorIndexExtDupSOperand : AsmVectorIndex<0, 15, "SVE">;
1035 def SVEVectorIndexExtDupDOperand : AsmVectorIndex<0, 7, "SVE">;
1036 def SVEVectorIndexExtDupQOperand : AsmVectorIndex<0, 3, "SVE">;
1038 def sve_elm_idx_extdup_b
1039 : AsmVectorIndexOpnd<SVEVectorIndexExtDupBOperand, [{ return ((uint64_t)Imm) < 64; }]>;
1040 def sve_elm_idx_extdup_h
1041 : AsmVectorIndexOpnd<SVEVectorIndexExtDupHOperand, [{ return ((uint64_t)Imm) < 32; }]>;
1042 def sve_elm_idx_extdup_s
1043 : AsmVectorIndexOpnd<SVEVectorIndexExtDupSOperand, [{ return ((uint64_t)Imm) < 16; }]>;
1044 def sve_elm_idx_extdup_d
1045 : AsmVectorIndexOpnd<SVEVectorIndexExtDupDOperand, [{ return ((uint64_t)Imm) < 8; }]>;
1046 def sve_elm_idx_extdup_q
1047 : AsmVectorIndexOpnd<SVEVectorIndexExtDupQOperand, [{ return ((uint64_t)Imm) < 4; }]>;
1049 // 8-bit immediate for AdvSIMD where 64-bit values of the form:
1050 // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
1051 // are encoded as the eight bit value 'abcdefgh'.
1052 def simdimmtype10 : Operand<i32>,
1054 return AArch64_AM::isAdvSIMDModImmType10(
1055 Imm.bitcastToAPInt().getZExtValue());
1056 }], SDNodeXForm<fpimm, [{
1057 APFloat InVal = N->getValueAPF();
1058 uint32_t enc = AArch64_AM::encodeAdvSIMDModImmType10(N->getValueAPF()
1061 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
1063 let ParserMatchClass = SIMDImmType10Operand;
1064 let PrintMethod = "printSIMDType10Operand";
1069 // System management
1072 // Base encoding for system instruction operands.
1073 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
1074 class BaseSystemI<bit L, dag oops, dag iops, string asm, string operands,
1075 list<dag> pattern = []>
1076 : I<oops, iops, asm, operands, "", pattern> {
1077 let Inst{31-22} = 0b1101010100;
1081 // System instructions which do not have an Rt register.
1082 class SimpleSystemI<bit L, dag iops, string asm, string operands,
1083 list<dag> pattern = []>
1084 : BaseSystemI<L, (outs), iops, asm, operands, pattern> {
1085 let Inst{4-0} = 0b11111;
1088 // System instructions which have an Rt register.
1089 class RtSystemI<bit L, dag oops, dag iops, string asm, string operands>
1090 : BaseSystemI<L, oops, iops, asm, operands>,
1096 // System instructions for transactional memory extension
1097 class TMBaseSystemI<bit L, bits<4> CRm, bits<3> op2, dag oops, dag iops,
1098 string asm, string operands, list<dag> pattern>
1099 : BaseSystemI<L, oops, iops, asm, operands, pattern>,
1101 let Inst{20-12} = 0b000110011;
1102 let Inst{11-8} = CRm;
1103 let Inst{7-5} = op2;
1104 let DecoderMethod = "";
1110 // System instructions for transactional memory - single input operand
1111 class TMSystemI<bits<4> CRm, string asm, list<dag> pattern>
1112 : TMBaseSystemI<0b1, CRm, 0b011,
1113 (outs GPR64:$Rt), (ins), asm, "\t$Rt", pattern> {
1118 // System instructions for transactional memory - no operand
1119 class TMSystemINoOperand<bits<4> CRm, string asm, list<dag> pattern>
1120 : TMBaseSystemI<0b0, CRm, 0b011, (outs), (ins), asm, "", pattern> {
1121 let Inst{4-0} = 0b11111;
1124 // System instructions for exit from transactions
1125 class TMSystemException<bits<3> op1, string asm, list<dag> pattern>
1126 : I<(outs), (ins i64_imm0_65535:$imm), asm, "\t$imm", "", pattern>,
1129 let Inst{31-24} = 0b11010100;
1130 let Inst{23-21} = op1;
1131 let Inst{20-5} = imm;
1132 let Inst{4-0} = 0b00000;
1135 // Hint instructions that take both a CRm and a 3-bit immediate.
1136 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
1137 // model patterns with sufficiently fine granularity
1138 let mayStore = 1, mayLoad = 1, hasSideEffects = 1 in
1139 class HintI<string mnemonic>
1140 : SimpleSystemI<0, (ins imm0_127:$imm), mnemonic#"\t$imm", "",
1141 [(int_aarch64_hint imm0_127:$imm)]>,
1142 Sched<[WriteHint]> {
1144 let Inst{20-12} = 0b000110010;
1145 let Inst{11-5} = imm;
1148 // System instructions taking a single literal operand which encodes into
1149 // CRm. op2 differentiates the opcodes.
1150 def BarrierAsmOperand : AsmOperandClass {
1151 let Name = "Barrier";
1152 let ParserMethod = "tryParseBarrierOperand";
1154 def barrier_op : Operand<i32> {
1155 let PrintMethod = "printBarrierOption";
1156 let ParserMatchClass = BarrierAsmOperand;
1158 class CRmSystemI<Operand crmtype, bits<3> opc, string asm,
1159 list<dag> pattern = []>
1160 : SimpleSystemI<0, (ins crmtype:$CRm), asm, "\t$CRm", pattern>,
1161 Sched<[WriteBarrier]> {
1163 let Inst{20-12} = 0b000110011;
1164 let Inst{11-8} = CRm;
1165 let Inst{7-5} = opc;
1168 class SystemNoOperands<bits<3> op2, string asm, list<dag> pattern = []>
1169 : SimpleSystemI<0, (ins), asm, "", pattern>,
1173 let Inst{31-12} = 0b11010101000000110010;
1174 let Inst{11-8} = CRm;
1175 let Inst{7-5} = op2;
1176 let Inst{4-0} = 0b11111;
1179 // MRS/MSR system instructions. These have different operand classes because
1180 // a different subset of registers can be accessed through each instruction.
1181 def MRSSystemRegisterOperand : AsmOperandClass {
1182 let Name = "MRSSystemRegister";
1183 let ParserMethod = "tryParseSysReg";
1184 let DiagnosticType = "MRS";
1186 // concatenation of op0, op1, CRn, CRm, op2. 16-bit immediate.
1187 def mrs_sysreg_op : Operand<i32> {
1188 let ParserMatchClass = MRSSystemRegisterOperand;
1189 let DecoderMethod = "DecodeMRSSystemRegister";
1190 let PrintMethod = "printMRSSystemRegister";
1193 def MSRSystemRegisterOperand : AsmOperandClass {
1194 let Name = "MSRSystemRegister";
1195 let ParserMethod = "tryParseSysReg";
1196 let DiagnosticType = "MSR";
1198 def msr_sysreg_op : Operand<i32> {
1199 let ParserMatchClass = MSRSystemRegisterOperand;
1200 let DecoderMethod = "DecodeMSRSystemRegister";
1201 let PrintMethod = "printMSRSystemRegister";
1204 def PSBHintOperand : AsmOperandClass {
1205 let Name = "PSBHint";
1206 let ParserMethod = "tryParsePSBHint";
1208 def psbhint_op : Operand<i32> {
1209 let ParserMatchClass = PSBHintOperand;
1210 let PrintMethod = "printPSBHintOp";
1211 let MCOperandPredicate = [{
1212 // Check, if operand is valid, to fix exhaustive aliasing in disassembly.
1213 // "psb" is an alias to "hint" only for certain values of CRm:Op2 fields.
1216 return AArch64PSBHint::lookupPSBByEncoding(MCOp.getImm()) != nullptr;
1220 def BTIHintOperand : AsmOperandClass {
1221 let Name = "BTIHint";
1222 let ParserMethod = "tryParseBTIHint";
1224 def btihint_op : Operand<i32> {
1225 let ParserMatchClass = BTIHintOperand;
1226 let PrintMethod = "printBTIHintOp";
1227 let MCOperandPredicate = [{
1228 // "bti" is an alias to "hint" only for certain values of CRm:Op2 fields.
1231 return AArch64BTIHint::lookupBTIByEncoding((MCOp.getImm() ^ 32) >> 1) != nullptr;
1235 class MRSI : RtSystemI<1, (outs GPR64:$Rt), (ins mrs_sysreg_op:$systemreg),
1236 "mrs", "\t$Rt, $systemreg"> {
1238 let Inst{20-5} = systemreg;
1241 // FIXME: Some of these def NZCV, others don't. Best way to model that?
1242 // Explicitly modeling each of the system register as a register class
1243 // would do it, but feels like overkill at this point.
1244 class MSRI : RtSystemI<0, (outs), (ins msr_sysreg_op:$systemreg, GPR64:$Rt),
1245 "msr", "\t$systemreg, $Rt"> {
1247 let Inst{20-5} = systemreg;
1250 def SystemPStateFieldWithImm0_15Operand : AsmOperandClass {
1251 let Name = "SystemPStateFieldWithImm0_15";
1252 let ParserMethod = "tryParseSysReg";
1254 def pstatefield4_op : Operand<i32> {
1255 let ParserMatchClass = SystemPStateFieldWithImm0_15Operand;
1256 let PrintMethod = "printSystemPStateField";
1259 // Instructions to modify PSTATE, no input reg
1260 let Defs = [NZCV] in
1261 class PstateWriteSimple<dag iops, string asm, string operands>
1262 : SimpleSystemI<0, iops, asm, operands> {
1264 let Inst{20-19} = 0b00;
1265 let Inst{15-12} = 0b0100;
1268 class MSRpstateImm0_15
1269 : PstateWriteSimple<(ins pstatefield4_op:$pstatefield, imm0_15:$imm), "msr",
1270 "\t$pstatefield, $imm">,
1273 bits<6> pstatefield;
1275 let Inst{18-16} = pstatefield{5-3};
1276 let Inst{11-8} = imm;
1277 let Inst{7-5} = pstatefield{2-0};
1279 let DecoderMethod = "DecodeSystemPStateInstruction";
1280 // MSRpstateI aliases with MSRI. When the MSRpstateI decoder method returns
1281 // Fail the decoder should attempt to decode the instruction as MSRI.
1282 let hasCompleteDecoder = 0;
1285 def SystemPStateFieldWithImm0_1Operand : AsmOperandClass {
1286 let Name = "SystemPStateFieldWithImm0_1";
1287 let ParserMethod = "tryParseSysReg";
1289 def pstatefield1_op : Operand<i32> {
1290 let ParserMatchClass = SystemPStateFieldWithImm0_1Operand;
1291 let PrintMethod = "printSystemPStateField";
1294 class MSRpstateImm0_1
1295 : PstateWriteSimple<(ins pstatefield1_op:$pstatefield, imm0_1:$imm), "msr",
1296 "\t$pstatefield, $imm">,
1299 bits<6> pstatefield;
1301 let Inst{18-16} = pstatefield{5-3};
1302 let Inst{11-9} = 0b000;
1304 let Inst{7-5} = pstatefield{2-0};
1306 let DecoderMethod = "DecodeSystemPStateInstruction";
1307 // MSRpstateI aliases with MSRI. When the MSRpstateI decoder method returns
1308 // Fail the decoder should attempt to decode the instruction as MSRI.
1309 let hasCompleteDecoder = 0;
1312 // SYS and SYSL generic system instructions.
1313 def SysCRAsmOperand : AsmOperandClass {
1315 let ParserMethod = "tryParseSysCROperand";
1318 def sys_cr_op : Operand<i32> {
1319 let PrintMethod = "printSysCROperand";
1320 let ParserMatchClass = SysCRAsmOperand;
1323 class SystemXtI<bit L, string asm>
1324 : RtSystemI<L, (outs),
1325 (ins imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2, GPR64:$Rt),
1326 asm, "\t$op1, $Cn, $Cm, $op2, $Rt"> {
1331 let Inst{20-19} = 0b01;
1332 let Inst{18-16} = op1;
1333 let Inst{15-12} = Cn;
1334 let Inst{11-8} = Cm;
1335 let Inst{7-5} = op2;
1338 class SystemLXtI<bit L, string asm>
1339 : RtSystemI<L, (outs),
1340 (ins GPR64:$Rt, imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2),
1341 asm, "\t$Rt, $op1, $Cn, $Cm, $op2"> {
1346 let Inst{20-19} = 0b01;
1347 let Inst{18-16} = op1;
1348 let Inst{15-12} = Cn;
1349 let Inst{11-8} = Cm;
1350 let Inst{7-5} = op2;
1354 // Branch (register) instructions:
1362 // otherwise UNDEFINED
1363 class BaseBranchReg<bits<4> opc, dag oops, dag iops, string asm,
1364 string operands, list<dag> pattern>
1365 : I<oops, iops, asm, operands, "", pattern>, Sched<[WriteBrReg]> {
1366 let Inst{31-25} = 0b1101011;
1367 let Inst{24-21} = opc;
1368 let Inst{20-16} = 0b11111;
1369 let Inst{15-10} = 0b000000;
1370 let Inst{4-0} = 0b00000;
1373 class BranchReg<bits<4> opc, string asm, list<dag> pattern>
1374 : BaseBranchReg<opc, (outs), (ins GPR64:$Rn), asm, "\t$Rn", pattern> {
1379 let mayLoad = 0, mayStore = 0, hasSideEffects = 1, isReturn = 1 in
1380 class SpecialReturn<bits<4> opc, string asm>
1381 : BaseBranchReg<opc, (outs), (ins), asm, "", []> {
1382 let Inst{9-5} = 0b11111;
1386 class RCPCLoad<bits<2> sz, string asm, RegisterClass RC>
1387 : I<(outs RC:$Rt), (ins GPR64sp0:$Rn), asm, "\t$Rt, [$Rn]", "", []>,
1391 let Inst{31-30} = sz;
1392 let Inst{29-10} = 0b11100010111111110000;
1397 class AuthBase<bits<1> M, dag oops, dag iops, string asm, string operands,
1399 : I<oops, iops, asm, operands, "", pattern>, Sched<[]> {
1400 let Inst{31-25} = 0b1101011;
1401 let Inst{20-11} = 0b1111100001;
1403 let Inst{4-0} = 0b11111;
1406 class AuthBranchTwoOperands<bits<1> op, bits<1> M, string asm>
1407 : AuthBase<M, (outs), (ins GPR64:$Rn, GPR64sp:$Rm), asm, "\t$Rn, $Rm", []> {
1410 let Inst{24-22} = 0b100;
1416 class AuthOneOperand<bits<3> opc, bits<1> M, string asm>
1417 : AuthBase<M, (outs), (ins GPR64:$Rn), asm, "\t$Rn", []> {
1420 let Inst{23-21} = opc;
1424 class AuthReturn<bits<3> op, bits<1> M, string asm>
1425 : AuthBase<M, (outs), (ins), asm, "", []> {
1427 let Inst{23-21} = op;
1428 let Inst{9-0} = 0b1111111111;
1432 class BaseAuthLoad<bit M, bit W, dag oops, dag iops, string asm,
1433 string operands, string cstr, Operand opr>
1434 : I<oops, iops, asm, operands, cstr, []>, Sched<[]> {
1438 let Inst{31-24} = 0b11111000;
1440 let Inst{22} = offset{9};
1442 let Inst{20-12} = offset{8-0};
1449 multiclass AuthLoad<bit M, string asm, Operand opr> {
1450 def indexed : BaseAuthLoad<M, 0, (outs GPR64:$Rt),
1451 (ins GPR64sp:$Rn, opr:$offset),
1452 asm, "\t$Rt, [$Rn, $offset]", "", opr>;
1453 def writeback : BaseAuthLoad<M, 1, (outs GPR64sp:$wback, GPR64:$Rt),
1454 (ins GPR64sp:$Rn, opr:$offset),
1455 asm, "\t$Rt, [$Rn, $offset]!",
1456 "$Rn = $wback,@earlyclobber $wback", opr>;
1458 def : InstAlias<asm # "\t$Rt, [$Rn]",
1459 (!cast<Instruction>(NAME # "indexed") GPR64:$Rt, GPR64sp:$Rn, 0)>;
1463 // Conditional branch instruction.
1467 // 4-bit immediate. Pretty-printed as <cc>
1468 def ccode : Operand<i32> {
1469 let PrintMethod = "printCondCode";
1470 let ParserMatchClass = CondCode;
1472 def inv_ccode : Operand<i32> {
1473 // AL and NV are invalid in the aliases which use inv_ccode
1474 let PrintMethod = "printInverseCondCode";
1475 let ParserMatchClass = CondCode;
1476 let MCOperandPredicate = [{
1477 return MCOp.isImm() &&
1478 MCOp.getImm() != AArch64CC::AL &&
1479 MCOp.getImm() != AArch64CC::NV;
1483 // Conditional branch target. 19-bit immediate. The low two bits of the target
1484 // offset are implied zero and so are not part of the immediate.
1485 def am_brcond : Operand<OtherVT> {
1486 let EncoderMethod = "getCondBranchTargetOpValue";
1487 let DecoderMethod = "DecodePCRelLabel19";
1488 let PrintMethod = "printAlignedLabel";
1489 let ParserMatchClass = PCRelLabel19Operand;
1490 let OperandType = "OPERAND_PCREL";
1493 class BranchCond : I<(outs), (ins ccode:$cond, am_brcond:$target),
1494 "b", ".$cond\t$target", "",
1495 [(AArch64brcond bb:$target, imm:$cond, NZCV)]>,
1498 let isTerminator = 1;
1503 let Inst{31-24} = 0b01010100;
1504 let Inst{23-5} = target;
1506 let Inst{3-0} = cond;
1510 // Compare-and-branch instructions.
1512 class BaseCmpBranch<RegisterClass regtype, bit op, string asm, SDNode node>
1513 : I<(outs), (ins regtype:$Rt, am_brcond:$target),
1514 asm, "\t$Rt, $target", "",
1515 [(node regtype:$Rt, bb:$target)]>,
1518 let isTerminator = 1;
1522 let Inst{30-25} = 0b011010;
1524 let Inst{23-5} = target;
1528 multiclass CmpBranch<bit op, string asm, SDNode node> {
1529 def W : BaseCmpBranch<GPR32, op, asm, node> {
1532 def X : BaseCmpBranch<GPR64, op, asm, node> {
1538 // Test-bit-and-branch instructions.
1540 // Test-and-branch target. 14-bit sign-extended immediate. The low two bits of
1541 // the target offset are implied zero and so are not part of the immediate.
1542 def am_tbrcond : Operand<OtherVT> {
1543 let EncoderMethod = "getTestBranchTargetOpValue";
1544 let PrintMethod = "printAlignedLabel";
1545 let ParserMatchClass = BranchTarget14Operand;
1546 let OperandType = "OPERAND_PCREL";
1549 // AsmOperand classes to emit (or not) special diagnostics
1550 def TBZImm0_31Operand : AsmOperandClass {
1551 let Name = "TBZImm0_31";
1552 let PredicateMethod = "isImmInRange<0,31>";
1553 let RenderMethod = "addImmOperands";
1555 def TBZImm32_63Operand : AsmOperandClass {
1556 let Name = "Imm32_63";
1557 let PredicateMethod = "isImmInRange<32,63>";
1558 let DiagnosticType = "InvalidImm0_63";
1559 let RenderMethod = "addImmOperands";
1562 class tbz_imm0_31<AsmOperandClass matcher> : Operand<i64>, ImmLeaf<i64, [{
1563 return (((uint32_t)Imm) < 32);
1565 let ParserMatchClass = matcher;
1568 def tbz_imm0_31_diag : tbz_imm0_31<Imm0_31Operand>;
1569 def tbz_imm0_31_nodiag : tbz_imm0_31<TBZImm0_31Operand>;
1571 def tbz_imm32_63 : Operand<i64>, ImmLeaf<i64, [{
1572 return (((uint32_t)Imm) > 31) && (((uint32_t)Imm) < 64);
1574 let ParserMatchClass = TBZImm32_63Operand;
1577 class BaseTestBranch<RegisterClass regtype, Operand immtype,
1578 bit op, string asm, SDNode node>
1579 : I<(outs), (ins regtype:$Rt, immtype:$bit_off, am_tbrcond:$target),
1580 asm, "\t$Rt, $bit_off, $target", "",
1581 [(node regtype:$Rt, immtype:$bit_off, bb:$target)]>,
1584 let isTerminator = 1;
1590 let Inst{30-25} = 0b011011;
1592 let Inst{23-19} = bit_off{4-0};
1593 let Inst{18-5} = target;
1596 let DecoderMethod = "DecodeTestAndBranch";
1599 multiclass TestBranch<bit op, string asm, SDNode node> {
1600 def W : BaseTestBranch<GPR32, tbz_imm0_31_diag, op, asm, node> {
1604 def X : BaseTestBranch<GPR64, tbz_imm32_63, op, asm, node> {
1608 // Alias X-reg with 0-31 imm to W-Reg.
1609 def : InstAlias<asm # "\t$Rd, $imm, $target",
1610 (!cast<Instruction>(NAME#"W") GPR32as64:$Rd,
1611 tbz_imm0_31_nodiag:$imm, am_tbrcond:$target), 0>;
1612 def : Pat<(node GPR64:$Rn, tbz_imm0_31_diag:$imm, bb:$target),
1613 (!cast<Instruction>(NAME#"W") (EXTRACT_SUBREG GPR64:$Rn, sub_32),
1614 tbz_imm0_31_diag:$imm, bb:$target)>;
1618 // Unconditional branch (immediate) instructions.
1620 def am_b_target : Operand<OtherVT> {
1621 let EncoderMethod = "getBranchTargetOpValue";
1622 let PrintMethod = "printAlignedLabel";
1623 let ParserMatchClass = BranchTarget26Operand;
1624 let OperandType = "OPERAND_PCREL";
1626 def am_bl_target : Operand<i64> {
1627 let EncoderMethod = "getBranchTargetOpValue";
1628 let PrintMethod = "printAlignedLabel";
1629 let ParserMatchClass = BranchTarget26Operand;
1630 let OperandType = "OPERAND_PCREL";
1633 class BImm<bit op, dag iops, string asm, list<dag> pattern>
1634 : I<(outs), iops, asm, "\t$addr", "", pattern>, Sched<[WriteBr]> {
1637 let Inst{30-26} = 0b00101;
1638 let Inst{25-0} = addr;
1640 let DecoderMethod = "DecodeUnconditionalBranch";
1643 class BranchImm<bit op, string asm, list<dag> pattern>
1644 : BImm<op, (ins am_b_target:$addr), asm, pattern>;
1645 class CallImm<bit op, string asm, list<dag> pattern>
1646 : BImm<op, (ins am_bl_target:$addr), asm, pattern>;
1649 // Basic one-operand data processing instructions.
1652 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1653 class BaseOneOperandData<bits<3> opc, RegisterClass regtype, string asm,
1654 SDPatternOperator node>
1655 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
1656 [(set regtype:$Rd, (node regtype:$Rn))]>,
1657 Sched<[WriteI, ReadI]> {
1661 let Inst{30-13} = 0b101101011000000000;
1662 let Inst{12-10} = opc;
1667 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
1668 multiclass OneOperandData<bits<3> opc, string asm,
1669 SDPatternOperator node = null_frag> {
1670 def Wr : BaseOneOperandData<opc, GPR32, asm, node> {
1674 def Xr : BaseOneOperandData<opc, GPR64, asm, node> {
1679 class OneWRegData<bits<3> opc, string asm, SDPatternOperator node>
1680 : BaseOneOperandData<opc, GPR32, asm, node> {
1684 class OneXRegData<bits<3> opc, string asm, SDPatternOperator node>
1685 : BaseOneOperandData<opc, GPR64, asm, node> {
1689 class SignAuthOneData<bits<3> opcode_prefix, bits<2> opcode, string asm>
1690 : I<(outs GPR64:$Rd), (ins GPR64sp:$Rn), asm, "\t$Rd, $Rn", "",
1692 Sched<[WriteI, ReadI]> {
1695 let Inst{31-15} = 0b11011010110000010;
1696 let Inst{14-12} = opcode_prefix;
1697 let Inst{11-10} = opcode;
1702 class SignAuthZero<bits<3> opcode_prefix, bits<2> opcode, string asm>
1703 : I<(outs GPR64:$Rd), (ins), asm, "\t$Rd", "", []>, Sched<[]> {
1705 let Inst{31-15} = 0b11011010110000010;
1706 let Inst{14-12} = opcode_prefix;
1707 let Inst{11-10} = opcode;
1708 let Inst{9-5} = 0b11111;
1712 class SignAuthTwoOperand<bits<4> opc, string asm,
1713 SDPatternOperator OpNode>
1714 : I<(outs GPR64:$Rd), (ins GPR64:$Rn, GPR64sp:$Rm),
1715 asm, "\t$Rd, $Rn, $Rm", "",
1716 [(set GPR64:$Rd, (OpNode GPR64:$Rn, GPR64sp:$Rm))]>,
1717 Sched<[WriteI, ReadI, ReadI]> {
1721 let Inst{31-21} = 0b10011010110;
1722 let Inst{20-16} = Rm;
1723 let Inst{15-14} = 0b00;
1724 let Inst{13-10} = opc;
1729 // Base class for the Armv8.4-A 8 and 16-bit flag manipulation instructions
1730 class BaseFlagManipulation<bit sf, bit sz, dag iops, string asm, string ops>
1731 : I<(outs), iops, asm, ops, "", []>,
1732 Sched<[WriteI, ReadI, ReadI]> {
1736 let Inst{30-15} = 0b0111010000000000;
1738 let Inst{13-10} = 0b0010;
1740 let Inst{4-0} = 0b01101;
1743 class FlagRotate<dag iops, string asm, string ops>
1744 : BaseFlagManipulation<0b1, 0b0, iops, asm, ops> {
1747 let Inst{20-15} = imm;
1748 let Inst{13-10} = 0b0001;
1750 let Inst{3-0} = mask;
1754 // Basic two-operand data processing instructions.
1756 class BaseBaseAddSubCarry<bit isSub, RegisterClass regtype, string asm,
1758 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
1759 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
1760 Sched<[WriteI, ReadI, ReadI]> {
1765 let Inst{30} = isSub;
1766 let Inst{28-21} = 0b11010000;
1767 let Inst{20-16} = Rm;
1768 let Inst{15-10} = 0;
1773 class BaseAddSubCarry<bit isSub, RegisterClass regtype, string asm,
1775 : BaseBaseAddSubCarry<isSub, regtype, asm,
1776 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm, NZCV))]>;
1778 class BaseAddSubCarrySetFlags<bit isSub, RegisterClass regtype, string asm,
1780 : BaseBaseAddSubCarry<isSub, regtype, asm,
1781 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm, NZCV)),
1786 multiclass AddSubCarry<bit isSub, string asm, string asm_setflags,
1787 SDNode OpNode, SDNode OpNode_setflags> {
1788 def Wr : BaseAddSubCarry<isSub, GPR32, asm, OpNode> {
1792 def Xr : BaseAddSubCarry<isSub, GPR64, asm, OpNode> {
1798 def SWr : BaseAddSubCarrySetFlags<isSub, GPR32, asm_setflags,
1803 def SXr : BaseAddSubCarrySetFlags<isSub, GPR64, asm_setflags,
1810 class BaseTwoOperand<bits<4> opc, RegisterClass regtype, string asm,
1811 SDPatternOperator OpNode,
1812 RegisterClass in1regtype = regtype,
1813 RegisterClass in2regtype = regtype>
1814 : I<(outs regtype:$Rd), (ins in1regtype:$Rn, in2regtype:$Rm),
1815 asm, "\t$Rd, $Rn, $Rm", "",
1816 [(set regtype:$Rd, (OpNode in1regtype:$Rn, in2regtype:$Rm))]> {
1820 let Inst{30-21} = 0b0011010110;
1821 let Inst{20-16} = Rm;
1822 let Inst{15-14} = 0b00;
1823 let Inst{13-10} = opc;
1828 class BaseDiv<bit isSigned, RegisterClass regtype, string asm,
1829 SDPatternOperator OpNode>
1830 : BaseTwoOperand<{0,0,1,?}, regtype, asm, OpNode> {
1831 let Inst{10} = isSigned;
1834 multiclass Div<bit isSigned, string asm, SDPatternOperator OpNode> {
1835 def Wr : BaseDiv<isSigned, GPR32, asm, OpNode>,
1836 Sched<[WriteID32, ReadID, ReadID]> {
1839 def Xr : BaseDiv<isSigned, GPR64, asm, OpNode>,
1840 Sched<[WriteID64, ReadID, ReadID]> {
1845 class BaseShift<bits<2> shift_type, RegisterClass regtype, string asm,
1846 SDPatternOperator OpNode = null_frag>
1847 : BaseTwoOperand<{1,0,?,?}, regtype, asm, OpNode>,
1848 Sched<[WriteIS, ReadI]> {
1849 let Inst{11-10} = shift_type;
1852 multiclass Shift<bits<2> shift_type, string asm, SDNode OpNode> {
1853 def Wr : BaseShift<shift_type, GPR32, asm> {
1857 def Xr : BaseShift<shift_type, GPR64, asm, OpNode> {
1861 def : Pat<(i32 (OpNode GPR32:$Rn, i64:$Rm)),
1862 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn,
1863 (EXTRACT_SUBREG i64:$Rm, sub_32))>;
1865 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (zext GPR32:$Rm)))),
1866 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1868 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (anyext GPR32:$Rm)))),
1869 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1871 def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (sext GPR32:$Rm)))),
1872 (!cast<Instruction>(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>;
1874 def : Pat<(i64 (OpNode GPR64:$Rn, (i64 (sext GPR32:$Rm)))),
1875 (!cast<Instruction>(NAME # "Xr") GPR64:$Rn,
1876 (SUBREG_TO_REG (i32 0), GPR32:$Rm, sub_32))>;
1878 def : Pat<(i64 (OpNode GPR64:$Rn, (i64 (zext GPR32:$Rm)))),
1879 (!cast<Instruction>(NAME # "Xr") GPR64:$Rn,
1880 (SUBREG_TO_REG (i32 0), GPR32:$Rm, sub_32))>;
1883 class ShiftAlias<string asm, Instruction inst, RegisterClass regtype>
1884 : InstAlias<asm#"\t$dst, $src1, $src2",
1885 (inst regtype:$dst, regtype:$src1, regtype:$src2), 0>;
1887 class BaseMulAccum<bit isSub, bits<3> opc, RegisterClass multype,
1888 RegisterClass addtype, string asm,
1890 : I<(outs addtype:$Rd), (ins multype:$Rn, multype:$Rm, addtype:$Ra),
1891 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pattern> {
1896 let Inst{30-24} = 0b0011011;
1897 let Inst{23-21} = opc;
1898 let Inst{20-16} = Rm;
1899 let Inst{15} = isSub;
1900 let Inst{14-10} = Ra;
1905 multiclass MulAccum<bit isSub, string asm, SDNode AccNode> {
1906 // MADD/MSUB generation is decided by MachineCombiner.cpp
1907 def Wrrr : BaseMulAccum<isSub, 0b000, GPR32, GPR32, asm,
1908 [/*(set GPR32:$Rd, (AccNode GPR32:$Ra, (mul GPR32:$Rn, GPR32:$Rm)))*/]>,
1909 Sched<[WriteIM32, ReadIM, ReadIM, ReadIMA]> {
1913 def Xrrr : BaseMulAccum<isSub, 0b000, GPR64, GPR64, asm,
1914 [/*(set GPR64:$Rd, (AccNode GPR64:$Ra, (mul GPR64:$Rn, GPR64:$Rm)))*/]>,
1915 Sched<[WriteIM64, ReadIM, ReadIM, ReadIMA]> {
1920 class WideMulAccum<bit isSub, bits<3> opc, string asm,
1921 SDNode AccNode, SDNode ExtNode>
1922 : BaseMulAccum<isSub, opc, GPR32, GPR64, asm,
1923 [(set GPR64:$Rd, (AccNode GPR64:$Ra,
1924 (mul (ExtNode GPR32:$Rn), (ExtNode GPR32:$Rm))))]>,
1925 Sched<[WriteIM32, ReadIM, ReadIM, ReadIMA]> {
1929 class MulHi<bits<3> opc, string asm, SDNode OpNode>
1930 : I<(outs GPR64:$Rd), (ins GPR64:$Rn, GPR64:$Rm),
1931 asm, "\t$Rd, $Rn, $Rm", "",
1932 [(set GPR64:$Rd, (OpNode GPR64:$Rn, GPR64:$Rm))]>,
1933 Sched<[WriteIM64, ReadIM, ReadIM]> {
1937 let Inst{31-24} = 0b10011011;
1938 let Inst{23-21} = opc;
1939 let Inst{20-16} = Rm;
1944 // The Ra field of SMULH and UMULH is unused: it should be assembled as 31
1945 // (i.e. all bits 1) but is ignored by the processor.
1946 let PostEncoderMethod = "fixMulHigh";
1949 class MulAccumWAlias<string asm, Instruction inst>
1950 : InstAlias<asm#"\t$dst, $src1, $src2",
1951 (inst GPR32:$dst, GPR32:$src1, GPR32:$src2, WZR)>;
1952 class MulAccumXAlias<string asm, Instruction inst>
1953 : InstAlias<asm#"\t$dst, $src1, $src2",
1954 (inst GPR64:$dst, GPR64:$src1, GPR64:$src2, XZR)>;
1955 class WideMulAccumAlias<string asm, Instruction inst>
1956 : InstAlias<asm#"\t$dst, $src1, $src2",
1957 (inst GPR64:$dst, GPR32:$src1, GPR32:$src2, XZR)>;
1959 class BaseCRC32<bit sf, bits<2> sz, bit C, RegisterClass StreamReg,
1960 SDPatternOperator OpNode, string asm>
1961 : I<(outs GPR32:$Rd), (ins GPR32:$Rn, StreamReg:$Rm),
1962 asm, "\t$Rd, $Rn, $Rm", "",
1963 [(set GPR32:$Rd, (OpNode GPR32:$Rn, StreamReg:$Rm))]>,
1964 Sched<[WriteISReg, ReadI, ReadISReg]> {
1970 let Inst{30-21} = 0b0011010110;
1971 let Inst{20-16} = Rm;
1972 let Inst{15-13} = 0b010;
1974 let Inst{11-10} = sz;
1977 let Predicates = [HasCRC];
1981 // Address generation.
1984 class ADRI<bit page, string asm, Operand adr, list<dag> pattern>
1985 : I<(outs GPR64:$Xd), (ins adr:$label), asm, "\t$Xd, $label", "",
1990 let Inst{31} = page;
1991 let Inst{30-29} = label{1-0};
1992 let Inst{28-24} = 0b10000;
1993 let Inst{23-5} = label{20-2};
1996 let DecoderMethod = "DecodeAdrInstruction";
2003 def movimm32_imm : Operand<i32> {
2004 let ParserMatchClass = AsmImmRange<0, 65535>;
2005 let EncoderMethod = "getMoveWideImmOpValue";
2006 let PrintMethod = "printImm";
2008 def movimm32_shift : Operand<i32> {
2009 let PrintMethod = "printShifter";
2010 let ParserMatchClass = MovImm32ShifterOperand;
2012 def movimm64_shift : Operand<i32> {
2013 let PrintMethod = "printShifter";
2014 let ParserMatchClass = MovImm64ShifterOperand;
2017 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2018 class BaseMoveImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
2020 : I<(outs regtype:$Rd), (ins movimm32_imm:$imm, shifter:$shift),
2021 asm, "\t$Rd, $imm$shift", "", []>,
2026 let Inst{30-29} = opc;
2027 let Inst{28-23} = 0b100101;
2028 let Inst{22-21} = shift{5-4};
2029 let Inst{20-5} = imm;
2032 let DecoderMethod = "DecodeMoveImmInstruction";
2035 multiclass MoveImmediate<bits<2> opc, string asm> {
2036 def Wi : BaseMoveImmediate<opc, GPR32, movimm32_shift, asm> {
2040 def Xi : BaseMoveImmediate<opc, GPR64, movimm64_shift, asm> {
2045 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2046 class BaseInsertImmediate<bits<2> opc, RegisterClass regtype, Operand shifter,
2048 : I<(outs regtype:$Rd),
2049 (ins regtype:$src, movimm32_imm:$imm, shifter:$shift),
2050 asm, "\t$Rd, $imm$shift", "$src = $Rd", []>,
2051 Sched<[WriteI, ReadI]> {
2055 let Inst{30-29} = opc;
2056 let Inst{28-23} = 0b100101;
2057 let Inst{22-21} = shift{5-4};
2058 let Inst{20-5} = imm;
2061 let DecoderMethod = "DecodeMoveImmInstruction";
2064 multiclass InsertImmediate<bits<2> opc, string asm> {
2065 def Wi : BaseInsertImmediate<opc, GPR32, movimm32_shift, asm> {
2069 def Xi : BaseInsertImmediate<opc, GPR64, movimm64_shift, asm> {
2078 class BaseAddSubImm<bit isSub, bit setFlags, RegisterClass dstRegtype,
2079 string asm_inst, string asm_ops,
2080 dag inputs, dag pattern>
2081 : I<(outs dstRegtype:$Rd), inputs, asm_inst, asm_ops, "", [pattern]>,
2082 Sched<[WriteI, ReadI]> {
2085 let Inst{30} = isSub;
2086 let Inst{29} = setFlags;
2087 let Inst{28-24} = 0b10001;
2092 class AddSubImmShift<bit isSub, bit setFlags, RegisterClass dstRegtype,
2093 RegisterClass srcRegtype, addsub_shifted_imm immtype,
2094 string asm_inst, SDPatternOperator OpNode>
2095 : BaseAddSubImm<isSub, setFlags, dstRegtype, asm_inst, "\t$Rd, $Rn, $imm",
2096 (ins srcRegtype:$Rn, immtype:$imm),
2097 (set dstRegtype:$Rd, (OpNode srcRegtype:$Rn, immtype:$imm))> {
2099 let Inst{23-22} = imm{13-12}; // '00' => lsl #0, '01' => lsl #12
2100 let Inst{21-10} = imm{11-0};
2101 let DecoderMethod = "DecodeAddSubImmShift";
2104 class BaseAddSubRegPseudo<RegisterClass regtype,
2105 SDPatternOperator OpNode>
2106 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
2107 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
2108 Sched<[WriteI, ReadI, ReadI]>;
2110 class BaseAddSubSReg<bit isSub, bit setFlags, RegisterClass regtype,
2111 arith_shifted_reg shifted_regtype, string asm,
2112 SDPatternOperator OpNode>
2113 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
2114 asm, "\t$Rd, $Rn, $Rm", "",
2115 [(set regtype:$Rd, (OpNode regtype:$Rn, shifted_regtype:$Rm))]>,
2116 Sched<[WriteISReg, ReadI, ReadISReg]> {
2117 // The operands are in order to match the 'addr' MI operands, so we
2118 // don't need an encoder method and by-name matching. Just use the default
2119 // in-order handling. Since we're using by-order, make sure the names
2125 let Inst{30} = isSub;
2126 let Inst{29} = setFlags;
2127 let Inst{28-24} = 0b01011;
2128 let Inst{23-22} = shift{7-6};
2130 let Inst{20-16} = src2;
2131 let Inst{15-10} = shift{5-0};
2132 let Inst{9-5} = src1;
2133 let Inst{4-0} = dst;
2135 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
2138 class BaseAddSubEReg<bit isSub, bit setFlags, RegisterClass dstRegtype,
2139 RegisterClass src1Regtype, Operand src2Regtype,
2140 string asm, SDPatternOperator OpNode>
2141 : I<(outs dstRegtype:$R1),
2142 (ins src1Regtype:$R2, src2Regtype:$R3),
2143 asm, "\t$R1, $R2, $R3", "",
2144 [(set dstRegtype:$R1, (OpNode src1Regtype:$R2, src2Regtype:$R3))]>,
2145 Sched<[WriteIEReg, ReadI, ReadIEReg]> {
2150 let Inst{30} = isSub;
2151 let Inst{29} = setFlags;
2152 let Inst{28-24} = 0b01011;
2153 let Inst{23-21} = 0b001;
2154 let Inst{20-16} = Rm;
2155 let Inst{15-13} = ext{5-3};
2156 let Inst{12-10} = ext{2-0};
2160 let DecoderMethod = "DecodeAddSubERegInstruction";
2163 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2164 class BaseAddSubEReg64<bit isSub, bit setFlags, RegisterClass dstRegtype,
2165 RegisterClass src1Regtype, RegisterClass src2Regtype,
2166 Operand ext_op, string asm>
2167 : I<(outs dstRegtype:$Rd),
2168 (ins src1Regtype:$Rn, src2Regtype:$Rm, ext_op:$ext),
2169 asm, "\t$Rd, $Rn, $Rm$ext", "", []>,
2170 Sched<[WriteIEReg, ReadI, ReadIEReg]> {
2175 let Inst{30} = isSub;
2176 let Inst{29} = setFlags;
2177 let Inst{28-24} = 0b01011;
2178 let Inst{23-21} = 0b001;
2179 let Inst{20-16} = Rm;
2180 let Inst{15} = ext{5};
2181 let Inst{12-10} = ext{2-0};
2185 let DecoderMethod = "DecodeAddSubERegInstruction";
2188 // Aliases for register+register add/subtract.
2189 class AddSubRegAlias<string asm, Instruction inst, RegisterClass dstRegtype,
2190 RegisterClass src1Regtype, RegisterClass src2Regtype,
2192 : InstAlias<asm#"\t$dst, $src1, $src2",
2193 (inst dstRegtype:$dst, src1Regtype:$src1, src2Regtype:$src2,
2196 multiclass AddSub<bit isSub, string mnemonic, string alias,
2197 SDPatternOperator OpNode = null_frag> {
2198 let hasSideEffects = 0, isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2199 // Add/Subtract immediate
2200 // Increase the weight of the immediate variant to try to match it before
2201 // the extended register variant.
2202 // We used to match the register variant before the immediate when the
2203 // register argument could be implicitly zero-extended.
2204 let AddedComplexity = 6 in
2205 def Wri : AddSubImmShift<isSub, 0, GPR32sp, GPR32sp, addsub_shifted_imm32,
2209 let AddedComplexity = 6 in
2210 def Xri : AddSubImmShift<isSub, 0, GPR64sp, GPR64sp, addsub_shifted_imm64,
2215 // Add/Subtract register - Only used for CodeGen
2216 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
2217 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
2219 // Add/Subtract shifted register
2220 def Wrs : BaseAddSubSReg<isSub, 0, GPR32, arith_shifted_reg32, mnemonic,
2224 def Xrs : BaseAddSubSReg<isSub, 0, GPR64, arith_shifted_reg64, mnemonic,
2230 // Add/Subtract extended register
2231 let AddedComplexity = 1, hasSideEffects = 0 in {
2232 def Wrx : BaseAddSubEReg<isSub, 0, GPR32sp, GPR32sp,
2233 arith_extended_reg32_i32, mnemonic, OpNode> {
2236 def Xrx : BaseAddSubEReg<isSub, 0, GPR64sp, GPR64sp,
2237 arith_extended_reg32to64_i64, mnemonic, OpNode> {
2242 def Xrx64 : BaseAddSubEReg64<isSub, 0, GPR64sp, GPR64sp, GPR64,
2243 arith_extendlsl64, mnemonic> {
2244 // UXTX and SXTX only.
2245 let Inst{14-13} = 0b11;
2249 // add Rd, Rb, -imm -> sub Rd, Rn, imm
2250 def : InstSubst<alias#"\t$Rd, $Rn, $imm",
2251 (!cast<Instruction>(NAME # "Wri") GPR32sp:$Rd, GPR32sp:$Rn,
2252 addsub_shifted_imm32_neg:$imm), 0>;
2253 def : InstSubst<alias#"\t$Rd, $Rn, $imm",
2254 (!cast<Instruction>(NAME # "Xri") GPR64sp:$Rd, GPR64sp:$Rn,
2255 addsub_shifted_imm64_neg:$imm), 0>;
2257 // Register/register aliases with no shift when SP is not used.
2258 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
2259 GPR32, GPR32, GPR32, 0>;
2260 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
2261 GPR64, GPR64, GPR64, 0>;
2263 // Register/register aliases with no shift when either the destination or
2264 // first source register is SP.
2265 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
2266 GPR32sponly, GPR32sp, GPR32, 16>; // UXTW #0
2267 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
2268 GPR32sp, GPR32sponly, GPR32, 16>; // UXTW #0
2269 def : AddSubRegAlias<mnemonic,
2270 !cast<Instruction>(NAME#"Xrx64"),
2271 GPR64sponly, GPR64sp, GPR64, 24>; // UXTX #0
2272 def : AddSubRegAlias<mnemonic,
2273 !cast<Instruction>(NAME#"Xrx64"),
2274 GPR64sp, GPR64sponly, GPR64, 24>; // UXTX #0
2277 multiclass AddSubS<bit isSub, string mnemonic, SDNode OpNode, string cmp,
2278 string alias, string cmpAlias> {
2279 let isCompare = 1, Defs = [NZCV] in {
2280 // Add/Subtract immediate
2281 def Wri : AddSubImmShift<isSub, 1, GPR32, GPR32sp, addsub_shifted_imm32,
2285 def Xri : AddSubImmShift<isSub, 1, GPR64, GPR64sp, addsub_shifted_imm64,
2290 // Add/Subtract register
2291 def Wrr : BaseAddSubRegPseudo<GPR32, OpNode>;
2292 def Xrr : BaseAddSubRegPseudo<GPR64, OpNode>;
2294 // Add/Subtract shifted register
2295 def Wrs : BaseAddSubSReg<isSub, 1, GPR32, arith_shifted_reg32, mnemonic,
2299 def Xrs : BaseAddSubSReg<isSub, 1, GPR64, arith_shifted_reg64, mnemonic,
2304 // Add/Subtract extended register
2305 let AddedComplexity = 1 in {
2306 def Wrx : BaseAddSubEReg<isSub, 1, GPR32, GPR32sp,
2307 arith_extended_reg32_i32, mnemonic, OpNode> {
2310 def Xrx : BaseAddSubEReg<isSub, 1, GPR64, GPR64sp,
2311 arith_extended_reg32_i64, mnemonic, OpNode> {
2316 def Xrx64 : BaseAddSubEReg64<isSub, 1, GPR64, GPR64sp, GPR64,
2317 arith_extendlsl64, mnemonic> {
2318 // UXTX and SXTX only.
2319 let Inst{14-13} = 0b11;
2324 // Support negative immediates, e.g. adds Rd, Rn, -imm -> subs Rd, Rn, imm
2325 def : InstSubst<alias#"\t$Rd, $Rn, $imm",
2326 (!cast<Instruction>(NAME # "Wri") GPR32:$Rd, GPR32sp:$Rn,
2327 addsub_shifted_imm32_neg:$imm), 0>;
2328 def : InstSubst<alias#"\t$Rd, $Rn, $imm",
2329 (!cast<Instruction>(NAME # "Xri") GPR64:$Rd, GPR64sp:$Rn,
2330 addsub_shifted_imm64_neg:$imm), 0>;
2333 def : InstAlias<cmp#"\t$src, $imm", (!cast<Instruction>(NAME#"Wri")
2334 WZR, GPR32sp:$src, addsub_shifted_imm32:$imm), 5>;
2335 def : InstAlias<cmp#"\t$src, $imm", (!cast<Instruction>(NAME#"Xri")
2336 XZR, GPR64sp:$src, addsub_shifted_imm64:$imm), 5>;
2337 def : InstAlias<cmp#"\t$src1, $src2$sh", (!cast<Instruction>(NAME#"Wrx")
2338 WZR, GPR32sp:$src1, GPR32:$src2, arith_extend:$sh), 4>;
2339 def : InstAlias<cmp#"\t$src1, $src2$sh", (!cast<Instruction>(NAME#"Xrx")
2340 XZR, GPR64sp:$src1, GPR32:$src2, arith_extend:$sh), 4>;
2341 def : InstAlias<cmp#"\t$src1, $src2$sh", (!cast<Instruction>(NAME#"Xrx64")
2342 XZR, GPR64sp:$src1, GPR64:$src2, arith_extendlsl64:$sh), 4>;
2343 def : InstAlias<cmp#"\t$src1, $src2$sh", (!cast<Instruction>(NAME#"Wrs")
2344 WZR, GPR32:$src1, GPR32:$src2, arith_shift32:$sh), 4>;
2345 def : InstAlias<cmp#"\t$src1, $src2$sh", (!cast<Instruction>(NAME#"Xrs")
2346 XZR, GPR64:$src1, GPR64:$src2, arith_shift64:$sh), 4>;
2348 // Support negative immediates, e.g. cmp Rn, -imm -> cmn Rn, imm
2349 def : InstSubst<cmpAlias#"\t$src, $imm", (!cast<Instruction>(NAME#"Wri")
2350 WZR, GPR32sp:$src, addsub_shifted_imm32_neg:$imm), 0>;
2351 def : InstSubst<cmpAlias#"\t$src, $imm", (!cast<Instruction>(NAME#"Xri")
2352 XZR, GPR64sp:$src, addsub_shifted_imm64_neg:$imm), 0>;
2354 // Compare shorthands
2355 def : InstAlias<cmp#"\t$src1, $src2", (!cast<Instruction>(NAME#"Wrs")
2356 WZR, GPR32:$src1, GPR32:$src2, 0), 5>;
2357 def : InstAlias<cmp#"\t$src1, $src2", (!cast<Instruction>(NAME#"Xrs")
2358 XZR, GPR64:$src1, GPR64:$src2, 0), 5>;
2359 def : InstAlias<cmp#"\t$src1, $src2", (!cast<Instruction>(NAME#"Wrx")
2360 WZR, GPR32sponly:$src1, GPR32:$src2, 16), 5>;
2361 def : InstAlias<cmp#"\t$src1, $src2", (!cast<Instruction>(NAME#"Xrx64")
2362 XZR, GPR64sponly:$src1, GPR64:$src2, 24), 5>;
2364 // Register/register aliases with no shift when SP is not used.
2365 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrs"),
2366 GPR32, GPR32, GPR32, 0>;
2367 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Xrs"),
2368 GPR64, GPR64, GPR64, 0>;
2370 // Register/register aliases with no shift when the first source register
2372 def : AddSubRegAlias<mnemonic, !cast<Instruction>(NAME#"Wrx"),
2373 GPR32, GPR32sponly, GPR32, 16>; // UXTW #0
2374 def : AddSubRegAlias<mnemonic,
2375 !cast<Instruction>(NAME#"Xrx64"),
2376 GPR64, GPR64sponly, GPR64, 24>; // UXTX #0
2379 class AddSubG<bit isSub, string asm_inst, SDPatternOperator OpNode>
2381 isSub, 0, GPR64sp, asm_inst, "\t$Rd, $Rn, $imm6, $imm4",
2382 (ins GPR64sp:$Rn, uimm6s16:$imm6, imm0_15:$imm4),
2383 (set GPR64sp:$Rd, (OpNode GPR64sp:$Rn, imm0_63:$imm6, imm0_15:$imm4))> {
2387 let Inst{23-22} = 0b10;
2388 let Inst{21-16} = imm6;
2389 let Inst{15-14} = 0b00;
2390 let Inst{13-10} = imm4;
2391 let Unpredictable{15-14} = 0b11;
2394 class SUBP<bit setsFlags, string asm_instr, SDPatternOperator OpNode>
2395 : BaseTwoOperand<0b0000, GPR64, asm_instr, OpNode, GPR64sp, GPR64sp> {
2397 let Inst{29} = setsFlags;
2403 def SDTA64EXTR : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
2405 def AArch64Extr : SDNode<"AArch64ISD::EXTR", SDTA64EXTR>;
2407 class BaseExtractImm<RegisterClass regtype, Operand imm_type, string asm,
2409 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, imm_type:$imm),
2410 asm, "\t$Rd, $Rn, $Rm, $imm", "", patterns>,
2411 Sched<[WriteExtr, ReadExtrHi]> {
2417 let Inst{30-23} = 0b00100111;
2419 let Inst{20-16} = Rm;
2420 let Inst{15-10} = imm;
2425 multiclass ExtractImm<string asm> {
2426 def Wrri : BaseExtractImm<GPR32, imm0_31, asm,
2428 (AArch64Extr GPR32:$Rn, GPR32:$Rm, imm0_31:$imm))]> {
2431 // imm<5> must be zero.
2434 def Xrri : BaseExtractImm<GPR64, imm0_63, asm,
2436 (AArch64Extr GPR64:$Rn, GPR64:$Rm, imm0_63:$imm))]> {
2447 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2448 class BaseBitfieldImm<bits<2> opc,
2449 RegisterClass regtype, Operand imm_type, string asm>
2450 : I<(outs regtype:$Rd), (ins regtype:$Rn, imm_type:$immr, imm_type:$imms),
2451 asm, "\t$Rd, $Rn, $immr, $imms", "", []>,
2452 Sched<[WriteIS, ReadI]> {
2458 let Inst{30-29} = opc;
2459 let Inst{28-23} = 0b100110;
2460 let Inst{21-16} = immr;
2461 let Inst{15-10} = imms;
2466 multiclass BitfieldImm<bits<2> opc, string asm> {
2467 def Wri : BaseBitfieldImm<opc, GPR32, imm0_31, asm> {
2470 // imms<5> and immr<5> must be zero, else ReservedValue().
2474 def Xri : BaseBitfieldImm<opc, GPR64, imm0_63, asm> {
2480 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2481 class BaseBitfieldImmWith2RegArgs<bits<2> opc,
2482 RegisterClass regtype, Operand imm_type, string asm>
2483 : I<(outs regtype:$Rd), (ins regtype:$src, regtype:$Rn, imm_type:$immr,
2485 asm, "\t$Rd, $Rn, $immr, $imms", "$src = $Rd", []>,
2486 Sched<[WriteIS, ReadI]> {
2492 let Inst{30-29} = opc;
2493 let Inst{28-23} = 0b100110;
2494 let Inst{21-16} = immr;
2495 let Inst{15-10} = imms;
2500 multiclass BitfieldImmWith2RegArgs<bits<2> opc, string asm> {
2501 def Wri : BaseBitfieldImmWith2RegArgs<opc, GPR32, imm0_31, asm> {
2504 // imms<5> and immr<5> must be zero, else ReservedValue().
2508 def Xri : BaseBitfieldImmWith2RegArgs<opc, GPR64, imm0_63, asm> {
2518 // Logical (immediate)
2519 class BaseLogicalImm<bits<2> opc, RegisterClass dregtype,
2520 RegisterClass sregtype, Operand imm_type, string asm,
2522 : I<(outs dregtype:$Rd), (ins sregtype:$Rn, imm_type:$imm),
2523 asm, "\t$Rd, $Rn, $imm", "", pattern>,
2524 Sched<[WriteI, ReadI]> {
2528 let Inst{30-29} = opc;
2529 let Inst{28-23} = 0b100100;
2530 let Inst{22} = imm{12};
2531 let Inst{21-16} = imm{11-6};
2532 let Inst{15-10} = imm{5-0};
2536 let DecoderMethod = "DecodeLogicalImmInstruction";
2539 // Logical (shifted register)
2540 class BaseLogicalSReg<bits<2> opc, bit N, RegisterClass regtype,
2541 logical_shifted_reg shifted_regtype, string asm,
2543 : I<(outs regtype:$Rd), (ins regtype:$Rn, shifted_regtype:$Rm),
2544 asm, "\t$Rd, $Rn, $Rm", "", pattern>,
2545 Sched<[WriteISReg, ReadI, ReadISReg]> {
2546 // The operands are in order to match the 'addr' MI operands, so we
2547 // don't need an encoder method and by-name matching. Just use the default
2548 // in-order handling. Since we're using by-order, make sure the names
2554 let Inst{30-29} = opc;
2555 let Inst{28-24} = 0b01010;
2556 let Inst{23-22} = shift{7-6};
2558 let Inst{20-16} = src2;
2559 let Inst{15-10} = shift{5-0};
2560 let Inst{9-5} = src1;
2561 let Inst{4-0} = dst;
2563 let DecoderMethod = "DecodeThreeAddrSRegInstruction";
2566 // Aliases for register+register logical instructions.
2567 class LogicalRegAlias<string asm, Instruction inst, RegisterClass regtype>
2568 : InstAlias<asm#"\t$dst, $src1, $src2",
2569 (inst regtype:$dst, regtype:$src1, regtype:$src2, 0)>;
2571 multiclass LogicalImm<bits<2> opc, string mnemonic, SDNode OpNode,
2573 let AddedComplexity = 6, isReMaterializable = 1, isAsCheapAsAMove = 1 in
2574 def Wri : BaseLogicalImm<opc, GPR32sp, GPR32, logical_imm32, mnemonic,
2575 [(set GPR32sp:$Rd, (OpNode GPR32:$Rn,
2576 logical_imm32:$imm))]> {
2578 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
2580 let AddedComplexity = 6, isReMaterializable = 1, isAsCheapAsAMove = 1 in
2581 def Xri : BaseLogicalImm<opc, GPR64sp, GPR64, logical_imm64, mnemonic,
2582 [(set GPR64sp:$Rd, (OpNode GPR64:$Rn,
2583 logical_imm64:$imm))]> {
2587 def : InstSubst<Alias # "\t$Rd, $Rn, $imm",
2588 (!cast<Instruction>(NAME # "Wri") GPR32sp:$Rd, GPR32:$Rn,
2589 logical_imm32_not:$imm), 0>;
2590 def : InstSubst<Alias # "\t$Rd, $Rn, $imm",
2591 (!cast<Instruction>(NAME # "Xri") GPR64sp:$Rd, GPR64:$Rn,
2592 logical_imm64_not:$imm), 0>;
2595 multiclass LogicalImmS<bits<2> opc, string mnemonic, SDNode OpNode,
2597 let isCompare = 1, Defs = [NZCV] in {
2598 def Wri : BaseLogicalImm<opc, GPR32, GPR32, logical_imm32, mnemonic,
2599 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_imm32:$imm))]> {
2601 let Inst{22} = 0; // 64-bit version has an additional bit of immediate.
2603 def Xri : BaseLogicalImm<opc, GPR64, GPR64, logical_imm64, mnemonic,
2604 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_imm64:$imm))]> {
2607 } // end Defs = [NZCV]
2609 def : InstSubst<Alias # "\t$Rd, $Rn, $imm",
2610 (!cast<Instruction>(NAME # "Wri") GPR32:$Rd, GPR32:$Rn,
2611 logical_imm32_not:$imm), 0>;
2612 def : InstSubst<Alias # "\t$Rd, $Rn, $imm",
2613 (!cast<Instruction>(NAME # "Xri") GPR64:$Rd, GPR64:$Rn,
2614 logical_imm64_not:$imm), 0>;
2617 class BaseLogicalRegPseudo<RegisterClass regtype, SDPatternOperator OpNode>
2618 : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
2619 [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>,
2620 Sched<[WriteI, ReadI, ReadI]>;
2622 // Split from LogicalImm as not all instructions have both.
2623 multiclass LogicalReg<bits<2> opc, bit N, string mnemonic,
2624 SDPatternOperator OpNode> {
2625 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2626 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
2627 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
2630 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
2631 [(set GPR32:$Rd, (OpNode GPR32:$Rn,
2632 logical_shifted_reg32:$Rm))]> {
2635 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
2636 [(set GPR64:$Rd, (OpNode GPR64:$Rn,
2637 logical_shifted_reg64:$Rm))]> {
2641 def : LogicalRegAlias<mnemonic,
2642 !cast<Instruction>(NAME#"Wrs"), GPR32>;
2643 def : LogicalRegAlias<mnemonic,
2644 !cast<Instruction>(NAME#"Xrs"), GPR64>;
2647 // Split from LogicalReg to allow setting NZCV Defs
2648 multiclass LogicalRegS<bits<2> opc, bit N, string mnemonic,
2649 SDPatternOperator OpNode = null_frag> {
2650 let Defs = [NZCV], mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
2651 def Wrr : BaseLogicalRegPseudo<GPR32, OpNode>;
2652 def Xrr : BaseLogicalRegPseudo<GPR64, OpNode>;
2654 def Wrs : BaseLogicalSReg<opc, N, GPR32, logical_shifted_reg32, mnemonic,
2655 [(set GPR32:$Rd, (OpNode GPR32:$Rn, logical_shifted_reg32:$Rm))]> {
2658 def Xrs : BaseLogicalSReg<opc, N, GPR64, logical_shifted_reg64, mnemonic,
2659 [(set GPR64:$Rd, (OpNode GPR64:$Rn, logical_shifted_reg64:$Rm))]> {
2664 def : LogicalRegAlias<mnemonic,
2665 !cast<Instruction>(NAME#"Wrs"), GPR32>;
2666 def : LogicalRegAlias<mnemonic,
2667 !cast<Instruction>(NAME#"Xrs"), GPR64>;
2671 // Conditionally set flags
2674 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2675 class BaseCondComparisonImm<bit op, RegisterClass regtype, ImmLeaf immtype,
2676 string mnemonic, SDNode OpNode>
2677 : I<(outs), (ins regtype:$Rn, immtype:$imm, imm32_0_15:$nzcv, ccode:$cond),
2678 mnemonic, "\t$Rn, $imm, $nzcv, $cond", "",
2679 [(set NZCV, (OpNode regtype:$Rn, immtype:$imm, (i32 imm:$nzcv),
2680 (i32 imm:$cond), NZCV))]>,
2681 Sched<[WriteI, ReadI]> {
2691 let Inst{29-21} = 0b111010010;
2692 let Inst{20-16} = imm;
2693 let Inst{15-12} = cond;
2694 let Inst{11-10} = 0b10;
2697 let Inst{3-0} = nzcv;
2700 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
2701 class BaseCondComparisonReg<bit op, RegisterClass regtype, string mnemonic,
2703 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm32_0_15:$nzcv, ccode:$cond),
2704 mnemonic, "\t$Rn, $Rm, $nzcv, $cond", "",
2705 [(set NZCV, (OpNode regtype:$Rn, regtype:$Rm, (i32 imm:$nzcv),
2706 (i32 imm:$cond), NZCV))]>,
2707 Sched<[WriteI, ReadI, ReadI]> {
2717 let Inst{29-21} = 0b111010010;
2718 let Inst{20-16} = Rm;
2719 let Inst{15-12} = cond;
2720 let Inst{11-10} = 0b00;
2723 let Inst{3-0} = nzcv;
2726 multiclass CondComparison<bit op, string mnemonic, SDNode OpNode> {
2727 // immediate operand variants
2728 def Wi : BaseCondComparisonImm<op, GPR32, imm32_0_31, mnemonic, OpNode> {
2731 def Xi : BaseCondComparisonImm<op, GPR64, imm0_31, mnemonic, OpNode> {
2734 // register operand variants
2735 def Wr : BaseCondComparisonReg<op, GPR32, mnemonic, OpNode> {
2738 def Xr : BaseCondComparisonReg<op, GPR64, mnemonic, OpNode> {
2744 // Conditional select
2747 class BaseCondSelect<bit op, bits<2> op2, RegisterClass regtype, string asm>
2748 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
2749 asm, "\t$Rd, $Rn, $Rm, $cond", "",
2751 (AArch64csel regtype:$Rn, regtype:$Rm, (i32 imm:$cond), NZCV))]>,
2752 Sched<[WriteI, ReadI, ReadI]> {
2761 let Inst{29-21} = 0b011010100;
2762 let Inst{20-16} = Rm;
2763 let Inst{15-12} = cond;
2764 let Inst{11-10} = op2;
2769 multiclass CondSelect<bit op, bits<2> op2, string asm> {
2770 def Wr : BaseCondSelect<op, op2, GPR32, asm> {
2773 def Xr : BaseCondSelect<op, op2, GPR64, asm> {
2778 class BaseCondSelectOp<bit op, bits<2> op2, RegisterClass regtype, string asm,
2780 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
2781 asm, "\t$Rd, $Rn, $Rm, $cond", "",
2783 (AArch64csel regtype:$Rn, (frag regtype:$Rm),
2784 (i32 imm:$cond), NZCV))]>,
2785 Sched<[WriteI, ReadI, ReadI]> {
2794 let Inst{29-21} = 0b011010100;
2795 let Inst{20-16} = Rm;
2796 let Inst{15-12} = cond;
2797 let Inst{11-10} = op2;
2802 def inv_cond_XFORM : SDNodeXForm<imm, [{
2803 AArch64CC::CondCode CC = static_cast<AArch64CC::CondCode>(N->getZExtValue());
2804 return CurDAG->getTargetConstant(AArch64CC::getInvertedCondCode(CC), SDLoc(N),
2808 multiclass CondSelectOp<bit op, bits<2> op2, string asm, PatFrag frag> {
2809 def Wr : BaseCondSelectOp<op, op2, GPR32, asm, frag> {
2812 def Xr : BaseCondSelectOp<op, op2, GPR64, asm, frag> {
2816 def : Pat<(AArch64csel (frag GPR32:$Rm), GPR32:$Rn, (i32 imm:$cond), NZCV),
2817 (!cast<Instruction>(NAME # Wr) GPR32:$Rn, GPR32:$Rm,
2818 (inv_cond_XFORM imm:$cond))>;
2820 def : Pat<(AArch64csel (frag GPR64:$Rm), GPR64:$Rn, (i32 imm:$cond), NZCV),
2821 (!cast<Instruction>(NAME # Xr) GPR64:$Rn, GPR64:$Rm,
2822 (inv_cond_XFORM imm:$cond))>;
2826 // Special Mask Value
2828 def maski8_or_more : Operand<i32>,
2829 ImmLeaf<i32, [{ return (Imm & 0xff) == 0xff; }]> {
2831 def maski16_or_more : Operand<i32>,
2832 ImmLeaf<i32, [{ return (Imm & 0xffff) == 0xffff; }]> {
2840 // (unsigned immediate)
2841 // Indexed for 8-bit registers. offset is in range [0,4095].
2842 def am_indexed8 : ComplexPattern<i64, 2, "SelectAddrModeIndexed8", []>;
2843 def am_indexed16 : ComplexPattern<i64, 2, "SelectAddrModeIndexed16", []>;
2844 def am_indexed32 : ComplexPattern<i64, 2, "SelectAddrModeIndexed32", []>;
2845 def am_indexed64 : ComplexPattern<i64, 2, "SelectAddrModeIndexed64", []>;
2846 def am_indexed128 : ComplexPattern<i64, 2, "SelectAddrModeIndexed128", []>;
2848 def gi_am_indexed8 :
2849 GIComplexOperandMatcher<s64, "selectAddrModeIndexed<8>">,
2850 GIComplexPatternEquiv<am_indexed8>;
2851 def gi_am_indexed16 :
2852 GIComplexOperandMatcher<s64, "selectAddrModeIndexed<16>">,
2853 GIComplexPatternEquiv<am_indexed16>;
2854 def gi_am_indexed32 :
2855 GIComplexOperandMatcher<s64, "selectAddrModeIndexed<32>">,
2856 GIComplexPatternEquiv<am_indexed32>;
2857 def gi_am_indexed64 :
2858 GIComplexOperandMatcher<s64, "selectAddrModeIndexed<64>">,
2859 GIComplexPatternEquiv<am_indexed64>;
2860 def gi_am_indexed128 :
2861 GIComplexOperandMatcher<s64, "selectAddrModeIndexed<128>">,
2862 GIComplexPatternEquiv<am_indexed128>;
2864 class UImm12OffsetOperand<int Scale> : AsmOperandClass {
2865 let Name = "UImm12Offset" # Scale;
2866 let RenderMethod = "addUImm12OffsetOperands<" # Scale # ">";
2867 let PredicateMethod = "isUImm12Offset<" # Scale # ">";
2868 let DiagnosticType = "InvalidMemoryIndexed" # Scale;
2871 def UImm12OffsetScale1Operand : UImm12OffsetOperand<1>;
2872 def UImm12OffsetScale2Operand : UImm12OffsetOperand<2>;
2873 def UImm12OffsetScale4Operand : UImm12OffsetOperand<4>;
2874 def UImm12OffsetScale8Operand : UImm12OffsetOperand<8>;
2875 def UImm12OffsetScale16Operand : UImm12OffsetOperand<16>;
2877 class uimm12_scaled<int Scale> : Operand<i64> {
2878 let ParserMatchClass
2879 = !cast<AsmOperandClass>("UImm12OffsetScale" # Scale # "Operand");
2881 = "getLdStUImm12OpValue<AArch64::fixup_aarch64_ldst_imm12_scale" # Scale # ">";
2882 let PrintMethod = "printUImm12Offset<" # Scale # ">";
2885 def uimm12s1 : uimm12_scaled<1>;
2886 def uimm12s2 : uimm12_scaled<2>;
2887 def uimm12s4 : uimm12_scaled<4>;
2888 def uimm12s8 : uimm12_scaled<8>;
2889 def uimm12s16 : uimm12_scaled<16>;
2891 class BaseLoadStoreUI<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
2892 string asm, list<dag> pattern>
2893 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]", "", pattern> {
2899 let Inst{31-30} = sz;
2900 let Inst{29-27} = 0b111;
2902 let Inst{25-24} = 0b01;
2903 let Inst{23-22} = opc;
2904 let Inst{21-10} = offset;
2908 let DecoderMethod = "DecodeUnsignedLdStInstruction";
2911 multiclass LoadUI<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
2912 Operand indextype, string asm, list<dag> pattern> {
2913 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2914 def ui : BaseLoadStoreUI<sz, V, opc, (outs regtype:$Rt),
2915 (ins GPR64sp:$Rn, indextype:$offset),
2919 def : InstAlias<asm # "\t$Rt, [$Rn]",
2920 (!cast<Instruction>(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>;
2923 multiclass StoreUI<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
2924 Operand indextype, string asm, list<dag> pattern> {
2925 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2926 def ui : BaseLoadStoreUI<sz, V, opc, (outs),
2927 (ins regtype:$Rt, GPR64sp:$Rn, indextype:$offset),
2931 def : InstAlias<asm # "\t$Rt, [$Rn]",
2932 (!cast<Instruction>(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>;
2935 // Same as StoreUI, but take a RegisterOperand. This is used by GlobalISel to
2936 // substitute zero-registers automatically.
2938 // TODO: Roll out zero-register subtitution to GPR32/GPR64 and fold this back
2940 multiclass StoreUIz<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
2941 Operand indextype, string asm, list<dag> pattern> {
2942 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
2943 def ui : BaseLoadStoreUI<sz, V, opc, (outs),
2944 (ins regtype:$Rt, GPR64sp:$Rn, indextype:$offset),
2948 def : InstAlias<asm # "\t$Rt, [$Rn]",
2949 (!cast<Instruction>(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>;
2952 def PrefetchOperand : AsmOperandClass {
2953 let Name = "Prefetch";
2954 let ParserMethod = "tryParsePrefetch";
2956 def prfop : Operand<i32> {
2957 let PrintMethod = "printPrefetchOp";
2958 let ParserMatchClass = PrefetchOperand;
2961 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2962 class PrefetchUI<bits<2> sz, bit V, bits<2> opc, string asm, list<dag> pat>
2963 : BaseLoadStoreUI<sz, V, opc,
2964 (outs), (ins prfop:$Rt, GPR64sp:$Rn, uimm12s8:$offset),
2972 // Load literal address: 19-bit immediate. The low two bits of the target
2973 // offset are implied zero and so are not part of the immediate.
2974 def am_ldrlit : Operand<iPTR> {
2975 let EncoderMethod = "getLoadLiteralOpValue";
2976 let DecoderMethod = "DecodePCRelLabel19";
2977 let PrintMethod = "printAlignedLabel";
2978 let ParserMatchClass = PCRelLabel19Operand;
2979 let OperandType = "OPERAND_PCREL";
2982 let mayLoad = 1, mayStore = 0, hasSideEffects = 0, AddedComplexity = 20 in
2983 class LoadLiteral<bits<2> opc, bit V, RegisterOperand regtype, string asm, list<dag> pat>
2984 : I<(outs regtype:$Rt), (ins am_ldrlit:$label),
2985 asm, "\t$Rt, $label", "", pat>,
2989 let Inst{31-30} = opc;
2990 let Inst{29-27} = 0b011;
2992 let Inst{25-24} = 0b00;
2993 let Inst{23-5} = label;
2997 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
2998 class PrefetchLiteral<bits<2> opc, bit V, string asm, list<dag> pat>
2999 : I<(outs), (ins prfop:$Rt, am_ldrlit:$label),
3000 asm, "\t$Rt, $label", "", pat>,
3004 let Inst{31-30} = opc;
3005 let Inst{29-27} = 0b011;
3007 let Inst{25-24} = 0b00;
3008 let Inst{23-5} = label;
3013 // Load/store register offset
3016 def ro_Xindexed8 : ComplexPattern<i64, 4, "SelectAddrModeXRO<8>", []>;
3017 def ro_Xindexed16 : ComplexPattern<i64, 4, "SelectAddrModeXRO<16>", []>;
3018 def ro_Xindexed32 : ComplexPattern<i64, 4, "SelectAddrModeXRO<32>", []>;
3019 def ro_Xindexed64 : ComplexPattern<i64, 4, "SelectAddrModeXRO<64>", []>;
3020 def ro_Xindexed128 : ComplexPattern<i64, 4, "SelectAddrModeXRO<128>", []>;
3022 def gi_ro_Xindexed8 :
3023 GIComplexOperandMatcher<s64, "selectAddrModeXRO<8>">,
3024 GIComplexPatternEquiv<ro_Xindexed8>;
3025 def gi_ro_Xindexed16 :
3026 GIComplexOperandMatcher<s64, "selectAddrModeXRO<16>">,
3027 GIComplexPatternEquiv<ro_Xindexed16>;
3028 def gi_ro_Xindexed32 :
3029 GIComplexOperandMatcher<s64, "selectAddrModeXRO<32>">,
3030 GIComplexPatternEquiv<ro_Xindexed32>;
3031 def gi_ro_Xindexed64 :
3032 GIComplexOperandMatcher<s64, "selectAddrModeXRO<64>">,
3033 GIComplexPatternEquiv<ro_Xindexed64>;
3034 def gi_ro_Xindexed128 :
3035 GIComplexOperandMatcher<s64, "selectAddrModeXRO<128>">,
3036 GIComplexPatternEquiv<ro_Xindexed128>;
3038 def ro_Windexed8 : ComplexPattern<i64, 4, "SelectAddrModeWRO<8>", []>;
3039 def ro_Windexed16 : ComplexPattern<i64, 4, "SelectAddrModeWRO<16>", []>;
3040 def ro_Windexed32 : ComplexPattern<i64, 4, "SelectAddrModeWRO<32>", []>;
3041 def ro_Windexed64 : ComplexPattern<i64, 4, "SelectAddrModeWRO<64>", []>;
3042 def ro_Windexed128 : ComplexPattern<i64, 4, "SelectAddrModeWRO<128>", []>;
3044 class MemExtendOperand<string Reg, int Width> : AsmOperandClass {
3045 let Name = "Mem" # Reg # "Extend" # Width;
3046 let PredicateMethod = "isMem" # Reg # "Extend<" # Width # ">";
3047 let RenderMethod = "addMemExtendOperands";
3048 let DiagnosticType = "InvalidMemory" # Reg # "Extend" # Width;
3051 def MemWExtend8Operand : MemExtendOperand<"W", 8> {
3052 // The address "[x0, x1, lsl #0]" actually maps to the variant which performs
3053 // the trivial shift.
3054 let RenderMethod = "addMemExtend8Operands";
3056 def MemWExtend16Operand : MemExtendOperand<"W", 16>;
3057 def MemWExtend32Operand : MemExtendOperand<"W", 32>;
3058 def MemWExtend64Operand : MemExtendOperand<"W", 64>;
3059 def MemWExtend128Operand : MemExtendOperand<"W", 128>;
3061 def MemXExtend8Operand : MemExtendOperand<"X", 8> {
3062 // The address "[x0, x1, lsl #0]" actually maps to the variant which performs
3063 // the trivial shift.
3064 let RenderMethod = "addMemExtend8Operands";
3066 def MemXExtend16Operand : MemExtendOperand<"X", 16>;
3067 def MemXExtend32Operand : MemExtendOperand<"X", 32>;
3068 def MemXExtend64Operand : MemExtendOperand<"X", 64>;
3069 def MemXExtend128Operand : MemExtendOperand<"X", 128>;
3071 class ro_extend<AsmOperandClass ParserClass, string Reg, int Width>
3073 let ParserMatchClass = ParserClass;
3074 let PrintMethod = "printMemExtend<'" # Reg # "', " # Width # ">";
3075 let DecoderMethod = "DecodeMemExtend";
3076 let EncoderMethod = "getMemExtendOpValue";
3077 let MIOperandInfo = (ops i32imm:$signed, i32imm:$doshift);
3080 def ro_Wextend8 : ro_extend<MemWExtend8Operand, "w", 8>;
3081 def ro_Wextend16 : ro_extend<MemWExtend16Operand, "w", 16>;
3082 def ro_Wextend32 : ro_extend<MemWExtend32Operand, "w", 32>;
3083 def ro_Wextend64 : ro_extend<MemWExtend64Operand, "w", 64>;
3084 def ro_Wextend128 : ro_extend<MemWExtend128Operand, "w", 128>;
3086 def ro_Xextend8 : ro_extend<MemXExtend8Operand, "x", 8>;
3087 def ro_Xextend16 : ro_extend<MemXExtend16Operand, "x", 16>;
3088 def ro_Xextend32 : ro_extend<MemXExtend32Operand, "x", 32>;
3089 def ro_Xextend64 : ro_extend<MemXExtend64Operand, "x", 64>;
3090 def ro_Xextend128 : ro_extend<MemXExtend128Operand, "x", 128>;
3092 class ROAddrMode<ComplexPattern windex, ComplexPattern xindex,
3093 Operand wextend, Operand xextend> {
3094 // CodeGen-level pattern covering the entire addressing mode.
3095 ComplexPattern Wpat = windex;
3096 ComplexPattern Xpat = xindex;
3098 // Asm-level Operand covering the valid "uxtw #3" style syntax.
3099 Operand Wext = wextend;
3100 Operand Xext = xextend;
3103 def ro8 : ROAddrMode<ro_Windexed8, ro_Xindexed8, ro_Wextend8, ro_Xextend8>;
3104 def ro16 : ROAddrMode<ro_Windexed16, ro_Xindexed16, ro_Wextend16, ro_Xextend16>;
3105 def ro32 : ROAddrMode<ro_Windexed32, ro_Xindexed32, ro_Wextend32, ro_Xextend32>;
3106 def ro64 : ROAddrMode<ro_Windexed64, ro_Xindexed64, ro_Wextend64, ro_Xextend64>;
3107 def ro128 : ROAddrMode<ro_Windexed128, ro_Xindexed128, ro_Wextend128,
3110 class LoadStore8RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3111 string asm, dag ins, dag outs, list<dag> pat>
3112 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
3117 let Inst{31-30} = sz;
3118 let Inst{29-27} = 0b111;
3120 let Inst{25-24} = 0b00;
3121 let Inst{23-22} = opc;
3123 let Inst{20-16} = Rm;
3124 let Inst{15} = extend{1}; // sign extend Rm?
3126 let Inst{12} = extend{0}; // do shift?
3127 let Inst{11-10} = 0b10;
3132 class ROInstAlias<string asm, RegisterOperand regtype, Instruction INST>
3133 : InstAlias<asm # "\t$Rt, [$Rn, $Rm]",
3134 (INST regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, 0, 0)>;
3136 multiclass Load8RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3137 string asm, ValueType Ty, SDPatternOperator loadop> {
3138 let AddedComplexity = 10 in
3139 def roW : LoadStore8RO<sz, V, opc, regtype, asm,
3141 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend8:$extend),
3142 [(set (Ty regtype:$Rt),
3143 (loadop (ro_Windexed8 GPR64sp:$Rn, GPR32:$Rm,
3144 ro_Wextend8:$extend)))]>,
3145 Sched<[WriteLDIdx, ReadAdrBase]> {
3149 let AddedComplexity = 10 in
3150 def roX : LoadStore8RO<sz, V, opc, regtype, asm,
3152 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend8:$extend),
3153 [(set (Ty regtype:$Rt),
3154 (loadop (ro_Xindexed8 GPR64sp:$Rn, GPR64:$Rm,
3155 ro_Xextend8:$extend)))]>,
3156 Sched<[WriteLDIdx, ReadAdrBase]> {
3160 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3163 multiclass Store8RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3164 string asm, ValueType Ty, SDPatternOperator storeop> {
3165 let AddedComplexity = 10 in
3166 def roW : LoadStore8RO<sz, V, opc, regtype, asm, (outs),
3167 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend8:$extend),
3168 [(storeop (Ty regtype:$Rt),
3169 (ro_Windexed8 GPR64sp:$Rn, GPR32:$Rm,
3170 ro_Wextend8:$extend))]>,
3171 Sched<[WriteSTIdx, ReadAdrBase]> {
3175 let AddedComplexity = 10 in
3176 def roX : LoadStore8RO<sz, V, opc, regtype, asm, (outs),
3177 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend8:$extend),
3178 [(storeop (Ty regtype:$Rt),
3179 (ro_Xindexed8 GPR64sp:$Rn, GPR64:$Rm,
3180 ro_Xextend8:$extend))]>,
3181 Sched<[WriteSTIdx, ReadAdrBase]> {
3185 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3188 class LoadStore16RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3189 string asm, dag ins, dag outs, list<dag> pat>
3190 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
3195 let Inst{31-30} = sz;
3196 let Inst{29-27} = 0b111;
3198 let Inst{25-24} = 0b00;
3199 let Inst{23-22} = opc;
3201 let Inst{20-16} = Rm;
3202 let Inst{15} = extend{1}; // sign extend Rm?
3204 let Inst{12} = extend{0}; // do shift?
3205 let Inst{11-10} = 0b10;
3210 multiclass Load16RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3211 string asm, ValueType Ty, SDPatternOperator loadop> {
3212 let AddedComplexity = 10 in
3213 def roW : LoadStore16RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3214 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend16:$extend),
3215 [(set (Ty regtype:$Rt),
3216 (loadop (ro_Windexed16 GPR64sp:$Rn, GPR32:$Rm,
3217 ro_Wextend16:$extend)))]>,
3218 Sched<[WriteLDIdx, ReadAdrBase]> {
3222 let AddedComplexity = 10 in
3223 def roX : LoadStore16RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3224 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend16:$extend),
3225 [(set (Ty regtype:$Rt),
3226 (loadop (ro_Xindexed16 GPR64sp:$Rn, GPR64:$Rm,
3227 ro_Xextend16:$extend)))]>,
3228 Sched<[WriteLDIdx, ReadAdrBase]> {
3232 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3235 multiclass Store16RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3236 string asm, ValueType Ty, SDPatternOperator storeop> {
3237 let AddedComplexity = 10 in
3238 def roW : LoadStore16RO<sz, V, opc, regtype, asm, (outs),
3239 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend16:$extend),
3240 [(storeop (Ty regtype:$Rt),
3241 (ro_Windexed16 GPR64sp:$Rn, GPR32:$Rm,
3242 ro_Wextend16:$extend))]>,
3243 Sched<[WriteSTIdx, ReadAdrBase]> {
3247 let AddedComplexity = 10 in
3248 def roX : LoadStore16RO<sz, V, opc, regtype, asm, (outs),
3249 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend16:$extend),
3250 [(storeop (Ty regtype:$Rt),
3251 (ro_Xindexed16 GPR64sp:$Rn, GPR64:$Rm,
3252 ro_Xextend16:$extend))]>,
3253 Sched<[WriteSTIdx, ReadAdrBase]> {
3257 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3260 class LoadStore32RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3261 string asm, dag ins, dag outs, list<dag> pat>
3262 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
3267 let Inst{31-30} = sz;
3268 let Inst{29-27} = 0b111;
3270 let Inst{25-24} = 0b00;
3271 let Inst{23-22} = opc;
3273 let Inst{20-16} = Rm;
3274 let Inst{15} = extend{1}; // sign extend Rm?
3276 let Inst{12} = extend{0}; // do shift?
3277 let Inst{11-10} = 0b10;
3282 multiclass Load32RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3283 string asm, ValueType Ty, SDPatternOperator loadop> {
3284 let AddedComplexity = 10 in
3285 def roW : LoadStore32RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3286 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend32:$extend),
3287 [(set (Ty regtype:$Rt),
3288 (loadop (ro_Windexed32 GPR64sp:$Rn, GPR32:$Rm,
3289 ro_Wextend32:$extend)))]>,
3290 Sched<[WriteLDIdx, ReadAdrBase]> {
3294 let AddedComplexity = 10 in
3295 def roX : LoadStore32RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3296 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend32:$extend),
3297 [(set (Ty regtype:$Rt),
3298 (loadop (ro_Xindexed32 GPR64sp:$Rn, GPR64:$Rm,
3299 ro_Xextend32:$extend)))]>,
3300 Sched<[WriteLDIdx, ReadAdrBase]> {
3304 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3307 multiclass Store32RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3308 string asm, ValueType Ty, SDPatternOperator storeop> {
3309 let AddedComplexity = 10 in
3310 def roW : LoadStore32RO<sz, V, opc, regtype, asm, (outs),
3311 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend32:$extend),
3312 [(storeop (Ty regtype:$Rt),
3313 (ro_Windexed32 GPR64sp:$Rn, GPR32:$Rm,
3314 ro_Wextend32:$extend))]>,
3315 Sched<[WriteSTIdx, ReadAdrBase]> {
3319 let AddedComplexity = 10 in
3320 def roX : LoadStore32RO<sz, V, opc, regtype, asm, (outs),
3321 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend32:$extend),
3322 [(storeop (Ty regtype:$Rt),
3323 (ro_Xindexed32 GPR64sp:$Rn, GPR64:$Rm,
3324 ro_Xextend32:$extend))]>,
3325 Sched<[WriteSTIdx, ReadAdrBase]> {
3329 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3332 class LoadStore64RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3333 string asm, dag ins, dag outs, list<dag> pat>
3334 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
3339 let Inst{31-30} = sz;
3340 let Inst{29-27} = 0b111;
3342 let Inst{25-24} = 0b00;
3343 let Inst{23-22} = opc;
3345 let Inst{20-16} = Rm;
3346 let Inst{15} = extend{1}; // sign extend Rm?
3348 let Inst{12} = extend{0}; // do shift?
3349 let Inst{11-10} = 0b10;
3354 multiclass Load64RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3355 string asm, ValueType Ty, SDPatternOperator loadop> {
3356 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
3357 def roW : LoadStore64RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3358 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend),
3359 [(set (Ty regtype:$Rt),
3360 (loadop (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
3361 ro_Wextend64:$extend)))]>,
3362 Sched<[WriteLDIdx, ReadAdrBase]> {
3366 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
3367 def roX : LoadStore64RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3368 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend),
3369 [(set (Ty regtype:$Rt),
3370 (loadop (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
3371 ro_Xextend64:$extend)))]>,
3372 Sched<[WriteLDIdx, ReadAdrBase]> {
3376 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3379 multiclass Store64RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3380 string asm, ValueType Ty, SDPatternOperator storeop> {
3381 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
3382 def roW : LoadStore64RO<sz, V, opc, regtype, asm, (outs),
3383 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend),
3384 [(storeop (Ty regtype:$Rt),
3385 (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
3386 ro_Wextend64:$extend))]>,
3387 Sched<[WriteSTIdx, ReadAdrBase]> {
3391 let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
3392 def roX : LoadStore64RO<sz, V, opc, regtype, asm, (outs),
3393 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend),
3394 [(storeop (Ty regtype:$Rt),
3395 (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
3396 ro_Xextend64:$extend))]>,
3397 Sched<[WriteSTIdx, ReadAdrBase]> {
3401 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3404 class LoadStore128RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3405 string asm, dag ins, dag outs, list<dag> pat>
3406 : I<ins, outs, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat> {
3411 let Inst{31-30} = sz;
3412 let Inst{29-27} = 0b111;
3414 let Inst{25-24} = 0b00;
3415 let Inst{23-22} = opc;
3417 let Inst{20-16} = Rm;
3418 let Inst{15} = extend{1}; // sign extend Rm?
3420 let Inst{12} = extend{0}; // do shift?
3421 let Inst{11-10} = 0b10;
3426 multiclass Load128RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3427 string asm, ValueType Ty, SDPatternOperator loadop> {
3428 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
3429 def roW : LoadStore128RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3430 (ins GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend),
3431 [(set (Ty regtype:$Rt),
3432 (loadop (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
3433 ro_Wextend128:$extend)))]>,
3434 Sched<[WriteLDIdx, ReadAdrBase]> {
3438 let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
3439 def roX : LoadStore128RO<sz, V, opc, regtype, asm, (outs regtype:$Rt),
3440 (ins GPR64sp:$Rn, GPR64:$Rm, ro_Xextend128:$extend),
3441 [(set (Ty regtype:$Rt),
3442 (loadop (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
3443 ro_Xextend128:$extend)))]>,
3444 Sched<[WriteLDIdx, ReadAdrBase]> {
3448 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3451 multiclass Store128RO<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3452 string asm, ValueType Ty, SDPatternOperator storeop> {
3453 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
3454 def roW : LoadStore128RO<sz, V, opc, regtype, asm, (outs),
3455 (ins regtype:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend),
3457 Sched<[WriteSTIdx, ReadAdrBase]> {
3461 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
3462 def roX : LoadStore128RO<sz, V, opc, regtype, asm, (outs),
3463 (ins regtype:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend128:$extend),
3465 Sched<[WriteSTIdx, ReadAdrBase]> {
3469 def : ROInstAlias<asm, regtype, !cast<Instruction>(NAME # "roX")>;
3472 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
3473 class BasePrefetchRO<bits<2> sz, bit V, bits<2> opc, dag outs, dag ins,
3474 string asm, list<dag> pat>
3475 : I<outs, ins, asm, "\t$Rt, [$Rn, $Rm, $extend]", "", pat>,
3481 let Inst{31-30} = sz;
3482 let Inst{29-27} = 0b111;
3484 let Inst{25-24} = 0b00;
3485 let Inst{23-22} = opc;
3487 let Inst{20-16} = Rm;
3488 let Inst{15} = extend{1}; // sign extend Rm?
3490 let Inst{12} = extend{0}; // do shift?
3491 let Inst{11-10} = 0b10;
3496 multiclass PrefetchRO<bits<2> sz, bit V, bits<2> opc, string asm> {
3497 def roW : BasePrefetchRO<sz, V, opc, (outs),
3498 (ins prfop:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend),
3499 asm, [(AArch64Prefetch imm:$Rt,
3500 (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
3501 ro_Wextend64:$extend))]> {
3505 def roX : BasePrefetchRO<sz, V, opc, (outs),
3506 (ins prfop:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend),
3507 asm, [(AArch64Prefetch imm:$Rt,
3508 (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
3509 ro_Xextend64:$extend))]> {
3513 def : InstAlias<"prfm $Rt, [$Rn, $Rm]",
3514 (!cast<Instruction>(NAME # "roX") prfop:$Rt,
3515 GPR64sp:$Rn, GPR64:$Rm, 0, 0)>;
3519 // Load/store unscaled immediate
3522 def am_unscaled8 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled8", []>;
3523 def am_unscaled16 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled16", []>;
3524 def am_unscaled32 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled32", []>;
3525 def am_unscaled64 : ComplexPattern<i64, 2, "SelectAddrModeUnscaled64", []>;
3526 def am_unscaled128 :ComplexPattern<i64, 2, "SelectAddrModeUnscaled128", []>;
3528 def gi_am_unscaled8 :
3529 GIComplexOperandMatcher<s64, "selectAddrModeUnscaled8">,
3530 GIComplexPatternEquiv<am_unscaled8>;
3531 def gi_am_unscaled16 :
3532 GIComplexOperandMatcher<s64, "selectAddrModeUnscaled16">,
3533 GIComplexPatternEquiv<am_unscaled16>;
3534 def gi_am_unscaled32 :
3535 GIComplexOperandMatcher<s64, "selectAddrModeUnscaled32">,
3536 GIComplexPatternEquiv<am_unscaled32>;
3537 def gi_am_unscaled64 :
3538 GIComplexOperandMatcher<s64, "selectAddrModeUnscaled64">,
3539 GIComplexPatternEquiv<am_unscaled64>;
3540 def gi_am_unscaled128 :
3541 GIComplexOperandMatcher<s64, "selectAddrModeUnscaled128">,
3542 GIComplexPatternEquiv<am_unscaled128>;
3545 class BaseLoadStoreUnscale<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
3546 string asm, list<dag> pattern>
3547 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]", "", pattern> {
3551 let Inst{31-30} = sz;
3552 let Inst{29-27} = 0b111;
3554 let Inst{25-24} = 0b00;
3555 let Inst{23-22} = opc;
3557 let Inst{20-12} = offset;
3558 let Inst{11-10} = 0b00;
3562 let DecoderMethod = "DecodeSignedLdStInstruction";
3565 // Armv8.4 LDAPR & STLR with Immediate Offset instruction
3566 multiclass BaseLoadUnscaleV84<string asm, bits<2> sz, bits<2> opc,
3567 RegisterOperand regtype > {
3568 def i : BaseLoadStoreUnscale<sz, 0, opc, (outs regtype:$Rt),
3569 (ins GPR64sp:$Rn, simm9:$offset), asm, []>,
3574 def : InstAlias<asm # "\t$Rt, [$Rn]",
3575 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
3578 multiclass BaseStoreUnscaleV84<string asm, bits<2> sz, bits<2> opc,
3579 RegisterOperand regtype > {
3580 def i : BaseLoadStoreUnscale<sz, 0, opc, (outs),
3581 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3587 def : InstAlias<asm # "\t$Rt, [$Rn]",
3588 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
3591 multiclass LoadUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3592 string asm, list<dag> pattern> {
3593 let AddedComplexity = 1 in // try this before LoadUI
3594 def i : BaseLoadStoreUnscale<sz, V, opc, (outs regtype:$Rt),
3595 (ins GPR64sp:$Rn, simm9:$offset), asm, pattern>,
3598 def : InstAlias<asm # "\t$Rt, [$Rn]",
3599 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
3602 multiclass StoreUnscaled<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3603 string asm, list<dag> pattern> {
3604 let AddedComplexity = 1 in // try this before StoreUI
3605 def i : BaseLoadStoreUnscale<sz, V, opc, (outs),
3606 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3610 def : InstAlias<asm # "\t$Rt, [$Rn]",
3611 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
3614 multiclass PrefetchUnscaled<bits<2> sz, bit V, bits<2> opc, string asm,
3616 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
3617 def i : BaseLoadStoreUnscale<sz, V, opc, (outs),
3618 (ins prfop:$Rt, GPR64sp:$Rn, simm9:$offset),
3622 def : InstAlias<asm # "\t$Rt, [$Rn]",
3623 (!cast<Instruction>(NAME # "i") prfop:$Rt, GPR64sp:$Rn, 0)>;
3627 // Load/store unscaled immediate, unprivileged
3630 class BaseLoadStoreUnprivileged<bits<2> sz, bit V, bits<2> opc,
3631 dag oops, dag iops, string asm>
3632 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]", "", []> {
3636 let Inst{31-30} = sz;
3637 let Inst{29-27} = 0b111;
3639 let Inst{25-24} = 0b00;
3640 let Inst{23-22} = opc;
3642 let Inst{20-12} = offset;
3643 let Inst{11-10} = 0b10;
3647 let DecoderMethod = "DecodeSignedLdStInstruction";
3650 multiclass LoadUnprivileged<bits<2> sz, bit V, bits<2> opc,
3651 RegisterClass regtype, string asm> {
3652 let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in
3653 def i : BaseLoadStoreUnprivileged<sz, V, opc, (outs regtype:$Rt),
3654 (ins GPR64sp:$Rn, simm9:$offset), asm>,
3657 def : InstAlias<asm # "\t$Rt, [$Rn]",
3658 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
3661 multiclass StoreUnprivileged<bits<2> sz, bit V, bits<2> opc,
3662 RegisterClass regtype, string asm> {
3663 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
3664 def i : BaseLoadStoreUnprivileged<sz, V, opc, (outs),
3665 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3669 def : InstAlias<asm # "\t$Rt, [$Rn]",
3670 (!cast<Instruction>(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>;
3674 // Load/store pre-indexed
3677 class BaseLoadStorePreIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
3678 string asm, string cstr, list<dag> pat>
3679 : I<oops, iops, asm, "\t$Rt, [$Rn, $offset]!", cstr, pat> {
3683 let Inst{31-30} = sz;
3684 let Inst{29-27} = 0b111;
3686 let Inst{25-24} = 0;
3687 let Inst{23-22} = opc;
3689 let Inst{20-12} = offset;
3690 let Inst{11-10} = 0b11;
3694 let DecoderMethod = "DecodeSignedLdStInstruction";
3697 let hasSideEffects = 0 in {
3698 let mayStore = 0, mayLoad = 1 in
3699 class LoadPreIdx<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3701 : BaseLoadStorePreIdx<sz, V, opc,
3702 (outs GPR64sp:$wback, regtype:$Rt),
3703 (ins GPR64sp:$Rn, simm9:$offset), asm,
3704 "$Rn = $wback,@earlyclobber $wback", []>,
3705 Sched<[WriteLD, WriteAdr]>;
3707 let mayStore = 1, mayLoad = 0 in
3708 class StorePreIdx<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3709 string asm, SDPatternOperator storeop, ValueType Ty>
3710 : BaseLoadStorePreIdx<sz, V, opc,
3711 (outs GPR64sp:$wback),
3712 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3713 asm, "$Rn = $wback,@earlyclobber $wback",
3714 [(set GPR64sp:$wback,
3715 (storeop (Ty regtype:$Rt), GPR64sp:$Rn, simm9:$offset))]>,
3716 Sched<[WriteAdr, WriteST]>;
3717 } // hasSideEffects = 0
3720 // Load/store post-indexed
3723 class BaseLoadStorePostIdx<bits<2> sz, bit V, bits<2> opc, dag oops, dag iops,
3724 string asm, string cstr, list<dag> pat>
3725 : I<oops, iops, asm, "\t$Rt, [$Rn], $offset", cstr, pat> {
3729 let Inst{31-30} = sz;
3730 let Inst{29-27} = 0b111;
3732 let Inst{25-24} = 0b00;
3733 let Inst{23-22} = opc;
3735 let Inst{20-12} = offset;
3736 let Inst{11-10} = 0b01;
3740 let DecoderMethod = "DecodeSignedLdStInstruction";
3743 let hasSideEffects = 0 in {
3744 let mayStore = 0, mayLoad = 1 in
3745 class LoadPostIdx<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3747 : BaseLoadStorePostIdx<sz, V, opc,
3748 (outs GPR64sp:$wback, regtype:$Rt),
3749 (ins GPR64sp:$Rn, simm9:$offset),
3750 asm, "$Rn = $wback,@earlyclobber $wback", []>,
3751 Sched<[WriteLD, WriteAdr]>;
3753 let mayStore = 1, mayLoad = 0 in
3754 class StorePostIdx<bits<2> sz, bit V, bits<2> opc, RegisterOperand regtype,
3755 string asm, SDPatternOperator storeop, ValueType Ty>
3756 : BaseLoadStorePostIdx<sz, V, opc,
3757 (outs GPR64sp:$wback),
3758 (ins regtype:$Rt, GPR64sp:$Rn, simm9:$offset),
3759 asm, "$Rn = $wback,@earlyclobber $wback",
3760 [(set GPR64sp:$wback,
3761 (storeop (Ty regtype:$Rt), GPR64sp:$Rn, simm9:$offset))]>,
3762 Sched<[WriteAdr, WriteST]>;
3763 } // hasSideEffects = 0
3770 // (indexed, offset)
3772 class BaseLoadStorePairOffset<bits<2> opc, bit V, bit L, dag oops, dag iops,
3774 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn, $offset]", "", []> {
3779 let Inst{31-30} = opc;
3780 let Inst{29-27} = 0b101;
3782 let Inst{25-23} = 0b010;
3784 let Inst{21-15} = offset;
3785 let Inst{14-10} = Rt2;
3789 let DecoderMethod = "DecodePairLdStInstruction";
3792 multiclass LoadPairOffset<bits<2> opc, bit V, RegisterOperand regtype,
3793 Operand indextype, string asm> {
3794 let hasSideEffects = 0, mayStore = 0, mayLoad = 1 in
3795 def i : BaseLoadStorePairOffset<opc, V, 1,
3796 (outs regtype:$Rt, regtype:$Rt2),
3797 (ins GPR64sp:$Rn, indextype:$offset), asm>,
3798 Sched<[WriteLD, WriteLDHi]>;
3800 def : InstAlias<asm # "\t$Rt, $Rt2, [$Rn]",
3801 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3806 multiclass StorePairOffset<bits<2> opc, bit V, RegisterOperand regtype,
3807 Operand indextype, string asm> {
3808 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
3809 def i : BaseLoadStorePairOffset<opc, V, 0, (outs),
3810 (ins regtype:$Rt, regtype:$Rt2,
3811 GPR64sp:$Rn, indextype:$offset),
3815 def : InstAlias<asm # "\t$Rt, $Rt2, [$Rn]",
3816 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3821 class BaseLoadStorePairPreIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
3823 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn, $offset]!", "$Rn = $wback,@earlyclobber $wback", []> {
3828 let Inst{31-30} = opc;
3829 let Inst{29-27} = 0b101;
3831 let Inst{25-23} = 0b011;
3833 let Inst{21-15} = offset;
3834 let Inst{14-10} = Rt2;
3838 let DecoderMethod = "DecodePairLdStInstruction";
3841 let hasSideEffects = 0 in {
3842 let mayStore = 0, mayLoad = 1 in
3843 class LoadPairPreIdx<bits<2> opc, bit V, RegisterOperand regtype,
3844 Operand indextype, string asm>
3845 : BaseLoadStorePairPreIdx<opc, V, 1,
3846 (outs GPR64sp:$wback, regtype:$Rt, regtype:$Rt2),
3847 (ins GPR64sp:$Rn, indextype:$offset), asm>,
3848 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
3850 let mayStore = 1, mayLoad = 0 in
3851 class StorePairPreIdx<bits<2> opc, bit V, RegisterOperand regtype,
3852 Operand indextype, string asm>
3853 : BaseLoadStorePairPreIdx<opc, V, 0, (outs GPR64sp:$wback),
3854 (ins regtype:$Rt, regtype:$Rt2,
3855 GPR64sp:$Rn, indextype:$offset),
3857 Sched<[WriteAdr, WriteSTP]>;
3858 } // hasSideEffects = 0
3862 class BaseLoadStorePairPostIdx<bits<2> opc, bit V, bit L, dag oops, dag iops,
3864 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn], $offset", "$Rn = $wback,@earlyclobber $wback", []> {
3869 let Inst{31-30} = opc;
3870 let Inst{29-27} = 0b101;
3872 let Inst{25-23} = 0b001;
3874 let Inst{21-15} = offset;
3875 let Inst{14-10} = Rt2;
3879 let DecoderMethod = "DecodePairLdStInstruction";
3882 let hasSideEffects = 0 in {
3883 let mayStore = 0, mayLoad = 1 in
3884 class LoadPairPostIdx<bits<2> opc, bit V, RegisterOperand regtype,
3885 Operand idxtype, string asm>
3886 : BaseLoadStorePairPostIdx<opc, V, 1,
3887 (outs GPR64sp:$wback, regtype:$Rt, regtype:$Rt2),
3888 (ins GPR64sp:$Rn, idxtype:$offset), asm>,
3889 Sched<[WriteLD, WriteLDHi, WriteAdr]>;
3891 let mayStore = 1, mayLoad = 0 in
3892 class StorePairPostIdx<bits<2> opc, bit V, RegisterOperand regtype,
3893 Operand idxtype, string asm>
3894 : BaseLoadStorePairPostIdx<opc, V, 0, (outs GPR64sp:$wback),
3895 (ins regtype:$Rt, regtype:$Rt2,
3896 GPR64sp:$Rn, idxtype:$offset),
3898 Sched<[WriteAdr, WriteSTP]>;
3899 } // hasSideEffects = 0
3903 class BaseLoadStorePairNoAlloc<bits<2> opc, bit V, bit L, dag oops, dag iops,
3905 : I<oops, iops, asm, "\t$Rt, $Rt2, [$Rn, $offset]", "", []> {
3910 let Inst{31-30} = opc;
3911 let Inst{29-27} = 0b101;
3913 let Inst{25-23} = 0b000;
3915 let Inst{21-15} = offset;
3916 let Inst{14-10} = Rt2;
3920 let DecoderMethod = "DecodePairLdStInstruction";
3923 multiclass LoadPairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3924 Operand indextype, string asm> {
3925 let hasSideEffects = 0, mayStore = 0, mayLoad = 1 in
3926 def i : BaseLoadStorePairNoAlloc<opc, V, 1,
3927 (outs regtype:$Rt, regtype:$Rt2),
3928 (ins GPR64sp:$Rn, indextype:$offset), asm>,
3929 Sched<[WriteLD, WriteLDHi]>;
3932 def : InstAlias<asm # "\t$Rt, $Rt2, [$Rn]",
3933 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3937 multiclass StorePairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
3938 Operand indextype, string asm> {
3939 let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in
3940 def i : BaseLoadStorePairNoAlloc<opc, V, 0, (outs),
3941 (ins regtype:$Rt, regtype:$Rt2,
3942 GPR64sp:$Rn, indextype:$offset),
3946 def : InstAlias<asm # "\t$Rt, $Rt2, [$Rn]",
3947 (!cast<Instruction>(NAME # "i") regtype:$Rt, regtype:$Rt2,
3952 // Load/store exclusive
3955 // True exclusive operations write to and/or read from the system's exclusive
3956 // monitors, which as far as a compiler is concerned can be modelled as a
3957 // random shared memory address. Hence LoadExclusive mayStore.
3959 // Since these instructions have the undefined register bits set to 1 in
3960 // their canonical form, we need a post encoder method to set those bits
3961 // to 1 when encoding these instructions. We do this using the
3962 // fixLoadStoreExclusive function. This function has template parameters:
3964 // fixLoadStoreExclusive<int hasRs, int hasRt2>
3966 // hasRs indicates that the instruction uses the Rs field, so we won't set
3967 // it to 1 (and the same for Rt2). We don't need template parameters for
3968 // the other register fields since Rt and Rn are always used.
3970 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
3971 class BaseLoadStoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3972 dag oops, dag iops, string asm, string operands>
3973 : I<oops, iops, asm, operands, "", []> {
3974 let Inst{31-30} = sz;
3975 let Inst{29-24} = 0b001000;
3981 let DecoderMethod = "DecodeExclusiveLdStInstruction";
3984 // Neither Rs nor Rt2 operands.
3985 class LoadStoreExclusiveSimple<bits<2> sz, bit o2, bit L, bit o1, bit o0,
3986 dag oops, dag iops, string asm, string operands>
3987 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, oops, iops, asm, operands> {
3990 let Inst{20-16} = 0b11111;
3991 let Unpredictable{20-16} = 0b11111;
3992 let Inst{14-10} = 0b11111;
3993 let Unpredictable{14-10} = 0b11111;
3997 let PostEncoderMethod = "fixLoadStoreExclusive<0,0>";
4000 // Simple load acquires don't set the exclusive monitor
4001 let mayLoad = 1, mayStore = 0 in
4002 class LoadAcquire<bits<2> sz, bit o2, bit L, bit o1, bit o0,
4003 RegisterClass regtype, string asm>
4004 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
4005 (ins GPR64sp0:$Rn), asm, "\t$Rt, [$Rn]">,
4008 class LoadExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
4009 RegisterClass regtype, string asm>
4010 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs regtype:$Rt),
4011 (ins GPR64sp0:$Rn), asm, "\t$Rt, [$Rn]">,
4014 class LoadExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
4015 RegisterClass regtype, string asm>
4016 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
4017 (outs regtype:$Rt, regtype:$Rt2),
4018 (ins GPR64sp0:$Rn), asm,
4019 "\t$Rt, $Rt2, [$Rn]">,
4020 Sched<[WriteLD, WriteLDHi]> {
4024 let Inst{14-10} = Rt2;
4028 let PostEncoderMethod = "fixLoadStoreExclusive<0,1>";
4031 // Simple store release operations do not check the exclusive monitor.
4032 let mayLoad = 0, mayStore = 1 in
4033 class StoreRelease<bits<2> sz, bit o2, bit L, bit o1, bit o0,
4034 RegisterClass regtype, string asm>
4035 : LoadStoreExclusiveSimple<sz, o2, L, o1, o0, (outs),
4036 (ins regtype:$Rt, GPR64sp0:$Rn),
4037 asm, "\t$Rt, [$Rn]">,
4040 let mayLoad = 1, mayStore = 1 in
4041 class StoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
4042 RegisterClass regtype, string asm>
4043 : BaseLoadStoreExclusive<sz, o2, L, o1, o0, (outs GPR32:$Ws),
4044 (ins regtype:$Rt, GPR64sp0:$Rn),
4045 asm, "\t$Ws, $Rt, [$Rn]">,
4050 let Inst{20-16} = Ws;
4054 let Constraints = "@earlyclobber $Ws";
4055 let PostEncoderMethod = "fixLoadStoreExclusive<1,0>";
4058 class StoreExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
4059 RegisterClass regtype, string asm>
4060 : BaseLoadStoreExclusive<sz, o2, L, o1, o0,
4062 (ins regtype:$Rt, regtype:$Rt2, GPR64sp0:$Rn),
4063 asm, "\t$Ws, $Rt, $Rt2, [$Rn]">,
4069 let Inst{20-16} = Ws;
4070 let Inst{14-10} = Rt2;
4074 let Constraints = "@earlyclobber $Ws";
4077 // Armv8.5-A Memory Tagging Extension
4078 class BaseMemTag<bits<2> opc1, bits<2> opc2, string asm_insn,
4079 string asm_opnds, string cstr, dag oops, dag iops>
4080 : I<oops, iops, asm_insn, asm_opnds, cstr, []>,
4084 let Inst{31-24} = 0b11011001;
4085 let Inst{23-22} = opc1;
4087 // Inst{20-12} defined by subclass
4088 let Inst{11-10} = opc2;
4090 // Inst{4-0} defined by subclass
4093 class MemTagVector<bit Load, string asm_insn, string asm_opnds,
4095 : BaseMemTag<{0b1, Load}, 0b00, asm_insn, asm_opnds,
4099 let Inst{20-12} = 0b000000000;
4105 class MemTagLoad<string asm_insn, string asm_opnds>
4106 : BaseMemTag<0b01, 0b00, asm_insn, asm_opnds, "$Rt = $wback",
4107 (outs GPR64:$wback),
4108 (ins GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)> {
4112 let Inst{20-12} = offset;
4118 class BaseMemTagStore<bits<2> opc1, bits<2> opc2, string asm_insn,
4119 string asm_opnds, string cstr, dag oops, dag iops>
4120 : BaseMemTag<opc1, opc2, asm_insn, asm_opnds, cstr, oops, iops> {
4124 let Inst{20-12} = offset;
4130 multiclass MemTagStore<bits<2> opc1, string insn> {
4132 BaseMemTagStore<opc1, 0b10, insn, "\t$Rt, [$Rn, $offset]", "",
4133 (outs), (ins GPR64sp:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
4135 BaseMemTagStore<opc1, 0b11, insn, "\t$Rt, [$Rn, $offset]!",
4137 (outs GPR64sp:$wback),
4138 (ins GPR64sp:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
4140 BaseMemTagStore<opc1, 0b01, insn, "\t$Rt, [$Rn], $offset",
4142 (outs GPR64sp:$wback),
4143 (ins GPR64sp:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
4145 def : InstAlias<insn # "\t$Rt, [$Rn]",
4146 (!cast<Instruction>(NAME # "Offset") GPR64sp:$Rt, GPR64sp:$Rn, 0)>;
4150 // Exception generation
4153 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
4154 class ExceptionGeneration<bits<3> op1, bits<2> ll, string asm>
4155 : I<(outs), (ins i32_imm0_65535:$imm), asm, "\t$imm", "", []>,
4158 let Inst{31-24} = 0b11010100;
4159 let Inst{23-21} = op1;
4160 let Inst{20-5} = imm;
4161 let Inst{4-2} = 0b000;
4166 // UDF : Permanently UNDEFINED instructions. Format: Opc = 0x0000, 16 bit imm.
4168 let hasSideEffects = 1, isTrap = 1, mayLoad = 0, mayStore = 0 in {
4169 class UDFType<bits<16> opc, string asm>
4170 : I<(outs), (ins uimm16:$imm),
4171 asm, "\t$imm", "", []>,
4174 let Inst{31-16} = opc;
4175 let Inst{15-0} = imm;
4178 let Predicates = [HasFPARMv8] in {
4181 // Floating point to integer conversion
4184 class BaseFPToIntegerUnscaled<bits<2> type, bits<2> rmode, bits<3> opcode,
4185 RegisterClass srcType, RegisterClass dstType,
4186 string asm, list<dag> pattern>
4187 : I<(outs dstType:$Rd), (ins srcType:$Rn),
4188 asm, "\t$Rd, $Rn", "", pattern>,
4189 Sched<[WriteFCvt]> {
4192 let Inst{30-29} = 0b00;
4193 let Inst{28-24} = 0b11110;
4194 let Inst{23-22} = type;
4196 let Inst{20-19} = rmode;
4197 let Inst{18-16} = opcode;
4198 let Inst{15-10} = 0;
4203 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4204 class BaseFPToInteger<bits<2> type, bits<2> rmode, bits<3> opcode,
4205 RegisterClass srcType, RegisterClass dstType,
4206 Operand immType, string asm, list<dag> pattern>
4207 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
4208 asm, "\t$Rd, $Rn, $scale", "", pattern>,
4209 Sched<[WriteFCvt]> {
4213 let Inst{30-29} = 0b00;
4214 let Inst{28-24} = 0b11110;
4215 let Inst{23-22} = type;
4217 let Inst{20-19} = rmode;
4218 let Inst{18-16} = opcode;
4219 let Inst{15-10} = scale;
4224 multiclass FPToIntegerUnscaled<bits<2> rmode, bits<3> opcode, string asm,
4225 SDPatternOperator OpN> {
4226 // Unscaled half-precision to 32-bit
4227 def UWHr : BaseFPToIntegerUnscaled<0b11, rmode, opcode, FPR16, GPR32, asm,
4228 [(set GPR32:$Rd, (OpN FPR16:$Rn))]> {
4229 let Inst{31} = 0; // 32-bit GPR flag
4230 let Predicates = [HasFullFP16];
4233 // Unscaled half-precision to 64-bit
4234 def UXHr : BaseFPToIntegerUnscaled<0b11, rmode, opcode, FPR16, GPR64, asm,
4235 [(set GPR64:$Rd, (OpN FPR16:$Rn))]> {
4236 let Inst{31} = 1; // 64-bit GPR flag
4237 let Predicates = [HasFullFP16];
4240 // Unscaled single-precision to 32-bit
4241 def UWSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR32, asm,
4242 [(set GPR32:$Rd, (OpN FPR32:$Rn))]> {
4243 let Inst{31} = 0; // 32-bit GPR flag
4246 // Unscaled single-precision to 64-bit
4247 def UXSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR64, asm,
4248 [(set GPR64:$Rd, (OpN FPR32:$Rn))]> {
4249 let Inst{31} = 1; // 64-bit GPR flag
4252 // Unscaled double-precision to 32-bit
4253 def UWDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR32, asm,
4254 [(set GPR32:$Rd, (OpN (f64 FPR64:$Rn)))]> {
4255 let Inst{31} = 0; // 32-bit GPR flag
4258 // Unscaled double-precision to 64-bit
4259 def UXDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR64, asm,
4260 [(set GPR64:$Rd, (OpN (f64 FPR64:$Rn)))]> {
4261 let Inst{31} = 1; // 64-bit GPR flag
4265 multiclass FPToIntegerScaled<bits<2> rmode, bits<3> opcode, string asm,
4266 SDPatternOperator OpN> {
4267 // Scaled half-precision to 32-bit
4268 def SWHri : BaseFPToInteger<0b11, rmode, opcode, FPR16, GPR32,
4269 fixedpoint_f16_i32, asm,
4270 [(set GPR32:$Rd, (OpN (fmul FPR16:$Rn,
4271 fixedpoint_f16_i32:$scale)))]> {
4272 let Inst{31} = 0; // 32-bit GPR flag
4274 let Predicates = [HasFullFP16];
4277 // Scaled half-precision to 64-bit
4278 def SXHri : BaseFPToInteger<0b11, rmode, opcode, FPR16, GPR64,
4279 fixedpoint_f16_i64, asm,
4280 [(set GPR64:$Rd, (OpN (fmul FPR16:$Rn,
4281 fixedpoint_f16_i64:$scale)))]> {
4282 let Inst{31} = 1; // 64-bit GPR flag
4283 let Predicates = [HasFullFP16];
4286 // Scaled single-precision to 32-bit
4287 def SWSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR32,
4288 fixedpoint_f32_i32, asm,
4289 [(set GPR32:$Rd, (OpN (fmul FPR32:$Rn,
4290 fixedpoint_f32_i32:$scale)))]> {
4291 let Inst{31} = 0; // 32-bit GPR flag
4295 // Scaled single-precision to 64-bit
4296 def SXSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR64,
4297 fixedpoint_f32_i64, asm,
4298 [(set GPR64:$Rd, (OpN (fmul FPR32:$Rn,
4299 fixedpoint_f32_i64:$scale)))]> {
4300 let Inst{31} = 1; // 64-bit GPR flag
4303 // Scaled double-precision to 32-bit
4304 def SWDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR32,
4305 fixedpoint_f64_i32, asm,
4306 [(set GPR32:$Rd, (OpN (fmul FPR64:$Rn,
4307 fixedpoint_f64_i32:$scale)))]> {
4308 let Inst{31} = 0; // 32-bit GPR flag
4312 // Scaled double-precision to 64-bit
4313 def SXDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR64,
4314 fixedpoint_f64_i64, asm,
4315 [(set GPR64:$Rd, (OpN (fmul FPR64:$Rn,
4316 fixedpoint_f64_i64:$scale)))]> {
4317 let Inst{31} = 1; // 64-bit GPR flag
4322 // Integer to floating point conversion
4325 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
4326 class BaseIntegerToFP<bit isUnsigned,
4327 RegisterClass srcType, RegisterClass dstType,
4328 Operand immType, string asm, list<dag> pattern>
4329 : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale),
4330 asm, "\t$Rd, $Rn, $scale", "", pattern>,
4331 Sched<[WriteFCvt]> {
4335 let Inst{30-24} = 0b0011110;
4336 let Inst{21-17} = 0b00001;
4337 let Inst{16} = isUnsigned;
4338 let Inst{15-10} = scale;
4343 class BaseIntegerToFPUnscaled<bit isUnsigned,
4344 RegisterClass srcType, RegisterClass dstType,
4345 ValueType dvt, string asm, SDNode node>
4346 : I<(outs dstType:$Rd), (ins srcType:$Rn),
4347 asm, "\t$Rd, $Rn", "", [(set (dvt dstType:$Rd), (node srcType:$Rn))]>,
4348 Sched<[WriteFCvt]> {
4352 let Inst{30-24} = 0b0011110;
4353 let Inst{21-17} = 0b10001;
4354 let Inst{16} = isUnsigned;
4355 let Inst{15-10} = 0b000000;
4360 multiclass IntegerToFP<bit isUnsigned, string asm, SDNode node> {
4362 def UWHri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR16, f16, asm, node> {
4363 let Inst{31} = 0; // 32-bit GPR flag
4364 let Inst{23-22} = 0b11; // 16-bit FPR flag
4365 let Predicates = [HasFullFP16];
4368 def UWSri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR32, f32, asm, node> {
4369 let Inst{31} = 0; // 32-bit GPR flag
4370 let Inst{23-22} = 0b00; // 32-bit FPR flag
4373 def UWDri: BaseIntegerToFPUnscaled<isUnsigned, GPR32, FPR64, f64, asm, node> {
4374 let Inst{31} = 0; // 32-bit GPR flag
4375 let Inst{23-22} = 0b01; // 64-bit FPR flag
4378 def UXHri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR16, f16, asm, node> {
4379 let Inst{31} = 1; // 64-bit GPR flag
4380 let Inst{23-22} = 0b11; // 16-bit FPR flag
4381 let Predicates = [HasFullFP16];
4384 def UXSri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR32, f32, asm, node> {
4385 let Inst{31} = 1; // 64-bit GPR flag
4386 let Inst{23-22} = 0b00; // 32-bit FPR flag
4389 def UXDri: BaseIntegerToFPUnscaled<isUnsigned, GPR64, FPR64, f64, asm, node> {
4390 let Inst{31} = 1; // 64-bit GPR flag
4391 let Inst{23-22} = 0b01; // 64-bit FPR flag
4395 def SWHri: BaseIntegerToFP<isUnsigned, GPR32, FPR16, fixedpoint_f16_i32, asm,
4397 (fdiv (node GPR32:$Rn),
4398 fixedpoint_f16_i32:$scale))]> {
4399 let Inst{31} = 0; // 32-bit GPR flag
4400 let Inst{23-22} = 0b11; // 16-bit FPR flag
4402 let Predicates = [HasFullFP16];
4405 def SWSri: BaseIntegerToFP<isUnsigned, GPR32, FPR32, fixedpoint_f32_i32, asm,
4407 (fdiv (node GPR32:$Rn),
4408 fixedpoint_f32_i32:$scale))]> {
4409 let Inst{31} = 0; // 32-bit GPR flag
4410 let Inst{23-22} = 0b00; // 32-bit FPR flag
4414 def SWDri: BaseIntegerToFP<isUnsigned, GPR32, FPR64, fixedpoint_f64_i32, asm,
4416 (fdiv (node GPR32:$Rn),
4417 fixedpoint_f64_i32:$scale))]> {
4418 let Inst{31} = 0; // 32-bit GPR flag
4419 let Inst{23-22} = 0b01; // 64-bit FPR flag
4423 def SXHri: BaseIntegerToFP<isUnsigned, GPR64, FPR16, fixedpoint_f16_i64, asm,
4425 (fdiv (node GPR64:$Rn),
4426 fixedpoint_f16_i64:$scale))]> {
4427 let Inst{31} = 1; // 64-bit GPR flag
4428 let Inst{23-22} = 0b11; // 16-bit FPR flag
4429 let Predicates = [HasFullFP16];
4432 def SXSri: BaseIntegerToFP<isUnsigned, GPR64, FPR32, fixedpoint_f32_i64, asm,
4434 (fdiv (node GPR64:$Rn),
4435 fixedpoint_f32_i64:$scale))]> {
4436 let Inst{31} = 1; // 64-bit GPR flag
4437 let Inst{23-22} = 0b00; // 32-bit FPR flag
4440 def SXDri: BaseIntegerToFP<isUnsigned, GPR64, FPR64, fixedpoint_f64_i64, asm,
4442 (fdiv (node GPR64:$Rn),
4443 fixedpoint_f64_i64:$scale))]> {
4444 let Inst{31} = 1; // 64-bit GPR flag
4445 let Inst{23-22} = 0b01; // 64-bit FPR flag
4450 // Unscaled integer <-> floating point conversion (i.e. FMOV)
4453 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4454 class BaseUnscaledConversion<bits<2> rmode, bits<3> opcode,
4455 RegisterClass srcType, RegisterClass dstType,
4457 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "",
4458 // We use COPY_TO_REGCLASS for these bitconvert operations.
4459 // copyPhysReg() expands the resultant COPY instructions after
4460 // regalloc is done. This gives greater freedom for the allocator
4461 // and related passes (coalescing, copy propagation, et. al.) to
4462 // be more effective.
4463 [/*(set (dvt dstType:$Rd), (bitconvert (svt srcType:$Rn)))*/]>,
4464 Sched<[WriteFCopy]> {
4467 let Inst{30-24} = 0b0011110;
4469 let Inst{20-19} = rmode;
4470 let Inst{18-16} = opcode;
4471 let Inst{15-10} = 0b000000;
4476 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4477 class BaseUnscaledConversionToHigh<bits<2> rmode, bits<3> opcode,
4478 RegisterClass srcType, RegisterOperand dstType, string asm,
4480 : I<(outs dstType:$Rd), (ins srcType:$Rn, VectorIndex1:$idx), asm,
4481 "{\t$Rd"#kind#"$idx, $Rn|"#kind#"\t$Rd$idx, $Rn}", "", []>,
4482 Sched<[WriteFCopy]> {
4485 let Inst{30-23} = 0b00111101;
4487 let Inst{20-19} = rmode;
4488 let Inst{18-16} = opcode;
4489 let Inst{15-10} = 0b000000;
4493 let DecoderMethod = "DecodeFMOVLaneInstruction";
4496 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4497 class BaseUnscaledConversionFromHigh<bits<2> rmode, bits<3> opcode,
4498 RegisterOperand srcType, RegisterClass dstType, string asm,
4500 : I<(outs dstType:$Rd), (ins srcType:$Rn, VectorIndex1:$idx), asm,
4501 "{\t$Rd, $Rn"#kind#"$idx|"#kind#"\t$Rd, $Rn$idx}", "", []>,
4502 Sched<[WriteFCopy]> {
4505 let Inst{30-23} = 0b00111101;
4507 let Inst{20-19} = rmode;
4508 let Inst{18-16} = opcode;
4509 let Inst{15-10} = 0b000000;
4513 let DecoderMethod = "DecodeFMOVLaneInstruction";
4517 multiclass UnscaledConversion<string asm> {
4518 def WHr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR16, asm> {
4519 let Inst{31} = 0; // 32-bit GPR flag
4520 let Inst{23-22} = 0b11; // 16-bit FPR flag
4521 let Predicates = [HasFullFP16];
4524 def XHr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR16, asm> {
4525 let Inst{31} = 1; // 64-bit GPR flag
4526 let Inst{23-22} = 0b11; // 16-bit FPR flag
4527 let Predicates = [HasFullFP16];
4530 def WSr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR32, asm> {
4531 let Inst{31} = 0; // 32-bit GPR flag
4532 let Inst{23-22} = 0b00; // 32-bit FPR flag
4535 def XDr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR64, asm> {
4536 let Inst{31} = 1; // 64-bit GPR flag
4537 let Inst{23-22} = 0b01; // 64-bit FPR flag
4540 def HWr : BaseUnscaledConversion<0b00, 0b110, FPR16, GPR32, asm> {
4541 let Inst{31} = 0; // 32-bit GPR flag
4542 let Inst{23-22} = 0b11; // 16-bit FPR flag
4543 let Predicates = [HasFullFP16];
4546 def HXr : BaseUnscaledConversion<0b00, 0b110, FPR16, GPR64, asm> {
4547 let Inst{31} = 1; // 64-bit GPR flag
4548 let Inst{23-22} = 0b11; // 16-bit FPR flag
4549 let Predicates = [HasFullFP16];
4552 def SWr : BaseUnscaledConversion<0b00, 0b110, FPR32, GPR32, asm> {
4553 let Inst{31} = 0; // 32-bit GPR flag
4554 let Inst{23-22} = 0b00; // 32-bit FPR flag
4557 def DXr : BaseUnscaledConversion<0b00, 0b110, FPR64, GPR64, asm> {
4558 let Inst{31} = 1; // 64-bit GPR flag
4559 let Inst{23-22} = 0b01; // 64-bit FPR flag
4562 def XDHighr : BaseUnscaledConversionToHigh<0b01, 0b111, GPR64, V128,
4568 def DXHighr : BaseUnscaledConversionFromHigh<0b01, 0b110, V128, GPR64,
4576 // Floating point conversion
4579 class BaseFPConversion<bits<2> type, bits<2> opcode, RegisterClass dstType,
4580 RegisterClass srcType, string asm, list<dag> pattern>
4581 : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", pattern>,
4582 Sched<[WriteFCvt]> {
4585 let Inst{31-24} = 0b00011110;
4586 let Inst{23-22} = type;
4587 let Inst{21-17} = 0b10001;
4588 let Inst{16-15} = opcode;
4589 let Inst{14-10} = 0b10000;
4594 multiclass FPConversion<string asm> {
4595 // Double-precision to Half-precision
4596 def HDr : BaseFPConversion<0b01, 0b11, FPR16, FPR64, asm,
4597 [(set FPR16:$Rd, (fpround FPR64:$Rn))]>;
4599 // Double-precision to Single-precision
4600 def SDr : BaseFPConversion<0b01, 0b00, FPR32, FPR64, asm,
4601 [(set FPR32:$Rd, (fpround FPR64:$Rn))]>;
4603 // Half-precision to Double-precision
4604 def DHr : BaseFPConversion<0b11, 0b01, FPR64, FPR16, asm,
4605 [(set FPR64:$Rd, (fpextend FPR16:$Rn))]>;
4607 // Half-precision to Single-precision
4608 def SHr : BaseFPConversion<0b11, 0b00, FPR32, FPR16, asm,
4609 [(set FPR32:$Rd, (fpextend FPR16:$Rn))]>;
4611 // Single-precision to Double-precision
4612 def DSr : BaseFPConversion<0b00, 0b01, FPR64, FPR32, asm,
4613 [(set FPR64:$Rd, (fpextend FPR32:$Rn))]>;
4615 // Single-precision to Half-precision
4616 def HSr : BaseFPConversion<0b00, 0b11, FPR16, FPR32, asm,
4617 [(set FPR16:$Rd, (fpround FPR32:$Rn))]>;
4621 // Single operand floating point data processing
4624 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4625 class BaseSingleOperandFPData<bits<6> opcode, RegisterClass regtype,
4626 ValueType vt, string asm, SDPatternOperator node>
4627 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "",
4628 [(set (vt regtype:$Rd), (node (vt regtype:$Rn)))]>,
4632 let Inst{31-24} = 0b00011110;
4634 let Inst{20-15} = opcode;
4635 let Inst{14-10} = 0b10000;
4640 multiclass SingleOperandFPData<bits<4> opcode, string asm,
4641 SDPatternOperator node = null_frag> {
4643 def Hr : BaseSingleOperandFPData<{0b00,opcode}, FPR16, f16, asm, node> {
4644 let Inst{23-22} = 0b11; // 16-bit size flag
4645 let Predicates = [HasFullFP16];
4648 def Sr : BaseSingleOperandFPData<{0b00,opcode}, FPR32, f32, asm, node> {
4649 let Inst{23-22} = 0b00; // 32-bit size flag
4652 def Dr : BaseSingleOperandFPData<{0b00,opcode}, FPR64, f64, asm, node> {
4653 let Inst{23-22} = 0b01; // 64-bit size flag
4657 multiclass SingleOperandFPNo16<bits<6> opcode, string asm,
4658 SDPatternOperator node = null_frag>{
4660 def Sr : BaseSingleOperandFPData<opcode, FPR32, f32, asm, node> {
4661 let Inst{23-22} = 0b00; // 32-bit registers
4664 def Dr : BaseSingleOperandFPData<opcode, FPR64, f64, asm, node> {
4665 let Inst{23-22} = 0b01; // 64-bit registers
4669 // FRInt[32|64][Z|N] instructions
4670 multiclass FRIntNNT<bits<2> opcode, string asm, SDPatternOperator node = null_frag> :
4671 SingleOperandFPNo16<{0b0100,opcode}, asm, node>;
4674 // Two operand floating point data processing
4677 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4678 class BaseTwoOperandFPData<bits<4> opcode, RegisterClass regtype,
4679 string asm, list<dag> pat>
4680 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm),
4681 asm, "\t$Rd, $Rn, $Rm", "", pat>,
4686 let Inst{31-24} = 0b00011110;
4688 let Inst{20-16} = Rm;
4689 let Inst{15-12} = opcode;
4690 let Inst{11-10} = 0b10;
4695 multiclass TwoOperandFPData<bits<4> opcode, string asm,
4696 SDPatternOperator node = null_frag> {
4697 def Hrr : BaseTwoOperandFPData<opcode, FPR16, asm,
4698 [(set (f16 FPR16:$Rd),
4699 (node (f16 FPR16:$Rn), (f16 FPR16:$Rm)))]> {
4700 let Inst{23-22} = 0b11; // 16-bit size flag
4701 let Predicates = [HasFullFP16];
4704 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
4705 [(set (f32 FPR32:$Rd),
4706 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]> {
4707 let Inst{23-22} = 0b00; // 32-bit size flag
4710 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
4711 [(set (f64 FPR64:$Rd),
4712 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]> {
4713 let Inst{23-22} = 0b01; // 64-bit size flag
4717 multiclass TwoOperandFPDataNeg<bits<4> opcode, string asm, SDNode node> {
4718 def Hrr : BaseTwoOperandFPData<opcode, FPR16, asm,
4719 [(set FPR16:$Rd, (fneg (node FPR16:$Rn, (f16 FPR16:$Rm))))]> {
4720 let Inst{23-22} = 0b11; // 16-bit size flag
4721 let Predicates = [HasFullFP16];
4724 def Srr : BaseTwoOperandFPData<opcode, FPR32, asm,
4725 [(set FPR32:$Rd, (fneg (node FPR32:$Rn, (f32 FPR32:$Rm))))]> {
4726 let Inst{23-22} = 0b00; // 32-bit size flag
4729 def Drr : BaseTwoOperandFPData<opcode, FPR64, asm,
4730 [(set FPR64:$Rd, (fneg (node FPR64:$Rn, (f64 FPR64:$Rm))))]> {
4731 let Inst{23-22} = 0b01; // 64-bit size flag
4737 // Three operand floating point data processing
4740 class BaseThreeOperandFPData<bit isNegated, bit isSub,
4741 RegisterClass regtype, string asm, list<dag> pat>
4742 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, regtype: $Ra),
4743 asm, "\t$Rd, $Rn, $Rm, $Ra", "", pat>,
4744 Sched<[WriteFMul]> {
4749 let Inst{31-24} = 0b00011111;
4750 let Inst{21} = isNegated;
4751 let Inst{20-16} = Rm;
4752 let Inst{15} = isSub;
4753 let Inst{14-10} = Ra;
4758 multiclass ThreeOperandFPData<bit isNegated, bit isSub,string asm,
4759 SDPatternOperator node> {
4760 def Hrrr : BaseThreeOperandFPData<isNegated, isSub, FPR16, asm,
4762 (node (f16 FPR16:$Rn), (f16 FPR16:$Rm), (f16 FPR16:$Ra)))]> {
4763 let Inst{23-22} = 0b11; // 16-bit size flag
4764 let Predicates = [HasFullFP16];
4767 def Srrr : BaseThreeOperandFPData<isNegated, isSub, FPR32, asm,
4769 (node (f32 FPR32:$Rn), (f32 FPR32:$Rm), (f32 FPR32:$Ra)))]> {
4770 let Inst{23-22} = 0b00; // 32-bit size flag
4773 def Drrr : BaseThreeOperandFPData<isNegated, isSub, FPR64, asm,
4775 (node (f64 FPR64:$Rn), (f64 FPR64:$Rm), (f64 FPR64:$Ra)))]> {
4776 let Inst{23-22} = 0b01; // 64-bit size flag
4781 // Floating point data comparisons
4784 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4785 class BaseOneOperandFPComparison<bit signalAllNans,
4786 RegisterClass regtype, string asm,
4788 : I<(outs), (ins regtype:$Rn), asm, "\t$Rn, #0.0", "", pat>,
4789 Sched<[WriteFCmp]> {
4791 let Inst{31-24} = 0b00011110;
4794 let Inst{15-10} = 0b001000;
4796 let Inst{4} = signalAllNans;
4797 let Inst{3-0} = 0b1000;
4799 // Rm should be 0b00000 canonically, but we need to accept any value.
4800 let PostEncoderMethod = "fixOneOperandFPComparison";
4803 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4804 class BaseTwoOperandFPComparison<bit signalAllNans, RegisterClass regtype,
4805 string asm, list<dag> pat>
4806 : I<(outs), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rn, $Rm", "", pat>,
4807 Sched<[WriteFCmp]> {
4810 let Inst{31-24} = 0b00011110;
4812 let Inst{20-16} = Rm;
4813 let Inst{15-10} = 0b001000;
4815 let Inst{4} = signalAllNans;
4816 let Inst{3-0} = 0b0000;
4819 multiclass FPComparison<bit signalAllNans, string asm,
4820 SDPatternOperator OpNode = null_frag> {
4821 let Defs = [NZCV] in {
4822 def Hrr : BaseTwoOperandFPComparison<signalAllNans, FPR16, asm,
4823 [(OpNode FPR16:$Rn, (f16 FPR16:$Rm)), (implicit NZCV)]> {
4824 let Inst{23-22} = 0b11;
4825 let Predicates = [HasFullFP16];
4828 def Hri : BaseOneOperandFPComparison<signalAllNans, FPR16, asm,
4829 [(OpNode (f16 FPR16:$Rn), fpimm0), (implicit NZCV)]> {
4830 let Inst{23-22} = 0b11;
4831 let Predicates = [HasFullFP16];
4834 def Srr : BaseTwoOperandFPComparison<signalAllNans, FPR32, asm,
4835 [(OpNode FPR32:$Rn, (f32 FPR32:$Rm)), (implicit NZCV)]> {
4836 let Inst{23-22} = 0b00;
4839 def Sri : BaseOneOperandFPComparison<signalAllNans, FPR32, asm,
4840 [(OpNode (f32 FPR32:$Rn), fpimm0), (implicit NZCV)]> {
4841 let Inst{23-22} = 0b00;
4844 def Drr : BaseTwoOperandFPComparison<signalAllNans, FPR64, asm,
4845 [(OpNode FPR64:$Rn, (f64 FPR64:$Rm)), (implicit NZCV)]> {
4846 let Inst{23-22} = 0b01;
4849 def Dri : BaseOneOperandFPComparison<signalAllNans, FPR64, asm,
4850 [(OpNode (f64 FPR64:$Rn), fpimm0), (implicit NZCV)]> {
4851 let Inst{23-22} = 0b01;
4857 // Floating point conditional comparisons
4860 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4861 class BaseFPCondComparison<bit signalAllNans, RegisterClass regtype,
4862 string mnemonic, list<dag> pat>
4863 : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm32_0_15:$nzcv, ccode:$cond),
4864 mnemonic, "\t$Rn, $Rm, $nzcv, $cond", "", pat>,
4865 Sched<[WriteFCmp]> {
4874 let Inst{31-24} = 0b00011110;
4876 let Inst{20-16} = Rm;
4877 let Inst{15-12} = cond;
4878 let Inst{11-10} = 0b01;
4880 let Inst{4} = signalAllNans;
4881 let Inst{3-0} = nzcv;
4884 multiclass FPCondComparison<bit signalAllNans, string mnemonic,
4885 SDPatternOperator OpNode = null_frag> {
4886 def Hrr : BaseFPCondComparison<signalAllNans, FPR16, mnemonic,
4887 [(set NZCV, (OpNode (f16 FPR16:$Rn), (f16 FPR16:$Rm), (i32 imm:$nzcv),
4888 (i32 imm:$cond), NZCV))]> {
4889 let Inst{23-22} = 0b11;
4890 let Predicates = [HasFullFP16];
4893 def Srr : BaseFPCondComparison<signalAllNans, FPR32, mnemonic,
4894 [(set NZCV, (OpNode (f32 FPR32:$Rn), (f32 FPR32:$Rm), (i32 imm:$nzcv),
4895 (i32 imm:$cond), NZCV))]> {
4896 let Inst{23-22} = 0b00;
4899 def Drr : BaseFPCondComparison<signalAllNans, FPR64, mnemonic,
4900 [(set NZCV, (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm), (i32 imm:$nzcv),
4901 (i32 imm:$cond), NZCV))]> {
4902 let Inst{23-22} = 0b01;
4907 // Floating point conditional select
4910 class BaseFPCondSelect<RegisterClass regtype, ValueType vt, string asm>
4911 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond),
4912 asm, "\t$Rd, $Rn, $Rm, $cond", "",
4914 (AArch64csel (vt regtype:$Rn), regtype:$Rm,
4915 (i32 imm:$cond), NZCV))]>,
4922 let Inst{31-24} = 0b00011110;
4924 let Inst{20-16} = Rm;
4925 let Inst{15-12} = cond;
4926 let Inst{11-10} = 0b11;
4931 multiclass FPCondSelect<string asm> {
4932 let Uses = [NZCV] in {
4933 def Hrrr : BaseFPCondSelect<FPR16, f16, asm> {
4934 let Inst{23-22} = 0b11;
4935 let Predicates = [HasFullFP16];
4938 def Srrr : BaseFPCondSelect<FPR32, f32, asm> {
4939 let Inst{23-22} = 0b00;
4942 def Drrr : BaseFPCondSelect<FPR64, f64, asm> {
4943 let Inst{23-22} = 0b01;
4949 // Floating move immediate
4952 class BaseFPMoveImmediate<RegisterClass regtype, Operand fpimmtype, string asm>
4953 : I<(outs regtype:$Rd), (ins fpimmtype:$imm), asm, "\t$Rd, $imm", "",
4954 [(set regtype:$Rd, fpimmtype:$imm)]>,
4955 Sched<[WriteFImm]> {
4958 let Inst{31-24} = 0b00011110;
4960 let Inst{20-13} = imm;
4961 let Inst{12-5} = 0b10000000;
4965 multiclass FPMoveImmediate<string asm> {
4966 def Hi : BaseFPMoveImmediate<FPR16, fpimm16, asm> {
4967 let Inst{23-22} = 0b11;
4968 let Predicates = [HasFullFP16];
4971 def Si : BaseFPMoveImmediate<FPR32, fpimm32, asm> {
4972 let Inst{23-22} = 0b00;
4975 def Di : BaseFPMoveImmediate<FPR64, fpimm64, asm> {
4976 let Inst{23-22} = 0b01;
4979 } // end of 'let Predicates = [HasFPARMv8]'
4981 //----------------------------------------------------------------------------
4983 //----------------------------------------------------------------------------
4985 let Predicates = [HasNEON] in {
4987 //----------------------------------------------------------------------------
4988 // AdvSIMD three register vector instructions
4989 //----------------------------------------------------------------------------
4991 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
4992 class BaseSIMDThreeSameVector<bit Q, bit U, bits<3> size, bits<5> opcode,
4993 RegisterOperand regtype, string asm, string kind,
4995 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
4996 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
4997 "|" # kind # "\t$Rd, $Rn, $Rm|}", "", pattern>,
5005 let Inst{28-24} = 0b01110;
5006 let Inst{23-21} = size;
5007 let Inst{20-16} = Rm;
5008 let Inst{15-11} = opcode;
5014 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5015 class BaseSIMDThreeSameVectorTied<bit Q, bit U, bits<3> size, bits<5> opcode,
5016 RegisterOperand regtype, string asm, string kind,
5018 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm), asm,
5019 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
5020 "|" # kind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
5028 let Inst{28-24} = 0b01110;
5029 let Inst{23-21} = size;
5030 let Inst{20-16} = Rm;
5031 let Inst{15-11} = opcode;
5037 // All operand sizes distinguished in the encoding.
5038 multiclass SIMDThreeSameVector<bit U, bits<5> opc, string asm,
5039 SDPatternOperator OpNode> {
5040 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b001, opc, V64,
5042 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
5043 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b001, opc, V128,
5045 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
5046 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b011, opc, V64,
5048 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
5049 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b011, opc, V128,
5051 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
5052 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b101, opc, V64,
5054 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
5055 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b101, opc, V128,
5057 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
5058 def v2i64 : BaseSIMDThreeSameVector<1, U, 0b111, opc, V128,
5060 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
5063 // As above, but D sized elements unsupported.
5064 multiclass SIMDThreeSameVectorBHS<bit U, bits<5> opc, string asm,
5065 SDPatternOperator OpNode> {
5066 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b001, opc, V64,
5068 [(set V64:$Rd, (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))]>;
5069 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b001, opc, V128,
5071 [(set V128:$Rd, (v16i8 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm))))]>;
5072 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b011, opc, V64,
5074 [(set V64:$Rd, (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))]>;
5075 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b011, opc, V128,
5077 [(set V128:$Rd, (v8i16 (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm))))]>;
5078 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b101, opc, V64,
5080 [(set V64:$Rd, (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))]>;
5081 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b101, opc, V128,
5083 [(set V128:$Rd, (v4i32 (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm))))]>;
5086 multiclass SIMDThreeSameVectorBHSTied<bit U, bits<5> opc, string asm,
5087 SDPatternOperator OpNode> {
5088 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, 0b001, opc, V64,
5090 [(set (v8i8 V64:$dst),
5091 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
5092 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, 0b001, opc, V128,
5094 [(set (v16i8 V128:$dst),
5095 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
5096 def v4i16 : BaseSIMDThreeSameVectorTied<0, U, 0b011, opc, V64,
5098 [(set (v4i16 V64:$dst),
5099 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
5100 def v8i16 : BaseSIMDThreeSameVectorTied<1, U, 0b011, opc, V128,
5102 [(set (v8i16 V128:$dst),
5103 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
5104 def v2i32 : BaseSIMDThreeSameVectorTied<0, U, 0b101, opc, V64,
5106 [(set (v2i32 V64:$dst),
5107 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
5108 def v4i32 : BaseSIMDThreeSameVectorTied<1, U, 0b101, opc, V128,
5110 [(set (v4i32 V128:$dst),
5111 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
5114 // As above, but only B sized elements supported.
5115 multiclass SIMDThreeSameVectorB<bit U, bits<5> opc, string asm,
5116 SDPatternOperator OpNode> {
5117 def v8i8 : BaseSIMDThreeSameVector<0, U, 0b001, opc, V64,
5119 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
5120 def v16i8 : BaseSIMDThreeSameVector<1, U, 0b001, opc, V128,
5122 [(set (v16i8 V128:$Rd),
5123 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>;
5126 // As above, but only floating point elements supported.
5127 multiclass SIMDThreeSameVectorFP<bit U, bit S, bits<3> opc,
5128 string asm, SDPatternOperator OpNode> {
5129 let Predicates = [HasNEON, HasFullFP16] in {
5130 def v4f16 : BaseSIMDThreeSameVector<0, U, {S,0b10}, {0b00,opc}, V64,
5132 [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (v4f16 V64:$Rm)))]>;
5133 def v8f16 : BaseSIMDThreeSameVector<1, U, {S,0b10}, {0b00,opc}, V128,
5135 [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8f16 V128:$Rm)))]>;
5136 } // Predicates = [HasNEON, HasFullFP16]
5137 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0b01}, {0b11,opc}, V64,
5139 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
5140 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0b01}, {0b11,opc}, V128,
5142 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
5143 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,0b11}, {0b11,opc}, V128,
5145 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
5148 multiclass SIMDThreeSameVectorFPCmp<bit U, bit S, bits<3> opc,
5150 SDPatternOperator OpNode> {
5151 let Predicates = [HasNEON, HasFullFP16] in {
5152 def v4f16 : BaseSIMDThreeSameVector<0, U, {S,0b10}, {0b00,opc}, V64,
5154 [(set (v4i16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (v4f16 V64:$Rm)))]>;
5155 def v8f16 : BaseSIMDThreeSameVector<1, U, {S,0b10}, {0b00,opc}, V128,
5157 [(set (v8i16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8f16 V128:$Rm)))]>;
5158 } // Predicates = [HasNEON, HasFullFP16]
5159 def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0b01}, {0b11,opc}, V64,
5161 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
5162 def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0b01}, {0b11,opc}, V128,
5164 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
5165 def v2f64 : BaseSIMDThreeSameVector<1, U, {S,0b11}, {0b11,opc}, V128,
5167 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
5170 multiclass SIMDThreeSameVectorFPTied<bit U, bit S, bits<3> opc,
5171 string asm, SDPatternOperator OpNode> {
5172 let Predicates = [HasNEON, HasFullFP16] in {
5173 def v4f16 : BaseSIMDThreeSameVectorTied<0, U, {S,0b10}, {0b00,opc}, V64,
5175 [(set (v4f16 V64:$dst),
5176 (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn), (v4f16 V64:$Rm)))]>;
5177 def v8f16 : BaseSIMDThreeSameVectorTied<1, U, {S,0b10}, {0b00,opc}, V128,
5179 [(set (v8f16 V128:$dst),
5180 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn), (v8f16 V128:$Rm)))]>;
5181 } // Predicates = [HasNEON, HasFullFP16]
5182 def v2f32 : BaseSIMDThreeSameVectorTied<0, U, {S,0b01}, {0b11,opc}, V64,
5184 [(set (v2f32 V64:$dst),
5185 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>;
5186 def v4f32 : BaseSIMDThreeSameVectorTied<1, U, {S,0b01}, {0b11,opc}, V128,
5188 [(set (v4f32 V128:$dst),
5189 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>;
5190 def v2f64 : BaseSIMDThreeSameVectorTied<1, U, {S,0b11}, {0b11,opc}, V128,
5192 [(set (v2f64 V128:$dst),
5193 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>;
5196 // As above, but D and B sized elements unsupported.
5197 multiclass SIMDThreeSameVectorHS<bit U, bits<5> opc, string asm,
5198 SDPatternOperator OpNode> {
5199 def v4i16 : BaseSIMDThreeSameVector<0, U, 0b011, opc, V64,
5201 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
5202 def v8i16 : BaseSIMDThreeSameVector<1, U, 0b011, opc, V128,
5204 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
5205 def v2i32 : BaseSIMDThreeSameVector<0, U, 0b101, opc, V64,
5207 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
5208 def v4i32 : BaseSIMDThreeSameVector<1, U, 0b101, opc, V128,
5210 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
5213 // Logical three vector ops share opcode bits, and only use B sized elements.
5214 multiclass SIMDLogicalThreeVector<bit U, bits<2> size, string asm,
5215 SDPatternOperator OpNode = null_frag> {
5216 def v8i8 : BaseSIMDThreeSameVector<0, U, {size,1}, 0b00011, V64,
5218 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn, V64:$Rm))]>;
5219 def v16i8 : BaseSIMDThreeSameVector<1, U, {size,1}, 0b00011, V128,
5221 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn, V128:$Rm))]>;
5223 def : Pat<(v4i16 (OpNode V64:$LHS, V64:$RHS)),
5224 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
5225 def : Pat<(v2i32 (OpNode V64:$LHS, V64:$RHS)),
5226 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
5227 def : Pat<(v1i64 (OpNode V64:$LHS, V64:$RHS)),
5228 (!cast<Instruction>(NAME#"v8i8") V64:$LHS, V64:$RHS)>;
5230 def : Pat<(v8i16 (OpNode V128:$LHS, V128:$RHS)),
5231 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
5232 def : Pat<(v4i32 (OpNode V128:$LHS, V128:$RHS)),
5233 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
5234 def : Pat<(v2i64 (OpNode V128:$LHS, V128:$RHS)),
5235 (!cast<Instruction>(NAME#"v16i8") V128:$LHS, V128:$RHS)>;
5238 multiclass SIMDLogicalThreeVectorTied<bit U, bits<2> size,
5239 string asm, SDPatternOperator OpNode> {
5240 def v8i8 : BaseSIMDThreeSameVectorTied<0, U, {size,1}, 0b00011, V64,
5242 [(set (v8i8 V64:$dst),
5243 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
5244 def v16i8 : BaseSIMDThreeSameVectorTied<1, U, {size,1}, 0b00011, V128,
5246 [(set (v16i8 V128:$dst),
5247 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
5248 (v16i8 V128:$Rm)))]>;
5250 def : Pat<(v4i16 (OpNode (v4i16 V64:$LHS), (v4i16 V64:$MHS),
5252 (!cast<Instruction>(NAME#"v8i8")
5253 V64:$LHS, V64:$MHS, V64:$RHS)>;
5254 def : Pat<(v2i32 (OpNode (v2i32 V64:$LHS), (v2i32 V64:$MHS),
5256 (!cast<Instruction>(NAME#"v8i8")
5257 V64:$LHS, V64:$MHS, V64:$RHS)>;
5258 def : Pat<(v1i64 (OpNode (v1i64 V64:$LHS), (v1i64 V64:$MHS),
5260 (!cast<Instruction>(NAME#"v8i8")
5261 V64:$LHS, V64:$MHS, V64:$RHS)>;
5263 def : Pat<(v8i16 (OpNode (v8i16 V128:$LHS), (v8i16 V128:$MHS),
5264 (v8i16 V128:$RHS))),
5265 (!cast<Instruction>(NAME#"v16i8")
5266 V128:$LHS, V128:$MHS, V128:$RHS)>;
5267 def : Pat<(v4i32 (OpNode (v4i32 V128:$LHS), (v4i32 V128:$MHS),
5268 (v4i32 V128:$RHS))),
5269 (!cast<Instruction>(NAME#"v16i8")
5270 V128:$LHS, V128:$MHS, V128:$RHS)>;
5271 def : Pat<(v2i64 (OpNode (v2i64 V128:$LHS), (v2i64 V128:$MHS),
5272 (v2i64 V128:$RHS))),
5273 (!cast<Instruction>(NAME#"v16i8")
5274 V128:$LHS, V128:$MHS, V128:$RHS)>;
5277 // ARMv8.2-A Dot Product Instructions (Vector): These instructions extract
5278 // bytes from S-sized elements.
5279 class BaseSIMDThreeSameVectorDot<bit Q, bit U, string asm, string kind1,
5280 string kind2, RegisterOperand RegType,
5281 ValueType AccumType, ValueType InputType,
5282 SDPatternOperator OpNode> :
5283 BaseSIMDThreeSameVectorTied<Q, U, 0b100, 0b10010, RegType, asm, kind1,
5284 [(set (AccumType RegType:$dst),
5285 (OpNode (AccumType RegType:$Rd),
5286 (InputType RegType:$Rn),
5287 (InputType RegType:$Rm)))]> {
5288 let AsmString = !strconcat(asm, "{\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2 # "}");
5291 multiclass SIMDThreeSameVectorDot<bit U, string asm, SDPatternOperator OpNode> {
5292 def v8i8 : BaseSIMDThreeSameVectorDot<0, U, asm, ".2s", ".8b", V64,
5293 v2i32, v8i8, OpNode>;
5294 def v16i8 : BaseSIMDThreeSameVectorDot<1, U, asm, ".4s", ".16b", V128,
5295 v4i32, v16i8, OpNode>;
5298 // ARMv8.2-A Fused Multiply Add-Long Instructions (Vector): These instructions
5299 // select inputs from 4H vectors and accumulate outputs to a 2S vector (or from
5300 // 8H to 4S, when Q=1).
5301 class BaseSIMDThreeSameVectorFML<bit Q, bit U, bit b13, bits<3> size, string asm, string kind1,
5302 string kind2, RegisterOperand RegType,
5303 ValueType AccumType, ValueType InputType,
5304 SDPatternOperator OpNode> :
5305 BaseSIMDThreeSameVectorTied<Q, U, size, 0b11101, RegType, asm, kind1,
5306 [(set (AccumType RegType:$dst),
5307 (OpNode (AccumType RegType:$Rd),
5308 (InputType RegType:$Rn),
5309 (InputType RegType:$Rm)))]> {
5310 let AsmString = !strconcat(asm, "{\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2 # "}");
5314 multiclass SIMDThreeSameVectorFML<bit U, bit b13, bits<3> size, string asm,
5315 SDPatternOperator OpNode> {
5316 def v4f16 : BaseSIMDThreeSameVectorFML<0, U, b13, size, asm, ".2s", ".2h", V64,
5317 v2f32, v4f16, OpNode>;
5318 def v8f16 : BaseSIMDThreeSameVectorFML<1, U, b13, size, asm, ".4s", ".4h", V128,
5319 v4f32, v8f16, OpNode>;
5323 //----------------------------------------------------------------------------
5324 // AdvSIMD two register vector instructions.
5325 //----------------------------------------------------------------------------
5327 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5328 class BaseSIMDTwoSameVector<bit Q, bit U, bits<2> size, bits<5> opcode,
5329 bits<2> size2, RegisterOperand regtype, string asm,
5330 string dstkind, string srckind, list<dag> pattern>
5331 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
5332 "{\t$Rd" # dstkind # ", $Rn" # srckind #
5333 "|" # dstkind # "\t$Rd, $Rn}", "", pattern>,
5340 let Inst{28-24} = 0b01110;
5341 let Inst{23-22} = size;
5343 let Inst{20-19} = size2;
5344 let Inst{18-17} = 0b00;
5345 let Inst{16-12} = opcode;
5346 let Inst{11-10} = 0b10;
5351 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5352 class BaseSIMDTwoSameVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
5353 bits<2> size2, RegisterOperand regtype,
5354 string asm, string dstkind, string srckind,
5356 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn), asm,
5357 "{\t$Rd" # dstkind # ", $Rn" # srckind #
5358 "|" # dstkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
5365 let Inst{28-24} = 0b01110;
5366 let Inst{23-22} = size;
5368 let Inst{20-19} = size2;
5369 let Inst{18-17} = 0b00;
5370 let Inst{16-12} = opcode;
5371 let Inst{11-10} = 0b10;
5376 // Supports B, H, and S element sizes.
5377 multiclass SIMDTwoVectorBHS<bit U, bits<5> opc, string asm,
5378 SDPatternOperator OpNode> {
5379 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64,
5381 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
5382 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128,
5383 asm, ".16b", ".16b",
5384 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
5385 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64,
5387 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
5388 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128,
5390 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
5391 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, 0b00, V64,
5393 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
5394 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, 0b00, V128,
5396 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
5399 class BaseSIMDVectorLShiftLongBySize<bit Q, bits<2> size,
5400 RegisterOperand regtype, string asm, string dstkind,
5401 string srckind, string amount>
5402 : I<(outs V128:$Rd), (ins regtype:$Rn), asm,
5403 "{\t$Rd" # dstkind # ", $Rn" # srckind # ", #" # amount #
5404 "|" # dstkind # "\t$Rd, $Rn, #" # amount # "}", "", []>,
5410 let Inst{29-24} = 0b101110;
5411 let Inst{23-22} = size;
5412 let Inst{21-10} = 0b100001001110;
5417 multiclass SIMDVectorLShiftLongBySizeBHS {
5418 let hasSideEffects = 0 in {
5419 def v8i8 : BaseSIMDVectorLShiftLongBySize<0, 0b00, V64,
5420 "shll", ".8h", ".8b", "8">;
5421 def v16i8 : BaseSIMDVectorLShiftLongBySize<1, 0b00, V128,
5422 "shll2", ".8h", ".16b", "8">;
5423 def v4i16 : BaseSIMDVectorLShiftLongBySize<0, 0b01, V64,
5424 "shll", ".4s", ".4h", "16">;
5425 def v8i16 : BaseSIMDVectorLShiftLongBySize<1, 0b01, V128,
5426 "shll2", ".4s", ".8h", "16">;
5427 def v2i32 : BaseSIMDVectorLShiftLongBySize<0, 0b10, V64,
5428 "shll", ".2d", ".2s", "32">;
5429 def v4i32 : BaseSIMDVectorLShiftLongBySize<1, 0b10, V128,
5430 "shll2", ".2d", ".4s", "32">;
5434 // Supports all element sizes.
5435 multiclass SIMDLongTwoVector<bit U, bits<5> opc, string asm,
5436 SDPatternOperator OpNode> {
5437 def v8i8_v4i16 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64,
5439 [(set (v4i16 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
5440 def v16i8_v8i16 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128,
5442 [(set (v8i16 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
5443 def v4i16_v2i32 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64,
5445 [(set (v2i32 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
5446 def v8i16_v4i32 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128,
5448 [(set (v4i32 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
5449 def v2i32_v1i64 : BaseSIMDTwoSameVector<0, U, 0b10, opc, 0b00, V64,
5451 [(set (v1i64 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
5452 def v4i32_v2i64 : BaseSIMDTwoSameVector<1, U, 0b10, opc, 0b00, V128,
5454 [(set (v2i64 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
5457 multiclass SIMDLongTwoVectorTied<bit U, bits<5> opc, string asm,
5458 SDPatternOperator OpNode> {
5459 def v8i8_v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, 0b00, V64,
5461 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd),
5463 def v16i8_v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, 0b00, V128,
5465 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd),
5466 (v16i8 V128:$Rn)))]>;
5467 def v4i16_v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, 0b00, V64,
5469 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd),
5470 (v4i16 V64:$Rn)))]>;
5471 def v8i16_v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, 0b00, V128,
5473 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd),
5474 (v8i16 V128:$Rn)))]>;
5475 def v2i32_v1i64 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, 0b00, V64,
5477 [(set (v1i64 V64:$dst), (OpNode (v1i64 V64:$Rd),
5478 (v2i32 V64:$Rn)))]>;
5479 def v4i32_v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, 0b00, V128,
5481 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd),
5482 (v4i32 V128:$Rn)))]>;
5485 // Supports all element sizes, except 1xD.
5486 multiclass SIMDTwoVectorBHSDTied<bit U, bits<5> opc, string asm,
5487 SDPatternOperator OpNode> {
5488 def v8i8 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, 0b00, V64,
5490 [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn)))]>;
5491 def v16i8 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, 0b00, V128,
5492 asm, ".16b", ".16b",
5493 [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
5494 def v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, 0b00, V64,
5496 [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn)))]>;
5497 def v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, 0b00, V128,
5499 [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn)))]>;
5500 def v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, 0b00, V64,
5502 [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn)))]>;
5503 def v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, 0b00, V128,
5505 [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
5506 def v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b11, opc, 0b00, V128,
5508 [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn)))]>;
5511 multiclass SIMDTwoVectorBHSD<bit U, bits<5> opc, string asm,
5512 SDPatternOperator OpNode = null_frag> {
5513 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64,
5515 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
5516 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128,
5517 asm, ".16b", ".16b",
5518 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
5519 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64,
5521 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
5522 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128,
5524 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
5525 def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, 0b00, V64,
5527 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
5528 def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, 0b00, V128,
5530 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
5531 def v2i64 : BaseSIMDTwoSameVector<1, U, 0b11, opc, 0b00, V128,
5533 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
5537 // Supports only B element sizes.
5538 multiclass SIMDTwoVectorB<bit U, bits<2> size, bits<5> opc, string asm,
5539 SDPatternOperator OpNode> {
5540 def v8i8 : BaseSIMDTwoSameVector<0, U, size, opc, 0b00, V64,
5542 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>;
5543 def v16i8 : BaseSIMDTwoSameVector<1, U, size, opc, 0b00, V128,
5544 asm, ".16b", ".16b",
5545 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
5549 // Supports only B and H element sizes.
5550 multiclass SIMDTwoVectorBH<bit U, bits<5> opc, string asm,
5551 SDPatternOperator OpNode> {
5552 def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64,
5554 [(set (v8i8 V64:$Rd), (OpNode V64:$Rn))]>;
5555 def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128,
5556 asm, ".16b", ".16b",
5557 [(set (v16i8 V128:$Rd), (OpNode V128:$Rn))]>;
5558 def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64,
5560 [(set (v4i16 V64:$Rd), (OpNode V64:$Rn))]>;
5561 def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128,
5563 [(set (v8i16 V128:$Rd), (OpNode V128:$Rn))]>;
5566 // Supports H, S and D element sizes, uses high bit of the size field
5567 // as an extra opcode bit.
5568 multiclass SIMDTwoVectorFP<bit U, bit S, bits<5> opc, string asm,
5569 SDPatternOperator OpNode> {
5570 let Predicates = [HasNEON, HasFullFP16] in {
5571 def v4f16 : BaseSIMDTwoSameVector<0, U, {S,1}, opc, 0b11, V64,
5573 [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn)))]>;
5574 def v8f16 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b11, V128,
5576 [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn)))]>;
5577 } // Predicates = [HasNEON, HasFullFP16]
5578 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64,
5580 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
5581 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128,
5583 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
5584 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b00, V128,
5586 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
5589 // Supports only S and D element sizes
5590 multiclass SIMDTwoVectorSD<bit U, bits<5> opc, string asm,
5591 SDPatternOperator OpNode = null_frag> {
5593 def v2f32 : BaseSIMDTwoSameVector<0, U, 00, opc, 0b00, V64,
5595 [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
5596 def v4f32 : BaseSIMDTwoSameVector<1, U, 00, opc, 0b00, V128,
5598 [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
5599 def v2f64 : BaseSIMDTwoSameVector<1, U, 01, opc, 0b00, V128,
5601 [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
5604 multiclass FRIntNNTVector<bit U, bit op, string asm,
5605 SDPatternOperator OpNode = null_frag> :
5606 SIMDTwoVectorSD<U, {0b1111,op}, asm, OpNode>;
5608 // Supports only S element size.
5609 multiclass SIMDTwoVectorS<bit U, bit S, bits<5> opc, string asm,
5610 SDPatternOperator OpNode> {
5611 def v2i32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64,
5613 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
5614 def v4i32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128,
5616 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
5620 multiclass SIMDTwoVectorFPToInt<bit U, bit S, bits<5> opc, string asm,
5621 SDPatternOperator OpNode> {
5622 let Predicates = [HasNEON, HasFullFP16] in {
5623 def v4f16 : BaseSIMDTwoSameVector<0, U, {S,1}, opc, 0b11, V64,
5625 [(set (v4i16 V64:$Rd), (OpNode (v4f16 V64:$Rn)))]>;
5626 def v8f16 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b11, V128,
5628 [(set (v8i16 V128:$Rd), (OpNode (v8f16 V128:$Rn)))]>;
5629 } // Predicates = [HasNEON, HasFullFP16]
5630 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64,
5632 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>;
5633 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128,
5635 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>;
5636 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b00, V128,
5638 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
5641 multiclass SIMDTwoVectorIntToFP<bit U, bit S, bits<5> opc, string asm,
5642 SDPatternOperator OpNode> {
5643 let Predicates = [HasNEON, HasFullFP16] in {
5644 def v4f16 : BaseSIMDTwoSameVector<0, U, {S,1}, opc, 0b11, V64,
5646 [(set (v4f16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>;
5647 def v8f16 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b11, V128,
5649 [(set (v8f16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
5650 } // Predicates = [HasNEON, HasFullFP16]
5651 def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64,
5653 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>;
5654 def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128,
5656 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
5657 def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b00, V128,
5659 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
5663 class BaseSIMDMixedTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
5664 RegisterOperand inreg, RegisterOperand outreg,
5665 string asm, string outkind, string inkind,
5667 : I<(outs outreg:$Rd), (ins inreg:$Rn), asm,
5668 "{\t$Rd" # outkind # ", $Rn" # inkind #
5669 "|" # outkind # "\t$Rd, $Rn}", "", pattern>,
5676 let Inst{28-24} = 0b01110;
5677 let Inst{23-22} = size;
5678 let Inst{21-17} = 0b10000;
5679 let Inst{16-12} = opcode;
5680 let Inst{11-10} = 0b10;
5685 class BaseSIMDMixedTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
5686 RegisterOperand inreg, RegisterOperand outreg,
5687 string asm, string outkind, string inkind,
5689 : I<(outs outreg:$dst), (ins outreg:$Rd, inreg:$Rn), asm,
5690 "{\t$Rd" # outkind # ", $Rn" # inkind #
5691 "|" # outkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>,
5698 let Inst{28-24} = 0b01110;
5699 let Inst{23-22} = size;
5700 let Inst{21-17} = 0b10000;
5701 let Inst{16-12} = opcode;
5702 let Inst{11-10} = 0b10;
5707 multiclass SIMDMixedTwoVector<bit U, bits<5> opc, string asm,
5708 SDPatternOperator OpNode> {
5709 def v8i8 : BaseSIMDMixedTwoVector<0, U, 0b00, opc, V128, V64,
5711 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn)))]>;
5712 def v16i8 : BaseSIMDMixedTwoVectorTied<1, U, 0b00, opc, V128, V128,
5713 asm#"2", ".16b", ".8h", []>;
5714 def v4i16 : BaseSIMDMixedTwoVector<0, U, 0b01, opc, V128, V64,
5716 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn)))]>;
5717 def v8i16 : BaseSIMDMixedTwoVectorTied<1, U, 0b01, opc, V128, V128,
5718 asm#"2", ".8h", ".4s", []>;
5719 def v2i32 : BaseSIMDMixedTwoVector<0, U, 0b10, opc, V128, V64,
5721 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn)))]>;
5722 def v4i32 : BaseSIMDMixedTwoVectorTied<1, U, 0b10, opc, V128, V128,
5723 asm#"2", ".4s", ".2d", []>;
5725 def : Pat<(concat_vectors (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn))),
5726 (!cast<Instruction>(NAME # "v16i8")
5727 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
5728 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn))),
5729 (!cast<Instruction>(NAME # "v8i16")
5730 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
5731 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn))),
5732 (!cast<Instruction>(NAME # "v4i32")
5733 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
5736 class BaseSIMDCmpTwoVector<bit Q, bit U, bits<2> size, bits<2> size2,
5737 bits<5> opcode, RegisterOperand regtype, string asm,
5738 string kind, string zero, ValueType dty,
5739 ValueType sty, SDNode OpNode>
5740 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
5741 "{\t$Rd" # kind # ", $Rn" # kind # ", #" # zero #
5742 "|" # kind # "\t$Rd, $Rn, #" # zero # "}", "",
5743 [(set (dty regtype:$Rd), (OpNode (sty regtype:$Rn)))]>,
5750 let Inst{28-24} = 0b01110;
5751 let Inst{23-22} = size;
5753 let Inst{20-19} = size2;
5754 let Inst{18-17} = 0b00;
5755 let Inst{16-12} = opcode;
5756 let Inst{11-10} = 0b10;
5761 // Comparisons support all element sizes, except 1xD.
5762 multiclass SIMDCmpTwoVector<bit U, bits<5> opc, string asm,
5764 def v8i8rz : BaseSIMDCmpTwoVector<0, U, 0b00, 0b00, opc, V64,
5766 v8i8, v8i8, OpNode>;
5767 def v16i8rz : BaseSIMDCmpTwoVector<1, U, 0b00, 0b00, opc, V128,
5769 v16i8, v16i8, OpNode>;
5770 def v4i16rz : BaseSIMDCmpTwoVector<0, U, 0b01, 0b00, opc, V64,
5772 v4i16, v4i16, OpNode>;
5773 def v8i16rz : BaseSIMDCmpTwoVector<1, U, 0b01, 0b00, opc, V128,
5775 v8i16, v8i16, OpNode>;
5776 def v2i32rz : BaseSIMDCmpTwoVector<0, U, 0b10, 0b00, opc, V64,
5778 v2i32, v2i32, OpNode>;
5779 def v4i32rz : BaseSIMDCmpTwoVector<1, U, 0b10, 0b00, opc, V128,
5781 v4i32, v4i32, OpNode>;
5782 def v2i64rz : BaseSIMDCmpTwoVector<1, U, 0b11, 0b00, opc, V128,
5784 v2i64, v2i64, OpNode>;
5787 // FP Comparisons support only S and D element sizes (and H for v8.2a).
5788 multiclass SIMDFPCmpTwoVector<bit U, bit S, bits<5> opc,
5789 string asm, SDNode OpNode> {
5791 let Predicates = [HasNEON, HasFullFP16] in {
5792 def v4i16rz : BaseSIMDCmpTwoVector<0, U, {S,1}, 0b11, opc, V64,
5794 v4i16, v4f16, OpNode>;
5795 def v8i16rz : BaseSIMDCmpTwoVector<1, U, {S,1}, 0b11, opc, V128,
5797 v8i16, v8f16, OpNode>;
5798 } // Predicates = [HasNEON, HasFullFP16]
5799 def v2i32rz : BaseSIMDCmpTwoVector<0, U, {S,0}, 0b00, opc, V64,
5801 v2i32, v2f32, OpNode>;
5802 def v4i32rz : BaseSIMDCmpTwoVector<1, U, {S,0}, 0b00, opc, V128,
5804 v4i32, v4f32, OpNode>;
5805 def v2i64rz : BaseSIMDCmpTwoVector<1, U, {S,1}, 0b00, opc, V128,
5807 v2i64, v2f64, OpNode>;
5809 let Predicates = [HasNEON, HasFullFP16] in {
5810 def : InstAlias<asm # "\t$Vd.4h, $Vn.4h, #0",
5811 (!cast<Instruction>(NAME # v4i16rz) V64:$Vd, V64:$Vn), 0>;
5812 def : InstAlias<asm # "\t$Vd.8h, $Vn.8h, #0",
5813 (!cast<Instruction>(NAME # v8i16rz) V128:$Vd, V128:$Vn), 0>;
5815 def : InstAlias<asm # "\t$Vd.2s, $Vn.2s, #0",
5816 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
5817 def : InstAlias<asm # "\t$Vd.4s, $Vn.4s, #0",
5818 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
5819 def : InstAlias<asm # "\t$Vd.2d, $Vn.2d, #0",
5820 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
5821 let Predicates = [HasNEON, HasFullFP16] in {
5822 def : InstAlias<asm # ".4h\t$Vd, $Vn, #0",
5823 (!cast<Instruction>(NAME # v4i16rz) V64:$Vd, V64:$Vn), 0>;
5824 def : InstAlias<asm # ".8h\t$Vd, $Vn, #0",
5825 (!cast<Instruction>(NAME # v8i16rz) V128:$Vd, V128:$Vn), 0>;
5827 def : InstAlias<asm # ".2s\t$Vd, $Vn, #0",
5828 (!cast<Instruction>(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>;
5829 def : InstAlias<asm # ".4s\t$Vd, $Vn, #0",
5830 (!cast<Instruction>(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>;
5831 def : InstAlias<asm # ".2d\t$Vd, $Vn, #0",
5832 (!cast<Instruction>(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>;
5835 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5836 class BaseSIMDFPCvtTwoVector<bit Q, bit U, bits<2> size, bits<5> opcode,
5837 RegisterOperand outtype, RegisterOperand intype,
5838 string asm, string VdTy, string VnTy,
5840 : I<(outs outtype:$Rd), (ins intype:$Rn), asm,
5841 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "", pattern>,
5848 let Inst{28-24} = 0b01110;
5849 let Inst{23-22} = size;
5850 let Inst{21-17} = 0b10000;
5851 let Inst{16-12} = opcode;
5852 let Inst{11-10} = 0b10;
5857 class BaseSIMDFPCvtTwoVectorTied<bit Q, bit U, bits<2> size, bits<5> opcode,
5858 RegisterOperand outtype, RegisterOperand intype,
5859 string asm, string VdTy, string VnTy,
5861 : I<(outs outtype:$dst), (ins outtype:$Rd, intype:$Rn), asm,
5862 !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "$Rd = $dst", pattern>,
5869 let Inst{28-24} = 0b01110;
5870 let Inst{23-22} = size;
5871 let Inst{21-17} = 0b10000;
5872 let Inst{16-12} = opcode;
5873 let Inst{11-10} = 0b10;
5878 multiclass SIMDFPWidenTwoVector<bit U, bit S, bits<5> opc, string asm> {
5879 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V128, V64,
5880 asm, ".4s", ".4h", []>;
5881 def v8i16 : BaseSIMDFPCvtTwoVector<1, U, {S,0}, opc, V128, V128,
5882 asm#"2", ".4s", ".8h", []>;
5883 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V128, V64,
5884 asm, ".2d", ".2s", []>;
5885 def v4i32 : BaseSIMDFPCvtTwoVector<1, U, {S,1}, opc, V128, V128,
5886 asm#"2", ".2d", ".4s", []>;
5889 multiclass SIMDFPNarrowTwoVector<bit U, bit S, bits<5> opc, string asm> {
5890 def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V64, V128,
5891 asm, ".4h", ".4s", []>;
5892 def v8i16 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,0}, opc, V128, V128,
5893 asm#"2", ".8h", ".4s", []>;
5894 def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
5895 asm, ".2s", ".2d", []>;
5896 def v4i32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
5897 asm#"2", ".4s", ".2d", []>;
5900 multiclass SIMDFPInexactCvtTwoVector<bit U, bit S, bits<5> opc, string asm,
5902 def v2f32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128,
5904 [(set (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn)))]>;
5905 def v4f32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128,
5906 asm#"2", ".4s", ".2d", []>;
5908 def : Pat<(concat_vectors (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn))),
5909 (!cast<Instruction>(NAME # "v4f32")
5910 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
5913 //----------------------------------------------------------------------------
5914 // AdvSIMD three register different-size vector instructions.
5915 //----------------------------------------------------------------------------
5917 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5918 class BaseSIMDDifferentThreeVector<bit U, bits<3> size, bits<4> opcode,
5919 RegisterOperand outtype, RegisterOperand intype1,
5920 RegisterOperand intype2, string asm,
5921 string outkind, string inkind1, string inkind2,
5923 : I<(outs outtype:$Rd), (ins intype1:$Rn, intype2:$Rm), asm,
5924 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
5925 "|" # outkind # "\t$Rd, $Rn, $Rm}", "", pattern>,
5931 let Inst{30} = size{0};
5933 let Inst{28-24} = 0b01110;
5934 let Inst{23-22} = size{2-1};
5936 let Inst{20-16} = Rm;
5937 let Inst{15-12} = opcode;
5938 let Inst{11-10} = 0b00;
5943 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
5944 class BaseSIMDDifferentThreeVectorTied<bit U, bits<3> size, bits<4> opcode,
5945 RegisterOperand outtype, RegisterOperand intype1,
5946 RegisterOperand intype2, string asm,
5947 string outkind, string inkind1, string inkind2,
5949 : I<(outs outtype:$dst), (ins outtype:$Rd, intype1:$Rn, intype2:$Rm), asm,
5950 "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 #
5951 "|" # outkind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>,
5957 let Inst{30} = size{0};
5959 let Inst{28-24} = 0b01110;
5960 let Inst{23-22} = size{2-1};
5962 let Inst{20-16} = Rm;
5963 let Inst{15-12} = opcode;
5964 let Inst{11-10} = 0b00;
5969 // FIXME: TableGen doesn't know how to deal with expanded types that also
5970 // change the element count (in this case, placing the results in
5971 // the high elements of the result register rather than the low
5972 // elements). Until that's fixed, we can't code-gen those.
5973 multiclass SIMDNarrowThreeVectorBHS<bit U, bits<4> opc, string asm,
5975 def v8i16_v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
5977 asm, ".8b", ".8h", ".8h",
5978 [(set (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>;
5979 def v8i16_v16i8 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
5981 asm#"2", ".16b", ".8h", ".8h",
5983 def v4i32_v4i16 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
5985 asm, ".4h", ".4s", ".4s",
5986 [(set (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>;
5987 def v4i32_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
5989 asm#"2", ".8h", ".4s", ".4s",
5991 def v2i64_v2i32 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
5993 asm, ".2s", ".2d", ".2d",
5994 [(set (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>;
5995 def v2i64_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
5997 asm#"2", ".4s", ".2d", ".2d",
6001 // Patterns for the '2' variants involve INSERT_SUBREG, which you can't put in
6002 // a version attached to an instruction.
6003 def : Pat<(concat_vectors (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn),
6005 (!cast<Instruction>(NAME # "v8i16_v16i8")
6006 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
6007 V128:$Rn, V128:$Rm)>;
6008 def : Pat<(concat_vectors (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn),
6010 (!cast<Instruction>(NAME # "v4i32_v8i16")
6011 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
6012 V128:$Rn, V128:$Rm)>;
6013 def : Pat<(concat_vectors (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn),
6015 (!cast<Instruction>(NAME # "v2i64_v4i32")
6016 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
6017 V128:$Rn, V128:$Rm)>;
6020 multiclass SIMDDifferentThreeVectorBD<bit U, bits<4> opc, string asm,
6022 def v8i8 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
6024 asm, ".8h", ".8b", ".8b",
6025 [(set (v8i16 V128:$Rd), (IntOp (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
6026 def v16i8 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
6028 asm#"2", ".8h", ".16b", ".16b", []>;
6029 let Predicates = [HasAES] in {
6030 def v1i64 : BaseSIMDDifferentThreeVector<U, 0b110, opc,
6032 asm, ".1q", ".1d", ".1d", []>;
6033 def v2i64 : BaseSIMDDifferentThreeVector<U, 0b111, opc,
6035 asm#"2", ".1q", ".2d", ".2d", []>;
6038 def : Pat<(v8i16 (IntOp (v8i8 (extract_high_v16i8 V128:$Rn)),
6039 (v8i8 (extract_high_v16i8 V128:$Rm)))),
6040 (!cast<Instruction>(NAME#"v16i8") V128:$Rn, V128:$Rm)>;
6043 multiclass SIMDLongThreeVectorHS<bit U, bits<4> opc, string asm,
6044 SDPatternOperator OpNode> {
6045 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
6047 asm, ".4s", ".4h", ".4h",
6048 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
6049 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
6051 asm#"2", ".4s", ".8h", ".8h",
6052 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
6053 (extract_high_v8i16 V128:$Rm)))]>;
6054 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
6056 asm, ".2d", ".2s", ".2s",
6057 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
6058 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
6060 asm#"2", ".2d", ".4s", ".4s",
6061 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
6062 (extract_high_v4i32 V128:$Rm)))]>;
6065 multiclass SIMDLongThreeVectorBHSabdl<bit U, bits<4> opc, string asm,
6066 SDPatternOperator OpNode = null_frag> {
6067 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
6069 asm, ".8h", ".8b", ".8b",
6070 [(set (v8i16 V128:$Rd),
6071 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))))]>;
6072 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
6074 asm#"2", ".8h", ".16b", ".16b",
6075 [(set (v8i16 V128:$Rd),
6076 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
6077 (extract_high_v16i8 V128:$Rm)))))]>;
6078 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
6080 asm, ".4s", ".4h", ".4h",
6081 [(set (v4i32 V128:$Rd),
6082 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))))]>;
6083 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
6085 asm#"2", ".4s", ".8h", ".8h",
6086 [(set (v4i32 V128:$Rd),
6087 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
6088 (extract_high_v8i16 V128:$Rm)))))]>;
6089 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
6091 asm, ".2d", ".2s", ".2s",
6092 [(set (v2i64 V128:$Rd),
6093 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))))]>;
6094 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
6096 asm#"2", ".2d", ".4s", ".4s",
6097 [(set (v2i64 V128:$Rd),
6098 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
6099 (extract_high_v4i32 V128:$Rm)))))]>;
6102 multiclass SIMDLongThreeVectorTiedBHSabal<bit U, bits<4> opc,
6104 SDPatternOperator OpNode> {
6105 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
6107 asm, ".8h", ".8b", ".8b",
6108 [(set (v8i16 V128:$dst),
6109 (add (v8i16 V128:$Rd),
6110 (zext (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))))]>;
6111 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
6113 asm#"2", ".8h", ".16b", ".16b",
6114 [(set (v8i16 V128:$dst),
6115 (add (v8i16 V128:$Rd),
6116 (zext (v8i8 (OpNode (extract_high_v16i8 V128:$Rn),
6117 (extract_high_v16i8 V128:$Rm))))))]>;
6118 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
6120 asm, ".4s", ".4h", ".4h",
6121 [(set (v4i32 V128:$dst),
6122 (add (v4i32 V128:$Rd),
6123 (zext (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))))]>;
6124 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
6126 asm#"2", ".4s", ".8h", ".8h",
6127 [(set (v4i32 V128:$dst),
6128 (add (v4i32 V128:$Rd),
6129 (zext (v4i16 (OpNode (extract_high_v8i16 V128:$Rn),
6130 (extract_high_v8i16 V128:$Rm))))))]>;
6131 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
6133 asm, ".2d", ".2s", ".2s",
6134 [(set (v2i64 V128:$dst),
6135 (add (v2i64 V128:$Rd),
6136 (zext (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))))]>;
6137 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
6139 asm#"2", ".2d", ".4s", ".4s",
6140 [(set (v2i64 V128:$dst),
6141 (add (v2i64 V128:$Rd),
6142 (zext (v2i32 (OpNode (extract_high_v4i32 V128:$Rn),
6143 (extract_high_v4i32 V128:$Rm))))))]>;
6146 multiclass SIMDLongThreeVectorBHS<bit U, bits<4> opc, string asm,
6147 SDPatternOperator OpNode = null_frag> {
6148 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
6150 asm, ".8h", ".8b", ".8b",
6151 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
6152 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
6154 asm#"2", ".8h", ".16b", ".16b",
6155 [(set (v8i16 V128:$Rd), (OpNode (extract_high_v16i8 V128:$Rn),
6156 (extract_high_v16i8 V128:$Rm)))]>;
6157 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
6159 asm, ".4s", ".4h", ".4h",
6160 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
6161 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
6163 asm#"2", ".4s", ".8h", ".8h",
6164 [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 V128:$Rn),
6165 (extract_high_v8i16 V128:$Rm)))]>;
6166 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
6168 asm, ".2d", ".2s", ".2s",
6169 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
6170 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
6172 asm#"2", ".2d", ".4s", ".4s",
6173 [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 V128:$Rn),
6174 (extract_high_v4i32 V128:$Rm)))]>;
6177 multiclass SIMDLongThreeVectorTiedBHS<bit U, bits<4> opc,
6179 SDPatternOperator OpNode> {
6180 def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b000, opc,
6182 asm, ".8h", ".8b", ".8b",
6183 [(set (v8i16 V128:$dst),
6184 (OpNode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>;
6185 def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied<U, 0b001, opc,
6187 asm#"2", ".8h", ".16b", ".16b",
6188 [(set (v8i16 V128:$dst),
6189 (OpNode (v8i16 V128:$Rd),
6190 (extract_high_v16i8 V128:$Rn),
6191 (extract_high_v16i8 V128:$Rm)))]>;
6192 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
6194 asm, ".4s", ".4h", ".4h",
6195 [(set (v4i32 V128:$dst),
6196 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>;
6197 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
6199 asm#"2", ".4s", ".8h", ".8h",
6200 [(set (v4i32 V128:$dst),
6201 (OpNode (v4i32 V128:$Rd),
6202 (extract_high_v8i16 V128:$Rn),
6203 (extract_high_v8i16 V128:$Rm)))]>;
6204 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
6206 asm, ".2d", ".2s", ".2s",
6207 [(set (v2i64 V128:$dst),
6208 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>;
6209 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
6211 asm#"2", ".2d", ".4s", ".4s",
6212 [(set (v2i64 V128:$dst),
6213 (OpNode (v2i64 V128:$Rd),
6214 (extract_high_v4i32 V128:$Rn),
6215 (extract_high_v4i32 V128:$Rm)))]>;
6218 multiclass SIMDLongThreeVectorSQDMLXTiedHS<bit U, bits<4> opc, string asm,
6219 SDPatternOperator Accum> {
6220 def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b010, opc,
6222 asm, ".4s", ".4h", ".4h",
6223 [(set (v4i32 V128:$dst),
6224 (Accum (v4i32 V128:$Rd),
6225 (v4i32 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn),
6226 (v4i16 V64:$Rm)))))]>;
6227 def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied<U, 0b011, opc,
6229 asm#"2", ".4s", ".8h", ".8h",
6230 [(set (v4i32 V128:$dst),
6231 (Accum (v4i32 V128:$Rd),
6232 (v4i32 (int_aarch64_neon_sqdmull (extract_high_v8i16 V128:$Rn),
6233 (extract_high_v8i16 V128:$Rm)))))]>;
6234 def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b100, opc,
6236 asm, ".2d", ".2s", ".2s",
6237 [(set (v2i64 V128:$dst),
6238 (Accum (v2i64 V128:$Rd),
6239 (v2i64 (int_aarch64_neon_sqdmull (v2i32 V64:$Rn),
6240 (v2i32 V64:$Rm)))))]>;
6241 def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied<U, 0b101, opc,
6243 asm#"2", ".2d", ".4s", ".4s",
6244 [(set (v2i64 V128:$dst),
6245 (Accum (v2i64 V128:$Rd),
6246 (v2i64 (int_aarch64_neon_sqdmull (extract_high_v4i32 V128:$Rn),
6247 (extract_high_v4i32 V128:$Rm)))))]>;
6250 multiclass SIMDWideThreeVectorBHS<bit U, bits<4> opc, string asm,
6251 SDPatternOperator OpNode> {
6252 def v8i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b000, opc,
6254 asm, ".8h", ".8h", ".8b",
6255 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i8 V64:$Rm)))]>;
6256 def v16i8_v8i16 : BaseSIMDDifferentThreeVector<U, 0b001, opc,
6258 asm#"2", ".8h", ".8h", ".16b",
6259 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
6260 (extract_high_v16i8 V128:$Rm)))]>;
6261 def v4i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b010, opc,
6263 asm, ".4s", ".4s", ".4h",
6264 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i16 V64:$Rm)))]>;
6265 def v8i16_v4i32 : BaseSIMDDifferentThreeVector<U, 0b011, opc,
6267 asm#"2", ".4s", ".4s", ".8h",
6268 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
6269 (extract_high_v8i16 V128:$Rm)))]>;
6270 def v2i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b100, opc,
6272 asm, ".2d", ".2d", ".2s",
6273 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i32 V64:$Rm)))]>;
6274 def v4i32_v2i64 : BaseSIMDDifferentThreeVector<U, 0b101, opc,
6276 asm#"2", ".2d", ".2d", ".4s",
6277 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
6278 (extract_high_v4i32 V128:$Rm)))]>;
6281 //----------------------------------------------------------------------------
6282 // AdvSIMD bitwise extract from vector
6283 //----------------------------------------------------------------------------
6285 class BaseSIMDBitwiseExtract<bit size, RegisterOperand regtype, ValueType vty,
6286 string asm, string kind>
6287 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, i32imm:$imm), asm,
6288 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $imm" #
6289 "|" # kind # "\t$Rd, $Rn, $Rm, $imm}", "",
6290 [(set (vty regtype:$Rd),
6291 (AArch64ext regtype:$Rn, regtype:$Rm, (i32 imm:$imm)))]>,
6298 let Inst{30} = size;
6299 let Inst{29-21} = 0b101110000;
6300 let Inst{20-16} = Rm;
6302 let Inst{14-11} = imm;
6309 multiclass SIMDBitwiseExtract<string asm> {
6310 def v8i8 : BaseSIMDBitwiseExtract<0, V64, v8i8, asm, ".8b"> {
6313 def v16i8 : BaseSIMDBitwiseExtract<1, V128, v16i8, asm, ".16b">;
6316 //----------------------------------------------------------------------------
6317 // AdvSIMD zip vector
6318 //----------------------------------------------------------------------------
6320 class BaseSIMDZipVector<bits<3> size, bits<3> opc, RegisterOperand regtype,
6321 string asm, string kind, SDNode OpNode, ValueType valty>
6322 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
6323 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind #
6324 "|" # kind # "\t$Rd, $Rn, $Rm}", "",
6325 [(set (valty regtype:$Rd), (OpNode regtype:$Rn, regtype:$Rm))]>,
6331 let Inst{30} = size{0};
6332 let Inst{29-24} = 0b001110;
6333 let Inst{23-22} = size{2-1};
6335 let Inst{20-16} = Rm;
6337 let Inst{14-12} = opc;
6338 let Inst{11-10} = 0b10;
6343 multiclass SIMDZipVector<bits<3>opc, string asm,
6345 def v8i8 : BaseSIMDZipVector<0b000, opc, V64,
6346 asm, ".8b", OpNode, v8i8>;
6347 def v16i8 : BaseSIMDZipVector<0b001, opc, V128,
6348 asm, ".16b", OpNode, v16i8>;
6349 def v4i16 : BaseSIMDZipVector<0b010, opc, V64,
6350 asm, ".4h", OpNode, v4i16>;
6351 def v8i16 : BaseSIMDZipVector<0b011, opc, V128,
6352 asm, ".8h", OpNode, v8i16>;
6353 def v2i32 : BaseSIMDZipVector<0b100, opc, V64,
6354 asm, ".2s", OpNode, v2i32>;
6355 def v4i32 : BaseSIMDZipVector<0b101, opc, V128,
6356 asm, ".4s", OpNode, v4i32>;
6357 def v2i64 : BaseSIMDZipVector<0b111, opc, V128,
6358 asm, ".2d", OpNode, v2i64>;
6360 def : Pat<(v4f16 (OpNode V64:$Rn, V64:$Rm)),
6361 (!cast<Instruction>(NAME#"v4i16") V64:$Rn, V64:$Rm)>;
6362 def : Pat<(v8f16 (OpNode V128:$Rn, V128:$Rm)),
6363 (!cast<Instruction>(NAME#"v8i16") V128:$Rn, V128:$Rm)>;
6364 def : Pat<(v2f32 (OpNode V64:$Rn, V64:$Rm)),
6365 (!cast<Instruction>(NAME#"v2i32") V64:$Rn, V64:$Rm)>;
6366 def : Pat<(v4f32 (OpNode V128:$Rn, V128:$Rm)),
6367 (!cast<Instruction>(NAME#"v4i32") V128:$Rn, V128:$Rm)>;
6368 def : Pat<(v2f64 (OpNode V128:$Rn, V128:$Rm)),
6369 (!cast<Instruction>(NAME#"v2i64") V128:$Rn, V128:$Rm)>;
6372 //----------------------------------------------------------------------------
6373 // AdvSIMD three register scalar instructions
6374 //----------------------------------------------------------------------------
6376 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6377 class BaseSIMDThreeScalar<bit U, bits<3> size, bits<5> opcode,
6378 RegisterClass regtype, string asm,
6380 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm,
6381 "\t$Rd, $Rn, $Rm", "", pattern>,
6386 let Inst{31-30} = 0b01;
6388 let Inst{28-24} = 0b11110;
6389 let Inst{23-21} = size;
6390 let Inst{20-16} = Rm;
6391 let Inst{15-11} = opcode;
6397 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
6398 class BaseSIMDThreeScalarTied<bit U, bits<2> size, bit R, bits<5> opcode,
6399 dag oops, dag iops, string asm,
6401 : I<oops, iops, asm, "\t$Rd, $Rn, $Rm", "$Rd = $dst", pattern>,
6406 let Inst{31-30} = 0b01;
6408 let Inst{28-24} = 0b11110;
6409 let Inst{23-22} = size;
6411 let Inst{20-16} = Rm;
6412 let Inst{15-11} = opcode;
6418 multiclass SIMDThreeScalarD<bit U, bits<5> opc, string asm,
6419 SDPatternOperator OpNode> {
6420 def v1i64 : BaseSIMDThreeScalar<U, 0b111, opc, FPR64, asm,
6421 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
6424 multiclass SIMDThreeScalarBHSD<bit U, bits<5> opc, string asm,
6425 SDPatternOperator OpNode> {
6426 def v1i64 : BaseSIMDThreeScalar<U, 0b111, opc, FPR64, asm,
6427 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn), (v1i64 FPR64:$Rm)))]>;
6428 def v1i32 : BaseSIMDThreeScalar<U, 0b101, opc, FPR32, asm, []>;
6429 def v1i16 : BaseSIMDThreeScalar<U, 0b011, opc, FPR16, asm, []>;
6430 def v1i8 : BaseSIMDThreeScalar<U, 0b001, opc, FPR8 , asm, []>;
6432 def : Pat<(i64 (OpNode (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6433 (!cast<Instruction>(NAME#"v1i64") FPR64:$Rn, FPR64:$Rm)>;
6434 def : Pat<(i32 (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm))),
6435 (!cast<Instruction>(NAME#"v1i32") FPR32:$Rn, FPR32:$Rm)>;
6438 multiclass SIMDThreeScalarHS<bit U, bits<5> opc, string asm,
6439 SDPatternOperator OpNode> {
6440 def v1i32 : BaseSIMDThreeScalar<U, 0b101, opc, FPR32, asm,
6441 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
6442 def v1i16 : BaseSIMDThreeScalar<U, 0b011, opc, FPR16, asm, []>;
6445 multiclass SIMDThreeScalarHSTied<bit U, bit R, bits<5> opc, string asm,
6446 SDPatternOperator OpNode = null_frag> {
6447 def v1i32: BaseSIMDThreeScalarTied<U, 0b10, R, opc, (outs FPR32:$dst),
6448 (ins FPR32:$Rd, FPR32:$Rn, FPR32:$Rm),
6450 def v1i16: BaseSIMDThreeScalarTied<U, 0b01, R, opc, (outs FPR16:$dst),
6451 (ins FPR16:$Rd, FPR16:$Rn, FPR16:$Rm),
6455 multiclass SIMDFPThreeScalar<bit U, bit S, bits<3> opc, string asm,
6456 SDPatternOperator OpNode = null_frag> {
6457 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6458 def #NAME#64 : BaseSIMDThreeScalar<U, {S,0b11}, {0b11,opc}, FPR64, asm,
6459 [(set (f64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
6460 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0b01}, {0b11,opc}, FPR32, asm,
6461 [(set FPR32:$Rd, (OpNode FPR32:$Rn, FPR32:$Rm))]>;
6462 let Predicates = [HasNEON, HasFullFP16] in {
6463 def #NAME#16 : BaseSIMDThreeScalar<U, {S,0b10}, {0b00,opc}, FPR16, asm,
6464 [(set FPR16:$Rd, (OpNode FPR16:$Rn, FPR16:$Rm))]>;
6465 } // Predicates = [HasNEON, HasFullFP16]
6468 def : Pat<(v1f64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
6469 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
6472 multiclass SIMDThreeScalarFPCmp<bit U, bit S, bits<3> opc, string asm,
6473 SDPatternOperator OpNode = null_frag> {
6474 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6475 def #NAME#64 : BaseSIMDThreeScalar<U, {S,0b11}, {0b11,opc}, FPR64, asm,
6476 [(set (i64 FPR64:$Rd), (OpNode (f64 FPR64:$Rn), (f64 FPR64:$Rm)))]>;
6477 def #NAME#32 : BaseSIMDThreeScalar<U, {S,0b01}, {0b11,opc}, FPR32, asm,
6478 [(set (i32 FPR32:$Rd), (OpNode (f32 FPR32:$Rn), (f32 FPR32:$Rm)))]>;
6479 let Predicates = [HasNEON, HasFullFP16] in {
6480 def #NAME#16 : BaseSIMDThreeScalar<U, {S,0b10}, {0b00,opc}, FPR16, asm,
6482 } // Predicates = [HasNEON, HasFullFP16]
6485 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
6486 (!cast<Instruction>(NAME # "64") FPR64:$Rn, FPR64:$Rm)>;
6489 class BaseSIMDThreeScalarMixed<bit U, bits<2> size, bits<5> opcode,
6490 dag oops, dag iops, string asm, string cstr, list<dag> pat>
6491 : I<oops, iops, asm,
6492 "\t$Rd, $Rn, $Rm", cstr, pat>,
6497 let Inst{31-30} = 0b01;
6499 let Inst{28-24} = 0b11110;
6500 let Inst{23-22} = size;
6502 let Inst{20-16} = Rm;
6503 let Inst{15-11} = opcode;
6509 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6510 multiclass SIMDThreeScalarMixedHS<bit U, bits<5> opc, string asm,
6511 SDPatternOperator OpNode = null_frag> {
6512 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
6514 (ins FPR16:$Rn, FPR16:$Rm), asm, "", []>;
6515 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
6517 (ins FPR32:$Rn, FPR32:$Rm), asm, "",
6518 [(set (i64 FPR64:$Rd), (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
6521 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6522 multiclass SIMDThreeScalarMixedTiedHS<bit U, bits<5> opc, string asm,
6523 SDPatternOperator OpNode = null_frag> {
6524 def i16 : BaseSIMDThreeScalarMixed<U, 0b01, opc,
6526 (ins FPR32:$Rd, FPR16:$Rn, FPR16:$Rm),
6527 asm, "$Rd = $dst", []>;
6528 def i32 : BaseSIMDThreeScalarMixed<U, 0b10, opc,
6530 (ins FPR64:$Rd, FPR32:$Rn, FPR32:$Rm),
6532 [(set (i64 FPR64:$dst),
6533 (OpNode (i64 FPR64:$Rd), (i32 FPR32:$Rn), (i32 FPR32:$Rm)))]>;
6536 //----------------------------------------------------------------------------
6537 // AdvSIMD two register scalar instructions
6538 //----------------------------------------------------------------------------
6540 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6541 class BaseSIMDTwoScalar<bit U, bits<2> size, bits<2> size2, bits<5> opcode,
6542 RegisterClass regtype, RegisterClass regtype2,
6543 string asm, list<dag> pat>
6544 : I<(outs regtype:$Rd), (ins regtype2:$Rn), asm,
6545 "\t$Rd, $Rn", "", pat>,
6549 let Inst{31-30} = 0b01;
6551 let Inst{28-24} = 0b11110;
6552 let Inst{23-22} = size;
6554 let Inst{20-19} = size2;
6555 let Inst{18-17} = 0b00;
6556 let Inst{16-12} = opcode;
6557 let Inst{11-10} = 0b10;
6562 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6563 class BaseSIMDTwoScalarTied<bit U, bits<2> size, bits<5> opcode,
6564 RegisterClass regtype, RegisterClass regtype2,
6565 string asm, list<dag> pat>
6566 : I<(outs regtype:$dst), (ins regtype:$Rd, regtype2:$Rn), asm,
6567 "\t$Rd, $Rn", "$Rd = $dst", pat>,
6571 let Inst{31-30} = 0b01;
6573 let Inst{28-24} = 0b11110;
6574 let Inst{23-22} = size;
6575 let Inst{21-17} = 0b10000;
6576 let Inst{16-12} = opcode;
6577 let Inst{11-10} = 0b10;
6583 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6584 class BaseSIMDCmpTwoScalar<bit U, bits<2> size, bits<2> size2, bits<5> opcode,
6585 RegisterClass regtype, string asm, string zero>
6586 : I<(outs regtype:$Rd), (ins regtype:$Rn), asm,
6587 "\t$Rd, $Rn, #" # zero, "", []>,
6591 let Inst{31-30} = 0b01;
6593 let Inst{28-24} = 0b11110;
6594 let Inst{23-22} = size;
6596 let Inst{20-19} = size2;
6597 let Inst{18-17} = 0b00;
6598 let Inst{16-12} = opcode;
6599 let Inst{11-10} = 0b10;
6604 class SIMDInexactCvtTwoScalar<bits<5> opcode, string asm>
6605 : I<(outs FPR32:$Rd), (ins FPR64:$Rn), asm, "\t$Rd, $Rn", "",
6606 [(set (f32 FPR32:$Rd), (int_aarch64_sisd_fcvtxn (f64 FPR64:$Rn)))]>,
6610 let Inst{31-17} = 0b011111100110000;
6611 let Inst{16-12} = opcode;
6612 let Inst{11-10} = 0b10;
6617 multiclass SIMDCmpTwoScalarD<bit U, bits<5> opc, string asm,
6618 SDPatternOperator OpNode> {
6619 def v1i64rz : BaseSIMDCmpTwoScalar<U, 0b11, 0b00, opc, FPR64, asm, "0">;
6621 def : Pat<(v1i64 (OpNode FPR64:$Rn)),
6622 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
6625 multiclass SIMDFPCmpTwoScalar<bit U, bit S, bits<5> opc, string asm,
6626 SDPatternOperator OpNode> {
6627 def v1i64rz : BaseSIMDCmpTwoScalar<U, {S,1}, 0b00, opc, FPR64, asm, "0.0">;
6628 def v1i32rz : BaseSIMDCmpTwoScalar<U, {S,0}, 0b00, opc, FPR32, asm, "0.0">;
6629 let Predicates = [HasNEON, HasFullFP16] in {
6630 def v1i16rz : BaseSIMDCmpTwoScalar<U, {S,1}, 0b11, opc, FPR16, asm, "0.0">;
6633 def : InstAlias<asm # "\t$Rd, $Rn, #0",
6634 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rd, FPR64:$Rn), 0>;
6635 def : InstAlias<asm # "\t$Rd, $Rn, #0",
6636 (!cast<Instruction>(NAME # v1i32rz) FPR32:$Rd, FPR32:$Rn), 0>;
6637 let Predicates = [HasNEON, HasFullFP16] in {
6638 def : InstAlias<asm # "\t$Rd, $Rn, #0",
6639 (!cast<Instruction>(NAME # v1i16rz) FPR16:$Rd, FPR16:$Rn), 0>;
6642 def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn))),
6643 (!cast<Instruction>(NAME # v1i64rz) FPR64:$Rn)>;
6646 multiclass SIMDTwoScalarD<bit U, bits<5> opc, string asm,
6647 SDPatternOperator OpNode = null_frag> {
6648 def v1i64 : BaseSIMDTwoScalar<U, 0b11, 0b00, opc, FPR64, FPR64, asm,
6649 [(set (v1i64 FPR64:$Rd), (OpNode (v1i64 FPR64:$Rn)))]>;
6651 def : Pat<(i64 (OpNode (i64 FPR64:$Rn))),
6652 (!cast<Instruction>(NAME # "v1i64") FPR64:$Rn)>;
6655 multiclass SIMDFPTwoScalar<bit U, bit S, bits<5> opc, string asm> {
6656 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, 0b00, opc, FPR64, FPR64, asm,[]>;
6657 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, 0b00, opc, FPR32, FPR32, asm,[]>;
6658 let Predicates = [HasNEON, HasFullFP16] in {
6659 def v1f16 : BaseSIMDTwoScalar<U, {S,1}, 0b11, opc, FPR16, FPR16, asm,[]>;
6663 multiclass SIMDFPTwoScalarCVT<bit U, bit S, bits<5> opc, string asm,
6664 SDPatternOperator OpNode> {
6665 def v1i64 : BaseSIMDTwoScalar<U, {S,1}, 0b00, opc, FPR64, FPR64, asm,
6666 [(set FPR64:$Rd, (OpNode (f64 FPR64:$Rn)))]>;
6667 def v1i32 : BaseSIMDTwoScalar<U, {S,0}, 0b00, opc, FPR32, FPR32, asm,
6668 [(set FPR32:$Rd, (OpNode (f32 FPR32:$Rn)))]>;
6669 let Predicates = [HasNEON, HasFullFP16] in {
6670 def v1i16 : BaseSIMDTwoScalar<U, {S,1}, 0b11, opc, FPR16, FPR16, asm,
6671 [(set FPR16:$Rd, (OpNode (f16 FPR16:$Rn)))]>;
6675 multiclass SIMDTwoScalarBHSD<bit U, bits<5> opc, string asm,
6676 SDPatternOperator OpNode = null_frag> {
6677 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6678 def v1i64 : BaseSIMDTwoScalar<U, 0b11, 0b00, opc, FPR64, FPR64, asm,
6679 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
6680 def v1i32 : BaseSIMDTwoScalar<U, 0b10, 0b00, opc, FPR32, FPR32, asm,
6681 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
6682 def v1i16 : BaseSIMDTwoScalar<U, 0b01, 0b00, opc, FPR16, FPR16, asm, []>;
6683 def v1i8 : BaseSIMDTwoScalar<U, 0b00, 0b00, opc, FPR8 , FPR8 , asm, []>;
6686 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn))),
6687 (!cast<Instruction>(NAME # v1i64) FPR64:$Rn)>;
6690 multiclass SIMDTwoScalarBHSDTied<bit U, bits<5> opc, string asm,
6692 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
6693 def v1i64 : BaseSIMDTwoScalarTied<U, 0b11, opc, FPR64, FPR64, asm,
6694 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn)))]>;
6695 def v1i32 : BaseSIMDTwoScalarTied<U, 0b10, opc, FPR32, FPR32, asm,
6696 [(set (i32 FPR32:$dst), (OpNode (i32 FPR32:$Rd), (i32 FPR32:$Rn)))]>;
6697 def v1i16 : BaseSIMDTwoScalarTied<U, 0b01, opc, FPR16, FPR16, asm, []>;
6698 def v1i8 : BaseSIMDTwoScalarTied<U, 0b00, opc, FPR8 , FPR8 , asm, []>;
6701 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn))),
6702 (!cast<Instruction>(NAME # v1i64) FPR64:$Rd, FPR64:$Rn)>;
6707 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6708 multiclass SIMDTwoScalarMixedBHS<bit U, bits<5> opc, string asm,
6709 SDPatternOperator OpNode = null_frag> {
6710 def v1i32 : BaseSIMDTwoScalar<U, 0b10, 0b00, opc, FPR32, FPR64, asm,
6711 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn)))]>;
6712 def v1i16 : BaseSIMDTwoScalar<U, 0b01, 0b00, opc, FPR16, FPR32, asm, []>;
6713 def v1i8 : BaseSIMDTwoScalar<U, 0b00, 0b00, opc, FPR8 , FPR16, asm, []>;
6716 //----------------------------------------------------------------------------
6717 // AdvSIMD scalar pairwise instructions
6718 //----------------------------------------------------------------------------
6720 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6721 class BaseSIMDPairwiseScalar<bit U, bits<2> size, bits<5> opcode,
6722 RegisterOperand regtype, RegisterOperand vectype,
6723 string asm, string kind>
6724 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
6725 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", []>,
6729 let Inst{31-30} = 0b01;
6731 let Inst{28-24} = 0b11110;
6732 let Inst{23-22} = size;
6733 let Inst{21-17} = 0b11000;
6734 let Inst{16-12} = opcode;
6735 let Inst{11-10} = 0b10;
6740 multiclass SIMDPairwiseScalarD<bit U, bits<5> opc, string asm> {
6741 def v2i64p : BaseSIMDPairwiseScalar<U, 0b11, opc, FPR64Op, V128,
6745 multiclass SIMDFPPairwiseScalar<bit S, bits<5> opc, string asm> {
6746 let Predicates = [HasNEON, HasFullFP16] in {
6747 def v2i16p : BaseSIMDPairwiseScalar<0, {S,0}, opc, FPR16Op, V64,
6750 def v2i32p : BaseSIMDPairwiseScalar<1, {S,0}, opc, FPR32Op, V64,
6752 def v2i64p : BaseSIMDPairwiseScalar<1, {S,1}, opc, FPR64Op, V128,
6756 //----------------------------------------------------------------------------
6757 // AdvSIMD across lanes instructions
6758 //----------------------------------------------------------------------------
6760 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
6761 class BaseSIMDAcrossLanes<bit Q, bit U, bits<2> size, bits<5> opcode,
6762 RegisterClass regtype, RegisterOperand vectype,
6763 string asm, string kind, list<dag> pattern>
6764 : I<(outs regtype:$Rd), (ins vectype:$Rn), asm,
6765 "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", pattern>,
6772 let Inst{28-24} = 0b01110;
6773 let Inst{23-22} = size;
6774 let Inst{21-17} = 0b11000;
6775 let Inst{16-12} = opcode;
6776 let Inst{11-10} = 0b10;
6781 multiclass SIMDAcrossLanesBHS<bit U, bits<5> opcode,
6783 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR8, V64,
6785 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR8, V128,
6787 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR16, V64,
6789 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR16, V128,
6791 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR32, V128,
6795 multiclass SIMDAcrossLanesHSD<bit U, bits<5> opcode, string asm> {
6796 def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR16, V64,
6798 def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR16, V128,
6800 def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR32, V64,
6802 def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR32, V128,
6804 def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR64, V128,
6808 multiclass SIMDFPAcrossLanes<bits<5> opcode, bit sz1, string asm,
6810 let Predicates = [HasNEON, HasFullFP16] in {
6811 def v4i16v : BaseSIMDAcrossLanes<0, 0, {sz1, 0}, opcode, FPR16, V64,
6813 [(set FPR16:$Rd, (intOp (v4f16 V64:$Rn)))]>;
6814 def v8i16v : BaseSIMDAcrossLanes<1, 0, {sz1, 0}, opcode, FPR16, V128,
6816 [(set FPR16:$Rd, (intOp (v8f16 V128:$Rn)))]>;
6817 } // Predicates = [HasNEON, HasFullFP16]
6818 def v4i32v : BaseSIMDAcrossLanes<1, 1, {sz1, 0}, opcode, FPR32, V128,
6820 [(set FPR32:$Rd, (intOp (v4f32 V128:$Rn)))]>;
6823 //----------------------------------------------------------------------------
6824 // AdvSIMD INS/DUP instructions
6825 //----------------------------------------------------------------------------
6827 // FIXME: There has got to be a better way to factor these. ugh.
6829 class BaseSIMDInsDup<bit Q, bit op, dag outs, dag ins, string asm,
6830 string operands, string constraints, list<dag> pattern>
6831 : I<outs, ins, asm, operands, constraints, pattern>,
6838 let Inst{28-21} = 0b01110000;
6845 class SIMDDupFromMain<bit Q, bits<5> imm5, string size, ValueType vectype,
6846 RegisterOperand vecreg, RegisterClass regtype>
6847 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins regtype:$Rn), "dup",
6848 "{\t$Rd" # size # ", $Rn" #
6849 "|" # size # "\t$Rd, $Rn}", "",
6850 [(set (vectype vecreg:$Rd), (AArch64dup regtype:$Rn))]> {
6851 let Inst{20-16} = imm5;
6852 let Inst{14-11} = 0b0001;
6855 class SIMDDupFromElement<bit Q, string dstkind, string srckind,
6856 ValueType vectype, ValueType insreg,
6857 RegisterOperand vecreg, Operand idxtype,
6858 ValueType elttype, SDNode OpNode>
6859 : BaseSIMDInsDup<Q, 0, (outs vecreg:$Rd), (ins V128:$Rn, idxtype:$idx), "dup",
6860 "{\t$Rd" # dstkind # ", $Rn" # srckind # "$idx" #
6861 "|" # dstkind # "\t$Rd, $Rn$idx}", "",
6862 [(set (vectype vecreg:$Rd),
6863 (OpNode (insreg V128:$Rn), idxtype:$idx))]> {
6864 let Inst{14-11} = 0b0000;
6867 class SIMDDup64FromElement
6868 : SIMDDupFromElement<1, ".2d", ".d", v2i64, v2i64, V128,
6869 VectorIndexD, i64, AArch64duplane64> {
6872 let Inst{19-16} = 0b1000;
6875 class SIMDDup32FromElement<bit Q, string size, ValueType vectype,
6876 RegisterOperand vecreg>
6877 : SIMDDupFromElement<Q, size, ".s", vectype, v4i32, vecreg,
6878 VectorIndexS, i64, AArch64duplane32> {
6880 let Inst{20-19} = idx;
6881 let Inst{18-16} = 0b100;
6884 class SIMDDup16FromElement<bit Q, string size, ValueType vectype,
6885 RegisterOperand vecreg>
6886 : SIMDDupFromElement<Q, size, ".h", vectype, v8i16, vecreg,
6887 VectorIndexH, i64, AArch64duplane16> {
6889 let Inst{20-18} = idx;
6890 let Inst{17-16} = 0b10;
6893 class SIMDDup8FromElement<bit Q, string size, ValueType vectype,
6894 RegisterOperand vecreg>
6895 : SIMDDupFromElement<Q, size, ".b", vectype, v16i8, vecreg,
6896 VectorIndexB, i64, AArch64duplane8> {
6898 let Inst{20-17} = idx;
6902 class BaseSIMDMov<bit Q, string size, bits<4> imm4, RegisterClass regtype,
6903 Operand idxtype, string asm, list<dag> pattern>
6904 : BaseSIMDInsDup<Q, 0, (outs regtype:$Rd), (ins V128:$Rn, idxtype:$idx), asm,
6905 "{\t$Rd, $Rn" # size # "$idx" #
6906 "|" # size # "\t$Rd, $Rn$idx}", "", pattern> {
6907 let Inst{14-11} = imm4;
6910 class SIMDSMov<bit Q, string size, RegisterClass regtype,
6912 : BaseSIMDMov<Q, size, 0b0101, regtype, idxtype, "smov", []>;
6913 class SIMDUMov<bit Q, string size, ValueType vectype, RegisterClass regtype,
6915 : BaseSIMDMov<Q, size, 0b0111, regtype, idxtype, "umov",
6916 [(set regtype:$Rd, (vector_extract (vectype V128:$Rn), idxtype:$idx))]>;
6918 class SIMDMovAlias<string asm, string size, Instruction inst,
6919 RegisterClass regtype, Operand idxtype>
6920 : InstAlias<asm#"{\t$dst, $src"#size#"$idx" #
6921 "|" # size # "\t$dst, $src$idx}",
6922 (inst regtype:$dst, V128:$src, idxtype:$idx)>;
6925 def vi8to32 : SIMDSMov<0, ".b", GPR32, VectorIndexB> {
6927 let Inst{20-17} = idx;
6930 def vi8to64 : SIMDSMov<1, ".b", GPR64, VectorIndexB> {
6932 let Inst{20-17} = idx;
6935 def vi16to32 : SIMDSMov<0, ".h", GPR32, VectorIndexH> {
6937 let Inst{20-18} = idx;
6938 let Inst{17-16} = 0b10;
6940 def vi16to64 : SIMDSMov<1, ".h", GPR64, VectorIndexH> {
6942 let Inst{20-18} = idx;
6943 let Inst{17-16} = 0b10;
6945 def vi32to64 : SIMDSMov<1, ".s", GPR64, VectorIndexS> {
6947 let Inst{20-19} = idx;
6948 let Inst{18-16} = 0b100;
6953 def vi8 : SIMDUMov<0, ".b", v16i8, GPR32, VectorIndexB> {
6955 let Inst{20-17} = idx;
6958 def vi16 : SIMDUMov<0, ".h", v8i16, GPR32, VectorIndexH> {
6960 let Inst{20-18} = idx;
6961 let Inst{17-16} = 0b10;
6963 def vi32 : SIMDUMov<0, ".s", v4i32, GPR32, VectorIndexS> {
6965 let Inst{20-19} = idx;
6966 let Inst{18-16} = 0b100;
6968 def vi64 : SIMDUMov<1, ".d", v2i64, GPR64, VectorIndexD> {
6971 let Inst{19-16} = 0b1000;
6973 def : SIMDMovAlias<"mov", ".s",
6974 !cast<Instruction>(NAME#"vi32"),
6975 GPR32, VectorIndexS>;
6976 def : SIMDMovAlias<"mov", ".d",
6977 !cast<Instruction>(NAME#"vi64"),
6978 GPR64, VectorIndexD>;
6981 class SIMDInsFromMain<string size, ValueType vectype,
6982 RegisterClass regtype, Operand idxtype>
6983 : BaseSIMDInsDup<1, 0, (outs V128:$dst),
6984 (ins V128:$Rd, idxtype:$idx, regtype:$Rn), "ins",
6985 "{\t$Rd" # size # "$idx, $Rn" #
6986 "|" # size # "\t$Rd$idx, $Rn}",
6989 (vector_insert (vectype V128:$Rd), regtype:$Rn, idxtype:$idx))]> {
6990 let Inst{14-11} = 0b0011;
6993 class SIMDInsFromElement<string size, ValueType vectype,
6994 ValueType elttype, Operand idxtype>
6995 : BaseSIMDInsDup<1, 1, (outs V128:$dst),
6996 (ins V128:$Rd, idxtype:$idx, V128:$Rn, idxtype:$idx2), "ins",
6997 "{\t$Rd" # size # "$idx, $Rn" # size # "$idx2" #
6998 "|" # size # "\t$Rd$idx, $Rn$idx2}",
7003 (elttype (vector_extract (vectype V128:$Rn), idxtype:$idx2)),
7006 class SIMDInsMainMovAlias<string size, Instruction inst,
7007 RegisterClass regtype, Operand idxtype>
7008 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" #
7009 "|" # size #"\t$dst$idx, $src}",
7010 (inst V128:$dst, idxtype:$idx, regtype:$src)>;
7011 class SIMDInsElementMovAlias<string size, Instruction inst,
7013 : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" # size # "$idx2" #
7014 # "|" # size #"\t$dst$idx, $src$idx2}",
7015 (inst V128:$dst, idxtype:$idx, V128:$src, idxtype:$idx2)>;
7018 multiclass SIMDIns {
7019 def vi8gpr : SIMDInsFromMain<".b", v16i8, GPR32, VectorIndexB> {
7021 let Inst{20-17} = idx;
7024 def vi16gpr : SIMDInsFromMain<".h", v8i16, GPR32, VectorIndexH> {
7026 let Inst{20-18} = idx;
7027 let Inst{17-16} = 0b10;
7029 def vi32gpr : SIMDInsFromMain<".s", v4i32, GPR32, VectorIndexS> {
7031 let Inst{20-19} = idx;
7032 let Inst{18-16} = 0b100;
7034 def vi64gpr : SIMDInsFromMain<".d", v2i64, GPR64, VectorIndexD> {
7037 let Inst{19-16} = 0b1000;
7040 def vi8lane : SIMDInsFromElement<".b", v16i8, i32, VectorIndexB> {
7043 let Inst{20-17} = idx;
7045 let Inst{14-11} = idx2;
7047 def vi16lane : SIMDInsFromElement<".h", v8i16, i32, VectorIndexH> {
7050 let Inst{20-18} = idx;
7051 let Inst{17-16} = 0b10;
7052 let Inst{14-12} = idx2;
7055 def vi32lane : SIMDInsFromElement<".s", v4i32, i32, VectorIndexS> {
7058 let Inst{20-19} = idx;
7059 let Inst{18-16} = 0b100;
7060 let Inst{14-13} = idx2;
7061 let Inst{12-11} = {?,?};
7063 def vi64lane : SIMDInsFromElement<".d", v2i64, i64, VectorIndexD> {
7067 let Inst{19-16} = 0b1000;
7068 let Inst{14} = idx2;
7069 let Inst{13-11} = {?,?,?};
7072 // For all forms of the INS instruction, the "mov" mnemonic is the
7073 // preferred alias. Why they didn't just call the instruction "mov" in
7074 // the first place is a very good question indeed...
7075 def : SIMDInsMainMovAlias<".b", !cast<Instruction>(NAME#"vi8gpr"),
7076 GPR32, VectorIndexB>;
7077 def : SIMDInsMainMovAlias<".h", !cast<Instruction>(NAME#"vi16gpr"),
7078 GPR32, VectorIndexH>;
7079 def : SIMDInsMainMovAlias<".s", !cast<Instruction>(NAME#"vi32gpr"),
7080 GPR32, VectorIndexS>;
7081 def : SIMDInsMainMovAlias<".d", !cast<Instruction>(NAME#"vi64gpr"),
7082 GPR64, VectorIndexD>;
7084 def : SIMDInsElementMovAlias<".b", !cast<Instruction>(NAME#"vi8lane"),
7086 def : SIMDInsElementMovAlias<".h", !cast<Instruction>(NAME#"vi16lane"),
7088 def : SIMDInsElementMovAlias<".s", !cast<Instruction>(NAME#"vi32lane"),
7090 def : SIMDInsElementMovAlias<".d", !cast<Instruction>(NAME#"vi64lane"),
7094 //----------------------------------------------------------------------------
7096 //----------------------------------------------------------------------------
7098 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7099 class BaseSIMDTableLookup<bit Q, bits<2> len, bit op, RegisterOperand vectype,
7100 RegisterOperand listtype, string asm, string kind>
7101 : I<(outs vectype:$Vd), (ins listtype:$Vn, vectype:$Vm), asm,
7102 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "", []>,
7109 let Inst{29-21} = 0b001110000;
7110 let Inst{20-16} = Vm;
7112 let Inst{14-13} = len;
7114 let Inst{11-10} = 0b00;
7119 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
7120 class BaseSIMDTableLookupTied<bit Q, bits<2> len, bit op, RegisterOperand vectype,
7121 RegisterOperand listtype, string asm, string kind>
7122 : I<(outs vectype:$dst), (ins vectype:$Vd, listtype:$Vn, vectype:$Vm), asm,
7123 "\t$Vd" # kind # ", $Vn, $Vm" # kind, "$Vd = $dst", []>,
7130 let Inst{29-21} = 0b001110000;
7131 let Inst{20-16} = Vm;
7133 let Inst{14-13} = len;
7135 let Inst{11-10} = 0b00;
7140 class SIMDTableLookupAlias<string asm, Instruction inst,
7141 RegisterOperand vectype, RegisterOperand listtype>
7142 : InstAlias<!strconcat(asm, "\t$dst, $lst, $index"),
7143 (inst vectype:$dst, listtype:$lst, vectype:$index), 0>;
7145 multiclass SIMDTableLookup<bit op, string asm> {
7146 def v8i8One : BaseSIMDTableLookup<0, 0b00, op, V64, VecListOne16b,
7148 def v8i8Two : BaseSIMDTableLookup<0, 0b01, op, V64, VecListTwo16b,
7150 def v8i8Three : BaseSIMDTableLookup<0, 0b10, op, V64, VecListThree16b,
7152 def v8i8Four : BaseSIMDTableLookup<0, 0b11, op, V64, VecListFour16b,
7154 def v16i8One : BaseSIMDTableLookup<1, 0b00, op, V128, VecListOne16b,
7156 def v16i8Two : BaseSIMDTableLookup<1, 0b01, op, V128, VecListTwo16b,
7158 def v16i8Three: BaseSIMDTableLookup<1, 0b10, op, V128, VecListThree16b,
7160 def v16i8Four : BaseSIMDTableLookup<1, 0b11, op, V128, VecListFour16b,
7163 def : SIMDTableLookupAlias<asm # ".8b",
7164 !cast<Instruction>(NAME#"v8i8One"),
7165 V64, VecListOne128>;
7166 def : SIMDTableLookupAlias<asm # ".8b",
7167 !cast<Instruction>(NAME#"v8i8Two"),
7168 V64, VecListTwo128>;
7169 def : SIMDTableLookupAlias<asm # ".8b",
7170 !cast<Instruction>(NAME#"v8i8Three"),
7171 V64, VecListThree128>;
7172 def : SIMDTableLookupAlias<asm # ".8b",
7173 !cast<Instruction>(NAME#"v8i8Four"),
7174 V64, VecListFour128>;
7175 def : SIMDTableLookupAlias<asm # ".16b",
7176 !cast<Instruction>(NAME#"v16i8One"),
7177 V128, VecListOne128>;
7178 def : SIMDTableLookupAlias<asm # ".16b",
7179 !cast<Instruction>(NAME#"v16i8Two"),
7180 V128, VecListTwo128>;
7181 def : SIMDTableLookupAlias<asm # ".16b",
7182 !cast<Instruction>(NAME#"v16i8Three"),
7183 V128, VecListThree128>;
7184 def : SIMDTableLookupAlias<asm # ".16b",
7185 !cast<Instruction>(NAME#"v16i8Four"),
7186 V128, VecListFour128>;
7189 multiclass SIMDTableLookupTied<bit op, string asm> {
7190 def v8i8One : BaseSIMDTableLookupTied<0, 0b00, op, V64, VecListOne16b,
7192 def v8i8Two : BaseSIMDTableLookupTied<0, 0b01, op, V64, VecListTwo16b,
7194 def v8i8Three : BaseSIMDTableLookupTied<0, 0b10, op, V64, VecListThree16b,
7196 def v8i8Four : BaseSIMDTableLookupTied<0, 0b11, op, V64, VecListFour16b,
7198 def v16i8One : BaseSIMDTableLookupTied<1, 0b00, op, V128, VecListOne16b,
7200 def v16i8Two : BaseSIMDTableLookupTied<1, 0b01, op, V128, VecListTwo16b,
7202 def v16i8Three: BaseSIMDTableLookupTied<1, 0b10, op, V128, VecListThree16b,
7204 def v16i8Four : BaseSIMDTableLookupTied<1, 0b11, op, V128, VecListFour16b,
7207 def : SIMDTableLookupAlias<asm # ".8b",
7208 !cast<Instruction>(NAME#"v8i8One"),
7209 V64, VecListOne128>;
7210 def : SIMDTableLookupAlias<asm # ".8b",
7211 !cast<Instruction>(NAME#"v8i8Two"),
7212 V64, VecListTwo128>;
7213 def : SIMDTableLookupAlias<asm # ".8b",
7214 !cast<Instruction>(NAME#"v8i8Three"),
7215 V64, VecListThree128>;
7216 def : SIMDTableLookupAlias<asm # ".8b",
7217 !cast<Instruction>(NAME#"v8i8Four"),
7218 V64, VecListFour128>;
7219 def : SIMDTableLookupAlias<asm # ".16b",
7220 !cast<Instruction>(NAME#"v16i8One"),
7221 V128, VecListOne128>;
7222 def : SIMDTableLookupAlias<asm # ".16b",
7223 !cast<Instruction>(NAME#"v16i8Two"),
7224 V128, VecListTwo128>;
7225 def : SIMDTableLookupAlias<asm # ".16b",
7226 !cast<Instruction>(NAME#"v16i8Three"),
7227 V128, VecListThree128>;
7228 def : SIMDTableLookupAlias<asm # ".16b",
7229 !cast<Instruction>(NAME#"v16i8Four"),
7230 V128, VecListFour128>;
7234 //----------------------------------------------------------------------------
7235 // AdvSIMD scalar CPY
7236 //----------------------------------------------------------------------------
7237 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
7238 class BaseSIMDScalarCPY<RegisterClass regtype, RegisterOperand vectype,
7239 string kind, Operand idxtype>
7240 : I<(outs regtype:$dst), (ins vectype:$src, idxtype:$idx), "mov",
7241 "{\t$dst, $src" # kind # "$idx" #
7242 "|\t$dst, $src$idx}", "", []>,
7246 let Inst{31-21} = 0b01011110000;
7247 let Inst{15-10} = 0b000001;
7248 let Inst{9-5} = src;
7249 let Inst{4-0} = dst;
7252 class SIMDScalarCPYAlias<string asm, string size, Instruction inst,
7253 RegisterClass regtype, RegisterOperand vectype, Operand idxtype>
7254 : InstAlias<asm # "{\t$dst, $src" # size # "$index" #
7255 # "|\t$dst, $src$index}",
7256 (inst regtype:$dst, vectype:$src, idxtype:$index), 0>;
7259 multiclass SIMDScalarCPY<string asm> {
7260 def i8 : BaseSIMDScalarCPY<FPR8, V128, ".b", VectorIndexB> {
7262 let Inst{20-17} = idx;
7265 def i16 : BaseSIMDScalarCPY<FPR16, V128, ".h", VectorIndexH> {
7267 let Inst{20-18} = idx;
7268 let Inst{17-16} = 0b10;
7270 def i32 : BaseSIMDScalarCPY<FPR32, V128, ".s", VectorIndexS> {
7272 let Inst{20-19} = idx;
7273 let Inst{18-16} = 0b100;
7275 def i64 : BaseSIMDScalarCPY<FPR64, V128, ".d", VectorIndexD> {
7278 let Inst{19-16} = 0b1000;
7281 def : Pat<(v1i64 (scalar_to_vector (i64 (vector_extract (v2i64 V128:$src),
7282 VectorIndexD:$idx)))),
7283 (!cast<Instruction>(NAME # i64) V128:$src, VectorIndexD:$idx)>;
7285 // 'DUP' mnemonic aliases.
7286 def : SIMDScalarCPYAlias<"dup", ".b",
7287 !cast<Instruction>(NAME#"i8"),
7288 FPR8, V128, VectorIndexB>;
7289 def : SIMDScalarCPYAlias<"dup", ".h",
7290 !cast<Instruction>(NAME#"i16"),
7291 FPR16, V128, VectorIndexH>;
7292 def : SIMDScalarCPYAlias<"dup", ".s",
7293 !cast<Instruction>(NAME#"i32"),
7294 FPR32, V128, VectorIndexS>;
7295 def : SIMDScalarCPYAlias<"dup", ".d",
7296 !cast<Instruction>(NAME#"i64"),
7297 FPR64, V128, VectorIndexD>;
7300 //----------------------------------------------------------------------------
7301 // AdvSIMD modified immediate instructions
7302 //----------------------------------------------------------------------------
7304 class BaseSIMDModifiedImm<bit Q, bit op, bit op2, dag oops, dag iops,
7305 string asm, string op_string,
7306 string cstr, list<dag> pattern>
7307 : I<oops, iops, asm, op_string, cstr, pattern>,
7314 let Inst{28-19} = 0b0111100000;
7315 let Inst{18-16} = imm8{7-5};
7318 let Inst{9-5} = imm8{4-0};
7322 class BaseSIMDModifiedImmVector<bit Q, bit op, bit op2, RegisterOperand vectype,
7323 Operand immtype, dag opt_shift_iop,
7324 string opt_shift, string asm, string kind,
7326 : BaseSIMDModifiedImm<Q, op, op2, (outs vectype:$Rd),
7327 !con((ins immtype:$imm8), opt_shift_iop), asm,
7328 "{\t$Rd" # kind # ", $imm8" # opt_shift #
7329 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
7331 let DecoderMethod = "DecodeModImmInstruction";
7334 class BaseSIMDModifiedImmVectorTied<bit Q, bit op, RegisterOperand vectype,
7335 Operand immtype, dag opt_shift_iop,
7336 string opt_shift, string asm, string kind,
7338 : BaseSIMDModifiedImm<Q, op, 0, (outs vectype:$dst),
7339 !con((ins vectype:$Rd, immtype:$imm8), opt_shift_iop),
7340 asm, "{\t$Rd" # kind # ", $imm8" # opt_shift #
7341 "|" # kind # "\t$Rd, $imm8" # opt_shift # "}",
7342 "$Rd = $dst", pattern> {
7343 let DecoderMethod = "DecodeModImmTiedInstruction";
7346 class BaseSIMDModifiedImmVectorShift<bit Q, bit op, bits<2> b15_b12,
7347 RegisterOperand vectype, string asm,
7348 string kind, list<dag> pattern>
7349 : BaseSIMDModifiedImmVector<Q, op, 0, vectype, imm0_255,
7350 (ins logical_vec_shift:$shift),
7351 "$shift", asm, kind, pattern> {
7353 let Inst{15} = b15_b12{1};
7354 let Inst{14-13} = shift;
7355 let Inst{12} = b15_b12{0};
7358 class BaseSIMDModifiedImmVectorShiftTied<bit Q, bit op, bits<2> b15_b12,
7359 RegisterOperand vectype, string asm,
7360 string kind, list<dag> pattern>
7361 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
7362 (ins logical_vec_shift:$shift),
7363 "$shift", asm, kind, pattern> {
7365 let Inst{15} = b15_b12{1};
7366 let Inst{14-13} = shift;
7367 let Inst{12} = b15_b12{0};
7371 class BaseSIMDModifiedImmVectorShiftHalf<bit Q, bit op, bits<2> b15_b12,
7372 RegisterOperand vectype, string asm,
7373 string kind, list<dag> pattern>
7374 : BaseSIMDModifiedImmVector<Q, op, 0, vectype, imm0_255,
7375 (ins logical_vec_hw_shift:$shift),
7376 "$shift", asm, kind, pattern> {
7378 let Inst{15} = b15_b12{1};
7380 let Inst{13} = shift{0};
7381 let Inst{12} = b15_b12{0};
7384 class BaseSIMDModifiedImmVectorShiftHalfTied<bit Q, bit op, bits<2> b15_b12,
7385 RegisterOperand vectype, string asm,
7386 string kind, list<dag> pattern>
7387 : BaseSIMDModifiedImmVectorTied<Q, op, vectype, imm0_255,
7388 (ins logical_vec_hw_shift:$shift),
7389 "$shift", asm, kind, pattern> {
7391 let Inst{15} = b15_b12{1};
7393 let Inst{13} = shift{0};
7394 let Inst{12} = b15_b12{0};
7397 multiclass SIMDModifiedImmVectorShift<bit op, bits<2> hw_cmode, bits<2> w_cmode,
7399 def v4i16 : BaseSIMDModifiedImmVectorShiftHalf<0, op, hw_cmode, V64,
7401 def v8i16 : BaseSIMDModifiedImmVectorShiftHalf<1, op, hw_cmode, V128,
7404 def v2i32 : BaseSIMDModifiedImmVectorShift<0, op, w_cmode, V64,
7406 def v4i32 : BaseSIMDModifiedImmVectorShift<1, op, w_cmode, V128,
7410 multiclass SIMDModifiedImmVectorShiftTied<bit op, bits<2> hw_cmode,
7411 bits<2> w_cmode, string asm,
7413 def v4i16 : BaseSIMDModifiedImmVectorShiftHalfTied<0, op, hw_cmode, V64,
7415 [(set (v4i16 V64:$dst), (OpNode V64:$Rd,
7417 (i32 imm:$shift)))]>;
7418 def v8i16 : BaseSIMDModifiedImmVectorShiftHalfTied<1, op, hw_cmode, V128,
7420 [(set (v8i16 V128:$dst), (OpNode V128:$Rd,
7422 (i32 imm:$shift)))]>;
7424 def v2i32 : BaseSIMDModifiedImmVectorShiftTied<0, op, w_cmode, V64,
7426 [(set (v2i32 V64:$dst), (OpNode V64:$Rd,
7428 (i32 imm:$shift)))]>;
7429 def v4i32 : BaseSIMDModifiedImmVectorShiftTied<1, op, w_cmode, V128,
7431 [(set (v4i32 V128:$dst), (OpNode V128:$Rd,
7433 (i32 imm:$shift)))]>;
7436 class SIMDModifiedImmMoveMSL<bit Q, bit op, bits<4> cmode,
7437 RegisterOperand vectype, string asm,
7438 string kind, list<dag> pattern>
7439 : BaseSIMDModifiedImmVector<Q, op, 0, vectype, imm0_255,
7440 (ins move_vec_shift:$shift),
7441 "$shift", asm, kind, pattern> {
7443 let Inst{15-13} = cmode{3-1};
7444 let Inst{12} = shift;
7447 class SIMDModifiedImmVectorNoShift<bit Q, bit op, bit op2, bits<4> cmode,
7448 RegisterOperand vectype,
7449 Operand imm_type, string asm,
7450 string kind, list<dag> pattern>
7451 : BaseSIMDModifiedImmVector<Q, op, op2, vectype, imm_type, (ins), "",
7452 asm, kind, pattern> {
7453 let Inst{15-12} = cmode;
7456 class SIMDModifiedImmScalarNoShift<bit Q, bit op, bits<4> cmode, string asm,
7458 : BaseSIMDModifiedImm<Q, op, 0, (outs FPR64:$Rd), (ins simdimmtype10:$imm8), asm,
7459 "\t$Rd, $imm8", "", pattern> {
7460 let Inst{15-12} = cmode;
7461 let DecoderMethod = "DecodeModImmInstruction";
7464 //----------------------------------------------------------------------------
7465 // AdvSIMD indexed element
7466 //----------------------------------------------------------------------------
7468 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
7469 class BaseSIMDIndexed<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
7470 RegisterOperand dst_reg, RegisterOperand lhs_reg,
7471 RegisterOperand rhs_reg, Operand vec_idx, string asm,
7472 string apple_kind, string dst_kind, string lhs_kind,
7473 string rhs_kind, list<dag> pattern>
7474 : I<(outs dst_reg:$Rd), (ins lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx),
7476 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
7477 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "", pattern>,
7486 let Inst{28} = Scalar;
7487 let Inst{27-24} = 0b1111;
7488 let Inst{23-22} = size;
7489 // Bit 21 must be set by the derived class.
7490 let Inst{20-16} = Rm;
7491 let Inst{15-12} = opc;
7492 // Bit 11 must be set by the derived class.
7498 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
7499 class BaseSIMDIndexedTied<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
7500 RegisterOperand dst_reg, RegisterOperand lhs_reg,
7501 RegisterOperand rhs_reg, Operand vec_idx, string asm,
7502 string apple_kind, string dst_kind, string lhs_kind,
7503 string rhs_kind, list<dag> pattern>
7504 : I<(outs dst_reg:$dst),
7505 (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx), asm,
7506 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" #
7507 "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "$Rd = $dst", pattern>,
7516 let Inst{28} = Scalar;
7517 let Inst{27-24} = 0b1111;
7518 let Inst{23-22} = size;
7519 // Bit 21 must be set by the derived class.
7520 let Inst{20-16} = Rm;
7521 let Inst{15-12} = opc;
7522 // Bit 11 must be set by the derived class.
7528 // ARMv8.2-A Dot Product Instructions (Indexed)
7529 class BaseSIMDThreeSameVectorDotIndex<bit Q, bit U, string asm, string dst_kind,
7530 string lhs_kind, string rhs_kind,
7531 RegisterOperand RegType,
7532 ValueType AccumType, ValueType InputType,
7533 SDPatternOperator OpNode> :
7534 BaseSIMDIndexedTied<Q, U, 0b0, 0b10, 0b1110, RegType, RegType, V128,
7535 VectorIndexS, asm, "", dst_kind, lhs_kind, rhs_kind,
7536 [(set (AccumType RegType:$dst),
7537 (AccumType (OpNode (AccumType RegType:$Rd),
7538 (InputType RegType:$Rn),
7539 (InputType (bitconvert (AccumType
7540 (AArch64duplane32 (v4i32 V128:$Rm),
7541 VectorIndexS:$idx)))))))]> {
7543 let Inst{21} = idx{0}; // L
7544 let Inst{11} = idx{1}; // H
7547 multiclass SIMDThreeSameVectorDotIndex<bit U, string asm,
7548 SDPatternOperator OpNode> {
7549 def v8i8 : BaseSIMDThreeSameVectorDotIndex<0, U, asm, ".2s", ".8b", ".4b",
7550 V64, v2i32, v8i8, OpNode>;
7551 def v16i8 : BaseSIMDThreeSameVectorDotIndex<1, U, asm, ".4s", ".16b", ".4b",
7552 V128, v4i32, v16i8, OpNode>;
7555 // ARMv8.2-A Fused Multiply Add-Long Instructions (Indexed)
7556 class BaseSIMDThreeSameVectorFMLIndex<bit Q, bit U, bits<4> opc, string asm,
7557 string dst_kind, string lhs_kind,
7558 string rhs_kind, RegisterOperand RegType,
7559 ValueType AccumType, ValueType InputType,
7560 SDPatternOperator OpNode> :
7561 BaseSIMDIndexedTied<Q, U, 0, 0b10, opc, RegType, RegType, V128,
7562 VectorIndexH, asm, "", dst_kind, lhs_kind, rhs_kind,
7563 [(set (AccumType RegType:$dst),
7564 (AccumType (OpNode (AccumType RegType:$Rd),
7565 (InputType RegType:$Rn),
7566 (InputType (AArch64duplane16 (v8f16 V128:$Rm),
7567 VectorIndexH:$idx)))))]> {
7570 let Inst{11} = idx{2}; // H
7571 let Inst{21} = idx{1}; // L
7572 let Inst{20} = idx{0}; // M
7575 multiclass SIMDThreeSameVectorFMLIndex<bit U, bits<4> opc, string asm,
7576 SDPatternOperator OpNode> {
7577 def v4f16 : BaseSIMDThreeSameVectorFMLIndex<0, U, opc, asm, ".2s", ".2h", ".h",
7578 V64, v2f32, v4f16, OpNode>;
7579 def v8f16 : BaseSIMDThreeSameVectorFMLIndex<1, U, opc, asm, ".4s", ".4h", ".h",
7580 V128, v4f32, v8f16, OpNode>;
7583 multiclass SIMDFPIndexed<bit U, bits<4> opc, string asm,
7584 SDPatternOperator OpNode> {
7585 let Predicates = [HasNEON, HasFullFP16] in {
7586 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b00, opc,
7588 V128_lo, VectorIndexH,
7589 asm, ".4h", ".4h", ".4h", ".h",
7590 [(set (v4f16 V64:$Rd),
7591 (OpNode (v4f16 V64:$Rn),
7592 (v4f16 (AArch64duplane16 (v8f16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7594 let Inst{11} = idx{2};
7595 let Inst{21} = idx{1};
7596 let Inst{20} = idx{0};
7599 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b00, opc,
7601 V128_lo, VectorIndexH,
7602 asm, ".8h", ".8h", ".8h", ".h",
7603 [(set (v8f16 V128:$Rd),
7604 (OpNode (v8f16 V128:$Rn),
7605 (v8f16 (AArch64duplane16 (v8f16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7607 let Inst{11} = idx{2};
7608 let Inst{21} = idx{1};
7609 let Inst{20} = idx{0};
7611 } // Predicates = [HasNEON, HasFullFP16]
7613 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
7616 asm, ".2s", ".2s", ".2s", ".s",
7617 [(set (v2f32 V64:$Rd),
7618 (OpNode (v2f32 V64:$Rn),
7619 (v2f32 (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
7621 let Inst{11} = idx{1};
7622 let Inst{21} = idx{0};
7625 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
7628 asm, ".4s", ".4s", ".4s", ".s",
7629 [(set (v4f32 V128:$Rd),
7630 (OpNode (v4f32 V128:$Rn),
7631 (v4f32 (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> {
7633 let Inst{11} = idx{1};
7634 let Inst{21} = idx{0};
7637 def v2i64_indexed : BaseSIMDIndexed<1, U, 0, 0b11, opc,
7640 asm, ".2d", ".2d", ".2d", ".d",
7641 [(set (v2f64 V128:$Rd),
7642 (OpNode (v2f64 V128:$Rn),
7643 (v2f64 (AArch64duplane64 (v2f64 V128:$Rm), VectorIndexD:$idx))))]> {
7645 let Inst{11} = idx{0};
7649 let Predicates = [HasNEON, HasFullFP16] in {
7650 def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b00, opc,
7651 FPR16Op, FPR16Op, V128_lo, VectorIndexH,
7652 asm, ".h", "", "", ".h",
7653 [(set (f16 FPR16Op:$Rd),
7654 (OpNode (f16 FPR16Op:$Rn),
7655 (f16 (vector_extract (v8f16 V128_lo:$Rm),
7656 VectorIndexH:$idx))))]> {
7658 let Inst{11} = idx{2};
7659 let Inst{21} = idx{1};
7660 let Inst{20} = idx{0};
7662 } // Predicates = [HasNEON, HasFullFP16]
7664 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
7665 FPR32Op, FPR32Op, V128, VectorIndexS,
7666 asm, ".s", "", "", ".s",
7667 [(set (f32 FPR32Op:$Rd),
7668 (OpNode (f32 FPR32Op:$Rn),
7669 (f32 (vector_extract (v4f32 V128:$Rm),
7670 VectorIndexS:$idx))))]> {
7672 let Inst{11} = idx{1};
7673 let Inst{21} = idx{0};
7676 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b11, opc,
7677 FPR64Op, FPR64Op, V128, VectorIndexD,
7678 asm, ".d", "", "", ".d",
7679 [(set (f64 FPR64Op:$Rd),
7680 (OpNode (f64 FPR64Op:$Rn),
7681 (f64 (vector_extract (v2f64 V128:$Rm),
7682 VectorIndexD:$idx))))]> {
7684 let Inst{11} = idx{0};
7689 multiclass SIMDFPIndexedTiedPatterns<string INST, SDPatternOperator OpNode> {
7690 // 2 variants for the .2s version: DUPLANE from 128-bit and DUP scalar.
7691 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
7692 (AArch64duplane32 (v4f32 V128:$Rm),
7693 VectorIndexS:$idx))),
7694 (!cast<Instruction>(INST # v2i32_indexed)
7695 V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
7696 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
7697 (AArch64dup (f32 FPR32Op:$Rm)))),
7698 (!cast<Instruction>(INST # "v2i32_indexed") V64:$Rd, V64:$Rn,
7699 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
7702 // 2 variants for the .4s version: DUPLANE from 128-bit and DUP scalar.
7703 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
7704 (AArch64duplane32 (v4f32 V128:$Rm),
7705 VectorIndexS:$idx))),
7706 (!cast<Instruction>(INST # "v4i32_indexed")
7707 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
7708 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
7709 (AArch64dup (f32 FPR32Op:$Rm)))),
7710 (!cast<Instruction>(INST # "v4i32_indexed") V128:$Rd, V128:$Rn,
7711 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
7713 // 2 variants for the .2d version: DUPLANE from 128-bit and DUP scalar.
7714 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
7715 (AArch64duplane64 (v2f64 V128:$Rm),
7716 VectorIndexD:$idx))),
7717 (!cast<Instruction>(INST # "v2i64_indexed")
7718 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
7719 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
7720 (AArch64dup (f64 FPR64Op:$Rm)))),
7721 (!cast<Instruction>(INST # "v2i64_indexed") V128:$Rd, V128:$Rn,
7722 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
7724 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
7725 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
7726 (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx))),
7727 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
7728 V128:$Rm, VectorIndexS:$idx)>;
7729 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
7730 (vector_extract (v2f32 V64:$Rm), VectorIndexS:$idx))),
7731 (!cast<Instruction>(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn,
7732 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
7734 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
7735 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
7736 (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx))),
7737 (!cast<Instruction>(INST # "v1i64_indexed") FPR64:$Rd, FPR64:$Rn,
7738 V128:$Rm, VectorIndexD:$idx)>;
7741 multiclass SIMDFPIndexedTied<bit U, bits<4> opc, string asm> {
7742 let Predicates = [HasNEON, HasFullFP16] in {
7743 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b00, opc, V64, V64,
7744 V128_lo, VectorIndexH,
7745 asm, ".4h", ".4h", ".4h", ".h", []> {
7747 let Inst{11} = idx{2};
7748 let Inst{21} = idx{1};
7749 let Inst{20} = idx{0};
7752 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b00, opc,
7754 V128_lo, VectorIndexH,
7755 asm, ".8h", ".8h", ".8h", ".h", []> {
7757 let Inst{11} = idx{2};
7758 let Inst{21} = idx{1};
7759 let Inst{20} = idx{0};
7761 } // Predicates = [HasNEON, HasFullFP16]
7763 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64,
7765 asm, ".2s", ".2s", ".2s", ".s", []> {
7767 let Inst{11} = idx{1};
7768 let Inst{21} = idx{0};
7771 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
7774 asm, ".4s", ".4s", ".4s", ".s", []> {
7776 let Inst{11} = idx{1};
7777 let Inst{21} = idx{0};
7780 def v2i64_indexed : BaseSIMDIndexedTied<1, U, 0, 0b11, opc,
7783 asm, ".2d", ".2d", ".2d", ".d", []> {
7785 let Inst{11} = idx{0};
7789 let Predicates = [HasNEON, HasFullFP16] in {
7790 def v1i16_indexed : BaseSIMDIndexedTied<1, U, 1, 0b00, opc,
7791 FPR16Op, FPR16Op, V128_lo, VectorIndexH,
7792 asm, ".h", "", "", ".h", []> {
7794 let Inst{11} = idx{2};
7795 let Inst{21} = idx{1};
7796 let Inst{20} = idx{0};
7798 } // Predicates = [HasNEON, HasFullFP16]
7800 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
7801 FPR32Op, FPR32Op, V128, VectorIndexS,
7802 asm, ".s", "", "", ".s", []> {
7804 let Inst{11} = idx{1};
7805 let Inst{21} = idx{0};
7808 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b11, opc,
7809 FPR64Op, FPR64Op, V128, VectorIndexD,
7810 asm, ".d", "", "", ".d", []> {
7812 let Inst{11} = idx{0};
7817 multiclass SIMDIndexedHS<bit U, bits<4> opc, string asm,
7818 SDPatternOperator OpNode> {
7819 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V64, V64,
7820 V128_lo, VectorIndexH,
7821 asm, ".4h", ".4h", ".4h", ".h",
7822 [(set (v4i16 V64:$Rd),
7823 (OpNode (v4i16 V64:$Rn),
7824 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7826 let Inst{11} = idx{2};
7827 let Inst{21} = idx{1};
7828 let Inst{20} = idx{0};
7831 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
7833 V128_lo, VectorIndexH,
7834 asm, ".8h", ".8h", ".8h", ".h",
7835 [(set (v8i16 V128:$Rd),
7836 (OpNode (v8i16 V128:$Rn),
7837 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7839 let Inst{11} = idx{2};
7840 let Inst{21} = idx{1};
7841 let Inst{20} = idx{0};
7844 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
7847 asm, ".2s", ".2s", ".2s", ".s",
7848 [(set (v2i32 V64:$Rd),
7849 (OpNode (v2i32 V64:$Rn),
7850 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
7852 let Inst{11} = idx{1};
7853 let Inst{21} = idx{0};
7856 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
7859 asm, ".4s", ".4s", ".4s", ".s",
7860 [(set (v4i32 V128:$Rd),
7861 (OpNode (v4i32 V128:$Rn),
7862 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
7864 let Inst{11} = idx{1};
7865 let Inst{21} = idx{0};
7868 def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
7869 FPR16Op, FPR16Op, V128_lo, VectorIndexH,
7870 asm, ".h", "", "", ".h", []> {
7872 let Inst{11} = idx{2};
7873 let Inst{21} = idx{1};
7874 let Inst{20} = idx{0};
7877 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
7878 FPR32Op, FPR32Op, V128, VectorIndexS,
7879 asm, ".s", "", "", ".s",
7880 [(set (i32 FPR32Op:$Rd),
7881 (OpNode FPR32Op:$Rn,
7882 (i32 (vector_extract (v4i32 V128:$Rm),
7883 VectorIndexS:$idx))))]> {
7885 let Inst{11} = idx{1};
7886 let Inst{21} = idx{0};
7890 multiclass SIMDVectorIndexedHS<bit U, bits<4> opc, string asm,
7891 SDPatternOperator OpNode> {
7892 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
7894 V128_lo, VectorIndexH,
7895 asm, ".4h", ".4h", ".4h", ".h",
7896 [(set (v4i16 V64:$Rd),
7897 (OpNode (v4i16 V64:$Rn),
7898 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7900 let Inst{11} = idx{2};
7901 let Inst{21} = idx{1};
7902 let Inst{20} = idx{0};
7905 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
7907 V128_lo, VectorIndexH,
7908 asm, ".8h", ".8h", ".8h", ".h",
7909 [(set (v8i16 V128:$Rd),
7910 (OpNode (v8i16 V128:$Rn),
7911 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7913 let Inst{11} = idx{2};
7914 let Inst{21} = idx{1};
7915 let Inst{20} = idx{0};
7918 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
7921 asm, ".2s", ".2s", ".2s", ".s",
7922 [(set (v2i32 V64:$Rd),
7923 (OpNode (v2i32 V64:$Rn),
7924 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
7926 let Inst{11} = idx{1};
7927 let Inst{21} = idx{0};
7930 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
7933 asm, ".4s", ".4s", ".4s", ".s",
7934 [(set (v4i32 V128:$Rd),
7935 (OpNode (v4i32 V128:$Rn),
7936 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
7938 let Inst{11} = idx{1};
7939 let Inst{21} = idx{0};
7943 multiclass SIMDVectorIndexedHSTied<bit U, bits<4> opc, string asm,
7944 SDPatternOperator OpNode> {
7945 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V64, V64,
7946 V128_lo, VectorIndexH,
7947 asm, ".4h", ".4h", ".4h", ".h",
7948 [(set (v4i16 V64:$dst),
7949 (OpNode (v4i16 V64:$Rd),(v4i16 V64:$Rn),
7950 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7952 let Inst{11} = idx{2};
7953 let Inst{21} = idx{1};
7954 let Inst{20} = idx{0};
7957 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
7959 V128_lo, VectorIndexH,
7960 asm, ".8h", ".8h", ".8h", ".h",
7961 [(set (v8i16 V128:$dst),
7962 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
7963 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
7965 let Inst{11} = idx{2};
7966 let Inst{21} = idx{1};
7967 let Inst{20} = idx{0};
7970 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
7973 asm, ".2s", ".2s", ".2s", ".s",
7974 [(set (v2i32 V64:$dst),
7975 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
7976 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
7978 let Inst{11} = idx{1};
7979 let Inst{21} = idx{0};
7982 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
7985 asm, ".4s", ".4s", ".4s", ".s",
7986 [(set (v4i32 V128:$dst),
7987 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
7988 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
7990 let Inst{11} = idx{1};
7991 let Inst{21} = idx{0};
7995 multiclass SIMDIndexedLongSD<bit U, bits<4> opc, string asm,
7996 SDPatternOperator OpNode> {
7997 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
7999 V128_lo, VectorIndexH,
8000 asm, ".4s", ".4s", ".4h", ".h",
8001 [(set (v4i32 V128:$Rd),
8002 (OpNode (v4i16 V64:$Rn),
8003 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
8005 let Inst{11} = idx{2};
8006 let Inst{21} = idx{1};
8007 let Inst{20} = idx{0};
8010 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
8012 V128_lo, VectorIndexH,
8013 asm#"2", ".4s", ".4s", ".8h", ".h",
8014 [(set (v4i32 V128:$Rd),
8015 (OpNode (extract_high_v8i16 V128:$Rn),
8016 (extract_high_v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
8017 VectorIndexH:$idx))))]> {
8020 let Inst{11} = idx{2};
8021 let Inst{21} = idx{1};
8022 let Inst{20} = idx{0};
8025 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
8028 asm, ".2d", ".2d", ".2s", ".s",
8029 [(set (v2i64 V128:$Rd),
8030 (OpNode (v2i32 V64:$Rn),
8031 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
8033 let Inst{11} = idx{1};
8034 let Inst{21} = idx{0};
8037 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
8040 asm#"2", ".2d", ".2d", ".4s", ".s",
8041 [(set (v2i64 V128:$Rd),
8042 (OpNode (extract_high_v4i32 V128:$Rn),
8043 (extract_high_v4i32 (AArch64duplane32 (v4i32 V128:$Rm),
8044 VectorIndexS:$idx))))]> {
8046 let Inst{11} = idx{1};
8047 let Inst{21} = idx{0};
8050 def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc,
8051 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
8052 asm, ".h", "", "", ".h", []> {
8054 let Inst{11} = idx{2};
8055 let Inst{21} = idx{1};
8056 let Inst{20} = idx{0};
8059 def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc,
8060 FPR64Op, FPR32Op, V128, VectorIndexS,
8061 asm, ".s", "", "", ".s", []> {
8063 let Inst{11} = idx{1};
8064 let Inst{21} = idx{0};
8068 multiclass SIMDIndexedLongSQDMLXSDTied<bit U, bits<4> opc, string asm,
8069 SDPatternOperator Accum> {
8070 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
8072 V128_lo, VectorIndexH,
8073 asm, ".4s", ".4s", ".4h", ".h",
8074 [(set (v4i32 V128:$dst),
8075 (Accum (v4i32 V128:$Rd),
8076 (v4i32 (int_aarch64_neon_sqdmull
8078 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
8079 VectorIndexH:$idx))))))]> {
8081 let Inst{11} = idx{2};
8082 let Inst{21} = idx{1};
8083 let Inst{20} = idx{0};
8086 // FIXME: it would be nice to use the scalar (v1i32) instruction here, but an
8087 // intermediate EXTRACT_SUBREG would be untyped.
8088 def : Pat<(i32 (Accum (i32 FPR32Op:$Rd),
8089 (i32 (vector_extract (v4i32
8090 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn),
8091 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
8092 VectorIndexH:$idx)))),
8095 (!cast<Instruction>(NAME # v4i16_indexed)
8096 (SUBREG_TO_REG (i32 0), FPR32Op:$Rd, ssub), V64:$Rn,
8097 V128_lo:$Rm, VectorIndexH:$idx),
8100 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
8102 V128_lo, VectorIndexH,
8103 asm#"2", ".4s", ".4s", ".8h", ".h",
8104 [(set (v4i32 V128:$dst),
8105 (Accum (v4i32 V128:$Rd),
8106 (v4i32 (int_aarch64_neon_sqdmull
8107 (extract_high_v8i16 V128:$Rn),
8109 (AArch64duplane16 (v8i16 V128_lo:$Rm),
8110 VectorIndexH:$idx))))))]> {
8112 let Inst{11} = idx{2};
8113 let Inst{21} = idx{1};
8114 let Inst{20} = idx{0};
8117 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
8120 asm, ".2d", ".2d", ".2s", ".s",
8121 [(set (v2i64 V128:$dst),
8122 (Accum (v2i64 V128:$Rd),
8123 (v2i64 (int_aarch64_neon_sqdmull
8125 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm),
8126 VectorIndexS:$idx))))))]> {
8128 let Inst{11} = idx{1};
8129 let Inst{21} = idx{0};
8132 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
8135 asm#"2", ".2d", ".2d", ".4s", ".s",
8136 [(set (v2i64 V128:$dst),
8137 (Accum (v2i64 V128:$Rd),
8138 (v2i64 (int_aarch64_neon_sqdmull
8139 (extract_high_v4i32 V128:$Rn),
8141 (AArch64duplane32 (v4i32 V128:$Rm),
8142 VectorIndexS:$idx))))))]> {
8144 let Inst{11} = idx{1};
8145 let Inst{21} = idx{0};
8148 def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc,
8149 FPR32Op, FPR16Op, V128_lo, VectorIndexH,
8150 asm, ".h", "", "", ".h", []> {
8152 let Inst{11} = idx{2};
8153 let Inst{21} = idx{1};
8154 let Inst{20} = idx{0};
8158 def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
8159 FPR64Op, FPR32Op, V128, VectorIndexS,
8160 asm, ".s", "", "", ".s",
8161 [(set (i64 FPR64Op:$dst),
8162 (Accum (i64 FPR64Op:$Rd),
8163 (i64 (int_aarch64_neon_sqdmulls_scalar
8165 (i32 (vector_extract (v4i32 V128:$Rm),
8166 VectorIndexS:$idx))))))]> {
8169 let Inst{11} = idx{1};
8170 let Inst{21} = idx{0};
8174 multiclass SIMDVectorIndexedLongSD<bit U, bits<4> opc, string asm,
8175 SDPatternOperator OpNode> {
8176 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
8177 def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc,
8179 V128_lo, VectorIndexH,
8180 asm, ".4s", ".4s", ".4h", ".h",
8181 [(set (v4i32 V128:$Rd),
8182 (OpNode (v4i16 V64:$Rn),
8183 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
8185 let Inst{11} = idx{2};
8186 let Inst{21} = idx{1};
8187 let Inst{20} = idx{0};
8190 def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc,
8192 V128_lo, VectorIndexH,
8193 asm#"2", ".4s", ".4s", ".8h", ".h",
8194 [(set (v4i32 V128:$Rd),
8195 (OpNode (extract_high_v8i16 V128:$Rn),
8196 (extract_high_v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
8197 VectorIndexH:$idx))))]> {
8200 let Inst{11} = idx{2};
8201 let Inst{21} = idx{1};
8202 let Inst{20} = idx{0};
8205 def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc,
8208 asm, ".2d", ".2d", ".2s", ".s",
8209 [(set (v2i64 V128:$Rd),
8210 (OpNode (v2i32 V64:$Rn),
8211 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
8213 let Inst{11} = idx{1};
8214 let Inst{21} = idx{0};
8217 def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc,
8220 asm#"2", ".2d", ".2d", ".4s", ".s",
8221 [(set (v2i64 V128:$Rd),
8222 (OpNode (extract_high_v4i32 V128:$Rn),
8223 (extract_high_v4i32 (AArch64duplane32 (v4i32 V128:$Rm),
8224 VectorIndexS:$idx))))]> {
8226 let Inst{11} = idx{1};
8227 let Inst{21} = idx{0};
8232 multiclass SIMDVectorIndexedLongSDTied<bit U, bits<4> opc, string asm,
8233 SDPatternOperator OpNode> {
8234 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
8235 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
8237 V128_lo, VectorIndexH,
8238 asm, ".4s", ".4s", ".4h", ".h",
8239 [(set (v4i32 V128:$dst),
8240 (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn),
8241 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> {
8243 let Inst{11} = idx{2};
8244 let Inst{21} = idx{1};
8245 let Inst{20} = idx{0};
8248 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
8250 V128_lo, VectorIndexH,
8251 asm#"2", ".4s", ".4s", ".8h", ".h",
8252 [(set (v4i32 V128:$dst),
8253 (OpNode (v4i32 V128:$Rd),
8254 (extract_high_v8i16 V128:$Rn),
8255 (extract_high_v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
8256 VectorIndexH:$idx))))]> {
8258 let Inst{11} = idx{2};
8259 let Inst{21} = idx{1};
8260 let Inst{20} = idx{0};
8263 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
8266 asm, ".2d", ".2d", ".2s", ".s",
8267 [(set (v2i64 V128:$dst),
8268 (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn),
8269 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> {
8271 let Inst{11} = idx{1};
8272 let Inst{21} = idx{0};
8275 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
8278 asm#"2", ".2d", ".2d", ".4s", ".s",
8279 [(set (v2i64 V128:$dst),
8280 (OpNode (v2i64 V128:$Rd),
8281 (extract_high_v4i32 V128:$Rn),
8282 (extract_high_v4i32 (AArch64duplane32 (v4i32 V128:$Rm),
8283 VectorIndexS:$idx))))]> {
8285 let Inst{11} = idx{1};
8286 let Inst{21} = idx{0};
8291 //----------------------------------------------------------------------------
8292 // AdvSIMD scalar shift by immediate
8293 //----------------------------------------------------------------------------
8295 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
8296 class BaseSIMDScalarShift<bit U, bits<5> opc, bits<7> fixed_imm,
8297 RegisterClass regtype1, RegisterClass regtype2,
8298 Operand immtype, string asm, list<dag> pattern>
8299 : I<(outs regtype1:$Rd), (ins regtype2:$Rn, immtype:$imm),
8300 asm, "\t$Rd, $Rn, $imm", "", pattern>,
8305 let Inst{31-30} = 0b01;
8307 let Inst{28-23} = 0b111110;
8308 let Inst{22-16} = fixed_imm;
8309 let Inst{15-11} = opc;
8315 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
8316 class BaseSIMDScalarShiftTied<bit U, bits<5> opc, bits<7> fixed_imm,
8317 RegisterClass regtype1, RegisterClass regtype2,
8318 Operand immtype, string asm, list<dag> pattern>
8319 : I<(outs regtype1:$dst), (ins regtype1:$Rd, regtype2:$Rn, immtype:$imm),
8320 asm, "\t$Rd, $Rn, $imm", "$Rd = $dst", pattern>,
8325 let Inst{31-30} = 0b01;
8327 let Inst{28-23} = 0b111110;
8328 let Inst{22-16} = fixed_imm;
8329 let Inst{15-11} = opc;
8336 multiclass SIMDFPScalarRShift<bit U, bits<5> opc, string asm> {
8337 let Predicates = [HasNEON, HasFullFP16] in {
8338 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
8339 FPR16, FPR16, vecshiftR16, asm, []> {
8340 let Inst{19-16} = imm{3-0};
8342 } // Predicates = [HasNEON, HasFullFP16]
8343 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
8344 FPR32, FPR32, vecshiftR32, asm, []> {
8345 let Inst{20-16} = imm{4-0};
8347 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
8348 FPR64, FPR64, vecshiftR64, asm, []> {
8349 let Inst{21-16} = imm{5-0};
8353 multiclass SIMDScalarRShiftD<bit U, bits<5> opc, string asm,
8354 SDPatternOperator OpNode> {
8355 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
8356 FPR64, FPR64, vecshiftR64, asm,
8357 [(set (i64 FPR64:$Rd),
8358 (OpNode (i64 FPR64:$Rn), (i32 vecshiftR64:$imm)))]> {
8359 let Inst{21-16} = imm{5-0};
8362 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftR64:$imm))),
8363 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftR64:$imm)>;
8366 multiclass SIMDScalarRShiftDTied<bit U, bits<5> opc, string asm,
8367 SDPatternOperator OpNode = null_frag> {
8368 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
8369 FPR64, FPR64, vecshiftR64, asm,
8370 [(set (i64 FPR64:$dst), (OpNode (i64 FPR64:$Rd), (i64 FPR64:$Rn),
8371 (i32 vecshiftR64:$imm)))]> {
8372 let Inst{21-16} = imm{5-0};
8375 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
8376 (i32 vecshiftR64:$imm))),
8377 (!cast<Instruction>(NAME # "d") FPR64:$Rd, FPR64:$Rn,
8381 multiclass SIMDScalarLShiftD<bit U, bits<5> opc, string asm,
8382 SDPatternOperator OpNode> {
8383 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
8384 FPR64, FPR64, vecshiftL64, asm,
8385 [(set (v1i64 FPR64:$Rd),
8386 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
8387 let Inst{21-16} = imm{5-0};
8391 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
8392 multiclass SIMDScalarLShiftDTied<bit U, bits<5> opc, string asm> {
8393 def d : BaseSIMDScalarShiftTied<U, opc, {1,?,?,?,?,?,?},
8394 FPR64, FPR64, vecshiftL64, asm, []> {
8395 let Inst{21-16} = imm{5-0};
8399 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
8400 multiclass SIMDScalarRShiftBHS<bit U, bits<5> opc, string asm,
8401 SDPatternOperator OpNode = null_frag> {
8402 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
8403 FPR8, FPR16, vecshiftR8, asm, []> {
8404 let Inst{18-16} = imm{2-0};
8407 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
8408 FPR16, FPR32, vecshiftR16, asm, []> {
8409 let Inst{19-16} = imm{3-0};
8412 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
8413 FPR32, FPR64, vecshiftR32, asm,
8414 [(set (i32 FPR32:$Rd), (OpNode (i64 FPR64:$Rn), vecshiftR32:$imm))]> {
8415 let Inst{20-16} = imm{4-0};
8419 multiclass SIMDScalarLShiftBHSD<bit U, bits<5> opc, string asm,
8420 SDPatternOperator OpNode> {
8421 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
8422 FPR8, FPR8, vecshiftL8, asm, []> {
8423 let Inst{18-16} = imm{2-0};
8426 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
8427 FPR16, FPR16, vecshiftL16, asm, []> {
8428 let Inst{19-16} = imm{3-0};
8431 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
8432 FPR32, FPR32, vecshiftL32, asm,
8433 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn), (i32 vecshiftL32:$imm)))]> {
8434 let Inst{20-16} = imm{4-0};
8437 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
8438 FPR64, FPR64, vecshiftL64, asm,
8439 [(set (i64 FPR64:$Rd), (OpNode (i64 FPR64:$Rn), (i32 vecshiftL64:$imm)))]> {
8440 let Inst{21-16} = imm{5-0};
8443 def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm))),
8444 (!cast<Instruction>(NAME # "d") FPR64:$Rn, vecshiftL64:$imm)>;
8447 multiclass SIMDScalarRShiftBHSD<bit U, bits<5> opc, string asm> {
8448 def b : BaseSIMDScalarShift<U, opc, {0,0,0,1,?,?,?},
8449 FPR8, FPR8, vecshiftR8, asm, []> {
8450 let Inst{18-16} = imm{2-0};
8453 def h : BaseSIMDScalarShift<U, opc, {0,0,1,?,?,?,?},
8454 FPR16, FPR16, vecshiftR16, asm, []> {
8455 let Inst{19-16} = imm{3-0};
8458 def s : BaseSIMDScalarShift<U, opc, {0,1,?,?,?,?,?},
8459 FPR32, FPR32, vecshiftR32, asm, []> {
8460 let Inst{20-16} = imm{4-0};
8463 def d : BaseSIMDScalarShift<U, opc, {1,?,?,?,?,?,?},
8464 FPR64, FPR64, vecshiftR64, asm, []> {
8465 let Inst{21-16} = imm{5-0};
8469 //----------------------------------------------------------------------------
8470 // AdvSIMD vector x indexed element
8471 //----------------------------------------------------------------------------
8473 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
8474 class BaseSIMDVectorShift<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
8475 RegisterOperand dst_reg, RegisterOperand src_reg,
8477 string asm, string dst_kind, string src_kind,
8479 : I<(outs dst_reg:$Rd), (ins src_reg:$Rn, immtype:$imm),
8480 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
8481 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "", pattern>,
8488 let Inst{28-23} = 0b011110;
8489 let Inst{22-16} = fixed_imm;
8490 let Inst{15-11} = opc;
8496 let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in
8497 class BaseSIMDVectorShiftTied<bit Q, bit U, bits<5> opc, bits<7> fixed_imm,
8498 RegisterOperand vectype1, RegisterOperand vectype2,
8500 string asm, string dst_kind, string src_kind,
8502 : I<(outs vectype1:$dst), (ins vectype1:$Rd, vectype2:$Rn, immtype:$imm),
8503 asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" #
8504 "|" # dst_kind # "\t$Rd, $Rn, $imm}", "$Rd = $dst", pattern>,
8511 let Inst{28-23} = 0b011110;
8512 let Inst{22-16} = fixed_imm;
8513 let Inst{15-11} = opc;
8519 multiclass SIMDVectorRShiftSD<bit U, bits<5> opc, string asm,
8521 let Predicates = [HasNEON, HasFullFP16] in {
8522 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
8523 V64, V64, vecshiftR16,
8525 [(set (v4i16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (i32 imm:$imm)))]> {
8527 let Inst{19-16} = imm;
8530 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
8531 V128, V128, vecshiftR16,
8533 [(set (v8i16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (i32 imm:$imm)))]> {
8535 let Inst{19-16} = imm;
8537 } // Predicates = [HasNEON, HasFullFP16]
8538 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
8539 V64, V64, vecshiftR32,
8541 [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (i32 imm:$imm)))]> {
8543 let Inst{20-16} = imm;
8546 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
8547 V128, V128, vecshiftR32,
8549 [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (i32 imm:$imm)))]> {
8551 let Inst{20-16} = imm;
8554 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
8555 V128, V128, vecshiftR64,
8557 [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (i32 imm:$imm)))]> {
8559 let Inst{21-16} = imm;
8563 multiclass SIMDVectorRShiftToFP<bit U, bits<5> opc, string asm,
8565 let Predicates = [HasNEON, HasFullFP16] in {
8566 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
8567 V64, V64, vecshiftR16,
8569 [(set (v4f16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (i32 imm:$imm)))]> {
8571 let Inst{19-16} = imm;
8574 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
8575 V128, V128, vecshiftR16,
8577 [(set (v8f16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (i32 imm:$imm)))]> {
8579 let Inst{19-16} = imm;
8581 } // Predicates = [HasNEON, HasFullFP16]
8583 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
8584 V64, V64, vecshiftR32,
8586 [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 imm:$imm)))]> {
8588 let Inst{20-16} = imm;
8591 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
8592 V128, V128, vecshiftR32,
8594 [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 imm:$imm)))]> {
8596 let Inst{20-16} = imm;
8599 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
8600 V128, V128, vecshiftR64,
8602 [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 imm:$imm)))]> {
8604 let Inst{21-16} = imm;
8608 multiclass SIMDVectorRShiftNarrowBHS<bit U, bits<5> opc, string asm,
8609 SDPatternOperator OpNode> {
8610 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
8611 V64, V128, vecshiftR16Narrow,
8613 [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))]> {
8615 let Inst{18-16} = imm;
8618 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
8619 V128, V128, vecshiftR16Narrow,
8620 asm#"2", ".16b", ".8h", []> {
8622 let Inst{18-16} = imm;
8623 let hasSideEffects = 0;
8626 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
8627 V64, V128, vecshiftR32Narrow,
8629 [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))]> {
8631 let Inst{19-16} = imm;
8634 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
8635 V128, V128, vecshiftR32Narrow,
8636 asm#"2", ".8h", ".4s", []> {
8638 let Inst{19-16} = imm;
8639 let hasSideEffects = 0;
8642 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
8643 V64, V128, vecshiftR64Narrow,
8645 [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))]> {
8647 let Inst{20-16} = imm;
8650 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
8651 V128, V128, vecshiftR64Narrow,
8652 asm#"2", ".4s", ".2d", []> {
8654 let Inst{20-16} = imm;
8655 let hasSideEffects = 0;
8658 // TableGen doesn't like patters w/ INSERT_SUBREG on the instructions
8659 // themselves, so put them here instead.
8661 // Patterns involving what's effectively an insert high and a normal
8662 // intrinsic, represented by CONCAT_VECTORS.
8663 def : Pat<(concat_vectors (v8i8 V64:$Rd),(OpNode (v8i16 V128:$Rn),
8664 vecshiftR16Narrow:$imm)),
8665 (!cast<Instruction>(NAME # "v16i8_shift")
8666 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
8667 V128:$Rn, vecshiftR16Narrow:$imm)>;
8668 def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn),
8669 vecshiftR32Narrow:$imm)),
8670 (!cast<Instruction>(NAME # "v8i16_shift")
8671 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
8672 V128:$Rn, vecshiftR32Narrow:$imm)>;
8673 def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn),
8674 vecshiftR64Narrow:$imm)),
8675 (!cast<Instruction>(NAME # "v4i32_shift")
8676 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
8677 V128:$Rn, vecshiftR64Narrow:$imm)>;
8680 multiclass SIMDVectorLShiftBHSD<bit U, bits<5> opc, string asm,
8681 SDPatternOperator OpNode> {
8682 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
8683 V64, V64, vecshiftL8,
8685 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
8686 (i32 vecshiftL8:$imm)))]> {
8688 let Inst{18-16} = imm;
8691 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
8692 V128, V128, vecshiftL8,
8693 asm, ".16b", ".16b",
8694 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
8695 (i32 vecshiftL8:$imm)))]> {
8697 let Inst{18-16} = imm;
8700 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
8701 V64, V64, vecshiftL16,
8703 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
8704 (i32 vecshiftL16:$imm)))]> {
8706 let Inst{19-16} = imm;
8709 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
8710 V128, V128, vecshiftL16,
8712 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
8713 (i32 vecshiftL16:$imm)))]> {
8715 let Inst{19-16} = imm;
8718 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
8719 V64, V64, vecshiftL32,
8721 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
8722 (i32 vecshiftL32:$imm)))]> {
8724 let Inst{20-16} = imm;
8727 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
8728 V128, V128, vecshiftL32,
8730 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
8731 (i32 vecshiftL32:$imm)))]> {
8733 let Inst{20-16} = imm;
8736 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
8737 V128, V128, vecshiftL64,
8739 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
8740 (i32 vecshiftL64:$imm)))]> {
8742 let Inst{21-16} = imm;
8746 multiclass SIMDVectorRShiftBHSD<bit U, bits<5> opc, string asm,
8747 SDPatternOperator OpNode> {
8748 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
8749 V64, V64, vecshiftR8,
8751 [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn),
8752 (i32 vecshiftR8:$imm)))]> {
8754 let Inst{18-16} = imm;
8757 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
8758 V128, V128, vecshiftR8,
8759 asm, ".16b", ".16b",
8760 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn),
8761 (i32 vecshiftR8:$imm)))]> {
8763 let Inst{18-16} = imm;
8766 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
8767 V64, V64, vecshiftR16,
8769 [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn),
8770 (i32 vecshiftR16:$imm)))]> {
8772 let Inst{19-16} = imm;
8775 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
8776 V128, V128, vecshiftR16,
8778 [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn),
8779 (i32 vecshiftR16:$imm)))]> {
8781 let Inst{19-16} = imm;
8784 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
8785 V64, V64, vecshiftR32,
8787 [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn),
8788 (i32 vecshiftR32:$imm)))]> {
8790 let Inst{20-16} = imm;
8793 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
8794 V128, V128, vecshiftR32,
8796 [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn),
8797 (i32 vecshiftR32:$imm)))]> {
8799 let Inst{20-16} = imm;
8802 def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?},
8803 V128, V128, vecshiftR64,
8805 [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn),
8806 (i32 vecshiftR64:$imm)))]> {
8808 let Inst{21-16} = imm;
8812 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
8813 multiclass SIMDVectorRShiftBHSDTied<bit U, bits<5> opc, string asm,
8814 SDPatternOperator OpNode = null_frag> {
8815 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
8816 V64, V64, vecshiftR8, asm, ".8b", ".8b",
8817 [(set (v8i8 V64:$dst),
8818 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
8819 (i32 vecshiftR8:$imm)))]> {
8821 let Inst{18-16} = imm;
8824 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
8825 V128, V128, vecshiftR8, asm, ".16b", ".16b",
8826 [(set (v16i8 V128:$dst),
8827 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
8828 (i32 vecshiftR8:$imm)))]> {
8830 let Inst{18-16} = imm;
8833 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
8834 V64, V64, vecshiftR16, asm, ".4h", ".4h",
8835 [(set (v4i16 V64:$dst),
8836 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
8837 (i32 vecshiftR16:$imm)))]> {
8839 let Inst{19-16} = imm;
8842 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
8843 V128, V128, vecshiftR16, asm, ".8h", ".8h",
8844 [(set (v8i16 V128:$dst),
8845 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
8846 (i32 vecshiftR16:$imm)))]> {
8848 let Inst{19-16} = imm;
8851 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
8852 V64, V64, vecshiftR32, asm, ".2s", ".2s",
8853 [(set (v2i32 V64:$dst),
8854 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
8855 (i32 vecshiftR32:$imm)))]> {
8857 let Inst{20-16} = imm;
8860 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
8861 V128, V128, vecshiftR32, asm, ".4s", ".4s",
8862 [(set (v4i32 V128:$dst),
8863 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
8864 (i32 vecshiftR32:$imm)))]> {
8866 let Inst{20-16} = imm;
8869 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
8870 V128, V128, vecshiftR64,
8871 asm, ".2d", ".2d", [(set (v2i64 V128:$dst),
8872 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
8873 (i32 vecshiftR64:$imm)))]> {
8875 let Inst{21-16} = imm;
8879 multiclass SIMDVectorLShiftBHSDTied<bit U, bits<5> opc, string asm,
8880 SDPatternOperator OpNode = null_frag> {
8881 def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?},
8882 V64, V64, vecshiftL8,
8884 [(set (v8i8 V64:$dst),
8885 (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn),
8886 (i32 vecshiftL8:$imm)))]> {
8888 let Inst{18-16} = imm;
8891 def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?},
8892 V128, V128, vecshiftL8,
8893 asm, ".16b", ".16b",
8894 [(set (v16i8 V128:$dst),
8895 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn),
8896 (i32 vecshiftL8:$imm)))]> {
8898 let Inst{18-16} = imm;
8901 def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?},
8902 V64, V64, vecshiftL16,
8904 [(set (v4i16 V64:$dst),
8905 (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn),
8906 (i32 vecshiftL16:$imm)))]> {
8908 let Inst{19-16} = imm;
8911 def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?},
8912 V128, V128, vecshiftL16,
8914 [(set (v8i16 V128:$dst),
8915 (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn),
8916 (i32 vecshiftL16:$imm)))]> {
8918 let Inst{19-16} = imm;
8921 def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?},
8922 V64, V64, vecshiftL32,
8924 [(set (v2i32 V64:$dst),
8925 (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn),
8926 (i32 vecshiftL32:$imm)))]> {
8928 let Inst{20-16} = imm;
8931 def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?},
8932 V128, V128, vecshiftL32,
8934 [(set (v4i32 V128:$dst),
8935 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
8936 (i32 vecshiftL32:$imm)))]> {
8938 let Inst{20-16} = imm;
8941 def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?},
8942 V128, V128, vecshiftL64,
8944 [(set (v2i64 V128:$dst),
8945 (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn),
8946 (i32 vecshiftL64:$imm)))]> {
8948 let Inst{21-16} = imm;
8952 multiclass SIMDVectorLShiftLongBHSD<bit U, bits<5> opc, string asm,
8953 SDPatternOperator OpNode> {
8954 def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?},
8955 V128, V64, vecshiftL8, asm, ".8h", ".8b",
8956 [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), vecshiftL8:$imm))]> {
8958 let Inst{18-16} = imm;
8961 def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?},
8962 V128, V128, vecshiftL8,
8963 asm#"2", ".8h", ".16b",
8964 [(set (v8i16 V128:$Rd),
8965 (OpNode (extract_high_v16i8 V128:$Rn), vecshiftL8:$imm))]> {
8967 let Inst{18-16} = imm;
8970 def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?},
8971 V128, V64, vecshiftL16, asm, ".4s", ".4h",
8972 [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), vecshiftL16:$imm))]> {
8974 let Inst{19-16} = imm;
8977 def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?},
8978 V128, V128, vecshiftL16,
8979 asm#"2", ".4s", ".8h",
8980 [(set (v4i32 V128:$Rd),
8981 (OpNode (extract_high_v8i16 V128:$Rn), vecshiftL16:$imm))]> {
8984 let Inst{19-16} = imm;
8987 def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?},
8988 V128, V64, vecshiftL32, asm, ".2d", ".2s",
8989 [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), vecshiftL32:$imm))]> {
8991 let Inst{20-16} = imm;
8994 def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?},
8995 V128, V128, vecshiftL32,
8996 asm#"2", ".2d", ".4s",
8997 [(set (v2i64 V128:$Rd),
8998 (OpNode (extract_high_v4i32 V128:$Rn), vecshiftL32:$imm))]> {
9000 let Inst{20-16} = imm;
9006 // Vector load/store
9008 // SIMD ldX/stX no-index memory references don't allow the optional
9009 // ", #0" constant and handle post-indexing explicitly, so we use
9010 // a more specialized parse method for them. Otherwise, it's the same as
9011 // the general GPR64sp handling.
9013 class BaseSIMDLdSt<bit Q, bit L, bits<4> opcode, bits<2> size,
9014 string asm, dag oops, dag iops, list<dag> pattern>
9015 : I<oops, iops, asm, "\t$Vt, [$Rn]", "", pattern> {
9020 let Inst{29-23} = 0b0011000;
9022 let Inst{21-16} = 0b000000;
9023 let Inst{15-12} = opcode;
9024 let Inst{11-10} = size;
9029 class BaseSIMDLdStPost<bit Q, bit L, bits<4> opcode, bits<2> size,
9030 string asm, dag oops, dag iops>
9031 : I<oops, iops, asm, "\t$Vt, [$Rn], $Xm", "$Rn = $wback", []> {
9037 let Inst{29-23} = 0b0011001;
9040 let Inst{20-16} = Xm;
9041 let Inst{15-12} = opcode;
9042 let Inst{11-10} = size;
9047 // The immediate form of AdvSIMD post-indexed addressing is encoded with
9048 // register post-index addressing from the zero register.
9049 multiclass SIMDLdStAliases<string BaseName, string asm, string layout, string Count,
9050 int Offset, int Size> {
9051 // E.g. "ld1 { v0.8b, v1.8b }, [x1], #16"
9052 // "ld1\t$Vt, [$Rn], #16"
9053 // may get mapped to
9054 // (LD1Twov8b_POST VecListTwo8b:$Vt, GPR64sp:$Rn, XZR)
9055 def : InstAlias<asm # "\t$Vt, [$Rn], #" # Offset,
9056 (!cast<Instruction>(BaseName # Count # "v" # layout # "_POST")
9058 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
9061 // E.g. "ld1.8b { v0, v1 }, [x1], #16"
9062 // "ld1.8b\t$Vt, [$Rn], #16"
9063 // may get mapped to
9064 // (LD1Twov8b_POST VecListTwo64:$Vt, GPR64sp:$Rn, XZR)
9065 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], #" # Offset,
9066 (!cast<Instruction>(BaseName # Count # "v" # layout # "_POST")
9068 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
9071 // E.g. "ld1.8b { v0, v1 }, [x1]"
9072 // "ld1\t$Vt, [$Rn]"
9073 // may get mapped to
9074 // (LD1Twov8b VecListTwo64:$Vt, GPR64sp:$Rn)
9075 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn]",
9076 (!cast<Instruction>(BaseName # Count # "v" # layout)
9077 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
9080 // E.g. "ld1.8b { v0, v1 }, [x1], x2"
9081 // "ld1\t$Vt, [$Rn], $Xm"
9082 // may get mapped to
9083 // (LD1Twov8b_POST VecListTwo64:$Vt, GPR64sp:$Rn, GPR64pi8:$Xm)
9084 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], $Xm",
9085 (!cast<Instruction>(BaseName # Count # "v" # layout # "_POST")
9087 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
9088 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
9091 multiclass BaseSIMDLdN<string BaseName, string Count, string asm, string veclist,
9092 int Offset128, int Offset64, bits<4> opcode> {
9093 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
9094 def v16b: BaseSIMDLdSt<1, 1, opcode, 0b00, asm,
9095 (outs !cast<RegisterOperand>(veclist # "16b"):$Vt),
9096 (ins GPR64sp:$Rn), []>;
9097 def v8h : BaseSIMDLdSt<1, 1, opcode, 0b01, asm,
9098 (outs !cast<RegisterOperand>(veclist # "8h"):$Vt),
9099 (ins GPR64sp:$Rn), []>;
9100 def v4s : BaseSIMDLdSt<1, 1, opcode, 0b10, asm,
9101 (outs !cast<RegisterOperand>(veclist # "4s"):$Vt),
9102 (ins GPR64sp:$Rn), []>;
9103 def v2d : BaseSIMDLdSt<1, 1, opcode, 0b11, asm,
9104 (outs !cast<RegisterOperand>(veclist # "2d"):$Vt),
9105 (ins GPR64sp:$Rn), []>;
9106 def v8b : BaseSIMDLdSt<0, 1, opcode, 0b00, asm,
9107 (outs !cast<RegisterOperand>(veclist # "8b"):$Vt),
9108 (ins GPR64sp:$Rn), []>;
9109 def v4h : BaseSIMDLdSt<0, 1, opcode, 0b01, asm,
9110 (outs !cast<RegisterOperand>(veclist # "4h"):$Vt),
9111 (ins GPR64sp:$Rn), []>;
9112 def v2s : BaseSIMDLdSt<0, 1, opcode, 0b10, asm,
9113 (outs !cast<RegisterOperand>(veclist # "2s"):$Vt),
9114 (ins GPR64sp:$Rn), []>;
9117 def v16b_POST: BaseSIMDLdStPost<1, 1, opcode, 0b00, asm,
9118 (outs GPR64sp:$wback,
9119 !cast<RegisterOperand>(veclist # "16b"):$Vt),
9121 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9122 def v8h_POST : BaseSIMDLdStPost<1, 1, opcode, 0b01, asm,
9123 (outs GPR64sp:$wback,
9124 !cast<RegisterOperand>(veclist # "8h"):$Vt),
9126 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9127 def v4s_POST : BaseSIMDLdStPost<1, 1, opcode, 0b10, asm,
9128 (outs GPR64sp:$wback,
9129 !cast<RegisterOperand>(veclist # "4s"):$Vt),
9131 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9132 def v2d_POST : BaseSIMDLdStPost<1, 1, opcode, 0b11, asm,
9133 (outs GPR64sp:$wback,
9134 !cast<RegisterOperand>(veclist # "2d"):$Vt),
9136 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9137 def v8b_POST : BaseSIMDLdStPost<0, 1, opcode, 0b00, asm,
9138 (outs GPR64sp:$wback,
9139 !cast<RegisterOperand>(veclist # "8b"):$Vt),
9141 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9142 def v4h_POST : BaseSIMDLdStPost<0, 1, opcode, 0b01, asm,
9143 (outs GPR64sp:$wback,
9144 !cast<RegisterOperand>(veclist # "4h"):$Vt),
9146 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9147 def v2s_POST : BaseSIMDLdStPost<0, 1, opcode, 0b10, asm,
9148 (outs GPR64sp:$wback,
9149 !cast<RegisterOperand>(veclist # "2s"):$Vt),
9151 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9154 defm : SIMDLdStAliases<BaseName, asm, "16b", Count, Offset128, 128>;
9155 defm : SIMDLdStAliases<BaseName, asm, "8h", Count, Offset128, 128>;
9156 defm : SIMDLdStAliases<BaseName, asm, "4s", Count, Offset128, 128>;
9157 defm : SIMDLdStAliases<BaseName, asm, "2d", Count, Offset128, 128>;
9158 defm : SIMDLdStAliases<BaseName, asm, "8b", Count, Offset64, 64>;
9159 defm : SIMDLdStAliases<BaseName, asm, "4h", Count, Offset64, 64>;
9160 defm : SIMDLdStAliases<BaseName, asm, "2s", Count, Offset64, 64>;
9163 // Only ld1/st1 has a v1d version.
9164 multiclass BaseSIMDStN<string BaseName, string Count, string asm, string veclist,
9165 int Offset128, int Offset64, bits<4> opcode> {
9166 let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in {
9167 def v16b : BaseSIMDLdSt<1, 0, opcode, 0b00, asm, (outs),
9168 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
9170 def v8h : BaseSIMDLdSt<1, 0, opcode, 0b01, asm, (outs),
9171 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
9173 def v4s : BaseSIMDLdSt<1, 0, opcode, 0b10, asm, (outs),
9174 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
9176 def v2d : BaseSIMDLdSt<1, 0, opcode, 0b11, asm, (outs),
9177 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
9179 def v8b : BaseSIMDLdSt<0, 0, opcode, 0b00, asm, (outs),
9180 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
9182 def v4h : BaseSIMDLdSt<0, 0, opcode, 0b01, asm, (outs),
9183 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
9185 def v2s : BaseSIMDLdSt<0, 0, opcode, 0b10, asm, (outs),
9186 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
9189 def v16b_POST : BaseSIMDLdStPost<1, 0, opcode, 0b00, asm,
9190 (outs GPR64sp:$wback),
9191 (ins !cast<RegisterOperand>(veclist # "16b"):$Vt,
9193 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9194 def v8h_POST : BaseSIMDLdStPost<1, 0, opcode, 0b01, asm,
9195 (outs GPR64sp:$wback),
9196 (ins !cast<RegisterOperand>(veclist # "8h"):$Vt,
9198 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9199 def v4s_POST : BaseSIMDLdStPost<1, 0, opcode, 0b10, asm,
9200 (outs GPR64sp:$wback),
9201 (ins !cast<RegisterOperand>(veclist # "4s"):$Vt,
9203 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9204 def v2d_POST : BaseSIMDLdStPost<1, 0, opcode, 0b11, asm,
9205 (outs GPR64sp:$wback),
9206 (ins !cast<RegisterOperand>(veclist # "2d"):$Vt,
9208 !cast<RegisterOperand>("GPR64pi" # Offset128):$Xm)>;
9209 def v8b_POST : BaseSIMDLdStPost<0, 0, opcode, 0b00, asm,
9210 (outs GPR64sp:$wback),
9211 (ins !cast<RegisterOperand>(veclist # "8b"):$Vt,
9213 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9214 def v4h_POST : BaseSIMDLdStPost<0, 0, opcode, 0b01, asm,
9215 (outs GPR64sp:$wback),
9216 (ins !cast<RegisterOperand>(veclist # "4h"):$Vt,
9218 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9219 def v2s_POST : BaseSIMDLdStPost<0, 0, opcode, 0b10, asm,
9220 (outs GPR64sp:$wback),
9221 (ins !cast<RegisterOperand>(veclist # "2s"):$Vt,
9223 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9226 defm : SIMDLdStAliases<BaseName, asm, "16b", Count, Offset128, 128>;
9227 defm : SIMDLdStAliases<BaseName, asm, "8h", Count, Offset128, 128>;
9228 defm : SIMDLdStAliases<BaseName, asm, "4s", Count, Offset128, 128>;
9229 defm : SIMDLdStAliases<BaseName, asm, "2d", Count, Offset128, 128>;
9230 defm : SIMDLdStAliases<BaseName, asm, "8b", Count, Offset64, 64>;
9231 defm : SIMDLdStAliases<BaseName, asm, "4h", Count, Offset64, 64>;
9232 defm : SIMDLdStAliases<BaseName, asm, "2s", Count, Offset64, 64>;
9235 multiclass BaseSIMDLd1<string BaseName, string Count, string asm, string veclist,
9236 int Offset128, int Offset64, bits<4> opcode>
9237 : BaseSIMDLdN<BaseName, Count, asm, veclist, Offset128, Offset64, opcode> {
9239 // LD1 instructions have extra "1d" variants.
9240 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
9241 def v1d : BaseSIMDLdSt<0, 1, opcode, 0b11, asm,
9242 (outs !cast<RegisterOperand>(veclist # "1d"):$Vt),
9243 (ins GPR64sp:$Rn), []>;
9245 def v1d_POST : BaseSIMDLdStPost<0, 1, opcode, 0b11, asm,
9246 (outs GPR64sp:$wback,
9247 !cast<RegisterOperand>(veclist # "1d"):$Vt),
9249 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9252 defm : SIMDLdStAliases<BaseName, asm, "1d", Count, Offset64, 64>;
9255 multiclass BaseSIMDSt1<string BaseName, string Count, string asm, string veclist,
9256 int Offset128, int Offset64, bits<4> opcode>
9257 : BaseSIMDStN<BaseName, Count, asm, veclist, Offset128, Offset64, opcode> {
9259 // ST1 instructions have extra "1d" variants.
9260 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
9261 def v1d : BaseSIMDLdSt<0, 0, opcode, 0b11, asm, (outs),
9262 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
9265 def v1d_POST : BaseSIMDLdStPost<0, 0, opcode, 0b11, asm,
9266 (outs GPR64sp:$wback),
9267 (ins !cast<RegisterOperand>(veclist # "1d"):$Vt,
9269 !cast<RegisterOperand>("GPR64pi" # Offset64):$Xm)>;
9272 defm : SIMDLdStAliases<BaseName, asm, "1d", Count, Offset64, 64>;
9275 multiclass SIMDLd1Multiple<string asm> {
9276 defm One : BaseSIMDLd1<NAME, "One", asm, "VecListOne", 16, 8, 0b0111>;
9277 defm Two : BaseSIMDLd1<NAME, "Two", asm, "VecListTwo", 32, 16, 0b1010>;
9278 defm Three : BaseSIMDLd1<NAME, "Three", asm, "VecListThree", 48, 24, 0b0110>;
9279 defm Four : BaseSIMDLd1<NAME, "Four", asm, "VecListFour", 64, 32, 0b0010>;
9282 multiclass SIMDSt1Multiple<string asm> {
9283 defm One : BaseSIMDSt1<NAME, "One", asm, "VecListOne", 16, 8, 0b0111>;
9284 defm Two : BaseSIMDSt1<NAME, "Two", asm, "VecListTwo", 32, 16, 0b1010>;
9285 defm Three : BaseSIMDSt1<NAME, "Three", asm, "VecListThree", 48, 24, 0b0110>;
9286 defm Four : BaseSIMDSt1<NAME, "Four", asm, "VecListFour", 64, 32, 0b0010>;
9289 multiclass SIMDLd2Multiple<string asm> {
9290 defm Two : BaseSIMDLdN<NAME, "Two", asm, "VecListTwo", 32, 16, 0b1000>;
9293 multiclass SIMDSt2Multiple<string asm> {
9294 defm Two : BaseSIMDStN<NAME, "Two", asm, "VecListTwo", 32, 16, 0b1000>;
9297 multiclass SIMDLd3Multiple<string asm> {
9298 defm Three : BaseSIMDLdN<NAME, "Three", asm, "VecListThree", 48, 24, 0b0100>;
9301 multiclass SIMDSt3Multiple<string asm> {
9302 defm Three : BaseSIMDStN<NAME, "Three", asm, "VecListThree", 48, 24, 0b0100>;
9305 multiclass SIMDLd4Multiple<string asm> {
9306 defm Four : BaseSIMDLdN<NAME, "Four", asm, "VecListFour", 64, 32, 0b0000>;
9309 multiclass SIMDSt4Multiple<string asm> {
9310 defm Four : BaseSIMDStN<NAME, "Four", asm, "VecListFour", 64, 32, 0b0000>;
9314 // AdvSIMD Load/store single-element
9317 class BaseSIMDLdStSingle<bit L, bit R, bits<3> opcode,
9318 string asm, string operands, string cst,
9319 dag oops, dag iops, list<dag> pattern>
9320 : I<oops, iops, asm, operands, cst, pattern> {
9324 let Inst{29-24} = 0b001101;
9327 let Inst{15-13} = opcode;
9332 class BaseSIMDLdStSingleTied<bit L, bit R, bits<3> opcode,
9333 string asm, string operands, string cst,
9334 dag oops, dag iops, list<dag> pattern>
9335 : I<oops, iops, asm, operands, "$Vt = $dst," # cst, pattern> {
9339 let Inst{29-24} = 0b001101;
9342 let Inst{15-13} = opcode;
9348 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
9349 class BaseSIMDLdR<bit Q, bit R, bits<3> opcode, bit S, bits<2> size, string asm,
9350 DAGOperand listtype>
9351 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, [$Rn]", "",
9352 (outs listtype:$Vt), (ins GPR64sp:$Rn),
9356 let Inst{20-16} = 0b00000;
9358 let Inst{11-10} = size;
9360 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
9361 class BaseSIMDLdRPost<bit Q, bit R, bits<3> opcode, bit S, bits<2> size,
9362 string asm, DAGOperand listtype, DAGOperand GPR64pi>
9363 : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, [$Rn], $Xm",
9365 (outs GPR64sp:$wback, listtype:$Vt),
9366 (ins GPR64sp:$Rn, GPR64pi:$Xm), []> {
9370 let Inst{20-16} = Xm;
9372 let Inst{11-10} = size;
9375 multiclass SIMDLdrAliases<string BaseName, string asm, string layout, string Count,
9376 int Offset, int Size> {
9377 // E.g. "ld1r { v0.8b }, [x1], #1"
9378 // "ld1r.8b\t$Vt, [$Rn], #1"
9379 // may get mapped to
9380 // (LD1Rv8b_POST VecListOne8b:$Vt, GPR64sp:$Rn, XZR)
9381 def : InstAlias<asm # "\t$Vt, [$Rn], #" # Offset,
9382 (!cast<Instruction>(BaseName # "v" # layout # "_POST")
9384 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
9387 // E.g. "ld1r.8b { v0 }, [x1], #1"
9388 // "ld1r.8b\t$Vt, [$Rn], #1"
9389 // may get mapped to
9390 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, XZR)
9391 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], #" # Offset,
9392 (!cast<Instruction>(BaseName # "v" # layout # "_POST")
9394 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
9397 // E.g. "ld1r.8b { v0 }, [x1]"
9398 // "ld1r.8b\t$Vt, [$Rn]"
9399 // may get mapped to
9400 // (LD1Rv8b VecListOne64:$Vt, GPR64sp:$Rn)
9401 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn]",
9402 (!cast<Instruction>(BaseName # "v" # layout)
9403 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
9406 // E.g. "ld1r.8b { v0 }, [x1], x2"
9407 // "ld1r.8b\t$Vt, [$Rn], $Xm"
9408 // may get mapped to
9409 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, GPR64pi1:$Xm)
9410 def : InstAlias<asm # "." # layout # "\t$Vt, [$Rn], $Xm",
9411 (!cast<Instruction>(BaseName # "v" # layout # "_POST")
9413 !cast<RegisterOperand>("VecList" # Count # Size):$Vt,
9414 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
9417 multiclass SIMDLdR<bit R, bits<3> opcode, bit S, string asm, string Count,
9418 int Offset1, int Offset2, int Offset4, int Offset8> {
9419 def v8b : BaseSIMDLdR<0, R, opcode, S, 0b00, asm,
9420 !cast<DAGOperand>("VecList" # Count # "8b")>;
9421 def v16b: BaseSIMDLdR<1, R, opcode, S, 0b00, asm,
9422 !cast<DAGOperand>("VecList" # Count #"16b")>;
9423 def v4h : BaseSIMDLdR<0, R, opcode, S, 0b01, asm,
9424 !cast<DAGOperand>("VecList" # Count #"4h")>;
9425 def v8h : BaseSIMDLdR<1, R, opcode, S, 0b01, asm,
9426 !cast<DAGOperand>("VecList" # Count #"8h")>;
9427 def v2s : BaseSIMDLdR<0, R, opcode, S, 0b10, asm,
9428 !cast<DAGOperand>("VecList" # Count #"2s")>;
9429 def v4s : BaseSIMDLdR<1, R, opcode, S, 0b10, asm,
9430 !cast<DAGOperand>("VecList" # Count #"4s")>;
9431 def v1d : BaseSIMDLdR<0, R, opcode, S, 0b11, asm,
9432 !cast<DAGOperand>("VecList" # Count #"1d")>;
9433 def v2d : BaseSIMDLdR<1, R, opcode, S, 0b11, asm,
9434 !cast<DAGOperand>("VecList" # Count #"2d")>;
9436 def v8b_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b00, asm,
9437 !cast<DAGOperand>("VecList" # Count # "8b"),
9438 !cast<DAGOperand>("GPR64pi" # Offset1)>;
9439 def v16b_POST: BaseSIMDLdRPost<1, R, opcode, S, 0b00, asm,
9440 !cast<DAGOperand>("VecList" # Count # "16b"),
9441 !cast<DAGOperand>("GPR64pi" # Offset1)>;
9442 def v4h_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b01, asm,
9443 !cast<DAGOperand>("VecList" # Count # "4h"),
9444 !cast<DAGOperand>("GPR64pi" # Offset2)>;
9445 def v8h_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b01, asm,
9446 !cast<DAGOperand>("VecList" # Count # "8h"),
9447 !cast<DAGOperand>("GPR64pi" # Offset2)>;
9448 def v2s_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b10, asm,
9449 !cast<DAGOperand>("VecList" # Count # "2s"),
9450 !cast<DAGOperand>("GPR64pi" # Offset4)>;
9451 def v4s_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b10, asm,
9452 !cast<DAGOperand>("VecList" # Count # "4s"),
9453 !cast<DAGOperand>("GPR64pi" # Offset4)>;
9454 def v1d_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b11, asm,
9455 !cast<DAGOperand>("VecList" # Count # "1d"),
9456 !cast<DAGOperand>("GPR64pi" # Offset8)>;
9457 def v2d_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b11, asm,
9458 !cast<DAGOperand>("VecList" # Count # "2d"),
9459 !cast<DAGOperand>("GPR64pi" # Offset8)>;
9461 defm : SIMDLdrAliases<NAME, asm, "8b", Count, Offset1, 64>;
9462 defm : SIMDLdrAliases<NAME, asm, "16b", Count, Offset1, 128>;
9463 defm : SIMDLdrAliases<NAME, asm, "4h", Count, Offset2, 64>;
9464 defm : SIMDLdrAliases<NAME, asm, "8h", Count, Offset2, 128>;
9465 defm : SIMDLdrAliases<NAME, asm, "2s", Count, Offset4, 64>;
9466 defm : SIMDLdrAliases<NAME, asm, "4s", Count, Offset4, 128>;
9467 defm : SIMDLdrAliases<NAME, asm, "1d", Count, Offset8, 64>;
9468 defm : SIMDLdrAliases<NAME, asm, "2d", Count, Offset8, 128>;
9471 class SIMDLdStSingleB<bit L, bit R, bits<3> opcode, string asm,
9472 dag oops, dag iops, list<dag> pattern>
9473 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
9475 // idx encoded in Q:S:size fields.
9477 let Inst{30} = idx{3};
9479 let Inst{20-16} = 0b00000;
9480 let Inst{12} = idx{2};
9481 let Inst{11-10} = idx{1-0};
9483 class SIMDLdStSingleBTied<bit L, bit R, bits<3> opcode, string asm,
9484 dag oops, dag iops, list<dag> pattern>
9485 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
9486 oops, iops, pattern> {
9487 // idx encoded in Q:S:size fields.
9489 let Inst{30} = idx{3};
9491 let Inst{20-16} = 0b00000;
9492 let Inst{12} = idx{2};
9493 let Inst{11-10} = idx{1-0};
9495 class SIMDLdStSingleBPost<bit L, bit R, bits<3> opcode, string asm,
9497 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9498 "$Rn = $wback", oops, iops, []> {
9499 // idx encoded in Q:S:size fields.
9502 let Inst{30} = idx{3};
9504 let Inst{20-16} = Xm;
9505 let Inst{12} = idx{2};
9506 let Inst{11-10} = idx{1-0};
9508 class SIMDLdStSingleBTiedPost<bit L, bit R, bits<3> opcode, string asm,
9510 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9511 "$Rn = $wback", oops, iops, []> {
9512 // idx encoded in Q:S:size fields.
9515 let Inst{30} = idx{3};
9517 let Inst{20-16} = Xm;
9518 let Inst{12} = idx{2};
9519 let Inst{11-10} = idx{1-0};
9522 class SIMDLdStSingleH<bit L, bit R, bits<3> opcode, bit size, string asm,
9523 dag oops, dag iops, list<dag> pattern>
9524 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
9526 // idx encoded in Q:S:size<1> fields.
9528 let Inst{30} = idx{2};
9530 let Inst{20-16} = 0b00000;
9531 let Inst{12} = idx{1};
9532 let Inst{11} = idx{0};
9533 let Inst{10} = size;
9535 class SIMDLdStSingleHTied<bit L, bit R, bits<3> opcode, bit size, string asm,
9536 dag oops, dag iops, list<dag> pattern>
9537 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
9538 oops, iops, pattern> {
9539 // idx encoded in Q:S:size<1> fields.
9541 let Inst{30} = idx{2};
9543 let Inst{20-16} = 0b00000;
9544 let Inst{12} = idx{1};
9545 let Inst{11} = idx{0};
9546 let Inst{10} = size;
9549 class SIMDLdStSingleHPost<bit L, bit R, bits<3> opcode, bit size, string asm,
9551 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9552 "$Rn = $wback", oops, iops, []> {
9553 // idx encoded in Q:S:size<1> fields.
9556 let Inst{30} = idx{2};
9558 let Inst{20-16} = Xm;
9559 let Inst{12} = idx{1};
9560 let Inst{11} = idx{0};
9561 let Inst{10} = size;
9563 class SIMDLdStSingleHTiedPost<bit L, bit R, bits<3> opcode, bit size, string asm,
9565 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9566 "$Rn = $wback", oops, iops, []> {
9567 // idx encoded in Q:S:size<1> fields.
9570 let Inst{30} = idx{2};
9572 let Inst{20-16} = Xm;
9573 let Inst{12} = idx{1};
9574 let Inst{11} = idx{0};
9575 let Inst{10} = size;
9577 class SIMDLdStSingleS<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
9578 dag oops, dag iops, list<dag> pattern>
9579 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
9581 // idx encoded in Q:S fields.
9583 let Inst{30} = idx{1};
9585 let Inst{20-16} = 0b00000;
9586 let Inst{12} = idx{0};
9587 let Inst{11-10} = size;
9589 class SIMDLdStSingleSTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
9590 dag oops, dag iops, list<dag> pattern>
9591 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
9592 oops, iops, pattern> {
9593 // idx encoded in Q:S fields.
9595 let Inst{30} = idx{1};
9597 let Inst{20-16} = 0b00000;
9598 let Inst{12} = idx{0};
9599 let Inst{11-10} = size;
9601 class SIMDLdStSingleSPost<bit L, bit R, bits<3> opcode, bits<2> size,
9602 string asm, dag oops, dag iops>
9603 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9604 "$Rn = $wback", oops, iops, []> {
9605 // idx encoded in Q:S fields.
9608 let Inst{30} = idx{1};
9610 let Inst{20-16} = Xm;
9611 let Inst{12} = idx{0};
9612 let Inst{11-10} = size;
9614 class SIMDLdStSingleSTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
9615 string asm, dag oops, dag iops>
9616 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9617 "$Rn = $wback", oops, iops, []> {
9618 // idx encoded in Q:S fields.
9621 let Inst{30} = idx{1};
9623 let Inst{20-16} = Xm;
9624 let Inst{12} = idx{0};
9625 let Inst{11-10} = size;
9627 class SIMDLdStSingleD<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
9628 dag oops, dag iops, list<dag> pattern>
9629 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "", oops, iops,
9631 // idx encoded in Q field.
9635 let Inst{20-16} = 0b00000;
9637 let Inst{11-10} = size;
9639 class SIMDLdStSingleDTied<bit L, bit R, bits<3> opcode, bits<2> size, string asm,
9640 dag oops, dag iops, list<dag> pattern>
9641 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn]", "",
9642 oops, iops, pattern> {
9643 // idx encoded in Q field.
9647 let Inst{20-16} = 0b00000;
9649 let Inst{11-10} = size;
9651 class SIMDLdStSingleDPost<bit L, bit R, bits<3> opcode, bits<2> size,
9652 string asm, dag oops, dag iops>
9653 : BaseSIMDLdStSingle<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9654 "$Rn = $wback", oops, iops, []> {
9655 // idx encoded in Q field.
9660 let Inst{20-16} = Xm;
9662 let Inst{11-10} = size;
9664 class SIMDLdStSingleDTiedPost<bit L, bit R, bits<3> opcode, bits<2> size,
9665 string asm, dag oops, dag iops>
9666 : BaseSIMDLdStSingleTied<L, R, opcode, asm, "\t$Vt$idx, [$Rn], $Xm",
9667 "$Rn = $wback", oops, iops, []> {
9668 // idx encoded in Q field.
9673 let Inst{20-16} = Xm;
9675 let Inst{11-10} = size;
9678 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
9679 multiclass SIMDLdSingleBTied<bit R, bits<3> opcode, string asm,
9680 RegisterOperand listtype,
9681 RegisterOperand GPR64pi> {
9682 def i8 : SIMDLdStSingleBTied<1, R, opcode, asm,
9683 (outs listtype:$dst),
9684 (ins listtype:$Vt, VectorIndexB:$idx,
9687 def i8_POST : SIMDLdStSingleBTiedPost<1, R, opcode, asm,
9688 (outs GPR64sp:$wback, listtype:$dst),
9689 (ins listtype:$Vt, VectorIndexB:$idx,
9690 GPR64sp:$Rn, GPR64pi:$Xm)>;
9692 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
9693 multiclass SIMDLdSingleHTied<bit R, bits<3> opcode, bit size, string asm,
9694 RegisterOperand listtype,
9695 RegisterOperand GPR64pi> {
9696 def i16 : SIMDLdStSingleHTied<1, R, opcode, size, asm,
9697 (outs listtype:$dst),
9698 (ins listtype:$Vt, VectorIndexH:$idx,
9701 def i16_POST : SIMDLdStSingleHTiedPost<1, R, opcode, size, asm,
9702 (outs GPR64sp:$wback, listtype:$dst),
9703 (ins listtype:$Vt, VectorIndexH:$idx,
9704 GPR64sp:$Rn, GPR64pi:$Xm)>;
9706 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
9707 multiclass SIMDLdSingleSTied<bit R, bits<3> opcode, bits<2> size,string asm,
9708 RegisterOperand listtype,
9709 RegisterOperand GPR64pi> {
9710 def i32 : SIMDLdStSingleSTied<1, R, opcode, size, asm,
9711 (outs listtype:$dst),
9712 (ins listtype:$Vt, VectorIndexS:$idx,
9715 def i32_POST : SIMDLdStSingleSTiedPost<1, R, opcode, size, asm,
9716 (outs GPR64sp:$wback, listtype:$dst),
9717 (ins listtype:$Vt, VectorIndexS:$idx,
9718 GPR64sp:$Rn, GPR64pi:$Xm)>;
9720 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
9721 multiclass SIMDLdSingleDTied<bit R, bits<3> opcode, bits<2> size, string asm,
9722 RegisterOperand listtype, RegisterOperand GPR64pi> {
9723 def i64 : SIMDLdStSingleDTied<1, R, opcode, size, asm,
9724 (outs listtype:$dst),
9725 (ins listtype:$Vt, VectorIndexD:$idx,
9728 def i64_POST : SIMDLdStSingleDTiedPost<1, R, opcode, size, asm,
9729 (outs GPR64sp:$wback, listtype:$dst),
9730 (ins listtype:$Vt, VectorIndexD:$idx,
9731 GPR64sp:$Rn, GPR64pi:$Xm)>;
9733 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
9734 multiclass SIMDStSingleB<bit R, bits<3> opcode, string asm,
9735 RegisterOperand listtype, RegisterOperand GPR64pi> {
9736 def i8 : SIMDLdStSingleB<0, R, opcode, asm,
9737 (outs), (ins listtype:$Vt, VectorIndexB:$idx,
9740 def i8_POST : SIMDLdStSingleBPost<0, R, opcode, asm,
9741 (outs GPR64sp:$wback),
9742 (ins listtype:$Vt, VectorIndexB:$idx,
9743 GPR64sp:$Rn, GPR64pi:$Xm)>;
9745 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
9746 multiclass SIMDStSingleH<bit R, bits<3> opcode, bit size, string asm,
9747 RegisterOperand listtype, RegisterOperand GPR64pi> {
9748 def i16 : SIMDLdStSingleH<0, R, opcode, size, asm,
9749 (outs), (ins listtype:$Vt, VectorIndexH:$idx,
9752 def i16_POST : SIMDLdStSingleHPost<0, R, opcode, size, asm,
9753 (outs GPR64sp:$wback),
9754 (ins listtype:$Vt, VectorIndexH:$idx,
9755 GPR64sp:$Rn, GPR64pi:$Xm)>;
9757 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
9758 multiclass SIMDStSingleS<bit R, bits<3> opcode, bits<2> size,string asm,
9759 RegisterOperand listtype, RegisterOperand GPR64pi> {
9760 def i32 : SIMDLdStSingleS<0, R, opcode, size, asm,
9761 (outs), (ins listtype:$Vt, VectorIndexS:$idx,
9764 def i32_POST : SIMDLdStSingleSPost<0, R, opcode, size, asm,
9765 (outs GPR64sp:$wback),
9766 (ins listtype:$Vt, VectorIndexS:$idx,
9767 GPR64sp:$Rn, GPR64pi:$Xm)>;
9769 let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in
9770 multiclass SIMDStSingleD<bit R, bits<3> opcode, bits<2> size, string asm,
9771 RegisterOperand listtype, RegisterOperand GPR64pi> {
9772 def i64 : SIMDLdStSingleD<0, R, opcode, size, asm,
9773 (outs), (ins listtype:$Vt, VectorIndexD:$idx,
9776 def i64_POST : SIMDLdStSingleDPost<0, R, opcode, size, asm,
9777 (outs GPR64sp:$wback),
9778 (ins listtype:$Vt, VectorIndexD:$idx,
9779 GPR64sp:$Rn, GPR64pi:$Xm)>;
9782 multiclass SIMDLdStSingleAliases<string asm, string layout, string Type,
9783 string Count, int Offset, Operand idxtype> {
9784 // E.g. "ld1 { v0.8b }[0], [x1], #1"
9785 // "ld1\t$Vt, [$Rn], #1"
9786 // may get mapped to
9787 // (LD1Rv8b_POST VecListOne8b:$Vt, GPR64sp:$Rn, XZR)
9788 def : InstAlias<asm # "\t$Vt$idx, [$Rn], #" # Offset,
9789 (!cast<Instruction>(NAME # Type # "_POST")
9791 !cast<RegisterOperand>("VecList" # Count # layout):$Vt,
9792 idxtype:$idx, XZR), 1>;
9794 // E.g. "ld1.8b { v0 }[0], [x1], #1"
9795 // "ld1.8b\t$Vt, [$Rn], #1"
9796 // may get mapped to
9797 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, XZR)
9798 def : InstAlias<asm # "." # layout # "\t$Vt$idx, [$Rn], #" # Offset,
9799 (!cast<Instruction>(NAME # Type # "_POST")
9801 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
9802 idxtype:$idx, XZR), 0>;
9804 // E.g. "ld1.8b { v0 }[0], [x1]"
9805 // "ld1.8b\t$Vt, [$Rn]"
9806 // may get mapped to
9807 // (LD1Rv8b VecListOne64:$Vt, GPR64sp:$Rn)
9808 def : InstAlias<asm # "." # layout # "\t$Vt$idx, [$Rn]",
9809 (!cast<Instruction>(NAME # Type)
9810 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
9811 idxtype:$idx, GPR64sp:$Rn), 0>;
9813 // E.g. "ld1.8b { v0 }[0], [x1], x2"
9814 // "ld1.8b\t$Vt, [$Rn], $Xm"
9815 // may get mapped to
9816 // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, GPR64pi1:$Xm)
9817 def : InstAlias<asm # "." # layout # "\t$Vt$idx, [$Rn], $Xm",
9818 (!cast<Instruction>(NAME # Type # "_POST")
9820 !cast<RegisterOperand>("VecList" # Count # "128"):$Vt,
9822 !cast<RegisterOperand>("GPR64pi" # Offset):$Xm), 0>;
9825 multiclass SIMDLdSt1SingleAliases<string asm> {
9826 defm "" : SIMDLdStSingleAliases<asm, "b", "i8", "One", 1, VectorIndexB>;
9827 defm "" : SIMDLdStSingleAliases<asm, "h", "i16", "One", 2, VectorIndexH>;
9828 defm "" : SIMDLdStSingleAliases<asm, "s", "i32", "One", 4, VectorIndexS>;
9829 defm "" : SIMDLdStSingleAliases<asm, "d", "i64", "One", 8, VectorIndexD>;
9832 multiclass SIMDLdSt2SingleAliases<string asm> {
9833 defm "" : SIMDLdStSingleAliases<asm, "b", "i8", "Two", 2, VectorIndexB>;
9834 defm "" : SIMDLdStSingleAliases<asm, "h", "i16", "Two", 4, VectorIndexH>;
9835 defm "" : SIMDLdStSingleAliases<asm, "s", "i32", "Two", 8, VectorIndexS>;
9836 defm "" : SIMDLdStSingleAliases<asm, "d", "i64", "Two", 16, VectorIndexD>;
9839 multiclass SIMDLdSt3SingleAliases<string asm> {
9840 defm "" : SIMDLdStSingleAliases<asm, "b", "i8", "Three", 3, VectorIndexB>;
9841 defm "" : SIMDLdStSingleAliases<asm, "h", "i16", "Three", 6, VectorIndexH>;
9842 defm "" : SIMDLdStSingleAliases<asm, "s", "i32", "Three", 12, VectorIndexS>;
9843 defm "" : SIMDLdStSingleAliases<asm, "d", "i64", "Three", 24, VectorIndexD>;
9846 multiclass SIMDLdSt4SingleAliases<string asm> {
9847 defm "" : SIMDLdStSingleAliases<asm, "b", "i8", "Four", 4, VectorIndexB>;
9848 defm "" : SIMDLdStSingleAliases<asm, "h", "i16", "Four", 8, VectorIndexH>;
9849 defm "" : SIMDLdStSingleAliases<asm, "s", "i32", "Four", 16, VectorIndexS>;
9850 defm "" : SIMDLdStSingleAliases<asm, "d", "i64", "Four", 32, VectorIndexD>;
9852 } // end of 'let Predicates = [HasNEON]'
9854 //----------------------------------------------------------------------------
9855 // AdvSIMD v8.1 Rounding Double Multiply Add/Subtract
9856 //----------------------------------------------------------------------------
9858 let Predicates = [HasNEON, HasRDM] in {
9860 class BaseSIMDThreeSameVectorTiedR0<bit Q, bit U, bits<2> size, bits<5> opcode,
9861 RegisterOperand regtype, string asm,
9862 string kind, list<dag> pattern>
9863 : BaseSIMDThreeSameVectorTied<Q, U, {size,0}, opcode, regtype, asm, kind,
9866 multiclass SIMDThreeSameVectorSQRDMLxHTiedHS<bit U, bits<5> opc, string asm,
9867 SDPatternOperator Accum> {
9868 def v4i16 : BaseSIMDThreeSameVectorTiedR0<0, U, 0b01, opc, V64, asm, ".4h",
9869 [(set (v4i16 V64:$dst),
9870 (Accum (v4i16 V64:$Rd),
9871 (v4i16 (int_aarch64_neon_sqrdmulh (v4i16 V64:$Rn),
9872 (v4i16 V64:$Rm)))))]>;
9873 def v8i16 : BaseSIMDThreeSameVectorTiedR0<1, U, 0b01, opc, V128, asm, ".8h",
9874 [(set (v8i16 V128:$dst),
9875 (Accum (v8i16 V128:$Rd),
9876 (v8i16 (int_aarch64_neon_sqrdmulh (v8i16 V128:$Rn),
9877 (v8i16 V128:$Rm)))))]>;
9878 def v2i32 : BaseSIMDThreeSameVectorTiedR0<0, U, 0b10, opc, V64, asm, ".2s",
9879 [(set (v2i32 V64:$dst),
9880 (Accum (v2i32 V64:$Rd),
9881 (v2i32 (int_aarch64_neon_sqrdmulh (v2i32 V64:$Rn),
9882 (v2i32 V64:$Rm)))))]>;
9883 def v4i32 : BaseSIMDThreeSameVectorTiedR0<1, U, 0b10, opc, V128, asm, ".4s",
9884 [(set (v4i32 V128:$dst),
9885 (Accum (v4i32 V128:$Rd),
9886 (v4i32 (int_aarch64_neon_sqrdmulh (v4i32 V128:$Rn),
9887 (v4i32 V128:$Rm)))))]>;
9890 multiclass SIMDIndexedSQRDMLxHSDTied<bit U, bits<4> opc, string asm,
9891 SDPatternOperator Accum> {
9892 def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc,
9893 V64, V64, V128_lo, VectorIndexH,
9894 asm, ".4h", ".4h", ".4h", ".h",
9895 [(set (v4i16 V64:$dst),
9896 (Accum (v4i16 V64:$Rd),
9897 (v4i16 (int_aarch64_neon_sqrdmulh
9899 (v4i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
9900 VectorIndexH:$idx))))))]> {
9902 let Inst{11} = idx{2};
9903 let Inst{21} = idx{1};
9904 let Inst{20} = idx{0};
9907 def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc,
9908 V128, V128, V128_lo, VectorIndexH,
9909 asm, ".8h", ".8h", ".8h", ".h",
9910 [(set (v8i16 V128:$dst),
9911 (Accum (v8i16 V128:$Rd),
9912 (v8i16 (int_aarch64_neon_sqrdmulh
9914 (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm),
9915 VectorIndexH:$idx))))))]> {
9917 let Inst{11} = idx{2};
9918 let Inst{21} = idx{1};
9919 let Inst{20} = idx{0};
9922 def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc,
9923 V64, V64, V128, VectorIndexS,
9924 asm, ".2s", ".2s", ".2s", ".s",
9925 [(set (v2i32 V64:$dst),
9926 (Accum (v2i32 V64:$Rd),
9927 (v2i32 (int_aarch64_neon_sqrdmulh
9929 (v2i32 (AArch64duplane32 (v4i32 V128:$Rm),
9930 VectorIndexS:$idx))))))]> {
9932 let Inst{11} = idx{1};
9933 let Inst{21} = idx{0};
9936 // FIXME: it would be nice to use the scalar (v1i32) instruction here, but
9937 // an intermediate EXTRACT_SUBREG would be untyped.
9938 // FIXME: direct EXTRACT_SUBREG from v2i32 to i32 is illegal, that's why we
9939 // got it lowered here as (i32 vector_extract (v4i32 insert_subvector(..)))
9940 def : Pat<(i32 (Accum (i32 FPR32Op:$Rd),
9941 (i32 (vector_extract
9942 (v4i32 (insert_subvector
9944 (v2i32 (int_aarch64_neon_sqrdmulh
9946 (v2i32 (AArch64duplane32
9948 VectorIndexS:$idx)))),
9952 (v2i32 (!cast<Instruction>(NAME # v2i32_indexed)
9953 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
9958 VectorIndexS:$idx)),
9961 def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc,
9962 V128, V128, V128, VectorIndexS,
9963 asm, ".4s", ".4s", ".4s", ".s",
9964 [(set (v4i32 V128:$dst),
9965 (Accum (v4i32 V128:$Rd),
9966 (v4i32 (int_aarch64_neon_sqrdmulh
9968 (v4i32 (AArch64duplane32 (v4i32 V128:$Rm),
9969 VectorIndexS:$idx))))))]> {
9971 let Inst{11} = idx{1};
9972 let Inst{21} = idx{0};
9975 // FIXME: it would be nice to use the scalar (v1i32) instruction here, but
9976 // an intermediate EXTRACT_SUBREG would be untyped.
9977 def : Pat<(i32 (Accum (i32 FPR32Op:$Rd),
9978 (i32 (vector_extract
9979 (v4i32 (int_aarch64_neon_sqrdmulh
9981 (v4i32 (AArch64duplane32
9983 VectorIndexS:$idx)))),
9986 (v4i32 (!cast<Instruction>(NAME # v4i32_indexed)
9987 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
9992 VectorIndexS:$idx)),
9995 def i16_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc,
9996 FPR16Op, FPR16Op, V128_lo,
9997 VectorIndexH, asm, ".h", "", "", ".h",
10000 let Inst{11} = idx{2};
10001 let Inst{21} = idx{1};
10002 let Inst{20} = idx{0};
10005 def i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc,
10006 FPR32Op, FPR32Op, V128, VectorIndexS,
10007 asm, ".s", "", "", ".s",
10008 [(set (i32 FPR32Op:$dst),
10009 (Accum (i32 FPR32Op:$Rd),
10010 (i32 (int_aarch64_neon_sqrdmulh
10012 (i32 (vector_extract (v4i32 V128:$Rm),
10013 VectorIndexS:$idx))))))]> {
10015 let Inst{11} = idx{1};
10016 let Inst{21} = idx{0};
10019 } // let Predicates = [HasNeon, HasRDM]
10021 //----------------------------------------------------------------------------
10022 // ARMv8.3 Complex ADD/MLA instructions
10023 //----------------------------------------------------------------------------
10025 class ComplexRotationOperand<int Angle, int Remainder, string Type>
10026 : AsmOperandClass {
10027 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
10028 let DiagnosticType = "InvalidComplexRotation" # Type;
10029 let Name = "ComplexRotation" # Type;
10031 def complexrotateop : Operand<i32> {
10032 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even">;
10033 let PrintMethod = "printComplexRotationOp<90, 0>";
10035 def complexrotateopodd : Operand<i32> {
10036 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd">;
10037 let PrintMethod = "printComplexRotationOp<180, 90>";
10040 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
10041 class BaseSIMDThreeSameVectorComplex<bit Q, bit U, bits<2> size, bits<3> opcode,
10042 RegisterOperand regtype, Operand rottype,
10043 string asm, string kind, list<dag> pattern>
10044 : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, rottype:$rot), asm,
10045 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $rot"
10046 "|" # kind # "\t$Rd, $Rn, $Rm, $rot}", "", pattern>,
10055 let Inst{28-24} = 0b01110;
10056 let Inst{23-22} = size;
10058 let Inst{20-16} = Rm;
10059 let Inst{15-13} = opcode;
10060 // Non-tied version (FCADD) only has one rotation bit
10061 let Inst{12} = rot;
10064 let Inst{9-5} = Rn;
10065 let Inst{4-0} = Rd;
10068 //8.3 CompNum - Floating-point complex number support
10069 multiclass SIMDThreeSameVectorComplexHSD<bit U, bits<3> opcode, Operand rottype,
10070 string asm, SDPatternOperator OpNode>{
10071 let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
10072 def v4f16 : BaseSIMDThreeSameVectorComplex<0, U, 0b01, opcode, V64, rottype,
10074 [(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd),
10077 (rottype i32:$rot)))]>;
10079 def v8f16 : BaseSIMDThreeSameVectorComplex<1, U, 0b01, opcode, V128, rottype,
10081 [(set (v8f16 V128:$dst), (OpNode (v8f16 V128:$Rd),
10084 (rottype i32:$rot)))]>;
10087 let Predicates = [HasComplxNum, HasNEON] in {
10088 def v2f32 : BaseSIMDThreeSameVectorComplex<0, U, 0b10, opcode, V64, rottype,
10090 [(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd),
10093 (rottype i32:$rot)))]>;
10095 def v4f32 : BaseSIMDThreeSameVectorComplex<1, U, 0b10, opcode, V128, rottype,
10097 [(set (v4f32 V128:$dst), (OpNode (v4f32 V128:$Rd),
10100 (rottype i32:$rot)))]>;
10102 def v2f64 : BaseSIMDThreeSameVectorComplex<1, U, 0b11, opcode, V128, rottype,
10104 [(set (v2f64 V128:$dst), (OpNode (v2f64 V128:$Rd),
10107 (rottype i32:$rot)))]>;
10111 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
10112 class BaseSIMDThreeSameVectorTiedComplex<bit Q, bit U, bits<2> size,
10114 RegisterOperand regtype,
10115 Operand rottype, string asm,
10116 string kind, list<dag> pattern>
10117 : I<(outs regtype:$dst),
10118 (ins regtype:$Rd, regtype:$Rn, regtype:$Rm, rottype:$rot), asm,
10119 "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $rot"
10120 "|" # kind # "\t$Rd, $Rn, $Rm, $rot}", "$Rd = $dst", pattern>,
10129 let Inst{28-24} = 0b01110;
10130 let Inst{23-22} = size;
10132 let Inst{20-16} = Rm;
10133 let Inst{15-13} = opcode;
10134 let Inst{12-11} = rot;
10136 let Inst{9-5} = Rn;
10137 let Inst{4-0} = Rd;
10140 multiclass SIMDThreeSameVectorTiedComplexHSD<bit U, bits<3> opcode,
10141 Operand rottype, string asm,
10142 SDPatternOperator OpNode> {
10143 let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
10144 def v4f16 : BaseSIMDThreeSameVectorTiedComplex<0, U, 0b01, opcode, V64,
10145 rottype, asm, ".4h",
10146 [(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd),
10149 (rottype i32:$rot)))]>;
10151 def v8f16 : BaseSIMDThreeSameVectorTiedComplex<1, U, 0b01, opcode, V128,
10152 rottype, asm, ".8h",
10153 [(set (v8f16 V128:$dst), (OpNode (v8f16 V128:$Rd),
10156 (rottype i32:$rot)))]>;
10159 let Predicates = [HasComplxNum, HasNEON] in {
10160 def v2f32 : BaseSIMDThreeSameVectorTiedComplex<0, U, 0b10, opcode, V64,
10161 rottype, asm, ".2s",
10162 [(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd),
10165 (rottype i32:$rot)))]>;
10167 def v4f32 : BaseSIMDThreeSameVectorTiedComplex<1, U, 0b10, opcode, V128,
10168 rottype, asm, ".4s",
10169 [(set (v4f32 V128:$dst), (OpNode (v4f32 V128:$Rd),
10172 (rottype i32:$rot)))]>;
10174 def v2f64 : BaseSIMDThreeSameVectorTiedComplex<1, U, 0b11, opcode, V128,
10175 rottype, asm, ".2d",
10176 [(set (v2f64 V128:$dst), (OpNode (v2f64 V128:$Rd),
10179 (rottype i32:$rot)))]>;
10183 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
10184 class BaseSIMDIndexedTiedComplex<bit Q, bit U, bit Scalar, bits<2> size,
10185 bit opc1, bit opc2, RegisterOperand dst_reg,
10186 RegisterOperand lhs_reg,
10187 RegisterOperand rhs_reg, Operand vec_idx,
10188 Operand rottype, string asm, string apple_kind,
10189 string dst_kind, string lhs_kind,
10190 string rhs_kind, list<dag> pattern>
10191 : I<(outs dst_reg:$dst),
10192 (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx, rottype:$rot),
10194 "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind #
10195 "$idx, $rot" # "|" # apple_kind #
10196 "\t$Rd, $Rn, $Rm$idx, $rot}", "$Rd = $dst", pattern>,
10206 let Inst{28} = Scalar;
10207 let Inst{27-24} = 0b1111;
10208 let Inst{23-22} = size;
10209 // Bit 21 must be set by the derived class.
10210 let Inst{20-16} = Rm;
10211 let Inst{15} = opc1;
10212 let Inst{14-13} = rot;
10213 let Inst{12} = opc2;
10214 // Bit 11 must be set by the derived class.
10216 let Inst{9-5} = Rn;
10217 let Inst{4-0} = Rd;
10220 // The complex instructions index by pairs of elements, so the VectorIndexes
10221 // don't match the lane types, and the index bits are different to the other
10223 multiclass SIMDIndexedTiedComplexHSD<bit U, bit opc1, bit opc2, Operand rottype,
10224 string asm, SDPatternOperator OpNode> {
10225 let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
10226 def v4f16_indexed : BaseSIMDIndexedTiedComplex<0, 1, 0, 0b01, opc1, opc2, V64,
10227 V64, V128, VectorIndexD, rottype, asm, ".4h", ".4h",
10231 let Inst{21} = idx{0};
10234 def v8f16_indexed : BaseSIMDIndexedTiedComplex<1, 1, 0, 0b01, opc1, opc2,
10235 V128, V128, V128, VectorIndexS, rottype, asm, ".8h",
10236 ".8h", ".8h", ".h", []> {
10238 let Inst{11} = idx{1};
10239 let Inst{21} = idx{0};
10241 } // Predicates = HasComplxNum, HasNEON, HasFullFP16]
10243 let Predicates = [HasComplxNum, HasNEON] in {
10244 def v4f32_indexed : BaseSIMDIndexedTiedComplex<1, 1, 0, 0b10, opc1, opc2,
10245 V128, V128, V128, VectorIndexD, rottype, asm, ".4s",
10246 ".4s", ".4s", ".s", []> {
10248 let Inst{11} = idx{0};
10251 } // Predicates = [HasComplxNum, HasNEON]
10254 //----------------------------------------------------------------------------
10255 // Crypto extensions
10256 //----------------------------------------------------------------------------
10258 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
10259 class AESBase<bits<4> opc, string asm, dag outs, dag ins, string cstr,
10261 : I<outs, ins, asm, "{\t$Rd.16b, $Rn.16b|.16b\t$Rd, $Rn}", cstr, pat>,
10265 let Inst{31-16} = 0b0100111000101000;
10266 let Inst{15-12} = opc;
10267 let Inst{11-10} = 0b10;
10268 let Inst{9-5} = Rn;
10269 let Inst{4-0} = Rd;
10272 class AESInst<bits<4> opc, string asm, Intrinsic OpNode>
10273 : AESBase<opc, asm, (outs V128:$Rd), (ins V128:$Rn), "",
10274 [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>;
10276 class AESTiedInst<bits<4> opc, string asm, Intrinsic OpNode>
10277 : AESBase<opc, asm, (outs V128:$dst), (ins V128:$Rd, V128:$Rn),
10279 [(set (v16i8 V128:$dst),
10280 (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>;
10282 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
10283 class SHA3OpTiedInst<bits<3> opc, string asm, string dst_lhs_kind,
10284 dag oops, dag iops, list<dag> pat>
10285 : I<oops, iops, asm,
10286 "{\t$Rd" # dst_lhs_kind # ", $Rn" # dst_lhs_kind # ", $Rm.4s" #
10287 "|.4s\t$Rd, $Rn, $Rm}", "$Rd = $dst", pat>,
10292 let Inst{31-21} = 0b01011110000;
10293 let Inst{20-16} = Rm;
10295 let Inst{14-12} = opc;
10296 let Inst{11-10} = 0b00;
10297 let Inst{9-5} = Rn;
10298 let Inst{4-0} = Rd;
10301 class SHATiedInstQSV<bits<3> opc, string asm, Intrinsic OpNode>
10302 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
10303 (ins FPR128:$Rd, FPR32:$Rn, V128:$Rm),
10304 [(set (v4i32 FPR128:$dst),
10305 (OpNode (v4i32 FPR128:$Rd), (i32 FPR32:$Rn),
10306 (v4i32 V128:$Rm)))]>;
10308 class SHATiedInstVVV<bits<3> opc, string asm, Intrinsic OpNode>
10309 : SHA3OpTiedInst<opc, asm, ".4s", (outs V128:$dst),
10310 (ins V128:$Rd, V128:$Rn, V128:$Rm),
10311 [(set (v4i32 V128:$dst),
10312 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn),
10313 (v4i32 V128:$Rm)))]>;
10315 class SHATiedInstQQV<bits<3> opc, string asm, Intrinsic OpNode>
10316 : SHA3OpTiedInst<opc, asm, "", (outs FPR128:$dst),
10317 (ins FPR128:$Rd, FPR128:$Rn, V128:$Rm),
10318 [(set (v4i32 FPR128:$dst),
10319 (OpNode (v4i32 FPR128:$Rd), (v4i32 FPR128:$Rn),
10320 (v4i32 V128:$Rm)))]>;
10322 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in
10323 class SHA2OpInst<bits<4> opc, string asm, string kind,
10324 string cstr, dag oops, dag iops,
10326 : I<oops, iops, asm, "{\t$Rd" # kind # ", $Rn" # kind #
10327 "|" # kind # "\t$Rd, $Rn}", cstr, pat>,
10331 let Inst{31-16} = 0b0101111000101000;
10332 let Inst{15-12} = opc;
10333 let Inst{11-10} = 0b10;
10334 let Inst{9-5} = Rn;
10335 let Inst{4-0} = Rd;
10338 class SHATiedInstVV<bits<4> opc, string asm, Intrinsic OpNode>
10339 : SHA2OpInst<opc, asm, ".4s", "$Rd = $dst", (outs V128:$dst),
10340 (ins V128:$Rd, V128:$Rn),
10341 [(set (v4i32 V128:$dst),
10342 (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>;
10344 class SHAInstSS<bits<4> opc, string asm, Intrinsic OpNode>
10345 : SHA2OpInst<opc, asm, "", "", (outs FPR32:$Rd), (ins FPR32:$Rn),
10346 [(set (i32 FPR32:$Rd), (OpNode (i32 FPR32:$Rn)))]>;
10348 // Armv8.2-A Crypto extensions
10349 class BaseCryptoV82<dag oops, dag iops, string asm, string asmops, string cst,
10351 : I <oops, iops, asm, asmops, cst, pattern>, Sched<[WriteV]> {
10354 let Inst{31-25} = 0b1100111;
10355 let Inst{9-5} = Vn;
10356 let Inst{4-0} = Vd;
10359 class CryptoRRTied<bits<1>op0, bits<2>op1, string asm, string asmops>
10360 : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm), asm, asmops,
10362 let Inst{31-25} = 0b1100111;
10363 let Inst{24-21} = 0b0110;
10364 let Inst{20-15} = 0b000001;
10365 let Inst{14} = op0;
10366 let Inst{13-12} = 0b00;
10367 let Inst{11-10} = op1;
10369 class CryptoRRTied_2D<bits<1>op0, bits<2>op1, string asm>
10370 : CryptoRRTied<op0, op1, asm, "{\t$Vd.2d, $Vn.2d}">;
10371 class CryptoRRTied_4S<bits<1>op0, bits<2>op1, string asm>
10372 : CryptoRRTied<op0, op1, asm, "{\t$Vd.4s, $Vn.4s}">;
10374 class CryptoRRR<bits<1> op0, bits<2>op1, dag oops, dag iops, string asm,
10375 string asmops, string cst>
10376 : BaseCryptoV82<oops, iops, asm , asmops, cst, []> {
10378 let Inst{24-21} = 0b0011;
10379 let Inst{20-16} = Vm;
10380 let Inst{15} = 0b1;
10381 let Inst{14} = op0;
10382 let Inst{13-12} = 0b00;
10383 let Inst{11-10} = op1;
10385 class CryptoRRR_2D<bits<1> op0, bits<2>op1, string asm>
10386 : CryptoRRR<op0, op1, (outs V128:$Vd), (ins V128:$Vn, V128:$Vm), asm,
10387 "{\t$Vd.2d, $Vn.2d, $Vm.2d}", "">;
10388 class CryptoRRRTied_2D<bits<1> op0, bits<2>op1, string asm>
10389 : CryptoRRR<op0, op1, (outs V128:$Vdst), (ins V128:$Vd, V128:$Vn, V128:$Vm), asm,
10390 "{\t$Vd.2d, $Vn.2d, $Vm.2d}", "$Vd = $Vdst">;
10391 class CryptoRRR_4S<bits<1> op0, bits<2>op1, string asm>
10392 : CryptoRRR<op0, op1, (outs V128:$Vd), (ins V128:$Vn, V128:$Vm), asm,
10393 "{\t$Vd.4s, $Vn.4s, $Vm.4s}", "">;
10394 class CryptoRRRTied_4S<bits<1> op0, bits<2>op1, string asm>
10395 : CryptoRRR<op0, op1, (outs V128:$Vdst), (ins V128:$Vd, V128:$Vn, V128:$Vm), asm,
10396 "{\t$Vd.4s, $Vn.4s, $Vm.4s}", "$Vd = $Vdst">;
10397 class CryptoRRRTied<bits<1> op0, bits<2>op1, string asm>
10398 : CryptoRRR<op0, op1, (outs FPR128:$Vdst), (ins FPR128:$Vd, FPR128:$Vn, V128:$Vm),
10399 asm, "{\t$Vd, $Vn, $Vm.2d}", "$Vd = $Vdst">;
10401 class CryptoRRRR<bits<2>op0, string asm, string asmops>
10402 : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm, V128:$Va), asm,
10406 let Inst{24-23} = 0b00;
10407 let Inst{22-21} = op0;
10408 let Inst{20-16} = Vm;
10409 let Inst{15} = 0b0;
10410 let Inst{14-10} = Va;
10412 class CryptoRRRR_16B<bits<2>op0, string asm>
10413 : CryptoRRRR<op0, asm, "{\t$Vd.16b, $Vn.16b, $Vm.16b, $Va.16b}"> {
10415 class CryptoRRRR_4S<bits<2>op0, string asm>
10416 : CryptoRRRR<op0, asm, "{\t$Vd.4s, $Vn.4s, $Vm.4s, $Va.4s}"> {
10419 class CryptoRRRi6<string asm>
10420 : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm, uimm6:$imm), asm,
10421 "{\t$Vd.2d, $Vn.2d, $Vm.2d, $imm}", "", []> {
10424 let Inst{24-21} = 0b0100;
10425 let Inst{20-16} = Vm;
10426 let Inst{15-10} = imm;
10427 let Inst{9-5} = Vn;
10428 let Inst{4-0} = Vd;
10431 class CryptoRRRi2Tied<bits<1>op0, bits<2>op1, string asm>
10432 : BaseCryptoV82<(outs V128:$Vdst),
10433 (ins V128:$Vd, V128:$Vn, V128:$Vm, VectorIndexS:$imm),
10434 asm, "{\t$Vd.4s, $Vn.4s, $Vm.s$imm}", "$Vd = $Vdst", []> {
10437 let Inst{24-21} = 0b0010;
10438 let Inst{20-16} = Vm;
10439 let Inst{15} = 0b1;
10440 let Inst{14} = op0;
10441 let Inst{13-12} = imm;
10442 let Inst{11-10} = op1;
10445 //----------------------------------------------------------------------------
10446 // v8.1 atomic instructions extension:
10450 // * LDOPregister<OP>, and aliases STOPregister<OP>
10452 // Instruction encodings:
10454 // 31 30|29 24|23|22|21|20 16|15|14 10|9 5|4 0
10455 // CAS SZ |001000|1 |A |1 |Rs |R |11111 |Rn |Rt
10456 // CASP 0|SZ|001000|0 |A |1 |Rs |R |11111 |Rn |Rt
10457 // SWP SZ |111000|A |R |1 |Rs |1 |OPC|00|Rn |Rt
10458 // LD SZ |111000|A |R |1 |Rs |0 |OPC|00|Rn |Rt
10459 // ST SZ |111000|A |R |1 |Rs |0 |OPC|00|Rn |11111
10461 // Instruction syntax:
10463 // CAS{<order>}[<size>] <Ws>, <Wt>, [<Xn|SP>]
10464 // CAS{<order>} <Xs>, <Xt>, [<Xn|SP>]
10465 // CASP{<order>} <Ws>, <W(s+1)>, <Wt>, <W(t+1)>, [<Xn|SP>]
10466 // CASP{<order>} <Xs>, <X(s+1)>, <Xt>, <X(t+1)>, [<Xn|SP>]
10467 // SWP{<order>}[<size>] <Ws>, <Wt>, [<Xn|SP>]
10468 // SWP{<order>} <Xs>, <Xt>, [<Xn|SP>]
10469 // LD<OP>{<order>}[<size>] <Ws>, <Wt>, [<Xn|SP>]
10470 // LD<OP>{<order>} <Xs>, <Xt>, [<Xn|SP>]
10471 // ST<OP>{<order>}[<size>] <Ws>, [<Xn|SP>]
10472 // ST<OP>{<order>} <Xs>, [<Xn|SP>]
10474 let Predicates = [HasLSE], mayLoad = 1, mayStore = 1, hasSideEffects = 1 in
10475 class BaseCASEncoding<dag oops, dag iops, string asm, string operands,
10476 string cstr, list<dag> pattern>
10477 : I<oops, iops, asm, operands, cstr, pattern> {
10485 let Inst{31-30} = Sz;
10486 let Inst{29-24} = 0b001000;
10488 let Inst{22} = Acq;
10489 let Inst{21} = 0b1;
10490 let Inst{20-16} = Rs;
10491 let Inst{15} = Rel;
10492 let Inst{14-10} = 0b11111;
10493 let Inst{9-5} = Rn;
10494 let Inst{4-0} = Rt;
10495 let Predicates = [HasLSE];
10498 class BaseCAS<string order, string size, RegisterClass RC>
10499 : BaseCASEncoding<(outs RC:$out),(ins RC:$Rs, RC:$Rt, GPR64sp:$Rn),
10500 "cas" # order # size, "\t$Rs, $Rt, [$Rn]",
10502 Sched<[WriteAtomic]> {
10506 multiclass CompareAndSwap<bits<1> Acq, bits<1> Rel, string order> {
10507 let Sz = 0b00, Acq = Acq, Rel = Rel in def B : BaseCAS<order, "b", GPR32>;
10508 let Sz = 0b01, Acq = Acq, Rel = Rel in def H : BaseCAS<order, "h", GPR32>;
10509 let Sz = 0b10, Acq = Acq, Rel = Rel in def W : BaseCAS<order, "", GPR32>;
10510 let Sz = 0b11, Acq = Acq, Rel = Rel in def X : BaseCAS<order, "", GPR64>;
10513 class BaseCASP<string order, string size, RegisterOperand RC>
10514 : BaseCASEncoding<(outs RC:$out),(ins RC:$Rs, RC:$Rt, GPR64sp:$Rn),
10515 "casp" # order # size, "\t$Rs, $Rt, [$Rn]",
10517 Sched<[WriteAtomic]> {
10521 multiclass CompareAndSwapPair<bits<1> Acq, bits<1> Rel, string order> {
10522 let Sz = 0b00, Acq = Acq, Rel = Rel in
10523 def W : BaseCASP<order, "", WSeqPairClassOperand>;
10524 let Sz = 0b01, Acq = Acq, Rel = Rel in
10525 def X : BaseCASP<order, "", XSeqPairClassOperand>;
10528 let Predicates = [HasLSE] in
10529 class BaseSWP<string order, string size, RegisterClass RC>
10530 : I<(outs RC:$Rt),(ins RC:$Rs, GPR64sp:$Rn), "swp" # order # size,
10531 "\t$Rs, $Rt, [$Rn]","",[]>,
10532 Sched<[WriteAtomic]> {
10537 bits<3> opc = 0b000;
10540 let Inst{31-30} = Sz;
10541 let Inst{29-24} = 0b111000;
10542 let Inst{23} = Acq;
10543 let Inst{22} = Rel;
10544 let Inst{21} = 0b1;
10545 let Inst{20-16} = Rs;
10546 let Inst{15} = 0b1;
10547 let Inst{14-12} = opc;
10548 let Inst{11-10} = 0b00;
10549 let Inst{9-5} = Rn;
10550 let Inst{4-0} = Rt;
10551 let Predicates = [HasLSE];
10554 multiclass Swap<bits<1> Acq, bits<1> Rel, string order> {
10555 let Sz = 0b00, Acq = Acq, Rel = Rel in def B : BaseSWP<order, "b", GPR32>;
10556 let Sz = 0b01, Acq = Acq, Rel = Rel in def H : BaseSWP<order, "h", GPR32>;
10557 let Sz = 0b10, Acq = Acq, Rel = Rel in def W : BaseSWP<order, "", GPR32>;
10558 let Sz = 0b11, Acq = Acq, Rel = Rel in def X : BaseSWP<order, "", GPR64>;
10561 let Predicates = [HasLSE], mayLoad = 1, mayStore = 1, hasSideEffects = 1 in
10562 class BaseLDOPregister<string op, string order, string size, RegisterClass RC>
10563 : I<(outs RC:$Rt),(ins RC:$Rs, GPR64sp:$Rn), "ld" # op # order # size,
10564 "\t$Rs, $Rt, [$Rn]","",[]>,
10565 Sched<[WriteAtomic]> {
10573 let Inst{31-30} = Sz;
10574 let Inst{29-24} = 0b111000;
10575 let Inst{23} = Acq;
10576 let Inst{22} = Rel;
10577 let Inst{21} = 0b1;
10578 let Inst{20-16} = Rs;
10579 let Inst{15} = 0b0;
10580 let Inst{14-12} = opc;
10581 let Inst{11-10} = 0b00;
10582 let Inst{9-5} = Rn;
10583 let Inst{4-0} = Rt;
10584 let Predicates = [HasLSE];
10587 multiclass LDOPregister<bits<3> opc, string op, bits<1> Acq, bits<1> Rel,
10589 let Sz = 0b00, Acq = Acq, Rel = Rel, opc = opc in
10590 def B : BaseLDOPregister<op, order, "b", GPR32>;
10591 let Sz = 0b01, Acq = Acq, Rel = Rel, opc = opc in
10592 def H : BaseLDOPregister<op, order, "h", GPR32>;
10593 let Sz = 0b10, Acq = Acq, Rel = Rel, opc = opc in
10594 def W : BaseLDOPregister<op, order, "", GPR32>;
10595 let Sz = 0b11, Acq = Acq, Rel = Rel, opc = opc in
10596 def X : BaseLDOPregister<op, order, "", GPR64>;
10599 // Differing SrcRHS and DstRHS allow you to cover CLR & SUB by giving a more
10600 // complex DAG for DstRHS.
10601 let Predicates = [HasLSE] in
10602 multiclass LDOPregister_patterns_ord_dag<string inst, string suffix, string op,
10603 string size, dag SrcRHS, dag DstRHS> {
10604 def : Pat<(!cast<PatFrag>(op#"_"#size#"_monotonic") GPR64sp:$Rn, SrcRHS),
10605 (!cast<Instruction>(inst # suffix) DstRHS, GPR64sp:$Rn)>;
10606 def : Pat<(!cast<PatFrag>(op#"_"#size#"_acquire") GPR64sp:$Rn, SrcRHS),
10607 (!cast<Instruction>(inst # "A" # suffix) DstRHS, GPR64sp:$Rn)>;
10608 def : Pat<(!cast<PatFrag>(op#"_"#size#"_release") GPR64sp:$Rn, SrcRHS),
10609 (!cast<Instruction>(inst # "L" # suffix) DstRHS, GPR64sp:$Rn)>;
10610 def : Pat<(!cast<PatFrag>(op#"_"#size#"_acq_rel") GPR64sp:$Rn, SrcRHS),
10611 (!cast<Instruction>(inst # "AL" # suffix) DstRHS, GPR64sp:$Rn)>;
10612 def : Pat<(!cast<PatFrag>(op#"_"#size#"_seq_cst") GPR64sp:$Rn, SrcRHS),
10613 (!cast<Instruction>(inst # "AL" # suffix) DstRHS, GPR64sp:$Rn)>;
10616 multiclass LDOPregister_patterns_ord<string inst, string suffix, string op,
10617 string size, dag RHS> {
10618 defm : LDOPregister_patterns_ord_dag<inst, suffix, op, size, RHS, RHS>;
10621 multiclass LDOPregister_patterns_ord_mod<string inst, string suffix, string op,
10622 string size, dag LHS, dag RHS> {
10623 defm : LDOPregister_patterns_ord_dag<inst, suffix, op, size, LHS, RHS>;
10626 multiclass LDOPregister_patterns<string inst, string op> {
10627 defm : LDOPregister_patterns_ord<inst, "X", op, "64", (i64 GPR64:$Rm)>;
10628 defm : LDOPregister_patterns_ord<inst, "W", op, "32", (i32 GPR32:$Rm)>;
10629 defm : LDOPregister_patterns_ord<inst, "H", op, "16", (i32 GPR32:$Rm)>;
10630 defm : LDOPregister_patterns_ord<inst, "B", op, "8", (i32 GPR32:$Rm)>;
10633 multiclass LDOPregister_patterns_mod<string inst, string op, string mod> {
10634 defm : LDOPregister_patterns_ord_mod<inst, "X", op, "64",
10636 (i64 (!cast<Instruction>(mod#Xrr) XZR, GPR64:$Rm))>;
10637 defm : LDOPregister_patterns_ord_mod<inst, "W", op, "32",
10639 (i32 (!cast<Instruction>(mod#Wrr) WZR, GPR32:$Rm))>;
10640 defm : LDOPregister_patterns_ord_mod<inst, "H", op, "16",
10642 (i32 (!cast<Instruction>(mod#Wrr) WZR, GPR32:$Rm))>;
10643 defm : LDOPregister_patterns_ord_mod<inst, "B", op, "8",
10645 (i32 (!cast<Instruction>(mod#Wrr) WZR, GPR32:$Rm))>;
10648 let Predicates = [HasLSE] in
10649 multiclass CASregister_patterns_ord_dag<string inst, string suffix, string op,
10650 string size, dag OLD, dag NEW> {
10651 def : Pat<(!cast<PatFrag>(op#"_"#size#"_monotonic") GPR64sp:$Rn, OLD, NEW),
10652 (!cast<Instruction>(inst # suffix) OLD, NEW, GPR64sp:$Rn)>;
10653 def : Pat<(!cast<PatFrag>(op#"_"#size#"_acquire") GPR64sp:$Rn, OLD, NEW),
10654 (!cast<Instruction>(inst # "A" # suffix) OLD, NEW, GPR64sp:$Rn)>;
10655 def : Pat<(!cast<PatFrag>(op#"_"#size#"_release") GPR64sp:$Rn, OLD, NEW),
10656 (!cast<Instruction>(inst # "L" # suffix) OLD, NEW, GPR64sp:$Rn)>;
10657 def : Pat<(!cast<PatFrag>(op#"_"#size#"_acq_rel") GPR64sp:$Rn, OLD, NEW),
10658 (!cast<Instruction>(inst # "AL" # suffix) OLD, NEW, GPR64sp:$Rn)>;
10659 def : Pat<(!cast<PatFrag>(op#"_"#size#"_seq_cst") GPR64sp:$Rn, OLD, NEW),
10660 (!cast<Instruction>(inst # "AL" # suffix) OLD, NEW, GPR64sp:$Rn)>;
10663 multiclass CASregister_patterns_ord<string inst, string suffix, string op,
10664 string size, dag OLD, dag NEW> {
10665 defm : CASregister_patterns_ord_dag<inst, suffix, op, size, OLD, NEW>;
10668 multiclass CASregister_patterns<string inst, string op> {
10669 defm : CASregister_patterns_ord<inst, "X", op, "64",
10670 (i64 GPR64:$Rold), (i64 GPR64:$Rnew)>;
10671 defm : CASregister_patterns_ord<inst, "W", op, "32",
10672 (i32 GPR32:$Rold), (i32 GPR32:$Rnew)>;
10673 defm : CASregister_patterns_ord<inst, "H", op, "16",
10674 (i32 GPR32:$Rold), (i32 GPR32:$Rnew)>;
10675 defm : CASregister_patterns_ord<inst, "B", op, "8",
10676 (i32 GPR32:$Rold), (i32 GPR32:$Rnew)>;
10679 let Predicates = [HasLSE] in
10680 class BaseSTOPregister<string asm, RegisterClass OP, Register Reg,
10681 Instruction inst> :
10682 InstAlias<asm # "\t$Rs, [$Rn]", (inst Reg, OP:$Rs, GPR64sp:$Rn)>;
10684 multiclass STOPregister<string asm, string instr> {
10685 def : BaseSTOPregister<asm # "lb", GPR32, WZR,
10686 !cast<Instruction>(instr # "LB")>;
10687 def : BaseSTOPregister<asm # "lh", GPR32, WZR,
10688 !cast<Instruction>(instr # "LH")>;
10689 def : BaseSTOPregister<asm # "l", GPR32, WZR,
10690 !cast<Instruction>(instr # "LW")>;
10691 def : BaseSTOPregister<asm # "l", GPR64, XZR,
10692 !cast<Instruction>(instr # "LX")>;
10693 def : BaseSTOPregister<asm # "b", GPR32, WZR,
10694 !cast<Instruction>(instr # "B")>;
10695 def : BaseSTOPregister<asm # "h", GPR32, WZR,
10696 !cast<Instruction>(instr # "H")>;
10697 def : BaseSTOPregister<asm, GPR32, WZR,
10698 !cast<Instruction>(instr # "W")>;
10699 def : BaseSTOPregister<asm, GPR64, XZR,
10700 !cast<Instruction>(instr # "X")>;
10703 //----------------------------------------------------------------------------
10704 // Allow the size specifier tokens to be upper case, not just lower.
10705 def : TokenAlias<".4B", ".4b">; // Add dot product
10706 def : TokenAlias<".8B", ".8b">;
10707 def : TokenAlias<".4H", ".4h">;
10708 def : TokenAlias<".2S", ".2s">;
10709 def : TokenAlias<".1D", ".1d">;
10710 def : TokenAlias<".16B", ".16b">;
10711 def : TokenAlias<".8H", ".8h">;
10712 def : TokenAlias<".4S", ".4s">;
10713 def : TokenAlias<".2D", ".2d">;
10714 def : TokenAlias<".1Q", ".1q">;
10715 def : TokenAlias<".2H", ".2h">;
10716 def : TokenAlias<".B", ".b">;
10717 def : TokenAlias<".H", ".h">;
10718 def : TokenAlias<".S", ".s">;
10719 def : TokenAlias<".D", ".d">;
10720 def : TokenAlias<".Q", ".q">;