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();
69 void describe(llvm::raw_ostream &OS)
const override;
89 template <
typename T>
const T &
getLocal(
unsigned Offset)
const {
90 return localRef<T>(Offset);
99 LID.IsInitialized =
true;
105 assert(Offset < Func->getFrameSize() &&
"Invalid local offset.");
109 Block *B = localBlock(Offset);
118 template <
typename T>
const T &
getParam(
unsigned Index)
const {
119 Block *ArgBlock = argBlock(Index);
121 return stackRef<T>(Func->getParamDescriptor(Index).Offset);
122 return ArgBlock->
deref<
T>();
127 argBlock(Index)->deref<
T>() =
Value;
139 return stackRef<Pointer>((FuncFlags & HasRVOFlag) ?
sizeof(
Pointer) : 0);
145 assert(Func->hasRVO());
147 return stackRef<Pointer>(0);
155 return RetPC -
align(
sizeof(
void *)) -
align(
sizeof(
unsigned));
174 void dump(llvm::raw_ostream &OS,
unsigned Indent = 0)
const;
177 static constexpr uint8_t HasRVOFlag = 1u << 0u;
178 static constexpr uint8_t HasThisFlag = 1u << 1u;
181 template <
typename T>
const T &stackRef(
unsigned Offset)
const {
183 return *
reinterpret_cast<const T *
>(Args - ArgSize + Offset);
187 template <
typename T>
T &localRef(
unsigned Offset)
const {
188 return localBlock(Offset)->
deref<
T>();
192 char *locals()
const {
193 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
199 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
205 Block *localBlock(
unsigned Offset)
const {
206 return reinterpret_cast<Block *
>(locals() + Offset -
sizeof(
Block));
210 Block *argBlock(
unsigned Index)
const {
211 unsigned ByteOffset = Func->getParamDescriptor(Index).BlockOffset;
212 return reinterpret_cast<Block *
>(args() + ByteOffset);
216 LocalInlineDescriptor *localInlineDesc(
unsigned Offset)
const {
217 return reinterpret_cast<LocalInlineDescriptor *
>(locals() + Offset);
232 char *Args =
nullptr;
235 size_t FrameOffset = 0;
238 const unsigned ArgSize;
245 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.
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