[PATCH] D135202: [IR] Add a target extension type to LLVM.

Joshua Cranmer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 14:15:50 PDT 2023


jcranmer-intel added a comment.

In D135202#4226539 <https://reviews.llvm.org/D135202#4226539>, @zixuan-wu wrote:

> @jcranmer-intel hi, have you considered how to design and implement target extension type in clang front-end?

I don't work too much in the Clang frontend, so you'd get better commentary by talking to people who work more specifically on the frontend pieces.

For my own personal opinion, I would be extremely reluctant to suggest a generic attribute-based approach to generate these types in the frontend. Instead, I suspect creating custom `clang::Type` is likely to be a more maintainable path: target extension types come with their own varied restrictions, and it's better to front those restrictions as early in the frontend as possible. For the target extension types I've needed for SPIR-V, almost all of them are existing already as `clang::BuiltinType` IDs, and the other types that have been looking at target extension types I believe also have other distinct types in the Clang frontend. Adding a new such builtin type isn't a very high maintenance burden. Things get more interesting if the types have parameters (which means you can't just add a new builtin type), but the need to do some form of AST and Sema analysis on such parameters likely requires you to have to do some modifications to clang anyways.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135202/new/

https://reviews.llvm.org/D135202



More information about the llvm-commits mailing list