This repository was archived by the owner on Oct 11, 2025. It is now read-only.
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);
634634/// Gets the location of the operation.
635635MLIR_CAPI_EXPORTED MlirLocation mlirOperationGetLocation (MlirOperation op );
636636
637+ /// Sets the location of the operation.
638+ MLIR_CAPI_EXPORTED void mlirOperationSetLocation (MlirOperation op ,
639+ MlirLocation loc );
640+
637641/// Gets the type id of the operation.
638642/// Returns null if the operation does not have a registered operation
639643/// description.
Original file line number Diff line number Diff line change @@ -3485,15 +3485,21 @@ void mlir::python::populateIRCore(nb::module_ &m) {
34853485 },
34863486 " Shortcut to get an op result if it has only one (throws an error "
34873487 " otherwise)." )
3488- .def_prop_ro (
3488+ .def_prop_rw (
34893489 " location" ,
34903490 [](PyOperationBase &self) {
34913491 PyOperation &operation = self.getOperation ();
34923492 return PyLocation (operation.getContext (),
34933493 mlirOperationGetLocation (operation.get ()));
34943494 },
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." ))
34973503 .def_prop_ro (" parent" ,
34983504 [](PyOperationBase &self)
34993505 -> 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) {
656656 return wrap (unwrap (op)->getLoc ());
657657}
658658
659+ void mlirOperationSetLocation (MlirOperation op, MlirLocation loc) {
660+ unwrap (op)->setLoc (unwrap (loc));
661+ }
662+
659663MlirTypeID mlirOperationGetTypeID (MlirOperation op) {
660664 if (auto info = unwrap (op)->getRegisteredInfo ())
661665 return wrap (info->getTypeID ());
You can’t perform that action at this time.
0 commit comments