LCOV - code coverage report
Current view: top level - lib/CodeGen/GlobalISel - LegalityPredicates.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 39 45 86.7 %
Date: 2018-06-17 00:07:59 Functions: 21 23 91.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- lib/CodeGen/GlobalISel/LegalizerPredicates.cpp - Predicates --------===//
       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             : // A library of predicate factories to use for LegalityPredicate.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
      15             : 
      16             : using namespace llvm;
      17             : 
      18             : LegalityPredicate
      19       54262 : LegalityPredicates::all(LegalityPredicate P0, LegalityPredicate P1) {
      20      971677 :   return [=](const LegalityQuery &Query) {
      21        1155 :     return P0(Query) && P1(Query);
      22       54845 :   };
      23             : }
      24             : 
      25             : LegalityPredicate
      26      222377 : LegalityPredicates::typeInSet(unsigned TypeIdx,
      27             :                               std::initializer_list<LLT> TypesInit) {
      28             :   SmallVector<LLT, 4> Types = TypesInit;
      29     3005311 :   return [=](const LegalityQuery &Query) {
      30        3428 :     return std::find(Types.begin(), Types.end(), Query.Types[TypeIdx]) != Types.end();
      31      670559 :   };
      32             : }
      33             : 
      34       57512 : LegalityPredicate LegalityPredicates::typePairInSet(
      35             :     unsigned TypeIdx0, unsigned TypeIdx1,
      36             :     std::initializer_list<std::pair<LLT, LLT>> TypesInit) {
      37             :   SmallVector<std::pair<LLT, LLT>, 4> Types = TypesInit;
      38      457344 :   return [=](const LegalityQuery &Query) {
      39         392 :     std::pair<LLT, LLT> Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1]};
      40         196 :     return std::find(Types.begin(), Types.end(), Match) != Types.end();
      41      172536 :   };
      42             : }
      43             : 
      44        5740 : LegalityPredicate LegalityPredicates::typePairAndMemSizeInSet(
      45             :     unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx,
      46             :     std::initializer_list<TypePairAndMemSize> TypesAndMemSizeInit) {
      47             :   SmallVector<TypePairAndMemSize, 4> TypesAndMemSize = TypesAndMemSizeInit;
      48       68950 :   return [=](const LegalityQuery &Query) {
      49         380 :     TypePairAndMemSize Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1],
      50         570 :                                 Query.MMODescrs[MMOIdx].Size};
      51             :     return std::find(TypesAndMemSize.begin(), TypesAndMemSize.end(), Match) !=
      52         190 :            TypesAndMemSize.end();
      53       22960 :   };
      54             : }
      55             : 
      56           0 : LegalityPredicate LegalityPredicates::isScalar(unsigned TypeIdx) {
      57             :   return [=](const LegalityQuery &Query) {
      58           0 :     return Query.Types[TypeIdx].isScalar();
      59           0 :   };
      60             : }
      61             : 
      62       74696 : LegalityPredicate LegalityPredicates::narrowerThan(unsigned TypeIdx,
      63             :                                                    unsigned Size) {
      64         269 :   return [=](const LegalityQuery &Query) {
      65         269 :     const LLT &QueryTy = Query.Types[TypeIdx];
      66         261 :     return QueryTy.isScalar() && QueryTy.getSizeInBits() < Size;
      67       74696 :   };
      68             : }
      69             : 
      70       75572 : LegalityPredicate LegalityPredicates::widerThan(unsigned TypeIdx,
      71             :                                                 unsigned Size) {
      72          79 :   return [=](const LegalityQuery &Query) {
      73          79 :     const LLT &QueryTy = Query.Types[TypeIdx];
      74          71 :     return QueryTy.isScalar() && QueryTy.getSizeInBits() > Size;
      75       75572 :   };
      76             : }
      77             : 
      78       46371 : LegalityPredicate LegalityPredicates::sizeNotPow2(unsigned TypeIdx) {
      79          21 :   return [=](const LegalityQuery &Query) {
      80          21 :     const LLT &QueryTy = Query.Types[TypeIdx];
      81          35 :     return QueryTy.isScalar() && !isPowerOf2_32(QueryTy.getSizeInBits());
      82       46371 :   };
      83             : }
      84             : 
      85        4305 : LegalityPredicate LegalityPredicates::memSizeInBytesNotPow2(unsigned MMOIdx) {
      86             :   return [=](const LegalityQuery &Query) {
      87          10 :     return !isPowerOf2_32(Query.MMODescrs[MMOIdx].Size /* In Bytes */);
      88        4310 :   };
      89             : }
      90             : 
      91        1435 : LegalityPredicate LegalityPredicates::numElementsNotPow2(unsigned TypeIdx) {
      92           0 :   return [=](const LegalityQuery &Query) {
      93           0 :     const LLT &QueryTy = Query.Types[TypeIdx];
      94           0 :     return QueryTy.isVector() && isPowerOf2_32(QueryTy.getNumElements());
      95        1435 :   };
      96             : }

Generated by: LCOV version 1.13