Porting Clang to a new architecture

Great.

BTW, cfe-dev is the right mailing list for this conversation, not cfe-commits.

So this is what I wanted to know. I think understand what you are saying. You are saying that most of the work that I would need to do from the AST (I’m assuming that this stands from Abstract Syntax Tree) is allready being done by LLVM and I should look to modify for a my new arquitecture. Right?

The AST to IR conversion is the job of the frontend, and is already done by clang. You would need to add a new architecture backend to LLVM. If you have a different ABI, that will need to go into clang (depending on the differences).

If I take the AST and process it myself to generate the opcodes, I’m essentially writing LLVM just less efficient (no optimizations) and specific for the new architecure, right?

If you do that, you are going to rewrite part of clang. There are a lot of corner cases when it comes to handling ABI, and those issues are hard to diagnose and time consuming to fix.

If you intend to write the backend outside of LLVM, it would be easier to write something to go from LLVM IR to your custom representation. As you pointed out already, doing so means you lose out on all the optimizations and it would be specific to your target architecture.