summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mc/Disassembler.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-08-17 17:44:15 +0000
committerOwen Anderson <resistor@mac.com>2011-08-17 17:44:15 +0000
commita4043c4b3237c4c37b3a1aba838e6255be4fb742 (patch)
tree400786eb5474d9a5da56ae61b08bd1d80f5af242 /llvm/tools/llvm-mc/Disassembler.cpp
parent3fce368d879815920f384ffb44177e447ef411c6 (diff)
downloadbcm5719-llvm-a4043c4b3237c4c37b3a1aba838e6255be4fb742.tar.gz
bcm5719-llvm-a4043c4b3237c4c37b3a1aba838e6255be4fb742.zip
Allow the MCDisassembler to return a "soft fail" status code, indicating an instruction that is disassemblable, but invalid. Only used for ARM UNPREDICTABLE instructions at the moment.
Patch by James Molloy. llvm-svn: 137830
Diffstat (limited to 'llvm/tools/llvm-mc/Disassembler.cpp')
-rw-r--r--llvm/tools/llvm-mc/Disassembler.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/tools/llvm-mc/Disassembler.cpp b/llvm/tools/llvm-mc/Disassembler.cpp
index c389f6a9530..626724c58e5 100644
--- a/llvm/tools/llvm-mc/Disassembler.cpp
+++ b/llvm/tools/llvm-mc/Disassembler.cpp
@@ -65,15 +65,26 @@ static bool PrintInsts(const MCDisassembler &DisAsm,
for (Index = 0; Index < Bytes.size(); Index += Size) {
MCInst Inst;
- if (DisAsm.getInstruction(Inst, Size, memoryObject, Index,
- /*REMOVE*/ nulls())) {
- Printer.printInst(&Inst, Out);
- Out << "\n";
- } else {
+ MCDisassembler::DecodeStatus S;
+ S = DisAsm.getInstruction(Inst, Size, memoryObject, Index,
+ /*REMOVE*/ nulls());
+ switch (S) {
+ case MCDisassembler::Fail:
SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
"invalid instruction encoding", "warning");
if (Size == 0)
Size = 1; // skip illegible bytes
+ break;
+
+ case MCDisassembler::SoftFail:
+ SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
+ "potentially undefined instruction encoding", "warning");
+ // Fall through
+
+ case MCDisassembler::Success:
+ Printer.printInst(&Inst, Out);
+ Out << "\n";
+ break;
}
}
OpenPOWER on IntegriCloud