Skip to content

Commit cf5fb19

Browse files
committed
refine using Join
1 parent 6a9a4d9 commit cf5fb19

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/Target/NVPTX/NVPTXIntrinsics.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,10 @@ foreach dim = [1, 2, 3, 4, 5] in {
741741
}
742742

743743
//Prefetch and Prefetchu
744+
class Join<string sep, list<string> lst> {
745+
string ret = !foldl("", lst, a, b, !if(!eq(a, ""), b, !if(!eq(b,""), a, !strconcat(a, sep, b))));
746+
}
747+
744748
class PREFETCH_INTRS<string InstName> :
745749
NVPTXInst<(outs), (ins Int64Regs:$addr),
746750
InstName # " [$addr];",
@@ -754,7 +758,7 @@ class PREFETCH_INTRS<string InstName> :
754758
foreach level = ["L1", "L2"] in {
755759
foreach addr = ["global", "local", ""] in {
756760
foreach evict = !if(!eq(addr, "global"), ["evictlast", "evictnormal"], ["evictnormal"]) in {
757-
defvar suffix = "" # !if(!eq(addr, ""), "", addr # "_") # level # "_" # evict;
761+
defvar suffix = Join<"_", [addr, level, evict]>.ret;
758762
defvar inst_name = "prefetch." # !subst("_", ".", suffix);
759763
def PREFETCH_# suffix : PREFETCH_INTRS<inst_name>;
760764
}

0 commit comments

Comments
 (0)