aboutsummaryrefslogtreecommitdiff
path: root/py/asmthumb.c
AgeCommit message (Collapse)Author
2022-05-24py/asmthumb: Provide implementations of clz/ctz for msvc.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-05-23py/asmthumb: Make ARMv7-M instruction use dynamically selectable.Damien George
This commit adjusts the asm_thumb_xxx functions so they can be dynamically configured to use ARMv7-M instructions or not. This is available when MICROPY_DYNAMIC_COMPILER is enabled, and then controlled by the value of mp_dynamic_compiler.native_arch. If MICROPY_DYNAMIC_COMPILER is disabled the previous behaviour is retained: the functions emit ARMv7-M instructions only if MICROPY_EMIT_THUMB_ARMV7M is enabled. Signed-off-by: Damien George <damien@micropython.org>
2022-05-23py/asmthumb: Add asm_thumb_ldrh_reg_reg_i12_optimised() helper func.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-05-19py/asmthumb: Fix PC relative load by sign extending the constant.Damien George
PC relative offsets can be negative, in which case the movw result must be sign extended. Signed-off-by: Damien George <damien@micropython.org>
2021-06-05py/emitglue: Always flush caches when assigning native ARM code.Damien George
Prior to this commit, cache flushing for ARM native code was done only in the assembler code asm_thumb_end_pass()/asm_arm_end_pass(), at the last pass of the assembler. But this misses flushing the cache when loading native code from an .mpy file, ie in persistentcode.c. The change here makes sure the cache is always flushed/cleaned/invalidated when assigning native code on ARM architectures. This problem was found running tests/micropython/import_mpy_native_gc.py on the mimxrt port. Signed-off-by: Damien George <damien@micropython.org>
2021-01-29py/emitnative: Support binary ops on ARMv6M without use of ite instr.graham sanderson
2021-01-29py/asmthumb: Add support for ARMv6M in native emitter.graham sanderson
Adds a new compile-time option MICROPY_EMIT_THUMB_ARMV7M which is enabled by default (to get existing behaviour) and which should be disabled (set to 0) when building native emitter support (@micropython.native) on ARMv6M targets.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2019-05-01py/asmthumb: Support asm_thumb code running on normal ARM processors.Damien George
With this change, @micropython.asm_thumb functions will work on standard ARM processors (that are in ARM state by default), in scripts and precompiled .mpy files. Addresses issue #4675.
2019-03-08py: Add support to save native, viper and asm code to .mpy files.Damien George
This commit adds support for saving and loading .mpy files that contain native code (native, viper and inline-asm). A lot of the ground work was already done for this in the form of removing pointers from generated native code. The changes here are mainly to link in qstr values to the native code, and change the format of .mpy files to contain native code blocks (possibly mixed with bytecode). A top-level summary: - @micropython.native, @micropython.viper and @micropython.asm_thumb/ asm_xtensa are now allowed in .py files when compiling to .mpy, and they work transparently to the user. - Entire .py files can be compiled to native via mpy-cross -X emit=native and for the most part the generated .mpy files should work the same as their bytecode version. - The .mpy file format is changed to 1) specify in the header if the file contains native code and if so the architecture (eg x86, ARMV7M, Xtensa); 2) for each function block the kind of code is specified (bytecode, native, viper, asm). - When native code is loaded from a .mpy file the native code must be modified (in place) to link qstr values in, just like bytecode (see py/persistentcode.c:arch_link_qstr() function). In addition, this now defines a public, native ABI for dynamically loadable native code generated by other languages, like C.
2018-10-13py/asmthumb: Remove unused fun_ptr arg from asm_thumb_bl_ind function.Damien George
2018-10-13py/emitnative: Load native fun table ptr from const table for all archs.Damien George
All architectures now have a dedicated register to hold the pointer to the native function table mp_fun_table, and so they all need to load this register at the start of the native function. This commit makes the loading of this register uniform across architectures by passing the pointer in the constant table for the native function, and then loading the register from the constant table. Doing it this way means that the pointer is not stored in the assembly code, helping to make the code more portable.
2018-09-30py/asmthumb: Extend asm entry/exit to handle stack larger than 508 bytesDamien George
2018-09-30py/asmthumb: Clean up asm_thumb_bl_ind to use new optimised ldr helper.Damien George
2018-09-30py/asmthumb: Add wide ldr to handle larger offsets.Damien George
In particular this allows native functions on Thumb2 to index more than 32 constants in the constant table.
2018-09-27py/asm*: Remove ASM_MOV_REG_ALIGNED_IMM emit macro, it's no longer used.Damien George
After the previous commit this macro is no longer needed by the native emitter because live heap pointers are no longer stored in generated native machine code.
2018-09-16py/asmthumb: Detect presence of I-cache using CMSIS macro.Damien George
Fixes issue #4113.
2018-08-16py/asm*: Support assembling code to jump to a register, and get PC+off.Damien George
Useful for position independent code, and implementing state machines.
2018-07-31py/asmthumb: Optimise native code calling runtime glue functions.Damien George
This patch makes the Thumb-2 native emitter use wide ldr instructions to call into the runtime, when the index into the native glue function table is 32 or greater. This reduces the generated assembler code from 10 bytes to 6 bytes, saving RAM and making native code run about 0.8% faster.
2018-02-24py/asm*.c: Remove unnecessary check for num_locals<0 in asm entry func.Damien George
All callers of the asm entry function guarantee that num_locals>=0, so no need to add an explicit check for it. Use an assertion instead. Also, the signature of asm_x86_entry is changed to match the other asm entry functions.
2017-08-23py/asmthumb: Use existing macro to properly clear the D-cache.Damien George
This macro is provided by stmhal/mphalport.h and makes sure the addr and size arguments are correctly aligned.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-05-29various: Spelling fixesVille Skyttä
2016-12-09py/asm: Remove need for dummy_data when doing initial assembler passes.Damien George
For all but the last pass the assembler only needs to count how much space is needed for the machine code, it doesn't actually need to emit anything. The dummy_data just uses unnecessary RAM and without it the code is not any more complex (and code size does not increase for Thumb and Xtensa archs).
2016-11-30py/asmthumb: Fix build for F7 MCUs after recent code refactoring.Damien George
2016-11-28py: Factor out common code from assemblers into asmbase.[ch].Damien George
All assemblers should "derive" from mp_asm_base_t.
2016-09-09py/asmthumb: Flush D-cache, and invalidate I-cache on STM32F7.Antonin ENFRUN
Tested on a STM32F7DISCO at 216MHz. All tests generating code (inlineasm, native, viper) now pass, except pybnative/while.py, but that's because there is no LED(2).
2015-11-09py/asmthumb: Allow to compile with -Wsign-compare and -Wunused-parameter.Damien George
2015-04-07py: Implement full func arg passing for native emitter.Damien George
This patch gets full function argument passing working with native emitter. Includes named args, keyword args, default args, var args and var keyword args. Fully Python compliant. It reuses the bytecode mp_setup_code_state function to do all the hard work. This function is slightly adjusted to accommodate native calls, and the native emitter is forced a bit to emit similar prelude and code-info as bytecode.
2015-03-02py: In inline assembler, fix branch out-of-range error reporting.Damien George
Should only give an error on the last pass of the assembler, since that's when we are certain about the branch size.
2015-03-02py: For inline assembler, add bcc_n and bcc_w ops.Damien George
Addresses issue #1143.
2015-02-25py: Make inline assembler raise exception when branch not in range.Damien George
Addresses issue #1132.
2015-02-24py: Make more asmthumb functions inline to reduce code size.Damien George
2015-02-16py: Implement bl/bx instructions for inline Thumb assembler.Damien George
2015-02-15py: Fix loading of immediate pointer in Thumb assembler.Damien George
Addresses issue #1117.
2015-01-14py: Allocate memory for assembled code at start of PASS_EMIT.Damien George
Previously was allocating at end of PASS_COMPUTE, and this pass was being run twice, so memory was being allocated twice.
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-09-29py: Make macro names in assemblers consistent, and tidy up a bit.Damien George
2014-09-29py: In asmthumb, clean up unit/int types and ite ops.Damien George
2014-09-03Add cache flush in py/asmarm.c and add new MP_PLAT_ALLOC_EXEC and ↵Fabian Vogt
MP_PLAT_FREE_EXEC macros Fixes issue #840
2014-08-24py: Fix bug where GC collected native/viper/asm function data.Damien George
Because (for Thumb) a function pointer has the LSB set, pointers to dynamic functions in RAM (eg native, viper or asm functions) were not being traced by the GC. This patch is a comprehensive fix for this. Addresses issue #820.
2014-08-16py: Code clean-up in native emitter; improve thumb native calls.Damien George
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-21py: Include mpconfig.h before all other includes.Paul Sokolovsky
It defines types used by all other headers. Fixes #691.
2014-05-10py, emitters: Fix dummy_data size for bytecode and thumb.Damien George
Thumb uses a bit less RAM, bytecode uses a tiny bit more, to avoid overflow of the dummy buffer in certain cases. Addresses issue #599.
2014-05-07py: Fix stack access in thumb native emitter.Damien George
2014-05-07py, compiler: Improve passes; add an extra pass for native emitter.Damien George
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-04-21py: Add 'align' and 'data' meta-instructions to inline assembler.Damien George
2014-04-18inlinethumb: Add wfi, cpsid and cpsie instructions.Damien George