Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/CodeGen/GlobalISel/LegalizerPredicates.cpp - Predicates --------===//
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 predicate factories to use for LegalityPredicate.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
14
15
using namespace llvm;
16
17
7.44k
LegalityPredicate LegalityPredicates::typeIs(unsigned TypeIdx, LLT Type) {
18
7.44k
  return
19
7.44k
      [=](const LegalityQuery &Query) 
{ return Query.Types[TypeIdx] == Type; }29
;
20
7.44k
}
21
22
LegalityPredicate
23
LegalityPredicates::typeInSet(unsigned TypeIdx,
24
1.15M
                              std::initializer_list<LLT> TypesInit) {
25
1.15M
  SmallVector<LLT, 4> Types = TypesInit;
26
6.16M
  return [=](const LegalityQuery &Query) {
27
6.16M
    return std::find(Types.begin(), Types.end(), Query.Types[TypeIdx]) != Types.end();
28
6.16M
  };
29
1.15M
}
30
31
LegalityPredicate LegalityPredicates::typePairInSet(
32
    unsigned TypeIdx0, unsigned TypeIdx1,
33
331k
    std::initializer_list<std::pair<LLT, LLT>> TypesInit) {
34
331k
  SmallVector<std::pair<LLT, LLT>, 4> Types = TypesInit;
35
4.24M
  return [=](const LegalityQuery &Query) {
36
4.24M
    std::pair<LLT, LLT> Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1]};
37
4.24M
    return std::find(Types.begin(), Types.end(), Match) != Types.end();
38
4.24M
  };
39
331k
}
40
41
LegalityPredicate LegalityPredicates::typePairAndMemDescInSet(
42
    unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx,
43
76.4k
    std::initializer_list<TypePairAndMemDesc> TypesAndMemDescInit) {
44
76.4k
  SmallVector<TypePairAndMemDesc, 4> TypesAndMemDesc = TypesAndMemDescInit;
45
2.06M
  return [=](const LegalityQuery &Query) {
46
2.06M
    TypePairAndMemDesc Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1],
47
2.06M
                                Query.MMODescrs[MMOIdx].SizeInBits,
48
2.06M
                                Query.MMODescrs[MMOIdx].AlignInBits};
49
2.06M
    return std::find_if(
50
2.06M
      TypesAndMemDesc.begin(), TypesAndMemDesc.end(),
51
8.62M
      [=](const TypePairAndMemDesc &Entry) ->bool {
52
8.62M
        return Match.isCompatible(Entry);
53
8.62M
      }) != TypesAndMemDesc.end();
54
2.06M
  };
