-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimOp-Parallelism.dl
85 lines (76 loc) · 1.9 KB
/
PrimOp-Parallelism.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
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
/*
HINT: is interpreted -/+
primop effectful
+ "par#" :: %a -> T_Int64
+ "spark#" :: %a -> {"State#" %s} -> {"GHC.Prim.Unit#" %a}
primop pure
+ "seq#" :: %a -> {"State#" %s} -> {"GHC.Prim.Unit#" %a}
primop effectful
+ "getSpark#" :: {"State#" %s} -> {"GHC.Prim.(#,#)" T_Int64 %a}
- "numSparks#" :: {"State#" %s} -> {"GHC.Prim.Unit#" T_Int64}
*/
#if 0
.decl Spark(item:Variable) brie
.output Spark
// "par#" :: %a -> T_Int64
USED("PrimOp-Parallelism-01")
//Called(r, "par#"),
Spark(item) :-
Call(r, "par#", _),
// value
CallArgument(r, 0, item),
NEW_REACHABLE(r)
.
// "spark#" :: %a -> {"State#" %s} -> {"GHC.Prim.Unit#" %a}
USED("PrimOp-Parallelism-02")
//Called(r, op),
TypeVarPointsTo(r, ty_node, item),
Spark(item) :-
op = "spark#",
Call(r, op, _),
// value
CallArgument(r, 0, item),
// extract result node
RetTup1Node0(op, ty_node),
NEW_REACHABLE(r)
.
// "seq#" :: %a -> {"State#" %s} -> {"GHC.Prim.Unit#" %a}
// TODO: ExecCall should support to emit TypeVarPointsTo relations
// ExecCall result can be: none, PointsTo, TypeVarPointsTo
/*
TypeVarPointsTo(r, ty_node, item),
ExecCall("seq#-thunk", r, item, 0) :-
op = "seq#",
Call(r, op, _),
// value
CallArgument(r, 0, item),
// extract result node
RetTup1Node0(op, ty_node).
*/
Error(r, "Unsupported (reachable) primop: seq# (TBD)") :-
Call(r, "seq#", _),
HasInst(f, r),
ReachableCode(f).
// "getSpark#" :: {"State#" %s} -> {"GHC.Prim.(#,#)" T_Int64 %a}
USED("PrimOp-Parallelism-03")
//Called(r, op),
TypeVarPointsTo(r, ty_node, item) :-
op = "getSpark#",
Call(r, op, _),
// lookup items
Spark(item),
// lookup result node
RetTup(op, "GHC.Prim.(#,#)", 1, ty_node),
NEW_REACHABLE(r)
.
#endif
// TODO: future work
Error(r, cat("Unsupported (reachable) primop: ", op)) :-
( op = "par#"
; op = "spark#"
; op = "seq#"
; op = "getSpark#"
),
Call(r, op, _),
NEW_REACHABLE(r)
.