@@ -44,7 +44,8 @@ class TargetTransformInfoImplBase {
44
44
const DataLayout &getDataLayout () const { return DL; }
45
45
46
46
int getGEPCost (Type *PointeeType, const Value *Ptr ,
47
- ArrayRef<const Value *> Operands) {
47
+ ArrayRef<const Value *> Operands,
48
+ TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) {
48
49
// In the basic model, we just assume that all-constant GEPs will be folded
49
50
// into their uses via addressing modes.
50
51
for (unsigned Idx = 0 , Size = Operands.size (); Idx != Size ; ++Idx)
@@ -285,15 +286,19 @@ class TargetTransformInfoImplBase {
285
286
return 0 ;
286
287
}
287
288
288
- unsigned getIntImmCost (const APInt &Imm, Type *Ty) { return TTI::TCC_Basic; }
289
+ unsigned getIntImmCost (const APInt &Imm, Type *Ty,
290
+ TTI::TargetCostKind CostKind) {
291
+ return TTI::TCC_Basic;
292
+ }
289
293
290
294
unsigned getIntImmCostInst (unsigned Opcode, unsigned Idx, const APInt &Imm,
291
- Type *Ty) {
295
+ Type *Ty, TTI::TargetCostKind CostKind ) {
292
296
return TTI::TCC_Free;
293
297
}
294
298
295
299
unsigned getIntImmCostIntrin (Intrinsic::ID IID, unsigned Idx,
296
- const APInt &Imm, Type *Ty) {
300
+ const APInt &Imm, Type *Ty,
301
+ TTI::TargetCostKind CostKind) {
297
302
return TTI::TCC_Free;
298
303
}
299
304
@@ -366,6 +371,7 @@ class TargetTransformInfoImplBase {
366
371
unsigned getMaxInterleaveFactor (unsigned VF) { return 1 ; }
367
372
368
373
unsigned getArithmeticInstrCost (unsigned Opcode, Type *Ty,
374
+ TTI::TargetCostKind CostKind,
369
375
TTI::OperandValueKind Opd1Info,
370
376
TTI::OperandValueKind Opd2Info,
371
377
TTI::OperandValueProperties Opd1PropInfo,
@@ -381,6 +387,7 @@ class TargetTransformInfoImplBase {
381
387
}
382
388
383
389
unsigned getCastInstrCost (unsigned Opcode, Type *Dst, Type *Src,
390
+ TTI::TargetCostKind CostKind,
384
391
const Instruction *I) {
385
392
switch (Opcode) {
386
393
default :
@@ -419,10 +426,12 @@ class TargetTransformInfoImplBase {
419
426
return 1 ;
420
427
}
421
428
422
- unsigned getCFInstrCost (unsigned Opcode) { return 1 ; }
429
+ unsigned getCFInstrCost (unsigned Opcode,
430
+ TTI::TargetCostKind CostKind) { return 1 ; }
423
431
424
432
unsigned getCmpSelInstrCost (unsigned Opcode, Type *ValTy, Type *CondTy,
425
- const Instruction *I) {
433
+ TTI::TargetCostKind CostKind,
434
+ const Instruction *I) const {
426
435
return 1 ;
427
436
}
428
437
@@ -431,43 +440,50 @@ class TargetTransformInfoImplBase {
431
440
}
432
441
433
442
unsigned getMemoryOpCost (unsigned Opcode, Type *Src, MaybeAlign Alignment,
434
- unsigned AddressSpace, const Instruction *I) {
443
+ unsigned AddressSpace, TTI::TargetCostKind CostKind,
444
+ const Instruction *I) const {
435
445
return 1 ;
436
446
}
437
447
438
448
unsigned getMaskedMemoryOpCost (unsigned Opcode, Type *Src, unsigned Alignment,
439
- unsigned AddressSpace) {
449
+ unsigned AddressSpace,
450
+ TTI::TargetCostKind CostKind) {
440
451
return 1 ;
441
452
}
442
453
443
- unsigned getGatherScatterOpCost (unsigned Opcode, Type *DataTy, Value *Ptr ,
444
- bool VariableMask, unsigned Alignment,
445
- const Instruction *I = nullptr ) {
454
+ unsigned getGatherScatterOpCost (
455
+ unsigned Opcode, Type *DataTy, Value *Ptr , bool VariableMask,
456
+ unsigned Alignment, TTI::TargetCostKind CostKind,
457
+ const Instruction *I = nullptr ) {
446
458
return 1 ;
447
459
}
448
460
449
461
unsigned getInterleavedMemoryOpCost (unsigned Opcode, Type *VecTy,
450
462
unsigned Factor,
451
463
ArrayRef<unsigned > Indices,
452
464
unsigned Alignment, unsigned AddressSpace,
453
- bool UseMaskForCond = false ,
454
- bool UseMaskForGaps = false ) {
465
+ TTI::TargetCostKind CostKind,
466
+ bool UseMaskForCond,
467
+ bool UseMaskForGaps) {
455
468
return 1 ;
456
469
}
457
470
458
471
unsigned getIntrinsicInstrCost (Intrinsic::ID ID, Type *RetTy,
459
472
ArrayRef<Type *> Tys, FastMathFlags FMF,
460
473
unsigned ScalarizationCostPassed,
474
+ TTI::TargetCostKind CostKind,
461
475
const Instruction *I) {
462
476
return 1 ;
463
477
}
464
478
unsigned getIntrinsicInstrCost (Intrinsic::ID ID, Type *RetTy,
465
479
ArrayRef<Value *> Args, FastMathFlags FMF,
466
- unsigned VF, const Instruction *I) {
480
+ unsigned VF, TTI::TargetCostKind CostKind,
481
+ const Instruction *I) {
467
482
return 1 ;
468
483
}
469
484
470
- unsigned getCallInstrCost (Function *F, Type *RetTy, ArrayRef<Type *> Tys) {
485
+ unsigned getCallInstrCost (Function *F, Type *RetTy, ArrayRef<Type *> Tys,
486
+ TTI::TargetCostKind CostKind) {
471
487
return 1 ;
472
488
}
473
489
@@ -478,9 +494,11 @@ class TargetTransformInfoImplBase {
478
494
return 0 ;
479
495
}
480
496
481
- unsigned getArithmeticReductionCost (unsigned , VectorType *, bool ) { return 1 ; }
497
+ unsigned getArithmeticReductionCost (unsigned , VectorType *, bool ,
498
+ TTI::TargetCostKind) { return 1 ; }
482
499
483
- unsigned getMinMaxReductionCost (VectorType *, VectorType *, bool , bool ) { return 1 ; }
500
+ unsigned getMinMaxReductionCost (VectorType *, VectorType *, bool , bool ,
501
+ TTI::TargetCostKind) { return 1 ; }
484
502
485
503
unsigned getCostOfKeepingLiveOverCall (ArrayRef<Type *> Tys) { return 0 ; }
486
504
@@ -680,7 +698,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
680
698
using BaseT::getGEPCost;
681
699
682
700
int getGEPCost (Type *PointeeType, const Value *Ptr ,
683
- ArrayRef<const Value *> Operands) {
701
+ ArrayRef<const Value *> Operands,
702
+ TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) {
684
703
assert (PointeeType && Ptr && " can't get GEPCost of nullptr" );
685
704
// TODO: will remove this when pointers have an opaque type.
686
705
assert (Ptr ->getType ()->getScalarType ()->getPointerElementType () ==
@@ -738,7 +757,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
738
757
}
739
758
740
759
unsigned getIntrinsicCost (Intrinsic::ID IID, Type *RetTy,
741
- ArrayRef<Type *> ParamTys, const User *U) {
760
+ ArrayRef<Type *> ParamTys, const User *U,
761
+ TTI::TargetCostKind TCK_SizeAndLatency) {
742
762
switch (IID) {
743
763
default :
744
764
// Intrinsics rarely (if ever) have normal argument setup constraints.
@@ -782,19 +802,21 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
782
802
}
783
803
784
804
unsigned getIntrinsicCost (Intrinsic::ID IID, Type *RetTy,
785
- ArrayRef<const Value *> Arguments, const User *U) {
805
+ ArrayRef<const Value *> Arguments, const User *U,
806
+ TTI::TargetCostKind CostKind) {
786
807
// Delegate to the generic intrinsic handling code. This mostly provides an
787
808
// opportunity for targets to (for example) special case the cost of
788
809
// certain intrinsics based on constants used as arguments.
789
810
SmallVector<Type *, 8 > ParamTys;
790
811
ParamTys.reserve (Arguments.size ());
791
812
for (unsigned Idx = 0 , Size = Arguments.size (); Idx != Size ; ++Idx)
792
813
ParamTys.push_back (Arguments[Idx]->getType ());
793
- return static_cast <T *>(this )->getIntrinsicCost (IID, RetTy, ParamTys, U);
814
+ return static_cast <T *>(this )->getIntrinsicCost (IID, RetTy, ParamTys, U,
815
+ CostKind);
794
816
}
795
817
796
818
unsigned getUserCost (const User *U, ArrayRef<const Value *> Operands,
797
- enum TTI::TargetCostKind CostKind) {
819
+ TTI::TargetCostKind CostKind) {
798
820
auto *TargetTTI = static_cast <T *>(this );
799
821
800
822
// FIXME: Unlikely to be true for anything but CodeSize.
@@ -805,7 +827,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
805
827
if (Intrinsic::ID IID = F->getIntrinsicID ()) {
806
828
SmallVector<Type *, 8 > ParamTys (FTy->param_begin (), FTy->param_end ());
807
829
return TargetTTI->getIntrinsicCost (IID, FTy->getReturnType (),
808
- ParamTys, U);
830
+ ParamTys, U, CostKind );
809
831
}
810
832
811
833
if (!TargetTTI->isLoweredToCall (F))
@@ -849,12 +871,12 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
849
871
case Instruction::IntToPtr:
850
872
case Instruction::PtrToInt:
851
873
case Instruction::Trunc:
852
- if (getCastInstrCost (Opcode, Ty, OpTy, I) == TTI::TCC_Free ||
853
- TargetTTI->getCastInstrCost (Opcode, Ty, OpTy, I) == TTI::TCC_Free)
874
+ if (getCastInstrCost (Opcode, Ty, OpTy, CostKind, I) == TTI::TCC_Free ||
875
+ TargetTTI->getCastInstrCost (Opcode, Ty, OpTy, CostKind, I) == TTI::TCC_Free)
854
876
return TTI::TCC_Free;
855
877
break ;
856
878
case Instruction::BitCast:
857
- if (getCastInstrCost (Opcode, Ty, OpTy, I) == TTI::TCC_Free)
879
+ if (getCastInstrCost (Opcode, Ty, OpTy, CostKind, I) == TTI::TCC_Free)
858
880
return TTI::TCC_Free;
859
881
break ;
860
882
case Instruction::FPExt:
0 commit comments