clang 24.0.0git
CGBuilder.h
Go to the documentation of this file.
1//===-- CGBuilder.h - Choose IRBuilder implementation ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
10#define LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
11
12#include "Address.h"
13#include "CGValue.h"
14#include "CodeGenModule.h"
15#include "CodeGenTypeCache.h"
16#include "llvm/Analysis/TargetFolder.h"
17#include "llvm/Analysis/Utils/Local.h"
18#include "llvm/IR/DataLayout.h"
19#include "llvm/IR/GEPNoWrapFlags.h"
20#include "llvm/IR/IRBuilder.h"
21#include "llvm/IR/Type.h"
22
23namespace clang {
24namespace CodeGen {
25
26class CGBuilderTy;
27class CodeGenFunction;
28
29/// This is an IRBuilder insertion helper that forwards to
30/// CodeGenFunction::InsertHelper, which adds necessary metadata to
31/// instructions.
32class CGBuilderInserter final : public llvm::IRBuilderDefaultInserter {
33 friend CGBuilderTy;
34
35public:
36 CGBuilderInserter() = default;
37 explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
38
39 /// This forwards to CodeGenFunction::InsertHelper.
40 void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
41 llvm::BasicBlock::iterator InsertPt) const;
42
43private:
44 CodeGenFunction *CGF = nullptr;
45};
46
48
49typedef llvm::IRBuilder<llvm::TargetFolder, CGBuilderInserterTy>
51
53 friend class Address;
54
55 /// Storing a reference to the type cache here makes it a lot easier
56 /// to build natural-feeling, target-specific IR.
57 const CodeGenTypeCache &TypeCache;
58
59 CodeGenFunction *getCGF() const { return getInserter().CGF; }
60
61 llvm::Value *emitRawPointerFromAddress(Address Addr) const {
62 return Addr.getBasePointer();
63 }
64
65 template <bool IsInBounds>
66 Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
67 const llvm::Twine &Name) {
68 const llvm::DataLayout &DL = getDataLayout();
69 llvm::Value *V;
70 if (IsInBounds)
71 V = CreateConstInBoundsGEP2_32(Addr.getElementType(),
72 emitRawPointerFromAddress(Addr), Idx0,
73 Idx1, Name);
74 else
75 V = CreateConstGEP2_32(Addr.getElementType(),
76 emitRawPointerFromAddress(Addr), Idx0, Idx1, Name);
77 llvm::APInt Offset(
78 DL.getIndexSizeInBits(Addr.getType()->getPointerAddressSpace()), 0,
79 /*isSigned=*/true);
80 if (!llvm::GEPOperator::accumulateConstantOffset(
81 Addr.getElementType(), {getInt32(Idx0), getInt32(Idx1)}, DL,
82 Offset))
83 llvm_unreachable(
84 "accumulateConstantOffset with constant indices should not fail.");
85 llvm::Type *ElementTy = llvm::GetElementPtrInst::getIndexedType(
86 Addr.getElementType(), {Idx0, Idx1});
87 return Address(V, ElementTy,
88 Addr.getAlignment().alignmentAtOffset(
89 CharUnits::fromQuantity(Offset.getSExtValue())),
90 IsInBounds ? Addr.isKnownNonNull() : NotKnownNonNull);
91 }
92
93public:
94 CGBuilderTy(const CodeGenModule &CGM, llvm::LLVMContext &C)
95 : CGBuilderBaseTy(CGM.getModule(),
96 llvm::TargetFolder(CGM.getDataLayout())),
97 TypeCache(CGM) {
98 disableGEPCanonicalization();
99 }
100 CGBuilderTy(const CodeGenModule &CGM, llvm::LLVMContext &C,
101 const CGBuilderInserterTy &Inserter)
102 : CGBuilderBaseTy(CGM.getModule(),
103 llvm::TargetFolder(CGM.getDataLayout()), Inserter),
104 TypeCache(CGM) {
105 disableGEPCanonicalization();
106 }
107 CGBuilderTy(const CodeGenModule &CGM, llvm::Instruction *I)
108 : CGBuilderBaseTy(I->getIterator(),
109 llvm::TargetFolder(CGM.getDataLayout())),
110 TypeCache(CGM) {
111 disableGEPCanonicalization();
112 }
113 CGBuilderTy(const CodeGenModule &CGM, llvm::BasicBlock *BB)
114 : CGBuilderBaseTy(BB, llvm::TargetFolder(CGM.getDataLayout())),
115 TypeCache(CGM) {
116 disableGEPCanonicalization();
117 }
118
119 llvm::ConstantInt *getSize(CharUnits N) {
120 return llvm::ConstantInt::getSigned(TypeCache.SizeTy, N.getQuantity());
121 }
122 llvm::ConstantInt *getSize(uint64_t N) {
123 return llvm::ConstantInt::get(TypeCache.SizeTy, N);
124 }
125
126 // Note that we intentionally hide the CreateLoad APIs that don't
127 // take an alignment.
128 llvm::LoadInst *CreateLoad(Address Addr, const llvm::Twine &Name = "") {
129 return CreateAlignedLoad(Addr.getElementType(),
130 emitRawPointerFromAddress(Addr),
131 Addr.getAlignment().getAsAlign(), Name);
132 }
133 llvm::LoadInst *CreateLoad(Address Addr, const char *Name) {
134 // This overload is required to prevent string literals from
135 // ending up in the IsVolatile overload.
136 return CreateAlignedLoad(Addr.getElementType(),
137 emitRawPointerFromAddress(Addr),
138 Addr.getAlignment().getAsAlign(), Name);
139 }
140 llvm::LoadInst *CreateLoad(Address Addr, bool IsVolatile,
141 const llvm::Twine &Name = "") {
142 return CreateAlignedLoad(
143 Addr.getElementType(), emitRawPointerFromAddress(Addr),
144 Addr.getAlignment().getAsAlign(), IsVolatile, Name);
145 }
146
147 using CGBuilderBaseTy::CreateAlignedLoad;
148 llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
149 CharUnits Align,
150 const llvm::Twine &Name = "") {
151 return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name);
152 }
153
154 // Note that we intentionally hide the CreateStore APIs that don't
155 // take an alignment.
156 llvm::StoreInst *CreateStore(llvm::Value *Val, Address Addr,
157 bool IsVolatile = false) {
158 return CreateAlignedStore(Val, emitRawPointerFromAddress(Addr),
159 Addr.getAlignment().getAsAlign(), IsVolatile);
160 }
161
162 using CGBuilderBaseTy::CreateAlignedStore;
163 llvm::StoreInst *CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr,
164 CharUnits Align,
165 bool IsVolatile = false) {
166 return CreateAlignedStore(Val, Addr, Align.getAsAlign(), IsVolatile);
167 }
168
169 // FIXME: these "default-aligned" APIs should be removed,
170 // but I don't feel like fixing all the builtin code right now.
171 llvm::StoreInst *CreateDefaultAlignedStore(llvm::Value *Val,
172 llvm::Value *Addr,
173 bool IsVolatile = false) {
174 return CGBuilderBaseTy::CreateStore(Val, Addr, IsVolatile);
175 }
176
177 /// Emit a load from an i1 flag variable.
178 llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr,
179 const llvm::Twine &Name = "") {
180 return CreateAlignedLoad(getInt1Ty(), Addr, CharUnits::One(), Name);
181 }
182
183 /// Emit a store to an i1 flag variable.
184 llvm::StoreInst *CreateFlagStore(bool Value, llvm::Value *Addr) {
185 return CreateAlignedStore(getInt1(Value), Addr, CharUnits::One());
186 }
187
188 llvm::AtomicCmpXchgInst *
189 CreateAtomicCmpXchg(Address Addr, llvm::Value *Cmp, llvm::Value *New,
190 llvm::AtomicOrdering SuccessOrdering,
191 llvm::AtomicOrdering FailureOrdering,
192 llvm::SyncScope::ID SSID = llvm::SyncScope::System) {
193 return CGBuilderBaseTy::CreateAtomicCmpXchg(
194 Addr.emitRawPointer(*getCGF()), Cmp, New,
195 Addr.getAlignment().getAsAlign(), SuccessOrdering, FailureOrdering,
196 SSID);
197 }
198
199 llvm::AtomicRMWInst *
200 CreateAtomicRMW(llvm::AtomicRMWInst::BinOp Op, Address Addr, llvm::Value *Val,
201 llvm::AtomicOrdering Ordering,
202 llvm::SyncScope::ID SSID = llvm::SyncScope::System) {
203 return CGBuilderBaseTy::CreateAtomicRMW(
204 Op, Addr.emitRawPointer(*getCGF()), Val,
205 Addr.getAlignment().getAsAlign(), Ordering, SSID);
206 }
207
208 using CGBuilderBaseTy::CreateAddrSpaceCast;
210 llvm::Type *ElementTy,
211 const llvm::Twine &Name = "") {
212 if (!Addr.hasOffset())
213 return Address(CreateAddrSpaceCast(Addr.getBasePointer(), Ty, Name),
214 ElementTy, Addr.getAlignment(), Addr.getPointerAuthInfo(),
215 /*Offset=*/nullptr, Addr.isKnownNonNull());
216 // Eagerly force a raw address if these is an offset.
217 return RawAddress(
218 CreateAddrSpaceCast(Addr.emitRawPointer(*getCGF()), Ty, Name),
219 ElementTy, Addr.getAlignment(), Addr.isKnownNonNull());
220 }
221
222 using CGBuilderBaseTy::CreatePointerBitCastOrAddrSpaceCast;
224 llvm::Type *ElementTy,
225 const llvm::Twine &Name = "") {
226 if (Addr.getType()->getAddressSpace() == Ty->getPointerAddressSpace())
227 return Addr.withElementType(ElementTy);
228 return CreateAddrSpaceCast(Addr, Ty, ElementTy, Name);
229 }
230
231 /// Given
232 /// %addr = {T1, T2...}* ...
233 /// produce
234 /// %name = getelementptr inbounds nuw %addr, i32 0, i32 index
235 ///
236 /// This API assumes that drilling into a struct like this is always an
237 /// inbounds and nuw operation.
238 using CGBuilderBaseTy::CreateStructGEP;
240 const llvm::Twine &Name = "") {
241 llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
242 const llvm::DataLayout &DL = getDataLayout();
243 const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
244 auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
245
246 return Address(CreateStructGEP(Addr.getElementType(), Addr.getBasePointer(),
247 Index, Name),
248 ElTy->getElementType(Index),
249 Addr.getAlignment().alignmentAtOffset(Offset),
250 Addr.isKnownNonNull());
251 }
252
253 /// Given
254 /// %addr = [n x T]* ...
255 /// produce
256 /// %name = getelementptr inbounds %addr, i64 0, i64 index
257 /// where i64 is actually the target word size.
258 ///
259 /// This API assumes that drilling into an array like this is always
260 /// an inbounds operation.
262 const llvm::Twine &Name = "") {
263 llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType());
264 const llvm::DataLayout &DL = getDataLayout();
265 CharUnits EltSize =
266 CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType()));
267
268 return Address(
269 CreateInBoundsGEP(Addr.getElementType(), Addr.getBasePointer(),
270 {getSize(CharUnits::Zero()), getSize(Index)}, Name),
271 ElTy->getElementType(),
272 Addr.getAlignment().alignmentAtOffset(Index * EltSize),
273 Addr.isKnownNonNull());
274 }
275
276 /// Given
277 /// %addr = T* ...
278 /// produce
279 /// %name = getelementptr inbounds %addr, i64 index
280 /// where i64 is actually the target word size.
282 const llvm::Twine &Name = "") {
283 llvm::Type *ElTy = Addr.getElementType();
284 const llvm::DataLayout &DL = getDataLayout();
285 CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
286
287 return Address(
288 CreateInBoundsGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name),
289 ElTy, Addr.getAlignment().alignmentAtOffset(Index * EltSize),
290 Addr.isKnownNonNull());
291 }
292
293 /// Given
294 /// %addr = T* ...
295 /// produce
296 /// %name = getelementptr inbounds %addr, i64 index
297 /// where i64 is actually the target word size.
299 const llvm::Twine &Name = "") {
300 llvm::Type *ElTy = Addr.getElementType();
301 const llvm::DataLayout &DL = getDataLayout();
302 CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
303
304 return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name),
305 Addr.getElementType(),
306 Addr.getAlignment().alignmentAtOffset(Index * EltSize));
307 }
308
309 /// Create GEP with single dynamic index. The address alignment is reduced
310 /// according to the element size.
311 using CGBuilderBaseTy::CreateGEP;
312 Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index,
313 const llvm::Twine &Name = "") {
314 const llvm::DataLayout &DL = getDataLayout();
315 CharUnits EltSize =
316 CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
317
318 return Address(
319 CreateGEP(Addr.getElementType(), Addr.emitRawPointer(CGF), Index, Name),
320 Addr.getElementType(),
321 Addr.getAlignment().alignmentOfArrayElement(EltSize));
322 }
323
324 /// Given a pointer to i8, adjust it by a given constant offset.
326 const llvm::Twine &Name = "") {
327 assert(Addr.getElementType() == TypeCache.Int8Ty);
328 return Address(
329 CreateInBoundsGEP(Addr.getElementType(), Addr.getBasePointer(),
330 getSize(Offset), Name),
331 Addr.getElementType(), Addr.getAlignment().alignmentAtOffset(Offset),
332 Addr.isKnownNonNull());
333 }
334
336 const llvm::Twine &Name = "") {
337 assert(Addr.getElementType() == TypeCache.Int8Ty);
338 return Address(CreateGEP(Addr.getElementType(), Addr.getBasePointer(),
339 getSize(Offset), Name),
340 Addr.getElementType(),
341 Addr.getAlignment().alignmentAtOffset(Offset));
342 }
343
344 using CGBuilderBaseTy::CreateConstInBoundsGEP2_32;
345 Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
346 const llvm::Twine &Name = "") {
347 return createConstGEP2_32<true>(Addr, Idx0, Idx1, Name);
348 }
349
350 using CGBuilderBaseTy::CreateConstGEP2_32;
351 Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
352 const llvm::Twine &Name = "") {
353 return createConstGEP2_32<false>(Addr, Idx0, Idx1, Name);
354 }
355
357 llvm::Type *ElementType, CharUnits Align,
358 const Twine &Name = "",
359 llvm::GEPNoWrapFlags NW = llvm::GEPNoWrapFlags::none()) {
360 llvm::Value *Ptr = emitRawPointerFromAddress(Addr);
361 return RawAddress(CreateGEP(Addr.getElementType(), Ptr, IdxList, Name, NW),
362 ElementType, Align);
363 }
364
365 using CGBuilderBaseTy::CreateInBoundsGEP;
367 llvm::Type *ElementType, CharUnits Align,
368 const Twine &Name = "") {
369 return RawAddress(CreateInBoundsGEP(Addr.getElementType(),
370 emitRawPointerFromAddress(Addr),
371 IdxList, Name),
372 ElementType, Align, Addr.isKnownNonNull());
373 }
374
375 using CGBuilderBaseTy::CreateStructuredGEP;
376 llvm::Value *CreateAccessChain(bool Logical, llvm::Type *BaseType,
377 llvm::Value *PtrBase,
379 const Twine &Name = "") {
380
381 if (Logical)
382 return CreateStructuredGEP(BaseType, PtrBase, IdxList, Name);
383 return CreateInBoundsGEP(BaseType, PtrBase, IdxList, Name);
384 }
385
388 llvm::Type *ElementType, CharUnits Align,
389 const Twine &Name = "") {
390
391 return RawAddress(CreateAccessChain(Logical, Addr.getElementType(),
392 emitRawPointerFromAddress(Addr),
393 IdxList, Name),
394 ElementType, Align, Addr.isKnownNonNull());
395 }
396
397 using CGBuilderBaseTy::CreateIsNull;
398 llvm::Value *CreateIsNull(Address Addr, const Twine &Name = "") {
399 if (!Addr.hasOffset())
400 return CreateIsNull(Addr.getBasePointer(), Name);
401 // The pointer isn't null if Addr has an offset since offsets can always
402 // be applied inbound.
403 return llvm::ConstantInt::getFalse(Context);
404 }
405
406 using CGBuilderBaseTy::CreateMemCpy;
407 llvm::CallInst *CreateMemCpy(Address Dest, Address Src, llvm::Value *Size,
408 bool IsVolatile = false) {
409 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
410 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
411 return CreateMemCpy(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
412 Src.getAlignment().getAsAlign(), Size, IsVolatile);
413 }
414 llvm::CallInst *CreateMemCpy(Address Dest, Address Src, uint64_t Size,
415 bool IsVolatile = false) {
416 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
417 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
418 return CreateMemCpy(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
419 Src.getAlignment().getAsAlign(), Size, IsVolatile);
420 }
421
422 using CGBuilderBaseTy::CreateMemCpyInline;
423 llvm::CallInst *CreateMemCpyInline(Address Dest, Address Src, uint64_t Size) {
424 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
425 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
426 return CreateMemCpyInline(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
427 Src.getAlignment().getAsAlign(), getInt64(Size));
428 }
429
430 using CGBuilderBaseTy::CreateMemMove;
431 llvm::CallInst *CreateMemMove(Address Dest, Address Src, llvm::Value *Size,
432 bool IsVolatile = false) {
433 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
434 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
435 return CreateMemMove(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
436 Src.getAlignment().getAsAlign(), Size, IsVolatile);
437 }
438
439 using CGBuilderBaseTy::CreateMemSet;
440 llvm::CallInst *CreateMemSet(Address Dest, llvm::Value *Value,
441 llvm::Value *Size, bool IsVolatile = false) {
442 return CreateMemSet(emitRawPointerFromAddress(Dest), Value, Size,
443 Dest.getAlignment().getAsAlign(), IsVolatile);
444 }
445
446 using CGBuilderBaseTy::CreateMemSetInline;
447 llvm::CallInst *CreateMemSetInline(Address Dest, llvm::Value *Value,
448 uint64_t Size) {
449 return CreateMemSetInline(emitRawPointerFromAddress(Dest),
450 Dest.getAlignment().getAsAlign(), Value,
451 getInt64(Size));
452 }
453
454 using CGBuilderBaseTy::CreatePreserveStructAccessIndex;
456 unsigned FieldIndex,
457 llvm::MDNode *DbgInfo) {
458 llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
459 const llvm::DataLayout &DL = getDataLayout();
460 const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
461 auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
462
463 return Address(
464 CreatePreserveStructAccessIndex(ElTy, emitRawPointerFromAddress(Addr),
465 Index, FieldIndex, DbgInfo),
466 ElTy->getElementType(Index),
467 Addr.getAlignment().alignmentAtOffset(Offset));
468 }
469
470 using CGBuilderBaseTy::CreatePreserveUnionAccessIndex;
472 llvm::MDNode *DbgInfo) {
473 Addr.replaceBasePointer(CreatePreserveUnionAccessIndex(
474 Addr.getBasePointer(), FieldIndex, DbgInfo));
475 return Addr;
476 }
477
478 using CGBuilderBaseTy::CreateLaunderInvariantGroup;
480 Addr.replaceBasePointer(CreateLaunderInvariantGroup(Addr.getBasePointer()));
481 return Addr;
482 }
483};
484
485} // end namespace CodeGen
486} // end namespace clang
487
488#endif
#define V(N, I)
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
llvm::Align getAsAlign() const
Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit bytes.
Definition CharUnits.h:159
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
Definition CharUnits.h:155
static CharUnits One()
Construct a CharUnits quantity of one.
Definition CharUnits.h:55
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
Definition CharUnits.h:58
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition Address.h:128
CharUnits getAlignment() const
Definition Address.h:194
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Definition Address.h:209
This is an IRBuilder insertion helper that forwards to CodeGenFunction::InsertHelper,...
Definition CGBuilder.h:32
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock::iterator InsertPt) const
This forwards to CodeGenFunction::InsertHelper.
CGBuilderInserter(CodeGenFunction *CGF)
Definition CGBuilder.h:37
CGBuilderTy(const CodeGenModule &CGM, llvm::BasicBlock *BB)
Definition CGBuilder.h:113
llvm::LoadInst * CreateLoad(Address Addr, bool IsVolatile, const llvm::Twine &Name="")
Definition CGBuilder.h:140
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
Definition CGBuilder.h:184
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Definition CGBuilder.h:156
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
Definition CGBuilder.h:325
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, uint64_t Size, bool IsVolatile=false)
Definition CGBuilder.h:414
Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name="")
Definition CGBuilder.h:345
llvm::Value * CreateIsNull(Address Addr, const Twine &Name="")
Definition CGBuilder.h:398
llvm::StoreInst * CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr, CharUnits Align, bool IsVolatile=false)
Definition CGBuilder.h:163
Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index, const llvm::Twine &Name="")
Definition CGBuilder.h:312
llvm::CallInst * CreateMemMove(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
Definition CGBuilder.h:431
Address CreatePointerBitCastOrAddrSpaceCast(Address Addr, llvm::Type *Ty, llvm::Type *ElementTy, const llvm::Twine &Name="")
Definition CGBuilder.h:223
llvm::CallInst * CreateMemCpyInline(Address Dest, Address Src, uint64_t Size)
Definition CGBuilder.h:423
Address CreateAccessChain(bool Logical, Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *ElementType, CharUnits Align, const Twine &Name="")
Definition CGBuilder.h:386
llvm::AtomicRMWInst * CreateAtomicRMW(llvm::AtomicRMWInst::BinOp Op, Address Addr, llvm::Value *Val, llvm::AtomicOrdering Ordering, llvm::SyncScope::ID SSID=llvm::SyncScope::System)
Definition CGBuilder.h:200
Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name="")
Definition CGBuilder.h:351
Address CreateConstArrayGEP(Address Addr, uint64_t Index, const llvm::Twine &Name="")
Given addr = [n x T]* ... produce name = getelementptr inbounds addr, i64 0, i64 index where i64 is a...
Definition CGBuilder.h:261
llvm::CallInst * CreateMemSetInline(Address Dest, llvm::Value *Value, uint64_t Size)
Definition CGBuilder.h:447
llvm::StoreInst * CreateDefaultAlignedStore(llvm::Value *Val, llvm::Value *Addr, bool IsVolatile=false)
Definition CGBuilder.h:171
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
Definition CGBuilder.h:440
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
Definition CGBuilder.h:239
llvm::AtomicCmpXchgInst * CreateAtomicCmpXchg(Address Addr, llvm::Value *Cmp, llvm::Value *New, llvm::AtomicOrdering SuccessOrdering, llvm::AtomicOrdering FailureOrdering, llvm::SyncScope::ID SSID=llvm::SyncScope::System)
Definition CGBuilder.h:189
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Definition CGBuilder.h:128
Address CreateConstByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Definition CGBuilder.h:335
Address CreatePreserveStructAccessIndex(Address Addr, unsigned Index, unsigned FieldIndex, llvm::MDNode *DbgInfo)
Definition CGBuilder.h:455
CGBuilderTy(const CodeGenModule &CGM, llvm::LLVMContext &C, const CGBuilderInserterTy &Inserter)
Definition CGBuilder.h:100
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
Definition CGBuilder.h:178
Address CreateLaunderInvariantGroup(Address Addr)
Definition CGBuilder.h:479
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
Definition CGBuilder.h:407
CGBuilderTy(const CodeGenModule &CGM, llvm::LLVMContext &C)
Definition CGBuilder.h:94
llvm::LoadInst * CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
Definition CGBuilder.h:148
llvm::Value * CreateAccessChain(bool Logical, llvm::Type *BaseType, llvm::Value *PtrBase, ArrayRef< llvm::Value * > IdxList, const Twine &Name="")
Definition CGBuilder.h:376
Address CreateConstGEP(Address Addr, uint64_t Index, const llvm::Twine &Name="")
Given addr = T* ... produce name = getelementptr inbounds addr, i64 index where i64 is actually the t...
Definition CGBuilder.h:298
llvm::ConstantInt * getSize(CharUnits N)
Definition CGBuilder.h:119
llvm::LoadInst * CreateLoad(Address Addr, const char *Name)
Definition CGBuilder.h:133
Address CreatePreserveUnionAccessIndex(Address Addr, unsigned FieldIndex, llvm::MDNode *DbgInfo)
Definition CGBuilder.h:471
Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty, llvm::Type *ElementTy, const llvm::Twine &Name="")
Definition CGBuilder.h:209
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, const llvm::Twine &Name="")
Given addr = T* ... produce name = getelementptr inbounds addr, i64 index where i64 is actually the t...
Definition CGBuilder.h:281
Address CreateInBoundsGEP(Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *ElementType, CharUnits Align, const Twine &Name="")
Definition CGBuilder.h:366
llvm::ConstantInt * getSize(uint64_t N)
Definition CGBuilder.h:122
CGBuilderTy(const CodeGenModule &CGM, llvm::Instruction *I)
Definition CGBuilder.h:107
Address CreateGEP(Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *ElementType, CharUnits Align, const Twine &Name="", llvm::GEPNoWrapFlags NW=llvm::GEPNoWrapFlags::none())
Definition CGBuilder.h:356
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
An abstract representation of an aligned address.
Definition Address.h:42
CGBuilderInserter CGBuilderInserterTy
Definition CGBuilder.h:47
llvm::IRBuilder< llvm::TargetFolder, CGBuilderInserterTy > CGBuilderBaseTy
Definition CGBuilder.h:50
Top level wrappers for InstallAPI frontend operations.
U cast(CodeGen::Address addr)
Definition Address.h:327
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
This structure provides a set of types that are commonly used during IR emission.