Skip to content

Commit 4d6413c

Browse files
committed
Hoist scope mapping into named function.
1 parent f65fa1d commit 4d6413c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
192192
return CGF.Builder.CreateCall(F, {Src0, Src1});
193193
}
194194

195+
static inline StringRef mapScopeToSPIRV(StringRef AMDGCNScope) {
196+
if (AMDGCNScope == "agent")
197+
return "device";
198+
if (AMDGCNScope == "wavefront")
199+
return "subgroup";
200+
return AMDGCNScope;
201+
}
202+
195203
// For processing memory ordering and memory scope arguments of various
196204
// amdgcn builtins.
197205
// \p Order takes a C++11 compatible memory-ordering specifier and converts
@@ -227,12 +235,8 @@ void CodeGenFunction::ProcessOrderScopeAMDGCN(Value *Order, Value *Scope,
227235
// Some of the atomic builtins take the scope as a string name.
228236
StringRef scp;
229237
if (llvm::getConstantStringInfo(Scope, scp)) {
230-
if (getTarget().getTriple().isSPIRV()) {
231-
if (scp == "agent")
232-
scp = "device";
233-
else if (scp == "wavefront")
234-
scp = "subgroup";
235-
}
238+
if (getTarget().getTriple().isSPIRV())
239+
scp = mapScopeToSPIRV(scp);
236240
SSID = getLLVMContext().getOrInsertSyncScopeID(scp);
237241
return;
238242
}

0 commit comments

Comments
 (0)