summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-12-18 07:54:35 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-12-18 07:54:35 +0000
commit712f3cbae6bfd3c6f6cc40d44f438aa0affcd371 (patch)
tree913762a241b5f97b3ef4df086ba6adaeb2ff45c4 /common
parentc629161139899e43a2fe7c5af59ca926cdab370e (diff)
Support for inline assembly (asm statements).
cparser: add primitive support for enum types. bitfield emulation: for bitfields with enum type, choose signed/unsigned as appropriate git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2074 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'common')
-rw-r--r--common/AST.v10
-rw-r--r--common/Events.v2
-rw-r--r--common/PrintAST.ml1
3 files changed, 12 insertions, 1 deletions
diff --git a/common/AST.v b/common/AST.v
index ccc9dbf..40da732 100644
--- a/common/AST.v
+++ b/common/AST.v
@@ -447,10 +447,16 @@ Inductive external_function : Type :=
(** A programmer-supplied annotation. Takes zero, one or several arguments,
produces an event carrying the text and the values of these arguments,
and returns no value. *)
- | EF_annot_val (text:ident) (targ: typ).
+ | EF_annot_val (text: ident) (targ: typ)
(** Another form of annotation that takes one argument, produces
an event carrying the text and the value of this argument,
and returns the value of the argument. *)
+ | EF_inline_asm (text: ident).
+ (** Inline [asm] statements. Semantically, treated like an
+ annotation with no parameters ([EF_annot text nil]). To be
+ used with caution, as it can invalidate the semantic
+ preservation theorem. Generated only if [-finline-asm] is
+ given. *)
(** The type signature of an external function. *)
@@ -467,6 +473,7 @@ Definition ef_sig (ef: external_function): signature :=
| EF_memcpy sz al => mksignature (Tint :: Tint :: nil) None
| EF_annot text targs => mksignature targs None
| EF_annot_val text targ => mksignature (targ :: nil) (Some targ)
+ | EF_inline_asm text => mksignature nil None
end.
(** Whether an external function should be inlined by the compiler. *)
@@ -484,6 +491,7 @@ Definition ef_inline (ef: external_function) : bool :=
| EF_memcpy sz al => true
| EF_annot text targs => true
| EF_annot_val text targ => true
+ | EF_inline_asm text => true
end.
(** Whether an external function must reload its arguments. *)
diff --git a/common/Events.v b/common/Events.v
index b36a86f..fd1acd0 100644
--- a/common/Events.v
+++ b/common/Events.v
@@ -1582,6 +1582,7 @@ Definition external_call (ef: external_function): extcall_sem :=
| EF_memcpy sz al => extcall_memcpy_sem sz al
| EF_annot txt targs => extcall_annot_sem txt targs
| EF_annot_val txt targ=> extcall_annot_val_sem txt targ
+ | EF_inline_asm txt => extcall_annot_sem txt nil
end.
Theorem external_call_spec:
@@ -1600,6 +1601,7 @@ Proof.
apply extcall_memcpy_ok.
apply extcall_annot_ok.
apply extcall_annot_val_ok.
+ apply extcall_annot_ok.
Qed.
Definition external_call_well_typed ef := ec_well_typed (external_call_spec ef).
diff --git a/common/PrintAST.ml b/common/PrintAST.ml
index 971bf77..6a66c30 100644
--- a/common/PrintAST.ml
+++ b/common/PrintAST.ml
@@ -45,3 +45,4 @@ let name_of_external = function
sprintf "memcpy size %ld align %ld " (camlint_of_z sz) (camlint_of_z al)
| EF_annot(text, targs) -> sprintf "annot %S" (extern_atom text)
| EF_annot_val(text, targ) -> sprintf "annot_val %S" (extern_atom text)
+ | EF_inline_asm text -> sprintf "inline_asm %S" (extern_atom text)