next up previous contents
Next: 6. Pretty-printing function Up: Dataflow analysis with MURZ: Previous: 4. Analysis support definition

5. Definition of meet and trasf functions

Here the user must define the meet and trasf functions needed by the problem. In our example, meet will be the set union, and trasf will be the well-known gen and kill function. Here the user must also choose if the analysis is to be performed in the Forward or Backward direction.

We remind the MURZ analysis algorithm stores the value flowing into the node, computed as the meet of the information flowing out of all predecessors, i.e. the trasf of the information flowing in.

(* meet and trasf functions *)

   let meet x y = VarSet.union x y

   (*
    * gen for live variables
    * a read variable is live
    *)

   let gen_lv info = function
       Skip -> VarSet.empty
     | Assign (i, e) -> 
        make_var_set(variabili (e))
     | Read (i) ->  VarSet.empty
     | Write (e) -> make_var_set(variabili (e))
     | Test (e) -> make_var_set(variabili (e))
     | Begin -> print_string "Begin in gen_lv";  VarSet.empty
     | End -> VarSet.empty
     |	_ -> failwith "internal compiler error gen_lv"


   (*
    * kill 
    * defined variables are killed
    *)

   let kill_lv info = function
       Skip -> VarSet.empty
     | Assign (i, e) -> VarSet.singleton (i)
     | Read (i) ->  VarSet.singleton (i)
     | Write (e) -> VarSet.empty
     | Test (e) -> VarSet.empty
     | Begin ->  print_string "Begin in kill_lv";  VarSet.empty
     | End -> VarSet.empty
     | _ -> failwith "internal compiler error kill_lv"


   (*
    * trasf
    *)

   let trasf info entry =     
      VarSet.union (VarSet.diff info
		      (kill_lv info entry.comando)) 
                    (gen_lv info entry.comando)


   let direction = Backward

(* end of meet and trasf *)



Diego
2000-05-16