From: Craig Topper Date: Wed, 8 Mar 2023 18:14:34 +0000 (-0800) Subject: [RISCV] Make getFPImm return a float instead of a uint32_t. NFC X-Git-Tag: upstream/17.0.6~15486 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fb0b1b8d7e75c442b4ae2f1564e1e703aca98b4;p=platform%2Fupstream%2Fllvm.git [RISCV] Make getFPImm return a float instead of a uint32_t. NFC The one caller bitcasted the uint32_t to float anyway. --- diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h index 22b6a73..afefdd2 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h @@ -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(I); } /// getLoadFP32Imm - Return a 5-bit binary encoding of the 32-bit diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp index 96225b4..e54f712 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp @@ -165,7 +165,7 @@ void RISCVInstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNo, else if (MO.getImm() == 31) O << "nan"; else - O << bit_cast(RISCVLoadFPImm::getFPImm(MO.getImm())); + O << RISCVLoadFPImm::getFPImm(MO.getImm()); } void RISCVInstPrinter::printZeroOffsetMemOp(const MCInst *MI, unsigned OpNo,