[inferno-npe] 22 new revisions pushed by extrudedaluminiu on 2010-04-29 02:02 GMT

1 view
Skip to first unread message

infer...@googlecode.com

unread,
Apr 28, 2010, 10:04:19 PM4/28/10
to inferno-n...@googlegroups.com
22 new revisions:

Revision: 976861a2bb
Author: for...@vitanuova.com
Date: Sun Apr 25 08:18:38 2010
Log: 20100425-1618
http://code.google.com/p/inferno-npe/source/detail?r=976861a2bb

Revision: 956efdb69f
Author: for...@vitanuova.com
Date: Tue Apr 27 01:51:54 2010
Log: 20100427-0951
http://code.google.com/p/inferno-npe/source/detail?r=956efdb69f

Revision: aa36ea9699
Author: for...@vitanuova.com
Date: Tue Apr 27 04:51:13 2010
Log: 20100427-1251
http://code.google.com/p/inferno-npe/source/detail?r=aa36ea9699

Revision: 72a88af60e
Author: for...@vitanuova.com
Date: Tue Apr 27 04:54:05 2010
Log: 20100427-1254
http://code.google.com/p/inferno-npe/source/detail?r=72a88af60e

Revision: 979057b3b2
Author: for...@vitanuova.com
Date: Tue Apr 27 04:55:38 2010
Log: 20100427-1255
http://code.google.com/p/inferno-npe/source/detail?r=979057b3b2

Revision: 6f4870cb12
Author: for...@vitanuova.com
Date: Tue Apr 27 04:56:56 2010
Log: 20100427-1256
http://code.google.com/p/inferno-npe/source/detail?r=6f4870cb12

Revision: a1da266fe4
Author: for...@vitanuova.com
Date: Tue Apr 27 04:58:01 2010
Log: 20100427-1257
http://code.google.com/p/inferno-npe/source/detail?r=a1da266fe4

Revision: ce8244847b
Author: for...@vitanuova.com
Date: Tue Apr 27 04:59:28 2010
Log: 20100427-1259
http://code.google.com/p/inferno-npe/source/detail?r=ce8244847b

Revision: d2f8ad93d2
Author: for...@vitanuova.com
Date: Tue Apr 27 05:00:13 2010
Log: 20100427-1300
http://code.google.com/p/inferno-npe/source/detail?r=d2f8ad93d2

Revision: 0ff17dc710
Author: for...@vitanuova.com
Date: Tue Apr 27 05:05:45 2010
Log: 20100427-1305
http://code.google.com/p/inferno-npe/source/detail?r=0ff17dc710

Revision: a9d7526ab4
Author: for...@vitanuova.com
Date: Tue Apr 27 05:10:29 2010
Log: 20100427-1310
http://code.google.com/p/inferno-npe/source/detail?r=a9d7526ab4

Revision: ea2b992c95
Author: for...@vitanuova.com
Date: Tue Apr 27 05:16:18 2010
Log: 20100427-1316
http://code.google.com/p/inferno-npe/source/detail?r=ea2b992c95

Revision: 5a3230d872
Author: for...@vitanuova.com
Date: Tue Apr 27 05:20:36 2010
Log: 20100427-1320
http://code.google.com/p/inferno-npe/source/detail?r=5a3230d872

Revision: 556e8957ba
Author: for...@vitanuova.com
Date: Tue Apr 27 05:21:20 2010
Log: 20100427-1321
http://code.google.com/p/inferno-npe/source/detail?r=556e8957ba

Revision: 6cb5b0cde4
Author: for...@vitanuova.com
Date: Tue Apr 27 05:24:29 2010
Log: 20100427-1324
http://code.google.com/p/inferno-npe/source/detail?r=6cb5b0cde4

Revision: f9af16a874
Author: for...@vitanuova.com
Date: Tue Apr 27 05:33:26 2010
Log: 20100427-1333
http://code.google.com/p/inferno-npe/source/detail?r=f9af16a874

Revision: 6b8cd637ac
Author: for...@vitanuova.com
Date: Tue Apr 27 11:09:04 2010
Log: 20100427-1909
http://code.google.com/p/inferno-npe/source/detail?r=6b8cd637ac

Revision: 573a102a3b
Author: for...@vitanuova.com
Date: Tue Apr 27 11:13:34 2010
Log: 20100427-1913
http://code.google.com/p/inferno-npe/source/detail?r=573a102a3b

Revision: 05b8866b1f
Author: for...@vitanuova.com
Date: Tue Apr 27 13:15:13 2010
Log: 20100427-2115
http://code.google.com/p/inferno-npe/source/detail?r=05b8866b1f

Revision: 458e251755
Author: for...@vitanuova.com
Date: Tue Apr 27 13:20:56 2010
Log: 20100427-2120
http://code.google.com/p/inferno-npe/source/detail?r=458e251755

Revision: 4bd48c3d44
Author: for...@vitanuova.com
Date: Tue Apr 27 14:08:33 2010
Log: 20100427-2208
http://code.google.com/p/inferno-npe/source/detail?r=4bd48c3d44

Revision: b9d0fe3aa5
Author: Venkatesh Srinivas <m...@endeavour.zapto.org>
Date: Wed Apr 28 18:25:58 2010
Log: Merge with inferno-os 20100427.
http://code.google.com/p/inferno-npe/source/detail?r=b9d0fe3aa5

==============================================================================
Revision: 976861a2bb
Author: for...@vitanuova.com
Date: Sun Apr 25 08:18:38 2010
Log: 20100425-1618
http://code.google.com/p/inferno-npe/source/detail?r=976861a2bb

Modified:
/CHANGES
/appl/wm/wm.b
/dis/wm/wm.dis
/include/version.h
/libtk/menus.c

=======================================
--- /CHANGES Tue Apr 6 11:59:10 2010
+++ /CHANGES Sun Apr 25 08:18:38 2010
@@ -1,3 +1,5 @@
+20100425
+ appl/wm/wm.b shorten processing of wmctl close if client hadn't started
20100406
fix handling of boundary case in libtk/utils.c
20100402
=======================================
--- /appl/wm/wm.b Sat Jul 14 03:41:18 2007
+++ /appl/wm/wm.b Sun Apr 25 08:18:38 2010
@@ -154,6 +154,8 @@
# if client leaving
if(rc == nil){
c.remove();
+ if(c.stop == nil)
+ break;
if(c == ptrfocus)
ptrfocus = nil;
if(c == kbdfocus)
=======================================
--- /dis/wm/wm.dis Sat Jul 14 03:41:18 2007
+++ /dis/wm/wm.dis Sun Apr 25 08:18:38 2010
Binary file, no diff available.
=======================================
--- /include/version.h Tue Apr 6 03:01:04 2010
+++ /include/version.h Sun Apr 25 08:18:38 2010
@@ -1,1 +1,1 @@
-#define VERSION "Fourth Edition (20100406)"
+#define VERSION "Fourth Edition (20100425)"
=======================================
--- /libtk/menus.c Thu Mar 25 02:26:15 2010
+++ /libtk/menus.c Sun Apr 25 08:18:38 2010
@@ -608,7 +608,7 @@
if(value[0] < '0' || value[0] > '9')
return;
v = atoi(value);
- if(v < 0 || v > tkl->nvalues)
+ if(v < 0 || v >= tkl->nvalues)
return; /* what else can we do? */
free(tkl->text);
tkl->text = strdup(tkl->values[v]);

==============================================================================
Revision: 956efdb69f
Author: for...@vitanuova.com
Date: Tue Apr 27 01:51:54 2010
Log: 20100427-0951
http://code.google.com/p/inferno-npe/source/detail?r=956efdb69f

Deleted:
/utils/libmach/tobj.c
Modified:
/utils/libmach/mkfile

=======================================
--- /utils/libmach/tobj.c Fri Dec 22 13:39:35 2006
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 5obj.c - identify and parse a arm object file
- */
-#include <lib9.h>
-#include <bio.h>
-#include "5c/5.out.h"
-#include "obj.h"
-
-typedef struct Addr Addr;
-struct Addr
-{
- char type;
- char sym;
- char name;
-};
-static Addr addr(Biobuf*);
-static char type2char(int);
-static void skip(Biobuf*, int);
-
-int
-_ist(char *s)
-{
- return s[0] == ANAME /* ANAME */
- && s[1] == D_FILE /* type */
- && s[2] == 1 /* sym */
- && s[3] == '<'; /* name of file */
-}
-
-int
-_readt(Biobuf *bp, Prog *p)
-{
- int as, n;
- Addr a;
-
- as = Bgetc(bp); /* as */
- if(as < 0)
- return 0;
- p->kind = aNone;
- if(as == ANAME || as == ASIGNAME){
- if(as == ASIGNAME)
- skip(bp, 4); /* signature */
- p->kind = aName;
- p->type = type2char(Bgetc(bp)); /* type */
- p->sym = Bgetc(bp); /* sym */
- n = 0;
- for(;;) {
- as = Bgetc(bp);
- if(as < 0)
- return 0;
- n++;
- if(as == 0)
- break;
- }
- p->id = malloc(n);
- if(p->id == 0)
- return 0;
- Bseek(bp, -n, 1);
- if(Bread(bp, p->id, n) != n)
- return 0;
- return 1;
- }
- if(as == ATEXT)
- p->kind = aText;
- else if(as == AGLOBL)
- p->kind = aData;
- skip(bp, 6); /* scond(1), reg(1), lineno(4) */
- a = addr(bp);
- addr(bp);
- if(a.type != D_OREG || a.name != D_STATIC && a.name != D_EXTERN)
- p->kind = aNone;
- p->sym = a.sym;
- return 1;
-}
-
-static Addr
-addr(Biobuf *bp)
-{
- Addr a;
- long off;
-
- a.type = Bgetc(bp); /* a.type */
- skip(bp,1); /* reg */
- a.sym = Bgetc(bp); /* sym index */
- a.name = Bgetc(bp); /* sym type */
- switch(a.type){
- default:
- case D_NONE:
- case D_REG:
- case D_FREG:
- case D_PSR:
- case D_FPCR:
- break;
- case D_OREG:
- case D_CONST:
- case D_BRANCH:
- case D_SHIFT:
- off = Bgetc(bp);
- off |= Bgetc(bp) << 8;
- off |= Bgetc(bp) << 16;
- off |= Bgetc(bp) << 24;
- if(off < 0)
- off = -off;
- if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
- _offset(a.sym, off);
- break;
- case D_SCONST:
- skip(bp, NSNAME);
- break;
- case D_FCONST:
- skip(bp, 8);
- break;
- }
- return a;
-}
-
-static char
-type2char(int t)
-{
- switch(t){
- case D_EXTERN: return 'U';
- case D_STATIC: return 'b';
- case D_AUTO: return 'a';
- case D_PARAM: return 'p';
- default: return UNKNOWN;
- }
-}
-
-static void
-skip(Biobuf *bp, int n)
-{
- while (n-- > 0)
- Bgetc(bp);
-}
=======================================
--- /utils/libmach/mkfile Fri Dec 22 13:39:35 2006
+++ /utils/libmach/mkfile Tue Apr 27 01:51:54 2010
@@ -25,7 +25,6 @@
8obj.$O\
kobj.$O\
qobj.$O\
- tobj.$O\
vobj.$O\
obj.$O\
map.$O\

==============================================================================
Revision: aa36ea9699
Author: for...@vitanuova.com
Date: Tue Apr 27 04:51:13 2010
Log: 20100427-1251
http://code.google.com/p/inferno-npe/source/detail?r=aa36ea9699

Added:
/utils/9c/9.out.h
/utils/cc/pgen.c
/utils/cc/pswt.c
/utils/libmach/9.c
/utils/libmach/9obj.c
/utils/libmach/ureg9.h
/utils/qc/machcap.c
Modified:
/CHANGES
/include/version.h
/utils/0c/gc.h
/utils/0c/peep.c
/utils/0c/sgen.c
/utils/0c/swt.c
/utils/1c/gc.h
/utils/1c/peep.c
/utils/1c/sgen.c
/utils/1c/swt.c
/utils/1l/asm.c
/utils/1l/obj.c
/utils/2c/gc.h
/utils/2c/peep.c
/utils/2c/sgen.c
/utils/2c/swt.c
/utils/2l/obj.c
/utils/5c/gc.h
/utils/5c/peep.c
/utils/5c/sgen.c
/utils/5c/swt.c
/utils/5coff/5coff.c
/utils/5cv/5cv.c
/utils/5l/obj.c
/utils/5l/thumb.c
/utils/6c/gc.h
/utils/6c/sgen.c
/utils/6c/swt.c
/utils/8c/gc.h
/utils/8c/sgen.c
/utils/8c/swt.c
/utils/acid/acid.h
/utils/acid/builtin.c
/utils/acid/exec.c
/utils/acid/expr.c
/utils/acid/list.c
/utils/acid/main.c
/utils/acid/os-Plan9.c
/utils/acid/util.c
/utils/c2l/com.c
/utils/c2l/dcl.c
/utils/c2l/lex.c
/utils/c2l/sub.c
/utils/cc/cc.h
/utils/cc/com.c
/utils/cc/com64.c
/utils/cc/dcl.c
/utils/cc/dpchk.c
/utils/cc/lex.c
/utils/cc/lexbody
/utils/cc/mkfile
/utils/cc/pickle.c
/utils/ftl/ftl.c
/utils/include/a.out.h
/utils/include/mach.h
/utils/kc/gc.h
/utils/kc/sgen.c
/utils/kc/swt.c
/utils/libmach/2.c
/utils/libmach/2db.c
/utils/libmach/2obj.c
/utils/libmach/5db.c
/utils/libmach/6.c
/utils/libmach/6obj.c
/utils/libmach/8db.c
/utils/libmach/a.out.h
/utils/libmach/access.c
/utils/libmach/ar.h
/utils/libmach/bootexec.h
/utils/libmach/elf.h
/utils/libmach/executable.c
/utils/libmach/kdb.c
/utils/libmach/machdata.c
/utils/libmach/map.c
/utils/libmach/mkfile
/utils/libmach/obj.c
/utils/libmach/obj.h
/utils/libmach/q.c
/utils/libmach/qdb.c
/utils/libmach/qobj.c
/utils/libmach/swap.c
/utils/libmach/sym.c
/utils/libmach/t.c
/utils/libmach/tdb.c
/utils/libmach/ureg6.h
/utils/libmach/uregq.h
/utils/libmach/uregt.h
/utils/libmach/vcodas.c
/utils/libmach/vdb.c
/utils/qa/a.y
/utils/qa/lex.c
/utils/qc/cgen.c
/utils/qc/enam.c
/utils/qc/gc.h
/utils/qc/list.c
/utils/qc/mkfile
/utils/qc/peep.c
/utils/qc/q.out.h
/utils/qc/reg.c
/utils/qc/sgen.c
/utils/qc/swt.c
/utils/qc/txt.c
/utils/ql/asm.c
/utils/ql/asmout.c
/utils/ql/list.c
/utils/ql/mkfile
/utils/ql/noop.c
/utils/ql/obj.c
/utils/ql/optab.c
/utils/ql/span.c
/utils/tc/gc.h
/utils/tc/peep.c
/utils/tc/sgen.c
/utils/tc/swt.c
/utils/va/lex.c
/utils/vc/gc.h
/utils/vc/sgen.c
/utils/vc/swt.c

=======================================
--- /dev/null
+++ /utils/9c/9.out.h Tue Apr 27 04:51:13 2010
@@ -0,0 +1,419 @@
+/*
+ * powerpc 64
+ */
+#define NSNAME 8
+#define NSYM 50
+#define NREG 32
+
+#define NOPROF (1<<0)
+#define DUPOK (1<<1)
+
+enum
+{
+ REGZERO = 0, /* set to zero */
+ REGSP = 1,
+ REGSB = 2,
+ REGRET = 3,
+ REGARG = 3,
+ REGMIN = 7, /* register variables allocated from here to REGMAX */
+ REGMAX = 27,
+ REGEXT = 30, /* external registers allocated from here down */
+ REGTMP = 31, /* used by the linker */
+
+ FREGRET = 0,
+ FREGMIN = 17, /* first register variable */
+ FREGEXT = 26, /* first external register */
+ FREGCVI = 27, /* floating conversion constant */
+ FREGZERO = 28, /* both float and double */
+ FREGHALF = 29, /* double */
+ FREGONE = 30, /* double */
+ FREGTWO = 31 /* double */
+/*
+ * GENERAL:
+ *
+ * compiler allocates R3 up as temps
+ * compiler allocates register variables R7-R27
+ * compiler allocates external registers R30 down
+ *
+ * compiler allocates register variables F17-F26
+ * compiler allocates external registers F26 down
+ */
+};
+
+enum as
+{
+ AXXX = 0,
+ AADD,
+ AADDCC,
+ AADDV,
+ AADDVCC,
+ AADDC,
+ AADDCCC,
+ AADDCV,
+ AADDCVCC,
+ AADDME,
+ AADDMECC,
+ AADDMEVCC,
+ AADDMEV,
+ AADDE,
+ AADDECC,
+ AADDEVCC,
+ AADDEV,
+ AADDZE,
+ AADDZECC,
+ AADDZEVCC,
+ AADDZEV,
+ AAND,
+ AANDCC,
+ AANDN,
+ AANDNCC,
+ ABC,
+ ABCL,
+ ABEQ,
+ ABGE,
+ ABGT,
+ ABL,
+ ABLE,
+ ABLT,
+ ABNE,
+ ABR,
+ ABVC,
+ ABVS,
+ ACMP,
+ ACMPU,
+ ACNTLZW,
+ ACNTLZWCC,
+ ACRAND,
+ ACRANDN,
+ ACREQV,
+ ACRNAND,
+ ACRNOR,
+ ACROR,
+ ACRORN,
+ ACRXOR,
+ ADIVW,
+ ADIVWCC,
+ ADIVWVCC,
+ ADIVWV,
+ ADIVWU,
+ ADIVWUCC,
+ ADIVWUVCC,
+ ADIVWUV,
+ AEQV,
+ AEQVCC,
+ AEXTSB,
+ AEXTSBCC,
+ AEXTSH,
+ AEXTSHCC,
+ AFABS,
+ AFABSCC,
+ AFADD,
+ AFADDCC,
+ AFADDS,
+ AFADDSCC,
+ AFCMPO,
+ AFCMPU,
+ AFCTIW,
+ AFCTIWCC,
+ AFCTIWZ,
+ AFCTIWZCC,
+ AFDIV,
+ AFDIVCC,
+ AFDIVS,
+ AFDIVSCC,
+ AFMADD,
+ AFMADDCC,
+ AFMADDS,
+ AFMADDSCC,
+ AFMOVD,
+ AFMOVDCC,
+ AFMOVDU,
+ AFMOVS,
+ AFMOVSU,
+ AFMSUB,
+ AFMSUBCC,
+ AFMSUBS,
+ AFMSUBSCC,
+ AFMUL,
+ AFMULCC,
+ AFMULS,
+ AFMULSCC,
+ AFNABS,
+ AFNABSCC,
+ AFNEG,
+ AFNEGCC,
+ AFNMADD,
+ AFNMADDCC,
+ AFNMADDS,
+ AFNMADDSCC,
+ AFNMSUB,
+ AFNMSUBCC,
+ AFNMSUBS,
+ AFNMSUBSCC,
+ AFRSP,
+ AFRSPCC,
+ AFSUB,
+ AFSUBCC,
+ AFSUBS,
+ AFSUBSCC,
+ AMOVMW,
+ ALSW,
+ ALWAR,
+ AMOVWBR,
+ AMOVB,
+ AMOVBU,
+ AMOVBZ,
+ AMOVBZU,
+ AMOVH,
+ AMOVHBR,
+ AMOVHU,
+ AMOVHZ,
+ AMOVHZU,
+ AMOVW,
+ AMOVWU,
+ AMOVFL,
+ AMOVCRFS,
+ AMTFSB0,
+ AMTFSB0CC,
+ AMTFSB1,
+ AMTFSB1CC,
+ AMULHW,
+ AMULHWCC,
+ AMULHWU,
+ AMULHWUCC,
+ AMULLW,
+ AMULLWCC,
+ AMULLWVCC,
+ AMULLWV,
+ ANAND,
+ ANANDCC,
+ ANEG,
+ ANEGCC,
+ ANEGVCC,
+ ANEGV,
+ ANOR,
+ ANORCC,
+ AOR,
+ AORCC,
+ AORN,
+ AORNCC,
+ AREM,
+ AREMCC,
+ AREMV,
+ AREMVCC,
+ AREMU,
+ AREMUCC,
+ AREMUV,
+ AREMUVCC,
+ ARFI,
+ ARLWMI,
+ ARLWMICC,
+ ARLWNM,
+ ARLWNMCC,
+ ASLW,
+ ASLWCC,
+ ASRW,
+ ASRAW,
+ ASRAWCC,
+ ASRWCC,
+ ASTSW,
+ ASTWCCC,
+ ASUB,
+ ASUBCC,
+ ASUBVCC,
+ ASUBC,
+ ASUBCCC,
+ ASUBCV,
+ ASUBCVCC,
+ ASUBME,
+ ASUBMECC,
+ ASUBMEVCC,
+ ASUBMEV,
+ ASUBV,
+ ASUBE,
+ ASUBECC,
+ ASUBEV,
+ ASUBEVCC,
+ ASUBZE,
+ ASUBZECC,
+ ASUBZEVCC,
+ ASUBZEV,
+ ASYNC,
+ AXOR,
+ AXORCC,
+
+ ADCBF,
+ ADCBI,
+ ADCBST,
+ ADCBT,
+ ADCBTST,
+ ADCBZ,
+ AECIWX,
+ AECOWX,
+ AEIEIO,
+ AICBI,
+ AISYNC,
+ APTESYNC,
+ ATLBIE,
+ ATLBIEL,
+ ATLBSYNC,
+ ATW,
+
+ ASYSCALL,
+ ADATA,
+ AGLOBL,
+ AGOK,
+ AHISTORY,
+ ANAME,
+ ANOP,
+ ARETURN,
+ ATEXT,
+ AWORD,
+ AEND,
+ ADYNT,
+ AINIT,
+ ASIGNAME,
+
+ ARFCI,
+
+ /* optional on 32-bit */
+ AFRES,
+ AFRESCC,
+ AFRSQRTE,
+ AFRSQRTECC,
+ AFSEL,
+ AFSELCC,
+ AFSQRT,
+ AFSQRTCC,
+ AFSQRTS,
+ AFSQRTSCC,
+
+ /* 64-bit */
+
+ ACNTLZD,
+ ACNTLZDCC,
+ ACMPW, /* CMP with L=0 */
+ ACMPWU,
+ ADIVD,
+ ADIVDCC,
+ ADIVDVCC,
+ ADIVDV,
+ ADIVDU,
+ ADIVDUCC,
+ ADIVDUVCC,
+ ADIVDUV,
+ AEXTSW,
+ AEXTSWCC,
+ /* AFCFIW; AFCFIWCC */
+ AFCFID,
+ AFCFIDCC,
+ AFCTID,
+ AFCTIDCC,
+ AFCTIDZ,
+ AFCTIDZCC,
+ ALDAR,
+ AMOVD,
+ AMOVDU,
+ AMOVWZ,
+ AMOVWZU,
+ AMULHD,
+ AMULHDCC,
+ AMULHDU,
+ AMULHDUCC,
+ AMULLD,
+ AMULLDCC,
+ AMULLDVCC,
+ AMULLDV,
+ ARFID,
+ ARLDMI,
+ ARLDMICC,
+ ARLDC,
+ ARLDCCC,
+ ARLDCR,
+ ARLDCRCC,
+ ARLDCL,
+ ARLDCLCC,
+ ASLBIA,
+ ASLBIE,
+ ASLBMFEE,
+ ASLBMFEV,
+ ASLBMTE,
+ ASLD,
+ ASLDCC,
+ ASRD,
+ ASRAD,
+ ASRADCC,
+ ASRDCC,
+ ASTDCCC,
+ ATD,
+
+ /* 64-bit pseudo operation */
+ ADWORD,
+ AREMD,
+ AREMDCC,
+ AREMDV,
+ AREMDVCC,
+ AREMDU,
+ AREMDUCC,
+ AREMDUV,
+ AREMDUVCC,
+
+ /* more 64-bit operations */
+ AHRFID,
+
+ ALAST
+};
+
+/* type/name */
+enum
+{
+ D_GOK = 0,
+ D_NONE,
+
+/* name */
+ D_EXTERN,
+ D_STATIC,
+ D_AUTO,
+ D_PARAM,
+
+/* type */
+ D_BRANCH,
+ D_OREG,
+ D_CONST,
+ D_FCONST,
+ D_SCONST,
+ D_REG,
+ D_FPSCR,
+ D_MSR,
+ D_FREG,
+ D_CREG,
+ D_SPR,
+ D_OPT, /* branch/trap option */
+ D_FILE,
+ D_FILE1,
+ D_DCR, /* device control register */
+ D_DCONST,
+
+/* reg names iff type is D_SPR */
+ D_XER = 1,
+ D_LR = 8,
+ D_CTR = 9
+ /* and many supervisor level registers */
+};
+
+/*
+ * this is the ranlib header
+ */
+#define SYMDEF "__.SYMDEF"
+
+/*
+ * this is the simulated IEEE floating point
+ */
+typedef struct ieee Ieee;
+struct ieee
+{
+ long l; /* contains ls-man 0xffffffff */
+ long h; /* contains sign 0x80000000
+ exp 0x7ff00000
+ ms-man 0x000fffff */
+};
=======================================
--- /dev/null
+++ /utils/cc/pgen.c Tue Apr 27 04:51:13 2010
@@ -0,0 +1,548 @@
+#include "gc.h"
+
+void
+codgen(Node *n, Node *nn)
+{
+ Prog *sp;
+ Node *n1, nod, nod1;
+
+ cursafe = 0;
+ curarg = 0;
+ maxargsafe = 0;
+ hasdoubled = 0;
+
+ /*
+ * isolate name
+ */
+ for(n1 = nn;; n1 = n1->left) {
+ if(n1 == Z) {
+ diag(nn, "cant find function name");
+ return;
+ }
+ if(n1->op == ONAME)
+ break;
+ }
+ nearln = nn->lineno;
+ gpseudo(ATEXT, n1->sym, nodconst(stkoff));
+ sp = p;
+
+ if(typecmplx[thisfn->link->etype]) {
+ if(nodret == nil) {
+ nodret = new(ONAME, Z, Z);
+ nodret->sym = slookup(".ret");
+ nodret->class = CPARAM;
+ nodret->type = types[TIND];
+ nodret->etype = TIND;
+ nodret = new(OIND, nodret, Z);
+ }
+ n1 = nodret->left;
+ if(n1->type == T || n1->type->link != thisfn->link) {
+ n1->type = typ(TIND, thisfn->link);
+ n1->etype = n1->type->etype;
+ nodret = new(OIND, n1, Z);
+ complex(nodret);
+ }
+ }
+
+ /*
+ * isolate first argument
+ */
+ if(REGARG >= 0) {
+ if(typecmplx[thisfn->link->etype]) {
+ nod1 = *nodret->left;
+ nodreg(&nod, &nod1, REGARG);
+ gmove(&nod, &nod1);
+ } else
+ if(firstarg && typeword[firstargtype->etype]) {
+ nod1 = znode;
+ nod1.op = ONAME;
+ nod1.sym = firstarg;
+ nod1.type = firstargtype;
+ nod1.class = CPARAM;
+ nod1.xoffset = align(0, firstargtype, Aarg1);
+ nod1.etype = firstargtype->etype;
+ xcom(&nod1);
+ nodreg(&nod, &nod1, REGARG);
+ gmove(&nod, &nod1);
+ }
+ }
+
+ canreach = 1;
+ warnreach = 1;
+ gen(n);
+ if(canreach && thisfn->link->etype != TVOID)
+ warn(Z, "no return at end of function: %s", n1->sym->name);
+ noretval(3);
+ gbranch(ORETURN);
+
+ if(!debug['N'] || debug['R'] || debug['P'])
+ regopt(sp);
+
+ if(thechar=='6' || thechar=='7' || thechar=='9' || hasdoubled) /* [sic] */
+ maxargsafe = round(maxargsafe, 8);
+ sp->to.offset += maxargsafe;
+}
+
+void
+supgen(Node *n)
+{
+ int owarn;
+ long spc;
+ Prog *sp;
+
+ if(n == Z)
+ return;
+ suppress++;
+ owarn = warnreach;
+ warnreach = 0;
+ spc = pc;
+ sp = lastp;
+ gen(n);
+ lastp = sp;
+ pc = spc;
+ sp->link = nil;
+ suppress--;
+ warnreach = owarn;
+}
+
+void
+gen(Node *n)
+{
+ Node *l, nod;
+ Prog *sp, *spc, *spb;
+ Case *cn;
+ long sbc, scc;
+ int snbreak, sncontin;
+ int f, o, oldreach;
+
+loop:
+ if(n == Z)
+ return;
+ nearln = n->lineno;
+ o = n->op;
+ if(debug['G'])
+ if(o != OLIST)
+ print("%L %O\n", nearln, o);
+
+ if(!canreach) {
+ switch(o) {
+ case OLABEL:
+ case OCASE:
+ case OLIST:
+ case OBREAK:
+ case OFOR:
+ case OWHILE:
+ case ODWHILE:
+ /* all handled specially - see switch body below */
+ break;
+ default:
+ if(warnreach) {
+ warn(n, "unreachable code %O", o);
+ warnreach = 0;
+ }
+ }
+ }
+
+ switch(o) {
+
+ default:
+ complex(n);
+ cgen(n, Z);
+ break;
+
+ case OLIST:
+ gen(n->left);
+
+ rloop:
+ n = n->right;
+ goto loop;
+
+ case ORETURN:
+ canreach = 0;
+ warnreach = !suppress;
+ complex(n);
+ if(n->type == T)
+ break;
+ l = n->left;
+ if(l == Z) {
+ noretval(3);
+ gbranch(ORETURN);
+ break;
+ }
+ if(typecmplx[n->type->etype]) {
+ nod = znode;
+ nod.op = OAS;
+ nod.left = nodret;
+ nod.right = l;
+ nod.type = n->type;
+ nod.complex = l->complex;
+ cgen(&nod, Z);
+ noretval(3);
+ gbranch(ORETURN);
+ break;
+ }
+ regret(&nod, n);
+ cgen(l, &nod);
+ regfree(&nod);
+ if(typefd[n->type->etype])
+ noretval(1);
+ else
+ noretval(2);
+ gbranch(ORETURN);
+ break;
+
+ case OLABEL:
+ canreach = 1;
+ l = n->left;
+ if(l) {
+ l->pc = pc;
+ if(l->label)
+ patch(l->label, pc);
+ }
+ gbranch(OGOTO); /* prevent self reference in reg */
+ patch(p, pc);
+ goto rloop;
+
+ case OGOTO:
+ canreach = 0;
+ warnreach = !suppress;
+ n = n->left;
+ if(n == Z)
+ return;
+ if(n->complex == 0) {
+ diag(Z, "label undefined: %s", n->sym->name);
+ return;
+ }
+ if(suppress)
+ return;
+ gbranch(OGOTO);
+ if(n->pc) {
+ patch(p, n->pc);
+ return;
+ }
+ if(n->label)
+ patch(n->label, pc-1);
+ n->label = p;
+ return;
+
+ case OCASE:
+ canreach = 1;
+ l = n->left;
+ if(cases == C)
+ diag(n, "case/default outside a switch");
+ if(l == Z) {
+ casf();
+ cases->val = 0;
+ cases->def = 1;
+ cases->label = pc;
+ cases->isv = 0;
+ goto rloop;
+ }
+ complex(l);
+ if(l->type == T)
+ goto rloop;
+ if(l->op == OCONST)
+ if(typeword[l->type->etype] && l->type->etype != TIND) {
+ casf();
+ cases->val = l->vconst;
+ cases->def = 0;
+ cases->label = pc;
+ cases->isv = typev[l->type->etype];
+ goto rloop;
+ }
+ diag(n, "case expression must be integer constant");
+ goto rloop;
+
+ case OSWITCH:
+ l = n->left;
+ complex(l);
+ if(l->type == T)
+ break;
+ if(!typeword[l->type->etype] || l->type->etype == TIND) {
+ diag(n, "switch expression must be integer");
+ break;
+ }
+
+ gbranch(OGOTO); /* entry */
+ sp = p;
+
+ cn = cases;
+ cases = C;
+ casf();
+
+ sbc = breakpc;
+ breakpc = pc;
+ snbreak = nbreak;
+ nbreak = 0;
+ gbranch(OGOTO);
+ spb = p;
+
+ gen(n->right); /* body */
+ if(canreach){
+ gbranch(OGOTO);
+ patch(p, breakpc);
+ nbreak++;
+ }
+
+ patch(sp, pc);
+ regalloc(&nod, l, Z);
+ /* always signed */
+ if(typev[l->type->etype])
+ nod.type = types[TVLONG];
+ else
+ nod.type = types[TLONG];
+ cgen(l, &nod);
+ doswit(&nod);
+ regfree(&nod);
+ patch(spb, pc);
+
+ cases = cn;
+ breakpc = sbc;
+ canreach = nbreak!=0;
+ if(canreach == 0)
+ warnreach = !suppress;
+ nbreak = snbreak;
+ break;
+
+ case OWHILE:
+ case ODWHILE:
+ l = n->left;
+ gbranch(OGOTO); /* entry */
+ sp = p;
+
+ scc = continpc;
+ continpc = pc;
+ gbranch(OGOTO);
+ spc = p;
+
+ sbc = breakpc;
+ breakpc = pc;
+ snbreak = nbreak;
+ nbreak = 0;
+ gbranch(OGOTO);
+ spb = p;
+
+ patch(spc, pc);
+ if(n->op == OWHILE)
+ patch(sp, pc);
+ bcomplex(l, Z); /* test */
+ patch(p, breakpc);
+ if(l->op != OCONST || vconst(l) == 0)
+ nbreak++;
+
+ if(n->op == ODWHILE)
+ patch(sp, pc);
+ gen(n->right); /* body */
+ gbranch(OGOTO);
+ patch(p, continpc);
+
+ patch(spb, pc);
+ continpc = scc;
+ breakpc = sbc;
+ canreach = nbreak!=0;
+ if(canreach == 0)
+ warnreach = !suppress;
+ nbreak = snbreak;
+ break;
+
+ case OFOR:
+ l = n->left;
+ if(!canreach && l->right->left && warnreach) {
+ warn(n, "unreachable code FOR");
+ warnreach = 0;
+ }
+ gen(l->right->left); /* init */
+ gbranch(OGOTO); /* entry */
+ sp = p;
+
+ /*
+ * if there are no incoming labels in the
+ * body and the top's not reachable, warn
+ */
+ if(!canreach && warnreach && deadheads(n)) {
+ warn(n, "unreachable code %O", o);
+ warnreach = 0;
+ }
+
+ scc = continpc;
+ continpc = pc;
+ gbranch(OGOTO);
+ spc = p;
+
+ sbc = breakpc;
+ breakpc = pc;
+ snbreak = nbreak;
+ nbreak = 0;
+ sncontin = ncontin;
+ ncontin = 0;
+ gbranch(OGOTO);
+ spb = p;
+
+ patch(spc, pc);
+ gen(l->right->right); /* inc */
+ patch(sp, pc);
+ if(l->left != Z) { /* test */
+ bcomplex(l->left, Z);
+ patch(p, breakpc);
+ if(l->left->op != OCONST || vconst(l->left) == 0)
+ nbreak++;
+ }
+ canreach = 1;
+ gen(n->right); /* body */
+ if(canreach){
+ gbranch(OGOTO);
+ patch(p, continpc);
+ ncontin++;
+ }
+ if(!ncontin && l->right->right && warnreach) {
+ warn(l->right->right, "unreachable FOR inc");
+ warnreach = 0;
+ }
+
+ patch(spb, pc);
+ continpc = scc;
+ breakpc = sbc;
+ canreach = nbreak!=0;
+ if(canreach == 0)
+ warnreach = !suppress;
+ nbreak = snbreak;
+ ncontin = sncontin;
+ break;
+
+ case OCONTINUE:
+ if(continpc < 0) {
+ diag(n, "continue not in a loop");
+ break;
+ }
+ gbranch(OGOTO);
+ patch(p, continpc);
+ ncontin++;
+ canreach = 0;
+ warnreach = !suppress;
+ break;
+
+ case OBREAK:
+ if(breakpc < 0) {
+ diag(n, "break not in a loop");
+ break;
+ }
+ /*
+ * Don't complain about unreachable break statements.
+ * There are breaks hidden in yacc's output and some people
+ * write return; break; in their switch statements out of habit.
+ * However, don't confuse the analysis by inserting an
+ * unreachable reference to breakpc either.
+ */
+ if(!canreach)
+ break;
+ gbranch(OGOTO);
+ patch(p, breakpc);
+ nbreak++;
+ canreach = 0;
+ warnreach = !suppress;
+ break;
+
+ case OIF:
+ l = n->left;
+ if(bcomplex(l, n->right)) {
+ if(typefd[l->type->etype])
+ f = !l->fconst;
+ else
+ f = !l->vconst;
+ if(debug['c'])
+ print("%L const if %s\n", nearln, f ? "false" : "true");
+ if(f) {
+ canreach = 1;
+ supgen(n->right->left);
+ oldreach = canreach;
+ canreach = 1;
+ gen(n->right->right);
+ /*
+ * treat constant ifs as regular ifs for
+ * reachability warnings.
+ */
+ if(!canreach && oldreach && debug['w'] < 2)
+ warnreach = 0;
+ }
+ else {
+ canreach = 1;
+ gen(n->right->left);
+ oldreach = canreach;
+ canreach = 1;
+ supgen(n->right->right);
+ /*
+ * treat constant ifs as regular ifs for
+ * reachability warnings.
+ */
+ if(!oldreach && canreach && debug['w'] < 2)
+ warnreach = 0;
+ canreach = oldreach;
+ }
+ }
+ else {
+ sp = p;
+ canreach = 1;
+ if(n->right->left != Z)
+ gen(n->right->left);
+ oldreach = canreach;
+ canreach = 1;
+ if(n->right->right != Z) {
+ gbranch(OGOTO);
+ patch(sp, pc);
+ sp = p;
+ gen(n->right->right);
+ }
+ patch(sp, pc);
+ canreach = canreach || oldreach;
+ if(canreach == 0)
+ warnreach = !suppress;
+ }
+ break;
+
+ case OSET:
+ case OUSED:
+ usedset(n->left, o);
+ break;
+ }
+}
+
+void
+usedset(Node *n, int o)
+{
+ if(n->op == OLIST) {
+ usedset(n->left, o);
+ usedset(n->right, o);
+ return;
+ }
+ complex(n);
+ switch(n->op) {
+ case OADDR: /* volatile */
+ gins(ANOP, n, Z);
+ break;
+ case ONAME:
+ if(o == OSET)
+ gins(ANOP, Z, n);
+ else
+ gins(ANOP, n, Z);
+ break;
+ }
+}
+
+int
+bcomplex(Node *n, Node *c)
+{
+
+ complex(n);
+ if(n->type != T)
+ if(tcompat(n, T, n->type, tnot))
+ n->type = T;
+ if(n->type == T) {
+ gbranch(OGOTO);
+ return 0;
+ }
+ if(c != Z && n->op == OCONST && deadheads(c))
+ return 1;
+ bool64(n);
+ boolgen(n, 1, Z);
+ return 0;
+}
=======================================
--- /dev/null
+++ /utils/cc/pswt.c Tue Apr 27 04:51:13 2010
@@ -0,0 +1,144 @@
+#include "gc.h"
+
+int
+swcmp(const void *a1, const void *a2)
+{
+ C1 *p1, *p2;
+
+ p1 = (C1*)a1;
+ p2 = (C1*)a2;
+ if(p1->val < p2->val)
+ return -1;
+ return p1->val > p2->val;
+}
+
+void
+doswit(Node *n)
+{
+ Case *c;
+ C1 *q, *iq;
+ long def, nc, i, isv;
+ int dup;
+
+ def = 0;
+ nc = 0;
+ isv = 0;
+ for(c = cases; c->link != C; c = c->link) {
+ if(c->def) {
+ if(def)
+ diag(n, "more than one default in switch");
+ def = c->label;
+ continue;
+ }
+ isv |= c->isv;
+ nc++;
+ }
+ if(isv && !typev[n->type->etype])
+ warn(n, "32-bit switch expression with 64-bit case constant");
+
+ iq = alloc(nc*sizeof(C1));
+ q = iq;
+ for(c = cases; c->link != C; c = c->link) {
+ if(c->def)
+ continue;
+ q->label = c->label;
+ if(isv)
+ q->val = c->val;
+ else
+ q->val = (long)c->val; /* cast ensures correct value for 32-bit switch
on 64-bit architecture */
+ q++;
+ }
+ qsort(iq, nc, sizeof(C1), swcmp);
+ if(debug['W'])
+ for(i=0; i<nc; i++)
+ print("case %2ld: = %.8llux\n", i, (vlong)iq[i].val);
+ dup = 0;
+ for(i=0; i<nc-1; i++)
+ if(iq[i].val == iq[i+1].val) {
+ diag(n, "duplicate cases in switch %lld", (vlong)iq[i].val);
+ dup = 1;
+ }
+ if(dup)
+ return;
+ if(def == 0) {
+ def = breakpc;
+ nbreak++;
+ }
+ swit1(iq, nc, def, n);
+}
+
+void
+casf(void)
+{
+ Case *c;
+
+ c = alloc(sizeof(*c));
+ c->link = cases;
+ cases = c;
+}
+
+long
+outlstring(ushort *s, long n)
+{
+ char buf[2];
+ int c;
+ long r;
+
+ if(suppress)
+ return nstring;
+ while(nstring & 1)
+ outstring("", 1);
+ r = nstring;
+ while(n > 0) {
+ c = *s++;
+ if(align(0, types[TCHAR], Aarg1)) {
+ buf[0] = c>>8;
+ buf[1] = c;
+ } else {
+ buf[0] = c;
+ buf[1] = c>>8;
+ }
+ outstring(buf, 2);
+ n -= sizeof(ushort);
+ }
+ return r;
+}
+
+void
+nullwarn(Node *l, Node *r)
+{
+ warn(Z, "result of operation not used");
+ if(l != Z)
+ cgen(l, Z);
+ if(r != Z)
+ cgen(r, Z);
+}
+
+void
+ieeedtod(Ieee *ieee, double native)
+{
+ double fr, ho, f;
+ int exp;
+
+ if(native < 0) {
+ ieeedtod(ieee, -native);
+ ieee->h |= 0x80000000L;
+ return;
+ }
+ if(native == 0) {
+ ieee->l = 0;
+ ieee->h = 0;
+ return;
+ }
+ fr = frexp(native, &exp);
+ f = 2097152L; /* shouldnt use fp constants here */
+ fr = modf(fr*f, &ho);
+ ieee->h = ho;
+ ieee->h &= 0xfffffL;
+ ieee->h |= (exp+1022L) << 20;
+ f = 65536L;
+ fr = modf(fr*f, &ho);
+ ieee->l = ho;
+ ieee->l <<= 16;
+ ieee->l |= (long)(fr*f);
+}
=======================================
--- /dev/null
+++ /utils/libmach/9.c Tue Apr 27 04:51:13 2010
@@ -0,0 +1,120 @@
+/*
+ * PowerPC 64 definition
+ * for...@vitanuova.com
+ */
+#include <lib9.h>
+#include <bio.h>
+#include "ureg9.h"
+#include <mach.h>
+
+
+#define REGOFF(x) offsetof(struct Ureg, x)
+
+#define R31 REGOFF(r31)
+#define FP_REG(x) (R31+4+8*(x))
+
+#define REGSIZE sizeof(struct Ureg)
+#define FPREGSIZE (8*33)
+
+Reglist power64reglist[] = {
+ {"CAUSE", REGOFF(cause), RINT|RRDONLY, 'Y'},
+ {"TRAP", REGOFF(cause), RINT|RRDONLY, 'Y'}, /* alias for acid */
+ {"MSR", REGOFF(msr), RINT|RRDONLY, 'Y'},
+ {"PC", REGOFF(pc), RINT, 'Y'},
+ {"LR", REGOFF(lr), RINT, 'Y'},
+ {"CR", REGOFF(cr), RINT, 'X'},
+ {"XER", REGOFF(xer), RINT, 'Y'},
+ {"CTR", REGOFF(ctr), RINT, 'Y'},
+ {"PC", REGOFF(pc), RINT, 'Y'},
+ {"SP", REGOFF(sp), RINT, 'Y'},
+ {"R0", REGOFF(r0), RINT, 'Y'},
+ /* R1 is SP */
+ {"R2", REGOFF(r2), RINT, 'Y'},
+ {"R3", REGOFF(r3), RINT, 'Y'},
+ {"R4", REGOFF(r4), RINT, 'Y'},
+ {"R5", REGOFF(r5), RINT, 'Y'},
+ {"R6", REGOFF(r6), RINT, 'Y'},
+ {"R7", REGOFF(r7), RINT, 'Y'},
+ {"R8", REGOFF(r8), RINT, 'Y'},
+ {"R9", REGOFF(r9), RINT, 'Y'},
+ {"R10", REGOFF(r10), RINT, 'Y'},
+ {"R11", REGOFF(r11), RINT, 'Y'},
+ {"R12", REGOFF(r12), RINT, 'Y'},
+ {"R13", REGOFF(r13), RINT, 'Y'},
+ {"R14", REGOFF(r14), RINT, 'Y'},
+ {"R15", REGOFF(r15), RINT, 'Y'},
+ {"R16", REGOFF(r16), RINT, 'Y'},
+ {"R17", REGOFF(r17), RINT, 'Y'},
+ {"R18", REGOFF(r18), RINT, 'Y'},
+ {"R19", REGOFF(r19), RINT, 'Y'},
+ {"R20", REGOFF(r20), RINT, 'Y'},
+ {"R21", REGOFF(r21), RINT, 'Y'},
+ {"R22", REGOFF(r22), RINT, 'Y'},
+ {"R23", REGOFF(r23), RINT, 'Y'},
+ {"R24", REGOFF(r24), RINT, 'Y'},
+ {"R25", REGOFF(r25), RINT, 'Y'},
+ {"R26", REGOFF(r26), RINT, 'Y'},
+ {"R27", REGOFF(r27), RINT, 'Y'},
+ {"R28", REGOFF(r28), RINT, 'Y'},
+ {"R29", REGOFF(r29), RINT, 'Y'},
+ {"R30", REGOFF(r30), RINT, 'Y'},
+ {"R31", REGOFF(r31), RINT, 'Y'},
+ {"F0", FP_REG(0), RFLT, 'F'},
+ {"F1", FP_REG(1), RFLT, 'F'},
+ {"F2", FP_REG(2), RFLT, 'F'},
+ {"F3", FP_REG(3), RFLT, 'F'},
+ {"F4", FP_REG(4), RFLT, 'F'},
+ {"F5", FP_REG(5), RFLT, 'F'},
+ {"F6", FP_REG(6), RFLT, 'F'},
+ {"F7", FP_REG(7), RFLT, 'F'},
+ {"F8", FP_REG(8), RFLT, 'F'},
+ {"F9", FP_REG(9), RFLT, 'F'},
+ {"F10", FP_REG(10), RFLT, 'F'},
+ {"F11", FP_REG(11), RFLT, 'F'},
+ {"F12", FP_REG(12), RFLT, 'F'},
+ {"F13", FP_REG(13), RFLT, 'F'},
+ {"F14", FP_REG(14), RFLT, 'F'},
+ {"F15", FP_REG(15), RFLT, 'F'},
+ {"F16", FP_REG(16), RFLT, 'F'},
+ {"F17", FP_REG(17), RFLT, 'F'},
+ {"F18", FP_REG(18), RFLT, 'F'},
+ {"F19", FP_REG(19), RFLT, 'F'},
+ {"F20", FP_REG(20), RFLT, 'F'},
+ {"F21", FP_REG(21), RFLT, 'F'},
+ {"F22", FP_REG(22), RFLT, 'F'},
+ {"F23", FP_REG(23), RFLT, 'F'},
+ {"F24", FP_REG(24), RFLT, 'F'},
+ {"F25", FP_REG(25), RFLT, 'F'},
+ {"F26", FP_REG(26), RFLT, 'F'},
+ {"F27", FP_REG(27), RFLT, 'F'},
+ {"F28", FP_REG(28), RFLT, 'F'},
+ {"F29", FP_REG(29), RFLT, 'F'},
+ {"F30", FP_REG(30), RFLT, 'F'},
+ {"F31", FP_REG(31), RFLT, 'F'},
+ {"FPSCR", FP_REG(32)+4, RFLT, 'X'},
+ { 0 }
+};
+
+ /* the machine description */
+Mach mpower64 =
+{
+ "power64",
+ MPOWER64, /* machine type */
+ power64reglist, /* register set */
+ REGSIZE, /* number of bytes in register set */
+ FPREGSIZE, /* number of bytes in FP register set */
+ "PC", /* name of PC */
+ "SP", /* name of SP */
+ "LR", /* name of link register */
+ "setSB", /* static base register name */
+ 0, /* value */
+ 0x1000, /* page size */
+ 0x80000000ULL, /* kernel base */
+ 0, /* kernel text mask */
+ 0x7FFFFFFFULL, /* user stack top */
+ 4, /* quantization of pc */
+ 8, /* szaddr */
+ 8, /* szreg */
+ 4, /* szfloat */
+ 8, /* szdouble */
+};
=======================================
--- /dev/null
+++ /utils/libmach/9obj.c Tue Apr 27 04:51:13 2010
@@ -0,0 +1,155 @@
+/*
+ * 9obj.c - identify and parse a PowerPC-64 object file
+ * for...@terzarima.net
+ */
+#include <lib9.h>
+#include <bio.h>
+#include "mach.h"
+#include "9c/9.out.h"
+#include "obj.h"
+
+typedef struct Addr Addr;
+struct Addr
+{
+ char type;
+ char sym;
+ char name;
+};
+static Addr addr(Biobuf*);
+static char type2char(int);
+static void skip(Biobuf*, int);
+
+int
+_is9(char *s)
+{
+ return (s[0]&0377) == ANAME /* ANAME */
+ && (s[1]&0377) == ANAME>>8
+ && s[2] == D_FILE /* type */
+ && s[3] == 1 /* sym */
+ && s[4] == '<'; /* name of file */
+}
+
+int
+_read9(Biobuf *bp, Prog *p)
+{
+ int as, n, c;
+ Addr a;
+
+ as = Bgetc(bp); /* as(low) */
+ if(as < 0)
+ return 0;
+ c = Bgetc(bp); /* as(high) */
+ if(c < 0)
+ return 0;
+ as |= ((c & 0xff) << 8);
+ p->kind = aNone;
+ p->sig = 0;
+ if(as == ANAME || as == ASIGNAME){
+ if(as == ASIGNAME){
+ Bread(bp, &p->sig, 4);
+ p->sig = beswal(p->sig);
+ }
+ p->kind = aName;
+ p->type = type2char(Bgetc(bp)); /* type */
+ p->sym = Bgetc(bp); /* sym */
+ n = 0;
+ for(;;) {
+ as = Bgetc(bp);
+ if(as < 0)
+ return 0;
+ n++;
+ if(as == 0)
+ break;
+ }
+ p->id = malloc(n);
+ if(p->id == 0)
+ return 0;
+ Bseek(bp, -n, 1);
+ if(Bread(bp, p->id, n) != n)
+ return 0;
+ return 1;
+ }
+ if(as == ATEXT)
+ p->kind = aText;
+ else if(as == AGLOBL)
+ p->kind = aData;
+ n = Bgetc(bp); /* reg and flag */
+ skip(bp, 4); /* lineno(4) */
+ a = addr(bp);
+ if(n & 0x40)
+ addr(bp);
+ addr(bp);
+ if(a.type != D_OREG || a.name != D_STATIC && a.name != D_EXTERN)
+ p->kind = aNone;
+ p->sym = a.sym;
+ return 1;
+}
+
+static Addr
+addr(Biobuf *bp)
+{
+ Addr a;
+ vlong off;
+ long l;
+
+ a.type = Bgetc(bp); /* a.type */
+ skip(bp,1); /* reg */
+ a.sym = Bgetc(bp); /* sym index */
+ a.name = Bgetc(bp); /* sym type */
+ switch(a.type){
+ default:
+ case D_NONE: case D_REG: case D_FREG: case D_CREG:
+ case D_FPSCR: case D_MSR:
+ break;
+ case D_SPR:
+ case D_OREG:
+ case D_CONST:
+ case D_BRANCH:
+ case D_DCONST:
+ case D_DCR:
+ l = Bgetc(bp);
+ l |= Bgetc(bp) << 8;
+ l |= Bgetc(bp) << 16;
+ l |= Bgetc(bp) << 24;
+ off = l;
+ if(a.type == D_DCONST){
+ l = Bgetc(bp);
+ l |= Bgetc(bp) << 8;
+ l |= Bgetc(bp) << 16;
+ l |= Bgetc(bp) << 24;
+ off = ((vlong)l << 32) | (off & 0xFFFFFFFF);
+ a.type = D_CONST; /* perhaps */
+ }
+ if(off < 0)
+ off = -off;
+ if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
+ _offset(a.sym, off);
+ break;
+ case D_SCONST:
+ skip(bp, NSNAME);
+ break;
+ case D_FCONST:
+ skip(bp, 8);
+ break;
+ }
+ return a;
+}
+
+static char
+type2char(int t)
+{
+ switch(t){
+ case D_EXTERN: return 'U';
+ case D_STATIC: return 'b';
+ case D_AUTO: return 'a';
+ case D_PARAM: return 'p';
+ default: return UNKNOWN;
+ }
+}
+
+static void
+skip(Biobuf *bp, int n)
+{
+ while (n-- > 0)
+ Bgetc(bp);
+}
=======================================
--- /dev/null
+++ /utils/libmach/ureg9.h Tue Apr 27 04:51:13 2010
@@ -0,0 +1,44 @@
+struct Ureg
+{
+/* 0*/ u64int cause; /* trap or interrupt vector */
+/* 8*/ u64int msr; /* SRR1 */
+/* 16*/ u64int pc; /* SRR0 */
+/* 24*/ u64int unused;
+/* 32*/ u64int lr;
+/* 36*/ u32int pad;
+/* 40*/ u32int cr;
+/* 48*/ u64int xer;
+/* 56*/ u64int ctr;
+/* 64*/ u64int r0;
+/* 72*/ union{ u64int r1; u64int sp; u64int usp; };
+/* 80*/ u64int r2;
+/* 88*/ u64int r3;
+/* 96*/ u64int r4;
+/*104*/ u64int r5;
+/*112*/ u64int r6;
+/*120*/ u64int r7;
+/*128*/ u64int r8;
+/*136*/ u64int r9;
+/*144*/ u64int r10;
+/*152*/ u64int r11;
+/*160*/ u64int r12;
+/*168*/ u64int r13;
+/*176*/ u64int r14;
+/*184*/ u64int r15;
+/*192*/ u64int r16;
+/*200*/ u64int r17;
+/*208*/ u64int r18;
+/*216*/ u64int r19;
+/*224*/ u64int r20;
+/*232*/ u64int r21;
+/*240*/ u64int r22;
+/*248*/ u64int r23;
+/*256*/ u64int r24;
+/*264*/ u64int r25;
+/*272*/ u64int r26;
+/*280*/ u64int r27;
+/*288*/ u64int r28;
+/*296*/ u64int r29;
+/*304*/ u64int r30;
+/*312*/ u64int r31;
+};
=======================================
--- /dev/null
+++ /utils/qc/machcap.c Tue Apr 27 04:51:13 2010
@@ -0,0 +1,16 @@
+#include "gc.h"
+
+/* default, like old cc */
+int
+machcap(Node *n)
+{
+ if(n == Z)
+ return 0; /* test */
+ switch(n->op){
+ case OCOMMA:
+ case OCOND:
+ case OLIST:
+ return 1;
+ }
+ return 0;
+}
=======================================
--- /CHANGES Sun Apr 25 08:18:38 2010
+++ /CHANGES Tue Apr 27 04:51:13 2010
@@ -1,3 +1,6 @@
+20100426
+ updated libmach
+ updated compiler suites (continuing)
20100425
appl/wm/wm.b shorten processing of wmctl close if client hadn't started
20100406
=======================================
--- /include/version.h Sun Apr 25 08:18:38 2010
+++ /include/version.h Tue Apr 27 04:51:13 2010
@@ -1,1 +1,1 @@
-#define VERSION "Fourth Edition (20100425)"
+#define VERSION "Fourth Edition (20100427)"
=======================================
--- /utils/0c/gc.h Fri Dec 22 13:39:35 2006
+++ /utils/0c/gc.h Tue Apr 27 04:51:13 2010
@@ -258,7 +258,7 @@
int swcmp(const void*, const void*);
void doswit(Node*);
void swit1(C1*, int, long, Node*, Node*);
-void cas(void);
+void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
long outstring(char*, long);
=======================================
--- /utils/0c/peep.c Fri Dec 22 16:30:12 2006
+++ /utils/0c/peep.c Tue Apr 27 04:51:13 2010
@@ -570,7 +570,7 @@
return 3;
return 0;
}
- return 0;
+ /* not reached */
}

