Go to the documentation of this file.
27 #define DEBUG_TYPE "inject-tli-mappings"
30 "Number of calls in which the mappings have been injected.");
33 "Number of function declarations that have been added.");
35 "Number of `@llvm.compiler.used` operands that have been added.");
50 Tys.push_back(
ToVectorTy(ArgOperand->getType(), VF));
52 "VarArg functions are not supported.");
59 <<
"` of type " << *(VectorF->
getType()) <<
"\n");
63 assert(!VectorF->
size() &&
"VFABI attribute requires `@llvm.compiler.used` "
64 "only on declarations.");
67 <<
"` to `@llvm.compiler.used`.\n");
93 const std::string TLIName =
95 if (!TLIName.empty()) {
96 std::string MangledName =
98 if (!OriginalSetOfMappings.
count(MangledName)) {
102 Function *VariantF =
M->getFunction(TLIName);
110 TLI.
getWidestVF(ScalarName, WidestFixedVF, WidestScalableVF);
118 "Scalable vector mappings not yet supported");
125 if (
auto CI = dyn_cast<CallInst>(&
I))
147 getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
169 "Inject TLI Mappings",
false,
false)
A set of analyses that are preserved following a run of a transformation pass.
This analysis provides dependence information for the memory accesses of a loop.
This is an optimization pass for GlobalISel generic memory operations.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
static bool isKnownLE(const LinearPolySize &LHS, const LinearPolySize &RHS)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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...
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
The instances of the Type class are immutable: once they are created, they are never changed.
FunctionType * getFunctionType() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::string mangleTLIVectorName(StringRef VectorName, StringRef ScalarName, unsigned numArgs, ElementCount VF)
This routine mangles the given VectorName according to the LangRef specification for vector-function-...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Type * ToVectorTy(Type *Scalar, ElementCount EC)
A helper function for converting Scalar types to vector types.
Represent the analysis usage information of a pass.
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
STATISTIC(NumFunctions, "Total number of functions")
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
FunctionPass * createInjectTLIMappingsLegacyPass()
static ElementCount getFixed(ScalarTy MinVal)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
inst_range instructions(Function *F)
INITIALIZE_PASS_BEGIN(InjectTLIMappingsLegacy, DEBUG_TYPE, "Inject TLI Mappings", false, false) INITIALIZE_PASS_END(InjectTLIMappingsLegacy
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
static void addVariantDeclaration(CallInst &CI, const ElementCount &VF, const StringRef VFName)
A helper function that adds the vector function declaration that vectorizes the CallInst CI with a ve...
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A Module instance is used to store all the information related to an LLVM module.
static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI)
void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef - Represent a constant reference to a string, i.e.
Type * getType() const
All values are typed, get the type of this value.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
StringRef getName() const
Return a constant reference to the value's name.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
unsigned arg_size() const
static bool runImpl(const TargetLibraryInfo &TLI, Function &F)
void setVectorVariantNames(CallInst *CI, ArrayRef< std::string > VariantMappings)
Overwrite the Vector Function ABI variants attribute with the names provide in VariantMappings.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
Provides information about what library functions are available for the current target.
@ ExternalLinkage
Externally visible function.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Legacy wrapper pass to provide the GlobalsAAResult object.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &ScalableVF) const
Returns the largest vectorization factor used in the list of vector functions.
PointerType * getType() const
Global values are always pointers.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
This class represents a function call, abstracting a target machine's calling convention.
AnalysisUsage & addRequired()
A vector that has set insertion semantics.
LLVM Value Representation.
Analysis pass providing the TargetLibraryInfo.
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Class to represent function types.