13#ifndef LLVM_CLANG_AST_INTERP_INTERPFRAME_H
14#define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
37 CodePtr RetPC,
unsigned ArgSize);
44 unsigned VarArgSize = 0);
58 return "Bottom frame";
59 return Func->getName();
65 delete[]
reinterpret_cast<char *
>(F);
77 return localInlineDesc(Idx)->IsActive;
81 void describe(llvm::raw_ostream &OS)
const override;
101 template <
typename T>
const T &
getLocal(
unsigned Offset)
const {
102 return localRef<T>(Offset);
107 localRef<T>(Offset) =
Value;
108 localInlineDesc(Offset)->IsInitialized =
true;
117 template <
typename T>
const T &
getParam(
unsigned Index)
const {
118 Block *ArgBlock = argBlock(Index);
120 return stackRef<T>(Func->getParamDescriptor(Index).Offset);
121 return ArgBlock->
deref<T>();
126 argBlock(Index)->deref<T>() =
Value;
138 return stackRef<Pointer>((FuncFlags & HasRVOFlag) ?
sizeof(
Pointer) : 0);
144 assert(Func->hasRVO());
146 return stackRef<Pointer>(0);
171 void dump(llvm::raw_ostream &OS,
unsigned Indent = 0)
const;
174 static constexpr uint8_t HasRVOFlag = 1u << 0u;
175 static constexpr uint8_t HasThisFlag = 1u << 1u;
178 template <
typename T>
const T &stackRef(
unsigned Offset)
const {
180 return *
reinterpret_cast<const T *
>(Args - ArgSize + Offset);
184 template <
typename T> T &localRef(
unsigned Offset)
const {
185 return localBlock(Offset)->
deref<T>();
189 char *locals()
const {
190 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
196 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
201 Block *localBlock(
unsigned Offset)
const {
202 return reinterpret_cast<Block *
>(locals() + Offset -
sizeof(
Block));
206 Block *argBlock(
unsigned Index)
const {
207 unsigned ByteOffset = Func->getParamDescriptor(Index).BlockOffset;
208 return reinterpret_cast<Block *
>(args() + ByteOffset);
212 InlineDescriptor *localInlineDesc(
unsigned Offset)
const {
213 return reinterpret_cast<InlineDescriptor *
>(locals() + Offset);
226 const unsigned ArgSize;
228 char *Args =
nullptr;
231 size_t FrameOffset = 0;
Expr * getExpr()
Get 'expr' part of the associated expression/statement.
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.
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.
static void free(InterpFrame *F)
InterpFrame(InterpState &S)
Bottom Frame.
bool isLocalEnabled(unsigned Idx) const
void setParam(unsigned Index, const T &Value)
Mutates a local copy of a parameter.
InterpFrame * Caller
The frame of the previous function.
Frame * getCaller() const override
Returns the parent frame object.
SourceInfo getSource(CodePtr PC) const
Map a location to a source.
CodePtr getRetPC() const
Returns the return address of the frame.
void enableLocal(unsigned Idx)
Block * getLocalBlock(unsigned Offset) const
CodePtr getPC() const
Returns the PC of the frame's code start.
SourceLocation getLocation(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.
SourceRange getRange(CodePtr PC) const
void setLocal(unsigned Offset, const T &Value)
Mutates a local variable.
bool isBottomFrame() const
bool isRoot() const
Checks if the frame is a root frame - return should quit the interpreter.
bool hasThisPointer() const
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
unsigned getDepth() const
const T & getParam(unsigned Index) const
Returns the value of an argument.
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.
std::string getName() const
bool isStdFunction() const
void initScope(unsigned Idx)
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.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
The JSON file list parser is used to communicate input to InstallAPI.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t