xref: /openbmc/qemu/include/tcg/helper-info.h (revision 2f95279a)
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 #include <ffi.h>
14 #endif
15 #include "tcg-target-reg-bits.h"
16 
17 #define MAX_CALL_IARGS  7
18 
19 /*
20  * Describe the calling convention of a given argument type.
21  */
22 typedef enum {
23     TCG_CALL_RET_NORMAL,         /* by registers */
24     TCG_CALL_RET_BY_REF,         /* for i128, by reference */
25     TCG_CALL_RET_BY_VEC,         /* for i128, by vector register */
26 } TCGCallReturnKind;
27 
28 typedef enum {
29     TCG_CALL_ARG_NORMAL,         /* by registers (continuing onto stack) */
30     TCG_CALL_ARG_EVEN,           /* like normal, but skipping odd slots */
31     TCG_CALL_ARG_EXTEND,         /* for i32, as a sign/zero-extended i64 */
32     TCG_CALL_ARG_EXTEND_U,       /*      ... as a zero-extended i64 */
33     TCG_CALL_ARG_EXTEND_S,       /*      ... as a sign-extended i64 */
34     TCG_CALL_ARG_BY_REF,         /* for i128, by reference, first */
35     TCG_CALL_ARG_BY_REF_N,       /*       ... by reference, subsequent */
36 } TCGCallArgumentKind;
37 
38 typedef struct TCGCallArgumentLoc {
39     TCGCallArgumentKind kind    : 8;
40     unsigned arg_slot           : 8;
41     unsigned ref_slot           : 8;
42     unsigned arg_idx            : 4;
43     unsigned tmp_subindex       : 2;
44 } TCGCallArgumentLoc;
45 
46 struct TCGHelperInfo {
47     void *func;
48     const char *name;
49 
50     /* Used with g_once_init_enter. */
51 #ifdef CONFIG_TCG_INTERPRETER
52     ffi_cif *cif;
53 #else
54     uintptr_t init;
55 #endif
56 
57     unsigned typemask           : 32;
58     unsigned flags              : 8;
59     unsigned nr_in              : 8;
60     unsigned nr_out             : 8;
61     TCGCallReturnKind out_kind  : 8;
62 
63     /* Maximum physical arguments are constrained by TCG_TYPE_I128. */
64     TCGCallArgumentLoc in[MAX_CALL_IARGS * (128 / TCG_TARGET_REG_BITS)];
65 };
66 
67 #endif /* TCG_HELPER_INFO_H */
68