class ByteCodeExprGen
Declaration
template <class Emitter>
class ByteCodeExprGen { /* full declaration omitted */ };
Description
Compilation context for expressions.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:40
Templates
- Emitter
Member Variables
- protected clang::interp::Context& Ctx
- Current compilation context.
- protected clang::interp::Program& P
- Program to link to.
- protected llvm::DenseMap<const ValueDecl*, Scope::Local> Locals
- Variable to storage mapping.
- protected llvm::DenseMap<const OpaqueValueExpr*, unsigned int> OpaqueExprs
- OpaqueValueExpr to location mapping.
- protected VariableScope<Emitter>* VarScope = nullptr
- Current scope.
- protected llvm::Optional<uint64_t> ArrayIndex
- Current argument index.
- protected bool DiscardResult = false
- Flag indicating if return value is to be discarded.
- protected llvm::Optional<InitFnRef> InitFn = {}
- Expression being initialized.
Method Overview
- public template <typename... Tys> ByteCodeExprGen<Emitter>(clang::interp::Context & Ctx, clang::interp::Program & P, Tys &&... Args)
- public bool VisitBinaryOperator(const clang::BinaryOperator * E)
- public bool VisitCastExpr(const clang::CastExpr * E)
- public bool VisitIntegerLiteral(const clang::IntegerLiteral * E)
- public bool VisitParenExpr(const clang::ParenExpr * E)
- protected llvm::Optional<unsigned int> allocateLocal(clang::interp::DeclTy && Decl, bool IsExtended = false)
- protected unsigned int allocateLocalPrimitive(clang::interp::DeclTy && Decl, clang::interp::PrimType Ty, bool IsMutable, bool IsExtended = false)
- protected llvm::Optional<PrimType> classify(clang::QualType Ty) const
- protected llvm::Optional<PrimType> classify(const clang::Expr * E) const
- protected clang::interp::PrimType classifyPrim(clang::QualType Ty) const
- private bool dereference(const clang::Expr * LV, clang::interp::ByteCodeExprGen::DerefKind AK, llvm::function_ref<bool (PrimType)> Direct, llvm::function_ref<bool (PrimType)> Indirect)
- private bool dereferenceParam(const clang::Expr * LV, clang::interp::PrimType T, const clang::ParmVarDecl * PD, clang::interp::ByteCodeExprGen::DerefKind AK, llvm::function_ref<bool (PrimType)> Direct, llvm::function_ref<bool (PrimType)> Indirect)
- private bool dereferenceVar(const clang::Expr * LV, clang::interp::PrimType T, const clang::VarDecl * PD, clang::interp::ByteCodeExprGen::DerefKind AK, llvm::function_ref<bool (PrimType)> Direct, llvm::function_ref<bool (PrimType)> Indirect)
- protected bool discard(const clang::Expr * E)
- protected void emitCleanup()
- private template <typename T>bool emitConst(const clang::Expr * E, T Value)
- private bool emitConst(clang::interp::PrimType T, unsigned int NumBits, const llvm::APInt & Value, const clang::Expr * E)
- private bool emitInitFn()
- protected unsigned int getCharBit() const
- private llvm::Optional<unsigned int> getGlobalIdx(const clang::VarDecl * VD)
- protected unsigned int getIntWidth(clang::QualType Ty)
- private bool getPtrVarDecl(const clang::VarDecl * VD, const clang::Expr * E)
- protected clang::interp::Record * getRecord(const clang::RecordDecl * RD)
- protected clang::interp::Record * getRecord(clang::QualType Ty)
- protected const clang::RecordType * getRecordTy(clang::QualType Ty)
- protected bool needsAdjust(clang::QualType Ty) const
- protected bool visit(const clang::Expr * E)
- protected bool visitBool(const clang::Expr * E)
- protected bool visitDecl(const clang::VarDecl * VD)
- protected bool visitExpr(const clang::Expr * E)
- protected bool visitGlobalInitializer(const clang::Expr * Init, unsigned int I)
- protected bool visitInitializer(const clang::Expr * E, clang::interp::ByteCodeExprGen::InitFnRef GenPtr)
- protected bool visitLocalInitializer(const clang::Expr * Init, unsigned int I)
- protected bool visitThisInitializer(const clang::Expr * I)
- private bool visitZeroInitializer(clang::interp::PrimType T, const clang::Expr * E)
Methods
¶template <typename... Tys>
ByteCodeExprGen<Emitter>(
clang::interp::Context& Ctx,
clang::interp::Program& P,
Tys&&... Args)
template <typename... Tys>
ByteCodeExprGen<Emitter>(
clang::interp::Context& Ctx,
clang::interp::Program& P,
Tys&&... Args)
Description
Initializes the compiler and the backend emitter.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:64
Templates
- Tys
Parameters
- clang::interp::Context& Ctx
- clang::interp::Program& P
- Tys&&... Args
¶bool VisitBinaryOperator(
const clang::BinaryOperator* E)
bool VisitBinaryOperator(
const clang::BinaryOperator* E)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:71
Parameters
- const clang::BinaryOperator* E
¶bool VisitCastExpr(const clang::CastExpr* E)
bool VisitCastExpr(const clang::CastExpr* E)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:68
Parameters
- const clang::CastExpr* E
¶bool VisitIntegerLiteral(
const clang::IntegerLiteral* E)
bool VisitIntegerLiteral(
const clang::IntegerLiteral* E)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:69
Parameters
- const clang::IntegerLiteral* E
¶bool VisitParenExpr(const clang::ParenExpr* E)
bool VisitParenExpr(const clang::ParenExpr* E)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:70
Parameters
- const clang::ParenExpr* E
¶llvm::Optional<unsigned int> allocateLocal(
clang::interp::DeclTy&& Decl,
bool IsExtended = false)
llvm::Optional<unsigned int> allocateLocal(
clang::interp::DeclTy&& Decl,
bool IsExtended = false)
Description
Allocates a space storing a local given its type.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:155
Parameters
- clang::interp::DeclTy&& Decl
- bool IsExtended = false
¶unsigned int allocateLocalPrimitive(
clang::interp::DeclTy&& Decl,
clang::interp::PrimType Ty,
bool IsMutable,
bool IsExtended = false)
unsigned int allocateLocalPrimitive(
clang::interp::DeclTy&& Decl,
clang::interp::PrimType Ty,
bool IsMutable,
bool IsExtended = false)
Description
Creates a local primitive value.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:151
Parameters
- clang::interp::DeclTy&& Decl
- clang::interp::PrimType Ty
- bool IsMutable
- bool IsExtended = false
¶llvm::Optional<PrimType> classify(
clang::QualType Ty) const
llvm::Optional<PrimType> classify(
clang::QualType Ty) const
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:104
Parameters
¶llvm::Optional<PrimType> classify(
const clang::Expr* E) const
llvm::Optional<PrimType> classify(
const clang::Expr* E) const
Description
Classifies a type.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:101
Parameters
- const clang::Expr* E
¶clang::interp::PrimType classifyPrim(
clang::QualType Ty) const
clang::interp::PrimType classifyPrim(
clang::QualType Ty) const
Description
Classifies a known primitive type
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:114
Parameters
¶bool dereference(
const clang::Expr* LV,
clang::interp::ByteCodeExprGen::DerefKind AK,
llvm::function_ref<bool(PrimType)> Direct,
llvm::function_ref<bool(PrimType)> Indirect)
bool dereference(
const clang::Expr* LV,
clang::interp::ByteCodeExprGen::DerefKind AK,
llvm::function_ref<bool(PrimType)> Direct,
llvm::function_ref<bool(PrimType)> Indirect)
Description
Method to directly load a value. If the value can be fetched directly, the direct handler is called. Otherwise, a pointer is left on the stack and the indirect handler is expected to operate on that.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:180
Parameters
- const clang::Expr* LV
- clang::interp::ByteCodeExprGen::DerefKind AK
- llvm::function_ref<bool(PrimType)> Direct
- llvm::function_ref<bool(PrimType)> Indirect
¶bool dereferenceParam(
const clang::Expr* LV,
clang::interp::PrimType T,
const clang::ParmVarDecl* PD,
clang::interp::ByteCodeExprGen::DerefKind AK,
llvm::function_ref<bool(PrimType)> Direct,
llvm::function_ref<bool(PrimType)> Indirect)
bool dereferenceParam(
const clang::Expr* LV,
clang::interp::PrimType T,
const clang::ParmVarDecl* PD,
clang::interp::ByteCodeExprGen::DerefKind AK,
llvm::function_ref<bool(PrimType)> Direct,
llvm::function_ref<bool(PrimType)> Indirect)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:183
Parameters
- const clang::Expr* LV
- clang::interp::PrimType T
- const clang::ParmVarDecl* PD
- clang::interp::ByteCodeExprGen::DerefKind AK
- llvm::function_ref<bool(PrimType)> Direct
- llvm::function_ref<bool(PrimType)> Indirect
¶bool dereferenceVar(
const clang::Expr* LV,
clang::interp::PrimType T,
const clang::VarDecl* PD,
clang::interp::ByteCodeExprGen::DerefKind AK,
llvm::function_ref<bool(PrimType)> Direct,
llvm::function_ref<bool(PrimType)> Indirect)
bool dereferenceVar(
const clang::Expr* LV,
clang::interp::PrimType T,
const clang::VarDecl* PD,
clang::interp::ByteCodeExprGen::DerefKind AK,
llvm::function_ref<bool(PrimType)> Direct,
llvm::function_ref<bool(PrimType)> Indirect)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:187
Parameters
- const clang::Expr* LV
- clang::interp::PrimType T
- const clang::VarDecl* PD
- clang::interp::ByteCodeExprGen::DerefKind AK
- llvm::function_ref<bool(PrimType)> Direct
- llvm::function_ref<bool(PrimType)> Indirect
¶bool discard(const clang::Expr* E)
bool discard(const clang::Expr* E)
Description
Evaluates an expression for side effects and discards the result.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:122
Parameters
- const clang::Expr* E
¶void emitCleanup()
void emitCleanup()
Description
Emits scope cleanup instructions.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:79
¶template <typename T>
bool emitConst(const clang::Expr* E, T Value)
template <typename T>
bool emitConst(const clang::Expr* E, T Value)
Description
Emits an integer constant.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:196
Templates
- T
Parameters
- const clang::Expr* E
- T Value
¶bool emitConst(clang::interp::PrimType T,
unsigned int NumBits,
const llvm::APInt& Value,
const clang::Expr* E)
bool emitConst(clang::interp::PrimType T,
unsigned int NumBits,
const llvm::APInt& Value,
const clang::Expr* E)
Description
Emits an APInt constant.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:192
Parameters
- clang::interp::PrimType T
- unsigned int NumBits
- const llvm::APInt& Value
- const clang::Expr* E
¶bool emitInitFn()
bool emitInitFn()
Description
Emits the initialized pointer.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:210
¶unsigned int getCharBit() const
unsigned int getCharBit() const
Description
Returns the value of CHAR_BIT.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:95
¶llvm::Optional<unsigned int> getGlobalIdx(
const clang::VarDecl* VD)
llvm::Optional<unsigned int> getGlobalIdx(
const clang::VarDecl* VD)
Description
Returns the index of a global.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:207
Parameters
- const clang::VarDecl* VD
¶unsigned int getIntWidth(clang::QualType Ty)
unsigned int getIntWidth(clang::QualType Ty)
Description
Returns the size int bits of an integer.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:89
Parameters
¶bool getPtrVarDecl(const clang::VarDecl* VD,
const clang::Expr* E)
bool getPtrVarDecl(const clang::VarDecl* VD,
const clang::Expr* E)
Description
Returns a pointer to a variable declaration.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:204
Parameters
- const clang::VarDecl* VD
- const clang::Expr* E
¶clang::interp::Record* getRecord(
const clang::RecordDecl* RD)
clang::interp::Record* getRecord(
const clang::RecordDecl* RD)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:86
Parameters
- const clang::RecordDecl* RD
¶clang::interp::Record* getRecord(
clang::QualType Ty)
clang::interp::Record* getRecord(
clang::QualType Ty)
Description
Returns a record from a record or pointer type.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:85
Parameters
¶const clang::RecordType* getRecordTy(
clang::QualType Ty)
const clang::RecordType* getRecordTy(
clang::QualType Ty)
Description
Returns a record type from a record or pointer type.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:82
Parameters
¶bool needsAdjust(clang::QualType Ty) const
bool needsAdjust(clang::QualType Ty) const
Description
Checks if a pointer needs adjustment.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:109
Parameters
¶bool visit(const clang::Expr* E)
bool visit(const clang::Expr* E)
Description
Evaluates an expression and places result on stack.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:124
Parameters
- const clang::Expr* E
¶bool visitBool(const clang::Expr* E)
bool visitBool(const clang::Expr* E)
Description
Visits an expression and converts it to a boolean.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:129
Parameters
- const clang::Expr* E
¶bool visitDecl(const clang::VarDecl* VD)
bool visitDecl(const clang::VarDecl* VD)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:75
Parameters
- const clang::VarDecl* VD
¶bool visitExpr(const clang::Expr* E)
bool visitExpr(const clang::Expr* E)
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:74
Parameters
- const clang::Expr* E
¶bool visitGlobalInitializer(
const clang::Expr* Init,
unsigned int I)
bool visitGlobalInitializer(
const clang::Expr* Init,
unsigned int I)
Description
Visits an initializer for a global.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:139
Parameters
- const clang::Expr* Init
- unsigned int I
¶bool visitInitializer(
const clang::Expr* E,
clang::interp::ByteCodeExprGen::InitFnRef
GenPtr)
bool visitInitializer(
const clang::Expr* E,
clang::interp::ByteCodeExprGen::InitFnRef
GenPtr)
Description
Compiles an initializer for a local.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:126
Parameters
- const clang::Expr* E
- clang::interp::ByteCodeExprGen::InitFnRef GenPtr
¶bool visitLocalInitializer(
const clang::Expr* Init,
unsigned int I)
bool visitLocalInitializer(
const clang::Expr* Init,
unsigned int I)
Description
Visits an initializer for a local.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:132
Parameters
- const clang::Expr* Init
- unsigned int I
¶bool visitThisInitializer(const clang::Expr* I)
bool visitThisInitializer(const clang::Expr* I)
Description
Visits a delegated initializer.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:146
Parameters
- const clang::Expr* I
¶bool visitZeroInitializer(
clang::interp::PrimType T,
const clang::Expr* E)
bool visitZeroInitializer(
clang::interp::PrimType T,
const clang::Expr* E)
Description
Emits a zero initializer.
Declared at: clang/lib/AST/Interp/ByteCodeExprGen.h:166
Parameters
- clang::interp::PrimType T
- const clang::Expr* E