Coverage Report

Created: 2023-12-08 06:05

/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
44.6M
{
26
44.6M
  const uint8_t *orig_p = p;
27
44.6M
  uint64_t Value = 0;
28
44.6M
  unsigned Shift = 0;
29
49.9M
  do {
30
49.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
49.9M
    Shift += 7;
32
49.9M
  } while (*p++ >= 128);
33
44.6M
  if (n)
34
44.6M
    *n = (unsigned)(p - orig_p);
35
44.6M
  return Value;
36
44.6M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
22.6M
{
26
22.6M
  const uint8_t *orig_p = p;
27
22.6M
  uint64_t Value = 0;
28
22.6M
  unsigned Shift = 0;
29
25.2M
  do {
30
25.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
25.2M
    Shift += 7;
32
25.2M
  } while (*p++ >= 128);
33
22.6M
  if (n)
34
22.6M
    *n = (unsigned)(p - orig_p);
35
22.6M
  return Value;
36
22.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.76M
{
26
5.76M
  const uint8_t *orig_p = p;
27
5.76M
  uint64_t Value = 0;
28
5.76M
  unsigned Shift = 0;
29
6.32M
  do {
30
6.32M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.32M
    Shift += 7;
32
6.32M
  } while (*p++ >= 128);
33
5.76M
  if (n)
34
5.76M
    *n = (unsigned)(p - orig_p);
35
5.76M
  return Value;
36
5.76M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.13M
{
26
3.13M
  const uint8_t *orig_p = p;
27
3.13M
  uint64_t Value = 0;
28
3.13M
  unsigned Shift = 0;
29
3.25M
  do {
30
3.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.25M
    Shift += 7;
32
3.25M
  } while (*p++ >= 128);
33
3.13M
  if (n)
34
3.13M
    *n = (unsigned)(p - orig_p);
35
3.13M
  return Value;
36
3.13M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.53M
{
26
3.53M
  const uint8_t *orig_p = p;
27
3.53M
  uint64_t Value = 0;
28
3.53M
  unsigned Shift = 0;
29
3.68M
  do {
30
3.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.68M
    Shift += 7;
32
3.68M
  } while (*p++ >= 128);
33
3.53M
  if (n)
34
3.53M
    *n = (unsigned)(p - orig_p);
35
3.53M
  return Value;
36
3.53M
}
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
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
4.71M
{
26
4.71M
  const uint8_t *orig_p = p;
27
4.71M
  uint64_t Value = 0;
28
4.71M
  unsigned Shift = 0;
29
6.39M
  do {
30
6.39M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.39M
    Shift += 7;
32
6.39M
  } while (*p++ >= 128);
33
4.71M
  if (n)
34
4.71M
    *n = (unsigned)(p - orig_p);
35
4.71M
  return Value;
36
4.71M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
776k
{
26
776k
  const uint8_t *orig_p = p;
27
776k
  uint64_t Value = 0;
28
776k
  unsigned Shift = 0;
29
887k
  do {
30
887k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
887k
    Shift += 7;
32
887k
  } while (*p++ >= 128);
33
776k
  if (n)
34
776k
    *n = (unsigned)(p - orig_p);
35
776k
  return Value;
36
776k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
927k
{
26
927k
  const uint8_t *orig_p = p;
27
927k
  uint64_t Value = 0;
28
927k
  unsigned Shift = 0;
29
949k
  do {
30
949k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
949k
    Shift += 7;
32
949k
  } while (*p++ >= 128);
33
927k
  if (n)
34
927k
    *n = (unsigned)(p - orig_p);
35
927k
  return Value;
36
927k
}
RISCVDisassembler.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
2.00M
  do {
30
2.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.00M
    Shift += 7;
32
2.00M
  } while (*p++ >= 128);
33
1.91M
  if (n)
34
1.91M
    *n = (unsigned)(p - orig_p);
35
1.91M
  return Value;
36
1.91M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H