7676 "SideEffects" : set (["NoUnwind" ]),
7777}
7878
79+ modref_map = {
80+ "ReadNone" : "none" ,
81+ "ReadOnly" : "readOnly" ,
82+ "WriteOnly" : "writeOnly"
83+ }
84+
7985# order does really matter.
8086# It is used to define ordering between the respected platforms
8187platform_list = [
@@ -102,6 +108,21 @@ def getAttributeList(Attrs):
102108 s = reduce (lambda acc , v : attribute_map [v ] | acc , Attrs , set ())
103109 return ['Attribute::' + x for x in sorted (s )]
104110
111+
112+ def getAttributeListModRef (Attrs ):
113+ """
114+ Takes a list of attribute names, calculates the union,
115+ and returns a list of the the given attributes
116+ """
117+ s = reduce (lambda acc , v : attribute_map [v ] | acc , Attrs , set ())
118+ attr = []
119+ for x in sorted (s ):
120+ if x in modref_map :
121+ attr += ['addMemoryAttr(MemoryEffects::' + modref_map [x ] + '())' ]
122+ else :
123+ attr += ['addAttribute(Attribute::' + x + ')' ]
124+ return attr
125+
105126Intrinsics = dict ()
106127parse = sys .argv
107128
@@ -536,12 +557,18 @@ def createAttributeTable():
536557
537558 for i in range (len (attribute_Array )): #Building case statements
538559 Attrs = getAttributeList ([x .strip () for x in attribute_Array [i ].split (',' )])
560+ AttrModRef = getAttributeListModRef ([x .strip () for x in attribute_Array [i ].split (',' )])
539561 f .write (""" case {num}: {{
562+ #if LLVM_VERSION_MAJOR >= 16
563+ AttrBuilder Atts(C);
564+ Atts.{attrs_mod};
565+ #else
540566 const Attribute::AttrKind Atts[] = {{{attrs}}};
567+ #endif
541568 AS[0] = AttributeList::get(C, AttributeList::FunctionIndex, Atts);
542569 NumAttrs = 1;
543570 break;
544- }}\n """ .format (num = i + 1 , attrs = ',' .join (Attrs )))
571+ }}\n """ .format (num = i + 1 , attrs_mod = '.' . join ( AttrModRef ), attrs = ',' .join (Attrs )))
545572 f .write (" }\n "
546573 " }\n "
547574 " return AttributeList::get(C, ArrayRef<AttributeList>(AS, NumAttrs));\n "
0 commit comments