clang 22.0.0git
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

void compileFunc (const FunctionDecl *FuncDecl, Function *Func=nullptr)
 Compiles the function into the module.

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, bool DestroyToplevelScope)=0
virtual bool visitDeclAndReturn (const VarDecl *E, bool ConstantContext)=0
virtual bool visit (const Expr *E)=0
virtual bool emitBool (bool V, const Expr *E)=0
bool jumpTrue (const LabelTy &Label)
 Emits jumps.
bool jumpFalse (const LabelTy &Label)
bool jump (const LabelTy &Label)
bool fallthrough (const LabelTy &Label)
bool speculate (const CallExpr *E, const LabelTy &EndLabel)
 Speculative execution.
bool isActive () const
 We're always emitting bytecode.
bool checkingForUndefinedBehavior () const
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.
std::optional< SourceInfoLocOverride = std::nullopt

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 37 of file ByteCodeEmitter.h.

◆ ~ByteCodeEmitter()

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

Definition at line 39 of file ByteCodeEmitter.h.

Member Function Documentation

◆ checkingForUndefinedBehavior()

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

Definition at line 63 of file ByteCodeEmitter.h.

◆ compileFunc()

◆ createLocal()

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

Callback for local registration.

Definition at line 95 of file ByteCodeEmitter.cpp.

References clang::interp::align(), and clang::interp::Descriptor::getAllocSize().

◆ emitBool()

virtual bool clang::interp::ByteCodeEmitter::emitBool ( bool V,
const Expr * E )
protectedpure virtual

References V.

◆ emitLabel()

void ByteCodeEmitter::emitLabel ( LabelTy Label)
protected

Define a label.

Definition at line 102 of file ByteCodeEmitter.cpp.

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

Referenced by fallthrough().

◆ fallthrough()

bool ByteCodeEmitter::fallthrough ( const LabelTy & Label)
protected

Definition at line 240 of file ByteCodeEmitter.cpp.

References emitLabel().

◆ getLabel()

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

Create a label.

Definition at line 44 of file ByteCodeEmitter.h.

◆ isActive()

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

We're always emitting bytecode.

Definition at line 62 of file ByteCodeEmitter.h.

◆ jump()

bool ByteCodeEmitter::jump ( const LabelTy & Label)
protected

Definition at line 236 of file ByteCodeEmitter.cpp.

◆ jumpFalse()

bool ByteCodeEmitter::jumpFalse ( const LabelTy & Label)
protected

Definition at line 232 of file ByteCodeEmitter.cpp.

◆ jumpTrue()

bool ByteCodeEmitter::jumpTrue ( const LabelTy & Label)
protected

Emits jumps.

Definition at line 228 of file ByteCodeEmitter.cpp.

◆ speculate()

bool ByteCodeEmitter::speculate ( const CallExpr * E,
const LabelTy & EndLabel )
protected

Speculative execution.

Definition at line 245 of file ByteCodeEmitter.cpp.

References clang::CallExpr::getArg(), clang::Expr::getType(), clang::interp::PT_Ptr, clang::T, and visit().

◆ visit()

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

Referenced by speculate().

◆ visitDeclAndReturn()

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

◆ visitExpr()

virtual bool clang::interp::ByteCodeEmitter::visitExpr ( const Expr * E,
bool DestroyToplevelScope )
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 75 of file ByteCodeEmitter.h.

Referenced by compileFunc().

◆ LambdaCaptures

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

Lambda captures.

Definition at line 71 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 73 of file ByteCodeEmitter.h.

Referenced by compileFunc().

◆ LocOverride

std::optional<SourceInfo> clang::interp::ByteCodeEmitter::LocOverride = std::nullopt
protected

Definition at line 76 of file ByteCodeEmitter.h.

◆ Params

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

Parameter indices.

Definition at line 69 of file ByteCodeEmitter.h.

Referenced by compileFunc().


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