[clang] [Clang][TableGen] Support specifying address space in clang builtin prototypes (PR #108497)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 17 08:17:29 PDT 2024
================
@@ -73,6 +73,13 @@ def Constexpr : Attribute<"E">;
// Builtin is immediate and must be constant evaluated. Implies Constexpr, and will only be supported in C++20 mode.
def Consteval : Attribute<"EG">;
+// 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> {
----------------
AaronBallman wrote:
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?
https://github.com/llvm/llvm-project/pull/108497
More information about the cfe-commits
mailing list