summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
diff options
context:
space:
mode:
authorLei Zhang <antiagainst@google.com>2019-10-30 05:40:47 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-10-30 05:41:18 -0700
commit80213ba5f0d72f4c50ec641d40eed171bba464ad (patch)
tree4fdaf40d5e218ba88261386d713c39764c32ee35 /mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
parentf3efb60ccc1942796a006434bf5935659bb5e3fc (diff)
downloadbcm5719-llvm-80213ba5f0d72f4c50ec641d40eed171bba464ad.tar.gz
bcm5719-llvm-80213ba5f0d72f4c50ec641d40eed171bba464ad.zip
[spirv] Fix gen_spirv_dialect.py and add spv.Unreachable
This CL fixed gen_spirv_dialect.py to support nested delimiters when chunking existing ODS entries in .td files and to allow ops without correspondence in the spec. This is needed to pull in the definition of OpUnreachable. PiperOrigin-RevId: 277486465
Diffstat (limited to 'mlir/lib/Dialect/SPIRV/SPIRVOps.cpp')
-rw-r--r--mlir/lib/Dialect/SPIRV/SPIRVOps.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
index 8d32daadb6b..85e22a5c391 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
@@ -2286,6 +2286,26 @@ static void print(spirv::UndefOp undefOp, OpAsmPrinter &printer) {
}
//===----------------------------------------------------------------------===//
+// spv.Unreachable
+//===----------------------------------------------------------------------===//
+
+static LogicalResult verify(spirv::UnreachableOp unreachableOp) {
+ auto *op = unreachableOp.getOperation();
+ auto *block = op->getBlock();
+ // Fast track: if this is in entry block, its invalid. Otherwise, if no
+ // predecessors, it's valid.
+ if (block->isEntryBlock())
+ return unreachableOp.emitOpError("cannot be used in reachable block");
+ if (block->hasNoPredecessors())
+ return success();
+
+ // TODO(antiagainst): further verification needs to analyze reachablility from
+ // the entry block.
+
+ return success();
+}
+
+//===----------------------------------------------------------------------===//
// spv.Variable
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud