//===-- 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 1.0. /// /// This file is included from RISCVInstrInfoV.td /// /// Overview of our vector instruction pseudos. Many of the instructions /// have behavior which depends on the value of VTYPE. Several core aspects of /// the compiler - e.g. register allocation - depend on fields in this /// configuration register. The details of which fields matter differ by the /// specific instruction, but the common dimensions are: /// /// LMUL/EMUL - Most instructions can write to differently sized register groups /// depending on LMUL. /// /// Masked vs Unmasked - Many instructions which allow a mask disallow register /// overlap. As a result, masked vs unmasked require different register /// allocation constraints. /// /// Policy - For each of mask and tail policy, there are three options: /// * "Undisturbed" - As defined in the specification, required to preserve the /// exact bit pattern of inactive lanes. /// * "Agnostic" - As defined in the specification, required to either preserve /// the exact bit pattern of inactive lanes, or produce the bit pattern -1 for /// those lanes. Note that each lane can make this choice independently. /// Instructions which produce masks (and only those instructions) also have the /// option of producing a result as-if VL had been VLMAX. /// * "Undefined" - The bit pattern of the inactive lanes is unspecified, and /// can be changed without impacting the semantics of the program. Note that /// this concept does not exist in the specification, and requires source /// knowledge to be preserved. /// /// SEW - Some instructions have semantics which depend on SEW. This is /// relatively rare, and mostly impacts scheduling and cost estimation. /// /// We have two techniques we use to represent the impact of these fields: /// * For fields which don't impact register classes, we largely use /// dummy operands on the pseudo instructions which convey information /// about the value of VTYPE. /// * For fields which do impact register classes (and a few bits of /// legacy - see policy discussion below), we define a family of pseudo /// instructions for each actual instruction. Said differently, we encode /// each of the preceding fields which are relevant for a given instruction /// in the opcode space. /// /// Currently, the policy is represented via the following instrinsic families: /// * _MASK - Can represent all three policy states for both tail and mask. If /// passthrough is IMPLICIT_DEF, then represents "undefined". Otherwise, /// policy operand and tablegen flags drive the interpretation. (If policy /// operand is not present - there are a couple, thought we're rapidly /// removing them - a non-undefined policy defaults to "tail agnostic", and /// "mask undisturbed". Since this is the only variant with a mask, all /// other variants are "mask undefined". /// * Unsuffixed w/ both passthrough and policy operand. Can represent all /// three policy states. If passthrough is IMPLICIT_DEF, then represents /// "undefined". Otherwise, policy operand and tablegen flags drive the /// interpretation. /// * Unsuffixed w/o passthrough or policy operand -- Does not have a /// passthrough operand, and thus represents the "undefined" state. Note /// that terminology in code frequently refers to these as "TA" which is /// confusing. We're in the process of migrating away from this /// representation. /// * _TU w/o policy operand -- Has a passthrough operand, and always /// represents the tail undisturbed state. /// * _TU w/policy operand - Can represent all three policy states. If /// passthrough is IMPLICIT_DEF, then represents "undefined". Otherwise, /// policy operand and tablegen flags drive the interpretation. /// //===----------------------------------------------------------------------===// 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_AGNOSTIC = 1; defvar TU_MU = 0; defvar TA_MA = 3; //===----------------------------------------------------------------------===// // Utilities. //===----------------------------------------------------------------------===// class PseudoToVInst { defvar AffixSubsts = [["Pseudo", ""], ["_E64", ""], ["_E32", ""], ["_E16", ""], ["_E8", ""], ["_F64", "_F"], ["_F32", "_F"], ["_F16", "_F"], ["_VF64", "_VF"], ["_VF32", "_VF"], ["_VF16", "_VF"], ["_WF64", "_WF"], ["_WF32", "_WF"], ["_WF16", "_WF"], ["_TU", ""], ["_TIED", ""], ["_MASK", ""], ["_B64", ""], ["_B32", ""], ["_B16", ""], ["_B8", ""], ["_B4", ""], ["_B2", ""], ["_B1", ""], ["_MF8", ""], ["_MF4", ""], ["_MF2", ""], ["_M1", ""], ["_M2", ""], ["_M4", ""], ["_M8", ""], ["_SE", ""] ]; string VInst = !foldl(PseudoInst, AffixSubsts, Acc, AffixSubst, !subst(AffixSubst[0], AffixSubst[1], Acc)); } // 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]; // Used for widening reductions. It can contain M8 because wider operands are // scalar operands. defvar MxListWRed = MxList; // For floating point which don't need MF8. defvar MxListFW = [V_MF4, V_MF2, V_M1, V_M2, V_M4]; // For widening floating-point Reduction as it doesn't contain MF8. It can // contain M8 because wider operands are scalar operands. defvar MxListFWRed = [V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8]; // 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 { RegisterClass fprclass = !cast("FPR" # sew); string FX = "F" # sew; int SEW = sew; list MxList = MxSet.m; list MxListFW = !if(!eq(sew, 64), [], !listremove(MxList, [V_M8])); } def SCALAR_F16 : FPR_Info<16>; def SCALAR_F32 : FPR_Info<32>; def SCALAR_F64 : FPR_Info<64>; 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 octuple_to_str { string ret = !cond(!eq(octuple, 1): "MF8", !eq(octuple, 2): "MF4", !eq(octuple, 4): "MF2", !eq(octuple, 8): "M1", !eq(octuple, 16): "M2", !eq(octuple, 32): "M4", !eq(octuple, 64): "M8"); } 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 = !logtwo(Sew); 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 // RISCVInstrInfo.h. class RISCVVPseudo { Pseudo Pseudo = !cast(NAME); // Used as a key. Instruction BaseInstr = !cast(PseudoToVInst.VInst); // SEW = 0 is used to denote that the Pseudo is not SEW specific (or unknown). bits<8> SEW = 0; } // 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 RISCVVInversePseudosTable : GenericTable { let FilterClass = "RISCVVPseudo"; let CppTypeName = "PseudoInfo"; let Fields = [ "Pseudo", "BaseInstr", "VLMul", "SEW"]; let PrimaryKey = [ "BaseInstr", "VLMul", "SEW"]; let PrimaryKeyName = "getBaseInfo"; let PrimaryKeyEarlyOut = true; } def RISCVVIntrinsicsTable : GenericTable { let FilterClass = "RISCVVIntrinsic"; let CppTypeName = "RISCVVIntrinsicInfo"; let Fields = ["IntrinsicID", "ScalarOperand", "VLOperand"]; let PrimaryKey = ["IntrinsicID"]; let PrimaryKeyName = "getRISCVVIntrinsicInfo"; } // Describes the relation of a masked pseudo to the unmasked variants. // Note that all masked variants (in this table) have exactly one // unmasked variant. For all but compares, both the masked and // unmasked variant have a passthru and policy operand. For compares, // neither has a policy op, and only the masked version has a passthru. class RISCVMaskedPseudo MaskIdx> { Pseudo MaskedPseudo = !cast(NAME); Pseudo UnmaskedPseudo = !cast(!subst("_MASK", "", NAME)); bits<4> MaskOpIdx = MaskIdx; } def RISCVMaskedPseudosTable : GenericTable { let FilterClass = "RISCVMaskedPseudo"; let CppTypeName = "RISCVMaskedPseudoInfo"; let Fields = ["MaskedPseudo", "UnmaskedPseudo", "MaskOpIdx"]; let PrimaryKey = ["MaskedPseudo"]; let PrimaryKeyName = "getMaskedPseudoInfo"; } class RISCVVLE S, bits<3> L> { 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 lookupMaskedIntrinsicByUnmasked : SearchIndex { let Table = RISCVMaskedPseudosTable; let Key = ["UnmaskedPseudo"]; } def RISCVVLETable : GenericTable { let FilterClass = "RISCVVLE"; let CppTypeName = "VLEPseudo"; let Fields = ["Masked", "Strided", "FF", "Log2SEW", "LMUL", "Pseudo"]; let PrimaryKey = ["Masked", "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> 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", "Ordered", "Log2SEW", "LMUL", "IndexLMUL", "Pseudo"]; let PrimaryKey = ["Masked", "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. //===----------------------------------------------------------------------===// // 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); } class VPseudo : Pseudo, RISCVVPseudo { let BaseInstr = instr; let VLMul = m.value; let SEW = sew; } class GetVTypePredicates { list Predicates = !cond(!eq(vti.Scalar, f16) : [HasVInstructionsF16], !eq(vti.Scalar, f32) : [HasVInstructionsAnyF], !eq(vti.Scalar, f64) : [HasVInstructionsF64], !eq(vti.SEW, 64) : [HasVInstructionsI64], true : [HasVInstructions]); } class VPseudoUSLoadNoMask : Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPRMem:$rs1, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = "$rd = $dest"; } class VPseudoUSLoadMask : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoUSLoadFFNoMask : Pseudo<(outs RetClass:$rd, GPR:$vl), (ins RetClass:$dest, GPRMem:$rs1, AVL:$avl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = "$rd = $dest"; } class VPseudoUSLoadFFMask : Pseudo<(outs GetVRegNoV0.R:$rd, GPR:$vl), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, VMaskOp:$vm, AVL:$avl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoSLoadNoMask: Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPRMem:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = "$rd = $dest"; } class VPseudoSLoadMask: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, GPR:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLE { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoILoadNoMask LMUL, bit Ordered, bit EarlyClobber>: Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPRMem:$rs1, IdxClass:$rs2, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLX { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = !if(!eq(EarlyClobber, 1), "@earlyclobber $rd, $rd = $dest", "$rd = $dest"); } class VPseudoILoadMask LMUL, bit Ordered, bit EarlyClobber>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, IdxClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLX { 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 HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoUSStoreNoMask: Pseudo<(outs), (ins StClass:$rd, GPRMem:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoUSStoreMask: Pseudo<(outs), (ins StClass:$rd, GPRMem:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoSStoreNoMask: Pseudo<(outs), (ins StClass:$rd, GPRMem:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoSStoreMask: Pseudo<(outs), (ins StClass:$rd, GPRMem:$rs1, GPR:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSE { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoNullaryNoMask: Pseudo<(outs RegClass:$rd), (ins RegClass:$merge, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; } class VPseudoNullaryMask: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints ="$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let UsesMaskPolicy = 1; let HasVecPolicyOp = 1; } // 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); } class VPseudoUnaryNoMask : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, OpClass:$rs2, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; } class VPseudoUnaryNoMaskRoundingMode : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, OpClass:$rs2, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let HasRoundModeOp = 1; let UsesVXRM = 0; } class VPseudoUnaryMask : 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoUnaryMaskRoundingMode : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, OpClass:$rs2, VMaskOp:$vm, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let HasRoundModeOp = 1; let UsesVXRM = 0; } class VPseudoUnaryMask_NoExcept : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, OpClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []> { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let usesCustomInserter = 1; } class VPseudoUnaryNoMask_FRM : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, OpClass:$rs2, ixlenimm:$frm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []> { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let usesCustomInserter = 1; } class VPseudoUnaryMask_FRM : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, OpClass:$rs2, VMaskOp:$vm, ixlenimm:$frm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []> { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let usesCustomInserter = 1; } class VPseudoUnaryNoMaskGPROut : Pseudo<(outs GPR:$rd), (ins VR:$rs2, AVL:$vl, ixlenimm:$sew), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoUnaryMaskGPROut: 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; } // 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; } 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; } class VPseudoBinaryNoMaskTU : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, Op1Class:$rs2, Op2Class:$rs1, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; } class VPseudoBinaryNoMaskRoundingMode : Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, Op1Class:$rs2, Op2Class:$rs1, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let HasRoundModeOp = 1; let UsesVXRM = UsesVXRM_; } class VPseudoBinaryMaskPolicyRoundingMode : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, Op1Class:$rs2, Op2Class:$rs1, VMaskOp:$vm, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let HasRoundModeOp = 1; let UsesVXRM = UsesVXRM_; } // 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, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $rs2"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let isConvertibleToThreeAddress = 1; let IsTiedPseudo = 1; } class VPseudoTiedBinaryNoMaskRoundingMode : Pseudo<(outs RetClass:$rd), (ins RetClass:$rs2, Op2Class:$rs1, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $rs2"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let isConvertibleToThreeAddress = 1; let IsTiedPseudo = 1; let HasRoundModeOp = 1; let UsesVXRM = 0; } class VPseudoIStoreNoMask LMUL, bit Ordered>: Pseudo<(outs), (ins StClass:$rd, GPRMem:$rs1, IdxClass:$rs2, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSX { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoIStoreMask LMUL, bit Ordered>: Pseudo<(outs), (ins StClass:$rd, GPRMem:$rs1, IdxClass:$rs2, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSX { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoBinaryMaskPolicy : 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoTernaryMaskPolicy : 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; } class VPseudoTernaryMaskPolicyRoundingMode : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, Op1Class:$rs2, Op2Class:$rs1, VMaskOp:$vm, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let HasRoundModeOp = 1; let UsesVXRM = 0; } // Like VPseudoBinaryNoMask, but output can be V0. class VPseudoBinaryMOutNoMask : 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; } // 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let UsesMaskPolicy = 1; } // 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let IsTiedPseudo = 1; } class VPseudoTiedBinaryMaskRoundingMode : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, Op2Class:$rs1, VMaskOp:$vm, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; let IsTiedPseudo = 1; let HasRoundModeOp = 1; let UsesVXRM = 0; } 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 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 = !interleave([Constraint, "$rd = $merge"], ","); let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 0; 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 = !interleave([Constraint, "$rd = $rs3"], ","); let HasVLOp = 1; let HasSEWOp = 1; } 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 = !interleave([Constraint, "$rd = $rs3"], ","); let HasVecPolicyOp = 1; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoTernaryNoMaskWithPolicyRoundingMode : Pseudo<(outs RetClass:$rd), (ins RetClass:$rs3, Op1Class:$rs1, Op2Class:$rs2, ixlenimm:$rm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []>, RISCVVPseudo { let mayLoad = 0; let mayStore = 0; let hasSideEffects = 0; let Constraints = !interleave([Constraint, "$rd = $rs3"], ","); let HasVecPolicyOp = 1; let HasVLOp = 1; let HasSEWOp = 1; let HasRoundModeOp = 1; let UsesVXRM = 0; } class VPseudoUSSegLoadNoMask NF>: Pseudo<(outs RetClass:$rd), (ins RetClass:$dest, GPRMem:$rs1, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = "$rd = $dest"; } class VPseudoUSSegLoadMask NF>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoUSSegLoadFFNoMask NF>: Pseudo<(outs RetClass:$rd, GPR:$vl), (ins RetClass:$dest, GPRMem:$rs1, AVL:$avl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = "$rd = $dest"; } class VPseudoUSSegLoadFFMask NF>: Pseudo<(outs GetVRegNoV0.R:$rd, GPR:$vl), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, VMaskOp:$vm, AVL:$avl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoSSegLoadNoMask NF>: Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, GPRMem:$rs1, GPR:$offset, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let Constraints = "$rd = $merge"; } class VPseudoSSegLoadMask NF>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, GPR:$offset, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLSEG { let mayLoad = 1; let mayStore = 0; let hasSideEffects = 0; let Constraints = "$rd = $merge"; let HasVLOp = 1; let HasSEWOp = 1; let HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoISegLoadNoMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs RetClass:$rd), (ins RetClass:$merge, GPRMem:$rs1, IdxClass:$offset, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLXSEG { 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 HasVecPolicyOp = 1; } class VPseudoISegLoadMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, GPRMem:$rs1, IdxClass:$offset, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew, ixlenimm:$policy),[]>, RISCVVPseudo, RISCVVLXSEG { 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 HasVecPolicyOp = 1; let UsesMaskPolicy = 1; } class VPseudoUSSegStoreNoMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPRMem:$rs1, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoUSSegStoreMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPRMem:$rs1, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoSSegStoreNoMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPRMem:$rs1, GPR: $offset, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoSSegStoreMask NF>: Pseudo<(outs), (ins ValClass:$rd, GPRMem:$rs1, GPR: $offset, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSSEG { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoISegStoreNoMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs), (ins ValClass:$rd, GPRMem:$rs1, IdxClass: $index, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSXSEG { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } class VPseudoISegStoreMask LMUL, bits<4> NF, bit Ordered>: Pseudo<(outs), (ins ValClass:$rd, GPRMem:$rs1, IdxClass: $index, VMaskOp:$vm, AVL:$vl, ixlenimm:$sew),[]>, RISCVVPseudo, RISCVVSXSEG { let mayLoad = 0; let mayStore = 1; let hasSideEffects = 0; let HasVLOp = 1; let HasSEWOp = 1; } multiclass VPseudoUSLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoUSLoadNoMask, VLESched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSLoadMask, RISCVMaskedPseudo, VLESched; } } } } multiclass VPseudoFFLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value, SEW=eew in { def "E" # eew # "FF_V_" # LInfo: VPseudoUSLoadFFNoMask, VLFSched; def "E" # eew # "FF_V_" # LInfo # "_MASK": VPseudoUSLoadFFMask, RISCVMaskedPseudo, VLFSched; } } } } multiclass VPseudoLoadMask { foreach mti = AllMasks in { defvar mx = mti.LMul.MX; defvar WriteVLDM_MX = !cast("WriteVLDM_" # mx); let VLMul = mti.LMul.value in { def "_V_" # mti.BX : VPseudoUSLoadNoMask, Sched<[WriteVLDM_MX, ReadVLDX]>; } } } multiclass VPseudoSLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoSLoadNoMask, VLSSched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSLoadMask, RISCVMaskedPseudo, VLSSched; } } } } multiclass VPseudoILoad { foreach idxEEW = EEWList in { foreach dataEEW = EEWList in { foreach dataEMUL = MxSet.m in { defvar dataEMULOctuple = dataEMUL.octuple; // Calculate emul = eew * lmul / sew defvar idxEMULOctuple = !srl(!mul(idxEEW, dataEMULOctuple), !logtwo(dataEEW)); if !and(!ge(idxEMULOctuple, 1), !le(idxEMULOctuple, 64)) then { defvar DataLInfo = dataEMUL.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idxEMUL = !cast("V_" # IdxLInfo); defvar Vreg = dataEMUL.vrclass; defvar IdxVreg = idxEMUL.vrclass; defvar HasConstraint = !ne(dataEEW, idxEEW); defvar Order = !if(Ordered, "O", "U"); let VLMul = dataEMUL.value in { def "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo : VPseudoILoadNoMask, VLXSched; def "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo # "_MASK" : VPseudoILoadMask, RISCVMaskedPseudo, VLXSched; } } } } } } multiclass VPseudoUSStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoUSStoreNoMask, VSESched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSStoreMask, VSESched; } } } } multiclass VPseudoStoreMask { foreach mti = AllMasks in { defvar mx = mti.LMul.MX; defvar WriteVSTM_MX = !cast("WriteVSTM_" # mx); let VLMul = mti.LMul.value in { def "_V_" # mti.BX : VPseudoUSStoreNoMask, Sched<[WriteVSTM_MX, ReadVSTX]>; } } } multiclass VPseudoSStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoSStoreNoMask, VSSSched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSStoreMask, VSSSched; } } } } multiclass VPseudoIStore { foreach idxEEW = EEWList in { foreach dataEEW = EEWList in { foreach dataEMUL = MxSet.m in { defvar dataEMULOctuple = dataEMUL.octuple; // Calculate emul = eew * lmul / sew defvar idxEMULOctuple = !srl(!mul(idxEEW, dataEMULOctuple), !logtwo(dataEEW)); if !and(!ge(idxEMULOctuple, 1), !le(idxEMULOctuple, 64)) then { defvar DataLInfo = dataEMUL.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idxEMUL = !cast("V_" # IdxLInfo); defvar Vreg = dataEMUL.vrclass; defvar IdxVreg = idxEMUL.vrclass; defvar Order = !if(Ordered, "O", "U"); let VLMul = dataEMUL.value in { def "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo : VPseudoIStoreNoMask, VSXSched; def "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo # "_MASK" : VPseudoIStoreMask, VSXSched; } } } } } } multiclass VPseudoVPOP_M { foreach mti = AllMasks in { defvar mx = mti.LMul.MX; defvar WriteVMPopV_MX = !cast("WriteVMPopV_" # mx); defvar ReadVMPopV_MX = !cast("ReadVMPopV_" # mx); let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoUnaryNoMaskGPROut, Sched<[WriteVMPopV_MX, ReadVMPopV_MX, ReadVMPopV_MX]>; def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMaskGPROut, Sched<[WriteVMPopV_MX, ReadVMPopV_MX, ReadVMPopV_MX]>; } } } multiclass VPseudoV1ST_M { foreach mti = AllMasks in { defvar mx = mti.LMul.MX; defvar WriteVMFFSV_MX = !cast("WriteVMFFSV_" # mx); defvar ReadVMFFSV_MX = !cast("ReadVMFFSV_" # mx); let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoUnaryNoMaskGPROut, Sched<[WriteVMFFSV_MX, ReadVMFFSV_MX, ReadVMFFSV_MX]>; def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMaskGPROut, Sched<[WriteVMFFSV_MX, ReadVMFFSV_MX, ReadVMFFSV_MX]>; } } } multiclass VPseudoVSFS_M { defvar constraint = "@earlyclobber $rd"; foreach mti = AllMasks in { defvar mx = mti.LMul.MX; defvar WriteVMSFSV_MX = !cast("WriteVMSFSV_" # mx); defvar ReadVMSFSV_MX = !cast("ReadVMSFSV_" # mx); let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoUnaryNoMask, Sched<[WriteVMSFSV_MX, ReadVMSFSV_MX, ReadVMask]>; def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMask, Sched<[WriteVMSFSV_MX, ReadVMSFSV_MX, ReadVMask]>; } } } multiclass VPseudoVID_V { foreach m = MxList in { defvar mx = m.MX; defvar WriteVMIdxV_MX = !cast("WriteVMIdxV_" # mx); defvar ReadVMIdxV_MX = !cast("ReadVMIdxV_" # mx); let VLMul = m.value in { def "_V_" # m.MX : VPseudoNullaryNoMask, Sched<[WriteVMIdxV_MX, ReadVMask]>; def "_V_" # m.MX # "_MASK" : VPseudoNullaryMask, RISCVMaskedPseudo, Sched<[WriteVMIdxV_MX, ReadVMask]>; } } } multiclass VPseudoNullaryPseudoM { foreach mti = AllMasks in { defvar mx = mti.LMul.MX; defvar WriteVMALUV_MX = !cast("WriteVMALUV_" # mx); defvar ReadVMALUV_MX = !cast("ReadVMALUV_" # mx); let VLMul = mti.LMul.value in { def "_M_" # mti.BX : VPseudoNullaryPseudoM, Sched<[WriteVMALUV_MX, ReadVMALUV_MX, ReadVMALUV_MX]>; } } } multiclass VPseudoVIOT_M { defvar constraint = "@earlyclobber $rd"; foreach m = MxList in { defvar mx = m.MX; defvar WriteVMIotV_MX = !cast("WriteVMIotV_" # mx); defvar ReadVMIotV_MX = !cast("ReadVMIotV_" # mx); let VLMul = m.value in { def "_" # m.MX : VPseudoUnaryNoMask, Sched<[WriteVMIotV_MX, ReadVMIotV_MX, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo, Sched<[WriteVMIotV_MX, ReadVMIotV_MX, ReadVMask]>; } } } multiclass VPseudoVCPR_V { foreach m = MxList in { defvar mx = m.MX; defvar sews = SchedSEWSet.val; let VLMul = m.value in foreach e = sews in { defvar suffix = "_" # m.MX # "_E" # e; defvar WriteVCompressV_MX_E = !cast("WriteVCompressV" # suffix); defvar ReadVCompressV_MX_E = !cast("ReadVCompressV" # suffix); let SEW = e in def _VM # suffix : VPseudoUnaryAnyMask, Sched<[WriteVCompressV_MX_E, ReadVCompressV_MX_E, ReadVCompressV_MX_E]>; } } } multiclass VPseudoBinary { let VLMul = MInfo.value, SEW=sew in { defvar suffix = !if(sew, "_" # MInfo.MX # "_E" # sew, "_" # MInfo.MX); def suffix : VPseudoBinaryNoMaskTU; def suffix # "_MASK" : VPseudoBinaryMaskPolicy, RISCVMaskedPseudo; } } multiclass VPseudoBinaryRoundingMode { let VLMul = MInfo.value, SEW=sew in { defvar suffix = !if(sew, "_" # MInfo.MX # "_E" # sew, "_" # MInfo.MX); def suffix : VPseudoBinaryNoMaskRoundingMode; def suffix # "_MASK" : VPseudoBinaryMaskPolicyRoundingMode, RISCVMaskedPseudo; } } multiclass VPseudoBinaryM { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoBinaryMOutNoMask; let ForceTailAgnostic = true in def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMOutMask, RISCVMaskedPseudo; } } multiclass VPseudoBinaryEmul { let VLMul = lmul.value, SEW=sew in { defvar suffix = !if(sew, "_" # lmul.MX # "_E" # sew, "_" # lmul.MX); def suffix # "_" # emul.MX : VPseudoBinaryNoMaskTU; def suffix # "_" # emul.MX # "_MASK" : VPseudoBinaryMaskPolicy, RISCVMaskedPseudo; } } multiclass VPseudoTiedBinary { let VLMul = MInfo.value in { def "_" # MInfo.MX # "_TIED": VPseudoTiedBinaryNoMask; def "_" # MInfo.MX # "_MASK_TIED" : VPseudoTiedBinaryMask; } } multiclass VPseudoTiedBinaryRoundingMode { let VLMul = MInfo.value in { def "_" # MInfo.MX # "_TIED": VPseudoTiedBinaryNoMaskRoundingMode; def "_" # MInfo.MX # "_MASK_TIED" : VPseudoTiedBinaryMaskRoundingMode; } } multiclass VPseudoBinaryV_VV { defm _VV : VPseudoBinary; } multiclass VPseudoBinaryV_VV_RM { defm _VV : VPseudoBinaryRoundingMode; } // Similar to VPseudoBinaryV_VV, but uses MxListF. multiclass VPseudoBinaryFV_VV { defm _VV : VPseudoBinary; } multiclass VPseudoBinaryFV_VV_RM { defm _VV : VPseudoBinaryRoundingMode; } multiclass VPseudoVGTR_VV_EEW { foreach m = MxList in { defvar mx = m.MX; foreach sew = EEWList in { defvar dataEMULOctuple = m.octuple; // emul = lmul * eew / sew defvar idxEMULOctuple = !srl(!mul(dataEMULOctuple, eew), !logtwo(sew)); if !and(!ge(idxEMULOctuple, 1), !le(idxEMULOctuple, 64)) then { defvar emulMX = octuple_to_str.ret; defvar emul = !cast("V_" # emulMX); defvar sews = SchedSEWSet.val; foreach e = sews in { defvar WriteVRGatherVV_MX_E = !cast("WriteVRGatherVV_" # mx # "_E" # e); defvar ReadVRGatherVV_data_MX_E = !cast("ReadVRGatherVV_data_" # mx # "_E" # e); defvar ReadVRGatherVV_index_MX_E = !cast("ReadVRGatherVV_index_" # mx # "_E" # e); defm _VV : VPseudoBinaryEmul, Sched<[WriteVRGatherVV_MX_E, ReadVRGatherVV_data_MX_E, ReadVRGatherVV_index_MX_E]>; } } } } } multiclass VPseudoBinaryV_VX { defm "_VX" : VPseudoBinary; } multiclass VPseudoBinaryV_VX_RM { defm "_VX" : VPseudoBinaryRoundingMode; } multiclass VPseudoVSLD1_VX { foreach m = MxList in { defvar mx = m.MX; defvar WriteVISlide1X_MX = !cast("WriteVISlide1X_" # mx); defvar ReadVISlideV_MX = !cast("ReadVISlideV_" # mx); defvar ReadVISlideX_MX = !cast("ReadVISlideX_" # mx); defm "_VX" : VPseudoBinary, Sched<[WriteVISlide1X_MX, ReadVISlideV_MX, ReadVISlideX_MX, ReadVMask]>; } } multiclass VPseudoBinaryV_VF { defm "_V" # f.FX : VPseudoBinary; } multiclass VPseudoBinaryV_VF_RM { defm "_V" # f.FX : VPseudoBinaryRoundingMode; } multiclass VPseudoVSLD1_VF { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFSlide1F_MX = !cast("WriteVFSlide1F_" # mx); defvar ReadVFSlideV_MX = !cast("ReadVFSlideV_" # mx); defvar ReadVFSlideF_MX = !cast("ReadVFSlideF_" # mx); defm "_V" # f.FX : VPseudoBinary, Sched<[WriteVFSlide1F_MX, ReadVFSlideV_MX, ReadVFSlideF_MX, ReadVMask]>; } } } multiclass VPseudoBinaryV_VI { defm _VI : VPseudoBinary; } multiclass VPseudoBinaryV_VI_RM { defm _VI : VPseudoBinaryRoundingMode; } multiclass VPseudoVALU_MM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVMALUV_MX = !cast("WriteVMALUV_" # mx); defvar ReadVMALUV_MX = !cast("ReadVMALUV_" # mx); let VLMul = m.value in { def "_MM_" # mx : VPseudoBinaryNoMask, Sched<[WriteVMALUV_MX, ReadVMALUV_MX, ReadVMALUV_MX]>; } } } // 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 { defm _VV : VPseudoBinary; } multiclass VPseudoBinaryW_VV_RM { defm _VV : VPseudoBinaryRoundingMode; } multiclass VPseudoBinaryW_VX { defm "_VX" : VPseudoBinary; } multiclass VPseudoBinaryW_VF { defm "_V" # f.FX : VPseudoBinary; } multiclass VPseudoBinaryW_VF_RM { defm "_V" # f.FX : VPseudoBinaryRoundingMode; } multiclass VPseudoBinaryW_WV { defm _WV : VPseudoBinary; defm _WV : VPseudoTiedBinary; } multiclass VPseudoBinaryW_WV_RM { defm _WV : VPseudoBinaryRoundingMode; defm _WV : VPseudoTiedBinaryRoundingMode; } multiclass VPseudoBinaryW_WX { defm "_WX" : VPseudoBinary; } multiclass VPseudoBinaryW_WF { defm "_W" # f.FX : VPseudoBinary; } multiclass VPseudoBinaryW_WF_RM { defm "_W" # f.FX : VPseudoBinaryRoundingMode; } // 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 { defm _WV : VPseudoBinary; } multiclass VPseudoBinaryV_WV_RM { defm _WV : VPseudoBinaryRoundingMode; } multiclass VPseudoBinaryV_WX { defm _WX : VPseudoBinary; } multiclass VPseudoBinaryV_WX_RM { defm _WX : VPseudoBinaryRoundingMode; } multiclass VPseudoBinaryV_WI { defm _WI : VPseudoBinary; } multiclass VPseudoBinaryV_WI_RM { defm _WI : VPseudoBinaryRoundingMode; } // 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 { def "_VV" # !if(CarryIn, "M", "") # "_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass)), m.vrclass, m.vrclass, m, CarryIn, Constraint>; } multiclass VPseudoTiedBinaryV_VM { def "_VVM" # "_" # m.MX: VPseudoTiedBinaryCarryIn.R, m.vrclass, m.vrclass, m, 1, "">; } multiclass VPseudoBinaryV_XM { def "_VX" # !if(CarryIn, "M", "") # "_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass)), m.vrclass, GPR, m, CarryIn, Constraint>; } multiclass VPseudoTiedBinaryV_XM { def "_VXM" # "_" # m.MX: VPseudoTiedBinaryCarryIn.R, m.vrclass, GPR, m, 1, "">; } multiclass VPseudoVMRG_FM { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFMergeV_MX = !cast("WriteVFMergeV_" # mx); defvar ReadVFMergeV_MX = !cast("ReadVFMergeV_" # mx); defvar ReadVFMergeF_MX = !cast("ReadVFMergeF_" # mx); def "_V" # f.FX # "M_" # mx: VPseudoTiedBinaryCarryIn.R, m.vrclass, f.fprclass, m, CarryIn=1, Constraint="">, Sched<[WriteVFMergeV_MX, ReadVFMergeV_MX, ReadVFMergeF_MX, ReadVMask]>; } } } multiclass VPseudoBinaryV_IM { def "_VI" # !if(CarryIn, "M", "") # "_" # m.MX : VPseudoBinaryCarryIn.R, m.vrclass)), m.vrclass, simm5, m, CarryIn, Constraint>; } multiclass VPseudoTiedBinaryV_IM { def "_VIM" # "_" # m.MX: VPseudoTiedBinaryCarryIn.R, m.vrclass, simm5, m, 1, "">; } multiclass VPseudoUnaryVMV_V_X_I { foreach m = MxList in { let VLMul = m.value in { defvar mx = m.MX; defvar WriteVIMovV_MX = !cast("WriteVIMovV_" # mx); defvar WriteVIMovX_MX = !cast("WriteVIMovX_" # mx); defvar WriteVIMovI_MX = !cast("WriteVIMovI_" # mx); defvar ReadVIMovV_MX = !cast("ReadVIMovV_" # mx); defvar ReadVIMovX_MX = !cast("ReadVIMovX_" # mx); let VLMul = m.value in { def "_V_" # mx : VPseudoUnaryNoMask, Sched<[WriteVIMovV_MX, ReadVIMovV_MX]>; def "_X_" # mx : VPseudoUnaryNoMask, Sched<[WriteVIMovX_MX, ReadVIMovX_MX]>; def "_I_" # mx : VPseudoUnaryNoMask, Sched<[WriteVIMovI_MX]>; } } } } multiclass VPseudoVMV_F { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFMovV_MX = !cast("WriteVFMovV_" # mx); defvar ReadVFMovF_MX = !cast("ReadVFMovF_" # mx); let VLMul = m.value in { def "_" # f.FX # "_" # mx : VPseudoUnaryNoMask, Sched<[WriteVFMovV_MX, ReadVFMovF_MX]>; } } } } multiclass VPseudoVCLS_V { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFClassV_MX = !cast("WriteVFClassV_" # mx); defvar ReadVFClassV_MX = !cast("ReadVFClassV_" # mx); let VLMul = m.value in { def "_V_" # mx : VPseudoUnaryNoMask, Sched<[WriteVFClassV_MX, ReadVFClassV_MX, ReadVMask]>; def "_V_" # mx # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo, Sched<[WriteVFClassV_MX, ReadVFClassV_MX, ReadVMask]>; } } } multiclass VPseudoVSQR_V_RM { foreach m = MxListF in { defvar mx = m.MX; defvar sews = SchedSEWSet.val; let VLMul = m.value in foreach e = sews in { defvar suffix = "_" # mx # "_E" # e; defvar WriteVFSqrtV_MX_E = !cast("WriteVFSqrtV" # suffix); defvar ReadVFSqrtV_MX_E = !cast("ReadVFSqrtV" # suffix); let SEW = e in { def "_V" # suffix : VPseudoUnaryNoMaskRoundingMode, Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, ReadVMask]>; def "_V" # suffix # "_MASK" : VPseudoUnaryMaskRoundingMode, RISCVMaskedPseudo, Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, ReadVMask]>; } } } } multiclass VPseudoVRCP_V { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFRecpV_MX = !cast("WriteVFRecpV_" # mx); defvar ReadVFRecpV_MX = !cast("ReadVFRecpV_" # mx); let VLMul = m.value in { def "_V_" # mx : VPseudoUnaryNoMask, Sched<[WriteVFRecpV_MX, ReadVFRecpV_MX, ReadVMask]>; def "_V_" # mx # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo, Sched<[WriteVFRecpV_MX, ReadVFRecpV_MX, ReadVMask]>; } } } multiclass VPseudoVRCP_V_RM { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFRecpV_MX = !cast("WriteVFRecpV_" # mx); defvar ReadVFRecpV_MX = !cast("ReadVFRecpV_" # mx); let VLMul = m.value in { def "_V_" # mx : VPseudoUnaryNoMaskRoundingMode, Sched<[WriteVFRecpV_MX, ReadVFRecpV_MX, ReadVMask]>; def "_V_" # mx # "_MASK" : VPseudoUnaryMaskRoundingMode, RISCVMaskedPseudo, Sched<[WriteVFRecpV_MX, ReadVFRecpV_MX, ReadVMask]>; } } } multiclass PseudoVEXT_VF2 { defvar constraints = "@earlyclobber $rd"; foreach m = MxListVF2 in { defvar mx = m.MX; defvar WriteVExtV_MX = !cast("WriteVExtV_" # mx); defvar ReadVExtV_MX = !cast("ReadVExtV_" # mx); let VLMul = m.value in { def "_" # mx : VPseudoUnaryNoMask, Sched<[WriteVExtV_MX, ReadVExtV_MX, ReadVMask]>; def "_" # mx # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo, Sched<[WriteVExtV_MX, ReadVExtV_MX, ReadVMask]>; } } } multiclass PseudoVEXT_VF4 { defvar constraints = "@earlyclobber $rd"; foreach m = MxListVF4 in { defvar mx = m.MX; defvar WriteVExtV_MX = !cast("WriteVExtV_" # mx); defvar ReadVExtV_MX = !cast("ReadVExtV_" # mx); let VLMul = m.value in { def "_" # mx : VPseudoUnaryNoMask, Sched<[WriteVExtV_MX, ReadVExtV_MX, ReadVMask]>; def "_" # mx # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo, Sched<[WriteVExtV_MX, ReadVExtV_MX, ReadVMask]>; } } } multiclass PseudoVEXT_VF8 { defvar constraints = "@earlyclobber $rd"; foreach m = MxListVF8 in { defvar mx = m.MX; defvar WriteVExtV_MX = !cast("WriteVExtV_" # mx); defvar ReadVExtV_MX = !cast("ReadVExtV_" # mx); let VLMul = m.value in { def "_" # mx : VPseudoUnaryNoMask, Sched<[WriteVExtV_MX, ReadVExtV_MX, ReadVMask]>; def "_" # mx # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo, Sched<[WriteVExtV_MX, ReadVExtV_MX, 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 { defm _VV : VPseudoBinaryM; } multiclass VPseudoBinaryM_VX { defm "_VX" : VPseudoBinaryM; } multiclass VPseudoBinaryM_VF { defm "_V" # f.FX : VPseudoBinaryM; } multiclass VPseudoBinaryM_VI { defm _VI : VPseudoBinaryM; } multiclass VPseudoVGTR_VV_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVRGatherVX_MX = !cast("WriteVRGatherVX_" # mx); defvar WriteVRGatherVI_MX = !cast("WriteVRGatherVI_" # mx); defvar ReadVRGatherVX_data_MX = !cast("ReadVRGatherVX_data_" # mx); defvar ReadVRGatherVX_index_MX = !cast("ReadVRGatherVX_index_" # mx); defvar ReadVRGatherVI_data_MX = !cast("ReadVRGatherVI_data_" # mx); defm "" : VPseudoBinaryV_VX, Sched<[WriteVRGatherVX_MX, ReadVRGatherVX_data_MX, ReadVRGatherVX_index_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVRGatherVI_MX, ReadVRGatherVI_data_MX, ReadVMask]>; defvar sews = SchedSEWSet.val; foreach e = sews in { defvar WriteVRGatherVV_MX_E = !cast("WriteVRGatherVV_" # mx # "_E" # e); defvar ReadVRGatherVV_data_MX_E = !cast("ReadVRGatherVV_data_" # mx # "_E" # e); defvar ReadVRGatherVV_index_MX_E = !cast("ReadVRGatherVV_index_" # mx # "_E" # e); defm "" : VPseudoBinaryV_VV, Sched<[WriteVRGatherVV_MX_E, ReadVRGatherVV_data_MX_E, ReadVRGatherVV_index_MX_E, ReadVMask]>; } } } multiclass VPseudoVSALU_VV_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVSALUV_MX = !cast("WriteVSALUV_" # mx); defvar WriteVSALUX_MX = !cast("WriteVSALUX_" # mx); defvar WriteVSALUI_MX = !cast("WriteVSALUI_" # mx); defvar ReadVSALUV_MX = !cast("ReadVSALUV_" # mx); defvar ReadVSALUX_MX = !cast("ReadVSALUX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVSALUV_MX, ReadVSALUV_MX, ReadVSALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVSALUX_MX, ReadVSALUV_MX, ReadVSALUX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVSALUI_MX, ReadVSALUV_MX, ReadVMask]>; } } multiclass VPseudoVSHT_VV_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVShiftV_MX = !cast("WriteVShiftV_" # mx); defvar WriteVShiftX_MX = !cast("WriteVShiftX_" # mx); defvar WriteVShiftI_MX = !cast("WriteVShiftI_" # mx); defvar ReadVShiftV_MX = !cast("ReadVShiftV_" # mx); defvar ReadVShiftX_MX = !cast("ReadVShiftX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVShiftV_MX, ReadVShiftV_MX, ReadVShiftV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVShiftX_MX, ReadVShiftV_MX, ReadVShiftX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVShiftI_MX, ReadVShiftV_MX, ReadVMask]>; } } multiclass VPseudoVSSHT_VV_VX_VI_RM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVSShiftV_MX = !cast("WriteVSShiftV_" # mx); defvar WriteVSShiftX_MX = !cast("WriteVSShiftX_" # mx); defvar WriteVSShiftI_MX = !cast("WriteVSShiftI_" # mx); defvar ReadVSShiftV_MX = !cast("ReadVSShiftV_" # mx); defvar ReadVSShiftX_MX = !cast("ReadVSShiftX_" # mx); defm "" : VPseudoBinaryV_VV_RM, Sched<[WriteVSShiftV_MX, ReadVSShiftV_MX, ReadVSShiftV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX_RM, Sched<[WriteVSShiftX_MX, ReadVSShiftV_MX, ReadVSShiftX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VI_RM, Sched<[WriteVSShiftI_MX, ReadVSShiftV_MX, ReadVMask]>; } } multiclass VPseudoVALU_VV_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIALUV_MX = !cast("WriteVIALUV_" # mx); defvar WriteVIALUX_MX = !cast("WriteVIALUX_" # mx); defvar WriteVIALUI_MX = !cast("WriteVIALUI_" # mx); defvar ReadVIALUV_MX = !cast("ReadVIALUV_" # mx); defvar ReadVIALUX_MX = !cast("ReadVIALUX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVIALUV_MX, ReadVIALUV_MX, ReadVIALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIALUX_MX, ReadVIALUV_MX, ReadVIALUX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVIALUI_MX, ReadVIALUV_MX, ReadVMask]>; } } multiclass VPseudoVSALU_VV_VX { foreach m = MxList in { defvar mx = m.MX; defvar WriteVSALUV_MX = !cast("WriteVSALUV_" # mx); defvar WriteVSALUX_MX = !cast("WriteVSALUX_" # mx); defvar ReadVSALUV_MX = !cast("ReadVSALUV_" # mx); defvar ReadVSALUX_MX = !cast("ReadVSALUX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVSALUV_MX, ReadVSALUV_MX, ReadVSALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVSALUX_MX, ReadVSALUV_MX, ReadVSALUX_MX, ReadVMask]>; } } multiclass VPseudoVSMUL_VV_VX_RM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVSMulV_MX = !cast("WriteVSMulV_" # mx); defvar WriteVSMulX_MX = !cast("WriteVSMulX_" # mx); defvar ReadVSMulV_MX = !cast("ReadVSMulV_" # mx); defvar ReadVSMulX_MX = !cast("ReadVSMulX_" # mx); defm "" : VPseudoBinaryV_VV_RM, Sched<[WriteVSMulV_MX, ReadVSMulV_MX, ReadVSMulV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX_RM, Sched<[WriteVSMulX_MX, ReadVSMulV_MX, ReadVSMulX_MX, ReadVMask]>; } } multiclass VPseudoVAALU_VV_VX_RM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVAALUV_MX = !cast("WriteVAALUV_" # mx); defvar WriteVAALUX_MX = !cast("WriteVAALUX_" # mx); defvar ReadVAALUV_MX = !cast("ReadVAALUV_" # mx); defvar ReadVAALUX_MX = !cast("ReadVAALUX_" # mx); defm "" : VPseudoBinaryV_VV_RM, Sched<[WriteVAALUV_MX, ReadVAALUV_MX, ReadVAALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX_RM, Sched<[WriteVAALUX_MX, ReadVAALUV_MX, ReadVAALUX_MX, ReadVMask]>; } } multiclass VPseudoVMINMAX_VV_VX { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIMinMaxV_MX = !cast("WriteVIMinMaxV_" # mx); defvar WriteVIMinMaxX_MX = !cast("WriteVIMinMaxX_" # mx); defvar ReadVIMinMaxV_MX = !cast("ReadVIMinMaxV_" # mx); defvar ReadVIMinMaxX_MX = !cast("ReadVIMinMaxX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVIMinMaxV_MX, ReadVIMinMaxV_MX, ReadVIMinMaxV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIMinMaxX_MX, ReadVIMinMaxV_MX, ReadVIMinMaxX_MX, ReadVMask]>; } } multiclass VPseudoVMUL_VV_VX { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIMulV_MX = !cast("WriteVIMulV_" # mx); defvar WriteVIMulX_MX = !cast("WriteVIMulX_" # mx); defvar ReadVIMulV_MX = !cast("ReadVIMulV_" # mx); defvar ReadVIMulX_MX = !cast("ReadVIMulX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVIMulV_MX, ReadVIMulV_MX, ReadVIMulV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIMulX_MX, ReadVIMulV_MX, ReadVIMulX_MX, ReadVMask]>; } } multiclass VPseudoVDIV_VV_VX { foreach m = MxList in { defvar mx = m.MX; defvar sews = SchedSEWSet.val; foreach e = sews in { defvar WriteVIDivV_MX_E = !cast("WriteVIDivV_" # mx # "_E" # e); defvar WriteVIDivX_MX_E = !cast("WriteVIDivX_" # mx # "_E" # e); defvar ReadVIDivV_MX_E = !cast("ReadVIDivV_" # mx # "_E" # e); defvar ReadVIDivX_MX_E = !cast("ReadVIDivX_" # mx # "_E" # e); defm "" : VPseudoBinaryV_VV, Sched<[WriteVIDivV_MX_E, ReadVIDivV_MX_E, ReadVIDivV_MX_E, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIDivX_MX_E, ReadVIDivV_MX_E, ReadVIDivX_MX_E, ReadVMask]>; } } } multiclass VPseudoVFMUL_VV_VF_RM { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFMulV_MX = !cast("WriteVFMulV_" # mx); defvar ReadVFMulV_MX = !cast("ReadVFMulV_" # mx); defm "" : VPseudoBinaryFV_VV_RM, Sched<[WriteVFMulV_MX, ReadVFMulV_MX, ReadVFMulV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFMulF_MX = !cast("WriteVFMulF_" # mx); defvar ReadVFMulV_MX = !cast("ReadVFMulV_" # mx); defvar ReadVFMulF_MX = !cast("ReadVFMulF_" # mx); defm "" : VPseudoBinaryV_VF_RM, Sched<[WriteVFMulF_MX, ReadVFMulV_MX, ReadVFMulF_MX, ReadVMask]>; } } } multiclass VPseudoVFDIV_VV_VF_RM { foreach m = MxListF in { defvar mx = m.MX; defvar sews = SchedSEWSet.val; foreach e = sews in { defvar WriteVFDivV_MX_E = !cast("WriteVFDivV_" # mx # "_E" # e); defvar ReadVFDivV_MX_E = !cast("ReadVFDivV_" # mx # "_E" # e); defm "" : VPseudoBinaryFV_VV_RM, Sched<[WriteVFDivV_MX_E, ReadVFDivV_MX_E, ReadVFDivV_MX_E, ReadVMask]>; } } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFDivF_MX_E = !cast("WriteVFDivF_" # mx # "_E" # f.SEW); defvar ReadVFDivV_MX_E = !cast("ReadVFDivV_" # mx # "_E" # f.SEW); defvar ReadVFDivF_MX_E = !cast("ReadVFDivF_" # mx # "_E" # f.SEW); defm "" : VPseudoBinaryV_VF_RM, Sched<[WriteVFDivF_MX_E, ReadVFDivV_MX_E, ReadVFDivF_MX_E, ReadVMask]>; } } } multiclass VPseudoVFRDIV_VF_RM { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFDivF_MX_E = !cast("WriteVFDivF_" # mx # "_E" # f.SEW); defvar ReadVFDivV_MX_E = !cast("ReadVFDivV_" # mx # "_E" # f.SEW); defvar ReadVFDivF_MX_E = !cast("ReadVFDivF_" # mx # "_E" # f.SEW); defm "" : VPseudoBinaryV_VF_RM, Sched<[WriteVFDivF_MX_E, ReadVFDivV_MX_E, ReadVFDivF_MX_E, ReadVMask]>; } } } multiclass VPseudoVALU_VV_VX { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIALUV_MX = !cast("WriteVIALUV_" # mx); defvar WriteVIALUX_MX = !cast("WriteVIALUV_" # mx); defvar ReadVIALUV_MX = !cast("ReadVIALUV_" # mx); defvar ReadVIALUX_MX = !cast("ReadVIALUX_" # mx); defm "" : VPseudoBinaryV_VV, Sched<[WriteVIALUV_MX, ReadVIALUV_MX, ReadVIALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VX, Sched<[WriteVIALUX_MX, ReadVIALUV_MX, ReadVIALUX_MX, ReadVMask]>; } } multiclass VPseudoVSGNJ_VV_VF { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFSgnjV_MX = !cast("WriteVFSgnjV_" # mx); defvar ReadVFSgnjV_MX = !cast("ReadVFSgnjV_" # mx); defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFSgnjV_MX, ReadVFSgnjV_MX, ReadVFSgnjV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFSgnjF_MX = !cast("WriteVFSgnjF_" # mx); defvar ReadVFSgnjV_MX = !cast("ReadVFSgnjV_" # mx); defvar ReadVFSgnjF_MX = !cast("ReadVFSgnjF_" # mx); defm "" : VPseudoBinaryV_VF, Sched<[WriteVFSgnjF_MX, ReadVFSgnjV_MX, ReadVFSgnjF_MX, ReadVMask]>; } } } multiclass VPseudoVMAX_VV_VF { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFMinMaxV_MX = !cast("WriteVFMinMaxV_" # mx); defvar ReadVFMinMaxV_MX = !cast("ReadVFMinMaxV_" # mx); defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFMinMaxV_MX, ReadVFMinMaxV_MX, ReadVFMinMaxV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFMinMaxF_MX = !cast("WriteVFMinMaxF_" # mx); defvar ReadVFMinMaxV_MX = !cast("ReadVFMinMaxV_" # mx); defvar ReadVFMinMaxF_MX = !cast("ReadVFMinMaxF_" # mx); defm "" : VPseudoBinaryV_VF, Sched<[WriteVFMinMaxF_MX, ReadVFMinMaxV_MX, ReadVFMinMaxF_MX, ReadVMask]>; } } } multiclass VPseudoVALU_VV_VF { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFALUV_MX = !cast("WriteVFALUV_" # mx); defvar ReadVFALUV_MX = !cast("ReadVFALUV_" # mx); defm "" : VPseudoBinaryFV_VV, Sched<[WriteVFALUV_MX, ReadVFALUV_MX, ReadVFALUV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFALUF_MX = !cast("WriteVFALUF_" # mx); defvar ReadVFALUV_MX = !cast("ReadVFALUV_" # mx); defvar ReadVFALUF_MX = !cast("ReadVFALUF_" # mx); defm "" : VPseudoBinaryV_VF, Sched<[WriteVFALUF_MX, ReadVFALUV_MX, ReadVFALUF_MX, ReadVMask]>; } } } multiclass VPseudoVALU_VV_VF_RM { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFALUV_MX = !cast("WriteVFALUV_" # mx); defvar ReadVFALUV_MX = !cast("ReadVFALUV_" # mx); defm "" : VPseudoBinaryFV_VV_RM, Sched<[WriteVFALUV_MX, ReadVFALUV_MX, ReadVFALUV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFALUF_MX = !cast("WriteVFALUF_" # mx); defvar ReadVFALUV_MX = !cast("ReadVFALUV_" # mx); defvar ReadVFALUF_MX = !cast("ReadVFALUF_" # mx); defm "" : VPseudoBinaryV_VF_RM, Sched<[WriteVFALUF_MX, ReadVFALUV_MX, ReadVFALUF_MX, ReadVMask]>; } } } multiclass VPseudoVALU_VF { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFALUF_MX = !cast("WriteVFALUF_" # mx); defvar ReadVFALUV_MX = !cast("ReadVFALUV_" # mx); defvar ReadVFALUF_MX = !cast("ReadVFALUF_" # mx); defm "" : VPseudoBinaryV_VF, Sched<[WriteVFALUF_MX, ReadVFALUV_MX, ReadVFALUF_MX, ReadVMask]>; } } } multiclass VPseudoVALU_VF_RM { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFALUF_MX = !cast("WriteVFALUF_" # mx); defvar ReadVFALUV_MX = !cast("ReadVFALUV_" # mx); defvar ReadVFALUF_MX = !cast("ReadVFALUF_" # mx); defm "" : VPseudoBinaryV_VF_RM, Sched<[WriteVFALUF_MX, ReadVFALUV_MX, ReadVFALUF_MX, ReadVMask]>; } } } multiclass VPseudoVALU_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIALUX_MX = !cast("WriteVIALUX_" # mx); defvar WriteVIALUI_MX = !cast("WriteVIALUI_" # mx); defvar ReadVIALUV_MX = !cast("ReadVIALUV_" # mx); defvar ReadVIALUX_MX = !cast("ReadVIALUX_" # mx); defm "" : VPseudoBinaryV_VX, Sched<[WriteVIALUX_MX, ReadVIALUV_MX, ReadVIALUX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_VI, Sched<[WriteVIALUI_MX, ReadVIALUV_MX, ReadVMask]>; } } multiclass VPseudoVWALU_VV_VX { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVIWALUV_MX = !cast("WriteVIWALUV_" # mx); defvar WriteVIWALUX_MX = !cast("WriteVIWALUX_" # mx); defvar ReadVIWALUV_MX = !cast("ReadVIWALUV_" # mx); defvar ReadVIWALUX_MX = !cast("ReadVIWALUX_" # mx); defm "" : VPseudoBinaryW_VV, Sched<[WriteVIWALUV_MX, ReadVIWALUV_MX, ReadVIWALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryW_VX, Sched<[WriteVIWALUX_MX, ReadVIWALUV_MX, ReadVIWALUX_MX, ReadVMask]>; } } multiclass VPseudoVWMUL_VV_VX { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVIWMulV_MX = !cast("WriteVIWMulV_" # mx); defvar WriteVIWMulX_MX = !cast("WriteVIWMulX_" # mx); defvar ReadVIWMulV_MX = !cast("ReadVIWMulV_" # mx); defvar ReadVIWMulX_MX = !cast("ReadVIWMulX_" # mx); defm "" : VPseudoBinaryW_VV, Sched<[WriteVIWMulV_MX, ReadVIWMulV_MX, ReadVIWMulV_MX, ReadVMask]>; defm "" : VPseudoBinaryW_VX, Sched<[WriteVIWMulX_MX, ReadVIWMulV_MX, ReadVIWMulX_MX, ReadVMask]>; } } multiclass VPseudoVWMUL_VV_VF_RM { foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWMulV_MX = !cast("WriteVFWMulV_" # mx); defvar ReadVFWMulV_MX = !cast("ReadVFWMulV_" # mx); defm "" : VPseudoBinaryW_VV_RM, Sched<[WriteVFWMulV_MX, ReadVFWMulV_MX, ReadVFWMulV_MX, ReadVMask]>; } foreach f = FPListW in { foreach m = f.MxListFW in { defvar mx = m.MX; defvar WriteVFWMulF_MX = !cast("WriteVFWMulF_" # mx); defvar ReadVFWMulV_MX = !cast("ReadVFWMulV_" # mx); defvar ReadVFWMulF_MX = !cast("ReadVFWMulF_" # mx); defm "" : VPseudoBinaryW_VF_RM, Sched<[WriteVFWMulF_MX, ReadVFWMulV_MX, ReadVFWMulF_MX, ReadVMask]>; } } } multiclass VPseudoVWALU_WV_WX { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVIWALUV_MX = !cast("WriteVIWALUV_" # mx); defvar WriteVIWALUX_MX = !cast("WriteVIWALUX_" # mx); defvar ReadVIWALUV_MX = !cast("ReadVIWALUV_" # mx); defvar ReadVIWALUX_MX = !cast("ReadVIWALUX_" # mx); defm "" : VPseudoBinaryW_WV, Sched<[WriteVIWALUV_MX, ReadVIWALUV_MX, ReadVIWALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryW_WX, Sched<[WriteVIWALUX_MX, ReadVIWALUV_MX, ReadVIWALUX_MX, ReadVMask]>; } } multiclass VPseudoVFWALU_VV_VF_RM { foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWALUV_MX = !cast("WriteVFWALUV_" # mx); defvar ReadVFWALUV_MX = !cast("ReadVFWALUV_" # mx); defm "" : VPseudoBinaryW_VV_RM, Sched<[WriteVFWALUV_MX, ReadVFWALUV_MX, ReadVFWALUV_MX, ReadVMask]>; } foreach f = FPListW in { foreach m = f.MxListFW in { defvar mx = m.MX; defvar WriteVFWALUF_MX = !cast("WriteVFWALUF_" # mx); defvar ReadVFWALUV_MX = !cast("ReadVFWALUV_" # mx); defvar ReadVFWALUF_MX = !cast("ReadVFWALUF_" # mx); defm "" : VPseudoBinaryW_VF_RM, Sched<[WriteVFWALUF_MX, ReadVFWALUV_MX, ReadVFWALUF_MX, ReadVMask]>; } } } multiclass VPseudoVFWALU_WV_WF_RM { foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWALUV_MX = !cast("WriteVFWALUV_" # mx); defvar ReadVFWALUV_MX = !cast("ReadVFWALUV_" # mx); defm "" : VPseudoBinaryW_WV_RM, Sched<[WriteVFWALUV_MX, ReadVFWALUV_MX, ReadVFWALUV_MX, ReadVMask]>; } foreach f = FPListW in { foreach m = f.MxListFW in { defvar mx = m.MX; defvar WriteVFWALUF_MX = !cast("WriteVFWALUF_" # mx); defvar ReadVFWALUV_MX = !cast("ReadVFWALUV_" # mx); defvar ReadVFWALUF_MX = !cast("ReadVFWALUF_" # mx); defm "" : VPseudoBinaryW_WF_RM, Sched<[WriteVFWALUF_MX, ReadVFWALUV_MX, ReadVFWALUF_MX, ReadVMask]>; } } } multiclass VPseudoVMRG_VM_XM_IM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIMergeV_MX = !cast("WriteVIMergeV_" # mx); defvar WriteVIMergeX_MX = !cast("WriteVIMergeX_" # mx); defvar WriteVIMergeI_MX = !cast("WriteVIMergeI_" # mx); defvar ReadVIMergeV_MX = !cast("ReadVIMergeV_" # mx); defvar ReadVIMergeX_MX = !cast("ReadVIMergeX_" # mx); def "_VVM" # "_" # m.MX: VPseudoTiedBinaryCarryIn.R, m.vrclass, m.vrclass, m, 1, "">, Sched<[WriteVIMergeV_MX, ReadVIMergeV_MX, ReadVIMergeV_MX, ReadVMask]>; def "_VXM" # "_" # m.MX: VPseudoTiedBinaryCarryIn.R, m.vrclass, GPR, m, 1, "">, Sched<[WriteVIMergeX_MX, ReadVIMergeV_MX, ReadVIMergeX_MX, ReadVMask]>; def "_VIM" # "_" # m.MX: VPseudoTiedBinaryCarryIn.R, m.vrclass, simm5, m, 1, "">, Sched<[WriteVIMergeI_MX, ReadVIMergeV_MX, ReadVMask]>; } } multiclass VPseudoVCALU_VM_XM_IM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICALUV_MX = !cast("WriteVICALUV_" # mx); defvar WriteVICALUX_MX = !cast("WriteVICALUX_" # mx); defvar WriteVICALUI_MX = !cast("WriteVICALUI_" # mx); defvar ReadVICALUV_MX = !cast("ReadVICALUV_" # mx); defvar ReadVICALUX_MX = !cast("ReadVICALUX_" # mx); defm "" : VPseudoTiedBinaryV_VM, Sched<[WriteVICALUV_MX, ReadVICALUV_MX, ReadVICALUV_MX, ReadVMask]>; defm "" : VPseudoTiedBinaryV_XM, Sched<[WriteVICALUX_MX, ReadVICALUV_MX, ReadVICALUX_MX, ReadVMask]>; defm "" : VPseudoTiedBinaryV_IM, Sched<[WriteVICALUI_MX, ReadVICALUV_MX, ReadVMask]>; } } multiclass VPseudoVCALU_VM_XM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICALUV_MX = !cast("WriteVICALUV_" # mx); defvar WriteVICALUX_MX = !cast("WriteVICALUX_" # mx); defvar ReadVICALUV_MX = !cast("ReadVICALUV_" # mx); defvar ReadVICALUX_MX = !cast("ReadVICALUX_" # mx); defm "" : VPseudoTiedBinaryV_VM, Sched<[WriteVICALUV_MX, ReadVICALUV_MX, ReadVICALUV_MX, ReadVMask]>; defm "" : VPseudoTiedBinaryV_XM, Sched<[WriteVICALUX_MX, ReadVICALUV_MX, ReadVICALUX_MX, ReadVMask]>; } } multiclass VPseudoVCALUM_VM_XM_IM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICALUV_MX = !cast("WriteVICALUV_" # mx); defvar WriteVICALUX_MX = !cast("WriteVICALUX_" # mx); defvar WriteVICALUI_MX = !cast("WriteVICALUI_" # mx); defvar ReadVICALUV_MX = !cast("ReadVICALUV_" # mx); defvar ReadVICALUX_MX = !cast("ReadVICALUX_" # mx); defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV_MX, ReadVICALUV_MX, ReadVICALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX_MX, ReadVICALUV_MX, ReadVICALUX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_IM, Sched<[WriteVICALUI_MX, ReadVICALUV_MX, ReadVMask]>; } } multiclass VPseudoVCALUM_VM_XM { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICALUV_MX = !cast("WriteVICALUV_" # mx); defvar WriteVICALUX_MX = !cast("WriteVICALUX_" # mx); defvar ReadVICALUV_MX = !cast("ReadVICALUV_" # mx); defvar ReadVICALUX_MX = !cast("ReadVICALUX_" # mx); defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV_MX, ReadVICALUV_MX, ReadVICALUV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX_MX, ReadVICALUV_MX, ReadVICALUX_MX, ReadVMask]>; } } multiclass VPseudoVCALUM_V_X_I { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICALUV_MX = !cast("WriteVICALUV_" # mx); defvar WriteVICALUX_MX = !cast("WriteVICALUX_" # mx); defvar WriteVICALUI_MX = !cast("WriteVICALUI_" # mx); defvar ReadVICALUV_MX = !cast("ReadVICALUV_" # mx); defvar ReadVICALUX_MX = !cast("ReadVICALUX_" # mx); defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV_MX, ReadVICALUV_MX, ReadVICALUV_MX]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX_MX, ReadVICALUV_MX, ReadVICALUX_MX]>; defm "" : VPseudoBinaryV_IM, Sched<[WriteVICALUI_MX, ReadVICALUV_MX]>; } } multiclass VPseudoVCALUM_V_X { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICALUV_MX = !cast("WriteVICALUV_" # mx); defvar WriteVICALUX_MX = !cast("WriteVICALUX_" # mx); defvar ReadVICALUV_MX = !cast("ReadVICALUV_" # mx); defvar ReadVICALUX_MX = !cast("ReadVICALUX_" # mx); defm "" : VPseudoBinaryV_VM, Sched<[WriteVICALUV_MX, ReadVICALUV_MX, ReadVICALUV_MX]>; defm "" : VPseudoBinaryV_XM, Sched<[WriteVICALUX_MX, ReadVICALUV_MX, ReadVICALUX_MX]>; } } multiclass VPseudoVNCLP_WV_WX_WI_RM { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVNClipV_MX = !cast("WriteVNClipV_" # mx); defvar WriteVNClipX_MX = !cast("WriteVNClipX_" # mx); defvar WriteVNClipI_MX = !cast("WriteVNClipI_" # mx); defvar ReadVNClipV_MX = !cast("ReadVNClipV_" # mx); defvar ReadVNClipX_MX = !cast("ReadVNClipX_" # mx); defm "" : VPseudoBinaryV_WV_RM, Sched<[WriteVNClipV_MX, ReadVNClipV_MX, ReadVNClipV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_WX_RM, Sched<[WriteVNClipX_MX, ReadVNClipV_MX, ReadVNClipX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_WI_RM, Sched<[WriteVNClipI_MX, ReadVNClipV_MX, ReadVMask]>; } } multiclass VPseudoVNSHT_WV_WX_WI { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVNShiftV_MX = !cast("WriteVNShiftV_" # mx); defvar WriteVNShiftX_MX = !cast("WriteVNShiftX_" # mx); defvar WriteVNShiftI_MX = !cast("WriteVNShiftI_" # mx); defvar ReadVNShiftV_MX = !cast("ReadVNShiftV_" # mx); defvar ReadVNShiftX_MX = !cast("ReadVNShiftX_" # mx); defm "" : VPseudoBinaryV_WV, Sched<[WriteVNShiftV_MX, ReadVNShiftV_MX, ReadVNShiftV_MX, ReadVMask]>; defm "" : VPseudoBinaryV_WX, Sched<[WriteVNShiftX_MX, ReadVNShiftV_MX, ReadVNShiftX_MX, ReadVMask]>; defm "" : VPseudoBinaryV_WI, Sched<[WriteVNShiftI_MX, ReadVNShiftV_MX, ReadVMask]>; } } multiclass VPseudoTernaryWithTailPolicy { let VLMul = MInfo.value in { defvar mx = MInfo.MX; let isCommutable = Commutable in def "_" # mx # "_E" # sew : VPseudoTernaryNoMaskWithPolicy; def "_" # mx # "_E" # sew # "_MASK" : VPseudoTernaryMaskPolicy; } } multiclass VPseudoTernaryWithTailPolicyRoundingMode { let VLMul = MInfo.value in { defvar mx = MInfo.MX; let isCommutable = Commutable in def "_" # mx # "_E" # sew : VPseudoTernaryNoMaskWithPolicyRoundingMode; def "_" # mx # "_E" # sew # "_MASK" : VPseudoTernaryMaskPolicyRoundingMode; } } multiclass VPseudoTernaryWithPolicy { let VLMul = MInfo.value in { let isCommutable = Commutable in def "_" # MInfo.MX : VPseudoTernaryNoMaskWithPolicy; def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMaskPolicy, RISCVMaskedPseudo; } } multiclass VPseudoTernaryWithPolicyRoundingMode { let VLMul = MInfo.value in { let isCommutable = Commutable in def "_" # MInfo.MX : VPseudoTernaryNoMaskWithPolicyRoundingMode; def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMaskPolicyRoundingMode, RISCVMaskedPseudo; } } multiclass VPseudoTernaryV_VV_AAXA { defm _VV : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryV_VV_AAXA_RM { defm _VV : VPseudoTernaryWithPolicyRoundingMode; } multiclass VPseudoTernaryV_VX_AAXA { defm "_VX" : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryV_VF_AAXA { defm "_V" # f.FX : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryV_VF_AAXA_RM { defm "_V" # f.FX : VPseudoTernaryWithPolicyRoundingMode; } multiclass VPseudoTernaryW_VV { defvar constraint = "@earlyclobber $rd"; defm _VV : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryW_VV_RM { defvar constraint = "@earlyclobber $rd"; defm _VV : VPseudoTernaryWithPolicyRoundingMode; } multiclass VPseudoTernaryW_VX { defvar constraint = "@earlyclobber $rd"; defm "_VX" : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryW_VF { defvar constraint = "@earlyclobber $rd"; defm "_V" # f.FX : VPseudoTernaryWithPolicy; } multiclass VPseudoTernaryW_VF_RM { defvar constraint = "@earlyclobber $rd"; defm "_V" # f.FX : VPseudoTernaryWithPolicyRoundingMode; } multiclass VPseudoVSLDVWithPolicy { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoTernaryNoMaskWithPolicy; def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMaskPolicy, RISCVMaskedPseudo; } } multiclass VPseudoVSLDV_VX { defm _VX : VPseudoVSLDVWithPolicy; } multiclass VPseudoVSLDV_VI { defm _VI : VPseudoVSLDVWithPolicy; } multiclass VPseudoVMAC_VV_VX_AAXA { foreach m = MxList in { defvar mx = m.MX; defvar WriteVIMulAddV_MX = !cast("WriteVIMulAddV_" # mx); defvar WriteVIMulAddX_MX = !cast("WriteVIMulAddX_" # mx); defvar ReadVIMulAddV_MX = !cast("ReadVIMulAddV_" # mx); defvar ReadVIMulAddX_MX = !cast("ReadVIMulAddX_" # mx); defm "" : VPseudoTernaryV_VV_AAXA, Sched<[WriteVIMulAddV_MX, ReadVIMulAddV_MX, ReadVIMulAddV_MX, ReadVIMulAddV_MX, ReadVMask]>; defm "" : VPseudoTernaryV_VX_AAXA, Sched<[WriteVIMulAddX_MX, ReadVIMulAddV_MX, ReadVIMulAddV_MX, ReadVIMulAddX_MX, ReadVMask]>; } } multiclass VPseudoVMAC_VV_VF_AAXA { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFMulAddV_MX = !cast("WriteVFMulAddV_" # mx); defvar ReadVFMulAddV_MX = !cast("ReadVFMulAddV_" # mx); defm "" : VPseudoTernaryV_VV_AAXA, Sched<[WriteVFMulAddV_MX, ReadVFMulAddV_MX, ReadVFMulAddV_MX, ReadVFMulAddV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFMulAddF_MX = !cast("WriteVFMulAddF_" # mx); defvar ReadVFMulAddV_MX = !cast("ReadVFMulAddV_" # mx); defvar ReadVFMulAddF_MX = !cast("ReadVFMulAddF_" # mx); defm "" : VPseudoTernaryV_VF_AAXA, Sched<[WriteVFMulAddF_MX, ReadVFMulAddV_MX, ReadVFMulAddV_MX, ReadVFMulAddF_MX, ReadVMask]>; } } } multiclass VPseudoVMAC_VV_VF_AAXA_RM { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFMulAddV_MX = !cast("WriteVFMulAddV_" # mx); defvar ReadVFMulAddV_MX = !cast("ReadVFMulAddV_" # mx); defm "" : VPseudoTernaryV_VV_AAXA_RM, Sched<[WriteVFMulAddV_MX, ReadVFMulAddV_MX, ReadVFMulAddV_MX, ReadVFMulAddV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFMulAddF_MX = !cast("WriteVFMulAddF_" # mx); defvar ReadVFMulAddV_MX = !cast("ReadVFMulAddV_" # mx); defvar ReadVFMulAddF_MX = !cast("ReadVFMulAddF_" # mx); defm "" : VPseudoTernaryV_VF_AAXA_RM, Sched<[WriteVFMulAddF_MX, ReadVFMulAddV_MX, ReadVFMulAddV_MX, ReadVFMulAddF_MX, ReadVMask]>; } } } multiclass VPseudoVSLD_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVISlideX_MX = !cast("WriteVISlideX_" # mx); defvar WriteVISlideI_MX = !cast("WriteVISlideI_" # mx); defvar ReadVISlideV_MX = !cast("ReadVISlideV_" # mx); defvar ReadVISlideX_MX = !cast("ReadVISlideX_" # mx); defm "" : VPseudoVSLDV_VX, Sched<[WriteVISlideX_MX, ReadVISlideV_MX, ReadVISlideV_MX, ReadVISlideX_MX, ReadVMask]>; defm "" : VPseudoVSLDV_VI, Sched<[WriteVISlideI_MX, ReadVISlideV_MX, ReadVISlideV_MX, ReadVMask]>; } } multiclass VPseudoVWMAC_VV_VX { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVIWMulAddV_MX = !cast("WriteVIWMulAddV_" # mx); defvar WriteVIWMulAddX_MX = !cast("WriteVIWMulAddX_" # mx); defvar ReadVIWMulAddV_MX = !cast("ReadVIWMulAddV_" # mx); defvar ReadVIWMulAddX_MX = !cast("ReadVIWMulAddX_" # mx); defm "" : VPseudoTernaryW_VV, Sched<[WriteVIWMulAddV_MX, ReadVIWMulAddV_MX, ReadVIWMulAddV_MX, ReadVIWMulAddV_MX, ReadVMask]>; defm "" : VPseudoTernaryW_VX, Sched<[WriteVIWMulAddX_MX, ReadVIWMulAddV_MX, ReadVIWMulAddV_MX, ReadVIWMulAddX_MX, ReadVMask]>; } } multiclass VPseudoVWMAC_VX { foreach m = MxListW in { defvar mx = m.MX; defvar WriteVIWMulAddX_MX = !cast("WriteVIWMulAddX_" # mx); defvar ReadVIWMulAddV_MX= !cast("ReadVIWMulAddV_" # mx); defvar ReadVIWMulAddX_MX = !cast("ReadVIWMulAddX_" # mx); defm "" : VPseudoTernaryW_VX, Sched<[WriteVIWMulAddX_MX, ReadVIWMulAddV_MX, ReadVIWMulAddV_MX, ReadVIWMulAddX_MX, ReadVMask]>; } } multiclass VPseudoVWMAC_VV_VF_RM { foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWMulAddV_MX = !cast("WriteVFWMulAddV_" # mx); defvar ReadVFWMulAddV_MX = !cast("ReadVFWMulAddV_" # mx); defm "" : VPseudoTernaryW_VV_RM, Sched<[WriteVFWMulAddV_MX, ReadVFWMulAddV_MX, ReadVFWMulAddV_MX, ReadVFWMulAddV_MX, ReadVMask]>; } foreach f = FPListW in { foreach m = f.MxListFW in { defvar mx = m.MX; defvar WriteVFWMulAddF_MX = !cast("WriteVFWMulAddF_" # mx); defvar ReadVFWMulAddV_MX = !cast("ReadVFWMulAddV_" # mx); defvar ReadVFWMulAddF_MX = !cast("ReadVFWMulAddF_" # mx); defm "" : VPseudoTernaryW_VF_RM, Sched<[WriteVFWMulAddF_MX, ReadVFWMulAddV_MX, ReadVFWMulAddV_MX, ReadVFWMulAddF_MX, ReadVMask]>; } } } multiclass VPseudoVCMPM_VV_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICmpV_MX = !cast("WriteVICmpV_" # mx); defvar WriteVICmpX_MX = !cast("WriteVICmpX_" # mx); defvar WriteVICmpI_MX = !cast("WriteVICmpI_" # mx); defvar ReadVICmpV_MX = !cast("ReadVICmpV_" # mx); defvar ReadVICmpX_MX = !cast("ReadVICmpX_" # mx); defm "" : VPseudoBinaryM_VV, Sched<[WriteVICmpV_MX, ReadVICmpV_MX, ReadVICmpV_MX, ReadVMask]>; defm "" : VPseudoBinaryM_VX, Sched<[WriteVICmpX_MX, ReadVICmpV_MX, ReadVICmpX_MX, ReadVMask]>; defm "" : VPseudoBinaryM_VI, Sched<[WriteVICmpI_MX, ReadVICmpV_MX, ReadVMask]>; } } multiclass VPseudoVCMPM_VV_VX { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICmpV_MX = !cast("WriteVICmpV_" # mx); defvar WriteVICmpX_MX = !cast("WriteVICmpX_" # mx); defvar ReadVICmpV_MX = !cast("ReadVICmpV_" # mx); defvar ReadVICmpX_MX = !cast("ReadVICmpX_" # mx); defm "" : VPseudoBinaryM_VV, Sched<[WriteVICmpV_MX, ReadVICmpV_MX, ReadVICmpV_MX, ReadVMask]>; defm "" : VPseudoBinaryM_VX, Sched<[WriteVICmpX_MX, ReadVICmpV_MX, ReadVICmpX_MX, ReadVMask]>; } } multiclass VPseudoVCMPM_VV_VF { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCmpV_MX = !cast("WriteVFCmpV_" # mx); defvar ReadVFCmpV_MX = !cast("ReadVFCmpV_" # mx); defm "" : VPseudoBinaryM_VV, Sched<[WriteVFCmpV_MX, ReadVFCmpV_MX, ReadVFCmpV_MX, ReadVMask]>; } foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFCmpF_MX = !cast("WriteVFCmpF_" # mx); defvar ReadVFCmpV_MX = !cast("ReadVFCmpV_" # mx); defvar ReadVFCmpF_MX = !cast("ReadVFCmpF_" # mx); defm "" : VPseudoBinaryM_VF, Sched<[WriteVFCmpF_MX, ReadVFCmpV_MX, ReadVFCmpF_MX, ReadVMask]>; } } } multiclass VPseudoVCMPM_VF { foreach f = FPList in { foreach m = f.MxList in { defvar mx = m.MX; defvar WriteVFCmpF_MX = !cast("WriteVFCmpF_" # mx); defvar ReadVFCmpV_MX = !cast("ReadVFCmpV_" # mx); defvar ReadVFCmpF_MX = !cast("ReadVFCmpF_" # mx); defm "" : VPseudoBinaryM_VF, Sched<[WriteVFCmpF_MX, ReadVFCmpV_MX, ReadVFCmpF_MX, ReadVMask]>; } } } multiclass VPseudoVCMPM_VX_VI { foreach m = MxList in { defvar mx = m.MX; defvar WriteVICmpX_MX = !cast("WriteVICmpX_" # mx); defvar WriteVICmpI_MX = !cast("WriteVICmpI_" # mx); defvar ReadVICmpV_MX = !cast("ReadVICmpV_" # mx); defvar ReadVICmpX_MX = !cast("ReadVICmpX_" # mx); defm "" : VPseudoBinaryM_VX, Sched<[WriteVICmpX_MX, ReadVICmpV_MX, ReadVICmpX_MX, ReadVMask]>; defm "" : VPseudoBinaryM_VI, Sched<[WriteVICmpI_MX, ReadVICmpV_MX, ReadVMask]>; } } multiclass VPseudoVRED_VS { foreach m = MxList in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVIRedV_From_MX_E = !cast("WriteVIRedV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicy, Sched<[WriteVIRedV_From_MX_E, ReadVIRedV, ReadVIRedV, ReadVIRedV, ReadVMask]>; } } } multiclass VPseudoVREDMINMAX_VS { foreach m = MxList in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVIRedMinMaxV_From_MX_E = !cast("WriteVIRedMinMaxV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicy, Sched<[WriteVIRedMinMaxV_From_MX_E, ReadVIRedV, ReadVIRedV, ReadVIRedV, ReadVMask]>; } } } multiclass VPseudoVWRED_VS { foreach m = MxListWRed in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVIWRedV_From_MX_E = !cast("WriteVIWRedV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicy, Sched<[WriteVIWRedV_From_MX_E, ReadVIWRedV, ReadVIWRedV, ReadVIWRedV, ReadVMask]>; } } } multiclass VPseudoVFRED_VS_RM { foreach m = MxListF in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVFRedV_From_MX_E = !cast("WriteVFRedV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicyRoundingMode, Sched<[WriteVFRedV_From_MX_E, ReadVFRedV, ReadVFRedV, ReadVFRedV, ReadVMask]>; } } } multiclass VPseudoVFREDMINMAX_VS { foreach m = MxListF in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVFRedMinMaxV_From_MX_E = !cast("WriteVFRedMinMaxV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicy, Sched<[WriteVFRedMinMaxV_From_MX_E, ReadVFRedV, ReadVFRedV, ReadVFRedV, ReadVMask]>; } } } multiclass VPseudoVFREDO_VS_RM { foreach m = MxListF in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVFRedOV_From_MX_E = !cast("WriteVFRedOV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicyRoundingMode, Sched<[WriteVFRedOV_From_MX_E, ReadVFRedOV, ReadVFRedOV, ReadVFRedOV, ReadVMask]>; } } } multiclass VPseudoVFWRED_VS_RM { foreach m = MxListFWRed in { defvar mx = m.MX; foreach e = SchedSEWSet.val in { defvar WriteVFWRedV_From_MX_E = !cast("WriteVFWRedV_From_" # mx # "_E" # e); defm _VS : VPseudoTernaryWithTailPolicyRoundingMode, Sched<[WriteVFWRedV_From_MX_E, ReadVFWRedV, ReadVFWRedV, ReadVFWRedV, ReadVMask]>; } } } multiclass VPseudoConversion { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoUnaryNoMask; def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMask, RISCVMaskedPseudo; } } multiclass VPseudoConversionRoundingMode { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoUnaryNoMaskRoundingMode; def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMaskRoundingMode, RISCVMaskedPseudo; } } multiclass VPseudoConversionRM { let VLMul = MInfo.value in { def "_" # MInfo.MX : VPseudoUnaryNoMask_FRM; def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMask_FRM, RISCVMaskedPseudo; } } multiclass VPseudoConversionNoExcept { let VLMul = MInfo.value in { def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMask_NoExcept; } } multiclass VPseudoVCVTI_V { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCvtFToIV_MX = !cast("WriteVFCvtFToIV_" # mx); defvar ReadVFCvtFToIV_MX = !cast("ReadVFCvtFToIV_" # mx); defm _V : VPseudoConversion, Sched<[WriteVFCvtFToIV_MX, ReadVFCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVCVTI_V_RM { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCvtFToIV_MX = !cast("WriteVFCvtFToIV_" # mx); defvar ReadVFCvtFToIV_MX = !cast("ReadVFCvtFToIV_" # mx); defm _V : VPseudoConversionRoundingMode, Sched<[WriteVFCvtFToIV_MX, ReadVFCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVCVTI_RM_V { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCvtFToIV_MX = !cast("WriteVFCvtFToIV_" # mx); defvar ReadVFCvtFToIV_MX = !cast("ReadVFCvtFToIV_" # mx); defm _V : VPseudoConversionRM, Sched<[WriteVFCvtFToIV_MX, ReadVFCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVFROUND_NOEXCEPT_V { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCvtFToIV_MX = !cast("WriteVFCvtFToIV_" # mx); defvar ReadVFCvtFToIV_MX = !cast("ReadVFCvtFToIV_" # mx); defm _V : VPseudoConversionNoExcept, Sched<[WriteVFCvtFToIV_MX, ReadVFCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVCVTF_V_RM { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCvtIToFV_MX = !cast("WriteVFCvtIToFV_" # mx); defvar ReadVFCvtIToFV_MX = !cast("ReadVFCvtIToFV_" # mx); defm _V : VPseudoConversionRoundingMode, Sched<[WriteVFCvtIToFV_MX, ReadVFCvtIToFV_MX, ReadVMask]>; } } multiclass VPseudoVCVTF_RM_V { foreach m = MxListF in { defvar mx = m.MX; defvar WriteVFCvtIToFV_MX = !cast("WriteVFCvtIToFV_" # mx); defvar ReadVFCvtIToFV_MX = !cast("ReadVFCvtIToFV_" # mx); defm _V : VPseudoConversionRM, Sched<[WriteVFCvtIToFV_MX, ReadVFCvtIToFV_MX, ReadVMask]>; } } multiclass VPseudoVWCVTI_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWCvtFToIV_MX = !cast("WriteVFWCvtFToIV_" # mx); defvar ReadVFWCvtFToIV_MX = !cast("ReadVFWCvtFToIV_" # mx); defm _V : VPseudoConversion, Sched<[WriteVFWCvtFToIV_MX, ReadVFWCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVWCVTI_V_RM { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWCvtFToIV_MX = !cast("WriteVFWCvtFToIV_" # mx); defvar ReadVFWCvtFToIV_MX = !cast("ReadVFWCvtFToIV_" # mx); defm _V : VPseudoConversionRoundingMode, Sched<[WriteVFWCvtFToIV_MX, ReadVFWCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVWCVTI_RM_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWCvtFToIV_MX = !cast("WriteVFWCvtFToIV_" # mx); defvar ReadVFWCvtFToIV_MX = !cast("ReadVFWCvtFToIV_" # mx); defm _V : VPseudoConversionRM, Sched<[WriteVFWCvtFToIV_MX, ReadVFWCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVWCVTF_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in { defvar mx = m.MX; defvar WriteVFWCvtIToFV_MX = !cast("WriteVFWCvtIToFV_" # mx); defvar ReadVFWCvtIToFV_MX = !cast("ReadVFWCvtIToFV_" # mx); defm _V : VPseudoConversion, Sched<[WriteVFWCvtIToFV_MX, ReadVFWCvtIToFV_MX, ReadVMask]>; } } multiclass VPseudoVWCVTD_V { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFWCvtFToFV_MX = !cast("WriteVFWCvtFToFV_" # mx); defvar ReadVFWCvtFToFV_MX = !cast("ReadVFWCvtFToFV_" # mx); defm _V : VPseudoConversion, Sched<[WriteVFWCvtFToFV_MX, ReadVFWCvtFToFV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTI_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in { defvar mx = m.MX; defvar WriteVFNCvtFToIV_MX = !cast("WriteVFNCvtFToIV_" # mx); defvar ReadVFNCvtFToIV_MX = !cast("ReadVFNCvtFToIV_" # mx); defm _W : VPseudoConversion, Sched<[WriteVFNCvtFToIV_MX, ReadVFNCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTI_W_RM { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in { defvar mx = m.MX; defvar WriteVFNCvtFToIV_MX = !cast("WriteVFNCvtFToIV_" # mx); defvar ReadVFNCvtFToIV_MX = !cast("ReadVFNCvtFToIV_" # mx); defm _W : VPseudoConversionRoundingMode, Sched<[WriteVFNCvtFToIV_MX, ReadVFNCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTI_RM_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListW in { defvar mx = m.MX; defvar WriteVFNCvtFToIV_MX = !cast("WriteVFNCvtFToIV_" # mx); defvar ReadVFNCvtFToIV_MX = !cast("ReadVFNCvtFToIV_" # mx); defm _W : VPseudoConversionRM, Sched<[WriteVFNCvtFToIV_MX, ReadVFNCvtFToIV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTF_W_RM { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFNCvtIToFV_MX = !cast("WriteVFNCvtIToFV_" # mx); defvar ReadVFNCvtIToFV_MX = !cast("ReadVFNCvtIToFV_" # mx); defm _W : VPseudoConversionRoundingMode, Sched<[WriteVFNCvtIToFV_MX, ReadVFNCvtIToFV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTF_RM_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFNCvtIToFV_MX = !cast("WriteVFNCvtIToFV_" # mx); defvar ReadVFNCvtIToFV_MX = !cast("ReadVFNCvtIToFV_" # mx); defm _W : VPseudoConversionRM, Sched<[WriteVFNCvtIToFV_MX, ReadVFNCvtIToFV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTD_W { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFNCvtFToFV_MX = !cast("WriteVFNCvtFToFV_" # mx); defvar ReadVFNCvtFToFV_MX = !cast("ReadVFNCvtFToFV_" # mx); defm _W : VPseudoConversion, Sched<[WriteVFNCvtFToFV_MX, ReadVFNCvtFToFV_MX, ReadVMask]>; } } multiclass VPseudoVNCVTD_W_RM { defvar constraint = "@earlyclobber $rd"; foreach m = MxListFW in { defvar mx = m.MX; defvar WriteVFNCvtFToFV_MX = !cast("WriteVFNCvtFToFV_" # mx); defvar ReadVFNCvtFToFV_MX = !cast("ReadVFNCvtFToFV_" # mx); defm _W : VPseudoConversionRoundingMode, Sched<[WriteVFNCvtFToFV_MX, ReadVFNCvtFToFV_MX, ReadVMask]>; } } multiclass VPseudoUSSegLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoUSSegLoadNoMask, VLSEGSched; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSSegLoadMask, VLSEGSched; } } } } } multiclass VPseudoUSSegLoadFF { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "FF_V_" # LInfo : VPseudoUSSegLoadFFNoMask, VLSEGFFSched; def nf # "E" # eew # "FF_V_" # LInfo # "_MASK" : VPseudoUSSegLoadFFMask, VLSEGFFSched; } } } } } multiclass VPseudoSSegLoad { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoSSegLoadNoMask, VLSSEGSched; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSSegLoadMask, VLSSEGSched; } } } } } multiclass VPseudoISegLoad { foreach idxEEW = EEWList in { foreach dataEEW = EEWList in { foreach dataEMUL = MxSet.m in { defvar dataEMULOctuple = dataEMUL.octuple; // Calculate emul = eew * lmul / sew defvar idxEMULOctuple = !srl(!mul(idxEEW, dataEMULOctuple), !logtwo(dataEEW)); if !and(!ge(idxEMULOctuple, 1), !le(idxEMULOctuple, 64)) then { defvar DataLInfo = dataEMUL.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idxEMUL = !cast("V_" # IdxLInfo); defvar DataVreg = dataEMUL.vrclass; defvar IdxVreg = idxEMUL.vrclass; defvar Order = !if(Ordered, "O", "U"); let VLMul = dataEMUL.value in { foreach nf = NFSet.L in { defvar Vreg = SegRegClass.RC; def nf # "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo : VPseudoISegLoadNoMask, VLXSEGSched; def nf # "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo # "_MASK" : VPseudoISegLoadMask, VLXSEGSched; } } } } } } } multiclass VPseudoUSSegStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoUSSegStoreNoMask, VSSEGSched; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSSegStoreMask, VSSEGSched; } } } } } multiclass VPseudoSSegStore { foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoSSegStoreNoMask, VSSSEGSched; def nf # "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSSegStoreMask, VSSSEGSched; } } } } } multiclass VPseudoISegStore { foreach idxEEW = EEWList in { foreach dataEEW = EEWList in { foreach dataEMUL = MxSet.m in { defvar dataEMULOctuple = dataEMUL.octuple; // Calculate emul = eew * lmul / sew defvar idxEMULOctuple = !srl(!mul(idxEEW, dataEMULOctuple), !logtwo(dataEEW)); if !and(!ge(idxEMULOctuple, 1), !le(idxEMULOctuple, 64)) then { defvar DataLInfo = dataEMUL.MX; defvar IdxLInfo = octuple_to_str.ret; defvar idxEMUL = !cast("V_" # IdxLInfo); defvar DataVreg = dataEMUL.vrclass; defvar IdxVreg = idxEMUL.vrclass; defvar Order = !if(Ordered, "O", "U"); let VLMul = dataEMUL.value in { foreach nf = NFSet.L in { defvar Vreg = SegRegClass.RC; def nf # "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo : VPseudoISegStoreNoMask, VSXSEGSched; def nf # "EI" # idxEEW # "_V_" # IdxLInfo # "_" # DataLInfo # "_MASK" : VPseudoISegStoreMask, VSXSEGSched; } } } } } } } //===----------------------------------------------------------------------===// // Helpers to define the intrinsic patterns. //===----------------------------------------------------------------------===// class VPatUnaryNoMask : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), VLOpFrag)), (!cast( !if(isSEWAware, inst#"_"#kind#"_"#vlmul.MX#"_E"#!shl(1, log2sew), inst#"_"#kind#"_"#vlmul.MX)) (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), GPR:$vl, log2sew, TU_MU)>; class VPatUnaryNoMaskRoundingMode : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (XLenVT timm:$round), VLOpFrag)), (!cast( !if(isSEWAware, inst#"_"#kind#"_"#vlmul.MX#"_E"#!shl(1, log2sew), inst#"_"#kind#"_"#vlmul.MX)) (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (XLenVT timm:$round), GPR:$vl, log2sew, TU_MU)>; 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, (XLenVT timm:$policy))), (!cast( !if(isSEWAware, inst#"_"#kind#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK", inst#"_"#kind#"_"#vlmul.MX#"_MASK")) (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), GPR:$vl, log2sew, (XLenVT timm:$policy))>; class VPatUnaryMaskRoundingMode : Pat<(result_type (!cast(intrinsic_name#"_mask") (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), (XLenVT timm:$round), VLOpFrag, (XLenVT timm:$policy))), (!cast( !if(isSEWAware, inst#"_"#kind#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK", inst#"_"#kind#"_"#vlmul.MX#"_MASK")) (result_type result_reg_class:$merge), (op2_type op2_reg_class:$rs2), (mask_type V0), (XLenVT timm:$round), GPR:$vl, log2sew, (XLenVT timm:$policy))>; class VPatMaskUnaryNoMask : Pat<(mti.Mask (!cast(intrinsic_name) (mti.Mask VR:$rs2), VLOpFrag)), (!cast(inst#"_M_"#mti.BX) (mti.Mask (IMPLICIT_DEF)), (mti.Mask VR:$rs2), GPR:$vl, mti.Log2SEW, TU_MU)>; 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, TU_MU)>; 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#"_E"#!shl(1, log2sew)) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (mask_type VR:$rs2), GPR:$vl, log2sew)>; class VPatBinaryM : 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)>; class VPatBinaryNoMaskTU : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), GPR:$vl, sew, TU_MU)>; class VPatBinaryNoMaskRoundingMode : Pat<(result_type (!cast(intrinsic_name) (result_type (undef)), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), VLOpFrag)), (!cast(inst) (result_type (IMPLICIT_DEF)), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), GPR:$vl, sew, TA_MA)>; class VPatBinaryNoMaskTURoundingMode : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), VLOpFrag)), (!cast(inst) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), GPR:$vl, sew, TU_MU)>; // 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))>; class VPatBinaryMaskTARoundingMode : 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), (XLenVT timm:$round), 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), (XLenVT timm:$round), 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 (undef)), (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, TAIL_AGNOSTIC)>; class VPatTiedBinaryNoMaskRoundingMode : Pat<(result_type (!cast(intrinsic_name) (result_type (undef)), (result_type result_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), VLOpFrag)), (!cast(inst#"_TIED") (result_type result_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), GPR:$vl, sew, TAIL_AGNOSTIC)>; class VPatTiedBinaryNoMaskTU : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$merge), (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), VLOpFrag)), (!cast(inst#"_TIED") (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), GPR:$vl, sew, TU_MU)>; class VPatTiedBinaryNoMaskTURoundingMode : Pat<(result_type (!cast(intrinsic_name) (result_type result_reg_class:$merge), (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), (XLenVT timm:$round), VLOpFrag)), (!cast(inst#"_TIED") (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), (XLenVT timm:$round), GPR:$vl, sew, TU_MU)>; 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 VPatTiedBinaryMaskRoundingMode : 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), (XLenVT timm:$round), VLOpFrag, (XLenVT timm:$policy))), (!cast(inst#"_MASK_TIED") (result_type result_reg_class:$merge), (op2_type op2_kind:$rs2), (mask_type V0), (XLenVT timm:$round), 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 VPatTernaryNoMaskTA : 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#"_E"#!shl(1, log2sew)) result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, GPR:$vl, log2sew, TAIL_AGNOSTIC)>; class VPatTernaryNoMaskTARoundingMode : Pat<(result_type (!cast(intrinsic) (result_type result_reg_class:$rs3), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX#"_E"#!shl(1, log2sew)) result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, (XLenVT timm:$round), GPR:$vl, log2sew, TAIL_AGNOSTIC)>; 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, (XLenVT timm:$policy))), (!cast(inst#"_"#kind#"_"#vlmul.MX) result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, GPR:$vl, sew, (XLenVT timm:$policy))>; class VPatTernaryNoMaskWithPolicyRoundingMode : Pat<(result_type (!cast(intrinsic) (result_type result_reg_class:$rs3), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (XLenVT timm:$round), VLOpFrag, (XLenVT timm:$policy))), (!cast(inst#"_"#kind#"_"#vlmul.MX) result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, (XLenVT timm:$round), GPR:$vl, sew, (XLenVT timm:$policy))>; 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)>; class VPatTernaryMaskPolicy : 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, (XLenVT timm:$policy))), (!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, (XLenVT timm:$policy))>; class VPatTernaryMaskPolicyRoundingMode : 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), (XLenVT timm:$round), VLOpFrag, (XLenVT timm:$policy))), (!cast(inst#"_"#kind#"_"#vlmul.MX # "_MASK") result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, (mask_type V0), (XLenVT timm:$round), GPR:$vl, sew, (XLenVT timm:$policy))>; class VPatTernaryMaskTA : 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#"_E"#!shl(1, log2sew)# "_MASK") result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, (mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>; class VPatTernaryMaskTARoundingMode : 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), (XLenVT timm:$round), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX#"_E"#!shl(1, log2sew)# "_MASK") result_reg_class:$rs3, (op1_type op1_reg_class:$rs1), op2_kind:$rs2, (mask_type V0), (XLenVT timm:$round), GPR:$vl, log2sew, TAIL_AGNOSTIC)>; 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 { let Predicates = GetVTypePredicates.Predicates in def : VPatUnaryAnyMask; } } multiclass VPatUnaryM_M { foreach mti = AllMasks in { def : VPatMaskUnaryNoMask; def : VPatMaskUnaryMask; } } multiclass VPatUnaryV_M { foreach vti = AllIntegerVectors in { let Predicates = GetVTypePredicates.Predicates in { def : VPatUnaryNoMask; def : VPatUnaryMask; } } } multiclass VPatUnaryV_VF fractionList> { foreach vtiTofti = fractionList in { defvar vti = vtiTofti.Vti; defvar fti = vtiTofti.Fti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in { def : VPatUnaryNoMask; def : VPatUnaryMask; } } } multiclass VPatUnaryV_V vtilist, bit isSEWAware = 0> { foreach vti = vtilist in { let Predicates = GetVTypePredicates.Predicates in { def : VPatUnaryNoMask; def : VPatUnaryMask; } } } multiclass VPatUnaryV_V_RM vtilist, bit isSEWAware = 0> { foreach vti = vtilist in { let Predicates = GetVTypePredicates.Predicates in { def : VPatUnaryNoMaskRoundingMode; def : VPatUnaryMaskRoundingMode; } } } multiclass VPatNullaryV { foreach vti = AllIntegerVectors in { let Predicates = GetVTypePredicates.Predicates in { def : Pat<(vti.Vector (!cast(intrinsic) (vti.Vector vti.RegClass:$merge), VLOpFrag)), (!cast(instruction#"_V_" # vti.LMul.MX) vti.RegClass:$merge, GPR:$vl, vti.Log2SEW, TU_MU)>; def : Pat<(vti.Vector (!cast(intrinsic # "_mask") (vti.Vector vti.RegClass:$merge), (vti.Mask V0), VLOpFrag, (XLenVT timm:$policy))), (!cast(instruction#"_V_" # vti.LMul.MX # "_MASK") vti.RegClass:$merge, (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>; } } } multiclass VPatNullaryM { foreach mti = AllMasks in def : Pat<(mti.Mask (!cast(intrinsic) VLOpFrag)), (!cast(inst#"_M_"#mti.BX) GPR:$vl, mti.Log2SEW)>; } multiclass VPatBinaryM { def : VPatBinaryM; def : VPatBinaryMask; } multiclass VPatBinary { def : VPatBinaryNoMaskTU; def : VPatBinaryMaskTA; } multiclass VPatBinaryRoundingMode { def : VPatBinaryNoMaskRoundingMode; def : VPatBinaryNoMaskTURoundingMode; def : VPatBinaryMaskTARoundingMode; } multiclass VPatBinarySwapped { def : VPatBinaryNoMaskSwapped; def : VPatBinaryMaskSwapped; } multiclass VPatBinaryCarryInTAIL { def : Pat<(result_type (!cast(intrinsic) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), VLOpFrag)), (!cast(inst#"_"#kind#"_"#vlmul.MX) (result_type result_reg_class:$merge), (op1_type op1_reg_class:$rs1), (op2_type op2_kind:$rs2), (mask_type V0), GPR:$vl, sew)>; } 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 VPatConversionTA { def : VPatUnaryNoMask; def : VPatUnaryMask; } multiclass VPatConversionTARoundingMode { def : VPatUnaryNoMaskRoundingMode; def : VPatUnaryMaskRoundingMode; } multiclass VPatBinaryV_VV vtilist, bit isSEWAware = 0> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinary; } multiclass VPatBinaryV_VV_RM vtilist, bit isSEWAware = 0> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryRoundingMode; } multiclass VPatBinaryV_VV_INT vtilist> { foreach vti = vtilist in { defvar ivti = GetIntVTypeInfo.Vti; let Predicates = GetVTypePredicates.Predicates in defm : VPatBinary; } } 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 # "_E" # vti.SEW # "_" # emul_str; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } } multiclass VPatBinaryV_VX vtilist, bit isSEWAware = 0> { foreach vti = vtilist in { defvar kind = "V"#vti.ScalarSuffix; let Predicates = GetVTypePredicates.Predicates in defm : VPatBinary; } } multiclass VPatBinaryV_VX_RM vtilist, bit isSEWAware = 0> { foreach vti = vtilist in { defvar kind = "V"#vti.ScalarSuffix; let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryV_VX_INT vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinary; } multiclass VPatBinaryV_VI vtilist, Operand imm_type> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinary; } multiclass VPatBinaryV_VI_RM vtilist, Operand imm_type> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryRoundingMode; } multiclass VPatBinaryM_MM { foreach mti = AllMasks in let Predicates = [HasVInstructions] in def : VPatBinaryM; } multiclass VPatBinaryW_VV vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } multiclass VPatBinaryW_VV_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryW_VX vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "V"#Vti.ScalarSuffix; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } multiclass VPatBinaryW_VX_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "V"#Vti.ScalarSuffix; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryW_WV vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in { def : VPatTiedBinaryNoMask; def : VPatBinaryNoMaskTU; let AddedComplexity = 1 in { def : VPatTiedBinaryNoMaskTU; def : VPatTiedBinaryMask; } def : VPatBinaryMaskTA; } } } multiclass VPatBinaryW_WV_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in { def : VPatTiedBinaryNoMaskRoundingMode; def : VPatBinaryNoMaskTURoundingMode; let AddedComplexity = 1 in { def : VPatTiedBinaryNoMaskTURoundingMode; def : VPatTiedBinaryMaskRoundingMode; } def : VPatBinaryMaskTARoundingMode; } } } multiclass VPatBinaryW_WX vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "W"#Vti.ScalarSuffix; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } multiclass VPatBinaryW_WX_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "W"#Vti.ScalarSuffix; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryV_WV vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } multiclass VPatBinaryV_WV_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryV_WX vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "W"#Vti.ScalarSuffix; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } multiclass VPatBinaryV_WX_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; defvar kind = "W"#Vti.ScalarSuffix; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryV_WI vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinary; } } multiclass VPatBinaryV_WI_RM vtilist> { foreach VtiToWti = vtilist in { defvar Vti = VtiToWti.Vti; defvar Wti = VtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatBinaryRoundingMode; } } multiclass VPatBinaryV_VM vtilist = AllIntegerVectors> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryCarryIn; } multiclass VPatBinaryV_XM vtilist = AllIntegerVectors> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryCarryIn; } multiclass VPatBinaryV_IM { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryCarryIn; } multiclass VPatBinaryV_VM_TAIL { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryCarryInTAIL; } multiclass VPatBinaryV_XM_TAIL { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryCarryInTAIL; } multiclass VPatBinaryV_IM_TAIL { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryCarryInTAIL; } multiclass VPatBinaryV_V { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryMaskOut; } multiclass VPatBinaryV_X { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryMaskOut; } multiclass VPatBinaryV_I { foreach vti = AllIntegerVectors in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryMaskOut; } multiclass VPatBinaryM_VV vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryM; } multiclass VPatBinarySwappedM_VV vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinarySwapped; } multiclass VPatBinaryM_VX vtilist> { foreach vti = vtilist in { defvar kind = "V"#vti.ScalarSuffix; let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryM; } } multiclass VPatBinaryM_VI vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatBinaryM; } multiclass VPatBinaryV_VV_VX_VI vtilist, Operand ImmType = simm5> : VPatBinaryV_VV, VPatBinaryV_VX, VPatBinaryV_VI; multiclass VPatBinaryV_VV_VX_VI_RM vtilist, Operand ImmType = simm5> : VPatBinaryV_VV_RM, VPatBinaryV_VX_RM, VPatBinaryV_VI_RM; multiclass VPatBinaryV_VV_VX vtilist, bit isSEWAware = 0> : VPatBinaryV_VV, VPatBinaryV_VX; multiclass VPatBinaryV_VV_VX_RM vtilist, bit isSEWAware = 0> : VPatBinaryV_VV_RM, VPatBinaryV_VX_RM; multiclass VPatBinaryV_VX_VI vtilist> : VPatBinaryV_VX, VPatBinaryV_VI; multiclass VPatBinaryW_VV_VX vtilist> : VPatBinaryW_VV, VPatBinaryW_VX; multiclass VPatBinaryW_VV_VX_RM vtilist> : VPatBinaryW_VV_RM, VPatBinaryW_VX_RM; multiclass VPatBinaryW_WV_WX vtilist> : VPatBinaryW_WV, VPatBinaryW_WX; multiclass VPatBinaryW_WV_WX_RM vtilist> : VPatBinaryW_WV_RM, VPatBinaryW_WX_RM; multiclass VPatBinaryV_WV_WX_WI vtilist> : VPatBinaryV_WV, VPatBinaryV_WX, VPatBinaryV_WI; multiclass VPatBinaryV_WV_WX_WI_RM vtilist> : VPatBinaryV_WV_RM, VPatBinaryV_WX_RM, VPatBinaryV_WI_RM; multiclass VPatBinaryV_VM_XM_IM : VPatBinaryV_VM_TAIL, VPatBinaryV_XM_TAIL, VPatBinaryV_IM_TAIL; 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_TAIL, VPatBinaryV_XM_TAIL; multiclass VPatBinaryM_VM_XM : VPatBinaryV_VM, VPatBinaryV_XM; multiclass VPatBinaryM_V_X : VPatBinaryV_V, VPatBinaryV_X; multiclass VPatTernary { def : VPatTernaryNoMask; def : VPatTernaryMask; } multiclass VPatTernaryNoMaskNoPolicy { def : VPatTernaryNoMask; def : VPatTernaryMaskPolicy; } multiclass VPatTernaryWithPolicy { def : VPatTernaryNoMaskWithPolicy; def : VPatTernaryMaskPolicy; } multiclass VPatTernaryWithPolicyRoundingMode { def : VPatTernaryNoMaskWithPolicyRoundingMode; def : VPatTernaryMaskPolicyRoundingMode; } multiclass VPatTernaryTA { def : VPatTernaryNoMaskTA; def : VPatTernaryMaskTA; } multiclass VPatTernaryTARoundingMode { def : VPatTernaryNoMaskTARoundingMode; def : VPatTernaryMaskTARoundingMode; } multiclass VPatTernaryV_VV_AAXA vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryWithPolicy; } multiclass VPatTernaryV_VV_AAXA_RM vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryWithPolicyRoundingMode; } multiclass VPatTernaryV_VX vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryWithPolicy; } multiclass VPatTernaryV_VX_AAXA vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryWithPolicy; } multiclass VPatTernaryV_VX_AAXA_RM vtilist> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryWithPolicyRoundingMode; } multiclass VPatTernaryV_VI vtilist, Operand Imm_type> { foreach vti = vtilist in let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryWithPolicy; } multiclass VPatTernaryW_VV vtilist> { foreach vtiToWti = vtilist in { defvar vti = vtiToWti.Vti; defvar wti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatTernaryWithPolicy; } } multiclass VPatTernaryW_VV_RM vtilist> { foreach vtiToWti = vtilist in { defvar vti = vtiToWti.Vti; defvar wti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatTernaryWithPolicyRoundingMode; } } multiclass VPatTernaryW_VX vtilist> { foreach vtiToWti = vtilist in { defvar vti = vtiToWti.Vti; defvar wti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatTernaryWithPolicy; } } multiclass VPatTernaryW_VX_RM vtilist> { foreach vtiToWti = vtilist in { defvar vti = vtiToWti.Vti; defvar wti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatTernaryWithPolicyRoundingMode; } } multiclass VPatTernaryV_VV_VX_AAXA vtilist> : VPatTernaryV_VV_AAXA, VPatTernaryV_VX_AAXA; multiclass VPatTernaryV_VV_VX_AAXA_RM vtilist> : VPatTernaryV_VV_AAXA_RM, VPatTernaryV_VX_AAXA_RM; 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 VPatTernaryW_VV_VX_RM vtilist> : VPatTernaryW_VV_RM, VPatTernaryW_VX_RM; 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"); let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryTA; } foreach gvti = !if(IsFloat, GroupFloatVectors, GroupIntegerVectors) in { let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryTA; } } multiclass VPatReductionV_VS_RM { foreach vti = !if(IsFloat, NoGroupFloatVectors, NoGroupIntegerVectors) in { defvar vectorM1 = !cast(!if(IsFloat, "VF", "VI") # vti.SEW # "M1"); let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryTARoundingMode; } foreach gvti = !if(IsFloat, GroupFloatVectors, GroupIntegerVectors) in { let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryTARoundingMode; } } 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"); let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryTA; } } } multiclass VPatReductionW_VS_RM { 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"); let Predicates = GetVTypePredicates.Predicates in defm : VPatTernaryTARoundingMode; } } } multiclass VPatConversionVI_VF { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTA; } } multiclass VPatConversionVI_VF_RM { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTARoundingMode; } } multiclass VPatConversionVF_VI_RM { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTARoundingMode; } } multiclass VPatConversionWI_VF { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTA; } } multiclass VPatConversionWI_VF_RM { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTARoundingMode; } } multiclass VPatConversionWF_VI { foreach vtiToWti = AllWidenableIntToFloatVectors in { defvar vti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTA; } } multiclass VPatConversionWF_VF { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTA; } } multiclass VPatConversionVI_WF { foreach vtiToWti = AllWidenableIntToFloatVectors in { defvar vti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTA; } } multiclass VPatConversionVI_WF_RM { foreach vtiToWti = AllWidenableIntToFloatVectors in { defvar vti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTARoundingMode; } } multiclass VPatConversionVF_WI_RM { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTARoundingMode; } } multiclass VPatConversionVF_WF { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTA; } } multiclass VPatConversionVF_WF_RM { foreach fvtiToFWti = AllWidenableFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; let Predicates = !listconcat(GetVTypePredicates.Predicates, GetVTypePredicates.Predicates) in defm : VPatConversionTARoundingMode; } } multiclass VPatCompare_VI { foreach vti = AllIntegerVectors in { defvar Intr = !cast(intrinsic); defvar Pseudo = !cast(inst#"_VI_"#vti.LMul.MX); let Predicates = GetVTypePredicates.Predicates in 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"); let Predicates = GetVTypePredicates.Predicates in 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, isCodeGenOnly = 1 in { def PseudoReadVLENB : Pseudo<(outs GPR:$rd), (ins), [(set GPR:$rd, (riscv_read_vlenb))]>, PseudoInstExpansion<(CSRRS GPR:$rd, SysRegVLENB.Encoding, X0)>, Sched<[WriteRdVLENB]>; } let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1, Uses = [VL] in def PseudoReadVL : Pseudo<(outs GPR:$rd), (ins), []>, PseudoInstExpansion<(CSRRS GPR:$rd, SysRegVL.Encoding, X0)>; 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), []>; } 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), []>; } } } /// Empty pseudo for RISCVInitUndefPass let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Size = 0, isCodeGenOnly = 1 in { def PseudoRVVInitUndefM1 : Pseudo<(outs VR:$vd), (ins), [], "">; def PseudoRVVInitUndefM2 : Pseudo<(outs VRM2:$vd), (ins), [], "">; def PseudoRVVInitUndefM4 : Pseudo<(outs VRM4:$vd), (ins), [], "">; def PseudoRVVInitUndefM8 : Pseudo<(outs VRM8:$vd), (ins), [], "">; } //===----------------------------------------------------------------------===// // 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), []>, Sched<[WriteVSETVLI, ReadVSETVLI]>; def PseudoVSETVLIX0 : Pseudo<(outs GPR:$rd), (ins GPRX0:$rs1, VTypeIOp11:$vtypei), []>, Sched<[WriteVSETVLI, ReadVSETVLI]>; def PseudoVSETIVLI : Pseudo<(outs GPR:$rd), (ins uimm5:$rs1, VTypeIOp10:$vtypei), []>, Sched<[WriteVSETIVLI]>; } //===----------------------------------------------------------------------===// // 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; defm PseudoVSM : VPseudoStoreMask; //===----------------------------------------------------------------------===// // 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 : VPseudoUSSegLoadFF; } //===----------------------------------------------------------------------===// // 11. Vector Integer Arithmetic Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 11.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. let Predicates = GetVTypePredicates.Predicates in { def : Pat<(vti.Vector (int_riscv_vrsub (vti.Vector vti.RegClass:$merge), (vti.Vector vti.RegClass:$rs2), (vti.Vector vti.RegClass:$rs1), VLOpFrag)), (!cast("PseudoVSUB_VV_"#vti.LMul.MX) vti.RegClass:$merge, vti.RegClass:$rs1, vti.RegClass:$rs2, GPR:$vl, vti.Log2SEW, TU_MU)>; 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 (undef)), (vti.Vector vti.RegClass:$rs1), (vti.Scalar simm5_plus1:$rs2), VLOpFrag)), (!cast("PseudoVADD_VI_"#vti.LMul.MX) (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs1, (NegImm simm5_plus1:$rs2), GPR:$vl, vti.Log2SEW, TU_MU)>; 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))>; } } //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.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">; //===----------------------------------------------------------------------===// // 11.5. Vector Bitwise Logical Instructions //===----------------------------------------------------------------------===// defm PseudoVAND : VPseudoVALU_VV_VX_VI; defm PseudoVOR : VPseudoVALU_VV_VX_VI; defm PseudoVXOR : VPseudoVALU_VV_VX_VI; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.7. Vector Narrowing Integer Right Shift Instructions //===----------------------------------------------------------------------===// defm PseudoVNSRL : VPseudoVNSHT_WV_WX_WI; defm PseudoVNSRA : VPseudoVNSHT_WV_WX_WI; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.12. Vector Widening Integer Multiply Instructions //===----------------------------------------------------------------------===// defm PseudoVWMUL : VPseudoVWMUL_VV_VX; defm PseudoVWMULU : VPseudoVWMUL_VV_VX; defm PseudoVWMULSU : VPseudoVWMUL_VV_VX; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.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; //===----------------------------------------------------------------------===// // 11.15. Vector Integer Merge Instructions //===----------------------------------------------------------------------===// defm PseudoVMERGE : VPseudoVMRG_VM_XM_IM; //===----------------------------------------------------------------------===// // 11.16. Vector Integer Move Instructions //===----------------------------------------------------------------------===// defm PseudoVMV_V : VPseudoUnaryVMV_V_X_I; //===----------------------------------------------------------------------===// // 12. Vector Fixed-Point Arithmetic Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 12.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; } //===----------------------------------------------------------------------===// // 12.2. Vector Single-Width Averaging Add and Subtract //===----------------------------------------------------------------------===// defm PseudoVAADDU : VPseudoVAALU_VV_VX_RM; defm PseudoVAADD : VPseudoVAALU_VV_VX_RM; defm PseudoVASUBU : VPseudoVAALU_VV_VX_RM; defm PseudoVASUB : VPseudoVAALU_VV_VX_RM; //===----------------------------------------------------------------------===// // 12.3. Vector Single-Width Fractional Multiply with Rounding and Saturation //===----------------------------------------------------------------------===// let Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVSMUL : VPseudoVSMUL_VV_VX_RM; } //===----------------------------------------------------------------------===// // 12.4. Vector Single-Width Scaling Shift Instructions //===----------------------------------------------------------------------===// defm PseudoVSSRL : VPseudoVSSHT_VV_VX_VI_RM; defm PseudoVSSRA : VPseudoVSSHT_VV_VX_VI_RM; //===----------------------------------------------------------------------===// // 12.5. Vector Narrowing Fixed-Point Clip Instructions //===----------------------------------------------------------------------===// let Defs = [VXSAT], hasSideEffects = 1 in { defm PseudoVNCLIP : VPseudoVNCLP_WV_WX_WI_RM; defm PseudoVNCLIPU : VPseudoVNCLP_WV_WX_WI_RM; } } // Predicates = [HasVInstructions] //===----------------------------------------------------------------------===// // 13. Vector Floating-Point Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructionsAnyF] in { //===----------------------------------------------------------------------===// // 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasPostISelHook = 1 in { defm PseudoVFADD : VPseudoVALU_VV_VF_RM; defm PseudoVFSUB : VPseudoVALU_VV_VF_RM; defm PseudoVFRSUB : VPseudoVALU_VF_RM; } //===----------------------------------------------------------------------===// // 13.3. Vector Widening Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFWADD : VPseudoVFWALU_VV_VF_RM; defm PseudoVFWSUB : VPseudoVFWALU_VV_VF_RM; defm PseudoVFWADD : VPseudoVFWALU_WV_WF_RM; defm PseudoVFWSUB : VPseudoVFWALU_WV_WF_RM; } //===----------------------------------------------------------------------===// // 13.4. Vector Single-Width Floating-Point Multiply/Divide Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFMUL : VPseudoVFMUL_VV_VF_RM; defm PseudoVFDIV : VPseudoVFDIV_VV_VF_RM; defm PseudoVFRDIV : VPseudoVFRDIV_VF_RM; } //===----------------------------------------------------------------------===// // 13.5. Vector Widening Floating-Point Multiply //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0 in { defm PseudoVFWMUL : VPseudoVWMUL_VV_VF_RM; } //===----------------------------------------------------------------------===// // 13.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFMACC : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFNMACC : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFMSAC : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFNMSAC : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFMADD : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFNMADD : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFMSUB : VPseudoVMAC_VV_VF_AAXA_RM; defm PseudoVFNMSUB : VPseudoVMAC_VV_VF_AAXA_RM; } //===----------------------------------------------------------------------===// // 13.7. Vector Widening Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFWMACC : VPseudoVWMAC_VV_VF_RM; defm PseudoVFWNMACC : VPseudoVWMAC_VV_VF_RM; defm PseudoVFWMSAC : VPseudoVWMAC_VV_VF_RM; defm PseudoVFWNMSAC : VPseudoVWMAC_VV_VF_RM; } //===----------------------------------------------------------------------===// // 13.8. Vector Floating-Point Square-Root Instruction //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0 in defm PseudoVFSQRT : VPseudoVSQR_V_RM; //===----------------------------------------------------------------------===// // 13.9. Vector Floating-Point Reciprocal Square-Root Estimate Instruction //===----------------------------------------------------------------------===// let mayRaiseFPException = true in defm PseudoVFRSQRT7 : VPseudoVRCP_V; //===----------------------------------------------------------------------===// // 13.10. Vector Floating-Point Reciprocal Estimate Instruction //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0 in defm PseudoVFREC7 : VPseudoVRCP_V_RM; //===----------------------------------------------------------------------===// // 13.11. Vector Floating-Point Min/Max Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true in { defm PseudoVFMIN : VPseudoVMAX_VV_VF; defm PseudoVFMAX : VPseudoVMAX_VV_VF; } //===----------------------------------------------------------------------===// // 13.12. Vector Floating-Point Sign-Injection Instructions //===----------------------------------------------------------------------===// defm PseudoVFSGNJ : VPseudoVSGNJ_VV_VF; defm PseudoVFSGNJN : VPseudoVSGNJ_VV_VF; defm PseudoVFSGNJX : VPseudoVSGNJ_VV_VF; //===----------------------------------------------------------------------===// // 13.13. Vector Floating-Point Compare Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true in { 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; } //===----------------------------------------------------------------------===// // 13.14. Vector Floating-Point Classify Instruction //===----------------------------------------------------------------------===// defm PseudoVFCLASS : VPseudoVCLS_V; //===----------------------------------------------------------------------===// // 13.15. Vector Floating-Point Merge Instruction //===----------------------------------------------------------------------===// defm PseudoVFMERGE : VPseudoVMRG_FM; //===----------------------------------------------------------------------===// // 13.16. Vector Floating-Point Move Instruction //===----------------------------------------------------------------------===// defm PseudoVFMV_V : VPseudoVMV_F; //===----------------------------------------------------------------------===// // 13.17. Single-Width Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true in { let hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFCVT_XU_F : VPseudoVCVTI_V_RM; defm PseudoVFCVT_X_F : VPseudoVCVTI_V_RM; } defm PseudoVFCVT_RM_XU_F : VPseudoVCVTI_RM_V; defm PseudoVFCVT_RM_X_F : VPseudoVCVTI_RM_V; defm PseudoVFCVT_RTZ_XU_F : VPseudoVCVTI_V; defm PseudoVFCVT_RTZ_X_F : VPseudoVCVTI_V; defm PseudoVFROUND_NOEXCEPT : VPseudoVFROUND_NOEXCEPT_V; let hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFCVT_F_XU : VPseudoVCVTF_V_RM; defm PseudoVFCVT_F_X : VPseudoVCVTF_V_RM; } defm PseudoVFCVT_RM_F_XU : VPseudoVCVTF_RM_V; defm PseudoVFCVT_RM_F_X : VPseudoVCVTF_RM_V; } // mayRaiseFPException = true //===----------------------------------------------------------------------===// // 13.18. Widening Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true in { let hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFWCVT_XU_F : VPseudoVWCVTI_V_RM; defm PseudoVFWCVT_X_F : VPseudoVWCVTI_V_RM; } defm PseudoVFWCVT_RM_XU_F : VPseudoVWCVTI_RM_V; defm PseudoVFWCVT_RM_X_F : VPseudoVWCVTI_RM_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; } // mayRaiseFPException = true //===----------------------------------------------------------------------===// // 13.19. Narrowing Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true in { let hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFNCVT_XU_F : VPseudoVNCVTI_W_RM; defm PseudoVFNCVT_X_F : VPseudoVNCVTI_W_RM; } defm PseudoVFNCVT_RM_XU_F : VPseudoVNCVTI_RM_W; defm PseudoVFNCVT_RM_X_F : VPseudoVNCVTI_RM_W; defm PseudoVFNCVT_RTZ_XU_F : VPseudoVNCVTI_W; defm PseudoVFNCVT_RTZ_X_F : VPseudoVNCVTI_W; let hasSideEffects = 0, hasPostISelHook = 1 in { defm PseudoVFNCVT_F_XU : VPseudoVNCVTF_W_RM; defm PseudoVFNCVT_F_X : VPseudoVNCVTF_W_RM; } defm PseudoVFNCVT_RM_F_XU : VPseudoVNCVTF_RM_W; defm PseudoVFNCVT_RM_F_X : VPseudoVNCVTF_RM_W; let hasSideEffects = 0, hasPostISelHook = 1 in defm PseudoVFNCVT_F_F : VPseudoVNCVTD_W_RM; defm PseudoVFNCVT_ROD_F_F : VPseudoVNCVTD_W; } // mayRaiseFPException = true } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 14. Vector Reduction Operations //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { //===----------------------------------------------------------------------===// // 14.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 : VPseudoVREDMINMAX_VS; defm PseudoVREDMIN : VPseudoVREDMINMAX_VS; defm PseudoVREDMAXU : VPseudoVREDMINMAX_VS; defm PseudoVREDMAX : VPseudoVREDMINMAX_VS; //===----------------------------------------------------------------------===// // 14.2. Vector Widening Integer Reduction Instructions //===----------------------------------------------------------------------===// let IsRVVWideningReduction = 1 in { defm PseudoVWREDSUMU : VPseudoVWRED_VS; defm PseudoVWREDSUM : VPseudoVWRED_VS; } } // Predicates = [HasVInstructions] let Predicates = [HasVInstructionsAnyF] in { //===----------------------------------------------------------------------===// // 14.3. Vector Single-Width Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// let mayRaiseFPException = true, hasSideEffects = 0 in { defm PseudoVFREDOSUM : VPseudoVFREDO_VS_RM; defm PseudoVFREDUSUM : VPseudoVFRED_VS_RM; } let mayRaiseFPException = true in { defm PseudoVFREDMIN : VPseudoVFREDMINMAX_VS; defm PseudoVFREDMAX : VPseudoVFREDMINMAX_VS; } //===----------------------------------------------------------------------===// // 14.4. Vector Widening Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// let IsRVVWideningReduction = 1, hasSideEffects = 0, mayRaiseFPException = true in { defm PseudoVFWREDUSUM : VPseudoVFWRED_VS_RM; defm PseudoVFWREDOSUM : VPseudoVFWRED_VS_RM; } } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 15. Vector Mask Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 15.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">; defm PseudoVMSET : VPseudoNullaryPseudoM<"VMXNOR">; //===----------------------------------------------------------------------===// // 15.2. Vector mask population count vcpop //===----------------------------------------------------------------------===// defm PseudoVCPOP: VPseudoVPOP_M; //===----------------------------------------------------------------------===// // 15.3. vfirst find-first-set mask bit //===----------------------------------------------------------------------===// defm PseudoVFIRST: VPseudoV1ST_M; //===----------------------------------------------------------------------===// // 15.4. vmsbf.m set-before-first mask bit //===----------------------------------------------------------------------===// defm PseudoVMSBF: VPseudoVSFS_M; //===----------------------------------------------------------------------===// // 15.5. vmsif.m set-including-first mask bit //===----------------------------------------------------------------------===// defm PseudoVMSIF: VPseudoVSFS_M; //===----------------------------------------------------------------------===// // 15.6. vmsof.m set-only-first mask bit //===----------------------------------------------------------------------===// defm PseudoVMSOF: VPseudoVSFS_M; //===----------------------------------------------------------------------===// // 15.8. Vector Iota Instruction //===----------------------------------------------------------------------===// defm PseudoVIOTA_M: VPseudoVIOT_M; //===----------------------------------------------------------------------===// // 15.9. Vector Element Index Instruction //===----------------------------------------------------------------------===// defm PseudoVID : VPseudoVID_V; //===----------------------------------------------------------------------===// // 16. Vector Permutation Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 16.1. Integer Scalar Move Instructions //===----------------------------------------------------------------------===// let Predicates = [HasVInstructions] in { let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in { foreach m = MxList in { defvar mx = m.MX; let VLMul = m.value in { let HasSEWOp = 1, BaseInstr = VMV_X_S in def PseudoVMV_X_S # "_" # 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 # "_" # mx: Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, GPR:$rs2, AVL:$vl, ixlenimm:$sew), []>, Sched<[WriteVIMovXV, ReadVIMovXV, ReadVIMovXX]>, RISCVVPseudo; } } } } // Predicates = [HasVInstructions] //===----------------------------------------------------------------------===// // 16.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 { defvar mx = m.MX; let VLMul = m.value in { let HasSEWOp = 1, BaseInstr = VFMV_F_S in def "PseudoVFMV_" # f.FX # "_S_" # 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 # "_" # mx : Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, f.fprclass:$rs2, AVL:$vl, ixlenimm:$sew), []>, Sched<[WriteVFMovFV, ReadVFMovFV, ReadVFMovFX]>, RISCVVPseudo; } } } } } // Predicates = [HasVInstructionsAnyF] //===----------------------------------------------------------------------===// // 16.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] //===----------------------------------------------------------------------===// // 16.4. Vector Register Gather Instructions //===----------------------------------------------------------------------===// defm PseudoVRGATHER : VPseudoVGTR_VV_VX_VI; defm PseudoVRGATHEREI16 : VPseudoVGTR_VV_EEW; //===----------------------------------------------------------------------===// // 16.5. Vector Compress Instruction //===----------------------------------------------------------------------===// defm PseudoVCOMPRESS : VPseudoVCPR_V; //===----------------------------------------------------------------------===// // Patterns. //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 11. Vector Integer Arithmetic Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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">; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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. let Predicates = GetVTypePredicates.Predicates in { def : Pat<(vti.Vector (int_riscv_vsll (vti.Vector undef), (vti.Vector vti.RegClass:$rs1), (XLenVT 1), VLOpFrag)), (!cast("PseudoVADD_VV_"#vti.LMul.MX) (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs1, vti.RegClass:$rs1, GPR:$vl, vti.Log2SEW, TU_MU)>; 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))>; } } //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.10. Vector Single-Width Integer Multiply Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vmul", "PseudoVMUL", AllIntegerVectors>; defvar IntegerVectorsExceptI64 = !filter(vti, AllIntegerVectors, !ne(vti.SEW, 64)); defm : VPatBinaryV_VV_VX<"int_riscv_vmulh", "PseudoVMULH", IntegerVectorsExceptI64>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulhu", "PseudoVMULHU", IntegerVectorsExceptI64>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulhsu", "PseudoVMULHSU", IntegerVectorsExceptI64>; // vmulh, vmulhu, vmulhsu are not included for EEW=64 in Zve64*. defvar I64IntegerVectors = !filter(vti, AllIntegerVectors, !eq(vti.SEW, 64)); let Predicates = [HasVInstructionsFullMultiply] in { defm : VPatBinaryV_VV_VX<"int_riscv_vmulh", "PseudoVMULH", I64IntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulhu", "PseudoVMULHU", I64IntegerVectors>; defm : VPatBinaryV_VV_VX<"int_riscv_vmulhsu", "PseudoVMULHSU", I64IntegerVectors>; } //===----------------------------------------------------------------------===// // 11.11. Vector Integer Divide Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX<"int_riscv_vdivu", "PseudoVDIVU", AllIntegerVectors, isSEWAware=1>; defm : VPatBinaryV_VV_VX<"int_riscv_vdiv", "PseudoVDIV", AllIntegerVectors, isSEWAware=1>; defm : VPatBinaryV_VV_VX<"int_riscv_vremu", "PseudoVREMU", AllIntegerVectors, isSEWAware=1>; defm : VPatBinaryV_VV_VX<"int_riscv_vrem", "PseudoVREM", AllIntegerVectors, isSEWAware=1>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.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>; //===----------------------------------------------------------------------===// // 11.15. Vector Integer Merge Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VM_XM_IM<"int_riscv_vmerge", "PseudoVMERGE">; //===----------------------------------------------------------------------===// // 11.16. Vector Integer Move Instructions //===----------------------------------------------------------------------===// foreach vti = AllVectors in { let Predicates = GetVTypePredicates.Predicates in { def : Pat<(vti.Vector (int_riscv_vmv_v_v (vti.Vector vti.RegClass:$passthru), (vti.Vector vti.RegClass:$rs1), VLOpFrag)), (!cast("PseudoVMV_V_V_"#vti.LMul.MX) $passthru, $rs1, GPR:$vl, vti.Log2SEW, TU_MU)>; // vmv.v.x/vmv.v.i are handled in RISCInstrVInstrInfoVVLPatterns.td } } //===----------------------------------------------------------------------===// // 12. Vector Fixed-Point Arithmetic Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 12.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>; //===----------------------------------------------------------------------===// // 12.2. Vector Single-Width Averaging Add and Subtract //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_RM<"int_riscv_vaaddu", "PseudoVAADDU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX_RM<"int_riscv_vasubu", "PseudoVASUBU", AllIntegerVectors>; defm : VPatBinaryV_VV_VX_RM<"int_riscv_vasub", "PseudoVASUB", AllIntegerVectors>; defm : VPatBinaryV_VV_VX_RM<"int_riscv_vaadd", "PseudoVAADD", AllIntegerVectors>; //===----------------------------------------------------------------------===// // 12.3. Vector Single-Width Fractional Multiply with Rounding and Saturation //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_RM<"int_riscv_vsmul", "PseudoVSMUL", IntegerVectorsExceptI64>; // vsmul.vv and vsmul.vx are not included in EEW=64 in Zve64*. let Predicates = [HasVInstructionsFullMultiply] in defm : VPatBinaryV_VV_VX_RM<"int_riscv_vsmul", "PseudoVSMUL", I64IntegerVectors>; //===----------------------------------------------------------------------===// // 12.4. Vector Single-Width Scaling Shift Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI_RM<"int_riscv_vssrl", "PseudoVSSRL", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VV_VX_VI_RM<"int_riscv_vssra", "PseudoVSSRA", AllIntegerVectors, uimm5>; //===----------------------------------------------------------------------===// // 12.5. Vector Narrowing Fixed-Point Clip Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_WV_WX_WI_RM<"int_riscv_vnclipu", "PseudoVNCLIPU", AllWidenableIntVectors>; defm : VPatBinaryV_WV_WX_WI_RM<"int_riscv_vnclip", "PseudoVNCLIP", AllWidenableIntVectors>; //===----------------------------------------------------------------------===// // 13. Vector Floating-Point Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_RM<"int_riscv_vfadd", "PseudoVFADD", AllFloatVectors>; defm : VPatBinaryV_VV_VX_RM<"int_riscv_vfsub", "PseudoVFSUB", AllFloatVectors>; defm : VPatBinaryV_VX_RM<"int_riscv_vfrsub", "PseudoVFRSUB", AllFloatVectors>; //===----------------------------------------------------------------------===// // 13.3. Vector Widening Floating-Point Add/Subtract Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryW_VV_VX_RM<"int_riscv_vfwadd", "PseudoVFWADD", AllWidenableFloatVectors>; defm : VPatBinaryW_VV_VX_RM<"int_riscv_vfwsub", "PseudoVFWSUB", AllWidenableFloatVectors>; defm : VPatBinaryW_WV_WX_RM<"int_riscv_vfwadd_w", "PseudoVFWADD", AllWidenableFloatVectors>; defm : VPatBinaryW_WV_WX_RM<"int_riscv_vfwsub_w", "PseudoVFWSUB", AllWidenableFloatVectors>; //===----------------------------------------------------------------------===// // 13.4. Vector Single-Width Floating-Point Multiply/Divide Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_RM<"int_riscv_vfmul", "PseudoVFMUL", AllFloatVectors>; defm : VPatBinaryV_VV_VX_RM<"int_riscv_vfdiv", "PseudoVFDIV", AllFloatVectors, isSEWAware=1>; defm : VPatBinaryV_VX_RM<"int_riscv_vfrdiv", "PseudoVFRDIV", AllFloatVectors, isSEWAware=1>; //===----------------------------------------------------------------------===// // 13.5. Vector Widening Floating-Point Multiply //===----------------------------------------------------------------------===// defm : VPatBinaryW_VV_VX_RM<"int_riscv_vfwmul", "PseudoVFWMUL", AllWidenableFloatVectors>; //===----------------------------------------------------------------------===// // 13.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfmacc", "PseudoVFMACC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfnmacc", "PseudoVFNMACC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfmsac", "PseudoVFMSAC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfnmsac", "PseudoVFNMSAC", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfmadd", "PseudoVFMADD", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfnmadd", "PseudoVFNMADD", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfmsub", "PseudoVFMSUB", AllFloatVectors>; defm : VPatTernaryV_VV_VX_AAXA_RM<"int_riscv_vfnmsub", "PseudoVFNMSUB", AllFloatVectors>; //===----------------------------------------------------------------------===// // 13.7. Vector Widening Floating-Point Fused Multiply-Add Instructions //===----------------------------------------------------------------------===// defm : VPatTernaryW_VV_VX_RM<"int_riscv_vfwmacc", "PseudoVFWMACC", AllWidenableFloatVectors>; defm : VPatTernaryW_VV_VX_RM<"int_riscv_vfwnmacc", "PseudoVFWNMACC", AllWidenableFloatVectors>; defm : VPatTernaryW_VV_VX_RM<"int_riscv_vfwmsac", "PseudoVFWMSAC", AllWidenableFloatVectors>; defm : VPatTernaryW_VV_VX_RM<"int_riscv_vfwnmsac", "PseudoVFWNMSAC", AllWidenableFloatVectors>; //===----------------------------------------------------------------------===// // 13.8. Vector Floating-Point Square-Root Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V_RM<"int_riscv_vfsqrt", "PseudoVFSQRT", AllFloatVectors, isSEWAware=1>; //===----------------------------------------------------------------------===// // 13.9. Vector Floating-Point Reciprocal Square-Root Estimate Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V<"int_riscv_vfrsqrt7", "PseudoVFRSQRT7", AllFloatVectors>; //===----------------------------------------------------------------------===// // 13.10. Vector Floating-Point Reciprocal Estimate Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V_RM<"int_riscv_vfrec7", "PseudoVFREC7", AllFloatVectors>; //===----------------------------------------------------------------------===// // 13.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>; //===----------------------------------------------------------------------===// // 13.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>; //===----------------------------------------------------------------------===// // 13.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>; //===----------------------------------------------------------------------===// // 13.14. Vector Floating-Point Classify Instruction //===----------------------------------------------------------------------===// defm : VPatConversionVI_VF<"int_riscv_vfclass", "PseudoVFCLASS">; //===----------------------------------------------------------------------===// // 13.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. foreach vti = AllFloatVectors in { let Predicates = GetVTypePredicates.Predicates in { defm : VPatBinaryCarryInTAIL<"int_riscv_vmerge", "PseudoVMERGE", "VVM", vti.Vector, vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass, vti.RegClass>; defm : VPatBinaryCarryInTAIL<"int_riscv_vfmerge", "PseudoVMERGE", "VVM", vti.Vector, vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass, vti.RegClass>; defm : VPatBinaryCarryInTAIL<"int_riscv_vfmerge", "PseudoVFMERGE", "V"#vti.ScalarSuffix#"M", vti.Vector, vti.Vector, vti.Scalar, vti.Mask, vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass, vti.ScalarRegClass>; } } foreach fvti = AllFloatVectors in { defvar instr = !cast("PseudoVMERGE_VIM_"#fvti.LMul.MX); let Predicates = GetVTypePredicates.Predicates in def : Pat<(fvti.Vector (int_riscv_vfmerge (fvti.Vector fvti.RegClass:$merge), (fvti.Vector fvti.RegClass:$rs2), (fvti.Scalar (fpimm0)), (fvti.Mask V0), VLOpFrag)), (instr fvti.RegClass:$merge, fvti.RegClass:$rs2, 0, (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>; } //===----------------------------------------------------------------------===// // 13.17. Single-Width Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm : VPatConversionVI_VF_RM<"int_riscv_vfcvt_x_f_v", "PseudoVFCVT_X_F">; defm : VPatConversionVI_VF_RM<"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_rtz_x_f_v", "PseudoVFCVT_RTZ_X_F">; defm : VPatConversionVF_VI_RM<"int_riscv_vfcvt_f_x_v", "PseudoVFCVT_F_X">; defm : VPatConversionVF_VI_RM<"int_riscv_vfcvt_f_xu_v", "PseudoVFCVT_F_XU">; //===----------------------------------------------------------------------===// // 13.18. Widening Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm : VPatConversionWI_VF_RM<"int_riscv_vfwcvt_xu_f_v", "PseudoVFWCVT_XU_F">; defm : VPatConversionWI_VF_RM<"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">; //===----------------------------------------------------------------------===// // 13.19. Narrowing Floating-Point/Integer Type-Convert Instructions //===----------------------------------------------------------------------===// defm : VPatConversionVI_WF_RM<"int_riscv_vfncvt_xu_f_w", "PseudoVFNCVT_XU_F">; defm : VPatConversionVI_WF_RM<"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_RM <"int_riscv_vfncvt_f_xu_w", "PseudoVFNCVT_F_XU">; defm : VPatConversionVF_WI_RM <"int_riscv_vfncvt_f_x_w", "PseudoVFNCVT_F_X">; defm : VPatConversionVF_WF_RM<"int_riscv_vfncvt_f_f_w", "PseudoVFNCVT_F_F">; defm : VPatConversionVF_WF<"int_riscv_vfncvt_rod_f_f_w", "PseudoVFNCVT_ROD_F_F">; //===----------------------------------------------------------------------===// // 14. Vector Reduction Operations //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 14.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">; //===----------------------------------------------------------------------===// // 14.2. Vector Widening Integer Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionW_VS<"int_riscv_vwredsumu", "PseudoVWREDSUMU">; defm : VPatReductionW_VS<"int_riscv_vwredsum", "PseudoVWREDSUM">; //===----------------------------------------------------------------------===// // 14.3. Vector Single-Width Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionV_VS_RM<"int_riscv_vfredosum", "PseudoVFREDOSUM", IsFloat=1>; defm : VPatReductionV_VS_RM<"int_riscv_vfredusum", "PseudoVFREDUSUM", IsFloat=1>; defm : VPatReductionV_VS<"int_riscv_vfredmin", "PseudoVFREDMIN", IsFloat=1>; defm : VPatReductionV_VS<"int_riscv_vfredmax", "PseudoVFREDMAX", IsFloat=1>; //===----------------------------------------------------------------------===// // 14.4. Vector Widening Floating-Point Reduction Instructions //===----------------------------------------------------------------------===// defm : VPatReductionW_VS_RM<"int_riscv_vfwredusum", "PseudoVFWREDUSUM", IsFloat=1>; defm : VPatReductionW_VS_RM<"int_riscv_vfwredosum", "PseudoVFWREDOSUM", IsFloat=1>; //===----------------------------------------------------------------------===// // 15. Vector Mask Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 15.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">; //===----------------------------------------------------------------------===// // 15.2. Vector count population in mask vcpop.m //===----------------------------------------------------------------------===// defm : VPatUnaryS_M<"int_riscv_vcpop", "PseudoVCPOP">; //===----------------------------------------------------------------------===// // 15.3. vfirst find-first-set mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryS_M<"int_riscv_vfirst", "PseudoVFIRST">; //===----------------------------------------------------------------------===// // 15.4. vmsbf.m set-before-first mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryM_M<"int_riscv_vmsbf", "PseudoVMSBF">; //===----------------------------------------------------------------------===// // 15.5. vmsif.m set-including-first mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryM_M<"int_riscv_vmsif", "PseudoVMSIF">; //===----------------------------------------------------------------------===// // 15.6. vmsof.m set-only-first mask bit //===----------------------------------------------------------------------===// defm : VPatUnaryM_M<"int_riscv_vmsof", "PseudoVMSOF">; //===----------------------------------------------------------------------===// // 15.8. Vector Iota Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_M<"int_riscv_viota", "PseudoVIOTA">; //===----------------------------------------------------------------------===// // 15.9. Vector Element Index Instruction //===----------------------------------------------------------------------===// defm : VPatNullaryV<"int_riscv_vid", "PseudoVID">; //===----------------------------------------------------------------------===// // 16. Vector Permutation Instructions //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // 16.1. Integer Scalar Move Instructions //===----------------------------------------------------------------------===// foreach vti = AllIntegerVectors in { let Predicates = GetVTypePredicates.Predicates in def : Pat<(XLenVT (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 } //===----------------------------------------------------------------------===// // 16.2. Floating-Point Scalar Move Instructions //===----------------------------------------------------------------------===// foreach fvti = AllFloatVectors in { let Predicates = GetVTypePredicates.Predicates in { 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)>; def : Pat<(fvti.Vector (int_riscv_vfmv_s_f (fvti.Vector fvti.RegClass:$rs1), (fvti.Scalar (fpimm0)), VLOpFrag)), (!cast("PseudoVMV_S_X_" # fvti.LMul.MX) (fvti.Vector $rs1), (XLenVT X0), GPR:$vl, fvti.Log2SEW)>; } } //===----------------------------------------------------------------------===// // 16.3. Vector Slide Instructions //===----------------------------------------------------------------------===// 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>; 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>; //===----------------------------------------------------------------------===// // 16.4. Vector Register Gather Instructions //===----------------------------------------------------------------------===// defm : VPatBinaryV_VV_VX_VI_INT<"int_riscv_vrgather", "PseudoVRGATHER", AllIntegerVectors, uimm5>; defm : VPatBinaryV_VV_INT_EEW<"int_riscv_vrgatherei16_vv", "PseudoVRGATHEREI16", eew=16, vtilist=AllIntegerVectors>; defm : VPatBinaryV_VV_VX_VI_INT<"int_riscv_vrgather", "PseudoVRGATHER", AllFloatVectors, uimm5>; defm : VPatBinaryV_VV_INT_EEW<"int_riscv_vrgatherei16_vv", "PseudoVRGATHEREI16", eew=16, vtilist=AllFloatVectors>; //===----------------------------------------------------------------------===// // 16.5. Vector Compress Instruction //===----------------------------------------------------------------------===// defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllIntegerVectors>; defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllIntegerVectors>; defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllIntegerVectors>; defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllFloatVectors>; defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllFloatVectors>; defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllFloatVectors>; // Include the non-intrinsic ISel patterns include "RISCVInstrInfoVVLPatterns.td" include "RISCVInstrInfoVSDPatterns.td"