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
62.9M
{
26
62.9M
  const uint8_t *orig_p = p;
27
62.9M
  uint64_t Value = 0;
28
62.9M
  unsigned Shift = 0;
29
71.2M
  do {
30
71.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
71.2M
    Shift += 7;
32
71.2M
  } while (*p++ >= 128);
33
62.9M
  if (n)
34
62.9M
    *n = (unsigned)(p - orig_p);
35
62.9M
  return Value;
36
62.9M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
815k
{
26
815k
  const uint8_t *orig_p = p;
27
815k
  uint64_t Value = 0;
28
815k
  unsigned Shift = 0;
29
895k
  do {
30
895k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
895k
    Shift += 7;
32
895k
  } while (*p++ >= 128);
33
815k
  if (n)
34
815k
    *n = (unsigned)(p - orig_p);
35
815k
  return Value;
36
815k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
849k
{
26
849k
  const uint8_t *orig_p = p;
27
849k
  uint64_t Value = 0;
28
849k
  unsigned Shift = 0;
29
868k
  do {
30
868k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
868k
    Shift += 7;
32
868k
  } while (*p++ >= 128);
33
849k
  if (n)
34
849k
    *n = (unsigned)(p - orig_p);
35
849k
  return Value;
36
849k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.26M
{
26
2.26M
  const uint8_t *orig_p = p;
27
2.26M
  uint64_t Value = 0;
28
2.26M
  unsigned Shift = 0;
29
2.36M
  do {
30
2.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.36M
    Shift += 7;
32
2.36M
  } while (*p++ >= 128);
33
2.26M
  if (n)
34
2.26M
    *n = (unsigned)(p - orig_p);
35
2.26M
  return Value;
36
2.26M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
32.1M
{
26
32.1M
  const uint8_t *orig_p = p;
27
32.1M
  uint64_t Value = 0;
28
32.1M
  unsigned Shift = 0;
29
35.5M
  do {
30
35.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
35.5M
    Shift += 7;
32
35.5M
  } while (*p++ >= 128);
33
32.1M
  if (n)
34
32.1M
    *n = (unsigned)(p - orig_p);
35
32.1M
  return Value;
36
32.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.57M
{
26
6.57M
  const uint8_t *orig_p = p;
27
6.57M
  uint64_t Value = 0;
28
6.57M
  unsigned Shift = 0;
29
7.33M
  do {
30
7.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.33M
    Shift += 7;
32
7.33M
  } while (*p++ >= 128);
33
6.57M
  if (n)
34
6.57M
    *n = (unsigned)(p - orig_p);
35
6.57M
  return Value;
36
6.57M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.72M
{
26
4.72M
  const uint8_t *orig_p = p;
27
4.72M
  uint64_t Value = 0;
28
4.72M
  unsigned Shift = 0;
29
4.93M
  do {
30
4.93M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.93M
    Shift += 7;
32
4.93M
  } while (*p++ >= 128);
33
4.72M
  if (n)
34
4.72M
    *n = (unsigned)(p - orig_p);
35
4.72M
  return Value;
36
4.72M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.79M
{
26
3.79M
  const uint8_t *orig_p = p;
27
3.79M
  uint64_t Value = 0;
28
3.79M
  unsigned Shift = 0;
29
3.94M
  do {
30
3.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.94M
    Shift += 7;
32
3.94M
  } while (*p++ >= 128);
33
3.79M
  if (n)
34
3.79M
    *n = (unsigned)(p - orig_p);
35
3.79M
  return Value;
36
3.79M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.51M
{
26
1.51M
  const uint8_t *orig_p = p;
27
1.51M
  uint64_t Value = 0;
28
1.51M
  unsigned Shift = 0;
29
1.56M
  do {
30
1.56M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.56M
    Shift += 7;
32
1.56M
  } while (*p++ >= 128);
33
1.51M
  if (n)
34
1.51M
    *n = (unsigned)(p - orig_p);
35
1.51M
  return Value;
36
1.51M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.16M
{
26
8.16M
  const uint8_t *orig_p = p;
27
8.16M
  uint64_t Value = 0;
28
8.16M
  unsigned Shift = 0;
29
11.3M
  do {
30
11.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.3M
    Shift += 7;
32
11.3M
  } while (*p++ >= 128);
33
8.16M
  if (n)
34
8.16M
    *n = (unsigned)(p - orig_p);
35
8.16M
  return Value;
36
8.16M
}
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