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 @@ -126,36 +126,88 @@ // Helpers to define the different pseudo instructions. //===----------------------------------------------------------------------===// -multiclass pseudo_binary { - let Constraints = "$rd = $merge", - Uses = [VL, VTYPE], VLIndex = 5, SEWIndex = 6, MergeOpIndex = 1, - BaseInstr = !cast(!subst("Pseudo", "", NAME)) in - def "_"# vlmul.MX : Pseudo<(outs result_reg_class:$rd), - (ins result_reg_class:$merge, - op1_reg_class:$rs2, op2_kind:$rs1, - VMaskOp:$vm, GPR:$vl, ixlenimm:$sew), - []>, - RISCVVPseudo; +class PseudoToVInst { + string VInst = !subst("_M8", "", + !subst("_M4", "", + !subst("_M2", "", + !subst("_M1", "", + !subst("_MF2", "", + !subst("_MF4", "", + !subst("_MF8", "", + !subst("_MASK", "", + !subst("Pseudo", "", PseudoInst))))))))); } -multiclass pseudo_binary_v_vv_vx_vi { +class VPseudoBinary : + Pseudo<(outs RetClass:$rd), + (ins Op1Class:$rs2, Op2Class:$rs1, GPR:$vl, ixlenimm:$sew), []>, + RISCVVPseudo { + let Uses = [VL, VTYPE]; + let VLIndex = 3; + let SEWIndex = 4; + let MergeOpIndex = -1; + let BaseInstr = !cast(PseudoToVInst.VInst); +} + +class VPseudoBinaryMask : + Pseudo<(outs RetClass:$rd), + (ins RetClass:$merge, + Op1Class:$rs2, Op2Class:$rs1, + VMaskOp:$vm, GPR:$vl, ixlenimm:$sew), []>, + RISCVVPseudo { + let Constraints = "$rd = $merge"; + let Uses = [VL, VTYPE]; + let VLIndex = 5; + let SEWIndex = 6; + let MergeOpIndex = 1; + let BaseInstr = !cast(PseudoToVInst.VInst); +} + +multiclass VPseudoBinary { + def "_" # MInfo.MX : VPseudoBinary; + def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMask; +} + +multiclass VPseudoBinaryV_VV { let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1 in foreach m = MxList.m in { let VLMul = m.value in - { - defvar evr = m.vrclass; - defm _VV : pseudo_binary; - defm _VX : pseudo_binary; - defm _VI : pseudo_binary; - } + defm _VV : VPseudoBinary; + } +} + +multiclass VPseudoBinaryV_VX { + let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1 in + foreach m = MxList.m in + { + let VLMul = m.value in + defm _VX : VPseudoBinary; + } +} + +multiclass VPseudoBinaryV_VI { + let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1 in + foreach m = MxList.m in + { + let VLMul = m.value in + defm _VI : VPseudoBinary; } } +multiclass VPseudoBinary_VV_VX_VI { + defm "" : VPseudoBinaryV_VV; + defm "" : VPseudoBinaryV_VX; + defm "" : VPseudoBinaryV_VI; +} + //===----------------------------------------------------------------------===// // Helpers to define the different patterns. //===----------------------------------------------------------------------===// @@ -167,7 +219,7 @@ ValueType mask_type, int sew, LMULInfo vlmul, - VReg result_reg_class, + VReg RetClass, VReg op_reg_class, bit swap = 0> { @@ -300,7 +352,7 @@ //===----------------------------------------------------------------------===// // Pseudo instructions. -defm PseudoVADD : pseudo_binary_v_vv_vx_vi; +defm PseudoVADD : VPseudoBinary_VV_VX_VI; // Whole-register vector patterns. defm "" : pat_vop_binary_common;