data_processing_bitfield: Move datasize variables after early-exit conditionals
Moves the declaration of datasize to the scope that it's used within. This also takes the opportunity to apply const where applicable, and make early-exits all vertically consistent with one another.
This commit is contained in:
parent
2e0fcd6161
commit
f4a66d2477
1 changed files with 44 additions and 29 deletions
|
@ -15,64 +15,79 @@ static IR::U32U64 ReplicateBit(IREmitter& ir, const IR::U32U64& value, u8 bit_po
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TranslatorVisitor::SBFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) {
|
bool TranslatorVisitor::SBFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) {
|
||||||
size_t datasize = sf ? 64 : 32;
|
if (sf && !N) {
|
||||||
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
if (sf && !N) return ReservedValue();
|
if (!sf && (N || immr.Bit<5>() || imms.Bit<5>())) {
|
||||||
if (!sf && (N || immr.Bit<5>() || imms.Bit<5>())) return ReservedValue();
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
u8 R = immr.ZeroExtend<u8>();
|
const u8 R = immr.ZeroExtend<u8>();
|
||||||
u8 S = imms.ZeroExtend<u8>();
|
const u8 S = imms.ZeroExtend<u8>();
|
||||||
auto masks = DecodeBitMasks(N, imms, immr, false);
|
const auto masks = DecodeBitMasks(N, imms, immr, false);
|
||||||
if (!masks) return ReservedValue();
|
if (!masks) {
|
||||||
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
auto src = X(datasize, Rn);
|
const size_t datasize = sf ? 64 : 32;
|
||||||
|
const auto src = X(datasize, Rn);
|
||||||
|
|
||||||
auto bot = ir.And(ir.RotateRight(src, ir.Imm8(R)), I(datasize, masks->wmask));
|
auto bot = ir.And(ir.RotateRight(src, ir.Imm8(R)), I(datasize, masks->wmask));
|
||||||
auto top = ReplicateBit(ir, src, S);
|
auto top = ReplicateBit(ir, src, S);
|
||||||
|
|
||||||
top = ir.And(top, I(datasize, ~masks->tmask));
|
top = ir.And(top, I(datasize, ~masks->tmask));
|
||||||
bot = ir.And(bot, I(datasize, masks->tmask));
|
bot = ir.And(bot, I(datasize, masks->tmask));
|
||||||
X(datasize, Rd, ir.Or(top, bot));
|
|
||||||
|
|
||||||
|
X(datasize, Rd, ir.Or(top, bot));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TranslatorVisitor::BFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) {
|
bool TranslatorVisitor::BFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) {
|
||||||
size_t datasize = sf ? 64 : 32;
|
if (sf && !N) {
|
||||||
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
if (sf && !N) return ReservedValue();
|
if (!sf && (N || immr.Bit<5>() || imms.Bit<5>())) {
|
||||||
if (!sf && (N || immr.Bit<5>() || imms.Bit<5>())) return ReservedValue();
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
u8 R = immr.ZeroExtend<u8>();
|
const u8 R = immr.ZeroExtend<u8>();
|
||||||
auto masks = DecodeBitMasks(N, imms, immr, false);
|
const auto masks = DecodeBitMasks(N, imms, immr, false);
|
||||||
if (!masks) return ReservedValue();
|
if (!masks) {
|
||||||
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
auto dst = X(datasize, Rd);
|
const size_t datasize = sf ? 64 : 32;
|
||||||
auto src = X(datasize, Rn);
|
const auto dst = X(datasize, Rd);
|
||||||
|
const auto src = X(datasize, Rn);
|
||||||
|
|
||||||
auto bot = ir.Or(ir.And(dst, I(datasize, ~masks->wmask)), ir.And(ir.RotateRight(src, ir.Imm8(R)), I(datasize, masks->wmask)));
|
const auto bot = ir.Or(ir.And(dst, I(datasize, ~masks->wmask)), ir.And(ir.RotateRight(src, ir.Imm8(R)), I(datasize, masks->wmask)));
|
||||||
|
|
||||||
X(datasize, Rd, ir.Or(ir.And(dst, I(datasize, ~masks->tmask)), ir.And(bot, I(datasize, masks->tmask))));
|
X(datasize, Rd, ir.Or(ir.And(dst, I(datasize, ~masks->tmask)), ir.And(bot, I(datasize, masks->tmask))));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TranslatorVisitor::UBFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) {
|
bool TranslatorVisitor::UBFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) {
|
||||||
size_t datasize = sf ? 64 : 32;
|
if (sf && !N) {
|
||||||
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
if (sf && !N) return ReservedValue();
|
if (!sf && (N || immr.Bit<5>() || imms.Bit<5>())) {
|
||||||
if (!sf && (N || immr.Bit<5>() || imms.Bit<5>())) return ReservedValue();
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
u8 R = immr.ZeroExtend<u8>();
|
const u8 R = immr.ZeroExtend<u8>();
|
||||||
auto masks = DecodeBitMasks(N, imms, immr, false);
|
const auto masks = DecodeBitMasks(N, imms, immr, false);
|
||||||
if (!masks) return ReservedValue();
|
if (!masks) {
|
||||||
|
return ReservedValue();
|
||||||
|
}
|
||||||
|
|
||||||
auto src = X(datasize, Rn);
|
const size_t datasize = sf ? 64 : 32;
|
||||||
|
const auto src = X(datasize, Rn);
|
||||||
auto bot = ir.And(ir.RotateRight(src, ir.Imm8(R)), I(datasize, masks->wmask));
|
const auto bot = ir.And(ir.RotateRight(src, ir.Imm8(R)), I(datasize, masks->wmask));
|
||||||
|
|
||||||
X(datasize, Rd, ir.And(bot, I(datasize, masks->tmask)));
|
X(datasize, Rd, ir.And(bot, I(datasize, masks->tmask)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue