/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 | 73.7M | { |
26 | 73.7M | const uint8_t *orig_p = p; |
27 | 73.7M | uint64_t Value = 0; |
28 | 73.7M | unsigned Shift = 0; |
29 | 82.1M | do { |
30 | 82.1M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 82.1M | Shift += 7; |
32 | 82.1M | } while (*p++ >= 128); |
33 | 73.7M | if (n) |
34 | 73.7M | *n = (unsigned)(p - orig_p); |
35 | 73.7M | return Value; |
36 | 73.7M | } Unexecuted instantiation: PPCModule.c:decodeULEB128 AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 9.23M | { | 26 | 9.23M | const uint8_t *orig_p = p; | 27 | 9.23M | uint64_t Value = 0; | 28 | 9.23M | unsigned Shift = 0; | 29 | 10.1M | do { | 30 | 10.1M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 10.1M | Shift += 7; | 32 | 10.1M | } while (*p++ >= 128); | 33 | 9.23M | if (n) | 34 | 9.23M | *n = (unsigned)(p - orig_p); | 35 | 9.23M | return Value; | 36 | 9.23M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.87M | { | 26 | 4.87M | const uint8_t *orig_p = p; | 27 | 4.87M | uint64_t Value = 0; | 28 | 4.87M | 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.87M | if (n) | 34 | 4.87M | *n = (unsigned)(p - orig_p); | 35 | 4.87M | return Value; | 36 | 4.87M | } |
Unexecuted instantiation: PPCMapping.c:decodeULEB128 SparcDisassembler.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.06M | do { | 30 | 2.06M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.06M | Shift += 7; | 32 | 2.06M | } while (*p++ >= 128); | 33 | 2.01M | if (n) | 34 | 2.01M | *n = (unsigned)(p - orig_p); | 35 | 2.01M | return Value; | 36 | 2.01M | } |
SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 7.22M | { | 26 | 7.22M | const uint8_t *orig_p = p; | 27 | 7.22M | uint64_t Value = 0; | 28 | 7.22M | unsigned Shift = 0; | 29 | 9.74M | do { | 30 | 9.74M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 9.74M | Shift += 7; | 32 | 9.74M | } while (*p++ >= 128); | 33 | 7.22M | if (n) | 34 | 7.22M | *n = (unsigned)(p - orig_p); | 35 | 7.22M | return Value; | 36 | 7.22M | } |
XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.39M | { | 26 | 1.39M | const uint8_t *orig_p = p; | 27 | 1.39M | uint64_t Value = 0; | 28 | 1.39M | unsigned Shift = 0; | 29 | 1.54M | do { | 30 | 1.54M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.54M | Shift += 7; | 32 | 1.54M | } while (*p++ >= 128); | 33 | 1.39M | if (n) | 34 | 1.39M | *n = (unsigned)(p - orig_p); | 35 | 1.39M | return Value; | 36 | 1.39M | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.36M | { | 26 | 1.36M | const uint8_t *orig_p = p; | 27 | 1.36M | uint64_t Value = 0; | 28 | 1.36M | unsigned Shift = 0; | 29 | 1.39M | do { | 30 | 1.39M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.39M | Shift += 7; | 32 | 1.39M | } while (*p++ >= 128); | 33 | 1.36M | if (n) | 34 | 1.36M | *n = (unsigned)(p - orig_p); | 35 | 1.36M | return Value; | 36 | 1.36M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 3.26M | { | 26 | 3.26M | const uint8_t *orig_p = p; | 27 | 3.26M | uint64_t Value = 0; | 28 | 3.26M | unsigned Shift = 0; | 29 | 3.40M | do { | 30 | 3.40M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.40M | Shift += 7; | 32 | 3.40M | } while (*p++ >= 128); | 33 | 3.26M | if (n) | 34 | 3.26M | *n = (unsigned)(p - orig_p); | 35 | 3.26M | return Value; | 36 | 3.26M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 39.1M | { | 26 | 39.1M | const uint8_t *orig_p = p; | 27 | 39.1M | uint64_t Value = 0; | 28 | 39.1M | unsigned Shift = 0; | 29 | 43.3M | do { | 30 | 43.3M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 43.3M | Shift += 7; | 32 | 43.3M | } while (*p++ >= 128); | 33 | 39.1M | if (n) | 34 | 39.1M | *n = (unsigned)(p - orig_p); | 35 | 39.1M | return Value; | 36 | 39.1M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 5.23M | { | 26 | 5.23M | const uint8_t *orig_p = p; | 27 | 5.23M | uint64_t Value = 0; | 28 | 5.23M | unsigned Shift = 0; | 29 | 5.43M | do { | 30 | 5.43M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 5.43M | Shift += 7; | 32 | 5.43M | } while (*p++ >= 128); | 33 | 5.23M | if (n) | 34 | 5.23M | *n = (unsigned)(p - orig_p); | 35 | 5.23M | return Value; | 36 | 5.23M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |