Top-down ISA evolution

The design process of an Instruction Set Architecture (ISA) has always struck me as being backwards. I imagine that they are mostly designed by hardware engineers whose decisions are largely influenced by the medium in which they work - hardware description languages. Every decision is influenced to some degree by implementation difficulty or limitations of the hardware.

Only the lucky compiler developers have a chance to review an ISA before it is fixed in stone. The few times I've seen this happen it has always been to everyone's benefit. Perhaps there are instructions
that the compiler could never use, or perhaps the compiler would generate better code if only it had some overlooked addressing mode.

I've often wondered what would happen if we reversed this process. What would an ISA look like that was solely influenced by the needs of the compiler writer, without regard to the hardware side of the house? Instead of designing from the hardware up, start from the compiler and design top-down.

As an experiment, I've developed the start of a GNU tools port to a new architecture that was wholly undefined at the start of the project. There was no instruction set architecture definition, no register file definition, no defined ABI or OS interfaces. Instead, I defined these things on the fly, letting things evolve naturally based on the needs of the compiler. The C compiler, assembler, linker, binutils and simulator were developed concurrently. So, for instance, when the compiler required an "add" instruction, each tool would be taught about "add" and so on.

I'm going to blog a patch a day to show my progress. Each patch will be small and buildable. I hope to show that you can get from nothing to running real programs using this top-down ISA design method in a surprisingly short amount of time.

A couple of caveats first... I am not an experienced compiler writer. I've been involved in many new GNU ports over the years at Cygnus and Red Hat, but mostly in a bizdev capacity. I have a good idea how all the pieces go together, but this will be my first attempt at it and I'm certain to botch some things. Second, I'm by no means an expert in ISA design. I'm taking the lazy man's route to ISA design:

1. Try to build something with gcc
2. See what the compiler is complaining about
3. Implement it
4. Go to 1.

Every design decision is driven by whatever is easiest to implement. What I expect I'll end up with is a simple although wildly inefficient architecture. Then perhaps we can optimize this toy ISA based on real-world code generation. At the end of the day, however, my goal is for this to be a fun and interesting experiment.

I'll post my first patch later today.

Trackbacks

    No Trackbacks

Comments

Display comments as (Linear | Threaded)

  1. gbenson says:

    Cool!

  2. JIm says:

    I was a contractor for IBM when they first introduced the Power architecture. The original design of that instruction set was highly influenced by the compiler writers. This was in the early 90's. Since then it has had all kinds of things added to meet real-world needs, for example, precise floating point exceptions - precise meaning that when the exception occurs, software can tell exactly which instruction caused the trap. Without precise exceptions, it wasn't possible to port certain Fortran programs from other systems to the Power architecture.

    You might want to read about the history of the Power architecture. It would probably give you some additional insight as to issues they faced.

    Good luck!

  3. Anthony Green says:

    Thanks Jim. I think I have the PowerPC Compiler Writer's Guide somewhere around here. I had never seen anything like that before. I had forgotten about it and will try to dig it up again.

  4. Alex says:

    But C is a language that is close to the hardware. The extension then seems to be what language would you create (or pick from the current plethora) that is most easy to write code in. From there say what is the most efficient underpinnings to run it on and then build the instruction set and hardware.

  5. Seg says:

    Hmmm you have a point. C was designed with hardware in mind in the first place. Python is in vogue these days, I wonder what a "Python Machine" would be like, in the vein of the LISP machines of old. I suppose it would look a lot like Python bytecode...

  6. Mikael says:

    Seems to me this has sort of already been done in bytecode languages, like Java or C#? Still an interesting thing to do for a more low-level language like C. C bytecode perhaps?


Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/lang] tags to embed source code snippets
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

 
Submitted comments will be subject to moderation before being displayed.