CompilationStage#

Module: iqm.cpc.compiler.compilation_stage

class iqm.cpc.compiler.compilation_stage.CompilationStage(name, info='')#

Bases: object

Sequence of compiler passes that are applied to the data.

The data and context are returned after all passes have been applied. A pass is a function that takes the data, context and pass options as arguments and returns the modified data. The context is a dictionary that can contain any information that needs to be passed between the passes and accumulates stateful side effects.

Methods

add_passes

Add multiple passes to the stage.

get_pass_args

Get pass function argument names.

get_pass_metadata

Returns all signature metadata in a single call.

get_pass_names

Get pass function names

run

Run all the passes in the stage on the data and context.

Parameters:
add_passes(*passes, index=None)#

Add multiple passes to the stage.

Parameters:
  • passes (Callable) – One or more passes to be added to the stage.

  • prepend – If True, prepend the passes to the stage instead of appending them.

  • index (int | None)

Return type:

None

get_pass_names()#

Get pass function names

Return type:

list[str]

get_pass_args()#

Get pass function argument names.

Return type:

list[str]

run(data, context, options)#

Run all the passes in the stage on the data and context. The data and context are returned after all passes have been applied.

Parameters:
  • data (Any) – The data to be processed.

  • context (dict[str, Any]) – A dictionary containing any additional information that needs to be passed between the passes.

  • options (dict[str, dict[str, dict[str, Any]]]) – A dictionary of stage’s pass function arguments and their values (mapped to the pass function name)

Returns:

The processed data and context.

Return type:

tuple[Any, dict[str, Any]]

static get_pass_metadata(pass_fn)#

Returns all signature metadata in a single call.

Parameters:

pass_fn (Callable)

Return type:

dict[str, Any]

Inheritance

Inheritance diagram of iqm.cpc.compiler.compilation_stage.CompilationStage