Skip to content

Commit

Permalink
Load potentially 64-bit values using mov64
Browse files Browse the repository at this point in the history
When Snabb switches to LuaJIT's GC64, FFI allocations might be in the
64-bit range.  This commit adapts the memory references to immediate
addresses to account for 64-bit immediates.
  • Loading branch information
wingo committed Mar 20, 2018
1 parent 46e0e4a commit de790aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/apps/example/asm.dasl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ local asm_status = ffi.new("uint32_t[1]")
|.arch x64
|.actionlist actions
local Dst = dasm.new(actions)
| mov dword [asm_status], 0xdeadbeef
| mov64 rax, asm_status
| mov dword [rax], 0xdeadbeef
| ret
code = Dst:build() -- assign to 'code' to avoid machine code being GC'd
fptr = ffi.cast("void(*)()", code)
Expand Down
6 changes: 3 additions & 3 deletions src/lib/hash/siphash.dasl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ local function SSE(stride)
function asm.init(key)
local initial_state = load_initial_state(key)
table.insert(__anchor, initial_state)
| mov rax, initial_state
| mov64 rax, initial_state
| movddup xmm0, [rax]
| movddup xmm1, [rax+8]
| movddup xmm2, [rax+16]
Expand Down Expand Up @@ -253,7 +253,7 @@ local function AVX2(stride)
local initial_state = load_initial_state(key)
table.insert(__anchor, initial_state)
| vzeroupper
| mov rax, initial_state
| mov64 rax, initial_state
| vbroadcastsd ymm0, qword [rax]
| vbroadcastsd ymm1, qword [rax+8]
| vbroadcastsd ymm2, qword [rax+16]
Expand Down Expand Up @@ -345,7 +345,7 @@ local function AVX2(stride)
-- write out.
local control = ffi.new('uint32_t[8]', 1, 3, 5, 7, 0, 0, 0, 0)
table.insert(__anchor, control)
| mov rax, control
| mov64 rax, control
| vmovdqu ymm5, [rax]
| vpermd ymm(reg), ymm5, ymm(reg)
| vpslld xmm(reg), xmm(reg), 1
Expand Down
2 changes: 1 addition & 1 deletion src/lib/multi_copy.dasl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function gen(count, size)
tail_mask = ffi.new("uint8_t[32]")
for i=0,tail_size-1 do tail_mask[i]=255 end
table.insert(anchor, tail_mask)
| mov rax, tail_mask
| mov64 rax, tail_mask
| vmovdqu ymm15, [rax]
end

Expand Down

0 comments on commit de790aa

Please sign in to comment.