[Mlir-commits] [mlir] [MLIR][WASM] Extending the Wasm binary to WasmSSA dialect importer (PR #154053)
Mehdi Amini
llvmlistbot at llvm.org
Mon Aug 18 02:27:54 PDT 2025
================
@@ -1229,6 +1465,51 @@ WasmBinaryParser::parseSectionItem<WasmSectionType::MEMORY>(ParserHead &ph,
symbols.memSymbols.push_back({SymbolRefAttr::get(memOp)});
return success();
}
+
+template <>
+LogicalResult
+WasmBinaryParser::parseSectionItem<WasmSectionType::GLOBAL>(ParserHead &ph,
+ size_t) {
+ FileLineColLoc globalLocation = ph.getLocation();
+ auto globalTypeParsed = ph.parseGlobalType(ctx);
+ if (failed(globalTypeParsed))
+ return failure();
+
+ GlobalTypeRecord globalType = *globalTypeParsed;
+ auto symbol = builder.getStringAttr(symbols.getNewGlobalSymbolName());
+ auto globalOp = builder.create<wasmssa::GlobalOp>(
+ globalLocation, symbol, globalType.type, globalType.isMutable);
+ symbols.globalSymbols.push_back(
+ {{FlatSymbolRefAttr::get(globalOp)}, globalOp.getType()});
+ auto ip = builder.saveInsertionPoint();
----------------
joker-eph wrote:
```suggestion
OpBuilder::InsertionGuard guard(builder);
```
Nit: RAII
https://github.com/llvm/llvm-project/pull/154053
More information about the Mlir-commits
mailing list