Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/CostTable.h
Line
Count
Source
1
//===-- CostTable.h - Instruction Cost Table handling -----------*- C++ -*-===//
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
/// \file
10
/// Cost tables and simple lookup functions
11
///
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CODEGEN_COSTTABLE_H_
15
#define LLVM_CODEGEN_COSTTABLE_H_
16
17
#include "llvm/ADT/ArrayRef.h"
18
#include "llvm/ADT/STLExtras.h"
19
#include "llvm/Support/MachineValueType.h"
20
21
namespace llvm {
22
23
/// Cost Table Entry
24
struct CostTblEntry {
25
  int ISD;
26
  MVT::SimpleValueType Type;
27
  unsigned Cost;
28
};
29
30
/// Find in cost table, TypeTy must be comparable to CompareTy by ==
31
inline const CostTblEntry *CostTableLookup(ArrayRef<CostTblEntry> Tbl,
32
980k
                                           int ISD, MVT Ty) {
33
15.0M
  auto I = find_if(Tbl, [=](const CostTblEntry &Entry) {
34
15.0M
    return ISD == Entry.ISD && 
Ty == Entry.Type1.65M
;
35
15.0M
  });
36
980k
  if (I != Tbl.end())
37
226k
    return I;
38
753k
39
753k
  // Could not find an entry.
40
753k
  return nullptr;
41
753k
}
42
43
/// Type Conversion Cost Table
44
struct TypeConversionCostTblEntry {
45
  int ISD;
46
  MVT::SimpleValueType Dst;
47
  MVT::SimpleValueType Src;
48
  unsigned Cost;
49
};
50
51
/// Find in type conversion cost table, TypeTy must be comparable to CompareTy
52
/// by ==
53
inline const TypeConversionCostTblEntry *
54
ConvertCostTableLookup(ArrayRef<TypeConversionCostTblEntry> Tbl,
55
210k
                       int ISD, MVT Dst, MVT Src) {
56
10.3M
  auto I = find_if(Tbl, [=](const TypeConversionCostTblEntry &Entry) {
57
10.3M
    return ISD == Entry.ISD && 
Src == Entry.Src1.19M
&&
Dst == Entry.Dst47.1k
;
58
10.3M
  });
59
210k
  if (I != Tbl.end())
60
30.9k
    return I;
61
179k
62
179k
  // Could not find an entry.
63
179k
  return nullptr;
64
179k
}
65
66
} // namespace llvm
67
68
#endif /* LLVM_CODEGEN_COSTTABLE_H_ */