source: Deliverables/D2.2/8051/src/RTL/RTL.mli @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

File size: 4.6 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  (* Assign the address of a symbol to registers. Parameters are the destination
20     registers, the symbol and the label of the next statement. *)
21  | St_addr of Register.t * Register.t * AST.ident * Label.t
22
23  (* Assign the stack pointer to registers. Parameters are the destination
24     registers, and the label of the next statement. *)
25  | St_stackaddr of Register.t * Register.t * Label.t
26
27  (* Assign an integer constant to a register. Parameters are the destination
28     register, the integer and the label of the next statement. *)
29  | St_int of Register.t * int * Label.t
30
31  (* Move the content of a register to another. Parameters are the destination
32     register, the source register, and the label of the next statement. *)
33  | St_move of Register.t * Register.t * Label.t
34
35  (* Apply a binary operation that will later be translated in an operation on
36     the accumulators. Parameters are the operation, the destination register,
37     the source registers, and the label of the next statement. *)
38  | St_opaccs of I8051.opaccs * Register.t * Register.t * Register.t * Label.t
39
40  (* Apply an unary operation. Parameters are the operation, the destination
41     register, the source register, and the label of the next statement. *)
42  | St_op1 of I8051.op1 * Register.t * Register.t * Label.t
43
44  (* Apply a binary operation. Parameters are the operation, the destination
45     register, the source registers, and the label of the next statement. *)
46  | St_op2 of I8051.op2 * Register.t * Register.t * Register.t * Label.t
47
48  (* Set the carry flag to zero. Parameter is the label of the next
49     statement. *)
50  | St_clear_carry of Label.t
51
52  (* Load from external memory. Parameters are the destination register, the
53     address registers, and the label of the next statement. *)
54  | St_load of Register.t * Register.t * Register.t * Label.t
55
56  (* Store to external memory. Parameters are the address registers, the source
57     register, and the label of the next statement. *)
58  | St_store of Register.t * Register.t * Register.t * Label.t
59
60  (* Call to a function given its name. Parameters are the name of the function,
61     the arguments of the function, the destination registers, and the label of
62     the next statement. *)
63  | St_call_id of AST.ident * Register.t list * registers * Label.t
64
65  (* Call to a function given its address. Parameters are the registers holding
66     the address of the function, the arguments of the function, the destination
67     registers, and the label of the next statement. *)
68  | St_call_ptr of Register.t * Register.t * Register.t list * registers *
69                   Label.t
70
71  (* Tail call to a function given its name. Parameters are the name of the
72     function, and the arguments of the function. *)
73  | St_tailcall_id of AST.ident * Register.t list
74
75  (* Tail call to a function given its address. Parameters are the registers
76     holding the address of the function, and the arguments of the function. *)
77  | St_tailcall_ptr of Register.t * Register.t * Register.t list
78
79  (* Branch. Parameters are the register holding the value for the branching,
80     the label to go to when the value is not 0, and the label to go to when the
81     value is 0. *)
82  | St_condacc of Register.t * Label.t * Label.t
83
84  (* Return the value of some registers. Their may be no register in case of
85     procedures, one register when returning an integer, or two registers when
86     returning an address. *)
87  | St_return of registers
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_sig       : AST.signature ;
96      f_result    : Register.t list ;
97      f_params    : Register.t list ;
98      f_locals    : Register.Set.t ;
99      f_stacksize : int ;
100      f_graph     : graph ;
101      f_entry     : Label.t ;
102      f_exit      : Label.t }
103
104type function_def =
105  | F_int of internal_function
106  | F_ext of AST.external_function
107
108(* A program is a list of global variables and their reserved space, a list of
109   function names and their definition, and the name of the main function. *)
110
111type program =
112    { vars   : (AST.ident * int (* size *)) list ;
113      functs : (AST.ident * function_def) list ;
114      main   : AST.ident option }
Note: See TracBrowser for help on using the repository browser.