[spirv] NFC: Remove functions wrapping spv.module in tests
authorLei Zhang <antiagainst@google.com>
Mon, 8 Jul 2019 17:10:39 +0000 (10:10 -0700)
committerjpienaar <jpienaar@google.com>
Mon, 8 Jul 2019 19:39:35 +0000 (12:39 -0700)
Now both functions and modules are just general ops and we do not require
top-level entities in a module's block to be the old builtin functions
any more. Removing the wrapping functions to simplify the tests.

PiperOrigin-RevId: 257003572

mlir/test/SPIRV/ops.mlir
mlir/test/SPIRV/structure-ops.mlir

index 739b04dde5519f527c0ce29dcb5ea4eab11e9fb0..062e044460b650c7b0297c01989ff0d7b13e210e 100644 (file)
@@ -173,14 +173,12 @@ func @aligned_load_incorrect_attributes() -> () {
 
 // -----
 
-func @return_mismatch_func_signature() -> () {
-  spv.module "Logical" "VulkanKHR" {
-    func @work() -> (i32) {
-      // expected-error @+1 {{cannot be used in functions returning value}}
-      spv.Return
-    }
+// Return mismatches function signature
+spv.module "Logical" "VulkanKHR" {
+  func @work() -> (i32) {
+    // expected-error @+1 {{cannot be used in functions returning value}}
+    spv.Return
   }
-  return
 }
 
 // -----
index 924cae4c51c9ca90680b746773b9d6ca5a7b5bac..8ab5b3a1a21374188cf60aaefb198c55a6693707 100644 (file)
@@ -1,8 +1,5 @@
 // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
 
-// TODO(antiagainst): Remove the wrapping functions once MLIR is moved to
-// be generally region-based.
-
 //===----------------------------------------------------------------------===//
 // spv.constant
 //===----------------------------------------------------------------------===//
@@ -59,133 +56,103 @@ func @value_result_type_mismatch() -> () {
 // spv.module
 //===----------------------------------------------------------------------===//
 
-// CHECK-LABEL: func @module_without_cap_ext
-func @module_without_cap_ext() -> () {
-  // CHECK: spv.module "Logical" "VulkanKHR"
-  spv.module "Logical" "VulkanKHR" { }
-  return
-}
+// Module without capability and extension
+// CHECK: spv.module "Logical" "VulkanKHR"
+spv.module "Logical" "VulkanKHR" { }
 
-// CHECK-LABEL: func @module_with_cap_ext
-func @module_with_cap_ext() -> () {
-  // CHECK: attributes {capability = ["Shader"], extension = ["SPV_KHR_16bit_storage"]}
-  spv.module "Logical" "VulkanKHR" { } attributes {
-    capability = ["Shader"],
-    extension = ["SPV_KHR_16bit_storage"]
-  }
-  return
+// Module with capability and extension
+// CHECK: attributes {capability = ["Shader"], extension = ["SPV_KHR_16bit_storage"]}
+spv.module "Logical" "VulkanKHR" { } attributes {
+  capability = ["Shader"],
+  extension = ["SPV_KHR_16bit_storage"]
 }
 
-// CHECK-LABEL: func @module_with_explict_module_end
-func @module_with_explict_module_end() -> () {
-  // CHECK: spv.module
-  spv.module "Logical" "VulkanKHR" {
-    spv._module_end
-  }
-  return
+// Module with explict spv._module_end
+// CHECK: spv.module
+spv.module "Logical" "VulkanKHR" {
+  spv._module_end
 }
 
-// CHECK-LABEL: func @module_with_func
-func @module_with_func() -> () {
-  // CHECK: spv.module
-  spv.module "Logical" "VulkanKHR" {
-    func @do_nothing() -> () {
-      spv.Return
-    }
+// Module with function
+// CHECK: spv.module
+spv.module "Logical" "VulkanKHR" {
+  func @do_nothing() -> () {
+    spv.Return
   }
-  return
 }
 
 // -----
 
-func @missing_addressing_model() -> () {
-  // expected-error@+1 {{custom op 'spv.module' expected addressing_model attribute specified as string}}
-  spv.module { }
-  return
-}
+// Missing addressing model
+// expected-error@+1 {{custom op 'spv.module' expected addressing_model attribute specified as string}}
+spv.module { }
 
 // -----
 
-func @wrong_addressing_model() -> () {
-  // expected-error@+1 {{custom op 'spv.module' invalid addressing_model attribute specification: "Physical"}}
-  spv.module "Physical" { }
-  return
-}
+// Wrong addressing model
+// expected-error@+1 {{custom op 'spv.module' invalid addressing_model attribute specification: "Physical"}}
+spv.module "Physical" { }
 
 // -----
 
-func @missing_memory_model() -> () {
-  // expected-error@+1 {{custom op 'spv.module' expected memory_model attribute specified as string}}
-  spv.module "Logical" { }
-  return
-}
+// Missing memory model
+// expected-error@+1 {{custom op 'spv.module' expected memory_model attribute specified as string}}
+spv.module "Logical" { }
 
 // -----
 
-func @wrong_memory_model() -> () {
-  // expected-error@+1 {{custom op 'spv.module' invalid memory_model attribute specification: "Bla"}}
-  spv.module "Logical" "Bla" { }
-  return
-}
+// Wrong memory model
+// expected-error@+1 {{custom op 'spv.module' invalid memory_model attribute specification: "Bla"}}
+spv.module "Logical" "Bla" { }
 
 // -----
 
-func @module_with_multiple_blocks() -> () {
-  // expected-error @+1 {{failed to verify constraint: region with 1 blocks}}
-  spv.module "Logical" "VulkanKHR" {
-  ^first:
-    spv.Return
-  ^second:
-    spv.Return
-  }
-  return
+// Module_with_multiple_blocks
+// expected-error @+1 {{failed to verify constraint: region with 1 blocks}}
+spv.module "Logical" "VulkanKHR" {
+^first:
+  spv.Return
+^second:
+  spv.Return
 }
 
 // -----
 
-func @use_non_spv_op_inside_module() -> () {
-  spv.module "Logical" "VulkanKHR" {
-    // expected-error @+1 {{'spv.module' can only contain func and spv.* ops}}
-    "dialect.op"() : () -> ()
-  }
-  return
+// Use non SPIR-V op inside.module
+spv.module "Logical" "VulkanKHR" {
+  // expected-error @+1 {{'spv.module' can only contain func and spv.* ops}}
+  "dialect.op"() : () -> ()
 }
 
 // -----
 
-func @use_non_spv_op_inside_func() -> () {
-  spv.module "Logical" "VulkanKHR" {
-    func @do_nothing() -> () {
-      // expected-error @+1 {{functions in 'spv.module' can only contain spv.* ops}}
-      "dialect.op"() : () -> ()
-    }
+// Use non SPIR-V op inside function
+spv.module "Logical" "VulkanKHR" {
+  func @do_nothing() -> () {
+    // expected-error @+1 {{functions in 'spv.module' can only contain spv.* ops}}
+    "dialect.op"() : () -> ()
   }
-  return
 }
 
 // -----
 
-func @use_extern_func() -> () {
-  spv.module "Logical" "VulkanKHR" {
-    // expected-error @+1 {{'spv.module' cannot contain external functions}}
-    func @extern() -> ()
-  }
-  return
+// Use external function
+spv.module "Logical" "VulkanKHR" {
+  // expected-error @+1 {{'spv.module' cannot contain external functions}}
+  func @extern() -> ()
 }
 
 // -----
 
-func @module_with_nested_func() -> () {
-  spv.module "Logical" "VulkanKHR" {
-    func @outer_func() -> () {
-      // expected-error @+1 {{'spv.module' cannot contain nested functions}}
-      func @inner_func() -> () {
-        spv.Return
-      }
+// Module with nested function
+spv.module "Logical" "VulkanKHR" {
+  func @outer_func() -> () {
+    // expected-error @+1 {{'spv.module' cannot contain nested functions}}
+    func @inner_func() -> () {
       spv.Return
     }
+    spv.Return
   }
-  return
 }
 
 // -----