23 #define DEBUG_TYPE "inject-tli-mappings" 26 "Number of calls in which the mappings have been injected.");
29 "Number of function declarations that have been added.");
31 "Number of `@llvm.compiler.used` operands that have been added.");
82 "VarArg functions are not supported.");
89 <<
"` of type " << *(VectorF->
getType()) <<
"\n");
93 assert(!VectorF->
size() &&
"VFABI attribute requires `@llvm.compiler.used` " 94 "only on declarations.");
97 <<
"` to `@llvm.compiler.used`.\n");
121 for (
unsigned VF = 2, WidestVF = TLI.
getWidestVF(ScalarName); VF <= WidestVF;
124 if (!TLIName.empty()) {
126 if (!OriginalSetOfMappings.count(MangledName)) {
141 if (
auto CI = dyn_cast<CallInst>(&
I))
163 getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
179 "Inject TLI Mappings",
false,
false)
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue *> Values)
Adds global values to the llvm.compiler.used list.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
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...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
void push_back(const T &Elt)
This class represents a function call, abstracting a target machine's calling convention.
static Type * ToVectorTy(Type *Scalar, unsigned VF, bool isScalable=false)
A helper function for converting Scalar types to vector types.
Externally visible function.
A raw_ostream that writes to an SmallVector or SmallString.
STATISTIC(NumFunctions, "Total number of functions")
static constexpr char const * _LLVM_
LLVM Internal VFABI ISA token for vector functions.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Class to represent function types.
Type * getType() const
All values are typed, get the type of this value.
iterator_range< User::op_iterator > arg_operands()
bool isVoidTy() const
Return true if this is 'void'.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
A set of analyses that are preserved following a run of a transformation pass.
The instances of the Type class are immutable: once they are created, they are never changed...
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI)
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
FunctionType * getFunctionType() const
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
FunctionPass * createInjectTLIMappingsLegacyPass()
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
bool isFunctionVectorizable(StringRef F, unsigned VF) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
static std::string mangleTLIName(StringRef VectorName, const CallInst &CI, unsigned VF)
Helper function to map the TLI name to a strings that holds scalar-to-vector mapping.
INITIALIZE_PASS_BEGIN(InjectTLIMappingsLegacy, DEBUG_TYPE, "Inject TLI Mappings", false, false) INITIALIZE_PASS_END(InjectTLIMappingsLegacy
StringRef str()
Return a StringRef for the vector contents.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef getVectorizedFunction(StringRef F, unsigned VF) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
unsigned getNumArgOperands() const
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
static void addVariantDeclaration(CallInst &CI, const unsigned VF, const StringRef VFName)
A helper function that adds the vector function declaration that vectorizes the CallInst CI with a ve...
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
A vector that has set insertion semantics.
static bool runImpl(const TargetLibraryInfo &TLI, Function &F)
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.
unsigned getWidestVF(StringRef ScalarF) const
Returns the largest vectorization factor used in the list of vector functions.
PointerType * getType() const
Global values are always pointers.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void setVectorVariantNames(CallInst *CI, const SmallVector< std::string, 8 > &VariantMappings)
Overwrite the Vector Function ABI variants attribute with the names provide in VariantMappings.