[LLVMdev] How to register a new LLVM backend

Jim Grosbach grosbach at apple.com
Wed Oct 13 13:16:10 PDT 2010


Hi Giuliano,

Have you modified the configure script to know to enable the target? Look for the bit that handles "--enable-targets" and you'll see a list of the default targets (all of them) that are enabled in a build and a case statement that parses the options to "--enable-targets". Make sure your new target is added in both places.

include/llvm/ADT/Triple.h contains a enumeration for the targets. Make sure you've added "risco" there, too.

-Jim

On Oct 13, 2010, at 12:57 PM, Giuliano Vilela wrote:

> Hi,
> 
> I'm developing a very basic new LLVM backend for a RISC machine (named Risco), based on the existing Sparc and Mips backends and the main tutorial [1]. I'm having trouble registering the backend so the main tools can see it.
> 
> My project code is outside the source tree, and I've altered the Makefile to generate a shared library for the backend (libLLVMRiscoCodeGen.so). I've tried running: llc -load ./libLLVMRiscoCodeGen.so -march=risco, but the target isn't recognized (it doesn't even appear in the llc -version output).
> 
> The main steps I did for registering the backend were:
> 
> - At RiscoTargetMachine.cpp:
> 
> extern "C" void LLVMInitializeRiscoTarget() {
>   // Register the target.
>   RegisterTargetMachine<RiscoTargetMachine> X(TheRiscoTarget);
>   RegisterAsmInfo<RiscoMCAsmInfo> A(TheRiscoTarget);
> }
> 
> - At Risco.td:
> 
> def Risco : Target {
>   let InstructionSet = RiscoInstrInfo;
> }
> 
> - At RiscoTargetInfo.cpp:
> 
> Target llvm::TheRiscoTarget;
> 
> extern "C" void LLVMInitializeRiscoTargetInfo() {
>   RegisterTarget<> X(TheRiscoTarget, "risco", "Risco");
> }
> 
> 
> 
> What I found suspicious was that in the last file (RiscoTargetInfo.cpp), the original RegisterTarget template parameter was Triple::mips. I found it odd because, if I understood it right, this attaches backend information to a LLVM core file. What am I supposed to put there for a new backend? Do I leave the default parameter?
> 
> Is this the problem or am I missing something else?
> 
> 
> [1] http://llvm.org/docs/WritingAnLLVMBackend.html
> 
> -- 
> []'s
> 
> Giuliano Vilela.
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101013/6f012c8b/attachment.html>


More information about the llvm-dev mailing list