brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · fa330b6 Raw
36 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3// This tests the replacement of operations for `declare target to` with the4// generated `declare target to` global variable inside of target op regions when5// lowering to IR for device. Unfortunately, as the host file is not passed as a6// module attribute, we miss out on the metadata and entry info.7 8module attributes {llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, omp.is_target_device = true} {9  // CHECK-DAG: @_QMtest_0Ezii = global [11 x float] zeroinitializer10  llvm.mlir.global external @_QMtest_0Ezii() {addr_space = 0 : i32, omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : !llvm.array<11 x f32> {11    %0 = llvm.mlir.zero : !llvm.array<11 x f32>12    llvm.return %0 : !llvm.array<11 x f32>13  }14 15  // CHECK-LABEL: define weak_odr protected amdgpu_kernel void @{{.*}}(ptr %{{.*}}) {{.*}} {16  // CHECK-DAG:   omp.target:17  // CHECK-DAG: store float 1.000000e+00, ptr @_QMtest_0Ezii, align 418  // CHECK-DAG: br label %omp.region.cont19  llvm.func @_QQmain() {20    %0 = llvm.mlir.constant(1 : index) : i6421    %1 = llvm.mlir.constant(0 : index) : i6422    %2 = llvm.mlir.constant(11 : index) : i6423    %3 = llvm.mlir.addressof @_QMtest_0Ezii : !llvm.ptr24    %4 = omp.map.bounds lower_bound(%1 : i64) upper_bound(%2 : i64) extent(%2 : i64) stride(%0 : i64) start_idx(%1 : i64) {stride_in_bytes = true}25    %5 = omp.map.info var_ptr(%3 : !llvm.ptr, !llvm.array<11 x f32>) map_clauses(tofrom) capture(ByRef) bounds(%4) -> !llvm.ptr26    omp.target map_entries(%5 -> %arg0 : !llvm.ptr) {27      %6 = llvm.mlir.constant(1.0 : f32) : f3228      %7 = llvm.mlir.constant(0 : i64) : i6429      %8 = llvm.getelementptr %arg0[%7] : (!llvm.ptr, i64) -> !llvm.ptr, f3230      llvm.store %6, %8 : f32, !llvm.ptr31      omp.terminator32    }33    llvm.return34  }35}36