int
=======================================
--- /utils/0c/sgen.c Fri Dec 22 13:39:35 2006
+++ /utils/0c/sgen.c Tue Apr 27 04:51:13 2010
@@ -154,7 +154,7 @@
if(cases == C)
diag(n, "case/default outside a switch");
if(l == Z) {
- cas();
+ casf();
cases->val = 0;
cases->def = 1;
cases->label = pc;
@@ -165,7 +165,7 @@
goto rloop;
if(l->op == OCONST)
if(typechl[l->type->etype]) {
- cas();
+ casf();
cases->val = l->vconst;
cases->def = 0;
cases->label = pc;
@@ -189,7 +189,7 @@

cn = cases;
cases = C;
- cas();
+ casf();

sbc = breakpc;
breakpc = pc;
=======================================
--- /utils/0c/swt.c Fri Dec 22 13:39:35 2006
+++ /utils/0c/swt.c Tue Apr 27 04:51:13 2010
@@ -93,7 +93,7 @@
}

void
-cas(void)
+casf(void)
{
Case *c;

=======================================
--- /utils/1c/gc.h Fri Dec 22 13:39:35 2006
+++ /utils/1c/gc.h Tue Apr 27 04:51:13 2010
@@ -280,7 +280,7 @@
int swcmp(const void*, const void*);
void doswit(int, Node*);
void swit1(C1*, int, long, int, Node*);
-void cas(void);
+void casf(void);
int bitload(Node*, int, int, int, Node*);
void bitstore(Node*, int, int, int, int, Node*);
long outstring(char*, long);
=======================================
--- /utils/1c/peep.c Fri Dec 22 13:39:35 2006
+++ /utils/1c/peep.c Tue Apr 27 04:51:13 2010
@@ -565,9 +565,6 @@
if(regtyp(a->type))
return 1;
return 0;
- if(a->type == D_AUTO || a->type == D_PARAM)
- return 1;
- return 0;
}

/*
=======================================
--- /utils/1c/sgen.c Fri Dec 22 13:39:35 2006
+++ /utils/1c/sgen.c Tue Apr 27 04:51:13 2010
@@ -131,7 +131,7 @@
if(cases == C)
diag(n, "case/default outside a switch");
if(l == Z) {
- cas();
+ casf();
cases->val = 0;
cases->def = 1;
cases->label = pc;
@@ -143,7 +143,7 @@
goto rloop;
if(l->op == OCONST)
if(typechl[l->type->etype]) {
- cas();
+ casf();
cases->val = l->vconst;
cases->def = 0;
cases->label = pc;
@@ -174,7 +174,7 @@

cn = cases;
cases = C;
- cas();
+ casf();

sbc = breakpc;
breakpc = pc;
=======================================
--- /utils/1c/swt.c Fri Dec 22 13:39:35 2006
+++ /utils/1c/swt.c Tue Apr 27 04:51:13 2010
@@ -106,7 +106,7 @@
}

void
-cas(void)
+casf(void)
{
Case *c;

=======================================
--- /utils/1l/asm.c Fri Dec 22 13:39:35 2006
+++ /utils/1l/asm.c Tue Apr 27 04:51:13 2010
@@ -1259,11 +1259,6 @@
diag("unknown addressing mode: %d in %s", t, TNAME);
return 0;

- if(!debug['a'])
- print("%P\n", p);
- diag("bad operand in %s", TNAME);
- return 0;
-
toobig:
if(!debug['a'])
print("%P\n", p);
=======================================
--- /utils/1l/obj.c Fri Dec 22 13:39:35 2006
+++ /utils/1l/obj.c Tue Apr 27 04:51:13 2010
@@ -1001,7 +1001,7 @@
pc++;
goto loop;
}
- goto loop;
+ /* not reached */

eof:
diag("%s: truncated object file in %s", pn, TNAME);
=======================================
--- /utils/2c/gc.h Fri Dec 22 13:39:35 2006
+++ /utils/2c/gc.h Tue Apr 27 04:51:13 2010
@@ -297,7 +297,7 @@
int swcmp(const void*, const void*);
void doswit(int, Node*);
void swit1(C1*, int, long, int, Node*);
-void cas(void);
+void casf(void);
int bitload(Node*, int, int, int, Node*);
void bitstore(Node*, int, int, int, int, Node*);
long outstring(char*, long);
=======================================
--- /utils/2c/peep.c Fri Dec 22 13:39:35 2006
+++ /utils/2c/peep.c Tue Apr 27 04:51:13 2010
@@ -572,9 +572,6 @@
if(regtyp(a->type))
return 1;
return 0;
- if(a->type == D_AUTO || a->type == D_PARAM)
- return 1;
- return 0;
}

/*
=======================================
--- /utils/2c/sgen.c Fri Dec 22 13:39:35 2006
+++ /utils/2c/sgen.c Tue Apr 27 04:51:13 2010
@@ -131,7 +131,7 @@
if(cases == C)
diag(n, "case/default outside a switch");
if(l == Z) {
- cas();
+ casf();
cases->val = 0;
cases->def = 1;
cases->label = pc;
@@ -143,7 +143,7 @@
goto rloop;
if(l->op == OCONST)
if(typechl[l->type->etype]) {
- cas();
+ casf();
cases->val = l->vconst;
cases->def = 0;
cases->label = pc;
@@ -174,7 +174,7 @@

cn = cases;
cases = C;
- cas();
+ casf();

sbc = breakpc;
breakpc = pc;
=======================================
--- /utils/2c/swt.c Fri Dec 22 13:39:35 2006
+++ /utils/2c/swt.c Tue Apr 27 04:51:13 2010
@@ -186,7 +186,7 @@
}

void
-cas(void)
+casf(void)
{
Case *c;

=======================================
--- /utils/2l/obj.c Fri Dec 22 13:39:35 2006
+++ /utils/2l/obj.c Tue Apr 27 04:51:13 2010
@@ -1025,7 +1025,7 @@
pc++;
goto loop;
}
- goto loop;
+ /* not reached */

eof:
diag("%s: truncated object file in %s", pn, TNAME);
=======================================
--- /utils/5c/gc.h Fri Dec 22 13:39:35 2006
+++ /utils/5c/gc.h Tue Apr 27 04:51:13 2010
@@ -266,7 +266,7 @@
int swcmp(const void*, const void*);
void doswit(Node*);
void swit1(C1*, int, long, Node*, Node*);
-void cas(void);
+void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
long outstring(char*, long);
=======================================
--- /utils/5c/peep.c Fri Dec 22 16:30:12 2006
+++ /utils/5c/peep.c Tue Apr 27 04:51:13 2010
@@ -1091,7 +1091,7 @@
return 3;
return 0;
}
- return 0;
+ /* not reached */
}

int
=======================================
--- /utils/5c/sgen.c Fri Dec 22 13:39:35 2006
+++ /utils/5c/sgen.c Tue Apr 27 04:51:13 2010
@@ -174,7 +174,7 @@
if(cases == C)
diag(n, "case/default outside a switch");
if(l == Z) {
- cas();
+ casf();
cases->val = 0;
cases->def = 1;
cases->label = pc;
@@ -185,7 +185,7 @@
goto rloop;
if(l->op == OCONST)
if(typechl[l->type->etype]) {
- cas();
+ casf();
cases->val = l->vconst;
cases->def = 0;
cases->label = pc;
@@ -209,7 +209,7 @@

cn = cases;
cases = C;
- cas();
+ casf();

sbc = breakpc;
breakpc = pc;
=======================================
--- /utils/5c/swt.c Sat Jun 27 14:08:09 2009
+++ /utils/5c/swt.c Tue Apr 27 04:51:13 2010
@@ -123,7 +123,7 @@
}

void
-cas(void)
+casf(void)
{
Case *c;

=======================================
--- /utils/5coff/5coff.c Fri Dec 22 13:39:35 2006
+++ /utils/5coff/5coff.c Tue Apr 27 04:51:13 2010
@@ -126,7 +126,7 @@
h = crackhdr(ifd, &ihdr);
if (!h || dflag){
fprint(2, "Crackhdr: %d, type: %d, name: %s\n", h, ihdr.type, ihdr.name);
- fprint(2, "txt %lux, ent %lux, txtsz %lux, dataddr %lux\n",
+ fprint(2, "txt %llux, ent %llux, txtsz %lux, dataddr %llux\n",
ihdr.txtaddr, ihdr.entry, ihdr.txtsz, ihdr.dataddr);
}
if (!h)
@@ -159,7 +159,7 @@
}
if(0){
print("H=%lux T=%lux D=%lux t=%lux d=%lux b=%lux e=%lux\n", HEADR,
INITTEXT, INITDAT, textsize, datsize, bsssize, INITENTRY);
- print("%lux %lux %lux %lux %lux %lux\n", ihdr.txtaddr, ihdr.dataddr,
ihdr.entry, ihdr.txtsz, ihdr.datsz, ihdr.bsssz);
+ print("%llux %llux %llux %lux %lux %lux\n", ihdr.txtaddr, ihdr.dataddr,
ihdr.entry, ihdr.txtsz, ihdr.datsz, ihdr.bsssz);
}

readsyms();
=======================================
--- /utils/5cv/5cv.c Fri Dec 22 13:39:35 2006
+++ /utils/5cv/5cv.c Tue Apr 27 04:51:13 2010
@@ -107,7 +107,7 @@
h = crackhdr(Ifd, &Ihdr);
if (!h || Debug){
fprint(2, "Crackhdr: %d, type: %d, name: %s\n", h, Ihdr.type, Ihdr.name);
- fprint(2, "txt %lux, ent %lux, txtsz %lux, dataddr %lux\n",
+ fprint(2, "txt %llux, ent %llux, txtsz %lux, dataddr %llux\n",
Ihdr.txtaddr, Ihdr.entry, Ihdr.txtsz, Ihdr.dataddr);
}
if (!h)
=======================================
--- /utils/5l/obj.c Sat Jun 27 14:08:09 2009
+++ /utils/5l/obj.c Tue Apr 27 04:51:13 2010
@@ -844,7 +844,7 @@
bloc += r;
c -= r;

- if(p->reg < 0 || p->reg > NREG)
+ if(p->reg > NREG)
diag("register out of range %d", p->reg);

p->link = P;
=======================================
--- /utils/5l/thumb.c Fri Dec 22 13:39:35 2006
+++ /utils/5l/thumb.c Tue Apr 27 04:51:13 2010
@@ -469,31 +469,30 @@
diag("bad op in brextra()");
c = thumbaclass(&p->to, p);
switch(p->as){
- case AB:
- if(c != C_SBRA)
- return 0;
- return 8-2+2;
- case ABL:
- if(c != C_SBRA)
- return 0;
- return 14-4+2;
- case ABX:
- if(c == C_REG || c == C_HREG)
- return 0;
+ case AB:
+ if(c != C_SBRA)
+ return 0;
+ return 8-2+2;
+ case ABL:
+ if(c != C_SBRA)
+ return 0;
+ return 14-4+2;
+ case ABX:
+ if(c == C_REG || c == C_HREG)
+ return 0;
#ifdef CALLEEBX
- diag("ABX $I in brextra");
+ diag("ABX $I in brextra");
#endif
- if(c != C_SBRA)
- return 0;
- return 14-10+2;
- default:
- if(c == C_GBRA)
- return 0;
- if(c == C_LBRA)
- return 10-4+2;
- return 10-2+2;
- }
- return 0;
+ if(c != C_SBRA)
+ return 0;
+ return 14-10+2;
+ default:
+ if(c == C_GBRA)
+ return 0;
+ if(c == C_LBRA)
+ return 10-4+2;
+ return 10-2+2;
+ }
}

#define high(r) ((r)>=8)
=======================================
--- /utils/6c/gc.h Sat May 30 17:07:21 2009
+++ /utils/6c/gc.h Tue Apr 27 04:51:13 2010
@@ -273,7 +273,7 @@
int swcmp(const void*, const void*);
void doswit(Node*);
void swit1(C1*, int, long, Node*);
-void cas(void);
+void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
long outstring(char*, long);
=======================================
--- /utils/6c/sgen.c Sat May 30 17:07:21 2009
+++ /utils/6c/sgen.c Tue Apr 27 04:51:13 2010
@@ -174,7 +174,7 @@
if(cases == C)
diag(n, "case/default outside a switch");
if(l == Z) {
- cas();
+ casf();
cases->val = 0;
cases->def = 1;
cases->label = pc;
@@ -186,7 +186,7 @@
goto rloop;
if(l->op == OCONST)
if(typechlv[l->type->etype]) {
- cas();
+ casf();
cases->val = l->vconst;
cases->def = 0;
cases->label = pc;
@@ -211,7 +211,7 @@

cn = cases;
cases = C;
- cas();
+ casf();

sbc = breakpc;
breakpc = pc;
=======================================
--- /utils/6c/swt.c Sat May 30 17:07:21 2009
+++ /utils/6c/swt.c Tue Apr 27 04:51:13 2010
@@ -96,7 +96,7 @@
}

void
-cas(void)
+casf(void)
{
Case *c;

=======================================
--- /utils/8c/gc.h Fri Dec 22 13:39:35 2006
+++ /utils/8c/gc.h Tue Apr 27 04:51:13 2010
@@ -268,7 +268,7 @@
int swcmp(const void*, const void*);
void doswit(Node*);
void swit1(C1*, int, long, Node*);
-void cas(void);
+void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
long outstring(char*, long);
=======================================
--- /utils/8c/sgen.c Fri Dec 22 13:39:35 2006
+++ /utils/8c/sgen.c Tue Apr 27 04:51:13 2010
@@ -177,7 +177,7 @@
if(cases == C)
diag(n, "case/default outside a switch");
if(l == Z) {
- cas();
+ casf();
cases->val = 0;
cases->def = 1;
cases->label = pc;
@@ -188,7 +188,7 @@
goto rloop;
if(l->op == OCONST)
if(typechl[l->type->etype]) {
- cas();
+ casf();
cases->val = l->vconst;
cases->def = 0;
cases->label = pc;
@@ -212,7 +212,7 @@

cn = cases;
cases = C;
- cas();
+ casf();

sbc = breakpc;
breakpc = pc;
=======================================
--- /utils/8c/swt.c Fri Dec 22 13:39:35 2006
+++ /utils/8c/swt.c Tue Apr 27 04:51:13 2010
@@ -89,7 +89,7 @@
}

void
-cas(void)
+casf(void)
{
Case *c;

=======================================
--- /utils/acid/acid.h Fri Dec 22 13:39:35 2006
+++ /utils/acid/acid.h Tue Apr 27 04:51:13 2010
@@ -240,7 +240,7 @@
int remote_write(int, char*, int);
int remput(struct segment*, ulong, long, char*, int);
void restartio(void);
-vlong rget(Map*, char*);
+uvlong rget(Map*, char*);
String *runenode(Rune*);
char* runcmd(char*);
int scmp(String*, String*);
@@ -251,7 +251,7 @@
String* strnode(char*);
String* strnodlen(char*, int);
char* mysystem(void);
-void trlist(Map*, ulong, ulong, Symbol*);
+void trlist(Map*, uvlong, uvlong, Symbol*);
void unwind(void);
void userinit(void);
void varreg(void);
=======================================
--- /utils/acid/builtin.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/builtin.c Tue Apr 27 04:51:13 2010
@@ -342,7 +342,7 @@
{
int n, i;
Node res;
- ulong f[10];
+ uvlong f[10];
List **tail, *l;

if(args == 0)
@@ -369,7 +369,7 @@
{
int n;
Node res;
- ulong bounds[2];
+ uvlong bounds[2];
List *l;

if(args == 0)
=======================================
--- /utils/acid/exec.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/exec.c Tue Apr 27 04:51:13 2010
@@ -210,8 +210,8 @@
indir(Map *m, ulong addr, char fmt, Node *r)
{
int i;
- long ival;
- vlong vval;
+ ulong ival;
+ uvlong vval;
int ret;
uchar cval;
ushort sval;
=======================================
--- /utils/acid/expr.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/expr.c Tue Apr 27 04:51:13 2010
@@ -153,7 +153,7 @@
{
char *p;
Node *lp;
- long ival;
+ uvlong ival;
Frtype *f;

p = n->sym->name;
=======================================
--- /utils/acid/list.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/list.c Tue Apr 27 04:51:13 2010
@@ -194,7 +194,7 @@
listlocals(Map *map, Symbol *fn, ulong fp)
{
int i;
- long val;
+ uvlong val;
Symbol s;
List **tail, *l2;

@@ -208,7 +208,7 @@
if(s.name[0] == '.')
continue;

- if(get4(map, fp-s.value, &val) > 0) {
+ if(geta(map, fp-s.value, &val) > 0) {
*tail = listvar(s.name, val);
tail = &(*tail)->next;
}
@@ -221,7 +221,7 @@
{
int i;
Symbol s;
- long v;
+ uvlong v;
List **tail, *l2;

l2 = 0;
@@ -232,7 +232,7 @@
if (s.class != CPARAM)
continue;

- if(get4(map, fp+s.value, &v) > 0) {
+ if(geta(map, fp+s.value, &v) > 0) {
*tail = listvar(s.name, v);
tail = &(*tail)->next;
}
@@ -241,7 +241,7 @@
}

void
-trlist(Map *map, ulong pc, ulong sp, Symbol *sym)
+trlist(Map *map, uvlong pc, uvlong sp, Symbol *sym)
{
List *q, *l;

=======================================
--- /utils/acid/main.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/main.c Tue Apr 27 04:51:13 2010
@@ -196,8 +196,7 @@

unwind();
}
- Bputc(bout, '\n');
- exits(0);
+ /* not reached */
}

static int
=======================================
--- /utils/acid/os-Plan9.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/os-Plan9.c Tue Apr 27 04:51:13 2010
@@ -54,7 +54,7 @@
}
free(w);
}
- return nil;
+ /* not reached */
}

char *
@@ -78,7 +78,7 @@
default:
return waitfor(pid);
}
- return 0;
+ /* not reached */
}

void
=======================================
--- /utils/acid/util.c Fri Dec 22 13:39:35 2006
+++ /utils/acid/util.c Tue Apr 27 04:51:13 2010
@@ -35,7 +35,7 @@
}
}
if(renamed && !quiet)
- print("\t%s=%s %c/%lux\n", s->name, buf, s->type, s->value);
+ print("\t%s=%s %c/%llux\n", s->name, buf, s->type, s->value);
if(l == 0)
l = enter(buf, Tid);
return l;
@@ -193,12 +193,12 @@
}
}

-vlong
+uvlong
rget(Map *map, char *reg)
{
Lsym *s;
- long x;
- vlong v;
+ ulong x;
+ uvlong v;
int ret;

s = look(reg);
@@ -206,7 +206,7 @@
fatal("rget: %s\n", reg);

if(s->v->vstore.fmt == 'Y')
- ret = get8(map, (long)s->v->vstore.u0.sival, &v);
+ ret = get8(map, s->v->vstore.u0.sival, &v);
else {
ret = get4(map, (long)s->v->vstore.u0.sival, &x);
v = x;
=======================================
--- /utils/c2l/com.c Fri Dec 22 13:39:35 2006
+++ /utils/c2l/com.c Tue Apr 27 04:51:13 2010
@@ -599,6 +599,7 @@
if(n->type->etype == TARRAY)
n->type = typ1(TIND, n->type->link);
return 0;
+#ifdef WHATEVA
if(tlvalue(n))
goto bad;
l = new1(OXXX, Z, Z);
@@ -611,6 +612,7 @@
n->type = typ1(TIND, l->type);
n->type->width = types[TIND]->width;
return 0;
+#endif

bad:
n->type = T;
=======================================
--- /utils/c2l/dcl.c Fri Dec 22 13:39:35 2006
+++ /utils/c2l/dcl.c Tue Apr 27 04:51:13 2010
@@ -926,7 +926,7 @@
return 1;
}
}
- return 0;
+ /* not reached */
}

ulong
=======================================
--- /utils/c2l/lex.c Fri Dec 22 13:39:35 2006
+++ /utils/c2l/lex.c Tue Apr 27 04:51:13 2010
@@ -951,7 +951,7 @@
}
c = GETC();
}
- return 0;
+ /* not reached */
}

