5from __future__
import annotations
7from ._om_ops_gen
import *
8from .._mlir_libs._circt._om
import AnyType, Evaluator
as BaseEvaluator, Object
as BaseObject, List
as BaseList, BasePath
as BaseBasePath, BasePathType, Path, PathType, ClassType, ReferenceAttr, ListAttr, ListType, OMIntegerAttr, Unknown
10from ..ir
import Attribute, Diagnostic, DiagnosticSeverity, Module, StringAttr, IntegerAttr, IntegerType
11from ..support
import attribute_to_var, var_to_attribute
15from dataclasses
import fields
16from typing
import TYPE_CHECKING, Any, Sequence, TypeVar
19 from _typeshed.stdlib.dataclass
import DataclassInstance
25 if isinstance(value, (int, float, str, bool, tuple, list, dict)):
28 if isinstance(value, Unknown):
31 if isinstance(value, BaseList):
34 if isinstance(value, BaseBasePath):
37 if isinstance(value, Path):
41 assert isinstance(value, BaseObject)
46 if isinstance(obj, int):
47 return OMIntegerAttr.get(IntegerAttr.get(IntegerType.get_signed(64), obj))
48 return var_to_attribute(obj, none_on_fail)
53 if isinstance(value, List):
56 if isinstance(value, BasePath):
59 if isinstance(value, Path):
62 if isinstance(value, Object):
80 for i
in range(0, self.__len__()):
88 return BasePath(BaseBasePath.get_empty(context))
109 for name
in self.field_names:
110 yield (name, getattr(self, name))
117 """Instantiate an Evaluator with a Module."""
124 format=
"[%(asctime)s] %(name)s (%(levelname)s) %(message)s",
125 datefmt=
"%Y-%m-%d %H:%M:%S",
135 """Instantiate an Object with a class name and actual parameters."""
139 with self.module.context:
141 class_name = StringAttr.get(cls)
148 obj = super().
instantiate(class_name, actual_params)
154 """Handle MLIR Diagnostics by logging them."""
157 if diagnostic.severity == DiagnosticSeverity.ERROR:
158 self.
_logger.error(diagnostic.message)
159 elif diagnostic.severity == DiagnosticSeverity.WARNING:
160 self.
_logger.warning(diagnostic.message)
162 self.
_logger.info(diagnostic.message)
165 for note
in diagnostic.notes:
"BasePath" get_empty(context=None)
None __init__(self, Module mod)
bool _handle_diagnostic(self, Diagnostic diagnostic)
Object instantiate(self, str cls, *Any args)
None __init__(self, BaseList obj)
None __init__(self, BaseObject obj)
get_field_loc(self, str name)
__getattr__(self, str name)
unwrap_python_object(value)
ir.Attrbute om_var_to_attribute(obj, bool none_on_fail=False)