Coverage Report

Created: 2024-09-08 06:22

/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
104M
{
26
104M
  const uint8_t *orig_p = p;
27
104M
  uint64_t Value = 0;
28
104M
  unsigned Shift = 0;
29
116M
  do {
30
116M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
116M
    Shift += 7;
32
116M
  } while (*p++ >= 128);
33
104M
  if (n)
34
104M
    *n = (unsigned)(p - orig_p);
35
104M
  return Value;
36
104M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
62.4M
{
26
62.4M
  const uint8_t *orig_p = p;
27
62.4M
  uint64_t Value = 0;
28
62.4M
  unsigned Shift = 0;
29
69.7M
  do {
30
69.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
69.7M
    Shift += 7;
32
69.7M
  } while (*p++ >= 128);
33
62.4M
  if (n)
34
62.4M
    *n = (unsigned)(p - orig_p);
35
62.4M
  return Value;
36
62.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
10.4M
{
26
10.4M
  const uint8_t *orig_p = p;
27
10.4M
  uint64_t Value = 0;
28
10.4M
  unsigned Shift = 0;
29
11.5M
  do {
30
11.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.5M
    Shift += 7;
32
11.5M
  } while (*p++ >= 128);
33
10.4M
  if (n)
34
10.4M
    *n = (unsigned)(p - orig_p);
35
10.4M
  return Value;
36
10.4M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.39M
{
26
5.39M
  const uint8_t *orig_p = p;
27
5.39M
  uint64_t Value = 0;
28
5.39M
  unsigned Shift = 0;
29
5.61M
  do {
30
5.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.61M
    Shift += 7;
32
5.61M
  } while (*p++ >= 128);
33
5.39M
  if (n)
34
5.39M
    *n = (unsigned)(p - orig_p);
35
5.39M
  return Value;
36
5.39M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.60M
{
26
8.60M
  const uint8_t *orig_p = p;
27
8.60M
  uint64_t Value = 0;
28
8.60M
  unsigned Shift = 0;
29
8.95M
  do {
30
8.95M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.95M
    Shift += 7;
32
8.95M
  } while (*p++ >= 128);
33
8.60M
  if (n)
34
8.60M
    *n = (unsigned)(p - orig_p);
35
8.60M
  return Value;
36
8.60M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.28M
{
26
2.28M
  const uint8_t *orig_p = p;
27
2.28M
  uint64_t Value = 0;
28
2.28M
  unsigned Shift = 0;
29
2.34M
  do {
30
2.34M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.34M
    Shift += 7;
32
2.34M
  } while (*p++ >= 128);
33
2.28M
  if (n)
34
2.28M
    *n = (unsigned)(p - orig_p);
35
2.28M
  return Value;
36
2.28M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.31M
{
26
8.31M
  const uint8_t *orig_p = p;
27
8.31M
  uint64_t Value = 0;
28
8.31M
  unsigned Shift = 0;
29
11.2M
  do {
30
11.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.2M
    Shift += 7;
32
11.2M
  } while (*p++ >= 128);
33
8.31M
  if (n)
34
8.31M
    *n = (unsigned)(p - orig_p);
35
8.31M
  return Value;
36
8.31M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.97M
{
26
1.97M
  const uint8_t *orig_p = p;
27
1.97M
  uint64_t Value = 0;
28
1.97M
  unsigned Shift = 0;
29
2.25M
  do {
30
2.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.25M
    Shift += 7;
32
2.25M
  } while (*p++ >= 128);
33
1.97M
  if (n)
34
1.97M
    *n = (unsigned)(p - orig_p);
35
1.97M
  return Value;
36
1.97M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.91M
{
26
1.91M
  const uint8_t *orig_p = p;
27
1.91M
  uint64_t Value = 0;
28
1.91M
  unsigned Shift = 0;
29
1.95M
  do {
30
1.95M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.95M
    Shift += 7;
32
1.95M
  } while (*p++ >= 128);
33
1.91M
  if (n)
34
1.91M
    *n = (unsigned)(p - orig_p);
35
1.91M
  return Value;
36
1.91M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.65M
{
26
2.65M
  const uint8_t *orig_p = p;
27
2.65M
  uint64_t Value = 0;
28
2.65M
  unsigned Shift = 0;
29
2.78M
  do {
30
2.78M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.78M
    Shift += 7;
32
2.78M
  } while (*p++ >= 128);
33
2.65M
  if (n)
34
2.65M
    *n = (unsigned)(p - orig_p);
35
2.65M
  return Value;
36
2.65M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H