diff --git a/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp b/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp --- a/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp +++ b/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp @@ -31,6 +31,7 @@ uint16_t Pseudo; uint16_t BaseInstr; uint8_t VLMul; + uint8_t SEW; }; #define GET_RISCVVInversePseudosTable_IMPL @@ -100,7 +101,7 @@ if (I->getDesc() == RISCVLMULInstrument::DESC_NAME) { uint8_t LMUL = static_cast(I)->getLMUL(); const RISCVVInversePseudosTable::PseudoInfo *RVV = - RISCVVInversePseudosTable::getBaseInfo(Opcode, LMUL); + RISCVVInversePseudosTable::getBaseInfo(Opcode, LMUL, 0); // Not a RVV instr if (!RVV) { LLVM_DEBUG( diff --git a/llvm/lib/Target/RISCV/RISCVInstrFormats.td b/llvm/lib/Target/RISCV/RISCVInstrFormats.td --- a/llvm/lib/Target/RISCV/RISCVInstrFormats.td +++ b/llvm/lib/Target/RISCV/RISCVInstrFormats.td @@ -217,6 +217,11 @@ bit HasRoundModeOp = 0; let TSFlags{19} = HasRoundModeOp; + + // SEW = 0 is used to denote that the RVInst is not SEW specific. + // TODO: make field smaller by using bit<2> where 0b00 = E8, 0b01=E16, + // 0b10=E32, 0b11=E64. + bits<7> SEW = 0; } // Pseudo instructions diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -522,8 +522,8 @@ def RISCVVInversePseudosTable : GenericTable { let FilterClass = "RISCVVPseudo"; let CppTypeName = "PseudoInfo"; - let Fields = [ "Pseudo", "BaseInstr", "VLMul" ]; - let PrimaryKey = [ "BaseInstr", "VLMul" ]; + let Fields = [ "Pseudo", "BaseInstr", "VLMul", "SEW"]; + let PrimaryKey = [ "BaseInstr", "VLMul", "SEW"]; let PrimaryKeyName = "getBaseInfo"; let PrimaryKeyEarlyOut = true; } @@ -1701,7 +1701,7 @@ foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoUSLoadNoMask, VLESched; @@ -1722,7 +1722,7 @@ foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { def "E" # eew # "FF_V_" # LInfo: VPseudoUSLoadFFNoMask, VLFSched; @@ -1754,7 +1754,7 @@ foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoSLoadNoMask, VLSSched; def "E" # eew # "_V_" # LInfo # "_TU": VPseudoSLoadNoMaskTU, @@ -1807,7 +1807,7 @@ foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoUSStoreNoMask, VSESched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoUSStoreMask, @@ -1833,7 +1833,7 @@ foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; defvar vreg = lmul.vrclass; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { def "E" # eew # "_V_" # LInfo : VPseudoSStoreNoMask, VSSSched; def "E" # eew # "_V_" # LInfo # "_MASK" : VPseudoSStoreMask, @@ -1977,6 +1977,7 @@ 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]>; } @@ -1989,7 +1990,7 @@ LMULInfo MInfo, string Constraint = "", int sew = 0> { - let VLMul = MInfo.value in { + let VLMul = MInfo.value, SEW=sew in { defvar suffix = !if(sew, "_" # MInfo.MX # "_E" # sew, "_" # MInfo.MX); def suffix : VPseudoBinaryNoMask; @@ -2007,7 +2008,7 @@ LMULInfo MInfo, string Constraint = "", int sew = 0> { - let VLMul = MInfo.value in { + let VLMul = MInfo.value, SEW=sew in { defvar suffix = !if(sew, "_" # MInfo.MX # "_E" # sew, "_" # MInfo.MX); def suffix : VPseudoBinaryNoMaskRoundingMode; @@ -2044,7 +2045,7 @@ LMULInfo emul, string Constraint = "", int sew = 0> { - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=sew in { defvar suffix = !if(sew, "_" # lmul.MX # "_E" # sew, "_" # lmul.MX); def suffix # "_" # emul.MX : VPseudoBinaryNoMask; @@ -2387,16 +2388,18 @@ defvar WriteVFSqrtV_MX_E = !cast("WriteVFSqrtV" # suffix); defvar ReadVFSqrtV_MX_E = !cast("ReadVFSqrtV" # suffix); - def "_V" # suffix : VPseudoUnaryNoMask, - Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, - ReadVMask]>; - def "_V" # suffix # "_TU": VPseudoUnaryNoMaskTU, - Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, - ReadVMask]>; - def "_V" # suffix # "_MASK" : VPseudoUnaryMask, - RISCVMaskedPseudo, - Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, - ReadVMask]>; + let SEW = e in { + def "_V" # suffix : VPseudoUnaryNoMask, + Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, + ReadVMask]>; + def "_V" # suffix # "_TU": VPseudoUnaryNoMaskTU, + Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, + ReadVMask]>; + def "_V" # suffix # "_MASK" : VPseudoUnaryMask, + RISCVMaskedPseudo, + Sched<[WriteVFSqrtV_MX_E, ReadVFSqrtV_MX_E, + ReadVMask]>; + } } } } @@ -3204,7 +3207,7 @@ int sew, string Constraint = "", bit Commutable = 0> { - let VLMul = MInfo.value in { + let VLMul = MInfo.value, SEW=sew in { defvar mx = MInfo.MX; let isCommutable = Commutable in def "_" # mx # "_E" # sew : VPseudoTernaryNoMaskWithPolicy; @@ -3765,7 +3768,7 @@ foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : @@ -3784,7 +3787,7 @@ foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "FF_V_" # LInfo : @@ -3803,7 +3806,7 @@ foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoSSegLoadNoMask, @@ -3859,7 +3862,7 @@ foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoUSSegStoreNoMask, @@ -3876,7 +3879,7 @@ foreach eew = EEWList in { foreach lmul = MxSet.m in { defvar LInfo = lmul.MX; - let VLMul = lmul.value in { + let VLMul = lmul.value, SEW=eew in { foreach nf = NFSet.L in { defvar vreg = SegRegClass.RC; def nf # "E" # eew # "_V_" # LInfo : VPseudoSSegStoreNoMask,