aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-01-12 14:20:31 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2015-01-12 14:20:31 +0100
commit81e91f965e7b1afbea8d1630015e75f11f0a3afd (patch)
tree270a85299f33d783e33745c917796f080f7300e1 /powerpc
parent3304820b870e4524c7d1f14fcd62506634f7922b (diff)
parent06841a5bb7ca27bc436e87e7991d0d05dbf5267c (diff)
downloadcompcert-81e91f965e7b1afbea8d1630015e75f11f0a3afd.tar.gz
compcert-81e91f965e7b1afbea8d1630015e75f11f0a3afd.zip
Merge branch 'master' into dwarf
Conflicts: powerpc/PrintAsm.ml
Diffstat (limited to 'powerpc')
-rw-r--r--powerpc/PrintAsm.ml13
-rw-r--r--powerpc/PrintDiab.ml18
-rw-r--r--powerpc/PrintLinux.ml16
-rw-r--r--powerpc/PrintUtil.ml3
4 files changed, 12 insertions, 38 deletions
diff --git a/powerpc/PrintAsm.ml b/powerpc/PrintAsm.ml
index 485493b1..97b57c0e 100644
--- a/powerpc/PrintAsm.ml
+++ b/powerpc/PrintAsm.ml
@@ -25,7 +25,7 @@ open PrintLinux
open PrintDiab
module AsmPrinter (Target : SYSTEM) =
- (struct
+ struct
include Target
(* Basic printing functions *)
@@ -44,15 +44,14 @@ let section oc sec =
fprintf oc " %s\n" name
let print_location oc loc =
- if loc <> Cutil.no_loc then
- print_file_line oc (fst loc) (string_of_int (snd loc))
-
+ if loc <> Cutil.no_loc then print_file_line oc (fst loc) (snd loc)
(* Handling of annotations *)
let print_annot_stmt oc txt targs args =
if Str.string_match re_file_line txt 0 then begin
- print_file_line oc (Str.matched_group 1 txt) (Str.matched_group 2 txt)
+ print_file_line oc (Str.matched_group 1 txt)
+ (int_of_string (Str.matched_group 2 txt))
end else begin
fprintf oc "%s annotation: " comment;
PrintAnnot.print_annot_stmt preg "R1" oc txt targs args
@@ -535,7 +534,7 @@ let print_globdef oc (name, gdef) =
| Gfun f -> print_fundef oc name f
| Gvar v -> print_var oc name v
- end)
+ end
type target = Linux | Diab
@@ -550,7 +549,7 @@ let print_program oc p =
| Diab -> (module Diab_System:SYSTEM)):SYSTEM) in
let module Printer = AsmPrinter(Target) in
Printer.set_compilation_unit_addrs 1 2; (* TODO This is dummy code *)
- Printer.reset_file_line();
+ PrintAnnot.reset_filenames();
PrintAnnot.print_version_and_options oc Printer.comment;
Printer.print_prologue oc;
List.iter (Printer.print_globdef oc) p.prog_defs;
diff --git a/powerpc/PrintDiab.ml b/powerpc/PrintDiab.ml
index 00a5c989..e431a8c7 100644
--- a/powerpc/PrintDiab.ml
+++ b/powerpc/PrintDiab.ml
@@ -72,22 +72,10 @@ module Diab_System =
let filenum : (string, int) Hashtbl.t = Hashtbl.create 7
- let last_file = ref ""
-
- let reset_file_line () =
- last_file := "";
- Hashtbl.clear filenum
-
let print_file_line oc file line =
- if !Clflags.option_g && file <> "" then begin
- if file <> !last_file then begin
- fprintf oc " .d2file %S\n" file;
- last_file := file;
- if not (Hashtbl.mem filenum file) then
- Hashtbl.add filenum file (new_label ());
- end;
- fprintf oc " .d2line %s\n" line
- end
+ PrintAnnot.print_file_line_d2 oc comment file line;
+ if !Clflags.option_g && file <> "" && not (Hashtbl.mem filenum file) then
+ Hashtbl.add filenum file (new_label ())
(* Emit .cfi directives *)
let cfi_startproc oc = ()
diff --git a/powerpc/PrintLinux.ml b/powerpc/PrintLinux.ml
index 4e90308c..7ed98d2e 100644
--- a/powerpc/PrintLinux.ml
+++ b/powerpc/PrintLinux.ml
@@ -68,21 +68,9 @@ module Linux_System =
sprintf ".section \"%s\",\"a%s%s\",@progbits"
s (if wr then "w" else "") (if ex then "x" else "")
- let filename_num : (string, int) Hashtbl.t = Hashtbl.create 7
- let reset_file_line () = Hashtbl.clear filename_num
let print_file_line oc file line =
- if !Clflags.option_g && file <> "" then begin
- let filenum =
- try
- Hashtbl.find filename_num file
- with Not_found ->
- let n = Hashtbl.length filename_num + 1 in
- Hashtbl.add filename_num file n;
- fprintf oc " .file %d %S\n" n file;
- n
- in fprintf oc " .loc %d %s\n" filenum line
- end
-
+ PrintAnnot.print_file_line oc comment file line
+
(* Emit .cfi directives *)
let cfi_startproc =
if Configuration.asm_supports_cfi then
diff --git a/powerpc/PrintUtil.ml b/powerpc/PrintUtil.ml
index 500ff1a3..e007b273 100644
--- a/powerpc/PrintUtil.ml
+++ b/powerpc/PrintUtil.ml
@@ -28,8 +28,7 @@ module type SYSTEM =
val freg: out_channel -> freg -> unit
val creg: out_channel -> int -> unit
val name_of_section: section_name -> string
- val print_file_line: out_channel -> string -> string -> unit
- val reset_file_line: unit -> unit
+ val print_file_line: out_channel -> string -> int -> unit
val cfi_startproc: out_channel -> unit
val cfi_endproc: out_channel -> unit
val cfi_adjust: out_channel -> int32 -> unit