summaryrefslogtreecommitdiff
path: root/ia32/Asm.v
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2011-06-13 18:11:19 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2011-06-13 18:11:19 +0000
commita5ffc59246b09a389e5f8cbc2f217e323e76990f (patch)
treee1bc7cc54518aad7c20645f187cee8110de8cff9 /ia32/Asm.v
parent4daccd62b92b23016d3f343d5691f9c164a8a951 (diff)
Revised handling of annotation statements, and more generally built-in functions, and more generally external functions
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1672 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'ia32/Asm.v')
-rw-r--r--ia32/Asm.v45
1 files changed, 34 insertions, 11 deletions
diff --git a/ia32/Asm.v b/ia32/Asm.v
index 0c4a153..f3809c4 100644
--- a/ia32/Asm.v
+++ b/ia32/Asm.v
@@ -186,7 +186,12 @@ Inductive instruction: Type :=
| Plabel(l: label)
| Pallocframe(sz: Z)(ofs_ra ofs_link: int)
| Pfreeframe(sz: Z)(ofs_ra ofs_link: int)
- | Pbuiltin(ef: external_function)(args: list preg)(res: preg).
+ | Pbuiltin(ef: external_function)(args: list preg)(res: preg)
+ | Pannot(ef: external_function)(args: list annot_param)
+
+with annot_param : Type :=
+ | APreg: preg -> annot_param
+ | APstack: memory_chunk -> Z -> annot_param.
Definition code := list instruction.
Definition fundef := AST.fundef code.
@@ -655,6 +660,8 @@ Definition exec_instr (c: code) (i: instruction) (rs: regset) (m: mem) : outcome
end
| Pbuiltin ef args res =>
Stuck (**r treated specially below *)
+ | Pannot ef args =>
+ Stuck (**r treated specially below *)
end.
(** Translation of the LTL/Linear/Mach view of machine registers
@@ -696,20 +703,27 @@ Inductive extcall_arg (rs: regset) (m: mem): loc -> val -> Prop :=
Mem.loadv Mfloat64 m (Val.add (rs (IR ESP)) (Vint (Int.repr bofs))) = Some v ->
extcall_arg rs m (S (Outgoing ofs Tfloat)) v.
-Inductive extcall_args (rs: regset) (m: mem): list loc -> list val -> Prop :=
- | extcall_args_nil:
- extcall_args rs m nil nil
- | extcall_args_cons: forall l1 ll v1 vl,
- extcall_arg rs m l1 v1 -> extcall_args rs m ll vl ->
- extcall_args rs m (l1 :: ll) (v1 :: vl).
-
Definition extcall_arguments
(rs: regset) (m: mem) (sg: signature) (args: list val) : Prop :=
- extcall_args rs m (loc_arguments sg) args.
+ list_forall2 (extcall_arg rs m) (loc_arguments sg) args.
Definition loc_external_result (sg: signature) : preg :=
preg_of (loc_result sg).
+(** Extract the values of the arguments of an annotation. *)
+
+Inductive annot_arg (rs: regset) (m: mem): annot_param -> val -> Prop :=
+ | annot_arg_reg: forall r,
+ annot_arg rs m (APreg r) (rs r)
+ | annot_arg_stack: forall chunk ofs stk base v,
+ rs (IR ESP) = Vptr stk base ->
+ Mem.load chunk m stk (Int.unsigned base + ofs) = Some v ->
+ annot_arg rs m (APstack chunk ofs) v.
+
+Definition annot_arguments
+ (rs: regset) (m: mem) (params: list annot_param) (args: list val) : Prop :=
+ list_forall2 (annot_arg rs m) params args.
+
(** Execution of the instruction at [rs#PC]. *)
Inductive state: Type :=
@@ -734,13 +748,22 @@ Inductive step: state -> trace -> state -> Prop :=
#XMM6 <- Vundef #XMM7 <- Vundef
#ST0 <- Vundef
#res <- v)) m')
+ | exec_step_annot:
+ forall b ofs c ef args rs m vargs t v m',
+ rs PC = Vptr b ofs ->
+ Genv.find_funct_ptr ge b = Some (Internal c) ->
+ find_instr (Int.unsigned ofs) c = Some (Pannot ef args) ->
+ annot_arguments rs m args vargs ->
+ external_call ef ge vargs m t v m' ->
+ step (State rs m) t
+ (State (nextinstr rs) m')
| exec_step_external:
forall b ef args res rs m t rs' m',
rs PC = Vptr b Int.zero ->
Genv.find_funct_ptr ge b = Some (External ef) ->
external_call ef ge args m t res m' ->
- extcall_arguments rs m ef.(ef_sig) args ->
- rs' = (rs#(loc_external_result ef.(ef_sig)) <- res
+ extcall_arguments rs m (ef_sig ef) args ->
+ rs' = (rs#(loc_external_result (ef_sig ef)) <- res
#PC <- (rs RA)) ->
step (State rs m) t (State rs' m').