14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCALL_H
15 #define LLVM_CLANG_LIB_CODEGEN_CGCALL_H
23 #include "llvm/ADT/STLForwardCompat.h"
24 #include "llvm/IR/Value.h"
49 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
51 : CalleeProtoTy(calleeProtoTy) {}
53 : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
72 struct BuiltinInfoStorage {
76 struct PseudoDestructorInfoStorage {
79 struct VirtualInfoStorage {
83 llvm::FunctionType *FTy;
86 SpecialKind KindOrFunctionPointer;
97 : KindOrFunctionPointer(SpecialKind::Builtin) {
103 CGCallee() : KindOrFunctionPointer(SpecialKind::Invalid) {}
108 : KindOrFunctionPointer(
109 SpecialKind(reinterpret_cast<
uintptr_t>(functionPtr))) {
111 assert(functionPtr &&
"configuring callee without function pointer");
116 CGCallee result(SpecialKind::Builtin);
123 CGCallee result(SpecialKind::PseudoDestructor);
130 return CGCallee(abstractInfo, functionPtr);
135 return CGCallee(abstractInfo, functionPtr.getCallee());
139 llvm::FunctionType *FTy) {
140 CGCallee result(SpecialKind::Virtual);
149 return KindOrFunctionPointer == SpecialKind::Builtin;
161 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
179 return reinterpret_cast<llvm::Value *
>(
uintptr_t(KindOrFunctionPointer));
183 KindOrFunctionPointer =
184 SpecialKind(
reinterpret_cast<uintptr_t>(functionPtr));
188 return KindOrFunctionPointer == SpecialKind::Virtual;
238 assert(HasLV && !IsUsed);
242 assert(!HasLV && !IsUsed);
291 insert(end(), other.begin(), other.end());
292 Writebacks.insert(Writebacks.end(), other.Writebacks.begin(),
293 other.Writebacks.end());
294 CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
295 other.CleanupsToDeactivate.begin(),
296 other.CleanupsToDeactivate.end());
297 assert(!(StackBase && other.StackBase) &&
"can't merge stackbases");
299 StackBase = other.StackBase;
303 Writeback writeback = {srcLV, temporary, toUse};
304 Writebacks.push_back(writeback);
309 typedef llvm::iterator_range<SmallVectorImpl<Writeback>::const_iterator>
317 llvm::Instruction *IsActiveIP) {
321 CleanupsToDeactivate.push_back(ArgCleanup);
325 return CleanupsToDeactivate;
345 llvm::CallInst *StackBase =
nullptr;
359 LLVM_PREFERRED_TYPE(
bool)
360 unsigned IsVolatile : 1;
361 LLVM_PREFERRED_TYPE(
bool)
362 unsigned IsUnused : 1;
363 LLVM_PREFERRED_TYPE(
bool)
364 unsigned IsExternallyDestructed : 1;
370 bool IsExternallyDestructed =
false)
371 : Addr(Addr), IsVolatile(IsVolatile), IsUnused(IsUnused),
372 IsExternallyDestructed(IsExternallyDestructed) {}
403 bool WillInternalize);
413 return static_cast<FnInfoOpts>(llvm::to_underlying(A) |
414 llvm::to_underlying(B));
418 return static_cast<FnInfoOpts>(llvm::to_underlying(A) &
419 llvm::to_underlying(B));
Forward declaration of all AST node types.
C Language Family Type Representation.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Abstract information about a function or function prototype.
const GlobalDecl getCalleeDecl() const
CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
CGCalleeInfo(const FunctionProtoType *calleeProtoTy, GlobalDecl calleeDecl)
const FunctionProtoType * getCalleeFunctionProtoType() const
CGCalleeInfo(GlobalDecl calleeDecl)
All available information about a concrete callee.
CGCalleeInfo getAbstractInfo() const
CGCallee prepareConcreteCallee(CodeGenFunction &CGF) const
If this is a delayed callee computation of some sort, prepare a concrete callee.
VirtualInfoStorage VirtualInfo
Address getThisAddress() const
BuiltinInfoStorage BuiltinInfo
bool isPseudoDestructor() const
const FunctionDecl * getBuiltinDecl() const
PseudoDestructorInfoStorage PseudoDestructorInfo
static CGCallee forBuiltin(unsigned builtinID, const FunctionDecl *builtinDecl)
llvm::Value * getFunctionPointer() const
unsigned getBuiltinID() const
CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr)
Construct a callee.
static CGCallee forVirtual(const CallExpr *CE, GlobalDecl MD, Address Addr, llvm::FunctionType *FTy)
void setFunctionPointer(llvm::Value *functionPtr)
static CGCallee forDirect(llvm::FunctionCallee functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
const CXXPseudoDestructorExpr * getPseudoDestructorExpr() const
const CallExpr * getVirtualCallExpr() const
static CGCallee forPseudoDestructor(const CXXPseudoDestructorExpr *E)
GlobalDecl getVirtualMethodDecl() const
llvm::FunctionType * getVirtualFunctionType() const
CGCalleeInfo AbstractInfo
CallArgList - Type for representing both the value and type of arguments in a call.
void addUncopiedAggregate(LValue LV, QualType type)
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const
llvm::Instruction * getStackBase() const
llvm::iterator_range< SmallVectorImpl< Writeback >::const_iterator > writeback_const_range
void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
bool hasWritebacks() const
void add(RValue rvalue, QualType type)
bool isUsingInAlloca() const
Returns if we're using an inalloca struct to pass arguments in memory.
void allocateArgumentMemory(CodeGenFunction &CGF)
void freeArgumentMemory(CodeGenFunction &CGF) const
writeback_const_range writebacks() const
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse)
void addFrom(const CallArgList &other)
Add all the arguments from another CallArgList to this one.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
A saved depth on the scope stack.
FunctionArgList - Type for representing both the decl and type of parameters to a function.
LValue - This represents an lvalue references.
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
bool isExternallyDestructed() const
ReturnValueSlot(Address Addr, bool IsVolatile, bool IsUnused=false, bool IsExternallyDestructed=false)
Address getAddress() const
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a function declaration or definition.
Represents a prototype with parameter type info, e.g.
GlobalDecl - represents a global declaration.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
Options for controlling the target.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
FnInfoOpts operator|=(FnInfoOpts A, FnInfoOpts B)
FnInfoOpts operator&(FnInfoOpts A, FnInfoOpts B)
FnInfoOpts operator&=(FnInfoOpts A, FnInfoOpts B)
void mergeDefaultFunctionDefinitionAttributes(llvm::Function &F, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, const TargetOptions &TargetOpts, bool WillInternalize)
Adds attributes to F according to our CodeGenOpts and LangOpts, as though we had emitted it ourselves...
BlockFlags operator|(BlockLiteralFlags l, BlockLiteralFlags r)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
llvm::Instruction * IsActiveIP
The "is active" insertion point.
EHScopeStack::stable_iterator Cleanup
llvm::Value * ToUse
A value to "use" after the writeback, or null.
LValue Source
The original argument.
Address Temporary
The temporary alloca.
LValue getKnownLValue() const
RValue getKnownRValue() const
CallArg(LValue lv, QualType ty)
void setRValue(RValue _RV)
void copyInto(CodeGenFunction &CGF, Address A) const
CallArg(RValue rv, QualType ty)
RValue getRValue(CodeGenFunction &CGF) const