[Mlir-commits] [mlir] 2c9d264 - [mlir][llvm] Move call and gep LLVM IR import tests.
Tobias Gysi
llvmlistbot at llvm.org
Thu Nov 17 01:41:39 PST 2022
Author: Tobias Gysi
Date: 2022-11-17T10:41:07+01:00
New Revision: 2c9d26478501588b87b0c276e69e1d797ff2efd1
URL: https://github.com/llvm/llvm-project/commit/2c9d26478501588b87b0c276e69e1d797ff2efd1
DIFF: https://github.com/llvm/llvm-project/commit/2c9d26478501588b87b0c276e69e1d797ff2efd1.diff
LOG: [mlir][llvm] Move call and gep LLVM IR import tests.
The revision moves call and gep tests to instructions.ll.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D137636
Added:
Modified:
mlir/test/Target/LLVMIR/Import/basic.ll
mlir/test/Target/LLVMIR/Import/instructions.ll
Removed:
mlir/test/Target/LLVMIR/Import/dynamic-gep-index.ll
################################################################################
diff --git a/mlir/test/Target/LLVMIR/Import/basic.ll b/mlir/test/Target/LLVMIR/Import/basic.ll
index 8318ff45c49d..1bbe370f43e1 100644
--- a/mlir/test/Target/LLVMIR/Import/basic.ll
+++ b/mlir/test/Target/LLVMIR/Import/basic.ll
@@ -55,14 +55,6 @@ if.end:
; CHECK-DBG: } loc(#[[UNKNOWNLOC]])
-; CHECK-LABEL: llvm.func @f6(%arg0: !llvm.ptr<func<void (i16)>>)
-define void @f6(void (i16) *%fn) {
-; CHECK: %[[c:[0-9]+]] = llvm.mlir.constant(0 : i16) : i16
-; CHECK: llvm.call %arg0(%[[c]])
- call void %fn(i16 0)
- ret void
-}
-
@_ZTIi = external dso_local constant i8*
@_ZTIii= external dso_local constant i8**
declare void @foo(i8*)
diff --git a/mlir/test/Target/LLVMIR/Import/dynamic-gep-index.ll b/mlir/test/Target/LLVMIR/Import/dynamic-gep-index.ll
deleted file mode 100644
index df072e90132f..000000000000
--- a/mlir/test/Target/LLVMIR/Import/dynamic-gep-index.ll
+++ /dev/null
@@ -1,12 +0,0 @@
-; RUN: mlir-translate --import-llvm %s | FileCheck %s
-
-%sub_struct = type { i32, i8 }
-%my_struct = type { %sub_struct, [4 x i32] }
-
-; CHECK: llvm.func @foo(%[[ARG0:.+]]: !llvm.ptr<struct<"my_struct", {{.+}}>>, %[[ARG1:.+]]: i32)
-define void @foo(%my_struct* %arg, i32 %idx) {
- ; CHECK: %[[C0:.+]] = llvm.mlir.constant(0 : i32)
- ; CHECK: llvm.getelementptr %[[ARG0]][%[[C0]], 1, %[[ARG1]]]
- %1 = getelementptr %my_struct, %my_struct* %arg, i32 0, i32 1, i32 %idx
- ret void
-}
diff --git a/mlir/test/Target/LLVMIR/Import/instructions.ll b/mlir/test/Target/LLVMIR/Import/instructions.ll
index c5322ab6f84f..ad4a981c7a6a 100644
--- a/mlir/test/Target/LLVMIR/Import/instructions.ll
+++ b/mlir/test/Target/LLVMIR/Import/instructions.ll
@@ -412,6 +412,56 @@ define void @atomic_cmpxchg(i32* %ptr1, i32 %val1, i32 %val2) {
; // -----
+; CHECK: llvm.func @fn(i32) -> f32
+declare float @fn(i32)
+
+; CHECK-LABEL: @call_fn
+; CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]
+define float @call_fn(i32 %arg1) {
+ ; CHECK: llvm.call @fn(%[[ARG1]])
+ %1 = call float @fn(i32 %arg1)
+ ret float %1
+}
+
+; // -----
+
+; CHECK-LABEL: @call_fn_ptr
+; CHECK-SAME: %[[PTR:[a-zA-Z0-9]+]]
+define void @call_fn_ptr(void (i16) *%fn) {
+ ; CHECK: %[[C0:[0-9]+]] = llvm.mlir.constant(0 : i16) : i16
+ ; CHECK: llvm.call %[[PTR]](%[[C0]])
+ call void %fn(i16 0)
+ ret void
+}
+
+; // -----
+
+; CHECK-LABEL: @gep_static_idx
+; CHECK-SAME: %[[PTR:[a-zA-Z0-9]+]]
+define void @gep_static_idx(float* %ptr) {
+ ; CHECK: %[[IDX:.+]] = llvm.mlir.constant(7 : i32)
+ ; CHECK: llvm.getelementptr %[[PTR]][%[[IDX]]] : (!llvm.ptr<f32>, i32) -> !llvm.ptr<f32>
+ %1 = getelementptr float, float* %ptr, i32 7
+ ret void
+}
+
+; // -----
+
+%sub_struct = type { i32, i8 }
+%my_struct = type { %sub_struct, [4 x i32] }
+
+; CHECK-LABEL: @gep_dynamic_idx
+; CHECK-SAME: %[[PTR:[a-zA-Z0-9]+]]
+; CHECK-SAME: %[[IDX:[a-zA-Z0-9]+]]
+define void @gep_dynamic_idx(%my_struct* %ptr, i32 %idx) {
+ ; CHECK: %[[C0:.+]] = llvm.mlir.constant(0 : i32)
+ ; CHECK: llvm.getelementptr %[[PTR]][%[[C0]], 1, %[[IDX]]]
+ %1 = getelementptr %my_struct, %my_struct* %ptr, i32 0, i32 1, i32 %idx
+ ret void
+}
+
+; // -----
+
; CHECK-LABEL: @freeze
; CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]
define void @freeze(i32 %arg1) {
More information about the Mlir-commits
mailing list