LLVM 19.0.0git
|
#include "llvm/CodeGen/ReplaceWithVeclib.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/DemandedBits.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/VFABIDemangler.h"
#include "llvm/Support/TypeSize.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "replace-with-veclib" |
Functions | |
STATISTIC (NumCallsReplaced, "Number of calls to intrinsics that have been replaced.") | |
STATISTIC (NumTLIFuncDeclAdded, "Number of vector library function declarations added.") | |
STATISTIC (NumFuncUsedAdded, "Number of functions added to `llvm.compiler.used`") | |
Function * | getTLIFunction (Module *M, FunctionType *VectorFTy, const StringRef TLIName, Function *ScalarFunc=nullptr) |
Returns a vector Function that it adds to the Module M . | |
static void | replaceWithTLIFunction (Instruction &I, VFInfo &Info, Function *TLIVecFunc) |
Replace the instruction I with a call to the corresponding function from the vector library (TLIVecFunc ). | |
static bool | replaceWithCallToVeclib (const TargetLibraryInfo &TLI, Instruction &I) |
Returns true when successfully replaced I with a suitable function taking vector arguments, based on available mappings in the TLI . | |
static bool | isSupportedInstruction (Instruction *I) |
Supported instruction I must be a vectorized frem or a call to an intrinsic that returns either void or a vector. | |
static bool | runImpl (const TargetLibraryInfo &TLI, Function &F) |
INITIALIZE_PASS_BEGIN (ReplaceWithVeclibLegacy, DEBUG_TYPE, "Replace intrinsics with calls to vector library", false, false) INITIALIZE_PASS_END(ReplaceWithVeclibLegacy | |
Variables | |
DEBUG_TYPE | |
Replace intrinsics with calls to vector | library |
Replace intrinsics with calls to vector | false |
#define DEBUG_TYPE "replace-with-veclib" |
Definition at line 34 of file ReplaceWithVeclib.cpp.
Function * getTLIFunction | ( | Module * | M, |
FunctionType * | VectorFTy, | ||
const StringRef | TLIName, | ||
Function * | ScalarFunc = nullptr |
||
) |
Returns a vector Function that it adds to the Module M
.
When an ScalarFunc
is not null, it copies its attributes to the newly created Function.
Definition at line 48 of file ReplaceWithVeclib.cpp.
References llvm::appendToCompilerUsed(), llvm::Function::copyAttributesFrom(), llvm::Function::Create(), llvm::dbgs(), DEBUG_TYPE, llvm::GlobalValue::getType(), and LLVM_DEBUG.
Referenced by replaceWithCallToVeclib().
INITIALIZE_PASS_BEGIN | ( | ReplaceWithVeclibLegacy | , |
DEBUG_TYPE | , | ||
"Replace intrinsics with calls to vector library" | , | ||
false | , | ||
false | |||
) |
|
static |
Supported instruction I
must be a vectorized frem or a call to an intrinsic that returns either void or a vector.
Definition at line 212 of file ReplaceWithVeclib.cpp.
References I, llvm::Type::isVectorTy(), llvm::Type::isVoidTy(), and llvm::Intrinsic::not_intrinsic.
Referenced by runImpl().
|
static |
Returns true when successfully replaced I
with a suitable function taking vector arguments, based on available mappings in the TLI
.
Currently only works when I
is a call to vectorized intrinsic or the frem instruction.
Definition at line 102 of file ReplaceWithVeclib.cpp.
References assert(), llvm::VFABI::createFunctionType(), llvm::dbgs(), DEBUG_TYPE, llvm::enumerate(), llvm::ElementCount::getFixed(), llvm::Function::getIntrinsicID(), llvm::TargetLibraryInfo::getLibFunc(), llvm::Value::getName(), llvm::Intrinsic::getName(), llvm::TargetLibraryInfo::getName(), getTLIFunction(), llvm::VecDesc::getVectorFnName(), llvm::VecDesc::getVectorFunctionABIVariantString(), llvm::TargetLibraryInfo::getVectorMappingInfo(), I, llvm::Intrinsic::isOverloaded(), llvm::isVectorIntrinsicWithScalarOpAtArg(), llvm::Type::isVectorTy(), LLVM_DEBUG, llvm::Intrinsic::not_intrinsic, llvm::SmallVectorTemplateBase< T, bool >::push_back(), replaceWithTLIFunction(), llvm::StringRef::str(), and llvm::VFABI::tryDemangleForVFABI().
Referenced by runImpl().
|
static |
Replace the instruction I
with a call to the corresponding function from the vector library (TLIVecFunc
).
Definition at line 75 of file ReplaceWithVeclib.cpp.
References llvm::IRBuilderBase::CreateCall(), llvm::Constant::getAllOnesValue(), llvm::Type::getInt1Ty(), I, and Info.
Referenced by replaceWithCallToVeclib().
|
static |
Definition at line 223 of file ReplaceWithVeclib.cpp.
References F, I, instructions, isSupportedInstruction(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and replaceWithCallToVeclib().
STATISTIC | ( | NumCallsReplaced | , |
"Number of calls to intrinsics that have been replaced." | |||
) |
STATISTIC | ( | NumFuncUsedAdded | , |
"Number of functions added to `llvm.compiler.used`" | |||
) |
DEBUG_TYPE |
Definition at line 294 of file ReplaceWithVeclib.cpp.
Replace intrinsics with calls to vector false |
Definition at line 295 of file ReplaceWithVeclib.cpp.
Replace intrinsics with calls to vector library |
Definition at line 295 of file ReplaceWithVeclib.cpp.