emitnx86.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // x86 needs a table to know how many args a given function has
  11. static byte mp_f_n_args[MP_F_NUMBER_OF] = {
  12. [MP_F_CONVERT_OBJ_TO_NATIVE] = 2,
  13. [MP_F_CONVERT_NATIVE_TO_OBJ] = 2,
  14. [MP_F_NATIVE_SWAP_GLOBALS] = 1,
  15. [MP_F_LOAD_NAME] = 1,
  16. [MP_F_LOAD_GLOBAL] = 1,
  17. [MP_F_LOAD_BUILD_CLASS] = 0,
  18. [MP_F_LOAD_ATTR] = 2,
  19. [MP_F_LOAD_METHOD] = 3,
  20. [MP_F_LOAD_SUPER_METHOD] = 2,
  21. [MP_F_STORE_NAME] = 2,
  22. [MP_F_STORE_GLOBAL] = 2,
  23. [MP_F_STORE_ATTR] = 3,
  24. [MP_F_OBJ_SUBSCR] = 3,
  25. [MP_F_OBJ_IS_TRUE] = 1,
  26. [MP_F_UNARY_OP] = 2,
  27. [MP_F_BINARY_OP] = 3,
  28. [MP_F_BUILD_TUPLE] = 2,
  29. [MP_F_BUILD_LIST] = 2,
  30. [MP_F_BUILD_MAP] = 1,
  31. [MP_F_BUILD_SET] = 2,
  32. [MP_F_STORE_SET] = 2,
  33. [MP_F_LIST_APPEND] = 2,
  34. [MP_F_STORE_MAP] = 3,
  35. [MP_F_MAKE_FUNCTION_FROM_PROTO_FUN] = 3,
  36. [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3,
  37. [MP_F_CALL_METHOD_N_KW] = 3,
  38. [MP_F_CALL_METHOD_N_KW_VAR] = 3,
  39. [MP_F_NATIVE_GETITER] = 2,
  40. [MP_F_NATIVE_ITERNEXT] = 1,
  41. [MP_F_NLR_PUSH] = 1,
  42. [MP_F_NLR_POP] = 0,
  43. [MP_F_NATIVE_RAISE] = 1,
  44. [MP_F_IMPORT_NAME] = 3,
  45. [MP_F_IMPORT_FROM] = 2,
  46. [MP_F_IMPORT_ALL] = 1,
  47. [MP_F_NEW_SLICE] = 3,
  48. [MP_F_UNPACK_SEQUENCE] = 3,
  49. [MP_F_UNPACK_EX] = 3,
  50. [MP_F_DELETE_NAME] = 1,
  51. [MP_F_DELETE_GLOBAL] = 1,
  52. [MP_F_NEW_CLOSURE] = 3,
  53. [MP_F_ARG_CHECK_NUM_SIG] = 3,
  54. [MP_F_SETUP_CODE_STATE] = 4,
  55. [MP_F_SMALL_INT_FLOOR_DIVIDE] = 2,
  56. [MP_F_SMALL_INT_MODULO] = 2,
  57. [MP_F_NATIVE_YIELD_FROM] = 3,
  58. [MP_F_SETJMP] = 1,
  59. };
  60. #define N_X86 (1)
  61. #define EXPORT_FUN(name) emit_native_x86_##name
  62. #include "py/emitnative.c"
  63. #endif