m2isar.metamodel

This module contains the M2-ISA-R metamodel classes to build an ISA from. The M2-ISA-R metamodel is split into two submodules, one for architectural description, one for the behavioral description.

Also included are preprocessing functions, mostly to simplify a model and to extract information about scalar and function staticness as well as exceptions.

Any model traversal should use a :subclass`` of the ExprVisitor MetaClass including the needed transformations/ recursive calls. For examples on how the recursive generate functions look like, see the ExprVisitor MetaClass with its default generate function in m2isar.metamodel.utils.ExprVisitor Multiple examples of such visitors can be found in the m2isar.backends submodules, e.g. m2isar.backends.etiss.instruction_transform or m2isar.backends.isa_manual.visitor. But also the metamodel builders in m2isar.frontends.coredsl2 use this approach to build the model from the parse tree. As well as the Frontend.

Usually a M2-ISA-R behavioral model is traversed from top to bottom. Necessary contextual information is either stored globally within the self object of the ExprVisitor or passed to lower levels by a user-defined context object for local stack-based information. Each object should then generate a piece of output (e.g. c-code for ETISS) and return it to its parent. Value passing between generation functions is completely user-defined, m2isar.backends.etiss.instruction_transform uses complex objects in lower levels of translation and switches to strings for the two highest levels of the hierarchy.

Submodules

Attributes

M2_METAMODEL_VERSION

intrinsic_defs

intrinsics

Classes

M2Model

Functions

patch_model(module)

Monkey patch transformation functions inside module

load_model(→ M2Model)

dump_model(model_obj, out_path[, ignore_suffix])

Package Contents

M2_METAMODEL_VERSION = 3[source]
patch_model(module)[source]

Monkey patch transformation functions inside module into m2isar.metamodel.behav classes

Transformation functions must have a specific signature for this to work:

def transform(self: <behav Class>, context: Any)

where <behav Class> is the class in m2isar.metamodel.behav which this transformation is associated with. Context can be any user-defined object to keep track of additional contextual information, if needed.

intrinsic_defs[source]
intrinsics[source]
class M2Model[source]
model_version: int[source]
cores: dict[str, arch.CoreDef][source]
sets: dict[str, arch.InstructionSet][source]
code_infos: dict[int, code_info.CodeInfoBase][source]
__post_init__()[source]
load_model(model_path: str | pathlib.Path, allow_missmatch: bool = False) M2Model[source]
dump_model(model_obj: M2Model, out_path: str | pathlib.Path, ignore_suffix: bool = False)[source]