/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 | 63.1M | { |
26 | 63.1M | const uint8_t *orig_p = p; |
27 | 63.1M | uint64_t Value = 0; |
28 | 63.1M | unsigned Shift = 0; |
29 | 71.0M | do { |
30 | 71.0M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 71.0M | Shift += 7; |
32 | 71.0M | } while (*p++ >= 128); |
33 | 63.1M | if (n) |
34 | 63.1M | *n = (unsigned)(p - orig_p); |
35 | 63.1M | return Value; |
36 | 63.1M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.03M | { | 26 | 1.03M | const uint8_t *orig_p = p; | 27 | 1.03M | uint64_t Value = 0; | 28 | 1.03M | unsigned Shift = 0; | 29 | 1.15M | do { | 30 | 1.15M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.15M | Shift += 7; | 32 | 1.15M | } while (*p++ >= 128); | 33 | 1.03M | if (n) | 34 | 1.03M | *n = (unsigned)(p - orig_p); | 35 | 1.03M | return Value; | 36 | 1.03M | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.12M | { | 26 | 1.12M | const uint8_t *orig_p = p; | 27 | 1.12M | uint64_t Value = 0; | 28 | 1.12M | unsigned Shift = 0; | 29 | 1.14M | do { | 30 | 1.14M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.14M | Shift += 7; | 32 | 1.14M | } while (*p++ >= 128); | 33 | 1.12M | if (n) | 34 | 1.12M | *n = (unsigned)(p - orig_p); | 35 | 1.12M | return Value; | 36 | 1.12M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.19M | { | 26 | 4.19M | const uint8_t *orig_p = p; | 27 | 4.19M | uint64_t Value = 0; | 28 | 4.19M | unsigned Shift = 0; | 29 | 4.37M | do { | 30 | 4.37M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.37M | Shift += 7; | 32 | 4.37M | } while (*p++ >= 128); | 33 | 4.19M | if (n) | 34 | 4.19M | *n = (unsigned)(p - orig_p); | 35 | 4.19M | return Value; | 36 | 4.19M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 23.3M | { | 26 | 23.3M | const uint8_t *orig_p = p; | 27 | 23.3M | uint64_t Value = 0; | 28 | 23.3M | unsigned Shift = 0; | 29 | 25.8M | do { | 30 | 25.8M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 25.8M | Shift += 7; | 32 | 25.8M | } while (*p++ >= 128); | 33 | 23.3M | if (n) | 34 | 23.3M | *n = (unsigned)(p - orig_p); | 35 | 23.3M | return Value; | 36 | 23.3M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 11.0M | { | 26 | 11.0M | const uint8_t *orig_p = p; | 27 | 11.0M | uint64_t Value = 0; | 28 | 11.0M | unsigned Shift = 0; | 29 | 12.1M | do { | 30 | 12.1M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 12.1M | Shift += 7; | 32 | 12.1M | } while (*p++ >= 128); | 33 | 11.0M | if (n) | 34 | 11.0M | *n = (unsigned)(p - orig_p); | 35 | 11.0M | return Value; | 36 | 11.0M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.25M | { | 26 | 4.25M | const uint8_t *orig_p = p; | 27 | 4.25M | uint64_t Value = 0; | 28 | 4.25M | unsigned Shift = 0; | 29 | 4.41M | do { | 30 | 4.41M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.41M | Shift += 7; | 32 | 4.41M | } while (*p++ >= 128); | 33 | 4.25M | if (n) | 34 | 4.25M | *n = (unsigned)(p - orig_p); | 35 | 4.25M | return Value; | 36 | 4.25M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 6.71M | { | 26 | 6.71M | const uint8_t *orig_p = p; | 27 | 6.71M | uint64_t Value = 0; | 28 | 6.71M | unsigned Shift = 0; | 29 | 6.98M | do { | 30 | 6.98M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 6.98M | Shift += 7; | 32 | 6.98M | } while (*p++ >= 128); | 33 | 6.71M | if (n) | 34 | 6.71M | *n = (unsigned)(p - orig_p); | 35 | 6.71M | return Value; | 36 | 6.71M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.31M | { | 26 | 2.31M | const uint8_t *orig_p = p; | 27 | 2.31M | uint64_t Value = 0; | 28 | 2.31M | unsigned Shift = 0; | 29 | 2.36M | do { | 30 | 2.36M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.36M | Shift += 7; | 32 | 2.36M | } while (*p++ >= 128); | 33 | 2.31M | if (n) | 34 | 2.31M | *n = (unsigned)(p - orig_p); | 35 | 2.31M | return Value; | 36 | 2.31M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 8.72M | { | 26 | 8.72M | const uint8_t *orig_p = p; | 27 | 8.72M | uint64_t Value = 0; | 28 | 8.72M | unsigned Shift = 0; | 29 | 12.2M | do { | 30 | 12.2M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 12.2M | Shift += 7; | 32 | 12.2M | } while (*p++ >= 128); | 33 | 8.72M | if (n) | 34 | 8.72M | *n = (unsigned)(p - orig_p); | 35 | 8.72M | return Value; | 36 | 8.72M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 366k | { | 26 | 366k | const uint8_t *orig_p = p; | 27 | 366k | uint64_t Value = 0; | 28 | 366k | unsigned Shift = 0; | 29 | 473k | do { | 30 | 473k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 473k | Shift += 7; | 32 | 473k | } while (*p++ >= 128); | 33 | 366k | if (n) | 34 | 366k | *n = (unsigned)(p - orig_p); | 35 | 366k | return Value; | 36 | 366k | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |