156 lines | 5873 chars
1 | (**************************************************************************) |
2 | (* *) |
3 | (* OCaml *) |
4 | (* *) |
5 | (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
6 | (* *) |
7 | (* Copyright 1996 Institut National de Recherche en Informatique et *) |
8 | (* en Automatique. *) |
9 | (* *) |
10 | (* All rights reserved. This file is distributed under the terms of *) |
11 | (* the GNU Lesser General Public License version 2.1, with the *) |
12 | (* special exception on linking described in the file LICENSE. *) |
13 | (* *) |
14 | (**************************************************************************) |
15 | |
16 | type mutable_flag = Asttypes.mutable_flag |
17 | |
18 | type immediate_or_pointer = Lambda.immediate_or_pointer |
19 | |
20 | type initialization_or_assignment = Lambda.initialization_or_assignment |
21 | |
22 | type is_safe = Lambda.is_safe |
23 | |
24 | type boxed = |
25 | | Boxed |
26 | | Unboxed |
27 | |
28 | type memory_access_size = |
29 | | Sixteen |
30 | | Thirty_two |
31 | | Sixty_four |
32 | |
33 | type primitive = |
34 | | Pread_symbol of string |
35 | (* Operations on heap blocks *) |
36 | | Pmakeblock of int * mutable_flag * block_shape |
37 | | Pfield of int |
38 | | Pfield_computed |
39 | | Psetfield of int * immediate_or_pointer * initialization_or_assignment |
40 | | Psetfield_computed of immediate_or_pointer * initialization_or_assignment |
41 | | Pfloatfield of int |
42 | | Psetfloatfield of int * initialization_or_assignment |
43 | | Pduprecord of Types.record_representation * int |
44 | (* External call *) |
45 | | Pccall of Primitive.description |
46 | (* Exceptions *) |
47 | | Praise of raise_kind |
48 | (* Boolean operations *) |
49 | | Psequand | Psequor | Pnot |
50 | (* Integer operations *) |
51 | | Pnegint | Paddint | Psubint | Pmulint |
52 | | Pdivint of is_safe | Pmodint of is_safe |
53 | | Pandint | Porint | Pxorint |
54 | | Plslint | Plsrint | Pasrint |
55 | | Pintcomp of integer_comparison |
56 | | Poffsetint of int |
57 | | Poffsetref of int |
58 | (* Float operations *) |
59 | | Pintoffloat | Pfloatofint |
60 | | Pnegfloat | Pabsfloat |
61 | | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat |
62 | | Pfloatcomp of float_comparison |
63 | (* String operations *) |
64 | | Pstringlength | Pstringrefu | Pstringrefs |
65 | | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets |
66 | (* Array operations *) |
67 | | Pmakearray of array_kind * mutable_flag |
68 | | Pduparray of array_kind * mutable_flag |
69 | (** For [Pduparray], the argument must be an immutable array. |
70 | The arguments of [Pduparray] give the kind and mutability of the |
71 | array being *produced* by the duplication. *) |
72 | | Parraylength of array_kind |
73 | | Parrayrefu of array_kind |
74 | | Parraysetu of array_kind |
75 | | Parrayrefs of array_kind |
76 | | Parraysets of array_kind |
77 | (* Test if the argument is a block or an immediate integer *) |
78 | | Pisint |
79 | (* Test if the (integer) argument is outside an interval *) |
80 | | Pisout |
81 | (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) |
82 | | Pbintofint of boxed_integer |
83 | | Pintofbint of boxed_integer |
84 | | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) |
85 | | Pnegbint of boxed_integer |
86 | | Paddbint of boxed_integer |
87 | | Psubbint of boxed_integer |
88 | | Pmulbint of boxed_integer |
89 | | Pdivbint of { size : boxed_integer; is_safe : is_safe } |
90 | | Pmodbint of { size : boxed_integer; is_safe : is_safe } |
91 | | Pandbint of boxed_integer |
92 | | Porbint of boxed_integer |
93 | | Pxorbint of boxed_integer |
94 | | Plslbint of boxed_integer |
95 | | Plsrbint of boxed_integer |
96 | | Pasrbint of boxed_integer |
97 | | Pbintcomp of boxed_integer * integer_comparison |
98 | (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) |
99 | | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout |
100 | | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout |
101 | (* size of the nth dimension of a big array *) |
102 | | Pbigarraydim of int |
103 | (* load/set 16,32,64 bits from a string: (unsafe)*) |
104 | | Pstring_load of (memory_access_size * is_safe) |
105 | | Pbytes_load of (memory_access_size * is_safe) |
106 | | Pbytes_set of (memory_access_size * is_safe) |
107 | (* load/set 16,32,64 bits from a |
108 | (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) |
109 | | Pbigstring_load of (memory_access_size * is_safe) |
110 | | Pbigstring_set of (memory_access_size * is_safe) |
111 | (* byte swap *) |
112 | | Pbswap16 |
113 | | Pbbswap of boxed_integer |
114 | (* Integer to external pointer *) |
115 | | Pint_as_pointer |
116 | (* Inhibition of optimisation *) |
117 | | Popaque |
118 | |
119 | and integer_comparison = Lambda.integer_comparison = |
120 | Ceq | Cne | Clt | Cgt | Cle | Cge |
121 | |
122 | and float_comparison = Lambda.float_comparison = |
123 | CFeq | CFneq | CFlt | CFnlt | CFgt | CFngt | CFle | CFnle | CFge | CFnge |
124 | |
125 | and array_kind = Lambda.array_kind = |
126 | Pgenarray | Paddrarray | Pintarray | Pfloatarray |
127 | |
128 | and value_kind = Lambda.value_kind = |
129 | (* CR mshinwell: Pfloatval should be renamed to Pboxedfloatval *) |
130 | Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval |
131 | |
132 | and block_shape = Lambda.block_shape |
133 | and boxed_integer = Primitive.boxed_integer = |
134 | Pnativeint | Pint32 | Pint64 |
135 | |
136 | and bigarray_kind = Lambda.bigarray_kind = |
137 | Pbigarray_unknown |
138 | | Pbigarray_float32 | Pbigarray_float64 |
139 | | Pbigarray_sint8 | Pbigarray_uint8 |
140 | | Pbigarray_sint16 | Pbigarray_uint16 |
141 | | Pbigarray_int32 | Pbigarray_int64 |
142 | | Pbigarray_caml_int | Pbigarray_native_int |
143 | | Pbigarray_complex32 | Pbigarray_complex64 |
144 | |
145 | and bigarray_layout = Lambda.bigarray_layout = |
146 | Pbigarray_unknown_layout |
147 | | Pbigarray_c_layout |
148 | | Pbigarray_fortran_layout |
149 | |
150 | and raise_kind = Lambda.raise_kind = |
151 | | Raise_regular |
152 | | Raise_reraise |
153 | | Raise_notrace |
154 | |
155 | let equal (x: primitive) (y: primitive) = x = y |
156 |