Skip to content

Commit 1d28ccf

Browse files
committed
Revert "removed small int parts"
This moves commit e0b8691 into this PR.
1 parent e856bc9 commit 1d28ccf

File tree

8 files changed

+51
-22
lines changed

8 files changed

+51
-22
lines changed

backend/arm64/cfg_selection.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class selector =
171171
method! insert_move_extcall_arg env ty_arg src dst =
172172
let ty_arg_is_int32 =
173173
match ty_arg with
174-
| XInt32 -> true
174+
| XInt8 | XInt16 | XInt32 -> true
175175
| XInt | XInt64 | XFloat32 | XFloat | XVec128 -> false
176176
in
177177
if macosx && ty_arg_is_int32 && is_stack_slot dst

backend/arm64/proc.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ let external_calling_conventions
297297
begin match ty_arg with
298298
| XInt | XInt64 ->
299299
loc.(i) <- [| loc_int last_int make_stack int ofs |]
300-
| XInt32 ->
300+
| XInt32 | XInt16 | XInt8 ->
301301
loc.(i) <- [| loc_int32 last_int make_stack int ofs |]
302302
| XFloat ->
303303
loc.(i) <- [| loc_float last_float make_stack float ofs |]

backend/arm64/selection.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ class selector =
157157
| _ -> super#select_operation op args dbg
158158

159159
method! insert_move_extcall_arg env ty_arg src dst =
160-
if macosx && ty_arg = XInt32 && is_stack_slot dst
160+
let ty_arg_is_int32 =
161+
match ty_arg with
162+
| XInt8 | XInt16 | XInt32 -> true
163+
| XInt | XInt64 | XFloat32 | XFloat | XVec128 -> false
164+
in
165+
if macosx && ty_arg_is_int32 && is_stack_slot dst
161166
then self#insert env (Iop (Ispecific Imove32)) src dst
162167
else self#insert_moves env src dst
163168
end

backend/cmm.ml

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# 1 "backend/cmm.ml"
12
(**************************************************************************)
23
(* *)
34
(* OCaml *)
@@ -107,6 +108,8 @@ let ge_component comp1 comp2 =
107108

108109
type exttype =
109110
| XInt
111+
| XInt8
112+
| XInt16
110113
| XInt32
111114
| XInt64
112115
| XFloat32
@@ -115,6 +118,8 @@ type exttype =
115118

