Coverage Report

Created: 2025-08-26 06:30

/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
56.5M
{
26
56.5M
  const uint8_t *orig_p = p;
27
56.5M
  uint64_t Value = 0;
28
56.5M
  unsigned Shift = 0;
29
64.1M
  do {
30
64.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
64.1M
    Shift += 7;
32
64.1M
  } while (*p++ >= 128);
33
56.5M
  if (n)
34
56.5M
    *n = (unsigned)(p - orig_p);
35
56.5M
  return Value;
36
56.5M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
711k
{
26
711k
  const uint8_t *orig_p = p;
27
711k
  uint64_t Value = 0;
28
711k
  unsigned Shift = 0;
29
785k
  do {
30
785k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
785k
    Shift += 7;
32
785k
  } while (*p++ >= 128);
33
711k
  if (n)
34
711k
    *n = (unsigned)(p - orig_p);
35
711k
  return Value;
36
711k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
782k
{
26
782k
  const uint8_t *orig_p = p;
27
782k
  uint64_t Value = 0;
28
782k
  unsigned Shift = 0;
29
799k
  do {
30
799k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
799k
    Shift += 7;
32
799k
  } while (*p++ >= 128);
33
782k
  if (n)
34
782k
    *n = (unsigned)(p - orig_p);
35
782k
  return Value;
36
782k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.83M
{
26
1.83M
  const uint8_t *orig_p = p;
27
1.83M
  uint64_t Value = 0;
28
1.83M
  unsigned Shift = 0;
29
1.91M
  do {
30
1.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.91M
    Shift += 7;
32
1.91M
  } while (*p++ >= 128);
33
1.83M
  if (n)
34
1.83M
    *n = (unsigned)(p - orig_p);
35
1.83M
  return Value;
36
1.83M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
28.1M
{
26
28.1M
  const uint8_t *orig_p = p;
27
28.1M
  uint64_t Value = 0;
28
28.1M
  unsigned Shift = 0;
29
31.1M
  do {
30
31.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
31.1M
    Shift += 7;
32
31.1M
  } while (*p++ >= 128);
33
28.1M
  if (n)
34
28.1M
    *n = (unsigned)(p - orig_p);
35
28.1M
  return Value;
36
28.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.94M
{
26
5.94M
  const uint8_t *orig_p = p;
27
5.94M
  uint64_t Value = 0;
28
5.94M
  unsigned Shift = 0;
29
6.59M
  do {
30
6.59M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.59M
    Shift += 7;
32
6.59M
  } while (*p++ >= 128);
33
5.94M
  if (n)
34
5.94M
    *n = (unsigned)(p - orig_p);
35
5.94M
  return Value;
36
5.94M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.39M
{
26
4.39M
  const uint8_t *orig_p = p;
27
4.39M
  uint64_t Value = 0;
28
4.39M
  unsigned Shift = 0;
29
4.60M
  do {
30
4.60M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.60M
    Shift += 7;
32
4.60M
  } while (*p++ >= 128);
33
4.39M
  if (n)
34
4.39M
    *n = (unsigned)(p - orig_p);
35
4.39M
  return Value;
36
4.39M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.72M
{
26
3.72M
  const uint8_t *orig_p = p;
27
3.72M
  uint64_t Value = 0;
28
3.72M
  unsigned Shift = 0;
29
3.85M
  do {
30
3.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.85M
    Shift += 7;
32
3.85M
  } while (*p++ >= 128);
33
3.72M
  if (n)
34
3.72M
    *n = (unsigned)(p - orig_p);
35
3.72M
  return Value;
36
3.72M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.67M
{
26
1.67M
  const uint8_t *orig_p = p;
27
1.67M
  uint64_t Value = 0;
28
1.67M
  unsigned Shift = 0;
29
1.72M
  do {
30
1.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.72M
    Shift += 7;
32
1.72M
  } while (*p++ >= 128);
33
1.67M
  if (n)
34
1.67M
    *n = (unsigned)(p - orig_p);
35
1.67M
  return Value;
36
1.67M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.25M
{
26
7.25M
  const uint8_t *orig_p = p;
27
7.25M
  uint64_t Value = 0;
28
7.25M
  unsigned Shift = 0;
29
10.1M
  do {
30
10.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.1M
    Shift += 7;
32
10.1M
  } while (*p++ >= 128);
33
7.25M
  if (n)
34
7.25M
    *n = (unsigned)(p - orig_p);
35
7.25M
  return Value;
36
7.25M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.13M
{
26
2.13M
  const uint8_t *orig_p = p;
27
2.13M
  uint64_t Value = 0;
28
2.13M
  unsigned Shift = 0;
29
2.57M
  do {
30
2.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.57M
    Shift += 7;
32
2.57M
  } while (*p++ >= 128);
33
2.13M
  if (n)
34
2.13M
    *n = (unsigned)(p - orig_p);
35
2.13M
  return Value;
36
2.13M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H