LLVM  9.0.0svn
CostTable.h
Go to the documentation of this file.
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"
20 
21 namespace llvm {
22 
23 /// Cost Table Entry
24 struct CostTblEntry {
25  int ISD;
27  unsigned Cost;
28 };
29 
30 /// Find in cost table, TypeTy must be comparable to CompareTy by ==
32  int ISD, MVT Ty) {
33  auto I = find_if(Tbl, [=](const CostTblEntry &Entry) {
34  return ISD == Entry.ISD && Ty == Entry.Type;
35  });
36  if (I != Tbl.end())
37  return I;
38 
39  // Could not find an entry.
40  return nullptr;
41 }
42 
43 /// Type Conversion Cost Table
45  int ISD;
48  unsigned Cost;
49 };
50 
51 /// Find in type conversion cost table, TypeTy must be comparable to CompareTy
52 /// by ==
53 inline const TypeConversionCostTblEntry *
55  int ISD, MVT Dst, MVT Src) {
56  auto I = find_if(Tbl, [=](const TypeConversionCostTblEntry &Entry) {
57  return ISD == Entry.ISD && Src == Entry.Src && Dst == Entry.Dst;
58  });
59  if (I != Tbl.end())
60  return I;
61 
62  // Could not find an entry.
63  return nullptr;
64 }
65 
66 } // namespace llvm
67 
68 #endif /* LLVM_CODEGEN_COSTTABLE_H_ */
This class represents lattice values for constants.
Definition: AllocatorList.h:23
MVT::SimpleValueType Src
Definition: CostTable.h:47
Type Conversion Cost Table.
Definition: CostTable.h:44
Cost Table Entry.
Definition: CostTable.h:24
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:54
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
Machine Value Type.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1220
iterator end() const
Definition: ArrayRef.h:137
const CostTblEntry * CostTableLookup(ArrayRef< CostTblEntry > Tbl, int ISD, MVT Ty)
Find in cost table, TypeTy must be comparable to CompareTy by ==.
Definition: CostTable.h:31
#define I(x, y, z)
Definition: MD5.cpp:58
MVT::SimpleValueType Type
Definition: CostTable.h:26
MVT::SimpleValueType Dst
Definition: CostTable.h:46