Jeremy Jackson jerj@coplanar.net writes:
On Tue, 2003-02-25 at 13:09, Steve Gehlbach wrote:
I think you have to cramp your C coding style anyway, to stay within registers. The extra scratch area does not help much, with chips such
A compiler *made* to compile this way could help a great deal by scheduling instructions like an RPN calculator though, so *you* don't have to write in spaghetti code.
So far I like the extern inline aspect in that it makes a good proof of concept that this code can be written in C, and that it is not so outrageous to expect a compiler to do it.
Steve for a feel of my worries try compiling that code with gcc-3.3. If what I saw earlier today is right it won't work because someone has decided that aggressive inlining is bad thing...
BUT, would C's block-scope local variables allow registers to be re-used
by different local variables, so instead of
void func (void) { register int eax;
/* use i for one purpose */
/* use same i for something else */ }
you could do
void func (void) { { register int ramsize; /* use ramsize */ } { register int cpuid; /* use cpuid */ } }
and have both end up using the same register, kind of like a union, but still looking more like C than assembler.
Yes. That is basic live variable analysis. In general a value not a variable gets assigned to a register.
The rule is that if a variable is assigned a new value before the old value is used again. The variable can be dropped in the intervening space, and afterwards a new register can be assigned.
It can go as far as a new register assignment every time you change the value of a variable.
as the SiS630, only has three gp regs, little help. You can't go around declaring variables willy nilly, you run out of space (registers) no matter what compiler.
But for the cases where (in the chipset or whereever) there are scratch registers, global extern static variables that are fixed when linking, (or define them in an assembler stub with .org or such) would allow them to be used easily from C.
That definitely requires some thinking. When it requires extra registers to spill a register it can be hard for a compiler. I am going to start with the spill free case...
So far it is about 400 lines of C, should I attach it? It compiles without using the stack (except for a %ebp push/pop which can be deleted).
Please do. It would be a good example of how complex the code can be with the register/inline constraints.
It has already shown up on the list but watch out for the inline part that says it is a pixmap when it should be text plain.
Eric