aboutsummaryrefslogtreecommitdiff
path: root/backend/unittests/Target/RISCVCallLoweringTest.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 19:42:45 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 19:42:45 +0800
commit2271b7b102ae0e5f2a1246bf6e615f3ac128c8bd (patch)
tree4cc3167be793a798b21bf46b9e84e2584824e402 /backend/unittests/Target/RISCVCallLoweringTest.cpp
parentb7716aba458fb3d49742f7a3c169deee7345396e (diff)
downloadrcc-project-2271b7b102ae0e5f2a1246bf6e615f3ac128c8bd.tar.gz
rcc-project-2271b7b102ae0e5f2a1246bf6e615f3ac128c8bd.tar.xz
[RISCV] Accept generic scalars in call lowering
Diffstat (limited to 'backend/unittests/Target/RISCVCallLoweringTest.cpp')
-rw-r--r--backend/unittests/Target/RISCVCallLoweringTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/backend/unittests/Target/RISCVCallLoweringTest.cpp b/backend/unittests/Target/RISCVCallLoweringTest.cpp
index 0262bf5..514c277 100644
--- a/backend/unittests/Target/RISCVCallLoweringTest.cpp
+++ b/backend/unittests/Target/RISCVCallLoweringTest.cpp
@@ -63,6 +63,13 @@ private:
return *Type;
}
+[[nodiscard]] rcc::LLT anyScalar(std::uint32_t Bits) {
+ const auto Type = rcc::LLT::makeAnyScalar(Bits);
+ if (!Type)
+ std::terminate();
+ return *Type;
+}
+
[[nodiscard]] rcc::LLT floating(rcc::FloatSemantics Semantics) {
const auto Type = rcc::LLT::makeFloat(Semantics);
if (!Type)
@@ -231,6 +238,15 @@ void testIntegerAndFloatingAssignments(TestContext &Context) {
isLocation(MixedPlan->argumentAssignments()[1], argumentGPR(0)),
"a mixed floating/integer aggregate must use one FPR and one GPR");
+ auto GenericScalar = callRequest({abiValue(anyScalar(64), 0)}, 1);
+ GenericScalar.Results = {abiValue(anyScalar(64), 0)};
+ auto GenericScalarPlan = rcc::riscv::callLowering().planCall(GenericScalar);
+ Context.expect(GenericScalarPlan && GenericScalarPlan->argumentAssignments().size() == 1 &&
+ GenericScalarPlan->returnAssignments().size() == 1 &&
+ GenericScalarPlan->argumentAssignments()[0].ValueType == anyScalar(64) &&
+ GenericScalarPlan->returnAssignments()[0].ValueType == anyScalar(64),
+ "LLVM generic scalar LLTs must use integer ABI transport without type loss");
+
auto Narrow = abiValue(integer(32), 0);
auto InvalidNarrow = callRequest({Narrow}, 1);
Context.expect(!rcc::riscv::callLowering().planCall(InvalidNarrow),