This relatively small change will allow Flang's frontend driver, `flang-new -fc1`, to consume and parse MLIR files. Semantically (i.e. from user's perspective) this is identical to reading LLVM IR files. Two file extensions are associated with MLIR files: .fir and .mlir. Note that reading MLIR files makes only sense when running one of the code-generation actions, i.e. when using one of the following action flags: -S, -emit-obj, -emit-llvm, -emit-llvm-bc. The majority of tests that required `tco` to run are updated to also run with `flang-new -fc1`. A few tests are updated to use `fir-opt` instead of `tco` (that's the preferred choice when testing a particular MLIR pass). basic-program.fir is not updated as that test is intended to verify the behaviour of `tco` specifically. Differential Revision: https://reviews.llvm.org/D126890
54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
// RUN: tco %s | FileCheck %s
|
|
// RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck %s
|
|
|
|
// Test fir.is_present and fir.absent codegen
|
|
|
|
// CHECK-LABEL: @foo1
|
|
func.func @foo1(%arg0: !fir.box<!fir.array<?xf32>>) -> i1 {
|
|
// CHECK: %[[ptr:.*]] = ptrtoint ptr %{{.*}} to i64
|
|
// CHECK: icmp ne i64 %[[ptr]], 0
|
|
%0 = fir.is_present %arg0 : (!fir.box<!fir.array<?xf32>>) -> i1
|
|
return %0 : i1
|
|
}
|
|
|
|
// CHECK-LABEL: @bar1
|
|
func.func @bar1() -> i1 {
|
|
%0 = fir.absent !fir.box<!fir.array<?xf32>>
|
|
// CHECK: call i1 @foo1(ptr null)
|
|
%1 = fir.call @foo1(%0) : (!fir.box<!fir.array<?xf32>>) -> i1
|
|
return %1 : i1
|
|
}
|
|
|
|
// CHECK-LABEL: @foo2
|
|
func.func @foo2(%arg0: !fir.ref<i64>) -> i1 {
|
|
// CHECK: %[[ptr:.*]] = ptrtoint ptr %{{.*}} to i64
|
|
// CHECK: icmp ne i64 %[[ptr]], 0
|
|
%0 = fir.is_present %arg0 : (!fir.ref<i64>) -> i1
|
|
return %0 : i1
|
|
}
|
|
|
|
// CHECK-LABEL: @bar2
|
|
func.func @bar2() -> i1 {
|
|
%0 = fir.absent !fir.ref<i64>
|
|
// CHECK: call i1 @foo2(ptr null)
|
|
%1 = fir.call @foo2(%0) : (!fir.ref<i64>) -> i1
|
|
return %1 : i1
|
|
}
|
|
|
|
// CHECK-LABEL: @foo3
|
|
func.func @foo3(%arg0: !fir.boxchar<1>) -> i1 {
|
|
// CHECK: %[[extract:.*]] = extractvalue { ptr, i64 } %{{.*}}, 0
|
|
// CHECK: %[[ptr:.*]] = ptrtoint ptr %[[extract]] to i64
|
|
// CHECK: icmp ne i64 %[[ptr]], 0
|
|
%0 = fir.is_present %arg0 : (!fir.boxchar<1>) -> i1
|
|
return %0 : i1
|
|
}
|
|
|
|
// CHECK-LABEL: @bar3
|
|
func.func @bar3() -> i1 {
|
|
%0 = fir.absent !fir.boxchar<1>
|
|
// CHECK: call i1 @foo3(ptr null, i64 undef)
|
|
%1 = fir.call @foo3(%0) : (!fir.boxchar<1>) -> i1
|
|
return %1 : i1
|
|
}
|