[Mlir-commits] [mlir] [MLIR][Types] add isFloat() to Type class (PR #88926)
Scott Manley
llvmlistbot at llvm.org
Tue Apr 16 09:35:34 PDT 2024
https://github.com/rscottmanley updated https://github.com/llvm/llvm-project/pull/88926
>From 1cbdcfb5e6d26a2f7bcf892721980f2db899a442 Mon Sep 17 00:00:00 2001
From: Scott Manley <scmanley at nvidia.com>
Date: Tue, 16 Apr 2024 09:00:52 -0700
Subject: [PATCH] [MLIR][Types] add isFloat() to Type class
Add isFloat() as a member function to the Type class and canonicalize
the compound queries to use the base queries.
---
mlir/include/mlir/IR/Types.h | 5 ++++-
mlir/lib/IR/Types.cpp | 16 +++++++---------
2 files changed, 11 insertions(+), 10 deletions(-)
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..d00f997f113c19 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,24 +103,20 @@ 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();
-}
+bool Type::isIntOrIndex() const { return isInteger() || isIndex(); }
-bool Type::isIntOrFloat() const {
- return llvm::isa<IntegerType, FloatType>(*this);
-}
+bool Type::isIntOrFloat() const { return isInteger() || isFloat(); }
bool Type::isIntOrIndexOrFloat() const { return isIntOrFloat() || isIndex(); }
More information about the Mlir-commits
mailing list