Skip to content

Commit e5c7499

Browse files
committed
refactored cmm to handle more integer widths
1 parent 2f5d60b commit e5c7499

12 files changed

+182
-194
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 *)

0 commit comments

Comments
 (0)