[clang] [lldb] [WebAssembly][Clang] Give wasm tables their own type in clang AST (PR #205817)
Demetrius Kanios via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 25 21:50:44 PDT 2026
QuantumSegfault wrote:
> Can you elaborate on this? e.g., how would we declare a table of externrefs and an array of externrefs?
Consider:
```c
#define WASM_GLOBAL __attribute__((address_space(1)))
#ifdef __cplusplus
extern "C" {
#endif
int i32_data;
WASM_GLOBAL int i32_global;
double f64_data;
WASM_GLOBAL double f64_global;
#ifdef __cplusplus
}
#endif
```
```ll
@i32_data = hidden global i32 0, align 4
@i32_global = hidden addrspace(1) global i32 0, align 4
@f64_data = hidden global double 0.000000e+00, align 8
@f64_global = hidden addrspace(1) global double 0.000000e+00, align 8
```
So externref table vs global array would be something like
```
WASM_GLOBAL static __externref_t externref_table[0];
__externref_t externref_array[];
```
Whether `WASM_GLOBAL` actually remains `__attribute__((address_space(1)))`, or if you design a new attribute (e.g. `wasmvar`), the concept applies.
https://github.com/llvm/llvm-project/pull/205817
More information about the cfe-commits
mailing list