Coverage Report

Created: 2025-08-29 06:29

/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
31.7M
{
26
31.7M
  const uint8_t *orig_p = p;
27
31.7M
  uint64_t Value = 0;
28
31.7M
  unsigned Shift = 0;
29
35.3M
  do {
30
35.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
35.3M
    Shift += 7;
32
35.3M
  } while (*p++ >= 128);
33
31.7M
  if (n)
34
31.7M
    *n = (unsigned)(p - orig_p);
35
31.7M
  return Value;
36
31.7M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
13.1M
{
26
13.1M
  const uint8_t *orig_p = p;
27
13.1M
  uint64_t Value = 0;
28
13.1M
  unsigned Shift = 0;
29
14.5M
  do {
30
14.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.5M
    Shift += 7;
32
14.5M
  } while (*p++ >= 128);
33
13.1M
  if (n)
34
13.1M
    *n = (unsigned)(p - orig_p);
35
13.1M
  return Value;
36
13.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.04M
{
26
5.04M
  const uint8_t *orig_p = p;
27
5.04M
  uint64_t Value = 0;
28
5.04M
  unsigned Shift = 0;
29
5.50M
  do {
30
5.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.50M
    Shift += 7;
32
5.50M
  } while (*p++ >= 128);
33
5.04M
  if (n)
34
5.04M
    *n = (unsigned)(p - orig_p);
35
5.04M
  return Value;
36
5.04M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
2.39M
{
26
2.39M
  const uint8_t *orig_p = p;
27
2.39M
  uint64_t Value = 0;
28
2.39M
  unsigned Shift = 0;
29
2.48M
  do {
30
2.48M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.48M
    Shift += 7;
32
2.48M
  } while (*p++ >= 128);
33
2.39M
  if (n)
34
2.39M
    *n = (unsigned)(p - orig_p);
35
2.39M
  return Value;
36
2.39M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.36M
{
26
3.36M
  const uint8_t *orig_p = p;
27
3.36M
  uint64_t Value = 0;
28
3.36M
  unsigned Shift = 0;
29
3.50M
  do {
30
3.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.50M
    Shift += 7;
32
3.50M
  } while (*p++ >= 128);
33
3.36M
  if (n)
34
3.36M
    *n = (unsigned)(p - orig_p);
35
3.36M
  return Value;
36
3.36M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.26M
{
26
1.26M
  const uint8_t *orig_p = p;
27
1.26M
  uint64_t Value = 0;
28
1.26M
  unsigned Shift = 0;
29
1.29M
  do {
30
1.29M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.29M
    Shift += 7;
32
1.29M
  } while (*p++ >= 128);
33
1.26M
  if (n)
34
1.26M
    *n = (unsigned)(p - orig_p);
35
1.26M
  return Value;
36
1.26M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
3.48M
{
26
3.48M
  const uint8_t *orig_p = p;
27
3.48M
  uint64_t Value = 0;
28
3.48M
  unsigned Shift = 0;
29
4.86M
  do {
30
4.86M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.86M
    Shift += 7;
32
4.86M
  } while (*p++ >= 128);
33
3.48M
  if (n)
34
3.48M
    *n = (unsigned)(p - orig_p);
35
3.48M
  return Value;
36
3.48M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
758k
{
26
758k
  const uint8_t *orig_p = p;
27
758k
  uint64_t Value = 0;
28
758k
  unsigned Shift = 0;
29
848k
  do {
30
848k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
848k
    Shift += 7;
32
848k
  } while (*p++ >= 128);
33
758k
  if (n)
34
758k
    *n = (unsigned)(p - orig_p);
35
758k
  return Value;
36
758k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
617k
{
26
617k
  const uint8_t *orig_p = p;
27
617k
  uint64_t Value = 0;
28
617k
  unsigned Shift = 0;
29
631k
  do {
30
631k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
631k
    Shift += 7;
32
631k
  } while (*p++ >= 128);
33
617k
  if (n)
34
617k
    *n = (unsigned)(p - orig_p);
35
617k
  return Value;
36
617k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.66M
{
26
1.66M
  const uint8_t *orig_p = p;
27
1.66M
  uint64_t Value = 0;
28
1.66M
  unsigned Shift = 0;
29
1.74M
  do {
30
1.74M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.74M
    Shift += 7;
32
1.74M
  } while (*p++ >= 128);
33
1.66M
  if (n)
34
1.66M
    *n = (unsigned)(p - orig_p);
35
1.66M
  return Value;
36
1.66M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H