55
76.4k
}
56
57
0
LegalityPredicate LegalityPredicates::isScalar(unsigned TypeIdx) {
58
0
  return [=](const LegalityQuery &Query) {
59
0
    return Query.Types[TypeIdx].isScalar();
60
0
  };
61
0
}
62
63
184k
LegalityPredicate LegalityPredicates::isVector(unsigned TypeIdx) {
64
184k
  return [=](const LegalityQuery &Query) {
65
3.04k
    return Query.Types[TypeIdx].isVector();
66
3.04k
  };
67
184k
}
68
69
21.8k
LegalityPredicate LegalityPredicates::isPointer(unsigned TypeIdx) {
70
21.8k
  return [=](const LegalityQuery &Query) {
71
27
    return Query.Types[TypeIdx].isPointer();
72
27
  };
73
21.8k
}
74
75
LegalityPredicate LegalityPredicates::isPointer(unsigned TypeIdx,
76
0
                                                unsigned AddrSpace) {
77
0
  return [=](const LegalityQuery &Query) {
78
0
    LLT Ty = Query.Types[TypeIdx];
79
0
    return Ty.isPointer() && Ty.getAddressSpace() == AddrSpace;
80
0
  };
81
0
}
82
83
LegalityPredicate LegalityPredicates::narrowerThan(unsigned TypeIdx,
84
850k
                                                   unsigned Size) {
85
1.45M
  return [=](const LegalityQuery &Query) {
86
1.45M
    const LLT QueryTy = Query.Types[TypeIdx];
87
1.45M
    return QueryTy.isScalar() && 
QueryTy.getSizeInBits() < Size1.44M
;
88
1.45M
  };
89
850k
}
90
91
LegalityPredicate LegalityPredicates::widerThan(unsigned TypeIdx,
92
655k
                                                unsigned Size) {
93
655k
  return [=](const LegalityQuery &Query) {
94
146k
    const LLT QueryTy = Query.Types[TypeIdx];
95
146k
    return QueryTy.isScalar() && 
QueryTy.getSizeInBits() > Size139k
;
96
146k
  };
97
655k
}
98
99
LegalityPredicate LegalityPredicates::scalarOrEltNarrowerThan(unsigned TypeIdx,
100
25.4k
                                                              unsigned Size) {
101
25.4k
  return [=](const LegalityQuery &Query) {
102
293
    const LLT QueryTy = Query.Types[TypeIdx];
103
293
    return QueryTy.getScalarSizeInBits() < Size;
104
293
  };
105
25.4k
}
106
107
LegalityPredicate LegalityPredicates::scalarOrEltWiderThan(unsigned TypeIdx,
108
3.64k
                                                           unsigned Size) {
109
3.64k
  return [=](const LegalityQuery &Query) {
110
138
    const LLT QueryTy = Query.Types[TypeIdx];
111
138
    return QueryTy.getScalarSizeInBits() > Size;
112
138
  };
113
3.64k
}
114
115
9.10k
LegalityPredicate LegalityPredicates::scalarOrEltSizeNotPow2(unsigned TypeIdx) {
116
9.10k
  return [=](const LegalityQuery &Query) {
117
18
    const LLT QueryTy = Query.Types[TypeIdx];
118
18
    return !isPowerOf2_32(QueryTy.getScalarSizeInBits());
119
18
  };
120
9.10k
}
121
122
359k
LegalityPredicate LegalityPredicates::sizeNotPow2(unsigned TypeIdx) {
123
359k
  return [=](const LegalityQuery &Query) {
124
11.7k
    const LLT QueryTy = Query.Types[TypeIdx];
125
11.7k
    return QueryTy.isScalar() && 
!isPowerOf2_32(QueryTy.getSizeInBits())8.25k
;
126
11.7k
  };
127
359k
}
128
129
LegalityPredicate LegalityPredicates::sameSize(unsigned TypeIdx0,
130
7.28k
                                               unsigned TypeIdx1) {
131
7.28k
  return [=](const LegalityQuery &Query) {
132
31
    return Query.Types[TypeIdx0].getSizeInBits() ==
133
31
           Query.Types[TypeIdx1].getSizeInBits();
134
31
  };
135
7.28k
}
136
137
37.6k
LegalityPredicate LegalityPredicates::memSizeInBytesNotPow2(unsigned MMOIdx) {
138
37.6k
  return [=](const LegalityQuery &Query) {
139
6.57k
    return !isPowerOf2_32(Query.MMODescrs[MMOIdx].SizeInBits / 8);
140
6.57k
  };
141
37.6k
}
142
143
18.2k
LegalityPredicate LegalityPredicates::numElementsNotPow2(unsigned TypeIdx) {
144
18.2k
  return [=](const LegalityQuery &Query) {
145
59
    const LLT QueryTy = Query.Types[TypeIdx];
146
59
    return QueryTy.isVector() && 
!isPowerOf2_32(QueryTy.getNumElements())55
;
147
59
  };
148
18.2k
}
149
150
LegalityPredicate LegalityPredicates::atomicOrderingAtLeastOrStrongerThan(
151
108
    unsigned MMOIdx, AtomicOrdering Ordering) {
152
108
  return [=](const LegalityQuery &Query) {
153
12
    return isAtLeastOrStrongerThan(Query.MMODescrs[MMOIdx].Ordering, Ordering);
154
12
  };
155
108
}