LLVM: lib/CodeGen/AllocationOrder.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef LLVM_LIB_CODEGEN_ALLOCATIONORDER_H
17#define LLVM_LIB_CODEGEN_ALLOCATIONORDER_H
18
23
24namespace llvm {
25
29
33
34
35
36
37
38
39
40 const int IterationLimit;
41
42public:
43
46 int Pos = 0;
47
48 public:
50
51
52 bool isHint() const { return Pos < 0; }
53
54
56 if (Pos < 0)
57 return AO.Hints.end()[Pos];
58 assert(Pos < AO.IterationLimit);
59 return AO.Order[Pos];
60 }
61
62
63
65 if (Pos < AO.IterationLimit)
66 ++Pos;
67 while (Pos >= 0 && Pos < AO.IterationLimit && AO.isHint(AO.Order[Pos]))
68 ++Pos;
69 return *this;
70 }
71
74 return Pos == Other.Pos;
75 }
76
78 };
79
80
81
82
83
87
88
89
91 bool HardHints)
92 : Hints(std::move(Hints)), Order(Order),
93 IterationLimit(HardHints ? 0 : static_cast(Order.size())) {}
94
96 return Iterator(*this, -(static_cast<int>(Hints.size())));
97 }
98
100
102 assert(OrderLimit <= Order.size());
103 if (OrderLimit == 0)
104 return end();
106 std::min(static_cast<int>(OrderLimit) - 1, IterationLimit));
107 return ++Ret;
108 }
109
110
112
113
116 Reg.id() <
117 static_cast<uint32_t>(std::numeric_limits::max()));
119 }
120};
121
122}
123
124#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_LIBRARY_VISIBILITY
This file defines the SmallVector class.
Forward iterator for an AllocationOrder.
Definition AllocationOrder.h:44
bool isHint() const
Return true if the current position is that of a preferred register.
Definition AllocationOrder.h:52
bool operator==(const Iterator &Other) const
Definition AllocationOrder.h:72
Iterator(const AllocationOrder &AO, int Pos)
Definition AllocationOrder.h:49
Iterator & operator++()
Advance the iterator to the next position.
Definition AllocationOrder.h:64
bool operator!=(const Iterator &Other) const
Definition AllocationOrder.h:77
MCRegister operator*() const
Return the next physical register in the allocation order.
Definition AllocationOrder.h:55
Definition AllocationOrder.h:30
bool isHint(Register Reg) const
Return true if Reg is a preferred physical register.
Definition AllocationOrder.h:114
ArrayRef< MCPhysReg > getOrder() const
Get the allocation order without reordered hints.
Definition AllocationOrder.h:111
Iterator end() const
Definition AllocationOrder.h:99
Iterator getOrderLimitEnd(unsigned OrderLimit) const
Definition AllocationOrder.h:101
AllocationOrder(SmallVector< MCPhysReg, 16 > &&Hints, ArrayRef< MCPhysReg > Order, bool HardHints)
Create an AllocationOrder given the Hints, Order, and HardHints values.
Definition AllocationOrder.h:90
Iterator begin() const
Definition AllocationOrder.h:95
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Wrapper class representing physical registers. Should be passed by value.
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Implement std::hash so that hash_code can be used in STL containers.