| \ throw execute, cfa and NEXT1 out? |
\ throw execute, cfa and NEXT1 out? |
| \ macroize *ip, ip++, *ip++ (pipelining)? |
\ macroize *ip, ip++, *ip++ (pipelining)? |
| |
|
| |
\ Stack caching setup |
| |
|
| |
ifdef(`M4_ENGINE_FAST', `include(cache1.vmg)', `include(cache0.vmg)') |
| |
|
| \ these m4 macros would collide with identifiers |
\ these m4 macros would collide with identifiers |
| undefine(`index') |
undefine(`index') |
| undefine(`shift') |
undefine(`shift') |
| undefine(`symbols') |
undefine(`symbols') |
| |
|
| |
\F 0 [if] |
| |
|
| \ run-time routines for non-primitives. They are defined as |
\ run-time routines for non-primitives. They are defined as |
| \ primitives, because that simplifies things. |
\ primitives, because that simplifies things. |
| |
|
| (docol) ( -- R:a_retaddr ) gforth-internal paren_docol |
(docol) ( -- R:a_retaddr ) gforth-internal paren_docol |
| ""run-time routine for colon definitions"" |
""run-time routine for colon definitions"" |
| a_retaddr = (Cell *)ip; |
#ifdef NO_IP |
| |
a_retaddr = next_code; |
| |
INST_TAIL; |
| |
goto **(Label *)PFA(CFA); |
| |
#else /* !defined(NO_IP) */ |
| |
a_retaddr = (Cell *)IP; |
| SET_IP((Xt *)PFA(CFA)); |
SET_IP((Xt *)PFA(CFA)); |
| |
#endif /* !defined(NO_IP) */ |
| |
|
| (docon) ( -- w ) gforth-internal paren_docon |
(docon) ( -- w ) gforth-internal paren_docon |
| ""run-time routine for constants"" |
""run-time routine for constants"" |
| w = *(Cell *)PFA(CFA); |
w = *(Cell *)PFA(CFA); |
| |
#ifdef NO_IP |
| |
INST_TAIL; |
| |
goto *next_code; |
| |
#endif /* defined(NO_IP) */ |
| |
|
| (dovar) ( -- a_body ) gforth-internal paren_dovar |
(dovar) ( -- a_body ) gforth-internal paren_dovar |
| ""run-time routine for variables and CREATEd words"" |
""run-time routine for variables and CREATEd words"" |
| a_body = PFA(CFA); |
a_body = PFA(CFA); |
| |
#ifdef NO_IP |
| |
INST_TAIL; |
| |
goto *next_code; |
| |
#endif /* defined(NO_IP) */ |
| |
|
| (douser) ( -- a_user ) gforth-internal paren_douser |
(douser) ( -- a_user ) gforth-internal paren_douser |
| ""run-time routine for constants"" |
""run-time routine for constants"" |
| a_user = (Cell *)(up+*(Cell *)PFA(CFA)); |
a_user = (Cell *)(up+*(Cell *)PFA(CFA)); |
| |
#ifdef NO_IP |
| |
INST_TAIL; |
| |
goto *next_code; |
| |
#endif /* defined(NO_IP) */ |
| |
|
| (dodefer) ( -- ) gforth-internal paren_dodefer |
(dodefer) ( -- ) gforth-internal paren_dodefer |
| ""run-time routine for deferred words"" |
""run-time routine for deferred words"" |
| SUPER_END; |
#ifndef NO_IP |
| |
ip=IP; /* undo any ip updating that may have been performed by NEXT_P0 */ |
| |
#endif /* !defined(NO_IP) */ |
| |
SUPER_END; /* !! probably unnecessary and may lead to measurement errors */ |
| EXEC(*(Xt *)PFA(CFA)); |
EXEC(*(Xt *)PFA(CFA)); |
| |
|
| (dofield) ( n1 -- n2 ) gforth-internal paren_field |
(dofield) ( n1 -- n2 ) gforth-internal paren_field |
| ""run-time routine for fields"" |
""run-time routine for fields"" |
| n2 = n1 + *(Cell *)PFA(CFA); |
n2 = n1 + *(Cell *)PFA(CFA); |
| |
#ifdef NO_IP |
| |
INST_TAIL; |
| |
goto *next_code; |
| |
#endif /* defined(NO_IP) */ |
| |
|
| (dodoes) ( -- a_body R:a_retaddr ) gforth-internal paren_dodoes |
(dodoes) ( -- a_body R:a_retaddr ) gforth-internal paren_dodoes |
| ""run-time routine for @code{does>}-defined words"" |
""run-time routine for @code{does>}-defined words"" |
| a_retaddr = (Cell *)ip; |
#ifdef NO_IP |
| |
a_retaddr = next_code; |
| |
a_body = PFA(CFA); |
| |
INST_TAIL; |
| |
goto **(Label *)DOES_CODE1(CFA); |
| |
#else /* !defined(NO_IP) */ |
| |
a_retaddr = (Cell *)IP; |
| a_body = PFA(CFA); |
a_body = PFA(CFA); |
| SET_IP(DOES_CODE1(CFA)); |
SET_IP(DOES_CODE1(CFA)); |
| |
#endif /* !defined(NO_IP) */ |
| |
|
| (does-handler) ( -- ) gforth-internal paren_does_handler |
(does-handler) ( -- ) gforth-internal paren_does_handler |
| ""just a slot to have an encoding for the DOESJUMP, |
""just a slot to have an encoding for the DOESJUMP, |
| which is no longer used anyway (!! eliminate this)"" |
which is no longer used anyway (!! eliminate this)"" |
| |
|
| |
\F [endif] |
| |
|
| \g control |
\g control |
| |
|
| noop ( -- ) gforth |
noop ( -- ) gforth |
| call ( #a_callee -- R:a_retaddr ) new |
call ( #a_callee -- R:a_retaddr ) new |
| ""Call callee (a variant of docol with inline argument)."" |
""Call callee (a variant of docol with inline argument)."" |
| #ifdef NO_IP |
#ifdef NO_IP |
| |
assert(0); |
| INST_TAIL; |
INST_TAIL; |
| JUMP(a_callee); |
JUMP(a_callee); |
| #else |
#else |
| #ifndef NO_IP |
#ifndef NO_IP |
| ip=IP; |
ip=IP; |
| #endif |
#endif |
| IF_spTOS(spTOS = sp[0]); |
IF_spTOS(spTOS = sp[0]); /* inst_tail would produce a NEXT_P1 */ |
| SUPER_END; |
SUPER_END; |
| EXEC(xt); |
EXEC(xt); |
| |
|
| #ifndef NO_IP |
#ifndef NO_IP |
| ip=IP; |
ip=IP; |
| #endif |
#endif |
| IF_spTOS(spTOS = sp[0]); |
IF_spTOS(spTOS = sp[0]); /* inst_tail would produce a NEXT_P1 */ |
| SUPER_END; |
SUPER_END; |
| EXEC(*(Xt *)a_addr); |
EXEC(*(Xt *)a_addr); |
| : |
: |
| /* dependent upon two's complement arithmetic */ |
/* dependent upon two's complement arithmetic */ |
| Cell olddiff = n1-nlimit; |
Cell olddiff = n1-nlimit; |
| n2=n1+n; |
n2=n1+n; |
| ,if ((olddiff^(olddiff+n))>=0 /* the limit is not crossed */ |
,if (((olddiff^(olddiff+n)) /* the limit is not crossed */ |
| || (olddiff^n)>=0 /* it is a wrap-around effect */) { |
&(olddiff^n)) /* OR it is a wrap-around effect */ |
| |
>=0) { /* & is used to avoid having two branches for gforth-native */ |
| ,: |
,: |
| r> swap |
r> swap |
| r> r> 2dup - >r |
r> r> 2dup - >r |
| newdiff = -newdiff; |
newdiff = -newdiff; |
| } |
} |
| n2=n1+n; |
n2=n1+n; |
| ,if (diff>=0 || newdiff<0) { |
,if (((~diff)|newdiff)<0) { /* use | to avoid two branches for gforth-native */ |
| ,) |
,) |
| |
|
| \+ |
\+ |
| : |
: |
| rot 2dup swap - >r min swap -text dup |
rot 2dup swap - >r min swap -text dup |
| IF rdrop ELSE drop r> sgn THEN ; |
IF rdrop ELSE drop r> sgn THEN ; |
| |
: -text ( c_addr1 u c_addr2 -- n ) |
| |
swap bounds |
| |
?DO dup c@ I c@ = WHILE 1+ LOOP drop 0 |
| |
ELSE c@ I c@ - unloop THEN sgn ; |
| : sgn ( n -- -1/0/1 ) |
: sgn ( n -- -1/0/1 ) |
| dup 0= IF EXIT THEN 0< 2* 1+ ; |
dup 0= IF EXIT THEN 0< 2* 1+ ; |
| |
|
| REPEAT THEN nip nip ; |
REPEAT THEN nip nip ; |
| : (findl-samelen) ( u longname1 -- u longname2/0 ) |
: (findl-samelen) ( u longname1 -- u longname2/0 ) |
| BEGIN 2dup cell+ @ lcount-mask and <> WHILE @ dup 0= UNTIL THEN ; |
BEGIN 2dup cell+ @ lcount-mask and <> WHILE @ dup 0= UNTIL THEN ; |
| |
: capscomp ( c_addr1 u c_addr2 -- n ) |
| |
swap bounds |
| |
?DO dup c@ I c@ <> |
| |
IF dup c@ toupper I c@ toupper = |
| |
ELSE true THEN WHILE 1+ LOOP drop 0 |
| |
ELSE c@ toupper I c@ toupper - unloop THEN sgn ; |
| |
: sgn ( n -- -1/0/1 ) |
| |
dup 0= IF EXIT THEN 0< 2* 1+ ; |
| |
|
| \+hash |
\+hash |
| |
|
| # endif |
# endif |
| #endif |
#endif |
| |
|
| |
wcall ( u -- ) gforth |
| |
IF_fpTOS(fp[0]=fpTOS); |
| |
FP=fp; |
| |
sp=(Cell*)(SYSCALL(Cell*(*)(Cell *, void *))u)(sp, &FP); |
| |
fp=FP; |
| |
IF_spTOS(spTOS=sp[0];) |
| |
IF_fpTOS(fpTOS=fp[0]); |
| |
|
| \+FFCALL |
\+FFCALL |
| |
|
| av-start-void ( c_addr -- ) gforth av_start_void |
av-start-void ( c_addr -- ) gforth av_start_void |
| av_double(alist, r); |
av_double(alist, r); |
| |
|
| av-longlong ( d -- ) gforth av_longlong |
av-longlong ( d -- ) gforth av_longlong |
| |
#ifdef BUGGY_LONG_LONG |
| |
av_longlong(alist, d.lo); |
| |
#else |
| av_longlong(alist, d); |
av_longlong(alist, d); |
| |
#endif |
| |
|
| av-ptr ( c_addr -- ) gforth av_ptr |
av-ptr ( c_addr -- ) gforth av_ptr |
| av_ptr(alist, void*, c_addr); |
av_ptr(alist, void*, c_addr); |
| av_double(alist, r); |
av_double(alist, r); |
| |
|
| av-longlong-r ( R:d -- ) gforth av_longlong_r |
av-longlong-r ( R:d -- ) gforth av_longlong_r |
| |
#ifdef BUGGY_LONG_LONG |
| |
av_longlong(alist, d.lo); |
| |
#else |
| av_longlong(alist, d); |
av_longlong(alist, d); |
| |
#endif |
| |
|
| av-ptr-r ( R:c_addr -- ) gforth av_ptr_r |
av-ptr-r ( R:c_addr -- ) gforth av_ptr_r |
| av_ptr(alist, void*, c_addr); |
av_ptr(alist, void*, c_addr); |
| SAVE_REGS |
SAVE_REGS |
| av_call(alist); |
av_call(alist); |
| REST_REGS |
REST_REGS |
| |
#ifdef BUGGY_LONG_LONG |
| d = llrv; |
d = llrv; |
| |
#else |
| |
d.lo = llrv; |
| |
d.hi = 0; |
| |
#endif |
| |
|
| av-call-ptr ( -- c_addr ) gforth av_call_ptr |
av-call-ptr ( -- c_addr ) gforth av_call_ptr |
| SAVE_REGS |
SAVE_REGS |
| w = va_arg_int(clist); |
w = va_arg_int(clist); |
| |
|
| va-arg-longlong ( -- d ) gforth va_arg_longlong |
va-arg-longlong ( -- d ) gforth va_arg_longlong |
| |
#ifdef BUGGY_LONG_LONG |
| |
d.lo = va_arg_longlong(clist); |
| |
d.hi = 0; |
| |
#else |
| d = va_arg_longlong(clist); |
d = va_arg_longlong(clist); |
| |
#endif |
| |
|
| va-arg-ptr ( -- c_addr ) gforth va_arg_ptr |
va-arg-ptr ( -- c_addr ) gforth va_arg_ptr |
| c_addr = (char *)va_arg_ptr(clist,char*); |
c_addr = (char *)va_arg_ptr(clist,char*); |
| return 0; |
return 0; |
| |
|
| va-return-longlong ( d -- ) gforth va_return_longlong |
va-return-longlong ( d -- ) gforth va_return_longlong |
| |
#ifdef BUGGY_LONG_LONG |
| |
va_return_longlong(clist, d.lo); |
| |
#else |
| va_return_longlong(clist, d); |
va_return_longlong(clist, d); |
| |
#endif |
| return 0; |
return 0; |
| |
|
| va-return-float ( r -- ) gforth va_return_float |
va-return-float ( r -- ) gforth va_return_float |
| va_return_double(clist, r); |
va_return_double(clist, r); |
| return 0; |
return 0; |
| |
|
| \- |
\+ |
| |
|
| |
\+OLDCALL |
| |
|
| define(`uploop', |
define(`uploop', |
| `pushdef(`$1', `$2')_uploop(`$1', `$2', `$3', `$4', `$5')`'popdef(`$1')') |
`pushdef(`$1', `$2')_uploop(`$1', `$2', `$3', `$4', `$5')`'popdef(`$1')') |
| \+ |
\+ |
| \+ |
\+ |
| |
|
| wcall ( u -- ) gforth |
\g peephole |
| IF_fpTOS(fp[0]=fpTOS); |
|
| FP=fp; |
|
| sp=(Cell*)(SYSCALL(Cell*(*)(Cell *, void *))u)(sp, &FP); |
|
| fp=FP; |
|
| IF_spTOS(spTOS=sp[0];) |
|
| IF_fpTOS(fpTOS=fp[0]); |
|
| |
|
| \+peephole |
\+peephole |
| |
|
| \g peephole |
|
| |
|
| compile-prim1 ( a_prim -- ) gforth compile_prim1 |
compile-prim1 ( a_prim -- ) gforth compile_prim1 |
| ""compile prim (incl. immargs) at @var{a_prim}"" |
""compile prim (incl. immargs) at @var{a_prim}"" |
| compile_prim1(a_prim); |
compile_prim1(a_prim); |
| finish-code ( -- ) gforth finish_code |
finish-code ( -- ) gforth finish_code |
| ""Perform delayed steps in code generation (branch resolution, I-cache |
""Perform delayed steps in code generation (branch resolution, I-cache |
| flushing)."" |
flushing)."" |
| |
IF_spTOS(sp[0]=spTOS); /* workaround for failing to save spTOS |
| |
(gcc-2.95.1, gforth-fast --enable-force-reg) */ |
| finish_code(); |
finish_code(); |
| |
IF_spTOS(spTOS=sp[0]); |
| |
|
| forget-dyncode ( c_code -- f ) gforth-internal forget_dyncode |
forget-dyncode ( c_code -- f ) gforth-internal forget_dyncode |
| f = forget_dyncode(c_code); |
f = forget_dyncode(c_code); |
| |
|
| \g static_super |
\g static_super |
| |
|
| \C #if !defined(GFORTH_DEBUGGING) && !defined(INDIRECT_THREADED) && !defined(DOUBLY_INDIRECT) && !defined(VM_PROFILING) |
ifdef(`M4_ENGINE_FAST', |
| |
`include(peeprules.vmg)') |
| include(peeprules.vmg) |
|
| |
|
| \C #endif |
|
| |
|
| \g end |
\g end |