/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 | 100M | { |
26 | 100M | const uint8_t *orig_p = p; |
27 | 100M | uint64_t Value = 0; |
28 | 100M | unsigned Shift = 0; |
29 | 112M | do { |
30 | 112M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 112M | Shift += 7; |
32 | 112M | } while (*p++ >= 128); |
33 | 100M | if (n) |
34 | 100M | *n = (unsigned)(p - orig_p); |
35 | 100M | return Value; |
36 | 100M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.47M | { | 26 | 1.47M | const uint8_t *orig_p = p; | 27 | 1.47M | uint64_t Value = 0; | 28 | 1.47M | 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.47M | if (n) | 34 | 1.47M | *n = (unsigned)(p - orig_p); | 35 | 1.47M | return Value; | 36 | 1.47M | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.86M | { | 26 | 1.86M | const uint8_t *orig_p = p; | 27 | 1.86M | uint64_t Value = 0; | 28 | 1.86M | unsigned Shift = 0; | 29 | 1.90M | do { | 30 | 1.90M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.90M | Shift += 7; | 32 | 1.90M | } while (*p++ >= 128); | 33 | 1.86M | if (n) | 34 | 1.86M | *n = (unsigned)(p - orig_p); | 35 | 1.86M | return Value; | 36 | 1.86M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.49M | { | 26 | 4.49M | const uint8_t *orig_p = p; | 27 | 4.49M | uint64_t Value = 0; | 28 | 4.49M | unsigned Shift = 0; | 29 | 4.68M | do { | 30 | 4.68M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.68M | Shift += 7; | 32 | 4.68M | } while (*p++ >= 128); | 33 | 4.49M | if (n) | 34 | 4.49M | *n = (unsigned)(p - orig_p); | 35 | 4.49M | return Value; | 36 | 4.49M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 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.2M | do { | 30 | 48.2M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 48.2M | Shift += 7; | 32 | 48.2M | } while (*p++ >= 128); | 33 | 43.6M | if (n) | 34 | 43.6M | *n = (unsigned)(p - orig_p); | 35 | 43.6M | return Value; | 36 | 43.6M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 12.5M | { | 26 | 12.5M | const uint8_t *orig_p = p; | 27 | 12.5M | uint64_t Value = 0; | 28 | 12.5M | unsigned Shift = 0; | 29 | 13.8M | do { | 30 | 13.8M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 13.8M | Shift += 7; | 32 | 13.8M | } while (*p++ >= 128); | 33 | 12.5M | if (n) | 34 | 12.5M | *n = (unsigned)(p - orig_p); | 35 | 12.5M | return Value; | 36 | 12.5M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 8.26M | { | 26 | 8.26M | const uint8_t *orig_p = p; | 27 | 8.26M | uint64_t Value = 0; | 28 | 8.26M | unsigned Shift = 0; | 29 | 8.60M | do { | 30 | 8.60M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 8.60M | Shift += 7; | 32 | 8.60M | } while (*p++ >= 128); | 33 | 8.26M | if (n) | 34 | 8.26M | *n = (unsigned)(p - orig_p); | 35 | 8.26M | return Value; | 36 | 8.26M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 8.41M | { | 26 | 8.41M | const uint8_t *orig_p = p; | 27 | 8.41M | uint64_t Value = 0; | 28 | 8.41M | unsigned Shift = 0; | 29 | 8.73M | do { | 30 | 8.73M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 8.73M | Shift += 7; | 32 | 8.73M | } while (*p++ >= 128); | 33 | 8.41M | if (n) | 34 | 8.41M | *n = (unsigned)(p - orig_p); | 35 | 8.41M | return Value; | 36 | 8.41M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.94M | { | 26 | 2.94M | const uint8_t *orig_p = p; | 27 | 2.94M | uint64_t Value = 0; | 28 | 2.94M | unsigned Shift = 0; | 29 | 3.02M | do { | 30 | 3.02M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.02M | Shift += 7; | 32 | 3.02M | } while (*p++ >= 128); | 33 | 2.94M | if (n) | 34 | 2.94M | *n = (unsigned)(p - orig_p); | 35 | 2.94M | return Value; | 36 | 2.94M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 13.8M | { | 26 | 13.8M | const uint8_t *orig_p = p; | 27 | 13.8M | uint64_t Value = 0; | 28 | 13.8M | unsigned Shift = 0; | 29 | 19.1M | do { | 30 | 19.1M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 19.1M | Shift += 7; | 32 | 19.1M | } while (*p++ >= 128); | 33 | 13.8M | if (n) | 34 | 13.8M | *n = (unsigned)(p - orig_p); | 35 | 13.8M | return Value; | 36 | 13.8M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.54M | { | 26 | 2.54M | const uint8_t *orig_p = p; | 27 | 2.54M | uint64_t Value = 0; | 28 | 2.54M | 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 | 2.54M | if (n) | 34 | 2.54M | *n = (unsigned)(p - orig_p); | 35 | 2.54M | return Value; | 36 | 2.54M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |