[cfe-dev] Custom calling conventions in C code

Chris Lattner clattner at apple.com
Thu Jul 10 12:56:29 PDT 2008

On Jul 10, 2008, at 12:19 PM, Matthijs Kooijman wrote:

>> or whatever.  The best way to do this is to have __interrupt__ be a
>> target-specific #define for __attribute__((interrupt)) and then  
>> have your
>> target handle the interrupt attribute however you want.
>> Yep, supporting specific calling conventions is fine, I just don't  
>> want
>> something like:
>> __attribute__((callingconv(47)))
> Okay, sounds reasonable. However, is there any generic way to do  
> this in
> clang, or will I end up locally patching clang for this?
> If the latter is the case, might function annotation be an  
> alternative?
> Currently, I can specify __attribute__((annotate("foo"))) for global
> variables, but not for functions (both in clang and gcc). I'm not  
> sure where
> this limitation comes from, but enabling generic annotation for  
> functions
> should also work for me (I can simply add a frontend pass that  
> translates
> those annotations into calling conventions for my backend, or leave  
> them as
> annotions even).

You could use attr(annotate).  I think attributes in general can only  
be put on function forward declarations, not definitions.


More information about the cfe-dev mailing list