void
=======================================
--- /utils/c2l/sub.c Fri Dec 22 13:39:35 2006
+++ /utils/c2l/sub.c Tue Apr 27 04:51:13 2010
@@ -263,10 +263,12 @@
int
stcompat(Node *n, Type *t1, Type *t2, long ttab[])
{
+ USED(n); USED(t1); USED(t2); USED(ttab[0]);
+ return 0;
+#ifdef WHATEVA
int i;
ulong b;

- return 0;
i = 0;
if(t2 != T)
i = t2->etype;
@@ -286,6 +288,7 @@
return 0;
}
return 1;
+#endif
}

int
=======================================
***Additional files exist in this changeset.***

==============================================================================
Revision: 72a88af60e
Author: for...@vitanuova.com
Date: Tue Apr 27 04:54:05 2010
Log: 20100427-1254
http://code.google.com/p/inferno-npe/source/detail?r=72a88af60e

Deleted:
/utils/libmach/mach.h

=======================================
--- /utils/libmach/mach.h Fri Dec 22 13:39:35 2006
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Architecture-dependent application data
- */
-#include "a.out.h"
-/*
- * Supported architectures:
- * mips,
- * 68020,
- * i386,
- * amd64,
- * sparc,
- * mips2 (R4000)
- * arm
- */
-enum
-{
- MMIPS, /* machine types */
- MSPARC,
- M68020,
- MI386,
- MI960, /* retired */
- M3210, /* retired */
- MMIPS2,
- NMIPS2,
- M29000, /* retired */
- MARM,
- MPOWER,
-
- /* types of executables */
- FNONE = 0, /* unidentified */
- FMIPS, /* v.out */
- FMIPSB, /* mips bootable */
- FSPARC, /* k.out */
- FSPARCB, /* Sparc bootable */
- F68020, /* 2.out */
- F68020B, /* 68020 bootable */
- FNEXTB, /* Next bootable */
- FI386, /* 8.out */
- FI386B, /* I386 bootable */
- FI960, /* retired */
- FI960B, /* retired */
- F3210, /* retired */
- FMIPS2BE, /* 4.out */
- F29000, /* retired */
- FARM, /* 5.out */
- FARMB, /* ARM bootable */
- FPOWER, /* q.out */
- FPOWERB, /* power pc bootable */
- FMIPS2LE, /* 4k little endian */
-
- ANONE = 0, /* dissembler types */
- AMIPS,
- AMIPSCO, /* native mips */
- ASPARC,
- ASUNSPARC, /* native sun */
- A68020,
- AI386,
- AI8086, /* oh god */
- AI960, /* retired */
- A29000,
- AARM,
- APOWER,
- /* object file types */
- Obj68020 = 0, /* .2 */
- ObjSparc, /* .k */
- ObjMips, /* .v */
- Obj386, /* .8 */
- Obj960, /* retired */
- Obj3210, /* .x */
- ObjMips2, /* .4 */
- Obj29000, /* retired */
- ObjArm, /* .5 */
- ObjPower, /* .q */
- ObjMips2le, /* .0 */
- Maxobjtype,
-
- CNONE = 0, /* symbol table classes */
- CAUTO,
- CPARAM,
- CSTAB,
- CTEXT,
- CDATA,
- CANY /* to look for any class */
-};
-
-typedef struct Map Map;
-typedef struct Symbol Symbol;
-typedef struct Reglist Reglist;
-typedef struct Mach Mach;
-typedef struct Machdata Machdata;
-typedef struct segment segment;
-
-typedef int (*Rsegio)(segment*, ulong, long, char*, int);
-
-/*
- * Structure to map a segment to a position in a file
- */
-struct Map {
- int nsegs; /* number of segments */
- struct segment { /* per-segment map */
- char *name; /* the segment name */
- int fd; /* file descriptor */
- int inuse; /* in use - not in use */
- ulong b; /* base */
- ulong e; /* end */
- ulong f; /* offset within file */
- Rsegio mget; /* special get if not 0 */
- Rsegio mput; /* special put if not 0 */
- } seg[1]; /* actually n of these */
-};
-
-
-
-/*
- * Internal structure describing a symbol table entry
- */
-struct Symbol {
- void *handle; /* used internally - owning func */
- /*struct {*/
- char *name;
- long value; /* address or stack offset */
- char type; /* as in a.out.h */
- char class; /* as above */
- /*};*/
-};
-
-/*
- * machine register description
- */
-struct Reglist {
- char *rname; /* register name */
- short roffs; /* offset in u-block */
- char rflags; /* INTEGER/FLOAT, WRITABLE */
- char rformat; /* print format: 'x', 'X', 'f', '8', '3', 'Y', 'W' */
-};
-
-enum { /* bits in rflags field */
- RINT = (0<<0),
- RFLT = (1<<0),
- RRDONLY = (1<<1)
-};
-/*
- * Machine-dependent data is stored in two structures:
- * Mach - miscellaneous general parameters
- * Machdata - jump vector of service functions used by debuggers
- *
- * Mach is defined in 2.c, 4.c, v.c, k.c, 8.c, 6.c and set in executable.c
- *
- * Machdata is defined in 2db.c, 4db.c, vdb.c, kdb.c, 8db.c, and 6db.c
- * and set in the debugger startup.
- */
-
-
-struct Mach{
- char *name;
- int mtype; /* machine type code */
- Reglist *reglist; /* register set */
- ulong regsize; /* sizeof registers in bytes*/
- ulong fpregsize; /* sizeof fp registers in bytes*/
- char *pc; /* pc name */
- char *sp; /* sp name */
- char *link; /* link register name */
- char *sbreg; /* static base register name */
- ulong sb; /* static base register value */
- int pgsize; /* page size */
- ulong kbase; /* kernel base address */
- ulong ktmask; /* ktzero = kbase & ~ktmask */
- int pcquant; /* quantization of pc */
- int szaddr; /* sizeof(void*) */
- int szreg; /* sizeof(register) */
- int szfloat; /* sizeof(float) */
- int szdouble; /* sizeof(double) */
-};
-
-extern Mach *mach; /* Current machine */
-
-typedef vlong (*Rgetter)(Map*, char*);
-typedef void (*Tracer)(Map*, ulong, ulong, Symbol*);
-
-struct Machdata { /* Machine-dependent debugger support */
- uchar bpinst[4]; /* break point instr. */
- short bpsize; /* size of break point instr. */
-
- ushort (*swab)(ushort); /* short to local byte order */
- long (*swal)(long); /* long to local byte order */
- vlong (*swav)(vlong); /* vlong to local byte order */
- int (*ctrace)(Map*, ulong, ulong, ulong, Tracer); /* C traceback */
- ulong (*findframe)(Map*, ulong, ulong, ulong, ulong);/* frame finder */
- char* (*excep)(Map*, Rgetter); /* last exception */
- ulong (*bpfix)(ulong); /* breakpoint fixup */
- int (*sftos)(char*, int, void*); /* single precision float */
- int (*dftos)(char*, int, void*); /* double precision float */
- int (*foll)(Map*, ulong, Rgetter, ulong*); /* follow set */
- int (*das)(Map*, ulong, char, char*, int); /* symbolic disassembly */
- int (*hexinst)(Map*, ulong, char*, int); /* hex disassembly */
- int (*instsize)(Map*, ulong); /* instruction size */
-};
-
-/*
- * Common a.out header describing all architectures
- */
-typedef struct Fhdr
-{
- char *name; /* identifier of executable */
- short type; /* file type - see codes above*/
- short hdrsz; /* size of this header */
- long magic; /* magic number */
- long txtaddr; /* text address */
- long entry; /* entry point */
- long txtsz; /* text size */
- long txtoff; /* start of text in file */
- long dataddr; /* start of data segment */
- long datsz; /* size of data seg */
- long datoff; /* offset to data seg in file */
- long bsssz; /* size of bss */
- long symsz; /* size of symbol table */
- long symoff; /* offset of symbol table in file */
- long sppcsz; /* size of sp-pc table */
- long sppcoff; /* offset of sp-pc table in file */
- long lnpcsz; /* size of line number-pc table */
- long lnpcoff; /* size of line number-pc table */
-} Fhdr;
-
-extern int asstype; /* dissembler type - machdata.c */
-extern Machdata *machdata; /* jump vector - machdata.c */
-
-Map* attachproc(int, int, int, Fhdr*);
-Map* attachremt(int, Fhdr*);
-int beieee80ftos(char*, int, void*);
-int beieeesftos(char*, int, void*);
-int beieeedftos(char*, int, void*);
-ushort beswab(ushort);
-long beswal(long);
-vlong beswav(vlong);
-int cisctrace(Map*, ulong, ulong, ulong, Tracer);
-ulong ciscframe(Map*, ulong, ulong, ulong, ulong);
-int crackhdr(int fd, Fhdr*);
-long file2pc(char*, ulong);
-int fileelem(Sym**, uchar *, char*, int);
-int fileline(char*, int, ulong);
-int filesym(int, char*, int);
-int findlocal(Symbol*, char*, Symbol*);
-int findseg(Map*, char*);
-int findsym(long, int, Symbol *);
-int fnbound(long, ulong*);
-int fpformat(Map*, Reglist*, char*, int, int);
-int get1(Map*, ulong, uchar*, int);
-int get2(Map*, ulong, ushort*);
-int get4(Map*, ulong, long*);
-int get8(Map*, ulong, vlong*);
-int getauto(Symbol*, int, int, Symbol*);
-Sym* getsym(int);
-int globalsym(Symbol *, int);
-char* _hexify(char*, ulong, int);
-int ieeesftos(char*, int, ulong);
-int ieeedftos(char*, int, ulong, ulong);
-int isar(Biobuf*);
-int leieee80ftos(char*, int, void*);
-int leieeesftos(char*, int, void*);
-int leieeedftos(char*, int, void*);
-ushort leswab(ushort);
-long leswal(long);
-vlong leswav(vlong);
-long line2addr(ulong, ulong, ulong);
-Map* loadmap(Map*, int, Fhdr*);
-int localaddr(Map*, char*, char*, long*, Rgetter);
-int localsym(Symbol*, int);
-int lookup(char*, char*, Symbol*);
-void machbytype(int);
-int machbyname(char*);
-int nextar(Biobuf*, int, char*);
-Map* newmap(Map*, int);
-void objtraverse(void(*)(Sym*, void*), void*);
-int objtype(Biobuf*, char**);
-long pc2sp(ulong);
-long pc2line(ulong);
-int put1(Map*, ulong, uchar*, int);
-int put2(Map*, ulong, ushort);
-int put4(Map*, ulong, long);
-int put8(Map*, ulong, vlong);
-int readar(Biobuf*, int, int, int);
-int readobj(Biobuf*, int);
-struct segment* reloc(Map*, ulong, long*);
-ulong riscframe(Map*, ulong, ulong, ulong, ulong);
-int risctrace(Map*, ulong, ulong, ulong, Tracer);
-int setmap(Map*, int, ulong, ulong, ulong, char*);
-void setmapio(Map*, int, Rsegio, Rsegio);
-Sym* symbase(long*);
-int syminit(int, Fhdr*);
-int symoff(char*, int, long, int);
-void textseg(ulong, Fhdr*);
-int textsym(Symbol*, int);
-void unusemap(Map*, int);
-

==============================================================================
Revision: 979057b3b2
Author: for...@vitanuova.com
Date: Tue Apr 27 04:55:38 2010
Log: 20100427-1255
http://code.google.com/p/inferno-npe/source/detail?r=979057b3b2

Modified:
/utils/libmach/q.c

=======================================
--- /utils/libmach/q.c Tue Apr 27 04:51:13 2010
+++ /utils/libmach/q.c Tue Apr 27 04:55:38 2010
@@ -2,7 +2,7 @@
* PowerPC definition
* for...@terzarima.net
*/
-#include <u.h>
+#include <lib9.h>
#include <bio.h>
#include "uregq.h"
#include "mach.h"

==============================================================================
Revision: 6f4870cb12
Author: for...@vitanuova.com
Date: Tue Apr 27 04:56:56 2010
Log: 20100427-1256
http://code.google.com/p/inferno-npe/source/detail?r=6f4870cb12

Modified:
/utils/libmach/executable.c

=======================================
--- /utils/libmach/executable.c Tue Apr 27 04:51:13 2010
+++ /utils/libmach/executable.c Tue Apr 27 04:56:56 2010
@@ -1,6 +1,6 @@
#include <lib9.h>
#include <bio.h>
-#include <bootexec.h>
+#include "bootexec.h"
#include "mach.h"
#include "elf.h"


==============================================================================
Revision: a1da266fe4
Author: for...@vitanuova.com
Date: Tue Apr 27 04:58:01 2010
Log: 20100427-1257
http://code.google.com/p/inferno-npe/source/detail?r=a1da266fe4

Modified:
/utils/libmach/executable.c

=======================================
--- /utils/libmach/executable.c Tue Apr 27 04:56:56 2010
+++ /utils/libmach/executable.c Tue Apr 27 04:58:01 2010
@@ -407,11 +407,12 @@
}

static int
-commonllp64(int, Fhdr *fp, ExecHdr *hp)
+commonllp64(int fd, Fhdr *fp, ExecHdr *hp)
{
long pgsize;
uvlong entry;

+ USED(fd);
hswal(&hp->e, sizeof(Exec)/sizeof(long), beswal);
if(!(hp->e.exec.magic & HDR_MAGIC))
return 0;

==============================================================================
Revision: ce8244847b
Author: for...@vitanuova.com
Date: Tue Apr 27 04:59:28 2010
Log: 20100427-1259
http://code.google.com/p/inferno-npe/source/detail?r=ce8244847b

Deleted:
/utils/cc/machcap.c

=======================================
--- /utils/cc/machcap.c Fri Dec 22 13:39:35 2006
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "cc.h"
-
-/* default, like old cc */
-int
-machcap(Node *n)
-{
- USED(n);
- return 0;
-}

==============================================================================
Revision: d2f8ad93d2
Author: for...@vitanuova.com
Date: Tue Apr 27 05:00:13 2010
Log: 20100427-1300
http://code.google.com/p/inferno-npe/source/detail?r=d2f8ad93d2

Added:
/utils/cc/omachcap.c

=======================================
--- /dev/null
+++ /utils/cc/omachcap.c Tue Apr 27 05:00:13 2010
@@ -0,0 +1,9 @@
+#include "cc.h"
+
+/* default, like old cc */
+int
+machcap(Node *n)
+{
+ USED(n);
+ return 0;
+}

==============================================================================
Revision: 0ff17dc710
Author: for...@vitanuova.com
Date: Tue Apr 27 05:05:45 2010
Log: 20100427-1305
http://code.google.com/p/inferno-npe/source/detail?r=0ff17dc710

Modified:
/utils/cc/cc.y
/utils/cc/lex.c

=======================================
--- /utils/cc/cc.y Fri Dec 22 13:39:35 2006
+++ /utils/cc/cc.y Tue Apr 27 05:05:45 2010
@@ -35,7 +35,7 @@
%type <node> xdecor xdecor2 labels label ulstmnt
%type <node> adlist edecor tag qual qlist
%type <node> abdecor abdecor1 abdecor2 abdecor3
-%type <node> zexpr lexpr init ilist
+%type <node> zexpr lexpr init ilist forexpr

%left ';'
%left ','
@@ -62,6 +62,7 @@
%token LIF LINT LLONG LREGISTER LRETURN LSHORT LSIZEOF LUSED
%token LSTATIC LSTRUCT LSWITCH LTYPEDEF LTYPESTR LUNION LUNSIGNED
%token LWHILE LVOID LENUM LSIGNED LCONSTNT LVOLATILE LSET LSIGNOF
+%token LRESTRICT LINLINE
%%
prog:
| prog xdecl
@@ -146,26 +147,13 @@
* automatic declarator
*/
adecl:
- {
- $$ = Z;
- }
-| adecl ctlist ';'
+ ctlist ';'
{
$$ = dodecl(adecl, lastclass, lasttype, Z);
- if($1 != Z)
- if($$ != Z)
- $$ = new(OLIST, $1, $$);
- else
- $$ = $1;
- }
-| adecl ctlist adlist ';'
- {
- $$ = $1;
- if($3 != Z) {
- $$ = $3;
- if($1 != Z)
- $$ = new(OLIST, $1, $3);
- }
+ }
+| ctlist adlist ';'
+ {
+ $$ = $2;
}

adlist:
@@ -371,11 +359,11 @@
}

block:
- '{' adecl slist '}'
- {
- $$ = invert($3);
- if($2 != Z)
- $$ = new(OLIST, $2, $$);
+ '{' slist '}'
+ {
+ $$ = invert($2);
+ // if($2 != Z)
+ // $$ = new(OLIST, $2, $$);
if($$ == Z)
$$ = new(OLIST, Z, Z);
}
@@ -384,6 +372,10 @@
{
$$ = Z;
}
+| slist adecl
+ {
+ $$ = new(OLIST, $1, $2);
+ }
| slist stmnt
{
$$ = new(OLIST, $1, $2);
@@ -420,6 +412,13 @@
{
$$ = new(OLIST, $1, $2);
}
+
+forexpr:
+ zcexpr
+| ctlist adlist
+ {
+ $$ = $2;
+ }

ulstmnt:
zcexpr ';'
@@ -448,9 +447,16 @@
if($7 == Z)
warn($3, "empty else body");
}
-| LFOR '(' zcexpr ';' zcexpr ';' zcexpr ')' stmnt
- {
- $$ = new(OFOR, new(OLIST, $5, new(OLIST, $3, $7)), $9);
+| { markdcl(); } LFOR '(' forexpr ';' zcexpr ';' zcexpr ')' stmnt
+ {
+ $$ = revertdcl();
+ if($$){
+ if($4)
+ $4 = new(OLIST, $$, $4);
+ else
+ $4 = $$;
+ }
+ $$ = new(OFOR, new(OLIST, $6, new(OLIST, $4, $8)), $10);
}
| LWHILE '(' cexpr ')' stmnt
{
@@ -1129,10 +1135,12 @@
| LTYPEDEF { $$ = BTYPEDEF; }
| LTYPESTR { $$ = BTYPESTR; }
| LREGISTER { $$ = BREGISTER; }
+| LINLINE { $$ = 0; }

gname: /* garbage words */
LCONSTNT { $$ = BCONSTNT; }
| LVOLATILE { $$ = BVOLATILE; }
+| LRESTRICT { $$ = 0; }

name:
LNAME
=======================================
--- /utils/cc/lex.c Tue Apr 27 04:51:13 2010
+++ /utils/cc/lex.c Tue Apr 27 05:05:45 2010
@@ -203,8 +203,8 @@
if((debug['a'] || debug['Z']) && !debug['n']) {
if (first) {
outfile = 0;
- Binit(&outbuf, dup(1, -1), OWRITE);
- dup(2, 1);
+ Binit(&outbuf, mydup(1, -1), OWRITE);
+ mydup(2, 1);
}
} else {
c = mycreat(outfile, 0664);

==============================================================================
Revision: a9d7526ab4
Author: for...@vitanuova.com
Date: Tue Apr 27 05:10:29 2010
Log: 20100427-1310
http://code.google.com/p/inferno-npe/source/detail?r=a9d7526ab4

Modified:
/utils/qc/q.out.h

=======================================
--- /utils/qc/q.out.h Tue Apr 27 04:51:13 2010
+++ /utils/qc/q.out.h Tue Apr 27 05:10:29 2010
@@ -394,21 +394,18 @@
AFXNMSUB,
AFXCPNMSUB,
AFXCSNMSUB,
- AFPMOVD,
AFPABS,
AFPNEG,
AFPRSP,
AFPNABS,
- AFSMOVD,
AFSCMP,
AFSABS,
AFSNEG,
AFSNABS,
- AFXMOVD,
AFPCTIW,
AFPCTIWZ,
- AFSMOVP,
- AFPMOVS,
+ AFMOVSPD,
+ AFMOVPSD,
AFXCPNPMA,
AFXCSNPMA,
AFXCPNSMA,
@@ -419,19 +416,19 @@
AFXCXNMS,

/* parallel, cross, and secondary load and store */
- AFMOVSS,
- AFMOVSSU,
- AFMOVSD,
- AFMOVSDU,
- AFMOVXS,
- AFMOVSXU,
- AFMOVXD,
- AFMOVXDU,
- AFMOVPS,
- AFMOVPSU,
- AFMOVPD,
- AFMOVPDU,
- AFMOVPIW,
+ AFSMOVS,
+ AFSMOVSU,
+ AFSMOVD,
+ AFSMOVDU,
+ AFXMOVS,
+ AFXMOVSU,
+ AFXMOVD,
+ AFXMOVDU,
+ AFPMOVS,
+ AFPMOVSU,
+ AFPMOVD,
+ AFPMOVDU,
+ AFPMOVIW,

ALAST
};

==============================================================================
Revision: ea2b992c95
Author: for...@vitanuova.com
Date: Tue Apr 27 05:16:18 2010
Log: 20100427-1316
http://code.google.com/p/inferno-npe/source/detail?r=ea2b992c95

Modified:
/utils/qc/enam.c
/utils/qc/list.c
/utils/qc/machcap.c
/utils/qc/swt.c

=======================================
--- /utils/qc/enam.c Tue Apr 27 04:51:13 2010
+++ /utils/qc/enam.c Tue Apr 27 05:16:18 2010
@@ -346,21 +346,18 @@
"FXNMSUB",
"FXCPNMSUB",
"FXCSNMSUB",
- "FPMOVD",
"FPABS",
"FPNEG",
"FPRSP",
"FPNABS",
- "FSMOVD",
"FSCMP",
"FSABS",
"FSNEG",
"FSNABS",
- "FXMOVD",
"FPCTIW",
"FPCTIWZ",
- "FSMOVP",
- "FPMOVS",
+ "FMOVSPD",
+ "FMOVPSD",
"FXCPNPMA",
"FXCSNPMA",
"FXCPNSMA",
@@ -369,18 +366,18 @@
"FXCXNSMA",
"FXCXMA",
"FXCXNMS",
- "FMOVSS",
- "FMOVSSU",
- "FMOVSD",
- "FMOVSDU",
- "FMOVXS",
- "FMOVSXU",
- "FMOVXD",
- "FMOVXDU",
- "FMOVPS",
- "FMOVPSU",
- "FMOVPD",
- "FMOVPDU",
- "FMOVPIW",
+ "FSMOVS",
+ "FSMOVSU",
+ "FSMOVD",
+ "FSMOVDU",
+ "FXMOVS",
+ "FXMOVSU",
+ "FXMOVD",
+ "FXMOVDU",
+ "FPMOVS",
+ "FPMOVSU",
+ "FPMOVD",
+ "FPMOVDU",
+ "FPMOVIW",
"LAST",
};
=======================================
--- /utils/qc/list.c Tue Apr 27 04:51:13 2010
+++ /utils/qc/list.c Tue Apr 27 05:16:18 2010
@@ -42,7 +42,7 @@
int
Pconv(Fmt *fp)
{
- char str[STRINGSZ];
+ char str[STRINGSZ], *s;
Prog *p;
int a;

@@ -50,17 +50,16 @@
a = p->as;
if(a == ADATA)
sprint(str, " %A %D/%d,%D", a, &p->from, p->reg, &p->to);
- else
- if(p->as == ATEXT)
+ else if(p->as == ATEXT)
sprint(str, " %A %D,%d,%D", a, &p->from, p->reg, &p->to);
- else
- if(p->reg == NREG)
- sprint(str, " %A %D,%D", a, &p->from, &p->to);
- else
- if(p->from.type != D_FREG)
- sprint(str, " %A %D,R%d,%D", a, &p->from, p->reg, &p->to);
- else
- sprint(str, " %A %D,F%d,%D", a, &p->from, p->reg, &p->to);
+ else {
+ s = seprint(str, str+sizeof(str), " %A %D", a, &p->from);
+ if(p->reg != NREG)
+ s = seprint(s, str+sizeof(str), ",%c%d",
p->from.type==D_FREG? 'F': 'R', p->reg);
+ if(p->from3.type != D_NONE)
+ s = seprint(s, str+sizeof(str), ",%D", &p->from3);
+ seprint(s, s+sizeof(str), ",%D", &p->to);
+ }
return fmtstrcpy(fp, str);
}

@@ -196,10 +195,25 @@
char str[STRINGSZ];
Adr *a;
Sym *s;
+ int i, l, b, n;

a = va_arg(fp->args, Adr*);
s = a->sym;
if(s == S) {
+ if(a->offset > 64 || -a->offset > 64) {
+ n = 0;
+ l = a->offset & 1;
+ for(i=0; i<32; i++){
+ b = (a->offset >> i) & 1;
+ if(b != l)
+ n++;
+ l = b;
+ }
+ if(n < 2) {
+ sprint(str, "%#lux", a->offset);
+ goto out;
+ }
+ }
sprint(str, "%ld", a->offset);
goto out;
}
=======================================
--- /utils/qc/machcap.c Tue Apr 27 04:51:13 2010
+++ /utils/qc/machcap.c Tue Apr 27 05:16:18 2010
@@ -1,16 +1,98 @@
#include "gc.h"

-/* default, like old cc */
int
machcap(Node *n)
{
if(n == Z)
- return 0; /* test */
+ return 1; /* test */
switch(n->op){
+
+ case OADD:
+ case OAND:
+ case OOR:
+ case OSUB:
+ case OXOR:
+ if(typev[n->left->type->etype])
+ return 1;
+ break;
+
+ case OMUL:
+ case OLMUL:
+ case OASMUL:
+ case OASLMUL:
+ return 1;
+
+ case OLSHR:
+ case OASHR:
+ case OASHL:
+ case OASASHL:
+ case OASASHR:
+ case OASLSHR:
+ return 1;
+
+ case OCAST:
+ if(typev[n->type->etype]) {
+ if(!typefd[n->left->type->etype])
+ return 1;
+ } else if(!typefd[n->type->etype]) {
+ if(typev[n->left->type->etype])
+ return 1;
+ }
+ break;
+
case OCOMMA:
case OCOND:
case OLIST:
+ case OANDAND:
+ case OOROR:
+ case ONOT:
return 1;
+
+ case OCOM:
+ case ONEG:
+ if(typechl[n->left->type->etype])
+ return 1;
+ if(typev[n->left->type->etype])
+ return 1;
+ return 0;
+
+ case OASADD:
+ case OASSUB:
+ case OASAND:
+ case OASOR:
+ case OASXOR:
+ return 1;
+
+ case OPOSTINC:
+ case OPOSTDEC:
+ case OPREINC:
+ case OPREDEC:
+ return 1;
+
+ case OEQ:
+ case ONE:
+ case OLE:
+ case OGT:
+ case OLT:
+ case OGE:
+ case OHI:
+ case OHS:
+ case OLO:
+ case OLS:
+ return 1;
+
+ case ODIV:
+ case OLDIV:
+ case OLMOD:
+ case OMOD:
+ return 0;
+
+ case OASDIV:
+ case OASLDIV:
+ case OASLMOD:
+ case OASMOD:
+ return 0;
+
}
return 0;
}
=======================================
--- /utils/qc/swt.c Tue Apr 27 04:51:13 2010
+++ /utils/qc/swt.c Tue Apr 27 05:16:18 2010
@@ -1,6 +1,5 @@
#include "gc.h"

-int hasdoubled;
static int doubleflag;

void
@@ -370,12 +369,16 @@
bf[0] = p->as;
bf[1] = p->as>>8;
bf[2] = p->reg;
+ if(p->from3.type != D_NONE)
+ bf[2] |= 0x40;
l = p->lineno;
bf[3] = l;
bf[4] = l>>8;
bf[5] = l>>16;
bf[6] = l>>24;
bp = zaddr(bf+7, &p->from, sf);
+ if(bf[2] & 0x40)
+ bp = zaddr(bp, &p->from3, 0);
bp = zaddr(bp, &p->to, st);
Bwrite(b, bf, bp-bf);
}

==============================================================================
Revision: 5a3230d872
Author: for...@vitanuova.com
Date: Tue Apr 27 05:20:36 2010
Log: 20100427-1320
http://code.google.com/p/inferno-npe/source/detail?r=5a3230d872

Modified:
/utils/qc/gc.h
/utils/qc/mkfile

=======================================
--- /utils/qc/gc.h Tue Apr 27 04:51:13 2010
+++ /utils/qc/gc.h Tue Apr 27 05:20:36 2010
@@ -267,7 +267,7 @@
/*
* swt.c
*/
-int swcmp(void*, void*);
+int swcmp(const void*, const void*);
void doswit(Node*);
void swit1(C1*, int, long, Node*);
void swit2(C1*, int, long, Node*, Node*);
=======================================
--- /utils/qc/mkfile Tue Apr 27 04:51:13 2010
+++ /utils/qc/mkfile Tue Apr 27 05:20:36 2010
@@ -32,7 +32,7 @@
mk $MKFLAGS clean

%.$O: ../cc/%.c
- $CC $CFLAGS ../cc/$stem.c
+ $CC $CFLAGS -I. ../cc/$stem.c

#enam.c: q.out.h
# rc mkenam

==============================================================================
Revision: 556e8957ba
Author: for...@vitanuova.com
Date: Tue Apr 27 05:21:20 2010
Log: 20100427-1321
http://code.google.com/p/inferno-npe/source/detail?r=556e8957ba

Modified:
/utils/qc/peep.c

=======================================
--- /utils/qc/peep.c Tue Apr 27 04:51:13 2010
+++ /utils/qc/peep.c Tue Apr 27 05:21:20 2010
@@ -618,7 +618,7 @@

default:
if(debug['P'])
- print(" (???)");
+ print(" (?)");
return 2;



==============================================================================
Revision: 6cb5b0cde4
Author: for...@vitanuova.com
Date: Tue Apr 27 05:24:29 2010
Log: 20100427-1324
http://code.google.com/p/inferno-npe/source/detail?r=6cb5b0cde4

Modified:
/utils/libmach/kdb.c

=======================================
--- /utils/libmach/kdb.c Tue Apr 27 04:51:13 2010
+++ /utils/libmach/kdb.c Tue Apr 27 05:24:29 2010
@@ -84,16 +84,16 @@
}

/* Sparc disassembler and related functions */
+typedef struct instr Instr;

struct opcode {
char *mnemonic;
- void (*f)(struct instr*, char*);
+ void (*f)(Instr*, char*);
int flag;
};

static char FRAMENAME[] = ".frame";

-typedef struct instr Instr;

struct instr {
uchar op; /* bits 31-30 */

==============================================================================
Revision: f9af16a874
Author: for...@vitanuova.com
Date: Tue Apr 27 05:33:26 2010
Log: 20100427-1333
http://code.google.com/p/inferno-npe/source/detail?r=f9af16a874

Modified:
/utils/ql/asm.c
/utils/ql/asmout.c
/utils/ql/l.h
/utils/ql/obj.c
/utils/ql/optab.c
/utils/ql/span.c

=======================================
--- /utils/ql/asm.c Tue Apr 27 04:51:13 2010
+++ /utils/ql/asm.c Tue Apr 27 05:33:26 2010
@@ -1,6 +1,7 @@
#include "l.h"

#define KMASK 0xF0000000
+#define JMPSZ sizeof(u32int) /* size of bootstrap jump section */

#define LPUT(c)\
{\
@@ -50,12 +51,15 @@
Prog *p;
long t;
Optab *o;
+ long prevpc;

if(debug['v'])
Bprint(&bso, "%5.2f asm\n", cputime());
Bflush(&bso);
+
+ /* emit text segment */
seek(cout, HEADR, 0);
- pc = INITTEXT;
+ prevpc = pc = INITTEXT;
for(p = firstp; p != P; p = p->link) {
if(p->as == ATEXT) {
curtext = p;
@@ -79,14 +83,32 @@
pc += 4;
}
pc += o->size;
- }
+ if (prevpc & (1<<31) && (pc & (1<<31)) == 0) {
+ char *tn;
+
+ tn = "?none?";
+ if(curtext != P && curtext->from.sym != S)
+ tn = curtext->from.sym->name;
+ Bprint(&bso, "%s: warning: text segment wrapped past 0\n", tn);
+ }
+ prevpc = pc;
+ }
+ /* for virtex 4, inject a jmp instruction after other text */
+ if(HEADTYPE == 6)
+ /* branch to absolute entry address (0xfffe2100) */
+ lput((18 << 26) | (0x03FFFFFC & entryvalue()) | 2);
+
if(debug['a'])
Bprint(&bso, "\n");
Bflush(&bso);
cflush();

+ /* emit data segment */
curtext = P;
switch(HEADTYPE) {
+ case 6:
+ textsize += JMPSZ;
+ /* fall through */
case 0:
case 1:
case 2:
@@ -126,6 +148,7 @@
case 1:
case 2:
case 5:
+ case 6:
seek(cout, HEADR+textsize+datsize, 0);
break;
case 3:
@@ -154,6 +177,7 @@
cflush();
}

+ /* back up and write the header */
seek(cout, 0L, 0);
switch(HEADTYPE) {
case 0:
@@ -290,6 +314,10 @@
lput(0x80L); /* flags */
break;
case 5:
+ /*
+ * customised for blue/gene,
+ * notably the alignment and KMASK masking.
+ */
strnput("\177ELF", 4); /* e_ident */
CPUT(1); /* class = 32 bit */
CPUT(2); /* data = MSB */
@@ -335,8 +363,8 @@

lput(0L); /* data - type = PT_NULL */
lput(HEADR+textsize+datsize); /* file offset */
- lput(0L);
- lput(0L);
+ lput(0L); /* vaddr */
+ lput(0L); /* paddr */
lput(symsize); /* symbol table size */
lput(lcsize); /* line number size */
lput(0x04L); /* protections = R */
@@ -391,6 +419,76 @@
cput(0);
cput(0);

+ break;
+ case 6:
+ /*
+ * customised for virtex 4 boot,
+ * notably the alignment and KMASK masking.
+ */
+ strnput("\177ELF", 4); /* e_ident */
+ CPUT(1); /* class = 32 bit */
+ CPUT(2); /* data = MSB */
+ CPUT(1); /* version = CURRENT */
+ strnput("", 9);
+ lput((2L<<16)|20L); /* type = EXEC; machine = PowerPC */
+ lput(1L); /* version = CURRENT */
+ lput(entryvalue()); /* entry vaddr */
+ lput(52L); /* offset to first phdr */
+
+ debug['S'] = 1; /* no symbol table */
+ if(debug['S']){
+ lput(HEADR+textsize+datsize+symsize); /* offset to first shdr */
+ lput(0L); /* flags = PPC */
+ lput((52L<<16)|32L); /* Ehdr & Phdr sizes*/
+ lput((4L<<16)|40L); /* # Phdrs & Shdr size */
+ lput((4L<<16)|2L); /* # Shdrs & shdr string size */
+ }
+ else{
+ lput(0L);
+ lput(0L); /* flags = PPC */
+ lput((52L<<16)|32L); /* Ehdr & Phdr sizes*/
+ lput((4L<<16)|0L); /* # Phdrs & Shdr size */
+ lput((4L<<16)|0L); /* # Shdrs & shdr string size */
+ }
+
+ lput(1L); /* text - type = PT_LOAD */
+ lput(HEADR); /* file offset */
+ lput(INITTEXT); /* vaddr */
+ lput(INITTEXT); /* paddr */
+ lput(textsize-JMPSZ); /* file size */
+ lput(textsize-JMPSZ); /* memory size */
+ lput(0x05L); /* protections = RX */
+ lput(0); /* alignment */
+
+ lput(1L); /* data - type = PT_LOAD */
+ lput(HEADR+textsize); /* file offset */
+ lput(INITDAT); /* vaddr */
+ lput(INITDAT); /* paddr */
+ lput(datsize); /* file size */
+ lput(datsize+bsssize); /* memory size */
+ lput(0x07L); /* protections = RWX */
+ lput(0); /* alignment */
+
+ lput(0L); /* data - type = PT_NULL */
+ lput(HEADR+textsize+datsize); /* file offset */
+ lput(0L); /* vaddr */
+ lput(0L); /* paddr */
+ lput(symsize); /* symbol table size */
+ lput(lcsize); /* line number size */
+ lput(0x04L); /* protections = R */
+ lput(0x04L); /* alignment code?? */
+
+ /* add tiny text section at end with jmp to start */
+ lput(1L); /* text - type = PT_LOAD */
+ lput(HEADR+textsize-JMPSZ); /* file offset */
+ lput(0xFFFFFFFC); /* vaddr */
+ lput(0xFFFFFFFC); /* paddr */
+ lput(JMPSZ); /* file size */
+ lput(JMPSZ); /* memory size */
+ lput(0x05L); /* protections = RX */
+ lput(0); /* disable alignment */
+
+ cflush();
break;
}
cflush();
=======================================
--- /utils/ql/asmout.c Tue Apr 27 04:51:13 2010
+++ /utils/ql/asmout.c Tue Apr 27 05:33:26 2010
@@ -672,16 +672,24 @@
if(p->from.type == D_REG) {
r = p->from.reg;
v = p->to.offset;
- if(p->to.type == D_DCR)
- o1 = OPVCC(31,451,0,0); /* mtdcr */
- else
+ if(p->to.type == D_DCR) {
+ if(p->to.reg != NREG) {
+ o1 = OPVCC(31,387,0,0); /* mtdcrx */
+ v = p->to.reg;
+ }else
+ o1 = OPVCC(31,451,0,0); /* mtdcr */
+ }else
o1 = OPVCC(31,467,0,0); /* mtspr */
} else {
r = p->to.reg;
v = p->from.offset;
- if(p->from.type == D_DCR)
- o1 = OPVCC(31,323,0,0); /* mfdcr */
- else
+ if(p->from.type == D_DCR) {
+ if(p->from.reg != NREG) {
+ o1 = OPVCC(31,259,0,0); /* mfdcrx */
+ v = p->from.reg;
+ }else
+ o1 = OPVCC(31,323,0,0); /* mfdcr */
+ }else
o1 = OPVCC(31,339,0,0); /* mfspr */
}
o1 = AOP_RRR(o1, r, 0, 0) | ((v&0x1f)<<16) | (((v>>5)&0x1f)<<11);
@@ -984,25 +992,22 @@
case AFXNMSUB: return OPVCC(0,29,0,0);
case AFXCPNMSUB: return OPVCC(0,30,0,0);
case AFXCSNMSUB: return OPVCC(0,31,0,0);
- case AFMOVPD: return OPVCC(0,32,0,0); /* fpmr, X form */
case AFPABS: return OPVCC(0,96,0,0);
case AFPNEG: return OPVCC(0,160,0,0);
case AFPRSP: return OPVCC(0,192,0,0);
case AFPNABS: return OPVCC(0,224,0,0);
- case AFMOVSD: return OPVCC(0,288,0,0); /* fsmr */
case AFSCMP: return OPVCC(0,320,0,0)|(3<<21);
case AFSABS: return OPVCC(0,352,0,0);
case AFSNEG: return OPVCC(0,416,0,0);
case AFSNABS: return OPVCC(0,480,0,0);
- case AFMOVXD: return OPVCC(0,544,0,0);
case AFPCTIW: return OPVCC(0,576,0,0);
case AFPCTIWZ: return OPVCC(0,704,0,0);

case AFPMOVD: return OPVCC(0,32,0,0); /* fpmr */
case AFSMOVD: return OPVCC(0,288,0,0); /* fsmr */
case AFXMOVD: return OPVCC(0,544,0,0); /* fxmr */
- case AFSMOVP: return OPVCC(0,800,0,0); /* fsmtp */
- case AFPMOVS: return OPVCC(0,928,0,0); /* fsmfp */
+ case AFMOVSPD: return OPVCC(0,800,0,0); /* fsmtp */
+ case AFMOVPSD: return OPVCC(0,928,0,0); /* fsmfp */

case AFXCPNPMA: return OPVCC(4,24,0,0);
case AFXCSNPMA: return OPVCC(4,25,0,0);
@@ -1290,18 +1295,18 @@
case AECIWX: return OPVCC(31,310,0,0); /* eciwx */
case ALWAR: return OPVCC(31,20,0,0); /* lwarx */
case ALSW: return OPVCC(31,533,0,0); /* lswx */
- case AFMOVSS: return OPVCC(31,142,0,0); /* lfssx */
- case AFMOVSSU: return OPVCC(31,174,0,0); /* lfssux */
- case AFMOVSD: return OPVCC(31,206,0,0);
- case AFMOVSDU: return OPVCC(31,238,0,0);
- case AFMOVXS: return OPVCC(31,270,0,0);
- case AFMOVSXU: return OPVCC(31,302,0,0);
- case AFMOVXD: return OPVCC(31,334,0,0);
- case AFMOVXDU: return OPVCC(31,366,0,0);
- case AFMOVPS: return OPVCC(31,398,0,0);
- case AFMOVPSU: return OPVCC(31,430,0,0);
- case AFMOVPD: return OPVCC(31,462,0,0);
- case AFMOVPDU: return OPVCC(31,494,0,0);
+ case AFSMOVS: return OPVCC(31,142,0,0); /* lfssx */
+ case AFSMOVSU: return OPVCC(31,174,0,0); /* lfssux */
+ case AFSMOVD: return OPVCC(31,206,0,0); /* lfsdx */
+ case AFSMOVDU: return OPVCC(31,238,0,0); /* lfsdux */
+ case AFXMOVS: return OPVCC(31,270,0,0); /* lfxsx */
+ case AFXMOVSU: return OPVCC(31,302,0,0); /* lfxsux */
+ case AFXMOVD: return OPVCC(31,334,0,0); /* lfxdx */
+ case AFXMOVDU: return OPVCC(31,366,0,0); /* lfxdux */
+ case AFPMOVS: return OPVCC(31,398,0,0); /* lfpsx */
+ case AFPMOVSU: return OPVCC(31,430,0,0); /* lfpsux */
+ case AFPMOVD: return OPVCC(31,462,0,0); /* lfpdx */
+ case AFPMOVDU: return OPVCC(31,494,0,0); /* lfpdux */
}
diag("bad loadx opcode %A", a);
return 0;
@@ -1361,19 +1366,19 @@
case AMOVWBR: return OPVCC(31,662,0,0); /* stwbrx */
case ASTWCCC: return OPVCC(31,150,0,1); /* stwcx. */
case AECOWX: return OPVCC(31,438,0,0); /* ecowx */
- case AFMOVSS: return OPVCC(31,654,0,0);
-/* case AFMOVSSU: return OPVCC(31,yy,0,0); */ /* stfssux not known */
-/* case AFMOVSD: return OPVCC(31,yy,0,0); */ /* stfsdx not known */
- case AFMOVSDU: return OPVCC(31,750,0,0);
- case AFMOVXS: return OPVCC(31,782,0,0);
- case AFMOVSXU: return OPVCC(31,814,0,0);
- case AFMOVXD: return OPVCC(31,846,0,0);
- case AFMOVXDU: return OPVCC(31,878,0,0);
- case AFMOVPS: return OPVCC(31,910,0,0);
- case AFMOVPSU: return OPVCC(31,942,0,0);
- case AFMOVPD: return OPVCC(31,974,0,0);
- case AFMOVPDU: return OPVCC(31,1006,0,0);
- case AFMOVPIW: return OPVCC(31,526,0,0); /* stfpiwx */
+ case AFSMOVS: return OPVCC(31,654,0,0); /* stfssx */
+/* case AFSMOVSU: return OPVCC(31,yy,0,0); */ /* stfssux not known */
+/* case AFSMOVD: return OPVCC(31,yy,0,0); */ /* stfsdx not known */
+ case AFSMOVDU: return OPVCC(31,750,0,0); /* stfsdux */
+ case AFXMOVS: return OPVCC(31,782,0,0); /* stfxsx */
+ case AFXMOVSU: return OPVCC(31,814,0,0); /* stfxsux */
+ case AFXMOVD: return OPVCC(31,846,0,0); /* stfxdx */
+ case AFXMOVDU: return OPVCC(31,878,0,0); /* stfxdux */
+ case AFPMOVS: return OPVCC(31,910,0,0); /* stfpsx */
+ case AFPMOVSU: return OPVCC(31,942,0,0); /* stfpsux */
+ case AFPMOVD: return OPVCC(31,974,0,0); /* stfpdx */
+ case AFPMOVDU: return OPVCC(31,1006,0,0); /* stfpdux */
+ case AFPMOVIW: return OPVCC(31,526,0,0); /* stfpiwx */
}
diag("unknown storex opcode %A", a);
return 0;
=======================================
--- /utils/ql/l.h Fri Dec 22 16:30:12 2006
+++ /utils/ql/l.h Tue Apr 27 05:33:26 2010
@@ -303,6 +303,7 @@
void names(void);
void nocache(Prog*);
void noops(void);
+void nopout(Prog*);
void nuxiinit(void);
void objfile(char*);
int ocmp(void*, void*);
@@ -327,9 +328,12 @@
void xfol(Prog*);
void zerosig(char*);

