wip: linearizer compiles with stubs

This commit is contained in:
Joe Bryan 2024-07-18 17:47:26 -04:00
parent 1a45b588d5
commit 0bba7d132c

View File

@ -1,8 +1,7 @@
/- gen
/- gene
|.
=> $:gene
%zero
=* skan +3
=* sack +3
=* moan moan.sack
=* cole cole.sack
=| =fuji
@ -12,22 +11,23 @@
::
++ puck
|= b=bell
=> [b=b m=moan ja=ja hone=hone]
=> [b=b m=moan ..hone]
~+
=/ h (~(get ja m) form.b)
|- ^- (unit hone)
?< ?=(h ~)
?: =(text.b soot.i.h) `h
|- ^- (unit hone) :: XX just hone?
?< ?=(~ h)
?: =(text.b soot.i.h) `i.h
$(h t.h)
:: compute which analysis results are not linearized and return in
:: toposorted order
::
++ work
=/ mell
^- (list bell)
=/ mell=(set bell)
%- ~(rep by moan)
|= [[f=* l=(list hone)] mell=(set bell)]
(roll l |:([h=*hone mell=mell] (~(put in mell) [soot.h f])))
=/ novo (~(dif in mell) ~(key by peal.fuji))
=/ novo (~(dif in mell) `(set bell)`~(key by peal.fuji))
=/ sire=(jug bell bell)
%- ~(rep in novo)
|= [b=bell sire=(jug bell bell)]
@ -40,12 +40,12 @@
|: [k=*bell s=sire]
(~(put ju s) k b)
=< tack.s
%+ roll novo
%- ~(rep in novo)
|= [v=bell s=[done=(set bell) tack=(list bell)]]
=* dfs $
^- _s
?: (~(has in done.s v) s
=. done.s (~(put in done.s) v
?: (~(has in done.s) v) s
=. done.s (~(put in done.s) v)
=/ e=(set bell) (~(get ju sire) v)
=. s
%- ~(rep in e)
@ -53,7 +53,7 @@
^- _s
dfs(v n, s s)
s(tack [v tack.s])
+$ gen [redo=(list [t=bell b=@uwoo]) =fuji sans=@uvre chan=@uwoo]
+$ gen [redo=(list [t=bell b=@uwoo]) =^fuji sans=@uvre chan=@uwoo]
++ jean
|_ =gen
:: core DDCG linearizer
@ -62,8 +62,9 @@
=/ =goal [%done ~]
|= =bell
=/ h (puck bell)
=* n nomm.norm.h
|- ^- [_goal _gen]
?< ?=(~ h)
=* n nomm.norm.u.h
|- ^- [next _gen]
?- -.n
%par
?- -.goal
@ -78,14 +79,14 @@
%next
=^ [bill=@uwoo left=need rite=need] gen (lyse goal)
=^ tale gen
$(nomm rite.nomm, goal [%next rite bill])
$(n rite.n, goal [%next rite bill])
=^ hale gen
$(nomm left.nomm, goal [%next then.tale])
$(n left.n, goal [%next left then.tale])
(copy hale what.tale)
==
::
%not
?: =(0 here.nomm) bomb
?: =(0 here.n) bomb
?- -.goal
%done
=^ last gen rain
@ -98,33 +99,34 @@
$(goal [%next [%this cove] cozy])
::
%next
(from here.nomm goal)
(from here.n goal)
==
::
%one
?- -.goal
%done
=^ last gen rain
=^ rime gen (emit ~ [%imm moan.nomm last]~ %don last)
=^ rime gen (emit ~ [%imm moan.n last]~ %don last)
[[%next [%none ~] rime] gen]
::
%pick
?: =(0 moan.nomm)
?: =(0 moan.n)
[[%next [%none ~] zero.goal] gen]
?: =(1 moan.nomm)
?: =(1 moan.n)
[[%next [%none ~] once.goal] gen]
(mine sass.goal zero.goal)
::
%next
=^ bill gen (mede then.goal moan.nomm what.goal)
=^ bill gen (mede then.goal moan.n what.goal)
[[%next [%none ~] bill] gen]
==
::
%two ~| %todo-two !!
?: ?=(pick -.goal)
%two
?: ?=(%pick -.goal)
=^ flip gen rain
=^ bird gen (emit ~ ~ %brn flip [zero once]:goal)
$(goal [%next [%this flip] bird])
=/ bull (~(get by ices.norm.h) rail.n)
=/ bull (~(get by ices.norm.u.h) rail.n)
?~ bull
:: indirect call
?- -.goal
@ -132,26 +134,26 @@
=^ s gen rain
=^ f gen rain
=^ tide gen (emit ~ ~ %lnt s f)
=^ corn gen $(nomm corn.nomm, goal [%next [%this f] tide])
=^ cost gen $(nomm cost.nomm, goal [%next [%this s] then.corn])
=^ corn gen $(n corn.n, goal [%next [%this f] tide])
=^ cost gen $(n cost.n, goal [%next [%this s] then.corn])
(copy cost what.corn)
::
%next
=^ [post=@uwoo salt=@uvre] gen (kerf %post goal)
=^ [post=@uwoo salt=@uvre] gen (kerf goal)
=^ s gen rain
=^ f gen rain
=^ dine gen (emit ~ ~ %lnk s f salt post)
=^ corn gen $(nomm corn.nomm, goal [%next [%this f] dine])
=^ cost gen $(nomm cost.nomm, goal [%next [%this s] then.corn])
=^ corn gen $(n corn.n, goal [%next [%this f] dine])
=^ cost gen $(n cost.n, goal [%next [%this s] then.corn])
(copy cost what.corn)
==
:: direct call
:: XX we need a placeholder for the @uwoo for a recursive call
=/ hope (~(get by call.cole) u.bull)
=^ a gen (args u.bull)
=/ wool
=/ wool=@uwoo
?. r.a (~(got by peal.fuji.gen) u.bull)
0
`@`0
?- -.goal
%done
=^ [dire=@uwoo seed=need] gen
@ -162,11 +164,14 @@
=^ s gen rain
=^ dial gen (emit ~ ~ %jmf wool v.a s u.hope)
=? redo.gen r.a [[u.bull dial] redo.gen]
=^ next gen (copy [%next n.a dial] [%this s])
=^ nest gen (copy [%next n.a dial] [%this s])
[[then.nest what.nest] gen]
=^ corn gen $(n corn.n, goal [%next [%none ~] dire])
=^ cost gen $(n cost.n, goal [%next seed then.corn])
(copy cost what.corn)
::
%next
=^ [post=@uwoo salt=@uvre] gen (kerf %post goal)
=^ [post=@uwoo salt=@uvre] gen (kerf goal)
=^ [dire=@uwoo seed=need] gen
?~ hope
=^ dine gen (emit ~ ~ %cal wool v.a salt post)
@ -177,8 +182,8 @@
=? redo.gen r.a [[u.bull dime] redo.gen]
=^ nest gen (copy [%next n.a dime] [%this s])
[[then.nest what.nest] gen]
=^ corn gen $(nomm corn.nomm, goal [%next [%none ~] dire])
=^ cost gen $(nomm cost.nomm, goal [%next seed then.corn])
=^ corn gen $(n corn.n, goal [%next [%none ~] dire])
=^ cost gen $(n cost.n, goal [%next seed then.corn])
(copy cost what.corn)
==
::
@ -196,7 +201,7 @@
?: ?=(%both -.what.goal) (mine sass.what.goal then.goal)
:: no need for check if result unused
?: ?=(%none -.what.goal)
$(nomm pell.nom)
$(n pell.n)
=^ tare gen rain
=^ tile gen vial
=^ fare gen rain
@ -220,7 +225,7 @@
%pick
=^ coat gen rain
=^ pith gen (emit ~ ~ %clq coat [zero once]:goal)
$(nomm pell.nomm, goall [%next [%this coat] pith])
$(n pell.n, goal [%next [%this coat] pith])
==
::
%for
@ -229,14 +234,14 @@
=^ rink gen rain
=^ pink gen rain
=^ tike gen (emit ~ [%inc pink rink]~ %don rink)
$(nomm mall.nomm, goal [%next [%this pink] tike])
$(n mall.n, goal [%next [%this pink] tike])
::
%pick
=^ rink gen rain
=^ pink gen rain
=^ pike gen
(emit %pike ~ [%inc pink rink]~ %brn rink [zero once]:goal)
$(nomm mall.nomm, goal [%next [%this pink] pike])
(emit ~ [%inc pink rink]~ %brn rink [zero once]:goal)
$(n mall.n, goal [%next [%this pink] pike])
::
%next
?: ?=(%both -.what.goal) (mine sass.what.goal then.goal)
@ -245,8 +250,8 @@
rain
[sass.what.goal gen]
=^ pink gen rain
=^ bike gen (emit ~ [%inc pink rin]~ %hop then.goal)
$(nomm mall.nomm, goal [%next [%this pink] bike])
=^ bike gen (emit ~ [%inc pink rink]~ %hop then.goal)
$(n mall.n, goal [%next [%this pink] bike])
==
::
%ivy
@ -262,8 +267,8 @@
%next
?: ?=(%both -.what.goal) (mine sass.what.goal then.goal)
?: ?=(%none -.what.goal)
=^ than gen $(nomm that.nomm)
=^ thin gen $(nomm this.nomm, then.goal then.than)
=^ than gen $(n that.n)
=^ thin gen $(n this.n, then.goal then.than)
(copy thin what.than)
=^ tare gen rain
=^ till gen vial
@ -290,32 +295,32 @@
=^ tire gen rain
=^ tear gen rain
=^ pare gen (emit ~ ~ %eqq tire tear [zero once]:goal)
=^ than gen $(nomm that.nomm, goal [%next [%this tear] pare])
=^ thin gen $(nomm this.nomm, goal [%next [%this tire] then.than])
=^ than gen $(n that.n, goal [%next [%this tear] pare])
=^ thin gen $(n this.n, goal [%next [%this tire] then.than])
(copy thin what.than)
==
::
%six
?: ?=(%next -.goal)
=^ [teal=next feel=next] gen (phil goal)
=^ fest gen $(nomm else.nomm, goal feel)
=^ zest gen $(nomm then.nomm, goal teal)
=^ fest gen $(n else.n, goal feel)
=^ zest gen $(n then.n, goal teal)
=^ [bead=need tile=@uwoo file=@uwoo] gen (sect zest fest)
=^ lead gen rain
=^ cond gen $(nomm what.nomm, goal [%pick lead tile file])
=^ cond gen $(n what.n, goal [%pick lead tile file])
(copy cond bead)
=^ fest gen $(nomm else.nomm)
=^ zest gen $(nomm then.nomm)
=^ fest gen $(n else.n)
=^ zest gen $(n then.n)
=^ [bead=need tile=@uwoo file=@uwoo] gen (sect zest fest)
=^ barf gen rain
=^ tool gen (emit ~ [%ipb ~[barf]]~ %hop tile)
=^ cond gen
$(nomm what.nomm, goal [%pick barf tool file])
$(n what.n, goal [%pick barf tool file])
(copy cond bead)
::
%eve
=^ thin gen $(nomm then.nomm)
$(nomm once.nomm, goal thin)
=^ thin gen $(n then.n)
$(n once.n, goal thin)
::
%ten
?- -.goal
@ -325,94 +330,155 @@
$(goal [%next [%this last] dead])
::
%pick
?. =(here.nomm 1) (mine sass.goal zero.goal)
?. =(here.n 1) (mine sass.goal zero.goal)
=^ flip gen rain
=^ deep gen (emit ~ ~ %brn flip [zero once]:goal)
$(goal [%next [%this flip] deep])
::
%next
=^ [twig=need tree=need then=@uwoo] gen (into here.nomm goal)
=^ nest gen $(nomm tree.nomm, goal [%next tree then])
=^ eggs gen $(nomm twig.nomm, goal [%next twig then.nest])
=^ [twig=need tree=need then=@uwoo] gen (into here.n goal)
=^ nest gen $(n tree.n, goal [%next tree then])
=^ eggs gen $(n twig.n, goal [%next twig then.nest])
(copy eggs what.nest)
==
::
%sip
?+ hint.nomm $(nomm then.nomm)
?+ hint.n $(n then.n)
%bout
?- -.goal
%done
=^ last gen rain
=^ dime gen (emit ~ ~ %don last)
$(goal [%next [%this last] dime)
$(goal [%next [%this last] dime])
::
%pick
=^ tome gen (emit ~ [%tom ~]~ %hop zero.goal)
=^ foam gen (emit ~ [%tom ~]~ %hop once.goal)
=^ race gen $(nomm then.nomm, goal [%pick sass.goal tome foam])
=^ race gen $(n then.n, goal [%pick sass.goal tome foam])
=^ tick gen (emit ~ [%tim ~]~ %hop then.race)
[race(then tick) gen]
::
%next
=^ stop gen (emit ~ [%tom ~]~ %hop then.goal)
=^ race gen $(nomm then.nomm, then.goal stop)
=^ goes gen (emit %goes ~ [%tim ~]~ %hop then.race)
=^ race gen $(n then.n, then.goal stop)
=^ goes gen (emit ~ [%tim ~]~ %hop then.race)
[race(then goes) gen]
==
::
%meme
=^ raft gen $(nomm then.nomm)
=^ raft gen $(n then.n)
=^ meme gen (emit ~ [%mem ~]~ %hop then.raft)
[raft(then meme) gen]
==
::
%tip
?+ hint.nomm
=^ thin gen $(nomm then.nomm)
=^ fake gen $(nomm vice.nomm, goal [%next [%none ~] then.thin])
?+ hint.n
=^ thin gen $(n then.n)
=^ fake gen $(n vice.n, goal [%next [%none ~] then.thin])
(copy fake what.thin)
::
?(%hunk %hand %lose %mean %spot)
=^ mane gen rain
?- -.goal
%done
=^ real gen $(nomm then.nomm)
=^ dint gen (emit ~ [%men hint.nomm mane]~ %hop then.real)
=^ fake gen $(nomm vice.nomm, goal [%next [%this maine] dint])
=^ real gen $(n then.n)
=^ dint gen (emit ~ [%men hint.n mane]~ %hop then.real)
=^ fake gen $(n vice.n, goal [%next [%this mane] dint])
(copy fake what.real)
::
%pick
=^ tame gen (emit ~ [%man ~]~ %hop zero.goal)
=^ fame gen (emit ~ [%man ~]~ %hop once.goal)
=^ real gen $(nomm then.nomm, goal [%pick sass.goal tame fame])
=^ dint gen (emit ~ [%men hint.nomm mane]~ %hop then.real)
=^ fake gen $(nomm vice.nomm, goal [%next [%this mane] dint])
=^ real gen $(n then.n, goal [%pick sass.goal tame fame])
=^ dint gen (emit ~ [%men hint.n mane]~ %hop then.real)
=^ fake gen $(n vice.n, goal [%next [%this mane] dint])
(copy fake what.real)
::
%next
=^ rugs gen (emit ~ [%man ~]~ %hop then.goal)
=^ real gen $(nomm then.nomm, then.goal rugs)
=^ dint gen (emit ~ [%men hint.nomm mane]~ %hop then.real)
=^ fake gen $(nomm vice.nomm, goal [%next [%this mane] dint])
=^ real gen $(n then.n, then.goal rugs)
=^ dint gen (emit ~ [%men hint.n mane]~ %hop then.real)
=^ fake gen $(n vice.n, goal [%next [%this mane] dint])
(copy fake what.real)
==
:: XX TODO %live %slog %memo %bout
==
::
%elf ~| %todo !!
==
:: XX
:: rain - new register
++ rain
^- [@uvre _gen]
!!
:: emit - add basic block
++ emit
|= =blob
^- [@uwoo _gen]
!!
:: lyse - split need for cons
++ lyse
|= =next
^- [[@uwoo need need] _gen]
!!
:: mine - set up deferred crash
++ mine
|= [r=@uvre t=@uwoo]
^- [next _gen]
!!
:: from - push need down by axis
++ from
|= [axe=@ =next]
^- [^next _gen]
!!
:: mede - immediates into need
++ mede
|= [u=@uwoo n=* =need]
^- [@uwoo _gen]
!!
:: kerf - split single register into goal
++ kerf
|= =next
^- [[@uwoo @uvre] _gen]
!!
:: args - look up subject registerization
++ args
|= =bell
^- [[v=(list @uvre) n=need r=?] _gen]
!!
:: vial - new basic block label
++ vial
^- [@uwoo _gen]
!!
:: copy - align subject needs for sequential computation
++ copy
|= [feed=next seed=need]
^- [next _gen]
!!
:: sect - align subject needs for branching computation
++ sect
|= [zero=next once=next]
^- [[need @uwoo @uwoo] _gen]
!!
:: phil - generate phi nodes
++ phil
|= =next
^- [[^next ^next] _gen]
!!
:: into - split need for edit
++ into
|= [axe=@ =next]
^- [[need need @uwoo] _gen]
!!
::
::
++ bomb
^- [next _gen]
!!
++ come
|= [f=@uwoo t=@uwoo]
^- [@uwoo _gen]
!!
--
--
=+ ver=%1