From 30199d11d27460e8c96a81c493526c32dbea428d Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 19 Dec 2022 22:38:37 +0100 Subject: [PATCH] [mlir] Drop Optional::value() references from tblgen files std::optional::value() has undesired exception checking semantics and is unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The call sites block std::optional migration. --- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 2 +- mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td | 6 +++--- mlir/tools/mlir-tblgen/OpFormatGen.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 9ee69bdd..f7f168b 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -179,7 +179,7 @@ def LLVM_FNegOp : LLVM_UnaryFloatArithmeticOp< class MemoryOpWithAlignmentBase { code setAlignmentCode = [{ if ($alignment.has_value()) { - auto align = $alignment.value(); + auto align = *$alignment; if (align != 0) inst->setAlignment(llvm::Align(align)); } diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td index 525c60c..3c618e3 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -599,7 +599,7 @@ class MMA_SYNC_INTR { # " \"" # op[2].ptx_elt_type # "\" == eltypeC && " # " \"" # op[3].ptx_elt_type # "\" == eltypeD " # " && (sat.has_value() ? " # sat # " == static_cast(*sat) : true)" - # !if(!ne(b1op, ""), " && (b1Op.has_value() ? MMAB1Op::" # b1op # " == b1Op.value() : true)", "") # ")\n" + # !if(!ne(b1op, ""), " && (b1Op.has_value() ? MMAB1Op::" # b1op # " == *b1Op : true)", "") # ")\n" # " return " # MMA_SYNC_NAME.id # ";", "") // if supported @@ -1028,8 +1028,8 @@ def NVVM_MmaOp : NVVM_Op<"mma.sync", [AttrSizedOperandSegments]> { $shape.getM(), $shape.getN(), $shape.getK(), $b1Op, $intOverflowBehavior, $layoutA, $layoutB, - $multiplicandAPtxType.value(), - $multiplicandBPtxType.value(), + *$multiplicandAPtxType, + *$multiplicandBPtxType, op.accumPtxType(), op.resultPtxType()); diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index d90d130..c88738f 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -1051,7 +1051,7 @@ static void genEnumAttrParser(const NamedAttribute *var, MethodBody &body, { llvm::raw_string_ostream os(attrBuilderStr); os << tgfmt(enumAttr.getConstBuilderTemplate(), &attrTypeCtx, - "attrOptional.value()"); + "*attrOptional"); } // Build a string containing the cases that can be formatted as a keyword. -- 2.7.4