[RISCV] Make getFPImm return a float instead of a uint32_t. NFC
authorCraig Topper <craig.topper@sifive.com>
Wed, 8 Mar 2023 18:14:34 +0000 (10:14 -0800)
committerCraig Topper <craig.topper@sifive.com>
Wed, 8 Mar 2023 18:32:03 +0000 (10:32 -0800)
The one caller bitcasted the uint32_t to float anyway.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp

index 22b6a73..afefdd2 100644 (file)
@@ -375,7 +375,7 @@ static inline int getLoadFPImm(uint8_t Sign, uint8_t Exp, uint8_t Mantissa) {
 }
 
 namespace RISCVLoadFPImm {
-inline static uint32_t getFPImm(unsigned Imm) {
+inline static float getFPImm(unsigned Imm) {
   assert(Imm != 1 && Imm != 30 && Imm != 31 && "Unsupported immediate");
   uint8_t Sign;
   uint8_t Exp;
@@ -391,7 +391,8 @@ inline static uint32_t getFPImm(unsigned Imm) {
     Mantissa = LoadFPImmArr[Imm - 1].second;
   }
 
-  return Sign << 31 | Exp << 23 | Mantissa << 20;
+  uint32_t I = Sign << 31 | Exp << 23 | Mantissa << 20;
+  return bit_cast<float>(I);
 }
 
 /// getLoadFP32Imm - Return a 5-bit binary encoding of the 32-bit
index 96225b4..e54f712 100644 (file)
@@ -165,7 +165,7 @@ void RISCVInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNo,
   else if (MO.getImm() == 31)
     O << "nan";
   else
-    O << bit_cast<float>(RISCVLoadFPImm::getFPImm(MO.getImm()));
+    O << RISCVLoadFPImm::getFPImm(MO.getImm());
 }
 
 void RISCVInstPrinter::printZeroOffsetMemOp(const MCInst *MI, unsigned OpNo,