-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimOp-StablePtr.dl
44 lines (38 loc) · 1.25 KB
/
PrimOp-StablePtr.dl
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
/*
HINT: is interpreted -/+
primop effectful
+ "makeStablePtr#" :: %a -> {"State#" {RealWorld}} -> {"GHC.Prim.Unit#" {"StablePtr#" %a}}
+ "deRefStablePtr#" :: {"StablePtr#" %a} -> {"State#" {RealWorld}} -> {"GHC.Prim.Unit#" %a}
- "eqStablePtr#" :: {"StablePtr#" %a} -> {"StablePtr#" %a} -> T_Int64
- "makeStableName#" :: %a -> {"State#" {RealWorld}} -> {"GHC.Prim.Unit#" {"StableName#" %a}}
primop pure
- "eqStableName#" :: {"StableName#" %a} -> {"StableName#" %b} -> T_Int64
- "stableNameToInt#" :: {"StableName#" %a} -> T_Int64
*/
.decl StablePtr(item:Variable) brie
.output StablePtr
// "makeStablePtr#" :: %a -> {"State#" {RealWorld}} -> {"GHC.Prim.Unit#" {"StablePtr#" %a}}
// new stable ptr
USED("PrimOp-StablePtr-01")
//Called(r, op),
StablePtr(item) :-
op = "makeStablePtr#",
Call(r, op, _),
// initial item
CallArgument(r, 0, item),
NEW_REACHABLE(r)
.
// CHECKED
// "deRefStablePtr#" :: {"StablePtr#" %a} -> {"State#" {RealWorld}} -> {"GHC.Prim.Unit#" %a}
USED("PrimOp-StablePtr-02")
//Called(r, op),
TypeVarPointsTo(r, ty_node, item) :-
op = "deRefStablePtr#",
Call(r, op, _),
// lookup stable ptr items
StablePtr(item),
// lookup result node
RetTup1Node0(op, ty_node),
NEW_REACHABLE(r)
.
// CHECKED