Unverified Commit bbab5e47 authored by Kiran Chandramohan's avatar Kiran Chandramohan Committed by GitHub
Browse files

[MLIR][OpenMP] Use opaque pointers in OpenMP translation tests 2/2 (#70138)

Second half of the tests switching to opaque pointers. All are the
target related tests.

Removes mlir/test/Target/LLVMIR/openmp-reduction-typed-pointers.mlir,
since this seems to be added to test the typed pointers and probably not
needed anymore.
parent ea99df2e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -15,16 +15,16 @@ module attributes {omp.is_target_device = true} {
  }
                                                            
  llvm.func @_QQmain() attributes {} {
    %0 = llvm.mlir.addressof @_QMtest_0Esp : !llvm.ptr<i32>
    %0 = llvm.mlir.addressof @_QMtest_0Esp : !llvm.ptr
  
  // CHECK-DAG:   omp.target:                                       ; preds = %user_code.entry
  // CHECK-DAG: %1 = load ptr, ptr @_QMtest_0Esp_decl_tgt_ref_ptr, align 8
  // CHECK-DAG: store i32 1, ptr %1, align 4
  // CHECK-DAG: br label %omp.region.cont
    %map = omp.map_info var_ptr(%0 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
    omp.target   map_entries(%map : !llvm.ptr<i32>) {
    %map = omp.map_info var_ptr(%0 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    omp.target   map_entries(%map : !llvm.ptr) {
      %1 = llvm.mlir.constant(1 : i32) : i32
      llvm.store %1, %0 : !llvm.ptr<i32>
      llvm.store %1, %0 : i32, !llvm.ptr
      omp.terminator
    }

+15 −15
Original line number Diff line number Diff line
@@ -102,30 +102,30 @@ module attributes {llvm.target_triple = "x86_64-unknown-linux-gnu", omp.is_targe
  // CHECK-DAG: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [31 x i8] c"_QMtest_0Ept1_decl_tgt_ref_ptr\00"
  // CHECK-DAG: @.omp_offloading.entry._QMtest_0Ept1_decl_tgt_ref_ptr = weak constant %struct.__tgt_offload_entry { ptr @_QMtest_0Ept1_decl_tgt_ref_ptr, ptr @.omp_offloading.entry_name{{.*}}, i64 8, i32 1, i32 0 }, section "omp_offloading_entries", align 1
  // CHECK-DAG: !{{.*}} = !{i32 {{.*}}, !"_QMtest_0Ept1_decl_tgt_ref_ptr", i32 {{.*}}, i32 {{.*}}}
  llvm.mlir.global external @_QMtest_0Ept1() {addr_space = 0 : i32, omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)> {
    %0 = llvm.mlir.zero : !llvm.ptr<i32>
  llvm.mlir.global external @_QMtest_0Ept1() {addr_space = 0 : i32, omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {
    %0 = llvm.mlir.zero : !llvm.ptr
    %1 = llvm.mlir.constant(9 : i32) : i32
    %2 = llvm.mlir.zero : !llvm.ptr<i32>
    %3 = llvm.getelementptr %2[1] : (!llvm.ptr<i32>) -> !llvm.ptr<i32>
    %4 = llvm.ptrtoint %3 : !llvm.ptr<i32> to i64
    %5 = llvm.mlir.undef : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %6 = llvm.insertvalue %4, %5[1] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %2 = llvm.mlir.zero : !llvm.ptr
    %3 = llvm.getelementptr %2[1] : (!llvm.ptr) -> !llvm.ptr, i32
    %4 = llvm.ptrtoint %3 : !llvm.ptr to i64
    %5 = llvm.mlir.undef : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %6 = llvm.insertvalue %4, %5[1] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %7 = llvm.mlir.constant(20180515 : i32) : i32
    %8 = llvm.insertvalue %7, %6[2] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %8 = llvm.insertvalue %7, %6[2] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %9 = llvm.mlir.constant(0 : i32) : i32
    %10 = llvm.trunc %9 : i32 to i8
    %11 = llvm.insertvalue %10, %8[3] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %11 = llvm.insertvalue %10, %8[3] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %12 = llvm.trunc %1 : i32 to i8
    %13 = llvm.insertvalue %12, %11[4] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %13 = llvm.insertvalue %12, %11[4] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %14 = llvm.mlir.constant(1 : i32) : i32
    %15 = llvm.trunc %14 : i32 to i8
    %16 = llvm.insertvalue %15, %13[5] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %16 = llvm.insertvalue %15, %13[5] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %17 = llvm.mlir.constant(0 : i32) : i32
    %18 = llvm.trunc %17 : i32 to i8
    %19 = llvm.insertvalue %18, %16[6] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %20 = llvm.bitcast %0 : !llvm.ptr<i32> to !llvm.ptr<i32>
    %21 = llvm.insertvalue %20, %19[0] : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    llvm.return %21 : !llvm.struct<(ptr<i32>, i64, i32, i8, i8, i8, i8)>
    %19 = llvm.insertvalue %18, %16[6] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    %20 = llvm.bitcast %0 : !llvm.ptr to !llvm.ptr
    %21 = llvm.insertvalue %20, %19[0] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
    llvm.return %21 : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
  }

  // CHECK-DAG: @_QMtest_0Ept2_tar = global i32 5
+60 −60
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@

llvm.func @_QPopenmp_target_data() {
  %0 = llvm.mlir.constant(1 : i64) : i64
  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr<i32>
  %2 = omp.map_info var_ptr(%1 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
  omp.target_data map_entries(%2 : !llvm.ptr<i32>) {
  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
  %2 = omp.map_info var_ptr(%1 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data map_entries(%2 : !llvm.ptr) {
    %3 = llvm.mlir.constant(99 : i32) : i32
    llvm.store %3, %1 : !llvm.ptr<i32>
    llvm.store %3, %1 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
@@ -38,15 +38,15 @@ llvm.func @_QPopenmp_target_data() {

// -----

llvm.func @_QPopenmp_target_data_region(%1 : !llvm.ptr<array<1024 x i32>>) {
  %2 = omp.map_info var_ptr(%1 : !llvm.ptr<array<1024 x i32>>, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr<array<1024 x i32>> {name = ""}
  omp.target_data map_entries(%2 : !llvm.ptr<array<1024 x i32>>) {
llvm.func @_QPopenmp_target_data_region(%1 : !llvm.ptr) {
  %2 = omp.map_info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data map_entries(%2 : !llvm.ptr) {
    %3 = llvm.mlir.constant(99 : i32) : i32
    %4 = llvm.mlir.constant(1 : i64) : i64
    %5 = llvm.mlir.constant(1 : i64) : i64
    %6 = llvm.mlir.constant(0 : i64) : i64
    %7 = llvm.getelementptr %1[0, %6] : (!llvm.ptr<array<1024 x i32>>, i64) -> !llvm.ptr<i32>
    llvm.store %3, %7 : !llvm.ptr<i32>
    %7 = llvm.getelementptr %1[0, %6] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<1024 x i32>
    llvm.store %3, %7 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
@@ -79,29 +79,29 @@ llvm.func @_QPopenmp_target_data_region(%1 : !llvm.ptr<array<1024 x i32>>) {

// -----

llvm.func @_QPomp_target_enter_exit(%1 : !llvm.ptr<array<1024 x i32>>, %3 : !llvm.ptr<array<512 x i32>>) {
llvm.func @_QPomp_target_enter_exit(%1 : !llvm.ptr, %3 : !llvm.ptr) {
  %4 = llvm.mlir.constant(1 : i64) : i64
  %5 = llvm.alloca %4 x i32 {bindc_name = "dvc", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEdvc"} : (i64) -> !llvm.ptr<i32>
  %5 = llvm.alloca %4 x i32 {bindc_name = "dvc", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEdvc"} : (i64) -> !llvm.ptr
  %6 = llvm.mlir.constant(1 : i64) : i64
  %7 = llvm.alloca %6 x i32 {bindc_name = "i", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEi"} : (i64) -> !llvm.ptr<i32>
  %7 = llvm.alloca %6 x i32 {bindc_name = "i", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_enter_exitEi"} : (i64) -> !llvm.ptr
  %8 = llvm.mlir.constant(5 : i32) : i32
  llvm.store %8, %7 : !llvm.ptr<i32>
  llvm.store %8, %7 : i32, !llvm.ptr
  %9 = llvm.mlir.constant(2 : i32) : i32
  llvm.store %9, %5 : !llvm.ptr<i32>
  %10 = llvm.load %7 : !llvm.ptr<i32>
  llvm.store %9, %5 : i32, !llvm.ptr
  %10 = llvm.load %7 : !llvm.ptr -> i32
  %11 = llvm.mlir.constant(10 : i32) : i32
  %12 = llvm.icmp "slt" %10, %11 : i32
  %13 = llvm.load %5 : !llvm.ptr<i32>
  %map1 = omp.map_info var_ptr(%1 : !llvm.ptr<array<1024 x i32>>, !llvm.array<1024 x i32>)   map_clauses(to) capture(ByRef) -> !llvm.ptr<array<1024 x i32>> {name = ""}
  %map2 = omp.map_info var_ptr(%3 : !llvm.ptr<array<512 x i32>>, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) -> !llvm.ptr<array<512 x i32>> {name = ""}
  omp.target_enter_data   if(%12 : i1) device(%13 : i32) map_entries(%map1, %map2 : !llvm.ptr<array<1024 x i32>>, !llvm.ptr<array<512 x i32>>)
  %14 = llvm.load %7 : !llvm.ptr<i32>
  %13 = llvm.load %5 : !llvm.ptr -> i32
  %map1 = omp.map_info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
  %map2 = omp.map_info var_ptr(%3 : !llvm.ptr, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_enter_data   if(%12 : i1) device(%13 : i32) map_entries(%map1, %map2 : !llvm.ptr, !llvm.ptr)
  %14 = llvm.load %7 : !llvm.ptr -> i32
  %15 = llvm.mlir.constant(10 : i32) : i32
  %16 = llvm.icmp "sgt" %14, %15 : i32
  %17 = llvm.load %5 : !llvm.ptr<i32>
  %map3 = omp.map_info var_ptr(%1 : !llvm.ptr<array<1024 x i32>>, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr<array<1024 x i32>> {name = ""}
  %map4 = omp.map_info var_ptr(%3 : !llvm.ptr<array<512 x i32>>, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) -> !llvm.ptr<array<512 x i32>> {name = ""}
  omp.target_exit_data   if(%16 : i1) device(%17 : i32) map_entries(%map3, %map4 : !llvm.ptr<array<1024 x i32>>, !llvm.ptr<array<512 x i32>>)
  %17 = llvm.load %5 : !llvm.ptr -> i32
  %map3 = omp.map_info var_ptr(%1 : !llvm.ptr, !llvm.array<1024 x i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
  %map4 = omp.map_info var_ptr(%3 : !llvm.ptr, !llvm.array<512 x i32>)   map_clauses(exit_release_or_enter_alloc) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_exit_data   if(%16 : i1) device(%17 : i32) map_entries(%map3, %map4 : !llvm.ptr, !llvm.ptr)
  llvm.return
}

@@ -177,13 +177,13 @@ llvm.func @_QPomp_target_enter_exit(%1 : !llvm.ptr<array<1024 x i32>>, %3 : !llv

llvm.func @_QPopenmp_target_use_dev_ptr() {
  %0 = llvm.mlir.constant(1 : i64) : i64
  %a = llvm.alloca %0 x !llvm.ptr<!llvm.ptr<i32>> : (i64) -> !llvm.ptr<!llvm.ptr<i32>>
  %map1 = omp.map_info var_ptr(%a : !llvm.ptr<!llvm.ptr<i32>>, !llvm.ptr<i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr<!llvm.ptr<i32>> {name = ""}
  omp.target_data  map_entries(%map1 : !llvm.ptr<!llvm.ptr<i32>>) use_device_ptr(%a : !llvm.ptr<!llvm.ptr<i32>>)  {
  ^bb0(%arg0: !llvm.ptr<!llvm.ptr<i32>>):
  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
  %map1 = omp.map_info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data  map_entries(%map1 : !llvm.ptr) use_device_ptr(%a : !llvm.ptr)  {
  ^bb0(%arg0: !llvm.ptr):
    %1 = llvm.mlir.constant(10 : i32) : i32
    %2 = llvm.load %arg0 : !llvm.ptr<!llvm.ptr<i32>>
    llvm.store %1, %2 : !llvm.ptr<i32>
    %2 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
    llvm.store %1, %2 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
@@ -221,13 +221,13 @@ llvm.func @_QPopenmp_target_use_dev_ptr() {

llvm.func @_QPopenmp_target_use_dev_addr() {
  %0 = llvm.mlir.constant(1 : i64) : i64
  %a = llvm.alloca %0 x !llvm.ptr<!llvm.ptr<i32>> : (i64) -> !llvm.ptr<!llvm.ptr<i32>>
  %map = omp.map_info var_ptr(%a : !llvm.ptr<!llvm.ptr<i32>>, !llvm.ptr<i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr<!llvm.ptr<i32>> {name = ""}
  omp.target_data  map_entries(%map : !llvm.ptr<!llvm.ptr<i32>>) use_device_addr(%a : !llvm.ptr<!llvm.ptr<i32>>)  {
  ^bb0(%arg0: !llvm.ptr<!llvm.ptr<i32>>):
  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
  %map = omp.map_info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%a : !llvm.ptr)  {
  ^bb0(%arg0: !llvm.ptr):
    %1 = llvm.mlir.constant(10 : i32) : i32
    %2 = llvm.load %arg0 : !llvm.ptr<!llvm.ptr<i32>>
    llvm.store %1, %2 : !llvm.ptr<i32>
    %2 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
    llvm.store %1, %2 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
@@ -263,12 +263,12 @@ llvm.func @_QPopenmp_target_use_dev_addr() {

llvm.func @_QPopenmp_target_use_dev_addr_no_ptr() {
  %0 = llvm.mlir.constant(1 : i64) : i64
  %a = llvm.alloca %0 x !llvm.ptr<i32> : (i64) -> !llvm.ptr<i32>
  %map = omp.map_info var_ptr(%a : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
  omp.target_data  map_entries(%map : !llvm.ptr<i32>) use_device_addr(%a : !llvm.ptr<i32>)  {
  ^bb0(%arg0: !llvm.ptr<i32>):
  %a = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr
  %map = omp.map_info var_ptr(%a : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%a : !llvm.ptr)  {
  ^bb0(%arg0: !llvm.ptr):
    %1 = llvm.mlir.constant(10 : i32) : i32
    llvm.store %1, %arg0 : !llvm.ptr<i32>
    llvm.store %1, %arg0 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
@@ -303,18 +303,18 @@ llvm.func @_QPopenmp_target_use_dev_addr_no_ptr() {

llvm.func @_QPopenmp_target_use_dev_addr_nomap() {
  %0 = llvm.mlir.constant(1 : i64) : i64
  %a = llvm.alloca %0 x !llvm.ptr<!llvm.ptr<i32>> : (i64) -> !llvm.ptr<!llvm.ptr<i32>>
  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
  %1 = llvm.mlir.constant(1 : i64) : i64
  %b = llvm.alloca %0 x !llvm.ptr<!llvm.ptr<i32>> : (i64) -> !llvm.ptr<!llvm.ptr<i32>>
  %map = omp.map_info var_ptr(%b : !llvm.ptr<!llvm.ptr<i32>>, !llvm.ptr<i32>)   map_clauses(from) capture(ByRef) -> !llvm.ptr<!llvm.ptr<i32>> {name = ""}
  omp.target_data  map_entries(%map : !llvm.ptr<!llvm.ptr<i32>>) use_device_addr(%a : !llvm.ptr<!llvm.ptr<i32>>)  {
  ^bb0(%arg0: !llvm.ptr<!llvm.ptr<i32>>):
  %b = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
  %map = omp.map_info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data  map_entries(%map : !llvm.ptr) use_device_addr(%a : !llvm.ptr)  {
  ^bb0(%arg0: !llvm.ptr):
    %2 = llvm.mlir.constant(10 : i32) : i32
    %3 = llvm.load %arg0 : !llvm.ptr<!llvm.ptr<i32>>
    llvm.store %2, %3 : !llvm.ptr<i32>
    %3 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
    llvm.store %2, %3 : i32, !llvm.ptr
    %4 = llvm.mlir.constant(20 : i32) : i32
    %5 = llvm.load %b : !llvm.ptr<!llvm.ptr<i32>>
    llvm.store %4, %5 : !llvm.ptr<i32>
    %5 = llvm.load %b : !llvm.ptr -> !llvm.ptr
    llvm.store %4, %5 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
@@ -359,19 +359,19 @@ llvm.func @_QPopenmp_target_use_dev_addr_nomap() {

llvm.func @_QPopenmp_target_use_dev_both() {
  %0 = llvm.mlir.constant(1 : i64) : i64
  %a = llvm.alloca %0 x !llvm.ptr<!llvm.ptr<i32>> : (i64) -> !llvm.ptr<!llvm.ptr<i32>>
  %a = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
  %1 = llvm.mlir.constant(1 : i64) : i64
  %b = llvm.alloca %0 x !llvm.ptr<!llvm.ptr<i32>> : (i64) -> !llvm.ptr<!llvm.ptr<i32>>
  %map = omp.map_info var_ptr(%a : !llvm.ptr<!llvm.ptr<i32>>, !llvm.ptr<i32>)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<!llvm.ptr<i32>> {name = ""}
  %map1 = omp.map_info var_ptr(%b : !llvm.ptr<!llvm.ptr<i32>>, !llvm.ptr<i32>)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<!llvm.ptr<i32>> {name = ""}
  omp.target_data  map_entries(%map, %map1 : !llvm.ptr<!llvm.ptr<i32>>, !llvm.ptr<!llvm.ptr<i32>>) use_device_ptr(%a : !llvm.ptr<!llvm.ptr<i32>>) use_device_addr(%b : !llvm.ptr<!llvm.ptr<i32>>)  {
  ^bb0(%arg0: !llvm.ptr<!llvm.ptr<i32>>, %arg1: !llvm.ptr<!llvm.ptr<i32>>):
  %b = llvm.alloca %0 x !llvm.ptr : (i64) -> !llvm.ptr
  %map = omp.map_info var_ptr(%a : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
  %map1 = omp.map_info var_ptr(%b : !llvm.ptr, !llvm.ptr)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
  omp.target_data  map_entries(%map, %map1 : !llvm.ptr, !llvm.ptr) use_device_ptr(%a : !llvm.ptr) use_device_addr(%b : !llvm.ptr)  {
  ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
    %2 = llvm.mlir.constant(10 : i32) : i32
    %3 = llvm.load %arg0 : !llvm.ptr<!llvm.ptr<i32>>
    llvm.store %2, %3 : !llvm.ptr<i32>
    %3 = llvm.load %arg0 : !llvm.ptr -> !llvm.ptr
    llvm.store %2, %3 : i32, !llvm.ptr
    %4 = llvm.mlir.constant(20 : i32) : i32
    %5 = llvm.load %arg1 : !llvm.ptr<!llvm.ptr<i32>>
    llvm.store %4, %5 : !llvm.ptr<i32>
    %5 = llvm.load %arg1 : !llvm.ptr -> !llvm.ptr
    llvm.store %4, %5 : i32, !llvm.ptr
    omp.terminator
  }
  llvm.return
+12 −12
Original line number Diff line number Diff line
@@ -5,21 +5,21 @@ module attributes {omp.is_target_device = true} {
    %0 = llvm.mlir.constant(20 : i32) : i32
    %1 = llvm.mlir.constant(10 : i32) : i32
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i32 {bindc_name = "a", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_regionEa"} : (i64) -> !llvm.ptr<i32>
    %3 = llvm.alloca %2 x i32 {bindc_name = "a", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_regionEa"} : (i64) -> !llvm.ptr
    %4 = llvm.mlir.constant(1 : i64) : i64
    %5 = llvm.alloca %4 x i32 {bindc_name = "b", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_regionEb"} : (i64) -> !llvm.ptr<i32>
    %5 = llvm.alloca %4 x i32 {bindc_name = "b", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_regionEb"} : (i64) -> !llvm.ptr
    %6 = llvm.mlir.constant(1 : i64) : i64
    %7 = llvm.alloca %6 x i32 {bindc_name = "c", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_regionEc"} : (i64) -> !llvm.ptr<i32>
    llvm.store %1, %3 : !llvm.ptr<i32>
    llvm.store %0, %5 : !llvm.ptr<i32>
    %map1 = omp.map_info var_ptr(%3 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
    %map2 = omp.map_info var_ptr(%5 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
    %map3 = omp.map_info var_ptr(%7 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
    omp.target map_entries(%map1, %map2, %map3 : !llvm.ptr<i32>, !llvm.ptr<i32>, !llvm.ptr<i32>) {
      %8 = llvm.load %3 : !llvm.ptr<i32>
      %9 = llvm.load %5 : !llvm.ptr<i32>
    %7 = llvm.alloca %6 x i32 {bindc_name = "c", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_regionEc"} : (i64) -> !llvm.ptr
    llvm.store %1, %3 : i32, !llvm.ptr
    llvm.store %0, %5 : i32, !llvm.ptr
    %map1 = omp.map_info var_ptr(%3 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    %map2 = omp.map_info var_ptr(%5 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    %map3 = omp.map_info var_ptr(%7 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    omp.target map_entries(%map1, %map2, %map3 : !llvm.ptr, !llvm.ptr, !llvm.ptr) {
      %8 = llvm.load %3 : !llvm.ptr -> i32
      %9 = llvm.load %5 : !llvm.ptr -> i32
      %10 = llvm.add %8, %9  : i32
      llvm.store %10, %7 : !llvm.ptr<i32>
      llvm.store %10, %7 : i32, !llvm.ptr
      omp.terminator
    }
    llvm.return
+6 −6
Original line number Diff line number Diff line
@@ -3,14 +3,14 @@
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s

module attributes {omp.is_target_device = true} {
  llvm.func @writeindex_omp_outline_0_(%arg0: !llvm.ptr<i32>, %arg1: !llvm.ptr<i32>) attributes {omp.outline_parent_name = "writeindex_"} {
    %0 = omp.map_info var_ptr(%arg0 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
    %1 = omp.map_info var_ptr(%arg1 : !llvm.ptr<i32>, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr<i32> {name = ""}
    omp.target   map_entries(%0, %1 : !llvm.ptr<i32>, !llvm.ptr<i32>) {
  llvm.func @writeindex_omp_outline_0_(%arg0: !llvm.ptr, %arg1: !llvm.ptr) attributes {omp.outline_parent_name = "writeindex_"} {
    %0 = omp.map_info var_ptr(%arg0 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    %1 = omp.map_info var_ptr(%arg1 : !llvm.ptr, i32)   map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
    omp.target   map_entries(%0, %1 : !llvm.ptr, !llvm.ptr) {
      %2 = llvm.mlir.constant(20 : i32) : i32
      %3 = llvm.mlir.constant(10 : i32) : i32
      llvm.store %3, %arg0 : !llvm.ptr<i32>
      llvm.store %2, %arg1 : !llvm.ptr<i32>
      llvm.store %3, %arg0 : i32, !llvm.ptr
      llvm.store %2, %arg1 : i32, !llvm.ptr
      omp.terminator
    }
    llvm.return
Loading