[llvm] r259857 - Fix printing of f16 machine operands
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 16:50:19 PST 2016
Author: arsenm
Date: Thu Feb 4 18:50:18 2016
New Revision: 259857
URL: http://llvm.org/viewvc/llvm-project?rev=259857&view=rev
Log:
Fix printing of f16 machine operands
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.
This cannot currently be hit by any in-tree target.
Patch by Stanislav Mekhanoshin
Modified:
llvm/trunk/lib/CodeGen/MachineInstr.cpp
Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=259857&r1=259856&r2=259857&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Thu Feb 4 18:50:18 2016
@@ -372,10 +372,16 @@ void MachineOperand::print(raw_ostream &
getCImm()->getValue().print(OS, false);
break;
case MachineOperand::MO_FPImmediate:
- if (getFPImm()->getType()->isFloatTy())
+ if (getFPImm()->getType()->isFloatTy()) {
OS << getFPImm()->getValueAPF().convertToFloat();
- else
+ } 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;
case MachineOperand::MO_MachineBasicBlock:
OS << "<BB#" << getMBB()->getNumber() << ">";
More information about the llvm-commits
mailing list