clang: lib/CodeGen/CGCall.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_LIB_CODEGEN_CGCALL_H
15#define LLVM_CLANG_LIB_CODEGEN_CGCALL_H
16
24#include "llvm/ADT/STLForwardCompat.h"
25#include "llvm/IR/Value.h"
26
27namespace llvm {
30}
31
34class FunctionDecl;
35class TargetOptions;
36class VarDecl;
37
38namespace CodeGen {
39
40
42
44
46
47public:
50 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
52 : CalleeProtoTy(calleeProtoTy) {}
54 : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
55
57 return CalleeProtoTy;
58 }
60};
61
62
64 enum class SpecialKind : uintptr_t {
65 Invalid,
66 Builtin,
67 PseudoDestructor,
69
71 };
72
73 struct OrdinaryInfoStorage {
76 };
77 struct BuiltinInfoStorage {
79 unsigned ID;
80 };
81 struct PseudoDestructorInfoStorage {
83 };
84 struct VirtualInfoStorage {
88 llvm::FunctionType *FTy;
89 };
90
91 SpecialKind KindOrFunctionPointer;
92 union {
97 };
98
99 explicit CGCallee(SpecialKind kind) : KindOrFunctionPointer(kind) {}
100
102 : KindOrFunctionPointer(SpecialKind::Builtin) {
105 }
106
107public:
108 CGCallee() : KindOrFunctionPointer(SpecialKind::Invalid) {}
109
110
111
113
115 : KindOrFunctionPointer(
116 SpecialKind(reinterpret_cast<uintptr_t>(functionPtr))) {
118 OrdinaryInfo.PointerAuthInfo = pointerAuthInfo;
119 assert(functionPtr && "configuring callee without function pointer");
120 assert(functionPtr->getType()->isPointerTy());
121 }
122
125 CGCallee result(SpecialKind::Builtin);
128 return result;
129 }
130
132 CGCallee result(SpecialKind::PseudoDestructor);
134 return result;
135 }
136
139 return CGCallee(abstractInfo, functionPtr);
140 }
141
144 return CGCallee(abstractInfo, functionPtr.getCallee());
145 }
146
148 llvm::FunctionType *FTy) {
149 CGCallee result(SpecialKind::Virtual);
154 return result;
155 }
156
158 return KindOrFunctionPointer == SpecialKind::Builtin;
159 }
163 }
167 }
168
170 return KindOrFunctionPointer == SpecialKind::PseudoDestructor;
171 }
175 }
176
178 return uintptr_t(KindOrFunctionPointer) > uintptr_t(SpecialKind::Last);
179 }
185 }
189 }
192 return reinterpret_cast<llvm::Value *>(uintptr_t(KindOrFunctionPointer));
193 }
196 KindOrFunctionPointer =
197 SpecialKind(reinterpret_cast<uintptr_t>(functionPtr));
198 }
202 }
203
205 return KindOrFunctionPointer == SpecialKind::Virtual;
206 }
210 }
214 }
218 }
222 }
223
224
225
227};
228
230private:
231 union {
234 };
235 bool HasLV;
236
237
238
239 mutable bool IsUsed;
240
241public:
249
250
251
253
255 assert(HasLV && !IsUsed);
256 return LV;
257 }
259 assert(!HasLV && !IsUsed);
260 return RV;
261 }
263 assert(!HasLV);
264 RV = _RV;
265 }
266
268
270};
271
272
273
275public:
277
279
280
282
283
285
286
288
289
290
292
293
295 };
296
299
300
301
303 };
304
306
309 }
310
311
312
313
315 insert(end(), other.begin(), other.end());
316 Writebacks.insert(Writebacks.end(), other.Writebacks.begin(),
317 other.Writebacks.end());
318 CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
319 other.CleanupsToDeactivate.begin(),
320 other.CleanupsToDeactivate.end());
321 assert(!(StackBase && other.StackBase) && "can't merge stackbases");
322 if (!StackBase)
323 StackBase = other.StackBase;
324 }
325
327 const Expr *writebackExpr = nullptr,
328 llvm::Value *lifetimeSz = nullptr) {
329 Writeback writeback = {srcLV, temporary, toUse, writebackExpr, lifetimeSz};
330 Writebacks.push_back(writeback);
331 }
332
334
335 typedef llvm::iterator_range<SmallVectorImpl::const_iterator>
337
340 }
341
343 llvm::Instruction *IsActiveIP) {
345 ArgCleanup.Cleanup = Cleanup;
347 CleanupsToDeactivate.push_back(ArgCleanup);
348 }
349
351 return CleanupsToDeactivate;
352 }
353
355 llvm::Instruction *getStackBase() const { return StackBase; }
357
358
359
361
362
364 std::reverse(Writebacks.begin(), Writebacks.end());
365 }
366
367private:
369
370
371
372
374
375
376 llvm::CallInst *StackBase = nullptr;
377};
378
379
380
381
383
384
385
388
389
390 LLVM_PREFERRED_TYPE(bool)
391 unsigned IsVolatile : 1;
392 LLVM_PREFERRED_TYPE(bool)
393 unsigned IsUnused : 1;
394 LLVM_PREFERRED_TYPE(bool)
395 unsigned IsExternallyDestructed : 1;
396
397public:
399 : IsVolatile(false), IsUnused(false), IsExternallyDestructed(false) {}
401 bool IsExternallyDestructed = false)
402 : Addr(Addr), IsVolatile(IsVolatile), IsUnused(IsUnused),
403 IsExternallyDestructed(IsExternallyDestructed) {}
404
408 bool isUnused() const { return IsUnused; }
411};
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
434 bool WillInternalize);
435
441};
442
444 return static_cast<FnInfoOpts>(llvm::to_underlying(A) |
445 llvm::to_underlying(B));
446}
447
449 return static_cast<FnInfoOpts>(llvm::to_underlying(A) &
450 llvm::to_underlying(B));
451}
452
454 A = A | B;
455 return A;
456}
457
459 A = A & B;
460 return A;
461}
462
463}
464}
465
466#endif
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
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
CallArgList - Type for representing both the value and type of arguments in a call.
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 addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse, const Expr *writebackExpr=nullptr, llvm::Value *lifetimeSz=nullptr)
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.
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.
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