@@ -115,6 +115,8 @@ class octuple_to_str<int octuple> {
115115 " NoDef" )))))));
116116}
117117
118+ def VLOpFrag : PatFrag <(ops ), (XLenVT (VLOp (XLenVT GPR :$vl )))>;
119+
118120// Output pattern for X0 used to represent VLMAX in the pseudo instructions.
119121def VLMax : OutPatFrag <(ops ), (XLenVT X0 )>;
120122
@@ -2132,7 +2134,7 @@ class VPatUnaryNoMask<string intrinsic_name,
21322134 VReg op2_reg_class > :
21332135 Pat <(result_type (!cast <Intrinsic >(intrinsic_name )
21342136 (op2_type op2_reg_class :$rs2 ),
2135- ( XLenVT ( VLOp GPR : $vl )) )),
2137+ VLOpFrag )),
21362138 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX )
21372139 (op2_type op2_reg_class :$rs2 ),
21382140 GPR :$vl , sew )>;
@@ -2151,7 +2153,7 @@ class VPatUnaryMask<string intrinsic_name,
21512153 (result_type result_reg_class :$merge ),
21522154 (op2_type op2_reg_class :$rs2 ),
21532155 (mask_type V0 ),
2154- ( XLenVT ( VLOp GPR : $vl )) )),
2156+ VLOpFrag )),
21552157 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX #" _MASK" )
21562158 (result_type result_reg_class :$merge ),
21572159 (op2_type op2_reg_class :$rs2 ),
@@ -2162,7 +2164,7 @@ class VPatMaskUnaryNoMask<string intrinsic_name,
21622164 MTypeInfo mti > :
21632165 Pat <(mti .Mask (!cast <Intrinsic >(intrinsic_name )
21642166 (mti .Mask VR :$rs2 ),
2165- ( XLenVT ( VLOp GPR : $vl )) )),
2167+ VLOpFrag )),
21662168 (!cast <Instruction >(inst #" _M_" #mti .BX )
21672169 (mti .Mask VR :$rs2 ),
21682170 GPR :$vl , mti .SEW )>;
@@ -2174,7 +2176,7 @@ class VPatMaskUnaryMask<string intrinsic_name,
21742176 (mti .Mask VR :$merge ),
21752177 (mti .Mask VR :$rs2 ),
21762178 (mti .Mask V0 ),
2177- ( XLenVT ( VLOp GPR : $vl )) )),
2179+ VLOpFrag )),
21782180 (!cast <Instruction >(inst #" _M_" #mti .BX #" _MASK" )
21792181 (mti .Mask VR :$merge ),
21802182 (mti .Mask VR :$rs2 ),
@@ -2194,7 +2196,7 @@ class VPatUnaryAnyMask<string intrinsic,
21942196 (result_type result_reg_class :$merge ),
21952197 (op1_type op1_reg_class :$rs1 ),
21962198 (mask_type VR :$rs2 ),
2197- ( XLenVT ( VLOp GPR : $vl )) )),
2199+ VLOpFrag )),
21982200 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX )
21992201 (result_type result_reg_class :$merge ),
22002202 (op1_type op1_reg_class :$rs1 ),
@@ -2212,7 +2214,7 @@ class VPatBinaryNoMask<string intrinsic_name,
22122214 Pat <(result_type (!cast <Intrinsic >(intrinsic_name )
22132215 (op1_type op1_reg_class :$rs1 ),
22142216 (op2_type op2_kind :$rs2 ),
2215- ( XLenVT ( VLOp GPR : $vl )) )),
2217+ VLOpFrag )),
22162218 (!cast <Instruction >(inst )
22172219 (op1_type op1_reg_class :$rs1 ),
22182220 (op2_type op2_kind :$rs2 ),
@@ -2233,7 +2235,7 @@ class VPatBinaryMask<string intrinsic_name,
22332235 (op1_type op1_reg_class :$rs1 ),
22342236 (op2_type op2_kind :$rs2 ),
22352237 (mask_type V0 ),
2236- ( XLenVT ( VLOp GPR : $vl )) )),
2238+ VLOpFrag )),
22372239 (!cast <Instruction >(inst #" _MASK" )
22382240 (result_type result_reg_class :$merge ),
22392241 (op1_type op1_reg_class :$rs1 ),
@@ -2256,7 +2258,7 @@ class VPatTernaryNoMask<string intrinsic,
22562258 (result_type result_reg_class :$rs3 ),
22572259 (op1_type op1_reg_class :$rs1 ),
22582260 (op2_type op2_kind :$rs2 ),
2259- ( XLenVT ( VLOp GPR : $vl )) )),
2261+ VLOpFrag )),
22602262 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX )
22612263 result_reg_class :$rs3 ,
22622264 (op1_type op1_reg_class :$rs1 ),
@@ -2280,7 +2282,7 @@ class VPatTernaryMask<string intrinsic,
22802282 (op1_type op1_reg_class :$rs1 ),
22812283 (op2_type op2_kind :$rs2 ),
22822284 (mask_type V0 ),
2283- ( XLenVT ( VLOp GPR : $vl )) )),
2285+ VLOpFrag )),
22842286 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX # " _MASK" )
22852287 result_reg_class :$rs3 ,
22862288 (op1_type op1_reg_class :$rs1 ),
@@ -2300,7 +2302,7 @@ class VPatAMOWDNoMask<string intrinsic_name,
23002302 GPR :$rs1 ,
23012303 (op1_type op1_reg_class :$vs2 ),
23022304 (result_type vlmul .vrclass :$vd ),
2303- ( XLenVT ( VLOp GPR : $vl )) )),
2305+ VLOpFrag )),
23042306 (!cast <Instruction >(inst # " _WD_" # vlmul .MX # " _" # emul .MX )
23052307 $rs1 , $vs2 , $vd ,
23062308 GPR :$vl , sew )>;
@@ -2319,7 +2321,7 @@ class VPatAMOWDMask<string intrinsic_name,
23192321 (op1_type op1_reg_class :$vs2 ),
23202322 (result_type vlmul .vrclass :$vd ),
23212323 (mask_type V0 ),
2322- ( XLenVT ( VLOp GPR : $vl )) )),
2324+ VLOpFrag )),
23232325 (!cast <Instruction >(inst # " _WD_" # vlmul .MX # " _" # emul .MX # " _MASK" )
23242326 $rs1 , $vs2 , $vd ,
23252327 (mask_type V0 ), GPR :$vl , sew )>;
@@ -2329,11 +2331,11 @@ multiclass VPatUnaryS_M<string intrinsic_name,
23292331{
23302332 foreach mti = AllMasks in {
23312333 def : Pat <(XLenVT (!cast <Intrinsic >(intrinsic_name )
2332- (mti .Mask VR :$rs1 ), ( XLenVT ( VLOp GPR : $vl )) )),
2334+ (mti .Mask VR :$rs1 ), VLOpFrag )),
23332335 (!cast <Instruction >(inst #" _M_" #mti .BX ) $rs1 ,
23342336 GPR :$vl , mti .SEW )>;
23352337 def : Pat <(XLenVT (!cast <Intrinsic >(intrinsic_name # " _mask" )
2336- (mti .Mask VR :$rs1 ), (mti .Mask V0 ), ( XLenVT ( VLOp GPR : $vl )) )),
2338+ (mti .Mask VR :$rs1 ), (mti .Mask V0 ), VLOpFrag )),
23372339 (!cast <Instruction >(inst #" _M_" #mti .BX #" _MASK" ) $rs1 ,
23382340 (mti .Mask V0 ), GPR :$vl , mti .SEW )>;
23392341 }
@@ -2400,12 +2402,12 @@ multiclass VPatNullaryV<string intrinsic, string instruction>
24002402{
24012403 foreach vti = AllIntegerVectors in {
24022404 def : Pat <(vti .Vector (!cast <Intrinsic >(intrinsic )
2403- ( XLenVT ( VLOp GPR : $vl )) )),
2405+ VLOpFrag )),
24042406 (!cast <Instruction >(instruction #" _V_" # vti .LMul .MX )
24052407 GPR :$vl , vti .SEW )>;
24062408 def : Pat <(vti .Vector (!cast <Intrinsic >(intrinsic # " _mask" )
24072409 (vti .Vector vti .RegClass :$merge ),
2408- (vti .Mask V0 ), ( XLenVT ( VLOp GPR : $vl )) )),
2410+ (vti .Mask V0 ), VLOpFrag )),
24092411 (!cast <Instruction >(instruction #" _V_" # vti .LMul .MX # " _MASK" )
24102412 vti .RegClass :$merge , (vti .Mask V0 ),
24112413 GPR :$vl , vti .SEW )>;
@@ -2415,7 +2417,7 @@ multiclass VPatNullaryV<string intrinsic, string instruction>
24152417multiclass VPatNullaryM <string intrinsic , string inst > {
24162418 foreach mti = AllMasks in
24172419 def : Pat <(mti .Mask (!cast <Intrinsic >(intrinsic )
2418- (XLenVT (VLOp GPR :$vl )))),
2420+ (XLenVT (VLOp ( XLenVT ( XLenVT GPR :$vl )) )))),
24192421 (!cast <Instruction >(inst #" _M_" #mti .BX )
24202422 GPR :$vl , mti .SEW )>;
24212423}
@@ -2454,7 +2456,7 @@ multiclass VPatBinaryCarryIn<string intrinsic,
24542456 (op1_type op1_reg_class :$rs1 ),
24552457 (op2_type op2_kind :$rs2 ),
24562458 (mask_type V0 ),
2457- ( XLenVT ( VLOp GPR : $vl )) )),
2459+ VLOpFrag )),
24582460 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX )
24592461 (op1_type op1_reg_class :$rs1 ),
24602462 (op2_type op2_kind :$rs2 ),
@@ -2475,7 +2477,7 @@ multiclass VPatBinaryMaskOut<string intrinsic,
24752477 def : Pat <(result_type (!cast <Intrinsic >(intrinsic )
24762478 (op1_type op1_reg_class :$rs1 ),
24772479 (op2_type op2_kind :$rs2 ),
2478- ( XLenVT ( VLOp GPR : $vl )) )),
2480+ VLOpFrag )),
24792481 (!cast <Instruction >(inst #" _" #kind #" _" #vlmul .MX )
24802482 (op1_type op1_reg_class :$rs1 ),
24812483 (op2_type op2_kind :$rs2 ),
@@ -3248,7 +3250,7 @@ foreach vti = AllIntegerVectors in {
32483250 // consistency.
32493251 def : Pat <(vti .Vector (int_riscv_vrsub (vti .Vector vti .RegClass :$rs2 ),
32503252 (vti .Vector vti .RegClass :$rs1 ),
3251- ( XLenVT ( VLOp GPR : $vl )) )),
3253+ VLOpFrag )),
32523254 (!cast <Instruction >(" PseudoVSUB_VV_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
32533255 vti .RegClass :$rs2 ,
32543256 GPR :$vl ,
@@ -3257,7 +3259,7 @@ foreach vti = AllIntegerVectors in {
32573259 (vti .Vector vti .RegClass :$rs2 ),
32583260 (vti .Vector vti .RegClass :$rs1 ),
32593261 (vti .Mask V0 ),
3260- ( XLenVT ( VLOp GPR : $vl )) )),
3262+ VLOpFrag )),
32613263 (!cast <Instruction >(" PseudoVSUB_VV_" #vti .LMul .MX #" _MASK" )
32623264 vti .RegClass :$merge ,
32633265 vti .RegClass :$rs1 ,
@@ -3269,7 +3271,7 @@ foreach vti = AllIntegerVectors in {
32693271 // Match VSUB with a small immediate to vadd.vi by negating the immediate.
32703272 def : Pat <(vti .Vector (int_riscv_vsub (vti .Vector vti .RegClass :$rs1 ),
32713273 (vti .Scalar simm5_plus1 :$rs2 ),
3272- ( XLenVT ( VLOp GPR : $vl )) )),
3274+ VLOpFrag )),
32733275 (!cast <Instruction >(" PseudoVADD_VI_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
32743276 (NegImm simm5_plus1 :$rs2 ),
32753277 GPR :$vl ,
@@ -3278,7 +3280,7 @@ foreach vti = AllIntegerVectors in {
32783280 (vti .Vector vti .RegClass :$rs1 ),
32793281 (vti .Scalar simm5_plus1 :$rs2 ),
32803282 (vti .Mask V0 ),
3281- ( XLenVT ( VLOp GPR : $vl )) )),
3283+ VLOpFrag )),
32823284 (!cast <Instruction >(" PseudoVADD_VI_" #vti .LMul .MX #" _MASK" )
32833285 vti .RegClass :$merge ,
32843286 vti .RegClass :$rs1 ,
@@ -3885,7 +3887,7 @@ defm : VPatBinaryM_VX_VI<"int_riscv_vmsgt", "PseudoVMSGT", AllIntegerVectors>;
38853887foreach vti = AllIntegerVectors in {
38863888 def : Pat <(vti .Mask (int_riscv_vmsgt (vti .Vector vti .RegClass :$rs2 ),
38873889 (vti .Vector vti .RegClass :$rs1 ),
3888- ( XLenVT ( VLOp GPR : $vl )) )),
3890+ VLOpFrag )),
38893891 (!cast <Instruction >(" PseudoVMSLT_VV_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
38903892 vti .RegClass :$rs2 ,
38913893 GPR :$vl ,
@@ -3894,7 +3896,7 @@ foreach vti = AllIntegerVectors in {
38943896 (vti .Vector vti .RegClass :$rs2 ),
38953897 (vti .Vector vti .RegClass :$rs1 ),
38963898 (vti .Mask V0 ),
3897- ( XLenVT ( VLOp GPR : $vl )) )),
3899+ VLOpFrag )),
38983900 (!cast <Instruction >(" PseudoVMSLT_VV_" #vti .LMul .MX #" _MASK" )
38993901 VR :$merge ,
39003902 vti .RegClass :$rs1 ,
@@ -3905,7 +3907,7 @@ foreach vti = AllIntegerVectors in {
39053907
39063908 def : Pat <(vti .Mask (int_riscv_vmsgtu (vti .Vector vti .RegClass :$rs2 ),
39073909 (vti .Vector vti .RegClass :$rs1 ),
3908- ( XLenVT ( VLOp GPR : $vl )) )),
3910+ VLOpFrag )),
39093911 (!cast <Instruction >(" PseudoVMSLTU_VV_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
39103912 vti .RegClass :$rs2 ,
39113913 GPR :$vl ,
@@ -3914,7 +3916,7 @@ foreach vti = AllIntegerVectors in {
39143916 (vti .Vector vti .RegClass :$rs2 ),
39153917 (vti .Vector vti .RegClass :$rs1 ),
39163918 (vti .Mask V0 ),
3917- ( XLenVT ( VLOp GPR : $vl )) )),
3919+ VLOpFrag )),
39183920 (!cast <Instruction >(" PseudoVMSLTU_VV_" #vti .LMul .MX #" _MASK" )
39193921 VR :$merge ,
39203922 vti .RegClass :$rs1 ,
@@ -3931,7 +3933,7 @@ foreach vti = AllIntegerVectors in {
39313933foreach vti = AllIntegerVectors in {
39323934 def : Pat <(vti .Mask (int_riscv_vmslt (vti .Vector vti .RegClass :$rs1 ),
39333935 (vti .Scalar simm5_plus1 :$rs2 ),
3934- ( XLenVT ( VLOp GPR : $vl )) )),
3936+ VLOpFrag )),
39353937 (!cast <Instruction >(" PseudoVMSLE_VI_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
39363938 (DecImm simm5_plus1 :$rs2 ),
39373939 GPR :$vl ,
@@ -3940,7 +3942,7 @@ foreach vti = AllIntegerVectors in {
39403942 (vti .Vector vti .RegClass :$rs1 ),
39413943 (vti .Scalar simm5_plus1 :$rs2 ),
39423944 (vti .Mask V0 ),
3943- ( XLenVT ( VLOp GPR : $vl )) )),
3945+ VLOpFrag )),
39443946 (!cast <Instruction >(" PseudoVMSLE_VI_" #vti .LMul .MX #" _MASK" )
39453947 VR :$merge ,
39463948 vti .RegClass :$rs1 ,
@@ -3951,7 +3953,7 @@ foreach vti = AllIntegerVectors in {
39513953
39523954 def : Pat <(vti .Mask (int_riscv_vmsltu (vti .Vector vti .RegClass :$rs1 ),
39533955 (vti .Scalar simm5_plus1 :$rs2 ),
3954- ( XLenVT ( VLOp GPR : $vl )) )),
3956+ VLOpFrag )),
39553957 (!cast <Instruction >(" PseudoVMSLEU_VI_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
39563958 (DecImm simm5_plus1 :$rs2 ),
39573959 GPR :$vl ,
@@ -3960,7 +3962,7 @@ foreach vti = AllIntegerVectors in {
39603962 (vti .Vector vti .RegClass :$rs1 ),
39613963 (vti .Scalar simm5_plus1 :$rs2 ),
39623964 (vti .Mask V0 ),
3963- ( XLenVT ( VLOp GPR : $vl )) )),
3965+ VLOpFrag )),
39643966 (!cast <Instruction >(" PseudoVMSLEU_VI_" #vti .LMul .MX #" _MASK" )
39653967 VR :$merge ,
39663968 vti .RegClass :$rs1 ,
@@ -3972,7 +3974,7 @@ foreach vti = AllIntegerVectors in {
39723974 // Special cases to avoid matching vmsltu.vi 0 (always false) to
39733975 // vmsleu.vi -1 (always true). Instead match to vmsne.vv.
39743976 def : Pat <(vti .Mask (int_riscv_vmsltu (vti .Vector vti .RegClass :$rs1 ),
3975- (vti .Scalar 0 ), ( XLenVT ( VLOp GPR : $vl )) )),
3977+ (vti .Scalar 0 ), VLOpFrag )),
39763978 (!cast <Instruction >(" PseudoVMSNE_VV_" #vti .LMul .MX ) vti .RegClass :$rs1 ,
39773979 vti .RegClass :$rs1 ,
39783980 GPR :$vl ,
@@ -3981,7 +3983,7 @@ foreach vti = AllIntegerVectors in {
39813983 (vti .Vector vti .RegClass :$rs1 ),
39823984 (vti .Scalar 0 ),
39833985 (vti .Mask V0 ),
3984- ( XLenVT ( VLOp GPR : $vl )) )),
3986+ VLOpFrag )),
39853987 (!cast <Instruction >(" PseudoVMSNE_VV_" #vti .LMul .MX #" _MASK" )
39863988 VR :$merge ,
39873989 vti .RegClass :$rs1 ,
@@ -4048,7 +4050,7 @@ defm : VPatBinaryV_VM_XM_IM<"int_riscv_vmerge", "PseudoVMERGE">;
40484050//===----------------------------------------------------------------------===//
40494051foreach vti = AllVectors in {
40504052 def : Pat <(vti .Vector (int_riscv_vmv_v_v (vti .Vector vti .RegClass :$rs1 ),
4051- ( XLenVT ( VLOp GPR : $vl )) )),
4053+ VLOpFrag )),
40524054 (!cast <Instruction >(" PseudoVMV_V_V_" #vti .LMul .MX )
40534055 $rs1 , GPR :$vl , vti .SEW )>;
40544056
@@ -4196,7 +4198,7 @@ foreach fvti = AllFloatVectors in {
41964198 defvar instr = !cast <Instruction >(" PseudoVMERGE_VIM_" #fvti .LMul .MX );
41974199 def : Pat <(fvti .Vector (int_riscv_vfmerge (fvti .Vector fvti .RegClass :$rs2 ),
41984200 (fvti .Scalar (fpimm0 )),
4199- (fvti .Mask V0 ), ( XLenVT ( VLOp GPR : $vl )) )),
4201+ (fvti .Mask V0 ), VLOpFrag )),
42004202 (instr fvti .RegClass :$rs2 , 0 , (fvti .Mask V0 ), GPR :$vl , fvti .SEW )>;
42014203}
42024204
@@ -4357,7 +4359,7 @@ foreach fvti = AllFloatVectors in {
43574359 (instr $rs2 , fvti .SEW )>;
43584360
43594361 def : Pat <(fvti .Vector (int_riscv_vfmv_s_f (fvti .Vector fvti .RegClass :$rs1 ),
4360- (fvti .Scalar fvti .ScalarRegClass :$rs2 ), ( XLenVT ( VLOp GPR : $vl )) )),
4362+ (fvti .Scalar fvti .ScalarRegClass :$rs2 ), VLOpFrag )),
43614363 (!cast <Instruction >(" PseudoVFMV_S_" #fvti .ScalarSuffix #" _" #
43624364 fvti .LMul .MX )
43634365 (fvti .Vector $rs1 ),
0 commit comments