Skip to content

Commit 9adedce

Browse files
committed
py: Add new Xtensa-Windowed arch for native emitter.
Enabled via the configuration MICROPY_EMIT_XTENSAWIN.
1 parent f7ddc94 commit 9adedce

File tree

11 files changed

+50
-6
lines changed

11 files changed

+50
-6
lines changed

py/asmxtensa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "py/mpconfig.h"
3131

3232
// wrapper around everything in this file
33-
#if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA
33+
#if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA || MICROPY_EMIT_XTENSAWIN
3434

3535
#include "py/asmxtensa.h"
3636

@@ -250,4 +250,4 @@ void asm_xtensa_call_ind_win(asm_xtensa_t *as, uint idx) {
250250
asm_xtensa_op_callx8(as, ASM_XTENSA_REG_A8);
251251
}
252252

253-
#endif // MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA
253+
#endif // MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA || MICROPY_EMIT_XTENSAWIN

py/compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ STATIC const emit_method_table_t *emit_native_table[] = {
9595
&emit_native_thumb_method_table,
9696
&emit_native_thumb_method_table,
9797
&emit_native_xtensa_method_table,
98+
&emit_native_xtensawin_method_table,
9899
};
99100

100101
#elif MICROPY_EMIT_NATIVE
@@ -109,6 +110,8 @@ STATIC const emit_method_table_t *emit_native_table[] = {
109110
#define NATIVE_EMITTER(f) emit_native_arm_##f
110111
#elif MICROPY_EMIT_XTENSA
111112
#define NATIVE_EMITTER(f) emit_native_xtensa_##f
113+
#elif MICROPY_EMIT_XTENSAWIN
114+
#define NATIVE_EMITTER(f) emit_native_xtensawin_##f
112115
#else
113116
#error "unknown native emitter"
114117
#endif
@@ -131,6 +134,7 @@ STATIC const emit_inline_asm_method_table_t *emit_asm_table[] = {
131134
&emit_inline_thumb_method_table,
132135
&emit_inline_thumb_method_table,
133136
&emit_inline_xtensa_method_table,
137+
NULL,
134138
};
135139

136140
#elif MICROPY_EMIT_INLINE_ASM

py/emit.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ extern const emit_method_table_t emit_native_x86_method_table;
174174
extern const emit_method_table_t emit_native_thumb_method_table;
175175
extern const emit_method_table_t emit_native_arm_method_table;
176176
extern const emit_method_table_t emit_native_xtensa_method_table;
177+
extern const emit_method_table_t emit_native_xtensawin_method_table;
177178

178179
extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops;
179180
extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops;
@@ -185,6 +186,7 @@ emit_t *emit_native_x86_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t ma
185186
emit_t *emit_native_thumb_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
186187
emit_t *emit_native_arm_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
187188
emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
189+
emit_t *emit_native_xtensawin_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
188190

189191
void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels);
190192

@@ -194,6 +196,7 @@ void emit_native_x86_free(emit_t *emit);
194196
void emit_native_thumb_free(emit_t *emit);
195197
void emit_native_arm_free(emit_t *emit);
196198
void emit_native_xtensa_free(emit_t *emit);
199+
void emit_native_xtensawin_free(emit_t *emit);
197200

198201
void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope);
199202
void mp_emit_bc_end_pass(emit_t *emit);

py/emitnative.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#endif
5959

6060
// wrapper around everything in this file
61-
#if N_X64 || N_X86 || N_THUMB || N_ARM || N_XTENSA
61+
#if N_X64 || N_X86 || N_THUMB || N_ARM || N_XTENSA || N_XTENSAWIN
6262

