/src/capstonenext/arch/PowerPC/PPCInstrInfo.h
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | /* Capstone Disassembly Engine, http://www.capstone-engine.org */ | 
| 2 |  | /* By Rot127 <unisono@quyllur.org> 2022-2023 */ | 
| 3 |  |  | 
| 4 |  | #ifndef CS_PPC_INSTRINFO_H | 
| 5 |  | #define CS_PPC_INSTRINFO_H | 
| 6 |  |  | 
| 7 |  | #include "PPCMCTargetDesc.h" | 
| 8 |  |  | 
| 9 |  | extern const MCInstrDesc PPCInsts[]; | 
| 10 |  |  | 
| 11 |  | static bool isVFRegister(unsigned Reg) | 
| 12 | 9.30k | { | 
| 13 | 9.30k |   return Reg >= PPC_VF0 && Reg <= PPC_VF31; | 
| 14 | 9.30k | } | 
| 15 |  | static bool isVRRegister(unsigned Reg) | 
| 16 | 7.02k | { | 
| 17 | 7.02k |   return Reg >= PPC_V0 && Reg <= PPC_V31; | 
| 18 | 7.02k | } | 
| 19 |  |  | 
| 20 |  | /// getRegNumForOperand - some operands use different numbering schemes | 
| 21 |  | /// for the same registers. For example, a VSX instruction may have any of | 
| 22 |  | /// vs0-vs63 allocated whereas an Altivec instruction could only have | 
| 23 |  | /// vs32-vs63 allocated (numbered as v0-v31). This function returns the actual | 
| 24 |  | /// register number needed for the opcode/operand number combination. | 
| 25 |  | /// The operand number argument will be useful when we need to extend this | 
| 26 |  | /// to instructions that use both Altivec and VSX numbering (for different | 
| 27 |  | /// operands). | 
| 28 |  | static unsigned PPCInstrInfo_getRegNumForOperand(const MCInstrDesc *Desc, | 
| 29 |  |              unsigned Reg, unsigned OpNo) | 
| 30 | 127k | { | 
| 31 | 127k |   int16_t regClass = Desc->OpInfo[OpNo].RegClass; | 
| 32 | 127k |   switch (regClass) { | 
| 33 |  |   // We store F0-F31, VF0-VF31 in MCOperand and it should be F0-F31, | 
| 34 |  |   // VSX32-VSX63 during encoding/disassembling | 
| 35 | 7.16k |   case PPC_VSSRCRegClassID: | 
| 36 | 9.30k |   case PPC_VSFRCRegClassID: | 
| 37 | 9.30k |     if (isVFRegister(Reg)) | 
| 38 | 2.16k |       return PPC_VSX32 + (Reg - PPC_VF0); | 
| 39 | 7.14k |     break; | 
| 40 |  |   // We store VSL0-VSL31, V0-V31 in MCOperand and it should be VSL0-VSL31, | 
| 41 |  |   // VSX32-VSX63 during encoding/disassembling | 
| 42 | 7.14k |   case PPC_VSRCRegClassID: | 
| 43 | 7.02k |     if (isVRRegister(Reg)) | 
| 44 | 2.88k |       return PPC_VSX32 + (Reg - PPC_V0); | 
| 45 | 4.14k |     break; | 
| 46 |  |   // Other RegClass doesn't need mapping | 
| 47 | 111k |   default: | 
| 48 | 111k |     break; | 
| 49 | 127k |   } | 
| 50 | 122k |   return Reg; | 
| 51 | 127k | } | 
| 52 |  |  | 
| 53 |  | #endif // CS_PPC_INSTRINFO_H |