Deeploy.CommonExtensions.CodeTransformationPasses.MemoryAllocation.ArgumentStructGeneration

class Deeploy.CommonExtensions.CodeTransformationPasses.MemoryAllocation.ArgumentStructGeneration

Bases: CodeTransformationPass, IntrospectiveCodeTransformationMixIn

A code transformation pass that generates a struct for function arguments.

Methods

__init__()

__init__()

apply(ctxt, executionBlock, name[, verbose])

Apply the argument struct generation transformation.

dereferenceVars(template, varNames)

Dereference the specified variables in the given template.

extractDynamicReferences(ctxt[, ...])

Extract all dynamic references from the given execution block.

indexVars(template, varNames, index)

Index the specified variables in the given template.

Attributes

parseTreeDict

apply(ctxt: NetworkContext, executionBlock: ExecutionBlock, name: str, verbose: CodeGenVerbosity = CodeGenVerbosity(tilingProfiling=None, untiledProfiling=None)) Tuple[NetworkContext, ExecutionBlock]

Apply the argument struct generation transformation.

This transformation generates a struct for the function arguments. It allocates memory for the struct and initializes its fields.

Parameters:
  • ctxt (NetworkContext) – The network context.

  • executionBlock (ExecutionBlock) – The execution block.

  • name (str) – The name of the argument.

  • verbose (CodeGenVerbosity, optional) – The verbosity level for code generation.

Returns:

The transformed network context and execution block.

Return type:

Tuple[NetworkContext, ExecutionBlock]

static dereferenceVars(template: Template, varNames: List[str]) None

Dereference the specified variables in the given template.

This function modifies the provided template in place by dereferencing the variables listed in varNames. The template is modified in place.

Parameters:
  • template (Template) – The template object to be modified.

  • varNames (list of str) – List of variable names to dereference within the template.

extractDynamicReferences(ctxt: NetworkContext, executionBlock: ExecutionBlock = None, unrollStructs=False, includeGlobalReferences=False)

Extract all dynamic references from the given execution block.

Parameters:
  • ctxt (NetworkContext) – The network context.

  • executionBlock (ExecutionBlock, optional) – The execution block.

  • unrollStructs (bool, optional) – Whether to unroll structs.

  • includeGlobalReferences (bool, optional) – Whether to include global references.

Returns:

A list of dynamic references.

Return type:

List[str]

static indexVars(template: Template, varNames: List[str], index: str) None

Index the specified variables in the given template.

Modifies the template in place by indexing the specified variable names.

Parameters:
  • template (Template) – The template to modify.

  • varNames (List[str]) – The variable names to index.

  • index (str) – The index to use.