1 // x86 specific stuff
2 
3 #include "py/mpconfig.h"
4 #include "py/nativeglue.h"
5 
6 #if MICROPY_EMIT_X86
7 
8 // This is defined so that the assembler exports generic assembler API macros
9 #define GENERIC_ASM_API (1)
10 #include "py/asmx86.h"
11 
12 // Word indices of REG_LOCAL_x in nlr_buf_t
13 #define NLR_BUF_IDX_LOCAL_1 (5) // ebx
14 #define NLR_BUF_IDX_LOCAL_2 (7) // esi
15 #define NLR_BUF_IDX_LOCAL_3 (6) // edi
16 
17 // x86 needs a table to know how many args a given function has
18 STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
19     [MP_F_CONVERT_OBJ_TO_NATIVE] = 2,
20     [MP_F_CONVERT_NATIVE_TO_OBJ] = 2,
21     [MP_F_NATIVE_SWAP_GLOBALS] = 1,
22     [MP_F_LOAD_NAME] = 1,
23     [MP_F_LOAD_GLOBAL] = 1,
24     [MP_F_LOAD_BUILD_CLASS] = 0,
25     [MP_F_LOAD_ATTR] = 2,
26     [MP_F_LOAD_METHOD] = 3,
27     [MP_F_LOAD_SUPER_METHOD] = 2,
28     [MP_F_STORE_NAME] = 2,
29     [MP_F_STORE_GLOBAL] = 2,
30     [MP_F_STORE_ATTR] = 3,
31     [MP_F_OBJ_SUBSCR] = 3,
32     [MP_F_OBJ_IS_TRUE] = 1,
33     [MP_F_UNARY_OP] = 2,
34     [MP_F_BINARY_OP] = 3,
35     [MP_F_BUILD_TUPLE] = 2,
36     [MP_F_BUILD_LIST] = 2,
37     [MP_F_BUILD_MAP] = 1,
38     [MP_F_BUILD_SET] = 2,
39     [MP_F_STORE_SET] = 2,
40     [MP_F_LIST_APPEND] = 2,
41     [MP_F_STORE_MAP] = 3,
42     [MP_F_MAKE_FUNCTION_FROM_RAW_CODE] = 3,
43     [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3,
44     [MP_F_CALL_METHOD_N_KW] = 3,
45     [MP_F_CALL_METHOD_N_KW_VAR] = 3,
46     [MP_F_NATIVE_GETITER] = 2,
47     [MP_F_NATIVE_ITERNEXT] = 1,
48     [MP_F_NLR_PUSH] = 1,
49     [MP_F_NLR_POP] = 0,
50     [MP_F_NATIVE_RAISE] = 1,
51     [MP_F_IMPORT_NAME] = 3,
52     [MP_F_IMPORT_FROM] = 2,
53     [MP_F_IMPORT_ALL] = 1,
54     [MP_F_NEW_SLICE] = 3,
55     [MP_F_UNPACK_SEQUENCE] = 3,
56     [MP_F_UNPACK_EX] = 3,
57     [MP_F_DELETE_NAME] = 1,
58     [MP_F_DELETE_GLOBAL] = 1,
59     [MP_F_MAKE_CLOSURE_FROM_RAW_CODE] = 3,
60     [MP_F_ARG_CHECK_NUM_SIG] = 3,
61     [MP_F_SETUP_CODE_STATE] = 4,
62     [MP_F_SMALL_INT_FLOOR_DIVIDE] = 2,
63     [MP_F_SMALL_INT_MODULO] = 2,
64     [MP_F_NATIVE_YIELD_FROM] = 3,
65     [MP_F_SETJMP] = 1,
66 };
67 
68 #define N_X86 (1)
69 #define EXPORT_FUN(name) emit_native_x86_##name
70 #include "py/emitnative.c"
71 
72 #endif
73