LCOV - code coverage report
Current view: top level - lib/Support - LEB128.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 14 14 100.0 %
Date: 2017-09-14 15:23:50 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- LEB128.cpp - LEB128 utility functions implementation -----*- 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 implements some utility functions for encoding SLEB128 and
      11             : // ULEB128 values.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/Support/LEB128.h"
      16             : 
      17             : namespace llvm {
      18             : 
      19             : /// Utility function to get the size of the ULEB128-encoded value.
      20      248405 : unsigned getULEB128Size(uint64_t Value) {
      21      248405 :   unsigned Size = 0;
      22             :   do {
      23      257250 :     Value >>= 7;
      24      257250 :     Size += sizeof(int8_t);
      25      257250 :   } while (Value);
      26      248405 :   return Size;
      27             : }
      28             : 
      29             : /// Utility function to get the size of the SLEB128-encoded value.
      30        3106 : unsigned getSLEB128Size(int64_t Value) {
      31        3106 :   unsigned Size = 0;
      32        3106 :   int Sign = Value >> (8 * sizeof(Value) - 1);
      33             :   bool IsMore;
      34             : 
      35             :   do {
      36        3926 :     unsigned Byte = Value & 0x7f;
      37        3926 :     Value >>= 7;
      38       10248 :     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
      39        3926 :     Size += sizeof(int8_t);
      40             :   } while (IsMore);
      41        3106 :   return Size;
      42             : }
      43             : 
      44             : }  // namespace llvm

Generated by: LCOV version 1.13