Hi,
Is there a way to implement named address spaces with clang/llvm as it is
possible with gcc ?
We would like to have our own named address space that would be recognized
by the frontend.
Thanks in advance!
Regards,
Sebastien
Hi,
Is there a way to implement named address spaces with clang/llvm as it is
possible with gcc ?
We would like to have our own named address space that would be recognized
by the frontend.
Thanks in advance!
Regards,
Sebastien
Hi Sebastien,
Clang does have support for numbered address spaces via the attribute((address_space(N))) syntax. These address spaces map down to addrspace() in LLVM IR, and addrspaces in LLVM IR have arbitrary semantics unknown to LLVM itself.
However, there is no way to define custom address space keywords without adding them explicitly to the lexing and parsing, and there is also no way for a target to express how its address spaces are supposed to be related (subspaces, conversions etc). I have an initial patch to add support for target AS compatibility here (https://reviews.llvm.org/D62574) but hit some snags and have not had the bandwidth to finish it. I don’t think a lot of people really require this, so it’s hard to justify working on it.
/ Bevin
Sebastien Le Duc via llvm-dev <llvm-dev@lists.llvm.org> Sent:
> Hi, Is there a way to implement named address spaces with
> clang/llvm as it is possible with gcc ?
> We would like to have our own named address space that would
> be recognized by the frontend.
> Hi Sebastien, Clang does have support for numbered address
> spaces via the __attribute__((address_space(N)))
> syntax. These address spaces map down to addrspace() in LLVM
> IR, and addrspaces in LLVM IR have arbitrary semantics
> unknown to LLVM itself.
In the meantime, I wonder whether something like
#define __mppa_cluster __attribute__((address_space(42)))
plus a few LLVM-only passes could not do most of the job while avoiding
diving into Clang...
Then you have some decent minimal __mppa_cluster named address space.
Otherwise, if you can use C++, you can also use wrapper
classes to add address spaces around some data types,
such as
mppa::cluster<int> v;
to declare some int variable inside your MPPA cluster (just an imaginative
example to give the idea).
I used to do this in SYCL and also OpenCL C++ was using this trick
https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_Cxx.html#address-spaces-library
At some point if the C++ proposal about the . (dot) operator overloading
lands, it should be easier to implement this way.