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 /dev-notes/primop-list.md
ViewVC logotype

Diff of /dev-notes/primop-list.md

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

revision 4878, Mon Oct 8 14:20:35 2018 UTC revision 4879, Tue Oct 9 19:24:33 2018 UTC
# Line 29  Line 29 
29    
30  ## Naming conventions  ## Naming conventions
31    
32    Operations that "belong" to a specific type (*e.g.*, addition) have an initial
33    prefix that specifies the type as follows:
34    
35      * "`int`" -- default tagged integer type (*i.e.*, either `Int31.int` or `Int63.int`)
36      * "`word`" -- default tagged word type (*i.e.*, either `Word31.word` or `Word63.word`)
37      * "`int32`" -- 32-bit integers
38      * "`word32`" -- 32-bit words
39      * "`int64`" -- 64-bit integers
40      * "`word64`" -- 64-bit words
41      * "`intinf`" -- arbitrary precision integers
42      * "`real32`" -- 32-bit real numbers (not yet supported)
43      * "`real64`" -- 64-bit real numbers
44      * "`ptr`" -- machine address
45      * "`barr`" -- bytearray (used for arrays of `Word8.word` and `char`)
46      * "`bvec`" -- bytevector (used for strings and vectors of `Word8.word`)
47      * "`arr`" -- polymorphic arrays
48      * "`vec`" -- polymorphic vectors
49    
50    We use the attribute "`raw`" to denote direct machine operations that are not
51    directly accesible in the Basis Library (*e.g.*, shift operations, where the basis
52    versions clamp the shift amount to the word size, but the raw versions do not).
53    
54    We use the attribute "`unsafe`" for operations that could potentially result in
55    a crash (*e.g.*, array subscript operations that do not check the index against
56    the array bounds).
57    
58  ## Primitive operators  ## Primitive operators
59    
60  ### Size-independent primops  ### Size-independent primops
# Line 54  Line 80 
80    * `! : 'a ref -> 'a`<br/>    * `! : 'a ref -> 'a`<br/>
81      `P.DEREF`      `P.DEREF`
82    
83    * `:= : xx`<br/>    * `:= : 'a ref * 'a -> unit`<br/>
84      `P.ASSIGN`      `P.ASSIGN`
85    
86    * `makeref : 'a ref * 'a -> unit`<br/>    * `makeref : 'a ref * 'a -> unit`<br/>
# Line 145  Line 171 
171    * `objlength : 'a -> int`<br/>    * `objlength : 'a -> int`<br/>
172      `P.OBJLENGTH`      `P.OBJLENGTH`
173    
174    * `unboxedupdate : 'a array * int * 'a -> unit`<br/>    * `bool_not : bool -> bool`<br/>
     `P.UNBOXEDUPDATE`  
   
   
 #### Boolean operations  
   * `inlnot : bool -> bool`<br/>  
175      `P.INLNOT`      `P.INLNOT`
176    
177    
178  #### Bytearray and bytevector operations  #### Bytearray and bytevector operations
179    * `ordof : 'a * int -> 'b`<br/>  Operations on byte/char array/vectors.  We renamed these to make it clear
180      `P.NUMSUBSCRIPT{kind=P.INT 8, checked=false, immutable=true}`  which operations do bounds checking and which do not.
   
   * `store : 'a * int * 'b -> unit`<br/>  
     `P.NUMUPDATE{kind=P.INT 8, checked=false}`  
   
   * `inlbyteof : 'a * int -> 'b`<br/>  
     `P.NUMSUBSCRIPT{kind=P.INT 8, checked=true, immutable=false}`  
   
   * `inlstore : 'a * int * 'b -> unit`<br/>  
     `P.NUMUPDATE{kind=P.INT 8, checked=true}`  
