
    sKgJ                     z   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j2                        Z G d dej2                        Z G d dej2                        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jH                   ee      gejJ                  jL                  _'        ejH                  gejJ                  jP                  _'        ejR                  ejJ                  jP                  _*        ejH                  gejJ                  jV                  _'        eejJ                  jV                  _*        ejH                  egejJ                  jX                  _'        ejH                  gejJ                  jZ                  _'        ej\                  ejJ                  jZ                  _*        ej\                  gejJ                  j^                  _'        eejJ                  j^                  _*        ejH                  gejJ                  j`                  _'        eejJ                  j`                  _*        ejH                  egejJ                  jb                  _'        ejH                  gejJ                  jd                  _'        eejJ                  jd                  _*        ejH                  egejJ                  jf                  _'        ejH                  gejJ                  jh                  _'        eejJ                  jh                  _*        ejH                  egejJ                  jj                  _'        eegejJ                  jl                  _'        eejJ                  jl                  _*        ejH                  egejJ                  jn                  _'        ejH                  gejJ                  jp                  _'        eejJ                  jp                  _*        ejH                  gejJ                  jr                  _'        ejt                  ejJ                  jr                  _*        ejH                  gejJ                  jv                  _'        ejt                  ejJ                  jv                  _*        ejH                  gejJ                  jx                  _'        ejt                  ejJ                  jx                  _*        ejH                  gejJ                  jz                  _'        ej|                  ejJ                  jz                  _*        ejH                  gejJ                  j~                  _'        ej|                  ejJ                  j~                  _*        ejH                  gejJ                  j                  _'        ej                  ejJ                  j                  _*        ejH                  gejJ                  j                  _'        ej                  ejJ                  j                  _*        ejH                  gejJ                  j                  _'        ej                  ejJ                  j                  _*        ejH                  gejJ                  j                  _'        ej                  ejJ                  j                  _*        ejH                  gejJ                  j                  _'        ej                  ejJ                  j                  _*        ejt                  gejJ                  j                  _'        ej|                  gejJ                  j                  _'        ej                  gejJ                  j                  _'        ej                  gejJ                  j                  _'        ej                  gejJ                  j                  _'        ej                  gejJ                  j                  _'        ejt                  gejJ                  j                  _'        eejJ                  j                  _*        ej|                  gejJ                  j                  _'        eejJ                  j                  _*        ej                  gejJ                  j                  _'        ejH                  ejJ                  j                  _*        ej                  gejJ                  j                  _'        ejH                  ejJ                  j                  _*        ej                  gejJ                  j                  _'        ejH                  ejJ                  j                  _*        ej                  gejJ                  j                  _'        ejH                  ejJ                  j                  _*        ej                  gejJ                  j                  _'        ejH                  ejJ                  j                  _*        ejH                  gejJ                  j                  _'        eejJ                  j                  _*        ejH                  gejJ                  j                  _'        e
ejJ                  j                  _*        ejH                  gejJ                  j                  _'        eejJ                  j                  _*        ejH                   ee
      gejJ                  j                  _'         ee	      ejJ                  j                  _*        ejH                  gejJ                  j                  _'        eejJ                  j                  _*        ejH                   ee
      gejJ                  j                  _'        eejJ                  j                  _*        y)"    )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                   P    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y)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     Z/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/llvmlite/binding/value.pyr   r   
   s\     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y)
