1/*
2 * Copyright (C) 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#include "config.h"
27#include "DFGArithMode.h"
28
29#if ENABLE(DFG_JIT)
30
31#include "DFGOperations.h"
32#include "JSCInlines.h"
33#include <wtf/PrintStream.h>
34
35namespace JSC { namespace DFG {
36
37Arith::UnaryFunction arithUnaryFunction(Arith::UnaryType type)
38{
39 switch (type) {
40#define DFG_ARITH_UNARY(capitalizedName, lowerName) \
41 case Arith::UnaryType::capitalizedName: \
42 return static_cast<Arith::UnaryFunction>(JSC::Math::lowerName);
43 FOR_EACH_DFG_ARITH_UNARY_OP(DFG_ARITH_UNARY)
44#undef DFG_ARITH_UNARY
45 }
46 RELEASE_ASSERT_NOT_REACHED();
47
48}
49
50Arith::UnaryOperation arithUnaryOperation(Arith::UnaryType type)
51{
52 switch (type) {
53#define DFG_ARITH_UNARY(capitalizedName, lowerName) \
54 case Arith::UnaryType::capitalizedName: \
55 return static_cast<Arith::UnaryOperation>(operationArith##capitalizedName);
56 FOR_EACH_DFG_ARITH_UNARY_OP(DFG_ARITH_UNARY)
57#undef DFG_ARITH_UNARY
58 }
59 RELEASE_ASSERT_NOT_REACHED();
60}
61
62} } // namespace JSC::DFG
63
64namespace WTF {
65
66void printInternal(PrintStream& out, JSC::DFG::Arith::Mode mode)
67{
68 switch (mode) {
69 case JSC::DFG::Arith::NotSet:
70 out.print("NotSet");
71 return;
72 case JSC::DFG::Arith::Unchecked:
73 out.print("Unchecked");
74 return;
75 case JSC::DFG::Arith::CheckOverflow:
76 out.print("CheckOverflow");
77 return;
78 case JSC::DFG::Arith::CheckOverflowAndNegativeZero:
79 out.print("CheckOverflowAndNegativeZero");
80 return;
81 case JSC::DFG::Arith::DoOverflow:
82 out.print("DoOverflow");
83 return;
84 }
85 RELEASE_ASSERT_NOT_REACHED();
86}
87
88void printInternal(PrintStream& out, JSC::DFG::Arith::RoundingMode mode)
89{
90 switch (mode) {
91 case JSC::DFG::Arith::RoundingMode::Int32:
92 out.print("Int32");
93 return;
94 case JSC::DFG::Arith::RoundingMode::Int32WithNegativeZeroCheck:
95 out.print("Int32WithNegativeZeroCheck");
96 return;
97 case JSC::DFG::Arith::RoundingMode::Double:
98 out.print("Double");
99 return;
100 }
101 RELEASE_ASSERT_NOT_REACHED();
102}
103
104void printInternal(PrintStream& out, JSC::DFG::Arith::UnaryType type)
105{
106 switch (type) {
107#define DFG_ARITH_UNARY(capitalizedName, lowerName) \
108 case JSC::DFG::Arith::UnaryType::capitalizedName: \
109 out.print(#capitalizedName); \
110 return;
111 FOR_EACH_DFG_ARITH_UNARY_OP(DFG_ARITH_UNARY)
112#undef DFG_ARITH_UNARY
113 }
114 RELEASE_ASSERT_NOT_REACHED();
115}
116
117
118} // namespace WTF
119
120#endif // ENABLE(DFG_JIT)
121
122