Skip to content

Commit 4bd0440

Browse files
authored
[RISCV] Add RVVConstraint to SiFive custom matrix multiply instructions. (llvm#124055)
The instructions don't allow the vs1 encoded register to overlap vd. Confusingly these instructions order their operands vd, vs1, vs2 while every other vector instruction is vd, vs2, vs1. So we need to use VS2Constraint for this since it checks the first operand after vd. 2 of the 3 extensions have instruction that produce a result with EMUL=2*LMUL. This makes them subject to the widening constraints for vs2. So for these extensions we use WidenV which includes VS2Constraint.
1 parent cb426b1 commit 4bd0440

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,23 @@ let Predicates = [HasVendorXSfvcp], mayLoad = 0, mayStore = 0,
202202
}
203203

204204
let Predicates = [HasVendorXSfvqmaccdod], DecoderNamespace = "XSfvqmaccdod",
205-
DestEEW = EEWSEWx4 in {
205+
DestEEW = EEWSEWx4, RVVConstraint=VS2Constraint in {
206206
def VQMACCU_2x8x2 : CustomSiFiveVMACC<0b101100, OPMVV, "sf.vqmaccu.2x8x2">;
207207
def VQMACC_2x8x2 : CustomSiFiveVMACC<0b101101, OPMVV, "sf.vqmacc.2x8x2">;
208208
def VQMACCUS_2x8x2 : CustomSiFiveVMACC<0b101110, OPMVV, "sf.vqmaccus.2x8x2">;
209209
def VQMACCSU_2x8x2 : CustomSiFiveVMACC<0b101111, OPMVV, "sf.vqmaccsu.2x8x2">;
210210
}
211211

212212
let Predicates = [HasVendorXSfvqmaccqoq], DecoderNamespace = "XSfvqmaccqoq",
213-
DestEEW = EEWSEWx4 in {
213+
DestEEW = EEWSEWx4, RVVConstraint=WidenV in {
214214
def VQMACCU_4x8x4 : CustomSiFiveVMACC<0b111100, OPMVV, "sf.vqmaccu.4x8x4">;
215215
def VQMACC_4x8x4 : CustomSiFiveVMACC<0b111101, OPMVV, "sf.vqmacc.4x8x4">;
216216
def VQMACCUS_4x8x4 : CustomSiFiveVMACC<0b111110, OPMVV, "sf.vqmaccus.4x8x4">;
217217
def VQMACCSU_4x8x4 : CustomSiFiveVMACC<0b111111, OPMVV, "sf.vqmaccsu.4x8x4">;
218218
}
219219

220220
let Predicates = [HasVendorXSfvfwmaccqqq], DecoderNamespace = "XSfvfwmaccqqq",
221-
DestEEW = EEWSEWx2 in {
221+
DestEEW = EEWSEWx2, RVVConstraint=WidenV in {
222222
def VFWMACC_4x4x4 : CustomSiFiveVMACC<0b111100, OPFVV, "sf.vfwmacc.4x4x4">;
223223
}
224224

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUN: not llvm-mc -triple=riscv64 -show-encoding -mattr=+v,+xsfvfwmaccqqq %s 2>&1 \
2+
# RUN: | FileCheck %s --check-prefixes=CHECK-ERROR
3+
4+
sf.vfwmacc.4x4x4 v8, v8, v20
5+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
6+
# CHECK-ERROR-LABEL: sf.vfwmacc.4x4x4 v8, v8, v20{{$}}
7+
8+
sf.vfwmacc.4x4x4 v8, v4, v8
9+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
10+
# CHECK-ERROR-LABEL: sf.vfwmacc.4x4x4 v8, v4, v8{{$}}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# RUN: not llvm-mc -triple=riscv64 -show-encoding -mattr=+v,+xsfvqmaccqoq,+xsfvqmaccdod %s 2>&1 \
2+
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
3+
4+
sf.vqmaccu.2x8x2 v8, v8, v20
5+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
6+
# CHECK-ERROR-LABEL: sf.vqmaccu.2x8x2 v8, v8, v20
7+
8+
sf.vqmacc.2x8x2 v8, v8, v20
9+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
10+
# CHECK-ERROR-LABEL: sf.vqmacc.2x8x2 v8, v8, v20
11+
12+
sf.vqmaccus.2x8x2 v8, v8, v20
13+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
14+
# CHECK-ERROR-LABEL: sf.vqmaccus.2x8x2 v8, v8, v20
15+
16+
sf.vqmaccsu.2x8x2 v8, v8, v20
17+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
18+
# CHECK-ERROR-LABEL: sf.vqmaccsu.2x8x2 v8, v8, v20
19+
20+
sf.vqmaccu.4x8x4 v8, v8, v20
21+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
22+
# CHECK-ERROR-LABEL: sf.vqmaccu.4x8x4 v8, v8, v20
23+
24+
sf.vqmacc.4x8x4 v8, v8, v20
25+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
26+
# CHECK-ERROR-LABEL: sf.vqmacc.4x8x4 v8, v8, v20
27+
28+
sf.vqmaccus.4x8x4 v8, v8, v20
29+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
30+
# CHECK-ERROR-LABEL: sf.vqmaccus.4x8x4 v8, v8, v20
31+
32+
sf.vqmaccsu.4x8x4 v8, v8, v20
33+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
34+
# CHECK-ERROR-LABEL: sf.vqmaccsu.4x8x4 v8, v8, v20
35+
36+
sf.vqmaccu.4x8x4 v8, v4, v8
37+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
38+
# CHECK-ERROR-LABEL: sf.vqmaccu.4x8x4 v8, v4, v8
39+
40+
sf.vqmacc.4x8x4 v8, v4, v8
41+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
42+
# CHECK-ERROR-LABEL: sf.vqmacc.4x8x4 v8, v4, v8
43+
44+
sf.vqmaccus.4x8x4 v8, v4, v8
45+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
46+
# CHECK-ERROR-LABEL: sf.vqmaccus.4x8x4 v8, v4, v8
47+
48+
sf.vqmaccsu.4x8x4 v8, v4, v8
49+
# CHECK-ERROR: the destination vector register group cannot overlap the source vector register group{{$}}
50+
# CHECK-ERROR-LABEL: sf.vqmaccsu.4x8x4 v8, v4, v8

0 commit comments

Comments
 (0)