/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 | 37.2M | { |
26 | 37.2M | const uint8_t *orig_p = p; |
27 | 37.2M | uint64_t Value = 0; |
28 | 37.2M | unsigned Shift = 0; |
29 | 42.1M | do { |
30 | 42.1M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 42.1M | Shift += 7; |
32 | 42.1M | } while (*p++ >= 128); |
33 | 37.2M | if (n) |
34 | 37.2M | *n = (unsigned)(p - orig_p); |
35 | 37.2M | return Value; |
36 | 37.2M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 677k | { | 26 | 677k | const uint8_t *orig_p = p; | 27 | 677k | uint64_t Value = 0; | 28 | 677k | unsigned Shift = 0; | 29 | 763k | do { | 30 | 763k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 763k | Shift += 7; | 32 | 763k | } while (*p++ >= 128); | 33 | 677k | if (n) | 34 | 677k | *n = (unsigned)(p - orig_p); | 35 | 677k | return Value; | 36 | 677k | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 624k | { | 26 | 624k | const uint8_t *orig_p = p; | 27 | 624k | uint64_t Value = 0; | 28 | 624k | unsigned Shift = 0; | 29 | 637k | do { | 30 | 637k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 637k | Shift += 7; | 32 | 637k | } while (*p++ >= 128); | 33 | 624k | if (n) | 34 | 624k | *n = (unsigned)(p - orig_p); | 35 | 624k | return Value; | 36 | 624k | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 935k | { | 26 | 935k | const uint8_t *orig_p = p; | 27 | 935k | uint64_t Value = 0; | 28 | 935k | unsigned Shift = 0; | 29 | 975k | do { | 30 | 975k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 975k | Shift += 7; | 32 | 975k | } while (*p++ >= 128); | 33 | 935k | if (n) | 34 | 935k | *n = (unsigned)(p - orig_p); | 35 | 935k | return Value; | 36 | 935k | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 19.2M | { | 26 | 19.2M | const uint8_t *orig_p = p; | 27 | 19.2M | uint64_t Value = 0; | 28 | 19.2M | unsigned Shift = 0; | 29 | 21.3M | do { | 30 | 21.3M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 21.3M | Shift += 7; | 32 | 21.3M | } while (*p++ >= 128); | 33 | 19.2M | if (n) | 34 | 19.2M | *n = (unsigned)(p - orig_p); | 35 | 19.2M | return Value; | 36 | 19.2M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.87M | { | 26 | 3.87M | const uint8_t *orig_p = p; | 27 | 3.87M | uint64_t Value = 0; | 28 | 3.87M | unsigned Shift = 0; | 29 | 4.32M | do { | 30 | 4.32M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.32M | Shift += 7; | 32 | 4.32M | } while (*p++ >= 128); | 33 | 3.87M | if (n) | 34 | 3.87M | *n = (unsigned)(p - orig_p); | 35 | 3.87M | return Value; | 36 | 3.87M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.99M | { | 26 | 2.99M | const uint8_t *orig_p = p; | 27 | 2.99M | uint64_t Value = 0; | 28 | 2.99M | unsigned Shift = 0; | 29 | 3.12M | do { | 30 | 3.12M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.12M | Shift += 7; | 32 | 3.12M | } while (*p++ >= 128); | 33 | 2.99M | if (n) | 34 | 2.99M | *n = (unsigned)(p - orig_p); | 35 | 2.99M | return Value; | 36 | 2.99M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.35M | { | 26 | 2.35M | const uint8_t *orig_p = p; | 27 | 2.35M | uint64_t Value = 0; | 28 | 2.35M | unsigned Shift = 0; | 29 | 2.44M | do { | 30 | 2.44M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.44M | Shift += 7; | 32 | 2.44M | } while (*p++ >= 128); | 33 | 2.35M | if (n) | 34 | 2.35M | *n = (unsigned)(p - orig_p); | 35 | 2.35M | return Value; | 36 | 2.35M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 836k | { | 26 | 836k | const uint8_t *orig_p = p; | 27 | 836k | uint64_t Value = 0; | 28 | 836k | unsigned Shift = 0; | 29 | 865k | do { | 30 | 865k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 865k | Shift += 7; | 32 | 865k | } while (*p++ >= 128); | 33 | 836k | if (n) | 34 | 836k | *n = (unsigned)(p - orig_p); | 35 | 836k | return Value; | 36 | 836k | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.36M | { | 26 | 4.36M | const uint8_t *orig_p = p; | 27 | 4.36M | uint64_t Value = 0; | 28 | 4.36M | unsigned Shift = 0; | 29 | 5.97M | do { | 30 | 5.97M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 5.97M | Shift += 7; | 32 | 5.97M | } while (*p++ >= 128); | 33 | 4.36M | if (n) | 34 | 4.36M | *n = (unsigned)(p - orig_p); | 35 | 4.36M | return Value; | 36 | 4.36M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.35M | { | 26 | 1.35M | const uint8_t *orig_p = p; | 27 | 1.35M | uint64_t Value = 0; | 28 | 1.35M | unsigned Shift = 0; | 29 | 1.61M | do { | 30 | 1.61M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.61M | Shift += 7; | 32 | 1.61M | } while (*p++ >= 128); | 33 | 1.35M | if (n) | 34 | 1.35M | *n = (unsigned)(p - orig_p); | 35 | 1.35M | return Value; | 36 | 1.35M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |