[llvm] r317132 - [globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash.
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 1 15:13:05 PDT 2017
Author: dsanders
Date: Wed Nov 1 15:13:05 2017
New Revision: 317132
URL: http://llvm.org/viewvc/llvm-project?rev=317132&view=rev
Log:
[globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash.
Modified:
llvm/trunk/include/llvm/TableGen/Error.h
llvm/trunk/lib/TableGen/Error.cpp
llvm/trunk/utils/TableGen/RegisterBankEmitter.cpp
Modified: llvm/trunk/include/llvm/TableGen/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Error.h?rev=317132&r1=317131&r2=317132&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Error.h (original)
+++ llvm/trunk/include/llvm/TableGen/Error.h Wed Nov 1 15:13:05 2017
@@ -19,6 +19,8 @@
namespace llvm {
+void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg);
+
void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg);
void PrintWarning(const char *Loc, const Twine &Msg);
void PrintWarning(const Twine &Msg);
Modified: llvm/trunk/lib/TableGen/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Error.cpp?rev=317132&r1=317131&r2=317132&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Error.cpp (original)
+++ llvm/trunk/lib/TableGen/Error.cpp Wed Nov 1 15:13:05 2017
@@ -39,6 +39,10 @@ static void PrintMessage(ArrayRef<SMLoc>
"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) {
PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
}
Modified: llvm/trunk/utils/TableGen/RegisterBankEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterBankEmitter.cpp?rev=317132&r1=317131&r2=317132&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/RegisterBankEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/RegisterBankEmitter.cpp Wed Nov 1 15:13:05 2017
@@ -299,6 +299,19 @@ void RegisterBankEmitter::run(raw_ostrea
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";
More information about the llvm-commits
mailing list