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/runner/work/llvm/llvm/repo/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. More...
 
const void * getNativePointer (unsigned Idx)
 Returns the value of a marshalled native pointer. More...
 
unsigned createGlobalString (const StringLiteral *S)
 Emits a string literal among global data. More...
 
Pointer getPtrGlobal (unsigned Idx) const
 Returns a pointer to a global. More...
 
BlockgetGlobal (unsigned Idx)
 Returns the value of a global. More...
 
std::optional< unsignedgetGlobal (const ValueDecl *VD)
 Finds a global's index. More...
 
std::optional< unsignedgetOrCreateGlobal (const ValueDecl *VD, const Expr *Init=nullptr)
 Returns or creates a global an creates an index to it. More...
 
std::optional< unsignedgetOrCreateDummy (const ValueDecl *VD)
 Returns or creates a dummy value for unknown declarations. More...
 
std::optional< unsignedcreateGlobal (const ValueDecl *VD, const Expr *Init)
 Creates a global and returns its index. More...
 
std::optional< unsignedcreateGlobal (const Expr *E)
 Creates a global from a lifetime-extended temporary. More...
 
template<typename... Ts>
FunctioncreateFunction (const FunctionDecl *Def, Ts &&... Args)
 Creates a new function from a code range. More...
 
template<typename... Ts>
FunctioncreateFunction (Ts &&... Args)
 Creates an anonymous function. More...
 
FunctiongetFunction (const FunctionDecl *F)
 Returns a function. More...
 
RecordgetOrCreateRecord (const RecordDecl *RD)
 Returns a record or creates one if it does not exist. More...
 
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. More...
 
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. More...
 
std::optional< unsignedgetCurrentDecl () const
 Returns the current declaration ID. More...
 
void dump () const
 Dumps the disassembled bytecode to llvm::errs(). More...
 
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.

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(), 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 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 198 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 176 of file Program.cpp.

References clang::ValueDecl::getType(), clang::interp::Init(), clang::isa(), IsStatic, P, and clang::interp::Context::shouldBeGloballyIndexed().

Referenced by createGlobal(), and getOrCreateGlobal().

◆ createGlobalString()

unsigned Program::createGlobalString ( const StringLiteral S)

Emits a string literal among global data.

Definition at line 37 of file Program.cpp.

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

◆ 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 233 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.

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

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

References createGlobal(), getGlobal(), and clang::interp::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: