#ifndef LLVM_TARGET_COSTTABLE_H_
#define LLVM_TARGET_COSTTABLE_H_
namespace llvm {
template <class TypeTy>
struct CostTblEntry {
int ISD;
TypeTy Type;
unsigned Cost;
};
template <class TypeTy, class CompareTy>
int CostTableLookup(const CostTblEntry<TypeTy> *Tbl, unsigned len, int ISD,
CompareTy Ty) {
for (unsigned int i = 0; i < len; ++i)
if (ISD == Tbl[i].ISD && Ty == Tbl[i].Type)
return i;
return -1;
}
template <class TypeTy, class CompareTy, unsigned N>
int CostTableLookup(const CostTblEntry<TypeTy>(&Tbl)[N], int ISD,
CompareTy Ty) {
return CostTableLookup(Tbl, N, ISD, Ty);
}
template <class TypeTy>
struct TypeConversionCostTblEntry {
int ISD;
TypeTy Dst;
TypeTy Src;
unsigned Cost;
};
template <class TypeTy, class CompareTy>
int ConvertCostTableLookup(const TypeConversionCostTblEntry<TypeTy> *Tbl,
unsigned len, int ISD, CompareTy Dst,
CompareTy Src) {
for (unsigned int i = 0; i < len; ++i)
if (ISD == Tbl[i].ISD && Src == Tbl[i].Src && Dst == Tbl[i].Dst)
return i;
return -1;
}
template <class TypeTy, class CompareTy, unsigned N>
int ConvertCostTableLookup(const TypeConversionCostTblEntry<TypeTy>(&Tbl)[N],
int ISD, CompareTy Dst, CompareTy Src) {
return ConvertCostTableLookup(Tbl, N, ISD, Dst, Src);
}
}
#endif