Coverage Report

Created: 2026-01-12 07:13

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.5M
{
26
52.5M
  const uint8_t *orig_p = p;
27
52.5M
  uint64_t Value = 0;
28
52.5M
  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.5M
  if (n)
34
52.5M
    *n = (unsigned)(p - orig_p);
35
52.5M
  return Value;
36
52.5M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.4M
{
26
19.4M
  const uint8_t *orig_p = p;
27
19.4M
  uint64_t Value = 0;
28
19.4M
  unsigned Shift = 0;
29
21.5M
  do {
30
21.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.5M
    Shift += 7;
32
21.5M
  } while (*p++ >= 128);
33
19.4M
  if (n)
34
19.4M
    *n = (unsigned)(p - orig_p);
35
19.4M
  return Value;
36
19.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.17M
{
26
9.17M
  const uint8_t *orig_p = p;
27
9.17M
  uint64_t Value = 0;
28
9.17M
  unsigned Shift = 0;
29
10.0M
  do {
30
10.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.0M
    Shift += 7;
32
10.0M
  } while (*p++ >= 128);
33
9.17M
  if (n)
34
9.17M
    *n = (unsigned)(p - orig_p);
35
9.17M
  return Value;
36
9.17M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.55M
{
26
3.55M
  const uint8_t *orig_p = p;
27
3.55M
  uint64_t Value = 0;
28
3.55M
  unsigned Shift = 0;
29
3.68M
  do {
30
3.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.68M
    Shift += 7;
32
3.68M
  } while (*p++ >= 128);
33
3.55M
  if (n)
34
3.55M
    *n = (unsigned)(p - orig_p);
35
3.55M
  return Value;
36
3.55M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.12M
{
26
6.12M
  const uint8_t *orig_p = p;
27
6.12M
  uint64_t Value = 0;
28
6.12M
  unsigned Shift = 0;
29
6.36M
  do {
30
6.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.36M
    Shift += 7;
32
6.36M
  } while (*p++ >= 128);
33
6.12M
  if (n)
34
6.12M
    *n = (unsigned)(p - orig_p);
35
6.12M
  return Value;
36
6.12M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.00M
{
26
2.00M
  const uint8_t *orig_p = p;
27
2.00M
  uint64_t Value = 0;
28
2.00M
  unsigned Shift = 0;
29
2.05M
  do {
30
2.05M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.05M
    Shift += 7;
32
2.05M
  } while (*p++ >= 128);
33
2.00M
  if (n)
34
2.00M
    *n = (unsigned)(p - orig_p);
35
2.00M
  return Value;
36
2.00M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.09M
{
26
7.09M
  const uint8_t *orig_p = p;
27
7.09M
  uint64_t Value = 0;
28
7.09M
  unsigned Shift = 0;
29
9.84M
  do {
30
9.84M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.84M
    Shift += 7;
32
9.84M
  } while (*p++ >= 128);
33
7.09M
  if (n)
34
7.09M
    *n = (unsigned)(p - orig_p);
35
7.09M
  return Value;
36
7.09M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
842k
{
26
842k
  const uint8_t *orig_p = p;
27
842k
  uint64_t Value = 0;
28
842k
  unsigned Shift = 0;
29
929k
  do {
30
929k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
929k
    Shift += 7;
32
929k
  } while (*p++ >= 128);
33
842k
  if (n)
34
842k
    *n = (unsigned)(p - orig_p);
35
842k
  return Value;
36
842k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.06M
{
26
1.06M
  const uint8_t *orig_p = p;
27
1.06M
  uint64_t Value = 0;
28
1.06M
  unsigned Shift = 0;
29
1.08M
  do {
30
1.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.08M
    Shift += 7;
32
1.08M
  } while (*p++ >= 128);
33
1.06M
  if (n)
34
1.06M
    *n = (unsigned)(p - orig_p);
35
1.06M
  return Value;
36
1.06M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.27M
{
26
3.27M
  const uint8_t *orig_p = p;
27
3.27M
  uint64_t Value = 0;
28
3.27M
  unsigned Shift = 0;
29
3.41M
  do {
30
3.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.41M
    Shift += 7;
32
3.41M
  } while (*p++ >= 128);
33
3.27M
  if (n)
34
3.27M
    *n = (unsigned)(p - orig_p);
35
3.27M
  return Value;
36
3.27M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H