diff --git a/mlir/test/Target/LLVMIR/Import/basic.ll b/mlir/test/Target/LLVMIR/Import/basic.ll --- a/mlir/test/Target/LLVMIR/Import/basic.ll +++ b/mlir/test/Target/LLVMIR/Import/basic.ll @@ -55,14 +55,6 @@ ; CHECK-DBG: } loc(#[[UNKNOWNLOC]]) -; CHECK-LABEL: llvm.func @f6(%arg0: !llvm.ptr>) -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 --- 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>, %[[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 --- a/mlir/test/Target/LLVMIR/Import/instructions.ll +++ b/mlir/test/Target/LLVMIR/Import/instructions.ll @@ -412,6 +412,56 @@ ; // ----- +; 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, i32) -> !llvm.ptr + %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) {