"""
This type stub file was generated by pyright.
"""

from typing import Any

from llvmlite.ir._utils import _HasMetadata
from llvmlite.ir.types import Type
from llvmlite.ir.values import AttributeSet, Block, NamedValue, Value

"""
Implementation of LLVM IR instructions.
"""

class Instruction(NamedValue, _HasMetadata):
    opname: str
    flags: list[str]
    type: Type
    def __init__(
        self,
        parent: Block,
        typ: Type,
        opname: str,
        operands: list[Value],
        name: str = ...,
        flags: list[str] | tuple[str, ...] = ...,
    ) -> None: ...
    @property
    def function(self): ...
    @property
    def operands(self) -> list[Value]: ...
    @property
    def opname(self) -> str: ...
    @property
    def flags(self) -> list[str] | tuple[str, ...]: ...
    @property
    def module(self): ...
    def descr(self, buf):  # -> None:
        ...
    def replace_usage(self, old, new):  # -> None:
        ...
    def __repr__(self):  # -> str:
        ...

class CallInstrAttributes(AttributeSet):
    _known = ...

TailMarkerOptions = ...

class FastMathFlags(AttributeSet):
    _known = ...

class CallInstr(Instruction):
    def __init__(
        self,
        parent: Block,
        func: Value,
        args: list[Value],
        name: str = ...,
        cconv: str | None = ...,
        tail: bool = ...,
        fastmath: str = ...,
        attrs: Any = ...,
        arg_attrs: Any = ...,
    ) -> None: ...
    @property
    def callee(self): ...
    @callee.setter
    def callee(self, newcallee):  # -> None:
        ...
    @property
    def args(self):  # -> tuple[Any, ...]:
        ...
    def replace_callee(self, newfunc):  # -> None:
        ...
    @property
    def called_function(self):
        """The callee function"""
        ...

    def descr(self, buf):  # -> None:
        ...

class InvokeInstr(CallInstr):
    def __init__(
        self,
        parent,
        func,
        args,
        normal_to,
        unwind_to,
        name=...,
        cconv=...,
        fastmath=...,
        attrs=...,
        arg_attrs=...,
    ) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class Terminator(Instruction):
    def __init__(self, parent: Block, opname: str, operands: list[Value]) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class PredictableInstr(Instruction):
    def set_weights(self, weights):  # -> None:
        ...

class Ret(Terminator):
    def __init__(
        self, parent: Block, opname: str, return_value: Value | None = ...
    ) -> None: ...
    @property
    def return_value(self):  # -> None:
        ...
    def descr(self, buf):  # -> None:
        ...

class Branch(Terminator): ...
class ConditionalBranch(PredictableInstr, Terminator): ...

class IndirectBranch(PredictableInstr, Terminator):
    def __init__(self, parent: Block, opname: str, addr: Value) -> None: ...
    @property
    def address(self): ...
    def add_destination(self, block):  # -> None:
        ...
    def descr(self, buf):  # -> None:
        ...

class SwitchInstr(PredictableInstr, Terminator):
    def __init__(
        self, parent: Block, opname: str, val: Value, default: Block
    ) -> None: ...
    @property
    def value(self): ...
    def add_case(self, val, block):  # -> None:
        ...
    def descr(self, buf):  # -> None:
        ...

class Resume(Terminator): ...

class SelectInstr(Instruction):
    def __init__(
        self,
        parent: Block,
        cond: Value,
        lhs: Value,
        rhs: Value,
        name: str = ...,
        flags: list[str] = ...,
    ) -> None: ...
    @property
    def cond(self): ...
    @property
    def lhs(self): ...
    @property
    def rhs(self): ...
    def descr(self, buf):  # -> None:
        ...

class CompareInstr(Instruction):
    OPNAME = ...
    VALID_OP = ...
    def __init__(
        self,
        parent: Block,
        op: str,
        lhs: Value,
        rhs: Value,
        name: str = ...,
        flags: list[str] = ...,
    ) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class ICMPInstr(CompareInstr):
    OPNAME = ...
    VALID_OP = ...
    VALID_FLAG = ...

class FCMPInstr(CompareInstr):
    OPNAME = ...
    VALID_OP = ...
    VALID_FLAG = ...

class CastInstr(Instruction):
    def __init__(
        self,
        parent: Block,
        op: str,
        val: Value,
        typ: Type,
        name: str = ...,
        flags: list[str] | tuple[str, ...] = ...,
    ) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class LoadInstr(Instruction):
    align: int | None
    def __init__(
        self, parent: Block, ptr: Value, name: str = ..., typ: Type | None = ...
    ) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class StoreInstr(Instruction):
    align: int | None
    def __init__(self, parent: Block, val: Value, ptr: Value) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class LoadAtomicInstr(Instruction):
    def __init__(self, parent, ptr, ordering, align, name=..., typ=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class StoreAtomicInstr(Instruction):
    def __init__(self, parent, val, ptr, ordering, align) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class AllocaInstr(Instruction):
    align: int | None
    def __init__(
        self, parent: Block, typ: Type, count: Value | int, name: str
    ) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class GEPInstr(Instruction):
    def __init__(
        self,
        parent: Block,
        ptr: Value,
        indices: list[Value],
        inbounds: bool,
        name: str,
        source_etype: Type = ...,
    ) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class PhiInstr(Instruction):
    def __init__(self, parent, typ, name, flags=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...
    def add_incoming(self, value: Value, block: Block) -> None: ...
    def replace_usage(self, old, new):  # -> None:
        ...

class ExtractElement(Instruction):
    def __init__(self, parent, vector, index, name=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class InsertElement(Instruction):
    def __init__(self, parent, vector, value, index, name=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class ShuffleVector(Instruction):
    def __init__(self, parent, vector1, vector2, mask, name=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class ExtractValue(Instruction):
    def __init__(self, parent, agg, indices, name=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class InsertValue(Instruction):
    def __init__(self, parent, agg, elem, indices, name=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class Unreachable(Instruction):
    def __init__(self, parent) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class InlineAsm(Value):
    def __init__(self, ftype, asm, constraint, side_effect=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...
    def get_reference(self):  # -> LiteralString:
        ...

class AtomicRMW(Instruction):
    def __init__(self, parent, op, ptr, val, ordering, name) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class CmpXchg(Instruction):
    """This instruction has changed since llvm3.5.  It is not compatible with
    older llvm versions.
    """
    def __init__(self, parent, ptr, cmp, val, ordering, failordering, name) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class _LandingPadClause:
    def __init__(self, value) -> None: ...

class CatchClause(_LandingPadClause):
    kind = ...

class FilterClause(_LandingPadClause):
    kind = ...
    def __init__(self, value) -> None: ...

class LandingPadInstr(Instruction):
    def __init__(self, parent, typ, name=..., cleanup=...) -> None: ...
    def add_clause(self, clause):  # -> None:
        ...
    def descr(self, buf):  # -> None:
        ...

class Fence(Instruction):
    """
    The `fence` instruction.

    As of LLVM 5.0.1:

    fence [syncscope("<target-scope>")] <ordering>  ; yields void
    """

    VALID_FENCE_ORDERINGS = ...
    def __init__(self, parent, ordering, targetscope=..., name=...) -> None: ...
    def descr(self, buf):  # -> None:
        ...

class Comment(Instruction):
    """
    A line comment.
    """
    def __init__(self, parent, text) -> None: ...
    def descr(self, buf):  # -> None:
        ...
