aboutsummaryrefslogtreecommitdiff
path: root/py/asmxtensa.h
AgeCommit message (Collapse)Author
2022-05-23py/asm: Add ASM_LOAD16_REG_REG_OFFSET macro for load-u16 with offset.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-30py/asmxtensa: Fix use of l32i/s32i when offset won't fit in encoding.Damien George
This commit adds optimised l32i/s32i functions that select the best load/ store encoding based on the size of the offset, and uses the function when necessary in code generation. Without this, ASM_LOAD_REG_REG_OFFSET() could overflow the word offset (using a narrow encoding), for example when loading the prelude from the constant table when there are many (>16) constants. Fixes issue #8458. Signed-off-by: Damien George <damien@micropython.org>
2020-06-27py/asm: Add funcs/macros to emit machine code for logical-shift-right.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2019-10-05py/asmxtensa: Add support for Xtensa with windowed registers.Damien George
Window-specific asm emit functions are added, along with a new macro option GENERIC_ASM_API_WIN.
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/emitnative: Remove unused ptr argument from ASM_CALL_IND macro.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-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/asmxtensa: Make indirect calls using func table, not raw pointers.Damien George
Loading a pointer by indexing into the native function table mp_fun_table, rather than loading an immediate value (via a PC-relative load), uses less code space.
2018-08-17py/asmxtensa: Use narrow version of add instr to reduce native code sizeDamien George
2018-08-17py/asmxtensa: Fix bug with order of regs in addi encoding.Damien George
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-08-04py/emitnative: Fix x86 native zero checks by comparing full word.Damien George
On x86 archs (both 32 and 64 bit) a bool return value only sets the 8-bit al register, and the higher bits of the ax register have an undefined value. When testing the return value of such cases it is required to just test al for zero/non-zero. On the other hand, checking for truth or zero/non-zero on an integer return value requires checking all bits of the register. These two cases must be distinguished and handled correctly in generated native code. This patch makes sure of this. For other supported native archs (ARM, Thumb2, Xtensa) there is no such distinction and this patch does not change anything for them.
2017-11-15py/emitnative: Clean up asm macro names so they have dest as first arg.Damien George
All the asm macro names that convert a particular architecture to a generic interface now follow the convention whereby the "destination" (usually a register) is specified first.
2017-02-08py/asmxtensa.h: Explicitly cast args to 32-bits so left-shift is legal.Damien George
For archs that have 16-bit pointers, the asmxtensa.h file can give compiler warnings about left-shift being greater than the width of the type (due to the inline functions in this header file). Explicitly casting the constants to uint32_t stops these warnings.
2016-12-09py/asmxtensa: Add low-level Xtensa assembler.Damien George