
    e	                     |    d Z ddlmZmZ i Z G d d      Zd Z ee      Zd Zed        Z	ed        Z
ed	        Zy
)z'Aliases for microarchitecture features.   )TARGETS_JSONLazyDictionaryc                       e Zd ZdZd Zd Zy)FeatureAliasTestzA test that must be passed for a feature alias to succeed.

    Args:
        rules (dict): dictionary of rules to be met. Each key must be a
            valid alias predicate
    c                     || _         g | _        |j                         D ],  \  }}| j                  j                  t	        |   |             . y N)rules
predicatesitemsappend_FEATURE_ALIAS_PREDICATE)selfr	   nameargss       2lib/python3.12/site-packages/archspec/cpu/alias.py__init__zFeatureAliasTest.__init__   sA    
++-JD$OO""#;D#A$#GH (    c                 @    t        fd| j                  D              S )Nc              3   .   K   | ]  } |        y wr    ).0feature_testmicroarchitectures     r   	<genexpr>z,FeatureAliasTest.__call__.<locals>.<genexpr>   s     W|< 12s   )allr
   )r   r   s    `r   __call__zFeatureAliasTest.__call__   s    WtWWWr   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r      s    IXr   r   c                  h    t         d   } i }| j                         D ]  \  }}t        |      ||<    |S )z6Returns the dictionary of all defined feature aliases.feature_aliases)r   r   r   )	json_dataaliasesaliasr	   s       r   _feature_aliasesr&      s:    ./IG!)u)%0 *Nr   c                 b    | j                   }|t        v rd| d}t        |      | t        |<   | S )zXDecorator to register a predicate that can be used to evaluate
    feature aliases.
    zthe alias predicate "z" already exists)r   r   KeyError)funcr   msgs      r   alias_predicater+   *   sA     ==D ''%dV+;<sm%)T"Kr   c                     d S )zThis predicate returns always True and it's there to allow writing
    a documentation string in the JSON file to explain why an alias is needed.
    c                      y)NTr   )xs    r   <lambda>zreason.<locals>.<lambda>?   s    Tr   r   )_s    r   reasonr1   :   s
    
 r   c                       fd}|S )zReturns a predicate that is True if any of the feature in the
    list is in the microarchitecture being tested, False otherwise.
    c                 .     t         fdD              S )Nc              3   &   K   | ]  }|v  
 y wr   r   )r   r.   r   s     r   r   z(any_of.<locals>._impl.<locals>.<genexpr>I   s     D3Ca1))3Cs   )any)r   list_of_featuress   `r   _implzany_of.<locals>._implH   s    D3CDDDr   r   )r6   r7   s   ` r   any_ofr8   B   s    E Lr   c                       fd}|S )zReturns a predicate that is True if the architecture family of
    the microarchitecture being tested is in the list, False otherwise.
    c                 2    t        | j                        v S r   )strfamily)r   list_of_familiess    r   r7   zfamilies.<locals>._implT   s    $++,0@@@r   r   )r=   r7   s   ` r   familiesr>   N   s    A Lr   N)r    schemar   r   r   r   r&   FEATURE_ALIASESr+   r1   r8   r>   r   r   r   <module>rA      sr   
 . 0 X X& !!12       r   