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 4961, Thu Apr 18 10:18:12 2019 UTC revision 4989, Fri Apr 26 17:17:35 2019 UTC
# Line 14  Line 14 
14      datatypes used to represent primitive operations internally in the      datatypes used to represent primitive operations internally in the
15      front-end of the compiler.  The main type is `Primop.primop`.      front-end of the compiler.  The main type is `Primop.primop`.
16    
17    * `compiler/ElabData/prim/primop.sml`<br/>    * `compiler/ElabData/prim/primop.sig`<br/>
18      this file defines the `PRIMOP` signature use for the `Primop` structure.      this file defines the `PRIMOP` signature use for the `Primop` structure.
19    
20    * `compiler/Semant/prim/primop-bindings.sml`<br/>    * `compiler/Semant/prim/primop-bindings.sml`<br/>
# Line 47  Line 47 
47    * "`vec`" -- polymorphic vectors    * "`vec`" -- polymorphic vectors
48    * "`seq`" -- sequence types (arrays and vectors)    * "`seq`" -- sequence types (arrays and vectors)
49    
50    Following the type prefix may one or more attributes, which highlight properties
51    of the operation.
52    
53  We use the attribute "`raw`" to denote direct machine operations that are not  We use the attribute "`raw`" to denote direct machine operations that are not
54  directly accesible in the Basis Library (*e.g.*, shift operations, where the basis  directly accesible in the Basis Library (*e.g.*, shift operations, where the basis
55  versions clamp the shift amount to the word size, but the raw versions do not).  versions clamp the shift amount to the word size, but the raw versions do not).
# Line 141  Line 144 
144    
145    * `objlength : 'a -> int`<br/>    * `objlength : 'a -> int`<br/>
146      extracts the length field from an object's header word.      extracts the length field from an object's header word.
147      `P.OBJLENGTH`      (`P.OBJLENGTH`)
148    
149    
150  #### Inline operations  #### Inline operations
# Line 161  Line 164 
164    * `bool_not : bool -> bool`<br/>    * `bool_not : bool -> bool`<br/>
165      `P.INLNOT`      `P.INLNOT`
166    
167  Some additional candidates for inlined operations include `hd`, `tl`, `null`, `chr`, and `ord`.  Some additional candidates for inlined operations include `hd`, `tl`, `null`, `chr`,
168    and `ord`.
169    
170  If the compiler had the `option` and `order` datatypes builtin (like `bool` and `list`),  If the compiler had the `option` and `order` datatypes builtin (like `bool` and `list`),
171  then `valOf`, `isSome`, `isNone` and some of the `compare` functions could be inlined.  then `valOf`, `isSome`, `isNone` and some of the `compare` functions could also
172    be inlined.
173    
174    In the long run, however, a better way to support inlining library functions would
175    be through a reliable cross-module inliner.
176    
177  #### Bytearray and bytevector operations  #### Bytearray and bytevector operations
178  Operations on byte/char array/vectors.  We renamed these to make it clear  Operations on byte/char array/vectors.  We renamed these to make it clear
# Line 194  Line 202 
202      update byte array      update byte array
203      (`P.NUMUPDATE{kind=P.INT 8, checked=true}`)      (`P.NUMUPDATE{kind=P.INT 8, checked=true}`)
204    
   
205  #### Polymorphic array and vector  #### Polymorphic array and vector
206    * `mkarray : int * 'a -> 'a array`<br/>    * `mkarray : int * 'a -> 'a array`<br/>
207      create a polymorphic array      create a polymorphic array
# Line 227  Line 234 
234    * `arr_unboxed_update : 'a array * int * 'a -> unit`<br/>    * `arr_unboxed_update : 'a array * int * 'a -> unit`<br/>
235      update a polymorphic array with an unboxed value, which means that there is      update a polymorphic array with an unboxed value, which means that there is
236      no store-list entry created for the update.      no store-list entry created for the update.
237      `P.UNBOXEDUPDATE`      (`P.UNBOXEDUPDATE`)
   
