@@ -2,7 +2,7 @@ using ForwardDiff
22using Base. Meta
33using Graphs
44using Core. IR
5- using Core . Compiler : InferenceState, bbidxiter, dominates, tmerge, typeinf_lattice
5+ using . CC : InferenceState, bbidxiter, dominates, tmerge, typeinf_lattice
66
77@breadcrumb " ir_levels" function run_dae_passes (
88 interp:: DAEInterpreter , ir:: IRCode , debug_config:: DebugConfig = DebugConfig ())
@@ -317,7 +317,7 @@ has_any_genscope(sc::Scope) = isdefined(sc, :parent) && has_any_genscope(sc.pare
317317has_any_genscope (sc:: PartialScope ) = false
318318has_any_genscope (sc:: PartialStruct ) = false # TODO
319319
320- function _make_argument_lattice_elem (which:: Argument , @nospecialize (argt), add_variable!, add_equation!, add_scope!)
320+ function _make_argument_lattice_elem (𝕃, which:: Argument , @nospecialize (argt), add_variable!, add_equation!, add_scope!)
321321 if isa (argt, Const)
322322 # @assert !isa(argt.val, Scope) # Shouldn't have been forwarded
323323 return argt
@@ -331,7 +331,7 @@ function _make_argument_lattice_elem(which::Argument, @nospecialize(argt), add_v
331331 inc = Incidence (add_variable! (which))
332332 return argt === Float64 ? inc : Incidence (argt, inc. row, inc. eps)
333333 elseif isa (argt, PartialStruct)
334- return PartialStruct (argt. typ, Any[make_argument_lattice_elem (which, f, add_variable!, add_equation!, add_scope!) for f in argt. fields])
334+ return PartialStruct (𝕃, argt. typ, Any[make_argument_lattice_elem (𝕃, which, f, add_variable!, add_equation!, add_scope!) for f in argt. fields])
335335 elseif isabstracttype (argt) || ismutabletype (argt) || ! isa (argt, DataType)
336336 return nothing
337337 else
@@ -344,20 +344,20 @@ function _make_argument_lattice_elem(which::Argument, @nospecialize(argt), add_v
344344 for i = 1 : length (fieldtypes (argt))
345345 # TODO : Can we make this lazy?
346346 ft = fieldtype (argt, i)
347- mft = _make_argument_lattice_elem (which, ft, add_variable!, add_equation!, add_scope!)
347+ mft = _make_argument_lattice_elem (𝕃, which, ft, add_variable!, add_equation!, add_scope!)
348348 if mft === nothing
349349 push! (fields, Incidence (ft))
350350 else
351351 any = true
352352 push! (fields, mft)
353353 end
354354 end
355- return any ? PartialStruct (argt, fields) : nothing
355+ return any ? PartialStruct (𝕃, argt, fields) : nothing
356356 end
357357end
358358
359- function make_argument_lattice_elem (which:: Argument , @nospecialize (argt), add_variable!, add_equation!, add_scope!)
360- mft = _make_argument_lattice_elem (which, argt, add_variable!, add_equation!, add_scope!)
359+ function make_argument_lattice_elem (𝕃, which:: Argument , @nospecialize (argt), add_variable!, add_equation!, add_scope!)
360+ mft = _make_argument_lattice_elem (𝕃, which, argt, add_variable!, add_equation!, add_scope!)
361361 mft === nothing ? Incidence (argt) : mft
362362end
363363
532532 nexternalvars = 0 # number of variables that we expect to come in
533533 nexternaleqs = 0 # number of equation references that we expect to come in
534534 if caller != = nothing
535- argtypes = Any[make_argument_lattice_elem (Argument (i), argt, add_variable!, add_equation!, add_scope!) for (i, argt) in enumerate (ir. argtypes)]
535+ argtypes = Any[make_argument_lattice_elem (CC . typeinf_lattice (interp), Argument (i), argt, add_variable!, add_equation!, add_scope!) for (i, argt) in enumerate (ir. argtypes)]
536536 nexternalvars = length (var_to_diff)
537537 nexternaleqs = length (eqssas)
538538 else
571571 end
572572 end
573573
574- cur_scope_lattice = PartialStruct (Base. ScopedValues. Scope,
574+ cur_scope_lattice = PartialStruct (CC . typeinf_lattice (interp), Base. ScopedValues. Scope,
575575 Any[PartialKeyValue (Incidence (Base. PersistentDict{Base. ScopedValues. ScopedValue, Any}))])
576576
577577 # Scan the IR, computing equations, variables, diffgraph, etc.
@@ -1017,7 +1017,7 @@ end
10171017 for eq = 1 : length (result. eq_kind)
10181018 mapped_eq = mapping. eqs[eq]
10191019 mapped_eq == 0 && continue
1020- mapped_inc = apply_linear_incidence (result. total_incidence[eq], result, var_to_diff, var_kind, eq_kind, mapping)
1020+ mapped_inc = apply_linear_incidence (CC . typeinf_lattice (interp), result. total_incidence[eq], result, var_to_diff, var_kind, eq_kind, mapping)
10211021 if isassigned (total_incidence, mapped_eq)
10221022 total_incidence[mapped_eq] = tfunc (Val (Core. Intrinsics. add_float),
10231023 total_incidence[mapped_eq],
@@ -1033,7 +1033,7 @@ end
10331033
10341034 for (ieq, inc) in enumerate (result. total_incidence[(result. nexternaleqs+ 1 ): end ])
10351035 mapping. eqs[ieq] == 0 || continue
1036- push! (total_incidence, apply_linear_incidence (inc, result, var_to_diff, var_kind, eq_kind, mapping))
1036+ push! (total_incidence, apply_linear_incidence (CC . typeinf_lattice (interp), inc, result, var_to_diff, var_kind, eq_kind, mapping))
10371037 push! (eq_callee_mapping, [SSAValue (i)=> ieq])
10381038 push! (eq_kind, CalleeInternal)
10391039 mapping. eqs[ieq] = length (total_incidence)
@@ -1115,7 +1115,7 @@ end
11151115
11161116 nimplicitoutpairs = 0
11171117 if caller != = nothing
1118- ultimate_rt, nimplicitoutpairs = process_ipo_return! (ultimate_rt, eq_kind, var_kind,
1118+ ultimate_rt, nimplicitoutpairs = process_ipo_return! (CC . typeinf_lattice (interp), ultimate_rt, eq_kind, var_kind,
11191119 var_to_diff, total_incidence, eq_callee_mapping)
11201120 end
11211121
@@ -1135,7 +1135,7 @@ end
11351135 Dict {TornCacheKey, CodeInstance} ())
11361136end
11371137
1138- function process_ipo_return! (ultimate_rt:: Incidence , eq_kind, var_kind, var_to_diff, total_incidence, eq_callee_mapping)
1138+ function process_ipo_return! (𝕃, ultimate_rt:: Incidence , eq_kind, var_kind, var_to_diff, total_incidence, eq_callee_mapping)
11391139 nonlinrepl = nothing
11401140 nimplicitoutpairs = 0
11411141 function get_nonlinrepl ()
@@ -1179,20 +1179,20 @@ function process_ipo_return!(ultimate_rt::Incidence, eq_kind, var_kind, var_to_d
11791179 return ultimate_rt, nimplicitoutpairs
11801180end
11811181
1182- function process_ipo_return! (ultimate_rt:: Eq , eq_kind, args... )
1182+ function process_ipo_return! (𝕃, ultimate_rt:: Eq , eq_kind, args... )
11831183 eq_kind[ultimate_rt. id] = External
11841184 return ultimate_rt, 0
11851185end
1186- process_ipo_return! (ultimate_rt:: Union{Type, PartialScope, PartialKeyValue, Const} , args... ) = ultimate_rt, 0
1187- function process_ipo_return! (ultimate_rt:: PartialStruct , args... )
1186+ process_ipo_return! (𝕃, ultimate_rt:: Union{Type, PartialScope, PartialKeyValue, Const} , args... ) = ultimate_rt, 0
1187+ function process_ipo_return! (𝕃, ultimate_rt:: PartialStruct , args... )
11881188 nimplicitoutpairs = 0
11891189 fields = Any[]
11901190 for f in ultimate_rt. fields
1191- (rt, n) = process_ipo_return! (f, args... )
1191+ (rt, n) = process_ipo_return! (𝕃, f, args... )
11921192 nimplicitoutpairs += n
11931193 push! (fields, rt)
11941194 end
1195- return PartialStruct (ultimate_rt. typ, fields), nimplicitoutpairs
1195+ return PartialStruct (𝕃, ultimate_rt. typ, fields), nimplicitoutpairs
11961196end
11971197
11981198function get_variable_name (names:: OrderedDict , var_to_diff, var_idx)
0 commit comments