diff --git a/flang/test/Fir/addrof.fir b/flang/test/Fir/addrof.fir new file mode 100644 --- /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> { + %1 = fir.address_of(@var_x) : !fir.ref> + // CHECK: ret i32* @var_x + return %1 : !fir.ref> +} diff --git a/flang/test/Fir/arrayset.fir b/flang/test/Fir/arrayset.fir new file mode 100644 --- /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>) { + %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>, index) -> !fir.ref + // CHECK: %[[reg10:.*]] = load float, float* + %4 = fir.load %3 : !fir.ref + // CHECK: %[[reg11:.*]] = getelementptr [10 x float], [10 x float]* + %5 = fir.coordinate_of %a, %iv : (!fir.ref>, index) -> !fir.ref + // CHECK: store float %[[reg10]], float* %[[reg11]] + fir.store %4 to %5 : !fir.ref + } + %6 = fir.embox %a : (!fir.ref>) -> !fir.box> + fir.call @y(%6) : (!fir.box>) -> () + return +} + +func private @y(!fir.box>) -> ()