Coverage Report

Created: 2026-01-10 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
98.9M
{
26
98.9M
  const uint8_t *orig_p = p;
27
98.9M
  uint64_t Value = 0;
28
98.9M
  unsigned Shift = 0;
29
111M
  do {
30
111M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
111M
    Shift += 7;
32
111M
  } while (*p++ >= 128);
33
98.9M
  if (n)
34
98.9M
    *n = (unsigned)(p - orig_p);
35
98.9M
  return Value;
36
98.9M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
43.8M
{
26
43.8M
  const uint8_t *orig_p = p;
27
43.8M
  uint64_t Value = 0;
28
43.8M
  unsigned Shift = 0;
29
48.3M
  do {
30
48.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
48.3M
    Shift += 7;
32
48.3M
  } while (*p++ >= 128);
33
43.8M
  if (n)
34
43.8M
    *n = (unsigned)(p - orig_p);
35
43.8M
  return Value;
36
43.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
13.9M
{
26
13.9M
  const uint8_t *orig_p = p;
27
13.9M
  uint64_t Value = 0;
28
13.9M
  unsigned Shift = 0;
29
15.3M
  do {
30
15.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.3M
    Shift += 7;
32
15.3M
  } while (*p++ >= 128);
33
13.9M
  if (n)
34
13.9M
    *n = (unsigned)(p - orig_p);
35
13.9M
  return Value;
36
13.9M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.22M
{
26
7.22M
  const uint8_t *orig_p = p;
27
7.22M
  uint64_t Value = 0;
28
7.22M
  unsigned Shift = 0;
29
7.51M
  do {
30
7.51M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.51M
    Shift += 7;
32
7.51M
  } while (*p++ >= 128);
33
7.22M
  if (n)
34
7.22M
    *n = (unsigned)(p - orig_p);
35
7.22M
  return Value;
36
7.22M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.49M
{
26
8.49M
  const uint8_t *orig_p = p;
27
8.49M
  uint64_t Value = 0;
28
8.49M
  unsigned Shift = 0;
29
8.81M
  do {
30
8.81M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.81M
    Shift += 7;
32
8.81M
  } while (*p++ >= 128);
33
8.49M
  if (n)
34
8.49M
    *n = (unsigned)(p - orig_p);
35
8.49M
  return Value;
36
8.49M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.87M
{
26
2.87M
  const uint8_t *orig_p = p;
27
2.87M
  uint64_t Value = 0;
28
2.87M
  unsigned Shift = 0;
29
2.95M
  do {
30
2.95M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.95M
    Shift += 7;
32
2.95M
  } while (*p++ >= 128);
33
2.87M
  if (n)
34
2.87M
    *n = (unsigned)(p - orig_p);
35
2.87M
  return Value;
36
2.87M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
14.6M
{
26
14.6M
  const uint8_t *orig_p = p;
27
14.6M
  uint64_t Value = 0;
28
14.6M
  unsigned Shift = 0;
29
20.4M
  do {
30
20.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.4M
    Shift += 7;
32
20.4M
  } while (*p++ >= 128);
33
14.6M
  if (n)
34
14.6M
    *n = (unsigned)(p - orig_p);
35
14.6M
  return Value;
36
14.6M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.53M
{
26
1.53M
  const uint8_t *orig_p = p;
27
1.53M
  uint64_t Value = 0;
28
1.53M
  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.53M
  if (n)
34
1.53M
    *n = (unsigned)(p - orig_p);
35
1.53M
  return Value;
36
1.53M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.68M
{
26
1.68M
  const uint8_t *orig_p = p;
27
1.68M
  uint64_t Value = 0;
28
1.68M
  unsigned Shift = 0;
29
1.72M
  do {
30
1.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.72M
    Shift += 7;
32
1.72M
  } while (*p++ >= 128);
33
1.68M
  if (n)
34
1.68M
    *n = (unsigned)(p - orig_p);
35
1.68M
  return Value;
36
1.68M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.65M
{
26
4.65M
  const uint8_t *orig_p = p;
27
4.65M
  uint64_t Value = 0;
28
4.65M
  unsigned Shift = 0;
29
4.85M
  do {
30
4.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.85M
    Shift += 7;
32
4.85M
  } while (*p++ >= 128);
33
4.65M
  if (n)
34
4.65M
    *n = (unsigned)(p - orig_p);
35
4.65M
  return Value;
36
4.65M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H