Coverage Report

Created: 2023-09-25 06:24

/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
15.3M
{
26
15.3M
  const uint8_t *orig_p = p;
27
15.3M
  uint64_t Value = 0;
28
15.3M
  unsigned Shift = 0;
29
17.1M
  do {
30
17.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.1M
    Shift += 7;
32
17.1M
  } while (*p++ >= 128);
33
15.3M
  if (n)
34
15.3M
    *n = (unsigned)(p - orig_p);
35
15.3M
  return Value;
36
15.3M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
7.15M
{
26
7.15M
  const uint8_t *orig_p = p;
27
7.15M
  uint64_t Value = 0;
28
7.15M
  unsigned Shift = 0;
29
7.94M
  do {
30
7.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.94M
    Shift += 7;
32
7.94M
  } while (*p++ >= 128);
33
7.15M
  if (n)
34
7.15M
    *n = (unsigned)(p - orig_p);
35
7.15M
  return Value;
36
7.15M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
1.81M
{
26
1.81M
  const uint8_t *orig_p = p;
27
1.81M
  uint64_t Value = 0;
28
1.81M
  unsigned Shift = 0;
29
1.99M
  do {
30
1.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.99M
    Shift += 7;
32
1.99M
  } while (*p++ >= 128);
33
1.81M
  if (n)
34
1.81M
    *n = (unsigned)(p - orig_p);
35
1.81M
  return Value;
36
1.81M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
1.37M
{
26
1.37M
  const uint8_t *orig_p = p;
27
1.37M
  uint64_t Value = 0;
28
1.37M
  unsigned Shift = 0;
29
1.42M
  do {
30
1.42M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.42M
    Shift += 7;
32
1.42M
  } while (*p++ >= 128);
33
1.37M
  if (n)
34
1.37M
    *n = (unsigned)(p - orig_p);
35
1.37M
  return Value;
36
1.37M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
1.31M
{
26
1.31M
  const uint8_t *orig_p = p;
27
1.31M
  uint64_t Value = 0;
28
1.31M
  unsigned Shift = 0;
29
1.37M
  do {
30
1.37M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.37M
    Shift += 7;
32
1.37M
  } while (*p++ >= 128);
33
1.31M
  if (n)
34
1.31M
    *n = (unsigned)(p - orig_p);
35
1.31M
  return Value;
36
1.31M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
419k
{
26
419k
  const uint8_t *orig_p = p;
27
419k
  uint64_t Value = 0;
28
419k
  unsigned Shift = 0;
29
431k
  do {
30
431k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
431k
    Shift += 7;
32
431k
  } while (*p++ >= 128);
33
419k
  if (n)
34
419k
    *n = (unsigned)(p - orig_p);
35
419k
  return Value;
36
419k
}
SystemZDisassembler.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
2.31M
  do {
30
2.31M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.31M
    Shift += 7;
32
2.31M
  } while (*p++ >= 128);
33
1.71M
  if (n)
34
1.71M
    *n = (unsigned)(p - orig_p);
35
1.71M
  return Value;
36
1.71M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
571k
{
26
571k
  const uint8_t *orig_p = p;
27
571k
  uint64_t Value = 0;
28
571k
  unsigned Shift = 0;
29
636k
  do {
30
636k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
636k
    Shift += 7;
32
636k
  } while (*p++ >= 128);
33
571k
  if (n)
34
571k
    *n = (unsigned)(p - orig_p);
35
571k
  return Value;
36
571k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
364k
{
26
364k
  const uint8_t *orig_p = p;
27
364k
  uint64_t Value = 0;
28
364k
  unsigned Shift = 0;
29
373k
  do {
30
373k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
373k
    Shift += 7;
32
373k
  } while (*p++ >= 128);
33
364k
  if (n)
34
364k
    *n = (unsigned)(p - orig_p);
35
364k
  return Value;
36
364k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
604k
{
26
604k
  const uint8_t *orig_p = p;
27
604k
  uint64_t Value = 0;
28
604k
  unsigned Shift = 0;
29
630k
  do {
30
630k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
630k
    Shift += 7;
32
630k
  } while (*p++ >= 128);
33
604k
  if (n)
34
604k
    *n = (unsigned)(p - orig_p);
35
604k
  return Value;
36
604k
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H