o
    D2hL                     @   sZ  d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZ d dlZd dlmZ d dlmZmZ d dlmZ G dd dejZG dd	 d	ejZG d
d dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G d d! d!eZ#ej$eegej%j&_'ej$gej%j(_'ej)ej%j(_*ej$gej%j+_'eej%j+_*ej$egej%j,_'ej$gej%j-_'ej.ej%j-_*ej$gej%j/_'ej.ej%j/_*ej.gej%j0_'eej%j0_*ej$gej%j1_'eej%j1_*ej$egej%j2_'ej$gej%j3_'eej%j3_*ej$egej%j4_'ej$gej%j5_'eej%j5_*ej$egej%j6_'eegej%j7_'eej%j7_*ej$egej%j8_'ej$gej%j9_'eej%j9_*ej$gej%j:_'ej;ej%j:_*ej$gej%j<_'ej;ej%j<_*ej$gej%j=_'ej;ej%j=_*ej$gej%j>_'ej?ej%j>_*ej$gej%j@_'ej?ej%j@_*ej$gej%jA_'ejBej%jA_*ej$gej%jC_'ejDej%jC_*ej$gej%jE_'ejFej%jE_*ej$gej%jG_'ejHej%jG_*ej$gej%jI_'ejJej%jI_*ej;gej%jK_'ej?gej%jL_'ejBgej%jM_'ejFgej%jN_'ejHgej%jO_'ejJgej%jP_'ej;gej%jQ_'eej%jQ_*ej?gej%jR_'eej%jR_*ejBgej%jS_'ej$ej%jS_*ejDgej%jT_'ej$ej%jT_*ejFgej%jU_'ej$ej%jU_*ejHgej%jV_'ej$ej%jV_*ejJgej%jW_'ej$ej%jW_*ej$gej%jX_'eej%jX_*ej$gej%jY_'e
ej%jY_*ej$gej%jZ_'eej%jZ_*ej$ee
gej%j[_'ee	ej%j[_*ej$gej%j\_'eej%j\_*ej$ee
gej%j]_'eej%j]_*dS )"    )POINTERbyrefcastc_char_pc_doublec_intc_size_tc_uintc_uint64c_boolc_void_pN)ffi)_decode_string_encode_string)TypeRefc                   @   sP   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdS )Linkager                           	   
                     N)__name__
__module____qualname__externalavailable_externallylinkonce_anylinkonce_odrlinkonce_odr_autohideweak_anyweak_odr	appendinginternalprivate	dllimport	dllexportexternal_weakghostcommonlinker_privatelinker_private_weak r6   r6   j/var/www/html/alexa/alex_system/speach-to-text/venv/lib/python3.10/site-packages/llvmlite/binding/value.pyr   
   s$    r   c                   @      e Zd ZdZdZdZdS )
Visibilityr   r   r   N)r"   r#   r$   defaulthidden	protectedr6   r6   r6   r7   r9           r9   c                   @   r8   )StorageClassr   r   r   N)r"   r#   r$   r:   r/   r0   r6   r6   r6   r7   r>   (   r=   r>   c                   @   st   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdS )	ValueKindr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!                              N)r"   r#   r$   argumentbasic_block
memory_use
memory_def
memory_phifunctionglobal_aliasglobal_ifuncglobal_variableblock_addressconstant_exprconstant_arrayconstant_structconstant_vectorundef_valueconstant_aggregate_zeroconstant_data_arrayconstant_data_vectorconstant_intconstant_fpconstant_pointer_nullconstant_token_nonemetadata_as_value
inline_asminstructionpoison_valuer6   r6   r6   r7   r?   0   s6    r?   c                   @   s  e Zd ZdZdd Zdd Zedd Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zejd d Zed!d" Zejd#d" Zed$d% Zejd&d% Zed'd( Zejd)d( Zd*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 Zed4d5 Zed6d7 Zed8d9 Zed:d; Z ed<d= Z!ed>d? Z"dDdAdBZ#dCS )EValueRefz&A weak reference to a LLVM value.
    c                 C   s   || _ || _tj| | d S N)_kind_parentsr   	ObjectRef__init__)selfptrkindparentsr6   r6   r7   rh   W   s   zValueRef.__init__c                 C   sB   t  }t j| | t|W  d    S 1 sw   Y  d S rd   )r   OutputStringlibLLVMPY_PrintValueToStringstr)ri   outstrr6   r6   r7   __str__\   s   
