10 #ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
11 #define LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
13 #include "llvm/IR/DataLayout.h"
14 #include "llvm/IR/IRBuilder.h"
21 class CodeGenFunction;
42 typedef llvm::IRBuilder<llvm::ConstantFolder, CGBuilderInserterTy>
53 llvm::LLVMContext &C,
const llvm::ConstantFolder &F,
65 return llvm::ConstantInt::get(TypeCache.
SizeTy, N);
83 const llvm::Twine &
Name =
"") {
90 using CGBuilderBaseTy::CreateAlignedLoad;
92 const llvm::Twine &
Name =
"") {
101 const llvm::Twine &
Name =
"") {
102 assert(Addr->getType()->getPointerElementType() == Ty);
107 const llvm::Twine &
Name =
"") {
114 bool IsVolatile =
false) {
119 using CGBuilderBaseTy::CreateAlignedStore;
121 CharUnits Align,
bool IsVolatile =
false) {
128 const llvm::Twine &
Name =
"") {
129 return CGBuilderBaseTy::CreateLoad(Addr,
false,
Name);
133 return CGBuilderBaseTy::CreateLoad(Addr,
false, Name);
136 const llvm::Twine &
Name =
"") {
137 return CGBuilderBaseTy::CreateLoad(Addr, IsVolatile,
Name);
142 bool IsVolatile =
false) {
143 return CGBuilderBaseTy::CreateStore(Val, Addr, IsVolatile);
148 const llvm::Twine &
Name =
"") {
149 assert(Addr->getType()->getPointerElementType() == getInt1Ty());
155 assert(Addr->getType()->getPointerElementType() == getInt1Ty());
159 using CGBuilderBaseTy::CreateBitCast;
161 const llvm::Twine &
Name =
"") {
169 const llvm::Twine &
Name =
"") {
174 using CGBuilderBaseTy::CreatePointerBitCastOrAddrSpaceCast;
176 const llvm::Twine &
Name =
"") {
182 using CGBuilderBaseTy::CreateStructGEP;
184 const llvm::Twine &
Name =
"") {
190 const llvm::StructLayout *Layout,
191 const llvm::Twine &
Name =
"") {
207 const llvm::Twine &
Name =
"") {
224 const llvm::Twine &
Name =
"") {
238 const llvm::Twine &
Name =
"") {
246 const llvm::Twine &
Name =
"") {
252 const llvm::Twine &
Name =
"") {
259 const llvm::Twine &
Name =
"") {
260 assert(Ptr->getType()->getPointerElementType() == TypeCache.
Int8Ty);
261 return CreateInBoundsGEP(Ptr,
getSize(Offset),
Name);
264 const llvm::Twine &
Name =
"") {
265 assert(Ptr->getType()->getPointerElementType() == TypeCache.
Int8Ty);
269 using CGBuilderBaseTy::CreateMemCpy;
271 bool IsVolatile =
false) {
274 Align.getQuantity(), IsVolatile);
277 bool IsVolatile =
false) {
280 Align.getQuantity(), IsVolatile);
283 using CGBuilderBaseTy::CreateMemMove;
285 bool IsVolatile =
false) {
288 Align.getQuantity(), IsVolatile);
291 using CGBuilderBaseTy::CreateMemSet;
CGBuilderTy(const CodeGenTypeCache &TypeCache, llvm::Instruction *I)
llvm::StoreInst * CreateDefaultAlignedStore(llvm::Value *Val, llvm::Value *Addr, bool IsVolatile=false)
CGBuilderTy(const CodeGenTypeCache &TypeCache, llvm::BasicBlock *BB)
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::StructLayout *Layout, const llvm::Twine &Name="")
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="")
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
This forwards to CodeGenFunction::InsertHelper.
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)
CGBuilderInserter CGBuilderInserterTy
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...
CGBuilderInserter(CodeGenFunction *CGF)
llvm::IntegerType * SizeTy
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)
CGBuilderInserter()=default
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.
llvm::Value * getPointer() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
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
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.
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::IRBuilder< llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderBaseTy
llvm::LoadInst * CreateDefaultAlignedLoad(llvm::Value *Addr, const char *Name)