238    
239  #### Sequence operations  #### Sequence operations
240  Sequence values (*e.g.*, `string`, `'a array`, `RealVector.vector`, *etc*.)  Sequence values (*e.g.*, `string`, `'a array`, `RealVector.vector`, *etc*.)
# Line 240  Line 246 
246    
247    * `seq_length : 'a -> int`<br/>    * `seq_length : 'a -> int`<br/>
248      get the length field from a sequence header      get the length field from a sequence header
249      `P.LENGTH`      (`P.LENGTH`)
250    
251    * `seq_data : 'a -> 'b`<br/>    * `seq_data : 'a -> 'b`<br/>
252      get the length field from a sequence header      get the length field from a sequence header
253      `P.GET_SEQ_DATA`      (`P.GET_SEQ_DATA`)
254    
255    * `unsafe_record_sub : 'a * int -> 'b`<br/>    * `unsafe_record_sub : 'a * int -> 'b`<br/>
256      `P.SUBSCRIPT_REC`      `P.SUBSCRIPT_REC`
257    
258    * `raw64Sub : 'a * int -> real64`<br/>    * `raw64Sub : 'a * int -> real64`<br/>
259      Unclear what purpose this primop serves      gets an element from a packed tuple of 64-bit reals.  The only use of
260      `P.SUBSCRIPT_RAW64`      this function is in the implementation of the `Unsafe.Object.nth`
261        function. <br/>
262        (`P.SUBSCRIPT_RAW64`)
263    
264    
265  ### Numeric primops  ### Numeric primops
# Line 262  Line 270 
270    
271    * `int_add : int * int -> int`<br/>    * `int_add : int * int -> int`<br/>
272      Signed integer addition with overflow checking.      Signed integer addition with overflow checking.
273      `P.ARITH{oper=P.ADD, overflow=true, kind=P.INT <int-size>}`      (`P.ARITH{oper=P.ADD, overflow=true, kind=P.INT <int-size>}`)
274    
275    * `int_unsafe_add : int * int -> int`<br/>    * `int_unsafe_add : int * int -> int`<br/>
276      Signed integer addition *without* overflow checking.      Signed integer addition *without* overflow checking.
277      `P.ARITH{oper=P.ADD, overflow=false, kind=P.INT <int-size>}`      (`P.ARITH{oper=P.ADD, overflow=false, kind=P.INT <int-size>}`)
278    
279    * `int_sub : int * int -> int`<br/>    * `int_sub : int * int -> int`<br/>
280      Signed integer subtraction with overflow checking.      Signed integer subtraction with overflow checking.
281      `P.ARITH{oper=P.SUB, overflow=true, kind=P.INT <int-size>}`      (`P.ARITH{oper=P.SUB, overflow=true, kind=P.INT <int-size>}`)
282    
283    * `int_unsafe_sub : int * int -> int`<br/>    * `int_unsafe_sub : int * int -> int`<br/>
284      Signed integer subtraction *without* overflow checking.      Signed integer subtraction *without* overflow checking.
285      `P.ARITH{oper=P.SUB, overflow=false, kind=P.INT <int-size>}`      (`P.ARITH{oper=P.SUB, overflow=false, kind=P.INT <int-size>}`)
286    
287    * `int_mul : int * int -> int`<br/>    * `int_mul : int * int -> int`<br/>
288      `P.ARITH{oper=P.MUL, overflow=true, kind=P.INT <int-size>}`      `P.ARITH{oper=P.MUL, overflow=true, kind=P.INT <int-size>}`
# Line 333  Line 341 
341    * `int_max : int * int -> int`<br/>    * `int_max : int * int -> int`<br/>
342      `P.INLMAX (P.INT <int-size>)`      `P.INLMAX (P.INT <int-size>)`
343    
344    * `int_abs : word32 -> word32`<br/>    * `int_abs : int -> int`<br/>
345      `P.INLABS (P.INT <int-size>)`      `P.INLABS (P.INT <int-size>)`
346    
347  #### Default tagged word operations  #### Default tagged word operations
# Line 341  Line 349 
349  type (`Word.word`).  type (`Word.word`).
350    
351    * `word_mul : word * word -> word`<br/>    * `word_mul : word * word -> word`<br/>
352      `P.ARITH{oper=P.MUL, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.MUL, overflow=false, kind=P.UINT <int-size>}`
353    
354    * `word_div : word * word -> word`<br/>    * `word_div : word * word -> word`<br/>
355      `P.ARITH{oper=P.QUOT, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.QUOT, overflow=false, kind=P.UINT <int-size>}`
356    
357    * `word_mod : word * word -> word`<br/>    * `word_mod : word * word -> word`<br/>
358      `P.ARITH{oper=P.REM, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.REM, overflow=false, kind=P.UINT <int-size>}`
359    
360    * `word_add : word * word -> word`<br/>    * `word_add : word * word -> word`<br/>
361      `P.ARITH{oper=P.ADD, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.ADD, overflow=false, kind=P.UINT <int-size>}`
362    
363    * `word_sub : word * word -> word`<br/>    * `word_sub : word * word -> word`<br/>
364      `P.ARITH{oper=P.SUB, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.SUB, overflow=false, kind=P.UINT <int-size>}`
365    
366    * `word_orb : word * word -> word`<br/>    * `word_orb : word * word -> word`<br/>
367      `P.ARITH{oper=P.ORB, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.ORB, overflow=false, kind=P.UINT <int-size>}`
368    
369    * `word_xorb : word * word -> word`<br/>    * `word_xorb : word * word -> word`<br/>
370      `P.ARITH{oper=P.XORB, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.XORB, overflow=false, kind=P.UINT <int-size>}`
371    
372    * `word_andb : word * word -> word`<br/>    * `word_andb : word * word -> word`<br/>
373      `P.ARITH{oper=P.ANDB, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.ANDB, overflow=false, kind=P.UINT <int-size>}`
374    
375    * `word_notb : word -> word`<br/>    * `word_notb : word -> word`<br/>
376      `P.ARITH{oper=P.NOTB, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.NOTB, overflow=false, kind=P.UINT <int-size>}`
377    
378    * `word_neg : word -> word`<br/>    * `word_neg : word -> word`<br/>
379      `P.ARITH{oper=P.NEG, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.NEG, overflow=false, kind=P.UINT <int-size>}`
380    
381    * `word_rshift : word * word -> word`<br/>    * `word_rshift : word * word -> word`<br/>
382      `P.ARITH{oper=P.RSHIFT, overflow=false, kind=P.INT <int-size>}`      `P.INLRSHIFT(P.UINT <int-size>)`
383    
384    * `word_rshiftl : word * word -> word`<br/>    * `word_rshiftl : word * word -> word`<br/>
385      `P.ARITH{oper=P.RSHIFTL, overflow=false, kind=P.INT <int-size>}`      `P.INLRSHIFTL(P.UINT <int-size>)`
386    
387    * `word_lshift : word * word -> word`<br/>    * `word_lshift : word * word -> word`<br/>
388      `P.ARITH{oper=P.LSHIFT, overflow=false, kind=P.INT <int-size>}`      `P.ARITH{oper=P.LSHIFT, overflow=false, kind=P.UINT <int-size>}`
389    
390      * `word_raw_rshift : word * word -> word`<br/>
391        `P.INLLSHIFT(P.UINT <int-size>)`
392    
393      * `word_raw_rshiftl : word * word -> word`<br/>
394        `P.ARITH{oper=P.RSHIFTL, overflow=false, kind=P.UINT <int-size>}`
395    
396      * `word_raw_lshift : word * word -> word`<br/>
397        `P.ARITH{oper=P.RSHIFT, overflow=false, kind=P.UINT <int-size>}`
398    
399    * `word_gt : word * word -> bool`<br/>    * `word_gt : word * word -> bool`<br/>
400      `P.CMP{oper=P.GT, kind=P.UINT <int-size>}`      `P.CMP{oper=P.GT, kind=P.UINT <int-size>}`
# Line 397  Line 414 
414    * `word_neq : word * word -> bool`<br/>    * `word_neq : word * word -> bool`<br/>
415      `P.CMP{oper=P.NEQ, kind=P.UINT <int-size>}`      `P.CMP{oper=P.NEQ, kind=P.UINT <int-size>}`
416    
   * `word_raw_rshift : word * word -> word`<br/>  
     `P.INLRSHIFT(P.UINT <int-size>)`  
   
   * `word_raw_rshiftl : word * word -> word`<br/>  
     `P.INLRSHIFTL(P.UINT <int-size>)`  
   
   * `word_raw_lshift : word * word -> word`<br/>  
     `P.INLLSHIFT(P.UINT <int-size>)`  
   
