
    sh\                        S SK r S SKrS SKJrJrJr  SSSSSSS	.r\R                  4S
 jr\R                  4S jr	\R                  4S jr
\R                  4S jrS rS rS rS r\R                   4S jrS r " S S\5      rg)    N)instructionstypesvaluesgtlteqnegele)><==!=z>=z<=c                    ^ ^ UU 4S jnU$ )Nc                 L   > [         R                  " U 5      SUU4S jj5       nU$ )Nc                 l   > T" U R                   UR                  TU/X#5      nU R                  U5        U$ Nblocktype_insert)selfargnameflagsinstrclsopnames        g/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/llvmlite/ir/builder.pywrapped$_unop.<locals>.wrap.<locals>.wrapped   s0    

CHHfseTIELLL      	functoolswrapsfnr    r   r   s     r   wrap_unop.<locals>.wrap   %    			 
	
 r"   r%   r   r   r+   s   `` r   _unopr/           Kr"   c                    ^ ^ UU 4S jnU$ )Nc                 L   > [         R                  " U 5      SUU4S jj5       nU$ )Nc                    > UR                   UR                   :w  a(  [        SUR                   < SUR                   < S35      eT" U R                  UR                   TX4X45      nU R                  U5        U$ )N%Operands must be the same type, got (, ))r   
ValueErrorr   r   )r   lhsrhsr   r   r   r   r   s         r   r    %_binop.<locals>.wrap.<locals>.wrapped   s_    xx388# $'HHchh"8 9 9