$zValueRef.__str__c                 C      | j dS )zV
        The module this function or global variable value was obtained from.
        modulerf   getri   r6   r6   r7   rt   a      zValueRef.modulec                 C   rs   )zT
        The function this argument or basic block value was obtained from.
        rN   ru   rw   r6   r6   r7   rN   h   rx   zValueRef.functionc                 C   rs   )zE
        The block this instruction value was obtained from.
        blockru   rw   r6   r6   r7   ry   o   rx   zValueRef.blockc                 C   rs   )zG
        The instruction this operand value was obtained from.
        ra   ru   rw   r6   r6   r7   ra   v   rx   zValueRef.instructionc                 C   
   | j dkS )Nglobalre   rw   r6   r6   r7   	is_global}      
zValueRef.is_globalc                 C   rz   )NrN   r|   rw   r6   r6   r7   is_function   r~   zValueRef.is_functionc                 C   rz   )Nry   r|   rw   r6   r6   r7   is_block   r~   zValueRef.is_blockc                 C   rz   )NrI   r|   rw   r6   r6   r7   is_argument   r~   zValueRef.is_argumentc                 C   rz   )Nra   r|   rw   r6   r6   r7   is_instruction   r~   zValueRef.is_instructionc                 C   rz   )Noperandr|   rw   r6   r6   r7   
is_operand   r~   zValueRef.is_operandc                 C      t tj| S rd   )boolr   rn   LLVMPY_IsConstantrw   r6   r6   r7   is_constant      zValueRef.is_constantc                 C   r   rd   )r?   r   rn   LLVMPY_GetValueKindrw   r6   r6   r7   
value_kind   r   zValueRef.value_kindc                 C   r   rd   )r   r   rn   LLVMPY_GetValueNamerw   r6   r6   r7   name   r   zValueRef.namec                 C   s   t j| t| d S rd   )r   rn   LLVMPY_SetValueNamer   )ri   valr6   r6   r7   r      s   c                 C   r   rd   )r   r   rn   LLVMPY_GetLinkagerw   r6   r6   r7   linkage   r   zValueRef.linkagec                 C   $   t |ts	t| }tj| | d S rd   )
isinstancer   r   rn   LLVMPY_SetLinkageri   valuer6   r6   r7   r         
c                 C   r   rd   )r9   r   rn   LLVMPY_GetVisibilityrw   r6   r6   r7   
visibility   r   zValueRef.visibilityc                 C   r   rd   )r   r9   r   rn   LLVMPY_SetVisibilityr   r6   r6   r7   r      r   c                 C   r   rd   )r>   r   rn   LLVMPY_GetDLLStorageClassrw   r6   r6   r7   storage_class   r   zValueRef.storage_classc                 C   r   rd   )r   r>   r   rn   LLVMPY_SetDLLStorageClassr   r6   r6   r7   r      r   c                 C   s\   | j std| jf t|}tjt|t|}|dkr%td	|tj
| | dS )z{Only works on function value

        Parameters
        -----------
        attr : str
            attribute name
        expected function value, got %sr   zno such attribute {!r}N)r   
ValueErrorre   rp   r   rn   "LLVMPY_GetEnumAttributeKindForNamer   lenformatLLVMPY_AddFunctionAttr)ri   attrattrnameattrvalr6   r6   r7   add_function_attribute   s   zValueRef.add_function_attributec                 C   r   )z)
        This value's LLVM type.
        )r   r   rn   LLVMPY_TypeOfrw   r6   r6   r7   type   s   zValueRef.typec                 C   s    | j s| jsJ ttj| S )z
        Uses ``LLVMGlobalGetValueType()``.
        Needed for opaque pointers in globals.
        > For globals, use getValueType().
        See https://llvm.org/docs/OpaquePointers.html#migration-instructions
        )r}   r   r   r   rn   LLVMPY_GlobalGetValueTyperw   r6   r6   r7   global_value_type   s   zValueRef.global_value_typec                 C   s(   | j s| jstd| jf tj| S )zb
        Whether this value (presumably global) is defined in the current
        module.
        z)expected global or function value, got %s)r}   r   r   re   r   rn   LLVMPY_IsDeclarationrw   r6   r6   r7   is_declaration   s
   zValueRef.is_declarationc                 C   s   t d}| jrtj| }t|}|S | jr8| jdkr'tj| }t|}|S | jdkr6tj	| }t|}|S | j
