/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 | 57.7M | { |
26 | 57.7M | const uint8_t *orig_p = p; |
27 | 57.7M | uint64_t Value = 0; |
28 | 57.7M | unsigned Shift = 0; |
29 | 65.2M | do { |
30 | 65.2M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 65.2M | Shift += 7; |
32 | 65.2M | } while (*p++ >= 128); |
33 | 57.7M | if (n) |
34 | 57.7M | *n = (unsigned)(p - orig_p); |
35 | 57.7M | return Value; |
36 | 57.7M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 709k | { | 26 | 709k | const uint8_t *orig_p = p; | 27 | 709k | uint64_t Value = 0; | 28 | 709k | unsigned Shift = 0; | 29 | 779k | do { | 30 | 779k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 779k | Shift += 7; | 32 | 779k | } while (*p++ >= 128); | 33 | 709k | if (n) | 34 | 709k | *n = (unsigned)(p - orig_p); | 35 | 709k | return Value; | 36 | 709k | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 964k | { | 26 | 964k | const uint8_t *orig_p = p; | 27 | 964k | uint64_t Value = 0; | 28 | 964k | unsigned Shift = 0; | 29 | 984k | do { | 30 | 984k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 984k | Shift += 7; | 32 | 984k | } while (*p++ >= 128); | 33 | 964k | if (n) | 34 | 964k | *n = (unsigned)(p - orig_p); | 35 | 964k | return Value; | 36 | 964k | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.01M | { | 26 | 2.01M | const uint8_t *orig_p = p; | 27 | 2.01M | uint64_t Value = 0; | 28 | 2.01M | unsigned Shift = 0; | 29 | 2.10M | do { | 30 | 2.10M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.10M | Shift += 7; | 32 | 2.10M | } while (*p++ >= 128); | 33 | 2.01M | if (n) | 34 | 2.01M | *n = (unsigned)(p - orig_p); | 35 | 2.01M | return Value; | 36 | 2.01M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 29.8M | { | 26 | 29.8M | const uint8_t *orig_p = p; | 27 | 29.8M | uint64_t Value = 0; | 28 | 29.8M | unsigned Shift = 0; | 29 | 33.0M | do { | 30 | 33.0M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 33.0M | Shift += 7; | 32 | 33.0M | } while (*p++ >= 128); | 33 | 29.8M | if (n) | 34 | 29.8M | *n = (unsigned)(p - orig_p); | 35 | 29.8M | return Value; | 36 | 29.8M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 6.09M | { | 26 | 6.09M | const uint8_t *orig_p = p; | 27 | 6.09M | uint64_t Value = 0; | 28 | 6.09M | unsigned Shift = 0; | 29 | 6.77M | do { | 30 | 6.77M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 6.77M | Shift += 7; | 32 | 6.77M | } while (*p++ >= 128); | 33 | 6.09M | if (n) | 34 | 6.09M | *n = (unsigned)(p - orig_p); | 35 | 6.09M | return Value; | 36 | 6.09M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.31M | { | 26 | 4.31M | const uint8_t *orig_p = p; | 27 | 4.31M | uint64_t Value = 0; | 28 | 4.31M | unsigned Shift = 0; | 29 | 4.49M | do { | 30 | 4.49M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.49M | Shift += 7; | 32 | 4.49M | } while (*p++ >= 128); | 33 | 4.31M | if (n) | 34 | 4.31M | *n = (unsigned)(p - orig_p); | 35 | 4.31M | return Value; | 36 | 4.31M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.34M | { | 26 | 3.34M | const uint8_t *orig_p = p; | 27 | 3.34M | uint64_t Value = 0; | 28 | 3.34M | unsigned Shift = 0; | 29 | 3.46M | do { | 30 | 3.46M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.46M | Shift += 7; | 32 | 3.46M | } while (*p++ >= 128); | 33 | 3.34M | if (n) | 34 | 3.34M | *n = (unsigned)(p - orig_p); | 35 | 3.34M | return Value; | 36 | 3.34M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.22M | { | 26 | 1.22M | const uint8_t *orig_p = p; | 27 | 1.22M | uint64_t Value = 0; | 28 | 1.22M | unsigned Shift = 0; | 29 | 1.27M | do { | 30 | 1.27M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.27M | Shift += 7; | 32 | 1.27M | } while (*p++ >= 128); | 33 | 1.22M | if (n) | 34 | 1.22M | *n = (unsigned)(p - orig_p); | 35 | 1.22M | return Value; | 36 | 1.22M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 7.27M | { | 26 | 7.27M | const uint8_t *orig_p = p; | 27 | 7.27M | uint64_t Value = 0; | 28 | 7.27M | unsigned Shift = 0; | 29 | 9.99M | do { | 30 | 9.99M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 9.99M | Shift += 7; | 32 | 9.99M | } while (*p++ >= 128); | 33 | 7.27M | if (n) | 34 | 7.27M | *n = (unsigned)(p - orig_p); | 35 | 7.27M | return Value; | 36 | 7.27M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.96M | { | 26 | 1.96M | const uint8_t *orig_p = p; | 27 | 1.96M | uint64_t Value = 0; | 28 | 1.96M | unsigned Shift = 0; | 29 | 2.33M | do { | 30 | 2.33M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.33M | Shift += 7; | 32 | 2.33M | } while (*p++ >= 128); | 33 | 1.96M | if (n) | 34 | 1.96M | *n = (unsigned)(p - orig_p); | 35 | 1.96M | return Value; | 36 | 1.96M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |