Skip to content

Commit 7e2ed4a

Browse files
committed
Made VFABI::getVectorFunctionABIVariantString a VecDesc member function,
renamed a macro field and rebased on top of the main branch.
1 parent d419001 commit 7e2ed4a

File tree

6 files changed

+23
-43
lines changed

6 files changed

+23
-43
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class VecDesc {
6161
ElementCount getVectorizationFactor() const { return VectorizationFactor; }
6262
bool isMasked() const { return Masked; }
6363
StringRef getMangledNamePrefix() const { return MangledNamePrefix; }
64+
65+
/// Returns a vector function ABI variant string on the form:
66+
/// _ZGV<isa><mask><vlen><vparams>_<scalarname>(<vectorname>)
67+
std::string getVectorFunctionABIVariantString() const;
6468
};
6569

6670
enum LibFunc : unsigned {

llvm/include/llvm/Analysis/VecFuncs.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#if defined(TLI_DEFINE_MASSV_VECFUNCS_NAMES)
1616
#define TLI_DEFINE_MASSV_VECFUNCS
17-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MANGLN) VEC,
17+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) VEC,
1818
#endif
1919

2020
#define FIXED(NL) ElementCount::getFixed(NL)
@@ -23,7 +23,7 @@
2323
#define MASKED true
2424

2525
#if !(defined(TLI_DEFINE_VECFUNC))
26-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MANGLN) {SCAL, VEC, VF, NOMASK, MANGLN},
26+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) {SCAL, VEC, VF, NOMASK, VABI_PREFIX},
2727
#endif
2828

2929
#if defined(TLI_DEFINE_ACCELERATE_VECFUNCS)

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,26 +182,6 @@ static constexpr char const *_LLVM_Scalarize_ = "_LLVM_Scalarize_";
182182
std::optional<VFInfo> tryDemangleForVFABI(StringRef MangledName,
183183
const Module &M);
184184

185-
/// Describes a possible vectorization of a function.
186-
/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
187-
/// by a factor 'VectorizationFactor'.
188-
/// The MangledName string holds scalar-to-vector mapping:
189-
/// _ZGV<isa><mask><vlen><vparams>_<scalarname>(<vectorname>)
190-
///
191-
/// where:
192-
///
193-
/// <isa> = "_LLVM_"
194-
/// <mask> = "M" if masked, "N" if no mask.
195-
/// <vlen> = Number of concurrent lanes, stored in the `VectorizationFactor`
196-
/// field of the `VecDesc` struct. If the number of lanes is scalable
197-
/// then 'x' is printed instead.
198-
/// <vparams> = "v", as many as the function arguments.
199-
/// <scalarname> = the name of the scalar function.
200-
/// <vectorname> = the name of the vector function.
201-
std::string getVectorFunctionABIVariantString(const StringRef MangledNamePrefix,
202-
const StringRef ScalarFnName,
203-
const StringRef VectorFnName);
204-
205185
/// Retrieve the `VFParamKind` from a string token.
206186
VFParamKind getVFParamKindFromString(const StringRef Token);
207187

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "llvm/Analysis/TargetLibraryInfo.h"
1414
#include "llvm/ADT/DenseMap.h"
15+
#include "llvm/ADT/SmallString.h"
1516
#include "llvm/IR/Constants.h"
1617
#include "llvm/InitializePasses.h"
1718
#include "llvm/Support/CommandLine.h"
@@ -44,6 +45,13 @@ StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
4445
#include "llvm/Analysis/TargetLibraryInfo.def"
4546
};
4647

48+
std::string VecDesc::getVectorFunctionABIVariantString() const {
49+
SmallString<256> Buffer;
50+
llvm::raw_svector_ostream Out(Buffer);
51+
Out << MangledNamePrefix << "_" << ScalarFnName << "(" << VectorFnName << ")";
52+
return std::string(Out.str());
53+
}
54+
4755
// Recognized types of library function arguments and return types.
4856
enum FuncArgTypeID : char {
4957
Void = 0, // Must be zero.
@@ -1203,20 +1211,20 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
12031211
case SLEEFGNUABI: {
12041212
const VecDesc VecFuncs_VF2[] = {
12051213
#define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
1206-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MANGLN) \
1207-
{SCAL, VEC, VF, /* MASK = */ false, MANGLN},
1214+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \
1215+
{SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX},
12081216
#include "llvm/Analysis/VecFuncs.def"
12091217
};
12101218
const VecDesc VecFuncs_VF4[] = {
12111219
#define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
1212-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MANGLN) \
1213-
{SCAL, VEC, VF, /* MASK = */ false, MANGLN},
1220+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \
1221+
{SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX},
12141222
#include "llvm/Analysis/VecFuncs.def"
12151223
};
12161224
const VecDesc VecFuncs_VFScalable[] = {
12171225
#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
1218-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, MANGLN) \
1219-
{SCAL, VEC, VF, MASK, MANGLN},
1226+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
1227+
{SCAL, VEC, VF, MASK, VABI_PREFIX},
12201228
#include "llvm/Analysis/VecFuncs.def"
12211229
};
12221230

@@ -1235,8 +1243,8 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
12351243
case ArmPL: {
12361244
const VecDesc VecFuncs[] = {
12371245
#define TLI_DEFINE_ARMPL_VECFUNCS
1238-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, MANGLN) \
1239-
{SCAL, VEC, VF, MASK, MANGLN},
1246+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
1247+
{SCAL, VEC, VF, MASK, VABI_PREFIX},
12401248
#include "llvm/Analysis/VecFuncs.def"
12411249
};
12421250

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,16 +1453,6 @@ void InterleaveGroup<Instruction>::addMetadata(Instruction *NewInst) const {
14531453
}
14541454
}
14551455

1456-
std::string
1457-
VFABI::getVectorFunctionABIVariantString(const StringRef MangledNamePrefix,
1458-
const StringRef ScalarFnName,
1459-
const StringRef VectorFnName) {
1460-
SmallString<256> Buffer;
1461-
llvm::raw_svector_ostream Out(Buffer);
1462-
Out << MangledNamePrefix << "_" << ScalarFnName << "(" << VectorFnName << ")";
1463-
return std::string(Out.str());
1464-
}
1465-
14661456
void VFABI::getVectorVariantNames(
14671457
const CallInst &CI, SmallVectorImpl<std::string> &VariantMappings) {
14681458
const StringRef S = CI.getFnAttr(VFABI::MappingsAttrName).getValueAsString();

llvm/lib/Transforms/Utils/InjectTLIMappings.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
9393
auto AddVariantDecl = [&](const ElementCount &VF, bool Predicate) {
9494
const VecDesc *VD = TLI.getVectorMappingInfo(ScalarName, VF, Predicate);
9595
if (VD) {
96-
std::string MangledName = VFABI::getVectorFunctionABIVariantString(
97-
VD->getMangledNamePrefix(), VD->getScalarFnName(),
98-
VD->getVectorFnName());
96+
std::string MangledName = VD->getVectorFunctionABIVariantString();
9997
if (!OriginalSetOfMappings.count(MangledName)) {
10098
Mappings.push_back(MangledName);
10199
++NumCallInjected;

0 commit comments

Comments
 (0)