For Programmers: Free Programming Magazines  


Home > Archive > Scheme > April 2005 > A more assembly-like usage of C as a compilation target language?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author A more assembly-like usage of C as a compilation target language?
Sunnan

2005-04-22, 3:58 am

Is there any advantage in using large amounts of gotos and similar
things to use C only as a cross-platform assembly, compared to using C
constructs like, say, Chicken does?

(One divantage I can think of is that it could make FFIs harder.)
Ulrich Hobelmann

2005-04-22, 3:58 am

Sunnan wrote:
> Is there any advantage in using large amounts of gotos and similar
> things to use C only as a cross-platform assembly, compared to using C
> constructs like, say, Chicken does?
>
> (One divantage I can think of is that it could make FFIs harder.)


Yes, you avoid the horrible calling conventions.

OTOH you have to compile everything into one function, which is
probably slow for GCC to process (with all those graph
algorithms). You lose separate compilation, and you can't call
individual functions from outside the big blob method.

For a while I though about this, but if I need to get real machine
code, I'd rather compile to assembler instead.

--
No man is good enough to govern another man without that other's
consent. -- Abraham Lincoln
Jonathan Bartlett

2005-04-22, 4:01 pm

I wonder if you could generate gcc's RTL and somehow convince GCC to
compile that?

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
Ulrich Hobelmann

2005-04-22, 4:01 pm

Jonathan Bartlett wrote:
> I wonder if you could generate gcc's RTL and somehow convince GCC to
> compile that?


It would certainly be great if you could define your own calling
conventions and otherwise use GCC's backend for optimizing,
scheduling and register allocation. However, there doesn't seem
to be lots of docs available, so I think it's easier
(unfortunately, as with many badly docced open-source projects) to
just roll your own simple backend. If you don't use C's calling
conventions it might even be *faster* for well-structured code
using many functions (ok, then maybe inlining would be a good
thing to add, too...).

--
No man is good enough to govern another man without that other's
consent. -- Abraham Lincoln
Sunnan

2005-04-22, 8:58 pm

Marcin 'Qrczak' Kowalczyk wrote:
> Jonathan Bartlett <johnnyb@eskimo.com> writes:
>
>
>
>
> I guess it would be painful to port to various GCC versions as the RTL
> is evolving.
>


How about a very thin frontend? It should map pretty closely to rtl, but
still be sexp.
I think I read of such a work in progress, once. Wonder what happened
with it.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com