Coverage Report

Created: 2026-01-17 06:58

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
52.7M
{
26
52.7M
  const uint8_t *orig_p = p;
27
52.7M
  uint64_t Value = 0;
28
52.7M
  unsigned Shift = 0;
29
58.9M
  do {
30
58.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
58.9M
    Shift += 7;
32
58.9M
  } while (*p++ >= 128);
33
52.7M
  if (n)
34
52.7M
    *n = (unsigned)(p - orig_p);
35
52.7M
  return Value;
36
52.7M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.7M
{
26
19.7M
  const uint8_t *orig_p = p;
27
19.7M
  uint64_t Value = 0;
28
19.7M
  unsigned Shift = 0;
29
21.8M
  do {
30
21.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.8M
    Shift += 7;
32
21.8M
  } while (*p++ >= 128);
33
19.7M
  if (n)
34
19.7M
    *n = (unsigned)(p - orig_p);
35
19.7M
  return Value;
36
19.7M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.83M
{
26
8.83M
  const uint8_t *orig_p = p;
27
8.83M
  uint64_t Value = 0;
28
8.83M
  unsigned Shift = 0;
29
9.67M
  do {
30
9.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.67M
    Shift += 7;
32
9.67M
  } while (*p++ >= 128);
33
8.83M
  if (n)
34
8.83M
    *n = (unsigned)(p - orig_p);
35
8.83M
  return Value;
36
8.83M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.73M
{
26
3.73M
  const uint8_t *orig_p = p;
27
3.73M
  uint64_t Value = 0;
28
3.73M
  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.73M
  if (n)
34
3.73M
    *n = (unsigned)(p - orig_p);
35
3.73M
  return Value;
36
3.73M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.43M
{
26
6.43M
  const uint8_t *orig_p = p;
27
6.43M
  uint64_t Value = 0;
28
6.43M
  unsigned Shift = 0;
29
6.68M
  do {
30
6.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.68M
    Shift += 7;
32
6.68M
  } while (*p++ >= 128);
33
6.43M
  if (n)
34
6.43M
    *n = (unsigned)(p - orig_p);
35
6.43M
  return Value;
36
6.43M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.10M
{
26
2.10M
  const uint8_t *orig_p = p;
27
2.10M
  uint64_t Value = 0;
28
2.10M
  unsigned Shift = 0;
29
2.16M
  do {
30
2.16M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.16M
    Shift += 7;
32
2.16M
  } while (*p++ >= 128);
33
2.10M
  if (n)
34
2.10M
    *n = (unsigned)(p - orig_p);
35
2.10M
  return Value;
36
2.10M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.74M
{
26
6.74M
  const uint8_t *orig_p = p;
27
6.74M
  uint64_t Value = 0;
28
6.74M
  unsigned Shift = 0;
29
9.35M
  do {
30
9.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.35M
    Shift += 7;
32
9.35M
  } while (*p++ >= 128);
33
6.74M
  if (n)
34
6.74M
    *n = (unsigned)(p - orig_p);
35
6.74M
  return Value;
36
6.74M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
779k
{
26
779k
  const uint8_t *orig_p = p;
27
779k
  uint64_t Value = 0;
28
779k
  unsigned Shift = 0;
29
871k
  do {
30
871k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
871k
    Shift += 7;
32
871k
  } while (*p++ >= 128);
33
779k
  if (n)
34
779k
    *n = (unsigned)(p - orig_p);
35
779k
  return Value;
36
779k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.09M
{
26
1.09M
  const uint8_t *orig_p = p;
27
1.09M
  uint64_t Value = 0;
28
1.09M
  unsigned Shift = 0;
29
1.11M
  do {
30
1.11M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.11M
    Shift += 7;
32
1.11M
  } while (*p++ >= 128);
33
1.09M
  if (n)
34
1.09M
    *n = (unsigned)(p - orig_p);
35
1.09M
  return Value;
36
1.09M
}
RISCVDisassembler.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.40M
  do {
30
3.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.40M
    Shift += 7;
32
3.40M
  } while (*p++ >= 128);
33
3.26M
  if (n)
34
3.26M
    *n = (unsigned)(p - orig_p);
35
3.26M
  return Value;
36
3.26M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H