Skip to content

Commit e2fcf2c

Browse files
Simon Mollmemfrob
authored andcommitted
[nfc] clang-format TargetTransformInfoImpl.h
1 parent b4745ee commit e2fcf2c

File tree

1 file changed

+62
-65
lines changed

1 file changed

+62
-65
lines changed

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ class TargetTransformInfoImplBase {
136136

137137
int getInlinerVectorBonusPercent() { return 150; }
138138

139-
unsigned getMemcpyCost(const Instruction *I) {
140-
return TTI::TCC_Expensive;
141-
}
139+
unsigned getMemcpyCost(const Instruction *I) { return TTI::TCC_Expensive; }
142140

143141
bool hasBranchDivergence() { return false; }
144142

@@ -148,17 +146,15 @@ class TargetTransformInfoImplBase {
148146

149147
bool isAlwaysUniform(const Value *V) { return false; }
150148

151-
unsigned getFlatAddressSpace () {
152-
return -1;
153-
}
149+
unsigned getFlatAddressSpace() { return -1; }
154150

155151
bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
156152
Intrinsic::ID IID) const {
157153
return false;
158154
}
159155

160-
bool rewriteIntrinsicWithAddressSpace(IntrinsicInst *II,
161-
Value *OldV, Value *NewV) const {
156+
bool rewriteIntrinsicWithAddressSpace(IntrinsicInst *II, Value *OldV,
157+
Value *NewV) const {
162158
return false;
163159
}
164160

@@ -199,8 +195,7 @@ class TargetTransformInfoImplBase {
199195
}
200196

201197
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
202-
AssumptionCache &AC,
203-
TargetLibraryInfo *LibInfo,
198+
AssumptionCache &AC, TargetLibraryInfo *LibInfo,
204199
HardwareLoopInfo &HWLoopInfo) {
205200
return false;
206201
}
@@ -220,8 +215,8 @@ class TargetTransformInfoImplBase {
220215
bool isLegalICmpImmediate(int64_t Imm) { return false; }
221216

222217
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) {
225220
// Guess that only reg and reg+reg addressing is allowed. This heuristic is
226221
// taken from the implementation of LSR.
227222
return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
@@ -246,7 +241,9 @@ class TargetTransformInfoImplBase {
246241

247242
bool shouldFavorBackedgeIndex(const Loop *L) const { return false; }
248243

249-
bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) { return false; }
244+
bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) {
245+
return false;
246+
}
250247

251248
bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment) { return false; }
252249

@@ -285,8 +282,8 @@ class TargetTransformInfoImplBase {
285282
int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
286283
bool HasBaseReg, int64_t Scale, unsigned AddrSpace) {
287284
// 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))
290287
return 0;
291288
return -1;
292289
}
@@ -311,7 +308,9 @@ class TargetTransformInfoImplBase {
311308
}
312309

313310
unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
314-
unsigned VF) { return 0; }
311+
unsigned VF) {
312+
return 0;
313+
}
315314

316315
bool supportsEfficientVectorElementLoadStore() { return false; }
317316

@@ -328,11 +327,11 @@ class TargetTransformInfoImplBase {
328327

329328
bool isFPVectorizationPotentiallyUnsafe() { return false; }
330329

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+
}
336335

