Skip to content

Commit

Permalink
[RISCV] Fix whole vector register move instruction's vector register …
Browse files Browse the repository at this point in the history
…constraint.

According to the v-spec, the source and destination VR of vmv<nr>r.v should be aligned for the VR group size.

Differential Revision: https://reviews.llvm.org/D115720
  • Loading branch information
jacquesguan committed Dec 16, 2021
1 parent ec8628b commit d3c2ad1
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
15 changes: 11 additions & 4 deletions llvm/lib/Target/RISCV/RISCVInstrInfoV.td
Expand Up @@ -1416,13 +1416,20 @@ defm VCOMPRESS_V : VCPR_MV_Mask<"vcompress", 0b010111>;

let hasSideEffects = 0, mayLoad = 0, mayStore = 0,
RVVConstraint = NoConstraint in {
foreach n = [1, 2, 4, 8] in {
def VMV#n#R_V : RVInstV<0b100111, !add(n, -1), OPIVI, (outs VR:$vd),
(ins VR:$vs2), "vmv" # n # "r.v", "$vd, $vs2">,
VMVRSched<n> {
def VMV1R_V : RVInstV<0b100111, 0, OPIVI, (outs VR:$vd), (ins VR:$vs2),
"vmv1r.v", "$vd, $vs2">, VMVRSched<1> {
let Uses = [];
let vm = 1;
}
// A future extension may relax the vector register alignment restrictions.
foreach n = [2, 4, 8] in {
defvar vrc = !cast<VReg>("VRM"#n);
def VMV#n#R_V : RVInstV<0b100111, !add(n, -1), OPIVI, (outs vrc:$vd),
(ins vrc:$vs2), "vmv" # n # "r.v", "$vd, $vs2">,
VMVRSched<n> {
let Uses = [];
let vm = 1;
}
}
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
} // Predicates = [HasStdExtV]
Expand Down
66 changes: 66 additions & 0 deletions llvm/test/MC/RISCV/rvv/invalid.s
Expand Up @@ -661,6 +661,72 @@ vs8r.v v6, (a0)
vs8r.v v7, (a0)
# CHECK-ERROR: invalid operand for instruction

vmv2r.v v1, v0
# CHECK-ERROR: invalid operand for instruction

vmv2r.v v0, v1
# CHECK-ERROR: invalid operand for instruction

vmv4r.v v1, v0
# CHECK-ERROR: invalid operand for instruction

vmv4r.v v2, v0
# CHECK-ERROR: invalid operand for instruction

vmv4r.v v3, v0
# CHECK-ERROR: invalid operand for instruction

vmv4r.v v0, v1
# CHECK-ERROR: invalid operand for instruction

vmv4r.v v0, v2
# CHECK-ERROR: invalid operand for instruction

vmv4r.v v0, v3
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v1, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v2, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v3, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v4, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v5, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v6, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v7, v0
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v1
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v2
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v3
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v4
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v5
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v6
# CHECK-ERROR: invalid operand for instruction

vmv8r.v v0, v7
# CHECK-ERROR: invalid operand for instruction

vmsge.vx v2, v4, a0, v0.t, v0
# CHECK-ERROR: invalid operand for instruction

Expand Down

0 comments on commit d3c2ad1

Please sign in to comment.