[Mlir-commits] [mlir] [mlir][IR] Add `isInteger()` (without width) (PR #84467)

Marius Brehler llvmlistbot at llvm.org
Fri Mar 8 04:04:29 PST 2024


https://github.com/marbre created https://github.com/llvm/llvm-project/pull/84467

For the singless and signed integers overloads exist, so that the width does not need to be specified as an argument. This adds the same for integers without checking for signedness.

>From 23d97db7cfa39114a9b014f13b5ef13bab43faf7 Mon Sep 17 00:00:00 2001
From: Marius Brehler <marius.brehler at iml.fraunhofer.de>
Date: Fri, 8 Mar 2024 11:48:09 +0000
Subject: [PATCH] [mlir][IR] Add `isInteger()` (without width)

For the singless and signed integers overloads exist, so that the width
does not need to be specified as an argument. This adds the same for
integers without checking for signedness.
---
 mlir/include/mlir/IR/Types.h | 3 ++-
 mlir/lib/IR/Types.cpp        | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 46bb733101c127..a89e13b625bf40 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -133,7 +133,8 @@ 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 an integer type (with the specified width).
+  bool isInteger() const;
   bool isInteger(unsigned width) const;
   /// Return true if this is a signless integer type (with the specified width).
   bool isSignlessInteger() const;
diff --git a/mlir/lib/IR/Types.cpp b/mlir/lib/IR/Types.cpp
index 32dfef9e810495..1d1ba6df4db2f7 100644
--- a/mlir/lib/IR/Types.cpp
+++ b/mlir/lib/IR/Types.cpp
@@ -55,6 +55,8 @@ bool Type::isF128() const { return llvm::isa<Float128Type>(*this); }
 
 bool Type::isIndex() const { return llvm::isa<IndexType>(*this); }
 
+bool Type::isInteger() const { return llvm::isa<IntegerType>(*this); }
+
 /// Return true if this is an integer type with the specified width.
 bool Type::isInteger(unsigned width) const {
   if (auto intTy = llvm::dyn_cast<IntegerType>(*this))



More information about the Mlir-commits mailing list