The check to see if an item was already on the heap was randomly hitting.
[jitcs.git] / tools / x86_reglist2data.lua
blobe4ded9e0651cd8fea800a974bab9fe7caaa7fe49
1 local _setfenv, _ipairs, _loadstr = setfenv, ipairs, loadstring
2 local _open = io.open
3 local _match, _gmatch, _fmt = string.match, string.gmatch, string.format
4 local _gsub, _sub = string.gsub, string.sub
5 local _exec = os.execute
7 --local function readfile(n)
8 -- local f = _open(n)
9 -- local ctnt = f:read("*a")
10 -- f:close()
11 -- return ctnt
12 --end
14 --local testname, outname = ...
15 --if (testname == nil or testname == "") then
16 -- testname = "..\\evm\\x86\\src\\_x86_insalias.ltxt"
17 --end
18 --if outname == nil or outname == "" then
19 -- outname = _match(testname, "^(.-)%.[^.\\/]*$") .. ".dat"
20 --end
22 --local emblua = _loadstr(readfile("emblua.lua"))
23 --local aliaslist = emblua(testname,{type="string"})
25 --f= ...
27 --f= f:gsub( "(//[^\r\n]*)([\r\n])","%2" )
28 --f= f:gsub( "(/%*.-%*/)","" )
30 --local mode, lines, data = "", {}, {}
31 --for l in f:lines() do
32 -- l= l:trim()
33 -- if (l~="") then
34 -- local m = l:match("^:(%w+)$")
35 -- if m then
36 -- mode = m
37 -- else
38 -- local ll = lines[mode] or {}
39 -- ll[#ll + 1] = l
40 -- lines[mode] = ll
41 -- end
42 -- end
43 --end
45 -----------------------------------------
46 local barrier = {}
47 barrier.start = function() return {false,false} end
48 barrier.stop = function(b)
49 if b[1] or b[2] then
50 print(" #endif")
51 end
52 end
53 barrier.continue2 = function(b,newx32,newx64)
54 if (b[1] and not newx64) or (b[2] and not newx32) then
55 print(" #endif")
56 b = {false,false}
57 end
58 if not b[1] and newx64 then
59 print(" #ifdef EVM_64")
60 return {true,false}
61 end
62 if not b[2] and newx32 then
63 print(" #ifndef EVM_64")
64 return {false,true}
65 end
66 return b
67 end
68 barrier.continue = function(b,op)
69 return barrier.continue2(b,op.x32only,op.x64)
70 end
71 -----------------------------------------
72 -- selector
73 -----------------------------------------
75 local data = {}
76 data.classes = {
77 {name = "FLAGSR", resclass = "FLAGRSC", subres = "0x01", regbase = 1},
78 {name = "GR8L", partial = "true", subres = "0x01", resclass = "GRRSC", restrictres = "0-3", regbase = 32},
79 {name = "GR8H", partial = "true", subres = "0x02", resclass = "GRRSC", restrictres = "0-3", regbase = 36},
80 {name = "GR16", partial = "true", subres = "0x03", resclass = "GRRSC", regbase = 64},
81 {name = "GR32", subres = "0x07", resclass = "GRRSC", regbase = 16},
82 {name = "VR128", subres = "0x01", resclass = "VRRSC", regbase = 96, restrictres_64 = "0-31"},
83 {name = "VR256", subres = "0x03", resclass = "VRRSC", regbase = 128, restrictres_64 = "0-31"},
84 {name = "VR512", subres = "0x07", resclass = "VRRSC", regbase = 160, restrictres_64 = "0-31"},
85 {name = "GR8X", partial = "true", subres = "0x01", x64 = true, resclass = "GRRSC", restrictres = "4-15", regbase = 48},
86 {name = "GR64", subres = "0x07", x64 = true, resclass = "GRRSC", regbase = 80},
88 data.classaliases = {
89 {name = "GR", dest = "GR32", x32 = true},
90 {name = "GR", dest = "GR64", x64 = true},
92 data.resources = {
93 {name = "GRRSC", cnt = 8, resbits = 4, x32 = true},
94 {name = "VRRSC", cnt = 8, resbits = 4, x32 = true},
95 {name = "GRRSC", cnt = 16, resbits = 4, x64 = true},
96 {name = "VRRSC", cnt = 32, resbits = 4, x64 = true},
97 {name = "FLAGRSC", cnt = 1, resbits = 1},
99 data.registers = {
100 {name = "FLAGS", class = "FLAGSR", id = 1, refclass = "FLAGS", resindex = 0},
102 local r = data.registers
103 for k,v in pairs({ A = 0, C = 1, D = 2, B = 3}) do
104 r[#r+1] = {name = k.."L", id = 32+v, class = "GR8L", refclass = "GR8", resindex = v}
105 r[#r+1] = {name = k.."H", id = 32+4+v, class = "GR8H", refclass = "GR8", resindex = v}
106 r[#r+1] = {name = k.."X", id = 64+v, class = "GR16", refclass = "GR16", resindex = v}
107 r[#r+1] = {name = "E"..k.."X", id = 16+v, class = "GR32", refclass = "GR32", resindex = v}
108 r[#r+1] = {name = "R"..k.."X", id = 80+v, class = "GR64", refclass = "GR64", resindex = v, x64 = true}
110 for k,v in pairs({ SP = 4, BP = 5, SI = 6, DI = 7}) do
111 r[#r+1] = {name = k.."L", id = 48+v, class = "GR8X", refclass = "GR8", resindex = v, x64 = true}
112 r[#r+1] = {name = k, id = 64+v, class = "GR16", refclass = "GR16", resindex = v}
113 r[#r+1] = {name = "E"..k, id = 16+v, class = "GR32", refclass = "GR32", resindex = v}
114 r[#r+1] = {name = "R"..k, id = 80+v, class = "GR64", refclass = "GR64", resindex = v, x64 = true}
116 for v = 0,7 do
117 r[#r+1] = {name = "XMM"..v, namemask = "XMM%d", id = 96+v, class = "VR128", refclass = "VR128", resindex = v}
118 r[#r+1] = {name = "YMM"..v, namemask = "YMM%d", id = 128+v, class = "VR256", refclass = "VR256", resindex = v}
119 r[#r+1] = {name = "ZMM"..v, namemask = "ZMM%d", id = 160+v, class = "VR512", refclass = "VR512", resindex = v}
121 for v = 8,31 do
122 if v < 16 then
123 r[#r+1] = {name = "R"..v.."L", namemask = "R%dL", id = 48+v, class = "GR8X", refclass = "GR8", resindex = v, x64 = true}
124 r[#r+1] = {name = "R"..v.."W", namemask = "R%dW", id = 64+v, class = "GR16", refclass = "GR16", resindex = v, x64 = true}
125 r[#r+1] = {name = "R"..v.."D", namemask = "R%dD", id = 16+v, class = "GR32", refclass = "GR32", resindex = v, x64 = true}
126 r[#r+1] = {name = "R"..v, namemask = "R%d", id = 80+v, class = "GR64", refclass = "GR64", resindex = v, x64 = true}
128 r[#r+1] = {name = "XMM"..v, namemask = "XMM%d", id = 96+v, class = "VR128", refclass = "VR128", resindex = v, x64 = true}
129 r[#r+1] = {name = "YMM"..v, namemask = "YMM%d", id = 128+v, class = "VR256", refclass = "VR256", resindex = v, x64 = true}
130 r[#r+1] = {name = "ZMM"..v, namemask = "ZMM%d", id = 160+v, class = "VR512", refclass = "VR512", resindex = v, x64 = true}
132 table.sort(r,function(a,b)
133 if a.x64 ~= b.x64 then return b.x64 end
134 if a.x32 ~= b.x32 then return b.x32 end
135 return a.id<b.id
136 end)
138 data.registeraliases = {
140 r = data.registeraliases
141 for k,v in pairs({ A = 0, C = 1, D = 2, B = 3}) do
142 r[#r+1] = {name = "R"..v.."L", dest = k.."L"}
143 r[#r+1] = {name = "R"..v.."H", dest = k.."H"}
144 r[#r+1] = {name = "R"..v.."W", dest = k.."X"}
145 r[#r+1] = {name = "R"..v.."D", dest = "E"..k.."X"}
146 r[#r+1] = {name = "R"..v, dest = "R"..k.."X", x64 = true}
147 r[#r+1] = {name = "R"..v, dest = "E"..k.."X", x32 = true}
148 r[#r+1] = {name = "R"..k.."X", dest = "E"..k.."X", x32 = true}
150 for k,v in pairs({ SP = 4, BP = 5, SI = 6, DI = 7}) do
151 r[#r+1] = {name = "R"..v.."L", dest = k.."L", x64 = true}
152 r[#r+1] = {name = "R"..v.."W", dest = k}
153 r[#r+1] = {name = "R"..v.."D", dest = "E"..k}
154 r[#r+1] = {name = "R"..v, dest = "R"..k, x64 = true}
155 r[#r+1] = {name = "R"..v, dest = "E"..k, x32 = true}
156 r[#r+1] = {name = "R"..k, dest = "E"..k, x32 = true}
158 table.sort(r,function(a,b)
159 if a.x64 ~= b.x64 then return b.x64 end
160 if a.x32 ~= b.x32 then return b.x32 end
161 return a.name<b.name
162 end)
163 data.refclasses = {
164 {name = "GR8", classes = {"GR8L", "GR8H", "GR8X"}, dontalloc="4-7", defsz = 1},
165 {name = "GR16", classes = {"GR16", "GR32", "GR64"}, superrefclasses = {"GR32", "GR64"}, defsz = 2},
166 {name = "GR32", classes = {"GR32", "GR64"}, superrefclasses = {"GR64"}, defsz = 4},
167 {name = "VR128", classes = {"VR128", "VR256","VR512"}, superrefclasses = {"VR256","VR512"}, defsz = 16},
168 {name = "VR256", classes = {"VR256","VR512"}, superrefclasses = {"VR512"}, defsz = 32},
169 {name = "VR512", classes = {"VR512"}, defsz = 64},
170 {name = "GR64", x64 = true, classes = {"GR64"}, defsz = 8},
171 {name = "FLAGS", classes = {"FLAGSR"}, defsz = 0},
173 data.refclassaliases = {
174 {name = "GR", dest = "GR32", x32 = true},
175 {name = "GR", dest = "GR64", x64 = true},
177 data.barrier = barrier
179 return data