/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 | 66.8M | { |
26 | 66.8M | const uint8_t *orig_p = p; |
27 | 66.8M | uint64_t Value = 0; |
28 | 66.8M | unsigned Shift = 0; |
29 | 75.1M | do { |
30 | 75.1M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 75.1M | Shift += 7; |
32 | 75.1M | } while (*p++ >= 128); |
33 | 66.8M | if (n) |
34 | 66.8M | *n = (unsigned)(p - orig_p); |
35 | 66.8M | return Value; |
36 | 66.8M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 774k | { | 26 | 774k | const uint8_t *orig_p = p; | 27 | 774k | uint64_t Value = 0; | 28 | 774k | unsigned Shift = 0; | 29 | 864k | do { | 30 | 864k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 864k | Shift += 7; | 32 | 864k | } while (*p++ >= 128); | 33 | 774k | if (n) | 34 | 774k | *n = (unsigned)(p - orig_p); | 35 | 774k | return Value; | 36 | 774k | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.06M | { | 26 | 1.06M | const uint8_t *orig_p = p; | 27 | 1.06M | uint64_t Value = 0; | 28 | 1.06M | unsigned Shift = 0; | 29 | 1.09M | do { | 30 | 1.09M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.09M | Shift += 7; | 32 | 1.09M | } while (*p++ >= 128); | 33 | 1.06M | if (n) | 34 | 1.06M | *n = (unsigned)(p - orig_p); | 35 | 1.06M | return Value; | 36 | 1.06M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.84M | { | 26 | 2.84M | const uint8_t *orig_p = p; | 27 | 2.84M | uint64_t Value = 0; | 28 | 2.84M | unsigned Shift = 0; | 29 | 2.93M | do { | 30 | 2.93M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.93M | Shift += 7; | 32 | 2.93M | } while (*p++ >= 128); | 33 | 2.84M | if (n) | 34 | 2.84M | *n = (unsigned)(p - orig_p); | 35 | 2.84M | return Value; | 36 | 2.84M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 33.1M | { | 26 | 33.1M | const uint8_t *orig_p = p; | 27 | 33.1M | uint64_t Value = 0; | 28 | 33.1M | unsigned Shift = 0; | 29 | 36.7M | do { | 30 | 36.7M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 36.7M | Shift += 7; | 32 | 36.7M | } while (*p++ >= 128); | 33 | 33.1M | if (n) | 34 | 33.1M | *n = (unsigned)(p - orig_p); | 35 | 33.1M | return Value; | 36 | 33.1M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 6.48M | { | 26 | 6.48M | const uint8_t *orig_p = p; | 27 | 6.48M | uint64_t Value = 0; | 28 | 6.48M | unsigned Shift = 0; | 29 | 7.18M | do { | 30 | 7.18M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 7.18M | Shift += 7; | 32 | 7.18M | } while (*p++ >= 128); | 33 | 6.48M | if (n) | 34 | 6.48M | *n = (unsigned)(p - orig_p); | 35 | 6.48M | return Value; | 36 | 6.48M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 6.58M | { | 26 | 6.58M | const uint8_t *orig_p = p; | 27 | 6.58M | uint64_t Value = 0; | 28 | 6.58M | unsigned Shift = 0; | 29 | 6.88M | do { | 30 | 6.88M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 6.88M | Shift += 7; | 32 | 6.88M | } while (*p++ >= 128); | 33 | 6.58M | if (n) | 34 | 6.58M | *n = (unsigned)(p - orig_p); | 35 | 6.58M | return Value; | 36 | 6.58M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.95M | { | 26 | 4.95M | const uint8_t *orig_p = p; | 27 | 4.95M | uint64_t Value = 0; | 28 | 4.95M | unsigned Shift = 0; | 29 | 5.15M | do { | 30 | 5.15M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 5.15M | Shift += 7; | 32 | 5.15M | } while (*p++ >= 128); | 33 | 4.95M | if (n) | 34 | 4.95M | *n = (unsigned)(p - orig_p); | 35 | 4.95M | return Value; | 36 | 4.95M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.90M | { | 26 | 1.90M | const uint8_t *orig_p = p; | 27 | 1.90M | uint64_t Value = 0; | 28 | 1.90M | unsigned Shift = 0; | 29 | 1.97M | do { | 30 | 1.97M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.97M | Shift += 7; | 32 | 1.97M | } while (*p++ >= 128); | 33 | 1.90M | if (n) | 34 | 1.90M | *n = (unsigned)(p - orig_p); | 35 | 1.90M | return Value; | 36 | 1.90M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 8.11M | { | 26 | 8.11M | const uint8_t *orig_p = p; | 27 | 8.11M | uint64_t Value = 0; | 28 | 8.11M | unsigned Shift = 0; | 29 | 11.2M | do { | 30 | 11.2M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 11.2M | Shift += 7; | 32 | 11.2M | } while (*p++ >= 128); | 33 | 8.11M | if (n) | 34 | 8.11M | *n = (unsigned)(p - orig_p); | 35 | 8.11M | return Value; | 36 | 8.11M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 952k | { | 26 | 952k | const uint8_t *orig_p = p; | 27 | 952k | uint64_t Value = 0; | 28 | 952k | unsigned Shift = 0; | 29 | 1.02M | do { | 30 | 1.02M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.02M | Shift += 7; | 32 | 1.02M | } while (*p++ >= 128); | 33 | 952k | if (n) | 34 | 952k | *n = (unsigned)(p - orig_p); | 35 | 952k | return Value; | 36 | 952k | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |