<div dir="ltr">Hey Can you refer me to some documentation on manually creating a backend without codegen?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 5, 2017 at 3:08 PM, Matthias Braun <span dir="ltr"><<a href="mailto:mbraun@apple.com" target="_blank">mbraun@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Jun 1, 2017, at 8:13 PM, Sreejita saha via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_3356889247725521825Apple-interchange-newline"><div><div class="m_3356889247725521825WordSection1" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Hello everyone,</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">I was trying to create an LLVM backend for a processor with a very simple architecture and that does all instructions like load, store, arithmetic and logical instructions using a bunch of majority functions. The processor has only one instruction(majority function) in its ISA and breaks down all other instructions into a number of majority instructions depending on what instruction it is. All the instructions have different combinations of majority operations. Is there any way to implement this without creating a new Selection DAG node for the majority operation?</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">I was thinking of creation of a new Selection DAG node and mapping all the other instructions like loads, stores as pseudo instructions and breaking them up. Can someone please help me with this?</div></div></div></blockquote><div><br></div></span><div>If your architecture is alien enough (and so far this sounds pretty alien to me) it may make sense to just create a custom backend that goes from the IR representation to whatever machine format/assembly you are using.</div><div>While CodeGen gives you a lot of infrastructure that fits "normal" CPUs well (ABI lowering, instruction selection, register allocation, scheduling, object file formats, debug info). On the other hand if your target is a hypothetical CPU (just making guesses from what little you wrote) you may not need all that:</div><div>- Register allocation usually only makes sense if you have a bounded number of registers or special constraints.</div><div>- Scheduling usually only makes sense if you have a machine model with different latencies or want to optimize register pressure to minimize spill reloads (for bounded number of regs).</div><div>- If your object file format isn't ELF/macho/coff then you won't gain much from the MC infrastructure and debug generation infrastructure.</div><div><br></div><div>If you don't need most of these things then you are probably better off manually implementing a TargetMachine without using CodeGen (instead of implementing an LLVMTargetMachine with all the CodeGen utilities).</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Matthias</div></font></span></div></div></blockquote></div><br></div>