Skip to content

Commit 0a85efc

Browse files
svenvhsys-ce-bb
authored andcommitted
Use StringRef::operator== instead of StringRef::equals (#2574)
The llvm project plans to deprecate `StringRef::equals` in favor of `StringRef::operator==`. Most of these changes were done using sed -i -e 's/\.equals("\([a-z0-9_\-]*\)")/ == "\1"/g' Original commit: KhronosGroup/SPIRV-LLVM-Translator@5e8c5dfeb0febe0
1 parent 43a52bb commit 0a85efc

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,12 +1027,11 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10271027
setVarArg(1);
10281028
else if (NameRef.starts_with("write_imageui"))
10291029
addUnsignedArg(2);
1030-
else if (NameRef.equals("prefetch")) {
1030+
else if (NameRef == "prefetch") {
10311031
addUnsignedArg(1);
10321032
setArgAttr(0, SPIR::ATTR_CONST);
1033-
} else if (NameRef.equals("get_kernel_work_group_size") ||
1034-
NameRef.equals(
1035-
"get_kernel_preferred_work_group_size_multiple")) {
1033+
} else if (NameRef == "get_kernel_work_group_size" ||
1034+
NameRef == "get_kernel_preferred_work_group_size_multiple") {
10361035
assert(F && "lack of necessary information");
10371036
const size_t BlockArgIdx = 0;
10381037
FunctionType *InvokeTy = getBlockInvokeTy(F, BlockArgIdx);
@@ -1041,19 +1040,18 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10411040
} else if (NameRef.starts_with("__enqueue_kernel")) {
10421041
// clang doesn't mangle enqueue_kernel builtins
10431042
setAsDontMangle();
1044-
} else if (NameRef.starts_with("get_") || NameRef.equals("nan") ||
1045-
NameRef.equals("mem_fence") || NameRef.starts_with("shuffle")) {
1043+
} else if (NameRef.starts_with("get_") || NameRef == "nan" ||
1044+
NameRef == "mem_fence" || NameRef.starts_with("shuffle")) {
10461045
addUnsignedArg(-1);
10471046
if (NameRef.starts_with(kOCLBuiltinName::GetFence)) {
10481047
setArgAttr(0, SPIR::ATTR_CONST);
10491048
addVoidPtrArg(0);
10501049
}
10511050
} else if (NameRef.contains("barrier")) {
10521051
addUnsignedArg(0);
1053-
if (NameRef.equals("work_group_barrier") ||
1054-
NameRef.equals("sub_group_barrier") ||
1055-
NameRef.equals("intel_work_group_barrier_arrive") ||
1056-
NameRef.equals("intel_work_group_barrier_wait"))
1052+
if (NameRef == "work_group_barrier" || NameRef == "sub_group_barrier" ||
1053+
NameRef == "intel_work_group_barrier_arrive" ||
1054+
NameRef == "intel_work_group_barrier_wait")
10571055
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_SCOPE);
10581056
} else if (NameRef.starts_with("atomic_work_item_fence")) {
10591057
addUnsignedArg(0);
@@ -1109,35 +1107,33 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11091107
NameRef = NameRef.drop_front(1);
11101108
UnmangledName.erase(0, 1);
11111109
} else if (NameRef.starts_with("s_")) {
1112-
if (NameRef.equals("s_upsample"))
1110+
if (NameRef == "s_upsample")
11131111
addUnsignedArg(1);
11141112
NameRef = NameRef.drop_front(2);
11151113
} else if (NameRef.starts_with("u_")) {
11161114
addUnsignedArg(-1);
11171115
NameRef = NameRef.drop_front(2);
1118-
} else if (NameRef.equals("fclamp")) {
1116+
} else if (NameRef == "fclamp") {
11191117
NameRef = NameRef.drop_front(1);
11201118
}
11211119
// handle [read|write]pipe builtins (plus two i32 literal args
11221120
// required by SPIR 2.0 provisional specification):
1123-
else if (NameRef.equals("read_pipe_2") || NameRef.equals("write_pipe_2")) {
1121+
else if (NameRef == "read_pipe_2" || NameRef == "write_pipe_2") {
11241122
// with 2 arguments (plus two i32 literals):
11251123
// int read_pipe (read_only pipe gentype p, gentype *ptr)
11261124
// int write_pipe (write_only pipe gentype p, const gentype *ptr)
11271125
addVoidPtrArg(1);
11281126
addUnsignedArg(2);
11291127
addUnsignedArg(3);
11301128
// OpenCL-like representation of blocking pipes
1131-
} else if (NameRef.equals("read_pipe_2_bl") ||
1132-
NameRef.equals("write_pipe_2_bl")) {
1129+
} else if (NameRef == "read_pipe_2_bl" || NameRef == "write_pipe_2_bl") {
11331130
// with 2 arguments (plus two i32 literals):
11341131
// int read_pipe_bl (read_only pipe gentype p, gentype *ptr)
11351132
// int write_pipe_bl (write_only pipe gentype p, const gentype *ptr)
11361133
addVoidPtrArg(1);
11371134
addUnsignedArg(2);
11381135
addUnsignedArg(3);
1139-
} else if (NameRef.equals("read_pipe_4") ||
1140-
NameRef.equals("write_pipe_4")) {
1136+
} else if (NameRef == "read_pipe_4" || NameRef == "write_pipe_4") {
11411137
// with 4 arguments (plus two i32 literals):
11421138
// int read_pipe (read_only pipe gentype p, reserve_id_t reserve_id, uint
11431139
// index, gentype *ptr) int write_pipe (write_only pipe gentype p,
@@ -1157,10 +1153,10 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11571153
// process [|work_group|sub_group]commit[read|write]pipe builtins
11581154
addUnsignedArg(2);
11591155
addUnsignedArg(3);
1160-
} else if (NameRef.equals("capture_event_profiling_info")) {
1156+
} else if (NameRef == "capture_event_profiling_info") {
11611157
addVoidPtrArg(2);
11621158
setEnumArg(1, SPIR::PRIMITIVE_CLK_PROFILING_INFO);
1163-
} else if (NameRef.equals("enqueue_marker")) {
1159+
} else if (NameRef == "enqueue_marker") {
11641160
setArgAttr(2, SPIR::ATTR_CONST);
11651161
addUnsignedArg(1);
11661162
} else if (NameRef.starts_with("vload")) {
@@ -1521,7 +1517,7 @@ SPIRV::transSPIRVMemoryScopeIntoOCLMemoryScope(Value *MemScope,
15211517

15221518
if (auto *CI = dyn_cast<CallInst>(MemScope)) {
15231519
Function *F = CI->getCalledFunction();
1524-
if (F && F->getName().equals(kSPIRVName::TranslateOCLMemScope)) {
1520+
if (F && F->getName() == kSPIRVName::TranslateOCLMemScope) {
15251521
// In case the SPIR-V module was created from an OpenCL program by
15261522
// *this* SPIR-V generator, we know that the value passed to
15271523
// __translate_ocl_memory_scope is what we should pass to the
@@ -1545,7 +1541,7 @@ SPIRV::transSPIRVMemorySemanticsIntoOCLMemoryOrder(Value *MemorySemantics,
15451541

15461542
if (auto *CI = dyn_cast<CallInst>(MemorySemantics)) {
15471543
Function *F = CI->getCalledFunction();
1548-
if (F && F->getName().equals(kSPIRVName::TranslateOCLMemOrder)) {
1544+
if (F && F->getName() == kSPIRVName::TranslateOCLMemOrder) {
15491545
// In case the SPIR-V module was created from an OpenCL program by
15501546
// *this* SPIR-V generator, we know that the value passed to
15511547
// __translate_ocl_memory_order is what we should pass to the

llvm-spirv/lib/SPIRV/PassPlugin.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ PassPluginLibraryInfo getSPIRVPluginInfo() {
6565
PB.registerPipelineParsingCallback(
6666
[](StringRef Name, FunctionPassManager &PM,
6767
ArrayRef<PassBuilder::PipelineElement>) {
68-
if (Name.equals("spirv-lower-bitcast")) {
68+
if (Name == "spirv-lower-bitcast") {
6969
PM.addPass(
7070
SPIRVLowerBitCastToNonStandardTypePass(TranslatorOpts{}));
7171
return true;
@@ -75,50 +75,50 @@ PassPluginLibraryInfo getSPIRVPluginInfo() {
7575
PB.registerPipelineParsingCallback(
7676
[](StringRef Name, ModulePassManager &PM,
7777
ArrayRef<PassBuilder::PipelineElement>) {
78-
if (Name.equals("ocl-to-spirv")) {
78+
if (Name == "ocl-to-spirv") {
7979
PM.addPass(OCLToSPIRVPass());
8080
return true;
8181
}
82-
if (Name.equals("llvm-to-spirv")) {
82+
if (Name == "llvm-to-spirv") {
8383
SPIRV::TranslatorOpts DefaultOpts;
8484
DefaultOpts.enableAllExtensions();
8585
SPIRVModule *BM = SPIRVModule::createSPIRVModule(DefaultOpts);
8686
PM.addPass(LLVMToSPIRVPass(BM));
8787
return true;
8888
}
89-
if (Name.equals("process-metadata")) {
89+
if (Name == "process-metadata") {
9090
PM.addPass(PreprocessMetadataPass());
9191
return true;
9292
}
93-
if (Name.equals("spirv-lower-bool")) {
93+
if (Name == "spirv-lower-bool") {
9494
PM.addPass(SPIRVLowerBoolPass());
9595
return true;
9696
}
97-
if (Name.equals("spirv-lower-constexpr")) {
97+
if (Name == "spirv-lower-constexpr") {
9898
PM.addPass(SPIRVLowerConstExprPass());
9999
return true;
100100
}
101-
if (Name.equals("spirv-lower-memmove")) {
101+
if (Name == "spirv-lower-memmove") {
102102
PM.addPass(SPIRVLowerMemmovePass());
103103
return true;
104104
}
105-
if (Name.equals("spirv-lower-ocl-blocks")) {
105+
if (Name == "spirv-lower-ocl-blocks") {
106106
PM.addPass(SPIRVLowerOCLBlocksPass());
107107
return true;
108108
}
109-
if (Name.equals("spirv-lower-llvm-intrinsic")) {
109+
if (Name == "spirv-lower-llvm-intrinsic") {
110110
PM.addPass(SPIRVLowerLLVMIntrinsicPass(TranslatorOpts{}));
111111
return true;
112112
}
113-
if (Name.equals("spirv-regularize-llvm")) {
113+
if (Name == "spirv-regularize-llvm") {
114114
PM.addPass(SPIRVRegularizeLLVMPass());
115115
return true;
116116
}
117-
if (Name.equals("spirv-to-ocl12")) {
117+
if (Name == "spirv-to-ocl12") {
118118
PM.addPass(SPIRVToOCL12Pass());
119119
return true;
120120
}
121-
if (Name.equals("spirv-to-ocl20")) {
121+
if (Name == "spirv-to-ocl20") {
122122
PM.addPass(SPIRVToOCL20Pass());
123123
return true;
124124
}

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,7 @@ bool getRetParamSignedness(Function *F, ParamSignedness &RetSignedness,
915915
StringRef Arg(stringify(Name));
916916
if (Arg.starts_with("unsigned"))
917917
return ParamSignedness::Unsigned;
918-
if (Arg.equals("char") || Arg.equals("short") || Arg.equals("int") ||
919-
Arg.equals("long"))
918+
if (Arg == "char" || Arg == "short" || Arg == "int" || Arg == "long")
920919
return ParamSignedness::Signed;
921920
}
922921
return ParamSignedness::Unknown;

0 commit comments

Comments
 (0)