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_
21 template <class TypeTy>
28 /// Find in cost table, TypeTy must be comparable by ==
29 template <class TypeTy>
30 int CostTableLookup(const CostTblEntry<TypeTy> *Tbl,
31 unsigned len, int ISD, TypeTy Ty) {
32 for (unsigned int i = 0; i < len; ++i)
33 if (Tbl[i].ISD == ISD && Tbl[i].Type == Ty)
36 // Could not find an entry.
40 /// Type Conversion Cost Table
41 template <class TypeTy>
42 struct TypeConversionCostTblEntry {
49 /// Find in type conversion cost table, TypeTy must be comparable by ==
50 template <class TypeTy>
51 int ConvertCostTableLookup(const TypeConversionCostTblEntry<TypeTy> *Tbl,
52 unsigned len, int ISD, TypeTy Dst, TypeTy Src) {
53 for (unsigned int i = 0; i < len; ++i)
54 if (Tbl[i].ISD == ISD && Tbl[i].Src == Src && Tbl[i].Dst == Dst)
57 // Could not find an entry.
64 #endif /* LLVM_TARGET_COSTTABLE_H_ */