Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][codegen] Add a conversion for
!fir.coordinate_of
- part 1
This patch extends the `FIRToLLVMLowering` pass in Flang by adding a hook to transform `!fir.coordinate_of` into a sequence of LLVM MLIR instructions. The following cases are currently supported: 1. the input object is a `!fir.complex` (wrapped in e.g. `!fir.ref` or `!fir.box`) 2. the input object is wrapped in a `!fir.box` (including e.g. `!fir.array`). Note that `!fir.complex` inside a `!fir.box` falls under case 1. above (i.e. it's a special case regardless of the wrapping type). This is part of the upstreaming effort from the `!fir-dev` branch in [1]. Differential Revision: https://reviews.llvm.org/D114159 Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
- Loading branch information
1 parent
cf58b9c
commit 75db341
Showing
7 changed files
with
438 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %not_todo_cmd fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s 2>&1 | FileCheck %s | ||
|
||
// `fir.coordinate_of` - derived type with `fir.len_param_index`. As | ||
// `fir.len_param_index` is not implemented yet, that's the error that's | ||
// currently being generated (this error is generated before trying to convert | ||
// `fir.coordinate_of`) | ||
func @coordinate_box_derived_with_fir_len(%arg0: !fir.box<!fir.type<derived_2{len1:i32}>>) { | ||
// CHECK: not yet implemented fir.len_param_index codegen | ||
%e = fir.len_param_index len1, !fir.type<derived_2{len1:i32}> | ||
%q = fir.coordinate_of %arg0, %e : (!fir.box<!fir.type<derived_2{len1:i32}>>, !fir.len) -> !fir.ref<i32> | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %not_todo_cmd fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s 2>&1 | FileCheck %s | ||
|
||
// CHECK: not yet implemented fir.array nested inside other array and/or derived type | ||
|
||
// `!fir.coordinate_of` - `!fir.array` inside "boxed" `!fir.type` | ||
func @coordinate_box_array_inside_derived(%arg0: !fir.box<!fir.type<derived_2{field_1:!fir.array<10 x i32>, field_2:i32}>>, %arg1 : index) { | ||
%idx0 = arith.constant 0 : i32 | ||
%q = fir.coordinate_of %arg0, %idx0, %arg1 : (!fir.box<!fir.type<derived_2{field_1:!fir.array<10 x i32>, field_2:i32}>>, i32, index) -> !fir.ref<f32> | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %not_todo_cmd fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s 2>&1 | FileCheck %s | ||
|
||
// CHECK: not yet implemented fir.array nested inside other array and/or derived type | ||
|
||
// `fir.coordinate_of` - `fir.array` inside "boxed" `!fir.type<derived_1{!fir.type<derived_2{}>}` (i.e. nested `!fir.type`) | ||
func @coordinate_box_array_inside_derived(%arg0: !fir.box<!fir.type<derived_1{field_1:!fir.type<derived_2{field_2:!fir.array<10 x i32>}>}>>, %arg1 : index) { | ||
%idx0 = arith.constant 0 : i32 | ||
%q = fir.coordinate_of %arg0, %idx0, %idx0, %arg1 : (!fir.box<!fir.type<derived_1{field_1:!fir.type<derived_2{field_2:!fir.array<10 x i32>}>}>>, i32, i32, index) -> !fir.ref<f32> | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// RUN: %not_todo_cmd fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s 2>&1 | FileCheck %s | ||
|
||
// `!fir.coordinate_of` - derived type with `!fir.len_param_index`. As | ||
// `!fir.len_param_index` is not implemented yet, the error that we hit is | ||
// related to `!fir.len_param_index` rather than `!fir.coordinate_of`. | ||
func @coordinate_box_derived_with_fir_len(%arg0: !fir.box<!fir.type<derived_2{len1:i32}>>) { | ||
// CHECK: not yet implemented fir.len_param_index codegen | ||
%e = fir.len_param_index len1, !fir.type<derived_2{len1:i32}> | ||
%q = fir.coordinate_of %arg0, %e : (!fir.box<!fir.type<derived_2{len1:i32}>>, !fir.len) -> !fir.ref<i32> | ||
return | ||
} |
Oops, something went wrong.