source: src/joint/SemanticUtils.ma @ 1382

Last change on this file since 1382 was 1382, checked in by sacerdot, 9 years ago
  • succ_pc generalized to return a res (necessary for LIN semantics)
  • succ_pc implemented for LIN
File size: 2.6 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: XXXX; do we need to create a brand new chunk per label, so that
22  pointer operations on labels are not semantically valid?
23  ATM, the pointers are not valid (they do not point to allocated regions)
24  and, moreover, they conflict with function blocks and with other pointers
25  in other functions. However, there could be simpler ways to invalidate
26  pointer arithmetics on Code pointers.
27*)
28definition pointer_of_label: label → Σp:pointer. ptype p = Code ≝
29 λl.
30  mk_pointer Code
31   (mk_block Code (Zopp (nat_of_bitvector ? (word_of_identifier … l))))
32   ? (mk_offset OZ).
33// qed.
34
35(*CSC: XXXX; inverse of the previous function, but it does not check that
36  the offset is zero and thus it never fails. *)
37definition label_of_pointer: pointer → res label ≝
38 λp. OK … (an_identifier ? (bitvector_of_nat … (abs (block_id (pblock p))))).
39
40(*CSC: XXX This code is cut&paste from joint/semantics.ma, address_of_label.
41  Maybe there is a better way to organize the code!!! *)
42definition graph_succ_p: label → address → res address.
43 #l #_ generalize in match (refl … (address_of_pointer (pointer_of_label l)))
44 cases (address_of_pointer (pointer_of_label l)) in ⊢ (???% → ?)
45  [ #res #_ @(OK … res)
46  | #msg cases (pointer_of_label l) * * #q #com #off #E1 destruct #E2 normalize in E2; destruct ]
47qed.
48
49axiom BadProgramCounter: String.
50definition graph_fetch_statement:
51 ∀params1,sem_params,globals.
52  genv … (graph_params params1 globals) →
53   state sem_params → res (joint_statement (graph_params_ params1) globals) ≝
54 λparams1,sem_params,globals,ge,st.
55  do p ← pointer_of_address (pc … st) ;
56  let b ≝ pblock p in
57  do l ← label_of_pointer p;
58  do def ← opt_to_res ? [MSG BadProgramCounter] (find_funct_ptr … ge b) ;
59  match def with
60  [ Internal def' ⇒
61     opt_to_res ? [MSG BadProgramCounter] (lookup ?? (joint_if_code … def') l)
62  | External _ ⇒ Error … [MSG BadProgramCounter]].
Note: See TracBrowser for help on using the repository browser.