Format code

This commit is contained in:
offtkp 2024-08-28 23:08:42 +03:00
parent 8e19ccd507
commit 96afa3d8ee
1 changed files with 15 additions and 11 deletions

View File

@ -333,8 +333,9 @@ static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGe
static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
// INSERTQ Instruction Reference // INSERTQ Instruction Reference
// Inserts bits from the lower 64 bits of the source operand into the lower 64 bits of the destination operand // Inserts bits from the lower 64 bits of the source operand into the lower 64 bits of the
// No other bits in the lower 64 bits of the destination are modified. The upper 64 bits of the destination are undefined. // destination operand No other bits in the lower 64 bits of the destination are modified. The
// upper 64 bits of the destination are undefined.
// There's two forms of the instruction: // There's two forms of the instruction:
// INSERTQ xmm1, xmm2, imm8, imm8 // INSERTQ xmm1, xmm2, imm8, imm8
@ -352,14 +353,15 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
// xmm1 starting at the bit position specified by // xmm1 starting at the bit position specified by
// xmm2[77:72]. // xmm2[77:72].
// A value of zero in the field length is defined as a length of 64. If the length field is 0 and the bit index // A value of zero in the field length is defined as a length of 64. If the length field is 0
// is 0, bits 63:0 of the source operand are inserted. For any other value of the bit index, the results are // and the bit index is 0, bits 63:0 of the source operand are inserted. For any other value of
// undefined. // the bit index, the results are undefined.
bool immediateForm = operands[2].type == ZYDIS_OPERAND_TYPE_IMMEDIATE && bool immediateForm = operands[2].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
operands[3].type == ZYDIS_OPERAND_TYPE_IMMEDIATE; operands[3].type == ZYDIS_OPERAND_TYPE_IMMEDIATE;
if (operands[0].type != ZYDIS_OPERAND_TYPE_REGISTER || operands[1].type != ZYDIS_OPERAND_TYPE_REGISTER) { if (operands[0].type != ZYDIS_OPERAND_TYPE_REGISTER ||
operands[1].type != ZYDIS_OPERAND_TYPE_REGISTER) {
ASSERT_MSG("operands 0 and 1 must be registers."); ASSERT_MSG("operands 0 and 1 must be registers.");
} }
@ -408,14 +410,16 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
RestoreRegisters(c, {scratch1, scratch2, mask}); RestoreRegisters(c, {scratch1, scratch2, mask});
} else { } else {
if (operands[2].type != ZYDIS_OPERAND_TYPE_UNUSED || operands[3].type != ZYDIS_OPERAND_TYPE_UNUSED) { if (operands[2].type != ZYDIS_OPERAND_TYPE_UNUSED ||
operands[3].type != ZYDIS_OPERAND_TYPE_UNUSED) {
ASSERT_MSG("operands 2 and 3 must be unused for register form."); ASSERT_MSG("operands 2 and 3 must be unused for register form.");
} }
const Xbyak::Reg64 scratch1 = AllocateScratchRegister({}, 64).cvt64(); const Xbyak::Reg64 scratch1 = AllocateScratchRegister({}, 64).cvt64();
const Xbyak::Reg64 scratch2 = AllocateScratchRegister({&scratch1}, 64).cvt64(); const Xbyak::Reg64 scratch2 = AllocateScratchRegister({&scratch1}, 64).cvt64();
const Xbyak::Reg64 index = AllocateScratchRegister({&scratch1, &scratch2}, 64).cvt64(); const Xbyak::Reg64 index = AllocateScratchRegister({&scratch1, &scratch2}, 64).cvt64();
const Xbyak::Reg64 mask = AllocateScratchRegister({&scratch1, &scratch2, &index}, 64).cvt64(); const Xbyak::Reg64 mask =
AllocateScratchRegister({&scratch1, &scratch2, &index}, 64).cvt64();
SaveRegisters(c, {scratch1, scratch2, index, mask}); SaveRegisters(c, {scratch1, scratch2, index, mask});