source: Deliverables/D2.2/8051/src/RTLabs/RTLabs.mli @ 818

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

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

File size: 4.5 KB
Line 
1
2(** This module defines the abstract syntax tree of [RTLabs]. *)
3
4(* A program in RTLabs associates to each function of the program a
5   Control Flow Graph. Pseudo-registers are used to represent the
6   variables. The operations and instructions of the language are
7   those of Cminor.
8
9   RTLabs is the last language of the frontend. It is intended to
10   ease retargetting. *)
11
12
13(* A function in RTLabs is a mapping from labels to
14   statements. Statements explicitely mention their successors. *)
15
16type statement =
17
18  (* The empty statement. *)
19  | St_skip of Label.t
20
21  (* Emit a cost label. *)
22  | St_cost of CostLabel.t * Label.t
23
24  (* Assign a constant to registers. Parameters are the destination register,
25     the constant and the label of the next statement. *)
26  | St_cst of Register.t * AST.cst * Label.t
27
28  (* Application of an unary operation. Parameters are the operation, the
29     destination register, the argument register and the label of the next
30     statement. *)
31  | St_op1 of AST.op1 * Register.t * Register.t * Label.t
32
33  (* Application of a binary operation. Parameters are the operation, the
34     destination register, the two argument registers and the label of the next
35     statement. *)
36  | St_op2 of AST.op2 * Register.t * Register.t * Register.t * Label.t
37
38  (* Memory load. Parameters are the size in bytes of what to load, the
39     register containing the address, the destination register and the label
40     of the next statement. *)
41  | St_load of AST.quantity * Register.t * Register.t * Label.t
42
43  (* Memory store. Parameters are the size in bytes of what to store, the
44     register containing the address, the source register and the label of the
45     next statement. *)
46  | St_store of AST.quantity * Register.t * Register.t * Label.t
47
48  (* Call to a function given its name. Parameters are the name of the
49     function, the arguments of the function, the destination
50     register, the signature of the function and the label of the next
51     statement. *)
52  | St_call_id of AST.ident * Register.t list * Register.t option *
53                  AST.signature * Label.t
54
55  (* Call to a function given its address. Parameters are the register
56     holding the address of the function, the arguments of the
57     function, the destination register, the signature of the function
58     and the label of the next statement. This statement with an
59     [St_op] before can represent a [St_call_id]. However, we
60     differenciate the two to allow translation to a formalism with no
61     function pointer. *)
62  | St_call_ptr of Register.t * Register.t list * Register.t option *
63                   AST.signature * Label.t
64
65  (* Tail call to a function given its name. Parameters are the name of the
66     function, the arguments of the function, the signature of the function and
67     the label of the next statement. *)
68  | St_tailcall_id of AST.ident * Register.t list * AST.signature
69
70  (* Tail call to a function given its address. Parameters are a register
71     holding the address of the function, the arguments of the function, the
72     signature of the function and the label of the next statement. Same remark
73     as for the [St_call_ptr]. *)
74  | St_tailcall_ptr of Register.t * Register.t list * AST.signature
75
76  (* Branch. Parameters are the register holding the value to branch on, the
77     label to go to when the value evaluates to true (not 0), and the label
78     to go to when the value evaluates to false (0). *)
79  | St_cond of Register.t * Label.t * Label.t
80
81  (* Jump statement. Parameters are a register and a list of
82     labels. The execution will go to the [n]th label of the list of
83     labels, where [n] is the natural value held in the register. *)
84  | St_jumptable of Register.t * Label.t list
85
86  (* Return statement. *)
87  | St_return of Register.t option
88
89
90type graph = statement Label.Map.t
91
92type internal_function =
93    { f_luniverse : Label.Gen.universe ;
94      f_runiverse : Register.universe ;
95      f_result    : (Register.t * AST.sig_type) option ;
96      f_params    : (Register.t * AST.sig_type) list ;
97      f_locals    : (Register.t * AST.sig_type) list ;
98      f_stacksize : AST.abstract_size ;
99      f_graph     : graph ;
100      f_entry     : Label.t ;
101      f_exit      : Label.t }
102
103type function_def =
104  | F_int of internal_function
105  | F_ext of AST.external_function
106
107(* A program is a list of global variables and their reserved space, a list of
108   function names and their definition, and the name of the main function. *)
109
110type program =
111    { vars   : (AST.ident * AST.abstract_size) list ;
112      functs : (AST.ident * function_def) list ;
113      main   : AST.ident option }
Note: See TracBrowser for help on using the repository browser.