Coverage Report

Created: 2025-07-11 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
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
49.0M
{
26
49.0M
  const uint8_t *orig_p = p;
27
49.0M
  uint64_t Value = 0;
28
49.0M
  unsigned Shift = 0;
29
54.2M
  do {
30
54.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.2M
    Shift += 7;
32
54.2M
  } while (*p++ >= 128);
33
49.0M
  if (n)
34
49.0M
    *n = (unsigned)(p - orig_p);
35
49.0M
  return Value;
36
49.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
14.4M
{
26
14.4M
  const uint8_t *orig_p = p;
27
14.4M
  uint64_t Value = 0;
28
14.4M
  unsigned Shift = 0;
29
15.8M
  do {
30
15.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.8M
    Shift += 7;
32
15.8M
  } while (*p++ >= 128);
33
14.4M
  if (n)
34
14.4M
    *n = (unsigned)(p - orig_p);
35
14.4M
  return Value;
36
14.4M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.56M
{
26
7.56M
  const uint8_t *orig_p = p;
27
7.56M
  uint64_t Value = 0;
28
7.56M
  unsigned Shift = 0;
29
7.86M
  do {
30
7.86M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.86M
    Shift += 7;
32
7.86M
  } while (*p++ >= 128);
33
7.56M
  if (n)
34
7.56M
    *n = (unsigned)(p - orig_p);
35
7.56M
  return Value;
36
7.56M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
9.05M
{
26
9.05M
  const uint8_t *orig_p = p;
27
9.05M
  uint64_t Value = 0;
28
9.05M
  unsigned Shift = 0;
29
9.40M
  do {
30
9.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.40M
    Shift += 7;
32
9.40M
  } while (*p++ >= 128);
33
9.05M
  if (n)
34
9.05M
    *n = (unsigned)(p - orig_p);
35
9.05M
  return Value;
36
9.05M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.13M
{
26
3.13M
  const uint8_t *orig_p = p;
27
3.13M
  uint64_t Value = 0;
28
3.13M
  unsigned Shift = 0;
29
3.21M
  do {
30
3.21M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.21M
    Shift += 7;
32
3.21M
  } while (*p++ >= 128);
33
3.13M
  if (n)
34
3.13M
    *n = (unsigned)(p - orig_p);
35
3.13M
  return Value;
36
3.13M
}
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.6M
  do {
30
18.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.6M
    Shift += 7;
32
18.6M
  } 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.43M
{
26
1.43M
  const uint8_t *orig_p = p;
27
1.43M
  uint64_t Value = 0;
28
1.43M
  unsigned Shift = 0;
29
1.58M
  do {
30
1.58M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.58M
    Shift += 7;
32
1.58M
  } while (*p++ >= 128);
33
1.43M
  if (n)
34
1.43M
    *n = (unsigned)(p - orig_p);
35
1.43M
  return Value;
36
1.43M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.03M
{
26
2.03M
  const uint8_t *orig_p = p;
27
2.03M
  uint64_t Value = 0;
28
2.03M
  unsigned Shift = 0;
29
2.08M
  do {
30
2.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.08M
    Shift += 7;
32
2.08M
  } while (*p++ >= 128);
33
2.03M
  if (n)
34
2.03M
    *n = (unsigned)(p - orig_p);
35
2.03M
  return Value;
36
2.03M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.89M
{
26
4.89M
  const uint8_t *orig_p = p;
27
4.89M
  uint64_t Value = 0;
28
4.89M
  unsigned Shift = 0;
29
5.10M
  do {
30
5.10M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.10M
    Shift += 7;
32
5.10M
  } while (*p++ >= 128);
33
4.89M
  if (n)
34
4.89M
    *n = (unsigned)(p - orig_p);
35
4.89M
  return Value;
36
4.89M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H