@@ -319,7 +319,8 @@ def hlfir_ParentComponentOp : hlfir_Op<"parent_comp", [AttrSizedOperandSegments,
319
319
let hasVerifier = 1;
320
320
}
321
321
322
- def hlfir_ConcatOp : hlfir_Op<"concat", []> {
322
+ def hlfir_ConcatOp : hlfir_Op<"concat",
323
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
323
324
let summary = "concatenate characters";
324
325
let description = [{
325
326
Concatenate two or more character strings of a same character kind.
@@ -340,7 +341,7 @@ def hlfir_ConcatOp : hlfir_Op<"concat", []> {
340
341
let hasVerifier = 1;
341
342
}
342
343
343
- def hlfir_AllOp : hlfir_Op<"all", []> {
344
+ def hlfir_AllOp : hlfir_Op<"all", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface> ]> {
344
345
let summary = "ALL transformational intrinsic";
345
346
let description = [{
346
347
Takes a logical array MASK as argument, optionally along a particular dimension,
@@ -361,7 +362,7 @@ def hlfir_AllOp : hlfir_Op<"all", []> {
361
362
let hasVerifier = 1;
362
363
}
363
364
364
- def hlfir_AnyOp : hlfir_Op<"any", []> {
365
+ def hlfir_AnyOp : hlfir_Op<"any", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface> ]> {
365
366
let summary = "ANY transformational intrinsic";
366
367
let description = [{
367
368
Takes a logical array MASK as argument, optionally along a particular dimension,
@@ -382,7 +383,7 @@ def hlfir_AnyOp : hlfir_Op<"any", []> {
382
383
let hasVerifier = 1;
383
384
}
384
385
385
- def hlfir_CountOp : hlfir_Op<"count", [AttrSizedOperandSegments]> {
386
+ def hlfir_CountOp : hlfir_Op<"count", [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface> ]> {
386
387
let summary = "COUNT transformational intrinsic";
387
388
let description = [{
388
389
Takes a logical and counts the number of true values.
@@ -403,9 +404,9 @@ def hlfir_CountOp : hlfir_Op<"count", [AttrSizedOperandSegments]> {
403
404
let hasVerifier = 1;
404
405
}
405
406
406
-
407
407
def hlfir_ProductOp : hlfir_Op<"product", [AttrSizedOperandSegments,
408
- DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
408
+ DeclareOpInterfaceMethods<ArithFastMathInterface>,
409
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
409
410
let summary = "PRODUCT transformational intrinsic";
410
411
let description = [{
411
412
Multiplies the elements of an array, optionally along a particular dimension,
@@ -429,7 +430,8 @@ def hlfir_ProductOp : hlfir_Op<"product", [AttrSizedOperandSegments,
429
430
let hasVerifier = 1;
430
431
}
431
432
432
- def hlfir_SetLengthOp : hlfir_Op<"set_length", []> {
433
+ def hlfir_SetLengthOp : hlfir_Op<"set_length",
434
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
433
435
let summary = "change the length of a character entity";
434
436
let description = [{
435
437
Change the length of character entity. This trims or pads the
@@ -468,7 +470,8 @@ def hlfir_GetLengthOp : hlfir_Op<"get_length", [Pure]> {
468
470
}
469
471
470
472
def hlfir_SumOp : hlfir_Op<"sum", [AttrSizedOperandSegments,
471
- DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
473
+ DeclareOpInterfaceMethods<ArithFastMathInterface>,
474
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
472
475
let summary = "SUM transformational intrinsic";
473
476
let description = [{
474
477
Sums the elements of an array, optionally along a particular dimension,
@@ -493,7 +496,8 @@ def hlfir_SumOp : hlfir_Op<"sum", [AttrSizedOperandSegments,
493
496
}
494
497
495
498
def hlfir_DotProductOp : hlfir_Op<"dot_product",
496
- [DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
499
+ [DeclareOpInterfaceMethods<ArithFastMathInterface>,
500
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
497
501
let summary = "DOT_PRODUCT transformational intrinsic";
498
502
let description = [{
499
503
Dot product of two vectors
@@ -516,7 +520,8 @@ def hlfir_DotProductOp : hlfir_Op<"dot_product",
516
520
}
517
521
518
522
def hlfir_MatmulOp : hlfir_Op<"matmul",
519
- [DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
523
+ [DeclareOpInterfaceMethods<ArithFastMathInterface>,
524
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
520
525
let summary = "MATMUL transformational intrinsic";
521
526
let description = [{
522
527
Matrix multiplication
@@ -541,7 +546,8 @@ def hlfir_MatmulOp : hlfir_Op<"matmul",
541
546
let hasVerifier = 1;
542
547
}
543
548
544
- def hlfir_TransposeOp : hlfir_Op<"transpose", []> {
549
+ def hlfir_TransposeOp : hlfir_Op<"transpose",
550
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
545
551
let summary = "TRANSPOSE transformational intrinsic";
546
552
let description = [{
547
553
Transpose a rank 2 array
@@ -559,7 +565,8 @@ def hlfir_TransposeOp : hlfir_Op<"transpose", []> {
559
565
}
560
566
561
567
def hlfir_MatmulTransposeOp : hlfir_Op<"matmul_transpose",
562
- [DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
568
+ [DeclareOpInterfaceMethods<ArithFastMathInterface>,
569
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
563
570
let summary = "Optimized MATMUL(TRANSPOSE(...), ...)";
564
571
let description = [{
565
572
Matrix multiplication where the left hand side is transposed
@@ -581,8 +588,12 @@ def hlfir_MatmulTransposeOp : hlfir_Op<"matmul_transpose",
581
588
let hasVerifier = 1;
582
589
}
583
590
591
+ // An allocation effect is needed because the value produced by the associate
592
+ // is "deallocated" by hlfir.end_associate (the end_associate must not be
593
+ // removed, and there must be only one hlfir.end_associate).
584
594
def hlfir_AssociateOp : hlfir_Op<"associate", [AttrSizedOperandSegments,
585
- DeclareOpInterfaceMethods<fir_FortranVariableOpInterface>]> {
595
+ DeclareOpInterfaceMethods<fir_FortranVariableOpInterface>,
596
+ MemoryEffects<[MemAlloc]>]> {
586
597
let summary = "Create a variable from an expression value";
587
598
let description = [{
588
599
Create a variable from an expression value.
@@ -635,7 +646,7 @@ def hlfir_AssociateOp : hlfir_Op<"associate", [AttrSizedOperandSegments,
635
646
}];
636
647
}
637
648
638
- def hlfir_EndAssociateOp : hlfir_Op<"end_associate", []> {
649
+ def hlfir_EndAssociateOp : hlfir_Op<"end_associate", [MemoryEffects<[MemFree]> ]> {
639
650
let summary = "Mark the end of life of a variable associated to an expression";
640
651
641
652
let description = [{
@@ -652,7 +663,8 @@ def hlfir_EndAssociateOp : hlfir_Op<"end_associate", []> {
652
663
let builders = [OpBuilder<(ins "hlfir::AssociateOp":$associate)>];
653
664
}
654
665
655
- def hlfir_AsExprOp : hlfir_Op<"as_expr", []> {
666
+ def hlfir_AsExprOp : hlfir_Op<"as_expr",
667
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
656
668
let summary = "Take the value of an array, character or derived variable";
657
669
658
670
let description = [{
@@ -934,7 +946,7 @@ def hlfir_DestroyOp : hlfir_Op<"destroy", [MemoryEffects<[MemFree]>]> {
934
946
let assemblyFormat = "$expr attr-dict `:` qualified(type($expr))";
935
947
}
936
948
937
- def hlfir_CopyInOp : hlfir_Op<"copy_in", []> {
949
+ def hlfir_CopyInOp : hlfir_Op<"copy_in", [MemoryEffects<[MemAlloc]> ]> {
938
950
let summary = "copy a variable into a contiguous temporary if it is not contiguous";
939
951
let description = [{
940
952
Copy a variable into a contiguous temporary if the variable is not
@@ -954,7 +966,7 @@ def hlfir_CopyInOp : hlfir_Op<"copy_in", []> {
954
966
is true and, when it is false, the original value will be returned instead.
955
967
}];
956
968
957
- let arguments = (ins fir_BaseBoxType:$var,
969
+ let arguments = (ins Arg< fir_BaseBoxType, "", [MemRead]> :$var,
958
970
Optional<I1>:$var_is_present);
959
971
960
972
let results = (outs fir_BaseBoxType, I1);
@@ -981,7 +993,7 @@ def hlfir_CopyInOp : hlfir_Op<"copy_in", []> {
981
993
}];
982
994
}
983
995
984
- def hlfir_CopyOutOp : hlfir_Op<"copy_out", []> {
996
+ def hlfir_CopyOutOp : hlfir_Op<"copy_out", [MemoryEffects<[MemFree]> ]> {
985
997
let summary = "copy out a variable after a copy in";
986
998
let description = [{
987
999
If the variable was copied in a temporary in the related hlfir.copy_in,
@@ -992,9 +1004,9 @@ def hlfir_CopyOutOp : hlfir_Op<"copy_out", []> {
992
1004
The deallocation of $temp is done if $was_copied is true.
993
1005
}];
994
1006
995
- let arguments = (ins fir_BaseBoxType:$temp,
1007
+ let arguments = (ins Arg< fir_BaseBoxType, "", [MemRead]> :$temp,
996
1008
I1:$was_copied,
997
- Optional<fir_BaseBoxType>:$var);
1009
+ Arg< Optional<fir_BaseBoxType>, "", [MemWrite] >:$var);
998
1010
999
1011
let assemblyFormat = [{
1000
1012
$temp `,` $was_copied (`to` $var^)?
@@ -1546,7 +1558,8 @@ def hlfir_ForallIndexOp : hlfir_Op<"forall_index", [fir_FortranVariableOpInterfa
1546
1558
let hasCanonicalizeMethod = 1;
1547
1559
}
1548
1560
1549
- def hlfir_CharExtremumOp : hlfir_Op<"char_extremum", []> {
1561
+ def hlfir_CharExtremumOp : hlfir_Op<"char_extremum",
1562
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
1550
1563
let summary = "Find max/min from given character strings";
1551
1564
let description = [{
1552
1565
Find the lexicographical minimum or maximum of two or more character
0 commit comments