File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -634,6 +634,10 @@ MLIR_CAPI_EXPORTED MlirContext mlirOperationGetContext(MlirOperation op);
634
634
/// Gets the location of the operation.
635
635
MLIR_CAPI_EXPORTED MlirLocation mlirOperationGetLocation (MlirOperation op );
636
636
637
+ /// Sets the location of the operation.
638
+ MLIR_CAPI_EXPORTED void mlirOperationSetLocation (MlirOperation op ,
639
+ MlirLocation loc );
640
+
637
641
/// Gets the type id of the operation.
638
642
/// Returns null if the operation does not have a registered operation
639
643
/// description.
Original file line number Diff line number Diff line change @@ -3485,15 +3485,21 @@ void mlir::python::populateIRCore(nb::module_ &m) {
3485
3485
},
3486
3486
" Shortcut to get an op result if it has only one (throws an error "
3487
3487
" otherwise)." )
3488
- .def_prop_ro (
3488
+ .def_prop_rw (
3489
3489
" location" ,
3490
3490
[](PyOperationBase &self) {
3491
3491
PyOperation &operation = self.getOperation ();
3492
3492
return PyLocation (operation.getContext (),
3493
3493
mlirOperationGetLocation (operation.get ()));
3494
3494
},
3495
- " Returns the source location the operation was defined or derived "
3496
- " from." )
3495
+ [](PyOperationBase &self, const PyLocation &location) {
3496
+ PyOperation &operation = self.getOperation ();
3497
+ mlirOperationSetLocation (operation.get (), location.get ());
3498
+ },
3499
+ nb::for_getter (" Returns the source location the operation was "
3500
+ " defined or derived from." ),
3501
+ nb::for_setter (" Sets the source location the operation was defined "
3502
+ " or derived from." ))
3497
3503
.def_prop_ro (" parent" ,
3498
3504
[](PyOperationBase &self)
3499
3505
-> std::optional<nb::typed<nb::object, PyOperation>> {
Original file line number Diff line number Diff line change @@ -656,6 +656,10 @@ MlirLocation mlirOperationGetLocation(MlirOperation op) {
656
656
return wrap (unwrap (op)->getLoc ());
657
657
}
658
658
659
+ void mlirOperationSetLocation (MlirOperation op, MlirLocation loc) {
660
+ unwrap (op)->setLoc (unwrap (loc));
661
+ }
662
+
659
663
MlirTypeID mlirOperationGetTypeID (MlirOperation op) {
660
664
if (auto info = unwrap (op)->getRegisteredInfo ())
661
665
return wrap (info->getTypeID ());
You can’t perform that action at this time.
0 commit comments