25#define DEBUG_TYPE "ppc-lower-massv-entries"
32#define TLI_DEFINE_MASSV_VECFUNCS
33#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) VEC,
34#include "llvm/Analysis/VecFuncs.def"
35#undef TLI_DEFINE_MASSV_VECFUNCS
38class PPCLowerMASSVEntries :
public ModulePass {
55 static std::string createMASSVFuncName(
Function &Func,
80 if (Subtarget->
isAIXABI() && Subtarget->hasP10Vector())
82 if (Subtarget->hasP9Vector())
84 if (Subtarget->hasP8Vector())
90 "Mininum subtarget for -vector-library=MASSV option is Power8 on Linux "
91 "and Power7 on AIX when vectorization is not disabled.");
97PPCLowerMASSVEntries::createMASSVFuncName(
Function &Func,
99 StringRef Suffix = getCPUSuffix(Subtarget);
100 auto GenericName =
Func.getName().str();
101 std::string MASSVEntryName = GenericName + Suffix.
str();
102 return MASSVEntryName;
107bool PPCLowerMASSVEntries::handlePowSpecialCases(
CallInst *CI,
Function &Func,
109 if (
Func.getName() !=
"__powf4" &&
Func.getName() !=
"__powd2")
113 if (
ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(
Exp->getSplatValue())) {
119 if (!CFP->isExactlyValue(0.75) && !CFP->isExactlyValue(0.25))
143 if (handlePowSpecialCases(CI, Func, M))
146 std::string MASSVEntryName = createMASSVFuncName(Func, Subtarget);
148 MASSVEntryName,
Func.getFunctionType(),
Func.getAttributes());
155bool PPCLowerMASSVEntries::runOnModule(
Module &M) {
156 bool Changed =
false;
158 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
166 if (!
Func.isDeclaration())
169 if (!isMASSVFunc(
Func.getName()))
177 for (
auto *
User : MASSVUsers) {
178 auto *CI = dyn_cast<CallInst>(
User);
183 Changed |= lowerMASSVCall(CI, Func, M, Subtarget);
190char PPCLowerMASSVEntries::ID = 0;
198 return new PPCLowerMASSVEntries();
Module.h This file contains the declarations for the Module class.
const char LLVMTargetMachineRef TM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Target-Independent Code Generator Pass Configuration Options pass.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
Value * getArgOperand(unsigned i) const
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
This class represents a function call, abstracting a target machine's calling convention.
ConstantFP - Floating Point Values [float, double].
This is an important base class in LLVM.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
bool hasNoInfs() const LLVM_READONLY
Determine whether the no-infs flag is set.
bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
bool hasApproxFunc() const LLVM_READONLY
Determine whether the approximate-math-functions flag is set.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
Common code between 32-bit and 64-bit PowerPC targets.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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.
std::string str() const
str - Get the contents as an std::string.
Type * getType() const
All values are typed, get the type of this value.
const ParentTy * getParent() const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createPPCLowerMASSVEntriesPass()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
char & PPCLowerMASSVEntriesID
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.