diff options
author | Mike Pall <mike> | 2016-03-28 23:04:33 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2016-03-28 23:04:33 +0200 |
commit | 6801e7165c3a5031db3cfe0e52f50cebb918695f (patch) | |
tree | 6a26e078a7ecee447dc861860e2bacaf20f04d3c | |
parent | c24c8e5312003da5ac0643645e321e84a672fea3 (diff) | |
download | luajit-6801e7165c3a5031db3cfe0e52f50cebb918695f.tar.gz luajit-6801e7165c3a5031db3cfe0e52f50cebb918695f.tar.bz2 luajit-6801e7165c3a5031db3cfe0e52f50cebb918695f.zip |
x86: Detect BMI2 instruction support.
Diffstat (limited to '')
-rw-r--r-- | src/lib_jit.c | 5 | ||||
-rw-r--r-- | src/lj_jit.h | 3 | ||||
-rw-r--r-- | src/vm_x64.dasc | 1 | ||||
-rw-r--r-- | src/vm_x86.dasc | 2 |
4 files changed, 10 insertions, 1 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 402ca35c..c6330c49 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -668,6 +668,11 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
668 | if (fam >= 0x00000f00) /* K8, K10. */ | 668 | if (fam >= 0x00000f00) /* K8, K10. */ |
669 | flags |= JIT_F_PREFER_IMUL; | 669 | flags |= JIT_F_PREFER_IMUL; |
670 | } | 670 | } |
671 | if (vendor[0] >= 7) { | ||
672 | uint32_t xfeatures[4]; | ||
673 | lj_vm_cpuid(7, xfeatures); | ||
674 | flags |= ((xfeatures[1] >> 8)&1) * JIT_F_BMI2; | ||
675 | } | ||
671 | #endif | 676 | #endif |
672 | } | 677 | } |
673 | /* Check for required instruction set support on x86 (unnecessary on x64). */ | 678 | /* Check for required instruction set support on x86 (unnecessary on x64). */ |
diff --git a/src/lj_jit.h b/src/lj_jit.h index 5a51357e..2d2e833a 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -19,10 +19,11 @@ | |||
19 | #define JIT_F_SSE4_1 0x00000040 | 19 | #define JIT_F_SSE4_1 0x00000040 |
20 | #define JIT_F_PREFER_IMUL 0x00000080 | 20 | #define JIT_F_PREFER_IMUL 0x00000080 |
21 | #define JIT_F_LEA_AGU 0x00000100 | 21 | #define JIT_F_LEA_AGU 0x00000100 |
22 | #define JIT_F_BMI2 0x00000200 | ||
22 | 23 | ||
23 | /* Names for the CPU-specific flags. Must match the order above. */ | 24 | /* Names for the CPU-specific flags. Must match the order above. */ |
24 | #define JIT_F_CPU_FIRST JIT_F_SSE2 | 25 | #define JIT_F_CPU_FIRST JIT_F_SSE2 |
25 | #define JIT_F_CPUSTRING "\4SSE2\4SSE3\6SSE4.1\3AMD\4ATOM" | 26 | #define JIT_F_CPUSTRING "\4SSE2\4SSE3\6SSE4.1\3AMD\4ATOM\4BMI2" |
26 | #elif LJ_TARGET_ARM | 27 | #elif LJ_TARGET_ARM |
27 | #define JIT_F_ARMV6_ 0x00000010 | 28 | #define JIT_F_ARMV6_ 0x00000010 |
28 | #define JIT_F_ARMV6T2_ 0x00000020 | 29 | #define JIT_F_ARMV6T2_ 0x00000020 |
diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc index bc2419c1..99ebb9b9 100644 --- a/src/vm_x64.dasc +++ b/src/vm_x64.dasc | |||
@@ -2639,6 +2639,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
2639 | | mov eax, CARG1d | 2639 | | mov eax, CARG1d |
2640 | | .if X64WIN; push rsi; mov rsi, CARG2; .endif | 2640 | | .if X64WIN; push rsi; mov rsi, CARG2; .endif |
2641 | | push rbx | 2641 | | push rbx |
2642 | | xor ecx, ecx | ||
2642 | | cpuid | 2643 | | cpuid |
2643 | | mov [rsi], eax | 2644 | | mov [rsi], eax |
2644 | | mov [rsi+4], ebx | 2645 | | mov [rsi+4], ebx |
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc index fcef660c..f108c0b5 100644 --- a/src/vm_x86.dasc +++ b/src/vm_x86.dasc | |||
@@ -3026,6 +3026,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
3026 | | mov eax, CARG1d | 3026 | | mov eax, CARG1d |
3027 | | .if X64WIN; push rsi; mov rsi, CARG2; .endif | 3027 | | .if X64WIN; push rsi; mov rsi, CARG2; .endif |
3028 | | push rbx | 3028 | | push rbx |
3029 | | xor ecx, ecx | ||
3029 | | cpuid | 3030 | | cpuid |
3030 | | mov [rsi], eax | 3031 | | mov [rsi], eax |
3031 | | mov [rsi+4], ebx | 3032 | | mov [rsi+4], ebx |
@@ -3049,6 +3050,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
3049 | | mov eax, [esp+4] // Argument 1 is function number. | 3050 | | mov eax, [esp+4] // Argument 1 is function number. |
3050 | | push edi | 3051 | | push edi |
3051 | | push ebx | 3052 | | push ebx |
3053 | | xor ecx, ecx | ||
3052 | | cpuid | 3054 | | cpuid |
3053 | | mov edi, [esp+16] // Argument 2 is result area. | 3055 | | mov edi, [esp+16] // Argument 2 is result area. |
3054 | | mov [edi], eax | 3056 | | mov [edi], eax |