
    Xh                     0   d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ d dlmZ  e	ddd          Z ee          Ze j                            e          Ze j                            ed	          Z G d
 de          Zd Zd Zd Zd ZdS )    N)	ASTSourcemake_backend)	GPUTarget)GluonASTSource)ircudad       	FileCheckc                   (     e Zd Z fdZ fdZ xZS )
MatchErrorc                 X    t                                          |           || _        d S N)super__init__
module_str)selfmessager   	__class__s      c/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/triton/_filecheck.pyr   zMatchError.__init__   s&    !!!$    c                 X    t                                                       d| j         S )N
)r   __str__r   )r   r   s    r   r   zMatchError.__str__   s'    ''//##88t888r   )__name__
__module____qualname__r   r   __classcell__)r   s   @r   r   r      sQ        % % % % %9 9 9 9 9 9 9 9 9r   r   c                    t          j                    5 }t          j                            |d          }t          |d          5 }|                    |           d d d            n# 1 swxY w Y   t          j                            |d          }t          |d          5 }|                    |           d d d            n# 1 swxY w Y   	 t          j        t          |d|gt          j
                   n@# t          j        $ r.}|j                            d          }t          |          d }~ww xY w	 d d d            d S # 1 swxY w Y   d S )Nmodulewexpectedz--input-file)stderrunicode_escape)tempfileTemporaryDirectoryospathjoinopenwrite
subprocesscheck_outputfilecheck_pathSTDOUTCalledProcessErroroutputdecode
ValueError)	namer   check_templatetempdirtemp_moduletemptemp_expectederrordecodeds	            r   run_filecheckr<   "   s   		$	&	& &'gll7H55+s## 	#tJJz"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# Wj99-%% 	'JJ~&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'	&#^]NT_$`+5+<> > > > >, 	& 	& 	&l))*:;;GW%%%	&>& & & & & & & & & & & & & & & & & &s}   1EA'E'A+	+E.A+	/3E"C8EC	EC	E)C:9E:D7	)D22D77EEEc                    d | j         D             }d t          t          |                    D             }d t          ||          D             }|                                 rt
          nt          } || |          }t          j                    }t          j	        |           t          	                    |           |                                }t                              t          di |          }t                              |          }	t                                          }
|                    ||	|
|          }|                                sJ |S )Nc                     g | ]	}|j         
S  )r4   ).0xs     r   
<listcomp>zrun_parser.<locals>.<listcomp>5   s    000!qv000r   c                     g | ]}d | S )argr?   )r@   is     r   rB   zrun_parser.<locals>.<listcomp>6   s    666QyQyy666r   c                     i | ]\  }}||	S r?   r?   )r@   kvs      r   
<dictcomp>zrun_parser.<locals>.<dictcomp>7   s    :::&1aA:::r   )fn	signaturer?   )paramsrangelenzipis_gluonr   r   r   contextload_dialectsstub_backendparse_optionsdictget_codegen_implementationget_module_mapmake_irverify)	kernel_fnsigkeyssigvalsrK   
source_clssrcrQ   extra_optionsoptionscodegen_fns
module_mapr    s               r   
run_parserrc   4   s:   00y/000G66%G"5"5666G::C$9$9:::I#,#5#5#7#7FYJ
*	Y
7
7
7CjllGWw'''%%''M(()>)>)>)>??G99'BBK,,..J[[+z7CCF==??Mr   c                     t          | t          j        j                  sJ t	          j        | j                  }|t          d          t          |           }t          d|
                                |           d S )Nz=kernel function must have a docstring with FileCheck templateplaceholder)
isinstancetritonruntimeJITFunctioninspect	getsourcerJ   r3   rc   r<   str_nodebug)rZ   r5   mlir_modules      r   run_filecheck_testrn   H   su    i!;<<<<<&y|44NXYYYY''K-!8!8!:!:NKKKKKr   c                       fd}|S )Nc                  &    t                      d S r   )rn   )rJ   s   r   test_fnzfilecheck_test.<locals>.test_fnT   s    2r   r?   )rJ   rq   s   ` r   filecheck_testrr   R   s#         Nr   )r'   rj   r,   r%   rg   triton.compilerr   r   triton.backends.compilerr   "triton.experimental.gluon._runtimer   triton._C.libtritonr   stub_targetrS   r(   dirname__file__
triton_dirr)   r.   r3   r   r<   rc   rn   rr   r?   r   r   <module>r{      sB   				        3 3 3 3 3 3 3 3 . . . . . . = = = = = = " " " " " " iR((|K((W__X&&
j+669 9 9 9 9 9 9 9& & &$  (L L L    r   