[PATCH] D115810: [RISCV] Don't allow vector types to be used with inline asm 'r' constraint
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 15 11:23:39 PST 2021
craig.topper updated this revision to Diff 394616.
craig.topper added a comment.
Address @jrtc's feedback. Add FIXME for P extension.
I thought about allowing fixed vectors, but if it is larger than XLen it creates multiple registers. So needs more care.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115810/new/
https://reviews.llvm.org/D115810
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/inline-asm-invalid.ll
Index: llvm/test/CodeGen/RISCV/inline-asm-invalid.ll
===================================================================
--- llvm/test/CodeGen/RISCV/inline-asm-invalid.ll
+++ llvm/test/CodeGen/RISCV/inline-asm-invalid.ll
@@ -30,3 +30,15 @@
tail call void asm "fadd.d fa0, fa0, $0", "f"(double 0.0)
ret void
}
+
+define void @constraint_r_fixed_vec() nounwind {
+; CHECK: error: couldn't allocate input reg for constraint 'r'
+ tail call void asm "add a0, a0, $0", "r"(<4 x i32> <i32 1, i32 2, i32 3, i32 4>)
+ ret void
+}
+zeroinitializer)
+define void @constraint_r_scalable_vec() nounwind {
+; CHECK: error: couldn't allocate input reg for constraint 'r'
+ tail call void asm "add a0, a0, $0", "r"(<vscale x 4 x i32> zeroinitializer)
+ ret void
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -9586,6 +9586,9 @@
if (Constraint.size() == 1) {
switch (Constraint[0]) {
case 'r':
+ // TODO: Support fixed vectors up to XLen for P extension?
+ if (VT.isVector())
+ break;
return std::make_pair(0U, &RISCV::GPRRegClass);
case 'f':
if (Subtarget.hasStdExtZfh() && VT == MVT::f16)
@@ -9598,17 +9601,15 @@
default:
break;
}
- } else {
- if (Constraint == "vr") {
- for (const auto *RC : {&RISCV::VRRegClass, &RISCV::VRM2RegClass,
- &RISCV::VRM4RegClass, &RISCV::VRM8RegClass}) {
- if (TRI->isTypeLegalForClass(*RC, VT.SimpleTy))
- return std::make_pair(0U, RC);
- }
- } else if (Constraint == "vm") {
- if (TRI->isTypeLegalForClass(RISCV::VMV0RegClass, VT.SimpleTy))
- return std::make_pair(0U, &RISCV::VMV0RegClass);
+ } else if (Constraint == "vr") {
+ for (const auto *RC : {&RISCV::VRRegClass, &RISCV::VRM2RegClass,
+ &RISCV::VRM4RegClass, &RISCV::VRM8RegClass}) {
+ if (TRI->isTypeLegalForClass(*RC, VT.SimpleTy))
+ return std::make_pair(0U, RC);
}
+ } else if (Constraint == "vm") {
+ if (TRI->isTypeLegalForClass(RISCV::VMV0RegClass, VT.SimpleTy))
+ return std::make_pair(0U, &RISCV::VMV0RegClass);
}
// Clang will correctly decode the usage of register name aliases into their
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115810.394616.patch
Type: text/x-patch
Size: 2366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211215/03e24cca/attachment.bin>
More information about the llvm-commits
mailing list