[LLVMdev] MOS6502 target

David Chisnall David.Chisnall at cl.cam.ac.uk
Thu Jul 3 02:23:09 PDT 2014


I'd not seen that tutorial, but it looks very nice.  One other piece of advice I'd give:

Get the assembler working first.  Go through your instruction reference, define each instruction's encoding, add the relevant bits to the AsmParser (typically not much, unless you have some weird encodings), and test the assembler with llvm-mc and its show-encodings feature before you try to connect up code generation.  And write lots of tests while you're doing this!

It makes it easy to see if you've got sensible patterns, when every instruction is in the .td files and you can easily find the ones that aren't used (is it because there's a more sensible way of expressing what they can do, because they do something that isn't easily expressed in LLVM IR, or because you made a mistake?).  It's a lot easier to track down bugs in instruction encodings when you've got a decent set of assembly tests for them than when you're staring at compiler output.  Common errors include not realising immediates are sign / zero extended or shifted.

David

On 3 Jul 2014, at 09:57, Roel Jordans <r.jordans at tue.nl> wrote:

> Hi,
> 
> I found the tutorial presented at last LLVM conference very helpful when starting on my own backend.  Especially with the GitHub repository containing a template backend that was quite easy to rename and extend.
> 
> Here's the slides with a pointer to the repository:
> 
> http://llvm.org/devmtg/2014-04/PDFs/Talks/Building%20an%20LLVM%20backend.pdf
> 
> Cheers,
> Roel
> 
> On 03/07/14 03:23, Edwin Amsler wrote:
>> Hey there!
>> 
>> I've started to embark on a path to try and create a backend for a 39 year old CPU with only an accumulator, two index registers, and a 256 byte stack. It does have a bank of 256 bytes before the stack that are pretty quick though.
>> 
>> Really, if I can get an assembler out of `llc`, that'll be success enough for me. Clang would be better, but I think that might be crazy talk.
>> 
>> I've been doing lots of research so far, but from the experts, how feasible does this sound?
>> 
>> I've also been banging my head against the wall trying to figure out what all the classes for different instruction types do. Is there a nicely documented index? Is it in source somewhere, or should I start one?
>> 
>> Thanks,
>> 
>> Edwin
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list