
    J/Ph                         d dl mZmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZmZ d dlmZmZmZ d dlmZ d dlmZ  G d	 d
e          Z G d de          ZdS )    )CompilerDefaultPassBuilder)FunctionPassAnalysisPassregister_pass)InlineInlinables)IRLegalization)jitobjmodenjitcfunc)typespostprocerrors)
FunctionIR)TestCasec                   0     e Zd Z fdZd Zd Zd Z xZS )TestCustomPipelinec                     t          t          |                                             G fddt                    | _        d S )Nc                   2     e Zd Zg Z fdZ fdZ xZS )0TestCustomPipeline.setUp.<locals>.CustomPipelinec                 ~    | j                             |           t          |                               |          S N)custom_pipeline_cacheappendsupercompile_extra)selffuncCustomPipeline	__class__s     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/tests/test_pipeline.pyr   z>TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_extra   s8    *11$777^T22@@FFF    c                 v    | j                             |            t          |           j        |g|R i |S r   )r   r   r   
compile_ir)r   func_irargskwargsr    r!   s       r"   r%   z;TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_ir   sX    *11':::=u^T22=.". . .&,. . .r#   )__name__
__module____qualname__r   r   r%   __classcell__)r!   r    s   @r"   r    r      sh        $&!G G G G G G
. . . . . . . . . .r#   r    )r   r   setUpr   pipeline_class)r   r    r!   s    @r"   r-   zTestCustomPipeline.setUp   se     $''--///	. 	. 	. 	. 	. 	. 	.X 	. 	. 	. -r#   c                    |                      | j        j        g            t          | j                  d             }|                      |d          d           |                      | j        j        |j        g           d S )Nr.   c                     | S r    xs    r"   fooz8TestCustomPipeline.test_jit_custom_pipeline.<locals>.foo$       Hr#      )assertListEqualr.   r   r
   assertEqualpy_funcr   r5   s     r"   test_jit_custom_pipelinez+TestCustomPipeline.test_jit_custom_pipeline!   s    T0FKKK	D/	0	0	0	 	 
1	0	 	Q###T0F!k]	, 	, 	, 	, 	,r#   c                 F   |                      | j        j        g            t          t	          j        t          j                  | j                  d             }|                      |d          d           |                      | j        j        |j        g           d S )Nr0   c                     | S r   r2   r3   s    r"   r5   z:TestCustomPipeline.test_cfunc_custom_pipeline.<locals>.foo/   r6   r#   r7   )r8   r.   r   r   r   int64r9   __wrapped__r;   s     r"   test_cfunc_custom_pipelinez-TestCustomPipeline.test_cfunc_custom_pipeline,   s    T0FKKK	u{5;''8K	L	L	L	 	 
M	L	 	Q###T0F!o.	0 	0 	0 	0 	0r#   c                    |                      | j        j        g            t          | j                  d             }d}|                      ||          |dz              |                     t          | j        j                  d           | j        j        d         }|                     ||j                   | j        j        d         }|                     |t                     d S )Nr0   c                 z    t          d          5  | t          d          z  } d d d            n# 1 swxY w Y   | S )Nintpr3      )r   intr3   s    r"   r5   z<TestCustomPipeline.test_objmode_custom_pipeline.<locals>.foo:   s|    6"""  SXX              Hs   044{   rE      r   )
r8   r.   r   r
   r9   lenassertIsr:   assertIsInstancer   )r   r5   argfirstseconds        r"   test_objmode_custom_pipelinez/TestCustomPipeline.test_objmode_custom_pipeline7   s    T0FKKK	D/	0	0	0	 	 
