Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / js / src / jit / ABIFunctionType.h
blobfe54aaf4a17e0685b894eb7e0fc8ff30851f8eaf
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jit_ABIFunctionType_h
8 #define jit_ABIFunctionType_h
10 #include <initializer_list>
11 #include <stdint.h>
13 #include "jit/ABIFunctionTypeGenerated.h"
15 namespace js {
16 namespace jit {
18 enum class ABIType {
19 // A pointer sized integer
20 General = 0x1,
21 // A 32-bit integer
22 Int32 = 0x2,
23 // A 64-bit integer
24 Int64 = 0x3,
25 // A 32-bit floating point number
26 Float32 = 0x4,
27 // A 64-bit floating point number
28 Float64 = 0x5
31 const size_t ABITypeArgShift = 0x3;
32 const size_t ABITypeArgMask = (1 << ABITypeArgShift) - 1;
34 namespace detail {
36 static constexpr uint64_t MakeABIFunctionType(
37 ABIType ret, std::initializer_list<ABIType> args) {
38 uint64_t abiType = 0;
39 for (auto arg : args) {
40 abiType <<= ABITypeArgShift;
41 abiType |= (uint64_t)arg;
43 abiType <<= ABITypeArgShift;
44 abiType |= (uint64_t)ret;
45 return abiType;
48 } // namespace detail
50 enum ABIFunctionType : uint64_t {
51 // The enum must be explicitly typed to avoid UB: some validly constructed
52 // members are larger than any explicitly declared members.
53 ABI_FUNCTION_TYPE_ENUM
56 static constexpr ABIFunctionType MakeABIFunctionType(
57 ABIType ret, std::initializer_list<ABIType> args) {
58 return ABIFunctionType(detail::MakeABIFunctionType(ret, args));
61 } // namespace jit
62 } // namespace js
64 #endif /* jit_ABIFunctionType_h */