• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "include/v8config.h"
7 #include "src/base/macros.h"
8 
9 namespace v8 {
10 namespace internal {
11 
12 // ISA constants. --------------------------------------------------------------
13 
14 // The following code initializes float/double variables with bit patterns
15 // without using static initializers (which is surprisingly difficult in
16 // C++).  These variables are used by client code as extern float16,
17 // extern float and extern double types, which works because (I think) the
18 // linker ignores the types.  This is kept in a separate source file to
19 // avoid breaking jumbo builds.
20 //
21 // TODO(mostynb): replace these with std::numeric_limits constexpr's where
22 // possible, and figure out how to replace *DefaultNaN with something clean,
23 // then move this code back into instructions-arm64.cc with the same types
24 // that client code uses.
25 
26 #if defined(V8_OS_WIN)
27 extern "C" {
28 #endif
29 
30 extern const uint16_t kFP16PositiveInfinity = 0x7C00;
31 extern const uint16_t kFP16NegativeInfinity = 0xFC00;
32 V8_EXPORT_PRIVATE extern const uint32_t kFP32PositiveInfinity = 0x7F800000;
33 V8_EXPORT_PRIVATE extern const uint32_t kFP32NegativeInfinity = 0xFF800000;
34 V8_EXPORT_PRIVATE extern const uint64_t kFP64PositiveInfinity =
35     0x7FF0000000000000UL;
36 V8_EXPORT_PRIVATE extern const uint64_t kFP64NegativeInfinity =
37     0xFFF0000000000000UL;
38 
39 // This value is a signalling NaN as both a double and as a float (taking the
40 // least-significant word).
41 V8_EXPORT_PRIVATE extern const uint64_t kFP64SignallingNaN = 0x7FF000007F800001;
42 V8_EXPORT_PRIVATE extern const uint32_t kFP32SignallingNaN = 0x7F800001;
43 
44 // A similar value, but as a quiet NaN.
45 V8_EXPORT_PRIVATE extern const uint64_t kFP64QuietNaN = 0x7FF800007FC00001;
46 V8_EXPORT_PRIVATE extern const uint32_t kFP32QuietNaN = 0x7FC00001;
47 
48 // The default NaN values (for FPCR.DN=1).
49 V8_EXPORT_PRIVATE extern const uint64_t kFP64DefaultNaN = 0x7FF8000000000000UL;
50 V8_EXPORT_PRIVATE extern const uint32_t kFP32DefaultNaN = 0x7FC00000;
51 extern const uint16_t kFP16DefaultNaN = 0x7E00;
52 
53 #if defined(V8_OS_WIN)
54 }  // end of extern "C"
55 #endif
56 
57 }  // namespace internal
58 }  // namespace v8
59