Coverage Report

Created: 2023-12-08 06:05

/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
43.6M
{
26
43.6M
  const uint8_t *orig_p = p;
27
43.6M
  uint64_t Value = 0;
28
43.6M
  unsigned Shift = 0;
29
48.6M
  do {
30
48.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
48.6M
    Shift += 7;
32
48.6M
  } while (*p++ >= 128);
33
43.6M
  if (n)
34
43.6M
    *n = (unsigned)(p - orig_p);
35
43.6M
  return Value;
36
43.6M
}
Unexecuted instantiation: PPCModule.c:decodeULEB128
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
2.40M
{
26
2.40M
  const uint8_t *orig_p = p;
27
2.40M
  uint64_t Value = 0;
28
2.40M
  unsigned Shift = 0;
29
2.49M
  do {
30
2.49M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.49M
    Shift += 7;
32
2.49M
  } while (*p++ >= 128);
33
2.40M
  if (n)
34
2.40M
    *n = (unsigned)(p - orig_p);
35
2.40M
  return Value;
36
2.40M
}
Unexecuted instantiation: PPCMapping.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
895k
{
26
895k
  const uint8_t *orig_p = p;
27
895k
  uint64_t Value = 0;
28
895k
  unsigned Shift = 0;
29
920k
  do {
30
920k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
920k
    Shift += 7;
32
920k
  } while (*p++ >= 128);
33
895k
  if (n)
34
895k
    *n = (unsigned)(p - orig_p);
35
895k
  return Value;
36
895k
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
3.07M
{
26
3.07M
  const uint8_t *orig_p = p;
27
3.07M
  uint64_t Value = 0;
28
3.07M
  unsigned Shift = 0;
29
4.16M
  do {
30
4.16M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.16M
    Shift += 7;
32
4.16M
  } while (*p++ >= 128);
33
3.07M
  if (n)
34
3.07M
    *n = (unsigned)(p - orig_p);
35
3.07M
  return Value;
36
3.07M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
916k
{
26
916k
  const uint8_t *orig_p = p;
27
916k
  uint64_t Value = 0;
28
916k
  unsigned Shift = 0;
29
1.01M
  do {
30
1.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.01M
    Shift += 7;
32
1.01M
  } while (*p++ >= 128);
33
916k
  if (n)
34
916k
    *n = (unsigned)(p - orig_p);
35
916k
  return Value;
36
916k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
758k
{
26
758k
  const uint8_t *orig_p = p;
27
758k
  uint64_t Value = 0;
28
758k
  unsigned Shift = 0;
29
776k
  do {
30
776k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
776k
    Shift += 7;
32
776k
  } while (*p++ >= 128);
33
758k
  if (n)
34
758k
    *n = (unsigned)(p - orig_p);
35
758k
  return Value;
36
758k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
888k
{
26
888k
  const uint8_t *orig_p = p;
27
888k
  uint64_t Value = 0;
28
888k
  unsigned Shift = 0;
29
928k
  do {
30
928k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
928k
    Shift += 7;
32
928k
  } while (*p++ >= 128);
33
888k
  if (n)
34
888k
    *n = (unsigned)(p - orig_p);
35
888k
  return Value;
36
888k
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
27.5M
{
26
27.5M
  const uint8_t *orig_p = p;
27
27.5M
  uint64_t Value = 0;
28
27.5M
  unsigned Shift = 0;
29
30.6M
  do {
30
30.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
30.6M
    Shift += 7;
32
30.6M
  } while (*p++ >= 128);
33
27.5M
  if (n)
34
27.5M
    *n = (unsigned)(p - orig_p);
35
27.5M
  return Value;
36
27.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
4.10M
{
26
4.10M
  const uint8_t *orig_p = p;
27
4.10M
  uint64_t Value = 0;
28
4.10M
  unsigned Shift = 0;
29
4.53M
  do {
30
4.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.53M
    Shift += 7;
32
4.53M
  } while (*p++ >= 128);
33
4.10M
  if (n)
34
4.10M
    *n = (unsigned)(p - orig_p);
35
4.10M
  return Value;
36
4.10M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.03M
{
26
3.03M
  const uint8_t *orig_p = p;
27
3.03M
  uint64_t Value = 0;
28
3.03M
  unsigned Shift = 0;
29
3.15M
  do {
30
3.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.15M
    Shift += 7;
32
3.15M
  } while (*p++ >= 128);
33
3.03M
  if (n)
34
3.03M
    *n = (unsigned)(p - orig_p);
35
3.03M
  return Value;
36
3.03M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H