@@ -668,7 +668,7 @@ AtomicWorkItemFenceLiterals getAtomicWorkItemFenceLiterals(CallInst *CI) {
668
668
}
669
669
670
670
size_t getAtomicBuiltinNumMemoryOrderArgs (StringRef Name) {
671
- if (Name.startswith (" atomic_compare_exchange" ))
671
+ if (Name.starts_with (" atomic_compare_exchange" ))
672
672
return 2 ;
673
673
return 1 ;
674
674
}
@@ -683,8 +683,8 @@ size_t getSPIRVAtomicBuiltinNumMemoryOrderArgs(Op OC) {
683
683
// max]_explicit functions declared in clang headers should be translated
684
684
// to corresponding FP-typed Atomic Instructions
685
685
bool isComputeAtomicOCLBuiltin (StringRef DemangledName) {
686
- if (!DemangledName.startswith (kOCLBuiltinName ::AtomicPrefix) &&
687
- !DemangledName.startswith (kOCLBuiltinName ::AtomPrefix))
686
+ if (!DemangledName.starts_with (kOCLBuiltinName ::AtomicPrefix) &&
687
+ !DemangledName.starts_with (kOCLBuiltinName ::AtomPrefix))
688
688
return false ;
689
689
690
690
return llvm::StringSwitch<bool >(DemangledName)
@@ -1019,12 +1019,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1019
1019
NameRef = StringRef (TempStorage);
1020
1020
};
1021
1021
1022
- if (NameRef.startswith (" async_work_group" )) {
1022
+ if (NameRef.starts_with (" async_work_group" )) {
1023
1023
addUnsignedArg (-1 );
1024
1024
setArgAttr (1 , SPIR::ATTR_CONST);
1025
- } else if (NameRef.startswith (" printf" ))
1025
+ } else if (NameRef.starts_with (" printf" ))
1026
1026
setVarArg (1 );
1027
- else if (NameRef.startswith (" write_imageui" ))
1027
+ else if (NameRef.starts_with (" write_imageui" ))
1028
1028
addUnsignedArg (2 );
1029
1029
else if (NameRef.equals (" prefetch" )) {
1030
1030
addUnsignedArg (1 );
@@ -1037,13 +1037,13 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1037
1037
FunctionType *InvokeTy = getBlockInvokeTy (F, BlockArgIdx);
1038
1038
if (InvokeTy->getNumParams () > 1 )
1039
1039
setLocalArgBlock (BlockArgIdx);
1040
- } else if (NameRef.startswith (" __enqueue_kernel" )) {
1040
+ } else if (NameRef.starts_with (" __enqueue_kernel" )) {
1041
1041
// clang doesn't mangle enqueue_kernel builtins
1042
1042
setAsDontMangle ();
1043
- } else if (NameRef.startswith (" get_" ) || NameRef.equals (" nan" ) ||
1044
- NameRef.equals (" mem_fence" ) || NameRef.startswith (" shuffle" )) {
1043
+ } else if (NameRef.starts_with (" get_" ) || NameRef.equals (" nan" ) ||
1044
+ NameRef.equals (" mem_fence" ) || NameRef.starts_with (" shuffle" )) {
1045
1045
addUnsignedArg (-1 );
1046
- if (NameRef.startswith (kOCLBuiltinName ::GetFence)) {
1046
+ if (NameRef.starts_with (kOCLBuiltinName ::GetFence)) {
1047
1047
setArgAttr (0 , SPIR::ATTR_CONST);
1048
1048
addVoidPtrArg (0 );
1049
1049
}
@@ -1054,18 +1054,18 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1054
1054
NameRef.equals (" intel_work_group_barrier_arrive" ) ||
1055
1055
NameRef.equals (" intel_work_group_barrier_wait" ))
1056
1056
setEnumArg (1 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1057
- } else if (NameRef.startswith (" atomic_work_item_fence" )) {
1057
+ } else if (NameRef.starts_with (" atomic_work_item_fence" )) {
1058
1058
addUnsignedArg (0 );
1059
1059
setEnumArg (1 , SPIR::PRIMITIVE_MEMORY_ORDER);
1060
1060
setEnumArg (2 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1061
- } else if (NameRef.startswith (" atom_" )) {
1061
+ } else if (NameRef.starts_with (" atom_" )) {
1062
1062
setArgAttr (0 , SPIR::ATTR_VOLATILE);
1063
- if (NameRef.endswith (" _umax" ) || NameRef.endswith (" _umin" )) {
1063
+ if (NameRef.ends_with (" _umax" ) || NameRef.ends_with (" _umin" )) {
1064
1064
addUnsignedArg (-1 );
1065
1065
// We need to remove u to match OpenCL C built-in function name
1066
1066
EraseSymbol (5 );
1067
1067
}
1068
- } else if (NameRef.startswith (" atomic" )) {
1068
+ } else if (NameRef.starts_with (" atomic" )) {
1069
1069
setArgAttr (0 , SPIR::ATTR_VOLATILE);
1070
1070
if (NameRef.contains (" _umax" ) || NameRef.contains (" _umin" )) {
1071
1071
addUnsignedArg (-1 );
@@ -1077,41 +1077,41 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1077
1077
}
1078
1078
if (NameRef.contains (" store_explicit" ) ||
1079
1079
NameRef.contains (" exchange_explicit" ) ||
1080
- (NameRef.startswith (" atomic_fetch" ) &&
1080
+ (NameRef.starts_with (" atomic_fetch" ) &&
1081
1081
NameRef.contains (" explicit" ))) {
1082
1082
setEnumArg (2 , SPIR::PRIMITIVE_MEMORY_ORDER);
1083
1083
setEnumArg (3 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1084
1084
} else if (NameRef.contains (" load_explicit" ) ||
1085
- (NameRef.startswith (" atomic_flag" ) &&
1085
+ (NameRef.starts_with (" atomic_flag" ) &&
1086
1086
NameRef.contains (" explicit" ))) {
1087
1087
setEnumArg (1 , SPIR::PRIMITIVE_MEMORY_ORDER);
1088
1088
setEnumArg (2 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1089
- } else if (NameRef.endswith (" compare_exchange_strong_explicit" ) ||
1090
- NameRef.endswith (" compare_exchange_weak_explicit" )) {
1089
+ } else if (NameRef.ends_with (" compare_exchange_strong_explicit" ) ||
1090
+ NameRef.ends_with (" compare_exchange_weak_explicit" )) {
1091
1091
setEnumArg (3 , SPIR::PRIMITIVE_MEMORY_ORDER);
1092
1092
setEnumArg (4 , SPIR::PRIMITIVE_MEMORY_ORDER);
1093
1093
setEnumArg (5 , SPIR::PRIMITIVE_MEMORY_SCOPE);
1094
1094
}
1095
1095
// Don't set atomic property to the first argument of 1.2 atomic
1096
1096
// built-ins.
1097
- if (!NameRef.endswith (" xchg" ) && // covers _cmpxchg too
1097
+ if (!NameRef.ends_with (" xchg" ) && // covers _cmpxchg too
1098
1098
(NameRef.contains (" fetch" ) ||
1099
- !(NameRef.endswith (" _add" ) || NameRef.endswith (" _sub" ) ||
1100
- NameRef.endswith (" _inc" ) || NameRef.endswith (" _dec" ) ||
1101
- NameRef.endswith (" _min" ) || NameRef.endswith (" _max" ) ||
1102
- NameRef.endswith (" _and" ) || NameRef.endswith (" _or" ) ||
1103
- NameRef.endswith (" _xor" )))) {
1099
+ !(NameRef.ends_with (" _add" ) || NameRef.ends_with (" _sub" ) ||
1100
+ NameRef.ends_with (" _inc" ) || NameRef.ends_with (" _dec" ) ||
1101
+ NameRef.ends_with (" _min" ) || NameRef.ends_with (" _max" ) ||
1102
+ NameRef.ends_with (" _and" ) || NameRef.ends_with (" _or" ) ||
1103
+ NameRef.ends_with (" _xor" )))) {
1104
1104
addAtomicArg (0 );
1105
1105
}
1106
- } else if (NameRef.startswith (" uconvert_" )) {
1106
+ } else if (NameRef.starts_with (" uconvert_" )) {
1107
1107
addUnsignedArg (0 );
1108
1108
NameRef = NameRef.drop_front (1 );
1109
1109
UnmangledName.erase (0 , 1 );
1110
- } else if (NameRef.startswith (" s_" )) {
1110
+ } else if (NameRef.starts_with (" s_" )) {
1111
1111
if (NameRef.equals (" s_upsample" ))
1112
1112
addUnsignedArg (1 );
1113
1113
NameRef = NameRef.drop_front (2 );
1114
- } else if (NameRef.startswith (" u_" )) {
1114
+ } else if (NameRef.starts_with (" u_" )) {
1115
1115
addUnsignedArg (-1 );
1116
1116
NameRef = NameRef.drop_front (2 );
1117
1117
} else if (NameRef.equals (" fclamp" )) {
@@ -1162,12 +1162,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1162
1162
} else if (NameRef.equals (" enqueue_marker" )) {
1163
1163
setArgAttr (2 , SPIR::ATTR_CONST);
1164
1164
addUnsignedArg (1 );
1165
- } else if (NameRef.startswith (" vload" )) {
1165
+ } else if (NameRef.starts_with (" vload" )) {
1166
1166
addUnsignedArg (0 );
1167
1167
setArgAttr (1 , SPIR::ATTR_CONST);
1168
- } else if (NameRef.startswith (" vstore" )) {
1168
+ } else if (NameRef.starts_with (" vstore" )) {
1169
1169
addUnsignedArg (1 );
1170
- } else if (NameRef.startswith (" ndrange_" )) {
1170
+ } else if (NameRef.starts_with (" ndrange_" )) {
1171
1171
addUnsignedArgs (0 , 2 );
1172
1172
if (NameRef[8 ] == ' 2' || NameRef[8 ] == ' 3' ) {
1173
1173
setArgAttr (0 , SPIR::ATTR_CONST);
@@ -1182,7 +1182,7 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1182
1182
EraseSymbol (NameRef.find (" umin" ));
1183
1183
} else if (NameRef.contains (" broadcast" )) {
1184
1184
addUnsignedArg (-1 );
1185
- } else if (NameRef.startswith (kOCLBuiltinName ::SampledReadImage)) {
1185
+ } else if (NameRef.starts_with (kOCLBuiltinName ::SampledReadImage)) {
1186
1186
if (!NameRef.consume_front (kOCLBuiltinName ::Sampled))
1187
1187
report_fatal_error (llvm::Twine (" Builtin name illformed" ));
1188
1188
addSamplerArg (1 );
@@ -1274,12 +1274,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1274
1274
else if (NameRef.contains (" chroma_mode_cost_function" ))
1275
1275
addUnsignedArg (0 );
1276
1276
}
1277
- } else if (NameRef.startswith (" intel_sub_group_shuffle" )) {
1278
- if (NameRef.endswith (" _down" ) || NameRef.endswith (" _up" ))
1277
+ } else if (NameRef.starts_with (" intel_sub_group_shuffle" )) {
1278
+ if (NameRef.ends_with (" _down" ) || NameRef.ends_with (" _up" ))
1279
1279
addUnsignedArg (2 );
1280
1280
else
1281
1281
addUnsignedArg (1 );
1282
- } else if (NameRef.startswith (" intel_sub_group_block_write" )) {
1282
+ } else if (NameRef.starts_with (" intel_sub_group_block_write" )) {
1283
1283
// distinguish write to image and other data types based on number of
1284
1284
// arguments--images have one more argument.
1285
1285
if (F->getFunctionType ()->getNumParams () == 2 ) {
@@ -1288,16 +1288,16 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1288
1288
} else {
1289
1289
addUnsignedArg (2 );
1290
1290
}
1291
- } else if (NameRef.startswith (" intel_sub_group_block_read" )) {
1291
+ } else if (NameRef.starts_with (" intel_sub_group_block_read" )) {
1292
1292
// distinguish read from image and other data types based on number of
1293
1293
// arguments--images have one more argument.
1294
1294
if (F->getFunctionType ()->getNumParams () == 1 ) {
1295
1295
setArgAttr (0 , SPIR::ATTR_CONST);
1296
1296
addUnsignedArg (0 );
1297
1297
}
1298
- } else if (NameRef.startswith (" intel_sub_group_media_block_write" )) {
1298
+ } else if (NameRef.starts_with (" intel_sub_group_media_block_write" )) {
1299
1299
addUnsignedArg (3 );
1300
- } else if (NameRef.startswith (kOCLBuiltinName ::SubGroupPrefix)) {
1300
+ } else if (NameRef.starts_with (kOCLBuiltinName ::SubGroupPrefix)) {
1301
1301
if (NameRef.contains (" ballot" )) {
1302
1302
if (NameRef.contains (" inverse" ) || NameRef.contains (" bit_count" ) ||
1303
1303
NameRef.contains (" inclusive_scan" ) ||
@@ -1307,14 +1307,14 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
1307
1307
else if (NameRef.contains (" bit_extract" )) {
1308
1308
addUnsignedArgs (0 , 1 );
1309
1309
}
1310
- } else if (NameRef.startswith (" sub_group_clustered_rotate" )) {
1310
+ } else if (NameRef.starts_with (" sub_group_clustered_rotate" )) {
1311
1311
addUnsignedArg (2 );
1312
1312
} else if (NameRef.contains (" shuffle" ) || NameRef.contains (" clustered" ))
1313
1313
addUnsignedArg (1 );
1314
- } else if (NameRef.startswith (" bitfield_insert" )) {
1314
+ } else if (NameRef.starts_with (" bitfield_insert" )) {
1315
1315
addUnsignedArgs (2 , 3 );
1316
- } else if (NameRef.startswith (" bitfield_extract_signed" ) ||
1317
- NameRef.startswith (" bitfield_extract_unsigned" )) {
1316
+ } else if (NameRef.starts_with (" bitfield_extract_signed" ) ||
1317
+ NameRef.starts_with (" bitfield_extract_unsigned" )) {
1318
1318
addUnsignedArgs (1 , 2 );
1319
1319
}
1320
1320
0 commit comments