-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][TableGen] Support specifying address space in clang builtin prototypes #108497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Gentle ping @AaronBallman , @philnik777 , @fpetrogalli :) |
Ah, sorry -- because the PR is marked as a Draft, I figured it wasn't ready for review yet. I think I'd rather this was expressed differently; we already don't put attribute information in the prototype anyway (
I think that makes it more clean in terms of specifying the attribute, and it also means we can name the address spaces in WDYT? |
Thanks for the reply @AaronBallman . The reason this is still a draft is that I wanted it to be an initial proposal to get some inputs and a consensus on the final design. and about it being part of the "Attributes" field, one major issue is that the address space information should be per argument including the return type. "Attributes" field currently expresses attributes to the function. If attribute in the prototype is not desired, probably a new field that lets us specify per argument attributes makes sense ? |
Oh! I hadn't realized this was needed on a per-parameter basis. Oof that makes this more awkward. I'd still love to avoid writing this as part of the signature; I think we could use the existing
|
Makes sense, I will give this a try and update the PR |
Made some initial changes according to suggestions @AaronBallman , how does this look ?
|
5ab4003
to
74b2ad7
Compare
gentle ping.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing this, it was in Draft status and so I wasn't looking at it for reviews. :-)
This is sort of heading in the direction I think it should go. I did have a suggestion though.
// Address space attribute, only valid for pointer or reference arguments. | ||
// ArgIdx - argument to which the attribute refers. value 0 is for return type. | ||
// AddrSpaceNum - Address space number for the argument. | ||
class AddressSpace<int ArgIdx, int AddrSpaceNum> : IndexedAttribute<"", ArgIdx> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of taking an int
for the second argument, I think it would make more sense to do:
class AddressSpace<int AddrSpaceValue> {
int SpaceNum = AddrSpaceValue;
}
// Use whatever the correct values are, I just used random numbers
def Global : AddressSpace<12>;
def Constant : AddressSpace<1002>;
class ArgWithAddressSpace<int ArgIdx, AddressSpace Num> : IndexedAttribute<"", ArgIdx< {
AddressSpace AddrSpace = Num;
}
...
let Attributes = [ArgWithAddressSpace<0, Global>, NoThrow];
WDYT?
handled #122873 |
this is a follow up from the discussion in #86801 (apologies for the long delay...).
This PR proposes a way to specify address spaces in builtin prototypes. The idea is to specify address space numbers using CXX11 attribute list syntax ([[<attr_list>]]) with following limitations,
int* const [[addrspace[3]]] ;
I would like some views on this approach and alternate suggestions if any. Also please let me know if there are any parallel efforts towards this which I might not be aware of.