summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h
diff options
context:
space:
mode:
authorJF Bastien <jfbastien@apple.com>2018-09-07 23:08:26 +0000
committerJF Bastien <jfbastien@apple.com>2018-09-07 23:08:26 +0000
commit28655081a476d8808e9e2c0900d4ca87fb17abe3 (patch)
tree0d3cc6e818710083eda5cd6472b6a9c7798cd770 /llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h
parentf803b23879d9e1d9415ec1875713534dcc203df5 (diff)
downloadbcm5719-llvm-28655081a476d8808e9e2c0900d4ca87fb17abe3.tar.gz
bcm5719-llvm-28655081a476d8808e9e2c0900d4ca87fb17abe3.zip
ADT: add <bit> header, implement C++20 bit_cast, use
Summary: I saw a few places that were punning through a union of FP and integer, and that made me sad. Luckily, C++20 adds bit_cast for exactly that purpose. Implement our own version in ADT (without constexpr, leaving us a bit sad), and use it in the few places my grep-fu found silly union punning. Reviewers: javed.absar Subscribers: dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D51693 llvm-svn: 341728
Diffstat (limited to 'llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h')
-rw-r--r--llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h
index f472b215431..e450d3f5d75 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h
@@ -627,27 +627,22 @@ namespace ARM_AM {
//
inline float getFPImmFloat(unsigned Imm) {
// We expect an 8-bit binary encoding of a floating-point number here.
- union {
- uint32_t I;
- float F;
- } FPUnion;
uint8_t Sign = (Imm >> 7) & 0x1;
uint8_t Exp = (Imm >> 4) & 0x7;
uint8_t Mantissa = Imm & 0xf;
- // 8-bit FP iEEEE Float Encoding
+ // 8-bit FP IEEE Float Encoding
// abcd efgh aBbbbbbc defgh000 00000000 00000000
//
// where B = NOT(b);
-
- FPUnion.I = 0;
- FPUnion.I |= Sign << 31;
- FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
- FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
- FPUnion.I |= (Exp & 0x3) << 23;
- FPUnion.I |= Mantissa << 19;
- return FPUnion.F;
+ uint32_t I = 0;
+ I |= Sign << 31;
+ I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
+ I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
+ I |= (Exp & 0x3) << 23;
+ I |= Mantissa << 19;
+ return bit_cast<float>(F);
}
/// getFP16Imm - Return an 8-bit floating-point version of the 16-bit
OpenPOWER on IntegriCloud