66#
77# =========================== end_copyright_notice =============================
88
9- from typing import List , Set , Optional
9+ from typing import List , Set , Optional , Union
1010from enum import Enum
1111import yaml
1212
@@ -593,20 +593,26 @@ class IntrinsicDefinition(SafeYAMLObject):
593593
594594 yaml_tag = u'IntrinsicDefinition'
595595
596+ AttributeSet = Set [Union [AttributeID
597+ ]]
598+
596599 @classmethod
597600 def from_yaml (cls , loader , node ):
598601 arg_dict = loader .construct_mapping (node , deep = True )
599602 res = cls (** arg_dict )
600603 return res
601604
602605 def __init__ (self , name : str , comment : str , return_definition : ReturnDefinition ,
603- arguments : List [ArgumentDefinition ], attributes : Set [ AttributeID ] ,
606+ arguments : List [ArgumentDefinition ], attributes : AttributeSet ,
604607 memory_effects : List [MemoryRestriction ] = [ MemoryRestriction () ]):
605608 self .name = QuotedString (name )
606609 self .comment = QuotedString (comment )
607610 self .return_definition = return_definition
608611 self .arguments = arguments
609- self .attributes = sorted (list (attributes ), key = lambda x : x .__str__ ())
612+
613+ self .attributes = [attr for attr in attributes if isinstance (attr , AttributeID )]
614+ self .attributes = sorted (self .attributes , key = lambda x : x .__str__ ())
615+
610616 if len (memory_effects ) > 1 :
611617 # TODO: To support LLVM 16-style memory effects per multiple locations,
612618 # we'll need to gather multiple MemoryRestriction entries into a
@@ -616,9 +622,13 @@ def __init__(self, name : str, comment : str, return_definition : ReturnDefiniti
616622 self .memory_effects = memory_effects
617623
618624 def __repr__ (self ):
619- return "%s(name=%r, comment=%r, return_definition=%r, arguments=%r, attributes=%r, memory_effects=%r)" % (
625+ fmt_string = "%s(name=%r, comment=%r, return_definition=%r, arguments=%r, attributes=%r"
626+ fmt_string += ", memory_effects=%r)"
627+ return fmt_string % (
620628 self .__class__ .__name__ , self .name , self .comment , self .return_definition ,
621- self .arguments , self .attributes , self .memory_effects )
629+ self .arguments ,
630+ self .attributes ,
631+ self .memory_effects )
622632
623633 def to_dict (self ):
624634 res = {
@@ -643,7 +653,9 @@ def from_dict(json_dct : dict):
643653 if memory_effects_entry else []
644654 )
645655 return IntrinsicDefinition (json_dct ['name' ], json_dct ['comment' ], return_definition ,
646- arguments , attributes , memory_effects )
656+ arguments ,
657+ attributes
658+ , memory_effects )
647659
648660class PrimitiveArgumentDefinition (SafeYAMLObject ):
649661
0 commit comments