[mlir] Drop Optional::value() references from tblgen files
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 19 Dec 2022 21:38:37 +0000 (22:38 +0100)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 19 Dec 2022 21:50:19 +0000 (22:50 +0100)
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
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
mlir/tools/mlir-tblgen/OpFormatGen.cpp

index 9ee69bd..f7f168b 100644 (file)
@@ -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));
     }
index 525c60c..3c618e3 100644 (file)
@@ -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<int>(*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<layoutA, layoutB, b1op, sat, op[0], op[1], op[2], op[3]>.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());
 
index d90d130..c88738f 100644 (file)
@@ -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.