[OM] Add Evaluator API to get the underlying Module.

This API is useful when you have an Evaluator, but need to get back to
the core MLIR data structures. For example, to get a Location to print
an error, or to get the context for creating attributes. This change
will be useful in a couple upcoming patches, so committing it now as
"obvious".
This commit is contained in:
Mike Urbach 2023-05-22 18:20:39 -06:00
parent c7100bed69
commit 9e3aa6e638
2 changed files with 8 additions and 0 deletions

View File

@ -41,6 +41,9 @@ struct Evaluator {
FailureOr<std::shared_ptr<Object>>
instantiate(StringAttr className, ArrayRef<ObjectValue> actualParams);
/// Get the Module this Evaluator is built from.
mlir::ModuleOp getModule();
private:
/// Evaluate a Value in a Class body according to the small expression grammar
/// described in the rationale document. The actual parameters are the values

View File

@ -21,6 +21,11 @@ using namespace circt::om;
/// Construct an Evaluator with an IR module.
circt::om::Evaluator::Evaluator(ModuleOp mod) : symbolTable(mod) {}
/// Get the Module this Evaluator is built from.
ModuleOp circt::om::Evaluator::getModule() {
return cast<ModuleOp>(symbolTable.getOp());
}
/// Instantiate an Object with its class name and actual parameters.
FailureOr<std::shared_ptr<Object>>
circt::om::Evaluator::instantiate(StringAttr className,