I'm developing a very basic new LLVM backend for a RISC machine (named Risco), based on the existing Sparc backend and this tutorial. To register the backend, I've used the following.
At RiscoTargetMachine.cpp:
extern "C" void LLVMInitializeRiscoTarget() { // Register the target. RegisterTargetMachine<RiscoSimulatorTargetMachine> X(TheRiscoTarget); RegisterAsmInfo<RiscoMCAsmInfo> Y(TheRiscoTarget); }
At Risco.td:
def : Processor<"simulator", NoItineraries, [FeatureA]>; def Risco : Target { // Pull in Instruction Info: let InstructionSet = RiscoInstrInfo; }
At TargetInfo/RiscoTargetInfo.cpp:
Target llvm::TheRiscoTarget; extern "C" void LLVMInitializeRiscoTargetInfo() { RegisterTarget<> X(TheRiscoTarget, "risco", "Risco"); }
At the top level LLVM configure script:
# Added Risco to the TARGETS_TO_BUILD variable at line 4965 (from svn trunk): all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze PTX Risco" ;;
After build, llc -version
doesn't show the new target. Even llc -march=risco test.ll
says it's an invalid target. What am I missing?
PS: Currently, I'm including the new target as a folder inside llvm/lib/Target. How can I change that so I can build the target separately, and load it dynamic with llc -load
?