rGtj| }t|}|S | jrTtj| }t|}|S )z
        Return an iterator over this value's attributes.
        The iterator will yield a string for each attribute.
        r6   callinvoke)iterr   r   rn   LLVMPY_FunctionAttributesIter_AttributeListIteratorr   opcodeLLVMPY_CallInstAttributesIterLLVMPY_InvokeInstAttributesIterr}   LLVMPY_GlobalAttributesIter_AttributeSetIteratorr   LLVMPY_ArgumentAttributesIter)ri   itritr6   r6   r7   
attributes   s,   


zValueRef.attributesc                 C   B   | j std| jf tj| }| j }|j| d t	||S )z|
        Return an iterator over this function's blocks.
        The iterator will yield a ValueRef for each block.
        r   rN   )
r   r   re   r   rn   LLVMPY_FunctionBlocksIterrf   copyupdate_BlocksIteratorri   r   rl   r6   r6   r7   blocks     

zValueRef.blocksc                 C   r   )z
        Return an iterator over this function's arguments.
        The iterator will yield a ValueRef for each argument.
        r   r   )
r   r   re   r   rn   LLVMPY_FunctionArgumentsIterrf   r   r   _ArgumentsIteratorr   r6   r6   r7   	arguments  r   zValueRef.argumentsc                 C   r   )z
        Return an iterator over this block's instructions.
        The iterator will yield a ValueRef for each instruction.
        zexpected block value, got %s)ry   )
r   r   re   r   rn   LLVMPY_BlockInstructionsIterrf   r   r   _InstructionsIteratorr   r6   r6   r7   instructions%  r   zValueRef.instructionsc                 C   r   )z
        Return an iterator over this instruction's operands.
        The iterator will yield a ValueRef for each operand.
        "expected instruction value, got %sra   )
r   r   re   r   rn   LLVMPY_InstructionOperandsIterrf   r   r   _OperandsIteratorr   r6   r6   r7   operands2  s   

zValueRef.operandsc                 C   s(   | j std| jf ttj| S )Nr   )r   r   re   r   
ret_stringrn   LLVMPY_GetOpcodeNamerw   r6   r6   r7   r   @  s
   zValueRef.opcodec                 C   sL   | j r| jdkrtd| jf tj| }| j }|j	| d t
||S )z
        Return an iterator over this phi instruction's incoming blocks.
        The iterator will yield a ValueRef for each block.
        phiz&expected phi instruction value, got %sr   )r   r   r   re   r   rn   LLVMPY_PhiIncomingBlocksIterrf   r   r   _IncomingBlocksIteratorr   r6   r6   r7   incoming_blocksG  s   

zValueRef.incoming_blocksFc           	      C   s   | j std| jf | jtjkr@td}tj	| }tj
| t|}tt|tt| j}tj||jr;d|dS d|dS | jtjkrctd}tj| t|}|jra|satdt|  |S t| S )a  
        Return the constant value, either as a literal (when supported)
        or as a string.

        Parameters
        -----------
        signed_int : bool
            if True and the constant is an integer, returns a signed version
        round_fp : bool
            if True and the constant is a floating point value, rounds the
            result upon accuracy loss (e.g., when querying an fp128 value).
            By default, raises an exception on accuracy loss
        zexpected constant value, got %sFlittlebig)signedz:Accuracy loss encountered in conversion of constant value )r   r   re   r   r?   r[   r   r   rn   LLVMPY_GetConstantIntNumWordsLLVMPY_GetConstantIntRawValuer   bytesr   r   r
   contentsint
from_bytesr   r\   LLVMPY_GetConstantFPValuerp   )	ri   
signed_intround_fplittle_endianwordsrj   asbytesaccuracy_lossr   r6   r6   r7   get_constant_valueU  s@   
zValueRef.get_constant_valueN)FF)$r"   r#   r$   __doc__rh   rr   propertyrt   rN   ry   ra   r}   r   r   r   r   r   r   r   r   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r6   r6   r6   r7   rc   S   s    































rc   c                   @   s,   e Zd ZdZdd Zdd ZeZdd ZdS )_ValueIteratorNc                 C   s6   t j| | || _| jd u rtdt| jf d S )Nz%s must specify kind attribute)r   rg   rh   rf   rk   NotImplementedErrorr   r"   )ri   rj   rl   r6   r6   r7   rh     s   

