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