preliminary powerpc work

cvs
Slava Pestov 2005-03-13 22:55:57 +00:00
parent 31be7f42a7
commit 9f2e3aaab6
4 changed files with 68 additions and 6 deletions

View File

@ -11,7 +11,6 @@ parse-command-line
! Dummy defs for mini bootstrap
IN: compiler : compile-all ; : compile drop ; : supported-cpu? f ;
IN: assembler : init-assembler ;
IN: alien : add-library 3drop ;
: pull-in ( ? list -- )
swap [
@ -22,7 +21,7 @@ IN: alien : add-library 3drop ;
drop
] ifte ;
"mini" get not [
t [
"/library/tools/debugger.factor"
"/library/tools/gensym.factor"
"/library/tools/interpreter.factor"
@ -47,14 +46,19 @@ IN: alien : add-library 3drop ;
"/library/compiler/alien.factor"
] pull-in
cpu "x86" = "mini" get not and [
cpu "x86" = [
"/library/compiler/x86/assembler.factor"
"/library/compiler/x86/stack.factor"
"/library/compiler/x86/generator.factor"
"/library/compiler/x86/fixnum.factor"
] pull-in
"compile" get supported-cpu? and [
cpu "ppc" = [
"/library/compiler/ppc/assembler.factor"
"/library/compiler/ppc/stack.factor"
] pull-in
"compile" get cpu "x86" = and [
init-assembler
\ car compile
\ = compile
@ -62,7 +66,7 @@ cpu "x86" = "mini" get not and [
\ scan compile
] when
"mini" get not [
t [
"/library/math/constants.factor"
"/library/math/pow.factor"
"/library/math/trig-hyp.factor"

View File

@ -0,0 +1,34 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: assembler
USING: errors kernel math memory words ;
: insn ( operand opcode -- ) 26 shift bitor compile-cell ;
: b-form ( bo bi bd aa lk -- n )
>r 1 shift >r 2 shift >r 16 shift >r 21 shift
r> bitor r> bitor r> bitor r> bitor ;
: d-form ( d a simm -- n )
>r 16 shift >r 21 shift r> bitor r> bitor ;
: i-form ( li aa lk -- n )
>r 1 shift bitor r> bitor ;
: xfx-form ( d spr xo -- n )
1 shift >r 11 shift >r 21 shift r> bitor r> bitor ;
: ADDI d-form 14 insn ;
: LI 0 rot ADDI ;
: ADDIS d-form 15 insn ;
: LIS 0 rot ADDIS ;
: ORI d-form 24 insn ;
: BL 0 1 i-form 18 insn ;
: BCLR 0 8 0 0 b-form 19 insn ;
: BLR 20 BCLR ;
: MFSPR 5 shift 339 xfx-form 31 insn ;
: MFLR 8 MFSPR ;
: MTSPR 5 shift 467 xfx-form 31 insn ;
: MTLR 8 MTSPR ;
: STW d-form 36 insn ;
: STWU d-form 37 insn ;

View File

@ -0,0 +1,22 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: assembler
USING: errors kernel math memory words ;
: PUSH-DS
#! Push r18 on the data stack.
18 14 4 STWU ;
: w>h/h dup -16 shift HEX: ffff bitand >r HEX: ffff bitand r> ;
: immediate-literal ( obj -- )
#! PowerPC cannot load a 32 bit literal in one instruction.
address dup HEX: ffff <= [
18 LI
] [
w>h/h 18 LIS 18 18 rot ORI
] ifte PUSH-DS ;
: PUSH-CS
#! Push r18 on the return stack.
18 15 4 STWU ;

View File

@ -10,8 +10,10 @@ void init_factor(char* image)
init_errors();
#ifdef FACTOR_X86
#if defined(FACTOR_X86)
userenv[CPU_ENV] = tag_object(from_c_string("x86"));
#elif defined(FACTOR_PPC)
userenv[CPU_ENV] = tag_object(from_c_string("ppc"));
#else
userenv[CPU_ENV] = tag_object(from_c_string("unknown"));
#endif