Coverage Report

Created: 2025-07-04 06:11

/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
95.4M
{
26
95.4M
  const uint8_t *orig_p = p;
27
95.4M
  uint64_t Value = 0;
28
95.4M
  unsigned Shift = 0;
29
107M
  do {
30
107M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
107M
    Shift += 7;
32
107M
  } while (*p++ >= 128);
33
95.4M
  if (n)
34
95.4M
    *n = (unsigned)(p - orig_p);
35
95.4M
  return Value;
36
95.4M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.52M
{
26
1.52M
  const uint8_t *orig_p = p;
27
1.52M
  uint64_t Value = 0;
28
1.52M
  unsigned Shift = 0;
29
1.67M
  do {
30
1.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.67M
    Shift += 7;
32
1.67M
  } while (*p++ >= 128);
33
1.52M
  if (n)
34
1.52M
    *n = (unsigned)(p - orig_p);
35
1.52M
  return Value;
36
1.52M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.89M
{
26
1.89M
  const uint8_t *orig_p = p;
27
1.89M
  uint64_t Value = 0;
28
1.89M
  unsigned Shift = 0;
29
1.93M
  do {
30
1.93M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.93M
    Shift += 7;
32
1.93M
  } while (*p++ >= 128);
33
1.89M
  if (n)
34
1.89M
    *n = (unsigned)(p - orig_p);
35
1.89M
  return Value;
36
1.89M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.89M
{
26
3.89M
  const uint8_t *orig_p = p;
27
3.89M
  uint64_t Value = 0;
28
3.89M
  unsigned Shift = 0;
29
4.06M
  do {
30
4.06M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.06M
    Shift += 7;
32
4.06M
  } while (*p++ >= 128);
33
3.89M
  if (n)
34
3.89M
    *n = (unsigned)(p - orig_p);
35
3.89M
  return Value;
36
3.89M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
45.0M
{
26
45.0M
  const uint8_t *orig_p = p;
27
45.0M
  uint64_t Value = 0;
28
45.0M
  unsigned Shift = 0;
29
50.0M
  do {
30
50.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
50.0M
    Shift += 7;
32
50.0M
  } while (*p++ >= 128);
33
45.0M
  if (n)
34
45.0M
    *n = (unsigned)(p - orig_p);
35
45.0M
  return Value;
36
45.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
12.1M
{
26
12.1M
  const uint8_t *orig_p = p;
27
12.1M
  uint64_t Value = 0;
28
12.1M
  unsigned Shift = 0;
29
13.3M
  do {
30
13.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.3M
    Shift += 7;
32
13.3M
  } while (*p++ >= 128);
33
12.1M
  if (n)
34
12.1M
    *n = (unsigned)(p - orig_p);
35
12.1M
  return Value;
36
12.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.90M
{
26
6.90M
  const uint8_t *orig_p = p;
27
6.90M
  uint64_t Value = 0;
28
6.90M
  unsigned Shift = 0;
29
7.18M
  do {
30
7.18M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.18M
    Shift += 7;
32
7.18M
  } while (*p++ >= 128);
33
6.90M
  if (n)
34
6.90M
    *n = (unsigned)(p - orig_p);
35
6.90M
  return Value;
36
6.90M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.00M
{
26
8.00M
  const uint8_t *orig_p = p;
27
8.00M
  uint64_t Value = 0;
28
8.00M
  unsigned Shift = 0;
29
8.31M
  do {
30
8.31M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.31M
    Shift += 7;
32
8.31M
  } while (*p++ >= 128);
33
8.00M
  if (n)
34
8.00M
    *n = (unsigned)(p - orig_p);
35
8.00M
  return Value;
36
8.00M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.65M
{
26
2.65M
  const uint8_t *orig_p = p;
27
2.65M
  uint64_t Value = 0;
28
2.65M
  unsigned Shift = 0;
29
2.72M
  do {
30
2.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.72M
    Shift += 7;
32
2.72M
  } while (*p++ >= 128);
33
2.65M
  if (n)
34
2.65M
    *n = (unsigned)(p - orig_p);
35
2.65M
  return Value;
36
2.65M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
11.4M
{
26
11.4M
  const uint8_t *orig_p = p;
27
11.4M
  uint64_t Value = 0;
28
11.4M
  unsigned Shift = 0;
29
15.7M
  do {
30
15.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.7M
    Shift += 7;
32
15.7M
  } while (*p++ >= 128);
33
11.4M
  if (n)
34
11.4M
    *n = (unsigned)(p - orig_p);
35
11.4M
  return Value;
36
11.4M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.92M
{
26
1.92M
  const uint8_t *orig_p = p;
27
1.92M
  uint64_t Value = 0;
28
1.92M
  unsigned Shift = 0;
29
2.29M
  do {
30
2.29M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.29M
    Shift += 7;
32
2.29M
  } while (*p++ >= 128);
33
1.92M
  if (n)
34
1.92M
    *n = (unsigned)(p - orig_p);
35
1.92M
  return Value;
36
1.92M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H