[OM] Add dedicated path attribute (#5972)

This attribute represents a value of Path type, and can be used with the OM
constant operation. For now, it holds a string encoding of the path, but will
probably change in the near future.
This commit is contained in:
Andrew Young 2023-08-28 14:33:55 -07:00 committed by GitHub
parent 154ac81cbf
commit b29ed8305e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -103,4 +103,22 @@ def MapAttr : AttrDef<OMDialect, "Map", [TypedAttrInterface]> {
}];
}
def OMPathAttribute : AttrDef<OMDialect, "Path", [TypedAttrInterface]> {
let summary = "An attribute that represents a path";
let mnemonic = "path";
let parameters = (ins "::mlir::StringAttr":$path);
let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$path)>
];
let assemblyFormat = " `<` $path `>` ";
let extraClassDeclaration = [{
mlir::Type getType();
}];
}
#endif // CIRCT_DIALECT_OM_OMATTRIBUTES_TD

View File

@ -91,6 +91,12 @@ circt::om::MapAttr::verify(function_ref<InFlightDiagnostic()> emitError,
return success();
}
circt::om::PathAttr circt::om::PathAttr::get(mlir::StringAttr path) {
return om::PathAttr::get(path.getContext(), path);
}
Type circt::om::PathAttr::getType() { return PathType::get(getContext()); }
void circt::om::OMDialect::registerAttributes() {
addAttributes<
#define GET_ATTRDEF_LIST