@@ -1645,6 +1645,28 @@ multiclass XVPseudoBinaryW_WX<LMULInfo m> {
1645
1645
defm _WX : XVPseudoBinary<m.wvrclass, m.wvrclass, GPR, m>;
1646
1646
}
1647
1647
1648
+ // In RVV 1.0 `@earlyclobber` is used here to prevent the source and destination
1649
+ // from overlapping. The case where LMUL <= 1 is excluded because of the
1650
+ // exception from the 1.0 spec:
1651
+ // "The destination EEW is smaller than the source EEW and the overlap is in the
1652
+ // lowest-numbered part of the source register group."
1653
+ // However, the 0.7 spec is unclear about the source-destination overlapping of
1654
+ // narrowing instructions like vnsrl/vnsra. Here we simply follow the 1.0 spec.
1655
+ multiclass XVPseudoBinaryVNSHT_VV<LMULInfo m> {
1656
+ defm _VV : XVPseudoBinary<m.vrclass, m.wvrclass, m.vrclass, m,
1657
+ !if(!ge(m.octuple, 8), "@earlyclobber $rd", "")>;
1658
+ }
1659
+
1660
+ multiclass XVPseudoBinaryVNSHT_VX<LMULInfo m> {
1661
+ defm _VX : XVPseudoBinary<m.vrclass, m.wvrclass, GPR, m,
1662
+ !if(!ge(m.octuple, 8), "@earlyclobber $rd", "")>;
1663
+ }
1664
+
1665
+ multiclass XVPseudoBinaryVNSHT_VI<LMULInfo m> {
1666
+ defm _VI : XVPseudoBinary<m.vrclass, m.wvrclass, uimm5, m,
1667
+ !if(!ge(m.octuple, 8), "@earlyclobber $rd", "")>;
1668
+ }
1669
+
1648
1670
multiclass XVPseudoVALU_VV_VX_VI<Operand ImmType = simm5, string Constraint = ""> {
1649
1671
foreach m = MxListXTHeadV in {
1650
1672
defvar mx = m.MX;
@@ -1807,6 +1829,24 @@ multiclass XVPseudoVSHT_VV_VX_VI<Operand ImmType = simm5, string Constraint = ""
1807
1829
}
1808
1830
}
1809
1831
1832
+ multiclass XVPseudoVNSHT_VV_VX_VI {
1833
+ foreach m = MxListWXTHeadV in {
1834
+ defvar mx = m.MX;
1835
+ defvar WriteVNShiftV_MX = !cast<SchedWrite>("WriteVNShiftV_" # mx);
1836
+ defvar WriteVNShiftX_MX = !cast<SchedWrite>("WriteVNShiftX_" # mx);
1837
+ defvar WriteVNShiftI_MX = !cast<SchedWrite>("WriteVNShiftI_" # mx);
1838
+ defvar ReadVNShiftV_MX = !cast<SchedRead>("ReadVNShiftV_" # mx);
1839
+ defvar ReadVNShiftX_MX = !cast<SchedRead>("ReadVNShiftX_" # mx);
1840
+
1841
+ defm "" : XVPseudoBinaryVNSHT_VV<m>,
1842
+ Sched<[WriteVNShiftV_MX, ReadVNShiftV_MX, ReadVNShiftV_MX, ReadVMask]>;
1843
+ defm "" : XVPseudoBinaryVNSHT_VX<m>,
1844
+ Sched<[WriteVNShiftX_MX, ReadVNShiftV_MX, ReadVNShiftX_MX, ReadVMask]>;
1845
+ defm "" : XVPseudoBinaryVNSHT_VI<m>,
1846
+ Sched<[WriteVNShiftI_MX, ReadVNShiftV_MX, ReadVMask]>;
1847
+ }
1848
+ }
1849
+
1810
1850
//===----------------------------------------------------------------------===//
1811
1851
// Helpers to define the intrinsic patterns for the XTHeadVector extension.
1812
1852
//===----------------------------------------------------------------------===//
@@ -2053,6 +2093,49 @@ multiclass XVPatBinaryV_IM<string intrinsic, string instruction,
2053
2093
vti.RegClass, simm5>;
2054
2094
}
2055
2095
2096
+ multiclass XVPatBinaryVNSHT_VV<string intrinsic, string instruction,
2097
+ list<VTypeInfoToWide> vtilist> {
2098
+ foreach VtiToWti = vtilist in {
2099
+ defvar Vti = VtiToWti.Vti;
2100
+ defvar Wti = VtiToWti.Wti;
2101
+ let Predicates = !listconcat(GetXVTypePredicates<Vti>.Predicates,
2102
+ GetXVTypePredicates<Wti>.Predicates) in
2103
+ defm : XVPatBinary<intrinsic, instruction # "_VV_" # Vti.LMul.MX,
2104
+ Vti.Vector, Wti.Vector, Vti.Vector, Vti.Mask,
2105
+ Vti.Log2SEW, Vti.RegClass,
2106
+ Wti.RegClass, Vti.RegClass>;
2107
+ }
2108
+ }
2109
+
2110
+ multiclass XVPatBinaryVNSHT_VX<string intrinsic, string instruction,
2111
+ list<VTypeInfoToWide> vtilist> {
2112
+ foreach VtiToWti = vtilist in {
2113
+ defvar Vti = VtiToWti.Vti;
2114
+ defvar Wti = VtiToWti.Wti;
2115
+ defvar kind = "V"#Vti.ScalarSuffix;
2116
+ let Predicates = !listconcat(GetXVTypePredicates<Vti>.Predicates,
2117
+ GetXVTypePredicates<Wti>.Predicates) in
2118
+ defm : XVPatBinary<intrinsic, instruction#"_"#kind#"_"#Vti.LMul.MX,
2119
+ Vti.Vector, Wti.Vector, Vti.Scalar, Vti.Mask,
2120
+ Vti.Log2SEW, Vti.RegClass,
2121
+ Wti.RegClass, Vti.ScalarRegClass>;
2122
+ }
2123
+ }
2124
+
2125
+ multiclass XVPatBinaryVNSHT_VI<string intrinsic, string instruction,
2126
+ list<VTypeInfoToWide> vtilist> {
2127
+ foreach VtiToWti = vtilist in {
2128
+ defvar Vti = VtiToWti.Vti;
2129
+ defvar Wti = VtiToWti.Wti;
2130
+ let Predicates = !listconcat(GetXVTypePredicates<Vti>.Predicates,
2131
+ GetXVTypePredicates<Wti>.Predicates) in
2132
+ defm : XVPatBinary<intrinsic, instruction # "_VI_" # Vti.LMul.MX,
2133
+ Vti.Vector, Wti.Vector, XLenVT, Vti.Mask,
2134
+ Vti.Log2SEW, Vti.RegClass,
2135
+ Wti.RegClass, uimm5>;
2136
+ }
2137
+ }
2138
+
2056
2139
multiclass XVPatBinaryV_VV_VX_VI<string intrinsic, string instruction,
2057
2140
list<VTypeInfo> vtilist, Operand ImmType = simm5>
2058
2141
: XVPatBinaryV_VV<intrinsic, instruction, vtilist>,
@@ -2097,6 +2180,12 @@ multiclass XVPatBinaryM_VM_XM<string intrinsic, string instruction>
2097
2180
: XVPatBinaryV_VM<intrinsic, instruction, CarryOut=1>,
2098
2181
XVPatBinaryV_XM<intrinsic, instruction, CarryOut=1>;
2099
2182
2183
+ multiclass XVPatBinaryVNSHT_VV_VX_VI<string intrinsic, string instruction,
2184
+ list<VTypeInfoToWide> vtilist>
2185
+ : XVPatBinaryVNSHT_VV<intrinsic, instruction, vtilist>,
2186
+ XVPatBinaryVNSHT_VX<intrinsic, instruction, vtilist>,
2187
+ XVPatBinaryVNSHT_VI<intrinsic, instruction, vtilist>;
2188
+
2100
2189
//===----------------------------------------------------------------------===//
2101
2190
// 12.1. Vector Single-Width Saturating Add and Subtract
2102
2191
//===----------------------------------------------------------------------===//
@@ -2267,6 +2356,19 @@ let Predicates = [HasVendorXTHeadV] in {
2267
2356
}
2268
2357
} // Predicates = [HasVendorXTHeadV]
2269
2358
2359
+ //===----------------------------------------------------------------------===//
2360
+ // 12.6. Vector Narrowing Integer Right Shift Instructions
2361
+ //===----------------------------------------------------------------------===//
2362
+ let Predicates = [HasVendorXTHeadV] in {
2363
+ defm PseudoTH_VNSRL : XVPseudoVNSHT_VV_VX_VI;
2364
+ defm PseudoTH_VNSRA : XVPseudoVNSHT_VV_VX_VI;
2365
+ } // Predicates = [HasVendorXTHeadV]
2366
+
2367
+ let Predicates = [HasVendorXTHeadV] in {
2368
+ defm : XVPatBinaryVNSHT_VV_VX_VI<"int_riscv_th_vnsrl", "PseudoTH_VNSRL", AllWidenableIntXVectors>;
2369
+ defm : XVPatBinaryVNSHT_VV_VX_VI<"int_riscv_th_vnsra", "PseudoTH_VNSRA", AllWidenableIntXVectors>;
2370
+ }
2371
+
2270
2372
//===----------------------------------------------------------------------===//
2271
2373
// 12.14. Vector Integer Merge and Move Instructions
2272
2374
//===----------------------------------------------------------------------===//
0 commit comments