Skip to content

Commit 41fa581

Browse files
igorban-intelsys-cmllvm
authored andcommitted
Fix memory types for llvm-16 build
.
1 parent 4daa8d1 commit 41fa581

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

GenXIntrinsics/include/llvm/GenXIntrinsics/GenXIntrinsics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ SPDX-License-Identifier: MIT
2323
#include "llvm/IR/Intrinsics.h"
2424
#include "llvm/IR/Instructions.h"
2525
#include "llvm/GenXIntrinsics/GenXVersion.h"
26+
#if LLVM_VERSION_MAJOR >= 16
27+
#include "llvm/Support/ModRef.h"
28+
#endif
2629

2730
namespace llvm {
2831

GenXIntrinsics/include/llvm/GenXIntrinsics/Intrinsics.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
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
8187
platform_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+
105126
Intrinsics = dict()
106127
parse = 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

Comments
 (0)