text
stringlengths
0
601k
let result_types t = Code_metadata . result_types t . code_metadata
let stub t = Code_metadata . stub t . code_metadata
let inline t = Code_metadata . inline t . code_metadata
let is_a_functor t = Code_metadata . is_a_functor t . code_metadata
let recursive t = Code_metadata . recursive t . code_metadata
let cost_metrics t = Code_metadata . cost_metrics t . code_metadata
let inlining_arguments t = Code_metadata . inlining_arguments t . code_metadata
let dbg t = Code_metadata . dbg t . code_metadata
let is_tupled t = Code_metadata . is_tupled t . code_metadata
let is_my_closure_used t = Code_metadata . is_my_closure_used t . code_metadata
let inlining_decision t = Code_metadata . inlining_decision t . code_metadata
let contains_no_escaping_local_allocs t = Code_metadata . contains_no_escaping_local_allocs t . code_metadata
let absolute_history t = Code_metadata . absolute_history t . code_metadata
let relative_history t = Code_metadata . relative_history t . code_metadata
let check_free_names_of_params_and_body ~ print_function_params_and_body code_id ~ params_and_body ~ free_names_of_params_and_body = if not ( Name_occurrences . no_continuations free_names_of_params_and_body && Name_occurrences . no_variables free_names_of_params_and_body ) then Misc . fatal_errorf " Incorrect free nam...
let create ~ print_function_params_and_body code_id ~ params_and_body ~ free_names_of_params_and_body ~ newer_version_of ~ params_arity ~ num_trailing_local_params ~ result_arity ~ result_types ~ contains_no_escaping_local_allocs ~ stub ( ~ inline : Inline_attribute . t ) ~ is_a_functor ~ recursive ~ cost_metrics ~ inl...
let with_code_id code_id t = { t with code_metadata = Code_metadata . with_code_id code_id t . code_metadata }
let with_params_and_body ~ print_function_params_and_body ~ params_and_body ~ free_names_of_params_and_body ~ cost_metrics t = check_free_names_of_params_and_body ~ print_function_params_and_body ( code_id t ) ~ params_and_body ~ free_names_of_params_and_body ; let code_metadata = Code_metadata . with_cost_metrics cost...
let with_newer_version_of newer_version_of t = { t with code_metadata = Code_metadata . with_newer_version_of newer_version_of t . code_metadata }
let print ~ print_function_params_and_body ppf { params_and_body ; code_metadata ; free_names_of_params_and_body = _ } = Format . fprintf ppf " [ @< hov 1 ( [ >@< hov 1 ( > code_metadata @ % a ) ] @@ % a ) ] " @ Code_metadata . print code_metadata print_function_params_and_body params_and_body
let compare t1 t2 = Code_id . compare ( code_id t1 ) ( code_id t2 )
let free_names { params_and_body = _ ; free_names_of_params_and_body ; code_metadata } = Name_occurrences . union ( Code_metadata . free_names code_metadata ) free_names_of_params_and_body
let apply_renaming ~ apply_renaming_function_params_and_body ( { params_and_body ; free_names_of_params_and_body ; code_metadata } as t ) renaming = let code_metadata ' = Code_metadata . apply_renaming code_metadata renaming in let params_and_body ' = apply_renaming_function_params_and_body params_and_body renaming in ...
let all_ids_for_export ~ all_ids_for_export_function_params_and_body { params_and_body ; free_names_of_params_and_body = _ ; code_metadata } = let params_and_body_ids = all_ids_for_export_function_params_and_body params_and_body in Ids_for_export . union ( Code_metadata . all_ids_for_export code_metadata ) params_and_b...
let map_result_types ( { code_metadata ; _ } as t ) ~ f = { t with code_metadata = Code_metadata . map_result_types code_metadata ~ f }
let dump_cmm = ref false
let dump_selection = ref false
let dump_live = ref false
let dump_spill = ref false
let dump_split = ref false
let dump_interf = ref false
let dump_prefer = ref false
let dump_regalloc = ref false
let dump_reload = ref false
let dump_linear = ref false
let use_llvm = ref false
let rec regalloc fd = if ! dump_live then Printmach . phase " Liveness analysis " fd ; Interf . build_graph fd ; if ! dump_interf then Printmach . interferences ( ) ; if ! dump_prefer then Printmach . preferences ( ) ; Coloring . allocate_registers ( ) ; if ! dump_regalloc then Printmach . phase " After register alloca...
let fundecl ppf fd_cmm = if ! dump_cmm then begin fprintf ppf " *** C -- code . " ; @ fprintf ppf " % a . " @ Printcmm . fundecl fd_cmm end ; Reg . reset ( ) ; let fd_sel = Sequence . fundecl fd_cmm in if ! dump_selection then Printmach . phase " After instruction selection " fd_sel ; Liveness . fundecl fd_sel ; if ! d...
let phrase = function Cfunction fd -> fundecl fd | Cdata dl -> Emit . data dl
let file filename = let ic = open_in filename in let lb = Lexing . from_channel ic in try while true do phrase ( Parsecmm . phrase Lexcmm . token lb ) done with End_of_file -> close_in ic | Lexcmm . Error msg -> close_in ic ; Lexcmm . report_error lb msg | Parsing . Parse_error -> close_in ic ; prerr_string " Syntax er...
type t = Code_id . t Code_id . Map . t
let [ @ ocamlformat " disable " ] print ppf t = Code_id . Map . print Code_id . print ppf t
let get_older_version_of t code_id = Code_id . Map . find_opt code_id t
let add t ~ newer ~ older = Code_id . Map . add newer older t
let rec all_ids_up_to_root t ~ resolver id = match Code_id . Map . find id t with | exception Not_found -> ( let comp_unit = Code_id . get_compilation_unit id in if Compilation_unit . equal comp_unit ( Compilation_unit . get_current_exn ( ) ) then Code_id . Set . singleton id else match resolver comp_unit with | except...
let num_ids_up_to_root t ~ resolver id = Code_id . Set . cardinal ( all_ids_up_to_root t ~ resolver id )
let meet t ~ resolver id1 id2 : _ Or_bottom . t = if Code_id . equal id1 id2 then Ok id1 else let id1_to_root = all_ids_up_to_root t ~ resolver id1 in let id2_to_root = all_ids_up_to_root t ~ resolver id2 in if Code_id . Set . mem id1 id2_to_root then Ok id2 else if Code_id . Set . mem id2 id1_to_root then Ok id1 else ...
let join ~ target_t ~ resolver t1 t2 id1 id2 : _ Or_unknown . t = if Code_id . equal id1 id2 then Known id1 else let id1_to_root = all_ids_up_to_root ~ resolver t1 id1 in let id2_to_root = all_ids_up_to_root ~ resolver t2 id2 in let shared_ids = Code_id . Set . inter id1_to_root id2_to_root in let shared_ids_in_scope =...
let union t1 t2 = Code_id . Map . disjoint_union ~ eq : Code_id . equal t1 t2
let all_code_ids_for_export t = Code_id . Map . fold ( fun key v acc -> Code_id . Set . add key ( Code_id . Set . add v acc ) ) t Code_id . Set . empty
let apply_renaming t renaming = let rename_code_id = Renaming . apply_code_id renaming in Code_id . Map . fold ( fun key v acc -> Code_id . Map . add ( rename_code_id key ) ( rename_code_id v ) acc ) t Code_id . Map . empty
let clean_for_export t ~ reachable_names = Code_id . Map . filter ( fun newer_code_id _older_code_id -> Name_occurrences . mem_code_id reachable_names newer_code_id ) t
type t = { code_id : Code_id . t ; newer_version_of : Code_id . t option ; params_arity : Flambda_arity . With_subkinds . t ; num_trailing_local_params : int ; result_arity : Flambda_arity . With_subkinds . t ; result_types : Result_types . t ; contains_no_escaping_local_allocs : bool ; stub : bool ; inline : Inline_at...
let code_id { code_id ; _ } = code_id
let newer_version_of { newer_version_of ; _ } = newer_version_of
let params_arity { params_arity ; _ } = params_arity
let num_leading_heap_params { params_arity ; num_trailing_local_params ; _ } = let n = Flambda_arity . With_subkinds . cardinal params_arity - num_trailing_local_params in assert ( n >= 0 ) ; n
let num_trailing_local_params { num_trailing_local_params ; _ } = num_trailing_local_params
let result_arity { result_arity ; _ } = result_arity
let result_types { result_types ; _ } = result_types
let stub { stub ; _ } = stub
let inline { inline ; _ } = inline
let is_a_functor { is_a_functor ; _ } = is_a_functor
let recursive { recursive ; _ } = recursive
let cost_metrics { cost_metrics ; _ } = cost_metrics
let inlining_arguments { inlining_arguments ; _ } = inlining_arguments
let dbg { dbg ; _ } = dbg
let is_tupled { is_tupled ; _ } = is_tupled
let is_my_closure_used { is_my_closure_used ; _ } = is_my_closure_used
let inlining_decision { inlining_decision ; _ } = inlining_decision
let contains_no_escaping_local_allocs { contains_no_escaping_local_allocs ; _ } = contains_no_escaping_local_allocs
let absolute_history { absolute_history ; _ } = absolute_history
let relative_history { relative_history ; _ } = relative_history
let create code_id ~ newer_version_of ~ params_arity ~ num_trailing_local_params ~ result_arity ~ result_types ~ contains_no_escaping_local_allocs ~ stub ( ~ inline : Inline_attribute . t ) ~ is_a_functor ~ recursive ~ cost_metrics ~ inlining_arguments ~ dbg ~ is_tupled ~ is_my_closure_used ~ inlining_decision ~ absolu...
let with_code_id code_id t = { t with code_id }
let with_newer_version_of newer_version_of t = { t with newer_version_of }
let with_cost_metrics cost_metrics t = { t with cost_metrics }
module Option = struct include Option let print_compact print_contents ppf t = match t with | None -> Format . pp_print_string ppf " ( ) " | Some contents -> Format . fprintf ppf " % a " print_contents contents end
let [ @ ocamlformat " disable " ] print_inlining_paths ppf ( relative_history , absolute_history ) = if ! Flambda_backend_flags . dump_inlining_paths then Format . fprintf ppf " [ @< hov 1 ( > relative_history @ % a ) ] @@ \ [ @< hov 1 ( > absolute_history @ % a ) ] @@ " Inlining_history . Relative . print relative_his...
let [ @ ocamlformat " disable " ] print ppf { code_id = _ ; newer_version_of ; stub ; inline ; is_a_functor ; params_arity ; num_trailing_local_params ; result_arity ; result_types ; contains_no_escaping_local_allocs ; recursive ; cost_metrics ; inlining_arguments ; dbg ; is_tupled ; is_my_closure_used ; inlining_decis...
let free_names { code_id = _ ; newer_version_of ; params_arity = _ ; num_trailing_local_params = _ ; result_arity = _ ; result_types ; contains_no_escaping_local_allocs = _ ; stub = _ ; inline = _ ; is_a_functor = _ ; recursive = _ ; cost_metrics = _ ; inlining_arguments = _ ; dbg = _ ; is_tupled = _ ; is_my_closure_us...
let apply_renaming ( { code_id ; newer_version_of ; params_arity = _ ; num_trailing_local_params = _ ; result_arity = _ ; result_types ; contains_no_escaping_local_allocs = _ ; stub = _ ; inline = _ ; is_a_functor = _ ; recursive = _ ; cost_metrics = _ ; inlining_arguments = _ ; dbg = _ ; is_tupled = _ ; is_my_closure_...
let all_ids_for_export { code_id ; newer_version_of ; params_arity = _ ; num_trailing_local_params = _ ; result_arity = _ ; result_types ; contains_no_escaping_local_allocs = _ ; stub = _ ; inline = _ ; is_a_functor = _ ; recursive = _ ; cost_metrics = _ ; inlining_arguments = _ ; dbg = _ ; is_tupled = _ ; is_my_closur...
let approx_equal { code_id = code_id1 ; newer_version_of = newer_version_of1 ; params_arity = params_arity1 ; num_trailing_local_params = num_trailing_local_params1 ; result_arity = result_arity1 ; result_types = _ ; contains_no_escaping_local_allocs = contains_no_escaping_local_allocs1 ; stub = stub1 ; inline = inline...
let map_result_types ( { result_types ; _ } as t ) ~ f = { t with result_types = Result_types . map_result_types result_types ~ f }
type t = | Code_present of Code . t | Metadata_only of Code_metadata . t
let print ppf t = match t with | Code_present code -> Format . fprintf ppf " [ @< hov 1 ( > Code_present @ ( [ @< hov 1 ( > code @ % a ) ] ) ) ] " @@ Code . print code | Metadata_only code_metadata -> Format . fprintf ppf " [ @< hov 1 ( > Metadata_only @ ( code_metadata @ % a ) ) ] " @ Code_metadata . print code_metada...
let create code = Code_present code
let merge code_id t1 t2 = match t1 , t2 with | Metadata_only cm1 , Metadata_only cm2 -> if Code_metadata . approx_equal cm1 cm2 then Some t1 else Misc . fatal_errorf " Code id % a is imported with different code metadata ( % a and % a ) " Code_id . print code_id Code_metadata . print cm1 Code_metadata . print cm2 | Cod...
let free_names t = match t with | Code_present code -> Code . free_names code | Metadata_only code_metadata -> Code_metadata . free_names code_metadata
let apply_renaming t renaming = match t with | Code_present code -> let code = Code . apply_renaming code renaming in Code_present code | Metadata_only code_metadata -> let code_metadata = Code_metadata . apply_renaming code_metadata renaming in Metadata_only code_metadata
let all_ids_for_export t = match t with | Code_present code -> Code . all_ids_for_export code | Metadata_only code_metadata -> Code_metadata . all_ids_for_export code_metadata
let remember_only_metadata t = match t with | Code_present code -> Metadata_only ( Code . code_metadata code ) | Metadata_only _ -> t
let code_metadata t = match t with | Code_present code -> Code . code_metadata code | Metadata_only code_metadata -> code_metadata
let iter_code t ~ f = match t with Code_present code -> f code | Metadata_only _ -> ( )
let map_result_types t ~ f = match t with | Code_present code -> Code_present ( Code . map_result_types code ~ f ) | Metadata_only code_metadata -> Metadata_only ( Code_metadata . map_result_types code_metadata ~ f )
let code_present t = match t with Code_present _ -> true | Metadata_only _ -> false
let equal a b = a = b
let ( + ) ( a : t ) ( b : t ) : t = a + b
let ( <= ) a b = a <= b