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 /exportclight/ExportClight.ml | |
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.
Diffstat (limited to 'exportclight/ExportClight.ml')
-rw-r--r-- | exportclight/ExportClight.ml | 22 |
1 files changed, 19 insertions, 3 deletions
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 :=@ "; |