+#pragma varargck type "A" int
+#pragma varargck type "A" uint
#pragma varargck type "D" Adr*
#pragma varargck type "N" Adr*
#pragma varargck type "P" Prog*
#pragma varargck type "R" int
-#pragma varargck type "A" int
#pragma varargck type "S" char*
+
+#pragma varargck argpos diag 1
=======================================
--- /utils/ql/obj.c Tue Apr 27 04:51:13 2010
+++ /utils/ql/obj.c Tue Apr 27 05:33:26 2010
@@ -17,10 +17,13 @@
/*
* -H0 -T0x200000 -R0 is boot
* -H1 -T0x100000 -R4 is Be boot
- * -H2 -T4128 -R4096 is plan9 format
+ * -H2 -T0x100020 -R0x100000 is plan9 format (was -T4128 -R4096)
* -H3 -T0x02010000 -D0x00001000 is raw
* -H4 -T0x1000200 -D0x20000e00 -R4 is aix xcoff executable
* -H5 -T0x80010000 -t0x10000 ELF, phys = 10000, vaddr = 0x8001...
+ * appropriate for blue gene (bg/l anyway)
+ * -H6 -T0xfffe2100 -R4 ELF, phys = vaddr = 0xfffe2100
+ * appropriate for virtex 4 boot
*/

static int
@@ -150,11 +153,11 @@
case 2: /* plan 9 */
HEADR = 32L;
if(INITTEXT == -1)
- INITTEXT = 4128;
+ INITTEXT = 0x100020;
if(INITDAT == -1)
INITDAT = 0;
if(INITRND == -1)
- INITRND = 4096;
+ INITRND = 0x100000;
break;
case 3: /* raw */
HEADR = 0;
@@ -177,6 +180,7 @@
INITRND = 0;
break;
case 5: /* elf executable */
+ case 6: /* elf for virtex 4 */
HEADR = rnd(52L+3*32L, 16);
if(INITTEXT == -1)
INITTEXT = 0x00400000L+HEADR;
@@ -1220,16 +1224,24 @@
doprof2(void)
{
Sym *s2, *s4;
- Prog *p, *q, *ps2, *ps4;
+ Prog *p, *q, *q2, *ps2, *ps4;

if(debug['v'])
Bprint(&bso, "%5.2f profile 2\n", cputime());
Bflush(&bso);

- s2 = lookup("_profin", 0);
- s4 = lookup("_profout", 0);
+ if(debug['e']){
+ s2 = lookup("_tracein", 0);
+ s4 = lookup("_traceout", 0);
+ }else{
+ s2 = lookup("_profin", 0);
+ s4 = lookup("_profout", 0);
+ }
if(s2->type != STEXT || s4->type != STEXT) {
- diag("_profin/_profout not defined");
+ if(debug['e'])
+ diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+ else
+ diag("_profin/_profout not defined");
return;
}

@@ -1270,7 +1282,20 @@
q->line = p->line;
q->pc = p->pc;
q->link = p->link;
- p->link = q;
+ if(debug['e']){ /* embedded tracing */
+ q2 = prg();
+ p->link = q2;
+ q2->link = q;
+
+ q2->line = p->line;
+ q2->pc = p->pc;
+
+ q2->as = ABR;
+ q2->to.type = D_BRANCH;
+ q2->to.sym = p->to.sym;
+ q2->cond = q->link;
+ }else
+ p->link = q;
p = q;
p->as = ABL;
p->to.type = D_BRANCH;
@@ -1280,7 +1305,17 @@
continue;
}
if(p->as == ARETURN) {
-
+ /*
+ * RETURN (default)
+ */
+ if(debug['e']){ /* embedded tracing */
+ q = prg();
+ q->line = p->line;
+ q->pc = p->pc;
+ q->link = p->link;
+ p->link = q;
+ p = q;
+ }
/*
* RETURN
*/
=======================================
--- /utils/ql/optab.c Tue Apr 27 04:51:13 2010
+++ /utils/ql/optab.c Tue Apr 27 05:33:26 2010
@@ -206,8 +206,6 @@
{ AFMOVD, C_FREG, C_NONE, C_NONE, C_LOREG, 7, 4, REGZERO },
{ AFMOVD, C_FREG, C_NONE, C_NONE, C_ADDR, 74, 8, 0 },

- { AFPMOVD, C_FREG, C_NONE, C_NONE, C_FREG, 33, 4, 0 },
-
{ ASYNC, C_NONE, C_NONE, C_NONE, C_NONE, 46, 4, 0 },
{ AWORD, C_LCON, C_NONE, C_NONE, C_NONE, 40, 4, 0 },

@@ -287,13 +285,18 @@

{ AMACCHW, C_REG, C_REG, C_NONE, C_REG, 2, 4, 0 }, /* op rb,ra,rt */

- { AFMOVSS, C_ZOREG, C_REG, C_NONE, C_FREG, 45, 4, 0 },
- { AFMOVSS, C_ZOREG, C_NONE, C_NONE, C_FREG, 45, 4, 0 },
- { AFMOVSS, C_FREG, C_REG, C_NONE, C_ZOREG, 44, 4, 0 },
- { AFMOVSS, C_FREG, C_NONE, C_NONE, C_ZOREG, 44, 4, 0 },
-
- { AFMOVPIW, C_FREG, C_REG, C_NONE, C_ZOREG, 44, 4, 0 },
- { AFMOVPIW, C_FREG, C_NONE, C_NONE, C_ZOREG, 44, 4, 0 },
+ { AFSMOVS, C_ZOREG, C_REG, C_NONE, C_FREG, 45, 4, 0 },
+ { AFSMOVS, C_ZOREG, C_NONE, C_NONE, C_FREG, 45, 4, 0 },
+ { AFSMOVS, C_FREG, C_REG, C_NONE, C_ZOREG, 44, 4, 0 },
+ { AFSMOVS, C_FREG, C_NONE, C_NONE, C_ZOREG, 44, 4, 0 },
+
+ { AFPMOVD, C_ZOREG, C_REG, C_NONE, C_FREG, 45, 4, 0 },
+ { AFPMOVD, C_ZOREG, C_NONE, C_NONE, C_FREG, 45, 4, 0 },
+ { AFPMOVD, C_FREG, C_REG, C_NONE, C_ZOREG, 44, 4, 0 },
+ { AFPMOVD, C_FREG, C_NONE, C_NONE, C_ZOREG, 44, 4, 0 },
+
+ { AFPMOVD, C_FREG, C_NONE, C_NONE, C_FREG, 33, 4, 0 }, /* f[xps]mr */
+ { AFMOVSPD, C_FREG, C_NONE, C_NONE, C_FREG, 33, 4, 0 }, /* fsm[tf]p */

{ AXXX, C_NONE, C_NONE, C_NONE, C_NONE, 0, 4, 0 },
};
=======================================
--- /utils/ql/span.c Tue Apr 27 04:51:13 2010
+++ /utils/ql/span.c Tue Apr 27 05:33:26 2010
@@ -499,8 +499,6 @@
case AECOWX: /* indexed store: op s,(b+a); op s,(b) */
oprange[ASTWCCC] = oprange[r];
break;
- case AFMOVPIW: /* indexed floating store */
- break;
case AREM: /* macro */
oprange[AREMCC] = oprange[r];
oprange[AREMV] = oprange[r];
@@ -845,12 +843,6 @@
oprange[AFMOVS] = oprange[r];
oprange[AFMOVSU] = oprange[r];
break;
- case AFPMOVD:
- oprange[AFSMOVD] = oprange[r];
- oprange[AFXMOVD] = oprange[r];
- oprange[AFSMOVP] = oprange[r];
- oprange[AFPMOVS] = oprange[r];
- break;
case AECIWX:
oprange[ALWAR] = oprange[r];
break;
@@ -861,18 +853,23 @@
case AMOVHBR:
oprange[AMOVWBR] = oprange[r];
break;
- case AFMOVSS: /* indexed floating loads and stores (fp2) */
- oprange[AFMOVSSU] = oprange[r];
- oprange[AFMOVSD] = oprange[r];
- oprange[AFMOVSDU] = oprange[r];
- oprange[AFMOVXS] = oprange[r];
- oprange[AFMOVSXU] = oprange[r];
- oprange[AFMOVXD] = oprange[r];
- oprange[AFMOVXDU] = oprange[r];
- oprange[AFMOVPS] = oprange[r];
- oprange[AFMOVPSU] = oprange[r];
- oprange[AFMOVPD] = oprange[r];
- oprange[AFMOVPDU] = oprange[r];
+ case AFSMOVS: /* indexed floating loads and stores (fp2) */
+ oprange[AFSMOVSU] = oprange[r];
+ oprange[AFSMOVDU] = oprange[r];
+ oprange[AFXMOVS] = oprange[r];
+ oprange[AFXMOVSU] = oprange[r];
+ oprange[AFXMOVDU] = oprange[r];
+ oprange[AFPMOVS] = oprange[r];
+ oprange[AFPMOVSU] = oprange[r];
+ oprange[AFPMOVDU] = oprange[r];
+ oprange[AFPMOVIW] = oprange[r];
+ break;
+ case AFPMOVD: /* indexed load/store and moves (fp2) */
+ oprange[AFSMOVD] = oprange[r];
+ oprange[AFXMOVD] = oprange[r];
+ break;
+ case AFMOVSPD: /* move between fp reg sets (fp2) */
+ oprange[AFMOVPSD] = oprange[r];
break;
case AADD:
case AANDCC: /* and. Rb,Rs,Ra; andi. $uimm,Rs,Ra; andis. $uimm,Rs,Ra */

==============================================================================
Revision: 6b8cd637ac
Author: for...@vitanuova.com
Date: Tue Apr 27 11:09:04 2010
Log: 20100427-1909
http://code.google.com/p/inferno-npe/source/detail?r=6b8cd637ac

Modified:
/utils/6c/cgen.c
/utils/6c/gc.h
/utils/6c/mkfile
/utils/6c/sgen.c
/utils/6c/swt.c
/utils/6c/txt.c

=======================================
--- /utils/6c/cgen.c Sat May 30 17:07:21 2009
+++ /utils/6c/cgen.c Tue Apr 27 11:09:04 2010
@@ -577,13 +577,14 @@
regalloc(&nod2, r, Z);
gmove(&nod, &nod2);
gopcode(o, r->type, &nod1, &nod2);
+ regfree(&nod1);
gmove(&nod2, &nod);
regfree(&nod2);
} else {
gopcode(o, r->type, &nod, &nod1);
gmove(&nod1, &nod);
- }
- regfree(&nod1);
+ regfree(&nod1);
+ }
}
if(nn != Z)
gmove(&nod, nn);
=======================================
--- /utils/6c/gc.h Tue Apr 27 04:51:13 2010
+++ /utils/6c/gc.h Tue Apr 27 11:09:04 2010
@@ -132,6 +132,7 @@
};

EXTERN long breakpc;
+EXTERN long nbreak;
EXTERN Case* cases;
EXTERN Node constnode;
EXTERN Node fconstnode;
@@ -143,7 +144,6 @@
EXTERN Prog* lastp;
EXTERN long maxargsafe;
EXTERN int mnstring;
-EXTERN int retok;
EXTERN Node* nodrat;
EXTERN Node* nodret;
EXTERN Node* nodsafe;
@@ -376,10 +376,6 @@
#pragma varargck type "R" int
#pragma varargck type "S" char*

-/* wrecklessly steal a field */
-
-#define rplink label
-
#define D_X7 (D_X0+7)

void fgopcode(int, Node*, Node*, int, int);
=======================================
--- /utils/6c/mkfile Sat May 30 17:07:21 2009
+++ /utils/6c/mkfile Tue Apr 27 11:09:04 2010
@@ -12,6 +12,8 @@
txt.$O\
reg.$O\
peep.$O\
+ pgen.$O\
+ pswt.$O\
machcap.$O\
div.$O\
mul.$O\
@@ -33,3 +35,9 @@
cd ../cc
mk $MKFLAGS install
mk $MKFLAGS clean
+
+%.$O: ../cc/%.c
+ $CC $CFLAGS -I. ../cc/$stem.c
+
+#enam.c: 6.out.h
+# rc mkenam
=======================================
--- /utils/6c/sgen.c Tue Apr 27 04:51:13 2010
+++ /utils/6c/sgen.c Tue Apr 27 11:09:04 2010
@@ -1,382 +1,4 @@
#include "gc.h"
-
-void
-codgen(Node *n, Node *nn)
-{
- Prog *sp;
- Node *n1, nod, nod1;
-
- cursafe = 0;
- curarg = 0;
- maxargsafe = 0;
-
- /*
- * isolate name
- */
- for(n1 = nn;; n1 = n1->left) {
- if(n1 == Z) {
- diag(nn, "cant find function name");
- return;
- }
- if(n1->op == ONAME)
- break;
- }
- nearln = nn->lineno;
- gpseudo(ATEXT, n1->sym, nodconst(stkoff));
- sp = p;
-
- /*
- * isolate first argument
- */
- if(REGARG) {
- if(typesu[thisfn->link->etype]) {
- nod1 = *nodret->left;
- nodreg(&nod, &nod1, REGARG);
- gmove(&nod, &nod1);
- } else
- if(firstarg && typechlpv[firstargtype->etype]) {
- nod1 = *nodret->left;
- nod1.sym = firstarg;
- nod1.type = firstargtype;
- nod1.xoffset = align(0, firstargtype, Aarg1);
- nod1.etype = firstargtype->etype;
- nodreg(&nod, &nod1, REGARG);
- gmove(&nod, &nod1);
- }
- }
-
- retok = 0;
- gen(n);
- if(!retok)
- if(thisfn->link->etype != TVOID)
- warn(Z, "no return at end of function: %s", n1->sym->name);
- noretval(3);
- gbranch(ORETURN);
-
- if(!debug['N'] || debug['R'] || debug['P'])
- regopt(sp);
- maxargsafe = round(maxargsafe, 8);
- sp->to.offset += maxargsafe;
-}
-
-void
-supgen(Node *n)
-{
- long spc;
- Prog *sp;
-
- if(n == Z)
- return;
- suppress++;
- spc = pc;
- sp = lastp;
- gen(n);
- lastp = sp;
- pc = spc;
- sp->link = nil;
- suppress--;
-}
-
-void
-gen(Node *n)
-{
- Node *l, nod;
- Prog *sp, *spc, *spb;
- Case *cn;
- long sbc, scc;
- int f, o;
-
-loop:
- if(n == Z)
- return;
- nearln = n->lineno;
- o = n->op;
- if(debug['G'])
- if(o != OLIST)
- print("%L %O\n", nearln, o);
-
- retok = 0;
- switch(o) {
-
- default:
- complex(n);
- cgen(n, Z);
- break;
-
- case OLIST:
- gen(n->left);
-
- rloop:
- n = n->right;
- goto loop;
-
- case ORETURN:
- retok = 1;
- complex(n);
- if(n->type == T)
- break;
- l = n->left;
- if(l == Z) {
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- if(typesu[n->type->etype]) {
- sugen(l, nodret, n->type->width);
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- regret(&nod, n);
- cgen(l, &nod);
- regfree(&nod);
- if(typefd[n->type->etype])
- noretval(1);
- else
- noretval(2);
- gbranch(ORETURN);
- break;
-
- case OLABEL:
- l = n->left;
- if(l) {
- l->xoffset = pc;
- if(l->label)
- patch(l->label, pc);
- }
- gbranch(OGOTO); /* prevent self reference in reg */
- patch(p, pc);
- goto rloop;
-
- case OGOTO:
- retok = 1;
- n = n->left;
- if(n == Z)
- return;
- if(n->complex == 0) {
- diag(Z, "label undefined: %s", n->sym->name);
- return;
- }
- if(suppress)
- return;
- gbranch(OGOTO);
- if(n->xoffset) {
- patch(p, n->xoffset);
- return;
- }
- if(n->label)
- patch(n->label, pc-1);
- n->label = p;
- return;
-
- case OCASE:
- l = n->left;
- if(cases == C)
- diag(n, "case/default outside a switch");
- if(l == Z) {
- casf();
- cases->val = 0;
- cases->def = 1;
- cases->label = pc;
- cases->isv = 0;
- goto rloop;
- }
- complex(l);
- if(l->type == T)
- goto rloop;
- if(l->op == OCONST)
- if(typechlv[l->type->etype]) {
- casf();
- cases->val = l->vconst;
- cases->def = 0;
- cases->label = pc;
- cases->isv = typev[l->type->etype];
- goto rloop;
- }
- diag(n, "case expression must be integer constant");
- goto rloop;
-
- case OSWITCH:
- l = n->left;
- complex(l);
- if(l->type == T)
- break;
- if(!typechlv[l->type->etype]) {
- diag(n, "switch expression must be integer");
- break;
- }
-
- gbranch(OGOTO); /* entry */
- sp = p;
-
- cn = cases;
- cases = C;
- casf();
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- gen(n->right);
- gbranch(OGOTO);
- patch(p, breakpc);
-
- patch(sp, pc);
- regalloc(&nod, l, Z);
- nod.type = typev[l->type->etype]? types[TVLONG]: types[TLONG]; /* always
signed */
- cgen(l, &nod);
- doswit(&nod);
- regfree(&nod);
- patch(spb, pc);
-
- cases = cn;
- breakpc = sbc;
- break;
-
- case OWHILE:
- case ODWHILE:
- l = n->left;
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- if(n->op == OWHILE)
- patch(sp, pc);
- bcomplex(l, Z); /* test */
- patch(p, breakpc);
-
- if(n->op == ODWHILE)
- patch(sp, pc);
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OFOR:
- l = n->left;
- gen(l->right->left); /* init */
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- gen(l->right->right); /* inc */
- patch(sp, pc);
- if(l->left != Z) { /* test */
- bcomplex(l->left, Z);
- patch(p, breakpc);
- }
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OCONTINUE:
- if(continpc < 0) {
- diag(n, "continue not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, continpc);
- break;
-
- case OBREAK:
- if(breakpc < 0) {
- diag(n, "break not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, breakpc);
- break;
-
- case OIF:
- l = n->left;
- if(bcomplex(l, n->right)) {
- if(typefd[l->type->etype])
- f = !l->fconst;
- else
- f = !l->vconst;
- if(debug['c'])
- print("%L const if %s\n", nearln, f ? "false" : "true");
- if(f) {
- supgen(n->right->left);
- gen(n->right->right);
- }
- else {
- gen(n->right->left);
- supgen(n->right->right);
- }
- }
- else {
- sp = p;
- if(n->right->left != Z)
- gen(n->right->left);
- if(n->right->right != Z) {
- gbranch(OGOTO);
- patch(sp, pc);
- sp = p;
- gen(n->right->right);
- }
- patch(sp, pc);
- }
- break;
-
- case OSET:
- case OUSED:
- usedset(n->left, o);
- break;
- }
-}
-
-void
-usedset(Node *n, int o)
-{
- if(n->op == OLIST) {
- usedset(n->left, o);
- usedset(n->right, o);
- return;
- }
- complex(n);
- switch(n->op) {
- case OADDR: /* volatile */
- gins(ANOP, n, Z);
- break;
- case ONAME:
- if(o == OSET)
- gins(ANOP, Z, n);
- else
- gins(ANOP, n, Z);
- break;
- }
-}

void
noretval(int n)
@@ -811,19 +433,3 @@
prtree(idx.basetree, "base");
}
}
-
-int
-bcomplex(Node *n, Node *c)
-{
- complex(n);
- if(n->type != T)
- if(tcompat(n, T, n->type, tnot))
- n->type = T;
- if(n->type != T) {
- if(c != Z && n->op == OCONST && deadheads(c))
- return 1;
- boolgen(n, 1, Z);
- } else
- gbranch(OGOTO);
- return 0;
-}
=======================================
--- /utils/6c/swt.c Tue Apr 27 04:51:13 2010
+++ /utils/6c/swt.c Tue Apr 27 11:09:04 2010
@@ -1,63 +1,4 @@
#include "gc.h"
-
-int
-swcmp(const void *a1, const void *a2)
-{
- C1 *p1, *p2;
-
- p1 = (C1*)a1;
- p2 = (C1*)a2;
- if(p1->val < p2->val)
- return -1;
- return p1->val > p2->val;
-}
-
-void
-doswit(Node *n)
-{
- Case *c;
- C1 *q, *iq;
- long def, nc, i, isv;
-
- def = 0;
- nc = 0;
- isv = 0;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def) {
- if(def)
- diag(n, "more than one default in switch");
- def = c->label;
- continue;
- }
- isv |= c->isv;
- nc++;
- }
- if(isv && !typev[n->type->etype])
- warn(n, "32-bit switch expression with 64-bit case constant");
-
- iq = alloc(nc*sizeof(C1));
- q = iq;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def)
- continue;
- q->label = c->label;
- if(isv)
- q->val = c->val;
- else
- q->val = (long)c->val;
- q++;
- }
- qsort(iq, nc, sizeof(C1), swcmp);
- if(debug['W'])
- for(i=0; i<nc; i++)
- print("case %2ld: = %.8llux\n", i, iq[i].val);
- if(def == 0)
- def = breakpc;
- for(i=0; i<nc-1; i++)
- if(iq[i].val == iq[i+1].val)
- diag(n, "duplicate cases in switch %lld", iq[i].val);
- swit1(iq, nc, def, n);
-}

void
swit1(C1 *q, int nc, long def, Node *n)
@@ -94,16 +35,6 @@
patch(sp, pc);
swit1(r+1, nc-i-1, def, n);
}
-
-void
-casf(void)
-{
- Case *c;
-
- c = alloc(sizeof(*c));
- c->link = cases;
- cases = c;
-}

void
bitload(Node *b, Node *n1, Node *n2, Node *n3, Node *nn)
@@ -195,43 +126,6 @@
}
return r;
}
-
-long
-outlstring(ushort *s, long n)
-{
- char buf[2];
- int c;
- long r;
-
- if(suppress)
- return nstring;
- while(nstring & 1)
- outstring("", 1);
- r = nstring;
- while(n > 0) {
- c = *s++;
- if(align(0, types[TCHAR], Aarg1)) {
- buf[0] = c>>8;
- buf[1] = c;
- } else {
- buf[0] = c;
- buf[1] = c>>8;
- }
- outstring(buf, 2);
- n -= sizeof(ushort);
- }
- return r;
-}
-
-void
-nullwarn(Node *l, Node *r)
-{
- warn(Z, "result of operation not used");
- if(l != Z)
- cgen(l, Z);
- if(r != Z)
- cgen(r, Z);
-}

void
sextern(Sym *s, Node *a, long o, long w)
@@ -559,35 +453,6 @@
if(t & T_TYPE)
Bputc(b, a->type);
}
-
-void
-ieeedtod(Ieee *ieee, double native)
-{
- double fr, ho, f;
- int exp;
-
- if(native < 0) {
- ieeedtod(ieee, -native);
- ieee->h |= 0x80000000L;
- return;
- }
- if(native == 0) {
- ieee->l = 0;
- ieee->h = 0;
- return;
- }
- fr = frexp(native, &exp);
- f = 2097152L; /* shouldnt use fp constants here */
- fr = modf(fr*f, &ho);
- ieee->h = ho;
- ieee->h &= 0xfffffL;
- ieee->h |= (exp+1022L) << 20;
- f = 65536L;
- fr = modf(fr*f, &ho);
- ieee->l = ho;
- ieee->l <<= 16;
- ieee->l |= (long)(fr*f);
-}

long
align(long i, Type *t, int op)
=======================================
--- /utils/6c/txt.c Sat May 30 17:07:21 2009
+++ /utils/6c/txt.c Tue Apr 27 11:09:04 2010
@@ -22,6 +22,9 @@
lastp = P;
tfield = types[TINT];

