Prechádzať zdrojové kódy

dump debug set locals in hlopt.txt

Nicolas Cannasse 7 rokov pred
rodič
commit
bb88610306
2 zmenil súbory, kde vykonal 12 pridanie a 3 odobranie
  1. 1 1
      src/generators/genhl.ml
  2. 11 2
      src/generators/hlopt.ml

+ 1 - 1
src/generators/genhl.ml

@@ -3077,7 +3077,7 @@ and make_fun ?gen_content ctx name fidx f cthis cparent =
 	} in
 	ctx.m <- old;
 	Hashtbl.add ctx.defined_funs fidx ();
-	let f = if ctx.optimize then Hlopt.optimize ctx.dump_out f else f in
+	let f = if ctx.optimize then Hlopt.optimize ctx.dump_out (DynArray.get ctx.cstrings.arr) f else f in
 	DynArray.add ctx.cfunctions f;
 	capt
 

+ 11 - 2
src/generators/hlopt.ml

@@ -488,7 +488,7 @@ let code_graph (f:fundecl) =
 	in
 	blocks_pos, make_block 0
 
-let optimize dump (f:fundecl) =
+let optimize dump get_str (f:fundecl) =
 	let nregs = Array.length f.regs in
 	let old_code = match dump with None -> f.code | Some _ -> Array.copy f.code in
 	let op index = f.code.(index) in
@@ -743,6 +743,8 @@ let optimize dump (f:fundecl) =
 
 	(* done *)
 	if dump <> None then begin
+		let assigns = Hashtbl.create 0 in
+		Array.iter (fun (var,pos) -> if pos >= 0 then Hashtbl.replace assigns pos var) f.assigns;
 		let rec loop i block =
 			if i = Array.length f.code then () else
 			let block = try
@@ -765,10 +767,17 @@ let optimize dump (f:fundecl) =
 				live_loop (r + 1) (if is_live r i then r :: l else l)
 			in
 			let live = "LIVE=" ^ String.concat "," (List.map string_of_int (live_loop 0 [])) in
-			write (Printf.sprintf "\t@%-3X %-20s %-20s%s" i (ostr string_of_int old) (if opcode_eq old op then "" else ostr string_of_int op) live);
+			let var_set = (try let v = Hashtbl.find assigns i in "set " ^ get_str v with Not_found -> "") in
+			write (Printf.sprintf "\t@%-3X %-20s %-20s %-20s %s" i (ostr string_of_int old) (if opcode_eq old op then "" else ostr string_of_int op) var_set live);
 			loop (i + 1) block
 		in
 		write (Printf.sprintf "%s@%d" (fundecl_name f) f.findex);
+		let rec loop_arg = function
+			| [] -> []
+			| (_,p) :: _ when p >= 0 -> []
+			| (str,p) :: l -> (get_str str ^ ":" ^ string_of_int p) :: loop_arg l
+		in
+		write (Printf.sprintf "ARGS = %s\n" (String.concat ", " (loop_arg (Array.to_list f.assigns))));
 		if reg_remap then begin
 			for i=0 to nregs-1 do
 				write (Printf.sprintf "\tr%-2d %-10s%s" i (tstr f.regs.(i)) (if reg_map.(i) < 0 then " unused" else if reg_map.(i) = i then "" else Printf.sprintf " r%-2d" reg_map.(i)))