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

          Line data    Source code
       1             : //===-- llvm/CodeGen/LowLevelType.cpp -------------------------------------===//
       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             : /// \file This file implements the more header-heavy bits of the LLT class to
      11             : /// avoid polluting users' namespaces.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/CodeGen/LowLevelType.h"
      16             : #include "llvm/IR/DataLayout.h"
      17             : #include "llvm/IR/DerivedTypes.h"
      18             : #include "llvm/Support/raw_ostream.h"
      19             : using namespace llvm;
      20             : 
      21        4237 : LLT llvm::getLLTForType(Type &Ty, const DataLayout &DL) {
      22        4237 :   if (auto VTy = dyn_cast<VectorType>(&Ty)) {
      23         540 :     auto NumElements = VTy->getNumElements();
      24         540 :     LLT ScalarTy = getLLTForType(*VTy->getElementType(), DL);
      25         540 :     if (NumElements == 1)
      26           9 :       return ScalarTy;
      27         531 :     return LLT::vector(NumElements, ScalarTy);
      28        3697 :   } else if (auto PTy = dyn_cast<PointerType>(&Ty)) {
      29        1052 :     return LLT::pointer(PTy->getAddressSpace(), DL.getTypeSizeInBits(&Ty));
      30        3171 :   } else if (Ty.isSized()) {
      31             :     // Aggregates are no different from real scalars as far as GlobalISel is
      32             :     // concerned.
      33        3171 :     auto SizeInBits = DL.getTypeSizeInBits(&Ty);
      34             :     assert(SizeInBits != 0 && "invalid zero-sized type");
      35        3171 :     return LLT::scalar(SizeInBits);
      36             :   }
      37           0 :   return LLT();
      38             : }

Generated by: LCOV version 1.13