Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/compiler/ElabData/prim/primop.sig
ViewVC logotype

Annotation of /sml/trunk/compiler/ElabData/prim/primop.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5473 - (view) (download) (as text)

1 : jhr 4431 (* primop.sig
2 :     *
3 :     * COPYRIGHT (c) 2017 The Fellowship of SML/NJ (http://www.smlnj.org)
4 :     * All rights reserved.
5 :     *)
6 : monnier 16
7 : jhr 4804 signature PRIMOP =
8 : jhr 4431 sig
9 : monnier 16
10 : jhr 4431 (* numkind includes kind and number of bits *)
11 : jhr 4804 datatype numkind
12 :     = INT of int
13 :     | UINT of int
14 : jhr 4431 | FLOAT of int
15 :     (* QUESTION: what about IntInf.int? *)
16 : jhr 4804
17 : jhr 5022 (* arithmetic operations that may overflow; for the division operators,
18 :     * we assume that the second argument is never zero (i.e., an explicit
19 :     * test for zero is done before the operation).
20 :     *)
21 : jhr 4431 datatype arithop
22 : jhr 5022 = IADD | ISUB | IMUL | IDIV | IMOD | IQUOT | IREM | INEG
23 : monnier 16
24 : jhr 5022 (* arithmetic operations that do not overflow; for the division operators,
25 :     * we assume that the second argument is never zero (i.e., an explicit
26 :     * test for zero is done before the operation).
27 :     *)
28 :     datatype pureop
29 :     = ADD | SUB | MUL | QUOT | REM | NEG
30 :     | LSHIFT | RSHIFT | RSHIFTL
31 :     | ORB | XORB | ANDB | NOTB
32 :     | FDIV | FABS | FSQRT | FSIN | FCOS | FTAN
33 :    
34 :     (* comparison operators *)
35 : jhr 4431 datatype cmpop
36 : jhr 5022 = GT | GTE | LT | LTE | EQL | NEQ
37 : monnier 16
38 : jhr 4431 (* datatype primop:
39 :     * Various primitive operations. Those that are designated "inline" (L:) in
40 : jhr 5024 * the comments are expanded into lambda code in terms of other operators.
41 : jhr 5026 * "Environmental" primops (occurring in the Inline structure) are indicated
42 : jhr 4431 * by "E:" in the comment.
43 : jhr 4889 *
44 :     * See dev-notes/conversions.md for an explanation of the conversion operators.
45 : jhr 4431 *)
46 :     datatype primop
47 : jhr 5022 = IARITH of { (* E: integer arithmetic ops *)
48 :     oper : arithop, sz : int (* kind = INT sz *)
49 : jhr 4431 }
50 : jhr 5022 | PURE_ARITH of { (* E: arithmetic ops *)
51 :     oper : pureop, kind : numkind
52 :     }
53 :     | INLDIV of numkind (* E: integer div *)
54 :     | INLMOD of numkind (* E: integer mod *)
55 :     | INLQUOT of numkind (* E: integer/word quot *)
56 :     | INLREM of numkind (* E: integer/word rem *)
57 : jhr 4431 | INLLSHIFT of numkind (* E: left shift *)
58 :     | INLRSHIFT of numkind (* E: right shift *)
59 :     | INLRSHIFTL of numkind (* E: right shift logical *)
60 :     | CMP of {oper: cmpop, kind: numkind} (* E: generic compare *)
61 : jhr 5022 | FSGN of int (* E: floating point sign test *)
62 :     | INLCHR (* E: inline int to char conversion *)
63 : jhr 4431 | TESTU of int * int (* E: conversions to int, e.g. testu_31_31 *)
64 :     | TEST of int * int (* E: conversions to int, e.g. test_32_31_w *)
65 :     | TRUNC of int * int (* E: truncations to smaller int/word, e.g. trunc_32_31_i *)
66 :     | EXTEND of int * int (* E: extensions to int32, word32 *)
67 :     | COPY of int * int (* E: conversions, e.g. copy_32_32_ii *)
68 :     | TEST_INF of int (* E: intinf conversions, e.g. test_inf_31 *)
69 :     | TRUNC_INF of int (* E: intinf truncations, e.g. trunc_inf_31 *)
70 :     | EXTEND_INF of int (* E: intinf extensions, e.g. extend_8_inf *)
71 :     | COPY_INF of int (* E: conversions to intinf, e.g. copy_8_inf *)
72 : jhr 5022 | REAL_TO_INT of { (* E: floor, round *)
73 : jhr 4986 floor: bool, from: int, to: int
74 : jhr 4431 }
75 : jhr 4992 | INT_TO_REAL of { (* E: real, real32 *)
76 : jhr 4986 from: int, to: int
77 : jhr 4431 }
78 : jhr 5024 | NUMSUBSCRIPT of numkind (* E: unchecked numeric array subscript *)
79 :     | NUMSUBSCRIPTV of numkind (* E: unchecked numeric vector subscript *)
80 :     | NUMUPDATE of numkind (* E: unchecked numeric array update *)
81 :     | INLNUMSUBSCRIPT of numkind (* E: L: checked numeric array subscript *)
82 :     | INLNUMSUBSCRIPTV of numkind (* E: L: checked numeric vector subscript *)
83 :     | INLNUMUPDATE of numkind (* E: L: checked numeric array update *)
84 : jhr 4431 | SUBSCRIPT (* E: polymorphic array subscript *)
85 :     | SUBSCRIPTV (* E: poly vector subscript *)
86 :     | INLSUBSCRIPT (* E: L: poly array subscript *)
87 :     | INLSUBSCRIPTV (* E: L: poly vector subscript *)
88 :     | INLMKARRAY (* E: L: poly array creation *)
89 :     | PTREQL | PTRNEQ (* E: pointer equality *)
90 :     | POLYEQL | POLYNEQ (* E: polymorphic equality *)
91 :     | BOXED | UNBOXED (* E: boxity tests *)
92 :     | LENGTH (* E: vector, string, array, ... length *)
93 :     | OBJLENGTH (* E: length of arbitrary heap object *)
94 :     | CAST (* E: cast *)
95 :     | GETHDLR | SETHDLR (* E: get/set exn handler pointer *)
96 :     | GETVAR | SETVAR (* E: get/set var register *)
97 :     | MAKEREF (* E: allocate a ref cell *)
98 :     | CALLCC | CAPTURE | THROW (* E: continuation operations *)
99 :     | ISOLATE (* E: isolating a function *)
100 :     | DEREF (* E: dereferencing *)
101 :     | ASSIGN (* E: assignment *)
102 :     | UPDATE (* E: array or reference update (maybe boxed) *)
103 :     | INLUPDATE (* E: L: array update (maybe boxed) *)
104 :     | UNBOXEDUPDATE (* E: update array of integers WITH tags
105 :     * removed by Zhong, put back by Matthias
106 :     * (see FLINT/trans/primopmap.sml) *)
107 :     | GETTAG (* E: extract the tag portion of an
108 :     * object's descriptor as an ML int *)
109 :     | MKSPECIAL (* E: make a special object *)
110 :     | SETSPECIAL (* E: set the state of a special object *)
111 :     | GETSPECIAL (* E: get the state of a special object *)
112 :     | INLMIN of numkind (* E: L: min *)
113 :     | INLMAX of numkind (* E: L: max *)
114 :     | INLABS of numkind (* E: L: abs *)
115 :     | INLNOT (* E: L: bool not operator *)
116 :     | INLCOMPOSE (* E: L: compose "op o" operator *)
117 : jhr 4804 | INLBEFORE (* E: L: "before" operator *)
118 : jhr 4431 | INLIGNORE (* E: L: "ignore" function *)
119 :     (* primops to support new array representations *)
120 :     | NEW_ARRAY0 (* E: allocate zero-length array header *)
121 :     | GET_SEQ_DATA (* E: get data pointer from arr/vec header *)
122 :     | SUBSCRIPT_REC (* E: record subscript operation *)
123 :     | SUBSCRIPT_RAW64 (* E: raw64 subscript operation *)
124 :     | INLIDENTITY (* E: polymorphic identity *)
125 : jhr 5168 | INTERN64 (* E: convert a pair of word32 values to
126 :     * a 64-bit number.
127 :     *)
128 :     | EXTERN64 (* E: convert a 64-bit number to a pair
129 :     * of word32 values.
130 :     *)
131 : jhr 4431 (* Primops to support C FFI. *)
132 :     | RAW_LOAD of numkind (* E: load from arbitrary memory location *)
133 :     | RAW_STORE of numkind (* E: store to arbitrary memory location *)
134 :     (* E: make a call to a C-function;
135 : blume 773 * The primop carries C function prototype information and specifies
136 :     * which of its (ML-) arguments are floating point. C prototype
137 :     * information is for use by the backend, ML information is for
138 :     * use by the CPS converter. *)
139 : jhr 4431 | RAW_CCALL of {
140 : jhr 4432 c_proto: PrimCTypes.c_proto,
141 : jhr 4431 ml_args: ccall_type list,
142 :     ml_res_opt: ccall_type option,
143 :     reentrant: bool
144 :     } option
145 : leunga 1174 (* Allocate uninitialized storage on the heap.
146 :     * The record is meant to hold short-lived C objects, i.e., they
147 : jhr 4804 * are not ML pointers. The representation is
148 : jhr 5015 * the same as RECORD with tag tag_raw or tag_raw64.
149 : leunga 1174 *)
150 : jhr 5015 | RAW_RECORD of { align64 : bool } (* E: *)
151 : monnier 16
152 : jhr 5026 (* non-environmental primops (not found in Inline) *)
153 : jhr 4431 | UNBOXEDASSIGN (* assignment to integer reference *)
154 : mblume 1347
155 : jhr 4431 | WCAST (* ? *)
156 :     | MARKEXN (* mark an exception value with a string *)
157 : mblume 1683
158 : jhr 4431 | INL_ARRAY (* L: polymorphic array allocation *)
159 :     | INL_VECTOR (* L: polymorphic vector allocation *)
160 :     | INL_MONOARRAY of numkind (* L: monomorphic array allocation *)
161 :     | INL_MONOVECTOR of numkind (* L: monomorphic vector allocation *)
162 : dbm 4428
163 : jhr 4431 | MKETAG (* make a new exception tag *)
164 :     | WRAP (* box a value by wrapping it *)
165 :     | UNWRAP (* unbox a value by unwrapping it *)
166 : jhr 5366 | PTR_TO_WORD (* cast c_pointer to address-sized word type *)
167 :     | WORD_TO_PTR (* case address-sized word type to c_pointer *)
168 : jhr 5473 | REAL_TO_BITS of int (* cast real of the given size to a word of
169 :     * the same size
170 :     *)
171 : dbm 4428
172 : jhr 4431 and ccall_type =
173 :     CCI32 | (* passed as int32 *)
174 :     CCI64 | (* int64, currently unused *)
175 :     CCR64 | (* passed as real64 *)
176 :     CCML (* passed as Unsafe.Object.object *)
177 : dbm 4428
178 : jhr 4431 end (* signature PRIM_OP *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0