116119
let machtype_of_exttype = function
117120
| XInt -> typ_int
121+
| XInt8 -> typ_int
122+
| XInt16 -> typ_int
118123
| XInt32 -> typ_int
119124
| XInt64 -> typ_int
120125
| XFloat -> typ_float
@@ -611,21 +616,19 @@ let equal_machtype_component (left : machtype_component) (right : machtype_compo
611616
| Float32, (Val | Addr | Int | Float | Vec128 | Valx2) ->
612617
false
613618

614-
let equal_exttype left right =
615-
match left, right with
616-
| XInt, XInt -> true
617-
| XInt32, XInt32 -> true
618-
| XInt64, XInt64 -> true
619-
| XFloat32, XFloat32 -> true
620-
| XFloat, XFloat -> true
621-
| XVec128, XVec128 -> true
622-
| XInt, (XInt32 | XInt64 | XFloat | XFloat32 | XVec128)
623-
| XInt32, (XInt | XInt64 | XFloat | XFloat32 | XVec128)
624-
| XInt64, (XInt | XInt32 | XFloat | XFloat32 | XVec128)
625-
| XFloat, (XInt | XInt32 | XFloat32 | XInt64 | XVec128)
626-
| XVec128, (XInt | XInt32 | XInt64 | XFloat | XFloat32)
627-
| XFloat32, (XInt | XInt32 | XInt64 | XFloat | XVec128) ->
628-
false
619+
let equal_exttype
620+
((XInt
621+
| XInt8
622+
| XInt16
623+
| XInt32
624+
| XInt64
625+
| XFloat32
626+
| XFloat
627+
| XVec128) as left)
628+
right
629+
=
630+
(* we can use polymorphic compare as long as exttype is all constant constructors *)
631+
left = right
629632

630633
let equal_vec128_type v1 v2 =
631634
match v1, v2 with

backend/cmm.mli

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ val ge_component
7575

7676
type exttype =
7777
| XInt (**r OCaml value, word-sized integer *)
78+
| XInt8 (**r 8-bit integer *)
79+
| XInt16 (**r 16-bit integer *)
7880
| XInt32 (**r 32-bit integer *)
7981
| XInt64 (**r 64-bit integer *)
8082
| XFloat32 (**r single-precision FP number *)

backend/printcmm.ml

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ let machtype ppf mty =
4949

5050
let exttype ppf = function
5151
| XInt -> fprintf ppf "int"
52+
| XInt8 -> fprintf ppf "int8"
53+
| XInt16 -> fprintf ppf "int16"
5254
| XInt32 -> fprintf ppf "int32"
5355
| XInt64 -> fprintf ppf "int64"
5456
| XFloat -> fprintf ppf "float"

middle_end/flambda2/to_cmm/to_cmm_shared.ml

+15-4
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ module Update_kind = struct
306306
type kind =
307307
| Pointer
308308
| Immediate
309+
| Naked_int8
310+
| Naked_int16
309311
| Naked_int32
310312
| Naked_int64
311313
| Naked_float
@@ -329,8 +331,8 @@ module Update_kind = struct
329331

330332
let field_size_in_words t =
331333
match t.kind with
332-
| Pointer | Immediate | Naked_int32 | Naked_int64 | Naked_float
333-
| Naked_float32 ->
334+
| Pointer | Immediate | Naked_int8 | Naked_int16 | Naked_int32 | Naked_int64
335+
| Naked_float | Naked_float32 ->
334336
1
335337
| Naked_vec128 -> 2
336338

@@ -348,6 +350,10 @@ module Update_kind = struct
348350

349351
let naked_vec128s = { kind = Naked_vec128; stride = 16 }
350352

353+
let naked_int8_fields = { kind = Naked_int8; stride = Arch.size_addr }
354+
355+
let naked_int16_fields = { kind = Naked_int16; stride = Arch.size_addr }
356+
351357
let naked_int32_fields = { kind = Naked_int32; stride = Arch.size_addr }
352358

353359
let naked_float32_fields = { kind = Naked_float32; stride = Arch.size_addr }
@@ -372,8 +378,8 @@ let make_update env res dbg ({ kind; stride } : Update_kind.t) ~symbol var
372378
| Immediate ->
373379
(* See [caml_initialize]; we can avoid this function in this case. *)
374380
None
375-
| Naked_int32 | Naked_int64 | Naked_float | Naked_float32 | Naked_vec128
376-
->
381+
| Naked_int8 | Naked_int16 | Naked_int32 | Naked_int64 | Naked_float
382+
| Naked_float32 | Naked_vec128 ->
377383
(* The GC never sees these fields, so we can avoid using
378384
[caml_initialize]. This is important as it significantly reduces
379385
the complexity of the statically-allocated inconstant unboxed int32
@@ -389,6 +395,11 @@ let make_update env res dbg ({ kind; stride } : Update_kind.t) ~symbol var
389395
match kind with
390396
| Pointer -> Word_val
391397
| Immediate -> Word_int
398+
| Naked_int8 | Naked_int16 ->
399+
(* CR layouts v5.1: we only support small integers in being
400+
sign-extended in word fields *)
401+
assert (stride = Arch.size_addr);
402+
Word_int
392403
| Naked_int32 ->
393404
(* Cmm expressions representing int32 values are always sign extended.
394405
By using [Word_int] in the "fields" cases (see [Update_kind],

middle_end/flambda2/to_cmm/to_cmm_shared.mli

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ module Update_kind : sig
113113

114114
val tagged_immediates : t
115115

116+
(** Assumes each field is a word; the byte offset is [index * size_addr]. *)
117+
val naked_int8_fields : t
118+
119+
(** Assumes each field is a word; the byte offset is [index * size_addr]. *)
120+
val naked_int16_fields : t
121+
116122
(** Tightly packed; the byte offset is [index * 4]. ([index] is as for
117123
[make_update], below.) *)
118124
val naked_int32s : t

0 commit comments

Comments
 (0)