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();
64 return localInlineDesc(Idx)->IsActive;
68 void describe(llvm::raw_ostream &OS)
const override;
88 template <
typename T>
const T &
getLocal(
unsigned Offset)
const {
89 return localRef<T>(Offset);
94 localRef<T>(Offset) =
Value;
95 localInlineDesc(Offset)->IsInitialized =
true;
104 template <
typename T>
const T &
getParam(
unsigned Index)
const {
105 Block *ArgBlock = argBlock(Index);
107 return stackRef<T>(Func->getParamDescriptor(Index).Offset);
108 return ArgBlock->
deref<
T>();
113 argBlock(Index)->deref<
T>() =
Value;
125 return stackRef<Pointer>((FuncFlags & HasRVOFlag) ?
sizeof(
Pointer) : 0);
131 assert(Func->hasRVO());
133 return stackRef<Pointer>(0);
141 return RetPC -
align(
sizeof(
void *)) -
align(
sizeof(
unsigned));
161 void dump(llvm::raw_ostream &OS,
unsigned Indent = 0)
const;
164 static constexpr uint8_t HasRVOFlag = 1u << 0u;
165 static constexpr uint8_t HasThisFlag = 1u << 1u;
168 template <
typename T>
const T &stackRef(
unsigned Offset)
const {
170 return *
reinterpret_cast<const T *
>(Args - ArgSize + Offset);
174 template <
typename T>
T &localRef(
unsigned Offset)
const {
175 return localBlock(Offset)->
deref<
T>();
179 char *locals()
const {
180 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
186 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
191 Block *localBlock(
unsigned Offset)
const {
192 return reinterpret_cast<Block *
>(locals() + Offset -
sizeof(
Block));
196 Block *argBlock(
unsigned Index)
const {
197 unsigned ByteOffset = Func->getParamDescriptor(Index).BlockOffset;
198 return reinterpret_cast<Block *
>(args() + ByteOffset);
202 InlineDescriptor *localInlineDesc(
unsigned Offset)
const {
203 return reinterpret_cast<InlineDescriptor *
>(locals() + Offset);
218 char *Args =
nullptr;
221 size_t FrameOffset = 0;
224 const unsigned ArgSize;
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.
SourceLocation getLocation(CodePtr PC) const
CodePtr getRetOpPC() const
Returns the return address of the opcode in the caller frame.
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.
SourceRange getRange(CodePtr PC) const
void enableLocal(unsigned Idx)
Block * getLocalBlock(unsigned Offset) 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
bool hasThisPointer() const
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
const Expr * getExpr(CodePtr PC) const
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.
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
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t