@ -16,22 +16,25 @@ numLib.prefer_num ();
(* - - - - - A b s t r a c t s y n t a x - - - - - *)
(* - - - - - A b s t r a c t s y n t a x - - - - - *)
Datatype `
Datatype :
typ =
typ =
| FunctionT typ ( typ list )
| FunctionT typ ( typ list )
| IntegerT num
| IntegerT num
| PointerT typ
| PointerT typ
| ArrayT typ num
| ArrayT typ num
| TupleT ( typ list ) ` ;
| TupleT ( typ list )
End
Datatype `
Datatype :
var = Var_name string ` ;
var = Var_name string
End
Datatype `
Datatype :
label = Lab_name string string ` ;
label = Lab_name string string
End
(* B a s e d o n t h e c o n s t r u c t o r f u n c t i o n s i n e x p . m l i r a t h e r t h a n t h e t y p e d e f i n i t i o n *)
(* B a s e d o n t h e c o n s t r u c t o r f u n c t i o n s i n e x p . m l i r a t h e r t h a n t h e t y p e d e f i n i t i o n *)
Datatype `
Datatype :
exp =
exp =
| Var var
| Var var
| Nondet
| Nondet
@ -52,9 +55,10 @@ Datatype `
(* A r g s : R e c o r d , i n d e x *)
(* A r g s : R e c o r d , i n d e x *)
| Select exp exp
| Select exp exp
(* A r g s : R e c o r d , i n d e x , v a l u e *)
(* A r g s : R e c o r d , i n d e x , v a l u e *)
| Update exp exp exp ` ;
| Update exp exp exp
End
Datatype `
Datatype :
inst =
inst =
(* A r g s : t h e l i s t o f v a r i a b l e , e x p r e s s i o n a s s i g n m e n t s t o d o *)
(* A r g s : t h e l i s t o f v a r i a b l e , e x p r e s s i o n a s s i g n m e n t s t o d o *)
| Move ( ( var # exp ) list )
| Move ( ( var # exp ) list )
@ -74,9 +78,10 @@ Datatype `
| Free exp
| Free exp
(* A r g s : r e s u l t r e g *)
(* A r g s : r e s u l t r e g *)
| NondetI var
| NondetI var
| Abort ` ;
| Abort
End
Datatype `
Datatype :
term =
term =
(* A r g s : k e y , b r a n c h t a b l e , d e f a u l t e x p *)
(* A r g s : k e y , b r a n c h t a b l e , d e f a u l t e x p *)
| Switch exp ( ( num # label ) list ) label
| Switch exp ( ( num # label ) list ) label
@ -87,53 +92,62 @@ Datatype `
| Call var label ( exp list ) typ label label
| Call var label ( exp list ) typ label label
| Return exp
| Return exp
| Throw exp
| Throw exp
| Unreachable ` ;
| Unreachable
End
Datatype `
Datatype :
block = <| cmnd : inst list ; term : term |>` ;
block = <| cmnd : inst list ; term : term |>
End
(* T h e l l a i r c o d e d o e s n ' t h a v e p a r a m s h e r e y e t , b u t i t w i l l n e e d t o *)
(* T h e l l a i r c o d e d o e s n ' t h a v e p a r a m s h e r e y e t , b u t i t w i l l n e e d t o *)
Datatype `
Datatype :
func = <| params : var list ;
func = <| params : var list ;
locals : var set ;
locals : var set ;
entry : label ;
entry : label ;
cfg : ( label , block ) alist ;
cfg : ( label , block ) alist ;
freturn : var ;
freturn : var ;
fthrow : var |>` ;
fthrow : var |>
End
(* T h e i n t i s h o w m u c h s p a c e t h e g l o b a l n e e d s *)
(* T h e i n t i s h o w m u c h s p a c e t h e g l o b a l n e e d s *)
Datatype `
Datatype :
global = <| var : var ; init : ( exp # int ) option ; typ : typ |>` ;
global = <| var : var ; init : ( exp # int ) option ; typ : typ |>
End
Datatype `
Datatype :
llair = <| globals : global list ; functions : ( label , func ) alist |>` ;
llair = <| globals : global list ; functions : ( label , func ) alist |>
End
(* - - - - - S e m a n t i c s t a t e s - - - - - *)
(* - - - - - S e m a n t i c s t a t e s - - - - - *)
(* T O D O G i v e n t h e s i m i l a r i t i e s w i t h L L V M , c o n s i d e r m o v i n g s o m e d e f i n i t i o n s i n t o
(* T O D O G i v e n t h e s i m i l a r i t i e s w i t h L L V M , c o n s i d e r m o v i n g s o m e d e f i n i t i o n s i n t o
* a common predecessor theory * )
* a common predecessor theory * )
Datatype `
Datatype :
addr = A num ` ;
addr = A num
End
(* T h e s e a r e t h e v a l u e s t h a t c a n b e s t o r e d i n r e g i s t e r s . T h e i m p l e m e n t a t i o n u s e s
(* T h e s e a r e t h e v a l u e s t h a t c a n b e s t o r e d i n r e g i s t e r s . T h e i m p l e m e n t a t i o n u s e s
* integers with a bit - width to represent numbers , and keeps locations and sizes
* integers with a bit - width to represent numbers , and keeps locations and sizes
* separate.
* separate.
* )
* )
Datatype `
Datatype :
v =
v =
| LocV num
| LocV num
| SizeV num
| SizeV num
| IntV int num
| IntV int num
| AggV ( v list ) ` ;
| AggV ( v list )
End
Datatype `
Datatype :
pc = <| l : label ; i : num |>` ;
pc = <| l : label ; i : num |>
End
Datatype `
Datatype :
frame = <| ret : pc ; exn_ret : pc ; ret_var : var ; saved_locals : var |-> v ; |>` ;
frame = <| ret : pc ; exn_ret : pc ; ret_var : var ; saved_locals : var |-> v ; |>
End
Datatype `
Datatype :
state =
state =
<| ip : pc ;
<| ip : pc ;
globals : var |-> word64 ;
globals : var |-> word64 ;
@ -147,7 +161,8 @@ Datatype `
* semantics. * )
* semantics. * )
allocations : ( num # num ) set ;
allocations : ( num # num ) set ;
(* A b y t e a d d r e s s e d h e a p *)
(* A b y t e a d d r e s s e d h e a p *)
heap : addr |-> word8 |>` ;
heap : addr |-> word8 |>
End
(* - - - - - S e m a n t i c t r a n s i t i o n s - - - - - *)
(* - - - - - S e m a n t i c t r a n s i t i o n s - - - - - *)