clang 20.0.0git
|
The program contains and links the bytecode for all functions. More...
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/Program.h"
Classes | |
class | DeclScope |
Context to manage declaration lifetimes. More... | |
Public Member Functions | |
Program (Context &Ctx) | |
~Program () | |
unsigned | getOrCreateNativePointer (const void *Ptr) |
Marshals a native pointer to an ID for embedding in bytecode. | |
const void * | getNativePointer (unsigned Idx) |
Returns the value of a marshalled native pointer. | |
unsigned | createGlobalString (const StringLiteral *S) |
Emits a string literal among global data. | |
Pointer | getPtrGlobal (unsigned Idx) const |
Returns a pointer to a global. | |
Block * | getGlobal (unsigned Idx) |
Returns the value of a global. | |
std::optional< unsigned > | getGlobal (const ValueDecl *VD) |
Finds a global's index. | |
std::optional< unsigned > | getGlobal (const Expr *E) |
std::optional< unsigned > | getOrCreateGlobal (const ValueDecl *VD, const Expr *Init=nullptr) |
Returns or creates a global an creates an index to it. | |
std::optional< unsigned > | getOrCreateDummy (const ValueDecl *VD) |
Returns or creates a dummy value for unknown declarations. | |
std::optional< unsigned > | createGlobal (const ValueDecl *VD, const Expr *Init) |
Creates a global and returns its index. | |
std::optional< unsigned > | createGlobal (const Expr *E) |
Creates a global from a lifetime-extended temporary. | |
template<typename... Ts> | |
Function * | createFunction (const FunctionDecl *Def, Ts &&...Args) |
Creates a new function from a code range. | |
template<typename... Ts> | |
Function * | createFunction (Ts &&...Args) |
Creates an anonymous function. | |
Function * | getFunction (const FunctionDecl *F) |
Returns a function. | |
Record * | getOrCreateRecord (const RecordDecl *RD) |
Returns a record or creates one if it does not exist. | |
Descriptor * | createDescriptor (const DeclTy &D, PrimType Type, Descriptor::MetadataSize MDSize=std::nullopt, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false) |
Creates a descriptor for a primitive type. | |
Descriptor * | createDescriptor (const DeclTy &D, const Type *Ty, Descriptor::MetadataSize MDSize=std::nullopt, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false, const Expr *Init=nullptr) |
Creates a descriptor for a composite type. | |
std::optional< unsigned > | getCurrentDecl () const |
Returns the current declaration ID. | |
void | dump () const |
Dumps the disassembled bytecode to llvm::errs() . | |
void | dump (llvm::raw_ostream &OS) const |
Friends | |
class | DeclScope |
The program contains and links the bytecode for all functions.
|
inline |
Definition at line 43 of file Program.h.
References clang::Global, and clang::interp::Block::isInitialized().
Descriptor * Program::createDescriptor | ( | const DeclTy & | D, |
const Type * | Ty, | ||
Descriptor::MetadataSize | MDSize = std::nullopt , |
||
bool | IsConst = false , |
||
bool | IsTemporary = false , |
||
bool | IsMutable = false , |
||
const Expr * | Init = nullptr |
||
) |
Creates a descriptor for a composite type.
Definition at line 364 of file Program.cpp.
References clang::interp::Context::classify(), createDescriptor(), D, clang::interp::Descriptor::getAllocSize(), clang::Type::getAs(), clang::Type::getAsArrayTypeUnsafe(), clang::ArrayType::getElementType(), getOrCreateRecord(), clang::QualType::getTypePtr(), clang::interp::primSize(), and clang::T.
|
inline |
Creates a descriptor for a primitive type.
Definition at line 117 of file Program.h.
References D.
Referenced by clang::interp::ByteCodeEmitter::compileFunc(), clang::interp::ByteCodeEmitter::compileObjCBlock(), createDescriptor(), getOrCreateDummy(), and getOrCreateRecord().
|
inline |
Creates a new function from a code range.
Definition at line 97 of file Program.h.
References clang::Func, and clang::FunctionDecl::getCanonicalDecl().
Referenced by clang::interp::ByteCodeEmitter::compileFunc(), and clang::interp::ByteCodeEmitter::compileObjCBlock().
|
inline |
Creates a global from a lifetime-extended temporary.
Definition at line 204 of file Program.cpp.
References createGlobal(), E, getGlobal(), and clang::Expr::getType().
Creates a global and returns its index.
Definition at line 182 of file Program.cpp.
References createGlobal(), clang::ValueDecl::getType(), clang::Init, clang::isa(), IsStatic, P, and clang::interp::Context::shouldBeGloballyIndexed().
Referenced by createGlobal(), and getOrCreateGlobal().
unsigned Program::createGlobalString | ( | const StringLiteral * | S | ) |
Emits a string literal among global data.
Definition at line 36 of file Program.cpp.
References clang::interp::Pointer::atIndex(), clang::interp::Descriptor::getAllocSize(), clang::interp::Context::getCharBit(), clang::interp::Context::getEvalID(), clang::Global, clang::interp::Descriptor::GlobalMD, clang::interp::Pointer::narrow(), clang::interp::PT_Sint8, clang::interp::PT_Uint16, clang::interp::PT_Uint32, and clang::T.
LLVM_DUMP_METHOD void Program::dump | ( | ) | const |
Dumps the disassembled bytecode to llvm::errs()
.
Definition at line 95 of file Disasm.cpp.
References dump().
Referenced by dump().
LLVM_DUMP_METHOD void Program::dump | ( | llvm::raw_ostream & | OS | ) | const |
Definition at line 133 of file Disasm.cpp.
References clang::interp::Descriptor::asExpr(), clang::interp::Descriptor::dump(), clang::Func, clang::interp::Context::getASTContext(), clang::interp::Descriptor::getPrimType(), getPtrGlobal(), clang::Global, clang::interp::Descriptor::isDummy(), clang::interp::Pointer::isInitialized(), clang::interp::Descriptor::isPrimitive(), clang::interp::Descriptor::IsTemporary, primTypeToString(), TYPE_SWITCH, and V.
|
inline |
Returns the current declaration ID.
Definition at line 144 of file Program.h.
Referenced by getOrCreateDummy().
Function * Program::getFunction | ( | const FunctionDecl * | F | ) |
Returns a function.
Definition at line 247 of file Program.cpp.
References clang::FunctionDecl::getCanonicalDecl().
Referenced by clang::interp::ByteCodeEmitter::compileFunc(), and clang::interp::MemberPointer::toFunctionPointer().
Definition at line 129 of file Program.cpp.
References E.
Finds a global's index.
Definition at line 109 of file Program.cpp.
References clang::Decl::getPreviousDecl(), and P.
Returns the value of a global.
Definition at line 73 of file Program.h.
Referenced by createGlobal(), and getOrCreateGlobal().
const void * Program::getNativePointer | ( | unsigned | Idx | ) |
Returns the value of a marshalled native pointer.
Definition at line 32 of file Program.cpp.
Returns or creates a dummy value for unknown declarations.
Definition at line 147 of file Program.cpp.
References clang::interp::Context::classify(), createDescriptor(), clang::interp::Descriptor::getAllocSize(), clang::Type::getAs(), getCurrentDecl(), clang::interp::Context::getEvalID(), clang::Type::getPointeeType(), clang::ValueDecl::getType(), clang::QualType::getTypePtr(), clang::Global, clang::interp::Descriptor::isDummy(), clang::interp::Descriptor::makeDummy(), and clang::T.
std::optional< unsigned > Program::getOrCreateGlobal | ( | const ValueDecl * | VD, |
const Expr * | Init = nullptr |
||
) |
Returns or creates a global an creates an index to it.
Definition at line 135 of file Program.cpp.
References createGlobal(), getGlobal(), and clang::Init.
unsigned Program::getOrCreateNativePointer | ( | const void * | Ptr | ) |
Marshals a native pointer to an ID for embedding in bytecode.
Definition at line 21 of file Program.cpp.
Record * Program::getOrCreateRecord | ( | const RecordDecl * | RD | ) |
Returns a record or creates one if it does not exist.
Definition at line 254 of file Program.cpp.
References clang::interp::align(), clang::interp::Context::classify(), createDescriptor(), clang::RecordDecl::fields(), clang::interp::Descriptor::getAllocSize(), clang::RecordDecl::getDefinition(), getOrCreateRecord(), clang::interp::Record::getSize(), clang::QualType::getTypePtr(), clang::TagDecl::isCompleteDefinition(), clang::QualType::isConstQualified(), and clang::T.
Referenced by clang::interp::ByteCodeEmitter::compileFunc(), createDescriptor(), and getOrCreateRecord().