Coverage Report

Created: 2026-08-13 06:59

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
94.1M
{
26
94.1M
  const uint8_t *orig_p = p;
27
94.1M
  uint64_t Value = 0;
28
94.1M
  unsigned Shift = 0;
29
106M
  do {
30
106M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
106M
    Shift += 7;
32
106M
  } while (*p++ >= 128);
33
94.1M
  if (n)
34
94.1M
    *n = (unsigned)(p - orig_p);
35
94.1M
  return Value;
36
94.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
42.3M
{
26
42.3M
  const uint8_t *orig_p = p;
27
42.3M
  uint64_t Value = 0;
28
42.3M
  unsigned Shift = 0;
29
46.9M
  do {
30
46.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
46.9M
    Shift += 7;
32
46.9M
  } while (*p++ >= 128);
33
42.3M
  if (n)
34
42.3M
    *n = (unsigned)(p - orig_p);
35
42.3M
  return Value;
36
42.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.1M
{
26
11.1M
  const uint8_t *orig_p = p;
27
11.1M
  uint64_t Value = 0;
28
11.1M
  unsigned Shift = 0;
29
12.2M
  do {
30
12.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.2M
    Shift += 7;
32
12.2M
  } while (*p++ >= 128);
33
11.1M
  if (n)
34
11.1M
    *n = (unsigned)(p - orig_p);
35
11.1M
  return Value;
36
11.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.37M
{
26
8.37M
  const uint8_t *orig_p = p;
27
8.37M
  uint64_t Value = 0;
28
8.37M
  unsigned Shift = 0;
29
8.71M
  do {
30
8.71M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.71M
    Shift += 7;
32
8.71M
  } while (*p++ >= 128);
33
8.37M
  if (n)
34
8.37M
    *n = (unsigned)(p - orig_p);
35
8.37M
  return Value;
36
8.37M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.43M
{
26
8.43M
  const uint8_t *orig_p = p;
27
8.43M
  uint64_t Value = 0;
28
8.43M
  unsigned Shift = 0;
29
8.76M
  do {
30
8.76M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.76M
    Shift += 7;
32
8.76M
  } while (*p++ >= 128);
33
8.43M
  if (n)
34
8.43M
    *n = (unsigned)(p - orig_p);
35
8.43M
  return Value;
36
8.43M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.07M
{
26
3.07M
  const uint8_t *orig_p = p;
27
3.07M
  uint64_t Value = 0;
28
3.07M
  unsigned Shift = 0;
29
3.15M
  do {
30
3.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.15M
    Shift += 7;
32
3.15M
  } while (*p++ >= 128);
33
3.07M
  if (n)
34
3.07M
    *n = (unsigned)(p - orig_p);
35
3.07M
  return Value;
36
3.07M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
13.2M
{
26
13.2M
  const uint8_t *orig_p = p;
27
13.2M
  uint64_t Value = 0;
28
13.2M
  unsigned Shift = 0;
29
18.3M
  do {
30
18.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.3M
    Shift += 7;
32
18.3M
  } while (*p++ >= 128);
33
13.2M
  if (n)
34
13.2M
    *n = (unsigned)(p - orig_p);
35
13.2M
  return Value;
36
13.2M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.38M
{
26
1.38M
  const uint8_t *orig_p = p;
27
1.38M
  uint64_t Value = 0;
28
1.38M
  unsigned Shift = 0;
29
1.53M
  do {
30
1.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.53M
    Shift += 7;
32
1.53M
  } while (*p++ >= 128);
33
1.38M
  if (n)
34
1.38M
    *n = (unsigned)(p - orig_p);
35
1.38M
  return Value;
36
1.38M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.56M
{
26
1.56M
  const uint8_t *orig_p = p;
27
1.56M
  uint64_t Value = 0;
28
1.56M
  unsigned Shift = 0;
29
1.60M
  do {
30
1.60M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.60M
    Shift += 7;
32
1.60M
  } while (*p++ >= 128);
33
1.56M
  if (n)
34
1.56M
    *n = (unsigned)(p - orig_p);
35
1.56M
  return Value;
36
1.56M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.51M
{
26
4.51M
  const uint8_t *orig_p = p;
27
4.51M
  uint64_t Value = 0;
28
4.51M
  unsigned Shift = 0;
29
4.70M
  do {
30
4.70M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.70M
    Shift += 7;
32
4.70M
  } while (*p++ >= 128);
33
4.51M
  if (n)
34
4.51M
    *n = (unsigned)(p - orig_p);
35
4.51M
  return Value;
36
4.51M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H