From 26808edf5098555a4e0d334125727b2201cfedc5 Mon Sep 17 00:00:00 2001 From: fsfod Date: Tue, 19 Sep 2017 18:39:42 +0100 Subject: [PATCH] Change intrinsic REX opcode mode X to be silently ignored in 32 builds to allow pointer based intrinsics to work in both 64 bit and 32 bit with the same definion. --- src/lj_intrinsic.c | 2 ++ tests/intrinsic_spec.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lj_intrinsic.c b/src/lj_intrinsic.c index c5ee7a94..845e0e62 100644 --- a/src/lj_intrinsic.c +++ b/src/lj_intrinsic.c @@ -780,6 +780,8 @@ int lj_intrinsic_fromcdef(lua_State *L, CTypeID fid, GCstr *opstr, uint32_t imm) /* Use opcode unmodified in its SSE form */ intrins->flags &= ~INTRINSFLAG_VEX; } + } else if(!LJ_64 && (intrins->flags & INTRINSFLAG_REXW)) { + intrins->flags &= ~INTRINSFLAG_REXW; } #endif diff --git a/tests/intrinsic_spec.lua b/tests/intrinsic_spec.lua index 563209b0..eacf94a5 100644 --- a/tests/intrinsic_spec.lua +++ b/tests/intrinsic_spec.lua @@ -429,7 +429,7 @@ context("__mcode", function() end) it("output pointers", function() - assert_cdef([[const char* addptr(const char* nptr, int32_t n) __mcode("03rM");]], "addptr") + assert_cdef([[const char* addptr(const char* nptr, int32_t n) __mcode("03rMX");]], "addptr") local s = "0123456789abcdefghijklmnopqrstvwxyz" local ptr = ffi.C.addptr(s, 0)