-rw-r--r-- | include/lightning/jit_arm.h | 9 | ||||
-rw-r--r-- | lib/jit_arm-cpu.c | 2 | ||||
-rw-r--r-- | lib/jit_arm.c | 10 |
diff --git a/include/lightning/jit_arm.h b/include/lightning/jit_arm.h index 8f7278d..742baa7 100644 --- a/include/lightning/jit_arm.h +++ b/include/lightning/jit_arm.h @@ -106,6 +106,9 @@ typedef enum { typedef struct { jit_uint32_t version : 4; + /* this field originally was only used for the 'e' in armv5te. + * it can also be used to force hardware division, if setting + * version to 7, telling it is armv7r or better. */ jit_uint32_t extend : 1; /* only generate thumb instructions for thumb2 */ jit_uint32_t thumb : 1; @@ -117,6 +120,12 @@ typedef struct { * due to some memory ordering constraint not being respected, so, * disable by default */ jit_uint32_t ldrt_strt : 1; + /* assume functions called never match jit instruction set? + * that is libc, gmp, mpfr, etc functions are in thumb mode and jit + * is in arm mode, or the reverse, what may cause a crash upon return + * of that function if generating jit for a relative jump. + */ + jit_uint32_t exchange : 1; } jit_cpu_t; /* diff --git a/lib/jit_arm-cpu.c b/lib/jit_arm-cpu.c index a834efd..a9ccd17 100644 --- a/lib/jit_arm-cpu.c +++ b/lib/jit_arm-cpu.c @@ -37,7 +37,7 @@ # define jit_armv5e_p() (jit_cpu.version > 5 || (jit_cpu.version == 5 && jit_cpu.extend)) # define jit_armv6_p() (jit_cpu.version >= 6) # define jit_armv7_p() (jit_cpu.version >= 7) -# define jit_armv7r_p() 0 +# define jit_armv7r_p() (jit_cpu.version > 7 || (jit_cpu.version == 7 && jit_cpu.extend)) extern int __aeabi_idivmod(int, int); extern unsigned __aeabi_uidivmod(unsigned, unsigned); # define _R0_REGNO 0x00 diff --git a/lib/jit_arm.c b/lib/jit_arm.c index 47246d8..478f9b7 100644 --- a/lib/jit_arm.c +++ b/lib/jit_arm.c @@ -44,7 +44,7 @@ * arm mode, what may cause a crash upon return of that function * if generating jit for a relative jump. */ -#define jit_exchange_p() 1 +#define jit_exchange_p() jit_cpu.exchange /* FIXME is it really required to not touch _R10? */ @@ -225,6 +225,14 @@ jit_get_cpu(void) /* armv6t2 todo (software float and thumb2) */ if (!jit_cpu.vfp && jit_cpu.thumb) jit_cpu.thumb = 0; + /* FIXME need test environments for the below. For the moment just + * be very conservative */ + /* force generation of code assuming jit and function libraries called + * instruction set do not match */ + jit_cpu.exchange = 1; + /* do not generate hardware integer division by default */ + if (jit_cpu.version == 7) + jit_cpu.extend = 0; } void |