Add support for printing out floating point values from the ARM assembly
[oota-llvm.git] / lib / Target / ARM / InstPrinter / ARMInstPrinter.cpp
index 46616f8ebc9349fbc419093f5243d96882e5cc89..941c69d14ea182e8f0fcb4cc3c1811ddd3852477 100644 (file)
@@ -674,13 +674,36 @@ void ARMInstPrinter::printT2AddrModeSoRegOperand(const MCInst *MI,
 void ARMInstPrinter::printVFPf32ImmOperand(const MCInst *MI, unsigned OpNum,
                                            raw_ostream &O) {
   const MCOperand &MO = MI->getOperand(OpNum);
-  O << '#' << APInt(64, MO.getImm(), true).bitsToDouble();
+  O << '#';
+  if (MO.isFPImm()) {
+    O << (float)MO.getFPImm();
+  } else {
+    union {
+      uint32_t I;
+      float F;
+    } FPUnion;
+
+    FPUnion.I = MO.getImm();
+    O << FPUnion.F;
+  }
 }
 
 void ARMInstPrinter::printVFPf64ImmOperand(const MCInst *MI, unsigned OpNum,
                                            raw_ostream &O) {
   const MCOperand &MO = MI->getOperand(OpNum);
-  O << '#' << APInt(64, MO.getImm(), true).bitsToDouble();
+  O << '#';
+  if (MO.isFPImm()) {
+    O << MO.getFPImm();
+  } else {
+    // We expect the binary encoding of a floating point number here.
+    union {
+      uint64_t I;
+      double D;
+    } FPUnion;
+
+    FPUnion.I = MO.getImm();
+    O << FPUnion.D;
+  }
 }
 
 void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,