diff options
Diffstat (limited to 'mppa_k1c/TargetPrinter.ml')
-rw-r--r-- | mppa_k1c/TargetPrinter.ml | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml index 4be94390..d9f49a5d 100644 --- a/mppa_k1c/TargetPrinter.ml +++ b/mppa_k1c/TargetPrinter.ml @@ -99,6 +99,14 @@ module Target (*: TARGET*) = (* Associate labels to floating-point constants and to symbols. *) + let print_tbl oc (lbl, tbl) = + fprintf oc " .balign 4\n"; + fprintf oc "%a:\n" label lbl; + List.iter + (fun l -> fprintf oc " .4byte %a\n" + print_label l) + tbl + let emit_constants oc lit = if exists_constants () then begin section oc lit; @@ -264,6 +272,19 @@ module Target (*: TARGET*) = fprintf oc " cb.%a %a? %a\n" bcond bt ireg r print_label lbl | Ploopdo (r, lbl) -> fprintf oc " loopdo %a, %a\n" ireg r print_label lbl + | Pjumptable (idx_reg, tbl) -> + let lbl = new_label() in + (* jumptables := (lbl, tbl) :: !jumptables; *) + let base_reg = if idx_reg=Asmblock.GPR63 then Asmblock.GPR62 else Asmblock.GPR63 in + fprintf oc "%s jumptable [ " comment; + List.iter (fun l -> fprintf oc "%a " print_label l) tbl; + fprintf oc "]\n"; + fprintf oc " make %a = %a\n ;;\n" ireg base_reg label lbl; + fprintf oc " lwz.xs %a = %a[%a]\n ;;\n" ireg base_reg ireg idx_reg ireg base_reg; + fprintf oc " igoto %a\n ;;\n" ireg base_reg; + section oc Section_jumptable; + print_tbl oc (lbl, tbl); + section oc Section_text (* Load/Store instructions *) | Plb(rd, ra, ofs) -> @@ -517,21 +538,14 @@ module Target (*: TARGET*) = let print_align oc alignment = fprintf oc " .balign %d\n" alignment - - let print_jumptable oc jmptbl = - let print_tbl oc (lbl, tbl) = - fprintf oc "%a:\n" label lbl; - List.iter - (fun l -> fprintf oc " .long %a - %a\n" - print_label l label lbl) - tbl in - if !jumptables <> [] then + + let print_jumptable oc jmptbl = () + (* if !jumptables <> [] then begin section oc jmptbl; - fprintf oc " .balign 4\n"; List.iter (print_tbl oc) !jumptables; jumptables := [] - end + end *) let print_fun_info = elf_print_fun_info |