Flutter Engine
The Flutter Engine
abi.cc
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
6
7#include "platform/globals.h"
8#include "vm/constants.h"
9
10namespace dart {
11
12namespace compiler {
13
14namespace ffi {
15
16// See pkg/vm/lib/transformations/ffi/abi.dart, which makes these assumptions.
19 double d;
20};
23 uint64_t i;
24};
25
26#if defined(HOST_ARCH_X64) || defined(HOST_ARCH_ARM64) || \
27 defined(HOST_ARCH_RISCV32) || defined(HOST_ARCH_RISCV64)
28static_assert(offsetof(AbiAlignmentDouble, d) == 8,
29 "FFI transformation alignment");
30static_assert(offsetof(AbiAlignmentUint64, i) == 8,
31 "FFI transformation alignment");
32#elif (defined(HOST_ARCH_IA32) && /* NOLINT(whitespace/parens) */ \
33 (defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_MACOS) || \
34 defined(DART_HOST_OS_ANDROID))) || \
35 (defined(HOST_ARCH_ARM) && defined(DART_HOST_OS_IOS))
36static_assert(offsetof(AbiAlignmentDouble, d) == 4,
37 "FFI transformation alignment");
38static_assert(offsetof(AbiAlignmentUint64, i) == 4,
39 "FFI transformation alignment");
40#elif defined(HOST_ARCH_IA32) && defined(DART_HOST_OS_WINDOWS) || \
41 defined(HOST_ARCH_ARM)
42static_assert(offsetof(AbiAlignmentDouble, d) == 8,
43 "FFI transformation alignment");
44static_assert(offsetof(AbiAlignmentUint64, i) == 8,
45 "FFI transformation alignment");
46#else
47#error "Unknown platform. Please add alignment requirements for ABI."
48#endif
49
50#if defined(DART_TARGET_OS_ANDROID)
51#define DART_TARGET_OS_NAME Android
52#elif defined(DART_TARGET_OS_FUCHSIA)
53#define DART_TARGET_OS_NAME Fuchsia
54#elif defined(DART_TARGET_OS_LINUX)
55#define DART_TARGET_OS_NAME Linux
56#elif defined(DART_TARGET_OS_MACOS)
57#if DART_TARGET_OS_MACOS_IOS
58#define DART_TARGET_OS_NAME IOS
59#else
60#define DART_TARGET_OS_NAME MacOS
61#endif
62#elif defined(DART_TARGET_OS_WINDOWS)
63#define DART_TARGET_OS_NAME Windows
64#else
65#error Unknown OS
66#endif
67
68#if defined(TARGET_ARCH_IA32)
69#define TARGET_ARCH_NAME IA32
70#elif defined(TARGET_ARCH_X64)
71#define TARGET_ARCH_NAME X64
72#elif defined(TARGET_ARCH_ARM)
73#define TARGET_ARCH_NAME Arm
74#elif defined(TARGET_ARCH_ARM64)
75#define TARGET_ARCH_NAME Arm64
76#elif defined(TARGET_ARCH_RISCV32)
77#define TARGET_ARCH_NAME Riscv32
78#elif defined(TARGET_ARCH_RISCV64)
79#define TARGET_ARCH_NAME Riscv64
80#else
81#error Unknown arch
82#endif
83
84#define ABI_ENUM_VALUE1(os, arch) k##os##arch
85#define ABI_ENUM_VALUE2(os, arch) ABI_ENUM_VALUE1(os, arch)
86#define ABI_ENUM_VALUE3 ABI_ENUM_VALUE2(DART_TARGET_OS_NAME, TARGET_ARCH_NAME)
87
90}
91
92const char* target_abi_name =
93 kTargetOperatingSystemName "_" kTargetArchitectureName;
94
95} // namespace ffi
96
97} // namespace compiler
98
99} // namespace dart
#define ABI_ENUM_VALUE3
Definition: abi.cc:86
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
const char * target_abi_name
Definition: abi.cc:92
Abi TargetAbi()
Definition: abi.cc:88
Definition: dart_vm.cc:33