1	0	
 S37+++T0FGGKKK#9!<eS[)))$:1=fj11111r#   )r)   r*   r+   r-   r<   rA   rO   r,   )r!   s   @r"   r   r      se        - - - - -(	, 	, 	,	0 	0 	02 2 2 2 2 2 2r#   r   c                   "    e Zd ZddZd Zd ZdS )TestPassManagerFunctionalityNc                     |                      du           |                      du           t          dd           G fdd                       G fddt                    }|S )z
        Creates a new compiler pipeline with the _InjectDelsPass injected after
        the pass supplied in kwarg 'inject_after'.
        NF)mutates_CFGanalysis_onlyc                   @    e Zd ZdZd e           z  Z fdZd ZdS )LTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPasszD
            This pass injects ir.Del nodes into the IR
            zinject_dels_%sc                 2                         |            d S r   )__init__)r   bases    r"   rX   zUTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPass.__init__]   s    d#####r#   c                 d    t          j        |j                  }|                    d           dS )NT)	emit_dels)r   PostProcessorr&   run)r   statepps      r"   run_passzUTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPass.run_pass`   s-    +EM::&&&tr#   N)r)   r*   r+   __doc__str_namerX   r`   )rY   s   r"   _InjectDelsPassrV   V   s[          %ss4yy0E$ $ $ $ $    r#   rd   c                       e Zd Z fdZdS )ITestPassManagerFunctionality._create_pipeline_w_del.<locals>.TestCompilerc                     t          j        | j                  }|                               |                                 |gS r   )r   define_nopython_pipeliner^   add_pass_afterfinalize)r   pmrd   inject_afters     r"   define_pipelineszZTestPassManagerFunctionality._create_pipeline_w_del.<locals>.TestCompiler.define_pipelinesg   s?    '@LL!!/<@@@tr#   N)r)   r*   r+   rm   )rd   rl   s   r"   TestCompilerrf   e   s3               r#   rn   )
assertTruer   r   )r   rY   rl   rn   rd   s    `` @r"   _create_pipeline_w_delz3TestPassManagerFunctionality._create_pipeline_w_delN   s    
 	D0111D()))	5	>	>	>	 	 	 	 	 	 	d 	 	 
?	>		 	 	 	 	 	 	 	8 	 	 	 r#   c                 |   |                      t          t                    }t          |          d             }|                     t
          j                  5 } |d           d d d            n# 1 swxY w Y   t          |j                  }| 	                    d|           | 	                    d|           d S )Nr0   c                     | dz   S NrE   r2   r3   s    r"   r5   zYTestPassManagerFunctionality.test_compiler_error_on_ir_del_from_functionpass.<locals>.foos       q5Lr#   
   zIllegal IR, del found at:zdel x)
rp   r   r   r   assertRaisesr   CompilerErrorrb   	exceptionassertIn)r   new_compilerr5   raiseserrstrs        r"   /test_compiler_error_on_ir_del_from_functionpasszLTestPassManagerFunctionality.test_compiler_error_on_ir_del_from_functionpasso   s    22<3CE E 
\	*	*	*	 	 
+	*	 v344 	CGGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 V%&&16:::gv&&&&&s   A11A58A5c                     |                      t          t                    }t          |          d             }|                      |d          |                    d                     d S )Nr0   c                     | dz   S rs   r2   r3   s    r"   r5   z]TestPassManagerFunctionality.test_no_compiler_error_on_ir_del_after_legalization.<locals>.foo   rt   r#   ru   )rp   r   r	   r   ro   r:   )r   rz   r5   s      r"   3test_no_compiler_error_on_ir_del_after_legalizationzPTestPassManagerFunctionality.test_no_compiler_error_on_ir_del_after_legalization   su     22<3AC C 
\	*	*	*	 	 
+	*	 	BR11111r#   )NN)r)   r*   r+   rp   r}   r   r2   r#   r"   rQ   rQ   L   sG           B' ' ' 2 2 2 2 2r#   rQ   N)numba.core.compilerr   r   numba.core.compiler_machineryr   r   r   numba.core.untyped_passesr   numba.core.typed_passesr	   numbar
   r   r   r   
numba.corer   r   r   numba.core.irr   numba.tests.supportr   r   rQ   r2   r#   r"   <module>r      sB   < < < < < < < <: : : : : : : : : : 6 6 6 6 6 6 2 2 2 2 2 2 + + + + + + + + + + + + . . . . . . . . . . $ $ $ $ $ $ ( ( ( ( ( (=2 =2 =2 =2 =2 =2 =2 =2@C2 C2 C2 C2 C28 C2 C2 C2 C2 C2r#   