Commit Graph

67 Commits

Author SHA1 Message Date
Damien George 28adab36c7 py/emitinlinethumb: Use qstrs instead of char* for names of asm ops.
Reduces code size by 112 bytes on Thumb2 arch, and makes assembler faster
because comparison can be a simple equals instead of a string compare.

Not all ops have been converted, only those that were simple to convert
and reduced code size.
2016-02-23 15:20:39 +00:00
Damien George 8f54c08691 py/inlineasm: Add ability to specify return type of asm_thumb funcs.
Supported return types are: object, bool, int, uint.

For example:

@micropython.asm_thumb
def foo(r0, r1) -> uint:
    add(r0, r0, r1)
2016-01-27 14:27:10 +00:00
Damien George ea8be373a9 py/inlinethumb: Remove 30-bit restriction on movwt instruction.
movwt can now move a full 32-bit constant into a register.
2016-01-07 16:34:11 +00:00
Damien George 47dc5922ca py/inlinethumb: Allow assembler to use big ints as args to instructions. 2016-01-07 16:21:07 +00:00
Henrik Sölver e242b1785f py/emitinlinethumb: Add support for MRS instruction.
Only IPSR and BASEPRI special registers supported at the moment, but easy
to extend in the future.
2015-12-10 17:32:54 +00:00
Damien George c3f64d9799 py: Change qstr_* functions to use size_t as the type for str len arg. 2015-11-29 14:25:04 +00:00
Damien George 713ea1800d py: Add constant table to bytecode.
Contains just argument names at the moment but makes it easy to add
arbitrary constants.
2015-11-13 12:49:18 +00:00
Damien George 3a3db4dcf0 py: Put all bytecode state (arg count, etc) in bytecode. 2015-11-13 12:49:18 +00:00
Damien George 1f92ffb5b7 py/emitinlinethumb: Allow to compile with -Wsign-compare. 2015-11-09 14:11:47 +00:00
adminpete d6201fc4b7 py: In inline asm, vldr and vstr offsets now in bytes not words.
As per ARM convention.
2015-10-31 10:50:45 +00:00
Damien George 096d1e4512 py: Add lsl/lsr/asr opcode support to inline Thumb2 assembler. 2015-10-19 14:26:19 +01:00
Damien George e813541e3f py: Add option for inline assembler to support ARMv7-M instructions.
Cortex-M0, M0+ and M1 only have ARMv6-M Thumb/Thumb2 instructions.  M3,
M4 and M7 have a superset of these, named ARMv7-M.  This patch adds a
config option to enable support of the superset of instructions.
2015-10-16 22:08:57 +01:00
= 5008972fef py/inlinethumb: Support for core floating point instructions.
Adds support for the following Thumb2 VFP instructions, via the option
MICROPY_EMIT_INLINE_THUMB_FLOAT:

vcmp
vsqrt
vneg
vcvt_f32_to_s32
vcvt_s32_to_f32
vmrs
vmov
vldr
vstr
vadd
vsub
vmul
vdiv
2015-04-19 15:47:05 +01:00
Damien George 044c473de2 py: Add %q format support to mp_[v]printf, and use it. 2015-04-16 14:30:16 +00:00
Damien George 6eb7530083 py: In emitinlinethumb, use qstr_data instead of qstr_str and strlen. 2015-04-11 21:53:39 +01:00
Damien George 9988618e0e py: Implement full func arg passing for native emitter.
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-04-07 22:43:28 +01:00
Damien George dc790977d4 py: In inline assembler, reset labels on code-size pass. 2015-03-03 17:34:49 +00:00
Damien George 9c5cabb502 py: Give error for duplicate label in inline assembler. 2015-03-03 17:08:02 +00:00
Damien George 9f142f0c84 py: For inline assembler, add bcc_n and bcc_w ops.
Addresses issue #1143.
2015-03-02 14:29:52 +00:00
Damien George 534574348e py: Make inline assembler raise exception when branch not in range.
Addresses issue #1132.
2015-02-25 15:45:55 +00:00
Damien George 993f067fa2 py: In inline assembler, add return statement to fix flow logic. 2015-02-24 22:43:01 +00:00
Damien George e5315f7ffd py: Factor some code in inline thumb assembler to reduce code size. 2015-02-24 16:35:37 +00:00
Damien George e41b21c01e py: Make more asmthumb functions inline to reduce code size. 2015-02-24 16:32:52 +00:00
Damien George 8f7976ba0d py: Reduce code size of inline thumb assembler by using static tables.
Reduces stmhal by about 300 bytes ROM.
2015-02-24 16:10:58 +00:00
Damien George eff10f66a6 py: Implement bl/bx instructions for inline Thumb assembler. 2015-02-16 18:17:07 +00:00
Damien George 42495392da py: Implement "it" instruction for inline Thumb assembler. 2015-02-16 17:46:49 +00:00
Damien George 192d536fe4 py: Implement clz and rbit for inline Thumb assembler. 2015-02-13 11:06:23 +00:00
Damien George 32f0b7942c py: Implement sdiv/udiv for inline Thumb assembler. 2015-02-13 10:43:05 +00:00
Damien George 0d967b8ae4 py: Implement push/pop for inline Thumb assembler. 2015-02-13 02:30:35 +00:00
Damien George 8dfbd2d589 py: Make inline assembler raise proper SyntaxError exception on error.
Also gives line number of location of error.  Very useful!
2015-02-13 01:00:51 +00:00
Damien George 1bf5a022fe py: Add ldrex and strex to thumb2 inline assembler.
These are useful for implementing atomic lock operations.
2015-02-12 22:52:42 +00:00
Damien George 51dfcb4bb7 py: Move to guarded includes, everywhere in py/ core.
Addresses issue #1022.
2015-01-01 20:32:09 +00:00
Damien George 6efa66f125 py: Remove unnecessary RULE_none and PN_none from parser. 2014-12-20 18:41:59 +00:00
Damien George 969a6b37bf py: Make functions static where appropriate. 2014-12-10 22:08:14 +00:00
Damien George 0b610de017 py: Make macro names in assemblers consistent, and tidy up a bit. 2014-09-29 19:42:06 +01:00
Damien George 851f15f34c py: In asmthumb, clean up unit/int types and ite ops. 2014-09-29 19:42:06 +01:00
Damien George 7ff996c237 py: Convert [u]int to mp_[u]int_t in emit.h and associated .c files.
Towards resolving issue #50.
2014-09-08 23:05:16 +01:00
Damien George 2ac4af6946 py: Allow viper to have type annotations.
Viper functions can now be annotated with the type of their arguments
and return value.  Eg:

