aboutsummaryrefslogtreecommitdiffstats
path: root/exportclight
diff options
context:
space:
mode:
authorXavier Leroy <xavierleroy@users.noreply.github.com>2018-06-20 17:27:38 +0200
committerGitHub <noreply@github.com>2018-06-20 17:27:38 +0200
commita55025d1ab6f7b3525ccf42c874086d3a3da21c9 (patch)
treec4286f1d3a604dc0e0e56eefe16858f01725d91b /exportclight
parentb193660372d87a6587b96d84980d8f8b1b175948 (diff)
downloadcompcert-kvx-a55025d1ab6f7b3525ccf42c874086d3a3da21c9.tar.gz
compcert-kvx-a55025d1ab6f7b3525ccf42c874086d3a3da21c9.zip
clightgen: add info on configuration and platform to generated .v files (#238)
Information about the run of clightgen is added to the generated .v file as definitions within a sub-module named Info. Closes: #226.
Diffstat (limited to 'exportclight')
-rw-r--r--exportclight/Clightgen.ml3
-rw-r--r--exportclight/ExportClight.ml22
2 files changed, 21 insertions, 4 deletions
diff --git a/exportclight/Clightgen.ml b/exportclight/Clightgen.ml
index 9cb0674e..1eb4fe03 100644
--- a/exportclight/Clightgen.ml
+++ b/exportclight/Clightgen.ml
@@ -53,7 +53,8 @@ let compile_c_ast sourcename csyntax ofile =
end;
(* Print Clight in Coq syntax *)
let oc = open_out ofile in
- ExportClight.print_program (Format.formatter_of_out_channel oc) clight;
+ ExportClight.print_program (Format.formatter_of_out_channel oc)
+ clight sourcename !option_normalize;
close_out oc
(* From C source to Clight *)
diff --git a/exportclight/ExportClight.ml b/exportclight/ExportClight.ml
index 1ae78c15..b124586a 100644
--- a/exportclight/ExportClight.ml
+++ b/exportclight/ExportClight.ml
@@ -487,8 +487,7 @@ let print_assertions p =
let prologue = "\
From Coq Require Import String List ZArith.\n\
From compcert Require Import Coqlib Integers Floats AST Ctypes Cop Clight Clightdefs.\n\
-Local Open Scope Z_scope.\n\
-\n"
+Local Open Scope Z_scope.\n"
(* Naming the compiler-generated temporaries occurring in the program *)
@@ -543,13 +542,30 @@ let name_globdef (id, g) =
let name_program p =
List.iter name_globdef p.Ctypes.prog_defs
+(* Information about this run of clightgen *)
+
+let print_clightgen_info p sourcefile normalized =
+ fprintf p "@[<v 2>Module Info.";
+ fprintf p "@ Definition version := %S%%string." Version.version;
+ fprintf p "@ Definition build_number := %S%%string." Version.buildnr;
+ fprintf p "@ Definition build_tag := %S%%string." Version.tag;
+ fprintf p "@ Definition arch := %S%%string." Configuration.arch;
+ fprintf p "@ Definition model := %S%%string." Configuration.model;
+ fprintf p "@ Definition abi := %S%%string." Configuration.abi;
+ fprintf p "@ Definition bitsize := %d." (if Archi.ptr64 then 64 else 32);
+ fprintf p "@ Definition big_endian := %B." Archi.big_endian;
+ fprintf p "@ Definition source_file := %S%%string." sourcefile;
+ fprintf p "@ Definition normalized := %B." normalized;
+ fprintf p "@]@ End Info.@ @ "
+
(* All together *)
-let print_program p prog =
+let print_program p prog sourcefile normalized =
Hashtbl.clear temp_names;
name_program prog;
fprintf p "@[<v 0>";
fprintf p "%s" prologue;
+ print_clightgen_info p sourcefile normalized;
define_idents p;
List.iter (print_globdef p) prog.Ctypes.prog_defs;
fprintf p "Definition composites : list composite_definition :=@ ";