emit native - how to control which architecture is emitted

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

emit native - how to control which architecture is emitted

Post by jickster » Tue Oct 17, 2017 9:17 pm

In mpconfigport.h, there's the following code

Code: Select all

#define MICROPY_EMIT_X64            (0)
#define MICROPY_EMIT_X86            (0)
#define MICROPY_EMIT_THUMB          (0)
#define MICROPY_EMIT_INLINE_THUMB   (0)
#define MICROPY_EMIT_INLINE_THUMB_ARMV7M (0)
#define MICROPY_EMIT_INLINE_THUMB_FLOAT (0)
#define MICROPY_EMIT_ARM            (0)
If I enable them all, how do I control for which architecture native code is emitted?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: emit native - how to control which architecture is emitted

Post by pythoncoder » Wed Oct 18, 2017 9:23 am

I'm struggling to see what you're trying to achieve - mpconfigport.h is port-specific. You build firmware for a specific port (as the firmware itself comprises machine code for that arch). So the emitter has to match.

Or is it the cross-compiler you're concerned about? As far as I know it produces bytecode only and doesn't yet support the native code emitter or inline assembler.
Peter Hinch
Index to my micropython libraries.

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: emit native - how to control which architecture is emitted

Post by jickster » Wed Oct 18, 2017 6:05 pm

pythoncoder wrote:
Wed Oct 18, 2017 9:23 am
I'm struggling to see what you're trying to achieve - mpconfigport.h is port-specific. You build firmware for a specific port (as the firmware itself comprises machine code for that arch). So the emitter has to match.

Or is it the cross-compiler you're concerned about? As far as I know it produces bytecode only and doesn't yet support the native code emitter or inline assembler.

The cross-compiler can provide native instructions
C:\micropython\mpy-cross>mpy-cross --help
usage: mpy-cross [<opts>] [-X <implopt>] <input filename>
Options:
-o : output file for compiled bytecode (defaults to input with .mpy extension)
-s : source filename to embed in the compiled bytecode (defaults to input file)
-v : verbose (trace various operations); can be multiple
-O[N] : apply bytecode optimizations of level N

Target specific options:
-msmall-int-bits=number : set the maximum bits used to encode a small-int
-mno-unicode : don't support unicode in compiled strings
-mcache-lookup-bc : cache map lookups in the bytecode

Implementation specific options:
emit={bytecode,native,viper} -- set the default code emitter
heapsize=<n> -- set the heap size for the GC (default 1048576)
For my processor, how do I know which macro to enable?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: emit native - how to control which architecture is emitted

Post by pythoncoder » Thu Oct 19, 2017 9:44 am

Well I'm guessing, and I'm unsure if this functionality has actually been implemented in the cross compiler, but my approach would be to look at the mpconfigport.h in the ports directory of your target arch and copy the relevant settings to the cross-compiler's mpconfigport.h.

Hopefully someone with some actual knowledge/experience will pop up here ;)
Peter Hinch
Index to my micropython libraries.

Post Reply