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

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)
 
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)
 Returns a pointer to a global. More...
 
BlockgetGlobal (unsigned Idx)
 Returns the value of a global. More...
 
llvm::Optional< unsignedgetGlobal (const ValueDecl *VD)
 Finds a global's index. More...
 
llvm::Optional< unsignedgetOrCreateGlobal (const ValueDecl *VD)
 Returns or creates a global an creates an index to it. More...
 
llvm::Optional< unsignedgetOrCreateDummy (const ParmVarDecl *PD)
 Returns or creates a dummy value for parameters. More...
 
llvm::Optional< unsignedcreateGlobal (const ValueDecl *VD)
 Creates a global and returns its index. More...
 
llvm::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...
 
llvm::Expected< Function * > getOrCreateFunction (const FunctionDecl *F)
 Returns a pointer to a function if it exists and can be compiled. More...
 
RecordgetOrCreateRecord (const RecordDecl *RD)
 Returns a record or creates one if it does not exist. More...
 
DescriptorcreateDescriptor (const DeclTy &D, PrimType Type, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false)
 Creates a descriptor for a primitive type. More...
 
DescriptorcreateDescriptor (const DeclTy &D, const Type *Ty, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false)
 Creates a descriptor for a composite type. More...
 
llvm::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 43 of file Program.h.

Constructor & Destructor Documentation

◆ Program()

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

Definition at line 45 of file Program.h.

Member Function Documentation

◆ createDescriptor() [1/2]

Descriptor * Program::createDescriptor ( const DeclTy D,
const Type Ty,
bool  IsConst = false,
bool  IsTemporary = false,
bool  IsMutable = false 
)

◆ createDescriptor() [2/2]

Descriptor* clang::interp::Program::createDescriptor ( const DeclTy D,
PrimType  Type,
bool  IsConst = false,
bool  IsTemporary = false,
bool  IsMutable = false 
)
inline

Creates a descriptor for a primitive type.

Definition at line 107 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 82 of file Program.h.

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

◆ createGlobal() [1/2]

llvm::Optional< unsigned > Program::createGlobal ( const Expr E)

Creates a global from a lifetime-extended temporary.

Definition at line 173 of file Program.cpp.

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

◆ createGlobal() [2/2]

llvm::Optional< unsigned > Program::createGlobal ( const ValueDecl VD)

Creates a global and returns its index.

Definition at line 156 of file Program.cpp.

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

Referenced by createGlobal(), getOrCreateDummy(), and getOrCreateGlobal().

◆ createGlobalString()

unsigned Program::createGlobalString ( const StringLiteral S)

Emits a string literal among global data.

Definition at line 36 of file Program.cpp.

◆ dump() [1/2]

LLVM_DUMP_METHOD void Program::dump ( ) const

Dumps the disassembled bytecode to llvm::errs().

Definition at line 74 of file Disasm.cpp.

◆ dump() [2/2]

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

Definition at line 76 of file Disasm.cpp.

◆ getCurrentDecl()

llvm::Optional<unsigned> clang::interp::Program::getCurrentDecl ( ) const
inline

Returns the current declaration ID.

Definition at line 130 of file Program.h.

◆ getFunction()

Function * Program::getFunction ( const FunctionDecl F)

Returns a function.

Definition at line 203 of file Program.cpp.

References clang::FunctionDecl::getDefinition().

Referenced by getOrCreateFunction().

◆ getGlobal() [1/2]

llvm::Optional< unsigned > Program::getGlobal ( const ValueDecl VD)

Finds a global's index.

Definition at line 102 of file Program.cpp.

◆ getGlobal() [2/2]

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

Returns the value of a global.

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

◆ getOrCreateDummy()

llvm::Optional< unsigned > Program::getOrCreateDummy ( const ParmVarDecl PD)

Returns or creates a dummy value for parameters.

Definition at line 137 of file Program.cpp.

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

◆ getOrCreateFunction()

llvm::Expected< Function * > Program::getOrCreateFunction ( const FunctionDecl F)

Returns a pointer to a function if it exists and can be compiled.

If a function couldn't be compiled, an error is returned. If a function was not yet defined, a null pointer is returned.

Definition at line 209 of file Program.cpp.

References clang::FunctionDecl::getDefinition(), and getFunction().

◆ getOrCreateGlobal()

llvm::Optional< unsigned > Program::getOrCreateGlobal ( const ValueDecl VD)

Returns or creates a global an creates an index to it.

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

Friends And Related Function Documentation

◆ DeclScope

friend class DeclScope
friend

Definition at line 137 of file Program.h.


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