Coverage Report

Created: 2025-08-26 06:30

/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.4M
{
26
48.4M
  const uint8_t *orig_p = p;
27
48.4M
  uint64_t Value = 0;
28
48.4M
  unsigned Shift = 0;
29
54.1M
  do {
30
54.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.1M
    Shift += 7;
32
54.1M
  } while (*p++ >= 128);
33
48.4M
  if (n)
34
48.4M
    *n = (unsigned)(p - orig_p);
35
48.4M
  return Value;
36
48.4M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
18.9M
{
26
18.9M
  const uint8_t *orig_p = p;
27
18.9M
  uint64_t Value = 0;
28
18.9M
  unsigned Shift = 0;
29
20.9M
  do {
30
20.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.9M
    Shift += 7;
32
20.9M
  } while (*p++ >= 128);
33
18.9M
  if (n)
34
18.9M
    *n = (unsigned)(p - orig_p);
35
18.9M
  return Value;
36
18.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.81M
{
26
8.81M
  const uint8_t *orig_p = p;
27
8.81M
  uint64_t Value = 0;
28
8.81M
  unsigned Shift = 0;
29
9.64M
  do {
30
9.64M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.64M
    Shift += 7;
32
9.64M
  } while (*p++ >= 128);
33
8.81M
  if (n)
34
8.81M
    *n = (unsigned)(p - orig_p);
35
8.81M
  return Value;
36
8.81M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.37M
{
26
3.37M
  const uint8_t *orig_p = p;
27
3.37M
  uint64_t Value = 0;
28
3.37M
  unsigned Shift = 0;
29
3.49M
  do {
30
3.49M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.49M
    Shift += 7;
32
3.49M
  } while (*p++ >= 128);
33
3.37M
  if (n)
34
3.37M
    *n = (unsigned)(p - orig_p);
35
3.37M
  return Value;
36
3.37M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.37M
{
26
5.37M
  const uint8_t *orig_p = p;
27
5.37M
  uint64_t Value = 0;
28
5.37M
  unsigned Shift = 0;
29
5.59M
  do {
30
5.59M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.59M
    Shift += 7;
32
5.59M
  } while (*p++ >= 128);
33
5.37M
  if (n)
34
5.37M
    *n = (unsigned)(p - orig_p);
35
5.37M
  return Value;
36
5.37M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.80M
{
26
1.80M
  const uint8_t *orig_p = p;
27
1.80M
  uint64_t Value = 0;
28
1.80M
  unsigned Shift = 0;
29
1.84M
  do {
30
1.84M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.84M
    Shift += 7;
32
1.84M
  } while (*p++ >= 128);
33
1.80M
  if (n)
34
1.80M
    *n = (unsigned)(p - orig_p);
35
1.80M
  return Value;
36
1.80M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.62M
{
26
5.62M
  const uint8_t *orig_p = p;
27
5.62M
  uint64_t Value = 0;
28
5.62M
  unsigned Shift = 0;
29
7.84M
  do {
30
7.84M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.84M
    Shift += 7;
32
7.84M
  } while (*p++ >= 128);
33
5.62M
  if (n)
34
5.62M
    *n = (unsigned)(p - orig_p);
35
5.62M
  return Value;
36
5.62M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
635k
{
26
635k
  const uint8_t *orig_p = p;
27
635k
  uint64_t Value = 0;
28
635k
  unsigned Shift = 0;
29
695k
  do {
30
695k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
695k
    Shift += 7;
32
695k
  } while (*p++ >= 128);
33
635k
  if (n)
34
635k
    *n = (unsigned)(p - orig_p);
35
635k
  return Value;
36
635k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
869k
{
26
869k
  const uint8_t *orig_p = p;
27
869k
  uint64_t Value = 0;
28
869k
  unsigned Shift = 0;
29
888k
  do {
30
888k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
888k
    Shift += 7;
32
888k
  } while (*p++ >= 128);
33
869k
  if (n)
34
869k
    *n = (unsigned)(p - orig_p);
35
869k
  return Value;
36
869k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.03M
{
26
3.03M
  const uint8_t *orig_p = p;
27
3.03M
  uint64_t Value = 0;
28
3.03M
  unsigned Shift = 0;
29
3.16M
  do {
30
3.16M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.16M
    Shift += 7;
32
3.16M
  } while (*p++ >= 128);
33
3.03M
  if (n)
34
3.03M
    *n = (unsigned)(p - orig_p);
35
3.03M
  return Value;
36
3.03M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H