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

Last change on this file was 1589, checked in by tranquil, 8 years ago
  • turned to argument-less return statements for RTLabs and RTL (there was a hidden invariant, for which the arguments of return statements where equal to the f_result field of the function definition: they were useless and an optimization was breaking the compilation)
  • corrected a bug in liveness analysis I had introduced
File size: 4.8 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(* arguments to certain operations: either registers or immediate args *)
14type argument =
15  | Reg of Register.t
16  | Imm of AST.cst*AST.sig_type
17
18(* A function in RTLabs is a mapping from labels to
19   statements. Statements explicitely mention their successors. *)
20
21type statement =
22
23  (* The empty statement. *)
24  | St_skip of Label.t
25
26  (* Emit a cost label. *)
27  | St_cost of CostLabel.t * Label.t
28
29  (* Reset to 0 a loop index *) 
30  | St_ind_0 of CostLabel.index * Label.t
31
32  (* Increment a loop index *)
33  | St_ind_inc of CostLabel.index * Label.t
34
35  (* Assign a constant to registers. Parameters are the destination register,
36     the constant and the label of the next statement. *)
37  | St_cst of Register.t * AST.cst * Label.t
38
39  (* Application of an unary operation. Parameters are the operation, the
40     destination register, the argument register and the label of the next
41     statement. *)
42  | St_op1 of AST.op1 * Register.t * Register.t * Label.t
43
44  (* Application of a binary operation. Parameters are the operation, the
45     destination register, the two arguments and the label of the next
46     statement. *)
47  | St_op2 of AST.op2 * Register.t * argument * argument * Label.t
48
49  (* Memory load. Parameters are the size in bytes of what to load, the
50     register containing the address, the destination register and the label
51     of the next statement. *)
52  | St_load of AST.quantity * argument * Register.t * Label.t
53
54  (* Memory store. Parameters are the size in bytes of what to store, the
55     register containing the address, the source register and the label of the
56     next statement. *)
57  | St_store of AST.quantity * argument * argument * Label.t
58
59  (* Call to a function given its name. Parameters are the name of the
60     function, the arguments of the function, the destination
61     register, the signature of the function and the label of the next
62     statement. *)
63  | St_call_id of AST.ident * argument list * Register.t option *
64                  AST.signature * Label.t
65
66  (* Call to a function given its address. Parameters are the register
67     holding the address of the function, the arguments of the
68     function, the destination register, the signature of the function
69     and the label of the next statement. This statement with an
70     [St_op] before can represent a [St_call_id]. However, we
71     differenciate the two to allow translation to a formalism with no
72     function pointer. *)
73  | St_call_ptr of Register.t * argument list * Register.t option *
74                   AST.signature * Label.t
75
76  (* Tail call to a function given its name. Parameters are the name of the
77     function, the arguments of the function, the signature of the function and
78     the label of the next statement. *)
79  | St_tailcall_id of AST.ident * argument list * AST.signature
80
81  (* Tail call to a function given its address. Parameters are a register
82     holding the address of the function, the arguments of the function, the
83     signature of the function and the label of the next statement. Same remark
84     as for the [St_call_ptr]. *)
85  | St_tailcall_ptr of Register.t * argument list * AST.signature
86
87  (* Branch. Parameters are the register holding the value to branch on, the
88     label to go to when the value evaluates to true (not 0), and the label
89     to go to when the value evaluates to false (0). *)
90  | St_cond of Register.t * Label.t * Label.t
91
92  (* Jump statement. Parameters are a register and a list of
93     labels. The execution will go to the [n]th label of the list of
94     labels, where [n] is the natural value held in the register. *)
95  | St_jumptable of Register.t * Label.t list
96
97  (* Return statement. *)
98  | St_return
99
100
101type graph = statement Label.Map.t
102
103type internal_function =
104    { f_luniverse : Label.Gen.universe ;
105      f_runiverse : Register.universe ;
106      f_result    : (Register.t * AST.sig_type) option ;
107      f_params    : (Register.t * AST.sig_type) list ;
108      f_locals    : (Register.t * AST.sig_type) list ;
109      f_stacksize : AST.abstract_size ;
110      f_graph     : graph ;
111      f_entry     : Label.t ;
112      f_exit      : Label.t }
113
114type function_def =
115  | F_int of internal_function
116  | F_ext of AST.external_function
117
118(* A program is a list of global variables and their reserved space, a list of
119   function names and their definition, and the name of the main function. *)
120
121type program =
122    { vars   : (AST.ident * AST.abstract_size) list ;
123      functs : (AST.ident * function_def) list ;
124      main   : AST.ident option }
Note: See TracBrowser for help on using the repository browser.