forked from OSchip/llvm-project
[globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash.
llvm-svn: 317132
This commit is contained in:
parent
cf82cc3d54
commit
466fe399b8
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg);
|
||||||
|
|
||||||
void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg);
|
void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg);
|
||||||
void PrintWarning(const char *Loc, const Twine &Msg);
|
void PrintWarning(const char *Loc, const Twine &Msg);
|
||||||
void PrintWarning(const Twine &Msg);
|
void PrintWarning(const Twine &Msg);
|
||||||
|
|
|
@ -39,6 +39,10 @@ static void PrintMessage(ArrayRef<SMLoc> Loc, SourceMgr::DiagKind Kind,
|
||||||
"instantiated from multiclass");
|
"instantiated from multiclass");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg) {
|
||||||
|
PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg);
|
||||||
|
}
|
||||||
|
|
||||||
void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg) {
|
void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg) {
|
||||||
PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
|
PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,6 +299,19 @@ void RegisterBankEmitter::run(raw_ostream &OS) {
|
||||||
Banks.push_back(Bank);
|
Banks.push_back(Bank);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn about ambiguous MIR caused by register bank/class name clashes.
|
||||||
|
for (const auto &Class : Records.getAllDerivedDefinitions("RegisterClass")) {
|
||||||
|
for (const auto &Bank : Banks) {
|
||||||
|
if (Bank.getName().lower() == Class->getName().lower()) {
|
||||||
|
PrintWarning(Bank.getDef().getLoc(), "Register bank names should be "
|
||||||
|
"distinct from register classes "
|
||||||
|
"to avoid ambiguous MIR");
|
||||||
|
PrintNote(Bank.getDef().getLoc(), "RegisterBank was declared here");
|
||||||
|
PrintNote(Class->getLoc(), "RegisterClass was declared here");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emitSourceFileHeader("Register Bank Source Fragments", OS);
|
emitSourceFileHeader("Register Bank Source Fragments", OS);
|
||||||
OS << "#ifdef GET_REGBANK_DECLARATIONS\n"
|
OS << "#ifdef GET_REGBANK_DECLARATIONS\n"
|
||||||
<< "#undef GET_REGBANK_DECLARATIONS\n";
|
<< "#undef GET_REGBANK_DECLARATIONS\n";
|
||||||
|
|
Loading…
Reference in New Issue