source: Deliverables/D2.2/8051-indexed-labels-branch/src/RTL/RTL.mli @ 1340

Last change on this file since 1340 was 1340, checked in by tranquil, 8 years ago

work on RTLabs and RTL completed

File size: 4.9 KB
Line 
1
2(** This module defines the abstract syntax tree of [RTL]. *)
3
4(* The main differences between RTLabs and RTL is instruction selection.
5
6   Also, since addresses in 8051 are two words long, the instructions involving
7   addresses use two registers to represent them. *)
8
9type registers = Register.t list
10
11type statement =
12
13  (* The empty statement. *)
14  | St_skip of Label.t
15
16  (* Emit a cost label. *)
17  | St_cost of CostLabel.t * Label.t
18
19  (* Reset to 0 a loop index *) 
20  | St_ind_0 of CostLabel.index * Label.t
21
22  (* Increment a loop index *)
23  | St_ind_inc of CostLabel.index * Label.t
24
25  (* Assign the address of a symbol to registers. Parameters are the destination
26     registers (low bytes first), the symbol and the label of the next
27     statement. *)
28  | St_addr of Register.t * Register.t * AST.ident * Label.t
29
30  (* Assign the stack pointer to registers. Parameters are the destination
31     registers (low bytes first), and the label of the next statement. *)
32  | St_stackaddr of Register.t * Register.t * Label.t
33
34  (* Assign an integer constant to a register. Parameters are the destination
35     register, the integer and the label of the next statement. *)
36  | St_int of Register.t * int * Label.t
37
38  (* Move the content of a register to another. Parameters are the destination
39     register, the source register, and the label of the next statement. *)
40  | St_move of Register.t * Register.t * Label.t
41
42  (* Apply a binary operation that will later be translated in an operation on
43     the accumulators. Parameters are the operation, the destination registers
44     (ACC first, BACC second), the source registers, and the label of the next
45     statement. *)
46  | St_opaccs of I8051.opaccs * Register.t * Register.t *
47                                Register.t * Register.t * Label.t
48
49  (* Apply an unary operation. Parameters are the operation, the destination
50     register, the source register, and the label of the next statement. *)
51  | St_op1 of I8051.op1 * Register.t * Register.t * Label.t
52
53  (* Apply a binary operation. Parameters are the operation, the destination
54     register, the source registers, and the label of the next statement. *)
55  | St_op2 of I8051.op2 * Register.t * Register.t * Register.t * Label.t
56
57  (* Set the carry flag to zero. Parameter is the label of the next
58     statement. *)
59  | St_clear_carry of Label.t
60
61  (* Set the carry flag to 1. Parameter is the label of the next statement. *)
62  | St_set_carry of Label.t
63
64  (* Load from external memory. Parameters are the destination register, the
65     address registers (low bytes first), and the label of the next
66     statement. *)
67  | St_load of Register.t * Register.t * Register.t * Label.t
68
69  (* Store to external memory. Parameters are the address registers (low bytes
70     first), the source register, and the label of the next statement. *)
71  | St_store of Register.t * Register.t * Register.t * Label.t
72
73  (* Call to a function given its name. Parameters are the name of the function,
74     the arguments of the function, the destination registers, and the label of
75     the next statement. *)
76  | St_call_id of AST.ident * Register.t list * registers * Label.t
77
78  (* Call to a function given its address. Parameters are the registers holding
79     the address of the function (low bytes first), the arguments of the
80     function, the destination registers, and the label of the next
81     statement. *)
82  | St_call_ptr of Register.t * Register.t * Register.t list * registers *
83      Label.t
84
85  (* Tail call to a function given its name. Parameters are the name of the
86     function, and the arguments of the function. *)
87  | St_tailcall_id of AST.ident * Register.t list
88
89  (* Tail call to a function given its address. Parameters are the registers
90     holding the address of the function (low bytes first), and the arguments of
91     the function. *)
92  | St_tailcall_ptr of Register.t * Register.t * Register.t list
93
94  (* Branch. Parameters are the register holding the value for the branching,
95     the label to go to when the value is not 0, and the label to go to when the
96     value is 0. *)
97  | St_cond of Register.t * Label.t * Label.t
98
99  (* Return the value of some registers (low bytes first). *)
100  | St_return of registers
101
102
103type graph = statement Label.Map.t
104
105type internal_function =
106    { f_luniverse : Label.Gen.universe ;
107      f_runiverse : Register.universe ;
108      f_result    : Register.t list (* low byte first *) ;
109      f_params    : Register.t list ;
110      f_locals    : Register.Set.t ;
111      f_stacksize : int ;
112      f_graph     : graph ;
113      f_entry     : Label.t ;
114      f_exit      : Label.t }
115
116type function_def =
117  | F_int of internal_function
118  | F_ext of AST.external_function
119
120(* A program is a list of global variables and their reserved space, a list of
121   function names and their definition, and the name of the main function. *)
122
123type program =
124    { vars   : (AST.ident * int (* size *)) list ;
125      functs : (AST.ident * function_def) list ;
126      main   : AST.ident option }
Note: See TracBrowser for help on using the repository browser.