@@ -243,7 +243,7 @@ LLVM_DUMP_METHOD void SCEV::dump() const {
243
243
#endif
244
244
245
245
void SCEV::print (raw_ostream &OS) const {
246
- switch (static_cast <SCEVTypes>( getSCEVType () )) {
246
+ switch (getSCEVType ()) {
247
247
case scConstant:
248
248
cast<SCEVConstant>(this )->getValue ()->printAsOperand (OS, false );
249
249
return ;
@@ -304,6 +304,8 @@ void SCEV::print(raw_ostream &OS) const {
304
304
case scSMinExpr:
305
305
OpStr = " smin " ;
306
306
break ;
307
+ default :
308
+ llvm_unreachable (" There are no other nary expression types." );
307
309
}
308
310
OS << " (" ;
309
311
for (SCEVNAryExpr::op_iterator I = NAry->op_begin (), E = NAry->op_end ();
@@ -320,6 +322,10 @@ void SCEV::print(raw_ostream &OS) const {
320
322
OS << " <nuw>" ;
321
323
if (NAry->hasNoSignedWrap ())
322
324
OS << " <nsw>" ;
325
+ break ;
326
+ default :
327
+ // Nothing to print for other nary expressions.
328
+ break ;
323
329
}
324
330
return ;
325
331
}
@@ -361,7 +367,7 @@ void SCEV::print(raw_ostream &OS) const {
361
367
}
362
368
363
369
Type *SCEV::getType () const {
364
- switch (static_cast <SCEVTypes>( getSCEVType () )) {
370
+ switch (getSCEVType ()) {
365
371
case scConstant:
366
372
return cast<SCEVConstant>(this )->getType ();
367
373
case scTruncate:
@@ -446,7 +452,7 @@ ScalarEvolution::getConstant(Type *Ty, uint64_t V, bool isSigned) {
446
452
}
447
453
448
454
SCEVIntegralCastExpr::SCEVIntegralCastExpr (const FoldingSetNodeIDRef ID,
449
- unsigned SCEVTy, const SCEV *op,
455
+ SCEVTypes SCEVTy, const SCEV *op,
450
456
Type *ty)
451
457
: SCEV(ID, SCEVTy, computeExpressionSize(op)), Ty(ty) {
452
458
Operands[0 ] = op;
@@ -668,7 +674,7 @@ static int CompareSCEVComplexity(
668
674
return 0 ;
669
675
670
676
// Primarily, sort the SCEVs by their getSCEVType().
671
- unsigned LType = LHS->getSCEVType (), RType = RHS->getSCEVType ();
677
+ SCEVTypes LType = LHS->getSCEVType (), RType = RHS->getSCEVType ();
672
678
if (LType != RType)
673
679
return (int )LType - (int )RType;
674
680
@@ -677,7 +683,7 @@ static int CompareSCEVComplexity(
677
683
// Aside from the getSCEVType() ordering, the particular ordering
678
684
// isn't very important except that it's beneficial to be consistent,
679
685
// so that (a + b) and (b + a) don't end up as different expressions.
680
- switch (static_cast <SCEVTypes>( LType) ) {
686
+ switch (LType) {
681
687
case scUnknown: {
682
688
const SCEVUnknown *LU = cast<SCEVUnknown>(LHS);
683
689
const SCEVUnknown *RU = cast<SCEVUnknown>(RHS);
@@ -3325,7 +3331,7 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
3325
3331
}
3326
3332
3327
3333
std::tuple<SCEV *, FoldingSetNodeID, void *>
3328
- ScalarEvolution::findExistingSCEVInCache (int SCEVType,
3334
+ ScalarEvolution::findExistingSCEVInCache (SCEVTypes SCEVType,
3329
3335
ArrayRef<const SCEV *> Ops) {
3330
3336
FoldingSetNodeID ID;
3331
3337
void *IP = nullptr ;
@@ -3346,7 +3352,7 @@ const SCEV *ScalarEvolution::getSignumExpr(const SCEV *Op) {
3346
3352
return getSMinExpr (getSMaxExpr (Op, getMinusOne (Ty)), getOne (Ty));
3347
3353
}
3348
3354
3349
- const SCEV *ScalarEvolution::getMinMaxExpr (unsigned Kind,
3355
+ const SCEV *ScalarEvolution::getMinMaxExpr (SCEVTypes Kind,
3350
3356
SmallVectorImpl<const SCEV *> &Ops) {
3351
3357
assert (!Ops.empty () && " Cannot get empty (u|s)(min|max)!" );
3352
3358
if (Ops.size () == 1 ) return Ops[0 ];
@@ -3470,8 +3476,8 @@ const SCEV *ScalarEvolution::getMinMaxExpr(unsigned Kind,
3470
3476
return ExistingSCEV;
3471
3477
const SCEV **O = SCEVAllocator.Allocate <const SCEV *>(Ops.size ());
3472
3478
std::uninitialized_copy (Ops.begin (), Ops.end (), O);
3473
- SCEV *S = new (SCEVAllocator) SCEVMinMaxExpr (
3474
- ID.Intern (SCEVAllocator), static_cast <SCEVTypes>( Kind) , O, Ops.size ());
3479
+ SCEV *S = new (SCEVAllocator)
3480
+ SCEVMinMaxExpr ( ID.Intern (SCEVAllocator), Kind, O, Ops.size ());
3475
3481
3476
3482
UniqueSCEVs.InsertNode (S, IP);
3477
3483
addToLoopUseLists (S);
@@ -3792,9 +3798,8 @@ const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) {
3792
3798
return (const SCEV *)nullptr ;
3793
3799
MatchedOperands.push_back (Matched);
3794
3800
}
3795
- return getMinMaxExpr (
3796
- SCEVMinMaxExpr::negate (static_cast <SCEVTypes>(MME->getSCEVType ())),
3797
- MatchedOperands);
3801
+ return getMinMaxExpr (SCEVMinMaxExpr::negate (MME->getSCEVType ()),
3802
+ MatchedOperands);
3798
3803
};
3799
3804
if (const SCEV *Replaced = MatchMinMaxNegation (MME))
3800
3805
return Replaced;
@@ -5036,7 +5041,7 @@ static bool IsAvailableOnEntry(const Loop *L, DominatorTree &DT, const SCEV *S,
5036
5041
// We do not try to smart about these at all.
5037
5042
return setUnavailable ();
5038
5043
}
5039
- llvm_unreachable (" switch should be fully covered !" );
5044
+ llvm_unreachable (" Unknown SCEV kind !" );
5040
5045
}
5041
5046
5042
5047
bool isDone () { return TraversalDone; }
@@ -7970,10 +7975,10 @@ const SCEV *ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
7970
7975
// / SCEVConstant, because SCEVConstant is restricted to ConstantInt.
7971
7976
// / Returns NULL if the SCEV isn't representable as a Constant.
7972
7977
static Constant *BuildConstantFromSCEV (const SCEV *V) {
7973
- switch (static_cast <SCEVTypes>( V->getSCEVType () )) {
7978
+ switch (V->getSCEVType ()) {
7974
7979
case scCouldNotCompute:
7975
7980
case scAddRecExpr:
7976
- break ;
7981
+ return nullptr ;
7977
7982
case scConstant:
7978
7983
return cast<SCEVConstant>(V)->getValue ();
7979
7984
case scUnknown:
@@ -7982,19 +7987,19 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) {
7982
7987
const SCEVSignExtendExpr *SS = cast<SCEVSignExtendExpr>(V);
7983
7988
if (Constant *CastOp = BuildConstantFromSCEV (SS->getOperand ()))
7984
7989
return ConstantExpr::getSExt (CastOp, SS->getType ());
7985
- break ;
7990
+ return nullptr ;
7986
7991
}
7987
7992
case scZeroExtend: {
7988
7993
const SCEVZeroExtendExpr *SZ = cast<SCEVZeroExtendExpr>(V);
7989
7994
if (Constant *CastOp = BuildConstantFromSCEV (SZ->getOperand ()))
7990
7995
return ConstantExpr::getZExt (CastOp, SZ->getType ());
7991
- break ;
7996
+ return nullptr ;
7992
7997
}
7993
7998
case scTruncate: {
7994
7999
const SCEVTruncateExpr *ST = cast<SCEVTruncateExpr>(V);
7995
8000
if (Constant *CastOp = BuildConstantFromSCEV (ST->getOperand ()))
7996
8001
return ConstantExpr::getTrunc (CastOp, ST->getType ());
7997
- break ;
8002
+ return nullptr ;
7998
8003
}
7999
8004
case scAddExpr: {
8000
8005
const SCEVAddExpr *SA = cast<SCEVAddExpr>(V);
@@ -8034,7 +8039,7 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) {
8034
8039
}
8035
8040
return C;
8036
8041
}
8037
- break ;
8042
+ return nullptr ;
8038
8043
}
8039
8044
case scMulExpr: {
8040
8045
const SCEVMulExpr *SM = cast<SCEVMulExpr>(V);
@@ -8050,23 +8055,23 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) {
8050
8055
}
8051
8056
return C;
8052
8057
}
8053
- break ;
8058
+ return nullptr ;
8054
8059
}
8055
8060
case scUDivExpr: {
8056
8061
const SCEVUDivExpr *SU = cast<SCEVUDivExpr>(V);
8057
8062
if (Constant *LHS = BuildConstantFromSCEV (SU->getLHS ()))
8058
8063
if (Constant *RHS = BuildConstantFromSCEV (SU->getRHS ()))
8059
8064
if (LHS->getType () == RHS->getType ())
8060
8065
return ConstantExpr::getUDiv (LHS, RHS);
8061
- break ;
8066
+ return nullptr ;
8062
8067
}
8063
8068
case scSMaxExpr:
8064
8069
case scUMaxExpr:
8065
8070
case scSMinExpr:
8066
8071
case scUMinExpr:
8067
- break ; // TODO: smax, umax, smin, umax.
8072
+ return nullptr ; // TODO: smax, umax, smin, umax.
8068
8073
}
8069
- return nullptr ;
8074
+ llvm_unreachable ( " Unknown SCEV kind! " ) ;
8070
8075
}
8071
8076
8072
8077
const SCEV *ScalarEvolution::computeSCEVAtScope (const SCEV *V, const Loop *L) {
@@ -11794,7 +11799,7 @@ ScalarEvolution::getLoopDisposition(const SCEV *S, const Loop *L) {
11794
11799
11795
11800
ScalarEvolution::LoopDisposition
11796
11801
ScalarEvolution::computeLoopDisposition (const SCEV *S, const Loop *L) {
11797
- switch (static_cast <SCEVTypes>( S->getSCEVType () )) {
11802
+ switch (S->getSCEVType ()) {
11798
11803
case scConstant:
11799
11804
return LoopInvariant;
11800
11805
case scTruncate:
@@ -11901,7 +11906,7 @@ ScalarEvolution::getBlockDisposition(const SCEV *S, const BasicBlock *BB) {
11901
11906
11902
11907
ScalarEvolution::BlockDisposition
11903
11908
ScalarEvolution::computeBlockDisposition (const SCEV *S, const BasicBlock *BB) {
11904
- switch (static_cast <SCEVTypes>( S->getSCEVType () )) {
11909
+ switch (S->getSCEVType ()) {
11905
11910
case scConstant:
11906
11911
return ProperlyDominatesBlock;
11907
11912
case scTruncate:
0 commit comments