[mlir][CAPI] Add APIs for mlirOperationGetName and Identifier.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D90583
This commit is contained in:
Stella Laurenzo
2020-11-02 18:26:38 +00:00
parent e59726220f
commit b85f2f5c5f
4 changed files with 57 additions and 3 deletions

View File

@@ -249,6 +249,10 @@ int mlirOperationEqual(MlirOperation op, MlirOperation other) {
return unwrap(op) == unwrap(other);
}
MlirIdentifier mlirOperationGetName(MlirOperation op) {
return wrap(unwrap(op)->getName().getIdentifier());
}
MlirBlock mlirOperationGetBlock(MlirOperation op) {
return wrap(unwrap(op)->getBlock());
}
@@ -576,3 +580,19 @@ void mlirAttributeDump(MlirAttribute attr) { unwrap(attr).dump(); }
MlirNamedAttribute mlirNamedAttributeGet(const char *name, MlirAttribute attr) {
return MlirNamedAttribute{name, attr};
}
/*============================================================================*/
/* Identifier API. */
/*============================================================================*/
MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str) {
return wrap(Identifier::get(unwrap(str), unwrap(context)));
}
int mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other) {
return unwrap(ident) == unwrap(other);
}
MlirStringRef mlirIdentifierStr(MlirIdentifier ident) {
return wrap(unwrap(ident).strref());
}