[Mlir-commits] [mlir] [mlir][python]Python Bindings for select edit operations on Block arguments (PR #94305)
Maksim Levental
llvmlistbot at llvm.org
Tue Jun 4 16:37:10 PDT 2024
================
@@ -3238,6 +3238,25 @@ void mlir::python::populateIRCore(py::module &m) {
return PyBlockArgumentList(self.getParentOperation(), self.get());
},
"Returns a list of block arguments.")
+ .def(
+ "add_argument",
+ [](PyBlock &self, const PyType &type, const PyLocation &loc) {
+ return mlirBlockAddArgument(self.get(), type, loc);
+ },
+ "Append an argument of the specified type to the block and returns "
+ "the newly added argument.")
+ .def(
+ "erase_argument",
+ [](PyBlock &self, unsigned index) {
+ return mlirBlockEraseArgument(self.get(), index);
+ },
+ "Erase the argument at 'index' and remove it from the argument list.")
+ .def(
+ "erase_arguments",
+ [](PyBlock &self, unsigned start, unsigned num) {
+ return mlirBlockEraseArguments(self.get(), start, num);
+ },
+ "Erases 'num' arguments from the index 'start'.")
----------------
makslevental wrote:
nit: Do we really need both of these APIs? I mean I don't know why it exists at the cpp level so I'm not commenting on that but at the python level, writing a for loop that just individually removes each one is pretty simple (as long as one remembers to iterate in reverse...). It doesn't really matter to me if they both stay (i.e., if you have a need) but removing would simplify the API.
https://github.com/llvm/llvm-project/pull/94305
More information about the Mlir-commits
mailing list