
    J/PhL                        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ej                  Z G d d	ej                  Z G d
 dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d de          Z G d de          Z G d de          Z G d de          Z  G d de          Z! G d de          Z" G 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jB        ej%        jA        _*        ej$        gej%        jC        _'        ejD        ej%        jC        _*        ej$        gej%        jE        _'        ejF        ej%        jE        _*        ej$        gej%        jG        _'        ejH        ej%        jG        _*        ej$        gej%        jI        _'        ejJ        ej%        jI        _*        ej;        gej%        jK        _'        ej?        gej%        jL        _'        ejB        gej%        jM        _'        ejF        gej%        jN        _'        ejH        gej%        jO        _'        ejJ        gej%        jP        _'        ej;        gej%        jQ        _'        eej%        jQ        _*        ej?        gej%        jR        _'        eej%        jR        _*        ejB        gej%        jS        _'        ej$        ej%        jS        _*        ejD        gej%        jT        _'        ej$        ej%        jT        _*        ejF        gej%        jU        _'        ej$        ej%        jU        _*        ejH        gej%        jV        _'        ej$        ej%        jV        _*        ejJ        g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                   R    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     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/llvmlite/binding/value.pyr   r   
   sj         HLLHHIHGIIMEFNr9   r   c                       e Zd ZdZdZdZdS )
Visibilityr   r   r   N)r$   r%   r&   defaulthidden	protectedr8   r9   r:   r<   r<       s         GFIIIr9   r<   c                       e Zd ZdZdZdZdS )StorageClassr   r   r   N)r$   r%   r&   r=   r1   r2   r8   r9   r:   rA   rA   (   s         GIIIIr9   rA   c                   v    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_valuer8   r9   r:   rC   rC   0   s         HKJJJHLLOMMNOOK LKJKLLLr9   rC   c                      e Zd ZdZd Zd Zed             Zed             Zed             Z	ed             Z
ed             Zed	             Zed
             Zed             Zed             Zed             Zed             Zed             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zd Zed             Zed             Zed             Zed             Zed             Zed             Zed             Zed              Z ed!             Z!ed"             Z"d&d$Z#d%S )'ValueRefz&A weak reference to a LLVM value.
    c                 b    || _         || _        t          j                            | |           d S N)_kind_parentsr   	ObjectRef__init__)selfptrkindparentss       r:   rn   zValueRef.__init__W   s.    
tS)))))r9   c                     t          j                    5 }t           j                            | |           t	          |          cd d d            S # 1 swxY w Y   d S rj   )r   OutputStringlibLLVMPY_PrintValueToStringstr)ro   outstrs     r:   __str__zValueRef.__str__\   s     	6G--dF;;;v;;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   /AAAc                 6    | j                             d          S )zV
        The module this function or global variable value was obtained from.
        modulerl   getro   s    r:   r{   zValueRef.modulea   s    
 }  ***r9   c                 6    | j                             d          S )zT
        The function this argument or basic block value was obtained from.
        rR   r|   r~   s    r:   rR   zValueRef.functionh   s    
 }  ,,,r9   c                 6    | j                             d          S )zE
        The block this instruction value was obtained from.
        blockr|   r~   s    r:   r   zValueRef.blocko   s    
 }  )))r9   c                 6    | j                             d          S )zG
        The instruction this operand value was obtained from.
        re   r|   r~   s    r:   re   zValueRef.instructionv   s    
 }  ///r9   c                     | j         dk    S )Nglobalrk   r~   s    r:   	is_globalzValueRef.is_global}   s    zX%%r9   c                     | j         dk    S )NrR   r   r~   s    r:   is_functionzValueRef.is_function       zZ''r9   c                     | j         dk    S )Nr   r   r~   s    r:   is_blockzValueRef.is_block   s    zW$$r9   c                     | j         dk    S )NrM   r   r~   s    r:   is_argumentzValueRef.is_argument   r   r9   c                     | j         dk    S )Nre   r   r~   s    r:   is_instructionzValueRef.is_instruction   s    z]**r9   c                     | j         dk    S )Noperandr   r~   s    r:   
