summaryrefslogtreecommitdiffstats
path: root/mlir/lib
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-08-16 14:45:37 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-08-16 14:46:06 -0700
commit36c373129d2605a81fbb606b36f9e95b31e29a95 (patch)
tree196c4173bac85686f5ea98c2ff5e90f2090af47f /mlir/lib
parent3191f9c5e074de8d9d220ee702d5298870bde032 (diff)
downloadbcm5719-llvm-36c373129d2605a81fbb606b36f9e95b31e29a95.tar.gz
bcm5719-llvm-36c373129d2605a81fbb606b36f9e95b31e29a95.zip
NFC: Move the Type::is* predicates to StandardTypes.cpp
These methods are currently defined 'inline' in StandardTypes.h, but this may create linker errors if StandardTypes.h isn't included at the use site. PiperOrigin-RevId: 263850328
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/IR/StandardTypes.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp
index 6077e4d9dd7..7c996f5eca2 100644
--- a/mlir/lib/IR/StandardTypes.cpp
+++ b/mlir/lib/IR/StandardTypes.cpp
@@ -28,6 +28,32 @@ using namespace mlir;
using namespace mlir::detail;
//===----------------------------------------------------------------------===//
+// Type
+//===----------------------------------------------------------------------===//
+
+bool Type::isBF16() { return getKind() == StandardTypes::BF16; }
+bool Type::isF16() { return getKind() == StandardTypes::F16; }
+bool Type::isF32() { return getKind() == StandardTypes::F32; }
+bool Type::isF64() { return getKind() == StandardTypes::F64; }
+
+bool Type::isIndex() { return isa<IndexType>(); }
+
+/// Return true if this is an integer type with the specified width.
+bool Type::isInteger(unsigned width) {
+ if (auto intTy = dyn_cast<IntegerType>())
+ return intTy.getWidth() == width;
+ return false;
+}
+
+bool Type::isIntOrIndex() { return isa<IndexType>() || isa<IntegerType>(); }
+
+bool Type::isIntOrIndexOrFloat() {
+ return isa<IndexType>() || isa<IntegerType>() || isa<FloatType>();
+}
+
+bool Type::isIntOrFloat() { return isa<IntegerType>() || isa<FloatType>(); }
+
+//===----------------------------------------------------------------------===//
// Integer Type
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud