/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 | 35.6M | { |
26 | 35.6M | const uint8_t *orig_p = p; |
27 | 35.6M | uint64_t Value = 0; |
28 | 35.6M | unsigned Shift = 0; |
29 | 40.4M | do { |
30 | 40.4M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 40.4M | Shift += 7; |
32 | 40.4M | } while (*p++ >= 128); |
33 | 35.6M | if (n) |
34 | 35.6M | *n = (unsigned)(p - orig_p); |
35 | 35.6M | return Value; |
36 | 35.6M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 462k | { | 26 | 462k | const uint8_t *orig_p = p; | 27 | 462k | uint64_t Value = 0; | 28 | 462k | unsigned Shift = 0; | 29 | 508k | do { | 30 | 508k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 508k | Shift += 7; | 32 | 508k | } while (*p++ >= 128); | 33 | 462k | if (n) | 34 | 462k | *n = (unsigned)(p - orig_p); | 35 | 462k | return Value; | 36 | 462k | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 567k | { | 26 | 567k | const uint8_t *orig_p = p; | 27 | 567k | uint64_t Value = 0; | 28 | 567k | unsigned Shift = 0; | 29 | 579k | do { | 30 | 579k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 579k | Shift += 7; | 32 | 579k | } while (*p++ >= 128); | 33 | 567k | if (n) | 34 | 567k | *n = (unsigned)(p - orig_p); | 35 | 567k | return Value; | 36 | 567k | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.10M | { | 26 | 1.10M | const uint8_t *orig_p = p; | 27 | 1.10M | uint64_t Value = 0; | 28 | 1.10M | 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.10M | if (n) | 34 | 1.10M | *n = (unsigned)(p - orig_p); | 35 | 1.10M | return Value; | 36 | 1.10M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 17.3M | { | 26 | 17.3M | const uint8_t *orig_p = p; | 27 | 17.3M | uint64_t Value = 0; | 28 | 17.3M | unsigned Shift = 0; | 29 | 19.2M | do { | 30 | 19.2M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 19.2M | Shift += 7; | 32 | 19.2M | } while (*p++ >= 128); | 33 | 17.3M | if (n) | 34 | 17.3M | *n = (unsigned)(p - orig_p); | 35 | 17.3M | return Value; | 36 | 17.3M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.84M | { | 26 | 3.84M | const uint8_t *orig_p = p; | 27 | 3.84M | uint64_t Value = 0; | 28 | 3.84M | 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 | 3.84M | if (n) | 34 | 3.84M | *n = (unsigned)(p - orig_p); | 35 | 3.84M | return Value; | 36 | 3.84M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.63M | { | 26 | 2.63M | const uint8_t *orig_p = p; | 27 | 2.63M | uint64_t Value = 0; | 28 | 2.63M | unsigned Shift = 0; | 29 | 2.76M | do { | 30 | 2.76M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.76M | Shift += 7; | 32 | 2.76M | } while (*p++ >= 128); | 33 | 2.63M | if (n) | 34 | 2.63M | *n = (unsigned)(p - orig_p); | 35 | 2.63M | return Value; | 36 | 2.63M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.24M | { | 26 | 2.24M | const uint8_t *orig_p = p; | 27 | 2.24M | uint64_t Value = 0; | 28 | 2.24M | unsigned Shift = 0; | 29 | 2.32M | do { | 30 | 2.32M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.32M | Shift += 7; | 32 | 2.32M | } while (*p++ >= 128); | 33 | 2.24M | if (n) | 34 | 2.24M | *n = (unsigned)(p - orig_p); | 35 | 2.24M | return Value; | 36 | 2.24M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.02M | { | 26 | 1.02M | const uint8_t *orig_p = p; | 27 | 1.02M | uint64_t Value = 0; | 28 | 1.02M | unsigned Shift = 0; | 29 | 1.05M | do { | 30 | 1.05M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.05M | Shift += 7; | 32 | 1.05M | } while (*p++ >= 128); | 33 | 1.02M | if (n) | 34 | 1.02M | *n = (unsigned)(p - orig_p); | 35 | 1.02M | return Value; | 36 | 1.02M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.94M | { | 26 | 4.94M | const uint8_t *orig_p = p; | 27 | 4.94M | uint64_t Value = 0; | 28 | 4.94M | unsigned Shift = 0; | 29 | 6.84M | do { | 30 | 6.84M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 6.84M | Shift += 7; | 32 | 6.84M | } while (*p++ >= 128); | 33 | 4.94M | if (n) | 34 | 4.94M | *n = (unsigned)(p - orig_p); | 35 | 4.94M | return Value; | 36 | 4.94M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.44M | { | 26 | 1.44M | const uint8_t *orig_p = p; | 27 | 1.44M | uint64_t Value = 0; | 28 | 1.44M | unsigned Shift = 0; | 29 | 1.75M | do { | 30 | 1.75M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.75M | Shift += 7; | 32 | 1.75M | } while (*p++ >= 128); | 33 | 1.44M | if (n) | 34 | 1.44M | *n = (unsigned)(p - orig_p); | 35 | 1.44M | return Value; | 36 | 1.44M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |