[llvm] [VFABI] Improve VFABI unit tests (PR #73907)
Paschalis Mpeis via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 00:51:28 PST 2023
https://github.com/paschalis-mpeis updated https://github.com/llvm/llvm-project/pull/73907
>From 292bbaba6b35897cabefb1abc2254613a0d100b4 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Tue, 28 Nov 2023 17:49:49 +0000
Subject: [PATCH 01/10] [VFABI] Improve VFABI unit tests
Do checks for scalar parameter counts for all mappings with
`matchScalarParametersNum`. It is not part of `invokeParser` so it can
be selectively applied only to tests that supply valid mangled names.
Also, minor reformatting and typo fixes.
---
.../Analysis/VectorFunctionABITest.cpp | 161 ++++++++++++------
1 file changed, 105 insertions(+), 56 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 81c1807cdcaa81..3112c5d09aad30 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -1,4 +1,4 @@
-//===------- VectorFunctionABITest.cpp - VFABI Unittests ---------===//
+//===------- VectorFunctionABITest.cpp - VFABI unit tests ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/InstIterator.h"
@@ -14,7 +15,7 @@
using namespace llvm;
namespace {
-// Test fixture needed that holds the veariables needed by the parser.
+// Test fixture needed that holds the variables needed by the parser.
class VFABIParserTest : public ::testing::Test {
private:
// Parser output.
@@ -34,6 +35,7 @@ class VFABIParserTest : public ::testing::Test {
<< "The function must be present in the module\n";
// Reset the VFInfo
Info = VFInfo();
+ ScalarParametersNum = 0;
}
// Data needed to load the optional IR passed to invokeParser
@@ -44,10 +46,11 @@ class VFABIParserTest : public ::testing::Test {
FunctionCallee F;
protected:
- // Referencies to the parser output field.
+ // References to the parser output field.
ElementCount &VF = Info.Shape.VF;
VFISAKind &ISA = Info.ISA;
SmallVector<VFParameter, 8> &Parameters = Info.Shape.Parameters;
+ size_t ScalarParametersNum;
std::string &ScalarName = Info.ScalarName;
std::string &VectorName = Info.VectorName;
// Invoke the parser. We need to make sure that a function exist in
@@ -78,24 +81,22 @@ class VFABIParserTest : public ::testing::Test {
// Fake the arguments to the CallInst.
SmallVector<Value *> Args;
- for (Type *ParamTy : FTy->params()) {
+ for (Type *ParamTy : FTy->params())
Args.push_back(Constant::getNullValue(ParamTy->getScalarType()));
- }
std::unique_ptr<CallInst> CI(CallInst::Create(F, Args));
const auto OptInfo =
VFABI::tryDemangleForVFABI(MangledName, CI->getFunctionType());
if (OptInfo) {
Info = *OptInfo;
+ ScalarParametersNum = Info.Shape.getScalarShape(*CI).Parameters.size();
return true;
}
-
return false;
}
// Checks that 1. the last Parameter in the Shape is of type
- // VFParamKind::GlobalPredicate and 2. it is the only one of such
- // type.
- bool IsMasked() const {
+ // VFParamKind::GlobalPredicate and 2. it is the only one of such type.
+ bool isMasked() const {
const auto NGlobalPreds =
std::count_if(Info.Shape.Parameters.begin(),
Info.Shape.Parameters.end(), [](const VFParameter PK) {
@@ -104,6 +105,12 @@ class VFABIParserTest : public ::testing::Test {
return NGlobalPreds == 1 && Info.Shape.Parameters.back().ParamKind ==
VFParamKind::GlobalPredicate;
}
+
+ // Checks that the number of vectorized parameters matches the scalar ones.
+ // Takes into account that vectorized calls may also have a Mask.
+ bool matchScalarParametersNum() {
+ return (Parameters.size() - isMasked()) == ScalarParametersNum;
+ }
};
} // unnamed namespace
@@ -141,8 +148,10 @@ TEST_F(VFABIParserTest, OnlyValidNames) {
}
TEST_F(VFABIParserTest, ParamListParsing) {
- EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo", "",
+ "void(double, i32, i32, ptr, i32)"));
EXPECT_EQ(Parameters.size(), (unsigned)5);
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 16}));
EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearValPos, 32}));
@@ -169,9 +178,12 @@ TEST_F(VFABIParserTest, ScalarNameAndVectorName_03) {
}
TEST_F(VFABIParserTest, Parse) {
- EXPECT_TRUE(invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_sin", "sin",
+ "void(double, i32, i32, i32, ptr, i32, i32, i32, ptr)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(IsMasked());
+ EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
EXPECT_EQ(Parameters.size(), (unsigned)9);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
@@ -188,9 +200,11 @@ TEST_F(VFABIParserTest, Parse) {
}
TEST_F(VFABIParserTest, ParseVectorName) {
- EXPECT_TRUE(invokeParser("_ZGVnN2v_sin(my_v_sin)", "my_v_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVnN2v_sin(my_v_sin)", "my_v_sin", "double(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(IsMasked());
+ EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
@@ -199,9 +213,11 @@ TEST_F(VFABIParserTest, ParseVectorName) {
}
TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
- EXPECT_TRUE(invokeParser("_ZGVnN2ln1Ln10Un100Rn1000_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2ln1Ln10Un100Rn1000_sin", "",
+ "double(i32, i32, i32, ptr)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(IsMasked());
+ EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
EXPECT_EQ(Parameters.size(), (unsigned)4);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, -1}));
@@ -214,17 +230,19 @@ TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
TEST_F(VFABIParserTest, ParseScalableSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_sin(custom_vg)", "sin", "i32(i32)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getScalable(4));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_EQ(ScalarName, "sin");
EXPECT_EQ(VectorName, "custom_vg");
}
TEST_F(VFABIParserTest, ParseFixedWidthSVE) {
- EXPECT_TRUE(invokeParser("_ZGVsM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVsM2v_sin", "", "double(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_EQ(ScalarName, "sin");
EXPECT_EQ(VectorName, "_ZGVsM2v_sin");
@@ -251,7 +269,9 @@ TEST_F(VFABIParserTest, LinearWithRuntimeStep) {
}
TEST_F(VFABIParserTest, LinearWithoutCompileTime) {
- EXPECT_TRUE(invokeParser("_ZGVnN3lLRUlnLnRnUn_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN3lLRUlnLnRnUn_sin", "",
+ "void(i32, i32, ptr, i32, i32, i32, ptr, i32)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(Parameters.size(), (unsigned)8);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, 1}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, 1}));
@@ -301,7 +321,8 @@ TEST_F(VFABIParserTest, InvalidParameter) {
}
TEST_F(VFABIParserTest, Align) {
- EXPECT_TRUE(invokeParser("_ZGVsN2l2a2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVsN2l2a2_sin", "", "void(i32)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0].Alignment, Align(2));
@@ -319,9 +340,10 @@ TEST_F(VFABIParserTest, Align) {
}
TEST_F(VFABIParserTest, ParseUniform) {
- EXPECT_TRUE(invokeParser("_ZGVnN2u_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2u_sin", "", "void(i32)"));
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(IsMasked());
+ EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Uniform, 0}));
@@ -351,58 +373,70 @@ TEST_F(VFABIParserTest, ISAIndependentMangling) {
#define __COMMON_CHECKS \
do { \
EXPECT_EQ(VF, ElementCount::getFixed(2)); \
- EXPECT_FALSE(IsMasked()); \
+ EXPECT_FALSE(isMasked()); \
+ EXPECT_TRUE(matchScalarParametersNum()); \
EXPECT_EQ(Parameters.size(), (unsigned)10); \
EXPECT_EQ(Parameters, ExpectedParams); \
EXPECT_EQ(ScalarName, "sin"); \
} while (0)
+ const StringRef IRTy =
+ "void(double, i32, i32, i32, ptr, i32, i32, i32, i32, i32)";
+
// Advanced SIMD: <isa> = "n"
- EXPECT_TRUE(invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// SVE: <isa> = "s"
- EXPECT_TRUE(invokeParser("_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::SVE);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// SSE: <isa> = "b"
- EXPECT_TRUE(invokeParser("_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::SSE);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX: <isa> = "c"
- EXPECT_TRUE(invokeParser("_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::AVX);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX2: <isa> = "d"
- EXPECT_TRUE(invokeParser("_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::AVX2);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX512: <isa> = "e"
- EXPECT_TRUE(invokeParser("_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::AVX512);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// LLVM: <isa> = "_LLVM_" internal vector function.
- EXPECT_TRUE(invokeParser(
- "_ZGV_LLVM_N2vls2Ls27Us4Rs5l1L10U100R1000u_sin(vectorf)", "vectorf"));
+ EXPECT_TRUE(
+ invokeParser("_ZGV_LLVM_N2vls2Ls27Us4Rs5l1L10U100R1000u_sin(vectorf)",
+ "vectorf", IRTy));
EXPECT_EQ(ISA, VFISAKind::LLVM);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "vectorf");
// Unknown ISA (randomly using "q"). This test will need update if
// some targets decide to use "q" as their ISA token.
- EXPECT_TRUE(invokeParser("_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
EXPECT_EQ(ISA, VFISAKind::Unknown);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
@@ -423,9 +457,10 @@ TEST_F(VFABIParserTest, MissingVectorNameTermination) {
}
TEST_F(VFABIParserTest, ParseMaskingNEON) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnM2v_sin", "", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -434,9 +469,10 @@ TEST_F(VFABIParserTest, ParseMaskingNEON) {
}
TEST_F(VFABIParserTest, ParseMaskingSVE) {
- EXPECT_TRUE(invokeParser("_ZGVsM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVsM2v_sin", "", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -445,9 +481,10 @@ TEST_F(VFABIParserTest, ParseMaskingSVE) {
}
TEST_F(VFABIParserTest, ParseMaskingSSE) {
- EXPECT_TRUE(invokeParser("_ZGVbM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVbM2v_sin", "", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SSE);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -456,9 +493,10 @@ TEST_F(VFABIParserTest, ParseMaskingSSE) {
}
TEST_F(VFABIParserTest, ParseMaskingAVX) {
- EXPECT_TRUE(invokeParser("_ZGVcM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVcM2v_sin", "", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -467,9 +505,10 @@ TEST_F(VFABIParserTest, ParseMaskingAVX) {
}
TEST_F(VFABIParserTest, ParseMaskingAVX2) {
- EXPECT_TRUE(invokeParser("_ZGVdM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVdM2v_sin", "", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX2);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -478,9 +517,10 @@ TEST_F(VFABIParserTest, ParseMaskingAVX2) {
}
TEST_F(VFABIParserTest, ParseMaskingAVX512) {
- EXPECT_TRUE(invokeParser("_ZGVeM2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVeM2v_sin", "", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX512);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -490,9 +530,10 @@ TEST_F(VFABIParserTest, ParseMaskingAVX512) {
TEST_F(VFABIParserTest, ParseMaskingLLVM) {
EXPECT_TRUE(invokeParser("_ZGV_LLVM_M2v_sin(custom_vector_sin)",
- "custom_vector_sin"));
+ "custom_vector_sin", "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -504,12 +545,14 @@ TEST_F(VFABIParserTest, ParseMaskingLLVM) {
TEST_F(VFABIParserTest, ParseScalableMaskingLLVM) {
EXPECT_FALSE(
invokeParser("_ZGV_LLVM_Mxv_sin(custom_vector_sin)", "sin", "i32(i32)"));
+ EXPECT_TRUE(matchScalarParametersNum());
}
TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
EXPECT_TRUE(
invokeParser("_ZGVsMxv_sin(custom_vector_sin)", "sin", "i32(i32)"));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(VF, ElementCount::getScalable(4));
EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_EQ(Parameters.size(), (unsigned)2);
@@ -521,9 +564,10 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
EXPECT_TRUE(invokeParser("_ZGVsMxvl8l8_sincos(custom_vector_sincos)",
- "sincos", "void(double, double *, double *)"));
+ "sincos", "void(double, ptr, ptr)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getScalable(2));
- EXPECT_TRUE(IsMasked());
+ EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_EQ(Parameters.size(), (unsigned)4);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -539,12 +583,14 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
TEST_F(VFABIParserTest, ParseWiderReturnTypeSVE) {
EXPECT_TRUE(
invokeParser("_ZGVsMxvv_foo(vector_foo)", "foo", "i64(i32, i32)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getScalable(2));
}
// Make sure we handle void return types.
TEST_F(VFABIParserTest, ParseVoidReturnTypeSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "foo", "void(i16)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getScalable(8));
}
@@ -557,7 +603,6 @@ TEST_F(VFABIParserTest, ParseUnsupportedElementTypeSVE) {
TEST_F(VFABIParserTest, ParseUnsupportedReturnTypeSVE) {
EXPECT_FALSE(invokeParser("_ZGVsMxv_foo(vector_foo)", "foo", "fp128(float)"));
}
-
class VFABIAttrTest : public testing::Test {
protected:
void SetUp() override {
@@ -594,15 +639,18 @@ TEST_F(VFABIAttrTest, Read) {
TEST_F(VFABIParserTest, LLVM_InternalISA) {
EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_sin"));
- EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_sin_(vector_name)", "vector_name"));
+ EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_sin_(vector_name)", "vector_name",
+ "void(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(ISA, VFISAKind::LLVM);
}
TEST_F(VFABIParserTest, IntrinsicsInLLVMIsa) {
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N4vv_llvm.pow.f32(__svml_powf4)",
- "__svml_powf4"));
+ "__svml_powf4", "void(float, float)"));
+ EXPECT_TRUE(matchScalarParametersNum());
EXPECT_EQ(VF, ElementCount::getFixed(4));
- EXPECT_FALSE(IsMasked());
+ EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -616,6 +664,7 @@ TEST_F(VFABIParserTest, ParseScalableRequiresDeclaration) {
// `custom_vg` is added to the module.
EXPECT_FALSE(invokeParser(MangledName));
EXPECT_TRUE(invokeParser(MangledName, "sin", "double(double)"));
+ EXPECT_TRUE(matchScalarParametersNum());
}
TEST_F(VFABIParserTest, ZeroIsInvalidVLEN) {
@@ -642,9 +691,9 @@ define void @call(void () * %f) {
ret void
}
)IR");
- auto F = dyn_cast_or_null<Function>(M->getNamedValue("call"));
+ auto *F = dyn_cast_or_null<Function>(M->getNamedValue("call"));
ASSERT_TRUE(F);
- auto CI = dyn_cast<CallInst>(&F->front().front());
+ auto *CI = dyn_cast<CallInst>(&F->front().front());
ASSERT_TRUE(CI);
ASSERT_TRUE(CI->isIndirectCall());
auto Mappings = VFDatabase::getMappings(*CI);
>From c4508ba1e2a1d828943ecbffcc9429ef5438bd68 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Thu, 30 Nov 2023 14:31:26 +0000
Subject: [PATCH 02/10] Further cleanup and simplication of VFABI tests.
`tryDemangleForVFABI` and `VFShape`'s `getScalarShape`, `get` use
`FunctionType` instead of `CallInst`.
Each successful parsing should provide a vector name, and do checks for
the names, number of arguments, and vector parameter types, eg:
```
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
...
EXPECT_TRUE(matchScalarParamNum());
...
EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::OMP_Linear, 2}));
```
Replace method names to `foo` and `vector_foo` for the scalar and vector
variants respectively.
Using only `i32` for parameters when it's not relevant, except when
the VF Elements are explicitly checked, `ptr` for references, and `void`
for most return types.
All `VFABIParserTest` tests are now listed contiguously in the source.
---
.../Analysis/VectorFunctionABITest.cpp | 593 ++++++++++--------
1 file changed, 324 insertions(+), 269 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 3112c5d09aad30..50c3fdebd762fe 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -35,22 +35,22 @@ class VFABIParserTest : public ::testing::Test {
<< "The function must be present in the module\n";
// Reset the VFInfo
Info = VFInfo();
- ScalarParametersNum = 0;
+ ScalarFuncParametersNum = 0;
}
// Data needed to load the optional IR passed to invokeParser
LLVMContext Ctx;
SMDiagnostic Err;
std::unique_ptr<Module> M;
- FunctionType *FTy;
+ FunctionType *FTy = nullptr;
FunctionCallee F;
protected:
// References to the parser output field.
ElementCount &VF = Info.Shape.VF;
VFISAKind &ISA = Info.ISA;
- SmallVector<VFParameter, 8> &Parameters = Info.Shape.Parameters;
- size_t ScalarParametersNum;
+ SmallVector<VFParameter, 8> &VecFuncParameters = Info.Shape.Parameters;
+ size_t ScalarFuncParametersNum = 0;
std::string &ScalarName = Info.ScalarName;
std::string &VectorName = Info.VectorName;
// Invoke the parser. We need to make sure that a function exist in
@@ -70,25 +70,17 @@ class VFABIParserTest : public ::testing::Test {
// generic fixed-length case can use as signature `void()`.
//
bool invokeParser(const StringRef MangledName,
- const StringRef ScalarName = "",
const StringRef IRType = "void()") {
- StringRef Name = MangledName;
- if (!ScalarName.empty())
- Name = ScalarName;
// Reset the VFInfo and the Module to be able to invoke
// `invokeParser` multiple times in the same test.
- reset(Name, IRType);
+ reset(MangledName, IRType);
// Fake the arguments to the CallInst.
- SmallVector<Value *> Args;
- for (Type *ParamTy : FTy->params())
- Args.push_back(Constant::getNullValue(ParamTy->getScalarType()));
- std::unique_ptr<CallInst> CI(CallInst::Create(F, Args));
- const auto OptInfo =
- VFABI::tryDemangleForVFABI(MangledName, CI->getFunctionType());
+ const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, FTy);
if (OptInfo) {
Info = *OptInfo;
- ScalarParametersNum = Info.Shape.getScalarShape(*CI).Parameters.size();
+ ScalarFuncParametersNum =
+ Info.Shape.getScalarShape(FTy).Parameters.size();
return true;
}
return false;
@@ -108,8 +100,8 @@ class VFABIParserTest : public ::testing::Test {
// Checks that the number of vectorized parameters matches the scalar ones.
// Takes into account that vectorized calls may also have a Mask.
- bool matchScalarParametersNum() {
- return (Parameters.size() - isMasked()) == ScalarParametersNum;
+ bool matchScalarParamNum() {
+ return (VecFuncParameters.size() - isMasked()) == ScalarFuncParametersNum;
}
};
} // unnamed namespace
@@ -139,224 +131,264 @@ TEST_F(VFABIParserTest, OnlyValidNames) {
EXPECT_FALSE(invokeParser("_ZGVnN2v_"));
// Missing _ separator.
EXPECT_FALSE(invokeParser("_ZGVnN2vfoo"));
- // Missing <vectorname>. Using `fakename` because the string being
- // parsed is not a valid function name that `invokeParser` can add.
- EXPECT_FALSE(invokeParser("_ZGVnN2v_foo()", "fakename"));
- // Unterminated name. Using `fakename` because the string being
- // parsed is not a valid function name that `invokeParser` can add.
- EXPECT_FALSE(invokeParser("_ZGVnN2v_foo(bar", "fakename"));
+ // Missing <vectorname>.
+ EXPECT_FALSE(invokeParser("_ZGVnN2v_foo()"));
+ // Unterminated name.
+ EXPECT_FALSE(invokeParser("_ZGVnN2v_foo(bar"));
}
TEST_F(VFABIParserTest, ParamListParsing) {
- EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo", "",
- "void(double, i32, i32, ptr, i32)"));
- EXPECT_EQ(Parameters.size(), (unsigned)5);
- EXPECT_TRUE(matchScalarParametersNum());
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 16}));
- EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearValPos, 32}));
- EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearRef, 3}));
- EXPECT_EQ(Parameters[4], VFParameter({4, VFParamKind::OMP_Linear, 1}));
+ EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo(vector_foo)",
+ "void(i32, i32, i32, ptr, i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)5);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::OMP_Linear, 16}));
+ EXPECT_EQ(VecFuncParameters[2],
+ VFParameter({2, VFParamKind::OMP_LinearValPos, 32}));
+ EXPECT_EQ(VecFuncParameters[3],
+ VFParameter({3, VFParamKind::OMP_LinearRef, 3}));
+ EXPECT_EQ(VecFuncParameters[4], VFParameter({4, VFParamKind::OMP_Linear, 1}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_01) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v_sin"));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "_ZGVnM2v_sin");
+ EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)"));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_02) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v_sin(UserFunc)", "UserFunc"));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "UserFunc");
+ EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)"));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_03) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v___sin_sin_sin"));
- EXPECT_EQ(ScalarName, "__sin_sin_sin");
- EXPECT_EQ(VectorName, "_ZGVnM2v___sin_sin_sin");
+ EXPECT_TRUE(invokeParser("_ZGVnM2v___foo_bar_abc(fooBarAbcVec)"));
+ EXPECT_EQ(ScalarName, "__foo_bar_abc");
+ EXPECT_EQ(VectorName, "fooBarAbcVec");
}
TEST_F(VFABIParserTest, Parse) {
EXPECT_TRUE(
- invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_sin", "sin",
- "void(double, i32, i32, i32, ptr, i32, i32, i32, ptr)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo(vector_foo)",
+ "void(i32, i32, i32, i32, ptr, i32, i32, i32, ptr)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(Parameters.size(), (unsigned)9);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearPos, 2}));
- EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearValPos, 27}));
- EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearUValPos, 4}));
- EXPECT_EQ(Parameters[4], VFParameter({4, VFParamKind::OMP_LinearRefPos, 5}));
- EXPECT_EQ(Parameters[5], VFParameter({5, VFParamKind::OMP_Linear, 1}));
- EXPECT_EQ(Parameters[6], VFParameter({6, VFParamKind::OMP_LinearVal, 10}));
- EXPECT_EQ(Parameters[7], VFParameter({7, VFParamKind::OMP_LinearUVal, 100}));
- EXPECT_EQ(Parameters[8], VFParameter({8, VFParamKind::OMP_LinearRef, 1000}));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)9);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::OMP_LinearPos, 2}));
+ EXPECT_EQ(VecFuncParameters[2],
+ VFParameter({2, VFParamKind::OMP_LinearValPos, 27}));
+ EXPECT_EQ(VecFuncParameters[3],
+ VFParameter({3, VFParamKind::OMP_LinearUValPos, 4}));
+ EXPECT_EQ(VecFuncParameters[4],
+ VFParameter({4, VFParamKind::OMP_LinearRefPos, 5}));
+ EXPECT_EQ(VecFuncParameters[5], VFParameter({5, VFParamKind::OMP_Linear, 1}));
+ EXPECT_EQ(VecFuncParameters[6],
+ VFParameter({6, VFParamKind::OMP_LinearVal, 10}));
+ EXPECT_EQ(VecFuncParameters[7],
+ VFParameter({7, VFParamKind::OMP_LinearUVal, 100}));
+ EXPECT_EQ(VecFuncParameters[8],
+ VFParameter({8, VFParamKind::OMP_LinearRef, 1000}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseVectorName) {
- EXPECT_TRUE(
- invokeParser("_ZGVnN2v_sin(my_v_sin)", "my_v_sin", "double(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVnN2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(Parameters.size(), (unsigned)1);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "my_v_sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
- EXPECT_TRUE(invokeParser("_ZGVnN2ln1Ln10Un100Rn1000_sin", "",
- "double(i32, i32, i32, ptr)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVnN2ln1Ln10Un100Rn1000_foo(vector_foo)",
+ "void(i32, i32, i32, ptr)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(Parameters.size(), (unsigned)4);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, -1}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, -10}));
- EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearUVal, -100}));
- EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearRef, -1000}));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "_ZGVnN2ln1Ln10Un100Rn1000_sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)4);
+ EXPECT_EQ(VecFuncParameters[0],
+ VFParameter({0, VFParamKind::OMP_Linear, -1}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::OMP_LinearVal, -10}));
+ EXPECT_EQ(VecFuncParameters[2],
+ VFParameter({2, VFParamKind::OMP_LinearUVal, -100}));
+ EXPECT_EQ(VecFuncParameters[3],
+ VFParameter({3, VFParamKind::OMP_LinearRef, -1000}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseScalableSVE) {
- EXPECT_TRUE(invokeParser("_ZGVsMxv_sin(custom_vg)", "sin", "i32(i32)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getScalable(4));
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "custom_vg");
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseFixedWidthSVE) {
- EXPECT_TRUE(invokeParser("_ZGVsM2v_sin", "", "double(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVsM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "_ZGVsM2v_sin");
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, NotAVectorFunctionABIName) {
// Vector names should start with `_ZGV`.
- EXPECT_FALSE(invokeParser("ZGVnN2v_sin"));
+ EXPECT_FALSE(invokeParser("ZGVnN2v_foo"));
}
TEST_F(VFABIParserTest, LinearWithRuntimeStep) {
- EXPECT_FALSE(invokeParser("_ZGVnN2ls_sin"))
+ EXPECT_FALSE(invokeParser("_ZGVnN2ls_foo"))
<< "A number should be present after \"ls\".";
- EXPECT_TRUE(invokeParser("_ZGVnN2ls2_sin"));
- EXPECT_FALSE(invokeParser("_ZGVnN2Rs_sin"))
+ EXPECT_TRUE(invokeParser("_ZGVnN2ls2_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVnN2Rs_foo"))
<< "A number should be present after \"Rs\".";
- EXPECT_TRUE(invokeParser("_ZGVnN2Rs4_sin"));
- EXPECT_FALSE(invokeParser("_ZGVnN2Ls_sin"))
+ EXPECT_TRUE(invokeParser("_ZGVnN2Rs4_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVnN2Ls_foo"))
<< "A number should be present after \"Ls\".";
- EXPECT_TRUE(invokeParser("_ZGVnN2Ls6_sin"));
- EXPECT_FALSE(invokeParser("_ZGVnN2Us_sin"))
+ EXPECT_TRUE(invokeParser("_ZGVnN2Ls6_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVnN2Us_foo"))
<< "A number should be present after \"Us\".";
- EXPECT_TRUE(invokeParser("_ZGVnN2Us8_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2Us8_foo"));
}
TEST_F(VFABIParserTest, LinearWithoutCompileTime) {
- EXPECT_TRUE(invokeParser("_ZGVnN3lLRUlnLnRnUn_sin", "",
+ EXPECT_TRUE(invokeParser("_ZGVnN3lLRUlnLnRnUn_foo(vector_foo)",
"void(i32, i32, ptr, i32, i32, i32, ptr, i32)"));
- EXPECT_TRUE(matchScalarParametersNum());
- EXPECT_EQ(Parameters.size(), (unsigned)8);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, 1}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, 1}));
- EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearRef, 1}));
- EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearUVal, 1}));
- EXPECT_EQ(Parameters[4], VFParameter({4, VFParamKind::OMP_Linear, -1}));
- EXPECT_EQ(Parameters[5], VFParameter({5, VFParamKind::OMP_LinearVal, -1}));
- EXPECT_EQ(Parameters[6], VFParameter({6, VFParamKind::OMP_LinearRef, -1}));
- EXPECT_EQ(Parameters[7], VFParameter({7, VFParamKind::OMP_LinearUVal, -1}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)8);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::OMP_Linear, 1}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::OMP_LinearVal, 1}));
+ EXPECT_EQ(VecFuncParameters[2],
+ VFParameter({2, VFParamKind::OMP_LinearRef, 1}));
+ EXPECT_EQ(VecFuncParameters[3],
+ VFParameter({3, VFParamKind::OMP_LinearUVal, 1}));
+ EXPECT_EQ(VecFuncParameters[4],
+ VFParameter({4, VFParamKind::OMP_Linear, -1}));
+ EXPECT_EQ(VecFuncParameters[5],
+ VFParameter({5, VFParamKind::OMP_LinearVal, -1}));
+ EXPECT_EQ(VecFuncParameters[6],
+ VFParameter({6, VFParamKind::OMP_LinearRef, -1}));
+ EXPECT_EQ(VecFuncParameters[7],
+ VFParameter({7, VFParamKind::OMP_LinearUVal, -1}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ISA) {
- EXPECT_TRUE(invokeParser("_ZGVqN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVqN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::Unknown);
- EXPECT_TRUE(invokeParser("_ZGVnN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_TRUE(invokeParser("_ZGVsN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVsN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_TRUE(invokeParser("_ZGVbN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVbN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::SSE);
- EXPECT_TRUE(invokeParser("_ZGVcN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVcN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::AVX);
- EXPECT_TRUE(invokeParser("_ZGVdN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVdN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::AVX2);
- EXPECT_TRUE(invokeParser("_ZGVeN2v_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVeN2v_foo"));
EXPECT_EQ(ISA, VFISAKind::AVX512);
}
TEST_F(VFABIParserTest, LLVM_ISA) {
- EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_sin"));
- EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_sin_(vector_name)", "vector_name"));
+ EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
+ EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
EXPECT_EQ(ISA, VFISAKind::LLVM);
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, InvalidMask) {
- EXPECT_FALSE(invokeParser("_ZGVsK2v_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVsK2v_foo"));
}
TEST_F(VFABIParserTest, InvalidParameter) {
- EXPECT_FALSE(invokeParser("_ZGVsM2vX_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVsM2vX_foo"));
}
TEST_F(VFABIParserTest, Align) {
- EXPECT_TRUE(invokeParser("_ZGVsN2l2a2_sin", "", "void(i32)"));
- EXPECT_TRUE(matchScalarParametersNum());
- EXPECT_EQ(Parameters.size(), (unsigned)1);
- EXPECT_EQ(Parameters[0].Alignment, Align(2));
+ EXPECT_TRUE(invokeParser("_ZGVsN2l2a2_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
+ EXPECT_EQ(VecFuncParameters[0].Alignment, Align(2));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
// Missing alignment value.
- EXPECT_FALSE(invokeParser("_ZGVsM2l2a_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVsM2l2a_foo"));
// Invalid alignment token "x".
- EXPECT_FALSE(invokeParser("_ZGVsM2l2ax_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVsM2l2ax_foo"));
// Alignment MUST be associated to a paramater.
- EXPECT_FALSE(invokeParser("_ZGVsM2a2_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVsM2a2_foo"));
// Alignment must be a power of 2.
- EXPECT_FALSE(invokeParser("_ZGVsN2l2a0_sin"));
- EXPECT_TRUE(invokeParser("_ZGVsN2l2a1_sin"));
- EXPECT_FALSE(invokeParser("_ZGVsN2l2a3_sin"));
- EXPECT_FALSE(invokeParser("_ZGVsN2l2a6_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVsN2l2a0_foo"));
+ EXPECT_TRUE(invokeParser("_ZGVsN2l2a1_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVsN2l2a3_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVsN2l2a6_foo"));
}
TEST_F(VFABIParserTest, ParseUniform) {
- EXPECT_TRUE(invokeParser("_ZGVnN2u_sin", "", "void(i32)"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2u_foo(vector_foo)", "void(i32)"));
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(Parameters.size(), (unsigned)1);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Uniform, 0}));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "_ZGVnN2u_sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
+ EXPECT_EQ(VecFuncParameters[0],
+ VFParameter({0, VFParamKind::OMP_Uniform, 0}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
// Uniform doesn't expect extra data.
- EXPECT_FALSE(invokeParser("_ZGVnN2u0_sin"));
+ EXPECT_FALSE(invokeParser("_ZGVnN2u0_foo"));
}
TEST_F(VFABIParserTest, ISAIndependentMangling) {
// This test makes sure that the mangling of the parameters in
// independent on the <isa> token.
+ const StringRef IRTy =
+ "void(i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32)";
const SmallVector<VFParameter, 8> ExpectedParams = {
VFParameter({0, VFParamKind::Vector, 0}),
VFParameter({1, VFParamKind::OMP_LinearPos, 2}),
@@ -374,72 +406,62 @@ TEST_F(VFABIParserTest, ISAIndependentMangling) {
do { \
EXPECT_EQ(VF, ElementCount::getFixed(2)); \
EXPECT_FALSE(isMasked()); \
- EXPECT_TRUE(matchScalarParametersNum()); \
- EXPECT_EQ(Parameters.size(), (unsigned)10); \
- EXPECT_EQ(Parameters, ExpectedParams); \
- EXPECT_EQ(ScalarName, "sin"); \
+ EXPECT_TRUE(matchScalarParamNum()) \
+ << "Different number of Scalar parameters"; \
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)10); \
+ EXPECT_EQ(VecFuncParameters, ExpectedParams); \
+ EXPECT_EQ(ScalarName, "foo"); \
+ EXPECT_EQ(VectorName, "vector_foo"); \
} while (0)
- const StringRef IRTy =
- "void(double, i32, i32, i32, ptr, i32, i32, i32, i32, i32)";
-
// Advanced SIMD: <isa> = "n"
- EXPECT_TRUE(
- invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// SVE: <isa> = "s"
- EXPECT_TRUE(
- invokeParser("_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::SVE);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// SSE: <isa> = "b"
- EXPECT_TRUE(
- invokeParser("_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::SSE);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX: <isa> = "c"
- EXPECT_TRUE(
- invokeParser("_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::AVX);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX2: <isa> = "d"
- EXPECT_TRUE(
- invokeParser("_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::AVX2);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX512: <isa> = "e"
- EXPECT_TRUE(
- invokeParser("_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::AVX512);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// LLVM: <isa> = "_LLVM_" internal vector function.
- EXPECT_TRUE(
- invokeParser("_ZGV_LLVM_N2vls2Ls27Us4Rs5l1L10U100R1000u_sin(vectorf)",
- "vectorf", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGV_LLVM_N2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::LLVM);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "vectorf");
// Unknown ISA (randomly using "q"). This test will need update if
// some targets decide to use "q" as their ISA token.
- EXPECT_TRUE(
- invokeParser("_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin", "", IRTy));
+ EXPECT_TRUE(invokeParser(
+ "_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_foo(vector_foo)", IRTy));
EXPECT_EQ(ISA, VFISAKind::Unknown);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
#undef __COMMON_CHECKS
}
@@ -457,123 +479,181 @@ TEST_F(VFABIParserTest, MissingVectorNameTermination) {
}
TEST_F(VFABIParserTest, ParseMaskingNEON) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v_sin", "", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingSVE) {
- EXPECT_TRUE(invokeParser("_ZGVsM2v_sin", "", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVsM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingSSE) {
- EXPECT_TRUE(invokeParser("_ZGVbM2v_sin", "", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVbM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SSE);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX) {
- EXPECT_TRUE(invokeParser("_ZGVcM2v_sin", "", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVcM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX2) {
- EXPECT_TRUE(invokeParser("_ZGVdM2v_sin", "", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVdM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX2);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX512) {
- EXPECT_TRUE(invokeParser("_ZGVeM2v_sin", "", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVeM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX512);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingLLVM) {
- EXPECT_TRUE(invokeParser("_ZGV_LLVM_M2v_sin(custom_vector_sin)",
- "custom_vector_sin", "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGV_LLVM_M2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "custom_vector_sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseScalableMaskingLLVM) {
- EXPECT_FALSE(
- invokeParser("_ZGV_LLVM_Mxv_sin(custom_vector_sin)", "sin", "i32(i32)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_FALSE(invokeParser("_ZGV_LLVM_Mxv_foo(vector_foo)"));
+}
+
+TEST_F(VFABIParserTest, LLVM_InternalISA) {
+ EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
+ EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(ISA, VFISAKind::LLVM);
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
+}
+
+TEST_F(VFABIParserTest, IntrinsicsInLLVMIsa) {
+ EXPECT_TRUE(invokeParser("_ZGV_LLVM_N4vv_llvm.pow.f32(__svml_powf4)",
+ "void(float, float)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(4));
+ EXPECT_FALSE(isMasked());
+ EXPECT_EQ(ISA, VFISAKind::LLVM);
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1], VFParameter({1, VFParamKind::Vector}));
+ EXPECT_EQ(ScalarName, "llvm.pow.f32");
+ EXPECT_EQ(VectorName, "__svml_powf4");
+}
+
+TEST_F(VFABIParserTest, ParseScalableRequiresDeclaration) {
+ const char *MangledName = "_ZGVsMxv_sin(custom_vg)";
+ // The parser succeeds only when the correct function definition of
+ // `custom_vg` is added to the module.
+ EXPECT_FALSE(invokeParser(MangledName));
+ EXPECT_TRUE(invokeParser(MangledName, "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "sin");
+ EXPECT_EQ(VectorName, "custom_vg");
+}
+
+TEST_F(VFABIParserTest, ZeroIsInvalidVLEN) {
+ EXPECT_FALSE(invokeParser("_ZGVeM0v_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVeN0v_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVsM0v_foo"));
+ EXPECT_FALSE(invokeParser("_ZGVsN0v_foo"));
}
TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
- EXPECT_TRUE(
- invokeParser("_ZGVsMxv_sin(custom_vector_sin)", "sin", "i32(i32)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "i32(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_TRUE(isMasked());
EXPECT_EQ(VF, ElementCount::getScalable(4));
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
- EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "custom_vector_sin");
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
EXPECT_TRUE(invokeParser("_ZGVsMxvl8l8_sincos(custom_vector_sincos)",
- "sincos", "void(double, ptr, ptr)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ "void(double, ptr, ptr)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getScalable(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(Parameters.size(), (unsigned)4);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 8}));
- EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_Linear, 8}));
- EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)4);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1], VFParameter({1, VFParamKind::OMP_Linear, 8}));
+ EXPECT_EQ(VecFuncParameters[2], VFParameter({2, VFParamKind::OMP_Linear, 8}));
+ EXPECT_EQ(VecFuncParameters[3],
+ VFParameter({3, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "sincos");
EXPECT_EQ(VectorName, "custom_vector_sincos");
}
@@ -581,27 +661,39 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
// Make sure that we get the correct VF if the return type is wider than any
// parameter type.
TEST_F(VFABIParserTest, ParseWiderReturnTypeSVE) {
- EXPECT_TRUE(
- invokeParser("_ZGVsMxvv_foo(vector_foo)", "foo", "i64(i32, i32)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVsMxvv_foo(vector_foo)", "i64(i32, i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)3);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1], VFParameter({1, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[2],
+ VFParameter({2, VFParamKind::GlobalPredicate}));
EXPECT_EQ(VF, ElementCount::getScalable(2));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
// Make sure we handle void return types.
TEST_F(VFABIParserTest, ParseVoidReturnTypeSVE) {
- EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "foo", "void(i16)"));
- EXPECT_TRUE(matchScalarParametersNum());
+ EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i16)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
+ EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(VecFuncParameters[1],
+ VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(VF, ElementCount::getScalable(8));
+ EXPECT_EQ(ScalarName, "foo");
+ EXPECT_EQ(VectorName, "vector_foo");
}
// Make sure we reject unsupported parameter types.
TEST_F(VFABIParserTest, ParseUnsupportedElementTypeSVE) {
- EXPECT_FALSE(invokeParser("_ZGVsMxv_foo(vector_foo)", "foo", "void(i128)"));
+ EXPECT_FALSE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i128)"));
}
// Make sure we reject unsupported return types
TEST_F(VFABIParserTest, ParseUnsupportedReturnTypeSVE) {
- EXPECT_FALSE(invokeParser("_ZGVsMxv_foo(vector_foo)", "foo", "fp128(float)"));
+ EXPECT_FALSE(invokeParser("_ZGVsMxv_foo(vector_foo)", "fp128(float)"));
}
class VFABIAttrTest : public testing::Test {
protected:
@@ -637,43 +729,6 @@ TEST_F(VFABIAttrTest, Read) {
EXPECT_EQ(Mappings, Exp);
}
-TEST_F(VFABIParserTest, LLVM_InternalISA) {
- EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_sin"));
- EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_sin_(vector_name)", "vector_name",
- "void(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
- EXPECT_EQ(ISA, VFISAKind::LLVM);
-}
-
-TEST_F(VFABIParserTest, IntrinsicsInLLVMIsa) {
- EXPECT_TRUE(invokeParser("_ZGV_LLVM_N4vv_llvm.pow.f32(__svml_powf4)",
- "__svml_powf4", "void(float, float)"));
- EXPECT_TRUE(matchScalarParametersNum());
- EXPECT_EQ(VF, ElementCount::getFixed(4));
- EXPECT_FALSE(isMasked());
- EXPECT_EQ(ISA, VFISAKind::LLVM);
- EXPECT_EQ(Parameters.size(), (unsigned)2);
- EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::Vector}));
- EXPECT_EQ(ScalarName, "llvm.pow.f32");
-}
-
-TEST_F(VFABIParserTest, ParseScalableRequiresDeclaration) {
- const char *MangledName = "_ZGVsMxv_sin(custom_vg)";
- // The parser succeds only when the correct function definition of
- // `custom_vg` is added to the module.
- EXPECT_FALSE(invokeParser(MangledName));
- EXPECT_TRUE(invokeParser(MangledName, "sin", "double(double)"));
- EXPECT_TRUE(matchScalarParametersNum());
-}
-
-TEST_F(VFABIParserTest, ZeroIsInvalidVLEN) {
- EXPECT_FALSE(invokeParser("_ZGVeM0v_sin"));
- EXPECT_FALSE(invokeParser("_ZGVeN0v_sin"));
- EXPECT_FALSE(invokeParser("_ZGVsM0v_sin"));
- EXPECT_FALSE(invokeParser("_ZGVsN0v_sin"));
-}
-
static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
std::unique_ptr<Module> Mod = parseAssemblyString(IR, Err, C);
>From cd99514c5dca0f24c38260320945441bcb506691 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Thu, 30 Nov 2023 17:51:23 +0000
Subject: [PATCH 03/10] Addressing 2nd review round.
- Clean up duplicate ISA tests.
- Added an extra test to clearly show that the mangled name becomes the
VectorName, when no VectorName is specified.
---
.../Analysis/VectorFunctionABITest.cpp | 68 +++++++------------
1 file changed, 24 insertions(+), 44 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 50c3fdebd762fe..3adf6e97a7b7dd 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -21,18 +21,15 @@ class VFABIParserTest : public ::testing::Test {
// Parser output.
VFInfo Info;
// Reset the data needed for the test.
- void reset(const StringRef Name, const StringRef IRType) {
+ void reset(const StringRef SFunTy) {
M = parseAssemblyString("declare void @dummy()", Err, Ctx);
EXPECT_NE(M.get(), nullptr) << "Loading an invalid module.\n "
<< Err.getMessage() << "\n";
- Type *Ty = parseType(IRType, Err, *(M.get()));
- FTy = dyn_cast<FunctionType>(Ty);
- EXPECT_NE(FTy, nullptr) << "Invalid function type string: " << IRType
+ Type *Ty = parseType(SFunTy, Err, *(M.get()));
+ ScalarFTy = dyn_cast<FunctionType>(Ty);
+ EXPECT_NE(ScalarFTy, nullptr) << "Invalid function type string: " << SFunTy
<< "\n"
<< Err.getMessage() << "\n";
- F = M->getOrInsertFunction(Name, FTy);
- EXPECT_NE(F.getCallee(), nullptr)
- << "The function must be present in the module\n";
// Reset the VFInfo
Info = VFInfo();
ScalarFuncParametersNum = 0;
@@ -42,7 +39,7 @@ class VFABIParserTest : public ::testing::Test {
LLVMContext Ctx;
SMDiagnostic Err;
std::unique_ptr<Module> M;
- FunctionType *FTy = nullptr;
+ FunctionType *ScalarFTy = nullptr;
FunctionCallee F;
protected:
@@ -64,23 +61,23 @@ class VFABIParserTest : public ::testing::Test {
// use to create the function in the module if it differs from the
// standard mangled name.
//
- // \p IRType -> FunctionType string to be used for the signature of
+ // \p STy -> FunctionType string to be used for the signature of
// the vector function. The correct signature is needed by the
// parser only for scalable functions. For the sake of testing, the
// generic fixed-length case can use as signature `void()`.
//
bool invokeParser(const StringRef MangledName,
- const StringRef IRType = "void()") {
- // Reset the VFInfo and the Module to be able to invoke
- // `invokeParser` multiple times in the same test.
- reset(MangledName, IRType);
+ const StringRef SFunTy = "void()") {
+ // Reset the VFInfo and the Module to be able to invoke `invokeParser`
+ // multiple times in the same test.
+ reset(SFunTy);
// Fake the arguments to the CallInst.
- const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, FTy);
+ const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, ScalarFTy);
if (OptInfo) {
Info = *OptInfo;
ScalarFuncParametersNum =
- Info.Shape.getScalarShape(FTy).Parameters.size();
+ Info.Shape.getScalarShape(ScalarFTy).Parameters.size();
return true;
}
return false;
@@ -138,7 +135,7 @@ TEST_F(VFABIParserTest, OnlyValidNames) {
}
TEST_F(VFABIParserTest, ParamListParsing) {
- EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo(vector_foo)",
+ EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo",
"void(i32, i32, i32, ptr, i32)"));
EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VecFuncParameters.size(), (unsigned)5);
@@ -151,7 +148,7 @@ TEST_F(VFABIParserTest, ParamListParsing) {
VFParameter({3, VFParamKind::OMP_LinearRef, 3}));
EXPECT_EQ(VecFuncParameters[4], VFParameter({4, VFParamKind::OMP_Linear, 1}));
EXPECT_EQ(ScalarName, "foo");
- EXPECT_EQ(VectorName, "vector_foo");
+ EXPECT_EQ(VectorName, "_ZGVnN2vl16Ls32R3l_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_01) {
@@ -172,9 +169,17 @@ TEST_F(VFABIParserTest, ScalarNameAndVectorName_03) {
EXPECT_EQ(VectorName, "fooBarAbcVec");
}
+TEST_F(VFABIParserTest, ScalarNameOnly) {
+ EXPECT_TRUE(invokeParser("_ZGVnM2v___foo_bar_abc"));
+ EXPECT_EQ(ScalarName, "__foo_bar_abc");
+ // no vector name specified (as it's optional), so it should have the entire
+ // mangled name.
+ EXPECT_EQ(VectorName, "_ZGVnM2v___foo_bar_abc");
+}
+
TEST_F(VFABIParserTest, Parse) {
EXPECT_TRUE(
- invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo(vector_foo)",
+ invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo",
"void(i32, i32, i32, i32, ptr, i32, i32, i32, ptr)"));
EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
@@ -198,7 +203,7 @@ TEST_F(VFABIParserTest, Parse) {
EXPECT_EQ(VecFuncParameters[8],
VFParameter({8, VFParamKind::OMP_LinearRef, 1000}));
EXPECT_EQ(ScalarName, "foo");
- EXPECT_EQ(VectorName, "vector_foo");
+ EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo");
}
TEST_F(VFABIParserTest, ParseVectorName) {
@@ -305,29 +310,6 @@ TEST_F(VFABIParserTest, LinearWithoutCompileTime) {
EXPECT_EQ(VectorName, "vector_foo");
}
-TEST_F(VFABIParserTest, ISA) {
- EXPECT_TRUE(invokeParser("_ZGVqN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::Unknown);
-
- EXPECT_TRUE(invokeParser("_ZGVnN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
-
- EXPECT_TRUE(invokeParser("_ZGVsN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::SVE);
-
- EXPECT_TRUE(invokeParser("_ZGVbN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::SSE);
-
- EXPECT_TRUE(invokeParser("_ZGVcN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::AVX);
-
- EXPECT_TRUE(invokeParser("_ZGVdN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::AVX2);
-
- EXPECT_TRUE(invokeParser("_ZGVeN2v_foo"));
- EXPECT_EQ(ISA, VFISAKind::AVX512);
-}
-
TEST_F(VFABIParserTest, LLVM_ISA) {
EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
@@ -607,8 +589,6 @@ TEST_F(VFABIParserTest, IntrinsicsInLLVMIsa) {
TEST_F(VFABIParserTest, ParseScalableRequiresDeclaration) {
const char *MangledName = "_ZGVsMxv_sin(custom_vg)";
- // The parser succeeds only when the correct function definition of
- // `custom_vg` is added to the module.
EXPECT_FALSE(invokeParser(MangledName));
EXPECT_TRUE(invokeParser(MangledName, "void(i32)"));
EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
>From 7e4f22b0d800775947a4a28cd5c74a108e98f11f Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Thu, 30 Nov 2023 18:58:16 +0000
Subject: [PATCH 04/10] Clang-format issue.
---
llvm/unittests/Analysis/VectorFunctionABITest.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 3adf6e97a7b7dd..64d0399c69a8a0 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -27,9 +27,9 @@ class VFABIParserTest : public ::testing::Test {
<< Err.getMessage() << "\n";
Type *Ty = parseType(SFunTy, Err, *(M.get()));
ScalarFTy = dyn_cast<FunctionType>(Ty);
- EXPECT_NE(ScalarFTy, nullptr) << "Invalid function type string: " << SFunTy
- << "\n"
- << Err.getMessage() << "\n";
+ EXPECT_NE(ScalarFTy, nullptr)
+ << "Invalid function type string: " << SFunTy << "\n"
+ << Err.getMessage() << "\n";
// Reset the VFInfo
Info = VFInfo();
ScalarFuncParametersNum = 0;
@@ -135,8 +135,8 @@ TEST_F(VFABIParserTest, OnlyValidNames) {
}
TEST_F(VFABIParserTest, ParamListParsing) {
- EXPECT_TRUE(invokeParser("_ZGVnN2vl16Ls32R3l_foo",
- "void(i32, i32, i32, ptr, i32)"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVnN2vl16Ls32R3l_foo", "void(i32, i32, i32, ptr, i32)"));
EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
EXPECT_EQ(VecFuncParameters.size(), (unsigned)5);
EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
>From 1bcad8bc7012a3df300b80a17b3a0ea086a702df Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Fri, 1 Dec 2023 10:08:27 +0000
Subject: [PATCH 05/10] Made use for Scalar FunctionTypes more clear.
Removed ScalarFuncParametersNum, and now using the ScalarFTy directly,
that is parsed from the input ScalarFTyStr.
---
.../Analysis/VectorFunctionABITest.cpp | 43 ++++++++-----------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 64d0399c69a8a0..3cd7ba981e6e63 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -32,7 +32,6 @@ class VFABIParserTest : public ::testing::Test {
<< Err.getMessage() << "\n";
// Reset the VFInfo
Info = VFInfo();
- ScalarFuncParametersNum = 0;
}
// Data needed to load the optional IR passed to invokeParser
@@ -47,37 +46,29 @@ class VFABIParserTest : public ::testing::Test {
ElementCount &VF = Info.Shape.VF;
VFISAKind &ISA = Info.ISA;
SmallVector<VFParameter, 8> &VecFuncParameters = Info.Shape.Parameters;
- size_t ScalarFuncParametersNum = 0;
std::string &ScalarName = Info.ScalarName;
std::string &VectorName = Info.VectorName;
- // Invoke the parser. We need to make sure that a function exist in
- // the module because the parser fails if such function don't
- // exists. Every time this method is invoked the state of the test
- // is reset.
- //
- // \p MangledName -> the string the parser has to demangle.
- //
- // \p VectorName -> optional vector name that the method needs to
- // use to create the function in the module if it differs from the
- // standard mangled name.
- //
- // \p STy -> FunctionType string to be used for the signature of
- // the vector function. The correct signature is needed by the
- // parser only for scalable functions. For the sake of testing, the
- // generic fixed-length case can use as signature `void()`.
- //
+
+ /// Invoke the parser. We need to make sure that a function exist in the
+ /// module because the parser fails if such function don't exists. Every time
+ /// this method is invoked the state of the test is reset.
+ ///
+ /// \p MangledName string the parser has to demangle.
+ ///
+ /// \p ScalarFTyStr FunctionType string to be used to get the signature of
+ /// the Scalar function. Used by `tryDemangleForVFABI` to check for the number
+ // of arguments on Scalable vectors, and by `matchScalarParamNum` to perform
+ /// some additional checking in the tests in this file.
bool invokeParser(const StringRef MangledName,
- const StringRef SFunTy = "void()") {
+ const StringRef ScalarFTyStr = "void()") {
// Reset the VFInfo and the Module to be able to invoke `invokeParser`
// multiple times in the same test.
- reset(SFunTy);
+ reset(ScalarFTyStr);
// Fake the arguments to the CallInst.
const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, ScalarFTy);
if (OptInfo) {
Info = *OptInfo;
- ScalarFuncParametersNum =
- Info.Shape.getScalarShape(ScalarFTy).Parameters.size();
return true;
}
return false;
@@ -95,10 +86,12 @@ class VFABIParserTest : public ::testing::Test {
VFParamKind::GlobalPredicate;
}
- // Checks that the number of vectorized parameters matches the scalar ones.
- // Takes into account that vectorized calls may also have a Mask.
+ // Checks that the number of vectorized parameters matches the
+ // scalar ones. This requires a correct scalar FunctionType string to be fed
+ // to the 'invokeParser'. It takes into account that vectorized calls may also
+ // have a Mask.
bool matchScalarParamNum() {
- return (VecFuncParameters.size() - isMasked()) == ScalarFuncParametersNum;
+ return (VecFuncParameters.size() - isMasked()) == ScalarFTy->getNumParams();
}
};
} // unnamed namespace
>From daef7bc37853e876ba9ec4c8614308dcfeb8672f Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Fri, 1 Dec 2023 13:20:41 +0000
Subject: [PATCH 06/10] Fix for demangle-fuzzer tool and minor refactoring
demangle-fuzzer had an extra parenthesis introduced by previous commit
in this PR and it was not formatted properly.
In ABI tests, renamed `reset` parameter to match `invokeParser`, and
did a few more minor styling changes.
---
llvm/unittests/Analysis/VectorFunctionABITest.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 3cd7ba981e6e63..480615228c67d9 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -21,14 +21,14 @@ class VFABIParserTest : public ::testing::Test {
// Parser output.
VFInfo Info;
// Reset the data needed for the test.
- void reset(const StringRef SFunTy) {
+ void reset(const StringRef ScalarFTyStr) {
M = parseAssemblyString("declare void @dummy()", Err, Ctx);
EXPECT_NE(M.get(), nullptr) << "Loading an invalid module.\n "
<< Err.getMessage() << "\n";
- Type *Ty = parseType(SFunTy, Err, *(M.get()));
+ Type *Ty = parseType(ScalarFTyStr, Err, *(M.get()));
ScalarFTy = dyn_cast<FunctionType>(Ty);
EXPECT_NE(ScalarFTy, nullptr)
- << "Invalid function type string: " << SFunTy << "\n"
+ << "Invalid function type string: " << ScalarFTyStr << "\n"
<< Err.getMessage() << "\n";
// Reset the VFInfo
Info = VFInfo();
>From 154401fa9540778ae0c11485e08d48bdb3abbca7 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Mon, 4 Dec 2023 16:27:09 +0000
Subject: [PATCH 07/10] Use VFInfo for `isMasked` and cleanup
Adjusted code and comments to address reviewers.
For masked calls, checking if the last parameter is a mask, only for
SVE and NEON ISAs.
Reverted VecFuncParameters to Parameters.
---
.../Analysis/VectorFunctionABITest.cpp | 344 ++++++++----------
1 file changed, 155 insertions(+), 189 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 480615228c67d9..78007e974f58ce 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -15,12 +15,24 @@
using namespace llvm;
namespace {
-// Test fixture needed that holds the variables needed by the parser.
+/// Perform tests against VFABI Rules. `invokeParser` creates a VFInfo object
+/// and a scalar FunctionType, which are used by tests to check that:
+/// 1. The scalar and vector names are correct.
+/// 2. The parameter number from the parsed mangled name matches the scalar ones
+/// given by the string FunctionType.
+/// 3. The number of vector parameters and their types match the values
+/// specified in the test.
+/// On masked functions, when the VFISAKind is SVE or AdvancedSIMD (NEON) it
+/// also checks that the last parameter is a mask (ie, GlobalPredicate).
+/// TODO: Other VFISAKinds must add such checks according to their ABI
+/// specification.
+/// 4. The function is correctly found to have a mask.
+///
class VFABIParserTest : public ::testing::Test {
private:
// Parser output.
VFInfo Info;
- // Reset the data needed for the test.
+ /// Reset the data needed for the test.
void reset(const StringRef ScalarFTyStr) {
M = parseAssemblyString("declare void @dummy()", Err, Ctx);
EXPECT_NE(M.get(), nullptr) << "Loading an invalid module.\n "
@@ -39,59 +51,47 @@ class VFABIParserTest : public ::testing::Test {
SMDiagnostic Err;
std::unique_ptr<Module> M;
FunctionType *ScalarFTy = nullptr;
- FunctionCallee F;
protected:
// References to the parser output field.
ElementCount &VF = Info.Shape.VF;
VFISAKind &ISA = Info.ISA;
- SmallVector<VFParameter, 8> &VecFuncParameters = Info.Shape.Parameters;
+ /// Parameters for the vectorized function
+ SmallVector<VFParameter, 8> &Parameters = Info.Shape.Parameters;
std::string &ScalarName = Info.ScalarName;
std::string &VectorName = Info.VectorName;
- /// Invoke the parser. We need to make sure that a function exist in the
- /// module because the parser fails if such function don't exists. Every time
- /// this method is invoked the state of the test is reset.
+ /// Invoke the parser. Every time this method is invoked the state of the test
+ /// is reset.
///
/// \p MangledName string the parser has to demangle.
///
/// \p ScalarFTyStr FunctionType string to be used to get the signature of
- /// the Scalar function. Used by `tryDemangleForVFABI` to check for the number
- // of arguments on Scalable vectors, and by `matchScalarParamNum` to perform
- /// some additional checking in the tests in this file.
+ /// the scalar function. Needed by `tryDemangleForVFABI` to check for the
+ /// number of arguments on scalable vectors, and by `matchScalarParamNum` to
+ /// perform some additional checking in the tests in this file.
bool invokeParser(const StringRef MangledName,
const StringRef ScalarFTyStr = "void()") {
- // Reset the VFInfo and the Module to be able to invoke `invokeParser`
- // multiple times in the same test.
+ // Reset the VFInfo to be able to call `invokeParser` multiple times in
+ // the same test.
reset(ScalarFTyStr);
- // Fake the arguments to the CallInst.
const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, ScalarFTy);
- if (OptInfo) {
+ if (OptInfo)
Info = *OptInfo;
- return true;
- }
- return false;
- }
- // Checks that 1. the last Parameter in the Shape is of type
- // VFParamKind::GlobalPredicate and 2. it is the only one of such type.
- bool isMasked() const {
- const auto NGlobalPreds =
- std::count_if(Info.Shape.Parameters.begin(),
- Info.Shape.Parameters.end(), [](const VFParameter PK) {
- return PK.ParamKind == VFParamKind::GlobalPredicate;
- });
- return NGlobalPreds == 1 && Info.Shape.Parameters.back().ParamKind ==
- VFParamKind::GlobalPredicate;
+ return OptInfo.has_value();
}
- // Checks that the number of vectorized parameters matches the
- // scalar ones. This requires a correct scalar FunctionType string to be fed
- // to the 'invokeParser'. It takes into account that vectorized calls may also
- // have a Mask.
+ /// Returns whether the parsed function contains a mask
+ bool isMasked() const { return Info.isMasked(); }
+
+ /// Checks that the number of vectorized parameters matches the
+ /// scalar ones. This requires a correct scalar FunctionType string to be fed
+ /// to the 'invokeParser'. It takes into account that vectorized calls may
+ /// also have a Mask.
bool matchScalarParamNum() {
- return (VecFuncParameters.size() - isMasked()) == ScalarFTy->getNumParams();
+ return (Parameters.size() - isMasked()) == ScalarFTy->getNumParams();
}
};
} // unnamed namespace
@@ -130,34 +130,35 @@ TEST_F(VFABIParserTest, OnlyValidNames) {
TEST_F(VFABIParserTest, ParamListParsing) {
EXPECT_TRUE(
invokeParser("_ZGVnN2vl16Ls32R3l_foo", "void(i32, i32, i32, ptr, i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)5);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::OMP_Linear, 16}));
- EXPECT_EQ(VecFuncParameters[2],
- VFParameter({2, VFParamKind::OMP_LinearValPos, 32}));
- EXPECT_EQ(VecFuncParameters[3],
- VFParameter({3, VFParamKind::OMP_LinearRef, 3}));
- EXPECT_EQ(VecFuncParameters[4], VFParameter({4, VFParamKind::OMP_Linear, 1}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(Parameters.size(), (unsigned)5);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 16}));
+ EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearValPos, 32}));
+ EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearRef, 3}));
+ EXPECT_EQ(Parameters[4], VFParameter({4, VFParamKind::OMP_Linear, 1}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "_ZGVnN2vl16Ls32R3l_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_01) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)"));
+ EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_02) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)"));
+ EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_03) {
- EXPECT_TRUE(invokeParser("_ZGVnM2v___foo_bar_abc(fooBarAbcVec)"));
+ EXPECT_TRUE(
+ invokeParser("_ZGVnM2v___foo_bar_abc(fooBarAbcVec)", "void(i32)"));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(ScalarName, "__foo_bar_abc");
EXPECT_EQ(VectorName, "fooBarAbcVec");
}
@@ -174,39 +175,32 @@ TEST_F(VFABIParserTest, Parse) {
EXPECT_TRUE(
invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo",
"void(i32, i32, i32, i32, ptr, i32, i32, i32, ptr)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)9);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::OMP_LinearPos, 2}));
- EXPECT_EQ(VecFuncParameters[2],
- VFParameter({2, VFParamKind::OMP_LinearValPos, 27}));
- EXPECT_EQ(VecFuncParameters[3],
- VFParameter({3, VFParamKind::OMP_LinearUValPos, 4}));
- EXPECT_EQ(VecFuncParameters[4],
- VFParameter({4, VFParamKind::OMP_LinearRefPos, 5}));
- EXPECT_EQ(VecFuncParameters[5], VFParameter({5, VFParamKind::OMP_Linear, 1}));
- EXPECT_EQ(VecFuncParameters[6],
- VFParameter({6, VFParamKind::OMP_LinearVal, 10}));
- EXPECT_EQ(VecFuncParameters[7],
- VFParameter({7, VFParamKind::OMP_LinearUVal, 100}));
- EXPECT_EQ(VecFuncParameters[8],
- VFParameter({8, VFParamKind::OMP_LinearRef, 1000}));
+ EXPECT_EQ(Parameters.size(), (unsigned)9);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearPos, 2}));
+ EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearValPos, 27}));
+ EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearUValPos, 4}));
+ EXPECT_EQ(Parameters[4], VFParameter({4, VFParamKind::OMP_LinearRefPos, 5}));
+ EXPECT_EQ(Parameters[5], VFParameter({5, VFParamKind::OMP_Linear, 1}));
+ EXPECT_EQ(Parameters[6], VFParameter({6, VFParamKind::OMP_LinearVal, 10}));
+ EXPECT_EQ(Parameters[7], VFParameter({7, VFParamKind::OMP_LinearUVal, 100}));
+ EXPECT_EQ(Parameters[8], VFParameter({8, VFParamKind::OMP_LinearRef, 1000}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo");
}
TEST_F(VFABIParserTest, ParseVectorName) {
EXPECT_TRUE(invokeParser("_ZGVnN2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters.size(), (unsigned)1);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -214,47 +208,41 @@ TEST_F(VFABIParserTest, ParseVectorName) {
TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
EXPECT_TRUE(invokeParser("_ZGVnN2ln1Ln10Un100Rn1000_foo(vector_foo)",
"void(i32, i32, i32, ptr)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)4);
- EXPECT_EQ(VecFuncParameters[0],
- VFParameter({0, VFParamKind::OMP_Linear, -1}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::OMP_LinearVal, -10}));
- EXPECT_EQ(VecFuncParameters[2],
- VFParameter({2, VFParamKind::OMP_LinearUVal, -100}));
- EXPECT_EQ(VecFuncParameters[3],
- VFParameter({3, VFParamKind::OMP_LinearRef, -1000}));
+ EXPECT_EQ(Parameters.size(), (unsigned)4);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, -1}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, -10}));
+ EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearUVal, -100}));
+ EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearRef, -1000}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseScalableSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VF, ElementCount::getScalable(4));
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_EQ(VF, ElementCount::getScalable(4));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseFixedWidthSVE) {
EXPECT_TRUE(invokeParser("_ZGVsM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -282,23 +270,16 @@ TEST_F(VFABIParserTest, LinearWithRuntimeStep) {
TEST_F(VFABIParserTest, LinearWithoutCompileTime) {
EXPECT_TRUE(invokeParser("_ZGVnN3lLRUlnLnRnUn_foo(vector_foo)",
"void(i32, i32, ptr, i32, i32, i32, ptr, i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)8);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::OMP_Linear, 1}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::OMP_LinearVal, 1}));
- EXPECT_EQ(VecFuncParameters[2],
- VFParameter({2, VFParamKind::OMP_LinearRef, 1}));
- EXPECT_EQ(VecFuncParameters[3],
- VFParameter({3, VFParamKind::OMP_LinearUVal, 1}));
- EXPECT_EQ(VecFuncParameters[4],
- VFParameter({4, VFParamKind::OMP_Linear, -1}));
- EXPECT_EQ(VecFuncParameters[5],
- VFParameter({5, VFParamKind::OMP_LinearVal, -1}));
- EXPECT_EQ(VecFuncParameters[6],
- VFParameter({6, VFParamKind::OMP_LinearRef, -1}));
- EXPECT_EQ(VecFuncParameters[7],
- VFParameter({7, VFParamKind::OMP_LinearUVal, -1}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(Parameters.size(), (unsigned)8);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, 1}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, 1}));
+ EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_LinearRef, 1}));
+ EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::OMP_LinearUVal, 1}));
+ EXPECT_EQ(Parameters[4], VFParameter({4, VFParamKind::OMP_Linear, -1}));
+ EXPECT_EQ(Parameters[5], VFParameter({5, VFParamKind::OMP_LinearVal, -1}));
+ EXPECT_EQ(Parameters[6], VFParameter({6, VFParamKind::OMP_LinearRef, -1}));
+ EXPECT_EQ(Parameters[7], VFParameter({7, VFParamKind::OMP_LinearUVal, -1}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -307,9 +288,9 @@ TEST_F(VFABIParserTest, LLVM_ISA) {
EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
EXPECT_EQ(ISA, VFISAKind::LLVM);
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(Parameters.size(), (unsigned)1);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -324,9 +305,9 @@ TEST_F(VFABIParserTest, InvalidParameter) {
TEST_F(VFABIParserTest, Align) {
EXPECT_TRUE(invokeParser("_ZGVsN2l2a2_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
- EXPECT_EQ(VecFuncParameters[0].Alignment, Align(2));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(Parameters.size(), (unsigned)1);
+ EXPECT_EQ(Parameters[0].Alignment, Align(2));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
@@ -346,12 +327,11 @@ TEST_F(VFABIParserTest, Align) {
TEST_F(VFABIParserTest, ParseUniform) {
EXPECT_TRUE(invokeParser("_ZGVnN2u_foo(vector_foo)", "void(i32)"));
EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
- EXPECT_EQ(VecFuncParameters[0],
- VFParameter({0, VFParamKind::OMP_Uniform, 0}));
+ EXPECT_EQ(Parameters.size(), (unsigned)1);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Uniform, 0}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
@@ -382,9 +362,9 @@ TEST_F(VFABIParserTest, ISAIndependentMangling) {
EXPECT_EQ(VF, ElementCount::getFixed(2)); \
EXPECT_FALSE(isMasked()); \
EXPECT_TRUE(matchScalarParamNum()) \
- << "Different number of Scalar parameters"; \
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)10); \
- EXPECT_EQ(VecFuncParameters, ExpectedParams); \
+ << "Different number of scalar parameters"; \
+ EXPECT_EQ(Parameters.size(), (unsigned)10); \
+ EXPECT_EQ(Parameters, ExpectedParams); \
EXPECT_EQ(ScalarName, "foo"); \
EXPECT_EQ(VectorName, "vector_foo"); \
} while (0)
@@ -455,98 +435,86 @@ TEST_F(VFABIParserTest, MissingVectorNameTermination) {
TEST_F(VFABIParserTest, ParseMaskingNEON) {
EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingSVE) {
EXPECT_TRUE(invokeParser("_ZGVsM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingSSE) {
EXPECT_TRUE(invokeParser("_ZGVbM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SSE);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX) {
EXPECT_TRUE(invokeParser("_ZGVcM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX2) {
EXPECT_TRUE(invokeParser("_ZGVdM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX2);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX512) {
EXPECT_TRUE(invokeParser("_ZGVeM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX512);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingLLVM) {
EXPECT_TRUE(invokeParser("_ZGV_LLVM_M2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -558,9 +526,9 @@ TEST_F(VFABIParserTest, ParseScalableMaskingLLVM) {
TEST_F(VFABIParserTest, LLVM_InternalISA) {
EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)1);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(Parameters.size(), (unsigned)1);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ISA, VFISAKind::LLVM);
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
@@ -569,13 +537,13 @@ TEST_F(VFABIParserTest, LLVM_InternalISA) {
TEST_F(VFABIParserTest, IntrinsicsInLLVMIsa) {
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N4vv_llvm.pow.f32(__svml_powf4)",
"void(float, float)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(4));
EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1], VFParameter({1, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "llvm.pow.f32");
EXPECT_EQ(VectorName, "__svml_powf4");
}
@@ -584,11 +552,11 @@ TEST_F(VFABIParserTest, ParseScalableRequiresDeclaration) {
const char *MangledName = "_ZGVsMxv_sin(custom_vg)";
EXPECT_FALSE(invokeParser(MangledName));
EXPECT_TRUE(invokeParser(MangledName, "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "sin");
EXPECT_EQ(VectorName, "custom_vg");
}
@@ -602,14 +570,13 @@ TEST_F(VFABIParserTest, ZeroIsInvalidVLEN) {
TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "i32(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_TRUE(isMasked());
EXPECT_EQ(VF, ElementCount::getScalable(4));
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -617,16 +584,15 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
EXPECT_TRUE(invokeParser("_ZGVsMxvl8l8_sincos(custom_vector_sincos)",
"void(double, ptr, ptr)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getScalable(2));
EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)4);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1], VFParameter({1, VFParamKind::OMP_Linear, 8}));
- EXPECT_EQ(VecFuncParameters[2], VFParameter({2, VFParamKind::OMP_Linear, 8}));
- EXPECT_EQ(VecFuncParameters[3],
- VFParameter({3, VFParamKind::GlobalPredicate}));
+ EXPECT_EQ(Parameters.size(), (unsigned)4);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 8}));
+ EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::OMP_Linear, 8}));
+ EXPECT_EQ(Parameters[3], VFParameter({3, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "sincos");
EXPECT_EQ(VectorName, "custom_vector_sincos");
}
@@ -635,12 +601,12 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
// parameter type.
TEST_F(VFABIParserTest, ParseWiderReturnTypeSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxvv_foo(vector_foo)", "i64(i32, i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)3);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1], VFParameter({1, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[2],
- VFParameter({2, VFParamKind::GlobalPredicate}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_EQ(Parameters.size(), (unsigned)3);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[2], VFParameter({2, VFParamKind::GlobalPredicate}));
EXPECT_EQ(VF, ElementCount::getScalable(2));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
@@ -649,11 +615,11 @@ TEST_F(VFABIParserTest, ParseWiderReturnTypeSVE) {
// Make sure we handle void return types.
TEST_F(VFABIParserTest, ParseVoidReturnTypeSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i16)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of Scalar parameters";
- EXPECT_EQ(VecFuncParameters.size(), (unsigned)2);
- EXPECT_EQ(VecFuncParameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(VecFuncParameters[1],
- VFParameter({1, VFParamKind::GlobalPredicate}));
+ EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_EQ(Parameters.size(), (unsigned)2);
+ EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(VF, ElementCount::getScalable(8));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
>From 4713f9590512800d686c0bbf4166583bfeb03c9d Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Thu, 7 Dec 2023 16:23:53 +0000
Subject: [PATCH 08/10] Restored checks for predicates.
Checks in tests are now added in the same order:
1. Verify ISA
2. Verify presence/absence of a mask
3. match the number of parameters
Appended the tests if any of those were missing.
---
.../Analysis/VectorFunctionABITest.cpp | 156 ++++++++++--------
1 file changed, 90 insertions(+), 66 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 78007e974f58ce..84e969d093067c 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -67,9 +67,9 @@ class VFABIParserTest : public ::testing::Test {
/// \p MangledName string the parser has to demangle.
///
/// \p ScalarFTyStr FunctionType string to be used to get the signature of
- /// the scalar function. Needed by `tryDemangleForVFABI` to check for the
- /// number of arguments on scalable vectors, and by `matchScalarParamNum` to
- /// perform some additional checking in the tests in this file.
+ /// the scalar function. Used by `tryDemangleForVFABI` to check for the number
+ /// of arguments on scalable vectors, and by `matchParameters` to perform
+ /// some additional checking in the tests in this file.
bool invokeParser(const StringRef MangledName,
const StringRef ScalarFTyStr = "void()") {
// Reset the VFInfo to be able to call `invokeParser` multiple times in
@@ -86,11 +86,11 @@ class VFABIParserTest : public ::testing::Test {
/// Returns whether the parsed function contains a mask
bool isMasked() const { return Info.isMasked(); }
- /// Checks that the number of vectorized parameters matches the
- /// scalar ones. This requires a correct scalar FunctionType string to be fed
- /// to the 'invokeParser'. It takes into account that vectorized calls may
- /// also have a Mask.
- bool matchScalarParamNum() {
+ /// Check the number of vectorized parameters matches the scalar ones. This
+ /// requires a correct scalar FunctionType string to be fed to the
+ /// 'invokeParser'. Mask parameters that are only required by the vector
+ /// function call are ignored.
+ bool matchParametersNum() {
return (Parameters.size() - isMasked()) == ScalarFTy->getNumParams();
}
};
@@ -130,7 +130,9 @@ TEST_F(VFABIParserTest, OnlyValidNames) {
TEST_F(VFABIParserTest, ParamListParsing) {
EXPECT_TRUE(
invokeParser("_ZGVnN2vl16Ls32R3l_foo", "void(i32, i32, i32, ptr, i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_EQ(false, isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)5);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 16}));
@@ -143,14 +145,18 @@ TEST_F(VFABIParserTest, ParamListParsing) {
TEST_F(VFABIParserTest, ScalarNameAndVectorName_01) {
EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_EQ(true, isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ScalarNameAndVectorName_02) {
EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_EQ(true, isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -158,13 +164,17 @@ TEST_F(VFABIParserTest, ScalarNameAndVectorName_02) {
TEST_F(VFABIParserTest, ScalarNameAndVectorName_03) {
EXPECT_TRUE(
invokeParser("_ZGVnM2v___foo_bar_abc(fooBarAbcVec)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_EQ(true, isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(ScalarName, "__foo_bar_abc");
EXPECT_EQ(VectorName, "fooBarAbcVec");
}
TEST_F(VFABIParserTest, ScalarNameOnly) {
EXPECT_TRUE(invokeParser("_ZGVnM2v___foo_bar_abc"));
+ EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_EQ(true, isMasked());
EXPECT_EQ(ScalarName, "__foo_bar_abc");
// no vector name specified (as it's optional), so it should have the entire
// mangled name.
@@ -175,10 +185,10 @@ TEST_F(VFABIParserTest, Parse) {
EXPECT_TRUE(
invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000_foo",
"void(i32, i32, i32, i32, ptr, i32, i32, i32, ptr)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)9);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearPos, 2}));
@@ -195,10 +205,10 @@ TEST_F(VFABIParserTest, Parse) {
TEST_F(VFABIParserTest, ParseVectorName) {
EXPECT_TRUE(invokeParser("_ZGVnN2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector, 0}));
EXPECT_EQ(ScalarName, "foo");
@@ -208,10 +218,10 @@ TEST_F(VFABIParserTest, ParseVectorName) {
TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
EXPECT_TRUE(invokeParser("_ZGVnN2ln1Ln10Un100Rn1000_foo(vector_foo)",
"void(i32, i32, i32, ptr)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)4);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, -1}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, -10}));
@@ -223,9 +233,9 @@ TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
TEST_F(VFABIParserTest, ParseScalableSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getScalable(4));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -236,9 +246,9 @@ TEST_F(VFABIParserTest, ParseScalableSVE) {
TEST_F(VFABIParserTest, ParseFixedWidthSVE) {
EXPECT_TRUE(invokeParser("_ZGVsM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
@@ -270,7 +280,9 @@ TEST_F(VFABIParserTest, LinearWithRuntimeStep) {
TEST_F(VFABIParserTest, LinearWithoutCompileTime) {
EXPECT_TRUE(invokeParser("_ZGVnN3lLRUlnLnRnUn_foo(vector_foo)",
"void(i32, i32, ptr, i32, i32, i32, ptr, i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)8);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Linear, 1}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_LinearVal, 1}));
@@ -288,7 +300,8 @@ TEST_F(VFABIParserTest, LLVM_ISA) {
EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
EXPECT_EQ(ISA, VFISAKind::LLVM);
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(ScalarName, "foo");
@@ -305,7 +318,9 @@ TEST_F(VFABIParserTest, InvalidParameter) {
TEST_F(VFABIParserTest, Align) {
EXPECT_TRUE(invokeParser("_ZGVsN2l2a2_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0].Alignment, Align(2));
EXPECT_EQ(ScalarName, "foo");
@@ -326,10 +341,10 @@ TEST_F(VFABIParserTest, Align) {
TEST_F(VFABIParserTest, ParseUniform) {
EXPECT_TRUE(invokeParser("_ZGVnN2u_foo(vector_foo)", "void(i32)"));
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Uniform, 0}));
EXPECT_EQ(ScalarName, "foo");
@@ -361,7 +376,7 @@ TEST_F(VFABIParserTest, ISAIndependentMangling) {
do { \
EXPECT_EQ(VF, ElementCount::getFixed(2)); \
EXPECT_FALSE(isMasked()); \
- EXPECT_TRUE(matchScalarParamNum()) \
+ EXPECT_TRUE(matchParametersNum()) \
<< "Different number of scalar parameters"; \
EXPECT_EQ(Parameters.size(), (unsigned)10); \
EXPECT_EQ(Parameters, ExpectedParams); \
@@ -435,10 +450,10 @@ TEST_F(VFABIParserTest, MissingVectorNameTermination) {
TEST_F(VFABIParserTest, ParseMaskingNEON) {
EXPECT_TRUE(invokeParser("_ZGVnM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
@@ -448,10 +463,10 @@ TEST_F(VFABIParserTest, ParseMaskingNEON) {
TEST_F(VFABIParserTest, ParseMaskingSVE) {
EXPECT_TRUE(invokeParser("_ZGVsM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
@@ -461,60 +476,65 @@ TEST_F(VFABIParserTest, ParseMaskingSVE) {
TEST_F(VFABIParserTest, ParseMaskingSSE) {
EXPECT_TRUE(invokeParser("_ZGVbM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SSE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX) {
EXPECT_TRUE(invokeParser("_ZGVcM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX2) {
EXPECT_TRUE(invokeParser("_ZGVdM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX2);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingAVX512) {
EXPECT_TRUE(invokeParser("_ZGVeM2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::AVX512);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
TEST_F(VFABIParserTest, ParseMaskingLLVM) {
EXPECT_TRUE(invokeParser("_ZGV_LLVM_M2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(2));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
+ EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -526,10 +546,11 @@ TEST_F(VFABIParserTest, ParseScalableMaskingLLVM) {
TEST_F(VFABIParserTest, LLVM_InternalISA) {
EXPECT_FALSE(invokeParser("_ZGV_LLVM_N2v_foo"));
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N2v_foo(vector_foo)", "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::LLVM);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
- EXPECT_EQ(ISA, VFISAKind::LLVM);
EXPECT_EQ(ScalarName, "foo");
EXPECT_EQ(VectorName, "vector_foo");
}
@@ -537,10 +558,10 @@ TEST_F(VFABIParserTest, LLVM_InternalISA) {
TEST_F(VFABIParserTest, IntrinsicsInLLVMIsa) {
EXPECT_TRUE(invokeParser("_ZGV_LLVM_N4vv_llvm.pow.f32(__svml_powf4)",
"void(float, float)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getFixed(4));
- EXPECT_FALSE(isMasked());
EXPECT_EQ(ISA, VFISAKind::LLVM);
+ EXPECT_FALSE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getFixed(4));
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::Vector}));
@@ -552,8 +573,9 @@ TEST_F(VFABIParserTest, ParseScalableRequiresDeclaration) {
const char *MangledName = "_ZGVsMxv_sin(custom_vg)";
EXPECT_FALSE(invokeParser(MangledName));
EXPECT_TRUE(invokeParser(MangledName, "void(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
@@ -570,10 +592,10 @@ TEST_F(VFABIParserTest, ZeroIsInvalidVLEN) {
TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "i32(i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(VF, ElementCount::getScalable(4));
- EXPECT_EQ(ISA, VFISAKind::SVE);
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
@@ -584,10 +606,10 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVE) {
TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
EXPECT_TRUE(invokeParser("_ZGVsMxvl8l8_sincos(custom_vector_sincos)",
"void(double, ptr, ptr)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
- EXPECT_EQ(VF, ElementCount::getScalable(2));
- EXPECT_TRUE(isMasked());
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
+ EXPECT_EQ(VF, ElementCount::getScalable(2));
EXPECT_EQ(Parameters.size(), (unsigned)4);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::OMP_Linear, 8}));
@@ -601,8 +623,9 @@ TEST_F(VFABIParserTest, ParseScalableMaskingSVESincos) {
// parameter type.
TEST_F(VFABIParserTest, ParseWiderReturnTypeSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxvv_foo(vector_foo)", "i64(i32, i32)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)3);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::Vector}));
@@ -615,8 +638,9 @@ TEST_F(VFABIParserTest, ParseWiderReturnTypeSVE) {
// Make sure we handle void return types.
TEST_F(VFABIParserTest, ParseVoidReturnTypeSVE) {
EXPECT_TRUE(invokeParser("_ZGVsMxv_foo(vector_foo)", "void(i16)"));
- EXPECT_TRUE(matchScalarParamNum()) << "Different number of scalar parameters";
EXPECT_EQ(ISA, VFISAKind::SVE);
+ EXPECT_TRUE(isMasked());
+ EXPECT_TRUE(matchParametersNum()) << "Different number of scalar parameters";
EXPECT_EQ(Parameters.size(), (unsigned)2);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::Vector}));
EXPECT_EQ(Parameters[1], VFParameter({1, VFParamKind::GlobalPredicate}));
>From 65e202d4f07713ad9b6f2395759e95ace6710c18 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Thu, 7 Dec 2023 17:59:32 +0000
Subject: [PATCH 09/10] Updated doxygen
---
llvm/unittests/Analysis/VectorFunctionABITest.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 84e969d093067c..34e761dceae00e 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -22,10 +22,8 @@ namespace {
/// given by the string FunctionType.
/// 3. The number of vector parameters and their types match the values
/// specified in the test.
-/// On masked functions, when the VFISAKind is SVE or AdvancedSIMD (NEON) it
-/// also checks that the last parameter is a mask (ie, GlobalPredicate).
-/// TODO: Other VFISAKinds must add such checks according to their ABI
-/// specification.
+/// On masked functions it also checks that the last parameter is a mask (ie,
+/// GlobalPredicate).
/// 4. The function is correctly found to have a mask.
///
class VFABIParserTest : public ::testing::Test {
>From 8fc4f538eadefa38d8737db140fc0ebc3f22d105 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
Date: Mon, 11 Dec 2023 08:47:24 +0000
Subject: [PATCH 10/10] Improved comments.
---
.../Analysis/VectorFunctionABITest.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index 34e761dceae00e..201dd1127ef234 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -18,13 +18,13 @@ namespace {
/// Perform tests against VFABI Rules. `invokeParser` creates a VFInfo object
/// and a scalar FunctionType, which are used by tests to check that:
/// 1. The scalar and vector names are correct.
-/// 2. The parameter number from the parsed mangled name matches the scalar ones
-/// given by the string FunctionType.
+/// 2. The number of parameters from the parsed mangled name matches the number
+/// of arguments in the scalar function passed as FunctionType string.
/// 3. The number of vector parameters and their types match the values
/// specified in the test.
/// On masked functions it also checks that the last parameter is a mask (ie,
/// GlobalPredicate).
-/// 4. The function is correctly found to have a mask.
+/// 4. The vector function is correctly found to have a mask.
///
class VFABIParserTest : public ::testing::Test {
private:
@@ -64,10 +64,10 @@ class VFABIParserTest : public ::testing::Test {
///
/// \p MangledName string the parser has to demangle.
///
- /// \p ScalarFTyStr FunctionType string to be used to get the signature of
- /// the scalar function. Used by `tryDemangleForVFABI` to check for the number
- /// of arguments on scalable vectors, and by `matchParameters` to perform
- /// some additional checking in the tests in this file.
+ /// \p ScalarFTyStr FunctionType string to get the signature of the scalar
+ /// function, which is used by `tryDemangleForVFABI` to check for the number
+ /// of arguments on scalable vectors, and by `matchParameters` to perform some
+ /// additional checking in the tests in this file.
bool invokeParser(const StringRef MangledName,
const StringRef ScalarFTyStr = "void()") {
// Reset the VFInfo to be able to call `invokeParser` multiple times in
@@ -81,10 +81,10 @@ class VFABIParserTest : public ::testing::Test {
return OptInfo.has_value();
}
- /// Returns whether the parsed function contains a mask
+ /// Returns whether the parsed function contains a mask.
bool isMasked() const { return Info.isMasked(); }
- /// Check the number of vectorized parameters matches the scalar ones. This
+ /// Check if the number of vectorized parameters matches the scalar ones. This
/// requires a correct scalar FunctionType string to be fed to the
/// 'invokeParser'. Mask parameters that are only required by the vector
/// function call are ignored.
More information about the llvm-commits
mailing list