# HG changeset patch # User Mike Pavone # Date 1305527518 25200 # Node ID 926b56a43f47192986104908ddc6d6c8fa13445a # Parent a32afde77abb17833101a140e35b0a061ac6370f Fix some bugs related to inlining diff -r a32afde77abb -r 926b56a43f47 cbackend_c.rhope --- a/cbackend_c.rhope Sun May 08 18:36:33 2011 -0700 +++ b/cbackend_c.rhope Sun May 15 23:31:58 2011 -0700 @@ -597,6 +597,7 @@ } + Do AddRef@C Function[func,psource,pdest:out] { source <- [psource]Make Op[func] @@ -991,8 +992,9 @@ }{ after free <- Val[after statements] } - out <- [[after free]Add Raw Line["}"] + out <- [[[after free]Add Raw Line["}"] ]Resume Index <<[[stream]Resume Index >>] + ]Variables <<[ Combine[[after free]Variables >>, [stream]Variables >>]] } Discard Outputs@C Function[func,first to discard:out] diff -r a32afde77abb -r 926b56a43f47 list.rhope --- a/list.rhope Sun May 08 18:36:33 2011 -0700 +++ b/list.rhope Sun May 15 23:31:58 2011 -0700 @@ -116,7 +116,7 @@ Length(Int32,Naked) } -List[:out(List)] +List[:out(List Leaf)] { out <- [Build[List Leaf()]]Buffer <<[Array[]] } diff -r a32afde77abb -r 926b56a43f47 nworker_c.rhope --- a/nworker_c.rhope Sun May 08 18:36:33 2011 -0700 +++ b/nworker_c.rhope Sun May 15 23:31:58 2011 -0700 @@ -881,6 +881,7 @@ out <- Val[after save] }{ fname <- [[node]Data >>]Name >> + first unused <- [Max Used Output[node, [[node]Outputs >>]-[1]]]+[1] [program]Method?[fname] { with call <- [func]Method Call[fname, inputs] @@ -895,7 +896,11 @@ }{ ,normal call <- If[[[inputs]Length]=[1]] { - out,normal call <- Compile Boolean Inline Check[func, justfunc, [[[node]Input Types >>]Index[0]]Index[0], [inputs]Index[0], Result Var Name[0, node index], Result Var Name[1, node index]] + //TODO: Inline a partial version of If when only one output is used + ,normal call <- If[[first unused]>[1]] + { + out,normal call <- Compile Boolean Inline Check[func, justfunc, [[[node]Input Types >>]Index[0]]Index[0], [inputs]Index[0], Result Var Name[0, node index], Result Var Name[1, node index]] + } } } } @@ -905,7 +910,6 @@ with call <- [func]Call[fname, inputs] } } - first unused <- [Max Used Output[node, [[node]Outputs >>]-[1]]]+[1] If[[first unused] > [[node]Min Outputs >>]] { save outs <- [node]Min Outputs >> @@ -981,6 +985,7 @@ } }{ If[[[node]Type >>]=["setglobal"]] + { inputs <- [worker]Collect Inputs[node] [conditions]For Backend