//===-- RISCVInstrInfoVPseudos.td - RISC-V 'V' Pseudos -----*- tablegen -*-===// // // 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 // //===----------------------------------------------------------------------===// /// /// This file contains the required infrastructure to support code generation /// for the standard 'V' (Vector) extension, version 0.10. This version is still /// experimental as the 'V' extension hasn't been ratified yet. /// /// This file is included from RISCVInstrInfoV.td /// //===----------------------------------------------------------------------===// def riscv_vmv_x_s : SDNode<"RISCVISD::VMV_X_S", SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisVec<1>, SDTCisInt<1>]>>; def riscv_read_vlenb : SDNode<"RISCVISD::READ_VLENB", SDTypeProfile<1, 0, [SDTCisVT<0, XLenVT>]>>; // Operand that is allowed to be a register or a 5 bit immediate. // This allows us to pick between VSETIVLI and VSETVLI opcodes using the same // pseudo instructions. def AVL : RegisterOperand { let OperandNamespace = "RISCVOp"; let OperandType = "OPERAND_AVL"; } // X0 has special meaning for vsetvl/vsetvli. // rd | rs1 | AVL value | Effect on vl //-------------------------------------------------------------- // !X0 | X0 | VLMAX | Set vl to VLMAX // X0 | X0 | Value in vl | Keep current vl, just change vtype. def VLOp : ComplexPattern; def DecImm : SDNodeXFormgetTargetConstant(N->getSExtValue() - 1, SDLoc(N), N->getValueType(0)); }]>; defvar TAIL_UNDISTURBED = 0; defvar TAIL_AGNOSTIC = 1; //===----------------------------------------------------------------------===// // Utilities. //===----------------------------------------------------------------------===// // This class describes information associated to the LMUL. class LMULInfo { bits<3> value = lmul; // This is encoded as the vlmul field of vtype. VReg vrclass = regclass; VReg wvrclass = wregclass; VReg f8vrclass = f8regclass; VReg f4vrclass = f4regclass; VReg f2vrclass = f2regclass; string MX = mx; int octuple = oct; } // Associate LMUL with tablegen records of register classes. def V_M1 : LMULInfo<0b000, 8, VR, VRM2, VR, VR, VR, "M1">; def V_M2 : LMULInfo<0b001, 16, VRM2, VRM4, VR, VR, VR, "M2">; def V_M4 : LMULInfo<0b010, 32, VRM4, VRM8, VRM2, VR, VR, "M4">; def V_M8 : LMULInfo<0b011, 64, VRM8,/*NoVReg*/VR, VRM4, VRM2, VR, "M8">; def V_MF8 : LMULInfo<0b101, 1, VR, VR,/*NoVReg*/VR,/*NoVReg*/VR,/*NoVReg*/VR, "MF8">; def V_MF4 : LMULInfo<0b110, 2, VR, VR, VR,/*NoVReg*/VR,/*NoVReg*/VR, "MF4">; def V_MF2 : LMULInfo<0b111, 4, VR, VR, VR, VR,/*NoVReg*/VR, "MF2">; // Used to iterate over all possible LMULs. defvar MxList = [V_MF8, V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8]; // For floating point which don't need MF8. defvar MxListF = [V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8]; // Used for widening and narrowing instructions as it doesn't contain M8. defvar MxListW = [V_MF8, V_MF4, V_MF2, V_M1, V_M2, V_M4]; // For floating point which don't need MF8. defvar MxListFW = [V_MF4, V_MF2, V_M1, V_M2, V_M4]; // Use for zext/sext.vf2 defvar MxListVF2 = [V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8]; // Use for zext/sext.vf4 defvar MxListVF4 = [V_MF2, V_M1, V_M2, V_M4, V_M8]; // Use for zext/sext.vf8 defvar MxListVF8 = [V_M1, V_M2, V_M4, V_M8]; class MxSet { list m = !cond(!eq(eew, 8) : [V_MF8, V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8], !eq(eew, 16) : [V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8], !eq(eew, 32) : [V_MF2, V_M1, V_M2, V_M4, V_M8], !eq(eew, 64) : [V_M1, V_M2, V_M4, V_M8]); } class FPR_Info mxlist> { RegisterClass fprclass = regclass; string FX = fx; list MxList = mxlist; } def SCALAR_F16 : FPR_Info.m>; def SCALAR_F32 : FPR_Info.m>; def SCALAR_F64 : FPR_Info.m>; defvar FPList = [SCALAR_F16, SCALAR_F32, SCALAR_F64]; // Used for widening instructions. It excludes F64. defvar FPListW = [SCALAR_F16, SCALAR_F32]; class NFSet { list L = !cond(!eq(m.value, V_M8.value): [], !eq(m.value, V_M4.value): [2], !eq(m.value, V_M2.value): [2, 3, 4], true: [2, 3, 4, 5, 6, 7, 8]); } class log2 { int val = !if(!eq(num, 1), 0, !add(1, log2.val)); } class octuple_to_str { string ret = !if(!eq(octuple, 1), "MF8", !if(!eq(octuple, 2), "MF4", !if(!eq(octuple, 4), "MF2", !if(!eq(octuple, 8), "M1", !if(!eq(octuple, 16), "M2", !if(!eq(octuple, 32), "M4", !if(!eq(octuple, 64), "M8", "NoDef"))))))); } def VLOpFrag : PatFrag<(ops), (XLenVT (VLOp (XLenVT AVL:$vl)))>; // Output pattern for X0 used to represent VLMAX in the pseudo instructions. // We can't use X0 register becuase the AVL operands use GPRNoX0. // This must be kept in sync with RISCV::VLMaxSentinel. def VLMax : OutPatFrag<(ops), (XLenVT -1)>; // List of EEW. defvar EEWList = [8, 16, 32, 64]; class SegRegClass { VReg RC = !cast("VRN" # nf # !cond(!eq(m.value, V_MF8.value): V_M1.MX, !eq(m.value, V_MF4.value): V_M1.MX, !eq(m.value, V_MF2.value): V_M1.MX, true: m.MX)); } //===----------------------------------------------------------------------===// // Vector register and vector group type information. //===----------------------------------------------------------------------===// class VTypeInfo { ValueType Vector = Vec; ValueType Mask = Mas; int SEW = Sew; int Log2SEW = log2.val; VReg RegClass = Reg; LMULInfo LMul = M; ValueType Scalar = Scal; RegisterClass ScalarRegClass = ScalarReg; // The pattern fragment which produces the AVL operand, representing the // "natural" vector length for this type. For scalable vectors this is VLMax. OutPatFrag AVL = VLMax; string ScalarSuffix = !cond(!eq(Scal, XLenVT) : "X", !eq(Scal, f16) : "F16", !eq(Scal, f32) : "F32", !eq(Scal, f64) : "F64"); } class GroupVTypeInfo : VTypeInfo { ValueType VectorM1 = VecM1; } defset list AllVectors = { defset list AllIntegerVectors = { defset list NoGroupIntegerVectors = { defset list FractionalGroupIntegerVectors = { def VI8MF8: VTypeInfo; def VI8MF4: VTypeInfo; def VI8MF2: VTypeInfo; def VI16MF4: VTypeInfo; def VI16MF2: VTypeInfo; def VI32MF2: VTypeInfo; } def VI8M1: VTypeInfo; def VI16M1: VTypeInfo; def VI32M1: VTypeInfo; def VI64M1: VTypeInfo; } defset list GroupIntegerVectors = { def VI8M2: GroupVTypeInfo; def VI8M4: GroupVTypeInfo; def VI8M8: GroupVTypeInfo; def VI16M2: GroupVTypeInfo; def VI16M4: GroupVTypeInfo; def VI16M8: GroupVTypeInfo; def VI32M2: GroupVTypeInfo; def VI32M4: GroupVTypeInfo; def VI32M8: GroupVTypeInfo; def VI64M2: GroupVTypeInfo; def VI64M4: GroupVTypeInfo; def VI64M8: GroupVTypeInfo; } } defset list AllFloatVectors = { defset list NoGroupFloatVectors = { defset list FractionalGroupFloatVectors = { def VF16MF4: VTypeInfo; def VF16MF2: VTypeInfo; def VF32MF2: VTypeInfo; } def VF16M1: VTypeInfo; def VF32M1: VTypeInfo; def VF64M1: VTypeInfo; } defset list GroupFloatVectors = { def VF16M2: GroupVTypeInfo; def VF16M4: GroupVTypeInfo; def VF16M8: GroupVTypeInfo; def VF32M2: GroupVTypeInfo; def VF32M4: GroupVTypeInfo; def VF32M8: GroupVTypeInfo; def VF64M2: GroupVTypeInfo; def VF64M4: GroupVTypeInfo; def VF64M8: GroupVTypeInfo; } } } // This functor is used to obtain the int vector type that has the same SEW and // multiplier as the input parameter type class GetIntVTypeInfo { // Equivalent integer vector type. Eg. // VI8M1 → VI8M1 (identity) // VF64M4 → VI64M4 VTypeInfo Vti = !cast(!subst("VF", "VI", !cast(vti))); } class MTypeInfo { ValueType Mask = Mas; // {SEW, VLMul} values set a valid VType to deal with this mask type. // we assume SEW=1 and set corresponding LMUL. vsetvli insertion will // look for SEW=1 to optimize based on surrounding instructions. int SEW = 1; int Log2SEW = 0; LMULInfo LMul = M; string BX = Bx; // Appendix of mask operations. // The pattern fragment which produces the AVL operand, representing the // "natural" vector length for this mask type. For scalable masks this is // VLMax. OutPatFrag AVL = VLMax; } defset list AllMasks = { // vbool_t, = SEW/LMUL, we assume SEW=8 and corresponding LMUL. def : MTypeInfo; def : MTypeInfo; def : MTypeInfo; def : MTypeInfo; def : MTypeInfo; def : MTypeInfo; def : MTypeInfo; } class VTypeInfoToWide { VTypeInfo Vti = vti; VTypeInfo Wti = wti; } class VTypeInfoToFraction { VTypeInfo Vti = vti; VTypeInfo Fti = fti; } defset list AllWidenableIntVectors = { def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; } defset list AllWidenableFloatVectors = { def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; } defset list AllFractionableVF2IntVectors = { def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; } defset list AllFractionableVF4IntVectors = { def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; } defset list AllFractionableVF8IntVectors = { def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; def : VTypeInfoToFraction; } defset list AllWidenableIntToFloatVectors = { def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; def : VTypeInfoToWide; } // This class holds the record of the RISCVVPseudoTable below. // This represents the information we need in codegen for each pseudo. // The definition should be consistent with `struct PseudoInfo` in // RISCVBaseInfo.h. class CONST8b val> { bits<8> V = val; } def InvalidIndex : CONST8b<0x80>; class RISCVVPseudo { Pseudo Pseudo = !cast(NAME); // Used as a key. Instruction BaseInstr; } // The actual table. def RISCVVPseudosTable : GenericTable { let FilterClass = "RISCVVPseudo"; let CppTypeName = "PseudoInfo"; let Fields = [ "Pseudo", "BaseInstr" ]; let PrimaryKey = [ "Pseudo" ]; let PrimaryKeyName = "getPseudoInfo"; let PrimaryKeyEarlyOut = true; } def RISCVVIntrinsicsTable : GenericTable { let FilterClass = "RISCVVIntrinsic"; let CppTypeName = "RISCVVIntrinsicInfo"; let Fields = ["IntrinsicID", "SplatOperand", "VLOperand"]; let PrimaryKey = ["IntrinsicID"]; let PrimaryKeyName = "getRISCVVIntrinsicInfo"; } class RISCVVLE S, bits<3> L> { bits<1> Masked = M; bits<1> IsTU = TU; bits<1> Strided = Str; bits<1> FF = F; bits<3> Log2SEW = S; bits<3> LMUL = L; Pseudo Pseudo = !cast(NAME); } def RISCVVLETable : GenericTable { let FilterClass = "RISCVVLE"; let CppTypeName = "VLEPseudo"; let Fields = ["Masked", "IsTU", "Strided", "FF", "Log2SEW", "LMUL", "Pseudo"]; let PrimaryKey = ["Masked", "IsTU", "Strided", "FF", "Log2SEW", "LMUL"]; let PrimaryKeyName = "getVLEPseudo"; } class RISCVVSE S, bits<3> L> { bits<1> Masked = M; bits<1> Strided = Str; bits<3> Log2SEW = S; bits<3> LMUL = L; Pseudo Pseudo = !cast(NAME); } def RISCVVSETable : GenericTable { let FilterClass = "RISCVVSE"; let CppTypeName = "VSEPseudo"; let Fields = ["Masked", "Strided", "Log2SEW", "LMUL", "Pseudo"]; let PrimaryKey = ["Masked", "Strided", "Log2SEW", "LMUL"]; let PrimaryKeyName = "getVSEPseudo"; } class RISCVVLX_VSX S, bits<3> L, bits<3> IL> { bits<1> Masked = M; bits<1> IsTU = TU; bits<1> Ordered = O; bits<3> Log2SEW = S; bits<3> LMUL = L; bits<3> IndexLMUL = IL; Pseudo Pseudo = !cast(NAME); } class RISCVVLX S, bits<3> L, bits<3> IL> : RISCVVLX_VSX; class RISCVVSX S, bits<3> L, bits<3> IL> : RISCVVLX_VSX; class RISCVVLX_VSXTable : GenericTable { let CppTypeName = "VLX_VSXPseudo"; let Fields = ["Masked", "IsTU", "Ordered", "Log2SEW", "LMUL", "IndexLMUL", "Pseudo"]; let PrimaryKey = ["Masked", "IsTU", "Ordered", "Log2SEW", "LMUL", "IndexLMUL"]; } def RISCVVLXTable : RISCVVLX_VSXTable { let FilterClass = "RISCVVLX"; let PrimaryKeyName = "getVLXPseudo"; } def RISCVVSXTable : RISCVVLX_VSXTable { let FilterClass = "RISCVVSX"; let PrimaryKeyName = "getVSXPseudo"; } class RISCVVLSEG N, bit M, bit Str, bit F, bits<3> S, bits<3> L> { bits<4> NF = N; bits<1> Masked = M; bits<1> Strided = Str; bits<1> FF = F; bits<3> Log2SEW = S; bits<3> LMUL = L; Pseudo Pseudo = !cast(NAME); } def RISCVVLSEGTable : GenericTable { let FilterClass = "RISCVVLSEG"; let CppTypeName = "VLSEGPseudo"; let Fields = ["NF", "Masked", "Strided", "FF", "Log2SEW", "LMUL", "Pseudo"]; let PrimaryKey = ["NF", "Masked", "Strided", "FF", "Log2SEW", "LMUL"]; let PrimaryKeyName = "getVLSEGPseudo"; } class RISCVVLXSEG N, bit M, bit O, bits<3> S, bits<3> L, bits<3> IL> { bits<4> NF = N; bits<1> Masked = M; bits<1> Ordered = O; bits<3> Log2SEW = S; bits<3> LMUL = L; bits<3> IndexLMUL = IL; Pseudo Pseudo = !cast(NAME); } def RISCVVLXSEGTable : GenericTable { let FilterClass = "RISCVVLXSEG"; let CppTypeName = "VLXSEGPseudo"; let Fields = ["NF", "Masked", "Ordered", "Log2SEW", "LMUL", "IndexLMUL", "Pseudo"]; let PrimaryKey = ["NF", "Masked", "Ordered", "Log2SEW", "LMUL", "IndexLMUL"]; let PrimaryKeyName = "getVLXSEGPseudo"; } class RISCVVSSEG N, bit M, bit Str, bits<3> S, bits<3> L> { bits<4> NF = N; bits<1> Masked = M; bits<1> Strided = Str; bits<3> Log2SEW = S; bits<3> LMUL = L; Pseudo Pseudo = !cast(NAME); } def RISCVVSSEGTable : GenericTable { let FilterClass = "RISCVVSSEG"; let CppTypeName = "VSSEGPseudo"; let Fields = ["NF", "Masked", "Strided", "Log2SEW", "LMUL", "Pseudo"]; let PrimaryKey = ["NF", "Masked", "Strided", "Log2SEW", "LMUL"]; let PrimaryKeyName = "getVSSEGPseudo"; } class RISCVVSXSEG N, bit M, bit O, bits<3> S, bits<3> L, bits<3> IL> { bits<4> NF = N; bits<1> Masked = M; bits<1> Ordered = O; bits<3> Log2SEW = S; bits<3> LMUL = L; bits<3> IndexLMUL = IL; Pseudo Pseudo = !cast(NAME); } def RISCVVSXSEGTable : GenericTable { let FilterClass = "RISCVVSXSEG"; let CppTypeName = "VSXSEGPseudo"; let Fields = ["NF", "Masked", "Ordered", "Log2SEW", "LMUL", "IndexLMUL", "Pseudo"]; let PrimaryKey = ["NF", "Masked", "Ordered", "Log2SEW", "LMUL", "IndexLMUL"]; let PrimaryKeyName = "getVSXSEGPseudo"; } //===----------------------------------------------------------------------===// // Helpers to define the different pseudo instructions. //===----------------------------------------------------------------------===// class PseudoToVInst { string VInst = !subst("_M8", "", !subst("_M4", "", !subst("_M2", "", !subst("_M1", "", !subst("_MF2", "", !subst("_MF4", "", !subst("_MF8", "", !subst("_B1", "", !subst("_B2", "", !subst("_B4", "", !subst("_B8", "", !subst("_B16", "", !subst("_B32", "", !subst("_B64", "", !subst("_MASK", "", !subst("_TIED", "", !subst("_TU", "", !subst("F16", "F", !subst("F32", "F", !subst("F64", "F", !subst("Pseudo", "", PseudoInst))))))))))))))))))))); } // The destination vector register group for a masked vector instruction cannot // overlap the source mask register (v0), unless the destination vector register // is being written with a mask value (e.g., comparisons) or the scalar result // of a reduction. class GetVRegNoV0 { VReg R = !cond(!eq(VRegClass, VR) : VRNoV0, !eq(VRegClass, VRM2) : VRM2NoV0, !eq(VRegClass, VRM4) : VRM4NoV0, !eq(VRegClass, VRM8) : VRM8NoV0, !eq(VRegClass, VRN2M1) : VRN2M1NoV0, !eq(VRegClass, VRN2M2) : VRN2M2NoV0, !eq(VRegClass, VRN2M4) : VRN2M4NoV0, !eq(VRegClass, VRN3M1) : VRN3M1NoV0, !eq(VRegClass, VRN3M2) : VRN3M2NoV0, !eq(VRegClass, VRN4M1) : VRN4M1NoV0, !eq(VRegClass, VRN4M2) : VRN4M2NoV0, !eq(VRegClass, VRN5M1) : VRN5M1NoV0, !eq(VRegClass, VRN6M1) : VRN6M1NoV0, !eq(VRegClass, VRN7M1) : VRN7M1NoV0, !eq(VRegClass, VRN8M1) : VRN8M1NoV0, true : VRegClass); } // Join strings in list using separator and ignoring empty elements class Join strings, string separator> { string ret = !foldl(!head(strings), !tail(strings), a, b, !cond( !and(!empty(a), !empty(b)) : "", !empty(a) : b, !empty(b) : a, 1 : a#separator#b)); } class VPseudo : Pseudo, RISCVVPseudo { let BaseInstr = instr; let VLMul = m.value; } class VPseudoUSLoadNoMask : Pseudo<(outs RetClass:$rd), (ins GPR:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLE.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSLoadNoMaskTU : Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPR:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLE.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let HasMergeOp = 1; let Constraints = "$rd = $dest"; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSLoadMask : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPR:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSLoadNoMask: Pseudo<(outs RetClass:$rd), (ins GPR:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLE.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSLoadNoMaskTU: Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPR:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLE.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let HasMergeOp = 1; let Constraints = "$rd = $dest"; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSLoadMask: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPR:$rs1, GPR:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoILoadNoMask LMUL, bit Ordered, bit EarlyClobber>: Pseudo<(outs RetClass:$rd), (ins GPR:$rs1, IdxClass:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLX.val, VLMul, LMUL> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let Constraints = !if(!eq(EarlyClobber, 1), "@earlyclobber $rd", ""); let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoILoadNoMaskTU LMUL, bit Ordered, bit EarlyClobber>: Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPR:$rs1, IdxClass:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLX.val, VLMul, LMUL> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let HasMergeOp = 1; let Constraints = !if(!eq(EarlyClobber, 1), "@earlyclobber $rd, $rd = $dest", "$rd = $dest"); let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoILoadMask LMUL, bit Ordered, bit EarlyClobber>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPR:$rs1, IdxClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLX.val, VLMul, LMUL> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = !if(!eq(EarlyClobber, 1), "@earlyclobber $rd, $rd = $merge", "$rd = $merge"); let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSStoreNoMask: Pseudo<(outs), (ins StClass:$rd, GPR:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSStoreMask: Pseudo<(outs), (ins StClass:$rd, GPR:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSStoreNoMask: Pseudo<(outs), (ins StClass:$rd, GPR:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSStoreMask: Pseudo<(outs), (ins StClass:$rd, GPR:$rs1, GPR:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // Unary instruction that is never masked so HasDummyMask=0. class VPseudoUnaryNoDummyMask : Pseudo<(outs RetClass:$rd), (ins Op2Class:$rs1, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoNullaryNoMask: Pseudo<(outs RegClass:$rd), (ins AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoNullaryMask: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints ="$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // Nullary for pseudo instructions. They are expanded in // RISCVExpandPseudoInsts pass. class VPseudoNullaryPseudoM : Pseudo<(outs VR:$rd), (ins AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; // BaseInstr is not used in RISCVExpandPseudoInsts pass. // Just fill a corresponding real v-inst to pass tablegen check. let BaseInstr = !cast(BaseInst); } // RetClass could be GPR or VReg. class VPseudoUnaryNoMask : Pseudo<(outs RetClass:$rd), (ins OpClass:$rs2, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Constraint; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUnaryMask : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, OpClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUnaryMaskTA : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, OpClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // mask unary operation without maskedoff class VPseudoMaskUnarySOutMask: Pseudo<(outs GPR:$rd), (ins VR:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // Mask can be V0~V31 class VPseudoUnaryAnyMask : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, Op1Class:$rs2, VR:$vm, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = "@earlyclobber $rd, $rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoBinaryNoMask : Pseudo<(outs RetClass:$rd), (ins Op1Class:$rs2, Op2Class:$rs1, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Constraint; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // Special version of VPseudoBinaryNoMask where we pretend the first source is // tied to the destination. // This allows maskedoff and rs2 to be the same register. class VPseudoTiedBinaryNoMask : Pseudo<(outs RetClass:$rd), (ins RetClass:$rs2, Op2Class:$rs1, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $rs2"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let ForceTailAgnostic = 1; let isConvertibleToThreeAddress = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoIStoreNoMask LMUL, bit Ordered>: Pseudo<(outs), (ins StClass:$rd, GPR:$rs1, IdxClass:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSX.val, VLMul, LMUL> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoIStoreMask LMUL, bit Ordered>: Pseudo<(outs), (ins StClass:$rd, GPR:$rs1, IdxClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSX.val, VLMul, LMUL> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoBinaryMask : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, Op1Class:$rs2, Op2Class:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoBinaryMaskTA : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, Op1Class:$rs2, Op2Class:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // Like VPseudoBinaryMask, but output can be V0. class VPseudoBinaryMOutMask : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, Op1Class:$rs2, Op2Class:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } // Special version of VPseudoBinaryMask where we pretend the first source is // tied to the destination so we can workaround the earlyclobber constraint. // This allows maskedoff and rs2 to be the same register. class VPseudoTiedBinaryMask : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, Op2Class:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 0; // Merge is also rs2. let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoBinaryCarryIn : Pseudo<(outs RetClass:$rd), !if(CarryIn, (ins Op1Class:$rs2, Op2Class:$rs1, VMV0:$carry, AVL:$vl, ixlenimm:$sew), (ins Op1Class:$rs2, Op2Class:$rs1, AVL:$vl, ixlenimm:$sew)), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Constraint; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 0; let BaseInstr = !cast(PseudoToVInst.VInst); let VLMul = MInfo.value; } class VPseudoTiedBinaryCarryIn : Pseudo<(outs RetClass:$rd), !if(CarryIn, (ins RetClass:$merge, Op1Class:$rs2, Op2Class:$rs1, VMV0:$carry, AVL:$vl, ixlenimm:$sew), (ins RetClass:$merge, Op1Class:$rs2, Op2Class:$rs1, AVL:$vl, ixlenimm:$sew)), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 0; let BaseInstr = !cast(PseudoToVInst.VInst); let VLMul = MInfo.value; } class VPseudoTernaryNoMask : Pseudo<(outs RetClass:$rd), (ins RetClass:$rs3, Op1Class:$rs1, Op2Class:$rs2, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $rs3"], ",">.ret; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoTernaryNoMaskWithPolicy : Pseudo<(outs RetClass:$rd), (ins RetClass:$rs3, Op1Class:$rs1, Op2Class:$rs2, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = Join<[Constraint, "$rd = $rs3"], ",">.ret; let HasVecPolicyOp = 1; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSSegLoadNoMask NF, bit isFF>: Pseudo<(outs RetClass:$rd), (ins GPR:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLSEG.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSSegLoadMask NF, bit isFF>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPR:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSSegLoadNoMask NF>: Pseudo<(outs RetClass:$rd), (ins GPR:$rs1, GPR:$offset, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLSEG.val, VLMul> { let mayLoad = 1; let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSSegLoadMask NF>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPR:$rs1, GPR:$offset, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG.val, VLMul> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoISegLoadNoMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs RetClass:$rd), (ins GPR:$rs1, IdxClass:$offset, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVLXSEG.val, VLMul, LMUL> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; // For vector indexed segment loads, the destination vector register groups // cannot overlap the source vector register group let Constraints = "@earlyclobber $rd"; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoISegLoadMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPR:$rs1, IdxClass:$offset, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLXSEG.val, VLMul, LMUL> { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; // For vector indexed segment loads, the destination vector register groups // cannot overlap the source vector register group let Constraints = "@earlyclobber $rd, $rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasMergeOp = 1; let HasVecPolicyOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSSegStoreNoMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPR:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoUSSegStoreMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPR:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSSegStoreNoMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPR:$rs1, GPR: $offset, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoSSegStoreMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPR:$rs1, GPR: $offset, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG.val, VLMul> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoISegStoreNoMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs), (ins ValClass:$rd, GPR:$rs1, IdxClass: $index, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSXSEG.val, VLMul, LMUL> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasDummyMask = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } class VPseudoISegStoreMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs), (ins ValClass:$rd, GPR:$rs1, IdxClass: $index, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSXSEG.val, VLMul, LMUL> { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let BaseInstr = !cast(PseudoToVInst.VInst); } multiclass VPseudoUSLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value in { def "E" # eew # "_V_" # LInfo : VPseudoUSLoadNoMask, VLESched; def "E" # eew # "_V_" # LInfo # "_TU": VPseudoUSLoadNoMaskTU, VLESched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSLoadMask, VLESched; } } } } multiclass VPseudoFFLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value in { def "E" # eew # "FF_V_" # LInfo : VPseudoUSLoadNoMask, VLFSched; def "E" # eew # "FF_V_" # LInfo # "_TU": VPseudoUSLoadNoMaskTU, VLFSched; def "E" # eew # "FF_V_" # LInfo # "_MASK" : VPseudoUSLoadMask, VLFSched; } } } } multiclass VPseudoLoadMask { foreach mti = AllMasks in { let VLMul = mti.LMul.value in { def "_V_" # mti.BX : VPseudoUSLoadNoMask; } } } multiclass VPseudoSLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value in { def "E" # eew # "_V_" # LInfo : VPseudoSLoadNoMask, VLSSched; def "E" # eew # "_V_" # LInfo # "_TU": VPseudoSLoadNoMaskTU, VLSSched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSLoadMask, VLSSched; } } } } multiclass VPseudoILoad { foreach eew = EEWList in { foreach sew = EEWList in { foreach lmul = MxSet.m in { defvar octuple_lmul = lmul.octuple; // Calculate emul = eew * lmul / sew defvar octuple_emul = !srl(!mul(eew, octuple_lmul), log2.val); if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then { defvar LInfo = lmul.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idx_lmul = !cast("V_" # IdxLInfo); defvar Vreg = lmul.vrclass; defvar IdxVreg = idx_lmul.vrclass; defvar HasConstraint = !ne(sew, eew); defvar Order = !if(Ordered, "O", "U"); let VLMul = lmul.value in { def "EI" # eew # "_V_" # IdxLInfo # "_" # LInfo : VPseudoILoadNoMask, VLXSched; def "EI" # eew # "_V_" # IdxLInfo # "_" # LInfo # "_TU": VPseudoILoadNoMaskTU, VLXSched; def "EI" # eew # "_V_" # IdxLInfo # "_" # LInfo # "_MASK" : VPseudoILoadMask, VLXSched; } } } } } } multiclass VPseudoUSStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value in { def "E" # eew # "_V_" # LInfo : VPseudoUSStoreNoMask, VSESched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSStoreMask, VSESched; } } } } multiclass VPseudoStoreMask { foreach mti = AllMasks in { let VLMul = mti.LMul.value in { def "_V_" # mti.BX : VPseudoUSStoreNoMask; } } } multiclass VPseudoSStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value in { def "E" # eew # "_V_" # LInfo : VPseudoSStoreNoMask, VSSSched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSStoreMask, VSSSched; } } } } multiclass VPseudoIStore { foreach eew = EEWList in { foreach sew = EEWList in { foreach lmul = MxSet.m in { defvar octuple_lmul = lmul.octuple; // Calculate emul = eew * lmul / sew defvar octuple_emul = !srl(!mul(eew, octuple_lmul), log2.val); if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then { defvar LInfo = lmul.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idx_lmul = !cast("V_" # IdxLInfo); defvar Vreg = lmul.vrclass; defvar IdxVreg = idx_lmul.vrclass; defvar Order = !if(Ordered, "O", "U"); let VLMul = lmul.value in { def "EI" # eew # "_V_" # IdxLInfo # "_" # LInfo : VPseudoIStoreNoMask, VSXSched; def "EI" # eew # "_V_" # IdxLInfo # "_" # LInfo # "_MASK" : VPseudoIStoreMask, VSXSched; } } } } } } multiclass VPseudoVPOP_M { foreach mti = AllMasks in { let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoUnaryNoMask, Sched<[WriteVMPopV, ReadVMPopV, ReadVMPopV]>; def "_M_" # mti.BX # "_MASK" : VPseudoMaskUnarySOutMask, Sched<[WriteVMPopV, ReadVMPopV, ReadVMPopV]>; } } } multiclass VPseudoV1ST_M { foreach mti = AllMasks in { let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoUnaryNoMask, Sched<[WriteVMFFSV, ReadVMFFSV, ReadVMFFSV]>; def "_M_" # mti.BX # "_MASK" : VPseudoMaskUnarySOutMask, Sched<[WriteVMFFSV, ReadVMFFSV, ReadVMFFSV]>; } } } multiclass VPseudoVSFS_M { defvar constraint = "@earlyclobber $rd"; foreach mti = AllMasks in { let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoUnaryNoMask, Sched<[WriteVMSFSV, ReadVMSFSV, ReadVMask]>; def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMask, Sched<[WriteVMSFSV, ReadVMSFSV, ReadVMask]>; } } } multiclass VPseudoVID_V { foreach m = MxList in { let VLMul = m.value in { def "_V_" # m.MX : VPseudoNullaryNoMask, Sched<[WriteVMIdxV, ReadVMask]>; def "_V_" # m.MX # "_MASK" : VPseudoNullaryMask, Sched<[WriteVMIdxV, ReadVMask]>; } } } multiclass VPseudoNullaryPseudoM { foreach mti = AllMasks in { let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoNullaryPseudoM; } } } multiclass VPseudoVIOT_M { defvar constraint = "@earlyclobber $rd"; foreach m = MxList in { let VLMul = m.value in { def "_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVMIotV, ReadVMIotV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMask, Sched<[WriteVMIotV, ReadVMIotV, ReadVMask]>; } } } multiclass VPseudoVCPR_V { foreach m = MxList in { let VLMul = m.value in def _VM # "_" # m.MX : VPseudoUnaryAnyMask, Sched<[WriteVCompressV, ReadVCompressV, ReadVCompressV]>; } } multiclass VPseudoBinary { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoBinaryNoMask; def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMaskTA; } } multiclass VPseudoBinaryM { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoBinaryNoMask; let ForceTailAgnostic = true in def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMOutMask; } } multiclass VPseudoBinaryEmul { let VLMul = lmul.value in { def "_" # lmul.MX # "_" # emul.MX : VPseudoBinaryNoMask; def "_" # lmul.MX # "_" # emul.MX # "_MASK" : VPseudoBinaryMaskTA; } } multiclass VPseudoTiedBinary { let VLMul = MInfo.value in { def "_" # MInfo.MX # "_TIED": VPseudoTiedBinaryNoMask; def "_" # MInfo.MX # "_MASK_TIED" : VPseudoTiedBinaryMask; } } multiclass VPseudoBinaryV_VV { foreach m = MxList in defm _VV : VPseudoBinary; } // Similar to VPseudoBinaryV_VV, but uses MxListF. multiclass VPseudoBinaryFV_VV { foreach m = MxListF in defm _VV : VPseudoBinary; } multiclass VPseudoVGTR_VV_EEW { foreach m = MxList in { foreach sew = EEWList in { defvar octuple_lmul = m.octuple; // emul = lmul * eew / sew defvar octuple_emul = !srl(!mul(octuple_lmul, eew), log2.val); if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then { defvar emulMX = octuple_to_str.ret; defvar emul = !cast("V_" # emulMX); defm _VV : VPseudoBinaryEmul, Sched<[WriteVGatherV, ReadVGatherV, ReadVGatherV]>; } } } } multiclass VPseudoBinaryV_VX { foreach m = MxList in defm "_VX" : VPseudoBinary; } multiclass VPseudoVSLD1_VX { foreach m = MxList in defm "_VX" : VPseudoBinary, Sched<[WriteVISlide1X, ReadVISlideV, ReadVISlideX, ReadVMask]>; } multiclass VPseudoBinaryV_VF { foreach f = FPList in foreach m = f.MxList in defm "_V" # f.FX : VPseudoBinary; } multiclass VPseudoVSLD1_VF { foreach f = FPList in foreach m = f.MxList in defm "_V" # f.FX : VPseudoBinary, Sched<[WriteVFSlide1F, ReadVFSlideV, ReadVFSlideF, ReadVMask]>; } multiclass VPseudoBinaryV_VI { foreach m = MxList in defm _VI : VPseudoBinary; } multiclass VPseudoVALU_MM { foreach m = MxList in let VLMul = m.value in { def "_MM_" # m.MX : VPseudoBinaryNoMask, Sched<[WriteVMALUV, ReadVMALUV, ReadVMALUV]>; } } // We use earlyclobber here due to // * The destination EEW is smaller than the source EEW and the overlap is // in the lowest-numbered part of the source register group is legal. // Otherwise, it is illegal. // * The destination EEW is greater than the source EEW, the source EMUL is // at least 1, and the overlap is in the highest-numbered part of the // destination register group is legal. Otherwise, it is illegal. multiclass VPseudoBinaryW_VV mxlist = MxListW> { foreach m = mxlist in defm _VV : VPseudoBinary; } multiclass VPseudoBinaryW_VX { foreach m = MxListW in defm "_VX" : VPseudoBinary; } multiclass VPseudoBinaryW_VF { foreach f = FPListW in foreach m = f.MxList in defm "_V" # f.FX : VPseudoBinary; } multiclass VPseudoBinaryW_WV mxlist = MxListW> { foreach m = mxlist in { defm _WV : VPseudoBinary; defm _WV : VPseudoTiedBinary; } } multiclass VPseudoBinaryW_WX { foreach m = MxListW in defm "_WX" : VPseudoBinary; } multiclass VPseudoBinaryW_WF { foreach f = FPListW in foreach m = f.MxList in defm "_W" # f.FX : VPseudoBinary; } // Narrowing instructions like vnsrl/vnsra/vnclip(u) don't need @earlyclobber // if the source and destination have an LMUL<=1. This matches this overlap // exception from the spec. // "The destination EEW is smaller than the source EEW and the overlap is in the // lowest-numbered part of the source register group." multiclass VPseudoBinaryV_WV { foreach m = MxListW in defm _WV : VPseudoBinary; } multiclass VPseudoBinaryV_WX { foreach m = MxListW in defm _WX : VPseudoBinary; } multiclass VPseudoBinaryV_WI { foreach m = MxListW in defm _WI : VPseudoBinary; } // For vadc and vsbc, the instruction encoding is reserved if the destination // vector register is v0. // For vadc and vsbc, CarryIn == 1 and CarryOut == 0 multiclass VPseudoBinaryV_VM { foreach m = MxList in def "_VV" # !if(CarryIn, "M", "") # "_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass)), m.vrclass, m.vrclass, m, CarryIn, Constraint>; } multiclass VPseudoTiedBinaryV_VM { foreach m = MxList in def "_VV" # !if(CarryIn, "M", "") # "_" # m.MX # "_TU" : VPseudoTiedBinaryCarryIn.R, m.vrclass)), m.vrclass, m.vrclass, m, CarryIn, Constraint>; } multiclass VPseudoBinaryV_XM { foreach m = MxList in def "_VX" # !if(CarryIn, "M", "") # "_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass)), m.vrclass, GPR, m, CarryIn, Constraint>; } multiclass VPseudoTiedBinaryV_XM { foreach m = MxList in def "_VX" # !if(CarryIn, "M", "") # "_" # m.MX # "_TU": VPseudoTiedBinaryCarryIn.R, m.vrclass)), m.vrclass, GPR, m, CarryIn, Constraint>; } multiclass VPseudoVMRG_FM { foreach f = FPList in foreach m = f.MxList in { def "_V" # f.FX # "M_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass, f.fprclass, m, /*CarryIn=*/1, "">, Sched<[WriteVFMergeV, ReadVFMergeV, ReadVFMergeF, ReadVMask]>; // Tied version to allow codegen control over the tail elements def "_V" # f.FX # "M_" # m.MX # "_TU": VPseudoTiedBinaryCarryIn.R, m.vrclass, f.fprclass, m, /*CarryIn=*/1, "">, Sched<[WriteVFMergeV, ReadVFMergeV, ReadVFMergeF, ReadVMask]>; } } multiclass VPseudoBinaryV_IM { foreach m = MxList in def "_VI" # !if(CarryIn, "M", "") # "_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass)), m.vrclass, simm5, m, CarryIn, Constraint>; } multiclass VPseudoTiedBinaryV_IM { foreach m = MxList in def "_VI" # !if(CarryIn, "M", "") # "_" # m.MX # "_TU": VPseudoTiedBinaryCarryIn.R, m.vrclass)), m.vrclass, simm5, m, CarryIn, Constraint>; } multiclass VPseudoUnaryVMV_V_X_I { foreach m = MxList in { let VLMul = m.value in { def "_V_" # m.MX : VPseudoUnaryNoDummyMask, Sched<[WriteVIMovV, ReadVIMovV]>; def "_X_" # m.MX : VPseudoUnaryNoDummyMask, Sched<[WriteVIMovX, ReadVIMovX]>; def "_I_" # m.MX : VPseudoUnaryNoDummyMask, Sched<[WriteVIMovI]>; } } } multiclass VPseudoVMV_F { foreach f = FPList in { foreach m = f.MxList in { let VLMul = m.value in { def "_" # f.FX # "_" # m.MX : VPseudoUnaryNoDummyMask, Sched<[WriteVFMovV, ReadVFMovF]>; } } } } multiclass VPseudoVCLS_V { foreach m = MxListF in { let VLMul = m.value in { def "_V_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVFClassV, ReadVFClassV, ReadVMask]>; def "_V_" # m.MX # "_MASK" : VPseudoUnaryMask, Sched<[WriteVFClassV, ReadVFClassV, ReadVMask]>; } } } multiclass VPseudoVSQR_V { foreach m = MxListF in { let VLMul = m.value in { def "_V_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVFSqrtV, ReadVFSqrtV, ReadVMask]>; def "_V_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, Sched<[WriteVFSqrtV, ReadVFSqrtV, ReadVMask]>; } } } multiclass VPseudoVRCP_V { foreach m = MxListF in { let VLMul = m.value in { def "_V_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVFRecpV, ReadVFRecpV, ReadVMask]>; def "_V_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, Sched<[WriteVFRecpV, ReadVFRecpV, ReadVMask]>; } } } multiclass PseudoVEXT_VF2 { defvar constraints = "@earlyclobber $rd"; foreach m = MxListVF2 in { let VLMul = m.value in { def "_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; } } } multiclass PseudoVEXT_VF4 { defvar constraints = "@earlyclobber $rd"; foreach m = MxListVF4 in { let VLMul = m.value in { def "_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; } } } multiclass PseudoVEXT_VF8 { defvar constraints = "@earlyclobber $rd"; foreach m = MxListVF8 in { let VLMul = m.value in { def "_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; } } } // The destination EEW is 1 since "For the purposes of register group overlap // constraints, mask elements have EEW=1." // The source EEW is 8, 16, 32, or 64. // When the destination EEW is different from source EEW, we need to use // @earlyclobber to avoid the overlap between destination and source registers. // We don't need @earlyclobber for LMUL<=1 since that matches this overlap // exception from the spec // "The destination EEW is smaller than the source EEW and the overlap is in the // lowest-numbered part of the source register group". // With LMUL<=1 the source and dest occupy a single register so any overlap // is in the lowest-numbered part. multiclass VPseudoBinaryM_VV mxlist = MxList> { foreach m = mxlist in defm _VV : VPseudoBinaryM; } multiclass VPseudoBinaryM_VX { foreach m = MxList in defm "_VX" : VPseudoBinaryM; } multiclass VPseudoBinaryM_VF { foreach f = FPList in foreach m = f.MxList in defm "_V" # f.FX : VPseudoBinaryM; } multiclass VPseudoBinaryM_VI { foreach m = MxList in defm _VI : VPseudoBinaryM; } multiclass VPseudoVGTR_VV_VX_VI { defm "" : VPseudoBinaryV_VV, Sched<[WriteVGatherV, ReadVGatherV, ReadVGatherV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVGatherX, ReadVGatherV, ReadVGatherX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVGatherI, ReadVGatherV, ReadVMask]>; } multiclass VPseudoVSALU_VV_VX_VI { defm "" : VPseudoBinaryV_VV, Sched<[WriteVSALUV, ReadVSALUV, ReadVSALUV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVSALUX, ReadVSALUV, ReadVSALUX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVSALUI, ReadVSALUV, ReadVMask]>; } multiclass VPseudoVSHT_VV_VX_VI { defm "" : VPseudoBinaryV_VV, Sched<[WriteVShiftV, ReadVShiftV, ReadVShiftV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVShiftX, ReadVShiftV, ReadVShiftX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVShiftI, ReadVShiftV, ReadVMask]>; } multiclass VPseudoVSSHT_VV_VX_VI { defm "" : VPseudoBinaryV_VV, Sched<[WriteVSShiftV, ReadVSShiftV, ReadVSShiftV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVSShiftX, ReadVSShiftV, ReadVSShiftX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVSShiftI, ReadVSShiftV, ReadVMask]>; } multiclass VPseudoVALU_VV_VX_VI { defm "" : VPseudoBinaryV_VV, Sched<[WriteVIALUV, ReadVIALUV, ReadVIALUV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIALUX, ReadVIALUV, ReadVIALUX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVIALUI, ReadVIALUV, ReadVMask]>; } multiclass VPseudoVSALU_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVSALUV, ReadVSALUV, ReadVSALUV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVSALUX, ReadVSALUV, ReadVSALUX, ReadVMask]>; } multiclass VPseudoVSMUL_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVSMulV, ReadVSMulV, ReadVSMulV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVSMulX, ReadVSMulV, ReadVSMulX, ReadVMask]>; } multiclass VPseudoVAALU_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVAALUV, ReadVAALUV, ReadVAALUV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVAALUX, ReadVAALUV, ReadVAALUX, ReadVMask]>; } multiclass VPseudoVMINMAX_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVICmpV, ReadVICmpV, ReadVICmpV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVICmpX, ReadVICmpV, ReadVICmpX, ReadVMask]>; } multiclass VPseudoVMUL_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVIMulV, ReadVIMulV, ReadVIMulV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIMulX, ReadVIMulV, ReadVIMulX, ReadVMask]>; } multiclass VPseudoVDIV_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVIDivV, ReadVIDivV, ReadVIDivV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIDivX, ReadVIDivV, ReadVIDivX, ReadVMask]>; } multiclass VPseudoVFMUL_VV_VF { defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFMulV, ReadVFMulV, ReadVFMulV, ReadVMask]>; defm "" : VPseudoBinaryV_VF, Sched<[WriteVFMulF, ReadVFMulV, ReadVFMulF, ReadVMask]>; } multiclass VPseudoVFDIV_VV_VF { defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFDivV, ReadVFDivV, ReadVFDivV, ReadVMask]>; defm "" : VPseudoBinaryV_VF, Sched<[WriteVFDivF, ReadVFDivV, ReadVFDivF, ReadVMask]>; } multiclass VPseudoVFRDIV_VF { defm "" : VPseudoBinaryV_VF, Sched<[WriteVFDivF, ReadVFDivV, ReadVFDivF, ReadVMask]>; } multiclass VPseudoVALU_VV_VX { defm "" : VPseudoBinaryV_VV, Sched<[WriteVIALUV, ReadVIALUV, ReadVIALUV, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIALUX, ReadVIALUV, ReadVIALUX, ReadVMask]>; } multiclass VPseudoVSGNJ_VV_VF { defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFSgnjV, ReadVFSgnjV, ReadVFSgnjV, ReadVMask]>; defm "" : VPseudoBinaryV_VF, Sched<[WriteVFSgnjF, ReadVFSgnjV, ReadVFSgnjF, ReadVMask]>; } multiclass VPseudoVMAX_VV_VF { defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFCmpV, ReadVFCmpV, ReadVFCmpV, ReadVMask]>; defm "" : VPseudoBinaryV_VF, Sched<[WriteVFCmpF, ReadVFCmpV, ReadVFCmpF, ReadVMask]>; } multiclass VPseudoVALU_VV_VF { defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFALUV, ReadVFALUV, ReadVFALUV, ReadVMask]>; defm "" : VPseudoBinaryV_VF, Sched<[WriteVFALUF, ReadVFALUV, ReadVFALUF, ReadVMask]>; } multiclass VPseudoVALU_VF { defm "" : VPseudoBinaryV_VF, Sched<[WriteVFALUF, ReadVFALUV, ReadVFALUF, ReadVMask]>; } multiclass VPseudoVALU_VX_VI { defm "" : VPseudoBinaryV_VX, Sched<[WriteVIALUX, ReadVIALUV, ReadVIALUX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVIALUI, ReadVIALUV, ReadVMask]>; } multiclass VPseudoVWALU_VV_VX { defm "" : VPseudoBinaryW_VV, Sched<[WriteVIWALUV, ReadVIWALUV, ReadVIWALUV, ReadVMask]>; defm "" : VPseudoBinaryW_VX, Sched<[WriteVIWALUX, ReadVIWALUV, ReadVIWALUX, ReadVMask]>; } multiclass VPseudoVWMUL_VV_VX { defm "" : VPseudoBinaryW_VV, Sched<[WriteVIWMulV, ReadVIWMulV, ReadVIWMulV, ReadVMask]>; defm "" : VPseudoBinaryW_VX, Sched<[WriteVIWMulX, ReadVIWMulV, ReadVIWMulX, ReadVMask]>; } multiclass VPseudoVWMUL_VV_VF { defm "" : VPseudoBinaryW_VV, Sched<[WriteVFWMulV, ReadVFWMulV, ReadVFWMulV, ReadVMask]>; defm "" : VPseudoBinaryW_VF, Sched<[WriteVFWMulF, ReadVFWMulV, ReadVFWMulF, ReadVMask]>; } multiclass VPseudoVWALU_WV_WX { defm "" : VPseudoBinaryW_WV, Sched<[WriteVIWALUV, ReadVIWALUV, ReadVIWALUV, ReadVMask]>; defm "" : VPseudoBinaryW_WX, Sched<[WriteVIWALUX, ReadVIWALUV, ReadVIWALUX, ReadVMask]>; } multiclass VPseudoVFWALU_VV_VF { defm "" : VPseudoBinaryW_VV, Sched<[WriteVFWALUV, ReadVFWALUV, ReadVFWALUV, ReadVMask]>; defm "" : VPseudoBinaryW_VF, Sched<[WriteVFWALUF, ReadVFWALUV, ReadVFWALUF, ReadVMask]>; } multiclass VPseudoVFWALU_WV_WF { defm "" : VPseudoBinaryW_WV, Sched<[WriteVFWALUV, ReadVFWALUV, ReadVFWALUV, ReadVMask]>; defm "" : VPseudoBinaryW_WF, Sched<[WriteVFWALUF, ReadVFWALUV, ReadVFWALUF, ReadVMask]>; } multiclass VPseudoVMRG_VM_XM_IM { defm "" : VPseudoBinaryV_VM, Sched<[WriteVIMergeV, ReadVIMergeV, ReadVIMergeV, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVIMergeX, ReadVIMergeV, ReadVIMergeX, ReadVMask]>; defm "" : VPseudoBinaryV_IM, Sched<[WriteVIMergeI, ReadVIMergeV, ReadVMask]>; // Tied versions to allow codegen control over the tail elements defm "" : VPseudoTiedBinaryV_VM, Sched<[WriteVIMergeV, ReadVIMergeV, ReadVIMergeV, ReadVMask]>; defm "" : VPseudoTiedBinaryV_XM, Sched<[WriteVIMergeX, ReadVIMergeV, ReadVIMergeX, ReadVMask]>; defm "" : VPseudoTiedBinaryV_IM, Sched<[WriteVIMergeI, ReadVIMergeV, ReadVMask]>; } multiclass VPseudoVCALU_VM_XM_IM { defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV, ReadVIALUCV, ReadVIALUCV, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX, ReadVIALUCV, ReadVIALUCX, ReadVMask]>; defm "" : VPseudoBinaryV_IM, Sched<[WriteVICALUI, ReadVIALUCV, ReadVMask]>; } multiclass VPseudoVCALU_VM_XM { defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV, ReadVIALUCV, ReadVIALUCV, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX, ReadVIALUCV, ReadVIALUCX, ReadVMask]>; } multiclass VPseudoVCALUM_VM_XM_IM { defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV, ReadVIALUCV, ReadVIALUCV, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX, ReadVIALUCV, ReadVIALUCX, ReadVMask]>; defm "" : VPseudoBinaryV_IM, Sched<[WriteVICALUI, ReadVIALUCV, ReadVMask]>; } multiclass VPseudoVCALUM_VM_XM { defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV, ReadVIALUCV, ReadVIALUCV, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX, ReadVIALUCV, ReadVIALUCX, ReadVMask]>; } multiclass VPseudoVCALUM_V_X_I { defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV, ReadVIALUCV, ReadVIALUCV]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX, ReadVIALUCV, ReadVIALUCX]>; defm "" : VPseudoBinaryV_IM, Sched<[WriteVICALUI, ReadVIALUCV]>; } multiclass VPseudoVCALUM_V_X { defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV, ReadVIALUCV, ReadVIALUCV]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX, ReadVIALUCV, ReadVIALUCX]>; } multiclass VPseudoVNCLP_WV_WX_WI { defm "" : VPseudoBinaryV_WV, Sched<[WriteVNClipV, ReadVNClipV, ReadVNClipV, ReadVMask]>; defm "" : VPseudoBinaryV_WX, Sched<[WriteVNClipX, ReadVNClipV, ReadVNClipX, ReadVMask]>; defm "" : VPseudoBinaryV_WI, Sched<[WriteVNClipI, ReadVNClipV, ReadVMask]>; } multiclass VPseudoVNSHT_WV_WX_WI { defm "" : VPseudoBinaryV_WV, Sched<[WriteVNShiftV, ReadVNShiftV, ReadVNShiftV, ReadVMask]>; defm "" : VPseudoBinaryV_WX, Sched<[WriteVNShiftX, ReadVNShiftV, ReadVNShiftX, ReadVMask]>; defm "" : VPseudoBinaryV_WI, Sched<[WriteVNShiftI, ReadVNShiftV, ReadVMask]>; } multiclass VPseudoTernary { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoTernaryNoMask; def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMask; } } multiclass VPseudoTernaryWithPolicy { let VLMul = MInfo.value in { let isCommutable = Commutable in def "_" # MInfo.MX : VPseudoTernaryNoMaskWithPolicy; def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMask; } } multiclass VPseudoTernaryV_VV_AAXA mxlist = MxList> { foreach m = mxlist in { defm _VV : VPseudoTernaryWithPolicy; } } multiclass VPseudoTernaryV_VX { foreach m = MxList in defm _VX : VPseudoTernary; } multiclass VPseudoTernaryV_VX_AAXA { foreach m = MxList in defm "_VX" : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryV_VF_AAXA { foreach f = FPList in foreach m = f.MxList in defm "_V" # f.FX : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryW_VV mxlist = MxListW> { defvar constraint = "@earlyclobber $rd"; foreach m = mxlist in defm _VV : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryW_VX { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in defm "_VX" : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryW_VF { defvar constraint = "@earlyclobber $rd"; foreach f = FPListW in foreach m = f.MxList in defm "_V" # f.FX : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryV_VI { foreach m = MxList in defm _VI : VPseudoTernary; } multiclass VPseudoVMAC_VV_VX_AAXA { defm "" : VPseudoTernaryV_VV_AAXA, Sched<[WriteVIMulAddV, ReadVIMulAddV, ReadVIMulAddV, ReadVIMulAddV, ReadVMask]>; defm "" : VPseudoTernaryV_VX_AAXA, Sched<[WriteVIMulAddX, ReadVIMulAddV, ReadVIMulAddV, ReadVIMulAddX, ReadVMask]>; } multiclass VPseudoVMAC_VV_VF_AAXA { defm "" : VPseudoTernaryV_VV_AAXA, Sched<[WriteVFMulAddV, ReadVFMulAddV, ReadVFMulAddV, ReadVFMulAddV, ReadVMask]>; defm "" : VPseudoTernaryV_VF_AAXA, Sched<[WriteVFMulAddF, ReadVFMulAddV, ReadVFMulAddV, ReadVFMulAddF, ReadVMask]>; } multiclass VPseudoVSLD_VX_VI { defm "" : VPseudoTernaryV_VX, Sched<[WriteVISlideX, ReadVISlideV, ReadVISlideV, ReadVISlideX, ReadVMask]>; defm "" : VPseudoTernaryV_VI, Sched<[WriteVISlideI, ReadVISlideV, ReadVISlideV, ReadVMask]>; } multiclass VPseudoVWMAC_VV_VX { defm "" : VPseudoTernaryW_VV, Sched<[WriteVIWMulAddV, ReadVIWMulAddV, ReadVIWMulAddV, ReadVIWMulAddV, ReadVMask]>; defm "" : VPseudoTernaryW_VX, Sched<[WriteVIWMulAddX, ReadVIWMulAddV, ReadVIWMulAddV, ReadVIWMulAddX, ReadVMask]>; } multiclass VPseudoVWMAC_VX { defm "" : VPseudoTernaryW_VX, Sched<[WriteVIWMulAddX, ReadVIWMulAddV, ReadVIWMulAddV, ReadVIWMulAddX, ReadVMask]>; } multiclass VPseudoVWMAC_VV_VF { defm "" : VPseudoTernaryW_VV, Sched<[WriteVFWMulAddV, ReadVFWMulAddV, ReadVFWMulAddV, ReadVFWMulAddV, ReadVMask]>; defm "" : VPseudoTernaryW_VF, Sched<[WriteVFWMulAddF, ReadVFWMulAddV, ReadVFWMulAddV, ReadVFWMulAddF, ReadVMask]>; } multiclass VPseudoVCMPM_VV_VX_VI { defm "" : VPseudoBinaryM_VV, Sched<[WriteVICmpV, ReadVICmpV, ReadVICmpV, ReadVMask]>; defm "" : VPseudoBinaryM_VX, Sched<[WriteVICmpX, ReadVICmpV, ReadVICmpX, ReadVMask]>; defm "" : VPseudoBinaryM_VI, Sched<[WriteVICmpI, ReadVICmpV, ReadVMask]>; } multiclass VPseudoVCMPM_VV_VX { defm "" : VPseudoBinaryM_VV, Sched<[WriteVICmpV, ReadVICmpV, ReadVICmpV, ReadVMask]>; defm "" : VPseudoBinaryM_VX, Sched<[WriteVICmpX, ReadVICmpV, ReadVICmpX, ReadVMask]>; } multiclass VPseudoVCMPM_VV_VF { defm "" : VPseudoBinaryM_VV, Sched<[WriteVFCmpV, ReadVFCmpV, ReadVFCmpV, ReadVMask]>; defm "" : VPseudoBinaryM_VF, Sched<[WriteVFCmpF, ReadVFCmpV, ReadVFCmpF, ReadVMask]>; } multiclass VPseudoVCMPM_VF { defm "" : VPseudoBinaryM_VF, Sched<[WriteVFCmpF, ReadVFCmpV, ReadVFCmpF, ReadVMask]>; } multiclass VPseudoVCMPM_VX_VI { defm "" : VPseudoBinaryM_VX, Sched<[WriteVICmpX, ReadVICmpV, ReadVICmpX, ReadVMask]>; defm "" : VPseudoBinaryM_VI, Sched<[WriteVICmpI, ReadVICmpV, ReadVMask]>; } multiclass VPseudoVRED_VS { foreach m = MxList in { defm _VS : VPseudoTernary, Sched<[WriteVIRedV, ReadVIRedV, ReadVIRedV, ReadVIRedV, ReadVMask]>; } } multiclass VPseudoVWRED_VS { foreach m = MxList in { defm _VS : VPseudoTernary, Sched<[WriteVIWRedV, ReadVIWRedV, ReadVIWRedV, ReadVIWRedV, ReadVMask]>; } } multiclass VPseudoVFRED_VS { foreach m = MxListF in { defm _VS : VPseudoTernary, Sched<[WriteVFRedV, ReadVFRedV, ReadVFRedV, ReadVFRedV, ReadVMask]>; } } multiclass VPseudoVFREDO_VS { foreach m = MxListF in { defm _VS : VPseudoTernary, Sched<[WriteVFRedOV, ReadVFRedOV, ReadVFRedOV, ReadVFRedOV, ReadVMask]>; } } multiclass VPseudoVFWRED_VS { foreach m = MxListF in { defm _VS : VPseudoTernary, Sched<[WriteVFWRedV, ReadVFWRedV, ReadVFWRedV, ReadVFWRedV, ReadVMask]>; } } multiclass VPseudoConversion { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoUnaryNoMask; def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMaskTA; } } multiclass VPseudoVCVTI_V { foreach m = MxListF in defm _V : VPseudoConversion, Sched<[WriteVFCvtFToIV, ReadVFCvtFToIV, ReadVMask]>; } multiclass VPseudoVCVTF_V { foreach m = MxListF in defm _V : VPseudoConversion, Sched<[WriteVFCvtIToFV, ReadVFCvtIToFV, ReadVMask]>; } multiclass VPseudoConversionW_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in defm _V : VPseudoConversion; } multiclass VPseudoVWCVTI_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in defm _V : VPseudoConversion, Sched<[WriteVFWCvtFToIV, ReadVFWCvtFToIV, ReadVMask]>; } multiclass VPseudoVWCVTF_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in defm _V : VPseudoConversion, Sched<[WriteVFWCvtIToFV, ReadVFWCvtIToFV, ReadVMask]>; } multiclass VPseudoVWCVTD_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in defm _V : VPseudoConversion, Sched<[WriteVFWCvtFToFV, ReadVFWCvtFToFV, ReadVMask]>; } multiclass VPseudoVNCVTI_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in defm _W : VPseudoConversion, Sched<[WriteVFNCvtFToIV, ReadVFNCvtFToIV, ReadVMask]>; } multiclass VPseudoVNCVTF_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in defm _W : VPseudoConversion, Sched<[WriteVFNCvtIToFV, ReadVFNCvtIToFV, ReadVMask]>; } multiclass VPseudoVNCVTD_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in defm _W : VPseudoConversion, Sched<[WriteVFNCvtFToFV, ReadVFNCvtFToFV, ReadVMask]>; } multiclass VPseudoUSSegLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; defvar FFStr = !if(isFF, "FF", ""); def nf # "E" # eew # FFStr # "_V_" # LInfo : VPseudoUSSegLoadNoMask; def nf # "E" # eew # FFStr # "_V_" # LInfo # "_MASK" : VPseudoUSSegLoadMask; } } } } } multiclass VPseudoSSegLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoSSegLoadNoMask; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSSegLoadMask; } } } } } multiclass VPseudoISegLoad { foreach idx_eew = EEWList in { foreach sew = EEWList in { foreach val_lmul = MxSet.m in { defvar octuple_lmul = val_lmul.octuple; // Calculate emul = eew * lmul / sew defvar octuple_emul = !srl(!mul(idx_eew, octuple_lmul), log2.val); if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then { defvar ValLInfo = val_lmul.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idx_lmul = !cast("V_" # IdxLInfo); defvar Vreg = val_lmul.vrclass; defvar IdxVreg = idx_lmul.vrclass; let VLMul = val_lmul.value in { foreach nf = NFSet.L in { defvar ValVreg = SegRegClass.RC; def nf # "EI" # idx_eew # "_V_" # IdxLInfo # "_" # ValLInfo : VPseudoISegLoadNoMask; def nf # "EI" # idx_eew # "_V_" # IdxLInfo # "_" # ValLInfo # "_MASK" : VPseudoISegLoadMask; } } } } } } } multiclass VPseudoUSSegStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoUSSegStoreNoMask; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSSegStoreMask; } } } } } multiclass VPseudoSSegStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoSSegStoreNoMask; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSSegStoreMask; } } } } } multiclass VPseudoISegStore { foreach idx_eew = EEWList in { foreach sew = EEWList in { foreach val_lmul = MxSet.m in { defvar octuple_lmul = val_lmul.octuple; // Calculate emul = eew * lmul / sew defvar octuple_emul = !srl(!mul(idx_eew, octuple_lmul), log2.val); if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then { defvar ValLInfo = val_lmul.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idx_lmul = !cast("V_" # IdxLInfo); defvar Vreg = val_lmul.vrclass; defvar IdxVreg = idx_lmul.vrclass; let VLMul = val_lmul.value in { foreach nf = NFSet.L in { defvar ValVreg = SegRegClass.RC; def nf # "EI" # idx_eew # "_V_" # IdxLInfo # "_" # ValLInfo : VPseudoISegStoreNoMask; def nf # "EI" # idx_eew # "_V_" # IdxLInfo # "_" # ValLInfo # "_MASK" : VPseudoISegStoreMask; } } } } } } } //===----------------------------------------------------------------------===// // Helpers to define the intrinsic patterns. //===----------------------------------------------------------------------===// class VPatUnaryNoMask : Pat<(result_type (!cast(intrinsic_name) (op2_type op2_reg_class:$rs2), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) (op2_type op2_reg_class:$rs2), GPR:$vl, sew)>; class VPatUnaryMask : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX#"_MASK") (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), GPR:$vl, sew)>; class VPatUnaryMaskTA : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), VLOpFrag, (XLenVT timm:$policy))), (!cast(inst#"_"#kind#"_"#vlmul.MX#"_MASK") (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), GPR:$vl, sew, (XLenVT timm:$policy))>; class VPatMaskUnaryNoMask : Pat<(mti.Mask (!cast(intrinsic_name) (mti.Mask VR:$rs2), VLOpFrag)), (!cast(inst#"_M_"#mti.BX) (mti.Mask VR:$rs2), GPR:$vl, mti.Log2SEW)>; class VPatMaskUnaryMask : Pat<(mti.Mask (!cast(intrinsic_name#"_mask") (mti.Mask VR:$merge), (mti.Mask VR:$rs2), (mti.Mask V0), VLOpFrag)), (!cast(inst#"_M_"#mti.BX#"_MASK") (mti.Mask VR:$merge), (mti.Mask VR:$rs2), (mti.Mask V0), GPR:$vl, mti.Log2SEW)>; class VPatUnaryAnyMask : Pat<(result_type (!cast(intrinsic) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (mask_type VR:$rs2), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (mask_type VR:$rs2), GPR:$vl, sew)>; class VPatBinaryNoMask : Pat<(result_type (!cast(intrinsic_name) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), GPR:$vl, sew)>; // Same as above but source operands are swapped. class VPatBinaryNoMaskSwapped : Pat<(result_type (!cast(intrinsic_name) (op2_type op2_kind:$rs2), (op1_type op1_reg_class:$rs1), VLOpFrag)), (!cast(inst) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), GPR:$vl, sew)>; class VPatBinaryMask : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), VLOpFrag)), (!cast(inst#"_MASK") (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), GPR:$vl, sew)>; class VPatBinaryMaskTA : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), VLOpFrag, (XLenVT timm:$policy))), (!cast(inst#"_MASK") (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), GPR:$vl, sew, (XLenVT timm:$policy))>; // Same as above but source operands are swapped. class VPatBinaryMaskSwapped : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), (op1_type op1_reg_class:$rs1), (mask_type V0), VLOpFrag)), (!cast(inst#"_MASK") (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), GPR:$vl, sew)>; class VPatTiedBinaryNoMask : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$rs1), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst#"_TIED") (result_type result_reg_class:$rs1), (op2_type op2_kind:$rs2), GPR:$vl, sew)>; class VPatTiedBinaryMask : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), (mask_type V0), VLOpFrag, (XLenVT timm:$policy))), (!cast(inst#"_MASK_TIED") (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), (mask_type V0), GPR:$vl, sew, (XLenVT timm:$policy))>; class VPatTernaryNoMask : Pat<(result_type (!cast(intrinsic) (result_type result_reg_class:$rs3), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, GPR:$vl, sew)>; class VPatTernaryNoMaskWithPolicy : Pat<(result_type (!cast(intrinsic) (result_type result_reg_class:$rs3), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, GPR:$vl, sew, TAIL_UNDISTURBED)>; class VPatTernaryMask : Pat<(result_type (!cast(intrinsic#"_mask") (result_type result_reg_class:$rs3), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX # "_MASK") result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, (mask_type V0), GPR:$vl, sew)>; multiclass VPatUnaryS_M { foreach mti = AllMasks in { def : Pat<(XLenVT (!cast(intrinsic_name) (mti.Mask VR:$rs1), VLOpFrag)), (!cast(inst#"_M_"#mti.BX) $rs1, GPR:$vl, mti.Log2SEW)>; def : Pat<(XLenVT (!cast(intrinsic_name # "_mask") (mti.Mask VR:$rs1), (mti.Mask V0), VLOpFrag)), (!cast(inst#"_M_"#mti.BX#"_MASK") $rs1, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>; } } multiclass VPatUnaryV_V_AnyMask vtilist> { foreach vti = vtilist in { def : VPatUnaryAnyMask; } } multiclass VPatUnaryM_M { foreach mti = AllMasks in { def : VPatMaskUnaryNoMask; def : VPatMaskUnaryMask; } } multiclass VPatUnaryV_M { foreach vti = AllIntegerVectors in { def : VPatUnaryNoMask; def : VPatUnaryMask; } } multiclass VPatUnaryV_VF fractionList> { foreach vtiTofti = fractionList in { defvar vti = vtiTofti.Vti; defvar fti = vtiTofti.Fti; def : VPatUnaryNoMask; def : VPatUnaryMaskTA; } } multiclass VPatUnaryV_V vtilist> { foreach vti = vtilist in { def : VPatUnaryNoMask; def : VPatUnaryMaskTA; } } multiclass VPatNullaryV { foreach vti = AllIntegerVectors in { def : Pat<(vti.Vector (!cast(intrinsic) VLOpFrag)), (!cast(instruction#"_V_" # vti.LMul.MX) GPR:$vl, vti.Log2SEW)>; def : Pat<(vti.Vector (!cast(intrinsic # "_mask") (vti.Vector vti.RegClass:$merge), (vti.Mask V0), VLOpFrag)), (!cast(instruction#"_V_" # vti.LMul.MX # "_MASK") vti.RegClass:$merge, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>; } } multiclass VPatNullaryM { foreach mti = AllMasks in def : Pat<(mti.Mask (!cast(intrinsic) (XLenVT (VLOp (XLenVT (XLenVT GPR:$vl)))))), (!cast(inst#"_M_"#mti.BX) GPR:$vl, mti.Log2SEW)>; } multiclass VPatBinary { def : VPatBinaryNoMask; def : VPatBinaryMask; } multiclass VPatBinaryTA { def : VPatBinaryNoMask; def : VPatBinaryMaskTA; } multiclass VPatBinarySwapped { def : VPatBinaryNoMaskSwapped; def : VPatBinaryMaskSwapped; } multiclass VPatBinaryCarryIn { def : Pat<(result_type (!cast(intrinsic) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), GPR:$vl, sew)>; } multiclass VPatBinaryMaskOut { def : Pat<(result_type (!cast(intrinsic) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), GPR:$vl, sew)>; } multiclass VPatConversion { def : VPatUnaryNoMask; def : VPatUnaryMask; } multiclass VPatConversionTA { def : VPatUnaryNoMask; def : VPatUnaryMaskTA; } multiclass VPatBinaryV_VV vtilist> { foreach vti = vtilist in defm : VPatBinaryTA; } multiclass VPatBinaryV_VV_INT vtilist> { foreach vti = vtilist in { defvar ivti = GetIntVTypeInfo.Vti; defm : VPatBinaryTA; } } multiclass VPatBinaryV_VV_INT_EEW vtilist> { foreach vti = vtilist in { // emul = lmul * eew / sew defvar vlmul = vti.LMul; defvar octuple_lmul = vlmul.octuple; defvar octuple_emul = !srl(!mul(octuple_lmul, eew), vti.Log2SEW); if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then { defvar emul_str = octuple_to_str.ret; defvar ivti = !cast("VI" # eew # emul_str); defvar inst = instruction # "_VV_" # vti.LMul.MX # "_" # emul_str; defm : VPatBinaryTA; } } } multiclass VPatBinaryV_VX vtilist> { foreach vti = vtilist in { defvar kind = "V"#vti.ScalarSuffix; defm : VPatBinaryTA; } } multiclass VPatBinaryV_VX_INT vtilist> { foreach vti = vtilist in defm : VPatBinaryTA; } multiclass VPatBinaryV_VI vtilist, Operand imm_type> { foreach vti = vtilist in defm : VPatBinaryTA; } multiclass VPatBinaryM_MM { foreach mti = AllMasks in def : VPatBinaryNoMask; } multiclass VPatBinaryW_VV vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defm : VPatBinaryTA; } } multiclass VPatBinaryW_VX vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "V"#Vti.ScalarSuffix; defm : VPatBinaryTA; } } multiclass VPatBinaryW_WV vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; def : VPatTiedBinaryNoMask; let AddedComplexity = 1 in def : VPatTiedBinaryMask; def : VPatBinaryMaskTA; } } multiclass VPatBinaryW_WX vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "W"#Vti.ScalarSuffix; defm : VPatBinaryTA; } } multiclass VPatBinaryV_WV vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defm : VPatBinaryTA; } } multiclass VPatBinaryV_WX vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "W"#Vti.ScalarSuffix; defm : VPatBinaryTA; } } multiclass VPatBinaryV_WI vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defm : VPatBinaryTA; } } multiclass VPatBinaryV_VM vtilist = AllIntegerVectors> { foreach vti = vtilist in defm : VPatBinaryCarryIn; } multiclass VPatBinaryV_XM vtilist = AllIntegerVectors> { foreach vti = vtilist in defm : VPatBinaryCarryIn; } multiclass VPatBinaryV_IM { foreach vti = AllIntegerVectors in defm : VPatBinaryCarryIn; } multiclass VPatBinaryV_V { foreach vti = AllIntegerVectors in defm : VPatBinaryMaskOut; } multiclass VPatBinaryV_X { foreach vti = AllIntegerVectors in defm : VPatBinaryMaskOut; } multiclass VPatBinaryV_I { foreach vti = AllIntegerVectors in defm : VPatBinaryMaskOut; } multiclass VPatBinaryM_VV vtilist> { foreach vti = vtilist in defm : VPatBinary; } multiclass VPatBinarySwappedM_VV vtilist> { foreach vti = vtilist in defm : VPatBinarySwapped; } multiclass VPatBinaryM_VX vtilist> { foreach vti = vtilist in { defvar kind = "V"#vti.ScalarSuffix; defm : VPatBinary; } } multiclass VPatBinaryM_VI vtilist> { foreach vti = vtilist in defm : VPatBinary; } multiclass VPatBinaryV_VV_VX_VI vtilist, Operand ImmType = simm5> : VPatBinaryV_VV, VPatBinaryV_VX, VPatBinaryV_VI; multiclass VPatBinaryV_VV_VX vtilist> : VPatBinaryV_VV, VPatBinaryV_VX; multiclass VPatBinaryV_VX_VI vtilist> : VPatBinaryV_VX, VPatBinaryV_VI; multiclass VPatBinaryW_VV_VX vtilist> : VPatBinaryW_VV, VPatBinaryW_VX; multiclass VPatBinaryW_WV_WX vtilist> : VPatBinaryW_WV, VPatBinaryW_WX; multiclass VPatBinaryV_WV_WX_WI vtilist> : VPatBinaryV_WV, VPatBinaryV_WX, VPatBinaryV_WI; multiclass VPatBinaryV_VM_XM_IM : VPatBinaryV_VM, VPatBinaryV_XM, VPatBinaryV_IM; multiclass VPatBinaryM_VM_XM_IM : VPatBinaryV_VM, VPatBinaryV_XM, VPatBinaryV_IM; multiclass VPatBinaryM_V_X_I : VPatBinaryV_V, VPatBinaryV_X, VPatBinaryV_I; multiclass VPatBinaryV_VM_XM : VPatBinaryV_VM, VPatBinaryV_XM; multiclass VPatBinaryM_VM_XM : VPatBinaryV_VM, VPatBinaryV_XM; multiclass VPatBinaryM_V_X : VPatBinaryV_V, VPatBinaryV_X; multiclass VPatTernary { def : VPatTernaryNoMask; def : VPatTernaryMask; } multiclass VPatTernaryWithPolicy { def : VPatTernaryNoMaskWithPolicy; def : VPatTernaryMask; } multiclass VPatTernaryV_VV_AAXA vtilist> { foreach vti = vtilist in defm : VPatTernaryWithPolicy; } multiclass VPatTernaryV_VX vtilist> { foreach vti = vtilist in defm : VPatTernary; } multiclass VPatTernaryV_VX_AAXA vtilist> { foreach vti = vtilist in defm : VPatTernaryWithPolicy; } multiclass VPatTernaryV_VI vtilist, Operand Imm_type> { foreach vti = vtilist in defm : VPatTernary; } multiclass VPatTernaryW_VV vtilist> { foreach vtiToWti = vtilist in { defvar vti = vtiToWti.Vti; defvar wti = vtiToWti.Wti; defm : VPatTernaryWithPolicy; } } multiclass VPatTernaryW_VX vtilist> { foreach vtiToWti = vtilist in { defvar vti = vtiToWti.Vti; defvar wti = vtiToWti.Wti; defm : VPatTernaryWithPolicy; } } multiclass VPatTernaryV_VV_VX_AAXA vtilist> : VPatTernaryV_VV_AAXA, VPatTernaryV_VX_AAXA; multiclass VPatTernaryV_VX_VI vtilist, Operand Imm_type = simm5> : VPatTernaryV_VX, VPatTernaryV_VI; multiclass VPatBinaryM_VV_VX_VI vtilist> : VPatBinaryM_VV, VPatBinaryM_VX, VPatBinaryM_VI; multiclass VPatTernaryW_VV_VX vtilist> : VPatTernaryW_VV, VPatTernaryW_VX; multiclass VPatBinaryM_VV_VX vtilist> : VPatBinaryM_VV, VPatBinaryM_VX; multiclass VPatBinaryM_VX_VI vtilist> : VPatBinaryM_VX, VPatBinaryM_VI; multiclass VPatBinaryV_VV_VX_VI_INT vtilist, Operand ImmType = simm5> : VPatBinaryV_VV_INT, VPatBinaryV_VX_INT, VPatBinaryV_VI; multiclass VPatReductionV_VS { foreach vti = !if(IsFloat, NoGroupFloatVectors, NoGroupIntegerVectors) in { defvar vectorM1 = !cast(!if(IsFloat, "VF", "VI") # vti.SEW # "M1"); defm : VPatTernary; } foreach gvti = !if(IsFloat, GroupFloatVectors, GroupIntegerVectors) in { defm : VPatTernary; } } multiclass VPatReductionW_VS { foreach vti = !if(IsFloat, AllFloatVectors, AllIntegerVectors) in { defvar wtiSEW = !mul(vti.SEW, 2); if !le(wtiSEW, 64) then { defvar wtiM1 = !cast(!if(IsFloat, "VF", "VI") # wtiSEW # "M1"); defm : VPatTernary; } } } multiclass VPatClassifyVI_VF { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; defm : VPatConversion; } } multiclass VPatConversionVI_VF { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; defm : VPatConversionTA; } } multiclass VPatConversionVF_VI { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; defm : VPatConversionTA; } } multiclass VPatConversionWI_VF { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; defm : VPatConversionTA; } } multiclass VPatConversionWF_VI { foreach vtiToWti = AllWidenableIntToFloatVectors in { defvar vti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; defm : VPatConversionTA; } } multiclass VPatConversionWF_VF { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; defm : VPatConversionTA; } } multiclass VPatConversionVI_WF { foreach vtiToWti = AllWidenableIntToFloatVectors in { defvar vti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; defm : VPatConversionTA; } } multiclass VPatConversionVF_WI { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; defm : VPatConversionTA; } } multiclass VPatConversionVF_WF { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; defm : VPatConversionTA; } } multiclass VPatCompare_VI { foreach vti = AllIntegerVectors in { defvar Intr = !cast(intrinsic); defvar Pseudo = !cast(inst#"_VI_"#vti.LMul.MX); def : Pat<(vti.Mask (Intr (vti.Vector vti.RegClass:$rs1), (vti.Scalar ImmType:$rs2), VLOpFrag)), (Pseudo vti.RegClass:$rs1, (DecImm ImmType:$rs2), GPR:$vl, vti.Log2SEW)>; defvar IntrMask = !cast(intrinsic # "_mask"); defvar PseudoMask = !cast(inst#"_VI_"#vti.LMul.MX#"_MASK"); def : Pat<(vti.Mask (IntrMask (vti.Mask VR:$merge), (vti.Vector vti.RegClass:$rs1), (vti.Scalar ImmType:$rs2), (vti.Mask V0), VLOpFrag)), (PseudoMask VR:$merge, vti.RegClass:$rs1, (DecImm ImmType:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW)>; } } //===----------------------------------------------------------------------===// // Pseudo instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { //===----------------------------------------------------------------------===// // Pseudo Instructions for CodeGen //===----------------------------------------------------------------------===// let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in { def PseudoVMV1R_V : VPseudo; def PseudoVMV2R_V : VPseudo; def PseudoVMV4R_V : VPseudo; def PseudoVMV8R_V : VPseudo; } let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1 in { def PseudoReadVLENB : Pseudo<(outs GPR:$rd), (ins), [(set GPR:$rd, (riscv_read_vlenb))]>; } let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Uses = [VL] in def PseudoReadVL : Pseudo<(outs GPR:$rd), (ins), []>; let hasSideEffects = 0, mayLoad = 0, mayStore = 1, isCodeGenOnly = 1 in { def PseudoVSPILL_M1 : VPseudo; def PseudoVSPILL_M2 : VPseudo; def PseudoVSPILL_M4 : VPseudo; def PseudoVSPILL_M8 : VPseudo; } let hasSideEffects = 0, mayLoad = 1, mayStore = 0, isCodeGenOnly = 1 in { def PseudoVRELOAD_M1 : VPseudo; def PseudoVRELOAD_M2 : VPseudo; def PseudoVRELOAD_M4 : VPseudo; def PseudoVRELOAD_M8 : VPseudo; } foreach lmul = MxList in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; let hasSideEffects = 0, mayLoad = 0, mayStore = 1, isCodeGenOnly = 1, Size = !mul(4, !sub(!mul(nf, 2), 1)) in { def "PseudoVSPILL" # nf # "_" # lmul.MX : Pseudo<(outs), (ins vreg:$rs1, GPR:$rs2, GPR:$vlenb), []>; } let hasSideEffects = 0, mayLoad = 1, mayStore = 0, isCodeGenOnly = 1, Size = !mul(4, !sub(!mul(nf, 2), 1)) in { def "PseudoVRELOAD" # nf # "_" # lmul.MX : Pseudo<(outs vreg:$rs1), (ins GPR:$rs2, GPR:$vlenb), []>; } } } //===----------------------------------------------------------------------===// // 6. Configuration-Setting Instructions //===----------------------------------------------------------------------===// // Pseudos. let hasSideEffects = 1, mayLoad = 0, mayStore = 0, Defs = [VL, VTYPE] in { // Due to rs1=X0 having special meaning, we need a GPRNoX0 register class for // the when we aren't using one of the special X0 encodings. Otherwise it could // be accidentally be made X0 by MachineIR optimizations. To satisfy the // verifier, we also need a GPRX0 instruction for the special encodings. def PseudoVSETVLI : Pseudo<(outs GPR:$rd), (ins GPRNoX0:$rs1, VTypeIOp11:$vtypei), []>; def PseudoVSETVLIX0 : Pseudo<(outs GPR:$rd), (ins GPRX0:$rs1, VTypeIOp11:$vtypei), []>; def PseudoVSETIVLI : Pseudo<(outs GPR:$rd), (ins uimm5:$rs1, VTypeIOp10:$vtypei), []>; } //===----------------------------------------------------------------------===// // 7. Vector Loads and Stores //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 7.4 Vector Unit-Stride Instructions //===----------------------------------------------------------------------===// // Pseudos Unit-Stride Loads and Stores defm PseudoVL : VPseudoUSLoad; defm PseudoVS : VPseudoUSStore; defm PseudoVLM : VPseudoLoadMask, Sched<[WriteVLDM, ReadVLDX]>; defm PseudoVSM : VPseudoStoreMask, Sched<[WriteVSTM, ReadVSTX]>; //===----------------------------------------------------------------------===// // 7.5 Vector Strided Instructions //===----------------------------------------------------------------------===// // Vector Strided Loads and Stores defm PseudoVLS : VPseudoSLoad; defm PseudoVSS : VPseudoSStore; //===----------------------------------------------------------------------===// // 7.6 Vector Indexed Instructions //===----------------------------------------------------------------------===// // Vector Indexed Loads and Stores defm PseudoVLUX : VPseudoILoad; defm PseudoVLOX : VPseudoILoad; defm PseudoVSOX : VPseudoIStore; defm PseudoVSUX : VPseudoIStore; //===----------------------------------------------------------------------===// // 7.7. Unit-stride Fault-Only-First Loads //===----------------------------------------------------------------------===// // vleff may update VL register let hasSideEffects = 1, Defs = [VL] in defm PseudoVL : VPseudoFFLoad; //===----------------------------------------------------------------------===// // 7.8. Vector Load/Store Segment Instructions //===----------------------------------------------------------------------===// defm PseudoVLSEG : VPseudoUSSegLoad; defm PseudoVLSSEG : VPseudoSSegLoad; defm PseudoVLOXSEG : VPseudoISegLoad; defm PseudoVLUXSEG : VPseudoISegLoad; defm PseudoVSSEG : VPseudoUSSegStore; defm PseudoVSSSEG : VPseudoSSegStore; defm PseudoVSOXSEG : VPseudoISegStore; defm PseudoVSUXSEG : VPseudoISegStore; // vlsegeff.v may update VL register let hasSideEffects = 1, Defs = [VL] in defm PseudoVLSEG : VPseudoUSSegLoad; //===----------------------------------------------------------------------===// // 12. Vector Integer Arithmetic Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 12.1. Vector Single-Width Integer Add and Subtract //===----------------------------------------------------------------------===// defm PseudoVADD : VPseudoVALU_VV_VX_VI; defm PseudoVSUB : VPseudoVALU_VV_VX; defm PseudoVRSUB : VPseudoVALU_VX_VI; foreach vti = AllIntegerVectors in { // Match vrsub with 2 vector operands to vsub.vv by swapping operands. This // Occurs when legalizing vrsub.vx intrinsics for i64 on RV32 since we need // to use a more complex splat sequence. Add the pattern for all VTs for // consistency. def : Pat<(vti.Vector (int_riscv_vrsub (vti.Vector vti.RegClass:$rs2), (vti.Vector vti.RegClass:$rs1), VLOpFrag)), (!cast("PseudoVSUB_VV_"#vti.LMul.MX) vti.RegClass:$rs1, vti.RegClass:$rs2, GPR:$vl, vti.Log2SEW)>; def : Pat<(vti.Vector (int_riscv_vrsub_mask (vti.Vector vti.RegClass:$merge), (vti.Vector vti.RegClass:$rs2), (vti.Vector vti.RegClass:$rs1), (vti.Mask V0), VLOpFrag, (XLenVT timm:$policy))), (!cast("PseudoVSUB_VV_"#vti.LMul.MX#"_MASK") vti.RegClass:$merge, vti.RegClass:$rs1, vti.RegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>; // Match VSUB with a small immediate to vadd.vi by negating the immediate. def : Pat<(vti.Vector (int_riscv_vsub (vti.Vector vti.RegClass:$rs1), (vti.Scalar simm5_plus1:$rs2), VLOpFrag)), (!cast("PseudoVADD_VI_"#vti.LMul.MX) vti.RegClass:$rs1, (NegImm simm5_plus1:$rs2), GPR:$vl, vti.Log2SEW)>; def : Pat<(vti.Vector (int_riscv_vsub_mask (vti.Vector vti.RegClass:$merge), (vti.Vector vti.RegClass:$rs1), (vti.Scalar simm5_plus1:$rs2), (vti.Mask V0), VLOpFrag, (XLenVT timm:$policy))), (!cast("PseudoVADD_VI_"#vti.LMul.MX#"_MASK") vti.RegClass:$merge, vti.RegClass:$rs1, (NegImm simm5_plus1:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>; } //===----------------------------------------------------------------------===// // 12.2. Vector Widening Integer Add/Subtract //===----------------------------------------------------------------------===// defm PseudoVWADDU : VPseudoVWALU_VV_VX; defm PseudoVWSUBU : VPseudoVWALU_VV_VX; defm PseudoVWADD : VPseudoVWALU_VV_VX; defm PseudoVWSUB : VPseudoVWALU_VV_VX; defm PseudoVWADDU : VPseudoVWALU_WV_WX; defm PseudoVWSUBU : VPseudoVWALU_WV_WX; defm PseudoVWADD : VPseudoVWALU_WV_WX; defm PseudoVWSUB : VPseudoVWALU_WV_WX; //===----------------------------------------------------------------------===// // 12.3. Vector Integer Extension //===----------------------------------------------------------------------===// defm PseudoVZEXT_VF2 : PseudoVEXT_VF2; defm PseudoVZEXT_VF4 : PseudoVEXT_VF4; defm PseudoVZEXT_VF8 : PseudoVEXT_VF8; defm PseudoVSEXT_VF2 : PseudoVEXT_VF2; defm PseudoVSEXT_VF4 : PseudoVEXT_VF4; defm PseudoVSEXT_VF8 : PseudoVEXT_VF8; //===----------------------------------------------------------------------===// // 12.4. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions //===----------------------------------------------------------------------===// defm PseudoVADC : VPseudoVCALU_VM_XM_IM; defm PseudoVMADC : VPseudoVCALUM_VM_XM_IM<"@earlyclobber $rd">; defm PseudoVMADC : VPseudoVCALUM_V_X_I<"@earlyclobber $rd">; defm PseudoVSBC : VPseudoVCALU_VM_XM; defm PseudoVMSBC : VPseudoVCALUM_VM_XM<"@earlyclobber $rd">; defm PseudoVMSBC : VPseudoVCALUM_V_X<"@earlyclobber $rd">; //===----------------------------------------------------------------------===// // 12.5. Vector Bitwise Logical Instructions //===----------------------------------------------------------------------===// defm PseudoVAND : VPseudoVALU_VV_VX_VI; defm PseudoVOR : VPseudoVALU_VV_VX_VI; defm PseudoVXOR : VPseudoVALU_VV_VX_VI; //===----------------------------------------------------------------------===// // 12.6. Vector Single-Width Bit Shift Instructions //===----------------------------------------------------------------------===// defm PseudoVSLL : VPseudoVSHT_VV_VX_VI; defm PseudoVSRL : VPseudoVSHT_VV_VX_VI; defm PseudoVSRA : VPseudoVSHT_VV_VX_VI; //===----------------------------------------------------------------------===// // 12.7. Vector Narrowing Integer Right Shift Instructions //===----------------------------------------------------------------------===// defm PseudoVNSRL : VPseudoVNSHT_WV_WX_WI; defm PseudoVNSRA : VPseudoVNSHT_WV_WX_WI; //===----------------------------------------------------------------------===// // 12.8. Vector Integer Comparison Instructions //===----------------------------------------------------------------------===// defm PseudoVMSEQ : VPseudoVCMPM_VV_VX_VI; defm PseudoVMSNE : VPseudoVCMPM_VV_VX_VI; defm PseudoVMSLTU : VPseudoVCMPM_VV_VX; defm PseudoVMSLT : VPseudoVCMPM_VV_VX; defm PseudoVMSLEU : VPseudoVCMPM_VV_VX_VI; defm PseudoVMSLE : VPseudoVCMPM_VV_VX_VI; defm PseudoVMSGTU : VPseudoVCMPM_VX_VI; defm PseudoVMSGT : VPseudoVCMPM_VX_VI; //===----------------------------------------------------------------------===// // 12.9. Vector Integer Min/Max Instructions //===----------------------------------------------------------------------===// defm PseudoVMINU : VPseudoVMINMAX_VV_VX; defm PseudoVMIN : VPseudoVMINMAX_VV_VX; defm PseudoVMAXU : VPseudoVMINMAX_VV_VX; defm PseudoVMAX : VPseudoVMINMAX_VV_VX; //===----------------------------------------------------------------------===// // 12.10. Vector Single-Width Integer Multiply Instructions //===----------------------------------------------------------------------===// defm PseudoVMUL : VPseudoVMUL_VV_VX; defm PseudoVMULH : VPseudoVMUL_VV_VX; defm PseudoVMULHU : VPseudoVMUL_VV_VX; defm PseudoVMULHSU : VPseudoVMUL_VV_VX; //===----------------------------------------------------------------------===// // 12.11. Vector Integer Divide Instructions //===----------------------------------------------------------------------===// defm PseudoVDIVU : VPseudoVDIV_VV_VX; defm PseudoVDIV : VPseudoVDIV_VV_VX; defm PseudoVREMU : VPseudoVDIV_VV_VX; defm PseudoVREM : VPseudoVDIV_VV_VX; //===----------------------------------------------------------------------===// // 12.12. Vector Widening Integer Multiply Instructions //===----------------------------------------------------------------------===// defm PseudoVWMUL : VPseudoVWMUL_VV_VX; defm PseudoVWMULU : VPseudoVWMUL_VV_VX; defm PseudoVWMULSU : VPseudoVWMUL_VV_VX; //===----------------------------------------------------------------------===// // 12.13. Vector Single-Width Integer Multiply-Add Instructions //===----------------------------------------------------------------------===// defm PseudoVMACC : VPseudoVMAC_VV_VX_AAXA; defm PseudoVNMSAC : VPseudoVMAC_VV_VX_AAXA; defm PseudoVMADD : VPseudoVMAC_VV_VX_AAXA; defm PseudoVNMSUB : VPseudoVMAC_VV_VX_AAXA; //===----------------------------------------------------------------------===// // 12.14. Vector Widening Integer Multiply-Add Instructions //===----------------------------------------------------------------------===// defm PseudoVWMACCU : VPseudoVWMAC_VV_VX; defm PseudoVWMACC : VPseudoVWMAC_VV_VX; defm PseudoVWMACCSU : VPseudoVWMAC_VV_VX; defm PseudoVWMACCUS : VPseudoVWMAC_VX; //===----------------------------------------------------------------------===// // 12.15. Vector Integer Merge Instructions //===----------------------------------------------------------------------===// defm PseudoVMERGE : VPseudoVMRG_VM_XM_IM; //===----------------------------------------------------------------------===// // 12.16. Vector Integer Move Instructions //===----------------------------------------------------------------------===// defm PseudoVMV_V : VPseudoUnaryVMV_V_X_I; //===----------------------------------------------------------------------===// // 13.1. Vector Single-Width Saturating Add and Subtract //===----------------------------------------------------------------------===// let Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVSADDU : VPseudoVSALU_VV_VX_VI; defm PseudoVSADD : VPseudoVSALU_VV_VX_VI; defm PseudoVSSUBU : VPseudoVSALU_VV_VX; defm PseudoVSSUB : VPseudoVSALU_VV_VX; } //===----------------------------------------------------------------------===// // 13.2. Vector Single-Width Averaging Add and Subtract //===----------------------------------------------------------------------===// let Uses = [VXRM], hasSideEffects = 1 in { defm PseudoVAADDU : VPseudoVAALU_VV_VX; defm PseudoVAADD : VPseudoVAALU_VV_VX; defm PseudoVASUBU : VPseudoVAALU_VV_VX; defm PseudoVASUB : VPseudoVAALU_VV_VX; } //===----------------------------------------------------------------------===// // 13.3. Vector Single-Width Fractional Multiply with Rounding and Saturation //===----------------------------------------------------------------------===// let Uses = [VXRM], Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVSMUL : VPseudoVSMUL_VV_VX; } //===----------------------------------------------------------------------===// // 13.4. Vector Single-Width Scaling Shift Instructions //===----------------------------------------------------------------------===// let Uses = [VXRM], hasSideEffects = 1 in { defm PseudoVSSRL : VPseudoVSSHT_VV_VX_VI; defm PseudoVSSRA : VPseudoVSSHT_VV_VX_VI; } //===----------------------------------------------------------------------===// // 13.5. Vector Narrowing Fixed-Point Clip Instructions //===----------------------------------------------------------------------===// let Uses = [VXRM], Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVNCLIP : VPseudoVNCLP_WV_WX_WI; defm PseudoVNCLIPU : VPseudoVNCLP_WV_WX_WI; } } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { //===----------------------------------------------------------------------===// // 14.2. Vector Single-Width Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// defm PseudoVFADD : VPseudoVALU_VV_VF; defm PseudoVFSUB : VPseudoVALU_VV_VF; defm PseudoVFRSUB : VPseudoVALU_VF; //===----------------------------------------------------------------------===// // 14.3. Vector Widening Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// defm PseudoVFWADD : VPseudoVFWALU_VV_VF; defm PseudoVFWSUB : VPseudoVFWALU_VV_VF; defm PseudoVFWADD : VPseudoVFWALU_WV_WF; defm PseudoVFWSUB : VPseudoVFWALU_WV_WF; //===----------------------------------------------------------------------===// // 14.4. Vector Single-Width Floating-Point Multiply/Divide Instructions //===----------------------------------------------------------------------===// defm PseudoVFMUL : VPseudoVFMUL_VV_VF; defm PseudoVFDIV : VPseudoVFDIV_VV_VF; defm PseudoVFRDIV : VPseudoVFRDIV_VF; //===----------------------------------------------------------------------===// // 14.5. Vector Widening Floating-Point Multiply //===----------------------------------------------------------------------===// defm PseudoVFWMUL : VPseudoVWMUL_VV_VF; //===----------------------------------------------------------------------===// // 14.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// defm PseudoVFMACC : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFNMACC : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFMSAC : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFNMSAC : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFMADD : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFNMADD : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFMSUB : VPseudoVMAC_VV_VF_AAXA; defm PseudoVFNMSUB : VPseudoVMAC_VV_VF_AAXA; //===----------------------------------------------------------------------===// // 14.7. Vector Widening Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// defm PseudoVFWMACC : VPseudoVWMAC_VV_VF; defm PseudoVFWNMACC : VPseudoVWMAC_VV_VF; defm PseudoVFWMSAC : VPseudoVWMAC_VV_VF; defm PseudoVFWNMSAC : VPseudoVWMAC_VV_VF; //===----------------------------------------------------------------------===// // 14.8. Vector Floating-Point Square-Root Instruction //===----------------------------------------------------------------------===// defm PseudoVFSQRT : VPseudoVSQR_V; //===----------------------------------------------------------------------===// // 14.9. Vector Floating-Point Reciprocal Square-Root Estimate Instruction //===----------------------------------------------------------------------===// defm PseudoVFRSQRT7 : VPseudoVRCP_V; //===----------------------------------------------------------------------===// // 14.10. Vector Floating-Point Reciprocal Estimate Instruction //===----------------------------------------------------------------------===// defm PseudoVFREC7 : VPseudoVRCP_V; //===----------------------------------------------------------------------===// // 14.11. Vector Floating-Point Min/Max Instructions //===----------------------------------------------------------------------===// defm PseudoVFMIN : VPseudoVMAX_VV_VF; defm PseudoVFMAX : VPseudoVMAX_VV_VF; //===----------------------------------------------------------------------===// // 14.12. Vector Floating-Point Sign-Injection Instructions //===----------------------------------------------------------------------===// defm PseudoVFSGNJ : VPseudoVSGNJ_VV_VF; defm PseudoVFSGNJN : VPseudoVSGNJ_VV_VF; defm PseudoVFSGNJX : VPseudoVSGNJ_VV_VF; //===----------------------------------------------------------------------===// // 14.13. Vector Floating-Point Compare Instructions //===----------------------------------------------------------------------===// defm PseudoVMFEQ : VPseudoVCMPM_VV_VF; defm PseudoVMFNE : VPseudoVCMPM_VV_VF; defm PseudoVMFLT : VPseudoVCMPM_VV_VF; defm PseudoVMFLE : VPseudoVCMPM_VV_VF; defm PseudoVMFGT : VPseudoVCMPM_VF; defm PseudoVMFGE : VPseudoVCMPM_VF; //===----------------------------------------------------------------------===// // 14.14. Vector Floating-Point Classify Instruction //===----------------------------------------------------------------------===// defm PseudoVFCLASS : VPseudoVCLS_V; //===----------------------------------------------------------------------===// // 14.15. Vector Floating-Point Merge Instruction //===----------------------------------------------------------------------===// defm PseudoVFMERGE : VPseudoVMRG_FM; //===----------------------------------------------------------------------===// // 14.16. Vector Floating-Point Move Instruction //===----------------------------------------------------------------------===// defm PseudoVFMV_V : VPseudoVMV_F; //===----------------------------------------------------------------------===// // 14.17. Single-Width Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm PseudoVFCVT_XU_F : VPseudoVCVTI_V; defm PseudoVFCVT_X_F : VPseudoVCVTI_V; defm PseudoVFCVT_RTZ_XU_F : VPseudoVCVTI_V; defm PseudoVFCVT_RTZ_X_F : VPseudoVCVTI_V; defm PseudoVFCVT_F_XU : VPseudoVCVTF_V; defm PseudoVFCVT_F_X : VPseudoVCVTF_V; //===----------------------------------------------------------------------===// // 14.18. Widening Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm PseudoVFWCVT_XU_F : VPseudoVWCVTI_V; defm PseudoVFWCVT_X_F : VPseudoVWCVTI_V; defm PseudoVFWCVT_RTZ_XU_F : VPseudoVWCVTI_V; defm PseudoVFWCVT_RTZ_X_F : VPseudoVWCVTI_V; defm PseudoVFWCVT_F_XU : VPseudoVWCVTF_V; defm PseudoVFWCVT_F_X : VPseudoVWCVTF_V; defm PseudoVFWCVT_F_F : VPseudoVWCVTD_V; //===----------------------------------------------------------------------===// // 14.19. Narrowing Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm PseudoVFNCVT_XU_F : VPseudoVNCVTI_W; defm PseudoVFNCVT_X_F : VPseudoVNCVTI_W; defm PseudoVFNCVT_RTZ_XU_F : VPseudoVNCVTI_W; defm PseudoVFNCVT_RTZ_X_F : VPseudoVNCVTI_W; defm PseudoVFNCVT_F_XU : VPseudoVNCVTF_W; defm PseudoVFNCVT_F_X : VPseudoVNCVTF_W; defm PseudoVFNCVT_F_F : VPseudoVNCVTD_W; defm PseudoVFNCVT_ROD_F_F : VPseudoVNCVTD_W; } // Predicates = [HasVInstructionsAnyF] let Predicates = [HasVInstructions] in { //===----------------------------------------------------------------------===// // 15.1. Vector Single-Width Integer Reduction Instructions //===----------------------------------------------------------------------===// defm PseudoVREDSUM : VPseudoVRED_VS; defm PseudoVREDAND : VPseudoVRED_VS; defm PseudoVREDOR : VPseudoVRED_VS; defm PseudoVREDXOR : VPseudoVRED_VS; defm PseudoVREDMINU : VPseudoVRED_VS; defm PseudoVREDMIN : VPseudoVRED_VS; defm PseudoVREDMAXU : VPseudoVRED_VS; defm PseudoVREDMAX : VPseudoVRED_VS; //===----------------------------------------------------------------------===// // 15.2. Vector Widening Integer Reduction Instructions //===----------------------------------------------------------------------===// let IsRVVWideningReduction = 1 in { defm PseudoVWREDSUMU : VPseudoVWRED_VS; defm PseudoVWREDSUM : VPseudoVWRED_VS; } } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { //===----------------------------------------------------------------------===// // 15.3. Vector Single-Width Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// defm PseudoVFREDOSUM : VPseudoVFREDO_VS; defm PseudoVFREDUSUM : VPseudoVFRED_VS; defm PseudoVFREDMIN : VPseudoVFRED_VS; defm PseudoVFREDMAX : VPseudoVFRED_VS; //===----------------------------------------------------------------------===// // 15.4. Vector Widening Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// let IsRVVWideningReduction = 1 in { defm PseudoVFWREDUSUM : VPseudoVFWRED_VS; defm PseudoVFWREDOSUM : VPseudoVFWRED_VS; } } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 16. Vector Mask Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 16.1 Vector Mask-Register Logical Instructions //===----------------------------------------------------------------------===// defm PseudoVMAND: VPseudoVALU_MM; defm PseudoVMNAND: VPseudoVALU_MM; defm PseudoVMANDN: VPseudoVALU_MM; defm PseudoVMXOR: VPseudoVALU_MM; defm PseudoVMOR: VPseudoVALU_MM; defm PseudoVMNOR: VPseudoVALU_MM; defm PseudoVMORN: VPseudoVALU_MM; defm PseudoVMXNOR: VPseudoVALU_MM; // Pseudo instructions defm PseudoVMCLR : VPseudoNullaryPseudoM<"VMXOR">, Sched<[WriteVMALUV, ReadVMALUV, ReadVMALUV]>; defm PseudoVMSET : VPseudoNullaryPseudoM<"VMXNOR">, Sched<[WriteVMALUV, ReadVMALUV, ReadVMALUV]>; //===----------------------------------------------------------------------===// // 16.2. Vector mask population count vcpop //===----------------------------------------------------------------------===// defm PseudoVCPOP: VPseudoVPOP_M; //===----------------------------------------------------------------------===// // 16.3. vfirst find-first-set mask bit //===----------------------------------------------------------------------===// defm PseudoVFIRST: VPseudoV1ST_M; //===----------------------------------------------------------------------===// // 16.4. vmsbf.m set-before-first mask bit //===----------------------------------------------------------------------===// defm PseudoVMSBF: VPseudoVSFS_M; //===----------------------------------------------------------------------===// // 16.5. vmsif.m set-including-first mask bit //===----------------------------------------------------------------------===// defm PseudoVMSIF: VPseudoVSFS_M; //===----------------------------------------------------------------------===// // 16.6. vmsof.m set-only-first mask bit //===----------------------------------------------------------------------===// defm PseudoVMSOF: VPseudoVSFS_M; //===----------------------------------------------------------------------===// // 16.8. Vector Iota Instruction //===----------------------------------------------------------------------===// defm PseudoVIOTA_M: VPseudoVIOT_M; //===----------------------------------------------------------------------===// // 16.9. Vector Element Index Instruction //===----------------------------------------------------------------------===// defm PseudoVID : VPseudoVID_V; //===----------------------------------------------------------------------===// // 17. Vector Permutation Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 17.1. Integer Scalar Move Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { foreach m = MxList in { let VLMul = m.value in { let HasSEWOp = 1, BaseInstr = VMV_X_S in def PseudoVMV_X_S # "_" # m.MX: Pseudo<(outs GPR:$rd), (ins m.vrclass:$rs2, ixlenimm:$sew), []>, Sched<[WriteVIMovVX, ReadVIMovVX]>, RISCVVPseudo; let HasVLOp = 1, HasSEWOp = 1, BaseInstr = VMV_S_X, Constraints = "$rd = $rs1" in def PseudoVMV_S_X # "_" # m.MX: Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew), []>, Sched<[WriteVIMovXV, ReadVIMovXV, ReadVIMovXX]>, RISCVVPseudo; } } } } // Predicates = [HasVInstructions] //===----------------------------------------------------------------------===// // 17.2. Floating-Point Scalar Move Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructionsAnyF] in { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { foreach f = FPList in { foreach m = f.MxList in { let VLMul = m.value in { let HasSEWOp = 1, BaseInstr = VFMV_F_S in def "PseudoVFMV_" # f.FX # "_S_" # m.MX : Pseudo<(outs f.fprclass:$rd), (ins m.vrclass:$rs2, ixlenimm:$sew), []>, Sched<[WriteVFMovVF, ReadVFMovVF]>, RISCVVPseudo; let HasVLOp = 1, HasSEWOp = 1, BaseInstr = VFMV_S_F, Constraints = "$rd = $rs1" in def "PseudoVFMV_S_" # f.FX # "_" # m.MX : Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, f.fprclass:$rs2, AVL:$vl, ixlenimm:$sew), []>, Sched<[WriteVFMovFV, ReadVFMovFV, ReadVFMovFX]>, RISCVVPseudo; } } } } } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 17.3. Vector Slide Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { defm PseudoVSLIDEUP : VPseudoVSLD_VX_VI; defm PseudoVSLIDEDOWN : VPseudoVSLD_VX_VI; defm PseudoVSLIDE1UP : VPseudoVSLD1_VX<"@earlyclobber $rd">; defm PseudoVSLIDE1DOWN : VPseudoVSLD1_VX; } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { defm PseudoVFSLIDE1UP : VPseudoVSLD1_VF<"@earlyclobber $rd">; defm PseudoVFSLIDE1DOWN : VPseudoVSLD1_VF; } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 17.4. Vector Register Gather Instructions //===----------------------------------------------------------------------===// defm PseudoVRGATHER : VPseudoVGTR_VV_VX_VI; defm PseudoVRGATHEREI16 : VPseudoVGTR_VV_EEW; //===----------------------------------------------------------------------===// // 17.5. Vector Compress Instruction //===----------------------------------------------------------------------===// defm PseudoVCOMPRESS : VPseudoVCPR_V; //===----------------------------------------------------------------------===// // Patterns. //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 12. Vector Integer Arithmetic Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { //===----------------------------------------------------------------------===// // 12.1. Vector Single-Width Integer Add and Subtract //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI<"int_riscv_vadd", "PseudoVADD", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vsub", "PseudoVSUB", AllIntegerVectors>; defm : VPatBinaryV_VX_VI<"int_riscv_vrsub", "PseudoVRSUB", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.2. Vector Widening Integer Add/Subtract //===----------------------------------------------------------------------===// defm : VPatBinaryW_VV_VX<"int_riscv_vwaddu", "PseudoVWADDU", AllWidenableIntVectors>; defm : VPatBinaryW_VV_VX<"int_riscv_vwsubu", "PseudoVWSUBU", AllWidenableIntVectors>; defm : VPatBinaryW_VV_VX<"int_riscv_vwadd", "PseudoVWADD", AllWidenableIntVectors>; defm : VPatBinaryW_VV_VX<"int_riscv_vwsub", "PseudoVWSUB", AllWidenableIntVectors>; defm : VPatBinaryW_WV_WX<"int_riscv_vwaddu_w", "PseudoVWADDU", AllWidenableIntVectors>; defm : VPatBinaryW_WV_WX<"int_riscv_vwsubu_w", "PseudoVWSUBU", AllWidenableIntVectors>; defm : VPatBinaryW_WV_WX<"int_riscv_vwadd_w", "PseudoVWADD", AllWidenableIntVectors>; defm : VPatBinaryW_WV_WX<"int_riscv_vwsub_w", "PseudoVWSUB", AllWidenableIntVectors>; //===----------------------------------------------------------------------===// // 12.3. Vector Integer Extension //===----------------------------------------------------------------------===// defm : VPatUnaryV_VF<"int_riscv_vzext", "PseudoVZEXT", "VF2", AllFractionableVF2IntVectors>; defm : VPatUnaryV_VF<"int_riscv_vzext", "PseudoVZEXT", "VF4", AllFractionableVF4IntVectors>; defm : VPatUnaryV_VF<"int_riscv_vzext", "PseudoVZEXT", "VF8", AllFractionableVF8IntVectors>; defm : VPatUnaryV_VF<"int_riscv_vsext", "PseudoVSEXT", "VF2", AllFractionableVF2IntVectors>; defm : VPatUnaryV_VF<"int_riscv_vsext", "PseudoVSEXT", "VF4", AllFractionableVF4IntVectors>; defm : VPatUnaryV_VF<"int_riscv_vsext", "PseudoVSEXT", "VF8", AllFractionableVF8IntVectors>; //===----------------------------------------------------------------------===// // 12.4. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VM_XM_IM<"int_riscv_vadc", "PseudoVADC">; defm : VPatBinaryM_VM_XM_IM<"int_riscv_vmadc_carry_in", "PseudoVMADC">; defm : VPatBinaryM_V_X_I<"int_riscv_vmadc", "PseudoVMADC">; defm : VPatBinaryV_VM_XM<"int_riscv_vsbc", "PseudoVSBC">; defm : VPatBinaryM_VM_XM<"int_riscv_vmsbc_borrow_in", "PseudoVMSBC">; defm : VPatBinaryM_V_X<"int_riscv_vmsbc", "PseudoVMSBC">; //===----------------------------------------------------------------------===// // 12.5. Vector Bitwise Logical Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI<"int_riscv_vand", "PseudoVAND", AllIntegerVectors>; defm : VPatBinaryV_VV_VX_VI<"int_riscv_vor", "PseudoVOR", AllIntegerVectors>; defm : VPatBinaryV_VV_VX_VI<"int_riscv_vxor", "PseudoVXOR", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.6. Vector Single-Width Bit Shift Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI<"int_riscv_vsll", "PseudoVSLL", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VV_VX_VI<"int_riscv_vsrl", "PseudoVSRL", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VV_VX_VI<"int_riscv_vsra", "PseudoVSRA", AllIntegerVectors, uimm5>; foreach vti = AllIntegerVectors in { // Emit shift by 1 as an add since it might be faster. def : Pat<(vti.Vector (int_riscv_vsll (vti.Vector vti.RegClass:$rs1), (XLenVT 1), VLOpFrag)), (!cast("PseudoVADD_VV_"#vti.LMul.MX) vti.RegClass:$rs1, vti.RegClass:$rs1, GPR:$vl, vti.Log2SEW)>; def : Pat<(vti.Vector (int_riscv_vsll_mask (vti.Vector vti.RegClass:$merge), (vti.Vector vti.RegClass:$rs1), (XLenVT 1), (vti.Mask V0), VLOpFrag, (XLenVT timm:$policy))), (!cast("PseudoVADD_VV_"#vti.LMul.MX#"_MASK") vti.RegClass:$merge, vti.RegClass:$rs1, vti.RegClass:$rs1, (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>; } //===----------------------------------------------------------------------===// // 12.7. Vector Narrowing Integer Right Shift Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_WV_WX_WI<"int_riscv_vnsrl", "PseudoVNSRL", AllWidenableIntVectors>; defm : VPatBinaryV_WV_WX_WI<"int_riscv_vnsra", "PseudoVNSRA", AllWidenableIntVectors>; //===----------------------------------------------------------------------===// // 12.8. Vector Integer Comparison Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryM_VV_VX_VI<"int_riscv_vmseq", "PseudoVMSEQ", AllIntegerVectors>; defm : VPatBinaryM_VV_VX_VI<"int_riscv_vmsne", "PseudoVMSNE", AllIntegerVectors>; defm : VPatBinaryM_VV_VX<"int_riscv_vmsltu", "PseudoVMSLTU", AllIntegerVectors>; defm : VPatBinaryM_VV_VX<"int_riscv_vmslt", "PseudoVMSLT", AllIntegerVectors>; defm : VPatBinaryM_VV_VX_VI<"int_riscv_vmsleu", "PseudoVMSLEU", AllIntegerVectors>; defm : VPatBinaryM_VV_VX_VI<"int_riscv_vmsle", "PseudoVMSLE", AllIntegerVectors>; defm : VPatBinaryM_VX_VI<"int_riscv_vmsgtu", "PseudoVMSGTU", AllIntegerVectors>; defm : VPatBinaryM_VX_VI<"int_riscv_vmsgt", "PseudoVMSGT", AllIntegerVectors>; // Match vmsgt with 2 vector operands to vmslt with the operands swapped. defm : VPatBinarySwappedM_VV<"int_riscv_vmsgtu", "PseudoVMSLTU", AllIntegerVectors>; defm : VPatBinarySwappedM_VV<"int_riscv_vmsgt", "PseudoVMSLT", AllIntegerVectors>; defm : VPatBinarySwappedM_VV<"int_riscv_vmsgeu", "PseudoVMSLEU", AllIntegerVectors>; defm : VPatBinarySwappedM_VV<"int_riscv_vmsge", "PseudoVMSLE", AllIntegerVectors>; // Match vmslt(u).vx intrinsics to vmsle(u).vi if the scalar is -15 to 16 and // non-zero. Zero can be .vx with x0. This avoids the user needing to know that // there is no vmslt(u).vi instruction. Similar for vmsge(u).vx intrinsics // using vmslt(u).vi. defm : VPatCompare_VI<"int_riscv_vmslt", "PseudoVMSLE", simm5_plus1_nonzero>; defm : VPatCompare_VI<"int_riscv_vmsltu", "PseudoVMSLEU", simm5_plus1_nonzero>; // We need to handle 0 for vmsge.vi using vmslt.vi because there is no vmsge.vx. defm : VPatCompare_VI<"int_riscv_vmsge", "PseudoVMSGT", simm5_plus1>; defm : VPatCompare_VI<"int_riscv_vmsgeu", "PseudoVMSGTU", simm5_plus1_nonzero>; //===----------------------------------------------------------------------===// // 12.9. Vector Integer Min/Max Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vminu", "PseudoVMINU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmin", "PseudoVMIN", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmaxu", "PseudoVMAXU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmax", "PseudoVMAX", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.10. Vector Single-Width Integer Multiply Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vmul", "PseudoVMUL", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulh", "PseudoVMULH", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulhu", "PseudoVMULHU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulhsu", "PseudoVMULHSU", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.11. Vector Integer Divide Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vdivu", "PseudoVDIVU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vdiv", "PseudoVDIV", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vremu", "PseudoVREMU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vrem", "PseudoVREM", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.12. Vector Widening Integer Multiply Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryW_VV_VX<"int_riscv_vwmul", "PseudoVWMUL", AllWidenableIntVectors>; defm : VPatBinaryW_VV_VX<"int_riscv_vwmulu", "PseudoVWMULU", AllWidenableIntVectors>; defm : VPatBinaryW_VV_VX<"int_riscv_vwmulsu", "PseudoVWMULSU", AllWidenableIntVectors>; //===----------------------------------------------------------------------===// // 12.13. Vector Single-Width Integer Multiply-Add Instructions //===----------------------------------------------------------------------===// defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vmadd", "PseudoVMADD", AllIntegerVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vnmsub", "PseudoVNMSUB", AllIntegerVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vmacc", "PseudoVMACC", AllIntegerVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vnmsac", "PseudoVNMSAC", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.14. Vector Widening Integer Multiply-Add Instructions //===----------------------------------------------------------------------===// defm : VPatTernaryW_VV_VX<"int_riscv_vwmaccu", "PseudoVWMACCU", AllWidenableIntVectors>; defm : VPatTernaryW_VV_VX<"int_riscv_vwmacc", "PseudoVWMACC", AllWidenableIntVectors>; defm : VPatTernaryW_VV_VX<"int_riscv_vwmaccsu", "PseudoVWMACCSU", AllWidenableIntVectors>; defm : VPatTernaryW_VX<"int_riscv_vwmaccus", "PseudoVWMACCUS", AllWidenableIntVectors>; //===----------------------------------------------------------------------===// // 12.15. Vector Integer Merge Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VM_XM_IM<"int_riscv_vmerge", "PseudoVMERGE">; //===----------------------------------------------------------------------===// // 12.16. Vector Integer Move Instructions //===----------------------------------------------------------------------===// foreach vti = AllVectors in { def : Pat<(vti.Vector (int_riscv_vmv_v_v (vti.Vector vti.RegClass:$rs1), VLOpFrag)), (!cast("PseudoVMV_V_V_"#vti.LMul.MX) $rs1, GPR:$vl, vti.Log2SEW)>; // vmv.v.x/vmv.v.i are handled in RISCInstrVInstrInfoVVLPatterns.td } //===----------------------------------------------------------------------===// // 13.1. Vector Single-Width Saturating Add and Subtract //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI<"int_riscv_vsaddu", "PseudoVSADDU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX_VI<"int_riscv_vsadd", "PseudoVSADD", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vssubu", "PseudoVSSUBU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vssub", "PseudoVSSUB", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 13.2. Vector Single-Width Averaging Add and Subtract //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vaaddu", "PseudoVAADDU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vaadd", "PseudoVAADD", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vasubu", "PseudoVASUBU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vasub", "PseudoVASUB", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 13.3. Vector Single-Width Fractional Multiply with Rounding and Saturation //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vsmul", "PseudoVSMUL", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 13.4. Vector Single-Width Scaling Shift Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI<"int_riscv_vssrl", "PseudoVSSRL", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VV_VX_VI<"int_riscv_vssra", "PseudoVSSRA", AllIntegerVectors, uimm5>; //===----------------------------------------------------------------------===// // 13.5. Vector Narrowing Fixed-Point Clip Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_WV_WX_WI<"int_riscv_vnclipu", "PseudoVNCLIPU", AllWidenableIntVectors>; defm : VPatBinaryV_WV_WX_WI<"int_riscv_vnclip", "PseudoVNCLIP", AllWidenableIntVectors>; } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { //===----------------------------------------------------------------------===// // 14.2. Vector Single-Width Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vfadd", "PseudoVFADD", AllFloatVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vfsub", "PseudoVFSUB", AllFloatVectors>; defm : VPatBinaryV_VX<"int_riscv_vfrsub", "PseudoVFRSUB", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.3. Vector Widening Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryW_VV_VX<"int_riscv_vfwadd", "PseudoVFWADD", AllWidenableFloatVectors>; defm : VPatBinaryW_VV_VX<"int_riscv_vfwsub", "PseudoVFWSUB", AllWidenableFloatVectors>; defm : VPatBinaryW_WV_WX<"int_riscv_vfwadd_w", "PseudoVFWADD", AllWidenableFloatVectors>; defm : VPatBinaryW_WV_WX<"int_riscv_vfwsub_w", "PseudoVFWSUB", AllWidenableFloatVectors>; //===----------------------------------------------------------------------===// // 14.4. Vector Single-Width Floating-Point Multiply/Divide Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vfmul", "PseudoVFMUL", AllFloatVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vfdiv", "PseudoVFDIV", AllFloatVectors>; defm : VPatBinaryV_VX<"int_riscv_vfrdiv", "PseudoVFRDIV", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.5. Vector Widening Floating-Point Multiply //===----------------------------------------------------------------------===// defm : VPatBinaryW_VV_VX<"int_riscv_vfwmul", "PseudoVFWMUL", AllWidenableFloatVectors>; //===----------------------------------------------------------------------===// // 14.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfmacc", "PseudoVFMACC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfnmacc", "PseudoVFNMACC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfmsac", "PseudoVFMSAC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfnmsac", "PseudoVFNMSAC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfmadd", "PseudoVFMADD", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfnmadd", "PseudoVFNMADD", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfmsub", "PseudoVFMSUB", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA<"int_riscv_vfnmsub", "PseudoVFNMSUB", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.7. Vector Widening Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// defm : VPatTernaryW_VV_VX<"int_riscv_vfwmacc", "PseudoVFWMACC", AllWidenableFloatVectors>; defm : VPatTernaryW_VV_VX<"int_riscv_vfwnmacc", "PseudoVFWNMACC", AllWidenableFloatVectors>; defm : VPatTernaryW_VV_VX<"int_riscv_vfwmsac", "PseudoVFWMSAC", AllWidenableFloatVectors>; defm : VPatTernaryW_VV_VX<"int_riscv_vfwnmsac", "PseudoVFWNMSAC", AllWidenableFloatVectors>; //===----------------------------------------------------------------------===// // 14.8. Vector Floating-Point Square-Root Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V<"int_riscv_vfsqrt", "PseudoVFSQRT", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.9. Vector Floating-Point Reciprocal Square-Root Estimate Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V<"int_riscv_vfrsqrt7", "PseudoVFRSQRT7", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.10. Vector Floating-Point Reciprocal Estimate Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V<"int_riscv_vfrec7", "PseudoVFREC7", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.11. Vector Floating-Point Min/Max Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vfmin", "PseudoVFMIN", AllFloatVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vfmax", "PseudoVFMAX", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.12. Vector Floating-Point Sign-Injection Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vfsgnj", "PseudoVFSGNJ", AllFloatVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vfsgnjn", "PseudoVFSGNJN", AllFloatVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vfsgnjx", "PseudoVFSGNJX", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.13. Vector Floating-Point Compare Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryM_VV_VX<"int_riscv_vmfeq", "PseudoVMFEQ", AllFloatVectors>; defm : VPatBinaryM_VV_VX<"int_riscv_vmfle", "PseudoVMFLE", AllFloatVectors>; defm : VPatBinaryM_VV_VX<"int_riscv_vmflt", "PseudoVMFLT", AllFloatVectors>; defm : VPatBinaryM_VV_VX<"int_riscv_vmfne", "PseudoVMFNE", AllFloatVectors>; defm : VPatBinaryM_VX<"int_riscv_vmfgt", "PseudoVMFGT", AllFloatVectors>; defm : VPatBinaryM_VX<"int_riscv_vmfge", "PseudoVMFGE", AllFloatVectors>; defm : VPatBinarySwappedM_VV<"int_riscv_vmfgt", "PseudoVMFLT", AllFloatVectors>; defm : VPatBinarySwappedM_VV<"int_riscv_vmfge", "PseudoVMFLE", AllFloatVectors>; //===----------------------------------------------------------------------===// // 14.14. Vector Floating-Point Classify Instruction //===----------------------------------------------------------------------===// defm : VPatClassifyVI_VF<"int_riscv_vfclass", "PseudoVFCLASS">; //===----------------------------------------------------------------------===// // 14.15. Vector Floating-Point Merge Instruction //===----------------------------------------------------------------------===// // We can use vmerge.vvm to support vector-vector vfmerge. // NOTE: Clang previously used int_riscv_vfmerge for vector-vector, but now uses // int_riscv_vmerge. Support both for compatibility. defm : VPatBinaryV_VM<"int_riscv_vmerge", "PseudoVMERGE", /*CarryOut = */0, /*vtilist=*/AllFloatVectors>; defm : VPatBinaryV_VM<"int_riscv_vfmerge", "PseudoVMERGE", /*CarryOut = */0, /*vtilist=*/AllFloatVectors>; defm : VPatBinaryV_XM<"int_riscv_vfmerge", "PseudoVFMERGE", /*CarryOut = */0, /*vtilist=*/AllFloatVectors>; foreach fvti = AllFloatVectors in { defvar instr = !cast("PseudoVMERGE_VIM_"#fvti.LMul.MX); def : Pat<(fvti.Vector (int_riscv_vfmerge (fvti.Vector fvti.RegClass:$rs2), (fvti.Scalar (fpimm0)), (fvti.Mask V0), VLOpFrag)), (instr fvti.RegClass:$rs2, 0, (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>; } //===----------------------------------------------------------------------===// // 14.17. Single-Width Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm : VPatConversionVI_VF<"int_riscv_vfcvt_xu_f_v", "PseudoVFCVT_XU_F">; defm : VPatConversionVI_VF<"int_riscv_vfcvt_rtz_xu_f_v", "PseudoVFCVT_RTZ_XU_F">; defm : VPatConversionVI_VF<"int_riscv_vfcvt_x_f_v", "PseudoVFCVT_X_F">; defm : VPatConversionVI_VF<"int_riscv_vfcvt_rtz_x_f_v", "PseudoVFCVT_RTZ_X_F">; defm : VPatConversionVF_VI<"int_riscv_vfcvt_f_x_v", "PseudoVFCVT_F_X">; defm : VPatConversionVF_VI<"int_riscv_vfcvt_f_xu_v", "PseudoVFCVT_F_XU">; //===----------------------------------------------------------------------===// // 14.18. Widening Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm : VPatConversionWI_VF<"int_riscv_vfwcvt_xu_f_v", "PseudoVFWCVT_XU_F">; defm : VPatConversionWI_VF<"int_riscv_vfwcvt_x_f_v", "PseudoVFWCVT_X_F">; defm : VPatConversionWI_VF<"int_riscv_vfwcvt_rtz_xu_f_v", "PseudoVFWCVT_RTZ_XU_F">; defm : VPatConversionWI_VF<"int_riscv_vfwcvt_rtz_x_f_v", "PseudoVFWCVT_RTZ_X_F">; defm : VPatConversionWF_VI<"int_riscv_vfwcvt_f_xu_v", "PseudoVFWCVT_F_XU">; defm : VPatConversionWF_VI<"int_riscv_vfwcvt_f_x_v", "PseudoVFWCVT_F_X">; defm : VPatConversionWF_VF<"int_riscv_vfwcvt_f_f_v", "PseudoVFWCVT_F_F">; //===----------------------------------------------------------------------===// // 14.19. Narrowing Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm : VPatConversionVI_WF<"int_riscv_vfncvt_xu_f_w", "PseudoVFNCVT_XU_F">; defm : VPatConversionVI_WF<"int_riscv_vfncvt_x_f_w", "PseudoVFNCVT_X_F">; defm : VPatConversionVI_WF<"int_riscv_vfncvt_rtz_xu_f_w", "PseudoVFNCVT_RTZ_XU_F">; defm : VPatConversionVI_WF<"int_riscv_vfncvt_rtz_x_f_w", "PseudoVFNCVT_RTZ_X_F">; defm : VPatConversionVF_WI <"int_riscv_vfncvt_f_xu_w", "PseudoVFNCVT_F_XU">; defm : VPatConversionVF_WI <"int_riscv_vfncvt_f_x_w", "PseudoVFNCVT_F_X">; defm : VPatConversionVF_WF<"int_riscv_vfncvt_f_f_w", "PseudoVFNCVT_F_F">; defm : VPatConversionVF_WF<"int_riscv_vfncvt_rod_f_f_w", "PseudoVFNCVT_ROD_F_F">; } // Predicates = [HasVInstructionsAnyF] let Predicates = [HasVInstructions] in { //===----------------------------------------------------------------------===// // 15.1. Vector Single-Width Integer Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionV_VS<"int_riscv_vredsum", "PseudoVREDSUM">; defm : VPatReductionV_VS<"int_riscv_vredand", "PseudoVREDAND">; defm : VPatReductionV_VS<"int_riscv_vredor", "PseudoVREDOR">; defm : VPatReductionV_VS<"int_riscv_vredxor", "PseudoVREDXOR">; defm : VPatReductionV_VS<"int_riscv_vredminu", "PseudoVREDMINU">; defm : VPatReductionV_VS<"int_riscv_vredmin", "PseudoVREDMIN">; defm : VPatReductionV_VS<"int_riscv_vredmaxu", "PseudoVREDMAXU">; defm : VPatReductionV_VS<"int_riscv_vredmax", "PseudoVREDMAX">; //===----------------------------------------------------------------------===// // 15.2. Vector Widening Integer Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionW_VS<"int_riscv_vwredsumu", "PseudoVWREDSUMU">; defm : VPatReductionW_VS<"int_riscv_vwredsum", "PseudoVWREDSUM">; } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { //===----------------------------------------------------------------------===// // 15.3. Vector Single-Width Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionV_VS<"int_riscv_vfredosum", "PseudoVFREDOSUM", /*IsFloat=*/1>; defm : VPatReductionV_VS<"int_riscv_vfredusum", "PseudoVFREDUSUM", /*IsFloat=*/1>; defm : VPatReductionV_VS<"int_riscv_vfredmin", "PseudoVFREDMIN", /*IsFloat=*/1>; defm : VPatReductionV_VS<"int_riscv_vfredmax", "PseudoVFREDMAX", /*IsFloat=*/1>; //===----------------------------------------------------------------------===// // 15.4. Vector Widening Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionW_VS<"int_riscv_vfwredusum", "PseudoVFWREDUSUM", /*IsFloat=*/1>; defm : VPatReductionW_VS<"int_riscv_vfwredosum", "PseudoVFWREDOSUM", /*IsFloat=*/1>; } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 16. Vector Mask Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { //===----------------------------------------------------------------------===// // 16.1 Vector Mask-Register Logical Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryM_MM<"int_riscv_vmand", "PseudoVMAND">; defm : VPatBinaryM_MM<"int_riscv_vmnand", "PseudoVMNAND">; defm : VPatBinaryM_MM<"int_riscv_vmandn", "PseudoVMANDN">; defm : VPatBinaryM_MM<"int_riscv_vmxor", "PseudoVMXOR">; defm : VPatBinaryM_MM<"int_riscv_vmor", "PseudoVMOR">; defm : VPatBinaryM_MM<"int_riscv_vmnor", "PseudoVMNOR">; defm : VPatBinaryM_MM<"int_riscv_vmorn", "PseudoVMORN">; defm : VPatBinaryM_MM<"int_riscv_vmxnor", "PseudoVMXNOR">; // pseudo instructions defm : VPatNullaryM<"int_riscv_vmclr", "PseudoVMCLR">; defm : VPatNullaryM<"int_riscv_vmset", "PseudoVMSET">; //===----------------------------------------------------------------------===// // 16.2. Vector count population in mask vcpop.m //===----------------------------------------------------------------------===// defm : VPatUnaryS_M<"int_riscv_vcpop", "PseudoVCPOP">; //===----------------------------------------------------------------------===// // 16.3. vfirst find-first-set mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryS_M<"int_riscv_vfirst", "PseudoVFIRST">; //===----------------------------------------------------------------------===// // 16.4. vmsbf.m set-before-first mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryM_M<"int_riscv_vmsbf", "PseudoVMSBF">; //===----------------------------------------------------------------------===// // 16.5. vmsif.m set-including-first mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryM_M<"int_riscv_vmsif", "PseudoVMSIF">; //===----------------------------------------------------------------------===// // 16.6. vmsof.m set-only-first mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryM_M<"int_riscv_vmsof", "PseudoVMSOF">; //===----------------------------------------------------------------------===// // 16.8. Vector Iota Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_M<"int_riscv_viota", "PseudoVIOTA">; //===----------------------------------------------------------------------===// // 16.9. Vector Element Index Instruction //===----------------------------------------------------------------------===// defm : VPatNullaryV<"int_riscv_vid", "PseudoVID">; } // Predicates = [HasVInstructions] //===----------------------------------------------------------------------===// // 17. Vector Permutation Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 17.1. Integer Scalar Move Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { foreach vti = AllIntegerVectors in { def : Pat<(riscv_vmv_x_s (vti.Vector vti.RegClass:$rs2)), (!cast("PseudoVMV_X_S_" # vti.LMul.MX) $rs2, vti.Log2SEW)>; // vmv.s.x is handled with a custom node in RISCVInstrInfoVVLPatterns.td } } // Predicates = [HasVInstructions] //===----------------------------------------------------------------------===// // 17.2. Floating-Point Scalar Move Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructionsAnyF] in { foreach fvti = AllFloatVectors in { defvar instr = !cast("PseudoVFMV_"#fvti.ScalarSuffix#"_S_" # fvti.LMul.MX); def : Pat<(fvti.Scalar (int_riscv_vfmv_f_s (fvti.Vector fvti.RegClass:$rs2))), (instr $rs2, fvti.Log2SEW)>; def : Pat<(fvti.Vector (int_riscv_vfmv_s_f (fvti.Vector fvti.RegClass:$rs1), (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)), (!cast("PseudoVFMV_S_"#fvti.ScalarSuffix#"_" # fvti.LMul.MX) (fvti.Vector $rs1), (fvti.Scalar fvti.ScalarRegClass:$rs2), GPR:$vl, fvti.Log2SEW)>; } } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 17.3. Vector Slide Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { defm : VPatTernaryV_VX_VI<"int_riscv_vslideup", "PseudoVSLIDEUP", AllIntegerVectors, uimm5>; defm : VPatTernaryV_VX_VI<"int_riscv_vslidedown", "PseudoVSLIDEDOWN", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VX<"int_riscv_vslide1up", "PseudoVSLIDE1UP", AllIntegerVectors>; defm : VPatBinaryV_VX<"int_riscv_vslide1down", "PseudoVSLIDE1DOWN", AllIntegerVectors>; } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { defm : VPatTernaryV_VX_VI<"int_riscv_vslideup", "PseudoVSLIDEUP", AllFloatVectors, uimm5>; defm : VPatTernaryV_VX_VI<"int_riscv_vslidedown", "PseudoVSLIDEDOWN", AllFloatVectors, uimm5>; defm : VPatBinaryV_VX<"int_riscv_vfslide1up", "PseudoVFSLIDE1UP", AllFloatVectors>; defm : VPatBinaryV_VX<"int_riscv_vfslide1down", "PseudoVFSLIDE1DOWN", AllFloatVectors>; } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 17.4. Vector Register Gather Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { defm : VPatBinaryV_VV_VX_VI_INT<"int_riscv_vrgather", "PseudoVRGATHER", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VV_INT_EEW<"int_riscv_vrgatherei16_vv", "PseudoVRGATHEREI16", /* eew */ 16, AllIntegerVectors>; } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { defm : VPatBinaryV_VV_VX_VI_INT<"int_riscv_vrgather", "PseudoVRGATHER", AllFloatVectors, uimm5>; defm : VPatBinaryV_VV_INT_EEW<"int_riscv_vrgatherei16_vv", "PseudoVRGATHEREI16", /* eew */ 16, AllFloatVectors>; } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 17.5. Vector Compress Instruction //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllIntegerVectors>; } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllFloatVectors>; } // Predicates = [HasVInstructionsAnyF] // Include the non-intrinsic ISel patterns include "RISCVInstrInfoVSDPatterns.td" include "RISCVInstrInfoVVLPatterns.td"