[llvm-dev] when would I use addrspacecast?

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 6 01:31:41 PDT 2015

On 6 Oct 2015, at 06:39, Hayden Livingston via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I was reading the LangRef for semantics of an instruction and came
> across addrspacecast. I've never needed it, so I suppose I don't care
> about it.

You use it when you have a pointer in one address space and you wish to have a pointer in another address space.

> But, why does it exist? What problem is it trying to solve?

Casts between address spaces may not be simple bitcasts.  For example, you may have one address space that uses 32-bit integers to cover all of physical memory and 16-bit pointers in some fast scratchpad memory.  It may or may not be defined to cast a 16-bit pointer to a 32-bit one (it definitely won’t be a simple sign / zero extension, but it may be a masking operation if the fast memory is mapped into the larger address space).


More information about the llvm-dev mailing list