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

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

New memory model and bug fixes in 8051 branch. Added primitive operations in interpreters from Clight to LIN.

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