LLVM  13.0.0git
IRBuilder.cpp
Go to the documentation of this file.
1 //===- IRBuilder.cpp - Builder for LLVM Instrs ----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the IRBuilder class, which is used as a convenient way
10 // to create LLVM instructions with a consistent and simplified interface.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/IR/IRBuilder.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/None.h"
17 #include "llvm/IR/Constant.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/DerivedTypes.h"
20 #include "llvm/IR/Function.h"
21 #include "llvm/IR/GlobalValue.h"
22 #include "llvm/IR/GlobalVariable.h"
23 #include "llvm/IR/IntrinsicInst.h"
24 #include "llvm/IR/Intrinsics.h"
25 #include "llvm/IR/LLVMContext.h"
26 #include "llvm/IR/NoFolder.h"
27 #include "llvm/IR/Operator.h"
28 #include "llvm/IR/Statepoint.h"
29 #include "llvm/IR/Type.h"
30 #include "llvm/IR/Value.h"
31 #include "llvm/Support/Casting.h"
33 #include <cassert>
34 #include <cstdint>
35 #include <vector>
36 
37 using namespace llvm;
38 
39 /// CreateGlobalString - Make a new global variable with an initializer that
40 /// has array of i8 type filled in with the nul terminated string value
41 /// specified. If Name is specified, it is the name of the global variable
42 /// created.
44  const Twine &Name,
45  unsigned AddressSpace,
46  Module *M) {
47  Constant *StrConstant = ConstantDataArray::getString(Context, Str);
48  if (!M)
49  M = BB->getParent()->getParent();
50  auto *GV = new GlobalVariable(
51  *M, StrConstant->getType(), true, GlobalValue::PrivateLinkage,
52  StrConstant, Name, nullptr, GlobalVariable::NotThreadLocal, AddressSpace);
53  GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
54  GV->setAlignment(Align(1));
55  return GV;
56 }
57 
59  assert(BB && BB->getParent() && "No current function!");
60  return BB->getParent()->getReturnType();
61 }
62 
63 Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
64  auto *PT = cast<PointerType>(Ptr->getType());
65  if (PT->getElementType()->isIntegerTy(8))
66  return Ptr;
67 
68  // Otherwise, we need to insert a bitcast.
69  return CreateBitCast(Ptr, getInt8PtrTy(PT->getAddressSpace()));
70 }
71 
74  const Twine &Name = "",
75  Instruction *FMFSource = nullptr,
76  ArrayRef<OperandBundleDef> OpBundles = {}) {
77  CallInst *CI = Builder->CreateCall(Callee, Ops, OpBundles, Name);
78  if (FMFSource)
79  CI->copyFastMathFlags(FMFSource);
80  return CI;
81 }
82 
85  assert(isa<ConstantInt>(Scaling) && "Expected constant integer");
86  Function *TheFn =
87  Intrinsic::getDeclaration(M, Intrinsic::vscale, {Scaling->getType()});
88  CallInst *CI = createCallHelper(TheFn, {}, this, Name);
89  return cast<ConstantInt>(Scaling)->getSExtValue() == 1
90  ? CI
91  : CreateMul(CI, Scaling);
92 }
93 
95  if (isa<ScalableVectorType>(DstType))
96  return CreateIntrinsic(Intrinsic::experimental_stepvector, {DstType}, {},
97  nullptr, Name);
98 
99  Type *STy = DstType->getScalarType();
100  unsigned NumEls = cast<FixedVectorType>(DstType)->getNumElements();
101 
102  // Create a vector of consecutive numbers from zero to VF.
104  for (unsigned i = 0; i < NumEls; ++i)
105  Indices.push_back(ConstantInt::get(STy, i));
106 
107  // Add the consecutive indices to the vector value.
108  return ConstantVector::get(Indices);
109 }
110 
112  MaybeAlign Align, bool isVolatile,
113  MDNode *TBAATag, MDNode *ScopeTag,
114  MDNode *NoAliasTag) {
115  Ptr = getCastedInt8PtrValue(Ptr);
116  Value *Ops[] = {Ptr, Val, Size, getInt1(isVolatile)};
117  Type *Tys[] = { Ptr->getType(), Size->getType() };
118  Module *M = BB->getParent()->getParent();
119  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
120 
121  CallInst *CI = createCallHelper(TheFn, Ops, this);
122 
123  if (Align)
124  cast<MemSetInst>(CI)->setDestAlignment(Align->value());
125 
126  // Set the TBAA info if present.
127  if (TBAATag)
128  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
129 
130  if (ScopeTag)
131  CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
132 
133  if (NoAliasTag)
134  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
135 
136  return CI;
137 }
138 
140  Value *Ptr, Value *Val, Value *Size, Align Alignment, uint32_t ElementSize,
141  MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) {
142 
143  Ptr = getCastedInt8PtrValue(Ptr);
144  Value *Ops[] = {Ptr, Val, Size, getInt32(ElementSize)};
145  Type *Tys[] = {Ptr->getType(), Size->getType()};
146  Module *M = BB->getParent()->getParent();
148  M, Intrinsic::memset_element_unordered_atomic, Tys);
149 
150  CallInst *CI = createCallHelper(TheFn, Ops, this);
151 
152  cast<AtomicMemSetInst>(CI)->setDestAlignment(Alignment);
153 
154  // Set the TBAA info if present.
155  if (TBAATag)
156  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
157 
158  if (ScopeTag)
159  CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
160 
161  if (NoAliasTag)
162  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
163 
164  return CI;
165 }
166 
168  Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src,
169  MaybeAlign SrcAlign, Value *Size, bool isVolatile, MDNode *TBAATag,
170  MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) {
171  Dst = getCastedInt8PtrValue(Dst);
172  Src = getCastedInt8PtrValue(Src);
173 
174  Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)};
175  Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
176  Module *M = BB->getParent()->getParent();
177  Function *TheFn = Intrinsic::getDeclaration(M, IntrID, Tys);
178 
179  CallInst *CI = createCallHelper(TheFn, Ops, this);
180 
181  auto* MCI = cast<MemTransferInst>(CI);
182  if (DstAlign)
183  MCI->setDestAlignment(*DstAlign);
184  if (SrcAlign)
185  MCI->setSourceAlignment(*SrcAlign);
186 
187  // Set the TBAA info if present.
188  if (TBAATag)
189  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
190 
191  // Set the TBAA Struct info if present.
192  if (TBAAStructTag)
193  CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
194 
195  if (ScopeTag)
196  CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
197 
198  if (NoAliasTag)
199  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
200 
201  return CI;
202 }
203 
205  Value *Src, MaybeAlign SrcAlign,
206  Value *Size) {
207  Dst = getCastedInt8PtrValue(Dst);
208  Src = getCastedInt8PtrValue(Src);
209  Value *IsVolatile = getInt1(false);
210 
211  Value *Ops[] = {Dst, Src, Size, IsVolatile};
212  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
213  Function *F = BB->getParent();
214  Module *M = F->getParent();
215  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys);
216 
217  CallInst *CI = createCallHelper(TheFn, Ops, this);
218 
219  auto *MCI = cast<MemCpyInlineInst>(CI);
220  if (DstAlign)
221  MCI->setDestAlignment(*DstAlign);
222  if (SrcAlign)
223  MCI->setSourceAlignment(*SrcAlign);
224 
225  return CI;
226 }
227 
229  Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
230  uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
231  MDNode *ScopeTag, MDNode *NoAliasTag) {
232  assert(DstAlign >= ElementSize &&
233  "Pointer alignment must be at least element size");
234  assert(SrcAlign >= ElementSize &&
235  "Pointer alignment must be at least element size");
236  Dst = getCastedInt8PtrValue(Dst);
237  Src = getCastedInt8PtrValue(Src);
238 
239  Value *Ops[] = {Dst, Src, Size, getInt32(ElementSize)};
240  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
241  Module *M = BB->getParent()->getParent();
243  M, Intrinsic::memcpy_element_unordered_atomic, Tys);
244 
245  CallInst *CI = createCallHelper(TheFn, Ops, this);
246 
247  // Set the alignment of the pointer args.
248  auto *AMCI = cast<AtomicMemCpyInst>(CI);
249  AMCI->setDestAlignment(DstAlign);
250  AMCI->setSourceAlignment(SrcAlign);
251 
252  // Set the TBAA info if present.
253  if (TBAATag)
254  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
255 
256  // Set the TBAA Struct info if present.
257  if (TBAAStructTag)
258  CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
259 
260  if (ScopeTag)
261  CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
262 
263  if (NoAliasTag)
264  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
265 
266  return CI;
267 }
268 
270  Value *Src, MaybeAlign SrcAlign,
271  Value *Size, bool isVolatile,
272  MDNode *TBAATag, MDNode *ScopeTag,
273  MDNode *NoAliasTag) {
274  Dst = getCastedInt8PtrValue(Dst);
275  Src = getCastedInt8PtrValue(Src);
276 
277  Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)};
278  Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
279  Module *M = BB->getParent()->getParent();
280  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys);
281 
282  CallInst *CI = createCallHelper(TheFn, Ops, this);
283 
284  auto *MMI = cast<MemMoveInst>(CI);
285  if (DstAlign)
286  MMI->setDestAlignment(*DstAlign);
287  if (SrcAlign)
288  MMI->setSourceAlignment(*SrcAlign);
289 
290  // Set the TBAA info if present.
291  if (TBAATag)
292  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
293 
294  if (ScopeTag)
295  CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
296 
297  if (NoAliasTag)
298  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
299 
300  return CI;
301 }
302 
304  Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
305  uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
306  MDNode *ScopeTag, MDNode *NoAliasTag) {
307  assert(DstAlign >= ElementSize &&
308  "Pointer alignment must be at least element size");
309  assert(SrcAlign >= ElementSize &&
310  "Pointer alignment must be at least element size");
311  Dst = getCastedInt8PtrValue(Dst);
312  Src = getCastedInt8PtrValue(Src);
313 
314  Value *Ops[] = {Dst, Src, Size, getInt32(ElementSize)};
315  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
316  Module *M = BB->getParent()->getParent();
318  M, Intrinsic::memmove_element_unordered_atomic, Tys);
319 
320  CallInst *CI = createCallHelper(TheFn, Ops, this);
321 
322  // Set the alignment of the pointer args.
323  CI->addParamAttr(0, Attribute::getWithAlignment(CI->getContext(), DstAlign));
324  CI->addParamAttr(1, Attribute::getWithAlignment(CI->getContext(), SrcAlign));
325 
326  // Set the TBAA info if present.
327  if (TBAATag)
328  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
329 
330  // Set the TBAA Struct info if present.
331  if (TBAAStructTag)
332  CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
333 
334  if (ScopeTag)
335  CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
336 
337  if (NoAliasTag)
338  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
339 
340  return CI;
341 }
342 
344  Value *Src) {
345  Module *M = Builder->GetInsertBlock()->getParent()->getParent();
346  Value *Ops[] = {Src};
347  Type *Tys[] = { Src->getType() };
348  auto Decl = Intrinsic::getDeclaration(M, ID, Tys);
349  return createCallHelper(Decl, Ops, Builder);
350 }
351 
354  Value *Ops[] = {Acc, Src};
355  auto Decl = Intrinsic::getDeclaration(M, Intrinsic::vector_reduce_fadd,
356  {Src->getType()});
357  return createCallHelper(Decl, Ops, this);
358 }
359 
362  Value *Ops[] = {Acc, Src};
363  auto Decl = Intrinsic::getDeclaration(M, Intrinsic::vector_reduce_fmul,
364  {Src->getType()});
365  return createCallHelper(Decl, Ops, this);
366 }
367 
369  return getReductionIntrinsic(this, Intrinsic::vector_reduce_add, Src);
370 }
371 
373  return getReductionIntrinsic(this, Intrinsic::vector_reduce_mul, Src);
374 }
375 
377  return getReductionIntrinsic(this, Intrinsic::vector_reduce_and, Src);
378 }
379 
381  return getReductionIntrinsic(this, Intrinsic::vector_reduce_or, Src);
382 }
383 
385  return getReductionIntrinsic(this, Intrinsic::vector_reduce_xor, Src);
386 }
387 
389  auto ID =
390  IsSigned ? Intrinsic::vector_reduce_smax : Intrinsic::vector_reduce_umax;
391  return getReductionIntrinsic(this, ID, Src);
392 }
393 
395  auto ID =
396  IsSigned ? Intrinsic::vector_reduce_smin : Intrinsic::vector_reduce_umin;
397  return getReductionIntrinsic(this, ID, Src);
398 }
399 
401  return getReductionIntrinsic(this, Intrinsic::vector_reduce_fmax, Src);
402 }
403 
405  return getReductionIntrinsic(this, Intrinsic::vector_reduce_fmin, Src);
406 }
407 
409  assert(isa<PointerType>(Ptr->getType()) &&
410  "lifetime.start only applies to pointers.");
411  Ptr = getCastedInt8PtrValue(Ptr);
412  if (!Size)
413  Size = getInt64(-1);
414  else
415  assert(Size->getType() == getInt64Ty() &&
416  "lifetime.start requires the size to be an i64");
417  Value *Ops[] = { Size, Ptr };
418  Module *M = BB->getParent()->getParent();
419  Function *TheFn =
420  Intrinsic::getDeclaration(M, Intrinsic::lifetime_start, {Ptr->getType()});
421  return createCallHelper(TheFn, Ops, this);
422 }
423 
425  assert(isa<PointerType>(Ptr->getType()) &&
426  "lifetime.end only applies to pointers.");
427  Ptr = getCastedInt8PtrValue(Ptr);
428  if (!Size)
429  Size = getInt64(-1);
430  else
431  assert(Size->getType() == getInt64Ty() &&
432  "lifetime.end requires the size to be an i64");
433  Value *Ops[] = { Size, Ptr };
434  Module *M = BB->getParent()->getParent();
435  Function *TheFn =
436  Intrinsic::getDeclaration(M, Intrinsic::lifetime_end, {Ptr->getType()});
437  return createCallHelper(TheFn, Ops, this);
438 }
439 
441 
442  assert(isa<PointerType>(Ptr->getType()) &&
443  "invariant.start only applies to pointers.");
444  Ptr = getCastedInt8PtrValue(Ptr);
445  if (!Size)
446  Size = getInt64(-1);
447  else
448  assert(Size->getType() == getInt64Ty() &&
449  "invariant.start requires the size to be an i64");
450 
451  Value *Ops[] = {Size, Ptr};
452  // Fill in the single overloaded type: memory object type.
453  Type *ObjectPtr[1] = {Ptr->getType()};
454  Module *M = BB->getParent()->getParent();
455  Function *TheFn =
456  Intrinsic::getDeclaration(M, Intrinsic::invariant_start, ObjectPtr);
457  return createCallHelper(TheFn, Ops, this);
458 }
459 
460 CallInst *
462  ArrayRef<OperandBundleDef> OpBundles) {
463  assert(Cond->getType() == getInt1Ty() &&
464  "an assumption condition must be of type i1");
465 
466  Value *Ops[] = { Cond };
467  Module *M = BB->getParent()->getParent();
468  Function *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume);
469  return createCallHelper(FnAssume, Ops, this, "", nullptr, OpBundles);
470 }
471 
473  Module *M = BB->getModule();
474  auto *FnIntrinsic = Intrinsic::getDeclaration(
475  M, Intrinsic::experimental_noalias_scope_decl, {});
476  return createCallHelper(FnIntrinsic, {Scope}, this);
477 }
478 
479 /// Create a call to a Masked Load intrinsic.
480 /// \p Ptr - base pointer for the load
481 /// \p Alignment - alignment of the source location
482 /// \p Mask - vector of booleans which indicates what vector lanes should
483 /// be accessed in memory
484 /// \p PassThru - pass-through value that is used to fill the masked-off lanes
485 /// of the result
486 /// \p Name - name of the result variable
488  Value *Mask, Value *PassThru,
489  const Twine &Name) {
490  auto *PtrTy = cast<PointerType>(Ptr->getType());
491  Type *DataTy = PtrTy->getElementType();
492  assert(DataTy->isVectorTy() && "Ptr should point to a vector");
493  assert(Mask && "Mask should not be all-ones (null)");
494  if (!PassThru)
495  PassThru = UndefValue::get(DataTy);
496  Type *OverloadedTypes[] = { DataTy, PtrTy };
497  Value *Ops[] = {Ptr, getInt32(Alignment.value()), Mask, PassThru};
498  return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
499  OverloadedTypes, Name);
500 }
501 
502 /// Create a call to a Masked Store intrinsic.
503 /// \p Val - data to be stored,
504 /// \p Ptr - base pointer for the store
505 /// \p Alignment - alignment of the destination location
506 /// \p Mask - vector of booleans which indicates what vector lanes should
507 /// be accessed in memory
509  Align Alignment, Value *Mask) {
510  auto *PtrTy = cast<PointerType>(Ptr->getType());
511  Type *DataTy = PtrTy->getElementType();
512  assert(DataTy->isVectorTy() && "Ptr should point to a vector");
513  assert(Mask && "Mask should not be all-ones (null)");
514  Type *OverloadedTypes[] = { DataTy, PtrTy };
515  Value *Ops[] = {Val, Ptr, getInt32(Alignment.value()), Mask};
516  return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
517 }
518 
519 /// Create a call to a Masked intrinsic, with given intrinsic Id,
520 /// an array of operands - Ops, and an array of overloaded types -
521 /// OverloadedTypes.
522 CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
523  ArrayRef<Value *> Ops,
524  ArrayRef<Type *> OverloadedTypes,
525  const Twine &Name) {
526  Module *M = BB->getParent()->getParent();
527  Function *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
528  return createCallHelper(TheFn, Ops, this, Name);
529 }
530 
531 /// Create a call to a Masked Gather intrinsic.
532 /// \p Ptrs - vector of pointers for loading
533 /// \p Align - alignment for one element
534 /// \p Mask - vector of booleans which indicates what vector lanes should
535 /// be accessed in memory
536 /// \p PassThru - pass-through value that is used to fill the masked-off lanes
537 /// of the result
538 /// \p Name - name of the result variable
540  Value *Mask, Value *PassThru,
541  const Twine &Name) {
542  auto *PtrsTy = cast<VectorType>(Ptrs->getType());
543  auto *PtrTy = cast<PointerType>(PtrsTy->getElementType());
544  ElementCount NumElts = PtrsTy->getElementCount();
545  auto *DataTy = VectorType::get(PtrTy->getElementType(), NumElts);
546 
547  if (!Mask)
550 
551  if (!PassThru)
552  PassThru = UndefValue::get(DataTy);
553 
554  Type *OverloadedTypes[] = {DataTy, PtrsTy};
555  Value *Ops[] = {Ptrs, getInt32(Alignment.value()), Mask, PassThru};
556 
557  // We specify only one type when we create this intrinsic. Types of other
558  // arguments are derived from this type.
559  return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, OverloadedTypes,
560  Name);
561 }
562 
563 /// Create a call to a Masked Scatter intrinsic.
564 /// \p Data - data to be stored,
565 /// \p Ptrs - the vector of pointers, where the \p Data elements should be
566 /// stored
567 /// \p Align - alignment for one element
568 /// \p Mask - vector of booleans which indicates what vector lanes should
569 /// be accessed in memory
571  Align Alignment, Value *Mask) {
572  auto *PtrsTy = cast<VectorType>(Ptrs->getType());
573  auto *DataTy = cast<VectorType>(Data->getType());
574  ElementCount NumElts = PtrsTy->getElementCount();
575 
576 #ifndef NDEBUG
577  auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
578  assert(NumElts == DataTy->getElementCount() &&
579  PtrTy->getElementType() == DataTy->getElementType() &&
580  "Incompatible pointer and data types");
581 #endif
582 
583  if (!Mask)
586 
587  Type *OverloadedTypes[] = {DataTy, PtrsTy};
588  Value *Ops[] = {Data, Ptrs, getInt32(Alignment.value()), Mask};
589 
590  // We specify only one type when we create this intrinsic. Types of other
591  // arguments are derived from this type.
592  return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, OverloadedTypes);
593 }
594 
595 template <typename T0>
596 static std::vector<Value *>
597 getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes,
598  Value *ActualCallee, uint32_t Flags, ArrayRef<T0> CallArgs) {
599  std::vector<Value *> Args;
600  Args.push_back(B.getInt64(ID));
601  Args.push_back(B.getInt32(NumPatchBytes));
602  Args.push_back(ActualCallee);
603  Args.push_back(B.getInt32(CallArgs.size()));
604  Args.push_back(B.getInt32(Flags));
605  llvm::append_range(Args, CallArgs);
606  // GC Transition and Deopt args are now always handled via operand bundle.
607  // They will be removed from the signature of gc.statepoint shortly.
608  Args.push_back(B.getInt32(0));
609  Args.push_back(B.getInt32(0));
610  // GC args are now encoded in the gc-live operand bundle
611  return Args;
612 }
613 
614 template<typename T1, typename T2, typename T3>
615 static std::vector<OperandBundleDef>
617  Optional<ArrayRef<T2>> DeoptArgs,
618  ArrayRef<T3> GCArgs) {
619  std::vector<OperandBundleDef> Rval;
620  if (DeoptArgs) {
621  SmallVector<Value*, 16> DeoptValues;
622  llvm::append_range(DeoptValues, *DeoptArgs);
623  Rval.emplace_back("deopt", DeoptValues);
624  }
625  if (TransitionArgs) {
626  SmallVector<Value*, 16> TransitionValues;
627  llvm::append_range(TransitionValues, *TransitionArgs);
628  Rval.emplace_back("gc-transition", TransitionValues);
629  }
630  if (GCArgs.size()) {
631  SmallVector<Value*, 16> LiveValues;
632  llvm::append_range(LiveValues, GCArgs);
633  Rval.emplace_back("gc-live", LiveValues);
634  }
635  return Rval;
636 }
637 
638 template <typename T0, typename T1, typename T2, typename T3>
640  IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes,
641  Value *ActualCallee, uint32_t Flags, ArrayRef<T0> CallArgs,
642  Optional<ArrayRef<T1>> TransitionArgs,
643  Optional<ArrayRef<T2>> DeoptArgs, ArrayRef<T3> GCArgs,
644  const Twine &Name) {
645  // Extract out the type of the callee.
646  auto *FuncPtrType = cast<PointerType>(ActualCallee->getType());
647  assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
648  "actual callee must be a callable value");
649 
650  Module *M = Builder->GetInsertBlock()->getParent()->getParent();
651  // Fill in the one generic type'd argument (the function is also vararg)
652  Type *ArgTypes[] = { FuncPtrType };
653  Function *FnStatepoint =
654  Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_statepoint,
655  ArgTypes);
656 
657  std::vector<Value *> Args =
658  getStatepointArgs(*Builder, ID, NumPatchBytes, ActualCallee, Flags,
659  CallArgs);
660 
661  return Builder->CreateCall(FnStatepoint, Args,
662  getStatepointBundles(TransitionArgs, DeoptArgs,
663  GCArgs),
664  Name);
665 }
666 
668  uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee,
669  ArrayRef<Value *> CallArgs, Optional<ArrayRef<Value *>> DeoptArgs,
670  ArrayRef<Value *> GCArgs, const Twine &Name) {
671  return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
672  this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
673  CallArgs, None /* No Transition Args */, DeoptArgs, GCArgs, Name);
674 }
675 
677  uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags,
678  ArrayRef<Value *> CallArgs, Optional<ArrayRef<Use>> TransitionArgs,
679  Optional<ArrayRef<Use>> DeoptArgs, ArrayRef<Value *> GCArgs,
680  const Twine &Name) {
681  return CreateGCStatepointCallCommon<Value *, Use, Use, Value *>(
682  this, ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
683  DeoptArgs, GCArgs, Name);
684 }
685 
687  uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee,
688  ArrayRef<Use> CallArgs, Optional<ArrayRef<Value *>> DeoptArgs,
689  ArrayRef<Value *> GCArgs, const Twine &Name) {
690  return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
691  this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
692  CallArgs, None, DeoptArgs, GCArgs, Name);
693 }
694 
695 template <typename T0, typename T1, typename T2, typename T3>
697  IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes,
698  Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest,
699  uint32_t Flags, ArrayRef<T0> InvokeArgs,
700  Optional<ArrayRef<T1>> TransitionArgs, Optional<ArrayRef<T2>> DeoptArgs,
701  ArrayRef<T3> GCArgs, const Twine &Name) {
702  // Extract out the type of the callee.
703  auto *FuncPtrType = cast<PointerType>(ActualInvokee->getType());
704  assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
705  "actual callee must be a callable value");
706 
707  Module *M = Builder->GetInsertBlock()->getParent()->getParent();
708  // Fill in the one generic type'd argument (the function is also vararg)
709  Function *FnStatepoint = Intrinsic::getDeclaration(
710  M, Intrinsic::experimental_gc_statepoint, {FuncPtrType});
711 
712  std::vector<Value *> Args =
713  getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee, Flags,
714  InvokeArgs);
715 
716  return Builder->CreateInvoke(FnStatepoint, NormalDest, UnwindDest, Args,
717  getStatepointBundles(TransitionArgs, DeoptArgs,
718  GCArgs),
719  Name);
720 }
721 
723  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
724  BasicBlock *NormalDest, BasicBlock *UnwindDest,
725  ArrayRef<Value *> InvokeArgs, Optional<ArrayRef<Value *>> DeoptArgs,
726  ArrayRef<Value *> GCArgs, const Twine &Name) {
727  return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
728  this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
729  uint32_t(StatepointFlags::None), InvokeArgs, None /* No Transition Args*/,
730  DeoptArgs, GCArgs, Name);
731 }
732 
734  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
735  BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
736  ArrayRef<Value *> InvokeArgs, Optional<ArrayRef<Use>> TransitionArgs,
737  Optional<ArrayRef<Use>> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
738  return CreateGCStatepointInvokeCommon<Value *, Use, Use, Value *>(
739  this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
740  InvokeArgs, TransitionArgs, DeoptArgs, GCArgs, Name);
741 }
742 
744  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
745  BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
746  Optional<ArrayRef<Value *>> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
747  return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
748  this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
749  uint32_t(StatepointFlags::None), InvokeArgs, None, DeoptArgs, GCArgs,
750  Name);
751 }
752 
754  Type *ResultType,
755  const Twine &Name) {
756  Intrinsic::ID ID = Intrinsic::experimental_gc_result;
757  Module *M = BB->getParent()->getParent();
758  Type *Types[] = {ResultType};
759  Function *FnGCResult = Intrinsic::getDeclaration(M, ID, Types);
760 
761  Value *Args[] = {Statepoint};
762  return createCallHelper(FnGCResult, Args, this, Name);
763 }
764 
766  int BaseOffset,
767  int DerivedOffset,
768  Type *ResultType,
769  const Twine &Name) {
770  Module *M = BB->getParent()->getParent();
771  Type *Types[] = {ResultType};
772  Function *FnGCRelocate =
773  Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
774 
775  Value *Args[] = {Statepoint,
776  getInt32(BaseOffset),
777  getInt32(DerivedOffset)};
778  return createCallHelper(FnGCRelocate, Args, this, Name);
779 }
780 
782  Instruction *FMFSource,
783  const Twine &Name) {
784  Module *M = BB->getModule();
786  return createCallHelper(Fn, {V}, this, Name, FMFSource);
787 }
788 
790  Value *RHS,
791  Instruction *FMFSource,
792  const Twine &Name) {
793  Module *M = BB->getModule();
794  Function *Fn = Intrinsic::getDeclaration(M, ID, { LHS->getType() });
795  return createCallHelper(Fn, {LHS, RHS}, this, Name, FMFSource);
796 }
797 
799  ArrayRef<Type *> Types,
801  Instruction *FMFSource,
802  const Twine &Name) {
803  Module *M = BB->getModule();
804  Function *Fn = Intrinsic::getDeclaration(M, ID, Types);
805  return createCallHelper(Fn, Args, this, Name, FMFSource);
806 }
807 
809  Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource,
810  const Twine &Name, MDNode *FPMathTag,
813  Value *RoundingV = getConstrainedFPRounding(Rounding);
814  Value *ExceptV = getConstrainedFPExcept(Except);
815 
816  FastMathFlags UseFMF = FMF;
817  if (FMFSource)
818  UseFMF = FMFSource->getFastMathFlags();
819 
820  CallInst *C = CreateIntrinsic(ID, {L->getType()},
821  {L, R, RoundingV, ExceptV}, nullptr, Name);
823  setFPAttrs(C, FPMathTag, UseFMF);
824  return C;
825 }
826 
828  const Twine &Name, MDNode *FPMathTag) {
829  if (Instruction::isBinaryOp(Opc)) {
830  assert(Ops.size() == 2 && "Invalid number of operands!");
831  return CreateBinOp(static_cast<Instruction::BinaryOps>(Opc),
832  Ops[0], Ops[1], Name, FPMathTag);
833  }
834  if (Instruction::isUnaryOp(Opc)) {
835  assert(Ops.size() == 1 && "Invalid number of operands!");
836  return CreateUnOp(static_cast<Instruction::UnaryOps>(Opc),
837  Ops[0], Name, FPMathTag);
838  }
839  llvm_unreachable("Unexpected opcode!");
840 }
841 
843  Intrinsic::ID ID, Value *V, Type *DestTy,
844  Instruction *FMFSource, const Twine &Name, MDNode *FPMathTag,
847  Value *ExceptV = getConstrainedFPExcept(Except);
848 
849  FastMathFlags UseFMF = FMF;
850  if (FMFSource)
851  UseFMF = FMFSource->getFastMathFlags();
852 
853  CallInst *C;
854  bool HasRoundingMD = false;
855  switch (ID) {
856  default:
857  break;
858 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
859  case Intrinsic::INTRINSIC: \
860  HasRoundingMD = ROUND_MODE; \
861  break;
862 #include "llvm/IR/ConstrainedOps.def"
863  }
864  if (HasRoundingMD) {
865  Value *RoundingV = getConstrainedFPRounding(Rounding);
866  C = CreateIntrinsic(ID, {DestTy, V->getType()}, {V, RoundingV, ExceptV},
867  nullptr, Name);
868  } else
869  C = CreateIntrinsic(ID, {DestTy, V->getType()}, {V, ExceptV}, nullptr,
870  Name);
871 
873 
874  if (isa<FPMathOperator>(C))
875  setFPAttrs(C, FPMathTag, UseFMF);
876  return C;
877 }
878 
879 Value *IRBuilderBase::CreateFCmpHelper(
880  CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name,
881  MDNode *FPMathTag, bool IsSignaling) {
882  if (IsFPConstrained) {
883  auto ID = IsSignaling ? Intrinsic::experimental_constrained_fcmps
884  : Intrinsic::experimental_constrained_fcmp;
885  return CreateConstrainedFPCmp(ID, P, LHS, RHS, Name);
886  }
887 
888  if (auto *LC = dyn_cast<Constant>(LHS))
889  if (auto *RC = dyn_cast<Constant>(RHS))
890  return Insert(Folder.CreateFCmp(P, LC, RC), Name);
891  return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
892 }
893 
896  const Twine &Name, Optional<fp::ExceptionBehavior> Except) {
897  Value *PredicateV = getConstrainedFPPredicate(P);
898  Value *ExceptV = getConstrainedFPExcept(Except);
899 
900  CallInst *C = CreateIntrinsic(ID, {L->getType()},
901  {L, R, PredicateV, ExceptV}, nullptr, Name);
903  return C;
904 }
905 
907  Function *Callee, ArrayRef<Value *> Args, const Twine &Name,
911 
912  append_range(UseArgs, Args);
913  bool HasRoundingMD = false;
914  switch (Callee->getIntrinsicID()) {
915  default:
916  break;
917 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
918  case Intrinsic::INTRINSIC: \
919  HasRoundingMD = ROUND_MODE; \
920  break;
921 #include "llvm/IR/ConstrainedOps.def"
922  }
923  if (HasRoundingMD)
924  UseArgs.push_back(getConstrainedFPRounding(Rounding));
925  UseArgs.push_back(getConstrainedFPExcept(Except));
926 
927  CallInst *C = CreateCall(Callee, UseArgs, Name);
929  return C;
930 }
931 
933  const Twine &Name, Instruction *MDFrom) {
934  if (auto *CC = dyn_cast<Constant>(C))
935  if (auto *TC = dyn_cast<Constant>(True))
936  if (auto *FC = dyn_cast<Constant>(False))
937  return Insert(Folder.CreateSelect(CC, TC, FC), Name);
938 
939  SelectInst *Sel = SelectInst::Create(C, True, False);
940  if (MDFrom) {
941  MDNode *Prof = MDFrom->getMetadata(LLVMContext::MD_prof);
942  MDNode *Unpred = MDFrom->getMetadata(LLVMContext::MD_unpredictable);
943  Sel = addBranchMetadata(Sel, Prof, Unpred);
944  }
945  if (isa<FPMathOperator>(Sel))
946  setFPAttrs(Sel, nullptr /* MDNode* */, FMF);
947  return Insert(Sel, Name);
948 }
949 
951  const Twine &Name) {
952  assert(LHS->getType() == RHS->getType() &&
953  "Pointer subtraction operand types must match!");
954  auto *ArgType = cast<PointerType>(LHS->getType());
955  Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context));
956  Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context));
957  Value *Difference = CreateSub(LHS_int, RHS_int);
958  return CreateExactSDiv(Difference,
959  ConstantExpr::getSizeOf(ArgType->getElementType()),
960  Name);
961 }
962 
964  assert(isa<PointerType>(Ptr->getType()) &&
965  "launder.invariant.group only applies to pointers.");
966  // FIXME: we could potentially avoid casts to/from i8*.
967  auto *PtrType = Ptr->getType();
968  auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
969  if (PtrType != Int8PtrTy)
970  Ptr = CreateBitCast(Ptr, Int8PtrTy);
971  Module *M = BB->getParent()->getParent();
972  Function *FnLaunderInvariantGroup = Intrinsic::getDeclaration(
973  M, Intrinsic::launder_invariant_group, {Int8PtrTy});
974 
975  assert(FnLaunderInvariantGroup->getReturnType() == Int8PtrTy &&
976  FnLaunderInvariantGroup->getFunctionType()->getParamType(0) ==
977  Int8PtrTy &&
978  "LaunderInvariantGroup should take and return the same type");
979 
980  CallInst *Fn = CreateCall(FnLaunderInvariantGroup, {Ptr});
981 
982  if (PtrType != Int8PtrTy)
983  return CreateBitCast(Fn, PtrType);
984  return Fn;
985 }
986 
988  assert(isa<PointerType>(Ptr->getType()) &&
989  "strip.invariant.group only applies to pointers.");
990 
991  // FIXME: we could potentially avoid casts to/from i8*.
992  auto *PtrType = Ptr->getType();
993  auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
994  if (PtrType != Int8PtrTy)
995  Ptr = CreateBitCast(Ptr, Int8PtrTy);
996  Module *M = BB->getParent()->getParent();
997  Function *FnStripInvariantGroup = Intrinsic::getDeclaration(
998  M, Intrinsic::strip_invariant_group, {Int8PtrTy});
999 
1000  assert(FnStripInvariantGroup->getReturnType() == Int8PtrTy &&
1001  FnStripInvariantGroup->getFunctionType()->getParamType(0) ==
1002  Int8PtrTy &&
1003  "StripInvariantGroup should take and return the same type");
1004 
1005  CallInst *Fn = CreateCall(FnStripInvariantGroup, {Ptr});
1006 
1007  if (PtrType != Int8PtrTy)
1008  return CreateBitCast(Fn, PtrType);
1009  return Fn;
1010 }
1011 
1013  auto *Ty = cast<VectorType>(V->getType());
1014  if (isa<ScalableVectorType>(Ty)) {
1015  Module *M = BB->getParent()->getParent();
1017  M, Intrinsic::experimental_vector_reverse, Ty);
1018  return Insert(CallInst::Create(F, V), Name);
1019  }
1020  // Keep the original behaviour for fixed vector
1021  SmallVector<int, 8> ShuffleMask;
1022  int NumElts = Ty->getElementCount().getKnownMinValue();
1023  for (int i = 0; i < NumElts; ++i)
1024  ShuffleMask.push_back(NumElts - i - 1);
1025  return CreateShuffleVector(V, ShuffleMask, Name);
1026 }
1027 
1029  const Twine &Name) {
1030  auto EC = ElementCount::getFixed(NumElts);
1031  return CreateVectorSplat(EC, V, Name);
1032 }
1033 
1035  const Twine &Name) {
1036  assert(EC.isNonZero() && "Cannot splat to an empty vector!");
1037 
1038  // First insert it into a poison vector so we can shuffle it.
1039  Type *I32Ty = getInt32Ty();
1040  Value *Poison = PoisonValue::get(VectorType::get(V->getType(), EC));
1041  V = CreateInsertElement(Poison, V, ConstantInt::get(I32Ty, 0),
1042  Name + ".splatinsert");
1043 
1044  // Shuffle the value across the desired number of elements.
1045  SmallVector<int, 16> Zeros;
1046  Zeros.resize(EC.getKnownMinValue());
1047  return CreateShuffleVector(V, Zeros, Name + ".splat");
1048 }
1049 
1051  const DataLayout &DL, Value *From, IntegerType *ExtractedTy,
1052  uint64_t Offset, const Twine &Name) {
1053  auto *IntTy = cast<IntegerType>(From->getType());
1054  assert(DL.getTypeStoreSize(ExtractedTy) + Offset <=
1055  DL.getTypeStoreSize(IntTy) &&
1056  "Element extends past full value");
1057  uint64_t ShAmt = 8 * Offset;
1058  Value *V = From;
1059  if (DL.isBigEndian())
1060  ShAmt = 8 * (DL.getTypeStoreSize(IntTy) -
1061  DL.getTypeStoreSize(ExtractedTy) - Offset);
1062  if (ShAmt) {
1063  V = CreateLShr(V, ShAmt, Name + ".shift");
1064  }
1065  assert(ExtractedTy->getBitWidth() <= IntTy->getBitWidth() &&
1066  "Cannot extract to a larger integer!");
1067  if (ExtractedTy != IntTy) {
1068  V = CreateTrunc(V, ExtractedTy, Name + ".trunc");
1069  }
1070  return V;
1071 }
1072 
1074  Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex,
1075  MDNode *DbgInfo) {
1076  assert(isa<PointerType>(Base->getType()) &&
1077  "Invalid Base ptr type for preserve.array.access.index.");
1078  auto *BaseType = Base->getType();
1079 
1080  Value *LastIndexV = getInt32(LastIndex);
1082  SmallVector<Value *, 4> IdxList(Dimension, Zero);
1083  IdxList.push_back(LastIndexV);
1084 
1085  Type *ResultType =
1086  GetElementPtrInst::getGEPReturnType(ElTy, Base, IdxList);
1087 
1088  Module *M = BB->getParent()->getParent();
1089  Function *FnPreserveArrayAccessIndex = Intrinsic::getDeclaration(
1090  M, Intrinsic::preserve_array_access_index, {ResultType, BaseType});
1091 
1092  Value *DimV = getInt32(Dimension);
1093  CallInst *Fn =
1094  CreateCall(FnPreserveArrayAccessIndex, {Base, DimV, LastIndexV});
1095  if (DbgInfo)
1096  Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1097 
1098  return Fn;
1099 }
1100 
1102  Value *Base, unsigned FieldIndex, MDNode *DbgInfo) {
1103  assert(isa<PointerType>(Base->getType()) &&
1104  "Invalid Base ptr type for preserve.union.access.index.");
1105  auto *BaseType = Base->getType();
1106 
1107  Module *M = BB->getParent()->getParent();
1108  Function *FnPreserveUnionAccessIndex = Intrinsic::getDeclaration(
1109  M, Intrinsic::preserve_union_access_index, {BaseType, BaseType});
1110 
1111  Value *DIIndex = getInt32(FieldIndex);
1112  CallInst *Fn =
1113  CreateCall(FnPreserveUnionAccessIndex, {Base, DIIndex});
1114  if (DbgInfo)
1115  Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1116 
1117  return Fn;
1118 }
1119 
1121  Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex,
1122  MDNode *DbgInfo) {
1123  assert(isa<PointerType>(Base->getType()) &&
1124  "Invalid Base ptr type for preserve.struct.access.index.");
1125  auto *BaseType = Base->getType();
1126 
1127  Value *GEPIndex = getInt32(Index);
1129  Type *ResultType =
1130  GetElementPtrInst::getGEPReturnType(ElTy, Base, {Zero, GEPIndex});
1131 
1132  Module *M = BB->getParent()->getParent();
1133  Function *FnPreserveStructAccessIndex = Intrinsic::getDeclaration(
1134  M, Intrinsic::preserve_struct_access_index, {ResultType, BaseType});
1135 
1136  Value *DIIndex = getInt32(FieldIndex);
1137  CallInst *Fn = CreateCall(FnPreserveStructAccessIndex,
1138  {Base, GEPIndex, DIIndex});
1139  if (DbgInfo)
1140  Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1141 
1142  return Fn;
1143 }
1144 
1145 CallInst *IRBuilderBase::CreateAlignmentAssumptionHelper(const DataLayout &DL,
1146  Value *PtrValue,
1147  Value *AlignValue,
1148  Value *OffsetValue) {
1149  SmallVector<Value *, 4> Vals({PtrValue, AlignValue});
1150  if (OffsetValue)
1151  Vals.push_back(OffsetValue);
1152  OperandBundleDefT<Value *> AlignOpB("align", Vals);
1153  return CreateAssumption(ConstantInt::getTrue(getContext()), {AlignOpB});
1154 }
1155 
1157  Value *PtrValue,
1158  unsigned Alignment,
1159  Value *OffsetValue) {
1160  assert(isa<PointerType>(PtrValue->getType()) &&
1161  "trying to create an alignment assumption on a non-pointer?");
1162  assert(Alignment != 0 && "Invalid Alignment");
1163  auto *PtrTy = cast<PointerType>(PtrValue->getType());
1164  Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
1165  Value *AlignValue = ConstantInt::get(IntPtrTy, Alignment);
1166  return CreateAlignmentAssumptionHelper(DL, PtrValue, AlignValue, OffsetValue);
1167 }
1168 
1170  Value *PtrValue,
1171  Value *Alignment,
1172  Value *OffsetValue) {
1173  assert(isa<PointerType>(PtrValue->getType()) &&
1174  "trying to create an alignment assumption on a non-pointer?");
1175  return CreateAlignmentAssumptionHelper(DL, PtrValue, Alignment, OffsetValue);
1176 }
1177 
1181 void ConstantFolder::anchor() {}
1182 void NoFolder::anchor() {}
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
i
i
Definition: README.txt:29
llvm::IRBuilderBase::CreateIntMaxReduce
CallInst * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:388
llvm::IRBuilderBase::getInt32Ty
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:518
llvm::IRBuilderBase::CreateConstrainedFPCall
CallInst * CreateConstrainedFPCall(Function *Callee, ArrayRef< Value * > Args, const Twine &Name="", Optional< RoundingMode > Rounding=None, Optional< fp::ExceptionBehavior > Except=None)
Definition: IRBuilder.cpp:906
getStatepointArgs
static std::vector< Value * > getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs)
Definition: IRBuilder.cpp:597
MathExtras.h
llvm
Definition: AllocatorList.h:23
llvm::IRBuilderBase::CreateMulReduce
CallInst * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:372
llvm::Type::getInt1Ty
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:201
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::IRBuilderBase::getInt64Ty
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Definition: IRBuilder.h:523
llvm::IRBuilderFolder::CreateFCmp
virtual Value * CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const =0
NoFolder.h
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::Instruction::UnaryOps
UnaryOps
Definition: Instruction.h:761
llvm::IRBuilderBase::CreateLifetimeEnd
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
Definition: IRBuilder.cpp:424
llvm::Intrinsic::getDeclaration
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1291
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:722
llvm::IRBuilderBase::CreateGCStatepointInvoke
InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > InvokeArgs, Optional< ArrayRef< Value * >> DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
Definition: IRBuilder.cpp:722
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:107
IntrinsicInst.h
llvm::ElementCount
Definition: TypeSize.h:386
llvm::Function
Definition: Function.h:61
llvm::IRBuilderBase::CreatePtrToInt
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2056
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::IRBuilderBase::CreateVectorReverse
Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
Definition: IRBuilder.cpp:1012
llvm::IRBuilderBase::CreateGlobalString
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0, Module *M=nullptr)
Make a new global variable with initializer type i8*.
Definition: IRBuilder.cpp:43
llvm::Type::getScalarType
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.h:317
llvm::GlobalValue::NotThreadLocal
@ NotThreadLocal
Definition: GlobalValue.h:179
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::IRBuilderBase::CreateConstrainedFPCast
CallInst * CreateConstrainedFPCast(Intrinsic::ID ID, Value *V, Type *DestTy, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, Optional< RoundingMode > Rounding=None, Optional< fp::ExceptionBehavior > Except=None)
Definition: IRBuilder.cpp:842
llvm::GlobalVariable
Definition: GlobalVariable.h:40
R600_InstFlag::FC
@ FC
Definition: R600Defines.h:32
llvm::IRBuilderBase::CreateUnaryIntrinsic
CallInst * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
Definition: IRBuilder.cpp:781
llvm::IRBuilderBase::CreateAssumption
CallInst * CreateAssumption(Value *Cond, ArrayRef< OperandBundleDef > OpBundles=llvm::None)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
Definition: IRBuilder.cpp:461
llvm::IRBuilderBase::setConstrainedFPCallAttr
void setConstrainedFPCallAttr(CallBase *I)
Definition: IRBuilder.h:353
llvm::IRBuilderBase::CreateMaskedLoad
CallInst * CreateMaskedLoad(Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
Definition: IRBuilder.cpp:487
llvm::IRBuilderBase::CreateStripInvariantGroup
Value * CreateStripInvariantGroup(Value *Ptr)
Create a strip.invariant.group intrinsic call.
Definition: IRBuilder.cpp:987
llvm::IRBuilderBase::CreatePreserveUnionAccessIndex
Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
Definition: IRBuilder.cpp:1101
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::IRBuilderBase::CreateShuffleVector
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition: IRBuilder.h:2418
llvm::OperandBundleDefT
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition: InstrTypes.h:1117
llvm::IRBuilderBase::FMF
FastMathFlags FMF
Definition: IRBuilder.h:127
CreateGCStatepointCallCommon
static CallInst * CreateGCStatepointCallCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, Optional< ArrayRef< T1 >> TransitionArgs, Optional< ArrayRef< T2 >> DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Definition: IRBuilder.cpp:639
llvm::GlobalValue::UnnamedAddr::Global
@ Global
llvm::IRBuilderBase::Folder
const IRBuilderFolder & Folder
Definition: IRBuilder.h:123
llvm::IRBuilderBase::CreateBinaryIntrinsic
CallInst * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type.
Definition: IRBuilder.cpp:789
llvm::Optional
Definition: APInt.h:33
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
Operator.h
llvm::IRBuilderBase::CreateNAryOp
Value * CreateNAryOp(unsigned Opc, ArrayRef< Value * > Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
Definition: IRBuilder.cpp:827
llvm::GetElementPtrInst::getGEPReturnType
static Type * getGEPReturnType(Type *ElTy, Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
Definition: Instructions.h:1073
llvm::FastMathFlags
Convenience struct for specifying and reasoning about fast-math flags.
Definition: Operator.h:160
BaseType
llvm::IRBuilderBase::CreatePtrDiff
Value * CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name="")
Return the i64 difference between two pointer values, dividing out the size of the pointed-to objects...
Definition: IRBuilder.cpp:950
llvm::CallBase::addParamAttr
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1507
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::Data
@ Data
Definition: SIMachineScheduler.h:56
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:204
llvm::IRBuilderBase::getInt1
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Definition: IRBuilder.h:453
llvm::IRBuilderBase::CreateInvariantStart
CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
Definition: IRBuilder.cpp:440
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::Instruction::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1330
llvm::IRBuilderBase::CreateBinOp
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1530
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::IRBuilderBase::CreateElementUnorderedAtomicMemMove
CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memmove between the specified pointers.
Definition: IRBuilder.cpp:303
llvm::IRBuilderBase::CreateConstrainedFPBinOp
CallInst * CreateConstrainedFPBinOp(Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, Optional< RoundingMode > Rounding=None, Optional< fp::ExceptionBehavior > Except=None)
Definition: IRBuilder.cpp:808
llvm::IRBuilderBase::CreateElementUnorderedAtomicMemSet
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
Definition: IRBuilder.h:599
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:77
llvm::IRBuilderBase::CreateMul
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1224
llvm::SelectInst::Create
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
Definition: Instructions.h:1746
GlobalValue.h
createCallHelper
static CallInst * createCallHelper(Function *Callee, ArrayRef< Value * > Ops, IRBuilderBase *Builder, const Twine &Name="", Instruction *FMFSource=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition: IRBuilder.cpp:72
llvm::IRBuilderBase::CreateElementUnorderedAtomicMemCpy
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memcpy between the specified pointers.
Definition: IRBuilder.cpp:228
Constants.h
llvm::IRBuilderDefaultInserter::~IRBuilderDefaultInserter
virtual ~IRBuilderDefaultInserter()
Definition: IRBuilder.cpp:1178
llvm::IRBuilderBase::CreateMemTransferInst
CallInst * CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.cpp:167
llvm::IRBuilderBase::CreateMemSet
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
Definition: IRBuilder.h:580
Intrinsics.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::IRBuilderBase::CreateExactSDiv
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1265
llvm::FCmpInst
This instruction compares its operands according to the predicate given to the constructor.
Definition: Instructions.h:1344
llvm::CallInst::Create
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Definition: Instructions.h:1493
llvm::IRBuilderBase::CreateUnOp
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1601
llvm::Type::isVectorTy
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:235
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:119
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::IntegerType
Class to represent integer types.
Definition: DerivedTypes.h:40
llvm::Constant::getAllOnesValue
static Constant * getAllOnesValue(Type *Ty)
Definition: Constants.cpp:405
llvm::IRBuilderBase::CreatePreserveStructAccessIndex
Value * CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex, MDNode *DbgInfo)
Definition: IRBuilder.cpp:1120
llvm::Instruction
Definition: Instruction.h:45
llvm::IRBuilderBase::CreateXorReduce
CallInst * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:384
llvm::IRBuilderBase::getContext
LLVMContext & getContext() const
Definition: IRBuilder.h:180
llvm::IRBuilderBase::CreateInsertElement
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2404
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition: SmallVector.h:606
llvm::UndefValue::get
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1770
llvm::ConstantInt::get
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:885
llvm::BasicBlock::getModule
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Definition: BasicBlock.cpp:144
llvm::IRBuilderBase::CreateVScale
Value * CreateVScale(Constant *Scaling, const Twine &Name="")
Create a call to llvm.vscale, multiplied by Scaling.
Definition: IRBuilder.cpp:83
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::IRBuilderBase::CreateFPMaxReduce
CallInst * CreateFPMaxReduce(Value *Src)
Create a vector float max reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:400
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::None
const NoneType None
Definition: None.h:23
llvm::LinearPolySize< ElementCount >::getFixed
static ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:284
Statepoint.h
Type.h
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:277
llvm::IRBuilderBase::CreateLifetimeStart
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.start intrinsic.
Definition: IRBuilder.cpp:408
llvm::IRBuilderBase::CreateLaunderInvariantGroup
Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
Definition: IRBuilder.cpp:963
llvm::InvokeInst
Invoke instruction.
Definition: Instructions.h:3686
llvm::IRBuilderBase::CreateBitCast
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2066
BaseType
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
Definition: SafepointIRVerifier.cpp:316
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Function::getReturnType
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.h:170
llvm::IRBuilderBase::getIntPtrTy
IntegerType * getIntPtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type representing a pointer to an integer value.
Definition: IRBuilder.h:566
llvm::StatepointFlags::None
@ None
llvm::IRBuilderBase::CreatePreserveArrayAccessIndex
Value * CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex, MDNode *DbgInfo)
Definition: IRBuilder.cpp:1073
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
getReductionIntrinsic
static CallInst * getReductionIntrinsic(IRBuilderBase *Builder, Intrinsic::ID ID, Value *Src)
Definition: IRBuilder.cpp:343
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:572
llvm::IRBuilderBase::getInt32
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:478
llvm::FunctionType::getParamType
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:134
llvm::IRBuilderBase::getInt8PtrTy
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Definition: IRBuilder.h:561
llvm::IRBuilderBase::Context
LLVMContext & Context
Definition: IRBuilder.h:122
llvm::IRBuilderBase::CreateSelect
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition: IRBuilder.cpp:932
llvm::IRBuilderBase::CreateFPMinReduce
CallInst * CreateFPMinReduce(Value *Src)
Create a vector float min reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:404
llvm::IRBuilderBase::CreateIntMinReduce
CallInst * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:394
ArrayRef.h
llvm::IRBuilderBase::CreateConstrainedFPCmp
CallInst * CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name="", Optional< fp::ExceptionBehavior > Except=None)
Definition: IRBuilder.cpp:894
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::IRBuilderBase::CreateFMulReduce
CallInst * CreateFMulReduce(Value *Acc, Value *Src)
Create a vector fmul reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:360
llvm::IRBuilderBase::CreateGCResult
CallInst * CreateGCResult(Instruction *Statepoint, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.result intrinsic to extract the result from a call wrapped in a ...
Definition: IRBuilder.cpp:753
llvm::SelectInst
This class represents the LLVM 'select' instruction.
Definition: Instructions.h:1715
llvm::Instruction::isBinaryOp
bool isBinaryOp() const
Definition: Instruction.h:165
llvm::IRBuilderBase::CreateIntrinsic
CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with args, mangled using Types.
Definition: IRBuilder.cpp:798
llvm::IRBuilderBase::CreateAndReduce
CallInst * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:376
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:897
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:649
llvm::ConstantExpr::getSizeOf
static Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
Definition: Constants.cpp:2331
llvm::IRBuilderBase::CreateNoAliasScopeDeclaration
Instruction * CreateNoAliasScopeDeclaration(Value *Scope)
Create a llvm.experimental.noalias.scope.decl intrinsic call.
Definition: IRBuilder.cpp:472
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::Instruction::getFastMathFlags
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Definition: Instruction.cpp:259
llvm::IRBuilderBase::IsFPConstrained
bool IsFPConstrained
Definition: IRBuilder.h:129
None.h
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:167
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
uint32_t
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1690
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:937
llvm::IRBuilderBase
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:95
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::ConstantDataArray::getString
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
Definition: Constants.cpp:3040
llvm::Instruction::copyFastMathFlags
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
Definition: Instruction.cpp:214
llvm::ConstantVector::get
static Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:1354
llvm::IRBuilderBase::CreateMaskedScatter
CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
Definition: IRBuilder.cpp:570
llvm::AMDGPU::HSAMD::Kernel::Arg::Key::IsVolatile
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
Definition: AMDGPUMetadata.h:194
llvm::IRBuilderBase::BB
BasicBlock * BB
Definition: IRBuilder.h:120
llvm::IRBuilderBase::CreateTrunc
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1970
llvm::IRBuilderBase::CreateAddReduce
CallInst * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:368
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:205
llvm::Attribute::getWithAlignment
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:160
Constant.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::Type::getInt64Ty
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:205
llvm::ConstantInt::getTrue
static ConstantInt * getTrue(LLVMContext &Context)
Definition: Constants.cpp:833
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::IRBuilderBase::Insert
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Definition: IRBuilder.h:149
llvm::IRBuilderBase::CreateMaskedGather
CallInst * CreateMaskedGather(Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
Definition: IRBuilder.cpp:539
GlobalVariable.h
llvm::IRBuilderBase::getInt64
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition: IRBuilder.h:483
llvm::IRBuilderBase::GetInsertBlock
BasicBlock * GetInsertBlock() const
Definition: IRBuilder.h:178
Casting.h
Function.h
llvm::IRBuilderFolder::~IRBuilderFolder
virtual ~IRBuilderFolder()
Definition: IRBuilder.cpp:1180
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:165
llvm::IRBuilderBase::CreateFAddReduce
CallInst * CreateFAddReduce(Value *Acc, Value *Src)
Create a vector fadd reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:352
llvm::IRBuilderBase::CreateExtractInteger
Value * CreateExtractInteger(const DataLayout &DL, Value *From, IntegerType *ExtractedTy, uint64_t Offset, const Twine &Name)
Return a value that has been extracted from a larger integer type.
Definition: IRBuilder.cpp:1050
llvm::Instruction::BinaryOps
BinaryOps
Definition: Instruction.h:768
llvm::IRBuilderFolder::CreateSelect
virtual Value * CreateSelect(Constant *C, Constant *True, Constant *False) const =0
llvm::IRBuilderBase::getInt1Ty
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Definition: IRBuilder.h:503
CreateGCStatepointInvokeCommon
static InvokeInst * CreateGCStatepointInvokeCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef< T0 > InvokeArgs, Optional< ArrayRef< T1 >> TransitionArgs, Optional< ArrayRef< T2 >> DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Definition: IRBuilder.cpp:696
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:56
llvm::IRBuilderBase::CreateMemMove
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:667
llvm::IRBuilderBase::CreateMemCpyInline
CallInst * CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size)
Definition: IRBuilder.cpp:204
llvm::IRBuilderBase::CreateLShr
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1300
llvm::IRBuilderBase::CreateMaskedStore
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Definition: IRBuilder.cpp:508
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:163
llvm::IntegerType::getBitWidth
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:71
llvm::IRBuilderCallbackInserter::~IRBuilderCallbackInserter
virtual ~IRBuilderCallbackInserter()
Definition: IRBuilder.cpp:1179
llvm::Instruction::isUnaryOp
bool isUnaryOp() const
Definition: Instruction.h:164
llvm::IRBuilderBase::CreateGCRelocate
CallInst * CreateGCRelocate(Instruction *Statepoint, int BaseOffset, int DerivedOffset, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.relocate intrinsics to project the relocated value of one pointe...
Definition: IRBuilder.cpp:765
getStatepointBundles
static std::vector< OperandBundleDef > getStatepointBundles(Optional< ArrayRef< T1 >> TransitionArgs, Optional< ArrayRef< T2 >> DeoptArgs, ArrayRef< T3 > GCArgs)
Definition: IRBuilder.cpp:616
llvm::IRBuilderBase::CreateVectorSplat
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Definition: IRBuilder.cpp:1028
llvm::IRBuilderBase::CreateStepVector
Value * CreateStepVector(Type *DstType, const Twine &Name="")
Creates a vector of type DstType with the linear sequence <0, 1, ...>
Definition: IRBuilder.cpp:94
DerivedTypes.h
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1450
LLVMContext.h
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::IRBuilderBase::CreateSub
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1207
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:221
llvm::IRBuilderBase::getCurrentFunctionReturnType
Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
Definition: IRBuilder.cpp:58
llvm::IRBuilderBase::CreateAlignmentAssumption
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, unsigned Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer.
Definition: IRBuilder.cpp:1156
Value.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::IRBuilderBase::CreateGCStatepointCall
CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, ArrayRef< Value * > CallArgs, Optional< ArrayRef< Value * >> DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
Definition: IRBuilder.cpp:667
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:634
llvm::IRBuilderBase::CreateOrReduce
CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:380
llvm::IRBuilderBase::CreateCall
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2344
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::AArch64::Rounding
Rounding
Possible values of current rounding mode, which is specified in bits 23:22 of FPCR.
Definition: AArch64ISelLowering.h:464
llvm::PoisonValue::get
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1789