| 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 "B3Common.h" |
| 31 | #include <wtf/StdLibExtras.h> |
| 32 | |
| 33 | #if ASSERT_DISABLED |
| 34 | IGNORE_RETURN_TYPE_WARNINGS_BEGIN |
| 35 | #endif |
| 36 | |
| 37 | namespace JSC { namespace B3 { |
| 38 | |
| 39 | enum Type : int8_t { |
| 40 | Void, |
| 41 | Int32, |
| 42 | Int64, |
| 43 | Float, |
| 44 | Double, |
| 45 | }; |
| 46 | |
| 47 | inline bool isInt(Type type) |
| 48 | { |
| 49 | return type == Int32 || type == Int64; |
| 50 | } |
| 51 | |
| 52 | inline bool isFloat(Type type) |
| 53 | { |
| 54 | return type == Float || type == Double; |
| 55 | } |
| 56 | |
| 57 | inline Type pointerType() |
| 58 | { |
| 59 | if (is32Bit()) |
| 60 | return Int32; |
| 61 | return Int64; |
| 62 | } |
| 63 | |
| 64 | inline size_t sizeofType(Type type) |
| 65 | { |
| 66 | switch (type) { |
| 67 | case Void: |
| 68 | return 0; |
| 69 | case Int32: |
| 70 | case Float: |
| 71 | return 4; |
| 72 | case Int64: |
| 73 | case Double: |
| 74 | return 8; |
| 75 | } |
| 76 | ASSERT_NOT_REACHED(); |
| 77 | } |
| 78 | |
| 79 | } } // namespace JSC::B3 |
| 80 | |
| 81 | namespace WTF { |
| 82 | |
| 83 | class PrintStream; |
| 84 | |
| 85 | void printInternal(PrintStream&, JSC::B3::Type); |
| 86 | |
| 87 | } // namespace WTF |
| 88 | |
| 89 | #if ASSERT_DISABLED |
| 90 | IGNORE_RETURN_TYPE_WARNINGS_END |
| 91 | #endif |
| 92 | |
| 93 | #endif // ENABLE(B3_JIT) |
| 94 | |