summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-09-23 18:05:37 +0000
committerJim Grosbach <grosbach@apple.com>2010-09-23 18:05:37 +0000
commit85030544104b6bf0273140e13eb232804d9ab2bf (patch)
tree3db31b59d11ce62b7456332f41405c9d9789d0b6 /llvm/lib/Target/ARM/ARMAsmPrinter.cpp
parent6366d1b85886d08397b13943dfb66a30f84ca282 (diff)
downloadbcm5719-llvm-85030544104b6bf0273140e13eb232804d9ab2bf.tar.gz
bcm5719-llvm-85030544104b6bf0273140e13eb232804d9ab2bf.zip
Clean up the 'trap' instruction printing a bit. Non-Darwin assemblers don't
(yet) recognize the 'trap' mnemonic, so we use .short/.long to emit the opcode directly. On Darwin, however, we do want the mnemonic for more readable assembly code and better disassembly. Adjust the .td file to use the 'trap' mnemonic and handle using the binutils workaround in the assembly printer. Also tweak the formatting of the opcode values to make them consistent between the MC printer and the old printer. llvm-svn: 114679
Diffstat (limited to 'llvm/lib/Target/ARM/ARMAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMAsmPrinter.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index 8fa7131267b..7bf76421439 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -1210,6 +1210,16 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
OS << '\t';
printRegisterList(MI, 5, OS);
} else
+ // TRAP and tTRAP need special handling for non-Darwin. The GNU binutils
+ // don't (yet) support the 'trap' mnemonic. (Use decimal, not hex, to
+ // be consistent with the MC instruction printer.)
+ // FIXME: This really should be in AsmPrinter/ARMInstPrinter.cpp, not here.
+ // Need a way to ask "isTargetDarwin()" there, first, though.
+ if (MI->getOpcode() == ARM::TRAP && !Subtarget->isTargetDarwin()) {
+ OS << "\t.long\t2147348462\t\t" << MAI->getCommentString() << "trap";
+ } else if (MI->getOpcode() == ARM::tTRAP && !Subtarget->isTargetDarwin()) {
+ OS << "\t.short\t57086\t\t\t" << MAI->getCommentString() << " trap";
+ } else
printInstruction(MI, OS);
// Output the instruction to the stream
@@ -1714,6 +1724,30 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
EmitJumpTable(MI);
return;
}
+ case ARM::TRAP: {
+ // Non-Darwin binutils don't yet support the "trap" mnemonic.
+ // FIXME: Remove this special case when they do.
+ if (!Subtarget->isTargetDarwin()) {
+ //.long 0xe7ffdefe ${:comment} trap
+ uint32_t Val = 0xe7ffdefee;
+ OutStreamer.AddComment("trap");
+ OutStreamer.EmitIntValue(Val, 4);
+ return;
+ }
+ break;
+ }
+ case ARM::tTRAP: {
+ // Non-Darwin binutils don't yet support the "trap" mnemonic.
+ // FIXME: Remove this special case when they do.
+ if (!Subtarget->isTargetDarwin()) {
+ //.long 0xe7ffdefe ${:comment} trap
+ uint32_t Val = 0xdefe;
+ OutStreamer.AddComment("trap");
+ OutStreamer.EmitIntValue(Val, 2);
+ return;
+ }
+ break;
+ }
}
MCInst TmpInst;
OpenPOWER on IntegriCloud