[llvm-dev] Target specific named address spaces

Ronan KERYELL via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 30 12:17:12 PDT 2020


    From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of
    Sebastien Le Duc via llvm-dev <llvm-dev at 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.

>>>>> On Thu, 25 Jun 2020 08:27:10 +0000, Bevin Hansson via llvm-dev <llvm-dev at lists.llvm.org> said:

    Bevin> Hi Sebastien, Clang does have support for numbered address
    Bevin> spaces via the __attribute__((address_space(N)))
    Bevin> syntax. These address spaces map down to addrspace() in LLVM
    Bevin> IR, and addrspaces in LLVM IR have arbitrary semantics
    Bevin> 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.
-- 
  Ronan KERYELL


More information about the llvm-dev mailing list