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 CGBuilderTy(const CodeGenModule &CGM, llvm::LLVMContext &C,
99 const CGBuilderInserterTy &Inserter)
100 : CGBuilderBaseTy(CGM.getModule(),
101 llvm::TargetFolder(CGM.getDataLayout()), Inserter),
102 TypeCache(CGM) {}
103 CGBuilderTy(const CodeGenModule &CGM, llvm::Instruction *I)
104 : CGBuilderBaseTy(I->getIterator(),
105 llvm::TargetFolder(CGM.getDataLayout())),
106 TypeCache(CGM) {}
107 CGBuilderTy(const CodeGenModule &CGM, llvm::BasicBlock *BB)
108 : CGBuilderBaseTy(BB, llvm::TargetFolder(CGM.getDataLayout())),
109 TypeCache(CGM) {}
110
111 llvm::ConstantInt *getSize(CharUnits N) {
112 return llvm::ConstantInt::getSigned(TypeCache.SizeTy, N.getQuantity());
113 }
114 llvm::ConstantInt *getSize(uint64_t N) {
115 return llvm::ConstantInt::get(TypeCache.SizeTy, N);
116 }
117
118 // Note that we intentionally hide the CreateLoad APIs that don't
119 // take an alignment.
120 llvm::LoadInst *CreateLoad(Address Addr, const llvm::Twine &Name = "") {
121 return CreateAlignedLoad(Addr.getElementType(),
122 emitRawPointerFromAddress(Addr),
123 Addr.getAlignment().getAsAlign(), Name);
124 }
125 llvm::LoadInst *CreateLoad(Address Addr, const char *Name) {
126 // This overload is required to prevent string literals from
127 // ending up in the IsVolatile overload.
128 return CreateAlignedLoad(Addr.getElementType(),
129 emitRawPointerFromAddress(Addr),
130 Addr.getAlignment().getAsAlign(), Name);
131 }
132 llvm::LoadInst *CreateLoad(Address Addr, bool IsVolatile,
133 const llvm::Twine &Name = "") {
134 return CreateAlignedLoad(
135 Addr.getElementType(), emitRawPointerFromAddress(Addr),
136 Addr.getAlignment().getAsAlign(), IsVolatile, Name);
137 }
138
139 using CGBuilderBaseTy::CreateAlignedLoad;
140 llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
141 CharUnits Align,
142 const llvm::Twine &Name = "") {
143 return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name);
144 }
145
146 // Note that we intentionally hide the CreateStore APIs that don't
147 // take an alignment.
148 llvm::StoreInst *CreateStore(llvm::Value *Val, Address Addr,
149 bool IsVolatile = false) {
150 return CreateAlignedStore(Val, emitRawPointerFromAddress(Addr),
151 Addr.getAlignment().getAsAlign(), IsVolatile);
152 }
153
154 using CGBuilderBaseTy::CreateAlignedStore;
155 llvm::StoreInst *CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr,
156 CharUnits Align,
157 bool IsVolatile = false) {
158 return CreateAlignedStore(Val, Addr, Align.getAsAlign(), IsVolatile);
159 }
160
161 // FIXME: these "default-aligned" APIs should be removed,
162 // but I don't feel like fixing all the builtin code right now.
163 llvm::StoreInst *CreateDefaultAlignedStore(llvm::Value *Val,
164 llvm::Value *Addr,
165 bool IsVolatile = false) {
166 return CGBuilderBaseTy::CreateStore(Val, Addr, IsVolatile);
167 }
168
169 /// Emit a load from an i1 flag variable.
170 llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr,
171 const llvm::Twine &Name = "") {
172 return CreateAlignedLoad(getInt1Ty(), Addr, CharUnits::One(), Name);
173 }
174
175 /// Emit a store to an i1 flag variable.
176 llvm::StoreInst *CreateFlagStore(bool Value, llvm::Value *Addr) {
177 return CreateAlignedStore(getInt1(Value), Addr, CharUnits::One());
178 }
179
180 llvm::AtomicCmpXchgInst *
181 CreateAtomicCmpXchg(Address Addr, llvm::Value *Cmp, llvm::Value *New,
182 llvm::AtomicOrdering SuccessOrdering,
183 llvm::AtomicOrdering FailureOrdering,
184 llvm::SyncScope::ID SSID = llvm::SyncScope::System) {
185 return CGBuilderBaseTy::CreateAtomicCmpXchg(
186 Addr.emitRawPointer(*getCGF()), Cmp, New,
187 Addr.getAlignment().getAsAlign(), SuccessOrdering, FailureOrdering,
188 SSID);
189 }
190
191 llvm::AtomicRMWInst *
192 CreateAtomicRMW(llvm::AtomicRMWInst::BinOp Op, Address Addr, llvm::Value *Val,
193 llvm::AtomicOrdering Ordering,
194 llvm::SyncScope::ID SSID = llvm::SyncScope::System) {
195 return CGBuilderBaseTy::CreateAtomicRMW(
196 Op, Addr.emitRawPointer(*getCGF()), Val,
197 Addr.getAlignment().getAsAlign(), Ordering, SSID);
198 }
199
200 using CGBuilderBaseTy::CreateAddrSpaceCast;
202 llvm::Type *ElementTy,
203 const llvm::Twine &Name = "") {
204 if (!Addr.hasOffset())
205 return Address(CreateAddrSpaceCast(Addr.getBasePointer(), Ty, Name),
206 ElementTy, Addr.getAlignment(), Addr.getPointerAuthInfo(),
207 /*Offset=*/nullptr, Addr.isKnownNonNull());
208 // Eagerly force a raw address if these is an offset.
209 return RawAddress(
210 CreateAddrSpaceCast(Addr.emitRawPointer(*getCGF()), Ty, Name),
211 ElementTy, Addr.getAlignment(), Addr.isKnownNonNull());
212 }
213
214 using CGBuilderBaseTy::CreatePointerBitCastOrAddrSpaceCast;
216 llvm::Type *ElementTy,
217 const llvm::Twine &Name = "") {
218 if (Addr.getType()->getAddressSpace() == Ty->getPointerAddressSpace())
219 return Addr.withElementType(ElementTy);
220 return CreateAddrSpaceCast(Addr, Ty, ElementTy, Name);
221 }
222
223 /// Given
224 /// %addr = {T1, T2...}* ...
225 /// produce
226 /// %name = getelementptr inbounds nuw %addr, i32 0, i32 index
227 ///
228 /// This API assumes that drilling into a struct like this is always an
229 /// inbounds and nuw operation.
230 using CGBuilderBaseTy::CreateStructGEP;
232 const llvm::Twine &Name = "") {
233 llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
234 const llvm::DataLayout &DL = getDataLayout();
235 const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
236 auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
237
238 return Address(CreateStructGEP(Addr.getElementType(), Addr.getBasePointer(),
239 Index, Name),
240 ElTy->getElementType(Index),
241 Addr.getAlignment().alignmentAtOffset(Offset),
242 Addr.isKnownNonNull());
243 }
244
245 /// Given
246 /// %addr = [n x T]* ...
247 /// produce
248 /// %name = getelementptr inbounds %addr, i64 0, i64 index
249 /// where i64 is actually the target word size.
250 ///
251 /// This API assumes that drilling into an array like this is always
252 /// an inbounds operation.
254 const llvm::Twine &Name = "") {
255 llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType());
256 const llvm::DataLayout &DL = getDataLayout();
257 CharUnits EltSize =
258 CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType()));
259
260 return Address(
261 CreateInBoundsGEP(Addr.getElementType(), Addr.getBasePointer(),
262 {getSize(CharUnits::Zero()), getSize(Index)}, Name),
263 ElTy->getElementType(),
264 Addr.getAlignment().alignmentAtOffset(Index * EltSize),
265 Addr.isKnownNonNull());
266 }
267
268 /// Given
269 /// %addr = T* ...
270 /// produce
271 /// %name = getelementptr inbounds %addr, i64 index
272 /// where i64 is actually the target word size.
274 const llvm::Twine &Name = "") {
275 llvm::Type *ElTy = Addr.getElementType();
276 const llvm::DataLayout &DL = getDataLayout();
277 CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
278
279 return Address(
280 CreateInBoundsGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name),
281 ElTy, Addr.getAlignment().alignmentAtOffset(Index * EltSize),
282 Addr.isKnownNonNull());
283 }
284
285 /// Given
286 /// %addr = T* ...
287 /// produce
288 /// %name = getelementptr inbounds %addr, i64 index
289 /// where i64 is actually the target word size.
291 const llvm::Twine &Name = "") {
292 llvm::Type *ElTy = Addr.getElementType();
293 const llvm::DataLayout &DL = getDataLayout();
294 CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
295
296 return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name),
297 Addr.getElementType(),
298 Addr.getAlignment().alignmentAtOffset(Index * EltSize));
299 }
300
301 /// Create GEP with single dynamic index. The address alignment is reduced
302 /// according to the element size.
303 using CGBuilderBaseTy::CreateGEP;
304 Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index,
305 const llvm::Twine &Name = "") {
306 const llvm::DataLayout &DL = getDataLayout();
307 CharUnits EltSize =
308 CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
309
310 return Address(
311 CreateGEP(Addr.getElementType(), Addr.emitRawPointer(CGF), Index, Name),
312 Addr.getElementType(),
313 Addr.getAlignment().alignmentOfArrayElement(EltSize));
314 }
315
316 /// Given a pointer to i8, adjust it by a given constant offset.
318 const llvm::Twine &Name = "") {
319 assert(Addr.getElementType() == TypeCache.Int8Ty);
320 return Address(
321 CreateInBoundsGEP(Addr.getElementType(), Addr.getBasePointer(),
322 getSize(Offset), Name),
323 Addr.getElementType(), Addr.getAlignment().alignmentAtOffset(Offset),
324 Addr.isKnownNonNull());
325 }
326
328 const llvm::Twine &Name = "") {
329 assert(Addr.getElementType() == TypeCache.Int8Ty);
330 return Address(CreateGEP(Addr.getElementType(), Addr.getBasePointer(),
331 getSize(Offset), Name),
332 Addr.getElementType(),
333 Addr.getAlignment().alignmentAtOffset(Offset));
334 }
335
336 using CGBuilderBaseTy::CreateConstInBoundsGEP2_32;
337 Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
338 const llvm::Twine &Name = "") {
339 return createConstGEP2_32<true>(Addr, Idx0, Idx1, Name);
340 }
341
342 using CGBuilderBaseTy::CreateConstGEP2_32;
343 Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
344 const llvm::Twine &Name = "") {
345 return createConstGEP2_32<false>(Addr, Idx0, Idx1, Name);
346 }
347
349 llvm::Type *ElementType, CharUnits Align,
350 const Twine &Name = "",
351 llvm::GEPNoWrapFlags NW = llvm::GEPNoWrapFlags::none()) {
352 llvm::Value *Ptr = emitRawPointerFromAddress(Addr);
353 return RawAddress(CreateGEP(Addr.getElementType(), Ptr, IdxList, Name, NW),
354 ElementType, Align);
355 }
356
357 using CGBuilderBaseTy::CreateInBoundsGEP;
359 llvm::Type *ElementType, CharUnits Align,
360 const Twine &Name = "") {
361 return RawAddress(CreateInBoundsGEP(Addr.getElementType(),
362 emitRawPointerFromAddress(Addr),
363 IdxList, Name),
364 ElementType, Align, Addr.isKnownNonNull());
365 }
366
367 using CGBuilderBaseTy::CreateStructuredGEP;
368 llvm::Value *CreateAccessChain(bool Logical, llvm::Type *BaseType,
369 llvm::Value *PtrBase,
371 const Twine &Name = "") {
372
373 if (Logical)
374 return CreateStructuredGEP(BaseType, PtrBase, IdxList, Name);
375 return CreateInBoundsGEP(BaseType, PtrBase, IdxList, Name);
376 }
377
380 llvm::Type *ElementType, CharUnits Align,
381 const Twine &Name = "") {
382
383 return RawAddress(CreateAccessChain(Logical, Addr.getElementType(),
384 emitRawPointerFromAddress(Addr),
385 IdxList, Name),
386 ElementType, Align, Addr.isKnownNonNull());
387 }
388
389 using CGBuilderBaseTy::CreateIsNull;
390 llvm::Value *CreateIsNull(Address Addr, const Twine &Name = "") {
391 if (!Addr.hasOffset())
392 return CreateIsNull(Addr.getBasePointer(), Name);
393 // The pointer isn't null if Addr has an offset since offsets can always
394 // be applied inbound.
395 return llvm::ConstantInt::getFalse(Context);
396 }
397
398 using CGBuilderBaseTy::CreateMemCpy;
399 llvm::CallInst *CreateMemCpy(Address Dest, Address Src, llvm::Value *Size,
400 bool IsVolatile = false) {
401 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
402 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
403 return CreateMemCpy(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
404 Src.getAlignment().getAsAlign(), Size, IsVolatile);
405 }
406 llvm::CallInst *CreateMemCpy(Address Dest, Address Src, uint64_t Size,
407 bool IsVolatile = false) {
408 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
409 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
410 return CreateMemCpy(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
411 Src.getAlignment().getAsAlign(), Size, IsVolatile);
412 }
413
414 using CGBuilderBaseTy::CreateMemCpyInline;
415 llvm::CallInst *CreateMemCpyInline(Address Dest, Address Src, uint64_t Size) {
416 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
417 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
418 return CreateMemCpyInline(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
419 Src.getAlignment().getAsAlign(), getInt64(Size));
420 }
421
422 using CGBuilderBaseTy::CreateMemMove;
423 llvm::CallInst *CreateMemMove(Address Dest, Address Src, llvm::Value *Size,
424 bool IsVolatile = false) {
425 llvm::Value *DestPtr = emitRawPointerFromAddress(Dest);
426 llvm::Value *SrcPtr = emitRawPointerFromAddress(Src);
427 return CreateMemMove(DestPtr, Dest.getAlignment().getAsAlign(), SrcPtr,
428 Src.getAlignment().getAsAlign(), Size, IsVolatile);
429 }
430
431 using CGBuilderBaseTy::CreateMemSet;
432 llvm::CallInst *CreateMemSet(Address Dest, llvm::Value *Value,
433 llvm::Value *Size, bool IsVolatile = false) {
434 return CreateMemSet(emitRawPointerFromAddress(Dest), Value, Size,
435 Dest.getAlignment().getAsAlign(), IsVolatile);
436 }
437
438 using CGBuilderBaseTy::CreateMemSetInline;
439 llvm::CallInst *CreateMemSetInline(Address Dest, llvm::Value *Value,
440 uint64_t Size) {
441 return CreateMemSetInline(emitRawPointerFromAddress(Dest),
442 Dest.getAlignment().getAsAlign(), Value,
443 getInt64(Size));
444 }
445
446 using CGBuilderBaseTy::CreatePreserveStructAccessIndex;
448 unsigned FieldIndex,
449 llvm::MDNode *DbgInfo) {
450 llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
451 const llvm::DataLayout &DL = getDataLayout();
452 const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
453 auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
454
455 return Address(
456 CreatePreserveStructAccessIndex(ElTy, emitRawPointerFromAddress(Addr),
457 Index, FieldIndex, DbgInfo),
458 ElTy->getElementType(Index),
459 Addr.getAlignment().alignmentAtOffset(Offset));
460 }
461
462 using CGBuilderBaseTy::CreatePreserveUnionAccessIndex;
464 llvm::MDNode *DbgInfo) {
465 Addr.replaceBasePointer(CreatePreserveUnionAccessIndex(
466 Addr.getBasePointer(), FieldIndex, DbgInfo));
467 return Addr;
468 }
469
470 using CGBuilderBaseTy::CreateLaunderInvariantGroup;
472 Addr.replaceBasePointer(CreateLaunderInvariantGroup(Addr.getBasePointer()));
473 return Addr;
474 }
475};
476
477} // end namespace CodeGen
478} // end namespace clang
479
480#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:107
llvm::LoadInst * CreateLoad(Address Addr, bool IsVolatile, const llvm::Twine &Name="")
Definition CGBuilder.h:132
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
Definition CGBuilder.h:176
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Definition CGBuilder.h:148
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:317
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, uint64_t Size, bool IsVolatile=false)
Definition CGBuilder.h:406
Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name="")
Definition CGBuilder.h:337
llvm::Value * CreateIsNull(Address Addr, const Twine &Name="")
Definition CGBuilder.h:390
llvm::StoreInst * CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr, CharUnits Align, bool IsVolatile=false)
Definition CGBuilder.h:155
Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index, const llvm::Twine &Name="")
Definition CGBuilder.h:304
llvm::CallInst * CreateMemMove(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
Definition CGBuilder.h:423
Address CreatePointerBitCastOrAddrSpaceCast(Address Addr, llvm::Type *Ty, llvm::Type *ElementTy, const llvm::Twine &Name="")
Definition CGBuilder.h:215
llvm::CallInst * CreateMemCpyInline(Address Dest, Address Src, uint64_t Size)
Definition CGBuilder.h:415
Address CreateAccessChain(bool Logical, Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *ElementType, CharUnits Align, const Twine &Name="")
Definition CGBuilder.h:378
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:192
Address CreateConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name="")
Definition CGBuilder.h:343
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:253
llvm::CallInst * CreateMemSetInline(Address Dest, llvm::Value *Value, uint64_t Size)
Definition CGBuilder.h:439
llvm::StoreInst * CreateDefaultAlignedStore(llvm::Value *Val, llvm::Value *Addr, bool IsVolatile=false)
Definition CGBuilder.h:163
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
Definition CGBuilder.h:432
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
Definition CGBuilder.h:231
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:181
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Definition CGBuilder.h:120
Address CreateConstByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Definition CGBuilder.h:327
Address CreatePreserveStructAccessIndex(Address Addr, unsigned Index, unsigned FieldIndex, llvm::MDNode *DbgInfo)
Definition CGBuilder.h:447
CGBuilderTy(const CodeGenModule &CGM, llvm::LLVMContext &C, const CGBuilderInserterTy &Inserter)
Definition CGBuilder.h:98
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
Definition CGBuilder.h:170
Address CreateLaunderInvariantGroup(Address Addr)
Definition CGBuilder.h:471
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
Definition CGBuilder.h:399
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:140
llvm::Value * CreateAccessChain(bool Logical, llvm::Type *BaseType, llvm::Value *PtrBase, ArrayRef< llvm::Value * > IdxList, const Twine &Name="")
Definition CGBuilder.h:368
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:290
llvm::ConstantInt * getSize(CharUnits N)
Definition CGBuilder.h:111
llvm::LoadInst * CreateLoad(Address Addr, const char *Name)
Definition CGBuilder.h:125
Address CreatePreserveUnionAccessIndex(Address Addr, unsigned FieldIndex, llvm::MDNode *DbgInfo)
Definition CGBuilder.h:463
Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty, llvm::Type *ElementTy, const llvm::Twine &Name="")
Definition CGBuilder.h:201
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:273
Address CreateInBoundsGEP(Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *ElementType, CharUnits Align, const Twine &Name="")
Definition CGBuilder.h:358
llvm::ConstantInt * getSize(uint64_t N)
Definition CGBuilder.h:114
CGBuilderTy(const CodeGenModule &CGM, llvm::Instruction *I)
Definition CGBuilder.h:103
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:348
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
This structure provides a set of types that are commonly used during IR emission.