[clang] [lld] [llvm] [WebAssembly] Emit constant initializers for addrspace(1) globals (PR #212007)
Yuta Saito via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 11 22:29:22 PDT 2026
================
@@ -470,25 +493,95 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
Parser.Lex();
}
- bool parseSingleFloat(bool IsNegative, OperandVector &Operands) {
+ // Parses a global's initial value, spelled like the matching const
+ // instruction's immediate: `i32.const 42`, `f32.const 0x1p1`.
+ bool parseGlobalInit(wasm::ValType Type,
----------------
kateinoigakukun wrote:
I don't think a dedicated parser for the init expression is a good direction. It implements another text instruction parser.
The extended-const proposal adds `i32.add`/`sub`/`mul`, `global.get` etc. with a stack discipline, and we already have the instruction parser/matcher for function bodies that knows all of these. Can we parse the const expr through the normal `parseInstruction` -> `MCInst` path and convert the resulting `MCInst`s to a `WasmInitExpr`? Otherwise this will need to grow into a second mini assembler.
https://github.com/llvm/llvm-project/pull/212007
More information about the cfe-commits
mailing list