+ compiler:\r
\r
- flushing optimization\r
-- compile-byte/cell: instantiating aliens\r
-- fix fixnum<< and /i overflow on PowerPC\r
-- simplifier:\r
- - kill replace after a peek\r
- - merge inc-d's across VOPs that don't touch the stack\r
-- intrinsic char-slot set-char-slot integer-slot set-integer-slot\r
+- fix fixnum/mod overflow on PowerPC\r
+- eliminate simplifier\r
+- intrinsic char-slot set-char-slot\r
- [ [ dup call ] dup call ] infer hangs\r
- declarations\r
- the invalid recursion form case needs to be fixed, for inlines too\r
-- #jump-f #jump-f-label\r
-- re-introduce #target-label => #target optimization\r
- recursion is iffy; if the stack at the recursive call doesn't match\r
up, throw an error\r
+- remove %fixnum-</<=/>/>=, always use %jump-* form\r
+- remove %jump-t, use %jump-eq? f instead\r
+- kill dead code after 'throw'\r
+- better type inference\r
\r
+ kernel:\r
\r
! A few things the front-end needs to know about the back-end.
+DEFER: cell ( -- n )
+#! Word size
+
DEFER: fixnum-imm? ( -- ? )
#! Can fixnum operations take immediate operands?
SYMBOL: interned-literals
-: cell 4 ; inline
: compiled-header HEX: 01c3babe ; inline
: compiled-byte ( a -- n )
IN: compiler-frontend
USING: assembler compiler-backend math ;
-! Architecture description
+! PowerPC register assignments
+! r3-r10 vregs
+! r14 data stack
+! r15 call stack
+
+: cell
+ #! Word size.
+ 4 ; inline
+
: fixnum-imm? ( -- ? )
#! Can fixnum operations take immediate operands?
- f ;
+ f ; inline
: vregs ( -- n )
#! Number of vregs
- 8 ;
+ 8 ; inline
M: vreg v>operand vreg-n 3 + ;
"end" get save-xt
3 6 MR ;
+: first-bignum ( -- n )
+ 1 cell 8 * tag-bits - 1 - shift ; inline
+
+: most-positive-fixnum ( -- n )
+ first-bignum 1 - >fixnum ; inline
+
: most-negative-fixnum ( -- n )
- 1 cell 8 * tag-bits - 1 - shift neg ; inline
+ first-bignum neg >fixnum ; inline
M: %fixnum/i generate-node ( vop -- )
#! This has specific vreg requirements.
- drop
- 0 MTXER
- 5 3 4 DIVWO.
- <label> "overflow" set
<label> "end" set
- "overflow" get BO
- 3 5 tag-fixnum
- "end" get B
- "overflow" get save-xt
+ drop
+ 5 3 4 DIVW
+ most-positive-fixnum 4 LOAD
+ 5 3 tag-fixnum
+ 5 0 4 CMP
+ "end" get BLE
most-negative-fixnum neg 3 LOAD
"s48_long_to_bignum" f compile-c-call
3 3 bignum-tag ORI
"end" get B
! there is not going to be an overflow
"no-overflow" get save-xt
- 3 3 rot SLWI
+ 3 3 rot SLWI.
"end" get save-xt ;
M: %fixnum>> generate-node ( vop -- )
USING: alien assembler compiler inference kernel
kernel-internals lists math memory namespaces words ;
-! PowerPC register assignments
-! r14 data stack
-! r15 call stack
-! r16-r30 vregs
-
: compile-c-call ( symbol dll -- )
- 2dup dlsym 19 LOAD32 0 1 rel-dlsym 19 MTLR BLRL ;
+ 2dup dlsym 3 LOAD32 0 1 rel-dlsym 3 MTLR BLRL ;
M: %prologue generate-node ( vop -- )
drop
M: %untag-fixnum generate-node ( vop -- )
dest/src tag-bits SRAWI ;
-: tag-fixnum ( dest src -- ) tag-bits SLWI ;
+: tag-fixnum ( src dest -- ) tag-bits SLWI ;
M: %retag-fixnum generate-node ( vop -- )
! todo: formalize scratch register usage
IN: compiler-frontend
USING: assembler compiler-backend sequences ;
-! Architecture description
+! x86 register assignments
+! EAX, ECX, EDX vregs
+! ESI datastack
+! EBX callstack
+
+: cell
+ #! Word size.
+ 4 ; inline
+
: fixnum-imm? ( -- ? )
#! Can fixnum operations take immediate operands?
- t ;
+ t ; inline
: vregs ( -- n )
#! Number of vregs
- 3 ;
+ 3 ; inline
M: vreg v>operand vreg-n { EAX ECX EDX } nth ;
[ 268435456 ] [ -268435456 >fixnum -1 [ fixnum/i ] compile-1 ] unit-test
+[ 268435456 0 ] [ -268435456 >fixnum -1 [ fixnum/mod ] compile-1 ] unit-test
+
[ t ] [ f [ f eq? ] compile-1 ] unit-test