[Flang] Notify conversion failure for Proc ops, types
Add the FIR to LLVM conversion patterns for the BoxProcHostOp, EmboxProcOp, and UnboxProcOp ops and the boxproc type. These are currently unimplemented. Implementation will come at a later time when support for Fortran 2003 procedure pointer feature is added. Reviewed By: clementval, rovka Differential Revision: https://reviews.llvm.org/D113879 Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
This commit is contained in:
parent
00200dbda3
commit
cc505c0bb7
|
|
@ -532,6 +532,20 @@ struct StringLitOpConversion : public FIROpConversion<fir::StringLitOp> {
|
|||
}
|
||||
};
|
||||
|
||||
/// Lower `fir.boxproc_host` operation. Extracts the host pointer from the
|
||||
/// boxproc.
|
||||
/// TODO: Part of supporting Fortran 2003 procedure pointers.
|
||||
struct BoxProcHostOpConversion : public FIROpConversion<fir::BoxProcHostOp> {
|
||||
using FIROpConversion::FIROpConversion;
|
||||
|
||||
mlir::LogicalResult
|
||||
matchAndRewrite(fir::BoxProcHostOp boxprochost, OpAdaptor adaptor,
|
||||
mlir::ConversionPatternRewriter &rewriter) const override {
|
||||
return rewriter.notifyMatchFailure(
|
||||
boxprochost, "fir.boxproc_host codegen is not implemented yet");
|
||||
}
|
||||
};
|
||||
|
||||
/// Lower `fir.box_tdesc` to the sequence of operations to extract the type
|
||||
/// descriptor from the box.
|
||||
struct BoxTypeDescOpConversion : public FIROpConversion<fir::BoxTypeDescOp> {
|
||||
|
|
@ -1529,6 +1543,20 @@ struct EmboxOpConversion : public EmboxCommonConversion<fir::EmboxOp> {
|
|||
}
|
||||
};
|
||||
|
||||
/// Lower `fir.emboxproc` operation. Creates a procedure box.
|
||||
/// TODO: Part of supporting Fortran 2003 procedure pointers.
|
||||
struct EmboxProcOpConversion : public FIROpConversion<fir::EmboxProcOp> {
|
||||
using FIROpConversion::FIROpConversion;
|
||||
|
||||
mlir::LogicalResult
|
||||
matchAndRewrite(fir::EmboxProcOp emboxproc, OpAdaptor adaptor,
|
||||
mlir::ConversionPatternRewriter &rewriter) const override {
|
||||
return rewriter.notifyMatchFailure(
|
||||
emboxproc, "fir.emboxproc codegen is not implemented yet");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Code shared between insert_value and extract_value Ops.
|
||||
struct ValueOpCommon {
|
||||
// Translate the arguments pertaining to any multidimensional array to
|
||||
|
|
@ -2035,6 +2063,20 @@ struct UnboxCharOpConversion : public FIROpConversion<fir::UnboxCharOp> {
|
|||
}
|
||||
};
|
||||
|
||||
/// Lower `fir.unboxproc` operation. Unbox a procedure box value, yielding its
|
||||
/// components.
|
||||
/// TODO: Part of supporting Fortran 2003 procedure pointers.
|
||||
struct UnboxProcOpConversion : public FIROpConversion<fir::UnboxProcOp> {
|
||||
using FIROpConversion::FIROpConversion;
|
||||
|
||||
mlir::LogicalResult
|
||||
matchAndRewrite(fir::UnboxProcOp unboxproc, OpAdaptor adaptor,
|
||||
mlir::ConversionPatternRewriter &rewriter) const override {
|
||||
return rewriter.notifyMatchFailure(
|
||||
unboxproc, "fir.unboxproc codegen is not implemented yet");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
|
@ -2061,20 +2103,21 @@ public:
|
|||
AbsentOpConversion, AddcOpConversion, AddrOfOpConversion,
|
||||
AllocaOpConversion, BoxAddrOpConversion, BoxCharLenOpConversion,
|
||||
BoxDimsOpConversion, BoxEleSizeOpConversion, BoxIsAllocOpConversion,
|
||||
BoxIsArrayOpConversion, BoxIsPtrOpConversion, BoxRankOpConversion,
|
||||
BoxTypeDescOpConversion, CallOpConversion, CmpcOpConversion,
|
||||
ConstcOpConversion, ConvertOpConversion, DispatchOpConversion,
|
||||
DispatchTableOpConversion, DTEntryOpConversion, DivcOpConversion,
|
||||
EmboxOpConversion, EmboxCharOpConversion, ExtractValueOpConversion,
|
||||
HasValueOpConversion, GenTypeDescOpConversion, GlobalLenOpConversion,
|
||||
GlobalOpConversion, InsertOnRangeOpConversion, InsertValueOpConversion,
|
||||
BoxIsArrayOpConversion, BoxIsPtrOpConversion, BoxProcHostOpConversion,
|
||||
BoxRankOpConversion, BoxTypeDescOpConversion, CallOpConversion,
|
||||
CmpcOpConversion, ConstcOpConversion, ConvertOpConversion,
|
||||
DispatchOpConversion, DispatchTableOpConversion, DTEntryOpConversion,
|
||||
DivcOpConversion, EmboxOpConversion, EmboxCharOpConversion,
|
||||
EmboxProcOpConversion, ExtractValueOpConversion, HasValueOpConversion,
|
||||
GenTypeDescOpConversion, GlobalLenOpConversion, GlobalOpConversion,
|
||||
InsertOnRangeOpConversion, InsertValueOpConversion,
|
||||
IsPresentOpConversion, LoadOpConversion, NegcOpConversion,
|
||||
MulcOpConversion, SelectCaseOpConversion, SelectOpConversion,
|
||||
SelectRankOpConversion, SelectTypeOpConversion, ShapeOpConversion,
|
||||
ShapeShiftOpConversion, ShiftOpConversion, SliceOpConversion,
|
||||
StoreOpConversion, StringLitOpConversion, SubcOpConversion,
|
||||
UnboxCharOpConversion, UndefOpConversion, UnreachableOpConversion,
|
||||
ZeroOpConversion>(typeConverter);
|
||||
UnboxCharOpConversion, UnboxProcOpConversion, UndefOpConversion,
|
||||
UnreachableOpConversion, ZeroOpConversion>(typeConverter);
|
||||
mlir::populateStdToLLVMConversionPatterns(typeConverter, pattern);
|
||||
mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter,
|
||||
pattern);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ public:
|
|||
LLVM_DEBUG(llvm::dbgs() << "type convert: " << boxchar << '\n');
|
||||
return convertType(specifics->boxcharMemoryType(boxchar.getEleTy()));
|
||||
});
|
||||
addConversion([&](BoxProcType boxproc) {
|
||||
// TODO: Support for this type will be added later when the Fortran 2003
|
||||
// procedure pointer feature is implemented.
|
||||
return llvm::None;
|
||||
});
|
||||
addConversion(
|
||||
[&](fir::CharacterType charTy) { return convertCharType(charTy); });
|
||||
addConversion([&](HeapType heap) { return convertPointerLike(heap); });
|
||||
|
|
|
|||
|
|
@ -148,3 +148,28 @@ func @shape_shift_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j:
|
|||
%1 = fir.array_coor %arg0(%0) %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>, index, index) -> !fir.ref<f32>
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// Test that the type `fir.boxproc` fails to be legalized.
|
||||
// Not implemented yet.
|
||||
|
||||
// expected-error@+1{{failed to legalize operation 'builtin.func'}}
|
||||
func private @foo0(%arg0: !fir.boxproc<() -> ()>)
|
||||
|
||||
// -----
|
||||
|
||||
// Test that `fir.emboxproc` fails to be legalized.
|
||||
// Not implemented yet.
|
||||
|
||||
func private @method_impl(i32)
|
||||
|
||||
func @emboxproc_test() {
|
||||
%host_vars = fir.alloca tuple<i32,f64>
|
||||
// expected-error@+1{{failed to legalize operation 'fir.emboxproc'}}
|
||||
%bproc = fir.emboxproc @method_impl, %host_vars : ((i32) -> (), !fir.ref<tuple<i32,f64>>) -> !fir.boxproc<(i32) -> ()>
|
||||
return
|
||||
}
|
||||
|
||||
// Test that `fir.unboxproc` and `fir.boxproc_host` also fails to be legalized.
|
||||
// At the moment these cannot be tested since the `fir.boxproc` type does not have a conversion.
|
||||
|
|
|
|||
Loading…
Reference in New Issue