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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

sml/trunk/compiler/Semant/prim/primop.sig revision 4428, Tue Sep 19 17:42:58 2017 UTC sml/trunk/compiler/ElabData/prim/primop.sig revision 4431, Tue Sep 19 20:09:13 2017 UTC
# Line 1  Line 1 
1  (* Copyright 1996 by AT&T Bell Laboratories *)  (* primop.sig
2  (* primop.sig *)   *
3     * COPYRIGHT (c) 2017 The Fellowship of SML/NJ (http://www.smlnj.org)
4     * All rights reserved.
5     *)
6    
7  (*********************************************************************  (*********************************************************************
8                     Integer/Word Conversions Explained                     Integer/Word Conversions Explained
# Line 118  Line 121 
121  can be eliminated.  can be eliminated.
122  *********************************************************************)  *********************************************************************)
123    
124  signature PRIM_OP =  signature PRIMOP =
125  sig  sig
126    
127  (* numkind includes kind and number of bits *)  (* numkind includes kind and number of bits *)
# Line 126  Line 129 
129    = INT of int    = INT of int
130    | UINT of int    | UINT of int
131    | FLOAT of int    | FLOAT of int
132    (* QUESTION: what about IntInf.int? *)
133    
134  datatype arithop  datatype arithop
135    = + | - | * | / | ~                           (* int or float *)        = ADD | SUB | MUL | DIV | NEG             (* int or float *)
136    | ABS | FSQRT | FSIN | FCOS | FTAN            (* floating point only *)    | ABS | FSQRT | FSIN | FCOS | FTAN            (* floating point only *)
137    | LSHIFT | RSHIFT | RSHIFTL                   (* int only *)    | LSHIFT | RSHIFT | RSHIFTL                   (* int only *)
138    | ANDB | ORB | XORB | NOTB                    (* int only *)    | ANDB | ORB | XORB | NOTB                    (* int only *)
139    | REM | DIV | MOD                             (* int only *)        | REM | QUOT | MOD                        (* int only *)
140    
141  datatype cmpop = > | >= | < | <= | LEU | LTU | GEU | GTU | EQL | NEQ      datatype cmpop
142          = GT | GTE | LT | LTE                     (* signed comparisons *)
143          | LEU | LTU | GEU | GTU                   (* unsigned comparisons *)
144          | EQL | NEQ                               (* equality *)
145                                  | FSGN (* floating point only *)                                  | FSGN (* floating point only *)
146    
147  (* datatype primop:  (* datatype primop:
# Line 145  Line 152 
152   * by "E:" in the comment.   * by "E:" in the comment.
153   *)   *)
154  datatype primop  datatype primop
155    = ARITH of {oper: arithop, overflow: bool, kind: numkind}  (* E: arithmetic ops *)        = ARITH of {                              (* E: arithmetic ops *)
156                oper: arithop, overflow: bool, kind: numkind
157              }
158    | INLLSHIFT of numkind       (* E: left shift *)    | INLLSHIFT of numkind       (* E: left shift *)
159    | INLRSHIFT of numkind       (* E: right shift *)    | INLRSHIFT of numkind       (* E: right shift *)
160    | INLRSHIFTL of numkind      (* E: right shift logical *)    | INLRSHIFTL of numkind      (* E: right shift logical *)
161    | CMP of {oper: cmpop, kind: numkind}  (* generic compare *)        | CMP of {oper: cmpop, kind: numkind}     (* E: generic compare *)
   
162    | TESTU of int * int         (* E: conversions to int, e.g. testu_31_31 *)    | TESTU of int * int         (* E: conversions to int, e.g. testu_31_31 *)
163    | TEST of int * int          (* E: conversions to int, e.g. test_32_31_w *)    | TEST of int * int          (* E: conversions to int, e.g. test_32_31_w *)
164    | TRUNC of int * int         (* E: truncations to smaller int/word, e.g. trunc_32_31_i *)    | TRUNC of int * int         (* E: truncations to smaller int/word, e.g. trunc_32_31_i *)
165    | EXTEND of int * int        (* E: extensions to int32, word32 *)    | EXTEND of int * int        (* E: extensions to int32, word32 *)
166    | COPY of int * int          (* E: conversions, e.g. copy_32_32_ii *)    | COPY of int * int          (* E: conversions, e.g. copy_32_32_ii *)
   
167    | TEST_INF of int            (* E: intinf conversions, e.g. test_inf_31 *)    | TEST_INF of int            (* E: intinf conversions, e.g. test_inf_31 *)
168    | TRUNC_INF of int           (* E: intinf truncations, e.g. trunc_inf_31 *)    | TRUNC_INF of int           (* E: intinf truncations, e.g. trunc_inf_31 *)
169    | EXTEND_INF of int          (* E: intinf extensions, e.g. extend_8_inf *)    | EXTEND_INF of int          (* E: intinf extensions, e.g. extend_8_inf *)
170    | COPY_INF of int            (* E: conversions to intinf, e.g. copy_8_inf *)    | COPY_INF of int            (* E: conversions to intinf, e.g. copy_8_inf *)
171          | ROUND of {                              (* E: floor, round *)
172    | ROUND of {floor: bool, fromkind: numkind, tokind: numkind}       (* E: floor, round *)              floor: bool, fromkind: numkind, tokind: numkind
173    | REAL of {fromkind: numkind, tokind: numkind}                     (* E: real, real32 *)            }
174          | REAL of {                               (* E: real, real32 *)
175    | NUMSUBSCRIPT of {kind: numkind, checked: bool, immutable: bool}  (* E: L?: ordof, etc. *)              fromkind: numkind, tokind: numkind
176    | NUMUPDATE of {kind: numkind, checked: bool}                      (* E: L?: store, etc. *)            }
177          | NUMSUBSCRIPT of {                       (* E: L?: ordof, etc. *)
178                kind: numkind, checked: bool, immutable: bool
179              }
180          | NUMUPDATE of {                          (* E: L?: store, etc. *)
181                kind: numkind, checked: bool
182              }
183    | SUBSCRIPT                  (* E: polymorphic array subscript *)    | SUBSCRIPT                  (* E: polymorphic array subscript *)
184    | SUBSCRIPTV                 (* E: poly vector subscript *)    | SUBSCRIPTV                 (* E: poly vector subscript *)
185    | INLSUBSCRIPT               (* E: L: poly array subscript *)    | INLSUBSCRIPT               (* E: L: poly array subscript *)
186    | INLSUBSCRIPTV              (* E: L: poly vector subscript *)    | INLSUBSCRIPTV              (* E: L: poly vector subscript *)
187    | INLMKARRAY                 (* E: L: poly array creation *)    | INLMKARRAY                 (* E: L: poly array creation *)
   
188    | PTREQL | PTRNEQ            (* E: pointer equality *)    | PTREQL | PTRNEQ            (* E: pointer equality *)
189    | POLYEQL | POLYNEQ          (* E: polymorphic equality *)    | POLYEQL | POLYNEQ          (* E: polymorphic equality *)
190    | BOXED | UNBOXED            (* E: boxity tests *)    | BOXED | UNBOXED            (* E: boxity tests *)
# Line 192  Line 203 
203    | UPDATE                     (* E: array or reference update (maybe boxed) *)    | UPDATE                     (* E: array or reference update (maybe boxed) *)
204    | INLUPDATE                  (* E: L: array update (maybe boxed) *)    | INLUPDATE                  (* E: L: array update (maybe boxed) *)
205    | UNBOXEDUPDATE              (* E: update array of integers WITH tags    | UNBOXEDUPDATE              (* E: update array of integers WITH tags
206                                  * removed by Zhong, put back by Matthias (see FLINT/trans/primopmap.sml) *)                                                   * removed by Zhong, put back by Matthias
207                                                     * (see FLINT/trans/primopmap.sml) *)
208    | GETTAG                     (* E: extract the tag portion of an    | GETTAG                     (* E: extract the tag portion of an
209                                  * object's descriptor as an ML int *)                                  * object's descriptor as an ML int *)
210    | MKSPECIAL                  (* E: make a special object *)    | MKSPECIAL                  (* E: make a special object *)
# Line 205  Line 217 
217    | INLCOMPOSE                 (* E: L: compose "op o"  operator *)    | INLCOMPOSE                 (* E: L: compose "op o"  operator *)
218    | INLBEFORE                  (* E: L: "before" operator *)    | INLBEFORE                  (* E: L: "before" operator *)
219    | INLIGNORE                  (* E: L: "ignore" function *)    | INLIGNORE                  (* E: L: "ignore" function *)
   
220  (* primops to support new array representations *)  (* primops to support new array representations *)
221    | NEW_ARRAY0                 (* E: allocate zero-length array header *)    | NEW_ARRAY0                 (* E: allocate zero-length array header *)
222    | GET_SEQ_DATA               (* E: get data pointer from arr/vec header *)    | GET_SEQ_DATA               (* E: get data pointer from arr/vec header *)
223    | SUBSCRIPT_REC              (* E: record subscript operation *)    | SUBSCRIPT_REC              (* E: record subscript operation *)
224    | SUBSCRIPT_RAW64            (* E: raw64 subscript operation *)    | SUBSCRIPT_RAW64            (* E: raw64 subscript operation *)
   
225    | INLIDENTITY                (* E: polymorphic identity *)    | INLIDENTITY                (* E: polymorphic identity *)
   
226    | CVT64                      (* E: convert between external and    | CVT64                      (* E: convert between external and
227                                  * internal representation of compiler                                  * internal representation of compiler
228                                  * simulated 64-bit scalars, e.g. w64p *)                                  * simulated 64-bit scalars, e.g. w64p *)
229        (* Primops to support C FFI. *)
 (* Primops to support new experimental C FFI. *)  
230    | RAW_LOAD of numkind         (* E: load from arbitrary memory location *)    | RAW_LOAD of numkind         (* E: load from arbitrary memory location *)
231    | RAW_STORE of numkind        (* E: store to arbitrary memory location *)    | RAW_STORE of numkind        (* E: store to arbitrary memory location *)
232      (* make a call to a C-function;      (* E: make a call to a C-function;
233       * The primop carries C function prototype information and specifies       * The primop carries C function prototype information and specifies
234       * which of its (ML-) arguments are floating point. C prototype       * which of its (ML-) arguments are floating point. C prototype
235       * information is for use by the backend, ML information is for       * information is for use by the backend, ML information is for
236       * use by the CPS converter. *)       * use by the CPS converter. *)
237    | RAW_CCALL of { c_proto: CTypes.c_proto,        | RAW_CCALL of {
238                c_proto: CTypes.c_proto,
239                     ml_args: ccall_type list,                     ml_args: ccall_type list,
240                     ml_res_opt: ccall_type option,                     ml_res_opt: ccall_type option,
241                     reentrant: bool                     reentrant: bool
242                   } option  (* E: *)            } option
243     (* Allocate uninitialized storage on the heap.     (* Allocate uninitialized storage on the heap.
244      * The record is meant to hold short-lived C objects, i.e., they      * The record is meant to hold short-lived C objects, i.e., they
245      * are not ML pointers.  The representation is      * are not ML pointers.  The representation is
# Line 239  Line 248 
248    | RAW_RECORD of { fblock: bool }  (* E: *)    | RAW_RECORD of { fblock: bool }  (* E: *)
249    
250  (* non-environmental primops (not found in InLine) *)  (* non-environmental primops (not found in InLine) *)
   
251    | UNBOXEDASSIGN              (* assignment to integer reference *)    | UNBOXEDASSIGN              (* assignment to integer reference *)
252    
253    | WCAST                      (* ? *)    | WCAST                      (* ? *)
# Line 277  Line 285 
285  val prNumkind : numkind -> string  val prNumkind : numkind -> string
286  val prPrimop: primop -> string  val prPrimop: primop -> string
287  val mayRaise : primop -> bool  val mayRaise : primop -> bool
288    
289  (* This should return more than just a boolean.  (* This should return more than just a boolean.
290   * True means "can not be dead-code eliminated" *)   * True means "can not be dead-code eliminated" *)
291  val effect : primop -> bool  val effect : primop -> bool

Legend:
Removed from v.4428  
changed lines
  Added in v.4431

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