[llvm] r301827 - [Hexagon] Give better error messages for solo instruction errors
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Mon May 1 13:06:01 PDT 2017
Author: kparzysz
Date: Mon May 1 15:06:01 2017
New Revision: 301827
URL: http://llvm.org/viewvc/llvm-project?rev=301827&view=rev
Log:
[Hexagon] Give better error messages for solo instruction errors
Patch by Colin LeMahieu.
Added:
llvm/trunk/test/MC/Hexagon/PacketRules/
llvm/trunk/test/MC/Hexagon/PacketRules/solo.s
llvm/trunk/test/MC/Hexagon/multiple_errs.s
Modified:
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp?rev=301827&r1=301826&r2=301827&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp Mon May 1 15:06:01 2017
@@ -484,16 +484,16 @@ bool HexagonMCChecker::checkRegisters()
// Check for legal use of solo insns.
bool HexagonMCChecker::checkSolo() {
- if (HexagonMCInstrInfo::isBundle(MCB) &&
- HexagonMCInstrInfo::bundleSize(MCB) > 1) {
+ if (HexagonMCInstrInfo::bundleSize(MCB) > 1)
for (auto const &I : HexagonMCInstrInfo::bundleInstructions(MCB)) {
if (llvm::HexagonMCInstrInfo::isSolo(MCII, *I.getInst())) {
- reportError(
- "instruction cannot appear in packet with other instructions");
+ SMLoc Loc = I.getInst()->getLoc();
+ reportError(Loc, "Instruction is marked `isSolo' and "
+ "cannot have other instructions in "
+ "the same packet");
return false;
}
}
- }
return true;
}
@@ -575,8 +575,12 @@ void HexagonMCChecker::reportErrorNewVal
}
void HexagonMCChecker::reportError(llvm::Twine const &Msg) {
+ reportError(MCB.getLoc(), Msg);
+}
+
+void HexagonMCChecker::reportError(SMLoc Loc, llvm::Twine const &Msg) {
if (ReportErrors)
- Context.reportError(MCB.getLoc(), Msg);
+ Context.reportError(Loc, Msg);
}
void HexagonMCChecker::reportWarning(llvm::Twine const &Msg) {
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h?rev=301827&r1=301826&r2=301827&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h Mon May 1 15:06:01 2017
@@ -118,7 +118,6 @@ class HexagonMCChecker {
bool checkSolo();
bool checkShuffle();
bool checkSlots();
- bool checkSize();
static void compoundRegisterMap(unsigned &);
@@ -141,6 +140,7 @@ public:
bool check(bool FullCheck = true);
void reportErrorRegisters(unsigned Register);
void reportErrorNewValue(unsigned Register);
+ void reportError(SMLoc Loc, llvm::Twine const &Msg);
void reportError(llvm::Twine const &Msg);
void reportWarning(llvm::Twine const &Msg);
};
Added: llvm/trunk/test/MC/Hexagon/PacketRules/solo.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Hexagon/PacketRules/solo.s?rev=301827&view=auto
==============================================================================
--- llvm/trunk/test/MC/Hexagon/PacketRules/solo.s (added)
+++ llvm/trunk/test/MC/Hexagon/PacketRules/solo.s Mon May 1 15:06:01 2017
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -arch=hexagon -filetype=asm %s 2>%t; FileCheck %s <%t
+
+{ brkpt
+ r0 = r0 }
+# CHECK: 3:3: error: Instruction is marked `isSolo' and cannot have other instructions in the same packet
Added: llvm/trunk/test/MC/Hexagon/multiple_errs.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Hexagon/multiple_errs.s?rev=301827&view=auto
==============================================================================
--- llvm/trunk/test/MC/Hexagon/multiple_errs.s (added)
+++ llvm/trunk/test/MC/Hexagon/multiple_errs.s Mon May 1 15:06:01 2017
@@ -0,0 +1,10 @@
+# RUN: not llvm-mc -arch=hexagon -filetype=asm %s 2> %t; FileCheck %s < %t
+#
+
+{
+ if (!p0) r0=r1;
+ if (!p0) r0=r2;
+ trap0(#15);
+}
+# CHECK: error: register `R0' modified more than once
+# CHECK: error: Instruction is marked `isSolo' and cannot have other instructions in the same packet
More information about the llvm-commits
mailing list