is_operandzValueRef.is_operand   s    zY&&r9   c                 Z    t          t          j                            |                     S rj   )boolr   ru   LLVMPY_IsConstantr~   s    r:   is_constantzValueRef.is_constant   s     CG--d33444r9   c                 Z    t          t          j                            |                     S rj   )rC   r   ru   LLVMPY_GetValueKindr~   s    r:   
value_kindzValueRef.value_kind   s     44T::;;;r9   c                 Z    t          t          j                            |                     S rj   )r   r   ru   LLVMPY_GetValueNamer~   s    r:   namezValueRef.name   s     cg99$??@@@r9   c                 `    t           j                            | t          |                     d S rj   )r   ru   LLVMPY_SetValueNamer   )ro   vals     r:   r   zValueRef.name   s(    ##D.*=*=>>>>>r9   c                 Z    t          t          j                            |                     S rj   )r   r   ru   LLVMPY_GetLinkager~   s    r:   linkagezValueRef.linkage   s     sw0066777r9   c                     t          |t                    st          |         }t          j                            | |           d S rj   )
isinstancer   r   ru   LLVMPY_SetLinkagero   values     r:   r   zValueRef.linkage   s;    %)) 	#ENE!!$.....r9   c                 Z    t          t          j                            |                     S rj   )r<   r   ru   LLVMPY_GetVisibilityr~   s    r:   
visibilityzValueRef.visibility   s     #'66t<<===r9   c                     t          |t                    st          |         }t          j                            | |           d S rj   )r   r<   r   ru   LLVMPY_SetVisibilityr   s     r:   r   zValueRef.visibility   s<    %,, 	&u%E$$T511111r9   c                 Z    t          t          j                            |                     S rj   )rA   r   ru   LLVMPY_GetDLLStorageClassr~   s    r:   storage_classzValueRef.storage_class   s     CG==dCCDDDr9   c                     t          |t                    st          |         }t          j                            | |           d S rj   )r   rA   r   ru   LLVMPY_SetDLLStorageClassr   s     r:   r   zValueRef.storage_class   s<    %.. 	( 'E))$66666r9   c                 d   | j         st          d| j                  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 r   zno such attribute {!r}N)r   
ValueErrorrk   rw   r   ru   "LLVMPY_GetEnumAttributeKindForNamer   lenformatLLVMPY_AddFunctionAttr)ro   attrattrnameattrvals       r:   add_function_attributezValueRef.add_function_attribute   s      	P*$**NOOOt99'<<8$$c(mm5 5a<<5<<XFFGGG&&tW55555r9   c                 Z    t          t          j                            |                     S )z)
        This value's LLVM type.
        )r   r   ru   LLVMPY_TypeOfr~   s    r:   typezValueRef.type   s"     sw,,T22333r9   c                 z    | 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   ru   LLVMPY_GlobalGetValueTyper~   s    r:   global_value_typezValueRef.global_value_type   s8     ~1!1111sw88>>???r9   c                     | j         s| j        st          d| j                  t          j                            |           S )zb
        Whether this value (presumably global) is defined in the current
        module.
        z'expected global or function value, got )r   r   r   rk   r   ru   LLVMPY_IsDeclarationr~   s    r:   is_declarationzValueRef.is_declaration   sN      	.$"2 	.* $

- . . .w++D111r9   c                 \   t          d          }| j        r/t          j                            |           }t          |          }n| j        rt| j        dk    r/t          j                            |           }t          |          }n| j        dk    r.t          j        	                    |           }t          |          }nk| j
        r/t          j                            |           }t          |          }n5| j        r.t          j                            |           }t          |          }|S )z
        Return an iterator over this value's attributes.
        The iterator will yield a string for each attribute.
        r8   callinvoke)iterr   r   ru   LLVMPY_FunctionAttributesIter_AttributeListIteratorr   opcodeLLVMPY_CallInstAttributesIterLLVMPY_InvokeInstAttributesIterr   LLVMPY_GlobalAttributesIter_AttributeSetIteratorr   LLVMPY_ArgumentAttributesIter)ro   itrits      r:   
attributeszValueRef.attributes   s
    2hh 	,66t<<B(,,CC  	,{f$$W::4@@,R00((W<<TBB,R00^ 	,44T::B'++CC 	,66t<<B'++C
r9   c                     | j         st          d| j                  t          j                            |           }| j                                        }|                    |            t          ||          S )z|
        Return an iterator over this function's blocks.
        The iterator will yield a ValueRef for each block.
        r   rR   )
r   r   rk   r   ru   LLVMPY_FunctionBlocksIterrl   copyupdate_BlocksIteratorro   r   rr   s      r:   blockszValueRef.blocks  ss      	P*$**NOOOW..t44-$$&&%%%r7+++r9   c                     | j         st          d| j                  t          j                            |           }| j                                        }|                    |            t          ||          S )z
        Return an iterator over this function's arguments.
        The iterator will yield a ValueRef for each argument.
        r   r   )
r   r   rk   r   ru   LLVMPY_FunctionArgumentsIterrl   r   r   _ArgumentsIteratorr   s      r:   	argumentszValueRef.arguments  ss      	P*$**NOOOW11$77-$$&&%%%!"g...r9   c                     | j         st          d| j                  t          j                            |           }| j                                        }|                    |            t          ||          S )z
        Return an iterator over this block's instructions.
        The iterator will yield a ValueRef for each instruction.
        zexpected block value, got )r   )
r   r   rk   r   ru   LLVMPY_BlockInstructionsIterrl   r   r   _InstructionsIteratorr   s      r:   instructionszValueRef.instructions%  sr     } 	M*tzzKLLLW11$77-$$&&T"""$R111r9   c                     | j         st          d| j                  t          j                            |           }| j                                        }|                    |            t          ||          S )z
        Return an iterator over this instruction's operands.
        The iterator will yield a ValueRef for each operand.
         expected instruction value, got re   )
r   r   rk   r   ru   LLVMPY_InstructionOperandsIterrl   r   r   _OperandsIteratorr   s      r:   operandszValueRef.operands2  s{     " 	.* $

- . . .W33D99-$$&&4((( W---r9   c                     | j         st          d| j                  t          j        t          j                            |                     S )Nr   )r   r   rk   r   
ret_stringru   LLVMPY_GetOpcodeNamer~   s    r:   r   zValueRef.opcode@  sM    " 	.* $

- . . .~cg::4@@AAAr9   c                    | j         r| j        dk    rt          d| j                  t          j                            |           }| j                                        }|	                    |            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 r   )r   r   r   rk   r   ru   LLVMPY_PhiIncomingBlocksIterrl   r   r   _IncomingBlocksIteratorr   s      r:   incoming_blockszValueRef.incoming_blocksG  s     " 	.dkU&:&:* $

- . . .W11$77-$$&&4(((&r7333r9   Fc           	         | j         st          d| j                  | j        t          j        k    rt          d          }t          j        	                    |           }t          j        
                    | t          |                    }t          t          |t          t          |z                      j                  }t"                              ||j        rdnd|          S | j        t          j        k    rft          d          }t          j                            | t          |                    }|j        r!|st          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 Flittlebig)signedz:Accuracy loss encountered in conversion of constant value )r   r   rk   r   rC   r_   r   r   ru   LLVMPY_GetConstantIntNumWordsLLVMPY_GetConstantIntRawValuer   bytesr   r   r   contentsint
from_bytesr   r`   LLVMPY_GetConstantFPValuerw   )	ro   
signed_intround_fplittle_endianwordsrp   asbytesaccuracy_lossr   s	            r:   get_constant_valuezValueRef.get_constant_valueU  sp     	.* $

