diff --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h --- a/mlir/include/mlir-c/IR.h +++ b/mlir/include/mlir-c/IR.h @@ -505,6 +505,11 @@ /// Returns the number of arguments of the block. MLIR_CAPI_EXPORTED intptr_t mlirBlockGetNumArguments(MlirBlock block); +/// Appends an argument of the specified type to the block. Returns the newly +/// added argument. +MLIR_CAPI_EXPORTED MlirValue mlirBlockAddArgument(MlirBlock block, + MlirType type); + /// Returns `pos`-th argument of the block. MLIR_CAPI_EXPORTED MlirValue mlirBlockGetArgument(MlirBlock block, intptr_t pos); diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp --- a/mlir/lib/CAPI/IR/IR.cpp +++ b/mlir/lib/CAPI/IR/IR.cpp @@ -525,6 +525,10 @@ return static_cast(unwrap(block)->getNumArguments()); } +MlirValue mlirBlockAddArgument(MlirBlock block, MlirType type) { + return wrap(unwrap(block)->addArgument(unwrap(type)); +} + MlirValue mlirBlockGetArgument(MlirBlock block, intptr_t pos) { return wrap(unwrap(block)->getArgument(static_cast(pos))); }