brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.2 KiB · 03eb94a Raw
295 lines · plain
1// RUN: %flang_fc1 -emit-llvm  %s -o - | FileCheck %s2 3// UNSUPPORTED: system-windows4// Disabled on 32-bit targets due to the additional `trunc` opcodes required5// UNSUPPORTED: target-x866// UNSUPPORTED: target=sparc-{{.*}}7// UNSUPPORTED: target=sparcel-{{.*}}8 9// CHECK-LABEL: define void @omp_target_allocmem_scalar_nonchar() {10// CHECK-NEXT:    [[TMP1:%.*]] = call ptr @omp_target_alloc(i64 4, i32 0)11// CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i6412// CHECK-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr13// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP3]], i32 0)14// CHECK-NEXT:    ret void15func.func @omp_target_allocmem_scalar_nonchar() -> () {16  %device = arith.constant 0 : i3217  %1 = omp.target_allocmem %device : i32, i3218  omp.target_freemem %device, %1 : i32, i6419  return20}21 22// CHECK-LABEL: define void @omp_target_allocmem_scalars_nonchar() {23// CHECK-NEXT:    [[TMP1:%.*]] = call ptr @omp_target_alloc(i64 400, i32 0)24// CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i6425// CHECK-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr26// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP3]], i32 0)27// CHECK-NEXT:    ret void28func.func @omp_target_allocmem_scalars_nonchar() -> () {29  %device = arith.constant 0 : i3230  %0 = arith.constant 100 : index31  %1 = omp.target_allocmem %device : i32, i32, %032  omp.target_freemem %device, %1 : i32, i6433  return34}35 36// CHECK-LABEL: define void @omp_target_allocmem_scalar_char() {37// CHECK-NEXT:    [[TMP1:%.*]] = call ptr @omp_target_alloc(i64 10, i32 0)38// CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i6439// CHECK-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr40// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP3]], i32 0)41// CHECK-NEXT:    ret void42func.func @omp_target_allocmem_scalar_char() -> () {43  %device = arith.constant 0 : i3244  %1 = omp.target_allocmem %device : i32, !fir.char<1,10>45  omp.target_freemem %device, %1 : i32, i6446  return47}48 49// CHECK-LABEL: define void @omp_target_allocmem_scalar_char_kind() {50// CHECK-NEXT:    [[TMP1:%.*]] = call ptr @omp_target_alloc(i64 20, i32 0)51// CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i6452// CHECK-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr53// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP3]], i32 0)54// CHECK-NEXT:    ret void55func.func @omp_target_allocmem_scalar_char_kind() -> () {56  %device = arith.constant 0 : i3257  %1 = omp.target_allocmem %device : i32, !fir.char<2,10>58  omp.target_freemem %device, %1 : i32, i6459  return60}61 62// CHECK-LABEL: define void @omp_target_allocmem_scalar_dynchar(63// CHECK-SAME: i32 [[TMP0:%.*]]) {64// CHECK-NEXT:    [[TMP2:%.*]] = sext i32 [[TMP0]] to i6465// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 1, [[TMP2]]66// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 1, [[TMP3]]67// CHECK-NEXT:    [[TMP5:%.*]] = call ptr @omp_target_alloc(i64 [[TMP4]], i32 0)68// CHECK-NEXT:    [[TMP6:%.*]] = ptrtoint ptr [[TMP5]] to i6469// CHECK-NEXT:    [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr70// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP7]], i32 0)71// CHECK-NEXT:    ret void72func.func @omp_target_allocmem_scalar_dynchar(%l : i32) -> () {73  %device = arith.constant 0 : i3274  %1 = omp.target_allocmem %device : i32, !fir.char<1,?>(%l : i32)75  omp.target_freemem %device, %1 : i32, i6476  return77}78 79 80// CHECK-LABEL: define void @omp_target_allocmem_scalar_dynchar_kind(81// CHECK-SAME: i32 [[TMP0:%.*]]) {82// CHECK-NEXT:    [[TMP2:%.*]] = sext i32 [[TMP0]] to i6483// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 2, [[TMP2]]84// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 1, [[TMP3]]85// CHECK-NEXT:    [[TMP5:%.*]] = call ptr @omp_target_alloc(i64 [[TMP4]], i32 0)86// CHECK-NEXT:    [[TMP6:%.*]] = ptrtoint ptr [[TMP5]] to i6487// CHECK-NEXT:    [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr88// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP7]], i32 0)89// CHECK-NEXT:    ret void90func.func @omp_target_allocmem_scalar_dynchar_kind(%l : i32) -> () {91  %device = arith.constant 0 : i3292  %1 = omp.target_allocmem %device : i32, !fir.char<2,?>(%l : i32)93  omp.target_freemem %device, %1 : i32, i6494  return95}96 97 98// CHECK-LABEL: define void @omp_target_allocmem_array_of_nonchar() {99// CHECK-NEXT:    [[TMP1:%.*]] = call ptr @omp_target_alloc(i64 36, i32 0)100// CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i64101// CHECK-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr102// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP3]], i32 0)103// CHECK-NEXT:    ret void104func.func @omp_target_allocmem_array_of_nonchar() -> () {105  %device = arith.constant 0 : i32106  %1 = omp.target_allocmem %device : i32, !fir.array<3x3xi32>107  omp.target_freemem %device, %1 : i32, i64108  return109}110 111// CHECK-LABEL: define void @omp_target_allocmem_array_of_char() {112// CHECK-NEXT:    [[TMP1:%.*]] = call ptr @omp_target_alloc(i64 90, i32 0)113// CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i64114// CHECK-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr115// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP3]], i32 0)116// CHECK-NEXT:    ret void117func.func @omp_target_allocmem_array_of_char() -> () {118  %device = arith.constant 0 : i32119  %1 = omp.target_allocmem %device : i32, !fir.array<3x3x!fir.char<1,10>>120  omp.target_freemem %device, %1 : i32, i64121  return122}123 124// CHECK-LABEL: define void @omp_target_allocmem_array_of_dynchar(125// CHECK-SAME: i32 [[TMP0:%.*]]) {126// CHECK-NEXT:    [[TMP2:%.*]] = sext i32 [[TMP0]] to i64127// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 9, [[TMP2]]128// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 1, [[TMP3]]129// CHECK-NEXT:    [[TMP5:%.*]] = call ptr @omp_target_alloc(i64 [[TMP4]], i32 0)130// CHECK-NEXT:    [[TMP6:%.*]] = ptrtoint ptr [[TMP5]] to i64131// CHECK-NEXT:    [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr132// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP7]], i32 0)133// CHECK-NEXT:    ret void134func.func @omp_target_allocmem_array_of_dynchar(%l: i32) -> () {135  %device = arith.constant 0 : i32136  %1 = omp.target_allocmem %device : i32, !fir.array<3x3x!fir.char<1,?>>(%l : i32)137  omp.target_freemem %device, %1 : i32, i64138  return139}140 141 142// CHECK-LABEL: define void @omp_target_allocmem_dynarray_of_nonchar(143// CHECK-SAME: i64 [[TMP0:%.*]]) {144// CHECK-NEXT:    [[TMP2:%.*]] = mul i64 12, [[TMP0]]145// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 1, [[TMP2]]146// CHECK-NEXT:    [[TMP4:%.*]] = call ptr @omp_target_alloc(i64 [[TMP3]], i32 0)147// CHECK-NEXT:    [[TMP5:%.*]] = ptrtoint ptr [[TMP4]] to i64148// CHECK-NEXT:    [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr149// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP6]], i32 0)150// CHECK-NEXT:    ret void151func.func @omp_target_allocmem_dynarray_of_nonchar(%e: index) -> () {152  %device = arith.constant 0 : i32153  %1 = omp.target_allocmem %device : i32, !fir.array<3x?xi32>, %e154  omp.target_freemem %device, %1 : i32, i64155  return156}157 158// CHECK-LABEL: define void @omp_target_allocmem_dynarray_of_nonchar2(159// CHECK-SAME: i64 [[TMP0:%.*]]) {160// CHECK-NEXT:    [[TMP2:%.*]] = mul i64 4, [[TMP0]]161// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 [[TMP2]], [[TMP0]]162// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 1, [[TMP3]]163// CHECK-NEXT:    [[TMP5:%.*]] = call ptr @omp_target_alloc(i64 [[TMP4]], i32 0)164// CHECK-NEXT:    [[TMP6:%.*]] = ptrtoint ptr [[TMP5]] to i64165// CHECK-NEXT:    [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr166// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP7]], i32 0)167// CHECK-NEXT:    ret void168func.func @omp_target_allocmem_dynarray_of_nonchar2(%e: index) -> () {169  %device = arith.constant 0 : i32170  %1 = omp.target_allocmem %device : i32, !fir.array<?x?xi32>, %e, %e171  omp.target_freemem %device, %1 : i32, i64172  return173}174 175// CHECK-LABEL: define void @omp_target_allocmem_dynarray_of_char(176// CHECK-SAME: i64 [[TMP0:%.*]]) {177// CHECK-NEXT:    [[TMP2:%.*]] = mul i64 60, [[TMP0]]178// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 1, [[TMP2]]179// CHECK-NEXT:    [[TMP4:%.*]] = call ptr @omp_target_alloc(i64 [[TMP3]], i32 0)180// CHECK-NEXT:    [[TMP5:%.*]] = ptrtoint ptr [[TMP4]] to i64181// CHECK-NEXT:    [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr182// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP6]], i32 0)183// CHECK-NEXT:    ret void184func.func @omp_target_allocmem_dynarray_of_char(%e : index) -> () {185  %device = arith.constant 0 : i32186  %1 = omp.target_allocmem %device : i32, !fir.array<3x?x!fir.char<2,10>>, %e187  omp.target_freemem %device, %1 : i32, i64188  return189}190 191 192// CHECK-LABEL: define void @omp_target_allocmem_dynarray_of_char2(193// CHECK-SAME: i64 [[TMP0:%.*]]) {194// CHECK-NEXT:    [[TMP2:%.*]] = mul i64 20, [[TMP0]]195// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 [[TMP2]], [[TMP0]]196// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 1, [[TMP3]]197// CHECK-NEXT:    [[TMP5:%.*]] = call ptr @omp_target_alloc(i64 [[TMP4]], i32 0)198// CHECK-NEXT:    [[TMP6:%.*]] = ptrtoint ptr [[TMP5]] to i64199// CHECK-NEXT:    [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr200// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP7]], i32 0)201// CHECK-NEXT:    ret void202func.func @omp_target_allocmem_dynarray_of_char2(%e : index) -> () {203  %device = arith.constant 0 : i32204  %1 = omp.target_allocmem %device : i32, !fir.array<?x?x!fir.char<2,10>>, %e, %e205  omp.target_freemem %device, %1 : i32, i64206  return207}208 209// CHECK-LABEL: define void @omp_target_allocmem_dynarray_of_dynchar(210// CHECK-SAME: i32 [[TMP0:%.*]], i64 [[TMP1:%.*]]) {211// CHECK-NEXT:    [[TMP3:%.*]] = sext i32 [[TMP0]] to i64212// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 6, [[TMP3]]213// CHECK-NEXT:    [[TMP5:%.*]] = mul i64 [[TMP4]], [[TMP1]]214// CHECK-NEXT:    [[TMP6:%.*]] = mul i64 1, [[TMP5]]215// CHECK-NEXT:    [[TMP7:%.*]] = call ptr @omp_target_alloc(i64 [[TMP6]], i32 0)216// CHECK-NEXT:    [[TMP8:%.*]] = ptrtoint ptr [[TMP7]] to i64217// CHECK-NEXT:    [[TMP9:%.*]] = inttoptr i64 [[TMP8]] to ptr218// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP9]], i32 0)219// CHECK-NEXT:    ret void220func.func @omp_target_allocmem_dynarray_of_dynchar(%l: i32, %e : index) -> () {221  %device = arith.constant 0 : i32222  %1 = omp.target_allocmem %device : i32, !fir.array<3x?x!fir.char<2,?>>(%l : i32), %e223  omp.target_freemem %device, %1 : i32, i64224  return225}226 227// CHECK-LABEL: define void @omp_target_allocmem_dynarray_of_dynchar2(228// CHECK-SAME: i32 [[TMP0:%.*]], i64 [[TMP1:%.*]]) {229// CHECK-NEXT:    [[TMP3:%.*]] = sext i32 [[TMP0]] to i64230// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 2, [[TMP3]]231// CHECK-NEXT:    [[TMP5:%.*]] = mul i64 [[TMP4]], [[TMP1]]232// CHECK-NEXT:    [[TMP6:%.*]] = mul i64 [[TMP5]], [[TMP1]]233// CHECK-NEXT:    [[TMP7:%.*]] = mul i64 1, [[TMP6]]234// CHECK-NEXT:    [[TMP8:%.*]] = call ptr @omp_target_alloc(i64 [[TMP7]], i32 0)235// CHECK-NEXT:    [[TMP9:%.*]] = ptrtoint ptr [[TMP8]] to i64236// CHECK-NEXT:    [[TMP10:%.*]] = inttoptr i64 [[TMP9]] to ptr237// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP10]], i32 0)238// CHECK-NEXT:    ret void239func.func @omp_target_allocmem_dynarray_of_dynchar2(%l: i32, %e : index) -> () {240  %device = arith.constant 0 : i32241  %1 = omp.target_allocmem %device : i32, !fir.array<?x?x!fir.char<2,?>>(%l : i32), %e, %e242  omp.target_freemem %device, %1 : i32, i64243  return244}245 246// CHECK-LABEL: define void @omp_target_allocmem_array_with_holes_nonchar(247// CHECK-SAME: i64 [[TMP0:%.*]], i64 [[TMP1:%.*]]) {248// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 240, [[TMP0]]249// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 [[TMP3]], [[TMP1]]250// CHECK-NEXT:    [[TMP5:%.*]] = mul i64 1, [[TMP4]]251// CHECK-NEXT:    [[TMP6:%.*]] = call ptr @omp_target_alloc(i64 [[TMP5]], i32 0)252// CHECK-NEXT:    [[TMP7:%.*]] = ptrtoint ptr [[TMP6]] to i64253// CHECK-NEXT:    [[TMP8:%.*]] = inttoptr i64 [[TMP7]] to ptr254// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP8]], i32 0)255// CHECK-NEXT:    ret void256func.func @omp_target_allocmem_array_with_holes_nonchar(%0 : index, %1 : index) -> () {257  %device = arith.constant 0 : i32258  %2 = omp.target_allocmem %device : i32, !fir.array<4x?x3x?x5xi32>, %0, %1259  omp.target_freemem %device, %2 : i32, i64260  return261}262 263// CHECK-LABEL: define void @omp_target_allocmem_array_with_holes_char(264// CHECK-SAME: i64 [[TMP0:%.*]]) {265// CHECK-NEXT:    [[TMP2:%.*]] = mul i64 240, [[TMP0]]266// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 1, [[TMP2]]267// CHECK-NEXT:    [[TMP4:%.*]] = call ptr @omp_target_alloc(i64 [[TMP3]], i32 0)268// CHECK-NEXT:    [[TMP5:%.*]] = ptrtoint ptr [[TMP4]] to i64269// CHECK-NEXT:    [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr270// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP6]], i32 0)271// CHECK-NEXT:    ret void272func.func @omp_target_allocmem_array_with_holes_char(%e: index) -> () {273  %device = arith.constant 0 : i32274  %1 = omp.target_allocmem %device : i32, !fir.array<3x?x4x!fir.char<2,10>>, %e275  omp.target_freemem %device, %1 : i32, i64276  return277}278 279// CHECK-LABEL: define void @omp_target_allocmem_array_with_holes_dynchar(280// CHECK-SAME: i64 [[TMP0:%.*]], i64 [[TMP1:%.*]]) {281// CHECK-NEXT:    [[TMP3:%.*]] = mul i64 24, [[TMP0]]282// CHECK-NEXT:    [[TMP4:%.*]] = mul i64 [[TMP3]], [[TMP1]]283// CHECK-NEXT:    [[TMP5:%.*]] = mul i64 1, [[TMP4]]284// CHECK-NEXT:    [[TMP6:%.*]] = call ptr @omp_target_alloc(i64 [[TMP5]], i32 0)285// CHECK-NEXT:    [[TMP7:%.*]] = ptrtoint ptr [[TMP6]] to i64286// CHECK-NEXT:    [[TMP8:%.*]] = inttoptr i64 [[TMP7]] to ptr287// CHECK-NEXT:    call void @omp_target_free(ptr [[TMP8]], i32 0)288// CHECK-NEXT:    ret void289func.func @omp_target_allocmem_array_with_holes_dynchar(%arg0: index, %arg1: index) -> () {290  %device = arith.constant 0 : i32291  %1 = omp.target_allocmem %device : i32, !fir.array<3x?x4x!fir.char<2,?>>(%arg0 : index), %arg1292  omp.target_freemem %device, %1 : i32, i64293  return294}295