[llvm-branch-commits] [mlir] 87c032f - [IR] Make Value::getType() work better with invalid IR.

2020-12-28 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2020-12-28T12:37:01-08:00
New Revision: 87c032f7b449cee97751d86739e249738029bf63

URL: 
https://github.com/llvm/llvm-project/commit/87c032f7b449cee97751d86739e249738029bf63
DIFF: 
https://github.com/llvm/llvm-project/commit/87c032f7b449cee97751d86739e249738029bf63.diff

LOG: [IR] Make Value::getType() work better with invalid IR.

The asmprinter would crash when dumping IR objects that had their
operands dropped.  With this change, we now get this output, which
makes op->dump() style debugging more useful.

%5 = "firrtl.eq"(<>, <>) : (<>, <>) -> 
!firrtl.uint<1>

Previously the asmprinter would crash getting the types of the null operands.

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

Added: 


Modified: 
mlir/lib/IR/Value.cpp

Removed: 




diff  --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp
index fd7e5b5d64e5..b29641a084a0 100644
--- a/mlir/lib/IR/Value.cpp
+++ b/mlir/lib/IR/Value.cpp
@@ -32,6 +32,11 @@ Value::Value(Operation *op, unsigned resultNo) {
 
 /// Return the type of this value.
 Type Value::getType() const {
+  // Support a null Value so the asmprinter doesn't crash on invalid IR (e.g.
+  // operations that have dropAllReferences() called on them).
+  if (!*this)
+return Type();
+
   if (BlockArgument arg = dyn_cast())
 return arg.getType();
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 25f23a6 - [AsmPrinter] Make OpAsmPrinter::printFunctionalType be resilient to null values.

2021-01-06 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2021-01-06T20:59:24-08:00
New Revision: 25f23a60398ee0a1ece2d49b281003ec642d5fed

URL: 
https://github.com/llvm/llvm-project/commit/25f23a60398ee0a1ece2d49b281003ec642d5fed
DIFF: 
https://github.com/llvm/llvm-project/commit/25f23a60398ee0a1ece2d49b281003ec642d5fed.diff

LOG: [AsmPrinter] Make OpAsmPrinter::printFunctionalType be resilient to null 
values.

A previous patch made Value::getType() be resilient to null values which was
considered to be too sweeping.  This is a more targeted change which requires
deabstracting some templates.

A middle ground would be to make ValueTypeIterator be tolerant to null values.

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

Added: 


Modified: 
mlir/include/mlir/IR/OpImplementation.h
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/Value.cpp

Removed: 




diff  --git a/mlir/include/mlir/IR/OpImplementation.h 
b/mlir/include/mlir/IR/OpImplementation.h
index f74eb52aec6d..99561c3a089b 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -128,16 +128,15 @@ class OpAsmPrinter {
   }
 
   /// Print the complete type of an operation in functional form.
-  void printFunctionalType(Operation *op) {
-printFunctionalType(op->getOperandTypes(), op->getResultTypes());
-  }
+  void printFunctionalType(Operation *op);
+
   /// Print the two given type ranges in a functional form.
   template 
   void printFunctionalType(InputRangeT &&inputs, ResultRangeT &&results) {
 auto &os = getStream();
-os << "(";
+os << '(';
 llvm::interleaveComma(inputs, *this);
-os << ")";
+os << ')';
 printArrowTypeList(results);
   }
 
@@ -414,7 +413,8 @@ class OpAsmParser {
   virtual ParseResult parseOptionalEllipsis() = 0;
 
   /// Parse an integer value from the stream.
-  template  ParseResult parseInteger(IntT &result) {
+  template 
+  ParseResult parseInteger(IntT &result) {
 auto loc = getCurrentLocation();
 OptionalParseResult parseResult = parseOptionalInteger(result);
 if (!parseResult.hasValue())

diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 1c2caa0bdfd6..302c226ca800 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -48,8 +48,41 @@ void OperationName::dump() const { print(llvm::errs()); }
 
 DialectAsmPrinter::~DialectAsmPrinter() {}
 
+//======//
+// OpAsmPrinter
+//======//
+
 OpAsmPrinter::~OpAsmPrinter() {}
 
+void OpAsmPrinter::printFunctionalType(Operation *op) {
+  auto &os = getStream();
+  os << '(';
+  llvm::interleaveComma(op->getOperands(), os, [&](Value op) {
+// Print the types of null values as <>.
+*this << (op ? op.getType() : Type());
+  });
+  os << ") -> ";
+
+  // Print the result list.  We don't parenthesize single result types unless
+  // it is a function (avoiding a grammar ambiguity).
+  auto numResults = op->getNumResults();
+  bool wrapped = numResults != 1;
+  if (!wrapped && op->getResult(0).getType() &&
+  op->getResult(0).getType().isa())
+wrapped = true;
+
+  if (wrapped)
+os << '(';
+
+  llvm::interleaveComma(op->getResults(), os, [&](const OpResult &r) {
+// Print the types of null values as <>.
+*this << (r ? r.getType() : Type());
+  });
+
+  if (wrapped)
+os << ')';
+}
+
 //======//
 // Operation OpAsm interface.
 //======//

diff  --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp
index b29641a084a0..fd7e5b5d64e5 100644
--- a/mlir/lib/IR/Value.cpp
+++ b/mlir/lib/IR/Value.cpp
@@ -32,11 +32,6 @@ Value::Value(Operation *op, unsigned resultNo) {
 
 /// Return the type of this value.
 Type Value::getType() const {
-  // Support a null Value so the asmprinter doesn't crash on invalid IR (e.g.
-  // operations that have dropAllReferences() called on them).
-  if (!*this)
-return Type();
-
   if (BlockArgument arg = dyn_cast())
 return arg.getType();
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 7510c11 - Update for review feedback: Inline var declaration and expand names.

2021-01-06 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2021-01-06T20:59:24-08:00
New Revision: 7510c1152f0bb5ca6ef68ace22cb702b57b96fe9

URL: 
https://github.com/llvm/llvm-project/commit/7510c1152f0bb5ca6ef68ace22cb702b57b96fe9
DIFF: 
https://github.com/llvm/llvm-project/commit/7510c1152f0bb5ca6ef68ace22cb702b57b96fe9.diff

LOG: Update for review feedback: Inline var declaration and expand names.

Depends on D93908.

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

Added: 


Modified: 
mlir/lib/IR/AsmPrinter.cpp

Removed: 




diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 302c226ca800..1679fa41c8b9 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -57,16 +57,15 @@ OpAsmPrinter::~OpAsmPrinter() {}
 void OpAsmPrinter::printFunctionalType(Operation *op) {
   auto &os = getStream();
   os << '(';
-  llvm::interleaveComma(op->getOperands(), os, [&](Value op) {
+  llvm::interleaveComma(op->getOperands(), os, [&](Value operand) {
 // Print the types of null values as <>.
-*this << (op ? op.getType() : Type());
+*this << (operand ? operand.getType() : Type());
   });
   os << ") -> ";
 
   // Print the result list.  We don't parenthesize single result types unless
   // it is a function (avoiding a grammar ambiguity).
-  auto numResults = op->getNumResults();
-  bool wrapped = numResults != 1;
+  bool wrapped = op->getNumResults() != 1;
   if (!wrapped && op->getResult(0).getType() &&
   op->getResult(0).getType().isa())
 wrapped = true;
@@ -74,9 +73,9 @@ void OpAsmPrinter::printFunctionalType(Operation *op) {
   if (wrapped)
 os << '(';
 
-  llvm::interleaveComma(op->getResults(), os, [&](const OpResult &r) {
+  llvm::interleaveComma(op->getResults(), os, [&](const OpResult &result) {
 // Print the types of null values as <>.
-*this << (r ? r.getType() : Type());
+*this << (result ? result.getType() : Type());
   });
 
   if (wrapped)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] dcac2da - [IR Parser] Fix a crash handling zero width integer attributes.

2021-01-10 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2021-01-10T21:18:01-08:00
New Revision: dcac2da10632c83737fce6da60fbc4dd09c01034

URL: 
https://github.com/llvm/llvm-project/commit/dcac2da10632c83737fce6da60fbc4dd09c01034
DIFF: 
https://github.com/llvm/llvm-project/commit/dcac2da10632c83737fce6da60fbc4dd09c01034.diff

LOG: [IR Parser] Fix a crash handling zero width integer attributes.

llvm::APInt cannot hold zero bit values, therefore we shouldn't try
to form them.

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

Added: 


Modified: 
mlir/lib/Parser/AttributeParser.cpp
mlir/test/IR/invalid-ops.mlir

Removed: 




diff  --git a/mlir/lib/Parser/AttributeParser.cpp 
b/mlir/lib/Parser/AttributeParser.cpp
index e78237e8e5a0..859e8e279917 100644
--- a/mlir/lib/Parser/AttributeParser.cpp
+++ b/mlir/lib/Parser/AttributeParser.cpp
@@ -334,6 +334,11 @@ static Optional buildAttributeAPInt(Type type, bool 
isNegative,
   // Extend or truncate the bitwidth to the right size.
   unsigned width = type.isIndex() ? IndexType::kInternalStorageBitWidth
   : type.getIntOrFloatBitWidth();
+
+  // APInt cannot hold a zero bit value.
+  if (width == 0)
+return llvm::None;
+
   if (width > result.getBitWidth()) {
 result = result.zext(width);
   } else if (width < result.getBitWidth()) {

diff  --git a/mlir/test/IR/invalid-ops.mlir b/mlir/test/IR/invalid-ops.mlir
index 595e3fe3f123..ff39611eaea1 100644
--- a/mlir/test/IR/invalid-ops.mlir
+++ b/mlir/test/IR/invalid-ops.mlir
@@ -1252,3 +1252,11 @@ func @subtensor_wrong_static_type(%t: 
tensor<8x16x4xf32>, %idx : index) {
 
   return
 }
+
+// -
+
+func @no_zero_bit_integer_attrs() {
+  // expected-error @+1 {{integer constant out of range for attribute}}
+  %x = "some.op"(){value = 0 : i0} : () -> f32
+  return
+}
\ No newline at end of file



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] 75a3f32 - [IR] Add an ImplicitLocOpBuilder helper class for building IR with the same loc.

2020-12-22 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2020-12-22T14:47:33-08:00
New Revision: 75a3f326c3d874853031d8bedd1d00127c835103

URL: 
https://github.com/llvm/llvm-project/commit/75a3f326c3d874853031d8bedd1d00127c835103
DIFF: 
https://github.com/llvm/llvm-project/commit/75a3f326c3d874853031d8bedd1d00127c835103.diff

LOG: [IR] Add an ImplicitLocOpBuilder helper class for building IR with the 
same loc.

One common situation is to create a lot of IR at a well known location,
e.g. when doing a big rewrite from one dialect to another where you're expanding
ops out into lots of other ops.

For these sorts of situations, it is annoying to pass the location into
every create call.  As we discused in a few threads on the forum, a way to help
with this is to produce a new sort of builder that holds a location and provides
it to each of the create<> calls automatically.

This patch implements an ImplicitLocOpBuilder class that does this.  We've had
good experience with this in the CIRCT project, and it makes sense to upstream 
to
MLIR.

I picked a random pass to adopt it to show the impact, but I don't think there 
is
any particular need to force adopt it in the codebase.

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

Added: 
mlir/include/mlir/IR/ImplicitLocOpBuilder.h

Modified: 
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp

Removed: 




diff  --git a/mlir/include/mlir/IR/ImplicitLocOpBuilder.h 
b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
new file mode 100644
index ..2dc7c34f4e85
--- /dev/null
+++ b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
@@ -0,0 +1,123 @@
+//===- ImplicitLocOpBuilder.h - Convenience OpBuilder ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Helper class to create ops with a modally set location.
+//
+//===--===//
+
+#ifndef MLIR_IR_IMPLICITLOCOPBUILDER_H
+#define MLIR_IR_IMPLICITLOCOPBUILDER_H
+
+#include "mlir/IR/Builders.h"
+
+namespace mlir {
+
+/// ImplictLocOpBuilder maintains a 'current location', allowing use of the
+/// create<> method without specifying the location.  It is otherwise the same
+/// as OpBuilder.
+class ImplicitLocOpBuilder : public mlir::OpBuilder {
+public:
+  /// Create an ImplicitLocOpBuilder using the insertion point and listener 
from
+  /// an existing OpBuilder.
+  ImplicitLocOpBuilder(Location loc, const OpBuilder &builder)
+  : OpBuilder(builder), curLoc(loc) {}
+
+  /// OpBuilder has a bunch of convenience constructors - we support them all
+  /// with the additional Location.
+  template 
+  ImplicitLocOpBuilder(Location loc, T &&operand, Listener *listener = nullptr)
+  : OpBuilder(std::forward(operand), listener), curLoc(loc) {}
+
+  ImplicitLocOpBuilder(Location loc, Block *block, Block::iterator insertPoint,
+   Listener *listener = nullptr)
+  : OpBuilder(block, insertPoint, listener), curLoc(loc) {}
+
+  /// Create a builder and set the insertion point to before the first 
operation
+  /// in the block but still inside the block.
+  static ImplicitLocOpBuilder atBlockBegin(Location loc, Block *block,
+   Listener *listener = nullptr) {
+return ImplicitLocOpBuilder(loc, block, block->begin(), listener);
+  }
+
+  /// Create a builder and set the insertion point to after the last operation
+  /// in the block but still inside the block.
+  static ImplicitLocOpBuilder atBlockEnd(Location loc, Block *block,
+ Listener *listener = nullptr) {
+return ImplicitLocOpBuilder(loc, block, block->end(), listener);
+  }
+
+  /// Create a builder and set the insertion point to before the block
+  /// terminator.
+  static ImplicitLocOpBuilder atBlockTerminator(Location loc, Block *block,
+Listener *listener = nullptr) {
+auto *terminator = block->getTerminator();
+assert(terminator != nullptr && "the block has no terminator");
+return ImplicitLocOpBuilder(loc, block, Block::iterator(terminator),
+listener);
+  }
+
+  /// Accessors for the implied location.
+  Location getLoc() const { return curLoc; }
+  void setLoc(Location loc) { curLoc = loc; }
+
+  // We allow clients to use the explicit-loc version of create as well.
+  using OpBuilder::create;
+  using OpBuilder::createOrFold;
+
+  /// Create an operation of specific op type at the current insertion point 
and
+  /// location.
+  template 
+  OpTy create(Args &&... args) {
+return OpBuilder::create(curLoc, std::forward(args)...);
+  }
+
+  /// Create an op

[llvm-branch-commits] [mlir] 9eb3e56 - [ODS] Make the getType() method on a OneResult instruction return a specific type.

2020-12-26 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2020-12-26T13:52:40-08:00
New Revision: 9eb3e564d3b1c772a64eef6ecaa3b1705d065218

URL: 
https://github.com/llvm/llvm-project/commit/9eb3e564d3b1c772a64eef6ecaa3b1705d065218
DIFF: 
https://github.com/llvm/llvm-project/commit/9eb3e564d3b1c772a64eef6ecaa3b1705d065218.diff

LOG: [ODS] Make the getType() method on a OneResult instruction return a 
specific type.

Implement Bug 46698, making ODS synthesize a getType() method that returns a
specific C++ class for OneResult methods where we know that class.  This 
eliminates
a common source of casts in things like:

   myOp.getType().cast().getPassive()

because we know that myOp always returns a FIRRTLType.  This also encourages
op authors to type their results more tightly (which is also good for
verification).

I chose to implement this by splitting the OneResult trait into itself plus a
OneTypedResult trait, given that many things are using `hasTrait`
to conditionalize various logic.

While this changes makes many many ops get more specific getType() results, it
is generally drop-in compatible with the previous behavior because 'x.cast()'
is allowed when x is already known to be a T.  The one exception to this is that
we need declarations of the types used by ops, which is why a couple headers
needed additional #includes.

I updated a few things in tree to remove the now-redundant `.cast<>`'s, but 
there
are probably many more than can be removed.

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

Added: 


Modified: 
mlir/docs/Tutorials/Toy/Ch-2.md
mlir/examples/standalone/include/Standalone/StandaloneOps.h
mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
mlir/include/mlir/Dialect/ArmNeon/ArmNeonDialect.h
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/TableGen/Type.h
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/lib/TableGen/Type.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 




diff  --git a/mlir/docs/Tutorials/Toy/Ch-2.md b/mlir/docs/Tutorials/Toy/Ch-2.md
index be76dc351912..6c9b93ae4066 100644
--- a/mlir/docs/Tutorials/Toy/Ch-2.md
+++ b/mlir/docs/Tutorials/Toy/Ch-2.md
@@ -210,7 +210,9 @@ class ConstantOp : public mlir::Op {
+ mlir::OpTrait::OneResult,
+ /// The result of getType is `Type`.
+ mlir::OpTraits::OneTypedResult::Impl> {
 
  public:
   /// Inherit the constructors from the base Op class.

diff  --git a/mlir/examples/standalone/include/Standalone/StandaloneOps.h 
b/mlir/examples/standalone/include/Standalone/StandaloneOps.h
index 5a8c5d1040e6..a56c2867b1c8 100644
--- a/mlir/examples/standalone/include/Standalone/StandaloneOps.h
+++ b/mlir/examples/standalone/include/Standalone/StandaloneOps.h
@@ -9,6 +9,7 @@
 #ifndef STANDALONE_STANDALONEOPS_H
 #define STANDALONE_STANDALONEOPS_H
 
+#include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"

diff  --git a/mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h 
b/mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
index aae3dbdf179f..eddee61d6b19 100644
--- a/mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
+++ b/mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
@@ -13,6 +13,7 @@
 #ifndef MLIR_DIALECT_AVX512_AVX512DIALECT_H_
 #define MLIR_DIALECT_AVX512_AVX512DIALECT_H_
 
+#include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"

diff  --git a/mlir/include/mlir/Dialect/ArmNeon/ArmNeonDialect.h 
b/mlir/include/mlir/Dialect/ArmNeon/ArmNeonDialect.h
index 76153af97689..18535353a104 100644
--- a/mlir/include/mlir/Dialect/ArmNeon/ArmNeonDialect.h
+++ b/mlir/include/mlir/Dialect/ArmNeon/ArmNeonDialect.h
@@ -13,6 +13,7 @@
 #ifndef MLIR_DIALECT_ARMNEON_ARMNEONDIALECT_H_
 #define MLIR_DIALECT_ARMNEON_ARMNEONDIALECT_H_
 
+#include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"

diff  --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index 0ae572c38f49..857a652f17d9 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -175,8 +175,12 @@ class Constraint {
 // are considered as uncategorized constraints.
 
 // Subclass for constraints on a type.
-class TypeConstraint :
-Constraint;
+class TypeConstraint :
+Constraint {
+  // The name of the C++ Type class if known, or Type if not.
+  string cppClassName = cppClassNameParam;
+}
 
 // Subclass for constraints on an attribute.
 class AttrConstraint :
@@ -285,8 +289,9 @@ class Dialect {
 
//===--===//
 

[llvm-branch-commits] [mlir] a44e630 - [AsmParser] Fix support for zero bit integer types.

2020-12-12 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2020-12-12T21:24:18-08:00
New Revision: a44e630353b83fea89b7d6e61cba5d34800d86d5

URL: 
https://github.com/llvm/llvm-project/commit/a44e630353b83fea89b7d6e61cba5d34800d86d5
DIFF: 
https://github.com/llvm/llvm-project/commit/a44e630353b83fea89b7d6e61cba5d34800d86d5.diff

LOG: [AsmParser] Fix support for zero bit integer types.

Zero bit integer types are supported by IntegerType for consistency,
but the asmparser never got updated. Allow them to be parsed, as
required to fix CIRCT issue #316

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

Added: 


Modified: 
mlir/lib/Parser/Token.cpp
mlir/test/Dialect/Quant/parse-any-invalid.mlir
mlir/test/Dialect/Quant/parse-uniform-invalid.mlir
mlir/test/IR/invalid.mlir
mlir/test/IR/parser.mlir

Removed: 




diff  --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp
index b4ac30f2c388..00bc7dbd6bd9 100644
--- a/mlir/lib/Parser/Token.cpp
+++ b/mlir/lib/Parser/Token.cpp
@@ -60,9 +60,7 @@ Optional Token::getIntTypeBitwidth() const {
   assert(getKind() == inttype);
   unsigned bitwidthStart = (spelling[0] == 'i' ? 1 : 2);
   unsigned result = 0;
-  if (spelling[bitwidthStart] == '0' ||
-  spelling.drop_front(bitwidthStart).getAsInteger(10, result) ||
-  result == 0)
+  if (spelling.drop_front(bitwidthStart).getAsInteger(10, result))
 return None;
   return result;
 }

diff  --git a/mlir/test/Dialect/Quant/parse-any-invalid.mlir 
b/mlir/test/Dialect/Quant/parse-any-invalid.mlir
index d90423ef4085..850174b4bd98 100644
--- a/mlir/test/Dialect/Quant/parse-any-invalid.mlir
+++ b/mlir/test/Dialect/Quant/parse-any-invalid.mlir
@@ -36,9 +36,9 @@
 !qalias = type !quant.any:f32>
 
 // -
-// Unrecognized storage type: storage size == 0
+// Unrecognized storage type: storage size
 // expected-error@+1 {{invalid integer width}}
-!qalias = type !quant.any:f32>
+!qalias = type !quant.any:f32>
 
 // -
 // Illegal storage min/max: max - min < 0

diff  --git a/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir 
b/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir
index 114ab7dc0d7b..f43496f85e0f 100644
--- a/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir
+++ b/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir
@@ -56,9 +56,9 @@
 !qalias = type !quant.uniform:f32, 0.99872:127>
 
 // -
-// Unrecognized storage type: storage size == 0
+// Unrecognized storage type: storage size
 // expected-error@+1 {{invalid integer width}}
-!qalias = type !quant.uniform:f32, 0.99872:127>
+!qalias = type !quant.uniform:f32, 0.99872:127>
 
 // -
 // Illegal storage min/max: max - min < 0

diff  --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir
index 6b28b33e7c78..86245ad25c3b 100644
--- a/mlir/test/IR/invalid.mlir
+++ b/mlir/test/IR/invalid.mlir
@@ -201,7 +201,7 @@ func @no_terminator() {
 
 // -
 
-func @illegaltype(i0) // expected-error {{invalid integer width}}
+func @illegaltype(i21312312323120) // expected-error {{invalid integer width}}
 
 // -
 

diff  --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir
index 9098e9ace5fa..8fcb7863726f 100644
--- a/mlir/test/IR/parser.mlir
+++ b/mlir/test/IR/parser.mlir
@@ -58,8 +58,8 @@ func private @baz() -> (i1, index, f32)
 // CHECK: func private @missingReturn()
 func private @missingReturn()
 
-// CHECK: func private @int_types(i1, i2, i4, i7, i87) -> (i1, index, i19)
-func private @int_types(i1, i2, i4, i7, i87) -> (i1, index, i19)
+// CHECK: func private @int_types(i0, i1, i2, i4, i7, i87) -> (i1, index, i19)
+func private @int_types(i0, i1, i2, i4, i7, i87) -> (i1, index, i19)
 
 // CHECK: func private @sint_types(si2, si4) -> (si7, si1023)
 func private @sint_types(si2, si4) -> (si7, si1023)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits