source: src/joint/SemanticUtils.ma @ 1395

Last change on this file since 1395 was 1395, checked in by sacerdot, 8 years ago

1) New versions of pointer_of_beval/beval_of_pointer with a stricter dependent

type. They allow to close several proof obligations.

2) Globalenvs no longer uses -1 as a valid function block. It starts with -2
3) joint/semantics.ma uses a -2 block for the fake address used to signal the

end of program execution. Differently from what happens in OCaml, the block
is not allocated.

File size: 3.3 KB
Line 
1include "joint/semantics.ma".
2include alias "common/Identifiers.ma".
3
4(*** Store/retrieve on pseudo-registers ***)
5
6axiom BadRegister : String.
7
8definition reg_store ≝ λreg,v,locals. update RegisterTag beval locals reg v.
9
10definition reg_retrieve : register_env beval → register → res beval ≝
11 λlocals,reg. opt_to_res … [MSG BadRegister; CTX ? reg] (lookup … locals reg).
12
13(*** Store/retrieve on hardware registers ***)
14
15axiom hw_register_env: Type[0]. (* CSC: use the one in I8051? *)
16axiom hwreg_retrieve : hw_register_env → Register → res beval.
17axiom hwreg_store : Register → beval → hw_register_env → res hw_register_env.
18
19(****************************************************************************)
20
21(*CSC: XXXXXXXXXXXXXXXXX bug here; we need to change the encoding so that
22  the block is the one of the function and the offset corresponds to the
23  label. Code pointer arithmetics must be prevented in another way, i.e.
24  by not allowing any increment/decrement on Code regions (with the
25  exception of LIN's succ_pc function). If we don't do that, then the
26  find_funct_ptr (e.g. in graph_fetch_statement) are not correct! *)
27(*CSC: XXXX; do we need to create a brand new chunk per label, so that
28  pointer operations on labels are not semantically valid?
29  ATM, the pointers are not valid (they do not point to allocated regions)
30  and, moreover, they conflict with function blocks and with other pointers
31  in other functions. However, there could be simpler ways to invalidate
32  pointer arithmetics on Code pointers.
33*)
34definition pointer_of_label: label → Σp:pointer. ptype p = Code ≝
35 λl.
36  mk_pointer Code
37   (mk_block Code (Zopp (nat_of_bitvector ? (word_of_identifier … l))))
38   ? (mk_offset OZ).
39// qed.
40
41(*CSC: XXXX; inverse of the previous function, but it does not check that
42  the offset is zero and thus it never fails. *)
43definition label_of_pointer: pointer → res label ≝
44 λp. OK … (an_identifier ? (bitvector_of_nat … (abs (block_id (pblock p))))).
45
46(*CSC: XXX This code is cut&paste from joint/semantics.ma, address_of_label.
47 But I can't use it directly because this one uses a concrete definition of
48 pointer_of_label and it is used to istantiate the more_sem_params record
49 where the abstract version is declared as a field. Is there a better way
50 to organize the code? *)
51definition graph_succ_p: label → address → res address ≝
52 λl.λ_.address_of_pointer (pointer_of_label l).
53
54axiom BadProgramCounter: String.
55
56definition graph_fetch_function:
57 ∀params1,sem_params,globals.
58  genv … (graph_params params1 globals) →
59   state sem_params → res (joint_internal_function … (graph_params params1 globals)) ≝
60 λparams1,sem_params,globals,ge,st.
61  do p ← code_pointer_of_address (pc … st) ;
62  let b ≝ pblock p in
63  do def ← opt_to_res ? [MSG BadProgramCounter] (find_funct_ptr … ge b) ;
64  match def with
65  [ Internal def' ⇒ OK … def'
66  | External _ ⇒ Error … [MSG BadProgramCounter]].
67
68definition graph_fetch_statement:
69 ∀params1,sem_params,globals.
70  genv … (graph_params params1 globals) →
71   state sem_params → res (joint_statement (graph_params_ params1) globals) ≝
72 λparams1,sem_params,globals,ge,st.
73  do p ← code_pointer_of_address (pc … st) ;
74  do f ← graph_fetch_function … ge st ;
75  do l ← label_of_pointer p;
76  opt_to_res ? [MSG BadProgramCounter] (lookup ?? (joint_if_code … f) l).
Note: See TracBrowser for help on using the repository browser.