Kay Roepke
2006-Nov-15 18:36 UTC
[LLVMdev] Targetting a virtual machine having no registers
Hi *! I am writing a C compiler to target the Lego Mindstorms NXT virtual machine. While I was implementing the optimizer and code generator I realized that it might be useful to use LLVM for this. 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: 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. Thanks in advance for your advice! cheers, -k -- Kay Röpke http://classdump.org/
Chris Lattner
2006-Nov-17 05:39 UTC
[LLVMdev] Targetting a virtual machine having no registers
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/
Kay Roepke
2006-Nov-17 07:23 UTC
[LLVMdev] Targetting a virtual machine having no registers
On 17. Nov 2006, at 6:39 , Chris Lattner wrote:> 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.Thanks for the reply, Chris! That was more or less the impression I got from reading the TableGen interfaces. I'll go that route then! cheers, -k -- Kay Röpke http://classdump.org/