compiler: change how 'f' is represented in low level IR to simplify some code, and fuse a ##load-constant of a word with a ##compare into a ##compare-imm on x86-32. This eliminates a spill from binary-search
parent
cf69c58eee
commit
2aaf24412a
basis
compiler
cfg
alias-analysis
builder
hats
intrinsics/fixnum
value-numbering
tests
cpu
architecture
x86
|
@ -287,7 +287,7 @@ M: ##copy analyze-aliases*
|
|||
M: ##compare analyze-aliases*
|
||||
call-next-method
|
||||
dup useless-compare? [
|
||||
dst>> \ f type-number \ ##load-immediate new-insn
|
||||
dst>> f \ ##load-constant new-insn
|
||||
analyze-aliases*
|
||||
] when ;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ M: #recursive emit-node
|
|||
and ;
|
||||
|
||||
: emit-trivial-if ( -- )
|
||||
ds-pop \ f type-number cc/= ^^compare-imm ds-push ;
|
||||
ds-pop f cc/= ^^compare-imm ds-push ;
|
||||
|
||||
: trivial-not-if? ( #if -- ? )
|
||||
children>> first2
|
||||
|
@ -132,7 +132,7 @@ M: #recursive emit-node
|
|||
and ;
|
||||
|
||||
: emit-trivial-not-if ( -- )
|
||||
ds-pop \ f type-number cc= ^^compare-imm ds-push ;
|
||||
ds-pop f cc= ^^compare-imm ds-push ;
|
||||
|
||||
: emit-actual-if ( #if -- )
|
||||
! Inputs to the final instruction need to be copied because of
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays byte-arrays kernel layouts math
|
||||
namespaces sequences combinators splitting parser effects
|
||||
words cpu.architecture compiler.cfg.registers
|
||||
USING: accessors arrays byte-arrays combinators.short-circuit
|
||||
kernel layouts math namespaces sequences combinators splitting
|
||||
parser effects words cpu.architecture compiler.cfg.registers
|
||||
compiler.cfg.instructions compiler.cfg.instructions.syntax ;
|
||||
IN: compiler.cfg.hats
|
||||
|
||||
|
@ -41,11 +41,13 @@ insn-classes get [
|
|||
|
||||
>>
|
||||
|
||||
: immutable? ( obj -- ? )
|
||||
{ [ float? ] [ word? ] [ not ] } 1|| ; inline
|
||||
|
||||
: ^^load-literal ( obj -- dst )
|
||||
[ next-vreg dup ] dip {
|
||||
{ [ dup not ] [ drop \ f type-number ##load-immediate ] }
|
||||
{ [ dup fixnum? ] [ tag-fixnum ##load-immediate ] }
|
||||
{ [ dup float? ] [ ##load-constant ] }
|
||||
{ [ dup immutable? ] [ ##load-constant ] }
|
||||
[ ##load-reference ]
|
||||
} cond ;
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@ IN: compiler.cfg.intrinsics.fixnum
|
|||
0 cc= ^^compare-imm
|
||||
ds-push ;
|
||||
|
||||
: tag-literal ( n -- tagged )
|
||||
literal>> [ tag-fixnum ] [ \ f type-number ] if* ;
|
||||
|
||||
: emit-fixnum-op ( insn -- )
|
||||
[ 2inputs ] dip call ds-push ; inline
|
||||
|
||||
|
@ -44,7 +41,7 @@ IN: compiler.cfg.intrinsics.fixnum
|
|||
{ [ dup 0 [-inf,a] interval-subset? ] [ drop emit-fixnum-right-shift ] }
|
||||
[ drop emit-fixnum-shift-general ]
|
||||
} cond ;
|
||||
|
||||
|
||||
: emit-fixnum-bitnot ( -- )
|
||||
ds-pop ^^not tag-mask get ^^xor-imm ds-push ;
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ IN: compiler.cfg.value-numbering.rewrite
|
|||
[ value>> immediate-bitwise? ]
|
||||
} 1&& ;
|
||||
|
||||
: vreg-immediate-comparand? ( vreg -- ? )
|
||||
vreg>expr {
|
||||
[ constant-expr? ]
|
||||
[ value>> immediate-comparand? ]
|
||||
} 1&& ;
|
||||
|
||||
! Outputs f to mean no change
|
||||
|
||||
GENERIC: rewrite ( insn -- insn/f )
|
||||
|
@ -35,10 +41,7 @@ M: insn rewrite drop f ;
|
|||
|
||||
: ##branch-t? ( insn -- ? )
|
||||
dup ##compare-imm-branch? [
|
||||
{
|
||||
[ cc>> cc/= eq? ]
|
||||
[ src2>> \ f type-number eq? ]
|
||||
} 1&&
|
||||
{ [ cc>> cc/= eq? ] [ src2>> not ] } 1&&
|
||||
] [ drop f ] if ; inline
|
||||
|
||||
: general-compare-expr? ( insn -- ? )
|
||||
|
@ -118,8 +121,8 @@ M: ##compare-imm rewrite-tagged-comparison
|
|||
: rewrite-redundant-comparison? ( insn -- ? )
|
||||
{
|
||||
[ src1>> vreg>expr general-compare-expr? ]
|
||||
[ src2>> \ f type-number = ]
|
||||
[ cc>> { cc= cc/= } member-eq? ]
|
||||
[ src2>> not ]
|
||||
[ cc>> { cc= cc/= } member? ]
|
||||
} 1&& ; inline
|
||||
|
||||
: rewrite-redundant-comparison ( insn -- insn' )
|
||||
|
@ -189,8 +192,8 @@ M: ##compare-imm-branch rewrite
|
|||
|
||||
M: ##compare-branch rewrite
|
||||
{
|
||||
{ [ dup src1>> vreg-immediate-arithmetic? ] [ t >compare-imm-branch ] }
|
||||
{ [ dup src2>> vreg-immediate-arithmetic? ] [ f >compare-imm-branch ] }
|
||||
{ [ dup src1>> vreg-immediate-comparand? ] [ t >compare-imm-branch ] }
|
||||
{ [ dup src2>> vreg-immediate-comparand? ] [ f >compare-imm-branch ] }
|
||||
{ [ dup self-compare? ] [ rewrite-self-compare-branch ] }
|
||||
[ drop f ]
|
||||
} cond ;
|
||||
|
@ -209,19 +212,15 @@ M: ##compare-branch rewrite
|
|||
next-vreg \ ##compare-imm new-insn ; inline
|
||||
|
||||
: >boolean-insn ( insn ? -- insn' )
|
||||
[ dst>> ] dip
|
||||
{
|
||||
{ t [ t \ ##load-constant new-insn ] }
|
||||
{ f [ \ f type-number \ ##load-immediate new-insn ] }
|
||||
} case ;
|
||||
[ dst>> ] dip \ ##load-constant new-insn ;
|
||||
|
||||
: rewrite-self-compare ( insn -- insn' )
|
||||
dup (rewrite-self-compare) >boolean-insn ;
|
||||
|
||||
M: ##compare rewrite
|
||||
{
|
||||
{ [ dup src1>> vreg-immediate-arithmetic? ] [ t >compare-imm ] }
|
||||
{ [ dup src2>> vreg-immediate-arithmetic? ] [ f >compare-imm ] }
|
||||
{ [ dup src1>> vreg-immediate-comparand? ] [ t >compare-imm ] }
|
||||
{ [ dup src2>> vreg-immediate-comparand? ] [ f >compare-imm ] }
|
||||
{ [ dup self-compare? ] [ rewrite-self-compare ] }
|
||||
[ drop f ]
|
||||
} cond ;
|
||||
|
|
|
@ -4,7 +4,8 @@ cpu.architecture tools.test kernel math combinators.short-circuit
|
|||
accessors sequences compiler.cfg.predecessors locals compiler.cfg.dce
|
||||
compiler.cfg.ssa.destruction compiler.cfg.loop-detection
|
||||
compiler.cfg.representations compiler.cfg assocs vectors arrays
|
||||
layouts literals namespaces alien compiler.cfg.value-numbering.simd ;
|
||||
layouts literals namespaces alien compiler.cfg.value-numbering.simd
|
||||
system ;
|
||||
IN: compiler.cfg.value-numbering.tests
|
||||
|
||||
: trim-temps ( insns -- insns )
|
||||
|
@ -82,7 +83,7 @@ IN: compiler.cfg.value-numbering.tests
|
|||
T{ ##load-reference f 1 + }
|
||||
T{ ##peek f 2 D 0 }
|
||||
T{ ##compare f 4 2 1 cc> }
|
||||
T{ ##compare-imm f 6 4 $[ \ f type-number ] cc/= }
|
||||
T{ ##compare-imm f 6 4 f cc/= }
|
||||
T{ ##replace f 6 D 0 }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
@ -100,7 +101,7 @@ IN: compiler.cfg.value-numbering.tests
|
|||
T{ ##load-reference f 1 + }
|
||||
T{ ##peek f 2 D 0 }
|
||||
T{ ##compare f 4 2 1 cc<= }
|
||||
T{ ##compare-imm f 6 4 $[ \ f type-number ] cc= }
|
||||
T{ ##compare-imm f 6 4 f cc= }
|
||||
T{ ##replace f 6 D 0 }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
@ -118,7 +119,7 @@ IN: compiler.cfg.value-numbering.tests
|
|||
T{ ##peek f 8 D 0 }
|
||||
T{ ##peek f 9 D -1 }
|
||||
T{ ##compare-float-unordered f 12 8 9 cc< }
|
||||
T{ ##compare-imm f 14 12 $[ \ f type-number ] cc= }
|
||||
T{ ##compare-imm f 14 12 f cc= }
|
||||
T{ ##replace f 14 D 0 }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
@ -135,7 +136,7 @@ IN: compiler.cfg.value-numbering.tests
|
|||
T{ ##peek f 29 D -1 }
|
||||
T{ ##peek f 30 D -2 }
|
||||
T{ ##compare f 33 29 30 cc<= }
|
||||
T{ ##compare-imm-branch f 33 $[ \ f type-number ] cc/= }
|
||||
T{ ##compare-imm-branch f 33 f cc/= }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
|
@ -149,7 +150,7 @@ IN: compiler.cfg.value-numbering.tests
|
|||
{
|
||||
T{ ##peek f 1 D -1 }
|
||||
T{ ##test-vector f 2 1 f float-4-rep vcc-any }
|
||||
T{ ##compare-imm-branch f 2 $[ \ f type-number ] cc/= }
|
||||
T{ ##compare-imm-branch f 2 f cc/= }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
|
@ -418,6 +419,36 @@ IN: compiler.cfg.value-numbering.tests
|
|||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
cpu x86.32? [
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 + }
|
||||
T{ ##compare-imm f 2 0 + cc= }
|
||||
}
|
||||
] [
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 + }
|
||||
T{ ##compare f 2 0 1 cc= }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 + }
|
||||
T{ ##compare-imm-branch f 0 + cc= }
|
||||
}
|
||||
] [
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 + }
|
||||
T{ ##compare-branch f 0 1 cc= }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
] when
|
||||
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
|
@ -432,6 +463,20 @@ IN: compiler.cfg.value-numbering.tests
|
|||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 3.5 }
|
||||
T{ ##compare-branch f 0 1 cc= }
|
||||
}
|
||||
] [
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 3.5 }
|
||||
T{ ##compare-branch f 0 1 cc= }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
|
@ -460,20 +505,6 @@ IN: compiler.cfg.value-numbering.tests
|
|||
} value-numbering-step
|
||||
] unit-test
|
||||
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 3.5 }
|
||||
T{ ##compare-branch f 0 1 cc= }
|
||||
}
|
||||
] [
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-constant f 1 3.5 }
|
||||
T{ ##compare-branch f 0 1 cc= }
|
||||
} value-numbering-step trim-temps
|
||||
] unit-test
|
||||
|
||||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
|
@ -1073,7 +1104,7 @@ cell 8 = [
|
|||
{
|
||||
T{ ##load-immediate f 1 10 }
|
||||
T{ ##load-immediate f 2 20 }
|
||||
T{ ##load-immediate f 3 $[ \ f type-number ] }
|
||||
T{ ##load-constant f 3 f }
|
||||
}
|
||||
] [
|
||||
{
|
||||
|
@ -1115,7 +1146,7 @@ cell 8 = [
|
|||
{
|
||||
T{ ##load-immediate f 1 10 }
|
||||
T{ ##load-immediate f 2 20 }
|
||||
T{ ##load-immediate f 3 $[ \ f type-number ] }
|
||||
T{ ##load-constant f 3 f }
|
||||
}
|
||||
] [
|
||||
{
|
||||
|
@ -1128,7 +1159,7 @@ cell 8 = [
|
|||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-immediate f 1 $[ \ f type-number ] }
|
||||
T{ ##load-constant f 1 f }
|
||||
}
|
||||
] [
|
||||
{
|
||||
|
@ -1152,7 +1183,7 @@ cell 8 = [
|
|||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-immediate f 1 $[ \ f type-number ] }
|
||||
T{ ##load-constant f 1 f }
|
||||
}
|
||||
] [
|
||||
{
|
||||
|
@ -1176,7 +1207,7 @@ cell 8 = [
|
|||
[
|
||||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##load-immediate f 1 $[ \ f type-number ] }
|
||||
T{ ##load-constant f 1 f }
|
||||
}
|
||||
] [
|
||||
{
|
||||
|
@ -1557,7 +1588,7 @@ cell 8 = [
|
|||
{
|
||||
T{ ##peek f 0 D 0 }
|
||||
T{ ##compare f 1 0 0 cc<= }
|
||||
T{ ##compare-imm-branch f 1 $[ \ f type-number ] cc/= }
|
||||
T{ ##compare-imm-branch f 1 f cc/= }
|
||||
} test-branch-folding
|
||||
] unit-test
|
||||
|
||||
|
@ -1659,7 +1690,7 @@ V{
|
|||
T{ ##copy { dst 21 } { src 20 } { rep any-rep } }
|
||||
T{ ##compare-imm-branch
|
||||
{ src1 21 }
|
||||
{ src2 $[ \ f type-number ] }
|
||||
{ src2 f }
|
||||
{ cc cc/= }
|
||||
}
|
||||
} 1 test-bb
|
||||
|
|
|
@ -33,10 +33,10 @@ IN: compiler.tests.low-level-ir
|
|||
compile-test-cfg
|
||||
execute( -- result ) ;
|
||||
|
||||
! loading immediates
|
||||
! loading constants
|
||||
[ f ] [
|
||||
V{
|
||||
T{ ##load-immediate f 0 $[ \ f type-number ] }
|
||||
T{ ##load-constant f 0 f }
|
||||
} compile-test-bb
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -496,15 +496,27 @@ M: reg-class param-reg param-regs nth ;
|
|||
|
||||
M: stack-params param-reg 2drop ;
|
||||
|
||||
! Is this integer small enough to be an immediate operand for
|
||||
! %add-imm, %sub-imm, and %mul-imm?
|
||||
! Can this value be an immediate operand for %add-imm, %sub-imm,
|
||||
! or %mul-imm?
|
||||
HOOK: immediate-arithmetic? cpu ( n -- ? )
|
||||
|
||||
! Is this integer small enough to be an immediate operand for
|
||||
! %and-imm, %or-imm, and %xor-imm?
|
||||
! Can this value be an immediate operand for %and-imm, %or-imm,
|
||||
! or %xor-imm?
|
||||
HOOK: immediate-bitwise? cpu ( n -- ? )
|
||||
|
||||
! What c-type describes the implicit struct return pointer for large structs?
|
||||
! Can this value be an immediate operand for %compare-imm or
|
||||
! %compare-imm-branch?
|
||||
HOOK: immediate-comparand? cpu ( n -- ? )
|
||||
|
||||
M: object immediate-comparand? ( n -- ? )
|
||||
{
|
||||
{ [ dup integer? ] [ immediate-arithmetic? ] }
|
||||
{ [ dup not ] [ drop t ] }
|
||||
[ drop f ]
|
||||
} cond ;
|
||||
|
||||
! What c-type describes the implicit struct return pointer for
|
||||
! large structs?
|
||||
HOOK: struct-return-pointer-type cpu ( -- c-type )
|
||||
|
||||
! Is this structure small enough to be returned in registers?
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: locals alien alien.c-types alien.libraries alien.syntax
|
||||
arrays kernel fry math namespaces sequences system layouts io
|
||||
vocabs.loader accessors init classes.struct combinators command-line
|
||||
make compiler compiler.units compiler.constants compiler.alien
|
||||
compiler.codegen compiler.codegen.fixup
|
||||
compiler.cfg.instructions compiler.cfg.builder
|
||||
compiler.cfg.intrinsics compiler.cfg.stack-frame
|
||||
cpu.x86.assembler cpu.x86.assembler.operands cpu.x86
|
||||
cpu.architecture vm ;
|
||||
vocabs.loader accessors init classes.struct combinators
|
||||
command-line make words compiler compiler.units
|
||||
compiler.constants compiler.alien compiler.codegen
|
||||
compiler.codegen.fixup compiler.cfg.instructions
|
||||
compiler.cfg.builder compiler.cfg.intrinsics
|
||||
compiler.cfg.stack-frame cpu.x86.assembler
|
||||
cpu.x86.assembler.operands cpu.x86 cpu.architecture vm ;
|
||||
FROM: layouts => cell ;
|
||||
IN: cpu.x86.32
|
||||
|
||||
M: x86.32 immediate-comparand? ( n -- ? )
|
||||
[ call-next-method ] [ word? ] bi or ;
|
||||
|
||||
M: x86.32 machine-registers
|
||||
{
|
||||
{ int-regs { EAX ECX EDX EBP EBX } }
|
||||
|
|
|
@ -491,43 +491,60 @@ M: x86 %push-context-stack ( -- )
|
|||
|
||||
M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
|
||||
|
||||
:: %boolean ( dst temp word -- )
|
||||
:: (%boolean) ( dst temp insn -- )
|
||||
dst \ f type-number MOV
|
||||
temp 0 MOV \ t rc-absolute-cell rel-immediate
|
||||
dst temp word execute ; inline
|
||||
dst temp insn execute ; inline
|
||||
|
||||
: (%compare) ( src1 src2 cc -- )
|
||||
2over [ { cc= cc/= } member? ] [ register? ] [ 0 = ] tri* and and
|
||||
[ drop dup TEST ]
|
||||
[ CMP ] if ;
|
||||
: %boolean ( dst cc temp -- )
|
||||
swap order-cc {
|
||||
{ cc< [ \ CMOVL (%boolean) ] }
|
||||
{ cc<= [ \ CMOVLE (%boolean) ] }
|
||||
{ cc> [ \ CMOVG (%boolean) ] }
|
||||
{ cc>= [ \ CMOVGE (%boolean) ] }
|
||||
{ cc= [ \ CMOVE (%boolean) ] }
|
||||
{ cc/= [ \ CMOVNE (%boolean) ] }
|
||||
} case ;
|
||||
|
||||
M:: x86 %compare ( dst src1 src2 cc temp -- )
|
||||
src1 src2 cc (%compare)
|
||||
cc order-cc {
|
||||
{ cc< [ dst temp \ CMOVL %boolean ] }
|
||||
{ cc<= [ dst temp \ CMOVLE %boolean ] }
|
||||
{ cc> [ dst temp \ CMOVG %boolean ] }
|
||||
{ cc>= [ dst temp \ CMOVGE %boolean ] }
|
||||
{ cc= [ dst temp \ CMOVE %boolean ] }
|
||||
{ cc/= [ dst temp \ CMOVNE %boolean ] }
|
||||
} case ;
|
||||
src1 src2 CMP
|
||||
dst cc temp %boolean ;
|
||||
|
||||
M: x86 %compare-imm ( dst src1 src2 cc temp -- )
|
||||
%compare ;
|
||||
: use-test? ( src1 src2 cc -- ? )
|
||||
[ register? ] [ 0 = ] [ { cc= cc/= } member? ] tri* and and ;
|
||||
|
||||
: (%compare-tagged) ( src1 src2 -- )
|
||||
[ HEX: ffffffff CMP ] dip rc-absolute rel-immediate ;
|
||||
|
||||
: (%compare-imm) ( src1 src2 cc -- )
|
||||
{
|
||||
{ [ 3dup use-test? ] [ 2drop dup TEST ] }
|
||||
{ [ over integer? ] [ drop CMP ] }
|
||||
{ [ over word? ] [ drop (%compare-tagged) ] }
|
||||
{ [ over not ] [ 2drop f type-number CMP ] }
|
||||
} cond ;
|
||||
|
||||
M:: x86 %compare-imm ( dst src1 src2 cc temp -- )
|
||||
src1 src2 cc (%compare-imm)
|
||||
dst cc temp %boolean ;
|
||||
|
||||
: %branch ( label cc -- )
|
||||
order-cc {
|
||||
{ cc< [ JL ] }
|
||||
{ cc<= [ JLE ] }
|
||||
{ cc> [ JG ] }
|
||||
{ cc>= [ JGE ] }
|
||||
{ cc= [ JE ] }
|
||||
{ cc/= [ JNE ] }
|
||||
} case ;
|
||||
|
||||
M:: x86 %compare-branch ( label src1 src2 cc -- )
|
||||
src1 src2 cc (%compare)
|
||||
cc order-cc {
|
||||
{ cc< [ label JL ] }
|
||||
{ cc<= [ label JLE ] }
|
||||
{ cc> [ label JG ] }
|
||||
{ cc>= [ label JGE ] }
|
||||
{ cc= [ label JE ] }
|
||||
{ cc/= [ label JNE ] }
|
||||
} case ;
|
||||
src1 src2 CMP
|
||||
label cc %branch ;
|
||||
|
||||
M: x86 %compare-imm-branch ( label src1 src2 cc -- )
|
||||
%compare-branch ;
|
||||
M:: x86 %compare-imm-branch ( label src1 src2 cc -- )
|
||||
src1 src2 cc (%compare-imm)
|
||||
label cc %branch ;
|
||||
|
||||
M: x86 %add-float double-rep two-operand ADDSD ;
|
||||
M: x86 %sub-float double-rep two-operand SUBSD ;
|
||||
|
@ -569,20 +586,20 @@ M: x86 %float>integer CVTTSD2SI ;
|
|||
|
||||
:: (%compare-float) ( dst src1 src2 cc temp compare -- )
|
||||
cc {
|
||||
{ cc< [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVA %boolean ] }
|
||||
{ cc<= [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVAE %boolean ] }
|
||||
{ cc> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVA %boolean ] }
|
||||
{ cc>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVAE %boolean ] }
|
||||
{ cc= [ src1 src2 \ compare execute( a b -- ) dst temp \ %cmov-float= %boolean ] }
|
||||
{ cc<> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVNE %boolean ] }
|
||||
{ cc<>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVNP %boolean ] }
|
||||
{ cc/< [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVBE %boolean ] }
|
||||
{ cc/<= [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVB %boolean ] }
|
||||
{ cc/> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVBE %boolean ] }
|
||||
{ cc/>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVB %boolean ] }
|
||||
{ cc/= [ src1 src2 \ compare execute( a b -- ) dst temp \ %cmov-float/= %boolean ] }
|
||||
{ cc/<> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVE %boolean ] }
|
||||
{ cc/<>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVP %boolean ] }
|
||||
{ cc< [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVA (%boolean) ] }
|
||||
{ cc<= [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVAE (%boolean) ] }
|
||||
{ cc> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVA (%boolean) ] }
|
||||
{ cc>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVAE (%boolean) ] }
|
||||
{ cc= [ src1 src2 \ compare execute( a b -- ) dst temp \ %cmov-float= (%boolean) ] }
|
||||
{ cc<> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVNE (%boolean) ] }
|
||||
{ cc<>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVNP (%boolean) ] }
|
||||
{ cc/< [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVBE (%boolean) ] }
|
||||
{ cc/<= [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVB (%boolean) ] }
|
||||
{ cc/> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVBE (%boolean) ] }
|
||||
{ cc/>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVB (%boolean) ] }
|
||||
{ cc/= [ src1 src2 \ compare execute( a b -- ) dst temp \ %cmov-float/= (%boolean) ] }
|
||||
{ cc/<> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVE (%boolean) ] }
|
||||
{ cc/<>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVP (%boolean) ] }
|
||||
} case ; inline
|
||||
|
||||
M: x86 %compare-float-ordered ( dst src1 src2 cc temp -- )
|
||||
|
@ -954,10 +971,10 @@ M: x86 %compare-vector-ccs
|
|||
|
||||
:: %test-vector-mask ( dst temp mask vcc -- )
|
||||
vcc {
|
||||
{ vcc-any [ dst dst TEST dst temp \ CMOVNE %boolean ] }
|
||||
{ vcc-none [ dst dst TEST dst temp \ CMOVE %boolean ] }
|
||||
{ vcc-all [ dst mask CMP dst temp \ CMOVE %boolean ] }
|
||||
{ vcc-notall [ dst mask CMP dst temp \ CMOVNE %boolean ] }
|
||||
{ vcc-any [ dst dst TEST dst temp \ CMOVNE (%boolean) ] }
|
||||
{ vcc-none [ dst dst TEST dst temp \ CMOVE (%boolean) ] }
|
||||
{ vcc-all [ dst mask CMP dst temp \ CMOVE (%boolean) ] }
|
||||
{ vcc-notall [ dst mask CMP dst temp \ CMOVNE (%boolean) ] }
|
||||
} case ;
|
||||
|
||||
: %move-vector-mask ( dst src rep -- mask )
|
||||
|
|
Loading…
Reference in New Issue