Use Global ISel or SelectionDAG

Hi llvm-dev,

I am currently writing a backend for an architecture I am designing in my bachelor’s thesis and recently came across the GlobalISel Selection Framework.
Should already start using this over the more common Selection DAG?
Being new llvm backend development, I am not sure if GlobalISel would be “easier” to implement than ISelDAG and if there is any decent documentation on how to do so.

Cheers,
Floris

Hi Floris,

For a bachelor thesis I would probably recommend going with the safest choice of SelectionDAG. When I started doing LLVM development I was surprised by how common it is to have to solve LLVM issues that other architectures didn’t happen to run into, despite me working on a very conventional target arch (RISC-V). You don’t want to spend all your time budget on incidental problems that aren’t core to your thesis. That said, GlobalISel is cool, so if you can make it work for you… ¯_(ツ)_/¯

Alex Bradbury did some great work on creating a series of patches that show how to create the RISC-V target in a piecemeal and systematic way, so you might want to check that out:

https://github.com/lowRISC/riscv-llvm
https://github.com/lowRISC/riscv-llvm/tree/master/docs

Cheers,
Luis

I think it depends on how much you care about optimization, how weird your target is, and how long you plan to maintain it. If you don’t care about optimization, and have a very strange target, you would probably be better off with GlobalISel. There will be fewer examples to work with however.

-Matt

Hi matt,
Thanks for your advice, ill stick to SelectionDAG then, since my target isn’t that strange and I’ll have more examples to look at.

Cheers,
Floris

Another thing to consider is that GlobalISel will report an error if your target is big-endian.