[Mlir-commits] [mlir] [MLIR][Types] add isFloat() to Type class (PR #88926)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Apr 16 09:30:55 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Scott Manley (rscottmanley)
<details>
<summary>Changes</summary>
Add isFloat() as a member function to the Type class and canonicalize the compound queries to use the base queries.
---
Full diff: https://github.com/llvm/llvm-project/pull/88926.diff
2 Files Affected:
- (modified) mlir/include/mlir/IR/Types.h (+4-1)
- (modified) mlir/lib/IR/Types.cpp (+7-5)
``````````diff
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index a89e13b625bf40..47306fbac6e681 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -133,7 +133,10 @@ class Type {
bool isF80() const;
bool isF128() const;
- /// Return true if this is an integer type (with the specified width).
+ /// Return true if this is a floating point type.
+ bool isFloat() const;
+
+ /// Return true if this is an integer type.
bool isInteger() const;
bool isInteger(unsigned width) const;
/// Return true if this is a signless integer type (with the specified width).
diff --git a/mlir/lib/IR/Types.cpp b/mlir/lib/IR/Types.cpp
index 1d1ba6df4db2f7..a18ef525143aed 100644
--- a/mlir/lib/IR/Types.cpp
+++ b/mlir/lib/IR/Types.cpp
@@ -53,6 +53,8 @@ bool Type::isF64() const { return llvm::isa<Float64Type>(*this); }
bool Type::isF80() const { return llvm::isa<Float80Type>(*this); }
bool Type::isF128() const { return llvm::isa<Float128Type>(*this); }
+bool Type::isFloat() const { return llvm::isa<FloatType>(*this); }
+
bool Type::isIndex() const { return llvm::isa<IndexType>(*this); }
bool Type::isInteger() const { return llvm::isa<IntegerType>(*this); }
@@ -101,23 +103,23 @@ bool Type::isUnsignedInteger(unsigned width) const {
}
bool Type::isSignlessIntOrIndex() const {
- return isSignlessInteger() || llvm::isa<IndexType>(*this);
+ return isSignlessInteger() || isIndex();
}
bool Type::isSignlessIntOrIndexOrFloat() const {
- return isSignlessInteger() || llvm::isa<IndexType, FloatType>(*this);
+ return isSignlessInteger() || isIndex() || isFloat();
}
bool Type::isSignlessIntOrFloat() const {
- return isSignlessInteger() || llvm::isa<FloatType>(*this);
+ return isSignlessInteger() || isFloat();
}
bool Type::isIntOrIndex() const {
- return llvm::isa<IntegerType>(*this) || isIndex();
+ return isInteger() || isIndex();
}
bool Type::isIntOrFloat() const {
- return llvm::isa<IntegerType, FloatType>(*this);
+ return isInteger() || isFloat();
}
bool Type::isIntOrIndexOrFloat() const { return isIntOrFloat() || isIndex(); }
``````````
</details>
https://github.com/llvm/llvm-project/pull/88926
More information about the Mlir-commits
mailing list