Coverage Report

Created: 2026-05-30 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonev5/LEB128.h
Line
Count
Source
1
//===- llvm/Support/LEB128.h - [SU]LEB128 utility functions -----*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file declares some utility functions for encoding SLEB128 and
11
// ULEB128 values.
12
//
13
//===----------------------------------------------------------------------===//
14
15
/* Capstone Disassembly Engine */
16
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
17
18
#ifndef CS_LLVM_SUPPORT_LEB128_H
19
#define CS_LLVM_SUPPORT_LEB128_H
20
21
#include "include/capstone/capstone.h"
22
23
/// Utility function to decode a ULEB128 value.
24
static inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n)
25
46.6M
{
26
46.6M
  const uint8_t *orig_p = p;
27
46.6M
  uint64_t Value = 0;
28
46.6M
  unsigned Shift = 0;
29
52.4M
  do {
30
52.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.4M
    Shift += 7;
32
52.4M
  } while (*p++ >= 128);
33
46.6M
  if (n)
34
46.6M
    *n = (unsigned)(p - orig_p);
35
46.6M
  return Value;
36
46.6M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.5M
{
26
19.5M
  const uint8_t *orig_p = p;
27
19.5M
  uint64_t Value = 0;
28
19.5M
  unsigned Shift = 0;
29
21.6M
  do {
30
21.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.6M
    Shift += 7;
32
21.6M
  } while (*p++ >= 128);
33
19.5M
  if (n)
34
19.5M
    *n = (unsigned)(p - orig_p);
35
19.5M
  return Value;
36
19.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.81M
{
26
6.81M
  const uint8_t *orig_p = p;
27
6.81M
  uint64_t Value = 0;
28
6.81M
  unsigned Shift = 0;
29
7.46M
  do {
30
7.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.46M
    Shift += 7;
32
7.46M
  } while (*p++ >= 128);
33
6.81M
  if (n)
34
6.81M
    *n = (unsigned)(p - orig_p);
35
6.81M
  return Value;
36
6.81M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.57M
{
26
3.57M
  const uint8_t *orig_p = p;
27
3.57M
  uint64_t Value = 0;
28
3.57M
  unsigned Shift = 0;
29
3.70M
  do {
30
3.70M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.70M
    Shift += 7;
32
3.70M
  } while (*p++ >= 128);
33
3.57M
  if (n)
34
3.57M
    *n = (unsigned)(p - orig_p);
35
3.57M
  return Value;
36
3.57M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.74M
{
26
4.74M
  const uint8_t *orig_p = p;
27
4.74M
  uint64_t Value = 0;
28
4.74M
  unsigned Shift = 0;
29
4.94M
  do {
30
4.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.94M
    Shift += 7;
32
4.94M
  } while (*p++ >= 128);
33
4.74M
  if (n)
34
4.74M
    *n = (unsigned)(p - orig_p);
35
4.74M
  return Value;
36
4.74M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.76M
{
26
1.76M
  const uint8_t *orig_p = p;
27
1.76M
  uint64_t Value = 0;
28
1.76M
  unsigned Shift = 0;
29
1.80M
  do {
30
1.80M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.80M
    Shift += 7;
32
1.80M
  } while (*p++ >= 128);
33
1.76M
  if (n)
34
1.76M
    *n = (unsigned)(p - orig_p);
35
1.76M
  return Value;
36
1.76M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.20M
{
26
6.20M
  const uint8_t *orig_p = p;
27
6.20M
  uint64_t Value = 0;
28
6.20M
  unsigned Shift = 0;
29
8.65M
  do {
30
8.65M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.65M
    Shift += 7;
32
8.65M
  } while (*p++ >= 128);
33
6.20M
  if (n)
34
6.20M
    *n = (unsigned)(p - orig_p);
35
6.20M
  return Value;
36
6.20M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
807k
{
26
807k
  const uint8_t *orig_p = p;
27
807k
  uint64_t Value = 0;
28
807k
  unsigned Shift = 0;
29
902k
  do {
30
902k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
902k
    Shift += 7;
32
902k
  } while (*p++ >= 128);
33
807k
  if (n)
34
807k
    *n = (unsigned)(p - orig_p);
35
807k
  return Value;
36
807k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
848k
{
26
848k
  const uint8_t *orig_p = p;
27
848k
  uint64_t Value = 0;
28
848k
  unsigned Shift = 0;
29
866k
  do {
30
866k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
866k
    Shift += 7;
32
866k
  } while (*p++ >= 128);
33
848k
  if (n)
34
848k
    *n = (unsigned)(p - orig_p);
35
848k
  return Value;
36
848k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.36M
{
26
2.36M
  const uint8_t *orig_p = p;
27
2.36M
  uint64_t Value = 0;
28
2.36M
  unsigned Shift = 0;
29
2.46M
  do {
30
2.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.46M
    Shift += 7;
32
2.46M
  } while (*p++ >= 128);
33
2.36M
  if (n)
34
2.36M
    *n = (unsigned)(p - orig_p);
35
2.36M
  return Value;
36
2.36M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H