clang 20.0.0git
Classes | Public Member Functions | Friends | List of all members
clang::interp::Program Class Referencefinal

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.
 
BlockgetGlobal (unsigned Idx)
 Returns the value of a global.
 
std::optional< unsignedgetGlobal (const ValueDecl *VD)
 Finds a global's index.
 
std::optional< unsignedgetGlobal (const Expr *E)
 
std::optional< unsignedgetOrCreateGlobal (const ValueDecl *VD, const Expr *Init=nullptr)
 Returns or creates a global an creates an index to it.
 
std::optional< unsignedgetOrCreateDummy (const ValueDecl *VD)
 Returns or creates a dummy value for unknown declarations.
 
std::optional< unsignedcreateGlobal (const ValueDecl *VD, const Expr *Init)
 Creates a global and returns its index.
 
std::optional< unsignedcreateGlobal (const Expr *E)
 Creates a global from a lifetime-extended temporary.
 
template<typename... Ts>
FunctioncreateFunction (const FunctionDecl *Def, Ts &&...Args)
 Creates a new function from a code range.
 
template<typename... Ts>
FunctioncreateFunction (Ts &&...Args)
 Creates an anonymous function.
 
FunctiongetFunction (const FunctionDecl *F)
 Returns a function.
 
RecordgetOrCreateRecord (const RecordDecl *RD)
 Returns a record or creates one if it does not exist.
 
DescriptorcreateDescriptor (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.
 
DescriptorcreateDescriptor (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< unsignedgetCurrentDecl () 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
 

Detailed Description

The program contains and links the bytecode for all functions.

Definition at line 39 of file Program.h.

Constructor & Destructor Documentation

◆ Program()

clang::interp::Program::Program ( Context Ctx)
inline

Definition at line 41 of file Program.h.

◆ ~Program()

clang::interp::Program::~Program ( )
inline

Definition at line 43 of file Program.h.

References clang::Global, and clang::interp::Block::isInitialized().

Member Function Documentation

◆ createDescriptor() [1/2]

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 
)

◆ createDescriptor() [2/2]

Descriptor * clang::interp::Program::createDescriptor ( const DeclTy D,
PrimType  Type,
Descriptor::MetadataSize  MDSize = std::nullopt,
bool  IsConst = false,
bool  IsTemporary = false,
bool  IsMutable = false 
)
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().

◆ createFunction() [1/2]

template<typename... Ts>
Function * clang::interp::Program::createFunction ( const FunctionDecl Def,
Ts &&...  Args 
)
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().

◆ createFunction() [2/2]

template<typename... Ts>
Function * clang::interp::Program::createFunction ( Ts &&...  Args)
inline

Creates an anonymous function.

Definition at line 104 of file Program.h.

References clang::Func.

◆ createGlobal() [1/2]

std::optional< unsigned > Program::createGlobal ( const Expr E)

Creates a global from a lifetime-extended temporary.

Definition at line 204 of file Program.cpp.

References createGlobal(), E, getGlobal(), and clang::Expr::getType().

◆ createGlobal() [2/2]

std::optional< unsigned > Program::createGlobal ( const ValueDecl VD,
const Expr Init 
)

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().

◆ createGlobalString()

unsigned Program::createGlobalString ( const StringLiteral S)

◆ dump() [1/2]

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().

◆ dump() [2/2]

LLVM_DUMP_METHOD void Program::dump ( llvm::raw_ostream &  OS) const

◆ getCurrentDecl()

std::optional< unsigned > clang::interp::Program::getCurrentDecl ( ) const
inline

Returns the current declaration ID.

Definition at line 144 of file Program.h.

Referenced by getOrCreateDummy().

◆ getFunction()

Function * Program::getFunction ( const FunctionDecl F)

◆ getGlobal() [1/3]

std::optional< unsigned > Program::getGlobal ( const Expr E)

Definition at line 129 of file Program.cpp.

References E.

◆ getGlobal() [2/3]

std::optional< unsigned > Program::getGlobal ( const ValueDecl VD)

Finds a global's index.

Definition at line 109 of file Program.cpp.

References clang::Decl::getPreviousDecl(), and P.

◆ getGlobal() [3/3]

Block * clang::interp::Program::getGlobal ( unsigned  Idx)
inline

Returns the value of a global.

Definition at line 73 of file Program.h.

Referenced by createGlobal(), and getOrCreateGlobal().

◆ getNativePointer()

const void * Program::getNativePointer ( unsigned  Idx)

Returns the value of a marshalled native pointer.

Definition at line 32 of file Program.cpp.

◆ getOrCreateDummy()

std::optional< unsigned > Program::getOrCreateDummy ( const ValueDecl VD)

◆ getOrCreateGlobal()

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.

◆ getOrCreateNativePointer()

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.

◆ getOrCreateRecord()

Record * Program::getOrCreateRecord ( const RecordDecl RD)

◆ getPtrGlobal()

Pointer Program::getPtrGlobal ( unsigned  Idx) const

Returns a pointer to a global.

Definition at line 104 of file Program.cpp.

Referenced by dump().

Friends And Related Function Documentation

◆ DeclScope

friend class DeclScope
friend

Definition at line 151 of file Program.h.


The documentation for this class was generated from the following files: