Skip to content

Commit f8a386c

Browse files
committed
[RISCV] Add RVVConstraint=VS2Constraint to SiFive custom matrix multiply instructions.
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. VS2Constraint really means check the first operand after vd which is vs1 in this case.
1 parent 652ff20 commit f8a386c

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-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=VS2Constraint 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=VS2Constraint in {
222222
def VFWMACC_4x4x4 : CustomSiFiveVMACC<0b111100, OPFVV, "sf.vfwmacc.4x4x4">;
223223
}
224224

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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{{$}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

0 commit comments

Comments
 (0)