LCOV - code coverage report
Current view: top level - lib/CodeGen/GlobalISel - LegalityPredicates.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 40 46 87.0 %
Date: 2018-07-13 00:08:38 Functions: 18 20 90.0 %
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          93 : LegalityPredicate LegalityPredicates::typeIs(unsigned TypeIdx, LLT Type) {
      19             :   return
      20         200 :       [=](const LegalityQuery &Query) { return Query.Types[TypeIdx] == Type; };
      21             : }
      22             : 
      23             : LegalityPredicate
      24      240122 : LegalityPredicates::typeInSet(unsigned TypeIdx,
      25             :                               std::initializer_list<LLT> TypesInit) {
      26             :   SmallVector<LLT, 4> Types = TypesInit;
      27     3269933 :   return [=](const LegalityQuery &Query) {
      28        3442 :     return std::find(Types.begin(), Types.end(), Query.Types[TypeIdx]) != Types.end();
      29      723808 :   };
      30             : }
      31             : 
      32       57269 : LegalityPredicate LegalityPredicates::typePairInSet(
      33             :     unsigned TypeIdx0, unsigned TypeIdx1,
      34             :     std::initializer_list<std::pair<LLT, LLT>> TypesInit) {
      35             :   SmallVector<std::pair<LLT, LLT>, 4> Types = TypesInit;
      36      456009 :   return [=](const LegalityQuery &Query) {
      37         392 :     std::pair<LLT, LLT> Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1]};
      38         196 :     return std::find(Types.begin(), Types.end(), Match) != Types.end();
      39      171807 :   };
      40             : }
      41             : 
      42        5752 : LegalityPredicate LegalityPredicates::typePairAndMemSizeInSet(
      43             :     unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx,
      44             :     std::initializer_list<TypePairAndMemSize> TypesAndMemSizeInit) {
      45             :   SmallVector<TypePairAndMemSize, 4> TypesAndMemSize = TypesAndMemSizeInit;
      46       69094 :   return [=](const LegalityQuery &Query) {
      47         380 :     TypePairAndMemSize Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1],
      48         570 :                                 Query.MMODescrs[MMOIdx].Size};
      49             :     return std::find(TypesAndMemSize.begin(), TypesAndMemSize.end(), Match) !=
      50         190 :            TypesAndMemSize.end();
      51       23008 :   };
      52             : }
      53             : 
      54           0 : LegalityPredicate LegalityPredicates::isScalar(unsigned TypeIdx) {
      55             :   return [=](const LegalityQuery &Query) {
      56           0 :     return Query.Types[TypeIdx].isScalar();
      57           0 :   };
      58             : }
      59             : 
      60       94897 : LegalityPredicate LegalityPredicates::narrowerThan(unsigned TypeIdx,
      61             :                                                    unsigned Size) {
      62         273 :   return [=](const LegalityQuery &Query) {
      63         273 :     const LLT &QueryTy = Query.Types[TypeIdx];
      64         265 :     return QueryTy.isScalar() && QueryTy.getSizeInBits() < Size;
      65       94897 :   };
      66             : }
      67             : 
      68       95197 : LegalityPredicate LegalityPredicates::widerThan(unsigned TypeIdx,
      69             :                                                 unsigned Size) {
      70          79 :   return [=](const LegalityQuery &Query) {
      71          79 :     const LLT &QueryTy = Query.Types[TypeIdx];
      72          71 :     return QueryTy.isScalar() && QueryTy.getSizeInBits() > Size;
      73       95197 :   };
      74             : }
      75             : 
      76       64137 : LegalityPredicate LegalityPredicates::sizeNotPow2(unsigned TypeIdx) {
      77          21 :   return [=](const LegalityQuery &Query) {
      78          21 :     const LLT &QueryTy = Query.Types[TypeIdx];
      79          35 :     return QueryTy.isScalar() && !isPowerOf2_32(QueryTy.getSizeInBits());
      80       64137 :   };
      81             : }
      82             : 
      83        4314 : LegalityPredicate LegalityPredicates::memSizeInBytesNotPow2(unsigned MMOIdx) {
      84             :   return [=](const LegalityQuery &Query) {
      85          10 :     return !isPowerOf2_32(Query.MMODescrs[MMOIdx].Size /* In Bytes */);
      86        4319 :   };
      87             : }
      88             : 
      89        1438 : LegalityPredicate LegalityPredicates::numElementsNotPow2(unsigned TypeIdx) {
      90           0 :   return [=](const LegalityQuery &Query) {
      91           0 :     const LLT &QueryTy = Query.Types[TypeIdx];
      92           0 :     return QueryTy.isVector() && isPowerOf2_32(QueryTy.getNumElements());
      93        1438 :   };
      94             : }
      95             : 
      96          62 : LegalityPredicate LegalityPredicates::atomicOrderingAtLeastOrStrongerThan(
      97             :     unsigned MMOIdx, AtomicOrdering Ordering) {
      98             :   return [=](const LegalityQuery &Query) {
      99          24 :     return isAtLeastOrStrongerThan(Query.MMODescrs[MMOIdx].Ordering, Ordering);
     100          62 :   };
     101             : }

Generated by: LCOV version 1.13