|
CIRCT 23.0.0git
|
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, List[int]] | _array_base_and_dims (self, types.ArrayType array_type) |
| str | _std_array_type (self, types.ArrayType array_type) |
| str | _cpp_type (self, types.ESIType wrapped) |
| types.ESIType | _unwrap_aliases (self, types.ESIType wrapped) |
| 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) |
| Optional[int] | _safe_byte_width (self, types.ESIType esi_type) |
| None | _emit_size_assert (self, TextIO hdr, str type_name, Optional[int] expected_bytes, str indent="") |
| _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_window_data_accessors (self, TextIO hdr, info) |
| None | _emit_window_deserializer (self, TextIO hdr, info) |
| None | _emit_alias (self, TextIO hdr, types.TypeAlias alias_type) |
Emit C++ headers from precomputed type ordering.
Definition at line 1029 of file codegen.py.
| None esiaccel.codegen.CppTypeEmitter.__init__ | ( | self, | |
| CppTypePlanner | planner | ||
| ) |
Definition at line 1032 of file codegen.py.
Referenced by synth.LongestPathCollection.drop_non_critical_paths(), and synth.LongestPathCollection.merge().
|
protected |
Extract the metadata needed to emit a bulk list window wrapper.
Definition at line 1219 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._storage_type(), esiaccel.codegen.CppTypeEmitter._type_byte_width(), esiaccel.codegen.CppTypePlanner._unwrap_aliases(), esiaccel.codegen.CppTypeEmitter._unwrap_aliases(), and esiaccel.codegen.CppTypeEmitter.type_id_map.
Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Return the base C++ type and outer-to-inner dimensions of a nested array.
Definition at line 1079 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type().
Referenced by esiaccel.codegen.CppTypeEmitter._std_array_type().
|
protected |
Escape a Python string for use as a C++ string literal.
Definition at line 1041 of file codegen.py.
|
protected |
Resolve an ESI type to its C++ identifier.
Definition at line 1104 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._get_bitvector_str(), esiaccel.codegen.CppTypeEmitter._std_array_type(), and esiaccel.codegen.CppTypeEmitter.type_id_map.
Referenced by esiaccel.codegen.CppTypeEmitter._analyze_window(), esiaccel.codegen.CppTypeEmitter._array_base_and_dims(), esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._emit_alias(), esiaccel.codegen.CppTypeEmitter._emit_struct(), esiaccel.codegen.CppTypeEmitter._emit_union(), esiaccel.codegen.CppTypeEmitter._emit_window_data_accessors(), esiaccel.codegen.CppTypeEmitter._format_window_ctor_param(), esiaccel.codegen.CppTypeEmitter._format_window_field_decl(), and esiaccel.codegen.CppTypeEmitter.type_identifier().
|
protected |
Emit a using alias when the alias targets a different C++ type.
Definition at line 1652 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), and esiaccel.codegen.CppTypeEmitter.type_id_map.
Referenced by esiaccel.codegen.CppTypeEmitter.write_header().
|
protected |
Emit a `static_assert` that pins the C++ `sizeof` of a packed type to the byte width derived from the manifest. `std::array` and bit-field layout are technically implementation-defined, so this assertion is the safety net that catches a toolchain that lays them out differently from the wire format. Skipped silently for types without a bounded static size.
Definition at line 1199 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._emit_struct(), esiaccel.codegen.CppTypeEmitter._emit_union(), and esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Emit a packed struct declaration plus its type id string.
Definition at line 1306 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._emit_size_assert(), esiaccel.codegen.CppTypeEmitter._format_window_ctor_param(), esiaccel.codegen.CppTypeEmitter._safe_byte_width(), esiaccel.codegen.CppTypePlanner._unwrap_aliases(), esiaccel.codegen.CppTypeEmitter._unwrap_aliases(), and esiaccel.codegen.CppTypeEmitter.type_id_map.
Referenced by esiaccel.codegen.CppTypeEmitter.write_header().
|
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 1367 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._emit_size_assert(), esiaccel.codegen.CppTypeEmitter._field_byte_width(), and esiaccel.codegen.CppTypeEmitter.type_id_map.
Referenced by esiaccel.codegen.CppTypeEmitter.write_header().
|
protected |
Emit a SegmentedMessageData helper for a serial list window.
Definition at line 1425 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._analyze_window(), esiaccel.codegen.CppTypeEmitter._emit_size_assert(), esiaccel.codegen.CppTypeEmitter._emit_window_data_accessors(), esiaccel.codegen.CppTypeEmitter._emit_window_deserializer(), esiaccel.codegen.CppTypeEmitter._emit_window_field_copy(), esiaccel.codegen.CppTypeEmitter._format_window_ctor_param(), and esiaccel.codegen.CppTypeEmitter._format_window_field_decl().
Referenced by esiaccel.codegen.CppTypeEmitter.write_header().
|
protected |
Emit accessors for the header and data fields of a window helper. Exposes each static header field as a scalar accessor, the count of data frames, and one vector-valued accessor per data field so decoded values are easy to inspect on the read side.
Definition at line 1546 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypePlanner._unwrap_aliases(), and esiaccel.codegen.CppTypeEmitter._unwrap_aliases().
Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Emit a few bridge helpers + a `TypeDeserializer` alias.
The actual decoder lives in `esi::SerialListTypeDeserializer<T>`, which
walks the header/data/footer burst protocol generically. Each window
helper only has to expose:
- `_headerCount(const header_frame &)` -> `count_type`
- `_fromFrames(const header_frame &, std::vector<data_frame> &&)`
-> `std::unique_ptr<T>`
plus a `friend class esi::SerialListTypeDeserializer<T>;` so the template
can reach the (private) `header_frame` definition.
Definition at line 1607 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Copy a generated window field.
Definition at line 1178 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Compute the byte width of a field type, rounding up to full bytes.
Definition at line 1183 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._emit_union().
|
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 1165 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypePlanner._unwrap_aliases(), and esiaccel.codegen.CppTypeEmitter._unwrap_aliases().
Referenced by esiaccel.codegen.CppTypeEmitter._emit_struct(), and esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Emit a packed field declaration for generated window helpers. Arrays use `std::array` (handled by `_cpp_type`), so no bracket syntax is needed and a single uniform declaration form covers every type.
Definition at line 1151 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypePlanner._unwrap_aliases(), and esiaccel.codegen.CppTypeEmitter._unwrap_aliases().
Referenced by esiaccel.codegen.CppTypeEmitter._emit_window().
|
protected |
Get the textual code for the storage class of an integer type.
Definition at line 1046 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._storage_type().
Referenced by esiaccel.codegen.CppTypeEmitter._cpp_type().
|
protected |
Return the bounded byte width of `esi_type`, or `None` if it has no well-defined static size (e.g. unbounded `!esi.any` or recursive types).
Definition at line 1187 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._emit_struct().
|
protected |
Return the equivalent nested `std::array<...>` type for an array. `std::array<T, N>` is layout-compatible in practice with `T[N]` on every major implementation (and identical under `#pragma pack(1)`), so the generator uses it everywhere a fixed-size array would appear. This keeps field/value/ctor types storable in `std::vector` and assignable with `=`.
Definition at line 1090 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._array_base_and_dims().
Referenced by esiaccel.codegen.CppTypeEmitter._cpp_type().
|
protected |
Get the textual code for a byte-addressable integer storage type.
Definition at line 1053 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._analyze_window(), and esiaccel.codegen.CppTypeEmitter._get_bitvector_str().
|
protected |
Return the size of a fixed-width type in bytes.
Definition at line 1073 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._analyze_window().
|
protected |
Strip alias wrappers to reach the underlying type.
Definition at line 1145 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter._analyze_window(), esiaccel.codegen.CppTypePlanner._auto_window_name(), esiaccel.codegen.CppTypePlanner._collect_decls_from_window(), esiaccel.codegen.CppTypePlanner._contains_window(), esiaccel.codegen.CppTypeEmitter._emit_struct(), esiaccel.codegen.CppTypeEmitter._emit_window_data_accessors(), esiaccel.codegen.CppTypeEmitter._format_window_ctor_param(), esiaccel.codegen.CppTypeEmitter._format_window_field_decl(), esiaccel.codegen.CppTypePlanner._is_supported_window(), and esiaccel.codegen.CppTypePlanner._ordered_emit_types().
| str esiaccel.codegen.CppTypeEmitter.type_identifier | ( | self, | |
| types.ESIType | type | ||
| ) |
Get the C++ type string for an ESI type.
Definition at line 1037 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._cpp_type().
| None esiaccel.codegen.CppTypeEmitter.write_header | ( | self, | |
| Path | output_dir, | ||
| str | system_name | ||
| ) |
Emit the fully ordered types.h header into the output directory.
Definition at line 1664 of file codegen.py.
References esiaccel.codegen.CppTypeEmitter._emit_alias(), esiaccel.codegen.CppTypeEmitter._emit_struct(), esiaccel.codegen.CppTypeEmitter._emit_union(), esiaccel.codegen.CppTypeEmitter._emit_window(), esiaccel.codegen.CppTypePlanner.has_cycle, esiaccel.codegen.CppTypeEmitter.has_cycle, esiaccel.codegen.CppTypePlanner.ordered_types, and esiaccel.codegen.CppTypeEmitter.ordered_types.
| esiaccel.codegen.CppTypeEmitter.has_cycle |
Definition at line 1035 of file codegen.py.
Referenced by esiaccel.codegen.CppTypeEmitter.write_header().
| esiaccel.codegen.CppTypeEmitter.ordered_types |
Definition at line 1034 of file codegen.py.
Referenced by esiaccel.codegen.CppTypePlanner.__init__(), and esiaccel.codegen.CppTypeEmitter.write_header().
| esiaccel.codegen.CppTypeEmitter.type_id_map |
Definition at line 1033 of file codegen.py.
Referenced by esiaccel.codegen.CppTypePlanner.__init__(), esiaccel.codegen.CppTypeEmitter._analyze_window(), esiaccel.codegen.CppTypePlanner._auto_window_name(), esiaccel.codegen.CppTypePlanner._collect_aliases(), esiaccel.codegen.CppTypePlanner._collect_structs(), esiaccel.codegen.CppTypePlanner._collect_windows(), esiaccel.codegen.CppTypeEmitter._cpp_type(), esiaccel.codegen.CppTypeEmitter._emit_alias(), esiaccel.codegen.CppTypeEmitter._emit_struct(), esiaccel.codegen.CppTypeEmitter._emit_union(), and esiaccel.codegen.CppTypePlanner._ordered_emit_types().