mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Add DynASM x64 module (non-functional). Add extra x64 registers.
This commit is contained in:
parent
4523c46d10
commit
fe36e4ac59
12
dynasm/dasm_x64.lua
Normal file
12
dynasm/dasm_x64.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
------------------------------------------------------------------------------
|
||||||
|
-- DynASM x64 module.
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2005-2009 Mike Pall. All rights reserved.
|
||||||
|
-- See dynasm.lua for full copyright notice.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
-- This module just sets 64 bit mode for the combined x86/x64 module.
|
||||||
|
-- All the interesting stuff is there.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
x64 = true -- Using a global is an ugly, but effective solution.
|
||||||
|
return require("dasm_x86")
|
@ -1,17 +1,19 @@
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
-- DynASM x86 module.
|
-- DynASM x86/x64 module.
|
||||||
--
|
--
|
||||||
-- Copyright (C) 2005-2009 Mike Pall. All rights reserved.
|
-- Copyright (C) 2005-2009 Mike Pall. All rights reserved.
|
||||||
-- See dynasm.lua for full copyright notice.
|
-- See dynasm.lua for full copyright notice.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local x64 = x64
|
||||||
|
|
||||||
-- Module information:
|
-- Module information:
|
||||||
local _info = {
|
local _info = {
|
||||||
arch = "x86",
|
arch = x64 and "x64" or "x86",
|
||||||
description = "DynASM x86 (i386) module",
|
description = "DynASM x86/x64 module",
|
||||||
version = "1.2.1",
|
version = "1.2.1",
|
||||||
vernum = 10201,
|
vernum = 10201,
|
||||||
release = "2009-04-16",
|
release = "2009-12-09",
|
||||||
author = "Mike Pall",
|
author = "Mike Pall",
|
||||||
license = "MIT",
|
license = "MIT",
|
||||||
}
|
}
|
||||||
@ -261,9 +263,9 @@ local reg_list = {} -- Canonical list of int. register names.
|
|||||||
local map_type = {} -- Type name -> { ctype, reg }
|
local map_type = {} -- Type name -> { ctype, reg }
|
||||||
local ctypenum = 0 -- Type number (for _PTx macros).
|
local ctypenum = 0 -- Type number (for _PTx macros).
|
||||||
|
|
||||||
local addrsize = "d" -- Size for address operands. !x64
|
local addrsize = x64 and "q" or "d" -- Size for address operands.
|
||||||
|
|
||||||
-- Helper function to fill register maps.
|
-- Helper functions to fill register maps.
|
||||||
local function mkrmap(sz, cl, names)
|
local function mkrmap(sz, cl, names)
|
||||||
local cname = format("@%s", sz)
|
local cname = format("@%s", sz)
|
||||||
reg_list[#reg_list+1] = cname
|
reg_list[#reg_list+1] = cname
|
||||||
@ -275,33 +277,57 @@ local function mkrmap(sz, cl, names)
|
|||||||
map_reg_valid_base[cname] = true
|
map_reg_valid_base[cname] = true
|
||||||
map_reg_valid_index[cname] = true
|
map_reg_valid_index[cname] = true
|
||||||
end
|
end
|
||||||
for n,name in ipairs(names) do
|
if names then
|
||||||
local iname = format("@%s%x", sz, n-1)
|
for n,name in ipairs(names) do
|
||||||
reg_list[#reg_list+1] = iname
|
local iname = format("@%s%x", sz, n-1)
|
||||||
|
reg_list[#reg_list+1] = iname
|
||||||
|
map_archdef[name] = iname
|
||||||
|
map_reg_rev[iname] = name
|
||||||
|
map_reg_num[iname] = n-1
|
||||||
|
map_reg_opsize[iname] = sz
|
||||||
|
if sz == addrsize then
|
||||||
|
map_reg_valid_base[iname] = true
|
||||||
|
map_reg_valid_index[iname] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i=0,(x64 and sz ~= "f") and 15 or 7 do
|
||||||
|
local iname = format("@%s%x", sz, i)
|
||||||
|
local name
|
||||||
|
if sz == "o" then name = format("xmm%d", i)
|
||||||
|
elseif sz == "f" then name = format("st%d", i)
|
||||||
|
else name = format("r%d%s", i, sz == addrsize and "" or sz) end
|
||||||
map_archdef[name] = iname
|
map_archdef[name] = iname
|
||||||
map_reg_rev[iname] = name
|
if not map_reg_rev[iname] then
|
||||||
map_reg_num[iname] = n-1
|
reg_list[#reg_list+1] = iname
|
||||||
map_reg_opsize[iname] = sz
|
map_reg_rev[iname] = name
|
||||||
if sz == addrsize then
|
map_reg_num[iname] = i
|
||||||
map_reg_valid_base[iname] = true
|
map_reg_opsize[iname] = sz
|
||||||
map_reg_valid_index[iname] = true
|
if sz == addrsize then
|
||||||
|
map_reg_valid_base[iname] = true
|
||||||
|
map_reg_valid_index[iname] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
reg_list[#reg_list+1] = ""
|
reg_list[#reg_list+1] = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Integer registers (dword, word and byte sized).
|
-- Integer registers (qword, dword, word and byte sized).
|
||||||
|
if x64 then
|
||||||
|
mkrmap("q", "Rq", {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"})
|
||||||
|
end
|
||||||
mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"})
|
mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"})
|
||||||
map_reg_valid_index[map_archdef.esp] = false
|
|
||||||
mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"})
|
mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"})
|
||||||
mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"})
|
mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"})
|
||||||
|
-- !x64: ah, ch, dh, bh not valid with REX, r4b-r15b require REX
|
||||||
|
map_reg_valid_index[map_archdef[x64 and "rsp" or "esp"]] = false
|
||||||
map_archdef["Ra"] = "@"..addrsize
|
map_archdef["Ra"] = "@"..addrsize
|
||||||
|
|
||||||
-- FP registers (internally tword sized, but use "f" as operand size).
|
-- FP registers (internally tword sized, but use "f" as operand size).
|
||||||
mkrmap("f", "Rf", {"st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7"})
|
mkrmap("f", "Rf")
|
||||||
|
|
||||||
-- SSE registers (oword sized, but qword and dword accessible).
|
-- SSE registers (oword sized, but qword and dword accessible).
|
||||||
mkrmap("o", "xmm", {"xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7"})
|
mkrmap("o", "xmm")
|
||||||
|
|
||||||
-- Operand size prefixes to codes.
|
-- Operand size prefixes to codes.
|
||||||
local map_opsize = {
|
local map_opsize = {
|
||||||
|
Loading…
Reference in New Issue
Block a user