26#define DEBUG_TYPE "inject-tli-mappings"
29 "Number of calls in which the mappings have been injected.");
32 "Number of function declarations that have been added.");
34 "Number of `@llvm.compiler.used` operands that have been added.");
51 "VarArg functions are not supported.");
60 <<
"` of type " << *(VectorF->
getType()) <<
"\n");
64 assert(!VectorF->
size() &&
"VFABI attribute requires `@llvm.compiler.used` "
65 "only on declarations.");
68 <<
"` to `@llvm.compiler.used`.\n");
93 auto AddVariantDecl = [&](
const ElementCount &VF,
bool Predicate) {
94 const std::string TLIName =
96 if (!TLIName.empty()) {
98 TLIName, ScalarName, CI.
arg_size(), VF, Predicate);
99 if (!OriginalSetOfMappings.
count(MangledName)) {
103 Function *VariantF = M->getFunction(TLIName);
111 TLI.
getWidestVF(ScalarName, WidestFixedVF, WidestScalableVF);
113 for (
bool Predicated : {
false,
true}) {
115 ElementCount::isKnownLE(VF, WidestFixedVF); VF *= 2)
116 AddVariantDecl(VF, Predicated);
119 ElementCount::isKnownLE(VF, WidestScalableVF); VF *= 2)
120 AddVariantDecl(VF, Predicated);
128 if (
auto CI = dyn_cast<CallInst>(&
I))
static bool runImpl(Function &F, const TargetLowering &TLI)
This is the interface for a simple mod/ref and alias analysis over globals.
static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI)
static void addVariantDeclaration(CallInst &CI, const ElementCount &VF, bool Predicate, const StringRef VFName)
A helper function that adds the vector function declaration that vectorizes the CallInst CI with a ve...
static bool runImpl(const TargetLibraryInfo &TLI, Function &F)
print must be executed print the must be executed context for all instructions
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
FunctionType * getFunctionType() const
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
unsigned arg_size() const
This class represents a function call, abstracting a target machine's calling convention.
static constexpr ElementCount getScalable(ScalarTy MinVal)
static constexpr ElementCount getFixed(ScalarTy MinVal)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
PointerType * getType() const
Global values are always pointers.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A vector that has set insertion semantics.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &ScalableVF) const
Returns the largest vectorization factor used in the list of vector functions.
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF, bool Masked=false) const
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt1Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
StringRef getName() const
Return a constant reference to the value's name.
void getVectorVariantNames(const CallInst &CI, SmallVectorImpl< std::string > &VariantMappings)
Populates a set of strings representing the Vector Function ABI variants associated to the CallInst C...
void setVectorVariantNames(CallInst *CI, ArrayRef< std::string > VariantMappings)
Overwrite the Vector Function ABI variants attribute with the names provide in VariantMappings.
std::string mangleTLIVectorName(StringRef VectorName, StringRef ScalarName, unsigned numArgs, ElementCount VF, bool Masked=false)
This routine mangles the given VectorName according to the LangRef specification for vector-function-...
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Type * ToVectorTy(Type *Scalar, ElementCount EC)
A helper function for converting Scalar types to vector types.
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.