MCPcopy Create free account
hub / github.com/capstone-engine/capstone / DecoderForMRRC2AndMCRR2

Function DecoderForMRRC2AndMCRR2

arch/ARM/ARMDisassembler.c:5686–5734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5684}
5685
5686static DecodeStatus DecoderForMRRC2AndMCRR2(MCInst *Inst, unsigned Val,
5687 uint64_t Address, const void *Decoder)
5688{
5689 DecodeStatus result = MCDisassembler_Success;
5690 unsigned CRm = fieldFromInstruction_4(Val, 0, 4);
5691 unsigned opc1 = fieldFromInstruction_4(Val, 4, 4);
5692 unsigned cop = fieldFromInstruction_4(Val, 8, 4);
5693 unsigned Rt = fieldFromInstruction_4(Val, 12, 4);
5694 unsigned Rt2 = fieldFromInstruction_4(Val, 16, 4);
5695
5696 if ((cop & ~0x1) == 0xa)
5697 return MCDisassembler_Fail;
5698
5699 if (Rt == Rt2)
5700 result = MCDisassembler_SoftFail;
5701
5702 // We have to check if the instruction is MRRC2
5703 // or MCRR2 when constructing the operands for
5704 // Inst. Reason is because MRRC2 stores to two
5705 // registers so it's tablegen desc has has two
5706 // outputs whereas MCRR doesn't store to any
5707 // registers so all of it's operands are listed
5708 // as inputs, therefore the operand order for
5709 // MRRC2 needs to be [Rt, Rt2, cop, opc1, CRm]
5710 // and MCRR2 operand order is [cop, opc1, Rt, Rt2, CRm]
5711
5712 if (MCInst_getOpcode(Inst) == ARM_MRRC2) {
5713 if (!Check(&result, DecodeGPRnopcRegisterClass(Inst, Rt, Address, Decoder)))
5714 return MCDisassembler_Fail;
5715
5716 if (!Check(&result, DecodeGPRnopcRegisterClass(Inst, Rt2, Address, Decoder)))
5717 return MCDisassembler_Fail;
5718 }
5719
5720 MCOperand_CreateImm0(Inst, cop);
5721 MCOperand_CreateImm0(Inst, opc1);
5722
5723 if (MCInst_getOpcode(Inst) == ARM_MCRR2) {
5724 if (!Check(&result, DecodeGPRnopcRegisterClass(Inst, Rt, Address, Decoder)))
5725 return MCDisassembler_Fail;
5726
5727 if (!Check(&result, DecodeGPRnopcRegisterClass(Inst, Rt2, Address, Decoder)))
5728 return MCDisassembler_Fail;
5729 }
5730
5731 MCOperand_CreateImm0(Inst, CRm);
5732
5733 return result;
5734}
5735
5736static DecodeStatus DecodeForVMRSandVMSR(MCInst *Inst, unsigned Val,
5737 uint64_t Address, const void *Decoder)

Callers

nothing calls this directly

Calls 4

MCInst_getOpcodeFunction · 0.85
MCOperand_CreateImm0Function · 0.85
CheckFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…