source: Deliverables/D2.2/8051/src/cminor/cminor.mli @ 818

Last change on this file since 818 was 818, checked in by ayache, 8 years ago

32 and 16 bits operations support in D2.2/8051

File size: 2.4 KB
Line 
1
2(** This module defines the abstract syntax tree of [Cminor]. *)
3
4(* This file describes the abstract syntax of the Cminor language.
5   Only types are: int8, int16, int32 and void. *)
6
7type etype = AST.sig_type
8
9type expression = Expr of expr_descr * etype
10and expr_descr =
11  | Id of AST.ident
12  | Cst of AST.cst
13  | Op1 of AST.op1 * expression
14  | Op2 of AST.op2 * expression * expression
15  | Mem of AST.quantity * expression          (* Memory read *)
16  | Cond of expression * expression * expression (* Ternary expression *)
17  | Exp_cost of CostLabel.t * expression         (* Labelled expression *)
18
19type statement =
20  | St_skip
21  | St_assign of AST.ident * expression
22  | St_store of AST.quantity * expression * expression
23
24  (* Function call. Parameters are an optional variable to store the
25     result of the function, the name of the function, the arguments,
26     and finally its signature. *)
27  | St_call of AST.ident option * expression * expression list * AST.signature
28
29  (* Tail call to a function, that is, a call to a function following
30     by a return statement. Parameters are the name of the function,
31     the arguments and its signature. *)
32  | St_tailcall of expression * expression list * AST.signature
33
34  | St_seq of statement * statement
35  | St_ifthenelse of expression * statement * statement
36  | St_loop of statement
37  | St_block of statement
38  | St_exit of int
39
40  (* Switch. Parameters are the expression whose value is switch, a
41     table of cases and their corresponding number of blocks to exit,
42     and the number of block to exit in the default case. *)
43  | St_switch of expression * (int*int) list * int
44
45  | St_return of expression option
46  | St_label of AST.ident * statement
47  | St_goto of string
48  | St_cost of CostLabel.t * statement
49
50
51type internal_function =
52    { f_return    : AST.type_return ;
53      f_params    : (AST.ident * etype) list ;
54      f_vars      : (AST.ident * etype) list ;
55      f_stacksize : AST.abstract_size ;
56      f_body      : statement }
57
58type function_def =
59  | F_int of internal_function
60  | F_ext of AST.external_function
61
62(* A program is a list of global variables and their initialization
63   datas, a list of function names and their definition, and the name
64   of the main function. *)
65
66type program =
67    { vars   : (AST.ident * AST.abstract_size * AST.data list option) list ;
68      functs : (AST.ident * function_def) list ;
69      main   : AST.ident option }
Note: See TracBrowser for help on using the repository browser.