master
h 79 lines 2.3 KB
Raw
1 /*
2 * TCG Helper Information Structure
3 *
4 * Copyright (c) 2023 Linaro Ltd
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #ifndef TCG_HELPER_INFO_H
10 #define TCG_HELPER_INFO_H
11
12 #ifdef CONFIG_TCG_INTERPRETER
13 /*
14 * MacOSX 15 uses an old version of libffi which contains
15 * #if FFI_GO_CLOSURES
16 * but does not define that in <ffitarget.h>, included from <ffi.h>.
17 * This was fixed upstream with
18 * https://github.com/libffi/libffi/commit/c23e9a1c
19 * We don't care about go closures one way or the other;
20 * just suppress the warning.
21 */
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wundef"
24 #include <ffi.h>
25 #pragma GCC diagnostic pop
26 #endif
27 #include "tcg/target-reg-bits.h"
28
29 #define MAX_CALL_IARGS 7
30
31 /*
32 * Describe the calling convention of a given argument type.
33 */
34 typedef enum {
35 TCG_CALL_RET_NORMAL, /* by registers */
36 TCG_CALL_RET_BY_REF, /* for i128, by reference */
37 TCG_CALL_RET_BY_VEC, /* for i128, by vector register */
38 } TCGCallReturnKind;
39
40 typedef enum {
41 TCG_CALL_ARG_NORMAL, /* by registers (continuing onto stack) */
42 TCG_CALL_ARG_EVEN, /* like normal, but skipping odd slots */
43 TCG_CALL_ARG_EXTEND, /* for i32, as a sign/zero-extended i64 */
44 TCG_CALL_ARG_EXTEND_U, /* ... as a zero-extended i64 */
45 TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */
46 TCG_CALL_ARG_BY_REF, /* for i128, by reference, first */
47 TCG_CALL_ARG_BY_REF_N, /* ... by reference, subsequent */
48 } TCGCallArgumentKind;
49
50 typedef struct TCGCallArgumentLoc {
51 TCGCallArgumentKind kind : 8;
52 unsigned arg_slot : 8;
53 unsigned ref_slot : 8;
54 unsigned arg_idx : 4;
55 unsigned tmp_subindex : 2;
56 } TCGCallArgumentLoc;
57
58 struct TCGHelperInfo {
59 void *func;
60 const char *name;
61
62 /* Used with g_once_init_enter. */
63 #ifdef CONFIG_TCG_INTERPRETER
64 ffi_cif *cif;
65 #else
66 uintptr_t init;
67 #endif
68
69 unsigned typemask : 32;
70 unsigned flags : 8;
71 unsigned nr_in : 8;
72 unsigned nr_out : 8;
73 TCGCallReturnKind out_kind : 8;
74
75 /* Maximum physical arguments are constrained by TCG_TYPE_I128. */
76 TCGCallArgumentLoc in[MAX_CALL_IARGS * (128 / TCG_TARGET_REG_BITS)];
77 };
78
79 #endif /* TCG_HELPER_INFO_H */