/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Target/CostTable.h
Line | Count | Source |
1 | | //===-- CostTable.h - Instruction Cost Table handling -----------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// \brief Cost tables and simple lookup functions |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_TARGET_COSTTABLE_H_ |
16 | | #define LLVM_TARGET_COSTTABLE_H_ |
17 | | |
18 | | #include "llvm/ADT/ArrayRef.h" |
19 | | #include "llvm/ADT/STLExtras.h" |
20 | | #include "llvm/CodeGen/MachineValueType.h" |
21 | | |
22 | | namespace llvm { |
23 | | |
24 | | /// Cost Table Entry |
25 | | struct CostTblEntry { |
26 | | int ISD; |
27 | | MVT::SimpleValueType Type; |
28 | | unsigned Cost; |
29 | | }; |
30 | | |
31 | | /// Find in cost table, TypeTy must be comparable to CompareTy by == |
32 | | inline const CostTblEntry *CostTableLookup(ArrayRef<CostTblEntry> Tbl, |
33 | 185k | int ISD, MVT Ty) { |
34 | 2.41M | auto I = find_if(Tbl, [=](const CostTblEntry &Entry) { |
35 | 2.41M | return ISD == Entry.ISD && Ty == Entry.Type197k ; |
36 | 2.41M | }); |
37 | 185k | if (I != Tbl.end()) |
38 | 13.7k | return I; |
39 | 172k | |
40 | 172k | // Could not find an entry. |
41 | 172k | return nullptr; |
42 | 172k | } |
43 | | |
44 | | /// Type Conversion Cost Table |
45 | | struct TypeConversionCostTblEntry { |
46 | | int ISD; |
47 | | MVT::SimpleValueType Dst; |
48 | | MVT::SimpleValueType Src; |
49 | | unsigned Cost; |
50 | | }; |
51 | | |
52 | | /// Find in type conversion cost table, TypeTy must be comparable to CompareTy |
53 | | /// by == |
54 | | inline const TypeConversionCostTblEntry * |
55 | | ConvertCostTableLookup(ArrayRef<TypeConversionCostTblEntry> Tbl, |
56 | 175k | int ISD, MVT Dst, MVT Src) { |
57 | 8.76M | auto I = find_if(Tbl, [=](const TypeConversionCostTblEntry &Entry) { |
58 | 8.76M | return ISD == Entry.ISD && Src == Entry.Src1.02M && Dst == Entry.Dst45.6k ; |
59 | 8.76M | }); |
60 | 175k | if (I != Tbl.end()) |
61 | 32.1k | return I; |
62 | 143k | |
63 | 143k | // Could not find an entry. |
64 | 143k | return nullptr; |
65 | 143k | } |
66 | | |
67 | | } // namespace llvm |
68 | | |
69 | | |
70 | | #endif /* LLVM_TARGET_COSTTABLE_H_ */ |