1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <cstdint>
6 
7 namespace v8 {
8 namespace internal {
9 
10 // ISA constants. --------------------------------------------------------------
11 
12 // The following code initializes float/double variables with bit patterns
13 // without using static initializers (which is surprisingly difficult in
14 // C++).  These variables are used by client code as extern float16,
15 // extern float and extern double types, which works because (I think) the
16 // linker ignores the types.  This is kept in a separate source file to
17 // avoid breaking jumbo builds.
18 //
19 // TODO(mostynb): replace these with std::numeric_limits constexpr's where
20 // possible, and figure out how to replace *DefaultNaN with something clean,
21 // then move this code back into instructions-arm64.cc with the same types
22 // that client code uses.
23 
24 extern const uint16_t kFP16PositiveInfinity = 0x7C00;
25 extern const uint16_t kFP16NegativeInfinity = 0xFC00;
26 extern const uint32_t kFP32PositiveInfinity = 0x7F800000;
27 extern const uint32_t kFP32NegativeInfinity = 0xFF800000;
28 extern const uint64_t kFP64PositiveInfinity = 0x7FF0000000000000UL;
29 extern const uint64_t kFP64NegativeInfinity = 0xFFF0000000000000UL;
30 
31 // This value is a signalling NaN as both a double and as a float (taking the
32 // least-significant word).
33 extern const uint64_t kFP64SignallingNaN = 0x7FF000007F800001;
34 extern const uint32_t kFP32SignallingNaN = 0x7F800001;
35 
36 // A similar value, but as a quiet NaN.
37 extern const uint64_t kFP64QuietNaN = 0x7FF800007FC00001;
38 extern const uint32_t kFP32QuietNaN = 0x7FC00001;
39 
40 // The default NaN values (for FPCR.DN=1).
41 extern const uint64_t kFP64DefaultNaN = 0x7FF8000000000000UL;
42 extern const uint32_t kFP32DefaultNaN = 0x7FC00000;
43 extern const uint16_t kFP16DefaultNaN = 0x7E00;
44 
45 }  // namespace internal
46 }  // namespace v8
47