@@ -347,6 +347,24 @@ def OpenACC_DataBoundsOp : OpenACC_Op<"bounds",
347
347
}];
348
348
349
349
let hasVerifier = 1;
350
+
351
+ let builders = [
352
+ OpBuilder<(ins "::mlir::Value":$extent), [{
353
+ build($_builder, $_state,
354
+ ::mlir::acc::DataBoundsType::get($_builder.getContext()),
355
+ /*lowerbound=*/{}, /*upperbound=*/{}, extent,
356
+ /*stride=*/{}, /*strideInBytes=*/nullptr, /*startIdx=*/{});
357
+ }]
358
+ >,
359
+ OpBuilder<(ins "::mlir::Value":$lowerbound,
360
+ "::mlir::Value":$upperbound), [{
361
+ build($_builder, $_state,
362
+ ::mlir::acc::DataBoundsType::get($_builder.getContext()),
363
+ lowerbound, upperbound, /*extent=*/{},
364
+ /*stride=*/{}, /*strideInBytes=*/nullptr, /*startIdx=*/{});
365
+ }]
366
+ >
367
+ ];
350
368
}
351
369
352
370
// Data entry operation does not refer to OpenACC spec terminology, but to
@@ -450,6 +468,33 @@ class OpenACC_DataEntryOp<string mnemonic, string clause, string extraDescriptio
450
468
}];
451
469
452
470
let hasVerifier = 1;
471
+
472
+ let builders = [
473
+ OpBuilder<(ins "::mlir::Value":$varPtr,
474
+ "bool":$structured,
475
+ "bool":$implicit,
476
+ CArg<"::mlir::ValueRange", "{}">:$bounds), [{
477
+ build($_builder, $_state, varPtr.getType(), varPtr, /*varPtrPtr=*/{},
478
+ bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
479
+ /*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
480
+ /*structured=*/$_builder.getBoolAttr(structured),
481
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*name=*/nullptr);
482
+ }]
483
+ >,
484
+ OpBuilder<(ins "::mlir::Value":$varPtr,
485
+ "bool":$structured,
486
+ "bool":$implicit,
487
+ "const ::llvm::Twine &":$name,
488
+ CArg<"::mlir::ValueRange", "{}">:$bounds), [{
489
+ build($_builder, $_state, varPtr.getType(), varPtr, /*varPtrPtr=*/{},
490
+ bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
491
+ /*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
492
+ /*structured=*/$_builder.getBoolAttr(structured),
493
+ /*implicit=*/$_builder.getBoolAttr(implicit),
494
+ /*name=*/$_builder.getStringAttr(name));
495
+ }]
496
+ >
497
+ ];
453
498
}
454
499
455
500
//===----------------------------------------------------------------------===//
@@ -762,23 +807,13 @@ class OpenACC_DataExitOp<string mnemonic, string clause, string extraDescription
762
807
let hasVerifier = 1;
763
808
}
764
809
765
- //===----------------------------------------------------------------------===//
766
- // 2.7.8 copyout clause
767
- //===----------------------------------------------------------------------===//
768
- def OpenACC_CopyoutOp : OpenACC_DataExitOp<"copyout",
769
- "mlir::acc::DataClause::acc_copyout",
770
- "- `varPtr`: The address of variable to copy back to.",
771
- [MemoryEffects<[MemRead<OpenACC_RuntimeCounters>,
772
- MemWrite<OpenACC_RuntimeCounters>]>],
773
- (ins Arg<OpenACC_PointerLikeTypeInterface,"Address of device variable",[MemRead]>:$accPtr,
774
- Arg<OpenACC_PointerLikeTypeInterface,"Address of variable",[MemWrite]>:$varPtr)> {
775
- let summary = "Represents acc copyout semantics - reverse of copyin.";
776
-
777
- let extraClassDeclaration = extraClassDeclarationBase # [{
778
- /// Check if this is a copyout with zero modifier.
779
- bool isCopyoutZero();
780
- }];
781
-
810
+ class OpenACC_DataExitOpWithVarPtr<string mnemonic, string clause> :
811
+ OpenACC_DataExitOp<mnemonic, clause,
812
+ "- `varPtr`: The address of variable to copy back to.",
813
+ [MemoryEffects<[MemRead<OpenACC_RuntimeCounters>,
814
+ MemWrite<OpenACC_RuntimeCounters>]>],
815
+ (ins Arg<OpenACC_PointerLikeTypeInterface,"Address of device variable",[MemRead]>:$accPtr,
816
+ Arg<OpenACC_PointerLikeTypeInterface,"Address of variable",[MemWrite]>:$varPtr)> {
782
817
let assemblyFormat = [{
783
818
`accPtr` `(` $accPtr `:` type($accPtr) `)`
784
819
(`bounds` `(` $bounds^ `)` )?
@@ -787,76 +822,121 @@ def OpenACC_CopyoutOp : OpenACC_DataExitOp<"copyout",
787
822
`to` `varPtr` `(` $varPtr `:` type($varPtr) `)`
788
823
attr-dict
789
824
}];
825
+
826
+ let builders = [
827
+ OpBuilder<(ins "::mlir::Value":$accPtr,
828
+ "::mlir::Value":$varPtr,
829
+ "bool":$structured,
830
+ "bool":$implicit,
831
+ CArg<"::mlir::ValueRange", "{}">:$bounds), [{
832
+ build($_builder, $_state, accPtr, varPtr,
833
+ bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
834
+ /*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
835
+ /*structured=*/$_builder.getBoolAttr(structured),
836
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*name=*/nullptr);
837
+ }]
838
+ >,
839
+ OpBuilder<(ins "::mlir::Value":$accPtr,
840
+ "::mlir::Value":$varPtr,
841
+ "bool":$structured,
842
+ "bool":$implicit,
843
+ "const ::llvm::Twine &":$name,
844
+ CArg<"::mlir::ValueRange", "{}">:$bounds), [{
845
+ build($_builder, $_state, accPtr, varPtr,
846
+ bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
847
+ /*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
848
+ /*structured=*/$_builder.getBoolAttr(structured),
849
+ /*implicit=*/$_builder.getBoolAttr(implicit),
850
+ /*name=*/$_builder.getStringAttr(name));
851
+ }]
852
+ >
853
+ ];
790
854
}
791
855
792
- //===----------------------------------------------------------------------===//
793
- // 2.7.11 delete clause
794
- //===----------------------------------------------------------------------===//
795
- def OpenACC_DeleteOp : OpenACC_DataExitOp<"delete",
796
- "mlir::acc::DataClause::acc_delete", "",
797
- [MemoryEffects<[MemRead<OpenACC_RuntimeCounters>,
856
+ class OpenACC_DataExitOpNoVarPtr<string mnemonic, string clause> :
857
+ OpenACC_DataExitOp<mnemonic, clause, "",
858
+ [MemoryEffects<[MemRead<OpenACC_RuntimeCounters>,
798
859
MemWrite<OpenACC_RuntimeCounters>]>],
799
- (ins Arg<OpenACC_PointerLikeTypeInterface,"Address of device variable",[MemRead]>:$accPtr)> {
800
- let summary = "Represents acc delete semantics - reverse of create.";
801
-
802
- let extraClassDeclaration = extraClassDeclarationBase;
803
-
860
+ (ins Arg<OpenACC_PointerLikeTypeInterface,"Address of device variable",[MemRead]>:$accPtr)> {
804
861
let assemblyFormat = [{
805
862
`accPtr` `(` $accPtr `:` type($accPtr) `)`
806
863
(`bounds` `(` $bounds^ `)` )?
807
864
(`async` `(` custom<DeviceTypeOperands>($asyncOperands,
808
865
type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
809
866
attr-dict
810
867
}];
868
+
869
+ let builders = [
870
+ OpBuilder<(ins "::mlir::Value":$accPtr,
871
+ "bool":$structured,
872
+ "bool":$implicit,
873
+ CArg<"::mlir::ValueRange", "{}">:$bounds), [{
874
+ build($_builder, $_state, accPtr,
875
+ bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
876
+ /*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
877
+ /*structured=*/$_builder.getBoolAttr(structured),
878
+ /*implicit=*/$_builder.getBoolAttr(implicit), /*name=*/nullptr);
879
+ }]
880
+ >,
881
+ OpBuilder<(ins "::mlir::Value":$accPtr,
882
+ "bool":$structured,
883
+ "bool":$implicit,
884
+ "const ::llvm::Twine &":$name,
885
+ CArg<"::mlir::ValueRange", "{}">:$bounds), [{
886
+ build($_builder, $_state, accPtr,
887
+ bounds, /*asyncOperands=*/{}, /*asyncOperandsDeviceType=*/nullptr,
888
+ /*asyncOnly=*/nullptr, /*dataClause=*/nullptr,
889
+ /*structured=*/$_builder.getBoolAttr(structured),
890
+ /*implicit=*/$_builder.getBoolAttr(implicit),
891
+ /*name=*/$_builder.getStringAttr(name));
892
+ }]
893
+ >
894
+ ];
811
895
}
812
896
813
897
//===----------------------------------------------------------------------===//
814
- // 2.7.13 detach clause
898
+ // 2.7.8 copyout clause
815
899
//===----------------------------------------------------------------------===//
816
- def OpenACC_DetachOp : OpenACC_DataExitOp<"detach",
817
- "mlir::acc::DataClause::acc_detach", "",
818
- [MemoryEffects<[MemRead<OpenACC_RuntimeCounters>,
819
- MemWrite<OpenACC_RuntimeCounters>]>],
820
- (ins Arg<OpenACC_PointerLikeTypeInterface,"Address of device variable",[MemRead]>:$accPtr)> {
821
- let summary = "Represents acc detach semantics - reverse of attach.";
900
+ def OpenACC_CopyoutOp : OpenACC_DataExitOpWithVarPtr<"copyout",
901
+ "mlir::acc::DataClause::acc_copyout"> {
902
+ let summary = "Represents acc copyout semantics - reverse of copyin.";
822
903
904
+ let extraClassDeclaration = extraClassDeclarationBase # [{
905
+ /// Check if this is a copyout with zero modifier.
906
+ bool isCopyoutZero();
907
+ }];
908
+ }
909
+
910
+ //===----------------------------------------------------------------------===//
911
+ // 2.7.11 delete clause
912
+ //===----------------------------------------------------------------------===//
913
+ def OpenACC_DeleteOp : OpenACC_DataExitOpNoVarPtr<"delete",
914
+ "mlir::acc::DataClause::acc_delete"> {
915
+ let summary = "Represents acc delete semantics - reverse of create.";
823
916
let extraClassDeclaration = extraClassDeclarationBase;
917
+ }
824
918
825
- let assemblyFormat = [{
826
- `accPtr` `(` $accPtr `:` type($accPtr) `)`
827
- (`bounds` `(` $bounds^ `)` )?
828
- (`async` `(` custom<DeviceTypeOperands>($asyncOperands ,
829
- type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
830
- attr-dict
831
- }] ;
919
+ //===----------------------------------------------------------------------===//
920
+ // 2.7.13 detach clause
921
+ //===----------------------------------------------------------------------===//
922
+ def OpenACC_DetachOp : OpenACC_DataExitOpNoVarPtr<"detach" ,
923
+ "mlir::acc::DataClause::acc_detach"> {
924
+ let summary = "Represents acc detach semantics - reverse of attach.";
925
+ let extraClassDeclaration = extraClassDeclarationBase ;
832
926
}
833
927
834
928
//===----------------------------------------------------------------------===//
835
929
// 2.14.4 host clause
836
930
//===----------------------------------------------------------------------===//
837
- def OpenACC_UpdateHostOp : OpenACC_DataExitOp<"update_host",
838
- "mlir::acc::DataClause::acc_update_host",
839
- "- `varPtr`: The address of variable to copy back to.",
840
- [MemoryEffects<[MemRead<OpenACC_RuntimeCounters>,
841
- MemWrite<OpenACC_RuntimeCounters>]>],
842
- (ins Arg<OpenACC_PointerLikeTypeInterface,"Address of device variable",[MemRead]>:$accPtr,
843
- Arg<OpenACC_PointerLikeTypeInterface,"Address of variable",[MemWrite]>:$varPtr)> {
931
+ def OpenACC_UpdateHostOp : OpenACC_DataExitOpWithVarPtr<"update_host",
932
+ "mlir::acc::DataClause::acc_update_host"> {
844
933
let summary = "Represents acc update host semantics.";
845
934
let extraClassDeclaration = extraClassDeclarationBase # [{
846
935
/// Check if this is an acc update self.
847
936
bool isSelf() {
848
937
return getDataClause() == acc::DataClause::acc_update_self;
849
938
}
850
939
}];
851
-
852
- let assemblyFormat = [{
853
- `accPtr` `(` $accPtr `:` type($accPtr) `)`
854
- (`bounds` `(` $bounds^ `)` )?
855
- (`async` `(` custom<DeviceTypeOperands>($asyncOperands,
856
- type($asyncOperands), $asyncOperandsDeviceType)^ `)`)?
857
- `to` `varPtr` `(` $varPtr `:` type($varPtr) `)`
858
- attr-dict
859
- }];
860
940
}
861
941
862
942
//===----------------------------------------------------------------------===//
0 commit comments