clang 20.0.0git
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
clang::interp::ByteCodeEmitter Class Referenceabstract

An emitter which links the program to bytecode for later use. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/ByteCodeEmitter.h"

Public Member Functions

FunctioncompileFunc (const FunctionDecl *FuncDecl)
 Compiles the function into the module.
 
FunctioncompileObjCBlock (const BlockExpr *BE)
 Compile an ObjC block, i.e.
 

Protected Types

using LabelTy = uint32_t
 
using AddrTy = uintptr_t
 
using Local = Scope::Local
 

Protected Member Functions

 ByteCodeEmitter (Context &Ctx, Program &P)
 
virtual ~ByteCodeEmitter ()
 
void emitLabel (LabelTy Label)
 Define a label.
 
LabelTy getLabel ()
 Create a label.
 
virtual bool visitFunc (const FunctionDecl *E)=0
 Methods implemented by the compiler.
 
virtual bool visitExpr (const Expr *E)=0
 
virtual bool visitDeclAndReturn (const VarDecl *E, bool ConstantContext)=0
 
bool jumpTrue (const LabelTy &Label)
 Emits jumps.
 
bool jumpFalse (const LabelTy &Label)
 
bool jump (const LabelTy &Label)
 
bool fallthrough (const LabelTy &Label)
 
bool isActive () const
 We're always emitting bytecode.
 
Local createLocal (Descriptor *D)
 Callback for local registration.
 

Protected Attributes

llvm::DenseMap< const ParmVarDecl *, ParamOffsetParams
 Parameter indices.
 
llvm::DenseMap< const ValueDecl *, ParamOffsetLambdaCaptures
 Lambda captures.
 
ParamOffset LambdaThisCapture {0, false}
 Offset of the This parameter in a lambda record.
 
llvm::SmallVector< SmallVector< Local, 8 >, 2 > Descriptors
 Local descriptors.
 

Detailed Description

An emitter which links the program to bytecode for later use.

Definition at line 26 of file ByteCodeEmitter.h.

Member Typedef Documentation

◆ AddrTy

Definition at line 29 of file ByteCodeEmitter.h.

◆ LabelTy

using clang::interp::ByteCodeEmitter::LabelTy = uint32_t
protected

Definition at line 28 of file ByteCodeEmitter.h.

◆ Local

Definition at line 30 of file ByteCodeEmitter.h.

Constructor & Destructor Documentation

◆ ByteCodeEmitter()

clang::interp::ByteCodeEmitter::ByteCodeEmitter ( Context Ctx,
Program P 
)
inlineprotected

Definition at line 38 of file ByteCodeEmitter.h.

References P.

◆ ~ByteCodeEmitter()

virtual clang::interp::ByteCodeEmitter::~ByteCodeEmitter ( )
inlineprotectedvirtual

Definition at line 40 of file ByteCodeEmitter.h.

Member Function Documentation

◆ compileFunc()

Function * ByteCodeEmitter::compileFunc ( const FunctionDecl FuncDecl)

◆ compileObjCBlock()

Function * ByteCodeEmitter::compileObjCBlock ( const BlockExpr BE)

Compile an ObjC block, i.e.

^(){}, that thing.

FIXME: We do not support calling the block though, so we create a function here but do not compile any code for it.

Definition at line 202 of file ByteCodeEmitter.cpp.

References clang::interp::align(), clang::interp::Context::classify(), clang::interp::Program::createDescriptor(), clang::interp::Program::createFunction(), clang::Func, clang::BlockExpr::getBlockDecl(), clang::BlockDecl::hasCaptures(), clang::BlockDecl::parameters(), Params, clang::interp::primSize(), clang::interp::PT_Ptr, and clang::T.

◆ createLocal()

Scope::Local ByteCodeEmitter::createLocal ( Descriptor D)
protected

Callback for local registration.

Definition at line 240 of file ByteCodeEmitter.cpp.

References clang::interp::align(), and D.

◆ emitLabel()

void ByteCodeEmitter::emitLabel ( LabelTy  Label)
protected

Define a label.

Definition at line 247 of file ByteCodeEmitter.cpp.

References clang::interp::align(), clang::interp::aligned(), and Label.

Referenced by fallthrough().

◆ fallthrough()

bool ByteCodeEmitter::fallthrough ( const LabelTy Label)
protected

Definition at line 377 of file ByteCodeEmitter.cpp.

References emitLabel(), and Label.

◆ getLabel()

LabelTy clang::interp::ByteCodeEmitter::getLabel ( )
inlineprotected

Create a label.

Definition at line 45 of file ByteCodeEmitter.h.

◆ isActive()

bool clang::interp::ByteCodeEmitter::isActive ( ) const
inlineprotected

We're always emitting bytecode.

Definition at line 59 of file ByteCodeEmitter.h.

◆ jump()

bool ByteCodeEmitter::jump ( const LabelTy Label)
protected

Definition at line 373 of file ByteCodeEmitter.cpp.

References Label.

◆ jumpFalse()

bool ByteCodeEmitter::jumpFalse ( const LabelTy Label)
protected

Definition at line 369 of file ByteCodeEmitter.cpp.

References Label.

◆ jumpTrue()

bool ByteCodeEmitter::jumpTrue ( const LabelTy Label)
protected

Emits jumps.

Definition at line 365 of file ByteCodeEmitter.cpp.

References Label.

◆ visitDeclAndReturn()

virtual bool clang::interp::ByteCodeEmitter::visitDeclAndReturn ( const VarDecl E,
bool  ConstantContext 
)
protectedpure virtual

◆ visitExpr()

virtual bool clang::interp::ByteCodeEmitter::visitExpr ( const Expr E)
protectedpure virtual

◆ visitFunc()

virtual bool clang::interp::ByteCodeEmitter::visitFunc ( const FunctionDecl E)
protectedpure virtual

Methods implemented by the compiler.

Referenced by compileFunc().

Member Data Documentation

◆ Descriptors

llvm::SmallVector<SmallVector<Local, 8>, 2> clang::interp::ByteCodeEmitter::Descriptors
protected

Local descriptors.

Definition at line 71 of file ByteCodeEmitter.h.

Referenced by compileFunc().

◆ LambdaCaptures

llvm::DenseMap<const ValueDecl *, ParamOffset> clang::interp::ByteCodeEmitter::LambdaCaptures
protected

Lambda captures.

Definition at line 67 of file ByteCodeEmitter.h.

Referenced by compileFunc().

◆ LambdaThisCapture

ParamOffset clang::interp::ByteCodeEmitter::LambdaThisCapture {0, false}
protected

Offset of the This parameter in a lambda record.

Definition at line 69 of file ByteCodeEmitter.h.

Referenced by compileFunc().

◆ Params

llvm::DenseMap<const ParmVarDecl *, ParamOffset> clang::interp::ByteCodeEmitter::Params
protected

Parameter indices.

Definition at line 65 of file ByteCodeEmitter.h.

Referenced by compileFunc(), and compileObjCBlock().


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