1/*
2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#if ENABLE(B3_JIT)
29
30#include "B3Bank.h"
31#include "B3Type.h"
32#include "B3Width.h"
33
34namespace JSC { namespace B3 {
35
36template<typename> struct NativeTraits;
37
38template<> struct NativeTraits<int8_t> {
39 typedef int32_t CanonicalType;
40 static constexpr Bank bank = GP;
41 static constexpr Width width = Width8;
42 static constexpr Type type = Int32;
43};
44
45template<> struct NativeTraits<uint8_t> {
46 typedef int32_t CanonicalType;
47 static constexpr Bank bank = GP;
48 static constexpr Width width = Width8;
49 static constexpr Type type = Int32;
50};
51
52template<> struct NativeTraits<int16_t> {
53 typedef int32_t CanonicalType;
54 static constexpr Bank bank = GP;
55 static constexpr Width width = Width16;
56 static constexpr Type type = Int32;
57};
58
59template<> struct NativeTraits<uint16_t> {
60 typedef int32_t CanonicalType;
61 static constexpr Bank bank = GP;
62 static constexpr Width width = Width16;
63 static constexpr Type type = Int32;
64};
65
66template<> struct NativeTraits<int32_t> {
67 typedef int32_t CanonicalType;
68 static constexpr Bank bank = GP;
69 static constexpr Width width = Width32;
70 static constexpr Type type = Int32;
71};
72
73template<> struct NativeTraits<uint32_t> {
74 typedef int32_t CanonicalType;
75 static constexpr Bank bank = GP;
76 static constexpr Width width = Width32;
77 static constexpr Type type = Int32;
78};
79
80template<> struct NativeTraits<int64_t> {
81 typedef int64_t CanonicalType;
82 static constexpr Bank bank = GP;
83 static constexpr Width width = Width64;
84 static constexpr Type type = Int64;
85};
86
87template<> struct NativeTraits<uint64_t> {
88 typedef int64_t CanonicalType;
89 static constexpr Bank bank = GP;
90 static constexpr Width width = Width64;
91 static constexpr Type type = Int64;
92};
93
94template<> struct NativeTraits<float> {
95 typedef float CanonicalType;
96 static constexpr Bank bank = FP;
97 static constexpr Width width = Width32;
98 static constexpr Type type = Float;
99};
100
101template<> struct NativeTraits<double> {
102 typedef double CanonicalType;
103 static constexpr Bank bank = FP;
104 static constexpr Width width = Width64;
105 static constexpr Type type = Double;
106};
107
108} } // namespace JSC::B3
109
110#endif // ENABLE(B3_JIT)
111
112