CIRCT 23.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
esiaccel.codegen.CppTypeEmitter Class Reference

Public Member Functions

None __init__ (self, CppTypePlanner planner)
 
str type_identifier (self, types.ESIType type)
 
None write_header (self, Path output_dir, str system_name)
 

Public Attributes

 type_id_map
 
 ordered_types
 
 has_cycle
 

Protected Member Functions

str _cpp_string_literal (self, str value)
 
str _get_bitvector_str (self, types.ESIType type)
 
str _storage_type (self, int bit_width, bool signed)
 
int _type_byte_width (self, types.ESIType wrapped)
 
Tuple[str, str] _array_base_and_suffix (self, types.ArrayType array_type)
 
str _format_array_type (self, types.ArrayType array_type)
 
str _cpp_type (self, types.ESIType wrapped)
 
types.ESIType _unwrap_aliases (self, types.ESIType wrapped)
 
str _format_array_decl (self, types.ArrayType array_type, str name)
 
str _format_window_field_decl (self, str field_name, types.ESIType field_type)
 
str _format_window_ctor_param (self, str field_name, types.ESIType field_type)
 
None _emit_window_field_copy (self, TextIO hdr, str dest_expr, str src_expr, types.ESIType field_type)
 
int _field_byte_width (self, types.ESIType field_type)
 
 _analyze_window (self, types.WindowType window_type)
 
None _emit_struct (self, TextIO hdr, types.StructType struct_type)
 
None _emit_union (self, TextIO hdr, types.UnionType union_type)
 
None _emit_window (self, TextIO hdr, types.WindowType window_type)
 
None _emit_alias (self, TextIO hdr, types.TypeAlias alias_type)
 

Detailed Description

Emit C++ headers from precomputed type ordering.

Definition at line 395 of file codegen.py.

Constructor & Destructor Documentation

◆ __init__()

None esiaccel.codegen.CppTypeEmitter.__init__ (   self,
CppTypePlanner  planner 
)

Member Function Documentation

◆ _analyze_window()

esiaccel.codegen.CppTypeEmitter._analyze_window (   self,
types.WindowType  window_type 
)
protected

◆ _array_base_and_suffix()

Tuple[str, str] esiaccel.codegen.CppTypeEmitter._array_base_and_suffix (   self,
types.ArrayType  array_type 
)
protected

◆ _cpp_string_literal()

str esiaccel.codegen.CppTypeEmitter._cpp_string_literal (   self,
str  value 
)
protected
Escape a Python string for use as a C++ string literal.

Definition at line 407 of file codegen.py.

◆ _cpp_type()

str esiaccel.codegen.CppTypeEmitter._cpp_type (   self,
types.ESIType  wrapped 
)
protected

◆ _emit_alias()

None esiaccel.codegen.CppTypeEmitter._emit_alias (   self,
TextIO  hdr,
types.TypeAlias  alias_type 
)
protected
Emit a using alias when the alias targets a different C++ type.

Definition at line 814 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._cpp_type(), and esiaccel.codegen.CppTypeEmitter.type_id_map.

Referenced by esiaccel.codegen.CppTypeEmitter.write_header().

◆ _emit_struct()

None esiaccel.codegen.CppTypeEmitter._emit_struct (   self,
TextIO  hdr,
types.StructType  struct_type 
)
protected

◆ _emit_union()

None esiaccel.codegen.CppTypeEmitter._emit_union (   self,
TextIO  hdr,
types.UnionType  union_type 
)
protected
Emit a packed union declaration plus its type id string.

Fields narrower than the union width get wrapper structs with a `_pad`
byte array so the data sits at the MSB end, matching SV packed union
layout where padding occupies the LSBs / lower addresses.

Definition at line 660 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._field_byte_width(), and esiaccel.codegen.CppTypeEmitter.type_id_map.

Referenced by esiaccel.codegen.CppTypeEmitter.write_header().

◆ _emit_window()

None esiaccel.codegen.CppTypeEmitter._emit_window (   self,
TextIO  hdr,
types.WindowType  window_type 
)
protected

◆ _emit_window_field_copy()

