-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftable.h
63 lines (45 loc) · 1.24 KB
/
ftable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef RENT_FTABLE_H
#define RENT_FTABLE_H
#include <llvm/IR/Function.h>
#include <set>
#include <vector>
using namespace llvm;
struct FunctionEntry {
std::string rname;
Function *fun;
int offset;
int eval;
int arity;
FunctionEntry(std::string rname, Function *fun, int offset, int eval, int arity):
rname(rname), fun(fun), offset(offset), eval(eval), arity(arity) {}
unsigned evalX() {
return eval / 100;
}
unsigned evalY() {
return (eval % 100) / 10;
}
unsigned evalZ() {
return eval % 10;
}
bool isInternal() {
return evalY() == 1;
}
bool isPrimitive() {
return evalY() != 1;
}
bool isBuiltin() {
return evalZ() == 1;
}
bool isSpecial() {
return evalZ() == 0;
}
};
typedef std::vector<FunctionEntry> FunctionTableTy; // the parsed function "table"
bool readFunctionTable(Module *m, FunctionTableTy& tbl);
void dumpFunctionTable(FunctionTableTy& funtab);
typedef std::set<int> IntSetTy;
int maxArity(Function* fun, FunctionTableTy& funtab);
IntSetTy uniqueFunctionArities(Function *fun, FunctionTableTy& funtab);
std::string dumpFunctionArities(IntSetTy arities, int effectiveArity);
bool isDoFunction(Function *fun, FunctionTableTy& funtab); // linear search
#endif