From: Daniel Sanders Date: Wed, 1 Nov 2017 22:13:05 +0000 (+0000) Subject: [globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=466fe399b87e3e9fac2bbe853e2200b4b146a5b3;p=platform%2Fupstream%2Fllvm.git [globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash. llvm-svn: 317132 --- diff --git a/llvm/include/llvm/TableGen/Error.h b/llvm/include/llvm/TableGen/Error.h index 3df658d..de4d3bf 100644 --- a/llvm/include/llvm/TableGen/Error.h +++ b/llvm/include/llvm/TableGen/Error.h @@ -19,6 +19,8 @@ namespace llvm { +void PrintNote(ArrayRef NoteLoc, const Twine &Msg); + void PrintWarning(ArrayRef WarningLoc, const Twine &Msg); void PrintWarning(const char *Loc, const Twine &Msg); void PrintWarning(const Twine &Msg); diff --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp index fd08935..b483017 100644 --- a/llvm/lib/TableGen/Error.cpp +++ b/llvm/lib/TableGen/Error.cpp @@ -39,6 +39,10 @@ static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, "instantiated from multiclass"); } +void PrintNote(ArrayRef NoteLoc, const Twine &Msg) { + PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg); +} + void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) { PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg); } diff --git a/llvm/utils/TableGen/RegisterBankEmitter.cpp b/llvm/utils/TableGen/RegisterBankEmitter.cpp index 293933f..5c64716 100644 --- a/llvm/utils/TableGen/RegisterBankEmitter.cpp +++ b/llvm/utils/TableGen/RegisterBankEmitter.cpp @@ -299,6 +299,19 @@ void RegisterBankEmitter::run(raw_ostream &OS) { 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); OS << "#ifdef GET_REGBANK_DECLARATIONS\n" << "#undef GET_REGBANK_DECLARATIONS\n";