Skip to content

Commit e6ad733

Browse files
authored
[SYCL][NFC] Replace a macro with a lambda in LowerWGScope.cpp (#17564)
There's no good reason to use a macro here, a lambda is simpler and easier to modify.
1 parent e1cf106 commit e6ad733

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

llvm/lib/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -938,24 +938,26 @@ Value *spirv::genPseudoLocalID(Instruction &Before, const Triple &TT) {
938938
IRBuilder<> Bld(Ctx);
939939
Bld.SetInsertPoint(&Before);
940940

941-
#define CREATE_CALLEE(NAME, FN_NAME) \
942-
FunctionCallee FnCallee##NAME = M.getOrInsertFunction(FN_NAME, RetTy); \
943-
assert(FnCallee##NAME && "spirv intrinsic creation failed"); \
944-
auto NAME = Bld.CreateCall(FnCallee##NAME, {});
945-
946-
CREATE_CALLEE(LocalInvocationId_X, "_Z27__spirv_LocalInvocationId_xv");
947-
CREATE_CALLEE(LocalInvocationId_Y, "_Z27__spirv_LocalInvocationId_yv");
948-
CREATE_CALLEE(LocalInvocationId_Z, "_Z27__spirv_LocalInvocationId_zv");
949-
950-
#undef CREATE_CALLEE
941+
auto CreateCallee = [&](StringRef Name) {
942+
FunctionCallee Callee = M.getOrInsertFunction(Name, RetTy);
943+
assert(Callee.getCallee() && "spirv intrinsic creation failed");
944+
return Bld.CreateCall(Callee, {});
945+
};
946+
947+
Value *LocalInvocationIdX =
948+
CreateCallee("_Z27__spirv_LocalInvocationId_xv");
949+
Value *LocalInvocationIdY =
950+
CreateCallee("_Z27__spirv_LocalInvocationId_yv");
951+
Value *LocalInvocationIdZ =
952+
CreateCallee("_Z27__spirv_LocalInvocationId_zv");
951953

952954
// 1: returns
953955
// __spirv_LocalInvocationId_x() |
954956
// __spirv_LocalInvocationId_y() |
955957
// __spirv_LocalInvocationId_z()
956958
//
957-
return Bld.CreateOr(LocalInvocationId_X,
958-
Bld.CreateOr(LocalInvocationId_Y, LocalInvocationId_Z));
959+
return Bld.CreateOr(LocalInvocationIdX,
960+
Bld.CreateOr(LocalInvocationIdY, LocalInvocationIdZ));
959961
} else {
960962
// extern "C" const __constant size_t __spirv_BuiltInLocalInvocationIndex;
961963
// Must correspond to the code in

0 commit comments

Comments
 (0)