#ifndef LLVM_TARGET_COSTTABLE_H_
#define LLVM_TARGET_COSTTABLE_H_
#include "llvm/ADT/ArrayRef.h"
#include "llvm/CodeGen/MachineValueType.h"
namespace llvm {
struct CostTblEntry {
int ISD;
MVT::SimpleValueType Type;
unsigned Cost;
};
inline const CostTblEntry *CostTableLookup(ArrayRef<CostTblEntry> Tbl,
int ISD, MVT Ty) {
auto I = std::find_if(Tbl.begin(), Tbl.end(),
[=](const CostTblEntry &Entry) {
return ISD == Entry.ISD && Ty == Entry.Type; });
if (I != Tbl.end())
return I;
return nullptr;
}
struct TypeConversionCostTblEntry {
int ISD;
MVT::SimpleValueType Dst;
MVT::SimpleValueType Src;
unsigned Cost;
};
inline const TypeConversionCostTblEntry *
ConvertCostTableLookup(ArrayRef<TypeConversionCostTblEntry> Tbl,
int ISD, MVT Dst, MVT Src) {
auto I = std::find_if(Tbl.begin(), Tbl.end(),
[=](const TypeConversionCostTblEntry &Entry) {
return ISD == Entry.ISD && Src == Entry.Src &&
Dst == Entry.Dst;
});
if (I != Tbl.end())
return I;
return nullptr;
}
}
#endif