aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2024-01-24 19:17:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-19 21:24:44 +0000
commitab50317e96e57dee5b3ff4ad3f16f205b2a3359e (patch)
tree4b1f388eb6a07e574417aaacecd3ec4a83550718 /contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp
parent412542983a5ba62902141a8a7e155cceb9196a66 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp b/contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp
index 1de784c44da1..bfc35e41fe65 100644
--- a/contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp
+++ b/contrib/llvm-project/llvm/lib/Object/OffloadBinary.cpp
@@ -343,3 +343,35 @@ StringRef object::getImageKindName(ImageKind Kind) {
return "";
}
}
+
+bool object::areTargetsCompatible(const OffloadFile::TargetID &LHS,
+ const OffloadFile::TargetID &RHS) {
+ // Exact matches are not considered compatible because they are the same
+ // target. We are interested in different targets that are compatible.
+ if (LHS == RHS)
+ return false;
+
+ // The triples must match at all times.
+ if (LHS.first != RHS.first)
+ return false;
+
+ // Only The AMDGPU target requires additional checks.
+ llvm::Triple T(LHS.first);
+ if (!T.isAMDGPU())
+ return false;
+
+ // The base processor must always match.
+ if (LHS.second.split(":").first != RHS.second.split(":").first)
+ return false;
+
+ // Check combintions of on / off features that must match.
+ if (LHS.second.contains("xnack+") && RHS.second.contains("xnack-"))
+ return false;
+ if (LHS.second.contains("xnack-") && RHS.second.contains("xnack+"))
+ return false;
+ if (LHS.second.contains("sramecc-") && RHS.second.contains("sramecc+"))
+ return false;
+ if (LHS.second.contains("sramecc+") && RHS.second.contains("sramecc-"))
+ return false;
+ return true;
+}