source: Deliverables/D2.2/8051/src/common/AST.mli

Last change on this file was 818, checked in by ayache, 8 years ago

32 and 16 bits operations support in D2.2/8051

File size: 3.4 KB
Line 
1
2(** This file defines some common structures of several languages. *)
3
4(** Types and Signatures *)
5
6type signedness = Signed | Unsigned
7
8type size = int (* in bytes *)
9
10type sig_type =
11  | Sig_int of size * signedness
12  | Sig_float of size * signedness
13  | Sig_offset
14  | Sig_ptr
15
16type type_return = Type_ret of sig_type | Type_void
17
18type signature = { args: sig_type list ; res: type_return }
19
20
21type ident = string (* identifiers for variable and function names *)
22
23type immediate = int (* immediate values for assembler constants and offsets *)
24
25
26(** Memory quantities is the size of what can fit in memory. *)
27
28type quantity =
29  | QInt of size (* concrete size in bytes *)
30  | QOffset      (* size of an offset *)
31  | QPtr         (* size of a pointer *)
32
33type abstract_size =
34  | SQ of quantity
35  | SProd of abstract_size list
36  | SSum of abstract_size list
37  | SArray of int * abstract_size
38
39type abstract_offset = abstract_size * int (* nth in size *)
40
41
42(** Comparison between integers or floats *)
43
44type cmp = Cmp_eq | Cmp_ne | Cmp_gt | Cmp_ge | Cmp_lt | Cmp_le
45
46(** Constants in high level languages *)
47
48type cst =
49  | Cst_int of int                     (* integer constant *)
50  | Cst_float of float                 (* float constant *)
51  | Cst_addrsymbol of ident            (* address of a global symbol *)
52  | Cst_stack                          (* address of the stack *)
53  | Cst_offset of abstract_offset      (* offset *)
54  | Cst_sizeof of abstract_size        (* size of a type *)
55
56(** Unary operations *)
57
58type op1 = 
59  | Op_cast of (size * signedness) * size
60  | Op_negint           (**r integer opposite *)
61  | Op_notbool          (**r boolean negation  *)
62  | Op_notint           (**r bitwise complement  *)
63  | Op_id               (**r identity *)
64  | Op_ptrofint         (**r int to pointer *)
65  | Op_intofptr         (**r pointer to int *)
66
67(** Binary operations *)
68
69type op2 =
70  | Op_add         (**r integer addition *)
71  | Op_sub         (**r integer subtraction *)
72  | Op_mul         (**r integer multiplication *)
73  | Op_div         (**r integer division *)
74  | Op_divu        (**r integer unsigned division *)
75  | Op_mod         (**r integer modulus *)
76  | Op_modu        (**r integer unsigned modulus *)
77  | Op_and         (**r bitwise ``and'' *)
78  | Op_or          (**r bitwise ``or'' *)
79  | Op_xor         (**r bitwise ``xor'' *)
80  | Op_shl         (**r left shift *)
81  | Op_shr         (**r right shift *)
82  | Op_shru        (**r unsigned right shift *)
83  | Op_cmp of cmp  (**r integer comparison *)
84  | Op_cmpu of cmp (**r unsigned integer comparison *)
85  | Op_addp        (**r addition for a pointer and an integer *)
86  | Op_subp        (**r substraction for a pointer and a integer *)
87  | Op_subpp       (**r substraction for two pointers *)
88  | Op_cmpp of cmp (**r pointer comparaison *)
89
90(* Datas are used to initialize the value of variables *)
91
92type data = 
93(* (* Disabled: needed abstraction. *)
94  | Data_reserve of int (* only reserve some space *)
95*)
96  | Data_int8 of int
97  | Data_int16 of int
98  | Data_int32 of int
99  | Data_float32 of float
100  | Data_float64 of float
101
102type data_size = Byte | HalfWord | Word
103
104(* External functions. *)
105
106type external_function = { ef_tag: ident ; ef_sig: signature }
107
108(* Traces returned by interpreters: result and cost labels are observed. The
109   result is interpreted as an 8 bits integer for coherence between
110   languages. *)
111
112type trace = IntValue.int32 * CostLabel.t list
Note: See TracBrowser for help on using the repository browser.