25#define DEBUG_TYPE "ppc-gen-scalar-mass"
31class PPCGenScalarMASSEntries :
public ModulePass {
37#define TLI_DEFINE_SCALAR_MASS_FUNCS
38#include "llvm/Analysis/ScalarFuncs.def"
45 return "PPC Generate Scalar MASS Entries";
53 std::map<StringRef, StringRef> ScalarMASSFuncs;
54 bool isCandidateSafeToLower(
const CallInst &CI)
const;
55 bool isFiniteCallSafe(
const CallInst &CI)
const;
64bool PPCGenScalarMASSEntries::isCandidateSafeToLower(
const CallInst &CI)
const {
66 if (!isa<FPMathOperator>(CI))
74bool PPCGenScalarMASSEntries::isFiniteCallSafe(
const CallInst &CI)
const {
76 if (!isa<FPMathOperator>(CI))
87bool PPCGenScalarMASSEntries::createScalarMASSCall(
StringRef MASSEntry,
94 assert(M &&
"Expecting a valid Module");
96 std::string MASSEntryStr = MASSEntry.
str();
97 if (isFiniteCallSafe(CI))
98 MASSEntryStr +=
"_finite";
101 MASSEntryStr,
Func.getFunctionType(),
Func.getAttributes());
108bool PPCGenScalarMASSEntries::runOnModule(
Module &M) {
109 bool Changed =
false;
111 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
112 if (!TPC || skipModule(M))
116 if (!
Func.isDeclaration())
119 auto Iter = ScalarMASSFuncs.find(
Func.getName());
120 if (Iter == ScalarMASSFuncs.end())
128 for (
auto *
User : TheUsers)
129 if (
auto *CI = dyn_cast_or_null<CallInst>(
User)) {
130 if (isCandidateSafeToLower(*CI))
131 Changed |= createScalarMASSCall(Iter->second, *CI, Func);
138char PPCGenScalarMASSEntries::ID = 0;
143 "Generate Scalar MASS entries",
false,
false)
146 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