180 |
local |
local |
181 |
structure F = FLINT |
structure F = FLINT |
182 |
structure M = IntBinaryMap |
structure M = IntBinaryMap |
183 |
structure S = IntSetF |
structure S = IntBinarySet |
184 |
structure C = Collect |
structure C = Collect |
185 |
structure O = Option |
structure O = Option |
186 |
structure DI = DebIndex |
structure DI = DebIndex |
388 |
if (C.unuse true (C.get lv)) then undertake m lv else () |
if (C.unuse true (C.get lv)) then undertake m lv else () |
389 |
|
|
390 |
|
|
391 |
fun addbind (m,lv,sv) = M.add(m, lv, sv) |
fun addbind (m,lv,sv) = M.insert(m, lv, sv) |
392 |
|
|
393 |
(* substitute a value sv for a variable lv and unuse value v. *) |
(* substitute a value sv for a variable lv and unuse value v. *) |
394 |
fun substitute (m, lv1, sv, v) = |
fun substitute (m, lv1, sv, v) = |
540 |
* Temporarily remove f's definition from the |
* Temporarily remove f's definition from the |
541 |
* environment while we're rebuilding it to avoid |
* environment while we're rebuilding it to avoid |
542 |
* nasty problems. *) |
* nasty problems. *) |
543 |
val nbody = fcexp (S.add(f, ifs)) |
val nbody = fcexp (S.add(ifs, f)) |
544 |
(addbind(nm, f, Var(f, NONE))) |
(addbind(nm, f, Var(f, NONE))) |
545 |
body #2 |
body #2 |
546 |
(* if inlining took place, the body might be completely |
(* if inlining took place, the body might be completely |
741 |
(* say("copyinline "^(C.LVarString g)^"\n"); *) |
(* say("copyinline "^(C.LVarString g)^"\n"); *) |
742 |
(app (unuseval m) vs); |
(app (unuseval m) vs); |
743 |
unusecall m g; |
unusecall m g; |
744 |
fcexp (S.add(g, ifs)) m nle cont |
fcexp (S.add(ifs, g)) m nle cont |
745 |
end |
end |
746 |
|
|
747 |
in if C.usenb gi = 1 andalso not(S.member ifs g) then simpleinline() |
in if C.usenb gi = 1 andalso not(S.member(ifs, g)) then simpleinline() |
748 |
else case inline of |
else case inline of |
749 |
F.IH_SAFE => noinline() |
F.IH_SAFE => noinline() |
750 |
| F.IH_UNROLL => noinline() |
| F.IH_UNROLL => noinline() |
751 |
| F.IH_ALWAYS => |
| F.IH_ALWAYS => |
752 |
if S.member ifs g then noinline() else copyinline() |
if S.member(ifs, g) then noinline() else copyinline() |
753 |
| F.IH_MAYBE(min,ws) => |
| F.IH_MAYBE(min,ws) => |
754 |
if S.member ifs g then noinline() else let |
if S.member(ifs, g) then noinline() else let |
755 |
fun value w _ (Val _ | Con _ | Record _) = w |
fun value w _ (Val _ | Con _ | Record _) = w |
756 |
| value w v (Fun (f,_,args,_,_)) = |
| value w v (Fun (f,_,args,_,_)) = |
757 |
if C.usenb(C.get v) = 1 then w * 2 else w |
if C.usenb(C.get v) = 1 then w * 2 else w |
818 |
click_copyinline(); |
click_copyinline(); |
819 |
(* say("copyinline "^(C.LVarString g)^"\n"); *) |
(* say("copyinline "^(C.LVarString g)^"\n"); *) |
820 |
unusecall m g; |
unusecall m g; |
821 |
fcexp (S.add(g, ifs)) m nle cont |
fcexp (S.add(ifs, g)) m nle cont |
822 |
end |
end |
823 |
|
|
824 |
in if C.usenb gi = 1 andalso not(S.member ifs g) |
in if C.usenb gi = 1 andalso not(S.member(ifs, g)) |
825 |
then noinline() (* simpleinline() *) |
then noinline() (* simpleinline() *) |
826 |
else case inline of |
else case inline of |
827 |
F.IH_ALWAYS => |
F.IH_ALWAYS => |
828 |
if S.member ifs g then noinline() else copyinline() |
if S.member(ifs, g) then noinline() else copyinline() |
829 |
| _ => noinline() |
| _ => noinline() |
830 |
end |
end |
831 |
| sv => noinline() |
| sv => noinline() |