blob: cc2948625242d23e9d06c18bec643a1d5299c630 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
open Location
open Static
type ident = Ident.t
type name = string
module IdentEnv = Map.Make (struct type t = ident let compare = compare end)
module IdentSet = Set.Make (struct type t = ident let compare = compare end)
module NameEnv = Map.Make (struct type t = name let compare = compare end)
module NameSet = Set.Make (struct type t = name let compare = compare end)
type ty =
| TUnit | TBit | TBitArray of static_exp | TProd of ty list
| TVar of link ref
and link =
| TIndex of int
| TLink of ty
let invalid_type = TUnit
type mem_kind = MRom | MRam
type value =
| VBit of bool
| VBitArray of bool array
type edesc =
| Econst of value
| Evar of ident
| Ereg of exp
| Ecall of name * static_exp list * exp list
(* function * params * args *)
| Emem of mem_kind * static_exp * static_exp * string option * exp list
(* ro * address size * word size * input file * args *)
and exp = {
e_desc : edesc;
e_ty : ty;
e_loc: location;
}
type pat =
| Evarpat of ident
| Etuplepat of ident list
type equation = pat * exp
type var_dec = {
v_ident : ident;
v_ty : ty;
}
type param = {
p_name : name;
}
type block =
| BEqs of equation list * var_dec list
| BIf of static_exp * block * block
type inlined_status = Inlined | NotInlined
type node_dec = {
n_name : name;
n_loc: location;
n_inlined : inlined_status;
n_inputs : var_dec list;
n_outputs : var_dec list;
n_params : param list;
n_constraints : static_exp list;
n_body : block;
n_probes : ident list;
}
type const_dec = {
c_name : name;
c_loc : location;
c_value : static_exp;
}
type program = {
p_consts : const_dec list;
p_nodes : node_dec list;
}
let mk_exp ?(loc = no_location) ?(ty = invalid_type) desc =
{ e_desc = desc; e_loc = loc; e_ty = ty }
let mk_const_dec ?(loc = no_location) n se =
{ c_name = n; c_loc = loc; c_value = se }
let mk_equation pat e = (pat, e)
let mk_var_dec n ty =
{ v_ident = n; v_ty = ty }
let mk_param n =
{ p_name = n }
let mk_node n loc inlined inputs outputs params b probes =
{ n_name = n; n_inputs = inputs; n_outputs = outputs;
n_body = b; n_params = params; n_constraints = [];
n_loc = loc; n_inlined = inlined; n_probes = probes }
let mk_program cds nds =
{ p_consts = cds; p_nodes = nds }
|