diff options
author | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2018-06-20 17:27:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 17:27:38 +0200 |
commit | a55025d1ab6f7b3525ccf42c874086d3a3da21c9 (patch) | |
tree | c4286f1d3a604dc0e0e56eefe16858f01725d91b | |
parent | b193660372d87a6587b96d84980d8f8b1b175948 (diff) | |
download | compcert-a55025d1ab6f7b3525ccf42c874086d3a3da21c9.tar.gz compcert-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.
-rw-r--r-- | exportclight/Clightgen.ml | 3 | ||||
-rw-r--r-- | exportclight/ExportClight.ml | 22 |
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 :=@ "; |