[LLVMdev] How to register a new LLVM backend

Giuliano Vilela giulianoxt at gmail.com
Wed Oct 13 12:57:14 PDT 2010


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101013/7e81f8c1/attachment.html>


More information about the llvm-dev mailing list