13#ifndef LLVM_CLANG_AST_INTERP_INTERPFRAME_H
14#define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
34 CodePtr RetPC,
unsigned ArgSize);
41 unsigned VarArgSize = 0);
55 return "Bottom frame";
56 return Func->getName();
67 void describe(llvm::raw_ostream &OS)
const override;
87 template <
typename T>
const T &
getLocal(
unsigned Offset)
const {
88 return localRef<T>(Offset);
97 LID.IsInitialized =
true;
103 assert(Offset < Func->getFrameSize() &&
"Invalid local offset.");
107 Block *B = localBlock(Offset);
116 template <
typename T>
const T &
getParam(
unsigned Index)
const {
117 Block *ArgBlock = argBlock(Index);
119 return stackRef<T>(Func->getParamDescriptor(Index).Offset);
120 return ArgBlock->
deref<
T>();
125 argBlock(Index)->deref<
T>() =
Value;
137 return stackRef<Pointer>((FuncFlags & HasRVOFlag) ?
sizeof(
Pointer) : 0);
143 assert(Func->hasRVO());
145 return stackRef<Pointer>(0);
153 return RetPC -
align(
sizeof(
void *)) -
align(
sizeof(
unsigned));
172 void dump(llvm::raw_ostream &OS,
unsigned Indent = 0)
const;
175 static constexpr uint8_t HasRVOFlag = 1u << 0u;
176 static constexpr uint8_t HasThisFlag = 1u << 1u;
179 template <
typename T>
const T &stackRef(
unsigned Offset)
const {
181 return *
reinterpret_cast<const T *
>(Args - ArgSize + Offset);
185 template <
typename T>
T &localRef(
unsigned Offset)
const {
186 return localBlock(Offset)->
deref<
T>();
190 char *locals()
const {
191 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
197 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
203 Block *localBlock(
unsigned Offset)
const {
204 return reinterpret_cast<Block *
>(locals() + Offset -
sizeof(
Block));
208 Block *argBlock(
unsigned Index)
const {
209 unsigned ByteOffset = Func->getParamDescriptor(Index).BlockOffset;
210 return reinterpret_cast<Block *
>(args() + ByteOffset);
214 InlineDescriptor *localInlineDesc(
unsigned Offset)
const {
215 return reinterpret_cast<InlineDescriptor *
>(locals() + Offset);
230 char *Args =
nullptr;
233 size_t FrameOffset = 0;
236 const unsigned ArgSize;
243 uint8_t FuncFlags = 0;
This represents one expression.
Represents a function declaration or definition.
Encodes a location in the source.
A trivial tuple used to represent a source range.
A memory block, either on the stack or in the heap.
const Descriptor * getDescriptor() const
Returns the block's descriptor.
void invokeCtor()
Invokes the constructor.
bool isInitialized() const
Returns whether the data of this block has been initialized via invoking the Ctor func.
Pointer into the code segment.
Base class for stack frames, shared between VM and walker.
unsigned getFrameSize() const
Returns the size of the function's local stack.
unsigned getNumWrittenParams() const
Returns the number of parameter this function takes when it's called, i.e excluding the instance poin...
unsigned getArgSize() const
Returns the size of the argument stack.
SourceLocation getLocation(CodePtr PC) const
CodePtr getRetOpPC() const
Returns the return address of the opcode in the caller frame.
InterpFrame(InterpState &S)
Bottom Frame.
void setParam(unsigned Index, const T &Value)
Mutates a local copy of a parameter.
InterpFrame * Caller
The frame of the previous function.
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
Frame * getCaller() const override
Returns the parent frame object.
SourceInfo getSource(CodePtr PC) const
Map a location to a source.
SourceRange getRange(CodePtr PC) const
~InterpFrame()
Destroys the frame, killing all live pointers to stack slots.
const Pointer & getThis() const
Returns the 'this' pointer.
unsigned MSVCConstexprAllowed
const Function * getFunction() const
Returns the current function.
size_t getFrameOffset() const
Returns the offset on the stack at which the frame starts.
void setLocal(unsigned Offset, const T &Value)
Mutates a local variable.
bool isBottomFrame() const
unsigned getArgSize() const
Block * getLocalBlock(unsigned Offset) const
bool hasThisPointer() const
const Expr * getExpr(CodePtr PC) const
const T & getParam(unsigned Index) const
Returns the value of an argument.
bool isLocalEnabled(unsigned Offset) const
void destroy(unsigned Idx)
Invokes the destructors for a scope.
const Pointer & getRVOPtr() const
Returns the RVO pointer, if the Function has one.
Pointer getParamPointer(unsigned Offset)
Returns a pointer to an argument - lazily creates a block.
const FunctionDecl * getCallee() const override
Returns the caller.
void enableLocal(unsigned Offset)
std::string getName() const
bool isStdFunction() const
const T & getLocal(unsigned Offset) const
Returns the value of a local variable.
SourceRange getCallRange() const override
Returns the location of the call to the frame.
void describe(llvm::raw_ostream &OS) const override
Describes the frame with arguments for diagnostic purposes.
static size_t allocSize(const Function *F)
Returns the number of bytes needed to allocate an InterpFrame for the given function.
A pointer to a memory block, live or dead.
Describes the statement/declaration an opcode was generated from.
const Expr * asExpr() const
SourceLocation getLoc() const
SourceRange getRange() const
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Top level wrappers for InstallAPI frontend operations.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
const FunctionProtoType * T
Inline descriptor embedded in structures and arrays.