From 70d534d587b08926efcfaa2206af07c3460d99be Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 15 Mar 2005 23:18:33 +0000 Subject: [PATCH] compiling a prologue and epilogue on PowerPC --- library/compiler/linearizer.factor | 14 ++++++++++++-- library/compiler/ppc/generator.factor | 19 +++++++++++++++++++ library/compiler/simplifier.factor | 2 ++ library/compiler/x86/generator.factor | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index 1ce276c110..748f5121d3 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -31,6 +31,12 @@ SYMBOL: #target ( part of jump table ) SYMBOL: #target-label SYMBOL: #end-dispatch +! on PowerPC, compiled definitions that make subroutine calls +! must have a prologue and epilogue to set up and tear down the +! link register. +SYMBOL: #prologue +SYMBOL: #epilogue + : linear, ( node -- ) #! Add a node to the linear IR. [ node-op get node-param get ] bind cons , ; @@ -50,7 +56,7 @@ SYMBOL: #end-dispatch #! jumps and labels, and turns dataflow IR nodes into #! lists where the first element is an operation, and the #! rest is arguments. - [ (linearize) ] make-list ; + [ [ #prologue ] , (linearize) ] make-list ; : immediate? ( obj -- ? ) #! fixnums and f have a pointerless representation, and @@ -83,6 +89,8 @@ SYMBOL: #end-dispatch linearize-simple-label ] "linearizer" set-word-prop +: return, [ #epilogue ] , [ #return ] , ; + : linearize-label ( node -- ) #! Labels are tricky, because they might contain non-tail #! calls. So we push the address of the location right after @@ -92,7 +100,7 @@ SYMBOL: #end-dispatch #! not contain non-tail recursive calls to itself.