diff options
author | Mike Pall <mike> | 2016-06-08 10:24:00 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2016-06-08 10:24:00 +0200 |
commit | 287a5347cfe452d44748327fb7c27f6ce57f5dc2 (patch) | |
tree | 72ee534bbad2ff069408977f0cb2787527dcdbc2 | |
parent | f5983437a6b08c140bdeb2fc15fa30d7f3b0daad (diff) | |
download | luajit-287a5347cfe452d44748327fb7c27f6ce57f5dc2.tar.gz luajit-287a5347cfe452d44748327fb7c27f6ce57f5dc2.tar.bz2 luajit-287a5347cfe452d44748327fb7c27f6ce57f5dc2.zip |
MIPS: Support MIPS16 interlinking.
-rw-r--r-- | doc/install.html | 2 | ||||
-rw-r--r-- | src/jit/dis_mips.lua | 2 | ||||
-rw-r--r-- | src/lib_jit.c | 4 | ||||
-rw-r--r-- | src/lj_emit_mips.h | 3 | ||||
-rw-r--r-- | src/lj_target_mips.h | 1 |
5 files changed, 9 insertions, 3 deletions
diff --git a/doc/install.html b/doc/install.html index 38c9a6bb..bbc71c98 100644 --- a/doc/install.html +++ b/doc/install.html | |||
@@ -386,7 +386,7 @@ important to compile with the proper CPU or architecture settings: | |||
386 | <li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li> | 386 | <li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li> |
387 | <li>For a pre-built, generic toolchain add <tt>-mcpu=...</tt> or <tt>-march=...</tt> and other necessary flags to <tt>TARGET_CFLAGS</tt>.</li> | 387 | <li>For a pre-built, generic toolchain add <tt>-mcpu=...</tt> or <tt>-march=...</tt> and other necessary flags to <tt>TARGET_CFLAGS</tt>.</li> |
388 | <li>For ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, too. Otherwise LuaJIT may not run at the full performance of your target CPU.</li> | 388 | <li>For ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, too. Otherwise LuaJIT may not run at the full performance of your target CPU.</li> |
389 | <li>For MIPS it's important to select a supported ABI (o32 on MIPS32, n64 on MIPS64) and consistently compile your project either with hard-float or soft-float compiler settings. Do not use <tt>-mips16</tt>.</li> | 389 | <li>For MIPS it's important to select a supported ABI (o32 on MIPS32, n64 on MIPS64) and consistently compile your project either with hard-float or soft-float compiler settings.</li> |
390 | </ul> | 390 | </ul> |
391 | <p> | 391 | <p> |
392 | Here are some examples for targets with a different CPU than the host: | 392 | Here are some examples for targets with a different CPU than the host: |
diff --git a/src/jit/dis_mips.lua b/src/jit/dis_mips.lua index 19327d6f..6776f0cb 100644 --- a/src/jit/dis_mips.lua +++ b/src/jit/dis_mips.lua | |||
@@ -214,7 +214,7 @@ local map_pri = { | |||
214 | map_cop0, map_cop1, false, map_cop1x, | 214 | map_cop0, map_cop1, false, map_cop1x, |
215 | "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", | 215 | "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", |
216 | false, false, false, false, | 216 | false, false, false, false, |
217 | map_special2, false, false, map_special3, | 217 | map_special2, "jalxJ", false, map_special3, |
218 | "lbTSO", "lhTSO", "lwlTSO", "lwTSO", | 218 | "lbTSO", "lhTSO", "lwlTSO", "lwTSO", |
219 | "lbuTSO", "lhuTSO", "lwrTSO", false, | 219 | "lbuTSO", "lhuTSO", "lwrTSO", false, |
220 | "sbTSO", "shTSO", "swlTSO", "swTSO", | 220 | "sbTSO", "shTSO", "swlTSO", "swTSO", |
diff --git a/src/lib_jit.c b/src/lib_jit.c index 1655f0c5..592538bd 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -721,8 +721,12 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
721 | #if defined(__GNUC__) | 721 | #if defined(__GNUC__) |
722 | if (!(flags & JIT_F_MIPSXXR2)) { | 722 | if (!(flags & JIT_F_MIPSXXR2)) { |
723 | int x; | 723 | int x; |
724 | #ifdef __mips16 | ||
725 | x = 0; /* Runtime detection is difficult. Ensure optimal -march flags. */ | ||
726 | #else | ||
724 | /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ | 727 | /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ |
725 | __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); | 728 | __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); |
729 | #endif | ||
726 | if (x) flags |= JIT_F_MIPSXXR2; /* Either 0x80000000 (R2) or 0 (R1). */ | 730 | if (x) flags |= JIT_F_MIPSXXR2; /* Either 0x80000000 (R2) or 0 (R1). */ |
727 | } | 731 | } |
728 | #endif | 732 | #endif |
diff --git a/src/lj_emit_mips.h b/src/lj_emit_mips.h index 9df04771..d35f830b 100644 --- a/src/lj_emit_mips.h +++ b/src/lj_emit_mips.h | |||
@@ -157,7 +157,8 @@ static void emit_call(ASMState *as, void *target, int needcfa) | |||
157 | MCode *p = as->mcp; | 157 | MCode *p = as->mcp; |
158 | *--p = MIPSI_NOP; | 158 | *--p = MIPSI_NOP; |
159 | if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) { | 159 | if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) { |
160 | *--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu); | 160 | *--p = (((uintptr_t)target & 1) ? MIPSI_JALX : MIPSI_JAL) | |
161 | (((uintptr_t)target >>2) & 0x03ffffffu); | ||
161 | } else { /* Target out of range: need indirect call. */ | 162 | } else { /* Target out of range: need indirect call. */ |
162 | *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR); | 163 | *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR); |
163 | needcfa = 1; | 164 | needcfa = 1; |
diff --git a/src/lj_target_mips.h b/src/lj_target_mips.h index ac72528d..6a7d4b50 100644 --- a/src/lj_target_mips.h +++ b/src/lj_target_mips.h | |||
@@ -239,6 +239,7 @@ typedef enum MIPSIns { | |||
239 | MIPSI_B = 0x10000000, | 239 | MIPSI_B = 0x10000000, |
240 | MIPSI_J = 0x08000000, | 240 | MIPSI_J = 0x08000000, |
241 | MIPSI_JAL = 0x0c000000, | 241 | MIPSI_JAL = 0x0c000000, |
242 | MIPSI_JALX = 0x74000000, | ||
242 | MIPSI_JR = 0x00000008, | 243 | MIPSI_JR = 0x00000008, |
243 | MIPSI_JALR = 0x0000f809, | 244 | MIPSI_JALR = 0x0000f809, |
244 | 245 | ||