+ typeword = typechlvp;
+ typecmplx = typesu;
+
/* TO DO */
memmove(typechlpv, typechlp, sizeof(typechlpv));
typechlpv[TVLONG] = 1;
@@ -979,7 +982,7 @@
case CASE( TDOUBLE,TUVLONG):
case CASE( TDOUBLE,TIND):
regalloc(&nod, t, Z);
- if(ewidth[tt] == SZ_VLONG){
+ if(ewidth[tt] == SZ_VLONG || typeu[tt] && ewidth[tt] == SZ_INT){
if(ft == TFLOAT)
a = ACVTTSS2SQ;
else

==============================================================================
Revision: 573a102a3b
Author: for...@vitanuova.com
Date: Tue Apr 27 11:13:34 2010
Log: 20100427-1913
http://code.google.com/p/inferno-npe/source/detail?r=573a102a3b

Modified:
/utils/6l/asm.c
/utils/6l/l.h
/utils/6l/obj.c
/utils/6l/optab.c
/utils/6l/span.c

=======================================
--- /utils/6l/asm.c Sat May 30 17:07:21 2009
+++ /utils/6l/asm.c Tue Apr 27 11:13:34 2010
@@ -4,7 +4,7 @@

#define PADDR(a) ((ulong)(a) & ~0x80000000)

-long
+vlong
entryvalue(void)
{
char *a;
@@ -50,6 +50,13 @@
cput(l>>8);
cput(l);
}
+
+void
+llput(vlong v)
+{
+ lput(v>>32);
+ lput(v);
+}

void
lputl(long l)
@@ -80,6 +87,7 @@
long v, magic;
int a;
uchar *op1;
+ vlong vl;

if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime());
@@ -123,21 +131,10 @@
switch(HEADTYPE) {
default:
diag("unknown header type %ld", HEADTYPE);
- case 0:
- seek(cout, rnd(HEADR+textsize, 8192), 0);
- break;
- case 1:
- textsize = rnd(HEADR+textsize, 4096)-HEADR;
- seek(cout, textsize+HEADR, 0);
- break;
case 2:
case 5:
seek(cout, HEADR+textsize, 0);
break;
- case 3:
- case 4:
- seek(cout, HEADR+rnd(textsize, INITRND), 0);
- break;
}

if(debug['v'])
@@ -167,20 +164,10 @@
Bflush(&bso);
switch(HEADTYPE) {
default:
- case 0:
- seek(cout, rnd(HEADR+textsize, 8192)+datsize, 0);
- break;
- case 1:
- seek(cout, rnd(HEADR+textsize, INITRND)+datsize, 0);
- break;
case 2:
case 5:
seek(cout, HEADR+textsize+datsize, 0);
break;
- case 3:
- case 4:
- debug['s'] = 1;
- break;
}
if(!debug['s'])
asmsym();
@@ -207,97 +194,23 @@
seek(cout, 0L, 0);
switch(HEADTYPE) {
default:
- case 0: /* garbage */
- lput(0x160L<<16); /* magic and sections */
- lput(0L); /* time and date */
- lput(rnd(HEADR+textsize, 4096)+datsize);
- lput(symsize); /* nsyms */
- lput((0x38L<<16)|7L); /* size of optional hdr and flags */
- lput((0413<<16)|0437L); /* magic and version */
- lput(rnd(HEADR+textsize, 4096)); /* sizes */
+ case 2: /* plan9 */
+ magic = 4*26*26+7;
+ magic |= 0x00008000; /* fat header */
+ if(dlm)
+ magic |= 0x80000000; /* dlm */
+ lput(magic); /* magic */
+ lput(textsize); /* sizes */
lput(datsize);
lput(bsssize);
- lput(entryvalue()); /* va of entry */
- lput(INITTEXT-HEADR); /* va of base of text */
- lput(INITDAT); /* va of base of data */
- lput(INITDAT+datsize); /* va of base of bss */
- lput(~0L); /* gp reg mask */
- lput(0L);
- lput(0L);
- lput(0L);
- lput(0L);
- lput(~0L); /* gp value ?? */
+ lput(symsize); /* nsyms */
+ vl = entryvalue();
+ lput(PADDR(vl)); /* va of entry */
+ lput(spsize); /* sp offsets */
+ lput(lcsize); /* line offsets */
+ llput(vl); /* va of entry */
break;
- lputl(0); /* x */
- case 1: /* unix coff */
- /*
- * file header
- */
- lputl(0x0004014c); /* 4 sections, magic */
- lputl(0); /* unix time stamp */
- lputl(0); /* symbol table */
- lputl(0); /* nsyms */
- lputl(0x0003001c); /* flags, sizeof a.out header */
- /*
- * a.out header
- */
- lputl(0x10b); /* magic, version stamp */
- lputl(rnd(textsize, INITRND)); /* text sizes */
- lputl(datsize); /* data sizes */
- lputl(bsssize); /* bss sizes */
- lput(entryvalue()); /* va of entry */
- lputl(INITTEXT); /* text start */
- lputl(INITDAT); /* data start */
- /*
- * text section header
- */
- strnput(".text", 8);
- lputl(HEADR); /* pa */
- lputl(HEADR); /* va */
- lputl(textsize); /* text size */
- lputl(HEADR); /* file offset */
- lputl(0); /* relocation */
- lputl(0); /* line numbers */
- lputl(0); /* relocation, line numbers */
- lputl(0x20); /* flags text only */
- /*
- * data section header
- */
- strnput(".data", 8);
- lputl(INITDAT); /* pa */
- lputl(INITDAT); /* va */
- lputl(datsize); /* data size */
- lputl(HEADR+textsize); /* file offset */
- lputl(0); /* relocation */
- lputl(0); /* line numbers */
- lputl(0); /* relocation, line numbers */
- lputl(0x40); /* flags data only */
- /*
- * bss section header
- */
- strnput(".bss", 8);
- lputl(INITDAT+datsize); /* pa */
- lputl(INITDAT+datsize); /* va */
- lputl(bsssize); /* bss size */
- lputl(0); /* file offset */
- lputl(0); /* relocation */
- lputl(0); /* line numbers */
- lputl(0); /* relocation, line numbers */
- lputl(0x80); /* flags bss only */
- /*
- * comment section header
- */
- strnput(".comment", 8);
- lputl(0); /* pa */
- lputl(0); /* va */
- lputl(symsize+lcsize); /* comment size */
- lputl(HEADR+textsize+datsize); /* file offset */
- lputl(HEADR+textsize+datsize); /* offset of syms */
- lputl(HEADR+textsize+datsize+symsize);/* offset of line numbers */
- lputl(0); /* relocation, line numbers */
- lputl(0x200); /* flags comment only */
- break;
- case 2: /* plan9 */
+ case 3: /* plan9 */
magic = 4*26*26+7;
if(dlm)
magic |= 0x80000000;
@@ -310,31 +223,6 @@
lput(spsize); /* sp offsets */
lput(lcsize); /* line offsets */
break;
- case 3:
- /* MS-DOS .COM */
- break;
- case 4:
- /* fake MS-DOS .EXE */
- v = rnd(HEADR+textsize, INITRND)+datsize;
- wputl(0x5A4D); /* 'MZ' */
- wputl(v % 512); /* bytes in last page */
- wputl(rnd(v, 512)/512); /* total number of pages */
- wputl(0x0000); /* number of reloc items */
- v = rnd(HEADR-(INITTEXT & 0xFFFF), 16);
- wputl(v/16); /* size of header */
- wputl(0x0000); /* minimum allocation */
- wputl(0xFFFF); /* maximum allocation */
- wputl(0x0000); /* initial ss value */
- wputl(0x0100); /* initial sp value */
- wputl(0x0000); /* complemented checksum */
- v = entryvalue();
- wputl(v); /* initial ip value (!) */
- wputl(0x0000); /* initial cs value */
- wputl(0x0000);
- wputl(0x0000);
- wputl(0x003E); /* reloc table offset */
- wputl(0x0000); /* overlay number */
- break;
case 5:
strnput("\177ELF", 4); /* e_ident */
cput(1); /* class = 32 bit */
@@ -342,12 +230,12 @@
cput(1); /* version = CURRENT */
strnput("", 9);
wputl(2); /* type = EXEC */
- wputl(3); /* machine = 386 */
+ wputl(62); /* machine = AMD64 */
lputl(1L); /* version = CURRENT */
lputl(PADDR(entryvalue())); /* entry vaddr */
lputl(52L); /* offset to first phdr */
lputl(0L); /* offset to first shdr */
- lputl(0L); /* flags = 386 */
+ lputl(0L); /* processor specific flags */
wputl(52); /* Ehdr size */
wputl(32); /* Phdr size */
wputl(3); /* # of Phdrs */
@@ -554,10 +442,10 @@
write(cout, buf.dbuf, n);
}

-long
-rnd(long v, long r)
-{
- long c;
+vlong
+rnd(vlong v, vlong r)
+{
+ vlong c;

if(r <= 0)
return v;
=======================================
--- /utils/6l/l.h Sat May 30 17:07:21 2009
+++ /utils/6l/l.h Tue Apr 27 11:13:34 2010
@@ -287,7 +287,6 @@
EXTERN int regrex[D_NONE+1];
EXTERN Prog* lastp;
EXTERN long lcsize;
-EXTERN int maxop;
EXTERN int nerrors;
EXTERN long nhunk;
EXTERN long nsymbol;
@@ -347,7 +346,7 @@
void doprof2(void);
void dostkoff(void);
void dynreloc(Sym*, ulong, int);
-long entryvalue(void);
+vlong entryvalue(void);
void errorexit(void);
void export(void);
int find1(long, int);
@@ -375,7 +374,7 @@
void readundefs(char*, int);
int relinv(int);
long reuse(Prog*, Sym*);
-long rnd(long, long);
+vlong rnd(vlong, vlong);
void span(void);
void undef(void);
void undefsym(Sym*);
=======================================
--- /utils/6l/obj.c Sat May 30 17:07:21 2009
+++ /utils/6l/obj.c Tue Apr 27 11:13:34 2010
@@ -13,7 +13,8 @@
char *paramspace = "FP";

/*
- * -H2 -T4128 -R4096 is plan9 format
+ * -H2 -T4136 -R4096 is plan9 64-bit format
+ * -H3 -T4128 -R4096 is plan9 32-bit format
* -H5 -T0x80110000 -R4096 is ELF32
*
* options used: 189BLQSWabcjlnpsvz
@@ -122,9 +123,18 @@
diag("unknown -H option");
errorexit();
case 2: /* plan 9 */
+ HEADR = 32L+8L;
+ if(INITTEXT == -1)
+ INITTEXT = 4096+HEADR;
+ if(INITDAT == -1)
+ INITDAT = 0;
+ if(INITRND == -1)
+ INITRND = 4096;
+ break;
+ case 3: /* plan 9 */
HEADR = 32L;
if(INITTEXT == -1)
- INITTEXT = 1024*1024;
+ INITTEXT = 4096+32;
if(INITDAT == -1)
INITDAT = 0;
if(INITRND == -1)
@@ -500,7 +510,11 @@
}
a->offset = 0;
if(t & T_OFFSET) {
- l = (long)(p[c] | (p[c+1]<<8) | (p[c+2]<<16) | (p[c+3]<<24));
+ /*
+ * Hack until Charles fixes the compiler.
+ a->offset = (long)(p[c] | (p[c+1]<<8) | (p[c+2]<<16) | (p[c+3]<<24));
+ */
+ l = p[c] | (p[c+1]<<8) | (p[c+2]<<16) | (p[c+3]<<24);
a->offset = l;
c += 4;
if(t & T_64) {
=======================================
--- /utils/6l/optab.c Sat May 30 17:07:21 2009
+++ /utils/6l/optab.c Tue Apr 27 11:13:34 2010
@@ -608,11 +608,11 @@
{ ACMOVWPS, yml_rl, Pq, 0x4a },
{ ACMPB, ycmpb, Pb, 0x3c,0x80,(07),0x38,0x3a },
{ ACMPL, ycmpl, Px, 0x83,(07),0x3d,0x81,(07),0x39,0x3b },
- { ACMPPD, yxcmpi, Px, Pe,0xc2 },
+ { ACMPPD, yxcmpi, Px, Pe,0xc2 },
{ ACMPPS, yxcmpi, Pm, 0xc2,0 },
{ ACMPQ, ycmpl, Pw, 0x83,(07),0x3d,0x81,(07),0x39,0x3b },
{ ACMPSB, ynone, Pb, 0xa6 },
- { ACMPSD, yxcmpi, Px, Pf2,0xc2 },
+ { ACMPSD, yxcmpi, Px, Pf2,0xc2 },
{ ACMPSL, ynone, Px, 0xa7 },
{ ACMPSQ, ynone, Pw, 0xa7 },
{ ACMPSS, yxcmpi, Px, Pf3,0xc2 },
@@ -620,13 +620,13 @@
{ ACMPW, ycmpl, Pe, 0x83,(07),0x3d,0x81,(07),0x39,0x3b },
{ ACOMISD, yxcmp, Pe, 0x2f },
{ ACOMISS, yxcmp, Pm, 0x2f },
- { ACPUID, ynone, Pm, 0xa2 },
- { ACVTPL2PD, yxcvm2, Px, Pf3,0xe6,Pe,0x2a },
- { ACVTPL2PS, yxcvm2, Pm, 0x5b,0,0x2a,0, },
- { ACVTPD2PL, yxcvm1, Px, Pf2,0xe6,Pe,0x2d },
+ { ACPUID, ynone, Pm, 0xa2 },
+ { ACVTPL2PD, yxcvm2, Px, Pf3,0xe6,Pe,0x2a },
+ { ACVTPL2PS, yxcvm2, Pm, 0x5b,0,0x2a,0, },
+ { ACVTPD2PL, yxcvm1, Px, Pf2,0xe6,Pe,0x2d },
{ ACVTPD2PS, yxm, Pe, 0x5a },
- { ACVTPS2PL, yxcvm1, Px, Pe,0x5b,Pm,0x2d },
- { ACVTPS2PD, yxm, Pm, 0x5a },
+ { ACVTPS2PL, yxcvm1, Px, Pe,0x5b,Pm,0x2d },
+ { ACVTPS2PD, yxm, Pm, 0x5a },
{ API2FW, ymfp, Px, 0x0c },
{ ACVTSD2SL, yxcvfl, Pf2, 0x2d },
{ ACVTSD2SQ, yxcvfq, Pw, Pf2,0x2d },
@@ -638,8 +638,8 @@
{ ACVTSS2SD, yxm, Pf3, 0x5a },
{ ACVTSS2SL, yxcvfl, Pf3, 0x2d },
{ ACVTSS2SQ, yxcvfq, Pw, Pf3,0x2d },
- { ACVTTPD2PL, yxcvm1, Px, Pe,0xe6,Pe,0x2c },
- { ACVTTPS2PL, yxcvm1, Px, Pf3,0x5b,Pm,0x2c },
+ { ACVTTPD2PL, yxcvm1, Px, Pe,0xe6,Pe,0x2c },
+ { ACVTTPS2PL, yxcvm1, Px, Pf3,0x5b,Pm,0x2c },
{ ACVTTSD2SL, yxcvfl, Pf2, 0x2c },
{ ACVTTSD2SQ, yxcvfq, Pw, Pf2,0x2c },
{ ACVTTSS2SL, yxcvfl, Pf3, 0x2c },
@@ -659,7 +659,7 @@
{ ADIVPS, yxm, Pm, 0x5e },
{ ADIVQ, ydivl, Pw, 0xf7,(06) },
{ ADIVSD, yxm, Pf2, 0x5e },
- { ADIVSS, yxm, Pf3, 0x5e },
+ { ADIVSS, yxm, Pf3, 0x5e },
{ ADIVW, ydivl, Pe, 0xf7,(06) },
{ AEMMS, ynone, Pm, 0x77 },
{ AENTER }, /* botch */
@@ -715,7 +715,7 @@
{ ALAHF, ynone, Px, 0x9f },
{ ALARL, yml_rl, Pm, 0x02 },
{ ALARW, yml_rl, Pq, 0x02 },
- { ALDMXCSR, ystcw, Pm, 0xae,(02),0xae,(02) },
+ { ALDMXCSR, ysvrs, Pm, 0xae,(02),0xae,(02) },
{ ALEAL, ym_rl, Px, 0x8d },
{ ALEAQ, ym_rl, Pw, 0x8d },
{ ALEAVEL, ynone, P32, 0xc9 },
@@ -734,15 +734,15 @@
{ ALSLL, yml_rl, Pm, 0x03 },
{ ALSLW, yml_rl, Pq, 0x03 },
{ AMASKMOVOU, yxr, Pe, 0xf7 },
- { AMASKMOVQ, ymr, Pm, 0xf7 },
+ { AMASKMOVQ, ymr, Pm, 0xf7 },
{ AMAXPD, yxm, Pe, 0x5f },
- { AMAXPS, yxm, Pm, 0x5f },
- { AMAXSD, yxm, Pf2, 0x5f },
- { AMAXSS, yxm, Pf3, 0x5f },
- { AMINPD, yxm, Pe, 0x5d },
- { AMINPS, yxm, Pm, 0x5d },
- { AMINSD, yxm, Pf2, 0x5d },
- { AMINSS, yxm, Pf3, 0x5d },
+ { AMAXPS, yxm, Pm, 0x5f },
+ { AMAXSD, yxm, Pf2, 0x5f },
+ { AMAXSS, yxm, Pf3, 0x5f },
+ { AMINPD, yxm, Pe, 0x5d },
+ { AMINPS, yxm, Pm, 0x5d },
+ { AMINSD, yxm, Pf2, 0x5d },
+ { AMINSS, yxm, Pf3, 0x5d },
{ AMOVAPD, yxmov, Pe, 0x28,0x29 },
{ AMOVAPS, yxmov, Pm, 0x28,0x29 },
{ AMOVB, ymovb, Pb, 0x88,0x8a,0xb0,0xc6,(00) },
@@ -770,7 +770,7 @@
{ AMOVNTPS, yxr_ml, Pm, 0x2b },
{ AMOVNTQ, ymr_ml, Pm, 0xe7 },
{ AMOVQ, ymovq, Pw,
0x89,0x8b,0x31,0xc7,(00),0xb8,0xc7,(00),0x6f,0x7f,0x6e,0x7e,Pf2,0xd6,Pe,0xd6,Pe,0x6e,Pe,0x7e
},
- { AMOVQOZX, ymrxr, Pf3, 0xd6,0x7e },
+ { AMOVQOZX, ymrxr, Pf3, 0xd6,0x7e },
{ AMOVSB, ynone, Pb, 0xa4 },
{ AMOVSD, yxmov, Pf2, 0x10,0x11 },
{ AMOVSL, ynone, Px, 0xa5 },
@@ -787,17 +787,17 @@
{ AMULB, ydivb, Pb, 0xf6,(04) },
{ AMULL, ydivl, Px, 0xf7,(04) },
{ AMULPD, yxm, Pe, 0x59 },
- { AMULPS, yxm, Ym, 0x59 },
+ { AMULPS, yxm, Ym, 0x59 },
{ AMULQ, ydivl, Pw, 0xf7,(04) },
{ AMULSD, yxm, Pf2, 0x59 },
- { AMULSS, yxm, Pf3, 0x59 },
+ { AMULSS, yxm, Pf3, 0x59 },
{ AMULW, ydivl, Pe, 0xf7,(04) },
{ ANAME },
{ ANEGB, yscond, Pb, 0xf6,(03) },
{ ANEGL, yscond, Px, 0xf7,(03) },
{ ANEGQ, yscond, Pw, 0xf7,(03) },
{ ANEGW, yscond, Pe, 0xf7,(03) },
- { ANOP, ynop, Px,0,0 },
+ { ANOP, ynop, Px, 0,0 },
{ ANOTB, yscond, Pb, 0xf6,(02) },
{ ANOTL, yscond, Px, 0xf7,(02) },
{ ANOTQ, yscond, Pw, 0xf7,(02) },
@@ -814,60 +814,60 @@
{ AOUTSL, ynone, Px, 0x6f },
{ AOUTSW, ynone, Pe, 0x6f },
{ AOUTW, yin, Pe, 0xe7,0xef },
- { APACKSSLW, ymm, Py, 0x6b,Pe,0x6b },
- { APACKSSWB, ymm, Py, 0x63,Pe,0x63 },
- { APACKUSWB, ymm, Py, 0x67,Pe,0x67 },
- { APADDB, ymm, Py, 0xfc,Pe,0xfc },
- { APADDL, ymm, Py, 0xfe,Pe,0xfe },
+ { APACKSSLW, ymm, Py, 0x6b,Pe,0x6b },
+ { APACKSSWB, ymm, Py, 0x63,Pe,0x63 },
+ { APACKUSWB, ymm, Py, 0x67,Pe,0x67 },
+ { APADDB, ymm, Py, 0xfc,Pe,0xfc },
+ { APADDL, ymm, Py, 0xfe,Pe,0xfe },
{ APADDQ, yxm, Pe, 0xd4 },
- { APADDSB, ymm, Py, 0xec,Pe,0xec },
- { APADDSW, ymm, Py, 0xed,Pe,0xed },
- { APADDUSB, ymm, Py, 0xdc,Pe,0xdc },
- { APADDUSW, ymm, Py, 0xdd,Pe,0xdd },
- { APADDW, ymm, Py, 0xfd,Pe,0xfd },
- { APAND, ymm, Py, 0xdb,Pe,0xdb },
- { APANDN, ymm, Py, 0xdf,Pe,0xdf },
- { APAVGB, ymm, Py, 0xe0,Pe,0xe0 },
- { APAVGW, ymm, Py, 0xe3,Pe,0xe3 },
- { APCMPEQB, ymm, Py, 0x74,Pe,0x74 },
- { APCMPEQL, ymm, Py, 0x76,Pe,0x76 },
- { APCMPEQW, ymm, Py, 0x75,Pe,0x75 },
- { APCMPGTB, ymm, Py, 0x64,Pe,0x64 },
- { APCMPGTL, ymm, Py, 0x66,Pe,0x66 },
- { APCMPGTW, ymm, Py, 0x65,Pe,0x65 },
- { APEXTRW, yextrw, Pq, 0xc5 },
- { APF2IL, ymfp, Px, 0x1d },
- { APF2IW, ymfp, Px, 0x1c },
- { API2FL, ymfp, Px, 0x0d },
- { APFACC, ymfp, Px, 0xae },
- { APFADD, ymfp, Px, 0x9e },
- { APFCMPEQ, ymfp, Px, 0xb0 },
- { APFCMPGE, ymfp, Px, 0x90 },
- { APFCMPGT, ymfp, Px, 0xa0 },
- { APFMAX, ymfp, Px, 0xa4 },
- { APFMIN, ymfp, Px, 0x94 },
- { APFMUL, ymfp, Px, 0xb4 },
- { APFNACC, ymfp, Px, 0x8a },
- { APFPNACC, ymfp, Px, 0x8e },
- { APFRCP, ymfp, Px, 0x96 },
- { APFRCPIT1, ymfp, Px, 0xa6 },
- { APFRCPI2T, ymfp, Px, 0xb6 },
- { APFRSQIT1, ymfp, Px, 0xa7 },
- { APFRSQRT, ymfp, Px, 0x97 },
- { APFSUB, ymfp, Px, 0x9a },
- { APFSUBR, ymfp, Px, 0xaa },
- { APINSRW, yextrw, Pq, 0xc4 },
- { APMADDWL, ymm, Py, 0xf5,Pe,0xf5 },
+ { APADDSB, ymm, Py, 0xec,Pe,0xec },
+ { APADDSW, ymm, Py, 0xed,Pe,0xed },
+ { APADDUSB, ymm, Py, 0xdc,Pe,0xdc },
+ { APADDUSW, ymm, Py, 0xdd,Pe,0xdd },
+ { APADDW, ymm, Py, 0xfd,Pe,0xfd },
+ { APAND, ymm, Py, 0xdb,Pe,0xdb },
+ { APANDN, ymm, Py, 0xdf,Pe,0xdf },
+ { APAVGB, ymm, Py, 0xe0,Pe,0xe0 },
+ { APAVGW, ymm, Py, 0xe3,Pe,0xe3 },
+ { APCMPEQB, ymm, Py, 0x74,Pe,0x74 },
+ { APCMPEQL, ymm, Py, 0x76,Pe,0x76 },
+ { APCMPEQW, ymm, Py, 0x75,Pe,0x75 },
+ { APCMPGTB, ymm, Py, 0x64,Pe,0x64 },
+ { APCMPGTL, ymm, Py, 0x66,Pe,0x66 },
+ { APCMPGTW, ymm, Py, 0x65,Pe,0x65 },
+ { APEXTRW, yextrw, Pq, 0xc5 },
+ { APF2IL, ymfp, Px, 0x1d },
+ { APF2IW, ymfp, Px, 0x1c },
+ { API2FL, ymfp, Px, 0x0d },
+ { APFACC, ymfp, Px, 0xae },
+ { APFADD, ymfp, Px, 0x9e },
+ { APFCMPEQ, ymfp, Px, 0xb0 },
+ { APFCMPGE, ymfp, Px, 0x90 },
+ { APFCMPGT, ymfp, Px, 0xa0 },
+ { APFMAX, ymfp, Px, 0xa4 },
+ { APFMIN, ymfp, Px, 0x94 },
+ { APFMUL, ymfp, Px, 0xb4 },
+ { APFNACC, ymfp, Px, 0x8a },
+ { APFPNACC, ymfp, Px, 0x8e },
+ { APFRCP, ymfp, Px, 0x96 },
+ { APFRCPIT1, ymfp, Px, 0xa6 },
+ { APFRCPI2T, ymfp, Px, 0xb6 },
+ { APFRSQIT1, ymfp, Px, 0xa7 },
+ { APFRSQRT, ymfp, Px, 0x97 },
+ { APFSUB, ymfp, Px, 0x9a },
+ { APFSUBR, ymfp, Px, 0xaa },
+ { APINSRW, yextrw, Pq, 0xc4 },
+ { APMADDWL, ymm, Py, 0xf5,Pe,0xf5 },
{ APMAXSW, yxm, Pe, 0xee },
- { APMAXUB, yxm, Pe, 0xde },
- { APMINSW, yxm, Pe, 0xea },
- { APMINUB, yxm, Pe, 0xda },
- { APMOVMSKB, ymskb, Px, Pe,0xd7,0xd7 },
- { APMULHRW, ymfp, Px, 0xb7 },
- { APMULHUW, ymm, Py, 0xe4,Pe,0xe4 },
- { APMULHW, ymm, Py, 0xe5,Pe,0xe5 },
- { APMULLW, ymm, Py, 0xd5,Pe,0xd5 },
- { APMULULQ, ymm, Py, 0xf4,Pe,0xf4 },
+ { APMAXUB, yxm, Pe, 0xde },
+ { APMINSW, yxm, Pe, 0xea },
+ { APMINUB, yxm, Pe, 0xda },
+ { APMOVMSKB, ymskb, Px, Pe,0xd7,0xd7 },
+ { APMULHRW, ymfp, Px, 0xb7 },
+ { APMULHUW, ymm, Py, 0xe4,Pe,0xe4 },
+ { APMULHW, ymm, Py, 0xe5,Pe,0xe5 },
+ { APMULLW, ymm, Py, 0xd5,Pe,0xd5 },
+ { APMULULQ, ymm, Py, 0xf4,Pe,0xf4 },
{ APOPAL, ynone, P32, 0x61 },
{ APOPAW, ynone, Pe, 0x61 },
{ APOPFL, ynone, P32, 0x9d },
@@ -876,39 +876,39 @@
{ APOPL, ypopl, P32, 0x58,0x8f,(00) },
{ APOPQ, ypopl, Py, 0x58,0x8f,(00) },
{ APOPW, ypopl, Pe, 0x58,0x8f,(00) },
- { APOR, ymm, Py, 0xeb,Pe,0xeb },
- { APSADBW, yxm, Pw, Pe,0xf6 },
+ { APOR, ymm, Py, 0xeb,Pe,0xeb },
+ { APSADBW, yxm, Pw, Pe,0xf6 },
{ APSHUFHW, yxshuf, Pf3, 0x70 },
- { APSHUFL, yxm, Pw, Pe,0x70 },
+ { APSHUFL, yxm, Pw, Pe,0x70 },
{ APSHUFLW, yxshuf, Pf2, 0x70 },
- { APSHUFW, ymshuf, Pm, 0x70 },
+ { APSHUFW, ymshuf, Pm, 0x70 },
{ APSLLO, ypsdq, Pq, 0x73,(07) },
- { APSLLL, yps, Py, 0xf2, 0x72,(06), Pe,0xf2, Pe,0x72,(06) },
- { APSLLQ, yps, Py, 0xf3, 0x73,(06), Pe,0xf3, Pe,0x7e,(06) },
- { APSLLW, yps, Py, 0xf1, 0x71,(06), Pe,0xf1, Pe,0x71,(06) },
- { APSRAL, yps, Py, 0xe2, 0x72,(04), Pe,0xe2, Pe,0x72,(04) },
- { APSRAW, yps, Py, 0xe1, 0x71,(04), Pe,0xe1, Pe,0x71,(04) },
+ { APSLLL, yps, Py, 0xf2, 0x72,(06), Pe,0xf2, Pe,0x72,(06) },
+ { APSLLQ, yps, Py, 0xf3, 0x73,(06), Pe,0xf3, Pe,0x7e,(06) },
+ { APSLLW, yps, Py, 0xf1, 0x71,(06), Pe,0xf1, Pe,0x71,(06) },
+ { APSRAL, yps, Py, 0xe2, 0x72,(04), Pe,0xe2, Pe,0x72,(04) },
+ { APSRAW, yps, Py, 0xe1, 0x71,(04), Pe,0xe1, Pe,0x71,(04) },
{ APSRLO, ypsdq, Pq, 0x73,(03) },
- { APSRLL, yps, Py, 0xd2, 0x72,(02), Pe,0xd2, Pe,0x72,(02) },
- { APSRLQ, yps, Py, 0xd3, 0x73,(02), Pe,0xd3, Pe,0x73,(02) },
- { APSRLW, yps, Py, 0xd1, 0x71,(02), Pe,0xe1, Pe,0x71,(02) },
- { APSUBB, yxm, Pe, 0xf8 },
- { APSUBL, yxm, Pe, 0xfa },
- { APSUBQ, yxm, Pe, 0xfb },
- { APSUBSB, yxm, Pe, 0xe8 },
- { APSUBSW, yxm, Pe, 0xe9 },
- { APSUBUSB, yxm, Pe, 0xd8 },
- { APSUBUSW, yxm, Pe, 0xd9 },
- { APSUBW, yxm, Pe, 0xf9 },
- { APSWAPL, ymfp, Px, 0xbb },
- { APUNPCKHBW, ymm, Py, 0x68,Pe,0x68 },
- { APUNPCKHLQ, ymm, Py, 0x6a,Pe,0x6a },
- { APUNPCKHQDQ, yxm, Pe, 0x6d },
- { APUNPCKHWL, ymm, Py, 0x69,Pe,0x69 },
- { APUNPCKLBW, ymm, Py, 0x60,Pe,0x60 },
- { APUNPCKLLQ, ymm, Py, 0x62,Pe,0x62 },
- { APUNPCKLQDQ, yxm, Pe, 0x6c },
- { APUNPCKLWL, ymm, Py, 0x61,Pe,0x61 },
+ { APSRLL, yps, Py, 0xd2, 0x72,(02), Pe,0xd2, Pe,0x72,(02) },
+ { APSRLQ, yps, Py, 0xd3, 0x73,(02), Pe,0xd3, Pe,0x73,(02) },
+ { APSRLW, yps, Py, 0xd1, 0x71,(02), Pe,0xe1, Pe,0x71,(02) },
+ { APSUBB, yxm, Pe, 0xf8 },
+ { APSUBL, yxm, Pe, 0xfa },
+ { APSUBQ, yxm, Pe, 0xfb },
+ { APSUBSB, yxm, Pe, 0xe8 },
+ { APSUBSW, yxm, Pe, 0xe9 },
+ { APSUBUSB, yxm, Pe, 0xd8 },
+ { APSUBUSW, yxm, Pe, 0xd9 },
+ { APSUBW, yxm, Pe, 0xf9 },
+ { APSWAPL, ymfp, Px, 0xbb },
+ { APUNPCKHBW, ymm, Py, 0x68,Pe,0x68 },
+ { APUNPCKHLQ, ymm, Py, 0x6a,Pe,0x6a },
+ { APUNPCKHQDQ, yxm, Pe, 0x6d },
+ { APUNPCKHWL, ymm, Py, 0x69,Pe,0x69 },
+ { APUNPCKLBW, ymm, Py, 0x60,Pe,0x60 },
+ { APUNPCKLLQ, ymm, Py, 0x62,Pe,0x62 },
+ { APUNPCKLQDQ, yxm, Pe, 0x6c },
+ { APUNPCKLWL, ymm, Py, 0x61,Pe,0x61 },
{ APUSHAL, ynone, P32, 0x60 },
{ APUSHAW, ynone, Pe, 0x60 },
{ APUSHFL, ynone, P32, 0x9c },
@@ -917,7 +917,7 @@
{ APUSHL, ypushl, P32, 0x50,0xff,(06),0x6a,0x68 },
{ APUSHQ, ypushl, Py, 0x50,0xff,(06),0x6a,0x68 },
{ APUSHW, ypushl, Pe, 0x50,0xff,(06),0x6a,0x68 },
- { APXOR, ymm, Py, 0xef,Pe,0xef },
+ { APXOR, ymm, Py, 0xef,Pe,0xef },
{ AQUAD, ybyte, Px, 8 },
{ ARCLB, yshb, Pb, 0xd0,(02),0xc0,(02),0xd2,(02) },
{ ARCLL, yshl, Px, 0xd1,(02),0xc1,(02),0xd3,(02),0xd3,(02) },
@@ -932,9 +932,9 @@
{ AREP, ynone, Px, 0xf3 },
{ AREPN, ynone, Px, 0xf2 },
{ ARET, ynone, Px, 0xc3 },
- { ARETFW, yret, Pe, 0xcb,0xca },
- { ARETFL, yret, Px, 0xcb,0xca },
- { ARETFQ, yret, Pw, 0xcb,0xca },
+ { ARETFW, yret, Pe, 0xcb,0xca },
+ { ARETFL, yret, Px, 0xcb,0xca },
+ { ARETFQ, yret, Pw, 0xcb,0xca },
{ AROLB, yshb, Pb, 0xd0,(00),0xc0,(00),0xd2,(00) },
{ AROLL, yshl, Px, 0xd1,(00),0xc1,(00),0xd3,(00),0xd3,(00) },
{ AROLQ, yshl, Pw, 0xd1,(00),0xc1,(00),0xd3,(00),0xd3,(00) },
@@ -989,13 +989,13 @@
{ ASHUFPD, yxshuf, Pq, 0xc6 },
{ ASHUFPS, yxshuf, Pm, 0xc6 },
{ ASQRTPD, yxm, Pe, 0x51 },
- { ASQRTPS, yxm, Pm, 0x51 },
+ { ASQRTPS, yxm, Pm, 0x51 },
{ ASQRTSD, yxm, Pf2, 0x51 },
{ ASQRTSS, yxm, Pf3, 0x51 },
{ ASTC, ynone, Px, 0xf9 },
{ ASTD, ynone, Px, 0xfd },
{ ASTI, ynone, Px, 0xfb },
- { ASTMXCSR, ystcw, Pm, 0xae,(03),0xae,(03) },
+ { ASTMXCSR, ysvrs, Pm, 0xae,(03),0xae,(03) },
{ ASTOSB, ynone, Pb, 0xaa },
{ ASTOSL, ynone, Px, 0xab },
{ ASTOSQ, ynone, Pw, 0xab },
@@ -1008,8 +1008,7 @@
{ ASUBSD, yxm, Pf2, 0x5c },
{ ASUBSS, yxm, Pf3, 0x5c },
{ ASUBW, yaddl, Pe, 0x83,(05),0x2d,0x81,(05),0x29,0x2b },
- { ASWAPGS, ynone, Pm, 0x01,0xf8 },
-/* { ASYSCALL, ynone, Px, 0xcd,0x40 },*/ /* INT $64, plan 9 syscall
(32-bit) */
+ { ASWAPGS, ynone, Pm, 0x01,0xf8 },
{ ASYSCALL, ynone, Px, 0x0f,0x05 }, /* fast syscall */
{ ATESTB, ytestb, Pb, 0xa8,0xf6,(00),0x84,0x84 },
{ ATESTL, ytestl, Px, 0xa9,0xf7,(00),0x85,0x85 },
@@ -1027,7 +1026,7 @@
{ AWAIT, ynone, Px, 0x9b },
{ AWORD, ybyte, Px, 2 },
{ AXCHGB, yml_mb, Pb, 0x86,0x86 },
- { AXCHGL, yml_ml, Px, 0x87,0x87 },
+ { AXCHGL, yml_ml, Px, 0x87,0x87 },
{ AXCHGQ, yml_ml, Pw, 0x87,0x87 },
{ AXCHGW, yml_ml, Pe, 0x87,0x87 },
{ AXLAT, ynone, Px, 0xd7 },
@@ -1148,27 +1147,27 @@
{ ACMPXCHGB, yrb_mb, Pb, 0x0f,0xb0 },
{ ACMPXCHGL, yrl_ml, Px, 0x0f,0xb1 },
{ ACMPXCHGW, yrl_ml, Pe, 0x0f,0xb1 },
- { ACMPXCHGQ, yrl_ml, Pw, 0x0f,0xb1 },
- { ACMPXCHG8B, yscond, Pm, 0xc7,(01) },
- { AINVD, ynone, Pm, 0x08 },
- { AINVLPG, ymbs, Pm, 0x01,(07) },
- { ALFENCE, ynone, Pm, 0xae,0xe8 },
- { AMFENCE, ynone, Pm, 0xae,0xf0 },
- { AMOVNTIL, yrl_ml, Pm, 0xc3 },
- { AMOVNTIQ, yrl_ml, Pw, 0x0f,0xc3 },
- { ARDMSR, ynone, Pm, 0x32 },
- { ARDPMC, ynone, Pm, 0x33 },
- { ARDTSC, ynone, Pm, 0x31 },
- { ARSM, ynone, Pm, 0xaa },
- { ASFENCE, ynone, Pm, 0xae,0xf8 },
- { ASYSRET, ynone, Pm, 0x07 },
- { AWBINVD, ynone, Pm, 0x09 },
- { AWRMSR, ynone, Pm, 0x30 },
-
- { AXADDB, yrb_mb, Pb, 0x0f,0xc0 },
- { AXADDL, yrl_ml, Px, 0x0f,0xc1 },
- { AXADDQ, yrl_ml, Pw, 0x0f,0xc1 },
- { AXADDW, yrl_ml, Pe, 0x0f,0xc1 },
+ { ACMPXCHGQ, yrl_ml, Pw, 0x0f,0xb1 },
+ { ACMPXCHG8B, yscond, Pm, 0xc7,(01) },
+ { AINVD, ynone, Pm, 0x08 },
+ { AINVLPG, ymbs, Pm, 0x01,(07) },
+ { ALFENCE, ynone, Pm, 0xae,0xe8 },
+ { AMFENCE, ynone, Pm, 0xae,0xf0 },
+ { AMOVNTIL, yrl_ml, Pm, 0xc3 },
+ { AMOVNTIQ, yrl_ml, Pw, 0x0f,0xc3 },
+ { ARDMSR, ynone, Pm, 0x32 },
+ { ARDPMC, ynone, Pm, 0x33 },
+ { ARDTSC, ynone, Pm, 0x31 },
+ { ARSM, ynone, Pm, 0xaa },
+ { ASFENCE, ynone, Pm, 0xae,0xf8 },
+ { ASYSRET, ynone, Pm, 0x07 },
+ { AWBINVD, ynone, Pm, 0x09 },
+ { AWRMSR, ynone, Pm, 0x30 },
+
+ { AXADDB, yrb_mb, Pb, 0x0f,0xc0 },
+ { AXADDL, yrl_ml, Px, 0x0f,0xc1 },
+ { AXADDQ, yrl_ml, Pw, 0x0f,0xc1 },
+ { AXADDW, yrl_ml, Pe, 0x0f,0xc1 },

{ AEND },
0
=======================================
--- /utils/6l/span.c Sat May 30 17:07:21 2009
+++ /utils/6l/span.c Tue Apr 27 11:13:34 2010
@@ -120,12 +120,17 @@
}

void
-putsymb(char *s, int t, long v, int ver)
-{
- int i, f;
+putsymb(char *s, int t, vlong v, int ver)
+{
+ int i, f, l;

if(t == 'f')
s++;
+ l = 4;
+ if(!debug['8']){
+ lput(v>>32);
+ l = 8;
+ }
lput(v);
if(ver)
t += 'a' - 'A';
@@ -146,11 +151,11 @@
cput(s[i]);
cput(0);
}
- symsize += 4 + 1 + i + 1;
+ symsize += l + 1 + i + 1;

if(debug['n']) {
if(t == 'z' || t == 'Z') {
- Bprint(&bso, "%c %.8lux ", t, v);
+ Bprint(&bso, "%c %.8llux ", t, v);
for(i=1; s[i] != 0 || s[i+1] != 0; i+=2) {
f = ((s[i]&0xff) << 8) | (s[i+1]&0xff);
Bprint(&bso, "/%x", f);
@@ -159,9 +164,9 @@
return;
}
if(ver)
- Bprint(&bso, "%c %.8lux %s<%d>\n", t, v, s, ver);
+ Bprint(&bso, "%c %.8llux %s<%d>\n", t, v, s, ver);
else
- Bprint(&bso, "%c %.8lux %s\n", t, v, s);
+ Bprint(&bso, "%c %.8llux %s\n", t, v, s);
}
}

@@ -213,7 +218,7 @@
putsymb(s->name, 'T', s->value, s->version);

/* frame, auto and param after */
- putsymb(".frame", 'm', p->to.offset+4, 0);
+ putsymb(".frame", 'm', p->to.offset+8, 0);

for(a=p->to.autom; a; a=a->link)
if(a->type == D_AUTO)
@@ -230,9 +235,9 @@
void
asmlc(void)
{
- long oldpc, oldlc;
+ vlong oldpc;
Prog *p;
- long v, s;
+ long oldlc, v, s;

oldpc = INITTEXT;
oldlc = 0;

==============================================================================
Revision: 05b8866b1f
Author: for...@vitanuova.com
Date: Tue Apr 27 13:15:13 2010
Log: 20100427-2115
http://code.google.com/p/inferno-npe/source/detail?r=05b8866b1f

Modified:
/utils/8c/8.out.h
/utils/8c/cgen.c
/utils/8c/cgen64.c
/utils/8c/gc.h
/utils/8c/mkfile
/utils/8c/peep.c
/utils/8c/sgen.c
/utils/8c/swt.c
/utils/8c/txt.c
/utils/8l/asm.c
/utils/8l/l.h
/utils/8l/list.c
/utils/8l/obj.c
/utils/8l/pass.c
/utils/8l/span.c
/utils/kl/span.c

=======================================
--- /utils/8c/8.out.h Fri Dec 22 13:39:35 2006
+++ /utils/8c/8.out.h Tue Apr 27 13:15:13 2010
@@ -420,7 +420,7 @@
T_SYM = 1<<4,
T_SCONST = 1<<5,

- REGARG = 0,
+ REGARG = -1,
REGRET = D_AX,
FREGRET = D_F0,
REGSP = D_SP,
=======================================
--- /utils/8c/cgen.c Fri Dec 22 13:39:35 2006
+++ /utils/8c/cgen.c Tue Apr 27 13:15:13 2010
@@ -895,7 +895,7 @@
regfree(&nod);
} else
gopcode(OFUNC, n->type, Z, l);
- if(REGARG && reg[REGARG])
+ if(REGARG>=0 && reg[REGARG])
reg[REGARG]--;
if(nn != Z) {
regret(&nod, n);
=======================================
--- /utils/8c/cgen64.c Fri Dec 22 13:39:35 2006
+++ /utils/8c/cgen64.c Tue Apr 27 13:15:13 2010
@@ -2681,7 +2681,19 @@
testv(Node *n, int true)
{
Type *t;
- Node *nn, nod;
+ Node *nn, nod, *b;
+
+ if(machcap(Z)) {
+ b = &nod;
+ b->op = true ? ONE : OEQ;
+ b->left = n;
+ b->right = new(0, Z, Z);
+ *b->right = *nodconst(0);
+ b->right->type = n->type;
+ b->type = types[TLONG];
+ cgen64(b, Z);
+ return;
+ }

switch(n->op) {
case OINDREG:
=======================================
--- /utils/8c/gc.h Tue Apr 27 04:51:13 2010
+++ /utils/8c/gc.h Tue Apr 27 13:15:13 2010
@@ -64,6 +64,7 @@
long val;
long label;
char def;
+ char isv;
};
#define C ((Case*)0)

@@ -131,6 +132,7 @@
};

EXTERN long breakpc;
+EXTERN long nbreak;
EXTERN Case* cases;
EXTERN Node constnode;
EXTERN Node fconstnode;
@@ -141,7 +143,6 @@
EXTERN Prog* lastp;
EXTERN long maxargsafe;
EXTERN int mnstring;
-EXTERN int retok;
EXTERN Node* nodrat;
EXTERN Node* nodret;
EXTERN Node* nodsafe;
=======================================
--- /utils/8c/mkfile Fri Dec 22 13:39:35 2006
+++ /utils/8c/mkfile Tue Apr 27 13:15:13 2010
@@ -11,6 +11,8 @@
txt.$O\
reg.$O\
peep.$O\
+ pgen.$O\
+ pswt.$O\
machcap.$O\
cgen64.$O\
div.$O\
@@ -33,3 +35,9 @@
cd ../cc
mk $MKFLAGS install
mk $MKFLAGS clean
+
+%.$O: ../cc/%.c
+ $CC $CFLAGS -I. ../cc/$stem.c
+
+#enam.c: 8.out.h
+# rc mkenam
=======================================
--- /utils/8c/peep.c Fri Dec 22 13:39:35 2006
+++ /utils/8c/peep.c Tue Apr 27 13:15:13 2010
@@ -669,7 +669,7 @@
return 3;

case ACALL: /* funny */
- if(REGARG && v->type == REGARG)
+ if(REGARG>=0 && v->type == REGARG)
return 2;

if(s != A) {
=======================================
--- /utils/8c/sgen.c Tue Apr 27 04:51:13 2010
+++ /utils/8c/sgen.c Tue Apr 27 13:15:13 2010
@@ -1,383 +1,4 @@
#include "gc.h"
-
-void
-codgen(Node *n, Node *nn)
-{
- Prog *sp;
- Node *n1, nod, nod1;
-
- cursafe = 0;
- curarg = 0;
- maxargsafe = 0;
-
- /*
- * isolate name
- */
- for(n1 = nn;; n1 = n1->left) {
- if(n1 == Z) {
- diag(nn, "cant find function name");
- return;
- }
- if(n1->op == ONAME)
- break;
- }
- nearln = nn->lineno;
- gpseudo(ATEXT, n1->sym, nodconst(stkoff));
-
- /*
- * isolate first argument
- */
- if(REGARG) {
- if(typesuv[thisfn->link->etype]) {
- nod1 = *nodret->left;
- nodreg(&nod, &nod1, REGARG);
- gmove(&nod, &nod1);
- } else
- if(firstarg && typechlp[firstargtype->etype]) {
- nod1 = *nodret->left;
- nod1.sym = firstarg;
- nod1.type = firstargtype;
- nod1.xoffset = align(0, firstargtype, Aarg1);
- nod1.etype = firstargtype->etype;
- nodreg(&nod, &nod1, REGARG);
- gmove(&nod, &nod1);
- }
- }
-
- sp = p;
- retok = 0;
- gen(n);
- if(!retok)
- if(thisfn->link->etype != TVOID)
- warn(Z, "no return at end of function: %s", n1->sym->name);
- noretval(3);
- if(thisfn && thisfn->link && typefd[thisfn->link->etype])
- gins(AFLDZ, Z, Z);
- gbranch(ORETURN);
-
- if(!debug['N'] || debug['R'] || debug['P'])
- regopt(sp);
- sp->to.offset += maxargsafe;
-}
-
-void
-supgen(Node *n)
-{
- long spc;
- Prog *sp;
-
- if(n == Z)
- return;
- suppress++;
- spc = pc;
- sp = lastp;
- gen(n);
- lastp = sp;
- pc = spc;
- sp->link = nil;
- suppress--;
-}
-
-void
-gen(Node *n)
-{
- Node *l, nod;
- Prog *sp, *spc, *spb;
- Case *cn;
- long sbc, scc;
- int f, o;
-
-loop:
- if(n == Z)
- return;
- nearln = n->lineno;
- o = n->op;
- if(debug['G'])
- if(o != OLIST)
- print("%L %O\n", nearln, o);
-
- retok = 0;
- switch(o) {
-
- default:
- complex(n);
- cgen(n, Z);
- break;
-
- case OLIST:
- gen(n->left);
-
- rloop:
- n = n->right;
- goto loop;
-
- case ORETURN:
- retok = 1;
- complex(n);
- if(n->type == T)
- break;
- l = n->left;
- if(l == Z) {
- noretval(3);
- if(typefd[n->type->etype])
- gins(AFLDZ, Z, Z);
- gbranch(ORETURN);
- break;
- }
- if(typesuv[n->type->etype]) {
- sugen(l, nodret, n->type->width);
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- regret(&nod, n);
- cgen(l, &nod);
- regfree(&nod);
- if(typefd[n->type->etype])
- noretval(1);
- else
- noretval(2);
- gbranch(ORETURN);
- break;
-
- case OLABEL:
- l = n->left;
- if(l) {
- l->xoffset = pc;
- if(l->label)
- patch(l->label, pc);
- }
- gbranch(OGOTO); /* prevent self reference in reg */
- patch(p, pc);
- goto rloop;
-
- case OGOTO:
- retok = 1;
- n = n->left;
- if(n == Z)
- return;
- if(n->complex == 0) {
- diag(Z, "label undefined: %s", n->sym->name);
- return;
- }
- if(suppress)
- return;
- gbranch(OGOTO);
- if(n->xoffset) {
- patch(p, n->xoffset);
- return;
- }
- if(n->label)
- patch(n->label, pc-1);
- n->label = p;
- return;
-
- case OCASE:
- l = n->left;
- if(cases == C)
- diag(n, "case/default outside a switch");
- if(l == Z) {
- casf();
- cases->val = 0;
- cases->def = 1;
- cases->label = pc;
- goto rloop;
- }
- complex(l);
- if(l->type == T)
- goto rloop;
- if(l->op == OCONST)
- if(typechl[l->type->etype]) {
- casf();
- cases->val = l->vconst;
- cases->def = 0;
- cases->label = pc;
- goto rloop;
- }
- diag(n, "case expression must be integer constant");
- goto rloop;
-
- case OSWITCH:
- l = n->left;
- complex(l);
- if(l->type == T)
- break;
- if(!typechl[l->type->etype]) {
- diag(n, "switch expression must be integer");
- break;
- }
-
- gbranch(OGOTO); /* entry */
- sp = p;
-
- cn = cases;
- cases = C;
- casf();
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- gen(n->right);
- gbranch(OGOTO);
- patch(p, breakpc);
-
- patch(sp, pc);
- regalloc(&nod, l, Z);
- nod.type = types[TLONG];
- cgen(l, &nod);
- doswit(&nod);
- regfree(&nod);
- patch(spb, pc);
-
- cases = cn;
- breakpc = sbc;
- break;
-
- case OWHILE:
- case ODWHILE:
- l = n->left;
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- if(n->op == OWHILE)
- patch(sp, pc);
- bcomplex(l, Z); /* test */
- patch(p, breakpc);
-
- if(n->op == ODWHILE)
- patch(sp, pc);
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OFOR:
- l = n->left;
- gen(l->right->left); /* init */
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- gen(l->right->right); /* inc */
- patch(sp, pc);
- if(l->left != Z) { /* test */
- bcomplex(l->left, Z);
- patch(p, breakpc);
- }
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OCONTINUE:
- if(continpc < 0) {
- diag(n, "continue not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, continpc);
- break;
-
- case OBREAK:
- if(breakpc < 0) {
- diag(n, "break not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, breakpc);
- break;
-
- case OIF:
- l = n->left;
- if(bcomplex(l, n->right)) {
- if(typefd[l->type->etype])
- f = !l->fconst;
- else
- f = !l->vconst;
- if(debug['c'])
- print("%L const if %s\n", nearln, f ? "false" : "true");
- if(f) {
- supgen(n->right->left);
- gen(n->right->right);
- }
- else {
- gen(n->right->left);
- supgen(n->right->right);
- }
- }
- else {
- sp = p;
- if(n->right->left != Z)
- gen(n->right->left);
- if(n->right->right != Z) {
- gbranch(OGOTO);
- patch(sp, pc);
- sp = p;
- gen(n->right->right);
- }
- patch(sp, pc);
- }
- break;
-
- case OSET:
- case OUSED:
- usedset(n->left, o);
- break;
- }
-}
-
-void
-usedset(Node *n, int o)
-{
- if(n->op == OLIST) {
- usedset(n->left, o);
- usedset(n->right, o);
- return;
- }
- complex(n);
- switch(n->op) {
- case OADDR: /* volatile */
- gins(ANOP, n, Z);
- break;
- case ONAME:
- if(o == OSET)
- gins(ANOP, Z, n);
- else
- gins(ANOP, n, Z);
- break;
- }
-}

void
noretval(int n)
@@ -391,6 +12,9 @@
gins(ANOP, Z, Z);
p->to.type = FREGRET;
}
+ if((n&3) == 3)
+ if(thisfn && thisfn->link && typefd[thisfn->link->etype])
+ gins(AFLDZ, Z, Z);
}

/* welcome to commute */
@@ -810,33 +434,3 @@
prtree(idx.basetree, "base");
}
}
-
-int
-bcomplex(Node *n, Node *c)
-{
- Node *b, nod;
-
- complex(n);
- if(n->type != T)
- if(tcompat(n, T, n->type, tnot))
- n->type = T;
- if(n->type != T) {
- if(c != Z && n->op == OCONST && deadheads(c))
- return 1;
- if(typev[n->type->etype] && machcap(Z)) {
- b = &nod;
- b->op = ONE;
- b->left = n;
- b->right = new(0, Z, Z);
- *b->right = *nodconst(0);
- b->right->type = n->type;
- b->type = types[TLONG];
- cgen64(b, Z);
- return 0;
- }
- bool64(n);
- boolgen(n, 1, Z);
- } else
- gbranch(OGOTO);
- return 0;
-}
=======================================
--- /utils/8c/swt.c Tue Apr 27 04:51:13 2010
+++ /utils/8c/swt.c Tue Apr 27 13:15:13 2010
@@ -1,56 +1,4 @@
#include "gc.h"
-
-int
-swcmp(const void *a1, const void *a2)
-{
- C1 *p1, *p2;
-
- p1 = (C1*)a1;
- p2 = (C1*)a2;
- if(p1->val < p2->val)
- return -1;
- return p1->val > p2->val;
-}
-
-void
-doswit(Node *n)
-{
- Case *c;
- C1 *q, *iq;
- long def, nc, i;
-
- def = 0;
- nc = 0;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def) {
- if(def)
- diag(n, "more than one default in switch");
- def = c->label;
- continue;
- }
- nc++;
- }
-
- iq = alloc(nc*sizeof(C1));
- q = iq;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def)
- continue;
- q->label = c->label;
- q->val = c->val;
- q++;
- }
- qsort(iq, nc, sizeof(C1), swcmp);
- if(debug['W'])
- for(i=0; i<nc; i++)
- print("case %2ld: = %.8lux\n", i, iq[i].val);
- if(def == 0)
- def = breakpc;
- for(i=0; i<nc-1; i++)
- if(iq[i].val == iq[i+1].val)
- diag(n, "duplicate cases in switch %ld", iq[i].val);
- swit1(iq, nc, def, n);
-}

void
swit1(C1 *q, int nc, long def, Node *n)
@@ -87,16 +35,6 @@
patch(sp, pc);
swit1(r+1, nc-i-1, def, n);
}
-
-void
-casf(void)
-{
- Case *c;
-
- c = alloc(sizeof(*c));
- c->link = cases;
- cases = c;
-}

void
bitload(Node *b, Node *n1, Node *n2, Node *n3, Node *nn)
@@ -188,43 +126,6 @@
}
return r;
}
-
-long
-outlstring(ushort *s, long n)
-{
- char buf[2];
- int c;
- long r;
-
- if(suppress)
- return nstring;
- while(nstring & 1)
- outstring("", 1);
- r = nstring;
- while(n > 0) {
- c = *s++;
- if(align(0, types[TCHAR], Aarg1)) {
- buf[0] = c>>8;
- buf[1] = c;
- } else {
- buf[0] = c;
- buf[1] = c>>8;
- }
- outstring(buf, 2);
- n -= sizeof(ushort);
- }
- return r;
-}
-
-void
-nullwarn(Node *l, Node *r)
-{
- warn(Z, "result of operation not used");
- if(l != Z)
- cgen(l, Z);
- if(r != Z)
- cgen(r, Z);
-}

