aboutsummaryrefslogtreecommitdiff
path: root/src/jit
diff options
context:
space:
mode:
authorMike Pall <mike>2017-02-20 03:43:10 +0100
committerMike Pall <mike>2017-02-20 03:43:10 +0100
commita25c0b99b84558887887b8e298409dcf8605e5e3 (patch)
tree8cb7b1db3cb0cd4f6cdd59540d39d986b502e471 /src/jit
parent4416e885d28c0f49d2c7bb3f9630ab23c22fbc9a (diff)
downloadluajit-a25c0b99b84558887887b8e298409dcf8605e5e3.tar.gz
luajit-a25c0b99b84558887887b8e298409dcf8605e5e3.tar.bz2
luajit-a25c0b99b84558887887b8e298409dcf8605e5e3.zip
MIPS64, part 2: Add MIPS64 hard-float JIT compiler backend.
Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com. Sponsored by Cisco Systems, Inc.
Diffstat (limited to 'src/jit')
-rw-r--r--src/jit/dis_mips.lua45
-rw-r--r--src/jit/dis_mips64.lua17
-rw-r--r--src/jit/dis_mips64el.lua17
-rw-r--r--src/jit/dump.lua2
4 files changed, 65 insertions, 16 deletions
diff --git a/src/jit/dis_mips.lua b/src/jit/dis_mips.lua
index fdd3d353..a12b8e62 100644
--- a/src/jit/dis_mips.lua
+++ b/src/jit/dis_mips.lua
@@ -34,15 +34,17 @@ local map_special = {
34 "jrS", "jalrD1S", "movzDST", "movnDST", 34 "jrS", "jalrD1S", "movzDST", "movnDST",
35 "syscallY", "breakY", false, "sync", 35 "syscallY", "breakY", false, "sync",
36 "mfhiD", "mthiS", "mfloD", "mtloS", 36 "mfhiD", "mthiS", "mfloD", "mtloS",
37 false, false, false, false, 37 "dsllvDST", false, "dsrlvDST", "dsravDST",
38 "multST", "multuST", "divST", "divuST", 38 "multST", "multuST", "divST", "divuST",
39 false, false, false, false, 39 "dmultST", "dmultuST", "ddivST", "ddivuST",
40 "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", 40 "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T",
41 "andDST", "or|moveDST0", "xorDST", "nor|notDST0", 41 "andDST", "or|moveDST0", "xorDST", "nor|notDST0",
42 false, false, "sltDST", "sltuDST", 42 false, false, "sltDST", "sltuDST",
43 false, false, false, false, 43 "daddDST", "dadduDST", "dsubDST", "dsubuDST",
44 "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", 44 "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ",
45 "teqSTZ", false, "tneSTZ", 45 "teqSTZ", false, "tneSTZ", false,
46 "dsllDTA", false, "dsrlDTA", "dsraDTA",
47 "dsll32DTA", false, "dsrl32DTA", "dsra32DTA",
46} 48}
47 49
48local map_special2 = { 50local map_special2 = {
@@ -60,11 +62,17 @@ local map_bshfl = {
60 [24] = "sehDT", 62 [24] = "sehDT",
61} 63}
62 64
65local map_dbshfl = {
66 shift = 6, mask = 31,
67 [2] = "dsbhDT",
68 [5] = "dshdDT",
69}
70
63local map_special3 = { 71local map_special3 = {
64 shift = 0, mask = 63, 72 shift = 0, mask = 63,
65 [0] = "extTSAK", [4] = "insTSAL", 73 [0] = "extTSAK", [1] = "dextmTSAP", [3] = "dextTSAK",
66 [32] = map_bshfl, 74 [4] = "insTSAL", [6] = "dinsuTSEQ", [7] = "dinsTSAL",
67 [59] = "rdhwrTD", 75 [32] = map_bshfl, [36] = map_dbshfl, [59] = "rdhwrTD",
68} 76}
69 77
70local map_regimm = { 78local map_regimm = {
@@ -178,8 +186,8 @@ local map_cop1bc = {
178 186
179local map_cop1 = { 187local map_cop1 = {
180 shift = 21, mask = 31, 188 shift = 21, mask = 31,
181 [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", 189 [0] = "mfc1TG", "dmfc1TG", "cfc1TG", "mfhc1TG",
182 "mtc1TG", false, "ctc1TG", "mthc1TG", 190 "mtc1TG", "dmtc1TG", "ctc1TG", "mthc1TG",
183 map_cop1bc, false, false, false, 191 map_cop1bc, false, false, false,
184 false, false, false, false, 192 false, false, false, false,
185 map_cop1s, map_cop1d, false, false, 193 map_cop1s, map_cop1d, false, false,
@@ -213,16 +221,16 @@ local map_pri = {
213 "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", 221 "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU",
214 map_cop0, map_cop1, false, map_cop1x, 222 map_cop0, map_cop1, false, map_cop1x,
215 "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", 223 "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB",
216 false, false, false, false, 224 "daddiTSI", "daddiuTSI", false, false,
217 map_special2, "jalxJ", false, map_special3, 225 map_special2, "jalxJ", false, map_special3,
218 "lbTSO", "lhTSO", "lwlTSO", "lwTSO", 226 "lbTSO", "lhTSO", "lwlTSO", "lwTSO",
219 "lbuTSO", "lhuTSO", "lwrTSO", false, 227 "lbuTSO", "lhuTSO", "lwrTSO", false,
220 "sbTSO", "shTSO", "swlTSO", "swTSO", 228 "sbTSO", "shTSO", "swlTSO", "swTSO",
221 false, false, "swrTSO", "cacheNSO", 229 false, false, "swrTSO", "cacheNSO",
222 "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", 230 "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO",
223 false, "ldc1HSO", "ldc2TSO", false, 231 false, "ldc1HSO", "ldc2TSO", "ldTSO",
224 "scTSO", "swc1HSO", "swc2TSO", false, 232 "scTSO", "swc1HSO", "swc2TSO", false,
225 false, "sdc1HSO", "sdc2TSO", false, 233 false, "sdc1HSO", "sdc2TSO", "sdTSO",
226} 234}
227 235
228------------------------------------------------------------------------------ 236------------------------------------------------------------------------------
@@ -306,6 +314,8 @@ local function disass_ins(ctx)
306 x = "f"..band(rshift(op, 21), 31) 314 x = "f"..band(rshift(op, 21), 31)
307 elseif p == "A" then 315 elseif p == "A" then
308 x = band(rshift(op, 6), 31) 316 x = band(rshift(op, 6), 31)
317 elseif p == "E" then
318 x = band(rshift(op, 6), 31) + 32
309 elseif p == "M" then 319 elseif p == "M" then
310 x = band(rshift(op, 11), 31) 320 x = band(rshift(op, 11), 31)
311 elseif p == "N" then 321 elseif p == "N" then
@@ -315,8 +325,12 @@ local function disass_ins(ctx)
315 if x == 0 then x = nil end 325 if x == 0 then x = nil end
316 elseif p == "K" then 326 elseif p == "K" then
317 x = band(rshift(op, 11), 31) + 1 327 x = band(rshift(op, 11), 31) + 1
328 elseif p == "P" then
329 x = band(rshift(op, 11), 31) + 33
318 elseif p == "L" then 330 elseif p == "L" then
319 x = band(rshift(op, 11), 31) - last + 1 331 x = band(rshift(op, 11), 31) - last + 1
332 elseif p == "Q" then
333 x = band(rshift(op, 11), 31) - last + 33
320 elseif p == "I" then 334 elseif p == "I" then
321 x = arshift(lshift(op, 16), 16) 335 x = arshift(lshift(op, 16), 16)
322 elseif p == "U" then 336 elseif p == "U" then
@@ -330,11 +344,12 @@ local function disass_ins(ctx)
330 elseif p == "B" then 344 elseif p == "B" then
331 x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 345 x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4
332 ctx.rel = x 346 ctx.rel = x
333 x = "0x"..tohex(x) 347 x = format("0x%08x", x)
334 elseif p == "J" then 348 elseif p == "J" then
335 x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 349 local a = ctx.addr + ctx.pos
350 x = a - band(a, 0x0fffffff) + band(op, 0x03ffffff)*4
336 ctx.rel = x 351 ctx.rel = x
337 x = "0x"..tohex(x) 352 x = format("0x%08x", x)
338 elseif p == "V" then 353 elseif p == "V" then
339 x = band(rshift(op, 8), 7) 354 x = band(rshift(op, 8), 7)
340 if x == 0 then x = nil end 355 if x == 0 then x = nil end
diff --git a/src/jit/dis_mips64.lua b/src/jit/dis_mips64.lua
new file mode 100644
index 00000000..c4374928
--- /dev/null
+++ b/src/jit/dis_mips64.lua
@@ -0,0 +1,17 @@
1----------------------------------------------------------------------------
2-- LuaJIT MIPS64 disassembler wrapper module.
3--
4-- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
5-- Released under the MIT license. See Copyright Notice in luajit.h
6----------------------------------------------------------------------------
7-- This module just exports the big-endian functions from the
8-- MIPS disassembler module. All the interesting stuff is there.
9------------------------------------------------------------------------------
10
11local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips")
12return {
13 create = dis_mips.create,
14 disass = dis_mips.disass,
15 regname = dis_mips.regname
16}
17
diff --git a/src/jit/dis_mips64el.lua b/src/jit/dis_mips64el.lua
new file mode 100644
index 00000000..2b1470af
--- /dev/null
+++ b/src/jit/dis_mips64el.lua
@@ -0,0 +1,17 @@
1----------------------------------------------------------------------------
2-- LuaJIT MIPS64EL disassembler wrapper module.
3--
4-- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
5-- Released under the MIT license. See Copyright Notice in luajit.h
6----------------------------------------------------------------------------
7-- This module just exports the little-endian functions from the
8-- MIPS disassembler module. All the interesting stuff is there.
9------------------------------------------------------------------------------
10
11local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips")
12return {
13 create = dis_mips.create_el,
14 disass = dis_mips.disass_el,
15 regname = dis_mips.regname
16}
17
diff --git a/src/jit/dump.lua b/src/jit/dump.lua
index 898ce9a1..2bea652b 100644
--- a/src/jit/dump.lua
+++ b/src/jit/dump.lua
@@ -85,7 +85,7 @@ local nexitsym = 0
85local function fillsymtab_tr(tr, nexit) 85local function fillsymtab_tr(tr, nexit)
86 local t = {} 86 local t = {}
87 symtabmt.__index = t 87 symtabmt.__index = t
88 if jit.arch == "mips" or jit.arch == "mipsel" then 88 if jit.arch:sub(1, 4) == "mips" then
89 t[traceexitstub(tr, 0)] = "exit" 89 t[traceexitstub(tr, 0)] = "exit"
90 return 90 return
91 end 91 end