Changeset 740 for Deliverables/D2.2/8051/src/cminor/cminorPointers.ml
 Timestamp:
 Apr 4, 2011, 5:18:15 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Deliverables/D2.2/8051/src/cminor/cminorPointers.ml
r486 r740 4 4 5 5 6 (** [is_pointer ptrs e] returns true iff the expression [e] represents an6 (** [is_pointer ptrs e] returns true only if the expression [e] represents an 7 7 address when considering that the variables in the set [ptrs] are 8 8 pointers. *) … … 15 15  Cminor.Op1 (AST.Op_ptrofint, _) > true 16 16  Cminor.Op2 (AST.Op_addp, _, _)  Cminor.Op2 (AST.Op_subp, _, _) > true 17  Cminor.Mem (Memory.MQ_pointer, _) > true18 17  Cminor.Cond (_, e2, e3) > (is_pointer ptrs e2)  (is_pointer ptrs e3) 19 18  Cminor.Exp_cost (_, e) > is_pointer ptrs e … … 109 108 statement, if any. [ptrs] is a set of already known pointer variables. *) 110 109 111 let statement_pointers type_retstmt ptrs =110 let statement_pointers ret_type stmt ptrs = 112 111 CminorFold.statement_left (fun _ _ > StringTools.Set.empty) 113 (f_statement_pointers type_ret ptrs) stmt 112 (f_statement_pointers ret_type ptrs) stmt 113 114 115 (** [init_pointer def] returns the local variables or parameters of a function 116 that can be deduced as pointers from the signature and the declarations of 117 the function. *) 118 119 let init_pointers def = 120 let ptrs = StringTools.Set.empty in 121 (* Adding the parameter pointers. *) 122 let f ptrs x = function 123  AST.Sig_ptr > StringTools.Set.add x ptrs 124  _ > ptrs in 125 let ptrs = 126 List.fold_left2 f ptrs def.Cminor.f_params def.Cminor.f_sig.AST.args in 127 (* Adding the local pointers. *) 128 let f ptrs x = 129 if List.mem x def.Cminor.f_ptrs then StringTools.Set.add x ptrs 130 else 131 if StringTools.Set.mem x ptrs then 132 (* Case where a parameter with the same name is a pointer. Thus, for the 133 moment, it is in [ptrs]. But only the local can be seen inside the 134 function and it is not a pointer, so we have to remove it. *) 135 StringTools.Set.remove x ptrs 136 else ptrs in 137 List.fold_left f ptrs def.Cminor.f_vars 114 138 115 139 … … 126 150 (* The pointers of a function are found by iterating one step of collecting 127 151 the pointers until a fixpoint is reached. *) 152 let ptrs = init_pointers def in 128 153 let ptrs = 129 154 fixpoint 130 (statement_pointers def.Cminor.f_sig.AST.res def.Cminor.f_body) 131 StringTools.Set.empty in 155 (statement_pointers def.Cminor.f_sig.AST.res def.Cminor.f_body) ptrs in 132 156 let ptrs = StringTools.Set.fold (fun x l > x :: l) ptrs [] in 133 157 { def with Cminor.f_ptrs = ptrs }
Note: See TracChangeset
for help on using the changeset viewer.