Coverage Report

Created: 2024-08-21 06:24

/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
90.9M
{
26
90.9M
  const uint8_t *orig_p = p;
27
90.9M
  uint64_t Value = 0;
28
90.9M
  unsigned Shift = 0;
29
101M
  do {
30
101M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
101M
    Shift += 7;
32
101M
  } while (*p++ >= 128);
33
90.9M
  if (n)
34
90.9M
    *n = (unsigned)(p - orig_p);
35
90.9M
  return Value;
36
90.9M
}
Unexecuted instantiation: PPCModule.c:decodeULEB128
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.05M
{
26
5.05M
  const uint8_t *orig_p = p;
27
5.05M
  uint64_t Value = 0;
28
5.05M
  unsigned Shift = 0;
29
5.25M
  do {
30
5.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.25M
    Shift += 7;
32
5.25M
  } while (*p++ >= 128);
33
5.05M
  if (n)
34
5.05M
    *n = (unsigned)(p - orig_p);
35
5.05M
  return Value;
36
5.05M
}
Unexecuted instantiation: PPCMapping.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.14M
{
26
2.14M
  const uint8_t *orig_p = p;
27
2.14M
  uint64_t Value = 0;
28
2.14M
  unsigned Shift = 0;
29
2.19M
  do {
30
2.19M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.19M
    Shift += 7;
32
2.19M
  } while (*p++ >= 128);
33
2.14M
  if (n)
34
2.14M
    *n = (unsigned)(p - orig_p);
35
2.14M
  return Value;
36
2.14M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.41M
{
26
7.41M
  const uint8_t *orig_p = p;
27
7.41M
  uint64_t Value = 0;
28
7.41M
  unsigned Shift = 0;
29
10.0M
  do {
30
10.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.0M
    Shift += 7;
32
10.0M
  } while (*p++ >= 128);
33
7.41M
  if (n)
34
7.41M
    *n = (unsigned)(p - orig_p);
35
7.41M
  return Value;
36
7.41M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.71M
{
26
1.71M
  const uint8_t *orig_p = p;
27
1.71M
  uint64_t Value = 0;
28
1.71M
  unsigned Shift = 0;
29
1.92M
  do {
30
1.92M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.92M
    Shift += 7;
32
1.92M
  } while (*p++ >= 128);
33
1.71M
  if (n)
34
1.71M
    *n = (unsigned)(p - orig_p);
35
1.71M
  return Value;
36
1.71M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.63M
{
26
1.63M
  const uint8_t *orig_p = p;
27
1.63M
  uint64_t Value = 0;
28
1.63M
  unsigned Shift = 0;
29
1.66M
  do {
30
1.66M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.66M
    Shift += 7;
32
1.66M
  } while (*p++ >= 128);
33
1.63M
  if (n)
34
1.63M
    *n = (unsigned)(p - orig_p);
35
1.63M
  return Value;
36
1.63M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.59M
{
26
2.59M
  const uint8_t *orig_p = p;
27
2.59M
  uint64_t Value = 0;
28
2.59M
  unsigned Shift = 0;
29
2.71M
  do {
30
2.71M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.71M
    Shift += 7;
32
2.71M
  } while (*p++ >= 128);
33
2.59M
  if (n)
34
2.59M
    *n = (unsigned)(p - orig_p);
35
2.59M
  return Value;
36
2.59M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
53.5M
{
26
53.5M
  const uint8_t *orig_p = p;
27
53.5M
  uint64_t Value = 0;
28
53.5M
  unsigned Shift = 0;
29
59.8M
  do {
30
59.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
59.8M
    Shift += 7;
32
59.8M
  } while (*p++ >= 128);
33
53.5M
  if (n)
34
53.5M
    *n = (unsigned)(p - orig_p);
35
53.5M
  return Value;
36
53.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.53M
{
26
9.53M
  const uint8_t *orig_p = p;
27
9.53M
  uint64_t Value = 0;
28
9.53M
  unsigned Shift = 0;
29
10.5M
  do {
30
10.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.5M
    Shift += 7;
32
10.5M
  } while (*p++ >= 128);
33
9.53M
  if (n)
34
9.53M
    *n = (unsigned)(p - orig_p);
35
9.53M
  return Value;
36
9.53M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
7.27M
{
26
7.27M
  const uint8_t *orig_p = p;
27
7.27M
  uint64_t Value = 0;
28
7.27M
  unsigned Shift = 0;
29
7.56M
  do {
30
7.56M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.56M
    Shift += 7;
32
7.56M
  } while (*p++ >= 128);
33
7.27M
  if (n)
34
7.27M
    *n = (unsigned)(p - orig_p);
35
7.27M
  return Value;
36
7.27M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H