diff options
author | Damien George <damien.p.george@gmail.com> | 2019-03-09 10:59:57 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-03-14 12:22:25 +1100 |
commit | 9c9bc65e74abb645817c757f005eef6d7394f507 (patch) | |
tree | 82d6d56eb945bc8c64ef3fa53b72a127404dd1b0 /mpy-cross/main.c | |
parent | d9d92f27d7cce287850d971abf3104d2230092fa (diff) |
mpy-cross: Add "-march=<arch>" option to select native emitter.
Diffstat (limited to 'mpy-cross/main.c')
-rw-r--r-- | mpy-cross/main.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c index d819f74f1..ef5d8752a 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -109,6 +109,7 @@ STATIC int usage(char **argv) { "-msmall-int-bits=number : set the maximum bits used to encode a small-int\n" "-mno-unicode : don't support unicode in compiled strings\n" "-mcache-lookup-bc : cache map lookups in the bytecode\n" +"-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv7m, xtensa\n" "\n" "Implementation specific options:\n", argv[0] ); @@ -193,6 +194,13 @@ MP_NOINLINE int main_(int argc, char **argv) { mp_dynamic_compiler.small_int_bits = 31; mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0; mp_dynamic_compiler.py_builtins_str_unicode = 1; + #if defined(__i386__) + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86; + #elif defined(__x86_64__) + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X64; + #else + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_NONE; + #endif const char *input_file = NULL; const char *output_file = NULL; @@ -240,6 +248,21 @@ MP_NOINLINE int main_(int argc, char **argv) { mp_dynamic_compiler.py_builtins_str_unicode = 0; } else if (strcmp(argv[a], "-municode") == 0) { mp_dynamic_compiler.py_builtins_str_unicode = 1; + } else if (strncmp(argv[a], "-march=", sizeof("-march=") - 1) == 0) { + const char *arch = argv[a] + sizeof("-march=") - 1; + if (strcmp(arch, "x86") == 0) { + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86; + } else if (strcmp(arch, "x64") == 0) { + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X64; + } else if (strcmp(arch, "armv6") == 0) { + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_ARMV6; + } else if (strcmp(arch, "armv7m") == 0) { + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_ARMV7M; + } else if (strcmp(arch, "xtensa") == 0) { + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_XTENSA; + } else { + return usage(argv); + } } else { return usage(argv); } |