LLVM: lib/Transforms/Utils/InjectTLIMappings.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

23

24using namespace llvm;

25

26#define DEBUG_TYPE "inject-tli-mappings"

27

29 "Number of calls in which the mappings have been injected.");

30

32 "Number of function declarations that have been added.");

34 "Number of `@llvm.compiler.used` operands that have been added.");

35

36

37

38

39

44

45 assert(!ScalarFTy->isVarArg() && "VarArg functions are not supported.");

46

49

50 assert(Info && "Failed to demangle vector variant");

51 assert(Info->Shape.VF == VF && "Mangled name does not match VF");

52

60 ++NumVFDeclAdded;

62 << "` of type " << *VectorFTy << "\n");

63

64

65

66 assert(!VecFunc->size() && "VFABI attribute requires `@llvm.compiler.used` "

67 "only on declarations.");

70 << "` to `@llvm.compiler.used`.\n");

71 ++NumCompUsedAdded;

72}

73

75

76

77

78

79

81 return;

82

84

85

86

88 return;

93

98 if (!OriginalSetOfMappings.count(MangledName)) {

100 ++NumCallInjected;

101 }

103 if (!VariantF)

105 }

106 };

107

108

109 ElementCount WidestFixedVF, WidestScalableVF;

110 TLI.getWidestVF(ScalarName, WidestFixedVF, WidestScalableVF);

111

112 for (bool Predicated : {false, true}) {

116

120 }

121

123}

124

129

130 return false;

131}

132

133

134

135

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

Expand Atomic instructions

Analysis containing CSE Info

static bool runImpl(Function &F, const TargetLowering &TLI, const LibcallLoweringInfo &Libcalls, AssumptionCache *AC)

This is the interface for a simple mod/ref and alias analysis over globals.

static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI)

Definition InjectTLIMappings.cpp:74

static void addVariantDeclaration(CallInst &CI, const ElementCount &VF, const VecDesc *VD)

A helper function that adds the vector variant declaration for vectorizing the CallInst CI with a vec...

Definition InjectTLIMappings.cpp:40

static bool runImpl(const TargetLibraryInfo &TLI, Function &F)

Definition InjectTLIMappings.cpp:125

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...

#define STATISTIC(VARNAME, DESC)

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

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)

const Function & getFunction() const

void setCallingConv(CallingConv::ID CC)

void copyAttributesFrom(const Function *Src)

copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...

@ ExternalLinkage

Externally visible function.

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)

Definition InjectTLIMappings.cpp:136

LLVM_ABI 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_arg_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.

constexpr bool empty() const

empty - Check if the string is empty.

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.

const VecDesc * getVectorMappingInfo(StringRef F, const ElementCount &VF, bool Masked) const

bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

Provides info so a possible vectorization of a function can be computed.

std::optional< CallingConv::ID > getCallingConv() const

LLVM_ABI std::string getVectorFunctionABIVariantString() const

Returns a vector function ABI variant string on the form: ZGV(<...

StringRef getVectorFnName() const

static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

LLVM_ABI std::optional< VFInfo > tryDemangleForVFABI(StringRef MangledName, const FunctionType *FTy)

Function to construct a VFInfo out of a mangled names in the following format:

LLVM_ABI FunctionType * createFunctionType(const VFInfo &Info, const FunctionType *ScalarFTy)

Constructs a FunctionType by applying vector function information to the type of a matching scalar fu...

LLVM_ABI 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...

LLVM_ABI void setVectorVariantNames(CallInst *CI, ArrayRef< std::string > VariantMappings)

Overwrite the Vector Function ABI variants attribute with the names provide in VariantMappings.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

constexpr from_range_t from_range

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

LLVM_ABI void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)

Adds global values to the llvm.compiler.used list.

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.