U
    ,d                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ	 d dl
Z
dZdZed	e
ejd
kde
e  dG dd de
jZedkre
  dS )    )nvvm)skip_on_cudasim)utils)ir)bindingNzNcall void @llvm.memset.p0i8.i64(i8* align 4 %arg.x.41, i8 0, i64 %0, i1 false)zFcall void @llvm.memset.p0i8.i64(i8* %arg.x.41, i8 0, i64 %0, i1 false)z"libNVVM not supported in simulator    zCUDA not support for 32-bitz
No libNVVMc                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestNvvmWithoutCudac                 C   sD   t t}| d| | D ] }d|kr| |ddd qdS )z
        Test llvm.memset changes in llvm7.
        In LLVM7 the alignment parameter can be implicitly provided as
        an attribute to pointer in the first argument.
        zcall void @llvm.memsetzi32 4, i1 false\) z\s+N)r   llvm100_to_34_iroriginalassertIn
splitlinesZassertRegexpMatchesreplace)selfZfixedln r   E/tmp/pip-unpacked-wheel-eu7e0c37/numba/cuda/tests/nocuda/test_nvvm.pytest_nvvm_memset_fixup_for_34   s    

z1TestNvvmWithoutCuda.test_nvvm_memset_fixup_for_34c              	   C   s6   |  t}tt W 5 Q R X | t|jd dS )zy
        We require alignment to be specified as a parameter attribute to the
        dest argument of a memset.
        z+No alignment attribute found on memset destN)assertRaises
ValueErrorr   r
   missing_alignr   str	exception)r   er   r   r   +test_nvvm_memset_fixup_for_34_missing_align'   s
    z?TestNvvmWithoutCuda.test_nvvm_memset_fixup_for_34_missing_alignc                 C   s   t t t ddttd}t  }t ||jd}d|_	||_
t| tt|}tt|}ddd tdD }d| d	d
}| || d S )N      
myconstantTz, c                 S   s   g | ]}t |qS r   )r   ).0ir   r   r   
<listcomp>J   s     zBTestNvvmWithoutCuda.test_nvvm_accepts_encoding.<locals>.<listcomp>zmyconstant[256] = {}zutf-8)r   ConstantZ	ArrayTypeZIntType	bytearrayrangeModuleZGlobalVariabletypeZglobal_constantZinitializerr   Zfix_data_layoutllvmZparse_assemblyr   Zllvm_to_ptxjoinencoder   )r   cmgvparsedZptxelementsr   r   r   r   test_nvvm_accepts_encoding2   s    

z.TestNvvmWithoutCuda.test_nvvm_accepts_encodingN)__name__
__module____qualname__r   r   r/   r   r   r   r   r      s   r   __main__)Znumba.cuda.cudadrvr   Znumba.cuda.testingr   Z
numba.corer   Zllvmliter   r   r'   Zunittestr   r   ZskipIfZMACHINE_BITSZis_availableZTestCaser   r0   mainr   r   r   r   <module>   s   :