417    * `word_min : word * word -> word`<br/>    * `word_min : word * word -> word`<br/>
418      `P.INLMIN (P.UINT <int-size>)`      `P.INLMIN (P.UINT <int-size>)`
419    
# Line 478  Line 486 
486    * `int32_max : int32 * int32 -> int32`<br/>    * `int32_max : int32 * int32 -> int32`<br/>
487      `P.INLMAX (P.INT 32)`      `P.INLMAX (P.INT 32)`
488    
489    * `int32_abs : word32 -> word32`<br/>    * `int32_abs : int32 -> int32`<br/>
490      `P.INLABS (P.INT 32)`      `P.INLABS (P.INT 32)`
491    
492  #### 32-bit word operations  #### 32-bit word operations
493    These operations work on the boxed 32-bit word type on 32-bit
494    machines and are just wrappers for 63-bit tagged word operations
495    on 64-bit machines.
496    
497      * `word32_mul : word32 * word32 -> word32`<br/>
498        `P.ARITH{oper=P.MUL, overflow=false, kind=P.UINT 32}`
499    
500      * `word32_div : word32 * word32 -> word32`<br/>
501        `P.ARITH{oper=P.QUOT, overflow=false, kind=P.UINT 32}`
502    
503      * `word32_mod : word32 * word32 -> word32`<br/>
504        `P.ARITH{oper=P.REM, overflow=false, kind=P.UINT 32}`
505    
506      * `word32_add : word32 * word32 -> word32`<br/>
507        `P.ARITH{oper=P.ADD, overflow=false, kind=P.UINT 32}`
508    
509      * `word32_sub : word32 * word32 -> word32`<br/>
510        `P.ARITH{oper=P.SUB, overflow=false, kind=P.UINT 32}`
511    
512      * `word32_orb : word32 * word32 -> word32`<br/>
513        `P.ARITH{oper=P.ORB, overflow=false, kind=P.UINT 32}`
514    
515      * `word32_xorb : word32 * word32 -> word32`<br/>
516        `P.ARITH{oper=P.XORB, overflow=false, kind=P.UINT 32}`
517    
518      * `word32_andb : word32 * word32 -> word32`<br/>
519        `P.ARITH{oper=P.ANDB, overflow=false, kind=P.UINT 32}`
520    
521      * `word32_notb : word32 -> word32`<br/>
522        `P.ARITH{oper=P.NOTB, overflow=false, kind=P.UINT 32}`
523    
524      * `word32_neg : word32 -> word32`<br/>
525        `P.ARITH{oper=P.NEG, overflow=false, kind=P.UINT 32}`
526    
527      * `word32_rshift : word32 * word -> word`<br/>
528        `P.INLRSHIFT(P.UINT 32)`
529    
530      * `word32_rshiftl : word32 * word -> word`<br/>
531        `P.INLRSHIFTL(P.UINT 32)`
532    
533      * `word32_lshift : word32 * word -> word`<br/>
534        `P.INLLSHIFT(P.UINT 32)`
535    
536      * `word32_raw_rshift : word32 * word -> word`<br/>
537        `P.ARITH{oper=P.RSHIFT, overflow=false, kind=P.UINT 32}`
538    
539      * `word32_raw_rshiftl : word32 * word -> word`<br/>
540        `P.ARITH{oper=P.RSHIFTL, overflow=false, kind=P.UINT 32}`
541    
542      * `word32_raw_lshift : word32 * word -> word`<br/>
543        `P.ARITH{oper=P.LSHIFT, overflow=false, kind=P.UINT 32}`
544    
545      * `word32_gt : word32 * word32 -> bool`<br/>
546        `P.CMP{oper=P.GT, kind=P.UINT 32}`
547    
548      * `word32_ge : word32 * word32 -> bool`<br/>
549        `P.CMP{oper=P.GTE, kind=P.UINT 32}`
550    
551      * `word32_lt : word32 * word32 -> bool`<br/>
552        `P.CMP{oper=P.LT, kind=P.UINT 32}`
553    
554      * `word32_le : word32 * word32 -> bool`<br/>
555        `P.CMP{oper=P.LTE, kind=P.UINT 32}`
556    
557      * `word32_eql : word32 * word32 -> bool`<br/>
558        `P.CMP{oper=P.EQL, kind=P.UINT 32}`
559    
560      * `word32_neq : word32 * word32 -> bool`<br/>
561        `P.CMP{oper=P.NEQ, kind=P.UINT 32}`
562    
563      * `word32_min : word32 * word32 -> word32`<br/>
564        `P.INLMIN (P.UINT 32)`
565    
566      * `word32_max : word32 * word32 -> word32`<br/>
567        `P.INLMAX (P.UINT 32)`
568    
569  #### 64-bit integer operations  #### 64-bit integer operations
570    * `int64_add : int64 * int64 -> int64`<br/>    * `int64_add : int64 * int64 -> int64`<br/>
# Line 547  Line 630 
630    * `int64_max : int64 * int64 -> int64`<br/>    * `int64_max : int64 * int64 -> int64`<br/>
631      `P.INLMAX (P.INT 64)`      `P.INLMAX (P.INT 64)`
632    
633    * `int64_abs : word32 -> word32`<br/>    * `int64_abs : int64 -> int64`<br/>
634      `P.INLABS (P.INT 64)`      `P.INLABS (P.INT 64)`
635    
636  #### 64-bit word operations  #### 64-bit word operations
637    
638      * `word64_mul : word64 * word64 -> word64`<br/>
639        `P.ARITH{oper=P.MUL, overflow=false, kind=P.UINT 64}`
640    
641      * `word64_div : word64 * word64 -> word64`<br/>
642        `P.ARITH{oper=P.QUOT, overflow=false, kind=P.UINT 64}`
643    
644      * `word64_mod : word64 * word64 -> word64`<br/>
645        `P.ARITH{oper=P.REM, overflow=false, kind=P.UINT 64}`
646    
647      * `word64_add : word64 * word64 -> word64`<br/>
648        `P.ARITH{oper=P.ADD, overflow=false, kind=P.UINT 64}`
649    
650      * `word64_sub : word64 * word64 -> word64`<br/>
651        `P.ARITH{oper=P.SUB, overflow=false, kind=P.UINT 64}`
652    
653      * `word64_orb : word64 * word64 -> word64`<br/>
654        `P.ARITH{oper=P.ORB, overflow=false, kind=P.UINT 64}`
655    
656      * `word64_xorb : word64 * word64 -> word64`<br/>
657        `P.ARITH{oper=P.XORB, overflow=false, kind=P.UINT 64}`
658    
659      * `word64_andb : word64 * word64 -> word64`<br/>
660        `P.ARITH{oper=P.ANDB, overflow=false, kind=P.UINT 64}`
661    
662      * `word64_notb : word64 -> word64`<br/>
663        `P.ARITH{oper=P.NOTB, overflow=false, kind=P.UINT 64}`
664    
665      * `word64_neg : word64 -> word64`<br/>
666        `P.ARITH{oper=P.NEG, overflow=false, kind=P.UINT 64}`
667    
668      * `word64_rshift : word64 * word -> word`<br/>
669        `P.INLRSHIFT(P.UINT 64)`
670    
671      * `word64_rshiftl : word64 * word -> word`<br/>
672        `P.INLRSHIFTL(P.UINT 64)`
673    
674      * `word64_lshift : word64 * word -> word`<br/>
675        `P.INLLSHIFT(P.UINT 64)`
676    
677      * `word64_raw_rshift : word64 * word -> word`<br/>
678        `P.ARITH{oper=P.RSHIFT, overflow=false, kind=P.UINT 64}`
679    
680      * `word64_raw_rshiftl : word64 * word -> word`<br/>
681        `P.ARITH{oper=P.RSHIFTL, overflow=false, kind=P.UINT 64}`
682    
683      * `word64_raw_lshift : word64 * word -> word`<br/>
684        `P.ARITH{oper=P.LSHIFT, overflow=false, kind=P.UINT 64}`
685    
686      * `word64_gt : word64 * word64 -> bool`<br/>
687        `P.CMP{oper=P.GT, kind=P.UINT 64}`
688    
689      * `word64_ge : word64 * word64 -> bool`<br/>
690        `P.CMP{oper=P.GTE, kind=P.UINT 64}`
691    
692      * `word64_lt : word64 * word64 -> bool`<br/>
693        `P.CMP{oper=P.LT, kind=P.UINT 64}`
694    
695      * `word64_le : word64 * word64 -> bool`<br/>
696        `P.CMP{oper=P.LTE, kind=P.UINT 64}`
697    
698      * `word64_eql : word64 * word64 -> bool`<br/>
699        `P.CMP{oper=P.EQL, kind=P.UINT 64}`
700    
701      * `word64_neq : word64 * word64 -> bool`<br/>
702        `P.CMP{oper=P.NEQ, kind=P.UINT 64}`
703    
704      * `word64_min : word64 * word64 -> word64`<br/>
705        `P.INLMIN (P.UINT 64)`
706    
707      * `word64_max : word64 * word64 -> word64`<br/>
708        `P.INLMAX (P.UINT 64)`
709    
710  #### 64-bit real operations  #### 64-bit real operations
711      * `real64_add : real64 * real64 -> real64`<br/>
712        `P.ARITH{oper=P.ADD, overflow=true, kind=P.FLOAT 64}`
713    
714      * `real64_sub : real64 * real64 -> real64`<br/>
715        `P.ARITH{oper=P.SUB, overflow=true, kind=P.FLOAT 64}`
716    
717      * `real64_mul : real64 * real64 -> real64`<br/>
718        `P.ARITH{oper=P.MUL, overflow=true, kind=P.FLOAT 64}`
719    
720      * `real64_div : real64 * real64 -> real64`<br/>
721        `P.ARITH{oper=P.QUOT, overflow=true, kind=P.FLOAT 64}`
722    
723      * `real64_neg : word32 -> word32`<br/>
724        `P.ARITH{oper=P.NEG, overflow=true, kind=P.FLOAT 64}`
725    
726      * `real64_gt : real64 * real64 -> bool`<br/>
727        `P.CMP{oper=P.GT, kind=P.FLOAT 64}`
728    
729      * `real64_ge : real64 * real64 -> bool`<br/>
730        `P.CMP{oper=P.GTE, kind=P.FLOAT 64}`
731    
732      * `real64_lt : real64 * real64 -> bool`<br/>
733        `P.CMP{oper=P.LT, kind=P.FLOAT 64}`
734    
735      * `real64_le : real64 * real64 -> bool`<br/>
736        `P.CMP{oper=P.LTE, kind=P.FLOAT 64}`
737    
738      * `real64_eql : real64 * real64 -> bool`<br/>
739        `P.CMP{oper=P.EQL, kind=P.FLOAT 64}`
740    
741      * `real64_neq : real64 * real64 -> bool`<br/>
742        `P.CMP{oper=P.NEQ, kind=P.FLOAT 64}`
743    
744      * `real64_sgn : real64 -> bool`<br/>
745        `P.CMP{oper=P.FSGN, kind=P.FLOAT 64}`
746    
747      * `real64_min : real64 * real64 -> real64`<br/>
748        `P.INLMIN (P.FLOAT 64)`
749    
750      * `real64_max : real64 * real64 -> real64`<br/>
751        `P.INLMAX (P.FLOAT 64)`
752    
753      * `abs : real64 -> real64`<br/>
754        `P.ARITH{oper=P.ABS, kind=P.FLOAT 64}`
755    
756      * `real64_sin : real64 -> real64`<br/>
757        `P.ARITH{oper=P.FSIN, kind=P.FLOAT 64}`
758    
759      * `real64_cos : real64 -> real64`<br/>
760        `P.ARITH{oper=P.FCOS, kind=P.FLOAT 64}`
761    
762      * `real64_tan : real64 -> real64`<br/>
763        `P.ARITH{oper=P.FTAN, kind=P.FLOAT 64}`
764    
765      * `real64_sqrt : real64 -> real64`<br/>
766        `P.ARITH{oper=P.FSQRT, kind=P.FLOAT 64}`
767    
768    
769  ### Conversions  ### Conversions
770    
771    We use the following operation-prefixes for conversions between integer and
772    word types:
773    
774      * `cvt_unsigned` -- for word to integer conversions where the resulting
775        integer will be non-negative (*i.e.*, represent the same number as the
776        argument).  These operations raise `Overflow` if the argument it not
777        representable as an integer of the specified size.
778    
779      * `cvt_signed` -- for word to integer conversions where the resulting
780        integer will have the same bit representation as the argument.  These
781        operations raise `Overflow` if the argument (interpreted as a signed
782        2's complement number) is not representable as an integer of the specified
783        size.
784    
785      * `cvt` -- for integer-to-integer, integer-to-word, and word-to-word,
786        conversions.  In the case of integer-to-integer conversions, the
787        operation will raise `Overflow` if the argument is too large to
788        represent in the result type.
789    
790    For conversions between integer and word types, there are five basic
791    primitive operations (**TEST**, **TESTU**, **EXTEND**, **TRUNC**, and **COPY**),
792    which are described in the `conversions.md` file.
793    
794      * `cvt_int_to_word : int -> word`<br />
795        `P.COPY(<int-size>, <int-size>)`
796    
797      * `cvt_signed_word_to_int : word -> int`<br />
798        `P.COPY(<int-size>, <int-size>)`
799    
800      * `cvt_unsigned_word_to_int : word -> int`<br />
801        `P.TESTU(<int-size>, <int-size>)`
802    
803      * `cvt_int_to_int8 : int -> int8`<br />
804        `P.TEST(<int-size>, 8)`
805    
806      * `cvt_int_to_word8 : int -> word8`<br />
807        `P.TRUNC(<int-size>, 8)`
808    
809      * `cvt_signed_word_to_int8 : word -> int8`<br />
810        `P.TEST(<int-size>, 8)`
811    
812      * `cvt_unsigned_word_to_int8 : word -> int8`<br />
813        `P.TESTU(<int-size>, 8)`
814    
815      * `cvt_word_to_word8 : word -> word8`<br />
816        `P.TRUNC(<int-size>, 8)`
817    
818      * `cvt_int_to_int32 : int -> int32`<br />
819        `P.EXTEND(31, 32)` on 32-bit targets or `P.TEST(63, 32)` on 64-bit targets.
820    
821      * `cvt_int_to_word32 : int -> word32`<br />
822        `P.COPY(31, 32)` on 32-bit targets or `P.TRUNC(63, 32)` on 64-bit targets.
823    
824      * `cvt_signed_word_to_int32 : word -> int32`<br />
825        `P.EXTEND(31, 32)` on 32-bit targets or `P.TEST(63, 32)` on 64-bit targets.
826    
827      * `cvt_unsigned_word_to_int32 : word -> int32`<br />
828        `P.COPY(31, 32)` on 32-bit targets or `P.TESTU(63, 32)` on 64-bit targets.
829    
830      * `cvt_word_to_word32 : word -> word32`<br />
831        `P.COPY(31, 32)` on 32-bit targets or `P.TRUNC(63, 32)` on 64-bit targets.
832    
833      * `cvt_int_to_int64 : int -> int64`<br />
834        `P.EXTEND(<int-size>, 64)`
835    
836      * `cvt_int_to_word64 : int -> word64`<br />
837    
838      * `cvt_signed_word_to_int64 : word -> int64`<br />
839    
840      * `cvt_unsigned_word_to_int64 : word -> int64`<br />
841    
842      * `cvt_word_to_word64 : word -> word64`<br />
843    
844      * `cvt_int8_to_int : int8 -> int`<br />
845    
846      * `cvt_int8_to_word : int8 -> word`<br />
847    
848      * `cvt_signed_word8_to_int : word8 -> int`<br />
849    
850      * `cvt_unsigned_word8_to_int : word8 -> int`<br />
851    
852      * `cvt_word8_to_word : word8 -> word`<br />
853    
854      * `cvt_int32_to_int : int32 -> int`<br />
855    
856      * `cvt_int32_to_word : int32 -> word`<br />
857    
858      * `cvt_signed_word32_to_int : word32 -> int`<br />
859    
860      * `cvt_unsigned_word32_to_int : word32 -> int`<br />
861    
862      * `cvt_word32_to_word : word32 -> word`<br />
863    
864      * `cvt_int64_to_int : int64 -> int`<br />
865    
866      * `cvt_int64_to_word : int64 -> word`<br />
867    
868      * `cvt_signed_word64_to_int : word64 -> int`<br />
869    
870      * `cvt_unsigned_word64_to_int : word64 -> int`<br />
871    
872      * `cvt_word64_to_word : word64 -> word`<br />
873    
874    #### Conversions that are specific to 32-bit targets
875    
876    These conversions assume that the `LargeWord` structure is
877    bound to `Word32` (even though there is a `Word64` structure).
878    
879      * `cvt_int8_to_word32 : int8 -> word32`<br />
880        `P.EXTEND(8, 32)`
881    
882      * `cvt_word8_to_word32 : word8 -> word32`<br />
883        `P.COPY(8, 32)`
884    
885      * `cvt_int32_to_word32 : int32 -> word32`<br />
886        `P.COPY(32, 32)`
887    
888      * `cvt_int64_to_word32 : int64 -> word32`<br />
889        `P.TRUNC(64, 32)`
890    
891      * `cvt_word64_to_word32 : word64 -> word32`<br />
892        `P.TRUNC(64, 32)`
893    
894    #### Conversions that are specific to 64-bit targets
895    
896      * `cvt_int8_to_word64 : int8 -> word64`<br />
897        `P.EXTEND(8, 64)`
898    
899      * `cvt_word8_to_word64 : word8 -> word64`<br />
900        `P.COPY(8, 64)`
901    
902      * `cvt_int32_to_word64 : int32 -> word64`<br />
903        `P.EXTEND(32, 64)`
904    
905      * `cvt_word32_to_word64 : word32 -> word64`<br />
906        `P.COPY(32, 64)`
907    
908      * `cvt_int64_to_word64 : int64 -> word64`<br />
909        `P.COPY(64, 64)`
910    
911    #### Conversions between integers and reals
912    
913      * `cvt_int_to_real64 : int -> real64`<br />
914        `P.REAL{from=<int-size>, to=64}`
915    
916      * `cvt_int32_to_real64 : int32 -> real64`<br />
917        `P.REAL{from=32, to=64}`
918    
919      * `floor_real64_to_int : real64 -> int`<br />
920        `P.ROUND{floor=true, from=64, to=<int-size>}`
921    
922      * `round_real64_to_int : real64 -> int`<br />
923        `P.ROUND{floor=false, from=64, to=<int-size>}`

Legend:
Removed from v.4961  
changed lines
  Added in v.4989

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