Coverage Report

Created: 2026-03-03 06:15

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
86.1M
{
26
86.1M
  const uint8_t *orig_p = p;
27
86.1M
  uint64_t Value = 0;
28
86.1M
  unsigned Shift = 0;
29
96.8M
  do {
30
96.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
96.8M
    Shift += 7;
32
96.8M
  } while (*p++ >= 128);
33
86.1M
  if (n)
34
86.1M
    *n = (unsigned)(p - orig_p);
35
86.1M
  return Value;
36
86.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
37.4M
{
26
37.4M
  const uint8_t *orig_p = p;
27
37.4M
  uint64_t Value = 0;
28
37.4M
  unsigned Shift = 0;
29
41.4M
  do {
30
41.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
41.4M
    Shift += 7;
32
41.4M
  } while (*p++ >= 128);
33
37.4M
  if (n)
34
37.4M
    *n = (unsigned)(p - orig_p);
35
37.4M
  return Value;
36
37.4M
}
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.3M
  do {
30
14.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.3M
    Shift += 7;
32
14.3M
  } 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
6.85M
{
26
6.85M
  const uint8_t *orig_p = p;
27
6.85M
  uint64_t Value = 0;
28
6.85M
  unsigned Shift = 0;
29
7.11M
  do {
30
7.11M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.11M
    Shift += 7;
32
7.11M
  } while (*p++ >= 128);
33
6.85M
  if (n)
34
6.85M
    *n = (unsigned)(p - orig_p);
35
6.85M
  return Value;
36
6.85M
}
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
3.26M
{
26
3.26M
  const uint8_t *orig_p = p;
27
3.26M
  uint64_t Value = 0;
28
3.26M
  unsigned Shift = 0;
29
3.34M
  do {
30
3.34M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.34M
    Shift += 7;
32
3.34M
  } while (*p++ >= 128);
33
3.26M
  if (n)
34
3.26M
    *n = (unsigned)(p - orig_p);
35
3.26M
  return Value;
36
3.26M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
11.5M
{
26
11.5M
  const uint8_t *orig_p = p;
27
11.5M
  uint64_t Value = 0;
28
11.5M
  unsigned Shift = 0;
29
16.0M
  do {
30
16.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.0M
    Shift += 7;
32
16.0M
  } while (*p++ >= 128);
33
11.5M
  if (n)
34
11.5M
    *n = (unsigned)(p - orig_p);
35
11.5M
  return Value;
36
11.5M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.33M
{
26
1.33M
  const uint8_t *orig_p = p;
27
1.33M
  uint64_t Value = 0;
28
1.33M
  unsigned Shift = 0;
29
1.47M
  do {
30
1.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.47M
    Shift += 7;
32
1.47M
  } while (*p++ >= 128);
33
1.33M
  if (n)
34
1.33M
    *n = (unsigned)(p - orig_p);
35
1.33M
  return Value;
36
1.33M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.48M
{
26
1.48M
  const uint8_t *orig_p = p;
27
1.48M
  uint64_t Value = 0;
28
1.48M
  unsigned Shift = 0;
29
1.52M
  do {
30
1.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.52M
    Shift += 7;
32
1.52M
  } while (*p++ >= 128);
33
1.48M
  if (n)
34
1.48M
    *n = (unsigned)(p - orig_p);
35
1.48M
  return Value;
36
1.48M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.70M
{
26
3.70M
  const uint8_t *orig_p = p;
27
3.70M
  uint64_t Value = 0;
28
3.70M
  unsigned Shift = 0;
29
3.86M
  do {
30
3.86M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.86M
    Shift += 7;
32
3.86M
  } while (*p++ >= 128);
33
3.70M
  if (n)
34
3.70M
    *n = (unsigned)(p - orig_p);
35
3.70M
  return Value;
36
3.70M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H