- . . . ?i444"5MMMG99$??E'77eM**, ,CDgh.>&?&?@@IJJG>>*0;e! "   
 _	 555"5MMMG55d6;M6J6JL LE" *8 * ) YY) )* * * L 4yyr9   N)FF)$r$   r%   r&   __doc__rn   ry   propertyr{   rR   r   re   r   r   r   r   r   r   r   r   r   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r8   r9   r:   rh   rh   S   s        * * *
  
 + + X+ - - X- * * X* 0 0 X0 & & X& ( ( X( % % X% ( ( X( + + X+ ' ' X' 5 5 X5 < < X< A A XA 
[? ? [? 8 8 X8 ^/ / ^/
 > > X> 2 2 2
 E E XE 7 7 7
6 6 6" 4 4 X4 @ @ X@ 2 2 X2   X0 
, 
, X
, 
/ 
/ X
/ 
2 
2 X
2 . . X. B B XB 4 4 X4+ + + + + +r9   rh   c                   (    e Zd ZdZd Zd ZeZd ZdS )_ValueIteratorNc                     t           j                            | |           || _        | j        $t          t          |           j        d          d S )Nz must specify kind attribute)r   rm   rn   rl   rq   NotImplementedErrorr   r$   )ro   rp   rr   s      r:   rn   z_ValueIterator.__init__  s]    tS)))9%)-d)<)<)<'? @ @ @ r9   c                 r    |                                  }|rt          || j        | j                  S t          rj   )_nextrh   rq   rl   StopIterationro   vps     r:   __next__z_ValueIterator.__next__  s3    ZZ\\ 	 B	4=999r9   c                     | S rj   r8   r~   s    r:   __iter__z_ValueIterator.__iter__      r9   )r$   r%   r&   rq   rn   r  nextr  r8   r9   r:   r	  r	    sP        D@ @ @      D    r9   r	  c                       e Zd Zd ZeZd ZdS )_AttributeIteratorc                 @    |                                  }|r|S t          rj   )r  r  r  s     r:   r  z_AttributeIterator.__next__  s"    ZZ\\ 	 Ir9   c                     | S rj   r8   r~   s    r:   r  z_AttributeIterator.__iter__  r  r9   N)r$   r%   r&   r  r  r  r8   r9   r:   r  r    s9              D    r9   r  c                       e Zd Zd Zd ZdS )r   c                 :    | j                             |            d S rj   )_capiLLVMPY_DisposeAttributeListIterr~   s    r:   _disposez_AttributeListIterator._dispose  s    
22488888r9   c                 d    t          j        t           j                            |                     S rj   )r   	ret_bytesru   LLVMPY_AttributeListIterNextr~   s    r:   r  z_AttributeListIterator._next  s"    }SWAA$GGHHHr9   Nr$   r%   r&   r  r  r8   r9   r:   r   r     s7        9 9 9I I I I Ir9   r   c                       e Zd Zd Zd ZdS )r   c                 :    | j                             |            d S rj   )r  LLVMPY_DisposeAttributeSetIterr~   s    r:   r  z_AttributeSetIterator._dispose      
11$77777r9   c                 d    t          j        t           j                            |                     S rj   )r   r   ru   LLVMPY_AttributeSetIterNextr~   s    r:   r  z_AttributeSetIterator._next  s"    }SW@@FFGGGr9   Nr"  r8   r9   r:   r   r     s7        8 8 8H H H H Hr9   r   c                       e Zd ZdZd Zd ZdS )r   r   c                 :    | j                             |            d S rj   )r  LLVMPY_DisposeBlocksIterr~   s    r:   r  z_BlocksIterator._dispose  s    
++D11111r9   c                 @    t           j                            |           S rj   )r   ru   LLVMPY_BlocksIterNextr~   s    r:   r  z_BlocksIterator._next  s    w,,T222r9   Nr$   r%   r&   rq   r  r  r8   r9   r:   r   r     s7        D2 2 23 3 3 3 3r9   r   c                       e Zd ZdZd Zd ZdS )r   rM   c                 :    | j                             |            d S rj   )r  LLVMPY_DisposeArgumentsIterr~   s    r:   r  z_ArgumentsIterator._dispose  s    
..t44444r9   c                 @    t           j                            |           S rj   )r   ru   LLVMPY_ArgumentsIterNextr~   s    r:   r  z_ArgumentsIterator._next  s    w//555r9   Nr.  r8   r9   r:   r   r     s7        D5 5 56 6 6 6 6r9   r   c                       e Zd ZdZd Zd ZdS )r   re   c                 :    | j                             |            d S rj   )r  LLVMPY_DisposeInstructionsIterr~   s    r:   r  z_InstructionsIterator._dispose  r&  r9   c                 @    t           j                            |           S rj   )r   ru   LLVMPY_InstructionsIterNextr~   s    r:   r  z_InstructionsIterator._next  s    w224888r9   Nr.  r8   r9   r:   r   r     s7        D8 8 89 9 9 9 9r9   r   c                       e Zd ZdZd Zd ZdS )r   r   c                 :    | j                             |            d S rj   )r  LLVMPY_DisposeOperandsIterr~   s    r:   r  z_OperandsIterator._dispose  s    
--d33333r9   c                 @    t           j                            |           S rj   )r   ru   LLVMPY_OperandsIterNextr~   s    r:   r  z_OperandsIterator._next  s    w..t444r9   Nr.  r8   r9   r:   r   r     s7        D4 4 45 5 5 5 5r9   r   c                       e Zd ZdZd Zd ZdS )r   r   c                 :    | j                             |            d S rj   )r   LLVMPY_DisposeIncomingBlocksIterr~   s    r:   r  z _IncomingBlocksIterator._dispose  s    
33D99999r9   c                 @    t           j                            |           S rj   )r   ru   LLVMPY_IncomingBlocksIterNextr~   s    r:   r  z_IncomingBlocksIterator._next  s    w44T:::r9   Nr.  r8   r9   r:   r   r     s7        D: : :; ; ; ; ;r9   r   )^ctypesr   r   r   r   r   r   r	   r
   r   r   r   enumllvmlite.bindingr   llvmlite.binding.commonr   r   llvmlite.binding.typerefr   IntEnumr   r<   rA   rC   rm   rh   r	  r  r   r   r   r   r   r   r   LLVMValueRefru   rv   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+  r6  r;  r@  r!  r(  r-  r3  r8  r=  rB  r   r   r   r   r   r   r8   r9   r:   <module>rW     s  8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8              B B B B B B B B , , , , , ,    dl   ,           4<                  Fm m m m ms} m m m`	    S]   4       I I I I I/ I I IH H H H H. H H H3 3 3 3 3n 3 3 36 6 6 6 6 6 6 69 9 9 9 9N 9 9 95 5 5 5 5 5 5 5; ; ; ; ;n ; ; ; GH. ! *
 ,/+;*<  '),):  &(+(8'9  $&.  #(+(8('C  $"%"2!3   #  .1.>-? ! *,/O ! )'*&7  #%-  "&)&6%7  "$)  !&)&6%>  "),)9(:  %',  $),)95(A  %.1.>-? ! *,1 ! ).1.>-F ! *7?6J * 35; * 2+.+;V*D  '),)9(:  %',  $252B1C % .030M % -252B1C % .030M % -474D3E ' 0252O ' /030@/A # ,.1.J # +252B1C % .030L % -.1.>-? ! *,/,B ! )141A0B $ -/2/H $ ,141A0B $ -/2/K $ ,363C2D & /141I & .141A0B $ -/2/M $ , !4# ' 0 473O2P & /-0-C,D   )363O2P & //2/G.H " + "5$ ( 1 251N0O $ -/7 $ ,030L/M # ,.6 # +*-*@)A  &(+(8  %-0-F,G   )+.+;   (030L/M # ,.1.> # +,/,D+E  (*-*:  ' "2$ % .030@ % -),)9(:  %'/  $&)&6%7  "$*  !(+(8'9  $&+  #252B29'&//2C % .070A0A % -252B1C % .06 % -.1.>.5gfoo.? ! *,4 ! ) ) )r9   