(** This module defines the abstract syntax tree of [LIN]. *) (** Compared to LTL where functions were graphs, the functions of a LIN program are sequential instructions. *) type statement = (* Unconditional branch. *) | St_goto of Label.t (* Label a statement. *) | St_label of Label.t (* Comment. *) | St_comment of string (* Emit a cost label. *) | St_cost of CostLabel.t (* Assign an integer constant to a register. Parameters are the destination register, and the integer. *) | St_int of I8051.register * int (* Pop a value from the IRAM to the accumulator. *) | St_pop (* Push a value from the accumulator to the IRAM. *) | St_push (* Assign the address of a symbol to DPTR. Parameter is the symbol. *) | St_addr of AST.ident (* Move the content of the accumulator to a register. Parameters is the destination register. *) | St_from_acc of I8051.register (* Move the content of a register to the accumulator. Parameters is the source register. *) | St_to_acc of I8051.register (* Apply an operation on the accumulators. Parameter is the operation. *) | St_opaccs of I8051.opaccs (* Apply an unary operation on the A accumulator. Parameter is the operation. *) | St_op1 of I8051.op1 (* Apply a binary operation on the A accumulator. Parameters are the operation, and the other source register. *) | St_op2 of I8051.op2 * I8051.register (* Set the carry flag to zero. *) | St_clear_carry (* Set the carry flag to 1. *) | St_set_carry (* Load from external memory (address in DPTR) to the accumulator. *) | St_load (* Store to external memory (address in DPTR) from the accumulator. *) | St_store (* Call to a function given its name. Parameter is the name of the function. *) | St_call_id of AST.ident (* Call to a function given its address in DPTR. *) | St_call_ptr (* Branch on A accumulator. Parameter is the label to go to when the A accumulator is not 0. *) | St_condacc of Label.t (* Transfer control to the address stored in the return address registers. *) | St_return type internal_function = statement list type function_def = | F_int of internal_function | F_ext of AST.external_function (* A program is a list of global variables and their reserved space, a list of function names and their definition, and the name of the main function. *) type program = { vars : (AST.ident * int (* size *)) list ; functs : (AST.ident * function_def) list ; main : AST.ident option }