irx.builder.protocols

irx.builder.protocols

Source: packages/irx/src/irx/builder/protocols.py

title: Typing protocols for llvmliteir visitors.

Classes

VisitorProtocol(BaseVisitorProtocol, Protocol)

title: Stable interface used by visitor mixins and runtime features.
attributes:
  _llvm:
    type: VariablesLLVM
  named_values:
    type: NamedValueMap
  const_vars:
    type: set[str]
  function_protos:
    type: dict[str, astx.FunctionPrototype]
  llvm_functions_by_symbol_id:
    type: dict[str, ir.Function]
  result_stack:
    type: list[ResultStackValue]
  _buffer_view_global_counter:
    type: int
  loop_stack:
    type: list[LoopTargets]
  cleanup_stack:
    type: list[CleanupEmitter]
  struct_types:
    type: dict[str, ir.Type]
  llvm_structs_by_qualified_name:
    type: dict[str, ir.IdentifiedStructType]
  runtime_features:
    type: RuntimeFeatureState
  entry_function_symbol_id:
    type: str | None
  _fast_math_enabled:
    type: bool
  _current_function_return_type:
    type: astx.DataType | None
  _current_function_signature:
    type: FunctionSignature | None
  _current_generator_frame_ptr:
    type: ir.Value | None
  _current_generator_frame_slots:
    type: dict[str, int]
  _current_generator_out_ptr:
    type: ir.Value | None
  _current_generator_next_state:
    type: int | None
  target:
    type: llvm.TargetRef
  target_machine:
    type: llvm.TargetMachine

Methods

get_function(self, _name: str) -> ir.Function | None
title: Get function.
parameters:
  _name:
    type: str
returns:
  type: ir.Function | None
llvm_function_name_for_node(self, _node: astx.AST, _fallback: str) -> str
title: Return the LLVM symbol name for a function node.
parameters:
  _node:
    type: astx.AST
  _fallback:
    type: str
returns:
  type: str
create_entry_block_alloca(self, _var_name: str, _type_name: str | ir.Type) -> Any
title: Create entry block alloca.
parameters:
  _var_name:
    type: str
  _type_name:
    type: str | ir.Type
returns:
  type: Any
require_runtime_symbol(self, _feature_name: str, _symbol_name: str) -> ir.Function
title: Require runtime symbol.
parameters:
  _feature_name:
    type: str
  _symbol_name:
    type: str
returns:
  type: ir.Function
activate_runtime_feature(self, _feature_name: str) -> None
title: Activate runtime feature.
parameters:
  _feature_name:
    type: str
set_fast_math(self, _enabled: bool) -> None
title: Set fast math.
parameters:
  _enabled:
    type: bool

VisitorMixinTypingBase

title: Type-checking-only annotation carrier for llvmliteir visitor mixins.
attributes:
  _llvm:
    type: VariablesLLVM
  named_values:
    type: NamedValueMap
  const_vars:
    type: set[str]
  function_protos:
    type: dict[str, astx.FunctionPrototype]
  llvm_functions_by_symbol_id:
    type: dict[str, ir.Function]
  result_stack:
    type: list[ResultStackValue]
  _buffer_view_global_counter:
    type: int
  loop_stack:
    type: list[LoopTargets]
  cleanup_stack:
    type: list[CleanupEmitter]
  struct_types:
    type: dict[str, ir.Type]
  llvm_structs_by_qualified_name:
    type: dict[str, ir.IdentifiedStructType]
  runtime_features:
    type: RuntimeFeatureState
  entry_function_symbol_id:
    type: str | None
  _fast_math_enabled:
    type: bool
  _current_function_return_type:
    type: astx.DataType | None
  _current_function_signature:
    type: FunctionSignature | None
  _current_generator_frame_ptr:
    type: ir.Value | None
  _current_generator_frame_slots:
    type: dict[str, int]
  _current_generator_out_ptr:
    type: ir.Value | None
  _current_generator_next_state:
    type: int | None
  target:
    type: llvm.TargetRef
  target_machine:
    type: llvm.TargetMachine

Methods

visit(self, _node: astx.AST) -> None
title: Visit AST nodes.
parameters:
  _node:
    type: astx.AST
visit_child(self, _node: astx.AST) -> None
title: Visit one child AST node.
parameters:
  _node:
    type: astx.AST
get_function(self, _name: str) -> ir.Function | None
title: Get function.
parameters:
  _name:
    type: str
returns:
  type: ir.Function | None
llvm_function_name_for_node(self, _node: astx.AST, _fallback: str) -> str
title: Return the LLVM symbol name for a function node.
parameters:
  _node:
    type: astx.AST
  _fallback:
    type: str
returns:
  type: str
create_entry_block_alloca(self, _var_name: str, _type_name: str | ir.Type) -> Any
title: Create entry block alloca.
parameters:
  _var_name:
    type: str
  _type_name:
    type: str | ir.Type
returns:
  type: Any
require_runtime_symbol(self, _feature_name: str, _symbol_name: str) -> ir.Function
title: Require runtime symbol.
parameters:
  _feature_name:
    type: str
  _symbol_name:
    type: str
returns:
  type: ir.Function
activate_runtime_feature(self, _feature_name: str) -> None
title: Activate runtime feature.
parameters:
  _feature_name:
    type: str
set_fast_math(self, _enabled: bool) -> None
title: Set fast math.
parameters:
  _enabled:
    type: bool

VisitorMixinRuntimeBase

title: Runtime-empty base shared by llvmliteir visitor mixins.