void
sextern(Sym *s, Node *a, long o, long w)
@@ -541,35 +442,6 @@
if(t & T_TYPE)
Bputc(b, a->type);
}
-
-void
-ieeedtod(Ieee *ieee, double native)
-{
- double fr, ho, f;
- int exp;
-
- if(native < 0) {
- ieeedtod(ieee, -native);
- ieee->h |= 0x80000000L;
- return;
- }
- if(native == 0) {
- ieee->l = 0;
- ieee->h = 0;
- return;
- }
- fr = frexp(native, &exp);
- f = 2097152L; /* shouldnt use fp constants here */
- fr = modf(fr*f, &ho);
- ieee->h = ho;
- ieee->h &= 0xfffffL;
- ieee->h |= (exp+1022L) << 20;
- f = 65536L;
- fr = modf(fr*f, &ho);
- ieee->l = ho;
- ieee->l <<= 16;
- ieee->l |= (long)(fr*f);
-}

long
align(long i, Type *t, int op)
=======================================
--- /utils/8c/txt.c Fri Dec 22 13:39:35 2006
+++ /utils/8c/txt.c Tue Apr 27 13:15:13 2010
@@ -203,7 +203,7 @@
sugen(n, tn2, n->type->width);
return;
}
- if(REGARG && curarg == 0 && typeilp[n->type->etype]) {
+ if(REGARG>=0 && curarg == 0 && typeilp[n->type->etype]) {
regaalloc1(tn1, n);
if(n->complex >= FNX) {
cgen(*fnxp, tn1);
@@ -306,6 +306,7 @@
if(reg[i] == 0)
goto out;
diag(tn, "out of fixed registers");
+abort();
goto err;

case TFLOAT:
@@ -321,6 +322,7 @@
if(i)
reg[i]++;
nodreg(n, tn, i);
+//print("+ %R %d\n", i, reg[i]);
}

void
@@ -347,6 +349,7 @@
if(reg[i] <= 0)
goto err;
reg[i]--;
+//print("- %R %d\n", i, reg[i]);
return;
err:
diag(n, "error in regfree: %R", i);
@@ -367,11 +370,19 @@
void
regaalloc1(Node *n, Node *nn)
{
+ USED(nn);
+
+ if(REGARG < 0) {
+ diag(n, "regaalloc1");
+ return;
+ }
+/* not reached
nodreg(n, nn, REGARG);
reg[REGARG]++;
curarg = align(curarg, nn->type, Aarg1);
curarg = align(curarg, nn->type, Aarg2);
maxargsafe = maxround(maxargsafe, cursafe+curarg);
+*/
}

void
@@ -412,6 +423,7 @@
default:
bad:
diag(n, "bad in naddr: %O %D", n->op, a);
+//prtree(n, "naddr");
break;

case OREGISTER:
@@ -787,9 +799,7 @@
case CASE( TFLOAT, TSHORT):
case CASE( TFLOAT, TUSHORT):
case CASE( TFLOAT, TINT):
- case CASE( TFLOAT, TUINT):
case CASE( TFLOAT, TLONG):
- case CASE( TFLOAT, TULONG):
case CASE( TFLOAT, TIND):

case CASE( TDOUBLE,TCHAR):
@@ -797,20 +807,8 @@
case CASE( TDOUBLE,TSHORT):
case CASE( TDOUBLE,TUSHORT):
case CASE( TDOUBLE,TINT):
- case CASE( TDOUBLE,TUINT):
case CASE( TDOUBLE,TLONG):
- case CASE( TDOUBLE,TULONG):
case CASE( TDOUBLE,TIND):
-
- case CASE( TVLONG, TCHAR):
- case CASE( TVLONG, TUCHAR):
- case CASE( TVLONG, TSHORT):
- case CASE( TVLONG, TUSHORT):
- case CASE( TVLONG, TINT):
- case CASE( TVLONG, TUINT):
- case CASE( TVLONG, TLONG):
- case CASE( TVLONG, TULONG):
- case CASE( TVLONG, TIND):
if(fproundflg) {
regsalloc(&nod, &regnode);
gins(AFMOVLP, f, &nod);
@@ -829,14 +827,27 @@
gmove(&nod, t);
return;

+/*
+ * float to ulong
+ */
+ case CASE( TDOUBLE, TULONG):
+ case CASE( TFLOAT, TULONG):
+ case CASE( TDOUBLE, TUINT):
+ case CASE( TFLOAT, TUINT):
+ regsalloc(&nod, &regnode);
+ gmove(f, &fregnode0);
+ gins(AFADDD, nodfconst(-2147483648.), &fregnode0);
+ gins(AFMOVLP, f, &nod);
+ gins(ASUBL, nodconst(-2147483648), &nod);
+ gmove(&nod, t);
+ return;
+
/*
* ulong to float
*/
case CASE( TULONG, TDOUBLE):
- case CASE( TULONG, TVLONG):
case CASE( TULONG, TFLOAT):
case CASE( TUINT, TDOUBLE):
- case CASE( TUINT, TVLONG):
case CASE( TUINT, TFLOAT):
regalloc(&nod, f, f);
gmove(f, &nod);
@@ -869,14 +880,6 @@
case CASE( TINT, TDOUBLE):
case CASE( TLONG, TDOUBLE):
case CASE( TIND, TDOUBLE):
-
- case CASE( TCHAR, TVLONG):
- case CASE( TUCHAR, TVLONG):
- case CASE( TSHORT, TVLONG):
- case CASE( TUSHORT,TVLONG):
- case CASE( TINT, TVLONG):
- case CASE( TLONG, TVLONG):
- case CASE( TIND, TVLONG):
regsalloc(&nod, &regnode);
gmove(f, &nod);
gins(AFMOVL, &nod, &fregnode0);
@@ -887,15 +890,9 @@
*/
case CASE( TFLOAT, TFLOAT):
case CASE( TDOUBLE,TFLOAT):
- case CASE( TVLONG, TFLOAT):

case CASE( TFLOAT, TDOUBLE):
case CASE( TDOUBLE,TDOUBLE):
- case CASE( TVLONG, TDOUBLE):
-
- case CASE( TFLOAT, TVLONG):
- case CASE( TDOUBLE,TVLONG):
- case CASE( TVLONG, TVLONG):
a = AFMOVD; break;
}
if(a == AMOVL || a == AFMOVD)
@@ -923,6 +920,7 @@
if(n->left->op == OCONST)
idx.ptr = D_CONST;
else if(n->left->op == OREGISTER)
+// else if(n->left->op == OREGISTER && typeil[n->left->type->etype])
idx.ptr = n->left->reg;
else if(n->left->op != OADDR) {
reg[D_BP]++; // cant be used as a base
=======================================
--- /utils/8l/asm.c Fri Dec 22 13:39:35 2006
+++ /utils/8l/asm.c Tue Apr 27 13:15:13 2010
@@ -2,6 +2,8 @@

#define Dbufslop 100

+#define PADDR(a) ((ulong)(a) & ~0xF0000000)
+
long
entryvalue(void)
{
@@ -27,18 +29,49 @@
}

void
-wput(ushort w)
+wputl(ushort w)
{
cput(w);
cput(w>>8);
}

void
-wputb(ushort w)
+wput(ushort w)
{
cput(w>>8);
cput(w);
}
+
+void
+lput(long l)
+{
+ cput(l>>24);
+ cput(l>>16);
+ cput(l>>8);
+ cput(l);
+}
+
+void
+lputl(long l)
+{
+ cput(l);
+ cput(l>>8);
+ cput(l>>16);
+ cput(l>>24);
+}
+
+void
+strnput(char *s, int n)
+{
+ for(; *s && n > 0; s++){
+ cput(*s);
+ n--;
+ }
+ while(n > 0){
+ cput(0);
+ n--;
+ }
+}

void
asmb(void)
@@ -89,7 +122,7 @@
cflush();
switch(HEADTYPE) {
default:
- diag("unknown header type %d", HEADTYPE);
+ diag("unknown header type %ld", HEADTYPE);
case 0:
seek(cout, rnd(HEADR+textsize, 8192), 0);
break;
@@ -98,6 +131,7 @@
seek(cout, textsize+HEADR, 0);
break;
case 2:
+ case 5:
seek(cout, HEADR+textsize, 0);
break;
case 3:
@@ -140,6 +174,7 @@
seek(cout, rnd(HEADR+textsize, INITRND)+datsize, 0);
break;
case 2:
+ case 5:
seek(cout, HEADR+textsize+datsize, 0);
break;
case 3:
@@ -179,7 +214,7 @@
lput(symsize); /* nsyms */
lput((0x38L<<16)|7L); /* size of optional hdr and flags */
lput((0413<<16)|0437L); /* magic and version */
- lput(rnd(HEADR+textsize, 4096)); /* sizes */
+ lput(rnd(HEADR+textsize, 4096));/* sizes */
lput(datsize);
lput(bsssize);
lput(entryvalue()); /* va of entry */
@@ -193,7 +228,6 @@
lput(0L);
lput(~0L); /* gp value ?? */
break;
- lputl(0); /* x */
case 1: /* unix coff */
/*
* file header
@@ -216,7 +250,7 @@
/*
* text section header
*/
- s8put(".text");
+ strnput(".text", 8);
lputl(HEADR); /* pa */
lputl(HEADR); /* va */
lputl(textsize); /* text size */
@@ -228,7 +262,7 @@
/*
* data section header
*/
- s8put(".data");
+ strnput(".data", 8);
lputl(INITDAT); /* pa */
lputl(INITDAT); /* va */
lputl(datsize); /* data size */
@@ -240,7 +274,7 @@
/*
* bss section header
*/
- s8put(".bss");
+ strnput(".bss", 8);
lputl(INITDAT+datsize); /* pa */
lputl(INITDAT+datsize); /* va */
lputl(bsssize); /* bss size */
@@ -252,7 +286,7 @@
/*
* comment section header
*/
- s8put(".comment");
+ strnput(".comment", 8);
lputl(0); /* pa */
lputl(0); /* va */
lputl(symsize+lcsize); /* comment size */
@@ -266,7 +300,7 @@
magic = 4*11*11+7;
if(dlm)
magic |= 0x80000000;
- lput(magic); /* magic */
+ lput(magic); /* magic */
lput(textsize); /* sizes */
lput(datsize);
lput(bsssize);
@@ -281,56 +315,74 @@
case 4:
/* fake MS-DOS .EXE */
v = rnd(HEADR+textsize, INITRND)+datsize;
- wput(0x5A4D); /* 'MZ' */
- wput(v % 512); /* bytes in last page */
- wput(rnd(v, 512)/512); /* total number of pages */
- wput(0x0000); /* number of reloc items */
+ wputl(0x5A4D); /* 'MZ' */
+ wputl(v % 512); /* bytes in last page */
+ wputl(rnd(v, 512)/512); /* total number of pages */
+ wputl(0x0000); /* number of reloc items */
v = rnd(HEADR-(INITTEXT & 0xFFFF), 16);
- wput(v/16); /* size of header */
- wput(0x0000); /* minimum allocation */
- wput(0xFFFF); /* maximum allocation */
- wput(0x0000); /* initial ss value */
- wput(0x0100); /* initial sp value */
- wput(0x0000); /* complemented checksum */
+ wputl(v/16); /* size of header */
+ wputl(0x0000); /* minimum allocation */
+ wputl(0xFFFF); /* maximum allocation */
+ wputl(0x0000); /* initial ss value */
+ wputl(0x0100); /* initial sp value */
+ wputl(0x0000); /* complemented checksum */
v = entryvalue();
- wput(v); /* initial ip value (!) */
- wput(0x0000); /* initial cs value */
- wput(0x0000);
- wput(0x0000);
- wput(0x003E); /* reloc table offset */
- wput(0x0000); /* overlay number */
+ wputl(v); /* initial ip value (!) */
+ wputl(0x0000); /* initial cs value */
+ wputl(0x0000);
+ wputl(0x0000);
+ wputl(0x003E); /* reloc table offset */
+ wputl(0x0000); /* overlay number */
break;
- }
- cflush();
-}
-
-void
-lput(long l)
-{
- cput(l>>24);
- cput(l>>16);
- cput(l>>8);
- cput(l);
-}
-
-void
-lputl(long l)
-{
- cput(l);
- cput(l>>8);
- cput(l>>16);
- cput(l>>24);
-}
-
-void
-s8put(char *n)
-{
- char name[8];
- int i;
-
- strncpy(name, n, sizeof(name));
- for(i=0; i<sizeof(name); i++)
- cput(name[i]);
+ case 5:
+ strnput("\177ELF", 4); /* e_ident */
+ cput(1); /* class = 32 bit */
+ cput(1); /* data = LSB */
+ cput(1); /* version = CURRENT */
+ strnput("", 9);
+ wputl(2); /* type = EXEC */
+ wputl(3); /* machine = 386 */
+ lputl(1L); /* version = CURRENT */
+ lputl(PADDR(entryvalue())); /* entry vaddr */
+ lputl(52L); /* offset to first phdr */
+ lputl(0L); /* offset to first shdr */
+ lputl(0L); /* flags = 386 */
+ wputl(52); /* Ehdr size */
+ wputl(32); /* Phdr size */
+ wputl(3); /* # of Phdrs */
+ wputl(0); /* Shdr size */
+ wputl(0); /* # of Shdrs */
+ wputl(0); /* Shdr string size */
+
+ lputl(1L); /* text - type = PT_LOAD */
+ lputl(HEADR); /* file offset */
+ lputl(INITTEXT); /* vaddr */
+ lputl(PADDR(INITTEXT)); /* paddr */
+ lputl(textsize); /* file size */
+ lputl(textsize); /* memory size */
+ lputl(0x05L); /* protections = RX */
+ lputl(INITRND); /* alignment */
+
+ lputl(1L); /* data - type = PT_LOAD */
+ lputl(HEADR+textsize); /* file offset */
+ lputl(INITDAT); /* vaddr */
+ lputl(PADDR(INITDAT)); /* paddr */
+ lputl(datsize); /* file size */
+ lputl(datsize+bsssize); /* memory size */
+ lputl(0x06L); /* protections = RW */
+ lputl(INITRND); /* alignment */
+
+ lputl(0L); /* data - type = PT_NULL */
+ lputl(HEADR+textsize+datsize); /* file offset */
+ lputl(0L);
+ lputl(0L);
+ lputl(symsize); /* symbol table size */
+ lputl(lcsize); /* line number size */
+ lputl(0x04L); /* protections = R */
+ lputl(0x04L); /* alignment */
+ break;
+ }
+ cflush();
}

void
=======================================
--- /utils/8l/l.h Fri Dec 22 13:39:35 2006
+++ /utils/8l/l.h Tue Apr 27 13:15:13 2010
@@ -9,6 +9,7 @@
#define P ((Prog*)0)
#define S ((Sym*)0)
#define TNAME (curtext?curtext->from.sym->name:noname)
+
#define cput(c)\
{ *cbp++ = c;\
if(--cbc <= 0)\
@@ -246,7 +247,6 @@
EXTERN char reg[D_NONE];
EXTERN Prog* lastp;
EXTERN long lcsize;
-EXTERN int maxop;
EXTERN int nerrors;
EXTERN long nhunk;
EXTERN long nsymbol;
@@ -266,7 +266,7 @@
EXTERN Adr* reloca;
EXTERN int doexp, dlm;
EXTERN int imports, nimports;
-EXTERN int exports, nexports;
+EXTERN int exports, nexports, allexport;
EXTERN char* EXPTAB;
EXTERN Prog undefp;

@@ -332,12 +332,11 @@
int relinv(int);
long reuse(Prog*, Sym*);
long rnd(long, long);
-void s8put(char*);
void span(void);
void undef(void);
void undefsym(Sym*);
long vaddr(Adr*);
-void wputb(ushort);
+void wput(ushort);
void xdefine(char*, int, long);
void xfol(Prog*);
int zaddr(uchar*, Adr*, Sym*[]);
=======================================
--- /utils/8l/list.c Fri Dec 22 13:39:35 2006
+++ /utils/8l/list.c Tue Apr 27 13:15:13 2010
@@ -285,7 +285,7 @@
print("%s: %s\n", tn, buf);

nerrors++;
- if(nerrors > 20) {
+ if(nerrors > 20 && !debug['A']) {
print("too many errors\n");
errorexit();
}
=======================================
--- /utils/8l/obj.c Fri Dec 22 13:39:35 2006
+++ /utils/8l/obj.c Tue Apr 27 13:15:13 2010
@@ -17,6 +17,7 @@
* -H2 -T4128 -R4096 is plan9 format
* -H3 -Tx -Rx is MS-DOS .COM
* -H4 -Tx -Rx is fake MS-DOS .EXE
+ * -H5 -T0x80100020 -R4096 is ELF
*/

static int
@@ -94,8 +95,13 @@
break;
case 'x': /* produce export table */
doexp = 1;
- if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
- readundefs(ARGF(), SEXPORT);
+ if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])){
+ a = ARGF();
+ if(strcmp(a, "*") == 0)
+ allexport = 1;
+ else
+ readundefs(a, SEXPORT);
+ }
break;
case 'u': /* produce dynamically loadable module */
dlm = 1;
@@ -172,6 +178,15 @@
if(debug['v'])
Bprint(&bso, "HEADR = 0x%ld\n", HEADR);
break;
+ case 5: /* elf executable */
+ HEADR = rnd(52L+3*32L, 16);
+ if(INITTEXT == -1)
+ INITTEXT = 0x80100020L;
+ if(INITDAT == -1)
+ INITDAT = 0;
+ if(INITRND == -1)
+ INITRND = 4096;
+ break;
}
if(INITDAT != 0 && INITRND != 0)
print("warning: -D0x%lux is ignored because of -R0x%lux\n",
@@ -185,7 +200,6 @@
diag("phase error in optab: %d", i);
errorexit();
}
- maxop = i;

for(i=0; i<Ymax; i++)
ycover[i*Ymax + i] = 1;
=======================================
--- /utils/8l/pass.c Fri Dec 22 13:39:35 2006
+++ /utils/8l/pass.c Tue Apr 27 13:15:13 2010
@@ -629,7 +629,8 @@
if(s->value != 0)
diag("value != 0 on SXREF");
undefsym(s);
- Bprint(&bso, "IMPORT: %s sig=%lux v=%ld\n", s->name, s->sig, s->value);
+ if(debug['X'])
+ Bprint(&bso, "IMPORT: %s sig=%lux v=%ld\n", s->name, s->sig,
s->value);
if(debug['S'])
s->sig = 0;
}
@@ -674,14 +675,14 @@
n = 0;
for(i = 0; i < NHASH; i++)
for(s = hash[i]; s != S; s = s->link)
- if(s->sig != 0 && s->type != SXREF && s->type != SUNDEF && (nexports ==
0 || s->subtype == SEXPORT))
+ if(s->type != SXREF && s->type != SUNDEF && (nexports == 0 && s->sig !=
0 || s->subtype == SEXPORT || allexport))
n++;
esyms = malloc(n*sizeof(Sym*));
ne = n;
n = 0;
for(i = 0; i < NHASH; i++)
for(s = hash[i]; s != S; s = s->link)
- if(s->sig != 0 && s->type != SXREF && s->type != SUNDEF && (nexports ==
0 || s->subtype == SEXPORT))
+ if(s->type != SXREF && s->type != SUNDEF && (nexports == 0 && s->sig !=
0 || s->subtype == SEXPORT || allexport))
esyms[n++] = s;
for(i = 0; i < ne-1; i++)
for(j = i+1; j < ne; j++)
=======================================
--- /utils/8l/span.c Fri Dec 22 13:39:35 2006
+++ /utils/8l/span.c Tue Apr 27 13:15:13 2010
@@ -1133,7 +1133,7 @@
}
return;
}
- diag("doasm: notfound t2=%lux from=%lux to=%lux %P", t[2], p->from.type,
p->to.type, p);
+ diag("doasm: notfound t2=%ux from=%ux to=%ux %P", t[2], p->from.type,
p->to.type, p);
return;

mfound:
@@ -1366,7 +1366,7 @@
t++;
}
else if(c == 1){
- wputb(ra);
+ wput(ra);
t += 2;
}
else{
=======================================
--- /utils/kl/span.c Fri Dec 22 13:39:35 2006
+++ /utils/kl/span.c Tue Apr 27 13:15:13 2010
@@ -182,6 +182,7 @@
instoffset = s->value + a->offset + INITDAT;
/* not sure why this barfs */
return C_LCON;
+/*
if(instoffset == 0)
return C_ZCON;
if(instoffset >= -0x1000 && instoffset <= 0xfff)
@@ -189,6 +190,7 @@
if((instoffset & 0x3ff) == 0)
return C_UCON;
return C_LCON;
+*/

case D_AUTO:
instoffset = autosize + a->offset;

==============================================================================
Revision: 458e251755
Author: for...@vitanuova.com
Date: Tue Apr 27 13:20:56 2010
Log: 20100427-2120
http://code.google.com/p/inferno-npe/source/detail?r=458e251755

Modified:
/utils/kl/l.h
/utils/vl/asm.c
/utils/vl/l.h
/utils/vl/obj.c
/utils/vl/pass.c

=======================================
--- /utils/kl/l.h Fri Dec 22 13:39:35 2006
+++ /utils/kl/l.h Tue Apr 27 13:20:56 2010
@@ -1,4 +1,3 @@
-/* #include <u.h> */
#include <lib9.h>
#include <bio.h>
#include "../kc/k.out.h"
@@ -250,11 +249,14 @@
extern char* anames[];

#pragma varargck type "A" int
+#pragma varargck type "A" uint
#pragma varargck type "D" Adr*
#pragma varargck type "N" Adr*
#pragma varargck type "P" Prog*
#pragma varargck type "S" char*

+#pragma varargck argpos diag 1
+
int Aconv(Fmt*);
int Dconv(Fmt*);
int Nconv(Fmt*);
=======================================
--- /utils/vl/asm.c Fri Dec 22 13:39:35 2006
+++ /utils/vl/asm.c Tue Apr 27 13:20:56 2010
@@ -13,7 +13,27 @@
OFFSET++;\
*/

-#define LPUT(c)\
+#define LPUT(l) { \
+ if (little) { \
+ LLEPUT(l); \
+ } else { \
+ LBEPUT(l); \
+ } \
+ }
+
+#define LLEPUT(c)\
+ {\
+ cbp[0] = (c);\
+ cbp[1] = (c)>>8;\
+ cbp[2] = (c)>>16;\
+ cbp[3] = (c)>>24;\
+ cbp += 4;\
+ cbc -= 4;\
+ if(cbc <= 0)\
+ cflush();\
+ }
+
+#define LBEPUT(c)\
{\
cbp[0] = (c)>>24;\
cbp[1] = (c)>>16;\
@@ -24,6 +44,35 @@
if(cbc <= 0)\
cflush();\
}
+
+#define HPUT(h) { \
+ if (little) { \
+ HLEPUT(h); \
+ } else { \
+ HBEPUT(h); \
+ } \
+ }
+
+#define HLEPUT(c)\
+ {\
+ cbp[0] = (c);\
+ cbp[1] = (c)>>8;\
+ cbp += 2;\
+ cbc -= 2;\
+ if(cbc <= 0)\
+ cflush();\
+ }
+
+#define HBEPUT(c)\
+ {\
+ cbp[0] = (c)>>8;\
+ cbp[1] = (c);\
+ cbp += 2;\
+ cbc -= 2;\
+ if(cbc <= 0)\
+ cflush();\
+ }
+

#define CPUT(c)\
{\
@@ -33,6 +82,24 @@
if(cbc <= 0)\
cflush();\
}
+
+void
+objput(long l) /* emit long in byte order appropriate to object machine */
+{
+ LPUT(l);
+}
+
+void
+objhput(short s)
+{
+ HPUT(s);
+}
+
+void
+lput(long l) /* emit long in big-endian byte order */
+{
+ LBEPUT(l);
+}

long
entryvalue(void)
@@ -111,6 +178,7 @@
case 2:
case 3:
case 5:
+ case 6:
OFFSET = HEADR+textsize;
seek(cout, OFFSET, 0);
break;
@@ -138,6 +206,7 @@
case 2:
case 1:
case 5:
+ case 6:
OFFSET = HEADR+textsize+datsize;
seek(cout, OFFSET, 0);
break;
@@ -203,7 +272,11 @@
lput(0L); /* complete mystery */
break;
case 2:
- lput(0x407); /* magic */
+ if (little)
+ t = 24;
+ else
+ t = 16;
+ lput(((((4*t)+0)*t)+7)); /* magic */
lput(textsize); /* sizes */
lput(datsize);
lput(bsssize);
@@ -318,47 +391,67 @@
lput(0x80L); /* flags */
break;
case 5:
+ /* first part of ELF is byte-wide parts, thus no byte-order issues */
strnput("\177ELF", 4); /* e_ident */
CPUT(1); /* class = 32 bit */
- CPUT(2); /* data = MSB */
- CPUT(1); /* version = CURRENT */
- strnput("", 9);
- lput((2L<<16)|8L); /* type = EXEC; machine = MIPS */
- lput(1L); /* version = CURRENT */
- lput(entryvalue()); /* entry vaddr */
- lput(52L); /* offset to first phdr */
- lput(0L); /* offset to first shdr */
- lput(0L); /* flags = MIPS */
- lput((52L<<16)|32L); /* Ehdr & Phdr sizes*/
- lput((3L<<16)|0L); /* # Phdrs & Shdr size */
- lput((0L<<16)|0L); /* # Shdrs & shdr string size */
-
- lput(1L); /* text - type = PT_LOAD */
- lput(0L); /* file offset */
- lput(INITTEXT-HEADR); /* vaddr */
- lput(INITTEXT-HEADR); /* paddr */
- lput(HEADR+textsize); /* file size */
- lput(HEADR+textsize); /* memory size */
- lput(0x05L); /* protections = RX */
- lput(0x10000L); /* alignment code?? */
-
- lput(1L); /* data - type = PT_LOAD */
- lput(HEADR+textsize); /* file offset */
- lput(INITDAT); /* vaddr */
- lput(INITDAT); /* paddr */
- lput(datsize); /* file size */
- lput(datsize+bsssize); /* memory size */
- lput(0x06L); /* protections = RW */
- lput(0x10000L); /* alignment code?? */
-
- lput(0L); /* data - type = PT_NULL */
- lput(HEADR+textsize+datsize); /* file offset */
- lput(0L);
- lput(0L);
- lput(symsize); /* symbol table size */
- lput(lcsize); /* line number size */
- lput(0x04L); /* protections = R */
- lput(0x04L); /* alignment code?? */
+ CPUT(little? 1: 2); /* data: 1 = LSB, 2 = MSB */
+ CPUT(1); /* version = 1 */
+ strnput("", 9); /* reserved for expansion */
+ /* entire remainder of ELF file is in target byte order */
+
+ /* file header part of ELF header */
+ objhput(2); /* type = EXEC */
+ objhput(8); /* machine = MIPS */
+ objput(1L); /* version = CURRENT */
+ objput(entryvalue()); /* entry vaddr */
+ objput(52L); /* offset to first phdr */
+ objput(0L); /* offset to first shdr */
+ objput(0L); /* flags (no MIPS flags defined) */
+ objhput(52); /* Ehdr size */
+ objhput(32); /* Phdr size */
+ objhput(3); /* # of Phdrs */
+ objhput(0); /* Shdr size */
+ objhput(0); /* # of Shdrs */
+ objhput(0); /* Shdr string size */
+
+ /* "Program headers" - one per chunk of file to load */
+
+ /*
+ * include ELF headers in text -- 8l doesn't,
+ * but in theory it aids demand loading.
+ */
+ objput(1L); /* text: type = PT_LOAD */
+ objput(0L); /* file offset */
+ objput(INITTEXT-HEADR); /* vaddr */
+ objput(INITTEXT-HEADR); /* paddr */
+ objput(HEADR+textsize); /* file size */
+ objput(HEADR+textsize); /* memory size */
+ objput(0x05L); /* protections = RX */
+ objput(0x1000L); /* page-align text off's & vaddrs */
+
+ objput(1L); /* data: type = PT_LOAD */
+ objput(HEADR+textsize); /* file offset */
+ objput(INITDAT); /* vaddr */
+ objput(INITDAT); /* paddr */
+ objput(datsize); /* file size */
+ objput(datsize+bsssize); /* memory size */
+ objput(0x06L); /* protections = RW */
+ if(INITDAT % 4096 == 0 && (HEADR + textsize) % 4096 == 0)
+ objput(0x1000L); /* page-align data off's & vaddrs */
+ else
+ objput(0L); /* do not claim alignment */
+
+ objput(0L); /* P9 symbols: type = PT_NULL */
+ objput(HEADR+textsize+datsize); /* file offset */
+ objput(0L);
+ objput(0L);
+ objput(symsize); /* symbol table size */
+ objput(lcsize); /* line number size */
+ objput(0x04L); /* protections = R */
+ objput(0L); /* do not claim alignment */
+ break;
+ case 6:
+ break;
}
cflush();
}
@@ -373,13 +466,6 @@
for(; n > 0; n--)
CPUT(0);
}
-
-void
-lput(long l)
-{
-
- LPUT(l);
-}

void
cflush(void)
@@ -477,7 +563,7 @@

if(t == 'f')
s++;
- LPUT(v);
+ LBEPUT(v);
if(ver)
t += 'a' - 'A';
CPUT(t+0x80); /* 0x80 is variable length */
@@ -820,7 +906,7 @@
else
v = (p->cond->pc - pc-4) >> 2;
if(((v << 16) >> 16) != v)
- diag("short branch too far: %d\n%P", v, p);
+ diag("short branch too far: %ld\n%P", v, p);
o1 = OP_IRR(opirr(p->as), v, p->from.reg, p->reg);
break;

