Gerald E Butler wrote:
    I've been investigating the possibility of creating a MACHINE
DESCRIPTION (aka BACK-END) for GCC to target PARROT. My thinking is
this: If a satisfactory GCC back-end targeting PARROT is created -and-
PARROT is efficient enough (which from reading the documentation thus
far produced seems like it is an inevitable conclusion) then GCC could
compile itself to PARROT byte-code giving PARROT (and the whole open
source community) a PARROT self-host compiler which compiles multiple
languages (C#, C++, C, Pascal, Objective-C, Java, etc, etc, etc) to the
PARROT runtime.

At first glance, this looks like a good thing to do. After all, Parrot was made a register machine, instead of a stack machine, to be able to leverage the existing art with reference to real machines, which are register machines, not stack machines.


So what's the problem?

In a word: Memory. GCC expects the machine to be more or less like a real machine. This means, in no small part, that it has a large amount of memory, accessible by getting a pointer to it, which is an integer. Now, it would be possible to emulate that with an appropriately-crafted PMC.

So is it possible, after you write that PMC?

Well... in theory, if you do this, you can write a gcc backend targeting parrot. It shouldn't even be /that/ difficult. (More difficult then porting gcc to a more traditional arch, less difficult then writing your own C, etc, compiler.)

Unfortunately, since you've created that "memory" PMC, and stuffed much of your data in it, you no longer have assembler that resembles, even vaguely, that of the rest of the parrot world. Heck, most languages will end up putting most user-visible things in PMC registers, and you'll only ever use one. You'll never use string registers. You've got an implicit PMC argument to every function, and one that probably wants highlander (singleton) semantics as well.

You can write C, C#, C++, Pascal, Objective-C, Java, etc, but it won't interoperlate with other Parrot code well (without stubs), if at all (the stubs may be quite difficult).

Is it worthwhile anyway?

Quite possibly.

Is it easy?

No.

Will it do everything you want it to do?

No.

-=- James Mastros

Reply via email to