Guidance regarding a dummy project

Dear,

I am looking to build a compiler-assembler with a custom architecture.

I have a new Instruction set defined with me and I would like atleast my C programs to get converted to assembly language corresponding to the custom architecture.

I have been going through llvm and its resources on the web, Can any one of you offer guidance about the above problem.

All I want is to develop a tool which can take in a custom architecture and assemble all programs corresponding to the architecture.

Regards,

Pratik

Dear Pratik,

What I think you will want to do is to create a new assembler and a new code generator for your architecture. This, I suspect, means that you'll need to understand how to describe your architecture's instruction set using TableGen, how to create an assembler using the MC interface, and how to build a code generator.

My best suggestion is to start looking at the documentation "Writing an LLVM Backend" and "The LLVM Target-Dependent Code Generator" at http://llvm.org/docs. The "Tablegen" document may also help. The links for these documents are at:

http://llvm.org/docs/WritingAnLLVMBackend.html
http://llvm.org/docs/CodeGenerator.html
http://llvm.org/docs/TableGen/index.html

As I have not written a new code generator from scratch myself, that's about all the help I can offer. I suggest reading these documents (if you have not already) and then write the list with more specific questions as needed.

Good luck,

John Criswell

The documents John mentions are highly useful. I’m actually doing this - and find the source in various other architecture subtrees to be invaluable - lib/Target/. Our machine is a 64-bit RISC machine, so reading the PPC/Mips/Sparc code is useful. For some instructions, ARM has been useful (pre/post increment/decrement).

If this is a commercial effort, Synopsys makes a tool called Processor Designer which can take you quite a ways to doing this.

Best of Luck,

Richard Gorton