Taints the non-acquire RMW's store address with the load part
[oota-llvm.git] / include / llvm / Target / CostTable.h
index a974b560945604b1a517e218d4c1c9ddf8e9e987..2499f5c3189c9e8946a4d5b26903057a9891c963 100644 (file)
 #ifndef LLVM_TARGET_COSTTABLE_H_
 #define LLVM_TARGET_COSTTABLE_H_
 
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/CodeGen/MachineValueType.h"
+
 namespace llvm {
 
 /// Cost Table Entry
-template <class TypeTy>
 struct CostTblEntry {
   int ISD;
-  TypeTy Type;
+  MVT::SimpleValueType Type;
   unsigned Cost;
 };
 
-/// Find in cost table, TypeTy must be comparable by ==
-template <class TypeTy>
-int CostTableLookup(const CostTblEntry<TypeTy> *Tbl,
-                    unsigned len, int ISD, TypeTy Ty) {
-  for (unsigned int i = 0; i < len; ++i)
-    if (Tbl[i].ISD == ISD && Tbl[i].Type == Ty)
-      return i;
+/// Find in cost table, TypeTy must be comparable to CompareTy by ==
+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;
 
   // Could not find an entry.
-  return -1;
+  return nullptr;
 }
 
 /// Type Conversion Cost Table
-template <class TypeTy>
 struct TypeConversionCostTblEntry {
   int ISD;
-  TypeTy Dst;
-  TypeTy Src;
+  MVT::SimpleValueType Dst;
+  MVT::SimpleValueType Src;
   unsigned Cost;
 };
 
-/// Find in type conversion cost table, TypeTy must be comparable by ==
-template <class TypeTy>
-int ConvertCostTableLookup(const TypeConversionCostTblEntry<TypeTy> *Tbl,
-                           unsigned len, int ISD, TypeTy Dst, TypeTy Src) {
-  for (unsigned int i = 0; i < len; ++i)
-    if (Tbl[i].ISD == ISD && Tbl[i].Src == Src && Tbl[i].Dst == Dst)
-      return i;
+/// Find in type conversion cost table, TypeTy must be comparable to CompareTy
+/// by ==
+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;
 
   // Could not find an entry.
-  return -1;
+  return nullptr;
 }
 
 } // namespace llvm