Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/CodeGen/GlobalISel/LegalizerMutations.cpp - Mutations ----------===//
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
// A library of mutation factories to use for LegalityMutation.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
14
15
using namespace llvm;
16
17
1.50M
LegalizeMutation LegalizeMutations::changeTo(unsigned TypeIdx, LLT Ty) {
18
1.50M
  return
19
1.50M
      [=](const LegalityQuery &Query) 
{ return std::make_pair(TypeIdx, Ty); }1.30M
;
20
1.50M
}
21
22
LegalizeMutation LegalizeMutations::changeTo(unsigned TypeIdx,
23
47.1k
                                             unsigned FromTypeIdx) {
24
47.1k
  return [=](const LegalityQuery &Query) {
25
4.24k
    return std::make_pair(TypeIdx, Query.Types[FromTypeIdx]);
26
4.24k
  };
27
47.1k
}
28
29
LegalizeMutation LegalizeMutations::changeElementTo(unsigned TypeIdx,
30
0
                                                    unsigned FromTypeIdx) {
31
0
  return [=](const LegalityQuery &Query) {
32
0
    const LLT OldTy = Query.Types[TypeIdx];
33
0
    const LLT NewTy = Query.Types[FromTypeIdx];
34
0
    return std::make_pair(TypeIdx, OldTy.changeElementType(NewTy));
35
0
  };
36
0
}
37
38
LegalizeMutation LegalizeMutations::changeElementTo(unsigned TypeIdx,
39
65.5k
                                                    LLT NewEltTy) {
40
65.5k
  return [=](const LegalityQuery &Query) {
41
163
    const LLT OldTy = Query.Types[TypeIdx];
42
163
    return std::make_pair(TypeIdx, OldTy.changeElementType(NewEltTy));
43
163
  };
44
65.5k
}
45
46
LegalizeMutation LegalizeMutations::widenScalarOrEltToNextPow2(unsigned TypeIdx,
47
383k
                                                               unsigned Min) {
48
383k
  return [=](const LegalityQuery &Query) {
49
167
    const LLT Ty = Query.Types[TypeIdx];
50
167
    unsigned NewEltSizeInBits =
51
167
        std::max(1u << Log2_32_Ceil(Ty.getScalarSizeInBits()), Min);
52
167
    return std::make_pair(TypeIdx, Ty.changeElementSize(NewEltSizeInBits));
53
167
  };
54
383k
}
55
56
LegalizeMutation LegalizeMutations::moreElementsToNextPow2(unsigned TypeIdx,
57
18.2k
                                                           unsigned Min) {
58
18.2k
  return [=](const LegalityQuery &Query) {
59
2
    const LLT VecTy = Query.Types[TypeIdx];
60
2
    unsigned NewNumElements =
61
2
        std::max(1u << Log2_32_Ceil(VecTy.getNumElements()), Min);
62
2
    return std::make_pair(TypeIdx,
63
2
                          LLT::vector(NewNumElements, VecTy.getElementType()));
64
2
  };
65
18.2k
}
66
67
239k
LegalizeMutation LegalizeMutations::scalarize(unsigned TypeIdx) {
68
239k
  return [=](const LegalityQuery &Query) {
69
1.55k
    return std::make_pair(TypeIdx, Query.Types[TypeIdx].getElementType());
70
1.55k
  };
71
239k
}