Remove some extraneous const qualifiers on Type, and 0b1 -> 1 in tblgen files...
authorChris Lattner <clattner@google.com>
Wed, 15 May 2019 14:54:28 +0000 (07:54 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 20 May 2019 20:42:56 +0000 (13:42 -0700)
--

PiperOrigin-RevId: 248332674

mlir/g3doc/QuickstartRewrites.md
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/StandardTypes.h
mlir/include/mlir/IR/Types.h
mlir/include/mlir/StandardOps/Ops.td
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/StandardTypes.cpp
mlir/lib/IR/Types.cpp
mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp

index 6335bd5..db440b2 100644 (file)
@@ -61,7 +61,7 @@ def TFL_LeakyReluOp: TFL_Op<"leaky_relu", [NoSideEffect, SameValueType]>,
 
   // TFLite specific attribute that is used when generating the output
   // flatbuffer.
-  let hasOptions = 0b1;
+  let hasOptions = 1;
 }
 ```
 
index 21bce37..1463da2 100644 (file)
@@ -481,7 +481,7 @@ class Attr<Pred condition, string descr = ""> :
   // Whether the attribute is optional. Typically requires a custom
   // convertFromStorage method to handle the case where the attribute is
   // not present.
-  bit isOptional = 0b0;
+  bit isOptional = 0;
 }
 
 // Decorates an attribute to have an (unvalidated) default value if not present.
@@ -510,7 +510,7 @@ class OptionalAttr<Attr attr> : Attr<attr.predicate, attr.description> {
   let returnType = "Optional<" # attr.returnType #">";
   let convertFromStorage = "$_self ? " # returnType # "(" #
                            attr.convertFromStorage # ") : (llvm::None)";
-  let isOptional = 0b1;
+  let isOptional = 1;
 
   // Remember `attr`'s def name.
   // TOOD(b/132458159): consider embedding Attr as a field.
@@ -923,13 +923,13 @@ class Op<Dialect dialect, string mnemonic, list<OpTrait> props = []> {
   // TODO(b/120163349): figure out a better way to write canonicalization
   // patterns in TableGen rules directly instead of using this marker
   // and C++ implementations.
-  bit hasCanonicalizer = 0b0;
+  bit hasCanonicalizer = 0;
 
   // Whether this op has a constant folder.
-  bit hasConstantFolder = 0b0;
+  bit hasConstantFolder = 0;
 
   // Whether this op has a folder.
-  bit hasFolder = 0b0;
+  bit hasFolder = 0;
 
   // Op traits.
   list<OpTrait> traits = props;
index 7d8fad5..8043ac6 100644 (file)
@@ -71,12 +71,12 @@ enum Kind {
 
 } // namespace StandardTypes
 
-inline bool Type::isBF16() const { return getKind() == StandardTypes::BF16; }
-inline bool Type::isF16() const { return getKind() == StandardTypes::F16; }
-inline bool Type::isF32() const { return getKind() == StandardTypes::F32; }
-inline bool Type::isF64() const { return getKind() == StandardTypes::F64; }
+inline bool Type::isBF16() { return getKind() == StandardTypes::BF16; }
+inline bool Type::isF16() { return getKind() == StandardTypes::F16; }
+inline bool Type::isF32() { return getKind() == StandardTypes::F32; }
+inline bool Type::isF64() { return getKind() == StandardTypes::F64; }
 
-inline bool Type::isIndex() const { return getKind() == StandardTypes::Index; }
+inline bool Type::isIndex() { return getKind() == StandardTypes::Index; }
 
 /// Index is a special integer-like type with unknown platform-dependent bit
 /// width.
@@ -126,21 +126,21 @@ public:
 };
 
 /// Return true if this is an integer type with the specified width.
-inline bool Type::isInteger(unsigned width) const {
+inline bool Type::isInteger(unsigned width) {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.getWidth() == width;
   return false;
 }
 
-inline bool Type::isIntOrIndex() const {
+inline bool Type::isIntOrIndex() {
   return isa<IndexType>() || isa<IntegerType>();
 }
 
-inline bool Type::isIntOrIndexOrFloat() const {
+inline bool Type::isIntOrIndexOrFloat() {
   return isa<IndexType>() || isa<IntegerType>() || isa<FloatType>();
 }
 
-inline bool Type::isIntOrFloat() const {
+inline bool Type::isIntOrFloat() {
   return isa<IntegerType>() || isa<FloatType>();
 }
 
@@ -174,10 +174,10 @@ public:
   }
 
   /// Return the bitwidth of this float type.
-  unsigned getWidth() const;
+  unsigned getWidth();
 
   /// Return the floating semantics of this float type.
-  const llvm::fltSemantics &getFloatSemantics() const;
+  const llvm::fltSemantics &getFloatSemantics();
 };
 
 /// This is a common base class between Vector, UnrankedTensor, and RankedTensor
index 511a988..59db7eb 100644 (file)
@@ -141,36 +141,36 @@ public:
   unsigned getKind() const;
 
   /// Return the LLVMContext in which this type was uniqued.
-  MLIRContext *getContext() const;
+  MLIRContext *getContext();
 
   /// Get the dialect this type is registered to.
-  const Dialect &getDialect() const;
+  const Dialect &getDialect();
 
   // Convenience predicates.  This is only for floating point types,
   // derived types should use isa/dyn_cast.
-  bool isIndex() const;
-  bool isBF16() const;
-  bool isF16() const;
-  bool isF32() const;
-  bool isF64() const;
+  bool isIndex();
+  bool isBF16();
+  bool isF16();
+  bool isF32();
+  bool isF64();
 
   /// Return true if this is an integer type with the specified width.
-  bool isInteger(unsigned width) const;
+  bool isInteger(unsigned width);
 
   /// Return the bit width of an integer or a float type, assert failure on
   /// other types.
-  unsigned getIntOrFloatBitWidth() const;
+  unsigned getIntOrFloatBitWidth();
 
   /// Return true if this is an integer or index type.
-  bool isIntOrIndex() const;
+  bool isIntOrIndex();
   /// Return true if this is an integer, index, or float type.
-  bool isIntOrIndexOrFloat() const;
+  bool isIntOrIndexOrFloat();
   /// Return true of this is an integer or a float type.
-  bool isIntOrFloat() const;
+  bool isIntOrFloat();
 
   /// Print the current type.
-  void print(raw_ostream &os) const;
-  void dump() const;
+  void print(raw_ostream &os);
+  void dump();
 
   friend ::llvm::hash_code hash_value(Type arg);
 
index 31c2787..0497b84 100644 (file)
@@ -112,13 +112,13 @@ class FloatArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
 
 def AddFOp : FloatArithmeticOp<"addf"> {
   let summary = "floating point addition operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def AddIOp : IntArithmeticOp<"addi", [Commutative]> {
   let summary = "integer addition operation";
   let hasFolder = 1;
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def AllocOp : Std_Op<"alloc"> {
@@ -158,12 +158,12 @@ def AllocOp : Std_Op<"alloc"> {
     MemRefType getType() { return getResult()->getType().cast<MemRefType>(); }
   }];
 
-  let hasCanonicalizer = 0b1;
+  let hasCanonicalizer = 1;
 }
 
 def AndOp : IntArithmeticOp<"and", [Commutative]> {
   let summary = "integer binary and";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
   let hasFolder = 1;
 }
 
@@ -271,7 +271,7 @@ def CallIndirectOp : Std_Op<"call_indirect"> {
     operand_iterator arg_operand_end() { return operand_end(); }
   }];
 
-  let hasCanonicalizer = 0b1;
+  let hasCanonicalizer = 1;
 }
 
 def ConstantOp : Std_Op<"constant", [NoSideEffect]> {
@@ -306,7 +306,7 @@ def DeallocOp : Std_Op<"dealloc"> {
 
   let arguments = (ins MemRef<AnyType>:$memref);
 
-  let hasCanonicalizer = 0b1;
+  let hasCanonicalizer = 1;
 }
 
 def DimOp : Std_Op<"dim", [NoSideEffect]> {
@@ -338,7 +338,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> {
     }
   }];
 
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def DivFOp : FloatArithmeticOp<"divf"> {
@@ -347,12 +347,12 @@ def DivFOp : FloatArithmeticOp<"divf"> {
 
 def DivISOp : IntArithmeticOp<"divis"> {
   let summary = "signed integer division operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def DivIUOp : IntArithmeticOp<"diviu"> {
   let summary = "unsigned integer division operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> {
@@ -389,7 +389,7 @@ def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> {
     }
   }];
 
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def MemRefCastOp : CastOp<"memref_cast"> {
@@ -426,18 +426,18 @@ def MemRefCastOp : CastOp<"memref_cast"> {
 
 def MulFOp : FloatArithmeticOp<"mulf"> {
   let summary = "foating point multiplication operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def MulIOp : IntArithmeticOp<"muli", [Commutative]> {
   let summary = "integer multiplication operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
   let hasFolder = 1;
 }
 
 def OrOp : IntArithmeticOp<"or", [Commutative]> {
   let summary = "integer binary or";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
   let hasFolder = 1;
 }
 
@@ -447,12 +447,12 @@ def RemFOp : FloatArithmeticOp<"remf"> {
 
 def RemISOp : IntArithmeticOp<"remis"> {
   let summary = "signed integer division remainder operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def RemIUOp : IntArithmeticOp<"remiu"> {
   let summary = "unsigned integer division remainder operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def ReturnOp : Std_Op<"return", [Terminator]> {
@@ -481,13 +481,13 @@ def ShlISOp : IntArithmeticOp<"shlis"> {
 
 def SubFOp : FloatArithmeticOp<"subf"> {
   let summary = "floating point subtraction operation";
-  let hasConstantFolder = 0b1;
+  let hasConstantFolder = 1;
 }
 
 def SubIOp : IntArithmeticOp<"subi"> {
   let summary = "integer subtraction operation";
-  let hasConstantFolder = 0b1;
-  let hasCanonicalizer = 0b1;
+  let hasConstantFolder = 1;
+  let hasCanonicalizer = 1;
 }
 
 def TensorCastOp : CastOp<"tensor_cast"> {
@@ -518,8 +518,8 @@ def TensorCastOp : CastOp<"tensor_cast"> {
 
 def XOrOp : IntArithmeticOp<"xor", [Commutative]> {
   let summary = "integer binary xor";
-  let hasConstantFolder = 0b1;
-  let hasCanonicalizer = 0b1;
+  let hasConstantFolder = 1;
+  let hasCanonicalizer = 1;
   let hasFolder = 1;
 }
 
index ba0b9b5..807bc93 100644 (file)
@@ -1628,12 +1628,12 @@ void Attribute::dump() const {
   llvm::errs() << "\n";
 }
 
-void Type::print(raw_ostream &os) const {
+void Type::print(raw_ostream &os) {
   ModuleState state(getContext());
   ModulePrinter(os, state).printType(*this);
 }
 
-void Type::dump() const { print(llvm::errs()); }
+void Type::dump() { print(llvm::errs()); }
 
 void AffineMap::dump() const {
   print(llvm::errs());
index 37071e1..ba7d1d3 100644 (file)
@@ -61,7 +61,7 @@ unsigned IntegerType::getWidth() const { return getImpl()->width; }
 // Float Type
 //===----------------------------------------------------------------------===//
 
-unsigned FloatType::getWidth() const {
+unsigned FloatType::getWidth() {
   switch (getKind()) {
   case StandardTypes::BF16:
   case StandardTypes::F16:
@@ -76,7 +76,7 @@ unsigned FloatType::getWidth() const {
 }
 
 /// Returns the floating semantics for the given type.
-const llvm::fltSemantics &FloatType::getFloatSemantics() const {
+const llvm::fltSemantics &FloatType::getFloatSemantics() {
   if (isBF16())
     // Treat BF16 like a double. This is unfortunate but BF16 fltSemantics is
     // not defined in LLVM.
@@ -93,7 +93,7 @@ const llvm::fltSemantics &FloatType::getFloatSemantics() const {
   llvm_unreachable("non-floating point type used");
 }
 
-unsigned Type::getIntOrFloatBitWidth() const {
+unsigned Type::getIntOrFloatBitWidth() {
   assert(isIntOrFloat() && "only ints and floats have a bitwidth");
   if (auto intType = dyn_cast<IntegerType>()) {
     return intType.getWidth();
index a8f8c6c..3932e94 100644 (file)
@@ -27,9 +27,9 @@ using namespace mlir::detail;
 unsigned Type::getKind() const { return impl->getKind(); }
 
 /// Get the dialect this type is registered to.
-const Dialect &Type::getDialect() const { return impl->getDialect(); }
+const Dialect &Type::getDialect() { return impl->getDialect(); }
 
-MLIRContext *Type::getContext() const { return getDialect().getContext(); }
+MLIRContext *Type::getContext() { return getDialect().getContext(); }
 
 unsigned Type::getSubclassData() const { return impl->getSubclassData(); }
 void Type::setSubclassData(unsigned val) { impl->setSubclassData(val); }
index 7b4db1f..81c0099 100644 (file)
@@ -105,9 +105,8 @@ void VectorizerTestPass::testVectorShapeRatio(llvm::raw_ostream &outs) {
       VectorType::get(shape, FloatType::getF32(f->getContext()));
   // Only filter operations that operate on a strict super-vector and have one
   // return. This makes testing easier.
-  auto filter = [subVectorType](Operation &op) {
-    assert(subVectorType.getElementType() ==
-               FloatType::getF32(subVectorType.getContext()) &&
+  auto filter = [&](Operation &op) {
+    assert(subVectorType.getElementType().isF32() &&
            "Only f32 supported for now");
     if (!matcher::operatesOnSuperVectorsOf(op, subVectorType)) {
       return false;