/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 | 61.3M | { |
26 | 61.3M | const uint8_t *orig_p = p; |
27 | 61.3M | uint64_t Value = 0; |
28 | 61.3M | unsigned Shift = 0; |
29 | 69.9M | do { |
30 | 69.9M | Value += (uint64_t)(*p & 0x7f) << Shift; |
31 | 69.9M | Shift += 7; |
32 | 69.9M | } while (*p++ >= 128); |
33 | 61.3M | if (n) |
34 | 61.3M | *n = (unsigned)(p - orig_p); |
35 | 61.3M | return Value; |
36 | 61.3M | } Unexecuted instantiation: SparcModule.c:decodeULEB128 Unexecuted instantiation: PPCMapping.c:decodeULEB128 Unexecuted instantiation: SparcMapping.c:decodeULEB128 XCoreDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 693k | { | 26 | 693k | const uint8_t *orig_p = p; | 27 | 693k | uint64_t Value = 0; | 28 | 693k | unsigned Shift = 0; | 29 | 757k | do { | 30 | 757k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 757k | Shift += 7; | 32 | 757k | } while (*p++ >= 128); | 33 | 693k | if (n) | 34 | 693k | *n = (unsigned)(p - orig_p); | 35 | 693k | return Value; | 36 | 693k | } |
TMS320C64xDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 935k | { | 26 | 935k | const uint8_t *orig_p = p; | 27 | 935k | uint64_t Value = 0; | 28 | 935k | unsigned Shift = 0; | 29 | 959k | do { | 30 | 959k | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 959k | Shift += 7; | 32 | 959k | } while (*p++ >= 128); | 33 | 935k | if (n) | 34 | 935k | *n = (unsigned)(p - orig_p); | 35 | 935k | return Value; | 36 | 935k | } |
RISCVDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.43M | { | 26 | 2.43M | const uint8_t *orig_p = p; | 27 | 2.43M | uint64_t Value = 0; | 28 | 2.43M | unsigned Shift = 0; | 29 | 2.54M | do { | 30 | 2.54M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 2.54M | Shift += 7; | 32 | 2.54M | } while (*p++ >= 128); | 33 | 2.43M | if (n) | 34 | 2.43M | *n = (unsigned)(p - orig_p); | 35 | 2.43M | return Value; | 36 | 2.43M | } |
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128 Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128 ARMDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 28.2M | { | 26 | 28.2M | const uint8_t *orig_p = p; | 27 | 28.2M | uint64_t Value = 0; | 28 | 28.2M | unsigned Shift = 0; | 29 | 31.1M | do { | 30 | 31.1M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 31.1M | Shift += 7; | 32 | 31.1M | } while (*p++ >= 128); | 33 | 28.2M | if (n) | 34 | 28.2M | *n = (unsigned)(p - orig_p); | 35 | 28.2M | return Value; | 36 | 28.2M | } |
AArch64Disassembler.c:decodeULEB128 Line | Count | Source | 25 | 7.41M | { | 26 | 7.41M | const uint8_t *orig_p = p; | 27 | 7.41M | uint64_t Value = 0; | 28 | 7.41M | unsigned Shift = 0; | 29 | 8.19M | do { | 30 | 8.19M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 8.19M | Shift += 7; | 32 | 8.19M | } while (*p++ >= 128); | 33 | 7.41M | if (n) | 34 | 7.41M | *n = (unsigned)(p - orig_p); | 35 | 7.41M | return Value; | 36 | 7.41M | } |
MipsDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.49M | { | 26 | 4.49M | const uint8_t *orig_p = p; | 27 | 4.49M | uint64_t Value = 0; | 28 | 4.49M | unsigned Shift = 0; | 29 | 4.69M | do { | 30 | 4.69M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.69M | Shift += 7; | 32 | 4.69M | } while (*p++ >= 128); | 33 | 4.49M | if (n) | 34 | 4.49M | *n = (unsigned)(p - orig_p); | 35 | 4.49M | return Value; | 36 | 4.49M | } |
PPCDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 4.04M | { | 26 | 4.04M | const uint8_t *orig_p = p; | 27 | 4.04M | uint64_t Value = 0; | 28 | 4.04M | unsigned Shift = 0; | 29 | 4.18M | do { | 30 | 4.18M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 4.18M | Shift += 7; | 32 | 4.18M | } while (*p++ >= 128); | 33 | 4.04M | if (n) | 34 | 4.04M | *n = (unsigned)(p - orig_p); | 35 | 4.04M | return Value; | 36 | 4.04M | } |
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 SparcDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 1.47M | { | 26 | 1.47M | const uint8_t *orig_p = p; | 27 | 1.47M | uint64_t Value = 0; | 28 | 1.47M | unsigned Shift = 0; | 29 | 1.51M | do { | 30 | 1.51M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 1.51M | Shift += 7; | 32 | 1.51M | } while (*p++ >= 128); | 33 | 1.47M | if (n) | 34 | 1.47M | *n = (unsigned)(p - orig_p); | 35 | 1.47M | return Value; | 36 | 1.47M | } |
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128 Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128 SystemZDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 9.02M | { | 26 | 9.02M | const uint8_t *orig_p = p; | 27 | 9.02M | uint64_t Value = 0; | 28 | 9.02M | unsigned Shift = 0; | 29 | 12.6M | do { | 30 | 12.6M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 12.6M | Shift += 7; | 32 | 12.6M | } while (*p++ >= 128); | 33 | 9.02M | if (n) | 34 | 9.02M | *n = (unsigned)(p - orig_p); | 35 | 9.02M | return Value; | 36 | 9.02M | } |
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128 XtensaDisassembler.c:decodeULEB128 Line | Count | Source | 25 | 2.65M | { | 26 | 2.65M | const uint8_t *orig_p = p; | 27 | 2.65M | uint64_t Value = 0; | 28 | 2.65M | unsigned Shift = 0; | 29 | 3.27M | do { | 30 | 3.27M | Value += (uint64_t)(*p & 0x7f) << Shift; | 31 | 3.27M | Shift += 7; | 32 | 3.27M | } while (*p++ >= 128); | 33 | 2.65M | if (n) | 34 | 2.65M | *n = (unsigned)(p - orig_p); | 35 | 2.65M | return Value; | 36 | 2.65M | } |
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128 |
37 | | |
38 | | #endif // LLVM_SYSTEM_LEB128_H |