CIRCT 23.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
esiaccel.codegen.CppGenerator Class Reference
Inheritance diagram for esiaccel.codegen.CppGenerator:
Inheritance graph
[legend]
Collaboration diagram for esiaccel.codegen.CppGenerator:
Collaboration graph
[legend]

Public Member Functions

 __init__ (self, AcceleratorConnection conn)
 
str get_consts_str (self, ModuleInfo module_info)
 
 write_modules (self, Path output_dir, str system_name)
 
 generate (self, Path output_dir, str system_name)
 

Public Attributes

 type_planner
 
 type_emitter
 
- Public Attributes inherited from esiaccel.codegen.Generator
 manifest
 

Static Public Attributes

str language = "C++"
 
- Static Public Attributes inherited from esiaccel.codegen.Generator
Optional language = None
 

Protected Member Functions

Dict[str, object] _build_module_instance_map (self)
 
str _cpp_member_type (self, port, Optional[str] alias_prefix=None)
 
List[Tuple[str, str]] _port_using_aliases (self, str alias_prefix, port)
 
str _cpp_indexed_elem_type (self, port, Optional[str] alias_prefix=None)
 
str _cpp_ctor_param_type (self, port)
 
str _port_find_code (self, str member_name, port, appid)
 
_PortGroup _scalar_port_group (self, str member_name, port, appid)
 
_PortGroup _indexed_ports_group (self, str member_name, str appid_name, port_list)
 
_PortGroup _mixed_struct_group (self, str member_name, str appid_name, port_list)
 
