compiling over, pick, >r and r>
parent
e2541faa72
commit
0fa94a9102
|
@ -56,6 +56,7 @@ cpu "x86" = [
|
||||||
cpu "ppc" = [
|
cpu "ppc" = [
|
||||||
"/library/compiler/ppc/assembler.factor"
|
"/library/compiler/ppc/assembler.factor"
|
||||||
"/library/compiler/ppc/stack.factor"
|
"/library/compiler/ppc/stack.factor"
|
||||||
|
"/library/compiler/ppc/generator.factor"
|
||||||
] pull-in
|
] pull-in
|
||||||
|
|
||||||
"compile" get cpu "x86" = and [
|
"compile" get cpu "x86" = and [
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
IN: assembler
|
IN: assembler
|
||||||
USING: errors kernel math memory words ;
|
USING: errors kernel math memory words ;
|
||||||
|
|
||||||
|
! See the Motorola or IBM documentation for details. The opcode
|
||||||
|
! names are standard.
|
||||||
|
|
||||||
: insn ( operand opcode -- ) 26 shift bitor compile-cell ;
|
: insn ( operand opcode -- ) 26 shift bitor compile-cell ;
|
||||||
|
|
||||||
: b-form ( bo bi bd aa lk -- n )
|
: b-form ( bo bi bd aa lk -- n )
|
||||||
|
@ -10,7 +13,7 @@ USING: errors kernel math memory words ;
|
||||||
r> bitor r> bitor r> bitor r> bitor ;
|
r> bitor r> bitor r> bitor r> bitor ;
|
||||||
|
|
||||||
: d-form ( d a simm -- n )
|
: d-form ( d a simm -- n )
|
||||||
>r 16 shift >r 21 shift r> bitor r> bitor ;
|
HEX: ffff bitand >r 16 shift >r 21 shift r> bitor r> bitor ;
|
||||||
|
|
||||||
: i-form ( li aa lk -- n )
|
: i-form ( li aa lk -- n )
|
||||||
>r 1 shift bitor r> bitor ;
|
>r 1 shift bitor r> bitor ;
|
||||||
|
@ -19,6 +22,7 @@ USING: errors kernel math memory words ;
|
||||||
1 shift >r 11 shift >r 21 shift r> bitor r> bitor ;
|
1 shift >r 11 shift >r 21 shift r> bitor r> bitor ;
|
||||||
|
|
||||||
: ADDI d-form 14 insn ;
|
: ADDI d-form 14 insn ;
|
||||||
|
: SUBI neg ADDI ;
|
||||||
: LI 0 rot ADDI ;
|
: LI 0 rot ADDI ;
|
||||||
: ADDIS d-form 15 insn ;
|
: ADDIS d-form 15 insn ;
|
||||||
: LIS 0 rot ADDIS ;
|
: LIS 0 rot ADDIS ;
|
||||||
|
@ -30,5 +34,6 @@ USING: errors kernel math memory words ;
|
||||||
: MFLR 8 MFSPR ;
|
: MFLR 8 MFSPR ;
|
||||||
: MTSPR 5 shift 467 xfx-form 31 insn ;
|
: MTSPR 5 shift 467 xfx-form 31 insn ;
|
||||||
: MTLR 8 MTSPR ;
|
: MTLR 8 MTSPR ;
|
||||||
|
: LWZ d-form 32 insn ;
|
||||||
: STW d-form 36 insn ;
|
: STW d-form 36 insn ;
|
||||||
: STWU d-form 37 insn ;
|
: STWU d-form 37 insn ;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
! Copyright (C) 2005 Slava Pestov.
|
||||||
|
! See http://factor.sf.net/license.txt for BSD license.
|
||||||
|
IN: compiler
|
||||||
|
USING: assembler inference kernel words ;
|
||||||
|
|
||||||
|
#return [ drop BLR ] "generator" set-word-prop
|
|
@ -1,11 +1,18 @@
|
||||||
! Copyright (C) 2005 Slava Pestov.
|
! Copyright (C) 2005 Slava Pestov.
|
||||||
! See http://factor.sf.net/license.txt for BSD license.
|
! See http://factor.sf.net/license.txt for BSD license.
|
||||||
IN: assembler
|
IN: assembler
|
||||||
USING: errors kernel math memory words ;
|
USING: compiler errors kernel math memory words ;
|
||||||
|
|
||||||
: PUSH-DS
|
! Pushing and popping the data stack.
|
||||||
#! Push r18 on the data stack.
|
: PEEK-DS 18 14 0 LWZ ;
|
||||||
18 14 4 STWU ;
|
: POP-DS PEEK-DS 14 14 4 SUBI ;
|
||||||
|
: PUSH-DS 18 14 4 STWU ;
|
||||||
|
: REPL-DS 18 14 0 STW ;
|
||||||
|
|
||||||
|
! Pushing and popping the return stack.
|
||||||
|
: PEEK-CS 18 15 0 LWZ ;
|
||||||
|
: POP-CS PEEK-CS 15 15 4 SUBI ;
|
||||||
|
: PUSH-CS 18 15 4 STWU ;
|
||||||
|
|
||||||
: w>h/h dup -16 shift HEX: ffff bitand >r HEX: ffff bitand r> ;
|
: w>h/h dup -16 shift HEX: ffff bitand >r HEX: ffff bitand r> ;
|
||||||
|
|
||||||
|
@ -15,8 +22,19 @@ USING: errors kernel math memory words ;
|
||||||
18 LI
|
18 LI
|
||||||
] [
|
] [
|
||||||
w>h/h 18 LIS 18 18 rot ORI
|
w>h/h 18 LIS 18 18 rot ORI
|
||||||
] ifte PUSH-DS ;
|
] ifte ;
|
||||||
|
|
||||||
: PUSH-CS
|
#push-immediate [
|
||||||
#! Push r18 on the return stack.
|
immediate-literal PUSH-DS
|
||||||
18 15 4 STWU ;
|
] "generator" set-word-prop
|
||||||
|
|
||||||
|
#replace-immediate [
|
||||||
|
immediate-literal REPL-DS
|
||||||
|
] "generator" set-word-prop
|
||||||
|
|
||||||
|
\ drop [ drop 14 14 4 SUBI ] "generator" set-word-prop
|
||||||
|
\ dup [ drop PEEK-DS PUSH-DS ] "generator" set-word-prop
|
||||||
|
\ over [ drop 18 14 -4 LWZ PUSH-DS ] "generator" set-word-prop
|
||||||
|
\ pick [ drop 18 14 -8 LWZ PUSH-DS ] "generator" set-word-prop
|
||||||
|
\ >r [ drop POP-DS PUSH-CS ] "generator" set-word-prop
|
||||||
|
\ r> [ drop POP-CS PUSH-DS ] "generator" set-word-prop
|
||||||
|
|
|
@ -23,7 +23,7 @@ void primitive_set_literal_top(void);
|
||||||
void collect_literals(void);
|
void collect_literals(void);
|
||||||
|
|
||||||
#ifdef FACTOR_PPC
|
#ifdef FACTOR_PPC
|
||||||
extern void flush_icache(void *start, int len);
|
void flush_icache(void *start, int len);
|
||||||
#else
|
#else
|
||||||
INLINE void flush_icache(void *start, int len) {}
|
INLINE void flush_icache(void *start, int len) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#ifndef __FACTOR_H__
|
#ifndef __FACTOR_H__
|
||||||
#define __FACTOR_H__
|
#define __FACTOR_H__
|
||||||
|
|
||||||
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32)
|
#include "platform.h"
|
||||||
#define FACTOR_X86
|
|
||||||
#elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC)
|
|
||||||
#define FACTOR_PPC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#define DLLEXPORT __declspec(dllexport)
|
#define DLLEXPORT __declspec(dllexport)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
/* Thanks to Joshua Grams for this code.
|
/* Thanks to Joshua Grams for this code.
|
||||||
|
|
||||||
On PowerPC processors, we must flush the instruction cache manually
|
On PowerPC processors, we must flush the instruction cache manually
|
||||||
|
@ -12,8 +14,8 @@ This function is called from compiler.c. */
|
||||||
|
|
||||||
/* IN: 3 = start, 4 = len */
|
/* IN: 3 = start, 4 = len */
|
||||||
|
|
||||||
.global _flush_icache
|
.global flush_icache
|
||||||
_flush_icache:
|
flush_icache:
|
||||||
/* compute number of cache lines to flush */
|
/* compute number of cache lines to flush */
|
||||||
add 4,4,3
|
add 4,4,3
|
||||||
clrrwi 3,3,5 /* align addr to next lower cache line boundary */
|
clrrwi 3,3,5 /* align addr to next lower cache line boundary */
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32)
|
||||||
|
#define FACTOR_X86
|
||||||
|
#elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC)
|
||||||
|
#define FACTOR_PPC
|
||||||
|
#endif
|
Loading…
Reference in New Issue