[Simh] O2 optimization on Linux

Jason Stevens neozeed at gmail.com
Mon Jan 3 14:52:50 EST 2011


Hmmm interesting....

I found that these macros compile though...

#define ML_PXBR_TEST(r) if (((((uint32)r) & 0x80000000u) == 0) || \
                            (((uint32)r) & 0x40000003u)!=0) RSVD_OPND_FAULT
#define ML_SBR_TEST(r)  if (((uint32)(r) & 0x00000003u)!=0) RSVD_OPND_FAULT


it's too many ('s for me to even begin to work out....

Anyways what's funny on OS X is that gcc version 4.2.1 (Apple Inc.
build 5664) for the i386, x86_64 and PowerPC all fail with the
original macros.... while gcc version 4.0.1 (Apple Inc. build 5494)
works with the originals...........

And on my Sony Playstation 3 with gcc version 4.1.1 20070105 (Red Hat
4.1.1-52.ydl.1) it again fails with the original macros, and works
with the new ones....



On Mon, Jan 3, 2011 at 12:47 PM, Bob Supnik <bob at supnik.org> wrote:
> Well, the 780 microcode is complicated and patched to fare-thee-well, but it
> uses absolutely common code for the tests on P0BR and P1BR.  [The PDFs are
> on line at Bitsaver.]  Based on the comments, the actual tests are:
>
> 1) Offset P1BR by 0x800000 (2**23).
> 2) Test PxBR<1:0> = 0.
> 3) Test PxBR<31> = 1.
> 4) Test PxBR<30> = 0.  [this is missing in SimH]
>
> For SBR, it's:
>
> 1) Test SBR<1:0> = 0.
> 2) Test SBR<31:30> = 0. [this is missing in SimH]
>
> So while SimH may not be SRM conformant, it follows the 780 microcode more
> or less faithfully; in particular, by using a common macro for testing P0BR
> and P1BR.  Remember, SimH is a hardware simulator, not an architectural
> simulator.
>
> So I would venture that the "right" formulation of these tests is:
>
> #define ML_SBR_TEST(r)  if ((r) & 0xC000003) RSVD_OPND_FAULT
> #define ML_PXBR_TEST(r) if ((((r) & 0x80000000) == 0) || \
>                            ((r) & 0x40000003)) RSVD_OPND_FAULT
>
> Of course, you can throw in whatever casts, etc, you want to add to make the
> code 64b proof; and also the != 0 that good C coding seems to imply these
> days:
>
> #define ML_SBR_TEST(r) if (((uint32)(r)) & 0xC000003u) != 0) RSVD_OPND_FAULT
> #define ML_PXBR_TEST(r) if (((((uint32)(r)) & 0x80000000u) == 0) || \
>                            (((uint32)(r)) & 0x40000003u) != 0))
> RSVD_OPND_FAULT
>
> The ANSI C standard says that hex constants are unsigned by default, so I
> really don't think all the u's are needed.
>
> Remember, the problem is unique to one version of the C compiler, with
> CentOS 5.5.  It works everywhere else.
>
> /Bob
> _______________________________________________
> Simh mailing list
> Simh at trailing-edge.com
> http://mailman.trailing-edge.com/mailman/listinfo/simh
>



More information about the Simh mailing list