@@ -16,12 +16,9 @@ use crate::output::liveness;
16
16
use crate :: output:: Output ;
17
17
18
18
use datafrog:: { Iteration , Relation , RelationLeaper } ;
19
- use facts:: { AllFacts , Atom } ;
19
+ use facts:: { AllFacts , FactTypes } ;
20
20
21
- pub ( super ) fn compute < Origin : Atom , Loan : Atom , Point : Atom , Variable : Atom , MovePath : Atom > (
22
- dump_enabled : bool ,
23
- all_facts : AllFacts < Origin , Loan , Point , Variable , MovePath > ,
24
- ) -> Output < Origin , Loan , Point , Variable , MovePath > {
21
+ pub ( super ) fn compute < T : FactTypes > ( dump_enabled : bool , all_facts : AllFacts < T > ) -> Output < T > {
25
22
let mut result = Output :: new ( dump_enabled) ;
26
23
27
24
let var_maybe_initialized_on_exit = initialization:: init_var_maybe_initialized_on_exit (
@@ -55,33 +52,35 @@ pub(super) fn compute<Origin: Atom, Loan: Atom, Point: Atom, Variable: Atom, Mov
55
52
// static inputs
56
53
let cfg_edge_rel = Relation :: from_iter ( all_facts. cfg_edge . iter ( ) . map ( |& ( p, q) | ( p, q) ) ) ;
57
54
58
- let killed_rel: Relation < ( Loan , Point ) > = all_facts. killed . into ( ) ;
55
+ let killed_rel: Relation < ( T :: Loan , T :: Point ) > = all_facts. killed . into ( ) ;
59
56
60
57
// `invalidates` facts, stored ready for joins
61
- let invalidates = iteration. variable :: < ( ( Loan , Point ) , ( ) ) > ( "invalidates" ) ;
58
+ let invalidates = iteration. variable :: < ( ( T :: Loan , T :: Point ) , ( ) ) > ( "invalidates" ) ;
62
59
63
60
// we need `region_live_at` in both variable and relation forms.
64
61
// (respectively, for join and antijoin).
65
- let region_live_at_rel: Relation < ( Origin , Point ) > = region_live_at. into ( ) ;
66
- let region_live_at_var = iteration. variable :: < ( ( Origin , Point ) , ( ) ) > ( "region_live_at" ) ;
62
+ let region_live_at_rel: Relation < ( T :: Origin , T :: Point ) > = region_live_at. into ( ) ;
63
+ let region_live_at_var =
64
+ iteration. variable :: < ( ( T :: Origin , T :: Point ) , ( ) ) > ( "region_live_at" ) ;
67
65
68
66
// `borrow_region` input but organized for join
69
- let borrow_region_rp = iteration. variable :: < ( ( Origin , Point ) , Loan ) > ( "borrow_region_rp" ) ;
67
+ let borrow_region_rp =
68
+ iteration. variable :: < ( ( T :: Origin , T :: Point ) , T :: Loan ) > ( "borrow_region_rp" ) ;
70
69
71
70
// .decl subset(R1, R2, P)
72
71
//
73
72
// Indicates that `R1: R2` at the point `P`.
74
- let subset_r1p = iteration. variable :: < ( ( Origin , Point ) , Origin ) > ( "subset_r1p" ) ;
73
+ let subset_r1p = iteration. variable :: < ( ( T :: Origin , T :: Point ) , T :: Origin ) > ( "subset_r1p" ) ;
75
74
76
75
// .decl requires(R, B, P)
77
76
//
78
77
// At the point, things with origin R may depend on data from
79
78
// borrow B
80
- let requires_rp = iteration. variable :: < ( ( Origin , Point ) , Loan ) > ( "requires_rp" ) ;
79
+ let requires_rp = iteration. variable :: < ( ( T :: Origin , T :: Point ) , T :: Loan ) > ( "requires_rp" ) ;
81
80
82
81
// .decl borrow_live_at(B, P) -- true if the restrictions of the borrow B
83
82
// need to be enforced at the point P
84
- let borrow_live_at = iteration. variable :: < ( ( Loan , Point ) , ( ) ) > ( "borrow_live_at" ) ;
83
+ let borrow_live_at = iteration. variable :: < ( ( T :: Loan , T :: Point ) , ( ) ) > ( "borrow_live_at" ) ;
85
84
86
85
// .decl live_to_dying_regions(R1, R2, P, Q)
87
86
//
@@ -94,23 +93,23 @@ pub(super) fn compute<Origin: Atom, Loan: Atom, Point: Atom, Variable: Atom, Mov
94
93
// In that case, `Q` would like to add all the
95
94
// live things reachable from `R2` to `R1`.
96
95
//
97
- let live_to_dying_regions_r2pq =
98
- iteration . variable :: < ( ( Origin , Point , Point ) , Origin ) > ( "live_to_dying_regions_r2pq" ) ;
96
+ let live_to_dying_regions_r2pq = iteration
97
+ . variable :: < ( ( T :: Origin , T :: Point , T :: Point ) , T :: Origin ) > ( "live_to_dying_regions_r2pq" ) ;
99
98
100
99
// .decl dying_region_requires((R, P, Q), B)
101
100
//
102
101
// The origin `R` requires the borrow `B`, but the
103
102
// origin `R` goes dead along the edge `P -> Q`
104
- let dying_region_requires =
105
- iteration . variable :: < ( ( Origin , Point , Point ) , Loan ) > ( "dying_region_requires" ) ;
103
+ let dying_region_requires = iteration
104
+ . variable :: < ( ( T :: Origin , T :: Point , T :: Point ) , T :: Loan ) > ( "dying_region_requires" ) ;
106
105
107
106
// .decl dying_can_reach_origins(R, P, Q)
108
107
//
109
108
// Contains dead regions where we are interested
110
109
// in computing the transitive closure of things they
111
110
// can reach.
112
111
let dying_can_reach_origins =
113
- iteration. variable :: < ( ( Origin , Point ) , Point ) > ( "dying_can_reach_origins" ) ;
112
+ iteration. variable :: < ( ( T :: Origin , T :: Point ) , T :: Point ) > ( "dying_can_reach_origins" ) ;
114
113
115
114
// .decl dying_can_reach(R1, R2, P, Q)
116
115
//
@@ -121,7 +120,7 @@ pub(super) fn compute<Origin: Atom, Loan: Atom, Point: Atom, Variable: Atom, Mov
121
120
// relation, but we try to limit it to regions
122
121
// that are dying on the edge P -> Q.
123
122
let dying_can_reach_r2q =
124
- iteration. variable :: < ( ( Origin , Point ) , ( Origin , Point ) ) > ( "dying_can_reach" ) ;
123
+ iteration. variable :: < ( ( T :: Origin , T :: Point ) , ( T :: Origin , T :: Point ) ) > ( "dying_can_reach" ) ;
125
124
let dying_can_reach_1 = iteration. variable_indistinct ( "dying_can_reach_1" ) ;
126
125
127
126
// .decl dying_can_reach_live(R1, R2, P, Q)
@@ -131,19 +130,19 @@ pub(super) fn compute<Origin: Atom, Loan: Atom, Point: Atom, Variable: Atom, Mov
131
130
// relation. This is a subset of the full `dying_can_reach`
132
131
// relation where we filter down to those cases where R2 is
133
132
// live in Q.
134
- let dying_can_reach_live =
135
- iteration . variable :: < ( ( Origin , Point , Point ) , Origin ) > ( "dying_can_reach_live" ) ;
133
+ let dying_can_reach_live = iteration
134
+ . variable :: < ( ( T :: Origin , T :: Point , T :: Point ) , T :: Origin ) > ( "dying_can_reach_live" ) ;
136
135
137
136
// .decl dead_borrow_region_can_reach_root((R, P), B)
138
137
//
139
138
// Indicates a "borrow region" R at P which is not live on
140
139
// entry to P.
141
- let dead_borrow_region_can_reach_root =
142
- iteration . variable :: < ( ( Origin , Point ) , Loan ) > ( "dead_borrow_region_can_reach_root" ) ;
140
+ let dead_borrow_region_can_reach_root = iteration
141
+ . variable :: < ( ( T :: Origin , T :: Point ) , T :: Loan ) > ( "dead_borrow_region_can_reach_root" ) ;
143
142
144
143
// .decl dead_borrow_region_can_reach_dead((R2, P), B)
145
- let dead_borrow_region_can_reach_dead =
146
- iteration . variable :: < ( ( Origin , Point ) , Loan ) > ( "dead_borrow_region_can_reach_dead" ) ;
144
+ let dead_borrow_region_can_reach_dead = iteration
145
+ . variable :: < ( ( T :: Origin , T :: Point ) , T :: Loan ) > ( "dead_borrow_region_can_reach_dead" ) ;
147
146
let dead_borrow_region_can_reach_dead_1 =
148
147
iteration. variable_indistinct ( "dead_borrow_region_can_reach_dead_1" ) ;
149
148
0 commit comments