LLVM  13.0.0git
DenseMapInfo.h
Go to the documentation of this file.
1 //===- llvm/ADT/DenseMapInfo.h - Type traits for DenseMap -------*- 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 // This file defines DenseMapInfo traits for DenseMap.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ADT_DENSEMAPINFO_H
14 #define LLVM_ADT_DENSEMAPINFO_H
15 
16 #include "llvm/ADT/APInt.h"
17 #include "llvm/ADT/APSInt.h"
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/Hashing.h"
20 #include "llvm/ADT/StringRef.h"
21 #include <cassert>
22 #include <cstddef>
23 #include <cstdint>
24 #include <utility>
25 
26 namespace llvm {
27 
28 namespace detail {
29 
30 /// Simplistic combination of 32-bit hash values into 32-bit hash values.
31 static inline unsigned combineHashValue(unsigned a, unsigned b) {
32  uint64_t key = (uint64_t)a << 32 | (uint64_t)b;
33  key += ~(key << 32);
34  key ^= (key >> 22);
35  key += ~(key << 13);
36  key ^= (key >> 8);
37  key += (key << 3);
38  key ^= (key >> 15);
39  key += ~(key << 27);
40  key ^= (key >> 31);
41  return (unsigned)key;
42 }
43 
44 } // end namespace detail
45 
46 template<typename T>
47 struct DenseMapInfo {
48  //static inline T getEmptyKey();
49  //static inline T getTombstoneKey();
50  //static unsigned getHashValue(const T &Val);
51  //static bool isEqual(const T &LHS, const T &RHS);
52 };
53 
54 // Provide DenseMapInfo for all pointers. Come up with sentinel pointer values
55 // that are aligned to alignof(T) bytes, but try to avoid requiring T to be
56 // complete. This allows clients to instantiate DenseMap<T*, ...> with forward
57 // declared key types. Assume that no pointer key type requires more than 4096
58 // bytes of alignment.
59 template<typename T>
60 struct DenseMapInfo<T*> {
61  // The following should hold, but it would require T to be complete:
62  // static_assert(alignof(T) <= (1 << Log2MaxAlign),
63  // "DenseMap does not support pointer keys requiring more than "
64  // "Log2MaxAlign bits of alignment");
65  static constexpr uintptr_t Log2MaxAlign = 12;
66 
67  static inline T* getEmptyKey() {
68  uintptr_t Val = static_cast<uintptr_t>(-1);
69  Val <<= Log2MaxAlign;
70  return reinterpret_cast<T*>(Val);
71  }
72 
73  static inline T* getTombstoneKey() {
74  uintptr_t Val = static_cast<uintptr_t>(-2);
75  Val <<= Log2MaxAlign;
76  return reinterpret_cast<T*>(Val);
77  }
78 
79  static unsigned getHashValue(const T *PtrVal) {
80  return (unsigned((uintptr_t)PtrVal) >> 4) ^
81  (unsigned((uintptr_t)PtrVal) >> 9);
82  }
83 
84  static bool isEqual(const T *LHS, const T *RHS) { return LHS == RHS; }
85 };
86 
87 // Provide DenseMapInfo for chars.
88 template<> struct DenseMapInfo<char> {
89  static inline char getEmptyKey() { return ~0; }
90  static inline char getTombstoneKey() { return ~0 - 1; }
91  static unsigned getHashValue(const char& Val) { return Val * 37U; }
92 
93  static bool isEqual(const char &LHS, const char &RHS) {
94  return LHS == RHS;
95  }
96 };
97 
98 // Provide DenseMapInfo for unsigned chars.
99 template <> struct DenseMapInfo<unsigned char> {
100  static inline unsigned char getEmptyKey() { return ~0; }
101  static inline unsigned char getTombstoneKey() { return ~0 - 1; }
102  static unsigned getHashValue(const unsigned char &Val) { return Val * 37U; }
103 
104  static bool isEqual(const unsigned char &LHS, const unsigned char &RHS) {
105  return LHS == RHS;
106  }
107 };
108 
109 // Provide DenseMapInfo for unsigned shorts.
110 template <> struct DenseMapInfo<unsigned short> {
111  static inline unsigned short getEmptyKey() { return 0xFFFF; }
112  static inline unsigned short getTombstoneKey() { return 0xFFFF - 1; }
113  static unsigned getHashValue(const unsigned short &Val) { return Val * 37U; }
114 
115  static bool isEqual(const unsigned short &LHS, const unsigned short &RHS) {
116  return LHS == RHS;
117  }
118 };
119 
120 // Provide DenseMapInfo for unsigned ints.
121 template<> struct DenseMapInfo<unsigned> {
122  static inline unsigned getEmptyKey() { return ~0U; }
123  static inline unsigned getTombstoneKey() { return ~0U - 1; }
124  static unsigned getHashValue(const unsigned& Val) { return Val * 37U; }
125 
126  static bool isEqual(const unsigned& LHS, const unsigned& RHS) {
127  return LHS == RHS;
128  }
129 };
130 
131 // Provide DenseMapInfo for unsigned longs.
132 template<> struct DenseMapInfo<unsigned long> {
133  static inline unsigned long getEmptyKey() { return ~0UL; }
134  static inline unsigned long getTombstoneKey() { return ~0UL - 1L; }
135 
136  static unsigned getHashValue(const unsigned long& Val) {
137  return (unsigned)(Val * 37UL);
138  }
139 
140  static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) {
141  return LHS == RHS;
142  }
143 };
144 
145 // Provide DenseMapInfo for unsigned long longs.
146 template<> struct DenseMapInfo<unsigned long long> {
147  static inline unsigned long long getEmptyKey() { return ~0ULL; }
148  static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; }
149 
150  static unsigned getHashValue(const unsigned long long& Val) {
151  return (unsigned)(Val * 37ULL);
152  }
153 
154  static bool isEqual(const unsigned long long& LHS,
155  const unsigned long long& RHS) {
156  return LHS == RHS;
157  }
158 };
159 
160 // Provide DenseMapInfo for shorts.
161 template <> struct DenseMapInfo<short> {
162  static inline short getEmptyKey() { return 0x7FFF; }
163  static inline short getTombstoneKey() { return -0x7FFF - 1; }
164  static unsigned getHashValue(const short &Val) { return Val * 37U; }
165  static bool isEqual(const short &LHS, const short &RHS) { return LHS == RHS; }
166 };
167 
168 // Provide DenseMapInfo for ints.
169 template<> struct DenseMapInfo<int> {
170  static inline int getEmptyKey() { return 0x7fffffff; }
171  static inline int getTombstoneKey() { return -0x7fffffff - 1; }
172  static unsigned getHashValue(const int& Val) { return (unsigned)(Val * 37U); }
173 
174  static bool isEqual(const int& LHS, const int& RHS) {
175  return LHS == RHS;
176  }
177 };
178 
179 // Provide DenseMapInfo for longs.
180 template<> struct DenseMapInfo<long> {
181  static inline long getEmptyKey() {
182  return (1UL << (sizeof(long) * 8 - 1)) - 1UL;
183  }
184 
185  static inline long getTombstoneKey() { return getEmptyKey() - 1L; }
186 
187  static unsigned getHashValue(const long& Val) {
188  return (unsigned)(Val * 37UL);
189  }
190 
191  static bool isEqual(const long& LHS, const long& RHS) {
192  return LHS == RHS;
193  }
194 };
195 
196 // Provide DenseMapInfo for long longs.
197 template<> struct DenseMapInfo<long long> {
198  static inline long long getEmptyKey() { return 0x7fffffffffffffffLL; }
199  static inline long long getTombstoneKey() { return -0x7fffffffffffffffLL-1; }
200 
201  static unsigned getHashValue(const long long& Val) {
202  return (unsigned)(Val * 37ULL);
203  }
204 
205  static bool isEqual(const long long& LHS,
206  const long long& RHS) {
207  return LHS == RHS;
208  }
209 };
210 
211 // Provide DenseMapInfo for all pairs whose members have info.
212 template<typename T, typename U>
213 struct DenseMapInfo<std::pair<T, U>> {
214  using Pair = std::pair<T, U>;
217 
218  static inline Pair getEmptyKey() {
219  return std::make_pair(FirstInfo::getEmptyKey(),
220  SecondInfo::getEmptyKey());
221  }
222 
223  static inline Pair getTombstoneKey() {
224  return std::make_pair(FirstInfo::getTombstoneKey(),
225  SecondInfo::getTombstoneKey());
226  }
227 
228  static unsigned getHashValue(const Pair& PairVal) {
229  return detail::combineHashValue(FirstInfo::getHashValue(PairVal.first),
230  SecondInfo::getHashValue(PairVal.second));
231  }
232 
233  static bool isEqual(const Pair &LHS, const Pair &RHS) {
234  return FirstInfo::isEqual(LHS.first, RHS.first) &&
235  SecondInfo::isEqual(LHS.second, RHS.second);
236  }
237 };
238 
239 // Provide DenseMapInfo for all tuples whose members have info.
240 template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
241  using Tuple = std::tuple<Ts...>;
242 
243  static inline Tuple getEmptyKey() {
245  }
246 
247  static inline Tuple getTombstoneKey() {
249  }
250 
251  template <unsigned I>
252  static unsigned getHashValueImpl(const Tuple &values, std::false_type) {
253  using EltType = typename std::tuple_element<I, Tuple>::type;
254  std::integral_constant<bool, I + 1 == sizeof...(Ts)> atEnd;
257  getHashValueImpl<I + 1>(values, atEnd));
258  }
259 
260  template <unsigned I>
261  static unsigned getHashValueImpl(const Tuple &, std::true_type) {
262  return 0;
263  }
264 
265  static unsigned getHashValue(const std::tuple<Ts...> &values) {
266  std::integral_constant<bool, 0 == sizeof...(Ts)> atEnd;
267  return getHashValueImpl<0>(values, atEnd);
268  }
269 
270  template <unsigned I>
271  static bool isEqualImpl(const Tuple &lhs, const Tuple &rhs, std::false_type) {
272  using EltType = typename std::tuple_element<I, Tuple>::type;
273  std::integral_constant<bool, I + 1 == sizeof...(Ts)> atEnd;
274  return DenseMapInfo<EltType>::isEqual(std::get<I>(lhs), std::get<I>(rhs)) &&
275  isEqualImpl<I + 1>(lhs, rhs, atEnd);
276  }
277 
278  template <unsigned I>
279  static bool isEqualImpl(const Tuple &, const Tuple &, std::true_type) {
280  return true;
281  }
282 
283  static bool isEqual(const Tuple &lhs, const Tuple &rhs) {
284  std::integral_constant<bool, 0 == sizeof...(Ts)> atEnd;
285  return isEqualImpl<0>(lhs, rhs, atEnd);
286  }
287 };
288 
289 // Provide DenseMapInfo for StringRefs.
290 template <> struct DenseMapInfo<StringRef> {
291  static inline StringRef getEmptyKey() {
292  return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(0)),
293  0);
294  }
295 
296  static inline StringRef getTombstoneKey() {
297  return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)),
298  0);
299  }
300 
301  static unsigned getHashValue(StringRef Val) {
302  assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
303  assert(Val.data() != getTombstoneKey().data() &&
304  "Cannot hash the tombstone key!");
305  return (unsigned)(hash_value(Val));
306  }
307 
308  static bool isEqual(StringRef LHS, StringRef RHS) {
309  if (RHS.data() == getEmptyKey().data())
310  return LHS.data() == getEmptyKey().data();
311  if (RHS.data() == getTombstoneKey().data())
312  return LHS.data() == getTombstoneKey().data();
313  return LHS == RHS;
314  }
315 };
316 
317 // Provide DenseMapInfo for ArrayRefs.
318 template <typename T> struct DenseMapInfo<ArrayRef<T>> {
319  static inline ArrayRef<T> getEmptyKey() {
320  return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)),
321  size_t(0));
322  }
323 
324  static inline ArrayRef<T> getTombstoneKey() {
325  return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)),
326  size_t(0));
327  }
328 
329  static unsigned getHashValue(ArrayRef<T> Val) {
330  assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
331  assert(Val.data() != getTombstoneKey().data() &&
332  "Cannot hash the tombstone key!");
333  return (unsigned)(hash_value(Val));
334  }
335 
336  static bool isEqual(ArrayRef<T> LHS, ArrayRef<T> RHS) {
337  if (RHS.data() == getEmptyKey().data())
338  return LHS.data() == getEmptyKey().data();
339  if (RHS.data() == getTombstoneKey().data())
340  return LHS.data() == getTombstoneKey().data();
341  return LHS == RHS;
342  }
343 };
344 
345 template <> struct DenseMapInfo<hash_code> {
346  static inline hash_code getEmptyKey() { return hash_code(-1); }
347  static inline hash_code getTombstoneKey() { return hash_code(-2); }
348  static unsigned getHashValue(hash_code val) { return val; }
349  static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
350 };
351 
352 /// Provide DenseMapInfo for APInt.
353 template <> struct DenseMapInfo<APInt> {
354  static inline APInt getEmptyKey() {
355  APInt V(nullptr, 0);
356  V.U.VAL = 0;
357  return V;
358  }
359 
360  static inline APInt getTombstoneKey() {
361  APInt V(nullptr, 0);
362  V.U.VAL = 1;
363  return V;
364  }
365 
366  static unsigned getHashValue(const APInt &Key) {
367  return static_cast<unsigned>(hash_value(Key));
368  }
369 
370  static bool isEqual(const APInt &LHS, const APInt &RHS) {
371  return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
372  }
373 };
374 
375 /// Provide DenseMapInfo for APSInt, using the DenseMapInfo for APInt.
376 template <> struct DenseMapInfo<APSInt> {
377  static inline APSInt getEmptyKey() {
379  }
380 
381  static inline APSInt getTombstoneKey() {
383  }
384 
385  static unsigned getHashValue(const APSInt &Key) {
386  return static_cast<unsigned>(hash_value(Key));
387  }
388 
389  static bool isEqual(const APSInt &LHS, const APSInt &RHS) {
390  return LHS.getBitWidth() == RHS.getBitWidth() &&
391  LHS.isUnsigned() == RHS.isUnsigned() && LHS == RHS;
392  }
393 };
394 
395 } // end namespace llvm
396 
397 #endif // LLVM_ADT_DENSEMAPINFO_H
llvm::DenseMapInfo< unsigned short >::getTombstoneKey
static unsigned short getTombstoneKey()
Definition: DenseMapInfo.h:112
llvm::DenseMapInfo< short >::getEmptyKey
static short getEmptyKey()
Definition: DenseMapInfo.h:162
llvm::DenseMapInfo< T * >::getTombstoneKey
static T * getTombstoneKey()
Definition: DenseMapInfo.h:73
llvm
Definition: AllocatorList.h:23
llvm::APInt::VAL
uint64_t VAL
Used to store the <= 64 bits integer value.
Definition: APInt.h:94
llvm::DenseMapInfo< std::tuple< Ts... > >::isEqualImpl
static bool isEqualImpl(const Tuple &lhs, const Tuple &rhs, std::false_type)
Definition: DenseMapInfo.h:271
llvm::DenseMapInfo< long long >::getEmptyKey
static long long getEmptyKey()
Definition: DenseMapInfo.h:198
llvm::DenseMapInfo< long >::getEmptyKey
static long getEmptyKey()
Definition: DenseMapInfo.h:181
llvm::DenseMapInfo< char >::getEmptyKey
static char getEmptyKey()
Definition: DenseMapInfo.h:89
llvm::DenseMapInfo< unsigned long long >::getHashValue
static unsigned getHashValue(const unsigned long long &Val)
Definition: DenseMapInfo.h:150
llvm::DenseMapInfo< StringRef >::getHashValue
static unsigned getHashValue(StringRef Val)
Definition: DenseMapInfo.h:301
llvm::DenseMapInfo< APInt >::getHashValue
static unsigned getHashValue(const APInt &Key)
Definition: DenseMapInfo.h:366
llvm::DenseMapInfo< std::tuple< Ts... > >::getTombstoneKey
static Tuple getTombstoneKey()
Definition: DenseMapInfo.h:247
StringRef.h
llvm::DenseMapInfo< APSInt >::getEmptyKey
static APSInt getEmptyKey()
Definition: DenseMapInfo.h:377
llvm::lltok::APSInt
@ APSInt
Definition: LLToken.h:488
llvm::DenseMapInfo< unsigned long >::getTombstoneKey
static unsigned long getTombstoneKey()
Definition: DenseMapInfo.h:134
APInt.h
llvm::APInt::getBitWidth
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1581
llvm::DenseMapInfo< T * >::getHashValue
static unsigned getHashValue(const T *PtrVal)
Definition: DenseMapInfo.h:79
llvm::DenseMapInfo< long >::getHashValue
static unsigned getHashValue(const long &Val)
Definition: DenseMapInfo.h:187
llvm::DenseMapInfo< char >::isEqual
static bool isEqual(const char &LHS, const char &RHS)
Definition: DenseMapInfo.h:93
T
#define T
Definition: Mips16ISelLowering.cpp:341
Hashing.h
llvm::DenseMapInfo< ArrayRef< T > >::getTombstoneKey
static ArrayRef< T > getTombstoneKey()
Definition: DenseMapInfo.h:324
llvm::DenseMapInfo< APInt >::getTombstoneKey
static APInt getTombstoneKey()
Definition: DenseMapInfo.h:360
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4803
llvm::DenseMapInfo< APInt >::getEmptyKey
static APInt getEmptyKey()
Definition: DenseMapInfo.h:354
llvm::DenseMapInfo< unsigned short >::isEqual
static bool isEqual(const unsigned short &LHS, const unsigned short &RHS)
Definition: DenseMapInfo.h:115
llvm::DenseMapInfo< unsigned long long >::isEqual
static bool isEqual(const unsigned long long &LHS, const unsigned long long &RHS)
Definition: DenseMapInfo.h:154
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:160
llvm::DenseMapInfo< long long >::isEqual
static bool isEqual(const long long &LHS, const long long &RHS)
Definition: DenseMapInfo.h:205
a
=0.0 ? 0.0 :(a > 0.0 ? 1.0 :-1.0) a
Definition: README.txt:489
llvm::DenseMapInfo< char >::getTombstoneKey
static char getTombstoneKey()
Definition: DenseMapInfo.h:90
llvm::DenseMapInfo
Definition: APInt.h:34
llvm::DenseMapInfo< StringRef >::getEmptyKey
static StringRef getEmptyKey()
Definition: DenseMapInfo.h:291
llvm::DenseMapInfo< unsigned >::isEqual
static bool isEqual(const unsigned &LHS, const unsigned &RHS)
Definition: DenseMapInfo.h:126
llvm::DenseMapInfo< long long >::getHashValue
static unsigned getHashValue(const long long &Val)
Definition: DenseMapInfo.h:201
llvm::DenseMapInfo< unsigned char >::isEqual
static bool isEqual(const unsigned char &LHS, const unsigned char &RHS)
Definition: DenseMapInfo.h:104
llvm::DenseMapInfo< int >::getHashValue
static unsigned getHashValue(const int &Val)
Definition: DenseMapInfo.h:172
llvm::DenseMapInfo< std::tuple< Ts... > >::Tuple
std::tuple< Ts... > Tuple
Definition: DenseMapInfo.h:241
llvm::DenseMapInfo< unsigned long >::getHashValue
static unsigned getHashValue(const unsigned long &Val)
Definition: DenseMapInfo.h:136
llvm::DenseMapInfo< unsigned short >::getEmptyKey
static unsigned short getEmptyKey()
Definition: DenseMapInfo.h:111
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::DenseMapInfo< StringRef >::isEqual
static bool isEqual(StringRef LHS, StringRef RHS)
Definition: DenseMapInfo.h:308
llvm::DenseMapInfo< unsigned long long >::getEmptyKey
static unsigned long long getEmptyKey()
Definition: DenseMapInfo.h:147
b
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int b
Definition: README.txt:418
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
llvm::DenseMapInfo< unsigned short >::getHashValue
static unsigned getHashValue(const unsigned short &Val)
Definition: DenseMapInfo.h:113
llvm::DenseMapInfo< std::tuple< Ts... > >::isEqualImpl
static bool isEqualImpl(const Tuple &, const Tuple &, std::true_type)
Definition: DenseMapInfo.h:279
llvm::APSInt
An arbitrary precision integer that knows its signedness.
Definition: APSInt.h:22
llvm::DenseMapInfo< int >::getTombstoneKey
static int getTombstoneKey()
Definition: DenseMapInfo.h:171
llvm::DenseMapInfo< T * >::getEmptyKey
static T * getEmptyKey()
Definition: DenseMapInfo.h:67
llvm::DenseMapInfo< std::pair< T, U > >::getHashValue
static unsigned getHashValue(const Pair &PairVal)
Definition: DenseMapInfo.h:228
llvm::detail::combineHashValue
static unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
Definition: DenseMapInfo.h:31
llvm::DenseMapInfo< unsigned long >::getEmptyKey
static unsigned long getEmptyKey()
Definition: DenseMapInfo.h:133
llvm::DenseMapInfo< long >::getTombstoneKey
static long getTombstoneKey()
Definition: DenseMapInfo.h:185
llvm::DenseMapInfo< APSInt >::getHashValue
static unsigned getHashValue(const APSInt &Key)
Definition: DenseMapInfo.h:385
llvm::DenseMapInfo< ArrayRef< T > >::isEqual
static bool isEqual(ArrayRef< T > LHS, ArrayRef< T > RHS)
Definition: DenseMapInfo.h:336
val
The initial backend is deliberately restricted to z10 We should add support for later architectures at some point If an asm ties an i32 r result to an i64 the input will be treated as an leaving the upper bits uninitialised For i64 store i32 val
Definition: README.txt:15
llvm::DenseMapInfo< APInt >::isEqual
static bool isEqual(const APInt &LHS, const APInt &RHS)
Definition: DenseMapInfo.h:370
llvm::DenseMapInfo< unsigned >::getHashValue
static unsigned getHashValue(const unsigned &Val)
Definition: DenseMapInfo.h:124
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:699
type
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
Definition: README-X86-64.txt:70
llvm::DenseMapInfo< std::tuple< Ts... > >::getHashValue
static unsigned getHashValue(const std::tuple< Ts... > &values)
Definition: DenseMapInfo.h:265
llvm::DenseMapInfo< hash_code >::isEqual
static bool isEqual(hash_code LHS, hash_code RHS)
Definition: DenseMapInfo.h:349
llvm::DenseMapInfo< T * >::isEqual
static bool isEqual(const T *LHS, const T *RHS)
Definition: DenseMapInfo.h:84
I
#define I(x, y, z)
Definition: MD5.cpp:59
ArrayRef.h
llvm::DenseMapInfo< long >::isEqual
static bool isEqual(const long &LHS, const long &RHS)
Definition: DenseMapInfo.h:191
llvm::DenseMapInfo< unsigned >::getEmptyKey
static unsigned getEmptyKey()
Definition: DenseMapInfo.h:122
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::DenseMapInfo< short >::getTombstoneKey
static short getTombstoneKey()
Definition: DenseMapInfo.h:163
llvm::DenseMapInfo< std::tuple< Ts... > >::getEmptyKey
static Tuple getEmptyKey()
Definition: DenseMapInfo.h:243
llvm::APSInt::isUnsigned
bool isUnsigned() const
Definition: APSInt.h:77
APSInt.h
llvm::DenseMapInfo< hash_code >::getTombstoneKey
static hash_code getTombstoneKey()
Definition: DenseMapInfo.h:347
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:70
llvm::DenseMapInfo< std::pair< T, U > >::isEqual
static bool isEqual(const Pair &LHS, const Pair &RHS)
Definition: DenseMapInfo.h:233
llvm::DenseMapInfo< std::pair< T, U > >::Pair
std::pair< T, U > Pair
Definition: DenseMapInfo.h:214
llvm::DenseMapInfo< hash_code >::getHashValue
static unsigned getHashValue(hash_code val)
Definition: DenseMapInfo.h:348
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::DenseMapInfo< int >::isEqual
static bool isEqual(const int &LHS, const int &RHS)
Definition: DenseMapInfo.h:174
llvm::DenseMapInfo< char >::getHashValue
static unsigned getHashValue(const char &Val)
Definition: DenseMapInfo.h:91
llvm::DenseMapInfo< unsigned char >::getEmptyKey
static unsigned char getEmptyKey()
Definition: DenseMapInfo.h:100
llvm::DenseMapInfo< unsigned char >::getTombstoneKey
static unsigned char getTombstoneKey()
Definition: DenseMapInfo.h:101
llvm::DenseMapInfo< int >::getEmptyKey
static int getEmptyKey()
Definition: DenseMapInfo.h:170
llvm::DenseMapInfo< APSInt >::getTombstoneKey
static APSInt getTombstoneKey()
Definition: DenseMapInfo.h:381
llvm::DenseMapInfo< unsigned char >::getHashValue
static unsigned getHashValue(const unsigned char &Val)
Definition: DenseMapInfo.h:102
llvm::DenseMapInfo< StringRef >::getTombstoneKey
static StringRef getTombstoneKey()
Definition: DenseMapInfo.h:296
std
Definition: BitVector.h:838
llvm::DenseMapInfo< unsigned long >::isEqual
static bool isEqual(const unsigned long &LHS, const unsigned long &RHS)
Definition: DenseMapInfo.h:140
llvm::DenseMapInfo< std::tuple< Ts... > >::getHashValueImpl
static unsigned getHashValueImpl(const Tuple &values, std::false_type)
Definition: DenseMapInfo.h:252
isEqual
static bool isEqual(const Function &Caller, const Function &Callee)
Definition: Attributes.cpp:2127
llvm::DenseMapInfo< std::tuple< Ts... > >::isEqual
static bool isEqual(const Tuple &lhs, const Tuple &rhs)
Definition: DenseMapInfo.h:283
llvm::DenseMapInfo< hash_code >::getEmptyKey
static hash_code getEmptyKey()
Definition: DenseMapInfo.h:346
llvm::DenseMapInfo< std::tuple< Ts... > >::getHashValueImpl
static unsigned getHashValueImpl(const Tuple &, std::true_type)
Definition: DenseMapInfo.h:261
llvm::DenseMapInfo< long long >::getTombstoneKey
static long long getTombstoneKey()
Definition: DenseMapInfo.h:199
llvm::DenseMapInfo< ArrayRef< T > >::getEmptyKey
static ArrayRef< T > getEmptyKey()
Definition: DenseMapInfo.h:319
llvm::DenseMapInfo< unsigned >::getTombstoneKey
static unsigned getTombstoneKey()
Definition: DenseMapInfo.h:123
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:152
llvm::DenseMapInfo< short >::getHashValue
static unsigned getHashValue(const short &Val)
Definition: DenseMapInfo.h:164
llvm::DenseMapInfo< ArrayRef< T > >::getHashValue
static unsigned getHashValue(ArrayRef< T > Val)
Definition: DenseMapInfo.h:329
llvm::DenseMapInfo< unsigned long long >::getTombstoneKey
static unsigned long long getTombstoneKey()
Definition: DenseMapInfo.h:148
llvm::DenseMapInfo< short >::isEqual
static bool isEqual(const short &LHS, const short &RHS)
Definition: DenseMapInfo.h:165
llvm::DenseMapInfo< std::pair< T, U > >::getTombstoneKey
static Pair getTombstoneKey()
Definition: DenseMapInfo.h:223
llvm::DenseMapInfo< std::pair< T, U > >::getEmptyKey
static Pair getEmptyKey()
Definition: DenseMapInfo.h:218
llvm::DenseMapInfo< APSInt >::isEqual
static bool isEqual(const APSInt &LHS, const APSInt &RHS)
Definition: DenseMapInfo.h:389
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:72