=======================================
--- /utils/vl/l.h Fri Dec 22 13:39:35 2006
+++ /utils/vl/l.h Tue Apr 27 13:20:56 2010
@@ -236,6 +236,7 @@
EXTERN char xcmp[32][32];
EXTERN Prog zprg;
EXTERN int dtype;
+EXTERN int little;

EXTERN struct
{
@@ -256,6 +257,8 @@
#pragma varargck type "P" Prog*
#pragma varargck type "S" char*

+#pragma varargck argpos diag 1
+
int Aconv(Fmt*);
int Dconv(Fmt*);
int Nconv(Fmt*);
@@ -297,6 +300,7 @@
void listinit(void);
Sym* lookup(char*, int);
void lput(long);
+void bput(long);
void mkfwd(void);
void* mysbrk(ulong);
void names(void);
=======================================
--- /utils/vl/obj.c Fri Dec 22 16:30:12 2006
+++ /utils/vl/obj.c Tue Apr 27 13:20:56 2010
@@ -18,8 +18,11 @@
* -H3 -T0x80020000 -R8 is bootp() format for 4k
* -H4 -T0x400000 -R4 is sgi unix coff executable
* -H5 -T0x4000A0 -R4 is sgi unix elf executable
+ * -H6 is headerless
*/

+int little;
+
void
main(int argc, char *argv[])
{
@@ -52,6 +55,11 @@
if(a)
INITENTRY = a;
break;
+ case 'L': /* for little-endian mips */
+ thechar = '0';
+ thestring = "spim";
+ little = 1;
+ break;
case 'T':
a = ARGF();
if(a)
@@ -78,7 +86,7 @@
USED(argc);

if(*argv == 0) {
- diag("usage: vl [-options] objects");
+ diag("usage: %cl [-options] objects", thechar);
errorexit();
}
if(!debug['9'] && !debug['U'] && !debug['B'])
@@ -150,6 +158,15 @@
if(INITRND == -1)
INITRND = 0;
break;
+ case 6: /* headerless */
+ HEADR = 0;
+ if(INITTEXT == -1)
+ INITTEXT = 0x80000000L+HEADR;
+ if(INITDAT == -1)
+ INITDAT = 0;
+ if(INITRND == -1)
+ INITRND = 4096;
+ break;
}
if(INITDAT != 0 && INITRND != 0)
print("warning: -D0x%lux is ignored because of -R0x%lux\n",
@@ -170,8 +187,12 @@
datap = P;
pc = 0;
dtype = 4;
- if(outfile == 0)
- outfile = "v.out";
+ if(outfile == 0) {
+ static char name[20];
+
+ snprint(name, sizeof name, "%c.out", thechar);
+ outfile = name;
+ }
cout = create(outfile, 1, 0775);
if(cout < 0) {
diag("%s: cannot create", outfile);
@@ -677,7 +698,7 @@
o = bloc[0]; /* as */
if(o <= AXXX || o >= ALAST) {
diag("%s: line %ld: opcode out of range %d", pn, pc-ipc, o);
- print(" probably not a .v file\n");
+ print(" probably not a .%c file\n", thechar);
errorexit();
}
if(o == ANAME || o == ASIGNAME) {
@@ -1150,15 +1171,24 @@
doprof2(void)
{
Sym *s2, *s4;
- Prog *p, *q, *ps2, *ps4;
+ Prog *p, *q, *q2, *ps2, *ps4;

if(debug['v'])
Bprint(&bso, "%5.2f profile 2\n", cputime());
Bflush(&bso);
- s2 = lookup("_profin", 0);
- s4 = lookup("_profout", 0);
+
+ if(debug['e']){
+ s2 = lookup("_tracein", 0);
+ s4 = lookup("_traceout", 0);
+ }else{
+ s2 = lookup("_profin", 0);
+ s4 = lookup("_profout", 0);
+ }
if(s2->type != STEXT || s4->type != STEXT) {
- diag("_profin/_profout not defined");
+ if(debug['e'])
+ diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+ else
+ diag("_profin/_profout not defined");
return;
}

@@ -1197,7 +1227,20 @@
q->line = p->line;
q->pc = p->pc;
q->link = p->link;
- p->link = q;
+ if(debug['e']){ /* embedded tracing */
+ q2 = prg();
+ p->link = q2;
+ q2->link = q;
+
+ q2->line = p->line;
+ q2->pc = p->pc;
+
+ q2->as = AJMP;
+ q2->to.type = D_BRANCH;
+ q2->to.sym = p->to.sym;
+ q2->cond = q->link;
+ }else
+ p->link = q;
p = q;
p->as = AJAL;
p->to.type = D_BRANCH;
@@ -1207,6 +1250,17 @@
continue;
}
if(p->as == ARET) {
+ /*
+ * RET (default)
+ */
+ if(debug['e']){ /* embedded tracing */
+ q = prg();
+ q->line = p->line;
+ q->pc = p->pc;
+ q->link = p->link;
+ p->link = q;
+ p = q;
+ }
/*
* RET
*/
@@ -1239,17 +1293,27 @@
{
int i, c;

- for(i=0; i<4; i++) {
- c = find1(0x01020304L, i+1);
- if(i >= 2)
- inuxi2[i-2] = c;
- if(i >= 3)
- inuxi1[i-3] = c;
- inuxi4[i] = c;
-
- fnuxi8[i] = c+4;
- fnuxi8[i+4] = c;
- }
+ for(i=0; i<4; i++)
+ if (!little) { /* normal big-endian case */
+ c = find1(0x01020304L, i+1);
+ if(i >= 2)
+ inuxi2[i-2] = c;
+ if(i >= 3)
+ inuxi1[i-3] = c;
+ inuxi4[i] = c;
+ fnuxi8[i] = c+4;
+ fnuxi8[i+4] = c;
+ } else { /* oddball little-endian case */
+ c = find1(0x04030201L, i+1);
+ if(i < 2)
+ inuxi2[i] = c;
+ if(i < 1)
+ inuxi1[i] = c;
+ inuxi4[i] = c;
+ fnuxi4[i] = c;
+ fnuxi8[i] = c;
+ fnuxi8[i+4] = c+4;
+ }
if(debug['v']) {
Bprint(&bso, "inuxi = ");
for(i=0; i<1; i++)
@@ -1268,7 +1332,6 @@
Bflush(&bso);
}

-int
find1(long l, int c)
{
char *p;
=======================================
--- /utils/vl/pass.c Fri Dec 22 13:39:35 2006
+++ /utils/vl/pass.c Tue Apr 27 13:20:56 2010
@@ -133,7 +133,7 @@
continue;
/* size should be 19 max */
if(strlen(s->name) >= 10) /* has loader address */
- sprint(literal, "$%lux.%lux", (long)s, p->from.offset);
+ sprint(literal, "$%p.%lux", s, p->from.offset);
else
sprint(literal, "$%s.%d.%lux", s->name, s->version, p->from.offset);
} else {

==============================================================================
Revision: 4bd48c3d44
Author: for...@vitanuova.com
Date: Tue Apr 27 14:08:33 2010
Log: 20100427-2208
http://code.google.com/p/inferno-npe/source/detail?r=4bd48c3d44

Modified:
/utils/5c/5.out.h
/utils/5c/cgen.c
/utils/5c/gc.h
/utils/5c/mkfile
/utils/5c/reg.c
/utils/5c/sgen.c
/utils/5c/swt.c
/utils/5c/txt.c
/utils/kc/gc.h
/utils/kc/mkfile
/utils/kc/sgen.c
/utils/kc/swt.c
/utils/vc/cgen.c
/utils/vc/gc.h
/utils/vc/mkfile
/utils/vc/peep.c
/utils/vc/sgen.c
/utils/vc/swt.c

=======================================
--- /utils/5c/5.out.h Fri Dec 22 13:39:35 2006
+++ /utils/5c/5.out.h Tue Apr 27 14:08:33 2010
@@ -9,7 +9,9 @@
#define REGRET 0
#define REGARG 0
/* compiler allocates R1 up as temps */
-/* compiler allocates register variables R3 up */
+/* compiler allocates register variables R2 up */
+#define REGMIN 2
+#define REGMAX 8
#define REGEXT 10
/* compiler allocates external registers R10 down */
#define REGTMP 11
=======================================
--- /utils/5c/cgen.c Sat Jun 27 14:08:09 2009
+++ /utils/5c/cgen.c Tue Apr 27 14:08:33 2010
@@ -1,7 +1,13 @@
#include "gc.h"

void
-cgen(Node *n, Node *nn, int inrel)
+cgen(Node *n, Node *nn)
+{
+ cgenrel(n, nn, 0);
+}
+
+void
+cgenrel(Node *n, Node *nn, int inrel)
{
Node *l, *r;
Prog *p1;
@@ -45,7 +51,7 @@
switch(o) {
default:
regret(&nod, r);
- cgen(r, &nod, 0);
+ cgen(r, &nod);

regsalloc(&nod1, r);
gopcode(OAS, &nod, Z, &nod1);
@@ -53,7 +59,7 @@
regfree(&nod);
nod = *n;
nod.right = &nod1;
- cgen(&nod, nn, 0);
+ cgen(&nod, nn);
return;

case OFUNC:
@@ -79,7 +85,7 @@
regret(&nod, r);
else
regalloc(&nod, r, nn);
- cgen(r, &nod, 0);
+ cgen(r, &nod);
gmove(&nod, l);
if(nn != Z)
gmove(&nod, nn);
@@ -98,10 +104,10 @@
break;
}
regalloc(&nod, r, nn);
- cgen(r, &nod, 0);
+ cgen(r, &nod);
} else {
regalloc(&nod, r, nn);
- cgen(r, &nod, 0);
+ cgen(r, &nod);
reglcgen(&nod1, l, Z);
}
gmove(&nod, &nod1);
@@ -114,9 +120,9 @@
regalloc(&nod, r, nn);
if(l->complex >= r->complex) {
reglcgen(&nod1, n, Z);
- cgen(r, &nod, 0);
+ cgen(r, &nod);
} else {
- cgen(r, &nod, 0);
+ cgen(r, &nod);
reglcgen(&nod1, n, Z);
}
regalloc(&nod2, n, Z);
@@ -139,7 +145,7 @@
if(nn != Z)
if((t = vlog(r)) >= 0) {
/* signed div/mod by constant power of 2 */
- cgen(l, nn, 0);
+ cgen(l, nn);
gopcode(OGE, nodconst(0), nn, Z);
p1 = p;
if(o == ODIV) {
@@ -164,7 +170,7 @@
if(nn != Z)
if(l->op == OCONST)
if(!typefd[n->type->etype]) {
- cgen(r, nn, 0);
+ cgen(r, nn);
gopcode(o, Z, l, nn);
break;
}
@@ -181,7 +187,7 @@
if(nn != Z)
if(r->op == OCONST)
if(!typefd[n->type->etype]) {
- cgen(l, nn, 0);
+ cgen(l, nn);
if(r->vconst == 0)
if(o != OAND)
break;
@@ -205,15 +211,15 @@
}
if(l->complex >= r->complex) {
regalloc(&nod, l, nn);
- cgen(l, &nod, 0);
+ cgen(l, &nod);
regalloc(&nod1, r, Z);
- cgen(r, &nod1, 0);
+ cgen(r, &nod1);
gopcode(o, &nod1, Z, &nod);
} else {
regalloc(&nod, r, nn);
- cgen(r, &nod, 0);
+ cgen(r, &nod);
regalloc(&nod1, l, Z);
- cgen(l, &nod1, 0);
+ cgen(l, &nod1);
gopcode(o, &nod, &nod1, &nod);
}
gopcode(OAS, &nod, Z, nn);
@@ -263,10 +269,10 @@
else
nod2 = *l;
regalloc(&nod1, r, Z);
- cgen(r, &nod1, 0);
+ cgen(r, &nod1);
} else {
regalloc(&nod1, r, Z);
- cgen(r, &nod1, 0);
+ cgen(r, &nod1);
if(l->addable < INDEXED)
reglcgen(&nod2, l, Z);
else
@@ -290,10 +296,10 @@
if(l->complex >= r->complex) {
bitload(l, &nod, &nod1, &nod2, &nod4);
regalloc(&nod3, r, Z);
- cgen(r, &nod3, 0);
+ cgen(r, &nod3);
} else {
regalloc(&nod3, r, Z);
- cgen(r, &nod3, 0);
+ cgen(r, &nod3);
bitload(l, &nod, &nod1, &nod2, &nod4);
}
gmove(&nod, &nod4);
@@ -318,7 +324,7 @@
diag(n, "bad function call");

regret(&nod, l->left);
- cgen(l->left, &nod, 0);
+ cgen(l->left, &nod);
regsalloc(&nod1, l->left);
gopcode(OAS, &nod, Z, &nod1);
regfree(&nod);
@@ -328,7 +334,7 @@
nod2 = *l;
nod2.left = &nod1;
nod2.complex = 1;
- cgen(&nod, nn, 0);
+ cgen(&nod, nn);

return;
}
@@ -363,11 +369,11 @@
if(sconst(r) && (v = r->vconst+nod.xoffset) > -4096 && v < 4096) {
v = r->vconst;
r->vconst = 0;
- cgen(l, &nod, 0);
+ cgen(l, &nod);
nod.xoffset += v;
r->vconst = v;
} else
- cgen(l, &nod, 0);
+ cgen(l, &nod);
regind(&nod, n);
gopcode(OAS, &nod, Z, nn);
regfree(&nod);
@@ -406,8 +412,8 @@
break;

case OCOMMA:
- cgen(l, Z, 0);
- cgen(r, nn, 0);
+ cgen(l, Z);
+ cgen(r, nn);
break;

case OCAST:
@@ -420,12 +426,12 @@
*/
if(nocast(l->type, n->type)) {
if(nocast(n->type, nn->type)) {
- cgen(l, nn, 0);
+ cgen(l, nn);
break;
}
}
regalloc(&nod, l, nn);
- cgen(l, &nod, 0);
+ cgen(l, &nod);
regalloc(&nod1, n, &nod);
if(inrel)
gmover(&nod, &nod1);
@@ -447,18 +453,18 @@
}
nod.xoffset += (long)r->vconst;
nod.type = n->type;
- cgen(&nod, nn, 0);
+ cgen(&nod, nn);
}
break;

case OCOND:
bcgen(l, 1);
p1 = p;
- cgen(r->left, nn, 0);
+ cgen(r->left, nn);
gbranch(OGOTO);
patch(p1, pc);
p1 = p;
- cgen(r->right, nn, 0);
+ cgen(r->right, nn);
patch(p1, pc);
break;

@@ -533,6 +539,8 @@
} else
gopcode(OADD, nodconst(v), Z, &nod);
gopcode(OAS, &nod, Z, &nod2);
+ if(nn && l->op == ONAME) /* in x=++i, emit USED(i) */
+ gins(ANOP, l, Z);

regfree(&nod);
if(l->addable < INDEXED)
@@ -579,7 +587,7 @@
} else if(n->op == OINDREG) {
if((v = n->xoffset) > -4096 && v < 4096) {
n->op = OREGISTER;
- cgen(n, t, 0);
+ cgen(n, t);
t->xoffset += v;
n->op = OINDREG;
regind(t, n);
@@ -638,12 +646,12 @@
break;

case OCOMMA:
- cgen(n->left, n->left, 0);
+ cgen(n->left, n->left);
lcgen(n->right, nn);
break;

case OIND:
- cgen(n->left, nn, 0);
+ cgen(n->left, nn);
break;

case OCOND:
@@ -688,7 +696,7 @@

default:
regalloc(&nod, n, nn);
- cgen(n, &nod, 0);
+ cgen(n, &nod);
o = ONE;
if(true)
o = comrel[relindex(o)];
@@ -712,7 +720,7 @@
goto com;

case OCOMMA:
- cgen(l, Z, 0);
+ cgen(l, Z);
boolgen(r, true, nn);
break;

@@ -779,7 +787,7 @@
o = comrel[relindex(o)];
if(l->complex >= FNX && r->complex >= FNX) {
regret(&nod, r);
- cgen(r, &nod, 1);
+ cgenrel(r, &nod, 1);
regsalloc(&nod1, r);
gopcode(OAS, &nod, Z, &nod1);
regfree(&nod);
@@ -790,7 +798,7 @@
}
if(sconst(l)) {
regalloc(&nod, r, nn);
- cgen(r, &nod, 1);
+ cgenrel(r, &nod, 1);
o = invrel[relindex(o)];
gopcode(o, l, &nod, Z);
regfree(&nod);
@@ -798,21 +806,21 @@
}
if(sconst(r)) {
regalloc(&nod, l, nn);
- cgen(l, &nod, 1);
+ cgenrel(l, &nod, 1);
gopcode(o, r, &nod, Z);
regfree(&nod);
goto com;
}
if(l->complex >= r->complex) {
regalloc(&nod1, l, nn);
- cgen(l, &nod1, 1);
+ cgenrel(l, &nod1, 1);
regalloc(&nod, r, Z);
- cgen(r, &nod, 1);
+ cgenrel(r, &nod, 1);
} else {
regalloc(&nod, r, nn);
- cgen(r, &nod, 1);
+ cgenrel(r, &nod, 1);
regalloc(&nod1, l, Z);
- cgen(l, &nod1, 1);
+ cgenrel(l, &nod1, 1);
}
gopcode(o, &nod, &nod1, Z);
regfree(&nod);
@@ -936,7 +944,7 @@
r = r->right;
}
if(nn == Z) {
- cgen(l, nn, 0);
+ cgen(l, nn);
continue;
}
/*
@@ -974,7 +982,7 @@
xcom(&nod0);
nod0.addable = 0;

- cgen(&nod0, Z, 0);
+ cgen(&nod0, Z);
}
break;

@@ -1004,7 +1012,7 @@
n = new(OFUNC, n->left, new(OLIST, nn, n->right));
n->type = types[TVOID];
n->left->type = types[TVOID];
- cgen(n, Z, 0);
+ cgen(n, Z);
break;

case OCOND:
@@ -1019,7 +1027,7 @@
break;

case OCOMMA:
- cgen(n->left, Z, 0);
+ cgen(n->left, Z);
sugen(n->right, nn, w);
break;
}
@@ -1063,6 +1071,10 @@
}
regalloc(&nod3, &regnode, Z);
regalloc(&nod4, &regnode, Z);
+ if(nod3.reg > nod4.reg){
+ /* code below assumes nod3 loaded first */
+ Node t = nod3; nod3 = nod4; nod4 = t;
+ }
nod0 = *nodconst((1<<nod3.reg)|(1<<nod4.reg));
if(w == 2 && nod1.xoffset == 0)
gmovm(&nod1, &nod0, 0);
=======================================
--- /utils/5c/gc.h Tue Apr 27 04:51:13 2010
+++ /utils/5c/gc.h Tue Apr 27 14:08:33 2010
@@ -62,6 +62,7 @@
long val;
long label;
char def;
+ char isv;
};
#define C ((Case*)0)

@@ -134,6 +135,7 @@
};

EXTERN long breakpc;
+EXTERN long nbreak;
EXTERN Case* cases;
EXTERN Node constnode;
EXTERN Node fconstnode;
@@ -145,7 +147,6 @@
EXTERN long maxargsafe;
EXTERN int mnstring;
EXTERN Multab multab[20];
-EXTERN int retok;
EXTERN int hintabsize;
EXTERN Node* nodrat;
EXTERN Node* nodret;
@@ -216,7 +217,8 @@
/*
* cgen.c
*/
-void cgen(Node*, Node*, int);
+void cgen(Node*, Node*);
+void cgenrel(Node*, Node*, int);
void reglcgen(Node*, Node*, Node*);
void lcgen(Node*, Node*);
void bcgen(Node*, int);
@@ -265,7 +267,8 @@
*/
int swcmp(const void*, const void*);
void doswit(Node*);
-void swit1(C1*, int, long, Node*, Node*);
+void swit1(C1*, int, long, Node*);
+void swit2(C1*, int, long, Node*, Node*);
void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
=======================================
--- /utils/5c/mkfile Fri Dec 22 13:39:35 2006
+++ /utils/5c/mkfile Tue Apr 27 14:08:33 2010
@@ -8,6 +8,8 @@
list.$O\
mul.$O\
peep.$O\
+ pgen.$O\
+ pswt.$O\
reg.$O\
sgen.$O\
swt.$O\
@@ -28,3 +30,9 @@
cd ../cc
mk $MKFLAGS install
mk $MKFLAGS clean
+
+%.$O: ../cc/%.c
+ $CC $CFLAGS -I. ../cc/$stem.c
+
+#enam.c: 5.out.h
+# rc mkenam
=======================================
--- /utils/5c/reg.c Fri Dec 22 13:39:35 2006
+++ /utils/5c/reg.c Tue Apr 27 14:08:33 2010
@@ -789,6 +789,7 @@
idom = alloc(nr * sizeof(long));
maxnr = nr;
}
+
d = postorder(r, rpo2r, 0);
if(d > nr)
fatal(Z, "too many reg nodes");
@@ -1116,15 +1117,15 @@
RtoB(int r)
{

- if(r < 2 || r >= REGTMP)
- return 0;
- return 1L << r;
+ if(r >= REGMIN && r <= REGMAX)
+ return 1L << r;
+ return 0;
}

int
BtoR(long b)
{
- b &= 0x07fcL;
+ b &= 0x01fcL;
if(b == 0)
return 0;
return bitno(b);
=======================================
--- /utils/5c/sgen.c Tue Apr 27 04:51:13 2010
+++ /utils/5c/sgen.c Tue Apr 27 14:08:33 2010
@@ -1,380 +1,4 @@
#include "gc.h"
-
-void
-codgen(Node *n, Node *nn)
-{
- Prog *sp;
- Node *n1, nod, nod1;
-
- cursafe = 0;
- curarg = 0;
- maxargsafe = 0;
-
- /*
- * isolate name
- */
- for(n1 = nn;; n1 = n1->left) {
- if(n1 == Z) {
- diag(nn, "cant find function name");
- return;
- }
- if(n1->op == ONAME)
- break;
- }
- nearln = nn->lineno;
- gpseudo(ATEXT, n1->sym, nodconst(stkoff));
- sp = p;
-
- /*
- * isolate first argument
- */
- if(REGARG >= 0) {
- if(typesuv[thisfn->link->etype]) {
- nod1 = *nodret->left;
- nodreg(&nod, &nod1, REGARG);
- gopcode(OAS, &nod, Z, &nod1);
- } else
- if(firstarg && typechlp[firstargtype->etype]) {
- nod1 = *nodret->left;
- nod1.sym = firstarg;
- nod1.type = firstargtype;
- nod1.xoffset = align(0, firstargtype, Aarg1);
- nod1.etype = firstargtype->etype;
- nodreg(&nod, &nod1, REGARG);
- gopcode(OAS, &nod, Z, &nod1);
- }
- }
-
- retok = 0;
- gen(n);
- if(!retok)
- if(thisfn->link->etype != TVOID)
- warn(Z, "no return at end of function: %s", n1->sym->name);
- noretval(3);
- gbranch(ORETURN);
-
- if(!debug['N'] || debug['R'] || debug['P'])
- regopt(sp);
-
- sp->to.offset += maxargsafe;
-}
-
-void
-supgen(Node *n)
-{
- long spc;
- Prog *sp;
-
- if(n == Z)
- return;
- suppress++;
- spc = pc;
- sp = lastp;
- gen(n);
- lastp = sp;
- pc = spc;
- sp->link = nil;
- suppress--;
-}
-
-void
-gen(Node *n)
-{
- Node *l, nod;
- Prog *sp, *spc, *spb;
- Case *cn;
- long sbc, scc;
- int o, f;
-
-loop:
- if(n == Z)
- return;
- nearln = n->lineno;
- o = n->op;
- if(debug['G'])
- if(o != OLIST)
- print("%L %O\n", nearln, o);
-
- retok = 0;
- switch(o) {
-
- default:
- complex(n);
- cgen(n, Z, 0);
- break;
-
- case OLIST:
- gen(n->left);
-
- rloop:
- n = n->right;
- goto loop;
-
- case ORETURN:
- retok = 1;
- complex(n);
- if(n->type == T)
- break;
- l = n->left;
- if(l == Z) {
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- if(typesuv[n->type->etype]) {
- sugen(l, nodret, n->type->width);
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- regret(&nod, n);
- cgen(l, &nod, 0);
- regfree(&nod);
- if(typefd[n->type->etype])
- noretval(1);
- else
- noretval(2);
- gbranch(ORETURN);
- break;
-
- case OLABEL:
- l = n->left;
- if(l) {
- l->pc = pc;
- if(l->label)
- patch(l->label, pc);
- }
- gbranch(OGOTO); /* prevent self reference in reg */
- patch(p, pc);
- goto rloop;
-
- case OGOTO:
- retok = 1;
- n = n->left;
- if(n == Z)
- return;
- if(n->complex == 0) {
- diag(Z, "label undefined: %s", n->sym->name);
- return;
- }
- if(suppress)
- return;
- gbranch(OGOTO);
- if(n->pc) {
- patch(p, n->pc);
- return;
- }
- if(n->label)
- patch(n->label, pc-1);
- n->label = p;
- return;
-
- case OCASE:
- l = n->left;
- if(cases == C)
- diag(n, "case/default outside a switch");
- if(l == Z) {
- casf();
- cases->val = 0;
- cases->def = 1;
- cases->label = pc;
- goto rloop;
- }
- complex(l);
- if(l->type == T)
- goto rloop;
- if(l->op == OCONST)
- if(typechl[l->type->etype]) {
- casf();
- cases->val = l->vconst;
- cases->def = 0;
- cases->label = pc;
- goto rloop;
- }
- diag(n, "case expression must be integer constant");
- goto rloop;
-
- case OSWITCH:
- l = n->left;
- complex(l);
- if(l->type == T)
- break;
- if(!typechl[l->type->etype]) {
- diag(n, "switch expression must be integer");
- break;
- }
-
- gbranch(OGOTO); /* entry */
- sp = p;
-
- cn = cases;
- cases = C;
- casf();
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- gen(n->right);
- gbranch(OGOTO);
- patch(p, breakpc);
-
- patch(sp, pc);
- regalloc(&nod, l, Z);
- nod.type = types[TLONG];
- cgen(l, &nod, 0);
- doswit(&nod);
- regfree(&nod);
- patch(spb, pc);
-
- cases = cn;
- breakpc = sbc;
- break;
-
- case OWHILE:
- case ODWHILE:
- l = n->left;
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- if(n->op == OWHILE)
- patch(sp, pc);
- bcomplex(l, Z); /* test */
- patch(p, breakpc);
-
- if(n->op == ODWHILE)
- patch(sp, pc);
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OFOR:
- l = n->left;
- gen(l->right->left); /* init */
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- gen(l->right->right); /* inc */
- patch(sp, pc);
- if(l->left != Z) { /* test */
- bcomplex(l->left, Z);
- patch(p, breakpc);
- }
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OCONTINUE:
- if(continpc < 0) {
- diag(n, "continue not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, continpc);
- break;
-
- case OBREAK:
- if(breakpc < 0) {
- diag(n, "break not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, breakpc);
- break;
-
- case OIF:
- l = n->left;
- if(bcomplex(l, n->right)) {
- if(typefd[l->type->etype])
- f = !l->fconst;
- else
- f = !l->vconst;
- if(debug['c'])
- print("%L const if %s\n", nearln, f ? "false" : "true");
- if(f) {
- supgen(n->right->left);
- gen(n->right->right);
- }
- else {
- gen(n->right->left);
- supgen(n->right->right);
- }
- }
- else {
- sp = p;
- if(n->right->left != Z)
- gen(n->right->left);
- if(n->right->right != Z) {
- gbranch(OGOTO);
- patch(sp, pc);
- sp = p;
- gen(n->right->right);
- }
- patch(sp, pc);
- }
- break;
-
- case OSET:
- case OUSED:
- usedset(n->left, o);
- break;
- }
-}
-
-void
-usedset(Node *n, int o)
-{
- if(n->op == OLIST) {
- usedset(n->left, o);
- usedset(n->right, o);
- return;
- }
- complex(n);
- switch(n->op) {
- case OADDR: /* volatile */
- gins(ANOP, n, Z);
- break;
- case ONAME:
- if(o == OSET)
- gins(ANOP, Z, n);
- else
- gins(ANOP, n, Z);
- break;
- }
-}

void
noretval(int n)
@@ -593,21 +217,3 @@
break;
}
}
-
-int
-bcomplex(Node *n, Node *c)
-{
-
- complex(n);
- if(n->type != T)
- if(tcompat(n, T, n->type, tnot))
- n->type = T;
- if(n->type != T) {
- if(c != Z && n->op == OCONST && deadheads(c))
- return 1;
- bool64(n);
- boolgen(n, 1, Z);
- } else
- gbranch(OGOTO);
- return 0;
-}
=======================================
--- /utils/5c/swt.c Tue Apr 27 04:51:13 2010
+++ /utils/5c/swt.c Tue Apr 27 14:08:33 2010
@@ -1,62 +1,17 @@
#include "gc.h"
-
-int
-swcmp(const void *a1, const void *a2)
-{
- C1 *p1, *p2;
-
- p1 = (C1*)a1;
- p2 = (C1*)a2;
- if(p1->val < p2->val)
- return -1;
- return p1->val > p2->val;
-}

void
-doswit(Node *n)
-{
- Case *c;
- C1 *q, *iq;
- long def, nc, i;
+swit1(C1 *q, int nc, long def, Node *n)
+{
Node tn;
-
- def = 0;
- nc = 0;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def) {
- if(def)
- diag(n, "more than one default in switch");
- def = c->label;
- continue;
- }
- nc++;
- }
-
- iq = alloc(nc*sizeof(C1));
- q = iq;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def)
- continue;
- q->label = c->label;
- q->val = c->val;
- q++;
- }
- qsort(iq, nc, sizeof(C1), swcmp);
- if(debug['W'])
- for(i=0; i<nc; i++)
- print("case %2ld: = %.8lux\n", i, iq[i].val);
- if(def == 0)
- def = breakpc;
- for(i=0; i<nc-1; i++)
- if(iq[i].val == iq[i+1].val)
- diag(n, "duplicate cases in switch %ld", iq[i].val);
+
regalloc(&tn, &regnode, Z);
- swit1(iq, nc, def, n, &tn);
+ swit2(q, nc, def, n, &tn);
regfree(&tn);
}

void
-swit1(C1 *q, int nc, long def, Node *n, Node *tn)
+swit2(C1 *q, int nc, long def, Node *n, Node *tn)
{
C1 *r;
int i;
@@ -89,12 +44,12 @@
sp = p;
gopcode(OEQ, nodconst(r->val), n, Z); /* just gen the B.EQ */
patch(p, r->label);
- swit1(q, i, def, n, tn);
+ swit2(q, i, def, n, tn);

if(debug['W'])
print("case < %.8lux\n", r->val);
patch(sp, pc);
- swit1(r+1, nc-i-1, def, n, tn);
+ swit2(r+1, nc-i-1, def, n, tn);
return;

direct:
@@ -121,16 +76,6 @@
gbranch(OGOTO); /* so that regopt() won't be confused */
patch(p, def);
}
-
-void
-casf(void)
-{
- Case *c;
-
- c = alloc(sizeof(*c));
- c->link = cases;
- cases = c;
-}

void
bitload(Node *b, Node *n1, Node *n2, Node *n3, Node *nn)
@@ -153,7 +98,7 @@
gopcode(OAS, n3, Z, n1);
} else {
regalloc(n1, l, nn);
- cgen(l, n1, 0);
+ cgen(l, n1);
}
if(b->type->shift == 0 && typeu[b->type->etype]) {
v = ~0 + (1L << b->type->nbits);
@@ -228,33 +173,6 @@
}
return r;
}
-
-long
-outlstring(ushort *s, long n)
-{
- char buf[2];
- int c;
- long r;
-
- if(suppress)
- return nstring;
- while(nstring & 1)
- outstring("", 1);
- r = nstring;
- while(n > 0) {
- c = *s++;
- if(align(0, types[TCHAR], Aarg1)) {
- buf[0] = c>>8;
- buf[1] = c;
- } else {
- buf[0] = c;
- buf[1] = c>>8;
- }
- outstring(buf, 2);
- n -= sizeof(ushort);
- }
- return r;
-}

int
mulcon(Node *n, Node *nn)
@@ -297,7 +215,7 @@
if(p[1] == 'i')
p += 2;
regalloc(&nod1, n, nn);
- cgen(l, &nod1, 0);
+ cgen(l, &nod1);
vs = v;
regalloc(&nod2, n, Z);

@@ -349,16 +267,6 @@
p += 2;
goto loop;
}
-
-void
-nullwarn(Node *l, Node *r)
-{
- warn(Z, "result of operation not used");
- if(l != Z)
- cgen(l, Z, 0);
- if(r != Z)
- cgen(r, Z, 0);
-}

void
sextern(Sym *s, Node *a, long o, long w)
@@ -650,35 +558,6 @@
}
return bp;
}
-
-void
-ieeedtod(Ieee *ieee, double native)
-{
- double fr, ho, f;
- int exp;
-
- if(native < 0) {
- ieeedtod(ieee, -native);
- ieee->h |= 0x80000000L;
- return;
- }
- if(native == 0) {
- ieee->l = 0;
- ieee->h = 0;
- return;
- }
- fr = frexp(native, &exp);
- f = 2097152L; /* shouldnt use fp constants here */
- fr = modf(fr*f, &ho);
- ieee->h = ho;
- ieee->h &= 0xfffffL;
- ieee->h |= (exp+1022L) << 20;
- f = 65536L;
- fr = modf(fr*f, &ho);
- ieee->l = ho;
- ieee->l <<= 16;
- ieee->l |= (long)(fr*f);
-}

long
align(long i, Type *t, int op)
=======================================
--- /utils/5c/txt.c Fri Dec 22 16:30:12 2006
+++ /utils/5c/txt.c Tue Apr 27 14:08:33 2010
@@ -170,7 +170,7 @@
nod.left = *fnxp;
nod.right = n;
nod.type = n->type;
- cgen(&nod, Z, 0);
+ cgen(&nod, Z);
(*fnxp)++;
}
return;
@@ -187,18 +187,18 @@
if(REGARG >= 0 && curarg == 0 && typechlp[n->type->etype]) {
regaalloc1(tn1, n);
if(n->complex >= FNX) {
- cgen(*fnxp, tn1, 0);
+ cgen(*fnxp, tn1);
(*fnxp)++;
} else
- cgen(n, tn1, 0);
+ cgen(n, tn1);
return;
}
regalloc(tn1, n, Z);
if(n->complex >= FNX) {
- cgen(*fnxp, tn1, 0);
+ cgen(*fnxp, tn1);
(*fnxp)++;
} else
- cgen(n, tn1, 0);
+ cgen(n, tn1);
regaalloc(tn2, n);
gopcode(OAS, tn1, Z, tn2);
regfree(tn1);
=======================================
--- /utils/kc/gc.h Tue Apr 27 04:51:13 2010
+++ /utils/kc/gc.h Tue Apr 27 14:08:33 2010
@@ -57,6 +57,7 @@
long val;
long label;
char def;
+ char isv;
};
#define C ((Case*)0)

@@ -128,6 +129,7 @@
};

EXTERN long breakpc;
+EXTERN long nbreak;
EXTERN Case* cases;
EXTERN Node constnode;
EXTERN Node fconstnode;
@@ -140,7 +142,6 @@
EXTERN long maxargsafe;
EXTERN Multab multab[20];
EXTERN int mnstring;
-EXTERN int retok;
EXTERN Node* nodrat;
EXTERN Node* nodret;
EXTERN Node* nodsafe;
@@ -183,6 +184,7 @@
EXTERN long exregbits;

EXTERN int change;
+EXTERN int suppress;

EXTERN Reg* firstr;
EXTERN Reg* lastr;
@@ -204,7 +206,7 @@
void usedset(Node*, int);
void noretval(int);
void xcom(Node*);
-void bcomplex(Node*);
+int bcomplex(Node*, Node*);

/*
* cgen.c
@@ -255,7 +257,8 @@
*/
int swcmp(const void*, const void*);
void doswit(Node*);
-void swit1(C1*, int, long, Node*, Node*);
+void swit1(C1*, int, long, Node*);
+void swit2(C1*, int, long, Node*, Node*);
void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
=======================================
--- /utils/kc/mkfile Fri Dec 22 13:39:35 2006
+++ /utils/kc/mkfile Tue Apr 27 14:08:33 2010
@@ -4,6 +4,8 @@