@micropython.viper
def f(x:int) -> int:
    return x + 1
2014-08-15 16:45:41 +01:00
Damien George a4022c92f0 py, inline asm: Change "and" op name to "and_" to avoid keyword clash.
Addresses issue #753.
2014-07-17 12:37:56 +01:00
Paul Sokolovsky 59c675a64c py: Include mpconfig.h before all other includes.
It defines types used by all other headers.

Fixes #691.
2014-06-21 22:43:22 +03:00
Emmanuel Blot f6932d6506 Prefix ARRAY_SIZE with micropython prefix MP_ 2014-06-19 18:54:34 +02:00
Damien George ccc85ea0da py: Combine native emitters to 1 glue function; distinguish viper.
This patch simplifies the glue between native emitter and runtime,
and handles viper code like inline assember: return values are
converted to Python objects.

Fixes issue #531.
2014-05-10 13:40:46 +01:00
Damien George 36db6bcf54 py, compiler: Improve passes; add an extra pass for native emitter. 2014-05-07 17:24:22 +01:00
Damien George 04b9147e15 Add license header to (almost) all files.
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-05-03 23:27:38 +01:00
Damien George 2827d62e8b py: Implement keyword-only args.
Implements 'def f(*, a)' and 'def f(*a, b)', but not default
keyword-only args, eg 'def f(*, a=1)'.

Partially addresses issue #524.
2014-04-27 15:50:52 +01:00
Damien George 6d3c5e4301 Add ARRAY_SIZE macro, and use it where possible. 2014-04-26 10:47:29 +01:00
Damien George e5f8a77db6 py: Add 'align' and 'data' meta-instructions to inline assembler. 2014-04-21 13:33:15 +01:00
Damien George 90edf9e13b inlinethumb: Add wfi, cpsid and cpsie instructions. 2014-04-18 16:56:54 +01:00
Damien George df8127a17e py: Remove unique_codes from emitglue.c. Replace with pointers.
Attempt to address issue #386.  unique_code_id's have been removed and
replaced with a pointer to the "raw code" information.  This pointer is
stored in the actual byte code (aligned, so the GC can trace it), so
that raw code (ie byte code, native code and inline assembler) is kept
only for as long as it is needed.  In memory it's now like a tree: the
outer module's byte code points directly to its children's raw code.  So
when the outer code gets freed, if there are no remaining functions that
need the raw code, then the children's code gets freed as well.

This is pretty much like CPython does it, except that CPython stores
indexes in the byte code rather than machine pointers.  These indices
index the per-function constant table in order to find the relevant
code.
2014-04-13 11:04:33 +01:00
Damien George 8721087661 py: Big improvements to inline assembler.
Improved the Thumb assembler back end.  Added many more Thumb
instructions to the inline assembler.  Improved parsing of assembler
instructions and arguments.  Assembler functions can now be passed the
address of any object that supports the buffer protocol (to get the
address of the buffer).  Added an example of how to sum numbers from
an array in assembler.
2014-04-13 00:30:32 +01:00