Enclose instruction rdhwr with directives, which are needed when target is
authorAkira Hatanaka <ahatanaka@mips.com>
Thu, 5 Jul 2012 19:26:38 +0000 (19:26 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Thu, 5 Jul 2012 19:26:38 +0000 (19:26 +0000)
mips32 rev1 (the directives are emitted when target is mips32r2 too).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159770 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp

index 6886b1745240c888c686b974802c0f44882a1882..227fd387f2c8db63e5ef95d8edc36ce9fd53d401 100644 (file)
@@ -13,6 +13,7 @@
 
 #define DEBUG_TYPE "asm-printer"
 #include "MipsInstPrinter.h"
+#include "MipsInstrInfo.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
@@ -68,8 +69,25 @@ void MipsInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
 
 void MipsInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
                                 StringRef Annot) {
+  switch (MI->getOpcode()) {
+  default:
+    break;
+  case Mips::RDHWR:
+  case Mips::RDHWR64:
+    O << "\t.set\tpush\n";
+    O << "\t.set\tmips32r2\n";
+  }
+
   printInstruction(MI, O);
   printAnnotation(O, Annot);
+
+  switch (MI->getOpcode()) {
+  default:
+    break;
+  case Mips::RDHWR:
+  case Mips::RDHWR64:
+    O << "\n\t.set\tpop";
+  }
 }
 
 static void printExpr(const MCExpr *Expr, raw_ostream &OS) {