/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 | 58.4M | { | 
| 26 | 58.4M |   const uint8_t *orig_p = p; | 
| 27 | 58.4M |   uint64_t Value = 0; | 
| 28 | 58.4M |   unsigned Shift = 0; | 
| 29 | 65.0M |   do { | 
| 30 | 65.0M |     Value += (uint64_t)(*p & 0x7f) << Shift; | 
| 31 | 65.0M |     Shift += 7; | 
| 32 | 65.0M |   } while (*p++ >= 128); | 
| 33 | 58.4M |   if (n) | 
| 34 | 58.4M |     *n = (unsigned)(p - orig_p); | 
| 35 | 58.4M |   return Value; | 
| 36 | 58.4M | } Unexecuted instantiation: PPCModule.c:decodeULEB128AArch64Disassembler.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.14M |   do { |  | 30 | 8.14M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 8.14M |     Shift += 7; |  | 32 | 8.14M |   } 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 | 3.50M | { |  | 26 | 3.50M |   const uint8_t *orig_p = p; |  | 27 | 3.50M |   uint64_t Value = 0; |  | 28 | 3.50M |   unsigned Shift = 0; |  | 29 | 3.64M |   do { |  | 30 | 3.64M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 3.64M |     Shift += 7; |  | 32 | 3.64M |   } while (*p++ >= 128); |  | 33 | 3.50M |   if (n) |  | 34 | 3.50M |     *n = (unsigned)(p - orig_p); |  | 35 | 3.50M |   return Value; |  | 36 | 3.50M | } | 
Unexecuted instantiation: PPCMapping.c:decodeULEB128SparcDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 1.59M | { |  | 26 | 1.59M |   const uint8_t *orig_p = p; |  | 27 | 1.59M |   uint64_t Value = 0; |  | 28 | 1.59M |   unsigned Shift = 0; |  | 29 | 1.63M |   do { |  | 30 | 1.63M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 1.63M |     Shift += 7; |  | 32 | 1.63M |   } while (*p++ >= 128); |  | 33 | 1.59M |   if (n) |  | 34 | 1.59M |     *n = (unsigned)(p - orig_p); |  | 35 | 1.59M |   return Value; |  | 36 | 1.59M | } | 
SystemZDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 5.50M | { |  | 26 | 5.50M |   const uint8_t *orig_p = p; |  | 27 | 5.50M |   uint64_t Value = 0; |  | 28 | 5.50M |   unsigned Shift = 0; |  | 29 | 7.42M |   do { |  | 30 | 7.42M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 7.42M |     Shift += 7; |  | 32 | 7.42M |   } while (*p++ >= 128); |  | 33 | 5.50M |   if (n) |  | 34 | 5.50M |     *n = (unsigned)(p - orig_p); |  | 35 | 5.50M |   return Value; |  | 36 | 5.50M | } | 
XCoreDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 823k | { |  | 26 | 823k |   const uint8_t *orig_p = p; |  | 27 | 823k |   uint64_t Value = 0; |  | 28 | 823k |   unsigned Shift = 0; |  | 29 | 913k |   do { |  | 30 | 913k |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 913k |     Shift += 7; |  | 32 | 913k |   } while (*p++ >= 128); |  | 33 | 823k |   if (n) |  | 34 | 823k |     *n = (unsigned)(p - orig_p); |  | 35 | 823k |   return Value; |  | 36 | 823k | } | 
TMS320C64xDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 1.00M | { |  | 26 | 1.00M |   const uint8_t *orig_p = p; |  | 27 | 1.00M |   uint64_t Value = 0; |  | 28 | 1.00M |   unsigned Shift = 0; |  | 29 | 1.02M |   do { |  | 30 | 1.02M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 1.02M |     Shift += 7; |  | 32 | 1.02M |   } while (*p++ >= 128); |  | 33 | 1.00M |   if (n) |  | 34 | 1.00M |     *n = (unsigned)(p - orig_p); |  | 35 | 1.00M |   return Value; |  | 36 | 1.00M | } | 
RISCVDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 2.66M | { |  | 26 | 2.66M |   const uint8_t *orig_p = p; |  | 27 | 2.66M |   uint64_t Value = 0; |  | 28 | 2.66M |   unsigned Shift = 0; |  | 29 | 2.77M |   do { |  | 30 | 2.77M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 2.77M |     Shift += 7; |  | 32 | 2.77M |   } while (*p++ >= 128); |  | 33 | 2.66M |   if (n) |  | 34 | 2.66M |     *n = (unsigned)(p - orig_p); |  | 35 | 2.66M |   return Value; |  | 36 | 2.66M | } | 
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128ARMDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 32.0M | { |  | 26 | 32.0M |   const uint8_t *orig_p = p; |  | 27 | 32.0M |   uint64_t Value = 0; |  | 28 | 32.0M |   unsigned Shift = 0; |  | 29 | 35.4M |   do { |  | 30 | 35.4M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 35.4M |     Shift += 7; |  | 32 | 35.4M |   } while (*p++ >= 128); |  | 33 | 32.0M |   if (n) |  | 34 | 32.0M |     *n = (unsigned)(p - orig_p); |  | 35 | 32.0M |   return Value; |  | 36 | 32.0M | } | 
PPCDisassembler.c:decodeULEB128| Line | Count | Source |  | 25 | 3.91M | { |  | 26 | 3.91M |   const uint8_t *orig_p = p; |  | 27 | 3.91M |   uint64_t Value = 0; |  | 28 | 3.91M |   unsigned Shift = 0; |  | 29 | 4.05M |   do { |  | 30 | 4.05M |     Value += (uint64_t)(*p & 0x7f) << Shift; |  | 31 | 4.05M |     Shift += 7; |  | 32 | 4.05M |   } while (*p++ >= 128); |  | 33 | 3.91M |   if (n) |  | 34 | 3.91M |     *n = (unsigned)(p - orig_p); |  | 35 | 3.91M |   return Value; |  | 36 | 3.91M | } | 
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128 | 
| 37 |  |  | 
| 38 |  | #endif  // LLVM_SYSTEM_LEB128_H |