[all-commits] [llvm/llvm-project] 715b02: [mlir][ods] Simplify signature of `custom` printer...

zero9178 via All-commits all-commits at lists.llvm.org
Sun Jan 22 07:18:50 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 715b0258522ff3c99aa57801d1f4d2b1b7a90ee1
      https://github.com/llvm/llvm-project/commit/715b0258522ff3c99aa57801d1f4d2b1b7a90ee1
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2023-01-22 (Sun, 22 Jan 2023)

  Changed paths:
    M mlir/docs/DefiningDialects/AttributesAndTypes.md
    M mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
    M mlir/include/mlir/IR/AttributeSupport.h
    M mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
    M mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
    M mlir/test/lib/Dialect/Test/TestAttributes.cpp
    M mlir/test/lib/Dialect/Test/TestTypes.cpp
    M mlir/test/mlir-tblgen/attr-or-type-format.td
    M mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp

  Log Message:
  -----------
  [mlir][ods] Simplify signature of `custom` printers and parsers of Attributes and Types in presence of default constructible parameters

The vast majority of parameters of C++ types used as parameters for Attributes and Types are likely to be default constructible. Nevertheless, TableGen conservatively generates code for the custom directive, expecting signatures using FailureOr<T> for all parameter types T to accomodate them possibly not being default constructible. This however reduces the ergonomics of the likely case of default constructible parameters.

This patch fixes that issue, while barely changing the generated TableGen code, by using a helper function that is used to pass any parameters into custom parser methods. If the type is default constructible, as deemed by the C++ compiler, a default constructible instance is created and passed into the parser method by reference. In all other cases it is a Noop and a FailureOr is passed as before.

Documentation was also updated to document the new behaviour.

Fixes https://github.com/llvm/llvm-project/issues/60178

Differential Revision: https://reviews.llvm.org/D142301




More information about the All-commits mailing list