-
Notifications
You must be signed in to change notification settings - Fork 34
/
invoketables.hpp
130 lines (102 loc) · 3.57 KB
/
invoketables.hpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#pragma once
#include "clay.hpp"
#include "matchinvoke.hpp"
namespace clay {
struct InvokeSet;
struct InvokeEntry;
static llvm::SpecificBumpPtrAllocator<InvokeEntry> *invokeEntryAllocator
= new llvm::SpecificBumpPtrAllocator<InvokeEntry>();
static llvm::SpecificBumpPtrAllocator<InvokeSet> *invokeSetAllocator
= new llvm::SpecificBumpPtrAllocator<InvokeSet>();
struct InvokeEntry {
InvokeSet *parent;
ObjectPtr callable;
vector<TypePtr> argsKey;
vector<uint8_t> forwardedRValueFlags;
CodePtr origCode;
CodePtr code;
EnvPtr env;
EnvPtr interfaceEnv;
vector<TypePtr> fixedArgTypes;
vector<IdentifierPtr> fixedArgNames;
IdentifierPtr varArgName;
vector<TypePtr> varArgTypes;
unsigned varArgPosition;
InlineAttribute isInline;
ObjectPtr analysis;
vector<uint8_t> returnIsRef;
vector<TypePtr> returnTypes;
llvm::Function *llvmFunc;
llvm::Function *llvmCWrappers[CC_Count];
llvm::TrackingVH<llvm::MDNode> debugInfo;
bool analyzed:1;
bool analyzing:1;
bool callByName:1; // if callByName the rest of InvokeEntry is not set
bool runtimeNop:1;
InvokeEntry(InvokeSet *parent,
ObjectPtr callable,
llvm::ArrayRef<TypePtr> argsKey)
: parent(parent), callable(callable),
argsKey(argsKey),
varArgPosition(0),
isInline(IGNORE),
llvmFunc(NULL),
debugInfo(NULL),
analyzed(false),
analyzing(false),
callByName(false),
runtimeNop(false)
{
for (size_t i = 0; i < CC_Count; ++i)
llvmCWrappers[i] = NULL;
}
void *operator new(size_t num_bytes) {
return invokeEntryAllocator->Allocate();
}
virtual void dealloc() { ANodeAllocator->Deallocate(this); }
llvm::DISubprogram getDebugInfo() { return llvm::DISubprogram(debugInfo); }
};
extern vector<OverloadPtr> patternOverloads;
struct InvokeSet {
ObjectPtr callable;
vector<TypePtr> argsKey;
OverloadPtr interface;
vector<OverloadPtr> overloads;
vector<MatchSuccessPtr> matches;
map<vector<bool>, InvokeEntry*> tempnessMap;
map<vector<ValueTempness>, InvokeEntry*> tempnessMap2;
unsigned nextOverloadIndex; //:31;
bool shouldLog:1;
bool evaluatingPredicate:1;
InvokeSet(ObjectPtr callable,
llvm::ArrayRef<TypePtr> argsKey,
OverloadPtr symbolInterface,
llvm::ArrayRef<OverloadPtr> symbolOverloads)
: callable(callable), argsKey(argsKey),
interface(symbolInterface),
overloads(symbolOverloads), nextOverloadIndex(0),
shouldLog(false),
evaluatingPredicate(false)
{
overloads.insert(overloads.end(), patternOverloads.begin(), patternOverloads.end());
}
void *operator new(size_t num_bytes) {
return invokeSetAllocator->Allocate();
}
virtual void dealloc() { ANodeAllocator->Deallocate(this); }
};
typedef vector< pair<OverloadPtr, MatchResultPtr> > MatchFailureVector;
struct MatchFailureError {
MatchFailureVector failures;
bool failedInterface:1;
bool ambiguousMatch:1;
MatchFailureError() : failedInterface(false), ambiguousMatch(false) {}
};
InvokeSet *lookupInvokeSet(ObjectPtr callable,
llvm::ArrayRef<TypePtr> argsKey);
vector<InvokeSet*> lookupInvokeSets(ObjectPtr callable);
InvokeEntry* lookupInvokeEntry(ObjectPtr callable,
llvm::ArrayRef<PVData> args,
MatchFailureError &failures);
void setFinalOverloadsEnabled(bool enabled);
}