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;
35 llvm::BasicBlock::iterator InsertPt)
const;
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);
109 bool IsVolatile =
false) {
114 using CGBuilderBaseTy::CreateAlignedStore;
116 CharUnits Align,
bool IsVolatile =
false) {
124 bool IsVolatile =
false) {
125 return CGBuilderBaseTy::CreateStore(Val, Addr, IsVolatile);
130 const llvm::Twine &
Name =
"") {
131 assert(Addr->getType()->getPointerElementType() == getInt1Ty());
137 assert(Addr->getType()->getPointerElementType() == getInt1Ty());
141 using CGBuilderBaseTy::CreateBitCast;
143 const llvm::Twine &
Name =
"") {
151 const llvm::Twine &
Name =
"") {
156 using CGBuilderBaseTy::CreatePointerBitCastOrAddrSpaceCast;
158 const llvm::Twine &
Name =
"") {
164 using CGBuilderBaseTy::CreateStructGEP;
166 const llvm::Twine &
Name =
"") {
172 const llvm::StructLayout *Layout,
173 const llvm::Twine &
Name =
"") {
189 const llvm::Twine &
Name =
"") {
206 const llvm::Twine &
Name =
"") {
220 const llvm::Twine &
Name =
"") {
228 const llvm::Twine &
Name =
"") {
234 const llvm::Twine &
Name =
"") {
241 const llvm::Twine &
Name =
"") {
242 assert(Ptr->getType()->getPointerElementType() == TypeCache.
Int8Ty);
243 return CreateInBoundsGEP(Ptr,
getSize(Offset),
Name);
246 const llvm::Twine &
Name =
"") {
247 assert(Ptr->getType()->getPointerElementType() == TypeCache.
Int8Ty);
251 using CGBuilderBaseTy::CreateMemCpy;
253 bool IsVolatile =
false) {
256 Align.getQuantity(), IsVolatile);
259 bool IsVolatile =
false) {
262 Align.getQuantity(), IsVolatile);
265 using CGBuilderBaseTy::CreateMemMove;
267 bool IsVolatile =
false) {
270 Align.getQuantity(), IsVolatile);
273 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::ConstantInt * getSize(CharUnits N)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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)
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="")
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::IRBuilder< llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderBaseTy