@@ -114,6 +114,13 @@ let mk_checkmach_details_cutoff f =
114114 | No_details -> 0
115115 | At_most n -> n)
116116
117+ let mk_function_layout f =
118+ let layouts = Flambda_backend_flags.Function_layout. (List. map to_string all) in
119+ let default = Flambda_backend_flags.Function_layout. (to_string default) in
120+ " -function-layout" , Arg. Symbol (layouts, f),
121+ (Printf. sprintf " Order of functions in the generated assembly (default: %s)"
122+ default)
123+
117124let mk_disable_poll_insertion f =
118125 " -disable-poll-insertion" , Arg. Unit f, " Do not insert poll points"
119126
@@ -629,6 +636,7 @@ module type Flambda_backend_options = sig
629636 val dcheckmach : unit -> unit
630637 val checkmach_details_cutoff : int -> unit
631638
639+ val function_layout : string -> unit
632640 val disable_poll_insertion : unit -> unit
633641 val enable_poll_insertion : unit -> unit
634642
@@ -741,6 +749,7 @@ struct
741749 mk_dcheckmach F. dcheckmach;
742750 mk_checkmach_details_cutoff F. checkmach_details_cutoff;
743751
752+ mk_function_layout F. function_layout;
744753 mk_disable_poll_insertion F. disable_poll_insertion;
745754 mk_enable_poll_insertion F. enable_poll_insertion;
746755
@@ -907,6 +916,12 @@ module Flambda_backend_options_impl = struct
907916 in
908917 Flambda_backend_flags. checkmach_details_cutoff := c
909918
919+ let function_layout s =
920+ match Flambda_backend_flags.Function_layout. of_string s with
921+ | None -> () (* this should not occur as we use Arg.Symbol *)
922+ | Some layout ->
923+ Flambda_backend_flags. function_layout := layout
924+
910925 let disable_poll_insertion = set' Flambda_backend_flags. disable_poll_insertion
911926 let enable_poll_insertion = clear' Flambda_backend_flags. disable_poll_insertion
912927
@@ -1179,6 +1194,13 @@ module Extra_params = struct
11791194 | None -> ()
11801195 end ;
11811196 true
1197+ | "function-layout" ->
1198+ (match Flambda_backend_flags.Function_layout. of_string v with
1199+ | Some layout -> Flambda_backend_flags. function_layout := layout; true
1200+ | None ->
1201+ raise
1202+ (Arg. Bad
1203+ (Printf. sprintf " Unexpected value %s for %s" v name)))
11821204 | "poll-insertion" -> set' Flambda_backend_flags. disable_poll_insertion
11831205 | "symbol-visibility-protected" -> set' Flambda_backend_flags. disable_poll_insertion
11841206 | "long-frames" -> set' Flambda_backend_flags. allow_long_frames
0 commit comments