Skip to content

Commit 1bcad8b

Browse files
Made use for Scalar FunctionTypes more clear.
Removed ScalarFuncParametersNum, and now using the ScalarFTy directly, that is parsed from the input ScalarFTyStr.
1 parent 7e4f22b commit 1bcad8b

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

llvm/unittests/Analysis/VectorFunctionABITest.cpp

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class VFABIParserTest : public ::testing::Test {
3232
<< Err.getMessage() << "\n";
3333
// Reset the VFInfo
3434
Info = VFInfo();
35-
ScalarFuncParametersNum = 0;
3635
}
3736

3837
// Data needed to load the optional IR passed to invokeParser
@@ -47,37 +46,29 @@ class VFABIParserTest : public ::testing::Test {
4746
ElementCount &VF = Info.Shape.VF;
4847
VFISAKind &ISA = Info.ISA;
4948
SmallVector<VFParameter, 8> &VecFuncParameters = Info.Shape.Parameters;
50-
size_t ScalarFuncParametersNum = 0;
5149
std::string &ScalarName = Info.ScalarName;
5250
std::string &VectorName = Info.VectorName;
53-
// Invoke the parser. We need to make sure that a function exist in
54-
// the module because the parser fails if such function don't
55-
// exists. Every time this method is invoked the state of the test
56-
// is reset.
57-
//
58-
// \p MangledName -> the string the parser has to demangle.
59-
//
60-
// \p VectorName -> optional vector name that the method needs to
61-
// use to create the function in the module if it differs from the
62-
// standard mangled name.
63-
//
64-
// \p STy -> FunctionType string to be used for the signature of
65-
// the vector function. The correct signature is needed by the
66-
// parser only for scalable functions. For the sake of testing, the
67-
// generic fixed-length case can use as signature `void()`.
68-
//
51+
52+
/// Invoke the parser. We need to make sure that a function exist in the
53+
/// module because the parser fails if such function don't exists. Every time
54+
/// this method is invoked the state of the test is reset.
55+
///
56+
/// \p MangledName string the parser has to demangle.
57+
///
58+
/// \p ScalarFTyStr FunctionType string to be used to get the signature of
59+
/// the Scalar function. Used by `tryDemangleForVFABI` to check for the number
60+
// of arguments on Scalable vectors, and by `matchScalarParamNum` to perform
61+
/// some additional checking in the tests in this file.
6962
bool invokeParser(const StringRef MangledName,
70-
const StringRef SFunTy = "void()") {
63+
const StringRef ScalarFTyStr = "void()") {
7164
// Reset the VFInfo and the Module to be able to invoke `invokeParser`
7265
// multiple times in the same test.
73-
reset(SFunTy);
66+
reset(ScalarFTyStr);
7467

7568
// Fake the arguments to the CallInst.
7669
const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, ScalarFTy);
7770
if (OptInfo) {
7871
Info = *OptInfo;
79-
ScalarFuncParametersNum =
80-
Info.Shape.getScalarShape(ScalarFTy).Parameters.size();
8172
return true;
8273
}
8374
return false;
@@ -95,10 +86,12 @@ class VFABIParserTest : public ::testing::Test {
9586
VFParamKind::GlobalPredicate;
9687
}
9788

98-
// Checks that the number of vectorized parameters matches the scalar ones.
99-
// Takes into account that vectorized calls may also have a Mask.
89+
// Checks that the number of vectorized parameters matches the
90+
// scalar ones. This requires a correct scalar FunctionType string to be fed
91+
// to the 'invokeParser'. It takes into account that vectorized calls may also
92+
// have a Mask.
10093
bool matchScalarParamNum() {
101-
return (VecFuncParameters.size() - isMasked()) == ScalarFuncParametersNum;
94+
return (VecFuncParameters.size() - isMasked()) == ScalarFTy->getNumParams();
10295
}
10396
};
10497
} // unnamed namespace

0 commit comments

Comments
 (0)