Coverage Report

Created: 2025-07-09 06:32

/src/capstonev5/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
103M
{
26
103M
  const uint8_t *orig_p = p;
27
103M
  uint64_t Value = 0;
28
103M
  unsigned Shift = 0;
29
116M
  do {
30
116M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
116M
    Shift += 7;
32
116M
  } while (*p++ >= 128);
33
103M
  if (n)
34
103M
    *n = (unsigned)(p - orig_p);
35
103M
  return Value;
36
103M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
48.3M
{
26
48.3M
  const uint8_t *orig_p = p;
27
48.3M
  uint64_t Value = 0;
28
48.3M
  unsigned Shift = 0;
29
53.5M
  do {
30
53.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
53.5M
    Shift += 7;
32
53.5M
  } while (*p++ >= 128);
33
48.3M
  if (n)
34
48.3M
    *n = (unsigned)(p - orig_p);
35
48.3M
  return Value;
36
48.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
14.2M
{
26
14.2M
  const uint8_t *orig_p = p;
27
14.2M
  uint64_t Value = 0;
28
14.2M
  unsigned Shift = 0;
29
15.6M
  do {
30
15.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.6M
    Shift += 7;
32
15.6M
  } while (*p++ >= 128);
33
14.2M
  if (n)
34
14.2M
    *n = (unsigned)(p - orig_p);
35
14.2M
  return Value;
36
14.2M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.51M
{
26
7.51M
  const uint8_t *orig_p = p;
27
7.51M
  uint64_t Value = 0;
28
7.51M
  unsigned Shift = 0;
29
7.81M
  do {
30
7.81M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.81M
    Shift += 7;
32
7.81M
  } while (*p++ >= 128);
33
7.51M
  if (n)
34
7.51M
    *n = (unsigned)(p - orig_p);
35
7.51M
  return Value;
36
7.51M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.93M
{
26
8.93M
  const uint8_t *orig_p = p;
27
8.93M
  uint64_t Value = 0;
28
8.93M
  unsigned Shift = 0;
29
9.27M
  do {
30
9.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.27M
    Shift += 7;
32
9.27M
  } while (*p++ >= 128);
33
8.93M
  if (n)
34
8.93M
    *n = (unsigned)(p - orig_p);
35
8.93M
  return Value;
36
8.93M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.03M
{
26
3.03M
  const uint8_t *orig_p = p;
27
3.03M
  uint64_t Value = 0;
28
3.03M
  unsigned Shift = 0;
29
3.11M
  do {
30
3.11M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.11M
    Shift += 7;
32
3.11M
  } while (*p++ >= 128);
33
3.03M
  if (n)
34
3.03M
    *n = (unsigned)(p - orig_p);
35
3.03M
  return Value;
36
3.03M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
13.2M
{
26
13.2M
  const uint8_t *orig_p = p;
27
13.2M
  uint64_t Value = 0;
28
13.2M
  unsigned Shift = 0;
29
18.1M
  do {
30
18.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.1M
    Shift += 7;
32
18.1M
  } while (*p++ >= 128);
33
13.2M
  if (n)
34
13.2M
    *n = (unsigned)(p - orig_p);
35
13.2M
  return Value;
36
13.2M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.44M
{
26
1.44M
  const uint8_t *orig_p = p;
27
1.44M
  uint64_t Value = 0;
28
1.44M
  unsigned Shift = 0;
29
1.59M
  do {
30
1.59M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.59M
    Shift += 7;
32
1.59M
  } while (*p++ >= 128);
33
1.44M
  if (n)
34
1.44M
    *n = (unsigned)(p - orig_p);
35
1.44M
  return Value;
36
1.44M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.99M
{
26
1.99M
  const uint8_t *orig_p = p;
27
1.99M
  uint64_t Value = 0;
28
1.99M
  unsigned Shift = 0;
29
2.03M
  do {
30
2.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.03M
    Shift += 7;
32
2.03M
  } while (*p++ >= 128);
33
1.99M
  if (n)
34
1.99M
    *n = (unsigned)(p - orig_p);
35
1.99M
  return Value;
36
1.99M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.76M
{
26
4.76M
  const uint8_t *orig_p = p;
27
4.76M
  uint64_t Value = 0;
28
4.76M
  unsigned Shift = 0;
29
4.97M
  do {
30
4.97M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.97M
    Shift += 7;
32
4.97M
  } while (*p++ >= 128);
33
4.76M
  if (n)
34
4.76M
    *n = (unsigned)(p - orig_p);
35
4.76M
  return Value;
36
4.76M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H