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
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, BaseList):
31 if isinstance(value, BaseBasePath):
34 if isinstance(value, Path):
38 assert isinstance(value, BaseObject)
43 if isinstance(obj, int):
44 return OMIntegerAttr.get(IntegerAttr.get(IntegerType.get_signless(64), obj))
45 return var_to_attribute(obj, none_on_fail)
50 if isinstance(value, List):
53 if isinstance(value, BasePath):
56 if isinstance(value, Path):
59 if isinstance(value, Object):
77 for i
in range(0, self.__len__()):
85 return BasePath(BaseBasePath.get_empty(context))
106 for name
in self.field_names:
107 yield (name, getattr(self, name))
114 """Instantiate an Evaluator with a Module."""
121 format=
"[%(asctime)s] %(name)s (%(levelname)s) %(message)s",
122 datefmt=
"%Y-%m-%d %H:%M:%S",
132 """Instantiate an Object with a class name and actual parameters."""
136 with self.module.context:
138 class_name = StringAttr.get(cls)
145 obj = super().
instantiate(class_name, actual_params)
151 """Handle MLIR Diagnostics by logging them."""
154 if diagnostic.severity == DiagnosticSeverity.ERROR:
155 self.
_logger.error(diagnostic.message)
156 elif diagnostic.severity == DiagnosticSeverity.WARNING:
157 self.
_logger.warning(diagnostic.message)
159 self.
_logger.info(diagnostic.message)
162 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)