Coverage Report

Created: 2025-07-09 06:32

/src/capstonenext/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
56.4M
{
26
56.4M
  const uint8_t *orig_p = p;
27
56.4M
  uint64_t Value = 0;
28
56.4M
  unsigned Shift = 0;
29
63.8M
  do {
30
63.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
63.8M
    Shift += 7;
32
63.8M
  } while (*p++ >= 128);
33
56.4M
  if (n)
34
56.4M
    *n = (unsigned)(p - orig_p);
35
56.4M
  return Value;
36
56.4M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
710k
{
26
710k
  const uint8_t *orig_p = p;
27
710k
  uint64_t Value = 0;
28
710k
  unsigned Shift = 0;
29
780k
  do {
30
780k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
780k
    Shift += 7;
32
780k
  } while (*p++ >= 128);
33
710k
  if (n)
34
710k
    *n = (unsigned)(p - orig_p);
35
710k
  return Value;
36
710k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
929k
{
26
929k
  const uint8_t *orig_p = p;
27
929k
  uint64_t Value = 0;
28
929k
  unsigned Shift = 0;
29
949k
  do {
30
949k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
949k
    Shift += 7;
32
949k
  } while (*p++ >= 128);
33
929k
  if (n)
34
929k
    *n = (unsigned)(p - orig_p);
35
929k
  return Value;
36
929k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.89M
{
26
1.89M
  const uint8_t *orig_p = p;
27
1.89M
  uint64_t Value = 0;
28
1.89M
  unsigned Shift = 0;
29
1.98M
  do {
30
1.98M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.98M
    Shift += 7;
32
1.98M
  } while (*p++ >= 128);
33
1.89M
  if (n)
34
1.89M
    *n = (unsigned)(p - orig_p);
35
1.89M
  return Value;
36
1.89M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
29.2M
{
26
29.2M
  const uint8_t *orig_p = p;
27
29.2M
  uint64_t Value = 0;
28
29.2M
  unsigned Shift = 0;
29
32.3M
  do {
30
32.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
32.3M
    Shift += 7;
32
32.3M
  } while (*p++ >= 128);
33
29.2M
  if (n)
34
29.2M
    *n = (unsigned)(p - orig_p);
35
29.2M
  return Value;
36
29.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.98M
{
26
5.98M
  const uint8_t *orig_p = p;
27
5.98M
  uint64_t Value = 0;
28
5.98M
  unsigned Shift = 0;
29
6.66M
  do {
30
6.66M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.66M
    Shift += 7;
32
6.66M
  } while (*p++ >= 128);
33
5.98M
  if (n)
34
5.98M
    *n = (unsigned)(p - orig_p);
35
5.98M
  return Value;
36
5.98M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.26M
{
26
4.26M
  const uint8_t *orig_p = p;
27
4.26M
  uint64_t Value = 0;
28
4.26M
  unsigned Shift = 0;
29
4.44M
  do {
30
4.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.44M
    Shift += 7;
32
4.44M
  } while (*p++ >= 128);
33
4.26M
  if (n)
34
4.26M
    *n = (unsigned)(p - orig_p);
35
4.26M
  return Value;
36
4.26M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.27M
{
26
3.27M
  const uint8_t *orig_p = p;
27
3.27M
  uint64_t Value = 0;
28
3.27M
  unsigned Shift = 0;
29
3.38M
  do {
30
3.38M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.38M
    Shift += 7;
32
3.38M
  } while (*p++ >= 128);
33
3.27M
  if (n)
34
3.27M
    *n = (unsigned)(p - orig_p);
35
3.27M
  return Value;
36
3.27M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.18M
{
26
1.18M
  const uint8_t *orig_p = p;
27
1.18M
  uint64_t Value = 0;
28
1.18M
  unsigned Shift = 0;
29
1.22M
  do {
30
1.22M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.22M
    Shift += 7;
32
1.22M
  } while (*p++ >= 128);
33
1.18M
  if (n)
34
1.18M
    *n = (unsigned)(p - orig_p);
35
1.18M
  return Value;
36
1.18M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.07M
{
26
7.07M
  const uint8_t *orig_p = p;
27
7.07M
  uint64_t Value = 0;
28
7.07M
  unsigned Shift = 0;
29
9.70M
  do {
30
9.70M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.70M
    Shift += 7;
32
9.70M
  } while (*p++ >= 128);
33
7.07M
  if (n)
34
7.07M
    *n = (unsigned)(p - orig_p);
35
7.07M
  return Value;
36
7.07M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.95M
{
26
1.95M
  const uint8_t *orig_p = p;
27
1.95M
  uint64_t Value = 0;
28
1.95M
  unsigned Shift = 0;
29
2.32M
  do {
30
2.32M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.32M
    Shift += 7;
32
2.32M
  } while (*p++ >= 128);
33
1.95M
  if (n)
34
1.95M
    *n = (unsigned)(p - orig_p);
35
1.95M
  return Value;
36
1.95M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H