Can I use address space indices in Rust-llvm?

Hi, I want to use "Memory references off the GS segment" in Rust.
Below is an example of it in clang.

#define GS_RELATIVE __attribute__((address_space(256)))
int foo(int GS_RELATIVE *P) {
return *P;
}
Which compiles to (on X86-32):
_foo:
movl 4(%esp), %eax
movl %gs:(%eax), %eax
ret

Check https://buildmedia.readthedocs.org/media/pdf/clang/release_37/clang.pdf on page 128

i don't think this is currently possible without using (inline) assembly

for AMDGCN (GPU) there has been some work on supporting address spaces: https://github.com/rust-lang/rust/issues/51575, but this was never merged not even unstable

proposals to make it easier to 'punch through' LLVM attributes tend to be rejected because of not wanting to tie the language too closely to LLVM: https://github.com/rust-lang/rust/issues/15180

FYI, supporting the Atmel AVR family of µCs is also blocked on the need for properly supporting address spaces.

1 Like