}
}
}
+ },
+ { -- 010
+ shift = 0, mask = 0x81f8fc00,
+ [0x100e400] = "moviDdG"
}
}
return sign * frac * 2^exp
end
+local function decode_fpmovi(op)
+ local lo = rshift(op, 5)
+ local hi = rshift(op, 9)
+ lo = bor(band(lo, 1) * 0xff, band(lo, 2) * 0x7f80, band(lo, 4) * 0x3fc000,
+ band(lo, 8) * 0x1fe00000)
+ hi = bor(band(hi, 1) * 0xff, band(hi, 0x80) * 0x1fe,
+ band(hi, 0x100) * 0xff00, band(hi, 0x200) * 0x7f8000)
+ if hi ~= 0 then
+ return fmt_hex32(hi)..tohex(lo)
+ else
+ return fmt_hex32(lo)
+ end
+end
+
local function prefer_bfx(sf, uns, imms, immr)
if imms < immr or imms == 31 or imms == 63 then
return false
x = 0
elseif p == "F" then
x = parse_fpimm8(op)
+ elseif p == "G" then
+ x = "#0x"..decode_fpmovi(op)
elseif p == "g" or p == "f" or p == "x" or p == "w" or
p == "d" or p == "s" then
-- These are handled in D/N/M/A.
return ~0u;
}
+static uint32_t emit_isfpmovi(uint64_t n)
+{
+ /* Is every byte either 0x00 or 0xff? */
+ if ((n & U64x(01010101,01010101)) * 0xff != n) return 0;
+ /* Form 8-bit value by taking one bit from each byte. */
+ n &= U64x(80402010,08040201);
+ n = (n * U64x(01010101,01010101)) >> 56;
+ /* Split into the format expected by movi. */
+ return ((n & 0xe0) << 6) | 0x700 | (n & 0x1f);
+}
+
/* -- Emit basic instructions --------------------------------------------- */
static void emit_dnma(ASMState *as, A64Ins ai, Reg rd, Reg rn, Reg rm, Reg ra)
if (fpk != ~0u) {
emit_d(as, A64I_FMOV_DI | A64F_FP8(fpk), (r & 31));
return;
+ } else if ((fpk = emit_isfpmovi(*k))) {
+ emit_d(as, A64I_MOVI_DI | (fpk << 5), (r & 31));
+ return;
}
}
ofs = glofs(as, k);
A64I_FMOV_R_D = 0x9e660000,
A64I_FMOV_D_R = 0x9e670000,
A64I_FMOV_DI = 0x1e601000,
+ A64I_MOVI_DI = 0x2f000400,
} A64Ins;
#define A64I_BR_AUTH (LJ_ABI_PAUTH ? A64I_BRAAZ : A64I_BR)