summaryrefslogtreecommitdiff
path: root/mlir/test/Target
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/test/Target')
-rw-r--r--mlir/test/Target/Cpp/switch.mlir28
-rw-r--r--mlir/test/Target/LLVMIR/Import/debug-info.ll51
-rw-r--r--mlir/test/Target/LLVMIR/Import/global-variables.ll30
-rw-r--r--mlir/test/Target/LLVMIR/llvmir-debug.mlir38
-rw-r--r--mlir/test/Target/LLVMIR/rocdl.mlir23
5 files changed, 168 insertions, 2 deletions
diff --git a/mlir/test/Target/Cpp/switch.mlir b/mlir/test/Target/Cpp/switch.mlir
index f9b8600606ec..3339c0261794 100644
--- a/mlir/test/Target/Cpp/switch.mlir
+++ b/mlir/test/Target/Cpp/switch.mlir
@@ -17,6 +17,7 @@
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -40,6 +41,7 @@
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_ptrdiff_t() {
@@ -77,6 +79,7 @@ func.func @emitc_switch_ptrdiff_t() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -100,6 +103,7 @@ func.func @emitc_switch_ptrdiff_t() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_ssize_t() {
@@ -138,6 +142,7 @@ func.func @emitc_switch_ssize_t() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -161,6 +166,7 @@ func.func @emitc_switch_ssize_t() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_size_t() {
@@ -199,6 +205,7 @@ func.func @emitc_switch_size_t() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -222,6 +229,7 @@ func.func @emitc_switch_size_t() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_index() {
@@ -260,6 +268,7 @@ func.func @emitc_switch_index() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -283,6 +292,7 @@ func.func @emitc_switch_index() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_opaque() {
@@ -322,6 +332,7 @@ func.func @emitc_switch_opaque() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -345,6 +356,7 @@ func.func @emitc_switch_opaque() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_i1() {
@@ -383,6 +395,7 @@ func.func @emitc_switch_i1() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -406,6 +419,7 @@ func.func @emitc_switch_i1() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_i8() {
@@ -444,6 +458,7 @@ func.func @emitc_switch_i8() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -467,6 +482,7 @@ func.func @emitc_switch_i8() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_ui8() {
@@ -505,6 +521,7 @@ func.func @emitc_switch_ui8() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -528,6 +545,7 @@ func.func @emitc_switch_ui8() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_i16() {
@@ -566,6 +584,7 @@ func.func @emitc_switch_i16() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -589,6 +608,7 @@ func.func @emitc_switch_i16() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_ui16() {
@@ -627,6 +647,7 @@ func.func @emitc_switch_ui16() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -650,6 +671,7 @@ func.func @emitc_switch_ui16() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_i32() {
@@ -688,6 +710,7 @@ func.func @emitc_switch_i32() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -711,6 +734,7 @@ func.func @emitc_switch_i32() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_ui32() {
@@ -749,6 +773,7 @@ func.func @emitc_switch_ui32() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -772,6 +797,7 @@ func.func @emitc_switch_ui32() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_i64() {
@@ -810,6 +836,7 @@ func.func @emitc_switch_i64() {
// CPP-DEFAULT: func2(v4);
// CPP-DEFAULT: break;
// CPP-DEFAULT: }
+// CPP-DEFAULT: }
// CPP-DEFAULT: return;
// CPP-DEFAULT: }
@@ -833,6 +860,7 @@ func.func @emitc_switch_i64() {
// CPP-DECLTOP: func2(v2);
// CPP-DECLTOP: break;
// CPP-DECLTOP: }
+// CPP-DECLTOP: }
// CPP-DECLTOP: return;
// CPP-DECLTOP: }
func.func @emitc_switch_ui64() {
diff --git a/mlir/test/Target/LLVMIR/Import/debug-info.ll b/mlir/test/Target/LLVMIR/Import/debug-info.ll
index 02e35ae7f0ee..09909d7d63b2 100644
--- a/mlir/test/Target/LLVMIR/Import/debug-info.ll
+++ b/mlir/test/Target/LLVMIR/Import/debug-info.ll
@@ -816,3 +816,54 @@ define void @imp_fn() !dbg !12 {
; CHECK-DAG: #[[SP_REC:.+]] = #llvm.di_subprogram<recId = distinct{{.*}}<>, isRecSelf = true>
; CHECK-DAG: #[[IE:.+]] = #llvm.di_imported_entity<tag = DW_TAG_imported_module, scope = #[[SP_REC]], entity = #[[M]]{{.*}}>
; CHECK-DAG: #[[SP:.+]] = #llvm.di_subprogram<{{.*}}name = "imp_fn"{{.*}}retainedNodes = #[[IE]]>
+
+; // -----
+
+; Test that annotations are handled correctly
+
+; CHECK-LABEL: @fn_with_annotations
+
+define void @fn_with_annotations() !dbg !12 {
+ ret void
+}
+
+!llvm.module.flags = !{!10}
+!llvm.dbg.cu = !{!4}
+
+!2 = !DIModule(scope: !4, name: "mod1", file: !3, line: 1)
+!3 = !DIFile(filename: "test.f90", directory: "")
+!4 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3)
+!8 = !DIModule(scope: !4, name: "mod1", file: !3, line: 5)
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!12 = distinct !DISubprogram(name: "fn_with_annotations", linkageName: "fn_with_annotations", scope: !3, file: !3, line: 10, type: !14, scopeLine: 10, spFlags: DISPFlagDefinition, unit: !4, annotations: !16)
+!14 = !DISubroutineType(cc: DW_CC_program, types: !15)
+!15 = !{}
+!16 = !{!17}
+!17 = !{!"foo", !"bar"}
+
+
+; CHECK-DAG: #llvm.di_subprogram<{{.*}}name = "fn_with_annotations"{{.*}}annotations = #llvm.di_annotation<name = "foo", value = "bar">>
+
+; // -----
+
+@block = common global [4 x i8] zeroinitializer, !dbg !0
+
+define void @test() !dbg !3 {
+ ret void
+}
+
+!llvm.module.flags = !{!10}
+!llvm.dbg.cu = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "alpha", scope: !2, file: !4, type: !9)
+!2 = !DICommonBlock(scope: !3, declaration: null, name: "block", file: !4, line: 3)
+!3 = distinct !DISubprogram(name: "test", scope: !4, file: !4, spFlags: DISPFlagDefinition, unit: !7)
+!4 = !DIFile(filename: "test.f90", directory: "")
+!7 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !4)
+!9 = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed)
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+
+; CHECK: #[[FILE:.+]] = #llvm.di_file<"test.f90" in "">
+; CHECK: #[[SP:.+]] = #llvm.di_subprogram<{{.*}}name = "test"{{.*}}>
+; CHECK: #llvm.di_common_block<scope = #[[SP]], name = "block", file = #[[FILE]], line = 3>
diff --git a/mlir/test/Target/LLVMIR/Import/global-variables.ll b/mlir/test/Target/LLVMIR/Import/global-variables.ll
index cac7411431ae..879e9135fe4e 100644
--- a/mlir/test/Target/LLVMIR/Import/global-variables.ll
+++ b/mlir/test/Target/LLVMIR/Import/global-variables.ll
@@ -41,6 +41,25 @@
; // -----
+; Verifies that converting a reference to a global does not convert the global
+; a second time.
+
+; CHECK-LABEL: llvm.mlir.global external constant @reference
+; CHECK-NEXT: %[[ADDR:.*]] = llvm.mlir.addressof @simple
+; CHECK-NEXT: llvm.return %[[ADDR]]
+@reference = constant ptr @simple
+
+@simple = global { ptr } { ptr null }
+
+; // -----
+
+; CHECK-LABEL: llvm.mlir.global external @recursive
+; CHECK: %[[ADDR:.*]] = llvm.mlir.addressof @recursive
+; CHECK: llvm.return %[[ADDR]]
+@recursive = global ptr @recursive
+
+; // -----
+
; alignment attribute.
; CHECK: llvm.mlir.global private @global_int_align_32
@@ -311,3 +330,14 @@ declare void @"mlir.llvm.nameless_global_2"()
!5 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!6 = !{}
!7 = !{i32 2, !"Debug Info Version", i32 3}
+
+; // -----
+
+; Verify that unnamed globals can also be referenced before they are defined.
+
+; CHECK: llvm.mlir.global internal constant @reference()
+; CHECK: llvm.mlir.addressof @mlir.llvm.nameless_global_0 : !llvm.ptr
+@reference = internal constant ptr @0
+
+; CHECK: llvm.mlir.global private unnamed_addr constant @mlir.llvm.nameless_global_0("0\00")
+@0 = private unnamed_addr constant [2 x i8] c"0\00"
diff --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index 01194df50477..826fda60c5ef 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -89,7 +89,8 @@ llvm.func @func_no_debug() {
#spType1 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>
#sp1 = #llvm.di_subprogram<
compileUnit = #cu, scope = #module, name = "empty_types",
- file = #file, subprogramFlags = "Definition", type = #spType1
+ file = #file, subprogramFlags = "Definition", type = #spType1,
+ annotations = #llvm.di_annotation<name = "foo", value = "bar">
>
// CHECK-LABEL: define void @func_with_debug(
@@ -177,11 +178,14 @@ llvm.func @empty_types() {
// CHECK: ![[CALLEE_ARGS]] = !{![[ARG_TYPE:.*]], ![[ARG_TYPE:.*]]}
// CHECK: ![[INLINE_LOC]] = !DILocation(line: 28, column: 5,
-// CHECK: ![[EMPTY_TYPES_LOC]] = distinct !DISubprogram(name: "empty_types", scope: ![[MODULE:.*]], file: ![[CU_FILE_LOC]], type: ![[EMPTY_TYPES_TYPE:.*]], spFlags: DISPFlagDefinition
+// CHECK: ![[EMPTY_TYPES_LOC]] = distinct !DISubprogram(name: "empty_types", scope: ![[MODULE:.*]], file: ![[CU_FILE_LOC]], type: ![[EMPTY_TYPES_TYPE:.*]], spFlags: DISPFlagDefinition, unit: ![[CU_LOC]], annotations: ![[ANNOTATIONS:.*]])
// CHECK: ![[MODULE]] = !DIModule(scope: ![[CU_FILE_LOC]], name: "module", configMacros: "bar", includePath: "/", apinotes: "/", file: ![[CU_FILE_LOC]], line: 42, isDecl: true)
// CHECK: ![[EMPTY_TYPES_TYPE]] = !DISubroutineType(cc: DW_CC_normal, types: ![[EMPTY_TYPES_ARGS:.*]])
// CHECK: ![[EMPTY_TYPES_ARGS]] = !{}
+// CHECK: ![[ANNOTATIONS]] = !{![[ANNOTATION:.*]]}
+// CHECK: ![[ANNOTATION]] = !{!"foo", !"bar"}
+
// -----
#di_file = #llvm.di_file<"foo.mlir" in "/test/">
@@ -656,3 +660,33 @@ llvm.func @string_ty(%arg0: !llvm.ptr) {
// CHECK-DAG: !DIStringType(name: "character(*)", stringLength: ![[VAR:[0-9]+]], stringLengthExpression: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8), stringLocationExpression: !DIExpression(DW_OP_push_object_address, DW_OP_deref), size: 32, align: 8)
// CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "string_size"{{.*}} flags: DIFlagArtificial)
+
+// -----
+
+// Test translation of DICommonBlockAttr.
+#bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>
+#file = #llvm.di_file<"test.f90" in "">
+#cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,
+ file = #file, isOptimized = false, emissionKind = Full>
+#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",
+ file = #file, subprogramFlags = Definition>
+#di_common_block = #llvm.di_common_block<scope = #sp, name = "block",
+ file = #file, line = 3>
+#global_var = #llvm.di_global_variable<scope = #di_common_block, name = "a",
+ file = #file, line = 2, type = #bt>
+#var_expression = #llvm.di_global_variable_expression<var = #global_var,
+ expr = <>>
+
+llvm.mlir.global common @block_(dense<0> : tensor<8xi8>)
+ {dbg_expr = #var_expression} : !llvm.array<8 x i8>
+
+llvm.func @test() {
+ llvm.return
+} loc(#loc2)
+
+#loc1 = loc("test.f90":1:0)
+#loc2 = loc(fused<#sp>[#loc1])
+
+// CHECK: !DICommonBlock(scope: ![[SCOPE:[0-9]+]], declaration: null, name: "block", file: ![[FILE:[0-9]+]], line: 3)
+// CHECK: ![[SCOPE]] = {{.*}}!DISubprogram(name: "test"{{.*}})
+// CHECK: ![[FILE]] = !DIFile(filename: "test.f90"{{.*}})
diff --git a/mlir/test/Target/LLVMIR/rocdl.mlir b/mlir/test/Target/LLVMIR/rocdl.mlir
index 08c2d4e64779..97276b087b7e 100644
--- a/mlir/test/Target/LLVMIR/rocdl.mlir
+++ b/mlir/test/Target/LLVMIR/rocdl.mlir
@@ -564,11 +564,34 @@ llvm.func @rocdl_8bit_floats(%source: i32, %stoch: i32) -> i32 {
}
llvm.func @rocdl_16bit_packed_floats(%sourceA: f32, %sourceB: f32) -> vector<2xf16> {
+ // CHECK-LABEL: @rocdl_16bit_packed_floats
// CHECK: call <2 x half> @llvm.amdgcn.cvt.pkrtz(float {{.*}}, float {{.*}})
%source = rocdl.cvt.pkrtz %sourceA, %sourceB : vector<2xf16>
llvm.return %source : vector<2xf16>
}
+llvm.func @rocdl_atomic_attrs(%ptr: !llvm.ptr<1>, %data: f32) {
+ // CHECK-LABEL: @rocdl_atomic_attrs
+ // CHECK: atomicrmw
+ // CHECK-SAME: !amdgpu.ignore.denormal.mode
+ // CHECK-SAME: !amdgpu.no.fine.grained.memory
+ // CHECK-SAME: !amdgpu.no.remote.memory
+ llvm.atomicrmw fadd %ptr, %data monotonic {
+ rocdl.ignore_denormal_mode,
+ rocdl.no_fine_grained_memory,
+ rocdl.no_remote_memory} : !llvm.ptr<1>, f32
+ llvm.return
+}
+
+llvm.func @rocdl_last_use(%ptr: !llvm.ptr<1>) -> i32 {
+ // CHECK-LABEL: @rocdl_last_use
+ // CHECK: %[[ret:.+]] = load
+ // CHECK-SAME: !amdgpu.last.use
+ // CHECK: ret i32 %[[ret]]
+ %ret = llvm.load %ptr {rocdl.last_use} : !llvm.ptr<1> -> i32
+ llvm.return %ret : i32
+}
+
// CHECK-DAG: attributes #[[$KERNEL_ATTRS]] = { "amdgpu-flat-work-group-size"="1,256" "uniform-work-group-size"="true" }
// CHECK-DAG: attributes #[[$KERNEL_WORKGROUP_ATTRS]] = { "amdgpu-flat-work-group-size"="1,1024"
// CHECK-DAG: attributes #[[$KNOWN_BLOCK_SIZE_ATTRS]] = { "amdgpu-flat-work-group-size"="128,128"