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>
13 #include "jit/ABIFunctionTypeGenerated.h"
19 // A pointer sized integer
25 // A 32-bit floating point number
27 // A 64-bit floating point number
31 const size_t ABITypeArgShift
= 0x3;
32 const size_t ABITypeArgMask
= (1 << ABITypeArgShift
) - 1;
36 static constexpr uint64_t MakeABIFunctionType(
37 ABIType ret
, std::initializer_list
<ABIType
> args
) {
39 for (auto arg
: args
) {
40 abiType
<<= ABITypeArgShift
;
41 abiType
|= (uint64_t)arg
;
43 abiType
<<= ABITypeArgShift
;
44 abiType
|= (uint64_t)ret
;
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
));
64 #endif /* jit_ABIFunctionType_h */