@@ -676,7 +676,7 @@ AtomicWorkItemFenceLiterals getAtomicWorkItemFenceLiterals(CallInst *CI) {
676
676
}
677
677
678
678
size_t getAtomicBuiltinNumMemoryOrderArgs (StringRef Name) {
679
- if (Name.startswith (" atomic_compare_exchange" ))
679
+ if (Name.starts_with (" atomic_compare_exchange" ))
680
680
return 2 ;
681
681
return 1 ;
682
682
}
@@ -691,8 +691,8 @@ size_t getSPIRVAtomicBuiltinNumMemoryOrderArgs(Op OC) {
691
691
// max]_explicit functions declared in clang headers should be translated
692
692
// to corresponding FP-typed Atomic Instructions
693
693
bool isComputeAtomicOCLBuiltin (StringRef DemangledName) {
694
- if (!DemangledName.startswith (kOCLBuiltinName ::AtomicPrefix) &&
695
- !DemangledName.startswith (kOCLBuiltinName ::AtomPrefix))
694
+ if (!DemangledName.starts_with (kOCLBuiltinName ::AtomicPrefix) &&
695
+ !DemangledName.starts_with (kOCLBuiltinName ::AtomPrefix))
696
696
return false ;
697
697
698
698
return llvm::StringSwitch<bool >(DemangledName)
@@ -1027,12 +1027,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1027
1027
NameRef = StringRef (TempStorage);
1028
1028
};
1029
1029
1030
- if (NameRef.startswith (" async_work_group" )) {
1030
+ if (NameRef.starts_with (" async_work_group" )) {
1031
1031
addUnsignedArg (-1 );
1032
1032
setArgAttr (1 , SPIR::ATTR_CONST);
1033
- } else if (NameRef.startswith (" printf" ))
1033
+ } else if (NameRef.starts_with (" printf" ))
1034
1034
setVarArg (1 );
1035
- else if (NameRef.startswith (" write_imageui" ))
1035
+ else if (NameRef.starts_with (" write_imageui" ))
1036
1036
addUnsignedArg (2 );
1037
1037
else if (NameRef.equals (" prefetch" )) {
1038
1038
addUnsignedArg (1 );
@@ -1045,13 +1045,13 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1045
1045
FunctionType *InvokeTy = getBlockInvokeTy (F, BlockArgIdx);
1046
1046
if (InvokeTy->getNumParams () > 1 )
1047
1047
setLocalArgBlock (BlockArgIdx);
1048
- } else if (NameRef.startswith (" __enqueue_kernel" )) {
1048
+ } else if (NameRef.starts_with (" __enqueue_kernel" )) {
1049
1049
// clang doesn't mangle enqueue_kernel builtins
1050
1050
setAsDontMangle ();
1051
- } else if (NameRef.startswith (" get_" ) || NameRef.equals (" nan" ) ||
1052
- NameRef.equals (" mem_fence" ) || NameRef.startswith (" shuffle" )) {
1051
+ } else if (NameRef.starts_with (" get_" ) || NameRef.equals (" nan" ) ||
1052
+ NameRef.equals (" mem_fence" ) || NameRef.starts_with (" shuffle" )) {
1053
1053
addUnsignedArg (-1 );
1054
- if (NameRef.startswith (kOCLBuiltinName ::GetFence)) {
1054
+ if (NameRef.starts_with (kOCLBuiltinName ::GetFence)) {
1055
1055
setArgAttr (0 , SPIR::ATTR_CONST);
1056
1056
addVoidPtrArg (0 );
1057
1057
}
@@ -1062,18 +1062,18 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1062
1062
NameRef.equals (" intel_work_group_barrier_arrive" ) ||
1063
1063
NameRef.equals (" intel_work_group_barrier_wait" ))
1064
1064
setEnumArg (1 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1065
- } else if (NameRef.startswith (" atomic_work_item_fence" )) {
1065
+ } else if (NameRef.starts_with (" atomic_work_item_fence" )) {
1066
1066
addUnsignedArg (0 );
1067
1067
setEnumArg (1 , SPIR::PRIMITIVE_MEMORY_ORDER);
1068
1068
setEnumArg (2 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1069
- } else if (NameRef.startswith (" atom_" )) {
1069
+ } else if (NameRef.starts_with (" atom_" )) {
1070
1070
setArgAttr (0 , SPIR::ATTR_VOLATILE);
1071
- if (NameRef.endswith (" _umax" ) || NameRef.endswith (" _umin" )) {
1071
+ if (NameRef.ends_with (" _umax" ) || NameRef.ends_with (" _umin" )) {
1072
1072
addUnsignedArg (-1 );
1073
1073
// We need to remove u to match OpenCL C built-in function name
1074
1074
EraseSymbol (5 );
1075
1075
}
1076
- } else if (NameRef.startswith (" atomic" )) {
1076
+ } else if (NameRef.starts_with (" atomic" )) {
1077
1077
setArgAttr (0 , SPIR::ATTR_VOLATILE);
1078
1078
if (NameRef.contains (" _umax" ) || NameRef.contains (" _umin" )) {
1079
1079
addUnsignedArg (-1 );
@@ -1085,41 +1085,41 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1085
1085
}
1086
1086
if (NameRef.contains (" store_explicit" ) ||
1087
1087
NameRef.contains (" exchange_explicit" ) ||
1088
- (NameRef.startswith (" atomic_fetch" ) &&
1088
+ (NameRef.starts_with (" atomic_fetch" ) &&
1089
1089
NameRef.contains (" explicit" ))) {
1090
1090
setEnumArg (2 , SPIR::PRIMITIVE_MEMORY_ORDER);
1091
1091
setEnumArg (3 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1092
1092
} else if (NameRef.contains (" load_explicit" ) ||
1093
- (NameRef.startswith (" atomic_flag" ) &&
1093
+ (NameRef.starts_with (" atomic_flag" ) &&
1094
1094
NameRef.contains (" explicit" ))) {
1095
1095
setEnumArg (1 , SPIR::PRIMITIVE_MEMORY_ORDER);
1096
1096
setEnumArg (2 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1097
- } else if (NameRef.endswith (" compare_exchange_strong_explicit" ) ||
1098
- NameRef.endswith (" compare_exchange_weak_explicit" )) {
1097
+ } else if (NameRef.ends_with (" compare_exchange_strong_explicit" ) ||
1098
+ NameRef.ends_with (" compare_exchange_weak_explicit" )) {
1099
1099
setEnumArg (3 , SPIR::PRIMITIVE_MEMORY_ORDER);
1100
1100
setEnumArg (4 , SPIR::PRIMITIVE_MEMORY_ORDER);
1101
1101
setEnumArg (5 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1102
1102
}
1103
1103
// Don't set atomic property to the first argument of 1.2 atomic
1104
1104
// built-ins.
1105
- if (!NameRef.endswith (" xchg" ) && // covers _cmpxchg too
1105
+ if (!NameRef.ends_with (" xchg" ) && // covers _cmpxchg too
1106
1106
(NameRef.contains (" fetch" ) ||
1107
- !(NameRef.endswith (" _add" ) || NameRef.endswith (" _sub" ) ||
1108
- NameRef.endswith (" _inc" ) || NameRef.endswith (" _dec" ) ||
1109
- NameRef.endswith (" _min" ) || NameRef.endswith (" _max" ) ||
1110
- NameRef.endswith (" _and" ) || NameRef.endswith (" _or" ) ||
1111
- NameRef.endswith (" _xor" )))) {
1107
+ !(NameRef.ends_with (" _add" ) || NameRef.ends_with (" _sub" ) ||
1108
+ NameRef.ends_with (" _inc" ) || NameRef.ends_with (" _dec" ) ||
1109
+ NameRef.ends_with (" _min" ) || NameRef.ends_with (" _max" ) ||
1110
+ NameRef.ends_with (" _and" ) || NameRef.ends_with (" _or" ) ||
1111
+ NameRef.ends_with (" _xor" )))) {
1112
1112
addAtomicArg (0 );
1113
1113
}
1114
- } else if (NameRef.startswith (" uconvert_" )) {
1114
+ } else if (NameRef.starts_with (" uconvert_" )) {
1115
1115
addUnsignedArg (0 );
1116
1116
NameRef = NameRef.drop_front (1 );
1117
1117
UnmangledName.erase (0 , 1 );
1118
- } else if (NameRef.startswith (" s_" )) {
1118
+ } else if (NameRef.starts_with (" s_" )) {
1119
1119
if (NameRef.equals (" s_upsample" ))
1120
1120
addUnsignedArg (1 );
1121
1121
NameRef = NameRef.drop_front (2 );
1122
- } else if (NameRef.startswith (" u_" )) {
1122
+ } else if (NameRef.starts_with (" u_" )) {
1123
1123
addUnsignedArg (-1 );
1124
1124
NameRef = NameRef.drop_front (2 );
1125
1125
} else if (NameRef.equals (" fclamp" )) {
@@ -1170,12 +1170,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1170
1170
} else if (NameRef.equals (" enqueue_marker" )) {
1171
1171
setArgAttr (2 , SPIR::ATTR_CONST);
1172
1172
addUnsignedArg (1 );
1173
- } else if (NameRef.startswith (" vload" )) {
1173
+ } else if (NameRef.starts_with (" vload" )) {
1174
1174
addUnsignedArg (0 );
1175
1175
setArgAttr (1 , SPIR::ATTR_CONST);
1176
- } else if (NameRef.startswith (" vstore" )) {
1176
+ } else if (NameRef.starts_with (" vstore" )) {
1177
1177
addUnsignedArg (1 );
1178
- } else if (NameRef.startswith (" ndrange_" )) {
1178
+ } else if (NameRef.starts_with (" ndrange_" )) {
1179
1179
addUnsignedArgs (0 , 2 );
1180
1180
if (NameRef[8 ] == ' 2' || NameRef[8 ] == ' 3' ) {
1181
1181
setArgAttr (0 , SPIR::ATTR_CONST);
@@ -1190,7 +1190,7 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1190
1190
EraseSymbol (NameRef.find (" umin" ));
1191
1191
} else if (NameRef.contains (" broadcast" )) {
1192
1192
addUnsignedArg (-1 );
1193
- } else if (NameRef.startswith (kOCLBuiltinName ::SampledReadImage)) {
1193
+ } else if (NameRef.starts_with (kOCLBuiltinName ::SampledReadImage)) {
1194
1194
if (!NameRef.consume_front (kOCLBuiltinName ::Sampled))
1195
1195
report_fatal_error (llvm::Twine (" Builtin name illformed" ));
1196
1196
addSamplerArg (1 );
@@ -1282,12 +1282,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1282
1282
else if (NameRef.contains (" chroma_mode_cost_function" ))
1283
1283
addUnsignedArg (0 );
1284
1284
}
1285
- } else if (NameRef.startswith (" intel_sub_group_shuffle" )) {
1286
- if (NameRef.endswith (" _down" ) || NameRef.endswith (" _up" ))
1285
+ } else if (NameRef.starts_with (" intel_sub_group_shuffle" )) {
1286
+ if (NameRef.ends_with (" _down" ) || NameRef.ends_with (" _up" ))
1287
1287
addUnsignedArg (2 );
1288
1288
else
1289
1289
addUnsignedArg (1 );
1290
- } else if (NameRef.startswith (" intel_sub_group_block_write" )) {
1290
+ } else if (NameRef.starts_with (" intel_sub_group_block_write" )) {
1291
1291
// distinguish write to image and other data types based on number of
1292
1292
// arguments--images have one more argument.
1293
1293
if (F->getFunctionType ()->getNumParams () == 2 ) {
@@ -1296,16 +1296,16 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1296
1296
} else {
1297
1297
addUnsignedArg (2 );
1298
1298
}
1299
- } else if (NameRef.startswith (" intel_sub_group_block_read" )) {
1299
+ } else if (NameRef.starts_with (" intel_sub_group_block_read" )) {
1300
1300
// distinguish read from image and other data types based on number of
1301
1301
// arguments--images have one more argument.
1302
1302
if (F->getFunctionType ()->getNumParams () == 1 ) {
1303
1303
setArgAttr (0 , SPIR::ATTR_CONST);
1304
1304
addUnsignedArg (0 );
1305
1305
}
1306
- } else if (NameRef.startswith (" intel_sub_group_media_block_write" )) {
1306
+ } else if (NameRef.starts_with (" intel_sub_group_media_block_write" )) {
1307
1307
addUnsignedArg (3 );
1308
- } else if (NameRef.startswith (kOCLBuiltinName ::SubGroupPrefix)) {
1308
+ } else if (NameRef.starts_with (kOCLBuiltinName ::SubGroupPrefix)) {
1309
1309
if (NameRef.contains (" ballot" )) {
1310
1310
if (NameRef.contains (" inverse" ) || NameRef.contains (" bit_count" ) ||
1311
1311
NameRef.contains (" inclusive_scan" ) ||
@@ -1315,14 +1315,14 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1315
1315
else if (NameRef.contains (" bit_extract" )) {
1316
1316
addUnsignedArgs (0 , 1 );
1317
1317
}
1318
- } else if (NameRef.startswith (" sub_group_clustered_rotate" )) {
1318
+ } else if (NameRef.starts_with (" sub_group_clustered_rotate" )) {
1319
1319
addUnsignedArg (2 );
1320
1320
} else if (NameRef.contains (" shuffle" ) || NameRef.contains (" clustered" ))
1321
1321
addUnsignedArg (1 );
1322
- } else if (NameRef.startswith (" bitfield_insert" )) {
1322
+ } else if (NameRef.starts_with (" bitfield_insert" )) {
1323
1323
addUnsignedArgs (2 , 3 );
1324
- } else if (NameRef.startswith (" bitfield_extract_signed" ) ||
1325
- NameRef.startswith (" bitfield_extract_unsigned" )) {
1324
+ } else if (NameRef.starts_with (" bitfield_extract_signed" ) ||
1325
+ NameRef.starts_with (" bitfield_extract_unsigned" )) {
1326
1326
addUnsignedArgs (1 , 2 );
1327
1327
}
1328
1328
0 commit comments