None esiaccel.codegen.CppTypeEmitter._emit_window_field_copy (   self,
TextIO  hdr,
str  dest_expr,
str  src_expr,
types.ESIType  field_type 
)
protected
Copy a generated window field, preserving array semantics.

Definition at line 530 of file codegen.py.

Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().

◆ _field_byte_width()

int esiaccel.codegen.CppTypeEmitter._field_byte_width (   self,
types.ESIType  field_type 
)
protected
Compute the byte width of a field type, rounding up to full bytes.

Definition at line 539 of file codegen.py.

Referenced by esiaccel.codegen.CppTypeEmitter._emit_union().

◆ _format_array_decl()

str esiaccel.codegen.CppTypeEmitter._format_array_decl (   self,
types.ArrayType  array_type,
str  name 
)
protected
Emit a field declaration for a multi-dimensional array member.

The declaration flattens nested arrays into repeated bracketed sizes for C++.

Definition at line 494 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._array_base_and_suffix().

Referenced by esiaccel.codegen.CppTypeEmitter._emit_struct(), and esiaccel.codegen.CppTypeEmitter._format_window_field_decl().

◆ _format_array_type()

str esiaccel.codegen.CppTypeEmitter._format_array_type (   self,
types.ArrayType  array_type 
)
protected
Return the C++ type string for a nested array alias.

Definition at line 457 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._array_base_and_suffix().

Referenced by esiaccel.codegen.CppTypeEmitter._cpp_type().

◆ _format_window_ctor_param()

str esiaccel.codegen.CppTypeEmitter._format_window_ctor_param (   self,
str  field_name,
types.ESIType  field_type 
)
protected
Emit a constructor parameter for generated window helpers.

Small scalar header fields are cheaper to pass by value than by reference.
Larger aggregates stay as const references.

Definition at line 514 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._array_base_and_suffix(), esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypePlanner._unwrap_aliases(), and esiaccel.codegen.CppTypeEmitter._unwrap_aliases().

Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().

◆ _format_window_field_decl()

str esiaccel.codegen.CppTypeEmitter._format_window_field_decl (   self,
str  field_name,
types.ESIType  field_type 
)
protected

◆ _get_bitvector_str()

str esiaccel.codegen.CppTypeEmitter._get_bitvector_str (   self,
types.ESIType  type 
)
protected
Get the textual code for the storage class of an integer type.

Definition at line 412 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._storage_type().

Referenced by esiaccel.codegen.CppTypeEmitter._cpp_type().

◆ _storage_type()

str esiaccel.codegen.CppTypeEmitter._storage_type (   self,
int  bit_width,
bool  signed 
)
protected
Get the textual code for a byte-addressable integer storage type.

Definition at line 419 of file codegen.py.

Referenced by esiaccel.codegen.CppTypeEmitter._analyze_window(), and esiaccel.codegen.CppTypeEmitter._get_bitvector_str().

◆ _type_byte_width()

int esiaccel.codegen.CppTypeEmitter._type_byte_width (   self,
types.ESIType  wrapped 
)
protected
Return the size of a fixed-width type in bytes.

Definition at line 439 of file codegen.py.

Referenced by esiaccel.codegen.CppTypeEmitter._analyze_window().

◆ _unwrap_aliases()

types.ESIType esiaccel.codegen.CppTypeEmitter._unwrap_aliases (   self,
types.ESIType  wrapped 
)
protected

◆ type_identifier()

str esiaccel.codegen.CppTypeEmitter.type_identifier (   self,
types.ESIType  type 
)
Get the C++ type string for an ESI type.

Definition at line 403 of file codegen.py.

References esiaccel.codegen.CppTypeEmitter._cpp_type().

◆ write_header()

None esiaccel.codegen.CppTypeEmitter.write_header (   self,
Path  output_dir,
str  system_name 
)

Member Data Documentation

◆ has_cycle

esiaccel.codegen.CppTypeEmitter.has_cycle

Definition at line 401 of file codegen.py.

Referenced by esiaccel.codegen.CppTypeEmitter.write_header().

◆ ordered_types

esiaccel.codegen.CppTypeEmitter.ordered_types

◆ type_id_map

esiaccel.codegen.CppTypeEmitter.type_id_map

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