10e3c0090ae32944f5bd52f439e8254b53e481d3
[apple/javascriptcore.git] / dfg / DFGFlushFormat.h
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 DFGFlushFormat_h
27 #define DFGFlushFormat_h
28
29 #if ENABLE(DFG_JIT)
30
31 #include "DFGNodeFlags.h"
32 #include "DFGUseKind.h"
33 #include "DataFormat.h"
34 #include "DumpContext.h"
35 #include <wtf/PrintStream.h>
36
37 namespace JSC { namespace DFG {
38
39 enum FlushFormat {
40 DeadFlush,
41 FlushedInt32,
42 FlushedInt52,
43 FlushedDouble,
44 FlushedCell,
45 FlushedBoolean,
46 FlushedJSValue,
47 FlushedArguments,
48 ConflictingFlush
49 };
50
51 inline NodeFlags resultFor(FlushFormat format)
52 {
53 switch (format) {
54 case DeadFlush:
55 case FlushedJSValue:
56 case FlushedCell:
57 case ConflictingFlush:
58 case FlushedArguments:
59 return NodeResultJS;
60 case FlushedInt32:
61 return NodeResultInt32;
62 case FlushedInt52:
63 return NodeResultInt52;
64 case FlushedDouble:
65 return NodeResultDouble;
66 case FlushedBoolean:
67 return NodeResultBoolean;
68 }
69 RELEASE_ASSERT_NOT_REACHED();
70 return 0;
71 }
72
73 inline UseKind useKindFor(FlushFormat format)
74 {
75 switch (format) {
76 case DeadFlush:
77 case FlushedJSValue:
78 case ConflictingFlush:
79 case FlushedArguments:
80 return UntypedUse;
81 case FlushedCell:
82 return CellUse;
83 case FlushedInt32:
84 return Int32Use;
85 case FlushedInt52:
86 return Int52RepUse;
87 case FlushedDouble:
88 return DoubleRepUse;
89 case FlushedBoolean:
90 return BooleanUse;
91 }
92 RELEASE_ASSERT_NOT_REACHED();
93 return UntypedUse;
94 }
95
96 inline DataFormat dataFormatFor(FlushFormat format)
97 {
98 switch (format) {
99 case DeadFlush:
100 case ConflictingFlush:
101 return DataFormatDead;
102 case FlushedJSValue:
103 return DataFormatJS;
104 case FlushedDouble:
105 return DataFormatDouble;
106 case FlushedInt32:
107 return DataFormatInt32;
108 case FlushedInt52:
109 return DataFormatInt52;
110 case FlushedCell:
111 return DataFormatCell;
112 case FlushedBoolean:
113 return DataFormatBoolean;
114 case FlushedArguments:
115 return DataFormatArguments;
116 }
117 RELEASE_ASSERT_NOT_REACHED();
118 return DataFormatDead;
119 }
120
121 } } // namespace JSC::DFG
122
123 namespace WTF {
124
125 void printInternal(PrintStream&, JSC::DFG::FlushFormat);
126
127 inline JSC::DFG::FlushFormat inContext(JSC::DFG::FlushFormat format, JSC::DumpContext*)
128 {
129 return format;
130 }
131
132 } // namespace WTF
133
134 #endif // ENABLE(DFG_JIT)
135
136 #endif // DFGFlushFormat_h
137