List[_PortGroup_collect_port_groups (self, dict ports)
 
None _emit_module_class (self, str name, str system_name, ModuleInfo module_info, List[_PortGroup] port_groups, TextIO out)
 

Static Protected Member Functions

str _sanitize_id (str name)
 
str _cpp_ctor_param_suffix (port)
 
str _appid_expr (appid)
 
str _port_make_unique_arg (str member_name, port)
 
bool _port_is_connectable (port)
 

Protected Attributes

 _conn
 

Detailed Description

Generate C++ headers from an ESI manifest.

Definition at line 58 of file codegen.py.

Constructor & Destructor Documentation

◆ __init__()

esiaccel.codegen.CppGenerator.__init__ (   self,
AcceleratorConnection  conn 
)

Member Function Documentation

◆ _appid_expr()

str esiaccel.codegen.CppGenerator._appid_expr (   appid)
staticprotected
Return `esi::AppID(...)` expression for an AppID.

Definition at line 206 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._port_find_code().

◆ _build_module_instance_map()

Dict[str, object] esiaccel.codegen.CppGenerator._build_module_instance_map (   self)
protected
Walk the live hierarchy and return {module_name: first Instance}.

Definition at line 94 of file codegen.py.

References esiaccel.codegen.CppGenerator._conn.

Referenced by esiaccel.codegen.CppGenerator.write_modules().

◆ _collect_port_groups()

List[_PortGroup] esiaccel.codegen.CppGenerator._collect_port_groups (   self,
dict  ports 
)
protected

◆ _cpp_ctor_param_suffix()

str esiaccel.codegen.CppGenerator._cpp_ctor_param_suffix (   port)
staticprotected
Return the parameter name suffix ('_chan', '_svc', or '_port').

Definition at line 197 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _cpp_ctor_param_type()

str esiaccel.codegen.CppGenerator._cpp_ctor_param_type (   self,
  port 
)
protected
Return the C++ constructor parameter type for a port.

Definition at line 180 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _cpp_indexed_elem_type()

str esiaccel.codegen.CppGenerator._cpp_indexed_elem_type (   self,
  port,
Optional[str]   alias_prefix = None 
)
protected
Return the storage type used inside an `IndexedPorts<T>` for `port`.

Typed ports use the same `TypedFunction<...>` / `TypedReadPort<...>` etc.
that `_cpp_member_type` produces. MMIO regions, telemetry metrics, and
plain bundle ports are stored as raw pointers because `std::map<int, T&>`
is ill-formed.

Definition at line 161 of file codegen.py.

References esiaccel.codegen.CppGenerator._cpp_member_type().

Referenced by esiaccel.codegen.CppGenerator._indexed_ports_group().

◆ _cpp_member_type()

str esiaccel.codegen.CppGenerator._cpp_member_type (   self,
  port,
Optional[str]   alias_prefix = None 
)
protected
Return the C++ member type string for a port (no member name).

For typed ports (function/callback/to-host/from-host channels) `alias_prefix`
is required; the returned template parameters are written using the alias
names (`<prefix>Args`, `<prefix>Result`, `<prefix>Data`) that should be
emitted at module-class scope via `_port_using_aliases`. For non-typed
ports (MMIO regions, telemetry metrics, plain bundles) `alias_prefix` is
ignored and the runtime reference/pointer type is returned directly.

Definition at line 109 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._cpp_indexed_elem_type(), esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _emit_module_class()

None esiaccel.codegen.CppGenerator._emit_module_class (   self,
str  name,
str  system_name,
ModuleInfo  module_info,
List[_PortGroup port_groups,
TextIO  out 
)
protected
Emit the full module class to `out`.

Definition at line 496 of file codegen.py.

References esiaccel.codegen.CppGenerator.get_consts_str().

Referenced by esiaccel.codegen.CppGenerator.write_modules().

◆ _indexed_ports_group()

_PortGroup esiaccel.codegen.CppGenerator._indexed_ports_group (   self,
str  member_name,
str  appid_name,
  port_list 
)
protected

◆ _mixed_struct_group()

_PortGroup esiaccel.codegen.CppGenerator._mixed_struct_group (   self,
str  member_name,
str  appid_name,
  port_list 
)
protected

◆ _port_find_code()

str esiaccel.codegen.CppGenerator._port_find_code (   self,
str  member_name,
  port,
  appid 
)
protected
Return the code snippet that resolves a scalar port in connect().

Definition at line 214 of file codegen.py.

References esiaccel.codegen.CppGenerator._appid_expr().

Referenced by esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _port_is_connectable()

bool esiaccel.codegen.CppGenerator._port_is_connectable (   port)
staticprotected
True if the generated connect() should call .connect() on this port.

CallbackPort.connect() requires a user-supplied callback — skip.
MMIORegion, BundlePort — no .connect() method.

Definition at line 266 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._indexed_ports_group(), esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _port_make_unique_arg()

str esiaccel.codegen.CppGenerator._port_make_unique_arg ( str  member_name,
  port 
)
staticprotected
Return the argument expression for make_unique<Connected>(...).

Definition at line 257 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _port_using_aliases()

List[Tuple[str, str]] esiaccel.codegen.CppGenerator._port_using_aliases (   self,
str  alias_prefix,
  port 
)
protected
Return (alias_name, type_id) pairs to emit as `using` declarations at
module-class scope for the typed-port template parameters.

Definition at line 145 of file codegen.py.

References esiaccel.codegen.CppGenerator.type_emitter.

Referenced by esiaccel.codegen.CppGenerator._indexed_ports_group(), esiaccel.codegen.CppGenerator._mixed_struct_group(), and esiaccel.codegen.CppGenerator._scalar_port_group().

◆ _sanitize_id()

str esiaccel.codegen.CppGenerator._sanitize_id ( str  name)
staticprotected
Return a C++-safe identifier from an AppID name.

Definition at line 83 of file codegen.py.

References isdigit.

Referenced by esiaccel.codegen.CppGenerator._collect_port_groups().

◆ _scalar_port_group()

_PortGroup esiaccel.codegen.CppGenerator._scalar_port_group (   self,
str  member_name,
  port,
  appid 
)
protected

◆ generate()

esiaccel.codegen.CppGenerator.generate (   self,
Path  output_dir,
str  system_name 
)

◆ get_consts_str()

str esiaccel.codegen.CppGenerator.get_consts_str (   self,
ModuleInfo  module_info 
)
Get the C++ code for a constant in a module.

Definition at line 69 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._emit_module_class().

◆ write_modules()

esiaccel.codegen.CppGenerator.write_modules (   self,
Path  output_dir,
str  system_name 
)

Member Data Documentation

◆ _conn

esiaccel.codegen.CppGenerator._conn
protected

Definition at line 65 of file codegen.py.

Referenced by esiaccel.codegen.CppGenerator._build_module_instance_map().

◆ language

str esiaccel.codegen.CppGenerator.language = "C++"
static

Definition at line 61 of file codegen.py.

◆ type_emitter

esiaccel.codegen.CppGenerator.type_emitter

◆ type_planner

esiaccel.codegen.CppGenerator.type_planner

Definition at line 66 of file codegen.py.


The documentation for this class was generated from the following file: