LLVM: lib/Target/PowerPC/PPCGenScalarMASSEntries.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
23
24#define DEBUG_TYPE "ppc-gen-scalar-mass"
25
26using namespace llvm;
27
28namespace {
29
30class PPCGenScalarMASSEntries : public ModulePass {
31public:
32 static char ID;
33
35 ScalarMASSFuncs = {
36#define TLI_DEFINE_SCALAR_MASS_FUNCS
37#include "llvm/Analysis/ScalarFuncs.def"
38 };
39 }
40
41 bool runOnModule(Module &M) override;
42
43 StringRef getPassName() const override {
44 return "PPC Generate Scalar MASS Entries";
45 }
46
47 void getAnalysisUsage(AnalysisUsage &AU) const override {
49 }
50
51private:
52 std::map<StringRef, StringRef> ScalarMASSFuncs;
53 bool isCandidateSafeToLower(const CallInst &CI) const;
54 bool isFiniteCallSafe(const CallInst &CI) const;
57};
58
59}
60
61
62
63bool PPCGenScalarMASSEntries::isCandidateSafeToLower(const CallInst &CI) const {
64
66 return false;
67
69}
70
71
72
73bool PPCGenScalarMASSEntries::isFiniteCallSafe(const CallInst &CI) const {
74
76 return false;
77
78
79
81}
82
83
84
85
86bool PPCGenScalarMASSEntries::createScalarMASSCall(StringRef MASSEntry,
87 CallInst &CI,
88 Function &Func) const {
90 return false;
91
93 assert(M && "Expecting a valid Module");
94
95 std::string MASSEntryStr = MASSEntry.str();
96 if (isFiniteCallSafe(CI))
97 MASSEntryStr += "_finite";
98
99 FunctionCallee FCache = M->getOrInsertFunction(
100 MASSEntryStr, Func.getFunctionType(), Func.getAttributes());
101
103
104 return true;
105}
106
107bool PPCGenScalarMASSEntries::runOnModule(Module &M) {
109
110 auto *TPC = getAnalysisIfAvailable();
111 if (!TPC || skipModule(M))
112 return false;
113
114 for (Function &Func : M) {
115 if (.isDeclaration())
116 continue;
117
118 auto Iter = ScalarMASSFuncs.find(Func.getName());
119 if (Iter == ScalarMASSFuncs.end())
120 continue;
121
122
123
124
126
127 for (auto *User : TheUsers)
129 if (isCandidateSafeToLower(*CI))
130 Changed |= createScalarMASSCall(Iter->second, *CI, Func);
131 }
132 }
133
135}
136
137char PPCGenScalarMASSEntries::ID = 0;
138
140
142 "Generate Scalar MASS entries", false, false)
143
145 return new PPCGenScalarMASSEntries();
146}
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.
This pass exposes codegen information to IR-level passes.
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.
Wrapper pass for TargetTransformInfo.
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 - Return true if the parameter to the template is an instance of one of the template type argu...
char & PPCGenScalarMASSEntriesID
Definition PPCGenScalarMASSEntries.cpp:139