2 (** This file defines some common structures of several languages. *)
4 (** Types and Signatures *)
6 type signedness = Signed | Unsigned
8 type size = int (* in bytes *)
11 | Sig_int of size * signedness
12 | Sig_float of size * signedness
16 type type_return = Type_ret of sig_type | Type_void
18 type signature = { args: sig_type list ; res: type_return }
21 type ident = string (* identifiers for variable and function names *)
23 type immediate = int (* immediate values for assembler constants and offsets *)
26 (** Memory quantities is the size of what can fit in memory. *)
29 | QInt of size (* concrete size in bytes *)
30 | QOffset (* size of an offset *)
31 | QPtr (* size of a pointer *)
35 | SProd of abstract_size list
36 | SSum of abstract_size list
37 | SArray of int * abstract_size
39 type abstract_offset = abstract_size * int (* nth in size *)
42 (** Comparison between integers or floats *)
44 type cmp = Cmp_eq | Cmp_ne | Cmp_gt | Cmp_ge | Cmp_lt | Cmp_le
46 (** Constants in high level languages *)
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 *)
56 (** Unary operations *)
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 *)
67 (** Binary operations *)
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 *)
90 (* Datas are used to initialize the value of variables *)
93 (* (* Disabled: needed abstraction. *)
94 | Data_reserve of int (* only reserve some space *)
99 | Data_float32 of float
100 | Data_float64 of float
102 type data_size = Byte | HalfWord | Word
104 (* External functions. *)
106 type external_function = { ef_tag: ident ; ef_sig: signature }
108 (* Traces returned by interpreters: result and cost labels are observed. The
109 result is interpreted as an 8 bits integer for coherence between
112 type trace = IntValue.int32 * CostLabel.t list