@@ -90,8 +90,8 @@ static Type *getBlockStructType(Value *Parameter) {
90
90
// / for a demangled function name, or 0 if the function does not return an
91
91
// / integer type (e.g. read_imagef).
92
92
static unsigned getImageSignZeroExt (StringRef DemangledName) {
93
- bool IsSigned = !DemangledName.endswith (" ui" ) && DemangledName.back () == ' i' ;
94
- bool IsUnsigned = DemangledName.endswith (" ui" );
93
+ bool IsSigned = !DemangledName.ends_with (" ui" ) && DemangledName.back () == ' i' ;
94
+ bool IsUnsigned = DemangledName.ends_with (" ui" );
95
95
96
96
if (IsSigned)
97
97
return ImageOperandsMask::ImageOperandsSignExtendMask;
@@ -327,8 +327,8 @@ void OCLToSPIRVBase::visitCallInst(CallInst &CI) {
327
327
}
328
328
if (DemangledName == kOCLBuiltinName ::Dot ||
329
329
DemangledName == kOCLBuiltinName ::DotAccSat ||
330
- DemangledName.startswith (kOCLBuiltinName ::Dot4x8PackedPrefix) ||
331
- DemangledName.startswith (kOCLBuiltinName ::DotAccSat4x8PackedPrefix)) {
330
+ DemangledName.starts_with (kOCLBuiltinName ::Dot4x8PackedPrefix) ||
331
+ DemangledName.starts_with (kOCLBuiltinName ::DotAccSat4x8PackedPrefix)) {
332
332
if (CI.getOperand (0 )->getType ()->isVectorTy ()) {
333
333
auto *VT = (VectorType *)(CI.getOperand (0 )->getType ());
334
334
if (!isa<llvm::IntegerType>(VT->getElementType ())) {
@@ -485,11 +485,12 @@ CallInst *OCLToSPIRVBase::visitCallAtomicCmpXchg(CallInst *CI) {
485
485
Mutator.mapArg (1 , [=](IRBuilder<> &Builder, Value *V) {
486
486
return Builder.CreateLoad (MemTy, V, " exp" );
487
487
});
488
- Mutator.changeReturnType (MemTy, [&](IRBuilder<> &Builder, CallInst *NCI) {
489
- NewCI = NCI;
490
- Builder.CreateStore (NCI, Expected);
491
- return Builder.CreateICmpEQ (NCI, NCI->getArgOperand (1 ));
492
- });
488
+ Mutator.changeReturnType (
489
+ MemTy, [Expected, &NewCI](IRBuilder<> &Builder, CallInst *NCI) {
490
+ NewCI = NCI;
491
+ Builder.CreateStore (NCI, Expected);
492
+ return Builder.CreateICmpEQ (NCI, NCI->getArgOperand (1 ));
493
+ });
493
494
}
494
495
return NewCI;
495
496
}
@@ -553,9 +554,9 @@ void OCLToSPIRVBase::transMemoryBarrier(CallInst *CI,
553
554
void OCLToSPIRVBase::visitCallAtomicLegacy (CallInst *CI, StringRef MangledName,
554
555
StringRef DemangledName) {
555
556
StringRef Stem = DemangledName;
556
- if (Stem.startswith (" atom_" ))
557
+ if (Stem.starts_with (" atom_" ))
557
558
Stem = Stem.drop_front (strlen (" atom_" ));
558
- else if (Stem.startswith (" atomic_" ))
559
+ else if (Stem.starts_with (" atomic_" ))
559
560
Stem = Stem.drop_front (strlen (" atomic_" ));
560
561
else
561
562
return ;
@@ -585,7 +586,7 @@ void OCLToSPIRVBase::visitCallAtomicLegacy(CallInst *CI, StringRef MangledName,
585
586
Info.UniqName = " atomic_" + Prefix + Sign + Stem.str () + Postfix;
586
587
std::vector<int > PostOps;
587
588
PostOps.push_back (OCLLegacyAtomicMemOrder);
588
- if (Stem.startswith (" compare_exchange" ))
589
+ if (Stem.starts_with (" compare_exchange" ))
589
590
PostOps.push_back (OCLLegacyAtomicMemOrder);
590
591
PostOps.push_back (OCLLegacyAtomicMemScope);
591
592
@@ -600,24 +601,24 @@ void OCLToSPIRVBase::visitCallAtomicLegacy(CallInst *CI, StringRef MangledName,
600
601
void OCLToSPIRVBase::visitCallAtomicCpp11 (CallInst *CI, StringRef MangledName,
601
602
StringRef DemangledName) {
602
603
StringRef Stem = DemangledName;
603
- if (Stem.startswith (" atomic_" ))
604
+ if (Stem.starts_with (" atomic_" ))
604
605
Stem = Stem.drop_front (strlen (" atomic_" ));
605
606
else
606
607
return ;
607
608
608
609
std::string NewStem (Stem);
609
610
std::vector<int > PostOps;
610
- if (Stem.startswith (" store" ) || Stem.startswith (" load" ) ||
611
- Stem.startswith (" exchange" ) || Stem.startswith (" compare_exchange" ) ||
612
- Stem.startswith (" fetch" ) || Stem.startswith (" flag" )) {
613
- if ((Stem.startswith (" fetch_min" ) || Stem.startswith (" fetch_max" )) &&
611
+ if (Stem.starts_with (" store" ) || Stem.starts_with (" load" ) ||
612
+ Stem.starts_with (" exchange" ) || Stem.starts_with (" compare_exchange" ) ||
613
+ Stem.starts_with (" fetch" ) || Stem.starts_with (" flag" )) {
614
+ if ((Stem.starts_with (" fetch_min" ) || Stem.starts_with (" fetch_max" )) &&
614
615
containsUnsignedAtomicType (MangledName))
615
616
NewStem.insert (NewStem.begin () + strlen (" fetch_" ), ' u' );
616
617
617
- if (!Stem.endswith (" _explicit" )) {
618
+ if (!Stem.ends_with (" _explicit" )) {
618
619
NewStem = NewStem + " _explicit" ;
619
620
PostOps.push_back (OCLMO_seq_cst);
620
- if (Stem.startswith (" compare_exchange" ))
621
+ if (Stem.starts_with (" compare_exchange" ))
621
622
PostOps.push_back (OCLMO_seq_cst);
622
623
PostOps.push_back (OCLMS_device);
623
624
} else {
@@ -792,7 +793,7 @@ void OCLToSPIRVBase::visitCallGroupBuiltin(CallInst *CI,
792
793
FuncName = FuncName.drop_front (strlen (kSPIRVName ::GroupPrefix));
793
794
SPIRSPIRVGroupOperationMap::foreachConditional (
794
795
[&](const std::string &S, SPIRVGroupOperationKind G) {
795
- if (!FuncName.startswith (S))
796
+ if (!FuncName.starts_with (S))
796
797
return true ; // continue
797
798
PreOps.push_back (G);
798
799
StringRef Op =
@@ -886,7 +887,7 @@ void OCLToSPIRVBase::transBuiltin(CallInst *CI, OCLBuiltinTransInfo &Info) {
886
887
Op OC = OpNop;
887
888
unsigned ExtOp = ~0U ;
888
889
SPIRVBuiltinVariableKind BVKind = BuiltInMax;
889
- if (StringRef (Info.UniqName ).startswith (kSPIRVName ::Prefix))
890
+ if (StringRef (Info.UniqName ).starts_with (kSPIRVName ::Prefix))
890
891
return ;
891
892
if (OCLSPIRVBuiltinMap::find (Info.UniqName , &OC)) {
892
893
if (OC == OpImageRead) {
@@ -912,16 +913,16 @@ void OCLToSPIRVBase::transBuiltin(CallInst *CI, OCLBuiltinTransInfo &Info) {
912
913
Info.UniqName = getSPIRVFuncName (BVKind);
913
914
} else
914
915
return ;
915
- auto Mutator = mutateCallInst (CI, Info.UniqName + Info.Postfix );
916
+ BuiltinCallMutator Mutator = mutateCallInst (CI, Info.UniqName + Info.Postfix );
916
917
Info.PostProc (Mutator);
917
918
if (Info.RetTy ) {
918
919
Type *OldRetTy = CI->getType ();
919
920
Mutator.changeReturnType (
920
- Info.RetTy , [& ](IRBuilder<> &Builder, CallInst *NewCI) {
921
- if (Info.RetTy ->isIntegerTy () && OldRetTy->isIntegerTy ())
921
+ Info.RetTy , [OldRetTy, &Info ](IRBuilder<> &Builder, CallInst *NewCI) {
922
+ if (Info.RetTy ->isIntegerTy () && OldRetTy->isIntegerTy ()) {
922
923
return Builder.CreateIntCast (NewCI, OldRetTy, Info.IsRetSigned );
923
- else
924
- return Builder.CreatePointerBitCastOrAddrSpaceCast (NewCI, OldRetTy);
924
+ }
925
+ return Builder.CreatePointerBitCastOrAddrSpaceCast (NewCI, OldRetTy);
925
926
});
926
927
}
927
928
}
@@ -1221,7 +1222,7 @@ void OCLToSPIRVBase::visitCallDot(CallInst *CI, StringRef MangledName,
1221
1222
// dot(short2, ushort2) _Z3dotDv2_sDv2_t
1222
1223
// dot(ushort2, short2) _Z3dotDv2_tDv2_s
1223
1224
// dot(ushort2, ushort2) _Z3dotDv2_tS_
1224
- assert (MangledName.startswith (" _Z3dotDv" ));
1225
+ assert (MangledName.starts_with (" _Z3dotDv" ));
1225
1226
if (MangledName[MangledName.size () - 1 ] == ' _' ) {
1226
1227
IsFirstSigned = ((MangledName[MangledName.size () - 3 ] == ' c' ) ||
1227
1228
(MangledName[MangledName.size () - 3 ] == ' s' ));
@@ -1242,7 +1243,7 @@ void OCLToSPIRVBase::visitCallDot(CallInst *CI, StringRef MangledName,
1242
1243
// dot_acc_sat(short2, ushort2, int) _Z11dot_acc_satDv4_sDv4_ti
1243
1244
// dot_acc_sat(ushort2, short2, int) _Z11dot_acc_satDv4_tDv4_si
1244
1245
// dot_acc_sat(ushort2, ushort2, uint) _Z11dot_acc_satDv4_tS_j
1245
- assert (MangledName.startswith (" _Z11dot_acc_satDv" ));
1246
+ assert (MangledName.starts_with (" _Z11dot_acc_satDv" ));
1246
1247
IsFirstSigned = ((MangledName[19 ] == ' c' ) || (MangledName[19 ] == ' s' ));
1247
1248
IsSecondSigned = (MangledName[20 ] == ' S'
1248
1249
? IsFirstSigned
@@ -1264,10 +1265,10 @@ void OCLToSPIRVBase::visitCallDot(CallInst *CI, StringRef MangledName,
1264
1265
// _Z28dot_acc_sat_4x8packed_us_intjji
1265
1266
// dot_acc_sat_4x8packed_uu_uint(uint, uint, uint)
1266
1267
// _Z29dot_acc_sat_4x8packed_uu_uintjjj
1267
- assert (MangledName.startswith (" _Z20dot_4x8packed" ) ||
1268
- MangledName.startswith (" _Z21dot_4x8packed" ) ||
1269
- MangledName.startswith (" _Z28dot_acc_sat_4x8packed" ) ||
1270
- MangledName.startswith (" _Z29dot_acc_sat_4x8packed" ));
1268
+ assert (MangledName.starts_with (" _Z20dot_4x8packed" ) ||
1269
+ MangledName.starts_with (" _Z21dot_4x8packed" ) ||
1270
+ MangledName.starts_with (" _Z28dot_acc_sat_4x8packed" ) ||
1271
+ MangledName.starts_with (" _Z29dot_acc_sat_4x8packed" ));
1271
1272
size_t SignIndex = IsAccSat
1272
1273
? strlen (kOCLBuiltinName ::DotAccSat4x8PackedPrefix)
1273
1274
: strlen (kOCLBuiltinName ::Dot4x8PackedPrefix);
@@ -1581,7 +1582,7 @@ static const char *getSubgroupAVCIntelTyKind(StringRef MangledName) {
1581
1582
// We're looking for the type name of the last parameter, which will be at the
1582
1583
// very end of the mangled name. Since we only care about the ending of the
1583
1584
// name, we don't need to be any more clever than this.
1584
- return MangledName.endswith (" _payload_t" ) ? " payload" : " result" ;
1585
+ return MangledName.ends_with (" _payload_t" ) ? " payload" : " result" ;
1585
1586
}
1586
1587
1587
1588
static Type *getSubgroupAVCIntelMCEType (Module *M, std::string &TName) {
0 commit comments