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 5022 - (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 :     * the comments are expanded into lambda code in terms of other operators,
41 :     * as are the "checked=true" versions of NUMSUBSCRIPT and NUMUPDATE (L?:).
42 :     * "Environmental" primops (occurring in the InLine structure) are indicated
43 :     * by "E:" in the comment.
44 : jhr 4889 *
45 :     * See dev-notes/conversions.md for an explanation of the conversion operators.
46 : jhr 4431 *)
47 :     datatype primop
48 : jhr 5022 = IARITH of { (* E: integer arithmetic ops *)
49 :     oper : arithop, sz : int (* kind = INT sz *)
50 : jhr 4431 }
51 : jhr 5022 | PURE_ARITH of { (* E: arithmetic ops *)
52 :     oper : pureop, kind : numkind
53 :     }
54 :     | INLDIV of numkind (* E: integer div *)
55 :     | INLMOD of numkind (* E: integer mod *)
56 :     | INLQUOT of numkind (* E: integer/word quot *)
57 :     | INLREM of numkind (* E: integer/word rem *)
58 : jhr 4431 | INLLSHIFT of numkind (* E: left shift *)
59 :     | INLRSHIFT of numkind (* E: right shift *)
60 :     | INLRSHIFTL of numkind (* E: right shift logical *)
61 :     | CMP of {oper: cmpop, kind: numkind} (* E: generic compare *)
62 : jhr 5022 | FSGN of int (* E: floating point sign test *)
63 :     | INLCHR (* E: inline int to char conversion *)
64 : jhr 4431 | TESTU of int * int (* E: conversions to int, e.g. testu_31_31 *)
65 :     | TEST of int * int (* E: conversions to int, e.g. test_32_31_w *)
66 :     | TRUNC of int * int (* E: truncations to smaller int/word, e.g. trunc_32_31_i *)
67 :     | EXTEND of int * int (* E: extensions to int32, word32 *)
68 :     | COPY of int * int (* E: conversions, e.g. copy_32_32_ii *)
69 :     | TEST_INF of int (* E: intinf conversions, e.g. test_inf_31 *)
70 :     | TRUNC_INF of int (* E: intinf truncations, e.g. trunc_inf_31 *)
71 :     | EXTEND_INF of int (* E: intinf extensions, e.g. extend_8_inf *)
72 :     | COPY_INF of int (* E: conversions to intinf, e.g. copy_8_inf *)
73 : jhr 5022 | REAL_TO_INT of { (* E: floor, round *)
74 : jhr 4986 floor: bool, from: int, to: int
75 : jhr 4431 }
76 : jhr 4992 | INT_TO_REAL of { (* E: real, real32 *)
77 : jhr 4986 from: int, to: int
78 : jhr 4431 }
79 :     | NUMSUBSCRIPT of { (* E: L?: ordof, etc. *)
80 :     kind: numkind, checked: bool, immutable: bool
81 :     }
82 :     | NUMUPDATE of { (* E: L?: store, etc. *)
83 :     kind: numkind, checked: bool
84 : jhr 4804 }
85 : jhr 4431 | SUBSCRIPT (* E: polymorphic array subscript *)
86 :     | SUBSCRIPTV (* E: poly vector subscript *)
87 :     | INLSUBSCRIPT (* E: L: poly array subscript *)
88 :     | INLSUBSCRIPTV (* E: L: poly vector subscript *)
89 :     | INLMKARRAY (* E: L: poly array creation *)
90 :     | PTREQL | PTRNEQ (* E: pointer equality *)
91 :     | POLYEQL | POLYNEQ (* E: polymorphic equality *)
92 :     | BOXED | UNBOXED (* E: boxity tests *)
93 :     | LENGTH (* E: vector, string, array, ... length *)
94 :     | OBJLENGTH (* E: length of arbitrary heap object *)
95 :     | CAST (* E: cast *)
96 :     | GETHDLR | SETHDLR (* E: get/set exn handler pointer *)
97 :     | GETVAR | SETVAR (* E: get/set var register *)
98 :     | MAKEREF (* E: allocate a ref cell *)
99 :     | CALLCC | CAPTURE | THROW (* E: continuation operations *)
100 :     | ISOLATE (* E: isolating a function *)
101 :     | DEREF (* E: dereferencing *)
102 :     | ASSIGN (* E: assignment *)
103 :     | UPDATE (* E: array or reference update (maybe boxed) *)
104 :     | INLUPDATE (* E: L: array update (maybe boxed) *)
105 :     | UNBOXEDUPDATE (* E: update array of integers WITH tags
106 :     * removed by Zhong, put back by Matthias
107 :     * (see FLINT/trans/primopmap.sml) *)
108 :     | GETTAG (* E: extract the tag portion of an
109 :     * object's descriptor as an ML int *)
110 :     | MKSPECIAL (* E: make a special object *)
111 :     | SETSPECIAL (* E: set the state of a special object *)
112 :     | GETSPECIAL (* E: get the state of a special object *)
113 :     | INLMIN of numkind (* E: L: min *)
114 :     | INLMAX of numkind (* E: L: max *)
115 :     | INLABS of numkind (* E: L: abs *)
116 :     | INLNOT (* E: L: bool not operator *)
117 :     | INLCOMPOSE (* E: L: compose "op o" operator *)
118 : jhr 4804 | INLBEFORE (* E: L: "before" operator *)
119 : jhr 4431 | INLIGNORE (* E: L: "ignore" function *)
120 :     (* primops to support new array representations *)
121 :     | NEW_ARRAY0 (* E: allocate zero-length array header *)
122 :     | GET_SEQ_DATA (* E: get data pointer from arr/vec header *)
123 :     | SUBSCRIPT_REC (* E: record subscript operation *)
124 :     | SUBSCRIPT_RAW64 (* E: raw64 subscript operation *)
125 :     | INLIDENTITY (* E: polymorphic identity *)
126 :     | CVT64 (* E: convert between external and
127 :     * internal representation of compiler
128 :     * simulated 64-bit scalars, e.g. w64p *)
129 :     (* Primops to support C FFI. *)
130 :     | RAW_LOAD of numkind (* E: load from arbitrary memory location *)
131 :     | RAW_STORE of numkind (* E: store to arbitrary memory location *)
132 :     (* E: make a call to a C-function;
133 : blume 773 * The primop carries C function prototype information and specifies
134 :     * which of its (ML-) arguments are floating point. C prototype
135 :     * information is for use by the backend, ML information is for
136 :     * use by the CPS converter. *)
137 : jhr 4431 | RAW_CCALL of {
138 : jhr 4432 c_proto: PrimCTypes.c_proto,
139 : jhr 4431 ml_args: ccall_type list,
140 :     ml_res_opt: ccall_type option,
141 :     reentrant: bool
142 :     } option
143 : leunga 1174 (* Allocate uninitialized storage on the heap.
144 :     * The record is meant to hold short-lived C objects, i.e., they
145 : jhr 4804 * are not ML pointers. The representation is
146 : jhr 5015 * the same as RECORD with tag tag_raw or tag_raw64.
147 : leunga 1174 *)
148 : jhr 5015 | RAW_RECORD of { align64 : bool } (* E: *)
149 : monnier 16
150 : jhr 4431 (* non-environmental primops (not found in InLine) *)
151 :     | UNBOXEDASSIGN (* assignment to integer reference *)
152 : mblume 1347
153 : jhr 4431 | WCAST (* ? *)
154 :     | MARKEXN (* mark an exception value with a string *)
155 : mblume 1683
156 : jhr 4431 | INL_ARRAY (* L: polymorphic array allocation *)
157 :     | INL_VECTOR (* L: polymorphic vector allocation *)
158 :     | INL_MONOARRAY of numkind (* L: monomorphic array allocation *)
159 :     | INL_MONOVECTOR of numkind (* L: monomorphic vector allocation *)
160 : dbm 4428
161 : jhr 4431 | MKETAG (* make a new exception tag *)
162 :     | WRAP (* box a value by wrapping it *)
163 :     | UNWRAP (* unbox a value by unwrapping it *)
164 : dbm 4428
165 : jhr 4431 and ccall_type =
166 :     CCI32 | (* passed as int32 *)
167 :     CCI64 | (* int64, currently unused *)
168 :     CCR64 | (* passed as real64 *)
169 :     CCML (* passed as Unsafe.Object.object *)
170 : dbm 4428
171 : jhr 4431 end (* signature PRIM_OP *)

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