Coverage Report

Created: 2025-07-18 06:43

/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
107M
{
26
107M
  const uint8_t *orig_p = p;
27
107M
  uint64_t Value = 0;
28
107M
  unsigned Shift = 0;
29
121M
  do {
30
121M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
121M
    Shift += 7;
32
121M
  } while (*p++ >= 128);
33
107M
  if (n)
34
107M
    *n = (unsigned)(p - orig_p);
35
107M
  return Value;
36
107M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.73M
{
26
1.73M
  const uint8_t *orig_p = p;
27
1.73M
  uint64_t Value = 0;
28
1.73M
  unsigned Shift = 0;
29
1.90M
  do {
30
1.90M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.90M
    Shift += 7;
32
1.90M
  } while (*p++ >= 128);
33
1.73M
  if (n)
34
1.73M
    *n = (unsigned)(p - orig_p);
35
1.73M
  return Value;
36
1.73M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.78M
{
26
1.78M
  const uint8_t *orig_p = p;
27
1.78M
  uint64_t Value = 0;
28
1.78M
  unsigned Shift = 0;
29
1.83M
  do {
30
1.83M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.83M
    Shift += 7;
32
1.83M
  } while (*p++ >= 128);
33
1.78M
  if (n)
34
1.78M
    *n = (unsigned)(p - orig_p);
35
1.78M
  return Value;
36
1.78M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.37M
{
26
4.37M
  const uint8_t *orig_p = p;
27
4.37M
  uint64_t Value = 0;
28
4.37M
  unsigned Shift = 0;
29
4.56M
  do {
30
4.56M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.56M
    Shift += 7;
32
4.56M
  } while (*p++ >= 128);
33
4.37M
  if (n)
34
4.37M
    *n = (unsigned)(p - orig_p);
35
4.37M
  return Value;
36
4.37M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
51.2M
{
26
51.2M
  const uint8_t *orig_p = p;
27
51.2M
  uint64_t Value = 0;
28
51.2M
  unsigned Shift = 0;
29
56.8M
  do {
30
56.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
56.8M
    Shift += 7;
32
56.8M
  } while (*p++ >= 128);
33
51.2M
  if (n)
34
51.2M
    *n = (unsigned)(p - orig_p);
35
51.2M
  return Value;
36
51.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
13.9M
{
26
13.9M
  const uint8_t *orig_p = p;
27
13.9M
  uint64_t Value = 0;
28
13.9M
  unsigned Shift = 0;
29
15.4M
  do {
30
15.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.4M
    Shift += 7;
32
15.4M
  } while (*p++ >= 128);
33
13.9M
  if (n)
34
13.9M
    *n = (unsigned)(p - orig_p);
35
13.9M
  return Value;
36
13.9M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.64M
{
26
7.64M
  const uint8_t *orig_p = p;
27
7.64M
  uint64_t Value = 0;
28
7.64M
  unsigned Shift = 0;
29
7.96M
  do {
30
7.96M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.96M
    Shift += 7;
32
7.96M
  } while (*p++ >= 128);
33
7.64M
  if (n)
34
7.64M
    *n = (unsigned)(p - orig_p);
35
7.64M
  return Value;
36
7.64M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.96M
{
26
8.96M
  const uint8_t *orig_p = p;
27
8.96M
  uint64_t Value = 0;
28
8.96M
  unsigned Shift = 0;
29
9.31M
  do {
30
9.31M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.31M
    Shift += 7;
32
9.31M
  } while (*p++ >= 128);
33
8.96M
  if (n)
34
8.96M
    *n = (unsigned)(p - orig_p);
35
8.96M
  return Value;
36
8.96M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.19M
{
26
3.19M
  const uint8_t *orig_p = p;
27
3.19M
  uint64_t Value = 0;
28
3.19M
  unsigned Shift = 0;
29
3.27M
  do {
30
3.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.27M
    Shift += 7;
32
3.27M
  } while (*p++ >= 128);
33
3.19M
  if (n)
34
3.19M
    *n = (unsigned)(p - orig_p);
35
3.19M
  return Value;
36
3.19M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.9M
{
26
12.9M
  const uint8_t *orig_p = p;
27
12.9M
  uint64_t Value = 0;
28
12.9M
  unsigned Shift = 0;
29
17.9M
  do {
30
17.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.9M
    Shift += 7;
32
17.9M
  } while (*p++ >= 128);
33
12.9M
  if (n)
34
12.9M
    *n = (unsigned)(p - orig_p);
35
12.9M
  return Value;
36
12.9M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.05M
{
26
2.05M
  const uint8_t *orig_p = p;
27
2.05M
  uint64_t Value = 0;
28
2.05M
  unsigned Shift = 0;
29
2.42M
  do {
30
2.42M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.42M
    Shift += 7;
32
2.42M
  } while (*p++ >= 128);
33
2.05M
  if (n)
34
2.05M
    *n = (unsigned)(p - orig_p);
35
2.05M
  return Value;
36
2.05M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H