Coverage Report

Created: 2025-08-28 06:43

/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
105M
{
26
105M
  const uint8_t *orig_p = p;
27
105M
  uint64_t Value = 0;
28
105M
  unsigned Shift = 0;
29
118M
  do {
30
118M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
118M
    Shift += 7;
32
118M
  } while (*p++ >= 128);
33
105M
  if (n)
34
105M
    *n = (unsigned)(p - orig_p);
35
105M
  return Value;
36
105M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
47.2M
{
26
47.2M
  const uint8_t *orig_p = p;
27
47.2M
  uint64_t Value = 0;
28
47.2M
  unsigned Shift = 0;
29
52.2M
  do {
30
52.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.2M
    Shift += 7;
32
52.2M
  } while (*p++ >= 128);
33
47.2M
  if (n)
34
47.2M
    *n = (unsigned)(p - orig_p);
35
47.2M
  return Value;
36
47.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
15.6M
{
26
15.6M
  const uint8_t *orig_p = p;
27
15.6M
  uint64_t Value = 0;
28
15.6M
  unsigned Shift = 0;
29
17.2M
  do {
30
17.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.2M
    Shift += 7;
32
17.2M
  } while (*p++ >= 128);
33
15.6M
  if (n)
34
15.6M
    *n = (unsigned)(p - orig_p);
35
15.6M
  return Value;
36
15.6M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.81M
{
26
7.81M
  const uint8_t *orig_p = p;
27
7.81M
  uint64_t Value = 0;
28
7.81M
  unsigned Shift = 0;
29
8.15M
  do {
30
8.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.15M
    Shift += 7;
32
8.15M
  } while (*p++ >= 128);
33
7.81M
  if (n)
34
7.81M
    *n = (unsigned)(p - orig_p);
35
7.81M
  return Value;
36
7.81M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
9.51M
{
26
9.51M
  const uint8_t *orig_p = p;
27
9.51M
  uint64_t Value = 0;
28
9.51M
  unsigned Shift = 0;
29
9.87M
  do {
30
9.87M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.87M
    Shift += 7;
32
9.87M
  } while (*p++ >= 128);
33
9.51M
  if (n)
34
9.51M
    *n = (unsigned)(p - orig_p);
35
9.51M
  return Value;
36
9.51M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.54M
{
26
3.54M
  const uint8_t *orig_p = p;
27
3.54M
  uint64_t Value = 0;
28
3.54M
  unsigned Shift = 0;
29
3.63M
  do {
30
3.63M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.63M
    Shift += 7;
32
3.63M
  } while (*p++ >= 128);
33
3.54M
  if (n)
34
3.54M
    *n = (unsigned)(p - orig_p);
35
3.54M
  return Value;
36
3.54M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
13.5M
{
26
13.5M
  const uint8_t *orig_p = p;
27
13.5M
  uint64_t Value = 0;
28
13.5M
  unsigned Shift = 0;
29
18.9M
  do {
30
18.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.9M
    Shift += 7;
32
18.9M
  } while (*p++ >= 128);
33
13.5M
  if (n)
34
13.5M
    *n = (unsigned)(p - orig_p);
35
13.5M
  return Value;
36
13.5M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.31M
{
26
1.31M
  const uint8_t *orig_p = p;
27
1.31M
  uint64_t Value = 0;
28
1.31M
  unsigned Shift = 0;
29
1.43M
  do {
30
1.43M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.43M
    Shift += 7;
32
1.43M
  } while (*p++ >= 128);
33
1.31M
  if (n)
34
1.31M
    *n = (unsigned)(p - orig_p);
35
1.31M
  return Value;
36
1.31M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.65M
{
26
1.65M
  const uint8_t *orig_p = p;
27
1.65M
  uint64_t Value = 0;
28
1.65M
  unsigned Shift = 0;
29
1.69M
  do {
30
1.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.69M
    Shift += 7;
32
1.69M
  } while (*p++ >= 128);
33
1.65M
  if (n)
34
1.65M
    *n = (unsigned)(p - orig_p);
35
1.65M
  return Value;
36
1.65M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.18M
{
26
5.18M
  const uint8_t *orig_p = p;
27
5.18M
  uint64_t Value = 0;
28
5.18M
  unsigned Shift = 0;
29
5.41M
  do {
30
5.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.41M
    Shift += 7;
32
5.41M
  } while (*p++ >= 128);
33
5.18M
  if (n)
34
5.18M
    *n = (unsigned)(p - orig_p);
35
5.18M
  return Value;
36
5.18M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H