]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 2013-2015 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 | #ifndef FTLIntrinsicRepository_h | |
27 | #define FTLIntrinsicRepository_h | |
28 | ||
29 | #if ENABLE(FTL_JIT) | |
30 | ||
31 | #include "DFGOperations.h" | |
32 | #include "FTLAbbreviations.h" | |
33 | #include "FTLCommonValues.h" | |
34 | ||
35 | namespace JSC { namespace FTL { | |
36 | ||
37 | #define FOR_EACH_FTL_INTRINSIC(macro) \ | |
38 | macro(ceil64, "llvm.ceil.f64", functionType(doubleType, doubleType)) \ | |
39 | macro(ctlz32, "llvm.ctlz.i32", functionType(int32, int32, boolean)) \ | |
40 | macro(addWithOverflow32, "llvm.sadd.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ | |
41 | macro(addWithOverflow64, "llvm.sadd.with.overflow.i64", functionType(structType(m_context, int64, boolean), int64, int64)) \ | |
42 | macro(doubleAbs, "llvm.fabs.f64", functionType(doubleType, doubleType)) \ | |
43 | macro(doubleSin, "llvm.sin.f64", functionType(doubleType, doubleType)) \ | |
44 | macro(doubleCos, "llvm.cos.f64", functionType(doubleType, doubleType)) \ | |
45 | macro(doublePow, "llvm.pow.f64", functionType(doubleType, doubleType, doubleType)) \ | |
46 | macro(doublePowi, "llvm.powi.f64", functionType(doubleType, doubleType, int32)) \ | |
47 | macro(doubleSqrt, "llvm.sqrt.f64", functionType(doubleType, doubleType)) \ | |
48 | macro(doubleLog, "llvm.log.f64", functionType(doubleType, doubleType)) \ | |
49 | macro(frameAddress, "llvm.frameaddress", functionType(pointerType(int8), int32)) \ | |
50 | macro(mulWithOverflow32, "llvm.smul.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ | |
51 | macro(mulWithOverflow64, "llvm.smul.with.overflow.i64", functionType(structType(m_context, int64, boolean), int64, int64)) \ | |
52 | macro(patchpointInt64, "llvm.experimental.patchpoint.i64", functionType(int64, int64, int32, ref8, int32, Variadic)) \ | |
53 | macro(patchpointVoid, "llvm.experimental.patchpoint.void", functionType(voidType, int64, int32, ref8, int32, Variadic)) \ | |
54 | macro(stackmap, "llvm.experimental.stackmap", functionType(voidType, int64, int32, Variadic)) \ | |
55 | macro(subWithOverflow32, "llvm.ssub.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ | |
56 | macro(subWithOverflow64, "llvm.ssub.with.overflow.i64", functionType(structType(m_context, int64, boolean), int64, int64)) \ | |
57 | macro(trap, "llvm.trap", functionType(voidType)) \ | |
58 | macro(x86SSE2CvtTSD2SI, "llvm.x86.sse2.cvttsd2si", functionType(int32, vectorType(doubleType, 2))) | |
59 | ||
60 | #define FOR_EACH_FUNCTION_TYPE(macro) \ | |
61 | macro(C_JITOperation_EC, functionType(intPtr, intPtr, intPtr)) \ | |
62 | macro(C_JITOperation_ECZ, functionType(intPtr, intPtr, intPtr, int32)) \ | |
63 | macro(C_JITOperation_ECZC, functionType(intPtr, intPtr, intPtr, int32, intPtr)) \ | |
64 | macro(C_JITOperation_EGC, functionType(intPtr, intPtr, intPtr, intPtr)) \ | |
65 | macro(C_JITOperation_EJ, functionType(intPtr, intPtr, int64)) \ | |
66 | macro(C_JITOperation_EJssJss, functionType(intPtr, intPtr, intPtr, intPtr)) \ | |
67 | macro(C_JITOperation_EJssJssJss, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
68 | macro(C_JITOperation_ESt, functionType(intPtr, intPtr, intPtr)) \ | |
69 | macro(C_JITOperation_EStJscSymtab, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
70 | macro(C_JITOperation_EStRZJsf, functionType(intPtr, intPtr, intPtr, intPtr, int32, intPtr)) \ | |
71 | macro(C_JITOperation_EStRZJsfL, functionType(intPtr, intPtr, intPtr, intPtr, int32, intPtr, intPtr)) \ | |
72 | macro(C_JITOperation_EStZ, functionType(intPtr, intPtr, intPtr, int32)) \ | |
73 | macro(C_JITOperation_EStZZ, functionType(intPtr, intPtr, intPtr, int32, int32)) \ | |
74 | macro(C_JITOperation_EZ, functionType(intPtr, intPtr, int32)) \ | |
75 | macro(D_JITOperation_D, functionType(doubleType, doubleType)) \ | |
76 | macro(T_JITOperation_EJss, functionType(intPtr, intPtr, intPtr)) \ | |
77 | macro(J_JITOperation_E, functionType(int64, intPtr)) \ | |
78 | macro(J_JITOperation_EA, functionType(int64, intPtr, intPtr)) \ | |
79 | macro(J_JITOperation_EAZ, functionType(int64, intPtr, intPtr, int32)) \ | |
80 | macro(J_JITOperation_ECJ, functionType(int64, intPtr, intPtr, int64)) \ | |
81 | macro(J_JITOperation_ECZ, functionType(int64, intPtr, intPtr, int32)) \ | |
82 | macro(J_JITOperation_EDA, functionType(int64, intPtr, doubleType, intPtr)) \ | |
83 | macro(J_JITOperation_EJ, functionType(int64, intPtr, int64)) \ | |
84 | macro(J_JITOperation_EJA, functionType(int64, intPtr, int64, intPtr)) \ | |
85 | macro(J_JITOperation_EJC, functionType(int64, intPtr, int64, intPtr)) \ | |
86 | macro(J_JITOperation_EJI, functionType(int64, intPtr, int64, intPtr)) \ | |
87 | macro(J_JITOperation_EJJ, functionType(int64, intPtr, int64, int64)) \ | |
88 | macro(J_JITOperation_EJscC, functionType(intPtr, intPtr, intPtr, intPtr)) \ | |
89 | macro(J_JITOperation_EJssZ, functionType(int64, intPtr, intPtr, int32)) \ | |
90 | macro(J_JITOperation_ESsiJI, functionType(int64, intPtr, intPtr, int64, intPtr)) \ | |
91 | macro(Jss_JITOperation_EZ, functionType(intPtr, intPtr, int32)) \ | |
92 | macro(P_JITOperation_E, functionType(intPtr, intPtr)) \ | |
93 | macro(P_JITOperation_EC, functionType(intPtr, intPtr, intPtr)) \ | |
94 | macro(P_JITOperation_EO, functionType(intPtr, intPtr, intPtr)) \ | |
95 | macro(P_JITOperation_ES, functionType(intPtr, intPtr, int64)) \ | |
96 | macro(P_JITOperation_EOS, functionType(intPtr, intPtr, intPtr, int64)) \ | |
97 | macro(P_JITOperation_ESt, functionType(intPtr, intPtr, intPtr)) \ | |
98 | macro(P_JITOperation_EStPS, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
99 | macro(P_JITOperation_EStSS, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
100 | macro(P_JITOperation_EStZ, functionType(intPtr, intPtr, intPtr, int32)) \ | |
101 | macro(Q_JITOperation_D, functionType(int64, doubleType)) \ | |
102 | macro(Q_JITOperation_J, functionType(int64, int64)) \ | |
103 | macro(S_JITOperation_EGC, functionType(intPtr, intPtr, intPtr, intPtr)) \ | |
104 | macro(S_JITOperation_EJ, functionType(intPtr, intPtr, int64)) \ | |
105 | macro(S_JITOperation_EJJ, functionType(intPtr, intPtr, int64, int64)) \ | |
106 | macro(S_JITOperation_J, functionType(intPtr, int64)) \ | |
107 | macro(V_JITOperation, functionType(voidType)) \ | |
108 | macro(V_JITOperation_EJJJ, functionType(voidType, intPtr, int64, int64, int64)) \ | |
109 | macro(V_JITOperation_EOZD, functionType(voidType, intPtr, intPtr, int32, doubleType)) \ | |
110 | macro(V_JITOperation_EOZJ, functionType(voidType, intPtr, intPtr, int32, int64)) \ | |
111 | macro(V_JITOperation_EC, functionType(voidType, intPtr, intPtr)) \ | |
112 | macro(V_JITOperation_ECb, functionType(voidType, intPtr, intPtr)) \ | |
113 | macro(V_JITOperation_EWs, functionType(voidType, intPtr, intPtr)) \ | |
114 | macro(V_JITOperation_EZJZZZ, functionType(voidType, intPtr, int32, int64, int32, int32, int32)) \ | |
115 | macro(V_JITOperation_J, functionType(voidType, int64)) \ | |
116 | macro(V_JITOperation_Z, functionType(voidType, int32)) \ | |
117 | macro(Z_JITOperation_D, functionType(int32, doubleType)) \ | |
118 | macro(Z_JITOperation_EC, functionType(int32, intPtr, intPtr)) \ | |
119 | macro(Z_JITOperation_EGC, functionType(int32, intPtr, intPtr, intPtr)) \ | |
120 | macro(Z_JITOperation_EJZ, functionType(int32, intPtr, int64, int32)) \ | |
121 | macro(Z_JITOperation_ESJss, functionType(int32, intPtr, intPtr, int64)) \ | |
122 | ||
123 | class IntrinsicRepository : public CommonValues { | |
124 | public: | |
125 | IntrinsicRepository(LContext); | |
126 | ||
127 | #define INTRINSIC_GETTER(ourName, llvmName, type) \ | |
128 | LValue ourName##Intrinsic() { \ | |
129 | if (!m_##ourName) \ | |
130 | return ourName##IntrinsicSlow(); \ | |
131 | return m_##ourName; \ | |
132 | } | |
133 | FOR_EACH_FTL_INTRINSIC(INTRINSIC_GETTER) | |
134 | #undef INTRINSIC_GETTER | |
135 | ||
136 | #define FUNCTION_TYPE_GETTER(typeName, type) \ | |
137 | LType typeName() \ | |
138 | { \ | |
139 | if (!m_##typeName) \ | |
140 | return typeName##Slow(); \ | |
141 | return m_##typeName; \ | |
142 | } | |
143 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_GETTER) | |
144 | #undef FUNCTION_TYPE_GETTER | |
145 | ||
146 | #define FUNCTION_TYPE_RESOLVER(typeName, type) \ | |
147 | LType operationType(JSC::typeName) \ | |
148 | { \ | |
149 | return typeName(); \ | |
150 | } | |
151 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_RESOLVER) | |
152 | #undef FUNCTION_TYPE_RESOLVER | |
153 | ||
154 | private: | |
155 | #define INTRINSIC_GETTER_SLOW_DECLARATION(ourName, llvmName, type) \ | |
156 | LValue ourName##IntrinsicSlow(); | |
157 | FOR_EACH_FTL_INTRINSIC(INTRINSIC_GETTER_SLOW_DECLARATION) | |
158 | #undef INTRINSIC_GETTER | |
159 | ||
160 | #define INTRINSIC_FIELD_DECLARATION(ourName, llvmName, type) LValue m_##ourName; | |
161 | FOR_EACH_FTL_INTRINSIC(INTRINSIC_FIELD_DECLARATION) | |
162 | #undef INTRINSIC_FIELD_DECLARATION | |
163 | ||
164 | #define FUNCTION_TYPE_GETTER_SLOW_DECLARATION(typeName, type) \ | |
165 | LType typeName##Slow(); | |
166 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_GETTER_SLOW_DECLARATION) | |
167 | #undef FUNCTION_TYPE_GETTER_SLOW_DECLARATION | |
168 | ||
169 | #define FUNCTION_TYPE_FIELD_DECLARATION(typeName, type) \ | |
170 | LType m_##typeName; | |
171 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_FIELD_DECLARATION) | |
172 | #undef FUNCTION_TYPE_FIELD_DECLARATION | |
173 | }; | |
174 | ||
175 | } } // namespace JSC::FTL | |
176 | ||
177 | #endif // ENABLE(FTL_JIT) | |
178 | ||
179 | #endif // FTLIntrinsicRepository_h | |
180 |