1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
1995-06-15 01:17:29 -07:00
|
|
|
type machtype_component =
|
|
|
|
Addr
|
|
|
|
| Int
|
|
|
|
| Float
|
|
|
|
|
|
|
|
type machtype = machtype_component array
|
|
|
|
|
1995-07-28 05:19:50 -07:00
|
|
|
let typ_void = ([||] : machtype_component array)
|
1995-06-15 01:17:29 -07:00
|
|
|
let typ_addr = [|Addr|]
|
|
|
|
let typ_int = [|Int|]
|
|
|
|
let typ_float = [|Float|]
|
|
|
|
|
|
|
|
let size_component = function
|
|
|
|
Addr -> Arch.size_addr
|
|
|
|
| Int -> Arch.size_int
|
|
|
|
| Float -> Arch.size_float
|
|
|
|
|
|
|
|
let size_machtype mty =
|
|
|
|
let size = ref 0 in
|
|
|
|
for i = 0 to Array.length mty - 1 do
|
|
|
|
size := !size + size_component mty.(i)
|
|
|
|
done;
|
|
|
|
!size
|
|
|
|
|
|
|
|
type comparison =
|
|
|
|
Ceq
|
|
|
|
| Cne
|
|
|
|
| Clt
|
|
|
|
| Cle
|
|
|
|
| Cgt
|
|
|
|
| Cge
|
|
|
|
|
|
|
|
let negate_comparison = function
|
|
|
|
Ceq -> Cne | Cne -> Ceq
|
|
|
|
| Clt -> Cge | Cle -> Cgt
|
|
|
|
| Cgt -> Cle | Cge -> Clt
|
|
|
|
|
|
|
|
let swap_comparison = function
|
|
|
|
Ceq -> Ceq | Cne -> Cne
|
|
|
|
| Clt -> Cgt | Cle -> Cge
|
|
|
|
| Cgt -> Clt | Cge -> Cle
|
|
|
|
|
|
|
|
type memory_chunk =
|
|
|
|
Byte_unsigned
|
|
|
|
| Byte_signed
|
|
|
|
| Sixteen_unsigned
|
|
|
|
| Sixteen_signed
|
2000-02-04 04:43:18 -08:00
|
|
|
| Thirtytwo_unsigned
|
|
|
|
| Thirtytwo_signed
|
1995-06-15 01:17:29 -07:00
|
|
|
| Word
|
2000-02-04 04:43:18 -08:00
|
|
|
| Single
|
|
|
|
| Double
|
2000-03-10 06:31:06 -08:00
|
|
|
| Double_u
|
1995-06-15 01:17:29 -07:00
|
|
|
|
|
|
|
type operation =
|
2007-01-29 04:11:18 -08:00
|
|
|
Capply of machtype * Debuginfo.t
|
|
|
|
| Cextcall of string * machtype * bool * Debuginfo.t
|
2000-02-04 04:43:18 -08:00
|
|
|
| Cload of memory_chunk
|
1995-06-15 01:17:29 -07:00
|
|
|
| Calloc
|
2000-02-04 04:43:18 -08:00
|
|
|
| Cstore of memory_chunk
|
1995-06-15 01:17:29 -07:00
|
|
|
| Caddi | Csubi | Cmuli | Cdivi | Cmodi
|
|
|
|
| Cand | Cor | Cxor | Clsl | Clsr | Casr
|
|
|
|
| Ccmpi of comparison
|
|
|
|
| Cadda | Csuba
|
|
|
|
| Ccmpa of comparison
|
1996-03-07 05:45:17 -08:00
|
|
|
| Cnegf | Cabsf
|
1995-06-15 01:17:29 -07:00
|
|
|
| Caddf | Csubf | Cmulf | Cdivf
|
|
|
|
| Cfloatofint | Cintoffloat
|
|
|
|
| Ccmpf of comparison
|
2007-01-29 04:11:18 -08:00
|
|
|
| Craise of Debuginfo.t
|
|
|
|
| Ccheckbound of Debuginfo.t
|
1995-06-15 01:17:29 -07:00
|
|
|
|
|
|
|
type expression =
|
1995-07-02 09:41:48 -07:00
|
|
|
Cconst_int of int
|
2000-02-21 11:38:09 -08:00
|
|
|
| Cconst_natint of nativeint
|
1995-07-02 09:41:48 -07:00
|
|
|
| Cconst_float of string
|
|
|
|
| Cconst_symbol of string
|
2000-03-17 05:24:17 -08:00
|
|
|
| Cconst_pointer of int
|
|
|
|
| Cconst_natpointer of nativeint
|
1995-06-15 01:17:29 -07:00
|
|
|
| Cvar of Ident.t
|
|
|
|
| Clet of Ident.t * expression * expression
|
|
|
|
| Cassign of Ident.t * expression
|
|
|
|
| Ctuple of expression list
|
|
|
|
| Cop of operation * expression list
|
|
|
|
| Csequence of expression * expression
|
|
|
|
| Cifthenelse of expression * expression * expression
|
|
|
|
| Cswitch of expression * int array * expression array
|
1995-07-02 09:41:48 -07:00
|
|
|
| Cloop of expression
|
2000-10-02 07:08:30 -07:00
|
|
|
| Ccatch of int * Ident.t list * expression * expression
|
|
|
|
| Cexit of int * expression list
|
1995-06-15 01:17:29 -07:00
|
|
|
| Ctrywith of expression * Ident.t * expression
|
|
|
|
|
|
|
|
type fundecl =
|
|
|
|
{ fun_name: string;
|
|
|
|
fun_args: (Ident.t * machtype) list;
|
1995-07-02 09:41:48 -07:00
|
|
|
fun_body: expression;
|
2012-02-21 09:41:02 -08:00
|
|
|
fun_fast: bool;
|
|
|
|
fun_dbg : Debuginfo.t; }
|
1995-06-15 01:17:29 -07:00
|
|
|
|
|
|
|
type data_item =
|
1995-07-02 09:41:48 -07:00
|
|
|
Cdefine_symbol of string
|
|
|
|
| Cdefine_label of int
|
2002-11-24 07:55:26 -08:00
|
|
|
| Cglobal_symbol of string
|
1995-06-15 01:17:29 -07:00
|
|
|
| Cint8 of int
|
|
|
|
| Cint16 of int
|
2000-02-21 11:38:09 -08:00
|
|
|
| Cint32 of nativeint
|
|
|
|
| Cint of nativeint
|
2000-02-04 04:43:18 -08:00
|
|
|
| Csingle of string
|
|
|
|
| Cdouble of string
|
1995-07-02 09:41:48 -07:00
|
|
|
| Csymbol_address of string
|
|
|
|
| Clabel_address of int
|
1995-06-15 01:17:29 -07:00
|
|
|
| Cstring of string
|
|
|
|
| Cskip of int
|
|
|
|
| Calign of int
|
|
|
|
|
|
|
|
type phrase =
|
|
|
|
Cfunction of fundecl
|
|
|
|
| Cdata of data_item list
|