|
LLVM 24.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/IntrinsicInst.h"#include "llvm/IR/VFABIDemangler.h"#include "llvm/InitializePasses.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, std::optional< CallingConv::ID > CC, Function *ScalarFunc=nullptr) |
Returns a vector Function that it adds to the Module M. | |
| static void | replaceWithTLIFunction (IntrinsicInst *II, VFInfo &Info, Function *TLIVecFunc) |
Replace the intrinsic call II to TLIVecFunc, which is the corresponding function from the vector library. | |
| static bool | replaceWithCallToVeclib (const TargetLibraryInfo &TLI, IntrinsicInst *II) |
Returns true when successfully replaced II, which is a call to a vectorized intrinsic, with a suitable function taking vector arguments, based on available mappings in the TLI. | |
| static bool | hasVectorMapping (const TargetLibraryInfo &TLI, StringRef Name, ElementCount EC) |
Returns true when TLI has a vector mapping for the scalar function name Name at EC (matching either masked or unmasked variants). | |
| static bool | hasIntrinsicVectorMapping (const TargetLibraryInfo &TLI, Intrinsic::ID IID, Type *ScalarTy, ElementCount EC, Module *M) |
Returns true when TLI has a vector mapping for IID at the given element type and EC. | |
| static bool | trySplitVectorSinCos (const TargetLibraryInfo &TLI, IntrinsicInst *II, SmallVectorImpl< Instruction * > &Replaced) |
If II is a vector llvm.sincos with no direct vector library mapping but the target does have vector mappings for both llvm.sin and llvm.cos at the same element count, replace it with separate llvm.sin and llvm.cos calls and run the standard veclib replacement on each. | |
| 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 35 of file ReplaceWithVeclib.cpp.
| Function * getTLIFunction | ( | Module * | M, |
| FunctionType * | VectorFTy, | ||
| const StringRef | TLIName, | ||
| std::optional< CallingConv::ID > | CC, | ||
| 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 49 of file ReplaceWithVeclib.cpp.
References llvm::appendToCompilerUsed(), llvm::Function::copyAttributesFrom(), llvm::Function::Create(), llvm::dbgs(), DEBUG_TYPE, llvm::GlobalValue::ExternalLinkage, llvm::Function::getFunction(), llvm::GlobalValue::getType(), LLVM_DEBUG, and llvm::Function::setCallingConv().
Referenced by replaceWithCallToVeclib().
|
static |
Returns true when TLI has a vector mapping for IID at the given element type and EC.
Definition at line 223 of file ReplaceWithVeclib.cpp.
References llvm::Intrinsic::getName(), and hasVectorMapping().
Referenced by trySplitVectorSinCos().
|
static |
Returns true when TLI has a vector mapping for the scalar function name Name at EC (matching either masked or unmasked variants).
Definition at line 215 of file ReplaceWithVeclib.cpp.
References llvm::TargetLibraryInfo::getVectorMappingInfo().
Referenced by hasIntrinsicVectorMapping(), and trySplitVectorSinCos().
| INITIALIZE_PASS_BEGIN | ( | ReplaceWithVeclibLegacy | , |
| DEBUG_TYPE | , | ||
| "Replace intrinsics with calls to vector library" | , | ||
| false | , | ||
| false | ) |
References DEBUG_TYPE, and INITIALIZE_PASS_DEPENDENCY.
|
static |
Returns true when successfully replaced II, which is a call to a vectorized intrinsic, with a suitable function taking vector arguments, based on available mappings in the TLI.
Definition at line 107 of file ReplaceWithVeclib.cpp.
References assert(), llvm::VFABI::createFunctionType(), llvm::dbgs(), DEBUG_TYPE, llvm::dyn_cast(), llvm::enumerate(), llvm::FunctionType::get(), llvm::VecDesc::getCallingConv(), llvm::ElementCount::getFixed(), llvm::Intrinsic::getName(), llvm::Value::getName(), llvm::Type::getScalarType(), getTLIFunction(), llvm::VecDesc::getVectorFnName(), llvm::VecDesc::getVectorFunctionABIVariantString(), llvm::TargetLibraryInfo::getVectorMappingInfo(), llvm::GlobalPredicate, II, llvm::Intrinsic::isOverloaded(), llvm::isVectorIntrinsicWithOverloadTypeAtArg(), llvm::isVectorIntrinsicWithScalarOpAtArg(), llvm::Type::isVectorTy(), llvm::Type::isVoidTy(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), replaceWithTLIFunction(), llvm::StringRef::str(), llvm::VFABI::tryDemangleForVFABI(), and llvm::Vector.
Referenced by runImpl(), and trySplitVectorSinCos().
|
static |
Replace the intrinsic call II to TLIVecFunc, which is the corresponding function from the vector library.
Definition at line 79 of file ReplaceWithVeclib.cpp.
References llvm::Instruction::copyMetadata(), llvm::IRBuilderBase::CreateCall(), llvm::VectorType::get(), llvm::Constant::getAllOnesValue(), llvm::Function::getCallingConv(), llvm::Type::getInt1Ty(), II, llvm::IRBuilder(), and llvm::isa().
Referenced by replaceWithCallToVeclib().
|
static |
Definition at line 299 of file ReplaceWithVeclib.cpp.
References llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), F, I, II, instructions, llvm::SmallVectorTemplateBase< T, bool >::push_back(), replaceWithCallToVeclib(), and trySplitVectorSinCos().
| STATISTIC | ( | NumCallsReplaced | , |
| "Number of calls to intrinsics that have been replaced." | ) |
| STATISTIC | ( | NumFuncUsedAdded | , |
| "Number of functions added to `llvm.compiler.used`" | ) |
|
static |
If II is a vector llvm.sincos with no direct vector library mapping but the target does have vector mappings for both llvm.sin and llvm.cos at the same element count, replace it with separate llvm.sin and llvm.cos calls and run the standard veclib replacement on each.
Definition at line 234 of file ReplaceWithVeclib.cpp.
References B(), llvm::cast(), llvm::Instruction::copyMetadata(), llvm::dyn_cast(), llvm::TargetLibraryInfo::getName(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::Value::getType(), hasIntrinsicVectorMapping(), hasVectorMapping(), II, llvm::isa(), llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), llvm::make_early_inc_range(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and replaceWithCallToVeclib().
Referenced by runImpl().
| DEBUG_TYPE |
Definition at line 380 of file ReplaceWithVeclib.cpp.
| Replace intrinsics with calls to vector false |
Definition at line 381 of file ReplaceWithVeclib.cpp.
| Replace intrinsics with calls to vector library |
Definition at line 381 of file ReplaceWithVeclib.cpp.