[PATCH] D16869: Fix printing of f16 machine operands

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 16:09:54 PST 2016


rampitec created this revision.
rampitec added a reviewer: arsenm.
rampitec added a subscriber: llvm-commits.
rampitec set the repository for this revision to rL LLVM.

Only single and double FP immediates are correctly printed by MachineInstr::print() during debug output. Half float type goes to APFloat::convertToDouble() and hits assertion it is not a double semantics. This diff prints half machine operands correctly.

Repository:
  rL LLVM

http://reviews.llvm.org/D16869

Files:
  MachineInstr.cpp

Index: MachineInstr.cpp
===================================================================
--- MachineInstr.cpp
+++ MachineInstr.cpp
@@ -374,6 +374,12 @@
   case MachineOperand::MO_FPImmediate:
     if (getFPImm()->getType()->isFloatTy())
       OS << getFPImm()->getValueAPF().convertToFloat();
+    else if (getFPImm()->getType()->isHalfTy()) {
+      APFloat APF = getFPImm()->getValueAPF();
+      bool unused;
+      APF.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &unused);
+      OS << "half " << APF.convertToFloat();
+    }
     else
       OS << getFPImm()->getValueAPF().convertToDouble();
     break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16869.46847.patch
Type: text/x-patch
Size: 629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160204/24ca9415/attachment.bin>


More information about the llvm-commits mailing list