/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.2M | { |
26 | 66.2M | const uint8_t *orig_p = p; |
27 | 66.2M | uint64_t Value = 0; |
28 | 66.2M | unsigned Shift = 0; |
29 | 75.7M | do { |
30 | 75.7M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 75.7M | Shift += 7; |
32 | 75.7M | } while (*p++ >= 128); |
33 | 66.2M | if (n) |
34 | 66.2M | *n = (unsigned)(p - orig_p); |
35 | 66.2M | return Value; |
36 | 66.2M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 777k | { | 26 | 777k | const uint8_t *orig_p = p; | 27 | 777k | uint64_t Value = 0; | 28 | 777k | unsigned Shift = 0; | 29 | 851k | do { | 30 | 851k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 851k | Shift += 7; | 32 | 851k | } while (*p++ >= 128); | 33 | 777k | if (n) | 34 | 777k | *n = (unsigned)(p - orig_p); | 35 | 777k | return Value; | 36 | 777k | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.04M | { | 26 | 1.04M | const uint8_t *orig_p = p; | 27 | 1.04M | uint64_t Value = 0; | 28 | 1.04M | unsigned Shift = 0; | 29 | 1.06M | do { | 30 | 1.06M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.06M | Shift += 7; | 32 | 1.06M | } while (*p++ >= 128); | 33 | 1.04M | if (n) | 34 | 1.04M | *n = (unsigned)(p - orig_p); | 35 | 1.04M | return Value; | 36 | 1.04M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.48M | { | 26 | 3.48M | const uint8_t *orig_p = p; | 27 | 3.48M | uint64_t Value = 0; | 28 | 3.48M | unsigned Shift = 0; | 29 | 3.63M | do { | 30 | 3.63M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.63M | Shift += 7; | 32 | 3.63M | } while (*p++ >= 128); | 33 | 3.48M | if (n) | 34 | 3.48M | *n = (unsigned)(p - orig_p); | 35 | 3.48M | return Value; | 36 | 3.48M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 28.1M | { | 26 | 28.1M | const uint8_t *orig_p = p; | 27 | 28.1M | uint64_t Value = 0; | 28 | 28.1M | unsigned Shift = 0; | 29 | 31.0M | do { | 30 | 31.0M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 31.0M | Shift += 7; | 32 | 31.0M | } while (*p++ >= 128); | 33 | 28.1M | if (n) | 34 | 28.1M | *n = (unsigned)(p - orig_p); | 35 | 28.1M | return Value; | 36 | 28.1M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 9.01M | { | 26 | 9.01M | const uint8_t *orig_p = p; | 27 | 9.01M | uint64_t Value = 0; | 28 | 9.01M | unsigned Shift = 0; | 29 | 9.96M | do { | 30 | 9.96M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 9.96M | Shift += 7; | 32 | 9.96M | } while (*p++ >= 128); | 33 | 9.01M | if (n) | 34 | 9.01M | *n = (unsigned)(p - orig_p); | 35 | 9.01M | return Value; | 36 | 9.01M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.82M | { | 26 | 4.82M | const uint8_t *orig_p = p; | 27 | 4.82M | uint64_t Value = 0; | 28 | 4.82M | unsigned Shift = 0; | 29 | 5.04M | do { | 30 | 5.04M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 5.04M | Shift += 7; | 32 | 5.04M | } while (*p++ >= 128); | 33 | 4.82M | if (n) | 34 | 4.82M | *n = (unsigned)(p - orig_p); | 35 | 4.82M | return Value; | 36 | 4.82M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.11M | { | 26 | 4.11M | const uint8_t *orig_p = p; | 27 | 4.11M | uint64_t Value = 0; | 28 | 4.11M | unsigned Shift = 0; | 29 | 4.25M | do { | 30 | 4.25M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.25M | Shift += 7; | 32 | 4.25M | } while (*p++ >= 128); | 33 | 4.11M | if (n) | 34 | 4.11M | *n = (unsigned)(p - orig_p); | 35 | 4.11M | return Value; | 36 | 4.11M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.75M | { | 26 | 1.75M | const uint8_t *orig_p = p; | 27 | 1.75M | uint64_t Value = 0; | 28 | 1.75M | unsigned Shift = 0; | 29 | 1.81M | do { | 30 | 1.81M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.81M | Shift += 7; | 32 | 1.81M | } while (*p++ >= 128); | 33 | 1.75M | if (n) | 34 | 1.75M | *n = (unsigned)(p - orig_p); | 35 | 1.75M | return Value; | 36 | 1.75M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 10.6M | { | 26 | 10.6M | const uint8_t *orig_p = p; | 27 | 10.6M | uint64_t Value = 0; | 28 | 10.6M | unsigned Shift = 0; | 29 | 14.9M | do { | 30 | 14.9M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 14.9M | Shift += 7; | 32 | 14.9M | } while (*p++ >= 128); | 33 | 10.6M | if (n) | 34 | 10.6M | *n = (unsigned)(p - orig_p); | 35 | 10.6M | return Value; | 36 | 10.6M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.44M | { | 26 | 2.44M | const uint8_t *orig_p = p; | 27 | 2.44M | uint64_t Value = 0; | 28 | 2.44M | 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.44M | if (n) | 34 | 2.44M | *n = (unsigned)(p - orig_p); | 35 | 2.44M | return Value; | 36 | 2.44M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |