Guide/tutorial for adding a new type to C in Clang?


I’d like to know if there’s any tutorial or guide on how to add a new C type in Clang. Basically, what I’m interested in is in software-emulated floating point types. Thus, what I’d need to know is how to define the keyword for a type, how to define its data as a private struct, how to implement arithmetic operators on the new type (no assembly, the operators are implemented in plain C, so I shouldn’t need to tweak any backend code at all), and how to deal with automatic promotions/casts in arithmetic operators.

If there’s some example available, it would be great.

Yes, I know you can do all of this directly with plain C++ without needing to modify the Clang frontend at all, but I want to implement these software floating point types for the C language…

Or maybe the procedure would be painfully long, hard, and not suitable to end users?

Kind regards and thanks a lot,



Have you found any information concerning this topic ?

Thank you