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: Tracking issue for targeting AMDGPU devices · Issue #51575 · rust-lang/rust · GitHub, 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: Make it easy to attach LLVM attributes to Rust functions · Issue #15180 · rust-lang/rust · GitHub

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

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.