@@ -3048,139 +3048,3 @@ let sign_extend_int arg ~bits ~loc =
3048
3048
3049
3049
let unary p arg ~loc = Lprim (Pscalar (Unary p), [arg], loc)
3050
3050
let binary p x y ~loc = Lprim (Pscalar (Binary p), [x; y], loc)
3051
-
3052
- (* CR jvanburen: clean up *)
3053
- (* module Bytecode = struct
3054
- * (* naked integers are boxed or tagged as appropriate in bytecode *)
3055
- *
3056
- * type smallint = Int8 | Int16 | Immediate
3057
- *
3058
- *
3059
- * let static_cast arg ~src ~dst ~loc =
3060
- * if src = dst then arg else
3061
- * Lprim (Pscalar (Unary (Static_cast {src ; dst })), [arg], loc)
3062
- *
3063
- * let to_bytecode_compatible arg ~from ~loc =
3064
- * static_cast arg ~src
3065
- * match (t : Scalar.t) with
3066
- * | Value value -> arg, Scalar.Bytecode.Value value
3067
- * | Naked value ->
3068
- * let bytecode = Scalar.Bytecode.Value value
3069
- * Lprim (Pscalar (Binary( Static_cast { src = t ; dst = Value value}) ) arg, [], Lconst const_unit), Scalar.Bytecode.Value Int8
3070
- * match value with
3071
- * | Int8 ->
3072
- * | Int16 -> Lprim (Pint16 arg, [], Lconst const_unit), Scalar.Bytecode.Value Int16
3073
- * | Immediate -> arg, Scalar.Bytecode.Value Immediate
3074
- * | _ -> assert false
3075
- *
3076
- * | Value () ->
3077
- * Lprim (Pscalar (Binary (Static_cast
3078
- * {src = Naked_int8}
3079
- * )),
3080
- * [int_size; Lconst(const_int bits)], loc)
3081
- *
3082
- * | Tagged_immediate Tagged_immediate
3083
- * -> Misc.fatal_error "There is no Naked_immediate type yet"
3084
- *
3085
- * let static_cast ~src ~dst args loc =
3086
- * let src = Bytecode_repr.of_size src in
3087
- * let dst = Bytecode_repr.of_size dst in
3088
- * let arg = Lprim (Bytecode_repr.wrap src, args, loc) in
3089
- * let converted =
3090
- * match src, dst with
3091
- * | Tagged src, Tagged dst ->
3092
- * if Bytecode_repr.bits src <= Bytecode_repr.bits dst
3093
- * then arg
3094
- * else sign_extend arg ~bits:(Bytecode_repr.bits dst)
3095
- * | Boxed src, Tagged dst ->
3096
- * sign_extend
3097
- * ~bits:(Bytecode_repr.bits dst)
3098
- * (Lprim (Pintofbint src, args, loc))
3099
- * | Tagged (_ : unboxed_integer), Boxed dst ->
3100
- * Lprim (Pbox_int (dst, alloc_local), [arg], loc)
3101
- * | Boxed src, Boxed dst ->
3102
- * Lprim (Pcvtbint (src, dst, alloc_local), [ arg ], loc)
3103
- * in
3104
- * Lprim (Bytecode_repr.unwrap dst, [converted], loc)
3105
- * end
3106
- *
3107
- * let naked_int_cast ~src ~dst args loc =
3108
- * let src = Bytecode_repr.of_size src in
3109
- * let dst = Bytecode_repr.of_size dst in
3110
- * let arg = Lprim (Bytecode_repr.wrap src, args, loc) in
3111
- * let converted =
3112
- * match src, dst with
3113
- * | Tagged src, Tagged dst ->
3114
- * if Bytecode_repr.bits src <= Bytecode_repr.bits dst
3115
- * then arg
3116
- * else sign_extend arg ~bits:(Bytecode_repr.bits dst)
3117
- * | Boxed src, Tagged dst ->
3118
- * sign_extend
3119
- * ~bits:(Bytecode_repr.bits dst)
3120
- * (Lprim (Pintofbint src, args, loc))
3121
- * | Tagged (_ : unboxed_integer), Boxed dst ->
3122
- * Lprim (Pbox_int (dst, alloc_local), [arg], loc)
3123
- * | Boxed src, Boxed dst ->
3124
- * Lprim (Pcvtbint (src, dst, alloc_local), [ arg ], loc)
3125
- * in
3126
- * Lprim (Bytecode_repr.unwrap dst, [converted], loc)
3127
- *
3128
- * let naked_int_cmp ~op ~size args loc =
3129
- * let repr = Bytecode_repr.of_size size in
3130
- * let wrap = Bytecode_repr.wrap repr in
3131
- * let args = ListLabels.map args ~f:(fun arg ->
3132
- * Lprim(wrap, [arg], loc))
3133
- * in
3134
- * let prim =
3135
- * match repr with
3136
- * | Tagged (_ : unboxed_integer) -> Pintcomp op
3137
- * | Boxed boxed -> Pbintcomp (boxed, op)
3138
- * in
3139
- * Lprim (prim, args, loc)
3140
- *
3141
- * let naked_int_binop ~op ~size args loc =
3142
- * let repr = Bytecode_repr.of_size size in
3143
- * let wrap = Bytecode_repr.wrap repr in
3144
- * let args = ListLabels.map args ~f:(fun arg ->
3145
- * Lprim (wrap, [arg], loc))
3146
- * in
3147
- * let go ?unbox_second_argument prim =
3148
- * match args with
3149
- * | [] | [_] | _::_::_::_ ->
3150
- * Misc.fatal_error "naked_int_binop expected two arguments"
3151
- * | [l; r] ->
3152
- * let args =
3153
- * match unbox_second_argument with
3154
- * | None -> [l; r]
3155
- * | Some boxed -> [l; Lprim (Pintofbint boxed, [r], loc)]
3156
- * in
3157
- * Lprim (Bytecode_repr.unwrap repr, [Lprim (prim, args, loc)], loc)
3158
- *
3159
- * in
3160
- * match op, repr with
3161
- * | Add , Tagged (_ : unboxed_integer) -> go Paddint
3162
- * | Sub , Tagged (_ : unboxed_integer) -> go Psubint
3163
- * | Mul , Tagged (_ : unboxed_integer) -> go Pmulint
3164
- * | Sdiv , Tagged (_ : unboxed_integer) -> go (Pdivint Safe)
3165
- * | Srem , Tagged (_ : unboxed_integer) -> go (Pmodint Safe)
3166
- * | And , Tagged (_ : unboxed_integer) -> go Pandint
3167
- * | Or , Tagged (_ : unboxed_integer) -> go Porint
3168
- * | Xor , Tagged (_ : unboxed_integer) -> go Pxorint
3169
- * | Shl , Tagged (_ : unboxed_integer) -> go Plslint
3170
- * | Lshr, Tagged (_ : unboxed_integer) -> go Plsrint
3171
- * | Ashr, Tagged (_ : unboxed_integer) -> go Pasrint
3172
- * | Add , Boxed boxed -> go (Paddbint (boxed, alloc_heap))
3173
- * | Sub , Boxed boxed -> go (Psubbint (boxed, alloc_heap))
3174
- * | Mul , Boxed boxed -> go (Pmulbint (boxed, alloc_heap))
3175
- * | Sdiv , Boxed boxed -> go (Pdivbint {size=boxed; is_safe=Safe; mode=alloc_heap})
3176
- * | Srem , Boxed boxed -> go (Pmodbint {size=boxed; is_safe=Safe; mode=alloc_heap})
3177
- * | And , Boxed boxed -> go (Pandbint (boxed, alloc_heap))
3178
- * | Or , Boxed boxed -> go (Porbint (boxed, alloc_heap))
3179
- * | Xor , Boxed boxed -> go (Pxorbint (boxed, alloc_heap))
3180
- * (* boxed integer shifts take a tagged integer as the second argument *)
3181
- * | Shl , Boxed boxed ->
3182
- * go (Plslbint (boxed, alloc_heap)) ~unbox_second_argument:boxed
3183
- * | Lshr, Boxed boxed ->
3184
- * go (Plsrbint (boxed, alloc_heap)) ~unbox_second_argument:boxed
3185
- * | Ashr, Boxed boxed ->
3186
- * go (Pasrbint (boxed, alloc_heap)) ~unbox_second_argument:boxed *)
0 commit comments