| 1 | /* |
| 2 | * Copyright (C) 2015-2016 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 | #pragma once |
| 27 | |
| 28 | #if ENABLE(B3_JIT) |
| 29 | |
| 30 | #include "B3Value.h" |
| 31 | |
| 32 | namespace JSC { namespace B3 { |
| 33 | |
| 34 | class JS_EXPORT_PRIVATE Const32Value : public Value { |
| 35 | public: |
| 36 | static bool accepts(Kind kind) { return kind == Const32; } |
| 37 | |
| 38 | ~Const32Value(); |
| 39 | |
| 40 | int32_t value() const { return m_value; } |
| 41 | |
| 42 | Value* negConstant(Procedure&) const override; |
| 43 | Value* addConstant(Procedure&, int32_t other) const override; |
| 44 | Value* addConstant(Procedure&, const Value* other) const override; |
| 45 | Value* subConstant(Procedure&, const Value* other) const override; |
| 46 | Value* mulConstant(Procedure&, const Value* other) const override; |
| 47 | Value* checkAddConstant(Procedure&, const Value* other) const override; |
| 48 | Value* checkSubConstant(Procedure&, const Value* other) const override; |
| 49 | Value* checkMulConstant(Procedure&, const Value* other) const override; |
| 50 | Value* checkNegConstant(Procedure&) const override; |
| 51 | Value* divConstant(Procedure&, const Value* other) const override; |
| 52 | Value* uDivConstant(Procedure&, const Value* other) const override; |
| 53 | Value* modConstant(Procedure&, const Value* other) const override; |
| 54 | Value* uModConstant(Procedure&, const Value* other) const override; |
| 55 | Value* bitAndConstant(Procedure&, const Value* other) const override; |
| 56 | Value* bitOrConstant(Procedure&, const Value* other) const override; |
| 57 | Value* bitXorConstant(Procedure&, const Value* other) const override; |
| 58 | Value* shlConstant(Procedure&, const Value* other) const override; |
| 59 | Value* sShrConstant(Procedure&, const Value* other) const override; |
| 60 | Value* zShrConstant(Procedure&, const Value* other) const override; |
| 61 | Value* rotRConstant(Procedure&, const Value* other) const override; |
| 62 | Value* rotLConstant(Procedure&, const Value* other) const override; |
| 63 | Value* bitwiseCastConstant(Procedure&) const override; |
| 64 | Value* iToDConstant(Procedure&) const override; |
| 65 | Value* iToFConstant(Procedure&) const override; |
| 66 | |
| 67 | TriState equalConstant(const Value* other) const override; |
| 68 | TriState notEqualConstant(const Value* other) const override; |
| 69 | TriState lessThanConstant(const Value* other) const override; |
| 70 | TriState greaterThanConstant(const Value* other) const override; |
| 71 | TriState lessEqualConstant(const Value* other) const override; |
| 72 | TriState greaterEqualConstant(const Value* other) const override; |
| 73 | TriState aboveConstant(const Value* other) const override; |
| 74 | TriState belowConstant(const Value* other) const override; |
| 75 | TriState aboveEqualConstant(const Value* other) const override; |
| 76 | TriState belowEqualConstant(const Value* other) const override; |
| 77 | |
| 78 | B3_SPECIALIZE_VALUE_FOR_NO_CHILDREN |
| 79 | |
| 80 | protected: |
| 81 | void dumpMeta(CommaPrinter&, PrintStream&) const override; |
| 82 | |
| 83 | // Protected because of ConstPtrValue |
| 84 | static Opcode opcodeFromConstructor(Origin = Origin(), int32_t = 0) { return Const32; } |
| 85 | |
| 86 | Const32Value(Origin origin, int32_t value) |
| 87 | : Value(CheckedOpcode, Const32, Int32, Zero, origin) |
| 88 | , m_value(value) |
| 89 | { |
| 90 | } |
| 91 | |
| 92 | private: |
| 93 | friend class Procedure; |
| 94 | friend class Value; |
| 95 | |
| 96 | int32_t m_value; |
| 97 | }; |
| 98 | |
| 99 | } } // namespace JSC::B3 |
| 100 | |
| 101 | #endif // ENABLE(B3_JIT) |
| 102 | |