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
102M
{
26
102M
  const uint8_t *orig_p = p;
27
102M
  uint64_t Value = 0;
28
102M
  unsigned Shift = 0;
29
115M
  do {
30
115M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
115M
    Shift += 7;
32
115M
  } while (*p++ >= 128);
33
102M
  if (n)
34
102M
    *n = (unsigned)(p - orig_p);
35
102M
  return Value;
36
102M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
47.0M
{
26
47.0M
  const uint8_t *orig_p = p;
27
47.0M
  uint64_t Value = 0;
28
47.0M
  unsigned Shift = 0;
29
52.1M
  do {
30
52.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.1M
    Shift += 7;
32
52.1M
  } while (*p++ >= 128);
33
47.0M
  if (n)
34
47.0M
    *n = (unsigned)(p - orig_p);
35
47.0M
  return Value;
36
47.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
14.7M
{
26
14.7M
  const uint8_t *orig_p = p;
27
14.7M
  uint64_t Value = 0;
28
14.7M
  unsigned Shift = 0;
29
16.2M
  do {
30
16.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.2M
    Shift += 7;
32
16.2M
  } while (*p++ >= 128);
33
14.7M
  if (n)
34
14.7M
    *n = (unsigned)(p - orig_p);
35
14.7M
  return Value;
36
14.7M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.76M
{
26
7.76M
  const uint8_t *orig_p = p;
27
7.76M
  uint64_t Value = 0;
28
7.76M
  unsigned Shift = 0;
29
8.10M
  do {
30
8.10M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.10M
    Shift += 7;
32
8.10M
  } while (*p++ >= 128);
33
7.76M
  if (n)
34
7.76M
    *n = (unsigned)(p - orig_p);
35
7.76M
  return Value;
36
7.76M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
9.10M
{
26
9.10M
  const uint8_t *orig_p = p;
27
9.10M
  uint64_t Value = 0;
28
9.10M
  unsigned Shift = 0;
29
9.44M
  do {
30
9.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.44M
    Shift += 7;
32
9.44M
  } while (*p++ >= 128);
33
9.10M
  if (n)
34
9.10M
    *n = (unsigned)(p - orig_p);
35
9.10M
  return Value;
36
9.10M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.48M
{
26
3.48M
  const uint8_t *orig_p = p;
27
3.48M
  uint64_t Value = 0;
28
3.48M
  unsigned Shift = 0;
29
3.57M
  do {
30
3.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.57M
    Shift += 7;
32
3.57M
  } while (*p++ >= 128);
33
3.48M
  if (n)
34
3.48M
    *n = (unsigned)(p - orig_p);
35
3.48M
  return Value;
36
3.48M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.8M
{
26
12.8M
  const uint8_t *orig_p = p;
27
12.8M
  uint64_t Value = 0;
28
12.8M
  unsigned Shift = 0;
29
17.9M
  do {
30
17.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.9M
    Shift += 7;
32
17.9M
  } while (*p++ >= 128);
33
12.8M
  if (n)
34
12.8M
    *n = (unsigned)(p - orig_p);
35
12.8M
  return Value;
36
12.8M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.34M
{
26
1.34M
  const uint8_t *orig_p = p;
27
1.34M
  uint64_t Value = 0;
28
1.34M
  unsigned Shift = 0;
29
1.48M
  do {
30
1.48M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.48M
    Shift += 7;
32
1.48M
  } while (*p++ >= 128);
33
1.34M
  if (n)
34
1.34M
    *n = (unsigned)(p - orig_p);
35
1.34M
  return Value;
36
1.34M
}
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.68M
  do {
30
1.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.68M
    Shift += 7;
32
1.68M
  } 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
4.87M
{
26
4.87M
  const uint8_t *orig_p = p;
27
4.87M
  uint64_t Value = 0;
28
4.87M
  unsigned Shift = 0;
29
5.08M
  do {
30
5.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.08M
    Shift += 7;
32
5.08M
  } while (*p++ >= 128);
33
4.87M
  if (n)
34
4.87M
    *n = (unsigned)(p - orig_p);
35
4.87M
  return Value;
36
4.87M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H