LLVM 22.0.0git
TargetLoweringBase.cpp
Go to the documentation of this file.
1//===- TargetLoweringBase.cpp - Implement the TargetLoweringBase class ----===//
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 implements the TargetLoweringBase class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/ADT/BitVector.h"
14#include "llvm/ADT/STLExtras.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/ADT/Twine.h"
19#include "llvm/Analysis/Loads.h"
38#include "llvm/IR/Attributes.h"
39#include "llvm/IR/CallingConv.h"
40#include "llvm/IR/DataLayout.h"
42#include "llvm/IR/Function.h"
43#include "llvm/IR/GlobalValue.h"
45#include "llvm/IR/IRBuilder.h"
46#include "llvm/IR/Module.h"
47#include "llvm/IR/Type.h"
57#include <algorithm>
58#include <cassert>
59#include <cstdint>
60#include <cstring>
61#include <iterator>
62#include <string>
63#include <tuple>
64#include <utility>
65
66using namespace llvm;
67
69 "jump-is-expensive", cl::init(false),
70 cl::desc("Do not create extra branches to split comparison logic."),
72
74 ("min-jump-table-entries", cl::init(4), cl::Hidden,
75 cl::desc("Set minimum number of entries to use a jump table."));
76
78 ("max-jump-table-size", cl::init(UINT_MAX), cl::Hidden,
79 cl::desc("Set maximum size of jump tables."));
80
81/// Minimum jump table density for normal functions.
83 JumpTableDensity("jump-table-density", cl::init(10), cl::Hidden,
84 cl::desc("Minimum density for building a jump table in "
85 "a normal function"));
86
87/// Minimum jump table density for -Os or -Oz functions.
89 "optsize-jump-table-density", cl::init(40), cl::Hidden,
90 cl::desc("Minimum density for building a jump table in "
91 "an optsize function"));
92
93// FIXME: This option is only to test if the strict fp operation processed
94// correctly by preventing mutating strict fp operation to normal fp operation
95// during development. When the backend supports strict float operation, this
96// option will be meaningless.
97static cl::opt<bool> DisableStrictNodeMutation("disable-strictnode-mutation",
98 cl::desc("Don't mutate strict-float node to a legalize node"),
99 cl::init(false), cl::Hidden);
100
101/// GetFPLibCall - Helper to return the right libcall for the given floating
102/// point type, or UNKNOWN_LIBCALL if there is none.
103RTLIB::Libcall RTLIB::getFPLibCall(EVT VT,
104 RTLIB::Libcall Call_F32,
105 RTLIB::Libcall Call_F64,
106 RTLIB::Libcall Call_F80,
107 RTLIB::Libcall Call_F128,
108 RTLIB::Libcall Call_PPCF128) {
109 return
110 VT == MVT::f32 ? Call_F32 :
111 VT == MVT::f64 ? Call_F64 :
112 VT == MVT::f80 ? Call_F80 :
113 VT == MVT::f128 ? Call_F128 :
114 VT == MVT::ppcf128 ? Call_PPCF128 :
115 RTLIB::UNKNOWN_LIBCALL;
116}
117
118/// getFPEXT - Return the FPEXT_*_* value for the given types, or
119/// UNKNOWN_LIBCALL if there is none.
120RTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) {
121 if (OpVT == MVT::f16) {
122 if (RetVT == MVT::f32)
123 return FPEXT_F16_F32;
124 if (RetVT == MVT::f64)
125 return FPEXT_F16_F64;
126 if (RetVT == MVT::f80)
127 return FPEXT_F16_F80;
128 if (RetVT == MVT::f128)
129 return FPEXT_F16_F128;
130 } else if (OpVT == MVT::f32) {
131 if (RetVT == MVT::f64)
132 return FPEXT_F32_F64;
133 if (RetVT == MVT::f128)
134 return FPEXT_F32_F128;
135 if (RetVT == MVT::ppcf128)
136 return FPEXT_F32_PPCF128;
137 } else if (OpVT == MVT::f64) {
138 if (RetVT == MVT::f128)
139 return FPEXT_F64_F128;
140 else if (RetVT == MVT::ppcf128)
141 return FPEXT_F64_PPCF128;
142 } else if (OpVT == MVT::f80) {
143 if (RetVT == MVT::f128)
144 return FPEXT_F80_F128;
145 } else if (OpVT == MVT::bf16) {
146 if (RetVT == MVT::f32)
147 return FPEXT_BF16_F32;
148 }
149
150 return UNKNOWN_LIBCALL;
151}
152
153/// getFPROUND - Return the FPROUND_*_* value for the given types, or
154/// UNKNOWN_LIBCALL if there is none.
155RTLIB::Libcall RTLIB::getFPROUND(EVT OpVT, EVT RetVT) {
156 if (RetVT == MVT::f16) {
157 if (OpVT == MVT::f32)
158 return FPROUND_F32_F16;
159 if (OpVT == MVT::f64)
160 return FPROUND_F64_F16;
161 if (OpVT == MVT::f80)
162 return FPROUND_F80_F16;
163 if (OpVT == MVT::f128)
164 return FPROUND_F128_F16;
165 if (OpVT == MVT::ppcf128)
166 return FPROUND_PPCF128_F16;
167 } else if (RetVT == MVT::bf16) {
168 if (OpVT == MVT::f32)
169 return FPROUND_F32_BF16;
170 if (OpVT == MVT::f64)
171 return FPROUND_F64_BF16;
172 if (OpVT == MVT::f80)
173 return FPROUND_F80_BF16;
174 if (OpVT == MVT::f128)
175 return FPROUND_F128_BF16;
176 } else if (RetVT == MVT::f32) {
177 if (OpVT == MVT::f64)
178 return FPROUND_F64_F32;
179 if (OpVT == MVT::f80)
180 return FPROUND_F80_F32;
181 if (OpVT == MVT::f128)
182 return FPROUND_F128_F32;
183 if (OpVT == MVT::ppcf128)
184 return FPROUND_PPCF128_F32;
185 } else if (RetVT == MVT::f64) {
186 if (OpVT == MVT::f80)
187 return FPROUND_F80_F64;
188 if (OpVT == MVT::f128)
189 return FPROUND_F128_F64;
190 if (OpVT == MVT::ppcf128)
191 return FPROUND_PPCF128_F64;
192 } else if (RetVT == MVT::f80) {
193 if (OpVT == MVT::f128)
194 return FPROUND_F128_F80;
195 }
196
197 return UNKNOWN_LIBCALL;
198}
199
200/// getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or
201/// UNKNOWN_LIBCALL if there is none.
202RTLIB::Libcall RTLIB::getFPTOSINT(EVT OpVT, EVT RetVT) {
203 if (OpVT == MVT::f16) {
204 if (RetVT == MVT::i32)
205 return FPTOSINT_F16_I32;
206 if (RetVT == MVT::i64)
207 return FPTOSINT_F16_I64;
208 if (RetVT == MVT::i128)
209 return FPTOSINT_F16_I128;
210 } else if (OpVT == MVT::f32) {
211 if (RetVT == MVT::i32)
212 return FPTOSINT_F32_I32;
213 if (RetVT == MVT::i64)
214 return FPTOSINT_F32_I64;
215 if (RetVT == MVT::i128)
216 return FPTOSINT_F32_I128;
217 } else if (OpVT == MVT::f64) {
218 if (RetVT == MVT::i32)
219 return FPTOSINT_F64_I32;
220 if (RetVT == MVT::i64)
221 return FPTOSINT_F64_I64;
222 if (RetVT == MVT::i128)
223 return FPTOSINT_F64_I128;
224 } else if (OpVT == MVT::f80) {
225 if (RetVT == MVT::i32)
226 return FPTOSINT_F80_I32;
227 if (RetVT == MVT::i64)
228 return FPTOSINT_F80_I64;
229 if (RetVT == MVT::i128)
230 return FPTOSINT_F80_I128;
231 } else if (OpVT == MVT::f128) {
232 if (RetVT == MVT::i32)
233 return FPTOSINT_F128_I32;
234 if (RetVT == MVT::i64)
235 return FPTOSINT_F128_I64;
236 if (RetVT == MVT::i128)
237 return FPTOSINT_F128_I128;
238 } else if (OpVT == MVT::ppcf128) {
239 if (RetVT == MVT::i32)
240 return FPTOSINT_PPCF128_I32;
241 if (RetVT == MVT::i64)
242 return FPTOSINT_PPCF128_I64;
243 if (RetVT == MVT::i128)
244 return FPTOSINT_PPCF128_I128;
245 }
246 return UNKNOWN_LIBCALL;
247}
248
249/// getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or
250/// UNKNOWN_LIBCALL if there is none.
251RTLIB::Libcall RTLIB::getFPTOUINT(EVT OpVT, EVT RetVT) {
252 if (OpVT == MVT::f16) {
253 if (RetVT == MVT::i32)
254 return FPTOUINT_F16_I32;
255 if (RetVT == MVT::i64)
256 return FPTOUINT_F16_I64;
257 if (RetVT == MVT::i128)
258 return FPTOUINT_F16_I128;
259 } else if (OpVT == MVT::f32) {
260 if (RetVT == MVT::i32)
261 return FPTOUINT_F32_I32;
262 if (RetVT == MVT::i64)
263 return FPTOUINT_F32_I64;
264 if (RetVT == MVT::i128)
265 return FPTOUINT_F32_I128;
266 } else if (OpVT == MVT::f64) {
267 if (RetVT == MVT::i32)
268 return FPTOUINT_F64_I32;
269 if (RetVT == MVT::i64)
270 return FPTOUINT_F64_I64;
271 if (RetVT == MVT::i128)
272 return FPTOUINT_F64_I128;
273 } else if (OpVT == MVT::f80) {
274 if (RetVT == MVT::i32)
275 return FPTOUINT_F80_I32;
276 if (RetVT == MVT::i64)
277 return FPTOUINT_F80_I64;
278 if (RetVT == MVT::i128)
279 return FPTOUINT_F80_I128;
280 } else if (OpVT == MVT::f128) {
281 if (RetVT == MVT::i32)
282 return FPTOUINT_F128_I32;
283 if (RetVT == MVT::i64)
284 return FPTOUINT_F128_I64;
285 if (RetVT == MVT::i128)
286 return FPTOUINT_F128_I128;
287 } else if (OpVT == MVT::ppcf128) {
288 if (RetVT == MVT::i32)
289 return FPTOUINT_PPCF128_I32;
290 if (RetVT == MVT::i64)
291 return FPTOUINT_PPCF128_I64;
292 if (RetVT == MVT::i128)
293 return FPTOUINT_PPCF128_I128;
294 }
295 return UNKNOWN_LIBCALL;
296}
297
298/// getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or
299/// UNKNOWN_LIBCALL if there is none.
300RTLIB::Libcall RTLIB::getSINTTOFP(EVT OpVT, EVT RetVT) {
301 if (OpVT == MVT::i32) {
302 if (RetVT == MVT::f16)
303 return SINTTOFP_I32_F16;
304 if (RetVT == MVT::f32)
305 return SINTTOFP_I32_F32;
306 if (RetVT == MVT::f64)
307 return SINTTOFP_I32_F64;
308 if (RetVT == MVT::f80)
309 return SINTTOFP_I32_F80;
310 if (RetVT == MVT::f128)
311 return SINTTOFP_I32_F128;
312 if (RetVT == MVT::ppcf128)
313 return SINTTOFP_I32_PPCF128;
314 } else if (OpVT == MVT::i64) {
315 if (RetVT == MVT::bf16)
316 return SINTTOFP_I64_BF16;
317 if (RetVT == MVT::f16)
318 return SINTTOFP_I64_F16;
319 if (RetVT == MVT::f32)
320 return SINTTOFP_I64_F32;
321 if (RetVT == MVT::f64)
322 return SINTTOFP_I64_F64;
323 if (RetVT == MVT::f80)
324 return SINTTOFP_I64_F80;
325 if (RetVT == MVT::f128)
326 return SINTTOFP_I64_F128;
327 if (RetVT == MVT::ppcf128)
328 return SINTTOFP_I64_PPCF128;
329 } else if (OpVT == MVT::i128) {
330 if (RetVT == MVT::f16)
331 return SINTTOFP_I128_F16;
332 if (RetVT == MVT::f32)
333 return SINTTOFP_I128_F32;
334 if (RetVT == MVT::f64)
335 return SINTTOFP_I128_F64;
336 if (RetVT == MVT::f80)
337 return SINTTOFP_I128_F80;
338 if (RetVT == MVT::f128)
339 return SINTTOFP_I128_F128;
340 if (RetVT == MVT::ppcf128)
341 return SINTTOFP_I128_PPCF128;
342 }
343 return UNKNOWN_LIBCALL;
344}
345
346/// getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or
347/// UNKNOWN_LIBCALL if there is none.
348RTLIB::Libcall RTLIB::getUINTTOFP(EVT OpVT, EVT RetVT) {
349 if (OpVT == MVT::i32) {
350 if (RetVT == MVT::f16)
351 return UINTTOFP_I32_F16;
352 if (RetVT == MVT::f32)
353 return UINTTOFP_I32_F32;
354 if (RetVT == MVT::f64)
355 return UINTTOFP_I32_F64;
356 if (RetVT == MVT::f80)
357 return UINTTOFP_I32_F80;
358 if (RetVT == MVT::f128)
359 return UINTTOFP_I32_F128;
360 if (RetVT == MVT::ppcf128)
361 return UINTTOFP_I32_PPCF128;
362 } else if (OpVT == MVT::i64) {
363 if (RetVT == MVT::bf16)
364 return UINTTOFP_I64_BF16;
365 if (RetVT == MVT::f16)
366 return UINTTOFP_I64_F16;
367 if (RetVT == MVT::f32)
368 return UINTTOFP_I64_F32;
369 if (RetVT == MVT::f64)
370 return UINTTOFP_I64_F64;
371 if (RetVT == MVT::f80)
372 return UINTTOFP_I64_F80;
373 if (RetVT == MVT::f128)
374 return UINTTOFP_I64_F128;
375 if (RetVT == MVT::ppcf128)
376 return UINTTOFP_I64_PPCF128;
377 } else if (OpVT == MVT::i128) {
378 if (RetVT == MVT::f16)
379 return UINTTOFP_I128_F16;
380 if (RetVT == MVT::f32)
381 return UINTTOFP_I128_F32;
382 if (RetVT == MVT::f64)
383 return UINTTOFP_I128_F64;
384 if (RetVT == MVT::f80)
385 return UINTTOFP_I128_F80;
386 if (RetVT == MVT::f128)
387 return UINTTOFP_I128_F128;
388 if (RetVT == MVT::ppcf128)
389 return UINTTOFP_I128_PPCF128;
390 }
391 return UNKNOWN_LIBCALL;
392}
393
394RTLIB::Libcall RTLIB::getPOWI(EVT RetVT) {
395 return getFPLibCall(RetVT, POWI_F32, POWI_F64, POWI_F80, POWI_F128,
396 POWI_PPCF128);
397}
398
399RTLIB::Libcall RTLIB::getPOW(EVT RetVT) {
400 return getFPLibCall(RetVT, POW_F32, POW_F64, POW_F80, POW_F128, POW_PPCF128);
401}
402
403RTLIB::Libcall RTLIB::getLDEXP(EVT RetVT) {
404 return getFPLibCall(RetVT, LDEXP_F32, LDEXP_F64, LDEXP_F80, LDEXP_F128,
405 LDEXP_PPCF128);
406}
407
408RTLIB::Libcall RTLIB::getFREXP(EVT RetVT) {
409 return getFPLibCall(RetVT, FREXP_F32, FREXP_F64, FREXP_F80, FREXP_F128,
410 FREXP_PPCF128);
411}
412
413RTLIB::Libcall RTLIB::getSIN(EVT RetVT) {
414 return getFPLibCall(RetVT, SIN_F32, SIN_F64, SIN_F80, SIN_F128, SIN_PPCF128);
415}
416
417RTLIB::Libcall RTLIB::getCOS(EVT RetVT) {
418 return getFPLibCall(RetVT, COS_F32, COS_F64, COS_F80, COS_F128, COS_PPCF128);
419}
420
421RTLIB::Libcall RTLIB::getSINCOS(EVT RetVT) {
422 return getFPLibCall(RetVT, SINCOS_F32, SINCOS_F64, SINCOS_F80, SINCOS_F128,
423 SINCOS_PPCF128);
424}
425
426RTLIB::Libcall RTLIB::getSINCOSPI(EVT RetVT) {
427 return getFPLibCall(RetVT, SINCOSPI_F32, SINCOSPI_F64, SINCOSPI_F80,
428 SINCOSPI_F128, SINCOSPI_PPCF128);
429}
430
431RTLIB::Libcall RTLIB::getMODF(EVT RetVT) {
432 return getFPLibCall(RetVT, MODF_F32, MODF_F64, MODF_F80, MODF_F128,
433 MODF_PPCF128);
434}
435
436RTLIB::Libcall RTLIB::getOutlineAtomicHelper(const Libcall (&LC)[5][4],
437 AtomicOrdering Order,
438 uint64_t MemSize) {
439 unsigned ModeN, ModelN;
440 switch (MemSize) {
441 case 1:
442 ModeN = 0;
443 break;
444 case 2:
445 ModeN = 1;
446 break;
447 case 4:
448 ModeN = 2;
449 break;
450 case 8:
451 ModeN = 3;
452 break;
453 case 16:
454 ModeN = 4;
455 break;
456 default:
457 return RTLIB::UNKNOWN_LIBCALL;
458 }
459
460 switch (Order) {
461 case AtomicOrdering::Monotonic:
462 ModelN = 0;
463 break;
464 case AtomicOrdering::Acquire:
465 ModelN = 1;
466 break;
467 case AtomicOrdering::Release:
468 ModelN = 2;
469 break;
470 case AtomicOrdering::AcquireRelease:
471 case AtomicOrdering::SequentiallyConsistent:
472 ModelN = 3;
473 break;
474 default:
475 return UNKNOWN_LIBCALL;
476 }
477
478 return LC[ModeN][ModelN];
479}
480
481RTLIB::Libcall RTLIB::getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order,
482 MVT VT) {
483 if (!VT.isScalarInteger())
484 return UNKNOWN_LIBCALL;
485 uint64_t MemSize = VT.getScalarSizeInBits() / 8;
486
487#define LCALLS(A, B) \
488 { A##B##_RELAX, A##B##_ACQ, A##B##_REL, A##B##_ACQ_REL }
489#define LCALL5(A) \
490 LCALLS(A, 1), LCALLS(A, 2), LCALLS(A, 4), LCALLS(A, 8), LCALLS(A, 16)
491 switch (Opc) {
493 const Libcall LC[5][4] = {LCALL5(OUTLINE_ATOMIC_CAS)};
494 return getOutlineAtomicHelper(LC, Order, MemSize);
495 }
496 case ISD::ATOMIC_SWAP: {
497 const Libcall LC[5][4] = {LCALL5(OUTLINE_ATOMIC_SWP)};
498 return getOutlineAtomicHelper(LC, Order, MemSize);
499 }
501 const Libcall LC[5][4] = {LCALL5(OUTLINE_ATOMIC_LDADD)};
502 return getOutlineAtomicHelper(LC, Order, MemSize);
503 }
504 case ISD::ATOMIC_LOAD_OR: {
505 const Libcall LC[5][4] = {LCALL5(OUTLINE_ATOMIC_LDSET)};
506 return getOutlineAtomicHelper(LC, Order, MemSize);
507 }
509 const Libcall LC[5][4] = {LCALL5(OUTLINE_ATOMIC_LDCLR)};
510 return getOutlineAtomicHelper(LC, Order, MemSize);
511 }
513 const Libcall LC[5][4] = {LCALL5(OUTLINE_ATOMIC_LDEOR)};
514 return getOutlineAtomicHelper(LC, Order, MemSize);
515 }
516 default:
517 return UNKNOWN_LIBCALL;
518 }
519#undef LCALLS
520#undef LCALL5
521}
522
523RTLIB::Libcall RTLIB::getSYNC(unsigned Opc, MVT VT) {
524#define OP_TO_LIBCALL(Name, Enum) \
525 case Name: \
526 switch (VT.SimpleTy) { \
527 default: \
528 return UNKNOWN_LIBCALL; \
529 case MVT::i8: \
530 return Enum##_1; \
531 case MVT::i16: \
532 return Enum##_2; \
533 case MVT::i32: \
534 return Enum##_4; \
535 case MVT::i64: \
536 return Enum##_8; \
537 case MVT::i128: \
538 return Enum##_16; \
539 }
540
541 switch (Opc) {
542 OP_TO_LIBCALL(ISD::ATOMIC_SWAP, SYNC_LOCK_TEST_AND_SET)
543 OP_TO_LIBCALL(ISD::ATOMIC_CMP_SWAP, SYNC_VAL_COMPARE_AND_SWAP)
544 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_ADD, SYNC_FETCH_AND_ADD)
545 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_SUB, SYNC_FETCH_AND_SUB)
546 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_AND, SYNC_FETCH_AND_AND)
547 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_OR, SYNC_FETCH_AND_OR)
548 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_XOR, SYNC_FETCH_AND_XOR)
549 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_NAND, SYNC_FETCH_AND_NAND)
550 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_MAX, SYNC_FETCH_AND_MAX)
551 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_UMAX, SYNC_FETCH_AND_UMAX)
552 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_MIN, SYNC_FETCH_AND_MIN)
553 OP_TO_LIBCALL(ISD::ATOMIC_LOAD_UMIN, SYNC_FETCH_AND_UMIN)
554 }
555
556#undef OP_TO_LIBCALL
557
558 return UNKNOWN_LIBCALL;
559}
560
562 switch (ElementSize) {
563 case 1:
564 return MEMCPY_ELEMENT_UNORDERED_ATOMIC_1;
565 case 2:
566 return MEMCPY_ELEMENT_UNORDERED_ATOMIC_2;
567 case 4:
568 return MEMCPY_ELEMENT_UNORDERED_ATOMIC_4;
569 case 8:
570 return MEMCPY_ELEMENT_UNORDERED_ATOMIC_8;
571 case 16:
572 return MEMCPY_ELEMENT_UNORDERED_ATOMIC_16;
573 default:
574 return UNKNOWN_LIBCALL;
575 }
576}
577
579 switch (ElementSize) {
580 case 1:
581 return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_1;
582 case 2:
583 return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_2;
584 case 4:
585 return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_4;
586 case 8:
587 return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_8;
588 case 16:
589 return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_16;
590 default:
591 return UNKNOWN_LIBCALL;
592 }
593}
594
596 switch (ElementSize) {
597 case 1:
598 return MEMSET_ELEMENT_UNORDERED_ATOMIC_1;
599 case 2:
600 return MEMSET_ELEMENT_UNORDERED_ATOMIC_2;
601 case 4:
602 return MEMSET_ELEMENT_UNORDERED_ATOMIC_4;
603 case 8:
604 return MEMSET_ELEMENT_UNORDERED_ATOMIC_8;
605 case 16:
606 return MEMSET_ELEMENT_UNORDERED_ATOMIC_16;
607 default:
608 return UNKNOWN_LIBCALL;
609 }
610}
611
613 RTLIB::LibcallImpl Impl) const {
614 switch (Impl) {
615 case RTLIB::impl___aeabi_dcmpeq__une:
616 case RTLIB::impl___aeabi_fcmpeq__une:
617 // Usage in the eq case, so we have to invert the comparison.
618 return ISD::SETEQ;
619 case RTLIB::impl___aeabi_dcmpeq__oeq:
620 case RTLIB::impl___aeabi_fcmpeq__oeq:
621 // Normal comparison to boolean value.
622 return ISD::SETNE;
623 case RTLIB::impl___aeabi_dcmplt:
624 case RTLIB::impl___aeabi_dcmple:
625 case RTLIB::impl___aeabi_dcmpge:
626 case RTLIB::impl___aeabi_dcmpgt:
627 case RTLIB::impl___aeabi_dcmpun:
628 case RTLIB::impl___aeabi_fcmplt:
629 case RTLIB::impl___aeabi_fcmple:
630 case RTLIB::impl___aeabi_fcmpge:
631 case RTLIB::impl___aeabi_fcmpgt:
632 /// The AEABI versions return a typical boolean value, so we can compare
633 /// against the integer result as simply != 0.
634 return ISD::SETNE;
635 default:
636 break;
637 }
638
639 // Assume libgcc/compiler-rt behavior. Most of the cases are really aliases of
640 // each other, and return a 3-way comparison style result of -1, 0, or 1
641 // depending on lt/eq/gt.
642 //
643 // FIXME: It would be cleaner to directly express this as a 3-way comparison
644 // soft FP libcall instead of individual compares.
645 RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
646 switch (LC) {
647 case RTLIB::OEQ_F32:
648 case RTLIB::OEQ_F64:
649 case RTLIB::OEQ_F128:
650 case RTLIB::OEQ_PPCF128:
651 return ISD::SETEQ;
652 case RTLIB::UNE_F32:
653 case RTLIB::UNE_F64:
654 case RTLIB::UNE_F128:
655 case RTLIB::UNE_PPCF128:
656 return ISD::SETNE;
657 case RTLIB::OGE_F32:
658 case RTLIB::OGE_F64:
659 case RTLIB::OGE_F128:
660 case RTLIB::OGE_PPCF128:
661 return ISD::SETGE;
662 case RTLIB::OLT_F32:
663 case RTLIB::OLT_F64:
664 case RTLIB::OLT_F128:
665 case RTLIB::OLT_PPCF128:
666 return ISD::SETLT;
667 case RTLIB::OLE_F32:
668 case RTLIB::OLE_F64:
669 case RTLIB::OLE_F128:
670 case RTLIB::OLE_PPCF128:
671 return ISD::SETLE;
672 case RTLIB::OGT_F32:
673 case RTLIB::OGT_F64:
674 case RTLIB::OGT_F128:
675 case RTLIB::OGT_PPCF128:
676 return ISD::SETGT;
677 case RTLIB::UO_F32:
678 case RTLIB::UO_F64:
679 case RTLIB::UO_F128:
680 case RTLIB::UO_PPCF128:
681 return ISD::SETNE;
682 default:
683 llvm_unreachable("not a compare libcall");
684 }
685}
686
687/// NOTE: The TargetMachine owns TLOF.
689 : TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.ExceptionModel,
690 TM.Options.FloatABIType, TM.Options.EABIVersion,
691 TM.Options.MCOptions.getABIName()) {
692 initActions();
693
694 // Perform these initializations only once.
700 HasExtractBitsInsn = false;
701 JumpIsExpensive = JumpIsExpensiveOverride;
703 EnableExtLdPromotion = false;
704 StackPointerRegisterToSaveRestore = 0;
705 BooleanContents = UndefinedBooleanContent;
706 BooleanFloatContents = UndefinedBooleanContent;
707 BooleanVectorContents = UndefinedBooleanContent;
708 SchedPreferenceInfo = Sched::ILP;
711 MaxBytesForAlignment = 0;
712 MaxAtomicSizeInBitsSupported = 0;
713
714 // Assume that even with libcalls, no target supports wider than 128 bit
715 // division.
716 MaxDivRemBitWidthSupported = 128;
717
718 MaxLargeFPConvertBitWidthSupported = llvm::IntegerType::MAX_INT_BITS;
719
720 MinCmpXchgSizeInBits = 0;
721 SupportsUnalignedAtomics = false;
722}
723
724// Define the virtual destructor out-of-line to act as a key method to anchor
725// debug info (see coding standards).
727
729 // All operations default to being supported.
730 memset(OpActions, 0, sizeof(OpActions));
731 memset(LoadExtActions, 0, sizeof(LoadExtActions));
732 memset(TruncStoreActions, 0, sizeof(TruncStoreActions));
733 memset(IndexedModeActions, 0, sizeof(IndexedModeActions));
734 memset(CondCodeActions, 0, sizeof(CondCodeActions));
735 llvm::fill(RegClassForVT, nullptr);
736 llvm::fill(TargetDAGCombineArray, 0);
737
738 // Let extending atomic loads be unsupported by default.
739 for (MVT ValVT : MVT::all_valuetypes())
740 for (MVT MemVT : MVT::all_valuetypes())
742 Expand);
743
744 // We're somewhat special casing MVT::i2 and MVT::i4. Ideally we want to
745 // remove this and targets should individually set these types if not legal.
748 for (MVT VT : {MVT::i2, MVT::i4})
749 OpActions[(unsigned)VT.SimpleTy][NT] = Expand;
750 }
751 for (MVT AVT : MVT::all_valuetypes()) {
752 for (MVT VT : {MVT::i2, MVT::i4, MVT::v128i2, MVT::v64i4}) {
753 setTruncStoreAction(AVT, VT, Expand);
756 }
757 }
758 for (unsigned IM = (unsigned)ISD::PRE_INC;
759 IM != (unsigned)ISD::LAST_INDEXED_MODE; ++IM) {
760 for (MVT VT : {MVT::i2, MVT::i4}) {
765 }
766 }
767
768 for (MVT VT : MVT::fp_valuetypes()) {
769 MVT IntVT = MVT::getIntegerVT(VT.getFixedSizeInBits());
770 if (IntVT.isValid()) {
773 }
774 }
775
776 // Set default actions for various operations.
777 for (MVT VT : MVT::all_valuetypes()) {
778 // Default all indexed load / store to expand.
779 for (unsigned IM = (unsigned)ISD::PRE_INC;
780 IM != (unsigned)ISD::LAST_INDEXED_MODE; ++IM) {
785 }
786
787 // Most backends expect to see the node which just returns the value loaded.
789
790 // These operations default to expand.
819 VT, Expand);
820
821 // Overflow operations default to expand
824 VT, Expand);
825
826 // Carry-using overflow operations default to expand.
829 VT, Expand);
830
831 // ADDC/ADDE/SUBC/SUBE default to expand.
833 Expand);
834
835 // [US]CMP default to expand
837
838 // Halving adds
841 Expand);
842
843 // Absolute difference
845
846 // Saturated trunc
850
851 // These default to Expand so they will be expanded to CTLZ/CTTZ by default.
853 Expand);
854
856
857 // These library functions default to expand.
860 VT, Expand);
861
862 // These operations default to expand for vector types.
863 if (VT.isVector())
869 VT, Expand);
870
871 // Constrained floating-point operations default to expand.
872#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \
873 setOperationAction(ISD::STRICT_##DAGN, VT, Expand);
874#include "llvm/IR/ConstrainedOps.def"
875
876 // For most targets @llvm.get.dynamic.area.offset just returns 0.
878
879 // Vector reduction default to expand.
887 VT, Expand);
888
889 // Named vector shuffles default to expand.
891
892 // Only some target support this vector operation. Most need to expand it.
894
895 // VP operations default to expand.
896#define BEGIN_REGISTER_VP_SDNODE(SDOPC, ...) \
897 setOperationAction(ISD::SDOPC, VT, Expand);
898#include "llvm/IR/VPIntrinsics.def"
899
900 // Masked vector extracts default to expand.
902
905
906 // FP environment operations default to expand.
910
912 }
913
914 // Most targets ignore the @llvm.prefetch intrinsic.
916
917 // Most targets also ignore the @llvm.readcyclecounter intrinsic.
919
920 // Most targets also ignore the @llvm.readsteadycounter intrinsic.
922
923 // ConstantFP nodes default to expand. Targets can either change this to
924 // Legal, in which case all fp constants are legal, or use isFPImmLegal()
925 // to optimize expansions for certain constants.
927 {MVT::bf16, MVT::f16, MVT::f32, MVT::f64, MVT::f80, MVT::f128},
928 Expand);
929
930 // Insert custom handling default for llvm.canonicalize.*.
932 {MVT::f16, MVT::f32, MVT::f64, MVT::f128}, Expand);
933
934 // FIXME: Query RuntimeLibCalls to make the decision.
936 {MVT::f32, MVT::f64, MVT::f128}, LibCall);
937
940 MVT::f16, Promote);
941 // Default ISD::TRAP to expand (which turns it into abort).
942 setOperationAction(ISD::TRAP, MVT::Other, Expand);
943
944 // On most systems, DEBUGTRAP and TRAP have no difference. The "Expand"
945 // here is to inform DAG Legalizer to replace DEBUGTRAP with TRAP.
947
949
952
953 for (MVT VT : {MVT::i8, MVT::i16, MVT::i32, MVT::i64}) {
956 }
958
959 // This one by default will call __clear_cache unless the target
960 // wants something different.
962}
963
965 EVT) const {
966 return MVT::getIntegerVT(DL.getPointerSizeInBits(0));
967}
968
970 const DataLayout &DL) const {
971 assert(LHSTy.isInteger() && "Shift amount is not an integer type!");
972 if (LHSTy.isVector())
973 return LHSTy;
974 MVT ShiftVT = getScalarShiftAmountTy(DL, LHSTy);
975 // If any possible shift value won't fit in the prefered type, just use
976 // something safe. Assume it will be legalized when the shift is expanded.
977 if (ShiftVT.getSizeInBits() < Log2_32_Ceil(LHSTy.getSizeInBits()))
978 ShiftVT = MVT::i32;
979 assert(ShiftVT.getSizeInBits() >= Log2_32_Ceil(LHSTy.getSizeInBits()) &&
980 "ShiftVT is still too small!");
981 return ShiftVT;
982}
983
984bool TargetLoweringBase::canOpTrap(unsigned Op, EVT VT) const {
985 assert(isTypeLegal(VT));
986 switch (Op) {
987 default:
988 return false;
989 case ISD::SDIV:
990 case ISD::UDIV:
991 case ISD::SREM:
992 case ISD::UREM:
993 return true;
994 }
995}
996
998 unsigned DestAS) const {
999 return TM.isNoopAddrSpaceCast(SrcAS, DestAS);
1000}
1001
1003 Type *RetTy, ElementCount EC, bool ZeroIsPoison,
1004 const ConstantRange *VScaleRange) const {
1005 // Find the smallest "sensible" element type to use for the expansion.
1006 ConstantRange CR(APInt(64, EC.getKnownMinValue()));
1007 if (EC.isScalable())
1008 CR = CR.umul_sat(*VScaleRange);
1009
1010 if (ZeroIsPoison)
1011 CR = CR.subtract(APInt(64, 1));
1012
1013 unsigned EltWidth = RetTy->getScalarSizeInBits();
1014 EltWidth = std::min(EltWidth, CR.getActiveBits());
1015 EltWidth = std::max(llvm::bit_ceil(EltWidth), (unsigned)8);
1016
1017 return EltWidth;
1018}
1019
1021 // If the command-line option was specified, ignore this request.
1023 JumpIsExpensive = isExpensive;
1024}
1025
1028 // If this is a simple type, use the ComputeRegisterProp mechanism.
1029 if (VT.isSimple()) {
1030 MVT SVT = VT.getSimpleVT();
1031 assert((unsigned)SVT.SimpleTy < std::size(TransformToType));
1032 MVT NVT = TransformToType[SVT.SimpleTy];
1033 LegalizeTypeAction LA = ValueTypeActions.getTypeAction(SVT);
1034
1035 assert((LA == TypeLegal || LA == TypeSoftenFloat ||
1036 LA == TypeSoftPromoteHalf ||
1037 (NVT.isVector() ||
1038 ValueTypeActions.getTypeAction(NVT) != TypePromoteInteger)) &&
1039 "Promote may not follow Expand or Promote");
1040
1041 if (LA == TypeSplitVector)
1042 return LegalizeKind(LA, EVT(SVT).getHalfNumVectorElementsVT(Context));
1043 if (LA == TypeScalarizeVector)
1044 return LegalizeKind(LA, SVT.getVectorElementType());
1045 return LegalizeKind(LA, NVT);
1046 }
1047
1048 // Handle Extended Scalar Types.
1049 if (!VT.isVector()) {
1050 assert(VT.isInteger() && "Float types must be simple");
1051 unsigned BitSize = VT.getSizeInBits();
1052 // First promote to a power-of-two size, then expand if necessary.
1053 if (BitSize < 8 || !isPowerOf2_32(BitSize)) {
1055 assert(NVT != VT && "Unable to round integer VT");
1056 LegalizeKind NextStep = getTypeConversion(Context, NVT);
1057 // Avoid multi-step promotion.
1058 if (NextStep.first == TypePromoteInteger)
1059 return NextStep;
1060 // Return rounded integer type.
1061 return LegalizeKind(TypePromoteInteger, NVT);
1062 }
1063
1066 }
1067
1068 // Handle vector types.
1069 ElementCount NumElts = VT.getVectorElementCount();
1070 EVT EltVT = VT.getVectorElementType();
1071
1072 // Vectors with only one element are always scalarized.
1073 if (NumElts.isScalar())
1074 return LegalizeKind(TypeScalarizeVector, EltVT);
1075
1076 // Try to widen vector elements until the element type is a power of two and
1077 // promote it to a legal type later on, for example:
1078 // <3 x i8> -> <4 x i8> -> <4 x i32>
1079 if (EltVT.isInteger()) {
1080 // Vectors with a number of elements that is not a power of two are always
1081 // widened, for example <3 x i8> -> <4 x i8>.
1082 if (!VT.isPow2VectorType()) {
1083 NumElts = NumElts.coefficientNextPowerOf2();
1084 EVT NVT = EVT::getVectorVT(Context, EltVT, NumElts);
1085 return LegalizeKind(TypeWidenVector, NVT);
1086 }
1087
1088 // Examine the element type.
1090
1091 // If type is to be expanded, split the vector.
1092 // <4 x i140> -> <2 x i140>
1093 if (LK.first == TypeExpandInteger) {
1094 if (NumElts.isScalable() && NumElts.getKnownMinValue() == 1)
1098 }
1099
1100 // Promote the integer element types until a legal vector type is found
1101 // or until the element integer type is too big. If a legal type was not
1102 // found, fallback to the usual mechanism of widening/splitting the
1103 // vector.
1104 EVT OldEltVT = EltVT;
1105 while (true) {
1106 // Increase the bitwidth of the element to the next pow-of-two
1107 // (which is greater than 8 bits).
1108 EltVT = EVT::getIntegerVT(Context, 1 + EltVT.getSizeInBits())
1110
1111 // Stop trying when getting a non-simple element type.
1112 // Note that vector elements may be greater than legal vector element
1113 // types. Example: X86 XMM registers hold 64bit element on 32bit
1114 // systems.
1115 if (!EltVT.isSimple())
1116 break;
1117
1118 // Build a new vector type and check if it is legal.
1119 MVT NVT = MVT::getVectorVT(EltVT.getSimpleVT(), NumElts);
1120 // Found a legal promoted vector type.
1121 if (NVT != MVT() && ValueTypeActions.getTypeAction(NVT) == TypeLegal)
1123 EVT::getVectorVT(Context, EltVT, NumElts));
1124 }
1125
1126 // Reset the type to the unexpanded type if we did not find a legal vector
1127 // type with a promoted vector element type.
1128 EltVT = OldEltVT;
1129 }
1130
1131 // Try to widen the vector until a legal type is found.
1132 // If there is no wider legal type, split the vector.
1133 while (true) {
1134 // Round up to the next power of 2.
1135 NumElts = NumElts.coefficientNextPowerOf2();
1136
1137 // If there is no simple vector type with this many elements then there
1138 // cannot be a larger legal vector type. Note that this assumes that
1139 // there are no skipped intermediate vector types in the simple types.
1140 if (!EltVT.isSimple())
1141 break;
1142 MVT LargerVector = MVT::getVectorVT(EltVT.getSimpleVT(), NumElts);
1143 if (LargerVector == MVT())
1144 break;
1145
1146 // If this type is legal then widen the vector.
1147 if (ValueTypeActions.getTypeAction(LargerVector) == TypeLegal)
1148 return LegalizeKind(TypeWidenVector, LargerVector);
1149 }
1150
1151 // Widen odd vectors to next power of two.
1152 if (!VT.isPow2VectorType()) {
1153 EVT NVT = VT.getPow2VectorType(Context);
1154 return LegalizeKind(TypeWidenVector, NVT);
1155 }
1156
1159
1160 // Vectors with illegal element types are expanded.
1161 EVT NVT = EVT::getVectorVT(Context, EltVT,
1163 return LegalizeKind(TypeSplitVector, NVT);
1164}
1165
1166static unsigned getVectorTypeBreakdownMVT(MVT VT, MVT &IntermediateVT,
1167 unsigned &NumIntermediates,
1168 MVT &RegisterVT,
1169 TargetLoweringBase *TLI) {
1170 // Figure out the right, legal destination reg to copy into.
1172 MVT EltTy = VT.getVectorElementType();
1173
1174 unsigned NumVectorRegs = 1;
1175
1176 // Scalable vectors cannot be scalarized, so splitting or widening is
1177 // required.
1178 if (VT.isScalableVector() && !isPowerOf2_32(EC.getKnownMinValue()))
1180 "Splitting or widening of non-power-of-2 MVTs is not implemented.");
1181
1182 // FIXME: We don't support non-power-of-2-sized vectors for now.
1183 // Ideally we could break down into LHS/RHS like LegalizeDAG does.
1184 if (!isPowerOf2_32(EC.getKnownMinValue())) {
1185 // Split EC to unit size (scalable property is preserved).
1186 NumVectorRegs = EC.getKnownMinValue();
1187 EC = ElementCount::getFixed(1);
1188 }
1189
1190 // Divide the input until we get to a supported size. This will
1191 // always end up with an EC that represent a scalar or a scalable
1192 // scalar.
1193 while (EC.getKnownMinValue() > 1 &&
1194 !TLI->isTypeLegal(MVT::getVectorVT(EltTy, EC))) {
1195 EC = EC.divideCoefficientBy(2);
1196 NumVectorRegs <<= 1;
1197 }
1198
1199 NumIntermediates = NumVectorRegs;
1200
1201 MVT NewVT = MVT::getVectorVT(EltTy, EC);
1202 if (!TLI->isTypeLegal(NewVT))
1203 NewVT = EltTy;
1204 IntermediateVT = NewVT;
1205
1206 unsigned LaneSizeInBits = NewVT.getScalarSizeInBits();
1207
1208 // Convert sizes such as i33 to i64.
1209 LaneSizeInBits = llvm::bit_ceil(LaneSizeInBits);
1210
1211 MVT DestVT = TLI->getRegisterType(NewVT);
1212 RegisterVT = DestVT;
1213 if (EVT(DestVT).bitsLT(NewVT)) // Value is expanded, e.g. i64 -> i16.
1214 return NumVectorRegs * (LaneSizeInBits / DestVT.getScalarSizeInBits());
1215
1216 // Otherwise, promotion or legal types use the same number of registers as
1217 // the vector decimated to the appropriate level.
1218 return NumVectorRegs;
1219}
1220
1221/// isLegalRC - Return true if the value types that can be represented by the
1222/// specified register class are all legal.
1224 const TargetRegisterClass &RC) const {
1225 for (const auto *I = TRI.legalclasstypes_begin(RC); *I != MVT::Other; ++I)
1226 if (isTypeLegal(*I))
1227 return true;
1228 return false;
1229}
1230
1231/// Replace/modify any TargetFrameIndex operands with a targte-dependent
1232/// sequence of memory operands that is recognized by PrologEpilogInserter.
1235 MachineBasicBlock *MBB) const {
1236 MachineInstr *MI = &InitialMI;
1237 MachineFunction &MF = *MI->getMF();
1238 MachineFrameInfo &MFI = MF.getFrameInfo();
1239
1240 // We're handling multiple types of operands here:
1241 // PATCHPOINT MetaArgs - live-in, read only, direct
1242 // STATEPOINT Deopt Spill - live-through, read only, indirect
1243 // STATEPOINT Deopt Alloca - live-through, read only, direct
1244 // (We're currently conservative and mark the deopt slots read/write in
1245 // practice.)
1246 // STATEPOINT GC Spill - live-through, read/write, indirect
1247 // STATEPOINT GC Alloca - live-through, read/write, direct
1248 // The live-in vs live-through is handled already (the live through ones are
1249 // all stack slots), but we need to handle the different type of stackmap
1250 // operands and memory effects here.
1251
1252 if (llvm::none_of(MI->operands(),
1253 [](MachineOperand &Operand) { return Operand.isFI(); }))
1254 return MBB;
1255
1256 MachineInstrBuilder MIB = BuildMI(MF, MI->getDebugLoc(), MI->getDesc());
1257
1258 // Inherit previous memory operands.
1259 MIB.cloneMemRefs(*MI);
1260
1261 for (unsigned i = 0; i < MI->getNumOperands(); ++i) {
1262 MachineOperand &MO = MI->getOperand(i);
1263 if (!MO.isFI()) {
1264 // Index of Def operand this Use it tied to.
1265 // Since Defs are coming before Uses, if Use is tied, then
1266 // index of Def must be smaller that index of that Use.
1267 // Also, Defs preserve their position in new MI.
1268 unsigned TiedTo = i;
1269 if (MO.isReg() && MO.isTied())
1270 TiedTo = MI->findTiedOperandIdx(i);
1271 MIB.add(MO);
1272 if (TiedTo < i)
1273 MIB->tieOperands(TiedTo, MIB->getNumOperands() - 1);
1274 continue;
1275 }
1276
1277 // foldMemoryOperand builds a new MI after replacing a single FI operand
1278 // with the canonical set of five x86 addressing-mode operands.
1279 int FI = MO.getIndex();
1280
1281 // Add frame index operands recognized by stackmaps.cpp
1283 // indirect-mem-ref tag, size, #FI, offset.
1284 // Used for spills inserted by StatepointLowering. This codepath is not
1285 // used for patchpoints/stackmaps at all, for these spilling is done via
1286 // foldMemoryOperand callback only.
1287 assert(MI->getOpcode() == TargetOpcode::STATEPOINT && "sanity");
1288 MIB.addImm(StackMaps::IndirectMemRefOp);
1289 MIB.addImm(MFI.getObjectSize(FI));
1290 MIB.add(MO);
1291 MIB.addImm(0);
1292 } else {
1293 // direct-mem-ref tag, #FI, offset.
1294 // Used by patchpoint, and direct alloca arguments to statepoints
1295 MIB.addImm(StackMaps::DirectMemRefOp);
1296 MIB.add(MO);
1297 MIB.addImm(0);
1298 }
1299
1300 assert(MIB->mayLoad() && "Folded a stackmap use to a non-load!");
1301
1302 // Add a new memory operand for this FI.
1303 assert(MFI.getObjectOffset(FI) != -1);
1304
1305 // Note: STATEPOINT MMOs are added during SelectionDAG. STACKMAP, and
1306 // PATCHPOINT should be updated to do the same. (TODO)
1307 if (MI->getOpcode() != TargetOpcode::STATEPOINT) {
1308 auto Flags = MachineMemOperand::MOLoad;
1310 MachinePointerInfo::getFixedStack(MF, FI), Flags,
1312 MIB->addMemOperand(MF, MMO);
1313 }
1314 }
1316 MI->eraseFromParent();
1317 return MBB;
1318}
1319
1320/// findRepresentativeClass - Return the largest legal super-reg register class
1321/// of the register class for the specified type and its associated "cost".
1322// This function is in TargetLowering because it uses RegClassForVT which would
1323// need to be moved to TargetRegisterInfo and would necessitate moving
1324// isTypeLegal over as well - a massive change that would just require
1325// TargetLowering having a TargetRegisterInfo class member that it would use.
1326std::pair<const TargetRegisterClass *, uint8_t>
1328 MVT VT) const {
1329 const TargetRegisterClass *RC = RegClassForVT[VT.SimpleTy];
1330 if (!RC)
1331 return std::make_pair(RC, 0);
1332
1333 // Compute the set of all super-register classes.
1334 BitVector SuperRegRC(TRI->getNumRegClasses());
1335 for (SuperRegClassIterator RCI(RC, TRI); RCI.isValid(); ++RCI)
1336 SuperRegRC.setBitsInMask(RCI.getMask());
1337
1338 // Find the first legal register class with the largest spill size.
1339 const TargetRegisterClass *BestRC = RC;
1340 for (unsigned i : SuperRegRC.set_bits()) {
1341 const TargetRegisterClass *SuperRC = TRI->getRegClass(i);
1342 // We want the largest possible spill size.
1343 if (TRI->getSpillSize(*SuperRC) <= TRI->getSpillSize(*BestRC))
1344 continue;
1345 if (!isLegalRC(*TRI, *SuperRC))
1346 continue;
1347 BestRC = SuperRC;
1348 }
1349 return std::make_pair(BestRC, 1);
1350}
1351
1352/// computeRegisterProperties - Once all of the register classes are added,
1353/// this allows us to compute derived properties we expose.
1355 const TargetRegisterInfo *TRI) {
1356 // Everything defaults to needing one register.
1357 for (unsigned i = 0; i != MVT::VALUETYPE_SIZE; ++i) {
1358 NumRegistersForVT[i] = 1;
1359 RegisterTypeForVT[i] = TransformToType[i] = (MVT::SimpleValueType)i;
1360 }
1361 // ...except isVoid, which doesn't need any registers.
1362 NumRegistersForVT[MVT::isVoid] = 0;
1363
1364 // Find the largest integer register class.
1365 unsigned LargestIntReg = MVT::LAST_INTEGER_VALUETYPE;
1366 for (; RegClassForVT[LargestIntReg] == nullptr; --LargestIntReg)
1367 assert(LargestIntReg != MVT::i1 && "No integer registers defined!");
1368
1369 // Every integer value type larger than this largest register takes twice as
1370 // many registers to represent as the previous ValueType.
1371 for (unsigned ExpandedReg = LargestIntReg + 1;
1372 ExpandedReg <= MVT::LAST_INTEGER_VALUETYPE; ++ExpandedReg) {
1373 NumRegistersForVT[ExpandedReg] = 2*NumRegistersForVT[ExpandedReg-1];
1374 RegisterTypeForVT[ExpandedReg] = (MVT::SimpleValueType)LargestIntReg;
1375 TransformToType[ExpandedReg] = (MVT::SimpleValueType)(ExpandedReg - 1);
1376 ValueTypeActions.setTypeAction((MVT::SimpleValueType)ExpandedReg,
1378 }
1379
1380 // Inspect all of the ValueType's smaller than the largest integer
1381 // register to see which ones need promotion.
1382 unsigned LegalIntReg = LargestIntReg;
1383 for (unsigned IntReg = LargestIntReg - 1;
1384 IntReg >= (unsigned)MVT::i1; --IntReg) {
1385 MVT IVT = (MVT::SimpleValueType)IntReg;
1386 if (isTypeLegal(IVT)) {
1387 LegalIntReg = IntReg;
1388 } else {
1389 RegisterTypeForVT[IntReg] = TransformToType[IntReg] =
1390 (MVT::SimpleValueType)LegalIntReg;
1391 ValueTypeActions.setTypeAction(IVT, TypePromoteInteger);
1392 }
1393 }
1394
1395 // ppcf128 type is really two f64's.
1396 if (!isTypeLegal(MVT::ppcf128)) {
1397 if (isTypeLegal(MVT::f64)) {
1398 NumRegistersForVT[MVT::ppcf128] = 2*NumRegistersForVT[MVT::f64];
1399 RegisterTypeForVT[MVT::ppcf128] = MVT::f64;
1400 TransformToType[MVT::ppcf128] = MVT::f64;
1401 ValueTypeActions.setTypeAction(MVT::ppcf128, TypeExpandFloat);
1402 } else {
1403 NumRegistersForVT[MVT::ppcf128] = NumRegistersForVT[MVT::i128];
1404 RegisterTypeForVT[MVT::ppcf128] = RegisterTypeForVT[MVT::i128];
1405 TransformToType[MVT::ppcf128] = MVT::i128;
1406 ValueTypeActions.setTypeAction(MVT::ppcf128, TypeSoftenFloat);
1407 }
1408 }
1409
1410 // Decide how to handle f128. If the target does not have native f128 support,
1411 // expand it to i128 and we will be generating soft float library calls.
1412 if (!isTypeLegal(MVT::f128)) {
1413 NumRegistersForVT[MVT::f128] = NumRegistersForVT[MVT::i128];
1414 RegisterTypeForVT[MVT::f128] = RegisterTypeForVT[MVT::i128];
1415 TransformToType[MVT::f128] = MVT::i128;
1416 ValueTypeActions.setTypeAction(MVT::f128, TypeSoftenFloat);
1417 }
1418
1419 // Decide how to handle f80. If the target does not have native f80 support,
1420 // expand it to i96 and we will be generating soft float library calls.
1421 if (!isTypeLegal(MVT::f80)) {
1422 NumRegistersForVT[MVT::f80] = 3*NumRegistersForVT[MVT::i32];
1423 RegisterTypeForVT[MVT::f80] = RegisterTypeForVT[MVT::i32];
1424 TransformToType[MVT::f80] = MVT::i32;
1425 ValueTypeActions.setTypeAction(MVT::f80, TypeSoftenFloat);
1426 }
1427
1428 // Decide how to handle f64. If the target does not have native f64 support,
1429 // expand it to i64 and we will be generating soft float library calls.
1430 if (!isTypeLegal(MVT::f64)) {
1431 NumRegistersForVT[MVT::f64] = NumRegistersForVT[MVT::i64];
1432 RegisterTypeForVT[MVT::f64] = RegisterTypeForVT[MVT::i64];
1433 TransformToType[MVT::f64] = MVT::i64;
1434 ValueTypeActions.setTypeAction(MVT::f64, TypeSoftenFloat);
1435 }
1436
1437 // Decide how to handle f32. If the target does not have native f32 support,
1438 // expand it to i32 and we will be generating soft float library calls.
1439 if (!isTypeLegal(MVT::f32)) {
1440 NumRegistersForVT[MVT::f32] = NumRegistersForVT[MVT::i32];
1441 RegisterTypeForVT[MVT::f32] = RegisterTypeForVT[MVT::i32];
1442 TransformToType[MVT::f32] = MVT::i32;
1443 ValueTypeActions.setTypeAction(MVT::f32, TypeSoftenFloat);
1444 }
1445
1446 // Decide how to handle f16. If the target does not have native f16 support,
1447 // promote it to f32, because there are no f16 library calls (except for
1448 // conversions).
1449 if (!isTypeLegal(MVT::f16)) {
1450 // Allow targets to control how we legalize half.
1451 bool SoftPromoteHalfType = softPromoteHalfType();
1452 bool UseFPRegsForHalfType = !SoftPromoteHalfType || useFPRegsForHalfType();
1453
1454 if (!UseFPRegsForHalfType) {
1455 NumRegistersForVT[MVT::f16] = NumRegistersForVT[MVT::i16];
1456 RegisterTypeForVT[MVT::f16] = RegisterTypeForVT[MVT::i16];
1457 } else {
1458 NumRegistersForVT[MVT::f16] = NumRegistersForVT[MVT::f32];
1459 RegisterTypeForVT[MVT::f16] = RegisterTypeForVT[MVT::f32];
1460 }
1461 TransformToType[MVT::f16] = MVT::f32;
1462 if (SoftPromoteHalfType) {
1463 ValueTypeActions.setTypeAction(MVT::f16, TypeSoftPromoteHalf);
1464 } else {
1465 ValueTypeActions.setTypeAction(MVT::f16, TypePromoteFloat);
1466 }
1467 }
1468
1469 // Decide how to handle bf16. If the target does not have native bf16 support,
1470 // promote it to f32, because there are no bf16 library calls (except for
1471 // converting from f32 to bf16).
1472 if (!isTypeLegal(MVT::bf16)) {
1473 NumRegistersForVT[MVT::bf16] = NumRegistersForVT[MVT::f32];
1474 RegisterTypeForVT[MVT::bf16] = RegisterTypeForVT[MVT::f32];
1475 TransformToType[MVT::bf16] = MVT::f32;
1476 ValueTypeActions.setTypeAction(MVT::bf16, TypeSoftPromoteHalf);
1477 }
1478
1479 // Loop over all of the vector value types to see which need transformations.
1480 for (unsigned i = MVT::FIRST_VECTOR_VALUETYPE;
1481 i <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++i) {
1482 MVT VT = (MVT::SimpleValueType) i;
1483 if (isTypeLegal(VT))
1484 continue;
1485
1486 MVT EltVT = VT.getVectorElementType();
1488 bool IsLegalWiderType = false;
1489 bool IsScalable = VT.isScalableVector();
1490 LegalizeTypeAction PreferredAction = getPreferredVectorAction(VT);
1491 switch (PreferredAction) {
1492 case TypePromoteInteger: {
1493 MVT::SimpleValueType EndVT = IsScalable ?
1494 MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE :
1495 MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE;
1496 // Try to promote the elements of integer vectors. If no legal
1497 // promotion was found, fall through to the widen-vector method.
1498 for (unsigned nVT = i + 1;
1499 (MVT::SimpleValueType)nVT <= EndVT; ++nVT) {
1500 MVT SVT = (MVT::SimpleValueType) nVT;
1501 // Promote vectors of integers to vectors with the same number
1502 // of elements, with a wider element type.
1503 if (SVT.getScalarSizeInBits() > EltVT.getFixedSizeInBits() &&
1504 SVT.getVectorElementCount() == EC && isTypeLegal(SVT)) {
1505 TransformToType[i] = SVT;
1506 RegisterTypeForVT[i] = SVT;
1507 NumRegistersForVT[i] = 1;
1508 ValueTypeActions.setTypeAction(VT, TypePromoteInteger);
1509 IsLegalWiderType = true;
1510 break;
1511 }
1512 }
1513 if (IsLegalWiderType)
1514 break;
1515 [[fallthrough]];
1516 }
1517
1518 case TypeWidenVector:
1519 if (isPowerOf2_32(EC.getKnownMinValue())) {
1520 // Try to widen the vector.
1521 for (unsigned nVT = i + 1; nVT <= MVT::LAST_VECTOR_VALUETYPE; ++nVT) {
1522 MVT SVT = (MVT::SimpleValueType) nVT;
1523 if (SVT.getVectorElementType() == EltVT &&
1524 SVT.isScalableVector() == IsScalable &&
1526 EC.getKnownMinValue() &&
1527 isTypeLegal(SVT)) {
1528 TransformToType[i] = SVT;
1529 RegisterTypeForVT[i] = SVT;
1530 NumRegistersForVT[i] = 1;
1531 ValueTypeActions.setTypeAction(VT, TypeWidenVector);
1532 IsLegalWiderType = true;
1533 break;
1534 }
1535 }
1536 if (IsLegalWiderType)
1537 break;
1538 } else {
1539 // Only widen to the next power of 2 to keep consistency with EVT.
1540 MVT NVT = VT.getPow2VectorType();
1541 if (isTypeLegal(NVT)) {
1542 TransformToType[i] = NVT;
1543 ValueTypeActions.setTypeAction(VT, TypeWidenVector);
1544 RegisterTypeForVT[i] = NVT;
1545 NumRegistersForVT[i] = 1;
1546 break;
1547 }
1548 }
1549 [[fallthrough]];
1550
1551 case TypeSplitVector:
1552 case TypeScalarizeVector: {
1553 MVT IntermediateVT;
1554 MVT RegisterVT;
1555 unsigned NumIntermediates;
1556 unsigned NumRegisters = getVectorTypeBreakdownMVT(VT, IntermediateVT,
1557 NumIntermediates, RegisterVT, this);
1558 NumRegistersForVT[i] = NumRegisters;
1559 assert(NumRegistersForVT[i] == NumRegisters &&
1560 "NumRegistersForVT size cannot represent NumRegisters!");
1561 RegisterTypeForVT[i] = RegisterVT;
1562
1563 MVT NVT = VT.getPow2VectorType();
1564 if (NVT == VT) {
1565 // Type is already a power of 2. The default action is to split.
1566 TransformToType[i] = MVT::Other;
1567 if (PreferredAction == TypeScalarizeVector)
1568 ValueTypeActions.setTypeAction(VT, TypeScalarizeVector);
1569 else if (PreferredAction == TypeSplitVector)
1570 ValueTypeActions.setTypeAction(VT, TypeSplitVector);
1571 else if (EC.getKnownMinValue() > 1)
1572 ValueTypeActions.setTypeAction(VT, TypeSplitVector);
1573 else
1574 ValueTypeActions.setTypeAction(VT, EC.isScalable()
1577 } else {
1578 TransformToType[i] = NVT;
1579 ValueTypeActions.setTypeAction(VT, TypeWidenVector);
1580 }
1581 break;
1582 }
1583 default:
1584 llvm_unreachable("Unknown vector legalization action!");
1585 }
1586 }
1587
1588 // Determine the 'representative' register class for each value type.
1589 // An representative register class is the largest (meaning one which is
1590 // not a sub-register class / subreg register class) legal register class for
1591 // a group of value types. For example, on i386, i8, i16, and i32
1592 // representative would be GR32; while on x86_64 it's GR64.
1593 for (unsigned i = 0; i != MVT::VALUETYPE_SIZE; ++i) {
1594 const TargetRegisterClass* RRC;
1595 uint8_t Cost;
1597 RepRegClassForVT[i] = RRC;
1598 RepRegClassCostForVT[i] = Cost;
1599 }
1600}
1601
1603 EVT VT) const {
1604 assert(!VT.isVector() && "No default SetCC type for vectors!");
1605 return getPointerTy(DL).SimpleTy;
1606}
1607
1609 return MVT::i32; // return the default value
1610}
1611
1612/// getVectorTypeBreakdown - Vector types are broken down into some number of
1613/// legal first class types. For example, MVT::v8f32 maps to 2 MVT::v4f32
1614/// with Altivec or SSE1, or 8 promoted MVT::f64 values with the X86 FP stack.
1615/// Similarly, MVT::v2i64 turns into 4 MVT::i32 values with both PPC and X86.
1616///
1617/// This method returns the number of registers needed, and the VT for each
1618/// register. It also returns the VT and quantity of the intermediate values
1619/// before they are promoted/expanded.
1621 EVT VT, EVT &IntermediateVT,
1622 unsigned &NumIntermediates,
1623 MVT &RegisterVT) const {
1624 ElementCount EltCnt = VT.getVectorElementCount();
1625
1626 // If there is a wider vector type with the same element type as this one,
1627 // or a promoted vector type that has the same number of elements which
1628 // are wider, then we should convert to that legal vector type.
1629 // This handles things like <2 x float> -> <4 x float> and
1630 // <4 x i1> -> <4 x i32>.
1632 if (!EltCnt.isScalar() &&
1633 (TA == TypeWidenVector || TA == TypePromoteInteger)) {
1634 EVT RegisterEVT = getTypeToTransformTo(Context, VT);
1635 if (isTypeLegal(RegisterEVT)) {
1636 IntermediateVT = RegisterEVT;
1637 RegisterVT = RegisterEVT.getSimpleVT();
1638 NumIntermediates = 1;
1639 return 1;
1640 }
1641 }
1642
1643 // Figure out the right, legal destination reg to copy into.
1644 EVT EltTy = VT.getVectorElementType();
1645
1646 unsigned NumVectorRegs = 1;
1647
1648 // Scalable vectors cannot be scalarized, so handle the legalisation of the
1649 // types like done elsewhere in SelectionDAG.
1650 if (EltCnt.isScalable()) {
1651 LegalizeKind LK;
1652 EVT PartVT = VT;
1653 do {
1654 // Iterate until we've found a legal (part) type to hold VT.
1655 LK = getTypeConversion(Context, PartVT);
1656 PartVT = LK.second;
1657 } while (LK.first != TypeLegal);
1658
1659 if (!PartVT.isVector()) {
1661 "Don't know how to legalize this scalable vector type");
1662 }
1663
1664 NumIntermediates =
1667 IntermediateVT = PartVT;
1668 RegisterVT = getRegisterType(Context, IntermediateVT);
1669 return NumIntermediates;
1670 }
1671
1672 // FIXME: We don't support non-power-of-2-sized vectors for now. Ideally
1673 // we could break down into LHS/RHS like LegalizeDAG does.
1674 if (!isPowerOf2_32(EltCnt.getKnownMinValue())) {
1675 NumVectorRegs = EltCnt.getKnownMinValue();
1676 EltCnt = ElementCount::getFixed(1);
1677 }
1678
1679 // Divide the input until we get to a supported size. This will always
1680 // end with a scalar if the target doesn't support vectors.
1681 while (EltCnt.getKnownMinValue() > 1 &&
1682 !isTypeLegal(EVT::getVectorVT(Context, EltTy, EltCnt))) {
1683 EltCnt = EltCnt.divideCoefficientBy(2);
1684 NumVectorRegs <<= 1;
1685 }
1686
1687 NumIntermediates = NumVectorRegs;
1688
1689 EVT NewVT = EVT::getVectorVT(Context, EltTy, EltCnt);
1690 if (!isTypeLegal(NewVT))
1691 NewVT = EltTy;
1692 IntermediateVT = NewVT;
1693
1694 MVT DestVT = getRegisterType(Context, NewVT);
1695 RegisterVT = DestVT;
1696
1697 if (EVT(DestVT).bitsLT(NewVT)) { // Value is expanded, e.g. i64 -> i16.
1698 TypeSize NewVTSize = NewVT.getSizeInBits();
1699 // Convert sizes such as i33 to i64.
1700 if (!llvm::has_single_bit<uint32_t>(NewVTSize.getKnownMinValue()))
1701 NewVTSize = NewVTSize.coefficientNextPowerOf2();
1702 return NumVectorRegs*(NewVTSize/DestVT.getSizeInBits());
1703 }
1704
1705 // Otherwise, promotion or legal types use the same number of registers as
1706 // the vector decimated to the appropriate level.
1707 return NumVectorRegs;
1708}
1709
1711 uint64_t NumCases,
1713 ProfileSummaryInfo *PSI,
1714 BlockFrequencyInfo *BFI) const {
1715 // FIXME: This function check the maximum table size and density, but the
1716 // minimum size is not checked. It would be nice if the minimum size is
1717 // also combined within this function. Currently, the minimum size check is
1718 // performed in findJumpTable() in SelectionDAGBuiler and
1719 // getEstimatedNumberOfCaseClusters() in BasicTTIImpl.
1720 const bool OptForSize =
1721 llvm::shouldOptimizeForSize(SI->getParent(), PSI, BFI);
1722 const unsigned MinDensity = getMinimumJumpTableDensity(OptForSize);
1723 const unsigned MaxJumpTableSize = getMaximumJumpTableSize();
1724
1725 // Check whether the number of cases is small enough and
1726 // the range is dense enough for a jump table.
1727 return (OptForSize || Range <= MaxJumpTableSize) &&
1728 (NumCases * 100 >= Range * MinDensity);
1729}
1730
1732 EVT ConditionVT) const {
1733 return getRegisterType(Context, ConditionVT);
1734}
1735
1736/// Get the EVTs and ArgFlags collections that represent the legalized return
1737/// type of the given function. This does not require a DAG or a return value,
1738/// and is suitable for use before any DAGs for the function are constructed.
1739/// TODO: Move this out of TargetLowering.cpp.
1741 AttributeList attr,
1743 const TargetLowering &TLI, const DataLayout &DL) {
1745 ComputeValueTypes(DL, ReturnType, Types);
1746 unsigned NumValues = Types.size();
1747 if (NumValues == 0) return;
1748
1749 for (Type *Ty : Types) {
1750 EVT VT = TLI.getValueType(DL, Ty);
1751 ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
1752
1753 if (attr.hasRetAttr(Attribute::SExt))
1754 ExtendKind = ISD::SIGN_EXTEND;
1755 else if (attr.hasRetAttr(Attribute::ZExt))
1756 ExtendKind = ISD::ZERO_EXTEND;
1757
1758 if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger())
1759 VT = TLI.getTypeForExtReturn(ReturnType->getContext(), VT, ExtendKind);
1760
1761 unsigned NumParts =
1762 TLI.getNumRegistersForCallingConv(ReturnType->getContext(), CC, VT);
1763 MVT PartVT =
1764 TLI.getRegisterTypeForCallingConv(ReturnType->getContext(), CC, VT);
1765
1766 // 'inreg' on function refers to return value
1768 if (attr.hasRetAttr(Attribute::InReg))
1769 Flags.setInReg();
1770
1771 // Propagate extension type if any
1772 if (attr.hasRetAttr(Attribute::SExt))
1773 Flags.setSExt();
1774 else if (attr.hasRetAttr(Attribute::ZExt))
1775 Flags.setZExt();
1776
1777 for (unsigned i = 0; i < NumParts; ++i)
1778 Outs.push_back(ISD::OutputArg(Flags, PartVT, VT, Ty, 0, 0));
1779 }
1780}
1781
1783 const DataLayout &DL) const {
1784 return DL.getABITypeAlign(Ty);
1785}
1786
1788 LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace,
1789 Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const {
1790 // Check if the specified alignment is sufficient based on the data layout.
1791 // TODO: While using the data layout works in practice, a better solution
1792 // would be to implement this check directly (make this a virtual function).
1793 // For example, the ABI alignment may change based on software platform while
1794 // this function should only be affected by hardware implementation.
1795 Type *Ty = VT.getTypeForEVT(Context);
1796 if (VT.isZeroSized() || Alignment >= DL.getABITypeAlign(Ty)) {
1797 // Assume that an access that meets the ABI-specified alignment is fast.
1798 if (Fast != nullptr)
1799 *Fast = 1;
1800 return true;
1801 }
1802
1803 // This is a misaligned access.
1804 return allowsMisalignedMemoryAccesses(VT, AddrSpace, Alignment, Flags, Fast);
1805}
1806
1808 LLVMContext &Context, const DataLayout &DL, EVT VT,
1809 const MachineMemOperand &MMO, unsigned *Fast) const {
1811 MMO.getAlign(), MMO.getFlags(), Fast);
1812}
1813
1815 const DataLayout &DL, EVT VT,
1816 unsigned AddrSpace, Align Alignment,
1818 unsigned *Fast) const {
1819 return allowsMemoryAccessForAlignment(Context, DL, VT, AddrSpace, Alignment,
1820 Flags, Fast);
1821}
1822
1824 const DataLayout &DL, EVT VT,
1825 const MachineMemOperand &MMO,
1826 unsigned *Fast) const {
1827 return allowsMemoryAccess(Context, DL, VT, MMO.getAddrSpace(), MMO.getAlign(),
1828 MMO.getFlags(), Fast);
1829}
1830
1832 const DataLayout &DL, LLT Ty,
1833 const MachineMemOperand &MMO,
1834 unsigned *Fast) const {
1836 return allowsMemoryAccess(Context, DL, VT, MMO.getAddrSpace(), MMO.getAlign(),
1837 MMO.getFlags(), Fast);
1838}
1839
1840//===----------------------------------------------------------------------===//
1841// TargetTransformInfo Helpers
1842//===----------------------------------------------------------------------===//
1843
1845 enum InstructionOpcodes {
1846#define HANDLE_INST(NUM, OPCODE, CLASS) OPCODE = NUM,
1847#define LAST_OTHER_INST(NUM) InstructionOpcodesCount = NUM
1848#include "llvm/IR/Instruction.def"
1849 };
1850 switch (static_cast<InstructionOpcodes>(Opcode)) {
1851 case Ret: return 0;
1852 case Br: return 0;
1853 case Switch: return 0;
1854 case IndirectBr: return 0;
1855 case Invoke: return 0;
1856 case CallBr: return 0;
1857 case Resume: return 0;
1858 case Unreachable: return 0;
1859 case CleanupRet: return 0;
1860 case CatchRet: return 0;
1861 case CatchPad: return 0;
1862 case CatchSwitch: return 0;
1863 case CleanupPad: return 0;
1864 case FNeg: return ISD::FNEG;
1865 case Add: return ISD::ADD;
1866 case FAdd: return ISD::FADD;
1867 case Sub: return ISD::SUB;
1868 case FSub: return ISD::FSUB;
1869 case Mul: return ISD::MUL;
1870 case FMul: return ISD::FMUL;
1871 case UDiv: return ISD::UDIV;
1872 case SDiv: return ISD::SDIV;
1873 case FDiv: return ISD::FDIV;
1874 case URem: return ISD::UREM;
1875 case SRem: return ISD::SREM;
1876 case FRem: return ISD::FREM;
1877 case Shl: return ISD::SHL;
1878 case LShr: return ISD::SRL;
1879 case AShr: return ISD::SRA;
1880 case And: return ISD::AND;
1881 case Or: return ISD::OR;
1882 case Xor: return ISD::XOR;
1883 case Alloca: return 0;
1884 case Load: return ISD::LOAD;
1885 case Store: return ISD::STORE;
1886 case GetElementPtr: return 0;
1887 case Fence: return 0;
1888 case AtomicCmpXchg: return 0;
1889 case AtomicRMW: return 0;
1890 case Trunc: return ISD::TRUNCATE;
1891 case ZExt: return ISD::ZERO_EXTEND;
1892 case SExt: return ISD::SIGN_EXTEND;
1893 case FPToUI: return ISD::FP_TO_UINT;
1894 case FPToSI: return ISD::FP_TO_SINT;
1895 case UIToFP: return ISD::UINT_TO_FP;
1896 case SIToFP: return ISD::SINT_TO_FP;
1897 case FPTrunc: return ISD::FP_ROUND;
1898 case FPExt: return ISD::FP_EXTEND;
1899 case PtrToAddr: return ISD::BITCAST;
1900 case PtrToInt: return ISD::BITCAST;
1901 case IntToPtr: return ISD::BITCAST;
1902 case BitCast: return ISD::BITCAST;
1903 case AddrSpaceCast: return ISD::ADDRSPACECAST;
1904 case ICmp: return ISD::SETCC;
1905 case FCmp: return ISD::SETCC;
1906 case PHI: return 0;
1907 case Call: return 0;
1908 case Select: return ISD::SELECT;
1909 case UserOp1: return 0;
1910 case UserOp2: return 0;
1911 case VAArg: return 0;
1912 case ExtractElement: return ISD::EXTRACT_VECTOR_ELT;
1913 case InsertElement: return ISD::INSERT_VECTOR_ELT;
1914 case ShuffleVector: return ISD::VECTOR_SHUFFLE;
1915 case ExtractValue: return ISD::MERGE_VALUES;
1916 case InsertValue: return ISD::MERGE_VALUES;
1917 case LandingPad: return 0;
1918 case Freeze: return ISD::FREEZE;
1919 }
1920
1921 llvm_unreachable("Unknown instruction type encountered!");
1922}
1923
1925 switch (ID) {
1926 case Intrinsic::exp:
1927 return ISD::FEXP;
1928 case Intrinsic::exp2:
1929 return ISD::FEXP2;
1930 case Intrinsic::log:
1931 return ISD::FLOG;
1932 default:
1933 return ISD::DELETED_NODE;
1934 }
1935}
1936
1937Value *
1939 bool UseTLS) const {
1940 // compiler-rt provides a variable with a magic name. Targets that do not
1941 // link with compiler-rt may also provide such a variable.
1942 Module *M = IRB.GetInsertBlock()->getParent()->getParent();
1943 const char *UnsafeStackPtrVar = "__safestack_unsafe_stack_ptr";
1944 auto UnsafeStackPtr =
1945 dyn_cast_or_null<GlobalVariable>(M->getNamedValue(UnsafeStackPtrVar));
1946
1947 const DataLayout &DL = M->getDataLayout();
1948 PointerType *StackPtrTy = DL.getAllocaPtrType(M->getContext());
1949
1950 if (!UnsafeStackPtr) {
1951 auto TLSModel = UseTLS ?
1954 // The global variable is not defined yet, define it ourselves.
1955 // We use the initial-exec TLS model because we do not support the
1956 // variable living anywhere other than in the main executable.
1957 UnsafeStackPtr = new GlobalVariable(
1958 *M, StackPtrTy, false, GlobalValue::ExternalLinkage, nullptr,
1959 UnsafeStackPtrVar, nullptr, TLSModel);
1960 } else {
1961 // The variable exists, check its type and attributes.
1962 //
1963 // FIXME: Move to IR verifier.
1964 if (UnsafeStackPtr->getValueType() != StackPtrTy)
1965 report_fatal_error(Twine(UnsafeStackPtrVar) + " must have void* type");
1966 if (UseTLS != UnsafeStackPtr->isThreadLocal())
1967 report_fatal_error(Twine(UnsafeStackPtrVar) + " must " +
1968 (UseTLS ? "" : "not ") + "be thread-local");
1969 }
1970 return UnsafeStackPtr;
1971}
1972
1973Value *
1975 // FIXME: Can this triple check be replaced with SAFESTACK_POINTER_ADDRESS
1976 // being available?
1977 if (!TM.getTargetTriple().isAndroid())
1978 return getDefaultSafeStackPointerLocation(IRB, true);
1979
1980 Module *M = IRB.GetInsertBlock()->getParent()->getParent();
1981 auto *PtrTy = PointerType::getUnqual(M->getContext());
1982
1983 const char *SafestackPointerAddressName =
1984 getLibcallName(RTLIB::SAFESTACK_POINTER_ADDRESS);
1985 if (!SafestackPointerAddressName) {
1986 M->getContext().emitError(
1987 "no libcall available for safestack pointer address");
1988 return PoisonValue::get(PtrTy);
1989 }
1990
1991 // Android provides a libc function to retrieve the address of the current
1992 // thread's unsafe stack pointer.
1993 FunctionCallee Fn =
1994 M->getOrInsertFunction(SafestackPointerAddressName, PtrTy);
1995 return IRB.CreateCall(Fn);
1996}
1997
1998//===----------------------------------------------------------------------===//
1999// Loop Strength Reduction hooks
2000//===----------------------------------------------------------------------===//
2001
2002/// isLegalAddressingMode - Return true if the addressing mode represented
2003/// by AM is legal for this target, for a load/store of the specified type.
2005 const AddrMode &AM, Type *Ty,
2006 unsigned AS, Instruction *I) const {
2007 // The default implementation of this implements a conservative RISCy, r+r and
2008 // r+i addr mode.
2009
2010 // Scalable offsets not supported
2011 if (AM.ScalableOffset)
2012 return false;
2013
2014 // Allows a sign-extended 16-bit immediate field.
2015 if (AM.BaseOffs <= -(1LL << 16) || AM.BaseOffs >= (1LL << 16)-1)
2016 return false;
2017
2018 // No global is ever allowed as a base.
2019 if (AM.BaseGV)
2020 return false;
2021
2022 // Only support r+r,
2023 switch (AM.Scale) {
2024 case 0: // "r+i" or just "i", depending on HasBaseReg.
2025 break;
2026 case 1:
2027 if (AM.HasBaseReg && AM.BaseOffs) // "r+r+i" is not allowed.
2028 return false;
2029 // Otherwise we have r+r or r+i.
2030 break;
2031 case 2:
2032 if (AM.HasBaseReg || AM.BaseOffs) // 2*r+r or 2*r+i is not allowed.
2033 return false;
2034 // Allow 2*r as r+r.
2035 break;
2036 default: // Don't allow n * r
2037 return false;
2038 }
2039
2040 return true;
2041}
2042
2043//===----------------------------------------------------------------------===//
2044// Stack Protector
2045//===----------------------------------------------------------------------===//
2046
2047// For OpenBSD return its special guard variable. Otherwise return nullptr,
2048// so that SelectionDAG handle SSP.
2050 if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
2051 Module &M = *IRB.GetInsertBlock()->getParent()->getParent();
2052 const DataLayout &DL = M.getDataLayout();
2053 PointerType *PtrTy =
2054 PointerType::get(M.getContext(), DL.getDefaultGlobalsAddressSpace());
2055 GlobalVariable *G = M.getOrInsertGlobal("__guard_local", PtrTy);
2056 G->setVisibility(GlobalValue::HiddenVisibility);
2057 return G;
2058 }
2059 return nullptr;
2060}
2061
2062// Currently only support "standard" __stack_chk_guard.
2063// TODO: add LOAD_STACK_GUARD support.
2065 RTLIB::LibcallImpl StackGuardImpl = getLibcallImpl(RTLIB::STACK_CHECK_GUARD);
2066 if (StackGuardImpl == RTLIB::Unsupported)
2067 return;
2068
2069 StringRef StackGuardVarName = getLibcallImplName(StackGuardImpl);
2070 M.getOrInsertGlobal(
2071 StackGuardVarName, PointerType::getUnqual(M.getContext()), [=, &M]() {
2072 auto *GV = new GlobalVariable(M, PointerType::getUnqual(M.getContext()),
2073 false, GlobalVariable::ExternalLinkage,
2074 nullptr, StackGuardVarName);
2075
2076 // FreeBSD has "__stack_chk_guard" defined externally on libc.so
2077 if (M.getDirectAccessExternalData() &&
2078 !TM.getTargetTriple().isOSCygMing() &&
2079 !(TM.getTargetTriple().isPPC64() &&
2080 TM.getTargetTriple().isOSFreeBSD()) &&
2081 (!TM.getTargetTriple().isOSDarwin() ||
2082 TM.getRelocationModel() == Reloc::Static))
2083 GV->setDSOLocal(true);
2084
2085 return GV;
2086 });
2087}
2088
2089// Currently only support "standard" __stack_chk_guard.
2090// TODO: add LOAD_STACK_GUARD support.
2092 RTLIB::LibcallImpl GuardVarImpl = getLibcallImpl(RTLIB::STACK_CHECK_GUARD);
2093 if (GuardVarImpl == RTLIB::Unsupported)
2094 return nullptr;
2095 return M.getNamedValue(getLibcallImplName(GuardVarImpl));
2096}
2097
2099 return nullptr;
2100}
2101
2104}
2105
2108}
2109
2110unsigned TargetLoweringBase::getMinimumJumpTableDensity(bool OptForSize) const {
2111 return OptForSize ? OptsizeJumpTableDensity : JumpTableDensity;
2112}
2113
2115 return MaximumJumpTableSize;
2116}
2117
2120}
2121
2124}
2125
2127 if (TM.Options.LoopAlignment)
2128 return Align(TM.Options.LoopAlignment);
2129 return PrefLoopAlignment;
2130}
2131
2133 MachineBasicBlock *MBB) const {
2134 return MaxBytesForAlignment;
2135}
2136
2137//===----------------------------------------------------------------------===//
2138// Reciprocal Estimates
2139//===----------------------------------------------------------------------===//
2140
2141/// Get the reciprocal estimate attribute string for a function that will
2142/// override the target defaults.
2144 const Function &F = MF.getFunction();
2145 return F.getFnAttribute("reciprocal-estimates").getValueAsString();
2146}
2147
2148/// Construct a string for the given reciprocal operation of the given type.
2149/// This string should match the corresponding option to the front-end's
2150/// "-mrecip" flag assuming those strings have been passed through in an
2151/// attribute string. For example, "vec-divf" for a division of a vXf32.
2152static std::string getReciprocalOpName(bool IsSqrt, EVT VT) {
2153 std::string Name = VT.isVector() ? "vec-" : "";
2154
2155 Name += IsSqrt ? "sqrt" : "div";
2156
2157 // TODO: Handle other float types?
2158 if (VT.getScalarType() == MVT::f64) {
2159 Name += "d";
2160 } else if (VT.getScalarType() == MVT::f16) {
2161 Name += "h";
2162 } else {
2163 assert(VT.getScalarType() == MVT::f32 &&
2164 "Unexpected FP type for reciprocal estimate");
2165 Name += "f";
2166 }
2167
2168 return Name;
2169}
2170
2171/// Return the character position and value (a single numeric character) of a
2172/// customized refinement operation in the input string if it exists. Return
2173/// false if there is no customized refinement step count.
2174static bool parseRefinementStep(StringRef In, size_t &Position,
2175 uint8_t &Value) {
2176 const char RefStepToken = ':';
2177 Position = In.find(RefStepToken);
2178 if (Position == StringRef::npos)
2179 return false;
2180
2181 StringRef RefStepString = In.substr(Position + 1);
2182 // Allow exactly one numeric character for the additional refinement
2183 // step parameter.
2184 if (RefStepString.size() == 1) {
2185 char RefStepChar = RefStepString[0];
2186 if (isDigit(RefStepChar)) {
2187 Value = RefStepChar - '0';
2188 return true;
2189 }
2190 }
2191 report_fatal_error("Invalid refinement step for -recip.");
2192}
2193
2194/// For the input attribute string, return one of the ReciprocalEstimate enum
2195/// status values (enabled, disabled, or not specified) for this operation on
2196/// the specified data type.
2197static int getOpEnabled(bool IsSqrt, EVT VT, StringRef Override) {
2198 if (Override.empty())
2200
2201 SmallVector<StringRef, 4> OverrideVector;
2202 Override.split(OverrideVector, ',');
2203 unsigned NumArgs = OverrideVector.size();
2204
2205 // Check if "all", "none", or "default" was specified.
2206 if (NumArgs == 1) {
2207 // Look for an optional setting of the number of refinement steps needed
2208 // for this type of reciprocal operation.
2209 size_t RefPos;
2210 uint8_t RefSteps;
2211 if (parseRefinementStep(Override, RefPos, RefSteps)) {
2212 // Split the string for further processing.
2213 Override = Override.substr(0, RefPos);
2214 }
2215
2216 // All reciprocal types are enabled.
2217 if (Override == "all")
2219
2220 // All reciprocal types are disabled.
2221 if (Override == "none")
2223
2224 // Target defaults for enablement are used.
2225 if (Override == "default")
2227 }
2228
2229 // The attribute string may omit the size suffix ('f'/'d').
2230 std::string VTName = getReciprocalOpName(IsSqrt, VT);
2231 std::string VTNameNoSize = VTName;
2232 VTNameNoSize.pop_back();
2233 static const char DisabledPrefix = '!';
2234
2235 for (StringRef RecipType : OverrideVector) {
2236 size_t RefPos;
2237 uint8_t RefSteps;
2238 if (parseRefinementStep(RecipType, RefPos, RefSteps))
2239 RecipType = RecipType.substr(0, RefPos);
2240
2241 // Ignore the disablement token for string matching.
2242 bool IsDisabled = RecipType[0] == DisabledPrefix;
2243 if (IsDisabled)
2244 RecipType = RecipType.substr(1);
2245
2246 if (RecipType == VTName || RecipType == VTNameNoSize)
2249 }
2250
2252}
2253
2254/// For the input attribute string, return the customized refinement step count
2255/// for this operation on the specified data type. If the step count does not
2256/// exist, return the ReciprocalEstimate enum value for unspecified.
2257static int getOpRefinementSteps(bool IsSqrt, EVT VT, StringRef Override) {
2258 if (Override.empty())
2260
2261 SmallVector<StringRef, 4> OverrideVector;
2262 Override.split(OverrideVector, ',');
2263 unsigned NumArgs = OverrideVector.size();
2264
2265 // Check if "all", "default", or "none" was specified.
2266 if (NumArgs == 1) {
2267 // Look for an optional setting of the number of refinement steps needed
2268 // for this type of reciprocal operation.
2269 size_t RefPos;
2270 uint8_t RefSteps;
2271 if (!parseRefinementStep(Override, RefPos, RefSteps))
2273
2274 // Split the string for further processing.
2275 Override = Override.substr(0, RefPos);
2276 assert(Override != "none" &&
2277 "Disabled reciprocals, but specifed refinement steps?");
2278
2279 // If this is a general override, return the specified number of steps.
2280 if (Override == "all" || Override == "default")
2281 return RefSteps;
2282 }
2283
2284 // The attribute string may omit the size suffix ('f'/'d').
2285 std::string VTName = getReciprocalOpName(IsSqrt, VT);
2286 std::string VTNameNoSize = VTName;
2287 VTNameNoSize.pop_back();
2288
2289 for (StringRef RecipType : OverrideVector) {
2290 size_t RefPos;
2291 uint8_t RefSteps;
2292 if (!parseRefinementStep(RecipType, RefPos, RefSteps))
2293 continue;
2294
2295 RecipType = RecipType.substr(0, RefPos);
2296 if (RecipType == VTName || RecipType == VTNameNoSize)
2297 return RefSteps;
2298 }
2299
2301}
2302
2304 MachineFunction &MF) const {
2305 return getOpEnabled(true, VT, getRecipEstimateForFunc(MF));
2306}
2307
2309 MachineFunction &MF) const {
2310 return getOpEnabled(false, VT, getRecipEstimateForFunc(MF));
2311}
2312
2314 MachineFunction &MF) const {
2315 return getOpRefinementSteps(true, VT, getRecipEstimateForFunc(MF));
2316}
2317
2319 MachineFunction &MF) const {
2320 return getOpRefinementSteps(false, VT, getRecipEstimateForFunc(MF));
2321}
2322
2324 EVT LoadVT, EVT BitcastVT, const SelectionDAG &DAG,
2325 const MachineMemOperand &MMO) const {
2326 // Single-element vectors are scalarized, so we should generally avoid having
2327 // any memory operations on such types, as they would get scalarized too.
2328 if (LoadVT.isFixedLengthVector() && BitcastVT.isFixedLengthVector() &&
2329 BitcastVT.getVectorNumElements() == 1)
2330 return false;
2331
2332 // Don't do if we could do an indexed load on the original type, but not on
2333 // the new one.
2334 if (!LoadVT.isSimple() || !BitcastVT.isSimple())
2335 return true;
2336
2337 MVT LoadMVT = LoadVT.getSimpleVT();
2338
2339 // Don't bother doing this if it's just going to be promoted again later, as
2340 // doing so might interfere with other combines.
2341 if (getOperationAction(ISD::LOAD, LoadMVT) == Promote &&
2342 getTypeToPromoteTo(ISD::LOAD, LoadMVT) == BitcastVT.getSimpleVT())
2343 return false;
2344
2345 unsigned Fast = 0;
2346 return allowsMemoryAccess(*DAG.getContext(), DAG.getDataLayout(), BitcastVT,
2347 MMO, &Fast) &&
2348 Fast;
2349}
2350
2353}
2354
2356 const LoadInst &LI, const DataLayout &DL, AssumptionCache *AC,
2357 const TargetLibraryInfo *LibInfo) const {
2359 if (LI.isVolatile())
2361
2362 if (LI.hasMetadata(LLVMContext::MD_nontemporal))
2364
2365 if (LI.hasMetadata(LLVMContext::MD_invariant_load))
2367
2369 LI.getAlign(), DL, &LI, AC,
2370 /*DT=*/nullptr, LibInfo))
2372
2373 Flags |= getTargetMMOFlags(LI);
2374 return Flags;
2375}
2376
2379 const DataLayout &DL) const {
2381
2382 if (SI.isVolatile())
2384
2385 if (SI.hasMetadata(LLVMContext::MD_nontemporal))
2387
2388 // FIXME: Not preserving dereferenceable
2389 Flags |= getTargetMMOFlags(SI);
2390 return Flags;
2391}
2392
2395 const DataLayout &DL) const {
2397
2398 if (const AtomicRMWInst *RMW = dyn_cast<AtomicRMWInst>(&AI)) {
2399 if (RMW->isVolatile())
2401 } else if (const AtomicCmpXchgInst *CmpX = dyn_cast<AtomicCmpXchgInst>(&AI)) {
2402 if (CmpX->isVolatile())
2404 } else
2405 llvm_unreachable("not an atomic instruction");
2406
2407 // FIXME: Not preserving dereferenceable
2408 Flags |= getTargetMMOFlags(AI);
2409 return Flags;
2410}
2411
2413 const VPIntrinsic &VPIntrin) const {
2415 Intrinsic::ID IntrinID = VPIntrin.getIntrinsicID();
2416
2417 switch (IntrinID) {
2418 default:
2419 llvm_unreachable("unexpected intrinsic. Existing code may be appropriate "
2420 "for it, but support must be explicitly enabled");
2421 case Intrinsic::vp_load:
2422 case Intrinsic::vp_gather:
2423 case Intrinsic::experimental_vp_strided_load:
2425 break;
2426 case Intrinsic::vp_store:
2427 case Intrinsic::vp_scatter:
2428 case Intrinsic::experimental_vp_strided_store:
2430 break;
2431 }
2432
2433 if (VPIntrin.hasMetadata(LLVMContext::MD_nontemporal))
2435
2436 Flags |= getTargetMMOFlags(VPIntrin);
2437 return Flags;
2438}
2439
2441 Instruction *Inst,
2442 AtomicOrdering Ord) const {
2443 if (isReleaseOrStronger(Ord) && Inst->hasAtomicStore())
2444 return Builder.CreateFence(Ord);
2445 else
2446 return nullptr;
2447}
2448
2450 Instruction *Inst,
2451 AtomicOrdering Ord) const {
2452 if (isAcquireOrStronger(Ord))
2453 return Builder.CreateFence(Ord);
2454 else
2455 return nullptr;
2456}
2457
2458//===----------------------------------------------------------------------===//
2459// GlobalISel Hooks
2460//===----------------------------------------------------------------------===//
2461
2463 const TargetTransformInfo *TTI) const {
2464 auto &MF = *MI.getMF();
2465 auto &MRI = MF.getRegInfo();
2466 // Assuming a spill and reload of a value has a cost of 1 instruction each,
2467 // this helper function computes the maximum number of uses we should consider
2468 // for remat. E.g. on arm64 global addresses take 2 insts to materialize. We
2469 // break even in terms of code size when the original MI has 2 users vs
2470 // choosing to potentially spill. Any more than 2 users we we have a net code
2471 // size increase. This doesn't take into account register pressure though.
2472 auto maxUses = [](unsigned RematCost) {
2473 // A cost of 1 means remats are basically free.
2474 if (RematCost == 1)
2475 return std::numeric_limits<unsigned>::max();
2476 if (RematCost == 2)
2477 return 2U;
2478
2479 // Remat is too expensive, only sink if there's one user.
2480 if (RematCost > 2)
2481 return 1U;
2482 llvm_unreachable("Unexpected remat cost");
2483 };
2484
2485 switch (MI.getOpcode()) {
2486 default:
2487 return false;
2488 // Constants-like instructions should be close to their users.
2489 // We don't want long live-ranges for them.
2490 case TargetOpcode::G_CONSTANT:
2491 case TargetOpcode::G_FCONSTANT:
2492 case TargetOpcode::G_FRAME_INDEX:
2493 case TargetOpcode::G_INTTOPTR:
2494 return true;
2495 case TargetOpcode::G_GLOBAL_VALUE: {
2496 unsigned RematCost = TTI->getGISelRematGlobalCost();
2497 Register Reg = MI.getOperand(0).getReg();
2498 unsigned MaxUses = maxUses(RematCost);
2499 if (MaxUses == UINT_MAX)
2500 return true; // Remats are "free" so always localize.
2501 return MRI.hasAtMostUserInstrs(Reg, MaxUses);
2502 }
2503 }
2504}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
Rewrite undef for PHI
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
This file implements the BitVector class.
return RetTy
std::string Name
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
static LVOptions Options
Definition: LVOptions.cpp:25
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
Register const TargetRegisterInfo * TRI
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static bool isDigit(const char C)
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
static cl::opt< bool > JumpIsExpensiveOverride("jump-is-expensive", cl::init(false), cl::desc("Do not create extra branches to split comparison logic."), cl::Hidden)
#define OP_TO_LIBCALL(Name, Enum)
static cl::opt< unsigned > MinimumJumpTableEntries("min-jump-table-entries", cl::init(4), cl::Hidden, cl::desc("Set minimum number of entries to use a jump table."))
static cl::opt< bool > DisableStrictNodeMutation("disable-strictnode-mutation", cl::desc("Don't mutate strict-float node to a legalize node"), cl::init(false), cl::Hidden)
static bool parseRefinementStep(StringRef In, size_t &Position, uint8_t &Value)
Return the character position and value (a single numeric character) of a customized refinement opera...
static cl::opt< unsigned > MaximumJumpTableSize("max-jump-table-size", cl::init(UINT_MAX), cl::Hidden, cl::desc("Set maximum size of jump tables."))
static cl::opt< unsigned > JumpTableDensity("jump-table-density", cl::init(10), cl::Hidden, cl::desc("Minimum density for building a jump table in " "a normal function"))
Minimum jump table density for normal functions.
static unsigned getVectorTypeBreakdownMVT(MVT VT, MVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT, TargetLoweringBase *TLI)
static std::string getReciprocalOpName(bool IsSqrt, EVT VT)
Construct a string for the given reciprocal operation of the given type.
#define LCALL5(A)
static int getOpRefinementSteps(bool IsSqrt, EVT VT, StringRef Override)
For the input attribute string, return the customized refinement step count for this operation on the...
static int getOpEnabled(bool IsSqrt, EVT VT, StringRef Override)
For the input attribute string, return one of the ReciprocalEstimate enum status values (enabled,...
static StringRef getRecipEstimateForFunc(MachineFunction &MF)
Get the reciprocal estimate attribute string for a function that will override the target defaults.
static cl::opt< unsigned > OptsizeJumpTableDensity("optsize-jump-table-density", cl::init(40), cl::Hidden, cl::desc("Minimum density for building a jump table in " "an optsize function"))
Minimum jump table density for -Os or -Oz functions.
This file describes how to lower LLVM code to machine code.
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
Definition: APInt.h:78
A cache of @llvm.assume calls within a function.
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:506
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:709
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:864
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:213
void setBitsInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
setBitsInMask - Add '1' bits from Mask to this vector.
Definition: BitVector.h:707
iterator_range< const_set_bits_iterator > set_bits() const
Definition: BitVector.h:140
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
This class represents a range of values.
Definition: ConstantRange.h:47
LLVM_ABI unsigned getActiveBits() const
Compute the maximal number of active bits needed to represent every value in this range.
LLVM_ABI ConstantRange umul_sat(const ConstantRange &Other) const
Perform an unsigned saturating multiplication of two constant ranges.
LLVM_ABI ConstantRange subtract(const APInt &CI) const
Subtract the specified constant from the endpoints of this constant range.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
LLVM_ABI unsigned getPointerSize(unsigned AS=0) const
The pointer representation size in bytes, rounded up to a whole number of bytes.
Definition: DataLayout.cpp:738
static constexpr ElementCount getScalable(ScalarTy MinVal)
Definition: TypeSize.h:315
static constexpr ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:312
constexpr bool isScalar() const
Exactly one element.
Definition: TypeSize.h:323
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:170
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:663
@ HiddenVisibility
The GV is hidden.
Definition: GlobalValue.h:69
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:53
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:114
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition: IRBuilder.h:1891
BasicBlock * GetInsertBlock() const
Definition: IRBuilder.h:201
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2508
LLVM_ABI bool hasAtomicStore() const LLVM_READONLY
Return true if this atomic instruction stores to memory.
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
Definition: Instruction.h:406
@ MAX_INT_BITS
Maximum number of bits that can be specified.
Definition: DerivedTypes.h:54
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Definition: IntrinsicInst.h:56
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
An instruction for reading from memory.
Definition: Instructions.h:180
Value * getPointerOperand()
Definition: Instructions.h:259
bool isVolatile() const
Return true if this is a load from a volatile memory location.
Definition: Instructions.h:209
Align getAlign() const
Return the alignment of the access that is being performed.
Definition: Instructions.h:215
Machine Value Type.
SimpleValueType SimpleTy
uint64_t getScalarSizeInBits() const
bool isVector() const
Return true if this is a vector value type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
static auto all_valuetypes()
SimpleValueType Iteration.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
ElementCount getVectorElementCount() const
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
bool isValid() const
Return true if this is a valid simple valuetype.
static MVT getIntegerVT(unsigned BitWidth)
static auto fp_valuetypes()
MVT getPow2VectorType() const
Widens the length of the given vector MVT up to the nearest power of 2 and returns that type.
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool isStatepointSpillSlotObjectIndex(int ObjectIdx) const
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
Representation of each machine instruction.
Definition: MachineInstr.h:72
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:590
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
LLVM_ABI void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
LLVM_ABI void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
A description of a memory reference used in the backend.
unsigned getAddrSpace() const
Flags
Flags values. These may be or'd together.
@ MOVolatile
The memory access is volatile.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOLoad
The memory access reads data.
@ MONonTemporal
The memory access is non-temporal.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
Flags getFlags() const
Return the raw flags of the source value,.
LLVM_ABI Align getAlign() const
Return the minimum known alignment in bytes of the actual memory reference.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
LLVM_ABI void freezeReservedRegs()
freezeReservedRegs - Called by the register allocator to freeze the set of reserved registers before ...
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Class to represent pointers.
Definition: DerivedTypes.h:700
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition: DerivedTypes.h:720
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1885
Analysis providing profile information.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:229
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:498
LLVMContext * getContext() const
Definition: SelectionDAG.h:511
size_t size() const
Definition: SmallVector.h:79
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
An instruction for storing to memory.
Definition: Instructions.h:296
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:710
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:581
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:151
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:154
static constexpr size_t npos
Definition: StringRef.h:57
bool isValid() const
Returns true if this iterator is still pointing at a valid entry.
Multiway switch.
Provides information about what library functions are available for the current target.
LegalizeTypeAction getTypeAction(MVT VT) const
void setTypeAction(MVT VT, LegalizeTypeAction Action)
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
virtual Align getByValTypeAlignment(Type *Ty, const DataLayout &DL) const
Returns the desired alignment for ByVal or InAlloca aggregate function arguments in the caller parame...
int InstructionOpcodeToISD(unsigned Opcode) const
Get the ISD node that corresponds to the Instruction class opcode.
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
virtual void finalizeLowering(MachineFunction &MF) const
Execute target specific actions to finalize target lowering.
void initActions()
Initialize all of the actions to default values.
bool PredictableSelectIsExpensive
Tells the code generator that select is more expensive than a branch if the branch is usually predict...
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
virtual Value * getSafeStackPointerLocation(IRBuilderBase &IRB) const
Returns the target-specific address of the unsafe stack pointer.
int getRecipEstimateSqrtEnabled(EVT VT, MachineFunction &MF) const
Return a ReciprocalEstimate enum value for a square root of the given type based on the function's at...
virtual bool canOpTrap(unsigned Op, EVT VT) const
Returns true if the operation can trap for the value type.
virtual bool shouldLocalize(const MachineInstr &MI, const TargetTransformInfo *TTI) const
Check whether or not MI needs to be moved close to its uses.
virtual unsigned getMaxPermittedBytesForAlignment(MachineBasicBlock *MBB) const
Return the maximum amount of bytes allowed to be emitted when padding for alignment.
void setMaximumJumpTableSize(unsigned)
Indicate the maximum number of entries in jump tables.
virtual unsigned getMinimumJumpTableEntries() const
Return lower limit for number of blocks in a jump table.
const TargetMachine & getTargetMachine() const
unsigned MaxLoadsPerMemcmp
Specify maximum number of load instructions per memcmp call.
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
virtual MachineMemOperand::Flags getTargetMMOFlags(const Instruction &I) const
This callback is used to inspect load/store instructions and add target-specific MachineMemOperand fl...
unsigned MaxGluedStoresPerMemcpy
Specify max number of store instructions to glue in inlined memcpy.
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
virtual bool isSuitableForJumpTable(const SwitchInst *SI, uint64_t NumCases, uint64_t Range, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI) const
Return true if lowering to a jump table is suitable for a set of case clusters which may contain NumC...
void setIndexedMaskedLoadAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
Indicate that the specified indexed masked load does or does not work with the specified type and ind...
virtual Value * getSDagStackGuard(const Module &M) const
Return the variable that's previously inserted by insertSSPDeclarations, if any, otherwise return nul...
virtual bool useFPRegsForHalfType() const
virtual bool isLoadBitCastBeneficial(EVT LoadVT, EVT BitcastVT, const SelectionDAG &DAG, const MachineMemOperand &MMO) const
Return true if the following transform is beneficial: fold (conv (load x)) -> (load (conv*)x) On arch...
void setIndexedLoadAction(ArrayRef< unsigned > IdxModes, MVT VT, LegalizeAction Action)
Indicate that the specified indexed load does or does not work with the specified type and indicate w...
virtual bool softPromoteHalfType() const
unsigned getMaximumJumpTableSize() const
Return upper limit for number of entries in a jump table.
virtual MVT::SimpleValueType getCmpLibcallReturnType() const
Return the ValueType for comparison libcalls.
unsigned getBitWidthForCttzElements(Type *RetTy, ElementCount EC, bool ZeroIsPoison, const ConstantRange *VScaleRange) const
Return the minimum number of bits required to hold the maximum possible number of trailing zero vecto...
bool isLegalRC(const TargetRegisterInfo &TRI, const TargetRegisterClass &RC) const
Return true if the value types that can be represented by the specified register class are all legal.
virtual TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const
Return the preferred vector type legalization action.
void setAtomicLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Let target indicate that an extending atomic load of the specified type is legal.
Value * getDefaultSafeStackPointerLocation(IRBuilderBase &IRB, bool UseTLS) const
virtual Function * getSSPStackGuardCheck(const Module &M) const
If the target has a standard stack protection check function that performs validation and error handl...
MachineMemOperand::Flags getAtomicMemOperandFlags(const Instruction &AI, const DataLayout &DL) const
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *=nullptr) const
Determine if the target supports unaligned memory accesses.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
Returns the type for the shift amount of a shift opcode.
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
virtual Align getPrefLoopAlignment(MachineLoop *ML=nullptr) const
Return the preferred loop alignment.
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
MachineMemOperand::Flags getVPIntrinsicMemOperandFlags(const VPIntrinsic &VPIntrin) const
int getDivRefinementSteps(EVT VT, MachineFunction &MF) const
Return the refinement step count for a division of the given type based on the function's attributes.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
MachineMemOperand::Flags getLoadMemOperandFlags(const LoadInst &LI, const DataLayout &DL, AssumptionCache *AC=nullptr, const TargetLibraryInfo *LibInfo=nullptr) const
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
virtual Value * getIRStackGuard(IRBuilderBase &IRB) const
If the target has a standard location for the stack protector guard, returns the address of that loca...
virtual MVT getPreferredSwitchConditionType(LLVMContext &Context, EVT ConditionVT) const
Returns preferred type for switch condition.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
int getRecipEstimateDivEnabled(EVT VT, MachineFunction &MF) const
Return a ReciprocalEstimate enum value for a division of the given type based on the function's attri...
void setIndexedStoreAction(ArrayRef< unsigned > IdxModes, MVT VT, LegalizeAction Action)
Indicate that the specified indexed store does or does not work with the specified type and indicate ...
virtual bool isJumpTableRelative() const
virtual MVT getScalarShiftAmountTy(const DataLayout &, EVT) const
Return the type to use for a scalar shift opcode, given the shifted amount type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
virtual bool isFreeAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast from SrcAS to DestAS is "cheap", such that e.g.
ISD::CondCode getSoftFloatCmpLibcallPredicate(RTLIB::LibcallImpl Call) const
Get the comparison predicate that's to be used to test the result of the comparison libcall against z...
void setIndexedMaskedStoreAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
Indicate that the specified indexed masked store does or does not work with the specified type and in...
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
virtual bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
Return true if the target supports a memory access of this type for the given address space and align...
unsigned MaxLoadsPerMemcmpOptSize
Likewise for functions with the OptSize attribute.
MachineMemOperand::Flags getStoreMemOperandFlags(const StoreInst &SI, const DataLayout &DL) const
void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT)
If Opc/OrigVT is specified as being promoted, the promotion code defaults to trying a larger integer/...
unsigned getMinimumJumpTableDensity(bool OptForSize) const
Return lower limit of the density in a jump table.
virtual std::pair< const TargetRegisterClass *, uint8_t > findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT) const
Return the largest legal super-reg register class of the register class for the specified type and it...
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Get the libcall impl routine name for the specified libcall.
TargetLoweringBase(const TargetMachine &TM)
NOTE: The TargetMachine owns TLOF.
static StringRef getLibcallImplName(RTLIB::LibcallImpl Call)
Get the libcall routine name for the specified libcall implementation.
LegalizeKind getTypeConversion(LLVMContext &Context, EVT VT) const
Return pair that represents the legalization kind (first) that needs to happen to EVT (second) in ord...
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
unsigned GatherAllAliasesMaxDepth
Depth that GatherAllAliases should continue looking for chain dependencies when trying to find a more...
int IntrinsicIDToISD(Intrinsic::ID ID) const
Get the ISD node that corresponds to the Intrinsic ID.
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
int getSqrtRefinementSteps(EVT VT, MachineFunction &MF) const
Return the refinement step count for a square root of the given type based on the function's attribut...
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
bool allowsMemoryAccessForAlignment(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
This function returns true if the memory access is aligned or if the target allows this specific unal...
virtual Instruction * emitTrailingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const
virtual Instruction * emitLeadingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const
Inserts in the IR a target-specific intrinsic specifying a fence.
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
virtual void insertSSPDeclarations(Module &M) const
Inserts necessary declarations for SSP (stack protection) purpose.
void setJumpIsExpensive(bool isExpensive=true)
Tells the code generator not to expand logic operations on comparison predicates into separate sequen...
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
MVT getTypeToPromoteTo(unsigned Op, MVT VT) const
If the action for this operation is to promote, this method returns the ValueType to promote to.
virtual bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AddrSpace, Instruction *I=nullptr) const
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
unsigned getVectorTypeBreakdown(LLVMContext &Context, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Vector types are broken down into some number of legal first class types.
std::pair< LegalizeTypeAction, EVT > LegalizeKind
LegalizeKind holds the legalization kind that needs to happen to EVT in order to type-legalize it.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
virtual EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, ISD::NodeType) const
Return the type that should be used to zero or sign extend a zeroext/signext integer return value.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
bool isPositionIndependent() const
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
const Triple & getTargetTriple() const
TargetOptions Options
unsigned LoopAlignment
If greater than 0, override TargetLoweringBase::PrefLoopAlignment.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
LLVM_ABI unsigned getGISelRematGlobalCost() const
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:817
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
This is the common base class for vector predication intrinsics.
LLVM Value Representation.
Definition: Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
int getNumOccurrences() const
Definition: CommandLine.h:400
constexpr LeafTy coefficientNextPowerOf2() const
Definition: TypeSize.h:263
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:172
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:169
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
Definition: TypeSize.h:255
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:41
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition: ISDOpcodes.h:41
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
Definition: ISDOpcodes.h:801
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
Definition: ISDOpcodes.h:256
@ CTLZ_ZERO_UNDEF
Definition: ISDOpcodes.h:774
@ DELETED_NODE
DELETED_NODE - This is an illegal value that is used to catch errors.
Definition: ISDOpcodes.h:45
@ SET_FPENV
Sets the current floating-point environment.
Definition: ISDOpcodes.h:1108
@ LOOP_DEPENDENCE_RAW_MASK
Definition: ISDOpcodes.h:1565
@ VECREDUCE_SEQ_FADD
Generic reduction nodes.
Definition: ISDOpcodes.h:1458
@ VECREDUCE_SMIN
Definition: ISDOpcodes.h:1491
@ FGETSIGN
INT = FGETSIGN(FP) - Return the sign bit of the specified floating point value as an integer 0/1 valu...
Definition: ISDOpcodes.h:525
@ ATOMIC_LOAD_NAND
Definition: ISDOpcodes.h:1379
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
Definition: ISDOpcodes.h:387
@ ConstantFP
Definition: ISDOpcodes.h:87
@ ATOMIC_LOAD_MAX
Definition: ISDOpcodes.h:1381
@ ATOMIC_LOAD_UMIN
Definition: ISDOpcodes.h:1382
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
Definition: ISDOpcodes.h:289
@ RESET_FPENV
Set floating-point environment to default state.
Definition: ISDOpcodes.h:1112
@ FMAD
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations.
Definition: ISDOpcodes.h:515
@ ADD
Simple integer binary arithmetic operators.
Definition: ISDOpcodes.h:259
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
Definition: ISDOpcodes.h:1141
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
Definition: ISDOpcodes.h:393
@ SET_FPMODE
Sets the current dynamic floating-point control modes.
Definition: ISDOpcodes.h:1131
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition: ISDOpcodes.h:835
@ VECTOR_FIND_LAST_ACTIVE
Definition: ISDOpcodes.h:1550
@ FMODF
FMODF - Decomposes the operand into integral and fractional parts, each having the same type and sign...
Definition: ISDOpcodes.h:1098
@ FATAN2
FATAN2 - atan2, inspired by libm.
Definition: ISDOpcodes.h:1020
@ FSINCOSPI
FSINCOSPI - Compute both the sine and cosine times pi more accurately than FSINCOS(pi*x),...
Definition: ISDOpcodes.h:1094
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
Definition: ISDOpcodes.h:1364
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
Definition: ISDOpcodes.h:862
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
Definition: ISDOpcodes.h:571
@ VECREDUCE_FMAX
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
Definition: ISDOpcodes.h:1476
@ FADD
Simple binary floating point operators.
Definition: ISDOpcodes.h:410
@ VECREDUCE_FMAXIMUM
FMINIMUM/FMAXIMUM nodes propatate NaNs and signed zeroes using the llvm.minimum and llvm....
Definition: ISDOpcodes.h:1480
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
Definition: ISDOpcodes.h:738
@ RESET_FPMODE
Sets default dynamic floating-point control modes.
Definition: ISDOpcodes.h:1135
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
Definition: ISDOpcodes.h:892
@ VECREDUCE_SMAX
Definition: ISDOpcodes.h:1490
@ ATOMIC_LOAD_OR
Definition: ISDOpcodes.h:1377
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
Definition: ISDOpcodes.h:975
@ ATOMIC_LOAD_XOR
Definition: ISDOpcodes.h:1378
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
Definition: ISDOpcodes.h:1018
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
Definition: ISDOpcodes.h:400
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:1574
@ SIGN_EXTEND
Conversion operators.
Definition: ISDOpcodes.h:826
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
Definition: ISDOpcodes.h:706
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
Definition: ISDOpcodes.h:1298
@ VECREDUCE_FADD
These reductions have relaxed evaluation order semantics, and have a single vector operand.
Definition: ISDOpcodes.h:1473
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
Definition: ISDOpcodes.h:773
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
Definition: ISDOpcodes.h:1331
@ TRUNCATE_SSAT_U
Definition: ISDOpcodes.h:855
@ VECREDUCE_FMIN
Definition: ISDOpcodes.h:1477
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
Definition: ISDOpcodes.h:1090
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
Definition: ISDOpcodes.h:809
@ FNEG
Perform various unary floating-point operations inspired by libm.
Definition: ISDOpcodes.h:1002
@ SSUBO
Same for subtraction.
Definition: ISDOpcodes.h:347
@ ATOMIC_LOAD_MIN
Definition: ISDOpcodes.h:1380
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
Definition: ISDOpcodes.h:528
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
Definition: ISDOpcodes.h:535
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
Definition: ISDOpcodes.h:369
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
Definition: ISDOpcodes.h:778
@ VECREDUCE_UMAX
Definition: ISDOpcodes.h:1492
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
Definition: ISDOpcodes.h:663
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
Definition: ISDOpcodes.h:343
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
Definition: ISDOpcodes.h:1485
@ GET_FPMODE
Reads the current dynamic floating-point control modes.
Definition: ISDOpcodes.h:1126
@ GET_FPENV
Gets the current floating-point environment.
Definition: ISDOpcodes.h:1103
@ SHL
Shift and rotation operations.
Definition: ISDOpcodes.h:756
@ ATOMIC_LOAD_CLR
Definition: ISDOpcodes.h:1376
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
Definition: ISDOpcodes.h:636
@ ATOMIC_LOAD_AND
Definition: ISDOpcodes.h:1375
@ FMINNUM_IEEE
FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or maximumNumber on two values,...
Definition: ISDOpcodes.h:1075
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
Definition: ISDOpcodes.h:563
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition: ISDOpcodes.h:832
@ DEBUGTRAP
DEBUGTRAP - Trap intended to get the attention of a debugger.
Definition: ISDOpcodes.h:1321
@ FP_TO_UINT_SAT
Definition: ISDOpcodes.h:928
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
Definition: ISDOpcodes.h:1358
@ ATOMIC_LOAD_UMAX
Definition: ISDOpcodes.h:1383
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum maximum on two values, following IEEE-754 definition...
Definition: ISDOpcodes.h:1059
@ UBSANTRAP
UBSANTRAP - Trap with an immediate describing the kind of sanitizer failure.
Definition: ISDOpcodes.h:1325
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
Definition: ISDOpcodes.h:379
@ SMULO
Same for multiplication.
Definition: ISDOpcodes.h:351
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
Definition: ISDOpcodes.h:881
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
Definition: ISDOpcodes.h:870
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
Definition: ISDOpcodes.h:718
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
Definition: ISDOpcodes.h:406
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
Definition: ISDOpcodes.h:960
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
Definition: ISDOpcodes.h:323
@ VECREDUCE_UMIN
Definition: ISDOpcodes.h:1493
@ ATOMIC_LOAD_ADD
Definition: ISDOpcodes.h:1373
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
Definition: ISDOpcodes.h:1081
@ ATOMIC_LOAD_SUB
Definition: ISDOpcodes.h:1374
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
Definition: ISDOpcodes.h:908
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
Definition: ISDOpcodes.h:1292
@ AND
Bitwise operators - logical and, logical or, logical xor.
Definition: ISDOpcodes.h:730
@ TRAP
TRAP - Trapping instruction.
Definition: ISDOpcodes.h:1318
@ GET_FPENV_MEM
Gets the current floating-point environment.
Definition: ISDOpcodes.h:1117
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
Definition: ISDOpcodes.h:726
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
Definition: ISDOpcodes.h:701
@ VECREDUCE_FMUL
Definition: ISDOpcodes.h:1474
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
Definition: ISDOpcodes.h:299
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
Definition: ISDOpcodes.h:236
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
Definition: ISDOpcodes.h:552
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
Definition: ISDOpcodes.h:648
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
Definition: ISDOpcodes.h:1372
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
Definition: ISDOpcodes.h:1025
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
Definition: ISDOpcodes.h:941
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
Definition: ISDOpcodes.h:690
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Definition: ISDOpcodes.h:903
@ ADDRSPACECAST
ADDRSPACECAST - This operator converts between pointers of different address spaces.
Definition: ISDOpcodes.h:979
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
Definition: ISDOpcodes.h:927
@ VECREDUCE_FMINIMUM
Definition: ISDOpcodes.h:1481
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
Definition: ISDOpcodes.h:838
@ VECREDUCE_SEQ_FMUL
Definition: ISDOpcodes.h:1459
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
Definition: ISDOpcodes.h:521
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
Definition: ISDOpcodes.h:360
@ GET_DYNAMIC_AREA_OFFSET
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca.
Definition: ISDOpcodes.h:1439
@ SET_FPENV_MEM
Sets the current floating point environment.
Definition: ISDOpcodes.h:1122
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - minimumnum/maximumnum that is same with FMINNUM_IEEE and FMAXNUM_IEEE besid...
Definition: ISDOpcodes.h:1086
@ TRUNCATE_SSAT_S
TRUNCATE_[SU]SAT_[SU] - Truncate for saturated operand [SU] located in middle, prefix for SAT means i...
Definition: ISDOpcodes.h:853
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
Definition: ISDOpcodes.h:713
@ TRUNCATE_USAT_U
Definition: ISDOpcodes.h:857
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
Definition: ISDOpcodes.h:333
@ LOOP_DEPENDENCE_WAR_MASK
Definition: ISDOpcodes.h:1564
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
Definition: ISDOpcodes.h:1691
static const int LAST_INDEXED_MODE
Definition: ISDOpcodes.h:1642
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFREXP(EVT RetVT)
getFREXP - Return the FREXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOSPI(EVT RetVT)
getSINCOSPI - Return the SINCOSPI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getMEMCPY_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMCPY_ELEMENT_UNORDERED_ATOMIC - Return MEMCPY_ELEMENT_UNORDERED_ATOMIC_* value for the given ele...
LLVM_ABI Libcall getMODF(EVT RetVT)
getMODF - Return the MODF_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPLibCall(EVT VT, Libcall Call_F32, Libcall Call_F64, Libcall Call_F80, Libcall Call_F128, Libcall Call_PPCF128)
GetFPLibCall - Helper to return the right libcall for the given floating point type,...
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getCOS(EVT RetVT)
Return the COS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSIN(EVT RetVT)
Return the SIN_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getMEMSET_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMSET_ELEMENT_UNORDERED_ATOMIC - Return MEMSET_ELEMENT_UNORDERED_ATOMIC_* value for the given ele...
LLVM_ABI Libcall getPOW(EVT RetVT)
getPOW - Return the POW_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getOutlineAtomicHelper(const Libcall(&LC)[5][4], AtomicOrdering Order, uint64_t MemSize)
Return the outline atomics value for the given atomic ordering, access size and set of libcalls for a...
LLVM_ABI Libcall getSINCOS(EVT RetVT)
getSINCOS - Return the SINCOS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMMOVE_ELEMENT_UNORDERED_ATOMIC - Return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_* value for the given e...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:444
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition: MathExtras.h:349
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1764
LLVM_ABI void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags,...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
Definition: Sequence.h:337
LLVM_ABI bool isDereferenceableAndAlignedPointer(const Value *V, Type *Ty, Align Alignment, const DataLayout &DL, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested.
Definition: Loads.cpp:232
LLVM_ABI bool shouldOptimizeForSize(const MachineFunction *MF, ProfileSummaryInfo *PSI, const MachineBlockFrequencyInfo *BFI, PGSOQueryType QueryType=PGSOQueryType::Other)
Returns true if machine function MF is suggested to be size-optimized based on the profile.
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
Definition: Sequence.h:108
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
Definition: bit.h:295
void ComputeValueTypes(const DataLayout &DL, Type *Ty, SmallVectorImpl< Type * > &Types, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
Given an LLVM IR type, compute non-aggregate subtypes.
Definition: Analysis.cpp:72
bool isReleaseOrStronger(AtomicOrdering AO)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:288
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1758
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition: Error.cpp:167
AtomicOrdering
Atomic ordering for LLVM's memory model.
LLVM_ABI EVT getApproximateEVTForLLT(LLT Ty, LLVMContext &Ctx)
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
Definition: MathExtras.h:399
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ FMul
Product of floats.
@ Sub
Subtraction of integers.
@ Add
Sum of integers.
@ FAdd
Sum of floats.
bool isAcquireOrStronger(AtomicOrdering AO)
InstructionCost Cost
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Extended Value Type.
Definition: ValueTypes.h:35
EVT getPow2VectorType(LLVMContext &Context) const
Widens the length of the given vector EVT up to the nearest power of 2 and returns that type.
Definition: ValueTypes.h:472
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
Definition: ValueTypes.h:137
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
Definition: ValueTypes.h:74
ElementCount getVectorElementCount() const
Definition: ValueTypes.h:345
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition: ValueTypes.h:368
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
Definition: ValueTypes.h:465
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:311
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
Definition: ValueTypes.h:65
bool isFixedLengthVector() const
Definition: ValueTypes.h:181
EVT getRoundIntegerType(LLVMContext &Context) const
Rounds the bit-width of the given integer EVT up to the nearest power of two (and at least to eight),...
Definition: ValueTypes.h:414
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:168
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Definition: ValueTypes.h:318
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
Definition: ValueTypes.cpp:216
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition: ValueTypes.h:323
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition: ValueTypes.h:331
bool isZeroSized() const
Test if the given EVT has zero size, this will fail if called on a scalable type.
Definition: ValueTypes.h:132
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
Definition: ValueTypes.h:448
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition: ValueTypes.h:152
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
Matching combinators.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static RTLIB::Libcall getLibcallFromImpl(RTLIB::LibcallImpl Impl)
Return the libcall provided by Impl.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...