[ScopDectionDiagnostic] Use scoped enums instead three letter prefix [NFC]

This improves readability of the code.

llvm-svn: 287963
This commit is contained in:
Tobias Grosser 2016-11-26 03:44:31 +00:00
parent 1473f07ceb
commit c64269ea1b
2 changed files with 83 additions and 75 deletions

View File

@ -62,43 +62,43 @@ class RejectLog;
void emitRejectionRemarks(const BBPair &P, const RejectLog &Log);
// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
enum RejectReasonKind {
enum class RejectReasonKind {
// CFG Category
rrkCFG,
rrkInvalidTerminator,
rrkCondition,
rrkLastCFG,
rrkIrreducibleRegion,
CFG,
InvalidTerminator,
Condition,
LastCFG,
IrreducibleRegion,
// Non-Affinity
rrkAffFunc,
rrkUndefCond,
rrkInvalidCond,
rrkUndefOperand,
rrkNonAffBranch,
rrkNoBasePtr,
rrkUndefBasePtr,
rrkVariantBasePtr,
rrkNonAffineAccess,
rrkDifferentElementSize,
rrkLastAffFunc,
AffFunc,
UndefCond,
InvalidCond,
UndefOperand,
NonAffBranch,
NoBasePtr,
UndefBasePtr,
VariantBasePtr,
NonAffineAccess,
DifferentElementSize,
LastAffFunc,
rrkLoopBound,
rrkLoopHasNoExit,
LoopBound,
LoopHasNoExit,
rrkFuncCall,
rrkNonSimpleMemoryAccess,
FuncCall,
NonSimpleMemoryAccess,
rrkAlias,
Alias,
// Other
rrkOther,
rrkIntToPtr,
rrkAlloca,
rrkUnknownInst,
rrkEntry,
rrkUnprofitable,
rrkLastOther
Other,
IntToPtr,
Alloca,
UnknownInst,
Entry,
Unprofitable,
LastOther
};
//===----------------------------------------------------------------------===//
@ -193,7 +193,7 @@ class ReportInvalidTerminator : public ReportCFG {
public:
ReportInvalidTerminator(BasicBlock *BB)
: ReportCFG(rrkInvalidTerminator), BB(BB) {}
: ReportCFG(RejectReasonKind::InvalidTerminator), BB(BB) {}
/// @name LLVM-RTTI interface
//@{
@ -215,7 +215,7 @@ class ReportIrreducibleRegion : public ReportCFG {
public:
ReportIrreducibleRegion(Region *R, DebugLoc DbgLoc)
: ReportCFG(rrkIrreducibleRegion), R(R), DbgLoc(DbgLoc) {}
: ReportCFG(RejectReasonKind::IrreducibleRegion), R(R), DbgLoc(DbgLoc) {}
/// @name LLVM-RTTI interface
//@{
@ -267,7 +267,7 @@ class ReportUndefCond : public ReportAffFunc {
public:
ReportUndefCond(const Instruction *Inst, BasicBlock *BB)
: ReportAffFunc(rrkUndefCond, Inst), BB(BB) {}
: ReportAffFunc(RejectReasonKind::UndefCond, Inst), BB(BB) {}
/// @name LLVM-RTTI interface
//@{
@ -292,7 +292,7 @@ class ReportInvalidCond : public ReportAffFunc {
public:
ReportInvalidCond(const Instruction *Inst, BasicBlock *BB)
: ReportAffFunc(rrkInvalidCond, Inst), BB(BB) {}
: ReportAffFunc(RejectReasonKind::InvalidCond, Inst), BB(BB) {}
/// @name LLVM-RTTI interface
//@{
@ -315,7 +315,7 @@ class ReportUndefOperand : public ReportAffFunc {
public:
ReportUndefOperand(BasicBlock *BB, const Instruction *Inst)
: ReportAffFunc(rrkUndefOperand, Inst), BB(BB) {}
: ReportAffFunc(RejectReasonKind::UndefOperand, Inst), BB(BB) {}
/// @name LLVM-RTTI interface
//@{
@ -345,7 +345,8 @@ class ReportNonAffBranch : public ReportAffFunc {
public:
ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS,
const Instruction *Inst)
: ReportAffFunc(rrkNonAffBranch, Inst), BB(BB), LHS(LHS), RHS(RHS) {}
: ReportAffFunc(RejectReasonKind::NonAffBranch, Inst), BB(BB), LHS(LHS),
RHS(RHS) {}
const SCEV *lhs() { return LHS; }
const SCEV *rhs() { return RHS; }
@ -367,7 +368,7 @@ class ReportNoBasePtr : public ReportAffFunc {
//===--------------------------------------------------------------------===//
public:
ReportNoBasePtr(const Instruction *Inst)
: ReportAffFunc(rrkNoBasePtr, Inst) {}
: ReportAffFunc(RejectReasonKind::NoBasePtr, Inst) {}
/// @name LLVM-RTTI interface
//@{
@ -386,7 +387,7 @@ class ReportUndefBasePtr : public ReportAffFunc {
//===--------------------------------------------------------------------===//
public:
ReportUndefBasePtr(const Instruction *Inst)
: ReportAffFunc(rrkUndefBasePtr, Inst) {}
: ReportAffFunc(RejectReasonKind::UndefBasePtr, Inst) {}
/// @name LLVM-RTTI interface
//@{
@ -409,7 +410,8 @@ class ReportVariantBasePtr : public ReportAffFunc {
public:
ReportVariantBasePtr(Value *BaseValue, const Instruction *Inst)
: ReportAffFunc(rrkVariantBasePtr, Inst), BaseValue(BaseValue) {}
: ReportAffFunc(RejectReasonKind::VariantBasePtr, Inst),
BaseValue(BaseValue) {}
/// @name LLVM-RTTI interface
//@{
@ -437,8 +439,8 @@ class ReportNonAffineAccess : public ReportAffFunc {
public:
ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst,
const Value *V)
: ReportAffFunc(rrkNonAffineAccess, Inst), AccessFunction(AccessFunction),
BaseValue(V) {}
: ReportAffFunc(RejectReasonKind::NonAffineAccess, Inst),
AccessFunction(AccessFunction), BaseValue(V) {}
const SCEV *get() { return AccessFunction; }
@ -464,7 +466,8 @@ class ReportDifferentArrayElementSize : public ReportAffFunc {
public:
ReportDifferentArrayElementSize(const Instruction *Inst, const Value *V)
: ReportAffFunc(rrkDifferentElementSize, Inst), BaseValue(V) {}
: ReportAffFunc(RejectReasonKind::DifferentElementSize, Inst),
BaseValue(V) {}
/// @name LLVM-RTTI interface
//@{
@ -522,7 +525,8 @@ class ReportLoopHasNoExit : public RejectReason {
public:
ReportLoopHasNoExit(Loop *L)
: RejectReason(rrkLoopHasNoExit), L(L), Loc(L->getStartLoc()) {}
: RejectReason(RejectReasonKind::LoopHasNoExit), L(L),
Loc(L->getStartLoc()) {}
/// @name LLVM-RTTI interface
//@{

View File

@ -140,7 +140,8 @@ ReportCFG::ReportCFG(const RejectReasonKind K) : RejectReason(K) {
}
bool ReportCFG::classof(const RejectReason *RR) {
return RR->getKind() >= rrkCFG && RR->getKind() <= rrkLastCFG;
return RR->getKind() >= RejectReasonKind::CFG &&
RR->getKind() <= RejectReasonKind::LastCFG;
}
//===----------------------------------------------------------------------===//
@ -155,7 +156,7 @@ const DebugLoc &ReportInvalidTerminator::getDebugLoc() const {
}
bool ReportInvalidTerminator::classof(const RejectReason *RR) {
return RR->getKind() == rrkInvalidTerminator;
return RR->getKind() == RejectReasonKind::InvalidTerminator;
}
//===----------------------------------------------------------------------===//
@ -172,7 +173,7 @@ std::string ReportIrreducibleRegion::getEndUserMessage() const {
}
bool ReportIrreducibleRegion::classof(const RejectReason *RR) {
return RR->getKind() == rrkIrreducibleRegion;
return RR->getKind() == RejectReasonKind::IrreducibleRegion;
}
//===----------------------------------------------------------------------===//
@ -184,7 +185,8 @@ ReportAffFunc::ReportAffFunc(const RejectReasonKind K, const Instruction *Inst)
}
bool ReportAffFunc::classof(const RejectReason *RR) {
return RR->getKind() >= rrkAffFunc && RR->getKind() <= rrkLastAffFunc;
return RR->getKind() >= RejectReasonKind::AffFunc &&
RR->getKind() <= RejectReasonKind::LastAffFunc;
}
//===----------------------------------------------------------------------===//
@ -195,7 +197,7 @@ std::string ReportUndefCond::getMessage() const {
}
bool ReportUndefCond::classof(const RejectReason *RR) {
return RR->getKind() == rrkUndefCond;
return RR->getKind() == RejectReasonKind::UndefCond;
}
//===----------------------------------------------------------------------===//
@ -207,7 +209,7 @@ std::string ReportInvalidCond::getMessage() const {
}
bool ReportInvalidCond::classof(const RejectReason *RR) {
return RR->getKind() == rrkInvalidCond;
return RR->getKind() == RejectReasonKind::InvalidCond;
}
//===----------------------------------------------------------------------===//
@ -218,7 +220,7 @@ std::string ReportUndefOperand::getMessage() const {
}
bool ReportUndefOperand::classof(const RejectReason *RR) {
return RR->getKind() == rrkUndefOperand;
return RR->getKind() == RejectReasonKind::UndefOperand;
}
//===----------------------------------------------------------------------===//
@ -230,7 +232,7 @@ std::string ReportNonAffBranch::getMessage() const {
}
bool ReportNonAffBranch::classof(const RejectReason *RR) {
return RR->getKind() == rrkNonAffBranch;
return RR->getKind() == RejectReasonKind::NonAffBranch;
}
//===----------------------------------------------------------------------===//
@ -239,7 +241,7 @@ bool ReportNonAffBranch::classof(const RejectReason *RR) {
std::string ReportNoBasePtr::getMessage() const { return "No base pointer"; }
bool ReportNoBasePtr::classof(const RejectReason *RR) {
return RR->getKind() == rrkNoBasePtr;
return RR->getKind() == RejectReasonKind::NoBasePtr;
}
//===----------------------------------------------------------------------===//
@ -250,7 +252,7 @@ std::string ReportUndefBasePtr::getMessage() const {
}
bool ReportUndefBasePtr::classof(const RejectReason *RR) {
return RR->getKind() == rrkUndefBasePtr;
return RR->getKind() == RejectReasonKind::UndefBasePtr;
}
//===----------------------------------------------------------------------===//
@ -265,7 +267,7 @@ std::string ReportVariantBasePtr::getEndUserMessage() const {
}
bool ReportVariantBasePtr::classof(const RejectReason *RR) {
return RR->getKind() == rrkVariantBasePtr;
return RR->getKind() == RejectReasonKind::VariantBasePtr;
}
//===----------------------------------------------------------------------===//
@ -276,7 +278,7 @@ std::string ReportDifferentArrayElementSize::getMessage() const {
}
bool ReportDifferentArrayElementSize::classof(const RejectReason *RR) {
return RR->getKind() == rrkDifferentElementSize;
return RR->getKind() == RejectReasonKind::DifferentElementSize;
}
std::string ReportDifferentArrayElementSize::getEndUserMessage() const {
@ -294,7 +296,7 @@ std::string ReportNonAffineAccess::getMessage() const {
}
bool ReportNonAffineAccess::classof(const RejectReason *RR) {
return RR->getKind() == rrkNonAffineAccess;
return RR->getKind() == RejectReasonKind::NonAffineAccess;
}
std::string ReportNonAffineAccess::getEndUserMessage() const {
@ -307,7 +309,7 @@ std::string ReportNonAffineAccess::getEndUserMessage() const {
// ReportLoopBound.
ReportLoopBound::ReportLoopBound(Loop *L, const SCEV *LoopCount)
: RejectReason(rrkLoopBound), L(L), LoopCount(LoopCount),
: RejectReason(RejectReasonKind::LoopBound), L(L), LoopCount(LoopCount),
Loc(L->getStartLoc()) {
++BadLoopBoundForScop;
}
@ -320,7 +322,7 @@ std::string ReportLoopBound::getMessage() const {
const DebugLoc &ReportLoopBound::getDebugLoc() const { return Loc; }
bool ReportLoopBound::classof(const RejectReason *RR) {
return RR->getKind() == rrkLoopBound;
return RR->getKind() == RejectReasonKind::LoopBound;
}
std::string ReportLoopBound::getEndUserMessage() const {
@ -335,7 +337,7 @@ std::string ReportLoopHasNoExit::getMessage() const {
}
bool ReportLoopHasNoExit::classof(const RejectReason *RR) {
return RR->getKind() == rrkLoopHasNoExit;
return RR->getKind() == RejectReasonKind::LoopHasNoExit;
}
const DebugLoc &ReportLoopHasNoExit::getDebugLoc() const { return Loc; }
@ -348,7 +350,7 @@ std::string ReportLoopHasNoExit::getEndUserMessage() const {
// ReportFuncCall.
ReportFuncCall::ReportFuncCall(Instruction *Inst)
: RejectReason(rrkFuncCall), Inst(Inst) {
: RejectReason(RejectReasonKind::FuncCall), Inst(Inst) {
++BadFuncCallForScop;
}
@ -366,14 +368,14 @@ std::string ReportFuncCall::getEndUserMessage() const {
}
bool ReportFuncCall::classof(const RejectReason *RR) {
return RR->getKind() == rrkFuncCall;
return RR->getKind() == RejectReasonKind::FuncCall;
}
//===----------------------------------------------------------------------===//
// ReportNonSimpleMemoryAccess
ReportNonSimpleMemoryAccess::ReportNonSimpleMemoryAccess(Instruction *Inst)
: ReportOther(rrkNonSimpleMemoryAccess), Inst(Inst) {}
: ReportOther(RejectReasonKind::NonSimpleMemoryAccess), Inst(Inst) {}
std::string ReportNonSimpleMemoryAccess::getMessage() const {
return "Non-simple memory access: " + *Inst;
@ -389,14 +391,14 @@ std::string ReportNonSimpleMemoryAccess::getEndUserMessage() const {
}
bool ReportNonSimpleMemoryAccess::classof(const RejectReason *RR) {
return RR->getKind() == rrkNonSimpleMemoryAccess;
return RR->getKind() == RejectReasonKind::NonSimpleMemoryAccess;
}
//===----------------------------------------------------------------------===//
// ReportAlias.
ReportAlias::ReportAlias(Instruction *Inst, AliasSet &AS)
: RejectReason(rrkAlias), Inst(Inst) {
: RejectReason(RejectReasonKind::Alias), Inst(Inst) {
for (const auto &I : AS)
Pointers.push_back(I.getValue());
@ -447,7 +449,7 @@ std::string ReportAlias::getEndUserMessage() const {
const DebugLoc &ReportAlias::getDebugLoc() const { return Inst->getDebugLoc(); }
bool ReportAlias::classof(const RejectReason *RR) {
return RR->getKind() == rrkAlias;
return RR->getKind() == RejectReasonKind::Alias;
}
//===----------------------------------------------------------------------===//
@ -460,13 +462,14 @@ ReportOther::ReportOther(const RejectReasonKind K) : RejectReason(K) {
}
bool ReportOther::classof(const RejectReason *RR) {
return RR->getKind() >= rrkOther && RR->getKind() <= rrkLastOther;
return RR->getKind() >= RejectReasonKind::Other &&
RR->getKind() <= RejectReasonKind::LastOther;
}
//===----------------------------------------------------------------------===//
// ReportIntToPtr.
ReportIntToPtr::ReportIntToPtr(Instruction *BaseValue)
: ReportOther(rrkIntToPtr), BaseValue(BaseValue) {}
: ReportOther(RejectReasonKind::IntToPtr), BaseValue(BaseValue) {}
std::string ReportIntToPtr::getMessage() const {
return "Find bad intToptr prt: " + *BaseValue;
@ -477,14 +480,14 @@ const DebugLoc &ReportIntToPtr::getDebugLoc() const {
}
bool ReportIntToPtr::classof(const RejectReason *RR) {
return RR->getKind() == rrkIntToPtr;
return RR->getKind() == RejectReasonKind::IntToPtr;
}
//===----------------------------------------------------------------------===//
// ReportAlloca.
ReportAlloca::ReportAlloca(Instruction *Inst)
: ReportOther(rrkAlloca), Inst(Inst) {}
: ReportOther(RejectReasonKind::Alloca), Inst(Inst) {}
std::string ReportAlloca::getMessage() const {
return "Alloca instruction: " + *Inst;
@ -495,14 +498,14 @@ const DebugLoc &ReportAlloca::getDebugLoc() const {
}
bool ReportAlloca::classof(const RejectReason *RR) {
return RR->getKind() == rrkAlloca;
return RR->getKind() == RejectReasonKind::Alloca;
}
//===----------------------------------------------------------------------===//
// ReportUnknownInst.
ReportUnknownInst::ReportUnknownInst(Instruction *Inst)
: ReportOther(rrkUnknownInst), Inst(Inst) {}
: ReportOther(RejectReasonKind::UnknownInst), Inst(Inst) {}
std::string ReportUnknownInst::getMessage() const {
return "Unknown instruction: " + *Inst;
@ -513,12 +516,13 @@ const DebugLoc &ReportUnknownInst::getDebugLoc() const {
}
bool ReportUnknownInst::classof(const RejectReason *RR) {
return RR->getKind() == rrkUnknownInst;
return RR->getKind() == RejectReasonKind::UnknownInst;
}
//===----------------------------------------------------------------------===//
// ReportEntry.
ReportEntry::ReportEntry(BasicBlock *BB) : ReportOther(rrkEntry), BB(BB) {}
ReportEntry::ReportEntry(BasicBlock *BB)
: ReportOther(RejectReasonKind::Entry), BB(BB) {}
std::string ReportEntry::getMessage() const {
return "Region containing entry block of function is invalid!";
@ -529,13 +533,13 @@ const DebugLoc &ReportEntry::getDebugLoc() const {
}
bool ReportEntry::classof(const RejectReason *RR) {
return RR->getKind() == rrkEntry;
return RR->getKind() == RejectReasonKind::Entry;
}
//===----------------------------------------------------------------------===//
// ReportUnprofitable.
ReportUnprofitable::ReportUnprofitable(Region *R)
: ReportOther(rrkUnprofitable), R(R) {}
: ReportOther(RejectReasonKind::Unprofitable), R(R) {}
std::string ReportUnprofitable::getMessage() const {
return "Region can not profitably be optimized!";
@ -555,6 +559,6 @@ const DebugLoc &ReportUnprofitable::getDebugLoc() const {
}
bool ReportUnprofitable::classof(const RejectReason *RR) {
return RR->getKind() == rrkUnprofitable;
return RR->getKind() == RejectReasonKind::Unprofitable;
}
} // namespace polly