123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175(** {0 OCaml compiler compatible command-line parameters} *)letcmi_file=refNoneletinclude_dirs=ref[]lethidden_include_dirs=ref[]letprint_variance=reffalse(* -i-variance *)letfast=reffalseletclassic=reffalseletall_ppx=ref[]letprincipal=reffalseletreal_paths=reftrueletrecursive_types=reffalseletstrict_sequence=reffalseletapplicative_functors=reftrueletnopervasives=reffalseletstrict_formats=reftrueletno_alias_deps=reffalse(* -no-alias-deps *)letunique_ids=reftrue(* -d(no-)unique-ids *)letcanonical_ids=reffalse(* -d(no-)canonical-ids *)letopen_modules=ref[]letannotations=reffalseletbinary_annotations=reftrueletstore_occurrences=reftrueletprint_types=reffalseletnative_code=reffalseleterror_size=ref500letdont_write_files=reftrueletkeep_locs=reftrueletkeep_docs=reffalselettransparent_modules=reftrueletfor_package=refNoneletdebug=reffalseletunsafe=reffalseletopaque=reffalseleterror_style=ref(SomeMisc.Error_style.Merlin)(* -error-style *)letunboxed_types=reffalseletlocations=reftrueletkeyword_edition:stringoptionref=refNone(* This is used by the -save-ir-after option. *)moduleCompiler_ir=structtypet=Linearletall=[Linear;]letextensiont=letext=matchtwith|Linear->"linear"in".cmir-"^ext(** [extract_extension_with_pass filename] returns the IR whose extension
is a prefix of the extension of [filename], and the suffix,
which can be used to distinguish different passes on the same IR.
For example, [extract_extension_with_pass "foo.cmir-linear123"]
returns [Some (Linear, "123")]. *)letextract_extension_with_passfilename=letext=Filename.extensionfilenameinletext_len=String.lengthextinifext_len<=0thenNoneelsebeginletis_prefixir=lets=extensionirinlets_len=String.lengthsins_len<=ext_len&&s=String.subext0s_leninletdrop_prefixir=lets=extensionirinlets_len=String.lengthsinString.subexts_len(ext_len-s_len)inletir=List.find_optis_prefixallinmatchirwith|None->None|Someir->Some(ir,drop_prefixir)endend(* This is used by the -stop-after option. *)moduleCompiler_pass=struct(* If you add a new pass, the following must be updated:
- the variable `passes` below
- the manpages in man/ocaml{c,opt}.m
- the manual manual/src/cmds/unified-options.etex
*)typet=Parsing|Typing|Lambda|Scheduling|Emitletto_string=function|Parsing->"parsing"|Typing->"typing"|Lambda->"lambda"|Scheduling->"scheduling"|Emit->"emit"letof_string=function|"parsing"->SomeParsing|"typing"->SomeTyping|"lambda"->SomeLambda|"scheduling"->SomeScheduling|"emit"->SomeEmit|_->Noneletrank=function|Parsing->0|Typing->1|Lambda->2|Scheduling->50|Emit->60letpasses=[Parsing;Typing;Lambda;Scheduling;Emit;]letis_compilation_pass_=trueletis_native_only=function|Scheduling->true|Emit->true|_->falseletenabledis_nativet=not(is_native_onlyt)||is_nativeletcan_save_ir_after=function|Scheduling->true|_->falseletavailable_pass_names~filter~native=passes|>List.filter(enablednative)|>List.filterfilter|>List.mapto_stringletcompareab=compare(ranka)(rankb)letto_output_filenamet~prefix=matchtwith|Scheduling->prefix^Compiler_ir.(extensionLinear)|_->Misc.fatal_error"Not supported"letof_input_filenamename=matchCompiler_ir.extract_extension_with_passnamewith|Some(Linear,_)->SomeEmit|None->Noneendletparse_keyword_editions=letparse_versions=letbad_version()=raise(Arg.Bad"Ill-formed version in keywords flag,\n\
the supported format is <major>.<minor>, for example 5.2 .")inifs=""thenNoneelsematchString.split_on_char'.'swith|[]|[_]|_::_::_::_->bad_version()|[major;minor]->matchint_of_string_optmajor,int_of_string_optminorwith|Somemajor,Someminor->Some(major,minor)|_->bad_version()inmatchString.split_on_char'+'swith|[]->None,[]|[s]->parse_versions,[]|v::rest->parse_versionv,restletstop_after=refNone