aboutsummaryrefslogtreecommitdiffstats
path: root/backend/PrintAsm.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-03-23 13:39:27 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2015-03-23 13:39:27 +0100
commit275d7f4091609ae30093a4a83a20a74997229f9c (patch)
treed1982b427dfb3606d99ed1e98b9b9d5f7ef3c5d2 /backend/PrintAsm.ml
parent5f10d3ecb0104527adf59d8ff2b74aec89811f23 (diff)
downloadcompcert-kvx-275d7f4091609ae30093a4a83a20a74997229f9c.tar.gz
compcert-kvx-275d7f4091609ae30093a4a83a20a74997229f9c.zip
Added translation fucntion for declarations and fundefinitions.
Diffstat (limited to 'backend/PrintAsm.ml')
-rw-r--r--backend/PrintAsm.ml42
1 files changed, 38 insertions, 4 deletions
diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml
index 05b55a10..11854ace 100644
--- a/backend/PrintAsm.ml
+++ b/backend/PrintAsm.ml
@@ -24,6 +24,22 @@ open TargetPrinter
module Printer(Target:TARGET) =
struct
+ let addr_mapping: (string, (int * int)) Hashtbl.t = Hashtbl.create 7
+
+ let get_fun_addr name =
+ let name = extern_atom name in
+ let start_addr = new_label ()
+ and end_addr = new_label () in
+ Hashtbl.add addr_mapping name (start_addr,end_addr);
+ start_addr,end_addr
+
+ let print_debug_label oc l =
+ if !Clflags.option_g && Configuration.advanced_debug then
+ fprintf oc "%a:\n" Target.label l
+ else
+ ()
+
+
let print_location oc loc =
if loc <> Cutil.no_loc then Target.print_file_line oc (fst loc) (snd loc)
@@ -38,16 +54,21 @@ module Printer(Target:TARGET) =
if not (C2C.atom_is_static name) then
fprintf oc " .globl %a\n" Target.symbol name;
Target.print_optional_fun_info oc;
+ let s,e = if !Clflags.option_g && Configuration.advanced_debug then
+ get_fun_addr name
+ else
+ -1,-1 in
+ print_debug_label oc s;
fprintf oc "%a:\n" Target.symbol name;
print_location oc (C2C.atom_location name);
Target.cfi_startproc oc;
Target.print_instructions oc fn;
Target.cfi_endproc oc;
+ print_debug_label oc e;
Target.print_fun_info oc name;
Target.emit_constants oc lit;
Target.print_jumptable oc jmptbl
-
-
+
let print_init_data oc name id =
if Str.string_match PrintCsyntax.re_string_literal (extern_atom name) 0
&& List.for_all (function Init_int8 _ -> true | _ -> false) id
@@ -89,8 +110,21 @@ module Printer(Target:TARGET) =
| Gfun (External ef) -> ()
| Gvar v -> print_var oc name v
- module DebugPrinter = DwarfPrinter (Target)
-
+ module DwarfTarget: DwarfTypes.DWARF_TARGET =
+ struct
+ let label = Target.label
+ let name_of_section = Target.name_of_section
+ let print_file_loc = Target.print_file_loc
+ let get_start_addr = Target.get_start_addr
+ let get_end_addr = Target.get_end_addr
+ let get_stmt_list_addr = Target.get_stmt_list_addr
+ let name_of_section = Target.name_of_section
+ let get_fun_addr s = Hashtbl.find addr_mapping s
+ end
+
+ module DebugPrinter = DwarfPrinter (DwarfTarget) (Target.DwarfAbbrevs)
+
+
end
let print_program oc p db =