# stage2: improve addrspace handling · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/5f3b91437f5cd23bcae66227932555b7abe32669)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 5f3b91437f5cd23bcae66227932555b7abe32669

Requested commit: 5f3b91437f5cd23bcae66227932555b7abe32669

Commit: 5f3b91437f5cd23bcae66227932555b7abe32669

Tree: 3d1db6c0e791e7b206ea4eb88abdad252f3901bd

Author: Robin Voetter

Committer: Robin Voetter

## Message

```
stage2: improve addrspace handling

This commit changes the way Zig is intended to deal with variable
declaration for exotic targets. Where previously the idea was to
enfore local/global variables to be placed into their respective
address spaces, depending on the target, this is now fixed to the
generic address space.

To facilitate this for targets where local variables _must_ be
generated into a specific address space (ex. amdgcn where locals
must be generated into the private address space), the variable
allocations (alloca) are generated into the right address space
and then addrspace-casted back to the generic address space. While this
could be less efficient in theory, LLVM will hopefull deal with figuring
out the actual correct address space for a pointer for us. HIP seems to
do the same thing in this regard.

Global variables are handled in a similar way.

```

## Parents

- [3392de87dcf516ed2e3fd1904372195bdc75c0eb](https://git.cafe/gitcafe/zig/commit/3392de87dcf516ed2e3fd1904372195bdc75c0eb?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/5f3b91437f5cd23bcae66227932555b7abe32669?format=markdown)