CHHfsj$NELLLr"   r#   r&   r)   s     r   r+   _binop.<locals>.wrap   s%    			 
	 r"   r%   r.   s   `` r   _binopr<      s    
 Kr"   c                    ^  U 4S jnU$ )Nc                 J   > [         R                  " U 5      SU4S jj5       nU$ )Nc                   > UR                   UR                   :w  a(  [        SUR                   < SUR                   < S35      eUR                   n[        U[        R                  5      (       d  [        SU< 35      e[        R                  " S5      nU R                  n[        R                  " [        R                  " XE/5      XD/5      nUR                  ST
< S3U/U5      nU R                  XU/US9n	U	$ )	Nr4   r5   r6   zexpected an integer type, got    zllvm.z.with.overflowr   )r   r7   
isinstancer   IntType	TypeErrormoduleFunctionTypeLiteralStructTypedeclare_intrinsiccall)r   r8   r9   r   tybool_tymodfntyr*   retr   s             r   r    3_binop_with_overflow.<locals>.wrap.<locals>.wrapped/   s    xx388# $'HHchh"8 9 9Bb%--00b JKKmmA&G++C%%e&=&=rm&L')h0D&&&'J(*tT3B))Bc
)6CJr"   r$   r&   r*   r    r   s     r   r+   "_binop_with_overflow.<locals>.wrap.   s%    			 
	" r"   r%   r.   s   `  r   _binop_with_overflowrS   -   s    * Kr"   c                    ^ ^ UU 4S jnU$ )Nc                 L   > [         R                  " U 5      SUU4S jj5       nU$ )Nc                 l   > T" U R                   UR                  TU/U5      nU R                  U5        U$ r   r   )r   operandr   r   r   r   s       r   r    %_uniop.<locals>.wrap.<locals>.wrappedH   s0    

GLL&7)TJELLLr"   rP   r&   r)   s     r   r+   _uniop.<locals>.wrapG   r-   r"   r%   r.   s   `` r   _unioprZ   F   r0   r"   c                    ^  U 4S jnU$ )Nc                 J   > [         R                  " U 5      SU4S jj5       nU$ )Nc                    > [        UR                  [        R                  5      (       d  [	        SUR                  -  5      eU R
                  R                  TUR                  /5      nU R                  X1/U5      $ )N expected an integer type, got %s)rB   r   r   rC   rD   rE   rH   rI   r   rW   r   r*   r   s       r   r    3_uniop_intrinsic_int.<locals>.wrap.<locals>.wrappedU   se    gllEMM::6LL!" " ..v~FB99RD11r"   rP   r&   rQ   s     r   r+   "_uniop_intrinsic_int.<locals>.wrapT   s%    			2 
	2 r"   r%   r   r+   s   ` r   _uniop_intrinsic_intrc   S   s    
 Kr"   c                    ^  U 4S jnU$ )Nc                 J   > [         R                  " U 5      SU4S jj5       nU$ )Nc                   > [        UR                  [        R                  [        R                  45      (       d  [        SUR                  -  5      eU R                  R                  TUR                  /5      nU R                  X1/U5      $ )Nexpected a float type, got %s)	rB   r   r   	FloatType
DoubleTyperD   rE   rH   rI   r_   s       r   r    5_uniop_intrinsic_float.<locals>.wrap.<locals>.wrappede   sn    LL5??E4D4D"EG G ?',, NOO..v~FB99RD11r"   rP   r&   rQ   s     r   r+   $_uniop_intrinsic_float.<locals>.wrapd   s%    			2 
	2 r"   r%   rb   s   ` r   _uniop_intrinsic_floatrl   c   s    	 Kr"   c                    ^  U 4S jnU$ )Nc                 J   > [         R                  " U 5      SU4S jj5       nU$ )Nc                   > [        UR                  [        R                  5      (       d  [	        SUR                  -  5      e[        UR                  [        R                  5      (       a  UR                  R
                  S:X  d  [	        SUR                  -  5      eU R                  R                  TUR                  UR                  /5      nU R                  XAU/U5      $ )Nr^   r@   zexpected an i1 type, got %s)	rB   r   r   rC   rD   widthrE   rH   rI   )r   rW   flagr   r*   r   s        r   r    9_uniop_intrinsic_with_flag.<locals>.wrap.<locals>.wrappedt   s    gllEMM::6LL!" " tyy%--88IIOOq( =		 IJJ..tyy13B99R4$77r"   rP   r&   rQ   s     r   r+   (_uniop_intrinsic_with_flag.<locals>.wraps   s%    		
	8 

	8 r"   r%   rb   s   ` r   _uniop_intrinsic_with_flagrt   r   s      Kr"   c                    ^  U 4S jnU$ )Nc                 J   > [         R                  " U 5      SU4S jj5       nU$ )Nc                 8  > UR                   UR                   :w  d  UR                   UR                   :w  a5  [        SUR                   < SUR                   < SUR                   < 35      e[        UR                   [        R                  [        R
                  [        R                  45      (       d  [        SUR                   -  5      eU R                  R                  TUR                   UR                   UR                   /5      nU R                  XQX#/U5      $ )Nz#expected types to be the same, got r5   z'expected an floating point type, got %s)
r   rD   rB   r   HalfTyperh   ri   rE   rH   rI   )r   abcr   r*   r   s         r   r    /_triop_intrinsic.<locals>.wrap.<locals>.wrapped   s    vv166QVV#3 ! !
  FF^^U__e6F6FGI I  =FF  ..v7OPB99RQD11r"   rP   r&   rQ   s     r   r+   _triop_intrinsic.<locals>.wrap   s%    			2 
	2  r"   r%   rb   s   ` r   _triop_intrinsicr~      s    ( Kr"   c                    ^ ^ UU 4S jnU$ )Nc                 L   > [         R                  " U 5      SUU4S jj5       nU$ )Nc                 x   > UR                   U:X  a  U$ T" U R                  TXU5      nU R                  U5        U$ r   )r   r   r   )r   valtypr   r   r   r   s        r   r    &_castop.<locals>.wrap.<locals>.wrapped   s8    xx3


FCd;ELLLr"   rP   r&   r)   s     r   r+   _castop.<locals>.wrap   s%    			 
	 r"   r%   r.   s   `` r   _castopr      s    	 Kr"   c                 Z    [        U 5      S:  a  SnSR                  U SU SU/5      $ X-   $ )zReturns (label + suffix) or a truncated version if it's too long.
Parameters
----------
label : str
    Label name
suffix : str
    Label suffix
2      r$   Nz..)lenjoin)labelsuffixnheads      r   _label_suffixr      s8     5zBwwfutV455~r"   c                   ,   \ rS rSrSS jr\S 5       r\r\S 5       r\S 5       r	S r
S rS	 rS
 rSS jrS r\R"                  S 5       r\R"                  S 5       r\R"                  S 5       r\R"                  SS j5       r\R"                  SS j5       rS rS r\" S5      SS j5       r\" S5      SS j5       r\" S5      SS j5       r\" S5      SS j5       r\" S5      SS j5       r\" S5      SS j5       r\" S 5      SS! j5       r \" S"5      SS# j5       r!\" S$5      SS% j5       r"\" S&5      SS' j5       r#\" S(5      SS) j5       r$\" S*5      SS+ j5       r%\" S,5      SS- j5       r&\" S.5      SS/ j5       r'\" S05      SS1 j5       r(\" S25      SS3 j5       r)\" S45      SS5 j5       r*\" S65      SS7 j5       r+\," S85      SS9 j5       r-\," S:5      SS; j5       r.\," S<5      SS= j5       r/\," S>5      SS? j5       r0\," S@5      SSA j5       r1\," SB5      SSC j5       r2SSD jr3SSE jr4\5" SF5      SSG j5       r6SH r7SSI jr8SSJ jr9SSK jr:SSL jr;SSM jr<\=" SN5      SSO j5       r>\=" SP5      SSQ j5       r?\=" SR5      SSS j5       r@\=" ST5      SSU j5       rA\=" SV5      SSW j5       rB\=" SX5      SSY j5       rC\=" SZ5      SS[ j5       rD\=" S\5      SS] j5       rE\=" S^5      SS_ j5       rF\=" S`5      SSa j5       rG\=" Sb5      SSc j5       rH\=" Sd5      SSe j5       rI\=" Sf5      SSg j5       rJSSh jrKSSi jrLSSj jrMSSk jrNSl rOSm rPSn rQSo rRSp rSSq rTSr rUSs rV  SSt jrWSSu jrXSSv jrYSSw jrZ SSx jr[SSy jr\SSz jr]SS{ jr^SS| jr_SS} jr`SS~ jraSS jrbS rcSS jrdSS jreSS jrfS rgSS jrhS ri\j" S5      S 5       rk\j" S5      S 5       rl\j" S5      S 5       rm\n" S5      S 5       ro\n" S5      S 5       rp\q" S5      S 5       rrSS jrs\t" S5      S 5       ruSrvg)	IRBuilder   Nc                 d    Xl         U(       a  [        UR                  5      OSU l        S U l        g )Nr   )_blockr   r   _anchordebug_metadatar   r   s     r   __init__IRBuilder.__init__   s%    27s5--.Q"r"   c                     U R                   $ )z
The current basic block.
)r   r   s    r   r   IRBuilder.block   s    
 {{r"   c                 .    U R                   R                  $ )z
The current function.
)r   parentr   s    r   functionIRBuilder.function   s    
 zz   r"   c                 B    U R                   R                  R                  $ )z
The current module.
)r   r   rE   r   s    r   rE   IRBuilder.module   s    
 zz  '''r"   c                 z    UR                   U l        U R                  R                  R                  U5      U l        g)zy
Position immediately before the given instruction.  The current block
is also changed to the instruction's basic block.
Nr   r   r   indexr   r   r   s     r   position_beforeIRBuilder.position_before   s+    
 ll{{//55e<r"   c                     UR                   U l        U R                  R                  R                  U5      S-   U l        g)zx
Position immediately after the given instruction.  The current block
is also changed to the instruction's basic block.
r@   Nr   r   s     r   position_afterIRBuilder.position_after   s0    
 ll{{//55e<q@r"   c                     Xl         SU l        g)z-
Position at the start of the basic *block*.
r   N)r   r   r   s     r   position_at_startIRBuilder.position_at_start   s     r"   c                 D    Xl         [        UR                  5      U l        g)z+
Position at the end of the basic *block*.
N)r   r   r   r   r   s     r   position_at_endIRBuilder.position_at_end   s     5--.r"   c                 8    U R                   R                  U5      $ )z
Append a basic block, with the given optional *name*, to the current
function.  The current block is not changed.  The new block is returned.
)r   append_basic_block)r   r   s     r   r   IRBuilder.append_basic_block   s    
 }}//55r"   c                    U R                   R                  R                  U5      nU R                   R                  U	 U R                   R                  U:X  a  SU R                   l        U R                  U:  a  U =R                  S-  sl        gg)zRemove the given instruction.Nr@   )r   r   r   
terminatorr   )r   r   idxs      r   removeIRBuilder.remove   sk    kk&&,,U3KK$$S);;!!U*%)DKK"<<#LLAL r"   c              #      #    U R                   nUR                  nUb  U R                  U5        OU R                  U5         Sv   U R                  U5        g! U R                  U5        f = f7f)zw
A context manager which temporarily positions the builder at the end
of basic block *bb* (but before any terminator).
N)basic_blockr   r   r   )r   r   	old_blockterms       r   
goto_blockIRBuilder.goto_block  sc      $$	  &  '	,  +D  +s   ?A.A A.A++A.c              #      #    U R                  U R                  R                  5         Sv   SSS5        g! , (       d  f       g= f7f)ze
A context manager which temporarily positions the builder at the
end of the function's entry block.
N)r   r   entry_basic_blockr   s    r   goto_entry_blockIRBuilder.goto_entry_block  s+      __T]]<<= >==s   &A6	A
A Ac              #      #    U R                  U5        Uv   U R                  R                  c  U R                  U5        g g 7fr   )r   r   r   branch)r   bbenterbbexits      r   _branch_helperIRBuilder._branch_helper"  s;     W%&&.KK /s   A Ac              #     #    U R                   nU R                  [        UR                  S5      S9nU R                  [        UR                  S5      S9nU R	                  XU5      nUb  UR                  U(       a  SS/OSS/5        U R                  XE5         Uv   SSS5        U R                  U5        g! , (       d  f       N = f7f)ao  
A context manager which sets up a conditional basic block based
on the given predicate (a i1 value).  If the conditional block
is not explicitly terminated, a branch will be added to the next
block.
If *likely* is given, its boolean value indicates whether the
predicate is likely to be true or not, and metadata is issued
for LLVM's optimizers to account for that.
.ifrA   .endifNc   r@   r   r   r   r   cbranchset_weightsr   r   )r   predlikelybbbbifbbendbrs          r   if_thenIRBuilder.if_then)  s      &&M"''5,I&J'']277H-M'N\\$e,NNfB71b':  -K . 	U# .-s   BC	B8C	8
CC	c              #     #    U R                   nU R                  [        UR                  S5      S9nU R                  [        UR                  S5      S9nU R                  [        UR                  S5      S9nU R	                  XU5      nUb  UR                  U(       a  SS/OSS/5        U R                  XF5      nU R                  XV5      n	X4v   U R                  U5        g7f)a  
A context manager which sets up two conditional basic blocks based
on the given predicate (a i1 value).
A tuple of context managers is yield'ed.  Each context manager
acts as a if_then() block.
*likely* has the same meaning as in if_then().

Typical use::
    with builder.if_else(pred) as (then, otherwise):
        with then:
            # emit instructions for when the predicate is true
        with otherwise:
            # emit instructions for when the predicate is false
r   rA   z.elser   Nr   r@   r   )
r   r   r   r   r   bbelser   r   then	otherwises
             r   if_elseIRBuilder.if_else@  s       &&M"''5,I&J((mBGGW.M(N'']277H-M'N\\$f-NNfB71b':""4/''6	oU#s   C"C$c                     U R                   b)  SUR                  ;  a  U R                   UR                  S'   U R                  R                  R	                  U R
                  U5        U =R
                  S-  sl        g )Ndbgr@   )r   metadatar   r   insertr   r   s     r   r   IRBuilder._insert_  sY    *uENN/J$($7$7ENN5!  ''e<r"   c                     U R                   R                  (       a   eU R                  U5        XR                   l        U$ r   )r   is_terminatedr   r   )r   r   s     r   _set_terminatorIRBuilder._set_terminatore  s0    ::++++T $

r"   shlc                     g)z+
Left integer shift:
    name = lhs << rhs
Nr%   r   r8   r9   r   s       r   r   IRBuilder.shlo      r"   lshrc                     g)z?
Logical (unsigned) right integer shift:
    name = lhs >> rhs
Nr%   r   s       r   r   IRBuilder.lshrv  r   r"   ashrc                     g)z@
Arithmetic (signed) right integer shift:
    name = lhs >> rhs
Nr%   r   s       r   r   IRBuilder.ashr}  r   r"   addc                     g)z(
Integer addition:
    name = lhs + rhs
Nr%   r   s       r   r   IRBuilder.add  r   r"   faddc                     g)z/
Floating-point addition:
    name = lhs + rhs
Nr%   r   s       r   r   IRBuilder.fadd  r   r"   subc                     g)z+
Integer subtraction:
    name = lhs - rhs
Nr%   r   s       r   r   IRBuilder.sub  r   r"   fsubc                     g)z2
Floating-point subtraction:
    name = lhs - rhs
Nr%   r   s       r   r   IRBuilder.fsub  r   r"   mulc                     g)z.
Integer multiplication:
    name = lhs * rhs
Nr%   r   s       r   r   IRBuilder.mul  r   r"   fmulc                     g)z5
Floating-point multiplication:
    name = lhs * rhs
Nr%   r   s       r   r  IRBuilder.fmul  r   r"   udivc                     g)z1
Unsigned integer division:
    name = lhs / rhs
Nr%   r   s       r   r  IRBuilder.udiv  r   r"   sdivc                     g)z/
Signed integer division:
    name = lhs / rhs
Nr%   r   s       r   r  IRBuilder.sdiv  r   r"   fdivc                     g)z/
Floating-point division:
    name = lhs / rhs
Nr%   r   s       r   r  IRBuilder.fdiv  r   r"   uremc                     g)z2
Unsigned integer remainder:
    name = lhs % rhs
Nr%   r   s       r   r  IRBuilder.urem  r   r"   sremc                     g)z0
Signed integer remainder:
    name = lhs % rhs
Nr%   r   s       r   r  IRBuilder.srem  r   r"   fremc                     g)z0
Floating-point remainder:
    name = lhs % rhs
Nr%   r   s       r   r  IRBuilder.frem  r   r"   orc                     g)z*
Bitwise integer OR:
    name = lhs | rhs
Nr%   r   s       r   or_IRBuilder.or_  r   r"   andc                     g)z+
Bitwise integer AND:
    name = lhs & rhs
Nr%   r   s       r   and_IRBuilder.and_  r   r"   xorc                     g)z+
Bitwise integer XOR:
    name = lhs ^ rhs
Nr%   r   s       r   r  IRBuilder.xor  r   r"   saddc                     g)zV
Signed integer addition with overflow:
    name = {result, overflow bit} = lhs + rhs
Nr%   r   s       r   sadd_with_overflowIRBuilder.sadd_with_overflow  r   r"   smulc                     g)z\
Signed integer multiplication with overflow:
    name = {result, overflow bit} = lhs * rhs
Nr%   r   s       r   smul_with_overflowIRBuilder.smul_with_overflow  r   r"   ssubc                     g)zY
Signed integer subtraction with overflow:
    name = {result, overflow bit} = lhs - rhs
Nr%   r   s       r   ssub_with_overflowIRBuilder.ssub_with_overflow  r   r"   uaddc                     g)zX
Unsigned integer addition with overflow:
    name = {result, overflow bit} = lhs + rhs
Nr%   r   s       r   uadd_with_overflowIRBuilder.uadd_with_overflow  r   r"   umulc                     g)z^
Unsigned integer multiplication with overflow:
    name = {result, overflow bit} = lhs * rhs
Nr%   r   s       r   umul_with_overflowIRBuilder.umul_with_overflow	  r   r"   usubc                     g)z[
Unsigned integer subtraction with overflow:
    name = {result, overflow bit} = lhs - rhs
Nr%   r   s       r   usub_with_overflowIRBuilder.usub_with_overflow  r   r"   c                 (   [        UR                  [        R                  5      (       a9  [        R
                  " UR                  SUR                  R                  -  5      nO![        R
                  " UR                  S5      nU R                  XUS9$ )z/
Bitwise integer complement:
    name = ~value
)r;  rA   )rB   r   r   
VectorTyper   Constantcountr  )r   valuer   r9   s       r   not_IRBuilder.not_  se    
 ejj%"2"233//%**eejj6F6F.FGC//%**b1Cxxx..r"   c                 `    U R                  [        R                  " UR                  S5      XS9$ )z%
Integer negative:
    name = -value
r   rA   )r   r   r=  r   )r   r?  r   s      r   negIRBuilder.neg&  s&    
 xx

A6xIIr"   fnegc                     g)z*
Floating-point negative:
    name = -arg
Nr%   )r   r   r   r   s       r   rE  IRBuilder.fneg-  r   r"   c                      [         U   nUS;  a  X-   n[        R                  " U R
                  XcXES9nU R                  U5        U$ ! [         a    [        SU< S35      ef = f)Nzinvalid comparison z	 for icmp)r   r   rA   )_CMP_MAPKeyErrorr7   r   	ICMPInstrr   r   )r   prefixcmpopr8   r9   r   opr   s           r   _icmpIRBuilder._icmp8  sl    	J%B $B&&tzz2CKU  	JHII	Js   	A A#c                 (    U R                  SXX45      $ )zl
Signed integer comparison:
    name = lhs <cmpop> rhs

where cmpop can be '==', '!=', '<', '<=', '>', '>='
srO  r   rM  r8   r9   r   s        r   icmp_signedIRBuilder.icmp_signedC       zz#u355r"   c                 (    U R                  SXX45      $ )z{
Unsigned integer (or pointer) comparison:
    name = lhs <cmpop> rhs

where cmpop can be '==', '!=', '<', '<=', '>', '>='
urS  rT  s        r   icmp_unsignedIRBuilder.icmp_unsignedL  rW  r"   c           	          U[         ;   a  S[         U   -   nOUn[        R                  " U R                  XbX4US9nU R	                  U5        U$ )z
Floating-point ordered comparison:
    name = lhs <cmpop> rhs

where cmpop can be '==', '!=', '<', '<=', '>', '>=', 'ord', 'uno'
or   r   rI  r   	FCMPInstrr   r   r   rM  r8   r9   r   r   rN  r   s           r   fcmp_orderedIRBuilder.fcmp_orderedU  M     Hx&BB&&JJu>Ur"   c           	          U[         ;   a  S[         U   -   nOUn[        R                  " U R                  XbX4US9nU R	                  U5        U$ )z
Floating-point unordered comparison:
    name = lhs <cmpop> rhs

where cmpop can be '==', '!=', '<', '<=', '>', '>=', 'ord', 'uno'
rY  r^  r_  ra  s           r   fcmp_unorderedIRBuilder.fcmp_unorderede  rd  r"   c           	      j    [         R                  " U R                  XX4US9nU R                  U5        U$ )z6
Ternary select operator:
    name = cond ? lhs : rhs
r^  )r   SelectInstrr   r   )r   condr8   r9   r   r   r   s          r   selectIRBuilder.selectu  s2    
 ((T/46Ur"   truncc                     g)zG
Truncating integer downcast to a smaller type:
    name = (typ) value
Nr%   r   r?  r   r   s       r   rm  IRBuilder.trunc  r   r"   zextc                     g)zH
Zero-extending integer upcast to a larger type:
    name = (typ) value
Nr%   ro  s       r   rq  IRBuilder.zext  r   r"   sextc                     g)zH
Sign-extending integer upcast to a larger type:
    name = (typ) value
Nr%   ro  s       r   rt  IRBuilder.sext  r   r"   fptruncc                     g)zH
Floating-point downcast to a less precise type:
    name = (typ) value
Nr%   ro  s       r   rw  IRBuilder.fptrunc  r   r"   fpextc                     g)zF
Floating-point upcast to a more precise type:
    name = (typ) value
Nr%   ro  s       r   rz  IRBuilder.fpext  r   r"   bitcastc                     g)zB
Pointer cast to a different pointer type:
    name = (typ) value
Nr%   ro  s       r   r}  IRBuilder.bitcast  r   r"   addrspacecastc                     g)zC
Pointer cast to a different address space:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.addrspacecast  r   r"   fptouic                     g)zD
Convert floating-point to unsigned integer:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.fptoui  r   r"   uitofpc                     g)zD
Convert unsigned integer to floating-point:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.uitofp  r   r"   fptosic                     g)zB
Convert floating-point to signed integer:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.fptosi  r   r"   sitofpc                     g)zB
Convert signed integer to floating-point:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.sitofp  r   r"   ptrtointc                     g)z1
Cast pointer to integer:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.ptrtoint  r   r"   inttoptrc                     g)z1
Cast integer to pointer:
    name = (typ) value
Nr%   ro  s       r   r  IRBuilder.inttoptr  r   r"   c                    Uc  O[        U[        R                  [        R                  45      (       a,  [        UR                  [
        R                  5      (       d   eO+[        R                  " [
        R                  " S5      U5      n[        R                  " U R                  XU5      nU R                  U5        U$ )zT
Stack-allocate a slot for *size* elements of the given type.
(default one element)
    )rB   r   Valuer=  r   r   rC   r   AllocaInstrr   r   )r   r   sizer   als        r   allocaIRBuilder.alloca  s    
 <v||V__=>>dii7777 ??5==#4d;D%%djj#TBR	r"   c                    [        UR                  [        R                  5      (       d$  Sn[	        XQR                  [        U5      4-  5      e[        R                  " U R                  XUS9nX6l	        U R                  U5        U$ zN
Load value from pointer, with optional guaranteed alignment:
    name = *ptr
z5cannot load from value of type %s (%r): not a pointer)r   )rB   r   r   PointerTyperD   strr   	LoadInstrr   alignr   )r   ptrr   r  r   msglds          r   loadIRBuilder.load  si    
 #((E$5$566ICC88SX"6677##DJJsCR	r"   c                    [        UR                  [        R                  5      (       d$  Sn[	        XBR                  [        U5      4-  5      eUR                  R                  (       dL  UR                  R                  UR                  :w  a(  [	        SUR                  < SUR                  < S35      e[        R                  " U R                  X5      nX5l        U R                  U5        U$ zM
Store value to pointer, with optional guaranteed alignment:
    *ptr = name
z4cannot store to value of type %s (%r): not a pointerzcannot store z to z: mismatching types)rB   r   r   r  rD   r  	is_opaquepointeer   
StoreInstrr   r  r   )r   r?  r  r  r  sts         r   storeIRBuilder.store  s    
 #((E$5$566HCC88SX"6677xx!!chh&6&6%**&D$zz3885 6 6$$TZZ<R	r"   c           	         [        UR                  [        R                  5      (       d$  Sn[	        XaR                  [        U5      4-  5      e[        R                  " U R                  XX4US9nU R                  U5        U$ r  )
rB   r   r   r  rD   r  r   LoadAtomicInstrr   r   )r   r  orderingr  r   r   r  r  s           r   load_atomicIRBuilder.load_atomic  si    
 #((E$5$566ICC88SX"6677))JJu=R	r"   c                    [        UR                  [        R                  5      (       d$  Sn[	        XRR                  [        U5      4-  5      eUR                  R                  UR                  :w  a(  [	        SUR                  < SUR                  < S35      e[        R                  " U R                  XX45      nU R                  U5        U$ r  )rB   r   r   r  rD   r  r  r   StoreAtomicInstrr   r   )r   r?  r  r  r  r  r  s          r   store_atomicIRBuilder.store_atomic  s    
 #((E$5$566HCC88SX"667788uzz)$zz3885 6 6**JJH5R	r"   c                 l    [         R                  " U R                  SX5      nU R                  U5        U$ )z6
Create a switch-case with a single *default* target.
switch)r   SwitchInstrr   r   )r   r?  defaultswts       r   r  IRBuilder.switch2  s/     &&tzz8ULS!
r"   c                 n    [         R                  " U R                  SU/5      nU R                  U5        U$ )z#
Unconditional branch to *target*.
r   r   Branchr   r   )r   targetr   s      r   r   IRBuilder.branch:  s1       TF8<R 	r"   c                 p    [         R                  " U R                  SXU/5      nU R                  U5        U$ )zF
Conditional branch to *truebr* if *cond* is true, else to *falsebr*.
r   )r   ConditionalBranchr   r   )r   rj  truebrfalsebrr   s        r   r   IRBuilder.cbranchB  s8     ++DJJ-17,CER 	r"   c                 l    [         R                  " U R                  SU5      nU R                  U5        U$ )z#
Indirect branch to target *addr*.

indirectbr)r   IndirectBranchr   r   )r   addrr   s      r   branch_indirectIRBuilder.branch_indirectK  s/     ((\4HR 	r"   c                 b    U R                  [        R                  " U R                  S5      5      $ )z'
Return from function without a value.
zret voidr   r   Retr   r   s    r   ret_voidIRBuilder.ret_voidS  s+     ##TZZ46 	6r"   c                 d    U R                  [        R                  " U R                  SU5      5      $ )z.
Return from function with the given *value*.
rN   r  )r   r?  s     r   rN   IRBuilder.retZ  s-     ##TZZ68 	8r"   c                 n    [         R                  " U R                  SU/5      nU R                  U5        U$ )z 
Resume an in-flight exception.
resumer  )r   
landingpadr   s      r   r  IRBuilder.resumea  s1       X
|DR 	r"   c	                 n    [         R                  " U R                  XUXEUXxS9	n	U R                  U	5        U	$ )z8
Call function *fn* with *args*:
    name = fn(args...)
)r   cconvtailfastmathattrs	arg_attrs)r   	CallInstrr   r   )
r   r*   argsr   r  r  r  r  r  insts
             r   rI   IRBuilder.callk  s:     %%djj",1x,1H 	Tr"   c                 T    [         R                  " XX55      nU R                  X$U5      $ )z
Inline assembler.
)r   	InlineAsmrI   )r   ftypeasm
constraintr  side_effectr   s          r   r  IRBuilder.asmw  s'     $$UIyyD))r"   c                 b    [         R                  " U/ 5      nU R                  USSU-  / SU5      $ )zW
Load a register value into an LLVM value.
  Example: v = load_reg(IntType(32), "eax")
r$   z={%s}F)r   rF   r  )r   reg_typereg_namer   r  s        r   load_regIRBuilder.load_reg~  s4    
 ""8R0xxr7X#5r5$GGr"   c                     [         R                  " [         R                  " 5       U/5      nU R                  USSU-  U/SU5      $ )zs
Store an LLVM value inside a register
Example:
  store_reg(Constant(IntType(32), 0xAAAAAAAA), IntType(32), "eax")
r$   z{%s}T)r   rF   VoidTyper  )r   r?  r  r  r   r  s         r   	store_regIRBuilder.store_reg  s?     ""5>>#3hZ@xxr6H#4ugtTJJr"   c
                 p    [         R                  " U R                  XUXEUXxU	S9
n
U R                  U
5        U
$ )N)r   r  r  r  r  )r   InvokeInstrr   r   )r   r*   r  	normal_to	unwind_tor   r  r  r  r  r  s              r   invokeIRBuilder.invoke  s<    ''

Bi(1E192;= 	T"r"   c           	      j    [         R                  " U R                  XX4US9nU R                  U5        U$ )zW
Compute effective address (getelementptr):
    name = getelementptr ptr, <indices...>
)inboundsr   source_etype)r   GEPInstrr   r   )r   r  indicesr  r   r  r   s          r   gepIRBuilder.gep  s6    
 %%djj#/73?A 	Ur"   c                 h    [         R                  " U R                  XUS9nU R                  U5        U$ )z$
Returns the value at position idx.
rA   )r   ExtractElementr   r   )r   vectorr   r   r   s        r   extract_elementIRBuilder.extract_element  s-     ++DJJ$OUr"   c                 j    [         R                  " U R                  XUUS9nU R                  U5        U$ )z}
Returns vector with vector[idx] replaced by value.
The result is undefined if the idx is larger or equal the vector length.
rA   )r   InsertElementr   r   )r   r  r?  r   r   r   s         r   insert_elementIRBuilder.insert_element  s2    
 **4::vc046Ur"   c                 j    [         R                  " U R                  XUUS9nU R                  U5        U$ )z
Constructs a permutation of elements from *vector1* and *vector2*.
Returns a new vector in the same length of *mask*.

* *vector1* and *vector2* must have the same element type.
* *mask* must be a constant vector of integer types.
rA   )r   ShuffleVectorr   r   )r   vector1vector2maskr   r   s         r   shuffle_vectorIRBuilder.shuffle_vector  s2     **4::w046Ur"   c                     [        U[        [        45      (       d  U/n[        R                  " U R
                  XUS9nU R                  U5        U$ )z-
Extract member number *idx* from aggregate.
rA   )rB   tuplelistr   ExtractValuer   r   )r   aggr   r   r   s        r   extract_valueIRBuilder.extract_value  sE     #t}--%C))$**cTJUr"   c                     [        U[        [        45      (       d  U/n[        R                  " U R
                  XX4S9nU R                  U5        U$ )z9
Insert *value* into member number *idx* from aggregate.
rA   )rB   r  r  r   InsertValuer   r   )r   r  r?  r   r   r   s         r   insert_valueIRBuilder.insert_value  sE     #t}--%C((SPUr"   c                 h    [         R                  " U R                  XUS9nU R                  U5        U$ )Nr^  )r   PhiInstrr   r   )r   r   r   r   r  s        r   phiIRBuilder.phi  s+    $$TZZuMTr"   c                 h    [         R                  " U R                  5      nU R                  U5        U$ r   )r   Unreachabler   r   )r   r  s     r   unreachableIRBuilder.unreachable  s)    ''

3T"r"   c           	      j    [         R                  " U R                  XX4US9nU R                  U5        U$ )NrA   )r   	AtomicRMWr   r   )r   rN  r  r   r  r   r  s          r   
atomic_rmwIRBuilder.atomic_rmw  s0    %%JJT;Tr"   c           
      x    Uc  UOUn[         R                  " U R                  XX4XVS9nU R                  U5        U$ )z
Atomic compared-and-set:
    atomic {
        old = *ptr
        success = (old == cmp)
        if (success)
            *ptr = val
        }
    name = { old, success }

If failordering is `None`, the value of `ordering` is used.
rA   )r   CmpXchgr   r   )r   r  cmpr   r  failorderingr   r  s           r   cmpxchgIRBuilder.cmpxchg  s>     $0#7x\##DJJ#$0=Tr"   c                 l    [         R                  " U R                  XU5      nU R                  U5        U$ r   )r   LandingPadInstrr   r   )r   r   r   cleanupr  s        r   r  IRBuilder.landingpad  s+    ++DJJ7KTr"   c                 \    U R                   R                  S5      nU R                  X!/5      $ )z/
Optimizer hint: assume *cond* is always true.
zllvm.assume)rE   rH   rI   )r   rj  r*   s      r   assumeIRBuilder.assume  s)     [[**=9yyV$$r"   c                 h    [         R                  " U R                  XUS9nU R                  U5        U$ )z
Add a memory barrier, preventing certain reorderings of load and/or
store accesses with
respect to other processors and devices.
rA   )r   Fencer   r   )r   r  targetscoper   r  s        r   fenceIRBuilder.fence  s-     !!$**h$OTr"   c                 j    [         R                  " U R                  U5      nU R                  U5        U$ )z
Puts a single-line comment into the generated IR. This will be ignored
by LLVM, but can be useful for debugging the output of a compiler. Adds
a comment to the source file.

* *text* is a string that does not contain new line characters.
)r   Commentr   r   )r   textr  s      r   commentIRBuilder.comment  s+     ##DJJ5Tr"   z
llvm.bswapc                     g)z^
Used to byte swap integer values with an even number of bytes (positive
multiple of 16 bits)
Nr%   r   rj  s     r   bswapIRBuilder.bswap%  r   r"   zllvm.bitreversec                     g)zX
Reverse the bitpattern of an integer value; for example 0b10110110
becomes 0b01101101.
Nr%   r@  s     r   
bitreverseIRBuilder.bitreverse,  r   r"   z
llvm.ctpopc                     g)z+
Counts the number of bits set in a value.
Nr%   r@  s     r   ctpopIRBuilder.ctpop3  r   r"   z	llvm.ctlzc                     g)zh
Counts leading zero bits in *value*. Boolean *flag* indicates whether
the result is defined for ``0``.
Nr%   r   rj  rq   s      r   ctlzIRBuilder.ctlz9  r   r"   z	llvm.cttzc                     g)zi
Counts trailing zero bits in *value*. Boolean *flag* indicates whether
the result is defined for ``0``.
Nr%   rJ  s      r   cttzIRBuilder.cttz@  r   r"   zllvm.fmac                     g)z+
Perform the fused multiply-add operation.
Nr%   )r   ry   rz   r{   s       r   fmaIRBuilder.fmaG  r   r"   c                    U(       d  [        S5      e[        U[        R                  [        R                  45      (       d  [        SU-  5      e[        UR
                  [        R                  5      (       a  UR
                  R                  S:X  d  [        SUR
                  -  5      eSnU R                  R                  XB/5      nU R                  XQ/U5      $ )z*
Convert from an i16 to the given FP type
zexpected a float return typerg      zexpected an i16 type, got %szllvm.convert.from.fp16)rD   rB   r   rh   ri   r   rC   rp   rE   rH   rI   )r   ry   tor   r   r*   s         r   convert_from_fp16IRBuilder.convert_from_fp16M  s     :;;"u0@0@ABB;b@AA1665==11affllb6H:QVVCDD)[[**648yyS$''r"   zllvm.convert.to.fp16c                     g)z'
Convert the given FP number to an i16
Nr%   )r   ry   s     r   convert_to_fp16IRBuilder.convert_to_fp16\  r   r"   )r   r   r   r   rP   r#   )Nr$   )r$   NN)r$   N)r$   NFr%   r%   N)r$   Nr%   r%   N)Fr$   N)r$   F)w__name__
__module____qualname____firstlineno__r   propertyr   r   r   rE   r   r   r   r   r   r   
contextlibcontextmanagerr   r   r   r   r   r   r   r<   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  rS   r$  r(  r,  r0  r4  r8  r@  rC  r/   rE  rO  rU  rZ  rb  rf  rk  r   rm  rq  rt  rw  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r  r  rN   r  rI   r  r  r  r  r  r  r  r  r  r  r  r"  r&  r,  r  r3  r8  r=  rc   rA  rD  rG  rt   rK  rN  r~   rQ  rV  rl   rY  __static_attributes__r%   r"   r   r   r      s!   #
   K! ! ( (=A/6 , ,        $ $, $ $< E]  F^  F^  E]  F^  E]  F^  E]  F^  F^  F^  F^  F^  F^  F^  D\  E]  E]  &! " &! " &! " &! " &! " &! "	/J 6] 	66   W  V_  V_  Y  W  Y  _  X  X  X  X  Z  Z $ (68 HJ!%
*HK FJ	
&
%
 ,' ( +, - ,' (
  , -  , - j! "
( 23 4r"   r   )r`  r'   llvmlite.irr   r   r   rI  Instructionr/   r<   rS   rZ   rc   rl   rt   r~   	CastInstrr   r   objectr   r%   r"   r   <module>rg     s      3 3 
	



 #.. 
 $//   &2%=%= 2 $// 
 (0 %..  c cr"   