[flang-commits] [flang] b19cbda - [flang][NFC] Add embox test with character

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Fri Jul 1 12:49:29 PDT 2022


Author: Valentin Clement
Date: 2022-07-01T21:49:20+02:00
New Revision: b19cbda45a01807db0cd39ada302e27ac8e5ccb5

URL: https://github.com/llvm/llvm-project/commit/b19cbda45a01807db0cd39ada302e27ac8e5ccb5
DIFF: https://github.com/llvm/llvm-project/commit/b19cbda45a01807db0cd39ada302e27ac8e5ccb5.diff

LOG: [flang][NFC] Add embox test with character

This test is added to check for multidimensional descriptor of array
substring/derived type component array.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D128990

Co-authored-by: Jean Perier <jperier at nvidia.com>

Added: 
    

Modified: 
    flang/test/Fir/embox.fir

Removed: 
    


################################################################################
diff  --git a/flang/test/Fir/embox.fir b/flang/test/Fir/embox.fir
index aec11dd19ddf7..12b956dff6238 100644
--- a/flang/test/Fir/embox.fir
+++ b/flang/test/Fir/embox.fir
@@ -61,6 +61,29 @@ func.func @_QPtest_dt_slice() {
   return
 }
 
+func.func private @takesRank2CharBox(!fir.box<!fir.array<?x?x!fir.char<1,?>>>)
+
+// CHECK-LABEL: define void @emboxSubstring(
+// CHECK-SAME: ptr %[[arg0:.*]])
+func.func @emboxSubstring(%arg0: !fir.ref<!fir.array<2x3x!fir.char<1,4>>>) {
+  %c2 = arith.constant 2 : index
+  %c3 = arith.constant 3 : index
+  %c1 = arith.constant 1 : index
+  %c1_i64 = arith.constant 1 : i64
+  %c2_i64 = arith.constant 2 : i64
+  %0 = fir.shape %c2, %c3 : (index, index) -> !fir.shape<2>
+  %1 = fir.slice %c1, %c2, %c1, %c1, %c3, %c1 substr %c1_i64, %c2_i64 : (index, index, index, index, index, index, i64, i64) -> !fir.slice<2>
+  %2 = fir.embox %arg0(%0) [%1] : (!fir.ref<!fir.array<2x3x!fir.char<1,4>>>, !fir.shape<2>, !fir.slice<2>) -> !fir.box<!fir.array<?x?x!fir.char<1,?>>>
+  // CHECK: %[[addr:.*]] = getelementptr [3 x [2 x [4 x i8]]], ptr %[[arg0]], i64 0, i64 0, i64 0
+  // CHECK: %[[substringAddr:.*]] = getelementptr {{.*}}, ptr %[[addr]], i64 0, i64 1
+  // CHECK: insertvalue {[[descriptorType:.*]]} { ptr undef, i64 2, i32 20180515, i8 2, i8 40, i8 0, i8 0,
+  // CHECK-SAME: [2 x [3 x i64]] [{{\[}}3 x i64] [i64 1, i64 2, i64 4], [3 x i64] [i64 1, i64 3, i64 8]] },
+  // CHECK-SAME: ptr %[[substringAddr]], 0
+
+  fir.call @takesRank2CharBox(%2) : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> ()
+  return
+}
+
 func.func private @do_something(!fir.box<!fir.array<?xf32>>) -> ()
 // CHECK: define void @fir_dev_issue_1416
 // CHECK-SAME: ptr %[[base_addr:.*]], i64 %[[low:.*]], i64 %[[up:.*]], i64 %[[at:.*]])


        


More information about the flang-commits mailing list