Visibilityr   r   r   N)r$   r%   r&   defaulthidden	protectedr8   r9   r:   r<   r<       s     GFIr9   r<   c                       e Zd ZdZdZdZy)StorageClassr   r   r   N)r$   r%   r&   r=   r1   r2   r8   r9   r:   rA   rA   (   s     GIIr9   rA   c                   t    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y)	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Lr9   rC   c                   J   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!d$d"Z"y#)%ValueRefz&A weak reference to a LLVM value.
    c                 `    || _         || _        t        j                  j	                  | |       y N)_kind_parentsr   	ObjectRef__init__)selfptrkindparentss       r:   rn   zValueRef.__init__W   s$    
tS)r9   c                     t        j                         5 }t         j                  j                  | |       t	        |      cd d d        S # 1 sw Y   y xY wrj   )r   OutputStringlibLLVMPY_PrintValueToStringstr)ro   outstrs     r:   __str__zValueRef.__str__\   s7    6GG--dF;v;  s   +A

Ac                 8    | j                   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                 8    | j                   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                 8    | j                   j                  d      S )zE
        The block this instruction value was obtained from.
        blockr|   r~   s    r:   r   zValueRef.blocko   s    
 }}  ))r9   c                 8    | j                   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    zzX%%r9   c                      | j                   dk(  S )NrR   r   r~   s    r:   is_functionzValueRef.is_function       zzZ''r9   c                      | j                   dk(  S )Nr   r   r~   s    r:   is_blockzValueRef.is_block   s    zzW$$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    zz]**r9   c                      | j                   dk(  S )Noperandr   r~   s    r:   
is_operandzValueRef.is_operand   s    zzY&&r9   c                 R    t        t        j                  j                  |             S rj   )boolr   ru   LLVMPY_IsConstantr~   s    r:   is_constantzValueRef.is_constant   s    CGG--d344r9   c                 R    t        t        j                  j                  |             S rj   )rC   r   ru   LLVMPY_GetValueKindr~   s    r:   
value_kindzValueRef.value_kind   s    44T:;;r9   c                 R    t        t        j                  j                  |             S rj   )r   r   ru   LLVMPY_GetValueNamer~   s    r:   namezValueRef.name   s    cgg99$?@@r9   c                 V    t         j                  j                  | t        |             y rj   )r   ru   LLVMPY_SetValueNamer   )ro   vals     r:   r   zValueRef.name   s    ##D.*=>r9   c                 R    t        t        j                  j                  |             S rj   )r   r   ru   LLVMPY_GetLinkager~   s    r:   linkagezValueRef.linkage   s    sww00677r9   c                 v    t        |t              s	t        |   }t        j                  j	                  | |       y rj   )
isinstancer   r   ru   LLVMPY_SetLinkagero   values     r:   r   zValueRef.linkage   s)    %)ENE!!$.r9   c                 R    t        t        j                  j                  |             S rj   )r<   r   ru   LLVMPY_GetVisibilityr~   s    r:   
visibilityzValueRef.visibility   s    #''66t<==r9   c                 v    t        |t              s	t        |   }t        j                  j	                  | |       y rj   )r   r<   r   ru   LLVMPY_SetVisibilityr   s     r:   r   zValueRef.visibility   s*    %,u%E$$T51r9   c                 R    t        t        j                  j                  |             S rj   )rA   r   ru   LLVMPY_GetDLLStorageClassr~   s    r:   storage_classzValueRef.storage_class   s    CGG==dCDDr9   c                 v    t        |t              s	t        |   }t        j                  j	                  | |       y rj   )r   rA   r   ru   LLVMPY_SetDLLStorageClassr   s     r:   r   zValueRef.storage_class   s*    %. 'E))$6r9   c                 D   | j                   st        d| j                        t        |      }t        j
                  j                  t        |      t        |            }|dk(  rt        dj                  |            t        j
                  j                  | |       y)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|     $**NOOt9''<<8$c(m5a<5<<XFGG&&tW5r9   c                 R    t        t        j                  j                  |             S )z)
        This value's LLVM type.
        )r   r   ru   LLVMPY_TypeOfr~   s    r:   typezValueRef.type   s     sww,,T233r9   c                     | j                   s$| j                  st        d| j                        t        j
                  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   sA     $"2"2 $

- . .ww++D11r9   c                 l   t        d      }| j                  r,t        j                  j	                  |       }t        |      }|S | j                  rv| j                  dk(  r,t        j                  j                  |       }t        |      }|S | j                  dk(  r*t        j                  j                  |       }t        |      }|S | j                  r,t        j                  j                  |       }t        |      }|S | j                  r*t        j                  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    2h66t<B(,C 
   {{f$WW::4@,R0 
 (WW<<TB,R0 
 ^^44T:B'+C 
 66t<B'+C
r9   c                     | j                   st        d| j                        t        j                  j                  |       }| j                  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   s`     $**NOOWW..t4--$$&%r7++r9   c                     | j                   st        d| j                        t        j                  j                  |       }| j                  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  s`     $**NOOWW11$7--$$&%!"g..r9   c                     | j                   st        d| j                        t        j                  j                  |       }| j                  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  s^     }}tzzKLLWW11$7--$$&T"$R11r9   c                     | j                   st        d| j                        t        j                  j                  |       }| j                  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.operands'  sg     "" $

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

- . .~~cgg::4@AAr9   c                    | j                   r| j                  dk7  rt        d| j                        t        j
                  j                  |       }| j                  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_blocks<  sr     ""dkkU&: $

- . .WW11$7--$$&4(&r733r9   c           	         | j                   st        d| j                        | j                  t        j
                  k(  rt        d      }t        j                  j                  |       }t        j                  j                  | t        |            }t        t        |t        t        |z              j                         }t"        j%                  ||j&                  rd|      S d|      S | j                  t        j(                  k(  r[t        d      }t        j                  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_valueJ  sL     $

- . . ??i444"5MMGG99$?E''77eM*,CDgh.>&?@IIJG>>*00! "  6;! "  
 __	 5 55"5MMGG55d6;M6JLE""8  YK)* * L 4y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  r8   r9   r:   rh   rh   S   sy   *

 + + - - * * 0 0 & & ( ( % % ( ( + + ' ' 5 5 < < A A 
[[? ? 8 8 ^^/ /
 > > 2 2
 E E 7 7
6" 4 4 2 2  0 
, 
, 
/ 
/ 
2 
2 . . B B 4 4+r9   rh   c                   &    e Zd ZdZd Zd ZeZd Zy)_ValueIteratorNc                     t         j                  j                  | |       || _        | j                  !t        t        |       j                  d      y )Nz must specify kind attribute)r   rm   rn   rl   rq   NotImplementedErrorr   r$   )ro   rp   rr   s      r:   rn   z_ValueIterator.__init__}  sM    tS)99%)-d)<)<'? @ @ r9   c                 t    | j                         }|r!t        || j                  | j                        S t        rj   )_nextrh   rq   rl   StopIterationro   vps     r:   __next__z_ValueIterator.__next__  s-    ZZ\B		4==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  x  s    D@  Dr9   r  c                       e Zd Zd ZeZd Zy)_AttributeIteratorc                 6    | j                         }|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    s      Dr9   r  c                       e Zd Zd Zd Zy)r   c                 :    | j                   j                  |        y rj   )_capiLLVMPY_DisposeAttributeListIterr~   s    r:   _disposez_AttributeListIterator._dispose  s    

2248r9   c                 f    t        j                  t         j                  j                  |             S rj   )r   	ret_bytesru   LLVMPY_AttributeListIterNextr~   s    r:   r
  z_AttributeListIterator._next  s     }}SWWAA$GHHr9   Nr$   r%   r&   r  r
  r8   r9   r:   r   r     s    9Ir9   r   c                       e Zd Zd Zd Zy)r   c                 :    | j                   j                  |        y rj   )r  LLVMPY_DisposeAttributeSetIterr~   s    r:   r  z_AttributeSetIterator._dispose      

11$7r9   c                 f    t        j                  t         j                  j                  |             S rj   )r   r  ru   LLVMPY_AttributeSetIterNextr~   s    r:   r
  z_AttributeSetIterator._next  s     }}SWW@@FGGr9   Nr  r8   r9   r:   r   r     s    8Hr9   r   c                       e Zd ZdZd Zd Zy)r   r   c                 :    | j                   j                  |        y rj   )r  LLVMPY_DisposeBlocksIterr~   s    r:   r  z_BlocksIterator._dispose  s    

++D1r9   c                 @    t         j                  j                  |       S rj   )r   ru   LLVMPY_BlocksIterNextr~   s    r:   r
  z_BlocksIterator._next  s    ww,,T22r9   Nr$   r%   r&   rq   r  r
  r8   r9   r:   r   r     s    D23r9   r   c                       e Zd ZdZd Zd Zy)r   rM   c                 :    | j                   j                  |        y rj   )r  LLVMPY_DisposeArgumentsIterr~   s    r:   r  z_ArgumentsIterator._dispose  s    

..t4r9   c                 @    t         j                  j                  |       S rj   )r   ru   LLVMPY_ArgumentsIterNextr~   s    r:   r
  z_ArgumentsIterator._next  s    ww//55r9   Nr+  r8   r9   r:   r   r     s    D56r9   r   c                       e Zd ZdZd Zd Zy)r   re   c                 :    | j                   j                  |        y rj   )r  LLVMPY_DisposeInstructionsIterr~   s    r:   r  z_InstructionsIterator._dispose  r#  r9   c                 @    t         j                  j                  |       S rj   )r   ru   LLVMPY_InstructionsIterNextr~   s    r:   r
  z_InstructionsIterator._next  s    ww22488r9   Nr+  r8   r9   r:   r   r     s    D89r9   r   c                       e Zd ZdZd Zd Zy)r   r   c                 :    | j                   j                  |        y rj   )r  LLVMPY_DisposeOperandsIterr~   s    r:   r  z_OperandsIterator._dispose  s    

--d3r9   c                 @    t         j                  j                  |       S rj   )r   ru   LLVMPY_OperandsIterNextr~   s    r:   r
  z_OperandsIterator._next  s    ww..t44r9   Nr+  r8   r9   r:   r   r     s    D45r9   r   c                       e Zd ZdZd Zd Zy)r   r   c                 :    | j                   j                  |        y rj   )r   LLVMPY_DisposeIncomingBlocksIterr~   s    r:   r  z _IncomingBlocksIterator._dispose  s    

33D9r9   c                 @    t         j                  j                  |       S rj   )r   ru   LLVMPY_IncomingBlocksIterNextr~   s    r:   r
  z_IncomingBlocksIterator._next  s    ww44T::r9   Nr+  r8   r9   r:   r   r     s    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   LLVMTypeRefLLVMPY_GetTypeNamer   r   r   r   r   r   r   r   r   r   LLVMAttributeListIteratorr   r   r   LLVMAttributeSetIteratorr   r   LLVMBlocksIteratorr   LLVMArgumentsIteratorr   LLVMInstructionsIteratorr   LLVMOperandsIteratorr   LLVMIncomingBlocksIteratorr  r"  r(  r3  r8  r=  r  r%  r*  r0  r5  r:  r?  r   r   r   r   r   r   r8   r9   r:   <module>rT     su  8 8 8 8    B ,dll , 4<<    Fbs}} bJ	S]] 4 I/ IH. H3n 36 69N 95 5;n ; H. ! ! *
 ,/+;+;*<   '),):):   &(+(8(8'9   $&.   #(+(8(8('C   $"%"2"2!3    #   '*&7   #%-   "&)&6&6%7   "$)   !&)&6&6%>   "),)9)9(:   %',   $),)9)95(A   %.1.>.>-? ! ! *,1 ! ! ).1.>.>-F ! ! *7?6J * * 35; * * 2+.+;+;V*D   '),)9)9(:   %',   $252B2B1C % % .030M0M % % -252B2B1C % % .030M0M % % -474D4D3E ' ' 0252O2O ' ' /030@0@/A # # ,.1.J.J # # +252B2B1C % % .030L0L % % -.1.>.>-? ! ! *,/,B,B ! ! )141A1A0B $ $ -/2/H/H $ $ ,141A1A0B $ $ -/2/K/K $ $ ,363C3C2D & & /141I1I & & .141A1A0B $ $ -/2/M/M $ $ , !!4# ' ' 0 473O3O2P & & /-0-C-C,D     )363O3O2P & & //2/G/G.H " " + ""5$ ( ( 1 251N1N0O $ $ -/7 $ $ ,030L0L/M # # ,.6 # # +*-*@*@)A   &(+(8(8   %-0-F-F,G     )+.+;+;     (030L0L/M # # ,.1.>.> # # +,/,D,D+E   (*-*:*:   ' ""2$ % % .030@0@ % % -),)9)9(:   %'/   $&)&6&6%7   "$*   !(+(8(8'9   $&+   #252B2B29&/2C % % .070A % % -252B2B1C % % .06 % % -.1.>.>.5fo.? ! ! *,4 ! ! )r9   