LCOV - code coverage report
Current view: top level - lib/CodeGen/GlobalISel - LegalityPredicates.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 22 28 78.6 %
Date: 2018-10-20 13:21:21 Functions: 10 11 90.9 %
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          99 : LegalityPredicate LegalityPredicates::typeIs(unsigned TypeIdx, LLT Type) {
      19             :   return
      20         198 :       [=](const LegalityQuery &Query) { return Query.Types[TypeIdx] == Type; };
      21             : }
      22             : 
      23             : LegalityPredicate
      24      414383 : LegalityPredicates::typeInSet(unsigned TypeIdx,
      25             :                               std::initializer_list<LLT> TypesInit) {
      26             :   SmallVector<LLT, 4> Types = TypesInit;
      27           0 :   return [=](const LegalityQuery &Query) {
      28             :     return std::find(Types.begin(), Types.end(), Query.Types[TypeIdx]) != Types.end();
      29      828765 :   };
      30             : }
      31             : 
      32       85361 : 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           0 :   return [=](const LegalityQuery &Query) {
      37             :     std::pair<LLT, LLT> Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1]};
      38             :     return std::find(Types.begin(), Types.end(), Match) != Types.end();
      39      170722 :   };
      40             : }
      41             : 
      42        6280 : LegalityPredicate LegalityPredicates::typePairAndMemSizeInSet(
      43             :     unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx,
      44             :     std::initializer_list<TypePairAndMemSize> TypesAndMemSizeInit) {
      45             :   SmallVector<TypePairAndMemSize, 4> TypesAndMemSize = TypesAndMemSizeInit;
      46           0 :   return [=](const LegalityQuery &Query) {
      47             :     TypePairAndMemSize Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1],
      48             :                                 Query.MMODescrs[MMOIdx].Size};
      49             :     return std::find(TypesAndMemSize.begin(), TypesAndMemSize.end(), Match) !=
      50             :            TypesAndMemSize.end();
      51       12560 :   };
      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      200364 : LegalityPredicate LegalityPredicates::narrowerThan(unsigned TypeIdx,
      61             :                                                    unsigned Size) {
      62             :   return [=](const LegalityQuery &Query) {
      63             :     const LLT &QueryTy = Query.Types[TypeIdx];
      64             :     return QueryTy.isScalar() && QueryTy.getSizeInBits() < Size;
      65      200364 :   };
      66             : }
      67             : 
      68      174168 : LegalityPredicate LegalityPredicates::widerThan(unsigned TypeIdx,
      69             :                                                 unsigned Size) {
      70             :   return [=](const LegalityQuery &Query) {
      71             :     const LLT &QueryTy = Query.Types[TypeIdx];
      72             :     return QueryTy.isScalar() && QueryTy.getSizeInBits() > Size;
      73      174168 :   };
      74             : }
      75             : 
      76      123153 : LegalityPredicate LegalityPredicates::sizeNotPow2(unsigned TypeIdx) {
      77             :   return [=](const LegalityQuery &Query) {
      78             :     const LLT &QueryTy = Query.Types[TypeIdx];
      79             :     return QueryTy.isScalar() && !isPowerOf2_32(QueryTy.getSizeInBits());
      80      123153 :   };
      81             : }
      82             : 
      83        4710 : LegalityPredicate LegalityPredicates::memSizeInBytesNotPow2(unsigned MMOIdx) {
      84             :   return [=](const LegalityQuery &Query) {
      85          16 :     return !isPowerOf2_32(Query.MMODescrs[MMOIdx].Size /* In Bytes */);
      86        4710 :   };
      87             : }
      88             : 
      89        1570 : LegalityPredicate LegalityPredicates::numElementsNotPow2(unsigned TypeIdx) {
      90             :   return [=](const LegalityQuery &Query) {
      91             :     const LLT &QueryTy = Query.Types[TypeIdx];
      92             :     return QueryTy.isVector() && isPowerOf2_32(QueryTy.getNumElements());
      93        1570 :   };
      94             : }
      95             : 
      96          66 : LegalityPredicate LegalityPredicates::atomicOrderingAtLeastOrStrongerThan(
      97             :     unsigned MMOIdx, AtomicOrdering Ordering) {
      98             :   return [=](const LegalityQuery &Query) {
      99          24 :     return isAtLeastOrStrongerThan(Query.MMODescrs[MMOIdx].Ordering, Ordering);
     100          66 :   };
     101             : }

Generated by: LCOV version 1.13