================
@@ -1223,21 +1224,52 @@ getLLVMMemOrder(std::optional<cir::MemOrder> memorder) {
llvm_unreachable("unknown memory order");
}
-static llvm::StringRef getLLVMSyncScope(cir::SyncScopeKind syncScope) {
+static bool isNVPTXTriple(mlir::Operation *op) {
+ auto moduleOp = op->getParentOfType<mlir::ModuleOp>();
+ if (!moduleOp)
+ return false;
+ if (auto tripleAttr = moduleOp->getAttrOfType<mlir::StringAttr>(
+ cir::CIRDialect::getTripleAttrName()))
+ return llvm::Triple(tripleAttr.getValue()).isNVPTX();
+ return false;
+}
+
+static llvm::StringRef getLLVMSyncScope(cir::SyncScopeKind syncScope,
+ mlir::Operation *op) {
switch (syncScope) {
case cir::SyncScopeKind::SingleThread:
+ case cir::SyncScopeKind::HIPSingleThread:
return "singlethread";
- case cir::SyncScopeKind::Workgroup:
- return "block";
- default:
+ case cir::SyncScopeKind::System:
+ case cir::SyncScopeKind::HIPSystem:
+ case cir::SyncScopeKind::OpenCLAllSVMDevices:
return "";
- }
+ case cir::SyncScopeKind::Device:
+ case cir::SyncScopeKind::HIPAgent:
+ case cir::SyncScopeKind::OpenCLDevice:
+ return "agent";
+ case cir::SyncScopeKind::Workgroup:
+ case cir::SyncScopeKind::HIPWorkgroup:
+ case cir::SyncScopeKind::OpenCLWorkGroup:
+ // NVPTX uses "block" for workgroup sync scope; AMDGPU uses "workgroup".
+ return isNVPTXTriple(op) ? "block" : "workgroup";
----------------
steffenlarsen wrote:
Ah, good shout. It is now used instead!
https://github.com/llvm/llvm-project/pull/225364
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits