LLVM  6.0.0svn
CostTable.h
Go to the documentation of this file.
1 //===-- CostTable.h - Instruction Cost Table handling -----------*- C++ -*-===//
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 /// \file
11 /// \brief Cost tables and simple lookup functions
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_COSTTABLE_H_
16 #define LLVM_CODEGEN_COSTTABLE_H_
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/STLExtras.h"
21 
22 namespace llvm {
23 
24 /// Cost Table Entry
25 struct CostTblEntry {
26  int ISD;
28  unsigned Cost;
29 };
30 
31 /// Find in cost table, TypeTy must be comparable to CompareTy by ==
33  int ISD, MVT Ty) {
34  auto I = find_if(Tbl, [=](const CostTblEntry &Entry) {
35  return ISD == Entry.ISD && Ty == Entry.Type;
36  });
37  if (I != Tbl.end())
38  return I;
39 
40  // Could not find an entry.
41  return nullptr;
42 }
43 
44 /// Type Conversion Cost Table
46  int ISD;
49  unsigned Cost;
50 };
51 
52 /// Find in type conversion cost table, TypeTy must be comparable to CompareTy
53 /// by ==
54 inline const TypeConversionCostTblEntry *
56  int ISD, MVT Dst, MVT Src) {
57  auto I = find_if(Tbl, [=](const TypeConversionCostTblEntry &Entry) {
58  return ISD == Entry.ISD && Src == Entry.Src && Dst == Entry.Dst;
59  });
60  if (I != Tbl.end())
61  return I;
62 
63  // Could not find an entry.
64  return nullptr;
65 }
66 
67 } // namespace llvm
68 
69 #endif /* LLVM_CODEGEN_COSTTABLE_H_ */
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
MVT::SimpleValueType Src
Definition: CostTable.h:48
Type Conversion Cost Table.
Definition: CostTable.h:45
Cost Table Entry.
Definition: CostTable.h:25
const TypeConversionCostTblEntry * ConvertCostTableLookup(ArrayRef< TypeConversionCostTblEntry > Tbl, int ISD, MVT Dst, MVT Src)
Find in type conversion cost table, TypeTy must be comparable to CompareTy by ==. ...
Definition: CostTable.h:55
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Machine Value Type.
iterator end() const
Definition: ArrayRef.h:138
const CostTblEntry * CostTableLookup(ArrayRef< CostTblEntry > Tbl, int ISD, MVT Ty)
Find in cost table, TypeTy must be comparable to CompareTy by ==.
Definition: CostTable.h:32
#define I(x, y, z)
Definition: MD5.cpp:58
MVT::SimpleValueType Type
Definition: CostTable.h:27
MVT::SimpleValueType Dst
Definition: CostTable.h:47
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:795