/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 | 88.2M | { |
26 | 88.2M | const uint8_t *orig_p = p; |
27 | 88.2M | uint64_t Value = 0; |
28 | 88.2M | unsigned Shift = 0; |
29 | 98.6M | do { |
30 | 98.6M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 98.6M | Shift += 7; |
32 | 98.6M | } while (*p++ >= 128); |
33 | 88.2M | if (n) |
34 | 88.2M | *n = (unsigned)(p - orig_p); |
35 | 88.2M | return Value; |
36 | 88.2M | } Unexecuted instantiation: PPCModule.c:decodeULEB128 MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 5.53M | { | 26 | 5.53M | const uint8_t *orig_p = p; | 27 | 5.53M | uint64_t Value = 0; | 28 | 5.53M | unsigned Shift = 0; | 29 | 5.74M | do { | 30 | 5.74M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 5.74M | Shift += 7; | 32 | 5.74M | } while (*p++ >= 128); | 33 | 5.53M | if (n) | 34 | 5.53M | *n = (unsigned)(p - orig_p); | 35 | 5.53M | return Value; | 36 | 5.53M | } |
Unexecuted instantiation: PPCMapping.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.08M | { | 26 | 2.08M | const uint8_t *orig_p = p; | 27 | 2.08M | uint64_t Value = 0; | 28 | 2.08M | unsigned Shift = 0; | 29 | 2.14M | do { | 30 | 2.14M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.14M | Shift += 7; | 32 | 2.14M | } while (*p++ >= 128); | 33 | 2.08M | if (n) | 34 | 2.08M | *n = (unsigned)(p - orig_p); | 35 | 2.08M | return Value; | 36 | 2.08M | } |
SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 7.79M | { | 26 | 7.79M | const uint8_t *orig_p = p; | 27 | 7.79M | uint64_t Value = 0; | 28 | 7.79M | unsigned Shift = 0; | 29 | 10.5M | do { | 30 | 10.5M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 10.5M | Shift += 7; | 32 | 10.5M | } while (*p++ >= 128); | 33 | 7.79M | if (n) | 34 | 7.79M | *n = (unsigned)(p - orig_p); | 35 | 7.79M | return Value; | 36 | 7.79M | } |
XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.69M | { | 26 | 1.69M | const uint8_t *orig_p = p; | 27 | 1.69M | uint64_t Value = 0; | 28 | 1.69M | unsigned Shift = 0; | 29 | 1.90M | do { | 30 | 1.90M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.90M | Shift += 7; | 32 | 1.90M | } while (*p++ >= 128); | 33 | 1.69M | if (n) | 34 | 1.69M | *n = (unsigned)(p - orig_p); | 35 | 1.69M | return Value; | 36 | 1.69M | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.68M | { | 26 | 1.68M | const uint8_t *orig_p = p; | 27 | 1.68M | uint64_t Value = 0; | 28 | 1.68M | unsigned Shift = 0; | 29 | 1.72M | do { | 30 | 1.72M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.72M | Shift += 7; | 32 | 1.72M | } while (*p++ >= 128); | 33 | 1.68M | if (n) | 34 | 1.68M | *n = (unsigned)(p - orig_p); | 35 | 1.68M | return Value; | 36 | 1.68M | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.80M | { | 26 | 2.80M | const uint8_t *orig_p = p; | 27 | 2.80M | uint64_t Value = 0; | 28 | 2.80M | unsigned Shift = 0; | 29 | 2.93M | do { | 30 | 2.93M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.93M | Shift += 7; | 32 | 2.93M | } while (*p++ >= 128); | 33 | 2.80M | if (n) | 34 | 2.80M | *n = (unsigned)(p - orig_p); | 35 | 2.80M | return Value; | 36 | 2.80M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 50.2M | { | 26 | 50.2M | const uint8_t *orig_p = p; | 27 | 50.2M | uint64_t Value = 0; | 28 | 50.2M | unsigned Shift = 0; | 29 | 55.8M | do { | 30 | 55.8M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 55.8M | Shift += 7; | 32 | 55.8M | } while (*p++ >= 128); | 33 | 50.2M | if (n) | 34 | 50.2M | *n = (unsigned)(p - orig_p); | 35 | 50.2M | return Value; | 36 | 50.2M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 9.86M | { | 26 | 9.86M | const uint8_t *orig_p = p; | 27 | 9.86M | uint64_t Value = 0; | 28 | 9.86M | unsigned Shift = 0; | 29 | 10.8M | do { | 30 | 10.8M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 10.8M | Shift += 7; | 32 | 10.8M | } while (*p++ >= 128); | 33 | 9.86M | if (n) | 34 | 9.86M | *n = (unsigned)(p - orig_p); | 35 | 9.86M | return Value; | 36 | 9.86M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 6.57M | { | 26 | 6.57M | const uint8_t *orig_p = p; | 27 | 6.57M | uint64_t Value = 0; | 28 | 6.57M | 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 | 6.57M | if (n) | 34 | 6.57M | *n = (unsigned)(p - orig_p); | 35 | 6.57M | return Value; | 36 | 6.57M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |