summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/asm.h6
-rw-r--r--6/gengas.c2
-rw-r--r--6/genp9.c38
-rw-r--r--6/typeinfo.c10
-rw-r--r--doc/mkfile1
-rwxr-xr-xmk/bootstrap/bootstrap+Plan9-amd64.sh6
6 files changed, 38 insertions, 25 deletions
diff --git a/6/asm.h b/6/asm.h
index e7a801a..4d55ac4 100644
--- a/6/asm.h
+++ b/6/asm.h
@@ -76,7 +76,10 @@ struct Blob {
char isglobl;
union {
uint64_t ival;
- char *ref;
+ struct {
+ char *str;
+ char isextern;
+ } ref;
struct {
size_t len;
char *buf;
@@ -236,6 +239,7 @@ void gen(Node *file, char *out);
void gengas(Node *file, char *out);
void genp9(Node *file, char *out);
Blob *tydescblob(Type *t);
+size_t blobsz(Blob *b);
/* location generation */
extern size_t maxregid;
diff --git a/6/gengas.c b/6/gengas.c
index 34f7991..3c5cd1c 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -542,7 +542,7 @@ static void gentyblob(FILE *fd, Blob *b)
encodemin(fd, b->ival);
break;
case Btref:
- fprintf(fd, "\t.quad %s\n", b->ref);
+ fprintf(fd, "\t.quad %s\n", b->ref.str);
break;
case Btbytes:
writebytes(fd, b->bytes.buf, b->bytes.len);
diff --git a/6/genp9.c b/6/genp9.c
index e1be10e..5a9a84d 100644
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -500,7 +500,7 @@ static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
static size_t encodemin(FILE *fd, uint64_t val, size_t off, char *lbl)
{
- size_t i, shift;
+ size_t i, shift, n;
uint8_t b;
if (val < 128) {
@@ -512,13 +512,15 @@ static size_t encodemin(FILE *fd, uint64_t val, size_t off, char *lbl)
if (val < 1ULL << (7*i))
break;
+ n = 0;
shift = 8 - i;
b = ~0 << (shift + 1);
b |= val & ((1 << (8 - shift)) - 1);
fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off, b);
val >>= shift;
while (val != 0) {
- fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off, (uint)val & 0xff);
+ n++;
+ fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off+n, (uint)val & 0xff);
val >>= 8;
}
return i;
@@ -533,34 +535,37 @@ static size_t gentyblob(FILE *fd, Blob *b, size_t off, char *lbl)
return 0;
switch (b->type) {
case Bti8:
- fprintf(fd, "\tDATA %s+%zd(SB)/1,$%zd\n", lbl, off, b->ival);
+ fprintf(fd, "DATA %s+%zd(SB)/1,$%zd\n", lbl, off+n, b->ival);
n += 1;
break;
case Bti16:
- fprintf(fd, "\tDATA %s+%zd(SB)/2,$%zd\n", lbl, off, b->ival);
+ fprintf(fd, "DATA %s+%zd(SB)/2,$%zd\n", lbl, off+n, b->ival);
n += 2;
break;
case Bti32:
- fprintf(fd, "\tDATA %s+%zd(SB)/4,$%zd\n", lbl, off, b->ival);
+ fprintf(fd, "DATA %s+%zd(SB)/4,$%zd\n", lbl, off+n, b->ival);
n += 4;
break;
case Bti64:
- fprintf(fd, "\tDATA %s+%zd(SB)/8,%zd\n", lbl, off, b->ival);
+ fprintf(fd, "DATA %s+%zd(SB)/8,%zd\n", lbl, off+n, b->ival);
n += 8;
break;
case Btimin:
- n += encodemin(fd, b->ival, off, lbl);
+ n += encodemin(fd, b->ival, off+n, lbl);
break;
case Btref:
- fprintf(fd, "\tDATA %s+%zd/8,$%s\n", lbl, off, b->ref);
+ if (b->ref.isextern)
+ fprintf(fd, "DATA %s+%zd(SB)/8,$%s<>+0(SB)\n", lbl, off+n, b->ref.str);
+ else
+ fprintf(fd, "DATA %s+%zd(SB)/8,$%s+0(SB)\n", lbl, off+n, b->ref.str);
n += 8;
break;
case Btbytes:
- n += writebytes(fd, lbl, off, b->bytes.buf, b->bytes.len);
+ n += writebytes(fd, lbl, off+n, b->bytes.buf, b->bytes.len);
break;
case Btseq:
for (i = 0; i < b->seq.nsub; i++)
- n += gentyblob(fd, b->seq.sub[i], off, lbl);
+ n += gentyblob(fd, b->seq.sub[i], off+n, lbl);
break;
}
return n;
@@ -574,11 +579,14 @@ static void gentype(FILE *fd, Type *ty)
if (ty->type == Tyvar)
return;
b = tydescblob(ty);
- if (b->lbl) {
- if (b->isglobl)
- snprintf(lbl, sizeof lbl, "DATA %s%s\n", Symprefix, lbl);
- else
- snprintf(lbl, sizeof lbl, "DATA %s%s<>+SB\n", Symprefix, lbl);
+ if (!b)
+ return;
+ if (b->isglobl) {
+ fprintf(fd, "GLOBL %s%s+0(SB),$%zd\n", Symprefix, b->lbl, blobsz(b));
+ snprintf(lbl, sizeof lbl, "%s%s", Symprefix, b->lbl);
+ } else {
+ fprintf(fd, "GLOBL %s%s<>+0(SB),$%zd\n", Symprefix, b->lbl, blobsz(b));
+ snprintf(lbl, sizeof lbl, "%s%s<>", Symprefix, b->lbl);
}
gentyblob(fd, b, 0, lbl);
}
diff --git a/6/typeinfo.c b/6/typeinfo.c
index dcb023d..0b94eda 100644
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -51,17 +51,18 @@ static Blob *mkblobseq(Blob **sub, size_t nsub)
return b;
}
-static Blob *mkblobref(char *lbl)
+static Blob *mkblobref(char *lbl, int isextern)
{
Blob *b;
b = zalloc(sizeof(Blob));
b->type = Btref;
- b->ref = strdup(lbl);
+ b->ref.str = strdup(lbl);
+ b->ref.isextern = isextern;
return b;
}
-static size_t blobsz(Blob *b)
+size_t blobsz(Blob *b)
{
size_t n;
size_t i;
@@ -91,6 +92,7 @@ static size_t blobsz(Blob *b)
default:
die("unknown blob type");
}
+ return 0;
}
void namevec(Blob ***sub, size_t *nsub, Node *n)
@@ -218,7 +220,7 @@ Blob *tydescsub(Type *ty)
case Tyname:
i = snprintf(buf, sizeof buf, "%s", Symprefix);
tydescid(buf + i, sizeof buf - i, ty);
- lappend(&sub, &nsub, mkblobref(buf));
+ lappend(&sub, &nsub, mkblobref(buf, ty->isimport));
break;
}
b = mkblobseq(sub, nsub);
diff --git a/doc/mkfile b/doc/mkfile
index d60b828..3a6dd18 100644
--- a/doc/mkfile
+++ b/doc/mkfile
@@ -1,7 +1,6 @@
MANS=\
mc.1 \
muse.1 \
- myrbuild.1 \
all:V: $MANS
diff --git a/mk/bootstrap/bootstrap+Plan9-amd64.sh b/mk/bootstrap/bootstrap+Plan9-amd64.sh
index 05fc368..d89a852 100755
--- a/mk/bootstrap/bootstrap+Plan9-amd64.sh
+++ b/mk/bootstrap/bootstrap+Plan9-amd64.sh
@@ -24,10 +24,10 @@ echo ../6/6.out -I . utf.myr ; ../6/6.out -I . utf.myr
echo ../6/6.out -I . `$pwd/sysselect.sh errno`; ../6/6.out -I . `$pwd/sysselect.sh errno`
echo ../6/6.out -I . cstrconv.myr ; ../6/6.out -I . cstrconv.myr
echo ../6/6.out -I . `$pwd/sysselect.sh syswrap-ss`; ../6/6.out -I . `$pwd/sysselect.sh syswrap-ss`
+echo ../6/6.out -I . introspect.myr ; ../6/6.out -I . introspect.myr
echo ../6/6.out -I . varargs.myr ; ../6/6.out -I . varargs.myr
echo ../6/6.out -I . chartype.myr ; ../6/6.out -I . chartype.myr
echo ../6/6.out -I . cmp.myr ; ../6/6.out -I . cmp.myr
-echo ../6/6.out -I . hasprefix.myr ; ../6/6.out -I . hasprefix.myr
echo ../6/6.out -I . slcp.myr ; ../6/6.out -I . slcp.myr
echo ../6/6.out -I . sldup.myr ; ../6/6.out -I . sldup.myr
echo ../6/6.out -I . slpush.myr ; ../6/6.out -I . slpush.myr
@@ -70,8 +70,8 @@ echo ../6/6.out -I . getcwd.myr ; ../6/6.out -I . getcwd.myr
echo ../6/6.out -I . swap.myr ; ../6/6.out -I . swap.myr
echo ../6/6.out -I . bitset.myr ; ../6/6.out -I . bitset.myr
echo ../6/6.out -I . `$pwd/sysselect.sh dial`; ../6/6.out -I . `$pwd/sysselect.sh dial`
-echo ../muse/6.out -o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use ; ../muse/6.out -o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use
-echo ar vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 ; ar vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6
+echo ../muse/6.out -o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use ; ../muse/6.out -o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use introspect.use
+echo ar vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 ; ar vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 introspect.6
echo cd $pwd; cd $pwd
echo cd $pwd/libbio; cd $pwd/libbio
echo ../6/6.out -I ../libstd bio.myr ; ../6/6.out -I ../libstd bio.myr