forked from OSchip/llvm-project
[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:
parent
25098736c1
commit
fd0417a3cf
|
@ -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
|
||||
|
|
|
@ -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{{.*}})>>)
|
||||
|
|
Loading…
Reference in New Issue