From 74351c7174d7c0e3a3a3605e1e4d69fda33d06eb Mon Sep 17 00:00:00 2001 From: Dirk Steinke Date: Fri, 1 Aug 2014 04:33:32 +0200 Subject: [PATCH] Fix layout of MOV_DI, now all instruction encodings are the same that nasm produce. --- include/jitcs_x86_xx_cons.lh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/include/jitcs_x86_xx_cons.lh b/include/jitcs_x86_xx_cons.lh index b7fde84..6e07b17 100644 --- a/include/jitcs_x86_xx_cons.lh +++ b/include/jitcs_x86_xx_cons.lh @@ -51,13 +51,14 @@ namespace x86_%(N) { inline uint ToSize(InsId id) { return ToSize(ToInsClass(id)); } u32 ToValidMask(InsClassId cl); + static const unsigned CI64Op = sizeof(iptr) >= sizeof(i64) ? 0 : 1; template struct InsClass2SizeCT {}; /*| for k,cl in pred_ipairs(data.opclasses, function(k,cl) return isa(cl.isa) end) do -/*| local sz = 1 + #cl.layout +/*| local sz, i64 = 1 + #cl.layout, 0 /*| for k,v in ipairs(cl.layout) do -/*| if N == 64 and v[1]=="Imm" and v[3] == 32 then sz = sz - 1 end +/*| if v[1]=="Imm" and v[4] == 32 then sz = sz - 1; i64 = i64 + 1 end /*| end -/*| local rsz = sz +/*| local rsz = sz .. (i64 > 0 and (" + CI64Op * "..i64) or "") template <> struct InsClass2SizeCT { static const u8 Value = %rsz; }; /*| end /*| --*/ @@ -80,12 +81,12 @@ namespace x86_%(N) { /*| local function sublayout(layout) /*| local l = { sig = "" } /*| for k,v in ipairs(layout) do -/*| if N == 64 and v[1] == "Imm" and k > 1 and islowimm_org(layout, k - 1) then +/*| --if N == 64 and v[1] == "Imm" and k > 1 and islowimm_org(layout, k - 1) then /*| -- skip -/*| else +/*| --else /*| l[#l + 1] = {v[1],v[3],v[4]} /*| l.sig = (#l.sig > 0 and (l.sig .. ",") or "")..v[1].." "..v[3]..(v[4] and (" "..v[4]) or "") -/*| end +/*| --end /*| end /*| if layoutlu[l.sig] then return layoutlu[l.sig] end /*| layoutlu[l.sig] = l @@ -120,7 +121,7 @@ namespace x86_%(N) { /*| if t[1] == "RegId" then fun = "RRef" end /*| if t[1] == "BBId" then fun = "BB" end /*| if t[1] == "Imm" then fun = "Imm" end -/*| if t[1] == "Imm" and t[3] == 32 then value = value .. (" >> ("..t[3].." % sizeof(iptr))") +/*| if t[1] == "Imm" and t[3] == 32 then value = value .. (" >> "..t[3]) if (%(t[3]) >= sizeof(iptr)) /*| end /*| if value then @@ -163,7 +164,9 @@ namespace x86_%(N) { /*| end /*| local parms, l = "", layoutlu2[op.opclass.layout.id] /*| for k,v in ipairs(l) do -/*| parms = parms .. ", "..(ren[v[2]]) +/*| if k < 2 or not islowimm(l, k - 1) then +/*| parms = parms .. ", "..(ren[v[2]]) +/*| end /*| end /*| return parms /*| end -- 2.11.4.GIT