Module of module types for OrderedType,ComparableType,Printable,Serializable,Discrete...
[ocaml.git] / asmcomp / cmm.ml
blob8d817a857d1e0531ae5a02d21183acc6367d54a1
1 (***********************************************************************)
2 (* *)
3 (* Objective Caml *)
4 (* *)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 (* *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
10 (* *)
11 (***********************************************************************)
13 (* $Id$ *)
15 type machtype_component =
16 Addr
17 | Int
18 | Float
20 type machtype = machtype_component array
22 let typ_void = ([||] : machtype_component array)
23 let typ_addr = [|Addr|]
24 let typ_int = [|Int|]
25 let typ_float = [|Float|]
27 let size_component = function
28 Addr -> Arch.size_addr
29 | Int -> Arch.size_int
30 | Float -> Arch.size_float
32 let size_machtype mty =
33 let size = ref 0 in
34 for i = 0 to Array.length mty - 1 do
35 size := !size + size_component mty.(i)
36 done;
37 !size
39 type comparison =
40 Ceq
41 | Cne
42 | Clt
43 | Cle
44 | Cgt
45 | Cge
47 let negate_comparison = function
48 Ceq -> Cne | Cne -> Ceq
49 | Clt -> Cge | Cle -> Cgt
50 | Cgt -> Cle | Cge -> Clt
52 let swap_comparison = function
53 Ceq -> Ceq | Cne -> Cne
54 | Clt -> Cgt | Cle -> Cge
55 | Cgt -> Clt | Cge -> Cle
57 type memory_chunk =
58 Byte_unsigned
59 | Byte_signed
60 | Sixteen_unsigned
61 | Sixteen_signed
62 | Thirtytwo_unsigned
63 | Thirtytwo_signed
64 | Word
65 | Single
66 | Double
67 | Double_u
69 type operation =
70 Capply of machtype * Debuginfo.t
71 | Cextcall of string * machtype * bool * Debuginfo.t
72 | Cload of memory_chunk
73 | Calloc
74 | Cstore of memory_chunk
75 | Caddi | Csubi | Cmuli | Cdivi | Cmodi
76 | Cand | Cor | Cxor | Clsl | Clsr | Casr
77 | Ccmpi of comparison
78 | Cadda | Csuba
79 | Ccmpa of comparison
80 | Cnegf | Cabsf
81 | Caddf | Csubf | Cmulf | Cdivf
82 | Cfloatofint | Cintoffloat
83 | Ccmpf of comparison
84 | Craise of Debuginfo.t
85 | Ccheckbound of Debuginfo.t
87 type expression =
88 Cconst_int of int
89 | Cconst_natint of nativeint
90 | Cconst_float of string
91 | Cconst_symbol of string
92 | Cconst_pointer of int
93 | Cconst_natpointer of nativeint
94 | Cvar of Ident.t
95 | Clet of Ident.t * expression * expression
96 | Cassign of Ident.t * expression
97 | Ctuple of expression list
98 | Cop of operation * expression list
99 | Csequence of expression * expression
100 | Cifthenelse of expression * expression * expression
101 | Cswitch of expression * int array * expression array
102 | Cloop of expression
103 | Ccatch of int * Ident.t list * expression * expression
104 | Cexit of int * expression list
105 | Ctrywith of expression * Ident.t * expression
107 type fundecl =
108 { fun_name: string;
109 fun_args: (Ident.t * machtype) list;
110 fun_body: expression;
111 fun_fast: bool }
113 type data_item =
114 Cdefine_symbol of string
115 | Cdefine_label of int
116 | Cglobal_symbol of string
117 | Cint8 of int
118 | Cint16 of int
119 | Cint32 of nativeint
120 | Cint of nativeint
121 | Csingle of string
122 | Cdouble of string
123 | Csymbol_address of string
124 | Clabel_address of int
125 | Cstring of string
126 | Cskip of int
127 | Calign of int
129 type phrase =
130 Cfunction of fundecl
131 | Cdata of data_item list