2 (** This module defines the abstract syntax tree of [LTL]. *)
4 (** The main difference with ERTL is that only physical registers are present in
5 LTL (no more pseudo-registers). Pseudo-registers are associated either a
6 physical register or a location on the stack. This is done by a coloring
7 algorithm. Actually, this coloring algorithm relies on the result of a
8 liveness analysis that will also allow to remove dead code. *)
12 (* The empty statement. *)
16 | St_comment of string * Label.t
18 (* Emit a cost label. *)
19 | St_cost of CostLabel.t * Label.t
21 (* Assign an integer constant to a register. Parameters are the destination
22 register, the integer and the label of the next statement. *)
23 | St_int of I8051.register * int * Label.t
25 (* Pop a value from the IRAM to the accumulator. Parameter is the label of the
29 (* Push a value from the accumulator to the IRAM. Parameter is the label of
30 the next statement. *)
33 (* Assign the address of a symbol to a DPTR. Parameters are the symbol, and
34 the label of the next statement. *)
35 | St_addr of AST.ident * Label.t
37 (* Move the content of the accumulator to a register. Parameters are the
38 destination register, and the label of the next statement. *)
39 | St_from_acc of I8051.register * Label.t
41 (* Move the content of a register to the accumulator. Parameters are the
42 source register, and the label of the next statement. *)
43 | St_to_acc of I8051.register * Label.t
45 (* Apply an operation on the accumulators. Parameters are the operation, and
46 the label of the next statement. *)
47 | St_opaccs of I8051.opaccs * Label.t
49 (* Apply an unary operation on the A accumulator. Parameters are the
50 operation, and the label of the next statement. *)
51 | St_op1 of I8051.op1 * Label.t
53 (* Apply a binary operation on the A accumulator. Parameters are the
54 operation, the other source register, and the label of the next
56 | St_op2 of I8051.op2 * I8051.register * Label.t
58 (* Set the carry flag to zero. Parameter is the label of the next
60 | St_clear_carry of Label.t
62 (* Set the carry flag to 1. Parameter is the label of the next statement. *)
63 | St_set_carry of Label.t
65 (* Load from external memory (address in DPTR) to the accumulator. Parameter
66 is the label of the next statement. *)
69 (* Store to external memory (address in DPTR) from the accumulator. Parameter
70 is the label of the next statement. *)
73 (* Call to a function given its name. Parameters are the name of the function,
74 and the label of the next statement. *)
75 | St_call_id of AST.ident * Label.t
77 (* Call to a function given its address in DPTR. Parameter is the label of the
79 | St_call_ptr of Label.t
81 (* Branch on A accumulator. Parameters are the label to go to when the A
82 accumulator is not 0, and the label to go to when the A accumulator is
84 | St_condacc of Label.t * Label.t
86 (* Transfer control to the address stored in the return address registers. *)
89 type graph = statement Label.Map.t
91 type internal_function =
92 { f_luniverse : Label.Gen.universe ;
99 | F_int of internal_function
100 | F_ext of AST.external_function
102 (* A program is a list of global variables and their reserved space, a list of
103 function names and their definition, and the name of the main function. *)
106 { vars : (AST.ident * int (* size *)) list ;
107 functs : (AST.ident * function_def) list ;
108 main : AST.ident option }