[cfe-dev] Adding a new def for global keyword in Attr.td

Aaron Ballman aaron at aaronballman.com
Wed Oct 29 15:31:58 PDT 2014


On Wed, Oct 29, 2014 at 5:00 PM, Aaron W.Hsu <arcfide at sacrideo.us> wrote:
> Hello Clang Developers:
>
> I’m new to clang and I’m trying to add a “global” keyword to a new extension
> of C. I’ve found Attr.td and I’ve been playing with it. It seems that what I
> want is basically the same as what is in the OpenCLGlobalAddressSpace
> definition:
>
> def OpenCLGlobalAddressSpace : TypeAttr {
>
> let Spellings = [Keyword<"__global">, Keyword<"global">];
>
> let Documentation = [Undocumented];
>
> }
>
> However, as you can see, OpenCL already uses “global” and the like. I had
> thought that just putting the TokenKinds.def options in to ensure that it
> only was recognized for the new language would work, but it turns out that
> even then, I still get an assertion error about multiple string matches if I
> duplicate the above using PXCGlobalAddressSpace instead. What I really want
> is to have the “global” keyword, when in my PXC language, to be mapped as a
> PXCGlobalAddressSpace, and not as an OpenCLGlobalAddressSpace. How can I do
> this? Attr.td does not seem to support multiple definitions with the same
> keywords.

The attribute tablegen does have some limited support for multiple
attributes with the same spelling, however, they must be
target-specific. For instance, ARMInterrupt and MSP430Interrupt are an
example of attributes which share the same spelling, and even have
different arguments. The problem is: you can't have both OpenCL's
global keyword at the same time as yours, because there's no machinery
in place to map which one should be generated when.

~Aaron




More information about the cfe-dev mailing list