[Mlir-commits] [mlir] 610396e - [mlir][ods] Allow null to be passed as default-valued attributes
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Mar 29 09:55:09 PDT 2022
Author: Mogball
Date: 2022-03-29T16:55:00Z
New Revision: 610396e481fdef382225cb729b2861ff535bdc98
URL: https://github.com/llvm/llvm-project/commit/610396e481fdef382225cb729b2861ff535bdc98
DIFF: https://github.com/llvm/llvm-project/commit/610396e481fdef382225cb729b2861ff535bdc98.diff
LOG: [mlir][ods] Allow null to be passed as default-valued attributes
Allow default-valued attributes to be passed as null to builders, which will not add the attribute if not present, so the default value will be returned by getters.
Added:
Modified:
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index dd09f9e3766a6..05a9f83aa6437 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1830,7 +1830,8 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(
if (attr.isDerivedAttr() || inferredAttributes.contains(namedAttr.name))
continue;
- bool emitNotNullCheck = attr.isOptional();
+ bool emitNotNullCheck =
+ attr.isOptional() || (attr.hasDefaultValue() && !isRawValueAttr);
if (emitNotNullCheck)
body << formatv(" if ({0}) ", namedAttr.name) << "{\n";
More information about the Mlir-commits
mailing list