aboutsummaryrefslogtreecommitdiff
path: root/py/asmx86.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>
2020-06-27py/asm: Add condition codes for signed comparisons.Damien George
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>
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-12-27py/asmx86: Remove unused 5th argument facility.Damien George
In commit 71a3d6ec3bd02c5bd13334537e1bd146bb643bad mp_setup_code_state was changed from a 5-arg function to a 4-arg function, and at that point 5-arg calls in native code were no longer needed. See also commit 4f9842ad80c235188955fd83317f715033a596c0.
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-10-13py/asmx86: Change indirect calls to load fun ptr from the native table.Damien George
Instead of storing the function pointer directly in the assembly code. This makes the generated code more independent of the runtime (so easier to relocate the code), and reduces the generated code size.
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-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.
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-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-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-07-18all: Unify header guard usage.Alexander Steffen
The code conventions suggest using header guards, but do not define how those should look like and instead point to existing files. However, not all existing files follow the same scheme, sometimes omitting header guards altogether, sometimes using non-standard names, making it easy to accidentally pick a "wrong" example. This commit ensures that all header files of the MicroPython project (that were not simply copied from somewhere else) follow the same pattern, that was already present in the majority of files, especially in the py folder. The rules are as follows. Naming convention: * start with the words MICROPY_INCLUDED * contain the full path to the file * replace special characters with _ In addition, there are no empty lines before #ifndef, between #ifndef and one empty line before #endif. #endif is followed by a comment containing the name of the guard macro. py/grammar.h cannot use header guards by design, since it has to be included multiple times in a single C file. Several other files also do not need header guards as they are only used internally and guaranteed to be included only once: * MICROPY_MPHALPORT_H * mpconfigboard.h * mpconfigport.h * mpthreadport.h * pin_defs_*.h * qstrdefs*.h
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-12-09py: Move arch-specific assembler macros from emitnative to asmXXX.h.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.
2015-06-04py: Implement native multiply operation in viper emitter.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-01-01py: Add guarded includes for asm-based headers.Damien George
2014-10-12py: Implement native load for viper.Damien George
Viper can now do: ptr8(buf)[0], which loads a byte from a buffer using machine instructions.
2014-10-12py: Implement and,or,xor native ops for viper.Damien George
2014-09-29py: Implement more binary ops for viper emitter.Damien George
This included a bit of restructuring of the assembler backends. Note that the ARM backend is missing a few functions and won't compile.
2014-09-29py: Make macro names in assemblers consistent, and tidy up a bit.Damien George
2014-09-29py: Add store r8 and store r16 ops to asm_x86 and asm_x64.Damien George
2014-09-08py: Put define of x86 argument registers in asmx86.h.Damien George
2014-09-07py: Clean up x86-64 native assembler; allow use of extended regs.Damien George
Native x86-64 now has 3 locals in registers.
2014-09-06py: Adjust regs for x86 so that 1 more local can live in a reg.Damien George
2014-09-06py: Allow x86 native functions to take arguments.Damien George
Fix some bugs with x86 stack and saving registers correctly.
2014-09-06py: Add support for emitting native x86 machine code.Damien George