[LLVMdev] Targetting a virtual machine having no registers

Chris Lattner sabre at nondot.org
Thu Nov 16 21:39:59 PST 2006


On Wed, 15 Nov 2006, Kay Roepke wrote:
> I am writing a C compiler to target the Lego Mindstorms NXT virtual
> machine.

cool!

> While I was implementing the optimizer and code generator I
> realized that it might be useful to use LLVM for this.

Sure.

> The question I have is related to writing a LLVM target for this
> architecture. I have read most of the documentation available on the
> website and read through portions of the code (including some
> TableGen interfaces for the various targets existing) but I have one
> unanswered question:

Ok

> As I'm targetting a virtual machine that doesn't have any registers,
> only memory addresses and immediates, how would I reflect that in the
> code?
> Could I just specify that I don't have any registers and expect LLVM
> to be happy with that?
>
> Furthermore, I would only have global variables whose access I'd have
> to arbitrate through mutexes. I imagine I could leave out anything
> regarding stack frames as well (this seems to be internal to each
> target).
>
> The instruction set is very limited, and pretty high level, but I
> don't think that will be a problem at all.

If your instruction set doesn't use registers, you will have little use 
for the common code generator code.  It would probably be easier to define 
a completely custom target like the CBackend.  This gives you full control 
over everything.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list