[Mlir-commits] [mlir] [mlir][wasm] Support for saturating FP truncations (PR #212709)

Max Graey llvmlistbot at llvm.org
Sat Aug 1 05:11:51 PDT 2026


================
@@ -415,98 +361,117 @@ class ExpressionParser {
   template <typename OpToCreate>
   parsed_inst_t parseSetOrTee(OpBuilder &);
 
-  /// Blocks and Loops have a similar format and differ only in how their exit
-  /// is handled which doesn´t matter at parsing time. Factorizes in one
-  /// function.
-  template <typename OpToCreate>
-  parsed_inst_t parseBlockLikeOp(OpBuilder &);
-
   Location getCurrentOpLoc() {
     assert(currentOpLoc.has_value() &&
            "expects current opcode location to be set");
     return *currentOpLoc;
   }
 
-  class TopLevelInstParserRegistry {
+  struct ExprParserProxy {
   public:
-    template <std::byte opCode>
-    static constexpr bool hasParserForOpcode = false;
+    friend ExpressionParser;
+    inline auto parseBlockFuncType(OpBuilder &builder) {
+      return exprParser.parseBlockFuncType(builder);
+    }
 
-    template <std::byte opCode>
-    static parsed_inst_t parseInstrWithOpCode(OpBuilder &,
-                                              ExpressionParser &) = delete;
-  };
+    template <typename FilterT = ByteSequence<WasmBinaryEncoding::endByte>>
+    /// @param blockToFill: the block which content will be populated
+    /// @param resType: the type that this block is supposed to return
+    llvm::FailureOr<std::byte>
+    parseBlockContent(OpBuilder &builder, Block *blockToFill,
+                      TypeRange resTypes, Location opLoc,
+                      LabelLevelOpInterface levelOp,
+                      FilterT parseEndBytes = {}) {
+      OpBuilder::InsertionGuard guard{builder};
+      builder.setInsertionPointToStart(blockToFill);
+      LDBG() << "parsing a block of type "
+             << builder.getFunctionType(blockToFill->getArgumentTypes(),
+                                        resTypes);
+      auto nC = exprParser.addNesting(levelOp);
----------------
MaxGraey wrote:

```suggestion
      auto nestingGuard = exprParser.addNesting(levelOp);
```

https://github.com/llvm/llvm-project/pull/212709


More information about the Mlir-commits mailing list