]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | /* |
2 | * Copyright (C) 2013, 2014 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(addWithOverflow32, "llvm.sadd.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ | |
39 | macro(addWithOverflow64, "llvm.sadd.with.overflow.i64", functionType(structType(m_context, int64, boolean), int64, int64)) \ | |
40 | macro(doubleAbs, "llvm.fabs.f64", functionType(doubleType, doubleType)) \ | |
41 | macro(doubleSin, "llvm.sin.f64", functionType(doubleType, doubleType)) \ | |
42 | macro(doubleCos, "llvm.cos.f64", functionType(doubleType, doubleType)) \ | |
43 | macro(doubleSqrt, "llvm.sqrt.f64", functionType(doubleType, doubleType)) \ | |
44 | macro(frameAddress, "llvm.frameaddress", functionType(pointerType(int8), int32)) \ | |
45 | macro(mulWithOverflow32, "llvm.smul.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ | |
46 | macro(mulWithOverflow64, "llvm.smul.with.overflow.i64", functionType(structType(m_context, int64, boolean), int64, int64)) \ | |
47 | macro(patchpointInt64, "llvm.experimental.patchpoint.i64", functionType(int64, int64, int32, ref8, int32, Variadic)) \ | |
48 | macro(patchpointVoid, "llvm.experimental.patchpoint.void", functionType(voidType, int64, int32, ref8, int32, Variadic)) \ | |
49 | macro(stackmap, "llvm.experimental.stackmap", functionType(voidType, int64, int32, Variadic)) \ | |
50 | macro(subWithOverflow32, "llvm.ssub.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ | |
51 | macro(subWithOverflow64, "llvm.ssub.with.overflow.i64", functionType(structType(m_context, int64, boolean), int64, int64)) \ | |
52 | macro(trap, "llvm.trap", functionType(voidType)) \ | |
53 | macro(x86SSE2CvtTSD2SI, "llvm.x86.sse2.cvttsd2si", functionType(int32, vectorType(doubleType, 2))) | |
54 | ||
55 | #define FOR_EACH_FUNCTION_TYPE(macro) \ | |
56 | macro(C_JITOperation_EC, functionType(intPtr, intPtr, intPtr)) \ | |
57 | macro(C_JITOperation_EJ, functionType(intPtr, intPtr, int64)) \ | |
58 | macro(C_JITOperation_EJssJss, functionType(intPtr, intPtr, intPtr, intPtr)) \ | |
59 | macro(C_JITOperation_EJssJssJss, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
60 | macro(C_JITOperation_ESt, functionType(intPtr, intPtr, intPtr)) \ | |
61 | macro(D_JITOperation_D, functionType(doubleType, doubleType)) \ | |
62 | macro(I_JITOperation_EJss, functionType(intPtr, intPtr, intPtr)) \ | |
63 | macro(J_JITOperation_E, functionType(int64, intPtr)) \ | |
64 | macro(J_JITOperation_EA, functionType(int64, intPtr, intPtr)) \ | |
65 | macro(J_JITOperation_EAZ, functionType(int64, intPtr, intPtr, int32)) \ | |
66 | macro(J_JITOperation_EDA, functionType(int64, intPtr, doubleType, intPtr)) \ | |
67 | macro(J_JITOperation_EJ, functionType(int64, intPtr, int64)) \ | |
68 | macro(J_JITOperation_EJA, functionType(int64, intPtr, int64, intPtr)) \ | |
69 | macro(J_JITOperation_EJJ, functionType(int64, intPtr, int64, int64)) \ | |
70 | macro(J_JITOperation_EJssZ, functionType(int64, intPtr, intPtr, int32)) \ | |
71 | macro(J_JITOperation_ESsiJI, functionType(int64, intPtr, intPtr, int64, intPtr)) \ | |
72 | macro(Jss_JITOperation_EZ, functionType(intPtr, intPtr, int32)) \ | |
73 | macro(P_JITOperation_E, functionType(intPtr, intPtr)) \ | |
74 | macro(P_JITOperation_EC, functionType(intPtr, intPtr, intPtr)) \ | |
75 | macro(P_JITOperation_EO, functionType(intPtr, intPtr, intPtr)) \ | |
76 | macro(P_JITOperation_ES, functionType(intPtr, intPtr, int64)) \ | |
77 | macro(P_JITOperation_EOS, functionType(intPtr, intPtr, intPtr, int64)) \ | |
78 | macro(P_JITOperation_ESt, functionType(intPtr, intPtr, intPtr)) \ | |
79 | macro(P_JITOperation_EStPS, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
80 | macro(P_JITOperation_EStSS, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \ | |
81 | macro(P_JITOperation_EStZ, functionType(intPtr, intPtr, intPtr, int32)) \ | |
82 | macro(Q_JITOperation_D, functionType(int64, doubleType)) \ | |
83 | macro(Q_JITOperation_J, functionType(int64, int64)) \ | |
84 | macro(S_JITOperation_EJ, functionType(intPtr, intPtr, int64)) \ | |
85 | macro(S_JITOperation_EJJ, functionType(intPtr, intPtr, int64, int64)) \ | |
86 | macro(S_JITOperation_J, functionType(intPtr, int64)) \ | |
87 | macro(V_JITOperation, functionType(voidType)) \ | |
88 | macro(V_JITOperation_EJJJ, functionType(voidType, intPtr, int64, int64, int64)) \ | |
89 | macro(V_JITOperation_EOZD, functionType(voidType, intPtr, intPtr, int32, doubleType)) \ | |
90 | macro(V_JITOperation_EOZJ, functionType(voidType, intPtr, intPtr, int32, int64)) \ | |
91 | macro(V_JITOperation_EC, functionType(voidType, intPtr, intPtr)) \ | |
92 | macro(V_JITOperation_ECb, functionType(voidType, intPtr, intPtr)) \ | |
93 | macro(V_JITOperation_EVwsJ, functionType(voidType, intPtr, intPtr, int64)) \ | |
94 | macro(Z_JITOperation_D, functionType(int32, doubleType)) | |
95 | ||
96 | class IntrinsicRepository : public CommonValues { | |
97 | public: | |
98 | IntrinsicRepository(LContext); | |
99 | ||
100 | #define INTRINSIC_GETTER(ourName, llvmName, type) \ | |
101 | LValue ourName##Intrinsic() { \ | |
102 | if (!m_##ourName) \ | |
103 | return ourName##IntrinsicSlow(); \ | |
104 | return m_##ourName; \ | |
105 | } | |
106 | FOR_EACH_FTL_INTRINSIC(INTRINSIC_GETTER) | |
107 | #undef INTRINSIC_GETTER | |
108 | ||
109 | #define FUNCTION_TYPE_GETTER(typeName, type) \ | |
110 | LType typeName() \ | |
111 | { \ | |
112 | if (!m_##typeName) \ | |
113 | return typeName##Slow(); \ | |
114 | return m_##typeName; \ | |
115 | } | |
116 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_GETTER) | |
117 | #undef FUNCTION_TYPE_GETTER | |
118 | ||
119 | #define FUNCTION_TYPE_RESOLVER(typeName, type) \ | |
120 | LType operationType(JSC::typeName) \ | |
121 | { \ | |
122 | return typeName(); \ | |
123 | } | |
124 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_RESOLVER) | |
125 | #undef FUNCTION_TYPE_RESOLVER | |
126 | ||
127 | private: | |
128 | #define INTRINSIC_GETTER_SLOW_DECLARATION(ourName, llvmName, type) \ | |
129 | LValue ourName##IntrinsicSlow(); | |
130 | FOR_EACH_FTL_INTRINSIC(INTRINSIC_GETTER_SLOW_DECLARATION) | |
131 | #undef INTRINSIC_GETTER | |
132 | ||
133 | #define INTRINSIC_FIELD_DECLARATION(ourName, llvmName, type) LValue m_##ourName; | |
134 | FOR_EACH_FTL_INTRINSIC(INTRINSIC_FIELD_DECLARATION) | |
135 | #undef INTRINSIC_FIELD_DECLARATION | |
136 | ||
137 | #define FUNCTION_TYPE_GETTER_SLOW_DECLARATION(typeName, type) \ | |
138 | LType typeName##Slow(); | |
139 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_GETTER_SLOW_DECLARATION) | |
140 | #undef FUNCTION_TYPE_GETTER_SLOW_DECLARATION | |
141 | ||
142 | #define FUNCTION_TYPE_FIELD_DECLARATION(typeName, type) \ | |
143 | LType m_##typeName; | |
144 | FOR_EACH_FUNCTION_TYPE(FUNCTION_TYPE_FIELD_DECLARATION) | |
145 | #undef FUNCTION_TYPE_FIELD_DECLARATION | |
146 | }; | |
147 | ||
148 | } } // namespace JSC::FTL | |
149 | ||
150 | #endif // ENABLE(FTL_JIT) | |
151 | ||
152 | #endif // FTLIntrinsicRepository_h | |
153 |