Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
IRBuilder.cpp
Go to the documentation of this file.
1//===- IRBuilder.cpp - Builder for LLVM Instrs ----------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the IRBuilder class, which is used as a convenient way
10// to create LLVM instructions with a consistent and simplified interface.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/IR/IRBuilder.h"
15#include "llvm/ADT/ArrayRef.h"
16#include "llvm/IR/Constant.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/DebugInfoMetadata.h"
19#include "llvm/IR/DerivedTypes.h"
20#include "llvm/IR/Function.h"
21#include "llvm/IR/GlobalValue.h"
22#include "llvm/IR/GlobalVariable.h"
23#include "llvm/IR/IntrinsicInst.h"
24#include "llvm/IR/Intrinsics.h"
25#include "llvm/IR/LLVMContext.h"
26#include "llvm/IR/Module.h"
27#include "llvm/IR/NoFolder.h"
28#include "llvm/IR/Operator.h"
29#include "llvm/IR/Statepoint.h"
30#include "llvm/IR/Type.h"
31#include "llvm/IR/Value.h"
32#include "llvm/Support/Casting.h"
33#include <cassert>
34#include <cstdint>
35#include <optional>
36#include <vector>
37
38using namespacellvm;
39
40/// CreateGlobalString - Make a new global variable with an initializer that
41/// has array of i8 type filled in with the nul terminated string value
42/// specified. If Name is specified, it is the name of the global variable
43/// created.
44GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
45constTwine &Name,
46unsignedAddressSpace,
47Module *M,bool AddNull) {
48Constant *StrConstant =ConstantDataArray::getString(Context, Str, AddNull);
49if (!M)
50 M =BB->getParent()->getParent();
51auto *GV =newGlobalVariable(
52 *M, StrConstant->getType(),true,GlobalValue::PrivateLinkage,
53 StrConstant,Name,nullptr,GlobalVariable::NotThreadLocal,AddressSpace);
54 GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
55 GV->setAlignment(Align(1));
56return GV;
57}
58
59Type *IRBuilderBase::getCurrentFunctionReturnType() const{
60assert(BB &&BB->getParent() &&"No current function!");
61returnBB->getParent()->getReturnType();
62}
63
64DebugLocIRBuilderBase::getCurrentDebugLocation() const{
65for (auto &KV : MetadataToCopy)
66if (KV.first == LLVMContext::MD_dbg)
67return {cast<DILocation>(KV.second)};
68
69return {};
70}
71voidIRBuilderBase::SetInstDebugLocation(Instruction *I) const{
72for (constauto &KV : MetadataToCopy)
73if (KV.first == LLVMContext::MD_dbg) {
74I->setDebugLoc(DebugLoc(KV.second));
75return;
76 }
77}
78
79CallInst *
80IRBuilderBase::createCallHelper(Function *Callee,ArrayRef<Value *> Ops,
81constTwine &Name,FMFSourceFMFSource,
82ArrayRef<OperandBundleDef> OpBundles) {
83CallInst *CI =CreateCall(Callee, Ops, OpBundles,Name);
84if (isa<FPMathOperator>(CI))
85 CI->setFastMathFlags(FMFSource.get(FMF));
86return CI;
87}
88
89Value *IRBuilderBase::CreateVScale(Constant *Scaling,constTwine &Name) {
90assert(isa<ConstantInt>(Scaling) &&"Expected constant integer");
91if (cast<ConstantInt>(Scaling)->isZero())
92return Scaling;
93CallInst *CI =
94CreateIntrinsic(Intrinsic::vscale, {Scaling->getType()}, {}, {},Name);
95return cast<ConstantInt>(Scaling)->isOne() ? CI :CreateMul(CI, Scaling);
96}
97
98Value *IRBuilderBase::CreateElementCount(Type *DstType,ElementCount EC) {
99Constant *MinEC = ConstantInt::get(DstType, EC.getKnownMinValue());
100return EC.isScalable() ?CreateVScale(MinEC) : MinEC;
101}
102
103Value *IRBuilderBase::CreateTypeSize(Type *DstType,TypeSizeSize) {
104Constant *MinSize = ConstantInt::get(DstType,Size.getKnownMinValue());
105returnSize.isScalable() ?CreateVScale(MinSize) : MinSize;
106}
107
108Value *IRBuilderBase::CreateStepVector(Type *DstType,constTwine &Name) {
109Type *STy = DstType->getScalarType();
110if (isa<ScalableVectorType>(DstType)) {
111Type *StepVecType = DstType;
112// TODO: We expect this special case (element type < 8 bits) to be
113// temporary - once the intrinsic properly supports < 8 bits this code
114// can be removed.
115if (STy->getScalarSizeInBits() < 8)
116 StepVecType =
117VectorType::get(getInt8Ty(), cast<ScalableVectorType>(DstType));
118Value *Res =CreateIntrinsic(Intrinsic::stepvector, {StepVecType}, {},
119nullptr,Name);
120if (StepVecType != DstType)
121 Res =CreateTrunc(Res, DstType);
122return Res;
123 }
124
125unsigned NumEls = cast<FixedVectorType>(DstType)->getNumElements();
126
127// Create a vector of consecutive numbers from zero to VF.
128SmallVector<Constant *, 8> Indices;
129for (unsigned i = 0; i < NumEls; ++i)
130 Indices.push_back(ConstantInt::get(STy, i));
131
132// Add the consecutive indices to the vector value.
133returnConstantVector::get(Indices);
134}
135
136CallInst *IRBuilderBase::CreateMemSet(Value *Ptr,Value *Val,Value *Size,
137MaybeAlignAlign,bool isVolatile,
138MDNode *TBAATag,MDNode *ScopeTag,
139MDNode *NoAliasTag) {
140Value *Ops[] = {Ptr, Val,Size,getInt1(isVolatile)};
141Type *Tys[] = {Ptr->getType(),Size->getType()};
142
143CallInst *CI =CreateIntrinsic(Intrinsic::memset, Tys, Ops);
144
145if (Align)
146 cast<MemSetInst>(CI)->setDestAlignment(*Align);
147
148// Set the TBAA info if present.
149if (TBAATag)
150 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
151
152if (ScopeTag)
153 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
154
155if (NoAliasTag)
156 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
157
158return CI;
159}
160
161CallInst *IRBuilderBase::CreateMemSetInline(Value *Dst,MaybeAlign DstAlign,
162Value *Val,Value *Size,
163bool IsVolatile,MDNode *TBAATag,
164MDNode *ScopeTag,
165MDNode *NoAliasTag) {
166Value *Ops[] = {Dst, Val,Size,getInt1(IsVolatile)};
167Type *Tys[] = {Dst->getType(),Size->getType()};
168
169CallInst *CI =CreateIntrinsic(Intrinsic::memset_inline, Tys, Ops);
170
171if (DstAlign)
172 cast<MemSetInlineInst>(CI)->setDestAlignment(*DstAlign);
173
174// Set the TBAA info if present.
175if (TBAATag)
176 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
177
178if (ScopeTag)
179 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
180
181if (NoAliasTag)
182 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
183
184return CI;
185}
186
187CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemSet(
188Value *Ptr,Value *Val,Value *Size,Align Alignment,uint32_t ElementSize,
189MDNode *TBAATag,MDNode *ScopeTag,MDNode *NoAliasTag) {
190
191Value *Ops[] = {Ptr, Val,Size,getInt32(ElementSize)};
192Type *Tys[] = {Ptr->getType(),Size->getType()};
193
194CallInst *CI =
195CreateIntrinsic(Intrinsic::memset_element_unordered_atomic, Tys, Ops);
196
197 cast<AtomicMemSetInst>(CI)->setDestAlignment(Alignment);
198
199// Set the TBAA info if present.
200if (TBAATag)
201 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
202
203if (ScopeTag)
204 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
205
206if (NoAliasTag)
207 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
208
209return CI;
210}
211
212CallInst *IRBuilderBase::CreateMemTransferInst(
213Intrinsic::ID IntrID,Value *Dst,MaybeAlign DstAlign,Value *Src,
214MaybeAlign SrcAlign,Value *Size,bool isVolatile,MDNode *TBAATag,
215MDNode *TBAAStructTag,MDNode *ScopeTag,MDNode *NoAliasTag) {
216assert((IntrID == Intrinsic::memcpy || IntrID == Intrinsic::memcpy_inline ||
217 IntrID == Intrinsic::memmove) &&
218"Unexpected intrinsic ID");
219Value *Ops[] = {Dst, Src,Size,getInt1(isVolatile)};
220Type *Tys[] = {Dst->getType(), Src->getType(),Size->getType()};
221
222CallInst *CI =CreateIntrinsic(IntrID, Tys, Ops);
223
224auto* MCI = cast<MemTransferInst>(CI);
225if (DstAlign)
226 MCI->setDestAlignment(*DstAlign);
227if (SrcAlign)
228 MCI->setSourceAlignment(*SrcAlign);
229
230// Set the TBAA info if present.
231if (TBAATag)
232 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
233
234// Set the TBAA Struct info if present.
235if (TBAAStructTag)
236 CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
237
238if (ScopeTag)
239 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
240
241if (NoAliasTag)
242 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
243
244return CI;
245}
246
247CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
248Value *Dst,Align DstAlign,Value *Src,Align SrcAlign,Value *Size,
249uint32_t ElementSize,MDNode *TBAATag,MDNode *TBAAStructTag,
250MDNode *ScopeTag,MDNode *NoAliasTag) {
251assert(DstAlign >= ElementSize &&
252"Pointer alignment must be at least element size");
253assert(SrcAlign >= ElementSize &&
254"Pointer alignment must be at least element size");
255Value *Ops[] = {Dst, Src,Size,getInt32(ElementSize)};
256Type *Tys[] = {Dst->getType(), Src->getType(),Size->getType()};
257
258CallInst *CI =
259CreateIntrinsic(Intrinsic::memcpy_element_unordered_atomic, Tys, Ops);
260
261// Set the alignment of the pointer args.
262auto *AMCI = cast<AtomicMemCpyInst>(CI);
263 AMCI->setDestAlignment(DstAlign);
264 AMCI->setSourceAlignment(SrcAlign);
265
266// Set the TBAA info if present.
267if (TBAATag)
268 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
269
270// Set the TBAA Struct info if present.
271if (TBAAStructTag)
272 CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
273
274if (ScopeTag)
275 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
276
277if (NoAliasTag)
278 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
279
280return CI;
281}
282
283/// isConstantOne - Return true only if val is constant int 1
284staticboolisConstantOne(constValue *Val) {
285assert(Val &&"isConstantOne does not work with nullptr Val");
286constConstantInt *CVal = dyn_cast<ConstantInt>(Val);
287return CVal && CVal->isOne();
288}
289
290CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy,Type *AllocTy,
291Value *AllocSize,Value *ArraySize,
292ArrayRef<OperandBundleDef> OpB,
293Function *MallocF,constTwine &Name) {
294// malloc(type) becomes:
295// i8* malloc(typeSize)
296// malloc(type, arraySize) becomes:
297// i8* malloc(typeSize*arraySize)
298if (!ArraySize)
299 ArraySize = ConstantInt::get(IntPtrTy, 1);
300elseif (ArraySize->getType() != IntPtrTy)
301 ArraySize =CreateIntCast(ArraySize, IntPtrTy,false);
302
303if (!isConstantOne(ArraySize)) {
304if (isConstantOne(AllocSize)) {
305 AllocSize = ArraySize;// Operand * 1 = Operand
306 }else {
307// Multiply type size by the array size...
308 AllocSize =CreateMul(ArraySize, AllocSize,"mallocsize");
309 }
310 }
311
312assert(AllocSize->getType() == IntPtrTy &&"malloc arg is wrong size");
313// Create the call to Malloc.
314Module *M =BB->getParent()->getParent();
315Type *BPTy =PointerType::getUnqual(Context);
316FunctionCallee MallocFunc = MallocF;
317if (!MallocFunc)
318// prototype malloc as "void *malloc(size_t)"
319 MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy);
320CallInst *MCall =CreateCall(MallocFunc, AllocSize, OpB,Name);
321
322 MCall->setTailCall();
323if (Function *F = dyn_cast<Function>(MallocFunc.getCallee())) {
324 MCall->setCallingConv(F->getCallingConv());
325F->setReturnDoesNotAlias();
326 }
327
328assert(!MCall->getType()->isVoidTy() &&"Malloc has void return type");
329
330return MCall;
331}
332
333CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy,Type *AllocTy,
334Value *AllocSize,Value *ArraySize,
335Function *MallocF,constTwine &Name) {
336
337returnCreateMalloc(IntPtrTy, AllocTy, AllocSize, ArraySize, {}, MallocF,
338Name);
339}
340
341/// CreateFree - Generate the IR for a call to the builtin free function.
342CallInst *IRBuilderBase::CreateFree(Value *Source,
343ArrayRef<OperandBundleDef> Bundles) {
344assert(Source->getType()->isPointerTy() &&
345"Can not free something of nonpointer type!");
346
347Module *M =BB->getParent()->getParent();
348
349Type *VoidTy =Type::getVoidTy(M->getContext());
350Type *VoidPtrTy =PointerType::getUnqual(M->getContext());
351// prototype free as "void free(void*)"
352FunctionCallee FreeFunc = M->getOrInsertFunction("free", VoidTy, VoidPtrTy);
353CallInst *Result =CreateCall(FreeFunc, Source, Bundles,"");
354 Result->setTailCall();
355if (Function *F = dyn_cast<Function>(FreeFunc.getCallee()))
356 Result->setCallingConv(F->getCallingConv());
357
358return Result;
359}
360
361CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemMove(
362Value *Dst,Align DstAlign,Value *Src,Align SrcAlign,Value *Size,
363uint32_t ElementSize,MDNode *TBAATag,MDNode *TBAAStructTag,
364MDNode *ScopeTag,MDNode *NoAliasTag) {
365assert(DstAlign >= ElementSize &&
366"Pointer alignment must be at least element size");
367assert(SrcAlign >= ElementSize &&
368"Pointer alignment must be at least element size");
369Value *Ops[] = {Dst, Src,Size,getInt32(ElementSize)};
370Type *Tys[] = {Dst->getType(), Src->getType(),Size->getType()};
371
372CallInst *CI =
373CreateIntrinsic(Intrinsic::memmove_element_unordered_atomic, Tys, Ops);
374
375// Set the alignment of the pointer args.
376 CI->addParamAttr(0,Attribute::getWithAlignment(CI->getContext(), DstAlign));
377 CI->addParamAttr(1,Attribute::getWithAlignment(CI->getContext(), SrcAlign));
378
379// Set the TBAA info if present.
380if (TBAATag)
381 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
382
383// Set the TBAA Struct info if present.
384if (TBAAStructTag)
385 CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
386
387if (ScopeTag)
388 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
389
390if (NoAliasTag)
391 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
392
393return CI;
394}
395
396CallInst *IRBuilderBase::getReductionIntrinsic(Intrinsic::IDID,Value *Src) {
397Value *Ops[] = {Src};
398Type *Tys[] = { Src->getType() };
399returnCreateIntrinsic(ID, Tys, Ops);
400}
401
402CallInst *IRBuilderBase::CreateFAddReduce(Value *Acc,Value *Src) {
403Value *Ops[] = {Acc, Src};
404returnCreateIntrinsic(Intrinsic::vector_reduce_fadd, {Src->getType()}, Ops);
405}
406
407CallInst *IRBuilderBase::CreateFMulReduce(Value *Acc,Value *Src) {
408Value *Ops[] = {Acc, Src};
409returnCreateIntrinsic(Intrinsic::vector_reduce_fmul, {Src->getType()}, Ops);
410}
411
412CallInst *IRBuilderBase::CreateAddReduce(Value *Src) {
413return getReductionIntrinsic(Intrinsic::vector_reduce_add, Src);
414}
415
416CallInst *IRBuilderBase::CreateMulReduce(Value *Src) {
417return getReductionIntrinsic(Intrinsic::vector_reduce_mul, Src);
418}
419
420CallInst *IRBuilderBase::CreateAndReduce(Value *Src) {
421return getReductionIntrinsic(Intrinsic::vector_reduce_and, Src);
422}
423
424CallInst *IRBuilderBase::CreateOrReduce(Value *Src) {
425return getReductionIntrinsic(Intrinsic::vector_reduce_or, Src);
426}
427
428CallInst *IRBuilderBase::CreateXorReduce(Value *Src) {
429return getReductionIntrinsic(Intrinsic::vector_reduce_xor, Src);
430}
431
432CallInst *IRBuilderBase::CreateIntMaxReduce(Value *Src,bool IsSigned) {
433autoID =
434 IsSigned ? Intrinsic::vector_reduce_smax : Intrinsic::vector_reduce_umax;
435return getReductionIntrinsic(ID, Src);
436}
437
438CallInst *IRBuilderBase::CreateIntMinReduce(Value *Src,bool IsSigned) {
439autoID =
440 IsSigned ? Intrinsic::vector_reduce_smin : Intrinsic::vector_reduce_umin;
441return getReductionIntrinsic(ID, Src);
442}
443
444CallInst *IRBuilderBase::CreateFPMaxReduce(Value *Src) {
445return getReductionIntrinsic(Intrinsic::vector_reduce_fmax, Src);
446}
447
448CallInst *IRBuilderBase::CreateFPMinReduce(Value *Src) {
449return getReductionIntrinsic(Intrinsic::vector_reduce_fmin, Src);
450}
451
452CallInst *IRBuilderBase::CreateFPMaximumReduce(Value *Src) {
453return getReductionIntrinsic(Intrinsic::vector_reduce_fmaximum, Src);
454}
455
456CallInst *IRBuilderBase::CreateFPMinimumReduce(Value *Src) {
457return getReductionIntrinsic(Intrinsic::vector_reduce_fminimum, Src);
458}
459
460CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr,ConstantInt *Size) {
461assert(isa<PointerType>(Ptr->getType()) &&
462"lifetime.start only applies to pointers.");
463if (!Size)
464Size =getInt64(-1);
465else
466assert(Size->getType() ==getInt64Ty() &&
467"lifetime.start requires the size to be an i64");
468Value *Ops[] = {Size,Ptr };
469returnCreateIntrinsic(Intrinsic::lifetime_start, {Ptr->getType()}, Ops);
470}
471
472CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr,ConstantInt *Size) {
473assert(isa<PointerType>(Ptr->getType()) &&
474"lifetime.end only applies to pointers.");
475if (!Size)
476Size =getInt64(-1);
477else
478assert(Size->getType() ==getInt64Ty() &&
479"lifetime.end requires the size to be an i64");
480Value *Ops[] = {Size,Ptr };
481returnCreateIntrinsic(Intrinsic::lifetime_end, {Ptr->getType()}, Ops);
482}
483
484CallInst *IRBuilderBase::CreateInvariantStart(Value *Ptr,ConstantInt *Size) {
485
486assert(isa<PointerType>(Ptr->getType()) &&
487"invariant.start only applies to pointers.");
488if (!Size)
489Size =getInt64(-1);
490else
491assert(Size->getType() ==getInt64Ty() &&
492"invariant.start requires the size to be an i64");
493
494Value *Ops[] = {Size,Ptr};
495// Fill in the single overloaded type: memory object type.
496Type *ObjectPtr[1] = {Ptr->getType()};
497returnCreateIntrinsic(Intrinsic::invariant_start, ObjectPtr, Ops);
498}
499
500staticMaybeAligngetAlign(Value *Ptr) {
501if (auto *O = dyn_cast<GlobalObject>(Ptr))
502return O->getAlign();
503if (auto *A = dyn_cast<GlobalAlias>(Ptr))
504returnA->getAliaseeObject()->getAlign();
505return {};
506}
507
508CallInst *IRBuilderBase::CreateThreadLocalAddress(Value *Ptr) {
509assert(isa<GlobalValue>(Ptr) && cast<GlobalValue>(Ptr)->isThreadLocal() &&
510"threadlocal_address only applies to thread local variables.");
511CallInst *CI =CreateIntrinsic(llvm::Intrinsic::threadlocal_address,
512 {Ptr->getType()}, {Ptr});
513if (MaybeAlignA =getAlign(Ptr)) {
514 CI->addParamAttr(0,Attribute::getWithAlignment(CI->getContext(), *A));
515 CI->addRetAttr(Attribute::getWithAlignment(CI->getContext(), *A));
516 }
517return CI;
518}
519
520CallInst *
521IRBuilderBase::CreateAssumption(Value *Cond,
522ArrayRef<OperandBundleDef> OpBundles) {
523assert(Cond->getType() ==getInt1Ty() &&
524"an assumption condition must be of type i1");
525
526Value *Ops[] = {Cond };
527Module *M =BB->getParent()->getParent();
528Function *FnAssume =Intrinsic::getOrInsertDeclaration(M, Intrinsic::assume);
529returnCreateCall(FnAssume, Ops, OpBundles);
530}
531
532Instruction *IRBuilderBase::CreateNoAliasScopeDeclaration(Value *Scope) {
533returnCreateIntrinsic(Intrinsic::experimental_noalias_scope_decl, {},
534 {Scope});
535}
536
537/// Create a call to a Masked Load intrinsic.
538/// \p Ty - vector type to load
539/// \p Ptr - base pointer for the load
540/// \p Alignment - alignment of the source location
541/// \p Mask - vector of booleans which indicates what vector lanes should
542/// be accessed in memory
543/// \p PassThru - pass-through value that is used to fill the masked-off lanes
544/// of the result
545/// \p Name - name of the result variable
546CallInst *IRBuilderBase::CreateMaskedLoad(Type *Ty,Value *Ptr,Align Alignment,
547Value *Mask,Value *PassThru,
548constTwine &Name) {
549auto *PtrTy = cast<PointerType>(Ptr->getType());
550assert(Ty->isVectorTy() &&"Type should be vector");
551assert(Mask &&"Mask should not be all-ones (null)");
552if (!PassThru)
553 PassThru =PoisonValue::get(Ty);
554Type *OverloadedTypes[] = { Ty, PtrTy };
555Value *Ops[] = {Ptr,getInt32(Alignment.value()), Mask, PassThru};
556return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
557 OverloadedTypes,Name);
558}
559
560/// Create a call to a Masked Store intrinsic.
561/// \p Val - data to be stored,
562/// \p Ptr - base pointer for the store
563/// \p Alignment - alignment of the destination location
564/// \p Mask - vector of booleans which indicates what vector lanes should
565/// be accessed in memory
566CallInst *IRBuilderBase::CreateMaskedStore(Value *Val,Value *Ptr,
567Align Alignment,Value *Mask) {
568auto *PtrTy = cast<PointerType>(Ptr->getType());
569Type *DataTy = Val->getType();
570assert(DataTy->isVectorTy() &&"Val should be a vector");
571assert(Mask &&"Mask should not be all-ones (null)");
572Type *OverloadedTypes[] = { DataTy, PtrTy };
573Value *Ops[] = {Val,Ptr,getInt32(Alignment.value()), Mask};
574return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
575}
576
577/// Create a call to a Masked intrinsic, with given intrinsic Id,
578/// an array of operands - Ops, and an array of overloaded types -
579/// OverloadedTypes.
580CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
581ArrayRef<Value *> Ops,
582ArrayRef<Type *> OverloadedTypes,
583constTwine &Name) {
584returnCreateIntrinsic(Id, OverloadedTypes, Ops, {},Name);
585}
586
587/// Create a call to a Masked Gather intrinsic.
588/// \p Ty - vector type to gather
589/// \p Ptrs - vector of pointers for loading
590/// \p Align - alignment for one element
591/// \p Mask - vector of booleans which indicates what vector lanes should
592/// be accessed in memory
593/// \p PassThru - pass-through value that is used to fill the masked-off lanes
594/// of the result
595/// \p Name - name of the result variable
596CallInst *IRBuilderBase::CreateMaskedGather(Type *Ty,Value *Ptrs,
597Align Alignment,Value *Mask,
598Value *PassThru,
599constTwine &Name) {
600auto *VecTy = cast<VectorType>(Ty);
601ElementCount NumElts = VecTy->getElementCount();
602auto *PtrsTy = cast<VectorType>(Ptrs->getType());
603assert(NumElts == PtrsTy->getElementCount() &&"Element count mismatch");
604
605if (!Mask)
606 Mask =getAllOnesMask(NumElts);
607
608if (!PassThru)
609 PassThru =PoisonValue::get(Ty);
610
611Type *OverloadedTypes[] = {Ty, PtrsTy};
612Value *Ops[] = {Ptrs,getInt32(Alignment.value()), Mask, PassThru};
613
614// We specify only one type when we create this intrinsic. Types of other
615// arguments are derived from this type.
616return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, OverloadedTypes,
617Name);
618}
619
620/// Create a call to a Masked Scatter intrinsic.
621/// \p Data - data to be stored,
622/// \p Ptrs - the vector of pointers, where the \p Data elements should be
623/// stored
624/// \p Align - alignment for one element
625/// \p Mask - vector of booleans which indicates what vector lanes should
626/// be accessed in memory
627CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data,Value *Ptrs,
628Align Alignment,Value *Mask) {
629auto *PtrsTy = cast<VectorType>(Ptrs->getType());
630auto *DataTy = cast<VectorType>(Data->getType());
631ElementCount NumElts = PtrsTy->getElementCount();
632
633if (!Mask)
634 Mask =getAllOnesMask(NumElts);
635
636Type *OverloadedTypes[] = {DataTy, PtrsTy};
637Value *Ops[] = {Data, Ptrs,getInt32(Alignment.value()), Mask};
638
639// We specify only one type when we create this intrinsic. Types of other
640// arguments are derived from this type.
641return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, OverloadedTypes);
642}
643
644/// Create a call to Masked Expand Load intrinsic
645/// \p Ty - vector type to load
646/// \p Ptr - base pointer for the load
647/// \p Align - alignment of \p Ptr
648/// \p Mask - vector of booleans which indicates what vector lanes should
649/// be accessed in memory
650/// \p PassThru - pass-through value that is used to fill the masked-off lanes
651/// of the result
652/// \p Name - name of the result variable
653CallInst *IRBuilderBase::CreateMaskedExpandLoad(Type *Ty,Value *Ptr,
654MaybeAlignAlign,Value *Mask,
655Value *PassThru,
656constTwine &Name) {
657assert(Ty->isVectorTy() &&"Type should be vector");
658assert(Mask &&"Mask should not be all-ones (null)");
659if (!PassThru)
660 PassThru =PoisonValue::get(Ty);
661Type *OverloadedTypes[] = {Ty};
662Value *Ops[] = {Ptr, Mask, PassThru};
663CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_expandload, Ops,
664 OverloadedTypes,Name);
665if (Align)
666 CI->addParamAttr(0,Attribute::getWithAlignment(CI->getContext(), *Align));
667return CI;
668}
669
670/// Create a call to Masked Compress Store intrinsic
671/// \p Val - data to be stored,
672/// \p Ptr - base pointer for the store
673/// \p Align - alignment of \p Ptr
674/// \p Mask - vector of booleans which indicates what vector lanes should
675/// be accessed in memory
676CallInst *IRBuilderBase::CreateMaskedCompressStore(Value *Val,Value *Ptr,
677MaybeAlignAlign,
678Value *Mask) {
679Type *DataTy = Val->getType();
680assert(DataTy->isVectorTy() &&"Val should be a vector");
681assert(Mask &&"Mask should not be all-ones (null)");
682Type *OverloadedTypes[] = {DataTy};
683Value *Ops[] = {Val,Ptr, Mask};
684CallInst *CI = CreateMaskedIntrinsic(Intrinsic::masked_compressstore, Ops,
685 OverloadedTypes);
686if (Align)
687 CI->addParamAttr(1,Attribute::getWithAlignment(CI->getContext(), *Align));
688return CI;
689}
690
691template <typename T0>
692static std::vector<Value *>
693getStatepointArgs(IRBuilderBase &B,uint64_tID,uint32_t NumPatchBytes,
694Value *ActualCallee,uint32_t Flags,ArrayRef<T0> CallArgs) {
695 std::vector<Value *> Args;
696 Args.push_back(B.getInt64(ID));
697 Args.push_back(B.getInt32(NumPatchBytes));
698 Args.push_back(ActualCallee);
699 Args.push_back(B.getInt32(CallArgs.size()));
700 Args.push_back(B.getInt32(Flags));
701llvm::append_range(Args, CallArgs);
702// GC Transition and Deopt args are now always handled via operand bundle.
703// They will be removed from the signature of gc.statepoint shortly.
704 Args.push_back(B.getInt32(0));
705 Args.push_back(B.getInt32(0));
706// GC args are now encoded in the gc-live operand bundle
707return Args;
708}
709
710template<typename T1,typename T2,typename T3>
711static std::vector<OperandBundleDef>
712getStatepointBundles(std::optional<ArrayRef<T1>> TransitionArgs,
713 std::optional<ArrayRef<T2>> DeoptArgs,
714ArrayRef<T3> GCArgs) {
715 std::vector<OperandBundleDef> Rval;
716if (DeoptArgs) {
717SmallVector<Value*, 16> DeoptValues;
718llvm::append_range(DeoptValues, *DeoptArgs);
719 Rval.emplace_back("deopt", DeoptValues);
720 }
721if (TransitionArgs) {
722SmallVector<Value*, 16> TransitionValues;
723llvm::append_range(TransitionValues, *TransitionArgs);
724 Rval.emplace_back("gc-transition", TransitionValues);
725 }
726if (GCArgs.size()) {
727SmallVector<Value*, 16> LiveValues;
728llvm::append_range(LiveValues, GCArgs);
729 Rval.emplace_back("gc-live", LiveValues);
730 }
731return Rval;
732}
733
734template <typename T0,typename T1,typename T2,typename T3>
735staticCallInst *CreateGCStatepointCallCommon(
736IRBuilderBase *Builder,uint64_tID,uint32_t NumPatchBytes,
737FunctionCallee ActualCallee,uint32_t Flags,ArrayRef<T0> CallArgs,
738 std::optional<ArrayRef<T1>> TransitionArgs,
739 std::optional<ArrayRef<T2>> DeoptArgs,ArrayRef<T3> GCArgs,
740constTwine &Name) {
741Module *M = Builder->GetInsertBlock()->getParent()->getParent();
742// Fill in the one generic type'd argument (the function is also vararg)
743Function *FnStatepoint =Intrinsic::getOrInsertDeclaration(
744 M, Intrinsic::experimental_gc_statepoint,
745 {ActualCallee.getCallee()->getType()});
746
747 std::vector<Value *> Args =getStatepointArgs(
748 *Builder,ID, NumPatchBytes, ActualCallee.getCallee(), Flags, CallArgs);
749
750CallInst *CI = Builder->CreateCall(
751 FnStatepoint, Args,
752getStatepointBundles(TransitionArgs, DeoptArgs, GCArgs),Name);
753 CI->addParamAttr(2,
754Attribute::get(Builder->getContext(), Attribute::ElementType,
755 ActualCallee.getFunctionType()));
756return CI;
757}
758
759CallInst *IRBuilderBase::CreateGCStatepointCall(
760uint64_tID,uint32_t NumPatchBytes,FunctionCallee ActualCallee,
761ArrayRef<Value *> CallArgs, std::optional<ArrayRef<Value *>> DeoptArgs,
762ArrayRef<Value *> GCArgs,constTwine &Name) {
763return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
764this,ID, NumPatchBytes, ActualCallee,uint32_t(StatepointFlags::None),
765 CallArgs, std::nullopt/* No Transition Args */, DeoptArgs, GCArgs,Name);
766}
767
768CallInst *IRBuilderBase::CreateGCStatepointCall(
769uint64_tID,uint32_t NumPatchBytes,FunctionCallee ActualCallee,
770uint32_t Flags,ArrayRef<Value *> CallArgs,
771 std::optional<ArrayRef<Use>> TransitionArgs,
772 std::optional<ArrayRef<Use>> DeoptArgs,ArrayRef<Value *> GCArgs,
773constTwine &Name) {
774return CreateGCStatepointCallCommon<Value *, Use, Use, Value *>(
775this,ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
776 DeoptArgs, GCArgs,Name);
777}
778
779CallInst *IRBuilderBase::CreateGCStatepointCall(
780uint64_tID,uint32_t NumPatchBytes,FunctionCallee ActualCallee,
781ArrayRef<Use> CallArgs, std::optional<ArrayRef<Value *>> DeoptArgs,
782ArrayRef<Value *> GCArgs,constTwine &Name) {
783return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
784this,ID, NumPatchBytes, ActualCallee,uint32_t(StatepointFlags::None),
785 CallArgs, std::nullopt, DeoptArgs, GCArgs,Name);
786}
787
788template <typename T0,typename T1,typename T2,typename T3>
789staticInvokeInst *CreateGCStatepointInvokeCommon(
790IRBuilderBase *Builder,uint64_tID,uint32_t NumPatchBytes,
791FunctionCallee ActualInvokee,BasicBlock *NormalDest,
792BasicBlock *UnwindDest,uint32_t Flags,ArrayRef<T0> InvokeArgs,
793 std::optional<ArrayRef<T1>> TransitionArgs,
794 std::optional<ArrayRef<T2>> DeoptArgs,ArrayRef<T3> GCArgs,
795constTwine &Name) {
796Module *M = Builder->GetInsertBlock()->getParent()->getParent();
797// Fill in the one generic type'd argument (the function is also vararg)
798Function *FnStatepoint =Intrinsic::getOrInsertDeclaration(
799 M, Intrinsic::experimental_gc_statepoint,
800 {ActualInvokee.getCallee()->getType()});
801
802 std::vector<Value *> Args =
803getStatepointArgs(*Builder,ID, NumPatchBytes, ActualInvokee.getCallee(),
804 Flags, InvokeArgs);
805
806InvokeInst *II = Builder->CreateInvoke(
807 FnStatepoint, NormalDest, UnwindDest, Args,
808getStatepointBundles(TransitionArgs, DeoptArgs, GCArgs),Name);
809II->addParamAttr(2,
810Attribute::get(Builder->getContext(), Attribute::ElementType,
811 ActualInvokee.getFunctionType()));
812returnII;
813}
814
815InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
816uint64_tID,uint32_t NumPatchBytes,FunctionCallee ActualInvokee,
817BasicBlock *NormalDest,BasicBlock *UnwindDest,
818ArrayRef<Value *> InvokeArgs, std::optional<ArrayRef<Value *>> DeoptArgs,
819ArrayRef<Value *> GCArgs,constTwine &Name) {
820return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
821this,ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
822uint32_t(StatepointFlags::None), InvokeArgs,
823 std::nullopt/* No Transition Args*/, DeoptArgs, GCArgs,Name);
824}
825
826InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
827uint64_tID,uint32_t NumPatchBytes,FunctionCallee ActualInvokee,
828BasicBlock *NormalDest,BasicBlock *UnwindDest,uint32_t Flags,
829ArrayRef<Value *> InvokeArgs, std::optional<ArrayRef<Use>> TransitionArgs,
830 std::optional<ArrayRef<Use>> DeoptArgs,ArrayRef<Value *> GCArgs,
831constTwine &Name) {
832return CreateGCStatepointInvokeCommon<Value *, Use, Use, Value *>(
833this,ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
834 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs,Name);
835}
836
837InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
838uint64_tID,uint32_t NumPatchBytes,FunctionCallee ActualInvokee,
839BasicBlock *NormalDest,BasicBlock *UnwindDest,ArrayRef<Use> InvokeArgs,
840 std::optional<ArrayRef<Value *>> DeoptArgs,ArrayRef<Value *> GCArgs,
841constTwine &Name) {
842return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
843this,ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
844uint32_t(StatepointFlags::None), InvokeArgs, std::nullopt, DeoptArgs,
845 GCArgs,Name);
846}
847
848CallInst *IRBuilderBase::CreateGCResult(Instruction *Statepoint,
849Type *ResultType,constTwine &Name) {
850Intrinsic::IDID = Intrinsic::experimental_gc_result;
851Type *Types[] = {ResultType};
852
853Value *Args[] = {Statepoint};
854returnCreateIntrinsic(ID, Types, Args, {},Name);
855}
856
857CallInst *IRBuilderBase::CreateGCRelocate(Instruction *Statepoint,
858int BaseOffset,int DerivedOffset,
859Type *ResultType,constTwine &Name) {
860Type *Types[] = {ResultType};
861
862Value *Args[] = {Statepoint,getInt32(BaseOffset),getInt32(DerivedOffset)};
863returnCreateIntrinsic(Intrinsic::experimental_gc_relocate, Types, Args, {},
864Name);
865}
866
867CallInst *IRBuilderBase::CreateGCGetPointerBase(Value *DerivedPtr,
868constTwine &Name) {
869Type *PtrTy = DerivedPtr->getType();
870returnCreateIntrinsic(Intrinsic::experimental_gc_get_pointer_base,
871 {PtrTy, PtrTy}, {DerivedPtr}, {},Name);
872}
873
874CallInst *IRBuilderBase::CreateGCGetPointerOffset(Value *DerivedPtr,
875constTwine &Name) {
876Type *PtrTy = DerivedPtr->getType();
877returnCreateIntrinsic(Intrinsic::experimental_gc_get_pointer_offset, {PtrTy},
878 {DerivedPtr}, {},Name);
879}
880
881CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::IDID,Value *V,
882FMFSourceFMFSource,
883constTwine &Name) {
884Module *M =BB->getModule();
885Function *Fn =Intrinsic::getOrInsertDeclaration(M,ID, {V->getType()});
886return createCallHelper(Fn, {V},Name,FMFSource);
887}
888
889Value *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::IDID,Value *LHS,
890Value *RHS,FMFSourceFMFSource,
891constTwine &Name) {
892Module *M =BB->getModule();
893Function *Fn =Intrinsic::getOrInsertDeclaration(M,ID, {LHS->getType()});
894if (Value *V =Folder.FoldBinaryIntrinsic(ID,LHS,RHS, Fn->getReturnType(),
895/*FMFSource=*/nullptr))
896return V;
897return createCallHelper(Fn, {LHS,RHS},Name,FMFSource);
898}
899
900CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::IDID,
901ArrayRef<Type *> Types,
902ArrayRef<Value *> Args,
903FMFSourceFMFSource,
904constTwine &Name) {
905Module *M =BB->getModule();
906Function *Fn =Intrinsic::getOrInsertDeclaration(M,ID, Types);
907return createCallHelper(Fn, Args,Name,FMFSource);
908}
909
910CallInst *IRBuilderBase::CreateIntrinsic(Type *RetTy,Intrinsic::IDID,
911ArrayRef<Value *> Args,
912FMFSourceFMFSource,
913constTwine &Name) {
914Module *M =BB->getModule();
915
916SmallVector<Intrinsic::IITDescriptor> Table;
917Intrinsic::getIntrinsicInfoTableEntries(ID, Table);
918ArrayRef<Intrinsic::IITDescriptor>TableRef(Table);
919
920SmallVector<Type *> ArgTys;
921 ArgTys.reserve(Args.size());
922for (auto &I : Args)
923 ArgTys.push_back(I->getType());
924FunctionType *FTy =FunctionType::get(RetTy, ArgTys,false);
925SmallVector<Type *> OverloadTys;
926Intrinsic::MatchIntrinsicTypesResult Res =
927 matchIntrinsicSignature(FTy,TableRef, OverloadTys);
928 (void)Res;
929assert(Res ==Intrinsic::MatchIntrinsicTypes_Match &&TableRef.empty() &&
930"Wrong types for intrinsic!");
931// TODO: Handle varargs intrinsics.
932
933Function *Fn =Intrinsic::getOrInsertDeclaration(M,ID, OverloadTys);
934return createCallHelper(Fn, Args,Name,FMFSource);
935}
936
937CallInst *IRBuilderBase::CreateConstrainedFPBinOp(
938Intrinsic::IDID,Value *L,Value *R,FMFSourceFMFSource,
939constTwine &Name,MDNode *FPMathTag, std::optional<RoundingMode> Rounding,
940 std::optional<fp::ExceptionBehavior> Except) {
941Value *RoundingV = getConstrainedFPRounding(Rounding);
942Value *ExceptV = getConstrainedFPExcept(Except);
943
944FastMathFlags UseFMF =FMFSource.get(FMF);
945
946CallInst *C =CreateIntrinsic(ID, {L->getType()},
947 {L, R, RoundingV, ExceptV},nullptr,Name);
948setConstrainedFPCallAttr(C);
949 setFPAttrs(C, FPMathTag, UseFMF);
950returnC;
951}
952
953CallInst *IRBuilderBase::CreateConstrainedFPUnroundedBinOp(
954Intrinsic::IDID,Value *L,Value *R,FMFSourceFMFSource,
955constTwine &Name,MDNode *FPMathTag,
956 std::optional<fp::ExceptionBehavior> Except) {
957Value *ExceptV = getConstrainedFPExcept(Except);
958
959FastMathFlags UseFMF =FMFSource.get(FMF);
960
961CallInst *C =
962CreateIntrinsic(ID, {L->getType()}, {L, R, ExceptV},nullptr,Name);
963setConstrainedFPCallAttr(C);
964 setFPAttrs(C, FPMathTag, UseFMF);
965returnC;
966}
967
968Value *IRBuilderBase::CreateNAryOp(unsigned Opc,ArrayRef<Value *> Ops,
969constTwine &Name,MDNode *FPMathTag) {
970if (Instruction::isBinaryOp(Opc)) {
971assert(Ops.size() == 2 &&"Invalid number of operands!");
972returnCreateBinOp(static_cast<Instruction::BinaryOps>(Opc),
973 Ops[0], Ops[1],Name, FPMathTag);
974 }
975if (Instruction::isUnaryOp(Opc)) {
976assert(Ops.size() == 1 &&"Invalid number of operands!");
977returnCreateUnOp(static_cast<Instruction::UnaryOps>(Opc),
978 Ops[0],Name, FPMathTag);
979 }
980llvm_unreachable("Unexpected opcode!");
981}
982
983CallInst *IRBuilderBase::CreateConstrainedFPCast(
984Intrinsic::IDID,Value *V,Type *DestTy,FMFSourceFMFSource,
985constTwine &Name,MDNode *FPMathTag, std::optional<RoundingMode> Rounding,
986 std::optional<fp::ExceptionBehavior> Except) {
987Value *ExceptV = getConstrainedFPExcept(Except);
988
989FastMathFlags UseFMF =FMFSource.get(FMF);
990
991CallInst *C;
992if (Intrinsic::hasConstrainedFPRoundingModeOperand(ID)) {
993Value *RoundingV = getConstrainedFPRounding(Rounding);
994C =CreateIntrinsic(ID, {DestTy, V->getType()}, {V, RoundingV, ExceptV},
995nullptr,Name);
996 }else
997C =CreateIntrinsic(ID, {DestTy, V->getType()}, {V, ExceptV},nullptr,
998Name);
999
1000setConstrainedFPCallAttr(C);
1001
1002if (isa<FPMathOperator>(C))
1003 setFPAttrs(C, FPMathTag, UseFMF);
1004returnC;
1005}
1006
1007Value *IRBuilderBase::CreateFCmpHelper(CmpInst::PredicateP,Value *LHS,
1008Value *RHS,constTwine &Name,
1009MDNode *FPMathTag,FMFSourceFMFSource,
1010bool IsSignaling) {
1011if (IsFPConstrained) {
1012autoID = IsSignaling ? Intrinsic::experimental_constrained_fcmps
1013 : Intrinsic::experimental_constrained_fcmp;
1014returnCreateConstrainedFPCmp(ID,P, LHS, RHS,Name);
1015 }
1016
1017if (auto *V =Folder.FoldCmp(P, LHS, RHS))
1018return V;
1019returnInsert(
1020 setFPAttrs(newFCmpInst(P, LHS, RHS), FPMathTag,FMFSource.get(FMF)),
1021Name);
1022}
1023
1024CallInst *IRBuilderBase::CreateConstrainedFPCmp(
1025Intrinsic::IDID,CmpInst::PredicateP,Value *L,Value *R,
1026constTwine &Name, std::optional<fp::ExceptionBehavior> Except) {
1027Value *PredicateV = getConstrainedFPPredicate(P);
1028Value *ExceptV = getConstrainedFPExcept(Except);
1029
1030CallInst *C =CreateIntrinsic(ID, {L->getType()},
1031 {L, R, PredicateV, ExceptV},nullptr,Name);
1032setConstrainedFPCallAttr(C);
1033returnC;
1034}
1035
1036CallInst *IRBuilderBase::CreateConstrainedFPCall(
1037Function *Callee,ArrayRef<Value *> Args,constTwine &Name,
1038 std::optional<RoundingMode> Rounding,
1039 std::optional<fp::ExceptionBehavior> Except) {
1040llvm::SmallVector<Value *, 6> UseArgs;
1041
1042append_range(UseArgs, Args);
1043
1044if (Intrinsic::hasConstrainedFPRoundingModeOperand(Callee->getIntrinsicID()))
1045 UseArgs.push_back(getConstrainedFPRounding(Rounding));
1046 UseArgs.push_back(getConstrainedFPExcept(Except));
1047
1048CallInst *C =CreateCall(Callee, UseArgs,Name);
1049setConstrainedFPCallAttr(C);
1050returnC;
1051}
1052
1053Value *IRBuilderBase::CreateSelect(Value *C,Value *True,Value *False,
1054constTwine &Name,Instruction *MDFrom) {
1055returnCreateSelectFMF(C, True, False, {},Name, MDFrom);
1056}
1057
1058Value *IRBuilderBase::CreateSelectFMF(Value *C,Value *True,Value *False,
1059FMFSourceFMFSource,constTwine &Name,
1060Instruction *MDFrom) {
1061if (auto *V =Folder.FoldSelect(C, True, False))
1062return V;
1063
1064SelectInst *Sel =SelectInst::Create(C, True, False);
1065if (MDFrom) {
1066MDNode *Prof = MDFrom->getMetadata(LLVMContext::MD_prof);
1067MDNode *Unpred = MDFrom->getMetadata(LLVMContext::MD_unpredictable);
1068 Sel = addBranchMetadata(Sel, Prof, Unpred);
1069 }
1070if (isa<FPMathOperator>(Sel))
1071 setFPAttrs(Sel,/*MDNode=*/nullptr,FMFSource.get(FMF));
1072returnInsert(Sel,Name);
1073}
1074
1075Value *IRBuilderBase::CreatePtrDiff(Type *ElemTy,Value *LHS,Value *RHS,
1076constTwine &Name) {
1077assert(LHS->getType() ==RHS->getType() &&
1078"Pointer subtraction operand types must match!");
1079Value *LHS_int =CreatePtrToInt(LHS,Type::getInt64Ty(Context));
1080Value *RHS_int =CreatePtrToInt(RHS,Type::getInt64Ty(Context));
1081Value *Difference =CreateSub(LHS_int, RHS_int);
1082returnCreateExactSDiv(Difference,ConstantExpr::getSizeOf(ElemTy),
1083Name);
1084}
1085
1086Value *IRBuilderBase::CreateLaunderInvariantGroup(Value *Ptr) {
1087assert(isa<PointerType>(Ptr->getType()) &&
1088"launder.invariant.group only applies to pointers.");
1089auto *PtrType =Ptr->getType();
1090Module *M =BB->getParent()->getParent();
1091Function *FnLaunderInvariantGroup =Intrinsic::getOrInsertDeclaration(
1092 M, Intrinsic::launder_invariant_group, {PtrType});
1093
1094assert(FnLaunderInvariantGroup->getReturnType() == PtrType &&
1095 FnLaunderInvariantGroup->getFunctionType()->getParamType(0) ==
1096 PtrType &&
1097"LaunderInvariantGroup should take and return the same type");
1098
1099returnCreateCall(FnLaunderInvariantGroup, {Ptr});
1100}
1101
1102Value *IRBuilderBase::CreateStripInvariantGroup(Value *Ptr) {
1103assert(isa<PointerType>(Ptr->getType()) &&
1104"strip.invariant.group only applies to pointers.");
1105
1106auto *PtrType =Ptr->getType();
1107Module *M =BB->getParent()->getParent();
1108Function *FnStripInvariantGroup =Intrinsic::getOrInsertDeclaration(
1109 M, Intrinsic::strip_invariant_group, {PtrType});
1110
1111assert(FnStripInvariantGroup->getReturnType() == PtrType &&
1112 FnStripInvariantGroup->getFunctionType()->getParamType(0) ==
1113 PtrType &&
1114"StripInvariantGroup should take and return the same type");
1115
1116returnCreateCall(FnStripInvariantGroup, {Ptr});
1117}
1118
1119Value *IRBuilderBase::CreateVectorReverse(Value *V,constTwine &Name) {
1120auto *Ty = cast<VectorType>(V->getType());
1121if (isa<ScalableVectorType>(Ty)) {
1122Module *M =BB->getParent()->getParent();
1123Function *F =
1124Intrinsic::getOrInsertDeclaration(M, Intrinsic::vector_reverse, Ty);
1125returnInsert(CallInst::Create(F, V),Name);
1126 }
1127// Keep the original behaviour for fixed vector
1128SmallVector<int, 8> ShuffleMask;
1129int NumElts = Ty->getElementCount().getKnownMinValue();
1130for (int i = 0; i < NumElts; ++i)
1131 ShuffleMask.push_back(NumElts - i - 1);
1132returnCreateShuffleVector(V, ShuffleMask,Name);
1133}
1134
1135Value *IRBuilderBase::CreateVectorSplice(Value *V1,Value *V2, int64_t Imm,
1136constTwine &Name) {
1137assert(isa<VectorType>(V1->getType()) &&"Unexpected type");
1138assert(V1->getType() == V2->getType() &&
1139"Splice expects matching operand types!");
1140
1141if (auto *VTy = dyn_cast<ScalableVectorType>(V1->getType())) {
1142Module *M =BB->getParent()->getParent();
1143Function *F =
1144Intrinsic::getOrInsertDeclaration(M, Intrinsic::vector_splice, VTy);
1145
1146Value *Ops[] = {V1, V2,getInt32(Imm)};
1147returnInsert(CallInst::Create(F, Ops),Name);
1148 }
1149
1150unsigned NumElts = cast<FixedVectorType>(V1->getType())->getNumElements();
1151assert(((-Imm <= NumElts) || (Imm < NumElts)) &&
1152"Invalid immediate for vector splice!");
1153
1154// Keep the original behaviour for fixed vector
1155unsignedIdx = (NumElts + Imm) % NumElts;
1156SmallVector<int, 8> Mask;
1157for (unsignedI = 0;I < NumElts; ++I)
1158 Mask.push_back(Idx +I);
1159
1160returnCreateShuffleVector(V1, V2, Mask);
1161}
1162
1163Value *IRBuilderBase::CreateVectorSplat(unsigned NumElts,Value *V,
1164constTwine &Name) {
1165auto EC =ElementCount::getFixed(NumElts);
1166returnCreateVectorSplat(EC, V,Name);
1167}
1168
1169Value *IRBuilderBase::CreateVectorSplat(ElementCount EC,Value *V,
1170constTwine &Name) {
1171assert(EC.isNonZero() &&"Cannot splat to an empty vector!");
1172
1173// First insert it into a poison vector so we can shuffle it.
1174Value *Poison =PoisonValue::get(VectorType::get(V->getType(), EC));
1175 V =CreateInsertElement(Poison, V,getInt64(0),Name +".splatinsert");
1176
1177// Shuffle the value across the desired number of elements.
1178SmallVector<int, 16> Zeros;
1179 Zeros.resize(EC.getKnownMinValue());
1180returnCreateShuffleVector(V, Zeros,Name +".splat");
1181}
1182
1183Value *IRBuilderBase::CreatePreserveArrayAccessIndex(
1184Type *ElTy,Value *Base,unsigned Dimension,unsigned LastIndex,
1185MDNode *DbgInfo) {
1186auto *BaseType =Base->getType();
1187assert(isa<PointerType>(BaseType) &&
1188"Invalid Base ptr type for preserve.array.access.index.");
1189
1190Value *LastIndexV =getInt32(LastIndex);
1191Constant *Zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
1192SmallVector<Value *, 4> IdxList(Dimension, Zero);
1193 IdxList.push_back(LastIndexV);
1194
1195Type *ResultType =GetElementPtrInst::getGEPReturnType(Base, IdxList);
1196
1197Value *DimV =getInt32(Dimension);
1198CallInst *Fn =
1199CreateIntrinsic(Intrinsic::preserve_array_access_index,
1200 {ResultType,BaseType}, {Base, DimV, LastIndexV});
1201 Fn->addParamAttr(
1202 0,Attribute::get(Fn->getContext(), Attribute::ElementType, ElTy));
1203if (DbgInfo)
1204 Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1205
1206return Fn;
1207}
1208
1209Value *IRBuilderBase::CreatePreserveUnionAccessIndex(
1210Value *Base,unsigned FieldIndex,MDNode *DbgInfo) {
1211assert(isa<PointerType>(Base->getType()) &&
1212"Invalid Base ptr type for preserve.union.access.index.");
1213auto *BaseType =Base->getType();
1214
1215Value *DIIndex =getInt32(FieldIndex);
1216CallInst *Fn =CreateIntrinsic(Intrinsic::preserve_union_access_index,
1217 {BaseType,BaseType}, {Base, DIIndex});
1218if (DbgInfo)
1219 Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1220
1221return Fn;
1222}
1223
1224Value *IRBuilderBase::CreatePreserveStructAccessIndex(
1225Type *ElTy,Value *Base,unsigned Index,unsigned FieldIndex,
1226MDNode *DbgInfo) {
1227auto *BaseType =Base->getType();
1228assert(isa<PointerType>(BaseType) &&
1229"Invalid Base ptr type for preserve.struct.access.index.");
1230
1231Value *GEPIndex =getInt32(Index);
1232Constant *Zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
1233Type *ResultType =
1234GetElementPtrInst::getGEPReturnType(Base, {Zero, GEPIndex});
1235
1236Value *DIIndex =getInt32(FieldIndex);
1237CallInst *Fn =
1238CreateIntrinsic(Intrinsic::preserve_struct_access_index,
1239 {ResultType,BaseType}, {Base, GEPIndex, DIIndex});
1240 Fn->addParamAttr(
1241 0,Attribute::get(Fn->getContext(), Attribute::ElementType, ElTy));
1242if (DbgInfo)
1243 Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
1244
1245return Fn;
1246}
1247
1248Value *IRBuilderBase::createIsFPClass(Value *FPNum,unsignedTest) {
1249ConstantInt *TestV =getInt32(Test);
1250returnCreateIntrinsic(Intrinsic::is_fpclass, {FPNum->getType()},
1251 {FPNum, TestV});
1252}
1253
1254CallInst *IRBuilderBase::CreateAlignmentAssumptionHelper(constDataLayout &DL,
1255Value *PtrValue,
1256Value *AlignValue,
1257Value *OffsetValue) {
1258SmallVector<Value *, 4> Vals({PtrValue, AlignValue});
1259if (OffsetValue)
1260 Vals.push_back(OffsetValue);
1261OperandBundleDefT<Value *> AlignOpB("align", Vals);
1262returnCreateAssumption(ConstantInt::getTrue(getContext()), {AlignOpB});
1263}
1264
1265CallInst *IRBuilderBase::CreateAlignmentAssumption(constDataLayout &DL,
1266Value *PtrValue,
1267unsigned Alignment,
1268Value *OffsetValue) {
1269assert(isa<PointerType>(PtrValue->getType()) &&
1270"trying to create an alignment assumption on a non-pointer?");
1271assert(Alignment != 0 &&"Invalid Alignment");
1272auto *PtrTy = cast<PointerType>(PtrValue->getType());
1273Type *IntPtrTy =getIntPtrTy(DL, PtrTy->getAddressSpace());
1274Value *AlignValue = ConstantInt::get(IntPtrTy, Alignment);
1275return CreateAlignmentAssumptionHelper(DL, PtrValue, AlignValue, OffsetValue);
1276}
1277
1278CallInst *IRBuilderBase::CreateAlignmentAssumption(constDataLayout &DL,
1279Value *PtrValue,
1280Value *Alignment,
1281Value *OffsetValue) {
1282assert(isa<PointerType>(PtrValue->getType()) &&
1283"trying to create an alignment assumption on a non-pointer?");
1284return CreateAlignmentAssumptionHelper(DL, PtrValue, Alignment, OffsetValue);
1285}
1286
1287IRBuilderDefaultInserter::~IRBuilderDefaultInserter() =default;
1288IRBuilderCallbackInserter::~IRBuilderCallbackInserter() =default;
1289IRBuilderFolder::~IRBuilderFolder() =default;
1290void ConstantFolder::anchor() {}
1291void NoFolder::anchor() {}
Poison
@ Poison
Definition:AArch64AsmPrinter.cpp:72
TableRef
ArrayRef< TableEntry > TableRef
Definition:AMDGPULibCalls.cpp:352
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
ArrayRef.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Casting.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
RetTy
return RetTy
Definition:DeadArgumentElimination.cpp:361
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
DebugInfoMetadata.h
DerivedTypes.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
GlobalValue.h
GlobalVariable.h
isConstantOne
static bool isConstantOne(const Value *Val)
isConstantOne - Return true only if val is constant int 1
Definition:IRBuilder.cpp:284
CreateGCStatepointInvokeCommon
static InvokeInst * CreateGCStatepointInvokeCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef< T0 > InvokeArgs, std::optional< ArrayRef< T1 > > TransitionArgs, std::optional< ArrayRef< T2 > > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Definition:IRBuilder.cpp:789
CreateGCStatepointCallCommon
static CallInst * CreateGCStatepointCallCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, std::optional< ArrayRef< T1 > > TransitionArgs, std::optional< ArrayRef< T2 > > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Definition:IRBuilder.cpp:735
getStatepointBundles
static std::vector< OperandBundleDef > getStatepointBundles(std::optional< ArrayRef< T1 > > TransitionArgs, std::optional< ArrayRef< T2 > > DeoptArgs, ArrayRef< T3 > GCArgs)
Definition:IRBuilder.cpp:712
getStatepointArgs
static std::vector< Value * > getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs)
Definition:IRBuilder.cpp:693
IRBuilder.h
Constant.h
Function.h
IntrinsicInst.h
Module.h
Module.h This file contains the declarations for the Module class.
Operator.h
Type.h
Value.h
Intrinsics.h
LLVMContext.h
isZero
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
Definition:Lint.cpp:557
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
II
uint64_t IntrinsicInst * II
Definition:NVVMIntrRange.cpp:51
NoFolder.h
P
#define P(N)
Cond
const SmallVectorImpl< MachineOperand > & Cond
Definition:RISCVRedundantCopyElimination.cpp:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Statepoint.h
getType
static SymbolRef::Type getType(const Symbol *Sym)
Definition:TapiFile.cpp:39
Ptr
@ Ptr
Definition:TargetLibraryInfo.cpp:77
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
BaseType
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition:ArrayRef.h:163
llvm::Attribute::get
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition:Attributes.cpp:95
llvm::Attribute::getWithAlignment
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition:Attributes.cpp:234
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition:BasicBlock.h:220
llvm::BasicBlock::getModule
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Definition:BasicBlock.cpp:292
llvm::CallBase::setCallingConv
void setCallingConv(CallingConv::ID CC)
Definition:InstrTypes.h:1403
llvm::CallBase::addRetAttr
void addRetAttr(Attribute::AttrKind Kind)
Adds the attribute to the return value.
Definition:InstrTypes.h:1484
llvm::CallBase::addParamAttr
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition:InstrTypes.h:1494
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition:Instructions.h:1479
llvm::CallInst::Create
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1514
llvm::CallInst::setTailCall
void setTailCall(bool IsTc=true)
Definition:Instructions.h:1602
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition:InstrTypes.h:673
llvm::ConstantDataArray::getString
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
Definition:Constants.cpp:2991
llvm::ConstantExpr::getSizeOf
static Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
Definition:Constants.cpp:2480
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition:Constants.h:83
llvm::ConstantInt::isOne
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
Definition:Constants.h:214
llvm::ConstantInt::getTrue
static ConstantInt * getTrue(LLVMContext &Context)
Definition:Constants.cpp:866
llvm::ConstantVector::get
static Constant * get(ArrayRef< Constant * > V)
Definition:Constants.cpp:1421
llvm::Constant
This is an important base class in LLVM.
Definition:Constant.h:42
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DebugLoc
A debug info location.
Definition:DebugLoc.h:33
llvm::ElementCount
Definition:TypeSize.h:300
llvm::ElementCount::getFixed
static constexpr ElementCount getFixed(ScalarTy MinVal)
Definition:TypeSize.h:311
llvm::FCmpInst
This instruction compares its operands according to the predicate given to the constructor.
Definition:Instructions.h:1379
llvm::FMFSource
This provides a helper for copying FMF from an instruction or setting specified flags.
Definition:IRBuilder.h:92
llvm::FMFSource::get
FastMathFlags get(FastMathFlags Default) const
Definition:IRBuilder.h:102
llvm::FastMathFlags
Convenience struct for specifying and reasoning about fast-math flags.
Definition:FMF.h:20
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition:DerivedTypes.h:170
llvm::FunctionCallee::getFunctionType
FunctionType * getFunctionType()
Definition:DerivedTypes.h:187
llvm::FunctionCallee::getCallee
Value * getCallee()
Definition:DerivedTypes.h:189
llvm::FunctionType
Class to represent function types.
Definition:DerivedTypes.h:105
llvm::FunctionType::getParamType
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition:DerivedTypes.h:137
llvm::FunctionType::get
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
llvm::Function
Definition:Function.h:63
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition:Function.h:216
llvm::Function::getReturnType
Type * getReturnType() const
Returns the type of the ret val.
Definition:Function.h:221
llvm::GetElementPtrInst::getGEPReturnType
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
Definition:Instructions.h:1059
llvm::GlobalValue::NotThreadLocal
@ NotThreadLocal
Definition:GlobalValue.h:197
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition:GlobalValue.h:657
llvm::GlobalValue::UnnamedAddr::Global
@ Global
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition:GlobalValue.h:60
llvm::GlobalVariable
Definition:GlobalVariable.h:39
llvm::IRBuilderBase
Common base class shared among various IRBuilders.
Definition:IRBuilder.h:113
llvm::IRBuilderBase::CreateExactSDiv
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition:IRBuilder.h:1443
llvm::IRBuilderBase::CreateElementUnorderedAtomicMemCpy
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memcpy between the specified pointers.
Definition:IRBuilder.cpp:247
llvm::IRBuilderBase::getInt1
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Definition:IRBuilder.h:480
llvm::IRBuilderBase::BB
BasicBlock * BB
Definition:IRBuilder.h:138
llvm::IRBuilderBase::CreatePtrDiff
Value * CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS, const Twine &Name="")
Return the i64 difference between two pointer values, dividing out the size of the pointed-to objects...
Definition:IRBuilder.cpp:1075
llvm::IRBuilderBase::CreateMulReduce
CallInst * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:416
llvm::IRBuilderBase::CreateFAddReduce
CallInst * CreateFAddReduce(Value *Acc, Value *Src)
Create a sequential vector fadd reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:402
llvm::IRBuilderBase::CreateVScale
Value * CreateVScale(Constant *Scaling, const Twine &Name="")
Create a call to llvm.vscale, multiplied by Scaling.
Definition:IRBuilder.cpp:89
llvm::IRBuilderBase::CreateLaunderInvariantGroup
Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
Definition:IRBuilder.cpp:1086
llvm::IRBuilderBase::CreateConstrainedFPUnroundedBinOp
CallInst * CreateConstrainedFPUnroundedBinOp(Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition:IRBuilder.cpp:953
llvm::IRBuilderBase::CreateInsertElement
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Definition:IRBuilder.h:2511
llvm::IRBuilderBase::CreateThreadLocalAddress
CallInst * CreateThreadLocalAddress(Value *Ptr)
Create a call to llvm.threadlocal.address intrinsic.
Definition:IRBuilder.cpp:508
llvm::IRBuilderBase::getInt1Ty
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Definition:IRBuilder.h:530
llvm::IRBuilderBase::CreateMaskedCompressStore
CallInst * CreateMaskedCompressStore(Value *Val, Value *Ptr, MaybeAlign Align, Value *Mask=nullptr)
Create a call to Masked Compress Store intrinsic.
Definition:IRBuilder.cpp:676
llvm::IRBuilderBase::getCurrentFunctionReturnType
Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
Definition:IRBuilder.cpp:59
llvm::IRBuilderBase::CreateGCGetPointerBase
CallInst * CreateGCGetPointerBase(Value *DerivedPtr, const Twine &Name="")
Create a call to the experimental.gc.pointer.base intrinsic to get the base pointer for the specified...
Definition:IRBuilder.cpp:867
llvm::IRBuilderBase::IsFPConstrained
bool IsFPConstrained
Definition:IRBuilder.h:147
llvm::IRBuilderBase::CreateGCStatepointCall
CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, ArrayRef< Value * > CallArgs, std::optional< ArrayRef< Value * > > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
Definition:IRBuilder.cpp:759
llvm::IRBuilderBase::CreateLifetimeStart
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.start intrinsic.
Definition:IRBuilder.cpp:460
llvm::IRBuilderBase::CreateConstrainedFPCmp
CallInst * CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name="", std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition:IRBuilder.cpp:1024
llvm::IRBuilderBase::CreateSelectFMF
Value * CreateSelectFMF(Value *C, Value *True, Value *False, FMFSource FMFSource, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition:IRBuilder.cpp:1058
llvm::IRBuilderBase::CreateAndReduce
CallInst * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:420
llvm::IRBuilderBase::CreateVectorSplice
Value * CreateVectorSplice(Value *V1, Value *V2, int64_t Imm, const Twine &Name="")
Return a vector splice intrinsic if using scalable vectors, otherwise return a shufflevector.
Definition:IRBuilder.cpp:1135
llvm::IRBuilderBase::CreateAssumption
CallInst * CreateAssumption(Value *Cond, ArrayRef< OperandBundleDef > OpBundles={})
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
Definition:IRBuilder.cpp:521
llvm::IRBuilderBase::CreateVectorSplat
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Definition:IRBuilder.cpp:1163
llvm::IRBuilderBase::CreatePreserveStructAccessIndex
Value * CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex, MDNode *DbgInfo)
Definition:IRBuilder.cpp:1224
llvm::IRBuilderBase::CreateAlignmentAssumption
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, unsigned Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer.
Definition:IRBuilder.cpp:1265
llvm::IRBuilderBase::CreateMaskedLoad
CallInst * CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
Definition:IRBuilder.cpp:546
llvm::IRBuilderBase::CreateConstrainedFPCall
CallInst * CreateConstrainedFPCall(Function *Callee, ArrayRef< Value * > Args, const Twine &Name="", std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition:IRBuilder.cpp:1036
llvm::IRBuilderBase::CreateMemSet
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
Definition:IRBuilder.h:614
llvm::IRBuilderBase::Context
LLVMContext & Context
Definition:IRBuilder.h:140
llvm::IRBuilderBase::CreateSelect
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition:IRBuilder.cpp:1053
llvm::IRBuilderBase::CreateInvoke
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Create an invoke instruction.
Definition:IRBuilder.h:1202
llvm::IRBuilderBase::CreateGCGetPointerOffset
CallInst * CreateGCGetPointerOffset(Value *DerivedPtr, const Twine &Name="")
Create a call to the experimental.gc.get.pointer.offset intrinsic to get the offset of the specified ...
Definition:IRBuilder.cpp:874
llvm::IRBuilderBase::CreateTypeSize
Value * CreateTypeSize(Type *DstType, TypeSize Size)
Create an expression which evaluates to the number of units in Size at runtime.
Definition:IRBuilder.cpp:103
llvm::IRBuilderBase::CreateAddReduce
CallInst * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:412
llvm::IRBuilderBase::CreateConstrainedFPBinOp
CallInst * CreateConstrainedFPBinOp(Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition:IRBuilder.cpp:937
llvm::IRBuilderBase::getIntPtrTy
IntegerType * getIntPtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type of an integer with size at least as big as that of a pointer in the given address spac...
Definition:IRBuilder.h:594
llvm::IRBuilderBase::GetInsertBlock
BasicBlock * GetInsertBlock() const
Definition:IRBuilder.h:193
llvm::IRBuilderBase::getInt64Ty
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Definition:IRBuilder.h:550
llvm::IRBuilderBase::CreateMemTransferInst
CallInst * CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition:IRBuilder.cpp:212
llvm::IRBuilderBase::CreateVectorReverse
Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
Definition:IRBuilder.cpp:1119
llvm::IRBuilderBase::CreateXorReduce
CallInst * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:428
llvm::IRBuilderBase::FMF
FastMathFlags FMF
Definition:IRBuilder.h:145
llvm::IRBuilderBase::getInt64
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition:IRBuilder.h:510
llvm::IRBuilderBase::getAllOnesMask
Value * getAllOnesMask(ElementCount NumElts)
Return an all true boolean vector (mask) with NumElts lanes.
Definition:IRBuilder.h:867
llvm::IRBuilderBase::CreateUnOp
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:1761
llvm::IRBuilderBase::CreateOrReduce
CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:424
llvm::IRBuilderBase::CreateMalloc
CallInst * CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF=nullptr, const Twine &Name="")
Definition:IRBuilder.cpp:290
llvm::IRBuilderBase::CreateFPMinReduce
CallInst * CreateFPMinReduce(Value *Src)
Create a vector float min reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:448
llvm::IRBuilderBase::CreateFPMaximumReduce
CallInst * CreateFPMaximumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:452
llvm::IRBuilderBase::CreateBinaryIntrinsic
Value * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type.
Definition:IRBuilder.cpp:889
llvm::IRBuilderBase::createIsFPClass
Value * createIsFPClass(Value *FPNum, unsigned Test)
Definition:IRBuilder.cpp:1248
llvm::IRBuilderBase::CreateIntrinsic
CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
Definition:IRBuilder.cpp:900
llvm::IRBuilderBase::CreateFPMaxReduce
CallInst * CreateFPMaxReduce(Value *Src)
Create a vector float max reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:444
llvm::IRBuilderBase::getInt32
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition:IRBuilder.h:505
llvm::IRBuilderBase::CreateFree
CallInst * CreateFree(Value *Source, ArrayRef< OperandBundleDef > Bundles={})
Generate the IR for a call to the builtin free function.
Definition:IRBuilder.cpp:342
llvm::IRBuilderBase::Insert
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Definition:IRBuilder.h:164
llvm::IRBuilderBase::getCurrentDebugLocation
DebugLoc getCurrentDebugLocation() const
Get location information used by debugging information.
Definition:IRBuilder.cpp:64
llvm::IRBuilderBase::CreateSub
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition:IRBuilder.h:1387
llvm::IRBuilderBase::CreateUnaryIntrinsic
CallInst * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
Definition:IRBuilder.cpp:881
llvm::IRBuilderBase::CreateNAryOp
Value * CreateNAryOp(unsigned Opc, ArrayRef< Value * > Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
Definition:IRBuilder.cpp:968
llvm::IRBuilderBase::CreateShuffleVector
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition:IRBuilder.h:2533
llvm::IRBuilderBase::getContext
LLVMContext & getContext() const
Definition:IRBuilder.h:195
llvm::IRBuilderBase::CreatePreserveUnionAccessIndex
Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
Definition:IRBuilder.cpp:1209
llvm::IRBuilderBase::CreateIntMaxReduce
CallInst * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:432
llvm::IRBuilderBase::CreateMaskedStore
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Definition:IRBuilder.cpp:566
llvm::IRBuilderBase::CreatePtrToInt
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Definition:IRBuilder.h:2142
llvm::IRBuilderBase::CreateCall
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:2449
llvm::IRBuilderBase::CreateGCResult
CallInst * CreateGCResult(Instruction *Statepoint, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.result intrinsic to extract the result from a call wrapped in a ...
Definition:IRBuilder.cpp:848
llvm::IRBuilderBase::CreateTrunc
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)
Definition:IRBuilder.h:2019
llvm::IRBuilderBase::CreateLifetimeEnd
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
Definition:IRBuilder.cpp:472
llvm::IRBuilderBase::CreateBinOp
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:1671
llvm::IRBuilderBase::CreateElementCount
Value * CreateElementCount(Type *DstType, ElementCount EC)
Create an expression which evaluates to the number of elements in EC at runtime.
Definition:IRBuilder.cpp:98
llvm::IRBuilderBase::CreateElementUnorderedAtomicMemMove
CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memmove between the specified pointers.
Definition:IRBuilder.cpp:361
llvm::IRBuilderBase::CreateIntCast
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Definition:IRBuilder.h:2225
llvm::IRBuilderBase::CreateIntMinReduce
CallInst * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:438
llvm::IRBuilderBase::setConstrainedFPCallAttr
void setConstrainedFPCallAttr(CallBase *I)
Definition:IRBuilder.h:380
llvm::IRBuilderBase::CreateGCStatepointInvoke
InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > InvokeArgs, std::optional< ArrayRef< Value * > > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
Definition:IRBuilder.cpp:815
llvm::IRBuilderBase::CreateMaskedExpandLoad
CallInst * CreateMaskedExpandLoad(Type *Ty, Value *Ptr, MaybeAlign Align, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Expand Load intrinsic.
Definition:IRBuilder.cpp:653
llvm::IRBuilderBase::Folder
const IRBuilderFolder & Folder
Definition:IRBuilder.h:141
llvm::IRBuilderBase::CreateMemSetInline
CallInst * CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, Value *Val, Value *Size, bool IsVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition:IRBuilder.cpp:161
llvm::IRBuilderBase::CreateElementUnorderedAtomicMemSet
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
Definition:IRBuilder.h:639
llvm::IRBuilderBase::CreateFMulReduce
CallInst * CreateFMulReduce(Value *Acc, Value *Src)
Create a sequential vector fmul reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:407
llvm::IRBuilderBase::SetInstDebugLocation
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Definition:IRBuilder.cpp:71
llvm::IRBuilderBase::getInt8Ty
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Definition:IRBuilder.h:535
llvm::IRBuilderBase::CreateGCRelocate
CallInst * CreateGCRelocate(Instruction *Statepoint, int BaseOffset, int DerivedOffset, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.relocate intrinsics to project the relocated value of one pointe...
Definition:IRBuilder.cpp:857
llvm::IRBuilderBase::CreateStepVector
Value * CreateStepVector(Type *DstType, const Twine &Name="")
Creates a vector of type DstType with the linear sequence <0, 1, ...>
Definition:IRBuilder.cpp:108
llvm::IRBuilderBase::CreatePreserveArrayAccessIndex
Value * CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex, MDNode *DbgInfo)
Definition:IRBuilder.cpp:1183
llvm::IRBuilderBase::CreateInvariantStart
CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
Definition:IRBuilder.cpp:484
llvm::IRBuilderBase::CreateMul
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition:IRBuilder.h:1404
llvm::IRBuilderBase::CreateNoAliasScopeDeclaration
Instruction * CreateNoAliasScopeDeclaration(Value *Scope)
Create a llvm.experimental.noalias.scope.decl intrinsic call.
Definition:IRBuilder.cpp:532
llvm::IRBuilderBase::CreateMaskedScatter
CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
Definition:IRBuilder.cpp:627
llvm::IRBuilderBase::CreateGlobalString
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0, Module *M=nullptr, bool AddNull=true)
Make a new global variable with initializer type i8*.
Definition:IRBuilder.cpp:44
llvm::IRBuilderBase::CreateFPMinimumReduce
CallInst * CreateFPMinimumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
Definition:IRBuilder.cpp:456
llvm::IRBuilderBase::CreateConstrainedFPCast
CallInst * CreateConstrainedFPCast(Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition:IRBuilder.cpp:983
llvm::IRBuilderBase::CreateStripInvariantGroup
Value * CreateStripInvariantGroup(Value *Ptr)
Create a strip.invariant.group intrinsic call.
Definition:IRBuilder.cpp:1102
llvm::IRBuilderBase::CreateMaskedGather
CallInst * CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
Definition:IRBuilder.cpp:596
llvm::IRBuilderCallbackInserter::~IRBuilderCallbackInserter
~IRBuilderCallbackInserter() override
llvm::IRBuilderDefaultInserter::~IRBuilderDefaultInserter
virtual ~IRBuilderDefaultInserter()
llvm::IRBuilderFolder::FoldCmp
virtual Value * FoldCmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const =0
llvm::IRBuilderFolder::FoldSelect
virtual Value * FoldSelect(Value *C, Value *True, Value *False) const =0
llvm::IRBuilderFolder::~IRBuilderFolder
virtual ~IRBuilderFolder()
llvm::IRBuilderFolder::FoldBinaryIntrinsic
virtual Value * FoldBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Type *Ty, Instruction *FMFSource=nullptr) const =0
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::isBinaryOp
bool isBinaryOp() const
Definition:Instruction.h:296
llvm::Instruction::setFastMathFlags
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
Definition:Instruction.cpp:601
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition:Instruction.h:407
llvm::Instruction::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition:Metadata.cpp:1679
llvm::Instruction::BinaryOps
BinaryOps
Definition:Instruction.h:989
llvm::Instruction::isUnaryOp
bool isUnaryOp() const
Definition:Instruction.h:295
llvm::Instruction::UnaryOps
UnaryOps
Definition:Instruction.h:982
llvm::InvokeInst
Invoke instruction.
Definition:Instructions.h:3670
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::OperandBundleDefT
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition:InstrTypes.h:1065
llvm::PointerType::getUnqual
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition:DerivedTypes.h:686
llvm::PoisonValue::get
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition:Constants.cpp:1878
llvm::SelectInst
This class represents the LLVM 'select' instruction.
Definition:Instructions.h:1657
llvm::SelectInst::Create
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)
Definition:Instructions.h:1682
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition:SmallVector.h:638
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::TypeSize
Definition:TypeSize.h:334
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::isVectorTy
bool isVectorTy() const
True if this is an instance of VectorType.
Definition:Type.h:270
llvm::Type::getScalarSizeInBits
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
llvm::Type::getInt64Ty
static IntegerType * getInt64Ty(LLVMContext &C)
llvm::Type::isVoidTy
bool isVoidTy() const
Return true if this is 'void'.
Definition:Type.h:139
llvm::Type::getScalarType
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition:Type.h:355
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition:Value.h:255
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition:Value.cpp:1075
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
uint32_t
uint64_t
unsigned
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::Intrinsic::getOrInsertDeclaration
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
Definition:Intrinsics.cpp:732
llvm::Intrinsic::getIntrinsicInfoTableEntries
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
Definition:Intrinsics.cpp:447
llvm::Intrinsic::MatchIntrinsicTypesResult
MatchIntrinsicTypesResult
Definition:Intrinsics.h:229
llvm::Intrinsic::MatchIntrinsicTypes_Match
@ MatchIntrinsicTypes_Match
Definition:Intrinsics.h:230
llvm::Intrinsic::hasConstrainedFPRoundingModeOperand
bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take ...
Definition:Intrinsics.cpp:775
llvm::NVPTXAS::AddressSpace
AddressSpace
Definition:NVPTXAddrSpace.h:20
llvm::sampleprof::Base
@ Base
Definition:Discriminator.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition:STLExtras.h:2115
llvm::getAlign
MaybeAlign getAlign(const Function &F, unsigned Index)
Definition:NVPTXUtilities.cpp:323
llvm::StatepointFlags::None
@ None
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::PGSOQueryType::Test
@ Test
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition:Alignment.h:39
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition:Alignment.h:85
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition:Alignment.h:117

Generated on Thu Jul 17 2025 12:30:13 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp