xref: /llvm-project/mlir/test/IR/module-op.mlir (revision 973ddb7d6e96e744a785ba64c065b592987a005f)
1// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -mlir-print-debuginfo -mlir-print-local-scope  | FileCheck %s
2
3// CHECK: module {
4module {
5}
6
7// -----
8
9// CHECK: module attributes {foo.attr = true} {
10module attributes {foo.attr = true} {
11}
12
13// -----
14
15// CHECK: module {
16module {
17  // CHECK-NEXT: "foo.result_op"() : () -> i32
18  %result = "foo.result_op"() : () -> i32
19}
20
21// -----
22
23// Check that a top-level module is always created, with location info.
24// CHECK: module {
25// CHECK-NEXT: } loc({{.*}}module-op.mlir{{.*}})
26
27// -----
28
29// Check that the top-level module can be defined via a single module operation.
30// CHECK: module {
31// CHECK-NOT: module {
32module {
33}
34
35// -----
36
37// Check that the implicit top-level module is also a name scope for SSA
38// values.  This should not crash.
39// CHECK: module {
40// CHECK: %{{.*}} = "op"
41// CHECK: }
42%0 = "op"() : () -> i32
43
44// -----
45
46// CHECK-LABEL: module @foo
47// CHECK-NOT: attributes
48module @foo {
49  // CHECK: module
50  module {
51    // CHECK: module @bar attributes
52    module @bar attributes {foo.bar} {
53    }
54  }
55}
56
57// -----
58
59// expected-error@below {{expects at most one data layout attribute}}
60// expected-note@below {{'test.another_attribute' is a data layout attribute}}
61// expected-note@below {{'test.random_attribute' is a data layout attribute}}
62module attributes { test.random_attribute = #dlti.dl_spec<>,
63                    test.another_attribute = #dlti.dl_spec<>} {
64}
65