default address space of pointers is generic in CL2.0 mode

Hi Anastasia,

Are you working this? That is to change the default address space of pointers to generic. Or anybody working on that?

Thanks!

Ruiling

I’m not sure exactly what this entails for OpenCL, but I have patches that allow the default AS in clang to be non-zero (and to LLVM to support a stack in a non-0 AS) that I could probably disentangle in about two weeks (or could point someone else at if they wanted to have a look now).

David

I am interested in these patches. There are too many things associated with LLVM's concept of 'generic' address space that would be nice to fully avoid with a non-0 stack.

-Matt

They’re part of the repositories here:

https://github.com/ctsrd-cheri/llvm/
https://github.com/ctsrd-cheri/clang/

I have a couple of deadlines next week and the FreeBSD DevSummit the week after, but the week after that I plan on cleaning up some things for upstreaming. Upstreaming the SelectionDAG::getPointerAdd method and uses will reduce my diff by a lot (and remove a huge amount of copy-and-paste coding in LLVM). I also hope to clean up the support for back ends where pointers are not integers, which is apparently of interest to some other out-of-tree consumers. I’ll put the stack-is-not-always-AS0 patches up for review at the same time.

On the LLVM side, I add a field to the DataLayout that tells you the AS for the stack. For our back end, we run an IR pass immediately before codegen that puts the stack back in AS0 and replaces all uses of allocas with the result of an intrinsic that we pattern match on to do the conversion. Other back ends may wish to keep it in a non-zero AS, but for us it’s an ABI choice and so we can share code between ABIs more easily this way.

There’s nothing in this tree that’s intended to be secret or private, so anything that’s useful to others please let me know. The main reason for not upstreaming things is that there are no in-tree consumers for most of the things that we’re doing and so little demand.

David

From: Dr D. Chisnall [mailto:dc552@hermes.cam.ac.uk] On Behalf Of David
Chisnall
Sent: Thursday, August 6, 2015 9:41 PM
To: Song, Ruiling
Cc: Anastasia Stulova <anastasia.stulova@arm.com>
(anastasia.stulova@arm.com); cfe-dev@lists.llvm.org
Subject: Re: [cfe-dev] default address space of pointers is generic in CL2.0 mode

>
> Hi Anastasia,
>
> Are you working this? That is to change the default address space of pointers
to generic. Or anybody working on that?

I’m not sure exactly what this entails for OpenCL, but I have patches that allow
the default AS in clang to be non-zero (and to LLVM to support a stack in a non-0
AS) that I could probably disentangle in about two weeks (or could point
someone else at if they wanted to have a look now).

Opencl default variables to private address space, but for program scope variable or static variables default to global address space.
And "Pointers that are declared without pointing to named address space point to the generic address space."
Previous discussion points to the provisional SPIR 2.0 generator from Khronos. The function is already included in the patch:

as I am not familiar with clang internal. I am still trying to figure out how it works.

Thanks!
Ruiling