aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2018-01-05 16:51:32 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2018-01-05 16:51:32 +0100
commit94c18ad233b9e16ee9263ba8b717630b4adbf91e (patch)
treef2e10ea75c79137c78021bc01dca112e9b430c7f /powerpc
parent91601d4bd435efdee12e08188573f0e9bd910a8a (diff)
downloadcompcert-94c18ad233b9e16ee9263ba8b717630b4adbf91e.tar.gz
compcert-94c18ad233b9e16ee9263ba8b717630b4adbf91e.zip
Change AsmToJson to be similar to other printers.
Diffstat (limited to 'powerpc')
-rw-r--r--powerpc/AsmToJSON.ml14
-rw-r--r--powerpc/AsmToJSON.mli8
2 files changed, 17 insertions, 5 deletions
diff --git a/powerpc/AsmToJSON.ml b/powerpc/AsmToJSON.ml
index 696f7ca5..5baed5dc 100644
--- a/powerpc/AsmToJSON.ml
+++ b/powerpc/AsmToJSON.ml
@@ -370,9 +370,17 @@ let pp_instructions pp ic =
| Pcfi_rel_offset _ -> assert false in (* Only debug relevant *)
pp_jarray instruction pp ic
-let pp_program pp prog =
- reset_id ();
- pp_program pp pp_instructions prog
+let destination : string option ref = ref None
+let sdump_folder : string ref = ref ""
+
+let print_if prog sourcename =
+ match !destination with
+ | None -> ()
+ | Some f ->
+ let f = Filename.concat !sdump_folder f in
+ let oc = open_out f in
+ pp_ast (formatter_of_out_channel oc) pp_instructions prog sourcename;
+ close_out oc
let pp_mnemonics pp =
pp_mnemonics pp mnemonic_names
diff --git a/powerpc/AsmToJSON.mli b/powerpc/AsmToJSON.mli
index 058a4e83..52c055c4 100644
--- a/powerpc/AsmToJSON.mli
+++ b/powerpc/AsmToJSON.mli
@@ -10,6 +10,10 @@
(* *)
(* *********************************************************************)
-val pp_program: Format.formatter -> (Asm.coq_function AST.fundef, 'a) AST.program -> unit
-
val pp_mnemonics: Format.formatter -> unit
+
+val print_if: (Asm.coq_function AST.fundef, 'a) AST.program -> string -> unit
+
+val destination: string option ref
+
+val sdump_folder : string ref