10 #ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
11 #define LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
13 #include "llvm/IR/IRBuilder.h"
20 class CodeGenFunction;
25 template <
bool PreserveNames>
27 :
protected llvm::IRBuilderDefaultInserter<PreserveNames> {
43 #define PreserveNames false
45 #define PreserveNames true
61 llvm::LLVMContext &
C,
const llvm::ConstantFolder &F,
73 return llvm::ConstantInt::get(TypeCache.
SizeTy, N);
91 const llvm::Twine &
Name =
"") {
98 using CGBuilderBaseTy::CreateAlignedLoad;
100 const llvm::Twine &
Name =
"") {
109 const llvm::Twine &
Name =
"") {
110 assert(Addr->getType()->getPointerElementType() == Ty);
115 const llvm::Twine &
Name =
"") {
122 bool IsVolatile =
false) {
127 using CGBuilderBaseTy::CreateAlignedStore;
129 CharUnits Align,
bool IsVolatile =
false) {
136 const llvm::Twine &
Name =
"") {
137 return CGBuilderBaseTy::CreateLoad(Addr,
false,
Name);
141 return CGBuilderBaseTy::CreateLoad(Addr,
false, Name);
144 const llvm::Twine &
Name =
"") {
145 return CGBuilderBaseTy::CreateLoad(Addr, IsVolatile,
Name);
150 bool IsVolatile =
false) {
151 return CGBuilderBaseTy::CreateStore(Val, Addr, IsVolatile);
156 const llvm::Twine &
Name =
"") {
157 assert(Addr->getType()->getPointerElementType() == getInt1Ty());
163 assert(Addr->getType()->getPointerElementType() == getInt1Ty());
167 using CGBuilderBaseTy::CreateBitCast;
169 const llvm::Twine &
Name =
"") {
177 const llvm::Twine &
Name =
"") {
182 using CGBuilderBaseTy::CreatePointerBitCastOrAddrSpaceCast;
184 const llvm::Twine &
Name =
"") {
190 using CGBuilderBaseTy::CreateStructGEP;
192 const llvm::Twine &
Name =
"") {
209 const llvm::Twine &
Name =
"") {
226 const llvm::Twine &
Name =
"") {
240 const llvm::Twine &
Name =
"") {
248 const llvm::Twine &
Name =
"") {
254 const llvm::Twine &
Name =
"") {
261 const llvm::Twine &
Name =
"") {
262 assert(Ptr->getType()->getPointerElementType() == TypeCache.
Int8Ty);
263 return CreateInBoundsGEP(Ptr,
getSize(Offset),
Name);
266 const llvm::Twine &
Name =
"") {
267 assert(Ptr->getType()->getPointerElementType() == TypeCache.
Int8Ty);
271 using CGBuilderBaseTy::CreateMemCpy;
273 bool IsVolatile =
false) {
276 Align.getQuantity(), IsVolatile);
279 bool IsVolatile =
false) {
282 Align.getQuantity(), IsVolatile);
285 using CGBuilderBaseTy::CreateMemMove;
287 bool IsVolatile =
false) {
290 Align.getQuantity(), IsVolatile);
293 using CGBuilderBaseTy::CreateMemSet;
CGBuilderTy(const CodeGenTypeCache &TypeCache, llvm::Instruction *I)
CGBuilderInserter()=default
llvm::StoreInst * CreateDefaultAlignedStore(llvm::Value *Val, llvm::Value *Addr, bool IsVolatile=false)
CGBuilderTy(const CodeGenTypeCache &TypeCache, llvm::BasicBlock *BB)
Address CreateConstGEP(Address Addr, uint64_t Index, CharUnits EltSize, const llvm::Twine &Name="")
Given addr = T* ...
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, bool IsVolatile, const llvm::Twine &Name="")
llvm::ConstantInt * getSize(CharUnits N)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
llvm::LoadInst * CreateDefaultAlignedLoad(llvm::Value *Addr, const llvm::Twine &Name="")
llvm::ConstantInt * getSize(uint64_t N)
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
llvm::Type * getElementType() const
Return the type of the values stored in this address.
CGBuilderTy(const CodeGenTypeCache &TypeCache, llvm::LLVMContext &C, const llvm::ConstantFolder &F, const CGBuilderInserterTy &Inserter)
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const char *Name)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::IntegerType * SizeTy
CGBuilderInserter(CodeGenFunction *CGF)
llvm::LoadInst * CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
llvm::CallInst * CreateMemMove(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
CharUnits - This is an opaque type for sizes expressed in character units.
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, uint64_t Size, bool IsVolatile=false)
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
detail::InMemoryDirectory::const_iterator I
static CharUnits One()
One - Construct a CharUnits quantity of one.
CGBuilderInserter< PreserveNames > CGBuilderInserterTy
llvm::Value * getPointer() const
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
The l-value was considered opaque, so the alignment was determined from a type.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
const TemplateArgument * iterator
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
This forwards to CodeGenFunction::InsertHelper.
unsigned getAddressSpace() const
Return the address space that this address resides in.
llvm::LoadInst * CreateLoad(Address Addr, const char *Name)
This is an IRBuilder insertion helper that forwards to CodeGenFunction::InsertHelper, which adds necessary metadata to instructions.
CharUnits getAlignment() const
Return the alignment of this pointer.
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, CharUnits EltSize, const llvm::Twine &Name="")
Given addr = T* ...
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Address CreateConstArrayGEP(Address Addr, uint64_t Index, CharUnits EltSize, const llvm::Twine &Name="")
Given addr = [n x T]* ...
llvm::Value * CreateConstInBoundsByteGEP(llvm::Value *Ptr, CharUnits Offset, const llvm::Twine &Name="")
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
llvm::IRBuilder< PreserveNames, llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderBaseTy
Address CreateConstByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset...
llvm::LoadInst * CreateLoad(Address Addr, bool IsVolatile, const llvm::Twine &Name="")
llvm::Value * CreateConstByteGEP(llvm::Value *Ptr, CharUnits Offset, const llvm::Twine &Name="")
This structure provides a set of types that are commonly used during IR emission. ...
llvm::StoreInst * CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr, CharUnits Align, bool IsVolatile=false)
Address CreatePointerBitCastOrAddrSpaceCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
CGBuilderTy(const CodeGenTypeCache &TypeCache, llvm::LLVMContext &C)
llvm::LoadInst * CreateDefaultAlignedLoad(llvm::Value *Addr, bool IsVolatile, const llvm::Twine &Name="")
llvm::LoadInst * CreateDefaultAlignedLoad(llvm::Value *Addr, const char *Name)