capstone icon indicating copy to clipboard operation
capstone copied to clipboard

arm: simplify DecodeGPRPairRegisterClass()

Open xypron opened this issue 3 years ago • 5 comments

For RegNo > 13 we return. After the return statement RegNo cannot be 0x0e.

Signed-off-by: Heinrich Schuchardt [email protected]

xypron avatar Jun 28 '21 20:06 xypron

Thanks for PR, can you provide a test case and give a more detailed explanation about this pr?

kabeor avatar Nov 10 '21 13:11 kabeor

Thanks for PR, can you provide a test case and give a more detailed explanation about this pr?

The RegNo > 13 check above guarantees that RegNo != 13. Since 13 == 0xe, there is no point in checking RegNo == 0xe which is always false.

tmfink avatar Nov 11 '21 06:11 tmfink

also, per #1781 the next branch should be used instead of master

tmfink avatar Nov 11 '21 06:11 tmfink

Thanks for PR, can you provide a test case and give a more detailed explanation about this pr?

The RegNo > 13 check above guarantees that RegNo != 13. Since 13 == 0xe, there is no point in checking RegNo == 0xe which is always false.

I see, 14 == 0xe > RegNo.

kabeor avatar Nov 11 '21 06:11 kabeor

Yes, we only accept PR for 'next' branch now, plz rebase it, thanks.

kabeor avatar Nov 11 '21 06:11 kabeor

Will be overwritten by https://github.com/capstone-engine/capstone/pull/1949 cc @Rot127

XVilka avatar May 25 '23 04:05 XVilka

@kabeor Can be closed. The function was already fixed by the LLVM folks and we get it with https://github.com/capstone-engine/capstone/pull/1949.

static DecodeStatus DecodeGPRPairRegisterClass(MCInst *Inst, unsigned RegNo,
											   uint64_t Address,
											   const void *Decoder)
{
	DecodeStatus S = MCDisassembler_Success;

	// According to the Arm ARM RegNo = 14 is undefined, but we return fail
	// rather than SoftFail as there is no GPRPair table entry for index 7.
	if (RegNo > 13)
		return MCDisassembler_Fail;

	if (RegNo & 1)
		S = MCDisassembler_SoftFail;

	unsigned RegisterPair = GPRPairDecoderTable[RegNo / 2];
	MCOperand_CreateReg0(Inst, (RegisterPair));
	return S;
}

Rot127 avatar May 25 '23 12:05 Rot127

Thanks a lot.

kabeor avatar May 25 '23 12:05 kabeor