Coverage Report

Created: 2026-06-15 06:41

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
95.6M
{
26
95.6M
  const uint8_t *orig_p = p;
27
95.6M
  uint64_t Value = 0;
28
95.6M
  unsigned Shift = 0;
29
107M
  do {
30
107M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
107M
    Shift += 7;
32
107M
  } while (*p++ >= 128);
33
95.6M
  if (n)
34
95.6M
    *n = (unsigned)(p - orig_p);
35
95.6M
  return Value;
36
95.6M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
42.8M
{
26
42.8M
  const uint8_t *orig_p = p;
27
42.8M
  uint64_t Value = 0;
28
42.8M
  unsigned Shift = 0;
29
47.5M
  do {
30
47.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
47.5M
    Shift += 7;
32
47.5M
  } while (*p++ >= 128);
33
42.8M
  if (n)
34
42.8M
    *n = (unsigned)(p - orig_p);
35
42.8M
  return Value;
36
42.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
13.1M
{
26
13.1M
  const uint8_t *orig_p = p;
27
13.1M
  uint64_t Value = 0;
28
13.1M
  unsigned Shift = 0;
29
14.4M
  do {
30
14.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.4M
    Shift += 7;
32
14.4M
  } while (*p++ >= 128);
33
13.1M
  if (n)
34
13.1M
    *n = (unsigned)(p - orig_p);
35
13.1M
  return Value;
36
13.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.34M
{
26
7.34M
  const uint8_t *orig_p = p;
27
7.34M
  uint64_t Value = 0;
28
7.34M
  unsigned Shift = 0;
29
7.63M
  do {
30
7.63M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.63M
    Shift += 7;
32
7.63M
  } while (*p++ >= 128);
33
7.34M
  if (n)
34
7.34M
    *n = (unsigned)(p - orig_p);
35
7.34M
  return Value;
36
7.34M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.62M
{
26
8.62M
  const uint8_t *orig_p = p;
27
8.62M
  uint64_t Value = 0;
28
8.62M
  unsigned Shift = 0;
29
8.96M
  do {
30
8.96M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.96M
    Shift += 7;
32
8.96M
  } while (*p++ >= 128);
33
8.62M
  if (n)
34
8.62M
    *n = (unsigned)(p - orig_p);
35
8.62M
  return Value;
36
8.62M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.36M
{
26
3.36M
  const uint8_t *orig_p = p;
27
3.36M
  uint64_t Value = 0;
28
3.36M
  unsigned Shift = 0;
29
3.45M
  do {
30
3.45M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.45M
    Shift += 7;
32
3.45M
  } while (*p++ >= 128);
33
3.36M
  if (n)
34
3.36M
    *n = (unsigned)(p - orig_p);
35
3.36M
  return Value;
36
3.36M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.4M
{
26
12.4M
  const uint8_t *orig_p = p;
27
12.4M
  uint64_t Value = 0;
28
12.4M
  unsigned Shift = 0;
29
17.3M
  do {
30
17.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.3M
    Shift += 7;
32
17.3M
  } while (*p++ >= 128);
33
12.4M
  if (n)
34
12.4M
    *n = (unsigned)(p - orig_p);
35
12.4M
  return Value;
36
12.4M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.34M
{
26
1.34M
  const uint8_t *orig_p = p;
27
1.34M
  uint64_t Value = 0;
28
1.34M
  unsigned Shift = 0;
29
1.49M
  do {
30
1.49M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.49M
    Shift += 7;
32
1.49M
  } while (*p++ >= 128);
33
1.34M
  if (n)
34
1.34M
    *n = (unsigned)(p - orig_p);
35
1.34M
  return Value;
36
1.34M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.70M
{
26
1.70M
  const uint8_t *orig_p = p;
27
1.70M
  uint64_t Value = 0;
28
1.70M
  unsigned Shift = 0;
29
1.74M
  do {
30
1.74M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.74M
    Shift += 7;
32
1.74M
  } while (*p++ >= 128);
33
1.70M
  if (n)
34
1.70M
    *n = (unsigned)(p - orig_p);
35
1.70M
  return Value;
36
1.70M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.73M
{
26
4.73M
  const uint8_t *orig_p = p;
27
4.73M
  uint64_t Value = 0;
28
4.73M
  unsigned Shift = 0;
29
4.92M
  do {
30
4.92M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.92M
    Shift += 7;
32
4.92M
  } while (*p++ >= 128);
33
4.73M
  if (n)
34
4.73M
    *n = (unsigned)(p - orig_p);
35
4.73M
  return Value;
36
4.73M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H