clang 17.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)
 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 ParmVarDecl *PD)
 Returns or creates a dummy value for parameters.
 
std::optional< unsignedcreateGlobal (const ValueDecl *VD, const Expr *E)
 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 40 of file Program.h.

Constructor & Destructor Documentation

◆ Program()

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

Definition at line 42 of file Program.h.

◆ ~Program()

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

Definition at line 44 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 117 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 96 of file Program.h.

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

◆ createGlobal() [1/2]

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

Creates a global from a lifetime-extended temporary.

Definition at line 178 of file Program.cpp.

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

◆ createGlobal() [2/2]

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

Creates a global and returns its index.

Definition at line 159 of file Program.cpp.

References createGlobal(), getGlobal(), clang::ValueDecl::getType(), IsStatic, and P.

Referenced by createGlobal(), getOrCreateDummy(), 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 69 of file Disasm.cpp.

References dump().

Referenced by dump().

◆ dump() [2/2]

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

Definition at line 71 of file Disasm.cpp.

◆ getCurrentDecl()

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

Returns the current declaration ID.

Definition at line 142 of file Program.h.

◆ getFunction()

Function * Program::getFunction ( const FunctionDecl F)

Returns a function.

Definition at line 210 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 104 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 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 ParmVarDecl PD)

Returns or creates a dummy value for parameters.

Definition at line 140 of file Program.cpp.

References clang::Type::castAs(), createGlobal(), clang::interp::Context::getASTContext(), clang::ValueDecl::getType(), and clang::ArrayType::Normal.

◆ 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 128 of file Program.cpp.

References createGlobal(), and getGlobal().

◆ 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)

Returns a pointer to a global.

Definition at line 99 of file Program.cpp.

Friends And Related Function Documentation

◆ DeclScope

friend class DeclScope
friend

Definition at line 149 of file Program.h.


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