[LLVMdev] How to register a new LLVM backend

John Myers atomicdog.jwm at gmail.com
Wed Oct 13 13:40:16 PDT 2010


Hi,

I think you need to modify these files, at a minimum, for it to build and
register the target.

* /configure
/lib/Support/Triple.cpp
/include/llvm/ADT/Triple.h*


--John

On Wed, Oct 13, 2010 at 12:57 PM, Giuliano Vilela <giulianoxt at gmail.com>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/85eeaebb/attachment.html>


More information about the llvm-dev mailing list