[flang-commits] [flang] 7dc492e - [flang][NFC] Add tests for fir.address_of
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Apr 4 00:28:53 PDT 2022
Author: Valentin Clement
Date: 2022-04-04T09:28:44+02:00
New Revision: 7dc492ed3443751a1de079a0f7eeeeeb862483c4
URL: https://github.com/llvm/llvm-project/commit/7dc492ed3443751a1de079a0f7eeeeeb862483c4
DIFF: https://github.com/llvm/llvm-project/commit/7dc492ed3443751a1de079a0f7eeeeeb862483c4.diff
LOG: [flang][NFC] Add tests for fir.address_of
This patch adds FIR to LLVM test for fir.address_of.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: schweitz
Differential Revision: https://reviews.llvm.org/D122889
Co-authored-by: Jean Perier <jperier at nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Added:
flang/test/Fir/addrof.fir
flang/test/Fir/arrayset.fir
Modified:
Removed:
################################################################################
diff --git a/flang/test/Fir/addrof.fir b/flang/test/Fir/addrof.fir
new file mode 100644
index 0000000000000..6a89c6fa58184
--- /dev/null
+++ b/flang/test/Fir/addrof.fir
@@ -0,0 +1,11 @@
+// RUN: fir-opt %s | tco | FileCheck %s
+
+// CHECK: @var_x = external global i32
+fir.global @var_x : !fir.int<4> {}
+
+// CHECK-LABEL: define i32* @getAddressOfX
+func @getAddressOfX() -> !fir.ref<!fir.int<4>> {
+ %1 = fir.address_of(@var_x) : !fir.ref<!fir.int<4>>
+ // CHECK: ret i32* @var_x
+ return %1 : !fir.ref<!fir.int<4>>
+}
diff --git a/flang/test/Fir/arrayset.fir b/flang/test/Fir/arrayset.fir
new file mode 100644
index 0000000000000..5a818698d11a3
--- /dev/null
+++ b/flang/test/Fir/arrayset.fir
@@ -0,0 +1,24 @@
+// RUN: tco %s | FileCheck %s
+
+// CHECK-LABEL: define void @x([10 x float]* %0)
+func @x(%arr : !fir.ref<!fir.array<10xf32>>) {
+ %1 = arith.constant 0 : index
+ %2 = arith.constant 9 : index
+ %stepvar = arith.constant 1 : index
+ // CHECK: alloca [10 x float], i64 1
+ %a = fir.alloca !fir.array<10xf32>
+ fir.do_loop %iv = %1 to %2 step %stepvar unordered {
+ %3 = fir.coordinate_of %arr, %iv : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
+ // CHECK: %[[reg10:.*]] = load float, float*
+ %4 = fir.load %3 : !fir.ref<f32>
+ // CHECK: %[[reg11:.*]] = getelementptr [10 x float], [10 x float]*
+ %5 = fir.coordinate_of %a, %iv : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
+ // CHECK: store float %[[reg10]], float* %[[reg11]]
+ fir.store %4 to %5 : !fir.ref<f32>
+ }
+ %6 = fir.embox %a : (!fir.ref<!fir.array<10xf32>>) -> !fir.box<!fir.array<10xf32>>
+ fir.call @y(%6) : (!fir.box<!fir.array<10xf32>>) -> ()
+ return
+}
+
+func private @y(!fir.box<!fir.array<10xf32>>) -> ()
More information about the flang-commits
mailing list