@@ -379,9 +379,8 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
379
379
ConstantInt::get (Ctx, APInt (32 , StringRef (" 0" ), 10 ));
380
380
ZeroIdxList.push_back (zeroInt);
381
381
382
- GetElementPtrInst *BufferIdx =
383
- dyn_cast<GetElementPtrInst>(GetElementPtrInst::Create (
384
- nullptr , pcall, ZeroIdxList, " PrintBuffID" , Brnch));
382
+ GetElementPtrInst *BufferIdx = GetElementPtrInst::Create (
383
+ nullptr , pcall, ZeroIdxList, " PrintBuffID" , Brnch);
385
384
386
385
Type *idPointer = PointerType::get (I32Ty, AMDGPUAS::GLOBAL_ADDRESS);
387
386
Value *id_gep_cast =
@@ -395,8 +394,8 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
395
394
396
395
FourthIdxList.push_back (fourInt); // 1st 4 bytes hold the printf_id
397
396
// the following GEP is the buffer pointer
398
- BufferIdx = cast< GetElementPtrInst>( GetElementPtrInst ::Create (
399
- nullptr , pcall, FourthIdxList, " PrintBuffGep" , Brnch) );
397
+ BufferIdx = GetElementPtrInst::Create (nullptr , pcall, FourthIdxList,
398
+ " PrintBuffGep" , Brnch);
400
399
401
400
Type *Int32Ty = Type::getInt32Ty (Ctx);
402
401
Type *Int64Ty = Type::getInt64Ty (Ctx);
@@ -409,17 +408,15 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
409
408
if (ArgType->isFPOrFPVectorTy () && !isa<VectorType>(ArgType)) {
410
409
Type *IType = (ArgType->isFloatTy ()) ? Int32Ty : Int64Ty;
411
410
if (OpConvSpecifiers[ArgCount - 1 ] == ' f' ) {
412
- ConstantFP *fpCons = dyn_cast<ConstantFP>(Arg);
413
- if (fpCons) {
414
- APFloat Val (fpCons->getValueAPF ());
411
+ if (auto *FpCons = dyn_cast<ConstantFP>(Arg)) {
412
+ APFloat Val (FpCons->getValueAPF ());
415
413
bool Lost = false ;
416
414
Val.convert (APFloat::IEEEsingle (), APFloat::rmNearestTiesToEven,
417
415
&Lost);
418
416
Arg = ConstantFP::get (Ctx, Val);
419
417
IType = Int32Ty;
420
- } else {
421
- FPExtInst *FpExt = dyn_cast<FPExtInst>(Arg);
422
- if (FpExt && FpExt->getType ()->isDoubleTy () &&
418
+ } else if (auto *FpExt = dyn_cast<FPExtInst>(Arg)) {
419
+ if (FpExt->getType ()->isDoubleTy () &&
423
420
FpExt->getOperand (0 )->getType ()->isFloatTy ()) {
424
421
Arg = FpExt->getOperand (0 );
425
422
IType = Int32Ty;
@@ -431,9 +428,8 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
431
428
} else if (ArgType->getTypeID () == Type::PointerTyID) {
432
429
if (shouldPrintAsStr (OpConvSpecifiers[ArgCount - 1 ], ArgType)) {
433
430
const char *S = NonLiteralStr;
434
- if (ConstantExpr *ConstExpr = dyn_cast<ConstantExpr>(Arg)) {
435
- GlobalVariable *GV =
436
- dyn_cast<GlobalVariable>(ConstExpr->getOperand (0 ));
431
+ if (auto *ConstExpr = dyn_cast<ConstantExpr>(Arg)) {
432
+ auto *GV = dyn_cast<GlobalVariable>(ConstExpr->getOperand (0 ));
437
433
if (GV && GV->hasInitializer ()) {
438
434
Constant *Init = GV->getInitializer ();
439
435
ConstantDataArray *CA = dyn_cast<ConstantDataArray>(Init);
@@ -491,27 +487,27 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
491
487
switch (EleSize) {
492
488
default :
493
489
EleCount = TotalSize / 64 ;
494
- IType = dyn_cast< Type>( Type ::getInt64Ty (ArgType->getContext () ));
490
+ IType = Type::getInt64Ty (ArgType->getContext ());
495
491
break ;
496
492
case 8 :
497
493
if (EleCount >= 8 ) {
498
494
EleCount = TotalSize / 64 ;
499
- IType = dyn_cast< Type>( Type ::getInt64Ty (ArgType->getContext () ));
495
+ IType = Type::getInt64Ty (ArgType->getContext ());
500
496
} else if (EleCount >= 3 ) {
501
497
EleCount = 1 ;
502
- IType = dyn_cast< Type>( Type ::getInt32Ty (ArgType->getContext () ));
498
+ IType = Type::getInt32Ty (ArgType->getContext ());
503
499
} else {
504
500
EleCount = 1 ;
505
- IType = dyn_cast< Type>( Type ::getInt16Ty (ArgType->getContext () ));
501
+ IType = Type::getInt16Ty (ArgType->getContext ());
506
502
}
507
503
break ;
508
504
case 16 :
509
505
if (EleCount >= 3 ) {
510
506
EleCount = TotalSize / 64 ;
511
- IType = dyn_cast< Type>( Type ::getInt64Ty (ArgType->getContext () ));
507
+ IType = Type::getInt64Ty (ArgType->getContext ());
512
508
} else {
513
509
EleCount = 1 ;
514
- IType = dyn_cast< Type>( Type ::getInt32Ty (ArgType->getContext () ));
510
+ IType = Type::getInt32Ty (ArgType->getContext ());
515
511
}
516
512
break ;
517
513
}
@@ -539,8 +535,8 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
539
535
(void )StBuff;
540
536
if (I + 1 == E && ArgCount + 1 == CI->getNumArgOperands ())
541
537
break ;
542
- BufferIdx = dyn_cast< GetElementPtrInst>( GetElementPtrInst ::Create (
543
- nullptr , BufferIdx, BuffOffset, " PrintBuffNextPtr" , Brnch) );
538
+ BufferIdx = GetElementPtrInst::Create (nullptr , BufferIdx, BuffOffset,
539
+ " PrintBuffNextPtr" , Brnch);
544
540
LLVM_DEBUG (dbgs () << " inserting gep to the printf buffer:\n "
545
541
<< *BufferIdx << ' \n ' );
546
542
}
0 commit comments