/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 | 105M | { |
26 | 105M | const uint8_t *orig_p = p; |
27 | 105M | uint64_t Value = 0; |
28 | 105M | unsigned Shift = 0; |
29 | 118M | do { |
30 | 118M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 118M | Shift += 7; |
32 | 118M | } while (*p++ >= 128); |
33 | 105M | if (n) |
34 | 105M | *n = (unsigned)(p - orig_p); |
35 | 105M | return Value; |
36 | 105M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.44M | { | 26 | 1.44M | const uint8_t *orig_p = p; | 27 | 1.44M | uint64_t Value = 0; | 28 | 1.44M | unsigned Shift = 0; | 29 | 1.59M | do { | 30 | 1.59M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.59M | Shift += 7; | 32 | 1.59M | } while (*p++ >= 128); | 33 | 1.44M | if (n) | 34 | 1.44M | *n = (unsigned)(p - orig_p); | 35 | 1.44M | return Value; | 36 | 1.44M | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.99M | { | 26 | 1.99M | const uint8_t *orig_p = p; | 27 | 1.99M | uint64_t Value = 0; | 28 | 1.99M | unsigned Shift = 0; | 29 | 2.03M | do { | 30 | 2.03M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.03M | Shift += 7; | 32 | 2.03M | } while (*p++ >= 128); | 33 | 1.99M | if (n) | 34 | 1.99M | *n = (unsigned)(p - orig_p); | 35 | 1.99M | return Value; | 36 | 1.99M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.76M | { | 26 | 4.76M | const uint8_t *orig_p = p; | 27 | 4.76M | uint64_t Value = 0; | 28 | 4.76M | unsigned Shift = 0; | 29 | 4.97M | do { | 30 | 4.97M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.97M | Shift += 7; | 32 | 4.97M | } while (*p++ >= 128); | 33 | 4.76M | if (n) | 34 | 4.76M | *n = (unsigned)(p - orig_p); | 35 | 4.76M | return Value; | 36 | 4.76M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 48.3M | { | 26 | 48.3M | const uint8_t *orig_p = p; | 27 | 48.3M | uint64_t Value = 0; | 28 | 48.3M | unsigned Shift = 0; | 29 | 53.5M | do { | 30 | 53.5M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 53.5M | Shift += 7; | 32 | 53.5M | } while (*p++ >= 128); | 33 | 48.3M | if (n) | 34 | 48.3M | *n = (unsigned)(p - orig_p); | 35 | 48.3M | return Value; | 36 | 48.3M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 14.2M | { | 26 | 14.2M | const uint8_t *orig_p = p; | 27 | 14.2M | uint64_t Value = 0; | 28 | 14.2M | unsigned Shift = 0; | 29 | 15.6M | do { | 30 | 15.6M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 15.6M | Shift += 7; | 32 | 15.6M | } while (*p++ >= 128); | 33 | 14.2M | if (n) | 34 | 14.2M | *n = (unsigned)(p - orig_p); | 35 | 14.2M | return Value; | 36 | 14.2M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 7.51M | { | 26 | 7.51M | const uint8_t *orig_p = p; | 27 | 7.51M | uint64_t Value = 0; | 28 | 7.51M | unsigned Shift = 0; | 29 | 7.81M | do { | 30 | 7.81M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 7.81M | Shift += 7; | 32 | 7.81M | } while (*p++ >= 128); | 33 | 7.51M | if (n) | 34 | 7.51M | *n = (unsigned)(p - orig_p); | 35 | 7.51M | return Value; | 36 | 7.51M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 8.93M | { | 26 | 8.93M | const uint8_t *orig_p = p; | 27 | 8.93M | uint64_t Value = 0; | 28 | 8.93M | unsigned Shift = 0; | 29 | 9.27M | do { | 30 | 9.27M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 9.27M | Shift += 7; | 32 | 9.27M | } while (*p++ >= 128); | 33 | 8.93M | if (n) | 34 | 8.93M | *n = (unsigned)(p - orig_p); | 35 | 8.93M | return Value; | 36 | 8.93M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.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.11M | do { | 30 | 3.11M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.11M | Shift += 7; | 32 | 3.11M | } 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: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 13.2M | { | 26 | 13.2M | const uint8_t *orig_p = p; | 27 | 13.2M | uint64_t Value = 0; | 28 | 13.2M | unsigned Shift = 0; | 29 | 18.1M | do { | 30 | 18.1M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 18.1M | Shift += 7; | 32 | 18.1M | } while (*p++ >= 128); | 33 | 13.2M | if (n) | 34 | 13.2M | *n = (unsigned)(p - orig_p); | 35 | 13.2M | return Value; | 36 | 13.2M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.95M | { | 26 | 1.95M | const uint8_t *orig_p = p; | 27 | 1.95M | uint64_t Value = 0; | 28 | 1.95M | unsigned Shift = 0; | 29 | 2.32M | do { | 30 | 2.32M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.32M | Shift += 7; | 32 | 2.32M | } while (*p++ >= 128); | 33 | 1.95M | if (n) | 34 | 1.95M | *n = (unsigned)(p - orig_p); | 35 | 1.95M | return Value; | 36 | 1.95M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |