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
65.9M
{
26
65.9M
  const uint8_t *orig_p = p;
27
65.9M
  uint64_t Value = 0;
28
65.9M
  unsigned Shift = 0;
29
74.1M
  do {
30
74.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
74.1M
    Shift += 7;
32
74.1M
  } while (*p++ >= 128);
33
65.9M
  if (n)
34
65.9M
    *n = (unsigned)(p - orig_p);
35
65.9M
  return Value;
36
65.9M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
30.4M
{
26
30.4M
  const uint8_t *orig_p = p;
27
30.4M
  uint64_t Value = 0;
28
30.4M
  unsigned Shift = 0;
29
33.7M
  do {
30
33.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
33.7M
    Shift += 7;
32
33.7M
  } while (*p++ >= 128);
33
30.4M
  if (n)
34
30.4M
    *n = (unsigned)(p - orig_p);
35
30.4M
  return Value;
36
30.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.88M
{
26
8.88M
  const uint8_t *orig_p = p;
27
8.88M
  uint64_t Value = 0;
28
8.88M
  unsigned Shift = 0;
29
9.75M
  do {
30
9.75M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.75M
    Shift += 7;
32
9.75M
  } while (*p++ >= 128);
33
8.88M
  if (n)
34
8.88M
    *n = (unsigned)(p - orig_p);
35
8.88M
  return Value;
36
8.88M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.03M
{
26
5.03M
  const uint8_t *orig_p = p;
27
5.03M
  uint64_t Value = 0;
28
5.03M
  unsigned Shift = 0;
29
5.24M
  do {
30
5.24M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.24M
    Shift += 7;
32
5.24M
  } while (*p++ >= 128);
33
5.03M
  if (n)
34
5.03M
    *n = (unsigned)(p - orig_p);
35
5.03M
  return Value;
36
5.03M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.60M
{
26
5.60M
  const uint8_t *orig_p = p;
27
5.60M
  uint64_t Value = 0;
28
5.60M
  unsigned Shift = 0;
29
5.82M
  do {
30
5.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.82M
    Shift += 7;
32
5.82M
  } while (*p++ >= 128);
33
5.60M
  if (n)
34
5.60M
    *n = (unsigned)(p - orig_p);
35
5.60M
  return Value;
36
5.60M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.28M
{
26
2.28M
  const uint8_t *orig_p = p;
27
2.28M
  uint64_t Value = 0;
28
2.28M
  unsigned Shift = 0;
29
2.34M
  do {
30
2.34M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.34M
    Shift += 7;
32
2.34M
  } while (*p++ >= 128);
33
2.28M
  if (n)
34
2.28M
    *n = (unsigned)(p - orig_p);
35
2.28M
  return Value;
36
2.28M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.42M
{
26
8.42M
  const uint8_t *orig_p = p;
27
8.42M
  uint64_t Value = 0;
28
8.42M
  unsigned Shift = 0;
29
11.7M
  do {
30
11.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.7M
    Shift += 7;
32
11.7M
  } while (*p++ >= 128);
33
8.42M
  if (n)
34
8.42M
    *n = (unsigned)(p - orig_p);
35
8.42M
  return Value;
36
8.42M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.22M
{
26
1.22M
  const uint8_t *orig_p = p;
27
1.22M
  uint64_t Value = 0;
28
1.22M
  unsigned Shift = 0;
29
1.35M
  do {
30
1.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.35M
    Shift += 7;
32
1.35M
  } while (*p++ >= 128);
33
1.22M
  if (n)
34
1.22M
    *n = (unsigned)(p - orig_p);
35
1.22M
  return Value;
36
1.22M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.18M
{
26
1.18M
  const uint8_t *orig_p = p;
27
1.18M
  uint64_t Value = 0;
28
1.18M
  unsigned Shift = 0;
29
1.21M
  do {
30
1.21M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.21M
    Shift += 7;
32
1.21M
  } while (*p++ >= 128);
33
1.18M
  if (n)
34
1.18M
    *n = (unsigned)(p - orig_p);
35
1.18M
  return Value;
36
1.18M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.77M
{
26
2.77M
  const uint8_t *orig_p = p;
27
2.77M
  uint64_t Value = 0;
28
2.77M
  unsigned Shift = 0;
29
2.90M
  do {
30
2.90M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.90M
    Shift += 7;
32
2.90M
  } while (*p++ >= 128);
33
2.77M
  if (n)
34
2.77M
    *n = (unsigned)(p - orig_p);
35
2.77M
  return Value;
36
2.77M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H