[llvm] 7fb0b1b - [RISCV] Make getFPImm return a float instead of a uint32_t. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 10:32:15 PST 2023
Author: Craig Topper
Date: 2023-03-08T10:32:03-08:00
New Revision: 7fb0b1b8d7e75c442b4ae2f1564e1e703aca98b4
URL: https://github.com/llvm/llvm-project/commit/7fb0b1b8d7e75c442b4ae2f1564e1e703aca98b4
DIFF: https://github.com/llvm/llvm-project/commit/7fb0b1b8d7e75c442b4ae2f1564e1e703aca98b4.diff
LOG: [RISCV] Make getFPImm return a float instead of a uint32_t. NFC
The one caller bitcasted the uint32_t to float anyway.
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index 22b6a73fac625..afefdd28ce1f1 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<float>(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 96225b4ae9f3c..e54f71279e7e9 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<float>(RISCVLoadFPImm::getFPImm(MO.getImm()));
+ O << RISCVLoadFPImm::getFPImm(MO.getImm());
}
void RISCVInstPrinter::printZeroOffsetMemOp(const MCInst *MI, unsigned OpNo,
More information about the llvm-commits
mailing list