Merge branch 'cross-plat' of https://github.com/pfalcon/micropython into pfalcon-cross-plat
This commit is contained in:
commit
cd340c44c2
@ -5,6 +5,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "mpconfig.h"
|
||||||
#include "asmx64.h"
|
#include "asmx64.h"
|
||||||
|
|
||||||
/* all offsets are measured in multiples of 8 bytes */
|
/* all offsets are measured in multiples of 8 bytes */
|
||||||
@ -602,7 +603,7 @@ void asm_x64_call_i1(asm_x64_t* as, void* func, int i1)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void asm_x64_call_ind(asm_x64_t* as, void *ptr, int temp_r64) {
|
void asm_x64_call_ind(asm_x64_t* as, void *ptr, int temp_r64) {
|
||||||
asm_x64_mov_i64_to_r64_optimised(as, (int64_t)ptr, temp_r64);
|
asm_x64_mov_i64_to_r64_optimised(as, (machine_int_t)ptr, temp_r64);
|
||||||
asm_x64_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R64(2) | MODRM_RM_REG | MODRM_RM_R64(temp_r64));
|
asm_x64_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R64(2) | MODRM_RM_REG | MODRM_RM_R64(temp_r64));
|
||||||
// this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all
|
// this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all
|
||||||
// doesn't work anymore because calls are 64 bits away
|
// doesn't work anymore because calls are 64 bits away
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@ thumb callee save: bx, bp, sp, r12, r14, r14, r15
|
#ifdef __thumb2__
|
||||||
|
/* thumb callee save: bx, bp, sp, r12, r14, r14, r15 */
|
||||||
|
|
||||||
.syntax unified
|
.syntax unified
|
||||||
.cpu cortex-m4
|
.cpu cortex-m4
|
||||||
@ -6,7 +7,7 @@
|
|||||||
.text
|
.text
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
@ uint nlr_push(r0=nlr_buf_t *nlr)
|
/* uint nlr_push(r0=nlr_buf_t *nlr) */
|
||||||
.global nlr_push
|
.global nlr_push
|
||||||
.thumb
|
.thumb
|
||||||
.thumb_func
|
.thumb_func
|
||||||
@ -51,7 +52,7 @@ nlr_pop:
|
|||||||
.word .LANCHOR0
|
.word .LANCHOR0
|
||||||
.size nlr_pop, .-nlr_pop
|
.size nlr_pop, .-nlr_pop
|
||||||
|
|
||||||
@ void nlr_jump(r0=uint val)
|
/* void nlr_jump(r0=uint val) */
|
||||||
.global nlr_jump
|
.global nlr_jump
|
||||||
.thumb
|
.thumb
|
||||||
.thumb_func
|
.thumb_func
|
||||||
@ -81,7 +82,7 @@ nlr_jump:
|
|||||||
.word .LANCHOR0
|
.word .LANCHOR0
|
||||||
.size nlr_jump, .-nlr_jump
|
.size nlr_jump, .-nlr_jump
|
||||||
|
|
||||||
@ local variable nlr_top
|
/* local variable nlr_top */
|
||||||
.bss
|
.bss
|
||||||
.align 2
|
.align 2
|
||||||
.set .LANCHOR0,. + 0
|
.set .LANCHOR0,. + 0
|
||||||
@ -89,3 +90,4 @@ nlr_jump:
|
|||||||
.size nlr_top, 4
|
.size nlr_top, 4
|
||||||
nlr_top:
|
nlr_top:
|
||||||
.space 4
|
.space 4
|
||||||
|
#endif
|
@ -1,9 +1,10 @@
|
|||||||
# x64 callee save: bx, bp, sp, r12, r14, r14, r15
|
#ifdef __x86_64__
|
||||||
|
/* x64 callee save: bx, bp, sp, r12, r14, r14, r15 */
|
||||||
|
|
||||||
.file "nlr.s"
|
.file "nlr.s"
|
||||||
.text
|
.text
|
||||||
|
|
||||||
# uint nlr_push(rdi=nlr_buf_t *nlr)
|
/* uint nlr_push(rdi=nlr_buf_t *nlr) */
|
||||||
.globl nlr_push
|
.globl nlr_push
|
||||||
.type nlr_push, @function
|
.type nlr_push, @function
|
||||||
nlr_push:
|
nlr_push:
|
||||||
@ -23,7 +24,7 @@ nlr_push:
|
|||||||
ret # return
|
ret # return
|
||||||
.size nlr_push, .-nlr_push
|
.size nlr_push, .-nlr_push
|
||||||
|
|
||||||
# void nlr_pop()
|
/* void nlr_pop() */
|
||||||
.globl nlr_pop
|
.globl nlr_pop
|
||||||
.type nlr_pop, @function
|
.type nlr_pop, @function
|
||||||
nlr_pop:
|
nlr_pop:
|
||||||
@ -33,7 +34,7 @@ nlr_pop:
|
|||||||
ret # return
|
ret # return
|
||||||
.size nlr_pop, .-nlr_pop
|
.size nlr_pop, .-nlr_pop
|
||||||
|
|
||||||
# void nlr_jump(rdi=uint val)
|
/* void nlr_jump(rdi=uint val) */
|
||||||
.globl nlr_jump
|
.globl nlr_jump
|
||||||
.type nlr_jump, @function
|
.type nlr_jump, @function
|
||||||
nlr_jump:
|
nlr_jump:
|
||||||
@ -58,3 +59,4 @@ nlr_jump:
|
|||||||
|
|
||||||
.local nlr_top
|
.local nlr_top
|
||||||
.comm nlr_top,8,8
|
.comm nlr_top,8,8
|
||||||
|
#endif
|
@ -1,9 +1,10 @@
|
|||||||
# x86 callee save: bx, di, si, bp, sp
|
#ifdef __i386__
|
||||||
|
/* x86 callee save: bx, di, si, bp, sp */
|
||||||
|
|
||||||
.file "nlr.s"
|
.file "nlr.s"
|
||||||
.text
|
.text
|
||||||
|
|
||||||
# uint nlr_push(4(%esp)=nlr_buf_t *nlr)
|
/* uint nlr_push(4(%esp)=nlr_buf_t *nlr) */
|
||||||
.globl nlr_push
|
.globl nlr_push
|
||||||
.type nlr_push, @function
|
.type nlr_push, @function
|
||||||
nlr_push:
|
nlr_push:
|
||||||
@ -22,7 +23,7 @@ nlr_push:
|
|||||||
ret # return
|
ret # return
|
||||||
.size nlr_push, .-nlr_push
|
.size nlr_push, .-nlr_push
|
||||||
|
|
||||||
# void nlr_pop()
|
/* void nlr_pop() */
|
||||||
.globl nlr_pop
|
.globl nlr_pop
|
||||||
.type nlr_pop, @function
|
.type nlr_pop, @function
|
||||||
nlr_pop:
|
nlr_pop:
|
||||||
@ -32,7 +33,7 @@ nlr_pop:
|
|||||||
ret # return
|
ret # return
|
||||||
.size nlr_pop, .-nlr_pop
|
.size nlr_pop, .-nlr_pop
|
||||||
|
|
||||||
# void nlr_jump(4(%esp)=uint val)
|
/* void nlr_jump(4(%esp)=uint val) */
|
||||||
.globl nlr_jump
|
.globl nlr_jump
|
||||||
.type nlr_jump, @function
|
.type nlr_jump, @function
|
||||||
nlr_jump:
|
nlr_jump:
|
||||||
@ -55,3 +56,4 @@ nlr_jump:
|
|||||||
|
|
||||||
.local nlr_top
|
.local nlr_top
|
||||||
.comm nlr_top,4,4
|
.comm nlr_top,4,4
|
||||||
|
#endif
|
32
py/showbc.c
32
py/showbc.c
@ -70,7 +70,7 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_LOAD_FAST_N:
|
case MP_BC_LOAD_FAST_N:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("LOAD_FAST_N %lu", unum);
|
printf("LOAD_FAST_N " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_LOAD_NAME:
|
case MP_BC_LOAD_NAME:
|
||||||
@ -111,7 +111,7 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_STORE_FAST_N:
|
case MP_BC_STORE_FAST_N:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("STORE_FAST_N %lu", unum);
|
printf("STORE_FAST_N " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_STORE_NAME:
|
case MP_BC_STORE_NAME:
|
||||||
@ -161,17 +161,17 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_JUMP:
|
case MP_BC_JUMP:
|
||||||
DECODE_SLABEL;
|
DECODE_SLABEL;
|
||||||
printf("JUMP %lu", ip + unum - ip_start);
|
printf("JUMP " UINT_FMT, ip + unum - ip_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_POP_JUMP_IF_TRUE:
|
case MP_BC_POP_JUMP_IF_TRUE:
|
||||||
DECODE_SLABEL;
|
DECODE_SLABEL;
|
||||||
printf("POP_JUMP_IF_TRUE %lu", ip + unum - ip_start);
|
printf("POP_JUMP_IF_TRUE " UINT_FMT, ip + unum - ip_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_POP_JUMP_IF_FALSE:
|
case MP_BC_POP_JUMP_IF_FALSE:
|
||||||
DECODE_SLABEL;
|
DECODE_SLABEL;
|
||||||
printf("POP_JUMP_IF_FALSE %lu", ip + unum - ip_start);
|
printf("POP_JUMP_IF_FALSE " UINT_FMT, ip + unum - ip_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -196,7 +196,7 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_SETUP_EXCEPT:
|
case MP_BC_SETUP_EXCEPT:
|
||||||
DECODE_ULABEL; // except labels are always forward
|
DECODE_ULABEL; // except labels are always forward
|
||||||
printf("SETUP_EXCEPT %lu", ip + unum - ip_start);
|
printf("SETUP_EXCEPT " UINT_FMT, ip + unum - ip_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_END_FINALLY:
|
case MP_BC_END_FINALLY:
|
||||||
@ -213,7 +213,7 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_FOR_ITER:
|
case MP_BC_FOR_ITER:
|
||||||
DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward
|
DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward
|
||||||
printf("FOR_ITER %lu", ip + unum - ip_start);
|
printf("FOR_ITER " UINT_FMT, ip + unum - ip_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_POP_BLOCK:
|
case MP_BC_POP_BLOCK:
|
||||||
@ -235,22 +235,22 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_BINARY_OP:
|
case MP_BC_BINARY_OP:
|
||||||
unum = *ip++;
|
unum = *ip++;
|
||||||
printf("BINARY_OP %lu", unum);
|
printf("BINARY_OP " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_COMPARE_OP:
|
case MP_BC_COMPARE_OP:
|
||||||
unum = *ip++;
|
unum = *ip++;
|
||||||
printf("COMPARE_OP %lu", unum);
|
printf("COMPARE_OP " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_BUILD_TUPLE:
|
case MP_BC_BUILD_TUPLE:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("BUILD_TUPLE %lu", unum);
|
printf("BUILD_TUPLE " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_BUILD_LIST:
|
case MP_BC_BUILD_LIST:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("BUILD_LIST %lu", unum);
|
printf("BUILD_LIST " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -264,7 +264,7 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_BUILD_MAP:
|
case MP_BC_BUILD_MAP:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("BUILD_MAP %lu", unum);
|
printf("BUILD_MAP " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -293,22 +293,22 @@ void mp_show_byte_code(const byte *ip, int len) {
|
|||||||
|
|
||||||
case MP_BC_UNPACK_SEQUENCE:
|
case MP_BC_UNPACK_SEQUENCE:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("UNPACK_SEQUENCE %lu", unum);
|
printf("UNPACK_SEQUENCE " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_MAKE_FUNCTION:
|
case MP_BC_MAKE_FUNCTION:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("MAKE_FUNCTION %lu", unum);
|
printf("MAKE_FUNCTION " UINT_FMT, unum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_CALL_FUNCTION:
|
case MP_BC_CALL_FUNCTION:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("CALL_FUNCTION n=%lu nkw=%lu", unum & 0xff, (unum >> 8) & 0xff);
|
printf("CALL_FUNCTION n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_CALL_METHOD:
|
case MP_BC_CALL_METHOD:
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
printf("CALL_METHOD n=%lu nkw=%lu", unum & 0xff, (unum >> 8) & 0xff);
|
printf("CALL_METHOD n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_RETURN_VALUE:
|
case MP_BC_RETURN_VALUE:
|
||||||
|
@ -9,7 +9,9 @@ SRC_C = \
|
|||||||
main.c \
|
main.c \
|
||||||
|
|
||||||
PY_O = \
|
PY_O = \
|
||||||
|
nlrx86.o \
|
||||||
nlrx64.o \
|
nlrx64.o \
|
||||||
|
nlrthumb.o \
|
||||||
malloc.o \
|
malloc.o \
|
||||||
qstr.o \
|
qstr.o \
|
||||||
vstr.o \
|
vstr.o \
|
||||||
@ -73,6 +75,9 @@ $(BUILD)/%.o: %.c
|
|||||||
$(BUILD)/%.o: $(PYSRC)/%.s
|
$(BUILD)/%.o: $(PYSRC)/%.s
|
||||||
$(AS) -o $@ $<
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
|
$(BUILD)/%.o: $(PYSRC)/%.S
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(BUILD)/%.o: $(PYSRC)/%.c mpconfig.h
|
$(BUILD)/%.o: $(PYSRC)/%.c mpconfig.h
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
@ -8,10 +8,22 @@
|
|||||||
|
|
||||||
// type definitions for the specific machine
|
// type definitions for the specific machine
|
||||||
|
|
||||||
#define BYTES_PER_WORD (8)
|
#ifdef __LP64__
|
||||||
|
typedef long machine_int_t; // must be pointer size
|
||||||
|
typedef unsigned long machine_uint_t; // must be pointer size
|
||||||
|
#define UINT_FMT "%lu"
|
||||||
|
#define INT_FMT "%ld"
|
||||||
|
#else
|
||||||
|
// These are definitions for machines where sizeof(int) == sizeof(void*),
|
||||||
|
// regardless for actual size.
|
||||||
|
typedef int machine_int_t; // must be pointer size
|
||||||
|
typedef unsigned int machine_uint_t; // must be pointer size
|
||||||
|
#define UINT_FMT "%u"
|
||||||
|
#define INT_FMT "%d"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BYTES_PER_WORD sizeof(machine_int_t)
|
||||||
|
|
||||||
typedef int64_t machine_int_t; // must be pointer size
|
|
||||||
typedef uint64_t machine_uint_t; // must be pointer size
|
|
||||||
typedef void *machine_ptr_t; // must be of pointer size
|
typedef void *machine_ptr_t; // must be of pointer size
|
||||||
typedef const void *machine_const_ptr_t; // must be of pointer size
|
typedef const void *machine_const_ptr_t; // must be of pointer size
|
||||||
typedef double machine_float_t;
|
typedef double machine_float_t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user