brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · 99fc012 Raw
121 lines · plain
1// RUN: fir-opt %s --split-input-file --pass-pipeline="builtin.module(func.func(test-acc-pointer-like-interface{test-mode=copy}))" 2>&1 | FileCheck %s2 3// The tests here use a synthetic hlfir.declare in order to ensure that the hlfir dialect is4// loaded. This is required because the pass used is part of OpenACC test passes outside of5// flang and the APIs being test may generate hlfir even when it does not appear.6 7func.func @test_copy_scalar() {8  %src = fir.alloca f32 {test.src_ptr}9  %dest = fir.alloca f32 {test.dest_ptr}10  %var = fir.alloca f3211  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)12  // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca f32 {test.src_ptr} to destination: %{{.*}} = fir.alloca f32 {test.dest_ptr}13  // CHECK: Generated: %{{.*}} = fir.load %{{.*}} : !fir.ref<f32>14  // CHECK: Generated: fir.store %{{.*}} to %{{.*}} : !fir.ref<f32>15  return16}17 18// -----19 20func.func @test_copy_static_array() {21  %src = fir.alloca !fir.array<10x20xf32> {test.src_ptr}22  %dest = fir.alloca !fir.array<10x20xf32> {test.dest_ptr}23  %var = fir.alloca f3224  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)25  // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca !fir.array<10x20xf32> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.array<10x20xf32> {test.dest_ptr}26  // CHECK: Generated: hlfir.assign %{{.*}} to %{{.*}} : !fir.ref<!fir.array<10x20xf32>>, !fir.ref<!fir.array<10x20xf32>>27  return28}29 30// -----31 32func.func @test_copy_derived_type() {33  %src = fir.alloca !fir.type<_QTt{i:i32}> {test.src_ptr}34  %dest = fir.alloca !fir.type<_QTt{i:i32}> {test.dest_ptr}35  %var = fir.alloca f3236  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)37  // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca !fir.type<_QTt{i:i32}> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.type<_QTt{i:i32}> {test.dest_ptr}38  // CHECK: Generated: hlfir.assign %{{.*}} to %{{.*}} : !fir.ref<!fir.type<_QTt{i:i32}>>, !fir.ref<!fir.type<_QTt{i:i32}>>39  return40}41 42// -----43 44func.func @test_copy_heap_scalar() {45  %src = fir.allocmem f32 {test.src_ptr}46  %dest = fir.allocmem f32 {test.dest_ptr}47  %var = fir.alloca f3248  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)49  // CHECK: Successfully generated copy from source: %{{.*}} = fir.allocmem f32 {test.src_ptr} to destination: %{{.*}} = fir.allocmem f32 {test.dest_ptr}50  // CHECK: Generated: %{{.*}} = fir.load %{{.*}} : !fir.heap<f32>51  // CHECK: Generated: fir.store %{{.*}} to %{{.*}} : !fir.heap<f32>52  return53}54 55// -----56 57func.func @test_copy_static_char() {58  %src = fir.alloca !fir.char<1,10> {test.src_ptr}59  %dest = fir.alloca !fir.char<1,10> {test.dest_ptr}60  %var = fir.alloca f3261  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)62  // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca !fir.char<1,10> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.char<1,10> {test.dest_ptr}63  // CHECK: Generated: hlfir.assign %{{.*}} to %{{.*}} : !fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>64  return65}66 67// -----68 69func.func @test_copy_mismatched_types_fails() {70  %src = fir.alloca f32 {test.src_ptr}71  %dest = fir.alloca f64 {test.dest_ptr}72  %var = fir.alloca f3273  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)74  // CHECK: Failed to generate copy from source: %{{.*}} = fir.alloca f32 {test.src_ptr} to destination: %{{.*}} = fir.alloca f64 {test.dest_ptr}75  return76}77 78// -----79 80func.func @test_copy_mismatched_shapes_fails() {81  %src = fir.alloca !fir.array<10xf32> {test.src_ptr}82  %dest = fir.alloca !fir.array<20xf32> {test.dest_ptr}83  %var = fir.alloca f3284  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)85  // CHECK: Failed to generate copy from source: %{{.*}} = fir.alloca !fir.array<10xf32> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.array<20xf32> {test.dest_ptr}86  return87}88 89// -----90 91func.func @test_copy_dynamic_array_fails(%arg0: !fir.ref<!fir.array<?xf32>>, %arg1: !fir.ref<!fir.array<?xf32>>) {92  %src = fir.convert %arg0 {test.src_ptr} : (!fir.ref<!fir.array<?xf32>>) -> !fir.llvm_ptr<!fir.array<?xf32>>93  %dest = fir.convert %arg1 {test.dest_ptr} : (!fir.ref<!fir.array<?xf32>>) -> !fir.llvm_ptr<!fir.array<?xf32>>94  %var = fir.alloca f3295  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)96  // CHECK: Failed to generate copy from source: %{{.*}} = fir.convert %{{.*}} {test.src_ptr} : (!fir.ref<!fir.array<?xf32>>) -> !fir.llvm_ptr<!fir.array<?xf32>> to destination: %{{.*}} = fir.convert %{{.*}} {test.dest_ptr} : (!fir.ref<!fir.array<?xf32>>) -> !fir.llvm_ptr<!fir.array<?xf32>>97  return98}99 100// -----101 102func.func @test_copy_unlimited_polymorphic_fails() {103  %src = fir.alloca !fir.class<none> {test.src_ptr}104  %dest = fir.alloca !fir.class<none> {test.dest_ptr}105  %var = fir.alloca f32106  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)107  // CHECK: Failed to generate copy from source: %{{.*}} = fir.alloca !fir.class<none> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.class<none> {test.dest_ptr}108  return109}110 111// -----112 113func.func @test_copy_dynamic_char_fails(%arg0: !fir.ref<!fir.char<1,?>>, %arg1: !fir.ref<!fir.char<1,?>>) {114  %src = fir.convert %arg0 {test.src_ptr} : (!fir.ref<!fir.char<1,?>>) -> !fir.llvm_ptr<!fir.char<1,?>>115  %dest = fir.convert %arg1 {test.dest_ptr} : (!fir.ref<!fir.char<1,?>>) -> !fir.llvm_ptr<!fir.char<1,?>>116  %var = fir.alloca f32117  %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)118  // CHECK: Failed to generate copy from source: %{{.*}} = fir.convert %{{.*}} {test.src_ptr} : (!fir.ref<!fir.char<1,?>>) -> !fir.llvm_ptr<!fir.char<1,?>> to destination: %{{.*}} = fir.convert %{{.*}} {test.dest_ptr} : (!fir.ref<!fir.char<1,?>>) -> !fir.llvm_ptr<!fir.char<1,?>>119  return120}121