Skip to content

Commit 0152d9a

Browse files
authored
[fir] Move save_result constraint to td file (#1108)
1 parent 577f81e commit 0152d9a

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
362362

363363
}];
364364

365-
let arguments = (ins AnyType:$value,
365+
let arguments = (ins ArrayOrBoxOrRecord:$value,
366366
Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
367367
Optional<AnyShapeType>:$shape,
368368
Variadic<AnyIntegerType>:$typeparams);

flang/include/flang/Optimizer/Dialect/FIRTypes.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,4 +588,8 @@ def AnyCoordinateType : Type<AnyCoordinateLike.predicate, "coordinate type">;
588588
def AnyAddressableLike : TypeConstraint<Or<[fir_ReferenceType.predicate,
589589
FunctionType.predicate]>, "any addressable">;
590590

591+
def ArrayOrBoxOrRecord : TypeConstraint<Or<[fir_SequenceType.predicate,
592+
fir_BoxType.predicate, fir_RecordType.predicate]>,
593+
"fir.box, fir.array or fir.type">;
594+
591595
#endif // FIR_DIALECT_FIR_TYPES

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,10 +2195,6 @@ static mlir::LogicalResult verify(fir::SaveResultOp op) {
21952195
if (fir::isa_unknown_size_box(resultType))
21962196
return op.emitOpError("cannot save !fir.box of unknown rank or type");
21972197

2198-
if (!resultType.isa<fir::BoxType, fir::SequenceType, fir::RecordType>())
2199-
return op.emitOpError(
2200-
"value operand must be a fir.box, fir.array or fir.type");
2201-
22022198
if (resultType.isa<fir::BoxType>()) {
22032199
if (op.shape() || !op.typeparams().empty())
22042200
return op.emitOpError(

flang/test/Fir/invalid.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func @bad_save_result(%buffer : !fir.ref<!fir.box<!fir.array<*:f32>>>) {
401401

402402
func @bad_save_result(%buffer : !fir.ref<f64>) {
403403
%res = fir.call @array_func() : () -> f64
404-
// expected-error@+1 {{'fir.save_result' op value operand must be a fir.box, fir.array or fir.type}}
404+
// expected-error@+1 {{'fir.save_result' op operand #0 must be fir.box, fir.array or fir.type, but got 'f64'}}
405405
fir.save_result %res to %buffer : f64, !fir.ref<f64>
406406
return
407407
}

0 commit comments

Comments
 (0)