emitnx86.c 2.0 KB

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