z_ValueIterator.__init__c                 C   s    |   }|rt|| j| jS trd   )_nextrc   rk   rf   StopIterationri   vpr6   r6   r7   __next__  s   z_ValueIterator.__next__c                 C      | S rd   r6   rw   r6   r6   r7   __iter__     z_ValueIterator.__iter__)r"   r#   r$   rk   rh   r   nextr   r6   r6   r6   r7   r     s    r   c                   @   s    e Zd Zdd ZeZdd ZdS )_AttributeIteratorc                 C   s   |   }|r|S trd   )r   r   r   r6   r6   r7   r     s   z_AttributeIterator.__next__c                 C   r   rd   r6   rw   r6   r6   r7   r     r   z_AttributeIterator.__iter__N)r"   r#   r$   r   r   r   r6   r6   r6   r7   r     s    r   c                   @      e Zd Zdd Zdd ZdS )r   c                 C      | j |  d S rd   )_capiLLVMPY_DisposeAttributeListIterrw   r6   r6   r7   _dispose     z_AttributeListIterator._disposec                 C      t t j| S rd   )r   	ret_bytesrn   LLVMPY_AttributeListIterNextrw   r6   r6   r7   r        z_AttributeListIterator._nextNr"   r#   r$   r   r   r6   r6   r6   r7   r         r   c                   @   r   )r   c                 C   r   rd   )r   LLVMPY_DisposeAttributeSetIterrw   r6   r6   r7   r     r   z_AttributeSetIterator._disposec                 C   r   rd   )r   r   rn   LLVMPY_AttributeSetIterNextrw   r6   r6   r7   r     r   z_AttributeSetIterator._nextNr   r6   r6   r6   r7   r     r  r   c                   @       e Zd ZdZdd Zdd ZdS )r   ry   c                 C   r   rd   )r   LLVMPY_DisposeBlocksIterrw   r6   r6   r7   r     r   z_BlocksIterator._disposec                 C      t j| S rd   )r   rn   LLVMPY_BlocksIterNextrw   r6   r6   r7   r        z_BlocksIterator._nextNr"   r#   r$   rk   r   r   r6   r6   r6   r7   r         r   c                   @   r  )r   rI   c                 C   r   rd   )r   LLVMPY_DisposeArgumentsIterrw   r6   r6   r7   r     r   z_ArgumentsIterator._disposec                 C   r  rd   )r   rn   LLVMPY_ArgumentsIterNextrw   r6   r6   r7   r     r  z_ArgumentsIterator._nextNr	  r6   r6   r6   r7   r     r
  r   c                   @   r  )r   ra   c                 C   r   rd   )r   LLVMPY_DisposeInstructionsIterrw   r6   r6   r7   r     r   z_InstructionsIterator._disposec                 C   r  rd   )r   rn   LLVMPY_InstructionsIterNextrw   r6   r6   r7   r     r  z_InstructionsIterator._nextNr	  r6   r6   r6   r7   r     r
  r   c                   @   r  )r   r   c                 C   r   rd   )r   LLVMPY_DisposeOperandsIterrw   r6   r6   r7   r     r   z_OperandsIterator._disposec                 C   r  rd   )r   rn   LLVMPY_OperandsIterNextrw   r6   r6   r7   r     r  z_OperandsIterator._nextNr	  r6   r6   r6   r7   r     r
  r   c                   @   r  )r   ry   c                 C   r   rd   )r    LLVMPY_DisposeIncomingBlocksIterrw   r6   r6   r7   r     r   z _IncomingBlocksIterator._disposec                 C   r  rd   )r   rn   LLVMPY_IncomingBlocksIterNextrw   r6   r6   r7   r     r  z_IncomingBlocksIterator._nextNr	  r6   r6   r6   r7   r     r
  r   )^ctypesr   r   r   r   r   r   r   r	   r
   r   r   enumllvmlite.bindingr   llvmlite.binding.commonr   r   llvmlite.binding.typerefr   IntEnumr   r9   r>   r?   rg   rc   r   r   r   r   r   r   r   r   r   LLVMValueRefrn   ro   argtypesLLVMPY_GetGlobalParentLLVMModuleRefrestyper   r   r   LLVMTypeRefr   LLVMPY_GetTypeNamer   r   r   r   r   r   r   r   r   r   LLVMAttributeListIteratorr   r   r   LLVMAttributeSetIteratorr   r   LLVMBlocksIteratorr   LLVMArgumentsIteratorr   LLVMInstructionsIteratorr   LLVMOperandsIteratorr   LLVMIncomingBlocksIteratorr   r  r  r  r  r  r   r  r  r  r  r  r  r   r   r   r   r   r   r6   r6   r6   r7   <module>   s   4 #  2		


















