Coverage Report

Created: 2025-10-12 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/arch/PowerPC/PPCInstrInfo.h
Line
Count
Source
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
static bool isVFRegister(unsigned Reg)
10
5.86k
{
11
5.86k
  return Reg >= PPC_VF0 && Reg <= PPC_VF31;
12
5.86k
}
13
static bool isVRRegister(unsigned Reg)
14
8.57k
{
15
8.57k
  return Reg >= PPC_V0 && Reg <= PPC_V31;
16
8.57k
}
17
18
/// getRegNumForOperand - some operands use different numbering schemes
19
/// for the same registers. For example, a VSX instruction may have any of
20
/// vs0-vs63 allocated whereas an Altivec instruction could only have
21
/// vs32-vs63 allocated (numbered as v0-v31). This function returns the actual
22
/// register number needed for the opcode/operand number combination.
23
/// The operand number argument will be useful when we need to extend this
24
/// to instructions that use both Altivec and VSX numbering (for different
25
/// operands).
26
static unsigned PPCInstrInfo_getRegNumForOperand(const MCInstrDesc *Desc,
27
             unsigned Reg, unsigned OpNo)
28
100k
{
29
100k
  int16_t regClass = Desc->OpInfo[OpNo].RegClass;
30
100k
  switch (regClass) {
31
  // We store F0-F31, VF0-VF31 in MCOperand and it should be F0-F31,
32
  // VSX32-VSX63 during encoding/disassembling
33
3.68k
  case PPC_VSSRCRegClassID:
34
5.86k
  case PPC_VSFRCRegClassID:
35
5.86k
    if (isVFRegister(Reg))
36
1.23k
      return PPC_VSX32 + (Reg - PPC_VF0);
37
4.63k
    break;
38
  // We store VSL0-VSL31, V0-V31 in MCOperand and it should be VSL0-VSL31,
39
  // VSX32-VSX63 during encoding/disassembling
40
8.57k
  case PPC_VSRCRegClassID:
41
8.57k
    if (isVRRegister(Reg))
42
2.53k
      return PPC_VSX32 + (Reg - PPC_V0);
43
6.03k
    break;
44
  // Other RegClass doesn't need mapping
45
86.1k
  default:
46
86.1k
    break;
47
100k
  }
48
96.8k
  return Reg;
49
100k
}
50
51
#endif // CS_PPC_INSTRINFO_H