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
 [smlnj] / sml / trunk / compiler / ElabData / prim / primop.sig

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

revision 5018, Mon Apr 29 11:33:16 2019 UTC revision 5022, Wed May 1 12:29:11 2019 UTC
# Line 14  Line 14
14        | FLOAT of int        | FLOAT of int
15  (* QUESTION: what about IntInf.int? *)  (* QUESTION: what about IntInf.int? *)
16
17      (* 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      datatype arithop      datatype arithop
22        = ADD | SUB | MUL | NEG                   (* int or float *)        = IADD | ISUB | IMUL | IDIV | IMOD | IQUOT | IREM | INEG
23        | FDIV | FABS | FSQRT | FSIN | FCOS | FTAN (* floating point only *)
24        | LSHIFT | RSHIFT | RSHIFTL               (* int only *)    (* arithmetic operations that do not overflow; for the division operators,
25        | ANDB | ORB | XORB | NOTB                (* int only *)     * we assume that the second argument is never zero (i.e., an explicit
26        | DIV | MOD | QUOT | REM                  (* int only *)     * 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      datatype cmpop      datatype cmpop
36        = GT | GTE | LT | LTE                     (* signed comparisons *)        = GT | GTE | LT | LTE | EQL | NEQ
| LEU | LTU | GEU | GTU                   (* unsigned comparisons *)
| EQL | NEQ                               (* equality *)
| FSGN                                    (* floating point only *)
37
38    (* datatype primop:    (* datatype primop:
39     * Various primitive operations. Those that are designated "inline" (L:) in     * Various primitive operations. Those that are designated "inline" (L:) in
# Line 37  Line 45
45     * See dev-notes/conversions.md for an explanation of the conversion operators.     * See dev-notes/conversions.md for an explanation of the conversion operators.
46     *)     *)
47      datatype primop      datatype primop
48        = ARITH of {                              (* E: arithmetic ops *)        = IARITH of {                             (* E: integer arithmetic ops *)
49              oper: arithop, overflow: bool, kind: numkind              oper : arithop, sz : int            (* kind = INT sz *)
50            }            }
51          | 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        | INLLSHIFT of numkind                    (* E: left shift *)        | INLLSHIFT of numkind                    (* E: left shift *)
59        | INLRSHIFT of numkind                    (* E: right shift *)        | INLRSHIFT of numkind                    (* E: right shift *)
60        | INLRSHIFTL of numkind                   (* E: right shift logical *)        | INLRSHIFTL of numkind                   (* E: right shift logical *)
61        | CMP of {oper: cmpop, kind: numkind}     (* E: generic compare *)        | CMP of {oper: cmpop, kind: numkind}     (* E: generic compare *)
62          | FSGN of int                             (* E: floating point sign test *)
63          | INLCHR                                  (* E: inline int to char conversion *)
64        | 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 *)
65        | 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 *)
66        | 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 *)
# Line 53  Line 70
70        | TRUNC_INF of int                        (* E: intinf truncations, e.g. trunc_inf_31 *)        | 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 *)        | 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 *)        | COPY_INF of int                         (* E: conversions to intinf, e.g. copy_8_inf *)
73        | ROUND of {                              (* E: floor, round *)        | REAL_TO_INT of {                        (* E: floor, round *)
74              floor: bool, from: int, to: int              floor: bool, from: int, to: int
75            }            }
76        | INT_TO_REAL of {                        (* E: real, real32 *)        | INT_TO_REAL of {                        (* E: real, real32 *)
# Line 151  Line 168
168          CCR64 |                         (* passed as real64 *)          CCR64 |                         (* passed as real64 *)
169          CCML                            (* passed as Unsafe.Object.object *)          CCML                            (* passed as Unsafe.Object.object *)
170
val ISUB : primop  (* default integer subtraction *)
val IMUL : primop
val IDIV : primop
val INEG : primop

val FEQLd : primop
val IEQL : primop
val INEQ : primop
val IGT : primop
val ILT : primop
val ILE : primop
val IGE : primop

(** default word arithmetic and comparison operators *)
val UIEQL : primop  (* for UINT kind, may not matter *)

val mkIEQL : int -> primop   (* make equality primop for other sizes *)
val mkUIEQL : int -> primop  (* and for unsigned (kind = UINT) *)

val prNumkind : numkind -> string
val prPrimop: primop -> string

(* This should return more than just a boolean.
* True means "can not be dead-code eliminated" *)
val effect : primop -> bool

171    end (* signature PRIM_OP *)    end (* signature PRIM_OP *)

Legend:
 Removed from v.5018 changed lines Added in v.5022