Add a test.symbol_scope operation that has the SymbolTable Traits to the Test dialect
authorMehdi Amini <aminim@google.com>
Thu, 31 Oct 2019 16:49:16 +0000 (09:49 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Thu, 31 Oct 2019 16:49:42 +0000 (09:49 -0700)
PiperOrigin-RevId: 277741687

mlir/include/mlir/IR/OpBase.td
mlir/test/IR/traits.mlir
mlir/test/lib/TestDialect/TestDialect.h
mlir/test/lib/TestDialect/TestOps.td

index 6e7e0e8..d8ad2e4 100644 (file)
@@ -1285,6 +1285,8 @@ def SameOperandsAndResultElementType :
   NativeOpTrait<"SameOperandsAndResultElementType">;
 // Op is a symbol.
 def Symbol : NativeOpTrait<"Symbol">;
+// Op defines a symbol table.
+def SymbolTable : NativeOpTrait<"SymbolTable">;
 // Op is a terminator.
 def Terminator       : NativeOpTrait<"IsTerminator">;
 
index 60c2afa..69804f1 100644 (file)
@@ -205,3 +205,13 @@ func @failedSingleBlockImplicitTerminator_missing_terminator() {
   }) : () -> ()
 }
 
+// -----
+
+// Test that operation with the SymbolTable Trait define a new symbol scope.
+"test.symbol_scope"() ({
+  func @foo() {
+  }
+  "test.finish" () : () -> ()
+}) : () -> ()
+func @foo() {
+}
index ade0eb8..5be1c10 100644 (file)
@@ -30,6 +30,7 @@
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/IR/OpImplementation.h"
 #include "mlir/IR/StandardTypes.h"
+#include "mlir/IR/SymbolTable.h"
 
 namespace mlir {
 
index 1ce13c7..09603e0 100644 (file)
@@ -86,6 +86,16 @@ def MultiTensorRankOf : TEST_Op<"multi_tensor_rank_of"> {
 // Test Operands
 //===----------------------------------------------------------------------===//
 
+def SymbolScopeOp : TEST_Op<"symbol_scope",
+    [SymbolTable, SingleBlockImplicitTerminator<"TerminatorOp">]> {
+  let summary =  "operation which defines a new symbol table";
+  let regions = (region SizedRegion<1>:$region);
+}
+
+//===----------------------------------------------------------------------===//
+// Test Operands
+//===----------------------------------------------------------------------===//
+
 def MixedNormalVariadicOperandOp : TEST_Op<
     "mixed_normal_variadic_operand", [SameVariadicOperandSize]> {
   let arguments = (ins