Skip to content

Commit bc2625f

Browse files
committed
no offset for bs backend
1 parent b7bc2ac commit bc2625f

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

asmcomp/cmmgen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ struct
14471447
let make_isout h arg = Cop (Ccmpa Clt, [h ; arg], Debuginfo.none)
14481448
let make_isin h arg = Cop (Ccmpa Cge, [h ; arg], Debuginfo.none)
14491449
let make_if cond ifso ifnot = Cifthenelse (cond, ifso, ifnot)
1450-
let make_switch loc arg cases actions _names =
1450+
let make_switch loc arg cases actions ~offset:_ _names =
14511451
make_switch arg cases actions (Debuginfo.from_location loc)
14521452
let bind arg body = bind "switcher" arg body
14531453

bytecomp/matching.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,10 +1954,10 @@ module SArg = struct
19541954
let make_isout h arg = Lprim (Pisout, [h ; arg],Location.none)
19551955
let make_isin h arg = Lprim (Pnot,[make_isout h arg],Location.none)
19561956
let make_if cond ifso ifnot = Lifthenelse (cond, ifso, ifnot)
1957-
let make_switch loc arg cases acts sw_names =
1957+
let make_switch loc arg cases acts ~offset sw_names =
19581958
let l = ref [] in
19591959
for i = Array.length cases-1 downto 0 do
1960-
l := (i,acts.(cases.(i))) :: !l
1960+
l := (offset + i,acts.(cases.(i))) :: !l
19611961
done ;
19621962
Lswitch(arg,
19631963
{sw_numconsts = Array.length cases ; sw_consts = !l ;

bytecomp/switch.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module type S =
106106
val make_isout : act -> act -> act
107107
val make_isin : act -> act -> act
108108
val make_if : act -> act -> act -> act
109-
val make_switch : Location.t -> act -> int array -> act array -> Lambda.switch_names option -> act
109+
val make_switch : Location.t -> act -> int array -> act array -> offset:int -> Lambda.switch_names option -> act
110110
val make_catch : act -> int * (act -> act)
111111
val make_exit : int -> act
112112
end
@@ -560,6 +560,9 @@ and enum top cases =
560560
do_make_if_out
561561
(Arg.make_const d) ctx.arg (mk_ifso ctx) (mk_ifno ctx)
562562
| _ ->
563+
if (*true || *)!Config.bs_only then
564+
do_make_if_out
565+
(Arg.make_const d) (Arg.make_offset ctx.arg (-l)) (mk_ifso ctx) (mk_ifno ctx) else
563566
Arg.bind
564567
(Arg.make_offset ctx.arg (-l))
565568
(fun arg ->
@@ -575,6 +578,9 @@ and enum top cases =
575578
do_make_if_in
576579
(Arg.make_const d) ctx.arg (mk_ifso ctx) (mk_ifno ctx)
577580
| _ ->
581+
if (*true || *) !Config.bs_only then
582+
do_make_if_in
583+
(Arg.make_const d) (Arg.make_offset ctx.arg (-l)) (mk_ifso ctx) (mk_ifno ctx) else
578584
Arg.bind
579585
(Arg.make_offset ctx.arg (-l))
580586
(fun arg ->
@@ -750,12 +756,15 @@ let make_switch loc {cases=cases ; actions=actions} i j sw_names =
750756
(fun act i -> acts.(i) <- actions.(act))
751757
t ;
752758
(fun ctx ->
759+
if !Config.bs_only then
760+
Arg.make_switch ~offset:(ll+ctx.off) loc ctx.arg tbl acts sw_names
761+
else
753762
match -ll-ctx.off with
754-
| 0 -> Arg.make_switch loc ctx.arg tbl acts sw_names
763+
| 0 -> Arg.make_switch loc ctx.arg tbl acts sw_names ~offset:0
755764
| _ ->
756765
Arg.bind
757766
(Arg.make_offset ctx.arg (-ll-ctx.off))
758-
(fun arg -> Arg.make_switch loc arg tbl acts sw_names))
767+
(fun arg -> Arg.make_switch loc arg tbl acts sw_names ~offset:0))
759768

760769

761770
let make_clusters loc ({cases=cases ; actions=actions} as s) n_clusters k sw_names =

bytecomp/switch.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module type S =
7979
make_switch arg cases acts
8080
NB: cases is in the value form *)
8181
val make_switch :
82-
Location.t -> act -> int array -> act array -> Lambda.switch_names option -> act
82+
Location.t -> act -> int array -> act array -> offset:int -> Lambda.switch_names option -> act
8383
(* Build last minute sharing of action stuff *)
8484
val make_catch : act -> int * (act -> act)
8585
val make_exit : int -> act

0 commit comments

Comments
 (0)