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";
51 std::map<StringRef, StringRef> ScalarMASSFuncs;
52 bool isCandidateSafeToLower(
const CallInst &CI)
const;
53 bool isFiniteCallSafe(
const CallInst &CI)
const;
62bool PPCGenScalarMASSEntries::isCandidateSafeToLower(
const CallInst &CI)
const {
72bool PPCGenScalarMASSEntries::isFiniteCallSafe(
const CallInst &CI)
const {
85bool PPCGenScalarMASSEntries::createScalarMASSCall(StringRef MASSEntry,
87 Function &Func)
const {
92 assert(M &&
"Expecting a valid Module");
94 std::string MASSEntryStr = MASSEntry.
str();
95 if (isFiniteCallSafe(CI))
96 MASSEntryStr +=
"_finite";
98 FunctionCallee FCache =
M->getOrInsertFunction(
99 MASSEntryStr,
Func.getFunctionType(),
Func.getAttributes());
106bool PPCGenScalarMASSEntries::runOnModule(
Module &M) {
109 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
110 if (!TPC || skipModule(M))
113 for (Function &Func : M) {
114 if (!
Func.isDeclaration())
117 auto Iter = ScalarMASSFuncs.find(
Func.getName());
118 if (Iter == ScalarMASSFuncs.end())
126 for (
auto *User : TheUsers)
128 if (isCandidateSafeToLower(*CI))
129 Changed |= createScalarMASSCall(Iter->second, *CI, Func);
136char PPCGenScalarMASSEntries::ID = 0;
141 "Generate Scalar MASS entries",
false,
false)
144 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.
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.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
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