LLVM  7.0.0svn
IRBuilder.h
Go to the documentation of this file.
1 //===---- llvm/IRBuilder.h - Builder for LLVM Instructions ------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the IRBuilder class, which is used as a convenient way
11 // to create LLVM instructions with a consistent and simplified interface.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_IRBUILDER_H
16 #define LLVM_IR_IRBUILDER_H
17 
18 #include "llvm-c/Types.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/None.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/Twine.h"
23 #include "llvm/IR/BasicBlock.h"
24 #include "llvm/IR/Constant.h"
25 #include "llvm/IR/ConstantFolder.h"
26 #include "llvm/IR/Constants.h"
27 #include "llvm/IR/DataLayout.h"
28 #include "llvm/IR/DebugLoc.h"
29 #include "llvm/IR/DerivedTypes.h"
30 #include "llvm/IR/Function.h"
31 #include "llvm/IR/GlobalVariable.h"
32 #include "llvm/IR/InstrTypes.h"
33 #include "llvm/IR/Instruction.h"
34 #include "llvm/IR/Instructions.h"
35 #include "llvm/IR/Intrinsics.h"
36 #include "llvm/IR/LLVMContext.h"
37 #include "llvm/IR/Module.h"
38 #include "llvm/IR/Operator.h"
39 #include "llvm/IR/Type.h"
40 #include "llvm/IR/Value.h"
41 #include "llvm/IR/ValueHandle.h"
44 #include "llvm/Support/Casting.h"
45 #include <algorithm>
46 #include <cassert>
47 #include <cstddef>
48 #include <cstdint>
49 #include <functional>
50 
51 namespace llvm {
52 
53 class APInt;
54 class MDNode;
55 class Module;
56 class Use;
57 
58 /// \brief This provides the default implementation of the IRBuilder
59 /// 'InsertHelper' method that is called whenever an instruction is created by
60 /// IRBuilder and needs to be inserted.
61 ///
62 /// By default, this inserts the instruction at the insertion point.
64 protected:
66  BasicBlock *BB, BasicBlock::iterator InsertPt) const {
67  if (BB) BB->getInstList().insert(InsertPt, I);
68  I->setName(Name);
69  }
70 };
71 
72 /// Provides an 'InsertHelper' that calls a user-provided callback after
73 /// performing the default insertion.
75  std::function<void(Instruction *)> Callback;
76 
77 public:
79  : Callback(std::move(Callback)) {}
80 
81 protected:
83  BasicBlock *BB, BasicBlock::iterator InsertPt) const {
84  IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt);
85  Callback(I);
86  }
87 };
88 
89 /// \brief Common base class shared among various IRBuilders.
91  DebugLoc CurDbgLocation;
92 
93 protected:
97 
100 
102 
103 public:
104  IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr,
105  ArrayRef<OperandBundleDef> OpBundles = None)
106  : Context(context), DefaultFPMathTag(FPMathTag),
107  DefaultOperandBundles(OpBundles) {
108  ClearInsertionPoint();
109  }
110 
111  //===--------------------------------------------------------------------===//
112  // Builder configuration methods
113  //===--------------------------------------------------------------------===//
114 
115  /// \brief Clear the insertion point: created instructions will not be
116  /// inserted into a block.
118  BB = nullptr;
119  InsertPt = BasicBlock::iterator();
120  }
121 
122  BasicBlock *GetInsertBlock() const { return BB; }
123  BasicBlock::iterator GetInsertPoint() const { return InsertPt; }
124  LLVMContext &getContext() const { return Context; }
125 
126  /// \brief This specifies that created instructions should be appended to the
127  /// end of the specified block.
128  void SetInsertPoint(BasicBlock *TheBB) {
129  BB = TheBB;
130  InsertPt = BB->end();
131  }
132 
133  /// \brief This specifies that created instructions should be inserted before
134  /// the specified instruction.
136  BB = I->getParent();
137  InsertPt = I->getIterator();
138  assert(InsertPt != BB->end() && "Can't read debug loc from end()");
139  SetCurrentDebugLocation(I->getDebugLoc());
140  }
141 
142  /// \brief This specifies that created instructions should be inserted at the
143  /// specified point.
145  BB = TheBB;
146  InsertPt = IP;
147  if (IP != TheBB->end())
148  SetCurrentDebugLocation(IP->getDebugLoc());
149  }
150 
151  /// \brief Set location information used by debugging information.
152  void SetCurrentDebugLocation(DebugLoc L) { CurDbgLocation = std::move(L); }
153 
154  /// \brief Get location information used by debugging information.
155  const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; }
156 
157  /// \brief If this builder has a current debug location, set it on the
158  /// specified instruction.
160  if (CurDbgLocation)
161  I->setDebugLoc(CurDbgLocation);
162  }
163 
164  /// \brief Get the return type of the current function that we're emitting
165  /// into.
166  Type *getCurrentFunctionReturnType() const;
167 
168  /// InsertPoint - A saved insertion point.
169  class InsertPoint {
170  BasicBlock *Block = nullptr;
171  BasicBlock::iterator Point;
172 
173  public:
174  /// \brief Creates a new insertion point which doesn't point to anything.
175  InsertPoint() = default;
176 
177  /// \brief Creates a new insertion point at the given location.
179  : Block(InsertBlock), Point(InsertPoint) {}
180 
181  /// \brief Returns true if this insert point is set.
182  bool isSet() const { return (Block != nullptr); }
183 
184  BasicBlock *getBlock() const { return Block; }
185  BasicBlock::iterator getPoint() const { return Point; }
186  };
187 
188  /// \brief Returns the current insert point.
189  InsertPoint saveIP() const {
190  return InsertPoint(GetInsertBlock(), GetInsertPoint());
191  }
192 
193  /// \brief Returns the current insert point, clearing it in the process.
195  InsertPoint IP(GetInsertBlock(), GetInsertPoint());
196  ClearInsertionPoint();
197  return IP;
198  }
199 
200  /// \brief Sets the current insert point to a previously-saved location.
202  if (IP.isSet())
203  SetInsertPoint(IP.getBlock(), IP.getPoint());
204  else
205  ClearInsertionPoint();
206  }
207 
208  /// \brief Get the floating point math metadata being used.
209  MDNode *getDefaultFPMathTag() const { return DefaultFPMathTag; }
210 
211  /// \brief Get the flags to be applied to created floating point ops
212  FastMathFlags getFastMathFlags() const { return FMF; }
213 
214  /// \brief Clear the fast-math flags.
215  void clearFastMathFlags() { FMF.clear(); }
216 
217  /// \brief Set the floating point math metadata to be used.
218  void setDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; }
219 
220  /// \brief Set the fast-math flags to be used with generated fp-math operators
221  void setFastMathFlags(FastMathFlags NewFMF) { FMF = NewFMF; }
222 
223  //===--------------------------------------------------------------------===//
224  // RAII helpers.
225  //===--------------------------------------------------------------------===//
226 
227  // \brief RAII object that stores the current insertion point and restores it
228  // when the object is destroyed. This includes the debug location.
230  IRBuilderBase &Builder;
232  BasicBlock::iterator Point;
233  DebugLoc DbgLoc;
234 
235  public:
237  : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
238  DbgLoc(B.getCurrentDebugLocation()) {}
239 
240  InsertPointGuard(const InsertPointGuard &) = delete;
241  InsertPointGuard &operator=(const InsertPointGuard &) = delete;
242 
244  Builder.restoreIP(InsertPoint(Block, Point));
245  Builder.SetCurrentDebugLocation(DbgLoc);
246  }
247  };
248 
249  // \brief RAII object that stores the current fast math settings and restores
250  // them when the object is destroyed.
252  IRBuilderBase &Builder;
253  FastMathFlags FMF;
254  MDNode *FPMathTag;
255 
256  public:
258  : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
259 
260  FastMathFlagGuard(const FastMathFlagGuard &) = delete;
261  FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
262 
264  Builder.FMF = FMF;
265  Builder.DefaultFPMathTag = FPMathTag;
266  }
267  };
268 
269  //===--------------------------------------------------------------------===//
270  // Miscellaneous creation methods.
271  //===--------------------------------------------------------------------===//
272 
273  /// \brief Make a new global variable with initializer type i8*
274  ///
275  /// Make a new global variable with an initializer that has array of i8 type
276  /// filled in with the null terminated string value specified. The new global
277  /// variable will be marked mergable with any others of the same contents. If
278  /// Name is specified, it is the name of the global variable created.
279  GlobalVariable *CreateGlobalString(StringRef Str, const Twine &Name = "",
280  unsigned AddressSpace = 0);
281 
282  /// \brief Get a constant value representing either true or false.
283  ConstantInt *getInt1(bool V) {
284  return ConstantInt::get(getInt1Ty(), V);
285  }
286 
287  /// \brief Get the constant value for i1 true.
289  return ConstantInt::getTrue(Context);
290  }
291 
292  /// \brief Get the constant value for i1 false.
294  return ConstantInt::getFalse(Context);
295  }
296 
297  /// \brief Get a constant 8-bit value.
298  ConstantInt *getInt8(uint8_t C) {
299  return ConstantInt::get(getInt8Ty(), C);
300  }
301 
302  /// \brief Get a constant 16-bit value.
303  ConstantInt *getInt16(uint16_t C) {
304  return ConstantInt::get(getInt16Ty(), C);
305  }
306 
307  /// \brief Get a constant 32-bit value.
309  return ConstantInt::get(getInt32Ty(), C);
310  }
311 
312  /// \brief Get a constant 64-bit value.
313  ConstantInt *getInt64(uint64_t C) {
314  return ConstantInt::get(getInt64Ty(), C);
315  }
316 
317  /// \brief Get a constant N-bit value, zero extended or truncated from
318  /// a 64-bit value.
319  ConstantInt *getIntN(unsigned N, uint64_t C) {
320  return ConstantInt::get(getIntNTy(N), C);
321  }
322 
323  /// \brief Get a constant integer value.
324  ConstantInt *getInt(const APInt &AI) {
325  return ConstantInt::get(Context, AI);
326  }
327 
328  //===--------------------------------------------------------------------===//
329  // Type creation methods
330  //===--------------------------------------------------------------------===//
331 
332  /// \brief Fetch the type representing a single bit
334  return Type::getInt1Ty(Context);
335  }
336 
337  /// \brief Fetch the type representing an 8-bit integer.
339  return Type::getInt8Ty(Context);
340  }
341 
342  /// \brief Fetch the type representing a 16-bit integer.
344  return Type::getInt16Ty(Context);
345  }
346 
347  /// \brief Fetch the type representing a 32-bit integer.
349  return Type::getInt32Ty(Context);
350  }
351 
352  /// \brief Fetch the type representing a 64-bit integer.
354  return Type::getInt64Ty(Context);
355  }
356 
357  /// \brief Fetch the type representing a 128-bit integer.
358  IntegerType *getInt128Ty() { return Type::getInt128Ty(Context); }
359 
360  /// \brief Fetch the type representing an N-bit integer.
361  IntegerType *getIntNTy(unsigned N) {
362  return Type::getIntNTy(Context, N);
363  }
364 
365  /// \brief Fetch the type representing a 16-bit floating point value.
367  return Type::getHalfTy(Context);
368  }
369 
370  /// \brief Fetch the type representing a 32-bit floating point value.
372  return Type::getFloatTy(Context);
373  }
374 
375  /// \brief Fetch the type representing a 64-bit floating point value.
377  return Type::getDoubleTy(Context);
378  }
379 
380  /// \brief Fetch the type representing void.
382  return Type::getVoidTy(Context);
383  }
384 
385  /// \brief Fetch the type representing a pointer to an 8-bit integer value.
386  PointerType *getInt8PtrTy(unsigned AddrSpace = 0) {
387  return Type::getInt8PtrTy(Context, AddrSpace);
388  }
389 
390  /// \brief Fetch the type representing a pointer to an integer value.
391  IntegerType *getIntPtrTy(const DataLayout &DL, unsigned AddrSpace = 0) {
392  return DL.getIntPtrType(Context, AddrSpace);
393  }
394 
395  //===--------------------------------------------------------------------===//
396  // Intrinsic creation methods
397  //===--------------------------------------------------------------------===//
398 
399  /// \brief Create and insert a memset to the specified pointer and the
400  /// specified value.
401  ///
402  /// If the pointer isn't an i8*, it will be converted. If a TBAA tag is
403  /// specified, it will be added to the instruction. Likewise with alias.scope
404  /// and noalias tags.
405  CallInst *CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align,
406  bool isVolatile = false, MDNode *TBAATag = nullptr,
407  MDNode *ScopeTag = nullptr,
408  MDNode *NoAliasTag = nullptr) {
409  return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile,
410  TBAATag, ScopeTag, NoAliasTag);
411  }
412 
413  CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
414  bool isVolatile = false, MDNode *TBAATag = nullptr,
415  MDNode *ScopeTag = nullptr,
416  MDNode *NoAliasTag = nullptr);
417 
418  /// \brief Create and insert a memcpy between the specified pointers.
419  ///
420  /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
421  /// specified, it will be added to the instruction. Likewise with alias.scope
422  /// and noalias tags.
423  CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
424  unsigned SrcAlign, uint64_t Size,
425  bool isVolatile = false, MDNode *TBAATag = nullptr,
426  MDNode *TBAAStructTag = nullptr,
427  MDNode *ScopeTag = nullptr,
428  MDNode *NoAliasTag = nullptr) {
429  return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
430  isVolatile, TBAATag, TBAAStructTag, ScopeTag,
431  NoAliasTag);
432  }
433 
434  CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
435  unsigned SrcAlign, Value *Size,
436  bool isVolatile = false, MDNode *TBAATag = nullptr,
437  MDNode *TBAAStructTag = nullptr,
438  MDNode *ScopeTag = nullptr,
439  MDNode *NoAliasTag = nullptr);
440 
441  // TODO: Old API. Remove this when no longer used.
442  CallInst *CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align,
443  bool isVolatile = false, MDNode *TBAATag = nullptr,
444  MDNode *TBAAStructTag = nullptr,
445  MDNode *ScopeTag = nullptr,
446  MDNode *NoAliasTag = nullptr) {
447  return CreateMemCpy(Dst, Align, Src, Align, getInt64(Size), isVolatile, TBAATag,
448  TBAAStructTag, ScopeTag, NoAliasTag);
449  }
450  // TODO: Old API. Remove this when no longer used.
451  CallInst *CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
452  bool isVolatile = false, MDNode *TBAATag = nullptr,
453  MDNode *TBAAStructTag = nullptr,
454  MDNode *ScopeTag = nullptr,
455  MDNode *NoAliasTag = nullptr) {
456  return CreateMemCpy(Dst, Align, Src, Align, Size, isVolatile, TBAATag,
457  TBAAStructTag, ScopeTag, NoAliasTag);
458  }
459 
460  /// \brief Create and insert an element unordered-atomic memcpy between the
461  /// specified pointers.
462  ///
463  /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers, respectively.
464  ///
465  /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
466  /// specified, it will be added to the instruction. Likewise with alias.scope
467  /// and noalias tags.
469  Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
470  uint64_t Size, uint32_t ElementSize, MDNode *TBAATag = nullptr,
471  MDNode *TBAAStructTag = nullptr, MDNode *ScopeTag = nullptr,
472  MDNode *NoAliasTag = nullptr) {
473  return CreateElementUnorderedAtomicMemCpy(
474  Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
475  TBAAStructTag, ScopeTag, NoAliasTag);
476  }
477 
478  CallInst *CreateElementUnorderedAtomicMemCpy(
479  Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, Value *Size,
480  uint32_t ElementSize, MDNode *TBAATag = nullptr,
481  MDNode *TBAAStructTag = nullptr, MDNode *ScopeTag = nullptr,
482  MDNode *NoAliasTag = nullptr);
483 
484  /// \brief Create and insert a memmove between the specified
485  /// pointers.
486  ///
487  /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
488  /// specified, it will be added to the instruction. Likewise with alias.scope
489  /// and noalias tags.
490  CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
491  uint64_t Size, bool isVolatile = false,
492  MDNode *TBAATag = nullptr, MDNode *ScopeTag = nullptr,
493  MDNode *NoAliasTag = nullptr) {
494  return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size), isVolatile,
495  TBAATag, ScopeTag, NoAliasTag);
496  }
497 
498  CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
499  Value *Size, bool isVolatile = false, MDNode *TBAATag = nullptr,
500  MDNode *ScopeTag = nullptr,
501  MDNode *NoAliasTag = nullptr);
502 
503  // TODO: Old API. Remove this when no longer used.
504  CallInst *CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align,
505  bool isVolatile = false, MDNode *TBAATag = nullptr,
506  MDNode *ScopeTag = nullptr,
507  MDNode *NoAliasTag = nullptr) {
508  return CreateMemMove(Dst, Align, Src, Align, getInt64(Size), isVolatile,
509  TBAATag, ScopeTag, NoAliasTag);
510  }
511  // TODO: Old API. Remove this when no longer used.
512  CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
513  bool isVolatile = false, MDNode *TBAATag = nullptr,
514  MDNode *ScopeTag = nullptr,
515  MDNode *NoAliasTag = nullptr) {
516  return CreateMemMove(Dst, Align, Src, Align, Size, isVolatile, TBAATag,
517  ScopeTag, NoAliasTag);
518  }
519 
520  /// \brief Create a vector fadd reduction intrinsic of the source vector.
521  /// The first parameter is a scalar accumulator value for ordered reductions.
522  CallInst *CreateFAddReduce(Value *Acc, Value *Src);
523 
524  /// \brief Create a vector fmul reduction intrinsic of the source vector.
525  /// The first parameter is a scalar accumulator value for ordered reductions.
526  CallInst *CreateFMulReduce(Value *Acc, Value *Src);
527 
528  /// \brief Create a vector int add reduction intrinsic of the source vector.
529  CallInst *CreateAddReduce(Value *Src);
530 
531  /// \brief Create a vector int mul reduction intrinsic of the source vector.
532  CallInst *CreateMulReduce(Value *Src);
533 
534  /// \brief Create a vector int AND reduction intrinsic of the source vector.
535  CallInst *CreateAndReduce(Value *Src);
536 
537  /// \brief Create a vector int OR reduction intrinsic of the source vector.
538  CallInst *CreateOrReduce(Value *Src);
539 
540  /// \brief Create a vector int XOR reduction intrinsic of the source vector.
541  CallInst *CreateXorReduce(Value *Src);
542 
543  /// \brief Create a vector integer max reduction intrinsic of the source
544  /// vector.
545  CallInst *CreateIntMaxReduce(Value *Src, bool IsSigned = false);
546 
547  /// \brief Create a vector integer min reduction intrinsic of the source
548  /// vector.
549  CallInst *CreateIntMinReduce(Value *Src, bool IsSigned = false);
550 
551  /// \brief Create a vector float max reduction intrinsic of the source
552  /// vector.
553  CallInst *CreateFPMaxReduce(Value *Src, bool NoNaN = false);
554 
555  /// \brief Create a vector float min reduction intrinsic of the source
556  /// vector.
557  CallInst *CreateFPMinReduce(Value *Src, bool NoNaN = false);
558 
559  /// \brief Create a lifetime.start intrinsic.
560  ///
561  /// If the pointer isn't i8* it will be converted.
562  CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = nullptr);
563 
564  /// \brief Create a lifetime.end intrinsic.
565  ///
566  /// If the pointer isn't i8* it will be converted.
567  CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = nullptr);
568 
569  /// Create a call to invariant.start intrinsic.
570  ///
571  /// If the pointer isn't i8* it will be converted.
572  CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nullptr);
573 
574  /// \brief Create a call to Masked Load intrinsic
575  CallInst *CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask,
576  Value *PassThru = nullptr, const Twine &Name = "");
577 
578  /// \brief Create a call to Masked Store intrinsic
579  CallInst *CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align,
580  Value *Mask);
581 
582  /// \brief Create a call to Masked Gather intrinsic
583  CallInst *CreateMaskedGather(Value *Ptrs, unsigned Align,
584  Value *Mask = nullptr,
585  Value *PassThru = nullptr,
586  const Twine& Name = "");
587 
588  /// \brief Create a call to Masked Scatter intrinsic
589  CallInst *CreateMaskedScatter(Value *Val, Value *Ptrs, unsigned Align,
590  Value *Mask = nullptr);
591 
592  /// \brief Create an assume intrinsic call that allows the optimizer to
593  /// assume that the provided condition will be true.
594  CallInst *CreateAssumption(Value *Cond);
595 
596  /// \brief Create a call to the experimental.gc.statepoint intrinsic to
597  /// start a new statepoint sequence.
598  CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
599  Value *ActualCallee,
600  ArrayRef<Value *> CallArgs,
601  ArrayRef<Value *> DeoptArgs,
602  ArrayRef<Value *> GCArgs,
603  const Twine &Name = "");
604 
605  /// \brief Create a call to the experimental.gc.statepoint intrinsic to
606  /// start a new statepoint sequence.
607  CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
608  Value *ActualCallee, uint32_t Flags,
609  ArrayRef<Use> CallArgs,
610  ArrayRef<Use> TransitionArgs,
611  ArrayRef<Use> DeoptArgs,
612  ArrayRef<Value *> GCArgs,
613  const Twine &Name = "");
614 
615  // \brief Conveninence function for the common case when CallArgs are filled
616  // in using makeArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be
617  // .get()'ed to get the Value pointer.
618  CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
619  Value *ActualCallee, ArrayRef<Use> CallArgs,
620  ArrayRef<Value *> DeoptArgs,
621  ArrayRef<Value *> GCArgs,
622  const Twine &Name = "");
623 
624  /// brief Create an invoke to the experimental.gc.statepoint intrinsic to
625  /// start a new statepoint sequence.
626  InvokeInst *
627  CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes,
628  Value *ActualInvokee, BasicBlock *NormalDest,
629  BasicBlock *UnwindDest, ArrayRef<Value *> InvokeArgs,
630  ArrayRef<Value *> DeoptArgs,
631  ArrayRef<Value *> GCArgs, const Twine &Name = "");
632 
633  /// brief Create an invoke to the experimental.gc.statepoint intrinsic to
634  /// start a new statepoint sequence.
635  InvokeInst *CreateGCStatepointInvoke(
636  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
637  BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
638  ArrayRef<Use> InvokeArgs, ArrayRef<Use> TransitionArgs,
639  ArrayRef<Use> DeoptArgs, ArrayRef<Value *> GCArgs,
640  const Twine &Name = "");
641 
642  // Conveninence function for the common case when CallArgs are filled in using
643  // makeArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be .get()'ed to
644  // get the Value *.
645  InvokeInst *
646  CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes,
647  Value *ActualInvokee, BasicBlock *NormalDest,
648  BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
649  ArrayRef<Value *> DeoptArgs,
650  ArrayRef<Value *> GCArgs, const Twine &Name = "");
651 
652  /// \brief Create a call to the experimental.gc.result intrinsic to extract
653  /// the result from a call wrapped in a statepoint.
654  CallInst *CreateGCResult(Instruction *Statepoint,
655  Type *ResultType,
656  const Twine &Name = "");
657 
658  /// \brief Create a call to the experimental.gc.relocate intrinsics to
659  /// project the relocated value of one pointer from the statepoint.
660  CallInst *CreateGCRelocate(Instruction *Statepoint,
661  int BaseOffset,
662  int DerivedOffset,
663  Type *ResultType,
664  const Twine &Name = "");
665 
666  /// Create a call to intrinsic \p ID with 2 operands which is mangled on the
667  /// first type.
668  CallInst *CreateBinaryIntrinsic(Intrinsic::ID ID,
669  Value *LHS, Value *RHS,
670  const Twine &Name = "");
671 
672  /// Create call to the minnum intrinsic.
673  CallInst *CreateMinNum(Value *LHS, Value *RHS, const Twine &Name = "") {
674  return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, Name);
675  }
676 
677  /// Create call to the maxnum intrinsic.
678  CallInst *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
679  return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, Name);
680  }
681 
682 private:
683  /// \brief Create a call to a masked intrinsic with given Id.
684  CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef<Value *> Ops,
685  ArrayRef<Type *> OverloadedTypes,
686  const Twine &Name = "");
687 
688  Value *getCastedInt8PtrValue(Value *Ptr);
689 };
690 
691 /// \brief This provides a uniform API for creating instructions and inserting
692 /// them into a basic block: either at the end of a BasicBlock, or at a specific
693 /// iterator location in a block.
694 ///
695 /// Note that the builder does not expose the full generality of LLVM
696 /// instructions. For access to extra instruction properties, use the mutators
697 /// (e.g. setVolatile) on the instructions after they have been
698 /// created. Convenience state exists to specify fast-math flags and fp-math
699 /// tags.
700 ///
701 /// The first template argument specifies a class to use for creating constants.
702 /// This defaults to creating minimally folded constants. The second template
703 /// argument allows clients to specify custom insertion hooks that are called on
704 /// every newly created insertion.
705 template <typename T = ConstantFolder,
707 class IRBuilder : public IRBuilderBase, public Inserter {
708  T Folder;
709 
710 public:
711  IRBuilder(LLVMContext &C, const T &F, Inserter I = Inserter(),
712  MDNode *FPMathTag = nullptr,
713  ArrayRef<OperandBundleDef> OpBundles = None)
714  : IRBuilderBase(C, FPMathTag, OpBundles), Inserter(std::move(I)),
715  Folder(F) {}
716 
717  explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr,
718  ArrayRef<OperandBundleDef> OpBundles = None)
719  : IRBuilderBase(C, FPMathTag, OpBundles), Folder() {}
720 
721  explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = nullptr,
722  ArrayRef<OperandBundleDef> OpBundles = None)
723  : IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
724  SetInsertPoint(TheBB);
725  }
726 
727  explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
728  ArrayRef<OperandBundleDef> OpBundles = None)
729  : IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder() {
730  SetInsertPoint(TheBB);
731  }
732 
733  explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
734  ArrayRef<OperandBundleDef> OpBundles = None)
735  : IRBuilderBase(IP->getContext(), FPMathTag, OpBundles), Folder() {
736  SetInsertPoint(IP);
737  }
738 
740  MDNode *FPMathTag = nullptr,
741  ArrayRef<OperandBundleDef> OpBundles = None)
742  : IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
743  SetInsertPoint(TheBB, IP);
744  }
745 
747  MDNode *FPMathTag = nullptr,
748  ArrayRef<OperandBundleDef> OpBundles = None)
749  : IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder() {
750  SetInsertPoint(TheBB, IP);
751  }
752 
753  /// \brief Get the constant folder being used.
754  const T &getFolder() { return Folder; }
755 
756  /// \brief Insert and return the specified instruction.
757  template<typename InstTy>
758  InstTy *Insert(InstTy *I, const Twine &Name = "") const {
759  this->InsertHelper(I, Name, BB, InsertPt);
760  this->SetInstDebugLocation(I);
761  return I;
762  }
763 
764  /// \brief No-op overload to handle constants.
765  Constant *Insert(Constant *C, const Twine& = "") const {
766  return C;
767  }
768 
769  //===--------------------------------------------------------------------===//
770  // Instruction creation methods: Terminators
771  //===--------------------------------------------------------------------===//
772 
773 private:
774  /// \brief Helper to add branch weight and unpredictable metadata onto an
775  /// instruction.
776  /// \returns The annotated instruction.
777  template <typename InstTy>
778  InstTy *addBranchMetadata(InstTy *I, MDNode *Weights, MDNode *Unpredictable) {
779  if (Weights)
780  I->setMetadata(LLVMContext::MD_prof, Weights);
781  if (Unpredictable)
782  I->setMetadata(LLVMContext::MD_unpredictable, Unpredictable);
783  return I;
784  }
785 
786 public:
787  /// \brief Create a 'ret void' instruction.
789  return Insert(ReturnInst::Create(Context));
790  }
791 
792  /// \brief Create a 'ret <val>' instruction.
794  return Insert(ReturnInst::Create(Context, V));
795  }
796 
797  /// \brief Create a sequence of N insertvalue instructions,
798  /// with one Value from the retVals array each, that build a aggregate
799  /// return value one value at a time, and a ret instruction to return
800  /// the resulting aggregate value.
801  ///
802  /// This is a convenience function for code that uses aggregate return values
803  /// as a vehicle for having multiple return values.
804  ReturnInst *CreateAggregateRet(Value *const *retVals, unsigned N) {
805  Value *V = UndefValue::get(getCurrentFunctionReturnType());
806  for (unsigned i = 0; i != N; ++i)
807  V = CreateInsertValue(V, retVals[i], i, "mrv");
808  return Insert(ReturnInst::Create(Context, V));
809  }
810 
811  /// \brief Create an unconditional 'br label X' instruction.
813  return Insert(BranchInst::Create(Dest));
814  }
815 
816  /// \brief Create a conditional 'br Cond, TrueDest, FalseDest'
817  /// instruction.
819  MDNode *BranchWeights = nullptr,
820  MDNode *Unpredictable = nullptr) {
821  return Insert(addBranchMetadata(BranchInst::Create(True, False, Cond),
822  BranchWeights, Unpredictable));
823  }
824 
825  /// \brief Create a conditional 'br Cond, TrueDest, FalseDest'
826  /// instruction. Copy branch meta data if available.
828  Instruction *MDSrc) {
829  BranchInst *Br = BranchInst::Create(True, False, Cond);
830  if (MDSrc) {
833  Br->copyMetadata(*MDSrc, makeArrayRef(&WL[0], 4));
834  }
835  return Insert(Br);
836  }
837 
838  /// \brief Create a switch instruction with the specified value, default dest,
839  /// and with a hint for the number of cases that will be added (for efficient
840  /// allocation).
841  SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
842  MDNode *BranchWeights = nullptr,
843  MDNode *Unpredictable = nullptr) {
844  return Insert(addBranchMetadata(SwitchInst::Create(V, Dest, NumCases),
845  BranchWeights, Unpredictable));
846  }
847 
848  /// \brief Create an indirect branch instruction with the specified address
849  /// operand, with an optional hint for the number of destinations that will be
850  /// added (for efficient allocation).
851  IndirectBrInst *CreateIndirectBr(Value *Addr, unsigned NumDests = 10) {
852  return Insert(IndirectBrInst::Create(Addr, NumDests));
853  }
854 
855  /// \brief Create an invoke instruction.
857  BasicBlock *UnwindDest,
859  const Twine &Name = "") {
860  return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args),
861  Name);
862  }
864  BasicBlock *UnwindDest, ArrayRef<Value *> Args,
865  ArrayRef<OperandBundleDef> OpBundles,
866  const Twine &Name = "") {
867  return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
868  OpBundles), Name);
869  }
870 
872  return Insert(ResumeInst::Create(Exn));
873  }
874 
876  BasicBlock *UnwindBB = nullptr) {
877  return Insert(CleanupReturnInst::Create(CleanupPad, UnwindBB));
878  }
879 
881  unsigned NumHandlers,
882  const Twine &Name = "") {
883  return Insert(CatchSwitchInst::Create(ParentPad, UnwindBB, NumHandlers),
884  Name);
885  }
886 
888  const Twine &Name = "") {
889  return Insert(CatchPadInst::Create(ParentPad, Args), Name);
890  }
891 
894  const Twine &Name = "") {
895  return Insert(CleanupPadInst::Create(ParentPad, Args), Name);
896  }
897 
899  return Insert(CatchReturnInst::Create(CatchPad, BB));
900  }
901 
903  return Insert(new UnreachableInst(Context));
904  }
905 
906  //===--------------------------------------------------------------------===//
907  // Instruction creation methods: Binary Operators
908  //===--------------------------------------------------------------------===//
909 private:
910  BinaryOperator *CreateInsertNUWNSWBinOp(BinaryOperator::BinaryOps Opc,
911  Value *LHS, Value *RHS,
912  const Twine &Name,
913  bool HasNUW, bool HasNSW) {
914  BinaryOperator *BO = Insert(BinaryOperator::Create(Opc, LHS, RHS), Name);
915  if (HasNUW) BO->setHasNoUnsignedWrap();
916  if (HasNSW) BO->setHasNoSignedWrap();
917  return BO;
918  }
919 
920  Instruction *AddFPMathAttributes(Instruction *I,
921  MDNode *FPMathTag,
922  FastMathFlags FMF) const {
923  if (!FPMathTag)
924  FPMathTag = DefaultFPMathTag;
925  if (FPMathTag)
926  I->setMetadata(LLVMContext::MD_fpmath, FPMathTag);
927  I->setFastMathFlags(FMF);
928  return I;
929  }
930 
931 public:
932  Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "",
933  bool HasNUW = false, bool HasNSW = false) {
934  if (Constant *LC = dyn_cast<Constant>(LHS))
935  if (Constant *RC = dyn_cast<Constant>(RHS))
936  return Insert(Folder.CreateAdd(LC, RC, HasNUW, HasNSW), Name);
937  return CreateInsertNUWNSWBinOp(Instruction::Add, LHS, RHS, Name,
938  HasNUW, HasNSW);
939  }
940  Value *CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name = "") {
941  return CreateAdd(LHS, RHS, Name, false, true);
942  }
943  Value *CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name = "") {
944  return CreateAdd(LHS, RHS, Name, true, false);
945  }
946  Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "",
947  MDNode *FPMathTag = nullptr) {
948  if (Constant *LC = dyn_cast<Constant>(LHS))
949  if (Constant *RC = dyn_cast<Constant>(RHS))
950  return Insert(Folder.CreateFAdd(LC, RC), Name);
951  return Insert(AddFPMathAttributes(BinaryOperator::CreateFAdd(LHS, RHS),
952  FPMathTag, FMF), Name);
953  }
954  Value *CreateSub(Value *LHS, Value *RHS, const Twine &Name = "",
955  bool HasNUW = false, bool HasNSW = false) {
956  if (Constant *LC = dyn_cast<Constant>(LHS))
957  if (Constant *RC = dyn_cast<Constant>(RHS))
958  return Insert(Folder.CreateSub(LC, RC, HasNUW, HasNSW), Name);
959  return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name,
960  HasNUW, HasNSW);
961  }
962  Value *CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name = "") {
963  return CreateSub(LHS, RHS, Name, false, true);
964  }
965  Value *CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name = "") {
966  return CreateSub(LHS, RHS, Name, true, false);
967  }
968  Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "",
969  MDNode *FPMathTag = nullptr) {
970  if (Constant *LC = dyn_cast<Constant>(LHS))
971  if (Constant *RC = dyn_cast<Constant>(RHS))
972  return Insert(Folder.CreateFSub(LC, RC), Name);
973  return Insert(AddFPMathAttributes(BinaryOperator::CreateFSub(LHS, RHS),
974  FPMathTag, FMF), Name);
975  }
976  Value *CreateMul(Value *LHS, Value *RHS, const Twine &Name = "",
977  bool HasNUW = false, bool HasNSW = false) {
978  if (Constant *LC = dyn_cast<Constant>(LHS))
979  if (Constant *RC = dyn_cast<Constant>(RHS))
980  return Insert(Folder.CreateMul(LC, RC, HasNUW, HasNSW), Name);
981  return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name,
982  HasNUW, HasNSW);
983  }
984  Value *CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name = "") {
985  return CreateMul(LHS, RHS, Name, false, true);
986  }
987  Value *CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name = "") {
988  return CreateMul(LHS, RHS, Name, true, false);
989  }
990  Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "",
991  MDNode *FPMathTag = nullptr) {
992  if (Constant *LC = dyn_cast<Constant>(LHS))
993  if (Constant *RC = dyn_cast<Constant>(RHS))
994  return Insert(Folder.CreateFMul(LC, RC), Name);
995  return Insert(AddFPMathAttributes(BinaryOperator::CreateFMul(LHS, RHS),
996  FPMathTag, FMF), Name);
997  }
998  Value *CreateUDiv(Value *LHS, Value *RHS, const Twine &Name = "",
999  bool isExact = false) {
1000  if (Constant *LC = dyn_cast<Constant>(LHS))
1001  if (Constant *RC = dyn_cast<Constant>(RHS))
1002  return Insert(Folder.CreateUDiv(LC, RC, isExact), Name);
1003  if (!isExact)
1004  return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
1005  return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
1006  }
1007  Value *CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
1008  return CreateUDiv(LHS, RHS, Name, true);
1009  }
1010  Value *CreateSDiv(Value *LHS, Value *RHS, const Twine &Name = "",
1011  bool isExact = false) {
1012  if (Constant *LC = dyn_cast<Constant>(LHS))
1013  if (Constant *RC = dyn_cast<Constant>(RHS))
1014  return Insert(Folder.CreateSDiv(LC, RC, isExact), Name);
1015  if (!isExact)
1016  return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
1017  return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
1018  }
1019  Value *CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
1020  return CreateSDiv(LHS, RHS, Name, true);
1021  }
1022  Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "",
1023  MDNode *FPMathTag = nullptr) {
1024  if (Constant *LC = dyn_cast<Constant>(LHS))
1025  if (Constant *RC = dyn_cast<Constant>(RHS))
1026  return Insert(Folder.CreateFDiv(LC, RC), Name);
1027  return Insert(AddFPMathAttributes(BinaryOperator::CreateFDiv(LHS, RHS),
1028  FPMathTag, FMF), Name);
1029  }
1030  Value *CreateURem(Value *LHS, Value *RHS, const Twine &Name = "") {
1031  if (Constant *LC = dyn_cast<Constant>(LHS))
1032  if (Constant *RC = dyn_cast<Constant>(RHS))
1033  return Insert(Folder.CreateURem(LC, RC), Name);
1034  return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
1035  }
1036  Value *CreateSRem(Value *LHS, Value *RHS, const Twine &Name = "") {
1037  if (Constant *LC = dyn_cast<Constant>(LHS))
1038  if (Constant *RC = dyn_cast<Constant>(RHS))
1039  return Insert(Folder.CreateSRem(LC, RC), Name);
1040  return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1041  }
1042  Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "",
1043  MDNode *FPMathTag = nullptr) {
1044  if (Constant *LC = dyn_cast<Constant>(LHS))
1045  if (Constant *RC = dyn_cast<Constant>(RHS))
1046  return Insert(Folder.CreateFRem(LC, RC), Name);
1047  return Insert(AddFPMathAttributes(BinaryOperator::CreateFRem(LHS, RHS),
1048  FPMathTag, FMF), Name);
1049  }
1050 
1051  Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "",
1052  bool HasNUW = false, bool HasNSW = false) {
1053  if (Constant *LC = dyn_cast<Constant>(LHS))
1054  if (Constant *RC = dyn_cast<Constant>(RHS))
1055  return Insert(Folder.CreateShl(LC, RC, HasNUW, HasNSW), Name);
1056  return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1057  HasNUW, HasNSW);
1058  }
1059  Value *CreateShl(Value *LHS, const APInt &RHS, const Twine &Name = "",
1060  bool HasNUW = false, bool HasNSW = false) {
1061  return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1062  HasNUW, HasNSW);
1063  }
1064  Value *CreateShl(Value *LHS, uint64_t RHS, const Twine &Name = "",
1065  bool HasNUW = false, bool HasNSW = false) {
1066  return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1067  HasNUW, HasNSW);
1068  }
1069 
1070  Value *CreateLShr(Value *LHS, Value *RHS, const Twine &Name = "",
1071  bool isExact = false) {
1072  if (Constant *LC = dyn_cast<Constant>(LHS))
1073  if (Constant *RC = dyn_cast<Constant>(RHS))
1074  return Insert(Folder.CreateLShr(LC, RC, isExact), Name);
1075  if (!isExact)
1076  return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1077  return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1078  }
1079  Value *CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1080  bool isExact = false) {
1081  return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1082  }
1083  Value *CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name = "",
1084  bool isExact = false) {
1085  return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1086  }
1087 
1088  Value *CreateAShr(Value *LHS, Value *RHS, const Twine &Name = "",
1089  bool isExact = false) {
1090  if (Constant *LC = dyn_cast<Constant>(LHS))
1091  if (Constant *RC = dyn_cast<Constant>(RHS))
1092  return Insert(Folder.CreateAShr(LC, RC, isExact), Name);
1093  if (!isExact)
1094  return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1095  return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1096  }
1097  Value *CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1098  bool isExact = false) {
1099  return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1100  }
1101  Value *CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name = "",
1102  bool isExact = false) {
1103  return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1104  }
1105 
1106  Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") {
1107  if (Constant *RC = dyn_cast<Constant>(RHS)) {
1108  if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isMinusOne())
1109  return LHS; // LHS & -1 -> LHS
1110  if (Constant *LC = dyn_cast<Constant>(LHS))
1111  return Insert(Folder.CreateAnd(LC, RC), Name);
1112  }
1113  return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1114  }
1115  Value *CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1116  return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1117  }
1118  Value *CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1119  return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1120  }
1121 
1122  Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "") {
1123  if (Constant *RC = dyn_cast<Constant>(RHS)) {
1124  if (RC->isNullValue())
1125  return LHS; // LHS | 0 -> LHS
1126  if (Constant *LC = dyn_cast<Constant>(LHS))
1127  return Insert(Folder.CreateOr(LC, RC), Name);
1128  }
1129  return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
1130  }
1131  Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1132  return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1133  }
1134  Value *CreateOr(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1135  return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1136  }
1137 
1138  Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") {
1139  if (Constant *LC = dyn_cast<Constant>(LHS))
1140  if (Constant *RC = dyn_cast<Constant>(RHS))
1141  return Insert(Folder.CreateXor(LC, RC), Name);
1142  return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1143  }
1144  Value *CreateXor(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1145  return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1146  }
1147  Value *CreateXor(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1148  return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1149  }
1150 
1152  Value *LHS, Value *RHS, const Twine &Name = "",
1153  MDNode *FPMathTag = nullptr) {
1154  if (Constant *LC = dyn_cast<Constant>(LHS))
1155  if (Constant *RC = dyn_cast<Constant>(RHS))
1156  return Insert(Folder.CreateBinOp(Opc, LC, RC), Name);
1157  Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
1158  if (isa<FPMathOperator>(BinOp))
1159  BinOp = AddFPMathAttributes(BinOp, FPMathTag, FMF);
1160  return Insert(BinOp, Name);
1161  }
1162 
1163  Value *CreateNeg(Value *V, const Twine &Name = "",
1164  bool HasNUW = false, bool HasNSW = false) {
1165  if (Constant *VC = dyn_cast<Constant>(V))
1166  return Insert(Folder.CreateNeg(VC, HasNUW, HasNSW), Name);
1167  BinaryOperator *BO = Insert(BinaryOperator::CreateNeg(V), Name);
1168  if (HasNUW) BO->setHasNoUnsignedWrap();
1169  if (HasNSW) BO->setHasNoSignedWrap();
1170  return BO;
1171  }
1172  Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
1173  return CreateNeg(V, Name, false, true);
1174  }
1175  Value *CreateNUWNeg(Value *V, const Twine &Name = "") {
1176  return CreateNeg(V, Name, true, false);
1177  }
1178  Value *CreateFNeg(Value *V, const Twine &Name = "",
1179  MDNode *FPMathTag = nullptr) {
1180  if (Constant *VC = dyn_cast<Constant>(V))
1181  return Insert(Folder.CreateFNeg(VC), Name);
1182  return Insert(AddFPMathAttributes(BinaryOperator::CreateFNeg(V),
1183  FPMathTag, FMF), Name);
1184  }
1185  Value *CreateNot(Value *V, const Twine &Name = "") {
1186  if (Constant *VC = dyn_cast<Constant>(V))
1187  return Insert(Folder.CreateNot(VC), Name);
1188  return Insert(BinaryOperator::CreateNot(V), Name);
1189  }
1190 
1191  //===--------------------------------------------------------------------===//
1192  // Instruction creation methods: Memory Instructions
1193  //===--------------------------------------------------------------------===//
1194 
1195  AllocaInst *CreateAlloca(Type *Ty, unsigned AddrSpace,
1196  Value *ArraySize = nullptr, const Twine &Name = "") {
1197  return Insert(new AllocaInst(Ty, AddrSpace, ArraySize), Name);
1198  }
1199 
1200  AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr,
1201  const Twine &Name = "") {
1202  const DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
1203  return Insert(new AllocaInst(Ty, DL.getAllocaAddrSpace(), ArraySize), Name);
1204  }
1205  // \brief Provided to resolve 'CreateLoad(Ptr, "...")' correctly, instead of
1206  // converting the string to 'bool' for the isVolatile parameter.
1207  LoadInst *CreateLoad(Value *Ptr, const char *Name) {
1208  return Insert(new LoadInst(Ptr), Name);
1209  }
1210  LoadInst *CreateLoad(Value *Ptr, const Twine &Name = "") {
1211  return Insert(new LoadInst(Ptr), Name);
1212  }
1213  LoadInst *CreateLoad(Type *Ty, Value *Ptr, const Twine &Name = "") {
1214  return Insert(new LoadInst(Ty, Ptr), Name);
1215  }
1216  LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name = "") {
1217  return Insert(new LoadInst(Ptr, nullptr, isVolatile), Name);
1218  }
1219  StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) {
1220  return Insert(new StoreInst(Val, Ptr, isVolatile));
1221  }
1222  // \brief Provided to resolve 'CreateAlignedLoad(Ptr, Align, "...")'
1223  // correctly, instead of converting the string to 'bool' for the isVolatile
1224  // parameter.
1225  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name) {
1226  LoadInst *LI = CreateLoad(Ptr, Name);
1227  LI->setAlignment(Align);
1228  return LI;
1229  }
1231  const Twine &Name = "") {
1232  LoadInst *LI = CreateLoad(Ptr, Name);
1233  LI->setAlignment(Align);
1234  return LI;
1235  }
1237  const Twine &Name = "") {
1238  LoadInst *LI = CreateLoad(Ptr, isVolatile, Name);
1239  LI->setAlignment(Align);
1240  return LI;
1241  }
1243  bool isVolatile = false) {
1244  StoreInst *SI = CreateStore(Val, Ptr, isVolatile);
1245  SI->setAlignment(Align);
1246  return SI;
1247  }
1250  const Twine &Name = "") {
1251  return Insert(new FenceInst(Context, Ordering, SSID), Name);
1252  }
1255  AtomicOrdering SuccessOrdering,
1256  AtomicOrdering FailureOrdering,
1258  return Insert(new AtomicCmpXchgInst(Ptr, Cmp, New, SuccessOrdering,
1259  FailureOrdering, SSID));
1260  }
1262  AtomicOrdering Ordering,
1264  return Insert(new AtomicRMWInst(Op, Ptr, Val, Ordering, SSID));
1265  }
1267  const Twine &Name = "") {
1268  return CreateGEP(nullptr, Ptr, IdxList, Name);
1269  }
1271  const Twine &Name = "") {
1272  if (Constant *PC = dyn_cast<Constant>(Ptr)) {
1273  // Every index must be constant.
1274  size_t i, e;
1275  for (i = 0, e = IdxList.size(); i != e; ++i)
1276  if (!isa<Constant>(IdxList[i]))
1277  break;
1278  if (i == e)
1279  return Insert(Folder.CreateGetElementPtr(Ty, PC, IdxList), Name);
1280  }
1281  return Insert(GetElementPtrInst::Create(Ty, Ptr, IdxList), Name);
1282  }
1284  const Twine &Name = "") {
1285  return CreateInBoundsGEP(nullptr, Ptr, IdxList, Name);
1286  }
1288  const Twine &Name = "") {
1289  if (Constant *PC = dyn_cast<Constant>(Ptr)) {
1290  // Every index must be constant.
1291  size_t i, e;
1292  for (i = 0, e = IdxList.size(); i != e; ++i)
1293  if (!isa<Constant>(IdxList[i]))
1294  break;
1295  if (i == e)
1296  return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IdxList),
1297  Name);
1298  }
1299  return Insert(GetElementPtrInst::CreateInBounds(Ty, Ptr, IdxList), Name);
1300  }
1301  Value *CreateGEP(Value *Ptr, Value *Idx, const Twine &Name = "") {
1302  return CreateGEP(nullptr, Ptr, Idx, Name);
1303  }
1304  Value *CreateGEP(Type *Ty, Value *Ptr, Value *Idx, const Twine &Name = "") {
1305  if (Constant *PC = dyn_cast<Constant>(Ptr))
1306  if (Constant *IC = dyn_cast<Constant>(Idx))
1307  return Insert(Folder.CreateGetElementPtr(Ty, PC, IC), Name);
1308  return Insert(GetElementPtrInst::Create(Ty, Ptr, Idx), Name);
1309  }
1311  const Twine &Name = "") {
1312  if (Constant *PC = dyn_cast<Constant>(Ptr))
1313  if (Constant *IC = dyn_cast<Constant>(Idx))
1314  return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IC), Name);
1315  return Insert(GetElementPtrInst::CreateInBounds(Ty, Ptr, Idx), Name);
1316  }
1317  Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const Twine &Name = "") {
1318  return CreateConstGEP1_32(nullptr, Ptr, Idx0, Name);
1319  }
1320  Value *CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
1321  const Twine &Name = "") {
1323 
1324  if (Constant *PC = dyn_cast<Constant>(Ptr))
1325  return Insert(Folder.CreateGetElementPtr(Ty, PC, Idx), Name);
1326 
1327  return Insert(GetElementPtrInst::Create(Ty, Ptr, Idx), Name);
1328  }
1329  Value *CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
1330  const Twine &Name = "") {
1332 
1333  if (Constant *PC = dyn_cast<Constant>(Ptr))
1334  return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idx), Name);
1335 
1336  return Insert(GetElementPtrInst::CreateInBounds(Ty, Ptr, Idx), Name);
1337  }
1338  Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1,
1339  const Twine &Name = "") {
1340  Value *Idxs[] = {
1343  };
1344 
1345  if (Constant *PC = dyn_cast<Constant>(Ptr))
1346  return Insert(Folder.CreateGetElementPtr(Ty, PC, Idxs), Name);
1347 
1348  return Insert(GetElementPtrInst::Create(Ty, Ptr, Idxs), Name);
1349  }
1350  Value *CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0,
1351  unsigned Idx1, const Twine &Name = "") {
1352  Value *Idxs[] = {
1355  };
1356 
1357  if (Constant *PC = dyn_cast<Constant>(Ptr))
1358  return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idxs), Name);
1359 
1360  return Insert(GetElementPtrInst::CreateInBounds(Ty, Ptr, Idxs), Name);
1361  }
1362  Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name = "") {
1364 
1365  if (Constant *PC = dyn_cast<Constant>(Ptr))
1366  return Insert(Folder.CreateGetElementPtr(nullptr, PC, Idx), Name);
1367 
1368  return Insert(GetElementPtrInst::Create(nullptr, Ptr, Idx), Name);
1369  }
1371  const Twine &Name = "") {
1373 
1374  if (Constant *PC = dyn_cast<Constant>(Ptr))
1375  return Insert(Folder.CreateInBoundsGetElementPtr(nullptr, PC, Idx), Name);
1376 
1377  return Insert(GetElementPtrInst::CreateInBounds(nullptr, Ptr, Idx), Name);
1378  }
1379  Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1,
1380  const Twine &Name = "") {
1381  Value *Idxs[] = {
1384  };
1385 
1386  if (Constant *PC = dyn_cast<Constant>(Ptr))
1387  return Insert(Folder.CreateGetElementPtr(nullptr, PC, Idxs), Name);
1388 
1389  return Insert(GetElementPtrInst::Create(nullptr, Ptr, Idxs), Name);
1390  }
1391  Value *CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1,
1392  const Twine &Name = "") {
1393  Value *Idxs[] = {
1396  };
1397 
1398  if (Constant *PC = dyn_cast<Constant>(Ptr))
1399  return Insert(Folder.CreateInBoundsGetElementPtr(nullptr, PC, Idxs),
1400  Name);
1401 
1402  return Insert(GetElementPtrInst::CreateInBounds(nullptr, Ptr, Idxs), Name);
1403  }
1404  Value *CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx,
1405  const Twine &Name = "") {
1406  return CreateConstInBoundsGEP2_32(Ty, Ptr, 0, Idx, Name);
1407  }
1408 
1409  /// \brief Same as CreateGlobalString, but return a pointer with "i8*" type
1410  /// instead of a pointer to array of i8.
1411  Value *CreateGlobalStringPtr(StringRef Str, const Twine &Name = "",
1412  unsigned AddressSpace = 0) {
1413  GlobalVariable *gv = CreateGlobalString(Str, Name, AddressSpace);
1415  Value *Args[] = { zero, zero };
1416  return CreateInBoundsGEP(gv->getValueType(), gv, Args, Name);
1417  }
1418 
1419  //===--------------------------------------------------------------------===//
1420  // Instruction creation methods: Cast/Conversion Operators
1421  //===--------------------------------------------------------------------===//
1422 
1423  Value *CreateTrunc(Value *V, Type *DestTy, const Twine &Name = "") {
1424  return CreateCast(Instruction::Trunc, V, DestTy, Name);
1425  }
1426  Value *CreateZExt(Value *V, Type *DestTy, const Twine &Name = "") {
1427  return CreateCast(Instruction::ZExt, V, DestTy, Name);
1428  }
1429  Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") {
1430  return CreateCast(Instruction::SExt, V, DestTy, Name);
1431  }
1432  /// \brief Create a ZExt or Trunc from the integer value V to DestTy. Return
1433  /// the value untouched if the type of V is already DestTy.
1435  const Twine &Name = "") {
1436  assert(V->getType()->isIntOrIntVectorTy() &&
1437  DestTy->isIntOrIntVectorTy() &&
1438  "Can only zero extend/truncate integers!");
1439  Type *VTy = V->getType();
1440  if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
1441  return CreateZExt(V, DestTy, Name);
1442  if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
1443  return CreateTrunc(V, DestTy, Name);
1444  return V;
1445  }
1446  /// \brief Create a SExt or Trunc from the integer value V to DestTy. Return
1447  /// the value untouched if the type of V is already DestTy.
1449  const Twine &Name = "") {
1450  assert(V->getType()->isIntOrIntVectorTy() &&
1451  DestTy->isIntOrIntVectorTy() &&
1452  "Can only sign extend/truncate integers!");
1453  Type *VTy = V->getType();
1454  if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
1455  return CreateSExt(V, DestTy, Name);
1456  if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
1457  return CreateTrunc(V, DestTy, Name);
1458  return V;
1459  }
1460  Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = ""){
1461  return CreateCast(Instruction::FPToUI, V, DestTy, Name);
1462  }
1463  Value *CreateFPToSI(Value *V, Type *DestTy, const Twine &Name = ""){
1464  return CreateCast(Instruction::FPToSI, V, DestTy, Name);
1465  }
1466  Value *CreateUIToFP(Value *V, Type *DestTy, const Twine &Name = ""){
1467  return CreateCast(Instruction::UIToFP, V, DestTy, Name);
1468  }
1469  Value *CreateSIToFP(Value *V, Type *DestTy, const Twine &Name = ""){
1470  return CreateCast(Instruction::SIToFP, V, DestTy, Name);
1471  }
1473  const Twine &Name = "") {
1474  return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
1475  }
1476  Value *CreateFPExt(Value *V, Type *DestTy, const Twine &Name = "") {
1477  return CreateCast(Instruction::FPExt, V, DestTy, Name);
1478  }
1480  const Twine &Name = "") {
1481  return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
1482  }
1484  const Twine &Name = "") {
1485  return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
1486  }
1488  const Twine &Name = "") {
1489  return CreateCast(Instruction::BitCast, V, DestTy, Name);
1490  }
1492  const Twine &Name = "") {
1493  return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name);
1494  }
1496  const Twine &Name = "") {
1497  if (V->getType() == DestTy)
1498  return V;
1499  if (Constant *VC = dyn_cast<Constant>(V))
1500  return Insert(Folder.CreateZExtOrBitCast(VC, DestTy), Name);
1501  return Insert(CastInst::CreateZExtOrBitCast(V, DestTy), Name);
1502  }
1504  const Twine &Name = "") {
1505  if (V->getType() == DestTy)
1506  return V;
1507  if (Constant *VC = dyn_cast<Constant>(V))
1508  return Insert(Folder.CreateSExtOrBitCast(VC, DestTy), Name);
1509  return Insert(CastInst::CreateSExtOrBitCast(V, DestTy), Name);
1510  }
1512  const Twine &Name = "") {
1513  if (V->getType() == DestTy)
1514  return V;
1515  if (Constant *VC = dyn_cast<Constant>(V))
1516  return Insert(Folder.CreateTruncOrBitCast(VC, DestTy), Name);
1517  return Insert(CastInst::CreateTruncOrBitCast(V, DestTy), Name);
1518  }
1520  const Twine &Name = "") {
1521  if (V->getType() == DestTy)
1522  return V;
1523  if (Constant *VC = dyn_cast<Constant>(V))
1524  return Insert(Folder.CreateCast(Op, VC, DestTy), Name);
1525  return Insert(CastInst::Create(Op, V, DestTy), Name);
1526  }
1528  const Twine &Name = "") {
1529  if (V->getType() == DestTy)
1530  return V;
1531  if (Constant *VC = dyn_cast<Constant>(V))
1532  return Insert(Folder.CreatePointerCast(VC, DestTy), Name);
1533  return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
1534  }
1535 
1537  const Twine &Name = "") {
1538  if (V->getType() == DestTy)
1539  return V;
1540 
1541  if (Constant *VC = dyn_cast<Constant>(V)) {
1542  return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(VC, DestTy),
1543  Name);
1544  }
1545 
1546  return Insert(CastInst::CreatePointerBitCastOrAddrSpaceCast(V, DestTy),
1547  Name);
1548  }
1549 
1550  Value *CreateIntCast(Value *V, Type *DestTy, bool isSigned,
1551  const Twine &Name = "") {
1552  if (V->getType() == DestTy)
1553  return V;
1554  if (Constant *VC = dyn_cast<Constant>(V))
1555  return Insert(Folder.CreateIntCast(VC, DestTy, isSigned), Name);
1556  return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned), Name);
1557  }
1558 
1560  const Twine &Name = "") {
1561  if (V->getType() == DestTy)
1562  return V;
1563  if (V->getType()->isPtrOrPtrVectorTy() && DestTy->isIntOrIntVectorTy())
1564  return CreatePtrToInt(V, DestTy, Name);
1565  if (V->getType()->isIntOrIntVectorTy() && DestTy->isPtrOrPtrVectorTy())
1566  return CreateIntToPtr(V, DestTy, Name);
1567 
1568  return CreateBitCast(V, DestTy, Name);
1569  }
1570 
1571 public:
1572  Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "") {
1573  if (V->getType() == DestTy)
1574  return V;
1575  if (Constant *VC = dyn_cast<Constant>(V))
1576  return Insert(Folder.CreateFPCast(VC, DestTy), Name);
1577  return Insert(CastInst::CreateFPCast(V, DestTy), Name);
1578  }
1579 
1580  // \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
1581  // compile time error, instead of converting the string to bool for the
1582  // isSigned parameter.
1583  Value *CreateIntCast(Value *, Type *, const char *) = delete;
1584 
1585  //===--------------------------------------------------------------------===//
1586  // Instruction creation methods: Compare Instructions
1587  //===--------------------------------------------------------------------===//
1588 
1589  Value *CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name = "") {
1590  return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name);
1591  }
1592  Value *CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name = "") {
1593  return CreateICmp(ICmpInst::ICMP_NE, LHS, RHS, Name);
1594  }
1595  Value *CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name = "") {
1596  return CreateICmp(ICmpInst::ICMP_UGT, LHS, RHS, Name);
1597  }
1598  Value *CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name = "") {
1599  return CreateICmp(ICmpInst::ICMP_UGE, LHS, RHS, Name);
1600  }
1601  Value *CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name = "") {
1602  return CreateICmp(ICmpInst::ICMP_ULT, LHS, RHS, Name);
1603  }
1604  Value *CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name = "") {
1605  return CreateICmp(ICmpInst::ICMP_ULE, LHS, RHS, Name);
1606  }
1607  Value *CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name = "") {
1608  return CreateICmp(ICmpInst::ICMP_SGT, LHS, RHS, Name);
1609  }
1610  Value *CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name = "") {
1611  return CreateICmp(ICmpInst::ICMP_SGE, LHS, RHS, Name);
1612  }
1613  Value *CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name = "") {
1614  return CreateICmp(ICmpInst::ICMP_SLT, LHS, RHS, Name);
1615  }
1616  Value *CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name = "") {
1617  return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name);
1618  }
1619 
1620  Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name = "",
1621  MDNode *FPMathTag = nullptr) {
1622  return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name, FPMathTag);
1623  }
1624  Value *CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name = "",
1625  MDNode *FPMathTag = nullptr) {
1626  return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name, FPMathTag);
1627  }
1628  Value *CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name = "",
1629  MDNode *FPMathTag = nullptr) {
1630  return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name, FPMathTag);
1631  }
1632  Value *CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name = "",
1633  MDNode *FPMathTag = nullptr) {
1634  return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name, FPMathTag);
1635  }
1636  Value *CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name = "",
1637  MDNode *FPMathTag = nullptr) {
1638  return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name, FPMathTag);
1639  }
1640  Value *CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name = "",
1641  MDNode *FPMathTag = nullptr) {
1642  return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name, FPMathTag);
1643  }
1644  Value *CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name = "",
1645  MDNode *FPMathTag = nullptr) {
1646  return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name, FPMathTag);
1647  }
1648  Value *CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name = "",
1649  MDNode *FPMathTag = nullptr) {
1650  return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name, FPMathTag);
1651  }
1652  Value *CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name = "",
1653  MDNode *FPMathTag = nullptr) {
1654  return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name, FPMathTag);
1655  }
1656  Value *CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name = "",
1657  MDNode *FPMathTag = nullptr) {
1658  return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name, FPMathTag);
1659  }
1660  Value *CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name = "",
1661  MDNode *FPMathTag = nullptr) {
1662  return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name, FPMathTag);
1663  }
1664  Value *CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name = "",
1665  MDNode *FPMathTag = nullptr) {
1666  return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name, FPMathTag);
1667  }
1668  Value *CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name = "",
1669  MDNode *FPMathTag = nullptr) {
1670  return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name, FPMathTag);
1671  }
1672  Value *CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name = "",
1673  MDNode *FPMathTag = nullptr) {
1674  return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name, FPMathTag);
1675  }
1676 
1678  const Twine &Name = "") {
1679  if (Constant *LC = dyn_cast<Constant>(LHS))
1680  if (Constant *RC = dyn_cast<Constant>(RHS))
1681  return Insert(Folder.CreateICmp(P, LC, RC), Name);
1682  return Insert(new ICmpInst(P, LHS, RHS), Name);
1683  }
1685  const Twine &Name = "", MDNode *FPMathTag = nullptr) {
1686  if (Constant *LC = dyn_cast<Constant>(LHS))
1687  if (Constant *RC = dyn_cast<Constant>(RHS))
1688  return Insert(Folder.CreateFCmp(P, LC, RC), Name);
1689  return Insert(AddFPMathAttributes(new FCmpInst(P, LHS, RHS),
1690  FPMathTag, FMF), Name);
1691  }
1692 
1693  //===--------------------------------------------------------------------===//
1694  // Instruction creation methods: Other Instructions
1695  //===--------------------------------------------------------------------===//
1696 
1697  PHINode *CreatePHI(Type *Ty, unsigned NumReservedValues,
1698  const Twine &Name = "") {
1699  return Insert(PHINode::Create(Ty, NumReservedValues), Name);
1700  }
1701 
1703  const Twine &Name = "", MDNode *FPMathTag = nullptr) {
1704  PointerType *PTy = cast<PointerType>(Callee->getType());
1705  FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
1706  return CreateCall(FTy, Callee, Args, Name, FPMathTag);
1707  }
1708 
1710  ArrayRef<Value *> Args, const Twine &Name = "",
1711  MDNode *FPMathTag = nullptr) {
1712  CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
1713  if (isa<FPMathOperator>(CI))
1714  CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
1715  return Insert(CI, Name);
1716  }
1717 
1719  ArrayRef<OperandBundleDef> OpBundles,
1720  const Twine &Name = "", MDNode *FPMathTag = nullptr) {
1721  CallInst *CI = CallInst::Create(Callee, Args, OpBundles);
1722  if (isa<FPMathOperator>(CI))
1723  CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
1724  return Insert(CI, Name);
1725  }
1726 
1728  const Twine &Name = "", MDNode *FPMathTag = nullptr) {
1729  return CreateCall(Callee->getFunctionType(), Callee, Args, Name, FPMathTag);
1730  }
1731 
1732  Value *CreateSelect(Value *C, Value *True, Value *False,
1733  const Twine &Name = "", Instruction *MDFrom = nullptr) {
1734  if (Constant *CC = dyn_cast<Constant>(C))
1735  if (Constant *TC = dyn_cast<Constant>(True))
1736  if (Constant *FC = dyn_cast<Constant>(False))
1737  return Insert(Folder.CreateSelect(CC, TC, FC), Name);
1738 
1739  SelectInst *Sel = SelectInst::Create(C, True, False);
1740  if (MDFrom) {
1741  MDNode *Prof = MDFrom->getMetadata(LLVMContext::MD_prof);
1742  MDNode *Unpred = MDFrom->getMetadata(LLVMContext::MD_unpredictable);
1743  Sel = addBranchMetadata(Sel, Prof, Unpred);
1744  }
1745  return Insert(Sel, Name);
1746  }
1747 
1748  VAArgInst *CreateVAArg(Value *List, Type *Ty, const Twine &Name = "") {
1749  return Insert(new VAArgInst(List, Ty), Name);
1750  }
1751 
1753  const Twine &Name = "") {
1754  if (Constant *VC = dyn_cast<Constant>(Vec))
1755  if (Constant *IC = dyn_cast<Constant>(Idx))
1756  return Insert(Folder.CreateExtractElement(VC, IC), Name);
1757  return Insert(ExtractElementInst::Create(Vec, Idx), Name);
1758  }
1759 
1760  Value *CreateExtractElement(Value *Vec, uint64_t Idx,
1761  const Twine &Name = "") {
1762  return CreateExtractElement(Vec, getInt64(Idx), Name);
1763  }
1764 
1766  const Twine &Name = "") {
1767  if (Constant *VC = dyn_cast<Constant>(Vec))
1768  if (Constant *NC = dyn_cast<Constant>(NewElt))
1769  if (Constant *IC = dyn_cast<Constant>(Idx))
1770  return Insert(Folder.CreateInsertElement(VC, NC, IC), Name);
1771  return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
1772  }
1773 
1774  Value *CreateInsertElement(Value *Vec, Value *NewElt, uint64_t Idx,
1775  const Twine &Name = "") {
1776  return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
1777  }
1778 
1780  const Twine &Name = "") {
1781  if (Constant *V1C = dyn_cast<Constant>(V1))
1782  if (Constant *V2C = dyn_cast<Constant>(V2))
1783  if (Constant *MC = dyn_cast<Constant>(Mask))
1784  return Insert(Folder.CreateShuffleVector(V1C, V2C, MC), Name);
1785  return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
1786  }
1787 
1789  const Twine &Name = "") {
1791  return CreateShuffleVector(V1, V2, Mask, Name);
1792  }
1793 
1795  ArrayRef<unsigned> Idxs,
1796  const Twine &Name = "") {
1797  if (Constant *AggC = dyn_cast<Constant>(Agg))
1798  return Insert(Folder.CreateExtractValue(AggC, Idxs), Name);
1799  return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
1800  }
1801 
1803  ArrayRef<unsigned> Idxs,
1804  const Twine &Name = "") {
1805  if (Constant *AggC = dyn_cast<Constant>(Agg))
1806  if (Constant *ValC = dyn_cast<Constant>(Val))
1807  return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs), Name);
1808  return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
1809  }
1810 
1811  LandingPadInst *CreateLandingPad(Type *Ty, unsigned NumClauses,
1812  const Twine &Name = "") {
1813  return Insert(LandingPadInst::Create(Ty, NumClauses), Name);
1814  }
1815 
1816  //===--------------------------------------------------------------------===//
1817  // Utility creation methods
1818  //===--------------------------------------------------------------------===//
1819 
1820  /// \brief Return an i1 value testing if \p Arg is null.
1821  Value *CreateIsNull(Value *Arg, const Twine &Name = "") {
1822  return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()),
1823  Name);
1824  }
1825 
1826  /// \brief Return an i1 value testing if \p Arg is not null.
1827  Value *CreateIsNotNull(Value *Arg, const Twine &Name = "") {
1828  return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()),
1829  Name);
1830  }
1831 
1832  /// \brief Return the i64 difference between two pointer values, dividing out
1833  /// the size of the pointed-to objects.
1834  ///
1835  /// This is intended to implement C-style pointer subtraction. As such, the
1836  /// pointers must be appropriately aligned for their element types and
1837  /// pointing into the same object.
1838  Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "") {
1839  assert(LHS->getType() == RHS->getType() &&
1840  "Pointer subtraction operand types must match!");
1841  PointerType *ArgType = cast<PointerType>(LHS->getType());
1842  Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context));
1843  Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context));
1844  Value *Difference = CreateSub(LHS_int, RHS_int);
1845  return CreateExactSDiv(Difference,
1846  ConstantExpr::getSizeOf(ArgType->getElementType()),
1847  Name);
1848  }
1849 
1850  /// \brief Create an invariant.group.barrier intrinsic call, that stops
1851  /// optimizer to propagate equality using invariant.group metadata.
1852  /// If Ptr type is different from pointer to i8, it's casted to pointer to i8
1853  /// in the same address space before call and casted back to Ptr type after
1854  /// call.
1856  assert(isa<PointerType>(Ptr->getType()) &&
1857  "invariant.group.barrier only applies to pointers.");
1858  auto *PtrType = Ptr->getType();
1859  auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
1860  if (PtrType != Int8PtrTy)
1861  Ptr = CreateBitCast(Ptr, Int8PtrTy);
1862  Module *M = BB->getParent()->getParent();
1863  Function *FnInvariantGroupBarrier = Intrinsic::getDeclaration(
1864  M, Intrinsic::invariant_group_barrier, {Int8PtrTy});
1865 
1866  assert(FnInvariantGroupBarrier->getReturnType() == Int8PtrTy &&
1867  FnInvariantGroupBarrier->getFunctionType()->getParamType(0) ==
1868  Int8PtrTy &&
1869  "InvariantGroupBarrier should take and return the same type");
1870 
1871  CallInst *Fn = CreateCall(FnInvariantGroupBarrier, {Ptr});
1872 
1873  if (PtrType != Int8PtrTy)
1874  return CreateBitCast(Fn, PtrType);
1875  return Fn;
1876  }
1877 
1878  /// \brief Return a vector value that contains \arg V broadcasted to \p
1879  /// NumElts elements.
1880  Value *CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name = "") {
1881  assert(NumElts > 0 && "Cannot splat to an empty vector!");
1882 
1883  // First insert it into an undef vector so we can shuffle it.
1884  Type *I32Ty = getInt32Ty();
1885  Value *Undef = UndefValue::get(VectorType::get(V->getType(), NumElts));
1886  V = CreateInsertElement(Undef, V, ConstantInt::get(I32Ty, 0),
1887  Name + ".splatinsert");
1888 
1889  // Shuffle the value across the desired number of elements.
1890  Value *Zeros = ConstantAggregateZero::get(VectorType::get(I32Ty, NumElts));
1891  return CreateShuffleVector(V, Undef, Zeros, Name + ".splat");
1892  }
1893 
1894  /// \brief Return a value that has been extracted from a larger integer type.
1896  IntegerType *ExtractedTy, uint64_t Offset,
1897  const Twine &Name) {
1898  IntegerType *IntTy = cast<IntegerType>(From->getType());
1899  assert(DL.getTypeStoreSize(ExtractedTy) + Offset <=
1900  DL.getTypeStoreSize(IntTy) &&
1901  "Element extends past full value");
1902  uint64_t ShAmt = 8 * Offset;
1903  Value *V = From;
1904  if (DL.isBigEndian())
1905  ShAmt = 8 * (DL.getTypeStoreSize(IntTy) -
1906  DL.getTypeStoreSize(ExtractedTy) - Offset);
1907  if (ShAmt) {
1908  V = CreateLShr(V, ShAmt, Name + ".shift");
1909  }
1910  assert(ExtractedTy->getBitWidth() <= IntTy->getBitWidth() &&
1911  "Cannot extract to a larger integer!");
1912  if (ExtractedTy != IntTy) {
1913  V = CreateTrunc(V, ExtractedTy, Name + ".trunc");
1914  }
1915  return V;
1916  }
1917 
1918 private:
1919  /// \brief Helper function that creates an assume intrinsic call that
1920  /// represents an alignment assumption on the provided Ptr, Mask, Type
1921  /// and Offset.
1922  CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
1923  Value *PtrValue, Value *Mask,
1924  Type *IntPtrTy,
1925  Value *OffsetValue) {
1926  Value *PtrIntValue = CreatePtrToInt(PtrValue, IntPtrTy, "ptrint");
1927 
1928  if (OffsetValue) {
1929  bool IsOffsetZero = false;
1930  if (ConstantInt *CI = dyn_cast<ConstantInt>(OffsetValue))
1931  IsOffsetZero = CI->isZero();
1932 
1933  if (!IsOffsetZero) {
1934  if (OffsetValue->getType() != IntPtrTy)
1935  OffsetValue = CreateIntCast(OffsetValue, IntPtrTy, /*isSigned*/ true,
1936  "offsetcast");
1937  PtrIntValue = CreateSub(PtrIntValue, OffsetValue, "offsetptr");
1938  }
1939  }
1940 
1941  Value *Zero = ConstantInt::get(IntPtrTy, 0);
1942  Value *MaskedPtr = CreateAnd(PtrIntValue, Mask, "maskedptr");
1943  Value *InvCond = CreateICmpEQ(MaskedPtr, Zero, "maskcond");
1944  return CreateAssumption(InvCond);
1945  }
1946 
1947 public:
1948  /// \brief Create an assume intrinsic call that represents an alignment
1949  /// assumption on the provided pointer.
1950  ///
1951  /// An optional offset can be provided, and if it is provided, the offset
1952  /// must be subtracted from the provided pointer to get the pointer with the
1953  /// specified alignment.
1955  unsigned Alignment,
1956  Value *OffsetValue = nullptr) {
1957  assert(isa<PointerType>(PtrValue->getType()) &&
1958  "trying to create an alignment assumption on a non-pointer?");
1959  PointerType *PtrTy = cast<PointerType>(PtrValue->getType());
1960  Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
1961 
1962  Value *Mask = ConstantInt::get(IntPtrTy, Alignment > 0 ? Alignment - 1 : 0);
1963  return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
1964  OffsetValue);
1965  }
1966  //
1967  /// \brief Create an assume intrinsic call that represents an alignment
1968  /// assumption on the provided pointer.
1969  ///
1970  /// An optional offset can be provided, and if it is provided, the offset
1971  /// must be subtracted from the provided pointer to get the pointer with the
1972  /// specified alignment.
1973  ///
1974  /// This overload handles the condition where the Alignment is dependent
1975  /// on an existing value rather than a static value.
1977  Value *Alignment,
1978  Value *OffsetValue = nullptr) {
1979  assert(isa<PointerType>(PtrValue->getType()) &&
1980  "trying to create an alignment assumption on a non-pointer?");
1981  PointerType *PtrTy = cast<PointerType>(PtrValue->getType());
1982  Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
1983 
1984  if (Alignment->getType() != IntPtrTy)
1985  Alignment = CreateIntCast(Alignment, IntPtrTy, /*isSigned*/ true,
1986  "alignmentcast");
1987  Value *IsPositive =
1988  CreateICmp(CmpInst::ICMP_SGT, Alignment,
1989  ConstantInt::get(Alignment->getType(), 0), "ispositive");
1990  Value *PositiveMask =
1991  CreateSub(Alignment, ConstantInt::get(IntPtrTy, 1), "positivemask");
1992  Value *Mask = CreateSelect(IsPositive, PositiveMask,
1993  ConstantInt::get(IntPtrTy, 0), "mask");
1994 
1995  return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
1996  OffsetValue);
1997  }
1998 };
1999 
2000 // Create wrappers for C Binding types (see CBindingWrapping.h).
2002 
2003 } // end namespace llvm
2004 
2005 #endif // LLVM_IR_IRBUILDER_H
IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
Definition: IRBuilder.h:343
Value * CreateInsertElement(Value *Vec, Value *NewElt, uint64_t Idx, const Twine &Name="")
Definition: IRBuilder.h:1774
Value * CreateNSWNeg(Value *V, const Twine &Name="")
Definition: IRBuilder.h:1172
Value * CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition: IRBuilder.h:1329
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Definition: IRBuilder.h:1283
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:90
uint64_t CallInst * C
Return a value (possibly void), from a function.
Value * CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1097
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:1310
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static ConstantInt * getFalse(LLVMContext &Context)
Definition: Constants.cpp:548
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional &#39;br Cond, TrueDest, FalseDest&#39; instruction.
Definition: IRBuilder.h:818
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1677
Value * CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition: IRBuilder.h:1317
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:165
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:173
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T &F, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:739
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1151
Value * CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition: IRBuilder.h:1320
FastMathFlags getFastMathFlags() const
Get the flags to be applied to created floating point ops.
Definition: IRBuilder.h:212
LLVMContext & Context
LLVMContext & getContext() const
Definition: IRBuilder.h:124
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
Definition: IRBuilder.h:1195
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1592
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Definition: IRBuilder.h:1827
Atomic ordering constants.
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1491
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
Definition: IRBuilder.h:1434
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1472
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:135
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1601
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1709
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1138
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=nullptr)
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1718
An instruction for ordering other memory operations.
Definition: Instructions.h:440
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Definition: Instructions.h:514
FastMathFlags FMF
Definition: IRBuilder.h:99
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1636
bool isSet() const
Returns true if this insert point is set.
Definition: IRBuilder.h:182
LoadInst * CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name="")
Definition: IRBuilder.h:1216
Value * CreateShl(Value *LHS, uint64_t RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1064
static ConstantAggregateZero * get(Type *Ty)
Definition: Constants.cpp:1273
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:943
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.h:1895
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Definition: Instructions.h:863
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1613
This class represents a function call, abstracting a target machine&#39;s calling convention.
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)
This specifies that created instructions should be inserted at the specified point.
Definition: IRBuilder.h:144
Value * CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Definition: IRBuilder.h:1338
unsigned less or equal
Definition: InstrTypes.h:879
unsigned less than
Definition: InstrTypes.h:878
IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:727
0 1 0 0 True if ordered and less than
Definition: InstrTypes.h:859
This instruction constructs a fixed permutation of two input vectors.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
1 1 1 0 True if unordered or not equal
Definition: InstrTypes.h:869
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Definition: Types.h:97
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1429
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:862
F(f)
static CallInst * Create(Value *Func, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1660
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned 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:405
An instruction for reading from memory.
Definition: Instructions.h:164
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1648
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:177
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Definition: Instructions.h:677
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1604
Value * CreateShuffleVector(Value *V1, Value *V2, ArrayRef< uint32_t > IntMask, const Twine &Name="")
Definition: IRBuilder.h:1788
static IntegerType * getInt16Ty(LLVMContext &C)
Definition: Type.cpp:175
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, Value *Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer...
Definition: IRBuilder.h:1976
static LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
Value * CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:940
static Constant * getNullValue(Type *Ty)
Constructor to create a &#39;0&#39; constant of arbitrary type.
Definition: Constants.cpp:232
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
Definition: IRBuilder.h:1242
Value * CreateNot(Value *V, const Twine &Name="")
Definition: IRBuilder.h:1185
LLVMContext & Context
Definition: IRBuilder.h:96
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1656
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:348
1 0 0 1 True if unordered or equal
Definition: InstrTypes.h:864
Value * CreateFSub(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:968
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition: IRBuilder.h:1134
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
Definition: IRBuilder.h:1200
unsigned getAllocaAddrSpace() const
Definition: DataLayout.h:258
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition: InstrTypes.h:863
Definition: BitVector.h:921
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1476
This class represents the LLVM &#39;select&#39; instruction.
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.h:1838
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
Value * CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1101
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Definition: IRBuilder.h:353
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:164
LoadInst * CreateLoad(Value *Ptr, const Twine &Name="")
Definition: IRBuilder.h:1210
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value *> Args=None, const Twine &Name="")
Definition: IRBuilder.h:892
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1503
ReturnInst * CreateRet(Value *V)
Create a &#39;ret <val>&#39; instruction.
Definition: IRBuilder.h:793
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:707
IntegerType * getIntPtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type representing a pointer to an integer value.
Definition: IRBuilder.h:391
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:860
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.h:1954
const DebugLoc & getCurrentDebugLocation() const
Get location information used by debugging information.
Definition: IRBuilder.h:155
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:932
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:295
CallInst * CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
Definition: IRBuilder.h:490
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1607
ConstantInt * getInt16(uint16_t C)
Get a constant 16-bit value.
Definition: IRBuilder.h:303
Type * getVoidTy()
Fetch the type representing void.
Definition: IRBuilder.h:381
BasicBlock * BB
Definition: IRBuilder.h:94
AtomicOrdering
Atomic ordering for LLVM&#39;s memory model.
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
Definition: IRBuilder.h:898
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Definition: IRBuilder.h:1219
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1483
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:1827
Class to represent function types.
Definition: DerivedTypes.h:103
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1487
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Definition: IRBuilder.h:1448
Value * CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1595
CallInst * CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:451
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:689
BasicBlock * GetInsertBlock() const
Definition: IRBuilder.h:122
Value * CreateGlobalStringPtr(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Same as CreateGlobalString, but return a pointer with "i8*" type instead of a pointer to array of i8...
Definition: IRBuilder.h:1411
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
Definition: IRBuilder.h:117
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Definition: IRBuilder.h:159
This instruction compares its operands according to the predicate given to the constructor.
CallInst * CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:504
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Definition: IRBuilder.h:1880
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
ConstantFolder - Create constants with minimum, target independent, folding.
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Definition: IRBuilder.h:1254
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:954
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1469
An instruction for storing to memory.
Definition: Instructions.h:306
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Definition: IRBuilder.h:152
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:203
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1426
IRBuilder(LLVMContext &C, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:717
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:66
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1620
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1495
amdgpu Simplify well known AMD library false Value * Callee
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:980
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Value * CreateXor(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition: IRBuilder.h:1144
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Definition: IRBuilder.h:128
ConstantInt * getIntN(unsigned N, uint64_t C)
Get a constant N-bit value, zero extended or truncated from a 64-bit value.
Definition: IRBuilder.h:319
Class to represent pointers.
Definition: DerivedTypes.h:467
Type * getHalfTy()
Fetch the type representing a 16-bit floating point value.
Definition: IRBuilder.h:366
CallInst * CreateMinNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minnum intrinsic.
Definition: IRBuilder.h:673
Value * CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1652
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1122
CallInst * CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:512
IndirectBrInst * CreateIndirectBr(Value *Addr, unsigned NumDests=10)
Create an indirect branch instruction with the specified address operand, with an optional hint for t...
Definition: IRBuilder.h:851
Synchronized with respect to all concurrently executing threads.
Definition: LLVMContext.h:59
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1684
InsertPoint saveAndClearIP()
Returns the current insert point, clearing it in the process.
Definition: IRBuilder.h:194
LoadInst * CreateLoad(Value *Ptr, const char *Name)
Definition: IRBuilder.h:1207
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
Definition: DataLayout.cpp:744
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
Definition: IRBuilder.h:376
#define P(N)
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.h:150
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
Definition: IRBuilder.h:201
static IntegerType * getInt128Ty(LLVMContext &C)
Definition: Type.cpp:178
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
IntegerType * getInt128Ty()
Fetch the type representing a 128-bit integer.
Definition: IRBuilder.h:358
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:282
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1088
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
Creates a new insertion point at the given location.
Definition: IRBuilder.h:178
IRBuilder(Instruction *IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:733
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
ConstantInt * getTrue()
Get the constant value for i1 true.
Definition: IRBuilder.h:288
UnreachableInst * CreateUnreachable()
Definition: IRBuilder.h:902
Conditional or Unconditional Branch instruction.
static ExtractValueInst * Create(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
MDNode * getDefaultFPMathTag() const
Get the floating point math metadata being used.
Definition: IRBuilder.h:209
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
This function has undefined behavior.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Definition: IRBuilder.h:283
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1019
This is an important base class in LLVM.
Definition: Constant.h:42
InsertPoint saveIP() const
Returns the current insert point.
Definition: IRBuilder.h:189
Resume the propagation of an exception.
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1059
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Value * CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1007
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition: IRBuilder.h:1732
Indirect Branch Instruction.
Value * CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:984
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1624
Value * CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition: IRBuilder.h:1379
Value * CreateFPToUI(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1460
CallInst * CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maxnum intrinsic.
Definition: IRBuilder.h:678
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const Twine &Name="")
Definition: IRBuilder.h:1213
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:161
CatchSwitchInst * CreateCatchSwitch(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, const Twine &Name="")
Definition: IRBuilder.h:880
VAArgInst * CreateVAArg(Value *List, Type *Ty, const Twine &Name="")
Definition: IRBuilder.h:1748
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1163
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:853
IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:721
Value * CreateFRem(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1042
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1610
A specialization of it&#39;s base class for read-write access to a gc.statepoint.
Definition: Statepoint.h:319
0 1 1 1 True if ordered (no nans)
Definition: InstrTypes.h:862
static CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast or an AddrSpaceCast cast instruction.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:495
void clearFastMathFlags()
Clear the fast-math flags.
Definition: IRBuilder.h:215
CallInst * CreateCall(Function *Callee, ArrayRef< Value *> Args, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1727
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1589
self_iterator getIterator()
Definition: ilist_node.h:82
Class to represent integer types.
Definition: DerivedTypes.h:40
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition: IRBuilder.h:313
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
IntegerType * getIntNTy(unsigned N)
Fetch the type representing an N-bit integer.
Definition: IRBuilder.h:361
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:1752
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile, const Twine &Name="")
Definition: IRBuilder.h:1236
IRBuilderCallbackInserter(std::function< void(Instruction *)> Callback)
Definition: IRBuilder.h:78
void setAlignment(unsigned Align)
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
Definition: IRBuilder.h:765
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Definition: IRBuilder.h:1261
NUW NUW NUW NUW Exact static Exact BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(std::shared_ptr< Module >, LLVMSharedModuleRef) namespace detail
static UndefValue * get(Type *T)
Static factory methods - Return an &#39;undef&#39; object of the specified type.
Definition: Constants.cpp:1356
Value * CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1079
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
void SetInsertPoint(Instruction *I)
This specifies that created instructions should be inserted before the specified instruction.
Definition: IRBuilder.h:135
const T & getFolder()
Get the constant folder being used.
Definition: IRBuilder.h:754
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:1794
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
Value * CreateInvariantGroupBarrier(Value *Ptr)
Create an invariant.group.barrier intrinsic call, that stops optimizer to propagate equality using in...
Definition: IRBuilder.h:1855
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:220
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Definition: IRBuilder.h:386
1 1 0 1 True if unordered, less than, or equal
Definition: InstrTypes.h:868
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1222
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:976
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1423
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=nullptr)
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1083
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1036
signed greater than
Definition: InstrTypes.h:880
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1672
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1466
Value * CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1628
Value * CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition: IRBuilder.h:1362
This provides the default implementation of the IRBuilder &#39;InsertHelper&#39; method that is called whenev...
Definition: IRBuilder.h:63
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition: IRBuilder.h:1697
Value * CreateGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Definition: IRBuilder.h:1266
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1632
0 0 1 0 True if ordered and greater than
Definition: InstrTypes.h:857
static BinaryOperator * CreateFNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:163
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition: Type.h:224
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:317
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
static CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
Value * CreateFAdd(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:946
This is the shared class of boolean and integer constants.
Definition: Constants.h:84
ResumeInst * CreateResume(Value *Exn)
Definition: IRBuilder.h:871
InsertPoint - A saved insertion point.
Definition: IRBuilder.h:169
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value *> Args=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
iterator end()
Definition: BasicBlock.h:254
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=nullptr)
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is null.
Definition: IRBuilder.h:1821
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
Definition: Type.cpp:130
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition: IRBuilder.h:863
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Definition: IRBuilder.h:1550
Value * CreateNUWNeg(Value *V, const Twine &Name="")
Definition: IRBuilder.h:1175
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1598
1 1 0 0 True if unordered or less than
Definition: InstrTypes.h:867
Module.h This file contains the declarations for the Module class.
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:1765
AddressSpace
Definition: NVPTXBaseInfo.h:22
signed less than
Definition: InstrTypes.h:882
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:104
Value * CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1644
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:308
static CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
Value * CreateExtractElement(Value *Vec, uint64_t Idx, const Twine &Name="")
Definition: IRBuilder.h:1760
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition: Type.cpp:180
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1640
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition: IRBuilder.h:1779
CallInst * CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
Definition: IRBuilder.h:423
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:585
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
#define NC
Definition: regutils.h:42
Value * CreateConstInBoundsGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition: IRBuilder.h:1370
Value * CreateURem(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1030
static ConstantInt * getTrue(LLVMContext &Context)
Definition: Constants.cpp:541
Value handle that asserts if the Value is deleted.
Definition: ValueHandle.h:238
ArrayRef< OperandBundleDef > DefaultOperandBundles
Definition: IRBuilder.h:101
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:145
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1572
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition: IRBuilder.h:1118
signed less or equal
Definition: InstrTypes.h:883
Class for arbitrary precision integers.
Definition: APInt.h:69
BasicBlock::iterator getPoint() const
Definition: IRBuilder.h:185
Value * CreateGEP(Value *Ptr, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:1301
Value * CreateSDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1010
Value * CreateUDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:998
Value * CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:987
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
Value * CreatePointerBitCastOrAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1536
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:91
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Definition: IRBuilder.h:338
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1051
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1527
Value * CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition: IRBuilder.h:1391
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value *> Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
amdgpu Simplify well known AMD library false Value Value * Arg
ConstantInt * getFalse()
Get the constant value for i1 false.
Definition: IRBuilder.h:293
MDNode * DefaultFPMathTag
Definition: IRBuilder.h:98
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const Twine &Name="")
Definition: IRBuilder.h:1230
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Definition: IRBuilder.h:333
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1559
SwitchInst * CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases=10, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a switch instruction with the specified value, default dest, and with a hint for the number of...
Definition: IRBuilder.h:841
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1511
Value * CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:965
ReturnInst * CreateRetVoid()
Create a &#39;ret void&#39; instruction.
Definition: IRBuilder.h:788
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass&#39;s ...
Value * CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1664
Value * CreateGEP(Type *Ty, Value *Ptr, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:1304
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Definition: IRBuilder.h:1270
Provides an &#39;InsertHelper&#39; that calls a user-provided callback after performing the default insertion...
Definition: IRBuilder.h:74
iterator insert(iterator where, pointer New)
Definition: ilist.h:241
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:285
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition: IRBuilder.h:1248
CallInst * CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:442
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:176
Value * CreateXor(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition: IRBuilder.h:1147
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value *> Args, const Twine &Name="")
Definition: IRBuilder.h:887
unsigned greater or equal
Definition: InstrTypes.h:877
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
Definition: IRBuilder.h:875
const NodeList & List
Definition: RDFGraph.cpp:210
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Definition: IRBuilder.h:1287
0 1 1 0 True if ordered and operands are unequal
Definition: InstrTypes.h:861
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Definition: IRBuilder.h:1350
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1463
Type * getValueType() const
Definition: GlobalValue.h:275
void setDefaultFPMathTag(MDNode *FPMathTag)
Set the floating point math metadata to be used.
Definition: IRBuilder.h:218
static BinaryOperator * CreateNeg(Value *S1, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
Definition: IRBuilder.h:371
1 0 1 0 True if unordered or greater than
Definition: InstrTypes.h:865
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
Definition: IRBuilder.h:82
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Definition: IRBuilder.h:1811
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1106
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1479
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Definition: IRBuilder.h:758
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
Multiway switch.
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1519
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Definition: Instructions.h:897
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition: IRBuilder.h:1115
ReturnInst * CreateAggregateRet(Value *const *retVals, unsigned N)
Create a sequence of N insertvalue instructions, with one Value from the retVals array each...
Definition: IRBuilder.h:804
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name)
Definition: IRBuilder.h:1225
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore=nullptr)
0 0 0 1 True if ordered and equal
Definition: InstrTypes.h:856
LLVM Value Representation.
Definition: Value.h:73
void setAlignment(unsigned Align)
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:866
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Definition: DataLayout.h:405
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, Instruction *MDSrc)
Create a conditional &#39;br Cond, TrueDest, FalseDest&#39; instruction.
Definition: IRBuilder.h:827
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional &#39;br label X&#39; instruction.
Definition: IRBuilder.h:812
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:593
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, Instruction *InsertBefore=nullptr)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E&#39;s largest value.
Definition: BitmaskEnum.h:81
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
Definition: IRBuilder.h:65
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
Definition: IRBuilder.h:221
BasicBlock::iterator GetInsertPoint() const
Definition: IRBuilder.h:123
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1070
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
Definition: IRBuilder.h:1404
Invoke instruction.
Value * CreateFDiv(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1022
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
Definition: IRBuilder.h:298
print Print MemDeps of function
Convenience struct for specifying and reasoning about fast-math flags.
Definition: Operator.h:160
unsigned greater than
Definition: InstrTypes.h:876
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Value * CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:962
static bool isVolatile(Instruction *Inst)
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t 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.h:468
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:746
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:1802
bool isBigEndian() const
Definition: DataLayout.h:222
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
Definition: Constants.cpp:2503
static ExtractElementInst * Create(Value *Vec, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
IRBuilder(LLVMContext &C, const T &F, Inserter I=Inserter(), MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Definition: IRBuilder.h:711
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
Definition: IRBuilder.h:324
static BinaryOperator * CreateMul(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Value * CreateFMul(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:990
BasicBlock * getBlock() const
Definition: IRBuilder.h:184
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args=None, const Twine &Name="")
Create an invoke instruction.
Definition: IRBuilder.h:856
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:858
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1616
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:174
BasicBlock::iterator InsertPt
Definition: IRBuilder.h:95
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1178
Type * getElementType() const
Definition: DerivedTypes.h:486
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
Definition: APFloat.h:1227
Value * CreateOr(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition: IRBuilder.h:1131
signed greater or equal
Definition: InstrTypes.h:881
const BasicBlock * getParent() const
Definition: Instruction.h:67
an instruction to allocate memory on the stack
Definition: Instructions.h:60
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1668
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1702