1 //===-- CostTable.h - Instruction Cost Table handling -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Cost tables and simple lookup functions
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TARGET_COSTTABLE_H_
16 #define LLVM_TARGET_COSTTABLE_H_
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/CodeGen/MachineValueType.h"
27 MVT::SimpleValueType Type;
31 /// Find in cost table, TypeTy must be comparable to CompareTy by ==
32 inline const CostTblEntry *CostTableLookup(ArrayRef<CostTblEntry> Tbl,
34 auto I = find_if(Tbl, [=](const CostTblEntry &Entry) {
35 return ISD == Entry.ISD && Ty == Entry.Type;
40 // Could not find an entry.
44 /// Type Conversion Cost Table
45 struct TypeConversionCostTblEntry {
47 MVT::SimpleValueType Dst;
48 MVT::SimpleValueType Src;
52 /// Find in type conversion cost table, TypeTy must be comparable to CompareTy
54 inline const TypeConversionCostTblEntry *
55 ConvertCostTableLookup(ArrayRef<TypeConversionCostTblEntry> Tbl,
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;
63 // Could not find an entry.
70 #endif /* LLVM_TARGET_COSTTABLE_H_ */