1 //===-- CostTable.h - Instruction Cost Table handling -----------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// Cost tables and simple lookup functions
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_COSTTABLE_H_
15 #define LLVM_CODEGEN_COSTTABLE_H_
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/Support/MachineValueType.h"
26 MVT::SimpleValueType Type
;
30 /// Find in cost table, TypeTy must be comparable to CompareTy by ==
31 inline const CostTblEntry
*CostTableLookup(ArrayRef
<CostTblEntry
> Tbl
,
33 auto I
= find_if(Tbl
, [=](const CostTblEntry
&Entry
) {
34 return ISD
== Entry
.ISD
&& Ty
== Entry
.Type
;
39 // Could not find an entry.
43 /// Type Conversion Cost Table
44 struct TypeConversionCostTblEntry
{
46 MVT::SimpleValueType Dst
;
47 MVT::SimpleValueType Src
;
51 /// Find in type conversion cost table, TypeTy must be comparable to CompareTy
53 inline const TypeConversionCostTblEntry
*
54 ConvertCostTableLookup(ArrayRef
<TypeConversionCostTblEntry
> Tbl
,
55 int ISD
, MVT Dst
, MVT Src
) {
56 auto I
= find_if(Tbl
, [=](const TypeConversionCostTblEntry
&Entry
) {
57 return ISD
== Entry
.ISD
&& Src
== Entry
.Src
&& Dst
== Entry
.Dst
;
62 // Could not find an entry.
68 #endif /* LLVM_CODEGEN_COSTTABLE_H_ */