Index: mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td =================================================================== --- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -452,6 +452,15 @@ let parser = [{ return parseReturnOp(parser, result); }]; let printer = [{ printReturnOp(p, *this); }]; } +def LLVM_ResumeOp : LLVM_TerminatorOp<"resume", []> { + let verifier = [{ + if(getNumOperands() != 1) + return emitOpError("expected exactly two successors"); + return success(); + }]; + let parser = [{ return parseResumeOp(parser, result); }]; + let printer = [{ printResumeOp(p, *this); }]; +} def LLVM_UnreachableOp : LLVM_TerminatorOp<"unreachable", []> { string llvmBuilder = [{ builder.CreateUnreachable(); }]; let parser = [{ return success(); }]; Index: mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp =================================================================== --- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -754,6 +754,30 @@ return success(); } +//===----------------------------------------------------------------------===// +// Printing/parsing for LLVM::ResumeOp. +//===----------------------------------------------------------------------===// + +static void printResumeOp(OpAsmPrinter &p, ResumeOp &op) { + p << op.getOperationName(); + p.printOptionalAttrDict(op.getAttrs()); + assert(op.getNumOperands() == 1); + p << ' ' << *op.getOperand(0) << " : " << op.getOperand(0)->getType(); +} + +// ::= `llvm.resume` ssa-use `:` type +static ParseResult parseResumeOp(OpAsmParser &parser, OperationState &result) { + SmallVector operands; + Type type; + + if (parser.parseOperandList(operands) || operands.empty() || + parser.parseColonType(type) || + parser.resolveOperand(operands[0], type, result.operands)) + return failure(); + + return success(); +} + //===----------------------------------------------------------------------===// // Printing/parsing for LLVM::UndefOp. //===----------------------------------------------------------------------===// Index: mlir/test/Dialect/LLVMIR/roundtrip.mlir =================================================================== --- mlir/test/Dialect/LLVMIR/roundtrip.mlir +++ mlir/test/Dialect/LLVMIR/roundtrip.mlir @@ -218,3 +218,10 @@ %1 = llvm.mlir.null : !llvm<"{void(i32, void()*)*, i64}*"> llvm.return } + +// CHECK-LABEL: @resume +func @resume() { + %0 = llvm.mlir.constant(3) : !llvm.i32 + // CHECK: llvm.resume %0 : !llvm.i32 + llvm.resume %0 : !llvm.i32 +} \ No newline at end of file