diff --git a/h/cgg_cg.h b/h/cgg_cg.h index 6cc04b007..a7802ad33 100644 --- a/h/cgg_cg.h +++ b/h/cgg_cg.h @@ -39,6 +39,7 @@ #define DO_TOSTACK 23 #define DO_KILLREG 24 #define DO_LABDEF 25 +#define DO_STACKADJUST 26 #ifndef MAXATT #define MAXATT TOKENSIZE @@ -133,6 +134,7 @@ typedef struct exprnode *node_p; #define EX_ISROM 44 #define EX_TOPELTSIZE 45 #define EX_FALLTHROUGH 46 +#define EX_STACKOFFSET 47 typedef struct { /* to stack coercions */ diff --git a/h/out.h b/h/out.h index 6fe64bd6b..122296f8e 100644 --- a/h/out.h +++ b/h/out.h @@ -61,7 +61,10 @@ struct outname { #define RELSZ 0x07 /* relocation length */ #define RELO1 1 /* 1 byte */ #define RELO2 2 /* 2 bytes */ -#define RELO4 4 /* 4 bytes */ +#define RELO4 3 /* 4 bytes */ +#define RELOPPC 4 /* PowerPC 26-bit address */ +#define RELOH2 5 /* write top 2 bytes of 4 byte word */ + #define RELPC 0x08 /* pc relative */ #define RELBR 0x10 /* High order byte lowest address. */ #define RELWR 0x20 /* High order word lowest address. */ diff --git a/mach/m68020/libem/dia.s b/mach/m68020/libem/dia.s index f2d18dc5a..4d794d76f 100644 --- a/mach/m68020/libem/dia.s +++ b/mach/m68020/libem/dia.s @@ -14,8 +14,8 @@ del = 0177 .sect .text .diagnos: movem.l d0/d1/d2/a0, -(sp) - move.l (.lino), -(sp) - move.l (.filn), d2 + move.l (hol0), -(sp) + move.l (hol0+4), d2 beq 1f move.l d2, a0 move.l #40, d0 diff --git a/mach/m68020/libem/nop.s b/mach/m68020/libem/nop.s index 180b64129..149cfb77f 100644 --- a/mach/m68020/libem/nop.s +++ b/mach/m68020/libem/nop.s @@ -9,7 +9,7 @@ move.l (.limhp),-(sp) move.l (.reghp),-(sp) pea (12, sp) - move.l (.lino),-(sp) + move.l (hol0),-(sp) pea (fmt) jsr (.diagnos) lea (20, sp), sp diff --git a/mach/m68020/libem/trp.s b/mach/m68020/libem/trp.s index bee0eccdf..73a468201 100644 --- a/mach/m68020/libem/trp.s +++ b/mach/m68020/libem/trp.s @@ -15,7 +15,7 @@ fmt: .asciz "%s\n" move.l d0, (12, sp) cmp.l #16, d0 bcc 1f - move.l (.trpim), d1 + move.l (.ignmask), d1 btst d0, d1 bne 3f 1: diff --git a/mach/m68020/libem/trpstr.c b/mach/m68020/libem/trpstr.c index c2d29f54b..58fc397b0 100644 --- a/mach/m68020/libem/trpstr.c +++ b/mach/m68020/libem/trpstr.c @@ -1,4 +1,5 @@ #include + char * _trpstr(d) { diff --git a/mach/m68020/libend/em_end.s b/mach/m68020/libend/em_end.s index a062368da..da167bdaf 100644 --- a/mach/m68020/libend/em_end.s +++ b/mach/m68020/libend/em_end.s @@ -1,22 +1,24 @@ +! $Source: /cvsroot/tack/Ack/mach/i386/libend/em_end.s,v $ +! $State: Exp $ +! $Revision: 1.2 $ + .sect .text .sect .rom .sect .data .sect .bss -.define endtext,enddata,endbss,__end -.sect .text - .align 4 -.sect .rom - .align 4 -.sect .data - .align 4 -.sect .bss - .align 4 .sect .end ! only for declaration of _end, __end and endbss. +.define endtext, endrom, enddata, endbss, __end .sect .text + .align 4 endtext: + .sect .rom + .align 4 +endrom: .sect .data + .align 4 enddata: .sect .end + .align 4 __end: endbss: diff --git a/mach/m68020/ncg/table b/mach/m68020/ncg/table index a53b6bcec..e771b3de8 100644 --- a/mach/m68020/ncg/table +++ b/mach/m68020/ncg/table @@ -5840,7 +5840,7 @@ with any_int STACK jsr {absolute4, ".exg"} pat fil - gen move_l {ext_addr, $1}, {absolute4, ".filn"} + gen move_l {ext_addr, $1}, {absolute4, "hol0+4"} pat gto with STACK @@ -5854,15 +5854,15 @@ with STACK jmp {indirect4, %a} #endif -pat lim yields {absolute_int, ".trpim"} +pat lim yields {absolute_int, ".ignmask"} pat lin kills posextern - gen move_i {const, $1}, {absolute_int, ".lino"} + gen move_i {const, $1}, {absolute_int, "hol0"} pat lni kills posextern - gen add_i {const, 1}, {absolute_int, ".lino"} + gen add_i {const, 1}, {absolute_int, "hol0"} pat lor $1==0 yields lb @@ -5955,7 +5955,7 @@ with any4 pat sim with any_int kills posextern - gen move_i %1, {absolute_int, ".trpim"} + gen move_i %1, {absolute_int, ".ignmask"} pat str $1==0 with any4 STACK diff --git a/mach/m68020/ncg/whichone.h b/mach/m68020/ncg/whichone.h index e7da6134a..cc0704aef 100644 --- a/mach/m68020/ncg/whichone.h +++ b/mach/m68020/ncg/whichone.h @@ -6,4 +6,4 @@ #define WORD_SIZE 4 /* should be 2 or 4 */ #define TBL68020 1 /* should be TBL68020 or TBL68000 */ -/* #define TBL68881 1 /* use floating point processor */ +#define TBL68881 1 /* use floating point processor */ diff --git a/mach/m68020/pmfile b/mach/m68020/pmfile index 62bfbb856..9481a3bbb 100644 --- a/mach/m68020/pmfile +++ b/mach/m68020/pmfile @@ -3,6 +3,9 @@ local d = ROOTDIR.."mach/m68020/" +include (d.."libem/pmfile") +include (d.."libend/pmfile") + mach_m68020 = group { ARCH = "m68020", @@ -10,20 +13,11 @@ mach_m68020 = group { proto_ncg { ARCHDIR = "m68020" }, proto_top, ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } } --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- +support_m68020 = group { + OPTIMISATION = "-O6", + + libem_m68020, + libend_m68020, +} diff --git a/mach/powerpc/ncg/table b/mach/powerpc/ncg/table index c35ea728e..356cfe5fa 100644 --- a/mach/powerpc/ncg/table +++ b/mach/powerpc/ncg/table @@ -53,12 +53,12 @@ PROPERTIES GPR24 GPR25 GPR26 GPR27 GPR28 GPR29 GPR30 GPR31 CR0 CR1 - + FPR0 FPR1 FPR2 FPR3 FPR4 FPR5 FPR6 FPR7 FPR8 FPR9 FPR10 FPR11 FPR12 FPR13 FPR14 FPR15 FPR16 FPR17 FPR18 FPR19 FPR20 FPR21 FPR22 FPR23 FPR24 FPR25 FPR26 FPR27 FPR28 FPR29 FPR30 FPR31 - + REGISTERS /* Reverse order to encourage ncg to allocate them from r31 down */ @@ -95,7 +95,7 @@ REGISTERS FP("fp") : GPR, GPRFP. SP("sp") : GPR, GPRSP. R0("r0") : GPR, GPR0. - + F31("f31") : FPR, FREG, FPR31. F30("f30") : FPR, FREG, FPR30. F29("f29") : FPR, FREG, FPR29. @@ -1996,7 +1996,7 @@ PATTERNS /* All very cheap and nasty --- this needs to be properly integrated into * the code generator. ncg doesn't like having separate FPU registers. */ - + /* Single-precision */ pat zrf $1==INT32 /* Push zero */ @@ -2158,4 +2158,3 @@ PATTERNS gen bl {LABEL, ".fif8"} - \ No newline at end of file diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 8f3d26c94..11f1231a9 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -41,7 +41,7 @@ #define GENLAB "I" /* compiler generated labels */ -#define valu_t short /* type of expression values */ +#define valu_t long /* type of expression values */ #define ADDR_T unsigned short /* type of dot */ #define word_t short /* type of keyword value */ /* @@ -113,6 +113,7 @@ _include #define lowb(z) ((int)(z) & 0xFF) #define loww(z) ((int)(z) & 0xFFFF) +#define fitx(x, d) ((((x) + (1<<(d-1))) & ~((int)(1<<(d))-1)) == 0) #define fitb(x) ((((x) + 0x80) & ~((int)0xFF)) == 0) #define fitw(x) ((((x) + 0x8000L) & ~0xFFFFL) == 0) diff --git a/mach/proto/ncg/assert.h b/mach/proto/ncg/assert.h index 5d1adada8..2fda064d1 100644 --- a/mach/proto/ncg/assert.h +++ b/mach/proto/ncg/assert.h @@ -4,6 +4,7 @@ */ /* $Id$ */ +#undef NDEBUG #ifndef NDEBUG #define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__) #else diff --git a/mach/proto/ncg/codegen.c b/mach/proto/ncg/codegen.c index 30d4c25db..cf7379ccf 100644 --- a/mach/proto/ncg/codegen.c +++ b/mach/proto/ncg/codegen.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "assert.h" #include "param.h" #include "tables.h" @@ -778,7 +780,10 @@ normalfailed: if (stackpad!=tokpatlen) { compute(&enodes[nodeno], &result); assert(result.e_typ!=EV_INT && result.e_typ!=EV_ADDR); if (result.e_typ==EV_REG) - erasereg(result.e_v.e_reg); + { + int regno = result.e_v.e_reg; + erasereg(regno); + } break; } case DO_TOKREPLACE: { @@ -904,6 +909,23 @@ normalfailed: if (stackpad!=tokpatlen) { break; } +#endif +#ifdef USE_NOFRAMEPOINTER + case DO_STACKADJUST: { + result_t result; + int nodeno; + + DEBUG("STACKADJUST"); + /* The offset is an expression, which we need to evaluate. */ + + getint(nodeno,codep); + compute(&enodes[nodeno], &result); + assert(result.e_typ==EV_INT); + + if (toplevel) + stackoffset += result.e_v.e_con; + break; + } #endif } } diff --git a/mach/proto/ncg/equiv.c b/mach/proto/ncg/equiv.c index e375a73c8..a78123180 100644 --- a/mach/proto/ncg/equiv.c +++ b/mach/proto/ncg/equiv.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "assert.h" #include "equiv.h" #include "param.h" diff --git a/mach/proto/ncg/extern.h b/mach/proto/ncg/extern.h index 4b1480a93..aa5e42489 100644 --- a/mach/proto/ncg/extern.h +++ b/mach/proto/ncg/extern.h @@ -20,6 +20,9 @@ extern rl_p curreglist; /* side effect of findcoerc() */ #ifndef NDEBUG extern int Debug; /* on/off debug printout */ #endif +#ifdef USE_NOFRAMEPOINTER +extern int stackoffset; /* offset from localbase to sp */ +#endif /* * Next descriptions are external declarations for tables created @@ -52,3 +55,6 @@ extern struct reginfo **reglist[]; /* lists of registers per property */ extern int nregvar[]; /* # of register variables per type */ extern int *rvnumbers[]; /* lists of numbers */ #endif + +extern FILE *codefile; +extern FILE *freopen(); diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index 76af4417f..8838d8f9c 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -60,8 +60,6 @@ long con(); #define get8() getc(emfile) FILE *emfile; -extern FILE *codefile; -extern FILE *freopen(); int nextispseu,savetab1; int opcode; diff --git a/mach/proto/ncg/move.c b/mach/proto/ncg/move.c index 65e448ecb..17669c956 100644 --- a/mach/proto/ncg/move.c +++ b/mach/proto/ncg/move.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/mach/proto/ncg/nextem.c b/mach/proto/ncg/nextem.c index 2c76e3ced..9023f8a22 100644 --- a/mach/proto/ncg/nextem.c +++ b/mach/proto/ncg/nextem.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include #include #include "assert.h" diff --git a/mach/proto/ncg/pmfile b/mach/proto/ncg/pmfile index 1a047b669..7f29aaa09 100644 --- a/mach/proto/ncg/pmfile +++ b/mach/proto/ncg/pmfile @@ -1,5 +1,5 @@ --- $Source$ --- $State$ +-- $Source: /cvsroot/tack/Ack/mach/proto/ncg/pmfile,v $ +-- $State: Exp $ local d = ROOTDIR.."mach/proto/ncg/" @@ -18,6 +18,8 @@ local cfile_with_tables = cfile { proto_ncg = cprogram { class = "proto_ncg", + exename = "ncg", + CINCLUDES = { PARENT, "mach/%PLATFORM%/ncg", @@ -50,6 +52,6 @@ proto_ncg = cprogram { lib_em_data, lib_flt_arith, - outputs = {"%U%/%PLATFORM%-ncg"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/ncg") + outputs = {"%U%/%PLATFORM%-%exename%"}, + install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/%exename%") } diff --git a/mach/proto/ncg/reg.c b/mach/proto/ncg/reg.c index 50a1b87b5..0ce218982 100644 --- a/mach/proto/ncg/reg.c +++ b/mach/proto/ncg/reg.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/mach/proto/ncg/regvar.c b/mach/proto/ncg/regvar.c index f74996406..dd791d60a 100644 --- a/mach/proto/ncg/regvar.c +++ b/mach/proto/ncg/regvar.c @@ -1,3 +1,5 @@ +#include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/mach/proto/ncg/salloc.c b/mach/proto/ncg/salloc.c index 2bafb3fd0..1826f1793 100644 --- a/mach/proto/ncg/salloc.c +++ b/mach/proto/ncg/salloc.c @@ -3,6 +3,7 @@ static char rcsid[] = "$Id$"; #endif #include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/mach/proto/ncg/state.c b/mach/proto/ncg/state.c index b65748ac7..23d074bc7 100644 --- a/mach/proto/ncg/state.c +++ b/mach/proto/ncg/state.c @@ -2,6 +2,8 @@ static char rcsid[] = "$Id$"; #endif +#include +#include #include "assert.h" #include "param.h" #include "tables.h" diff --git a/plat/linux386/libsys/_exit.c b/plat/linux386/libsys/_exit.c deleted file mode 100644 index 3171a1cce..000000000 --- a/plat/linux386/libsys/_exit.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -void _exit(int status) -{ - _syscall(__NR_exit, status, 0, 0); -} diff --git a/plat/linux386/libsys/_hol0.s b/plat/linux386/libsys/_hol0.s deleted file mode 100644 index 99a29fd4a..000000000 --- a/plat/linux386/libsys/_hol0.s +++ /dev/null @@ -1,20 +0,0 @@ -# -! $Source$ -! $State$ -! $Revision$ - -! Declare segments (the order is important). - -.sect .text -.sect .rom -.sect .data -.sect .bss - -.sect .text - -! -! This data block is used to store information about the current line number -! and file. - -.define hol0 -.comm hol0, 8 diff --git a/plat/linux386/libsys/_syscall.s b/plat/linux386/libsys/_syscall.s index f765ccfbe..4acfd4d14 100644 --- a/plat/linux386/libsys/_syscall.s +++ b/plat/linux386/libsys/_syscall.s @@ -3,8 +3,6 @@ ! $State$ ! $Revision$ -#include "syscalls.h" - ! Declare segments (the order is important). .sect .text diff --git a/plat/linux386/libsys/brk.c b/plat/linux386/libsys/brk.c deleted file mode 100644 index cf6c4d2d1..000000000 --- a/plat/linux386/libsys/brk.c +++ /dev/null @@ -1,13 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include "libsys.h" - -int brk(void* end) -{ - return _syscall(__NR_brk, (quad) end, 0, 0); -} diff --git a/plat/linux386/libsys/close.c b/plat/linux386/libsys/close.c deleted file mode 100644 index 2615333e2..000000000 --- a/plat/linux386/libsys/close.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -int close(int fd) -{ - return _syscall(__NR_close, fd, 0, 0); -} diff --git a/plat/linux386/libsys/creat.c b/plat/linux386/libsys/creat.c deleted file mode 100644 index 984ae6cf5..000000000 --- a/plat/linux386/libsys/creat.c +++ /dev/null @@ -1,13 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include "libsys.h" - -int creat(const char* filename, int mode) -{ - return open(filename, O_CREAT|O_WRONLY|O_TRUNC, mode); -} diff --git a/plat/linux386/libsys/errno.s b/plat/linux386/libsys/errno.s deleted file mode 100644 index 9858d2640..000000000 --- a/plat/linux386/libsys/errno.s +++ /dev/null @@ -1,28 +0,0 @@ -# -! $Source$ -! $State$ -! $Revision$ - -! Declare segments (the order is important). - -.sect .text -.sect .rom -.sect .data -.sect .bss - -#define D(e) .define e; e - -.sect .data - -! Define various ACK error numbers. Note that these are *not* ANSI C -! errnos, and are used for different purposes. - -D(ERANGE) = 1 -D(ESET) = 2 -D(EIDIVZ) = 6 -D(EHEAP) = 17 -D(EILLINS) = 18 -D(EODDZ) = 19 -D(ECASE) = 20 -D(EBADMON) = 25 - diff --git a/plat/linux386/libsys/getpid.c b/plat/linux386/libsys/getpid.c deleted file mode 100644 index ca2803246..000000000 --- a/plat/linux386/libsys/getpid.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -pid_t getpid(void) -{ - return _syscall(__NR_getpid, 0, 0, 0); -} diff --git a/plat/linux386/libsys/gettimeofday.c b/plat/linux386/libsys/gettimeofday.c deleted file mode 100644 index df01df5e7..000000000 --- a/plat/linux386/libsys/gettimeofday.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include -#include -#include "libsys.h" - -int gettimeofday(struct timeval *tv, struct timezone *tz) -{ - return _syscall(__NR_gettimeofday, (quad) tv, (quad) tz, 0); -} diff --git a/plat/linux386/libsys/isatty.c b/plat/linux386/libsys/isatty.c deleted file mode 100644 index 23ffb7fb3..000000000 --- a/plat/linux386/libsys/isatty.c +++ /dev/null @@ -1,13 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include - -int isatty(int fd) -{ - return 0; -} diff --git a/plat/linux386/libsys/kill.c b/plat/linux386/libsys/kill.c deleted file mode 100644 index 6b4cace40..000000000 --- a/plat/linux386/libsys/kill.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -int kill(pid_t pid, int signum) -{ - return _syscall(__NR_kill, pid, signum, 0); -} diff --git a/plat/linux386/libsys/libsys.h b/plat/linux386/libsys/libsys.h deleted file mode 100644 index 58d02d8cc..000000000 --- a/plat/linux386/libsys/libsys.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#ifndef LIBSYS_H -#define LIBSYS_H - -#include "syscalls.h" - -typedef unsigned long quad; - -extern quad _syscall(int op, quad p1, quad p2, quad p3); - -#endif diff --git a/plat/linux386/libsys/lseek.c b/plat/linux386/libsys/lseek.c deleted file mode 100644 index ca903c514..000000000 --- a/plat/linux386/libsys/lseek.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -off_t lseek(int fd, off_t offset, int whence) -{ - return _syscall(__NR_lseek, fd, offset, whence); -} diff --git a/plat/linux386/libsys/open.c b/plat/linux386/libsys/open.c deleted file mode 100644 index 1e8d9890e..000000000 --- a/plat/linux386/libsys/open.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include -#include "libsys.h" - -int open(const char* path, int access, ...) -{ - int mode = 0; - - if (access & O_CREAT) - { - va_list ap; - va_start(ap, access); - mode = va_arg(ap, int); - va_end(ap); - } - - return _syscall(__NR_open, (quad) path, access, mode); -} diff --git a/plat/linux386/libsys/pmfile b/plat/linux386/libsys/pmfile index 45b3e284e..d7d4930c5 100644 --- a/plat/linux386/libsys/pmfile +++ b/plat/linux386/libsys/pmfile @@ -1,33 +1,13 @@ --- $Source$ --- $State$ --- $Revision$ +-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ +-- $State: Exp $ +-- $Revision: 1.1 $ local d = ROOTDIR.."plat/linux386/libsys/" libsys_linux386 = acklibrary { - ACKBUILDFLAGS = {PARENT, "-ansi"}, ACKINCLUDES = {"%BINDIR%include"}, - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), ackfile (d.."_syscall.s"), - ackfile (d.."brk.c"), - ackfile (d.."close.c"), - ackfile (d.."creat.c"), - ackfile (d.."getpid.c"), - ackfile (d.."gettimeofday.c"), - ackfile (d.."_exit.c"), - ackfile (d.."isatty.c"), - ackfile (d.."kill.c"), - ackfile (d.."lseek.c"), - ackfile (d.."open.c"), - ackfile (d.."read.c"), - ackfile (d.."sbrk.c"), - ackfile (d.."signal.c"), - ackfile (d.."write.c"), - ackfile (d.."unlink.c"), - ackfile (d.."remove.c"), - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), } diff --git a/plat/linux386/libsys/read.c b/plat/linux386/libsys/read.c deleted file mode 100644 index 8d67190c9..000000000 --- a/plat/linux386/libsys/read.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -int read(int fd, void* buffer, size_t count) -{ - return _syscall(__NR_read, fd, (quad) buffer, count); -} diff --git a/plat/linux386/libsys/remove.c b/plat/linux386/libsys/remove.c deleted file mode 100644 index d1978d11b..000000000 --- a/plat/linux386/libsys/remove.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include -#include "libsys.h" - -int remove(const char* path) -{ - return unlink(path); -} diff --git a/plat/linux386/libsys/sbrk.c b/plat/linux386/libsys/sbrk.c deleted file mode 100644 index 1b66460a8..000000000 --- a/plat/linux386/libsys/sbrk.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include "libsys.h" - -#define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ - -static char* current = NULL; - -void* sbrk(intptr_t increment) -{ - char* old; - char* new; - char* actual; - - if (!current) - current = (char*) _syscall(__NR_brk, 0, 0, 0); - - if (increment == 0) - return current; - - old = current; - new = old + increment; - - actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0); - if (actual < new) - return OUT_OF_MEMORY; - - current = actual; - return old; -} diff --git a/plat/linux386/libsys/signal.c b/plat/linux386/libsys/signal.c deleted file mode 100644 index 7d3e575fa..000000000 --- a/plat/linux386/libsys/signal.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -sighandler_t signal(int signum, sighandler_t handler) -{ - return (sighandler_t) _syscall(__NR_signal, signum, (quad) handler, 0); -} diff --git a/plat/linux386/libsys/syscalls.h b/plat/linux386/libsys/syscalls.h deleted file mode 100644 index 6b495c169..000000000 --- a/plat/linux386/libsys/syscalls.h +++ /dev/null @@ -1,328 +0,0 @@ -/* $Source$ -* $State$ -* $Revision$ -*/ - -#ifndef SYSCALLS_H -#define SYSCALLS_H - -/* Linux system calls. */ - -#define __NR_restart_syscall 0 -#define __NR_exit 1 -#define __NR_fork 2 -#define __NR_read 3 -#define __NR_write 4 -#define __NR_open 5 -#define __NR_close 6 -#define __NR_waitpid 7 -#define __NR_creat 8 -#define __NR_link 9 -#define __NR_unlink 10 -#define __NR_execve 11 -#define __NR_chdir 12 -#define __NR_time 13 -#define __NR_mknod 14 -#define __NR_chmod 15 -#define __NR_lchown 16 -#define __NR_break 17 -#define __NR_oldstat 18 -#define __NR_lseek 19 -#define __NR_getpid 20 -#define __NR_mount 21 -#define __NR_umount 22 -#define __NR_setuid 23 -#define __NR_getuid 24 -#define __NR_stime 25 -#define __NR_ptrace 26 -#define __NR_alarm 27 -#define __NR_oldfstat 28 -#define __NR_pause 29 -#define __NR_utime 30 -#define __NR_stty 31 -#define __NR_gtty 32 -#define __NR_access 33 -#define __NR_nice 34 -#define __NR_ftime 35 -#define __NR_sync 36 -#define __NR_kill 37 -#define __NR_rename 38 -#define __NR_mkdir 39 -#define __NR_rmdir 40 -#define __NR_dup 41 -#define __NR_pipe 42 -#define __NR_times 43 -#define __NR_prof 44 -#define __NR_brk 45 -#define __NR_setgid 46 -#define __NR_getgid 47 -#define __NR_signal 48 -#define __NR_geteuid 49 -#define __NR_getegid 50 -#define __NR_acct 51 -#define __NR_umount2 52 -#define __NR_lock 53 -#define __NR_ioctl 54 -#define __NR_fcntl 55 -#define __NR_mpx 56 -#define __NR_setpgid 57 -#define __NR_ulimit 58 -#define __NR_oldolduname 59 -#define __NR_umask 60 -#define __NR_chroot 61 -#define __NR_ustat 62 -#define __NR_dup2 63 -#define __NR_getppid 64 -#define __NR_getpgrp 65 -#define __NR_setsid 66 -#define __NR_sigaction 67 -#define __NR_sgetmask 68 -#define __NR_ssetmask 69 -#define __NR_setreuid 70 -#define __NR_setregid 71 -#define __NR_sigsuspend 72 -#define __NR_sigpending 73 -#define __NR_sethostname 74 -#define __NR_setrlimit 75 -#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ -#define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 -#define __NR_getgroups 80 -#define __NR_setgroups 81 -#define __NR_select 82 -#define __NR_symlink 83 -#define __NR_oldlstat 84 -#define __NR_readlink 85 -#define __NR_uselib 86 -#define __NR_swapon 87 -#define __NR_reboot 88 -#define __NR_readdir 89 -#define __NR_mmap 90 -#define __NR_munmap 91 -#define __NR_truncate 92 -#define __NR_ftruncate 93 -#define __NR_fchmod 94 -#define __NR_fchown 95 -#define __NR_getpriority 96 -#define __NR_setpriority 97 -#define __NR_profil 98 -#define __NR_statfs 99 -#define __NR_fstatfs 100 -#define __NR_ioperm 101 -#define __NR_socketcall 102 -#define __NR_syslog 103 -#define __NR_setitimer 104 -#define __NR_getitimer 105 -#define __NR_stat 106 -#define __NR_lstat 107 -#define __NR_fstat 108 -#define __NR_olduname 109 -#define __NR_iopl 110 -#define __NR_vhangup 111 -#define __NR_idle 112 -#define __NR_vm86old 113 -#define __NR_wait4 114 -#define __NR_swapoff 115 -#define __NR_sysinfo 116 -#define __NR_ipc 117 -#define __NR_fsync 118 -#define __NR_sigreturn 119 -#define __NR_clone 120 -#define __NR_setdomainname 121 -#define __NR_uname 122 -#define __NR_modify_ldt 123 -#define __NR_adjtimex 124 -#define __NR_mprotect 125 -#define __NR_sigprocmask 126 -#define __NR_create_module 127 -#define __NR_init_module 128 -#define __NR_delete_module 129 -#define __NR_get_kernel_syms 130 -#define __NR_quotactl 131 -#define __NR_getpgid 132 -#define __NR_fchdir 133 -#define __NR_bdflush 134 -#define __NR_sysfs 135 -#define __NR_personality 136 -#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ -#define __NR_setfsuid 138 -#define __NR_setfsgid 139 -#define __NR__llseek 140 -#define __NR_getdents 141 -#define __NR__newselect 142 -#define __NR_flock 143 -#define __NR_msync 144 -#define __NR_readv 145 -#define __NR_writev 146 -#define __NR_getsid 147 -#define __NR_fdatasync 148 -#define __NR__sysctl 149 -#define __NR_mlock 150 -#define __NR_munlock 151 -#define __NR_mlockall 152 -#define __NR_munlockall 153 -#define __NR_sched_setparam 154 -#define __NR_sched_getparam 155 -#define __NR_sched_setscheduler 156 -#define __NR_sched_getscheduler 157 -#define __NR_sched_yield 158 -#define __NR_sched_get_priority_max 159 -#define __NR_sched_get_priority_min 160 -#define __NR_sched_rr_get_interval 161 -#define __NR_nanosleep 162 -#define __NR_mremap 163 -#define __NR_setresuid 164 -#define __NR_getresuid 165 -#define __NR_vm86 166 -#define __NR_query_module 167 -#define __NR_poll 168 -#define __NR_nfsservctl 169 -#define __NR_setresgid 170 -#define __NR_getresgid 171 -#define __NR_prctl 172 -#define __NR_rt_sigreturn 173 -#define __NR_rt_sigaction 174 -#define __NR_rt_sigprocmask 175 -#define __NR_rt_sigpending 176 -#define __NR_rt_sigtimedwait 177 -#define __NR_rt_sigqueueinfo 178 -#define __NR_rt_sigsuspend 179 -#define __NR_pread64 180 -#define __NR_pwrite64 181 -#define __NR_chown 182 -#define __NR_getcwd 183 -#define __NR_capget 184 -#define __NR_capset 185 -#define __NR_sigaltstack 186 -#define __NR_sendfile 187 -#define __NR_getpmsg 188/* some people actually want streams */ -#define __NR_putpmsg 189/* some people actually want streams */ -#define __NR_vfork 190 -#define __NR_ugetrlimit 191/* SuS compliant getrlimit */ -#define __NR_mmap2 192 -#define __NR_truncate64 193 -#define __NR_ftruncate64 194 -#define __NR_stat64 195 -#define __NR_lstat64 196 -#define __NR_fstat64 197 -#define __NR_lchown32 198 -#define __NR_getuid32 199 -#define __NR_getgid32 200 -#define __NR_geteuid32 201 -#define __NR_getegid32 202 -#define __NR_setreuid32 203 -#define __NR_setregid32 204 -#define __NR_getgroups32 205 -#define __NR_setgroups32 206 -#define __NR_fchown32 207 -#define __NR_setresuid32 208 -#define __NR_getresuid32 209 -#define __NR_setresgid32 210 -#define __NR_getresgid32 211 -#define __NR_chown32 212 -#define __NR_setuid32 213 -#define __NR_setgid32 214 -#define __NR_setfsuid32 215 -#define __NR_setfsgid32 216 -#define __NR_pivot_root 217 -#define __NR_mincore 218 -#define __NR_madvise 219 -#define __NR_getdents64 220 -#define __NR_fcntl64 221 -#define __NR_gettid 224 -#define __NR_readahead 225 -#define __NR_setxattr 226 -#define __NR_lsetxattr 227 -#define __NR_fsetxattr 228 -#define __NR_getxattr 229 -#define __NR_lgetxattr 230 -#define __NR_fgetxattr 231 -#define __NR_listxattr 232 -#define __NR_llistxattr 233 -#define __NR_flistxattr 234 -#define __NR_removexattr 235 -#define __NR_lremovexattr 236 -#define __NR_fremovexattr 237 -#define __NR_tkill 238 -#define __NR_sendfile64 239 -#define __NR_futex 240 -#define __NR_sched_setaffinity 241 -#define __NR_sched_getaffinity 242 -#define __NR_set_thread_area 243 -#define __NR_get_thread_area 244 -#define __NR_io_setup 245 -#define __NR_io_destroy 246 -#define __NR_io_getevents 247 -#define __NR_io_submit 248 -#define __NR_io_cancel 249 -#define __NR_fadvise64 250 -#define __NR_exit_group 252 -#define __NR_lookup_dcookie 253 -#define __NR_epoll_create 254 -#define __NR_epoll_ctl 255 -#define __NR_epoll_wait 256 -#define __NR_remap_file_pages 257 -#define __NR_set_tid_address 258 -#define __NR_timer_create 259 -#define __NR_timer_settime (__NR_timer_create+1) -#define __NR_timer_gettime (__NR_timer_create+2) -#define __NR_timer_getoverrun (__NR_timer_create+3) -#define __NR_timer_delete (__NR_timer_create+4) -#define __NR_clock_settime (__NR_timer_create+5) -#define __NR_clock_gettime (__NR_timer_create+6) -#define __NR_clock_getres (__NR_timer_create+7) -#define __NR_clock_nanosleep (__NR_timer_create+8) -#define __NR_statfs64 268 -#define __NR_fstatfs64 269 -#define __NR_tgkill 270 -#define __NR_utimes 271 -#define __NR_fadvise64_64 272 -#define __NR_vserver 273 -#define __NR_mbind 274 -#define __NR_get_mempolicy 275 -#define __NR_set_mempolicy 276 -#define __NR_mq_open 277 -#define __NR_mq_unlink (__NR_mq_open+1) -#define __NR_mq_timedsend (__NR_mq_open+2) -#define __NR_mq_timedreceive (__NR_mq_open+3) -#define __NR_mq_notify (__NR_mq_open+4) -#define __NR_mq_getsetattr (__NR_mq_open+5) -#define __NR_kexec_load 283 -#define __NR_waitid 284 -#define __NR_add_key 286 -#define __NR_request_key 287 -#define __NR_keyctl 288 -#define __NR_ioprio_set 289 -#define __NR_ioprio_get 290 -#define __NR_inotify_init 291 -#define __NR_inotify_add_watch 292 -#define __NR_inotify_rm_watch 293 -#define __NR_migrate_pages 294 -#define __NR_openat 295 -#define __NR_mkdirat 296 -#define __NR_mknodat 297 -#define __NR_fchownat 298 -#define __NR_futimesat 299 -#define __NR_fstatat64 300 -#define __NR_unlinkat 301 -#define __NR_renameat 302 -#define __NR_linkat 303 -#define __NR_symlinkat 304 -#define __NR_readlinkat 305 -#define __NR_fchmodat 306 -#define __NR_faccessat 307 -#define __NR_pselect6 308 -#define __NR_ppoll 309 -#define __NR_unshare 310 -#define __NR_set_robust_list 311 -#define __NR_get_robust_list 312 -#define __NR_splice 313 -#define __NR_sync_file_range 314 -#define __NR_tee 315 -#define __NR_vmsplice 316 - -#define concat(x, y) x##y -#define MAPPED_SYSCALL(p, n) .define concat(p,n); concat(p,n): xor eax, eax; movb al, concat(__NR_,n); jmp __mapped_syscall - -#endif diff --git a/plat/linux386/libsys/unlink.c b/plat/linux386/libsys/unlink.c deleted file mode 100644 index 67c4dc11c..000000000 --- a/plat/linux386/libsys/unlink.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include -#include "libsys.h" - -int unlink(const char* path) -{ - return _syscall(__NR_unlink, (quad) path, 0, 0); -} diff --git a/plat/linux386/libsys/write.c b/plat/linux386/libsys/write.c deleted file mode 100644 index a4543c8d8..000000000 --- a/plat/linux386/libsys/write.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $Source$ - * $State$ - * $Revision$ - */ - -#include -#include -#include -#include "libsys.h" - -int write(int fd, void* buffer, size_t count) -{ - return _syscall(__NR_write, fd, (quad) buffer, count); -} diff --git a/plat/linuxppc/.distr b/plat/linuxppc/.distr new file mode 100644 index 000000000..da4420e2f --- /dev/null +++ b/plat/linuxppc/.distr @@ -0,0 +1,26 @@ +descr +boot.s +pmfile +README +include/ack/config.h +include/unistd.h +libsys/pmfile +libsys/_exit.c +libsys/_hol0.s +libsys/_syscall.s +libsys/brk.c +libsys/close.c +libsys/creat.c +libsys/errno.s +libsys/getpid.c +libsys/gettimeofday.c +libsys/isatty.c +libsys/kill.c +libsys/libsys.h +libsys/lseek.c +libsys/open.c +libsys/read.c +libsys/sbrk.c +libsys/signal.c +libsys/syscalls.h +libsys/write.c diff --git a/plat/linuxppc/README b/plat/linuxppc/README new file mode 100644 index 000000000..412e33ad1 --- /dev/null +++ b/plat/linuxppc/README @@ -0,0 +1,42 @@ +# $Source: /cvsroot/tack/Ack/plat/linux386/README,v $ +# $State: Exp $ +# $Revision: 1.2 $ + + +The linux386 platform +===================== + +linux386 is an i386-based BSP that produces Linux ELF executables. + +This port only implements a very limited number of system calls; basically, +just enough to make the demo apps run. Adding more is easy, but there are some +subtleties that require more thought. The port should be considered only in +proof-of-concept stage right now. + +Important note: you *can't* link access ELF shared libraries from these +executables. In other words, you have to all your work from inside ACK. + +IEEE floating point is available, but requires an FPU. + +The executables are generated with aelfslod and are extremely simple; there's +one rwx ELF section which contains all the application's code and data. This +is not optimal, but it does work. + + +Bugs +==== + +isatty() is a stub and always returns 0. + + +Example command line +==================== + +ack -mlinux386 -O -o linux386.exe examples/paranoia.c + +The file linux386.exe can then be run on a i386 Linux machine (or on an +emulation thereof). + + +David Given +dg@cowlark.com diff --git a/plat/linuxppc/boot.s b/plat/linuxppc/boot.s new file mode 100644 index 000000000..66cb38306 --- /dev/null +++ b/plat/linuxppc/boot.s @@ -0,0 +1,56 @@ +# +! $Source: /cvsroot/tack/Ack/plat/linux386/boot.s,v $ +! $State: Exp $ +! $Revision: 1.3 $ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +begtext: + ! This code is placed at the beginning of the ELF executable and is the + ! first thing that runs. + ! + ! On entry, the stack looks like this: + ! + ! sp+... NULL + ! sp+8+(4*argc) env (X quads) + ! sp+4+(4*argc) NULL + ! sp+4 argv (argc quads) + ! sp argc + ! + ! The ACK actually expects: + ! + ! sp+8 argc + ! sp+4 ptr to argv + ! sp ptr to env + + lwz r3, 0(sp) ! r3 = argc + addi r4, sp, 4 ! r4 = argv + rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits + add r5, r5, r4 + addi r5, r5, 8 ! r5 = env + + stwu r5, -4(sp) + stwu r4, -4(sp) + stwu r3, -4(sp) + + b __m_a_i_n + +! Some magic data. All EM systems need these. + +.define _errno +.comm _errno, 4 ! Posix errno storage + +.define .trppc, .ignmask +.comm .trppc, 4 ! ptr to user trap handler +.comm .ignmask, 4 ! user trap ignore mask + +.define .linenumber, .filename +.comm .linenumber, 4 ! current linenumber (used for debugging) +.comm .filename, 4 ! ptr to current filename (used for debugging) diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr new file mode 100644 index 000000000..64f838e61 --- /dev/null +++ b/plat/linuxppc/descr @@ -0,0 +1,81 @@ +# $Source: /cvsroot/tack/Ack/plat/linux386/descr,v $ +# $State: Exp $ +# $Revision: 1.1 $ + +var w=4 +var p=4 +var s=2 +var l=4 +var f=4 +var d=8 +var ARCH=powerpc +var PLATFORM=linuxppc +var PLATFORMDIR={EM}/lib/{PLATFORM} +var CPP_F=-D__unix -D__POWERPC +var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x80000054 +var C_LIB={PLATFORMDIR}/libc-ansi.a +# bitfields reversed for compatibility with (g)cc. +var CC_ALIGN=-Vr +var OLD_C_LIB={C_LIB} +var MACHOPT_F= + +# Override the setting in fe so that files compiled for linuxppc can see +# the platform-specific headers. + +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi + +name be + from .m.g + to .s + program {EM}/lib.bin/{PLATFORM}/ncg + mapflag -gdb GF=-gdb + args {GF?} < + stdout + need .e +end +name asopt + from .s + to .so + program {EM}/lib.bin/{PLATFORM}/top + args + optimizer + stdin + stdout +end +name as + from .s.so + to .o + program {EM}/lib.bin/{PLATFORM}/as + args - -o > < + prep cond +end +name led + from .o.a + to .out + program {EM}/lib.bin/em_led + mapflag -l* LNAME={PLATFORMDIR}/lib* + mapflag -fp FLOATS={EM}/{LIB}fp + args {ALIGN} {SEPID?} \ + {PLATFORMDIR}/boot.o \ + ({RTS}:.ocm.b.c={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.mod={PLATFORMDIR}/modula2.o) \ + ({RTS}:.p={PLATFORMDIR}/pascal.o) \ + -o > < \ + (.p:{TAIL}={PLATFORMDIR}/libpascal.a) \ + (.b:{TAIL}={PLATFORMDIR}/libbasic.a) \ + (.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \ + (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ + (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ + {PLATFORMDIR}/liblinux.a \ + {PLATFORMDIR}/libem.a \ + {PLATFORMDIR}/libsys.a \ + {PLATFORMDIR}/libend.a + linker +end +name cv + from .out + to .exe + program {EM}/bin/aelflod + args 20 1 < > + outfile linuxppc.exe +end diff --git a/plat/linuxppc/include/ack/config.h b/plat/linuxppc/include/ack/config.h new file mode 100644 index 000000000..7c3c147b3 --- /dev/null +++ b/plat/linuxppc/include/ack/config.h @@ -0,0 +1,18 @@ +/* $Source: /cvsroot/tack/Ack/plat/linux386/include/ack/config.h,v $ + * $State: Exp $ + * $Revision: 1.1 $ + */ + +#ifndef _ACK_CONFIG_H +#define _ACK_CONFIG_H + +/* We're providing a time() system call rather than wanting a wrapper around + * gettimeofday() in the libc. */ + +/* #define ACKCONF_TIME_IS_A_SYSCALL */ + +/* We don't support floating point right now. */ + +/* #define ACKCONF_NO_STDIO_FLOAT */ + +#endif diff --git a/plat/linuxppc/include/sys/ioctl.h b/plat/linuxppc/include/sys/ioctl.h new file mode 100644 index 000000000..af41165d7 --- /dev/null +++ b/plat/linuxppc/include/sys/ioctl.h @@ -0,0 +1,76 @@ +/* $Source: /cvsroot/tack/Ack/plat/linux386/include/sys/ioctl.h,v $ + * $State: Exp $ + * $Revision: 1.1 $ + */ + +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H + +/* These are copied from the ioctl_list(2) man page. */ + +/* */ + +#define FIOSETOWN 0x00008901 +#define SIOCSPGRP 0x00008902 +#define FIOGETOWN 0x00008903 +#define SIOCGPGRP 0x00008904 +#define SIOCATMARK 0x00008905 +#define SIOCGSTAMP 0x00008906 + +/* */ + +#define TCGETS 0x00005401 +#define TCSETS 0x00005402 +#define TCSETSW 0x00005403 +#define TCSETSF 0x00005404 +#define TCGETA 0x00005405 +#define TCSETA 0x00005406 +#define TCSETAW 0x00005407 +#define TCSETAF 0x00005408 +#define TCSBRK 0x00005409 +#define TCXONC 0x0000540A +#define TCFLSH 0x0000540B +#define TIOCEXCL 0x0000540C +#define TIOCNXCL 0x0000540D +#define TIOCSCTTY 0x0000540E +#define TIOCGPGRP 0x0000540F +#define TIOCSPGRP 0x00005410 +#define TIOCOUTQ 0x00005411 +#define TIOCSTI 0x00005412 +#define TIOCGWINSZ 0x00005413 +#define TIOCSWINSZ 0x00005414 +#define TIOCMGET 0x00005415 +#define TIOCMBIS 0x00005416 +#define TIOCMBIC 0x00005417 +#define TIOCMSET 0x00005418 +#define TIOCGSOFTCAR 0x00005419 +#define TIOCSSOFTCAR 0x0000541A +#define FIONREAD 0x0000541B +#define TIOCINQ 0x0000541B +#define TIOCLINUX 0x0000541C +#define TIOCCONS 0x0000541D +#define TIOCGSERIAL 0x0000541E +#define TIOCSSERIAL 0x0000541F +#define TIOCPKT 0x00005420 +#define FIONBIO 0x00005421 +#define TIOCNOTTY 0x00005422 +#define TIOCSETD 0x00005423 +#define TIOCGETD 0x00005424 +#define TCSBRKP 0x00005425 +#define TIOCTTYGSTRUCT 0x00005426 +#define FIONCLEX 0x00005450 +#define FIOCLEX 0x00005451 +#define FIOASYNC 0x00005452 +#define TIOCSERCONFIG 0x00005453 +#define TIOCSERGWILD 0x00005454 +#define TIOCSERSWILD 0x00005455 +#define TIOCGLCKTRMIOS 0x00005456 +#define TIOCSLCKTRMIOS 0x00005457 +#define TIOCSERGSTRUCT 0x00005458 +#define TIOCSERGETLSR 0x00005459 +#define TIOCSERGETMULTI 0x0000545A +#define TIOCSERSETMULTI 0x0000545B + + + +#endif diff --git a/plat/linuxppc/include/unistd.h b/plat/linuxppc/include/unistd.h new file mode 100644 index 000000000..5cbdc1b5d --- /dev/null +++ b/plat/linuxppc/include/unistd.h @@ -0,0 +1,123 @@ +/* + * unistd.h - standard system calls + */ +/* $Id$ */ + +#ifndef _UNISTD_H +#define _UNISTD_H + +#include +#include + +/* Types */ + +typedef int pid_t; +typedef int mode_t; + +typedef long suseconds_t; + +/* Time handling. */ + +struct timeval +{ + time_t tv_sec; + suseconds_t tv_usec; +}; + +struct timezone +{ + int tz_minuteswest; + int tz_dsttime; +}; /* obsolete, unused */ + +extern int gettimeofday(struct timeval* tv, struct timezone* tz); +extern int settimeofday(const struct timeval* tv, const struct timezone* tz); + +/* File access. */ + +enum +{ + O_ACCMODE = 0x3, + + O_RDONLY = 0, + O_WRONLY = 1, + O_RDWR = 2, + + O_CREAT = 0x10, + O_TRUNC = 0x20, + O_APPEND = 0x40 +}; + +extern int open(const char* path, int access, ...); +extern int creat(const char* path, mode_t mode); +extern int close(int d); +extern int read(int fd, void* buffer, size_t count); +extern int write(int fd, void* buffer, size_t count); +extern off_t lseek(int fildes, off_t offset, int whence); +extern int fcntl(int fd, int op, ...); + +/* Special variables */ + +extern char** environ; + +/* Implemented system calls */ + +extern void _exit(int); +extern pid_t getpid(void); +extern int brk(void* ptr); +extern void* sbrk(intptr_t increment); +extern int isatty(int d); + +/* Signal handling */ + +typedef int sig_atomic_t; + +#define SIG_ERR ((sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */ + +#define SIGHUP 1 /* Hangup (POSIX). */ +#define SIGINT 2 /* Interrupt (ANSI). */ +#define SIGQUIT 3 /* Quit (POSIX). */ +#define SIGILL 4 /* Illegal instruction (ANSI). */ +#define SIGTRAP 5 /* Trace trap (POSIX). */ +#define SIGABRT 6 /* Abort (ANSI). */ +#define SIGIOT 6 /* IOT trap (4.2 BSD). */ +#define SIGBUS 7 /* BUS error (4.2 BSD). */ +#define SIGFPE 8 /* Floating-point exception (ANSI). */ +#define SIGKILL 9 /* Kill, unblockable (POSIX). */ +#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */ +#define SIGSEGV 11 /* Segmentation violation (ANSI). */ +#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */ +#define SIGPIPE 13 /* Broken pipe (POSIX). */ +#define SIGALRM 14 /* Alarm clock (POSIX). */ +#define SIGTERM 15 /* Termination (ANSI). */ +#define SIGSTKFLT 16 /* Stack fault. */ +#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ +#define SIGCHLD 17 /* Child status has changed (POSIX). */ +#define SIGCONT 18 /* Continue (POSIX). */ +#define SIGSTOP 19 /* Stop, unblockable (POSIX). */ +#define SIGTSTP 20 /* Keyboard stop (POSIX). */ +#define SIGTTIN 21 /* Background read from tty (POSIX). */ +#define SIGTTOU 22 /* Background write to tty (POSIX). */ +#define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */ +#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ +#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ +#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ +#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ +#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ +#define SIGPOLL SIGIO /* Pollable event occurred (System V). */ +#define SIGIO 29 /* I/O now possible (4.2 BSD). */ +#define SIGPWR 30 /* Power failure restart (System V). */ +#define SIGSYS 31 /* Bad system call. */ +#define SIGUNUSED 31 + +#define _NSIG 32 /* Biggest signal number + 1 + (not including real-time signals). */ +typedef void (*sighandler_t)(int); +extern sighandler_t signal(int signum, sighandler_t handler); +extern int raise(int signum); + + + +#endif diff --git a/plat/linuxppc/libsys/_syscall.s b/plat/linuxppc/libsys/_syscall.s new file mode 100644 index 000000000..122a3a5f5 --- /dev/null +++ b/plat/linuxppc/libsys/_syscall.s @@ -0,0 +1,53 @@ +# +! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $ +! $State: Exp $ +! $Revision: 1.1 $ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +EINVAL = 22 + +#define IFFALSE 4 +#define IFTRUE 12 +#define ALWAYS 20 + +#define LT 0 +#define GT 1 +#define EQ 2 +#define OV 3 + +! Perform a Linux system call. + +.define __syscall +__syscall: + lwz r0, 0(sp) + lwz r3, 4(sp) + lwz r4, 8(sp) + lwz r5, 12(sp) + sc 0 + bclr IFFALSE, OV, 0 + + ! On error, r3 contains the errno. + ! It just so happens that errnos 1-34 are the same in Linux as in ACK. + cmpi cr0, 0, r3, 1 + bc IFTRUE, LT, 2f + cmpi cr0, 0, r3, 34 + bc IFTRUE, GT, 2f + +3: + addis r4, r0, <_errno + ori r4, r4, >_errno + stw r3, 0(r4) + addi r3, r0, -1 + bclr ALWAYS, 0, 0 + +2: + addi r3, r0, EINVAL + b 3b diff --git a/plat/linuxppc/libsys/pmfile b/plat/linuxppc/libsys/pmfile new file mode 100644 index 000000000..0b3839aae --- /dev/null +++ b/plat/linuxppc/libsys/pmfile @@ -0,0 +1,14 @@ +-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ +-- $State: Exp $ +-- $Revision: 1.1 $ + +local d = ROOTDIR.."plat/linuxppc/libsys/" + +libsys_linuxppc = acklibrary { + ACKINCLUDES = {"%BINDIR%include"}, + + ackfile (d.."_syscall.s"), + ackfile (d.."trap.s"), + + install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), +} diff --git a/plat/linuxppc/libsys/trap.s b/plat/linuxppc/libsys/trap.s new file mode 100644 index 000000000..92ec4bd53 --- /dev/null +++ b/plat/linuxppc/libsys/trap.s @@ -0,0 +1,108 @@ +# +! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $ +! $State: Exp $ +! $Revision: 1.1 $ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +#define IFFALSE 4 +#define IFTRUE 12 +#define ALWAYS 20 + +#define LT 0 +#define GT 1 +#define EQ 2 +#define OV 3 + +EARRAY = 0 +ERANGE = 1 +ESET = 2 +EIOVFL = 3 +EFOVFL = 4 +EFUNFL = 5 +EIDIVZ = 6 +EFDIVZ = 7 +EIUND = 8 +EFUND = 9 +ECONV = 10 +ESTACK = 16 +EHEAP = 17 +EILLINS = 18 +EODDZ = 19 +ECASE = 20 +EMEMFLT = 21 +EBADPTR = 22 +EBADPC = 23 +EBADLAE = 24 +EBADMON = 25 +EBADLIN = 26 +EBADGTO = 27 +EUNIMPL = 63 ! unimplemented em-instruction called + +! EM trap handling. + +.define .trap_ecase +.trap_ecase: + addi r3, r0, ECASE + b .trap + +.define .trap_earray +.trap_earray: + addi r3, r0, EARRAY + b .trap + +.define .trap +.trap: + cmpi cr0, 0, r3, 15 ! traps >15 can't be ignored + bc IFTRUE, LT, 1f + + addi r4, r0, 1 + rlwnm r4, r4, r3, 0, 31 ! calculate trap bit + addis r5, r0, <.ignmask + ori r5, r5, >.ignmask + lwz r5, 0(r5) ! load ignore mask + and. r4, r4, r5 ! compare + bclr IFFALSE, EQ, 0 ! return if non-zero + +1: + addis r4, r0, <.trppc + ori r4, r4, >.trppc + lwz r5, 0(r4) ! load user trap routine + or. r5, r5, r5 ! test + bc IFTRUE, EQ, fatal ! if no user trap routine, bail out + + addi r0, r0, 0 + stw r0, 0(r4) ! reset trap routine + + mfspr r0, lr + stwu r0, -4(sp) ! save old lr + + stwu r3, -4(sp) + mtspr ctr, r5 + bcctrl ALWAYS, 0, 0 ! call trap routine + + lwz r0, 4(sp) ! load old lr again + addi sp, sp, 8 ! retract over stack usage + bclr ALWAYS, 0, 0 ! return + +fatal: + addi r3, r0, 1 + addis r4, r0, message + addi r5, r0, 6 + addi r0, r0, 4 ! write() + sc 0 + + addi r0, r0, 1 ! exit() + sc 0 + +.sect .rom +message: + .ascii "TRAP!\n" diff --git a/plat/linuxppc/pmfile b/plat/linuxppc/pmfile new file mode 100644 index 000000000..34acd7002 --- /dev/null +++ b/plat/linuxppc/pmfile @@ -0,0 +1,48 @@ +-- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $ +-- $State: Exp $ +-- $Revision: 1.3 $ + +local d = ROOTDIR.."plat/linuxppc/" + +include (d.."libsys/pmfile") +include "plat/linux/liblinux/pmfile" + +local bootsector = ackfile { + file (d.."boot.s"), + install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"), +} + +local descr = group { + install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") +} + +local headers = group { + install = { + pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), + pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), + } +} + +platform_linuxppc = group { + ARCH = "powerpc", + PLATFORM = "linuxppc", + OPTIMISATION = "-O", + + -- Ensure the descr and headers are installed first because we'll need it + -- to build the libraries. + + descr, + headers, + + -- Build the back-end support. + + mach_powerpc, + support_powerpc, + lang_runtimes, + + -- Build the PC standalone syscall library. + + liblinux, + libsys_linuxppc, + bootsector, +} diff --git a/pmfile b/pmfile index c7a806f08..14b518a53 100644 --- a/pmfile +++ b/pmfile @@ -95,6 +95,12 @@ include "plat/pc86/pmfile" -- PC standalone include "mach/i386/pmfile" -- generic i386 include "plat/linux386/pmfile" -- Linux executables +include "mach/powerpc/pmfile" -- generic PowerPC +include "plat/linuxppc/pmfile" -- Linux executables + +include "mach/m68020/pmfile" -- generic M68k +include "plat/linux68k/pmfile" -- Linux executables + include "mach/i80/pmfile" -- generic 8080 include "plat/cpm/pmfile" -- CP/M @@ -180,7 +186,9 @@ default = group { platform_pc86, platform_linux386, - platform_cpm + platform_linuxppc, + platform_linux68k, + platform_cpm, } -- Ensure that the work directories exist. diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index 13809c405..5f22827ee 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -112,10 +112,10 @@ showsect() struct outsect section; rd_sect(§ion, 1); - printf("\tstartaddress in machine\t%ld\n", section.os_base); - printf("\tsection size in machine\t%ld\n", section.os_size); - printf("\tstartaddress in file\t%ld\n", section.os_foff); - printf("\tsection size in file\t%ld\n", section.os_flen); + printf("\tstartaddress in machine\t0x%lX\n", section.os_base); + printf("\tsection size in machine\t0x%lX\n", section.os_size); + printf("\tstartaddress in file\t0x%lX\n", section.os_foff); + printf("\tsection size in file\t0x%lX\n", section.os_flen); printf("\tsection alignment\t%ld\n", section.os_lign); } @@ -137,8 +137,14 @@ showrelo() case RELO4: printf("\t4 bytes\n"); break; + case RELOPPC: + printf("\tPowerPC 26-bit address\n"); + break; + case RELOH2: + printf("\ttop 2 bytes of a 4 byte word\n"); + break; default: - error("\tunexpected relocation length\n"); + printf("\tunknown relocation type %d\n", relrec.or_type & RELSZ); break; } if (relrec.or_type & RELPC) printf("\tpc relative\n"); @@ -194,7 +200,7 @@ showname(namep) printf("\tstab 0x%x\n", namep->on_type >> 8); printf("\tdesc 0x%x\n", namep->on_desc); } - printf("\tvalue %ld\n", namep->on_valu); + printf("\tvalue 0x%lX\n", namep->on_valu); } /* diff --git a/util/led/ack.out.5 b/util/led/ack.out.5 index 4f1904dd3..8e85b3f92 100644 --- a/util/led/ack.out.5 +++ b/util/led/ack.out.5 @@ -161,7 +161,9 @@ struct outrelo { #define RELSZ 0x07 /* relocation length */ #define RELO1 0x01 /* 1 byte */ #define RELO2 0x02 /* 2 bytes */ -#define RELO4 0x04 /* 4 bytes */ +#define RELO4 0x03 /* 4 bytes */ +#define RELOPPC 0x04 /* 26-bit PowerPC address */ +#define RELOH2 0x05 /* write top 2 bytes of 4 byte word */ #define RELPC 0x08 /* pc relative */ #define RELBR 0x10 /* High order byte lowest address. */ #define RELWR 0x20 /* High order word lowest address. */ diff --git a/util/led/pmfile b/util/led/pmfile index 1704c077a..37aeba090 100644 --- a/util/led/pmfile +++ b/util/led/pmfile @@ -31,8 +31,8 @@ tool_led = cprogram { } -- Revision history --- $Log$ --- Revision 1.2 2006-07-22 20:52:44 dtrg +-- $Log: pmfile,v $ +-- Revision 1.2 2006/07/22 20:52:44 dtrg -- led now gets installed into the right place. -- -- Revision 1.1 2006/07/22 20:04:41 dtrg diff --git a/util/led/relocate.c b/util/led/relocate.c index 9c369560e..93b1e9c05 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -16,6 +16,33 @@ static char rcsid[] = "$Id$"; #define UBYTE(x) ((x) & BYTEMASK) +static long read2(char* addr, int type) +{ + unsigned short word0, word1; + + if (type & RELBR) + return (UBYTE(addr[0]) << WIDTH) + UBYTE(addr[1]); + else + return (UBYTE(addr[1]) << WIDTH) + UBYTE(addr[0]); +} + +static long read4(char* addr, int type) +{ + unsigned short word0, word1; + + if (type & RELBR) { + word0 = (UBYTE(addr[0]) << WIDTH) + UBYTE(addr[1]); + word1 = (UBYTE(addr[2]) << WIDTH) + UBYTE(addr[3]); + } else { + word0 = (UBYTE(addr[1]) << WIDTH) + UBYTE(addr[0]); + word1 = (UBYTE(addr[3]) << WIDTH) + UBYTE(addr[2]); + } + if (type & RELWR) + return ((long)word0 << (2 * WIDTH)) + word1; + else + return ((long)word1 << (2 * WIDTH)) + word0; +} + /* * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. @@ -25,34 +52,60 @@ getvalu(addr, type) char addr[]; char type; { - unsigned short word0, word1; - switch (type & RELSZ) { case RELO1: return UBYTE(addr[0]); case RELO2: - if (type & RELBR) - return (UBYTE(addr[0]) << WIDTH) + UBYTE(addr[1]); - else - return (UBYTE(addr[1]) << WIDTH) + UBYTE(addr[0]); + return read2(addr, type); case RELO4: - if (type & RELBR) { - word0 = (UBYTE(addr[0]) << WIDTH) + UBYTE(addr[1]); - word1 = (UBYTE(addr[2]) << WIDTH) + UBYTE(addr[3]); - } else { - word0 = (UBYTE(addr[1]) << WIDTH) + UBYTE(addr[0]); - word1 = (UBYTE(addr[3]) << WIDTH) + UBYTE(addr[2]); - } - if (type & RELWR) - return ((long)word0 << (2 * WIDTH)) + word1; - else - return ((long)word1 << (2 * WIDTH)) + word0; + return read4(addr, type); + case RELOPPC: + return read4(addr, type) & 0x03FFFFFD; + case RELOH2: + return read2(addr, type) << 16; default: fatal("bad relocation size"); } /* NOTREACHED */ } +static void write2(long valu, char* addr, int type) +{ + unsigned short word0, word1; + + if (type & RELBR) { + addr[0] = valu >> WIDTH; + addr[1] = valu; + } else { + addr[0] = valu; + addr[1] = valu >> WIDTH; + } +} + +static void write4(long valu, char* addr, int type) +{ + unsigned short word0, word1; + + if (type & RELWR) { + word0 = valu >> (2 * WIDTH); + word1 = valu; + } else { + word0 = valu; + word1 = valu >> (2 * WIDTH); + } + if (type & RELBR) { + addr[0] = word0 >> WIDTH; + addr[1] = word0; + addr[2] = word1 >> WIDTH; + addr[3] = word1; + } else { + addr[0] = word0; + addr[1] = word0 >> WIDTH; + addr[2] = word1; + addr[3] = word1 >> WIDTH; + } +} + /* * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. @@ -64,40 +117,26 @@ putvalu(valu, addr, type) char addr[]; char type; { - unsigned short word0, word1; switch (type & RELSZ) { case RELO1: addr[0] = valu; break; case RELO2: - if (type & RELBR) { - addr[0] = valu >> WIDTH; - addr[1] = valu; - } else { - addr[0] = valu; - addr[1] = valu >> WIDTH; - } + write2(valu, addr, type); break; case RELO4: - if (type & RELWR) { - word0 = valu >> (2 * WIDTH); - word1 = valu; - } else { - word0 = valu; - word1 = valu >> (2 * WIDTH); - } - if (type & RELBR) { - addr[0] = word0 >> WIDTH; - addr[1] = word0; - addr[2] = word1 >> WIDTH; - addr[3] = word1; - } else { - addr[0] = word0; - addr[1] = word0 >> WIDTH; - addr[2] = word1; - addr[3] = word1 >> WIDTH; - } + write4(valu, addr, type); + break; + case RELOPPC: + { + long i = read4(addr, type) & ~0x03FFFFFD; + i |= valu & 0x03FFFFFD; + write4(i, addr, type); + break; + } + case RELOH2: + write2(valu>>16, addr, type); break; default: fatal("bad relocation size"); @@ -182,6 +221,7 @@ relocate(head, emit, names, relo, off) * Pick up previous value at location to be relocated. */ valu = getvalu(emit + (relo->or_addr - off), relo->or_type); + /* * Or_nami is an index in the name table of the considered module. * The name of which it is an index can be: diff --git a/util/ncgg/cgg.y b/util/ncgg/cgg.y index 15059f871..f46d2d724 100644 --- a/util/ncgg/cgg.y +++ b/util/ncgg/cgg.y @@ -38,7 +38,7 @@ int Xstackflag=0; /* set in coercions, moves, and tests. %1 means something */ struct varinfo *gen_inst(),*gen_move(),*gen_test(),*gen_preturn(),*gen_tlab(); -struct varinfo *gen_label(), *make_erase(); +struct varinfo *gen_label(), *gen_stackadjust(), *make_erase(); expr_t make_expr(),ident_expr(),subreg_expr(),tokm_expr(),all_expr(); expr_t perc_ident_expr(),sum_expr(),regvar_expr(); @@ -74,9 +74,9 @@ iocc_t iops[20]; %token TOPELTSIZE FALLTHROUGH LABELDEF %token PROC CALL EXAMPLE %token FROM TO -%token TEST MOVE STACK RETURN +%token TEST MOVE STACK RETURN STACKADJUST %token PATTERNS PAT WITH EXACT KILLS USES REUSING GEN YIELDS LEAVING -%token DEFINED SAMESIGN SFIT UFIT ROM LOWW HIGHW ISROM +%token DEFINED SAMESIGN SFIT UFIT ROM LOWW HIGHW ISROM STACKOFFSET %token CMPEQ CMPNE CMPLT CMPGT CMPLE CMPGE OR2 AND2 LSHIFT RSHIFT NOT COMP %token INREG REGVAR REG_ANY REG_FLOAT REG_LOOP REG_POINTER %token ADORNACCESS @@ -635,8 +635,8 @@ coderule maxempatlen=empatlen; } patterns - { if (!saferulefound) - error("Previous rule impossible on empty stack"); + { /* if (!saferulefound) + error("Previous rule impossible on empty stack"); */ outpatterns(); } | PROC IDENT example @@ -849,6 +849,8 @@ gen_instruction { $$ = gen_label($2-1); use_tes++; } | RETURN { $$ = gen_preturn(); } + | STACKADJUST expr + { $$ = gen_stackadjust($2.ex_index); use_noframepointer++; } ; optstar : /* empty */ @@ -1028,6 +1030,8 @@ expr { $$ = make_expr(TYPINT,EX_LOWW,$3-1,0); } | HIGHW '(' emarg ')' { $$ = make_expr(TYPINT,EX_HIGHW,$3-1,0); } + | STACKOFFSET '(' ')' + { $$ = make_expr(TYPINT,EX_STACKOFFSET, 0, 0); } /* Excluded, because it causes a shift-reduce conflict (problems with a tokenset_no followed by an optexpr) | '-' expr %prec UMINUS diff --git a/util/ncgg/coerc.c b/util/ncgg/coerc.c index 893f81be3..eb5f6ee7a 100644 --- a/util/ncgg/coerc.c +++ b/util/ncgg/coerc.c @@ -127,6 +127,15 @@ struct varinfo *gen_preturn() { return(vp); } +struct varinfo *gen_stackadjust(int expr) { + register struct varinfo *vp; + + NEW(vp,struct varinfo); + vp->vi_int[0] = INSSTACKADJUST; + vp->vi_int[1] = expr; + return(vp); +} + struct varinfo *gen_tlab(n) { register struct varinfo *vp; diff --git a/util/ncgg/extern.h b/util/ncgg/extern.h index ff5260704..8a9604fa7 100644 --- a/util/ncgg/extern.h +++ b/util/ncgg/extern.h @@ -37,6 +37,7 @@ extern int regclass; extern int maxtokensize; extern int nprocargs, maxprocargs; extern int use_tes; +extern int use_noframepointer; extern char *mystrcpy(); extern char *myalloc(); diff --git a/util/ncgg/keywords b/util/ncgg/keywords index 606f7c839..641fd45b9 100644 --- a/util/ncgg/keywords +++ b/util/ncgg/keywords @@ -43,6 +43,8 @@ reusing REUSING rom ROM samesign SAMESIGN sfit SFIT +stackadjust STACKADJUST +stackoffset STACKOFFSET topeltsize TOPELTSIZE test TEST to TO diff --git a/util/ncgg/output.c b/util/ncgg/output.c index 50458e369..2a905c339 100644 --- a/util/ncgg/output.c +++ b/util/ncgg/output.c @@ -12,6 +12,8 @@ int tabledebug=0; /* do not generate code for table debugging */ #endif int verbose=0; /* print all statistics */ int use_tes; /* use top element size information */ +int use_noframepointer; /* use stackadjust mechanism to remove requirement + for frame pointer */ char *c_file= "tables.c"; char *h_file= "tables.H"; char *cd_file= "code"; @@ -612,6 +614,8 @@ outdefs() { cdef("TABLEDEBUG",1); if (use_tes) cdef("USE_TES",1); + if (use_noframepointer) + cdef("USE_NOFRAMEPOINTER",1); } outars() { @@ -852,6 +856,11 @@ varinfo *kills,*allocates,*generates,*yields,*leaving; codeint(vp->vi_int[1]); codenl(); break; + case INSSTACKADJUST: + code8(DO_STACKADJUST); + codeint(vp->vi_int[1]); + codenl(); + break; } } codecoco(cocono); diff --git a/util/ncgg/param.h b/util/ncgg/param.h index dcc4f1b22..d39dd6b38 100644 --- a/util/ncgg/param.h +++ b/util/ncgg/param.h @@ -15,8 +15,8 @@ #define BORS(x,y) y #endif -#define MAXREGS BORS(40,30) -#define MAXPROPS BORS(30,20) +#define MAXREGS BORS(80,30) +#define MAXPROPS BORS(120,20) #define MAXTOKENS BORS(100,60) #define MAXATT 6 #define MAXSETS BORS(200,100) @@ -27,14 +27,14 @@ #define MAXPATTERNS BORS(40,30) #define MAXALLREG 5 #define MAXINSTANCES BORS(500,300) -#define MAXMOVES BORS(40,20) +#define MAXMOVES BORS(80,20) #define MAXTESTS 10 #define MAXSTACKS BORS(30,20) #define MAXCOERCS BORS(50,30) #define MAXSPLCOERC BORS(20,10) #define MAXSPLIT 3 #define MAXPATBYTES BORS(14000,7000) -#define MAXREGVAR 10 +#define MAXREGVAR 64 #define MAXSOURCELINES 7000 #define MAXPROCARG 10 diff --git a/util/ncgg/pmfile b/util/ncgg/pmfile index 52c547feb..21ce2d92c 100644 --- a/util/ncgg/pmfile +++ b/util/ncgg/pmfile @@ -61,27 +61,7 @@ ncgg = simple { outputs = {"%U%/tables.c", "%U%/tables.h"}, command = { - "cd %out[1]:dirname% && (%BINDIR%%PLATDEP%/cpp.ansi -P -I%NCGGINCLUDEDIR% %in% | %TOOLDIR%ncgg)", + "cd %out[1]:dirname% && (%BINDIR%%PLATDEP%/cpp.ansi -I%NCGGINCLUDEDIR% %in% | %TOOLDIR%ncgg)", "mv %out[1]:dirname%/tables.H %out[2]%" }, } - ---[[ - @echo HOSTNCG $SRCDIR/src/arch/$table/ncg/table - @mkdir -p \$(dir \$@) - @(cd $OBJDIR/src/arch/$1/ncg && $DESTDIR/bin/cpp -P -I$SRCDIR/src/arch/$1/ncg $SRCDIR/src/arch/$table/ncg/table | \ - $DESTDIR/bin/ncgg) > /dev/null - @(cd $OBJDIR/src/arch/$1/ncg && mv tables.H tables.h) ---]] - --- Revision history --- $Log$ --- Revision 1.3 2007-04-23 23:40:59 dtrg --- Modified to run ncgg input files through the ANSI preprocessor rather than the K&R one. --- --- Revision 1.2 2006/07/22 20:58:27 dtrg --- cpp now gets installed in the right place. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. --- diff --git a/util/ncgg/pseudo.h b/util/ncgg/pseudo.h index 24b335c50..91013354a 100644 --- a/util/ncgg/pseudo.h +++ b/util/ncgg/pseudo.h @@ -12,3 +12,4 @@ #define INSERASE (-6) #define INSREMOVE (-7) #define INSLABDEF (-8) +#define INSSTACKADJUST (-9)