This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Porting GCC to a register-less, stack-less architecture

At 1:54 PM +0100 2/27/02, Alexandre Courbot wrote:

>Hello everybody,
>I'm currently trying to port GCC to a new Smartcard architecture that
>has been developped in my university labs. This architecture doesn't
>have any hardware register or any stack (all the operations are handled
>in memory), which raises a lot of questions about the porting.

	How are function calls handled?

	Is all program storage statically declared?

	Where are you planning on allocating compiler temporaries (e.g., if everything's a
	memory-memory operation, how do I compute

		a = (b + c - d*a);

	(You can't use 'a' as the target without great difficulty (you'll have to write an optimization pass....))
	Are you going to use static variables as temps?

>I've seen that many MD macros are dealing with hard registers. But I
>have nothing to fill them with. I had to define FIRST_PSEUDO_REGISTER to
>0, and of course some registers arrays (as reg_names) have a size of 0.
>Can I write a machine description for a register-less machine? Shall I
>emulate hard-registers and stack by using variables, which would result
>in an overhead? Do you guys have some general advices for porting GCC to
>such an architecture?

	I'd think about defining a minimal set of "dummy" registers - just to keep the
	compiler happy with the SP and FP. And so that you have SOMEWHERE to allocate
	compiler temporaries.   (or you could just reserve a small number of memory locations,
	call them "registers" and let the compiler do the "register allocation" for those locations
	to treat them as temporaries.)  Assuming you have enough memory registers, you'll never
	spill until you get to a complex program - and maybe your users won't write complex code :-)

	Then, assuming that I expect to never support function calls, I can map my "stack" onto a range of static
	variables when I emit the assembly language.  Anything that ends up "using" my pseudo registers in
	"funny ways" (like a _builtin_alloca_ would be defined with a DEFINE_INSN that prints an error message
	instead of emitting an instruction to the .s file...

>Also more generally, and as writing a MD for the first time is quite a
>hard sport, could someone point me to a very simple (simplistic?) MD
>example or template for GCC 3, if it exists? The ones that are provided
>with the sources are quite complex, and although the manual is very
>complete and helpfull in that respect, I'm rather the kind of guy who
>learn by example. I'd like to come as fast as possible with a very basic
>"working" compiler, so I can tune it step by step and experiment code

	Good strategy.  I'd pick a MD for a machine that you thoroughly understand, so you can see what it's
	doing and figure out if there's a correspondence to your architecture.  Off hand, I can't think of any
	machine that shares the characteristics of your architecture.


		    Quality Software Management
			(978)287-0435 Voice
			(978)808-6836 Cell
			(978)287-0436 Fax

	Software Process Improvement and Management Consulting
	     Language Design and Compiler Implementation

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]