OFILES=\
peep.$O\
+ pgen.$O\
+ pswt.$O\
reg.$O\
cgen.$O\
enam.$O\
@@ -30,3 +32,9 @@
cd ../cc
mk $MKFLAGS install
mk $MKFLAGS clean
+
+%.$O: ../cc/%.c
+ $CC $CFLAGS -I. ../cc/$stem.c
+
+#enam.c: k.out.h
+# rc mkenam
=======================================
--- /utils/kc/sgen.c Tue Apr 27 04:51:13 2010
+++ /utils/kc/sgen.c Tue Apr 27 14:08:33 2010
@@ -1,342 +1,4 @@
#include "gc.h"
-
-void
-codgen(Node *n, Node *nn)
-{
- Prog *sp;
- Node *n1, nod, nod1;
-
- cursafe = 0;
- curarg = 0;
- maxargsafe = 0;
-
- /*
- * isolate name
- */
- for(n1 = nn;; n1 = n1->left) {
- if(n1 == Z) {
- diag(nn, "cant find function name");
- return;
- }
- if(n1->op == ONAME)
- break;
- }
- nearln = nn->lineno;
- gpseudo(ATEXT, n1->sym, nodconst(stkoff));
- sp = p;
-
- /*
- * isolate first argument
- */
- if(REGARG) {
- if(typesuv[thisfn->link->etype]) {
- nod1 = *nodret->left;
- nodreg(&nod, &nod1, REGARG);
- gopcode(OAS, &nod, Z, &nod1);
- } else
- if(firstarg && typechlp[firstargtype->etype]) {
- nod1 = *nodret->left;
- nod1.sym = firstarg;
- nod1.type = firstargtype;
- nod1.xoffset = align(0, firstargtype, Aarg1);
- nod1.etype = firstargtype->etype;
- nodreg(&nod, &nod1, REGARG);
- gopcode(OAS, &nod, Z, &nod1);
- }
- }
-
- retok = 0;
- gen(n);
- if(!retok)
- if(thisfn->link->etype != TVOID)
- warn(Z, "no return at end of function: %s", n1->sym->name);
- noretval(3);
- gbranch(ORETURN);
-
- if(!debug['N'] || debug['R'] || debug['P'])
- regopt(sp);
-
- sp->to.offset += maxargsafe;
-}
-
-void
-gen(Node *n)
-{
- Node *l, nod;
- Prog *sp, *spc, *spb;
- Case *cn;
- long sbc, scc;
- int o;
-
-loop:
- if(n == Z)
- return;
- nearln = n->lineno;
- o = n->op;
- if(debug['G'])
- if(o != OLIST)
- print("%L %O\n", nearln, o);
- retok = 0;
- switch(o) {
-
- default:
- complex(n);
- cgen(n, Z);
- break;
-
- case OLIST:
- gen(n->left);
-
- rloop:
- n = n->right;
- goto loop;
-
- case ORETURN:
- retok = 1;
- complex(n);
- if(n->type == T)
- break;
- l = n->left;
- if(l == Z) {
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- if(typesuv[n->type->etype]) {
- sugen(l, nodret, n->type->width);
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- regret(&nod, n);
- cgen(l, &nod);
- regfree(&nod);
- if(typefd[n->type->etype])
- noretval(1);
- else
- noretval(2);
- gbranch(ORETURN);
- break;
-
- case OLABEL:
- l = n->left;
- if(l) {
- l->xoffset = pc;
- if(l->label)
- patch(l->label, pc);
- }
- gbranch(OGOTO); /* prevent self reference in reg */
- patch(p, pc);
- goto rloop;
-
- case OGOTO:
- retok = 1;
- n = n->left;
- if(n == Z)
- return;
- if(n->complex == 0) {
- diag(Z, "label undefined: %s", n->sym->name);
- return;
- }
- gbranch(OGOTO);
- if(n->xoffset) {
- patch(p, n->xoffset);
- return;
- }
- if(n->label)
- patch(n->label, pc-1);
- n->label = p;
- return;
-
- case OCASE:
- l = n->left;
- if(cases == C)
- diag(n, "case/default outside a switch");
- if(l == Z) {
- casf();
- cases->val = 0;
- cases->def = 1;
- cases->label = pc;
- goto rloop;
- }
- complex(l);
- if(l->type == T)
- goto rloop;
- if(l->op == OCONST)
- if(typechl[l->type->etype]) {
- casf();
- cases->val = l->vconst;
- cases->def = 0;
- cases->label = pc;
- goto rloop;
- }
- diag(n, "case expression must be integer constant");
- goto rloop;
-
- case OSWITCH:
- l = n->left;
- complex(l);
- if(l->type == T)
- break;
- if(!typechl[l->type->etype]) {
- diag(n, "switch expression must be integer");
- break;
- }
-
- gbranch(OGOTO); /* entry */
- sp = p;
-
- cn = cases;
- cases = C;
- casf();
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- gen(n->right);
- gbranch(OGOTO);
- patch(p, breakpc);
-
- patch(sp, pc);
- regalloc(&nod, l, Z);
- nod.type = types[TLONG];
- cgen(l, &nod);
- doswit(&nod);
- regfree(&nod);
- patch(spb, pc);
-
- cases = cn;
- breakpc = sbc;
- break;
-
- case OWHILE:
- case ODWHILE:
- l = n->left;
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- if(n->op == OWHILE)
- patch(sp, pc);
- bcomplex(l); /* test */
- patch(p, breakpc);
-
- if(n->op == ODWHILE)
- patch(sp, pc);
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OFOR:
- l = n->left;
- gen(l->right->left); /* init */
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- gen(l->right->right); /* inc */
- patch(sp, pc);
- if(l->left != Z) { /* test */
- bcomplex(l->left);
- patch(p, breakpc);
- }
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OCONTINUE:
- if(continpc < 0) {
- diag(n, "continue not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, continpc);
- break;
-
- case OBREAK:
- if(breakpc < 0) {
- diag(n, "break not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, breakpc);
- break;
-
- case OIF:
- l = n->left;
- bcomplex(l);
- sp = p;
- if(n->right->left != Z)
- gen(n->right->left);
- if(n->right->right != Z) {
- gbranch(OGOTO);
- patch(sp, pc);
- sp = p;
- gen(n->right->right);
- }
- patch(sp, pc);
- break;
-
- case OSET:
- case OUSED:
- usedset(n->left, o);
- break;
- }
-}
-
-void
-usedset(Node *n, int o)
-{
- if(n->op == OLIST) {
- usedset(n->left, o);
- usedset(n->right, o);
- return;
- }
- complex(n);
- switch(n->op) {
- case OADDR: /* volatile */
- gins(ANOP, n, Z);
- break;
- case ONAME:
- if(o == OSET)
- gins(ANOP, Z, n);
- else
- gins(ANOP, n, Z);
- break;
- }
-}

void
noretval(int n)
@@ -574,17 +236,3 @@
}
}

-void
-bcomplex(Node *n)
-{
-
- complex(n);
- if(n->type != T)
- if(tcompat(n, T, n->type, tnot))
- n->type = T;
- if(n->type != T) {
- bool64(n);
- boolgen(n, 1, Z);
- } else
- gbranch(OGOTO);
-}
=======================================
--- /utils/kc/swt.c Tue Apr 27 04:51:13 2010
+++ /utils/kc/swt.c Tue Apr 27 14:08:33 2010
@@ -1,59 +1,17 @@
#include "gc.h"
-
-int
-swcmp(const void *a1, const void *a2)
-{
- C1 *p1, *p2;
-
- p1 = (C1*)a1;
- p2 = (C1*)a2;
- if(p1->val < p2->val)
- return -1;
- return p1->val > p2->val;
-}

void
-doswit(Node *n)
-{
- Case *c;
- C1 *q, *iq;
- long def, nc, i;
+swit1(C1 *q, int nc, long def, Node *n)
+{
Node tn;
-
- def = 0;
- nc = 0;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def) {
- if(def)
- diag(n, "more than one default in switch");
- def = c->label;
- continue;
- }
- nc++;
- }
-
- iq = alloc(nc*sizeof(C1));
- q = iq;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def)
- continue;
- q->label = c->label;
- q->val = c->val;
- q++;
- }
- qsort(iq, nc, sizeof(C1), swcmp);
- if(def == 0)
- def = breakpc;
- for(i=0; i<nc-1; i++)
- if(iq[i].val == iq[i+1].val)
- diag(n, "duplicate cases in switch %ld", iq[i].val);
+
regalloc(&tn, &regnode, Z);
- swit1(iq, nc, def, n, &tn);
+ swit2(q, nc, def, n, &tn);
regfree(&tn);
}

void
-swit1(C1 *q, int nc, long def, Node *n, Node *tn)
+swit2(C1 *q, int nc, long def, Node *n, Node *tn)
{
C1 *r;
int i;
@@ -87,20 +45,10 @@
gbranch(OGOTO);
p->as = ABE;
patch(p, r->label);
- swit1(q, i, def, n, tn);
+ swit2(q, i, def, n, tn);

patch(sp, pc);
- swit1(r+1, nc-i-1, def, n, tn);
-}
-
-void
-casf(void)
-{
- Case *c;
-
- c = alloc(sizeof(*c));
- c->link = cases;
- cases = c;
+ swit2(r+1, nc-i-1, def, n, tn);
}

void
@@ -197,31 +145,6 @@
}
return r;
}
-
-long
-outlstring(ushort *s, long n)
-{
- char buf[2];
- int c;
- long r;
-
- while(nstring & 1)
- outstring("", 1);
- r = nstring;
- while(n > 0) {
- c = *s++;
- if(align(0, types[TCHAR], Aarg1)) {
- buf[0] = c>>8;
- buf[1] = c;
- } else {
- buf[0] = c;
- buf[1] = c>>8;
- }
- outstring(buf, 2);
- n -= sizeof(ushort);
- }
- return r;
-}

int
mulcon(Node *n, Node *nn)
@@ -311,16 +234,6 @@
p += 2;
goto loop;
}
-
-void
-nullwarn(Node *l, Node *r)
-{
- warn(Z, "result of operation not used");
- if(l != Z)
- cgen(l, Z);
- if(r != Z)
- cgen(r, Z);
-}

void
sextern(Sym *s, Node *a, long o, long w)
@@ -608,35 +521,6 @@
break;
}
}
-
-void
-ieeedtod(Ieee *ieee, double native)
-{
- double fr, ho, f;
- int exp;
-
- if(native < 0) {
- ieeedtod(ieee, -native);
- ieee->h |= 0x80000000L;
- return;
- }
- if(native == 0) {
- ieee->l = 0;
- ieee->h = 0;
- return;
- }
- fr = frexp(native, &exp);
- f = 2097152L; /* shouldnt use fp constants here */
- fr = modf(fr*f, &ho);
- ieee->h = ho;
- ieee->h &= 0xfffffL;
- ieee->h |= (exp+1022L) << 20;
- f = 65536L;
- fr = modf(fr*f, &ho);
- ieee->l = ho;
- ieee->l <<= 16;
- ieee->l |= (long)(fr*f);
-}

long
align(long i, Type *t, int op)
=======================================
--- /utils/vc/cgen.c Fri Dec 22 13:39:35 2006
+++ /utils/vc/cgen.c Tue Apr 27 14:08:33 2010
@@ -497,6 +497,8 @@
} else
gopcode(OADD, nodconst(v), Z, &nod);
gopcode(OAS, &nod, Z, &nod2);
+ if(nn && l->op == ONAME) /* in x=++i, emit USED(i) */
+ gins(ANOP, l, Z);

regfree(&nod);
if(l->addable < INDEXED)
=======================================
--- /utils/vc/gc.h Tue Apr 27 04:51:13 2010
+++ /utils/vc/gc.h Tue Apr 27 14:08:33 2010
@@ -58,6 +58,7 @@
long val;
long label;
char def;
+ char isv;
};
#define C ((Case*)0)

@@ -129,6 +130,7 @@
};

EXTERN long breakpc;
+EXTERN long nbreak;
EXTERN Case* cases;
EXTERN Node constnode;
EXTERN Node fconstnode;
@@ -140,7 +142,6 @@
EXTERN long maxargsafe;
EXTERN int mnstring;
EXTERN Multab multab[20];
-EXTERN int retok;
EXTERN int hintabsize;
EXTERN Node* nodrat;
EXTERN Node* nodret;
@@ -184,6 +185,7 @@
EXTERN long exregbits;

EXTERN int change;
+EXTERN int suppress;

EXTERN Reg* firstr;
EXTERN Reg* lastr;
@@ -204,7 +206,7 @@
void gen(Node*);
void noretval(int);
void xcom(Node*);
-void bcomplex(Node*);
+int bcomplex(Node*, Node*);
void usedset(Node*, int);

/*
@@ -256,7 +258,8 @@
*/
int swcmp(const void*, const void*);
void doswit(Node*);
-void swit1(C1*, int, long, Node*, Node*);
+void swit1(C1*, int, long, Node*);
+void swit2(C1*, int, long, Node*, Node*);
void casf(void);
void bitload(Node*, Node*, Node*, Node*, Node*);
void bitstore(Node*, Node*, Node*, Node*, Node*);
=======================================
--- /utils/vc/mkfile Fri Dec 22 13:39:35 2006
+++ /utils/vc/mkfile Tue Apr 27 14:08:33 2010
@@ -7,6 +7,8 @@
enam.$O\
list.$O\
peep.$O\
+ pgen.$O\
+ pswt.$O\
reg.$O\
sgen.$O\
swt.$O\
@@ -30,3 +32,9 @@
cd ../cc
mk $MKFLAGS install
mk $MKFLAGS clean
+
+%.$O: ../cc/%.c
+ $CC $CFLAGS -I. ../cc/$stem.c
+
+#enam.c: v.out.h
+# rc mkenam
=======================================
--- /utils/vc/peep.c Fri Dec 22 16:30:12 2006
+++ /utils/vc/peep.c Tue Apr 27 14:08:33 2010
@@ -569,7 +569,7 @@
return 3;
return 0;
}
- return 0;
+ /* not reached */
}

int
=======================================
--- /utils/vc/sgen.c Tue Apr 27 04:51:13 2010
+++ /utils/vc/sgen.c Tue Apr 27 14:08:33 2010
@@ -1,343 +1,4 @@
#include "gc.h"
-
-void
-codgen(Node *n, Node *nn)
-{
- Prog *sp;
- Node *n1, nod, nod1;
-
- cursafe = 0;
- curarg = 0;
- maxargsafe = 0;
-
- /*
- * isolate name
- */
- for(n1 = nn;; n1 = n1->left) {
- if(n1 == Z) {
- diag(nn, "cant find function name");
- return;
- }
- if(n1->op == ONAME)
- break;
- }
- nearln = nn->lineno;
- gpseudo(ATEXT, n1->sym, nodconst(stkoff));
- sp = p;
-
- /*
- * isolate first argument
- */
- if(REGARG) {
- if(typesuv[thisfn->link->etype]) {
- nod1 = *nodret->left;
- nodreg(&nod, &nod1, REGARG);
- gopcode(OAS, &nod, Z, &nod1);
- } else
- if(firstarg && typechlp[firstargtype->etype]) {
- nod1 = *nodret->left;
- nod1.sym = firstarg;
- nod1.type = firstargtype;
- nod1.xoffset = align(0, firstargtype, Aarg1);
- nod1.etype = firstargtype->etype;
- nodreg(&nod, &nod1, REGARG);
- gopcode(OAS, &nod, Z, &nod1);
- }
- }
-
- retok = 0;
- gen(n);
- if(!retok)
- if(thisfn->link->etype != TVOID)
- warn(Z, "no return at end of function: %s", n1->sym->name);
- noretval(3);
- gbranch(ORETURN);
-
- if(!debug['N'] || debug['R'] || debug['P'])
- regopt(sp);
-
- sp->to.offset += maxargsafe;
-}
-
-void
-gen(Node *n)
-{
- Node *l, nod;
- Prog *sp, *spc, *spb;
- Case *cn;
- long sbc, scc;
- int o;
-
-loop:
- if(n == Z)
- return;
- nearln = n->lineno;
- o = n->op;
- if(debug['G'])
- if(o != OLIST)
- print("%L %O\n", nearln, o);
-
- retok = 0;
- switch(o) {
-
- default:
- complex(n);
- cgen(n, Z);
- break;
-
- case OLIST:
- gen(n->left);
-
- rloop:
- n = n->right;
- goto loop;
-
- case ORETURN:
- retok = 1;
- complex(n);
- if(n->type == T)
- break;
- l = n->left;
- if(l == Z) {
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- if(typesuv[n->type->etype]) {
- sugen(l, nodret, n->type->width);
- noretval(3);
- gbranch(ORETURN);
- break;
- }
- regret(&nod, n);
- cgen(l, &nod);
- regfree(&nod);
- if(typefd[n->type->etype])
- noretval(1);
- else
- noretval(2);
- gbranch(ORETURN);
- break;
-
- case OLABEL:
- l = n->left;
- if(l) {
- l->pc = pc;
- if(l->label)
- patch(l->label, pc);
- }
- gbranch(OGOTO); /* prevent self reference in reg */
- patch(p, pc);
- goto rloop;
-
- case OGOTO:
- retok = 1;
- n = n->left;
- if(n == Z)
- return;
- if(n->complex == 0) {
- diag(Z, "label undefined: %s", n->sym->name);
- return;
- }
- gbranch(OGOTO);
- if(n->pc) {
- patch(p, n->pc);
- return;
- }
- if(n->label)
- patch(n->label, pc-1);
- n->label = p;
- return;
-
- case OCASE:
- l = n->left;
- if(cases == C)
- diag(n, "case/default outside a switch");
- if(l == Z) {
- casf();
- cases->val = 0;
- cases->def = 1;
- cases->label = pc;
- goto rloop;
- }
- complex(l);
- if(l->type == T)
- goto rloop;
- if(l->op == OCONST)
- if(typechl[l->type->etype]) {
- casf();
- cases->val = l->vconst;
- cases->def = 0;
- cases->label = pc;
- goto rloop;
- }
- diag(n, "case expression must be integer constant");
- goto rloop;
-
- case OSWITCH:
- l = n->left;
- complex(l);
- if(l->type == T)
- break;
- if(!typechl[l->type->etype]) {
- diag(n, "switch expression must be integer");
- break;
- }
-
- gbranch(OGOTO); /* entry */
- sp = p;
-
- cn = cases;
- cases = C;
- casf();
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- gen(n->right);
- gbranch(OGOTO);
- patch(p, breakpc);
-
- patch(sp, pc);
- regalloc(&nod, l, Z);
- nod.type = types[TLONG];
- cgen(l, &nod);
- doswit(&nod);
- regfree(&nod);
- patch(spb, pc);
-
- cases = cn;
- breakpc = sbc;
- break;
-
- case OWHILE:
- case ODWHILE:
- l = n->left;
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- if(n->op == OWHILE)
- patch(sp, pc);
- bcomplex(l); /* test */
- patch(p, breakpc);
-
- if(n->op == ODWHILE)
- patch(sp, pc);
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OFOR:
- l = n->left;
- gen(l->right->left); /* init */
- gbranch(OGOTO); /* entry */
- sp = p;
-
- scc = continpc;
- continpc = pc;
- gbranch(OGOTO);
- spc = p;
-
- sbc = breakpc;
- breakpc = pc;
- gbranch(OGOTO);
- spb = p;
-
- patch(spc, pc);
- gen(l->right->right); /* inc */
- patch(sp, pc);
- if(l->left != Z) { /* test */
- bcomplex(l->left);
- patch(p, breakpc);
- }
- gen(n->right); /* body */
- gbranch(OGOTO);
- patch(p, continpc);
-
- patch(spb, pc);
- continpc = scc;
- breakpc = sbc;
- break;
-
- case OCONTINUE:
- if(continpc < 0) {
- diag(n, "continue not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, continpc);
- break;
-
- case OBREAK:
- if(breakpc < 0) {
- diag(n, "break not in a loop");
- break;
- }
- gbranch(OGOTO);
- patch(p, breakpc);
- break;
-
- case OIF:
- l = n->left;
- bcomplex(l);
- sp = p;
- if(n->right->left != Z)
- gen(n->right->left);
- if(n->right->right != Z) {
- gbranch(OGOTO);
- patch(sp, pc);
- sp = p;
- gen(n->right->right);
- }
- patch(sp, pc);
- break;
-
- case OSET:
- case OUSED:
- usedset(n->left, o);
- break;
- }
-}
-
-void
-usedset(Node *n, int o)
-{
- if(n->op == OLIST) {
- usedset(n->left, o);
- usedset(n->right, o);
- return;
- }
- complex(n);
- switch(n->op) {
- case OADDR: /* volatile */
- gins(ANOP, n, Z);
- break;
- case ONAME:
- if(o == OSET)
- gins(ANOP, Z, n);
- else
- gins(ANOP, n, Z);
- break;
- }
-}

void
noretval(int n)
@@ -564,17 +225,3 @@
}
}

-void
-bcomplex(Node *n)
-{
-
- complex(n);
- if(n->type != T)
- if(tcompat(n, T, n->type, tnot))
- n->type = T;
- if(n->type != T) {
- bool64(n);
- boolgen(n, 1, Z);
- } else
- gbranch(OGOTO);
-}
=======================================
--- /utils/vc/swt.c Tue Apr 27 04:51:13 2010
+++ /utils/vc/swt.c Tue Apr 27 14:08:33 2010
@@ -1,62 +1,17 @@
#include "gc.h"
-
-int
-swcmp(const void *a1, const void *a2)
-{
- C1 *p1, *p2;
-
- p1 = (C1*)a1;
- p2 = (C1*)a2;
- if(p1->val < p2->val)
- return -1;
- return p1->val > p2->val;
-}

void
-doswit(Node *n)
-{
- Case *c;
- C1 *q, *iq;
- long def, nc, i;
+swit1(C1 *q, int nc, long def, Node *n)
+{
Node tn;
-
- def = 0;
- nc = 0;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def) {
- if(def)
- diag(n, "more than one default in switch");
- def = c->label;
- continue;
- }
- nc++;
- }
-
- iq = alloc(nc*sizeof(C1));
- q = iq;
- for(c = cases; c->link != C; c = c->link) {
- if(c->def)
- continue;
- q->label = c->label;
- q->val = c->val;
- q++;
- }
- qsort(iq, nc, sizeof(C1), swcmp);
- if(debug['W'])
- for(i=0; i<nc; i++)
- print("case %2ld: = %.8lux\n", i, iq[i].val);
- if(def == 0)
- def = breakpc;
- for(i=0; i<nc-1; i++)
- if(iq[i].val == iq[i+1].val)
- diag(n, "duplicate cases in switch %ld", iq[i].val);
+
regalloc(&tn, &regnode, Z);
- swit1(iq, nc, def, n, &tn);
+ swit2(q, nc, def, n, &tn);
regfree(&tn);
}

void
-swit1(C1 *q, int nc, long def, Node *n, Node *tn)
+swit2(C1 *q, int nc, long def, Node *n, Node *tn)
{
C1 *r;
int i;
@@ -84,22 +39,12 @@
sp = p;
gopcode(OEQ, n, tn, Z);
patch(p, r->label);
- swit1(q, i, def, n, tn);
+ swit2(q, i, def, n, tn);

if(debug['W'])
print("case < %.8lux\n", r->val);
patch(sp, pc);
- swit1(r+1, nc-i-1, def, n, tn);
-}
-
-void
-casf(void)
-{
- Case *c;
-
- c = alloc(sizeof(*c));
- c->link = cases;
- cases = c;
+ swit2(r+1, nc-i-1, def, n, tn);
}

void
@@ -196,31 +141,6 @@
}
return r;
}
-
-long
-outlstring(ushort *s, long n)
-{
- char buf[2];
- int c;
- long r;
-
- while(nstring & 1)
- outstring("", 1);
- r = nstring;
- while(n > 0) {
- c = *s++;
- if(align(0, types[TCHAR], Aarg1)) {
- buf[0] = c>>8;
- buf[1] = c;
- } else {
- buf[0] = c;
- buf[1] = c>>8;
- }
- outstring(buf, 2);
- n -= sizeof(ushort);
- }
- return r;
-}

int
mulcon(Node *n, Node *nn)
@@ -312,16 +232,6 @@
p += 2;
goto loop;
}
-
-void
-nullwarn(Node *l, Node *r)
-{
- warn(Z, "result of operation not used");
- if(l != Z)
- cgen(l, Z);
- if(r != Z)
- cgen(r, Z);
-}

void
sextern(Sym *s, Node *a, long o, long w)
@@ -614,35 +524,6 @@
}
return bp;
}
-
-void
-ieeedtod(Ieee *ieee, double native)
-{
- double fr, ho, f;
- int exp;
-
- if(native < 0) {
- ieeedtod(ieee, -native);
- ieee->h |= 0x80000000L;
- return;
- }
- if(native == 0) {
- ieee->l = 0;
- ieee->h = 0;
- return;
- }
- fr = frexp(native, &exp);
- f = 2097152L; /* shouldnt use fp constants here */
- fr = modf(fr*f, &ho);
- ieee->h = ho;
- ieee->h &= 0xfffffL;
- ieee->h |= (exp+1022L) << 20;
- f = 65536L;
- fr = modf(fr*f, &ho);
- ieee->l = ho;
- ieee->l <<= 16;
- ieee->l |= (long)(fr*f);
-}

long
align(long i, Type *t, int op)
@@ -660,6 +541,8 @@

case Asu2: /* padding at end of a struct */
w = SZ_LONG;
+ if(packflg)
+ w = packflg;
break;

case Ael1: /* initial allign of struct element */
@@ -668,6 +551,8 @@
w = ewidth[v->etype];
if(w <= 0 || w >= SZ_LONG)
w = SZ_LONG;
+ if(packflg)
+ w = packflg;
break;

case Ael2: /* width of a struct element */
@@ -687,7 +572,8 @@
w = SZ_LONG;
break;
}
- o += SZ_LONG - w; /* big endian adjustment */
+ if(thechar == 'v')
+ o += SZ_LONG - w; /* big endian adjustment */
w = 1;
break;


==============================================================================
Revision: b9d0fe3aa5
Author: Venkatesh Srinivas <m...@endeavour.zapto.org>
Date: Wed Apr 28 18:25:58 2010
Log: Merge with inferno-os 20100427.
http://code.google.com/p/inferno-npe/source/detail?r=b9d0fe3aa5

Deleted:
/utils/cc/machcap.c
/utils/libmach/mach.h
/utils/libmach/tobj.c
Modified:
/CHANGES
/include/version.h
/utils/8c/8.out.h

=======================================
--- /utils/cc/machcap.c Fri Dec 22 13:39:35 2006
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "cc.h"
-
-/* default, like old cc */
-int
-machcap(Node *n)
-{
- USED(n);
- return 0;
-}
=======================================
--- /utils/libmach/mach.h Fri Dec 22 13:39:35 2006
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Architecture-dependent application data
- */
-#include "a.out.h"
-/*
- * Supported architectures:
- * mips,
- * 68020,
- * i386,
- * amd64,
- * sparc,
- * mips2 (R4000)
- * arm
- */
-enum
-{
- MMIPS, /* machine types */
- MSPARC,
- M68020,
- MI386,
- MI960, /* retired */
- M3210, /* retired */
- MMIPS2,
- NMIPS2,
- M29000, /* retired */
- MARM,
- MPOWER,
-
- /* types of executables */
- FNONE = 0, /* unidentified */
- FMIPS, /* v.out */
- FMIPSB, /* mips bootable */
- FSPARC, /* k.out */
- FSPARCB, /* Sparc bootable */
- F68020, /* 2.out */
- F68020B, /* 68020 bootable */
- FNEXTB, /* Next bootable */
- FI386, /* 8.out */
- FI386B, /* I386 bootable */
- FI960, /* retired */
- FI960B, /* retired */
- F3210, /* retired */
- FMIPS2BE, /* 4.out */
- F29000, /* retired */
- FARM, /* 5.out */
- FARMB, /* ARM bootable */
- FPOWER, /* q.out */
- FPOWERB, /* power pc bootable */
- FMIPS2LE, /* 4k little endian */
-
- ANONE = 0, /* dissembler types */
- AMIPS,
- AMIPSCO, /* native mips */
- ASPARC,
- ASUNSPARC, /* native sun */
- A68020,
- AI386,
- AI8086, /* oh god */
- AI960, /* retired */
- A29000,
- AARM,
- APOWER,
- /* object file types */
- Obj68020 = 0, /* .2 */
- ObjSparc, /* .k */
- ObjMips, /* .v */
- Obj386, /* .8 */
- Obj960, /* retired */
- Obj3210, /* .x */
- ObjMips2, /* .4 */
- Obj29000, /* retired */
- ObjArm, /* .5 */
- ObjPower, /* .q */
- ObjMips2le, /* .0 */
- Maxobjtype,
-
- CNONE = 0, /* symbol table classes */
- CAUTO,
- CPARAM,
- CSTAB,
- CTEXT,
- CDATA,
- CANY /* to look for any class */
-};
-
-typedef struct Map Map;
-typedef struct Symbol Symbol;
-typedef struct Reglist Reglist;
-typedef struct Mach Mach;
-typedef struct Machdata Machdata;
-typedef struct segment segment;
-
-typedef int (*Rsegio)(segment*, ulong, long, char*, int);
-
-/*
- * Structure to map a segment to a position in a file
- */
-struct Map {
- int nsegs; /* number of segments */
- struct segment { /* per-segment map */
- char *name; /* the segment name */
- int fd; /* file descriptor */
- int inuse; /* in use - not in use */
- ulong b; /* base */
- ulong e; /* end */
- ulong f; /* offset within file */
- Rsegio mget; /* special get if not 0 */
- Rsegio mput; /* special put if not 0 */
- } seg[1]; /* actually n of these */
-};
-
-
-
-/*
- * Internal structure describing a symbol table entry
- */
-struct Symbol {
- void *handle; /* used internally - owning func */
- /*struct {*/
- char *name;
- long value; /* address or stack offset */
- char type; /* as in a.out.h */
- char class; /* as above */
- /*};*/
-};
-
-/*
- * machine register description
- */
-struct Reglist {
- char *rname; /* register name */
- short roffs; /* offset in u-block */
- char rflags; /* INTEGER/FLOAT, WRITABLE */
- char rformat; /* print format: 'x', 'X', 'f', '8', '3', 'Y', 'W' */
-};
-
-enum { /* bits in rflags field */
- RINT = (0<<0),
- RFLT = (1<<0),
- RRDONLY = (1<<1)
-};
-/*
- * Machine-dependent data is stored in two structures:
- * Mach - miscellaneous general parameters
- * Machdata - jump vector of service functions used by debuggers
- *
- * Mach is defined in 2.c, 4.c, v.c, k.c, 8.c, 6.c and set in executable.c
- *
- * Machdata is defined in 2db.c, 4db.c, vdb.c, kdb.c, 8db.c, and 6db.c
- * and set in the debugger startup.
- */
-
-
-struct Mach{
- char *name;
- int mtype; /* machine type code */
- Reglist *reglist; /* register set */
- ulong regsize; /* sizeof registers in bytes*/
- ulong fpregsize; /* sizeof fp registers in bytes*/
- char *pc; /* pc name */
- char *sp; /* sp name */
- char *link; /* link register name */
- char *sbreg; /* static base register name */
- ulong sb; /* static base register value */
- int pgsize; /* page size */
- ulong kbase; /* kernel base address */
- ulong ktmask; /* ktzero = kbase & ~ktmask */
- int pcquant; /* quantization of pc */
- int szaddr; /* sizeof(void*) */
- int szreg; /* sizeof(register) */
- int szfloat; /* sizeof(float) */
- int szdouble; /* sizeof(double) */
-};
-
-extern Mach *mach; /* Current machine */
-
-typedef vlong (*Rgetter)(Map*, char*);
-typedef void (*Tracer)(Map*, ulong, ulong, Symbol*);
-
-struct Machdata { /* Machine-dependent debugger support */
- uchar bpinst[4]; /* break point instr. */
- short bpsize; /* size of break point instr. */
-
- ushort (*swab)(ushort); /* short to local byte order */
- long (*swal)(long); /* long to local byte order */
- vlong (*swav)(vlong); /* vlong to local byte order */
- int (*ctrace)(Map*, ulong, ulong, ulong, Tracer); /* C traceback */
- ulong (*findframe)(Map*, ulong, ulong, ulong, ulong);/* frame finder */
- char* (*excep)(Map*, Rgetter); /* last exception */
- ulong (*bpfix)(ulong); /* breakpoint fixup */
- int (*sftos)(char*, int, void*); /* single precision float */
- int (*dftos)(char*, int, void*); /* double precision float */
- int (*foll)(Map*, ulong, Rgetter, ulong*); /* follow set */
- int (*das)(Map*, ulong, char, char*, int); /* symbolic disassembly */
- int (*hexinst)(Map*, ulong, char*, int); /* hex disassembly */
- int (*instsize)(Map*, ulong); /* instruction size */
-};
-
-/*
- * Common a.out header describing all architectures
- */
-typedef struct Fhdr
-{
- char *name; /* identifier of executable */
- short type; /* file type - see codes above*/
- short hdrsz; /* size of this header */
- long magic; /* magic number */
- long txtaddr; /* text address */
- long entry; /* entry point */
- long txtsz; /* text size */
- long txtoff; /* start of text in file */
- long dataddr; /* start of data segment */
- long datsz; /* size of data seg */
- long datoff; /* offset to data seg in file */
- long bsssz; /* size of bss */
- long symsz; /* size of symbol table */
- long symoff; /* offset of symbol table in file */
- long sppcsz; /* size of sp-pc table */
- long sppcoff; /* offset of sp-pc table in file */
- long lnpcsz; /* size of line number-pc table */
- long lnpcoff; /* size of line number-pc table */
-} Fhdr;
-
-extern int asstype; /* dissembler type - machdata.c */
-extern Machdata *machdata; /* jump vector - machdata.c */
-
-Map* attachproc(int, int, int, Fhdr*);
-Map* attachremt(int, Fhdr*);
-int beieee80ftos(char*, int, void*);
-int beieeesftos(char*, int, void*);
-int beieeedftos(char*, int, void*);
-ushort beswab(ushort);
-long beswal(long);
-vlong beswav(vlong);
-int cisctrace(Map*, ulong, ulong, ulong, Tracer);
-ulong ciscframe(Map*, ulong, ulong, ulong, ulong);
-int crackhdr(int fd, Fhdr*);
-long file2pc(char*, ulong);
-int fileelem(Sym**, uchar *, char*, int);
-int fileline(char*, int, ulong);
-int filesym(int, char*, int);
-int findlocal(Symbol*, char*, Symbol*);
-int findseg(Map*, char*);
-int findsym(long, int, Symbol *);
-int fnbound(long, ulong*);
-int fpformat(Map*, Reglist*, char*, int, int);
-int get1(Map*, ulong, uchar*, int);
-int get2(Map*, ulong, ushort*);
-int get4(Map*, ulong, long*);
-int get8(Map*, ulong, vlong*);
-int getauto(Symbol*, int, int, Symbol*);
-Sym* getsym(int);
-int globalsym(Symbol *, int);
-char* _hexify(char*, ulong, int);
-int ieeesftos(char*, int, ulong);
-int ieeedftos(char*, int, ulong, ulong);
-int isar(Biobuf*);
-int leieee80ftos(char*, int, void*);
-int leieeesftos(char*, int, void*);
-int leieeedftos(char*, int, void*);
-ushort leswab(ushort);
-long leswal(long);
-vlong leswav(vlong);
-long line2addr(ulong, ulong, ulong);
-Map* loadmap(Map*, int, Fhdr*);
-int localaddr(Map*, char*, char*, long*, Rgetter);
-int localsym(Symbol*, int);
-int lookup(char*, char*, Symbol*);
-void machbytype(int);
-int machbyname(char*);
-int nextar(Biobuf*, int, char*);
-Map* newmap(Map*, int);
-void objtraverse(void(*)(Sym*, void*), void*);
-int objtype(Biobuf*, char**);
-long pc2sp(ulong);
-long pc2line(ulong);
-int put1(Map*, ulong, uchar*, int);
-int put2(Map*, ulong, ushort);
-int put4(Map*, ulong, long);
-int put8(Map*, ulong, vlong);
-int readar(Biobuf*, int, int, int);
-int readobj(Biobuf*, int);
-struct segment* reloc(Map*, ulong, long*);
-ulong riscframe(Map*, ulong, ulong, ulong, ulong);
-int risctrace(Map*, ulong, ulong, ulong, Tracer);
-int setmap(Map*, int, ulong, ulong, ulong, char*);
-void setmapio(Map*, int, Rsegio, Rsegio);
-Sym* symbase(long*);
-int syminit(int, Fhdr*);
-int symoff(char*, int, long, int);
-void textseg(ulong, Fhdr*);
-int textsym(Symbol*, int);
-void unusemap(Map*, int);
-
=======================================
--- /utils/libmach/tobj.c Fri Dec 22 13:39:35 2006
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 5obj.c - identify and parse a arm object file
- */
-#include <lib9.h>
-#include <bio.h>
-#include "5c/5.out.h"
-#include "obj.h"
-
-typedef struct Addr Addr;
-struct Addr
-{
- char type;
- char sym;
- char name;
-};
-static Addr addr(Biobuf*);
-static char type2char(int);
-static void skip(Biobuf*, int);
-
-int
-_ist(char *s)
-{
- return s[0] == ANAME /* ANAME */
- && s[1] == D_FILE /* type */
- && s[2] == 1 /* sym */
- && s[3] == '<'; /* name of file */
-}
-
-int
-_readt(Biobuf *bp, Prog *p)
-{
- int as, n;
- Addr a;
-
- as = Bgetc(bp); /* as */
- if(as < 0)
- return 0;
- p->kind = aNone;
- if(as == ANAME || as == ASIGNAME){
- if(as == ASIGNAME)
- skip(bp, 4); /* signature */
- p->kind = aName;
- p->type = type2char(Bgetc(bp)); /* type */
- p->sym = Bgetc(bp); /* sym */
- n = 0;
- for(;;) {
- as = Bgetc(bp);
- if(as < 0)
- return 0;
- n++;
- if(as == 0)
- break;
- }
- p->id = malloc(n);
- if(p->id == 0)
- return 0;
- Bseek(bp, -n, 1);
- if(Bread(bp, p->id, n) != n)
- return 0;
- return 1;
- }
- if(as == ATEXT)
- p->kind = aText;
- else if(as == AGLOBL)
- p->kind = aData;
- skip(bp, 6); /* scond(1), reg(1), lineno(4) */
- a = addr(bp);
- addr(bp);
- if(a.type != D_OREG || a.name != D_STATIC && a.name != D_EXTERN)
- p->kind = aNone;
- p->sym = a.sym;
- return 1;
-}
-
-static Addr
-addr(Biobuf *bp)
-{
- Addr a;
- long off;
-
- a.type = Bgetc(bp); /* a.type */
- skip(bp,1); /* reg */
- a.sym = Bgetc(bp); /* sym index */
- a.name = Bgetc(bp); /* sym type */
- switch(a.type){
- default:
- case D_NONE:
- case D_REG:
- case D_FREG:
- case D_PSR:
- case D_FPCR:
- break;
- case D_OREG:
- case D_CONST:
- case D_BRANCH:
- case D_SHIFT:
- off = Bgetc(bp);
- off |= Bgetc(bp) << 8;
- off |= Bgetc(bp) << 16;
- off |= Bgetc(bp) << 24;
- if(off < 0)
- off = -off;
- if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
- _offset(a.sym, off);
- break;
- case D_SCONST:
- skip(bp, NSNAME);
- break;
- case D_FCONST:
- skip(bp, 8);
- break;
- }
- return a;
-}
-
-static char
-type2char(int t)
-{
- switch(t){
- case D_EXTERN: return 'U';
- case D_STATIC: return 'b';
- case D_AUTO: return 'a';
- case D_PARAM: return 'p';
- default: return UNKNOWN;
- }
-}
-
-static void
-skip(Biobuf *bp, int n)
-{
- while (n-- > 0)
- Bgetc(bp);
-}
=======================================
--- /CHANGES Wed Apr 7 06:04:21 2010
+++ /CHANGES Wed Apr 28 18:25:58 2010
@@ -1,3 +1,8 @@
+20100426
+ updated libmach
+ updated compiler suites (continuing)
+20100425
+ appl/wm/wm.b shorten processing of wmctl close if client hadn't started
20100406
fix handling of boundary case in libtk/utils.c
20100402
=======================================
--- /include/version.h Wed Apr 7 06:04:21 2010
+++ /include/version.h Wed Apr 28 18:25:58 2010
@@ -1,1 +1,1 @@
-#define VERSION "Fourth Edition (20100406)"
+#define VERSION "Fourth Edition (20100427)"
=======================================
--- /utils/8c/8.out.h Thu Jan 14 13:00:25 2010
+++ /utils/8c/8.out.h Wed Apr 28 18:25:58 2010
@@ -423,7 +423,7 @@
T_SYM = 1<<4,
T_SCONST = 1<<5,

- REGARG = 0,
+ REGARG = -1,
REGRET = D_AX,
FREGRET = D_F0,
REGSP = D_SP,
Reply all
Reply to author
Forward
0 new messages