prettier printing for basic block labels

This commit is contained in:
tali 2023-11-29 23:05:47 -05:00
parent 5a7ae5d5a4
commit 58827f230d
1 changed files with 5 additions and 2 deletions

View File

@ -116,7 +116,10 @@ let pp_ins ~label ppf = function
| CON (l, vt) -> Fmt.pf ppf "con %a, %a" pp_reg l pp_vtable vt | CON (l, vt) -> Fmt.pf ppf "con %a, %a" pp_reg l pp_vtable vt
| GET (o, s) -> Fmt.pf ppf "mov %a, %a[%a]" pp_reg s pp_reg o pp_reg s | GET (o, s) -> Fmt.pf ppf "mov %a, %a[%a]" pp_reg s pp_reg o pp_reg s
| SET (o, s) -> Fmt.pf ppf "mov %a[%a], %a" pp_reg o pp_reg s pp_reg (s + 1) | SET (o, s) -> Fmt.pf ppf "mov %a[%a], %a" pp_reg o pp_reg s pp_reg (s + 1)
| CBR (v, b1, b2) -> Fmt.pf ppf "cbr %a, %s, %s" pp_operand v (label b1) (label b2) | CBR (v, b1, b2) ->
let l1 = label b1 in
let l2 = label b2 in
Fmt.pf ppf "cbr %a, %s, %s" pp_operand v l1 l2
| RET -> Fmt.pf ppf "ret" | RET -> Fmt.pf ppf "ret"
| JMP l -> Fmt.pf ppf "jmp %s" (label l) | JMP l -> Fmt.pf ppf "jmp %s" (label l)
@ -130,7 +133,7 @@ let pp_program ppf pr =
| exception Not_found -> | exception Not_found ->
let name = Fmt.str "L%d" (List.length !basic_blocks - 1) in let name = Fmt.str "L%d" (List.length !basic_blocks - 1) in
basic_blocks := (bb, name) :: !basic_blocks; basic_blocks := (bb, name) :: !basic_blocks;
work_list := bb :: !work_list; work_list := !work_list @ [ bb ];
name name
in in
let rec loop i = let rec loop i =