/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 | 86.8M | { |
26 | 86.8M | const uint8_t *orig_p = p; |
27 | 86.8M | uint64_t Value = 0; |
28 | 86.8M | unsigned Shift = 0; |
29 | 97.7M | do { |
30 | 97.7M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 97.7M | Shift += 7; |
32 | 97.7M | } while (*p++ >= 128); |
33 | 86.8M | if (n) |
34 | 86.8M | *n = (unsigned)(p - orig_p); |
35 | 86.8M | return Value; |
36 | 86.8M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.33M | { | 26 | 1.33M | const uint8_t *orig_p = p; | 27 | 1.33M | uint64_t Value = 0; | 28 | 1.33M | unsigned Shift = 0; | 29 | 1.47M | do { | 30 | 1.47M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.47M | Shift += 7; | 32 | 1.47M | } while (*p++ >= 128); | 33 | 1.33M | if (n) | 34 | 1.33M | *n = (unsigned)(p - orig_p); | 35 | 1.33M | return Value; | 36 | 1.33M | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.48M | { | 26 | 1.48M | const uint8_t *orig_p = p; | 27 | 1.48M | uint64_t Value = 0; | 28 | 1.48M | unsigned Shift = 0; | 29 | 1.52M | do { | 30 | 1.52M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.52M | Shift += 7; | 32 | 1.52M | } while (*p++ >= 128); | 33 | 1.48M | if (n) | 34 | 1.48M | *n = (unsigned)(p - orig_p); | 35 | 1.48M | return Value; | 36 | 1.48M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.70M | { | 26 | 3.70M | const uint8_t *orig_p = p; | 27 | 3.70M | uint64_t Value = 0; | 28 | 3.70M | unsigned Shift = 0; | 29 | 3.86M | do { | 30 | 3.86M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.86M | Shift += 7; | 32 | 3.86M | } while (*p++ >= 128); | 33 | 3.70M | if (n) | 34 | 3.70M | *n = (unsigned)(p - orig_p); | 35 | 3.70M | return Value; | 36 | 3.70M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 37.4M | { | 26 | 37.4M | const uint8_t *orig_p = p; | 27 | 37.4M | uint64_t Value = 0; | 28 | 37.4M | unsigned Shift = 0; | 29 | 41.4M | do { | 30 | 41.4M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 41.4M | Shift += 7; | 32 | 41.4M | } while (*p++ >= 128); | 33 | 37.4M | if (n) | 34 | 37.4M | *n = (unsigned)(p - orig_p); | 35 | 37.4M | return Value; | 36 | 37.4M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 13.1M | { | 26 | 13.1M | const uint8_t *orig_p = p; | 27 | 13.1M | uint64_t Value = 0; | 28 | 13.1M | unsigned Shift = 0; | 29 | 14.3M | do { | 30 | 14.3M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 14.3M | Shift += 7; | 32 | 14.3M | } while (*p++ >= 128); | 33 | 13.1M | if (n) | 34 | 13.1M | *n = (unsigned)(p - orig_p); | 35 | 13.1M | return Value; | 36 | 13.1M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 6.85M | { | 26 | 6.85M | const uint8_t *orig_p = p; | 27 | 6.85M | uint64_t Value = 0; | 28 | 6.85M | unsigned Shift = 0; | 29 | 7.11M | do { | 30 | 7.11M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 7.11M | Shift += 7; | 32 | 7.11M | } while (*p++ >= 128); | 33 | 6.85M | if (n) | 34 | 6.85M | *n = (unsigned)(p - orig_p); | 35 | 6.85M | return Value; | 36 | 6.85M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 7.38M | { | 26 | 7.38M | const uint8_t *orig_p = p; | 27 | 7.38M | uint64_t Value = 0; | 28 | 7.38M | unsigned Shift = 0; | 29 | 7.68M | do { | 30 | 7.68M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 7.68M | Shift += 7; | 32 | 7.68M | } while (*p++ >= 128); | 33 | 7.38M | if (n) | 34 | 7.38M | *n = (unsigned)(p - orig_p); | 35 | 7.38M | return Value; | 36 | 7.38M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.26M | { | 26 | 3.26M | const uint8_t *orig_p = p; | 27 | 3.26M | uint64_t Value = 0; | 28 | 3.26M | unsigned Shift = 0; | 29 | 3.34M | do { | 30 | 3.34M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.34M | Shift += 7; | 32 | 3.34M | } while (*p++ >= 128); | 33 | 3.26M | if (n) | 34 | 3.26M | *n = (unsigned)(p - orig_p); | 35 | 3.26M | return Value; | 36 | 3.26M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 11.5M | { | 26 | 11.5M | const uint8_t *orig_p = p; | 27 | 11.5M | uint64_t Value = 0; | 28 | 11.5M | unsigned Shift = 0; | 29 | 16.0M | do { | 30 | 16.0M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 16.0M | Shift += 7; | 32 | 16.0M | } while (*p++ >= 128); | 33 | 11.5M | if (n) | 34 | 11.5M | *n = (unsigned)(p - orig_p); | 35 | 11.5M | return Value; | 36 | 11.5M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 705k | { | 26 | 705k | const uint8_t *orig_p = p; | 27 | 705k | uint64_t Value = 0; | 28 | 705k | unsigned Shift = 0; | 29 | 881k | do { | 30 | 881k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 881k | Shift += 7; | 32 | 881k | } while (*p++ >= 128); | 33 | 705k | if (n) | 34 | 705k | *n = (unsigned)(p - orig_p); | 35 | 705k | return Value; | 36 | 705k | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |