diff options
author | Jeff Niu <jeff@modular.com> | 2022-09-13 16:16:20 -0700 |
---|---|---|
committer | Jeff Niu <jeff@modular.com> | 2022-09-20 11:07:53 -0700 |
commit | 4792f2ab214e2df7875d17d4258bd5eae733e825 (patch) | |
tree | 40d2ec675c58e5820eb0d7f0b0f043481ea945d5 /mlir/lib/TableGen | |
parent | 95a33b455d74b8c0c112ad499c071117361dd403 (diff) | |
download | llvm-4792f2ab214e2df7875d17d4258bd5eae733e825.tar.gz |
[mlir][ods] Generalize default/optional parameters
This patch consolidates the notions of an optional parameter and a
default parameter. An optional parameter is a parameter equal to its
default value, which for a "purely optional" parameter is its "null"
value.
This allows the existing `comparator` and `defaultValue` fields to be
used enabled more complex "optional" parameters, such as empty arrays.
Depends on D133812
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D133816
Diffstat (limited to 'mlir/lib/TableGen')
-rw-r--r-- | mlir/lib/TableGen/AttrOrTypeDef.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp index bf86218c360b..38f1823b1437 100644 --- a/mlir/lib/TableGen/AttrOrTypeDef.cpp +++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp @@ -277,9 +277,7 @@ StringRef AttrOrTypeParameter::getSyntax() const { } bool AttrOrTypeParameter::isOptional() const { - // Parameters with default values are automatically optional. - return getDefValue<llvm::BitInit>("isOptional").value_or(false) || - getDefaultValue(); + return getDefaultValue().has_value(); } Optional<StringRef> AttrOrTypeParameter::getDefaultValue() const { |