Go to the documentation of this file.
14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCALL_H
15 #define LLVM_CLANG_LIB_CODEGEN_CGCALL_H
23 #include "llvm/IR/Value.h"
50 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
52 : CalleeProtoTy(calleeProtoTy) {}
54 : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
73 struct BuiltinInfoStorage {
77 struct PseudoDestructorInfoStorage {
80 struct VirtualInfoStorage {
84 llvm::FunctionType *FTy;
87 SpecialKind KindOrFunctionPointer;
98 : KindOrFunctionPointer(SpecialKind::Builtin) {
104 CGCallee() : KindOrFunctionPointer(SpecialKind::Invalid) {}
109 : KindOrFunctionPointer(
110 SpecialKind(reinterpret_cast<
uintptr_t>(functionPtr))) {
112 assert(functionPtr &&
"configuring callee without function pointer");
113 assert(functionPtr->getType()->isPointerTy());
114 assert(functionPtr->getType()->isOpaquePointerTy() ||
115 functionPtr->getType()->getNonOpaquePointerElementType()
121 CGCallee result(SpecialKind::Builtin);
128 CGCallee result(SpecialKind::PseudoDestructor);
135 return CGCallee(abstractInfo, functionPtr);
140 return CGCallee(abstractInfo, functionPtr.getCallee());
144 llvm::FunctionType *FTy) {
145 CGCallee result(SpecialKind::Virtual);
154 return KindOrFunctionPointer == SpecialKind::Builtin;
166 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
184 return reinterpret_cast<llvm::Value *
>(
uintptr_t(KindOrFunctionPointer));
188 KindOrFunctionPointer =
189 SpecialKind(
reinterpret_cast<uintptr_t>(functionPtr));
193 return KindOrFunctionPointer == SpecialKind::Virtual;
243 assert(HasLV && !IsUsed);
247 assert(!HasLV && !IsUsed);
296 insert(end(), other.begin(), other.end());
297 Writebacks.insert(Writebacks.end(), other.Writebacks.begin(),
298 other.Writebacks.end());
299 CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
300 other.CleanupsToDeactivate.begin(),
301 other.CleanupsToDeactivate.end());
302 assert(!(StackBase && other.StackBase) &&
"can't merge stackbases");
304 StackBase = other.StackBase;
308 Writeback writeback = {srcLV, temporary, toUse};
309 Writebacks.push_back(writeback);
314 typedef llvm::iterator_range<SmallVectorImpl<Writeback>::const_iterator>
322 llvm::Instruction *IsActiveIP) {
326 CleanupsToDeactivate.push_back(ArgCleanup);
330 return CleanupsToDeactivate;
350 llvm::CallInst *StackBase;
364 unsigned IsVolatile : 1;
365 unsigned IsUnused : 1;
366 unsigned IsExternallyDestructed : 1;
372 bool IsExternallyDestructed =
false)
373 : Addr(Addr), IsVolatile(IsVolatile), IsUnused(IsUnused),
374 IsExternallyDestructed(IsExternallyDestructed) {}
YAML serialization mapping.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
void addUncopiedAggregate(LValue LV, QualType type)
static CGCallee forDirect(llvm::FunctionCallee functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
const GlobalDecl getCalleeDecl() const
CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr)
Construct a callee.
void copyInto(CodeGenFunction &CGF, Address A) const
A (possibly-)qualified type.
const FunctionDecl * getBuiltinDecl() const
CGCallee prepareConcreteCallee(CodeGenFunction &CGF) const
If this is a delayed callee computation of some sort, prepare a concrete callee.
llvm::Instruction * IsActiveIP
The "is active" insertion point.
const FunctionProtoType * getCalleeFunctionProtoType() const
void freeArgumentMemory(CodeGenFunction &CGF) const
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const
llvm::Value * getFunctionPointer() const
void add(RValue rvalue, QualType type)
void setFunctionPointer(llvm::Value *functionPtr)
CGCalleeInfo(const FunctionProtoType *calleeProtoTy, GlobalDecl calleeDecl)
void setRValue(RValue _RV)
EHScopeStack::stable_iterator Cleanup
GlobalDecl - represents a global declaration.
Address Temporary
The temporary alloca.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
llvm::Value * ToUse
A value to "use" after the writeback, or null.
bool isExternallyDestructed() const
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
RValue getKnownRValue() const
LValue getKnownLValue() const
CGCalleeInfo AbstractInfo
bool hasWritebacks() const
VirtualInfoStorage VirtualInfo
CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
const CXXPseudoDestructorExpr * getPseudoDestructorExpr() const
const CallExpr * getVirtualCallExpr() const
llvm::Instruction * getStackBase() const
ReturnValueSlot(Address Addr, bool IsVolatile, bool IsUnused=false, bool IsExternallyDestructed=false)
PseudoDestructorInfoStorage PseudoDestructorInfo
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
CallArg(LValue lv, QualType ty)
writeback_const_range writebacks() const
bool isPseudoDestructor() const
bool isUsingInAlloca() const
Returns if we're using an inalloca struct to pass arguments in memory.
LValue - This represents an lvalue references.
RValue getRValue(CodeGenFunction &CGF) const
void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Represents a prototype with parameter type info, e.g.
Address getThisAddress() const
Decl - This represents one declaration (or definition), e.g.
All available information about a concrete callee.
llvm::FunctionType * getVirtualFunctionType() const
FunctionArgList - Type for representing both the decl and type of parameters to a function.
static CGCallee forBuiltin(unsigned builtinID, const FunctionDecl *builtinDecl)
BuiltinInfoStorage BuiltinInfo
GlobalDecl getVirtualMethodDecl() const
Abstract information about a function or function prototype.
unsigned getBuiltinID() const
CallArg(RValue rv, QualType ty)
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse)
void allocateArgumentMemory(CodeGenFunction &CGF)
void addFrom(const CallArgList &other)
Add all the arguments from another CallArgList to this one.
static CGCallee forVirtual(const CallExpr *CE, GlobalDecl MD, Address Addr, llvm::FunctionType *FTy)
CGCalleeInfo(GlobalDecl calleeDecl)
llvm::iterator_range< SmallVectorImpl< Writeback >::const_iterator > writeback_const_range
CGCalleeInfo getAbstractInfo() const
This represents one expression.
CallArgList - Type for representing both the value and type of arguments in a call.
LValue Source
The original argument.
Represents a function declaration or definition.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
unsigned kind
All of the diagnostics that can be emitted by the frontend.
A saved depth on the scope stack.
static CGCallee forPseudoDestructor(const CXXPseudoDestructorExpr *E)