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
48.9M
{
26
48.9M
  const uint8_t *orig_p = p;
27
48.9M
  uint64_t Value = 0;
28
48.9M
  unsigned Shift = 0;
29
54.7M
  do {
30
54.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.7M
    Shift += 7;
32
54.7M
  } while (*p++ >= 128);
33
48.9M
  if (n)
34
48.9M
    *n = (unsigned)(p - orig_p);
35
48.9M
  return Value;
36
48.9M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.1M
{
26
19.1M
  const uint8_t *orig_p = p;
27
19.1M
  uint64_t Value = 0;
28
19.1M
  unsigned Shift = 0;
29
21.1M
  do {
30
21.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.1M
    Shift += 7;
32
21.1M
  } while (*p++ >= 128);
33
19.1M
  if (n)
34
19.1M
    *n = (unsigned)(p - orig_p);
35
19.1M
  return Value;
36
19.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.23M
{
26
8.23M
  const uint8_t *orig_p = p;
27
8.23M
  uint64_t Value = 0;
28
8.23M
  unsigned Shift = 0;
29
9.02M
  do {
30
9.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.02M
    Shift += 7;
32
9.02M
  } while (*p++ >= 128);
33
8.23M
  if (n)
34
8.23M
    *n = (unsigned)(p - orig_p);
35
8.23M
  return Value;
36
8.23M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.24M
{
26
3.24M
  const uint8_t *orig_p = p;
27
3.24M
  uint64_t Value = 0;
28
3.24M
  unsigned Shift = 0;
29
3.36M
  do {
30
3.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.36M
    Shift += 7;
32
3.36M
  } while (*p++ >= 128);
33
3.24M
  if (n)
34
3.24M
    *n = (unsigned)(p - orig_p);
35
3.24M
  return Value;
36
3.24M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.66M
{
26
5.66M
  const uint8_t *orig_p = p;
27
5.66M
  uint64_t Value = 0;
28
5.66M
  unsigned Shift = 0;
29
5.88M
  do {
30
5.88M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.88M
    Shift += 7;
32
5.88M
  } while (*p++ >= 128);
33
5.66M
  if (n)
34
5.66M
    *n = (unsigned)(p - orig_p);
35
5.66M
  return Value;
36
5.66M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.85M
{
26
1.85M
  const uint8_t *orig_p = p;
27
1.85M
  uint64_t Value = 0;
28
1.85M
  unsigned Shift = 0;
29
1.89M
  do {
30
1.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.89M
    Shift += 7;
32
1.89M
  } while (*p++ >= 128);
33
1.85M
  if (n)
34
1.85M
    *n = (unsigned)(p - orig_p);
35
1.85M
  return Value;
36
1.85M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.18M
{
26
6.18M
  const uint8_t *orig_p = p;
27
6.18M
  uint64_t Value = 0;
28
6.18M
  unsigned Shift = 0;
29
8.49M
  do {
30
8.49M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.49M
    Shift += 7;
32
8.49M
  } while (*p++ >= 128);
33
6.18M
  if (n)
34
6.18M
    *n = (unsigned)(p - orig_p);
35
6.18M
  return Value;
36
6.18M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
736k
{
26
736k
  const uint8_t *orig_p = p;
27
736k
  uint64_t Value = 0;
28
736k
  unsigned Shift = 0;
29
816k
  do {
30
816k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
816k
    Shift += 7;
32
816k
  } while (*p++ >= 128);
33
736k
  if (n)
34
736k
    *n = (unsigned)(p - orig_p);
35
736k
  return Value;
36
736k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.06M
{
26
1.06M
  const uint8_t *orig_p = p;
27
1.06M
  uint64_t Value = 0;
28
1.06M
  unsigned Shift = 0;
29
1.08M
  do {
30
1.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.08M
    Shift += 7;
32
1.08M
  } while (*p++ >= 128);
33
1.06M
  if (n)
34
1.06M
    *n = (unsigned)(p - orig_p);
35
1.06M
  return Value;
36
1.06M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.86M
{
26
2.86M
  const uint8_t *orig_p = p;
27
2.86M
  uint64_t Value = 0;
28
2.86M
  unsigned Shift = 0;
29
2.99M
  do {
30
2.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.99M
    Shift += 7;
32
2.99M
  } while (*p++ >= 128);
33
2.86M
  if (n)
34
2.86M
    *n = (unsigned)(p - orig_p);
35
2.86M
  return Value;
36
2.86M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H