/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.7M | { |
26 | 66.7M | const uint8_t *orig_p = p; |
27 | 66.7M | uint64_t Value = 0; |
28 | 66.7M | unsigned Shift = 0; |
29 | 76.0M | do { |
30 | 76.0M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 76.0M | Shift += 7; |
32 | 76.0M | } while (*p++ >= 128); |
33 | 66.7M | if (n) |
34 | 66.7M | *n = (unsigned)(p - orig_p); |
35 | 66.7M | return Value; |
36 | 66.7M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 833k | { | 26 | 833k | const uint8_t *orig_p = p; | 27 | 833k | uint64_t Value = 0; | 28 | 833k | unsigned Shift = 0; | 29 | 919k | do { | 30 | 919k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 919k | Shift += 7; | 32 | 919k | } while (*p++ >= 128); | 33 | 833k | if (n) | 34 | 833k | *n = (unsigned)(p - orig_p); | 35 | 833k | return Value; | 36 | 833k | } |
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.07M | do { | 30 | 1.07M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.07M | Shift += 7; | 32 | 1.07M | } 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 | 2.85M | { | 26 | 2.85M | const uint8_t *orig_p = p; | 27 | 2.85M | uint64_t Value = 0; | 28 | 2.85M | unsigned Shift = 0; | 29 | 2.98M | do { | 30 | 2.98M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.98M | Shift += 7; | 32 | 2.98M | } while (*p++ >= 128); | 33 | 2.85M | if (n) | 34 | 2.85M | *n = (unsigned)(p - orig_p); | 35 | 2.85M | return Value; | 36 | 2.85M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 30.7M | { | 26 | 30.7M | const uint8_t *orig_p = p; | 27 | 30.7M | uint64_t Value = 0; | 28 | 30.7M | unsigned Shift = 0; | 29 | 34.0M | do { | 30 | 34.0M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 34.0M | Shift += 7; | 32 | 34.0M | } while (*p++ >= 128); | 33 | 30.7M | if (n) | 34 | 30.7M | *n = (unsigned)(p - orig_p); | 35 | 30.7M | return Value; | 36 | 30.7M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 8.19M | { | 26 | 8.19M | const uint8_t *orig_p = p; | 27 | 8.19M | uint64_t Value = 0; | 28 | 8.19M | unsigned Shift = 0; | 29 | 9.04M | do { | 30 | 9.04M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 9.04M | Shift += 7; | 32 | 9.04M | } while (*p++ >= 128); | 33 | 8.19M | if (n) | 34 | 8.19M | *n = (unsigned)(p - orig_p); | 35 | 8.19M | return Value; | 36 | 8.19M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.85M | { | 26 | 4.85M | const uint8_t *orig_p = p; | 27 | 4.85M | uint64_t Value = 0; | 28 | 4.85M | unsigned Shift = 0; | 29 | 5.06M | do { | 30 | 5.06M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 5.06M | Shift += 7; | 32 | 5.06M | } while (*p++ >= 128); | 33 | 4.85M | if (n) | 34 | 4.85M | *n = (unsigned)(p - orig_p); | 35 | 4.85M | return Value; | 36 | 4.85M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.09M | { | 26 | 4.09M | const uint8_t *orig_p = p; | 27 | 4.09M | uint64_t Value = 0; | 28 | 4.09M | unsigned Shift = 0; | 29 | 4.23M | do { | 30 | 4.23M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.23M | Shift += 7; | 32 | 4.23M | } while (*p++ >= 128); | 33 | 4.09M | if (n) | 34 | 4.09M | *n = (unsigned)(p - orig_p); | 35 | 4.09M | return Value; | 36 | 4.09M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.73M | { | 26 | 1.73M | const uint8_t *orig_p = p; | 27 | 1.73M | uint64_t Value = 0; | 28 | 1.73M | unsigned Shift = 0; | 29 | 1.79M | do { | 30 | 1.79M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.79M | Shift += 7; | 32 | 1.79M | } while (*p++ >= 128); | 33 | 1.73M | if (n) | 34 | 1.73M | *n = (unsigned)(p - orig_p); | 35 | 1.73M | return Value; | 36 | 1.73M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 10.0M | { | 26 | 10.0M | const uint8_t *orig_p = p; | 27 | 10.0M | uint64_t Value = 0; | 28 | 10.0M | unsigned Shift = 0; | 29 | 14.0M | do { | 30 | 14.0M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 14.0M | Shift += 7; | 32 | 14.0M | } while (*p++ >= 128); | 33 | 10.0M | if (n) | 34 | 10.0M | *n = (unsigned)(p - orig_p); | 35 | 10.0M | return Value; | 36 | 10.0M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.33M | { | 26 | 2.33M | const uint8_t *orig_p = p; | 27 | 2.33M | uint64_t Value = 0; | 28 | 2.33M | unsigned Shift = 0; | 29 | 2.87M | do { | 30 | 2.87M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.87M | Shift += 7; | 32 | 2.87M | } while (*p++ >= 128); | 33 | 2.33M | if (n) | 34 | 2.33M | *n = (unsigned)(p - orig_p); | 35 | 2.33M | return Value; | 36 | 2.33M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |