[cfe-dev] How to add a new calling convention?

Gaier, Bjoern via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 12 00:22:43 PDT 2021


Hello Clang-Devs,

this question originally came from the LLVM Discord server:
Currently we are using an inhouse library which a different department developed for us. I'm not aware about what they are doing in there implementation, however whenever we use functions from said library we are instructed to save the GS register. Currently we manage this by using inline assembly, we push the register before the call, do the call and pop it back. However this is very error prone because you can easily forget to do so.

My hope was to teach Clang an additional calling convention which we could explicitly declare with "__specialcall" or something. That convention would push the GS register for us and then do the normal x86_64 calling convention. In Discord I was told that this is possible but that there are no instructions for this.

Can someone guide me in the right direction for doing such a thing? Hopefully in a way a beginner can pick it up >o<

Thank you in advance and kind greetings
Björn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210712/19607820/attachment.html>


More information about the cfe-dev mailing list