@@ -136,9 +136,7 @@ class TargetTransformInfoImplBase {
136
136
137
137
int getInlinerVectorBonusPercent () { return 150 ; }
138
138
139
- unsigned getMemcpyCost (const Instruction *I) {
140
- return TTI::TCC_Expensive;
141
- }
139
+ unsigned getMemcpyCost (const Instruction *I) { return TTI::TCC_Expensive; }
142
140
143
141
bool hasBranchDivergence () { return false ; }
144
142
@@ -148,17 +146,15 @@ class TargetTransformInfoImplBase {
148
146
149
147
bool isAlwaysUniform (const Value *V) { return false ; }
150
148
151
- unsigned getFlatAddressSpace () {
152
- return -1 ;
153
- }
149
+ unsigned getFlatAddressSpace () { return -1 ; }
154
150
155
151
bool collectFlatAddressOperands (SmallVectorImpl<int > &OpIndexes,
156
152
Intrinsic::ID IID) const {
157
153
return false ;
158
154
}
159
155
160
- bool rewriteIntrinsicWithAddressSpace (IntrinsicInst *II,
161
- Value *OldV, Value * NewV) const {
156
+ bool rewriteIntrinsicWithAddressSpace (IntrinsicInst *II, Value *OldV,
157
+ Value *NewV) const {
162
158
return false ;
163
159
}
164
160
@@ -199,8 +195,7 @@ class TargetTransformInfoImplBase {
199
195
}
200
196
201
197
bool isHardwareLoopProfitable (Loop *L, ScalarEvolution &SE,
202
- AssumptionCache &AC,
203
- TargetLibraryInfo *LibInfo,
198
+ AssumptionCache &AC, TargetLibraryInfo *LibInfo,
204
199
HardwareLoopInfo &HWLoopInfo) {
205
200
return false ;
206
201
}
@@ -220,8 +215,8 @@ class TargetTransformInfoImplBase {
220
215
bool isLegalICmpImmediate (int64_t Imm) { return false ; }
221
216
222
217
bool isLegalAddressingMode (Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
223
- bool HasBaseReg, int64_t Scale,
224
- unsigned AddrSpace, Instruction *I = nullptr ) {
218
+ bool HasBaseReg, int64_t Scale, unsigned AddrSpace,
219
+ Instruction *I = nullptr ) {
225
220
// Guess that only reg and reg+reg addressing is allowed. This heuristic is
226
221
// taken from the implementation of LSR.
227
222
return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1 );
@@ -246,7 +241,9 @@ class TargetTransformInfoImplBase {
246
241
247
242
bool shouldFavorBackedgeIndex (const Loop *L) const { return false ; }
248
243
249
- bool isLegalMaskedStore (Type *DataType, MaybeAlign Alignment) { return false ; }
244
+ bool isLegalMaskedStore (Type *DataType, MaybeAlign Alignment) {
245
+ return false ;
246
+ }
250
247
251
248
bool isLegalMaskedLoad (Type *DataType, MaybeAlign Alignment) { return false ; }
252
249
@@ -285,8 +282,8 @@ class TargetTransformInfoImplBase {
285
282
int getScalingFactorCost (Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
286
283
bool HasBaseReg, int64_t Scale, unsigned AddrSpace) {
287
284
// Guess that all legal addressing mode are free.
288
- if (isLegalAddressingMode (Ty, BaseGV, BaseOffset, HasBaseReg,
289
- Scale, AddrSpace))
285
+ if (isLegalAddressingMode (Ty, BaseGV, BaseOffset, HasBaseReg, Scale,
286
+ AddrSpace))
290
287
return 0 ;
291
288
return -1 ;
292
289
}
@@ -311,7 +308,9 @@ class TargetTransformInfoImplBase {
311
308
}
312
309
313
310
unsigned getOperandsScalarizationOverhead (ArrayRef<const Value *> Args,
314
- unsigned VF) { return 0 ; }
311
+ unsigned VF) {
312
+ return 0 ;
313
+ }
315
314
316
315
bool supportsEfficientVectorElementLoadStore () { return false ; }
317
316
@@ -328,11 +327,11 @@ class TargetTransformInfoImplBase {
328
327
329
328
bool isFPVectorizationPotentiallyUnsafe () { return false ; }
330
329
331
- bool allowsMisalignedMemoryAccesses (LLVMContext &Context,
332
- unsigned BitWidth ,
333
- unsigned AddressSpace,
334
- unsigned Alignment,
335
- bool *Fast) { return false ; }
330
+ bool allowsMisalignedMemoryAccesses (LLVMContext &Context, unsigned BitWidth,
331
+ unsigned AddressSpace, unsigned Alignment ,
332
+ bool *Fast) {
333
+ return false ;
334
+ }
336
335
337
336
TTI::PopcntSupportKind getPopcntSupport (unsigned IntTyWidthInBit) {
338
337
return TTI::PSK_Software;
@@ -367,12 +366,14 @@ class TargetTransformInfoImplBase {
367
366
return Vector ? 1 : 0 ;
368
367
};
369
368
370
- const char * getRegisterClassName (unsigned ClassID) const {
369
+ const char * getRegisterClassName (unsigned ClassID) const {
371
370
switch (ClassID) {
372
- default :
373
- return " Generic::Unknown Register Class" ;
374
- case 0 : return " Generic::ScalarRC" ;
375
- case 1 : return " Generic::VectorRC" ;
371
+ default :
372
+ return " Generic::Unknown Register Class" ;
373
+ case 0 :
374
+ return " Generic::ScalarRC" ;
375
+ case 1 :
376
+ return " Generic::VectorRC" ;
376
377
}
377
378
}
378
379
@@ -393,7 +394,8 @@ class TargetTransformInfoImplBase {
393
394
394
395
unsigned getCacheLineSize () const { return 0 ; }
395
396
396
- llvm::Optional<unsigned > getCacheSize (TargetTransformInfo::CacheLevel Level) const {
397
+ llvm::Optional<unsigned >
398
+ getCacheSize (TargetTransformInfo::CacheLevel Level) const {
397
399
switch (Level) {
398
400
case TargetTransformInfo::CacheLevel::L1D:
399
401
LLVM_FALLTHROUGH;
@@ -403,8 +405,8 @@ class TargetTransformInfoImplBase {
403
405
llvm_unreachable (" Unknown TargetTransformInfo::CacheLevel" );
404
406
}
405
407
406
- llvm::Optional<unsigned > getCacheAssociativity (
407
- TargetTransformInfo::CacheLevel Level) const {
408
+ llvm::Optional<unsigned >
409
+ getCacheAssociativity ( TargetTransformInfo::CacheLevel Level) const {
408
410
switch (Level) {
409
411
case TargetTransformInfo::CacheLevel::L1D:
410
412
LLVM_FALLTHROUGH;
@@ -418,8 +420,9 @@ class TargetTransformInfoImplBase {
418
420
unsigned getPrefetchDistance () const { return 0 ; }
419
421
unsigned getMinPrefetchStride (unsigned NumMemAccesses,
420
422
unsigned NumStridedMemAccesses,
421
- unsigned NumPrefetches,
422
- bool HasCall) const { return 1 ; }
423
+ unsigned NumPrefetches, bool HasCall) const {
424
+ return 1 ;
425
+ }
423
426
unsigned getMaxPrefetchIterationsAhead () const { return UINT_MAX; }
424
427
bool enableWritePrefetching () const { return false ; }
425
428
@@ -441,7 +444,9 @@ class TargetTransformInfoImplBase {
441
444
}
442
445
443
446
unsigned getCastInstrCost (unsigned Opcode, Type *Dst, Type *Src,
444
- const Instruction *I) { return 1 ; }
447
+ const Instruction *I) {
448
+ return 1 ;
449
+ }
445
450
446
451
unsigned getExtractWithExtendCost (unsigned Opcode, Type *Dst,
447
452
VectorType *VecTy, unsigned Index) {
@@ -537,13 +542,10 @@ class TargetTransformInfoImplBase {
537
542
return Type::getInt8Ty (Context);
538
543
}
539
544
540
- void getMemcpyLoopResidualLoweringType (SmallVectorImpl<Type *> &OpsOut,
541
- LLVMContext &Context,
542
- unsigned RemainingBytes,
543
- unsigned SrcAddrSpace,
544
- unsigned DestAddrSpace,
545
- unsigned SrcAlign,
546
- unsigned DestAlign) const {
545
+ void getMemcpyLoopResidualLoweringType (
546
+ SmallVectorImpl<Type *> &OpsOut, LLVMContext &Context,
547
+ unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace,
548
+ unsigned SrcAlign, unsigned DestAlign) const {
547
549
for (unsigned i = 0 ; i != RemainingBytes; ++i)
548
550
OpsOut.push_back (Type::getInt8Ty (Context));
549
551
}
@@ -556,7 +558,8 @@ class TargetTransformInfoImplBase {
556
558
Callee->getFnAttribute (" target-features" ));
557
559
}
558
560
559
- bool areFunctionArgsABICompatible (const Function *Caller, const Function *Callee,
561
+ bool areFunctionArgsABICompatible (const Function *Caller,
562
+ const Function *Callee,
560
563
SmallPtrSetImpl<Argument *> &Args) const {
561
564
return (Caller->getFnAttribute (" target-cpu" ) ==
562
565
Callee->getFnAttribute (" target-cpu" )) &&
@@ -609,24 +612,18 @@ class TargetTransformInfoImplBase {
609
612
return false ;
610
613
}
611
614
612
- bool shouldExpandReduction (const IntrinsicInst *II) const {
613
- return true ;
614
- }
615
+ bool shouldExpandReduction (const IntrinsicInst *II) const { return true ; }
615
616
616
- unsigned getGISelRematGlobalCost () const {
617
- return 1 ;
618
- }
617
+ unsigned getGISelRematGlobalCost () const { return 1 ; }
619
618
620
- bool hasActiveVectorLength () const {
621
- return false ;
622
- }
619
+ bool hasActiveVectorLength () const { return false ; }
623
620
624
621
protected:
625
622
// Obtain the minimum required size to hold the value (without the sign)
626
623
// In case of a vector it returns the min required size for one element.
627
- unsigned minRequiredElementSize (const Value* Val, bool &isSigned) {
624
+ unsigned minRequiredElementSize (const Value * Val, bool &isSigned) {
628
625
if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
629
- const auto * VectorValue = cast<Constant>(Val);
626
+ const auto * VectorValue = cast<Constant>(Val);
630
627
631
628
// In case of a vector need to pick the max between the min
632
629
// required size for each element
@@ -640,37 +637,36 @@ class TargetTransformInfoImplBase {
640
637
unsigned MaxRequiredSize = VT->getBitWidth () / VT->getNumElements ();
641
638
642
639
unsigned MinRequiredSize = 0 ;
643
- for (unsigned i = 0 , e = VT->getNumElements (); i < e; ++i) {
644
- if (auto * IntElement =
645
- dyn_cast<ConstantInt>(VectorValue->getAggregateElement (i))) {
640
+ for (unsigned i = 0 , e = VT->getNumElements (); i < e; ++i) {
641
+ if (auto * IntElement =
642
+ dyn_cast<ConstantInt>(VectorValue->getAggregateElement (i))) {
646
643
bool signedElement = IntElement->getValue ().isNegative ();
647
644
// Get the element min required size.
648
645
unsigned ElementMinRequiredSize =
649
- IntElement->getValue ().getMinSignedBits () - 1 ;
646
+ IntElement->getValue ().getMinSignedBits () - 1 ;
650
647
// In case one element is signed then all the vector is signed.
651
648
isSigned |= signedElement;
652
649
// Save the max required bit size between all the elements.
653
650
MinRequiredSize = std::max (MinRequiredSize, ElementMinRequiredSize);
654
- }
655
- else {
651
+ } else {
656
652
// not an int constant element
657
653
return MaxRequiredSize;
658
654
}
659
655
}
660
656
return MinRequiredSize;
661
657
}
662
658
663
- if (const auto * CI = dyn_cast<ConstantInt>(Val)) {
659
+ if (const auto * CI = dyn_cast<ConstantInt>(Val)) {
664
660
isSigned = CI->getValue ().isNegative ();
665
661
return CI->getValue ().getMinSignedBits () - 1 ;
666
662
}
667
663
668
- if (const auto * Cast = dyn_cast<SExtInst>(Val)) {
664
+ if (const auto * Cast = dyn_cast<SExtInst>(Val)) {
669
665
isSigned = true ;
670
666
return Cast->getSrcTy ()->getScalarSizeInBits () - 1 ;
671
667
}
672
668
673
- if (const auto * Cast = dyn_cast<ZExtInst>(Val)) {
669
+ if (const auto * Cast = dyn_cast<ZExtInst>(Val)) {
674
670
isSigned = false ;
675
671
return Cast->getSrcTy ()->getScalarSizeInBits ();
676
672
}
@@ -715,7 +711,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
715
711
explicit TargetTransformInfoImplCRTPBase (const DataLayout &DL) : BaseT(DL) {}
716
712
717
713
public:
718
-
719
714
using BaseT::getGEPCost;
720
715
721
716
int getGEPCost (Type *PointeeType, const Value *Ptr,
@@ -860,7 +855,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
860
855
FunctionType *FTy = F->getFunctionType ();
861
856
if (Intrinsic::ID IID = F->getIntrinsicID ()) {
862
857
SmallVector<Type *, 8 > ParamTys (FTy->param_begin (), FTy->param_end ());
863
- return TargetTTI->getIntrinsicCost (IID, FTy->getReturnType (), ParamTys, U);
858
+ return TargetTTI->getIntrinsicCost (IID, FTy->getReturnType (),
859
+ ParamTys, U);
864
860
}
865
861
866
862
if (!TargetTTI->isLoweredToCall (F))
@@ -876,7 +872,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
876
872
// has been removed. A target that needs it should override getUserCost().
877
873
return TargetTTI->getExtCost (cast<Instruction>(U), Operands.back ());
878
874
879
- return TargetTTI->getOperationCost (Operator::getOpcode (U), U->getType (),
875
+ return TargetTTI->getOperationCost (
876
+ Operator::getOpcode (U), U->getType (),
880
877
U->getNumOperands () == 1 ? U->getOperand (0 )->getType () : nullptr );
881
878
}
882
879
@@ -899,7 +896,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
899
896
return 40 ;
900
897
// Some intrinsics return a value and a flag, we use the value type
901
898
// to decide its latency.
902
- if (StructType* StructTy = dyn_cast<StructType>(DstTy))
899
+ if (StructType * StructTy = dyn_cast<StructType>(DstTy))
903
900
DstTy = StructTy->getElementType (0 );
904
901
// Fall through to simple instructions.
905
902
}
@@ -912,6 +909,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
912
909
return 1 ;
913
910
}
914
911
};
915
- }
912
+ } // namespace llvm
916
913
917
914
#endif
0 commit comments