- Timestamp:
- Jul 13, 2012, 7:59:43 PM (9 years ago)
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/common/FrontEndMem.ma
r1993 r2185 50 50 51 51 definition valid_pointer : mem → pointer → bool ≝ 52 λm,ptr. Zltb (block_id (pblock ptr)) (nextblock m) ∧ 53 Zleb (low_bound m (pblock ptr)) (offv (poff ptr)) ∧ 54 Zleb (offv (poff ptr)) (high_bound m (pblock ptr)). 52 λm,ptr. 53 let off ≝ Z_of_unsigned_bitvector … (offv (poff ptr)) in 54 Zltb (block_id (pblock ptr)) (nextblock m) ∧ 55 Zleb (low_bound m (pblock ptr)) off ∧ 56 Zleb off (high_bound m (pblock ptr)). 55 57 -
src/common/GenMem.ma
r2180 r2185 178 178 //; qed. 179 179 180 (* XXX note that this won't allow access to negative offsets, and we don't 181 currently provide any other means to access them. We could choose to get 182 rid of them entirely. *) 180 183 181 184 (* This function should be moved to common/GenMem.ma and replaces in_bounds *) … … 186 189 if Zltb (block_id b) (nextblock … m) then 187 190 let content ≝ blocks … m b in 188 let off ≝ offv (poff ptr) in191 let off ≝ Z_of_unsigned_bitvector … (offv (poff ptr)) in 189 192 if andb (Zleb (low … content) off) (Zltb off (high … content)) then 190 193 Some … (F b content off) -
src/common/Globalenvs.ma
r2176 r2185 82 82 addresses of the memory region in question - here there are no real 83 83 pointers, so use the real region. *) 84 let ptr ≝ mk_pointer (*block_region m b*) b (*?*) (mk_offset p) in84 let ptr ≝ mk_pointer (*block_region m b*) b (*?*) (mk_offset (bitvector_of_Z … p)) in 85 85 match id with 86 86 [ Init_int8 n ⇒ store (ASTint I8 Unsigned) m ptr (Vint I8 n) … … 236 236 | #f #fn #E normalize in E; destruct 237 237 | (*#r*) #f #E normalize in E; destruct 238 | * (*#pty*) #b (*#c*) * #off #f #E whd in E:(??%?);239 cases off in E ⊢ %; [ 2,3: #x ]238 | * (*#pty*) #b (*#c*) * #off #f whd in ⊢ (??%? → ?); 239 @eq_offset_elim #Eoff 240 240 #E whd in E:(??%?); destruct 241 241 (*%{pty}*) %{b} (*%{c}*) % // @E -
src/common/Pointers.ma
r2176 r2185 68 68 the option of extending blocks backwards. *) 69 69 70 definition offset_size ≝ 8*size_pointer. 71 70 72 (* CSC: why do we need this awful indirection? *) 71 record offset : Type[0] ≝ { offv : Z}.73 record offset : Type[0] ≝ { offv : BitVector offset_size }. 72 74 73 definition eq_offset ≝ λx,y. eq Zb(offv x) (offv y).75 definition eq_offset ≝ λx,y. eq_bv ? (offv x) (offv y). 74 76 75 77 lemma reflexive_eq_offset: ∀x. eq_offset x x = true. … … 77 79 qed. 78 80 81 lemma eq_offset_elim : ∀P : bool → Prop.∀o1,o2. 82 (o1 = o2 → P true) → (o1 ≠ o2 → P false) → P (eq_offset o1 o2). 83 #P * #o1 * #o2 #T #F 84 change with (eq_bv ???) in ⊢ (?%); 85 @eq_bv_elim 86 [ /2/ 87 | * #FF @F % #E destruct /2/ 88 ] qed. 89 90 definition offset_of_Z : Z → offset ≝ 91 λz. mk_offset (bitvector_of_Z … z). 79 92 definition shift_offset : ∀n. offset → BitVector n → offset ≝ 80 λn,o,i. mk_offset ( offv o + Z_of_signed_bitvector ? i).93 λn,o,i. mk_offset (addition_n ? (offv o) (sign_ext … i)). 81 94 (* A version of shift_offset_n for multiplied addresses which avoids overflow. *) 82 95 definition shift_offset_n : ∀n. offset → nat → BitVector n → offset ≝ 83 λn,o,i,j. mk_offset ( offv o + (Z_of_nat i)*(Z_of_signed_bitvector ? j)).96 λn,o,i,j. mk_offset (addition_n ? (offv o) (short_multiplication ? (bitvector_of_nat … i) (sign_ext … j))). 84 97 definition neg_shift_offset : ∀n. offset → BitVector n → offset ≝ 85 λn,o,i. mk_offset ( offv o - Z_of_signed_bitvector ? i).98 λn,o,i. mk_offset (subtraction ? (offv o) (sign_ext … i)). 86 99 definition neg_shift_offset_n : ∀n. offset → nat → BitVector n → offset ≝ 87 λn,o,i,j. mk_offset ( offv o - (Z_of_nat i) * (Z_of_signed_bitvector ? j)).100 λn,o,i,j. mk_offset (subtraction ? (offv o) (short_multiplication ? (bitvector_of_nat … i) (sign_ext … j))). 88 101 definition sub_offset : ∀n. offset → offset → BitVector n ≝ 89 λn,x,y. bitvector_of_Z ? (offv x - offv y).90 definition zero_offset ≝ mk_offset OZ.102 λn,x,y. sign_ext … (subtraction ? (offv x) (offv y)). 103 definition zero_offset ≝ mk_offset (zero ?). 91 104 definition lt_offset : offset → offset → bool ≝ 92 λx,y. Zltb(offv x) (offv y).105 λx,y. lt_u ? (offv x) (offv y). 93 106 94 107 (*CSC: use this definition everywhere in Values.ma and Mem.ma. *) … … 132 145 whd in match (eq_pointer ??); 133 146 @eq_block_elim #block_eq 134 [ change with (eqZb ??) in match (eq_offset ??); 135 @eqZb_elim #offset_eq 147 [ @eq_offset_elim #offset_eq 136 148 [ destruct @Ptrue % 137 149 ] -
src/joint/BEMem.ma
r2176 r2185 118 118 *) 119 119 lemma pointer_of_address_is_safe : ∀a : safe_address.pointer_of_address a = OK … (pointer_of_address_safe a). 120 ** #a0 #a1 ***** #z #o 120 ** #a0 #a1 ***** #z #o 121 121 #Hr 122 122 (* … … 127 127 destruct normalize 128 128 @eqZb_elim [2,4,6: * #ABS elim (ABS (refl …))] 129 @eqZb_elim [2,4,6: * #ABS elim (ABS (refl …))] 129 change with (eq_bv ???) in match (eq_v ?????); 130 @eq_bv_elim [2,4,6: * #ABS elim (ABS (refl …))] 130 131 #_ #_ normalize % 131 132 qed. -
src/joint/semantics.ma
r2176 r2185 228 228 let l' ≝ joint_if_entry … fn in 229 229 let st ≝ set_regs p regs st in 230 let pointer_in_fn ≝ mk_pointer (mk_block Code (block_id b)) (mk_offset 0)in230 let pointer_in_fn ≝ mk_pointer (mk_block Code (block_id b)) zero_offset in 231 231 ! newpc ← address_of_label … ge pointer_in_fn l' ; 232 232 let st ≝ set_pc … newpc st in … … 401 401 (* Invariant: a -1 block is unused in common/Globalenvs *) 402 402 let b ≝ mk_block Code (-1) in 403 let ptr ≝ mk_pointer b (mk_offset 0)in403 let ptr ≝ mk_pointer b zero_offset in 404 404 let addr ≝ address_of_code_pointer ptr in 405 405 (λp. mk_evaluation_parameters (prog_var_names … p) (mk_sem_params2 … (sparams p)) addr (globalenv_noinit … p)). … … 416 416 let 〈m,spb〉 ≝ alloc … m 0 external_ram_size XData in 417 417 let 〈m,ispb〉 ≝ alloc … m 0 internal_ram_size XData in 418 let dummy_pc ≝ mk_pointer (mk_block Code (-1)) (mk_offset 0)in419 let spp ≝ mk_pointer spb ( mk_offsetexternal_ram_size) in420 let ispp ≝ mk_pointer ispb ( mk_offset47) in418 let dummy_pc ≝ mk_pointer (mk_block Code (-1)) zero_offset in 419 let spp ≝ mk_pointer spb (offset_of_Z external_ram_size) in 420 let ispp ≝ mk_pointer ispb (offset_of_Z 47) in 421 421 do sp ← address_of_pointer spp ; 422 422 let main ≝ prog_main … p in
Note: See TracChangeset
for help on using the changeset viewer.