//===- AArch64InstrFormats.td - AArch64 Instruction Formats --*- tblgen -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // Describe AArch64 instructions format here // // Format specifies the encoding used by the instruction. This is part of the // ad-hoc solution used to emit machine instruction encodings by our machine // code emitter. class Format val> { bits<2> Value = val; } def PseudoFrm : Format<0>; def NormalFrm : Format<1>; // Do we need any others? // Enum describing whether an instruction is // destructive in its first source operand. class DestructiveInstTypeEnum val> { bits<4> Value = val; } def NotDestructive : DestructiveInstTypeEnum<0>; // Destructive in its first operand and can be MOVPRFX'd, but has no other // special properties. def DestructiveOther : DestructiveInstTypeEnum<1>; def DestructiveUnary : DestructiveInstTypeEnum<2>; def DestructiveBinaryImm : DestructiveInstTypeEnum<3>; def DestructiveBinaryShImmUnpred : DestructiveInstTypeEnum<4>; def DestructiveBinary : DestructiveInstTypeEnum<5>; def DestructiveBinaryComm : DestructiveInstTypeEnum<6>; def DestructiveBinaryCommWithRev : DestructiveInstTypeEnum<7>; def DestructiveTernaryCommWithRev : DestructiveInstTypeEnum<8>; def DestructiveUnaryPassthru : DestructiveInstTypeEnum<9>; class FalseLanesEnum val> { bits<2> Value = val; } def FalseLanesNone : FalseLanesEnum<0>; def FalseLanesZero : FalseLanesEnum<1>; def FalseLanesUndef : FalseLanesEnum<2>; class SMEMatrixTypeEnum val> { bits<3> Value = val; } def SMEMatrixNone : SMEMatrixTypeEnum<0>; def SMEMatrixTileB : SMEMatrixTypeEnum<1>; def SMEMatrixTileH : SMEMatrixTypeEnum<2>; def SMEMatrixTileS : SMEMatrixTypeEnum<3>; def SMEMatrixTileD : SMEMatrixTypeEnum<4>; def SMEMatrixTileQ : SMEMatrixTypeEnum<5>; def SMEMatrixArray : SMEMatrixTypeEnum<6>; // AArch64 Instruction Format class AArch64Inst : Instruction { field bits<32> Inst; // Instruction encoding. // Mask of bits that cause an encoding to be UNPREDICTABLE. // If a bit is set, then if the corresponding bit in the // target encoding differs from its value in the "Inst" field, // the instruction is UNPREDICTABLE (SoftFail in abstract parlance). field bits<32> Unpredictable = 0; // SoftFail is the generic name for this field, but we alias it so // as to make it more obvious what it means in ARM-land. field bits<32> SoftFail = Unpredictable; let Namespace = "AArch64"; Format F = f; bits<2> Form = F.Value; // Defaults bit isWhile = 0; bit isPTestLike = 0; FalseLanesEnum FalseLanes = FalseLanesNone; DestructiveInstTypeEnum DestructiveInstType = NotDestructive; SMEMatrixTypeEnum SMEMatrixType = SMEMatrixNone; ElementSizeEnum ElementSize = ElementSizeNone; let TSFlags{13-11} = SMEMatrixType.Value; let TSFlags{10} = isPTestLike; let TSFlags{9} = isWhile; let TSFlags{8-7} = FalseLanes.Value; let TSFlags{6-3} = DestructiveInstType.Value; let TSFlags{2-0} = ElementSize.Value; let Pattern = []; let Constraints = cstr; } class InstSubst : InstAlias, Requires<[UseNegativeImmediates]>; // Pseudo instructions (don't have encoding information) class Pseudo pattern, string cstr = ""> : AArch64Inst { dag OutOperandList = oops; dag InOperandList = iops; let Pattern = pattern; let isCodeGenOnly = 1; let isPseudo = 1; } // Real instructions (have encoding information) class EncodedI pattern> : AArch64Inst { let Pattern = pattern; let Size = 4; } // Normal instructions class I pattern> : EncodedI { dag OutOperandList = oops; dag InOperandList = iops; let AsmString = !strconcat(asm, operands); } class TriOpFrag : PatFrag<(ops node:$LHS, node:$MHS, node:$RHS), res>; class BinOpFrag : PatFrag<(ops node:$LHS, node:$RHS), res>; class UnOpFrag : PatFrag<(ops node:$LHS), res>; // Helper fragment for an extract of the high portion of a 128-bit vector. The // ComplexPattern match both extract_subvector and bitcast(extract_subvector(..)). def extract_high_v16i8 : ComplexPattern; def extract_high_v8i16 : ComplexPattern; def extract_high_v4i32 : ComplexPattern; def extract_high_v2i64 : ComplexPattern; def gi_extract_high_v16i8 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_extract_high_v8i16 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_extract_high_v4i32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def extract_high_v8f16 : ComplexPattern; def extract_high_v4f32 : ComplexPattern; def gi_extract_high_v8f16 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_extract_high_v4f32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def extract_high_dup_v8i16 : BinOpFrag<(extract_subvector (v8i16 (AArch64duplane16 (v8i16 node:$LHS), node:$RHS)), (i64 4))>; def extract_high_dup_v4i32 : BinOpFrag<(extract_subvector (v4i32 (AArch64duplane32 (v4i32 node:$LHS), node:$RHS)), (i64 2))>; def dup_v8i16 : PatFrags<(ops node:$LHS, node:$RHS), [(v4i16 (extract_subvector (v8i16 (AArch64duplane16 (v8i16 node:$LHS), node:$RHS)), (i64 0))), (v4i16 (AArch64duplane16 (v8i16 node:$LHS), node:$RHS))]>; def dup_v4i32 : PatFrags<(ops node:$LHS, node:$RHS), [(v2i32 (extract_subvector (v4i32 (AArch64duplane32 (v4i32 node:$LHS), node:$RHS)), (i64 0))), (v2i32 (AArch64duplane32 (v4i32 node:$LHS), node:$RHS))]>; def dup_v8f16 : PatFrags<(ops node:$LHS, node:$RHS), [(v4f16 (extract_subvector (v8f16 (AArch64duplane16 (v8f16 node:$LHS), node:$RHS)), (i64 0))), (v4f16 (AArch64duplane16 (v8f16 node:$LHS), node:$RHS))]>; def dup_v4f32 : PatFrags<(ops node:$LHS, node:$RHS), [(v2f32 (extract_subvector (v4f32 (AArch64duplane32 (v4f32 node:$LHS), node:$RHS)), (i64 0))), (v2f32 (AArch64duplane32 (v4f32 node:$LHS), node:$RHS))]>; //===----------------------------------------------------------------------===// // Asm Operand Classes. // // Shifter operand for arithmetic shifted encodings. def ShifterOperand : AsmOperandClass { let Name = "Shifter"; } // Shifter operand for mov immediate encodings. def MovImm32ShifterOperand : AsmOperandClass { let SuperClasses = [ShifterOperand]; let Name = "MovImm32Shifter"; let RenderMethod = "addShifterOperands"; let DiagnosticType = "InvalidMovImm32Shift"; } def MovImm64ShifterOperand : AsmOperandClass { let SuperClasses = [ShifterOperand]; let Name = "MovImm64Shifter"; let RenderMethod = "addShifterOperands"; let DiagnosticType = "InvalidMovImm64Shift"; } // Shifter operand for arithmetic register shifted encodings. class ArithmeticShifterOperand : AsmOperandClass { let SuperClasses = [ShifterOperand]; let Name = "ArithmeticShifter" # width; let PredicateMethod = "isArithmeticShifter<" # width # ">"; let RenderMethod = "addShifterOperands"; let DiagnosticType = "AddSubRegShift" # width; } def ArithmeticShifterOperand32 : ArithmeticShifterOperand<32>; def ArithmeticShifterOperand64 : ArithmeticShifterOperand<64>; // Shifter operand for logical register shifted encodings. class LogicalShifterOperand : AsmOperandClass { let SuperClasses = [ShifterOperand]; let Name = "LogicalShifter" # width; let PredicateMethod = "isLogicalShifter<" # width # ">"; let RenderMethod = "addShifterOperands"; let DiagnosticType = "AddSubRegShift" # width; } def LogicalShifterOperand32 : LogicalShifterOperand<32>; def LogicalShifterOperand64 : LogicalShifterOperand<64>; // Shifter operand for logical vector 128/64-bit shifted encodings. def LogicalVecShifterOperand : AsmOperandClass { let SuperClasses = [ShifterOperand]; let Name = "LogicalVecShifter"; let RenderMethod = "addShifterOperands"; } def LogicalVecHalfWordShifterOperand : AsmOperandClass { let SuperClasses = [LogicalVecShifterOperand]; let Name = "LogicalVecHalfWordShifter"; let RenderMethod = "addShifterOperands"; } // The "MSL" shifter on the vector MOVI instruction. def MoveVecShifterOperand : AsmOperandClass { let SuperClasses = [ShifterOperand]; let Name = "MoveVecShifter"; let RenderMethod = "addShifterOperands"; } // Extend operand for arithmetic encodings. def ExtendOperand : AsmOperandClass { let Name = "Extend"; let DiagnosticType = "AddSubRegExtendLarge"; } def ExtendOperand64 : AsmOperandClass { let SuperClasses = [ExtendOperand]; let Name = "Extend64"; let DiagnosticType = "AddSubRegExtendSmall"; } // 'extend' that's a lsl of a 64-bit register. def ExtendOperandLSL64 : AsmOperandClass { let SuperClasses = [ExtendOperand]; let Name = "ExtendLSL64"; let RenderMethod = "addExtend64Operands"; let DiagnosticType = "AddSubRegExtendLarge"; } // 8-bit floating-point immediate encodings. def FPImmOperand : AsmOperandClass { let Name = "FPImm"; let ParserMethod = "tryParseFPImm"; let DiagnosticType = "InvalidFPImm"; } def CondCode : AsmOperandClass { let Name = "CondCode"; let DiagnosticType = "InvalidCondCode"; } // A 32-bit register pasrsed as 64-bit def GPR32as64Operand : AsmOperandClass { let Name = "GPR32as64"; let ParserMethod = "tryParseGPROperand"; } def GPR32as64 : RegisterOperand { let ParserMatchClass = GPR32as64Operand; } // A 64-bit register pasrsed as 32-bit def GPR64as32Operand : AsmOperandClass { let Name = "GPR64as32"; let ParserMethod = "tryParseGPROperand"; } def GPR64as32 : RegisterOperand { let ParserMatchClass = GPR64as32Operand; } // 8-bit immediate for AdvSIMD where 64-bit values of the form: // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh // are encoded as the eight bit value 'abcdefgh'. def SIMDImmType10Operand : AsmOperandClass { let Name = "SIMDImmType10"; } class UImmScaledMemoryIndexed : AsmOperandClass { let Name = "UImm" # Width # "s" # Scale; let DiagnosticType = "InvalidMemoryIndexed" # Scale # "UImm" # Width; let RenderMethod = "addImmScaledOperands<" # Scale # ">"; let PredicateMethod = "isUImmScaled<" # Width # ", " # Scale # ">"; } class SImmScaledMemoryIndexed : AsmOperandClass { let Name = "SImm" # Width # "s" # Scale; let DiagnosticType = "InvalidMemoryIndexed" # Scale # "SImm" # Width; let RenderMethod = "addImmScaledOperands<" # Scale # ">"; let PredicateMethod = "isSImmScaled<" # Width # ", " # Scale # ">"; } //===----------------------------------------------------------------------===// // Operand Definitions. // // ADR[P] instruction labels. def AdrpOperand : AsmOperandClass { let Name = "AdrpLabel"; let ParserMethod = "tryParseAdrpLabel"; let DiagnosticType = "InvalidLabel"; } def adrplabel : Operand { let EncoderMethod = "getAdrLabelOpValue"; let PrintMethod = "printAdrAdrpLabel"; let ParserMatchClass = AdrpOperand; let OperandType = "OPERAND_PCREL"; } def AdrOperand : AsmOperandClass { let Name = "AdrLabel"; let ParserMethod = "tryParseAdrLabel"; let DiagnosticType = "InvalidLabel"; } def adrlabel : Operand { let EncoderMethod = "getAdrLabelOpValue"; let PrintMethod = "printAdrAdrpLabel"; let ParserMatchClass = AdrOperand; let OperandType = "OPERAND_PCREL"; } class SImmOperand : AsmOperandClass { let Name = "SImm" # width; let DiagnosticType = "InvalidMemoryIndexedSImm" # width; let RenderMethod = "addImmOperands"; let PredicateMethod = "isSImm<" # width # ">"; } class AsmImmRange : AsmOperandClass { let Name = "Imm" # Low # "_" # High; let DiagnosticType = "InvalidImm" # Low # "_" # High; let RenderMethod = "addImmOperands"; let PredicateMethod = "isImmInRange<" # Low # "," # High # ">"; } // Authenticated loads for v8.3 can have scaled 10-bit immediate offsets. def SImm10s8Operand : SImmScaledMemoryIndexed<10, 8>; def simm10Scaled : Operand { let ParserMatchClass = SImm10s8Operand; let DecoderMethod = "DecodeSImm<10>"; let PrintMethod = "printImmScale<8>"; } def simm9s16 : Operand { let ParserMatchClass = SImmScaledMemoryIndexed<9, 16>; let DecoderMethod = "DecodeSImm<9>"; let PrintMethod = "printImmScale<16>"; } // uimm6 predicate - True if the immediate is in the range [0, 63]. def UImm6Operand : AsmOperandClass { let Name = "UImm6"; let DiagnosticType = "InvalidImm0_63"; } def uimm6 : Operand, ImmLeaf= 0 && Imm < 64; }]> { let ParserMatchClass = UImm6Operand; } def uimm16 : Operand, ImmLeaf= 0 && Imm < 65536;}]>{ let ParserMatchClass = AsmImmRange<0, 65535>; } def SImm9Operand : SImmOperand<9>; def simm9 : Operand, ImmLeaf= -256 && Imm < 256; }]> { let ParserMatchClass = SImm9Operand; let DecoderMethod = "DecodeSImm<9>"; } // imm0_255 predicate - True if the immediate is in the range [0,255]. def Imm0_255Operand : AsmImmRange<0,255>; def uimm8_32b : Operand, ImmLeaf= 0 && Imm < 256; }]> { let ParserMatchClass = Imm0_255Operand; } def uimm8_64b : Operand, ImmLeaf= 0 && Imm < 256; }]> { let ParserMatchClass = Imm0_255Operand; } def SImm8Operand : SImmOperand<8>; def simm8_32b : Operand, ImmLeaf= -128 && Imm < 128; }]> { let ParserMatchClass = SImm8Operand; let DecoderMethod = "DecodeSImm<8>"; } def simm8_64b : Operand, ImmLeaf= -128 && Imm < 128; }]> { let ParserMatchClass = SImm8Operand; let DecoderMethod = "DecodeSImm<8>"; } def SImm6Operand : SImmOperand<6>; def simm6_32b : Operand, ImmLeaf= -32 && Imm < 32; }]> { let ParserMatchClass = SImm6Operand; let DecoderMethod = "DecodeSImm<6>"; } def SImm5Operand : SImmOperand<5>; def simm5_64b : Operand, ImmLeaf= -16 && Imm < 16; }]> { let ParserMatchClass = SImm5Operand; let DecoderMethod = "DecodeSImm<5>"; } def simm5_32b : Operand, ImmLeaf= -16 && Imm < 16; }]> { let ParserMatchClass = SImm5Operand; let DecoderMethod = "DecodeSImm<5>"; } def simm5_8b : Operand, ImmLeaf= -16 && (int8_t)Imm < 16; }]> { let ParserMatchClass = SImm5Operand; let DecoderMethod = "DecodeSImm<5>"; let PrintMethod = "printSImm<8>"; } def simm5_16b : Operand, ImmLeaf= -16 && (int16_t)Imm < 16; }]> { let ParserMatchClass = SImm5Operand; let DecoderMethod = "DecodeSImm<5>"; let PrintMethod = "printSImm<16>"; } // simm7sN predicate - True if the immediate is a multiple of N in the range // [-64 * N, 63 * N]. def SImm7s4Operand : SImmScaledMemoryIndexed<7, 4>; def SImm7s8Operand : SImmScaledMemoryIndexed<7, 8>; def SImm7s16Operand : SImmScaledMemoryIndexed<7, 16>; def simm7s4 : Operand { let ParserMatchClass = SImm7s4Operand; let PrintMethod = "printImmScale<4>"; } def simm7s8 : Operand { let ParserMatchClass = SImm7s8Operand; let PrintMethod = "printImmScale<8>"; } def simm7s16 : Operand { let ParserMatchClass = SImm7s16Operand; let PrintMethod = "printImmScale<16>"; } def am_sve_fi : ComplexPattern; def am_indexed7s8 : ComplexPattern; def am_indexed7s16 : ComplexPattern; def am_indexed7s32 : ComplexPattern; def am_indexed7s64 : ComplexPattern; def am_indexed7s128 : ComplexPattern; def am_indexedu6s128 : ComplexPattern; def am_indexeds9s128 : ComplexPattern; def UImmS1XForm : SDNodeXFormgetTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i64); }]>; def UImmS2XForm : SDNodeXFormgetTargetConstant(N->getZExtValue() / 2, SDLoc(N), MVT::i64); }]>; def UImmS4XForm : SDNodeXFormgetTargetConstant(N->getZExtValue() / 4, SDLoc(N), MVT::i64); }]>; def UImmS8XForm : SDNodeXFormgetTargetConstant(N->getZExtValue() / 8, SDLoc(N), MVT::i64); }]>; // uimm5sN predicate - True if the immediate is a multiple of N in the range // [0 * N, 32 * N]. def UImm5s2Operand : UImmScaledMemoryIndexed<5, 2>; def UImm5s4Operand : UImmScaledMemoryIndexed<5, 4>; def UImm5s8Operand : UImmScaledMemoryIndexed<5, 8>; def uimm5s2 : Operand, ImmLeaf= 0 && Imm < (32*2) && ((Imm % 2) == 0); }], UImmS2XForm> { let ParserMatchClass = UImm5s2Operand; let PrintMethod = "printImmScale<2>"; } def uimm5s4 : Operand, ImmLeaf= 0 && Imm < (32*4) && ((Imm % 4) == 0); }], UImmS4XForm> { let ParserMatchClass = UImm5s4Operand; let PrintMethod = "printImmScale<4>"; } def uimm5s8 : Operand, ImmLeaf= 0 && Imm < (32*8) && ((Imm % 8) == 0); }], UImmS8XForm> { let ParserMatchClass = UImm5s8Operand; let PrintMethod = "printImmScale<8>"; } // tuimm5sN predicate - similiar to uimm5sN, but use TImmLeaf (TargetConstant) // instead of ImmLeaf (Constant) def tuimm5s2 : Operand, TImmLeaf= 0 && Imm < (32*2) && ((Imm % 2) == 0); }], UImmS2XForm> { let ParserMatchClass = UImm5s2Operand; let PrintMethod = "printImmScale<2>"; } def tuimm5s4 : Operand, TImmLeaf= 0 && Imm < (32*4) && ((Imm % 4) == 0); }], UImmS4XForm> { let ParserMatchClass = UImm5s4Operand; let PrintMethod = "printImmScale<4>"; } def tuimm5s8 : Operand, TImmLeaf= 0 && Imm < (32*8) && ((Imm % 8) == 0); }], UImmS8XForm> { let ParserMatchClass = UImm5s8Operand; let PrintMethod = "printImmScale<8>"; } // uimm6sN predicate - True if the immediate is a multiple of N in the range // [0 * N, 64 * N]. def UImm6s1Operand : UImmScaledMemoryIndexed<6, 1>; def UImm6s2Operand : UImmScaledMemoryIndexed<6, 2>; def UImm6s4Operand : UImmScaledMemoryIndexed<6, 4>; def UImm6s8Operand : UImmScaledMemoryIndexed<6, 8>; def UImm6s16Operand : UImmScaledMemoryIndexed<6, 16>; def uimm6s1 : Operand, ImmLeaf= 0 && Imm < 64; }]> { let ParserMatchClass = UImm6s1Operand; } def uimm6s2 : Operand, ImmLeaf= 0 && Imm < (64*2) && ((Imm % 2) == 0); }]> { let PrintMethod = "printImmScale<2>"; let ParserMatchClass = UImm6s2Operand; } def uimm6s4 : Operand, ImmLeaf= 0 && Imm < (64*4) && ((Imm % 4) == 0); }]> { let PrintMethod = "printImmScale<4>"; let ParserMatchClass = UImm6s4Operand; } def uimm6s8 : Operand, ImmLeaf= 0 && Imm < (64*8) && ((Imm % 8) == 0); }]> { let PrintMethod = "printImmScale<8>"; let ParserMatchClass = UImm6s8Operand; } def uimm6s16 : Operand, ImmLeaf= 0 && Imm < (64*16) && ((Imm % 16) == 0); }]> { let PrintMethod = "printImmScale<16>"; let ParserMatchClass = UImm6s16Operand; } def SImmS2XForm : SDNodeXFormgetTargetConstant(N->getSExtValue() / 2, SDLoc(N), MVT::i64); }]>; def SImmS3XForm : SDNodeXFormgetTargetConstant(N->getSExtValue() / 3, SDLoc(N), MVT::i64); }]>; def SImmS4XForm : SDNodeXFormgetTargetConstant(N->getSExtValue() / 4, SDLoc(N), MVT::i64); }]>; def SImmS16XForm : SDNodeXFormgetTargetConstant(N->getSExtValue() / 16, SDLoc(N), MVT::i64); }]>; def SImmS32XForm : SDNodeXFormgetTargetConstant(N->getSExtValue() / 32, SDLoc(N), MVT::i64); }]>; // simm6sN predicate - True if the immediate is a multiple of N in the range // [-32 * N, 31 * N]. def SImm6s1Operand : SImmScaledMemoryIndexed<6, 1>; def simm6s1 : Operand, ImmLeaf= -32 && Imm < 32; }]> { let ParserMatchClass = SImm6s1Operand; let DecoderMethod = "DecodeSImm<6>"; } // simm4sN predicate - True if the immediate is a multiple of N in the range // [ -8* N, 7 * N]. def SImm4s1Operand : SImmScaledMemoryIndexed<4, 1>; def SImm4s2Operand : SImmScaledMemoryIndexed<4, 2>; def SImm4s3Operand : SImmScaledMemoryIndexed<4, 3>; def SImm4s4Operand : SImmScaledMemoryIndexed<4, 4>; def SImm4s16Operand : SImmScaledMemoryIndexed<4, 16>; def SImm4s32Operand : SImmScaledMemoryIndexed<4, 32>; def simm4s1 : Operand, ImmLeaf=-8 && Imm <= 7; }]> { let ParserMatchClass = SImm4s1Operand; let DecoderMethod = "DecodeSImm<4>"; } def simm4s2 : Operand, ImmLeaf=-16 && Imm <= 14 && (Imm % 2) == 0x0; }], SImmS2XForm> { let PrintMethod = "printImmScale<2>"; let ParserMatchClass = SImm4s2Operand; let DecoderMethod = "DecodeSImm<4>"; } def simm4s3 : Operand, ImmLeaf=-24 && Imm <= 21 && (Imm % 3) == 0x0; }], SImmS3XForm> { let PrintMethod = "printImmScale<3>"; let ParserMatchClass = SImm4s3Operand; let DecoderMethod = "DecodeSImm<4>"; } def simm4s4 : Operand, ImmLeaf=-32 && Imm <= 28 && (Imm % 4) == 0x0; }], SImmS4XForm> { let PrintMethod = "printImmScale<4>"; let ParserMatchClass = SImm4s4Operand; let DecoderMethod = "DecodeSImm<4>"; } def simm4s16 : Operand, ImmLeaf=-128 && Imm <= 112 && (Imm % 16) == 0x0; }], SImmS16XForm> { let PrintMethod = "printImmScale<16>"; let ParserMatchClass = SImm4s16Operand; let DecoderMethod = "DecodeSImm<4>"; } def simm4s32 : Operand, ImmLeaf=-256 && Imm <= 224 && (Imm % 32) == 0x0; }], SImmS32XForm> { let PrintMethod = "printImmScale<32>"; let ParserMatchClass = SImm4s32Operand; let DecoderMethod = "DecodeSImm<4>"; } def Imm1_8Operand : AsmImmRange<1, 8>; def Imm1_16Operand : AsmImmRange<1, 16>; def Imm1_32Operand : AsmImmRange<1, 32>; def Imm1_64Operand : AsmImmRange<1, 64>; class BranchTarget : AsmOperandClass { let Name = "BranchTarget" # N; let DiagnosticType = "InvalidLabel"; let PredicateMethod = "isBranchTarget<" # N # ">"; } class PCRelLabel : BranchTarget { let Name = "PCRelLabel" # N; } def BranchTarget14Operand : BranchTarget<14>; def BranchTarget26Operand : BranchTarget<26>; def PCRelLabel19Operand : PCRelLabel<19>; def MovWSymbolG3AsmOperand : AsmOperandClass { let Name = "MovWSymbolG3"; let RenderMethod = "addImmOperands"; } def movw_symbol_g3 : Operand { let ParserMatchClass = MovWSymbolG3AsmOperand; } def MovWSymbolG2AsmOperand : AsmOperandClass { let Name = "MovWSymbolG2"; let RenderMethod = "addImmOperands"; } def movw_symbol_g2 : Operand { let ParserMatchClass = MovWSymbolG2AsmOperand; } def MovWSymbolG1AsmOperand : AsmOperandClass { let Name = "MovWSymbolG1"; let RenderMethod = "addImmOperands"; } def movw_symbol_g1 : Operand { let ParserMatchClass = MovWSymbolG1AsmOperand; } def MovWSymbolG0AsmOperand : AsmOperandClass { let Name = "MovWSymbolG0"; let RenderMethod = "addImmOperands"; } def movw_symbol_g0 : Operand { let ParserMatchClass = MovWSymbolG0AsmOperand; } class fixedpoint_i32 : Operand, ComplexPattern", [fpimm, ld]> { let EncoderMethod = "getFixedPointScaleOpValue"; let DecoderMethod = "DecodeFixedPointScaleImm32"; let ParserMatchClass = Imm1_32Operand; } class fixedpoint_i64 : Operand, ComplexPattern", [fpimm, ld]> { let EncoderMethod = "getFixedPointScaleOpValue"; let DecoderMethod = "DecodeFixedPointScaleImm64"; let ParserMatchClass = Imm1_64Operand; } def fixedpoint_f16_i32 : fixedpoint_i32; def fixedpoint_f32_i32 : fixedpoint_i32; def fixedpoint_f64_i32 : fixedpoint_i32; def fixedpoint_f16_i64 : fixedpoint_i64; def fixedpoint_f32_i64 : fixedpoint_i64; def fixedpoint_f64_i64 : fixedpoint_i64; class fixedpoint_recip_i32 : Operand, ComplexPattern", [fpimm, ld]> { let EncoderMethod = "getFixedPointScaleOpValue"; let DecoderMethod = "DecodeFixedPointScaleImm32"; } class fixedpoint_recip_i64 : Operand, ComplexPattern", [fpimm, ld]> { let EncoderMethod = "getFixedPointScaleOpValue"; let DecoderMethod = "DecodeFixedPointScaleImm64"; } def fixedpoint_recip_f16_i32 : fixedpoint_recip_i32; def fixedpoint_recip_f32_i32 : fixedpoint_recip_i32; def fixedpoint_recip_f64_i32 : fixedpoint_recip_i32; def fixedpoint_recip_f16_i64 : fixedpoint_recip_i64; def fixedpoint_recip_f32_i64 : fixedpoint_recip_i64; def fixedpoint_recip_f64_i64 : fixedpoint_recip_i64; def vecshiftR8 : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 9); }]> { let EncoderMethod = "getVecShiftR8OpValue"; let DecoderMethod = "DecodeVecShiftR8Imm"; let ParserMatchClass = Imm1_8Operand; } def vecshiftR16 : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 17); }]> { let EncoderMethod = "getVecShiftR16OpValue"; let DecoderMethod = "DecodeVecShiftR16Imm"; let ParserMatchClass = Imm1_16Operand; } def vecshiftR16Narrow : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 9); }]> { let EncoderMethod = "getVecShiftR16OpValue"; let DecoderMethod = "DecodeVecShiftR16ImmNarrow"; let ParserMatchClass = Imm1_8Operand; } def vecshiftR32 : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 33); }]> { let EncoderMethod = "getVecShiftR32OpValue"; let DecoderMethod = "DecodeVecShiftR32Imm"; let ParserMatchClass = Imm1_32Operand; } def vecshiftR32Narrow : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 17); }]> { let EncoderMethod = "getVecShiftR32OpValue"; let DecoderMethod = "DecodeVecShiftR32ImmNarrow"; let ParserMatchClass = Imm1_16Operand; } def vecshiftR64 : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 65); }]> { let EncoderMethod = "getVecShiftR64OpValue"; let DecoderMethod = "DecodeVecShiftR64Imm"; let ParserMatchClass = Imm1_64Operand; } def vecshiftR64Narrow : Operand, ImmLeaf 0) && (((uint32_t)Imm) < 33); }]> { let EncoderMethod = "getVecShiftR64OpValue"; let DecoderMethod = "DecodeVecShiftR64ImmNarrow"; let ParserMatchClass = Imm1_32Operand; } // Same as vecshiftR#N, but use TargetConstant (TimmLeaf) instead of Constant // (ImmLeaf) def tvecshiftR8 : Operand, TImmLeaf 0) && (((uint32_t)Imm) < 9); }]> { let EncoderMethod = "getVecShiftR8OpValue"; let DecoderMethod = "DecodeVecShiftR8Imm"; let ParserMatchClass = Imm1_8Operand; } def tvecshiftR16 : Operand, TImmLeaf 0) && (((uint32_t)Imm) < 17); }]> { let EncoderMethod = "getVecShiftR16OpValue"; let DecoderMethod = "DecodeVecShiftR16Imm"; let ParserMatchClass = Imm1_16Operand; } def tvecshiftR32 : Operand, TImmLeaf 0) && (((uint32_t)Imm) < 33); }]> { let EncoderMethod = "getVecShiftR32OpValue"; let DecoderMethod = "DecodeVecShiftR32Imm"; let ParserMatchClass = Imm1_32Operand; } def tvecshiftR64 : Operand, TImmLeaf 0) && (((uint32_t)Imm) < 65); }]> { let EncoderMethod = "getVecShiftR64OpValue"; let DecoderMethod = "DecodeVecShiftR64Imm"; let ParserMatchClass = Imm1_64Operand; } def Imm0_0Operand : AsmImmRange<0, 0>; def Imm0_1Operand : AsmImmRange<0, 1>; def Imm1_1Operand : AsmImmRange<1, 1>; def Imm0_3Operand : AsmImmRange<0, 3>; def Imm1_3Operand : AsmImmRange<1, 3>; def Imm0_7Operand : AsmImmRange<0, 7>; def Imm1_7Operand : AsmImmRange<1, 7>; def Imm0_15Operand : AsmImmRange<0, 15>; def Imm0_31Operand : AsmImmRange<0, 31>; def Imm0_63Operand : AsmImmRange<0, 63>; def vecshiftL8 : Operand, ImmLeaf { let EncoderMethod = "getVecShiftL8OpValue"; let DecoderMethod = "DecodeVecShiftL8Imm"; let ParserMatchClass = Imm0_7Operand; } def vecshiftL16 : Operand, ImmLeaf { let EncoderMethod = "getVecShiftL16OpValue"; let DecoderMethod = "DecodeVecShiftL16Imm"; let ParserMatchClass = Imm0_15Operand; } def vecshiftL32 : Operand, ImmLeaf { let EncoderMethod = "getVecShiftL32OpValue"; let DecoderMethod = "DecodeVecShiftL32Imm"; let ParserMatchClass = Imm0_31Operand; } def vecshiftL64 : Operand, ImmLeaf { let EncoderMethod = "getVecShiftL64OpValue"; let DecoderMethod = "DecodeVecShiftL64Imm"; let ParserMatchClass = Imm0_63Operand; } // Same as vecshiftL#N, but use TargetConstant (TimmLeaf) instead of Constant // (ImmLeaf) def tvecshiftL8 : Operand, TImmLeaf { let EncoderMethod = "getVecShiftL8OpValue"; let DecoderMethod = "DecodeVecShiftL8Imm"; let ParserMatchClass = Imm0_7Operand; } def tvecshiftL16 : Operand, TImmLeaf { let EncoderMethod = "getVecShiftL16OpValue"; let DecoderMethod = "DecodeVecShiftL16Imm"; let ParserMatchClass = Imm0_15Operand; } def tvecshiftL32 : Operand, TImmLeaf { let EncoderMethod = "getVecShiftL32OpValue"; let DecoderMethod = "DecodeVecShiftL32Imm"; let ParserMatchClass = Imm0_31Operand; } def tvecshiftL64 : Operand, TImmLeaf { let EncoderMethod = "getVecShiftL64OpValue"; let DecoderMethod = "DecodeVecShiftL64Imm"; let ParserMatchClass = Imm0_63Operand; } // Crazy immediate formats used by 32-bit and 64-bit logical immediate // instructions for splatting repeating bit patterns across the immediate. def logical_imm32_XFORM : SDNodeXFormgetZExtValue(), 32); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>; def logical_imm64_XFORM : SDNodeXFormgetZExtValue(), 64); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>; def gi_logical_imm32_XFORM : GICustomOperandRenderer<"renderLogicalImm32">, GISDNodeXFormEquiv; def gi_logical_imm64_XFORM : GICustomOperandRenderer<"renderLogicalImm64">, GISDNodeXFormEquiv; let DiagnosticType = "LogicalSecondSource" in { def LogicalImm32Operand : AsmOperandClass { let Name = "LogicalImm32"; let PredicateMethod = "isLogicalImm"; let RenderMethod = "addLogicalImmOperands"; } def LogicalImm64Operand : AsmOperandClass { let Name = "LogicalImm64"; let PredicateMethod = "isLogicalImm"; let RenderMethod = "addLogicalImmOperands"; } def LogicalImm32NotOperand : AsmOperandClass { let Name = "LogicalImm32Not"; let PredicateMethod = "isLogicalImm"; let RenderMethod = "addLogicalImmNotOperands"; } def LogicalImm64NotOperand : AsmOperandClass { let Name = "LogicalImm64Not"; let PredicateMethod = "isLogicalImm"; let RenderMethod = "addLogicalImmNotOperands"; } } def Imm0_127Operand : AsmImmRange<0, 127>; let OperandType = "OPERAND_IMMEDIATE" in { def logical_imm32 : Operand, IntImmLeaf { let PrintMethod = "printLogicalImm"; let ParserMatchClass = LogicalImm32Operand; } def logical_imm64 : Operand, IntImmLeaf { let PrintMethod = "printLogicalImm"; let ParserMatchClass = LogicalImm64Operand; } def logical_imm32_not : Operand { let ParserMatchClass = LogicalImm32NotOperand; } def logical_imm64_not : Operand { let ParserMatchClass = LogicalImm64NotOperand; } // immXX_0_65535 predicates - True if the immediate is in the range [0,65535]. let ParserMatchClass = AsmImmRange<0, 65535>, PrintMethod = "printImmHex" in { def timm32_0_65535 : Operand, TImmLeaf; def timm64_0_65535 : Operand, TImmLeaf; def imm64_0_65535 : Operand, ImmLeaf; } // ParserMatchClass def imm0_255 : Operand, ImmLeaf { let ParserMatchClass = Imm0_255Operand; let PrintMethod = "printImm"; } // imm0_127 predicate - True if the immediate is in the range [0,127] def imm0_127 : Operand, ImmLeaf { let ParserMatchClass = Imm0_127Operand; let PrintMethod = "printImm"; } def imm0_127_64b : Operand, ImmLeaf { let ParserMatchClass = Imm0_127Operand; let PrintMethod = "printImm"; } // NOTE: These imm0_N operands have to be of type i64 because i64 is the size // for all shift-amounts. // imm0_63 predicate - True if the immediate is in the range [0,63] def imm0_63 : Operand, ImmLeaf { let ParserMatchClass = Imm0_63Operand; } def timm0_63 : Operand, TImmLeaf { let ParserMatchClass = Imm0_63Operand; } // imm0_31 predicate - True if the immediate is in the range [0,31] def imm0_31 : Operand, ImmLeaf { let ParserMatchClass = Imm0_31Operand; } // timm0_31 predicate - same ass imm0_31, but use TargetConstant (TimmLeaf) // instead of Constant (ImmLeaf) def timm0_31 : Operand, TImmLeaf { let ParserMatchClass = Imm0_31Operand; } // True if the 32-bit immediate is in the range [0,31] def imm32_0_31 : Operand, ImmLeaf { let ParserMatchClass = Imm0_31Operand; } // imm0_1 predicate - True if the immediate is in the range [0,1] def imm0_1 : Operand, ImmLeaf { let ParserMatchClass = Imm0_1Operand; } // timm0_1 - as above, but use TargetConstant (TImmLeaf) def timm0_1 : Operand, TImmLeaf { let ParserMatchClass = Imm0_1Operand; } // timm32_0_0 predicate - True if the 32-bit immediate is in the range [0,0] def timm32_0_0 : Operand, TImmLeaf { let ParserMatchClass = Imm0_0Operand; } // timm32_0_1 predicate - True if the 32-bit immediate is in the range [0,1] def timm32_0_1 : Operand, TImmLeaf { let ParserMatchClass = Imm0_1Operand; } // timm32_1_1 - True if the 32-bit immediate is in the range [1,1] def timm32_1_1 : Operand, TImmLeaf { let ParserMatchClass = Imm1_1Operand; } // timm32_1_3 predicate - True if the 32-bit immediate is in the range [1,3] def timm32_1_3 : Operand, TImmLeaf 0 && ((uint32_t)Imm) < 4; }]> { let ParserMatchClass = Imm1_3Operand; } // imm0_15 predicate - True if the immediate is in the range [0,15] def imm0_15 : Operand, ImmLeaf { let ParserMatchClass = Imm0_15Operand; } // imm0_7 predicate - True if the immediate is in the range [0,7] def imm0_7 : Operand, ImmLeaf { let ParserMatchClass = Imm0_7Operand; } // imm0_3 predicate - True if the immediate is in the range [0,3] def imm0_3 : Operand, ImmLeaf { let ParserMatchClass = Imm0_3Operand; } // timm32_0_3 predicate - True if the 32-bit immediate is in the range [0,3] def timm32_0_3 : Operand, TImmLeaf { let ParserMatchClass = Imm0_3Operand; } // timm32_0_7 predicate - True if the 32-bit immediate is in the range [0,7] def timm32_0_7 : Operand, TImmLeaf { let ParserMatchClass = Imm0_7Operand; } // timm32_1_7 predicate - True if the 32-bit immediate is in the range [1,7] def timm32_1_7 : Operand, TImmLeaf 0 && ((uint32_t)Imm) < 8; }]> { let ParserMatchClass = Imm1_7Operand; } // imm32_0_15 predicate - True if the 32-bit immediate is in the range [0,15] def imm32_0_15 : Operand, ImmLeaf { let ParserMatchClass = Imm0_15Operand; } // timm32_0_15 predicate - True if the 32-bit immediate is in the range [0,15] def timm32_0_15 : Operand, TImmLeaf { let ParserMatchClass = Imm0_15Operand; } // timm32_0_31 predicate - True if the 32-bit immediate is in the range [0,31] def timm32_0_31 : Operand, TImmLeaf { let ParserMatchClass = Imm0_31Operand; } // timm32_0_255 predicate - True if the 32-bit immediate is in the range [0,255] def timm32_0_255 : Operand, TImmLeaf { let ParserMatchClass = Imm0_255Operand; } } // let OperandType = "OPERAND_IMMEDIATE" // An arithmetic shifter operand: // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr // {5-0} - imm6 class arith_shift : Operand { let PrintMethod = "printShifter"; let ParserMatchClass = !cast( "ArithmeticShifterOperand" # width); } def arith_shift32 : arith_shift; def arith_shift64 : arith_shift; class arith_shifted_reg : Operand, ComplexPattern { let PrintMethod = "printShiftedRegister"; let MIOperandInfo = (ops regclass, !cast("arith_shift" # width)); } def arith_shifted_reg32 : arith_shifted_reg; def arith_shifted_reg64 : arith_shifted_reg; def gi_arith_shifted_reg32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_arith_shifted_reg64 : GIComplexOperandMatcher, GIComplexPatternEquiv; // An arithmetic shifter operand: // {7-6} - shift type: 00 = lsl, 01 = lsr, 10 = asr, 11 = ror // {5-0} - imm6 class logical_shift : Operand { let PrintMethod = "printShifter"; let ParserMatchClass = !cast( "LogicalShifterOperand" # width); } def logical_shift32 : logical_shift<32>; def logical_shift64 : logical_shift<64>; class logical_shifted_reg : Operand, ComplexPattern { let PrintMethod = "printShiftedRegister"; let MIOperandInfo = (ops regclass, shiftop); } def logical_shifted_reg32 : logical_shifted_reg; def logical_shifted_reg64 : logical_shifted_reg; def gi_logical_shifted_reg32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_logical_shifted_reg64 : GIComplexOperandMatcher, GIComplexPatternEquiv; // A logical vector shifter operand: // {7-6} - shift type: 00 = lsl // {5-0} - imm6: #0, #8, #16, or #24 def logical_vec_shift : Operand { let PrintMethod = "printShifter"; let EncoderMethod = "getVecShifterOpValue"; let ParserMatchClass = LogicalVecShifterOperand; } // A logical vector half-word shifter operand: // {7-6} - shift type: 00 = lsl // {5-0} - imm6: #0 or #8 def logical_vec_hw_shift : Operand { let PrintMethod = "printShifter"; let EncoderMethod = "getVecShifterOpValue"; let ParserMatchClass = LogicalVecHalfWordShifterOperand; } // A vector move shifter operand: // {0} - imm1: #8 or #16 def move_vec_shift : Operand { let PrintMethod = "printShifter"; let EncoderMethod = "getMoveVecShifterOpValue"; let ParserMatchClass = MoveVecShifterOperand; } let DiagnosticType = "AddSubSecondSource" in { def AddSubImmOperand : AsmOperandClass { let Name = "AddSubImm"; let ParserMethod = "tryParseImmWithOptionalShift"; let RenderMethod = "addImmWithOptionalShiftOperands<12>"; } def AddSubImmNegOperand : AsmOperandClass { let Name = "AddSubImmNeg"; let ParserMethod = "tryParseImmWithOptionalShift"; let RenderMethod = "addImmNegWithOptionalShiftOperands<12>"; } } // An ADD/SUB immediate shifter operand: // second operand: // {7-6} - shift type: 00 = lsl // {5-0} - imm6: #0 or #12 class addsub_shifted_imm : Operand, ComplexPattern { let PrintMethod = "printAddSubImm"; let EncoderMethod = "getAddSubImmOpValue"; let ParserMatchClass = AddSubImmOperand; let MIOperandInfo = (ops i32imm, i32imm); } class addsub_shifted_imm_neg : Operand { let EncoderMethod = "getAddSubImmOpValue"; let ParserMatchClass = AddSubImmNegOperand; let MIOperandInfo = (ops i32imm, i32imm); } def addsub_shifted_imm32 : addsub_shifted_imm; def addsub_shifted_imm64 : addsub_shifted_imm; def addsub_shifted_imm32_neg : addsub_shifted_imm_neg; def addsub_shifted_imm64_neg : addsub_shifted_imm_neg; def gi_addsub_shifted_imm32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_addsub_shifted_imm64 : GIComplexOperandMatcher, GIComplexPatternEquiv; class neg_addsub_shifted_imm : Operand, ComplexPattern { let PrintMethod = "printAddSubImm"; let EncoderMethod = "getAddSubImmOpValue"; let ParserMatchClass = AddSubImmOperand; let MIOperandInfo = (ops i32imm, i32imm); } def neg_addsub_shifted_imm32 : neg_addsub_shifted_imm; def neg_addsub_shifted_imm64 : neg_addsub_shifted_imm; def gi_neg_addsub_shifted_imm32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_neg_addsub_shifted_imm64 : GIComplexOperandMatcher, GIComplexPatternEquiv; // An extend operand: // {5-3} - extend type // {2-0} - imm3 def arith_extend : Operand { let PrintMethod = "printArithExtend"; let ParserMatchClass = ExtendOperand; } def arith_extend64 : Operand { let PrintMethod = "printArithExtend"; let ParserMatchClass = ExtendOperand64; } // 'extend' that's a lsl of a 64-bit register. def arith_extendlsl64 : Operand { let PrintMethod = "printArithExtend"; let ParserMatchClass = ExtendOperandLSL64; } class arith_extended_reg32 : Operand, ComplexPattern { let PrintMethod = "printExtendedRegister"; let MIOperandInfo = (ops GPR32, arith_extend); } class arith_extended_reg32to64 : Operand, ComplexPattern { let PrintMethod = "printExtendedRegister"; let MIOperandInfo = (ops GPR32, arith_extend64); } def arith_extended_reg32_i32 : arith_extended_reg32; def gi_arith_extended_reg32_i32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def arith_extended_reg32_i64 : arith_extended_reg32; def gi_arith_extended_reg32_i64 : GIComplexOperandMatcher, GIComplexPatternEquiv; def arith_extended_reg32to64_i64 : arith_extended_reg32to64; def gi_arith_extended_reg32to64_i64 : GIComplexOperandMatcher, GIComplexPatternEquiv; def arith_uxtx : ComplexPattern; // Floating-point immediate. def fpimm16XForm : SDNodeXFormgetValueAPF(); uint32_t enc = AArch64_AM::getFP16Imm(InVal); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>; def fpimm32XForm : SDNodeXFormgetValueAPF(); uint32_t enc = AArch64_AM::getFP32Imm(InVal); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>; def fpimm32SIMDModImmType4XForm : SDNodeXFormgetValueAPF() .bitcastToAPInt() .getZExtValue()); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>; def fpimm64XForm : SDNodeXFormgetValueAPF(); uint32_t enc = AArch64_AM::getFP64Imm(InVal); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>; def fpimm16 : Operand, FPImmLeaf { let ParserMatchClass = FPImmOperand; let PrintMethod = "printFPImmOperand"; } def fpimmbf16 : Operand, FPImmLeaf; def fpimm32 : Operand, FPImmLeaf { let ParserMatchClass = FPImmOperand; let PrintMethod = "printFPImmOperand"; } def fpimm32SIMDModImmType4 : FPImmLeaf { } def fpimm64 : Operand, FPImmLeaf { let ParserMatchClass = FPImmOperand; let PrintMethod = "printFPImmOperand"; } def fpimm8 : Operand { let ParserMatchClass = FPImmOperand; let PrintMethod = "printFPImmOperand"; } def fpimm0 : FPImmLeaf; def fpimm_minus0 : FPImmLeaf; def fpimm_half : FPImmLeaf; def fpimm_one : FPImmLeaf; def fpimm_two : FPImmLeaf; def gi_fpimm16 : GICustomOperandRenderer<"renderFPImm16">, GISDNodeXFormEquiv; def gi_fpimm32 : GICustomOperandRenderer<"renderFPImm32">, GISDNodeXFormEquiv; def gi_fpimm64 : GICustomOperandRenderer<"renderFPImm64">, GISDNodeXFormEquiv; def gi_fpimm32SIMDModImmType4 : GICustomOperandRenderer<"renderFPImm32SIMDModImmType4">, GISDNodeXFormEquiv; // Vector lane operands class AsmVectorIndex : AsmOperandClass { let Name = NamePrefix # "IndexRange" # Min # "_" # Max; let DiagnosticType = "Invalid" # Name; let PredicateMethod = "isVectorIndex<" # Min # ", " # Max # ">"; let RenderMethod = "addVectorIndexOperands"; } class AsmVectorIndexOpnd : Operand { let ParserMatchClass = mc; let PrintMethod = "printVectorIndex"; } multiclass VectorIndex { def "" : AsmVectorIndexOpnd, ImmLeaf; def _timm : AsmVectorIndexOpnd, TImmLeaf; } def VectorIndex0Operand : AsmVectorIndex<0, 0>; def VectorIndex1Operand : AsmVectorIndex<1, 1>; def VectorIndexBOperand : AsmVectorIndex<0, 15>; def VectorIndexHOperand : AsmVectorIndex<0, 7>; def VectorIndexSOperand : AsmVectorIndex<0, 3>; def VectorIndexDOperand : AsmVectorIndex<0, 1>; let OperandNamespace = "AArch64" in { let OperandType = "OPERAND_IMPLICIT_IMM_0" in { defm VectorIndex0 : VectorIndex; defm VectorIndex032b : VectorIndex; } } defm VectorIndex1 : VectorIndex; defm VectorIndexB : VectorIndex; defm VectorIndexH : VectorIndex; defm VectorIndexS : VectorIndex; defm VectorIndexD : VectorIndex; defm VectorIndex132b : VectorIndex; defm VectorIndexB32b : VectorIndex; defm VectorIndexH32b : VectorIndex; defm VectorIndexS32b : VectorIndex; defm VectorIndexD32b : VectorIndex; def SVEVectorIndexExtDupBOperand : AsmVectorIndex<0, 63, "SVE">; def SVEVectorIndexExtDupHOperand : AsmVectorIndex<0, 31, "SVE">; def SVEVectorIndexExtDupSOperand : AsmVectorIndex<0, 15, "SVE">; def SVEVectorIndexExtDupDOperand : AsmVectorIndex<0, 7, "SVE">; def SVEVectorIndexExtDupQOperand : AsmVectorIndex<0, 3, "SVE">; defm sve_elm_idx_extdup_b : VectorIndex; defm sve_elm_idx_extdup_h : VectorIndex; defm sve_elm_idx_extdup_s : VectorIndex; defm sve_elm_idx_extdup_d : VectorIndex; defm sve_elm_idx_extdup_q : VectorIndex; def sme_elm_idx0_0 : Operand, TImmLeaf { let ParserMatchClass = Imm0_0Operand; let PrintMethod = "printMatrixIndex"; let OperandNamespace = "AArch64"; let OperandType = "OPERAND_IMPLICIT_IMM_0"; } def sme_elm_idx0_1 : Operand, TImmLeaf { let ParserMatchClass = Imm0_1Operand; let PrintMethod = "printMatrixIndex"; } def sme_elm_idx0_3 : Operand, TImmLeaf { let ParserMatchClass = Imm0_3Operand; let PrintMethod = "printMatrixIndex"; } def sme_elm_idx0_7 : Operand, TImmLeaf { let ParserMatchClass = Imm0_7Operand; let PrintMethod = "printMatrixIndex"; } def sme_elm_idx0_15 : Operand, TImmLeaf { let ParserMatchClass = Imm0_15Operand; let PrintMethod = "printMatrixIndex"; } // SME2 vector select offset operands // uimm3s8 predicate // True if the immediate is a multiple of 8 in the range [0,56]. def UImm3s8Operand : UImmScaledMemoryIndexed<3, 8>; def uimm3s8 : Operand, ImmLeaf= 0 && Imm <= 56 && ((Imm % 8) == 0); }], UImmS8XForm> { let PrintMethod = "printMatrixIndex<8>"; let ParserMatchClass = UImm3s8Operand; } class UImmScaledMemoryIndexedRange : AsmOperandClass { let Name = "UImm" # Width # "s" # Scale # "Range"; let DiagnosticType = "InvalidMemoryIndexedRange" # Scale # "UImm" # Width; let RenderMethod = "addImmScaledRangeOperands<" # Scale # ">"; let PredicateMethod = "isUImmScaled<" # Width # ", " # Scale # ", " # OffsetVal # ", /*IsRange=*/true>"; let ParserMethod = "tryParseImmRange"; } // Implicit immediate ranges 0:1 and 0:3, scale has no meaning // since the immediate is zero def UImm0s2RangeOperand : UImmScaledMemoryIndexedRange<0, 2, 1>; def UImm0s4RangeOperand : UImmScaledMemoryIndexedRange<0, 4, 3>; def UImm1s2RangeOperand : UImmScaledMemoryIndexedRange<1, 2, 1>; def UImm1s4RangeOperand : UImmScaledMemoryIndexedRange<1, 4, 3>; def UImm2s2RangeOperand : UImmScaledMemoryIndexedRange<2, 2, 1>; def UImm2s4RangeOperand : UImmScaledMemoryIndexedRange<2, 4, 3>; def UImm3s2RangeOperand : UImmScaledMemoryIndexedRange<3, 2, 1>; def uimm0s2range : Operand, ImmLeaf { let PrintMethod = "printImmRangeScale<2, 1>"; let ParserMatchClass = UImm0s2RangeOperand; let OperandNamespace = "AArch64"; let OperandType = "OPERAND_IMPLICIT_IMM_0"; } def uimm0s4range : Operand, ImmLeaf { let PrintMethod = "printImmRangeScale<4, 3>"; let ParserMatchClass = UImm0s4RangeOperand; let OperandNamespace = "AArch64"; let OperandType = "OPERAND_IMPLICIT_IMM_0"; } def uimm1s2range : Operand, ImmLeaf= 0 && Imm <= 2 && ((Imm % 2) == 0); }], UImmS2XForm> { let PrintMethod = "printImmRangeScale<2, 1>"; let ParserMatchClass = UImm1s2RangeOperand; } def uimm1s4range : Operand, ImmLeaf= 0 && Imm <= 4 && ((Imm % 4) == 0); }], UImmS4XForm> { let PrintMethod = "printImmRangeScale<4, 3>"; let ParserMatchClass = UImm1s4RangeOperand; } def uimm2s2range : Operand, ImmLeaf= 0 && Imm <= 6 && ((Imm % 2) == 0); }], UImmS2XForm> { let PrintMethod = "printImmRangeScale<2, 1>"; let ParserMatchClass = UImm2s2RangeOperand; } def uimm2s4range : Operand, ImmLeaf= 0 && Imm <= 12 && ((Imm % 4) == 0); }], UImmS4XForm> { let PrintMethod = "printImmRangeScale<4, 3>"; let ParserMatchClass = UImm2s4RangeOperand; } def uimm3s2range : Operand, ImmLeaf= 0 && Imm <= 14 && ((Imm % 2) == 0); }], UImmS2XForm> { let PrintMethod = "printImmRangeScale<2, 1>"; let ParserMatchClass = UImm3s2RangeOperand; } // 8-bit immediate for AdvSIMD where 64-bit values of the form: // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh // are encoded as the eight bit value 'abcdefgh'. def simdimmtype10 : Operand, FPImmLeafgetValueAPF(); uint32_t enc = AArch64_AM::encodeAdvSIMDModImmType10(N->getValueAPF() .bitcastToAPInt() .getZExtValue()); return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); }]>> { let ParserMatchClass = SIMDImmType10Operand; let PrintMethod = "printSIMDType10Operand"; } //--- // System management //--- // Base encoding for system instruction operands. let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in class BaseSystemI pattern = []> : I { let Inst{31-22} = 0b1101010100; let Inst{21} = L; } // System instructions which do not have an Rt register. class SimpleSystemI pattern = []> : BaseSystemI { let Inst{4-0} = 0b11111; } // System instructions which have an Rt register. class RtSystemI pattern = []> : BaseSystemI, Sched<[WriteSys]> { bits<5> Rt; let Inst{4-0} = Rt; } // System instructions for transactional memory extension class TMBaseSystemI CRm, bits<3> op2, dag oops, dag iops, string asm, string operands, list pattern> : BaseSystemI, Sched<[WriteSys]> { let Inst{20-12} = 0b000110011; let Inst{11-8} = CRm; let Inst{7-5} = op2; let DecoderMethod = ""; let mayLoad = 1; let mayStore = 1; } // System instructions for transactional memory - single input operand class TMSystemI CRm, string asm, list pattern> : TMBaseSystemI<0b1, CRm, 0b011, (outs GPR64:$Rt), (ins), asm, "\t$Rt", pattern> { bits<5> Rt; let Inst{4-0} = Rt; } // System instructions that pass a register argument // This class assumes the register is for input rather than output. class RegInputSystemI CRm, bits<3> Op2, string asm, list pattern = []> : RtSystemI<0, (outs), (ins GPR64:$Rt), asm, "\t$Rt", pattern> { let Inst{20-12} = 0b000110001; let Inst{11-8} = CRm; let Inst{7-5} = Op2; } // System instructions for transactional memory - no operand class TMSystemINoOperand CRm, string asm, list pattern> : TMBaseSystemI<0b0, CRm, 0b011, (outs), (ins), asm, "", pattern> { let Inst{4-0} = 0b11111; } // System instructions for exit from transactions class TMSystemException op1, string asm, list pattern> : I<(outs), (ins timm64_0_65535:$imm), asm, "\t$imm", "", pattern>, Sched<[WriteSys]> { bits<16> imm; let Inst{31-24} = 0b11010100; let Inst{23-21} = op1; let Inst{20-5} = imm; let Inst{4-0} = 0b00000; } // Hint instructions that take both a CRm and a 3-bit immediate. // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot // model patterns with sufficiently fine granularity let mayStore = 1, mayLoad = 1, hasSideEffects = 1 in class HintI : SimpleSystemI<0, (ins imm0_127:$imm), mnemonic#"\t$imm", "", [(int_aarch64_hint imm0_127:$imm)]>, Sched<[WriteHint]> { bits <7> imm; let Inst{20-12} = 0b000110010; let Inst{11-5} = imm; } // System instructions taking a single literal operand which encodes into // CRm. op2 differentiates the opcodes. def BarrierAsmOperand : AsmOperandClass { let Name = "Barrier"; let ParserMethod = "tryParseBarrierOperand"; } def barrier_op : Operand { let PrintMethod = "printBarrierOption"; let ParserMatchClass = BarrierAsmOperand; } def BarriernXSAsmOperand : AsmOperandClass { let Name = "BarriernXS"; let ParserMethod = "tryParseBarriernXSOperand"; } def barrier_nxs_op : Operand { let PrintMethod = "printBarriernXSOption"; let ParserMatchClass = BarriernXSAsmOperand; } class CRmSystemI opc, string asm, list pattern = []> : SimpleSystemI<0, (ins crmtype:$CRm), asm, "\t$CRm", pattern>, Sched<[WriteBarrier]> { bits<4> CRm; let Inst{20-12} = 0b000110011; let Inst{11-8} = CRm; let Inst{7-5} = opc; } class SystemNoOperands op2, string asm, list pattern = []> : SimpleSystemI<0, (ins), asm, "", pattern>, Sched<[WriteHint]> { bits<4> CRm; let CRm = 0b0011; let Inst{31-12} = 0b11010101000000110010; let Inst{11-8} = CRm; let Inst{7-5} = op2; let Inst{4-0} = 0b11111; } // MRS/MSR system instructions. These have different operand classes because // a different subset of registers can be accessed through each instruction. def MRSSystemRegisterOperand : AsmOperandClass { let Name = "MRSSystemRegister"; let ParserMethod = "tryParseSysReg"; let DiagnosticType = "MRS"; } // concatenation of op0, op1, CRn, CRm, op2. 16-bit immediate. def mrs_sysreg_op : Operand { let ParserMatchClass = MRSSystemRegisterOperand; let DecoderMethod = "DecodeMRSSystemRegister"; let PrintMethod = "printMRSSystemRegister"; } def MSRSystemRegisterOperand : AsmOperandClass { let Name = "MSRSystemRegister"; let ParserMethod = "tryParseSysReg"; let DiagnosticType = "MSR"; } def msr_sysreg_op : Operand { let ParserMatchClass = MSRSystemRegisterOperand; let DecoderMethod = "DecodeMSRSystemRegister"; let PrintMethod = "printMSRSystemRegister"; } def PSBHintOperand : AsmOperandClass { let Name = "PSBHint"; let ParserMethod = "tryParsePSBHint"; } def psbhint_op : Operand { let ParserMatchClass = PSBHintOperand; let PrintMethod = "printPSBHintOp"; let MCOperandPredicate = [{ // Check, if operand is valid, to fix exhaustive aliasing in disassembly. // "psb" is an alias to "hint" only for certain values of CRm:Op2 fields. if (!MCOp.isImm()) return false; return AArch64PSBHint::lookupPSBByEncoding(MCOp.getImm()) != nullptr; }]; } def BTIHintOperand : AsmOperandClass { let Name = "BTIHint"; let ParserMethod = "tryParseBTIHint"; } def btihint_op : Operand { let ParserMatchClass = BTIHintOperand; let PrintMethod = "printBTIHintOp"; let MCOperandPredicate = [{ // "bti" is an alias to "hint" only for certain values of CRm:Op2 fields. if (!MCOp.isImm()) return false; return AArch64BTIHint::lookupBTIByEncoding(MCOp.getImm() ^ 32) != nullptr; }]; } class MRSI : RtSystemI<1, (outs GPR64:$Rt), (ins mrs_sysreg_op:$systemreg), "mrs", "\t$Rt, $systemreg"> { bits<16> systemreg; let Inst{20-5} = systemreg; let DecoderNamespace = "Fallback"; // The MRS is set as a NZCV setting instruction. Not all MRS instructions // require doing this. The alternative was to explicitly model each one, but // it feels like it is unnecessary because it seems there are no negative // consequences setting these flags for all. let Defs = [NZCV]; } // FIXME: Some of these def NZCV, others don't. Best way to model that? // Explicitly modeling each of the system register as a register class // would do it, but feels like overkill at this point. class MSRI : RtSystemI<0, (outs), (ins msr_sysreg_op:$systemreg, GPR64:$Rt), "msr", "\t$systemreg, $Rt"> { bits<16> systemreg; let Inst{20-5} = systemreg; let DecoderNamespace = "Fallback"; } def SystemPStateFieldWithImm0_15Operand : AsmOperandClass { let Name = "SystemPStateFieldWithImm0_15"; let ParserMethod = "tryParseSysReg"; } def pstatefield4_op : Operand { let ParserMatchClass = SystemPStateFieldWithImm0_15Operand; let PrintMethod = "printSystemPStateField"; let MCOperandPredicate = [{ if (!MCOp.isImm()) return false; return AArch64SVCR::lookupPStateImm0_15ByEncoding(MCOp.getImm()) != nullptr; }]; } // Instructions to modify PSTATE, no input reg let Defs = [NZCV] in class PstateWriteSimple : SimpleSystemI<0, iops, asm, operands> { let Inst{20-19} = 0b00; let Inst{15-12} = 0b0100; } class MSRpstateImm0_15 : PstateWriteSimple<(ins pstatefield4_op:$pstatefield, imm0_15:$imm), "msr", "\t$pstatefield, $imm">, Sched<[WriteSys]> { bits<6> pstatefield; bits<4> imm; let Inst{18-16} = pstatefield{5-3}; let Inst{11-8} = imm; let Inst{7-5} = pstatefield{2-0}; let DecoderMethod = "DecodeSystemPStateImm0_15Instruction"; // MSRpstateI aliases with MSRI. When the MSRpstateI decoder method returns // Fail the decoder should attempt to decode the instruction as MSRI. let hasCompleteDecoder = false; } def SystemPStateFieldWithImm0_1Operand : AsmOperandClass { let Name = "SystemPStateFieldWithImm0_1"; let ParserMethod = "tryParseSysReg"; } def pstatefield1_op : Operand { let ParserMatchClass = SystemPStateFieldWithImm0_1Operand; let PrintMethod = "printSystemPStateField"; let MCOperandPredicate = [{ if (!MCOp.isImm()) return false; return AArch64SVCR::lookupPStateImm0_1ByEncoding(MCOp.getImm()) != nullptr; }]; } class MSRpstateImm0_1 : PstateWriteSimple<(ins pstatefield1_op:$pstatefield, imm0_1:$imm), "msr", "\t$pstatefield, $imm">, Sched<[WriteSys]> { bits<9> pstatefield; bit imm; let Inst{18-16} = pstatefield{5-3}; let Inst{11-9} = pstatefield{8-6}; let Inst{8} = imm; let Inst{7-5} = pstatefield{2-0}; let DecoderMethod = "DecodeSystemPStateImm0_1Instruction"; // MSRpstateI aliases with MSRI. When the MSRpstateI decoder method returns // Fail the decoder should attempt to decode the instruction as MSRI. let hasCompleteDecoder = false; let DecoderNamespace = "Fallback"; } // SYS and SYSL generic system instructions. def SysCRAsmOperand : AsmOperandClass { let Name = "SysCR"; let ParserMethod = "tryParseSysCROperand"; } def sys_cr_op : Operand { let PrintMethod = "printSysCROperand"; let ParserMatchClass = SysCRAsmOperand; } class SystemXtI : RtSystemI { bits<3> op1; bits<4> Cn; bits<4> Cm; bits<3> op2; let Inst{20-19} = 0b01; let Inst{18-16} = op1; let Inst{15-12} = Cn; let Inst{11-8} = Cm; let Inst{7-5} = op2; } class SystemLXtI : RtSystemI { bits<3> op1; bits<4> Cn; bits<4> Cm; bits<3> op2; let Inst{20-19} = 0b01; let Inst{18-16} = op1; let Inst{15-12} = Cn; let Inst{11-8} = Cm; let Inst{7-5} = op2; } def RangePrefetchOperand : AsmOperandClass { let Name = "RangePrefetch"; let ParserMethod = "tryParseRPRFMOperand"; let PredicateMethod = "isPrefetch"; let RenderMethod = "addPrefetchOperands"; } def rprfop : Operand, TImmLeaf { let PrintMethod = "printRPRFMOperand"; let ParserMatchClass = RangePrefetchOperand; } // Branch (register) instructions: // // case opc of // 0001 blr // 0000 br // 0101 dret // 0100 eret // 0010 ret // otherwise UNDEFINED class BaseBranchReg opc, dag oops, dag iops, string asm, string operands, list pattern> : I, Sched<[WriteBrReg]> { let Inst{31-25} = 0b1101011; let Inst{24-21} = opc; let Inst{20-16} = 0b11111; let Inst{15-10} = 0b000000; let Inst{4-0} = 0b00000; } class BranchReg opc, string asm, list pattern> : BaseBranchReg { bits<5> Rn; let Inst{9-5} = Rn; } let mayLoad = 0, mayStore = 0, hasSideEffects = 1, isReturn = 1 in class SpecialReturn opc, string asm> : BaseBranchReg { let Inst{9-5} = 0b11111; } let mayLoad = 1 in class RCPCLoad sz, string asm, RegisterClass RC> : I<(outs RC:$Rt), (ins GPR64sp0:$Rn), asm, "\t$Rt, [$Rn]", "", []>, Sched<[]> { bits<5> Rn; bits<5> Rt; let Inst{31-30} = sz; let Inst{29-10} = 0b11100010111111110000; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } class AuthBase M, dag oops, dag iops, string asm, string operands, list pattern> : I, Sched<[]> { let isAuthenticated = 1; let Inst{31-25} = 0b1101011; let Inst{20-11} = 0b1111100001; let Inst{10} = M; let Inst{4-0} = 0b11111; } class AuthBranchTwoOperands op, bits<1> M, string asm> : AuthBase { bits<5> Rn; bits<5> Rm; let Inst{24-22} = 0b100; let Inst{21} = op; let Inst{9-5} = Rn; let Inst{4-0} = Rm; } class AuthOneOperand opc, bits<1> M, string asm> : AuthBase { bits<5> Rn; let Inst{24} = 0; let Inst{23-21} = opc; let Inst{9-5} = Rn; } let Uses = [LR,SP] in class AuthReturn op, bits<1> M, string asm> : AuthBase { let Inst{24} = 0; let Inst{23-21} = op; let Inst{9-0} = 0b1111111111; } let mayLoad = 1 in class BaseAuthLoad : I, Sched<[]> { bits<10> offset; bits<5> Rn; bits<5> Rt; let isAuthenticated = 1; let Inst{31-24} = 0b11111000; let Inst{23} = M; let Inst{22} = offset{9}; let Inst{21} = 1; let Inst{20-12} = offset{8-0}; let Inst{11} = W; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodeAuthLoadInstruction"; } multiclass AuthLoad { def indexed : BaseAuthLoad; def writeback : BaseAuthLoad; def : InstAlias(NAME # "indexed") GPR64:$Rt, GPR64sp:$Rn, 0)>; def : InstAlias(NAME # "writeback") GPR64sp:$wback, GPR64:$Rt, 0), 0>; } //--- // Conditional branch instruction. //--- // Condition code. // 4-bit immediate. Pretty-printed as def ccode : Operand { let PrintMethod = "printCondCode"; let ParserMatchClass = CondCode; } def inv_ccode : Operand { // AL and NV are invalid in the aliases which use inv_ccode let PrintMethod = "printInverseCondCode"; let ParserMatchClass = CondCode; let MCOperandPredicate = [{ return MCOp.isImm() && MCOp.getImm() != AArch64CC::AL && MCOp.getImm() != AArch64CC::NV; }]; } // Conditional branch target. 19-bit immediate. The low two bits of the target // offset are implied zero and so are not part of the immediate. def am_brcond : Operand { let EncoderMethod = "getCondBranchTargetOpValue"; let DecoderMethod = "DecodePCRelLabel19"; let PrintMethod = "printAlignedLabel"; let ParserMatchClass = PCRelLabel19Operand; let OperandType = "OPERAND_PCREL"; } class BranchCond : I<(outs), (ins ccode:$cond, am_brcond:$target), mnemonic, ".$cond\t$target", "", [(AArch64brcond bb:$target, imm:$cond, NZCV)]>, Sched<[WriteBr]> { let isBranch = 1; let isTerminator = 1; let Uses = [NZCV]; bits<4> cond; bits<19> target; let Inst{31-24} = 0b01010100; let Inst{23-5} = target; let Inst{4} = bit4; let Inst{3-0} = cond; } //--- // Compare-and-branch instructions. //--- class BaseCmpBranch : I<(outs), (ins regtype:$Rt, am_brcond:$target), asm, "\t$Rt, $target", "", [(node regtype:$Rt, bb:$target)]>, Sched<[WriteBr]> { let isBranch = 1; let isTerminator = 1; bits<5> Rt; bits<19> target; let Inst{30-25} = 0b011010; let Inst{24} = op; let Inst{23-5} = target; let Inst{4-0} = Rt; } multiclass CmpBranch { def W : BaseCmpBranch { let Inst{31} = 0; } def X : BaseCmpBranch { let Inst{31} = 1; } } //--- // Test-bit-and-branch instructions. //--- // Test-and-branch target. 14-bit sign-extended immediate. The low two bits of // the target offset are implied zero and so are not part of the immediate. def am_tbrcond : Operand { let EncoderMethod = "getTestBranchTargetOpValue"; let PrintMethod = "printAlignedLabel"; let ParserMatchClass = BranchTarget14Operand; let OperandType = "OPERAND_PCREL"; } // AsmOperand classes to emit (or not) special diagnostics def TBZImm0_31Operand : AsmOperandClass { let Name = "TBZImm0_31"; let PredicateMethod = "isImmInRange<0,31>"; let RenderMethod = "addImmOperands"; } def TBZImm32_63Operand : AsmOperandClass { let Name = "Imm32_63"; let PredicateMethod = "isImmInRange<32,63>"; let DiagnosticType = "InvalidImm0_63"; let RenderMethod = "addImmOperands"; } class tbz_imm0_31 : Operand, ImmLeaf { let ParserMatchClass = matcher; } def tbz_imm0_31_diag : tbz_imm0_31; def tbz_imm0_31_nodiag : tbz_imm0_31; def tbz_imm32_63 : Operand, ImmLeaf 31) && (((uint32_t)Imm) < 64); }]> { let ParserMatchClass = TBZImm32_63Operand; } class BaseTestBranch : I<(outs), (ins regtype:$Rt, immtype:$bit_off, am_tbrcond:$target), asm, "\t$Rt, $bit_off, $target", "", [(node regtype:$Rt, immtype:$bit_off, bb:$target)]>, Sched<[WriteBr]> { let isBranch = 1; let isTerminator = 1; bits<5> Rt; bits<6> bit_off; bits<14> target; let Inst{30-25} = 0b011011; let Inst{24} = op; let Inst{23-19} = bit_off{4-0}; let Inst{18-5} = target; let Inst{4-0} = Rt; let DecoderMethod = "DecodeTestAndBranch"; } multiclass TestBranch { def W : BaseTestBranch { let Inst{31} = 0; } def X : BaseTestBranch { let Inst{31} = 1; } // Alias X-reg with 0-31 imm to W-Reg. def : InstAlias(NAME#"W") GPR32as64:$Rd, tbz_imm0_31_nodiag:$imm, am_tbrcond:$target), 0>; def : Pat<(node GPR64:$Rn, tbz_imm0_31_diag:$imm, bb:$target), (!cast(NAME#"W") (EXTRACT_SUBREG GPR64:$Rn, sub_32), tbz_imm0_31_diag:$imm, bb:$target)>; } //--- // Unconditional branch (immediate) instructions. //--- def am_b_target : Operand { let EncoderMethod = "getBranchTargetOpValue"; let PrintMethod = "printAlignedLabel"; let ParserMatchClass = BranchTarget26Operand; let OperandType = "OPERAND_PCREL"; } def am_bl_target : Operand { let EncoderMethod = "getBranchTargetOpValue"; let PrintMethod = "printAlignedLabel"; let ParserMatchClass = BranchTarget26Operand; let OperandType = "OPERAND_PCREL"; } class BImm pattern> : I<(outs), iops, asm, "\t$addr", "", pattern>, Sched<[WriteBr]> { bits<26> addr; let Inst{31} = op; let Inst{30-26} = 0b00101; let Inst{25-0} = addr; let DecoderMethod = "DecodeUnconditionalBranch"; } class BranchImm pattern> : BImm; class CallImm pattern> : BImm; //--- // Basic one-operand data processing instructions. //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseOneOperandData opc2, bits<6> opc, RegisterClass regtype, string asm, SDPatternOperator node> : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "", [(set regtype:$Rd, (node regtype:$Rn))]>, Sched<[WriteI, ReadI]> { bits<5> Rd; bits<5> Rn; let Inst{31} = sf; let Inst{30} = 0b1; let Inst{29} = S; let Inst{28-21} = 0b11010110; let Inst{20-16} = opc2; let Inst{15-10} = opc; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in multiclass OneOperandData opc, string asm, SDPatternOperator node = null_frag> { def Wr : BaseOneOperandData<0b0, 0b0, 0b00000, opc, GPR32, asm, node>; def Xr : BaseOneOperandData<0b1, 0b0, 0b00000, opc, GPR64, asm, node>; } class OneWRegData opc, string asm, SDPatternOperator node> : BaseOneOperandData<0b0, 0b0, 0b00000, opc, GPR32, asm, node>; class OneXRegData opc, string asm, SDPatternOperator node> : BaseOneOperandData<0b1, 0b0, 0b00000, opc, GPR64, asm, node>; class SignAuthOneData opcode_prefix, bits<2> opcode, string asm, SDPatternOperator op> : I<(outs GPR64:$dst), (ins GPR64:$Rd, GPR64sp:$Rn), asm, "\t$Rd, $Rn", "$dst = $Rd", [(set GPR64:$dst, (op GPR64:$Rd, opcode, GPR64sp:$Rn))]>, Sched<[WriteI, ReadI]> { bits<5> Rd; bits<5> Rn; let Inst{31-15} = 0b11011010110000010; let Inst{14-12} = opcode_prefix; let Inst{11-10} = opcode; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class SignAuthZero opcode_prefix, bits<2> opcode, string asm, SDPatternOperator op> : I<(outs GPR64:$dst), (ins GPR64:$Rd), asm, "\t$Rd", "$dst = $Rd", [(set GPR64:$dst, (op GPR64:$Rd, opcode, (i64 0)))]>, Sched<[]> { bits<5> Rd; let Inst{31-15} = 0b11011010110000010; let Inst{14-12} = opcode_prefix; let Inst{11-10} = opcode; let Inst{9-5} = 0b11111; let Inst{4-0} = Rd; } class SignAuthTwoOperand opc, string asm, SDPatternOperator OpNode> : I<(outs GPR64:$Rd), (ins GPR64:$Rn, GPR64sp:$Rm), asm, "\t$Rd, $Rn, $Rm", "", [(set GPR64:$Rd, (OpNode GPR64:$Rn, GPR64sp:$Rm))]>, Sched<[WriteI, ReadI, ReadI]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-21} = 0b10011010110; let Inst{20-16} = Rm; let Inst{15-14} = 0b00; let Inst{13-10} = opc; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class ClearAuth data, string asm> : I<(outs GPR64:$Rd), (ins GPR64:$Rn), asm, "\t$Rd", "$Rd = $Rn", []>, Sched<[]> { bits<5> Rd; let Inst{31-11} = 0b110110101100000101000; let Inst{10} = data; let Inst{9-5} = 0b11111; let Inst{4-0} = Rd; } // v9.5-A FEAT_PAuth_LR class SignAuthFixedRegs opcode2, bits<6> opcode, string asm> : I<(outs), (ins), asm, "", "", []>, Sched<[WriteI, ReadI]> { let Inst{31} = 0b1; // sf let Inst{30} = 0b1; let Inst{29} = 0b0; // S let Inst{28-21} = 0b11010110; let Inst{20-16} = opcode2; let Inst{15-10} = opcode; let Inst{9-5} = 0b11111; // Rn let Inst{4-0} = 0b11110; // Rd } def PAuthPCRelLabel16Operand : PCRelLabel<16> { let Name = "PAuthPCRelLabel16"; let PredicateMethod = "isPAuthPCRelLabel16Operand"; } def am_pauth_pcrel : Operand { let EncoderMethod = "getPAuthPCRelOpValue"; let DecoderMethod = "DecodePCRelLabel16"; let PrintMethod = "printAlignedLabel"; let ParserMatchClass = PAuthPCRelLabel16Operand; let OperandType = "OPERAND_PCREL"; } class SignAuthPCRel opc, string asm> : I<(outs), (ins am_pauth_pcrel:$label), asm, "\t$label", "", []>, Sched<[]> { bits<16> label; let Inst{31} = 0b1; // sf let Inst{30-23} = 0b11100111; let Inst{22-21} = opc; let Inst{20-5} = label; // imm let Inst{4-0} = 0b11111; // Rd } class SignAuthOneReg opcode2, bits<6> opcode, string asm> : I<(outs), (ins GPR64:$Rn), asm, "\t$Rn", "", []>, Sched<[]> { bits<5> Rn; let Inst{31} = 0b1; // sf let Inst{30} = 0b1; let Inst{29} = 0b0; // S let Inst{28-21} = 0b11010110; let Inst{20-16} = opcode2; let Inst{15-10} = opcode; let Inst{9-5} = Rn; let Inst{4-0} = 0b11110; // Rd } class SignAuthReturnPCRel opc, bits<5> op2, string asm> : I<(outs), (ins am_pauth_pcrel:$label), asm, "\t$label", "", []>, Sched<[WriteAtomic]> { bits<16> label; let Inst{31-24} = 0b01010101; let Inst{23-21} = opc; let Inst{20-5} = label; // imm16 let Inst{4-0} = op2; } class SignAuthReturnReg op3, string asm> : I<(outs), (ins GPR64common:$Rm), asm, "\t$Rm", "", []>, Sched<[WriteAtomic]> { bits<5> Rm; let Inst{31-25} = 0b1101011; let Inst{24-21} = 0b0010; // opc let Inst{20-16} = 0b11111; // op2 let Inst{15-10} = op3; let Inst{9-5} = 0b11111; // Rn let Inst{4-0} = Rm; // op4 (Rm) } // Base class for the Armv8.4-A 8 and 16-bit flag manipulation instructions class BaseFlagManipulation : I<(outs), iops, asm, ops, "", []>, Sched<[WriteI, ReadI, ReadI]> { let Uses = [NZCV]; let Defs = [NZCV]; bits<5> Rn; let Inst{31} = sf; let Inst{30-15} = 0b0111010000000000; let Inst{14} = sz; let Inst{13-10} = 0b0010; let Inst{9-5} = Rn; let Inst{4-0} = 0b01101; } class FlagRotate : BaseFlagManipulation<0b1, 0b0, iops, asm, ops> { bits<6> imm; bits<4> mask; let Inst{20-15} = imm; let Inst{13-10} = 0b0001; let Inst{4} = 0b0; let Inst{3-0} = mask; } //--- // Basic two-operand data processing instructions. //--- class BaseBaseAddSubCarry pattern> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rd, $Rn, $Rm", "", pattern>, Sched<[WriteI, ReadI, ReadI]> { let Uses = [NZCV]; bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{30} = isSub; let Inst{28-21} = 0b11010000; let Inst{20-16} = Rm; let Inst{15-10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class BaseAddSubCarry : BaseBaseAddSubCarry; class BaseAddSubCarrySetFlags : BaseBaseAddSubCarry { let Defs = [NZCV]; } multiclass AddSubCarry { def Wr : BaseAddSubCarry { let Inst{31} = 0; let Inst{29} = 0; } def Xr : BaseAddSubCarry { let Inst{31} = 1; let Inst{29} = 0; } // Sets flags. def SWr : BaseAddSubCarrySetFlags { let Inst{31} = 0; let Inst{29} = 1; } def SXr : BaseAddSubCarrySetFlags { let Inst{31} = 1; let Inst{29} = 1; } } class BaseTwoOperandRegReg opc, RegisterClass regtype, string asm, SDPatternOperator OpNode, RegisterClass in1regtype = regtype, RegisterClass in2regtype = regtype> : I<(outs regtype:$Rd), (ins in1regtype:$Rn, in2regtype:$Rm), asm, "\t$Rd, $Rn, $Rm", "", [(set regtype:$Rd, (OpNode in1regtype:$Rn, in2regtype:$Rm))]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = sf; let Inst{30} = 0b0; let Inst{29} = S; let Inst{28-21} = 0b11010110; let Inst{20-16} = Rm; let Inst{15-10} = opc; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class BaseDiv : BaseTwoOperandRegReg { let Inst{10} = isSigned; } multiclass Div { def Wr : BaseDiv<0b0, isSigned, GPR32, asm, OpNode>, Sched<[WriteID32, ReadID, ReadID]>; def Xr : BaseDiv<0b1, isSigned, GPR64, asm, OpNode>, Sched<[WriteID64, ReadID, ReadID]>; } class BaseShift shift_type, RegisterClass regtype, string asm, SDPatternOperator OpNode = null_frag> : BaseTwoOperandRegReg, Sched<[WriteIS, ReadI]> { let Inst{11-10} = shift_type; } multiclass Shift shift_type, string asm, SDNode OpNode> { def Wr : BaseShift<0b0, shift_type, GPR32, asm>; def Xr : BaseShift<0b1, shift_type, GPR64, asm, OpNode>; def : Pat<(i32 (OpNode GPR32:$Rn, i64:$Rm)), (!cast(NAME # "Wr") GPR32:$Rn, (EXTRACT_SUBREG i64:$Rm, sub_32))>; def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (zext GPR32:$Rm)))), (!cast(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>; def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (anyext GPR32:$Rm)))), (!cast(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>; def : Pat<(i32 (OpNode GPR32:$Rn, (i64 (sext GPR32:$Rm)))), (!cast(NAME # "Wr") GPR32:$Rn, GPR32:$Rm)>; def : Pat<(i64 (OpNode GPR64:$Rn, (i64 (sext GPR32:$Rm)))), (!cast(NAME # "Xr") GPR64:$Rn, (SUBREG_TO_REG (i32 0), GPR32:$Rm, sub_32))>; def : Pat<(i64 (OpNode GPR64:$Rn, (i64 (zext GPR32:$Rm)))), (!cast(NAME # "Xr") GPR64:$Rn, (SUBREG_TO_REG (i32 0), GPR32:$Rm, sub_32))>; } class ShiftAlias : InstAlias; class BaseMulAccum opc, RegisterClass multype, RegisterClass addtype, string asm, list pattern> : I<(outs addtype:$Rd), (ins multype:$Rn, multype:$Rm, addtype:$Ra), asm, "\t$Rd, $Rn, $Rm, $Ra", "", pattern> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<5> Ra; let Inst{30-24} = 0b0011011; let Inst{23-21} = opc; let Inst{20-16} = Rm; let Inst{15} = isSub; let Inst{14-10} = Ra; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass MulAccum { // MADD/MSUB generation is decided by MachineCombiner.cpp def Wrrr : BaseMulAccum, Sched<[WriteIM32, ReadIM, ReadIM, ReadIMA]> { let Inst{31} = 0; } def Xrrr : BaseMulAccum, Sched<[WriteIM64, ReadIM, ReadIM, ReadIMA]> { let Inst{31} = 1; } } class WideMulAccum opc, string asm, SDNode AccNode, SDNode ExtNode> : BaseMulAccum, Sched<[WriteIM32, ReadIM, ReadIM, ReadIMA]> { let Inst{31} = 1; } class MulHi opc, string asm, SDNode OpNode> : I<(outs GPR64:$Rd), (ins GPR64:$Rn, GPR64:$Rm), asm, "\t$Rd, $Rn, $Rm", "", [(set GPR64:$Rd, (OpNode GPR64:$Rn, GPR64:$Rm))]>, Sched<[WriteIM64, ReadIM, ReadIM]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-24} = 0b10011011; let Inst{23-21} = opc; let Inst{20-16} = Rm; let Inst{15} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; // The Ra field of SMULH and UMULH is unused: it should be assembled as 31 // (i.e. all bits 1) but is ignored by the processor. let PostEncoderMethod = "fixMulHigh"; } class MulAccumWAlias : InstAlias; class MulAccumXAlias : InstAlias; class WideMulAccumAlias : InstAlias; class BaseCRC32 sz, bit C, RegisterClass StreamReg, SDPatternOperator OpNode, string asm> : I<(outs GPR32:$Rd), (ins GPR32:$Rn, StreamReg:$Rm), asm, "\t$Rd, $Rn, $Rm", "", [(set GPR32:$Rd, (OpNode GPR32:$Rn, StreamReg:$Rm))]>, Sched<[WriteISReg, ReadI, ReadISReg]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = sf; let Inst{30-21} = 0b0011010110; let Inst{20-16} = Rm; let Inst{15-13} = 0b010; let Inst{12} = C; let Inst{11-10} = sz; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let Predicates = [HasCRC]; } //--- // Address generation. //--- class ADRI pattern> : I<(outs GPR64:$Xd), (ins adr:$label), asm, "\t$Xd, $label", "", pattern>, Sched<[WriteI]> { bits<5> Xd; bits<21> label; let Inst{31} = page; let Inst{30-29} = label{1-0}; let Inst{28-24} = 0b10000; let Inst{23-5} = label{20-2}; let Inst{4-0} = Xd; let DecoderMethod = "DecodeAdrInstruction"; } //--- // Move immediate. //--- def movimm32_imm : Operand { let ParserMatchClass = AsmImmRange<0, 65535>; let EncoderMethod = "getMoveWideImmOpValue"; let PrintMethod = "printImm"; } def movimm32_shift : Operand { let PrintMethod = "printShifter"; let ParserMatchClass = MovImm32ShifterOperand; } def movimm64_shift : Operand { let PrintMethod = "printShifter"; let ParserMatchClass = MovImm64ShifterOperand; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseMoveImmediate opc, RegisterClass regtype, Operand shifter, string asm> : I<(outs regtype:$Rd), (ins movimm32_imm:$imm, shifter:$shift), asm, "\t$Rd, $imm$shift", "", []>, Sched<[WriteImm]> { bits<5> Rd; bits<16> imm; bits<6> shift; let Inst{30-29} = opc; let Inst{28-23} = 0b100101; let Inst{22-21} = shift{5-4}; let Inst{20-5} = imm; let Inst{4-0} = Rd; let DecoderMethod = "DecodeMoveImmInstruction"; } multiclass MoveImmediate opc, string asm> { def Wi : BaseMoveImmediate { let Inst{31} = 0; } def Xi : BaseMoveImmediate { let Inst{31} = 1; } } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseInsertImmediate opc, RegisterClass regtype, Operand shifter, string asm> : I<(outs regtype:$Rd), (ins regtype:$src, movimm32_imm:$imm, shifter:$shift), asm, "\t$Rd, $imm$shift", "$src = $Rd", []>, Sched<[WriteI, ReadI]> { bits<5> Rd; bits<16> imm; bits<6> shift; let Inst{30-29} = opc; let Inst{28-23} = 0b100101; let Inst{22-21} = shift{5-4}; let Inst{20-5} = imm; let Inst{4-0} = Rd; let DecoderMethod = "DecodeMoveImmInstruction"; } multiclass InsertImmediate opc, string asm> { def Wi : BaseInsertImmediate { let Inst{31} = 0; } def Xi : BaseInsertImmediate { let Inst{31} = 1; } } //--- // Add/Subtract //--- class BaseAddSubImm : I<(outs dstRegtype:$Rd), inputs, asm_inst, asm_ops, "", [pattern]>, Sched<[WriteI, ReadI]> { bits<5> Rd; bits<5> Rn; let Inst{30} = isSub; let Inst{29} = setFlags; let Inst{28-24} = 0b10001; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class AddSubImmShift : BaseAddSubImm { bits<14> imm; let Inst{23-22} = imm{13-12}; // '00' => lsl #0, '01' => lsl #12 let Inst{21-10} = imm{11-0}; let DecoderMethod = "DecodeAddSubImmShift"; } class BaseAddSubRegPseudo : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>, Sched<[WriteI, ReadI, ReadI]>; class BaseAddSubSReg : I<(outs regtype:$Rd), (ins regtype:$Rn, (shifted_regtype $Rm, $shift):$Rm_and_shift), asm, "\t$Rd, $Rn, $Rm_and_shift", "", [(set regtype:$Rd, (OpNode regtype:$Rn, shifted_regtype:$Rm_and_shift))]>, Sched<[WriteISReg, ReadI, ReadISReg]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<8> shift; let Inst{30} = isSub; let Inst{29} = setFlags; let Inst{28-24} = 0b01011; let Inst{23-22} = shift{7-6}; let Inst{21} = 0; let Inst{20-16} = Rm; let Inst{15-10} = shift{5-0}; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeThreeAddrSRegInstruction"; } class BaseAddSubEReg : I<(outs dstRegtype:$Rd), (ins src1Regtype:$Rn, (src2Regtype $Rm, $extend):$Rm_and_extend), asm, "\t$Rd, $Rn, $Rm_and_extend", "", [(set dstRegtype:$Rd, (OpNode src1Regtype:$Rn, src2Regtype:$Rm_and_extend))]>, Sched<[WriteIEReg, ReadI, ReadIEReg]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<6> extend; let Inst{30} = isSub; let Inst{29} = setFlags; let Inst{28-24} = 0b01011; let Inst{23-21} = 0b001; let Inst{20-16} = Rm; let Inst{15-13} = extend{5-3}; let Inst{12-10} = extend{2-0}; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeAddSubERegInstruction"; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseAddSubEReg64 : I<(outs dstRegtype:$Rd), (ins src1Regtype:$Rn, src2Regtype:$Rm, ext_op:$ext), asm, "\t$Rd, $Rn, $Rm$ext", "", []>, Sched<[WriteIEReg, ReadI, ReadIEReg]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<6> ext; let Inst{30} = isSub; let Inst{29} = setFlags; let Inst{28-24} = 0b01011; let Inst{23-21} = 0b001; let Inst{20-16} = Rm; let Inst{15} = ext{5}; let Inst{12-10} = ext{2-0}; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeAddSubERegInstruction"; } // Aliases for register+register add/subtract. class AddSubRegAlias : InstAlias; multiclass AddSub { let hasSideEffects = 0, isReMaterializable = 1, isAsCheapAsAMove = 1 in { // Add/Subtract immediate // Increase the weight of the immediate variant to try to match it before // the extended register variant. // We used to match the register variant before the immediate when the // register argument could be implicitly zero-extended. let AddedComplexity = 6 in def Wri : AddSubImmShift { let Inst{31} = 0; } let AddedComplexity = 6 in def Xri : AddSubImmShift { let Inst{31} = 1; } // Add/Subtract register - Only used for CodeGen def Wrr : BaseAddSubRegPseudo; def Xrr : BaseAddSubRegPseudo; // Add/Subtract shifted register def Wrs : BaseAddSubSReg { let Inst{31} = 0; } def Xrs : BaseAddSubSReg { let Inst{31} = 1; } } // Add/Subtract extended register let AddedComplexity = 1, hasSideEffects = 0 in { def Wrx : BaseAddSubEReg { let Inst{31} = 0; } def Xrx : BaseAddSubEReg { let Inst{31} = 1; } } def Xrx64 : BaseAddSubEReg64 { // UXTX and SXTX only. let Inst{14-13} = 0b11; let Inst{31} = 1; } // add Rd, Rb, -imm -> sub Rd, Rn, imm def : InstSubst(NAME # "Wri") GPR32sp:$Rd, GPR32sp:$Rn, addsub_shifted_imm32_neg:$imm), 0>; def : InstSubst(NAME # "Xri") GPR64sp:$Rd, GPR64sp:$Rn, addsub_shifted_imm64_neg:$imm), 0>; // Register/register aliases with no shift when SP is not used. def : AddSubRegAlias(NAME#"Wrs"), GPR32, GPR32, GPR32, 0>; def : AddSubRegAlias(NAME#"Xrs"), GPR64, GPR64, GPR64, 0>; // Register/register aliases with no shift when either the destination or // first source register is SP. def : AddSubRegAlias(NAME#"Wrx"), GPR32sponly, GPR32sp, GPR32, 16>; // UXTW #0 def : AddSubRegAlias(NAME#"Wrx"), GPR32sp, GPR32sponly, GPR32, 16>; // UXTW #0 def : AddSubRegAlias(NAME#"Xrx64"), GPR64sponly, GPR64sp, GPR64, 24>; // UXTX #0 def : AddSubRegAlias(NAME#"Xrx64"), GPR64sp, GPR64sponly, GPR64, 24>; // UXTX #0 } multiclass AddSubS { let isCompare = 1, Defs = [NZCV] in { // Add/Subtract immediate def Wri : AddSubImmShift { let Inst{31} = 0; } def Xri : AddSubImmShift { let Inst{31} = 1; } // Add/Subtract register def Wrr : BaseAddSubRegPseudo; def Xrr : BaseAddSubRegPseudo; // Add/Subtract shifted register def Wrs : BaseAddSubSReg { let Inst{31} = 0; } def Xrs : BaseAddSubSReg { let Inst{31} = 1; } // Add/Subtract extended register let AddedComplexity = 1 in { def Wrx : BaseAddSubEReg { let Inst{31} = 0; } def Xrx : BaseAddSubEReg { let Inst{31} = 1; } } def Xrx64 : BaseAddSubEReg64 { // UXTX and SXTX only. let Inst{14-13} = 0b11; let Inst{31} = 1; } } // Defs = [NZCV] // Support negative immediates, e.g. adds Rd, Rn, -imm -> subs Rd, Rn, imm def : InstSubst(NAME # "Wri") GPR32:$Rd, GPR32sp:$Rn, addsub_shifted_imm32_neg:$imm), 0>; def : InstSubst(NAME # "Xri") GPR64:$Rd, GPR64sp:$Rn, addsub_shifted_imm64_neg:$imm), 0>; // Compare aliases def : InstAlias(NAME#"Wri") WZR, GPR32sp:$src, addsub_shifted_imm32:$imm), 5>; def : InstAlias(NAME#"Xri") XZR, GPR64sp:$src, addsub_shifted_imm64:$imm), 5>; def : InstAlias(NAME#"Wrx") WZR, GPR32sp:$src1, GPR32:$src2, arith_extend:$sh), 4>; def : InstAlias(NAME#"Xrx") XZR, GPR64sp:$src1, GPR32:$src2, arith_extend:$sh), 4>; def : InstAlias(NAME#"Xrx64") XZR, GPR64sp:$src1, GPR64:$src2, arith_extendlsl64:$sh), 4>; def : InstAlias(NAME#"Wrs") WZR, GPR32:$src1, GPR32:$src2, arith_shift32:$sh), 4>; def : InstAlias(NAME#"Xrs") XZR, GPR64:$src1, GPR64:$src2, arith_shift64:$sh), 4>; // Support negative immediates, e.g. cmp Rn, -imm -> cmn Rn, imm def : InstSubst(NAME#"Wri") WZR, GPR32sp:$src, addsub_shifted_imm32_neg:$imm), 0>; def : InstSubst(NAME#"Xri") XZR, GPR64sp:$src, addsub_shifted_imm64_neg:$imm), 0>; // Compare shorthands def : InstAlias(NAME#"Wrs") WZR, GPR32:$src1, GPR32:$src2, 0), 5>; def : InstAlias(NAME#"Xrs") XZR, GPR64:$src1, GPR64:$src2, 0), 5>; def : InstAlias(NAME#"Wrx") WZR, GPR32sponly:$src1, GPR32:$src2, 16), 5>; def : InstAlias(NAME#"Xrx64") XZR, GPR64sponly:$src1, GPR64:$src2, 24), 5>; // Register/register aliases with no shift when SP is not used. def : AddSubRegAlias(NAME#"Wrs"), GPR32, GPR32, GPR32, 0>; def : AddSubRegAlias(NAME#"Xrs"), GPR64, GPR64, GPR64, 0>; // Register/register aliases with no shift when the first source register // is SP. def : AddSubRegAlias(NAME#"Wrx"), GPR32, GPR32sponly, GPR32, 16>; // UXTW #0 def : AddSubRegAlias(NAME#"Xrx64"), GPR64, GPR64sponly, GPR64, 24>; // UXTX #0 } class AddSubG : BaseAddSubImm< isSub, 0, GPR64sp, asm_inst, "\t$Rd, $Rn, $imm6, $imm4", (ins GPR64sp:$Rn, uimm6s16:$imm6, imm0_15:$imm4), (set GPR64sp:$Rd, (OpNode GPR64sp:$Rn, imm0_63:$imm6, imm0_15:$imm4))> { bits<6> imm6; bits<4> imm4; let Inst{31} = 1; let Inst{23-22} = 0b10; let Inst{21-16} = imm6; let Inst{15-14} = 0b00; let Inst{13-10} = imm4; let Unpredictable{15-14} = 0b11; } class SUBP : BaseTwoOperandRegReg<0b1, setsFlags, 0b000000, GPR64, asm_instr, OpNode, GPR64sp, GPR64sp>; //--- // Extract //--- def SDTA64EXTR : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisPtrTy<3>]>; def AArch64Extr : SDNode<"AArch64ISD::EXTR", SDTA64EXTR>; class BaseExtractImm patterns> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, imm_type:$imm), asm, "\t$Rd, $Rn, $Rm, $imm", "", patterns>, Sched<[WriteExtr, ReadExtrHi]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<6> imm; let Inst{30-23} = 0b00100111; let Inst{21} = 0; let Inst{20-16} = Rm; let Inst{15-10} = imm; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass ExtractImm { def Wrri : BaseExtractImm { let Inst{31} = 0; let Inst{22} = 0; // imm<5> must be zero. let imm{5} = 0; } def Xrri : BaseExtractImm { let Inst{31} = 1; let Inst{22} = 1; } } //--- // Bitfield //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseBitfieldImm opc, RegisterClass regtype, Operand imm_type, string asm> : I<(outs regtype:$Rd), (ins regtype:$Rn, imm_type:$immr, imm_type:$imms), asm, "\t$Rd, $Rn, $immr, $imms", "", []>, Sched<[WriteIS, ReadI]> { bits<5> Rd; bits<5> Rn; bits<6> immr; bits<6> imms; let Inst{30-29} = opc; let Inst{28-23} = 0b100110; let Inst{21-16} = immr; let Inst{15-10} = imms; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass BitfieldImm opc, string asm> { def Wri : BaseBitfieldImm { let Inst{31} = 0; let Inst{22} = 0; // imms<5> and immr<5> must be zero, else ReservedValue(). let Inst{21} = 0; let Inst{15} = 0; } def Xri : BaseBitfieldImm { let Inst{31} = 1; let Inst{22} = 1; } } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseBitfieldImmWith2RegArgs opc, RegisterClass regtype, Operand imm_type, string asm> : I<(outs regtype:$Rd), (ins regtype:$src, regtype:$Rn, imm_type:$immr, imm_type:$imms), asm, "\t$Rd, $Rn, $immr, $imms", "$src = $Rd", []>, Sched<[WriteIS, ReadI]> { bits<5> Rd; bits<5> Rn; bits<6> immr; bits<6> imms; let Inst{30-29} = opc; let Inst{28-23} = 0b100110; let Inst{21-16} = immr; let Inst{15-10} = imms; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass BitfieldImmWith2RegArgs opc, string asm> { def Wri : BaseBitfieldImmWith2RegArgs { let Inst{31} = 0; let Inst{22} = 0; // imms<5> and immr<5> must be zero, else ReservedValue(). let Inst{21} = 0; let Inst{15} = 0; } def Xri : BaseBitfieldImmWith2RegArgs { let Inst{31} = 1; let Inst{22} = 1; } } //--- // Logical //--- // Logical (immediate) class BaseLogicalImm opc, RegisterClass dregtype, RegisterClass sregtype, Operand imm_type, string asm, list pattern> : I<(outs dregtype:$Rd), (ins sregtype:$Rn, imm_type:$imm), asm, "\t$Rd, $Rn, $imm", "", pattern>, Sched<[WriteI, ReadI]> { bits<5> Rd; bits<5> Rn; bits<13> imm; let Inst{30-29} = opc; let Inst{28-23} = 0b100100; let Inst{22} = imm{12}; let Inst{21-16} = imm{11-6}; let Inst{15-10} = imm{5-0}; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeLogicalImmInstruction"; } // Logical (shifted register) class BaseLogicalSReg opc, bit N, RegisterClass regtype, logical_shifted_reg shifted_regtype, string asm, list pattern> : I<(outs regtype:$Rd), (ins regtype:$Rn, (shifted_regtype $Rm, $shift):$Rm_and_shift), asm, "\t$Rd, $Rn, $Rm_and_shift", "", pattern>, Sched<[WriteISReg, ReadI, ReadISReg]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<8> shift; let Inst{30-29} = opc; let Inst{28-24} = 0b01010; let Inst{23-22} = shift{7-6}; let Inst{21} = N; let Inst{20-16} = Rm; let Inst{15-10} = shift{5-0}; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeThreeAddrSRegInstruction"; } // Aliases for register+register logical instructions. class LogicalRegAlias : InstAlias; multiclass LogicalImm opc, string mnemonic, SDNode OpNode, string Alias> { let AddedComplexity = 6, isReMaterializable = 1, isAsCheapAsAMove = 1 in def Wri : BaseLogicalImm { let Inst{31} = 0; let Inst{22} = 0; // 64-bit version has an additional bit of immediate. } let AddedComplexity = 6, isReMaterializable = 1, isAsCheapAsAMove = 1 in def Xri : BaseLogicalImm { let Inst{31} = 1; } def : InstSubst(NAME # "Wri") GPR32sp:$Rd, GPR32:$Rn, logical_imm32_not:$imm), 0>; def : InstSubst(NAME # "Xri") GPR64sp:$Rd, GPR64:$Rn, logical_imm64_not:$imm), 0>; } multiclass LogicalImmS opc, string mnemonic, SDNode OpNode, string Alias> { let isCompare = 1, Defs = [NZCV] in { def Wri : BaseLogicalImm { let Inst{31} = 0; let Inst{22} = 0; // 64-bit version has an additional bit of immediate. } def Xri : BaseLogicalImm { let Inst{31} = 1; } } // end Defs = [NZCV] def : InstSubst(NAME # "Wri") GPR32:$Rd, GPR32:$Rn, logical_imm32_not:$imm), 0>; def : InstSubst(NAME # "Xri") GPR64:$Rd, GPR64:$Rn, logical_imm64_not:$imm), 0>; } class BaseLogicalRegPseudo : Pseudo<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), [(set regtype:$Rd, (OpNode regtype:$Rn, regtype:$Rm))]>, Sched<[WriteI, ReadI, ReadI]>; // Split from LogicalImm as not all instructions have both. multiclass LogicalReg opc, bit N, string mnemonic, SDPatternOperator OpNode, int AddedComplexityVal = 0> { let isReMaterializable = 1, isAsCheapAsAMove = 1, AddedComplexity = AddedComplexityVal in { def Wrr : BaseLogicalRegPseudo; def Xrr : BaseLogicalRegPseudo; } def Wrs : BaseLogicalSReg { let Inst{31} = 0; } def Xrs : BaseLogicalSReg { let Inst{31} = 1; } def : LogicalRegAlias(NAME#"Wrs"), GPR32>; def : LogicalRegAlias(NAME#"Xrs"), GPR64>; } // Split from LogicalReg to allow setting NZCV Defs multiclass LogicalRegS opc, bit N, string mnemonic, SDPatternOperator OpNode = null_frag> { let Defs = [NZCV], mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { def Wrr : BaseLogicalRegPseudo; def Xrr : BaseLogicalRegPseudo; def Wrs : BaseLogicalSReg { let Inst{31} = 0; } def Xrs : BaseLogicalSReg { let Inst{31} = 1; } } // Defs = [NZCV] def : LogicalRegAlias(NAME#"Wrs"), GPR32>; def : LogicalRegAlias(NAME#"Xrs"), GPR64>; } //--- // Conditionally set flags //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseCondComparisonImm : I<(outs), (ins regtype:$Rn, immtype:$imm, imm32_0_15:$nzcv, ccode:$cond), mnemonic, "\t$Rn, $imm, $nzcv, $cond", "", [(set NZCV, (OpNode regtype:$Rn, immtype:$imm, (i32 imm:$nzcv), (i32 imm:$cond), NZCV))]>, Sched<[WriteI, ReadI]> { let Uses = [NZCV]; let Defs = [NZCV]; bits<5> Rn; bits<5> imm; bits<4> nzcv; bits<4> cond; let Inst{30} = op; let Inst{29-21} = 0b111010010; let Inst{20-16} = imm; let Inst{15-12} = cond; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4} = 0b0; let Inst{3-0} = nzcv; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseCondComparisonReg : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm32_0_15:$nzcv, ccode:$cond), mnemonic, "\t$Rn, $Rm, $nzcv, $cond", "", [(set NZCV, (OpNode regtype:$Rn, regtype:$Rm, (i32 imm:$nzcv), (i32 imm:$cond), NZCV))]>, Sched<[WriteI, ReadI, ReadI]> { let Uses = [NZCV]; let Defs = [NZCV]; bits<5> Rn; bits<5> Rm; bits<4> nzcv; bits<4> cond; let Inst{30} = op; let Inst{29-21} = 0b111010010; let Inst{20-16} = Rm; let Inst{15-12} = cond; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4} = 0b0; let Inst{3-0} = nzcv; } multiclass CondComparison { // immediate operand variants def Wi : BaseCondComparisonImm { let Inst{31} = 0; } def Xi : BaseCondComparisonImm { let Inst{31} = 1; } // register operand variants def Wr : BaseCondComparisonReg { let Inst{31} = 0; } def Xr : BaseCondComparisonReg { let Inst{31} = 1; } } //--- // Conditional select //--- class BaseCondSelect op2, RegisterClass regtype, string asm> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond), asm, "\t$Rd, $Rn, $Rm, $cond", "", [(set regtype:$Rd, (AArch64csel regtype:$Rn, regtype:$Rm, (i32 imm:$cond), NZCV))]>, Sched<[WriteI, ReadI, ReadI]> { let Uses = [NZCV]; bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<4> cond; let Inst{30} = op; let Inst{29-21} = 0b011010100; let Inst{20-16} = Rm; let Inst{15-12} = cond; let Inst{11-10} = op2; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass CondSelect op2, string asm> { def Wr : BaseCondSelect { let Inst{31} = 0; } def Xr : BaseCondSelect { let Inst{31} = 1; } } class BaseCondSelectOp op2, RegisterClass regtype, string asm, PatFrag frag> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond), asm, "\t$Rd, $Rn, $Rm, $cond", "", [(set regtype:$Rd, (AArch64csel regtype:$Rn, (frag regtype:$Rm), (i32 imm:$cond), NZCV))]>, Sched<[WriteI, ReadI, ReadI]> { let Uses = [NZCV]; bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<4> cond; let Inst{30} = op; let Inst{29-21} = 0b011010100; let Inst{20-16} = Rm; let Inst{15-12} = cond; let Inst{11-10} = op2; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } def inv_cond_XFORM : SDNodeXForm(N->getZExtValue()); return CurDAG->getTargetConstant(AArch64CC::getInvertedCondCode(CC), SDLoc(N), MVT::i32); }]>; multiclass CondSelectOp op2, string asm, PatFrag frag> { def Wr : BaseCondSelectOp { let Inst{31} = 0; } def Xr : BaseCondSelectOp { let Inst{31} = 1; } def : Pat<(AArch64csel (frag GPR32:$Rm), GPR32:$Rn, (i32 imm:$cond), NZCV), (!cast(NAME # Wr) GPR32:$Rn, GPR32:$Rm, (inv_cond_XFORM imm:$cond))>; def : Pat<(AArch64csel (frag GPR64:$Rm), GPR64:$Rn, (i32 imm:$cond), NZCV), (!cast(NAME # Xr) GPR64:$Rn, GPR64:$Rm, (inv_cond_XFORM imm:$cond))>; } //--- // Special Mask Value //--- def maski8_or_more : Operand, ImmLeaf { } def maski16_or_more : Operand, ImmLeaf { } //--- // Load/store //--- // (unsigned immediate) // Indexed for 8-bit registers. offset is in range [0,4095]. def am_indexed8 : ComplexPattern; def am_indexed16 : ComplexPattern; def am_indexed32 : ComplexPattern; def am_indexed64 : ComplexPattern; def am_indexed128 : ComplexPattern; // (unsigned immediate) // Indexed for 8-bit registers. offset is in range [0,63]. def am_indexed8_6b : ComplexPattern", []>; def am_indexed16_6b : ComplexPattern", []>; def am_indexed32_6b : ComplexPattern", []>; def am_indexed64_6b : ComplexPattern", []>; def gi_am_indexed8 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_am_indexed16 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_am_indexed32 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_am_indexed64 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_am_indexed128 : GIComplexOperandMatcher">, GIComplexPatternEquiv; class UImm12OffsetOperand : AsmOperandClass { let Name = "UImm12Offset" # Scale; let RenderMethod = "addUImm12OffsetOperands<" # Scale # ">"; let PredicateMethod = "isUImm12Offset<" # Scale # ">"; let DiagnosticType = "InvalidMemoryIndexed" # Scale; } def UImm12OffsetScale1Operand : UImm12OffsetOperand<1>; def UImm12OffsetScale2Operand : UImm12OffsetOperand<2>; def UImm12OffsetScale4Operand : UImm12OffsetOperand<4>; def UImm12OffsetScale8Operand : UImm12OffsetOperand<8>; def UImm12OffsetScale16Operand : UImm12OffsetOperand<16>; class uimm12_scaled : Operand { let ParserMatchClass = !cast("UImm12OffsetScale" # Scale # "Operand"); let EncoderMethod = "getLdStUImm12OpValue"; let PrintMethod = "printUImm12Offset<" # Scale # ">"; } def uimm12s1 : uimm12_scaled<1>; def uimm12s2 : uimm12_scaled<2>; def uimm12s4 : uimm12_scaled<4>; def uimm12s8 : uimm12_scaled<8>; def uimm12s16 : uimm12_scaled<16>; class BaseLoadStoreUI sz, bit V, bits<2> opc, dag oops, dag iops, string asm, list pattern> : I { bits<5> Rt; bits<5> Rn; bits<12> offset; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b01; let Inst{23-22} = opc; let Inst{21-10} = offset; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodeUnsignedLdStInstruction"; } multiclass LoadUI sz, bit V, bits<2> opc, DAGOperand regtype, Operand indextype, string asm, list pattern> { let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in def ui : BaseLoadStoreUI, Sched<[WriteLD]>; def : InstAlias(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>; } multiclass StoreUI sz, bit V, bits<2> opc, DAGOperand regtype, Operand indextype, string asm, list pattern> { let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in def ui : BaseLoadStoreUI, Sched<[WriteST]>; def : InstAlias(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>; } // Same as StoreUI, but take a RegisterOperand. This is used by GlobalISel to // substitute zero-registers automatically. // // TODO: Roll out zero-register subtitution to GPR32/GPR64 and fold this back // into StoreUI. multiclass StoreUIz sz, bit V, bits<2> opc, RegisterOperand regtype, Operand indextype, string asm, list pattern> { let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in def ui : BaseLoadStoreUI, Sched<[WriteST]>; def : InstAlias(NAME # "ui") regtype:$Rt, GPR64sp:$Rn, 0)>; } def PrefetchOperand : AsmOperandClass { let Name = "Prefetch"; let ParserMethod = "tryParsePrefetch"; } def prfop : Operand { let PrintMethod = "printPrefetchOp"; let ParserMatchClass = PrefetchOperand; } let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in class PrefetchUI sz, bit V, bits<2> opc, string asm, list pat> : BaseLoadStoreUI, Sched<[WriteLD]>; //--- // Load literal //--- // Load literal address: 19-bit immediate. The low two bits of the target // offset are implied zero and so are not part of the immediate. def am_ldrlit : Operand { let EncoderMethod = "getLoadLiteralOpValue"; let DecoderMethod = "DecodePCRelLabel19"; let PrintMethod = "printAlignedLabel"; let ParserMatchClass = PCRelLabel19Operand; let OperandType = "OPERAND_PCREL"; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0, AddedComplexity = 20 in class LoadLiteral opc, bit V, RegisterOperand regtype, string asm, list pat> : I<(outs regtype:$Rt), (ins am_ldrlit:$label), asm, "\t$Rt, $label", "", pat>, Sched<[WriteLD]> { bits<5> Rt; bits<19> label; let Inst{31-30} = opc; let Inst{29-27} = 0b011; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-5} = label; let Inst{4-0} = Rt; } let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in class PrefetchLiteral opc, bit V, string asm, list pat> : I<(outs), (ins prfop:$Rt, am_ldrlit:$label), asm, "\t$Rt, $label", "", pat>, Sched<[WriteLD]> { bits<5> Rt; bits<19> label; let Inst{31-30} = opc; let Inst{29-27} = 0b011; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-5} = label; let Inst{4-0} = Rt; } //--- // Load/store register offset //--- def ro_Xindexed8 : ComplexPattern", []>; def ro_Xindexed16 : ComplexPattern", []>; def ro_Xindexed32 : ComplexPattern", []>; def ro_Xindexed64 : ComplexPattern", []>; def ro_Xindexed128 : ComplexPattern", []>; def gi_ro_Xindexed8 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Xindexed16 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Xindexed32 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Xindexed64 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Xindexed128 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def ro_Windexed8 : ComplexPattern", []>; def ro_Windexed16 : ComplexPattern", []>; def ro_Windexed32 : ComplexPattern", []>; def ro_Windexed64 : ComplexPattern", []>; def ro_Windexed128 : ComplexPattern", []>; def gi_ro_Windexed8 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Windexed16 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Windexed32 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Windexed64 : GIComplexOperandMatcher">, GIComplexPatternEquiv; def gi_ro_Windexed128 : GIComplexOperandMatcher">, GIComplexPatternEquiv; class MemExtendOperand : AsmOperandClass { let Name = "Mem" # Reg # "Extend" # Width; let PredicateMethod = "isMem" # Reg # "Extend<" # Width # ">"; let RenderMethod = "addMemExtendOperands"; let DiagnosticType = "InvalidMemory" # Reg # "Extend" # Width; } def MemWExtend8Operand : MemExtendOperand<"W", 8> { // The address "[x0, x1, lsl #0]" actually maps to the variant which performs // the trivial shift. let RenderMethod = "addMemExtend8Operands"; } def MemWExtend16Operand : MemExtendOperand<"W", 16>; def MemWExtend32Operand : MemExtendOperand<"W", 32>; def MemWExtend64Operand : MemExtendOperand<"W", 64>; def MemWExtend128Operand : MemExtendOperand<"W", 128>; def MemXExtend8Operand : MemExtendOperand<"X", 8> { // The address "[x0, x1, lsl #0]" actually maps to the variant which performs // the trivial shift. let RenderMethod = "addMemExtend8Operands"; } def MemXExtend16Operand : MemExtendOperand<"X", 16>; def MemXExtend32Operand : MemExtendOperand<"X", 32>; def MemXExtend64Operand : MemExtendOperand<"X", 64>; def MemXExtend128Operand : MemExtendOperand<"X", 128>; class ro_extend : Operand { let ParserMatchClass = ParserClass; let PrintMethod = "printMemExtend<'" # Reg # "', " # Width # ">"; let DecoderMethod = "DecodeMemExtend"; let EncoderMethod = "getMemExtendOpValue"; let MIOperandInfo = (ops i32imm:$signed, i32imm:$doshift); } def ro_Wextend8 : ro_extend; def ro_Wextend16 : ro_extend; def ro_Wextend32 : ro_extend; def ro_Wextend64 : ro_extend; def ro_Wextend128 : ro_extend; def ro_Xextend8 : ro_extend; def ro_Xextend16 : ro_extend; def ro_Xextend32 : ro_extend; def ro_Xextend64 : ro_extend; def ro_Xextend128 : ro_extend; class ROAddrMode { // CodeGen-level pattern covering the entire addressing mode. ComplexPattern Wpat = windex; ComplexPattern Xpat = xindex; // Asm-level Operand covering the valid "uxtw #3" style syntax. Operand Wext = wextend; Operand Xext = xextend; } def ro8 : ROAddrMode; def ro16 : ROAddrMode; def ro32 : ROAddrMode; def ro64 : ROAddrMode; def ro128 : ROAddrMode; class LoadStore8RO sz, bit V, bits<2> opc, string asm, dag ins, dag outs, list pat> : I { bits<5> Rt; bits<5> Rn; bits<5> Rm; bits<2> extend; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15} = extend{1}; // sign extend Rm? let Inst{14} = 1; let Inst{12} = extend{0}; // do shift? let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } class ROInstAlias : InstAlias; multiclass Load8RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator loadop> { let AddedComplexity = 10 in def roW : LoadStore8RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10 in def roX : LoadStore8RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } multiclass Store8RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator storeop> { let AddedComplexity = 10 in def roW : LoadStore8RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10 in def roX : LoadStore8RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } class LoadStore16RO sz, bit V, bits<2> opc, string asm, dag ins, dag outs, list pat> : I { bits<5> Rt; bits<5> Rn; bits<5> Rm; bits<2> extend; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15} = extend{1}; // sign extend Rm? let Inst{14} = 1; let Inst{12} = extend{0}; // do shift? let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } multiclass Load16RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator loadop> { let AddedComplexity = 10 in def roW : LoadStore16RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10 in def roX : LoadStore16RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } multiclass Store16RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator storeop> { let AddedComplexity = 10 in def roW : LoadStore16RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10 in def roX : LoadStore16RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } class LoadStore32RO sz, bit V, bits<2> opc, string asm, dag ins, dag outs, list pat> : I { bits<5> Rt; bits<5> Rn; bits<5> Rm; bits<2> extend; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15} = extend{1}; // sign extend Rm? let Inst{14} = 1; let Inst{12} = extend{0}; // do shift? let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } multiclass Load32RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator loadop> { let AddedComplexity = 10 in def roW : LoadStore32RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10 in def roX : LoadStore32RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } multiclass Store32RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator storeop> { let AddedComplexity = 10 in def roW : LoadStore32RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10 in def roX : LoadStore32RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } class LoadStore64RO sz, bit V, bits<2> opc, string asm, dag ins, dag outs, list pat> : I { bits<5> Rt; bits<5> Rn; bits<5> Rm; bits<2> extend; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15} = extend{1}; // sign extend Rm? let Inst{14} = 1; let Inst{12} = extend{0}; // do shift? let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } multiclass Load64RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator loadop> { let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in def roW : LoadStore64RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in def roX : LoadStore64RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } multiclass Store64RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator storeop> { let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in def roW : LoadStore64RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10, mayLoad = 0, mayStore = 1, hasSideEffects = 0 in def roX : LoadStore64RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } class LoadStore128RO sz, bit V, bits<2> opc, string asm, dag ins, dag outs, list pat> : I { bits<5> Rt; bits<5> Rn; bits<5> Rm; bits<2> extend; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15} = extend{1}; // sign extend Rm? let Inst{14} = 1; let Inst{12} = extend{0}; // do shift? let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } multiclass Load128RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm, ValueType Ty, SDPatternOperator loadop> { let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in def roW : LoadStore128RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b0; } let AddedComplexity = 10, mayLoad = 1, mayStore = 0, hasSideEffects = 0 in def roX : LoadStore128RO, Sched<[WriteLDIdx, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } multiclass Store128RO sz, bit V, bits<2> opc, DAGOperand regtype, string asm> { let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in def roW : LoadStore128RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b0; } let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in def roX : LoadStore128RO, Sched<[WriteSTIdx, ReadST, ReadAdrBase]> { let Inst{13} = 0b1; } def : ROInstAlias(NAME # "roX")>; } let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in class BasePrefetchRO sz, bit V, bits<2> opc, dag outs, dag ins, string asm, list pat> : I, Sched<[WriteLD]> { bits<5> Rt; bits<5> Rn; bits<5> Rm; bits<2> extend; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15} = extend{1}; // sign extend Rm? let Inst{14} = 1; let Inst{12} = extend{0}; // do shift? let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodePRFMRegInstruction"; // PRFM (reg) aliases with RPRFM added to the base A64 instruction set. When // the decoder method returns Fail, the decoder should attempt to decode the // instruction as RPRFM. let hasCompleteDecoder = 0; } multiclass PrefetchRO sz, bit V, bits<2> opc, string asm> { def roW : BasePrefetchRO { let Inst{13} = 0b0; } def roX : BasePrefetchRO { let Inst{13} = 0b1; } def : InstAlias<"prfm $Rt, [$Rn, $Rm]", (!cast(NAME # "roX") prfop:$Rt, GPR64sp:$Rn, GPR64:$Rm, 0, 0)>; } //--- // Load/store unscaled immediate //--- def am_unscaled8 : ComplexPattern; def am_unscaled16 : ComplexPattern; def am_unscaled32 : ComplexPattern; def am_unscaled64 : ComplexPattern; def am_unscaled128 :ComplexPattern; def gi_am_unscaled8 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_am_unscaled16 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_am_unscaled32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_am_unscaled64 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_am_unscaled128 : GIComplexOperandMatcher, GIComplexPatternEquiv; class BaseLoadStoreUnscale sz, bit V, bits<2> opc, dag oops, dag iops, string asm, list pattern> : I { bits<5> Rt; bits<5> Rn; bits<9> offset; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 0; let Inst{20-12} = offset; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodeSignedLdStInstruction"; } // Armv8.4 LDAPR & STLR with Immediate Offset instruction multiclass BaseLoadUnscaleV84 sz, bits<2> opc, DAGOperand regtype > { def i : BaseLoadStoreUnscale, Sched<[WriteST]> { let Inst{29} = 0; let Inst{24} = 1; } def : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } multiclass BaseStoreUnscaleV84 sz, bits<2> opc, DAGOperand regtype > { def i : BaseLoadStoreUnscale, Sched<[WriteST]> { let Inst{29} = 0; let Inst{24} = 1; } def : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } multiclass LoadUnscaled sz, bit V, bits<2> opc, DAGOperand regtype, string asm, list pattern> { let AddedComplexity = 1 in // try this before LoadUI def i : BaseLoadStoreUnscale, Sched<[WriteLD]>; def : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } multiclass StoreUnscaled sz, bit V, bits<2> opc, DAGOperand regtype, string asm, list pattern> { let AddedComplexity = 1 in // try this before StoreUI def i : BaseLoadStoreUnscale, Sched<[WriteST]>; def : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } multiclass PrefetchUnscaled sz, bit V, bits<2> opc, string asm, list pat> { let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in def i : BaseLoadStoreUnscale, Sched<[WriteLD]>; def : InstAlias(NAME # "i") prfop:$Rt, GPR64sp:$Rn, 0)>; } //--- // Load/store unscaled immediate, unprivileged //--- class BaseLoadStoreUnprivileged sz, bit V, bits<2> opc, dag oops, dag iops, string asm> : I { bits<5> Rt; bits<5> Rn; bits<9> offset; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 0; let Inst{20-12} = offset; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodeSignedLdStInstruction"; } multiclass LoadUnprivileged sz, bit V, bits<2> opc, RegisterClass regtype, string asm> { let mayStore = 0, mayLoad = 1, hasSideEffects = 0 in def i : BaseLoadStoreUnprivileged, Sched<[WriteLD]>; def : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } multiclass StoreUnprivileged sz, bit V, bits<2> opc, RegisterClass regtype, string asm> { let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in def i : BaseLoadStoreUnprivileged, Sched<[WriteST]>; def : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } //--- // Load/store pre-indexed //--- class BaseLoadStorePreIdx sz, bit V, bits<2> opc, dag oops, dag iops, string asm, string cstr, list pat> : I { bits<5> Rt; bits<5> Rn; bits<9> offset; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0; let Inst{23-22} = opc; let Inst{21} = 0; let Inst{20-12} = offset; let Inst{11-10} = 0b11; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodeSignedLdStInstruction"; } let hasSideEffects = 0 in { let mayStore = 0, mayLoad = 1 in class LoadPreIdx sz, bit V, bits<2> opc, RegisterOperand regtype, string asm> : BaseLoadStorePreIdx, Sched<[WriteAdr, WriteLD]>; let mayStore = 1, mayLoad = 0 in class StorePreIdx sz, bit V, bits<2> opc, RegisterOperand regtype, string asm, SDPatternOperator storeop, ValueType Ty> : BaseLoadStorePreIdx, Sched<[WriteAdr, WriteST]>; } // hasSideEffects = 0 //--- // Load/store post-indexed //--- class BaseLoadStorePostIdx sz, bit V, bits<2> opc, dag oops, dag iops, string asm, string cstr, list pat> : I { bits<5> Rt; bits<5> Rn; bits<9> offset; let Inst{31-30} = sz; let Inst{29-27} = 0b111; let Inst{26} = V; let Inst{25-24} = 0b00; let Inst{23-22} = opc; let Inst{21} = 0b0; let Inst{20-12} = offset; let Inst{11-10} = 0b01; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodeSignedLdStInstruction"; } let hasSideEffects = 0 in { let mayStore = 0, mayLoad = 1 in class LoadPostIdx sz, bit V, bits<2> opc, RegisterOperand regtype, string asm> : BaseLoadStorePostIdx, Sched<[WriteAdr, WriteLD]>; let mayStore = 1, mayLoad = 0 in class StorePostIdx sz, bit V, bits<2> opc, RegisterOperand regtype, string asm, SDPatternOperator storeop, ValueType Ty> : BaseLoadStorePostIdx, Sched<[WriteAdr, WriteST]>; } // hasSideEffects = 0 //--- // Load/store pair //--- // (indexed, offset) class BaseLoadStorePairOffset opc, bit V, bit L, dag oops, dag iops, string asm> : I { bits<5> Rt; bits<5> Rt2; bits<5> Rn; bits<7> offset; let Inst{31-30} = opc; let Inst{29-27} = 0b101; let Inst{26} = V; let Inst{25-23} = 0b010; let Inst{22} = L; let Inst{21-15} = offset; let Inst{14-10} = Rt2; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodePairLdStInstruction"; } multiclass LoadPairOffset opc, bit V, RegisterOperand regtype, Operand indextype, string asm> { let hasSideEffects = 0, mayStore = 0, mayLoad = 1 in def i : BaseLoadStorePairOffset, Sched<[WriteLD, WriteLDHi]>; def : InstAlias(NAME # "i") regtype:$Rt, regtype:$Rt2, GPR64sp:$Rn, 0)>; } multiclass StorePairOffset opc, bit V, RegisterOperand regtype, Operand indextype, string asm> { let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in def i : BaseLoadStorePairOffset, Sched<[WriteSTP]>; def : InstAlias(NAME # "i") regtype:$Rt, regtype:$Rt2, GPR64sp:$Rn, 0)>; } // (pre-indexed) class BaseLoadStorePairPreIdx opc, bit V, bit L, dag oops, dag iops, string asm> : I { bits<5> Rt; bits<5> Rt2; bits<5> Rn; bits<7> offset; let Inst{31-30} = opc; let Inst{29-27} = 0b101; let Inst{26} = V; let Inst{25-23} = 0b011; let Inst{22} = L; let Inst{21-15} = offset; let Inst{14-10} = Rt2; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodePairLdStInstruction"; } let hasSideEffects = 0 in { let mayStore = 0, mayLoad = 1 in class LoadPairPreIdx opc, bit V, RegisterOperand regtype, Operand indextype, string asm> : BaseLoadStorePairPreIdx, Sched<[WriteAdr, WriteLD, WriteLDHi]>; let mayStore = 1, mayLoad = 0 in class StorePairPreIdx opc, bit V, RegisterOperand regtype, Operand indextype, string asm> : BaseLoadStorePairPreIdx, Sched<[WriteAdr, WriteSTP]>; } // hasSideEffects = 0 // (post-indexed) class BaseLoadStorePairPostIdx opc, bit V, bit L, dag oops, dag iops, string asm> : I { bits<5> Rt; bits<5> Rt2; bits<5> Rn; bits<7> offset; let Inst{31-30} = opc; let Inst{29-27} = 0b101; let Inst{26} = V; let Inst{25-23} = 0b001; let Inst{22} = L; let Inst{21-15} = offset; let Inst{14-10} = Rt2; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodePairLdStInstruction"; } let hasSideEffects = 0 in { let mayStore = 0, mayLoad = 1 in class LoadPairPostIdx opc, bit V, RegisterOperand regtype, Operand idxtype, string asm> : BaseLoadStorePairPostIdx, Sched<[WriteAdr, WriteLD, WriteLDHi]>; let mayStore = 1, mayLoad = 0 in class StorePairPostIdx opc, bit V, RegisterOperand regtype, Operand idxtype, string asm> : BaseLoadStorePairPostIdx, Sched<[WriteAdr, WriteSTP]>; } // hasSideEffects = 0 // (no-allocate) class BaseLoadStorePairNoAlloc opc, bit V, bit L, dag oops, dag iops, string asm> : I { bits<5> Rt; bits<5> Rt2; bits<5> Rn; bits<7> offset; let Inst{31-30} = opc; let Inst{29-27} = 0b101; let Inst{26} = V; let Inst{25-23} = 0b000; let Inst{22} = L; let Inst{21-15} = offset; let Inst{14-10} = Rt2; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let DecoderMethod = "DecodePairLdStInstruction"; } multiclass LoadPairNoAlloc opc, bit V, DAGOperand regtype, Operand indextype, string asm> { let hasSideEffects = 0, mayStore = 0, mayLoad = 1 in def i : BaseLoadStorePairNoAlloc, Sched<[WriteLD, WriteLDHi]>; def : InstAlias(NAME # "i") regtype:$Rt, regtype:$Rt2, GPR64sp:$Rn, 0)>; } multiclass StorePairNoAlloc opc, bit V, DAGOperand regtype, Operand indextype, string asm> { let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in def i : BaseLoadStorePairNoAlloc, Sched<[WriteSTP]>; def : InstAlias(NAME # "i") regtype:$Rt, regtype:$Rt2, GPR64sp:$Rn, 0)>; } //--- // Load/store exclusive //--- // True exclusive operations write to and/or read from the system's exclusive // monitors, which as far as a compiler is concerned can be modelled as a // random shared memory address. Hence LoadExclusive mayStore. // // Since these instructions have the undefined register bits set to 1 in // their canonical form, we need a post encoder method to set those bits // to 1 when encoding these instructions. We do this using the // fixLoadStoreExclusive function. This function has template parameters: // // fixLoadStoreExclusive // // hasRs indicates that the instruction uses the Rs field, so we won't set // it to 1 (and the same for Rt2). We don't need template parameters for // the other register fields since Rt and Rn are always used. // let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in class BaseLoadStoreExclusive sz, bit o2, bit L, bit o1, bit o0, dag oops, dag iops, string asm, string operands> : I { let Inst{31-30} = sz; let Inst{29-24} = 0b001000; let Inst{23} = o2; let Inst{22} = L; let Inst{21} = o1; let Inst{15} = o0; let DecoderMethod = "DecodeExclusiveLdStInstruction"; } // Neither Rs nor Rt2 operands. class LoadStoreExclusiveSimple sz, bit o2, bit L, bit o1, bit o0, dag oops, dag iops, string asm, string operands> : BaseLoadStoreExclusive { bits<5> Rt; bits<5> Rn; let Inst{20-16} = 0b11111; let Unpredictable{20-16} = 0b11111; let Inst{14-10} = 0b11111; let Unpredictable{14-10} = 0b11111; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let PostEncoderMethod = "fixLoadStoreExclusive<0,0>"; } // Simple load acquires don't set the exclusive monitor let mayLoad = 1, mayStore = 0 in class LoadAcquire sz, bit o2, bit L, bit o1, bit o0, RegisterClass regtype, string asm> : LoadStoreExclusiveSimple, Sched<[WriteLD]>; class LoadExclusive sz, bit o2, bit L, bit o1, bit o0, RegisterClass regtype, string asm> : LoadStoreExclusiveSimple, Sched<[WriteLD]>; class LoadExclusivePair sz, bit o2, bit L, bit o1, bit o0, RegisterClass regtype, string asm> : BaseLoadStoreExclusive, Sched<[WriteLD, WriteLDHi]> { bits<5> Rt; bits<5> Rt2; bits<5> Rn; let Inst{14-10} = Rt2; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let PostEncoderMethod = "fixLoadStoreExclusive<0,1>"; } // Simple store release operations do not check the exclusive monitor. let mayLoad = 0, mayStore = 1 in class StoreRelease sz, bit o2, bit L, bit o1, bit o0, RegisterClass regtype, string asm> : LoadStoreExclusiveSimple, Sched<[WriteST]>; let mayLoad = 1, mayStore = 1 in class StoreExclusive sz, bit o2, bit L, bit o1, bit o0, RegisterClass regtype, string asm> : BaseLoadStoreExclusive, Sched<[WriteSTX]> { bits<5> Ws; bits<5> Rt; bits<5> Rn; let Inst{20-16} = Ws; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let Constraints = "@earlyclobber $Ws"; let PostEncoderMethod = "fixLoadStoreExclusive<1,0>"; } class StoreExclusivePair sz, bit o2, bit L, bit o1, bit o0, RegisterClass regtype, string asm> : BaseLoadStoreExclusive, Sched<[WriteSTX]> { bits<5> Ws; bits<5> Rt; bits<5> Rt2; bits<5> Rn; let Inst{20-16} = Ws; let Inst{14-10} = Rt2; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let Constraints = "@earlyclobber $Ws"; } // Armv8.5-A Memory Tagging Extension class BaseMemTag opc1, bits<2> opc2, string asm_insn, string asm_opnds, string cstr, dag oops, dag iops> : I, Sched<[]> { bits<5> Rn; let Inst{31-24} = 0b11011001; let Inst{23-22} = opc1; let Inst{21} = 1; // Inst{20-12} defined by subclass let Inst{11-10} = opc2; let Inst{9-5} = Rn; // Inst{4-0} defined by subclass } class MemTagVector : BaseMemTag<{0b1, Load}, 0b00, asm_insn, asm_opnds, "", oops, iops> { bits<5> Rt; let Inst{20-12} = 0b000000000; let Inst{4-0} = Rt; let mayLoad = Load; } class MemTagLoad : BaseMemTag<0b01, 0b00, asm_insn, asm_opnds, "$Rt = $wback", (outs GPR64:$wback), (ins GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)> { bits<5> Rt; bits<9> offset; let Inst{20-12} = offset; let Inst{4-0} = Rt; let mayLoad = 1; } class BaseMemTagStore opc1, bits<2> opc2, string asm_insn, string asm_opnds, string cstr, dag oops, dag iops> : BaseMemTag { bits<5> Rt; bits<9> offset; let Inst{20-12} = offset; let Inst{4-0} = Rt; let mayStore = 1; } multiclass MemTagStore opc1, string insn> { def i : BaseMemTagStore; def PreIndex : BaseMemTagStore; def PostIndex : BaseMemTagStore; def : InstAlias(NAME # "i") GPR64sp:$Rt, GPR64sp:$Rn, 0)>; } //--- // Exception generation //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in class ExceptionGeneration op1, bits<2> ll, string asm, list pattern = []> : I<(outs), (ins timm32_0_65535:$imm), asm, "\t$imm", "", pattern>, Sched<[WriteSys]> { bits<16> imm; let Inst{31-24} = 0b11010100; let Inst{23-21} = op1; let Inst{20-5} = imm; let Inst{4-2} = 0b000; let Inst{1-0} = ll; } //--- // UDF : Permanently UNDEFINED instructions. Format: Opc = 0x0000, 16 bit imm. //-- let hasSideEffects = 1, isTrap = 1, mayLoad = 0, mayStore = 0 in { class UDFType opc, string asm> : I<(outs), (ins uimm16:$imm), asm, "\t$imm", "", []>, Sched<[]> { bits<16> imm; let Inst{31-16} = opc; let Inst{15-0} = imm; } } let Predicates = [HasFPARMv8] in { //--- // Floating point to integer conversion //--- let mayRaiseFPException = 1, Uses = [FPCR] in class BaseFPToIntegerUnscaled type, bits<2> rmode, bits<3> opcode, RegisterClass srcType, RegisterClass dstType, string asm, list pattern> : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", pattern>, Sched<[WriteFCvt]> { bits<5> Rd; bits<5> Rn; let Inst{30-29} = 0b00; let Inst{28-24} = 0b11110; let Inst{23-22} = type; let Inst{21} = 1; let Inst{20-19} = rmode; let Inst{18-16} = opcode; let Inst{15-10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseFPToInteger type, bits<2> rmode, bits<3> opcode, RegisterClass srcType, RegisterClass dstType, Operand immType, string asm, list pattern> : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale), asm, "\t$Rd, $Rn, $scale", "", pattern>, Sched<[WriteFCvt]> { bits<5> Rd; bits<5> Rn; bits<6> scale; let Inst{30-29} = 0b00; let Inst{28-24} = 0b11110; let Inst{23-22} = type; let Inst{21} = 0; let Inst{20-19} = rmode; let Inst{18-16} = opcode; let Inst{15-10} = scale; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass FPToIntegerUnscaled rmode, bits<3> opcode, string asm, SDPatternOperator OpN> { // Unscaled half-precision to 32-bit def UWHr : BaseFPToIntegerUnscaled<0b11, rmode, opcode, FPR16, GPR32, asm, [(set GPR32:$Rd, (OpN (f16 FPR16:$Rn)))]> { let Inst{31} = 0; // 32-bit GPR flag let Predicates = [HasFullFP16]; } // Unscaled half-precision to 64-bit def UXHr : BaseFPToIntegerUnscaled<0b11, rmode, opcode, FPR16, GPR64, asm, [(set GPR64:$Rd, (OpN (f16 FPR16:$Rn)))]> { let Inst{31} = 1; // 64-bit GPR flag let Predicates = [HasFullFP16]; } // Unscaled single-precision to 32-bit def UWSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR32, asm, [(set GPR32:$Rd, (OpN FPR32:$Rn))]> { let Inst{31} = 0; // 32-bit GPR flag } // Unscaled single-precision to 64-bit def UXSr : BaseFPToIntegerUnscaled<0b00, rmode, opcode, FPR32, GPR64, asm, [(set GPR64:$Rd, (OpN FPR32:$Rn))]> { let Inst{31} = 1; // 64-bit GPR flag } // Unscaled double-precision to 32-bit def UWDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR32, asm, [(set GPR32:$Rd, (OpN (f64 FPR64:$Rn)))]> { let Inst{31} = 0; // 32-bit GPR flag } // Unscaled double-precision to 64-bit def UXDr : BaseFPToIntegerUnscaled<0b01, rmode, opcode, FPR64, GPR64, asm, [(set GPR64:$Rd, (OpN (f64 FPR64:$Rn)))]> { let Inst{31} = 1; // 64-bit GPR flag } } multiclass FPToIntegerScaled rmode, bits<3> opcode, string asm, SDPatternOperator OpN> { // Scaled half-precision to 32-bit def SWHri : BaseFPToInteger<0b11, rmode, opcode, FPR16, GPR32, fixedpoint_f16_i32, asm, [(set GPR32:$Rd, (OpN (fmul (f16 FPR16:$Rn), fixedpoint_f16_i32:$scale)))]> { let Inst{31} = 0; // 32-bit GPR flag let scale{5} = 1; let Predicates = [HasFullFP16]; } // Scaled half-precision to 64-bit def SXHri : BaseFPToInteger<0b11, rmode, opcode, FPR16, GPR64, fixedpoint_f16_i64, asm, [(set GPR64:$Rd, (OpN (fmul (f16 FPR16:$Rn), fixedpoint_f16_i64:$scale)))]> { let Inst{31} = 1; // 64-bit GPR flag let Predicates = [HasFullFP16]; } // Scaled single-precision to 32-bit def SWSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR32, fixedpoint_f32_i32, asm, [(set GPR32:$Rd, (OpN (fmul FPR32:$Rn, fixedpoint_f32_i32:$scale)))]> { let Inst{31} = 0; // 32-bit GPR flag let scale{5} = 1; } // Scaled single-precision to 64-bit def SXSri : BaseFPToInteger<0b00, rmode, opcode, FPR32, GPR64, fixedpoint_f32_i64, asm, [(set GPR64:$Rd, (OpN (fmul FPR32:$Rn, fixedpoint_f32_i64:$scale)))]> { let Inst{31} = 1; // 64-bit GPR flag } // Scaled double-precision to 32-bit def SWDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR32, fixedpoint_f64_i32, asm, [(set GPR32:$Rd, (OpN (fmul FPR64:$Rn, fixedpoint_f64_i32:$scale)))]> { let Inst{31} = 0; // 32-bit GPR flag let scale{5} = 1; } // Scaled double-precision to 64-bit def SXDri : BaseFPToInteger<0b01, rmode, opcode, FPR64, GPR64, fixedpoint_f64_i64, asm, [(set GPR64:$Rd, (OpN (fmul FPR64:$Rn, fixedpoint_f64_i64:$scale)))]> { let Inst{31} = 1; // 64-bit GPR flag } } //--- // Integer to floating point conversion //--- let mayStore = 0, mayLoad = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseIntegerToFP pattern> : I<(outs dstType:$Rd), (ins srcType:$Rn, immType:$scale), asm, "\t$Rd, $Rn, $scale", "", pattern>, Sched<[WriteFCvt]> { bits<5> Rd; bits<5> Rn; bits<6> scale; let Inst{30-24} = 0b0011110; let Inst{21-17} = 0b00001; let Inst{16} = isUnsigned; let Inst{15-10} = scale; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayRaiseFPException = 1, Uses = [FPCR] in class BaseIntegerToFPUnscaled : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", [(set (dvt dstType:$Rd), (node srcType:$Rn))]>, Sched<[WriteFCvt]> { bits<5> Rd; bits<5> Rn; bits<6> scale; let Inst{30-24} = 0b0011110; let Inst{21-17} = 0b10001; let Inst{16} = isUnsigned; let Inst{15-10} = 0b000000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass IntegerToFP { // Unscaled def UWHri: BaseIntegerToFPUnscaled { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def UWSri: BaseIntegerToFPUnscaled { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b00; // 32-bit FPR flag } def UWDri: BaseIntegerToFPUnscaled { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b01; // 64-bit FPR flag } def UXHri: BaseIntegerToFPUnscaled { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def UXSri: BaseIntegerToFPUnscaled { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b00; // 32-bit FPR flag } def UXDri: BaseIntegerToFPUnscaled { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b01; // 64-bit FPR flag } // Scaled def SWHri: BaseIntegerToFP { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let scale{5} = 1; let Predicates = [HasFullFP16]; } def SWSri: BaseIntegerToFP { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b00; // 32-bit FPR flag let scale{5} = 1; } def SWDri: BaseIntegerToFP { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b01; // 64-bit FPR flag let scale{5} = 1; } def SXHri: BaseIntegerToFP { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def SXSri: BaseIntegerToFP { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b00; // 32-bit FPR flag } def SXDri: BaseIntegerToFP { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b01; // 64-bit FPR flag } } //--- // Unscaled integer <-> floating point conversion (i.e. FMOV) //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseUnscaledConversion rmode, bits<3> opcode, RegisterClass srcType, RegisterClass dstType, string asm> : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", // We use COPY_TO_REGCLASS for these bitconvert operations. // copyPhysReg() expands the resultant COPY instructions after // regalloc is done. This gives greater freedom for the allocator // and related passes (coalescing, copy propagation, et. al.) to // be more effective. [/*(set (dvt dstType:$Rd), (bitconvert (svt srcType:$Rn)))*/]>, Sched<[WriteFCopy]> { bits<5> Rd; bits<5> Rn; let Inst{30-24} = 0b0011110; let Inst{21} = 1; let Inst{20-19} = rmode; let Inst{18-16} = opcode; let Inst{15-10} = 0b000000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseUnscaledConversionToHigh rmode, bits<3> opcode, RegisterClass srcType, RegisterOperand dstType, string asm, string kind> : I<(outs dstType:$Rd), (ins srcType:$Rn, VectorIndex1:$idx), asm, "{\t$Rd"#kind#"$idx, $Rn|"#kind#"\t$Rd$idx, $Rn}", "", []>, Sched<[WriteFCopy]> { bits<5> Rd; bits<5> Rn; let Inst{30-23} = 0b00111101; let Inst{21} = 1; let Inst{20-19} = rmode; let Inst{18-16} = opcode; let Inst{15-10} = 0b000000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeFMOVLaneInstruction"; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseUnscaledConversionFromHigh rmode, bits<3> opcode, RegisterOperand srcType, RegisterClass dstType, string asm, string kind> : I<(outs dstType:$Rd), (ins srcType:$Rn, VectorIndex1:$idx), asm, "{\t$Rd, $Rn"#kind#"$idx|"#kind#"\t$Rd, $Rn$idx}", "", []>, Sched<[WriteFCopy]> { bits<5> Rd; bits<5> Rn; let Inst{30-23} = 0b00111101; let Inst{21} = 1; let Inst{20-19} = rmode; let Inst{18-16} = opcode; let Inst{15-10} = 0b000000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeFMOVLaneInstruction"; } multiclass UnscaledConversion { def WHr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR16, asm> { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def XHr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR16, asm> { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def WSr : BaseUnscaledConversion<0b00, 0b111, GPR32, FPR32, asm> { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b00; // 32-bit FPR flag } def XDr : BaseUnscaledConversion<0b00, 0b111, GPR64, FPR64, asm> { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b01; // 64-bit FPR flag } def HWr : BaseUnscaledConversion<0b00, 0b110, FPR16, GPR32, asm> { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def HXr : BaseUnscaledConversion<0b00, 0b110, FPR16, GPR64, asm> { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b11; // 16-bit FPR flag let Predicates = [HasFullFP16]; } def SWr : BaseUnscaledConversion<0b00, 0b110, FPR32, GPR32, asm> { let Inst{31} = 0; // 32-bit GPR flag let Inst{23-22} = 0b00; // 32-bit FPR flag } def DXr : BaseUnscaledConversion<0b00, 0b110, FPR64, GPR64, asm> { let Inst{31} = 1; // 64-bit GPR flag let Inst{23-22} = 0b01; // 64-bit FPR flag } def XDHighr : BaseUnscaledConversionToHigh<0b01, 0b111, GPR64, V128, asm, ".d"> { let Inst{31} = 1; let Inst{22} = 0; } def DXHighr : BaseUnscaledConversionFromHigh<0b01, 0b110, V128, GPR64, asm, ".d"> { let Inst{31} = 1; let Inst{22} = 0; } } //--- // Floating point conversion //--- let mayRaiseFPException = 1, Uses = [FPCR] in class BaseFPConversion type, bits<2> opcode, RegisterClass dstType, RegisterClass srcType, string asm, list pattern> : I<(outs dstType:$Rd), (ins srcType:$Rn), asm, "\t$Rd, $Rn", "", pattern>, Sched<[WriteFCvt]> { bits<5> Rd; bits<5> Rn; let Inst{31-24} = 0b00011110; let Inst{23-22} = type; let Inst{21-17} = 0b10001; let Inst{16-15} = opcode; let Inst{14-10} = 0b10000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass FPConversion { // Double-precision to Half-precision def HDr : BaseFPConversion<0b01, 0b11, FPR16, FPR64, asm, [(set (f16 FPR16:$Rd), (any_fpround FPR64:$Rn))]>; // Double-precision to Single-precision def SDr : BaseFPConversion<0b01, 0b00, FPR32, FPR64, asm, [(set FPR32:$Rd, (any_fpround FPR64:$Rn))]>; // Half-precision to Double-precision def DHr : BaseFPConversion<0b11, 0b01, FPR64, FPR16, asm, [(set FPR64:$Rd, (any_fpextend (f16 FPR16:$Rn)))]>; // Half-precision to Single-precision def SHr : BaseFPConversion<0b11, 0b00, FPR32, FPR16, asm, [(set FPR32:$Rd, (any_fpextend (f16 FPR16:$Rn)))]>; // Single-precision to Double-precision def DSr : BaseFPConversion<0b00, 0b01, FPR64, FPR32, asm, [(set FPR64:$Rd, (any_fpextend FPR32:$Rn))]>; // Single-precision to Half-precision def HSr : BaseFPConversion<0b00, 0b11, FPR16, FPR32, asm, [(set (f16 FPR16:$Rd), (any_fpround FPR32:$Rn))]>; } //--- // Single operand floating point data processing //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSingleOperandFPData opcode, RegisterClass regtype, ValueType vt, string asm, SDPatternOperator node> : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn", "", [(set (vt regtype:$Rd), (node (vt regtype:$Rn)))]>, Sched<[WriteF]> { bits<5> Rd; bits<5> Rn; let Inst{31-24} = 0b00011110; let Inst{21} = 0b1; let Inst{20-15} = opcode; let Inst{14-10} = 0b10000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SingleOperandFPData opcode, string asm, SDPatternOperator node = null_frag, int fpexceptions = 1> { let mayRaiseFPException = fpexceptions, Uses = !if(fpexceptions,[FPCR],[]) in { def Hr : BaseSingleOperandFPData<{0b00,opcode}, FPR16, f16, asm, node> { let Inst{23-22} = 0b11; // 16-bit size flag let Predicates = [HasFullFP16]; } def Sr : BaseSingleOperandFPData<{0b00,opcode}, FPR32, f32, asm, node> { let Inst{23-22} = 0b00; // 32-bit size flag } def Dr : BaseSingleOperandFPData<{0b00,opcode}, FPR64, f64, asm, node> { let Inst{23-22} = 0b01; // 64-bit size flag } } } multiclass SingleOperandFPDataNoException opcode, string asm, SDPatternOperator node = null_frag> : SingleOperandFPData; let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SingleOperandFPNo16 opcode, string asm, SDPatternOperator node = null_frag>{ def Sr : BaseSingleOperandFPData { let Inst{23-22} = 0b00; // 32-bit registers } def Dr : BaseSingleOperandFPData { let Inst{23-22} = 0b01; // 64-bit registers } } // FRInt[32|64][Z|N] instructions multiclass FRIntNNT opcode, string asm, SDPatternOperator node = null_frag> : SingleOperandFPNo16<{0b0100,opcode}, asm, node>; //--- // Two operand floating point data processing //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseTwoOperandFPData opcode, RegisterClass regtype, string asm, list pat> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rd, $Rn, $Rm", "", pat>, Sched<[WriteF]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-24} = 0b00011110; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass TwoOperandFPData opcode, string asm, SDPatternOperator node = null_frag> { def Hrr : BaseTwoOperandFPData { let Inst{23-22} = 0b11; // 16-bit size flag let Predicates = [HasFullFP16]; } def Srr : BaseTwoOperandFPData { let Inst{23-22} = 0b00; // 32-bit size flag } def Drr : BaseTwoOperandFPData { let Inst{23-22} = 0b01; // 64-bit size flag } } multiclass TwoOperandFPDataNeg opcode, string asm, SDPatternOperator node> { def Hrr : BaseTwoOperandFPData { let Inst{23-22} = 0b11; // 16-bit size flag let Predicates = [HasFullFP16]; } def Srr : BaseTwoOperandFPData { let Inst{23-22} = 0b00; // 32-bit size flag } def Drr : BaseTwoOperandFPData { let Inst{23-22} = 0b01; // 64-bit size flag } } //--- // Three operand floating point data processing //--- let mayRaiseFPException = 1, Uses = [FPCR] in class BaseThreeOperandFPData pat> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, regtype: $Ra), asm, "\t$Rd, $Rn, $Rm, $Ra", "", pat>, Sched<[WriteFMul]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<5> Ra; let Inst{31-24} = 0b00011111; let Inst{21} = isNegated; let Inst{20-16} = Rm; let Inst{15} = isSub; let Inst{14-10} = Ra; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass ThreeOperandFPData { def Hrrr : BaseThreeOperandFPData { let Inst{23-22} = 0b11; // 16-bit size flag let Predicates = [HasFullFP16]; } def Srrr : BaseThreeOperandFPData { let Inst{23-22} = 0b00; // 32-bit size flag } def Drrr : BaseThreeOperandFPData { let Inst{23-22} = 0b01; // 64-bit size flag } let Predicates = [HasFullFP16] in { def : Pat<(f16 (node (f16 FPR16:$Rn), (f16 (extractelt (v8f16 V128:$Rm), (i64 0))), (f16 FPR16:$Ra))), (!cast(NAME # Hrrr) FPR16:$Rn, (f16 (EXTRACT_SUBREG V128:$Rm, hsub)), FPR16:$Ra)>; def : Pat<(f16 (node (f16 (extractelt (v8f16 V128:$Rn), (i64 0))), (f16 FPR16:$Rm), (f16 FPR16:$Ra))), (!cast(NAME # Hrrr) (f16 (EXTRACT_SUBREG V128:$Rn, hsub)), FPR16:$Rm, FPR16:$Ra)>; } def : Pat<(f32 (node (f32 FPR32:$Rn), (f32 (extractelt (v4f32 V128:$Rm), (i64 0))), (f32 FPR32:$Ra))), (!cast(NAME # Srrr) FPR32:$Rn, (EXTRACT_SUBREG V128:$Rm, ssub), FPR32:$Ra)>; def : Pat<(f32 (node (f32 (extractelt (v4f32 V128:$Rn), (i64 0))), (f32 FPR32:$Rm), (f32 FPR32:$Ra))), (!cast(NAME # Srrr) (EXTRACT_SUBREG V128:$Rn, ssub), FPR32:$Rm, FPR32:$Ra)>; def : Pat<(f64 (node (f64 FPR64:$Rn), (f64 (extractelt (v2f64 V128:$Rm), (i64 0))), (f64 FPR64:$Ra))), (!cast(NAME # Drrr) FPR64:$Rn, (EXTRACT_SUBREG V128:$Rm, dsub), FPR64:$Ra)>; def : Pat<(f64 (node (f64 (extractelt (v2f64 V128:$Rn), (i64 0))), (f64 FPR64:$Rm), (f64 FPR64:$Ra))), (!cast(NAME # Drrr) (EXTRACT_SUBREG V128:$Rn, dsub), FPR64:$Rm, FPR64:$Ra)>; } //--- // Floating point data comparisons //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseOneOperandFPComparison pat> : I<(outs), (ins regtype:$Rn), asm, "\t$Rn, #0.0", "", pat>, Sched<[WriteFCmp]> { bits<5> Rn; let Inst{31-24} = 0b00011110; let Inst{21} = 1; let Inst{15-10} = 0b001000; let Inst{9-5} = Rn; let Inst{4} = signalAllNans; let Inst{3-0} = 0b1000; // Rm should be 0b00000 canonically, but we need to accept any value. let PostEncoderMethod = "fixOneOperandFPComparison"; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseTwoOperandFPComparison pat> : I<(outs), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rn, $Rm", "", pat>, Sched<[WriteFCmp]> { bits<5> Rm; bits<5> Rn; let Inst{31-24} = 0b00011110; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-10} = 0b001000; let Inst{9-5} = Rn; let Inst{4} = signalAllNans; let Inst{3-0} = 0b0000; } multiclass FPComparison { let Defs = [NZCV] in { def Hrr : BaseTwoOperandFPComparison { let Inst{23-22} = 0b11; let Predicates = [HasFullFP16]; } def Hri : BaseOneOperandFPComparison { let Inst{23-22} = 0b11; let Predicates = [HasFullFP16]; } def Srr : BaseTwoOperandFPComparison { let Inst{23-22} = 0b00; } def Sri : BaseOneOperandFPComparison { let Inst{23-22} = 0b00; } def Drr : BaseTwoOperandFPComparison { let Inst{23-22} = 0b01; } def Dri : BaseOneOperandFPComparison { let Inst{23-22} = 0b01; } } // Defs = [NZCV] } //--- // Floating point conditional comparisons //--- let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseFPCondComparison pat> : I<(outs), (ins regtype:$Rn, regtype:$Rm, imm32_0_15:$nzcv, ccode:$cond), mnemonic, "\t$Rn, $Rm, $nzcv, $cond", "", pat>, Sched<[WriteFCmp]> { let Uses = [NZCV]; let Defs = [NZCV]; bits<5> Rn; bits<5> Rm; bits<4> nzcv; bits<4> cond; let Inst{31-24} = 0b00011110; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-12} = cond; let Inst{11-10} = 0b01; let Inst{9-5} = Rn; let Inst{4} = signalAllNans; let Inst{3-0} = nzcv; } multiclass FPCondComparison { def Hrr : BaseFPCondComparison { let Inst{23-22} = 0b11; let Predicates = [HasFullFP16]; } def Srr : BaseFPCondComparison { let Inst{23-22} = 0b00; } def Drr : BaseFPCondComparison { let Inst{23-22} = 0b01; } } //--- // Floating point conditional select //--- class BaseFPCondSelect : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, ccode:$cond), asm, "\t$Rd, $Rn, $Rm, $cond", "", [(set regtype:$Rd, (AArch64csel (vt regtype:$Rn), regtype:$Rm, (i32 imm:$cond), NZCV))]>, Sched<[WriteF]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<4> cond; let Inst{31-24} = 0b00011110; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-12} = cond; let Inst{11-10} = 0b11; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass FPCondSelect { let Uses = [NZCV] in { def Hrrr : BaseFPCondSelect { let Inst{23-22} = 0b11; let Predicates = [HasFullFP16]; } def Srrr : BaseFPCondSelect { let Inst{23-22} = 0b00; } def Drrr : BaseFPCondSelect { let Inst{23-22} = 0b01; } } // Uses = [NZCV] } //--- // Floating move immediate //--- class BaseFPMoveImmediate : I<(outs regtype:$Rd), (ins fpimmtype:$imm), asm, "\t$Rd, $imm", "", [(set regtype:$Rd, fpimmtype:$imm)]>, Sched<[WriteFImm]> { bits<5> Rd; bits<8> imm; let Inst{31-24} = 0b00011110; let Inst{21} = 1; let Inst{20-13} = imm; let Inst{12-5} = 0b10000000; let Inst{4-0} = Rd; } multiclass FPMoveImmediate { def Hi : BaseFPMoveImmediate { let Inst{23-22} = 0b11; let Predicates = [HasFullFP16]; } def Si : BaseFPMoveImmediate { let Inst{23-22} = 0b00; } def Di : BaseFPMoveImmediate { let Inst{23-22} = 0b01; } } } // end of 'let Predicates = [HasFPARMv8]' //---------------------------------------------------------------------------- // AdvSIMD //---------------------------------------------------------------------------- let Predicates = [HasNEON] in { //---------------------------------------------------------------------------- // AdvSIMD three register vector instructions //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDThreeSameVector size, bits<5> opcode, RegisterOperand regtype, string asm, string kind, list pattern> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # "|" # kind # "\t$Rd, $Rn, $Rm|}", "", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-21} = size; let Inst{20-16} = Rm; let Inst{15-11} = opcode; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDThreeSameVectorTied size, bits<5> opcode, RegisterOperand regtype, string asm, string kind, list pattern> : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # "|" # kind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-21} = size; let Inst{20-16} = Rm; let Inst{15-11} = opcode; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDThreeSameVectorPseudo pattern> : Pseudo<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm), pattern>, Sched<[!if(!eq(regtype, V128), WriteVq, WriteVd)]>; multiclass SIMDLogicalThreeVectorPseudo { def v8i8 : BaseSIMDThreeSameVectorPseudo; def v16i8 : BaseSIMDThreeSameVectorPseudo; def : Pat<(v4i16 (OpNode (v4i16 V64:$LHS), (v4i16 V64:$MHS), (v4i16 V64:$RHS))), (!cast(NAME#"v8i8") V64:$LHS, V64:$MHS, V64:$RHS)>; def : Pat<(v2i32 (OpNode (v2i32 V64:$LHS), (v2i32 V64:$MHS), (v2i32 V64:$RHS))), (!cast(NAME#"v8i8") V64:$LHS, V64:$MHS, V64:$RHS)>; def : Pat<(v1i64 (OpNode (v1i64 V64:$LHS), (v1i64 V64:$MHS), (v1i64 V64:$RHS))), (!cast(NAME#"v8i8") V64:$LHS, V64:$MHS, V64:$RHS)>; def : Pat<(v8i16 (OpNode (v8i16 V128:$LHS), (v8i16 V128:$MHS), (v8i16 V128:$RHS))), (!cast(NAME#"v16i8") V128:$LHS, V128:$MHS, V128:$RHS)>; def : Pat<(v4i32 (OpNode (v4i32 V128:$LHS), (v4i32 V128:$MHS), (v4i32 V128:$RHS))), (!cast(NAME#"v16i8") V128:$LHS, V128:$MHS, V128:$RHS)>; def : Pat<(v2i64 (OpNode (v2i64 V128:$LHS), (v2i64 V128:$MHS), (v2i64 V128:$RHS))), (!cast(NAME#"v16i8") V128:$LHS, V128:$MHS, V128:$RHS)>; } // All operand sizes distinguished in the encoding. multiclass SIMDThreeSameVector opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDThreeSameVector<0, U, 0b001, opc, V64, asm, ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>; def v16i8 : BaseSIMDThreeSameVector<1, U, 0b001, opc, V128, asm, ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>; def v4i16 : BaseSIMDThreeSameVector<0, U, 0b011, opc, V64, asm, ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>; def v8i16 : BaseSIMDThreeSameVector<1, U, 0b011, opc, V128, asm, ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>; def v2i32 : BaseSIMDThreeSameVector<0, U, 0b101, opc, V64, asm, ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>; def v4i32 : BaseSIMDThreeSameVector<1, U, 0b101, opc, V128, asm, ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>; def v2i64 : BaseSIMDThreeSameVector<1, U, 0b111, opc, V128, asm, ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (v2i64 V128:$Rm)))]>; } multiclass SIMDThreeSameVectorExtraPatterns { def : Pat<(v8i8 (OpNode V64:$LHS, V64:$RHS)), (!cast(inst#"v8i8") V64:$LHS, V64:$RHS)>; def : Pat<(v4i16 (OpNode V64:$LHS, V64:$RHS)), (!cast(inst#"v4i16") V64:$LHS, V64:$RHS)>; def : Pat<(v2i32 (OpNode V64:$LHS, V64:$RHS)), (!cast(inst#"v2i32") V64:$LHS, V64:$RHS)>; def : Pat<(v16i8 (OpNode V128:$LHS, V128:$RHS)), (!cast(inst#"v16i8") V128:$LHS, V128:$RHS)>; def : Pat<(v8i16 (OpNode V128:$LHS, V128:$RHS)), (!cast(inst#"v8i16") V128:$LHS, V128:$RHS)>; def : Pat<(v4i32 (OpNode V128:$LHS, V128:$RHS)), (!cast(inst#"v4i32") V128:$LHS, V128:$RHS)>; def : Pat<(v2i64 (OpNode V128:$LHS, V128:$RHS)), (!cast(inst#"v2i64") V128:$LHS, V128:$RHS)>; } // As above, but D sized elements unsupported. multiclass SIMDThreeSameVectorBHS opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDThreeSameVector<0, U, 0b001, opc, V64, asm, ".8b", [(set V64:$Rd, (v8i8 (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm))))]>; def v16i8 : BaseSIMDThreeSameVector<1, U, 0b001, opc, V128, asm, ".16b", [(set V128:$Rd, (v16i8 (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm))))]>; def v4i16 : BaseSIMDThreeSameVector<0, U, 0b011, opc, V64, asm, ".4h", [(set V64:$Rd, (v4i16 (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm))))]>; def v8i16 : BaseSIMDThreeSameVector<1, U, 0b011, opc, V128, asm, ".8h", [(set V128:$Rd, (v8i16 (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm))))]>; def v2i32 : BaseSIMDThreeSameVector<0, U, 0b101, opc, V64, asm, ".2s", [(set V64:$Rd, (v2i32 (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm))))]>; def v4i32 : BaseSIMDThreeSameVector<1, U, 0b101, opc, V128, asm, ".4s", [(set V128:$Rd, (v4i32 (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm))))]>; } multiclass SIMDThreeSameVectorBHSTied opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDThreeSameVectorTied<0, U, 0b001, opc, V64, asm, ".8b", [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>; def v16i8 : BaseSIMDThreeSameVectorTied<1, U, 0b001, opc, V128, asm, ".16b", [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>; def v4i16 : BaseSIMDThreeSameVectorTied<0, U, 0b011, opc, V64, asm, ".4h", [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>; def v8i16 : BaseSIMDThreeSameVectorTied<1, U, 0b011, opc, V128, asm, ".8h", [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>; def v2i32 : BaseSIMDThreeSameVectorTied<0, U, 0b101, opc, V64, asm, ".2s", [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>; def v4i32 : BaseSIMDThreeSameVectorTied<1, U, 0b101, opc, V128, asm, ".4s", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>; } // As above, but only B sized elements supported. multiclass SIMDThreeSameVectorB opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDThreeSameVector<0, U, 0b001, opc, V64, asm, ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>; def v16i8 : BaseSIMDThreeSameVector<1, U, 0b001, opc, V128, asm, ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>; } // As above, but only floating point elements supported. let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDThreeSameVectorFP opc, string asm, SDPatternOperator OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDThreeSameVector<0, U, {S,0b10}, {0b00,opc}, V64, asm, ".4h", [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (v4f16 V64:$Rm)))]>; def v8f16 : BaseSIMDThreeSameVector<1, U, {S,0b10}, {0b00,opc}, V128, asm, ".8h", [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8f16 V128:$Rm)))]>; } // Predicates = [HasNEON, HasFullFP16] def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0b01}, {0b11,opc}, V64, asm, ".2s", [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>; def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0b01}, {0b11,opc}, V128, asm, ".4s", [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>; def v2f64 : BaseSIMDThreeSameVector<1, U, {S,0b11}, {0b11,opc}, V128, asm, ".2d", [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDThreeSameVectorFPCmp opc, string asm, SDPatternOperator OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDThreeSameVector<0, U, {S,0b10}, {0b00,opc}, V64, asm, ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (v4f16 V64:$Rm)))]>; def v8f16 : BaseSIMDThreeSameVector<1, U, {S,0b10}, {0b00,opc}, V128, asm, ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8f16 V128:$Rm)))]>; } // Predicates = [HasNEON, HasFullFP16] def v2f32 : BaseSIMDThreeSameVector<0, U, {S,0b01}, {0b11,opc}, V64, asm, ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>; def v4f32 : BaseSIMDThreeSameVector<1, U, {S,0b01}, {0b11,opc}, V128, asm, ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>; def v2f64 : BaseSIMDThreeSameVector<1, U, {S,0b11}, {0b11,opc}, V128, asm, ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDThreeSameVectorFPTied opc, string asm, SDPatternOperator OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDThreeSameVectorTied<0, U, {S,0b10}, {0b00,opc}, V64, asm, ".4h", [(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn), (v4f16 V64:$Rm)))]>; def v8f16 : BaseSIMDThreeSameVectorTied<1, U, {S,0b10}, {0b00,opc}, V128, asm, ".8h", [(set (v8f16 V128:$dst), (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn), (v8f16 V128:$Rm)))]>; } // Predicates = [HasNEON, HasFullFP16] def v2f32 : BaseSIMDThreeSameVectorTied<0, U, {S,0b01}, {0b11,opc}, V64, asm, ".2s", [(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm)))]>; def v4f32 : BaseSIMDThreeSameVectorTied<1, U, {S,0b01}, {0b11,opc}, V128, asm, ".4s", [(set (v4f32 V128:$dst), (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm)))]>; def v2f64 : BaseSIMDThreeSameVectorTied<1, U, {S,0b11}, {0b11,opc}, V128, asm, ".2d", [(set (v2f64 V128:$dst), (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm)))]>; } // As above, but D and B sized elements unsupported. let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDThreeSameVectorHS opc, string asm, SDPatternOperator OpNode> { def v4i16 : BaseSIMDThreeSameVector<0, U, 0b011, opc, V64, asm, ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (v4i16 V64:$Rm)))]>; def v8i16 : BaseSIMDThreeSameVector<1, U, 0b011, opc, V128, asm, ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 V128:$Rm)))]>; def v2i32 : BaseSIMDThreeSameVector<0, U, 0b101, opc, V64, asm, ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (v2i32 V64:$Rm)))]>; def v4i32 : BaseSIMDThreeSameVector<1, U, 0b101, opc, V128, asm, ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 V128:$Rm)))]>; } // Logical three vector ops share opcode bits, and only use B sized elements. multiclass SIMDLogicalThreeVector size, string asm, SDPatternOperator OpNode = null_frag> { def v8i8 : BaseSIMDThreeSameVector<0, U, {size,1}, 0b00011, V64, asm, ".8b", [(set (v8i8 V64:$Rd), (OpNode V64:$Rn, V64:$Rm))]>; def v16i8 : BaseSIMDThreeSameVector<1, U, {size,1}, 0b00011, V128, asm, ".16b", [(set (v16i8 V128:$Rd), (OpNode V128:$Rn, V128:$Rm))]>; def : Pat<(v4i16 (OpNode V64:$LHS, V64:$RHS)), (!cast(NAME#"v8i8") V64:$LHS, V64:$RHS)>; def : Pat<(v2i32 (OpNode V64:$LHS, V64:$RHS)), (!cast(NAME#"v8i8") V64:$LHS, V64:$RHS)>; def : Pat<(v1i64 (OpNode V64:$LHS, V64:$RHS)), (!cast(NAME#"v8i8") V64:$LHS, V64:$RHS)>; def : Pat<(v8i16 (OpNode V128:$LHS, V128:$RHS)), (!cast(NAME#"v16i8") V128:$LHS, V128:$RHS)>; def : Pat<(v4i32 (OpNode V128:$LHS, V128:$RHS)), (!cast(NAME#"v16i8") V128:$LHS, V128:$RHS)>; def : Pat<(v2i64 (OpNode V128:$LHS, V128:$RHS)), (!cast(NAME#"v16i8") V128:$LHS, V128:$RHS)>; } multiclass SIMDLogicalThreeVectorTied size, string asm, SDPatternOperator OpNode = null_frag> { def v8i8 : BaseSIMDThreeSameVectorTied<0, U, {size,1}, 0b00011, V64, asm, ".8b", [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm)))]>; def v16i8 : BaseSIMDThreeSameVectorTied<1, U, {size,1}, 0b00011, V128, asm, ".16b", [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]>; def : Pat<(v4i16 (OpNode (v4i16 V64:$LHS), (v4i16 V64:$MHS), (v4i16 V64:$RHS))), (!cast(NAME#"v8i8") V64:$LHS, V64:$MHS, V64:$RHS)>; def : Pat<(v2i32 (OpNode (v2i32 V64:$LHS), (v2i32 V64:$MHS), (v2i32 V64:$RHS))), (!cast(NAME#"v8i8") V64:$LHS, V64:$MHS, V64:$RHS)>; def : Pat<(v1i64 (OpNode (v1i64 V64:$LHS), (v1i64 V64:$MHS), (v1i64 V64:$RHS))), (!cast(NAME#"v8i8") V64:$LHS, V64:$MHS, V64:$RHS)>; def : Pat<(v8i16 (OpNode (v8i16 V128:$LHS), (v8i16 V128:$MHS), (v8i16 V128:$RHS))), (!cast(NAME#"v16i8") V128:$LHS, V128:$MHS, V128:$RHS)>; def : Pat<(v4i32 (OpNode (v4i32 V128:$LHS), (v4i32 V128:$MHS), (v4i32 V128:$RHS))), (!cast(NAME#"v16i8") V128:$LHS, V128:$MHS, V128:$RHS)>; def : Pat<(v2i64 (OpNode (v2i64 V128:$LHS), (v2i64 V128:$MHS), (v2i64 V128:$RHS))), (!cast(NAME#"v16i8") V128:$LHS, V128:$MHS, V128:$RHS)>; } // ARMv8.2-A Dot Product Instructions (Vector): These instructions extract // bytes from S-sized elements. class BaseSIMDThreeSameVectorDot sz, bits<4> opc, string asm, string kind1, string kind2, RegisterOperand RegType, ValueType AccumType, ValueType InputType, SDPatternOperator OpNode> : BaseSIMDThreeSameVectorTied { let AsmString = !strconcat(asm, "{\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2 # "}"); } multiclass SIMDThreeSameVectorDot { def v8i8 : BaseSIMDThreeSameVectorDot<0, U, 0b10, {0b001, Mixed}, asm, ".2s", ".8b", V64, v2i32, v8i8, OpNode>; def v16i8 : BaseSIMDThreeSameVectorDot<1, U, 0b10, {0b001, Mixed}, asm, ".4s", ".16b", V128, v4i32, v16i8, OpNode>; } // ARMv8.2-A Fused Multiply Add-Long Instructions (Vector): These instructions // select inputs from 4H vectors and accumulate outputs to a 2S vector (or from // 8H to 4S, when Q=1). let mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDThreeSameVectorFML size, string asm, string kind1, string kind2, RegisterOperand RegType, ValueType AccumType, ValueType InputType, SDPatternOperator OpNode> : BaseSIMDThreeSameVectorTied { let AsmString = !strconcat(asm, "{\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2 # "}"); let Inst{13} = b13; } multiclass SIMDThreeSameVectorFML size, string asm, SDPatternOperator OpNode> { def v4f16 : BaseSIMDThreeSameVectorFML<0, U, b13, size, asm, ".2s", ".2h", V64, v2f32, v4f16, OpNode>; def v8f16 : BaseSIMDThreeSameVectorFML<1, U, b13, size, asm, ".4s", ".4h", V128, v4f32, v8f16, OpNode>; } multiclass SIMDThreeSameVectorMLA{ def v8f16 : BaseSIMDThreeSameVectorDot; } multiclass SIMDThreeSameVectorMLAL sz, string asm>{ def v4f32 : BaseSIMDThreeSameVectorDot; } // FP8 assembly/disassembly classes //---------------------------------------------------------------------------- // FP8 Advanced SIMD three-register extension //---------------------------------------------------------------------------- class BaseSIMDThreeVectors size, bits<4> op, RegisterOperand regtype1, RegisterOperand regtype2, string asm, string kind1, string kind2> : I<(outs regtype1:$Rd), (ins regtype2:$Rn, regtype2:$Rm), asm, "\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2, "", []>, Sched<[]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21} = 0b0; let Inst{20-16} = Rm; let Inst{15} = 0b1; let Inst{14-11} = op; let Inst{10} = 0b1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } // FCVTN (FP16 to FP8) multiclass SIMDThreeSameSizeVectorCvt { def v8f8 : BaseSIMDThreeVectors<0b0, 0b0, 0b01, 0b1110, V64, V64, asm, ".8b",".4h">; def v16f8 : BaseSIMDThreeVectors<0b1, 0b0, 0b01, 0b1110, V128, V128, asm, ".16b", ".8h">; } // TODO : Create v16f8 value type // FCVTN, FCVTN2 (FP32 to FP8) multiclass SIMDThreeVectorCvt { def v8f8 : BaseSIMDThreeVectors<0b0, 0b0, 0b00, 0b1110, V64, V128, asm, ".8b", ".4s">; def 2v16f8 : BaseSIMDThreeSameVectorDot<0b1, 0b0, 0b00, 0b1110, asm#2, ".16b", ".4s", V128, v16i8, v4f32, null_frag>; } // TODO: Create a new Value Type v8f8 and v16f8 multiclass SIMDThreeSameVectorDOT2 { def v4f16 : BaseSIMDThreeSameVectorDot<0b0, 0b0, 0b01, 0b1111, asm, ".4h", ".8b", V64, v4f16, v8i8, null_frag>; def v8f16 : BaseSIMDThreeSameVectorDot<0b1, 0b0, 0b01, 0b1111, asm, ".8h", ".16b", V128, v8f16, v16i8, null_frag>; } multiclass SIMDThreeSameVectorDOT4 { def v2f32 : BaseSIMDThreeSameVectorDot<0b0, 0b0, 0b00, 0b1111, asm, ".2s", ".8b", V64, v2f32, v8i8, null_frag>; def v4f32 : BaseSIMDThreeSameVectorDot<0b1, 0b0, 0b00, 0b1111, asm, ".4s", ".16b", V128, v4f32, v16i8, null_frag>; } //---------------------------------------------------------------------------- // AdvSIMD two register vector instructions. //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDTwoSameVector size, bits<5> opcode, bits<2> size2, RegisterOperand regtype, string asm, string dstkind, string srckind, list pattern> : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "{\t$Rd" # dstkind # ", $Rn" # srckind # "|" # dstkind # "\t$Rd, $Rn}", "", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21} = 0b1; let Inst{20-19} = size2; let Inst{18-17} = 0b00; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDTwoSameVectorTied size, bits<5> opcode, bits<2> size2, RegisterOperand regtype, string asm, string dstkind, string srckind, list pattern> : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn), asm, "{\t$Rd" # dstkind # ", $Rn" # srckind # "|" # dstkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21} = 0b1; let Inst{20-19} = size2; let Inst{18-17} = 0b00; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } // Supports B, H, and S element sizes. multiclass SIMDTwoVectorBHS opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64, asm, ".8b", ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>; def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128, asm, ".16b", ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>; def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>; def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>; def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>; def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>; } class BaseSIMDVectorLShiftLongBySize size, RegisterOperand regtype, string asm, string dstkind, string srckind, string amount> : I<(outs V128:$Rd), (ins regtype:$Rn), asm, "{\t$Rd" # dstkind # ", $Rn" # srckind # ", #" # amount # "|" # dstkind # "\t$Rd, $Rn, #" # amount # "}", "", []>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-24} = 0b101110; let Inst{23-22} = size; let Inst{21-10} = 0b100001001110; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDVectorLShiftLongBySizeBHS { let hasSideEffects = 0 in { def v8i8 : BaseSIMDVectorLShiftLongBySize<0, 0b00, V64, "shll", ".8h", ".8b", "8">; def v16i8 : BaseSIMDVectorLShiftLongBySize<1, 0b00, V128, "shll2", ".8h", ".16b", "8">; def v4i16 : BaseSIMDVectorLShiftLongBySize<0, 0b01, V64, "shll", ".4s", ".4h", "16">; def v8i16 : BaseSIMDVectorLShiftLongBySize<1, 0b01, V128, "shll2", ".4s", ".8h", "16">; def v2i32 : BaseSIMDVectorLShiftLongBySize<0, 0b10, V64, "shll", ".2d", ".2s", "32">; def v4i32 : BaseSIMDVectorLShiftLongBySize<1, 0b10, V128, "shll2", ".2d", ".4s", "32">; } } // Supports all element sizes. multiclass SIMDLongTwoVector opc, string asm, SDPatternOperator OpNode> { def v8i8_v4i16 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64, asm, ".4h", ".8b", [(set (v4i16 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>; def v16i8_v8i16 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128, asm, ".8h", ".16b", [(set (v8i16 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>; def v4i16_v2i32 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64, asm, ".2s", ".4h", [(set (v2i32 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>; def v8i16_v4i32 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128, asm, ".4s", ".8h", [(set (v4i32 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>; def v2i32_v1i64 : BaseSIMDTwoSameVector<0, U, 0b10, opc, 0b00, V64, asm, ".1d", ".2s", [(set (v1i64 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>; def v4i32_v2i64 : BaseSIMDTwoSameVector<1, U, 0b10, opc, 0b00, V128, asm, ".2d", ".4s", [(set (v2i64 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>; } multiclass SIMDLongTwoVectorTied opc, string asm, SDPatternOperator OpNode> { def v8i8_v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, 0b00, V64, asm, ".4h", ".8b", [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v8i8 V64:$Rn)))]>; def v16i8_v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, 0b00, V128, asm, ".8h", ".16b", [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v16i8 V128:$Rn)))]>; def v4i16_v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, 0b00, V64, asm, ".2s", ".4h", [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v4i16 V64:$Rn)))]>; def v8i16_v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, 0b00, V128, asm, ".4s", ".8h", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v8i16 V128:$Rn)))]>; def v2i32_v1i64 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, 0b00, V64, asm, ".1d", ".2s", [(set (v1i64 V64:$dst), (OpNode (v1i64 V64:$Rd), (v2i32 V64:$Rn)))]>; def v4i32_v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, 0b00, V128, asm, ".2d", ".4s", [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v4i32 V128:$Rn)))]>; } // Supports all element sizes, except 1xD. multiclass SIMDTwoVectorBHSDTied opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDTwoSameVectorTied<0, U, 0b00, opc, 0b00, V64, asm, ".8b", ".8b", [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn)))]>; def v16i8 : BaseSIMDTwoSameVectorTied<1, U, 0b00, opc, 0b00, V128, asm, ".16b", ".16b", [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn)))]>; def v4i16 : BaseSIMDTwoSameVectorTied<0, U, 0b01, opc, 0b00, V64, asm, ".4h", ".4h", [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn)))]>; def v8i16 : BaseSIMDTwoSameVectorTied<1, U, 0b01, opc, 0b00, V128, asm, ".8h", ".8h", [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn)))]>; def v2i32 : BaseSIMDTwoSameVectorTied<0, U, 0b10, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn)))]>; def v4i32 : BaseSIMDTwoSameVectorTied<1, U, 0b10, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn)))]>; def v2i64 : BaseSIMDTwoSameVectorTied<1, U, 0b11, opc, 0b00, V128, asm, ".2d", ".2d", [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn)))]>; } multiclass SIMDTwoVectorBHSD opc, string asm, SDPatternOperator OpNode = null_frag> { def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64, asm, ".8b", ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>; def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128, asm, ".16b", ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>; def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>; def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>; def v2i32 : BaseSIMDTwoSameVector<0, U, 0b10, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>; def v4i32 : BaseSIMDTwoSameVector<1, U, 0b10, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>; def v2i64 : BaseSIMDTwoSameVector<1, U, 0b11, opc, 0b00, V128, asm, ".2d", ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>; } // Supports only B element sizes. multiclass SIMDTwoVectorB size, bits<5> opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDTwoSameVector<0, U, size, opc, 0b00, V64, asm, ".8b", ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn)))]>; def v16i8 : BaseSIMDTwoSameVector<1, U, size, opc, 0b00, V128, asm, ".16b", ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn)))]>; } // Supports only B and H element sizes. multiclass SIMDTwoVectorBH opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDTwoSameVector<0, U, 0b00, opc, 0b00, V64, asm, ".8b", ".8b", [(set (v8i8 V64:$Rd), (OpNode V64:$Rn))]>; def v16i8 : BaseSIMDTwoSameVector<1, U, 0b00, opc, 0b00, V128, asm, ".16b", ".16b", [(set (v16i8 V128:$Rd), (OpNode V128:$Rn))]>; def v4i16 : BaseSIMDTwoSameVector<0, U, 0b01, opc, 0b00, V64, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode V64:$Rn))]>; def v8i16 : BaseSIMDTwoSameVector<1, U, 0b01, opc, 0b00, V128, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode V128:$Rn))]>; } // Supports H, S and D element sizes, uses high bit of the size field // as an extra opcode bit. multiclass SIMDTwoVectorFP opc, string asm, SDPatternOperator OpNode, int fpexceptions = 1> { let mayRaiseFPException = fpexceptions, Uses = !if(fpexceptions,[FPCR],[]) in { let Predicates = [HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDTwoSameVector<0, U, {S,1}, opc, 0b11, V64, asm, ".4h", ".4h", [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn)))]>; def v8f16 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b11, V128, asm, ".8h", ".8h", [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn)))]>; } // Predicates = [HasNEON, HasFullFP16] def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>; def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>; def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b00, V128, asm, ".2d", ".2d", [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>; } } multiclass SIMDTwoVectorFPNoException opc, string asm, SDPatternOperator OpNode> : SIMDTwoVectorFP; // Supports only S and D element sizes let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDTwoVectorSD opc, string asm, SDPatternOperator OpNode = null_frag> { def v2f32 : BaseSIMDTwoSameVector<0, U, 00, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>; def v4f32 : BaseSIMDTwoSameVector<1, U, 00, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>; def v2f64 : BaseSIMDTwoSameVector<1, U, 01, opc, 0b00, V128, asm, ".2d", ".2d", [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>; } multiclass FRIntNNTVector : SIMDTwoVectorSD; // Supports only S element size. multiclass SIMDTwoVectorS opc, string asm, SDPatternOperator OpNode> { def v2i32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>; def v4i32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDTwoVectorFPToInt opc, string asm, SDPatternOperator OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDTwoSameVector<0, U, {S,1}, opc, 0b11, V64, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4f16 V64:$Rn)))]>; def v8f16 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b11, V128, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8f16 V128:$Rn)))]>; } // Predicates = [HasNEON, HasFullFP16] def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn)))]>; def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn)))]>; def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b00, V128, asm, ".2d", ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn)))]>; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDTwoVectorIntToFP opc, string asm, SDPatternOperator OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDTwoSameVector<0, U, {S,1}, opc, 0b11, V64, asm, ".4h", ".4h", [(set (v4f16 V64:$Rd), (OpNode (v4i16 V64:$Rn)))]>; def v8f16 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b11, V128, asm, ".8h", ".8h", [(set (v8f16 V128:$Rd), (OpNode (v8i16 V128:$Rn)))]>; } // Predicates = [HasNEON, HasFullFP16] def v2f32 : BaseSIMDTwoSameVector<0, U, {S,0}, opc, 0b00, V64, asm, ".2s", ".2s", [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn)))]>; def v4f32 : BaseSIMDTwoSameVector<1, U, {S,0}, opc, 0b00, V128, asm, ".4s", ".4s", [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn)))]>; def v2f64 : BaseSIMDTwoSameVector<1, U, {S,1}, opc, 0b00, V128, asm, ".2d", ".2d", [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn)))]>; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDMixedTwoVector size, bits<5> opcode, RegisterOperand inreg, RegisterOperand outreg, string asm, string outkind, string inkind, list pattern> : I<(outs outreg:$Rd), (ins inreg:$Rn), asm, "{\t$Rd" # outkind # ", $Rn" # inkind # "|" # outkind # "\t$Rd, $Rn}", "", pattern>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21-17} = 0b10000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDMixedTwoVectorTied size, bits<5> opcode, RegisterOperand inreg, RegisterOperand outreg, string asm, string outkind, string inkind, list pattern> : I<(outs outreg:$dst), (ins outreg:$Rd, inreg:$Rn), asm, "{\t$Rd" # outkind # ", $Rn" # inkind # "|" # outkind # "\t$Rd, $Rn}", "$Rd = $dst", pattern>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21-17} = 0b10000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDMixedTwoVector opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDMixedTwoVector<0, U, 0b00, opc, V128, V64, asm, ".8b", ".8h", [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn)))]>; def v16i8 : BaseSIMDMixedTwoVectorTied<1, U, 0b00, opc, V128, V128, asm#"2", ".16b", ".8h", []>; def v4i16 : BaseSIMDMixedTwoVector<0, U, 0b01, opc, V128, V64, asm, ".4h", ".4s", [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn)))]>; def v8i16 : BaseSIMDMixedTwoVectorTied<1, U, 0b01, opc, V128, V128, asm#"2", ".8h", ".4s", []>; def v2i32 : BaseSIMDMixedTwoVector<0, U, 0b10, opc, V128, V64, asm, ".2s", ".2d", [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn)))]>; def v4i32 : BaseSIMDMixedTwoVectorTied<1, U, 0b10, opc, V128, V128, asm#"2", ".4s", ".2d", []>; def : Pat<(concat_vectors (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn))), (!cast(NAME # "v16i8") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>; def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn))), (!cast(NAME # "v8i16") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>; def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn))), (!cast(NAME # "v4i32") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>; } //---------------------------------------------------------------------------- // FP8 Advanced SIMD two-register miscellaneous //---------------------------------------------------------------------------- multiclass SIMDMixedTwoVectorFP8sz, string asm> { def v8f16 : BaseSIMDMixedTwoVector<0b0, 0b1, sz, 0b10111, V64, V128, asm, ".8h", ".8b", []>; def 2v8f16 : BaseSIMDMixedTwoVector<0b1, 0b1, sz, 0b10111, V128, V128, asm#2, ".8h", ".16b", []>; } class BaseSIMDCmpTwoVector size, bits<2> size2, bits<5> opcode, RegisterOperand regtype, string asm, string kind, string zero, ValueType dty, ValueType sty, SDNode OpNode> : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", #" # zero # "|" # kind # "\t$Rd, $Rn, #" # zero # "}", "", [(set (dty regtype:$Rd), (OpNode (sty regtype:$Rn)))]>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21} = 0b1; let Inst{20-19} = size2; let Inst{18-17} = 0b00; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } // Comparisons support all element sizes, except 1xD. multiclass SIMDCmpTwoVector opc, string asm, SDNode OpNode> { def v8i8rz : BaseSIMDCmpTwoVector<0, U, 0b00, 0b00, opc, V64, asm, ".8b", "0", v8i8, v8i8, OpNode>; def v16i8rz : BaseSIMDCmpTwoVector<1, U, 0b00, 0b00, opc, V128, asm, ".16b", "0", v16i8, v16i8, OpNode>; def v4i16rz : BaseSIMDCmpTwoVector<0, U, 0b01, 0b00, opc, V64, asm, ".4h", "0", v4i16, v4i16, OpNode>; def v8i16rz : BaseSIMDCmpTwoVector<1, U, 0b01, 0b00, opc, V128, asm, ".8h", "0", v8i16, v8i16, OpNode>; def v2i32rz : BaseSIMDCmpTwoVector<0, U, 0b10, 0b00, opc, V64, asm, ".2s", "0", v2i32, v2i32, OpNode>; def v4i32rz : BaseSIMDCmpTwoVector<1, U, 0b10, 0b00, opc, V128, asm, ".4s", "0", v4i32, v4i32, OpNode>; def v2i64rz : BaseSIMDCmpTwoVector<1, U, 0b11, 0b00, opc, V128, asm, ".2d", "0", v2i64, v2i64, OpNode>; } // FP Comparisons support only S and D element sizes (and H for v8.2a). multiclass SIMDFPCmpTwoVector opc, string asm, SDNode OpNode> { let mayRaiseFPException = 1, Uses = [FPCR] in { let Predicates = [HasNEON, HasFullFP16] in { def v4i16rz : BaseSIMDCmpTwoVector<0, U, {S,1}, 0b11, opc, V64, asm, ".4h", "0.0", v4i16, v4f16, OpNode>; def v8i16rz : BaseSIMDCmpTwoVector<1, U, {S,1}, 0b11, opc, V128, asm, ".8h", "0.0", v8i16, v8f16, OpNode>; } // Predicates = [HasNEON, HasFullFP16] def v2i32rz : BaseSIMDCmpTwoVector<0, U, {S,0}, 0b00, opc, V64, asm, ".2s", "0.0", v2i32, v2f32, OpNode>; def v4i32rz : BaseSIMDCmpTwoVector<1, U, {S,0}, 0b00, opc, V128, asm, ".4s", "0.0", v4i32, v4f32, OpNode>; def v2i64rz : BaseSIMDCmpTwoVector<1, U, {S,1}, 0b00, opc, V128, asm, ".2d", "0.0", v2i64, v2f64, OpNode>; } let Predicates = [HasNEON, HasFullFP16] in { def : InstAlias(NAME # v4i16rz) V64:$Vd, V64:$Vn), 0>; def : InstAlias(NAME # v8i16rz) V128:$Vd, V128:$Vn), 0>; } def : InstAlias(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>; def : InstAlias(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>; def : InstAlias(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>; let Predicates = [HasNEON, HasFullFP16] in { def : InstAlias(NAME # v4i16rz) V64:$Vd, V64:$Vn), 0>; def : InstAlias(NAME # v8i16rz) V128:$Vd, V128:$Vn), 0>; } def : InstAlias(NAME # v2i32rz) V64:$Vd, V64:$Vn), 0>; def : InstAlias(NAME # v4i32rz) V128:$Vd, V128:$Vn), 0>; def : InstAlias(NAME # v2i64rz) V128:$Vd, V128:$Vn), 0>; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDFPCvtTwoVector size, bits<5> opcode, RegisterOperand outtype, RegisterOperand intype, string asm, string VdTy, string VnTy, list pattern> : I<(outs outtype:$Rd), (ins intype:$Rn), asm, !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "", pattern>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21-17} = 0b10000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDFPCvtTwoVectorTied size, bits<5> opcode, RegisterOperand outtype, RegisterOperand intype, string asm, string VdTy, string VnTy, list pattern> : I<(outs outtype:$dst), (ins outtype:$Rd, intype:$Rn), asm, !strconcat("\t$Rd", VdTy, ", $Rn", VnTy), "$Rd = $dst", pattern>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21-17} = 0b10000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDFPWidenTwoVector opc, string asm> { def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V128, V64, asm, ".4s", ".4h", []>; def v8i16 : BaseSIMDFPCvtTwoVector<1, U, {S,0}, opc, V128, V128, asm#"2", ".4s", ".8h", []>; def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V128, V64, asm, ".2d", ".2s", []>; def v4i32 : BaseSIMDFPCvtTwoVector<1, U, {S,1}, opc, V128, V128, asm#"2", ".2d", ".4s", []>; } multiclass SIMDFPNarrowTwoVector opc, string asm> { def v4i16 : BaseSIMDFPCvtTwoVector<0, U, {S,0}, opc, V64, V128, asm, ".4h", ".4s", []>; def v8i16 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,0}, opc, V128, V128, asm#"2", ".8h", ".4s", []>; def v2i32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128, asm, ".2s", ".2d", []>; def v4i32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128, asm#"2", ".4s", ".2d", []>; } multiclass SIMDFPInexactCvtTwoVector opc, string asm, Intrinsic OpNode> { def v2f32 : BaseSIMDFPCvtTwoVector<0, U, {S,1}, opc, V64, V128, asm, ".2s", ".2d", [(set (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn)))]>; def v4f32 : BaseSIMDFPCvtTwoVectorTied<1, U, {S,1}, opc, V128, V128, asm#"2", ".4s", ".2d", []>; def : Pat<(concat_vectors (v2f32 V64:$Rd), (OpNode (v2f64 V128:$Rn))), (!cast(NAME # "v4f32") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>; } //---------------------------------------------------------------------------- // AdvSIMD three register different-size vector instructions. //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDDifferentThreeVector size, bits<4> opcode, RegisterOperand outtype, RegisterOperand intype1, RegisterOperand intype2, string asm, string outkind, string inkind1, string inkind2, list pattern> : I<(outs outtype:$Rd), (ins intype1:$Rn, intype2:$Rm), asm, "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 # "|" # outkind # "\t$Rd, $Rn, $Rm}", "", pattern>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = size{0}; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size{2-1}; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-12} = opcode; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDDifferentThreeVectorTied size, bits<4> opcode, RegisterOperand outtype, RegisterOperand intype1, RegisterOperand intype2, string asm, string outkind, string inkind1, string inkind2, list pattern> : I<(outs outtype:$dst), (ins outtype:$Rd, intype1:$Rn, intype2:$Rm), asm, "{\t$Rd" # outkind # ", $Rn" # inkind1 # ", $Rm" # inkind2 # "|" # outkind # "\t$Rd, $Rn, $Rm}", "$Rd = $dst", pattern>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = size{0}; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size{2-1}; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-12} = opcode; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } // FIXME: TableGen doesn't know how to deal with expanded types that also // change the element count (in this case, placing the results in // the high elements of the result register rather than the low // elements). Until that's fixed, we can't code-gen those. multiclass SIMDNarrowThreeVectorBHS opc, string asm, Intrinsic IntOp> { def v8i16_v8i8 : BaseSIMDDifferentThreeVector; def v8i16_v16i8 : BaseSIMDDifferentThreeVectorTied; def v4i32_v4i16 : BaseSIMDDifferentThreeVector; def v4i32_v8i16 : BaseSIMDDifferentThreeVectorTied; def v2i64_v2i32 : BaseSIMDDifferentThreeVector; def v2i64_v4i32 : BaseSIMDDifferentThreeVectorTied; // Patterns for the '2' variants involve INSERT_SUBREG, which you can't put in // a version attached to an instruction. def : Pat<(concat_vectors (v8i8 V64:$Rd), (IntOp (v8i16 V128:$Rn), (v8i16 V128:$Rm))), (!cast(NAME # "v8i16_v16i8") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn, V128:$Rm)>; def : Pat<(concat_vectors (v4i16 V64:$Rd), (IntOp (v4i32 V128:$Rn), (v4i32 V128:$Rm))), (!cast(NAME # "v4i32_v8i16") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn, V128:$Rm)>; def : Pat<(concat_vectors (v2i32 V64:$Rd), (IntOp (v2i64 V128:$Rn), (v2i64 V128:$Rm))), (!cast(NAME # "v2i64_v4i32") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn, V128:$Rm)>; } multiclass SIMDDifferentThreeVectorBD opc, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDDifferentThreeVector; def v16i8 : BaseSIMDDifferentThreeVector; let Predicates = [HasAES] in { def v1i64 : BaseSIMDDifferentThreeVector; def v2i64 : BaseSIMDDifferentThreeVector; } def : Pat<(v8i16 (OpNode (v8i8 (extract_high_v16i8 (v16i8 V128:$Rn))), (v8i8 (extract_high_v16i8 (v16i8 V128:$Rm))))), (!cast(NAME#"v16i8") V128:$Rn, V128:$Rm)>; } multiclass SIMDLongThreeVectorHS opc, string asm, SDPatternOperator OpNode> { def v4i16_v4i32 : BaseSIMDDifferentThreeVector; def v8i16_v4i32 : BaseSIMDDifferentThreeVector; def v2i32_v2i64 : BaseSIMDDifferentThreeVector; def v4i32_v2i64 : BaseSIMDDifferentThreeVector; } multiclass SIMDLongThreeVectorBHSabdl opc, string asm, SDPatternOperator OpNode = null_frag> { def v8i8_v8i16 : BaseSIMDDifferentThreeVector; def v16i8_v8i16 : BaseSIMDDifferentThreeVector; def v4i16_v4i32 : BaseSIMDDifferentThreeVector; def v8i16_v4i32 : BaseSIMDDifferentThreeVector; def v2i32_v2i64 : BaseSIMDDifferentThreeVector; def v4i32_v2i64 : BaseSIMDDifferentThreeVector; } multiclass SIMDLongThreeVectorTiedBHSabal opc, string asm, SDPatternOperator OpNode> { def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied; def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied; def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied; def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied; def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied; def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied; } multiclass SIMDLongThreeVectorBHS opc, string asm, SDPatternOperator OpNode = null_frag> { def v8i8_v8i16 : BaseSIMDDifferentThreeVector; def v16i8_v8i16 : BaseSIMDDifferentThreeVector; def v4i16_v4i32 : BaseSIMDDifferentThreeVector; def v8i16_v4i32 : BaseSIMDDifferentThreeVector; def v2i32_v2i64 : BaseSIMDDifferentThreeVector; def v4i32_v2i64 : BaseSIMDDifferentThreeVector; } multiclass SIMDLongThreeVectorTiedBHS opc, string asm, SDPatternOperator OpNode> { def v8i8_v8i16 : BaseSIMDDifferentThreeVectorTied; def v16i8_v8i16 : BaseSIMDDifferentThreeVectorTied; def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied; def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied; def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied; def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied; } multiclass SIMDLongThreeVectorSQDMLXTiedHS opc, string asm, SDPatternOperator Accum> { def v4i16_v4i32 : BaseSIMDDifferentThreeVectorTied; def v8i16_v4i32 : BaseSIMDDifferentThreeVectorTied; def v2i32_v2i64 : BaseSIMDDifferentThreeVectorTied; def v4i32_v2i64 : BaseSIMDDifferentThreeVectorTied; } multiclass SIMDWideThreeVectorBHS opc, string asm, SDPatternOperator OpNode> { def v8i8_v8i16 : BaseSIMDDifferentThreeVector; def v16i8_v8i16 : BaseSIMDDifferentThreeVector; def v4i16_v4i32 : BaseSIMDDifferentThreeVector; def v8i16_v4i32 : BaseSIMDDifferentThreeVector; def v2i32_v2i64 : BaseSIMDDifferentThreeVector; def v4i32_v2i64 : BaseSIMDDifferentThreeVector; } //---------------------------------------------------------------------------- // AdvSIMD bitwise extract from vector //---------------------------------------------------------------------------- class BaseSIMDBitwiseExtract : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, i32imm:$imm), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $imm" # "|" # kind # "\t$Rd, $Rn, $Rm, $imm}", "", [(set (vty regtype:$Rd), (AArch64ext regtype:$Rn, regtype:$Rm, (i32 imm:$imm)))]>, Sched<[!if(size, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<4> imm; let Inst{31} = 0; let Inst{30} = size; let Inst{29-21} = 0b101110000; let Inst{20-16} = Rm; let Inst{15} = 0; let Inst{14-11} = imm; let Inst{10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDBitwiseExtract { def v8i8 : BaseSIMDBitwiseExtract<0, V64, v8i8, asm, ".8b"> { let imm{3} = 0; } def v16i8 : BaseSIMDBitwiseExtract<1, V128, v16i8, asm, ".16b">; } //---------------------------------------------------------------------------- // AdvSIMD zip vector //---------------------------------------------------------------------------- class BaseSIMDZipVector size, bits<3> opc, RegisterOperand regtype, string asm, string kind, SDNode OpNode, ValueType valty> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # "|" # kind # "\t$Rd, $Rn, $Rm}", "", [(set (valty regtype:$Rd), (OpNode regtype:$Rn, regtype:$Rm))]>, Sched<[!if(!eq(regtype, V128), WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = size{0}; let Inst{29-24} = 0b001110; let Inst{23-22} = size{2-1}; let Inst{21} = 0; let Inst{20-16} = Rm; let Inst{15} = 0; let Inst{14-12} = opc; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDZipVectoropc, string asm, SDNode OpNode> { def v8i8 : BaseSIMDZipVector<0b000, opc, V64, asm, ".8b", OpNode, v8i8>; def v16i8 : BaseSIMDZipVector<0b001, opc, V128, asm, ".16b", OpNode, v16i8>; def v4i16 : BaseSIMDZipVector<0b010, opc, V64, asm, ".4h", OpNode, v4i16>; def v8i16 : BaseSIMDZipVector<0b011, opc, V128, asm, ".8h", OpNode, v8i16>; def v2i32 : BaseSIMDZipVector<0b100, opc, V64, asm, ".2s", OpNode, v2i32>; def v4i32 : BaseSIMDZipVector<0b101, opc, V128, asm, ".4s", OpNode, v4i32>; def v2i64 : BaseSIMDZipVector<0b111, opc, V128, asm, ".2d", OpNode, v2i64>; def : Pat<(v4f16 (OpNode V64:$Rn, V64:$Rm)), (!cast(NAME#"v4i16") V64:$Rn, V64:$Rm)>; def : Pat<(v4bf16 (OpNode V64:$Rn, V64:$Rm)), (!cast(NAME#"v4i16") V64:$Rn, V64:$Rm)>; def : Pat<(v8f16 (OpNode V128:$Rn, V128:$Rm)), (!cast(NAME#"v8i16") V128:$Rn, V128:$Rm)>; def : Pat<(v8bf16 (OpNode V128:$Rn, V128:$Rm)), (!cast(NAME#"v8i16") V128:$Rn, V128:$Rm)>; def : Pat<(v2f32 (OpNode V64:$Rn, V64:$Rm)), (!cast(NAME#"v2i32") V64:$Rn, V64:$Rm)>; def : Pat<(v4f32 (OpNode V128:$Rn, V128:$Rm)), (!cast(NAME#"v4i32") V128:$Rn, V128:$Rm)>; def : Pat<(v2f64 (OpNode V128:$Rn, V128:$Rm)), (!cast(NAME#"v2i64") V128:$Rn, V128:$Rm)>; } //---------------------------------------------------------------------------- // AdvSIMD three register scalar instructions //---------------------------------------------------------------------------- let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDThreeScalar size, bits<5> opcode, RegisterClass regtype, string asm, list pattern> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm), asm, "\t$Rd, $Rn, $Rm", "", pattern>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-21} = size; let Inst{20-16} = Rm; let Inst{15-11} = opcode; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDThreeScalarTied size, bit R, bits<5> opcode, dag oops, dag iops, string asm, list pattern> : I, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-22} = size; let Inst{21} = R; let Inst{20-16} = Rm; let Inst{15-11} = opcode; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDThreeScalarD opc, string asm, SDPatternOperator OpNode> { def v1i64 : BaseSIMDThreeScalar; } multiclass SIMDThreeScalarBHSD opc, string asm, SDPatternOperator OpNode> { def v1i64 : BaseSIMDThreeScalar; def v1i32 : BaseSIMDThreeScalar; def v1i16 : BaseSIMDThreeScalar; def v1i8 : BaseSIMDThreeScalar; def : Pat<(i64 (OpNode (i64 FPR64:$Rn), (i64 FPR64:$Rm))), (!cast(NAME#"v1i64") FPR64:$Rn, FPR64:$Rm)>; def : Pat<(i32 (OpNode (i32 FPR32:$Rn), (i32 FPR32:$Rm))), (!cast(NAME#"v1i32") FPR32:$Rn, FPR32:$Rm)>; } multiclass SIMDThreeScalarHS opc, string asm, SDPatternOperator OpNode> { def v1i32 : BaseSIMDThreeScalar; def v1i16 : BaseSIMDThreeScalar; } multiclass SIMDThreeScalarHSTied opc, string asm> { def v1i32: BaseSIMDThreeScalarTied; def v1i16: BaseSIMDThreeScalarTied; } multiclass SIMDFPThreeScalar opc, string asm, SDPatternOperator OpNode = null_frag, Predicate pred = HasNEON> { let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in { let Predicates = [pred] in { def NAME#64 : BaseSIMDThreeScalar; def NAME#32 : BaseSIMDThreeScalar; } let Predicates = [pred, HasFullFP16] in { def NAME#16 : BaseSIMDThreeScalar; } } def : Pat<(v1f64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))), (!cast(NAME # "64") FPR64:$Rn, FPR64:$Rm)>; } multiclass SIMDThreeScalarFPCmp opc, string asm, SDPatternOperator OpNode = null_frag> { let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in { def NAME#64 : BaseSIMDThreeScalar; def NAME#32 : BaseSIMDThreeScalar; let Predicates = [HasNEON, HasFullFP16] in { def NAME#16 : BaseSIMDThreeScalar; } // Predicates = [HasNEON, HasFullFP16] } def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))), (!cast(NAME # "64") FPR64:$Rn, FPR64:$Rm)>; } class BaseSIMDThreeScalarMixed size, bits<5> opcode, dag oops, dag iops, string asm, string cstr, list pat> : I, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-22} = size; let Inst{21} = 1; let Inst{20-16} = Rm; let Inst{15-11} = opcode; let Inst{10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in multiclass SIMDThreeScalarMixedHS opc, string asm, SDPatternOperator OpNode = null_frag> { def i16 : BaseSIMDThreeScalarMixed; def i32 : BaseSIMDThreeScalarMixed; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in multiclass SIMDThreeScalarMixedTiedHS opc, string asm, SDPatternOperator OpNode = null_frag> { def i16 : BaseSIMDThreeScalarMixed; def i32 : BaseSIMDThreeScalarMixed; } //---------------------------------------------------------------------------- // AdvSIMD two register scalar instructions //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDTwoScalar size, bits<2> size2, bits<5> opcode, RegisterClass regtype, RegisterClass regtype2, string asm, list pat> : I<(outs regtype:$Rd), (ins regtype2:$Rn), asm, "\t$Rd, $Rn", "", pat>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-22} = size; let Inst{21} = 0b1; let Inst{20-19} = size2; let Inst{18-17} = 0b00; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDTwoScalarTied size, bits<5> opcode, RegisterClass regtype, RegisterClass regtype2, string asm, list pat> : I<(outs regtype:$dst), (ins regtype:$Rd, regtype2:$Rn), asm, "\t$Rd, $Rn", "$Rd = $dst", pat>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-22} = size; let Inst{21-17} = 0b10000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDCmpTwoScalar size, bits<2> size2, bits<5> opcode, RegisterClass regtype, string asm, string zero> : I<(outs regtype:$Rd), (ins regtype:$Rn), asm, "\t$Rd, $Rn, #" # zero, "", []>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-22} = size; let Inst{21} = 0b1; let Inst{20-19} = size2; let Inst{18-17} = 0b00; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayRaiseFPException = 1, Uses = [FPCR] in class SIMDInexactCvtTwoScalar opcode, string asm> : I<(outs FPR32:$Rd), (ins FPR64:$Rn), asm, "\t$Rd, $Rn", "", [(set (f32 FPR32:$Rd), (int_aarch64_sisd_fcvtxn (f64 FPR64:$Rn)))]>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; let Inst{31-17} = 0b011111100110000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDCmpTwoScalarD opc, string asm, SDPatternOperator OpNode> { def v1i64rz : BaseSIMDCmpTwoScalar; def : Pat<(v1i64 (OpNode FPR64:$Rn)), (!cast(NAME # v1i64rz) FPR64:$Rn)>; } multiclass SIMDFPCmpTwoScalar opc, string asm, SDPatternOperator OpNode> { let mayRaiseFPException = 1, Uses = [FPCR] in { def v1i64rz : BaseSIMDCmpTwoScalar; def v1i32rz : BaseSIMDCmpTwoScalar; let Predicates = [HasNEON, HasFullFP16] in { def v1i16rz : BaseSIMDCmpTwoScalar; } } def : InstAlias(NAME # v1i64rz) FPR64:$Rd, FPR64:$Rn), 0>; def : InstAlias(NAME # v1i32rz) FPR32:$Rd, FPR32:$Rn), 0>; let Predicates = [HasNEON, HasFullFP16] in { def : InstAlias(NAME # v1i16rz) FPR16:$Rd, FPR16:$Rn), 0>; } def : Pat<(v1i64 (OpNode (v1f64 FPR64:$Rn))), (!cast(NAME # v1i64rz) FPR64:$Rn)>; } multiclass SIMDTwoScalarD opc, string asm, SDPatternOperator OpNode = null_frag, list preds = []> { def v1i64 : BaseSIMDTwoScalar; let Predicates = preds in { def : Pat<(i64 (OpNode (i64 FPR64:$Rn))), (!cast(NAME # "v1i64") FPR64:$Rn)>; } } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDFPTwoScalar opc, string asm, Predicate pred = HasNEON> { let Predicates = [pred] in { def v1i64 : BaseSIMDTwoScalar; def v1i32 : BaseSIMDTwoScalar; } let Predicates = [pred, HasFullFP16] in { def v1f16 : BaseSIMDTwoScalar; } } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDFPTwoScalarCVT opc, string asm, SDPatternOperator OpNode> { def v1i64 : BaseSIMDTwoScalar; def v1i32 : BaseSIMDTwoScalar; let Predicates = [HasNEON, HasFullFP16] in { def v1i16 : BaseSIMDTwoScalar; } } multiclass SIMDTwoScalarBHSD opc, string asm, SDPatternOperator OpNode = null_frag> { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { def v1i64 : BaseSIMDTwoScalar; def v1i32 : BaseSIMDTwoScalar; def v1i16 : BaseSIMDTwoScalar; def v1i8 : BaseSIMDTwoScalar; } def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn))), (!cast(NAME # v1i64) FPR64:$Rn)>; } multiclass SIMDTwoScalarBHSDTied opc, string asm, Intrinsic OpNode> { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { def v1i64 : BaseSIMDTwoScalarTied; def v1i32 : BaseSIMDTwoScalarTied; def v1i16 : BaseSIMDTwoScalarTied; def v1i8 : BaseSIMDTwoScalarTied; } def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn))), (!cast(NAME # v1i64) FPR64:$Rd, FPR64:$Rn)>; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in multiclass SIMDTwoScalarMixedBHS opc, string asm, SDPatternOperator OpNode = null_frag> { def v1i32 : BaseSIMDTwoScalar; def v1i16 : BaseSIMDTwoScalar; def v1i8 : BaseSIMDTwoScalar; } //---------------------------------------------------------------------------- // AdvSIMD scalar pairwise instructions //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDPairwiseScalar size, bits<5> opcode, RegisterOperand regtype, RegisterOperand vectype, string asm, string kind> : I<(outs regtype:$Rd), (ins vectype:$Rn), asm, "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", []>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-24} = 0b11110; let Inst{23-22} = size; let Inst{21-17} = 0b11000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDPairwiseScalarD opc, string asm> { def v2i64p : BaseSIMDPairwiseScalar; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDFPPairwiseScalar opc, string asm> { let Predicates = [HasNEON, HasFullFP16] in { def v2i16p : BaseSIMDPairwiseScalar<0, {S,0}, opc, FPR16Op, V64, asm, ".2h">; } def v2i32p : BaseSIMDPairwiseScalar<1, {S,0}, opc, FPR32Op, V64, asm, ".2s">; def v2i64p : BaseSIMDPairwiseScalar<1, {S,1}, opc, FPR64Op, V128, asm, ".2d">; } //---------------------------------------------------------------------------- // AdvSIMD across lanes instructions //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDAcrossLanes size, bits<5> opcode, RegisterClass regtype, RegisterOperand vectype, string asm, string kind, list pattern> : I<(outs regtype:$Rd), (ins vectype:$Rn), asm, "{\t$Rd, $Rn" # kind # "|" # kind # "\t$Rd, $Rn}", "", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21-17} = 0b11000; let Inst{16-12} = opcode; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDAcrossLanesBHS opcode, string asm> { def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR8, V64, asm, ".8b", []>; def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR8, V128, asm, ".16b", []>; def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR16, V64, asm, ".4h", []>; def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR16, V128, asm, ".8h", []>; def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR32, V128, asm, ".4s", []>; } multiclass SIMDAcrossLanesHSD opcode, string asm> { def v8i8v : BaseSIMDAcrossLanes<0, U, 0b00, opcode, FPR16, V64, asm, ".8b", []>; def v16i8v : BaseSIMDAcrossLanes<1, U, 0b00, opcode, FPR16, V128, asm, ".16b", []>; def v4i16v : BaseSIMDAcrossLanes<0, U, 0b01, opcode, FPR32, V64, asm, ".4h", []>; def v8i16v : BaseSIMDAcrossLanes<1, U, 0b01, opcode, FPR32, V128, asm, ".8h", []>; def v4i32v : BaseSIMDAcrossLanes<1, U, 0b10, opcode, FPR64, V128, asm, ".4s", []>; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDFPAcrossLanes opcode, bit sz1, string asm, SDPatternOperator intOp> { let Predicates = [HasNEON, HasFullFP16] in { def v4i16v : BaseSIMDAcrossLanes<0, 0, {sz1, 0}, opcode, FPR16, V64, asm, ".4h", [(set (f16 FPR16:$Rd), (intOp (v4f16 V64:$Rn)))]>; def v8i16v : BaseSIMDAcrossLanes<1, 0, {sz1, 0}, opcode, FPR16, V128, asm, ".8h", [(set (f16 FPR16:$Rd), (intOp (v8f16 V128:$Rn)))]>; } // Predicates = [HasNEON, HasFullFP16] def v4i32v : BaseSIMDAcrossLanes<1, 1, {sz1, 0}, opcode, FPR32, V128, asm, ".4s", [(set FPR32:$Rd, (intOp (v4f32 V128:$Rn)))]>; } //---------------------------------------------------------------------------- // AdvSIMD INS/DUP instructions //---------------------------------------------------------------------------- // FIXME: There has got to be a better way to factor these. ugh. class BaseSIMDInsDup pattern> : I, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = op; let Inst{28-21} = 0b01110000; let Inst{15} = 0; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class SIMDDupFromMain imm5, string size, ValueType vectype, RegisterOperand vecreg, RegisterClass regtype> : BaseSIMDInsDup { let Inst{20-16} = imm5; let Inst{14-11} = 0b0001; } class SIMDDupFromElement : BaseSIMDInsDup { let Inst{14-11} = 0b0000; } class SIMDDup64FromElement : SIMDDupFromElement<1, ".2d", ".d", v2i64, v2i64, V128, VectorIndexD, AArch64duplane64> { bits<1> idx; let Inst{20} = idx; let Inst{19-16} = 0b1000; } class SIMDDup32FromElement : SIMDDupFromElement { bits<2> idx; let Inst{20-19} = idx; let Inst{18-16} = 0b100; } class SIMDDup16FromElement : SIMDDupFromElement { bits<3> idx; let Inst{20-18} = idx; let Inst{17-16} = 0b10; } class SIMDDup8FromElement : SIMDDupFromElement { bits<4> idx; let Inst{20-17} = idx; let Inst{16} = 1; } class BaseSIMDMov imm4, RegisterClass regtype, Operand idxtype, string asm, list pattern> : BaseSIMDInsDup { let Inst{14-11} = imm4; } class SIMDSMov : BaseSIMDMov; class SIMDUMov : BaseSIMDMov; class SIMDMovAlias : InstAlias; multiclass SMov { // SMOV with vector index of 0 are legal in Scalable Matrix Extension (SME) // streaming mode. let Predicates = [HasNEONorSME] in { def vi8to32_idx0 : SIMDSMov<0, ".b", GPR32, VectorIndex0> { let Inst{20-16} = 0b00001; } def vi8to64_idx0 : SIMDSMov<1, ".b", GPR64, VectorIndex0> { let Inst{20-16} = 0b00001; } def vi16to32_idx0 : SIMDSMov<0, ".h", GPR32, VectorIndex0> { let Inst{20-16} = 0b00010; } def vi16to64_idx0 : SIMDSMov<1, ".h", GPR64, VectorIndex0> { let Inst{20-16} = 0b00010; } def vi32to64_idx0 : SIMDSMov<1, ".s", GPR64, VectorIndex0> { let Inst{20-16} = 0b00100; } } def vi8to32 : SIMDSMov<0, ".b", GPR32, VectorIndexB> { bits<4> idx; let Inst{20-17} = idx; let Inst{16} = 1; } def vi8to64 : SIMDSMov<1, ".b", GPR64, VectorIndexB> { bits<4> idx; let Inst{20-17} = idx; let Inst{16} = 1; } def vi16to32 : SIMDSMov<0, ".h", GPR32, VectorIndexH> { bits<3> idx; let Inst{20-18} = idx; let Inst{17-16} = 0b10; } def vi16to64 : SIMDSMov<1, ".h", GPR64, VectorIndexH> { bits<3> idx; let Inst{20-18} = idx; let Inst{17-16} = 0b10; } def vi32to64 : SIMDSMov<1, ".s", GPR64, VectorIndexS> { bits<2> idx; let Inst{20-19} = idx; let Inst{18-16} = 0b100; } } multiclass UMov { // UMOV with vector index of 0 are legal in Scalable Matrix Extension (SME) // streaming mode. let Predicates = [HasNEONorSME] in { def vi8_idx0 : SIMDUMov<0, ".b", v16i8, GPR32, VectorIndex0> { let Inst{20-16} = 0b00001; } def vi16_idx0 : SIMDUMov<0, ".h", v8i16, GPR32, VectorIndex0> { let Inst{20-16} = 0b00010; } def vi32_idx0 : SIMDUMov<0, ".s", v4i32, GPR32, VectorIndex0> { let Inst{20-16} = 0b00100; } def vi64_idx0 : SIMDUMov<1, ".d", v2i64, GPR64, VectorIndex0> { let Inst{20-16} = 0b01000; } def : SIMDMovAlias<"mov", ".s", !cast(NAME # vi32_idx0), GPR32, VectorIndex0>; def : SIMDMovAlias<"mov", ".d", !cast(NAME # vi64_idx0), GPR64, VectorIndex0>; } def vi8 : SIMDUMov<0, ".b", v16i8, GPR32, VectorIndexB> { bits<4> idx; let Inst{20-17} = idx; let Inst{16} = 1; } def vi16 : SIMDUMov<0, ".h", v8i16, GPR32, VectorIndexH> { bits<3> idx; let Inst{20-18} = idx; let Inst{17-16} = 0b10; } def vi32 : SIMDUMov<0, ".s", v4i32, GPR32, VectorIndexS> { bits<2> idx; let Inst{20-19} = idx; let Inst{18-16} = 0b100; } def vi64 : SIMDUMov<1, ".d", v2i64, GPR64, VectorIndexD> { bits<1> idx; let Inst{20} = idx; let Inst{19-16} = 0b1000; } def : SIMDMovAlias<"mov", ".s", !cast(NAME#"vi32"), GPR32, VectorIndexS>; def : SIMDMovAlias<"mov", ".d", !cast(NAME#"vi64"), GPR64, VectorIndexD>; } class SIMDInsFromMain : BaseSIMDInsDup<1, 0, (outs V128:$dst), (ins V128:$Rd, idxtype:$idx, regtype:$Rn), "ins", "{\t$Rd" # size # "$idx, $Rn" # "|" # size # "\t$Rd$idx, $Rn}", "$Rd = $dst", [(set V128:$dst, (vector_insert (vectype V128:$Rd), regtype:$Rn, idxtype:$idx))]> { let Inst{14-11} = 0b0011; } class SIMDInsFromElement : BaseSIMDInsDup<1, 1, (outs V128:$dst), (ins V128:$Rd, idxtype:$idx, V128:$Rn, idxtype:$idx2), "ins", "{\t$Rd" # size # "$idx, $Rn" # size # "$idx2" # "|" # size # "\t$Rd$idx, $Rn$idx2}", "$Rd = $dst", [(set V128:$dst, (vector_insert (vectype V128:$Rd), (elttype (vector_extract (vectype V128:$Rn), idxtype:$idx2)), idxtype:$idx))]>; class SIMDInsMainMovAlias : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" # "|" # size #"\t$dst$idx, $src}", (inst V128:$dst, idxtype:$idx, regtype:$src)>; class SIMDInsElementMovAlias : InstAlias<"mov" # "{\t$dst" # size # "$idx, $src" # size # "$idx2" # "|" # size #"\t$dst$idx, $src$idx2}", (inst V128:$dst, idxtype:$idx, V128:$src, idxtype:$idx2)>; multiclass SIMDIns { def vi8gpr : SIMDInsFromMain<".b", v16i8, GPR32, VectorIndexB> { bits<4> idx; let Inst{20-17} = idx; let Inst{16} = 1; } def vi16gpr : SIMDInsFromMain<".h", v8i16, GPR32, VectorIndexH> { bits<3> idx; let Inst{20-18} = idx; let Inst{17-16} = 0b10; } def vi32gpr : SIMDInsFromMain<".s", v4i32, GPR32, VectorIndexS> { bits<2> idx; let Inst{20-19} = idx; let Inst{18-16} = 0b100; } def vi64gpr : SIMDInsFromMain<".d", v2i64, GPR64, VectorIndexD> { bits<1> idx; let Inst{20} = idx; let Inst{19-16} = 0b1000; } def vi8lane : SIMDInsFromElement<".b", v16i8, i32, VectorIndexB> { bits<4> idx; bits<4> idx2; let Inst{20-17} = idx; let Inst{16} = 1; let Inst{14-11} = idx2; } def vi16lane : SIMDInsFromElement<".h", v8i16, i32, VectorIndexH> { bits<3> idx; bits<3> idx2; let Inst{20-18} = idx; let Inst{17-16} = 0b10; let Inst{14-12} = idx2; let Inst{11} = {?}; } def vi32lane : SIMDInsFromElement<".s", v4i32, i32, VectorIndexS> { bits<2> idx; bits<2> idx2; let Inst{20-19} = idx; let Inst{18-16} = 0b100; let Inst{14-13} = idx2; let Inst{12-11} = {?,?}; } def vi64lane : SIMDInsFromElement<".d", v2i64, i64, VectorIndexD> { bits<1> idx; bits<1> idx2; let Inst{20} = idx; let Inst{19-16} = 0b1000; let Inst{14} = idx2; let Inst{13-11} = {?,?,?}; } // For all forms of the INS instruction, the "mov" mnemonic is the // preferred alias. Why they didn't just call the instruction "mov" in // the first place is a very good question indeed... def : SIMDInsMainMovAlias<".b", !cast(NAME#"vi8gpr"), GPR32, VectorIndexB>; def : SIMDInsMainMovAlias<".h", !cast(NAME#"vi16gpr"), GPR32, VectorIndexH>; def : SIMDInsMainMovAlias<".s", !cast(NAME#"vi32gpr"), GPR32, VectorIndexS>; def : SIMDInsMainMovAlias<".d", !cast(NAME#"vi64gpr"), GPR64, VectorIndexD>; def : SIMDInsElementMovAlias<".b", !cast(NAME#"vi8lane"), VectorIndexB>; def : SIMDInsElementMovAlias<".h", !cast(NAME#"vi16lane"), VectorIndexH>; def : SIMDInsElementMovAlias<".s", !cast(NAME#"vi32lane"), VectorIndexS>; def : SIMDInsElementMovAlias<".d", !cast(NAME#"vi64lane"), VectorIndexD>; } //---------------------------------------------------------------------------- // AdvSIMD TBL/TBX //---------------------------------------------------------------------------- let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDTableLookup len, bit op, RegisterOperand vectype, RegisterOperand listtype, string asm, string kind> : I<(outs vectype:$Vd), (ins listtype:$Vn, vectype:$Vm), asm, "\t$Vd" # kind # ", $Vn, $Vm" # kind, "", []>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Vd; bits<5> Vn; bits<5> Vm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-21} = 0b001110000; let Inst{20-16} = Vm; let Inst{15} = 0; let Inst{14-13} = len; let Inst{12} = op; let Inst{11-10} = 0b00; let Inst{9-5} = Vn; let Inst{4-0} = Vd; } let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDTableLookupTied len, bit op, RegisterOperand vectype, RegisterOperand listtype, string asm, string kind> : I<(outs vectype:$dst), (ins vectype:$Vd, listtype:$Vn, vectype:$Vm), asm, "\t$Vd" # kind # ", $Vn, $Vm" # kind, "$Vd = $dst", []>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Vd; bits<5> Vn; bits<5> Vm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-21} = 0b001110000; let Inst{20-16} = Vm; let Inst{15} = 0; let Inst{14-13} = len; let Inst{12} = op; let Inst{11-10} = 0b00; let Inst{9-5} = Vn; let Inst{4-0} = Vd; } class SIMDTableLookupAlias : InstAlias; multiclass SIMDTableLookup { def v8i8One : BaseSIMDTableLookup<0, 0b00, op, V64, VecListOne16b, asm, ".8b">; def v8i8Two : BaseSIMDTableLookup<0, 0b01, op, V64, VecListTwo16b, asm, ".8b">; def v8i8Three : BaseSIMDTableLookup<0, 0b10, op, V64, VecListThree16b, asm, ".8b">; def v8i8Four : BaseSIMDTableLookup<0, 0b11, op, V64, VecListFour16b, asm, ".8b">; def v16i8One : BaseSIMDTableLookup<1, 0b00, op, V128, VecListOne16b, asm, ".16b">; def v16i8Two : BaseSIMDTableLookup<1, 0b01, op, V128, VecListTwo16b, asm, ".16b">; def v16i8Three: BaseSIMDTableLookup<1, 0b10, op, V128, VecListThree16b, asm, ".16b">; def v16i8Four : BaseSIMDTableLookup<1, 0b11, op, V128, VecListFour16b, asm, ".16b">; def : SIMDTableLookupAlias(NAME#"v8i8One"), V64, VecListOne128>; def : SIMDTableLookupAlias(NAME#"v8i8Two"), V64, VecListTwo128>; def : SIMDTableLookupAlias(NAME#"v8i8Three"), V64, VecListThree128>; def : SIMDTableLookupAlias(NAME#"v8i8Four"), V64, VecListFour128>; def : SIMDTableLookupAlias(NAME#"v16i8One"), V128, VecListOne128>; def : SIMDTableLookupAlias(NAME#"v16i8Two"), V128, VecListTwo128>; def : SIMDTableLookupAlias(NAME#"v16i8Three"), V128, VecListThree128>; def : SIMDTableLookupAlias(NAME#"v16i8Four"), V128, VecListFour128>; } multiclass SIMDTableLookupTied { def v8i8One : BaseSIMDTableLookupTied<0, 0b00, op, V64, VecListOne16b, asm, ".8b">; def v8i8Two : BaseSIMDTableLookupTied<0, 0b01, op, V64, VecListTwo16b, asm, ".8b">; def v8i8Three : BaseSIMDTableLookupTied<0, 0b10, op, V64, VecListThree16b, asm, ".8b">; def v8i8Four : BaseSIMDTableLookupTied<0, 0b11, op, V64, VecListFour16b, asm, ".8b">; def v16i8One : BaseSIMDTableLookupTied<1, 0b00, op, V128, VecListOne16b, asm, ".16b">; def v16i8Two : BaseSIMDTableLookupTied<1, 0b01, op, V128, VecListTwo16b, asm, ".16b">; def v16i8Three: BaseSIMDTableLookupTied<1, 0b10, op, V128, VecListThree16b, asm, ".16b">; def v16i8Four : BaseSIMDTableLookupTied<1, 0b11, op, V128, VecListFour16b, asm, ".16b">; def : SIMDTableLookupAlias(NAME#"v8i8One"), V64, VecListOne128>; def : SIMDTableLookupAlias(NAME#"v8i8Two"), V64, VecListTwo128>; def : SIMDTableLookupAlias(NAME#"v8i8Three"), V64, VecListThree128>; def : SIMDTableLookupAlias(NAME#"v8i8Four"), V64, VecListFour128>; def : SIMDTableLookupAlias(NAME#"v16i8One"), V128, VecListOne128>; def : SIMDTableLookupAlias(NAME#"v16i8Two"), V128, VecListTwo128>; def : SIMDTableLookupAlias(NAME#"v16i8Three"), V128, VecListThree128>; def : SIMDTableLookupAlias(NAME#"v16i8Four"), V128, VecListFour128>; } //---------------------------------------------------------------------------- // AdvSIMD LUT //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDTableLookupIndexed opc, RegisterOperand vectype, RegisterOperand listtype, Operand idx_type, string asm, string kind> : I<(outs vectype:$Rd), (ins listtype:$Rn, vectype:$Rm, idx_type:$idx), asm, "\t$Rd" # kind # ", $Rn, $Rm$idx", "", []>, Sched<[]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-24} = 0b001110; let Inst{23-22} = opc{4-3}; let Inst{21} = 0; let Inst{20-16} = Rm; let Inst{15} = 0; let Inst{14-12} = opc{2-0}; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass BaseSIMDTableLookupIndexed2 { def v16f8 : BaseSIMDTableLookupIndexed<0b1, {0b10,?,?,0b1}, V128, VecListOne16b, VectorIndexS, asm, ".16b"> { bits<2> idx; let Inst{14-13} = idx; } def v8f16 : BaseSIMDTableLookupIndexed<0b1, {0b11,?,?,?}, V128, VecListOne8h, VectorIndexH, asm, ".8h" > { bits<3> idx; let Inst{14-12} = idx; } } multiclass BaseSIMDTableLookupIndexed4 { def v16f8 : BaseSIMDTableLookupIndexed<0b1, {0b01,?,0b10}, V128, VecListOne16b, VectorIndexD, asm, ".16b"> { bit idx; let Inst{14} = idx; } def v8f16 : BaseSIMDTableLookupIndexed<0b1, {0b01,?,?,0b1}, V128, VecListTwo8h, VectorIndexS, asm, ".8h" > { bits<2> idx; let Inst{14-13} = idx; } } //---------------------------------------------------------------------------- // AdvSIMD scalar DUP //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDScalarDUP : I<(outs regtype:$dst), (ins vectype:$src, idxtype:$idx), asm, "{\t$dst, $src" # kind # "$idx" # "|\t$dst, $src$idx}", "", []>, Sched<[WriteVd]> { bits<5> dst; bits<5> src; let Inst{31-21} = 0b01011110000; let Inst{15-10} = 0b000001; let Inst{9-5} = src; let Inst{4-0} = dst; } class SIMDScalarDUPAlias : InstAlias; multiclass SIMDScalarDUP { def i8 : BaseSIMDScalarDUP { bits<4> idx; let Inst{20-17} = idx; let Inst{16} = 1; } def i16 : BaseSIMDScalarDUP { bits<3> idx; let Inst{20-18} = idx; let Inst{17-16} = 0b10; } def i32 : BaseSIMDScalarDUP { bits<2> idx; let Inst{20-19} = idx; let Inst{18-16} = 0b100; } def i64 : BaseSIMDScalarDUP { bits<1> idx; let Inst{20} = idx; let Inst{19-16} = 0b1000; } def : Pat<(v1i64 (scalar_to_vector (i64 (vector_extract (v2i64 V128:$src), VectorIndexD:$idx)))), (!cast(NAME # i64) V128:$src, VectorIndexD:$idx)>; // 'DUP' mnemonic aliases. def : SIMDScalarDUPAlias<"dup", ".b", !cast(NAME#"i8"), FPR8, V128, VectorIndexB>; def : SIMDScalarDUPAlias<"dup", ".h", !cast(NAME#"i16"), FPR16, V128, VectorIndexH>; def : SIMDScalarDUPAlias<"dup", ".s", !cast(NAME#"i32"), FPR32, V128, VectorIndexS>; def : SIMDScalarDUPAlias<"dup", ".d", !cast(NAME#"i64"), FPR64, V128, VectorIndexD>; } //---------------------------------------------------------------------------- // AdvSIMD modified immediate instructions //---------------------------------------------------------------------------- class BaseSIMDModifiedImm pattern> : I, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<8> imm8; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = op; let Inst{28-19} = 0b0111100000; let Inst{18-16} = imm8{7-5}; let Inst{11} = op2; let Inst{10} = 1; let Inst{9-5} = imm8{4-0}; let Inst{4-0} = Rd; } class BaseSIMDModifiedImmVector pattern> : BaseSIMDModifiedImm { let DecoderMethod = "DecodeModImmInstruction"; } class BaseSIMDModifiedImmVectorTied pattern> : BaseSIMDModifiedImm { let DecoderMethod = "DecodeModImmTiedInstruction"; } class BaseSIMDModifiedImmVectorShift b15_b12, RegisterOperand vectype, string asm, string kind, list pattern> : BaseSIMDModifiedImmVector { bits<2> shift; let Inst{15} = b15_b12{1}; let Inst{14-13} = shift; let Inst{12} = b15_b12{0}; } class BaseSIMDModifiedImmVectorShiftTied b15_b12, RegisterOperand vectype, string asm, string kind, list pattern> : BaseSIMDModifiedImmVectorTied { bits<2> shift; let Inst{15} = b15_b12{1}; let Inst{14-13} = shift; let Inst{12} = b15_b12{0}; } class BaseSIMDModifiedImmVectorShiftHalf b15_b12, RegisterOperand vectype, string asm, string kind, list pattern> : BaseSIMDModifiedImmVector { bits<2> shift; let Inst{15} = b15_b12{1}; let Inst{14} = 0; let Inst{13} = shift{0}; let Inst{12} = b15_b12{0}; } class BaseSIMDModifiedImmVectorShiftHalfTied b15_b12, RegisterOperand vectype, string asm, string kind, list pattern> : BaseSIMDModifiedImmVectorTied { bits<2> shift; let Inst{15} = b15_b12{1}; let Inst{14} = 0; let Inst{13} = shift{0}; let Inst{12} = b15_b12{0}; } multiclass SIMDModifiedImmVectorShift hw_cmode, bits<2> w_cmode, string asm> { def v4i16 : BaseSIMDModifiedImmVectorShiftHalf<0, op, hw_cmode, V64, asm, ".4h", []>; def v8i16 : BaseSIMDModifiedImmVectorShiftHalf<1, op, hw_cmode, V128, asm, ".8h", []>; def v2i32 : BaseSIMDModifiedImmVectorShift<0, op, w_cmode, V64, asm, ".2s", []>; def v4i32 : BaseSIMDModifiedImmVectorShift<1, op, w_cmode, V128, asm, ".4s", []>; } multiclass SIMDModifiedImmVectorShiftTied hw_cmode, bits<2> w_cmode, string asm, SDNode OpNode> { def v4i16 : BaseSIMDModifiedImmVectorShiftHalfTied<0, op, hw_cmode, V64, asm, ".4h", [(set (v4i16 V64:$dst), (OpNode V64:$Rd, imm0_255:$imm8, (i32 imm:$shift)))]>; def v8i16 : BaseSIMDModifiedImmVectorShiftHalfTied<1, op, hw_cmode, V128, asm, ".8h", [(set (v8i16 V128:$dst), (OpNode V128:$Rd, imm0_255:$imm8, (i32 imm:$shift)))]>; def v2i32 : BaseSIMDModifiedImmVectorShiftTied<0, op, w_cmode, V64, asm, ".2s", [(set (v2i32 V64:$dst), (OpNode V64:$Rd, imm0_255:$imm8, (i32 imm:$shift)))]>; def v4i32 : BaseSIMDModifiedImmVectorShiftTied<1, op, w_cmode, V128, asm, ".4s", [(set (v4i32 V128:$dst), (OpNode V128:$Rd, imm0_255:$imm8, (i32 imm:$shift)))]>; } class SIMDModifiedImmMoveMSL cmode, RegisterOperand vectype, string asm, string kind, list pattern> : BaseSIMDModifiedImmVector { bits<1> shift; let Inst{15-13} = cmode{3-1}; let Inst{12} = shift; } class SIMDModifiedImmVectorNoShift cmode, RegisterOperand vectype, Operand imm_type, string asm, string kind, list pattern> : BaseSIMDModifiedImmVector { let Inst{15-12} = cmode; } class SIMDModifiedImmScalarNoShift cmode, string asm, list pattern> : BaseSIMDModifiedImm { let Inst{15-12} = cmode; let DecoderMethod = "DecodeModImmInstruction"; } //---------------------------------------------------------------------------- // AdvSIMD indexed element //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDIndexed size, bits<4> opc, RegisterOperand dst_reg, RegisterOperand lhs_reg, RegisterOperand rhs_reg, Operand vec_idx, string asm, string apple_kind, string dst_kind, string lhs_kind, string rhs_kind, list pattern> : I<(outs dst_reg:$Rd), (ins lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx), asm, "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" # "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "", pattern>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28} = Scalar; let Inst{27-24} = 0b1111; let Inst{23-22} = size; // Bit 21 must be set by the derived class. let Inst{20-16} = Rm; let Inst{15-12} = opc; // Bit 11 must be set by the derived class. let Inst{10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class BaseSIMDIndexedTied size, bits<4> opc, RegisterOperand dst_reg, RegisterOperand lhs_reg, RegisterOperand rhs_reg, Operand vec_idx, string asm, string apple_kind, string dst_kind, string lhs_kind, string rhs_kind, list pattern> : I<(outs dst_reg:$dst), (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx), asm, "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx" # "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx}", "$Rd = $dst", pattern>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28} = Scalar; let Inst{27-24} = 0b1111; let Inst{23-22} = size; // Bit 21 must be set by the derived class. let Inst{20-16} = Rm; let Inst{15-12} = opc; // Bit 11 must be set by the derived class. let Inst{10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } //---------------------------------------------------------------------------- // Armv8.6 BFloat16 Extension //---------------------------------------------------------------------------- let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in { class BaseSIMDThreeSameVectorBFDot : BaseSIMDThreeSameVectorTied { let AsmString = !strconcat(asm, "{\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2 # "}"); } multiclass SIMDThreeSameVectorBFDot { def v4bf16 : BaseSIMDThreeSameVectorBFDot<0, U, asm, ".2s", ".4h", V64, v2f32, v4bf16>; def v8bf16 : BaseSIMDThreeSameVectorBFDot<1, U, asm, ".4s", ".8h", V128, v4f32, v8bf16>; } class BaseSIMDThreeSameVectorBF16DotI : BaseSIMDIndexedTied { bits<2> idx; let Inst{21} = idx{0}; // L let Inst{11} = idx{1}; // H } multiclass SIMDThreeSameVectorBF16DotI { def v4bf16 : BaseSIMDThreeSameVectorBF16DotI<0, U, asm, ".2s", ".4h", ".2h", V64, v2f32, v4bf16>; def v8bf16 : BaseSIMDThreeSameVectorBF16DotI<1, U, asm, ".4s", ".8h", ".2h", V128, v4f32, v8bf16>; } let mayRaiseFPException = 1, Uses = [FPCR] in class SIMDBF16MLAL : BaseSIMDThreeSameVectorTied { let AsmString = !strconcat(asm, "{\t$Rd.4s, $Rn.8h, $Rm.8h}"); } let mayRaiseFPException = 1, Uses = [FPCR] in class SIMDBF16MLALIndex : I<(outs V128:$dst), (ins V128:$Rd, V128:$Rn, V128_lo:$Rm, VectorIndexH:$idx), asm, "{\t$Rd.4s, $Rn.8h, $Rm.h$idx}", "$Rd = $dst", [(set (v4f32 V128:$dst), (v4f32 (OpNode (v4f32 V128:$Rd), (v8bf16 V128:$Rn), (v8bf16 (AArch64duplane16 (v8bf16 V128_lo:$Rm), VectorIndexH:$idx)))))]>, Sched<[WriteVq]> { bits<5> Rd; bits<5> Rn; bits<4> Rm; bits<3> idx; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-22} = 0b00111111; let Inst{21-20} = idx{1-0}; let Inst{19-16} = Rm; let Inst{15-12} = 0b1111; let Inst{11} = idx{2}; // H let Inst{10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class SIMDThreeSameVectorBF16MatrixMul : BaseSIMDThreeSameVectorTied<1, 1, 0b010, 0b11101, V128, asm, ".4s", [(set (v4f32 V128:$dst), (int_aarch64_neon_bfmmla (v4f32 V128:$Rd), (v8bf16 V128:$Rn), (v8bf16 V128:$Rm)))]> { let AsmString = !strconcat(asm, "{\t$Rd", ".4s", ", $Rn", ".8h", ", $Rm", ".8h", "}"); } let mayRaiseFPException = 1, Uses = [FPCR] in class SIMD_BFCVTN : BaseSIMDMixedTwoVector<0, 0, 0b10, 0b10110, V128, V128, "bfcvtn", ".4h", ".4s", [(set (v8bf16 V128:$Rd), (int_aarch64_neon_bfcvtn (v4f32 V128:$Rn)))]>; let mayRaiseFPException = 1, Uses = [FPCR] in class SIMD_BFCVTN2 : BaseSIMDMixedTwoVectorTied<1, 0, 0b10, 0b10110, V128, V128, "bfcvtn2", ".8h", ".4s", [(set (v8bf16 V128:$dst), (int_aarch64_neon_bfcvtn2 (v8bf16 V128:$Rd), (v4f32 V128:$Rn)))]>; let mayRaiseFPException = 1, Uses = [FPCR] in class BF16ToSinglePrecision : I<(outs FPR16:$Rd), (ins FPR32:$Rn), asm, "\t$Rd, $Rn", "", [(set (bf16 FPR16:$Rd), (int_aarch64_neon_bfcvt (f32 FPR32:$Rn)))]>, Sched<[WriteFCvt]> { bits<5> Rd; bits<5> Rn; let Inst{31-10} = 0b0001111001100011010000; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } } // End of let mayStore = 0, mayLoad = 0, hasSideEffects = 0 //---------------------------------------------------------------------------- class BaseSIMDThreeSameVectorIndexB sz, bits<4> opc, string asm, string dst_kind, RegisterOperand RegType, RegisterOperand RegType_lo> : BaseSIMDIndexedTied { // idx = H:L:M bits<4> idx; let Inst{11} = idx{3}; let Inst{21-19} = idx{2-0}; } multiclass SIMDThreeSameVectorMLAIndex { def v8f16 : BaseSIMDThreeSameVectorIndexB; } multiclass SIMDThreeSameVectorMLALIndex sz, string asm> { def v4f32 : BaseSIMDThreeSameVectorIndexB; } //---------------------------------------------------------------------------- // Armv8.6 Matrix Multiply Extension //---------------------------------------------------------------------------- class SIMDThreeSameVectorMatMul : BaseSIMDThreeSameVectorTied<1, U, 0b100, {0b1010, B}, V128, asm, ".4s", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v16i8 V128:$Rn), (v16i8 V128:$Rm)))]> { let AsmString = asm # "{\t$Rd.4s, $Rn.16b, $Rm.16b}"; } //---------------------------------------------------------------------------- // ARMv8.2-A Dot Product Instructions (Indexed) class BaseSIMDThreeSameVectorIndexS size, bits<4> opc, string asm, string dst_kind, string lhs_kind, string rhs_kind, RegisterOperand RegType, ValueType AccumType, ValueType InputType, SDPatternOperator OpNode> : BaseSIMDIndexedTied { bits<2> idx; let Inst{21} = idx{0}; // L let Inst{11} = idx{1}; // H } multiclass SIMDThreeSameVectorDotIndex size, string asm, SDPatternOperator OpNode> { def v8i8 : BaseSIMDThreeSameVectorIndexS<0, U, size, {0b111, Mixed}, asm, ".2s", ".8b", ".4b", V64, v2i32, v8i8, OpNode>; def v16i8 : BaseSIMDThreeSameVectorIndexS<1, U, size, {0b111, Mixed}, asm, ".4s", ".16b", ".4b", V128, v4i32, v16i8, OpNode>; } // TODO: The vectors v8i8 and v16i8 should be v8f8 and v16f8 multiclass SIMDThreeSameVectorFP8DOT4Index { def v8f8 : BaseSIMDThreeSameVectorIndexS<0b0, 0b0, 0b00, 0b0000, asm, ".2s", ".8b", ".4b", V64, v2f32, v8i8, null_frag>; def v16f8 : BaseSIMDThreeSameVectorIndexS<0b1, 0b0, 0b00, 0b0000, asm, ".4s", ".16b",".4b", V128, v4f32, v16i8, null_frag>; } // ARMv8.2-A Fused Multiply Add-Long Instructions (Indexed) let mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDThreeSameVectorIndexH sz, bits<4> opc, string asm, string dst_kind, string lhs_kind, string rhs_kind, RegisterOperand RegType, RegisterOperand RegType_lo, ValueType AccumType, ValueType InputType, SDPatternOperator OpNode> : BaseSIMDIndexedTied { // idx = H:L:M bits<3> idx; let Inst{11} = idx{2}; // H let Inst{21} = idx{1}; // L let Inst{20} = idx{0}; // M } multiclass SIMDThreeSameVectorFMLIndex opc, string asm, SDPatternOperator OpNode> { def v4f16 : BaseSIMDThreeSameVectorIndexH<0, U, 0b10, opc, asm, ".2s", ".2h", ".h", V64, V128_lo, v2f32, v4f16, OpNode>; def v8f16 : BaseSIMDThreeSameVectorIndexH<1, U, 0b10, opc, asm, ".4s", ".4h", ".h", V128, V128_lo, v4f32, v8f16, OpNode>; } //---------------------------------------------------------------------------- // FP8 Advanced SIMD vector x indexed element // TODO: Replace value types v8i8 and v16i8 by v8f8 and v16f8 multiclass SIMDThreeSameVectorFP8DOT2Index { def v4f16 : BaseSIMDThreeSameVectorIndexH<0b0, 0b0, 0b01, 0b0000, asm, ".4h", ".8b", ".2b", V64, V128_lo, v4f16, v8i8, null_frag>; def v8f16 : BaseSIMDThreeSameVectorIndexH<0b1, 0b0, 0b01, 0b0000, asm, ".8h", ".16b", ".2b", V128, V128_lo, v8f16, v8i16, null_frag>; } multiclass SIMDFPIndexed opc, string asm, SDPatternOperator OpNode> { let mayRaiseFPException = 1, Uses = [FPCR] in { let Predicates = [HasNEON, HasFullFP16] in { def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b00, opc, V64, V64, V128_lo, VectorIndexH, asm, ".4h", ".4h", ".4h", ".h", [(set (v4f16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (dup_v8f16 (v8f16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b00, opc, V128, V128, V128_lo, VectorIndexH, asm, ".8h", ".8h", ".8h", ".h", [(set (v8f16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (v8f16 (AArch64duplane16 (v8f16 V128_lo:$Rm), VectorIndexH:$idx))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } } // Predicates = [HasNEON, HasFullFP16] def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc, V64, V64, V128, VectorIndexS, asm, ".2s", ".2s", ".2s", ".s", [(set (v2f32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (dup_v4f32 (v4f32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm, ".4s", ".4s", ".4s", ".s", [(set (v4f32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (v4f32 (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v2i64_indexed : BaseSIMDIndexed<1, U, 0, 0b11, opc, V128, V128, V128, VectorIndexD, asm, ".2d", ".2d", ".2d", ".d", [(set (v2f64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (v2f64 (AArch64duplane64 (v2f64 V128:$Rm), VectorIndexD:$idx))))]> { bits<1> idx; let Inst{11} = idx{0}; let Inst{21} = 0; } let Predicates = [HasNEON, HasFullFP16] in { def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b00, opc, FPR16Op, FPR16Op, V128_lo, VectorIndexH, asm, ".h", "", "", ".h", [(set (f16 FPR16Op:$Rd), (OpNode (f16 FPR16Op:$Rn), (f16 (vector_extract (v8f16 V128_lo:$Rm), VectorIndexH:$idx))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } } // Predicates = [HasNEON, HasFullFP16] def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc, FPR32Op, FPR32Op, V128, VectorIndexS, asm, ".s", "", "", ".s", [(set (f32 FPR32Op:$Rd), (OpNode (f32 FPR32Op:$Rn), (f32 (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b11, opc, FPR64Op, FPR64Op, V128, VectorIndexD, asm, ".d", "", "", ".d", [(set (f64 FPR64Op:$Rd), (OpNode (f64 FPR64Op:$Rn), (f64 (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx))))]> { bits<1> idx; let Inst{11} = idx{0}; let Inst{21} = 0; } } // mayRaiseFPException = 1, Uses = [FPCR] let Predicates = [HasNEON, HasFullFP16] in { def : Pat<(f16 (OpNode (f16 (vector_extract (v8f16 V128:$Rn), (i64 0))), (f16 (vector_extract (v8f16 V128:$Rm), VectorIndexH:$idx)))), (!cast(NAME # v1i16_indexed) (f16 (EXTRACT_SUBREG V128:$Rn, hsub)), V128:$Rm, VectorIndexH:$idx)>; } let Predicates = [HasNEON] in { def : Pat<(f32 (OpNode (f32 (vector_extract (v4f32 V128:$Rn), (i64 0))), (f32 (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx)))), (!cast(NAME # v1i32_indexed) (EXTRACT_SUBREG V128:$Rn, ssub), V128:$Rm, VectorIndexS:$idx)>; def : Pat<(f64 (OpNode (f64 (vector_extract (v2f64 V128:$Rn), (i64 0))), (f64 (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx)))), (!cast(NAME # v1i64_indexed) (EXTRACT_SUBREG V128:$Rn, dsub), V128:$Rm, VectorIndexD:$idx)>; } } multiclass SIMDFPIndexedTiedPatterns { let Predicates = [HasNEON, HasFullFP16] in { // Patterns for f16: DUPLANE, DUP scalar and vector_extract. def : Pat<(v8f16 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn), (AArch64duplane16 (v8f16 V128_lo:$Rm), VectorIndexH:$idx))), (!cast(INST # "v8i16_indexed") V128:$Rd, V128:$Rn, V128_lo:$Rm, VectorIndexH:$idx)>; def : Pat<(v8f16 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn), (AArch64dup (f16 FPR16Op_lo:$Rm)))), (!cast(INST # "v8i16_indexed") V128:$Rd, V128:$Rn, (SUBREG_TO_REG (i32 0), (f16 FPR16Op_lo:$Rm), hsub), (i64 0))>; def : Pat<(v4f16 (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn), (AArch64duplane16 (v8f16 V128_lo:$Rm), VectorIndexH:$idx))), (!cast(INST # "v4i16_indexed") V64:$Rd, V64:$Rn, V128_lo:$Rm, VectorIndexH:$idx)>; def : Pat<(v4f16 (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn), (AArch64dup (f16 FPR16Op_lo:$Rm)))), (!cast(INST # "v4i16_indexed") V64:$Rd, V64:$Rn, (SUBREG_TO_REG (i32 0), (f16 FPR16Op_lo:$Rm), hsub), (i64 0))>; def : Pat<(f16 (OpNode (f16 FPR16:$Rd), (f16 FPR16:$Rn), (vector_extract (v8f16 V128_lo:$Rm), VectorIndexH:$idx))), (!cast(INST # "v1i16_indexed") FPR16:$Rd, FPR16:$Rn, V128_lo:$Rm, VectorIndexH:$idx)>; } // Predicates = [HasNEON, HasFullFP16] // 2 variants for the .2s version: DUPLANE from 128-bit and DUP scalar. def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))), (!cast(INST # v2i32_indexed) V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>; def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (AArch64dup (f32 FPR32Op:$Rm)))), (!cast(INST # "v2i32_indexed") V64:$Rd, V64:$Rn, (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>; // 2 variants for the .4s version: DUPLANE from 128-bit and DUP scalar. def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (AArch64duplane32 (v4f32 V128:$Rm), VectorIndexS:$idx))), (!cast(INST # "v4i32_indexed") V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>; def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (AArch64dup (f32 FPR32Op:$Rm)))), (!cast(INST # "v4i32_indexed") V128:$Rd, V128:$Rn, (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>; // 2 variants for the .2d version: DUPLANE from 128-bit and DUP scalar. def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (AArch64duplane64 (v2f64 V128:$Rm), VectorIndexD:$idx))), (!cast(INST # "v2i64_indexed") V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>; def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (AArch64dup (f64 FPR64Op:$Rm)))), (!cast(INST # "v2i64_indexed") V128:$Rd, V128:$Rn, (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>; // Covers 2 variants for 32-bit scalar version: extract from .2s or from .4s def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn), (vector_extract (v4f32 V128:$Rm), VectorIndexS:$idx))), (!cast(INST # "v1i32_indexed") FPR32:$Rd, FPR32:$Rn, V128:$Rm, VectorIndexS:$idx)>; // 1 variant for 64-bit scalar version: extract from .1d or from .2d def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn), (vector_extract (v2f64 V128:$Rm), VectorIndexD:$idx))), (!cast(INST # "v1i64_indexed") FPR64:$Rd, FPR64:$Rn, V128:$Rm, VectorIndexD:$idx)>; } let mayRaiseFPException = 1, Uses = [FPCR] in multiclass SIMDFPIndexedTied opc, string asm> { let Predicates = [HasNEON, HasFullFP16] in { def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b00, opc, V64, V64, V128_lo, VectorIndexH, asm, ".4h", ".4h", ".4h", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b00, opc, V128, V128, V128_lo, VectorIndexH, asm, ".8h", ".8h", ".8h", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } } // Predicates = [HasNEON, HasFullFP16] def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64, V128, VectorIndexS, asm, ".2s", ".2s", ".2s", ".s", []> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm, ".4s", ".4s", ".4s", ".s", []> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v2i64_indexed : BaseSIMDIndexedTied<1, U, 0, 0b11, opc, V128, V128, V128, VectorIndexD, asm, ".2d", ".2d", ".2d", ".d", []> { bits<1> idx; let Inst{11} = idx{0}; let Inst{21} = 0; } let Predicates = [HasNEON, HasFullFP16] in { def v1i16_indexed : BaseSIMDIndexedTied<1, U, 1, 0b00, opc, FPR16Op, FPR16Op, V128_lo, VectorIndexH, asm, ".h", "", "", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } } // Predicates = [HasNEON, HasFullFP16] def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc, FPR32Op, FPR32Op, V128, VectorIndexS, asm, ".s", "", "", ".s", []> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b11, opc, FPR64Op, FPR64Op, V128, VectorIndexD, asm, ".d", "", "", ".d", []> { bits<1> idx; let Inst{11} = idx{0}; let Inst{21} = 0; } } multiclass SIMDIndexedHSPatterns { def : Pat<(v4i16 (OpNodeLane (v4i16 V64:$Rn), (v4i16 V64_lo:$Rm), VectorIndexS32b:$idx)), (!cast(NAME # v4i16_indexed) $Rn, (SUBREG_TO_REG (i32 0), (v4i16 V64_lo:$Rm), dsub), (UImmS1XForm $idx))>; def : Pat<(v4i16 (OpNodeLaneQ (v4i16 V64:$Rn), (v8i16 V128_lo:$Rm), VectorIndexH32b:$idx)), (!cast(NAME # v4i16_indexed) $Rn, $Rm, (UImmS1XForm $idx))>; def : Pat<(v8i16 (OpNodeLane (v8i16 V128:$Rn), (v4i16 V64_lo:$Rm), VectorIndexS32b:$idx)), (!cast(NAME # v8i16_indexed) $Rn, (SUBREG_TO_REG (i32 0), $Rm, dsub), (UImmS1XForm $idx))>; def : Pat<(v8i16 (OpNodeLaneQ (v8i16 V128:$Rn), (v8i16 V128_lo:$Rm), VectorIndexH32b:$idx)), (!cast(NAME # v8i16_indexed) $Rn, $Rm, (UImmS1XForm $idx))>; def : Pat<(v2i32 (OpNodeLane (v2i32 V64:$Rn), (v2i32 V64:$Rm), VectorIndexD32b:$idx)), (!cast(NAME # v2i32_indexed) $Rn, (SUBREG_TO_REG (i32 0), (v2i32 V64_lo:$Rm), dsub), (UImmS1XForm $idx))>; def : Pat<(v2i32 (OpNodeLaneQ (v2i32 V64:$Rn), (v4i32 V128:$Rm), VectorIndexS32b:$idx)), (!cast(NAME # v2i32_indexed) $Rn, $Rm, (UImmS1XForm $idx))>; def : Pat<(v4i32 (OpNodeLane (v4i32 V128:$Rn), (v2i32 V64:$Rm), VectorIndexD32b:$idx)), (!cast(NAME # v4i32_indexed) $Rn, (SUBREG_TO_REG (i32 0), $Rm, dsub), (UImmS1XForm $idx))>; def : Pat<(v4i32 (OpNodeLaneQ (v4i32 V128:$Rn), (v4i32 V128:$Rm), VectorIndexS32b:$idx)), (!cast(NAME # v4i32_indexed) $Rn, $Rm, (UImmS1XForm $idx))>; } multiclass SIMDIndexedHS opc, string asm, SDPatternOperator OpNode> { def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V64, V64, V128_lo, VectorIndexH, asm, ".4h", ".4h", ".4h", ".h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm, ".8h", ".8h", ".8h", ".h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc, V64, V64, V128, VectorIndexS, asm, ".2s", ".2s", ".2s", ".s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm, ".4s", ".4s", ".4s", ".s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v1i16_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc, FPR16Op, FPR16Op, V128_lo, VectorIndexH, asm, ".h", "", "", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc, FPR32Op, FPR32Op, V128, VectorIndexS, asm, ".s", "", "", ".s", [(set (i32 FPR32Op:$Rd), (OpNode FPR32Op:$Rn, (i32 (vector_extract (v4i32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } multiclass SIMDVectorIndexedHS opc, string asm, SDPatternOperator OpNode> { def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V64, V64, V128_lo, VectorIndexH, asm, ".4h", ".4h", ".4h", ".h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm, ".8h", ".8h", ".8h", ".h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc, V64, V64, V128, VectorIndexS, asm, ".2s", ".2s", ".2s", ".s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm, ".4s", ".4s", ".4s", ".s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } multiclass SIMDVectorIndexedHSTied opc, string asm, SDPatternOperator OpNode> { def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V64, V64, V128_lo, VectorIndexH, asm, ".4h", ".4h", ".4h", ".h", [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd),(v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm, ".8h", ".8h", ".8h", ".h", [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64, V128, VectorIndexS, asm, ".2s", ".2s", ".2s", ".s", [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm, ".4s", ".4s", ".4s", ".s", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } multiclass SIMDIndexedLongSD opc, string asm, SDPatternOperator OpNode> { def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V128, V64, V128_lo, VectorIndexH, asm, ".4s", ".4s", ".4h", ".h", [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm#"2", ".4s", ".4s", ".8h", ".h", [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 (v8i16 V128:$Rn)), (extract_high_dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc, V128, V64, V128, VectorIndexS, asm, ".2d", ".2d", ".2s", ".s", [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm#"2", ".2d", ".2d", ".4s", ".s", [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 (v4i32 V128:$Rn)), (extract_high_dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v1i32_indexed : BaseSIMDIndexed<1, U, 1, 0b01, opc, FPR32Op, FPR16Op, V128_lo, VectorIndexH, asm, ".h", "", "", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v1i64_indexed : BaseSIMDIndexed<1, U, 1, 0b10, opc, FPR64Op, FPR32Op, V128, VectorIndexS, asm, ".s", "", "", ".s", []> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } multiclass SIMDIndexedLongSQDMLXSDTied opc, string asm, SDPatternOperator Accum> { def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V128, V64, V128_lo, VectorIndexH, asm, ".4s", ".4s", ".4h", ".h", [(set (v4i32 V128:$dst), (Accum (v4i32 V128:$Rd), (v4i32 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm#"2", ".4s", ".4s", ".8h", ".h", [(set (v4i32 V128:$dst), (Accum (v4i32 V128:$Rd), (v4i32 (int_aarch64_neon_sqdmull (extract_high_v8i16 (v8i16 V128:$Rn)), (extract_high_dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V128, V64, V128, VectorIndexS, asm, ".2d", ".2d", ".2s", ".s", [(set (v2i64 V128:$dst), (Accum (v2i64 V128:$Rd), (v2i64 (int_aarch64_neon_sqdmull (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm#"2", ".2d", ".2d", ".4s", ".s", [(set (v2i64 V128:$dst), (Accum (v2i64 V128:$Rd), (v2i64 (int_aarch64_neon_sqdmull (extract_high_v4i32 (v4i32 V128:$Rn)), (extract_high_dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc, FPR32Op, FPR16Op, V128_lo, VectorIndexH, asm, ".h", "", "", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def : Pat<(i32 (Accum (i32 FPR32Op:$Rd), (i32 (vector_extract (v4i32 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn), (v4i16 V64:$Rm))), (i64 0))))), (!cast(NAME # v1i32_indexed) FPR32Op:$Rd, (f16 (EXTRACT_SUBREG V64:$Rn, hsub)), (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rm, dsub), (i64 0))>; def : Pat<(i32 (Accum (i32 FPR32Op:$Rd), (i32 (vector_extract (v4i32 (int_aarch64_neon_sqdmull (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))), (i64 0))))), (!cast(NAME # v1i32_indexed) FPR32Op:$Rd, (f16 (EXTRACT_SUBREG V64:$Rn, hsub)), V128_lo:$Rm, VectorIndexH:$idx)>; def v1i64_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc, FPR64Op, FPR32Op, V128, VectorIndexS, asm, ".s", "", "", ".s", [(set (i64 FPR64Op:$dst), (Accum (i64 FPR64Op:$Rd), (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32Op:$Rn), (i32 (vector_extract (v4i32 V128:$Rm), VectorIndexS:$idx))))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } multiclass SIMDVectorIndexedLongSD opc, string asm, SDPatternOperator OpNode> { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { def v4i16_indexed : BaseSIMDIndexed<0, U, 0, 0b01, opc, V128, V64, V128_lo, VectorIndexH, asm, ".4s", ".4s", ".4h", ".h", [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexed<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm#"2", ".4s", ".4s", ".8h", ".h", [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 (v8i16 V128:$Rn)), (extract_high_dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexed<0, U, 0, 0b10, opc, V128, V64, V128, VectorIndexS, asm, ".2d", ".2d", ".2s", ".s", [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexed<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm#"2", ".2d", ".2d", ".4s", ".s", [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 (v4i32 V128:$Rn)), (extract_high_dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } } multiclass SIMDVectorIndexedLongSDTied opc, string asm, SDPatternOperator OpNode> { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V128, V64, V128_lo, VectorIndexH, asm, ".4s", ".4s", ".4h", ".h", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm#"2", ".4s", ".4s", ".8h", ".h", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (extract_high_v8i16 (v8i16 V128:$Rn)), (extract_high_dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V128, V64, V128, VectorIndexS, asm, ".2d", ".2d", ".2s", ".s", [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm#"2", ".2d", ".2d", ".4s", ".s", [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (extract_high_v4i32 (v4i32 V128:$Rn)), (extract_high_dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx)))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } } //---------------------------------------------------------------------------- // AdvSIMD scalar shift by immediate //---------------------------------------------------------------------------- let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDScalarShift opc, bits<7> fixed_imm, RegisterClass regtype1, RegisterClass regtype2, Operand immtype, string asm, list pattern> : I<(outs regtype1:$Rd), (ins regtype2:$Rn, immtype:$imm), asm, "\t$Rd, $Rn, $imm", "", pattern>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<7> imm; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-23} = 0b111110; let Inst{22-16} = fixed_imm; let Inst{15-11} = opc; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDScalarShiftTied opc, bits<7> fixed_imm, RegisterClass regtype1, RegisterClass regtype2, Operand immtype, string asm, list pattern> : I<(outs regtype1:$dst), (ins regtype1:$Rd, regtype2:$Rn, immtype:$imm), asm, "\t$Rd, $Rn, $imm", "$Rd = $dst", pattern>, Sched<[WriteVd]> { bits<5> Rd; bits<5> Rn; bits<7> imm; let Inst{31-30} = 0b01; let Inst{29} = U; let Inst{28-23} = 0b111110; let Inst{22-16} = fixed_imm; let Inst{15-11} = opc; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDFPScalarRShift opc, string asm> { let Predicates = [HasNEON, HasFullFP16] in { def h : BaseSIMDScalarShift { let Inst{19-16} = imm{3-0}; } } // Predicates = [HasNEON, HasFullFP16] def s : BaseSIMDScalarShift { let Inst{20-16} = imm{4-0}; } def d : BaseSIMDScalarShift { let Inst{21-16} = imm{5-0}; } } multiclass SIMDScalarRShiftD opc, string asm, SDPatternOperator OpNode> { def d : BaseSIMDScalarShift { let Inst{21-16} = imm{5-0}; } def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftR64:$imm))), (!cast(NAME # "d") FPR64:$Rn, vecshiftR64:$imm)>; } multiclass SIMDScalarRShiftDTied opc, string asm, SDPatternOperator OpNode = null_frag> { def d : BaseSIMDScalarShiftTied { let Inst{21-16} = imm{5-0}; } def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn), (i32 vecshiftR64:$imm))), (!cast(NAME # "d") FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>; } multiclass SIMDScalarLShiftD opc, string asm, SDPatternOperator OpNode> { def d : BaseSIMDScalarShift { let Inst{21-16} = imm{5-0}; } def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm))), (!cast(NAME # "d") FPR64:$Rn, vecshiftL64:$imm)>; } let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in multiclass SIMDScalarLShiftDTied opc, string asm> { def d : BaseSIMDScalarShiftTied { let Inst{21-16} = imm{5-0}; } } let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in multiclass SIMDScalarRShiftBHS opc, string asm, SDPatternOperator OpNode = null_frag> { def b : BaseSIMDScalarShift { let Inst{18-16} = imm{2-0}; } def h : BaseSIMDScalarShift { let Inst{19-16} = imm{3-0}; } def s : BaseSIMDScalarShift { let Inst{20-16} = imm{4-0}; } } multiclass SIMDScalarLShiftBHSD opc, string asm, SDPatternOperator OpNode> { def b : BaseSIMDScalarShift { let Inst{18-16} = imm{2-0}; } def h : BaseSIMDScalarShift { let Inst{19-16} = imm{3-0}; } def s : BaseSIMDScalarShift { let Inst{20-16} = imm{4-0}; } def d : BaseSIMDScalarShift { let Inst{21-16} = imm{5-0}; } def : Pat<(v1i64 (OpNode (v1i64 FPR64:$Rn), (i32 vecshiftL64:$imm))), (!cast(NAME # "d") FPR64:$Rn, vecshiftL64:$imm)>; } multiclass SIMDScalarRShiftBHSD opc, string asm> { def b : BaseSIMDScalarShift { let Inst{18-16} = imm{2-0}; } def h : BaseSIMDScalarShift { let Inst{19-16} = imm{3-0}; } def s : BaseSIMDScalarShift { let Inst{20-16} = imm{4-0}; } def d : BaseSIMDScalarShift { let Inst{21-16} = imm{5-0}; } } //---------------------------------------------------------------------------- // AdvSIMD vector x indexed element //---------------------------------------------------------------------------- let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDVectorShift opc, bits<7> fixed_imm, RegisterOperand dst_reg, RegisterOperand src_reg, Operand immtype, string asm, string dst_kind, string src_kind, list pattern> : I<(outs dst_reg:$Rd), (ins src_reg:$Rn, immtype:$imm), asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" # "|" # dst_kind # "\t$Rd, $Rn, $imm}", "", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-23} = 0b011110; let Inst{22-16} = fixed_imm; let Inst{15-11} = opc; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } let mayStore = 0, mayLoad = 0, hasSideEffects = 0 in class BaseSIMDVectorShiftTied opc, bits<7> fixed_imm, RegisterOperand vectype1, RegisterOperand vectype2, Operand immtype, string asm, string dst_kind, string src_kind, list pattern> : I<(outs vectype1:$dst), (ins vectype1:$Rd, vectype2:$Rn, immtype:$imm), asm, "{\t$Rd" # dst_kind # ", $Rn" # src_kind # ", $imm" # "|" # dst_kind # "\t$Rd, $Rn, $imm}", "$Rd = $dst", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-23} = 0b011110; let Inst{22-16} = fixed_imm; let Inst{15-11} = opc; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDVectorRShiftSD opc, string asm, Intrinsic OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?}, V64, V64, vecshiftR16, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4f16 V64:$Rn), (i32 imm:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftR16, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8f16 V128:$Rn), (i32 imm:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } } // Predicates = [HasNEON, HasFullFP16] def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?}, V64, V64, vecshiftR32, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2f32 V64:$Rn), (i32 imm:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftR32, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4f32 V128:$Rn), (i32 imm:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?}, V128, V128, vecshiftR64, asm, ".2d", ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2f64 V128:$Rn), (i32 imm:$imm)))]> { bits<6> imm; let Inst{21-16} = imm; } } multiclass SIMDVectorRShiftToFP opc, string asm, Intrinsic OpNode> { let Predicates = [HasNEON, HasFullFP16] in { def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?}, V64, V64, vecshiftR16, asm, ".4h", ".4h", [(set (v4f16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (i32 imm:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftR16, asm, ".8h", ".8h", [(set (v8f16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (i32 imm:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } } // Predicates = [HasNEON, HasFullFP16] def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?}, V64, V64, vecshiftR32, asm, ".2s", ".2s", [(set (v2f32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 imm:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftR32, asm, ".4s", ".4s", [(set (v4f32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 imm:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?}, V128, V128, vecshiftR64, asm, ".2d", ".2d", [(set (v2f64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 imm:$imm)))]> { bits<6> imm; let Inst{21-16} = imm; } } multiclass SIMDVectorRShiftNarrowBHS opc, string asm, SDPatternOperator OpNode> { def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?}, V64, V128, vecshiftR16Narrow, asm, ".8b", ".8h", [(set (v8i8 V64:$Rd), (OpNode (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))]> { bits<3> imm; let Inst{18-16} = imm; } def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?}, V128, V128, vecshiftR16Narrow, asm#"2", ".16b", ".8h", []> { bits<3> imm; let Inst{18-16} = imm; let hasSideEffects = 0; } def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?}, V64, V128, vecshiftR32Narrow, asm, ".4h", ".4s", [(set (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftR32Narrow, asm#"2", ".8h", ".4s", []> { bits<4> imm; let Inst{19-16} = imm; let hasSideEffects = 0; } def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?}, V64, V128, vecshiftR64Narrow, asm, ".2s", ".2d", [(set (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftR64Narrow, asm#"2", ".4s", ".2d", []> { bits<5> imm; let Inst{20-16} = imm; let hasSideEffects = 0; } // TableGen doesn't like patters w/ INSERT_SUBREG on the instructions // themselves, so put them here instead. // Patterns involving what's effectively an insert high and a normal // intrinsic, represented by CONCAT_VECTORS. def : Pat<(concat_vectors (v8i8 V64:$Rd),(OpNode (v8i16 V128:$Rn), vecshiftR16Narrow:$imm)), (!cast(NAME # "v16i8_shift") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn, vecshiftR16Narrow:$imm)>; def : Pat<(concat_vectors (v4i16 V64:$Rd), (OpNode (v4i32 V128:$Rn), vecshiftR32Narrow:$imm)), (!cast(NAME # "v8i16_shift") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn, vecshiftR32Narrow:$imm)>; def : Pat<(concat_vectors (v2i32 V64:$Rd), (OpNode (v2i64 V128:$Rn), vecshiftR64Narrow:$imm)), (!cast(NAME # "v4i32_shift") (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn, vecshiftR64Narrow:$imm)>; } multiclass SIMDVectorLShiftBHSD opc, string asm, SDPatternOperator OpNode> { def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?}, V64, V64, vecshiftL8, asm, ".8b", ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (i32 vecshiftL8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?}, V128, V128, vecshiftL8, asm, ".16b", ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (i32 vecshiftL8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?}, V64, V64, vecshiftL16, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (i32 vecshiftL16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftL16, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (i32 vecshiftL16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?}, V64, V64, vecshiftL32, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 vecshiftL32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftL32, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 vecshiftL32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?}, V128, V128, vecshiftL64, asm, ".2d", ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 vecshiftL64:$imm)))]> { bits<6> imm; let Inst{21-16} = imm; } } multiclass SIMDVectorRShiftBHSD opc, string asm, SDPatternOperator OpNode> { def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?}, V64, V64, vecshiftR8, asm, ".8b", ".8b", [(set (v8i8 V64:$Rd), (OpNode (v8i8 V64:$Rn), (i32 vecshiftR8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?}, V128, V128, vecshiftR8, asm, ".16b", ".16b", [(set (v16i8 V128:$Rd), (OpNode (v16i8 V128:$Rn), (i32 vecshiftR8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?}, V64, V64, vecshiftR16, asm, ".4h", ".4h", [(set (v4i16 V64:$Rd), (OpNode (v4i16 V64:$Rn), (i32 vecshiftR16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftR16, asm, ".8h", ".8h", [(set (v8i16 V128:$Rd), (OpNode (v8i16 V128:$Rn), (i32 vecshiftR16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?}, V64, V64, vecshiftR32, asm, ".2s", ".2s", [(set (v2i32 V64:$Rd), (OpNode (v2i32 V64:$Rn), (i32 vecshiftR32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftR32, asm, ".4s", ".4s", [(set (v4i32 V128:$Rd), (OpNode (v4i32 V128:$Rn), (i32 vecshiftR32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v2i64_shift : BaseSIMDVectorShift<1, U, opc, {1,?,?,?,?,?,?}, V128, V128, vecshiftR64, asm, ".2d", ".2d", [(set (v2i64 V128:$Rd), (OpNode (v2i64 V128:$Rn), (i32 vecshiftR64:$imm)))]> { bits<6> imm; let Inst{21-16} = imm; } } let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in multiclass SIMDVectorRShiftBHSDTied opc, string asm, SDPatternOperator OpNode = null_frag> { def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?}, V64, V64, vecshiftR8, asm, ".8b", ".8b", [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (i32 vecshiftR8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?}, V128, V128, vecshiftR8, asm, ".16b", ".16b", [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (i32 vecshiftR8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?}, V64, V64, vecshiftR16, asm, ".4h", ".4h", [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (i32 vecshiftR16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftR16, asm, ".8h", ".8h", [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (i32 vecshiftR16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?}, V64, V64, vecshiftR32, asm, ".2s", ".2s", [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (i32 vecshiftR32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftR32, asm, ".4s", ".4s", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (i32 vecshiftR32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?}, V128, V128, vecshiftR64, asm, ".2d", ".2d", [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn), (i32 vecshiftR64:$imm)))]> { bits<6> imm; let Inst{21-16} = imm; } } multiclass SIMDVectorLShiftBHSDTied opc, string asm, SDPatternOperator OpNode = null_frag> { def v8i8_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,0,1,?,?,?}, V64, V64, vecshiftL8, asm, ".8b", ".8b", [(set (v8i8 V64:$dst), (OpNode (v8i8 V64:$Rd), (v8i8 V64:$Rn), (i32 vecshiftL8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v16i8_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,0,1,?,?,?}, V128, V128, vecshiftL8, asm, ".16b", ".16b", [(set (v16i8 V128:$dst), (OpNode (v16i8 V128:$Rd), (v16i8 V128:$Rn), (i32 vecshiftL8:$imm)))]> { bits<3> imm; let Inst{18-16} = imm; } def v4i16_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,0,1,?,?,?,?}, V64, V64, vecshiftL16, asm, ".4h", ".4h", [(set (v4i16 V64:$dst), (OpNode (v4i16 V64:$Rd), (v4i16 V64:$Rn), (i32 vecshiftL16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftL16, asm, ".8h", ".8h", [(set (v8i16 V128:$dst), (OpNode (v8i16 V128:$Rd), (v8i16 V128:$Rn), (i32 vecshiftL16:$imm)))]> { bits<4> imm; let Inst{19-16} = imm; } def v2i32_shift : BaseSIMDVectorShiftTied<0, U, opc, {0,1,?,?,?,?,?}, V64, V64, vecshiftL32, asm, ".2s", ".2s", [(set (v2i32 V64:$dst), (OpNode (v2i32 V64:$Rd), (v2i32 V64:$Rn), (i32 vecshiftL32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShiftTied<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftL32, asm, ".4s", ".4s", [(set (v4i32 V128:$dst), (OpNode (v4i32 V128:$Rd), (v4i32 V128:$Rn), (i32 vecshiftL32:$imm)))]> { bits<5> imm; let Inst{20-16} = imm; } def v2i64_shift : BaseSIMDVectorShiftTied<1, U, opc, {1,?,?,?,?,?,?}, V128, V128, vecshiftL64, asm, ".2d", ".2d", [(set (v2i64 V128:$dst), (OpNode (v2i64 V128:$Rd), (v2i64 V128:$Rn), (i32 vecshiftL64:$imm)))]> { bits<6> imm; let Inst{21-16} = imm; } } multiclass SIMDVectorLShiftLongBHSD opc, string asm, SDPatternOperator OpNode> { def v8i8_shift : BaseSIMDVectorShift<0, U, opc, {0,0,0,1,?,?,?}, V128, V64, vecshiftL8, asm, ".8h", ".8b", [(set (v8i16 V128:$Rd), (OpNode (v8i8 V64:$Rn), vecshiftL8:$imm))]> { bits<3> imm; let Inst{18-16} = imm; } def v16i8_shift : BaseSIMDVectorShift<1, U, opc, {0,0,0,1,?,?,?}, V128, V128, vecshiftL8, asm#"2", ".8h", ".16b", [(set (v8i16 V128:$Rd), (OpNode (extract_high_v16i8 (v16i8 V128:$Rn)), vecshiftL8:$imm))]> { bits<3> imm; let Inst{18-16} = imm; } def v4i16_shift : BaseSIMDVectorShift<0, U, opc, {0,0,1,?,?,?,?}, V128, V64, vecshiftL16, asm, ".4s", ".4h", [(set (v4i32 V128:$Rd), (OpNode (v4i16 V64:$Rn), vecshiftL16:$imm))]> { bits<4> imm; let Inst{19-16} = imm; } def v8i16_shift : BaseSIMDVectorShift<1, U, opc, {0,0,1,?,?,?,?}, V128, V128, vecshiftL16, asm#"2", ".4s", ".8h", [(set (v4i32 V128:$Rd), (OpNode (extract_high_v8i16 (v8i16 V128:$Rn)), vecshiftL16:$imm))]> { bits<4> imm; let Inst{19-16} = imm; } def v2i32_shift : BaseSIMDVectorShift<0, U, opc, {0,1,?,?,?,?,?}, V128, V64, vecshiftL32, asm, ".2d", ".2s", [(set (v2i64 V128:$Rd), (OpNode (v2i32 V64:$Rn), vecshiftL32:$imm))]> { bits<5> imm; let Inst{20-16} = imm; } def v4i32_shift : BaseSIMDVectorShift<1, U, opc, {0,1,?,?,?,?,?}, V128, V128, vecshiftL32, asm#"2", ".2d", ".4s", [(set (v2i64 V128:$Rd), (OpNode (extract_high_v4i32 (v4i32 V128:$Rn)), vecshiftL32:$imm))]> { bits<5> imm; let Inst{20-16} = imm; } } //--- // Vector load/store //--- // SIMD ldX/stX no-index memory references don't allow the optional // ", #0" constant and handle post-indexing explicitly, so we use // a more specialized parse method for them. Otherwise, it's the same as // the general GPR64sp handling. class BaseSIMDLdSt opcode, bits<2> size, string asm, dag oops, dag iops, list pattern> : I { bits<5> Vt; bits<5> Rn; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-23} = 0b0011000; let Inst{22} = L; let Inst{21-16} = 0b000000; let Inst{15-12} = opcode; let Inst{11-10} = size; let Inst{9-5} = Rn; let Inst{4-0} = Vt; } class BaseSIMDLdStPost opcode, bits<2> size, string asm, dag oops, dag iops> : I { bits<5> Vt; bits<5> Rn; bits<5> Xm; let Inst{31} = 0; let Inst{30} = Q; let Inst{29-23} = 0b0011001; let Inst{22} = L; let Inst{21} = 0; let Inst{20-16} = Xm; let Inst{15-12} = opcode; let Inst{11-10} = size; let Inst{9-5} = Rn; let Inst{4-0} = Vt; } // The immediate form of AdvSIMD post-indexed addressing is encoded with // register post-index addressing from the zero register. multiclass SIMDLdStAliases { // E.g. "ld1 { v0.8b, v1.8b }, [x1], #16" // "ld1\t$Vt, [$Rn], #16" // may get mapped to // (LD1Twov8b_POST VecListTwo8b:$Vt, GPR64sp:$Rn, XZR) def : InstAlias(BaseName # Count # "v" # layout # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # layout):$Vt, XZR), 1>; // E.g. "ld1.8b { v0, v1 }, [x1], #16" // "ld1.8b\t$Vt, [$Rn], #16" // may get mapped to // (LD1Twov8b_POST VecListTwo64:$Vt, GPR64sp:$Rn, XZR) def : InstAlias(BaseName # Count # "v" # layout # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # Size):$Vt, XZR), 0>; // E.g. "ld1.8b { v0, v1 }, [x1]" // "ld1\t$Vt, [$Rn]" // may get mapped to // (LD1Twov8b VecListTwo64:$Vt, GPR64sp:$Rn) def : InstAlias(BaseName # Count # "v" # layout) !cast("VecList" # Count # Size):$Vt, GPR64sp:$Rn), 0>; // E.g. "ld1.8b { v0, v1 }, [x1], x2" // "ld1\t$Vt, [$Rn], $Xm" // may get mapped to // (LD1Twov8b_POST VecListTwo64:$Vt, GPR64sp:$Rn, GPR64pi8:$Xm) def : InstAlias(BaseName # Count # "v" # layout # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # Size):$Vt, !cast("GPR64pi" # Offset):$Xm), 0>; } multiclass BaseSIMDLdN opcode> { let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in { def v16b: BaseSIMDLdSt<1, 1, opcode, 0b00, asm, (outs !cast(veclist # "16b"):$Vt), (ins GPR64sp:$Rn), []>; def v8h : BaseSIMDLdSt<1, 1, opcode, 0b01, asm, (outs !cast(veclist # "8h"):$Vt), (ins GPR64sp:$Rn), []>; def v4s : BaseSIMDLdSt<1, 1, opcode, 0b10, asm, (outs !cast(veclist # "4s"):$Vt), (ins GPR64sp:$Rn), []>; def v2d : BaseSIMDLdSt<1, 1, opcode, 0b11, asm, (outs !cast(veclist # "2d"):$Vt), (ins GPR64sp:$Rn), []>; def v8b : BaseSIMDLdSt<0, 1, opcode, 0b00, asm, (outs !cast(veclist # "8b"):$Vt), (ins GPR64sp:$Rn), []>; def v4h : BaseSIMDLdSt<0, 1, opcode, 0b01, asm, (outs !cast(veclist # "4h"):$Vt), (ins GPR64sp:$Rn), []>; def v2s : BaseSIMDLdSt<0, 1, opcode, 0b10, asm, (outs !cast(veclist # "2s"):$Vt), (ins GPR64sp:$Rn), []>; def v16b_POST: BaseSIMDLdStPost<1, 1, opcode, 0b00, asm, (outs GPR64sp:$wback, !cast(veclist # "16b"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v8h_POST : BaseSIMDLdStPost<1, 1, opcode, 0b01, asm, (outs GPR64sp:$wback, !cast(veclist # "8h"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v4s_POST : BaseSIMDLdStPost<1, 1, opcode, 0b10, asm, (outs GPR64sp:$wback, !cast(veclist # "4s"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v2d_POST : BaseSIMDLdStPost<1, 1, opcode, 0b11, asm, (outs GPR64sp:$wback, !cast(veclist # "2d"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v8b_POST : BaseSIMDLdStPost<0, 1, opcode, 0b00, asm, (outs GPR64sp:$wback, !cast(veclist # "8b"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; def v4h_POST : BaseSIMDLdStPost<0, 1, opcode, 0b01, asm, (outs GPR64sp:$wback, !cast(veclist # "4h"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; def v2s_POST : BaseSIMDLdStPost<0, 1, opcode, 0b10, asm, (outs GPR64sp:$wback, !cast(veclist # "2s"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; } defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; } // Only ld1/st1 has a v1d version. multiclass BaseSIMDStN opcode> { let hasSideEffects = 0, mayStore = 1, mayLoad = 0 in { def v16b : BaseSIMDLdSt<1, 0, opcode, 0b00, asm, (outs), (ins !cast(veclist # "16b"):$Vt, GPR64sp:$Rn), []>; def v8h : BaseSIMDLdSt<1, 0, opcode, 0b01, asm, (outs), (ins !cast(veclist # "8h"):$Vt, GPR64sp:$Rn), []>; def v4s : BaseSIMDLdSt<1, 0, opcode, 0b10, asm, (outs), (ins !cast(veclist # "4s"):$Vt, GPR64sp:$Rn), []>; def v2d : BaseSIMDLdSt<1, 0, opcode, 0b11, asm, (outs), (ins !cast(veclist # "2d"):$Vt, GPR64sp:$Rn), []>; def v8b : BaseSIMDLdSt<0, 0, opcode, 0b00, asm, (outs), (ins !cast(veclist # "8b"):$Vt, GPR64sp:$Rn), []>; def v4h : BaseSIMDLdSt<0, 0, opcode, 0b01, asm, (outs), (ins !cast(veclist # "4h"):$Vt, GPR64sp:$Rn), []>; def v2s : BaseSIMDLdSt<0, 0, opcode, 0b10, asm, (outs), (ins !cast(veclist # "2s"):$Vt, GPR64sp:$Rn), []>; def v16b_POST : BaseSIMDLdStPost<1, 0, opcode, 0b00, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "16b"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v8h_POST : BaseSIMDLdStPost<1, 0, opcode, 0b01, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "8h"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v4s_POST : BaseSIMDLdStPost<1, 0, opcode, 0b10, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "4s"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v2d_POST : BaseSIMDLdStPost<1, 0, opcode, 0b11, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "2d"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset128):$Xm)>; def v8b_POST : BaseSIMDLdStPost<0, 0, opcode, 0b00, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "8b"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; def v4h_POST : BaseSIMDLdStPost<0, 0, opcode, 0b01, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "4h"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; def v2s_POST : BaseSIMDLdStPost<0, 0, opcode, 0b10, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "2s"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; } defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; defm : SIMDLdStAliases; } multiclass BaseSIMDLd1 opcode> : BaseSIMDLdN { // LD1 instructions have extra "1d" variants. let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in { def v1d : BaseSIMDLdSt<0, 1, opcode, 0b11, asm, (outs !cast(veclist # "1d"):$Vt), (ins GPR64sp:$Rn), []>; def v1d_POST : BaseSIMDLdStPost<0, 1, opcode, 0b11, asm, (outs GPR64sp:$wback, !cast(veclist # "1d"):$Vt), (ins GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; } defm : SIMDLdStAliases; } multiclass BaseSIMDSt1 opcode> : BaseSIMDStN { // ST1 instructions have extra "1d" variants. let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in { def v1d : BaseSIMDLdSt<0, 0, opcode, 0b11, asm, (outs), (ins !cast(veclist # "1d"):$Vt, GPR64sp:$Rn), []>; def v1d_POST : BaseSIMDLdStPost<0, 0, opcode, 0b11, asm, (outs GPR64sp:$wback), (ins !cast(veclist # "1d"):$Vt, GPR64sp:$Rn, !cast("GPR64pi" # Offset64):$Xm)>; } defm : SIMDLdStAliases; } multiclass SIMDLd1Multiple { defm One : BaseSIMDLd1; defm Two : BaseSIMDLd1; defm Three : BaseSIMDLd1; defm Four : BaseSIMDLd1; } multiclass SIMDSt1Multiple { defm One : BaseSIMDSt1; defm Two : BaseSIMDSt1; defm Three : BaseSIMDSt1; defm Four : BaseSIMDSt1; } multiclass SIMDLd2Multiple { defm Two : BaseSIMDLdN; } multiclass SIMDSt2Multiple { defm Two : BaseSIMDStN; } multiclass SIMDLd3Multiple { defm Three : BaseSIMDLdN; } multiclass SIMDSt3Multiple { defm Three : BaseSIMDStN; } multiclass SIMDLd4Multiple { defm Four : BaseSIMDLdN; } multiclass SIMDSt4Multiple { defm Four : BaseSIMDStN; } //--- // AdvSIMD Load/store single-element //--- class BaseSIMDLdStSingle opcode, string asm, string operands, string cst, dag oops, dag iops, list pattern> : I { bits<5> Vt; bits<5> Rn; let Inst{31} = 0; let Inst{29-24} = 0b001101; let Inst{22} = L; let Inst{21} = R; let Inst{15-13} = opcode; let Inst{9-5} = Rn; let Inst{4-0} = Vt; } class BaseSIMDLdStSingleTied opcode, string asm, string operands, string cst, dag oops, dag iops, list pattern> : I { bits<5> Vt; bits<5> Rn; let Inst{31} = 0; let Inst{29-24} = 0b001101; let Inst{22} = L; let Inst{21} = R; let Inst{15-13} = opcode; let Inst{9-5} = Rn; let Inst{4-0} = Vt; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in class BaseSIMDLdR opcode, bit S, bits<2> size, string asm, DAGOperand listtype> : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, [$Rn]", "", (outs listtype:$Vt), (ins GPR64sp:$Rn), []> { let Inst{30} = Q; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = S; let Inst{11-10} = size; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in class BaseSIMDLdRPost opcode, bit S, bits<2> size, string asm, DAGOperand listtype, DAGOperand GPR64pi> : BaseSIMDLdStSingle<1, R, opcode, asm, "\t$Vt, [$Rn], $Xm", "$Rn = $wback", (outs GPR64sp:$wback, listtype:$Vt), (ins GPR64sp:$Rn, GPR64pi:$Xm), []> { bits<5> Xm; let Inst{30} = Q; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = S; let Inst{11-10} = size; } multiclass SIMDLdrAliases { // E.g. "ld1r { v0.8b }, [x1], #1" // "ld1r.8b\t$Vt, [$Rn], #1" // may get mapped to // (LD1Rv8b_POST VecListOne8b:$Vt, GPR64sp:$Rn, XZR) def : InstAlias(BaseName # "v" # layout # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # layout):$Vt, XZR), 1>; // E.g. "ld1r.8b { v0 }, [x1], #1" // "ld1r.8b\t$Vt, [$Rn], #1" // may get mapped to // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, XZR) def : InstAlias(BaseName # "v" # layout # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # Size):$Vt, XZR), 0>; // E.g. "ld1r.8b { v0 }, [x1]" // "ld1r.8b\t$Vt, [$Rn]" // may get mapped to // (LD1Rv8b VecListOne64:$Vt, GPR64sp:$Rn) def : InstAlias(BaseName # "v" # layout) !cast("VecList" # Count # Size):$Vt, GPR64sp:$Rn), 0>; // E.g. "ld1r.8b { v0 }, [x1], x2" // "ld1r.8b\t$Vt, [$Rn], $Xm" // may get mapped to // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, GPR64pi1:$Xm) def : InstAlias(BaseName # "v" # layout # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # Size):$Vt, !cast("GPR64pi" # Offset):$Xm), 0>; } multiclass SIMDLdR opcode, bit S, string asm, string Count, int Offset1, int Offset2, int Offset4, int Offset8> { def v8b : BaseSIMDLdR<0, R, opcode, S, 0b00, asm, !cast("VecList" # Count # "8b")>; def v16b: BaseSIMDLdR<1, R, opcode, S, 0b00, asm, !cast("VecList" # Count #"16b")>; def v4h : BaseSIMDLdR<0, R, opcode, S, 0b01, asm, !cast("VecList" # Count #"4h")>; def v8h : BaseSIMDLdR<1, R, opcode, S, 0b01, asm, !cast("VecList" # Count #"8h")>; def v2s : BaseSIMDLdR<0, R, opcode, S, 0b10, asm, !cast("VecList" # Count #"2s")>; def v4s : BaseSIMDLdR<1, R, opcode, S, 0b10, asm, !cast("VecList" # Count #"4s")>; def v1d : BaseSIMDLdR<0, R, opcode, S, 0b11, asm, !cast("VecList" # Count #"1d")>; def v2d : BaseSIMDLdR<1, R, opcode, S, 0b11, asm, !cast("VecList" # Count #"2d")>; def v8b_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b00, asm, !cast("VecList" # Count # "8b"), !cast("GPR64pi" # Offset1)>; def v16b_POST: BaseSIMDLdRPost<1, R, opcode, S, 0b00, asm, !cast("VecList" # Count # "16b"), !cast("GPR64pi" # Offset1)>; def v4h_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b01, asm, !cast("VecList" # Count # "4h"), !cast("GPR64pi" # Offset2)>; def v8h_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b01, asm, !cast("VecList" # Count # "8h"), !cast("GPR64pi" # Offset2)>; def v2s_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b10, asm, !cast("VecList" # Count # "2s"), !cast("GPR64pi" # Offset4)>; def v4s_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b10, asm, !cast("VecList" # Count # "4s"), !cast("GPR64pi" # Offset4)>; def v1d_POST : BaseSIMDLdRPost<0, R, opcode, S, 0b11, asm, !cast("VecList" # Count # "1d"), !cast("GPR64pi" # Offset8)>; def v2d_POST : BaseSIMDLdRPost<1, R, opcode, S, 0b11, asm, !cast("VecList" # Count # "2d"), !cast("GPR64pi" # Offset8)>; defm : SIMDLdrAliases; defm : SIMDLdrAliases; defm : SIMDLdrAliases; defm : SIMDLdrAliases; defm : SIMDLdrAliases; defm : SIMDLdrAliases; defm : SIMDLdrAliases; defm : SIMDLdrAliases; } class SIMDLdStSingleB opcode, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingle { // idx encoded in Q:S:size fields. bits<4> idx; let Inst{30} = idx{3}; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = idx{2}; let Inst{11-10} = idx{1-0}; } class SIMDLdStSingleBTied opcode, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingleTied { // idx encoded in Q:S:size fields. bits<4> idx; let Inst{30} = idx{3}; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = idx{2}; let Inst{11-10} = idx{1-0}; } class SIMDLdStSingleBPost opcode, string asm, dag oops, dag iops> : BaseSIMDLdStSingle { // idx encoded in Q:S:size fields. bits<4> idx; bits<5> Xm; let Inst{30} = idx{3}; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = idx{2}; let Inst{11-10} = idx{1-0}; } class SIMDLdStSingleBTiedPost opcode, string asm, dag oops, dag iops> : BaseSIMDLdStSingleTied { // idx encoded in Q:S:size fields. bits<4> idx; bits<5> Xm; let Inst{30} = idx{3}; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = idx{2}; let Inst{11-10} = idx{1-0}; } class SIMDLdStSingleH opcode, bit size, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingle { // idx encoded in Q:S:size<1> fields. bits<3> idx; let Inst{30} = idx{2}; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = idx{1}; let Inst{11} = idx{0}; let Inst{10} = size; } class SIMDLdStSingleHTied opcode, bit size, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingleTied { // idx encoded in Q:S:size<1> fields. bits<3> idx; let Inst{30} = idx{2}; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = idx{1}; let Inst{11} = idx{0}; let Inst{10} = size; } class SIMDLdStSingleHPost opcode, bit size, string asm, dag oops, dag iops> : BaseSIMDLdStSingle { // idx encoded in Q:S:size<1> fields. bits<3> idx; bits<5> Xm; let Inst{30} = idx{2}; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = idx{1}; let Inst{11} = idx{0}; let Inst{10} = size; } class SIMDLdStSingleHTiedPost opcode, bit size, string asm, dag oops, dag iops> : BaseSIMDLdStSingleTied { // idx encoded in Q:S:size<1> fields. bits<3> idx; bits<5> Xm; let Inst{30} = idx{2}; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = idx{1}; let Inst{11} = idx{0}; let Inst{10} = size; } class SIMDLdStSingleS opcode, bits<2> size, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingle { // idx encoded in Q:S fields. bits<2> idx; let Inst{30} = idx{1}; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = idx{0}; let Inst{11-10} = size; } class SIMDLdStSingleSTied opcode, bits<2> size, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingleTied { // idx encoded in Q:S fields. bits<2> idx; let Inst{30} = idx{1}; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = idx{0}; let Inst{11-10} = size; } class SIMDLdStSingleSPost opcode, bits<2> size, string asm, dag oops, dag iops> : BaseSIMDLdStSingle { // idx encoded in Q:S fields. bits<2> idx; bits<5> Xm; let Inst{30} = idx{1}; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = idx{0}; let Inst{11-10} = size; } class SIMDLdStSingleSTiedPost opcode, bits<2> size, string asm, dag oops, dag iops> : BaseSIMDLdStSingleTied { // idx encoded in Q:S fields. bits<2> idx; bits<5> Xm; let Inst{30} = idx{1}; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = idx{0}; let Inst{11-10} = size; } class SIMDLdStSingleD opcode, bits<2> size, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingle { // idx encoded in Q field. bits<1> idx; let Inst{30} = idx; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = 0; let Inst{11-10} = size; } class SIMDLdStSingleDTied opcode, bits<2> size, string asm, dag oops, dag iops, list pattern> : BaseSIMDLdStSingleTied { // idx encoded in Q field. bits<1> idx; let Inst{30} = idx; let Inst{23} = 0; let Inst{20-16} = 0b00000; let Inst{12} = 0; let Inst{11-10} = size; } class SIMDLdStSingleDPost opcode, bits<2> size, string asm, dag oops, dag iops> : BaseSIMDLdStSingle { // idx encoded in Q field. bits<1> idx; bits<5> Xm; let Inst{30} = idx; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = 0; let Inst{11-10} = size; } class SIMDLdStSingleDTiedPost opcode, bits<2> size, string asm, dag oops, dag iops> : BaseSIMDLdStSingleTied { // idx encoded in Q field. bits<1> idx; bits<5> Xm; let Inst{30} = idx; let Inst{23} = 1; let Inst{20-16} = Xm; let Inst{12} = 0; let Inst{11-10} = size; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in multiclass SIMDLdSingleBTied opcode, string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i8 : SIMDLdStSingleBTied<1, R, opcode, asm, (outs listtype:$dst), (ins listtype:$Vt, VectorIndexB:$idx, GPR64sp:$Rn), []>; def i8_POST : SIMDLdStSingleBTiedPost<1, R, opcode, asm, (outs GPR64sp:$wback, listtype:$dst), (ins listtype:$Vt, VectorIndexB:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in multiclass SIMDLdSingleHTied opcode, bit size, string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i16 : SIMDLdStSingleHTied<1, R, opcode, size, asm, (outs listtype:$dst), (ins listtype:$Vt, VectorIndexH:$idx, GPR64sp:$Rn), []>; def i16_POST : SIMDLdStSingleHTiedPost<1, R, opcode, size, asm, (outs GPR64sp:$wback, listtype:$dst), (ins listtype:$Vt, VectorIndexH:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in multiclass SIMDLdSingleSTied opcode, bits<2> size,string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i32 : SIMDLdStSingleSTied<1, R, opcode, size, asm, (outs listtype:$dst), (ins listtype:$Vt, VectorIndexS:$idx, GPR64sp:$Rn), []>; def i32_POST : SIMDLdStSingleSTiedPost<1, R, opcode, size, asm, (outs GPR64sp:$wback, listtype:$dst), (ins listtype:$Vt, VectorIndexS:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in multiclass SIMDLdSingleDTied opcode, bits<2> size, string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i64 : SIMDLdStSingleDTied<1, R, opcode, size, asm, (outs listtype:$dst), (ins listtype:$Vt, VectorIndexD:$idx, GPR64sp:$Rn), []>; def i64_POST : SIMDLdStSingleDTiedPost<1, R, opcode, size, asm, (outs GPR64sp:$wback, listtype:$dst), (ins listtype:$Vt, VectorIndexD:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in multiclass SIMDStSingleB opcode, string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i8 : SIMDLdStSingleB<0, R, opcode, asm, (outs), (ins listtype:$Vt, VectorIndexB:$idx, GPR64sp:$Rn), []>; def i8_POST : SIMDLdStSingleBPost<0, R, opcode, asm, (outs GPR64sp:$wback), (ins listtype:$Vt, VectorIndexB:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in multiclass SIMDStSingleH opcode, bit size, string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i16 : SIMDLdStSingleH<0, R, opcode, size, asm, (outs), (ins listtype:$Vt, VectorIndexH:$idx, GPR64sp:$Rn), []>; def i16_POST : SIMDLdStSingleHPost<0, R, opcode, size, asm, (outs GPR64sp:$wback), (ins listtype:$Vt, VectorIndexH:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in multiclass SIMDStSingleS opcode, bits<2> size,string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i32 : SIMDLdStSingleS<0, R, opcode, size, asm, (outs), (ins listtype:$Vt, VectorIndexS:$idx, GPR64sp:$Rn), []>; def i32_POST : SIMDLdStSingleSPost<0, R, opcode, size, asm, (outs GPR64sp:$wback), (ins listtype:$Vt, VectorIndexS:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } let mayLoad = 0, mayStore = 1, hasSideEffects = 0 in multiclass SIMDStSingleD opcode, bits<2> size, string asm, RegisterOperand listtype, RegisterOperand GPR64pi> { def i64 : SIMDLdStSingleD<0, R, opcode, size, asm, (outs), (ins listtype:$Vt, VectorIndexD:$idx, GPR64sp:$Rn), []>; def i64_POST : SIMDLdStSingleDPost<0, R, opcode, size, asm, (outs GPR64sp:$wback), (ins listtype:$Vt, VectorIndexD:$idx, GPR64sp:$Rn, GPR64pi:$Xm)>; } multiclass SIMDLdStSingleAliases { // E.g. "ld1 { v0.8b }[0], [x1], #1" // "ld1\t$Vt, [$Rn], #1" // may get mapped to // (LD1Rv8b_POST VecListOne8b:$Vt, GPR64sp:$Rn, XZR) def : InstAlias(NAME # Type # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # layout):$Vt, idxtype:$idx, XZR), 1>; // E.g. "ld1.8b { v0 }[0], [x1], #1" // "ld1.8b\t$Vt, [$Rn], #1" // may get mapped to // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, XZR) def : InstAlias(NAME # Type # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # "128"):$Vt, idxtype:$idx, XZR), 0>; // E.g. "ld1.8b { v0 }[0], [x1]" // "ld1.8b\t$Vt, [$Rn]" // may get mapped to // (LD1Rv8b VecListOne64:$Vt, GPR64sp:$Rn) def : InstAlias(NAME # Type) !cast("VecList" # Count # "128"):$Vt, idxtype:$idx, GPR64sp:$Rn), 0>; // E.g. "ld1.8b { v0 }[0], [x1], x2" // "ld1.8b\t$Vt, [$Rn], $Xm" // may get mapped to // (LD1Rv8b_POST VecListOne64:$Vt, GPR64sp:$Rn, GPR64pi1:$Xm) def : InstAlias(NAME # Type # "_POST") GPR64sp:$Rn, !cast("VecList" # Count # "128"):$Vt, idxtype:$idx, !cast("GPR64pi" # Offset):$Xm), 0>; } multiclass SIMDLdSt1SingleAliases { defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; } multiclass SIMDLdSt2SingleAliases { defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; } multiclass SIMDLdSt3SingleAliases { defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; } multiclass SIMDLdSt4SingleAliases { defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; defm "" : SIMDLdStSingleAliases; } } // end of 'let Predicates = [HasNEON]' //---------------------------------------------------------------------------- // AdvSIMD v8.1 Rounding Double Multiply Add/Subtract //---------------------------------------------------------------------------- let Predicates = [HasNEON, HasRDM] in { class BaseSIMDThreeSameVectorTiedR0 size, bits<5> opcode, RegisterOperand regtype, string asm, string kind, list pattern> : BaseSIMDThreeSameVectorTied { } multiclass SIMDThreeSameVectorSQRDMLxHTiedHS opc, string asm, SDPatternOperator op> { def v4i16 : BaseSIMDThreeSameVectorTiedR0<0, U, 0b01, opc, V64, asm, ".4h", [(set (v4i16 V64:$dst), (v4i16 (op (v4i16 V64:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))))]>; def v8i16 : BaseSIMDThreeSameVectorTiedR0<1, U, 0b01, opc, V128, asm, ".8h", [(set (v8i16 V128:$dst), (v8i16 (op (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 V128:$Rm))))]>; def v2i32 : BaseSIMDThreeSameVectorTiedR0<0, U, 0b10, opc, V64, asm, ".2s", [(set (v2i32 V64:$dst), (v2i32 (op (v2i32 V64:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))))]>; def v4i32 : BaseSIMDThreeSameVectorTiedR0<1, U, 0b10, opc, V128, asm, ".4s", [(set (v4i32 V128:$dst), (v4i32 (op (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 V128:$Rm))))]>; } multiclass SIMDIndexedSQRDMLxHSDTied opc, string asm, SDPatternOperator op> { def v4i16_indexed : BaseSIMDIndexedTied<0, U, 0, 0b01, opc, V64, V64, V128_lo, VectorIndexH, asm, ".4h", ".4h", ".4h", ".h", [(set (v4i16 V64:$dst), (v4i16 (op (v4i16 V64:$Rd), (v4i16 V64:$Rn), (dup_v8i16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v8i16_indexed : BaseSIMDIndexedTied<1, U, 0, 0b01, opc, V128, V128, V128_lo, VectorIndexH, asm, ".8h", ".8h", ".8h", ".h", [(set (v8i16 V128:$dst), (v8i16 (op (v8i16 V128:$Rd), (v8i16 V128:$Rn), (v8i16 (AArch64duplane16 (v8i16 V128_lo:$Rm), VectorIndexH:$idx)))))]> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v2i32_indexed : BaseSIMDIndexedTied<0, U, 0, 0b10, opc, V64, V64, V128, VectorIndexS, asm, ".2s", ".2s", ".2s", ".s", [(set (v2i32 V64:$dst), (v2i32 (op (v2i32 V64:$Rd), (v2i32 V64:$Rn), (dup_v4i32 (v4i32 V128:$Rm), VectorIndexS:$idx))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v4i32_indexed : BaseSIMDIndexedTied<1, U, 0, 0b10, opc, V128, V128, V128, VectorIndexS, asm, ".4s", ".4s", ".4s", ".s", [(set (v4i32 V128:$dst), (v4i32 (op (v4i32 V128:$Rd), (v4i32 V128:$Rn), (v4i32 (AArch64duplane32 (v4i32 V128:$Rm), VectorIndexS:$idx)))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } def v1i16_indexed : BaseSIMDIndexedTied<1, U, 1, 0b01, opc, FPR16Op, FPR16Op, V128_lo, VectorIndexH, asm, ".h", "", "", ".h", []> { bits<3> idx; let Inst{11} = idx{2}; let Inst{21} = idx{1}; let Inst{20} = idx{0}; } def v1i32_indexed : BaseSIMDIndexedTied<1, U, 1, 0b10, opc, FPR32Op, FPR32Op, V128, VectorIndexS, asm, ".s", "", "", ".s", [(set (i32 FPR32Op:$dst), (i32 (op (i32 FPR32Op:$Rd), (i32 FPR32Op:$Rn), (i32 (vector_extract (v4i32 V128:$Rm), VectorIndexS:$idx)))))]> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } } // let Predicates = [HasNeon, HasRDM] //---------------------------------------------------------------------------- // ARMv8.3 Complex ADD/MLA instructions //---------------------------------------------------------------------------- class ComplexRotationOperand : AsmOperandClass { let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">"; let DiagnosticType = "InvalidComplexRotation" # Type; let Name = "ComplexRotation" # Type; } def complexrotateop : Operand, TImmLeaf= 0 && Imm <= 270; }], SDNodeXFormgetTargetConstant((N->getSExtValue() / 90), SDLoc(N), MVT::i32); }]>> { let ParserMatchClass = ComplexRotationOperand<90, 0, "Even">; let PrintMethod = "printComplexRotationOp<90, 0>"; } def complexrotateopodd : Operand, TImmLeaf= 0 && Imm <= 270; }], SDNodeXFormgetTargetConstant(((N->getSExtValue() - 90) / 180), SDLoc(N), MVT::i32); }]>> { let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd">; let PrintMethod = "printComplexRotationOp<180, 90>"; } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDThreeSameVectorComplex size, bits<3> opcode, RegisterOperand regtype, Operand rottype, string asm, string kind, list pattern> : I<(outs regtype:$Rd), (ins regtype:$Rn, regtype:$Rm, rottype:$rot), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $rot" "|" # kind # "\t$Rd, $Rn, $Rm, $rot}", "", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<1> rot; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21} = 0; let Inst{20-16} = Rm; let Inst{15-13} = opcode; // Non-tied version (FCADD) only has one rotation bit let Inst{12} = rot; let Inst{11} = 0; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } //8.3 CompNum - Floating-point complex number support multiclass SIMDThreeSameVectorComplexHSD opcode, Operand rottype, string asm, SDPatternOperator OpNode>{ let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDThreeSameVectorComplex<0, U, 0b01, opcode, V64, rottype, asm, ".4h", [(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn), (v4f16 V64:$Rm), (i32 rottype:$rot)))]>; def v8f16 : BaseSIMDThreeSameVectorComplex<1, U, 0b01, opcode, V128, rottype, asm, ".8h", [(set (v8f16 V128:$dst), (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn), (v8f16 V128:$Rm), (i32 rottype:$rot)))]>; } let Predicates = [HasComplxNum, HasNEON] in { def v2f32 : BaseSIMDThreeSameVectorComplex<0, U, 0b10, opcode, V64, rottype, asm, ".2s", [(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm), (i32 rottype:$rot)))]>; def v4f32 : BaseSIMDThreeSameVectorComplex<1, U, 0b10, opcode, V128, rottype, asm, ".4s", [(set (v4f32 V128:$dst), (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm), (i32 rottype:$rot)))]>; def v2f64 : BaseSIMDThreeSameVectorComplex<1, U, 0b11, opcode, V128, rottype, asm, ".2d", [(set (v2f64 V128:$dst), (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm), (i32 rottype:$rot)))]>; } } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDThreeSameVectorTiedComplex size, bits<3> opcode, RegisterOperand regtype, Operand rottype, string asm, string kind, list pattern> : I<(outs regtype:$dst), (ins regtype:$Rd, regtype:$Rn, regtype:$Rm, rottype:$rot), asm, "{\t$Rd" # kind # ", $Rn" # kind # ", $Rm" # kind # ", $rot" "|" # kind # "\t$Rd, $Rn, $Rm, $rot}", "$Rd = $dst", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<2> rot; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28-24} = 0b01110; let Inst{23-22} = size; let Inst{21} = 0; let Inst{20-16} = Rm; let Inst{15-13} = opcode; let Inst{12-11} = rot; let Inst{10} = 1; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } multiclass SIMDThreeSameVectorTiedComplexHSD opcode, Operand rottype, string asm, SDPatternOperator OpNode> { let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in { def v4f16 : BaseSIMDThreeSameVectorTiedComplex<0, U, 0b01, opcode, V64, rottype, asm, ".4h", [(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn), (v4f16 V64:$Rm), (i32 rottype:$rot)))]>; def v8f16 : BaseSIMDThreeSameVectorTiedComplex<1, U, 0b01, opcode, V128, rottype, asm, ".8h", [(set (v8f16 V128:$dst), (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn), (v8f16 V128:$Rm), (i32 rottype:$rot)))]>; } let Predicates = [HasComplxNum, HasNEON] in { def v2f32 : BaseSIMDThreeSameVectorTiedComplex<0, U, 0b10, opcode, V64, rottype, asm, ".2s", [(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn), (v2f32 V64:$Rm), (i32 rottype:$rot)))]>; def v4f32 : BaseSIMDThreeSameVectorTiedComplex<1, U, 0b10, opcode, V128, rottype, asm, ".4s", [(set (v4f32 V128:$dst), (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn), (v4f32 V128:$Rm), (i32 rottype:$rot)))]>; def v2f64 : BaseSIMDThreeSameVectorTiedComplex<1, U, 0b11, opcode, V128, rottype, asm, ".2d", [(set (v2f64 V128:$dst), (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn), (v2f64 V128:$Rm), (i32 rottype:$rot)))]>; } } let mayLoad = 0, mayStore = 0, hasSideEffects = 0, mayRaiseFPException = 1, Uses = [FPCR] in class BaseSIMDIndexedTiedComplex size, bit opc1, bit opc2, RegisterOperand dst_reg, RegisterOperand lhs_reg, RegisterOperand rhs_reg, Operand vec_idx, Operand rottype, string asm, string apple_kind, string dst_kind, string lhs_kind, string rhs_kind, list pattern> : I<(outs dst_reg:$dst), (ins dst_reg:$Rd, lhs_reg:$Rn, rhs_reg:$Rm, vec_idx:$idx, rottype:$rot), asm, "{\t$Rd" # dst_kind # ", $Rn" # lhs_kind # ", $Rm" # rhs_kind # "$idx, $rot" # "|" # apple_kind # "\t$Rd, $Rn, $Rm$idx, $rot}", "$Rd = $dst", pattern>, Sched<[!if(Q, WriteVq, WriteVd)]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<2> rot; let Inst{31} = 0; let Inst{30} = Q; let Inst{29} = U; let Inst{28} = Scalar; let Inst{27-24} = 0b1111; let Inst{23-22} = size; // Bit 21 must be set by the derived class. let Inst{20-16} = Rm; let Inst{15} = opc1; let Inst{14-13} = rot; let Inst{12} = opc2; // Bit 11 must be set by the derived class. let Inst{10} = 0; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } // The complex instructions index by pairs of elements, so the VectorIndexes // don't match the lane types, and the index bits are different to the other // classes. multiclass SIMDIndexedTiedComplexHSD { let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in { def v4f16_indexed : BaseSIMDIndexedTiedComplex<0, 1, 0, 0b01, opc1, opc2, V64, V64, V128, VectorIndexD, rottype, asm, ".4h", ".4h", ".4h", ".h", []> { bits<1> idx; let Inst{11} = 0; let Inst{21} = idx{0}; } def v8f16_indexed : BaseSIMDIndexedTiedComplex<1, 1, 0, 0b01, opc1, opc2, V128, V128, V128, VectorIndexS, rottype, asm, ".8h", ".8h", ".8h", ".h", []> { bits<2> idx; let Inst{11} = idx{1}; let Inst{21} = idx{0}; } } // Predicates = HasComplxNum, HasNEON, HasFullFP16] let Predicates = [HasComplxNum, HasNEON] in { def v4f32_indexed : BaseSIMDIndexedTiedComplex<1, 1, 0, 0b10, opc1, opc2, V128, V128, V128, VectorIndexD, rottype, asm, ".4s", ".4s", ".4s", ".s", []> { bits<1> idx; let Inst{11} = idx{0}; let Inst{21} = 0; } } // Predicates = [HasComplxNum, HasNEON] } //---------------------------------------------------------------------------- // Crypto extensions //---------------------------------------------------------------------------- let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class AESBase opc, string asm, dag outs, dag ins, string cstr, list pat> : I, Sched<[WriteVq]>{ bits<5> Rd; bits<5> Rn; let Inst{31-16} = 0b0100111000101000; let Inst{15-12} = opc; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class AESInst opc, string asm, Intrinsic OpNode> : AESBase; class AESTiedInst opc, string asm, Intrinsic OpNode> : AESBase; let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class SHA3OpTiedInst opc, string asm, string dst_lhs_kind, dag oops, dag iops, list pat> : I, Sched<[WriteVq]>{ bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-21} = 0b01011110000; let Inst{20-16} = Rm; let Inst{15} = 0; let Inst{14-12} = opc; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class SHATiedInstQSV opc, string asm, Intrinsic OpNode> : SHA3OpTiedInst; class SHATiedInstVVV opc, string asm, Intrinsic OpNode> : SHA3OpTiedInst; class SHATiedInstQQV opc, string asm, Intrinsic OpNode> : SHA3OpTiedInst; let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in class SHA2OpInst opc, string asm, string kind, string cstr, dag oops, dag iops, list pat> : I, Sched<[WriteVq]>{ bits<5> Rd; bits<5> Rn; let Inst{31-16} = 0b0101111000101000; let Inst{15-12} = opc; let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class SHATiedInstVV opc, string asm, Intrinsic OpNode> : SHA2OpInst; class SHAInstSS opc, string asm, Intrinsic OpNode> : SHA2OpInst; // Armv8.2-A Crypto extensions class BaseCryptoV82 pattern> : I , Sched<[WriteVq]> { bits<5> Vd; bits<5> Vn; let Inst{31-25} = 0b1100111; let Inst{9-5} = Vn; let Inst{4-0} = Vd; } class CryptoRRTiedop0, bits<2>op1, string asm, string asmops> : BaseCryptoV82<(outs V128:$Vdst), (ins V128:$Vd, V128:$Vn), asm, asmops, "$Vd = $Vdst", []> { let Inst{31-25} = 0b1100111; let Inst{24-21} = 0b0110; let Inst{20-15} = 0b000001; let Inst{14} = op0; let Inst{13-12} = 0b00; let Inst{11-10} = op1; } class CryptoRRTied_2Dop0, bits<2>op1, string asm> : CryptoRRTied; class CryptoRRTied_4Sop0, bits<2>op1, string asm> : CryptoRRTied; class CryptoRRR op0, bits<2>op1, dag oops, dag iops, string asm, string asmops, string cst> : BaseCryptoV82 { bits<5> Vm; let Inst{24-21} = 0b0011; let Inst{20-16} = Vm; let Inst{15} = 0b1; let Inst{14} = op0; let Inst{13-12} = 0b00; let Inst{11-10} = op1; } class CryptoRRR_2D op0, bits<2>op1, string asm> : CryptoRRR; class CryptoRRRTied_2D op0, bits<2>op1, string asm> : CryptoRRR; class CryptoRRR_4S op0, bits<2>op1, string asm> : CryptoRRR; class CryptoRRRTied_4S op0, bits<2>op1, string asm> : CryptoRRR; class CryptoRRRTied op0, bits<2>op1, string asm> : CryptoRRR; class CryptoRRRRop0, string asm, string asmops> : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm, V128:$Va), asm, asmops, "", []> { bits<5> Vm; bits<5> Va; let Inst{24-23} = 0b00; let Inst{22-21} = op0; let Inst{20-16} = Vm; let Inst{15} = 0b0; let Inst{14-10} = Va; } class CryptoRRRR_16Bop0, string asm> : CryptoRRRR { } class CryptoRRRR_4Sop0, string asm> : CryptoRRRR { } class CryptoRRRi6 : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm, uimm6:$imm), asm, "{\t$Vd.2d, $Vn.2d, $Vm.2d, $imm" # "|.2d\t$Vd, $Vn, $Vm, $imm}", "", []> { bits<6> imm; bits<5> Vm; let Inst{24-21} = 0b0100; let Inst{20-16} = Vm; let Inst{15-10} = imm; let Inst{9-5} = Vn; let Inst{4-0} = Vd; } class CryptoRRRi2Tiedop0, bits<2>op1, string asm> : BaseCryptoV82<(outs V128:$Vdst), (ins V128:$Vd, V128:$Vn, V128:$Vm, VectorIndexS:$imm), asm, "{\t$Vd.4s, $Vn.4s, $Vm.s$imm" # "|.4s\t$Vd, $Vn, $Vm$imm}", "$Vd = $Vdst", []> { bits<2> imm; bits<5> Vm; let Inst{24-21} = 0b0010; let Inst{20-16} = Vm; let Inst{15} = 0b1; let Inst{14} = op0; let Inst{13-12} = imm; let Inst{11-10} = op1; } //---------------------------------------------------------------------------- // v8.1 atomic instructions extension: // * CAS // * CASP // * SWP // * LDOPregister, and aliases STOPregister // Instruction encodings: // // 31 30|29 24|23|22|21|20 16|15|14 10|9 5|4 0 // CAS SZ |001000|1 |A |1 |Rs |R |11111 |Rn |Rt // CASP 0|SZ|001000|0 |A |1 |Rs |R |11111 |Rn |Rt // SWP SZ |111000|A |R |1 |Rs |1 |OPC|00|Rn |Rt // LD SZ |111000|A |R |1 |Rs |0 |OPC|00|Rn |Rt // ST SZ |111000|A |R |1 |Rs |0 |OPC|00|Rn |11111 // Instruction syntax: // // CAS{}[] , , [] // CAS{} , , [] // CASP{} , , , , [] // CASP{} , , , , [] // SWP{}[] , , [] // SWP{} , , [] // LD{}[] , , [] // LD{} , , [] // ST{}[] , [] // ST{} , [] let Predicates = [HasLSE], mayLoad = 1, mayStore = 1, hasSideEffects = 1 in class BaseCASEncoding pattern> : I { bits<2> Sz; bit NP; bit Acq; bit Rel; bits<5> Rs; bits<5> Rn; bits<5> Rt; let Inst{31-30} = Sz; let Inst{29-24} = 0b001000; let Inst{23} = NP; let Inst{22} = Acq; let Inst{21} = 0b1; let Inst{20-16} = Rs; let Inst{15} = Rel; let Inst{14-10} = 0b11111; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let Predicates = [HasLSE]; } class BaseCAS : BaseCASEncoding<(outs RC:$out),(ins RC:$Rs, RC:$Rt, GPR64sp:$Rn), "cas" # order # size, "\t$Rs, $Rt, [$Rn]", "$out = $Rs",[]>, Sched<[WriteAtomic]> { let NP = 1; } multiclass CompareAndSwap Acq, bits<1> Rel, string order> { let Sz = 0b00, Acq = Acq, Rel = Rel in def B : BaseCAS; let Sz = 0b01, Acq = Acq, Rel = Rel in def H : BaseCAS; let Sz = 0b10, Acq = Acq, Rel = Rel in def W : BaseCAS; let Sz = 0b11, Acq = Acq, Rel = Rel in def X : BaseCAS; } class BaseCASP : BaseCASEncoding<(outs RC:$out),(ins RC:$Rs, RC:$Rt, GPR64sp:$Rn), "casp" # order # size, "\t$Rs, $Rt, [$Rn]", "$out = $Rs",[]>, Sched<[WriteAtomic]> { let NP = 0; } multiclass CompareAndSwapPair Acq, bits<1> Rel, string order> { let Sz = 0b00, Acq = Acq, Rel = Rel in def W : BaseCASP; let Sz = 0b01, Acq = Acq, Rel = Rel in def X : BaseCASP; } let Predicates = [HasLSE] in class BaseSWP : I<(outs RC:$Rt),(ins RC:$Rs, GPR64sp:$Rn), "swp" # order # size, "\t$Rs, $Rt, [$Rn]","",[]>, Sched<[WriteAtomic]> { bits<2> Sz; bit Acq; bit Rel; bits<5> Rs; bits<3> opc = 0b000; bits<5> Rn; bits<5> Rt; let Inst{31-30} = Sz; let Inst{29-24} = 0b111000; let Inst{23} = Acq; let Inst{22} = Rel; let Inst{21} = 0b1; let Inst{20-16} = Rs; let Inst{15} = 0b1; let Inst{14-12} = opc; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let Predicates = [HasLSE]; } multiclass Swap Acq, bits<1> Rel, string order> { let Sz = 0b00, Acq = Acq, Rel = Rel in def B : BaseSWP; let Sz = 0b01, Acq = Acq, Rel = Rel in def H : BaseSWP; let Sz = 0b10, Acq = Acq, Rel = Rel in def W : BaseSWP; let Sz = 0b11, Acq = Acq, Rel = Rel in def X : BaseSWP; } let Predicates = [HasLSE], mayLoad = 1, mayStore = 1, hasSideEffects = 1 in class BaseLDOPregister : I<(outs RC:$Rt),(ins RC:$Rs, GPR64sp:$Rn), "ld" # op # order # size, "\t$Rs, $Rt, [$Rn]","",[]>, Sched<[WriteAtomic]> { bits<2> Sz; bit Acq; bit Rel; bits<5> Rs; bits<3> opc; bits<5> Rn; bits<5> Rt; let Inst{31-30} = Sz; let Inst{29-24} = 0b111000; let Inst{23} = Acq; let Inst{22} = Rel; let Inst{21} = 0b1; let Inst{20-16} = Rs; let Inst{15} = 0b0; let Inst{14-12} = opc; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let Predicates = [HasLSE]; } multiclass LDOPregister opc, string op, bits<1> Acq, bits<1> Rel, string order> { let Sz = 0b00, Acq = Acq, Rel = Rel, opc = opc in def B : BaseLDOPregister; let Sz = 0b01, Acq = Acq, Rel = Rel, opc = opc in def H : BaseLDOPregister; let Sz = 0b10, Acq = Acq, Rel = Rel, opc = opc in def W : BaseLDOPregister; let Sz = 0b11, Acq = Acq, Rel = Rel, opc = opc in def X : BaseLDOPregister; } // Differing SrcRHS and DstRHS allow you to cover CLR & SUB by giving a more // complex DAG for DstRHS. let Predicates = [HasLSE] in multiclass LDOPregister_patterns_ord_dag { def : Pat<(!cast(op#"_"#size#"_monotonic") GPR64sp:$Rn, SrcRHS), (!cast(inst # suffix) DstRHS, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_acquire") GPR64sp:$Rn, SrcRHS), (!cast(inst # "A" # suffix) DstRHS, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_release") GPR64sp:$Rn, SrcRHS), (!cast(inst # "L" # suffix) DstRHS, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_acq_rel") GPR64sp:$Rn, SrcRHS), (!cast(inst # "AL" # suffix) DstRHS, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_seq_cst") GPR64sp:$Rn, SrcRHS), (!cast(inst # "AL" # suffix) DstRHS, GPR64sp:$Rn)>; } multiclass LDOPregister_patterns_ord { defm : LDOPregister_patterns_ord_dag; } multiclass LDOPregister_patterns_ord_mod { defm : LDOPregister_patterns_ord_dag; } multiclass LDOPregister_patterns { defm : LDOPregister_patterns_ord; defm : LDOPregister_patterns_ord; defm : LDOPregister_patterns_ord; defm : LDOPregister_patterns_ord; } multiclass LDOPregister_patterns_mod { defm : LDOPregister_patterns_ord_mod(mod#Xrr) XZR, GPR64:$Rm))>; defm : LDOPregister_patterns_ord_mod(mod#Wrr) WZR, GPR32:$Rm))>; defm : LDOPregister_patterns_ord_mod(mod#Wrr) WZR, GPR32:$Rm))>; defm : LDOPregister_patterns_ord_mod(mod#Wrr) WZR, GPR32:$Rm))>; } let Predicates = [HasLSE] in multiclass CASregister_patterns_ord_dag { def : Pat<(!cast(op#"_"#size#"_monotonic") GPR64sp:$Rn, OLD, NEW), (!cast(inst # suffix) OLD, NEW, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_acquire") GPR64sp:$Rn, OLD, NEW), (!cast(inst # "A" # suffix) OLD, NEW, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_release") GPR64sp:$Rn, OLD, NEW), (!cast(inst # "L" # suffix) OLD, NEW, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_acq_rel") GPR64sp:$Rn, OLD, NEW), (!cast(inst # "AL" # suffix) OLD, NEW, GPR64sp:$Rn)>; def : Pat<(!cast(op#"_"#size#"_seq_cst") GPR64sp:$Rn, OLD, NEW), (!cast(inst # "AL" # suffix) OLD, NEW, GPR64sp:$Rn)>; } multiclass CASregister_patterns_ord { defm : CASregister_patterns_ord_dag; } multiclass CASregister_patterns { defm : CASregister_patterns_ord; defm : CASregister_patterns_ord; defm : CASregister_patterns_ord; defm : CASregister_patterns_ord; } let Predicates = [HasLSE] in class BaseSTOPregister : InstAlias; multiclass STOPregister { def : BaseSTOPregister(instr # "LB")>; def : BaseSTOPregister(instr # "LH")>; def : BaseSTOPregister(instr # "LW")>; def : BaseSTOPregister(instr # "LX")>; def : BaseSTOPregister(instr # "B")>; def : BaseSTOPregister(instr # "H")>; def : BaseSTOPregister(instr # "W")>; def : BaseSTOPregister(instr # "X")>; } class LoadStore64B_base opc, string asm_inst, string asm_ops, dag iops, dag oops, list pat> : I, Sched<[]> /* FIXME: fill in scheduling details once known */ { bits<5> Rt; bits<5> Rn; let Inst{31-21} = 0b11111000001; let Inst{15} = 1; let Inst{14-12} = opc; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let Predicates = [HasV8_7a]; } class LoadStore64B opc, string asm_inst, dag iops, dag oops, list pat = []> : LoadStore64B_base { let Inst{20-16} = 0b11111; } class Store64BV opc, string asm_inst, list pat = []> : LoadStore64B_base { bits<5> Rs; let Inst{20-16} = Rs; } class MOPSMemoryCopyMoveBase opcode, bits<2> op1, bits<2> op2, string asm> : I<(outs GPR64common:$Rd_wb, GPR64common:$Rs_wb, GPR64:$Rn_wb), (ins GPR64common:$Rd, GPR64common:$Rs, GPR64:$Rn), asm, "\t[$Rd]!, [$Rs]!, $Rn!", "$Rd = $Rd_wb,$Rs = $Rs_wb,$Rn = $Rn_wb", []>, Sched<[]> { bits<5> Rd; bits<5> Rs; bits<5> Rn; let Inst{31-27} = 0b00011; let Inst{26} = isMove; let Inst{25-24} = 0b01; let Inst{23-22} = opcode; let Inst{21} = 0b0; let Inst{20-16} = Rs; let Inst{15-14} = op2; let Inst{13-12} = op1; let Inst{11-10} = 0b01; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeCPYMemOpInstruction"; let mayLoad = 1; let mayStore = 1; } class MOPSMemoryCopy opcode, bits<2> op1, bits<2> op2, string asm> : MOPSMemoryCopyMoveBase<0, opcode, op1, op2, asm>; class MOPSMemoryMove opcode, bits<2> op1, bits<2> op2, string asm> : MOPSMemoryCopyMoveBase<1, opcode, op1, op2, asm>; class MOPSMemorySetBase opcode, bit op1, bit op2, string asm> : I<(outs GPR64common:$Rd_wb, GPR64:$Rn_wb), (ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm), asm, "\t[$Rd]!, $Rn!, $Rm", "$Rd = $Rd_wb,$Rn = $Rn_wb", []>, Sched<[]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; let Inst{31-27} = 0b00011; let Inst{26} = isTagging; let Inst{25-21} = 0b01110; let Inst{20-16} = Rm; let Inst{15-14} = opcode; let Inst{13} = op2; let Inst{12} = op1; let Inst{11-10} = 0b01; let Inst{9-5} = Rn; let Inst{4-0} = Rd; let DecoderMethod = "DecodeSETMemOpInstruction"; let mayLoad = 0; let mayStore = 1; } class MOPSMemorySet opcode, bit op1, bit op2, string asm> : MOPSMemorySetBase<0, opcode, op1, op2, asm>; class MOPSMemorySetTagging opcode, bit op1, bit op2, string asm> : MOPSMemorySetBase<1, opcode, op1, op2, asm>; multiclass MOPSMemoryCopyInsns opcode, string asm> { def "" : MOPSMemoryCopy; def WN : MOPSMemoryCopy; def RN : MOPSMemoryCopy; def N : MOPSMemoryCopy; def WT : MOPSMemoryCopy; def WTWN : MOPSMemoryCopy; def WTRN : MOPSMemoryCopy; def WTN : MOPSMemoryCopy; def RT : MOPSMemoryCopy; def RTWN : MOPSMemoryCopy; def RTRN : MOPSMemoryCopy; def RTN : MOPSMemoryCopy; def T : MOPSMemoryCopy; def TWN : MOPSMemoryCopy; def TRN : MOPSMemoryCopy; def TN : MOPSMemoryCopy; } multiclass MOPSMemoryMoveInsns opcode, string asm> { def "" : MOPSMemoryMove; def WN : MOPSMemoryMove; def RN : MOPSMemoryMove; def N : MOPSMemoryMove; def WT : MOPSMemoryMove; def WTWN : MOPSMemoryMove; def WTRN : MOPSMemoryMove; def WTN : MOPSMemoryMove; def RT : MOPSMemoryMove; def RTWN : MOPSMemoryMove; def RTRN : MOPSMemoryMove; def RTN : MOPSMemoryMove; def T : MOPSMemoryMove; def TWN : MOPSMemoryMove; def TRN : MOPSMemoryMove; def TN : MOPSMemoryMove; } multiclass MOPSMemorySetInsns opcode, string asm> { def "" : MOPSMemorySet; def T : MOPSMemorySet; def N : MOPSMemorySet; def TN : MOPSMemorySet; } multiclass MOPSMemorySetTaggingInsns opcode, string asm> { def "" : MOPSMemorySetTagging; def T : MOPSMemorySetTagging; def N : MOPSMemorySetTagging; def TN : MOPSMemorySetTagging; } //---------------------------------------------------------------------------- // 2022 Armv8.9/Armv9.4 Extensions //---------------------------------------------------------------------------- //--- // 2022 Architecture Extensions: General Data Processing (FEAT_CSSC) //--- class BaseTwoOperandRegImm opc, RegisterClass regtype, ImmLeaf immtype, string asm, SDPatternOperator OpNode> : I<(outs regtype:$Rd), (ins regtype:$Rn, immtype:$imm), asm, "\t$Rd, $Rn, $imm", "", [(set regtype:$Rd, (OpNode regtype:$Rn, immtype:$imm))]> { bits<5> Rd; bits<5> Rn; bits<8> imm; let Inst{31} = sf; let Inst{30} = Op; let Inst{29} = S; let Inst{28-22} = 0b1000111; let Inst{21-18} = opc; let Inst{17-10} = imm; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } class BaseComparisonOpReg : BaseTwoOperandRegReg, Sched<[WriteI]> { let Inst{11} = isMin; let Inst{10} = isUnsigned; let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; } class BaseComparisonOpImm : BaseTwoOperandRegImm, Sched<[]> { let Inst{19} = isMin; let Inst{18} = isUnsigned; let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; } multiclass ComparisonOp { def Wrr : BaseComparisonOpReg<0b0, isUnsigned, isMin, GPR32, asm, OpNode>; def Wri : BaseComparisonOpImm<0b0, isUnsigned, isMin, GPR32, !cond(isUnsigned : uimm8_32b, !not(isUnsigned) : simm8_32b), asm, OpNode>; def Xrr : BaseComparisonOpReg<0b1, isUnsigned, isMin, GPR64, asm, OpNode>; def Xri : BaseComparisonOpImm<0b1, isUnsigned, isMin, GPR64, !cond(isUnsigned : uimm8_64b, !not(isUnsigned) : simm8_64b), asm, OpNode>; } //--- // RCPC instructions (FEAT_LRCPC3) //--- class BaseLRCPC3 size, bit V, bits<2> opc, dag oops, dag iops, string asm, string operands, string cstr = ""> : I, Sched<[WriteAtomic]> { bits<5> Rt; bits<5> Rn; let Inst{31-30} = size; let Inst{29-24} = {0,1,1,V,0,1}; let Inst{23-22} = opc; let Inst{21} = 0b0; // Inst{20-12} let Inst{11-10} = 0b10; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let mayLoad = Inst{22}; let mayStore = !not(Inst{22}); let hasSideEffects = 0; } class BaseLRCPC3IntegerLoadStorePair size, bits<2> opc, bits<4> opc2, dag oops, dag iops, string asm, string operands, string cstr> : BaseLRCPC3 { bits<5> Rt2; let Inst{20-16} = Rt2; let Inst{15-12} = opc2; } class BaseLRCPC3IntegerLoadStore size, bits<2> opc, dag oops, dag iops, string asm, string operands, string cstr> : BaseLRCPC3 { let Inst{20-12} = 0b000000000; // imm9 } multiclass LRCPC3NEONLoadStoreUnscaledOffset size, bits<2> opc, RegisterClass regtype, dag oops, dag iops, string asm> { def i : BaseLRCPC3 { bits<9> simm; // signed immediate encoded in imm9=Rt2:imm4 let Inst{20-12} = simm; } def a : InstAlias(NAME # "i") regtype:$Rt, GPR64sp:$Rn, 0)>; } class LRCPC3NEONLdStSingle : BaseSIMDLdStSingle, Sched<[]> { bit Q; let Inst{31} = 0; let Inst{30} = Q; let Inst{23} = 0; let Inst{20-16} = 0b00001; let Inst{12} = 0; // S let Inst{11-10} = 0b01; // size let mayLoad = L; let mayStore = !not(L); let hasSideEffects = 1; } //--- // Instrumentation Extension (FEAT_ITE) //--- let Predicates = [HasITE] in def TRCIT : RtSystemI<0b0, (outs), (ins GPR64:$Rt), "trcit", "\t$Rt"> { let Inst{20-19} = 0b01; let Inst{18-16} = 0b011; let Inst{15-12} = 0b0111; let Inst{11-8} = 0b0010; let Inst{7-5} = 0b111; } // * RCWCAS family // * RCW family //-------------------------------------------------------------------- // Read-Check-Write Compare And Swap family (RCWCAS[S|P|PS]?[A|L|AL]?) // Instruction encoding: // // 31 30|29 24|23|22|21|20 16|15|14 13|12 11 10|9 5|4 0 // RCWCAS 0 0|011001| A| R| 1| Rs| 0| 0 0| 0 1 0| Rn| Rt // RCWSCAS 0 1|011001| A| R| 1| Rs| 0| 0 0| 0 1 0| Rn| Rt // RCWCASP 0 0|011001| A| R| 1| Rs| 0| 0 0| 0 1 1| Rn| Rt // RCWSCASP 0 1|011001| A| R| 1| Rs| 0| 0 0| 0 1 1| Rn| Rt // Instruction syntax: // // RCW[S]CAS{} , , [] // RCW[S]CASP{} , , , [] class BaseRCWCASEncoding : I, Sched<[]> { bit Acq; bit Rel; bit SC; bit Pair; bits<5> Rs; bits<5> Rn; bits<5> Rt; let Inst{31} = 0b0; let Inst{30} = SC; let Inst{29-24} = 0b011001; let Inst{23} = Acq; let Inst{22} = Rel; let Inst{21} = 0b1; let Inst{20-16} = Rs; let Inst{15-13} = 0b000; let Inst{12-11} = 0b01; let Inst{10} = Pair; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let mayLoad = 1; let mayStore = 1; let hasSideEffects = 1; let Defs = [NZCV]; } multiclass BaseRCWCAS { let Acq = 0b0, Rel = 0b0 in def "" : BaseRCWCASEncoding; let Acq = 0b1, Rel = 0b0 in def A : BaseRCWCASEncoding; let Acq = 0b0, Rel = 0b1 in def L : BaseRCWCASEncoding; let Acq = 0b1, Rel = 0b1 in def AL : BaseRCWCASEncoding; } multiclass ReadCheckWriteCompareAndSwap { let SC = 0b0, Pair = 0b0, Predicates = [HasTHE] in defm CAS : BaseRCWCAS<(outs GPR64:$out), (ins GPR64:$Rs, GPR64:$Rt, GPR64sp:$Rn), "rcwcas" >; let SC = 0b1, Pair = 0b0, Predicates = [HasTHE] in defm SCAS : BaseRCWCAS<(outs GPR64:$out), (ins GPR64:$Rs, GPR64:$Rt, GPR64sp:$Rn), "rcwscas">; let SC = 0b0, Pair = 0b1, Predicates = [HasTHE, HasD128] in defm CASP : BaseRCWCAS<(outs XSeqPairClassOperand:$out), (ins XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp:$Rn), "rcwcasp">; let SC = 0b1, Pair = 0b1, Predicates = [HasTHE, HasD128] in defm SCASP: BaseRCWCAS<(outs XSeqPairClassOperand:$out), (ins XSeqPairClassOperand:$Rs, XSeqPairClassOperand:$Rt, GPR64sp:$Rn), "rcwscasp">; } //------------------------------------------------------------------ // Read-Check-Write family (RCW[CLR|SET|SWP][S|P|PS]?[A|L|AL]?) // Instruction encoding: // // 31 30|29 24|23|22|21|20 16|15|14 12|11 10|9 5|4 0 // RCWCLR 0 0|111000| A| R| 1| Rs| 1| 001| 0 0| Rn| Rt // RCWSCLR 0 1|111000| A| R| 1| Rs| 1| 001| 0 0| Rn| Rt // RCWSET 0 0|111000| A| R| 1| Rs| 1| 011| 0 0| Rn| Rt // RCWSSET 0 1|111000| A| R| 1| Rs| 1| 011| 0 0| Rn| Rt // RCWSWP 0 0|111000| A| R| 1| Rs| 1| 010| 0 0| Rn| Rt // RCWSSWP 0 1|111000| A| R| 1| Rs| 1| 010| 0 0| Rn| Rt // 31 30|29 24|23|22|21|20 16|15|14 12|11 10|9 5|4 0 // RCWCLRP 0 0|011001| A| R| 1| Rt2| 1| 001| 0 0| Rn| Rt // RCWSCLRP 0 1|011001| A| R| 1| Rt2| 1| 001| 0 0| Rn| Rt // RCWSETP 0 0|011001| A| R| 1| Rt2| 1| 011| 0 0| Rn| Rt // RCWSSETP 0 1|011001| A| R| 1| Rt2| 1| 011| 0 0| Rn| Rt // RCWSWPP 0 0|011001| A| R| 1| Rt2| 1| 010| 0 0| Rn| Rt // RCWSSWPP 0 1|011001| A| R| 1| Rt2| 1| 010| 0 0| Rn| Rt // Instruction syntax: // // RCW[S]{} , , [] // RCW[S]P{} , , [] class BaseRCWOPEncoding : I<(outs GPR64:$Rt),(ins GPR64:$Rs, GPR64sp:$Rn), asm, "\t$Rs, $Rt, [$Rn]", "", []>, Sched<[]> { bit Acq; bit Rel; bit SC; bits<3> opc; bits<5> Rs; bits<5> Rn; bits<5> Rt; let Inst{31} = 0b0; let Inst{30} = SC; let Inst{29-24} = 0b111000; let Inst{23} = Acq; let Inst{22} = Rel; let Inst{21} = 0b1; let Inst{20-16} = Rs; let Inst{15} = 0b1; let Inst{14-12} = opc; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let mayLoad = 1; let mayStore = 1; let hasSideEffects = 1; let Defs = [NZCV]; let Predicates = [HasTHE]; } class BaseRCWOPPEncoding : I<(outs GPR64common:$Rt_wb, GPR64common:$Rt2_wb), (ins GPR64common:$Rt, GPR64common:$Rt2, GPR64sp:$Rn), asm, "\t$Rt, $Rt2, [$Rn]", "$Rt = $Rt_wb, $Rt2 = $Rt2_wb", []>, Sched<[]> { bit Acq; bit Rel; bit SC; bits<3> opc; bits<5> Rt2; bits<5> Rn; bits<5> Rt; let Inst{31} = 0b0; let Inst{30} = SC; let Inst{29-24} = 0b011001; let Inst{23} = Acq; let Inst{22} = Rel; let Inst{21} = 0b1; let Inst{20-16} = Rt2; let Inst{15} = 0b1; let Inst{14-12} = opc; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; let mayLoad = 1; let mayStore = 1; let hasSideEffects = 1; let Defs = [NZCV]; let Predicates = [HasTHE, HasD128]; } multiclass BaseRCWOP { let Acq = 0b0, Rel = 0b0 in def "" : BaseRCWOPEncoding; let Acq = 0b1, Rel = 0b0 in def A : BaseRCWOPEncoding; let Acq = 0b0, Rel = 0b1 in def L : BaseRCWOPEncoding; let Acq = 0b1, Rel = 0b1 in def AL : BaseRCWOPEncoding; let Acq = 0b0, Rel = 0b0 in def P : BaseRCWOPPEncoding; let Acq = 0b1, Rel = 0b0 in def PA : BaseRCWOPPEncoding; let Acq = 0b0, Rel = 0b1 in def PL : BaseRCWOPPEncoding; let Acq = 0b1, Rel = 0b1 in def PAL : BaseRCWOPPEncoding; } multiclass ReadCheckWriteOperation opc, string op> { let SC = 0b0, opc = opc in defm "" : BaseRCWOP<"rcw" # "" # op>; let SC = 0b1, opc = opc in defm S : BaseRCWOP<"rcw" # "s" # op >; } //--- // 128-bit atomic instructions (FEAT_LSE128) //--- let mayLoad = 1, mayStore = 1, hasSideEffects = 0 in class LSE128Base op0, bits<2> AR, bit o3, string asm> : I<(outs GPR64common:$Rt_wb, GPR64common:$Rt2_wb), (ins GPR64common:$Rt, GPR64common:$Rt2, GPR64sp:$Rn), asm, "\t$Rt, $Rt2, [$Rn]", "$Rt = $Rt_wb, $Rt2 = $Rt2_wb", []>, Sched<[]> { bits<5> Rt; bits<5> Rt2; bits<5> Rn; let Inst{31-24} = 0b00011001; let Inst{23-22} = AR; let Inst{21} = 0b1; let Inst{20-16} = Rt2; let Inst{15} = o3; let Inst{14-12} = op0; let Inst{11-10} = 0b00; let Inst{9-5} = Rn; let Inst{4-0} = Rt; } //--- // 128-bit System Instructions (FEAT_SYSINSTR128) //--- // Instruction encoding: // // 31 19|18 16|15 12|11 8|7 5|4 0 // SYSP 1101010101001| op1| Cn| Cm|op2| Rt // Instruction syntax: // // SYSP #, , , #{, , } class RtSystemI128 pattern = []> : RtSystemI { let Inst{22} = 0b1; // override BaseSystemI } class BaseSYSPEncoding : RtSystemI128 { bits<3> op1; bits<4> Cn; bits<4> Cm; bits<3> op2; let Inst{20-19} = 0b01; let Inst{18-16} = op1; let Inst{15-12} = Cn; let Inst{11-8} = Cm; let Inst{7-5} = op2; } class SystemPXtI : BaseSYSPEncoding; //---------------------------------------------------------------------------- // 2023 Armv9.5 Extensions //---------------------------------------------------------------------------- //--- // Checked Pointer Arithmetic (FEAT_CPA) //--- def LSLImm3ShiftOperand : AsmOperandClass { let SuperClasses = [ExtendOperandLSL64]; let Name = "LSLImm3Shift"; let RenderMethod = "addLSLImm3ShifterOperands"; let DiagnosticType = "AddSubLSLImm3ShiftLarge"; } def lsl_imm3_shift_operand : Operand { let PrintMethod = "printShifter"; let ParserMatchClass = LSLImm3ShiftOperand; } // Base CPA scalar add/subtract with lsl #imm3 shift class BaseAddSubCPA : I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, GPR64:$Rm, lsl_imm3_shift_operand:$shift_imm), asm, "\t$Rd, $Rn, $Rm$shift_imm", "", []>, Sched<[]> { bits<5> Rd; bits<5> Rn; bits<5> Rm; bits<3> shift_imm; let Inst{31} = 0b1; let Inst{30} = isSub; let Inst{29-21} = 0b011010000; let Inst{20-16} = Rm; let Inst{15-13} = 0b001; let Inst{12-10} = shift_imm; let Inst{9-5} = Rn; let Inst{4-0} = Rd; } // Alias for CPA scalar add/subtract with no shift class AddSubCPAAlias : InstAlias; multiclass AddSubCPA { def _shift : BaseAddSubCPA; def _noshift : AddSubCPAAlias(NAME#"_shift")>; } class MulAccumCPA : BaseMulAccum, Sched<[]> { let Inst{31} = 0b1; } //---------------------------------------------------------------------------- // Allow the size specifier tokens to be upper case, not just lower. def : TokenAlias<".4B", ".4b">; // Add dot product def : TokenAlias<".8B", ".8b">; def : TokenAlias<".4H", ".4h">; def : TokenAlias<".2S", ".2s">; def : TokenAlias<".1D", ".1d">; def : TokenAlias<".16B", ".16b">; def : TokenAlias<".8H", ".8h">; def : TokenAlias<".4S", ".4s">; def : TokenAlias<".2D", ".2d">; def : TokenAlias<".1Q", ".1q">; def : TokenAlias<".2H", ".2h">; def : TokenAlias<".2B", ".2b">; def : TokenAlias<".B", ".b">; def : TokenAlias<".H", ".h">; def : TokenAlias<".S", ".s">; def : TokenAlias<".D", ".d">; def : TokenAlias<".Q", ".q">;