blob: b8f5aab0dba4cc0c2d874384974d23003271e2b1 [file] [log] [blame]
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +00001/*
fpizlo@apple.com8f47e9e2016-01-21 03:12:55 +00002 * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +00003 *
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
ryanhaddad@apple.com22104f52016-09-28 17:08:17 +000026#pragma once
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000027
28#if ENABLE(B3_JIT)
29
30#include "B3Value.h"
31
32namespace JSC { namespace B3 {
33
ross.kirsling@sony.com8e3c2ed2020-05-12 18:48:02 +000034class JS_EXPORT_PRIVATE ConstDoubleValue final : public Value {
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000035public:
fpizlo@apple.com11fa0092016-09-29 18:44:53 +000036 static bool accepts(Kind kind) { return kind == ConstDouble; }
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000037
ross.kirsling@sony.com8e3c2ed2020-05-12 18:48:02 +000038 ~ConstDoubleValue() final;
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000039
40 double value() const { return m_value; }
41
ross.kirsling@sony.com8e3c2ed2020-05-12 18:48:02 +000042 Value* negConstant(Procedure&) const final;
43 Value* addConstant(Procedure&, int32_t other) const final;
44 Value* addConstant(Procedure&, const Value* other) const final;
45 Value* subConstant(Procedure&, const Value* other) const final;
46 Value* divConstant(Procedure&, const Value* other) const final;
47 Value* modConstant(Procedure&, const Value* other) const final;
48 Value* mulConstant(Procedure&, const Value* other) const final;
49 Value* bitAndConstant(Procedure&, const Value* other) const final;
50 Value* bitOrConstant(Procedure&, const Value* other) const final;
51 Value* bitXorConstant(Procedure&, const Value* other) const final;
52 Value* bitwiseCastConstant(Procedure&) const final;
53 Value* doubleToFloatConstant(Procedure&) const final;
54 Value* absConstant(Procedure&) const final;
55 Value* ceilConstant(Procedure&) const final;
56 Value* floorConstant(Procedure&) const final;
57 Value* sqrtConstant(Procedure&) const final;
sbarati@apple.comb4249062021-12-16 23:30:22 +000058 Value* fMinConstant(Procedure&, const Value* other) const final;
59 Value* fMaxConstant(Procedure&, const Value* other) const final;
fpizlo@apple.com2ba7f072015-11-05 21:51:05 +000060
ross.kirsling@sony.com8e3c2ed2020-05-12 18:48:02 +000061 TriState equalConstant(const Value* other) const final;
62 TriState notEqualConstant(const Value* other) const final;
63 TriState lessThanConstant(const Value* other) const final;
64 TriState greaterThanConstant(const Value* other) const final;
65 TriState lessEqualConstant(const Value* other) const final;
66 TriState greaterEqualConstant(const Value* other) const final;
67 TriState equalOrUnorderedConstant(const Value* other) const final;
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000068
rmorisset@apple.coma28790a2019-04-15 23:53:23 +000069 B3_SPECIALIZE_VALUE_FOR_NO_CHILDREN
fpizlo@apple.com8f47e9e2016-01-21 03:12:55 +000070
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000071private:
72 friend class Procedure;
rmorisset@apple.coma28790a2019-04-15 23:53:23 +000073 friend class Value;
74
ross.kirsling@sony.com8e3c2ed2020-05-12 18:48:02 +000075 void dumpMeta(CommaPrinter&, PrintStream&) const final;
rmorisset@apple.coma28790a2019-04-15 23:53:23 +000076
77 static Opcode opcodeFromConstructor(Origin, double) { return ConstDouble; }
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000078
fpizlo@apple.comdb423142016-02-02 23:21:12 +000079 ConstDoubleValue(Origin origin, double value)
rmorisset@apple.coma28790a2019-04-15 23:53:23 +000080 : Value(CheckedOpcode, ConstDouble, Double, Zero, origin)
fpizlo@apple.coma00b4d82015-10-28 23:57:04 +000081 , m_value(value)
82 {
83 }
84
85 double m_value;
86};
87
88} } // namespace JSC::B3
89
90#endif // ENABLE(B3_JIT)