From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] more on why vc can't produce amd64 executables
Date: Thu, 22 Aug 2013 12:54:11 -0400 [thread overview]
Message-ID: <28376249a60c1da8f7f8956eb942eb02@brasstown.quanstro.net> (raw)
In-Reply-To: <20130822153243.A567AB827@mail.bitblocks.com>
> > i think a bug is setting inuxi8[i+4] = inuxi8[i] for 0<=i<4.
> > mikro; diffy -c *.c
> > diff -c /n/dump/2013/0821/sys/src/cmd/6l/obj.c obj.c
> > /n/dump/2013/0821/sys/src/cmd/6l/obj.c:1455,1471 - obj.c:1455,1471
> > int i, c;
> >
> > for(i=0; i<4; i++) {
> > - c = find1(0x04030201L, i+1);
> > + c = find1(0x0807060504030201ULL, i+1);
>
> Why not
> for(i=0; i<8; i++) {
> Else what is the point of
> c = find1(0x0807060504030201ULL, i+1);
> Just eyeballing. I haven't looked at the actual code.
as it turns out, floating point is already swapped by Ieee, and
anything less than or equal to 4 bytes is cast uprated to a ulong,
not a uvlong.
this version produces the same output with -a as on amd64.
i think it's a little more clear to straightforwardly set up the nuxi,
and special case the word-swapping in the floating point.
ideally, the low and high words would be merged to a vlong.
this fix likely won't survive its encounter with review intact, but
at least for now i can compile amd64 binaries on mips.
once a final form is in place a fix should be applied to all
compilers.
- erik
----
/n/atom/plan9/sys/src/cmd/6l/obj.c:1449,1472 - obj.c:1449,1482
}
}
+ static uvlong lorder = 0x0706050403020100ull;
+
void
+ letab(uchar *t, int w, int n)
+ {
+ uchar *o;
+ uint i;
+
+ o = (uchar*)&lorder;
+ o += (o[0]!=0)*(8-w); /* if big endian, use tail not head */
+ for(i = 0; i < n; i++)
+ t[i] = o[i];
+ }
+
+ void
nuxiinit(void)
{
- int i, c;
+ int i;
- for(i=0; i<4; i++) {
- c = find1(0x04030201L, i+1);
- if(i < 2)
- inuxi2[i] = c;
- if(i < 1)
- inuxi1[i] = c;
- inuxi4[i] = c;
- inuxi8[i] = c;
- inuxi8[i+4] = c+4;
- fnuxi4[i] = c;
- fnuxi8[i] = c;
- fnuxi8[i+4] = c+4;
- }
+ letab(inuxi1, 4, 1); /* cast to 4 bytes, 1 byte tab */
+ letab(inuxi2, 4, 2);
+ letab(inuxi4, 4, 4);
+ letab(inuxi8, 8, 8);
+ letab(fnuxi4, 4, 4);
+ letab(fnuxi8, 4, 4); /* undo Ieee swapping. */
+ for(i = 4; i < 8; i++)
+ fnuxi8[i] = fnuxi8[i-4]+4;
+
if(debug['v']) {
Bprint(&bso, "inuxi = ");
for(i=0; i<1; i++)
/n/atom/plan9/sys/src/cmd/6l/obj.c:1489,1523 - obj.c:1499,1504
Bprint(&bso, "\n");
}
Bflush(&bso);
- }
-
- int
- find1(long l, int c)
- {
- char *p;
- int i;
-
- p = (char*)&l;
- for(i=0; i<4; i++)
- if(*p++ == c)
- return i;
- return 0;
- }
-
- int
- find2(long l, int c)
- {
- short *p;
- int i;
-
- p = (short*)&l;
- for(i=0; i<4; i+=2) {
- if(((*p >> 8) & 0xff) == c)
- return i;
- if((*p++ & 0xff) == c)
- return i+1;
- }
- return 0;
}
long
prev parent reply other threads:[~2013-08-22 16:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 18:36 erik quanstrom
2013-08-21 18:49 ` Bakul Shah
2013-08-21 18:57 ` erik quanstrom
2013-08-21 19:25 ` Bakul Shah
2013-08-21 19:29 ` erik quanstrom
2013-08-21 21:44 ` erik quanstrom
2013-08-22 15:32 ` Bakul Shah
2013-08-22 16:54 ` erik quanstrom [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28376249a60c1da8f7f8956eb942eb02@brasstown.quanstro.net \
--to=quanstro@quanstro.net \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).