Generate branches in reverse order

db4
Slava Pestov 2008-04-17 03:06:55 -05:00
parent b4ce5c93e8
commit 91e516853a
8 changed files with 35 additions and 35 deletions

View File

@ -56,7 +56,7 @@ HOOK: %call cpu ( word -- )
HOOK: %jump-label cpu ( label -- )
! Test if vreg is 'f' or not
HOOK: %jump-t cpu ( label -- )
HOOK: %jump-f cpu ( label -- )
HOOK: %dispatch cpu ( -- )

View File

@ -106,8 +106,8 @@ M: ppc %call ( label -- ) BL ;
M: ppc %jump-label ( label -- ) B ;
M: ppc %jump-t ( label -- )
0 "flag" operand f v>operand CMPI BNE ;
M: ppc %jump-f ( label -- )
0 "flag" operand f v>operand CMPI BE ;
M: ppc %dispatch ( -- )
[

View File

@ -217,11 +217,11 @@ IN: cpu.ppc.intrinsics
2array define-if-intrinsics ;
{
{ fixnum< BLT }
{ fixnum<= BLE }
{ fixnum> BGT }
{ fixnum>= BGE }
{ eq? BEQ }
{ fixnum< BGE }
{ fixnum<= BGT }
{ fixnum> BLE }
{ fixnum>= BLT }
{ eq? BNE }
} [
first2 define-fixnum-jump
] each
@ -356,11 +356,11 @@ IN: cpu.ppc.intrinsics
{ { float "x" } { float "y" } } define-if-intrinsic ;
{
{ float< BLT }
{ float<= BLE }
{ float> BGT }
{ float>= BGE }
{ float= BEQ }
{ float< BGE }
{ float<= BGT }
{ float> BLE }
{ float>= BLT }
{ float= BNE }
} [
first2 define-float-jump
] each

View File

@ -267,7 +267,7 @@ os windows? [
EDX 26 SHR
EDX 1 AND
{ EAX EBX ECX EDX } [ POP ] each
JNE
JE
] { } define-if-intrinsic
"-no-sse2" cli-args member? [

View File

@ -47,13 +47,13 @@ M: x86 stack-frame ( n -- i )
3 cells + 16 align cell - ;
M: x86 %save-word-xt ( -- )
xt-reg 0 MOV rc-absolute-cell rel-this ;
temp-reg v>operand 0 MOV rc-absolute-cell rel-this ;
: factor-area-size 4 cells ;
M: x86 %prologue ( n -- )
dup cell + PUSH
xt-reg PUSH
temp-reg v>operand PUSH
stack-reg swap 2 cells - SUB ;
M: x86 %epilogue ( n -- )
@ -76,8 +76,8 @@ M: x86 %call ( label -- ) CALL ;
M: x86 %jump-label ( label -- ) JMP ;
M: x86 %jump-t ( label -- )
"flag" operand f v>operand CMP JNE ;
M: x86 %jump-f ( label -- )
"flag" operand f v>operand CMP JE ;
: code-alignment ( -- n )
building get length dup cell align swap - ;

View File

@ -212,11 +212,11 @@ IN: cpu.x86.intrinsics
2array define-if-intrinsics ;
{
{ fixnum< JL }
{ fixnum<= JLE }
{ fixnum> JG }
{ fixnum>= JGE }
{ eq? JE }
{ fixnum< JGE }
{ fixnum<= JG }
{ fixnum> JLE }
{ fixnum>= JL }
{ eq? JNE }
} [
first2 define-fixnum-jump
] each

View File

@ -27,11 +27,11 @@ IN: cpu.x86.sse2
{ { float "x" } { float "y" } } define-if-intrinsic ;
{
{ float< JB }
{ float<= JBE }
{ float> JA }
{ float>= JAE }
{ float= JE }
{ float< JAE }
{ float<= JA }
{ float> JBE }
{ float>= JB }
{ float= JNE }
} [
first2 define-float-jump
] each

View File

@ -131,14 +131,14 @@ M: #loop generate-node
: generate-if ( node label -- next )
<label> [
>r >r node-children first2 generate-branch
>r >r node-children first2 swap generate-branch
r> r> end-false-branch resolve-label
generate-branch
init-templates
] keep resolve-label iterate-next ;
M: #if generate-node
[ <label> dup %jump-t ]
[ <label> dup %jump-f ]
H{ { +input+ { { f "flag" } } } }
with-template
generate-if ;
@ -189,13 +189,13 @@ M: #dispatch generate-node
"if-intrinsics" set-word-prop ;
: if>boolean-intrinsic ( quot -- )
"true" define-label
"false" define-label
"end" define-label
"true" get swap call
f "if-scratch" get load-literal
"end" get %jump-label
"true" resolve-label
"false" get swap call
t "if-scratch" get load-literal
"end" get %jump-label
"false" resolve-label
f "if-scratch" get load-literal
"end" resolve-label
"if-scratch" get phantom-push ; inline