Skip to content

Conversation

@usr3-1415
Copy link
Collaborator

This PR introduces functionality to automatically detect and exclude unused generated functions, resulting in significantly smaller output code for both C and Ada backends.

Key Features

  1. Unused Function Elimination via -icdPdus
    When using the -icdPdus argument, ASN1SCC now performs a dependency analysis starting from the specified PDUs and their associated functions (isEqual(), isValid(), init(), encode(), and decode()).

    • Only the functions directly or indirectly required by these PDUs are generated.
    • All unused functions are excluded from the output, reducing code size and improving maintainability.
  2. New -dpdus Argument
    A new command-line option, -dpdus, was added to help identify Protocol Data Units (PDUs) in the input ASN.1 grammar.

    • PDUs are defined as top-level types that are not referenced by any other type.
    • Detected PDUs are printed to the console to help users configure -icdPdus more easily.

Impact

  • Reduces the size of generated code by omitting unused functions.
  • Especially beneficial for resource-constrained systems or projects aiming to minimize binary size.

Introduce mechanism to track and manage function calls within the state.
Add `calculateFunctionToBeGenerated` to determine necessary functions.
Update functions to propagate and update state with call info.
Handle top-level type assignments and update state accordingly.
Introduce `callersSet` in `AstRoot` to conditionally include/exclude functions.
Combine related function types in `FunctionType` enumeration.
Update `Caller` and `Callee` types to use `TypeAssignmentInfo`.
Optimize generated code by excluding unused functions based on `callersSet`.
Focused on improving PDU handling, optimizing analysis, and generating necessary functions.
Introduced a new mechanism to detect and track Protocol Data Units (PDUs) in the ASN.1/ACN AST.
@usr3-1415 usr3-1415 merged commit 0636196 into master Mar 30, 2025
4 checks passed
@usr3-1415 usr3-1415 deleted the OPTIMIZE_RT2 branch March 30, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants