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"
41 bool runOnModule(
Module &M)
override;
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 {
73bool PPCGenScalarMASSEntries::isFiniteCallSafe(
const CallInst &CI)
const {
86bool PPCGenScalarMASSEntries::createScalarMASSCall(StringRef MASSEntry,
88 Function &Func)
const {
93 assert(M &&
"Expecting a valid Module");
95 std::string MASSEntryStr = MASSEntry.
str();
96 if (isFiniteCallSafe(CI))
97 MASSEntryStr +=
"_finite";
99 FunctionCallee FCache =
M->getOrInsertFunction(
100 MASSEntryStr,
Func.getFunctionType(),
Func.getAttributes());
107bool PPCGenScalarMASSEntries::runOnModule(
Module &M) {
110 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
111 if (!TPC || skipModule(M))
114 for (Function &Func : M) {
115 if (!
Func.isDeclaration())
118 auto Iter = ScalarMASSFuncs.find(
Func.getName());
119 if (Iter == ScalarMASSFuncs.end())
127 for (
auto *User : TheUsers)
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();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
#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()
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.
LLVM_ABI bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
LLVM_ABI bool hasNoInfs() const LLVM_READONLY
Determine whether the no-infs flag is set.
LLVM_ABI bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
LLVM_ABI 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...
A Module instance is used to store all the information related to an LLVM module.
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.
auto dyn_cast_or_null(const Y &Val)
ModulePass * createPPCGenScalarMASSEntriesPass()
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
char & PPCGenScalarMASSEntriesID