clang 22.0.0git
|
An emitter which links the program to bytecode for later use. More...
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 *, ParamOffset > | Params |
Parameter indices. | |
llvm::DenseMap< const ValueDecl *, ParamOffset > | LambdaCaptures |
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< SourceInfo > | LocOverride = std::nullopt |
An emitter which links the program to bytecode for later use.
Definition at line 26 of file ByteCodeEmitter.h.
|
protected |
Definition at line 29 of file ByteCodeEmitter.h.
|
protected |
Definition at line 28 of file ByteCodeEmitter.h.
|
protected |
Definition at line 30 of file ByteCodeEmitter.h.
Definition at line 37 of file ByteCodeEmitter.h.
|
inlineprotectedvirtual |
Definition at line 39 of file ByteCodeEmitter.h.
|
inlineprotected |
Definition at line 63 of file ByteCodeEmitter.h.
void ByteCodeEmitter::compileFunc | ( | const FunctionDecl * | FuncDecl, |
Function * | Func = nullptr ) |
Compiles the function into the module.
Definition at line 23 of file ByteCodeEmitter.cpp.
References clang::interp::Record::Field::Decl, Descriptors, clang::Func, clang::interp::Record::getField(), clang::FieldDecl::getParent(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::FunctionDecl::hasBody(), clang::FunctionDecl::isConstexpr(), clang::FunctionDecl::isDefined(), clang::isLambdaCallOperator(), clang::Type::isPointerOrReferenceType(), LambdaCaptures, LambdaThisCapture, clang::interp::Record::Field::Offset, clang::FunctionDecl::param_begin(), clang::FunctionDecl::param_empty(), clang::FunctionDecl::parameters(), Params, clang::T, and visitFunc().
|
protected |
Callback for local registration.
Definition at line 95 of file ByteCodeEmitter.cpp.
References clang::interp::align(), and clang::interp::Descriptor::getAllocSize().
|
protectedpure virtual |
References V.
|
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().
Definition at line 240 of file ByteCodeEmitter.cpp.
References emitLabel().
|
inlineprotected |
Create a label.
Definition at line 44 of file ByteCodeEmitter.h.
|
inlineprotected |
We're always emitting bytecode.
Definition at line 62 of file ByteCodeEmitter.h.
Definition at line 236 of file ByteCodeEmitter.cpp.
Definition at line 232 of file ByteCodeEmitter.cpp.
Emits jumps.
Definition at line 228 of file ByteCodeEmitter.cpp.
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().
Referenced by speculate().
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
Methods implemented by the compiler.
Referenced by compileFunc().
|
protected |
|
protected |
|
protected |
Offset of the This parameter in a lambda record.
Definition at line 73 of file ByteCodeEmitter.h.
Referenced by compileFunc().
|
protected |
Definition at line 76 of file ByteCodeEmitter.h.
|
protected |