Coverage Report

Created: 2025-07-01 07:03

/src/capstonenext/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
69.8M
{
26
69.8M
  const uint8_t *orig_p = p;
27
69.8M
  uint64_t Value = 0;
28
69.8M
  unsigned Shift = 0;
29
78.6M
  do {
30
78.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
78.6M
    Shift += 7;
32
78.6M
  } while (*p++ >= 128);
33
69.8M
  if (n)
34
69.8M
    *n = (unsigned)(p - orig_p);
35
69.8M
  return Value;
36
69.8M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.34M
{
26
1.34M
  const uint8_t *orig_p = p;
27
1.34M
  uint64_t Value = 0;
28
1.34M
  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.34M
  if (n)
34
1.34M
    *n = (unsigned)(p - orig_p);
35
1.34M
  return Value;
36
1.34M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.39M
{
26
1.39M
  const uint8_t *orig_p = p;
27
1.39M
  uint64_t Value = 0;
28
1.39M
  unsigned Shift = 0;
29
1.41M
  do {
30
1.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.41M
    Shift += 7;
32
1.41M
  } while (*p++ >= 128);
33
1.39M
  if (n)
34
1.39M
    *n = (unsigned)(p - orig_p);
35
1.39M
  return Value;
36
1.39M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.40M
{
26
2.40M
  const uint8_t *orig_p = p;
27
2.40M
  uint64_t Value = 0;
28
2.40M
  unsigned Shift = 0;
29
2.50M
  do {
30
2.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.50M
    Shift += 7;
32
2.50M
  } while (*p++ >= 128);
33
2.40M
  if (n)
34
2.40M
    *n = (unsigned)(p - orig_p);
35
2.40M
  return Value;
36
2.40M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
33.5M
{
26
33.5M
  const uint8_t *orig_p = p;
27
33.5M
  uint64_t Value = 0;
28
33.5M
  unsigned Shift = 0;
29
37.2M
  do {
30
37.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
37.2M
    Shift += 7;
32
37.2M
  } while (*p++ >= 128);
33
33.5M
  if (n)
34
33.5M
    *n = (unsigned)(p - orig_p);
35
33.5M
  return Value;
36
33.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.46M
{
26
8.46M
  const uint8_t *orig_p = p;
27
8.46M
  uint64_t Value = 0;
28
8.46M
  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
8.46M
  if (n)
34
8.46M
    *n = (unsigned)(p - orig_p);
35
8.46M
  return Value;
36
8.46M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.18M
{
26
5.18M
  const uint8_t *orig_p = p;
27
5.18M
  uint64_t Value = 0;
28
5.18M
  unsigned Shift = 0;
29
5.39M
  do {
30
5.39M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.39M
    Shift += 7;
32
5.39M
  } while (*p++ >= 128);
33
5.18M
  if (n)
34
5.18M
    *n = (unsigned)(p - orig_p);
35
5.18M
  return Value;
36
5.18M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.97M
{
26
5.97M
  const uint8_t *orig_p = p;
27
5.97M
  uint64_t Value = 0;
28
5.97M
  unsigned Shift = 0;
29
6.22M
  do {
30
6.22M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.22M
    Shift += 7;
32
6.22M
  } while (*p++ >= 128);
33
5.97M
  if (n)
34
5.97M
    *n = (unsigned)(p - orig_p);
35
5.97M
  return Value;
36
5.97M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.96M
{
26
1.96M
  const uint8_t *orig_p = p;
27
1.96M
  uint64_t Value = 0;
28
1.96M
  unsigned Shift = 0;
29
2.01M
  do {
30
2.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.01M
    Shift += 7;
32
2.01M
  } while (*p++ >= 128);
33
1.96M
  if (n)
34
1.96M
    *n = (unsigned)(p - orig_p);
35
1.96M
  return Value;
36
1.96M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.24M
{
26
8.24M
  const uint8_t *orig_p = p;
27
8.24M
  uint64_t Value = 0;
28
8.24M
  unsigned Shift = 0;
29
11.2M
  do {
30
11.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.2M
    Shift += 7;
32
11.2M
  } while (*p++ >= 128);
33
8.24M
  if (n)
34
8.24M
    *n = (unsigned)(p - orig_p);
35
8.24M
  return Value;
36
8.24M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.35M
{
26
1.35M
  const uint8_t *orig_p = p;
27
1.35M
  uint64_t Value = 0;
28
1.35M
  unsigned Shift = 0;
29
1.61M
  do {
30
1.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.61M
    Shift += 7;
32
1.61M
  } while (*p++ >= 128);
33
1.35M
  if (n)
34
1.35M
    *n = (unsigned)(p - orig_p);
35
1.35M
  return Value;
36
1.35M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H