337336
TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) {
338337
return TTI::PSK_Software;
@@ -367,12 +366,14 @@ class TargetTransformInfoImplBase {
367366
return Vector ? 1 : 0;
368367
};
369368

370-
const char* getRegisterClassName(unsigned ClassID) const {
369+
const char *getRegisterClassName(unsigned ClassID) const {
371370
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";
376377
}
377378
}
378379

@@ -393,7 +394,8 @@ class TargetTransformInfoImplBase {
393394

394395
unsigned getCacheLineSize() const { return 0; }
395396

396-
llvm::Optional<unsigned> getCacheSize(TargetTransformInfo::CacheLevel Level) const {
397+
llvm::Optional<unsigned>
398+
getCacheSize(TargetTransformInfo::CacheLevel Level) const {
397399
switch (Level) {
398400
case TargetTransformInfo::CacheLevel::L1D:
399401
LLVM_FALLTHROUGH;
@@ -403,8 +405,8 @@ class TargetTransformInfoImplBase {
403405
llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
404406
}
405407

406-
llvm::Optional<unsigned> getCacheAssociativity(
407-
TargetTransformInfo::CacheLevel Level) const {
408+
llvm::Optional<unsigned>
409+
getCacheAssociativity(TargetTransformInfo::CacheLevel Level) const {
408410
switch (Level) {
409411
case TargetTransformInfo::CacheLevel::L1D:
410412
LLVM_FALLTHROUGH;
@@ -418,8 +420,9 @@ class TargetTransformInfoImplBase {
418420
unsigned getPrefetchDistance() const { return 0; }
419421
unsigned getMinPrefetchStride(unsigned NumMemAccesses,
420422
unsigned NumStridedMemAccesses,
421-
unsigned NumPrefetches,
422-
bool HasCall) const { return 1; }
423+
unsigned NumPrefetches, bool HasCall) const {
424+
return 1;
425+
}
423426
unsigned getMaxPrefetchIterationsAhead() const { return UINT_MAX; }
424427
bool enableWritePrefetching() const { return false; }
425428

@@ -441,7 +444,9 @@ class TargetTransformInfoImplBase {
441444
}
442445

443446
unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
444-
const Instruction *I) { return 1; }
447+
const Instruction *I) {
448+
return 1;
449+
}
445450

446451
unsigned getExtractWithExtendCost(unsigned Opcode, Type *Dst,
447452
VectorType *VecTy, unsigned Index) {
@@ -537,13 +542,10 @@ class TargetTransformInfoImplBase {
537542
return Type::getInt8Ty(Context);
538543
}
539544

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 {
547549
for (unsigned i = 0; i != RemainingBytes; ++i)
548550
OpsOut.push_back(Type::getInt8Ty(Context));
549551
}
@@ -556,7 +558,8 @@ class TargetTransformInfoImplBase {
556558
Callee->getFnAttribute("target-features"));
557559
}
558560

559-
bool areFunctionArgsABICompatible(const Function *Caller, const Function *Callee,
561+
bool areFunctionArgsABICompatible(const Function *Caller,
562+
const Function *Callee,
560563
SmallPtrSetImpl<Argument *> &Args) const {
561564
return (Caller->getFnAttribute("target-cpu") ==
562565
Callee->getFnAttribute("target-cpu")) &&
@@ -609,24 +612,18 @@ class TargetTransformInfoImplBase {
609612
return false;
610613
}
611614

612-
bool shouldExpandReduction(const IntrinsicInst *II) const {
613-
return true;
614-
}
615+
bool shouldExpandReduction(const IntrinsicInst *II) const { return true; }
615616

616-
unsigned getGISelRematGlobalCost() const {
617-
return 1;
618-
}
617+
unsigned getGISelRematGlobalCost() const { return 1; }
619618

620-
bool hasActiveVectorLength() const {
621-
return false;
622-
}
619+
bool hasActiveVectorLength() const { return false; }
623620

624621
protected:
625622
// Obtain the minimum required size to hold the value (without the sign)
626623
// 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) {
628625
if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
629-
const auto* VectorValue = cast<Constant>(Val);
626+
const auto *VectorValue = cast<Constant>(Val);
630627

631628
// In case of a vector need to pick the max between the min
632629
// required size for each element
@@ -640,37 +637,36 @@ class TargetTransformInfoImplBase {
640637
unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
641638

642639
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))) {
646643
bool signedElement = IntElement->getValue().isNegative();
647644
// Get the element min required size.
648645
unsigned ElementMinRequiredSize =
649-
IntElement->getValue().getMinSignedBits() - 1;
646+
IntElement->getValue().getMinSignedBits() - 1;
650647
// In case one element is signed then all the vector is signed.
651648
isSigned |= signedElement;
652649
// Save the max required bit size between all the elements.
653650
MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
654-
}
655-
else {
651+
} else {
656652
// not an int constant element
657653
return MaxRequiredSize;
658654
}
659655
}
660656
return MinRequiredSize;
661657
}
662658

663-
if (const auto* CI = dyn_cast<ConstantInt>(Val)) {
659+
if (const auto *CI = dyn_cast<ConstantInt>(Val)) {
664660
isSigned = CI->getValue().isNegative();
665661
return CI->getValue().getMinSignedBits() - 1;
666662
}
667663

668-
if (const auto* Cast = dyn_cast<SExtInst>(Val)) {
664+
if (const auto *Cast = dyn_cast<SExtInst>(Val)) {
669665
isSigned = true;
670666
return Cast->getSrcTy()->getScalarSizeInBits() - 1;
671667
}
672668

673-
if (const auto* Cast = dyn_cast<ZExtInst>(Val)) {
669+
if (const auto *Cast = dyn_cast<ZExtInst>(Val)) {
674670
isSigned = false;
675671
return Cast->getSrcTy()->getScalarSizeInBits();
676672
}
@@ -715,7 +711,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
715711
explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
716712

717713
public:
718-
719714
using BaseT::getGEPCost;
720715

721716
int getGEPCost(Type *PointeeType, const Value *Ptr,
@@ -860,7 +855,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
860855
FunctionType *FTy = F->getFunctionType();
861856
if (Intrinsic::ID IID = F->getIntrinsicID()) {
862857
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);
864860
}
865861

866862
if (!TargetTTI->isLoweredToCall(F))
@@ -876,7 +872,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
876872
// has been removed. A target that needs it should override getUserCost().
877873
return TargetTTI->getExtCost(cast<Instruction>(U), Operands.back());
878874

879-
return TargetTTI->getOperationCost(Operator::getOpcode(U), U->getType(),
875+
return TargetTTI->getOperationCost(
876+
Operator::getOpcode(U), U->getType(),
880877
U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr);
881878
}
882879

@@ -899,7 +896,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
899896
return 40;
900897
// Some intrinsics return a value and a flag, we use the value type
901898
// to decide its latency.
902-
if (StructType* StructTy = dyn_cast<StructType>(DstTy))
899+
if (StructType *StructTy = dyn_cast<StructType>(DstTy))
903900
DstTy = StructTy->getElementType(0);
904901
// Fall through to simple instructions.
905902
}
@@ -912,6 +909,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
912909
return 1;
913910
}
914911
};
915-
}
912+
} // namespace llvm
916913

917914
#endif

0 commit comments

Comments
 (0)