6363
// C stack layout for native functions:
6464
// 0: nlr_buf_t [optional]
@@ -2404,7 +2404,7 @@ STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
24042404
ASM_ARM_CC_NE,
24052405
};
24062406
asm_arm_setcc_reg(emit->as, REG_RET, ccs[op - MP_BINARY_OP_LESS]);
2407-
#elif N_XTENSA
2407+
#elif N_XTENSA || N_XTENSAWIN
24082408
static uint8_t ccs[6] = {
24092409
ASM_XTENSA_CC_LT,
24102410
0x80 | ASM_XTENSA_CC_LT, // for GT we'll swap args

py/emitnxtensawin.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Xtensa-Windowed specific stuff
2+
3+
#include "py/mpconfig.h"
4+
5+
#if MICROPY_EMIT_XTENSAWIN
6+
7+
// this is defined so that the assembler exports generic assembler API macros
8+
#define GENERIC_ASM_API (1)
9+
#define GENERIC_ASM_API_WIN (1)
10+
#include "py/asmxtensa.h"
11+
12+
// Word indices of REG_LOCAL_x in nlr_buf_t
13+
#define NLR_BUF_IDX_LOCAL_1 (2 + 4) // a4
14+
#define NLR_BUF_IDX_LOCAL_2 (2 + 5) // a5
15+
#define NLR_BUF_IDX_LOCAL_3 (2 + 6) // a6
16+
17+
#define N_NLR_SETJMP (1)
18+
#define N_PRELUDE_AS_BYTES_OBJ (1)
19+
#define N_XTENSAWIN (1)
20+
#define EXPORT_FUN(name) emit_native_xtensawin_##name
21+
#include "py/emitnative.c"
22+
23+
#endif

py/mpconfig.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,16 @@
323323
#define MICROPY_EMIT_INLINE_XTENSA (0)
324324
#endif
325325

326+
// Whether to emit Xtensa-Windowed native code
327+
#ifndef MICROPY_EMIT_XTENSAWIN
328+
#define MICROPY_EMIT_XTENSAWIN (0)
329+
#endif
330+
326331
// Convenience definition for whether any native emitter is enabled
327-
#define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA)
332+
#define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN)
333+
334+
// Select prelude-as-bytes-object for certain emitters
335+
#define MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ (MICROPY_EMIT_XTENSAWIN)
328336

329337
// Convenience definition for whether any inline assembler emitter is enabled
330338
#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)

py/nlr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define MICROPY_NLR_NUM_REGS_ARM_THUMB (10)
4141
#define MICROPY_NLR_NUM_REGS_ARM_THUMB_FP (10 + 6)
4242
#define MICROPY_NLR_NUM_REGS_XTENSA (10)
43+
#define MICROPY_NLR_NUM_REGS_XTENSAWIN (17)
4344

4445
// If MICROPY_NLR_SETJMP is not enabled then auto-detect the machine arch
4546
#if !MICROPY_NLR_SETJMP

py/persistentcode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV6)
7272
#elif MICROPY_EMIT_XTENSA
7373
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_XTENSA)
74+
#elif MICROPY_EMIT_XTENSAWIN
75+
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_XTENSAWIN)
7476
#else
7577
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_NONE)
7678
#endif
@@ -196,7 +198,7 @@ STATIC void arch_link_qstr(uint8_t *pc, bool is_obj, qstr qst) {
196198
if (is_obj) {
197199
val = (mp_uint_t)MP_OBJ_NEW_QSTR(qst);
198200
}
199-
#if MICROPY_EMIT_X86 || MICROPY_EMIT_X64 || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA
201+
#if MICROPY_EMIT_X86 || MICROPY_EMIT_X64 || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN
200202
pc[0] = val & 0xff;
201203
pc[1] = (val >> 8) & 0xff;
202204
pc[2] = (val >> 16) & 0xff;

py/persistentcode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ enum {
4444
MP_NATIVE_ARCH_ARMV7EMSP,
4545
MP_NATIVE_ARCH_ARMV7EMDP,
4646
MP_NATIVE_ARCH_XTENSA,
47+
MP_NATIVE_ARCH_XTENSAWIN,
4748
};
4849

4950
mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader);

py/py.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ PY_CORE_O_BASENAME = $(addprefix py/,\
7676
asmxtensa.o \
7777
emitnxtensa.o \
7878
emitinlinextensa.o \
79+
emitnxtensawin.o \
7980
formatfloat.o \
8081
parsenumbase.o \
8182
parsenum.o \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy