compiler.cfg: split off condition codes into a comparisons sub-vocabulary
parent
1481f7b591
commit
768e2a5148
|
@ -1,7 +1,10 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors combinators.short-circuit kernel sequences vectors
|
||||
compiler.cfg.instructions compiler.cfg.rpo compiler.cfg ;
|
||||
compiler.cfg.instructions
|
||||
compiler.cfg.comparisons
|
||||
compiler.cfg.rpo
|
||||
compiler.cfg ;
|
||||
IN: compiler.cfg.branch-folding
|
||||
|
||||
! Fold comparisons where both inputs are the same. Predecessors must be
|
||||
|
|
|
@ -14,6 +14,7 @@ compiler.cfg.stacks
|
|||
compiler.cfg.utilities
|
||||
compiler.cfg.registers
|
||||
compiler.cfg.intrinsics
|
||||
compiler.cfg.comparisons
|
||||
compiler.cfg.stack-frame
|
||||
compiler.cfg.instructions
|
||||
compiler.alien ;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: assocs math.order sequences ;
|
||||
IN: compiler.cfg.comparisons
|
||||
|
||||
SYMBOLS: cc< cc<= cc= cc> cc>= cc/= ;
|
||||
|
||||
: negate-cc ( cc -- cc' )
|
||||
H{
|
||||
{ cc< cc>= }
|
||||
{ cc<= cc> }
|
||||
{ cc> cc<= }
|
||||
{ cc>= cc< }
|
||||
{ cc= cc/= }
|
||||
{ cc/= cc= }
|
||||
} at ;
|
||||
|
||||
: swap-cc ( cc -- cc' )
|
||||
H{
|
||||
{ cc< cc> }
|
||||
{ cc<= cc>= }
|
||||
{ cc> cc< }
|
||||
{ cc>= cc<= }
|
||||
{ cc= cc= }
|
||||
{ cc/= cc/= }
|
||||
} at ;
|
||||
|
||||
: evaluate-cc ( result cc -- ? )
|
||||
H{
|
||||
{ cc< { +lt+ } }
|
||||
{ cc<= { +lt+ +eq+ } }
|
||||
{ cc= { +eq+ } }
|
||||
{ cc>= { +eq+ +gt+ } }
|
||||
{ cc> { +gt+ } }
|
||||
{ cc/= { +lt+ +gt+ } }
|
||||
} at memq? ;
|
|
@ -181,44 +181,6 @@ INSN: ##loop-entry ;
|
|||
|
||||
INSN: ##phi < ##pure inputs ;
|
||||
|
||||
! Condition codes
|
||||
SYMBOL: cc<
|
||||
SYMBOL: cc<=
|
||||
SYMBOL: cc=
|
||||
SYMBOL: cc>
|
||||
SYMBOL: cc>=
|
||||
SYMBOL: cc/=
|
||||
|
||||
: negate-cc ( cc -- cc' )
|
||||
H{
|
||||
{ cc< cc>= }
|
||||
{ cc<= cc> }
|
||||
{ cc> cc<= }
|
||||
{ cc>= cc< }
|
||||
{ cc= cc/= }
|
||||
{ cc/= cc= }
|
||||
} at ;
|
||||
|
||||
: swap-cc ( cc -- cc' )
|
||||
H{
|
||||
{ cc< cc> }
|
||||
{ cc<= cc>= }
|
||||
{ cc> cc< }
|
||||
{ cc>= cc<= }
|
||||
{ cc= cc= }
|
||||
{ cc/= cc/= }
|
||||
} at ;
|
||||
|
||||
: evaluate-cc ( result cc -- ? )
|
||||
H{
|
||||
{ cc< { +lt+ } }
|
||||
{ cc<= { +lt+ +eq+ } }
|
||||
{ cc= { +eq+ } }
|
||||
{ cc>= { +eq+ +gt+ } }
|
||||
{ cc> { +gt+ } }
|
||||
{ cc/= { +lt+ +gt+ } }
|
||||
} at memq? ;
|
||||
|
||||
TUPLE: ##conditional-branch < insn { src1 vreg } { src2 vreg } cc ;
|
||||
|
||||
INSN: ##compare-branch < ##conditional-branch ;
|
||||
|
|
|
@ -7,7 +7,8 @@ compiler.cfg.hats
|
|||
compiler.cfg.stacks
|
||||
compiler.cfg.instructions
|
||||
compiler.cfg.utilities
|
||||
compiler.cfg.registers ;
|
||||
compiler.cfg.registers
|
||||
compiler.cfg.comparisons ;
|
||||
IN: compiler.cfg.intrinsics.fixnum
|
||||
|
||||
: emit-both-fixnums? ( -- )
|
||||
|
|
|
@ -8,7 +8,8 @@ compiler.cfg.intrinsics.allot
|
|||
compiler.cfg.intrinsics.fixnum
|
||||
compiler.cfg.intrinsics.float
|
||||
compiler.cfg.intrinsics.slots
|
||||
compiler.cfg.intrinsics.misc ;
|
||||
compiler.cfg.intrinsics.misc
|
||||
compiler.cfg.comparisons ;
|
||||
QUALIFIED: kernel
|
||||
QUALIFIED: arrays
|
||||
QUALIFIED: byte-arrays
|
||||
|
|
|
@ -5,6 +5,7 @@ combinators assocs arrays locals cpu.architecture
|
|||
compiler.cfg
|
||||
compiler.cfg.rpo
|
||||
compiler.cfg.liveness
|
||||
compiler.cfg.comparisons
|
||||
compiler.cfg.stack-frame
|
||||
compiler.cfg.instructions ;
|
||||
IN: compiler.cfg.linearization
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors locals combinators combinators.short-circuit arrays
|
||||
fry kernel layouts math namespaces sequences cpu.architecture
|
||||
math.bitwise compiler.cfg.hats compiler.cfg.instructions
|
||||
math.bitwise
|
||||
compiler.cfg.hats
|
||||
compiler.cfg.comparisons
|
||||
compiler.cfg.instructions
|
||||
compiler.cfg.value-numbering.expressions
|
||||
compiler.cfg.value-numbering.graph
|
||||
compiler.cfg.value-numbering.simplify ;
|
||||
|
|
|
@ -4,9 +4,14 @@ USING: accessors assocs alien alien.c-types arrays strings
|
|||
cpu.x86.assembler cpu.x86.assembler.private cpu.architecture
|
||||
kernel kernel.private math memory namespaces make sequences
|
||||
words system layouts combinators math.order fry locals
|
||||
compiler.constants compiler.cfg.registers
|
||||
compiler.cfg.instructions compiler.cfg.intrinsics
|
||||
compiler.cfg.stack-frame compiler.codegen compiler.codegen.fixup ;
|
||||
compiler.constants
|
||||
compiler.cfg.registers
|
||||
compiler.cfg.instructions
|
||||
compiler.cfg.intrinsics
|
||||
compiler.cfg.comparisons
|
||||
compiler.cfg.stack-frame
|
||||
compiler.codegen
|
||||
compiler.codegen.fixup ;
|
||||
IN: cpu.x86
|
||||
|
||||
<< enable-fixnum-log2 >>
|
||||
|
|
Loading…
Reference in New Issue