@@ -420,18 +420,17 @@ let unboxed_types = ref false
420420
421421(* This is used by the -save-ir-after option. *)
422422module Compiler_ir = struct
423- type t = Linear
423+ type t = Linear | Cfg
424424
425425 let all = [
426- Linear ;
426+ Linear ; Cfg
427427 ]
428428
429- let extension t =
430- let ext =
431- match t with
432- | Linear -> " linear"
433- in
434- " .cmir-" ^ ext
429+ let to_string = function
430+ | Linear -> " linear"
431+ | Cfg -> " cfg"
432+
433+ let extension t = " .cmir-" ^ (to_string t)
435434
436435 (* * [extract_extension_with_pass filename] returns the IR whose extension
437436 is a prefix of the extension of [filename], and the suffix,
@@ -699,24 +698,27 @@ module Compiler_pass = struct
699698 - the manpages in man/ocaml{c,opt}.m
700699 - the manual manual/manual/cmds/unified-options.etex
701700 *)
702- type t = Parsing | Typing | Scheduling | Emit
701+ type t = Parsing | Typing | Scheduling | Emit | Simplify_cfg
703702
704703 let to_string = function
705704 | Parsing -> " parsing"
706705 | Typing -> " typing"
707706 | Scheduling -> " scheduling"
708707 | Emit -> " emit"
708+ | Simplify_cfg -> " simplify_cfg"
709709
710710 let of_string = function
711711 | "parsing" -> Some Parsing
712712 | "typing" -> Some Typing
713713 | "scheduling" -> Some Scheduling
714714 | "emit" -> Some Emit
715+ | "simplify_cfg" -> Some Simplify_cfg
715716 | _ -> None
716717
717718 let rank = function
718719 | Parsing -> 0
719720 | Typing -> 1
721+ | Simplify_cfg -> 49
720722 | Scheduling -> 50
721723 | Emit -> 60
722724
@@ -725,16 +727,19 @@ module Compiler_pass = struct
725727 Typing ;
726728 Scheduling ;
727729 Emit ;
730+ Simplify_cfg ;
728731 ]
729732 let is_compilation_pass _ = true
730733 let is_native_only = function
731734 | Scheduling -> true
732735 | Emit -> true
733- | _ -> false
736+ | Simplify_cfg -> true
737+ | Parsing | Typing -> false
734738
735739 let enabled is_native t = not (is_native_only t) || is_native
736740 let can_save_ir_after = function
737741 | Scheduling -> true
742+ | Simplify_cfg -> true
738743 | _ -> false
739744
740745 let available_pass_names ~filter ~native =
@@ -749,11 +754,13 @@ module Compiler_pass = struct
749754 let to_output_filename t ~prefix =
750755 match t with
751756 | Scheduling -> prefix ^ Compiler_ir. (extension Linear )
752- | _ -> Misc. fatal_error " Not supported"
757+ | Simplify_cfg -> prefix ^ Compiler_ir. (extension Cfg )
758+ | Emit | Parsing | Typing -> Misc. fatal_error " Not supported"
753759
754760 let of_input_filename name =
755761 match Compiler_ir. extract_extension_with_pass name with
756762 | Some (Linear, _ ) -> Some Emit
763+ | Some (Cfg, _ ) -> None
757764 | None -> None
758765end
759766
0 commit comments