24#define DEBUG_TYPE "ppc-gen-scalar-mass"
30class PPCGenScalarMASSEntries :
public ModulePass {
36#define TLI_DEFINE_SCALAR_MASS_FUNCS
37#include "llvm/Analysis/ScalarFuncs.def"
44 return "PPC Generate Scalar MASS Entries";
52 std::map<StringRef, StringRef> ScalarMASSFuncs;
53 bool isCandidateSafeToLower(
const CallInst &CI)
const;
54 bool isFiniteCallSafe(
const CallInst &CI)
const;
63bool PPCGenScalarMASSEntries::isCandidateSafeToLower(
const CallInst &CI)
const {
65 if (!isa<FPMathOperator>(CI))
73bool PPCGenScalarMASSEntries::isFiniteCallSafe(
const CallInst &CI)
const {
75 if (!isa<FPMathOperator>(CI))
86bool PPCGenScalarMASSEntries::createScalarMASSCall(
StringRef MASSEntry,
93 assert(M &&
"Expecting a valid Module");
95 std::string MASSEntryStr = MASSEntry.
str();
96 if (isFiniteCallSafe(CI))
97 MASSEntryStr +=
"_finite";
100 MASSEntryStr,
Func.getFunctionType(),
Func.getAttributes());
107bool PPCGenScalarMASSEntries::runOnModule(
Module &M) {
108 bool Changed =
false;
110 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
111 if (!TPC || skipModule(M))
115 if (!
Func.isDeclaration())
118 auto Iter = ScalarMASSFuncs.find(
Func.getName());
119 if (Iter == ScalarMASSFuncs.end())
127 for (
auto *
User : TheUsers)
128 if (
auto *CI = dyn_cast_or_null<CallInst>(
User)) {
129 if (isCandidateSafeToLower(*CI))
130 Changed |= createScalarMASSCall(Iter->second, *CI, Func);
137char PPCGenScalarMASSEntries::ID = 0;
142 "Generate Scalar MASS entries",
false,
false)
145 return new PPCGenScalarMASSEntries();
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Target-Independent Code Generator Pass Configuration Options pass.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
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.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
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.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createPPCGenScalarMASSEntriesPass()
char & PPCGenScalarMASSEntriesID