14#ifndef LLVM_CLANG_LIB_CODEGEN_CGCALL_H
15#define LLVM_CLANG_LIB_CODEGEN_CGCALL_H
25#include "llvm/ADT/STLForwardCompat.h"
26#include "llvm/IR/Value.h"
51 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
53 : CalleeProtoTy(calleeProtoTy) {}
55 : CalleeProtoTy(
nullptr), CalleeDecl(calleeDecl) {}
74 struct OrdinaryInfoStorage {
78 struct BuiltinInfoStorage {
82 struct PseudoDestructorInfoStorage {
85 struct VirtualInfoStorage {
89 llvm::FunctionType *FTy;
92 SpecialKind KindOrFunctionPointer;
103 : KindOrFunctionPointer(SpecialKind::
Builtin) {
109 CGCallee() : KindOrFunctionPointer(SpecialKind::Invalid) {}
116 : KindOrFunctionPointer(
117 SpecialKind(reinterpret_cast<
uintptr_t>(functionPtr))) {
120 assert(functionPtr &&
"configuring callee without function pointer");
121 assert(functionPtr->getType()->isPointerTy());
126 CGCallee result(SpecialKind::Builtin);
133 CGCallee result(SpecialKind::PseudoDestructor);
140 return CGCallee(abstractInfo, functionPtr);
143 static CGCallee
forDirect(llvm::FunctionCallee functionPtr,
145 return CGCallee(abstractInfo, functionPtr.getCallee());
149 llvm::FunctionType *FTy) {
150 CGCallee result(SpecialKind::Virtual);
159 return KindOrFunctionPointer == SpecialKind::Builtin;
171 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
193 return reinterpret_cast<llvm::Value *
>(
uintptr_t(KindOrFunctionPointer));
197 KindOrFunctionPointer =
198 SpecialKind(
reinterpret_cast<uintptr_t>(functionPtr));
206 return KindOrFunctionPointer == SpecialKind::Virtual;
256 assert(HasLV && !IsUsed);
260 assert(!HasLV && !IsUsed);
313 llvm::append_range(*
this, other);
314 llvm::append_range(Writebacks, other.Writebacks);
315 llvm::append_range(CleanupsToDeactivate, other.CleanupsToDeactivate);
316 assert(!(StackBase && other.StackBase) &&
"can't merge stackbases");
318 StackBase = other.StackBase;
322 const Expr *writebackExpr =
nullptr) {
323 Writeback writeback = {srcLV, temporary, toUse, writebackExpr};
324 Writebacks.push_back(writeback);
329 typedef llvm::iterator_range<SmallVectorImpl<Writeback>::const_iterator>
337 llvm::Instruction *IsActiveIP) {
341 CleanupsToDeactivate.push_back(ArgCleanup);
345 return CleanupsToDeactivate;
358 std::reverse(Writebacks.begin(), Writebacks.end());
370 llvm::CallInst *StackBase =
nullptr;
377 using SmallVector::SmallVector;
386 LLVM_PREFERRED_TYPE(
bool)
387 unsigned IsVolatile : 1;
388 LLVM_PREFERRED_TYPE(
bool)
389 unsigned IsUnused : 1;
390 LLVM_PREFERRED_TYPE(
bool)
391 unsigned IsExternallyDestructed : 1;
397 bool IsExternallyDestructed =
false)
398 : Addr(Addr), IsVolatile(IsVolatile), IsUnused(IsUnused),
399 IsExternallyDestructed(IsExternallyDestructed) {}
401 bool isNull()
const {
return !Addr.isValid(); }
417 return static_cast<FnInfoOpts>(llvm::to_underlying(A) |
418 llvm::to_underlying(B));
422 return static_cast<FnInfoOpts>(llvm::to_underlying(A) &
423 llvm::to_underlying(B));
Forward declaration of all AST node types.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
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]).
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
void setPointerAuthInfo(CGPointerAuthInfo PointerAuth)
const CXXPseudoDestructorExpr * getPseudoDestructorExpr() const
Address getThisAddress() const
const CallExpr * getVirtualCallExpr() const
CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr, const CGPointerAuthInfo &pointerAuthInfo=CGPointerAuthInfo())
Construct a callee.
BuiltinInfoStorage BuiltinInfo
bool isPseudoDestructor() const
llvm::Value * getFunctionPointer() const
PseudoDestructorInfoStorage PseudoDestructorInfo
static CGCallee forBuiltin(unsigned builtinID, const FunctionDecl *builtinDecl)
unsigned getBuiltinID() const
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())
llvm::FunctionType * getVirtualFunctionType() const
OrdinaryInfoStorage OrdinaryInfo
const FunctionDecl * getBuiltinDecl() const
const CGPointerAuthInfo & getPointerAuthInfo() const
static CGCallee forPseudoDestructor(const CXXPseudoDestructorExpr *E)
GlobalDecl getVirtualMethodDecl() const
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse, const Expr *writebackExpr=nullptr)
llvm::Instruction * getStackBase() const
void addUncopiedAggregate(LValue LV, QualType type)
llvm::iterator_range< SmallVectorImpl< Writeback >::const_iterator > writeback_const_range
void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *IsActiveIP)
ArrayRef< CallArgCleanup > getCleanupsToDeactivate() const
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 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.
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.
A (possibly-)qualified type.
Options for controlling the target.
Represents a variable declaration or definition.
@ 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)
BlockFlags operator|(BlockLiteralFlags l, BlockLiteralFlags r)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
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.
const Expr * WritebackExpr
An Expression (optional) that performs the writeback with any required casting.
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
~DisableDebugLocationUpdates()
DisableDebugLocationUpdates(CodeGenFunction &CGF)
DisableDebugLocationUpdates(const DisableDebugLocationUpdates &)=delete
DisableDebugLocationUpdates & operator=(const DisableDebugLocationUpdates &)=delete