mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-25 13:06:46 +00:00
tcg/arm: Try pc-relative addresses for movi
Backports commit 9c39b94f1448770e7e573e9516d2483816785d1b from qemu
This commit is contained in:
parent
a5133ccaa1
commit
c99edca63b
|
@ -427,13 +427,9 @@ static inline void tcg_out_dat_imm(TCGContext *s,
|
||||||
|
|
||||||
static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg)
|
static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg)
|
||||||
{
|
{
|
||||||
int rot, opc, rn;
|
int rot, opc, rn, diff;
|
||||||
|
|
||||||
/* For armv7, make sure not to use movw+movt when mov/mvn would do.
|
/* Check a single MOV/MVN before anything else. */
|
||||||
Speed things up by only checking when movt would be required.
|
|
||||||
Prior to armv7, have one go at fully rotated immediates before
|
|
||||||
doing the decomposition thing below. */
|
|
||||||
if (!use_armv7_instructions || (arg & 0xffff0000)) {
|
|
||||||
rot = encode_imm(arg);
|
rot = encode_imm(arg);
|
||||||
if (rot >= 0) {
|
if (rot >= 0) {
|
||||||
tcg_out_dat_imm(s, cond, ARITH_MOV, rd, 0,
|
tcg_out_dat_imm(s, cond, ARITH_MOV, rd, 0,
|
||||||
|
@ -446,6 +442,24 @@ static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg)
|
||||||
rotl(~arg, rot) | (rot << 7));
|
rotl(~arg, rot) | (rot << 7));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for a pc-relative address. This will usually be the TB,
|
||||||
|
or within the TB, which is immediately before the code block. */
|
||||||
|
diff = arg - ((intptr_t)s->code_ptr + 8);
|
||||||
|
if (diff >= 0) {
|
||||||
|
rot = encode_imm(diff);
|
||||||
|
if (rot >= 0) {
|
||||||
|
tcg_out_dat_imm(s, cond, ARITH_ADD, rd, TCG_REG_PC,
|
||||||
|
rotl(diff, rot) | (rot << 7));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rot = encode_imm(-diff);
|
||||||
|
if (rot >= 0) {
|
||||||
|
tcg_out_dat_imm(s, cond, ARITH_SUB, rd, TCG_REG_PC,
|
||||||
|
rotl(-diff, rot) | (rot << 7));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use movw + movt. */
|
/* Use movw + movt. */
|
||||||
|
|
Loading…
Reference in a new issue