LLVM
17.0.0git
include
llvm
CodeGen
CostTable.h
Go to the documentation of this file.
1
//===-- CostTable.h - Instruction Cost Table handling -----------*- C++ -*-===//
2
//
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
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// Cost tables and simple lookup functions
11
///
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CODEGEN_COSTTABLE_H_
15
#define LLVM_CODEGEN_COSTTABLE_H_
16
17
#include "
llvm/ADT/ArrayRef.h
"
18
#include "
llvm/ADT/STLExtras.h
"
19
#include "
llvm/Support/MachineValueType.h
"
20
21
namespace
llvm
{
22
23
/// Cost Table Entry
24
template
<
typename
CostType>
25
struct
CostTblEntryT
{
26
int
ISD
;
27
MVT::SimpleValueType
Type
;
28
CostType
Cost
;
29
};
30
using
CostTblEntry
=
CostTblEntryT<unsigned>
;
31
32
/// Find in cost table.
33
template
<
class
CostType>
34
inline
const
CostTblEntryT<CostType>
*
35
CostTableLookup
(
ArrayRef
<
CostTblEntryT<CostType>
> Tbl,
int
ISD,
MVT
Ty) {
36
auto
I
=
find_if
(Tbl, [=](
const
CostTblEntryT<CostType>
&Entry) {
37
return
ISD == Entry.ISD && Ty == Entry.Type;
38
});
39
if
(
I
!= Tbl.end())
40
return
I
;
41
42
// Could not find an entry.
43
return
nullptr
;
44
}
45
46
template
<
size_t
N,
class
CostType>
47
inline
const
CostTblEntryT<CostType> *
48
CostTableLookup
(
const
CostTblEntryT<CostType>
(&Table)[
N
],
int
ISD,
MVT
Ty) {
49
// Wrapper to fix template argument deduction failures.
50
return
CostTableLookup<CostType>(Table, ISD, Ty);
51
}
52
53
/// Type Conversion Cost Table
54
template
<
typename
CostType>
55
struct
TypeConversionCostTblEntryT
{
56
int
ISD
;
57
MVT::SimpleValueType
Dst
;
58
MVT::SimpleValueType
Src
;
59
CostType
Cost
;
60
};
61
using
TypeConversionCostTblEntry
=
TypeConversionCostTblEntryT<unsigned>
;
62
63
/// Find in type conversion cost table.
64
template
<
class
CostType>
65
inline
const
TypeConversionCostTblEntryT<CostType>
*
66
ConvertCostTableLookup
(
ArrayRef
<
TypeConversionCostTblEntryT<CostType>
> Tbl,
67
int
ISD,
MVT
Dst,
MVT
Src) {
68
auto
I
=
69
find_if
(Tbl, [=](
const
TypeConversionCostTblEntryT<CostType>
&Entry) {
70
return
ISD == Entry.ISD && Src == Entry.Src && Dst == Entry.Dst;
71
});
72
if
(
I
!= Tbl.end())
73
return
I
;
74
75
// Could not find an entry.
76
return
nullptr
;
77
}
78
79
template
<
size_t
N,
class
CostType>
80
inline
const
TypeConversionCostTblEntryT<CostType> *
81
ConvertCostTableLookup
(
const
TypeConversionCostTblEntryT<CostType>
(&Table)[
N
],
82
int
ISD,
MVT
Dst,
MVT
Src) {
83
// Wrapper to fix template argument deduction failures.
84
return
ConvertCostTableLookup<CostType>(Table, ISD, Dst, Src);
85
}
86
87
}
// namespace llvm
88
89
#endif
/* LLVM_CODEGEN_COSTTABLE_H_ */
llvm::TypeConversionCostTblEntryT::Dst
MVT::SimpleValueType Dst
Definition:
CostTable.h:57
llvm::CostTblEntryT::ISD
int ISD
Definition:
CostTable.h:26
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::ConvertCostTableLookup
const TypeConversionCostTblEntryT< CostType > * ConvertCostTableLookup(ArrayRef< TypeConversionCostTblEntryT< CostType >> Tbl, int ISD, MVT Dst, MVT Src)
Find in type conversion cost table.
Definition:
CostTable.h:66
llvm::CostTblEntryT
Cost Table Entry.
Definition:
CostTable.h:25
STLExtras.h
MachineValueType.h
llvm::MVT::SimpleValueType
SimpleValueType
Definition:
MachineValueType.h:33
llvm::CostTblEntryT::Cost
CostType Cost
Definition:
CostTable.h:28
llvm::TypeConversionCostTblEntryT
Type Conversion Cost Table.
Definition:
CostTable.h:55
llvm::CostTblEntryT::Type
MVT::SimpleValueType Type
Definition:
CostTable.h:27
llvm::CostTableLookup
const CostTblEntryT< CostType > * CostTableLookup(ArrayRef< CostTblEntryT< CostType >> Tbl, int ISD, MVT Ty)
Find in cost table.
Definition:
CostTable.h:35
I
#define I(x, y, z)
Definition:
MD5.cpp:58
ArrayRef.h
llvm::MVT
Machine Value Type.
Definition:
MachineValueType.h:31
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:
APInt.h:33
llvm::find_if
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition:
STLExtras.h:1762
llvm::TypeConversionCostTblEntryT::Cost
CostType Cost
Definition:
CostTable.h:59
N
#define N
llvm::TypeConversionCostTblEntryT::Src
MVT::SimpleValueType Src
Definition:
CostTable.h:58
llvm::TypeConversionCostTblEntryT::ISD
int ISD
Definition:
CostTable.h:56
Generated on Sat Jan 28 2023 08:42:00 for LLVM by
1.8.17