66#include <assert.h>
77
88#include "misc.h"
9+ #include "mpyconfig.h"
910#include "lexer.h"
10- #include "machine.h"
1111#include "parse.h"
1212#include "scope.h"
1313#include "compile.h"
@@ -768,8 +768,10 @@ static bool compile_built_in_decorator(compiler_t *comp, int name_len, py_parse_
768768 * emit_options = EMIT_OPT_NATIVE_PYTHON ;
769769 } else if (attr == comp -> qstr_viper ) {
770770 * emit_options = EMIT_OPT_VIPER ;
771+ #if defined(MICROPY_EMIT_ENABLE_INLINE_THUMB )
771772 } else if (attr == comp -> qstr_asm_thumb ) {
772773 * emit_options = EMIT_OPT_ASM_THUMB ;
774+ #endif
773775 } else {
774776 printf ("SyntaxError: invalid micropython decorator\n" );
775777 }
@@ -2673,8 +2675,11 @@ void py_compile(py_parse_node_t pn) {
26732675 comp -> emit_inline_asm_method_table = NULL ;
26742676 uint max_num_labels = 0 ;
26752677 for (scope_t * s = comp -> scope_head ; s != NULL ; s = s -> next ) {
2676- if (s -> emit_options == EMIT_OPT_ASM_THUMB ) {
2678+ if (false) {
2679+ #ifdef MICROPY_EMIT_ENABLE_INLINE_THUMB
2680+ } else if (s -> emit_options == EMIT_OPT_ASM_THUMB ) {
26772681 compile_scope_inline_asm (comp , s , PASS_1 );
2682+ #endif
26782683 } else {
26792684 compile_scope (comp , s , PASS_1 );
26802685 }
@@ -2694,11 +2699,20 @@ void py_compile(py_parse_node_t pn) {
26942699 emit_pass1_free (comp -> emit );
26952700
26962701 // compile pass 2 and 3
2702+ #if !defined(MICROPY_EMIT_ENABLE_CPYTHON )
26972703 emit_t * emit_bc = NULL ;
26982704 emit_t * emit_native = NULL ;
2705+ #endif
2706+ #if defined(MICROPY_EMIT_ENABLE_INLINE_THUMB )
26992707 emit_inline_asm_t * emit_inline_thumb = NULL ;
2708+ #endif
27002709 for (scope_t * s = comp -> scope_head ; s != NULL ; s = s -> next ) {
2701- if (s -> emit_options == EMIT_OPT_ASM_THUMB ) {
2710+ if (false) {
2711+ // dummy
2712+
2713+ #if defined(MICROPY_EMIT_ENABLE_INLINE_THUMB )
2714+ } else if (s -> emit_options == EMIT_OPT_ASM_THUMB ) {
2715+ // inline assembly for thumb
27022716 if (emit_inline_thumb == NULL ) {
27032717 emit_inline_thumb = emit_inline_thumb_new (max_num_labels );
27042718 }
@@ -2708,15 +2722,31 @@ void py_compile(py_parse_node_t pn) {
27082722 comp -> emit_inline_asm_method_table = & emit_inline_thumb_method_table ;
27092723 compile_scope_inline_asm (comp , s , PASS_2 );
27102724 compile_scope_inline_asm (comp , s , PASS_3 );
2725+ #endif
2726+
27112727 } else {
2728+
2729+ // choose the emit type
2730+
2731+ #if defined(MICROPY_EMIT_ENABLE_CPYTHON )
2732+ comp -> emit = emit_cpython_new (max_num_labels );
2733+ comp -> emit_method_table = & emit_cpython_method_table ;
2734+ #else
27122735 switch (s -> emit_options ) {
27132736 case EMIT_OPT_NATIVE_PYTHON :
27142737 case EMIT_OPT_VIPER :
2738+ #if defined(MICROPY_EMIT_ENABLE_X64 )
27152739 if (emit_native == NULL ) {
27162740 emit_native = emit_native_x64_new (max_num_labels );
27172741 }
2718- comp -> emit = emit_native ;
27192742 comp -> emit_method_table = & emit_native_x64_method_table ;
2743+ #elif defined(MICROPY_EMIT_ENABLE_THUMB )
2744+ if (emit_native == NULL ) {
2745+ emit_native = emit_native_thumb_new (max_num_labels );
2746+ }
2747+ comp -> emit_method_table = & emit_native_thumb_method_table ;
2748+ #endif
2749+ comp -> emit = emit_native ;
27202750 comp -> emit_method_table -> set_native_types (comp -> emit , s -> emit_options == EMIT_OPT_VIPER );
27212751 break ;
27222752
@@ -2728,8 +2758,9 @@ void py_compile(py_parse_node_t pn) {
27282758 comp -> emit_method_table = & emit_bc_method_table ;
27292759 break ;
27302760 }
2731- //comp->emit = emit_cpython_new(max_num_labels);
2732- //comp->emit_method_table = &emit_cpython_method_table;
2761+ #endif
2762+
2763+ // compile pass 2 and pass 3
27332764 compile_scope (comp , s , PASS_2 );
27342765 compile_scope (comp , s , PASS_3 );
27352766 }
0 commit comments