[flang-commits] [flang] 677df8c - [fir] Add fir.global_len conversion placeholder
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Nov 15 07:47:26 PST 2021
Author: Valentin Clement
Date: 2021-11-15T16:47:20+01:00
New Revision: 677df8c709d8c3913c6c1d03a30c4485e22419dc
URL: https://github.com/llvm/llvm-project/commit/677df8c709d8c3913c6c1d03a30c4485e22419dc
DIFF: https://github.com/llvm/llvm-project/commit/677df8c709d8c3913c6c1d03a30c4485e22419dc.diff
LOG: [fir] Add fir.global_len conversion placeholder
As for D113662, this patch just add a place holder for
the fir.global_len operation conversion. This operation
is part of F20xx and is not implemented yet.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D113887
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/convert-to-llvm-invalid.fir
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index d0156d37d6ab..8257c8a4f2f4 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2797,8 +2797,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
```mlir
global @g : !fir.type<t(len1:i32)> {
fir.global_len len1, 10 : i32
- %1 = fir.undefined : !fir.type<t(len1:i32)>
- return %1 : !fir.type<t(len1:i32)>
+ %1 = fir.undefined !fir.type<t(len1:i32)>
+ fir.has_value %1 : !fir.type<t(len1:i32)>
}
```
}];
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index ffc3b0a37aa0..43019f80935e 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -636,6 +636,18 @@ struct DTEntryOpConversion : public FIROpConversion<fir::DTEntryOp> {
}
};
+/// Lower `fir.global_len` operation.
+struct GlobalLenOpConversion : public FIROpConversion<fir::GlobalLenOp> {
+ using FIROpConversion::FIROpConversion;
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::GlobalLenOp globalLen, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ return rewriter.notifyMatchFailure(
+ globalLen, "fir.global_len codegen is not implemented yet");
+ }
+};
+
/// Lower `fir.has_value` operation to `llvm.return` operation.
struct HasValueOpConversion : public FIROpConversion<fir::HasValueOp> {
using FIROpConversion::FIROpConversion;
@@ -1504,8 +1516,8 @@ class FIRToLLVMLowering : public fir::FIRToLLVMLoweringBase<FIRToLLVMLowering> {
BoxIsPtrOpConversion, BoxRankOpConversion, CallOpConversion,
ConvertOpConversion, DispatchOpConversion, DispatchTableOpConversion,
DTEntryOpConversion, DivcOpConversion, EmboxCharOpConversion,
- ExtractValueOpConversion, HasValueOpConversion, GlobalOpConversion,
- InsertOnRangeOpConversion, InsertValueOpConversion,
+ ExtractValueOpConversion, HasValueOpConversion, GlobalLenOpConversion,
+ GlobalOpConversion, InsertOnRangeOpConversion, InsertValueOpConversion,
IsPresentOpConversion, LoadOpConversion, NegcOpConversion,
MulcOpConversion, SelectCaseOpConversion, SelectOpConversion,
SelectRankOpConversion, SelectTypeOpConversion, StoreOpConversion,
diff --git a/flang/test/Fir/convert-to-llvm-invalid.fir b/flang/test/Fir/convert-to-llvm-invalid.fir
index 8c38cab68fb6..88175a84eb56 100644
--- a/flang/test/Fir/convert-to-llvm-invalid.fir
+++ b/flang/test/Fir/convert-to-llvm-invalid.fir
@@ -72,3 +72,14 @@ func @bar_select_type(%arg : !fir.box<!fir.type<derived3{f:f32}>>) -> i32 {
%zero = arith.constant 0 : i32
return %zero : i32
}
+
+// -----
+
+// Test `fir.global_len` conversion failure. Not implemented yet.
+
+fir.global @global_derived : !fir.type<minez(f:i32)> {
+ // expected-error at +1{{failed to legalize operation 'fir.global_len'}}
+ fir.global_len f, 1 : i32
+ %0 = fir.undefined !fir.type<minez>
+ fir.has_value %0 : !fir.type<minez>
+}
More information about the flang-commits
mailing list