Skip to content

Commit e10e6b7

Browse files
committed
Emit_stores for arm64
Error in Arch.offset_addressing for now instead of emitting illegal offset
1 parent 387213e commit e10e6b7

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

backend/arm64/arch.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,19 @@ let size_float = 8
8383

8484
let size_vec128 = 16
8585

86-
let allow_unaligned_access = true
86+
let allow_unaligned_access = true
8787

8888
(* Behavior of division *)
8989

9090
let division_crashes_on_overflow = false
9191

9292
(* Operations on addressing modes *)
9393

94-
let identity_addressing = Iindexed 0
94+
let identity_addressing =
95+
Misc.fatal_error "Arch.identity_addressing not supported"
9596

96-
let offset_addressing addr delta =
97-
match addr with
98-
| Iindexed n -> Iindexed(n + delta)
99-
| Ibased(s, n) -> Ibased(s, n + delta)
97+
let offset_addressing _addr _delta =
98+
Misc.fatal_error "Arch.offset_addressing not supported"
10099

101100
let num_args_addressing = function
102101
| Iindexed _ -> 1

backend/arm64/cfg_selection.ml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,52 @@ class selector =
173173
(* Other operations are regular *)
174174
| _ -> super#select_operation op args dbg ~label_after
175175

176+
method! emit_stores env dbg data regs_addr =
177+
let offset = ref (-Arch.size_int) in
178+
let base =
179+
assert (Array.length regs_addr = 1);
180+
ref regs_addr
181+
in
182+
List.iter
183+
(fun arg ->
184+
match self#emit_expr env arg ~bound_name:None with
185+
| None -> assert false
186+
| Some regs ->
187+
for i = 0 to Array.length regs - 1 do
188+
let r = regs.(i) in
189+
let kind =
190+
match r.Reg.typ with
191+
| Float -> Double
192+
| Float32 -> Single { reg = Float32 }
193+
| Vec128 ->
194+
(* 128-bit memory operations are default unaligned. Aligned
195+
(big)array operations are handled separately via cmm. *)
196+
Onetwentyeight_unaligned
197+
| Val | Addr | Int -> Word_val
198+
| Valx2 ->
199+
Misc.fatal_error "Unexpected machtype_component Valx2"
200+
in
201+
if not (Selection_utils.is_offset kind !offset)
202+
then (
203+
let tmp = self#regs_for typ_int in
204+
self#insert_debug env
205+
(self#lift_op
206+
(self#make_const_int (Nativeint.of_int !offset)))
207+
dbg [||] tmp;
208+
self#insert_debug env
209+
(self#lift_op (Operation.Intop Iadd))
210+
dbg (Array.append !base tmp) tmp;
211+
base := tmp;
212+
offset := 0);
213+
self#insert_debug env
214+
(self#make_store kind (Iindexed !offset) false)
215+
dbg
216+
(Array.append [| r |] !base)
217+
[||];
218+
offset := !offset + Select_utils.size_component r.Reg.typ
219+
done)
220+
data
221+
176222
method! insert_move_extcall_arg env ty_arg src dst =
177223
let ty_arg_is_int32 =
178224
match ty_arg with

0 commit comments

Comments
 (0)