[LLVMdev] Creating an LLVM backend for a very small stack machine

Eli Friedman eli.friedman at gmail.com
Sun Feb 22 16:06:06 PST 2009


On Sun, Feb 22, 2009 at 3:25 PM, Wesley J. Landaker <wjl at icecavern.net> wrote:
>  * Has anyone else out there targeted (or tried to target) a stack machine
> before? Was it successfull? What problems did you have?

Haven't done that, and I don't think there are any existing backends
like this.  It should be feasible, though; the backend code is pretty
flexible.

>  * What parts of the LLVM backend code generator infrastructure would be
> usable for targeting a stack machine? e.g. Is it even possible to use
> TableGen to target a stack machine?

You should be able to use existing LLVM backend code and TableGen at
least through instruction selection; I'm not sure whether you'll want
register allocation or not, but it should be easy to choose either
way.  The whole thing is quite flexible; see
LLVMTargetMachine::addCommonCodeGenPasses in
lib/CodeGen/LLVMTargetMachine.cpp for a high-level overview of how
CodeGen works.  It might also be useful to look at LLVM handles x87
floating-point; the relevant code is in
lib/Target/X86/X86FloatingPoint.cpp.

>  * When/where/how do things like big integer (iXXXXX), phi nodes, llvm.*
> instrincs get lowered; e.g. does my target have to do that, or is it done
> generically?

Aribitrary-width integers, vectors, llvm.*, etc. are lowered
generically by the Legalize infrastructure; the backend just has to
say what it can and can't support.  See
lib/Target/X86/X86ISelLowering.cpp for an example.  I don't know the
details of PHI nodes, but that's also taken care of by instruction
selection.

-Eli



More information about the llvm-dev mailing list