clang 20.0.0git
|
An emitter which links the program to bytecode for later use. More...
Public Member Functions | |
Function * | compileFunc (const FunctionDecl *FuncDecl) |
Compiles the function into the module. | |
Function * | compileObjCBlock (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, bool DestroyToplevelScope)=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 *, 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. | |
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 38 of file ByteCodeEmitter.h.
References P.
|
inlineprotectedvirtual |
Definition at line 40 of file ByteCodeEmitter.h.
Function * ByteCodeEmitter::compileFunc | ( | const FunctionDecl * | FuncDecl | ) |
Compiles the function into the module.
Definition at line 23 of file ByteCodeEmitter.cpp.
References clang::interp::align(), clang::TemplateArgumentList::asArray(), clang::CXXRecordDecl::captures_begin(), clang::CXXRecordDecl::captures_end(), clang::interp::Context::classify(), clang::interp::Program::createDescriptor(), clang::interp::Program::createFunction(), clang::interp::Record::Field::Decl, Descriptors, clang::FunctionTemplateDecl::findSpecialization(), clang::Func, clang::FunctionDecl::getBuiltinID(), clang::FunctionDecl::getDescribedFunctionTemplate(), clang::interp::Record::getField(), clang::interp::Program::getFunction(), clang::CXXRecordDecl::getLambdaCallOperator(), clang::interp::Program::getOrCreateRecord(), clang::DeclContext::getParent(), clang::FieldDecl::getParent(), clang::FunctionDecl::getReturnType(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::FunctionDecl::hasBody(), clang::FunctionDecl::isConstexpr(), clang::FunctionDecl::isDefined(), clang::CXXRecordDecl::isGenericLambda(), clang::isLambdaCallOperator(), clang::Type::isPointerType(), clang::Type::isReferenceType(), clang::Type::isVoidType(), LambdaCaptures, LambdaThisCapture, clang::interp::Record::Field::Offset, clang::FunctionDecl::param_begin(), clang::FunctionDecl::param_empty(), clang::FunctionDecl::parameters(), Params, clang::interp::primSize(), clang::interp::PT_Ptr, clang::T, visitFunc(), and clang::FunctionDecl::willHaveBody().
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 187 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.
|
protected |
Callback for local registration.
Definition at line 225 of file ByteCodeEmitter.cpp.
References clang::interp::align(), and D.
|
protected |
Define a label.
Definition at line 232 of file ByteCodeEmitter.cpp.
References clang::interp::align(), clang::interp::aligned(), and Label.
Referenced by fallthrough().
Definition at line 362 of file ByteCodeEmitter.cpp.
References emitLabel(), and Label.
|
inlineprotected |
Create a label.
Definition at line 45 of file ByteCodeEmitter.h.
|
inlineprotected |
We're always emitting bytecode.
Definition at line 59 of file ByteCodeEmitter.h.
Definition at line 358 of file ByteCodeEmitter.cpp.
References Label.
Definition at line 354 of file ByteCodeEmitter.cpp.
References Label.
|
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 69 of file ByteCodeEmitter.h.
Referenced by compileFunc().
|
protected |
Parameter indices.
Definition at line 65 of file ByteCodeEmitter.h.
Referenced by compileFunc(), and compileObjCBlock().