Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/LowLevelType.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- llvm/CodeGen/LowLevelType.cpp -------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
/// \file This file implements the more header-heavy bits of the LLT class to
10
/// avoid polluting users' namespaces.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "llvm/CodeGen/LowLevelType.h"
15
#include "llvm/IR/DataLayout.h"
16
#include "llvm/IR/DerivedTypes.h"
17
#include "llvm/Support/raw_ostream.h"
18
using namespace llvm;
19
20
20.6M
LLT llvm::getLLTForType(Type &Ty, const DataLayout &DL) {
21
20.6M
  if (auto VTy = dyn_cast<VectorType>(&Ty)) {
22
258k
    auto NumElements = VTy->getNumElements();
23
258k
    LLT ScalarTy = getLLTForType(*VTy->getElementType(), DL);
24
258k
    if (NumElements == 1)
25
2.30k
      return ScalarTy;
26
256k
    return LLT::vector(NumElements, ScalarTy);
27
20.4M
  } else if (auto PTy = dyn_cast<PointerType>(&Ty)) {
28
8.97M
    return LLT::pointer(PTy->getAddressSpace(), DL.getTypeSizeInBits(&Ty));
29
11.4M
  } else if (Ty.isSized()) {
30
11.4M
    // Aggregates are no different from real scalars as far as GlobalISel is
31
11.4M
    // concerned.
32
11.4M
    auto SizeInBits = DL.getTypeSizeInBits(&Ty);
33
11.4M
    assert(SizeInBits != 0 && "invalid zero-sized type");
34
11.4M
    return LLT::scalar(SizeInBits);
35
11.4M
  }
36
0
  return LLT();
37
0
}