181    
182    * `inlordof : 'a * int -> 'b`<br/>    * `bvec_unsafe_sub : 'a * int -> 'b`<br/>
183      `P.NUMSUBSCRIPT{kind=P.INT 8, checked=true, immutable=true}`      subscript from byte vector without bounds checking
184        (`P.NUMSUBSCRIPT{kind=P.INT 8, checked=false, immutable=true}`)
185    
186      * `barr_unsafe_sub : 'a * int -> 'b`<br/>
187        subscript from byte array without bounds checking
188        (`P.NUMSUBSCRIPT{kind=P.INT 8, checked=false, immutable=false}`)
189    
190      * `barr_unsafe_update : 'a * int * 'b -> unit`<br/>
191        update byte array without bounds checking
192        (`P.NUMUPDATE{kind=P.INT 8, checked=false}`)
193    
194      * `bvec_sub : 'a * int -> 'b`<br/>
195        subscript from byte vector
196        (`P.NUMSUBSCRIPT{kind=P.INT 8, checked=true, immutable=true}`)
197    
198      * `barr_sub : 'a * int -> 'b`<br/>
199        subscript from byte array
200        (`P.NUMSUBSCRIPT{kind=P.INT 8, checked=true, immutable=false}`)
201    
202      * `barr_update : 'a * int * 'b -> unit`<br/>
203        update byte array
204        (`P.NUMUPDATE{kind=P.INT 8, checked=true}`)
205    
206    
207  #### Polymorphic array and vector  #### Polymorphic array and vector
208    * `mkarray : int * 'a -> 'a array`<br/>    * `mkarray : int * 'a -> 'a array`<br/>
209      `P.INLMKARRAY`      create a polymorphic array
210        (`P.INLMKARRAY`)
211    
212    * `arrSub : 'a array * int -> 'a`<br/>    * `arr_unsafe_sub : 'a array * int -> 'a`<br/>
213      `P.SUBSCRIPT`      subscript from polymorphic array without bounds checking
214        (`P.SUBSCRIPT`)
215    * `arrChkSub : 'a array * int -> 'a`<br/>  
216      `P.INLSUBSCRIPT`    * `arr_sub : 'a array * int -> 'a`<br/>
217        subscript from polymorphic array
218    * `vecSub : 'a vector * int -> 'a`<br/>      (`P.INLSUBSCRIPT`)
219      `P.SUBSCRIPTV`  
220      * `vec_unsafe_sub : 'a vector * int -> 'a`<br/>
221    * `vecChkSub : 'a vector * int -> 'a`<br/>      subscript from polymorphic vector without bounds checking
222      `P.INLSUBSCRIPTV`      (`P.SUBSCRIPTV`)
223    
224    * `arrUpdate : 'a array * int * 'a -> unit`<br/>    * `vec_sub : 'a vector * int -> 'a`<br/>
225      `P.UPDATE`      subscript from polymorphic vector
226        (`P.INLSUBSCRIPTV`)
227    * `arrChkUpdate : 'a array * int * 'a -> unit`<br/>  
228      `P.INLUPDATE`    * `arr_unsafe_update : 'a array * int * 'a -> unit`<br/>
229        update a polymorphic array without bounds checking
230        (`P.UPDATE`)
231    
232      * `arr_update : 'a array * int * 'a -> unit`<br/>
233        update a polymorphic array
234        (`P.INLUPDATE`)
235    
236      * `arr_unboxed_update : 'a array * int * 'a -> unit`<br/>
237        update a polymorphic array with an unboxed value, which means that there is
238        no store-list entry created for the update.
239        `P.UNBOXEDUPDATE`
240    
241    
242  #### Sequence operations  #### Sequence operations
243    * `newArray0 : unit -> 'a`<br/>    * `newArray0 : unit -> 'a`<br/>
244      `P.NEW_ARRAY0`      `P.NEW_ARRAY0`
245    
246    * `getSeqData : 'a -> 'b`<br/>    * `seq_get_data : 'a -> 'b`<br/>
247      `P.GET_SEQ_DATA`      `P.GET_SEQ_DATA`
248    
249    * `recordSub : 'a * int -> 'b`<br/>    * `unsafe_record_sub : 'a * int -> 'b`<br/>
250      `P.SUBSCRIPT_REC`      `P.SUBSCRIPT_REC`
251    
252    * `raw64Sub : 'a * int -> real64`<br/>    * `raw64Sub : 'a * int -> real64`<br/>
253        Unclear what purpose this primop serves
254      `P.SUBSCRIPT_RAW64`      `P.SUBSCRIPT_RAW64`
255    
256    
257  ### Numeric primops  ### Numeric primops
258    
259  #### Default tagged integer operations  #### Default tagged integer operations
260    These are the primitive operations on the default tagged integer
261    type (`Int.int`).
262    
263    * `int_add : int * int -> int`<br/>    * `int_add : int * int -> int`<br/>
264      `P.ARITH{oper=P.ADD, overflow=true, kind=P.INT <int-size>}`      `P.ARITH{oper=P.ADD, overflow=true, kind=P.INT <int-size>}`
265    
# Line 278  Line 327 
327      `P.INLABS (P.INT <int-size>)`      `P.INLABS (P.INT <int-size>)`
328    
329  #### Default tagged word operations  #### Default tagged word operations
330    These are the primitive operations on the default tagged word
331    type (`Word.word`).
332    
333    * `word_mul : word * word -> word`<br/>    * `word_mul : word * word -> word`<br/>
334      `P.ARITH{oper=P.MUL, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.MUL, overflow=false, kind=P.INT <int-size>}`
335    

Legend:
Removed from v.4878  
changed lines
  Added in v.4879

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