@@ -96,12 +96,13 @@ let pseudoregs_for_operation op arg res =
9696 (* One-address unary operations: arg.(0) and res.(0) must be the same *)
9797 | Iintop_imm ((Iadd | Isub | Imul | Iand | Ior | Ixor | Ilsl | Ilsr | Iasr ), _)
9898 | Iabsf | Inegf
99- | Ispecific (Ibswap { bitwidth = ( Thirtytwo | Sixtyfour ) } ) ->
99+ | Ispecific (Ibswap ( 32 | 64 ) ) ->
100100 (res, res)
101101 (* For xchg, args must be a register allowing access to high 8 bit register
102102 (rax, rbx, rcx or rdx). Keep it simple, just force the argument in rax. *)
103- | Ispecific (Ibswap { bitwidth = Sixteen } ) ->
103+ | Ispecific (Ibswap 16 ) ->
104104 ([| rax |], [| rax |])
105+ | Ispecific (Ibswap _ ) -> assert false
105106 (* For imulh, first arg must be in rax, rax is clobbered, and result is in
106107 rdx. *)
107108 | Iintop (Imulh _ ) ->
@@ -165,12 +166,6 @@ let select_locality (l : Cmm.prefetch_temporal_locality_hint)
165166 | Moderate -> Moderate
166167 | High -> High
167168
168- let select_bitwidth : Cmm.bswap_bitwidth -> Arch.bswap_bitwidth =
169- function
170- | Sixteen -> Sixteen
171- | Thirtytwo -> Thirtytwo
172- | Sixtyfour -> Sixtyfour
173-
174169let one_arg name args =
175170 match args with
176171 | [arg] -> arg
@@ -180,7 +175,8 @@ let one_arg name args =
180175(* If you update [inline_ops], you may need to update [is_simple_expr] and/or
181176 [effects_of], below. *)
182177let inline_ops =
183- [ " sqrt" ; ]
178+ [ " sqrt" ; " caml_bswap16_direct" ; " caml_int32_direct_bswap" ;
179+ " caml_int64_direct_bswap" ; " caml_nativeint_direct_bswap" ]
184180
185181let is_immediate n = n < = 0x7FFF_FFFF && n > = - 0x8000_0000
186182
@@ -334,9 +330,13 @@ method! select_operation op args dbg =
334330 | _ ->
335331 super#select_operation op args dbg
336332 end
337- | Cbswap { bitwidth } ->
338- let bitwidth = select_bitwidth bitwidth in
339- (Ispecific (Ibswap { bitwidth }), args)
333+ | Cextcall { func = "caml_bswap16_direct" ; } ->
334+ (Ispecific (Ibswap 16 ), args)
335+ | Cextcall { func = "caml_int32_direct_bswap" ; } ->
336+ (Ispecific (Ibswap 32 ), args)
337+ | Cextcall { func = " caml_int64_direct_bswap" ; }
338+ | Cextcall { func = "caml_nativeint_direct_bswap" ; } ->
339+ (Ispecific (Ibswap 64 ), args)
340340 (* Recognize sign extension *)
341341 | Casr ->
342342 begin match args with
0 commit comments