From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Thu, 22 Aug 2013 12:54:11 -0400 To: 9fans@9fans.net Message-ID: <28376249a60c1da8f7f8956eb942eb02@brasstown.quanstro.net> In-Reply-To: <20130822153243.A567AB827@mail.bitblocks.com> References: <2332222c9f75f30c6395f16787280535@brasstown.quanstro.net> <20130821184909.51FA2B827@mail.bitblocks.com> <0A2E2FB2-B2F1-444E-AF62-85FAC05335EA@bitblocks.com> <1c77ed407dc1ed28544e2033df7088ce@brasstown.quanstro.net> <20130822153243.A567AB827@mail.bitblocks.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] more on why vc can't produce amd64 executables Topicbox-Message-UUID: 7408d176-ead8-11e9-9d60-3106f5b1d025 > > 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