aboutsummaryrefslogtreecommitdiffstats
path: root/backend/CMparser.mly
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-10-11 17:43:59 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2015-10-11 17:43:59 +0200
commit7a6bb90048db7a254e959b1e3c308bac5fe6c418 (patch)
tree6119d963ce34b56386f79693972e8ce86d9c0e87 /backend/CMparser.mly
parent659b735ed2dbefcbe8bcb2ec2123b66019ddaf14 (diff)
downloadcompcert-kvx-7a6bb90048db7a254e959b1e3c308bac5fe6c418.tar.gz
compcert-kvx-7a6bb90048db7a254e959b1e3c308bac5fe6c418.zip
Use Coq strings instead of idents to name external and builtin functions.
The AST.ident type represents source-level identifiers as unique positive numbers. However, the mapping identifiers <-> AST.ident differs between runs of CompCert on different source files. This is problematic when we need to produce or recognize external functions and builtin functions with fixed names, for example: * in $ARCH/Machregs.v to define the register conventions for builtin functions; * in the VST program logic from Princeton to treat thread primitives specially. So far, we used AST.ident_of_string to recover the ident associated with a string. However, this function is defined in OCaml and doesn't execute within Coq. This is a problem both for VST and for future executability of CompCert within Coq. This commit replaces "ident" by "string" in the arguments of EF_external, EF_builtin, EF_inline_asm, EF_annot, and EF_annot_val. This provides stable names for externals and builtins, as needed. For inline asm and annotations, it's a matter of taste, but using strings feels more natural. EF_debug keeps using idents, since some kinds of EF_debug annotations talk about program variables.
Diffstat (limited to 'backend/CMparser.mly')
-rw-r--r--backend/CMparser.mly12
1 files changed, 6 insertions, 6 deletions
diff --git a/backend/CMparser.mly b/backend/CMparser.mly
index b48a486e..41bd35a1 100644
--- a/backend/CMparser.mly
+++ b/backend/CMparser.mly
@@ -35,9 +35,9 @@ type ef_token =
let mkef sg toks =
match toks with
| [EFT_tok "extern"; EFT_string s] ->
- EF_external(intern_string s, sg)
+ EF_external(coqstring_of_camlstring s, sg)
| [EFT_tok "builtin"; EFT_string s] ->
- EF_builtin(intern_string s, sg)
+ EF_builtin(coqstring_of_camlstring s, sg)
| [EFT_tok "volatile"; EFT_tok "load"; EFT_chunk c] ->
EF_vload c
| [EFT_tok "volatile"; EFT_tok "store"; EFT_chunk c] ->
@@ -49,12 +49,12 @@ let mkef sg toks =
| [EFT_tok "memcpy"; EFT_tok "size"; EFT_int sz; EFT_tok "align"; EFT_int al] ->
EF_memcpy(Z.of_sint32 sz, Z.of_sint32 al)
| [EFT_tok "annot"; EFT_string txt] ->
- EF_annot(intern_string txt, sg.sig_args)
+ EF_annot(coqstring_of_camlstring txt, sg.sig_args)
| [EFT_tok "annot_val"; EFT_string txt] ->
if sg.sig_args = [] then raise Parsing.Parse_error;
- EF_annot_val(intern_string txt, List.hd sg.sig_args)
+ EF_annot_val(coqstring_of_camlstring txt, List.hd sg.sig_args)
| [EFT_tok "inline_asm"; EFT_string txt] ->
- EF_inline_asm(intern_string txt, sg, [])
+ EF_inline_asm(coqstring_of_camlstring txt, sg, [])
| _ ->
raise Parsing.Parse_error
@@ -473,7 +473,7 @@ proc:
fn_stackspace = $8;
fn_body = $10 })) }
| EXTERN STRINGLIT COLON signature
- { (intern_string $2, Gfun(External(EF_external(intern_string $2,$4)))) }
+ { (intern_string $2, Gfun(External(EF_external(coqstring_of_camlstring $2,$4)))) }
| EXTERN STRINGLIT EQUAL eftoks COLON signature
{ (intern_string $2, Gfun(External(mkef $6 $4))) }
;