[flang] Add type conversion for !fir.box<none>

`none` is used in `fir.box` type to specify a polymorphic type.
This patch add the conversion from `!fir.box<none>` to LLVM.

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

Reviewed By: awarzynski

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
This commit is contained in:
Valentin Clement 2022-02-09 15:11:55 +01:00
parent 25098736c1
commit fd0417a3cf
No known key found for this signature in database
GPG Key ID: 086D54783C928776
2 changed files with 12 additions and 0 deletions

View File

@ -124,6 +124,10 @@ public:
return mlir::LLVM::LLVMStructType::getLiteral(&getContext(), members,
/*isPacked=*/false);
});
addConversion([&](mlir::NoneType none) {
return mlir::LLVM::LLVMStructType::getLiteral(
none.getContext(), llvm::None, /*isPacked=*/false);
});
}
// i32 is used here because LLVM wants i32 constants when indexing into struct

View File

@ -418,3 +418,11 @@ func private @foo0(%arg0: tuple<i64, !fir.box<i32>>)
func private @foo1(%arg0: !fir.type<derived8{a:i64,b:!fir.box<i32>}>)
// CHECK-LABEL: foo1
// CHECK-SAME: !llvm.struct<"derived8", (i64, struct<(ptr<i32>, i{{.*}})>)>
// -----
// Test fir.box<none> translation.
// `none` is used for polymorphic type.
func private @foo0(%arg0: !fir.box<none>)
// CHECK-LABEL: foo0
// CHECK-SAME: !llvm.ptr<struct<(ptr<struct<()>>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})>>)