mpy-cross: Add RISC-V RV32IMC support in MPY files.
MPY files can now hold generated RV32IMC native code. This can be accomplished by passing the `-march=rv32imc` flag to mpy-cross. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
parent
8338f66352
commit
99f5659cf5
@ -58,7 +58,7 @@ If importing an .mpy file fails then try the following:
|
||||
sys_mpy = sys.implementation._mpy
|
||||
arch = [None, 'x86', 'x64',
|
||||
'armv6', 'armv6m', 'armv7m', 'armv7em', 'armv7emsp', 'armv7emdp',
|
||||
'xtensa', 'xtensawin'][sys_mpy >> 10]
|
||||
'xtensa', 'xtensawin', 'rv32imc'][sys_mpy >> 10]
|
||||
print('mpy version:', sys_mpy & 0xff)
|
||||
print('mpy sub-version:', sys_mpy >> 8 & 3)
|
||||
print('mpy flags:', end='')
|
||||
|
||||
@ -129,7 +129,8 @@ static int usage(char **argv) {
|
||||
"\n"
|
||||
"Target specific options:\n"
|
||||
"-msmall-int-bits=number : set the maximum bits used to encode a small-int\n"
|
||||
"-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin\n"
|
||||
"-march=<arch> : set architecture for native emitter;\n"
|
||||
" x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin, rv32imc\n"
|
||||
"\n"
|
||||
"Implementation specific options:\n", argv[0]
|
||||
);
|
||||
@ -312,6 +313,9 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
} else if (strcmp(arch, "xtensawin") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_XTENSAWIN;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_XTENSAWIN;
|
||||
} else if (strcmp(arch, "rv32imc") == 0) {
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_RV32IMC;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_RV32I;
|
||||
} else if (strcmp(arch, "host") == 0) {
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86;
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
#define MICROPY_EMIT_XTENSA (1)
|
||||
#define MICROPY_EMIT_INLINE_XTENSA (1)
|
||||
#define MICROPY_EMIT_XTENSAWIN (1)
|
||||
#define MICROPY_EMIT_RV32 (1)
|
||||
|
||||
#define MICROPY_DYNAMIC_COMPILER (1)
|
||||
#define MICROPY_COMP_CONST_FOLDING (1)
|
||||
|
||||
@ -43,6 +43,7 @@ NATIVE_ARCHS = {
|
||||
"NATIVE_ARCH_ARMV7EMDP": "armv7emdp",
|
||||
"NATIVE_ARCH_XTENSA": "xtensa",
|
||||
"NATIVE_ARCH_XTENSAWIN": "xtensawin",
|
||||
"NATIVE_ARCH_RV32IMC": "rv32imc",
|
||||
}
|
||||
|
||||
globals().update(NATIVE_ARCHS)
|
||||
|
||||
@ -71,6 +71,8 @@
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_XTENSA)
|
||||
#elif MICROPY_EMIT_XTENSAWIN
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_XTENSAWIN)
|
||||
#elif MICROPY_EMIT_RV32
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_RV32IMC)
|
||||
#else
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_NONE)
|
||||
#endif
|
||||
@ -95,6 +97,7 @@ enum {
|
||||
MP_NATIVE_ARCH_ARMV7EMDP,
|
||||
MP_NATIVE_ARCH_XTENSA,
|
||||
MP_NATIVE_ARCH_XTENSAWIN,
|
||||
MP_NATIVE_ARCH_RV32IMC,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
@ -113,6 +113,7 @@ MP_NATIVE_ARCH_ARMV7EMSP = 7
|
||||
MP_NATIVE_ARCH_ARMV7EMDP = 8
|
||||
MP_NATIVE_ARCH_XTENSA = 9
|
||||
MP_NATIVE_ARCH_XTENSAWIN = 10
|
||||
MP_NATIVE_ARCH_RV32IMC = 11
|
||||
|
||||
MP_PERSISTENT_OBJ_FUN_TABLE = 0
|
||||
MP_PERSISTENT_OBJ_NONE = 1
|
||||
@ -1094,8 +1095,10 @@ class RawCodeNative(RawCode):
|
||||
):
|
||||
# ARMV6 or Xtensa -- four byte align.
|
||||
self.fun_data_attributes += " __attribute__ ((aligned (4)))"
|
||||
elif MP_NATIVE_ARCH_ARMV6M <= config.native_arch <= MP_NATIVE_ARCH_ARMV7EMDP:
|
||||
# ARMVxxM -- two byte align.
|
||||
elif (
|
||||
MP_NATIVE_ARCH_ARMV6M <= config.native_arch <= MP_NATIVE_ARCH_ARMV7EMDP
|
||||
) or config.native_arch == MP_NATIVE_ARCH_RV32IMC:
|
||||
# ARMVxxM or RV32IMC -- two byte align.
|
||||
self.fun_data_attributes += " __attribute__ ((aligned (2)))"
|
||||
|
||||
def disassemble(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user