clang 19.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/Interp/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< 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.

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 116 of file Program.h.

Referenced by clang::interp::ByteCodeEmitter::compileFunc(), createDescriptor(), 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 95 of file Program.h.

References clang::Func, and clang::FunctionDecl::getCanonicalDecl().

Referenced by clang::interp::ByteCodeEmitter::compileFunc().

◆ createFunction() [2/2]

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

Creates an anonymous function.

Definition at line 103 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 196 of file Program.cpp.

References createGlobal(), 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 174 of file Program.cpp.

References createGlobal(), getGlobal(), clang::ValueDecl::getType(), clang::Init, 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 91 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 143 of file Program.h.

Referenced by getOrCreateDummy().

◆ getFunction()

Function * Program::getFunction ( const FunctionDecl F)

Returns a function.

Definition at line 231 of file Program.cpp.

References clang::FunctionDecl::getCanonicalDecl().

Referenced by clang::interp::ByteCodeEmitter::compileFunc().

◆ getGlobal() [1/2]

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

Finds a global's index.

Definition at line 110 of file Program.cpp.

References P.

◆ getGlobal() [2/2]

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

Returns the value of a global.

Definition at line 72 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 33 of file Program.cpp.

◆ getOrCreateDummy()

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

Returns or creates a dummy value for unknown declarations.

Definition at line 146 of file Program.cpp.

References clang::interp::Descriptor::getAllocSize(), clang::Type::getAsArrayTypeUnsafe(), getCurrentDecl(), and clang::ValueDecl::getType().

◆ 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 134 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 22 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 105 of file Program.cpp.

Referenced by dump().

Friends And Related Function Documentation

◆ DeclScope

friend class DeclScope
friend

Definition at line 150 of file Program.h.


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