forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen_shared.h
71 lines (60 loc) · 2.06 KB
/
codegen_shared.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
64
65
66
67
68
69
70
71
// This file is a part of Julia. License is MIT: https://julialang.org/license
#include <utility>
#include <llvm/Support/Debug.h>
#include <llvm/IR/DebugLoc.h>
#include <llvm/IR/IRBuilder.h>
enum AddressSpace {
Generic = 0,
Tracked = 10,
Derived = 11,
CalleeRooted = 12,
Loaded = 13,
FirstSpecial = Tracked,
LastSpecial = Loaded,
};
// JLCALL with API arguments ([extra], arg0, arg1, arg2, ...) has the following ABI calling conventions defined:
#define JLCALL_F_CC (CallingConv::ID)37 // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv)
#define JLCALL_F2_CC (CallingConv::ID)38 // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv, jl_value_t *extra)
// return how many Tracked pointers are in T (count > 0),
// and if there is anything else in T (all == false)
struct CountTrackedPointers {
unsigned count = 0;
bool all = true;
bool derived = false;
CountTrackedPointers(llvm::Type *T);
};
#if JL_LLVM_VERSION >= 110000
unsigned TrackWithShadow(llvm::Value *Src, llvm::Type *T, bool isptr, llvm::Value *Dst, llvm::IRBuilder<> &irbuilder);
std::vector<llvm::Value*> ExtractTrackedValues(llvm::Value *Src, llvm::Type *STy, bool isptr, llvm::IRBuilder<> &irbuilder);
#else
unsigned TrackWithShadow(llvm::Value *Src, llvm::Type *T, bool isptr, llvm::Value *Dst, llvm::IRBuilder<> irbuilder);
std::vector<llvm::Value*> ExtractTrackedValues(llvm::Value *Src, llvm::Type *STy, bool isptr, llvm::IRBuilder<> irbuilder);
#endif
static inline void llvm_dump(llvm::Value *v)
{
v->print(llvm::dbgs(), true);
llvm::dbgs() << "\n";
}
static inline void llvm_dump(llvm::Type *v)
{
v->print(llvm::dbgs(), true);
llvm::dbgs() << "\n";
}
static inline void llvm_dump(llvm::Function *f)
{
f->print(llvm::dbgs(), nullptr, false, true);
}
static inline void llvm_dump(llvm::Module *m)
{
m->print(llvm::dbgs(), nullptr);
}
static inline void llvm_dump(llvm::Metadata *m)
{
m->print(llvm::dbgs());
llvm::dbgs() << "\n";
}
static inline void llvm_dump(llvm::DebugLoc *dbg)
{
dbg->print(llvm::dbgs());
llvm::dbgs() << "\n";
}