|
4 | 4 | #
|
5 | 5 | # The MIT License (MIT)
|
6 | 6 | #
|
7 |
| -# Copyright (c) 2016 Damien P. George |
| 7 | +# Copyright (c) 2016-2019 Damien P. George |
8 | 8 | #
|
9 | 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 | 10 | # of this software and associated documentation files (the "Software"), to deal
|
@@ -479,18 +479,23 @@ def _asm_thumb_rewrite_mov(self, pc, val):
|
479 | 479 |
|
480 | 480 | def _link_qstr(self, pc, kind, qst):
|
481 | 481 | if kind == 0:
|
| 482 | + # Generic 16-bit link |
482 | 483 | print(' %s & 0xff, %s >> 8,' % (qst, qst))
|
483 | 484 | else:
|
484 |
| - if kind == 2: |
| 485 | + # Architecture-specific link |
| 486 | + is_obj = kind == 2 |
| 487 | + if is_obj: |
485 | 488 | qst = '((uintptr_t)MP_OBJ_NEW_QSTR(%s))' % qst
|
486 | 489 | if config.native_arch in (MP_NATIVE_ARCH_X86, MP_NATIVE_ARCH_X64):
|
487 | 490 | print(' %s & 0xff, %s >> 8, 0, 0,' % (qst, qst))
|
488 | 491 | elif MP_NATIVE_ARCH_ARMV6M <= config.native_arch <= MP_NATIVE_ARCH_ARMV7EMDP:
|
489 | 492 | if is_obj:
|
490 |
| - self._asm_thumb_rewrite_mov(i, qst) |
491 |
| - self._asm_thumb_rewrite_mov(i + 4, '(%s >> 16)' % qst) |
| 493 | + # qstr object, movw and movt |
| 494 | + self._asm_thumb_rewrite_mov(pc, qst) |
| 495 | + self._asm_thumb_rewrite_mov(pc + 4, '(%s >> 16)' % qst) |
492 | 496 | else:
|
493 |
| - self._asm_thumb_rewrite_mov(i, qst) |
| 497 | + # qstr number, movw instruction |
| 498 | + self._asm_thumb_rewrite_mov(pc, qst) |
494 | 499 | else:
|
495 | 500 | assert 0
|
496 | 501 |
|
@@ -663,7 +668,7 @@ def read_raw_code(f, qstr_win):
|
663 | 668 | # load qstr link table
|
664 | 669 | n_qstr_link = read_uint(f)
|
665 | 670 | for _ in range(n_qstr_link):
|
666 |
| - off = read_uint(f, qstr_win) |
| 671 | + off = read_uint(f) |
667 | 672 | qst = read_qstr(f, qstr_win)
|
668 | 673 | qstr_links.append((off >> 2, off & 3, qst))
|
669 | 674 |
|
@@ -714,7 +719,12 @@ def read_mpy(filename):
|
714 | 719 | qw_size = read_uint(f)
|
715 | 720 | config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = (feature_byte & 1) != 0
|
716 | 721 | config.MICROPY_PY_BUILTINS_STR_UNICODE = (feature_byte & 2) != 0
|
717 |
| - config.native_arch = feature_byte >> 2 |
| 722 | + mpy_native_arch = feature_byte >> 2 |
| 723 | + if mpy_native_arch != MP_NATIVE_ARCH_NONE: |
| 724 | + if config.native_arch == MP_NATIVE_ARCH_NONE: |
| 725 | + config.native_arch = mpy_native_arch |
| 726 | + elif config.native_arch != mpy_native_arch: |
| 727 | + raise Exception('native architecture mismatch') |
718 | 728 | config.mp_small_int_bits = header[3]
|
719 | 729 | qstr_win = QStrWindow(qw_size)
|
720 | 730 | return read_raw_code(f, qstr_win)
|
@@ -838,6 +848,7 @@ def main():
|
838 | 848 | 'mpz':config.MICROPY_LONGINT_IMPL_MPZ,
|
839 | 849 | }[args.mlongint_impl]
|
840 | 850 | config.MPZ_DIG_SIZE = args.mmpz_dig_size
|
| 851 | + config.native_arch = MP_NATIVE_ARCH_NONE |
841 | 852 |
|
842 | 853 | # set config values for qstrs, and get the existing base set of qstrs
|
843 | 854 | if args.qstr_header:
|
|
0 commit comments