Hi,<br><br>I think you need to modify these files, at a minimum, for it to build and register the target.<br><br><i> /configure<br>/lib/Support/Triple.cpp<br>/include/llvm/ADT/Triple.h</i><br><br><br>--John <br><br><div class="gmail_quote">
On Wed, Oct 13, 2010 at 12:57 PM, Giuliano Vilela <span dir="ltr"><<a href="mailto:giulianoxt@gmail.com">giulianoxt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<div><br></div><div>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.</div>


<div><br></div><div>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).</div>


<div><br></div><div>The main steps I did for registering the backend were:</div><div><br></div><div>- At RiscoTargetMachine.cpp:</div><div><br></div><div><div>extern "C" void LLVMInitializeRiscoTarget() {</div>

<div>
  // Register the target.</div><div>  RegisterTargetMachine<RiscoTargetMachine> X(TheRiscoTarget);</div><div>  RegisterAsmInfo<RiscoMCAsmInfo> A(TheRiscoTarget);</div><div>}</div></div><div><br></div><div>- At Risco.td:</div>


<div><br></div><div><div>def Risco : Target {</div><div>  let InstructionSet = RiscoInstrInfo;</div><div>}</div></div><div><br></div><div>- At RiscoTargetInfo.cpp:</div><div><br></div><div>Target llvm::TheRiscoTarget;</div>


<div><br></div><div>extern "C" void LLVMInitializeRiscoTargetInfo() {</div><div>  RegisterTarget<> X(TheRiscoTarget, "risco", "Risco");</div><div>}</div><div><br></div><div><br></div><div>


<br></div><div>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?</div>


<div><br></div><div>Is this the problem or am I missing something else?</div><div><br></div><div><br></div><div>[1] <a href="http://llvm.org/docs/WritingAnLLVMBackend.html" target="_blank">http://llvm.org/docs/WritingAnLLVMBackend.html</a><br clear="all">


<br>-- <br>[]'s<br><br>Giuliano Vilela.<div><div><div><br></div></div></div><br>
</div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br>