[MLton] [iI]sBigEndian necessary?

Wesley W. Terpstra terpstra@gkec.tu-darmstadt.de
Mon, 13 Dec 2004 18:25:01 +0100

On Fri, Dec 10, 2004 at 06:27:53PM -0800, Stephen Weeks wrote:
> Using a platform-independent IL (like RSSA and Machine) that expresses
> platform-dependent programs means that we can share as much code as
> possible among all codegens while taking advantage of
> platform-dependent knowledge in a single IL.

Ok, so we need to know alignment and endian during MLton compilation.

Where I'm stuck is filling in the isBigEndian function.
My concern is that right now it looks like this:

         val isBigEndian =
           case host of
              Alpha => false  (* either, but little on linux *)
            | AMD64 => false  (* always little *)
            | ARM => true     (* either, but usually big *)
            | HPPA => true    (* either, but big on linux *)
            | IA64 => false   (* always little *)
            | m68k => true    (* either, but big on linux *)
            | MIPS => ?!?     (* either, even in linux *)
            | PowerPC => true (* either, but big for linux *)
            | S390 => true    (* either, but big for linux *)
            | Sparc => true   (* always big *)
            | X86 => false    (* always little *)

You will notice that most of the RISC processors support both little and big
endian formats. Generally, linux picked one of these formats, but other OSes
might have made a different choice. Under linux MIPS could be either.

What I think makes the most sense is to make isBigEndian a _constant. It's
easy to detect endian in the C program which generates the constants file.
That way, you can have a target mipsel-linux and mipseb-linux which differ
simply in the gcc settings (for endian) and the constants file which lists
on or the other.

What do you think?

I also think it makes sense to use C to grab the preferred alignment for
every fundamental type and throw that into the constants file too.

Wesley W. Terpstra