[Mlir-commits] [mlir] 65d4b5c - Add const qualifier to Type's utility functions

Mehdi Amini llvmlistbot at llvm.org
Mon Nov 16 19:59:46 PST 2020


Author: Tei Jeong
Date: 2020-11-17T03:56:17Z
New Revision: 65d4b5cb18e36897ebc09a4223f4b22d16e62b8c

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

LOG: Add const qualifier to Type's utility functions

Reviewed By: rriddle

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/Types.h
    mlir/lib/IR/StandardTypes.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index bd5228ff366e..46335373348f 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -126,43 +126,43 @@ class Type {
 
   // Convenience predicates.  This is only for floating point types,
   // derived types should use isa/dyn_cast.
-  bool isIndex();
-  bool isBF16();
-  bool isF16();
-  bool isF32();
-  bool isF64();
+  bool isIndex() const;
+  bool isBF16() const;
+  bool isF16() const;
+  bool isF32() const;
+  bool isF64() const;
 
   /// Return true if this is an integer type with the specified width.
-  bool isInteger(unsigned width);
+  bool isInteger(unsigned width) const;
   /// Return true if this is a signless integer type (with the specified width).
-  bool isSignlessInteger();
-  bool isSignlessInteger(unsigned width);
+  bool isSignlessInteger() const;
+  bool isSignlessInteger(unsigned width) const;
   /// Return true if this is a signed integer type (with the specified width).
-  bool isSignedInteger();
-  bool isSignedInteger(unsigned width);
+  bool isSignedInteger() const;
+  bool isSignedInteger(unsigned width) const;
   /// Return true if this is an unsigned integer type (with the specified
   /// width).
-  bool isUnsignedInteger();
-  bool isUnsignedInteger(unsigned width);
+  bool isUnsignedInteger() const;
+  bool isUnsignedInteger(unsigned width) const;
 
   /// Return the bit width of an integer or a float type, assert failure on
   /// other types.
-  unsigned getIntOrFloatBitWidth();
+  unsigned getIntOrFloatBitWidth() const;
 
   /// Return true if this is a signless integer or index type.
-  bool isSignlessIntOrIndex();
+  bool isSignlessIntOrIndex() const;
   /// Return true if this is a signless integer, index, or float type.
-  bool isSignlessIntOrIndexOrFloat();
+  bool isSignlessIntOrIndexOrFloat() const;
   /// Return true of this is a signless integer or a float type.
-  bool isSignlessIntOrFloat();
+  bool isSignlessIntOrFloat() const;
 
   /// Return true if this is an integer (of any signedness) or an index type.
-  bool isIntOrIndex();
+  bool isIntOrIndex() const;
   /// Return true if this is an integer (of any signedness) or a float type.
-  bool isIntOrFloat();
+  bool isIntOrFloat() const;
   /// Return true if this is an integer (of any signedness), index, or float
   /// type.
-  bool isIntOrIndexOrFloat();
+  bool isIntOrIndexOrFloat() const;
 
   /// Print the current type.
   void print(raw_ostream &os);

diff  --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp
index ea4fb74ad487..f2835bbd3702 100644
--- a/mlir/lib/IR/StandardTypes.cpp
+++ b/mlir/lib/IR/StandardTypes.cpp
@@ -22,75 +22,75 @@ using namespace mlir::detail;
 // Type
 //===----------------------------------------------------------------------===//
 
-bool Type::isBF16() { return isa<BFloat16Type>(); }
-bool Type::isF16() { return isa<Float16Type>(); }
-bool Type::isF32() { return isa<Float32Type>(); }
-bool Type::isF64() { return isa<Float64Type>(); }
+bool Type::isBF16() const { return isa<BFloat16Type>(); }
+bool Type::isF16() const { return isa<Float16Type>(); }
+bool Type::isF32() const { return isa<Float32Type>(); }
+bool Type::isF64() const { return isa<Float64Type>(); }
 
-bool Type::isIndex() { return isa<IndexType>(); }
+bool Type::isIndex() const { return isa<IndexType>(); }
 
 /// Return true if this is an integer type with the specified width.
-bool Type::isInteger(unsigned width) {
+bool Type::isInteger(unsigned width) const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.getWidth() == width;
   return false;
 }
 
-bool Type::isSignlessInteger() {
+bool Type::isSignlessInteger() const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.isSignless();
   return false;
 }
 
-bool Type::isSignlessInteger(unsigned width) {
+bool Type::isSignlessInteger(unsigned width) const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.isSignless() && intTy.getWidth() == width;
   return false;
 }
 
-bool Type::isSignedInteger() {
+bool Type::isSignedInteger() const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.isSigned();
   return false;
 }
 
-bool Type::isSignedInteger(unsigned width) {
+bool Type::isSignedInteger(unsigned width) const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.isSigned() && intTy.getWidth() == width;
   return false;
 }
 
-bool Type::isUnsignedInteger() {
+bool Type::isUnsignedInteger() const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.isUnsigned();
   return false;
 }
 
-bool Type::isUnsignedInteger(unsigned width) {
+bool Type::isUnsignedInteger(unsigned width) const {
   if (auto intTy = dyn_cast<IntegerType>())
     return intTy.isUnsigned() && intTy.getWidth() == width;
   return false;
 }
 
-bool Type::isSignlessIntOrIndex() {
+bool Type::isSignlessIntOrIndex() const {
   return isSignlessInteger() || isa<IndexType>();
 }
 
-bool Type::isSignlessIntOrIndexOrFloat() {
+bool Type::isSignlessIntOrIndexOrFloat() const {
   return isSignlessInteger() || isa<IndexType, FloatType>();
 }
 
-bool Type::isSignlessIntOrFloat() {
+bool Type::isSignlessIntOrFloat() const {
   return isSignlessInteger() || isa<FloatType>();
 }
 
-bool Type::isIntOrIndex() { return isa<IntegerType>() || isIndex(); }
+bool Type::isIntOrIndex() const { return isa<IntegerType>() || isIndex(); }
 
-bool Type::isIntOrFloat() { return isa<IntegerType, FloatType>(); }
+bool Type::isIntOrFloat() const { return isa<IntegerType, FloatType>(); }
 
-bool Type::isIntOrIndexOrFloat() { return isIntOrFloat() || isIndex(); }
+bool Type::isIntOrIndexOrFloat() const { return isIntOrFloat() || isIndex(); }
 
-unsigned Type::getIntOrFloatBitWidth() {
+unsigned Type::getIntOrFloatBitWidth() const {
   assert(isIntOrFloat() && "only integers and floats have a bitwidth");
   if (auto intType = dyn_cast<IntegerType>())
     return intType.getWidth();


        


More information about the Mlir-commits mailing list