Coverage Report

Created: 2026-04-12 06:30

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
83.6M
{
26
83.6M
  const uint8_t *orig_p = p;
27
83.6M
  uint64_t Value = 0;
28
83.6M
  unsigned Shift = 0;
29
94.3M
  do {
30
94.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
94.3M
    Shift += 7;
32
94.3M
  } while (*p++ >= 128);
33
83.6M
  if (n)
34
83.6M
    *n = (unsigned)(p - orig_p);
35
83.6M
  return Value;
36
83.6M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
37.0M
{
26
37.0M
  const uint8_t *orig_p = p;
27
37.0M
  uint64_t Value = 0;
28
37.0M
  unsigned Shift = 0;
29
40.9M
  do {
30
40.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
40.9M
    Shift += 7;
32
40.9M
  } while (*p++ >= 128);
33
37.0M
  if (n)
34
37.0M
    *n = (unsigned)(p - orig_p);
35
37.0M
  return Value;
36
37.0M
}
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
6.58M
{
26
6.58M
  const uint8_t *orig_p = p;
27
6.58M
  uint64_t Value = 0;
28
6.58M
  unsigned Shift = 0;
29
6.84M
  do {
30
6.84M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.84M
    Shift += 7;
32
6.84M
  } while (*p++ >= 128);
33
6.58M
  if (n)
34
6.58M
    *n = (unsigned)(p - orig_p);
35
6.58M
  return Value;
36
6.58M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
7.38M
{
26
7.38M
  const uint8_t *orig_p = p;
27
7.38M
  uint64_t Value = 0;
28
7.38M
  unsigned Shift = 0;
29
7.68M
  do {
30
7.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.68M
    Shift += 7;
32
7.68M
  } while (*p++ >= 128);
33
7.38M
  if (n)
34
7.38M
    *n = (unsigned)(p - orig_p);
35
7.38M
  return Value;
36
7.38M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.97M
{
26
2.97M
  const uint8_t *orig_p = p;
27
2.97M
  uint64_t Value = 0;
28
2.97M
  unsigned Shift = 0;
29
3.05M
  do {
30
3.05M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.05M
    Shift += 7;
32
3.05M
  } while (*p++ >= 128);
33
2.97M
  if (n)
34
2.97M
    *n = (unsigned)(p - orig_p);
35
2.97M
  return Value;
36
2.97M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
11.8M
{
26
11.8M
  const uint8_t *orig_p = p;
27
11.8M
  uint64_t Value = 0;
28
11.8M
  unsigned Shift = 0;
29
16.5M
  do {
30
16.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.5M
    Shift += 7;
32
16.5M
  } while (*p++ >= 128);
33
11.8M
  if (n)
34
11.8M
    *n = (unsigned)(p - orig_p);
35
11.8M
  return Value;
36
11.8M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.31M
{
26
1.31M
  const uint8_t *orig_p = p;
27
1.31M
  uint64_t Value = 0;
28
1.31M
  unsigned Shift = 0;
29
1.44M
  do {
30
1.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.44M
    Shift += 7;
32
1.44M
  } while (*p++ >= 128);
33
1.31M
  if (n)
34
1.31M
    *n = (unsigned)(p - orig_p);
35
1.31M
  return Value;
36
1.31M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.41M
{
26
1.41M
  const uint8_t *orig_p = p;
27
1.41M
  uint64_t Value = 0;
28
1.41M
  unsigned Shift = 0;
29
1.44M
  do {
30
1.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.44M
    Shift += 7;
32
1.44M
  } while (*p++ >= 128);
33
1.41M
  if (n)
34
1.41M
    *n = (unsigned)(p - orig_p);
35
1.41M
  return Value;
36
1.41M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.87M
{
26
3.87M
  const uint8_t *orig_p = p;
27
3.87M
  uint64_t Value = 0;
28
3.87M
  unsigned Shift = 0;
29
4.04M
  do {
30
4.04M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.04M
    Shift += 7;
32
4.04M
  } while (*p++ >= 128);
33
3.87M
  if (n)
34
3.87M
    *n = (unsigned)(p - orig_p);
35
3.87M
  return Value;
36
3.87M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H